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

View file

@ -1,7 +1,7 @@
; These routines manage gradual fading
; (e.g., entering a doorway)
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 hl, FadePal4
ld a, l

View file

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

View file

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

View file

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

View file

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

View file

@ -33,13 +33,13 @@ ClearBgMap::
jr nz,.loop
ret
RedrawRowOrColumn::
; 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
; scrolling the BG when the player takes a step. Redrawing only the exposed
; row or column is more efficient than redrawing the entire 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.
RedrawRowOrColumn::
ld a,[hRedrawRowOrColumnMode]
and a
ret z