-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlang.pas
More file actions
267 lines (250 loc) · 5.76 KB
/
lang.pas
File metadata and controls
267 lines (250 loc) · 5.76 KB
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
uses Atari,zx5;
const
{$I 'memory-lang.inc'}
{$R 'lang.rc'}
{$I 'memory-loader.inc'}
{$R 'loader.rc'}
TOP_SELECTOR: Array[0..13] of byte = (
$8C, $8D, $8E, $8E, $8E, $8E, $8E, $8E, $8E, $8E, $8E, $8E, $8F, $90
);
BTM_SELECTOR: Array[0..13] of byte = (
$A2, $A3, $A4, $A4, $A4, $A4, $A4, $A4, $A4, $A4, $A4, $A4, $A5, $A6
);
DLIST_LINE_ADDR:Array[0..7] of word = (
DLIST_ADDR+14+0*3,
DLIST_ADDR+14+1*3,
DLIST_ADDR+14+2*3,
DLIST_ADDR+14+3*3,
DLIST_ADDR+14+4*3,
DLIST_ADDR+14+5*3,
DLIST_ADDR+14+6*3,
DLIST_ADDR+14+7*3
);
var
VDL:pointer absolute $230;
VCH:byte absolute 756;
SCREEN_FLAG_LINE_ADDR:Array[0..7] of word = (
FLAGS_BEGIN_ADDR+0*FLAGS_LINE_WIDTH,
FLAGS_BEGIN_ADDR+1*FLAGS_LINE_WIDTH,
FLAGS_BEGIN_ADDR+2*FLAGS_LINE_WIDTH,
FLAGS_BEGIN_ADDR+3*FLAGS_LINE_WIDTH,
FLAGS_BEGIN_ADDR+4*FLAGS_LINE_WIDTH,
FLAGS_BEGIN_ADDR+5*FLAGS_LINE_WIDTH,
FLAGS_BEGIN_ADDR+6*FLAGS_LINE_WIDTH,
FLAGS_BEGIN_ADDR+7*FLAGS_LINE_WIDTH
);
scrOfs,
nscrOfs,
scrDx:shortint;
sel:shortint;
i,j:byte;
dptr:pointer;
oldDLVec:pointer;
oldScrVec:pointer;
oCol:Array[0..4] of byte;
tm:Byte absolute $14;
otm:Byte;
Fire:byte absolute $284;
joy:Byte absolute $278;
oJoy:Byte;
key:Byte absolute 764;
oKey:Byte;
dir:byte;
adr1,adr2:word;
{$I 'asm/sfx.pas'}
procedure delay(ticks:Byte); Assembler;
asm
lda ticks
beq endDelay
loopDelay:
lda $14
cmp $14
beq *-2
dec ticks
bne loopDelay
endDelay:
end;
procedure init;
begin
oldDLVec:=pointer(VDL);
SFX_Init;
VDL:=pointer(DLIST_ADDR);
VCH:=CHARSET1_PAGE;
for i:=0 to 4 do oCol[i]:=peek(708+i);
poke(708,$26);
poke(709,$0e);
poke(710,$72);
poke(711,$ea);
poke(712,$00);
fillchar(pointer(SCREEN_ADDR),SCREEN_SIZE,$B3);
end;
procedure drawSelector(x:byte);
begin
move(@TOP_SELECTOR,pointer(TOP_SELECTOR_ADDR+x),14);
move(@BTM_SELECTOR,pointer(BTM_SELECTOR_ADDR+x),14);
adr2:=FLAGS_BEGIN_ADDR+FLAGS_LINE_WIDTH+x;
for j:=0 to 5 do
begin
poke(adr2,$91);
inc(adr2,13);
poke(adr2,$91);
inc(adr2,FLAGS_LINE_WIDTH-13);
end;
end;
procedure drawFlags();
begin
fillchar(pointer(TOP_SELECTOR_ADDR),FLAGS_LINE_WIDTH,$B3);
fillchar(pointer(BTM_SELECTOR_ADDR),FLAGS_LINE_WIDTH,$B3);
for i:=0 to 3 do
begin
adr1:=FLAGS_ADDR+i*FLAG_SIZE;
adr2:=FLAGS_BEGIN_ADDR+FLAGS_LINE_WIDTH+(i+1)*13+1;
for j:=0 to 5 do
begin
poke(adr2-1,$b3);
poke(adr2+12,$b3);
move(pointer(adr1),pointer(adr2),12);
inc(adr1,12);
inc(adr2,FLAGS_LINE_WIDTH);
end;
end;
drawSelector(sel*13);
end;
procedure scrollFlags;
begin
for i:=0 to 7 do
dpoke(DLIST_LINE_ADDR[i],SCREEN_FLAG_LINE_ADDR[i]+scrOfs);
end;
procedure load_cz();
begin
GetResourceHandle(dptr,'letters_cz');
unZX5(dptr,pointer(LETTERS));
GetResourceHandle(dptr,'title_b_cz');
unZX5(dptr,pointer(TITLE_B));
GetResourceHandle(dptr,'scl_cz');
unZX5(dptr,pointer(SCROLLS));
GetResourceHandle(dptr,'STR_cz');
unZX5(dptr,pointer(STRINGS));
end;
procedure load_pl();
begin
GetResourceHandle(dptr,'letters_plen');
unZX5(dptr,pointer(LETTERS));
GetResourceHandle(dptr,'title_b_plen');
unZX5(dptr,pointer(TITLE_B));
GetResourceHandle(dptr,'scl_pl');
unZX5(dptr,pointer(SCROLLS));
GetResourceHandle(dptr,'STR_pl');
unZX5(dptr,pointer(STRINGS));
end;
procedure load_en();
begin
GetResourceHandle(dptr,'letters_plen');
unZX5(dptr,pointer(LETTERS));
GetResourceHandle(dptr,'title_b_plen');
unZX5(dptr,pointer(TITLE_B));
GetResourceHandle(dptr,'scl_en');
unZX5(dptr,pointer(SCROLLS));
GetResourceHandle(dptr,'STR_en');
unZX5(dptr,pointer(STRINGS));
end;
procedure load_de();
begin
GetResourceHandle(dptr,'letters_de');
unZX5(dptr,pointer(LETTERS));
GetResourceHandle(dptr,'title_b_de');
unZX5(dptr,pointer(TITLE_B));
GetResourceHandle(dptr,'scl_de');
unZX5(dptr,pointer(SCROLLS));
GetResourceHandle(dptr,'STR_de');
unZX5(dptr,pointer(STRINGS));
end;
begin
init;
sel:=1;
drawFlags;
scrOfs:=$0;
nscrOfs:=$0;
scrollFlags;
otm:=tm;
repeat
if (joy<>oJoy) or (key<>oKey) or (Fire=0) then
begin
if Fire=0 then key:=12;
if (joy<>15) or (key<>255) then
begin
dir:=0;
if (joy=11) or (key=6) then dir:=1;
if (joy= 7) or (key=7) then dir:=2;
if dir<>0 then SFX_Play(0,50,3-dir);
case dir of
1: begin
dec(sel); if sel<1 then sel:=4;
dec(nscrOfs,13);
if nscrOfs<0 then inc(nscrOfs,13*4);
drawFlags;
end;
2: begin
inc(sel); if sel>4 then sel:=1;
inc(nscrOfs,13);
if nscrOfs>13*4-1 then dec(nscrOfs,13*4);
drawFlags;
end;
end;
end;
oJoy:=joy; oKey:=key; key:=255;
end;
if (byte(tm-otm)>0) then
begin
otm:=tm;
if nscrOfs<>scrOfs then
begin
if nscrOfs<scrOfs then
begin
dec(scrOfs,1);
if scrOfs<0 then scrOfs:=13*4-1;
end;
if nscrOfs>scrOfs then
begin
inc(scrOfs,1);
if scrOfs>13*4-1 then scrOfs:=0;
end;
scrollFlags;
end;
end;
until (oKey=28) or (oKey=12);
tm:=0;
if oKey=12 then
begin
poke(559,0);
SFX_Play(0,50,0);
case sel of
1: load_pl;
2: load_cz;
3: load_en;
4: load_de;
end;
end;
repeat until tm>25;
SFX_Done;
if oKey=28 then
begin
VCH:=$e0;
for i:=0 to 4 do poke(708+i,oCol[i]);
VDL:=pointer(oldDLVec);
asm
jmp (dosvec)
end;
end;
GetResourceHandle(dptr,'LOADER');
unZX5(dptr,pointer(FNT));
poke(559,%100001);
dpoke(560,DLIST);
poke(756,hi(FNT));
poke(708,$96);
poke(709,$98);
poke(710,$0f);
poke(711,$c8);
poke(712,$00);
dpoke($13,0);
end.