sync home

This commit is contained in:
YamaArashi 2016-06-12 11:35:21 -07:00
parent 3a6a300da4
commit 3ab3f4273b
7 changed files with 150 additions and 131 deletions

126
home.asm
View file

@ -117,7 +117,6 @@ INCLUDE "home/joypad.asm"
INCLUDE "data/map_header_pointers.asm" INCLUDE "data/map_header_pointers.asm"
INCLUDE "home/overworld.asm" INCLUDE "home/overworld.asm"
CheckForUserInterruption:: CheckForUserInterruption::
; Return carry if Up+Select+B, Start or A are pressed in c frames. ; Return carry if Up+Select+B, Start or A are pressed in c frames.
; Used only in the intro and title screen. ; Used only in the intro and title screen.
@ -255,7 +254,6 @@ DrawHPBar::
LoadMonData:: LoadMonData::
jpab LoadMonData_ jpab LoadMonData_
OverwritewMoves:: OverwritewMoves::
; Write c to [wMoves + b]. Unused. ; Write c to [wMoves + b]. Unused.
ld hl, wMoves ld hl, wMoves
@ -327,7 +325,7 @@ GetCryData::
add hl, bc add hl, bc
add hl, bc add hl, bc
ld a, Bank(CryData) ld a, BANK(CryData)
call BankswitchHome call BankswitchHome
ld a, [hli] ld a, [hli]
ld b, a ; cry id ld b, a ; cry id
@ -347,7 +345,6 @@ GetCryData::
add c add c
ret ret
DisplayPartyMenu:: DisplayPartyMenu::
ld a,[hTilesetType] ld a,[hTilesetType]
push af push af
@ -497,6 +494,7 @@ PrintStatusCondition::
ld [hl],"T" ld [hl],"T"
and a and a
ret ret
PrintStatusConditionNotFainted: PrintStatusConditionNotFainted:
ld a,[H_LOADEDROMBANK] ld a,[H_LOADEDROMBANK]
push af push af
@ -519,7 +517,7 @@ PrintLevel::
ld [hli],a ld [hli],a
ld c,2 ; number of digits ld c,2 ; number of digits
ld a,[wLoadedMonLevel] ; level ld a,[wLoadedMonLevel] ; level
cp a,100 cp 100
jr c,PrintLevelCommon jr c,PrintLevelCommon
; if level at least 100, write over the ":L" tile ; if level at least 100, write over the ":L" tile
dec hl dec hl
@ -569,25 +567,25 @@ GetMonHeader::
ld [wd11e],a ld [wd11e],a
ld de,FossilKabutopsPic ld de,FossilKabutopsPic
ld b,$66 ; size of Kabutops fossil and Ghost sprites ld b,$66 ; size of Kabutops fossil and Ghost sprites
cp a,FOSSIL_KABUTOPS ; Kabutops fossil cp FOSSIL_KABUTOPS ; Kabutops fossil
jr z,.specialID jr z,.specialID
ld de,GhostPic ld de,GhostPic
cp a,MON_GHOST ; Ghost cp MON_GHOST ; Ghost
jr z,.specialID jr z,.specialID
ld de,FossilAerodactylPic ld de,FossilAerodactylPic
ld b,$77 ; size of Aerodactyl fossil sprite ld b,$77 ; size of Aerodactyl fossil sprite
cp a,FOSSIL_AERODACTYL ; Aerodactyl fossil cp FOSSIL_AERODACTYL ; Aerodactyl fossil
jr z,.specialID jr z,.specialID
cp a,MEW cp a,MEW
jr z,.mew jr z,.mew
predef IndexToPokedex ; convert pokemon ID in [wd11e] to pokedex number predef IndexToPokedex ; convert pokemon ID in [wd11e] to pokedex number
ld a,[wd11e] ld a,[wd11e]
dec a dec a
ld bc,MonBaseStatsEnd - MonBaseStats ld bc, MonBaseStatsEnd - MonBaseStats
ld hl,BaseStats ld hl,BaseStats
call AddNTimes call AddNTimes
ld de,wMonHeader ld de,wMonHeader
ld bc,MonBaseStatsEnd - MonBaseStats ld bc, MonBaseStatsEnd - MonBaseStats
call CopyData call CopyData
jr .done jr .done
.specialID .specialID
@ -703,7 +701,7 @@ PrintBCDDigit::
.skipCurrencySymbol .skipCurrencySymbol
res 7,b ; unset 7 to indicate that a nonzero digit has been reached res 7,b ; unset 7 to indicate that a nonzero digit has been reached
.outputDigit .outputDigit
add a,"0" add "0"
ld [hli],a ld [hli],a
jp PrintLetterDelay jp PrintLetterDelay
.zeroDigit .zeroDigit
@ -968,7 +966,6 @@ PokeCenterSignText::
db "@" db "@"
PickUpItemText:: PickUpItemText::
; XXX better label (what does predef $5C do?)
TX_ASM TX_ASM
predef PickUpItem predef PickUpItem
jp TextScriptEnd jp TextScriptEnd
@ -1000,15 +997,15 @@ ResetPlayerSpriteData_ClearSpriteData::
FadeOutAudio:: FadeOutAudio::
ld a, [wAudioFadeOutControl] ld a, [wAudioFadeOutControl]
and a and a ; currently fading out audio?
jr nz, .asm_28dc jr nz, .fadingOut
ld a, [wd72c] ld a, [wd72c]
bit 1, a bit 1, a
ret nz ret nz
ld a, $77 ld a, $77
ld [rNR50], a ld [rNR50], a
ret ret
.asm_28dc .fadingOut
ld a, [wAudioFadeOutCounter] ld a, [wAudioFadeOutCounter]
and a and a
jr z, .counterReachedZero jr z, .counterReachedZero
@ -1019,8 +1016,8 @@ FadeOutAudio::
ld a, [wAudioFadeOutCounterReloadValue] ld a, [wAudioFadeOutCounterReloadValue]
ld [wAudioFadeOutCounter], a ld [wAudioFadeOutCounter], a
ld a, [rNR50] ld a, [rNR50]
and a and a ; has the volume reached 0?
jr z, .asm_2903 jr z, .fadeOutComplete
ld b, a ld b, a
and $f and $f
dec a dec a
@ -1033,7 +1030,7 @@ FadeOutAudio::
or c or c
ld [rNR50], a ld [rNR50], a
ret ret
.asm_2903 .fadeOutComplete
ld a, [wAudioFadeOutControl] ld a, [wAudioFadeOutControl]
ld b, a ld b, a
xor a xor a
@ -1071,13 +1068,13 @@ DisplayTextID::
ld [wSpriteIndex],a ld [wSpriteIndex],a
and a and a
jp z,DisplayStartMenu jp z,DisplayStartMenu
cp a,TEXT_SAFARI_GAME_OVER cp TEXT_SAFARI_GAME_OVER
jp z,DisplaySafariGameOverText jp z,DisplaySafariGameOverText
cp a,TEXT_MON_FAINTED cp TEXT_MON_FAINTED
jp z,DisplayPokemonFaintedText jp z,DisplayPokemonFaintedText
cp a,TEXT_BLACKED_OUT cp TEXT_BLACKED_OUT
jp z,DisplayPlayerBlackedOutText jp z,DisplayPlayerBlackedOutText
cp a,TEXT_REPEL_WORE_OFF cp TEXT_REPEL_WORE_OFF
jp z,DisplayRepelWoreOffText jp z,DisplayRepelWoreOffText
ld a,[wNumSprites] ld a,[wNumSprites]
ld e,a ld e,a
@ -1116,24 +1113,24 @@ DisplayTextID::
ld l,a ; hl = address of the text ld l,a ; hl = address of the text
ld a,[hl] ; a = first byte of text ld a,[hl] ; a = first byte of text
; check first byte of text for special cases ; check first byte of text for special cases
cp a,$fe ; Pokemart NPC cp $fe ; Pokemart NPC
jp z,DisplayPokemartDialogue jp z,DisplayPokemartDialogue
cp a,$ff ; Pokemon Center NPC cp $ff ; Pokemon Center NPC
jp z,DisplayPokemonCenterDialogue jp z,DisplayPokemonCenterDialogue
cp a,$fc ; Item Storage PC cp $fc ; Item Storage PC
jp z,FuncTX_ItemStoragePC jp z,FuncTX_ItemStoragePC
cp a,$fd ; Bill's PC cp $fd ; Bill's PC
jp z,FuncTX_BillsPC jp z,FuncTX_BillsPC
cp a,$f9 ; Pokemon Center PC cp $f9 ; Pokemon Center PC
jp z,FuncTX_PokemonCenterPC jp z,FuncTX_PokemonCenterPC
cp a,$f5 ; Vending Machine cp $f5 ; Vending Machine
jr nz,.notVendingMachine jr nz,.notVendingMachine
callba VendingMachineMenu ; jump banks to vending machine routine callba VendingMachineMenu ; jump banks to vending machine routine
jr AfterDisplayingTextID jr AfterDisplayingTextID
.notVendingMachine .notVendingMachine
cp a,$f7 ; slot machine cp $f7 ; prize menu
jp z,FuncTX_SlotMachine jp z, FuncTX_GameCornerPrizeMenu
cp a,$f6 ; cable connection NPC in Pokemon Center cp $f6 ; cable connection NPC in Pokemon Center
jr nz,.notSpecialCase jr nz,.notSpecialCase
callab CableClubNPC callab CableClubNPC
jr AfterDisplayingTextID jr AfterDisplayingTextID
@ -1228,7 +1225,7 @@ LoadItemList::
ld a,[hli] ld a,[hli]
ld [de],a ld [de],a
inc de inc de
cp a,$ff cp $ff
jr nz,.loop jr nz,.loop
ret ret
@ -1382,7 +1379,7 @@ DisplayListMenuID::
ld a,$01 ; hardcoded bank ld a,$01 ; hardcoded bank
jr .bankswitch jr .bankswitch
.specialBattleType ; Old Man battle .specialBattleType ; Old Man battle
ld a, Bank(DisplayBattleMenu) ld a, BANK(DisplayBattleMenu)
.bankswitch .bankswitch
call BankswitchHome call BankswitchHome
ld hl,wd730 ld hl,wd730
@ -1411,7 +1408,7 @@ DisplayListMenuID::
ld a,1 ; max menu item ID is 1 if the list has less than 2 entries ld a,1 ; max menu item ID is 1 if the list has less than 2 entries
ld [wMenuWatchMovingOutOfBounds],a ld [wMenuWatchMovingOutOfBounds],a
ld a,[wListCount] ld a,[wListCount]
cp a,2 ; does the list have less than 2 entries? cp 2 ; does the list have less than 2 entries?
jr c,.setMenuVariables jr c,.setMenuVariables
ld a,2 ; max menu item ID is 2 if the list has at least 2 entries ld a,2 ; max menu item ID is 2 if the list has at least 2 entries
.setMenuVariables .setMenuVariables
@ -1481,7 +1478,7 @@ DisplayListMenuIDLoop::
ld a,c ld a,c
ld [wWhichPokemon],a ld [wWhichPokemon],a
ld a,[wListMenuID] ld a,[wListMenuID]
cp a,ITEMLISTMENU cp ITEMLISTMENU
jr nz,.skipMultiplying jr nz,.skipMultiplying
; if it's an item menu ; if it's an item menu
sla c ; item entries are 2 bytes long, so multiply by 2 sla c ; item entries are 2 bytes long, so multiply by 2
@ -1502,7 +1499,7 @@ DisplayListMenuIDLoop::
call GetItemPrice call GetItemPrice
pop hl pop hl
ld a,[wListMenuID] ld a,[wListMenuID]
cp a,ITEMLISTMENU cp ITEMLISTMENU
jr nz,.skipGettingQuantity jr nz,.skipGettingQuantity
; if it's an item menu ; if it's an item menu
inc hl inc hl
@ -1548,7 +1545,7 @@ DisplayListMenuIDLoop::
jr z,.upPressed jr z,.upPressed
.downPressed .downPressed
ld a,[hl] ld a,[hl]
add a,3 add 3
ld b,a ld b,a
ld a,[wListCount] ld a,[wListCount]
cp b ; will going down scroll past the Cancel button? cp b ; will going down scroll past the Cancel button?
@ -1568,7 +1565,7 @@ DisplayChooseQuantityMenu::
ld b,1 ; height ld b,1 ; height
ld c,3 ; width ld c,3 ; width
ld a,[wListMenuID] ld a,[wListMenuID]
cp a,PRICEDITEMLISTMENU cp PRICEDITEMLISTMENU
jr nz,.drawTextBox jr nz,.drawTextBox
; text box dimensions/coordinates for quantity and price ; text box dimensions/coordinates for quantity and price
coord hl, 7, 9 coord hl, 7, 9
@ -1578,7 +1575,7 @@ DisplayChooseQuantityMenu::
call TextBoxBorder call TextBoxBorder
coord hl, 16, 10 coord hl, 16, 10
ld a,[wListMenuID] ld a,[wListMenuID]
cp a,PRICEDITEMLISTMENU cp PRICEDITEMLISTMENU
jr nz,.printInitialQuantity jr nz,.printInitialQuantity
coord hl, 8, 10 coord hl, 8, 10
.printInitialQuantity .printInitialQuantity
@ -1622,7 +1619,7 @@ DisplayChooseQuantityMenu::
.handleNewQuantity .handleNewQuantity
coord hl, 17, 10 coord hl, 17, 10
ld a,[wListMenuID] ld a,[wListMenuID]
cp a,PRICEDITEMLISTMENU cp PRICEDITEMLISTMENU
jr nz,.printQuantity jr nz,.printQuantity
.printPrice .printPrice
ld c,$03 ld c,$03
@ -1716,7 +1713,7 @@ PrintListMenuEntries::
ld a,[wListScrollOffset] ld a,[wListScrollOffset]
ld c,a ld c,a
ld a,[wListMenuID] ld a,[wListMenuID]
cp a,ITEMLISTMENU cp ITEMLISTMENU
ld a,c ld a,c
jr nz,.skipMultiplying jr nz,.skipMultiplying
; if it's an item menu ; if it's an item menu
@ -1736,7 +1733,7 @@ PrintListMenuEntries::
ld [wWhichPokemon],a ld [wWhichPokemon],a
ld a,[de] ld a,[de]
ld [wd11e],a ld [wd11e],a
cp a,$ff cp $ff
jp z,.printCancelMenuItem jp z,.printCancelMenuItem
push bc push bc
push de push de
@ -1746,7 +1743,7 @@ PrintListMenuEntries::
ld a,[wListMenuID] ld a,[wListMenuID]
and a and a
jr z,.pokemonPCMenu jr z,.pokemonPCMenu
cp a,$01 cp MOVESLISTMENU
jr z,.movesMenu jr z,.movesMenu
.itemMenu .itemMenu
call GetItemName call GetItemName
@ -1834,7 +1831,7 @@ PrintListMenuEntries::
pop de pop de
inc de inc de
ld a,[wListMenuID] ld a,[wListMenuID]
cp a,ITEMLISTMENU cp ITEMLISTMENU
jr nz,.nextListEntry jr nz,.nextListEntry
.printItemQuantity .printItemQuantity
ld a,[wd11e] ld a,[wd11e]
@ -1991,7 +1988,6 @@ GetMachineName::
inc de inc de
ld a,"@" ld a,"@"
ld [de],a ld [de],a
pop af pop af
ld [wd11e],a ld [wd11e],a
pop bc pop bc
@ -2007,9 +2003,9 @@ HiddenPrefix::
; sets carry if item is HM, clears carry if item is not HM ; sets carry if item is HM, clears carry if item is not HM
; Input: a = item ID ; Input: a = item ID
IsItemHM:: IsItemHM::
cp a,HM_01 cp HM_01
jr c,.notHM jr c,.notHM
cp a,TM_01 cp TM_01
ret ret
.notHM .notHM
and a and a
@ -2189,6 +2185,7 @@ RunNPCMovementScript::
ld [H_LOADEDROMBANK], a ld [H_LOADEDROMBANK], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ret ret
.NPCMovementScriptPointerTables .NPCMovementScriptPointerTables
dw PalletMovementScriptPointerTable dw PalletMovementScriptPointerTable
dw PewterMuseumGuyMovementScriptPointerTable dw PewterMuseumGuyMovementScriptPointerTable
@ -2679,7 +2676,7 @@ FuncTX_BillsPC::
ld hl, BillsPC_ ld hl, BillsPC_
jr bankswitchAndContinue jr bankswitchAndContinue
FuncTX_SlotMachine:: FuncTX_GameCornerPrizeMenu::
; XXX find a better name for this function ; XXX find a better name for this function
; special_F7 ; special_F7
ld b,BANK(CeladonPrizeMenu) ld b,BANK(CeladonPrizeMenu)
@ -2752,7 +2749,7 @@ CheckCoords::
ld [wCoordIndex],a ld [wCoordIndex],a
.loop .loop
ld a,[hli] ld a,[hli]
cp a,$ff ; reached terminator? cp $ff ; reached terminator?
jr z,.notInArray jr z,.notInArray
push hl push hl
ld hl,wCoordIndex ld hl,wCoordIndex
@ -2871,7 +2868,7 @@ GetSpriteMovementByte1Pointer::
ld h,$C2 ld h,$C2
ld a,[H_SPRITEINDEX] ld a,[H_SPRITEINDEX]
swap a swap a
add a,6 add 6
ld l,a ld l,a
ret ret
@ -2924,7 +2921,6 @@ GetTrainerInformation::
GetTrainerName:: GetTrainerName::
jpba GetTrainerName_ jpba GetTrainerName_
HasEnoughMoney:: HasEnoughMoney::
; Check if the player has at least as much ; Check if the player has at least as much
; money as the 3-byte BCD value at hMoney. ; money as the 3-byte BCD value at hMoney.
@ -3006,12 +3002,13 @@ YesNoChoicePokeCenter::
lb bc, 8, 12 lb bc, 8, 12
jr DisplayYesNoChoice jr DisplayYesNoChoice
Func_361a:: WideYesNoChoice:: ; unused
call SaveScreenTilesToBuffer1 call SaveScreenTilesToBuffer1
ld a, WIDE_YES_NO_MENU ld a, WIDE_YES_NO_MENU
ld [wTwoOptionMenuID], a ld [wTwoOptionMenuID], a
coord hl, 12, 7 coord hl, 12, 7
lb bc, 8, 13 lb bc, 8, 13
DisplayYesNoChoice:: DisplayYesNoChoice::
ld a, TWO_OPTION_MENU ld a, TWO_OPTION_MENU
ld [wTextBoxID], a ld [wTextBoxID], a
@ -3045,7 +3042,7 @@ MoveSprite_::
ld [hli],a ld [hli],a
inc de inc de
inc c inc c
cp a,$FF ; have we reached the end of the movement data? cp $FF ; have we reached the end of the movement data?
jr nz,.loop jr nz,.loop
ld a,c ld a,c
@ -3066,7 +3063,7 @@ MoveSprite_::
; divides [hDividend2] by [hDivisor2] and stores the quotient in [hQuotient2] ; divides [hDividend2] by [hDivisor2] and stores the quotient in [hQuotient2]
DivideBytes:: DivideBytes::
push hl push hl
ld hl, $ffe7 ld hl, hQuotient2
xor a xor a
ld [hld], a ld [hld], a
ld a, [hld] ld a, [hld]
@ -3157,7 +3154,6 @@ UncompressSpriteFromDE::
ld [hl], d ld [hl], d
jp UncompressSpriteData jp UncompressSpriteData
SaveScreenTilesToBuffer2:: SaveScreenTilesToBuffer2::
coord hl, 0, 0 coord hl, 0, 0
ld de, wTileMapBackup2 ld de, wTileMapBackup2
@ -3199,7 +3195,7 @@ LoadScreenTilesFromBuffer1::
ret ret
DelayFrames:: DelayFrames::
; wait n frames, where n is the value in c ; wait c frames
call DelayFrame call DelayFrame
dec c dec c
jr nz,DelayFrames jr nz,DelayFrames
@ -3300,7 +3296,7 @@ GetName::
ld e,l ld e,l
.nextChar .nextChar
ld a,[hli] ld a,[hli]
cp a, "@" cp "@"
jr nz,.nextChar jr nz,.nextChar
inc c ;entry counter inc c ;entry counter
ld a,b ;wanted entry ld a,b ;wanted entry
@ -3332,9 +3328,9 @@ GetItemPrice::
ld a, [wListMenuID] ld a, [wListMenuID]
cp MOVESLISTMENU cp MOVESLISTMENU
ld a, BANK(ItemPrices) ld a, BANK(ItemPrices)
jr nz, .asm_37ed jr nz, .ok
ld a, $f ; hardcoded Bank ld a, $f ; hardcoded Bank
.asm_37ed .ok
ld [H_LOADEDROMBANK], a ld [H_LOADEDROMBANK], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ld hl, wItemPrices ld hl, wItemPrices
@ -3345,10 +3341,10 @@ GetItemPrice::
cp HM_01 cp HM_01
jr nc, .getTMPrice jr nc, .getTMPrice
ld bc, $3 ld bc, $3
.asm_3802 .loop
add hl, bc add hl, bc
dec a dec a
jr nz, .asm_3802 jr nz, .loop
dec hl dec hl
ld a, [hld] ld a, [hld]
ld [hItemPrice + 2], a ld [hItemPrice + 2], a
@ -3356,13 +3352,13 @@ GetItemPrice::
ld [hItemPrice + 1], a ld [hItemPrice + 1], a
ld a, [hl] ld a, [hl]
ld [hItemPrice], a ld [hItemPrice], a
jr .asm_381c jr .done
.getTMPrice .getTMPrice
ld a, Bank(GetMachinePrice) ld a, Bank(GetMachinePrice)
ld [H_LOADEDROMBANK], a ld [H_LOADEDROMBANK], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
call GetMachinePrice call GetMachinePrice
.asm_381c .done
ld de, hItemPrice ld de, hItemPrice
pop af pop af
ld [H_LOADEDROMBANK], a ld [H_LOADEDROMBANK], a
@ -4075,7 +4071,7 @@ PlaceMenuCursor::
jr nz,.currentMenuItemLoop jr nz,.currentMenuItemLoop
.checkForArrow2 .checkForArrow2
ld a,[hl] ld a,[hl]
cp a,"▶" ; has the right arrow already been placed? cp "▶" ; has the right arrow already been placed?
jr z,.skipSavingTile ; if so, don't lose the saved tile jr z,.skipSavingTile ; if so, don't lose the saved tile
ld [wTileBehindCursor],a ; save tile before overwriting with right arrow ld [wTileBehindCursor],a ; save tile before overwriting with right arrow
.skipSavingTile .skipSavingTile
@ -4656,6 +4652,8 @@ SetMapTextPointer::
ret ret
TextPredefs:: TextPredefs::
const_value = 1
add_tx_pre CardKeySuccessText ; 01 add_tx_pre CardKeySuccessText ; 01
add_tx_pre CardKeyFailText ; 02 add_tx_pre CardKeyFailText ; 02
add_tx_pre RedBedroomPCText ; 03 add_tx_pre RedBedroomPCText ; 03

