Post Reply 
(Free42) (DM42 or 42S with printer) Calendar Display / Print program
03-10-2022, 06:46 AM
Post: #1
(Free42) (DM42 or 42S with printer) Calendar Display / Print program
Calendar program:

Using the larger graphing area by printing the screen on the Free42, it is possible to print a 12 month calendar. I found an equation to calculate the first day of a year from 1901 to 2099:

Day = ( Int( 1.25 x (Year + 3) ) + 2 ) mod 7

For the day, 0=Sunday and 6=Saturday.

To see a calendar, put the year (in 4 digits) on the stack, then XEQ MCAL. Tap the screen and select “Show Print-Out” to see the calendar.

The main variables are:

A (date counter for the ISG loop)
B (initial column (X) to display the digit)
C (row (Y) to display the digit)
D (beginning day of the month)
E (leftmost column of the month (either 1 (month on left side of screen) or 65 (month on right side of screen).

To make this work, I took a modular approach to writing the code.

First, NUMS stores ten 24 bit numbers in registers 00 to 09, which hold the bitmap for the digits 0 to 9 (the numbers display as 3 pixels wide and 7 pixels tall). GMON uses variables B (matrix column), C (matrix row) and the digit to write to the matrix in register 10.

Code:
00 { 178-Byte Prgm }
01▸LBL "NUMS"
02 8339839
03 STO 00
04 127
05 STO 01
06 7948623
07 STO 02
08 4802943
09 STO 03
10 985215
11 STO 04
12 5196153
13 STO 05
14 8341881
15 STO 06
16 65919
17 STO 07
18 8341887
19 STO 08
20 5196159
21 STO 09
22 RTN
23▸LBL "GMON"
24 INDEX "M"
25 RCL "C"
26 RCL "B"
27 STOIJ
28 RCL IND 10
29 16
30 ROTXY
31 255
32 AND
33 STOEL
34 INDEX "M"
35 RCL "C"
36 RCL "B"
37 1
38 +
39 STOIJ
40 RCL IND 10
41 8
42 ROTXY
43 255
44 AND
45 STOEL
46 INDEX "M"
47 RCL "C"
48 RCL "B"
49 2
50 +
51 STOIJ
52 RCL IND 10
53 255
54 AND
55 STOEL
56 END

To display a month, the variable A stores the ISG loop counter, for example 1.031 for a 31 day month like March. CAL1 is called to display each of the days of the month. The tens digit is A / 10 and the ones digit is A mod 10. If the tens digit is not zero, we XEQ GMON. GMON is also used to write the ones digit to the matrix.

If (Int(A) + D) mod 7 is equal to 0, then we know that we have reached the end of the week, so C=C+1 and B=E.

Code:
00 { 132-Byte Prgm }
01▸LBL "CAL"
02 60
03 STO "B"
04 1
05 STO "C"
06 STO "D"
07 60
08 STO "E"
09 1.031
10 STO "A"
11▸LBL "CAL1"
12 RCL "A"
13 10
14 ÷
15 IP
16 STO 10
17 X≠0?
18 XEQ "GMON"
19 4
20 STO+ "B"
21 RCL "A"
22 10
23 MOD
24 IP
25 STO 10
26 XEQ "GMON"
27 5
28 STO+ "B"
29 RCL "A"
30 IP
31 RCL "D"
32 +
33 7
34 MOD
35 X≠0?
36 GTO "CAL2"
37 1
38 STO+ "C"
39 RCL "E"
40 STO "B"
41▸LBL "CAL2"
42 ISG "A"
43 GTO "CAL1"
44 RTN
45 END

The main calendar program MCAL first prints the year. Then it prints the names of the months (2 at a time).

The A, B, C and E variables are set up for each month. D is a variable that is updated on an ongoing basis (for example, February starts 3 days later than January (31 mod 7 =3), and May starts 2 days later than April (30 mod 7=2)).

If it’s a leap year, then for February, A=1.029 (count from 1 to 29), and March will start 1 day later (29 mod 7=1).

After 2 months are written to the matrix, XYG0 is called to print 6 rows of the matrix and XYINIT is called to clear the matrix.

Code:
00 { 890-Byte Prgm }
01▸LBL "MCAL"
02 PRX
03 STO 10
04 STO 12
05 3
06 +
07 1.25
08 ×
09 IP
10 2
11 +
12 7
13 MOD
14 STO "D"
15 XEQ "NUMS"
16▸LBL "MC1"
17 XEQ "XYINIT"
18 "JAN        FEB"
19 PRA
20 1.031
21 STO "A"
22 RCL "D"
23 9
24 ×
25 1
26 +
27 STO "B"
28 1
29 STO "C"
30 1
31 STO "E"
32 XEQ "CAL1"
33 1.028
34 STO "A"
35 RCL 12
36 4
37 MOD
38 X≠0?
39 GTO "MC2"
40 1.029
41 STO "A"
42▸LBL "MC2"
43 3
44 STO+ "D"
45 RCL "D"
46 7
47 MOD
48 STO "D"
49 9
50 ×
51 65
52 +
53 STO "B"
54 1
55 STO "C"
56 65
57 STO "E"
58 XEQ "CAL1"
59 XEQ "XYG0"
60 XEQ "XYINIT"
61 1.031
62 STO "A"
63 "MAR        APR"
64 PRA
65 RCL 12
66 4
67 MOD
68 X≠0?
69 GTO "MC3"
70 RCL "D"
71 1
72 +
73 7
74 MOD
75 STO "D"
76▸LBL "MC3"
77 RCL "D"
78 9
79 ×
80 1
81 +
82 STO "B"
83 1
84 STO "C"
85 1
86 STO "E"
87 XEQ "CAL1"
88 1.030
89 STO "A"
90 3
91 STO+ "D"
92 RCL "D"
93 7
94 MOD
95 STO "D"
96 RCL "D"
97 9
98 ×
99 65
100 +
101 STO "B"
102 1
103 STO "C"
104 65
105 STO "E"
106 XEQ "CAL1"
107 XEQ "XYG0"
108 XEQ "XYINIT"
109 1.031
110 STO "A"
111 "MAY        JUN"
112 PRA
113 2
114 STO+ "D"
115 RCL "D"
116 7
117 MOD
118 STO "D"
119 9
120 ×
121 1
122 +
123 STO "B"
124 1
125 STO "C"
126 1
127 STO "E"
128 XEQ "CAL1"
129 1.030
130 STO "A"
131 3
132 STO+ "D"
133 RCL "D"
134 7
135 MOD
136 STO "D"
137 9
138 ×
139 65
140 +
141 STO "B"
142 1
143 STO "C"
144 65
145 STO "E"
146 XEQ "CAL1"
147 XEQ "XYG0"
148 XEQ "XYINIT"
149 1.031
150 STO "A"
151 "JUL        AUG"
152 PRA
153 2
154 STO+ "D"
155 RCL "D"
156 7
157 MOD
158 STO "D"
159 9
160 ×
161 1
162 +
163 STO "B"
164 1
165 STO "C"
166 1
167 STO "E"
168 XEQ "CAL1"
169 1.031
170 STO "A"
171 3
172 STO+ "D"
173 RCL "D"
174 7
175 MOD
176 STO "D"
177 9
178 ×
179 65
180 +
181 STO "B"
182 1
183 STO "C"
184 65
185 STO "E"
186 XEQ "CAL1"
187 XEQ "XYG0"
188 XEQ "XYINIT"
189 1.030
190 STO "A"
191 "SEP        OCT"
192 PRA
193 3
194 STO+ "D"
195 RCL "D"
196 7
197 MOD
198 STO "D"
199 9
200 ×
201 1
202 +
203 STO "B"
204 1
205 STO "C"
206 1
207 STO "E"
208 XEQ "CAL1"
209 1.031
210 STO "A"
211 2
212 STO+ "D"
213 RCL "D"
214 7
215 MOD
216 STO "D"
217 9
218 ×
219 65
220 +
221 STO "B"
222 1
223 STO "C"
224 65
225 STO "E"
226 XEQ "CAL1"
227 XEQ "XYG0"
228 XEQ "XYINIT"
229 1.030
230 STO "A"
231 "NOV        DEC"
232 PRA
233 3
234 STO+ "D"
235 RCL "D"
236 7
237 MOD
238 STO "D"
239 9
240 ×
241 1
242 +
243 STO "B"
244 1
245 STO "C"
246 1
247 STO "E"
248 XEQ "CAL1"
249 1.031
250 STO "A"
251 2
252 STO+ "D"
253 RCL "D"
254 7
255 MOD
256 STO "D"
257 9
258 ×
259 65
260 +
261 STO "B"
262 1
263 STO "C"
264 65
265 STO "E"
266 XEQ "CAL1"
267 XEQ "XYG0"
268 RTN
269▸LBL "XYG0"
270 CLLCD
271 1.044
272 STO "X"
273 1.006
274 STO "Y"
275 CLA
276 GTO "XYG1"
277 END

Here is the (previously posted) code for XY plotting/printing:

Code:
00 { 408-Byte Prgm }
01▸LBL "XYINIT"
02 12
03 132
04 NEWMAT
05 STO "M"
06 RTN
07▸LBL "XYP"
08 INDEX "M"
09 X<>Y
10 STO "Y"
11 8
12 ÷
13 IP
14 1
15 +
16 X<>Y
17 1
18 +
19 STOIJ
20 RCLEL
21 1
22 RCL "Y"
23 8
24 MOD
25 +/-
26 ROTXY
27 OR
28 STOEL
29 RTN
30▸LBL "XYG"
31 CLLCD
32 1.044
33 STO "X"
34 1.012
35 STO "Y"
36 CLA
37▸LBL "XYG1"
38 INDEX "M"
39 RCL "Y"
40 RCL "X"
41 STOIJ
42 RCLEL
43 XTOA
44 ISG "X"
45 GTO "XYG1"
46 1
47 1
48 AGRAPH
49 CLA
50 45.088
51 STO "X"
52▸LBL "XYG2"
53 INDEX "M"
54 RCL "Y"
55 RCL "X"
56 STOIJ
57 RCLEL
58 XTOA
59 ISG "X"
60 GTO "XYG2"
61 1
62 45
63 AGRAPH
64 CLA
65 89.132
66 STO "X"
67▸LBL "XYG3"
68 INDEX "M"
69 RCL "Y"
70 RCL "X"
71 STOIJ
72 RCLEL
73 XTOA
74 ISG "X"
75 GTO "XYG3"
76 1
77 89
78 AGRAPH
79 1
80 STO+ "Y"
81 CLA
82 1.044
83 STO "X"
84▸LBL "XYG4"
85 INDEX "M"
86 RCL "Y"
87 RCL "X"
88 STOIJ
89 RCLEL
90 XTOA
91 ISG "X"
92 GTO "XYG4"
93 9
94 1
95 AGRAPH
96 CLA
97 45.088
98 STO "X"
99▸LBL "XYG5"
100 INDEX "M"
101 RCL "Y"
102 RCL "X"
103 STOIJ
104 RCLEL
105 XTOA
106 ISG "X"
107 GTO "XYG5"
108 9
109 45
110 AGRAPH
111 CLA
112 89.132
113 STO "X"
114▸LBL "XYG6"
115 RCL "Y"
116 RCL "X"
117 STOIJ
118 RCLEL
119 XTOA
120 ISG "X"
121 GTO "XYG6"
122 9
123 89
124 AGRAPH
125 PRLCD
126 CLLCD
127 CLA
128 1.044
129 STO "X"
130 ISG "Y"
131 GTO "XYG1"
132 RTN
133 END
Find all posts by this user
Quote this message in a reply
03-10-2022, 07:31 PM
Post: #2
RE: (Free42) (DM42 or 42S with printer) Calendar Display / Print program
Nice!
It's 2022 and we're still printing calendars like it's 1981.

[Image: attachment.php?aid=10450]


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)