Use labels instead of constants for HRAM

Use explicit ldh instruction to access HRAM locations, don't rely on optimizing ld
This commit is contained in:
Rangi
2018-08-25 14:28:22 -04:00
parent 376c64468b
commit eb1e3636bb
243 changed files with 4706 additions and 4661 deletions

View File

@@ -2,7 +2,7 @@
AskTimer::
push af
ld a, [hMobile]
ldh a, [hMobile]
and a
jr z, .not_mobile
call Timer
@@ -42,25 +42,25 @@ GetClock::
ld [hl], RTC_S
ld a, [de]
maskbits 60
ld [hRTCSeconds], a
ldh [hRTCSeconds], a
ld [hl], RTC_M
ld a, [de]
maskbits 60
ld [hRTCMinutes], a
ldh [hRTCMinutes], a
ld [hl], RTC_H
ld a, [de]
maskbits 24
ld [hRTCHours], a
ldh [hRTCHours], a
ld [hl], RTC_DL
ld a, [de]
ld [hRTCDayLo], a
ldh [hRTCDayLo], a
ld [hl], RTC_DH
ld a, [de]
ld [hRTCDayHi], a
ldh [hRTCDayHi], a
; unlatch clock / disable clock r/w
call CloseSRAM
@@ -71,16 +71,16 @@ FixDays::
; mod by 140
; check if day count > 255 (bit 8 set)
ld a, [hRTCDayHi] ; DH
ldh a, [hRTCDayHi] ; DH
bit 0, a
jr z, .daylo
; reset dh (bit 8)
res 0, a
ld [hRTCDayHi], a ; DH
ldh [hRTCDayHi], a ; DH
; mod 140
; mod twice since bit 8 (DH) was set
ld a, [hRTCDayLo] ; DL
ldh a, [hRTCDayLo] ; DL
.modh
sub 140
jr nc, .modh
@@ -90,7 +90,7 @@ FixDays::
add 140
; update dl
ld [hRTCDayLo], a ; DL
ldh [hRTCDayLo], a ; DL
; flag for sRTCStatusFlags
ld a, %01000000
@@ -98,7 +98,7 @@ FixDays::
.daylo
; quit if fewer than 140 days have passed
ld a, [hRTCDayLo] ; DL
ldh a, [hRTCDayLo] ; DL
cp 140
jr c, .quit
@@ -109,7 +109,7 @@ FixDays::
add 140
; update dl
ld [hRTCDayLo], a ; DL
ldh [hRTCDayLo], a ; DL
; flag for sRTCStatusFlags
ld a, %00100000
@@ -132,7 +132,7 @@ FixTime::
; store time in wCurDay, hHours, hMinutes, hSeconds
; second
ld a, [hRTCSeconds] ; S
ldh a, [hRTCSeconds] ; S
ld c, a
ld a, [wStartSecond]
add c
@@ -140,11 +140,11 @@ FixTime::
jr nc, .updatesec
add 60
.updatesec
ld [hSeconds], a
ldh [hSeconds], a
; minute
ccf ; carry is set, so turn it off
ld a, [hRTCMinutes] ; M
ldh a, [hRTCMinutes] ; M
ld c, a
ld a, [wStartMinute]
adc c
@@ -152,11 +152,11 @@ FixTime::
jr nc, .updatemin
add 60
.updatemin
ld [hMinutes], a
ldh [hMinutes], a
; hour
ccf ; carry is set, so turn it off
ld a, [hRTCHours] ; H
ldh a, [hRTCHours] ; H
ld c, a
ld a, [wStartHour]
adc c
@@ -164,11 +164,11 @@ FixTime::
jr nc, .updatehr
add 24
.updatehr
ld [hHours], a
ldh [hHours], a
; day
ccf ; carry is set, so turn it off
ld a, [hRTCDayLo] ; DL
ldh a, [hRTCDayLo] ; DL
ld c, a
ld a, [wStartDay]
adc c
@@ -184,11 +184,11 @@ InitTimeOfDay::
InitDayOfWeek::
call UpdateTime
ld a, [hHours]
ldh a, [hHours]
ld [wStringBuffer2 + 1], a
ld a, [hMinutes]
ldh a, [hMinutes]
ld [wStringBuffer2 + 2], a
ld a, [hSeconds]
ldh a, [hSeconds]
ld [wStringBuffer2 + 3], a
jr InitTime ; useless
@@ -203,11 +203,11 @@ PanicResetClock::
.ClearhRTC:
xor a
ld [hRTCSeconds], a
ld [hRTCMinutes], a
ld [hRTCHours], a
ld [hRTCDayLo], a
ld [hRTCDayHi], a
ldh [hRTCSeconds], a
ldh [hRTCMinutes], a
ldh [hRTCHours], a
ldh [hRTCDayLo], a
ldh [hRTCDayHi], a
ret
SetClock::
@@ -233,23 +233,23 @@ SetClock::
; seconds
ld [hl], RTC_S
ld a, [hRTCSeconds]
ldh a, [hRTCSeconds]
ld [de], a
; minutes
ld [hl], RTC_M
ld a, [hRTCMinutes]
ldh a, [hRTCMinutes]
ld [de], a
; hours
ld [hl], RTC_H
ld a, [hRTCHours]
ldh a, [hRTCHours]
ld [de], a
; day lo
ld [hl], RTC_DL
ld a, [hRTCDayLo]
ldh a, [hRTCDayLo]
ld [de], a
; day hi
ld [hl], RTC_DH
ld a, [hRTCDayHi]
ldh a, [hRTCDayHi]
res 6, a ; make sure timer is active
ld [de], a