Revisit some bank 5 code before continuing.

This commit is contained in:
entrpntr
2020-04-23 13:00:01 -04:00
parent 1d456d5f66
commit 5f2d3bedb9
11 changed files with 55 additions and 66 deletions

View File

@@ -63,6 +63,7 @@ compare: $(roms)
tools:
$(MAKE) -C tools/
RGBASMFLAGS = -L -Weverything
$(gold_obj): RGBASMFLAGS += -D _GOLD
$(silver_obj): RGBASMFLAGS += -D _SILVER

View File

@@ -598,7 +598,7 @@ FlyScript:
callasm FlyToAnimation
special WaitSFX
special ReplaceChrisSprite
callasm Function1415c
callasm _RefreshSprites
end
WaterfallFunction: ; caed

View File

@@ -185,7 +185,7 @@ _PlayersHousePC:
ld b, $1
call _PlayersPC
and a
jr nz, .asm_156f9
jr nz, .asm_159d0
call OverworldTextModeSwitch
call ApplyTilemap
call UpdateSprites
@@ -193,7 +193,7 @@ _PlayersHousePC:
ld c, $0
ret
.asm_156f9
.asm_159d0
call ClearBGPalettes
ld c, $1
ret
@@ -207,28 +207,28 @@ _PlayersPC:
ld [wWhichIndexSet], a
ld hl, PlayersPCAskWhatDoText
call PC_DisplayTextWaitMenu
call Function15715
call Function159ec
call ExitMenu
ret
Function15715:
Function159ec:
xor a
ld [wPCItemsCursor], a
ld [wPCItemsScrollPosition], a
ld hl, PlayersPCMenuData
call LoadMenuHeader
.asm_15722
.asm_159f9
call UpdateTimePals
call DoNthMenu
jr c, .asm_15731
jr c, .asm_15a08
call MenuJumptable
jr nc, .asm_15722
jr .asm_15732
jr nc, .asm_159f9
jr .asm_15a09
.asm_15731
.asm_15a08
xor a
.asm_15732
.asm_15a09
call ExitMenu
ret

View File

@@ -635,7 +635,7 @@ CheckPrimarySaveFile:
ld bc, wOptionsEnd - wOptions
call CopyBytes
call CloseSRAM
call Function15011
call CheckTextDelay
ld a, TRUE
ld [wSaveFileExists], a
@@ -656,7 +656,7 @@ CheckBackupSaveFile:
ld de, wOptions
ld bc, wOptionsEnd - wOptions
call CopyBytes
call Function15011
call CheckTextDelay
ld a, $2
ld [wSaveFileExists], a
@@ -664,23 +664,21 @@ CheckBackupSaveFile:
call CloseSRAM
ret
Function15011:
CheckTextDelay:
; Fix options if text delay is invalid
ld hl, wTextboxFlags
res 1, [hl]
res NO_TEXT_DELAY_F, [hl]
ld a, [wOptions]
and 7
cp 1
and TEXT_DELAY_MASK
cp TEXT_DELAY_FAST
ret z
cp 3
cp TEXT_DELAY_MED
ret z
cp 5
cp TEXT_DELAY_SLOW
ret z
ld a, [wOptions]
and $f8
or 3
and $ff ^ TEXT_DELAY_MASK
or (1 << FAST_TEXT_DELAY_F) | (1 << NO_TEXT_DELAY_F)
ld [wOptions], a
ret

View File

@@ -7,7 +7,7 @@ _ReplaceChrisSprite::
call GetUsedSprite
ret
Function1414b::
_ClearSprites::
ld hl, wSpriteFlags
ld a, [hl]
push af
@@ -18,7 +18,7 @@ Function1414b::
ld [wSpriteFlags], a
ret
Function1415c::
_RefreshSprites::
ld hl, wSpriteFlags
ld a, [hl]
push af
@@ -119,55 +119,45 @@ AddOutdoorSprites:
dec c
jr nz, .loop
ld a, [wd05a]
ld a, [wUnusedD05A]
ld c, a
ret
AddSpriteGFX:
and a
ret z
ld c, a
call _DoesSpriteHaveFacings
jr nc, .nope
ld de, wUsedSprites + (SPRITE_GFX_LIST_CAPACITY - 2) * 2
ld b, 2
call Function14212
call .Loop
jr nc, .ok
.nope:
.nope
ld de, wUsedSprites + 2
ld b, SPRITE_GFX_LIST_CAPACITY - 3
call Function14212
call .Loop
jr .ok
.ok:
ret
Function14212:
.loop
.Loop:
ld a, [de]
and a
jr z, .new
cp c
jr z, .exists
inc de
inc de
dec b
jr nz, .loop
jr nz, .Loop
scf
ret
.new:
ld a, c
ld [de], a
xor a
ret
.exists:
xor a
ret
@@ -178,7 +168,7 @@ LoadUsedSpritesGFX:
call GetUsedSprites
ret c
call Function14265
call _LoadMiscTiles
call LoadMiscTiles
ret
@@ -186,7 +176,7 @@ GetUsedSprites:
xor a
ldh [hUsedSpriteTile], a
ld hl, wUsedSprites
ld a, $a
ld a, SPRITE_GFX_LIST_CAPACITY - 2
.loop
push af
@@ -223,7 +213,7 @@ GetUsedSprites:
scf
ret
Function14265:
_LoadMiscTiles:
ld a, [wUsedSprites + (SPRITE_GFX_LIST_CAPACITY - 2) * 2]
and a
jr z, .asm_14274
@@ -443,7 +433,7 @@ endr
.done:
ret
Function1438a:
Unreferenced_Function1438a:
ld a, c
jr GetUsedSprite
@@ -452,7 +442,7 @@ Function1438a:
jr GetUsedSprite
ld a, c
ld b, 12
ld b, SPRITE_GFX_LIST_CAPACITY
jr GetUsedSprite
GetUsedSprite:

