-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplaygfx80.asm
717 lines (675 loc) · 9.04 KB
/
displaygfx80.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
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
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
;
; VI65 (c) 2010-2013 Soci/Singular ([email protected])
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
;
.if (TARGET==C64) || (TARGET==PLUGIN)
scr = $e000
col = $dc00
width = 80
height = 25
cache = $334
.elsif TARGET==PLUS4
scr = $e000
col = $0c00
width = 80
height = 23
cache = $333
.elsif TARGET==C128
scr = $a000
col = $8c00
width = 80
height = 25
cache = $0b00
.elsif TARGET==VIC20BIG
scr = $04e0
width = 40
height = 22
cache = $0334
.elsif TARGET==ATARI800
width = 80
height = 24
cache = $0489
.fi
width2 = width/2
gfx .macro
sta $ff03
.endm
displayinit .proc
ldx #height-1
- lda #width2
sta paintone.caches,x
lda #255
sta paintone.cachec,x
dex
bpl -
lda #8
sta cursor.size
lda #statusmsg.banner
jsr setstatusmsg
.if (TARGET!=C128) && (TARGET!=ATARI800)
jsr display
.fi
.if (TARGET==C64) || (TARGET==C128) || (TARGET==PLUGIN)
#kernal
.if TARGET==C128
lda #$47
sta $d506
lda #$7f
sta $d503
.fi
ldx #c2-c1
- ldy c1-1,x
lda c2-1,x
sta $d000,y
dex
bne -
lda #3-(scr >> 14)
sta $dd00
.if TARGET==C128
#gfx
.else
#ram
.fi
lda #15
cl sta col,x
sta col+$100,x
sta col+$200,x
sta col+$300,x
inx
bne cl
.if TARGET==C128
#ram
.fi
rts
c1 .byte $15, $20, $11, $16, $18
c2 .byte $00, $06, $3b, $08, ((col >> 6) & $f0)+((scr & $2000) >> 10)
.elsif TARGET==PLUS4
lda #$06
sta $ff19
lda #$37
sta $ff06
lda $ff07
and #$40
ora #$08
sta $ff07
lda #$c3+(scr >> 13)*8
sta $ff12
lda #>(col-$400)
sta $ff14
ldx #0
lda #$08
sta cl+2
lda #$61
jsr clr
lda #$01
jsr clr
ldx #79
- lda #$00
sta col+23*width2-$400,x
lda #$66
sta col+23*width2,x
dex
bpl -
rts
clr ldy #3
cl sta $ff00,x
inx
bne cl
inc cl+2
dey
bpl cl
rts
.elsif TARGET==VIC20BIG
lda #width2
sta $9002
lda #$17
sta $9003
lda #$19
sta $9005
ldx #0
- cpx #224
bge +
txa
adc #14
sta $0400,x
lda #0
+ sta $9400,x
sta $9500,x
inx
bne -
rts
.elsif TARGET==ATARI800
ldx #$30
lda #3
sta iccom,x
lda #<(dpname)
sta icba,x
lda #>(dpname)
sta icba+1,x
lda #8
sta icax1,x
lda #8
sta icax2,x
jsr ciov ;keyboard
lda #$70
sta $2c8 ;border
lda #$00
sta $2c5 ;text
lda #$0a
sta $2c6 ;background
lda $2e6
sta alloc.end+1
rts
dpname .text "S:",k_return
.fi
.pend
displayexit .proc
#kernal
.if (TARGET==C64) || (TARGET==C128) || (TARGET==PLUGIN)
.if TARGET==C128
lda #$04
sta $d506
.fi
lda #27
sta $d011
lda #$14
sta $d018
lda #3
sta $dd00
lda #147
jmp chrout
.elsif (TARGET==C16) || (TARGET==PLUS4)
lda #$1b
sta $ff06
lda #$c7
sta $ff12
lda #$08
sta $ff14
lda #147
jmp chrout
.elsif TARGET==ATARI800
ldx #$20
lda #12
sta iccom,x
jsr ciov ;close
ldx #$10
lda #12
sta iccom,x
jmp ciov ;close
.fi
.pend
displaylowinit .proc
p3 = num
.if TARGET==ATARI800
lda $58
clc
adc #<(width2*8-8)
sta p3
lda $59
adc #>(width2*8-8)
sta p3+1
.else
#loadw scr, p3
.fi
rts
.pend
displaylow .proc
p2 = screen
x = num+2
ln = num+3
sor = num+4
p3 = num
stx paintone.ao+1
sta paintone.cursorcol+1
ldx windows.start,y
lda windows.end,y
sta leng+1 ;length of window
loop jsr paintone
.if TARGET==VIC20BIG
lda p3
and #8
beq +
eor p3
sta p3
jmp ek
+ lda p3
sec
sbc #<(width2*16-8)
sta p3
lda p3+1
sbc #>(width2*16-8)
sta p3+1
ek
.elsif TARGET==ATARI800
lda p3
clc
adc #<(width2*7)
sta p3
lda p3+1
adc #>(width2*7)
sta p3+1
.fi
ldy #0
pha (currentline),y
iny
lda (currentline),y
sta currentline+1
pla currentline
inx
leng cpx #height-1
bne loop
rts
.pend
paintone .proc
p2 = screen
x = num+2
ln = num+3
sor = num+4
p3 = num
stx sor
lda cachec,x
cmp column2
bne ng
in lda cachel,x
cmp currentline
bne ng
lda cacheh,x
cmp currentline+1
bne ng
garbagelow cmp #0
bge ng
.if TARGET==VIC20BIG
lda p3
adc #<(width2*16)
sta p3
lda p3+1
adc #>(width2*16)
sta p3+1
.elsif TARGET==ATARI800
lda p3
adc #width2
sta p3
bcc +
inc p3+1
+
.else
lda p3
adc #<(width2*8)
sta p3
lda p3+1
adc #>(width2*8)
sta p3+1
.fi
jmp jo
ng
lda column2
sta cachec,x
lda caches,x
sta b+1
lda currentline
sta cachel,x
lda currentline+1
sta cacheh,x
ldy activewin
txa
sec
sbc windows.start,y
clc
adc line2
tay
lda #0
sta x
sta ez+1
adc line2+1
cpy lines
sbc lines+1
bcc +
lda #0
sta ln
tay
lda #"-"
gne er
+
ldy #4
lda (currentline),y
sec
sbc column2
bge +
lda #0
+ cmp #width+1
blt +
lda #width
+ sta ln
tya
sec
adc column2
adc currentline
sta currenttext
lda #0
adc currentline+1
sta currenttext+1
lp
ez ldy #0
lp2 cpy ln
bge fin
lda (currenttext),y
er asl
rol
rol
rol
tax
and #$f0
ror
adc #<font
sta p2
txa
and #7
tax
lda class,x
adc #0
sta p2+1
tya
iny
lsr
bcs k1
lda p2
sta u1+1
lda p2+1
sta u1+2
gcc lp2
k1 sty ez+1
.if TARGET==C128
#gfx
.fi
ldy #7
.if TARGET==ATARI800
clc
.fi
-
.if TARGET==ATARI800
lda p3
sbc #width2-1-1
sta p3
bcs +
dec p3+1
+
.fi
lda (p2),y
lsr
lsr
lsr
lsr
u1 ora tmpl,y
sta (p3),y
dey
bpl -
.if TARGET==C128
#ram
.fi
.if TARGET==ATARI800
lda p3
;clc
adc #<(width2*8-8+1)
sta p3
lda p3+1
adc #>(width2*8-8+1)
sta p3+1
.else
.if TARGET==VIC20BIG
lda #16
.else
lda #8
.fi
;sec
adc p3
sta p3
bcc lp
inc p3+1
.fi
jmp lp
fin
.if TARGET==C128
#gfx
.fi
tya
ldy #7
lsr
sta x
tax
bcc b
inc x
-
.if TARGET==ATARI800
lda p3
sec
sbc #width2-1
sta p3
bcs +
dec p3+1
+
.fi
lda (p2),y
sta (p3),y
dey
bpl -
l2
.if TARGET==ATARI800
lda p3
clc
adc #<(width2*8-8)
sta p3
lda p3+1
adc #>(width2*8-8)
sta p3+1
.fi
l ldy #7
.if TARGET==ATARI800
inc p3
bne +
inc p3+1
+
.else
.if TARGET==VIC20BIG
lda #15
.else
tya
.fi
sec
adc p3
sta p3
bcc +
inc p3+1
+
.fi
inx
b cpx #width2
bge ko
.if TARGET==ATARI800
- lda p3
sec
sbc #width2-1
sta p3
bcs +
dec p3+1
+ lda #0
sta (p3),y
dey
bpl -
.else
lda #0
- sta (p3),y
dey
sta (p3),y
dey
bpl -
.fi
gmi l2
ko cpx #width2
blt l
ldx sor
lda x
sta caches,x
jo
.if TARGET==C128
#ram
.fi
u lda activewin
ao cmp #0
bne nc
lda currentline
cmp cursorline
bne nc
lda currentline+1
cmp cursorline+1
bne nc
lda #255
sta ao+1
.if TARGET==VIC20BIG
lda p3
sbc #<(width2*16)
sta p2
lda p3+1
sbc #>(width2*16)
.elsif TARGET==ATARI800
lda p3
sbc #<(width2-8)
sta p2
lda p3+1
sbc #>(width2-8)
.else
lda p3
sbc #<(width2*8)
sta p2
lda p3+1
sbc #>(width2*8)
.fi
tax
cursorcol lda #0
sbc column2
tay
.if TARGET==ATARI800
lsr
clc
.else
asl
asl
and #$f8
.if TARGET==VIC20BIG
asl
.fi
bcc +
clc
inx
+
.fi
adc p2
bcc +
inx
+
.if TARGET==ATARI800
sta cursor.at1+1
stx cursor.at2+1
.else
sta cursor.at1+1
sta cursor.at2+1
stx cursor.at1+2
stx cursor.at2+2
.fi
tya
lsr
lda #%11110000
bcc +
lda #%00001111
+ ldy tochar.mode+1
bne +
and #%11001100
+ sta cursor.k+1
lda #1
jsr cursor.in
ldx sor
nc rts
.if TARGET==ATARI800
class .byte >(font+2*8*32),>font,>(font+8*32),>(font+3*8*32)
.byte >(font+2*8*32),>font,>(font+8*32),>(font+3*8*32)
;.byte >(font+3*8*32),>(font+8*32),>(font+2*8*32),>font
;.byte >(font+3*8*32),>(font+8*32),>(font+2*8*32),>font
.else
class .byte >font,>(font+8*32),>font,>(font+2*8*32)
.byte >(font+2*8*32),>(font+3*8*32),>(font+2*8*32),>(font+3*8*32)
.fi
o
.logical cache
tmpl .fill 8
cachec .fill height
cachel .fill height
cacheh .fill height
caches .fill height
.here
*= o
.if TARGET==ATARI800
font .binary "atascii4x8.fnt",2,$400
.else
font .binary "petscii4x8.fnt",2,$400
.fi
.pend
cursoroff .proc
lda cursor.on+1
beq cursor.x
gne cursor
.pend
cursor .proc
on lda #0
eor #1
in sta on+1
.if TARGET==ATARI800
at1 lda #0
sta screen
at2 lda #0
sta screen+1
ldy #0
size = *+1
ldx #8
- lda screen
sec
sbc #width2
sta screen
bcs +
dec screen+1
+ lda (screen),y
k eor #0
sta (screen),y
dex
bne -
.else
.if TARGET==C128
#gfx
.fi
size = *+1
ldx #8
ldy #7
-
at1 lda scr,y
k eor #0
at2 sta scr,y
dey
dex
bne -
.if TARGET==C128
#ram
.fi
.fi
x rts
.pend