pokecrystal/engine/rtc/restart_clock.asm

237 lines
3.1 KiB
NASM
Raw Normal View History

2018-06-24 14:09:41 +00:00
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
2018-06-24 14:09:41 +00:00
.WrapAroundTimes:
2018-01-23 22:39:09 +00:00
dw wBuffer4
db 7, 4
2018-01-23 22:39:09 +00:00
dw wBuffer5
db 24, 12
2018-01-23 22:39:09 +00:00
dw wBuffer6
db 60, 15
2018-06-24 14:09:41 +00:00
RestartClock:
; If we're here, we had an RTC overflow.
ld hl, .ClockTimeMayBeWrongText
call PrintText
2018-01-23 22:39:09 +00:00
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
2018-01-23 22:39:09 +00:00
ld hl, wOptions
ld [hl], b
ld c, a
ret
.ClockTimeMayBeWrongText:
text_far _ClockTimeMayBeWrongText
text_end
.ClockSetWithControlPadText:
text_far _ClockSetWithControlPadText
text_end
2018-06-24 14:09:41 +00:00
.SetClock:
ld a, 1
2018-01-23 22:39:09 +00:00
ld [wBuffer1], a ; which digit
ld [wBuffer2], a
ld a, 8
2018-01-23 22:39:09 +00:00
ld [wBuffer3], a
call UpdateTime
call GetWeekday
2018-01-23 22:39:09 +00:00
ld [wBuffer4], a
ldh a, [hHours]
2018-01-23 22:39:09 +00:00
ld [wBuffer5], a
ldh a, [hMinutes]
2018-01-23 22:39:09 +00:00
ld [wBuffer6], a
.loop
call .joy_loop
jr nc, .loop
and a
ret nz
call .PrintTime
ld hl, .ClockIsThisOKText
call PrintText
call YesNoBox
jr c, .cancel
2018-01-23 22:39:09 +00:00
ld a, [wBuffer4]
ld [wStringBuffer2], a
ld a, [wBuffer5]
ld [wStringBuffer2 + 1], a
ld a, [wBuffer6]
ld [wStringBuffer2 + 2], a
xor a
2018-01-23 22:39:09 +00:00
ld [wStringBuffer2 + 3], a
2015-12-19 01:07:09 +00:00
call InitTime
call .PrintTime
ld hl, .ClockHasResetText
call PrintText
call WaitPressAorB_BlinkCursor
xor a
ret
.cancel
ld a, $1
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, $0
scf
ret
.press_B
ld a, $1
scf
ret
.pressed_up
2018-01-23 22:39:09 +00:00
ld a, [wBuffer1]
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
2018-01-23 22:39:09 +00:00
ld a, [wBuffer1]
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
2018-01-23 22:39:09 +00:00
ld hl, wBuffer1
dec [hl]
jr nz, .done_scroll
ld [hl], $3
jr .done_scroll
.pressed_right
2018-01-23 22:39:09 +00:00
ld hl, wBuffer1
inc [hl]
ld a, [hl]
cp $4
jr c, .done_scroll
ld [hl], $1
.done_scroll
xor a
ret
2018-06-24 14:09:41 +00:00
.PrintTime:
hlcoord 0, 5
ld b, 5
ld c, 18
2019-04-08 12:15:10 +00:00
call Textbox
decoord 1, 8
2018-01-23 22:39:09 +00:00
ld a, [wBuffer4]
ld b, a
2017-12-24 17:47:30 +00:00
farcall PrintDayOfWeek
2018-01-23 22:39:09 +00:00
ld a, [wBuffer5]
ld b, a
2018-01-23 22:39:09 +00:00
ld a, [wBuffer6]
ld c, a
decoord 11, 8
2017-12-24 17:47:30 +00:00
farcall PrintHoursMins
2018-01-23 22:39:09 +00:00
ld a, [wBuffer2]
lb de, " ", " "
call .PlaceChars
2018-01-23 22:39:09 +00:00
ld a, [wBuffer1]
lb de, "▲", "▼"
call .PlaceChars
2018-01-23 22:39:09 +00:00
ld a, [wBuffer1]
ld [wBuffer2], a
ret
2018-06-24 14:09:41 +00:00
.unreferenced
2018-03-03 00:39:16 +00:00
; unused
2018-01-23 22:39:09 +00:00
ld a, [wBuffer3]
ld b, a
call Coord2Tile
ret
2018-06-24 14:09:41 +00:00
.PlaceChars:
push de
call RestartClock_GetWraparoundTime
2018-01-23 22:39:09 +00:00
ld a, [wBuffer3]
dec a
ld b, a
call Coord2Tile
pop de
ld [hl], d
ld bc, 2 * SCREEN_WIDTH
add hl, bc
ld [hl], e
ret
2018-06-24 14:09:41 +00:00
UnreferencedString_HourJP:
2018-03-03 00:39:16 +00:00
; unused
db "じ@" ; HR
2018-06-24 14:09:41 +00:00
UnreferencedString_MinuteJP:
2018-03-03 00:39:16 +00:00
; unused
db "ふん@" ; MIN