View File

@@ -74,11 +74,11 @@ StageRTCTimeForSave:
ret
SaveRTC:
ld a, $a
ld a, SRAM_ENABLE
ld [MBC3SRamEnable], a
call LatchClock
ld hl, MBC3RTC
ld a, $c
ld a, RTC_DH
ld [MBC3SRamBank], a
res 7, [hl]
ld a, BANK(sRTCStatusFlags)
@@ -89,9 +89,9 @@ SaveRTC:
ret
StartClock::
call Function140b1
call _GetClock
call GetClock
call Function1409e
call _FixDays
call FixDays
jr nc, .skip_set
; bit 5: Day count exceeds 139
@@ -102,7 +102,7 @@ StartClock::
call StartRTC
ret
Function1409e:
_FixDays:
ld hl, hRTCDayHi
bit 7, [hl]
jr nz, .set_bit_7
@@ -117,25 +117,25 @@ Function1409e:
call RecordRTCStatus ; set bit 7 on sRTCStatusFlags
ret
Function140b1:
ld a, $a
_GetClock:
ld a, SRAM_ENABLE
ld [MBC3SRamEnable], a
call LatchClock
ld a, $c
ld a, RTC_DH
ld [MBC3SRamBank], a
ld a, [MBC3RTC]
push af
call CloseSRAM
pop af
bit 6, a
bit 6, a ; halt
ret z
ld a, BANK(sRTCStatusFlags)
call OpenSRAM
ld a, $34
ld [s0_b7ef], a
ld [sUnusedRTCMinutes], a
ld a, $12
ld [s0_b7f0], a
ld [sUnusedRTCHours], a
call CloseSRAM
ret

View File

@@ -2320,7 +2320,7 @@ ReturnToMapWithSpeechTextbox::
ReloadTilesetAndPalettes::
call DisableLCD
call ClearSprites
farcall Function1414b
farcall _ClearSprites
call LoadStandardFont
call LoadFontsExtra
ldh a, [hROMBank]

View File

@@ -36,7 +36,7 @@ CloseText::
call SafeUpdateSprites
ld a, $90
ldh [hWY], a
farcall Function1415c
farcall _RefreshSprites
call ReplaceChrisSprite
ld hl, wEnteredMapFromContinue
res 7, [hl]

View File

@@ -96,8 +96,8 @@ sBackupPlayerData1:: ds wPlayerData1End - wPlayerData
SECTION "SRAM Stack", SRAM
sStackTop:: dw
s0_b7ef:: db
s0_b7f0:: db
sUnusedRTCMinutes:: db
sUnusedRTCHours:: db
SECTION "SRAM Window Stack", SRAM

View File

@@ -2,10 +2,10 @@ Function1704d:
ld hl, UnknownGFX17079
ld de, vTiles2 tile $20
ld a, BANK(UnknownGFX17079)
ld bc, $78
ld bc, wBGMapBufferEnd - wBGMapBuffer
call FarCopyBytesDouble
ld hl, vTiles2 tile $20
ld bc, $78
ld bc, wBGMapBufferEnd - wBGMapBuffer
.loop:
ld [hl], $ff
inc hl
@@ -20,7 +20,7 @@ Function1706b:
ld hl, UnknownGFX170f1
ld de, vTiles2 tile $2f
ld a, BANK(UnknownGFX170f1)
ld bc, $e0
ld bc, 14 tiles
jp FarCopyBytes
UnknownGFX17079:

View File

@@ -2295,7 +2295,7 @@ wd056:: ds 1 ; d056
wd057:: ds 1 ; d057
wd058:: ds 1 ; d058
wd059:: ds 1 ; d059
wd05a:: ds 1 ; d05a
wUnusedD05A:: db ; unused
wBGMapAnchor:: dw ; d05b