-
Notifications
You must be signed in to change notification settings - Fork 0
/
DESOLA.MAC
571 lines (528 loc) · 15.9 KB
/
DESOLA.MAC
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
.TITLE DESOLA
.MCALL .EXIT
.MACRO PUSH RR
MOV RR,-(SP)
.ENDM
.MACRO POP RR
MOV (SP)+,RR
.ENDM
;------------------------------------------------------------------------------
; Cheat codes on/off
CHROMN=0 ; Show room number at the bottom-left
CHACCE=0 ; All door access codes entered already
CHAINV=0 ; Have all inventory items
CHWEAP=0 ; Have the weapon
CHELTH=0 ; Health 999
;------------------------------------------------------------------------------
SCRTOP=115110 ; Íà÷àëî ýêðàíà, êîñâåííûé àäðåñ äëÿ ÓÊÍÖ
;------------------------------------------------------------------------------
.ASECT
.=001000
START::
CLR @#177560
MOV #GAMESC, R1 ; Ñòðîêà äëÿ ïîäãîòîâêè èãðîâîãî ýêðàíà
CALL PRINT
MOV #15., R2
STARTA: MOV #GAMES1, R1 ; Ñòðîêà äëÿ óñëîâíîé èíâåðñèè èãðîâîé ÷àñòè ýêðàíà
CALL PRINT
SOB R2, STARTA
CALL PRINT ; Ïå÷àòàåì ñòðîêó äëÿ óñòàíîâêè êóðñîðà
CALL PAUSE ; ïîäîæä¸ì ïîêà î÷èñòèòñÿ ýêðàí
CALL STHEMN ; Óñòàíîâêà íóæíîé íàì ïàëèòðû
; LDBF5 óæå ñîäåðæèò ïåðâûå òðè ñòðîêè òèòóëüíîãî ýêðàíà ñ íàäïèñüþ DESOLATE
; Ïîëó÷àåì òåíåâîé ýêðàí èç òàéëîâ è êîïèðóåì íàäïèñü DESOLATE íà ýêðàí ÓÊÍÖ
CALL CLSHAD ; î÷èñòêà òåíåâîãî ýêðàíà
MOV #LDBF5, R3
CALL LB177 ; Display screen from tiles with Tileset2
CALL CTITLE
CALL CLSHAD ; î÷èñòêà òåíåâîãî ýêðàíà
; Çàïóñê
CALL LBA07 ; Show titles and go to Menu
.IF NE CHACCE ; Cheat code to get all door access codes
MOV #<DLLENT+1>, R3
MOV #4., R1
START1: MOVB #001, (R3)+
SOB R1, START1
.ENDC
.IF NE CHAINV ; Cheat code to have all inventory items
MOV #LDB9C, R3
MOV #26., R1
START2: MOVB #001, (R3)+
SOB R1, START2
.ENDC
.IF NE CHWEAP ; Cheat code to have the weapon
MOVB #001, @#LDCF7
.ENDC
.IF NE CHELTH ; Cheat code to have health 999
MOV #999., @#LDB7A
.ENDC
; CALL LBA3D ; Menu
; CALL LB0A2 ; Inventory
; CALL LBBEC ; Info menu item, show Controls
; CALL LBADE ; New game
; CALL LBB7E ; Game start
; CALL LB9A2 ; Player is dead
; CALL LBD85 ; Final
; CALL LBF6F ; The End
; CALL LBF81 ; Credits
; CALL SHOWSC
; CALL WTKEY
FINISH:
CALL STHEMD ; Âåðíóòü ñòàíäàðòíóþ ïàëèòðó
MOV #EXITSC, R1 ; Ñòðîêà î÷èñòêè ýêðàíà ïåðåä âûõîäîì
CALL PRINT
.EXIT
GAMESC: ; Ñòðîêà ïîäãîòîâêè èãðîâîãî ýêðàíà
.BYTE 033,246,62 ; Ôîðìàò ýêðàíà 40x24
.BYTE 033,240,61 ; Öâåò ñèìâîëà
.BYTE 033,241,60 ; Öâåò çíàêîìåñòà 0
.BYTE 033,242,60 ; Öâåò ôîíà 0
.BYTE 14 ; Clear screen
.BYTE 033,243 ; ðåæèì èíâåðñèè
.BYTE 033,131,46,40 ; Êóðñîð â ïîçèöèþ
.BYTE 0
; Ñòðîêà äëÿ ïîäñâåòêè èãðîâîé îáëàñòè
GAMES1: .ASCIZ <031><031><031><031><031><031>/ /<015><012>
GAMES2: .BYTE 033,277,243 ; îòìåíà èíâåðñèè
.BYTE 033,131,66,40 ; Êóðñîð â ïîçèöèþ
.BYTE 0
EXITSC: ; Ñòðîêà î÷èñòêè ýêðàíà ïåðåä âûõîäîì
.BYTE 033,246,061 ; Ôîðìàò ýêðàíà 80x24
.BYTE 033,240,67 ; Öâåò ñèìâîëà
.BYTE 033,241,61 ; Öâåò çíàêîìåñòà 1
.BYTE 033,242,61 ; Öâåò ôîíà 1
.BYTE 14 ; Î÷èñòèòü ýêðàí
.BYTE 0
.EVEN
;------------------------------------------------------------------------------
; Ïàëèòðà äëÿ óñòàíîâêè â ïàìÿòè ÏÏ
PALETN: .WORD ^B1101110000000000 ; èãð.ýêð.1, ???, èãð.ýêð.0, îáùèé ôîí
.WORD ^B0000100010100111 ; ???, ???, ???, çàãîëîâîê
PALETL: .WORD ^B0000110011110000 ; èãð.ýêð.1, ???, èãð.ýêð.0, îáùèé ôîí
.WORD ^B0000100010100111 ; ???, ???, ???, çàãîëîâîê
; ====----====----
PALETD: .WORD 135230, 177334 ; Ïàëèòðà ÓÊÍÖ ïî óìîë÷àíèþ
; ScreenThemeNite - switching to dark theme for story mode
STHEMN:
MOV #PALETN, @#PPBACP
BR PPSEND
; ScreenThemeLite - switching to light theme
STHEML:
MOV #PALETL, @#PPBACP
BR PPSEND
; Âåðíóòü ñòàíäàðòíóþ ïàëèòðó
STHEMD:
MOV #PALETD, @#PPBACP
BR PPSEND
; Ìàññèâ ïàðàìåòðîâ äëÿ îáìåíà ñ ÏÏ ïî êàíàëó 2
PPBLCK: .BYTE 0 ; Â ýòîì áàéòå áóäåò ñîäåðæàòüñÿ êîä îøèáêè èëè 0
PPBCMD: .BYTE 20 ; Êîìàíäà (01-ÂÛÄÅËÈÒÜ ÏÀÌßÒÜ, 02-ÎÑÂÎÁÎÄÈÒÜ ÏÀÌßÒÜ 10-×ÒÅÍÈÅ, 20-ÇÀÏÈÑÜ, 30-ÏÓÑÊ)
.WORD 32 ; Óñòðîéñòâî - ïåðèôåðèéíûé ïðîöåññîð
PPBAPP: .WORD 002470 ; Àäðåñ ÎÇÓ ÏÏ - äâà ñëîâà ïàëèòðû
PPBACP: .WORD PALETL ; Àäðåñ ÎÇÓ ÖÏ - àäðåñ íîâîé ïàëèòðû
.WORD 2 ; Äëèíà áëîêà â ñëîâàõ
PPBADR: .WORD PPBLCK ; Ñëîâî âñåãäà ñîäåðæèò íà÷àëüíûé àäðåñ ìàññèâà ïàðàìåòðîâ
.WORD 401 ; Ñòîïîâûé ýëåìåíò (èñïîëüçóåòñÿ ïðè ïåðåäà÷å)
; Ïîäïðîãðàììà ïåðåäà÷è ïî êàíàëó Ê2 ìàññèâà ïàðàìåòðîâ â ÏÏ
PPSEND: MOV #PPBADR, R0
MOV #5, R1
MTPS #200
BR 1$
2$: MOVB (R0)+, @#176676
1$: TSTB @#176674
BPL 1$
SOB R1, 2$
MTPS #0
RETURN
;------------------------------------------------------------------------------
; Ïîäïðîãðàììà: Ïå÷àòü ñòðîêè: R1 = àäðåñ ñòðîêè, ñòðîêà çàâåðøàåòñÿ 0; ïîðòèò R0
; Ïîñëå çàâåðøåíèÿ R1 óêàçûâàåò íà áàéò ñëåäóþùèé çà 0
PRINT:
10$: MOVB (R1)+, R0 ; Êîíåö ñòðîêè?
BEQ RETN ; äà => âûõîäèì
20$: TSTB @#177564 ; Èñòî÷íèê êàíàëà 0 ãîòîâ?
BPL 20$ ; íåò => æä¸ì
MOV R0, @#177566 ; ïåðåäà¸ì ñèìâîë â êàíàë 0
BR 10$
; Ïîäïðîãðàììà: ïàóçà ïîñëå î÷èñòêè ýêðàíà ÷òîáû ÏÏ çàêîí÷èë ðàáîòó
PAUSE: ; Pause to let PPU finish the previous commands
MOV #177777, R5
1$: NOP
SOB R5, 1$
RETN: RETURN
; Ïîäïðîãðàììà: Îæèäàíèå ñèìâîëà ñ êëàâèàòóðû: R0 = ïîëó÷åííûé ñèìâîë
WTKEY: TSTB @#177560
BPL WTKEY
CLR R0
MOVB @#177562, R0 ; ñèìâîë â R0
CMPB R0, #33
BNE RETN
ESCKEY: TSTB @#177560
BPL ESCKEY
MOVB @#177562, R0 ; ñèìâîë â R0
BIS #15400,R0 ; #33 â âåðõíèé áàéò
RETURN
; Ïîäïðîãðàììà: Ïîëó÷åíèå ñèìâîëà ñ êëàâèàòóðû: ôëàã Z=0 = åñòü ñèìâîë, R0 = ïîëó÷åííûé ñèìâîë
GETKEY: TSTB @#177560 ; åñòü ñèìâîë?
BPL 10$ ; íåò ñèìâîëà => âûõîäèì
MOVB @#177562, R0 ; ñèìâîë â R0
CMPB R0, #33 ; Esc ?
BEQ ESCKEY
RETURN
10$: CLR R0 ; âîçâðàùàåì ïóñòîé êîä êëàâèøè
RETURN
;------------------------------------------------------------------------------
; Wait for any key
WAITAN:
CALL WAITUP
CALL WTKEY
RETURN
;
; Wait until no key pressed - to put after ReadKeyboard calls to prevent double-reads of the same key
WAITUP:
;TODO
RETURN
;
; Get shadow screen address using penCol in L86D7
; R0 = row 0..139
; (L86D7) = penCol 0..191
; Returns R3 = address
GSADDR:
ASL R0
MOV R0, R3
ASL R3 ; now R3 = row * 4
ADD R0, R3 ; now R3 = row * 6
ASL R3 ; now R3 = row * 12
ASL R3 ; now R3 = row * 24
; MOV MUL24D(R0), R3 ; R3 = row * 24
ADD #SHADOW, R3
MOVB @#L86D7, R0 ; get penCol
BIC #177400, R0
ASR R0
ASR R0
ASR R0 ; now A = 8px column
ADD R0, R3 ; now R3 = line address + column
RETURN
; Draw tile with mask 16x16 -> 16x16 on shadow screen - for Tileset2 tiles
; R3 = row 0..127; R2 = col 0..191; R4 = tile address
DRTIL2:
MOV R3, R0 ; penRow
MOV R2, @#L86D7 ; penCol
CALL GSADDR ; now R3 = screen addr
MOV #8., R1 ; 8 row pairs
MOV #24., R2 ; line increment
DRTILA:
; 1st line
MOV (R3), R0 ; get shadow screen bits
BIC (R4)+, R0 ; apply mask
BIS (R4)+, R0 ; use pixels
MOV R0, (R3) ; write the result
ADD R2, R3 ; next line
; 2nd line
MOV (R3), R0 ; get shadow screen bits
BIC (R4)+, R0 ; apply mask
BIS (R4)+, R0 ; use pixels
MOV R0, (R3) ; write the result
ADD R2, R3 ; next line
; Contine the loop
SOB R1, DRTILA
RETURN
; Draw string on shadow screen using FONTPR font
; R3 = string addr
DRSTR:
MOVB (R3)+, R0
BNE DRSTR1
RETURN
DRSTR1:
CALL DRCHAR
BR DRSTR
;
; Draw decimal number R3 in 5 digits
DRNUM5: MOV #10000., R1
CALL DRNUM1
MOV #1000., R1
CALL DRNUM1
; Draw decimal number R3 in 3 digits
DRNUM3: MOV #100., R1
CALL DRNUM1
MOV #10., R1
CALL DRNUM1
MOV #1., R1
DRNUM1: MOV #<060-1>, R0
DRNUM2: INC R0
SUB R1, R3
BHIS DRNUM2
ADD R1, R3
; JMP DRCHAR
;
; Draw character on the screen using FONTPR font
; R0 = character to show: $00-$1F space with R0 width; $20 space
; Preserves: R1, R3
DRCHAR:
PUSH R3 ; push hl
PUSH R1 ; push bc
CMPB R0, #040 ; cp $20 ; $00-$1F ?
BLO DRCH00 ; jr c,DrawChar_00 ; yes => set char width and process like space char
BNE DRCHR0 ; jr nz,DrawChar_0 ; not space char => jump
MOV #003, R0 ; ld a,$03 ; space char gap size
DRCH00: ; DrawChar_00:
MOVB R0, @#DRCHRW ; ld (DrawChar_width),a
BR DRCHRF ; jp DrawChar_fin
DRCHR0: ; DrawChar_0:
CMPB R0, #047 ; cp $27 ; char less than apostroph?
BHIS DRCHR1 ; jr nc,DrawChar_1
ADD #072, R0 ; add a,$3A ; for '!', quotes, '#' '$' '%' '&'
BR DRCHR2 ; jr DrawChar_2
DRCHR1: ; DrawChar_1:
CMPB R0, #052 ; cp $2A ; char less than '*'?
BHIS DRCHR2 ; jr nc,DrawChar_2
ADD #025, R0 ; add a,$15 ; for apostroph, '(' ')' chars
DRCHR2: SUB #054, R0 ; sub $2C ; font starts from ','
MOV R0, R2 ; ld e,a / ld l,a ; calculating the symbol address
ADD R2, R2 ; add hl,hl ; now hl = a * 2
ADD R2, R2 ; add hl,hl ; now hl = a * 4
ADD R0, R2 ; add hl,de ; now hl = a * 5
ADD R2, R2 ; add hl,hl ; now hl = a * 10
ADD R0, R2 ; add hl,de ; now hl = a * 11
ADD #FONTPR, R2 ; ld de,FontProto / add hl,de / ex de,hl ; now de=symbol addr
CLR R0 ;NOTE: Íîìåð ñòðîêè ìîæåò áûòü áîëüøå 127!
BISB @#L86D8, R0 ; ld a,(L86D8) ; get penRow
MOV R0, @#DRCHRO ; ld (DrawChar_row),a
MOVB (R2)+, R0 ; ld a,(de) / inc de ; get flag/width byte
BIT #200, R0 ; bit 7,a ; lowered symbol?
BEQ DRCHR3 ; jr z,DrawChar_3
INC @#DRCHRO ; ld hl,DrawChar_row / inc (hl) ; start on the next line
DRCHR3: ; DrawChar_3:
BIC #177760, R0 ; and $0f ; keep width 1..8
ADD #002, R0 ; add a,$02 ; gap 2px after the symbol
MOVB R0, @#DRCHRW ; ld (DrawChar_width),a
MOV @#DRCHRO, R0 ; ld a,(DrawChar_row)
CALL GSADDR ; call GetScreenAddr
PUSH R3 ; push hl ; store addr on the screen
PUSH R2 ; push de ; store symbol data addr
MOVB @#L86D7, R0 ; ld a,(L86D7) ; get penCol
BIC #177770, R0 ; and $07 ; shift 0..7
INC R0 ; inc a
MOV R0, R4 ; ld c,a
MOV #10., R1 ; ld b,10 ; 10 lines
DRCHR4: PUSH R4 ; DrawChar_4: ; loop by lines
PUSH R1 ; push bc ; save counter
MOVB (R2)+, R0 ; ld a,(de) / inc de
DRCHR5: ; DrawChar_5: ; loop for shift
DEC R4 ; dec c
BEQ DRCHR6 ; jr z, DrawChar_6
ASL R0 ; srl a ; shift right
BR DRCHR5 ; jr DrawChar_5
DRCHR6: ; DrawChar_6:
BISB R0, (R3) ; or (hl) / ld (hl),a ; put on the screen
MOV @#DRCHRO, R0 ; ld a,(DrawChar_row)
INC R0 ; inc a
MOV R0, @#DRCHRO ; ld (DrawChar_row),a
CALL GSADDR ; call GetScreenAddr
POP R1 ; pop bc ; restore counter and shift
POP R4
SOB R1, DRCHR4 ; djnz DrawChar_4
POP R2 ; pop de ; restore symbol data addr
POP R3 ; pop hl ; restore addr on the screen
MOVB @#L86D7, R0 ; ld a,(L86D7) ; get penCol
BIC #177770, R0 ; and $7 ; shift 0..7
MOV R0, R1 ; ld b,a
MOVB @#DRCHRW, R0 ; ld a,(DrawChar_width)
ADD R1, R0 ; add a,b
CMPB R0, #010 ; cp $08 ; shift + width <= 8 ?
BLO DRCHRF ; jr c,DrawChar_fin ; yes => no need for 2nd pass
; Second pass
MOVB @#L86D7, R0 ; ld a,(L86D7) ; get penCol
BIC #177770, R0 ; and $07 ; shift 1..7
SUB #8., R0 ; sub $08
COM R0 ; neg ; a = 8 - shift; result is 1..7
INC R0 ; inc a
INC R0
MOV R0, R4 ; ld c,a
MOV @#DRCHRO, R0 ; ld a,(DrawChar_row)
SUB #10., R0 ; add a,-10
MOV R0, @#DRCHRO ; ld (DrawChar_row),a
INC R3 ; inc hl
MOV #10.,R1 ; ld b,10 ; 10 lines
DRCHR8: PUSH R4 ; DrawChar_8: ; loop by lines
PUSH R1 ; push bc ; save counter
MOVB (R2)+, R0 ; ld a,(de) / inc de
BIC #177400, R0
DRCHR9: ; DrawChar_9: ; loop for shift
DEC R4 ; dec c
BEQ DRCHRA ; jr z, DrawChar_A
ASR R0 ; sla a ; shift left
BR DRCHR9 ; jr DrawChar_9
DRCHRA: ; DrawChar_A:
BISB R0, (R3) ; or (hl) / ld (hl),a ; put on the screen
MOV @#DRCHRO, R0 ; ld a,(DrawChar_row)
INC R0 ; inc a
MOV R0, @#DRCHRO ; ld (DrawChar_row),a
CALL GSADDR ; call GetScreenAddr
INC R3 ; inc hl
POP R1 ; pop bc ; restore counter
POP R4
SOB R1, DRCHR8 ; djnz DrawChar_8
DRCHRF: ; DrawChar_fin: ; All done, finalizing
MOV #L86D7, R3 ; ld hl,L86D7 ; penCol address
MOVB @#DRCHRW, R0 ; ld a,(DrawChar_width)
MOVB (R3), R5 ; add a,(hl)
BIC #177400, R5
ADD R5, R0
MOVB R0, (R3) ; ld (hl),a ; updating penCol
POP R1 ; pop bc
POP R3 ; pop hl
RETURN ; ret
DRCHRO: .WORD 0 ; DrawChar_row: DB 0 ; Saved current row number
DRCHRW: .BYTE 0 ; DrawChar_width: DB 0 ; Saved symbol width
.EVEN
; Copy DEDSOLATE title from Main Menu shadow screen to UKNC screen
CTITLE:
MOV #<SHADOW+192.>, R2
MOV #103610, R4 ; Àäðåñ â ÂÎÇÓ ÓÊÍÖ
MOV #30., R3 ; êîëè÷åñòâî ñòðîê
CTITL1: MOV #24., R5 ; 24. êîëîíêè â ñòðîêå
MOV #176640, R1 ; Àäðåñ ïîðòà àäðåñà êîñâåííîé çàïèñè ÓÊÍÖ
CTITL2:
CLR R0
BISB (R2)+, R0 ; áåð¸ì 8 ïèêñåëîâ
SWAB R0
MOV R4, (R1) ; ïèøåì àäðåñ
MOV R0, @#176642 ; ïèøåì â ÂÎÇÓ ÓÊÍÖ
INC R4 ; ê ñëåäóþùåé êîëîíêå
SOB R5, CTITL2 ; Êîíåö öèêëà ïî ñòðîêå
ADD #070, R4 ; ê ñëåäóþùåé ñòðîêå ýêðàíà ÓÊÍÖ
SOB R3, CTITL1 ; Êîíåö öèêëà ïî ñòðîêàì
RETURN
;
; Copy shadow screen 24*128=3072 bytes to UKNC screen
; ShowShadowScreen:
SHOWSC:
MOV #SHADOW, R2
MOV #SCRTOP, R4 ; Àäðåñ â ÂÎÇÓ ÓÊÍÖ
MOV #128., R3 ; êîëè÷åñòâî ñòðîê
SHOWS1: ; Íà÷àëî öèêëà ïî ñòðîêàì
MOV #6., R5 ; 24. êîëîíêè â ñòðîêå
MOV #176640, R1 ; Àäðåñ ïîðòà àäðåñà êîñâåííîé çàïèñè ÓÊÍÖ
SHOWS2: ; Íà÷àëî öèêëà ïî ñòðîêå
; 1
CLR R0
BISB (R2)+, R0 ; áåð¸ì 8 ïèêñåëîâ
MOV R4, (R1) ; ïèøåì àäðåñ
MOV R0, @#176642 ; ïèøåì â ÂÎÇÓ ÓÊÍÖ
INC R4 ; ê ñëåäóþùåé êîëîíêå
; 2
CLR R0
BISB (R2)+, R0 ; áåð¸ì 8 ïèêñåëîâ
MOV R4, (R1) ; ïèøåì àäðåñ
MOV R0, @#176642 ; ïèøåì â ÂÎÇÓ ÓÊÍÖ
INC R4 ; ê ñëåäóþùåé êîëîíêå
; 3
CLR R0
BISB (R2)+, R0 ; áåð¸ì 8 ïèêñåëîâ
MOV R4, (R1) ; ïèøåì àäðåñ
MOV R0, @#176642 ; ïèøåì â ÂÎÇÓ ÓÊÍÖ
INC R4 ; ê ñëåäóþùåé êîëîíêå
; 4
CLR R0
BISB (R2)+, R0 ; áåð¸ì 8 ïèêñåëîâ
MOV R4, (R1) ; ïèøåì àäðåñ
MOV R0, @#176642 ; ïèøåì â ÂÎÇÓ ÓÊÍÖ
INC R4 ; ê ñëåäóþùåé êîëîíêå
;
SOB R5, SHOWS2 ; Êîíåö öèêëà ïî ñòðîêå
ADD #070, R4 ; ê ñëåäóþùåé ñòðîêå ýêðàíà ÓÊÍÖ
SOB R3, SHOWS1 ; Êîíåö öèêëà ïî ñòðîêàì
RETURN
; Clear block on the shadow screen
; R3=row/col, R2=rows/cols
; columns are 8px wide; rows=1..128, row=0..127; col=0..23, cols=1..24
CLBLK:
PUSH R0
PUSH R1
PUSH R4
MOV R3, R4
SWAB R4
BIC #177400, R4 ; row 0..127
BIC #177400, R3 ; col 0..23
MOV R2, R1
SWAB R1
BIC #177400, R1 ; rows 1..128
BIC #177400, R2 ; cols 1..24
MOV R4, R0
ADD R4, R4 ; now R4 = row * 2
ADD R0, R4 ; now R4 = row * 3
ADD R4, R4
ADD R4, R4
ADD R4, R4 ; now R4 = row * 24
ADD R3, R4 ; now R4 = row * 24 + col
ADD #SHADOW, R4 ; now R4 = start address
CLBLK1: PUSH R4
MOV R2, R0
CLBLK2: CLRB (R4)+
;MOVB #201, (R4)+
SOB R0, CLBLK2
POP R4
ADD #24., R4
SOB R1, CLBLK1
POP R4
POP R1
POP R0
RETURN
; Routine: Get pseudo-random number, result in R3
; (copied from uknc-highwayencounter code)
RANDOM:
MOV RANDSD, R2 ; A270 LD DE,($5C76) ; Read RND SEED variable
MOV R2, R3 ; A274 LD H,E
SWAB R3
BIC #377, R3
ADD #375, R3 ; A275 LD L,$FD
MOV R2, R0 ; A277 LD A,D
SWAB R0
BIC #177400, R0 ; A278 OR A
SUB R2, R3 ; A279 SBC HL,DE
SBCB R0 ; A27B SBC A,$00
SUB R2, R3 ; A27D SBC HL,DE
SBCB R0 ; A27F SBC A,$00
; A281 LD E,A
BIC #177400, R0 ; A282 LD D,$00
SUB R0, R3 ; A284 SBC HL,DE
BHIS LA289 ; A286 JR NC,$A289
INC R3 ; A288 INC HL
LA289: MOV R3, RANDSD ; A289 LD ($5C76),HL ; Write RND SEED variable
RETURN ; A28C RET
RANDSD: .WORD 123456 ; Pseudo-random seed
;
; Get random number 0..7
RAND8:
CALL RANDOM
MOV R3, R0
BIC #177770, R0
RAND8R: RETURN
;
; Get random number 0..10 for door access codes
; value 10 is for '-' char and we made its probability lower by 1/3
RAND11:
CALL RANDOM
MOV R3, R0
BIC #177740, R0
RAND1A: CMP R0, #11.
BLO RAND8R
SUB #11., R0
BR RAND1A
;------------------------------------------------------------------------------
.INCLUDE /DESOLB.MAC/
.INCLUDE /DESOLD.MAC/
.INCLUDE /DESOLF.MAC/
.INCLUDE /DESOLS.MAC/
.INCLUDE /DESOLT.MAC/
;------------------------------------------------------------------------------
.EVEN
; Shadow screen, 192 x 140 pixels
; 12*2*(64*2+12) = 3360 bytes
SHADOW::
.BLKB 3360.
;------------------------------------------------------------------------------
STACK:: .BLKW 60 ; Ïîä ñòåê
;------------------------------------------------------------------------------
.END START