diff options
59 files changed, 603 insertions, 616 deletions
diff --git a/constants/music_constants.asm b/constants/music_constants.asm index c304fbb..acb47eb 100755 --- a/constants/music_constants.asm +++ b/constants/music_constants.asm @@ -15,5 +15,5 @@ const MUSIC_EVOLUTION ; 0C MUSIC_SURF EQU $62 - + SE_SELECT EQU 5 diff --git a/constants/pokedex_constants.asm b/constants/pokedex_constants.asm index 66da19b..b3c5e00 100644 --- a/constants/pokedex_constants.asm +++ b/constants/pokedex_constants.asm @@ -252,9 +252,9 @@ const DEX_BULU ; f9 SNUBBULL const DEX_TAIL ; fa AIPOM const DEX_LEAFY ; fb LEAFEON (evolved EEVEE) -NUM_POKEMON EQU const_value + -1 +NUM_POKEMON EQU const_value - 1 const DEX_FC ; fc - const DEX_FD ; fd + const DEX_EGG ; fd EGG const DEX_FE ; fe ; Annon forms @@ -285,4 +285,4 @@ NUM_POKEMON EQU const_value + -1 const ANNON_X ; 24 const ANNON_Y ; 25 const ANNON_Z ; 26 -NUM_ANNON EQU const_value + -1 ; 26 +NUM_ANNON EQU const_value - 1 ; 26 diff --git a/engine/dumps/bank03.asm b/engine/dumps/bank03.asm index 39d1f78..2c2a21c 100755 --- a/engine/dumps/bank03.asm +++ b/engine/dumps/bank03.asm @@ -2196,7 +2196,7 @@ Function60a0: ; 03:60a0 call LoadMapPart call GetMemSGBLayout call WaitBGMap - call RotateThreePalettesLeft + call GBFadeInFromWhite .sub_e155 pop bc ld a, b @@ -3342,7 +3342,7 @@ Functione8f9: ; 03:68f9 ld hl, NamingScreen push de call FarCall_hl - call RotateThreePalettesRight + call GBFadeOutToWhite pop de ld a, [de] cp $50 @@ -3364,7 +3364,7 @@ Functione8f9: ; 03:68f9 ld a, BANK(NamingScreen) ld hl, NamingScreen call FarCall_hl - call RotateThreePalettesRight + call GBFadeOutToWhite ld de, wdf17 ld a, [de] cp $50 diff --git a/engine/Intro.asm b/engine/intro.asm index 55f8c3f..ad8fb3e 100644 --- a/engine/Intro.asm +++ b/engine/intro.asm @@ -9,7 +9,7 @@ DemoStart:: ; 558D call FadeInIntroPic ld hl, OakSpeechDemo call PrintText - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap ld de, ProtagonistPic lb bc, BANK(ProtagonistPic), $00 @@ -27,7 +27,7 @@ GameStart:: ; 55BB call FadeInIntroPic ld hl, OakSpeech1 call PrintText - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap ld a, DEX_YADOKING ld [wCurSpecies], a @@ -43,7 +43,7 @@ GameStart:: ; 55BB call PlayCry ld hl, OakSpeech3 call PrintText - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap ld de, ProtagonistPic lb bc, BANK(ProtagonistPic), $00 @@ -52,7 +52,7 @@ GameStart:: ; 55BB ld hl, OakSpeech4 call PrintText call ChoosePlayerName - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap ld de, RivalPic lb bc, BANK(RivalPic), $00 @@ -61,7 +61,7 @@ GameStart:: ; 55BB ld hl, OakSpeech5 call PrintText call ChooseRivalName - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap ld de, OakPic lb bc, BANK(OakPic), $00 @@ -71,12 +71,12 @@ GameStart:: ; 55BB call PrintText callba SetClockDialog call Function04ac - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap ld de, ProtagonistPic lb bc, BANK(ProtagonistPic), $00 call IntroDisplayPicCenteredOrUpperRight - call RotateThreePalettesLeft + call GBFadeInFromWhite ld hl, OakSpeech7 call PrintText ldh a, [hROMBank] @@ -116,7 +116,7 @@ IntroCleanup:: ; 568E call LoadFontExtra ld c, $32 call DelayFrames - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap call Function0502 ld a, $00 @@ -499,14 +499,14 @@ ChoosePlayerName:: ; 5B25 cp "@" jr z, .loop - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap call LoadFontExtra call WaitBGMap ld de, $4D10 ld bc, $1200 call IntroDisplayPicCenteredOrUpperRight - call RotateThreePalettesLeft + call GBFadeInFromWhite .farjump ld hl, ChoosePlayerNameEndText call PrintText @@ -552,14 +552,14 @@ ChooseRivalName:: ; 5BA9 cp "@" jr z, .loop - call RotateThreePalettesRight + call GBFadeOutToWhite call ClearTileMap call LoadFontExtra call WaitBGMap ld de, $4BD4 ld bc, $1200 call IntroDisplayPicCenteredOrUpperRight - call RotateThreePalettesLeft + call GBFadeInFromWhite .farjump ld hl, ChooseRivalNameEndText call PrintText diff --git a/home/audio.asm b/home/audio.asm index f5154ae..b2d07c5 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -1,8 +1,9 @@ INCLUDE "constants.asm" + SECTION "home/audio.asm", ROM0 -DisableAudio:: ; 3cbf +DisableAudio:: push hl push de push bc @@ -22,7 +23,7 @@ DisableAudio:: ; 3cbf pop hl ret -UpdateSound:: ; 3cdb +UpdateSound:: push hl push de push bc @@ -42,7 +43,7 @@ UpdateSound:: ; 3cdb pop hl ret -_LoadMusicByte:: ; 3cf7 +_LoadMusicByte:: ld [MBC3RomBank], a ; Unsafe ldh [hROMBank], a ld a, [de] @@ -53,7 +54,7 @@ _LoadMusicByte:: ; 3cf7 pop af ret -PlayMusic:: ; 3d07 +PlayMusic:: push hl push de push bc @@ -73,7 +74,7 @@ PlayMusic:: ; 3d07 pop hl ret -PlayCryHeader:: ; 3d23 +PlayCryHeader:: push hl push de push bc @@ -115,7 +116,7 @@ endr pop hl ret -PlaySFX:: ; 3d63 +PlaySFX:: push hl push de push bc @@ -135,12 +136,12 @@ PlaySFX:: ; 3d63 pop hl ret -WaitPlaySFX:: ; 3d7f +WaitPlaySFX:: call WaitSFX call PlaySFX ret -WaitSFX:: ; 3d86 +WaitSFX:: push hl .loop ld hl, wChannel5Flags1 @@ -157,23 +158,23 @@ WaitSFX:: ; 3d86 jr nz, .loop pop hl ret - -MaxVolume:: ; 3DA5 + +MaxVolume:: ld a, $77 ld [wVolume], a ret -LowVolume:: ; 3DAB +LowVolume:: ld a, $33 ld [wVolume], a ret -VolumeOff:: ; 3DB1 +VolumeOff:: xor a ld [wVolume], a ret -UpdateSoundNTimes:: ; 3DB6 +UpdateSoundNTimes:: .loop and a ret z @@ -181,7 +182,7 @@ UpdateSoundNTimes:: ; 3DB6 call UpdateSound jr .loop -FadeToMapMusic:: ; 3DBE +FadeToMapMusic:: push hl push de push bc @@ -190,7 +191,7 @@ FadeToMapMusic:: ; 3DBE ld a, [wMapMusic] cp e jr z, .jump - ld a, $08 + ld a, 8 ld [wMusicFade], a ld a, e ld [wMusicFadeID], a @@ -205,7 +206,7 @@ FadeToMapMusic:: ; 3DBE pop hl ret -PlayMapMusic:: ; 3DE1 +PlayMapMusic:: push hl push de push bc @@ -215,7 +216,7 @@ PlayMapMusic:: ; 3DE1 cp e jr z, .jump push de - ld de, $0000 + ld de, MUSIC_NONE call PlayMusic call DelayFrame pop de @@ -229,37 +230,36 @@ PlayMapMusic:: ; 3DE1 pop hl ret -SpecialMapMusic:: ; 3E05 +SpecialMapMusic:: ld a, [wPlayerState] and a jr z, .normal cp $02 jr z, .state2 - ld de, $0009 + ld de, MUSIC_BICYCLE scf ret -.state2 ; 3E14 - ld de, $0000 +.state2 ; 3e14 + ld de, MUSIC_NONE scf ret -.normal ; 3E19 +.normal ; 3e19 and a ret -GetMapMusic:: ; 3E1B +GetMapMusic:: call SpecialMapMusic ret c ld a, [wMapPermissions] - cp $01 - jr z, .jump - cp $03 - jr z, .jump - ld de, $0002 - ret -.jump ; 3E2E - ld de, $0007 + cp TOWN + jr z, .not_route + cp INDOOR + jr z, .not_route + ld de, MUSIC_ROUTE_1 ret -; 3E32, this is likely not a function.
\ No newline at end of file +.not_route + ld de, MUSIC_VIRIDIAN_CITY + ret diff --git a/home/bankswitch.asm b/home/bankswitch.asm index 1df28e1..c28d72b 100644 --- a/home/bankswitch.asm +++ b/home/bankswitch.asm @@ -2,9 +2,9 @@ INCLUDE "constants.asm" SECTION "home/bankswitch.asm", ROM0 -; Moved to a rst vector in final US releases (not sure about JP) -; All rst vectors are unused at this point in development -Bankswitch:: ; 32c2 +; Moved to a rst vector in final US releases (not sure about JP). +; All rst vectors are unused at this point in development. +Bankswitch:: ldh [hROMBank], a ld [MBC3RomBank], a - ret
\ No newline at end of file + ret diff --git a/home/clear_sprites.asm b/home/clear_sprites.asm index c30c93d..c25d251 100644 --- a/home/clear_sprites.asm +++ b/home/clear_sprites.asm @@ -2,7 +2,7 @@ INCLUDE "constants.asm" SECTION "home/clear_sprites.asm", ROM0 -ClearSprites:: ; 32dc +ClearSprites:: ld hl, wVirtualOAM ld b, wVirtualOAMEnd - wVirtualOAM xor a @@ -12,7 +12,7 @@ ClearSprites:: ; 32dc jr nz, .loop ret -HideSprites:: ; 32e7 +HideSprites:: ld hl, wVirtualOAM ld de, SPRITEOAMSTRUCT_LENGTH ld b, NUM_SPRITE_OAM_STRUCTS @@ -22,4 +22,4 @@ HideSprites:: ; 32e7 add hl, de dec b jr nz, .loop - ret
\ No newline at end of file + ret diff --git a/home/copy.asm b/home/copy.asm index 0235906..ebce4f3 100644 --- a/home/copy.asm +++ b/home/copy.asm @@ -2,7 +2,7 @@ INCLUDE "constants.asm" SECTION "home/copy.asm", ROM0 -FarCopyBytes:: ; 32f7 +FarCopyBytes:: ; Copy bc bytes from a:hl to de. ld [wBuffer], a ldh a, [hROMBank] @@ -13,7 +13,7 @@ FarCopyBytes:: ; 32f7 pop af jp Bankswitch -CopyBytes:: ; 330a +CopyBytes:: ; Copy bc bytes from hl to de ld a, b and a @@ -28,7 +28,7 @@ CopyBytes:: ; 330a jr nz, .next ret -CopyBytesSmall:: ; 331a +CopyBytesSmall:: ; Copy c bytes from hl to de ld a, [hli] ld [de], a @@ -37,7 +37,7 @@ CopyBytesSmall:: ; 331a jr nz, CopyBytesSmall ret -GetFarByte:: ; 3321 +GetFarByte:: ld [wBuffer], a ldh a, [hROMBank] push af @@ -50,7 +50,7 @@ GetFarByte:: ; 3321 ld a, [wBuffer] ret -ByteFill:: ; 3339 +ByteFill:: push af ld a, b and a @@ -78,13 +78,13 @@ UncompressSpriteFromDE:: ld [hl], d jp UncompressSpriteData -BackUpTilesToBuffer:: ; 3355 +BackUpTilesToBuffer:: hlcoord 0, 0 decoord 0, 0, wTileMapBackup ld bc, SCREEN_HEIGHT * SCREEN_WIDTH jp CopyBytes -ReloadTilesFromBuffer:: ; 3361 +ReloadTilesFromBuffer:: xor a ldh [hBGMapMode], a hlcoord 0, 0, wTileMapBackup @@ -107,4 +107,4 @@ CopyString:: ld [hli], a cp "@" jr nz, CopyString - ret
\ No newline at end of file + ret diff --git a/home/copy2.asm b/home/copy2.asm index 1a30e63..a55ecb8 100644 --- a/home/copy2.asm +++ b/home/copy2.asm @@ -5,20 +5,20 @@ SECTION "home/copy2.asm", ROM0 RedrawPlayerSprite:: jpab _RedrawPlayerSprite -LoadFont:: ; 00:0d0a +LoadFont:: jpab LoadFontGraphics LoadFontsBattleExtra:: jpab LoadPokemonMenuGraphics -LoadFontExtra:: ; 00:0d1a +LoadFontExtra:: jpab LoadFontExtraGraphicsWithCursor LoadToolgearGraphics:: jpab LoadToolgearGraphicsDebug -FarCopyData: ; d2a (0:d2a) -; Identical to FarCopyBytes except for tail call optimization +FarCopyData: +; Identical to FarCopyBytes except for tail call optimization. ; Copy bc 2bpp bytes from a:hl to de. ld [wBuffer], a ldh a, [hROMBank] @@ -30,7 +30,7 @@ FarCopyData: ; d2a (0:d2a) call Bankswitch ret -FarCopyDataDouble: ; d3e (0:d3e) +FarCopyDataDouble: ; Copy and expand bc 1bpp bytes from a:hl to de. ld [wBuffer], a ldh a, [hROMBank] @@ -64,7 +64,7 @@ FarCopyDataDouble: ; d3e (0:d3e) call Bankswitch ret -Request2bpp:: ; d68 (0:d68) +Request2bpp:: ; Wait for the next VBlank, then copy c 2bpp ; tiles from b:de to hl, 8 tiles at a time. ; This takes c/8 frames. @@ -104,7 +104,7 @@ Request2bpp:: ; d68 (0:d68) ld c, a jr .loop -Request1bpp:: ; da6 (0:da6) +Request1bpp:: ; Wait for the next VBlank, then copy c 1bpp ; tiles from b:de to hl, 8 tiles at a time. ; This takes c/8 frames. @@ -144,15 +144,16 @@ Request1bpp:: ; da6 (0:da6) ld c, a jr .loop -Get2bpp:: ; de4 (0:de4) -; Copy c 2bpp tiles from b:de to hl in VRAM -; using VBlank service or direct copy in -; case LCD is off +Get2bpp:: +; Copy c 2bpp tiles from b:de to hl in VRAM using +; VBlank service or direct copy in case LCD is off. ldh a, [rLCDC] bit rLCDC_ENABLE, a jp nz, Request2bpp ; copy video data during vblank while screen is on -Copy2bpp:: ; 0deb - push hl ; convert to FarCopyData call + ; fallthrough + +Copy2bpp:: + push hl ld h, d ld l, e pop de @@ -168,14 +169,15 @@ Copy2bpp:: ; 0deb pop af jp FarCopyData -Get1bpp: ; dff (0:dff) -; Copy c 1bpp tiles from b:de to hl in VRAM -; using VBlank service or direct copy in -; case LCD is off +Get1bpp: +; Copy c 1bpp tiles from b:de to hl in VRAM using +; VBlank service or direct copy in case LCD is off. ldh a, [rLCDC] bit rLCDC_ENABLE, a jp nz, Request1bpp -Copy1bpp:: ; 0e06 + ; fallthrough + +Copy1bpp:: push de ld d, h ld e, l @@ -191,4 +193,3 @@ Copy1bpp:: ; 0e06 pop af pop hl jp FarCopyDataDouble -; 0xe18
\ No newline at end of file diff --git a/home/cry.asm b/home/cry.asm index 02a281b..075386a 100644 --- a/home/cry.asm +++ b/home/cry.asm @@ -7,15 +7,15 @@ PlayStereoCry:: ld a, $1 ld [wc1b9], a pop af - jr asm_39c3 + jr _PlayCry -PlayCry:: ; 00:39ba +PlayCry:: push af xor a ld [wc1b9], a ld [wc1ba], a pop af -asm_39c3: ; 00:39c3 +_PlayCry: push hl push de push bc @@ -58,7 +58,7 @@ LoadCryHeader:: call Bankswitch ret -GetCryIndex:: ; 00:3a02 +GetCryIndex:: ld d, a ld a, [wce37] push af @@ -74,22 +74,22 @@ GetCryIndex:: ; 00:3a02 ret PrintLevel:: - ld a, $6e + ld a, $6e ; ":L" ld [hli], a ld c, 2 - ld a, [wcd9e] + ld a, [wLoadedMonLevel] cp 100 - jr c, asm_3a37 + jr c, _PrintLevelCommon dec hl inc c - jr asm_3a37 + jr _PrintLevelCommon PrintLevelFullWidth:: - ld a, $6e + ld a, $6e ; ":L" ld [hli], a ld c, 3 - ld a, [wcd9e] -asm_3a37: ; 00:3a37 + ld a, [wLoadedMonLevel] +_PrintLevelCommon: ld [wce37], a ld de, wce37 ld b, PRINTNUM_RIGHTALIGN | 1 @@ -98,7 +98,7 @@ asm_3a37: ; 00:3a37 Function3a42:: ld hl, wce2e ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] - ret
\ No newline at end of file + ret diff --git a/home/delay.asm b/home/delay.asm index 2f8ec13..48b855c 100644 --- a/home/delay.asm +++ b/home/delay.asm @@ -19,4 +19,4 @@ DelayFrames:: call DelayFrame dec c jr nz, DelayFrames - ret
\ No newline at end of file + ret diff --git a/home/fade.asm b/home/fade.asm index 882a200..21a5a7b 100644 --- a/home/fade.asm +++ b/home/fade.asm @@ -2,10 +2,10 @@ include "constants.asm" SECTION "home/fade.asm", ROM0 -Function0343:: ; 0343 - ld a, [wTimeOfDayPal] +Function0343:: + ld a, [wTimeOfDayPal] ; tells if current map is dark ld b, a - ld hl, IncGradGBPalTable_11 ; $39f + ld hl, FadePal4 ld a, l sub b ld l, a @@ -20,17 +20,17 @@ Function0343:: ; 0343 ld [rOBP1], a ret -RotateFourPalettesRight:: - ld hl, IncGradGBPalTable_08 ; $396 - ld b, $4 - jr RotatePalettesRight +GBFadeInFromBlack:: + ld hl, FadePal1 + ld b, 4 + jr _GBFadeIncCommon -RotateThreePalettesRight:: - ld hl, IncGradGBPalTable_13 ; $3a5 - ld b, $3 -RotatePalettesRight:: ; 0366 -; Rotate palettes to the right and fill with loaded colors from the left -; If we're already at the leftmost color, fill with the leftmost color +GBFadeOutToWhite:: + ld hl, FadePal6 + ld b, 3 +_GBFadeIncCommon: +; Rotate palettes to the right and fill with loaded colors from the left. +; If we're already at the leftmost color, fill with the leftmost color. .loop ld a, [hli] ld [rBGP], a @@ -38,23 +38,23 @@ RotatePalettesRight:: ; 0366 ld [rOBP0], a ld a, [hli] ld [rOBP1], a - ld c, $8 + ld c, 8 call DelayFrames dec b jr nz, .loop ret -RotateFourPalettesLeft:: - ld hl, IncGradGBPalTable_12 - 1 ; $3a1 - ld b, $4 - jr RotatePalettesLeft +GBFadeOutToBlack:: + ld hl, FadePal5 - 1 + ld b, 4 + jr _GBFadeDecCommon -RotateThreePalettesLeft:: - ld hl, IncGradGBPalTable_15 - 1 ; $3aa - ld b, $3 -RotatePalettesLeft:: ; 0384 -; Rotate palettes to the left and fill with loaded colors from the right -; If we're already at the rightmost color, fill with the rightmost color +GBFadeInFromWhite:: + ld hl, FadePal8 - 1 + ld b, 3 +_GBFadeDecCommon: +; Rotate palettes to the left and fill with loaded colors from the right. +; If we're already at the rightmost color, fill with the rightmost color. .loop ld a, [hld] ld [rOBP1], a @@ -62,30 +62,18 @@ RotatePalettesLeft:: ; 0384 ld [rOBP0], a ld a, [hld] ld [rBGP], a - ld c, $8 + ld c, 8 call DelayFrames dec b jr nz, .loop ret -; IncGradGBPalTable_00:: db %11111111, %11111111, %11111111 -; IncGradGBPalTable_01:: db %11111110, %11111110, %11111110 -; IncGradGBPalTable_02:: db %11111001, %11111001, %11111001 -; IncGradGBPalTable_03:: db %11100100, %11100100, %11100100 - -; IncGradGBPalTable_04:: db %11100100, %11100100, %11100100 -; IncGradGBPalTable_05:: db %10010000, %10010000, %10010000 -; IncGradGBPalTable_06:: db %01000000, %01000000, %01000000 - -; IncGradGBPalTable_07:: db %00000000, %00000000, %00000000 -; bgp obp1 obp2 -IncGradGBPalTable_08:: db %11111111, %11111111, %11111111 -IncGradGBPalTable_09:: db %11111110, %11111110, %11111000 -IncGradGBPalTable_10:: db %11111001, %11100100, %11100100 -IncGradGBPalTable_11:: db %11100100, %11010000, %11100000 - -IncGradGBPalTable_12:: db %11100100, %11010000, %11100000 -IncGradGBPalTable_13:: db %10010000, %10000000, %10010000 -IncGradGBPalTable_14:: db %01000000, %01000000, %01000000 - -IncGradGBPalTable_15:: db %00000000, %00000000, %00000000
\ No newline at end of file +FadePal1:: db %11111111, %11111111, %11111111 +FadePal2:: db %11111110, %11111110, %11111000 +FadePal3:: db %11111001, %11100100, %11100100 +FadePal4:: db %11100100, %11010000, %11100000 +; rBGP rOBP0 rOBP1 +FadePal5:: db %11100100, %11010000, %11100000 +FadePal6:: db %10010000, %10000000, %10010000 +FadePal7:: db %01000000, %01000000, %01000000 +FadePal8:: db %00000000, %00000000, %00000000 diff --git a/home/farcall.asm b/home/farcall.asm index 8a5485b..ccc6bca 100644 --- a/home/farcall.asm +++ b/home/farcall.asm @@ -2,7 +2,7 @@ INCLUDE "constants.asm" SECTION "home/farcall.asm", ROM0 -FarCall_hl:: ; 2fa8 +FarCall_hl:: push af ld a, b ld [wFarCallBCBuffer], a @@ -23,7 +23,7 @@ FarCall_hl:: ; 2fa8 ld c, a ret -.return +.return: ld a, b ld [wFarCallBCBuffer], a ld a, c @@ -35,4 +35,4 @@ FarCall_hl:: ; 2fa8 ld b, a ld a, [wFarCallBCBuffer + 1] ld c, a - ret
\ No newline at end of file + ret diff --git a/home/init.asm b/home/init.asm index 0e690aa..4c06359 100644 --- a/home/init.asm +++ b/home/init.asm @@ -1,17 +1,24 @@ INCLUDE "constants.asm" + +SECTION "NULL", ROM0 +NULL:: + + SECTION "home/init.asm@Entry point", ROM0 nop jp Init + SECTION "home/init.asm@Global check value", ROM0 -; The ROM has an incorrect global check, so set it here -; It is not corrected by RGBFIX +; The ROM has an incorrect global check, so set it here. +; It is not corrected by RGBFIX. dw $C621 + SECTION "home/init.asm@Init", ROM0 -Reset: ; 51c (0:051c) +Reset: call DisableAudio call ClearPalettes ei @@ -22,9 +29,9 @@ Reset: ; 51c (0:051c) ld c, 32 call DelayFrames - jr Init + jr Init ; pointless -Init: ; 052f +Init: di xor a ld [rIF], a @@ -49,15 +56,17 @@ Init: ; 052f ld sp, wStackBottom call ClearVRAM + ld hl, WRAM0_Begin ld bc, WRAM1_End - WRAM0_Begin -.ByteFill ; 0565 +.clear_loop ld [hl], 0 inc hl dec bc ld a, b or c - jr nz, .ByteFill + jr nz, .clear_loop + ld hl, HRAM_Begin ld bc, HRAM_End - HRAM_Begin call ByteFill @@ -117,7 +126,7 @@ Init: ; 052f ld [MBC3SRamEnable], a jp GameInit -ClearVRAM: ; 05e6 +ClearVRAM: ld hl, VRAM_Begin ld bc, VRAM_End - VRAM_Begin xor a @@ -125,13 +134,11 @@ ClearVRAM: ; 05e6 ret BlankBGMap: - ld a, $7f + ld a, " " jr _FillBGMap FillBGMap: ld a, l - ; fallthrough - _FillBGMap: ld de, BG_MAP_WIDTH * BG_MAP_HEIGHT ld l, e @@ -141,4 +148,4 @@ _FillBGMap: jr nz, .loop dec d jr nz, .loop - ret
\ No newline at end of file + ret diff --git a/home/interrupts.asm b/home/interrupts.asm index 949b351..50a99fb 100644 --- a/home/interrupts.asm +++ b/home/interrupts.asm @@ -1,5 +1,6 @@ INCLUDE "constants.asm" + SECTION "home/interrupts.asm@VBlank interrupt vector", ROM0 jp VBlank @@ -18,11 +19,11 @@ SECTION "home/interrupts.asm@Joypad interrupt vector", ROM0 SECTION "home/interrupts.asm@Timer dummy interrupt", ROM0 -TimerDummy: ; 042a +TimerDummy: reti SECTION "home/interrupts.asm@Joypad dummy interrupt", ROM0 -JoypadDummy: ; 07f7 - reti
\ No newline at end of file +JoypadDummy: + reti diff --git a/home/items.asm b/home/items.asm index 5df4d13..c31d3b0 100755 --- a/home/items.asm +++ b/home/items.asm @@ -1,8 +1,9 @@ INCLUDE "constants.asm" + SECTION "home/items.asm@TossItem", ROM0 -TossItem: ; 00:3243 +TossItem: ldh a, [hROMBank] push af ld a, BANK(_TossItem) @@ -18,7 +19,7 @@ TossItem: ; 00:3243 call Bankswitch ret -ReceiveItem:: ; 3259 +ReceiveItem:: ; function to add an item (in varying quantities) to the player's bag or PC box ; INPUT: ; HL = address of inventory (either wNumBagItems or wNumBoxItems) @@ -41,6 +42,7 @@ ReceiveItem:: ; 3259 pop bc ret + SECTION "home/items.asm@GiveItem", ROM0 GiveItem:: @@ -58,4 +60,4 @@ GiveItem:: call GetItemName call CopyStringToStringBuffer2 scf - ret
\ No newline at end of file + ret diff --git a/home/joypad.asm b/home/joypad.asm index 6581413..b68cb32 100644 --- a/home/joypad.asm +++ b/home/joypad.asm @@ -1,5 +1,6 @@ INCLUDE "constants.asm" + SECTION "home/joypad.asm", ROM0 ClearJoypad:: @@ -10,7 +11,8 @@ ClearJoypad:: ldh [hJoyState], a ret -Joypad:: ; 7fe (0:7fe) + +Joypad:: ; Read the joypad register and translate it to something more ; workable for use in-game. There are 8 buttons, so we can use ; one byte to contain all player input. @@ -68,7 +70,7 @@ Joypad:: ; 7fe (0:7fe) jp z, Reset ret -GetJoypad:: ; 84a (0:84a) +GetJoypad:: ; Update mirror joypad input from hJoypadState (real input) ; hJoyReleased, hJoyDown and hJoyState are synchronized @@ -104,7 +106,7 @@ GetJoypad:: ; 84a (0:84a) pop af ret -JoyTitleScreenInput:: ; 869 (0:869) +JoyTitleScreenInput:: ; Check if any of the following conditions ; is met for c frames ; - B, Select and Up keys are pressed in same frame @@ -132,7 +134,7 @@ JoyTitleScreenInput:: ; 869 (0:869) scf ret -GetJoypadDebounced:: ; 884 (0:884) +GetJoypadDebounced:: ; Update hJoySum joypad input from either hJoyDown or ; hJoyState depending on hJoyDebounceSrc. ; hJoyState is only updated every 5 frames and @@ -166,7 +168,7 @@ GetJoypadDebounced:: ; 884 (0:884) ret ; 0x8ad -TextboxWaitPressAorB_BlinkCursor: ; 8ad (0:8ad) +TextboxWaitPressAorB_BlinkCursor: ; Show a blinking cursor in the lower right-hand ; corner of a textbox and wait until A or B is ; pressed. @@ -197,7 +199,7 @@ TextboxWaitPressAorB_BlinkCursor: ; 8ad (0:8ad) ldh [hSpriteWidth], a ret -ButtonSound:: ; 8d2 (0:8d2) +ButtonSound:: ld a, [wLinkMode] cp $03 jr z, .link @@ -211,7 +213,7 @@ ButtonSound:: ; 8d2 (0:8d2) ld c, $41 jp DelayFrames -WaitAorB_BlinkCursor:: ; 8ea (0:8ea) +WaitAorB_BlinkCursor:: .loop call BlinkCursor call GetJoypadDebounced @@ -225,7 +227,7 @@ WaitAorB_BlinkCursor:: ; 8ea (0:8ea) call DelayFrame jr .loop -BlinkCursor: ; 904 (0:904) +BlinkCursor: ; Show a blinking cursor in the lower right-hand ; corner of the screen ; Will toggle between cursor and blank every @@ -241,7 +243,7 @@ BlinkCursor: ; 904 (0:904) ldcoord_a (SCREEN_WIDTH - 2), (SCREEN_HEIGHT - 1) ret -TextboxBlinkCursor:: ; 914 (0:914) +TextboxBlinkCursor:: ; Show a blinking cursor at the specified position ; that toggles between down arrow and horizontal textbox ; frame tile. @@ -290,4 +292,4 @@ TextboxBlinkCursor:: ; 914 (0:914) ldh [hTextBoxCursorBlinkInterval + 1], a ; reset to 0x6FF iterations ld a, "▼" ld [hl], a - ret
\ No newline at end of file + ret diff --git a/home/jumptable.asm b/home/jumptable.asm index 7aba401..03947bf 100644 --- a/home/jumptable.asm +++ b/home/jumptable.asm @@ -2,17 +2,16 @@ INCLUDE "constants.asm" SECTION "home/jumptable.asm", ROM0 -CallJumptable:: ; 35cd (0:35cd) +CallJumptable:: ; CallJumptable ; Call function whose pointer is ; at index a in 2-byte pointer table ; pointed to by hl. ; Clobbers: a, hl ; -; This ultimately wound up at rst $28 in -; GSC +; This became rst $28 in final GSC. push de - ld d, $00 + ld d, 0 ld e, a add hl, de add hl, de @@ -34,10 +33,11 @@ CallFar_atHL:: ld a, [hli] ld h, [hl] ld l, a - call .jump + call ._hl_ pop hl ld a, h call Bankswitch ret -.jump: ; 35eb (0:35eb) - jp hl
\ No newline at end of file + +._hl_: + jp hl diff --git a/home/lcd.asm b/home/lcd.asm index 4553f09..5565786 100644 --- a/home/lcd.asm +++ b/home/lcd.asm @@ -2,7 +2,7 @@ INCLUDE "constants.asm" SECTION "home/lcd.asm", ROM0 -LCD:: ; 03ae +LCD:: push af ldh a, [hLCDCPointer] and a @@ -44,13 +44,10 @@ LCD:: ; 03ae pop af reti - -; 0:3e1 ; TODO: can this be done using `sine_table`? db 0, 1, 2, 2, 3, 3, 4, 4, 4, 4, 4, 3, 3, 2, 2, 1, 0, -1, -2, -2, -3, -3, -4, -4, -4, -4, -4, -3, -3, -2, -2, -1 - -DisableLCD:: ; 0401 +DisableLCD:: ld a, [rLCDC] bit 7, a ret z @@ -73,8 +70,8 @@ DisableLCD:: ; 0401 ld [rIE], a ret -EnableLCD:: ; 0423 +EnableLCD:: ld a, [rLCDC] set 7, a ld [rLCDC], a - ret
\ No newline at end of file + ret diff --git a/home/map.asm b/home/map.asm index 58c568d..9e6da75 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1731,4 +1731,4 @@ Function2be5:: ; 00:2be5 ; TODO jp hl .Return: ; 00:2c04 - ret
\ No newline at end of file + ret diff --git a/home/map_objects.asm b/home/map_objects.asm index 69bd60b..1362c84 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -685,4 +685,4 @@ SetObjectFacing:: ; 19C0 ld hl, OBJECT_DIRECTION_WALKING add hl, bc ld [hl], a - ret
\ No newline at end of file + ret diff --git a/home/math.asm b/home/math.asm index 31b7cd9..c9d9f5c 100644 --- a/home/math.asm +++ b/home/math.asm @@ -18,4 +18,4 @@ Divide:: pop bc pop de pop hl - ret
\ No newline at end of file + ret diff --git a/home/menu.asm b/home/menu.asm index 3199400..e9d41bb 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -2,17 +2,17 @@ include "constants.asm" SECTION "home/menu.asm", ROM0 -LoadMenuHeader:: ; 00:1d49 +LoadMenuHeader:: call CopyMenuHeader call PushWindow ret -CopyMenuHeader:: ; 00:1d50 +CopyMenuHeader:: ld de, wMenuDataHeader - ld bc, $10 + ld bc, wMenuDataHeaderEnd - wMenuDataHeader jp CopyBytes -MenuTextBox:: ; 00:1d59 +MenuTextBox:: push hl ld hl, .Data call LoadMenuHeader @@ -38,17 +38,17 @@ LoadStandardMenuHeader:: call LoadMenuHeader ret -.Data: ; 00:1d7b +.Data: db MENU_BACKUP_TILES ; flags menu_coords 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 - dw 0 + dw NULL db 1 ; default option Call_ExitMenu:: call ExitMenu ret -VerticalMenu:: ; 00:1d87 +VerticalMenu:: xor a ldh [hBGMapMode], a call MenuBox @@ -105,7 +105,7 @@ PlaceGenericTwoOptionBox:: call LoadMenuHeader jr asm_1df9 -asm_1ddc: ; 00:1ddc +asm_1ddc: push bc ld hl, YesNoMenuHeader call CopyMenuHeader @@ -119,7 +119,7 @@ asm_1ddc: ; 00:1ddc add 4 ld [wMenuBorderBottomCoord], a call PushWindow -asm_1df9: ; 00:1df9 +asm_1df9: call VerticalMenu push af ld c, 15 @@ -133,13 +133,13 @@ asm_1df9: ; 00:1df9 and a ret -.asm_1e11: ; 00:1e11 - ld a, $2 +.asm_1e11: + ld a, 2 ld [wMenuCursorY], a scf ret -YesNoMenuHeader:: ; 00:1e18 +YesNoMenuHeader:: db MENU_BACKUP_TILES ; flags menu_coords 10, 5, 15, 9 dw .MenuData @@ -156,7 +156,7 @@ OffsetMenuHeader:: call PushWindow ret -_OffsetMenuHeader:: ; 00:1e30 +_OffsetMenuHeader:: push de call CopyMenuHeader pop de @@ -164,7 +164,7 @@ _OffsetMenuHeader:: ; 00:1e30 ld h, a ld a, [wMenuBorderRightCoord] sub h -.asm_1e3d: ; 00:1e3d +.asm_1e3d: ld h, a ld a, d ld [wMenuBorderLeftCoord], a @@ -181,7 +181,7 @@ _OffsetMenuHeader:: ; 00:1e30 ld [wMenuBorderBottomCoord], a ret -OpenMenu:: ; 00:1e58 +OpenMenu:: call CopyMenuData call GetMenuIndexSet push de @@ -205,7 +205,7 @@ OpenMenu:: ; 00:1e58 call Function1f27 ret -Function1e8a:: ; 00:1e8a +Function1e8a:: xor a ldh [hBGMapMode], a xor a @@ -224,7 +224,7 @@ Function1e8a:: ; 00:1e8a dec [hl] ret -AutomaticGetMenuBottomCoord:: ; 00:1eac +AutomaticGetMenuBottomCoord:: ld a, [wMenuBorderLeftCoord] ld c, a ld a, [wMenuBorderRightCoord] @@ -239,7 +239,7 @@ AutomaticGetMenuBottomCoord:: ; 00:1eac ld [wMenuBorderBottomCoord], a ret -GetMenuIndexSet:: ; 00:1ec3 +GetMenuIndexSet:: ld hl, wMenuDataIndicesPointer ld a, [hli] ld h, [hl] @@ -249,18 +249,18 @@ GetMenuIndexSet:: ; 00:1ec3 jr z, .asm_1ed9 ld b, a ld c, -1 -.asm_1ed2: ; 00:1ed2 +.asm_1ed2: ld a, [hli] cp c jr nz, .asm_1ed2 dec b jr nz, .asm_1ed2 -.asm_1ed9: ; 00:1ed9 +.asm_1ed9: ld d, h ld e, l inc hl ld c, $ff -.asm_1ede: ; 00:1ede +.asm_1ede: inc c ld a, [hli] cp $ff @@ -269,7 +269,7 @@ GetMenuIndexSet:: ; 00:1ec3 ld [wMenuDataItems], a ret -Function1ee9:: ; 1ee9 +Function1ee9:: call MenuBoxCoord2Tile call GetMenuBoxDims ld a, [wMenuDataItems] @@ -280,7 +280,7 @@ Function1ee9:: ; 1ee9 dec c ret -.asm_1ef9: ; 00:1ef9 +.asm_1ef9: ld a, b srl a dec a @@ -288,7 +288,7 @@ Function1ee9:: ; 1ee9 dec c ret -RunMenuItemPrintingFunction:: ; 00:1f02 +RunMenuItemPrintingFunction:: call MenuBoxCoord2Tile ld bc, 2 * SCREEN_WIDTH + 2 add hl, bc @@ -316,7 +316,7 @@ RunMenuItemPrintingFunction:: ; 00:1f02 ld l, a jp hl -Function1f27:: ; 00:1f27 +Function1f27:: ; Combines Crystal functions "InitMenuCursorAndButtonPermissions" and "GetStaticMenuJoypad" push de call InitVerticalMenuCursor @@ -325,13 +325,13 @@ Function1f27:: ; 00:1f27 bit 3, a jr z, .asm_1f37 set 3, [hl] -.asm_1f37: ; 00:1f37 +.asm_1f37: bit 2, a jr z, .asm_1f3f ld a, [hl] or D_LEFT | D_RIGHT ld [hl], a -.asm_1f3f: ; 00:1f3f +.asm_1f3f: call Get2DMenuJoypad pop de bit 0, a @@ -346,20 +346,20 @@ Function1f27:: ; 00:1f27 jr nz, .asm_1f5f ret -.asm_1f58: ; 00:1f58 +.asm_1f58: ld a, D_RIGHT ld [wMenuJoypad], a jr .asm_1f6b -.asm_1f5f: ; 00:1f5f +.asm_1f5f: ld a, D_LEFT ld [wMenuJoypad], a jr .asm_1f6b -.asm_1f66: ; 00:1f66 +.asm_1f66: ld a, A_BUTTON ld [wMenuJoypad], a -.asm_1f6b: ; 00:1f6b +.asm_1f6b: ld a, [wMenuCursorY] ld l, a ld h, $0 @@ -371,7 +371,7 @@ Function1f27:: ; 00:1f27 and a ret -.asm_1f7e: ; 00:1f7e +.asm_1f7e: ld a, B_BUTTON ld [wMenuJoypad], a ld a, -1 @@ -393,15 +393,15 @@ PlaceMenuStrings:: call PlaceString ret -ClearWindowData:: ; 00:1f9e +ClearWindowData:: ld hl, wWindowStackPointer - call .bytefill + call .clear ld hl, wMenuDataHeader - call .bytefill + call .clear ld hl, wMenuData2 - call .bytefill + call .clear ld hl, wMenuData3 - call .bytefill + call .clear xor a call OpenSRAM @@ -418,8 +418,8 @@ ClearWindowData:: ; 00:1f9e call CloseSRAM ret -.bytefill: ; 00:1fcc - ld bc, 16 +.clear: + ld bc, wMenuDataHeaderEnd - wMenuDataHeader xor a call ByteFill - ret
\ No newline at end of file + ret diff --git a/home/menu_window.asm b/home/menu_window.asm index 4911863..5f8465e 100644 --- a/home/menu_window.asm +++ b/home/menu_window.asm @@ -7,7 +7,7 @@ SetMenuAttributes:: push bc ld hl, wMenuData3 ld b, $8 -.asm_1a6b: ; 00:1a6b +.asm_1a6b: ld a, [de] inc de ld [hli], a @@ -24,14 +24,14 @@ SetMenuAttributes:: pop hl ret -Get2DMenuJoypad:: ; 00:1a7c +Get2DMenuJoypad:: call Place2DMenuCursor ld hl, w2DMenuFlags + 1 res 7, [hl] -.loop: ; 00:1a84 +.loop: call Move2DMenuCursor call WaitBGMap -.asm_1a8a: ; 00:1a8a +.asm_1a8a: call UpdateTime call UpdateTimeOfDayPalettes call Menu_WasButtonPressed @@ -41,7 +41,7 @@ Get2DMenuJoypad:: ; 00:1a7c jp nz, .done jr .asm_1a8a -.asm_1a9f: ; 00:1a9f +.asm_1a9f: call _2DMenuInterpretJoypad jp c, .done ld a, [w2DMenuFlags] @@ -52,7 +52,7 @@ Get2DMenuJoypad:: ; 00:1a7c ld a, [wMenuJoypadFilter] and b jp z, .loop -.done: ; 00:1ab6 +.done: ldh a, [hJoyDown] and A_BUTTON | B_BUTTON jr z, .asm_1ac4 @@ -60,16 +60,16 @@ Get2DMenuJoypad:: ; 00:1a7c ld de, SE_SELECT call PlaySFX pop de -.asm_1ac4: ; 00:1ac4 +.asm_1ac4: ldh a, [hJoySum] ret -Menu_WasButtonPressed:: ; 00:1ac7 +Menu_WasButtonPressed:: ld a, [w2DMenuFlags] bit 6, a jr z, .asm_1ad6 callba PlaySpriteAnimationsAndDelayFrame -.asm_1ad6: ; 00:1ad6 +.asm_1ad6: call GetJoypadDebounced ldh a, [hJoySum] and a @@ -77,7 +77,7 @@ Menu_WasButtonPressed:: ; 00:1ac7 scf ret -_2DMenuInterpretJoypad:: ; 00:1adf +_2DMenuInterpretJoypad:: ldh a, [hJoySum] bit A_BUTTON_F, a jp nz, .PressedABStartOrSelect @@ -98,13 +98,13 @@ _2DMenuInterpretJoypad:: ; 00:1adf and a ret -.SetFlag15AndCarry: ; 00:1b07 +.SetFlag15AndCarry: ld hl, w2DMenuFlags + 1 set 7, [hl] scf ret -.PressedDown: ; 00:1b0e +.PressedDown: ld hl, wMenuCursorY ld a, [w2DMenuNumRows] cp [hl] @@ -113,7 +113,7 @@ _2DMenuInterpretJoypad:: ; 00:1adf xor a ret -.asm_1b1a: ; 00:1b1a +.asm_1b1a: ld a, [w2DMenuFlags] bit 5, a jr nz, .asm_1b28 @@ -122,12 +122,12 @@ _2DMenuInterpretJoypad:: ; 00:1adf xor a ret -.asm_1b28: ; 00:1b28 +.asm_1b28: ld [hl], $1 xor a ret -.PressedUp: ; 00:1b2c +.PressedUp: ld hl, wMenuCursorY ld a, [hl] dec a @@ -136,7 +136,7 @@ _2DMenuInterpretJoypad:: ; 00:1adf xor a ret -.asm_1b36: ; 00:1b36 +.asm_1b36: ld a, [w2DMenuFlags] bit 5, a jr nz, .asm_1b44 @@ -145,13 +145,13 @@ _2DMenuInterpretJoypad:: ; 00:1adf xor a ret -.asm_1b44: ; 00:1b44 +.asm_1b44: ld a, [w2DMenuNumRows] ld [hl], a xor a ret -.PressedLeft: ; 00:1b4a +.PressedLeft: ld hl, wMenuCursorX ld a, [hl] dec a @@ -160,7 +160,7 @@ _2DMenuInterpretJoypad:: ; 00:1adf xor a ret -.asm_1b54: ; 00:1b54 +.asm_1b54: ld a, [w2DMenuFlags] bit 4, a jr nz, .asm_1b62 @@ -169,13 +169,13 @@ _2DMenuInterpretJoypad:: ; 00:1adf xor a ret -.asm_1b62: ; 00:1b62 +.asm_1b62: ld a, [w2DMenuNumCols] ld [hl], a xor a ret -.PressedRight: ; 00:1b68 +.PressedRight: ld hl, wMenuCursorX ld a, [w2DMenuNumCols] cp [hl] @@ -184,7 +184,7 @@ _2DMenuInterpretJoypad:: ; 00:1adf xor a ret -.asm_1b74: ; 00:1b74 +.asm_1b74: ld a, [w2DMenuFlags] bit 4, a jr nz, .asm_1b82 @@ -193,16 +193,16 @@ _2DMenuInterpretJoypad:: ; 00:1adf xor a ret -.asm_1b82: ; 00:1b82 +.asm_1b82: ld [hl], $1 xor a ret -.PressedABStartOrSelect: ; 00:1b86 +.PressedABStartOrSelect: xor a ret -Move2DMenuCursor:: ; 00:1b88 +Move2DMenuCursor:: ld hl, wCursorCurrentTile ld a, [hli] ld h, [hl] @@ -212,7 +212,7 @@ Move2DMenuCursor:: ; 00:1b88 jr nz, Place2DMenuCursor ld a, [wCursorOffCharacter] ld [hl], a -Place2DMenuCursor:: ; 00:1b97 +Place2DMenuCursor:: ld a, [w2DMenuCursorInitY] ld b, a ld a, [w2DMenuCursorInitX] @@ -227,11 +227,11 @@ Place2DMenuCursor:: ; 00:1b97 xor a dec b jr z, .asm_1bb6 -.asm_1bb2: ; 00:1bb2 +.asm_1bb2: add c dec b jr nz, .asm_1bb2 -.asm_1bb6: ; 00:1bb6 +.asm_1bb6: ld c, SCREEN_WIDTH call AddNTimes ld a, [w2DMenuCursorOffsets] @@ -242,11 +242,11 @@ Place2DMenuCursor:: ; 00:1b97 xor a dec b jr z, .asm_1bcd -.asm_1bc9: ; 00:1bc9 +.asm_1bc9: add c dec b jr nz, .asm_1bc9 -.asm_1bcd: ; 00:1bcd +.asm_1bcd: ld c, a add hl, bc ld a, [hl] @@ -254,7 +254,7 @@ Place2DMenuCursor:: ; 00:1b97 jr z, .asm_1bd9 ld [wCursorOffCharacter], a ld [hl], $ed -.asm_1bd9: ; 00:1bd9 +.asm_1bd9: ld a, l ld [wCursorCurrentTile], a ld a, h @@ -277,19 +277,19 @@ HideCursor:: ld [hl], $7f ret -PushWindow:: ; 00:1bf4 +PushWindow:: ld hl, PlaceWaitingText ld a, $9 jp FarCall_hl -ExitMenu:: ; 00:1bfc +ExitMenu:: push af callab _ExitMenu call Function1c0a pop af ret -Function1c0a:: ; 00:1c0a +Function1c0a:: ld a, [wVramState] bit 0, a ret z @@ -325,10 +325,10 @@ Function1c0a:: ; 00:1c0a ret -InitVerticalMenuCursor:: ; 00:1c44 +InitVerticalMenuCursor:: jpab _InitVerticalMenuCursor -CloseWindow:: ; 00:1c4c +CloseWindow:: push af call ExitMenu call WaitBGMap @@ -339,15 +339,15 @@ CloseWindow:: ; 00:1c4c Function1c58:: jpab Function24185 -RestoreTileBackup:: ; 00:1c60 +RestoreTileBackup:: call MenuBoxCoord2Tile call GetMenuBoxDims inc b inc c -.asm_1c68: ; 00:1c68 +.asm_1c68: push bc push hl -.asm_1c6a: ; 00:1c6a +.asm_1c6a: ld a, [de] ld [hli], a dec de @@ -361,10 +361,10 @@ RestoreTileBackup:: ; 00:1c60 jr nz, .asm_1c68 ret -PopWindow:: ; 00:1c7a +PopWindow:: ld b, $10 ld de, wMenuDataHeader -.asm_1c7f: ; 00:1c7f +.asm_1c7f: ld a, [hld] ld [de], a inc de @@ -372,7 +372,7 @@ PopWindow:: ; 00:1c7a jr nz, .asm_1c7f ret -GetMenuBoxDims:: ; 00:1c86 +GetMenuBoxDims:: push hl ld hl, wMenuBorderTopCoord ld a, [hli] @@ -388,7 +388,7 @@ GetMenuBoxDims:: ; 00:1c86 pop hl ret -CopyMenuData:: ; 00:1c96 +CopyMenuData:: push hl push de push bc @@ -406,7 +406,7 @@ CopyMenuData:: ; 00:1c96 pop hl ret -GetWindowStackTop:: ; 00:1cae +GetWindowStackTop:: ld hl, wWindowStackPointer ld a, [hli] ld h, [hl] @@ -417,7 +417,7 @@ GetWindowStackTop:: ; 00:1cae ld l, a ret -PlaceVerticalMenuItems:: ; 00:1cb9 +PlaceVerticalMenuItems:: call CopyMenuData ld hl, wMenuDataPointer ld e, [hl] @@ -429,7 +429,7 @@ PlaceVerticalMenuItems:: ; 00:1cb9 ld a, [de] inc de ld b, a -.asm_1ccc: ; 00:1ccc +.asm_1ccc: push bc call PlaceString inc de @@ -451,14 +451,14 @@ PlaceVerticalMenuItems:: ; 00:1cb9 add hl, bc jp PlaceString -MenuBox:: ; 00:1ceb +MenuBox:: call MenuBoxCoord2Tile call GetMenuBoxDims dec b dec c jp DrawTextBox -GetMenuTextStartCoord:: ; 00:1cf6 +GetMenuTextStartCoord:: ld a, [wMenuBorderTopCoord] ld b, a inc b @@ -469,12 +469,12 @@ GetMenuTextStartCoord:: ; 00:1cf6 bit 6, a jr nz, .asm_1d08 inc b -.asm_1d08: ; 00:1d08 +.asm_1d08 ld a, [wMenuDataFlags] bit 7, a - jr z, .asm_1d10 + jr z, .done inc c -.asm_1d10: ; 00:1d10 +.done ret ClearMenuBoxInterior:: @@ -495,12 +495,12 @@ ClearWholeMenuBox:: call ClearBox ret -MenuBoxCoord2Tile:: ; 00:1d2d +MenuBoxCoord2Tile:: ld a, [wMenuBorderLeftCoord] ld c, a ld a, [wMenuBorderTopCoord] ld b, a -Coord2Tile:: ; 00:1d35 +Coord2Tile:: xor a ld h, a ld l, b @@ -518,4 +518,4 @@ Coord2Tile:: ; 00:1d35 add hl, bc bccoord 0, 0 add hl, bc - ret
\ No newline at end of file + ret diff --git a/home/misc_32c8.asm b/home/misc_32c8.asm index 3b1f898..3fafade 100644 --- a/home/misc_32c8.asm +++ b/home/misc_32c8.asm @@ -9,10 +9,10 @@ Function32c8:: ret Function32d0:: - ld hl, .Data + ld hl, .EmptyString ret -.Data: ; 00:32d4 +.EmptyString: db "@" SubtractSigned:: @@ -25,7 +25,7 @@ SubtractSigned:: SECTION "home/misc_32c8.asm@Unknown 3686", ROM0 -GiveMonToPlayer:: ; 3686 +GiveMonToPlayer:: ; Give to the player Pokemon of species b at level c. ld a, b ld [wMonDexIndex], a @@ -35,7 +35,7 @@ GiveMonToPlayer:: ; 3686 ld [wMonType], a jpba Function1130a -WaitPressedAny:: ; 369a +WaitPressedAny:: ; Waits for one of the buttons in d to be pressed. ; If bc is negative, waits forever. ; Otherwise, times out after bc frames then returns z. @@ -68,15 +68,15 @@ WaitPressedAny:: ; 369a ; Return z, signifying that the request timed out. ret -CountSetBits:: ; 36b1 +CountSetBits:: ; Count the number of bits set in b bytes at hl. ; Return to a, c, and wCountSetBitsResult. ld c, $0 -.asm_36b3: ; 00:36b3 +.asm_36b3: ld a, [hli] ld e, a ld d, $8 -.asm_36b7: ; 00:36b7 +.asm_36b7: srl e ld a, $0 adc c @@ -87,4 +87,4 @@ CountSetBits:: ; 36b1 jr nz, .asm_36b3 ld a, c ld [wCountSetBitsResult], a - ret
\ No newline at end of file + ret diff --git a/home/misc_3c43.asm b/home/misc_3c43.asm index 0abbd79..315856f 100644 --- a/home/misc_3c43.asm +++ b/home/misc_3c43.asm @@ -2,7 +2,7 @@ INCLUDE "constants.asm" SECTION "home/misc_3c43.asm", ROM0 -GetPartyParamLocation:: ; 3c43 (00:3c43) +GetPartyParamLocation:: ; Get the location of parameter a from wCurPartyMon in hl push bc ld hl, wPartyMons @@ -15,10 +15,10 @@ GetPartyParamLocation:: ; 3c43 (00:3c43) pop bc ret -UseItem:: ; 3c56 (00:3c56) +UseItem:: jpba _UseItem -CheckTossableItem:: ; 3c5e (00:3c5e) +CheckTossableItem:: push hl push de push bc @@ -28,7 +28,7 @@ CheckTossableItem:: ; 3c5e (00:3c5e) pop hl ret -GetBattleAnimPointer:: ; 3c6d (00:3c6d) +GetBattleAnimPointer:: ld a, BANK(BattleAnimationsBankRef) ld [MBC3RomBank], a ldh [hROMBank], a @@ -44,7 +44,7 @@ GetBattleAnimPointer:: ; 3c6d (00:3c6d) ret -GetBattleAnimByte:: ; 3c84 (00:3c84) +GetBattleAnimByte:: push hl push de @@ -75,7 +75,7 @@ GetBattleAnimByte:: ; 3c84 (00:3c84) ld a, [wBattleAnimByte] ret -InitSpriteAnimStruct:: ; 3ca8 (00:3ca8) +InitSpriteAnimStruct:: ld [wSpriteAnimIDBuffer], a ldh a, [hROMBank] push af @@ -87,5 +87,5 @@ InitSpriteAnimStruct:: ; 3ca8 (00:3ca8) call Bankswitch ret -EmptyFunction3cbe:: ; 3cbe (00:3cbe) - ret
\ No newline at end of file +EmptyFunction3cbe:: + ret diff --git a/home/mon_stats.asm b/home/mon_stats.asm index 7b07333..ed4f6a8 100644 --- a/home/mon_stats.asm +++ b/home/mon_stats.asm @@ -12,7 +12,7 @@ DrawBattleHPBar:: ld [hli], a push hl ld a, $62 -.asm_3957: ; 00:3957 +.asm_3957: ld [hli], a dec d jr nz, .asm_3957 @@ -27,7 +27,7 @@ DrawBattleHPBar:: and a jr z, .asm_397d ld e, $1 -.asm_396a: ; 00:396a +.asm_396a: ld a, e sub $8 jr c, .asm_3979 @@ -39,11 +39,11 @@ DrawBattleHPBar:: jr z, .asm_397d jr .asm_396a -.asm_3979: ; 00:3979 +.asm_3979: ld a, $62 add e ld [hl], a -.asm_397d: ; 00:397d +.asm_397d: pop bc pop de pop hl @@ -56,7 +56,7 @@ _PrepMonFrontpic:: ld a, [wMonDexIndex] and a jr z, .asm_39a8 - cp 252 + cp NUM_POKEMON + 1 jr nc, .asm_39a8 push hl ld de, vFrontPic @@ -70,9 +70,9 @@ _PrepMonFrontpic:: ld [wSpriteFlipped], a ret -.asm_39a8: ; 00:39a8 +.asm_39a8: xor a ld [wSpriteFlipped], a inc a ld [wMonDexIndex], a - ret
\ No newline at end of file + ret diff --git a/home/movement.asm b/home/movement.asm index b1dd6c0..db27b1e 100644 --- a/home/movement.asm +++ b/home/movement.asm @@ -22,7 +22,7 @@ DecrementMovementBufferCount:: ld [wMovementBufferCount], a ret -AppendToMovementBuffer:: ; 00:19f2 +AppendToMovementBuffer:: push hl push de ld hl, wMovementBufferCount @@ -36,7 +36,7 @@ AppendToMovementBuffer:: ; 00:19f2 pop hl ret -AppendToMovementBufferNTimes:: ; 00:1a03 +AppendToMovementBufferNTimes:: push af ld a, c and a @@ -44,9 +44,9 @@ AppendToMovementBufferNTimes:: ; 00:1a03 pop af ret -.asm_1a0a: ; 00:1a0a +.asm_1a0a: pop af -.asm_1a0b: ; 00:1a0b +.asm_1a0b: call AppendToMovementBuffer dec c jr nz, .asm_1a0b @@ -61,7 +61,7 @@ ComputePathToWalkToPlayer:: dec a cpl ld h, RIGHT -.asm_1a1d: ; 00:1a1d +.asm_1a1d: ld d, a ld a, c sub e @@ -70,7 +70,7 @@ ComputePathToWalkToPlayer:: dec a cpl ld l, DOWN -.asm_1a28: ; 00:1a28 +.asm_1a28: ld e, a cp d jr nc, .asm_1a32 @@ -80,7 +80,7 @@ ComputePathToWalkToPlayer:: ld a, d ld d, e ld e, a -.asm_1a32: ; 00:1a32 +.asm_1a32: pop af ld b, a ld a, h @@ -93,7 +93,7 @@ ComputePathToWalkToPlayer:: call AppendToMovementBufferNTimes ret -.GetMovementData: ; 00:1a45 +.GetMovementData: push de push hl ld l, b @@ -110,11 +110,11 @@ ComputePathToWalkToPlayer:: pop de ret -.Data: ; 00:1a58 +.Data: db $04, $05, $06, $07 db $08, $09, $0a, $0b db $0c, $0d, $0e, $0f - + ; slow_step DOWN ; slow_step UP ; slow_step LEFT @@ -126,4 +126,4 @@ ComputePathToWalkToPlayer:: ; big_step DOWN ; big_step UP ; big_step LEFT -; big_step RIGHT
\ No newline at end of file +; big_step RIGHT diff --git a/home/names.asm b/home/names.asm index 96100cd..656835a 100644 --- a/home/names.asm +++ b/home/names.asm @@ -1,8 +1,9 @@ INCLUDE "constants.asm" + SECTION "home/names.asm@Names", ROM0 -NamesPointers:: ; 00:36c8 +NamesPointers:: ; entries correspond to GetName constants (see constants/text_constants.asm) dba PokemonNames ; MON_NAME (not used; jumps to GetPokemonName) dba MoveNames ; MOVE_NAME @@ -13,7 +14,7 @@ NamesPointers:: ; 00:36c8 dba TrainerClassNames ; TRAINER_NAME dbw $04, $5677 ; MOVE_DESC_NAME_BROKEN (wrong bank..?) -GetName:: ; 00:36e0 +GetName:: ; Return name wCurSpecies from name list wNamedObjectTypeBuffer in wStringBuffer1. ldh a, [hROMBank] @@ -87,7 +88,7 @@ GetNthString:: pop bc ret -GetPokemonName: ; 00:3741 +GetPokemonName: ; Get Pokemon name wNamedObjectIndexBuffer. ldh a, [hROMBank] @@ -119,7 +120,7 @@ endr call Bankswitch ret -GetItemName:: ; 376F +GetItemName:: ; given an item ID at [wNamedObjectIndexBuffer], store the name of the item into a string ; starting at wStringBuffer1 push hl @@ -206,17 +207,17 @@ GetMachineName:: .HMTextEnd: db "@" -IsHM:: ; 00:37e4 - cp ITEM_TM01 ; ??? +IsHM:: + cp ITEM_HM01_RED jr c, .false - cp ITEM_TM05 ; ??? + cp ITEM_TM01_RED ret .false and a ret -IsHMMove:: ; 00:37ed +IsHMMove:: ld hl, .HMMoves ld de, 1 jp FindItemInTable @@ -229,7 +230,7 @@ IsHMMove:: ; 00:37ed db MOVE_FLASH db -1 -Unreferenced_GetMoveName:: ; 00:37fc +Unreferenced_GetMoveName:: push hl ld a, MOVE_NAME ld [wNamedObjectTypeBuffer], a @@ -240,13 +241,14 @@ Unreferenced_GetMoveName:: ; 00:37fc pop hl ret + SECTION "home/names.asm@GetNick", ROM0 -GetCurNick:: ; 3a91 (00:3a91) +GetCurNick:: ld a, [wWhichPokemon] ld hl, wPartyMonNicknames -GetNick: ; 00:3a97 +GetNick: ; Get nickname a from list hl. push hl push bc @@ -259,4 +261,4 @@ GetNick: ; 00:3a97 callab CorrectNickErrors pop bc pop hl - ret
\ No newline at end of file + ret diff --git a/home/oam_dma.asm b/home/oam_dma.asm index db08f0e..d48f98e 100644 --- a/home/oam_dma.asm +++ b/home/oam_dma.asm @@ -2,19 +2,19 @@ INCLUDE "constants.asm" SECTION "home/oam_dma.asm", ROMX -WriteOAMDMACodeToHRAM:: ; 4153 +WriteOAMDMACodeToHRAM:: ld c, LOW(hOAMDMA) ld b, .OAMDMAEnd - .OAMDMA ld hl, .OAMDMA .loop ld a, [hli] - ld [$ff00+c], a + ldh [c], a inc c dec b jr nz, .loop ret -.OAMDMA ; 4161 +.OAMDMA ld a, HIGH(wVirtualOAM) ldh [rDMA], a ld a, $28 @@ -22,4 +22,4 @@ WriteOAMDMACodeToHRAM:: ; 4153 dec a jr nz, .wait ret -.OAMDMAEnd ; 416b
\ No newline at end of file +.OAMDMAEnd diff --git a/home/overworld.asm b/home/overworld.asm index 412d3b9..d8bf242 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -1,8 +1,9 @@ INCLUDE "constants.asm" + SECTION "home/overworld.asm@Startmenu and Select Button Check", ROM0 -OverworldStartButtonCheck:: ; 2c05 (0:2c05) +OverworldStartButtonCheck:: ldh a, [hJoyState] bit START_F, a ret z @@ -17,7 +18,7 @@ OverworldStartButtonCheck:: ; 2c05 (0:2c05) .regularMenu callba DisplayStartMenu jr CheckStartmenuSelectHook -SelectButtonFunction:: ; 2c2a (0:2c2a) +SelectButtonFunction:: callab CheckRegisteredItem CheckStartmenuSelectHook: ldh a, [hStartmenuCloseAndSelectHookEnable] @@ -36,7 +37,7 @@ CheckStartmenuSelectHook: dec a ret -Function2c4a: ; 2c4a (0:2c4a) +Function2c4a: ; copy of Function2ba8 ; calling Functiond4e6 instead of Functiond6e4 .loop @@ -50,7 +51,7 @@ Function2c4a: ; 2c4a (0:2c4a) scf ret -Function2c5a: ; 2c5a (0:2c5a) +Function2c5a: ldh a, [hROMBank] push af ld a, BANK(Function50b9) @@ -72,7 +73,7 @@ Function2c5a: ; 2c5a (0:2c5a) call Bankswitch ret -UpdateAndTransferToolgear: ; 2c8b (0:2c8b) +UpdateAndTransferToolgear: call DelayFrame call UpdateToolgear ld hl, wToolgearFlags @@ -80,7 +81,7 @@ UpdateAndTransferToolgear: ; 2c8b (0:2c8b) call DelayFrame ret -ScheduleNorthRowRedraw: ; 2c9a (0:2c9a) +ScheduleNorthRowRedraw: coord hl, 0, 0 call CopyToRedrawRowOrColumnSrcTiles ld a, [wBGMapAnchor] @@ -91,7 +92,7 @@ ScheduleNorthRowRedraw: ; 2c9a (0:2c9a) ldh [hRedrawRowOrColumnMode], a ret -ScheduleSouthRowRedraw: ; 2caf (0:2caf) +ScheduleSouthRowRedraw: coord hl, 0, SCREEN_HEIGHT - 2 call CopyToRedrawRowOrColumnSrcTiles ld a, [wBGMapAnchor] @@ -111,7 +112,7 @@ ScheduleSouthRowRedraw: ; 2caf (0:2caf) ldh [hRedrawRowOrColumnMode], a ret -ScheduleEastColumnRedraw: ; 2cd0 (0:2cd0) +ScheduleEastColumnRedraw: coord hl, SCREEN_WIDTH - 2, 0 call ScheduleColumnRedrawHelper ld a, [wBGMapAnchor] @@ -129,7 +130,7 @@ ScheduleEastColumnRedraw: ; 2cd0 (0:2cd0) ldh [hRedrawRowOrColumnMode], a ret -ScheduleWestColumnRedraw: ; 2cef (0:2cef) +ScheduleWestColumnRedraw: coord hl, 0, 0 call ScheduleColumnRedrawHelper ld a, [wBGMapAnchor] @@ -140,7 +141,7 @@ ScheduleWestColumnRedraw: ; 2cef (0:2cef) ldh [hRedrawRowOrColumnMode], a ret -CopyToRedrawRowOrColumnSrcTiles: ; 2d04 (0:2d04) +CopyToRedrawRowOrColumnSrcTiles: ld de, wRedrawRowOrColumnSrcTiles ld c, 2 * SCREEN_WIDTH .loop @@ -151,7 +152,7 @@ CopyToRedrawRowOrColumnSrcTiles: ; 2d04 (0:2d04) jr nz, .loop ret -ScheduleColumnRedrawHelper: ; 2d10 (0:2d10) +ScheduleColumnRedrawHelper: ld de, wRedrawRowOrColumnSrcTiles ld c, SCREEN_HEIGHT .loop @@ -171,6 +172,7 @@ ScheduleColumnRedrawHelper: ; 2d10 (0:2d10) jr nz, .loop ret + SECTION "home/overworld.asm@QueueScript", ROM0 QueueScript:: @@ -182,4 +184,4 @@ QueueScript:: ld [wQueuedScriptAddr], a ld a, h ld [wQueuedScriptAddr + 1], a - ret
\ No newline at end of file + ret diff --git a/home/pokemon.asm b/home/pokemon.asm index 7a72646..ee0c1f9 100644 --- a/home/pokemon.asm +++ b/home/pokemon.asm @@ -1,8 +1,9 @@ INCLUDE "constants.asm" + SECTION "home/pokemon.asm@3A4B", ROM0 -GetMonHeader:: ; 3a4b (0:3a4b) +GetMonHeader:: ; copies the base stat data of a pokemon to wMonHeader ; INPUT: ; [wCurSpecies] = pokemon ID in dex order @@ -14,7 +15,7 @@ GetMonHeader:: ; 3a4b (0:3a4b) ld a, BANK(MonBaseStats) call Bankswitch ld a, [wCurSpecies] - cp DEX_FD + cp DEX_EGG jr z, .egg dec a ld bc, MonBaseStatsEnd - MonBaseStats @@ -33,7 +34,7 @@ GetMonHeader:: ; 3a4b (0:3a4b) ld [hl], e inc hl ld [hl], d - jr .done + jr .done ; useless .done ld a, [wCurSpecies] ld [wMonHIndex], a @@ -44,9 +45,10 @@ GetMonHeader:: ; 3a4b (0:3a4b) pop bc ret + SECTION "home/pokemon.asm@3AED", ROM0 -UncompressMonSprite:: ; 3aed (0:3aed) +UncompressMonSprite:: ; Uncompresses the front or back sprite of the specified mon ; assumes the corresponding mon header is already loaded ; hl contains offset to sprite pointer ($b for front or $d for back) @@ -97,7 +99,7 @@ UncompressMonSprite:: ; 3aed (0:3aed) ld a, BANK(AnnonPics) jp UncompressSpriteData -LoadMonFrontSprite:: ; 3b3f +LoadMonFrontSprite:: ; Uncompress Pokémon Front Sprite for ; mon currently loaded in wMonHeader ; to 0x9000 @@ -112,7 +114,7 @@ LoadMonFrontSprite:: ; 3b3f pop de ; fallthrough -LoadUncompressedSpriteData:: ; 3b4c (0:3b4c) +LoadUncompressedSpriteData:: ; postprocesses uncompressed sprite chunks to a 2bpp sprite and loads it into video ram ; calculates alignment parameters to place both sprite chunks in the center of the 7*7 tile sprite buffers ; de: destination location @@ -165,13 +167,13 @@ LoadUncompressedSpriteData:: ; 3b4c (0:3b4c) call InterlaceMergeSpriteBuffers ret -ZeroSpriteBuffer:: ; 3ba1 (0:3ba1) +ZeroSpriteBuffer:: ; fills the sprite buffer (pointed to in hl) with zeros ld bc, SPRITEBUFFERSIZE xor a jp ByteFill -AlignSpriteDataCentered:: ; 3ba8 (0:3ba8) +AlignSpriteDataCentered:: ; copies and aligns the sprite data properly inside the sprite buffer ; sprite buffers are 7*7 tiles in size, the loaded sprite is centered within this area ldh a, [hSpriteOffset] @@ -199,7 +201,7 @@ AlignSpriteDataCentered:: ; 3ba8 (0:3ba8) jr nz, .columnLoop ret -InterlaceMergeSpriteBuffers:: ; 3bc6 (0:3bc6) +InterlaceMergeSpriteBuffers:: ; combines the (7*7 tiles, 1bpp) sprite chunks in buffer 0 and 1 into a 2bpp sprite located in buffer 1 through 2 ; in the resulting sprite, the rows of the two source sprites are interlaced ; de: output address @@ -216,7 +218,7 @@ InterlaceMergeSpriteBuffers:: ; 3bc6 (0:3bc6) call CloseSRAM ret -_InterlaceMergeSpriteBuffers:: ; 3bdf (0:3bdf) +_InterlaceMergeSpriteBuffers:: ; actual implementation of InterlaceMergeSpriteBuffers ; sprite flipping is now done during interlace merge loop ; and not as second loop after regular interlace merge @@ -287,4 +289,4 @@ _InterlaceMergeSpriteBuffers:: ; 3bdf (0:3bdf) dec a ldh [hSpriteInterlaceCounter], a jr nz, .interlaceLoopFlipped - ret
\ No newline at end of file + ret diff --git a/home/predef.asm b/home/predef.asm index e4fbfdd..f9f195a 100644 --- a/home/predef.asm +++ b/home/predef.asm @@ -2,7 +2,7 @@ INCLUDE "constants.asm" SECTION "home/predef.asm", ROM0 -Predef:: ; 2fde +Predef:: ld [wPredefID], a ldh a, [hROMBank] push af @@ -21,7 +21,7 @@ Predef:: ; 2fde ld a, l ld [wPredefHL + 1], a pop hl - ld a, h ; Could have used `pop af` instead + ld a, h call Bankswitch ld a, [wPredefHL] ld h, a @@ -42,4 +42,4 @@ Predef:: ; 2fde ld b, a ld a, [wPredefBC + 1] ld c, a - ret
\ No newline at end of file + ret diff --git a/home/print_bcd.asm b/home/print_bcd.asm index ff4d8cb..87851ae 100644 --- a/home/print_bcd.asm +++ b/home/print_bcd.asm @@ -13,7 +13,7 @@ SECTION "home/print_bcd.asm", ROM0 ; bits 0-5: length of BCD number in bytes ; Note that bits 5 and 7 are modified during execution. The above reflects ; their meaning at the beginning of the functions's execution. -PrintBCDNumber:: ; 3ab2 (0:3ab2) +PrintBCDNumber:: ld b, c ; save flags in b res 7, c res 6, c ; c now holds the length @@ -39,7 +39,7 @@ PrintBCDNumber:: ; 3ab2 (0:3ab2) .done ret -PrintBCDDigit:: ; 3ad5 (0:3ad5) +PrintBCDDigit:: and $0f and a jr z, .zeroDigit @@ -56,4 +56,3 @@ PrintBCDDigit:: ; 3ad5 (0:3ad5) ld a, " " ld [hli], a ret -; 0x3aed
\ No newline at end of file diff --git a/home/print_hex.asm b/home/print_hex.asm index 1108afa..07d3736 100644 --- a/home/print_hex.asm +++ b/home/print_hex.asm @@ -2,7 +2,7 @@ INCLUDE "constants.asm" SECTION "home/print_hex.asm", ROM0 -PrintHexBytes: ; 3597 (0:3597) +PrintHexBytes: ; Print c hex bytes located at de to hl .loop push bc @@ -12,7 +12,7 @@ PrintHexBytes: ; 3597 (0:3597) jr nz, .loop ret -PrintHexByte:: ; 35a0 (0:35a0) +PrintHexByte:: ; Print one hex byte located at de to hl ld a, [de] swap a @@ -26,9 +26,8 @@ PrintHexByte:: ; 35a0 (0:35a0) inc de ret -GetHexDigit: ; 35b2 (0:35b2) -; Get a hex digit tile number -; in a. +GetHexDigit: +; Get a hex digit tile number in a ld bc, .hexDigitTable add c ld c, a @@ -39,4 +38,4 @@ GetHexDigit: ; 35b2 (0:35b2) ret .hexDigitTable: - db "0123456789ABCDEF"
\ No newline at end of file + db "0123456789ABCDEF" diff --git a/home/print_num.asm b/home/print_num.asm index 3a2a2fb..c40f826 100644 --- a/home/print_num.asm +++ b/home/print_num.asm @@ -2,7 +2,7 @@ INCLUDE "constants.asm" SECTION "home/print_num.asm", ROM0 -PrintNumber:: ; 3460 (0:3460) +PrintNumber:: ; function to print a number ; de = address of number in little-endian format ; hl = destination address @@ -160,7 +160,7 @@ PrintNumber:: ; 3460 (0:3460) pop bc ret -.PrintDigit: ; 3525 (0:3525) +.PrintDigit: ld c, $00 .loop ldh a, [hPrintNumDivisor] @@ -233,7 +233,7 @@ PrintNumber:: ; 3460 (0:3460) ld [hl], "0" ret -.AdvancePointer: ; 3589 (0:3589) +.AdvancePointer: ; increments the pointer unless leading zeroes are not being printed, ; the number is left-aligned, and no nonzero digits have been printed yet bit 7, d ; print leading zeroes? @@ -245,4 +245,4 @@ PrintNumber:: ; 3460 (0:3460) ret z ; don't advance if leading digit is zero .inc inc hl - ret
\ No newline at end of file + ret diff --git a/home/print_text.asm b/home/print_text.asm index f45a045..52f2489 100644 --- a/home/print_text.asm +++ b/home/print_text.asm @@ -2,7 +2,7 @@ include "constants.asm" SECTION "home/print_text.asm", ROM0 -PrintLetterDelay:: ; 33a3 (0:33a3) +PrintLetterDelay:: ld a, [wce5f] bit 4, a ret nz @@ -44,23 +44,22 @@ PrintLetterDelay:: ; 33a3 (0:33a3) pop de pop hl ret -; 0x33e3 -CopyDataUntil:: ; 33e3 +CopyDataUntil:: ; Copy [hl .. bc) to de. ; In other words, the source data is ; from hl up to but not including bc, ; and the destination is de. -.asm_33e3: ; 00:33e3 +.loop: ld a, [hli] ld [de], a inc de ld a, h cp b - jr nz, .asm_33e3 + jr nz, .loop ld a, l cp c - jr nz, .asm_33e3 - ret
\ No newline at end of file + jr nz, .loop + ret diff --git a/home/random.asm b/home/random.asm index 690c4b9..a342976 100644 --- a/home/random.asm +++ b/home/random.asm @@ -62,4 +62,4 @@ BattleRandom:: pop af call Bankswitch ld a, [wPredefHL + 1] - ret
\ No newline at end of file + ret diff --git a/home/rst.asm b/home/rst.asm index 6fea377..a3c5a59 100644 --- a/home/rst.asm +++ b/home/rst.asm @@ -22,4 +22,6 @@ SECTION "home/rst.asm@rst30", ROM0 rst $38 SECTION "home/rst.asm@rst38", ROM0 - jp $F080 ; Jumps in the middle of unmapped memory. Probably used to trigger a breakpoint of sorts. + ; Jumps in the middle of unmapped echo RAM. + ; Probably used to trigger a breakpoint. + jp $F080 diff --git a/home/rtc.asm b/home/rtc.asm index dd38876..bc81e80 100644 --- a/home/rtc.asm +++ b/home/rtc.asm @@ -2,14 +2,16 @@ include "constants.asm" SECTION "home/rtc.asm", ROM0 -UpdateTimeOfDayPalettes: ; 32b (0:032b) +UpdateTimeOfDayPalettes: ld a, [wVramState] bit 0, a ret z + ; fallthrough + TimeOfDayPals:: - callab _TimeOfDayPals ; Func_8c2e3 + callab _TimeOfDayPals ret -UpdateTimePals:: ; 33a - callab _UpdateTimePals ; Func_8c335 - ret
\ No newline at end of file +UpdateTimePals:: + callab _UpdateTimePals + ret diff --git a/home/scrolling_menu.asm b/home/scrolling_menu.asm index ed2fd6b..5a73bba 100644 --- a/home/scrolling_menu.asm +++ b/home/scrolling_menu.asm @@ -36,7 +36,7 @@ Function3810:: ld a, [wMenuJoypad] ret -ScrollingMenu:: ; 00:383e +ScrollingMenu:: call CopyMenuData ldh a, [hROMBank] push af @@ -60,7 +60,7 @@ Function385a:: Function385d:: callab Function_8f1cb -asm_3865: ; 00:3865 +asm_3865: pop hl call MenuTextBox ld c, $0 @@ -68,22 +68,22 @@ asm_3865: ; 00:3865 call CloseWindow ret -Function3872:: ; 00:3872 +Function3872:: push bc jr asm_387d Function3875:: callab PlaySpriteAnimationsAndDelayFrame -asm_387d: ; 00:387d +asm_387d: pop bc call GetJoypad ldh a, [hJoyDown] and A_BUTTON | B_BUTTON - jr nz, .asm_388e + jr nz, .done ld a, c and a jr z, Function3872 dec c jr z, Function3872 -.asm_388e: ; 00:388e - ret
\ No newline at end of file +.done: + ret diff --git a/home/serial.asm b/home/serial.asm index 6d4568b..a0f9dd8 100644 --- a/home/serial.asm +++ b/home/serial.asm @@ -53,7 +53,7 @@ Serial:: pop af reti -Serial_ExchangeBytes:: ; 64c +Serial_ExchangeBytes:: ld a, $1 ldh [hSerialIgnoringInitialData], a .loop @@ -88,7 +88,7 @@ Serial_ExchangeBytes:: ; 64c jr nz, .loop ret -Serial_ExchangeByte:: ; 677 (0:0677) +Serial_ExchangeByte:: .loop xor a ldh [hSerialReceived], a @@ -187,14 +187,14 @@ Serial_ExchangeByte:: ; 677 (0:0677) call DelayFrame jp .loop -.delay_15_cycles: ; 70e (0:070e) +.delay_15_cycles: ld a, 15 .delay_cycles dec a jr nz, .delay_cycles ret -CheckwLinkTimeoutFramesNonzero: ; 714 (0:0714) +CheckwLinkTimeoutFramesNonzero: push hl ld hl, wLinkTimeoutFrames ld a, [hli] @@ -202,7 +202,7 @@ CheckwLinkTimeoutFramesNonzero: ; 714 (0:0714) pop hl ret -SerialDisconnected: ; 71c (0:071c) +SerialDisconnected: dec a ld [wLinkTimeoutFrames], a ld [wLinkTimeoutFrames + 1], a @@ -241,7 +241,7 @@ Serial_PrintWaitingTextAndSyncAndExchangeNybble:: call WaitLinkTransfer jp ReloadTilesFromBuffer -WaitLinkTransfer:: ; 75c (0:075c) +WaitLinkTransfer:: ld a, $ff ld [wOtherPlayerLinkAction], a .loop @@ -286,7 +286,7 @@ WaitLinkTransfer:: ; 75c (0:075c) ld [wOtherPlayerLinkMode], a ret -LinkTransfer:: ; 7a0 (0:07a0) +LinkTransfer:: push bc ld b, $60 ld a, [wLinkMode] @@ -310,7 +310,7 @@ LinkTransfer:: ; 7a0 (0:07a0) pop bc ret -.Receive: ; 7c4 (0:07c4) +.Receive: ldh a, [hSerialReceive] ld [wOtherPlayerLinkMode], a and $f0 @@ -323,7 +323,7 @@ LinkTransfer:: ; 7a0 (0:07a0) ld [wOtherPlayerLinkAction], a ret -LinkDataReceived:: ; 7d9 (0:07d9) +LinkDataReceived:: ; Let the other system know that the data has been received. xor a ldh [hSerialSend], a @@ -344,4 +344,4 @@ Unreferenced_Function7e6:: ldh [hSerialReceive], a ld a, (1 << rSC_ON) ldh [rSC], a - ret
\ No newline at end of file + ret diff --git a/home/sram.asm b/home/sram.asm index 5089254..53798cd 100644 --- a/home/sram.asm +++ b/home/sram.asm @@ -2,7 +2,7 @@ INCLUDE "constants.asm" SECTION "home/sram.asm", ROM0 -OpenSRAM:: ; 32a7 +OpenSRAM:: push af ld a, 1 ld [MBC3LatchClock], a @@ -12,10 +12,10 @@ OpenSRAM:: ; 32a7 ld [MBC3SRamBank], a ret -CloseSRAM:: ; 32b7 +CloseSRAM:: push af ld a, SRAM_DISABLE ld [MBC3LatchClock], a ld [MBC3SRamEnable], a pop af - ret
\ No newline at end of file + ret diff --git a/home/tables.asm b/home/tables.asm index e5d9c1e..c005ffc 100755 --- a/home/tables.asm +++ b/home/tables.asm @@ -4,7 +4,7 @@ SECTION "home/tables.asm", ROM0 ; find value a from table hl with row length de ; returns carry and row index b if successful -FindItemInTable: ; 00:35F8 +FindItemInTable: ld b, 0 ld c, a @@ -24,4 +24,4 @@ FindItemInTable: ; 00:35F8 .success scf - ret
\ No newline at end of file + ret diff --git a/home/talk_to_npc.asm b/home/talk_to_npc.asm index 3206fe5..0be8e8e 100644 --- a/home/talk_to_npc.asm +++ b/home/talk_to_npc.asm @@ -7,18 +7,18 @@ MapDefaultText:: call OpenTextbox ret -GameplayText:: ; 00:302c +GameplayText:: text "ゲームフりーク!" done -Function3036:: ; 3036 +Function3036:: ld hl, EmptyText ret -EmptyText:: ; 00:303a +EmptyText:: db "@" -CallMapTextSubroutine:: ; 00:303b +CallMapTextSubroutine:: ld a, [wTalkingTargetType] bit 0, a jr z, asm_3062 @@ -32,14 +32,14 @@ CallMapTextSubroutine:: ; 00:303b push de jp hl -.Return: ; 00:3051 +.Return: call Function307a ret -Function3055:: ; 00:3055 +Function3055:: ldh a, [hFFEA] ld b, a -.Loop: ; 00:3058 +.Loop: ld a, [hli] cp $ff ret z @@ -47,7 +47,7 @@ Function3055:: ; 00:3055 jp z, SetFFInAccumulator jr .Loop -asm_3062: ; 00:3062 +asm_3062: ld a, [wTalkingTargetType] bit 1, a ret z @@ -66,14 +66,14 @@ asm_3062: ; 00:3062 push de jp hl -Function307a:: ; 00:307a +Function307a:: ld hl, wTalkingTargetType res 0, [hl] res 1, [hl] call SetFFInAccumulator ret -PrintTextboxDebugNumbers:: ; 00:3085 +PrintTextboxDebugNumbers:: push hl push de push bc @@ -84,12 +84,12 @@ PrintTextboxDebugNumbers:: ; 00:3085 ld de, hFFEA jr .PrintNum -.CheckSign: ; 00:3097 +.CheckSign: bit 1, a jr z, .PrintNum ld de, hFFEE -.PrintNum: ; 00:309e +.PrintNum: hlcoord 4, 12 lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNumber @@ -102,7 +102,7 @@ PrintTextboxDebugNumbers:: ; 00:3085 pop hl ret -QueueMapTextSubroutine:: ; 00:30b7 +QueueMapTextSubroutine:: ldh a, [hJoyState] bit A_BUTTON_F, a jp z, ClearAccumulator ; if we didn't press a @@ -130,7 +130,7 @@ QueueMapTextSubroutine:: ; 00:30b7 call SetFFInAccumulator ret -Function30e8:: ; 00:30e8 +Function30e8:: call GetFacingSignpost jp nc, ClearAccumulator ; if not facing person or sign ld a, e @@ -146,14 +146,14 @@ Function30e8:: ; 00:30e8 call SetFFInAccumulator ret -GetFacingPersonText:: ; 00:3103 +GetFacingPersonText:: callba Function776e ret nc call TurnNPCTalkingTo scf ret -OpenTextbox:: ; 00:3111 +OpenTextbox:: ; Opens a textbox and waits for input push hl call PrepareTextbox @@ -161,28 +161,28 @@ OpenTextbox:: ; 00:3111 bit DEBUG_FIELD_F, a call nz, PrintTextboxDebugNumbers pop hl - call TextboxIdle + call TextboxIdle ret -OpenTextboxNoInput:: ; 00:3122 - push hl - call PrepareTextbox +OpenTextboxNoInput:: + push hl + call PrepareTextbox pop hl -TextboxIdle:: ; 00:3127 +TextboxIdle:: ; Prints text, then waits for A or B to be pressed, unless bit 5 of JoypadFlags is set. call PrintTextBoxText .Loop ld a, [wJoypadFlags] bit 5, a - res 5, a - ld [wJoypadFlags], a + res 5, a + ld [wJoypadFlags], a jr nz, .Escape call GetJoypad ldh a, [hJoyDown] and A_BUTTON | B_BUTTON - jr nz, .Escape - call UpdateTime + jr nz, .Escape + call UpdateTime call UpdateTimeOfDayPalettes call DelayFrame jr .Loop @@ -190,16 +190,16 @@ TextboxIdle:: ; 00:3127 call TextboxCleanup ret -PrepareTextbox:: ; 00:314E +PrepareTextbox:: call ClearWindowData ldh a, [hROMBank] - push af - ld a, 01 + push af + ld a, 01 call Bankswitch call ReanchorBGMap_NoOAMUpdate hlcoord 0, 12 ;in the tilemap in WRAM - ld b, 04 - ld c, $12 + ld b, 04 + ld c, $12 call DrawTextBox call WaitBGMap call LoadFonts_NoOAMUpdate @@ -207,27 +207,27 @@ PrepareTextbox:: ; 00:314E call Bankswitch ret -TextboxCleanup: ; 00:3171 +TextboxCleanup: callab ReanchorBGMap_NoOAMUpdate call UpdateSprites xor a ldh [hBGMapMode], a ld a, $90 ldh [hWY], a - call Function318f + call Function318f ld hl, wToolgearFlags res 7, [hl] call InitToolgearBuffer ret -Function318f: ; 00:318f +Function318f: callab Function140ea call RedrawPlayerSprite ret - -TurnNPCTalkingTo:: ; 00:319b + +TurnNPCTalkingTo:: ; If an NPC is allowed to turn when talked to, turn it. - ldh a, [hObjectStructIndexBuffer] + ldh a, [hObjectStructIndexBuffer] call GetObjectStruct ld hl, OBJECT_SPRITE add hl, bc @@ -250,17 +250,17 @@ TurnNPCTalkingTo:: ; 00:319b ldh [hFFEA], a ret -Function31C3:: ; 00:31C3 +Function31C3:: ret -CheckInlineTrainer:: ; 00:31C4 +CheckInlineTrainer:: ; Passed de is the pointer to a map_object struct. If it's an inline trainer, write to relevant wram region. ld hl, MAPOBJECT_OBJECT_STRUCT_ID add hl, de ld a, [hl] call GetObjectStruct call GetInlineMapObject - jr nc, .Escape + jr nc, .Escape ld hl, MAPOBJECT_POINTER_HI add hl, de ld a, [hl] @@ -270,7 +270,7 @@ CheckInlineTrainer:: ; 00:31C4 add hl, de ld a, [hl] add a, a - ld hl, wCurrMapInlineTrainers + ld hl, wCurrMapInlineTrainers add a, l ld l, a jr nc, .NoCarry @@ -282,7 +282,7 @@ CheckInlineTrainer:: ; 00:31C4 .Escape ret -GetInlineMapObject:: ; 00:31EB +GetInlineMapObject:: ;bc is start of object struct. if c flag set, returns distance in B and direction in C ld hl, OBJECT_NEXT_MAP_X add hl, bc @@ -294,27 +294,27 @@ GetInlineMapObject:: ; 00:31EB ld a, [wPlayerNextMapY] cp [hl] jr z, .EqualY - and a + and a ret -.EqualX +.EqualX ld hl, OBJECT_NEXT_MAP_Y add hl, bc ld a, [wPlayerNextMapY] sub [hl] - jr z, .Reset - jr nc, .SetDown + jr z, .Reset + jr nc, .SetDown cpl inc a ld b, a ld c, UP scf ret -.SetDown ; 3214 +.SetDown ld b, a ld c, DOWN scf ret -.EqualY ; 3219 +.EqualY ld hl, OBJECT_NEXT_MAP_X add hl, bc ld a, [wPlayerNextMapX] @@ -327,16 +327,16 @@ GetInlineMapObject:: ; 00:31EB ld c, LEFT scf ret -.SetRight ; 322C +.SetRight ld b, a ld c, RIGHT scf ret -.Reset ; 3231 +.Reset and a ret - -CheckBPressedDebug: ; 3233 + +CheckBPressedDebug: ; If in debug mode, returns a check on the B button. ld a, [wDebugFlags] bit DEBUG_FIELD_F, a @@ -345,13 +345,11 @@ CheckBPressedDebug: ; 3233 bit B_BUTTON_F, a ret -ClearAccumulator:: ; 323E +ClearAccumulator:: xor a ret - -SetFFInAccumulator:: ; 3240 + +SetFFInAccumulator:: xor a dec a ret - -; 3243
\ No newline at end of file diff --git a/home/text.asm b/home/text.asm index abca7ab..fbf2ce5 100644 --- a/home/text.asm +++ b/home/text.asm @@ -729,4 +729,4 @@ TextCommands:: ; 120c dw Text_PlaySound dw Text_PlaySound dw Text_PlaySound - dw Text_PlaySound
\ No newline at end of file + dw Text_PlaySound diff --git a/home/tilemap.asm b/home/tilemap.asm index e814e5b..659974a 100644 --- a/home/tilemap.asm +++ b/home/tilemap.asm @@ -11,9 +11,9 @@ Function360b:: call GetMemSGBLayout jr WaitBGMap -ClearBGPalettes:: ; 361e +ClearBGPalettes:: call ClearPalettes -WaitBGMap:: ; 00:3621 +WaitBGMap:: ; Tell VBlank to update BG Map ld a, $1 ldh [hBGMapMode], a @@ -22,29 +22,29 @@ WaitBGMap:: ; 00:3621 call DelayFrames ret -SetPalettes:: ; 00:362b +SetPalettes:: ld a, %11100100 ldh [rBGP], a ld a, %11010000 ldh [rOBP0], a ret -ClearPalettes:: ; 00:3634 +ClearPalettes:: xor a ldh [rBGP], a ldh [rOBP0], a ldh [rOBP1], a ret -GetMemSGBLayout:: ; 00:363c +GetMemSGBLayout:: ld b, SGB_RAM -GetSGBLayout:: ; 00:363e +GetSGBLayout:: ld a, [wSGB] and a ret z predef_jump Function928b -SetHPPal:: ; 00:3648 +SetHPPal:: ld a, e cp 27 ; 56.25% ld d, $0 @@ -53,14 +53,14 @@ SetHPPal:: ; 00:3648 inc d jr nc, .done inc d -.done: ; 00:3655 +.done: ld [hl], d ret -Function3657:: ; 00:3657 +Function3657:: call DisableLCD callab Function140d9 call LoadFont call UpdateSprites call EnableLCD - ret
\ No newline at end of file + ret diff --git a/home/tileset.asm b/home/tileset.asm index d96018f..ddde57b 100644 --- a/home/tileset.asm +++ b/home/tileset.asm @@ -3,7 +3,7 @@ include "constants.asm" SECTION "home/tileset.asm", ROM0 -LoadTilesetGFX:: ; 2d26 +LoadTilesetGFX:: call GetMapEnvironment cp TOWN jr z, .exterior @@ -27,7 +27,7 @@ LoadTilesetGFX:: ; 2d26 ret .exterior - ld de, CommonExteriorTilesGFX ; TODO: maybe find a better name + ld de, CommonExteriorTilesGFX ld hl, vTileset lb bc, BANK(CommonExteriorTilesGFX), $20 call Get2bpp @@ -46,7 +46,7 @@ LoadTilesetGFX:: ; 2d26 ret -RefreshPlayerCoords:: ; 2d74 +RefreshPlayerCoords:: ld a, [wXCoord] add a, 4 ld d, a @@ -103,8 +103,7 @@ RefreshPlayerCoords:: ; 2d74 ld [hl], a ret - -BufferScreen:: ; 2dcd +BufferScreen:: ld hl, wOverworldMapAnchor ld a, [hli] ld h, [hl] @@ -132,7 +131,7 @@ BufferScreen:: ; 2dcd jr nz, .row ret -SaveScreen:: ; 2df1 +SaveScreen:: ld hl, wOverworldMapAnchor ld a, [hli] ld h, [hl] @@ -178,7 +177,7 @@ SaveScreen:: ; 2df1 ld b, 5 ld c, 5 -.load_neighbor ; 2e35 +.load_neighbor .row push bc push hl @@ -208,7 +207,7 @@ SaveScreen:: ; 2df1 ret -RefreshTiles:: ; 2e52 +RefreshTiles:: call .left_right call .up_down ld a, [wPlayerNextMapX] @@ -219,7 +218,7 @@ RefreshTiles:: ; 2e52 ld [wPlayerStandingTile], a ret -.up_down ; 2e67 +.up_down ld a, [wPlayerNextMapX] ld d, a ld a, [wPlayerNextMapY] @@ -234,7 +233,7 @@ RefreshTiles:: ; 2e52 ld [wTileUp], a ret -.left_right ; 2e80 +.left_right ld a, [wPlayerNextMapX] ld d, a ld a, [wPlayerNextMapY] @@ -250,7 +249,7 @@ RefreshTiles:: ; 2e52 ret -GetFacingTileCoord:: ; 2e99 +GetFacingTileCoord:: ld a, [wPlayerWalking] ; TODO: wPlayerDirection in Crystal. Not here? and %1100 srl a @@ -292,7 +291,7 @@ GetFacingTileCoord:: ; 2e99 db 1, 0 dw wTileRight -GetCoordTile:: ; 2ece +GetCoordTile:: ; Get the collision byte for tile d, e call GetBlockLocation ld a, [hl] @@ -326,7 +325,7 @@ GetCoordTile:: ; 2ece ld a, -1 ret -GetBlockLocation:: ; 2ef8 +GetBlockLocation:: ld a, [wMapWidth] add a, 6 ld c, a @@ -355,7 +354,7 @@ GetBlockLocation:: ; 2ef8 add hl, bc ret -GetFacingSignpost:: ; 00:2f1d +GetFacingSignpost:: call GetFacingTileCoord ld b, a ld a, d @@ -369,7 +368,7 @@ GetFacingSignpost:: ; 00:2f1d ret z ld c, a ld hl, wCurrMapSigns -.asm_2f32: ; 00:2f32 +.asm_2f32: ld a, [hli] cp e jr nz, .asm_2f3e @@ -380,9 +379,9 @@ GetFacingSignpost:: ; 00:2f1d cp b ; useless comparison jr .asm_2f46 -.asm_2f3e: ; 00:2f3e +.asm_2f3e: inc hl -.asm_2f3f: ; 00:2f3f +.asm_2f3f: inc hl inc hl dec c @@ -390,11 +389,11 @@ GetFacingSignpost:: ; 00:2f1d xor a ret -.asm_2f46: ; 00:2f46 +.asm_2f46: scf ret -LoadTileset:: ; 2f48 +LoadTileset:: push hl push bc @@ -418,7 +417,7 @@ LoadTileset:: ; 2f48 pop hl ret -ReloadFontAndTileset:: ; 2f6b (00:2f6b) +ReloadFontAndTileset:: call DisableLCD ldh a, [hROMBank] push af @@ -436,8 +435,8 @@ ReloadFontAndTileset:: ; 2f6b (00:2f6b) call EnableLCD ret -LoadTilesetGFX_LCDOff:: ; 2f8d (00:2f8d) +LoadTilesetGFX_LCDOff:: call DisableLCD call LoadTilesetGFX call EnableLCD - ret
\ No newline at end of file + ret diff --git a/home/time.asm b/home/time.asm index 98f3827..ccd6f33 100644 --- a/home/time.asm +++ b/home/time.asm @@ -2,14 +2,14 @@ include "constants.asm" SECTION "home/time.asm", ROM0 -LatchClock: ; 42b (0:042b) +LatchClock: ld a, 0 ld [MBC3LatchClock], a ld a, 1 ld [MBC3LatchClock], a ret -UpdateTime:: ; 436 (0:0436) +UpdateTime:: ldh a, [hRTCStatusFlags] bit 0, a ret nz @@ -81,7 +81,7 @@ UpdateTime:: ; 436 (0:0436) db $23, $01 db $32, $02 db $3b, $03 - + Function04ac:: ld hl, hRTCStatusFlags set 0, [hl] @@ -113,7 +113,7 @@ Function04ac:: res 0, [hl] ret -Function04ea:: ; 4ea (0:04ea) +Function04ea:: ld a, SRAM_ENABLE ld [MBC3SRamEnable], a call LatchClock @@ -125,7 +125,7 @@ Function04ea:: ; 4ea (0:04ea) call CloseSRAM ret -Function0502:: ; 0502 +Function0502:: ld a, SRAM_ENABLE ld [MBC3SRamEnable], a call LatchClock @@ -135,4 +135,4 @@ Function0502:: ; 0502 res 6, a ld [MBC3RTC], a call CloseSRAM - ret
\ No newline at end of file + ret diff --git a/home/toolgear.asm b/home/toolgear.asm index c5343da..0b21454 100644 --- a/home/toolgear.asm +++ b/home/toolgear.asm @@ -23,7 +23,7 @@ newcharmap local charmap "E", $74 charmap "F", $75 ; small kana aren't actively loaded - + ; if clock shown charmap ":", $70 charmap "日", $71 @@ -35,7 +35,7 @@ newcharmap local charmap "土", $77 charmap "⚡", $78 ; power charmap "☎", $79 ; mobile - + ; active frame charmap "┌", $79 ; only if debug coords shown charmap "─", $7a @@ -45,21 +45,21 @@ newcharmap local charmap "┘", $7e charmap " ", $7f -EnableToolgear:: ; 00:2018 +EnableToolgear:: ld hl, wd153 res 0, [hl] ld hl, wToolgearFlags set 0, [hl] ret -DisableToolgear:: ; 00:2023 +DisableToolgear:: ld hl, wToolgearFlags res 0, [hl] xor a ldh [hLCDCPointer], a ret -InitToolgearBuffer:: ; 00:202c +InitToolgearBuffer:: xor a ldh [hBGMapMode], a ld hl, wToolgearFlags @@ -93,7 +93,7 @@ InitToolgearBuffer:: ; 00:202c ldh [hWY], a ret -.hide_window: ; 00:206b +.hide_window: xor a ldh [hLCDCPointer], a ld a, $90 @@ -101,7 +101,7 @@ InitToolgearBuffer:: ; 00:202c ldh [hWY], a ret -UpdateToolgear:: ; 2075 +UpdateToolgear:: ; Prepares a buffer for the clock display, which in the Debug ROM is displayed on the bottom of the screen. ; This function is called every frame, and loads special tiles into the $66-$7a space. bgcoord hl, 0, 1, wToolgearBuffer @@ -144,7 +144,7 @@ UpdateToolgear:: ; 2075 ldbgcoord_a 2, 1, wToolgearBuffer ret -.printHex:: ; 20cd +.printHex:: ; .printHex ; print c hexadecimal digits from hl to de ; clobbers: a, b @@ -158,7 +158,7 @@ UpdateToolgear:: ; 2075 jr nz, .printHex ret -.printDec:: ; 20dc +.printDec:: ; .printDec ; print c decimal digits from hl to de ; clobbers: a, b @@ -177,7 +177,7 @@ UpdateToolgear:: ; 2075 call .printDigit ret -.printDigit:: ; 20f1 +.printDigit:: ; .printDigit ; print a hexadecimal digit for value in a to de and $0f diff --git a/home/unknown.asm b/home/unknown.asm index 0fe5d28..f06101b 100644 --- a/home/unknown.asm +++ b/home/unknown.asm @@ -1,8 +1,9 @@ INCLUDE "constants.asm" + SECTION "home/unknown.asm@Empty function", ROM0 -InexplicablyEmptyFunction:: ; 2f97 +InexplicablyEmptyFunction:: rept 16 nop endr @@ -16,7 +17,7 @@ endr SECTION "home/unknown.asm@Unknown functions", ROM0 -_1FF4:: ; 1ff4 +_1FF4:: ld a, BANK(s0_a600) call OpenSRAM ld hl, s0_a600 ; TODO: label this. @@ -26,7 +27,7 @@ _1FF4:: ; 1ff4 call CloseSRAM ret -_2007:: ; 2007 +_2007:: ld a, BANK(s0_a600) call OpenSRAM ld a, [s0_a600] @@ -35,6 +36,7 @@ _2007:: ; 2007 call CloseSRAM ret + SECTION "home/unknown.asm@Unknown_20f8", ROM0 Function20f8:: @@ -42,6 +44,7 @@ Function20f8:: call Function18cc ret + SECTION "home/unknown.asm@Unknown_094c", ROM0 Function094c:: @@ -53,4 +56,4 @@ Function094c:: pop af call Bankswitch - jp DebugMenu
\ No newline at end of file + jp DebugMenu diff --git a/home/unknown_388f.asm b/home/unknown_388f.asm index 631e0c2..b230dc8 100644 --- a/home/unknown_388f.asm +++ b/home/unknown_388f.asm @@ -88,7 +88,7 @@ Function3920:: res 4, [hl] ld hl, .text call OpenTextbox - call RotateFourPalettesLeft + call GBFadeOutToBlack jp Init .text: diff --git a/home/util.asm b/home/util.asm index ed3f16b..81435c2 100644 --- a/home/util.asm +++ b/home/util.asm @@ -14,7 +14,7 @@ Function33ef:: dec a dec a ld b, $0 -.asm_33f7: ; 00:33f7 +.asm_33f7: add hl, bc dec a jr nz, .asm_33f7 @@ -26,7 +26,7 @@ Function33ef:: ld d, h ld e, l pop hl -.asm_3403: ; 00:3403 +.asm_3403: push af push bc call CopyBytes @@ -49,7 +49,7 @@ Function33ef:: pop de jp CopyBytes -SkipNames:: ; 341f +SkipNames:: ; Returns hl + a * 6 and a ret z @@ -60,7 +60,7 @@ SkipNames:: ; 341f jr nz, .loop ret -AddNTimes:: ; 3429 (0:3429) +AddNTimes:: ; Adds bc to hl, a times and a ret z @@ -71,7 +71,7 @@ AddNTimes:: ; 3429 (0:3429) ret ; 0x3430 -memcmp:: ; 3430 +memcmp:: ; TODO: rename ; Compare c bytes at hl and de ; Returns z if all equal, nz otherwise. .loop: @@ -84,7 +84,7 @@ memcmp:: ; 3430 jr nz, .loop ret -Function3439:: ; 3439 +Function3439:: ; Place 2x2 sprite from *de into OAM at slot a ld h, HIGH(wVirtualOAM) swap a @@ -103,7 +103,7 @@ Function3439:: ; 3439 ld a, $8 add c ld c, a -.Load: ; 00:3455 +.Load: ld [hl], b inc hl ld [hl], c @@ -114,4 +114,4 @@ Function3439:: ; 3439 ld a, [de] inc de ld [hli], a - ret
\ No newline at end of file + ret diff --git a/home/vblank.asm b/home/vblank.asm index ea567ea..4313390 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -2,7 +2,7 @@ INCLUDE "constants.asm" SECTION "home/vblank.asm", ROM0 -VBlank:: ; 0150 +VBlank:: push af push bc push de @@ -33,7 +33,7 @@ VBlank:: ; 0150 dw VBlank2 dw VBlank3 -VBlank0:: ; 175 (0:175) +VBlank0:: ; rng ; scx, scy, wy, wx ; bg map @@ -115,7 +115,7 @@ VBlank0:: ; 175 (0:175) ldh [rIE], a ret -VBlank1:: ; 1f6 (0:1f6) +VBlank1:: ; Simple VBlank ; ; scx, scy @@ -162,7 +162,7 @@ VBlank1:: ; 1f6 (0:1f6) ldh [rIE], a ret -VBlank2:: ; 241 (0:241) +VBlank2:: ; rng ; scx, scy, wy, wx ; joypad @@ -223,7 +223,7 @@ VBlank2:: ; 241 (0:241) call Bankswitch ret -VBlank3:: ; 2a0 (0:2a0) +VBlank3:: ; rng ; joypad ; scx, scy, wy, wx @@ -297,4 +297,3 @@ VBlank3:: ; 2a0 (0:2a0) ld a, (1 << JOYPAD | 1 << SERIAL | 1 << TIMER | 1 << LCD_STAT | 1 << VBLANK) ldh [rIE], a ret -; 0x317
\ No newline at end of file diff --git a/home/vcopy.asm b/home/vcopy.asm index b0ad6eb..aae4a2f 100644 --- a/home/vcopy.asm +++ b/home/vcopy.asm @@ -614,4 +614,3 @@ VBlankCopyFar:: ; 1558 (0:1558) ld h, a ld sp, hl ret -; 0x15b5
\ No newline at end of file diff --git a/home/window.asm b/home/window.asm index 178ad9b..90a6116 100644 --- a/home/window.asm +++ b/home/window.asm @@ -20,4 +20,4 @@ Function1fea:: call TextboxCleanup call ClearWindowData call InitToolgearBuffer - ret
\ No newline at end of file + ret diff --git a/layout.link b/layout.link index c3795e0..5515630 100644 --- a/layout.link +++ b/layout.link @@ -1,46 +1,34 @@ -; Automatically generated by map2link.py ROM0 + org $0000 + "NULL" + org $0000 "home/rst.asm@rst00" - ; $0001 org $0008 "home/rst.asm@rst08" - ; $0009 org $0010 "home/rst.asm@rst10" - ; $0011 org $0018 "home/rst.asm@rst18" - ; $0019 org $0020 "home/rst.asm@rst20" - ; $0021 org $0028 "home/rst.asm@rst28" - ; $0029 org $0030 "home/rst.asm@rst30" - ; $0031 org $0038 "home/rst.asm@rst38" - ; $003b org $0040 "home/interrupts.asm@VBlank interrupt vector" - ; $0043 org $0048 "home/interrupts.asm@LCD interrupt vector" - ; $004b org $0050 "home/interrupts.asm@Timer interrupt vector" - ; $0053 org $0058 "home/interrupts.asm@Serial interrupt vector" - ; $005b org $0060 "home/interrupts.asm@Joypad interrupt vector" - ; $0063 org $0100 "home/init.asm@Entry point" - ; $0104 org $014e "home/init.asm@Global check value" "home/vblank.asm" @@ -103,6 +91,7 @@ ROM0 "home/pokemon.asm@3AED" "home/misc_3c43.asm" "home/audio.asm" + ROMX $01 org $4000 "engine/link/place_waiting_text.asm" @@ -128,6 +117,7 @@ ROMX $01 "engine/dumps/bank01.asm@Function782c" "engine/overworld/object_collision.asm@_CheckPlayerObjectCollision" "engine/dumps/bank01.asm@SettingsScreen" + ROMX $02 "engine/dumps/bank02.asm@Function8000" "gfx.asm@Bank 2 Misc GFX" @@ -142,6 +132,7 @@ ROMX $02 "bin.asm@Unknownaebc" "gfx.asm@Corrupted SGB GFX" "bin.asm@Unknownbb43" + ROMX $03 org $4000 "engine/overworld/player_movement.asm@Player Movement" @@ -163,10 +154,10 @@ ROMX $03 "engine/dumps/bank03.asm@Functiond41d" "engine/items/item_effects.asm" "engine/dumps/bank03.asm@Functionf960" + ROMX $04 org $4000 "data/maps/maps.asm" - ; $4743 org $47cf "gfx.asm@Title Screen GFX" "engine/items/tmhm.asm" @@ -181,210 +172,202 @@ ROMX $04 "engine/unknown11d32.asm" "engine/menu/start_menu.asm" "gfx.asm@Trainer Card GFX" - ; $7be3 + ROMX $05 org $4000 "engine/overworld/player_movement.asm@_RedrawPlayerSprite" org $4150 "engine/sprites/sprites.asm@LoadOverworldSprite" - ; $4193 org $423b "engine/sprites/sprites.asm@OverworldSprites" - ; $43a7 + ROMX $06 org $4000 "gfx.asm@Bank 6 Tilesets 00" - ; $4400 org $5800 "gfx.asm@Bank 6 Tilesets 01" - ; $5c00 org $6600 "gfx.asm@Bank 6 Tilesets 02" - ; $6a00 org $7400 "gfx.asm@Bank 6 Tilesets 09" + ROMX $07 org $4000 "gfx.asm@Bank 7 Tilesets 13" - ; $4600 org $4b00 "gfx.asm@Bank 7 Tilesets 0e" - ; $5100 org $5600 "gfx.asm@Bank 7 Tilesets 06" - ; $5a00 org $6400 "gfx.asm@Bank 7 Tilesets 05" - ; $6800 org $7200 "gfx.asm@Bank 7 Tilesets 03" + ROMX $08 org $4000 "gfx.asm@Bank 8 Tilesets 04" - ; $4400 org $4e00 "gfx.asm@Bank 8 Tilesets 07" - ; $5200 org $5c00 "gfx.asm@Bank 8 Tilesets 08" - ; $6000 org $6a00 "gfx.asm@Bank 8 Tilesets 0f" - ; $7000 org $7500 "gfx.asm@Bank 8 Tilesets 11" + ROMX $09 org $4000 - ; $4000 + ROMX $0a org $4000 - ; $4000 org $5641 "gfx.asm@Gameboy GFX" + ROMX $0b org $4000 - ; $4000 + ROMX $0c org $4000 "gfx.asm@Bank C Tilesets 12" - ; $4600 org $4b00 "gfx.asm@Bank C Tilesets 0b" - ; $5100 org $5600 "gfx.asm@Bank C Tilesets 0d" - ; $5c00 org $6100 "gfx.asm@Bank C Tilesets 14" - ; $6700 org $7100 "gfx.asm@Bank C Tilesets 0c" - ; $7700 org $7c00 "gfx.asm@Bank C Tilesets Common" - ; $7e00 + ROMX $0d org $4000 - ; $4000 org $506d "data/types/type_matchups.asm" + ROMX $0e org $4000 - ; $4000 org $4494 "gfx.asm@PokeBalls GFX" - ; $44d4 org $4d90 "data/trainers/class_names.asm" - ; $4f45 org $5110 "data/trainers/parties.asm@Trainer Parties" + ROMX $0f org $4000 - ; $4000 org $63da "engine/battle/core.asm" - ; $6411 org $6a3c "data/wild.asm" + ROMX $10 org $4000 org $4943 "data/pokemon/dex_order_alpha.asm" - ; $4a3e org $4ecc "data/types/search_strings.asm" - ; $4f17 org $5068 "data/types/search_types.asm" - ; $5077 org $52a1 "data/moves/names.asm" - ; $58b6 org $6493 "data/pokemon/evos_attacks.asm" + ROMX $11 org $4000 - ; $4000 org $40d5 "gfx.asm@Pokedex GFX" + ROMX $12 org $4000 "gfx.asm@Trainer Battle Sprites" + ROMX $13 org $4000 "gfx.asm@Bank 13 Tilesets 0a" - ; $4600 org $4b00 "gfx.asm@Bank 13 Tilesets 16" - ; $5100 org $5b00 "gfx.asm@Bank 13 Tilesets 19" - ; $5f00 org $6900 "gfx.asm@Bank 13 Tilesets 1a" + ROMX $14 org $4000 org $40dd "data/types/names.asm" - ; $4162 org $4f10 "data/pokemon/base_stats.asm" "data/pokemon/names.asm" "gfx.asm@PKMN Sprite Bank List" + ROMX $15 org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 1" + ROMX $16 org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 2" + ROMX $17 org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 3" + ROMX $18 org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 4" + ROMX $19 org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 5" + ROMX $1a org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 6" + ROMX $1b org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 7" + ROMX $1c org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 8" + ROMX $1d org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 9" + ROMX $1e org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 10" + ROMX $1f org $4000 "gfx/pokemon/pkmn_pics.asm@PKMN Pics 11" "gfx.asm@Annon Pic Ptrs and Pics" "gfx/pokemon/egg.asm" + ROMX $21 org $4000 "gfx.asm@Attack Animation GFX" + ROMX $23 org $4000 org $433e "engine/palettes.asm@Overworld fade" org $43d1 "engine/palettes.asm@Palette fading, part 2?" - ; $446d org $60cc "gfx.asm@Pokemon Party Sprites" org $722a "data/pokemon/menu_icons.asm" + ROMX $24 org $4000 org $4fdb "gfx.asm@Slot Machine GFX" + ROMX $25 org $4000 "data/maps/attributes/placeholder/Route2Gate1F.asm" @@ -427,6 +410,7 @@ ROMX $25 "maps/placeholder/OldCityKurtsHouse.asm" "data/maps/attributes/placeholder/OldCitySchool.asm" "maps/placeholder/OldCitySchool.asm" + ROMX $26 org $4000 "data/maps/attributes/Route1Gate1F.asm" @@ -469,6 +453,7 @@ ROMX $26 "maps/placeholder/WestHouse1.asm" "data/maps/attributes/placeholder/WestHouse2.asm" "maps/placeholder/WestHouse2.asm" + ROMX $27 org $4000 "data/maps/attributes/placeholder/HaitekuWestRouteGate.asm" @@ -711,6 +696,7 @@ ROMX $27 "maps/placeholder/NorthPokecenter1F.asm" "data/maps/attributes/placeholder/NorthPokecenter2F.asm" "maps/placeholder/NorthPokecenter2F.asm" + ROMX $2f org $4000 "data/maps/attributes/placeholder/PowerPlant1.asm" @@ -751,18 +737,22 @@ ROMX $2f "maps/placeholder/SlowpokeWellMain.asm" "data/maps/attributes/ShizukanaOka.asm" "maps/ShizukanaOka.asm" + ROMX $30 org $4000 "gfx.asm@Bank 30 Sprites 1" + ROMX $31 org $4000 "gfx.asm@Bank 31 Sprites 2" + ROMX $32 org $4000 "engine/battle_anims/bg_effects.asm" - ; $4cfe + ROMX $33 org $4000 + ROMX $34 org $4000 "data/maps/attributes/placeholder/RouteSilentEastGate.asm" @@ -781,6 +771,7 @@ ROMX $34 "maps/SilentHillLabBack.asm" "data/maps/attributes/UnusedMap13.asm" "maps/UnusedMap13.asm" + ROMX $36 org $4000 "maps/placeholder/dummy_text_pointers.asm" @@ -867,57 +858,52 @@ ROMX $36 "engine/menu/set_time.asm" "maps/Route1P1.asm" "maps/Route1P2.asm" + ROMX $37 org $4000 "gfx.asm@Bank 37 Tilesets 10" - ; $4600 org $4b00 "gfx.asm@Bank 37 Tilesets 15" - ; $5100 org $5b00 "gfx.asm@Bank 37 Tilesets 17" - ; $6100 org $6b00 "gfx.asm@Bank 37 Tilesets 18" + ROMX $38 org $4000 org $5403 "gfx.asm@Poker GFX" - ; $5ae3 org $5f93 "gfx.asm@15 Puzzle GFX" - ; $6213 org $6606 "gfx.asm@Matches GFX" - ; $6886 org $75b7 "gfx.asm@Picross GFX" + ROMX $39 org $4000 org $41ff "gfx.asm@Gamefreak Logo GFX" org $4adf "gfx.asm@Intro Underwater GFX" - ; $52df org $55ef "gfx.asm@Intro Water Mon and Forest GFX" - ; $60ef org $626f "gfx.asm@Intro Mon" + ROMX $3a org $4000 "audio/engine.asm@Audio" - ; $410b org $42bd "audio/engine.asm@IsChannelSFXOn" "audio/engine.asm@Functione82f0" org $4cee "audio/engine.asm@Audio engine, part 2" - ; $4d8d org $52c7 "audio/engine.asm@Song Header Pointers" org $52ee "audio/songs/none.asm" + ROMX $3b org $4000 "audio/songs/nidorinointro.asm" @@ -931,51 +917,48 @@ ROMX $3b "audio/songs/spottedrocket.asm" "audio/songs/victorytrainer.asm" "audio/songs/evolution.asm" + ROMX $3c org $4000 - ; $4000 org $51cb "audio/cries.asm" - ; $51cb org $62fe "audio/songs/title.asm" + ROMX $3e org $4000 "engine/gfx.asm" "gfx.asm@Misc GFX" + ROMX $3f org $4000 - ; $4000 org $4362 "engine/menu/reset_dialog.asm" - ; $4381 org $4aa5 "engine/landmarks.asm" "data/maps/landmarks.asm" - ; $4bc6 org $506f "gfx.asm@Town Map Cursor" - ; $50af + WRAM0 org $c000 "Music engine RAM" - ; $c1bc org $c200 "OAM Buffer" - ; $c570 org $c5e8 "Map Buffer" org $dfff "Stack Bottom" + VRAM 0 "VRAM" + HRAM "HRAM" + SRAM 0 "Sprite Buffers" - ; $a498 org $a600 "Unknown, bank 0" - ; $a607 org $bffe "Window Stack Top" diff --git a/maps/Route1P2.asm b/maps/Route1P2.asm index ae7e399..29b74f1 100644 --- a/maps/Route1P2.asm +++ b/maps/Route1P2.asm @@ -48,7 +48,7 @@ Route1P2Script:: ; 7C7F Route1P2Text1: ; 7CA7 ld hl, Route1P2TextString4 call OpenTextbox - call RotateFourPalettesLeft + call GBFadeOutToBlack jp Init Route1P2Text2: ; 7CB3 @@ -401,6 +401,7 @@ wMenuDataPointer:: dw ; cc07 wMenuCursorBuffer:: db ; cc09 ; cc0a ds 8 ; TODO +wMenuDataHeaderEnd:: wMenuData2:: wMenuDataFlags:: db ; cc12 @@ -619,7 +620,7 @@ wcd80:: db ; cd80 wcd81:: db ; cd81 SECTION "CD9E", WRAM0 [$CD9E] -wcd9e:: db ; cd9e +wLoadedMonLevel:: db ; cd9e SECTION "CDAF", WRAM0 [$CDAF] wcdaf:: db ; cdaf |