forked from narke/colorForth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen.asm
176 lines (160 loc) · 2.24 KB
/
gen.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
; gen.nasm colorForth for 80x86 PC generic graphics 2012 Oct 19 Howerd Oakford
;
align 4
frame: dd 0x2000000-hp*vp*2 ; assume 32 meg
displ: dd 0xf0000000 ; fujitsu
fore: dd 0xf7de
xc: dd 0
yc: dd 0
rgb:
ror eax, 8
shr ax, 2
ror eax, 6
shr al, 3
rol eax, 6+5
; and eax, 0xf7de
ret
white:
DUP_
mov eax, 0xffffff
color:
call rgb
mov dword [fore], eax
DROP
ret
fifof:
DROP
graphic:
ret
switch:
push esi
mov esi, dword [frame]
push edi
mov edi, dword [displ]
mov ecx, hp*vp/2
rep movsd
pop edi
pop esi
jmp pause
clip:
mov edi, [xy]
mov ecx, edi
test cx, cx
jns Xclip1
xor ecx, ecx
Xclip1: and ecx, 0x0ffff
mov [yc] , ecx
imul ecx, hp*2
sar edi, 16
jns Xclip2
xor edi, edi
Xclip2: mov [xc], edi
lea edi, [edi*2+ecx]
add edi, [frame]
ret
bit16: lodsw
xchg al, ah
mov ecx, 16
Xb16: shl ax, 1
jnc Xb162
mov [edi], dx
Xb162: add edi, byte 2
NEXT Xb16
ret
bit32: lodsw
xchg al, ah
mov ecx, 16
b32: shl eax, 1
jnc Xb322
mov [edi], dx
mov [edi+2], dx
mov [edi+hp*2], dx
mov [edi+hp*2+2], dx
Xb322: add edi, byte 4
NEXT b32
ret
emit:
call qcr
push esi
push edi
push edx
imul eax, byte 16*24/8
lea esi, [icons+eax]
call clip
mov edx, [fore]
mov ecx, 24
.em: push ecx
call bit16
add edi, (hp-16)*2
pop ecx
NEXT .em
pop edx
pop edi
pop esi
bl_: DROP
space: add dword [xy], iw*0x10000
ret
emit2:
push esi
push edi
push edx
imul eax, byte 16*24/8
lea esi, [icons+eax]
call clip
mov edx, [fore]
mov ecx, 24
.em2: push ecx
call bit32
add edi, (2*hp-16*2)*2
pop ecx
NEXT .em2
pop edx
pop edi
pop esi
add dword [xy], iw*0x10000*2
DROP
ret
text1:
call white
mov dword [lm], 3
mov dword [rm], hc*iw
jmp top
line:
call clip
mov ecx, [esi]
shl ecx, 1
sub edi, ecx
mov ecx, eax
mov eax, [fore]
rep stosw
inc dword [xy]
DROP
DROP
ret
box:
call clip
cmp eax, vp+1
js .bo1
mov eax, vp
.bo1 mov ecx, eax
sub ecx, dword [yc]
jng nob
cmp dword [esi], hp+1
js .bo2
mov dword [esi], hp
.bo2 mov eax, [xc]
sub [esi], eax
jng nob
mov edx, hp
sub edx, [esi]
shl edx, 1
mov eax, [fore]
.bo3 push ecx
mov ecx, [esi]
rep stosw
add edi, edx
pop ecx
NEXT .bo3
nob: DROP
DROP
ret