View file

@ -1,7 +1,7 @@
; These routines manage gradual fading ; These routines manage gradual fading
; (e.g., entering a doorway) ; (e.g., entering a doorway)
LoadGBPal:: LoadGBPal::
ld a, [wMapPalOffset] ;tells if cur.map is dark (requires HM5_FLASH?) ld a, [wMapPalOffset] ;tells if wCurMap is dark (requires HM5_FLASH?)
ld b, a ld b, a
ld hl, FadePal4 ld hl, FadePal4
ld a, l ld a, l

View file

@ -59,7 +59,7 @@ OverworldLoopLessDelay::
res 3,[hl] res 3,[hl]
jp nz,WarpFound2 jp nz,WarpFound2
ld a,[wd732] ld a,[wd732]
and a,1 << 4 | 1 << 3 ; fly warp or dungeon warp and 1 << 4 | 1 << 3 ; fly warp or dungeon warp
jp nz,HandleFlyWarpOrDungeonWarp jp nz,HandleFlyWarpOrDungeonWarp
ld a,[wCurOpponent] ld a,[wCurOpponent]
and a and a
@ -133,7 +133,7 @@ OverworldLoopLessDelay::
ld hl,wFlags_0xcd60 ld hl,wFlags_0xcd60
res 2,[hl] res 2,[hl]
call UpdateSprites call UpdateSprites
ld a,1 ld a, 1
ld [wCheckFor180DegreeTurn],a ld [wCheckFor180DegreeTurn],a
ld a,[wPlayerMovingDirection] ; the direction that was pressed last time ld a,[wPlayerMovingDirection] ; the direction that was pressed last time
and a and a
@ -143,6 +143,7 @@ OverworldLoopLessDelay::
xor a xor a
ld [wPlayerMovingDirection],a ; zero the direction ld [wPlayerMovingDirection],a ; zero the direction
jp OverworldLoop jp OverworldLoop
.checkIfDownButtonIsPressed .checkIfDownButtonIsPressed
ld a,[hJoyHeld] ; current joypad state ld a,[hJoyHeld] ; current joypad state
bit 7,a ; down button bit 7,a ; down button
@ -151,6 +152,7 @@ OverworldLoopLessDelay::
ld [wSpriteStateData1 + 3],a ; delta Y ld [wSpriteStateData1 + 3],a ; delta Y
ld a,PLAYER_DIR_DOWN ld a,PLAYER_DIR_DOWN
jr .handleDirectionButtonPress jr .handleDirectionButtonPress
.checkIfUpButtonIsPressed .checkIfUpButtonIsPressed
bit 6,a ; up button bit 6,a ; up button
jr z,.checkIfLeftButtonIsPressed jr z,.checkIfLeftButtonIsPressed
@ -158,6 +160,7 @@ OverworldLoopLessDelay::
ld [wSpriteStateData1 + 3],a ; delta Y ld [wSpriteStateData1 + 3],a ; delta Y
ld a,PLAYER_DIR_UP ld a,PLAYER_DIR_UP
jr .handleDirectionButtonPress jr .handleDirectionButtonPress
.checkIfLeftButtonIsPressed .checkIfLeftButtonIsPressed
bit 5,a ; left button bit 5,a ; left button
jr z,.checkIfRightButtonIsPressed jr z,.checkIfRightButtonIsPressed
@ -165,11 +168,14 @@ OverworldLoopLessDelay::
ld [wSpriteStateData1 + 5],a ; delta X ld [wSpriteStateData1 + 5],a ; delta X
ld a,PLAYER_DIR_LEFT ld a,PLAYER_DIR_LEFT
jr .handleDirectionButtonPress jr .handleDirectionButtonPress
.checkIfRightButtonIsPressed .checkIfRightButtonIsPressed
bit 4,a ; right button bit 4,a ; right button
jr z,.noDirectionButtonsPressed jr z,.noDirectionButtonsPressed
ld a,1 ; PLAYER_DIR_RIGHT ld a, 1
ld [wSpriteStateData1 + 5],a ; delta X ld [wSpriteStateData1 + 5],a ; delta X
.handleDirectionButtonPress .handleDirectionButtonPress
ld [wPlayerDirection],a ; new direction ld [wPlayerDirection],a ; new direction
ld a,[wd730] ld a,[wd730]
@ -226,12 +232,13 @@ OverworldLoopLessDelay::
call NewBattle call NewBattle
jp c,.battleOccurred jp c,.battleOccurred
jp OverworldLoop jp OverworldLoop
.noDirectionChange .noDirectionChange
ld a,[wPlayerDirection] ; current direction ld a,[wPlayerDirection] ; current direction
ld [wPlayerMovingDirection],a ; save direction ld [wPlayerMovingDirection],a ; save direction
call UpdateSprites call UpdateSprites
ld a,[wWalkBikeSurfState] ld a,[wWalkBikeSurfState]
cp a,$02 ; surfing cp $02 ; surfing
jr z,.surfing jr z,.surfing
; not surfing ; not surfing
call CollisionCheckOnLand call CollisionCheckOnLand
@ -248,20 +255,24 @@ OverworldLoopLessDelay::
pop hl pop hl
jp c,CheckWarpsCollision jp c,CheckWarpsCollision
jp OverworldLoop jp OverworldLoop
.surfing .surfing
call CollisionCheckOnWater call CollisionCheckOnWater
jp c,OverworldLoop jp c,OverworldLoop
.noCollision .noCollision
ld a,$08 ld a,$08
ld [wWalkCounter],a ld [wWalkCounter],a
jr .moveAhead2 jr .moveAhead2
.moveAhead .moveAhead
ld a,[wd736] ld a,[wd736]
bit 7,a bit 7,a
jr z,.noSpinning jr z,.noSpinning
callba LoadSpinnerArrowTiles ; spin while moving callba LoadSpinnerArrowTiles
.noSpinning .noSpinning
call UpdateSprites call UpdateSprites
.moveAhead2 .moveAhead2
ld hl,wFlags_0xcd60 ld hl,wFlags_0xcd60
res 2,[hl] res 2,[hl]
@ -271,7 +282,7 @@ OverworldLoopLessDelay::
ld a,[wd736] ld a,[wd736]
bit 6,a ; jumping a ledge? bit 6,a ; jumping a ledge?
jr nz,.normalPlayerSpriteAdvancement jr nz,.normalPlayerSpriteAdvancement
call BikeSpeedup ; if riding a bike and not jumping a ledge call DoBikeSpeedup
.normalPlayerSpriteAdvancement .normalPlayerSpriteAdvancement
call AdvancePlayerSprite call AdvancePlayerSprite
ld a,[wWalkCounter] ld a,[wWalkCounter]
@ -323,14 +334,14 @@ OverworldLoopLessDelay::
xor a xor a
ld [hJoyHeld],a ld [hJoyHeld],a
ld a,[wCurMap] ld a,[wCurMap]
cp a,CINNABAR_GYM cp CINNABAR_GYM
jr nz,.notCinnabarGym jr nz,.notCinnabarGym
SetEvent EVENT_2A7 SetEvent EVENT_2A7
.notCinnabarGym .notCinnabarGym
ld hl,wd72e ld hl,wd72e
set 5,[hl] set 5,[hl]
ld a,[wCurMap] ld a,[wCurMap]
cp a,OAKS_LAB cp OAKS_LAB
jp z,.noFaintCheck ; no blacking out if the player lost to the rival in Oak's lab jp z,.noFaintCheck ; no blacking out if the player lost to the rival in Oak's lab
callab AnyPartyAlive callab AnyPartyAlive
ld a,d ld a,d
@ -363,15 +374,15 @@ NewBattle::
ret ret
; function to make bikes twice as fast as walking ; function to make bikes twice as fast as walking
BikeSpeedup:: DoBikeSpeedup::
ld a,[wNPCMovementScriptPointerTableNum] ld a,[wNPCMovementScriptPointerTableNum]
and a and a
ret nz ret nz
ld a,[wCurMap] ld a,[wCurMap]
cp a,ROUTE_17 ; Cycling Road cp ROUTE_17 ; Cycling Road
jr nz,.goFaster jr nz,.goFaster
ld a,[hJoyHeld] ld a,[hJoyHeld]
and a,D_UP | D_LEFT | D_RIGHT and D_UP | D_LEFT | D_RIGHT
ret nz ret nz
.goFaster .goFaster
jp AdvancePlayerSprite jp AdvancePlayerSprite
@ -421,7 +432,7 @@ CheckWarpsNoCollisionLoop::
pop bc pop bc
pop de pop de
ld a,[hJoyHeld] ld a,[hJoyHeld]
and a,D_DOWN | D_UP | D_LEFT | D_RIGHT and D_DOWN | D_UP | D_LEFT | D_RIGHT
jr z,CheckWarpsNoCollisionRetry2 ; if directional buttons aren't being pressed, do not pass through the warp jr z,CheckWarpsNoCollisionRetry2 ; if directional buttons aren't being pressed, do not pass through the warp
jr WarpFound1 jr WarpFound1
@ -483,7 +494,7 @@ WarpFound2::
ld [wUnusedD366],a ; not read ld [wUnusedD366],a ; not read
ld a,[hWarpDestinationMap] ld a,[hWarpDestinationMap]
ld [wCurMap],a ld [wCurMap],a
cp a,ROCK_TUNNEL_1 cp ROCK_TUNNEL_1
jr nz,.notRockTunnel jr nz,.notRockTunnel
ld a,$06 ld a,$06
ld [wMapPalOffset],a ld [wMapPalOffset],a
@ -491,10 +502,12 @@ WarpFound2::
.notRockTunnel .notRockTunnel
call PlayMapChangeSound call PlayMapChangeSound
jr .done jr .done
; for maps that can have the 0xFF destination map, which means to return to the outside map; not all these maps are necessarily indoors, though
; for maps that can have the 0xFF destination map, which means to return to the outside map
; not all these maps are necessarily indoors, though
.indoorMaps .indoorMaps
ld a,[hWarpDestinationMap] ; destination map ld a,[hWarpDestinationMap] ; destination map
cp a,$ff cp $ff
jr z,.goBackOutside jr z,.goBackOutside
; if not going back to the previous map ; if not going back to the previous map
ld [wCurMap],a ld [wCurMap],a
@ -535,7 +548,7 @@ ContinueCheckWarpsNoCollisionLoop::
CheckMapConnections:: CheckMapConnections::
.checkWestMap .checkWestMap
ld a,[wXCoord] ld a,[wXCoord]
cp a,$ff cp $ff
jr nz,.checkEastMap jr nz,.checkEastMap
ld a,[wMapConn3Ptr] ld a,[wMapConn3Ptr]
ld [wCurMap],a ld [wCurMap],a
@ -555,7 +568,7 @@ CheckMapConnections::
jr z,.savePointer1 jr z,.savePointer1
.pointerAdjustmentLoop1 .pointerAdjustmentLoop1
ld a,[wWestConnectedMapWidth] ; width of connected map ld a,[wWestConnectedMapWidth] ; width of connected map
add a,MAP_BORDER * 2 add MAP_BORDER * 2
ld e,a ld e,a
ld d,0 ld d,0
ld b,0 ld b,0
@ -568,6 +581,7 @@ CheckMapConnections::
ld a,h ld a,h
ld [wCurrentTileBlockMapViewPointer + 1],a ld [wCurrentTileBlockMapViewPointer + 1],a
jp .loadNewMap jp .loadNewMap
.checkEastMap .checkEastMap
ld b,a ld b,a
ld a,[wCurrentMapWidth2] ; map width ld a,[wCurrentMapWidth2] ; map width
@ -591,7 +605,7 @@ CheckMapConnections::
jr z,.savePointer2 jr z,.savePointer2
.pointerAdjustmentLoop2 .pointerAdjustmentLoop2
ld a,[wEastConnectedMapWidth] ld a,[wEastConnectedMapWidth]
add a,MAP_BORDER * 2 add MAP_BORDER * 2
ld e,a ld e,a
ld d,0 ld d,0
ld b,0 ld b,0
@ -604,9 +618,10 @@ CheckMapConnections::
ld a,h ld a,h
ld [wCurrentTileBlockMapViewPointer + 1],a ld [wCurrentTileBlockMapViewPointer + 1],a
jp .loadNewMap jp .loadNewMap
.checkNorthMap .checkNorthMap
ld a,[wYCoord] ld a,[wYCoord]
cp a,$ff cp $ff
jr nz,.checkSouthMap jr nz,.checkSouthMap
ld a,[wMapConn1Ptr] ld a,[wMapConn1Ptr]
ld [wCurMap],a ld [wCurMap],a
@ -630,6 +645,7 @@ CheckMapConnections::
ld a,h ld a,h
ld [wCurrentTileBlockMapViewPointer + 1],a ld [wCurrentTileBlockMapViewPointer + 1],a
jp .loadNewMap jp .loadNewMap
.checkSouthMap .checkSouthMap
ld b,a ld b,a
ld a,[wCurrentMapHeight2] ld a,[wCurrentMapHeight2]
@ -666,13 +682,14 @@ CheckMapConnections::
callba InitMapSprites callba InitMapSprites
call LoadTileBlockMap call LoadTileBlockMap
jp OverworldLoopLessDelay jp OverworldLoopLessDelay
.didNotEnterConnectedMap .didNotEnterConnectedMap
jp OverworldLoop jp OverworldLoop
; function to play a sound when changing maps ; function to play a sound when changing maps
PlayMapChangeSound:: PlayMapChangeSound::
aCoord 8, 8 ; upper left tile of the 4x4 square the player's sprite is standing on aCoord 8, 8 ; upper left tile of the 4x4 square the player's sprite is standing on
cp a,$0b ; door tile in tileset 0 cp $0b ; door tile in tileset 0
jr nz,.didNotGoThroughDoor jr nz,.didNotGoThroughDoor
ld a,SFX_GO_INSIDE ld a,SFX_GO_INSIDE
jr .playSound jr .playSound
@ -883,7 +900,7 @@ LoadTileBlockMap::
ld hl,wOverworldMap ld hl,wOverworldMap
ld a,[wCurMapWidth] ld a,[wCurMapWidth]
ld [hMapWidth],a ld [hMapWidth],a
add a,MAP_BORDER * 2 ; east and west add MAP_BORDER * 2 ; east and west
ld [hMapStride],a ; map width + border ld [hMapStride],a ; map width + border
ld b,0 ld b,0
ld c,a ld c,a
@ -921,7 +938,7 @@ LoadTileBlockMap::
jr nz,.rowLoop jr nz,.rowLoop
.northConnection .northConnection
ld a,[wMapConn1Ptr] ld a,[wMapConn1Ptr]
cp a,$ff cp $ff
jr z,.southConnection jr z,.southConnection
call SwitchToMapRomBank call SwitchToMapRomBank
ld a,[wNorthConnectionStripSrc] ld a,[wNorthConnectionStripSrc]
@ -939,7 +956,7 @@ LoadTileBlockMap::
call LoadNorthSouthConnectionsTileMap call LoadNorthSouthConnectionsTileMap
.southConnection .southConnection
ld a,[wMapConn2Ptr] ld a,[wMapConn2Ptr]
cp a,$ff cp $ff
jr z,.westConnection jr z,.westConnection
call SwitchToMapRomBank call SwitchToMapRomBank
ld a,[wSouthConnectionStripSrc] ld a,[wSouthConnectionStripSrc]
@ -957,7 +974,7 @@ LoadTileBlockMap::
call LoadNorthSouthConnectionsTileMap call LoadNorthSouthConnectionsTileMap
.westConnection .westConnection
ld a,[wMapConn3Ptr] ld a,[wMapConn3Ptr]
cp a,$ff cp $ff
jr z,.eastConnection jr z,.eastConnection
call SwitchToMapRomBank call SwitchToMapRomBank
ld a,[wWestConnectionStripSrc] ld a,[wWestConnectionStripSrc]
@ -975,7 +992,7 @@ LoadTileBlockMap::
call LoadEastWestConnectionsTileMap call LoadEastWestConnectionsTileMap
.eastConnection .eastConnection
ld a,[wMapConn4Ptr] ld a,[wMapConn4Ptr]
cp a,$ff cp $ff
jr z,.done jr z,.done
call SwitchToMapRomBank call SwitchToMapRomBank
ld a,[wEastConnectionStripSrc] ld a,[wEastConnectionStripSrc]
@ -1016,7 +1033,7 @@ LoadNorthSouthConnectionsTileMap::
inc h inc h
.noCarry1 .noCarry1
ld a,[wCurMapWidth] ld a,[wCurMapWidth]
add a,MAP_BORDER * 2 add MAP_BORDER * 2
add e add e
ld e,a ld e,a
jr nc,.noCarry2 jr nc,.noCarry2
@ -1045,7 +1062,7 @@ LoadEastWestConnectionsTileMap::
inc h inc h
.noCarry1 .noCarry1
ld a,[wCurMapWidth] ld a,[wCurMapWidth]
add a,MAP_BORDER * 2 add MAP_BORDER * 2
add e add e
ld e,a ld e,a
jr nc,.noCarry2 jr nc,.noCarry2
@ -1126,6 +1143,7 @@ IsSpriteInFrontOfPlayer2::
ld b,a ld b,a
ld a,PLAYER_DIR_UP ld a,PLAYER_DIR_UP
jr .doneCheckingDirection jr .doneCheckingDirection
.checkIfPlayerFacingDown .checkIfPlayerFacingDown
cp SPRITE_FACING_DOWN cp SPRITE_FACING_DOWN
jr nz,.checkIfPlayerFacingRight jr nz,.checkIfPlayerFacingRight
@ -1135,6 +1153,7 @@ IsSpriteInFrontOfPlayer2::
ld b,a ld b,a
ld a,PLAYER_DIR_DOWN ld a,PLAYER_DIR_DOWN
jr .doneCheckingDirection jr .doneCheckingDirection
.checkIfPlayerFacingRight .checkIfPlayerFacingRight
cp SPRITE_FACING_RIGHT cp SPRITE_FACING_RIGHT
jr nz,.playerFacingLeft jr nz,.playerFacingLeft
@ -1144,6 +1163,7 @@ IsSpriteInFrontOfPlayer2::
ld c,a ld c,a
ld a,PLAYER_DIR_RIGHT ld a,PLAYER_DIR_RIGHT
jr .doneCheckingDirection jr .doneCheckingDirection
.playerFacingLeft .playerFacingLeft
; facing left ; facing left
ld a,c ld a,c
@ -1225,7 +1245,7 @@ CollisionCheckOnLand::
jr nc,.noCollision jr nc,.noCollision
.collision .collision
ld a,[wChannelSoundIDs + CH4] ld a,[wChannelSoundIDs + CH4]
cp a,SFX_COLLISION ; check if collision sound is already playing cp SFX_COLLISION ; check if collision sound is already playing
jr z,.setCarry jr z,.setCarry
ld a,SFX_COLLISION ld a,SFX_COLLISION
call PlaySound ; play collision sound (if it's not already playing) call PlaySound ; play collision sound (if it's not already playing)
@ -1287,7 +1307,7 @@ CheckForTilePairCollisions::
ld a,[wCurMapTileset] ; tileset number ld a,[wCurMapTileset] ; tileset number
ld b,a ld b,a
ld a,[hli] ld a,[hli]
cp a,$ff cp $ff
jr z,.noMatch jr z,.noMatch
cp b cp b
jr z,.tilesetMatches jr z,.tilesetMatches
@ -1387,7 +1407,7 @@ LoadCurrentMapView::
; update tile block map pointer to next row's address ; update tile block map pointer to next row's address
pop de pop de
ld a,[wCurMapWidth] ld a,[wCurMapWidth]
add a,MAP_BORDER * 2 add MAP_BORDER * 2
add e add e
ld e,a ld e,a
jr nc,.noCarry jr nc,.noCarry
@ -1722,8 +1742,8 @@ ScheduleSouthRowRedraw::
ld bc,$0200 ld bc,$0200
add hl,bc add hl,bc
ld a,h ld a,h
and a,$03 and $03
or a,$98 or $98
ld [hRedrawRowOrColumnDest + 1],a ld [hRedrawRowOrColumnDest + 1],a
ld a,l ld a,l
ld [hRedrawRowOrColumnDest],a ld [hRedrawRowOrColumnDest],a
@ -1736,11 +1756,11 @@ ScheduleEastColumnRedraw::
call ScheduleColumnRedrawHelper call ScheduleColumnRedrawHelper
ld a,[wMapViewVRAMPointer] ld a,[wMapViewVRAMPointer]
ld c,a ld c,a
and a,$e0 and $e0
ld b,a ld b,a
ld a,c ld a,c
add a,18 add 18
and a,$1f and $1f
or b or b
ld [hRedrawRowOrColumnDest],a ld [hRedrawRowOrColumnDest],a
ld a,[wMapViewVRAMPointer + 1] ld a,[wMapViewVRAMPointer + 1]
@ -1791,10 +1811,10 @@ DrawTileBlock::
ld a,c ld a,c
swap a swap a
ld b,a ld b,a
and a,$f0 and $f0
ld c,a ld c,a
ld a,b ld a,b
and a,$0f and $0f
ld b,a ; bc = tile block ID * 0x10 ld b,a ; bc = tile block ID * 0x10
add hl,bc add hl,bc
ld d,h ld d,h
@ -1833,10 +1853,10 @@ JoypadOverworld::
bit 3,a ; check if a trainer wants a challenge bit 3,a ; check if a trainer wants a challenge
jr nz,.notForcedDownwards jr nz,.notForcedDownwards
ld a,[wCurMap] ld a,[wCurMap]
cp a,ROUTE_17 ; Cycling Road cp ROUTE_17 ; Cycling Road
jr nz,.notForcedDownwards jr nz,.notForcedDownwards
ld a,[hJoyHeld] ld a,[hJoyHeld]
and a,D_DOWN | D_UP | D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON and D_DOWN | D_UP | D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON
jr nz,.notForcedDownwards jr nz,.notForcedDownwards
ld a,D_DOWN ld a,D_DOWN
ld [hJoyHeld],a ; on the cycling road, if there isn't a trainer and the player isn't pressing buttons, simulate a down press ld [hJoyHeld],a ; on the cycling road, if there isn't a trainer and the player isn't pressing buttons, simulate a down press
@ -1868,6 +1888,7 @@ JoypadOverworld::
ld [hJoyPressed],a ld [hJoyPressed],a
ld [hJoyReleased],a ld [hJoyReleased],a
ret ret
; if done simulating button presses ; if done simulating button presses
.doneSimulating .doneSimulating
xor a xor a
@ -1878,7 +1899,7 @@ JoypadOverworld::
ld [hJoyHeld],a ld [hJoyHeld],a
ld hl,wd736 ld hl,wd736
ld a,[hl] ld a,[hl]
and a,$f8 and $f8
ld [hl],a ld [hl],a
ld hl,wd730 ld hl,wd730
res 7,[hl] res 7,[hl]
@ -1928,7 +1949,7 @@ CollisionCheckOnWater::
jr .loop jr .loop
.collision .collision
ld a,[wChannelSoundIDs + CH4] ld a,[wChannelSoundIDs + CH4]
cp a,SFX_COLLISION ; check if collision sound is already playing cp SFX_COLLISION ; check if collision sound is already playing
jr z,.setCarry jr z,.setCarry
ld a,SFX_COLLISION ld a,SFX_COLLISION
call PlaySound ; play collision sound (if it's not already playing) call PlaySound ; play collision sound (if it's not already playing)
@ -2386,7 +2407,7 @@ IgnoreInputForHalfSecond:
ld [wIgnoreInputCounter], a ld [wIgnoreInputCounter], a
ld hl, wd730 ld hl, wd730
ld a, [hl] ld a, [hl]
or $26 or %00100110
ld [hl], a ; set ignore input bit ld [hl], a ; set ignore input bit
ret ret

