• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Functions for working with the idealized calendar of Planet Xhilr


Commit MetaInfo

修订版7651eb0d212262ea8c202690ccc3cba681773f5d (tree)
时间2017-06-13 17:48:41
作者Joel Matthew Rees <joel.rees@gmai...>
CommiterJoel Matthew Rees

Log Message

side path (bad days added early)

更改概述

差异

--- a/badweekdayshere.fs
+++ b/badweekdayshere.fs
@@ -84,5 +84,32 @@ DECIMAL
8484 : TESTMONTHS ( year -- )
8585 13 0 DO CR DUP I . I MDAYS . CR LOOP DROP ;
8686
87+( UDS* should be good. )
88+: UDS* ( ud u --- uhq ) ( AL AH B --- QL QML QMH )
89+ DUP >R SWAP >R
90+ ( AL B ) UM*
91+ 0 ( ready to sum into )
92+ R> R>
93+ ( AH B ) UM*
94+ D+ ;
95+
96+( I misshandle the return stack here. )
97+( I don't see any advantage to this approach. )
98+( It's just interesting, if I can fix the stack handling. )
99+: UFD* ( ud1 ud2 --- uq ) ( AL AH BL BH --- QL QML QMH QH )
100+ >R ( AL AH BL . BH )
101+ ROT DUP >R ( AH BL AL . BH AL )
102+ ROT DUP >R ( BL AL AH . BH AL AH )
103+ ROT ( AL AH BL )
104+ UDS* ( QL QMLp QMHp . BH AL AH )
105+ R> R> ( AH AL . BH ) SWAP ( AL AH . BH )
106+ R> ( QL QMLp QMHp AL AH BH . )
107+ UDS* ( QL QMLp QMHp QMLq QMHq QHq )
108+ >R >R ( QL QMLp QMHp QMLq . QHq QMHq )
109+ ROT ( QL QMHp QMLq QMLp )
110+ >R 0 R> 0 D+ ( QL QMHp QML QMHpq )
111+ ROT >R 0 R> 0 D+ ( QL QML QMH QHpq )
112+ R> + ;
113+
87114
88115
--- /dev/null
+++ b/econcalendar.fs
@@ -0,0 +1,151 @@
1+( Display a calendar for Bokadakr/Xhilr )
2+( by Ted Turpin of Bokadakr/Xhilr )
3+( Copyright 2017 Joel Matthew Rees )
4+
5+
6+SP@ SP@ - ABS CONSTANT CELLWIDTH
7+
8+
9+12 CONSTANT MPYMONTHS
10+
11+0 VARIABLE DOMDAYS
12+( Modern Forths don't initialize, will leave 0 on stack. )
13+
14+CELLWIDTH - ALLOT ( Back up to store values. )
15+
16+30 C,
17+29 C,
18+30 C,
19+29 C,
20+29 C,
21+30 C,
22+29 C,
23+30 C,
24+29 C,
25+29 C,
26+30 C,
27+29 C,
28+
29+352 CONSTANT YDAYS
30+
31+98 CONSTANT C98
32+343 CONSTANT C343
33+686 CONSTANT C686
34+
35+ 0 CONSTANT SKMONTH
36+ 1 CONSTANT SK1
37+ 4 CONSTANT SK2
38+ 48 CONSTANT SK48
39+186 CONSTANT LP186 ( Must be short1 or short2 within the seven year cycle. )
40+
41+( Since skipyears are the exception, )
42+( we test for skipyears instead of leapyears. )
43+( Calendar system starts with year 0, not year 1. )
44+( Would need to check and adjust if the calendar started with year )
45+: ISKIPYEAR ( year -- flag )
46+ DUP C98 MOD SK48 =
47+ IF DROP -1 ( One specified extra skip year in medium cycle. )
48+ ELSE
49+ DUP 7 MOD DUP
50+ SK1 =
51+ ( Using OR and AND to synthesize conditional math )
52+ ( depends on TRUE being all bits on: -1 on two's complement math architectures. )
53+ SWAP SK2 = OR ( Two specified skip years in short cycle, but ... )
54+ SWAP C686 MOD LP186 = 0= AND ( not the specified exception in the long cycle. )
55+ ENDIF
56+;
57+
58+: PRCH EMIT ;
59+
60+: COMMA 44 PRCH ;
61+: COLON 58 PRCH ;
62+: POINT 46 PRCH ;
63+: LPAREN 40 PRCH ;
64+: RPAREN 41 PRCH ;
65+
66+: MK8YBITS ( startyear --- )
67+ DUP 7 + DO
68+ I ISKIPYEAR 1 AND 0 .R
69+ -1 +LOOP ;
70+
71+: MKYBITS ( maxyear --- )
72+ CR
73+ 0 SWAP
74+ 7 +
75+ 0 DO LPAREN SPACE I 6 .R COLON SPACE RPAREN SPACE
76+ I MK8YBITS COMMA
77+ 1+ DUP 1 AND IF CR ELSE SPACE THEN
78+ 8 +LOOP ;
79+
80+
81+
82+: MDAYS ( year month -- days )
83+ DUP 0 < 0=
84+ OVER 12 < AND 0=
85+ IF
86+ DROP DROP 0 ( Out of range. No days. )
87+ ELSE
88+ DUP DOMDAYS + C@ ( Get the basic days. )
89+ SWAP SKMONTH = ( true if skip month )
90+ ROT ISKIPYEAR AND ( true if skip month of skip year )
91+ 1 AND - ( Subtrahend is 1 only if skip month of skip year. )
92+ ENDIF
93+;
94+
95+
96+
97+( Ancient Forths do not have standard WORDs, )
98+( and that makes it hard to have portable arrays of strings for those Forths. )
99+: TPWDAY ( n --- ) ( TYPE the name of the day of the week. )
100+ DUP 0 = IF ." Sunday " ELSE ( Fake case format to line the strings up. )
101+ DUP 1 = IF ." Moonsday" ELSE
102+ DUP 2 = IF ." Aegisday" ELSE
103+ DUP 3 = IF ." Gefnday" ELSE
104+ DUP 4 = IF ." Freyday" ELSE
105+ DUP 5 = IF ." Tewesday" ELSE
106+ DUP 6 = IF ." Vensday" ELSE ( DUP here allows final single DROP. )
107+ ." ??? "
108+ THEN
109+ THEN
110+ THEN
111+ THEN
112+ THEN
113+ THEN
114+ THEN
115+ DROP ;
116+
117+: TPMONTH ( n --- ) ( TYPE the name of the month. )
118+( DUP 6 < IF * Use this if the compile stack overflows. )
119+ DUP 0 = IF ." Time-division" ELSE ( Fake case format to line the strings up. )
120+ DUP 1 = IF ." Deep-winter " ELSE
121+ DUP 2 = IF ." War-time " ELSE
122+ DUP 3 = IF ." Thaw-time " ELSE
123+ DUP 4 = IF ." Rebirth " ELSE
124+ DUP 5 = IF ." Brides-month" ELSE
125+( ." ???" )
126+( THEN THEN THEN THEN THEN THEN )
127+( ELSE )
128+ DUP 6 = IF ." Imperious " ELSE
129+ DUP 7 = IF ." Senatorious " ELSE
130+ DUP 8 = IF ." False-summer" ELSE
131+ DUP 9 = IF ." Harvest " ELSE
132+ DUP 10 = IF ." Gratitude " ELSE
133+ DUP 11 = IF ." Winter-month" ELSE ( DUP here allows final single DROP. )
134+ ." ???"
135+ THEN
136+ THEN
137+ THEN
138+ THEN
139+ THEN
140+ THEN
141+ ( For 0 to 5: )
142+ THEN
143+ THEN
144+ THEN
145+ THEN
146+ THEN
147+ THEN
148+( THEN )
149+ DROP ;
150+
151+