diff options
Diffstat (limited to 'home')
-rw-r--r-- | home/audio.asm | 2 | ||||
-rw-r--r-- | home/battle.asm | 4 | ||||
-rw-r--r-- | home/decompress.asm | 9 | ||||
-rw-r--r-- | home/game_time.asm | 4 | ||||
-rw-r--r-- | home/gfx.asm | 8 | ||||
-rw-r--r-- | home/init.asm | 14 | ||||
-rw-r--r-- | home/joypad.asm | 4 | ||||
-rw-r--r-- | home/map.asm | 49 | ||||
-rw-r--r-- | home/menu.asm | 3 | ||||
-rw-r--r-- | home/movement.asm | 2 | ||||
-rw-r--r-- | home/names.asm | 4 | ||||
-rw-r--r-- | home/print_bcd.asm | 7 | ||||
-rw-r--r-- | home/print_num.asm | 5 | ||||
-rw-r--r-- | home/serial.asm | 96 | ||||
-rw-r--r-- | home/text.asm | 28 | ||||
-rw-r--r-- | home/video.asm | 22 | ||||
-rw-r--r-- | home/warp_connection.asm | 5 | ||||
-rw-r--r-- | home/window.asm | 2 |
18 files changed, 139 insertions, 129 deletions
diff --git a/home/audio.asm b/home/audio.asm index 410dad55..a1158427 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -409,7 +409,7 @@ SpecialMapMusic:: and a ret -.bike +.bike ; unreferenced ld de, MUSIC_BICYCLE scf ret diff --git a/home/battle.asm b/home/battle.asm index c0bcaad3..f471ba1e 100644 --- a/home/battle.asm +++ b/home/battle.asm @@ -252,6 +252,6 @@ PushLYOverrides:: ld a, HIGH(wLYOverrides) ld [wRequested2bppDest + 1], a - ld a, (wLYOverridesEnd - wLYOverrides) / 16 - ld [wRequested2bpp], a + ld a, (wLYOverridesEnd - wLYOverrides) / LEN_2BPP_TILE + ld [wRequested2bppSize], a ret diff --git a/home/decompress.asm b/home/decompress.asm index 0ac2c0b6..a072b1e7 100644 --- a/home/decompress.asm +++ b/home/decompress.asm @@ -80,7 +80,6 @@ LZ_LONG_HI EQU %00000011 cp LZ_LONG jr nz, .short -.long ; The count is now 10 bits. ; Read the next 3 bits. @@ -133,7 +132,7 @@ LZ_LONG_HI EQU %00000011 cp LZ_ZERO jr z, .Zero -.Literal: +; Literal ; Read literal data for bc bytes. .lloop dec c @@ -215,10 +214,8 @@ LZ_LONG_HI EQU %00000011 bit 7, a ; sign jr z, .positive -.negative -; hl = de - a - ; Since we can't subtract a from de, - ; Make it negative and add de. +; negative + ; hl = de + -a and %01111111 cpl add e diff --git a/home/game_time.asm b/home/game_time.asm index b0039952..33d7bcc1 100644 --- a/home/game_time.asm +++ b/home/game_time.asm @@ -20,8 +20,8 @@ GameTimer:: ret nz ; Is the timer paused? - ld hl, wGameTimerPause - bit GAMETIMERPAUSE_TIMER_PAUSED_F, [hl] + ld hl, wGameTimerPaused + bit GAME_TIMER_PAUSED_F, [hl] ret z ; Is the timer already capped? diff --git a/home/gfx.asm b/home/gfx.asm index efb0499a..42929935 100644 --- a/home/gfx.asm +++ b/home/gfx.asm @@ -137,7 +137,7 @@ Request2bpp:: cp TILES_PER_CYCLE jr nc, .cycle - ld [wRequested2bpp], a + ld [wRequested2bppSize], a call DelayFrame pop af @@ -149,7 +149,7 @@ Request2bpp:: .cycle ld a, TILES_PER_CYCLE - ld [wRequested2bpp], a + ld [wRequested2bppSize], a call DelayFrame ld a, c @@ -182,7 +182,7 @@ Request1bpp:: cp TILES_PER_CYCLE jr nc, .cycle - ld [wRequested1bpp], a + ld [wRequested1bppSize], a call DelayFrame pop af @@ -194,7 +194,7 @@ Request1bpp:: .cycle ld a, TILES_PER_CYCLE - ld [wRequested1bpp], a + ld [wRequested1bppSize], a call DelayFrame ld a, c diff --git a/home/init.asm b/home/init.asm index fc04cfd1..052a3685 100644 --- a/home/init.asm +++ b/home/init.asm @@ -5,8 +5,8 @@ Reset:: call ClearPalettes ei - ld hl, wd8ba - set 7, [hl] + ld hl, wJoypadDisable + set JOYPAD_DISABLE_SGB_TRANSFER_F, [hl] ld c, 32 call DelayFrames @@ -43,7 +43,7 @@ Init:: ldh [rOBP1], a ldh [rTMA], a ldh [rTAC], a - ld [wceeb], a + ld [wBetaTitleSequenceOpeningType], a ld a, %100 ; Start timer at 4096Hz ldh [rTAC], a @@ -161,11 +161,13 @@ ClearVRAM:: BlankBGMap:: ld a, " " - jr .fill -; unused; would fill BG Map with value in l + jr FillBGMap + +FillBGMap_l:: ; unreferenced ld a, l + ; fallthrough -.fill +FillBGMap:: ld de, vBGMap1 - vBGMap0 ld l, e .loop diff --git a/home/joypad.asm b/home/joypad.asm index 66d5649e..effe8e89 100644 --- a/home/joypad.asm +++ b/home/joypad.asm @@ -27,8 +27,8 @@ UpdateJoypad:: ; hJoypadSum: pressed so far ; Any of these three bits can be used to disable input. - ld a, [wd8ba] - and %11010000 + ld a, [wJoypadDisable] + and (1 << JOYPAD_DISABLE_MON_FAINT_F) | (1 << JOYPAD_DISABLE_SGB_TRANSFER_F) | (1 << 4) ret nz ; If we're saving, input is disabled. diff --git a/home/map.asm b/home/map.asm index 2701f477..22719788 100644 --- a/home/map.asm +++ b/home/map.asm @@ -124,12 +124,12 @@ LoadMetatiles:: ld a, [wOverworldMapAnchor + 1] ld d, a ld hl, wSurroundingTiles - ld b, SURROUNDING_HEIGHT / METATILE_WIDTH ; 5 + ld b, SCREEN_META_HEIGHT .row push de push hl - ld c, SURROUNDING_WIDTH / METATILE_WIDTH ; 6 + ld c, SCREEN_META_WIDTH .col push de @@ -195,7 +195,7 @@ endr add hl, de pop de ld a, [wMapWidth] - add 6 + add MAP_CONNECTION_PADDING_WIDTH * 2 add e ld e, a jr nc, .ok2 @@ -562,45 +562,43 @@ GetMapScreenCoords:: ld hl, wOverworldMapBlocks ld a, [wXCoord] bit 0, a - jr nz, .increment_then_halve1 + jr nz, .odd_x +; even x srl a - add $1 - jr .resume - -.increment_then_halve1 - add $1 + add 1 + jr .got_block_x +.odd_x + add 1 srl a - -.resume +.got_block_x ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [wMapWidth] - add $6 + add MAP_CONNECTION_PADDING_WIDTH * 2 ld c, a - ld b, $0 + ld b, 0 ld a, [wYCoord] bit 0, a - jr nz, .increment_then_halve2 + jr nz, .odd_y +; even y srl a - add $1 - jr .resume2 - -.increment_then_halve2 - add $1 + add 1 + jr .got_block_y +.odd_y + add 1 srl a - -.resume2 +.got_block_y call AddNTimes ld a, l ld [wOverworldMapAnchor], a ld a, h ld [wOverworldMapAnchor + 1], a ld a, [wYCoord] - and $1 + and 1 ld [wMetatileStandingY], a ld a, [wXCoord] - and $1 + and 1 ld [wMetatileStandingX], a ret @@ -2009,7 +2007,8 @@ GetMapEnvironment:: pop hl ret - ret ; unused +Map_DummyFunction:: ; unreferenced + ret GetAnyMapEnvironment:: push hl diff --git a/home/menu.asm b/home/menu.asm index 7bc6454d..ed17e05e 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -251,6 +251,7 @@ MenuBoxCoord2Tile:: ld c, a ld a, [wMenuBorderTopCoord] ld b, a + ; fallthrough Coord2Tile:: ; Return the address of wTilemap(c, b) in hl. @@ -294,7 +295,7 @@ MenuTextbox:: pop hl jp PrintText -; unused +Menu_DummyFunction:: ; unreferenced ret LoadMenuTextbox:: diff --git a/home/movement.asm b/home/movement.asm index f329a3c3..c5d9d12b 100644 --- a/home/movement.asm +++ b/home/movement.asm @@ -2,7 +2,7 @@ InitMovementBuffer:: ld [wMovementBufferObject], a xor a ld [wMovementBufferCount], a - ld a, $0 ; useless + ld a, BANK(wMovementBuffer) ld [wUnusedMovementBufferBank], a ld a, LOW(wMovementBuffer) ld [wUnusedMovementBufferPointer], a diff --git a/home/names.asm b/home/names.asm index e3da8793..58cc0fbb 100644 --- a/home/names.asm +++ b/home/names.asm @@ -56,9 +56,9 @@ GetName:: .done ld a, e - ld [wUnusedCFFE], a + ld [wUnusedNamesPointer], a ld a, d - ld [wUnusedCFFE + 1], a + ld [wUnusedNamesPointer + 1], a pop de pop bc diff --git a/home/print_bcd.asm b/home/print_bcd.asm index 74e2d161..4182eadf 100644 --- a/home/print_bcd.asm +++ b/home/print_bcd.asm @@ -33,10 +33,11 @@ PrintBCDNumber:: jr nz, .loop bit PRINTNUM_LEADINGZEROS_F, b jr z, .done ; if so, we are done -.numberEqualsZero ; if every digit of the BCD number is zero +; every digit of the BCD number is zero bit PRINTNUM_LEFTALIGN_F, b jr nz, .skipLeftAlignmentAdjustment - dec hl ; if the string is left-aligned, it needs to be moved back one space +; the string is left-aligned; it needs to be moved back one space + dec hl .skipLeftAlignmentAdjustment bit PRINTNUM_MONEY_F, b jr z, .skipCurrencySymbol @@ -53,7 +54,7 @@ PrintBCDDigit:: and %00001111 and a jr z, .zeroDigit -.nonzeroDigit +; nonzero digit bit PRINTNUM_LEADINGZEROS_F, b ; have any non-space characters been printed? jr z, .outputDigit ; if bit 7 is set, then no numbers have been printed yet diff --git a/home/print_num.asm b/home/print_num.asm index d9cf15f5..62f03f5a 100644 --- a/home/print_num.asm +++ b/home/print_num.asm @@ -35,7 +35,6 @@ PrintNum:: cp 2 jr z, .word ; maximum 3 bytes -.long ld a, [de] ldh [hPrintNumBuffer + 1], a inc de @@ -81,7 +80,7 @@ PrintNum:: cp 6 jr z, .six -.seven +; seven ld a, HIGH(1000000 >> 8) ldh [hPrintNumBuffer + 4], a ld a, HIGH(1000000) ; mid @@ -301,7 +300,7 @@ PrintNum:: inc hl ret -PrintHexNumber:: ; unreferenced +PrintHexNumber:: ; Print the c-byte value from de to hl as hexadecimal digits. .loop push bc diff --git a/home/serial.asm b/home/serial.asm index a317b5c7..0e42b9c0 100644 --- a/home/serial.asm +++ b/home/serial.asm @@ -49,13 +49,13 @@ Serial:: xor a ldh [rSB], a + ld a, 3 ldh [rDIV], a - -.wait_bit_7 +.delay_loop ldh a, [rDIV] bit 7, a - jr nz, .wait_bit_7 + jr nz, .delay_loop ld a, (0 << rSC_ON) | (0 << rSC_CLOCK) ldh [rSC], a @@ -81,8 +81,9 @@ Serial:: reti Serial_ExchangeBytes:: - ld a, $1 + ld a, TRUE ldh [hSerialIgnoringInitialData], a + .loop ld a, [hl] ldh [hSerialSend], a @@ -90,10 +91,12 @@ Serial_ExchangeBytes:: push bc ld b, a inc hl - ld a, $30 + + ld a, 48 .wait dec a jr nz, .wait + ldh a, [hSerialIgnoringInitialData] and a ld a, b @@ -116,7 +119,7 @@ Serial_ExchangeBytes:: ret Serial_ExchangeByte:: -.loop +.timeout_loop xor a ldh [hSerialReceivedNewData], a ldh a, [hSerialConnectionStatus] @@ -127,16 +130,16 @@ Serial_ExchangeByte:: ld a, (1 << rSC_ON) | (1 << rSC_CLOCK) ldh [rSC], a .not_player_2 -.loop2 +.loop ldh a, [hSerialReceivedNewData] and a - jr nz, .reset_ffcc + jr nz, .await_new_data ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK - jr nz, .not_player_1_or_wLinkTimeoutFrames_zero - call CheckwLinkTimeoutFramesNonzero - jr z, .not_player_1_or_wLinkTimeoutFrames_zero - call .delay_15_cycles + jr nz, .not_player_1_or_timed_out + call CheckLinkTimeoutFramesNonzero + jr z, .not_player_1_or_timed_out + call .ShortDelay push hl ld hl, wLinkTimeoutFrames + 1 inc [hl] @@ -146,51 +149,52 @@ Serial_ExchangeByte:: .no_rollover_up pop hl - call CheckwLinkTimeoutFramesNonzero - jr nz, .loop2 + call CheckLinkTimeoutFramesNonzero + jr nz, .loop jp SerialDisconnected -.not_player_1_or_wLinkTimeoutFrames_zero +.not_player_1_or_timed_out ldh a, [rIE] and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) cp 1 << SERIAL - jr nz, .loop2 - ld a, [wce5d] + jr nz, .loop + ld a, [wLinkByteTimeout] dec a - ld [wce5d], a - jr nz, .loop2 - ld a, [wce5d + 1] + ld [wLinkByteTimeout], a + jr nz, .loop + ld a, [wLinkByteTimeout + 1] dec a - ld [wce5d + 1], a - jr nz, .loop2 + ld [wLinkByteTimeout + 1], a + jr nz, .loop ldh a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK - jr z, .reset_ffcc + jr z, .await_new_data ld a, 255 -.delay_255_cycles +.long_delay_loop dec a - jr nz, .delay_255_cycles + jr nz, .long_delay_loop -.reset_ffcc +.await_new_data xor a ldh [hSerialReceivedNewData], a ldh a, [rIE] and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) sub 1 << SERIAL - jr nz, .rIE_not_equal_8 + jr nz, .non_serial_interrupts_enabled - ; LOW($5000) - ld [wce5d], a - ld a, HIGH($5000) - ld [wce5d + 1], a + ; a == 0 + assert LOW(SERIAL_LINK_BYTE_TIMEOUT) == 0 + ld [wLinkByteTimeout], a + ld a, HIGH(SERIAL_LINK_BYTE_TIMEOUT) + ld [wLinkByteTimeout + 1], a -.rIE_not_equal_8 +.non_serial_interrupts_enabled ldh a, [hSerialReceive] cp SERIAL_NO_DATA_BYTE ret nz - call CheckwLinkTimeoutFramesNonzero - jr z, .linkTimeoutFrames_zero + call CheckLinkTimeoutFramesNonzero + jr z, .timed_out push hl ld hl, wLinkTimeoutFrames + 1 ld a, [hl] @@ -202,10 +206,10 @@ Serial_ExchangeByte:: .no_rollover pop hl - call CheckwLinkTimeoutFramesNonzero + call CheckLinkTimeoutFramesNonzero jr z, SerialDisconnected -.linkTimeoutFrames_zero +.timed_out ldh a, [rIE] and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) cp 1 << SERIAL @@ -214,16 +218,16 @@ Serial_ExchangeByte:: ld a, [hl] ldh [hSerialSend], a call DelayFrame - jp .loop + jp .timeout_loop -.delay_15_cycles +.ShortDelay: ld a, 15 -.delay_cycles +.short_delay_loop dec a - jr nz, .delay_cycles + jr nz, .short_delay_loop ret -CheckwLinkTimeoutFramesNonzero:: +CheckLinkTimeoutFramesNonzero:: push hl ld hl, wLinkTimeoutFrames ld a, [hli] @@ -231,8 +235,10 @@ CheckwLinkTimeoutFramesNonzero:: pop hl ret +; This sets wLinkTimeoutFrames to $ffff, since +; a is always 0 when it is called. SerialDisconnected:: - dec a ; a is always 0 when this is called + dec a ld [wLinkTimeoutFrames], a ld [wLinkTimeoutFrames + 1], a ret @@ -273,9 +279,7 @@ Serial_PrintWaitingTextAndSyncAndExchangeNybble:: Serial_SyncAndExchangeNybble:: ; unreferenced call LoadTilemapToTempTilemap callfar PlaceWaitingText - jp WaitLinkTransfer - -; One "giant" leap for machinekind + jp WaitLinkTransfer ; pointless WaitLinkTransfer:: ld a, $ff @@ -283,7 +287,7 @@ WaitLinkTransfer:: .loop call LinkTransfer call DelayFrame - call CheckwLinkTimeoutFramesNonzero + call CheckLinkTimeoutFramesNonzero jr z, .check push hl ld hl, wLinkTimeoutFrames + 1 diff --git a/home/text.asm b/home/text.asm index 9d3428ac..77b8911c 100644 --- a/home/text.asm +++ b/home/text.asm @@ -138,6 +138,7 @@ RadioTerminator:: PrintText:: call SetUpTextbox + ; fallthrough PrintTextboxText:: bccoord TEXTBOX_INNERX, TEXTBOX_INNERY @@ -154,6 +155,7 @@ SetUpTextbox:: PlaceString:: push hl + ; fallthrough PlaceNextChar:: ld a, [de] @@ -164,7 +166,9 @@ PlaceNextChar:: pop hl ret - pop de ; unused +DummyChar:: ; unreferenced + pop de + ; fallthrough NextChar:: inc de @@ -238,18 +242,19 @@ ENDM .not_diacritic cp FIRST_REGULAR_TEXT_CHAR jr nc, .place - +; dakuten or handakuten cp "パ" jr nc, .handakuten - -.dakuten +; dakuten cp FIRST_HIRAGANA_DAKUTEN_CHAR jr nc, .hiragana_dakuten +; katakana dakuten add "カ" - "ガ" - jr .katakana_dakuten + jr .place_dakuten + .hiragana_dakuten add "か" - "が" -.katakana_dakuten +.place_dakuten ld b, "゙" ; dakuten call Diacritic jr .place @@ -257,11 +262,13 @@ ENDM .handakuten cp "ぱ" jr nc, .hiragana_handakuten +; katakana handakuten add "ハ" - "パ" - jr .katakana_handakuten + jr .place_handakuten + .hiragana_handakuten add "は" - "ぱ" -.katakana_handakuten +.place_handakuten ld b, "゚" ; handakuten call Diacritic @@ -298,12 +305,13 @@ PlaceKokoWa: print_name PlaceKokoWaText PlaceMoveTargetsName:: ldh a, [hBattleTurn] xor 1 - jr PlaceMoveUsersName.place + jr PlaceBattlersName PlaceMoveUsersName:: ldh a, [hBattleTurn] + ; fallthrough -.place: +PlaceBattlersName: push de and a jr nz, .enemy diff --git a/home/video.asm b/home/video.asm index dcf7b47c..a9592558 100644 --- a/home/video.asm +++ b/home/video.asm @@ -159,7 +159,7 @@ UpdateBGMap:: THIRD_HEIGHT EQU SCREEN_HEIGHT / 3 -.bottom +; bottom ld de, 2 * THIRD_HEIGHT * SCREEN_WIDTH add hl, de ld sp, hl @@ -240,11 +240,11 @@ endr ret Serve1bppRequest:: - ld a, [wRequested1bpp] + ld a, [wRequested1bppSize] and a ret z -; Copy [wRequested1bpp] 1bpp tiles from [wRequested1bppSource] to [wRequested1bppDest] +; Copy [wRequested1bppSize] 1bpp tiles from [wRequested1bppSource] to [wRequested1bppDest] ld [hSPBuffer], sp @@ -262,11 +262,11 @@ Serve1bppRequest:: ld l, a ; # tiles to copy - ld a, [wRequested1bpp] + ld a, [wRequested1bppSize] ld b, a xor a - ld [wRequested1bpp], a + ld [wRequested1bppSize], a .next @@ -309,11 +309,11 @@ endr ret Serve2bppRequest:: - ld a, [wRequested2bpp] + ld a, [wRequested2bppSize] and a ret z -; Copy [wRequested2bpp] 2bpp tiles from [wRequested2bppSource] to [wRequested2bppDest] +; Copy [wRequested2bppSize] 2bpp tiles from [wRequested2bppSource] to [wRequested2bppDest] ld [hSPBuffer], sp @@ -331,11 +331,11 @@ Serve2bppRequest:: ld l, a ; # tiles to copy - ld a, [wRequested2bpp] + ld a, [wRequested2bppSize] ld b, a xor a - ld [wRequested2bpp], a + ld [wRequested2bppSize], a .next @@ -385,10 +385,10 @@ AnimateTileset:: rst Bankswitch ret -; unused +Video_DummyFunction:: ; unreferenced ret -; unused +EnableSpriteDisplay:: ; unreferenced ld hl, rLCDC set 1, [hl] ret diff --git a/home/warp_connection.asm b/home/warp_connection.asm index 3c4c5929..ae8edcdb 100644 --- a/home/warp_connection.asm +++ b/home/warp_connection.asm @@ -459,7 +459,8 @@ EnterMapWarp:: ; MOUNT_MOON_SQUARE and TIN_TOWER_ROOF are outdoor maps within indoor maps. ; Dig and Escape Rope should not take you to them. ld a, [wPrevMapGroup] - cp GROUP_MOUNT_MOON_SQUARE ; aka GROUP_TIN_TOWER_ROOF + cp GROUP_MOUNT_MOON_SQUARE + assert GROUP_MOUNT_MOON_SQUARE == GROUP_TIN_TOWER_ROOF jr nz, .not_mt_moon_or_tin_tower ld a, [wPrevMapNumber] cp MAP_MOUNT_MOON_SQUARE @@ -497,8 +498,6 @@ EnterMapWarp:: ld a, c cp TILESET_POKECENTER ret nz - -.pokecenter ld a, [wPrevMapGroup] ld [wLastSpawnMapGroup], a ld a, [wPrevMapNumber] diff --git a/home/window.asm b/home/window.asm index c903cdd8..e8e0604d 100644 --- a/home/window.asm +++ b/home/window.asm @@ -92,6 +92,6 @@ SafeUpdateSprites:: ldh [hOAMUpdate], a ret -; unused +SetCarryFlag:: ; unreferenced scf ret |