View file

@ -531,9 +531,9 @@ ReverseNybble::
ld de, NybbleReverseTable ld de, NybbleReverseTable
add e add e
ld e, a ld e, a
jr nc, .asm_283f jr nc, .noCarry
inc d inc d
.asm_283f .noCarry
ld a, [de] ld a, [de]
ret ret

View file

@ -91,79 +91,79 @@ Serial_ExchangeByte::
ld [hSerialReceivedNewData], a ld [hSerialReceivedNewData], a
ld a, [hSerialConnectionStatus] ld a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK cp USING_INTERNAL_CLOCK
jr nz, .asm_21a7 jr nz, .loop
ld a, START_TRANSFER_INTERNAL_CLOCK ld a, START_TRANSFER_INTERNAL_CLOCK
ld [rSC], a ld [rSC], a
.asm_21a7 .loop
ld a, [hSerialReceivedNewData] ld a, [hSerialReceivedNewData]
and a and a
jr nz, .asm_21f1 jr nz, .ok
ld a, [hSerialConnectionStatus] ld a, [hSerialConnectionStatus]
cp USING_EXTERNAL_CLOCK cp USING_EXTERNAL_CLOCK
jr nz, .asm_21cc jr nz, .doNotIncrementUnknownCounter
call IsUnknownCounterZero call IsUnknownCounterZero
jr z, .asm_21cc jr z, .doNotIncrementUnknownCounter
call WaitLoop_15Iterations call WaitLoop_15Iterations
push hl push hl
ld hl, wUnknownSerialCounter + 1 ld hl, wUnknownSerialCounter + 1
inc [hl] inc [hl]
jr nz, .asm_21c3 jr nz, .noCarry
dec hl dec hl
inc [hl] inc [hl]
.asm_21c3 .noCarry
pop hl pop hl
call IsUnknownCounterZero call IsUnknownCounterZero
jr nz, .asm_21a7 jr nz, .loop
jp SetUnknownCounterToFFFF jp SetUnknownCounterToFFFF
.asm_21cc .doNotIncrementUnknownCounter
ld a, [rIE] ld a, [rIE]
and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
cp (1 << SERIAL) cp (1 << SERIAL)
jr nz, .asm_21a7 jr nz, .loop
ld a, [wUnknownSerialCounter2] ld a, [wUnknownSerialCounter2]
dec a dec a
ld [wUnknownSerialCounter2], a ld [wUnknownSerialCounter2], a
jr nz, .asm_21a7 jr nz, .loop
ld a, [wUnknownSerialCounter2 + 1] ld a, [wUnknownSerialCounter2 + 1]
dec a dec a
ld [wUnknownSerialCounter2 + 1], a ld [wUnknownSerialCounter2 + 1], a
jr nz, .asm_21a7 jr nz, .loop
ld a, [hSerialConnectionStatus] ld a, [hSerialConnectionStatus]
cp USING_EXTERNAL_CLOCK cp USING_EXTERNAL_CLOCK
jr z, .asm_21f1 jr z, .ok
ld a, 255 ld a, 255
.waitLoop .waitLoop
dec a dec a
jr nz, .waitLoop jr nz, .waitLoop
.asm_21f1 .ok
xor a xor a
ld [hSerialReceivedNewData], a ld [hSerialReceivedNewData], a
ld a, [rIE] ld a, [rIE]
and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
sub (1 << SERIAL) sub (1 << SERIAL)
jr nz, .asm_2204 jr nz, .skipReloadingUnknownCounter2
ld [wUnknownSerialCounter2], a ld [wUnknownSerialCounter2], a
ld a, $50 ld a, $50
ld [wUnknownSerialCounter2 + 1], a ld [wUnknownSerialCounter2 + 1], a
.asm_2204 .skipReloadingUnknownCounter2
ld a, [hSerialReceiveData] ld a, [hSerialReceiveData]
cp SERIAL_NO_DATA_BYTE cp SERIAL_NO_DATA_BYTE
ret nz ret nz
call IsUnknownCounterZero call IsUnknownCounterZero
jr z, .asm_221f jr z, .done
push hl push hl
ld hl, wUnknownSerialCounter + 1 ld hl, wUnknownSerialCounter + 1
ld a, [hl] ld a, [hl]
dec a dec a
ld [hld], a ld [hld], a
inc a inc a
jr nz, .asm_2219 jr nz, .noBorrow
dec [hl] dec [hl]
.asm_2219 .noBorrow
pop hl pop hl
call IsUnknownCounterZero call IsUnknownCounterZero
jr z, SetUnknownCounterToFFFF jr z, SetUnknownCounterToFFFF
.asm_221f .done
ld a, [rIE] ld a, [rIE]
and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK) and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
cp (1 << SERIAL) cp (1 << SERIAL)

