From afa35111a444890d57c0228d8213d38c606f9b60 Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 13 May 2013 15:37:14 -0400 Subject: Map connection wram labels --- wram.asm | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/wram.asm b/wram.asm index f462d611f..bc43ab9be 100644 --- a/wram.asm +++ b/wram.asm @@ -1030,7 +1030,37 @@ PartyMenuActionText ; d141 CurPartyLevel: ; d143 ds 1 - ds 149 + +SECTION "connections",BSS[$d1a9] + +MapConnections: ; d1a9 +MapConnectionNorth: ; d1a9 +ConnectedMapGroup: ; d1a9 + ds 1 +ConnectedMapNumber: ; d1aa + ds 1 +ConnectionStripPointer: ; d1ab + ds 2 +ConnectionStripLocation: ; d1ad + ds 2 +ConnectionStripLength: ; d1af + ds 1 +ConnectedMapWidth: ; d1b0 + ds 1 +ConnectionStripXOffset: ; d1b1 + ds 1 +ConnectionStripYOffset: ; d1b2 + ds 1 +ConnectionWindow: ; d1b3 + ds 2 + +MapConnectionSouth: ; d1b5 + ds 12 +MapConnectionWest:; d1c1 + ds 12 +MapConnectionEast: ; d1cd + ds 12 + TileSetHeader: TileSetBank: ; d1d9 -- cgit v1.2.3 From 6464df7b1175570c7e2d96a723dff4b20a01fe6a Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 13 May 2013 15:41:09 -0400 Subject: GetMapConnection --- main.asm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/main.asm b/main.asm index 99f2b1af2..2c46c1d98 100644 --- a/main.asm +++ b/main.asm @@ -2493,7 +2493,25 @@ UpdateGameTimer: ; 20ad ret ; 210f -INCBIN "baserom.gbc", $210f, $261f - $210f + +INCBIN "baserom.gbc", $210f, $23a3 - $210f + + +GetMapConnection: ; 23a3 +; Load map connection struct at hl into de. + ld c, MapConnectionSouth - MapConnectionNorth +.loop + ld a, [hli] + ld [de], a + inc de + dec c + jr nz, .loop + ret +; 23ac + + +INCBIN "baserom.gbc", $23ac, $261f - $23ac + PushScriptPointer: ; 261f ; used to call a script from asm -- cgit v1.2.3 From db84ec18d994ded86b4f34eaf280421414d9c119 Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 13 May 2013 18:40:33 -0400 Subject: connection wram labels for each direction --- main.asm | 2 +- wram.asm | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 72 insertions(+), 18 deletions(-) diff --git a/main.asm b/main.asm index 2c46c1d98..d0d55e191 100644 --- a/main.asm +++ b/main.asm @@ -2499,7 +2499,7 @@ INCBIN "baserom.gbc", $210f, $23a3 - $210f GetMapConnection: ; 23a3 ; Load map connection struct at hl into de. - ld c, MapConnectionSouth - MapConnectionNorth + ld c, SouthMapConnection - NorthMapConnection .loop ld a, [hli] ld [de], a diff --git a/wram.asm b/wram.asm index bc43ab9be..1cc6c0c8d 100644 --- a/wram.asm +++ b/wram.asm @@ -1033,33 +1033,87 @@ CurPartyLevel: ; d143 SECTION "connections",BSS[$d1a9] -MapConnections: ; d1a9 -MapConnectionNorth: ; d1a9 -ConnectedMapGroup: ; d1a9 +MapConnections: + +NorthMapConnection: ; d1a9 +NorthConnectedMapGroup: ; d1a9 ds 1 -ConnectedMapNumber: ; d1aa +NorthConnectedMapNumber: ; d1aa ds 1 -ConnectionStripPointer: ; d1ab +NorthConnectionStripPointer: ; d1ab ds 2 -ConnectionStripLocation: ; d1ad +NorthConnectionStripLocation: ; d1ad ds 2 -ConnectionStripLength: ; d1af +NorthConnectionStripLength: ; d1af ds 1 -ConnectedMapWidth: ; d1b0 +NorthConnectedMapWidth: ; d1b0 ds 1 -ConnectionStripXOffset: ; d1b1 +NorthConnectionStripXOffset: ; d1b1 ds 1 -ConnectionStripYOffset: ; d1b2 +NorthConnectionStripYOffset: ; d1b2 ds 1 -ConnectionWindow: ; d1b3 +NorthConnectionWindow: ; d1b3 ds 2 -MapConnectionSouth: ; d1b5 - ds 12 -MapConnectionWest:; d1c1 - ds 12 -MapConnectionEast: ; d1cd - ds 12 +SouthMapConnection: ; d1b5 +SouthConnectedMapGroup: ; d1b5 + ds 1 +SouthConnectedMapNumber: ; d1b6 + ds 1 +SouthConnectionStripPointer: ; d1b7 + ds 2 +SouthConnectionStripLocation: ; d1b9 + ds 2 +SouthConnectionStripLength: ; d1bb + ds 1 +SouthConnectedMapWidth: ; d1bc + ds 1 +SouthConnectionStripXOffset: ; d1bd + ds 1 +SouthConnectionStripYOffset: ; d1be + ds 1 +SouthConnectionWindow: ; d1bf + ds 2 + +WestMapConnection: ; d1c1 +WestConnectedMapGroup: ; d1c1 + ds 1 +WestConnectedMapNumber: ; d1c2 + ds 1 +WestConnectionStripPointer: ; d1c3 + ds 2 +WestConnectionStripLocation: ; d1c5 + ds 2 +WestConnectionStripLength: ; d1c7 + ds 1 +WestConnectedMapWidth: ; d1c8 + ds 1 +WestConnectionStripXOffset: ; d1c9 + ds 1 +WestConnectionStripYOffset: ; d1ca + ds 1 +WestConnectionWindow: ; d1cb + ds 2 + +EastMapConnection: ; d1cd +EastConnectedMapGroup: ; d1cd + ds 1 +EastConnectedMapNumber: ; d1ce + ds 1 +EastConnectionStripPointer: ; d1cf + ds 2 +EastConnectionStripLocation: ; d1d1 + ds 2 +EastConnectionStripLength: ; d1d3 + ds 1 +EastConnectedMapWidth: ; d1d4 + ds 1 +EastConnectionStripXOffset: ; d1d5 + ds 1 +EastConnectionStripYOffset: ; d1d6 + ds 1 +EastConnectionWindow: ; d1d7 + ds 2 TileSetHeader: -- cgit v1.2.3 From 91ebc0836bf8f1ef7dca95229d77fe9714514415 Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 13 May 2013 18:43:34 -0400 Subject: connection hram labels --- hram.asm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hram.asm b/hram.asm index bfab6e295..4bbd5ddb2 100644 --- a/hram.asm +++ b/hram.asm @@ -24,6 +24,9 @@ hJoyReleased EQU $ffa6 hJoyPressed EQU $ffa7 hJoyDown EQU $ffa8 +hConnectionStripLength EQU $ffaf +hConnectedMapWidth EQU $ffb0 + hPastLeadingZeroes EQU $ffb3 hDividend EQU $ffb3 -- cgit v1.2.3 From ceb4c138db1e3db6b44eb44ebb83406936f5aa0f Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 13 May 2013 18:44:01 -0400 Subject: FillMapConnections --- main.asm | 181 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 180 insertions(+), 1 deletion(-) diff --git a/main.asm b/main.asm index d0d55e191..a91f04942 100644 --- a/main.asm +++ b/main.asm @@ -2510,7 +2510,186 @@ GetMapConnection: ; 23a3 ; 23ac -INCBIN "baserom.gbc", $23ac, $261f - $23ac +INCBIN "baserom.gbc", $23ac, $2524 - $23ac + + +FillMapConnections: ; 2524 + +; North + ld a, [NorthConnectedMapGroup] + cp $ff + jr z, .South + ld b, a + ld a, [NorthConnectedMapNumber] + ld c, a + call $2c5b + + ld a, [NorthConnectionStripPointer] + ld l, a + ld a, [NorthConnectionStripPointer + 1] + ld h, a + ld a, [NorthConnectionStripLocation] + ld e, a + ld a, [NorthConnectionStripLocation + 1] + ld d, a + ld a, [NorthConnectionStripLength] + ld [hConnectionStripLength], a + ld a, [NorthConnectedMapWidth] + ld [hConnectedMapWidth], a + call FillNorthConnectionStrip + +.South + ld a, [SouthConnectedMapGroup] + cp $ff + jr z, .West + ld b, a + ld a, [SouthConnectedMapNumber] + ld c, a + call $2c5b + + ld a, [SouthConnectionStripPointer] + ld l, a + ld a, [SouthConnectionStripPointer + 1] + ld h, a + ld a, [SouthConnectionStripLocation] + ld e, a + ld a, [SouthConnectionStripLocation + 1] + ld d, a + ld a, [SouthConnectionStripLength] + ld [hConnectionStripLength], a + ld a, [SouthConnectedMapWidth] + ld [hConnectedMapWidth], a + call FillSouthConnectionStrip + +.West + ld a, [WestConnectedMapGroup] + cp $ff + jr z, .East + ld b, a + ld a, [WestConnectedMapNumber] + ld c, a + call $2c5b + + ld a, [WestConnectionStripPointer] + ld l, a + ld a, [WestConnectionStripPointer + 1] + ld h, a + ld a, [WestConnectionStripLocation] + ld e, a + ld a, [WestConnectionStripLocation + 1] + ld d, a + ld a, [WestConnectionStripLength] + ld b, a + ld a, [WestConnectedMapWidth] + ld [hConnectionStripLength], a + call FillWestConnectionStrip + +.East + ld a, [EastConnectedMapGroup] + cp $ff + jr z, .Done + ld b, a + ld a, [EastConnectedMapNumber] + ld c, a + call $2c5b + + ld a, [EastConnectionStripPointer] + ld l, a + ld a, [EastConnectionStripPointer + 1] + ld h, a + ld a, [EastConnectionStripLocation] + ld e, a + ld a, [EastConnectionStripLocation + 1] + ld d, a + ld a, [EastConnectionStripLength] + ld b, a + ld a, [EastConnectedMapWidth] + ld [hConnectionStripLength], a + call FillEastConnectionStrip + +.Done + ret +; 25d3 + + +FillNorthConnectionStrip: +FillSouthConnectionStrip: ; 25d3 + + ld c, 3 +.y + push de + + push hl + ld a, [hConnectionStripLength] + ld b, a +.x + ld a, [hli] + ld [de], a + inc de + dec b + jr nz, .x + pop hl + + ld a, [hConnectedMapWidth] + ld e, a + ld d, 0 + add hl, de + pop de + + ld a, [$d19f] + add 6 + add e + ld e, a + jr nc, .asm_25f2 + inc d +.asm_25f2 + dec c + jr nz, .y + ret +; 25f6 + + +FillWestConnectionStrip: +FillEastConnectionStrip: ; 25f6 + +.asm_25f6 + ld a, [$d19f] + add 6 + ld [hConnectedMapWidth], a + + push de + + push hl + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + inc de + pop hl + + ld a, [hConnectionStripLength] + ld e, a + ld d, 0 + add hl, de + pop de + + ld a, [hConnectedMapWidth] + add e + ld e, a + jr nc, .asm_2617 + inc d +.asm_2617 + dec b + jr nz, .asm_25f6 + ret +; 261b + + +INCBIN "baserom.gbc", $261b, $261f - $261b PushScriptPointer: ; 261f -- cgit v1.2.3 From e384a889cc1b4b645f6d73182428c2d81a7f6acf Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 13 May 2013 19:08:46 -0400 Subject: GetAnyMapBlockdataBank --- main.asm | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/main.asm b/main.asm index a91f04942..4cfe1efdb 100644 --- a/main.asm +++ b/main.asm @@ -2522,7 +2522,7 @@ FillMapConnections: ; 2524 ld b, a ld a, [NorthConnectedMapNumber] ld c, a - call $2c5b + call GetAnyMapBlockdataBank ld a, [NorthConnectionStripPointer] ld l, a @@ -2545,7 +2545,7 @@ FillMapConnections: ; 2524 ld b, a ld a, [SouthConnectedMapNumber] ld c, a - call $2c5b + call GetAnyMapBlockdataBank ld a, [SouthConnectionStripPointer] ld l, a @@ -2568,7 +2568,7 @@ FillMapConnections: ; 2524 ld b, a ld a, [WestConnectedMapNumber] ld c, a - call $2c5b + call GetAnyMapBlockdataBank ld a, [WestConnectionStripPointer] ld l, a @@ -2591,7 +2591,7 @@ FillMapConnections: ; 2524 ld b, a ld a, [EastConnectedMapNumber] ld c, a - call $2c5b + call GetAnyMapBlockdataBank ld a, [EastConnectionStripPointer] ld l, a @@ -2858,7 +2858,40 @@ GetAnyMapHeaderMember: ; 0x2c0c ret ; 0x2c1c -INCBIN "baserom.gbc", $2c1c, $2c7d-$2c1c + +INCBIN "baserom.gbc", $2c1c, $2c5b - $2c1c + + +GetAnyMapBlockdataBank: ; 2c5b +; Return the blockdata bank for group b map c. + push hl + push de + push bc + + push bc + ld de, 3 ; second map header pointer + call GetAnyMapHeaderMember + ld l, c + ld h, b + pop bc + + push hl + ld de, 0 ; second map header bank + call GetAnyMapHeaderMember + pop hl + + ld de, 3 ; blockdata bank + add hl, de + ld a, c + call GetFarByte + rst Bankswitch + + pop bc + pop de + pop hl + ret +; 2c7d + GetSecondaryMapHeaderPointer: ; 0x2c7d ; returns the current map's secondary map header pointer in hl. -- cgit v1.2.3 From 956cb507128a65cb83abd33263bdb109c08921b0 Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 13 May 2013 20:51:45 -0400 Subject: EnterMapConnection --- main.asm | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 153 insertions(+), 1 deletion(-) diff --git a/main.asm b/main.asm index 4cfe1efdb..d75d984df 100644 --- a/main.asm +++ b/main.asm @@ -16797,7 +16797,159 @@ INCBIN "baserom.gbc", $104000, $104350 - $104000 INCBIN "gfx/ow/misc.2bpp" -INCBIN "baserom.gbc", $1045b0, $105258 - $1045b0 + +INCBIN "baserom.gbc", $1045b0, $1045d6 - $1045b0 + + +EnterMapConnection: ; 1045d6 +; Return carry if a connection has been entered. + ld a, [$d151] + and a + jp z, EnterSouthConnection + cp 1 + jp z, EnterNorthConnection + cp 2 + jp z, EnterWestConnection + cp 3 + jp z, EnterEastConnection + ret +; 1045ed + + +EnterWestConnection: ; 1045ed + ld a, [WestConnectedMapGroup] + ld [MapGroup], a + ld a, [WestConnectedMapNumber] + ld [MapNumber], a + ld a, [WestConnectionStripYOffset] + ld [XCoord], a + ld a, [WestConnectionStripXOffset] + ld hl, YCoord + add [hl] + ld [hl], a + ld c, a + ld hl, WestConnectionWindow + ld a, [hli] + ld h, [hl] + ld l, a + srl c + jr z, .asm_10461e + ld a, [WestConnectedMapWidth] + add 6 + ld e, a + ld d, 0 + +.asm_10461a + add hl, de + dec c + jr nz, .asm_10461a + +.asm_10461e + ld a, l + ld [$d194], a + ld a, h + ld [$d195], a + jp EnteredConnection +; 104629 + + +EnterEastConnection: ; 104629 + ld a, [EastConnectedMapGroup] + ld [MapGroup], a + ld a, [EastConnectedMapNumber] + ld [MapNumber], a + ld a, [EastConnectionStripYOffset] + ld [XCoord], a + ld a, [EastConnectionStripXOffset] + ld hl, YCoord + add [hl] + ld [hl], a + ld c, a + ld hl, EastConnectionWindow + ld a, [hli] + ld h, [hl] + ld l, a + srl c + jr z, .asm_10465a + ld a, [EastConnectedMapWidth] + add 6 + ld e, a + ld d, 0 + +.asm_104656 + add hl, de + dec c + jr nz, .asm_104656 + +.asm_10465a + ld a, l + ld [$d194], a + ld a, h + ld [$d195], a + jp EnteredConnection +; 104665 + + +EnterNorthConnection: ; 104665 + ld a, [NorthConnectedMapGroup] + ld [MapGroup], a + ld a, [NorthConnectedMapNumber] + ld [MapNumber], a + ld a, [NorthConnectionStripXOffset] + ld [YCoord], a + ld a, [NorthConnectionStripYOffset] + ld hl, XCoord + add [hl] + ld [hl], a + ld c, a + ld hl, NorthConnectionWindow + ld a, [hli] + ld h, [hl] + ld l, a + ld b, 0 + srl c + add hl, bc + ld a, l + ld [$d194], a + ld a, h + ld [$d195], a + jp EnteredConnection +; 104696 + + +EnterSouthConnection: ; 104696 + ld a, [SouthConnectedMapGroup] + ld [MapGroup], a + ld a, [SouthConnectedMapNumber] + ld [MapNumber], a + ld a, [SouthConnectionStripXOffset] + ld [YCoord], a + ld a, [SouthConnectionStripYOffset] + ld hl, XCoord + add [hl] + ld [hl], a + ld c, a + ld hl, SouthConnectionWindow + ld a, [hli] + ld h, [hl] + ld l, a + ld b, 0 + srl c + add hl, bc + ld a, l + ld [$d194], a + ld a, h + ld [$d195], a + ; fallthrough +; 1046c4 + +EnteredConnection: ; 1046c4 + scf + ret +; 1046c6 + + +INCBIN "baserom.gbc", $1046c6, $105258 - $1046c6 MysteryGiftGFX: INCBIN "gfx/misc/mystery_gift.2bpp" -- cgit v1.2.3 From 0f3e9c6f7ea8c1b17101cc948e318a96c2b57265 Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 13 May 2013 22:09:01 -0400 Subject: mixed up connection y/x offset wram labels --- main.asm | 16 ++++++++-------- wram.asm | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/main.asm b/main.asm index d75d984df..71ee950bf 100644 --- a/main.asm +++ b/main.asm @@ -16821,9 +16821,9 @@ EnterWestConnection: ; 1045ed ld [MapGroup], a ld a, [WestConnectedMapNumber] ld [MapNumber], a - ld a, [WestConnectionStripYOffset] - ld [XCoord], a ld a, [WestConnectionStripXOffset] + ld [XCoord], a + ld a, [WestConnectionStripYOffset] ld hl, YCoord add [hl] ld [hl], a @@ -16858,9 +16858,9 @@ EnterEastConnection: ; 104629 ld [MapGroup], a ld a, [EastConnectedMapNumber] ld [MapNumber], a - ld a, [EastConnectionStripYOffset] - ld [XCoord], a ld a, [EastConnectionStripXOffset] + ld [XCoord], a + ld a, [EastConnectionStripYOffset] ld hl, YCoord add [hl] ld [hl], a @@ -16895,9 +16895,9 @@ EnterNorthConnection: ; 104665 ld [MapGroup], a ld a, [NorthConnectedMapNumber] ld [MapNumber], a - ld a, [NorthConnectionStripXOffset] - ld [YCoord], a ld a, [NorthConnectionStripYOffset] + ld [YCoord], a + ld a, [NorthConnectionStripXOffset] ld hl, XCoord add [hl] ld [hl], a @@ -16922,9 +16922,9 @@ EnterSouthConnection: ; 104696 ld [MapGroup], a ld a, [SouthConnectedMapNumber] ld [MapNumber], a - ld a, [SouthConnectionStripXOffset] - ld [YCoord], a ld a, [SouthConnectionStripYOffset] + ld [YCoord], a + ld a, [SouthConnectionStripXOffset] ld hl, XCoord add [hl] ld [hl], a diff --git a/wram.asm b/wram.asm index 1cc6c0c8d..7b8a82abf 100644 --- a/wram.asm +++ b/wram.asm @@ -1048,9 +1048,9 @@ NorthConnectionStripLength: ; d1af ds 1 NorthConnectedMapWidth: ; d1b0 ds 1 -NorthConnectionStripXOffset: ; d1b1 +NorthConnectionStripYOffset: ; d1b1 ds 1 -NorthConnectionStripYOffset: ; d1b2 +NorthConnectionStripXOffset: ; d1b2 ds 1 NorthConnectionWindow: ; d1b3 ds 2 @@ -1068,9 +1068,9 @@ SouthConnectionStripLength: ; d1bb ds 1 SouthConnectedMapWidth: ; d1bc ds 1 -SouthConnectionStripXOffset: ; d1bd +SouthConnectionStripYOffset: ; d1bd ds 1 -SouthConnectionStripYOffset: ; d1be +SouthConnectionStripXOffset: ; d1be ds 1 SouthConnectionWindow: ; d1bf ds 2 @@ -1088,9 +1088,9 @@ WestConnectionStripLength: ; d1c7 ds 1 WestConnectedMapWidth: ; d1c8 ds 1 -WestConnectionStripXOffset: ; d1c9 +WestConnectionStripYOffset: ; d1c9 ds 1 -WestConnectionStripYOffset: ; d1ca +WestConnectionStripXOffset: ; d1ca ds 1 WestConnectionWindow: ; d1cb ds 2 @@ -1108,9 +1108,9 @@ EastConnectionStripLength: ; d1d3 ds 1 EastConnectedMapWidth: ; d1d4 ds 1 -EastConnectionStripXOffset: ; d1d5 +EastConnectionStripYOffset: ; d1d5 ds 1 -EastConnectionStripYOffset: ; d1d6 +EastConnectionStripXOffset: ; d1d6 ds 1 EastConnectionWindow: ; d1d7 ds 2 -- cgit v1.2.3