Remove RTC (#1) and remove time of day dependence on RTC (#7) [Commit 1]

This commit is contained in:
xCrystal 2023-07-27 20:32:15 +02:00
parent 59bda0b36b
commit 0571144a7b
32 changed files with 40 additions and 2276 deletions

View File

@ -14,8 +14,6 @@
; wMomSavingMoney
const ENGINE_MOM_SAVING_MONEY
const ENGINE_MOM_ACTIVE
; wUnusedTwoDayTimerOn
const ENGINE_UNUSED_TWO_DAY_TIMER_ON
; wStatusFlags
const ENGINE_POKEDEX
const ENGINE_UNOWN_DEX

View File

@ -23,8 +23,6 @@ EngineFlags:
engine_flag wMomSavingMoney, MOM_SAVING_SOME_MONEY_F
engine_flag wMomSavingMoney, MOM_ACTIVE_F
engine_flag wUnusedTwoDayTimerOn, 0 ; unused, possibly related to a 2-day timer
engine_flag wStatusFlags, STATUSFLAGS_POKEDEX_F
engine_flag wStatusFlags, STATUSFLAGS_UNOWN_DEX_F
engine_flag wStatusFlags, STATUSFLAGS_CAUGHT_POKERUS_F

View File

@ -45,7 +45,6 @@ SpecialsPointers::
add_special BankOfMom
add_special MagnetTrain
add_special NameRival
add_special SetDayOfWeek
add_special OverworldTownMap
add_special UnownPrinter
add_special MapRadio
@ -76,7 +75,6 @@ SpecialsPointers::
add_special FindPartyMonAtLeastThatHappy ; unused
add_special FindPartyMonThatSpecies
add_special FindPartyMonThatSpeciesYourTrainerID
add_special UnusedCheckUnusedTwoDayTimer ; unused
add_special DayCareMon1
add_special DayCareMon2
add_special SelectRandomBugContestContestants
@ -136,7 +134,3 @@ SpecialsPointers::
add_special RefreshSprites
add_special AskRememberPassword
add_special LoadMapPalettes
add_special InitialSetDSTFlag
add_special InitialClearDSTFlag
add_special UnusedDummySpecial ; unused

View File

@ -1231,42 +1231,3 @@ _TimeAskOkayText::
text ","
line "is that OK?"
done
_TimesetAskDSTText::
text "Do you want to"
line "switch to Daylight"
cont "Saving Time?"
done
_TimesetDSTText::
text "I set the clock"
line "forward by one"
cont "hour."
prompt
_TimesetAskNotDSTText::
text "Is Daylight Saving"
line "Time over?"
done
_TimesetNotDSTText::
text "I put the clock"
line "back one hour."
prompt
_TimesetAskAdjustDSTText::
text "Do you want to"
line "adjust your clock"
para "for Daylight"
line "Saving Time?"
done
_MomLostGearBookletText::
text "I lost the in-"
line "struction booklet"
cont "for the #GEAR."
para "Come back again in"
line "a while."
prompt

View File

@ -77,7 +77,6 @@ BankOfMom:
jr .done_2
.nope
call DSTChecks
ld a, $7
.done_2
@ -281,128 +280,6 @@ BankOfMom:
set 7, [hl]
ret
DSTChecks:
; check the time; avoid changing DST if doing so would change the current day
ld a, [wDST]
bit 7, a
ldh a, [hHours]
jr z, .NotDST
and a ; within one hour of 00:00?
jr z, .LostBooklet
jr .loop
.NotDST:
cp 23 ; within one hour of 23:00?
jr nz, .loop
; fallthrough
.LostBooklet:
call .ClearBox
bccoord 1, 14
ld hl, .TimesetAskAdjustDSTText
call PlaceHLTextAtBC
call YesNoBox
ret c
call .ClearBox
bccoord 1, 14
ld hl, .MomLostGearBookletText
call PlaceHLTextAtBC
ret
.loop
call .ClearBox
bccoord 1, 14
ld a, [wDST]
bit 7, a
jr z, .SetDST
ld hl, .TimesetAskNotDSTText
call PlaceHLTextAtBC
call YesNoBox
ret c
ld a, [wDST]
res 7, a
ld [wDST], a
call .SetClockBack
call .ClearBox
bccoord 1, 14
ld hl, .TimesetNotDSTText
call PlaceHLTextAtBC
ret
.SetDST:
ld hl, .TimesetAskDSTText
call PlaceHLTextAtBC
call YesNoBox
ret c
ld a, [wDST]
set 7, a
ld [wDST], a
call .SetClockForward
call .ClearBox
bccoord 1, 14
ld hl, .TimesetDSTText
call PlaceHLTextAtBC
ret
.SetClockForward:
ld a, [wStartHour]
add 1
sub 24
jr nc, .DontLoopHourForward
add 24
.DontLoopHourForward:
ld [wStartHour], a
ccf
ld a, [wStartDay]
adc 0
ld [wStartDay], a
ret
.SetClockBack:
ld a, [wStartHour]
sub 1
jr nc, .DontLoopHourBack
add 24
.DontLoopHourBack:
ld [wStartHour], a
ld a, [wStartDay]
sbc 0
jr nc, .DontLoopDayBack
add 7
.DontLoopDayBack:
ld [wStartDay], a
ret
.ClearBox:
hlcoord 1, 14
lb bc, 3, 18
call ClearBox
ret
.TimesetAskAdjustDSTText:
text_far _TimesetAskAdjustDSTText
text_end
.MomLostGearBookletText:
text_far _MomLostGearBookletText
text_end
.TimesetAskDSTText:
text_far _TimesetAskDSTText
text_end
.TimesetDSTText:
text_far _TimesetDSTText
text_end
.TimesetAskNotDSTText:
text_far _TimesetAskNotDSTText
text_end
.TimesetNotDSTText:
text_far _TimesetNotDSTText
text_end
Mom_SetUpWithdrawMenu:
ld de, Mon_WithdrawString
jr Mom_ContinueMenuSetup

View File

@ -15,9 +15,6 @@ Special::
INCLUDE "data/events/special_pointers.asm"
UnusedDummySpecial:
ret
SetPlayerPalette:
ld a, [wScriptVar]
ld d, a
@ -231,12 +228,6 @@ ScriptReturnCarry:
ld [wScriptVar], a
ret
UnusedCheckUnusedTwoDayTimer:
farcall CheckUnusedTwoDayTimer
ld a, [wUnusedTwoDayTimer]
ld [wScriptVar], a
ret
ActivateFishingSwarm:
ld a, [wScriptVar]
ld [wFishingSwarmFlag], a

View File

@ -243,7 +243,7 @@ LinkTradeMenu:
ret
.loop2
call UpdateTimeAndPals
call UpdateTimeSensitivePals
call .TryAnims
ret c
ld a, [w2DMenuFlags1]

View File

@ -75,12 +75,6 @@ AreYouABoyOrAreYouAGirl:
farcall InitGender
ret
if DEF(_DEBUG)
DebugRoom: ; unreferenced
farcall _DebugRoom
ret
endc
ResetWRAM:
xor a
ldh [hBGMapMode], a
@ -322,17 +316,11 @@ Continue:
ld c, 20
call DelayFrames
call ConfirmContinue
jr nc, .Check1Pass
jr nc, .CheckPass
call CloseWindow
jr .FailToLoad
.Check1Pass:
call Continue_CheckRTC_RestartClock
jr nc, .Check2Pass
call CloseWindow
jr .FailToLoad
.Check2Pass:
.CheckPass:
ld a, $8
ld [wMusicFade], a
ld a, LOW(MUSIC_NONE)
@ -345,7 +333,6 @@ Continue:
ld c, 20
call DelayFrames
farcall JumpRoamMons
farcall ClockContinue
ld a, [wSpawnAfterChampion]
cp SPAWN_LEVEL_1
jr z, .SpawnAfterE4
@ -388,21 +375,6 @@ ConfirmContinue:
.PressA:
ret
Continue_CheckRTC_RestartClock:
call CheckRTCStatus
and %10000000 ; Day count exceeded 16383
jr z, .pass
farcall RestartClock
ld a, c
and a
jr z, .pass
scf
ret
.pass
xor a
ret
FinishContinueFunction:
.loop
xor a
@ -424,14 +396,6 @@ FinishContinueFunction:
jr .loop
DisplaySaveInfoOnContinue:
call CheckRTCStatus
and %10000000
jr z, .clock_ok
lb de, 4, 8
call DisplayContinueDataWithRTCError
ret
.clock_ok
lb de, 4, 8
call DisplayNormalContinueData
ret
@ -448,14 +412,6 @@ DisplayNormalContinueData:
call UpdateSprites
ret
DisplayContinueDataWithRTCError:
call Continue_LoadMenuHeader
call Continue_DisplayBadgesDexPlayerName
call Continue_UnknownGameTime
call LoadFontsExtra
call UpdateSprites
ret
Continue_LoadMenuHeader:
xor a
ldh [hBGMapMode], a
@ -528,16 +484,6 @@ Continue_PrintGameTime:
call Continue_DisplayGameTime
ret
Continue_UnknownGameTime:
decoord 9, 8, 0
add hl, de
ld de, .three_question_marks
call PlaceString
ret
.three_question_marks
db " ???@"
Continue_DisplayBadgeCount:
push hl
ld hl, wJohtoBadges
@ -576,7 +522,6 @@ Continue_DisplayGameTime:
jp PrintNum
OakSpeech:
farcall InitClock
call RotateFourPalettesLeft
call ClearTilemap
@ -909,7 +854,6 @@ Intro_PlacePlayerSprite:
const TITLESCREENOPTION_DELETE_SAVE_DATA
const TITLESCREENOPTION_RESTART
const TITLESCREENOPTION_UNUSED
const TITLESCREENOPTION_RESET_CLOCK
DEF NUM_TITLESCREENOPTIONS EQU const_value
IntroSequence:
@ -972,7 +916,6 @@ StartTitleScreen:
dw DeleteSaveData
dw IntroSequence
dw IntroSequence
dw ResetClock
.TitleScreen:
farcall _TitleScreen
@ -1109,38 +1052,7 @@ TitleScreenMain:
cp D_UP + B_BUTTON + SELECT
jr z, .delete_save_data
; To bring up the clock reset dialog:
; Hold Down + B + Select to initiate the sequence.
ldh a, [hClockResetTrigger]
cp $34
jr z, .check_clock_reset
ld a, [hl]
and D_DOWN + B_BUTTON + SELECT
cp D_DOWN + B_BUTTON + SELECT
jr nz, .check_start
ld a, $34
ldh [hClockResetTrigger], a
jr .check_start
; Keep Select pressed, and hold Left + Up.
; Then let go of Select.
.check_clock_reset
bit SELECT_F, [hl]
jr nz, .check_start
xor a
ldh [hClockResetTrigger], a
ld a, [hl]
and D_LEFT + D_UP
cp D_LEFT + D_UP
jr z, .reset_clock
; Press Start or A to start the game.
.check_start
ld a, [hl]
and START | A_BUTTON
jr nz, .incave
@ -1177,15 +1089,6 @@ TitleScreenMain:
inc [hl]
ret
.reset_clock
ld a, TITLESCREENOPTION_RESET_CLOCK
ld [wTitleScreenSelectedOption], a
; Return to the intro sequence.
ld hl, wJumptableIndex
set 7, [hl]
ret
TitleScreenEnd:
; Wait until the music is done fading.
@ -1208,61 +1111,6 @@ DeleteSaveData:
farcall _DeleteSaveData
jp Init
ResetClock:
farcall _ResetClock
jp Init
UpdateTitleTrailSprite: ; unreferenced
; If bit 0 or 1 of [wTitleScreenTimer] is set, we don't need to be here.
ld a, [wTitleScreenTimer]
and %00000011
ret nz
ld bc, wSpriteAnim10
ld hl, SPRITEANIMSTRUCT_FRAME
add hl, bc
ld l, [hl]
ld h, 0
add hl, hl
add hl, hl
ld de, .TitleTrailCoords
add hl, de
; If bit 2 of [wTitleScreenTimer] is set, get the second coords; else, get the first coords
ld a, [wTitleScreenTimer]
and %00000100
srl a
srl a
ld e, a
ld d, 0
add hl, de
add hl, de
ld a, [hli]
and a
ret z
ld e, a
ld d, [hl]
ld a, SPRITE_ANIM_INDEX_GS_TITLE_TRAIL
call InitSpriteAnimStruct
ret
.TitleTrailCoords:
MACRO trail_coords
rept _NARG / 2
DEF _dx = 4
if \1 == 0 && \2 == 0
DEF _dx = 0
endc
dbpixel \1, \2, _dx, 0
shift 2
endr
ENDM
; frame 0 y, x; frame 1 y, x
trail_coords 11, 10, 0, 0
trail_coords 11, 13, 11, 11
trail_coords 11, 13, 11, 15
trail_coords 11, 17, 11, 15
trail_coords 0, 0, 11, 15
trail_coords 0, 0, 11, 11
Copyright:
call ClearTilemap
call LoadFontsExtra

View File

@ -55,9 +55,6 @@ MainMenu:
db "CONTINUE@"
db "NEW GAME@"
db "OPTION@"
db "MYSTERY GIFT@"
db "MOBILE@"
db "MOBILE STUDIUM@"
if DEF(_DEBUG)
db "DEBUG ROOM@"
endc
@ -147,58 +144,26 @@ MainMenu_PrintCurrentTimeAndDay:
ret
.PlaceBox:
call CheckRTCStatus
and %10000000 ; Day count exceeded 16383
jr nz, .TimeFail
hlcoord 0, 14
ld b, 2
ld c, 18
call Textbox
ret
.TimeFail:
call SpeechTextbox
ret
.PlaceTime:
ld a, [wSaveFileExists]
and a
ret z
call CheckRTCStatus
and $80
jp nz, .PrintTimeNotSet
call UpdateTime
call GetWeekday
ld b, a
decoord 1, 15
call .PrintDayOfWeek
ld a, [wTimeOfDay]
maskbits NUM_DAYTIMES
decoord 4, 16
ldh a, [hHours]
ld c, a
farcall PrintHour
ld [hl], ":"
inc hl
ld de, hMinutes
lb bc, PRINTNUM_LEADINGZEROS | 1, 2
call PrintNum
call .PrintTimeOfDay
ret
.minString: ; unreferenced
db "min.@"
.PrintTimeNotSet:
hlcoord 1, 14
ld de, .TimeNotSetString
call PlaceString
ret
.TimeNotSetString:
db "TIME NOT SET@"
.MainMenuTimeUnknownText: ; unreferenced
text_far _MainMenuTimeUnknownText
text_end
.PrintDayOfWeek:
push de
ld hl, .Days
@ -225,6 +190,22 @@ MainMenu_PrintCurrentTimeAndDay:
.Day:
db "DAY@"
.PrintTimeOfDay:
push de
ld hl, .TimesOfDay
call GetNthString
ld d, h
ld e, l
pop hl
call PlaceString
ret
.TimesOfDay:
db "MORN@"
db "DAY@"
db "NITE@"
db "NITE@"
ClearTilemapEtc:
xor a
ldh [hMapAnims], a
@ -245,3 +226,9 @@ MainMenu_Option:
MainMenu_Continue:
farcall Continue
ret
if DEF(_DEBUG)
MainMenu_DebugRoom:
farcall _DebugRoom
ret
endc

View File

@ -263,7 +263,7 @@ MenuJoypadLoop:
Do2DMenuRTCJoypad:
.loopRTC
call UpdateTimeAndPals
call UpdateTimeSensitivePals
call Menu_WasButtonPressed
ret c
ld a, [w2DMenuFlags1]

View File

@ -25,13 +25,11 @@ SaveMenu:
SaveAfterLinkTrade:
call PauseGameLogic
farcall StageRTCTimeForSave
call SavePokemonData
call SaveChecksum
call SaveBackupPokemonData
call SaveBackupChecksum
farcall BackupPartyMonMail
farcall SaveRTC
call ResumeGameLogic
ret
@ -90,7 +88,6 @@ MoveMonWOMail_InsertMon_SaveGame:
ld [wCurBox], a
ld a, TRUE
ld [wSaveFileExists], a
farcall StageRTCTimeForSave
call ValidateSave
call SaveOptions
call SavePlayerData
@ -102,7 +99,6 @@ MoveMonWOMail_InsertMon_SaveGame:
call SaveBackupPokemonData
call SaveBackupChecksum
farcall BackupPartyMonMail
farcall SaveRTC
call LoadBox
call ResumeGameLogic
ld de, SFX_SAVE
@ -263,7 +259,6 @@ SavedTheGame:
_SaveGameData:
ld a, TRUE
ld [wSaveFileExists], a
farcall StageRTCTimeForSave
call ValidateSave
call SaveOptions
call SavePlayerData
@ -277,7 +272,6 @@ _SaveGameData:
call SaveBackupChecksum
call UpdateStackTop
farcall BackupPartyMonMail
farcall SaveRTC
ret
UpdateStackTop:
@ -593,7 +587,6 @@ TryLoadSaveData:
ld de, wOptions
ld bc, wOptionsEnd - wOptions
call CopyBytes
call ClearClock
ret
INCLUDE "data/default_options.asm"

View File

@ -19,7 +19,6 @@ TrainerCard:
set NO_TEXT_SCROLL, [hl]
call .InitRAM
.loop
call UpdateTime
call JoyTextDelay
ld a, [wJumptableIndex]
bit 7, a

View File

@ -195,7 +195,6 @@ HandleMapTimeAndJoypad:
cp MAPEVENTS_OFF
ret z
call UpdateTime
call GetJoypad
call TimeOfDayPals
ret
@ -469,11 +468,6 @@ CheckTimeEvents:
scf
ret
.unused ; unreferenced
ld a, $8 ; ???
scf
ret
OWPlayerInput:
call PlayerMovement
ret c

View File

@ -5,7 +5,6 @@ _InitializeStartDay:
ClearDailyTimers:
xor a
ld [wLuckyNumberDayTimer], a
ld [wUnusedTwoDayTimer], a
ld [wDailyResetTimer], a
ret
@ -63,10 +62,7 @@ InitOneDayCountdown:
InitNDaysCountdown:
ld [hl], a
push hl
call UpdateTime
pop hl
inc hl
inc hl ; wLuckyNumberDayTimer + 1 or wDailyResetTimer + 1 (both are dw)
call CopyDayToHL
ret
@ -83,7 +79,6 @@ CheckDayDependentEventHL:
RestartReceiveCallDelay:
ld hl, wReceiveCallDelay_MinsRemaining
ld [hl], a
call UpdateTime
ld hl, wReceiveCallDelay_StartTime
call CopyDayHourMinToHL
ret
@ -134,7 +129,6 @@ StartBugContestTimer:
ld [wBugContestMinsRemaining], a
ld a, BUG_CONTEST_SECONDS
ld [wBugContestSecsRemaining], a
call UpdateTime
ld hl, wBugContestStartTime
call CopyDayHourMinSecToHL
ret
@ -174,7 +168,6 @@ CheckBugContestTimer::
ret
InitializeStartDay:
call UpdateTime
ld hl, wTimerEventStartDay
call CopyDayToHL
ret
@ -191,36 +184,6 @@ CheckPokerusTick::
xor a
ret
SetUnusedTwoDayTimer: ; unreferenced
ld a, 2
ld hl, wUnusedTwoDayTimer
ld [hl], a
call UpdateTime
ld hl, wUnusedTwoDayTimerStartDate
call CopyDayToHL
ret
CheckUnusedTwoDayTimer:
ld hl, wUnusedTwoDayTimerStartDate
call CalcDaysSince
call GetDaysSince
ld hl, wUnusedTwoDayTimer
call UpdateTimeRemaining
ret
UnusedSetSwarmFlag: ; unreferenced
ld hl, wDailyFlags1
set DAILYFLAGS1_FISH_SWARM_F, [hl]
ret
UnusedCheckSwarmFlag: ; unreferenced
and a
ld hl, wDailyFlags1
bit DAILYFLAGS1_FISH_SWARM_F, [hl]
ret nz
scf
ret
RestartLuckyNumberCountdown:
call .GetDaysUntilNextFriday
ld hl, wLuckyNumberDayTimer
@ -382,13 +345,6 @@ CopyDayToHL:
ld [hl], a
ret
CopyDayHourToHL: ; unreferenced
ld a, [wCurDay]
ld [hli], a
ldh a, [hHours]
ld [hli], a
ret
CopyDayHourMinToHL:
ld a, [wCurDay]
ld [hli], a

View File

@ -1,19 +1,3 @@
LoadSGBPokedexGFX:
ld hl, SGBPokedexGFX_LZ
ld de, vTiles2 tile $31
call Decompress
ret
LoadSGBPokedexGFX2:
ld hl, SGBPokedexGFX_LZ
ld de, vTiles2 tile $31
lb bc, BANK(SGBPokedexGFX_LZ), 58
call DecompressRequest2bpp
ret
SGBPokedexGFX_LZ:
INCBIN "gfx/pokedex/pokedex_sgb.2bpp.lz"
LoadQuestionMarkPic:
ld hl, .QuestionMarkLZ
ld de, sScratch

View File

@ -40,7 +40,6 @@ PokeGear:
call .InitTilemap
call DelayFrame
.loop
call UpdateTime
call JoyTextDelay
ld a, [wJumptableIndex]
bit 7, a
@ -276,7 +275,6 @@ InitPokegearTilemap:
hlcoord 0, 12
lb bc, 4, 18
call Textbox
call Pokegear_UpdateClock
ret
.switch
@ -409,7 +407,6 @@ PokegearClock_Init:
ret
PokegearClock_Joypad:
call .UpdateClock
ld hl, hJoyLast
ld a, [hl]
and A_BUTTON | B_BUTTON | START | SELECT
@ -447,36 +444,6 @@ PokegearClock_Joypad:
set 7, [hl]
ret
.UpdateClock:
xor a
ldh [hBGMapMode], a
call Pokegear_UpdateClock
ld a, $1
ldh [hBGMapMode], a
ret
Pokegear_UpdateClock:
hlcoord 3, 5
lb bc, 5, 14
call ClearBox
ldh a, [hHours]
ld b, a
ldh a, [hMinutes]
ld c, a
decoord 6, 8
farcall PrintHoursMins
ld hl, .GearTodayText
bccoord 6, 6
call PlaceHLTextAtBC
ret
db "ごぜん@"
db "ごご@"
.GearTodayText:
text_far _GearTodayText
text_end
PokegearMap_CheckRegion:
ld a, POKEGEARSTATE_JOHTOMAPINIT
ld [wJumptableIndex], a
@ -1849,7 +1816,6 @@ PlayRadioStationPointers:
assert_table_length NUM_MAP_RADIO_STATIONS
LoadStation_PokemonChannel:
call UpdateTime
ld a, [wTimeOfDay]
and a
jp z, LoadStation_PokedexShow

View File

@ -1701,9 +1701,9 @@ BuenasPassword21:
jp NextRadioLine
BuenasPasswordCheckTime:
call UpdateTime
ldh a, [hHours]
cp NITE_HOUR
ld a, [wTimeOfDay]
maskbits NUM_DAYTIMES
cp NITE
ret
BuenasPasswordChannelName:

View File

@ -1,65 +0,0 @@
PrintFiveDigitNumber: ; unreferenced
; Debug function?
; Input: bc = value, de = destination
ld a, b
ld b, c
ld c, a
push bc ; de points to this on the stack for PrintNum
push de
ld hl, sp+2
ld d, h
ld e, l
pop hl
lb bc, PRINTNUM_LEADINGZEROS | 2, 5
call PrintNum
pop bc
ret
PrintHoursMins:
; Hours in b, minutes in c
ld a, b
cp 12
push af
jr c, .AM
jr z, .PM
sub 12
jr .PM
.AM:
or a
jr nz, .PM
ld a, 12
.PM:
ld b, a
; Crazy stuff happening with the stack
push bc
ld hl, sp+1
push de
push hl
pop de
pop hl
ld [hl], " "
lb bc, 1, 2
call PrintNum
ld [hl], ":"
inc hl
ld d, h
ld e, l
ld hl, sp+0
push de
push hl
pop de
pop hl
lb bc, PRINTNUM_LEADINGZEROS | 1, 2
call PrintNum
pop bc
ld de, String_AM
pop af
jr c, .place_am_pm
ld de, String_PM
.place_am_pm
inc hl
call PlaceString
ret
String_AM: db "AM@"
String_PM: db "PM@"

View File

@ -1,255 +0,0 @@
_ResetClock:
farcall BlankScreen
ld b, CGB_DIPLOMA
call GetCGBLayout
call LoadStandardFont
call LoadFontsExtra
ld de, MUSIC_MAIN_MENU
call PlayMusic
ld hl, .PasswordAskResetClockText
call PrintText
ld hl, .NoYes_MenuHeader
call CopyMenuHeader
call VerticalMenu
ret c
ld a, [wMenuCursorY]
cp 1
ret z
call ClockResetPassword
jr c, .wrongpassword
ld a, BANK(sRTCStatusFlags)
call OpenSRAM
ld a, $80
ld [sRTCStatusFlags], a
call CloseSRAM
ld hl, .PasswordAskResetText
call PrintText
ret
.wrongpassword
ld hl, .PasswordWrongText
call PrintText
ret
.PasswordAskResetText:
text_far _PasswordAskResetText
text_end
.PasswordWrongText:
text_far _PasswordWrongText
text_end
.PasswordAskResetClockText:
text_far _PasswordAskResetClockText
text_end
.NoYes_MenuHeader:
db 0 ; flags
menu_coords 14, 7, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .NoYes_MenuData
db 1 ; default option
.NoYes_MenuData:
db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 2 ; items
db "NO@"
db "YES@"
ClockResetPassword:
call .CalculatePassword
push de
ld hl, wStringBuffer2
ld bc, 5
xor a
call ByteFill
ld a, 4
ld [wStringBuffer2 + 5], a
ld hl, .PasswordAskEnterText
call PrintText
.loop
call .updateIDdisplay
.loop2
call JoyTextDelay
ldh a, [hJoyLast]
ld b, a
and A_BUTTON
jr nz, .confirm
ld a, b
and D_PAD
jr z, .loop2
call .dpadinput
ld c, 3
call DelayFrames
jr .loop
.confirm
call .ConvertDecIDToBytes
pop de
ld a, e
cp l
jr nz, .nope
ld a, d
cp h
jr nz, .nope
and a
ret
.nope
scf
ret
.PasswordAskEnterText:
text_far _PasswordAskEnterText
text_end
.updateIDdisplay
hlcoord 14, 15
ld de, wStringBuffer2
ld c, 5
.loop3
ld a, [de]
add "0"
ld [hli], a
inc de
dec c
jr nz, .loop3
hlcoord 14, 16
ld bc, 5
ld a, " "
call ByteFill
hlcoord 14, 16
ld a, [wStringBuffer2 + 5]
ld e, a
ld d, 0
add hl, de
ld [hl], "▲"
ret
.dpadinput
ld a, b
and D_LEFT
jr nz, .left
ld a, b
and D_RIGHT
jr nz, .right
ld a, b
and D_UP
jr nz, .up
ld a, b
and D_DOWN
jr nz, .down
ret
.left
ld a, [wStringBuffer2 + 5]
and a
ret z
dec a
ld [wStringBuffer2 + 5], a
ret
.right
ld a, [wStringBuffer2 + 5]
cp 4
ret z
inc a
ld [wStringBuffer2 + 5], a
ret
.up
call .getcurrentdigit
ld a, [hl]
cp 9
jr z, .wraparound_up
inc a
ld [hl], a
ret
.wraparound_up
ld [hl], 0
ret
.down
call .getcurrentdigit
ld a, [hl]
and a
jr z, .wraparound_down
dec a
ld [hl], a
ret
.wraparound_down
ld [hl], 9
ret
.getcurrentdigit
ld a, [wStringBuffer2 + 5]
ld e, a
ld d, 0
ld hl, wStringBuffer2
add hl, de
ret
.ConvertDecIDToBytes:
ld hl, 0
ld de, wStringBuffer2 + 4
ld bc, 1
call .ConvertToBytes
ld bc, 10
call .ConvertToBytes
ld bc, 100
call .ConvertToBytes
ld bc, 1000
call .ConvertToBytes
ld bc, 10000
.ConvertToBytes:
ld a, [de]
dec de
push hl
ld hl, 0
call AddNTimes
ld c, l
ld b, h
pop hl
add hl, bc
ret
.CalculatePassword:
ld a, BANK(sPlayerData)
call OpenSRAM
ld de, 0
ld hl, sPlayerData + (wPlayerID - wPlayerData)
ld c, 2
call .ComponentFromNumber
ld hl, sPlayerData + (wPlayerName - wPlayerData)
ld c, NAME_LENGTH_JAPANESE - 1
call .ComponentFromString
ld hl, sPlayerData + (wMoney - wPlayerData)
ld c, 3
call .ComponentFromNumber
call CloseSRAM
ret
.ComponentFromNumber:
ld a, [hli]
add e
ld e, a
ld a, 0
adc d
ld d, a
dec c
jr nz, .ComponentFromNumber
ret
.ComponentFromString:
ld a, [hli]
cp "@"
ret z
add e
ld e, a
ld a, 0
adc d
ld d, a
dec c
jr nz, .ComponentFromString
ret

View File

@ -1,241 +0,0 @@
; RestartClock_GetWraparoundTime.WrapAroundTimes indexes
const_def 1
const RESTART_CLOCK_DAY
const RESTART_CLOCK_HOUR
const RESTART_CLOCK_MIN
DEF NUM_RESTART_CLOCK_DIVISIONS EQU const_value - 1
RestartClock_GetWraparoundTime:
push hl
dec a
ld e, a
ld d, 0
ld hl, .WrapAroundTimes
rept 4
add hl, de
endr
ld e, [hl]
inc hl
ld d, [hl]
inc hl
ld b, [hl]
inc hl
ld c, [hl]
pop hl
ret
.WrapAroundTimes:
; entries correspond to RESTART_CLOCK_* constants
MACRO wraparound_time
dw \1 ; value pointer
db \2 ; maximum value
db \3 ; up/down arrow x coord (pairs with wRestartClockUpArrowYCoord)
ENDM
wraparound_time wRestartClockDay, 7, 4
wraparound_time wRestartClockHour, 24, 12
wraparound_time wRestartClockMin, 60, 15
RestartClock:
; If we're here, we had an RTC overflow.
ld hl, .ClockTimeMayBeWrongText
call PrintText
ld hl, wOptions
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
call LoadStandardMenuHeader
call ClearTilemap
ld hl, .ClockSetWithControlPadText
call PrintText
call .SetClock
call ExitMenu
pop bc
ld hl, wOptions
ld [hl], b
ld c, a
ret
.ClockTimeMayBeWrongText:
text_far _ClockTimeMayBeWrongText
text_end
.ClockSetWithControlPadText:
text_far _ClockSetWithControlPadText
text_end
.SetClock:
ld a, RESTART_CLOCK_DAY
ld [wRestartClockCurDivision], a
ld [wRestartClockPrevDivision], a
ld a, 8
ld [wRestartClockUpArrowYCoord], a
call UpdateTime
call GetWeekday
ld [wRestartClockDay], a
ldh a, [hHours]
ld [wRestartClockHour], a
ldh a, [hMinutes]
ld [wRestartClockMin], a
.loop
call .joy_loop
jr nc, .loop
and a
ret nz
call .PrintTime
ld hl, .ClockIsThisOKText
call PrintText
call YesNoBox
jr c, .cancel
ld a, [wRestartClockDay]
ld [wStringBuffer2], a
ld a, [wRestartClockHour]
ld [wStringBuffer2 + 1], a
ld a, [wRestartClockMin]
ld [wStringBuffer2 + 2], a
xor a
ld [wStringBuffer2 + 3], a
call InitTime
call .PrintTime
ld hl, .ClockHasResetText
call PrintText
call WaitPressAorB_BlinkCursor
xor a ; FALSE
ret
.cancel
ld a, TRUE
ret
.ClockIsThisOKText:
text_far _ClockIsThisOKText
text_end
.ClockHasResetText:
text_far _ClockHasResetText
text_end
.joy_loop
call JoyTextDelay_ForcehJoyDown
ld c, a
push af
call .PrintTime
pop af
bit 0, a
jr nz, .press_A
bit 1, a
jr nz, .press_B
bit 6, a
jr nz, .pressed_up
bit 7, a
jr nz, .pressed_down
bit 5, a
jr nz, .pressed_left
bit 4, a
jr nz, .pressed_right
jr .joy_loop
.press_A
ld a, FALSE
scf
ret
.press_B
ld a, TRUE
scf
ret
.pressed_up
ld a, [wRestartClockCurDivision]
call RestartClock_GetWraparoundTime
ld a, [de]
inc a
ld [de], a
cp b
jr c, .done_scroll
ld a, 0
ld [de], a
jr .done_scroll
.pressed_down
ld a, [wRestartClockCurDivision]
call RestartClock_GetWraparoundTime
ld a, [de]
dec a
ld [de], a
cp -1
jr nz, .done_scroll
ld a, b
dec a
ld [de], a
jr .done_scroll
.pressed_left
ld hl, wRestartClockCurDivision
dec [hl]
jr nz, .done_scroll
ld [hl], RESTART_CLOCK_MIN
jr .done_scroll
.pressed_right
ld hl, wRestartClockCurDivision
inc [hl]
ld a, [hl]
cp NUM_RESTART_CLOCK_DIVISIONS + 1
jr c, .done_scroll
ld [hl], RESTART_CLOCK_DAY
.done_scroll
xor a ; FALSE
ret
.PrintTime:
hlcoord 0, 5
ld b, 5
ld c, 18
call Textbox
decoord 1, 8
ld a, [wRestartClockDay]
ld b, a
farcall PrintDayOfWeek
ld a, [wRestartClockHour]
ld b, a
ld a, [wRestartClockMin]
ld c, a
decoord 11, 8
farcall PrintHoursMins
ld a, [wRestartClockPrevDivision]
lb de, " ", " "
call .PlaceChars
ld a, [wRestartClockCurDivision]
lb de, "▲", "▼"
call .PlaceChars
ld a, [wRestartClockCurDivision]
ld [wRestartClockPrevDivision], a
ret
.UnusedPlaceCharsFragment: ; unreferenced
ld a, [wRestartClockUpArrowYCoord]
ld b, a
call Coord2Tile
ret
.PlaceChars:
push de
call RestartClock_GetWraparoundTime
ld a, [wRestartClockUpArrowYCoord]
dec a
ld b, a
call Coord2Tile
pop de
ld [hl], d
ld bc, 2 * SCREEN_WIDTH
add hl, bc
ld [hl], e
ret
JPHourString: ; unreferenced
db "じ@" ; HR
JPMinuteString: ; unreferenced
db "ふん@" ; MIN

View File

@ -1,187 +0,0 @@
StopRTC: ; unreferenced
ld a, SRAM_ENABLE
ld [MBC3SRamEnable], a
call LatchClock
ld a, RTC_DH
ld [MBC3SRamBank], a
ld a, [MBC3RTC]
set 6, a ; halt
ld [MBC3RTC], a
call CloseSRAM
ret
StartRTC:
ld a, SRAM_ENABLE
ld [MBC3SRamEnable], a
call LatchClock
ld a, RTC_DH
ld [MBC3SRamBank], a
ld a, [MBC3RTC]
res 6, a ; halt
ld [MBC3RTC], a
call CloseSRAM
ret
GetTimeOfDay::
; get time of day based on the current hour
ldh a, [hHours] ; hour
ld hl, TimesOfDay
.check
; if we're within the given time period,
; get the corresponding time of day
cp [hl]
jr c, .match
; else, get the next entry
inc hl
inc hl
; try again
jr .check
.match
; get time of day
inc hl
ld a, [hl]
ld [wTimeOfDay], a
ret
TimesOfDay:
; hours for the time of day
; 0400-0959 morn | 1000-1759 day | 1800-0359 nite
db MORN_HOUR, NITE_F
db DAY_HOUR, MORN_F
db NITE_HOUR, DAY_F
db MAX_HOUR, NITE_F
db -1, MORN_F
BetaTimesOfDay: ; unreferenced
db 20, NITE_F
db 40, MORN_F
db 60, DAY_F
db -1, MORN_F
StageRTCTimeForSave:
call UpdateTime
ld hl, wRTC
ld a, [wCurDay]
ld [hli], a
ldh a, [hHours]
ld [hli], a
ldh a, [hMinutes]
ld [hli], a
ldh a, [hSeconds]
ld [hli], a
ret
SaveRTC:
ld a, SRAM_ENABLE
ld [MBC3SRamEnable], a
call LatchClock
ld hl, MBC3RTC
ld a, RTC_DH
ld [MBC3SRamBank], a
res 7, [hl]
ld a, BANK(sRTCStatusFlags)
ld [MBC3SRamBank], a
xor a
ld [sRTCStatusFlags], a
call CloseSRAM
ret
StartClock::
call GetClock
call _FixDays
call FixDays
jr nc, .skip_set
; bit 5: Day count exceeds 139
; bit 6: Day count exceeds 255
call RecordRTCStatus ; set flag on sRTCStatusFlags
.skip_set
call StartRTC
ret
_FixDays:
ld hl, hRTCDayHi
bit 7, [hl]
jr nz, .set_bit_7
bit 6, [hl]
jr nz, .set_bit_7
xor a
ret
.set_bit_7
; Day count exceeds 16383
ld a, %10000000
call RecordRTCStatus ; set bit 7 on sRTCStatusFlags
ret
ClockContinue:
call CheckRTCStatus
ld c, a
and %11000000 ; Day count exceeded 255 or 16383
jr nz, .time_overflow
ld a, c
and %00100000 ; Day count exceeded 139
jr z, .dont_update
call UpdateTime
ld a, [wRTC + 0]
ld b, a
ld a, [wCurDay]
cp b
jr c, .dont_update
.time_overflow
farcall ClearDailyTimers
ret
.dont_update
xor a
ret
_InitTime::
call GetClock
call FixDays
ld hl, hRTCSeconds
ld de, wStartSecond
ld a, [wStringBuffer2 + 3]
sub [hl]
dec hl
jr nc, .okay_secs
add 60
.okay_secs
ld [de], a
dec de
ld a, [wStringBuffer2 + 2]
sbc [hl]
dec hl
jr nc, .okay_mins
add 60
.okay_mins
ld [de], a
dec de
ld a, [wStringBuffer2 + 1]
sbc [hl]
dec hl
jr nc, .okay_hrs
add 24
.okay_hrs
ld [de], a
dec de
ld a, [wStringBuffer2]
sbc [hl]
dec hl
jr nc, .okay_days
add 140
ld c, 7
call SimpleDivide
.okay_days
ld [de], a
ret

View File

@ -1,726 +0,0 @@
DEF TIMESET_UP_ARROW EQU "♂" ; $ef
DEF TIMESET_DOWN_ARROW EQU "♀" ; $f5
InitClock:
; Ask the player to set the time.
ldh a, [hInMenu]
push af
ld a, $1
ldh [hInMenu], a
ld a, $0
ld [wSpriteUpdatesEnabled], a
ld a, $10
ld [wMusicFade], a
ld a, LOW(MUSIC_NONE)
ld [wMusicFadeID], a
ld a, HIGH(MUSIC_NONE)
ld [wMusicFadeID + 1], a
ld c, 8
call DelayFrames
call RotateFourPalettesLeft
call ClearTilemap
call ClearSprites
ld b, CGB_DIPLOMA
call GetCGBLayout
xor a
ldh [hBGMapMode], a
call LoadStandardFont
ld de, TimeSetBackgroundGFX
ld hl, vTiles2 tile $00
lb bc, BANK(TimeSetBackgroundGFX), 1
call Request1bpp
ld de, TimeSetUpArrowGFX
ld hl, vTiles2 tile $01
lb bc, BANK(TimeSetUpArrowGFX), 1
call Request1bpp
ld de, TimeSetDownArrowGFX
ld hl, vTiles2 tile $02
lb bc, BANK(TimeSetDownArrowGFX), 1
call Request1bpp
call .ClearScreen
call WaitBGMap
call RotateFourPalettesRight
ld hl, OakTimeWokeUpText
call PrintText
ld hl, wTimeSetBuffer
ld bc, wTimeSetBufferEnd - wTimeSetBuffer
xor a
call ByteFill
ld a, 10 ; default hour = 10 AM
ld [wInitHourBuffer], a
.loop
ld hl, OakTimeWhatTimeIsItText
call PrintText
hlcoord 3, 7
ld b, 2
ld c, 15
call Textbox
hlcoord 11, 7
ld [hl], $1
hlcoord 11, 10
ld [hl], $2
hlcoord 4, 9
call DisplayHourOClock
ld c, 10
call DelayFrames
.SetHourLoop:
call JoyTextDelay
call SetHour
jr nc, .SetHourLoop
ld a, [wInitHourBuffer]
ld [wStringBuffer2 + 1], a
call .ClearScreen
ld hl, OakTimeWhatHoursText
call PrintText
call YesNoBox
jr nc, .HourIsSet
call .ClearScreen
jr .loop
.HourIsSet:
ld hl, OakTimeHowManyMinutesText
call PrintText
hlcoord 11, 7
lb bc, 2, 7
call Textbox
hlcoord 15, 7
ld [hl], $1
hlcoord 15, 10
ld [hl], $2
hlcoord 12, 9
call DisplayMinutesWithMinString
ld c, 10
call DelayFrames
.SetMinutesLoop:
call JoyTextDelay
call SetMinutes
jr nc, .SetMinutesLoop
ld a, [wInitMinuteBuffer]
ld [wStringBuffer2 + 2], a
call .ClearScreen
ld hl, OakTimeWhoaMinutesText
call PrintText
call YesNoBox
jr nc, .MinutesAreSet
call .ClearScreen
jr .HourIsSet
.MinutesAreSet:
call InitTimeOfDay
ld hl, OakText_ResponseToSetTime
call PrintText
call WaitPressAorB_BlinkCursor
pop af
ldh [hInMenu], a
ret
.ClearScreen:
xor a
ldh [hBGMapMode], a
hlcoord 0, 0
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
xor a
call ByteFill
ld a, $1
ldh [hBGMapMode], a
ret
SetHour:
ldh a, [hJoyPressed]
and A_BUTTON
jr nz, .Confirm
ld hl, hJoyLast
ld a, [hl]
and D_UP
jr nz, .up
ld a, [hl]
and D_DOWN
jr nz, .down
call DelayFrame
and a
ret
.down
ld hl, wInitHourBuffer
ld a, [hl]
and a
jr nz, .DecreaseThroughMidnight
ld a, 23 + 1
.DecreaseThroughMidnight:
dec a
ld [hl], a
jr .okay
.up
ld hl, wInitHourBuffer
ld a, [hl]
cp 23
jr c, .AdvanceThroughMidnight
ld a, -1
.AdvanceThroughMidnight:
inc a
ld [hl], a
.okay
hlcoord 4, 9
ld a, " "
ld bc, 15
call ByteFill
hlcoord 4, 9
call DisplayHourOClock
call WaitBGMap
and a
ret
.Confirm:
scf
ret
DisplayHourOClock:
push hl
ld a, [wInitHourBuffer]
ld c, a
ld e, l
ld d, h
call PrintHour
inc hl
ld de, String_oclock
call PlaceString
pop hl
ret
DisplayHoursMinutesWithMinString: ; unreferenced
ld h, d
ld l, e
push hl
call DisplayHourOClock
pop de
inc de
inc de
ld a, ":"
ld [de], a
inc de
push de
ld hl, 3
add hl, de
ld a, [de]
inc de
ld [hli], a
ld a, [de]
ld [hl], a
pop hl
call DisplayMinutesWithMinString
inc hl
inc hl
inc hl
ret
SetMinutes:
ldh a, [hJoyPressed]
and A_BUTTON
jr nz, .a_button
ld hl, hJoyLast
ld a, [hl]
and D_UP
jr nz, .d_up
ld a, [hl]
and D_DOWN
jr nz, .d_down
call DelayFrame
and a
ret
.d_down
ld hl, wInitMinuteBuffer
ld a, [hl]
and a
jr nz, .decrease
ld a, 59 + 1
.decrease
dec a
ld [hl], a
jr .finish_dpad
.d_up
ld hl, wInitMinuteBuffer
ld a, [hl]
cp 59
jr c, .increase
ld a, -1
.increase
inc a
ld [hl], a
.finish_dpad
hlcoord 12, 9
ld a, " "
ld bc, 7
call ByteFill
hlcoord 12, 9
call DisplayMinutesWithMinString
call WaitBGMap
and a
ret
.a_button
scf
ret
DisplayMinutesWithMinString:
ld de, wInitMinuteBuffer
call PrintTwoDigitNumberLeftAlign
inc hl
ld de, String_min
call PlaceString
ret
PrintTwoDigitNumberLeftAlign:
push hl
ld a, " "
ld [hli], a
ld [hl], a
pop hl
lb bc, PRINTNUM_LEFTALIGN | 1, 2
call PrintNum
ret
OakTimeWokeUpText:
text_far _OakTimeWokeUpText
text_end
OakTimeWhatTimeIsItText:
text_far _OakTimeWhatTimeIsItText
text_end
String_oclock:
db "o'clock@"
OakTimeWhatHoursText:
; What?@ @
text_far _OakTimeWhatHoursText
text_asm
hlcoord 1, 16
call DisplayHourOClock
ld hl, .OakTimeHoursQuestionMarkText
ret
.OakTimeHoursQuestionMarkText:
text_far _OakTimeHoursQuestionMarkText
text_end
OakTimeHowManyMinutesText:
text_far _OakTimeHowManyMinutesText
text_end
String_min:
db "min.@"
OakTimeWhoaMinutesText:
; Whoa!@ @
text_far _OakTimeWhoaMinutesText
text_asm
hlcoord 7, 14
call DisplayMinutesWithMinString
ld hl, .OakTimeMinutesQuestionMarkText
ret
.OakTimeMinutesQuestionMarkText:
text_far _OakTimeMinutesQuestionMarkText
text_end
OakText_ResponseToSetTime:
text_asm
decoord 1, 14
ld a, [wInitHourBuffer]
ld c, a
call PrintHour
ld [hl], ":"
inc hl
ld de, wInitMinuteBuffer
lb bc, PRINTNUM_LEADINGZEROS | 1, 2
call PrintNum
ld b, h
ld c, l
ld a, [wInitHourBuffer]
cp MORN_HOUR
jr c, .nite
cp DAY_HOUR + 1
jr c, .morn
cp NITE_HOUR
jr c, .day
.nite
ld hl, .OakTimeSoDarkText
ret
.morn
ld hl, .OakTimeOversleptText
ret
.day
ld hl, .OakTimeYikesText
ret
.OakTimeOversleptText:
text_far _OakTimeOversleptText
text_end
.OakTimeYikesText:
text_far _OakTimeYikesText
text_end
.OakTimeSoDarkText:
text_far _OakTimeSoDarkText
text_end
TimeSetBackgroundGFX:
INCBIN "gfx/new_game/timeset_bg.1bpp"
TimeSetUpArrowGFX:
INCBIN "gfx/new_game/up_arrow.1bpp"
TimeSetDownArrowGFX:
INCBIN "gfx/new_game/down_arrow.1bpp"
SetDayOfWeek:
ldh a, [hInMenu]
push af
ld a, $1
ldh [hInMenu], a
ld de, TimeSetUpArrowGFX
ld hl, vTiles0 tile TIMESET_UP_ARROW
lb bc, BANK(TimeSetUpArrowGFX), 1
call Request1bpp
ld de, TimeSetDownArrowGFX
ld hl, vTiles0 tile TIMESET_DOWN_ARROW
lb bc, BANK(TimeSetDownArrowGFX), 1
call Request1bpp
xor a
ld [wTempDayOfWeek], a
.loop
hlcoord 0, 12
lb bc, 4, 18
call Textbox
call LoadStandardMenuHeader
ld hl, .OakTimeWhatDayIsItText
call PrintText
hlcoord 9, 3
ld b, 2
ld c, 9
call Textbox
hlcoord 14, 3
ld [hl], TIMESET_UP_ARROW
hlcoord 14, 6
ld [hl], TIMESET_DOWN_ARROW
hlcoord 10, 5
call .PlaceWeekdayString
call ApplyTilemap
ld c, 10
call DelayFrames
.loop2
call JoyTextDelay
call .GetJoypadAction
jr nc, .loop2
call ExitMenu
call UpdateSprites
ld hl, .ConfirmWeekdayText
call PrintText
call YesNoBox
jr c, .loop
ld a, [wTempDayOfWeek]
ld [wStringBuffer2], a
call InitDayOfWeek
call LoadStandardFont
pop af
ldh [hInMenu], a
ret
.GetJoypadAction:
ldh a, [hJoyPressed]
and A_BUTTON
jr z, .not_A
scf
ret
.not_A
ld hl, hJoyLast
ld a, [hl]
and D_UP
jr nz, .d_up
ld a, [hl]
and D_DOWN
jr nz, .d_down
call DelayFrame
and a
ret
.d_down
ld hl, wTempDayOfWeek
ld a, [hl]
and a
jr nz, .decrease
ld a, SATURDAY + 1
.decrease
dec a
ld [hl], a
jr .finish_dpad
.d_up
ld hl, wTempDayOfWeek
ld a, [hl]
cp 6
jr c, .increase
ld a, SUNDAY - 1
.increase
inc a
ld [hl], a
.finish_dpad
xor a
ldh [hBGMapMode], a
hlcoord 10, 4
ld b, 2
ld c, 9
call ClearBox
hlcoord 10, 5
call .PlaceWeekdayString
call WaitBGMap
and a
ret
.PlaceWeekdayString:
push hl
ld a, [wTempDayOfWeek]
ld e, a
ld d, 0
ld hl, .WeekdayStrings
add hl, de
add hl, de
ld a, [hli]
ld d, [hl]
ld e, a
pop hl
call PlaceString
ret
.WeekdayStrings:
; entries correspond to wCurDay constants (see constants/wram_constants.asm)
dw .Sunday
dw .Monday
dw .Tuesday
dw .Wednesday
dw .Thursday
dw .Friday
dw .Saturday
dw .Sunday
.Sunday: db " SUNDAY@"
.Monday: db " MONDAY@"
.Tuesday: db " TUESDAY@"
.Wednesday: db "WEDNESDAY@"
.Thursday: db "THURSDAY@"
.Friday: db " FRIDAY@"
.Saturday: db "SATURDAY@"
.OakTimeWhatDayIsItText:
text_far _OakTimeWhatDayIsItText
text_end
.ConfirmWeekdayText:
text_asm
hlcoord 1, 14
call .PlaceWeekdayString
ld hl, .OakTimeIsItText
ret
.OakTimeIsItText:
text_far _OakTimeIsItText
text_end
InitialSetDSTFlag:
ld a, [wDST]
set 7, a
ld [wDST], a
hlcoord 1, 14
lb bc, 3, 18
call ClearBox
ld hl, .Text
call PlaceHLTextAtBC
ret
.Text:
text_asm
call UpdateTime
ldh a, [hHours]
ld b, a
ldh a, [hMinutes]
ld c, a
decoord 1, 14
farcall PrintHoursMins
ld hl, .DSTIsThatOKText
ret
.DSTIsThatOKText:
text_far _DSTIsThatOKText
text_end
InitialClearDSTFlag:
ld a, [wDST]
res 7, a
ld [wDST], a
hlcoord 1, 14
lb bc, 3, 18
call ClearBox
ld hl, .Text
call PlaceHLTextAtBC
ret
.Text:
text_asm
call UpdateTime
ldh a, [hHours]
ld b, a
ldh a, [hMinutes]
ld c, a
decoord 1, 14
farcall PrintHoursMins
ld hl, .TimeAskOkayText
ret
.TimeAskOkayText:
text_far _TimeAskOkayText
text_end
MrChrono: ; unreferenced
hlcoord 1, 14
lb bc, 3, SCREEN_WIDTH - 2
call ClearBox
ld hl, .Text
call PlaceHLTextAtBC
ret
.Text:
text_asm
call UpdateTime
hlcoord 1, 14
ld [hl], "R"
inc hl
ld [hl], "T"
inc hl
ld [hl], " "
inc hl
ld de, hRTCDayLo
call .PrintTime
hlcoord 1, 16
ld [hl], "D"
inc hl
ld [hl], "F"
inc hl
ld [hl], " "
inc hl
ld de, wStartDay
call .PrintTime
ld [hl], " "
inc hl
ld a, [wDST]
bit 7, a
jr z, .off
ld [hl], "O"
inc hl
ld [hl], "N"
inc hl
jr .done
.off
ld [hl], "O"
inc hl
ld [hl], "F"
inc hl
ld [hl], "F"
inc hl
.done
ld hl, .NowOnDebug
ret
.NowOnDebug:
text_start
para "Now on DEBUG…"
prompt
.PrintTime:
lb bc, 1, 3
call PrintNum
ld [hl], "."
inc hl
inc de
lb bc, PRINTNUM_LEADINGZEROS | 1, 2
call PrintNum
ld [hl], ":"
inc hl
inc de
lb bc, PRINTNUM_LEADINGZEROS | 1, 2
call PrintNum
ret
PrintHour:
ld l, e
ld h, d
push bc
call GetTimeOfDayString
call PlaceString
ld l, c
ld h, b
inc hl
pop bc
call AdjustHourForAMorPM
ld [wTextDecimalByte], a
ld de, wTextDecimalByte
call PrintTwoDigitNumberLeftAlign
ret
GetTimeOfDayString:
ld a, c
cp MORN_HOUR
jr c, .nite
cp DAY_HOUR
jr c, .morn
cp NITE_HOUR
jr c, .day
.nite
ld de, .nite_string
ret
.morn
ld de, .morn_string
ret
.day
ld de, .day_string
ret
.nite_string: db "NITE@"
.morn_string: db "MORN@"
.day_string: db "DAY@"
AdjustHourForAMorPM:
; Convert the hour stored in c (0-23) to a 1-12 value
ld a, c
or a
jr z, .midnight
cp NOON_HOUR
ret c
ret z
sub NOON_HOUR
ret
.midnight
ld a, NOON_HOUR
ret

View File

@ -3,7 +3,6 @@ DummyPredef36:
ret
UpdateTimeOfDayPal::
call UpdateTime
ld a, [wTimeOfDay]
ld [wCurTimeOfDay], a
call GetTimePalette
@ -64,7 +63,7 @@ _TimeOfDayPals::
ld a, b
ldh [rSVBK], a
; update sgb pals
; update cgb pals
ld b, CGB_MAPPALS
call GetCGBLayout

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

View File

@ -140,8 +140,6 @@ Init::
xor a ; LOW(vBGMap1)
ldh [hBGMapAddress], a
farcall StartClock
xor a ; SRAM_DISABLE
ld [MBC3LatchClock], a
ld [MBC3SRamEnable], a

View File

@ -268,7 +268,7 @@ JoyWaitAorB::
ldh a, [hJoyPressed]
and A_BUTTON | B_BUTTON
ret nz
call UpdateTimeAndPals
call UpdateTimeSensitivePals
jr .loop
WaitButton::
@ -386,7 +386,7 @@ PromptButton::
ldh a, [hJoyPressed]
and A_BUTTON | B_BUTTON
jr nz, .received_input
call UpdateTimeAndPals
call UpdateTimeSensitivePals
ld a, $1
ldh [hBGMapMode], a
call DelayFrame

View File

@ -1,269 +1,4 @@
; Functions relating to the timer interrupt and the real-time-clock.
; Functions relating to the timer interrupt.
Timer::
reti
LatchClock::
; latch clock counter data
ld a, 0
ld [MBC3LatchClock], a
ld a, 1
ld [MBC3LatchClock], a
ret
UpdateTime::
call GetClock
call FixDays
call FixTime
farcall GetTimeOfDay
ret
GetClock::
; store clock data in hRTCDayHi-hRTCSeconds
; enable clock r/w
ld a, SRAM_ENABLE
ld [MBC3SRamEnable], a
; clock data is 'backwards' in hram
call LatchClock
ld hl, MBC3SRamBank
ld de, MBC3RTC
ld [hl], RTC_S
ld a, [de]
maskbits 60
ldh [hRTCSeconds], a
ld [hl], RTC_M
ld a, [de]
maskbits 60
ldh [hRTCMinutes], a
ld [hl], RTC_H
ld a, [de]
maskbits 24
ldh [hRTCHours], a
ld [hl], RTC_DL
ld a, [de]
ldh [hRTCDayLo], a
ld [hl], RTC_DH
ld a, [de]
ldh [hRTCDayHi], a
; unlatch clock / disable clock r/w
call CloseSRAM
ret
FixDays::
; fix day count
; mod by 140
; check if day count > 255 (bit 8 set)
ldh a, [hRTCDayHi] ; DH
bit 0, a
jr z, .daylo
; reset dh (bit 8)
res 0, a
ldh [hRTCDayHi], a
; mod 140
; mod twice since bit 8 (DH) was set
ldh a, [hRTCDayLo]
.modh
sub 140
jr nc, .modh
.modl
sub 140
jr nc, .modl
add 140
; update dl
ldh [hRTCDayLo], a
; flag for sRTCStatusFlags
ld a, %01000000
jr .set
.daylo
; quit if fewer than 140 days have passed
ldh a, [hRTCDayLo]
cp 140
jr c, .quit
; mod 140
.mod
sub 140
jr nc, .mod
add 140
; update dl
ldh [hRTCDayLo], a
; flag for sRTCStatusFlags
ld a, %00100000
.set
; update clock with modded day value
push af
call SetClock
pop af
scf
ret
.quit
xor a
ret
FixTime::
; add ingame time (set at newgame) to current time
; store time in wCurDay, hHours, hMinutes, hSeconds
; second
ldh a, [hRTCSeconds]
ld c, a
ld a, [wStartSecond]
add c
sub 60
jr nc, .updatesec
add 60
.updatesec
ldh [hSeconds], a
; minute
ccf ; carry is set, so turn it off
ldh a, [hRTCMinutes]
ld c, a
ld a, [wStartMinute]
adc c
sub 60
jr nc, .updatemin
add 60
.updatemin
ldh [hMinutes], a
; hour
ccf ; carry is set, so turn it off
ldh a, [hRTCHours]
ld c, a
ld a, [wStartHour]
adc c
sub 24
jr nc, .updatehr
add 24
.updatehr
ldh [hHours], a
; day
ccf ; carry is set, so turn it off
ldh a, [hRTCDayLo]
ld c, a
ld a, [wStartDay]
adc c
ld [wCurDay], a
ret
InitTimeOfDay::
xor a
ld [wStringBuffer2], a
ld a, 0 ; useless
ld [wStringBuffer2 + 3], a
jr InitTime
InitDayOfWeek::
call UpdateTime
ldh a, [hHours]
ld [wStringBuffer2 + 1], a
ldh a, [hMinutes]
ld [wStringBuffer2 + 2], a
ldh a, [hSeconds]
ld [wStringBuffer2 + 3], a
jr InitTime ; useless
InitTime::
farcall _InitTime
ret
ClearClock::
call .ClearhRTC
call SetClock
ret
.ClearhRTC:
xor a
ldh [hRTCSeconds], a
ldh [hRTCMinutes], a
ldh [hRTCHours], a
ldh [hRTCDayLo], a
ldh [hRTCDayHi], a
ret
SetClock::
; set clock data from hram
; enable clock r/w
ld a, SRAM_ENABLE
ld [MBC3SRamEnable], a
; set clock data
; stored 'backwards' in hram
call LatchClock
ld hl, MBC3SRamBank
ld de, MBC3RTC
; seems to be a halt check that got partially commented out
; this block is totally pointless
ld [hl], RTC_DH
ld a, [de]
bit 6, a ; halt
ld [de], a
; seconds
ld [hl], RTC_S
ldh a, [hRTCSeconds]
ld [de], a
; minutes
ld [hl], RTC_M
ldh a, [hRTCMinutes]
ld [de], a
; hours
ld [hl], RTC_H
ldh a, [hRTCHours]
ld [de], a
; day lo
ld [hl], RTC_DL
ldh a, [hRTCDayLo]
ld [de], a
; day hi
ld [hl], RTC_DH
ldh a, [hRTCDayHi]
res 6, a ; make sure timer is active
ld [de], a
; cleanup
call CloseSRAM ; unlatch clock, disable clock r/w
ret
RecordRTCStatus::
; append flags to sRTCStatusFlags
ld hl, sRTCStatusFlags
push af
ld a, BANK(sRTCStatusFlags)
call OpenSRAM
pop af
or [hl]
ld [hl], a
call CloseSRAM
ret
CheckRTCStatus::
; check sRTCStatusFlags
ld a, BANK(sRTCStatusFlags)
call OpenSRAM
ld a, [sRTCStatusFlags]
call CloseSRAM
ret

View File

@ -1,13 +1,11 @@
UpdateTimeAndPals::
; update time and time-sensitive palettes
UpdateTimeSensitivePals::
; update time-sensitive palettes if overworld sprite updates are enabled
; rtc enabled?
; sprite updates enabled?
ld a, [wSpriteUpdatesEnabled]
cp 0
ret z
call UpdateTime
; obj update on?
ld a, [wVramState]
bit 0, a ; obj update

View File

@ -46,7 +46,6 @@ ROMX $07
"Tileset Data 2"
"Extra Songs 1"
ROMX $08
"Clock Reset"
"Tileset Data 3"
"Egg Moves"
ROMX $09

View File

@ -69,7 +69,6 @@ INCLUDE "engine/math/get_square_root.asm"
SECTION "bank5", ROMX
INCLUDE "engine/rtc/rtc.asm"
INCLUDE "engine/overworld/overworld.asm"
INCLUDE "engine/overworld/tile_events.asm"
INCLUDE "engine/menus/save.asm"
@ -91,11 +90,6 @@ SECTION "Roofs", ROMX
INCLUDE "engine/tilesets/mapgroup_roofs.asm"
SECTION "Clock Reset", ROMX
INCLUDE "engine/rtc/restart_clock.asm"
SECTION "bank9", ROMX
INCLUDE "data/text_buffers.asm"
@ -202,7 +196,6 @@ INCLUDE "engine/phone/phonering_copytilemapatonce.asm"
SECTION "bank13_2", ROMX
INCLUDE "engine/link/link_2.asm"
INCLUDE "engine/rtc/reset_password.asm"
INCLUDE "engine/menus/delete_save.asm"
INCLUDE "data/tilesets.asm"
INCLUDE "engine/smallflag.asm"
@ -280,7 +273,6 @@ INCLUDE "engine/gfx/mon_icons.asm"
SECTION "bank24", ROMX
INCLUDE "engine/phone/phone.asm"
INCLUDE "engine/rtc/timeset.asm"
INCLUDE "engine/pokegear/pokegear.asm"
INCLUDE "engine/events/fish.asm"
INCLUDE "engine/games/slot_machine.asm"
@ -436,7 +428,6 @@ INCLUDE "engine/printer/print_party.asm"
SECTION "bank77", ROMX
INCLUDE "engine/rtc/print_hours_mins.asm"
INCLUDE "engine/events/diploma.asm"
INCLUDE "engine/pokedex/pokedex_3.asm"
INCLUDE "engine/events/catch_tutorial_input.asm"

View File

@ -5,18 +5,9 @@ hFarByte::
hTempBank:: db
hSRAMBank:: db
hRTCDayHi:: db
hRTCDayLo:: db
hRTCHours:: db
hRTCMinutes:: db
hRTCSeconds:: db
hHours:: db
ds 1
hMinutes:: db
ds 1
hSeconds:: db
ds 1
hVBlankCounter:: db
@ -150,4 +141,3 @@ hSystemBooted:: db
if DEF(_DEBUG)
hDebugRoomMenuPage::
endc
hClockResetTrigger:: db

View File

@ -1967,15 +1967,6 @@ NEXTU
wTreeMonCoordScore:: db
wTreeMonOTIDScore:: db
NEXTU
; restart clock
wRestartClockCurDivision:: db
wRestartClockPrevDivision:: db
wRestartClockUpArrowYCoord:: db
wRestartClockDay:: db
wRestartClockHour:: db
wRestartClockMin:: db
NEXTU
; link
wLinkBattleRNPreamble:: ds SERIAL_RN_PREAMBLE_LENGTH
@ -2253,12 +2244,6 @@ wStartHour:: db
wStartMinute:: db
wStartSecond:: db
wRTC:: ds 4
wDST::
; bit 7: dst
db
wGameTime:: ; used only for BANK(wGameTime)
wGameTimeCap:: db
wGameTimeHours:: dw
@ -2441,9 +2426,6 @@ wLuckyNumberDayTimer:: dw
wSpecialPhoneCallID:: db
wBugContestStartTime:: ds 4 ; day, hour, min, sec
wUnusedTwoDayTimerOn:: db
wUnusedTwoDayTimer:: db
wUnusedTwoDayTimerStartDate:: db
wBuenasPassword:: db
wBlueCardBalance:: db