-
Notifications
You must be signed in to change notification settings - Fork 1
/
SP-Forth-prep.txt
120 lines (95 loc) · 2.3 KB
/
SP-Forth-prep.txt
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
\ Preparation for SP-Forth
REQUIRE case-ins lib/ext/caseins.f
REQUIRE LOCALS| ~af/lib/locals-ans.f
REQUIRE { lib/ext/locals.f
REQUIRE M*/ lib/include/double.f
REQUIRE F. lib/include/float2.f
REQUIRE /STRING lib/include/string.f
REQUIRE INCLUDED devel/~ygrek/spf/included.f
: <= > 0= ;
: >= < 0= ;
CASE-INS ON
WINAPI: GetTickCount KERNEL32.DLL
WINAPI: SetConsoleCursorPosition KERNEL32.DLL
WINAPI: GetConsoleScreenBufferInfo KERNEL32.DLL
WINAPI: FillConsoleOutputCharacterA KERNEL32.DLL
0 2 -- off_x
2 -- off_y
CONSTANT /coord
0 2 -- Left
2 -- Top
2 -- Right
2 -- Bottom
CONSTANT /rect
0 /coord -- Size
/coord -- Position
2 -- Attrib
/rect -- Window
/coord -- Dimensions
CONSTANT /buffer
CREATE buffer /buffer ALLOT
: xy@ \ addr -- x y
DUP off_x W@ SWAP off_y W@ ;
: GETXY \ -- x y
buffer H-STDOUT GetConsoleScreenBufferInfo DROP
buffer Position xy@ ;
: SETXY \ x y --
16 LSHIFT OR H-STDOUT SetConsoleCursorPosition DROP ;
: ~chars \ char # --
SP@ GETXY 16 LSHIFT OR 2SWAP SWAP H-STDOUT
FillConsoleOutputCharacterA DROP ;
: PAGE 0 0 SETXY BL
buffer H-STDOUT GetConsoleScreenBufferInfo DROP
buffer Size ~chars ;
\ : fround 1.e 2.e f/ f+ fint ;
: utime GetTickCount 1000 um* ;
: under+ rot + swap ;
: .r \ n i --
>r dup 0< swap abs
0 <# #S rot sign #>
R> OVER - SPACES TYPE ;
\ CASE-OF STRUCTURE
: CASE \ -- 0
0 ; IMMEDIATE \ initial count of ofs
: OF \ c: #of -- orig #of+1
\ x --
1+ >R
POSTPONE OVER
POSTPONE =
[COMPILE] IF
POSTPONE DROP
R> ; IMMEDIATE
: ENDOF \ c: orig1 #of -- orig2 #of
>R [COMPILE] ELSE R> ; IMMEDIATE
: ENDCASE \ c: orig1..orign #of --
POSTPONE drop \ discard case value
0 ?DO [COMPILE] THEN LOOP ; IMMEDIATE \ generate targets
: f>s f>d drop ;
: s>f 0 d>f ;
: OK2 ( -- ) STATE @ IF EXIT THEN ." ok" CR ;
' OK2 TO OK
false [if]
\ _SYSTEMTIME
0
2 -- wYear
2 -- wMonth
2 -- wDayOfWeek
2 -- wDay
2 -- wHour
2 -- wMinute
2 -- wSecond
2 -- wMilliseconds
CONSTANT /SYSTEMTIME
CREATE SYSTEMTIME /SYSTEMTIME ALLOT
WINAPI: GetLocalTime KERNEL32.DLL
\ WINAPI: GetTickCount KERNEL32.DLL
: TIME&DATE \ -- sec min hr day mt year
SYSTEMTIME GetLocalTime DROP
SYSTEMTIME wSecond W@
SYSTEMTIME wMinute W@
SYSTEMTIME wHour W@
SYSTEMTIME wDay W@
SYSTEMTIME wMonth W@
SYSTEMTIME wYear W@
;
[then]