View file

@ -27,7 +27,7 @@ VBlank::
call VBlankCopyDouble call VBlankCopyDouble
call UpdateMovingBgTiles call UpdateMovingBgTiles
call $ff80 ; hOAMDMA call $ff80 ; hOAMDMA
ld a, Bank(PrepareOAMData) ld a, BANK(PrepareOAMData)
ld [H_LOADEDROMBANK], a ld [H_LOADEDROMBANK], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
call PrepareOAMData call PrepareOAMData

View file

@ -33,13 +33,13 @@ ClearBgMap::
jr nz,.loop jr nz,.loop
ret ret
RedrawRowOrColumn::
; This function redraws a BG row of height 2 or a BG column of width 2. ; This function redraws a BG row of height 2 or a BG column of width 2.
; One of its main uses is redrawing the row or column that will be exposed upon ; One of its main uses is redrawing the row or column that will be exposed upon
; scrolling the BG when the player takes a step. Redrawing only the exposed ; scrolling the BG when the player takes a step. Redrawing only the exposed
; row or column is more efficient than redrawing the entire screen. ; row or column is more efficient than redrawing the entire screen.
; However, this function is also called repeatedly to redraw the whole screen ; However, this function is also called repeatedly to redraw the whole screen
; when necessary. It is also used in trade animation and elevator code. ; when necessary. It is also used in trade animation and elevator code.
RedrawRowOrColumn::
ld a,[hRedrawRowOrColumnMode] ld a,[hRedrawRowOrColumnMode]
and a and a
ret z ret z