shithub: pokecrystal

Download patch

ref: 2b10d184b084cdd3390ad201db5f79af9bc224b9
parent: 2f5ed8468d0a7da1ee9de73fcecce86e8d6ef96c
author: yenatch <[email protected]>
date: Mon Aug 26 20:10:22 EDT 2013

recomment some common asm (rtc/lcd)

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