-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.asm
126 lines (105 loc) · 2.39 KB
/
main.asm
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include "kernel.inc"
#include "corelib.inc"
.db "KEXC"
.db KEXC_ENTRY_POINT
.dw start
.db KEXC_STACK_SIZE
.dw 20
.db KEXC_NAME
.dw window_title
.db KEXC_DESCRIPTION
.dw description
.db KEXC_HEADER_END
name:
.db "calendar", 0
description:
.db "An application to view a calendar", 0
start:
kld(de, corelib_path)
pcall(loadLibrary)
pcall(getLcdLock)
pcall(getKeypadLock)
pcall(allocScreenBuffer)
; if the RTC is supported, use that time as the default,
; otherwise default to 2015-01-01 00:00
pcall(clockSupported)
; to test the code path for calculators with no clocks:
; jr .notSupported
jr nz, .notSupported
; get the current time as in Tue 2014-11-11 15:04:32
; A IX L H B C D
pcall(getTime)
jr .setTimeVariables
.notSupported:
ld ix, 2015
ld hl, 0
.setTimeVariables:
kld((selected_year), ix)
ld a, l
kld((selected_month), a)
ld a, h
kld((selected_day), a)
; determine the weekday the month starts with
push hl
push ix
pop hl
pop de
kcall(updateMonthData)
; and start with the month view
kjp(monthView)
#include "graphics.asm"
#include "dates.asm"
#include "monthview.asm"
#include "dayview.asm"
; variables
selected_year:
.db 0, 0
selected_month:
.db 0
selected_day:
.db 0
start_weekday:
.db 0
is_leap_year:
.db 0
selected_month_length:
.db 0
; strings
window_title:
.db "Calendar", 0
corelib_path:
.db "/lib/core", 0
; lengths of the months
month_length_non_leap:
.db 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
month_length_leap:
.db 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
; weekday data for the months: this contains the weekday that starts a month in
; a year that starts on a Sunday (0)
month_start_weekday_non_leap:
.db 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5
month_start_weekday_leap:
.db 0, 3, 4, 0, 2, 5, 0, 3, 6, 1, 4, 6
; names of the months
month_names:
.db "Jan", 0
.db "Feb", 0
.db "Mar", 0
.db "Apr", 0
.db "May", 0
.db "Jun", 0
.db "Jul", 0
.db "Aug", 0
.db "Sep", 0
.db "Oct", 0
.db "Nov", 0
.db "Dec", 0
; menu strings
menu_monthview:
.db 1
.db "Quit", 0
menu_dayview:
.db 3
.db "New appointment", 0
.db "Month view", 0
.db "Quit", 0