summaryrefslogtreecommitdiff
path: root/engine/rtc/print_hours_mins.asm
blob: 4aa4925eb595c18cc93df05775182c8105875f12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
PrintFiveDigitNumber: ; unreferenced
; Debug function?
; Input: bc = value, de = destination
	ld a, b
	ld b, c
	ld c, a
	push bc ; de points to this on the stack for PrintNum
	push de
	ld hl, sp+2
	ld d, h
	ld e, l
	pop hl
	lb bc, PRINTNUM_LEADINGZEROS | 2, 5
	call PrintNum
	pop bc
	ret

PrintHoursMins:
; Hours in b, minutes in c
	ld a, b
	cp 12
	push af
	jr c, .AM
	jr z, .PM
	sub 12
	jr .PM
.AM:
	or a
	jr nz, .PM
	ld a, 12
.PM:
	ld b, a
; Crazy stuff happening with the stack
	push bc
	ld hl, sp+1
	push de
	push hl
	pop de
	pop hl
	ld [hl], " "
	lb bc, 1, 2
	call PrintNum
	ld [hl], ":"
	inc hl
	ld d, h
	ld e, l
	ld hl, sp+0
	push de
	push hl
	pop de
	pop hl
	lb bc, PRINTNUM_LEADINGZEROS | 1, 2
	call PrintNum
	pop bc
	ld de, String_AM
	pop af
	jr c, .place_am_pm
	ld de, String_PM
.place_am_pm
	inc hl
	call PlaceString
	ret

String_AM: db "AM@"
String_PM: db "PM@"

UpdateTimePredef::
	call UpdateTime
	ld hl, wDSTBackupDay
	ld a, [wCurDay]
	ld [hli], a ; wDSTBackupDay
	ldh a, [hHours]
	ld [hli], a ; wDSTBackupHours
	ldh a, [hMinutes]
	ld [hli], a ; wDSTBackupMinutes
	ldh a, [hSeconds]
	ld [hli], a ; wDSTBackupSeconds
	ret