2020-11-03 16:53:07 -08:00
|
|
|
; RestartClock_GetWraparoundTime.WrapAroundTimes indexes
|
|
|
|
const_def 1
|
|
|
|
const RESTART_CLOCK_DAY
|
|
|
|
const RESTART_CLOCK_HOUR
|
|
|
|
const RESTART_CLOCK_MIN
|
|
|
|
NUM_RESTART_CLOCK_DIVISIONS EQU const_value - 1
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RestartClock_GetWraparoundTime:
|
2015-11-10 08:05:26 -08:00
|
|
|
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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.WrapAroundTimes:
|
2020-11-03 16:53:07 -08:00
|
|
|
; entries correspond to RESTART_CLOCK_* constants
|
|
|
|
wraparound_time: MACRO
|
|
|
|
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
|
2015-11-10 08:05:26 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RestartClock:
|
2015-11-10 08:05:26 -08:00
|
|
|
; If we're here, we had an RTC overflow.
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .ClockTimeMayBeWrongText
|
2015-11-10 08:05:26 -08:00
|
|
|
call PrintText
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wOptions
|
2015-11-10 08:05:26 -08:00
|
|
|
ld a, [hl]
|
|
|
|
push af
|
|
|
|
set NO_TEXT_SCROLL, [hl]
|
2018-01-23 13:08:43 -08:00
|
|
|
call LoadStandardMenuHeader
|
2020-02-13 09:30:13 -08:00
|
|
|
call ClearTilemap
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .ClockSetWithControlPadText
|
2015-11-10 08:05:26 -08:00
|
|
|
call PrintText
|
|
|
|
call .SetClock
|
|
|
|
call ExitMenu
|
|
|
|
pop bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wOptions
|
2015-11-10 08:05:26 -08:00
|
|
|
ld [hl], b
|
|
|
|
ld c, a
|
|
|
|
ret
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.ClockTimeMayBeWrongText:
|
|
|
|
text_far _ClockTimeMayBeWrongText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-11-10 08:05:26 -08:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.ClockSetWithControlPadText:
|
|
|
|
text_far _ClockSetWithControlPadText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-11-10 08:05:26 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.SetClock:
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, RESTART_CLOCK_DAY
|
|
|
|
ld [wRestartClockCurDivision], a
|
|
|
|
ld [wRestartClockPrevDivision], a
|
2015-11-10 08:05:26 -08:00
|
|
|
ld a, 8
|
2020-11-03 16:53:07 -08:00
|
|
|
ld [wRestartClockUpArrowYCoord], a
|
2015-11-10 08:05:26 -08:00
|
|
|
call UpdateTime
|
|
|
|
call GetWeekday
|
2020-11-03 16:53:07 -08:00
|
|
|
ld [wRestartClockDay], a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hHours]
|
2020-11-03 16:53:07 -08:00
|
|
|
ld [wRestartClockHour], a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMinutes]
|
2020-11-03 16:53:07 -08:00
|
|
|
ld [wRestartClockMin], a
|
2015-11-10 08:05:26 -08:00
|
|
|
|
|
|
|
.loop
|
|
|
|
call .joy_loop
|
|
|
|
jr nc, .loop
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
call .PrintTime
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .ClockIsThisOKText
|
2015-11-10 08:05:26 -08:00
|
|
|
call PrintText
|
|
|
|
call YesNoBox
|
|
|
|
jr c, .cancel
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, [wRestartClockDay]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wStringBuffer2], a
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, [wRestartClockHour]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wStringBuffer2 + 1], a
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, [wRestartClockMin]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wStringBuffer2 + 2], a
|
2015-11-10 08:05:26 -08:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wStringBuffer2 + 3], a
|
2015-12-18 17:07:09 -08:00
|
|
|
call InitTime
|
2015-11-10 08:05:26 -08:00
|
|
|
call .PrintTime
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .ClockHasResetText
|
2015-11-10 08:05:26 -08:00
|
|
|
call PrintText
|
2015-11-10 20:23:28 -08:00
|
|
|
call WaitPressAorB_BlinkCursor
|
2020-11-03 16:53:07 -08:00
|
|
|
xor a ; FALSE
|
2015-11-10 08:05:26 -08:00
|
|
|
ret
|
|
|
|
|
|
|
|
.cancel
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, TRUE
|
2015-11-10 08:05:26 -08:00
|
|
|
ret
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.ClockIsThisOKText:
|
|
|
|
text_far _ClockIsThisOKText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-11-10 08:05:26 -08:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.ClockHasResetText:
|
|
|
|
text_far _ClockHasResetText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-11-10 08:05:26 -08:00
|
|
|
|
|
|
|
.joy_loop
|
2016-05-10 09:31:49 -07:00
|
|
|
call JoyTextDelay_ForcehJoyDown
|
2015-11-10 08:05:26 -08:00
|
|
|
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
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, FALSE
|
2015-11-10 08:05:26 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.press_B
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, TRUE
|
2015-11-10 08:05:26 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.pressed_up
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, [wRestartClockCurDivision]
|
2018-03-25 09:24:14 -07:00
|
|
|
call RestartClock_GetWraparoundTime
|
2015-11-10 08:05:26 -08:00
|
|
|
ld a, [de]
|
|
|
|
inc a
|
|
|
|
ld [de], a
|
|
|
|
cp b
|
|
|
|
jr c, .done_scroll
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, 0
|
2015-11-10 08:05:26 -08:00
|
|
|
ld [de], a
|
|
|
|
jr .done_scroll
|
|
|
|
|
|
|
|
.pressed_down
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, [wRestartClockCurDivision]
|
2018-03-25 09:24:14 -07:00
|
|
|
call RestartClock_GetWraparoundTime
|
2015-11-10 08:05:26 -08:00
|
|
|
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
|
2020-11-03 16:53:07 -08:00
|
|
|
ld hl, wRestartClockCurDivision
|
2015-11-10 08:05:26 -08:00
|
|
|
dec [hl]
|
|
|
|
jr nz, .done_scroll
|
2020-11-03 16:53:07 -08:00
|
|
|
ld [hl], RESTART_CLOCK_MIN
|
2015-11-10 08:05:26 -08:00
|
|
|
jr .done_scroll
|
|
|
|
|
|
|
|
.pressed_right
|
2020-11-03 16:53:07 -08:00
|
|
|
ld hl, wRestartClockCurDivision
|
2015-11-10 08:05:26 -08:00
|
|
|
inc [hl]
|
|
|
|
ld a, [hl]
|
2020-11-03 16:53:07 -08:00
|
|
|
cp NUM_RESTART_CLOCK_DIVISIONS + 1
|
2015-11-10 08:05:26 -08:00
|
|
|
jr c, .done_scroll
|
2020-11-03 16:53:07 -08:00
|
|
|
ld [hl], RESTART_CLOCK_DAY
|
2015-11-10 08:05:26 -08:00
|
|
|
|
|
|
|
.done_scroll
|
2020-11-03 16:53:07 -08:00
|
|
|
xor a ; FALSE
|
2015-11-10 08:05:26 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.PrintTime:
|
2015-11-10 08:05:26 -08:00
|
|
|
hlcoord 0, 5
|
|
|
|
ld b, 5
|
|
|
|
ld c, 18
|
2019-04-08 05:15:10 -07:00
|
|
|
call Textbox
|
2015-11-10 08:05:26 -08:00
|
|
|
decoord 1, 8
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, [wRestartClockDay]
|
2015-11-10 08:05:26 -08:00
|
|
|
ld b, a
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall PrintDayOfWeek
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, [wRestartClockHour]
|
2015-11-10 08:05:26 -08:00
|
|
|
ld b, a
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, [wRestartClockMin]
|
2015-11-10 08:05:26 -08:00
|
|
|
ld c, a
|
|
|
|
decoord 11, 8
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall PrintHoursMins
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, [wRestartClockPrevDivision]
|
2015-11-10 08:05:26 -08:00
|
|
|
lb de, " ", " "
|
|
|
|
call .PlaceChars
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, [wRestartClockCurDivision]
|
2015-11-10 08:05:26 -08:00
|
|
|
lb de, "▲", "▼"
|
|
|
|
call .PlaceChars
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, [wRestartClockCurDivision]
|
|
|
|
ld [wRestartClockPrevDivision], a
|
2015-11-10 08:05:26 -08:00
|
|
|
ret
|
|
|
|
|
2020-06-21 13:27:43 -07:00
|
|
|
.UnusedPlaceCharsFragment: ; unreferenced
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, [wRestartClockUpArrowYCoord]
|
2015-11-10 08:05:26 -08:00
|
|
|
ld b, a
|
2015-11-10 13:53:37 -08:00
|
|
|
call Coord2Tile
|
2015-11-10 08:05:26 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.PlaceChars:
|
2015-11-10 08:05:26 -08:00
|
|
|
push de
|
2018-03-25 09:24:14 -07:00
|
|
|
call RestartClock_GetWraparoundTime
|
2020-11-03 16:53:07 -08:00
|
|
|
ld a, [wRestartClockUpArrowYCoord]
|
2015-11-10 08:05:26 -08:00
|
|
|
dec a
|
|
|
|
ld b, a
|
2015-11-10 13:53:37 -08:00
|
|
|
call Coord2Tile
|
2015-11-10 08:05:26 -08:00
|
|
|
pop de
|
|
|
|
ld [hl], d
|
|
|
|
ld bc, 2 * SCREEN_WIDTH
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], e
|
|
|
|
ret
|
|
|
|
|
2020-06-21 13:27:43 -07:00
|
|
|
JPHourString: ; unreferenced
|
2015-11-10 08:05:26 -08:00
|
|
|
db "じ@" ; HR
|
|
|
|
|
2020-06-21 13:27:43 -07:00
|
|
|
JPMinuteString: ; unreferenced
|
2015-11-10 08:05:26 -08:00
|
|
|
db "ふん@" ; MIN
|