diff options
Diffstat (limited to 'home')
-rw-r--r-- | home/audio.asm | 20 | ||||
-rw-r--r-- | home/init.asm | 2 | ||||
-rw-r--r-- | home/overworld.asm | 26 | ||||
-rw-r--r-- | home/pic.asm | 16 | ||||
-rw-r--r-- | home/predef.asm | 6 | ||||
-rw-r--r-- | home/serial.asm | 624 | ||||
-rw-r--r-- | home/text.asm | 8 |
7 files changed, 351 insertions, 351 deletions
diff --git a/home/audio.asm b/home/audio.asm index 9210924c..1301550c 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -4,19 +4,19 @@ PlayDefaultMusic:: ; 2307 (0:2307) ld c, a ld d, a ld [wcfca], a - jr asm_2324 + jr Func_2324 Func_2312:: ; 2312 (0:2312) ld c, $a ld d, $0 ld a, [wd72e] bit 5, a - jr z, asm_2324 + jr z, Func_2324 xor a ld [wcfca], a ld c, $8 ld d, c -asm_2324:: ; 2324 (0:2324) +Func_2324:: ; 2324 (0:2324) ld a, [wWalkBikeSurfState] and a jr z, .asm_2343 @@ -146,27 +146,27 @@ PlaySound:: ; 23b1 (0:23b1) ld [$ffb9], a ld a, [wc0ef] ld [H_LOADEDROMBANK], a - ld [$2000], a - cp BANK(Func_9876) + ld [MBC1RomBank], a + cp BANK(Music2_9876) jr nz, .checkForBank08 .bank02 ld a, b - call Func_9876 + call Music2_9876 jr .asm_240b .checkForBank08 - cp BANK(Func_22035) + cp BANK(Music8_22035) jr nz, .bank1F .bank08 ld a, b - call Func_22035 + call Music8_22035 jr .asm_240b .bank1F ld a, b - call Func_7d8ea + call Music1f_7d8ea .asm_240b ld a, [$ffb9] ld [H_LOADEDROMBANK], a - ld [$2000], a + ld [MBC1RomBank], a jr .asm_2425 .asm_2414 ld a, b diff --git a/home/init.asm b/home/init.asm index cc89ad34..4ac2a4eb 100644 --- a/home/init.asm +++ b/home/init.asm @@ -1,7 +1,7 @@ SoftReset:: call StopAllSounds call GBPalWhiteOut - ld c, $20 + ld c, 32 call DelayFrames ; fallthrough diff --git a/home/overworld.asm b/home/overworld.asm index c5c180c7..0e62a932 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -257,7 +257,7 @@ OverworldLoopLessDelay:: jr z,.noSpinning callba LoadSpinnerArrowTiles ; spin while moving .noSpinning - call UpdateSprites ; move sprites + call UpdateSprites .moveAhead2 ld hl,wFlags_0xcd60 res 2,[hl] @@ -335,7 +335,7 @@ OverworldLoopLessDelay:: and a jr z,.allPokemonFainted .noFaintCheck - ld c,$0a + ld c,10 call DelayFrames jp EnterMap .allPokemonFainted @@ -778,7 +778,7 @@ HandleFlyWarpOrDungeonWarp:: call LeaveMapAnim ld a, Bank(SpecialWarpIn) ld [H_LOADEDROMBANK], a - ld [$2000], a + ld [MBC1RomBank], a call SpecialWarpIn jp SpecialEnterMap @@ -1120,7 +1120,7 @@ IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d) ld bc,$3c40 ; Y and X position of player sprite ld a,[wSpriteStateData1 + 9] ; direction the player is facing .checkIfPlayerFacingUp - cp a,$04 + cp SPRITE_FACING_UP jr nz,.checkIfPlayerFacingDown ; facing up ld a,b @@ -1129,7 +1129,7 @@ IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d) ld a,$08 jr .doneCheckingDirection .checkIfPlayerFacingDown - cp a,$00 + cp SPRITE_FACING_DOWN jr nz,.checkIfPlayerFacingRight ; facing down ld a,b @@ -1138,7 +1138,7 @@ IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d) ld a,$04 jr .doneCheckingDirection .checkIfPlayerFacingRight - cp a,$0c + cp SPRITE_FACING_RIGHT jr nz,.playerFacingLeft ; facing right ld a,c @@ -1358,7 +1358,7 @@ LoadCurrentMapView:: ; 0caa (0:0caa) push af ld a,[W_TILESETBANK] ; tile data ROM bank ld [H_LOADEDROMBANK],a - ld [$2000],a ; switch to ROM bank that contains tile data + ld [MBC1RomBank],a ; switch to ROM bank that contains tile data ld a,[wCurrentTileBlockMapViewPointer] ; address of upper left corner of current map view ld e,a ld a,[wCurrentTileBlockMapViewPointer + 1] @@ -1440,7 +1440,7 @@ LoadCurrentMapView:: ; 0caa (0:0caa) jr nz,.rowLoop2 pop af ld [H_LOADEDROMBANK],a - ld [$2000],a ; restore previous ROM bank + ld [MBC1RomBank],a ; restore previous ROM bank ret AdvancePlayerSprite:: ; 0d27 (0:0d27) @@ -1981,7 +1981,7 @@ RunMapScript:: ; 101b (0:101b) ret LoadWalkingPlayerSpriteGraphics:: ; 104d (0:104d) - ld de,RedSprite ; $4180 + ld de,RedSprite ld hl,vNPCSprites jr LoadPlayerSpriteGraphicsCommon @@ -2276,7 +2276,7 @@ LoadMapHeader:: ; 107c (0:107c) push af ld a, BANK(MapSongBanks) ld [H_LOADEDROMBANK],a - ld [$2000],a + ld [MBC1RomBank],a ld hl, MapSongBanks add hl,bc add hl,bc @@ -2286,7 +2286,7 @@ LoadMapHeader:: ; 107c (0:107c) ld [wd35c],a ; music 2 pop af ld [H_LOADEDROMBANK],a - ld [$2000],a + ld [MBC1RomBank],a ret ; function to copy map connection data from ROM to WRAM @@ -2359,7 +2359,7 @@ LoadMapData:: ; 1241 (0:1241) .restoreRomBank pop af ld [H_LOADEDROMBANK],a - ld [$2000],a + ld [MBC1RomBank],a ret ; function to switch to the ROM bank that a map is stored in @@ -2378,7 +2378,7 @@ SwitchToMapRomBank:: ; 12bc (0:12bc) call BankswitchBack ld a,[$ffe8] ld [H_LOADEDROMBANK],a - ld [$2000],a ; switch to map ROM bank + ld [MBC1RomBank],a ; switch to map ROM bank pop bc pop hl ret diff --git a/home/pic.asm b/home/pic.asm index 6aa2e5c0..4bc7b31c 100644 --- a/home/pic.asm +++ b/home/pic.asm @@ -6,7 +6,7 @@ UncompressSpriteData:: ; 24fd (0:24fd) push af ld a, b ld [H_LOADEDROMBANK], a - ld [$2000], a + ld [MBC1RomBank], a ld a, $a ld [$0], a xor a @@ -14,7 +14,7 @@ UncompressSpriteData:: ; 24fd (0:24fd) call _UncompressSpriteData pop af ld [H_LOADEDROMBANK], a - ld [$2000], a + ld [MBC1RomBank], a ret ; initializes necessary data to load a sprite and runs UncompressSpriteDataLoop @@ -31,7 +31,7 @@ _UncompressSpriteData:: ; 251a (0:251a) xor a ld [W_SPRITECURPOSX], a ld [W_SPRITECURPOSY], a - ld [W_SPRITELOADFLAGS], a ; wd0a8 + ld [W_SPRITELOADFLAGS], a call ReadNextInputByte ; first byte of input determines sprite width (high nybble) and height (low nybble) in tiles (8x8 pixels) ld b, a and $f @@ -57,13 +57,13 @@ _UncompressSpriteData:: ; 251a (0:251a) ; note that this is an endless loop which is terminated during a call to MoveToNextBufferPosition by manipulating the stack UncompressSpriteDataLoop:: ; 2556 (0:2556) ld hl, S_SPRITEBUFFER1 - ld a, [W_SPRITELOADFLAGS] ; wd0a8 + ld a, [W_SPRITELOADFLAGS] bit 0, a jr z, .useSpriteBuffer1 ; check which buffer to use ld hl, S_SPRITEBUFFER2 .useSpriteBuffer1 call StoreSpriteOutputPointer - ld a, [W_SPRITELOADFLAGS] ; wd0a8 + ld a, [W_SPRITELOADFLAGS] bit 1, a jr z, .startDecompression ; check if last iteration call ReadNextInputBit ; if last chunk, read 1-2 bit unpacking mode @@ -195,12 +195,12 @@ MoveToNextBufferPosition:: ; 25d8 (0:25d8) pop hl xor a ld [W_SPRITECURPOSX], a - ld a, [W_SPRITELOADFLAGS] ; wd0a8 + ld a, [W_SPRITELOADFLAGS] bit 1, a jr nz, .done ; test if there is one more sprite to go xor $1 set 1, a - ld [W_SPRITELOADFLAGS], a ; wd0a8 + ld [W_SPRITELOADFLAGS], a jp UncompressSpriteDataLoop .done jp UnpackSprite @@ -539,7 +539,7 @@ ReverseNybble:: ; 2837 (0:2837) ; resets sprite buffer pointers to buffer 1 and 2, depending on W_SPRITELOADFLAGS ResetSpriteBufferPointers:: ; 2841 (0:2841) - ld a, [W_SPRITELOADFLAGS] ; wd0a8 + ld a, [W_SPRITELOADFLAGS] bit 0, a jr nz, .buffer2Selected ld de, S_SPRITEBUFFER1 diff --git a/home/predef.asm b/home/predef.asm index 8efe3000..2fac9aca 100644 --- a/home/predef.asm +++ b/home/predef.asm @@ -14,13 +14,13 @@ Predef:: push af ld a, BANK(GetPredefPointer) ld [H_LOADEDROMBANK], a - ld [$2000], a + ld [MBC1RomBank], a call GetPredefPointer ld a, [wPredefBank] ld [H_LOADEDROMBANK], a - ld [$2000], a + ld [MBC1RomBank], a ld de, .done push de @@ -29,7 +29,7 @@ Predef:: pop af ld [H_LOADEDROMBANK], a - ld [$2000], a + ld [MBC1RomBank], a ret GetPredefRegisters:: diff --git a/home/serial.asm b/home/serial.asm index 86d74040..1f0146d9 100644 --- a/home/serial.asm +++ b/home/serial.asm @@ -1,312 +1,312 @@ -Serial:: ; 2125 (0:2125)
- push af
- push bc
- push de
- push hl
- ld a, [hSerialConnectionStatus]
- inc a
- jr z, .connectionNotYetEstablished
- ld a, [rSB]
- ld [hSerialReceiveData], a
- ld a, [hSerialSendData]
- ld [rSB], a
- ld a, [hSerialConnectionStatus]
- cp USING_INTERNAL_CLOCK
- jr z, .done
-; using external clock
- ld a, START_TRANSFER_EXTERNAL_CLOCK
- ld [rSC], a
- jr .done
-.connectionNotYetEstablished
- ld a, [rSB]
- ld [hSerialReceiveData], a
- ld [hSerialConnectionStatus], a
- cp USING_INTERNAL_CLOCK
- jr z, .usingInternalClock
-; using external clock
- xor a
- ld [rSB], a
- ld a, $3
- ld [rDIV], a
-.waitLoop
- ld a, [rDIV]
- bit 7, a
- jr nz, .waitLoop
- ld a, START_TRANSFER_EXTERNAL_CLOCK
- ld [rSC], a
- jr .done
-.usingInternalClock
- xor a
- ld [rSB], a
-.done
- ld a, $1
- ld [hSerialReceivedNewData], a
- ld a, SERIAL_NO_DATA_BYTE
- ld [hSerialSendData], a
- pop hl
- pop de
- pop bc
- pop af
- reti
-
-; hl = send data
-; de = receive data
-; bc = length of data
-Serial_ExchangeBytes:: ; 216f (0:216f)
- ld a, 1
- ld [hSerialIgnoringInitialData], a
-.loop
- ld a, [hl]
- ld [hSerialSendData], a
- call Serial_ExchangeByte
- push bc
- ld b, a
- inc hl
- ld a, 48
-.waitLoop
- dec a
- jr nz, .waitLoop
- ld a, [hSerialIgnoringInitialData]
- and a
- ld a, b
- pop bc
- jr z, .storeReceivedByte
- dec hl
- cp SERIAL_PREAMBLE_BYTE
- jr nz, .loop
- xor a
- ld [hSerialIgnoringInitialData], a
- jr .loop
-.storeReceivedByte
- ld [de], a
- inc de
- dec bc
- ld a, b
- or c
- jr nz, .loop
- ret
-
-Serial_ExchangeByte:: ; 219a (0:219a)
- xor a
- ld [hSerialReceivedNewData], a
- ld a, [hSerialConnectionStatus]
- cp USING_INTERNAL_CLOCK
- jr nz, .asm_21a7
- ld a, START_TRANSFER_INTERNAL_CLOCK
- ld [rSC], a
-.asm_21a7
- ld a, [hSerialReceivedNewData]
- and a
- jr nz, .asm_21f1
- ld a, [hSerialConnectionStatus]
- cp USING_EXTERNAL_CLOCK
- jr nz, .asm_21cc
- call IsUnknownCounterZero
- jr z, .asm_21cc
- call WaitLoop_15Iterations
- push hl
- ld hl, wUnknownSerialCounter + 1
- inc [hl]
- jr nz, .asm_21c3
- dec hl
- inc [hl]
-.asm_21c3
- pop hl
- call IsUnknownCounterZero
- jr nz, .asm_21a7
- jp SetUnknownCounterToFFFF
-.asm_21cc
- ld a, [rIE]
- and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
- cp (1 << SERIAL)
- jr nz, .asm_21a7
- ld a, [wUnknownSerialCounter2]
- dec a
- ld [wUnknownSerialCounter2], a
- jr nz, .asm_21a7
- ld a, [wUnknownSerialCounter2 + 1]
- dec a
- ld [wUnknownSerialCounter2 + 1], a
- jr nz, .asm_21a7
- ld a, [hSerialConnectionStatus]
- cp USING_EXTERNAL_CLOCK
- jr z, .asm_21f1
- ld a, 255
-.waitLoop
- dec a
- jr nz, .waitLoop
-.asm_21f1
- xor a
- ld [hSerialReceivedNewData], a
- ld a, [rIE]
- and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
- sub (1 << SERIAL)
- jr nz, .asm_2204
- ld [wUnknownSerialCounter2], a
- ld a, $50
- ld [wUnknownSerialCounter2 + 1], a
-.asm_2204
- ld a, [hSerialReceiveData]
- cp SERIAL_NO_DATA_BYTE
- ret nz
- call IsUnknownCounterZero
- jr z, .asm_221f
- push hl
- ld hl, wUnknownSerialCounter + 1
- ld a, [hl]
- dec a
- ld [hld], a
- inc a
- jr nz, .asm_2219
- dec [hl]
-.asm_2219
- pop hl
- call IsUnknownCounterZero
- jr z, SetUnknownCounterToFFFF
-.asm_221f
- ld a, [rIE]
- and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
- cp (1 << SERIAL)
- ld a, SERIAL_NO_DATA_BYTE
- ret z
- ld a, [hl]
- ld [hSerialSendData], a
- call DelayFrame
- jp Serial_ExchangeByte
-
-WaitLoop_15Iterations:: ; 2231 (0:2231)
- ld a, 15
-.waitLoop
- dec a
- jr nz, .waitLoop
- ret
-
-IsUnknownCounterZero:: ; 2237 (0:2237)
- push hl
- ld hl, wUnknownSerialCounter
- ld a, [hli]
- or [hl]
- pop hl
- ret
-
-; a is always 0 when this is called
-SetUnknownCounterToFFFF:: ; 223f (0:223f)
- dec a
- ld [wUnknownSerialCounter], a
- ld [wUnknownSerialCounter + 1], a
- ret
-
-; This is used to exchange the button press and selected menu item on the link menu.
-; The data is sent thrice and read twice to increase reliability.
-Serial_ExchangeLinkMenuSelection:: ; 2247 (0:2247)
- ld hl, wLinkMenuSelectionSendBuffer
- ld de, wLinkMenuSelectionReceiveBuffer
- ld c, 2 ; number of bytes to save
- ld a, 1
- ld [hSerialIgnoringInitialData], a
-.loop
- call DelayFrame
- ld a, [hl]
- ld [hSerialSendData], a
- call Serial_ExchangeByte
- ld b, a
- inc hl
- ld a, [hSerialIgnoringInitialData]
- and a
- ld a, 0
- ld [hSerialIgnoringInitialData], a
- jr nz, .loop
- ld a, b
- ld [de], a
- inc de
- dec c
- jr nz, .loop
- ret
-
-Serial_PrintWaitingTextAndSyncAndExchangeNybble:: ; 226e (0:226e)
- call SaveScreenTilesToBuffer1
- callab PrintWaitingText
- call Serial_SyncAndExchangeNybble
- jp LoadScreenTilesFromBuffer1
-
-Serial_SyncAndExchangeNybble:: ; 227f (0:227f)
- ld a, $ff
- ld [wSerialExchangeNybbleReceiveData], a
-.loop1
- call Serial_ExchangeNybble
- call DelayFrame
- call IsUnknownCounterZero
- jr z, .next1
- push hl
- ld hl, wUnknownSerialCounter + 1
- dec [hl]
- jr nz, .next2
- dec hl
- dec [hl]
- jr nz, .next2
- pop hl
- xor a
- jp SetUnknownCounterToFFFF
-.next2
- pop hl
-.next1
- ld a, [wSerialExchangeNybbleReceiveData]
- inc a
- jr z, .loop1
- ld b, 10
-.loop2
- call DelayFrame
- call Serial_ExchangeNybble
- dec b
- jr nz, .loop2
- ld b, 10
-.loop3
- call DelayFrame
- call Serial_SendZeroByte
- dec b
- jr nz, .loop3
- ld a, [wSerialExchangeNybbleReceiveData]
- ld [wSerialSyncAndExchangeNybbleReceiveData], a
- ret
-
-Serial_ExchangeNybble:: ; 22c3 (0:22c3)
- call .doExchange
- ld a, [wSerialExchangeNybbleSendData]
- add $60
- ld [hSerialSendData], a
- ld a, [hSerialConnectionStatus]
- cp USING_INTERNAL_CLOCK
- jr nz, .doExchange
- ld a, START_TRANSFER_INTERNAL_CLOCK
- ld [rSC], a
-.doExchange
- ld a, [hSerialReceiveData]
- ld [wSerialExchangeNybbleTempReceiveData], a
- and $f0
- cp $60
- ret nz
- xor a
- ld [hSerialReceiveData], a
- ld a, [wSerialExchangeNybbleTempReceiveData]
- and $f
- ld [wSerialExchangeNybbleReceiveData], a
- ret
-
-Serial_SendZeroByte:: ; 22ed (0:22ed)
- xor a
- ld [hSerialSendData], a
- ld a, [hSerialConnectionStatus]
- cp USING_INTERNAL_CLOCK
- ret nz
- ld a, START_TRANSFER_INTERNAL_CLOCK
- ld [rSC], a
- ret
-
-Serial_TryEstablishingExternallyClockedConnection:: ; 22fa (0:22fa)
- ld a, ESTABLISH_CONNECTION_WITH_EXTERNAL_CLOCK
- ld [rSB], a
- xor a
- ld [hSerialReceiveData], a
- ld a, START_TRANSFER_EXTERNAL_CLOCK
- ld [rSC], a
- ret
\ No newline at end of file +Serial:: ; 2125 (0:2125) + push af + push bc + push de + push hl + ld a, [hSerialConnectionStatus] + inc a + jr z, .connectionNotYetEstablished + ld a, [rSB] + ld [hSerialReceiveData], a + ld a, [hSerialSendData] + ld [rSB], a + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + jr z, .done +; using external clock + ld a, START_TRANSFER_EXTERNAL_CLOCK + ld [rSC], a + jr .done +.connectionNotYetEstablished + ld a, [rSB] + ld [hSerialReceiveData], a + ld [hSerialConnectionStatus], a + cp USING_INTERNAL_CLOCK + jr z, .usingInternalClock +; using external clock + xor a + ld [rSB], a + ld a, $3 + ld [rDIV], a +.waitLoop + ld a, [rDIV] + bit 7, a + jr nz, .waitLoop + ld a, START_TRANSFER_EXTERNAL_CLOCK + ld [rSC], a + jr .done +.usingInternalClock + xor a + ld [rSB], a +.done + ld a, $1 + ld [hSerialReceivedNewData], a + ld a, SERIAL_NO_DATA_BYTE + ld [hSerialSendData], a + pop hl + pop de + pop bc + pop af + reti + +; hl = send data +; de = receive data +; bc = length of data +Serial_ExchangeBytes:: ; 216f (0:216f) + ld a, 1 + ld [hSerialIgnoringInitialData], a +.loop + ld a, [hl] + ld [hSerialSendData], a + call Serial_ExchangeByte + push bc + ld b, a + inc hl + ld a, 48 +.waitLoop + dec a + jr nz, .waitLoop + ld a, [hSerialIgnoringInitialData] + and a + ld a, b + pop bc + jr z, .storeReceivedByte + dec hl + cp SERIAL_PREAMBLE_BYTE + jr nz, .loop + xor a + ld [hSerialIgnoringInitialData], a + jr .loop +.storeReceivedByte + ld [de], a + inc de + dec bc + ld a, b + or c + jr nz, .loop + ret + +Serial_ExchangeByte:: ; 219a (0:219a) + xor a + ld [hSerialReceivedNewData], a + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + jr nz, .asm_21a7 + ld a, START_TRANSFER_INTERNAL_CLOCK + ld [rSC], a +.asm_21a7 + ld a, [hSerialReceivedNewData] + and a + jr nz, .asm_21f1 + ld a, [hSerialConnectionStatus] + cp USING_EXTERNAL_CLOCK + jr nz, .asm_21cc + call IsUnknownCounterZero + jr z, .asm_21cc + call WaitLoop_15Iterations + push hl + ld hl, wUnknownSerialCounter + 1 + inc [hl] + jr nz, .asm_21c3 + dec hl + inc [hl] +.asm_21c3 + pop hl + call IsUnknownCounterZero + jr nz, .asm_21a7 + jp SetUnknownCounterToFFFF +.asm_21cc + ld a, [rIE] + and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) + cp (1 << SERIAL) + jr nz, .asm_21a7 + ld a, [wUnknownSerialCounter2] + dec a + ld [wUnknownSerialCounter2], a + jr nz, .asm_21a7 + ld a, [wUnknownSerialCounter2 + 1] + dec a + ld [wUnknownSerialCounter2 + 1], a + jr nz, .asm_21a7 + ld a, [hSerialConnectionStatus] + cp USING_EXTERNAL_CLOCK + jr z, .asm_21f1 + ld a, 255 +.waitLoop + dec a + jr nz, .waitLoop +.asm_21f1 + xor a + ld [hSerialReceivedNewData], a + ld a, [rIE] + and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) + sub (1 << SERIAL) + jr nz, .asm_2204 + ld [wUnknownSerialCounter2], a + ld a, $50 + ld [wUnknownSerialCounter2 + 1], a +.asm_2204 + ld a, [hSerialReceiveData] + cp SERIAL_NO_DATA_BYTE + ret nz + call IsUnknownCounterZero + jr z, .asm_221f + push hl + ld hl, wUnknownSerialCounter + 1 + ld a, [hl] + dec a + ld [hld], a + inc a + jr nz, .asm_2219 + dec [hl] +.asm_2219 + pop hl + call IsUnknownCounterZero + jr z, SetUnknownCounterToFFFF +.asm_221f + ld a, [rIE] + and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) + cp (1 << SERIAL) + ld a, SERIAL_NO_DATA_BYTE + ret z + ld a, [hl] + ld [hSerialSendData], a + call DelayFrame + jp Serial_ExchangeByte + +WaitLoop_15Iterations:: ; 2231 (0:2231) + ld a, 15 +.waitLoop + dec a + jr nz, .waitLoop + ret + +IsUnknownCounterZero:: ; 2237 (0:2237) + push hl + ld hl, wUnknownSerialCounter + ld a, [hli] + or [hl] + pop hl + ret + +; a is always 0 when this is called +SetUnknownCounterToFFFF:: ; 223f (0:223f) + dec a + ld [wUnknownSerialCounter], a + ld [wUnknownSerialCounter + 1], a + ret + +; This is used to exchange the button press and selected menu item on the link menu. +; The data is sent thrice and read twice to increase reliability. +Serial_ExchangeLinkMenuSelection:: ; 2247 (0:2247) + ld hl, wLinkMenuSelectionSendBuffer + ld de, wLinkMenuSelectionReceiveBuffer + ld c, 2 ; number of bytes to save + ld a, 1 + ld [hSerialIgnoringInitialData], a +.loop + call DelayFrame + ld a, [hl] + ld [hSerialSendData], a + call Serial_ExchangeByte + ld b, a + inc hl + ld a, [hSerialIgnoringInitialData] + and a + ld a, 0 + ld [hSerialIgnoringInitialData], a + jr nz, .loop + ld a, b + ld [de], a + inc de + dec c + jr nz, .loop + ret + +Serial_PrintWaitingTextAndSyncAndExchangeNybble:: ; 226e (0:226e) + call SaveScreenTilesToBuffer1 + callab PrintWaitingText + call Serial_SyncAndExchangeNybble + jp LoadScreenTilesFromBuffer1 + +Serial_SyncAndExchangeNybble:: ; 227f (0:227f) + ld a, $ff + ld [wSerialExchangeNybbleReceiveData], a +.loop1 + call Serial_ExchangeNybble + call DelayFrame + call IsUnknownCounterZero + jr z, .next1 + push hl + ld hl, wUnknownSerialCounter + 1 + dec [hl] + jr nz, .next2 + dec hl + dec [hl] + jr nz, .next2 + pop hl + xor a + jp SetUnknownCounterToFFFF +.next2 + pop hl +.next1 + ld a, [wSerialExchangeNybbleReceiveData] + inc a + jr z, .loop1 + ld b, 10 +.loop2 + call DelayFrame + call Serial_ExchangeNybble + dec b + jr nz, .loop2 + ld b, 10 +.loop3 + call DelayFrame + call Serial_SendZeroByte + dec b + jr nz, .loop3 + ld a, [wSerialExchangeNybbleReceiveData] + ld [wSerialSyncAndExchangeNybbleReceiveData], a + ret + +Serial_ExchangeNybble:: ; 22c3 (0:22c3) + call .doExchange + ld a, [wSerialExchangeNybbleSendData] + add $60 + ld [hSerialSendData], a + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + jr nz, .doExchange + ld a, START_TRANSFER_INTERNAL_CLOCK + ld [rSC], a +.doExchange + ld a, [hSerialReceiveData] + ld [wSerialExchangeNybbleTempReceiveData], a + and $f0 + cp $60 + ret nz + xor a + ld [hSerialReceiveData], a + ld a, [wSerialExchangeNybbleTempReceiveData] + and $f + ld [wSerialExchangeNybbleReceiveData], a + ret + +Serial_SendZeroByte:: ; 22ed (0:22ed) + xor a + ld [hSerialSendData], a + ld a, [hSerialConnectionStatus] + cp USING_INTERNAL_CLOCK + ret nz + ld a, START_TRANSFER_INTERNAL_CLOCK + ld [rSC], a + ret + +Serial_TryEstablishingExternallyClockedConnection:: ; 22fa (0:22fa) + ld a, ESTABLISH_CONNECTION_WITH_EXTERNAL_CLOCK + ld [rSB], a + xor a + ld [hSerialReceiveData], a + ld a, START_TRANSFER_EXTERNAL_CLOCK + ld [rSC], a + ret diff --git a/home/text.asm b/home/text.asm index 276b652e..fabcd843 100644 --- a/home/text.asm +++ b/home/text.asm @@ -293,7 +293,7 @@ Char51:: ; 1ab4 (0:1ab4) hlCoord 1, 13 ld bc,$0412 call ClearScreenArea - ld c,$14 + ld c,20 call DelayFrames pop de hlCoord 1, 14 @@ -308,7 +308,7 @@ Char49:: ; 1ad5 (0:1ad5) hlCoord 1, 10 ld bc,$0712 call ClearScreenArea - ld c,$14 + ld c,20 call DelayFrames pop de pop hl @@ -690,7 +690,7 @@ TextCommand17:: ; 1ca3 (0:1ca3) ld d,a ld a,[hli] ld [H_LOADEDROMBANK],a - ld [$2000],a + ld [MBC1RomBank],a push hl ld l,e ld h,d @@ -698,7 +698,7 @@ TextCommand17:: ; 1ca3 (0:1ca3) pop hl pop af ld [H_LOADEDROMBANK],a - ld [$2000],a + ld [MBC1RomBank],a jp NextTextCommand TextCommandJumpTable:: ; 1cc1 (0:1cc1) |