recomment some common asm (rtc/lcd)

This commit is contained in:
yenatch 2013-08-27 00:10:22 -04:00
parent 2f5ed8468d
commit 2b10d184b0

View File

@ -100,7 +100,6 @@ RTC: ; 46f
ld a, [VramState] ld a, [VramState]
bit 0, a ; obj update bit 0, a ; obj update
ret z ret z
; 47e
TimeOfDayPals: ; 47e TimeOfDayPals: ; 47e
callab _TimeOfDayPals callab _TimeOfDayPals
@ -171,7 +170,7 @@ Function4c7: ; 4c7
ld a, [hli] ld a, [hli]
ld d, a ld d, a
call DmgToCgbObjPals call DmgToCgbObjPals
ld c, $8 ld c, 8
call DelayFrames call DelayFrames
pop de pop de
dec b dec b
@ -216,7 +215,7 @@ Function501: ; 501
call DmgToCgbObjPals call DmgToCgbObjPals
ld a, [hld] ld a, [hld]
call DmgToCgbBGPals call DmgToCgbBGPals
ld c, $8 ld c, 8
call DelayFrames call DelayFrames
pop de pop de
dec b dec b
@ -282,41 +281,33 @@ Function552: ; 552
DisableLCD: ; 568 DisableLCD: ; 568
; Turn the LCD off ; Turn the LCD off
; Most of this is just going through the motions
; don't need to do anything if lcd is already off ; Don't need to do anything if the LCD is already off
ld a, [rLCDC] ld a, [rLCDC]
bit 7, a ; lcd enable bit 7, a ; lcd enable
ret z ret z
; reset ints
xor a xor a
ld [rIF], a ld [rIF], a
; save enabled ints
ld a, [rIE] ld a, [rIE]
ld b, a ld b, a
; disable vblank ; Disable VBlank
res 0, a ; vblank res 0, a ; vblank
ld [rIE], a ld [rIE], a
.wait .wait
; wait until vblank ; Wait until VBlank would normally happen
ld a, [rLY] ld a, [rLY]
cp 145 ; >144 (ensure beginning of vblank) cp 145
jr nz, .wait jr nz, .wait
; turn lcd off
ld a, [rLCDC] ld a, [rLCDC]
and %01111111 ; lcd enable off and %01111111 ; lcd enable off
ld [rLCDC], a ld [rLCDC], a
; reset ints
xor a xor a
ld [rIF], a ld [rIF], a
; restore enabled ints
ld a, b ld a, b
ld [rIE], a ld [rIE], a
ret ret
@ -355,13 +346,9 @@ LatchClock: ; 59c
UpdateTime: ; 5a7 UpdateTime: ; 5a7
; get rtc data
call GetClock call GetClock
; condense days to one byte, update rtc w/ new day count
call FixDays call FixDays
; add game time to rtc time
call FixTime call FixTime
; update time of day (0 = morn, 1 = day, 2 = nite)
callba GetTimeOfDay callba GetTimeOfDay
ret ret
; 5b7 ; 5b7
@ -373,40 +360,38 @@ GetClock: ; 5b7
; enable clock r/w ; enable clock r/w
ld a, SRAM_ENABLE ld a, SRAM_ENABLE
ld [MBC3SRamEnable], a ld [MBC3SRamEnable], a
; get clock data ; clock data is 'backwards' in hram
; stored 'backwards' in hram
call LatchClock call LatchClock
ld hl, MBC3SRamBank ld hl, MBC3SRamBank
ld de, MBC3RTC ld de, MBC3RTC
; seconds
ld [hl], RTC_S ld [hl], RTC_S
ld a, [de] ld a, [de]
and $3f and $3f
ld [hRTCSeconds], a ld [hRTCSeconds], a
; minutes
ld [hl], RTC_M ld [hl], RTC_M
ld a, [de] ld a, [de]
and $3f and $3f
ld [hRTCMinutes], a ld [hRTCMinutes], a
; hours
ld [hl], RTC_H ld [hl], RTC_H
ld a, [de] ld a, [de]
and $1f and $1f
ld [hRTCHours], a ld [hRTCHours], a
; day lo
ld [hl], RTC_DL ld [hl], RTC_DL
ld a, [de] ld a, [de]
ld [hRTCDayLo], a ld [hRTCDayLo], a
; day hi
ld [hl], RTC_DH ld [hl], RTC_DH
ld a, [de] ld a, [de]
ld [hRTCDayHi], a ld [hRTCDayHi], a
; cleanup ; unlatch clock / disable clock r/w
call CloseSRAM ; unlatch clock, disable clock r/w call CloseSRAM
ret ret
; 5e8 ; 5e8