Identify more uses of wBuffer1-6

This commit is contained in:
Rangi
2020-11-03 19:53:07 -05:00
parent 826e070f04
commit c88c4a8340
29 changed files with 327 additions and 264 deletions

View File

@@ -1,3 +1,10 @@
; 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
RestartClock_GetWraparoundTime:
push hl
dec a
@@ -18,14 +25,15 @@ endr
ret
.WrapAroundTimes:
dw wBuffer4
db 7, 4
dw wBuffer5
db 24, 12
dw wBuffer6
db 60, 15
; 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
RestartClock:
; If we're here, we had an RTC overflow.
@@ -56,18 +64,18 @@ RestartClock:
text_end
.SetClock:
ld a, 1
ld [wBuffer1], a ; which digit
ld [wBuffer2], a
ld a, RESTART_CLOCK_DAY
ld [wRestartClockCurDivision], a
ld [wRestartClockPrevDivision], a
ld a, 8
ld [wBuffer3], a
ld [wRestartClockUpArrowYCoord], a
call UpdateTime
call GetWeekday
ld [wBuffer4], a
ld [wRestartClockDay], a
ldh a, [hHours]
ld [wBuffer5], a
ld [wRestartClockHour], a
ldh a, [hMinutes]
ld [wBuffer6], a
ld [wRestartClockMin], a
.loop
call .joy_loop
@@ -79,11 +87,11 @@ RestartClock:
call PrintText
call YesNoBox
jr c, .cancel
ld a, [wBuffer4]
ld a, [wRestartClockDay]
ld [wStringBuffer2], a
ld a, [wBuffer5]
ld a, [wRestartClockHour]
ld [wStringBuffer2 + 1], a
ld a, [wBuffer6]
ld a, [wRestartClockMin]
ld [wStringBuffer2 + 2], a
xor a
ld [wStringBuffer2 + 3], a
@@ -92,11 +100,11 @@ RestartClock:
ld hl, .ClockHasResetText
call PrintText
call WaitPressAorB_BlinkCursor
xor a
xor a ; FALSE
ret
.cancel
ld a, $1
ld a, TRUE
ret
.ClockIsThisOKText:
@@ -128,29 +136,29 @@ RestartClock:
jr .joy_loop
.press_A
ld a, $0
ld a, FALSE
scf
ret
.press_B
ld a, $1
ld a, TRUE
scf
ret
.pressed_up
ld a, [wBuffer1]
ld a, [wRestartClockCurDivision]
call RestartClock_GetWraparoundTime
ld a, [de]
inc a
ld [de], a
cp b
jr c, .done_scroll
ld a, $0
ld a, 0
ld [de], a
jr .done_scroll
.pressed_down
ld a, [wBuffer1]
ld a, [wRestartClockCurDivision]
call RestartClock_GetWraparoundTime
ld a, [de]
dec a
@@ -163,22 +171,22 @@ RestartClock:
jr .done_scroll
.pressed_left
ld hl, wBuffer1
ld hl, wRestartClockCurDivision
dec [hl]
jr nz, .done_scroll
ld [hl], $3
ld [hl], RESTART_CLOCK_MIN
jr .done_scroll
.pressed_right
ld hl, wBuffer1
ld hl, wRestartClockCurDivision
inc [hl]
ld a, [hl]
cp $4
cp NUM_RESTART_CLOCK_DIVISIONS + 1
jr c, .done_scroll
ld [hl], $1
ld [hl], RESTART_CLOCK_DAY
.done_scroll
xor a
xor a ; FALSE
ret
.PrintTime:
@@ -187,27 +195,27 @@ RestartClock:
ld c, 18
call Textbox
decoord 1, 8
ld a, [wBuffer4]
ld a, [wRestartClockDay]
ld b, a
farcall PrintDayOfWeek
ld a, [wBuffer5]
ld a, [wRestartClockHour]
ld b, a
ld a, [wBuffer6]
ld a, [wRestartClockMin]
ld c, a
decoord 11, 8
farcall PrintHoursMins
ld a, [wBuffer2]
ld a, [wRestartClockPrevDivision]
lb de, " ", " "
call .PlaceChars
ld a, [wBuffer1]
ld a, [wRestartClockCurDivision]
lb de, "▲", "▼"
call .PlaceChars
ld a, [wBuffer1]
ld [wBuffer2], a
ld a, [wRestartClockCurDivision]
ld [wRestartClockPrevDivision], a
ret
.UnusedPlaceCharsFragment: ; unreferenced
ld a, [wBuffer3]
ld a, [wRestartClockUpArrowYCoord]
ld b, a
call Coord2Tile
ret
@@ -215,7 +223,7 @@ RestartClock:
.PlaceChars:
push de
call RestartClock_GetWraparoundTime
ld a, [wBuffer3]
ld a, [wRestartClockUpArrowYCoord]
dec a
ld b, a
call Coord2Tile