From dfa9adcaeb79f83087985192e1fb7052a1fe7143 Mon Sep 17 00:00:00 2001 From: Mr Wint Date: Sat, 5 Oct 2013 04:03:34 +0200 Subject: [PATCH] * added index comments to pointer lists * added map header wram addresses * analyzed some assembly --- engine/engine_flags.asm | 40 ++++++------ home/map.asm | 44 ++++++------- main.asm | 138 ++++++++++++++++++++-------------------- wram.asm | 28 ++++++-- 4 files changed, 133 insertions(+), 117 deletions(-) diff --git a/engine/engine_flags.asm b/engine/engine_flags.asm index 5527226e4..16ed58878 100644 --- a/engine/engine_flags.asm +++ b/engine/engine_flags.asm @@ -3,7 +3,7 @@ ; location, bit ; pokegear - dwb $d957, %00000010 ; radio card + dwb $d957, %00000010 ; radio card ; $0 dwb $d957, %00000001 ; map card dwb $d957, %00000100 ; phone card dwb $d957, %00001000 ; expn card @@ -17,7 +17,7 @@ ; DaycareLady, %10000000 = daycare 2 on dwb DaycareLady, %00000001 ; monster 2 in daycare - dwb $d854, %00000001 ; mom saving money + dwb $d854, %00000001 ; mom saving money ; $8 dwb $d854, %10000000 ; dst dwb $dc39, %00000001 @@ -27,7 +27,7 @@ dwb $d84c, %00001000 ; pokerus dwb $d84c, %00010000 ; rocket signal on ch20 dwb $d84c, %01000000 ; credits skip - dwb $d84c, %10000000 ; bug contest on + dwb $d84c, %10000000 ; bug contest on ; $10 dwb $d84d, %00000100 ; bug contest timer dwb $d84d, %00000010 ; rockets in radio tower dwb $d84d, %00000001 ; bike shop call enabled (1024 bike steps reqd) @@ -36,7 +36,7 @@ dwb $d84d, %01000000 dwb $d84d, %10000000 ; rockets in mahogany - dwb $dbf5, %00000001 ; strength active + dwb $dbf5, %00000001 ; strength active ; $18 dwb $dbf5, %00000010 ; always on bike (cant surf) dwb $dbf5, %00000100 ; downhill (cycling road) @@ -45,7 +45,7 @@ dwb JohtoBadges, %00000100 ; plainbadge dwb JohtoBadges, %00001000 ; fogbadge dwb JohtoBadges, %00010000 ; mineralbadge - dwb JohtoBadges, %00100000 ; stormbadge + dwb JohtoBadges, %00100000 ; stormbadge ; $20 dwb JohtoBadges, %01000000 ; glacierbadge dwb JohtoBadges, %10000000 ; risingbadge @@ -54,7 +54,7 @@ dwb KantoBadges, %00000100 ; thunderbadge dwb KantoBadges, %00001000 ; rainbowbadge dwb KantoBadges, %00010000 ; soulbadge - dwb KantoBadges, %00100000 ; marshbadge + dwb KantoBadges, %00100000 ; marshbadge ; $28 dwb KantoBadges, %01000000 ; volcanobadge dwb KantoBadges, %10000000 ; earthbadge @@ -64,7 +64,7 @@ dwb UnlockedUnowns, %00000100 ; 3 dwb UnlockedUnowns, %00001000 ; 4 dwb UnlockedUnowns, %00010000 ; 5 - dwb UnlockedUnowns, %00100000 ; 6 + dwb UnlockedUnowns, %00100000 ; 6 ; $30 dwb UnlockedUnowns, %01000000 ; 7 dwb UnlockedUnowns, %10000000 ; 8 @@ -74,7 +74,7 @@ dwb FlypointPerms, %00000100 ; pallet dwb FlypointPerms, %00001000 ; viridian dwb FlypointPerms, %00010000 ; pewter - dwb FlypointPerms, %00100000 ; cerulean + dwb FlypointPerms, %00100000 ; cerulean ; $38 dwb FlypointPerms, %01000000 ; rock tunnel dwb FlypointPerms, %10000000 ; vermilion dwb FlypointPerms + 1, %00000001 ; lavender @@ -82,7 +82,7 @@ dwb FlypointPerms + 1, %00000100 ; celadon dwb FlypointPerms + 1, %00001000 ; fuchsia dwb FlypointPerms + 1, %00010000 ; cinnabar - dwb FlypointPerms + 1, %00100000 ; indigo plateau + dwb FlypointPerms + 1, %00100000 ; indigo plateau ; $40 dwb FlypointPerms + 1, %01000000 ; new bark dwb FlypointPerms + 1, %10000000 ; cherrygrove dwb FlypointPerms + 2, %00000001 ; violet @@ -90,7 +90,7 @@ dwb FlypointPerms + 2, %00001000 ; cianwood dwb FlypointPerms + 2, %00010000 ; goldenrod dwb FlypointPerms + 2, %00100000 ; olivine - dwb FlypointPerms + 2, %01000000 ; ecruteak + dwb FlypointPerms + 2, %01000000 ; ecruteak ; $48 dwb FlypointPerms + 2, %10000000 ; mahogany dwb FlypointPerms + 3, %00000001 ; lake of rage dwb FlypointPerms + 3, %00000010 ; blackthorn @@ -100,7 +100,7 @@ dwb $dc9d, %00000001 ; lucky number show dwb $d84d, %00001000 - dwb $dc1e, %00000001 ; kurt making balls + dwb $dc1e, %00000001 ; kurt making balls ; $50 dwb $dc1e, %00000010 dwb $dc1e, %00000100 ; special wilddata? dwb $dc1e, %00001000 ; time capsule (24h wait) @@ -109,7 +109,7 @@ dwb $dc1e, %01000000 ; goldenrod underground merchant closed dwb $dc1e, %10000000 ; fought in trainer hall today - dwb $dc1f, %00000001 ; mt moon square clefairy + dwb $dc1f, %00000001 ; mt moon square clefairy ; $58 dwb $dc1f, %00000010 ; union cave lapras dwb $dc1f, %00000100 ; goldenrod underground haircut used dwb $dc1f, %00001000 ; goldenrod mall happiness event floor05 person07 @@ -131,7 +131,7 @@ dwb $dc4c, %00000001 ; jack dwb $dc4c, %00000010 ; huey dwb $dc4c, %00000100 ; gaven - dwb $dc4c, %00001000 ; beth + dwb $dc4c, %00001000 ; beth ; $68 dwb $dc4c, %00010000 ; jose dwb $dc4c, %00100000 ; reena dwb $dc4c, %01000000 ; joey @@ -139,7 +139,7 @@ dwb $dc4d, %00000001 ; ralph dwb $dc4d, %00000010 ; liz dwb $dc4d, %00000100 ; anthony - dwb $dc4d, %00001000 ; todd + dwb $dc4d, %00001000 ; todd ; $70 dwb $dc4d, %00010000 ; gina dwb $dc4d, %00100000 ; arnie dwb $dc4d, %01000000 ; alan @@ -147,7 +147,7 @@ dwb $dc4e, %00000001 ; chad dwb $dc4e, %00000010 ; tully dwb $dc4e, %00000100 ; brent - dwb $dc4e, %00001000 ; tiffany + dwb $dc4e, %00001000 ; tiffany ; $78 dwb $dc4e, %00010000 ; vance dwb $dc4e, %00100000 ; wilton dwb $dc4e, %01000000 ; parry @@ -156,7 +156,7 @@ dwb $dc50, %00000001 ; beverly has nugget dwb $dc50, %00000010 ; jose has star piece dwb $dc50, %00000100 ; wade has item (see bittable1 $032b-e) - dwb $dc50, %00001000 ; gina has leaf stone + dwb $dc50, %00001000 ; gina has leaf stone ; $80 dwb $dc50, %00010000 ; alan has fire stone dwb $dc50, %00100000 ; liz has thunderstone dwb $dc50, %01000000 ; derek has nugget @@ -166,7 +166,7 @@ dwb $dc51, %00000010 ; wilton has item (see bittable1 $032f-31) dwb $dc54, %00000001 - dwb $dc54, %00000010 + dwb $dc54, %00000010 ; $88 dwb $dc54, %00000100 dwb $dc54, %00001000 dwb $dc54, %00010000 @@ -175,7 +175,7 @@ dwb $dc54, %10000000 dwb $dc55, %00000001 - dwb $dc55, %00000010 + dwb $dc55, %00000010 ; $90 dwb $dc55, %00000100 dwb $dc55, %00001000 dwb $dc55, %00010000 @@ -184,7 +184,7 @@ dwb $dc55, %10000000 dwb $dc56, %00000001 - dwb $dc56, %00000010 + dwb $dc56, %00000010 ; $98 dwb $dc56, %00000100 dwb $dc56, %00001000 dwb $dc56, %00010000 @@ -194,5 +194,5 @@ dwb $d45b, %00000100 ; female player has been transformed into male - dwb $dc20, %00000100 ; dunsparce swarm + dwb $dc20, %00000100 ; dunsparce swarm ; $a0 dwb $dc20, %00001000 ; yanma swarm diff --git a/home/map.asm b/home/map.asm index 3c2e0e645..ade44a4a2 100644 --- a/home/map.asm +++ b/home/map.asm @@ -197,7 +197,7 @@ endr ld de, $0060 add hl, de pop de - ld a, [$d19f] + ld a, [MapWidth] add $6 add e ld e, a @@ -421,7 +421,7 @@ Function2326: ; 2326 Function2336: ; 2336 push af - ld hl, $d1a6 + ld hl, MapEventHeaderPointer ld a, [hli] ld h, [hl] ld l, a @@ -438,7 +438,7 @@ Function2336: ; 2336 ; 234f Function234f: ; 234f - ld hl, $d1a4 + ld hl, MapScriptHeaderPointer ld a, [hli] ld h, [hl] ld l, a @@ -466,7 +466,7 @@ Function2368: ; 2368 ld [WestConnectedMapGroup], a ld [EastConnectedMapGroup], a - ld a, [$d1a8] + ld a, [MapConnections] ld b, a bit 3, b @@ -670,10 +670,10 @@ Function2471: ; 2471 ; 248a Function248a: ; 248a - call GetMapEventBank + call GetMapScriptHeaderBank rst Bankswitch - ld hl, $d1a6 + ld hl, MapEventHeaderPointer ld a, [hli] ld h, [hl] ld l, a @@ -728,7 +728,7 @@ Function24e4: ; 24e4 ld a, [hROMBank] push af ld hl, OverworldMap - ld a, [$d19f] + ld a, [MapWidth] ld [hConnectedMapWidth], a add $6 ld [hConnectionStripLength], a @@ -739,14 +739,14 @@ Function24e4: ; 24e4 add hl, bc ld c, $3 add hl, bc - ld a, [$d1a0] + ld a, [MapBlockDataBank] rst Bankswitch - ld a, [$d1a1] + ld a, [MapBlockDataPointer] ld e, a - ld a, [$d1a2] + ld a, [MapBlockDataPointer+1] ld d, a - ld a, [$d19e] + ld a, [MapHeight] ld b, a .asm_250c push hl @@ -899,7 +899,7 @@ FillSouthConnectionStrip: ; 25d3 add hl, de pop de - ld a, [$d19f] + ld a, [MapWidth] add 6 add e ld e, a @@ -916,7 +916,7 @@ FillWestConnectionStrip: FillEastConnectionStrip: ; 25f6 .asm_25f6 - ld a, [$d19f] + ld a, [MapWidth] add 6 ld [hConnectedMapWidth], a @@ -977,7 +977,7 @@ Function2631: ; 2631 ld a, [ScriptRunning] and a ret nz - call GetMapEventBank + call GetMapScriptHeaderBank jr CallScript ; 263b @@ -989,7 +989,7 @@ Function263b: ; 263b call Function2653 jr nc, .done - call GetMapEventBank + call GetMapScriptHeaderBank ld b, a ld d, h ld e, l @@ -1442,7 +1442,7 @@ Function2879: ; 2879 dec b jr nz, .asm_2888 pop hl - ld a, [$d19f] + ld a, [MapWidth] add $6 ld c, a ld b, $0 @@ -1459,7 +1459,7 @@ Function289d: ; 289d ld h, [hl] ld l, a ld de, $dcb9 - ld a, [$d19f] + ld a, [MapWidth] add $6 ld [hConnectionStripLength], a ld a, [$d151] @@ -1506,7 +1506,7 @@ Function289d: ; 289d ld a, [hli] ld h, [hl] ld l, a - ld a, [$d19f] + ld a, [MapWidth] add $6 ld [hConnectionStripLength], a ld de, $dcb9 @@ -1776,7 +1776,7 @@ Function2a3c: ; 2a3c ; 2a66 Function2a66: ; 2a66 - ld a, [$d19f] + ld a, [MapWidth] add $6 ld c, a ld b, $0 @@ -2149,14 +2149,14 @@ Function2c3d: ; 2c3d ; 2c52 Function2c52: ; 2c52 - ld a, [MapEventBank] + ld a, [MapScriptHeaderBank] rst Bankswitch ret ; 2c57 -GetMapEventBank: ; 2c57 - ld a, [MapEventBank] +GetMapScriptHeaderBank: ; 2c57 + ld a, [MapScriptHeaderBank] ret ; 2c5b diff --git a/main.asm b/main.asm index cb8adcf08..7bafec0b6 100644 --- a/main.asm +++ b/main.asm @@ -1898,7 +1898,7 @@ Function3674: ; 3674 ld [MartPointer], a Function367e: ; 367e - call GetMapEventBank + call GetMapScriptHeaderBank ld [EngineBuffer1], a ld a, [$ffe0] call GetMapObject @@ -2010,7 +2010,7 @@ Function36f5: ; 36f5 ld a, [hli] ld h, [hl] ld l, a - call GetMapEventBank + call GetMapScriptHeaderBank call GetFarHalfword ld d, h ld e, l @@ -2044,7 +2044,7 @@ Function3718: ; 3718 ld a, [hli] ld h, [hl] ld l, a - call GetMapEventBank + call GetMapScriptHeaderBank call FarPrintText call WaitBGMap call Functiona80 @@ -11763,7 +11763,7 @@ PredefPointers: ; 856b ; $4b Predef pointers ; address, bank - dwb Function6508, BANK(Function6508) + dwb Function6508, BANK(Function6508) ; $0 dwb Function747a, BANK(Function747a) dwb Functionc658, BANK(Functionc658) dwb FlagPredef, BANK(FlagPredef) @@ -11771,7 +11771,7 @@ PredefPointers: ; 856b dwb FillPP, BANK(FillPP) dwb Functiond88c, BANK(Functiond88c) dwb Functionda96, BANK(Functionda96) - dwb Functiondb3f, BANK(Functiondb3f) + dwb Functiondb3f, BANK(Functiondb3f) ; $8 dwb Functionde6e, BANK(Functionde6e) dwb Functiondf8c, BANK(Functiondf8c) dwb Functionc6e0, BANK(Functionc6e0) @@ -11779,7 +11779,7 @@ PredefPointers: ; 856b dwb Functione17b, BANK(Functione17b) dwb CanLearnTMHMMove, BANK(CanLearnTMHMMove) dwb GetTMHMMove, BANK(GetTMHMMove) - dwb Function28eef, BANK(Function28eef) + dwb Function28eef, BANK(Function28eef) ; $ 10 dwb PrintMoveDesc, BANK(PrintMoveDesc) dwb Function3df48, BANK(Function3df48) ; UpdatePlayerHUD dwb FillBox, BANK(FillBox) @@ -11787,7 +11787,7 @@ PredefPointers: ; 856b dwb Function3e036, BANK(Function3e036) ; UpdateEnemyHUD dwb StartBattle, BANK(StartBattle) dwb FillInExpBar, BANK(FillInExpBar) - dwb Function3f43d, BANK(Function3f43d) + dwb Function3f43d, BANK(Function3f43d) ; $18 dwb Function3f47c, BANK(Function3f47c) dwb Function42487, BANK(Function42487) dwb FillMoves, BANK(FillMoves) @@ -11795,7 +11795,7 @@ PredefPointers: ; 856b dwb Function28f63, BANK(Function28f63) dwb Function28f24, BANK(Function28f24) dwb Function5084a, BANK(Function5084a) - dwb Function50d6f, BANK(Function50d6f) + dwb Function50d6f, BANK(Function50d6f) ; $20 dwb Function50d2e, BANK(Function50d2e) dwb Function50cdb, BANK(Function50cdb) dwb Function50c50, BANK(Function50c50) @@ -11803,7 +11803,7 @@ PredefPointers: ; 856b dwb StatsScreenInit, BANK(StatsScreenInit) dwb DrawPlayerHP, BANK(DrawPlayerHP) dwb DrawEnemyHP, BANK(DrawEnemyHP) - dwb Function50b7b, BANK(Function50b7b) + dwb Function50b7b, BANK(Function50b7b) ; $28 dwb GetTypeName, BANK(GetTypeName) dwb PrintMoveType, BANK(PrintMoveType) dwb PrintType, BANK(PrintType) @@ -11811,7 +11811,7 @@ PredefPointers: ; 856b dwb GetUnownLetter, BANK(GetUnownLetter) dwb Functioncbcdd, BANK(Functioncbcdd) dwb Functioncc0d5, BANK(Functioncc0d5) - dwb Function9853, BANK(Function9853) + dwb Function9853, BANK(Function9853) ; $30 dwb Function864c, BANK(Function864c) dwb Function91d11, BANK(Function91d11) dwb CheckContestMon, BANK(CheckContestMon) @@ -11819,7 +11819,7 @@ PredefPointers: ; 856b dwb Function8c000, BANK(Function8c000) dwb Function8c000, BANK(Function8c000) dwb Functioncc0d6, BANK(Functioncc0d6) - dwb Functioncc0d5, BANK(Functioncc0d5) + dwb Functioncc0d5, BANK(Functioncc0d5) ; $38 dwb Functioncc0d5, BANK(Functioncc0d5) dwb Functionfd1d0, BANK(Functionfd1d0) dwb PartyMonItemName, BANK(PartyMonItemName) @@ -11827,7 +11827,7 @@ PredefPointers: ; 856b dwb Function5116c, BANK(Function5116c) dwb Function5108b, BANK(Function5108b) dwb Function5120d, BANK(Function5120d) - dwb DecompressPredef, BANK(DecompressPredef) + dwb DecompressPredef, BANK(DecompressPredef) ; $40 dwb Function0x347d3, BANK(Function0x347d3) dwb Functionfb908, BANK(Functionfb908) dwb Functionfb877, BANK(Functionfb877) @@ -11835,7 +11835,7 @@ PredefPointers: ; 856b dwb Function50d0a, BANK(Function50d0a) dwb Functiond00a3, BANK(Functiond00a3) dwb Functiond008e, BANK(Functiond008e) - dwb Functiond0669, BANK(Functiond0669) + dwb Functiond0669, BANK(Functiond0669) ; $48 dwb Functiond066e, BANK(Functiond066e) dbw $ff, Function2d43 ; ???? ; 864c @@ -15350,7 +15350,7 @@ Functiond571: ; d571 (3:5571) ; known jump sources: d591 (3:5591) Functiond595: ; d595 (3:5595) ld hl, $d194 - ld a, [$d19f] + ld a, [MapWidth] add $6 add [hl] ld [hli], a @@ -15383,7 +15383,7 @@ Functiond5a2: ; d5a2 (3:55a2) ; known jump sources: d5c2 (3:55c2) Functiond5c6: ; d5c6 (3:55c6) ld hl, $d194 - ld a, [$d19f] + ld a, [MapWidth] add $6 ld b, a ld a, [hl] @@ -19841,7 +19841,7 @@ Function114e7: ; 114e7 jr z, .asm_114fa ld b, a - callba Function13988 + callba ApplyPokerusTick .asm_114fa xor a @@ -24691,7 +24691,8 @@ Function1397f: ; 1397f ret ; 13988 -Function13988: ; 13988 +; decreases all pokemon's pokerus counter by b. if the lower nybble reaches zero, the pokerus is cured. +ApplyPokerusTick: ; 13988 ld hl, PartyMon1PokerusStatus ld a, [PartyCount] and a @@ -40889,18 +40890,18 @@ INCLUDE "battle/moves/move_descriptions.asm" Function2ed44: ; 2ed44 - call Function2ede6 + call ConvertBerriesToBerryJuice ld hl, PartyMon1PokerusStatus ld a, [PartyCount] ld b, a ld de, $0030 -.asm_2ed51 +.loopMons ld a, [hl] and $f - jr nz, .asm_2ed9a + jr nz, .monHasActivePokerus add hl, de dec b - jr nz, .asm_2ed51 + jr nz, .loopMons ld hl, StatusFlags2 bit 6, [hl] ret z @@ -40910,23 +40911,23 @@ Function2ed44: ; 2ed44 ret nz ld a, [hRandomSub] cp $3 - ret nc + ret nc ; 3/65536 chance (00 00, 00 01 or 00 02) ld a, [PartyCount] ld b, a -.asm_2ed70 +.randomMonSelectLoop call Random and $7 cp b - jr nc, .asm_2ed70 + jr nc, .randomMonSelectLoop ld hl, PartyMon1PokerusStatus - call GetPartyLocation + call GetPartyLocation ; get pokerus byte of random mon ld a, [hl] and $f0 - ret nz -.asm_2ed82 + ret nz ; if it already has pokerus, do nothing +.randomPokerusLoop call Random and a - jr z, .asm_2ed82 + jr z, .randomPokerusLoop ld b, a and $f0 jr z, .asm_2ed91 @@ -40943,38 +40944,38 @@ Function2ed44: ; 2ed44 ld [hl], a ret -.asm_2ed9a +.monHasActivePokerus call Random cp $55 - ret nc + ret nc ; 1/3 chance ld a, [PartyCount] cp $1 - ret z + ret z ; only one mon, nothing to do ld c, [hl] ld a, b cp $2 - jr c, .asm_2edc3 + jr c, .checkPreviousMonsLoop ; no more mons after this one, go backwards call Random cp $80 - jr c, .asm_2edc3 -.asm_2edb3 + jr c, .checkPreviousMonsLoop ; 1/2 chance, go backwards +.checkFollowingMonsLoop add hl, de ld a, [hl] and a - jr z, .asm_2edd9 + jr z, .infectMon ld c, a and $3 - ret z - dec b + ret z ; if mon has cured pokerus, stop searching + dec b ; go on to next mon ld a, b cp $1 - jr nz, .asm_2edb3 + jr nz, .checkFollowingMonsLoop ; no more mons left ret -.asm_2edc3 +.checkPreviousMonsLoop ld a, [PartyCount] cp b - ret z + ret z ; no more mons ld a, l sub e ld l, a @@ -40983,14 +40984,14 @@ Function2ed44: ; 2ed44 ld h, a ld a, [hl] and a - jr z, .asm_2edd9 + jr z, .infectMon ld c, a and $3 - ret z - inc b - jr .asm_2edc3 + ret z ; if mon has cured pokerus, stop searching + inc b ; go on to next mon + jr .checkPreviousMonsLoop -.asm_2edd9 +.infectMon ld a, c and $f0 ld b, a @@ -41003,37 +41004,38 @@ Function2ed44: ; 2ed44 ret ; 2ede6 -Function2ede6: ; 2ede6 +; any berry held by a Shuckle may be converted to berry juice +ConvertBerriesToBerryJuice: ; 2ede6 ld hl, StatusFlags2 bit 6, [hl] ret z call Random cp $10 - ret nc + ret nc ; 1/16 chance ld hl, PartyMons ld a, [PartyCount] -.asm_2edf8 +.partyMonLoop push af push hl ld a, [hl] cp SHUCKLE - jr nz, .asm_2ee08 + jr nz, .nextMon ld bc, PartyMon1Item - PartyMon1Species add hl, bc ld a, [hl] cp BERRY - jr z, .asm_2ee12 + jr z, .convertToJuice -.asm_2ee08 +.nextMon pop hl ld bc, PartyMon2 - PartyMon1 add hl, bc pop af dec a - jr nz, .asm_2edf8 + jr nz, .partyMonLoop ret -.asm_2ee12 +.convertToJuice ld a, BERRY_JUICE ld [hl], a pop hl @@ -85916,7 +85918,7 @@ CheckTileEvent: ; 96874 ld a, [hli] ld h, [hl] ld l, a - call GetMapEventBank + call GetMapScriptHeaderBank call CallScript ret ; 968c7 @@ -85980,9 +85982,9 @@ Function968ec: ; 968ec add hl, de add hl, de - call GetMapEventBank + call GetMapScriptHeaderBank call GetFarHalfword - call GetMapEventBank + call GetMapScriptHeaderBank call CallScript ld hl, ScriptFlags @@ -86157,7 +86159,7 @@ TryObjectEvent: ; 969b5 ld a, [hli] ld h, [hl] ld l, a - call GetMapEventBank + call GetMapScriptHeaderBank call CallScript ; ld a, -1 ret @@ -86169,7 +86171,7 @@ TryObjectEvent: ; 969b5 ld a, [hli] ld h, [hl] ld l, a - call GetMapEventBank + call GetMapScriptHeaderBank ld de, EngineBuffer1 ld bc, 2 call FarCopyBytes @@ -86255,7 +86257,7 @@ TryReadSign: ; 96a38 ld a, [hli] ld h, [hl] ld l, a - call GetMapEventBank + call GetMapScriptHeaderBank call CallScript scf ret @@ -86264,7 +86266,7 @@ TryReadSign: ; 96a38 call CheckSignFlag jp nz, .dontread call PlayTalkObject - call GetMapEventBank + call GetMapScriptHeaderBank ld de, EngineBuffer1 ld bc, 3 call FarCopyBytes @@ -86277,7 +86279,7 @@ TryReadSign: ; 96a38 .asm_96aa2 call CheckSignFlag jr nz, .dontread - call GetMapEventBank + call GetMapScriptHeaderBank ld de, EngineBuffer1 ld bc, 3 call FarCopyBytes @@ -86298,9 +86300,9 @@ TryReadSign: ; 96a38 pop hl inc hl inc hl - call GetMapEventBank + call GetMapScriptHeaderBank call GetFarHalfword - call GetMapEventBank + call GetMapScriptHeaderBank call CallScript scf ret @@ -86317,7 +86319,7 @@ CheckSignFlag: ; 96ad8 ld h, [hl] ld l, a push hl - call GetMapEventBank + call GetMapScriptHeaderBank call GetFarHalfword ld e, l ld d, h @@ -87674,7 +87676,7 @@ Functionb8164: ; b8164 ; b8172 Functionb8172: ; b8172 - call GetMapEventBank + call GetMapScriptHeaderBank ld [MagikarpLength], a ld a, [XCoord] add $5 @@ -111876,7 +111878,7 @@ Function104820: ; 104820 (41:4820) ld a, [MapY] ; $d4e7 sub $4 ld b, a - ld a, [$d19e] + ld a, [MapHeight] add a cp b jr z, .asm_10486b @@ -111900,7 +111902,7 @@ Function104820: ; 104820 (41:4820) ld a, [MapX] ; $d4e6 sub $4 ld b, a - ld a, [$d19f] + ld a, [MapWidth] add a cp b jr z, .asm_10486b @@ -111928,7 +111930,7 @@ Function10486d: ; 10486d ld c, a ld b, $0 add hl, bc - ld a, [$d19f] + ld a, [MapWidth] add $6 ld c, a ld b, $0 diff --git a/wram.asm b/wram.asm index 22096650c..3796969fb 100644 --- a/wram.asm +++ b/wram.asm @@ -1099,15 +1099,29 @@ SECTION "UsedSprites",WRAMX[$d154],BANK[1] UsedSprites: ; d154 ds 32 -SECTION "map",WRAMX[$d1a3],BANK[1] +SECTION "map",WRAMX[$d19d],BANK[1] -MapEventBank: ; d1a3 +; both are in blocks (2x2 walkable tiles, 4x4 graphics tiles) +MapHeader: ; d19d +MapBorderBlock: ; d19d + ds 1 +MapHeight: ; d19e + ds 1 +MapWidth: ; d19f + ds 1 +MapBlockDataBank: ; d1a0 + ds 1 +MapBlockDataPointer: ; d1a1 + ds 2 +MapScriptHeaderBank: ; d1a3 + ds 1 +MapScriptHeaderPointer: ; d1a4 + ds 2 +MapEventHeaderPointer: ; d1a6 + ds 2 +; bit set +MapConnections: ; d1a8 ds 1 - - ds 5 - -MapConnections: - NorthMapConnection: ; d1a9 NorthConnectedMapGroup: ; d1a9 ds 1