-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuffer.asm
5391 lines (4978 loc) · 112 KB
/
buffer.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
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
mcopy buffer.macros
****************************************************************
*
* BufferCommon - Common data area
*
****************************************************************
*
BufferCommon data
;
; Key codes
;
RETURN equ 13
TAB equ 9
oldBreakChar equ $84 old break character
oldSkipChar equ $81 old skip character
newBreakChar equ $07 new break character
newSkipChar equ $06 new skip character
stepChar equ $05 step arrow character
;
; Displacements into the currentFile variable
;
wPtr equ 0 pointer to the window
vScroll equ wPtr+4 control handles
hScroll equ vScroll+4
grow equ hScroll+4
buffHandle equ grow+4 handle of the buffer
buffStart equ buffHandle+4 start, end of the buffer
buffEnd equ buffStart+4
gapStart equ buffEnd+4 first free byte in gap
pageStart equ gapStart+4 first character on the display
buffSize equ pageStart+4 size of buffer, in bytes
expanded equ buffSize+4 tells if the buffer is expanded
isFile equ expanded+2 is there an existing file?
fileName equ isFile+2 file name (if any)
pathName equ fileName+34 path name (if any)
changed equ pathName+256 has the file changed since saving?
cursor equ changed+2 points to char cursor is on or before
cursorColumn equ cursor+4 screen position of cursor
cursorRow equ cursorColumn+2
width equ cursorRow+4 screen width, height, in characters
height equ width+2
maxHeight equ height+2 height of main & split screen
numLines equ maxHeight+2 # lines in the file
topLine equ numLines+4 top line on the screen
leftColumn equ topLine+4 leftmost column on display
dispFromTop equ leftColumn+2 disp from top of first line
select equ dispFromTop+2 if selection, this is the end of the
! selected text - cursor is the other
selection equ select+4 is there an active selection?
splitScreen equ selection+2 is the screen split?
topLineAlt equ splitScreen+2 line # of top line on alt screen
heightAlt equ topLineAlt+4 height of alternate screen
vScrollAlt equ heightAlt+2 alt screen scroll bar
dispFromTopAlt equ vScrollAlt+4 disp from top in pixels
splitScreenRect equ dispFromTopAlt+2 split screen control location
showRuler equ splitScreenRect+8 is the ruler visible?}
ruler equ showRuler+2 ruler - 1 -> tab stop; 0 -> no code}
newDebug equ ruler+256 new debug characters? (or old)
insert equ newDebug+2 insert? (or overstrike)
autoReturn equ insert+2 return to first non-blank?
language equ autoReturn+2 language number
last equ language+2 pointer to last buffer
next equ last+4 pointer to next buffer
changesSinceCompile equ next+4 changes since last compile?
exeName equ changesSinceCompile+2 name of executable file
undoList equ exeName+256 head of undo list
verticalMove equ undoList+4 was the last key a vertical move?
vCursorColumn equ verticalMove+2 cursorColumn before vertical move
buffLength equ vCursorColumn+2 length of buffer
;
; Line drawing variables
;
locRec dc i1'$80' info about the object to draw
dc i1'0'
charAddr dc a4'line1'
dc i'77*2'
dc i'0,0,8,77*8'
rect dc i'0,0,8,8' size of rectangle to draw it in
point ds 4 work point
breakChar dc i'newBreakChar' current break-point character
skipChar dc i'newSkipChar' current auto-go character
line1 ds 77*2 line buffers
line2 ds 77*2
line3 ds 77*2
line4 ds 77*2
line5 ds 77*2
line6 ds 77*2
line7 ds 77*2
line8 ds 77*2
end
****************************************************************
*
* Check255 - make sure the current line is < 256 chars long
*
****************************************************************
*
Check255 start
lcursor equ 1 local copy of the cursor
using BufferCommon
phd set up work space
pha
pha
tsc
tcd
move4 currentFile+cursor,oldCursor save the old cursor
jsl MoveToStart see if the line is tool long
move4 currentFile+cursor,lcursor
ldy #0
tyx
short M
lb1 lda [lcursor],Y
cmp #RETURN
beq lb2
cmp #tab
bne tb2
tb1 inx
lda currentFile+ruler,X
beq tb1
dex
tb2 inx
cpx #256
bge lb3
iny
bra lb1
lb2 long M line is OK - restore cursor & return
move4 oldCursor,currentFile+cursor
bra lb7
lb3 long M push the source address
clc
tya
adc lcursor
sta lcursor
bcc dc1
inc lcursor+2
dc1 ph4 lcursor
ldy #-1 find the number of bytes being deleted
short M
dc2 iny
lda [lcursor],Y
cmp #return
bne dc2
long M
clc update cursor
tya
adc oldCursor
sta oldCursor
bcc dc3
inc oldCursor+2
dc3 clc push the destination address
tya
adc lcursor
tax
lda #0
adc lcursor+2
pha
phx
sub4 lcursor,currentFile+pageStart push the # of bytes to delete
ph4 lcursor
jsl MoveForward delete the bytes
move4 oldCursor,currentFile+cursor restore the cursor
jsl FindCursorColumn update cursorColumn
sta currentFile+cursorColumn
lb7 pla remove work space & return
pla
pld
rtl
oldCursor ds 4 old cursor value
end
****************************************************************
*
* DrawMark - draw the line marker
*
* Inputs:
* ch - character number
* v - row #
* dispFromTop - pixels from top to first row
*
****************************************************************
*
DrawMark start
using BufferCommon
subroutine (2:ch,2:v,2:dispFromTop),0
lda ch write the tab (or erase an old one)
asl a
asl a
asl a
asl a
clc
adc #characters
sta iconAddr
ph4 #iconRc write the stuff
ph4 #iRec
ph2 #0
lda v
asl a
asl a
asl a
inc a
clc
adc dispFromTop
pha
ph2 #0
_PPToPort
return
iconRc dc i1'$80' info about the object to draw
dc i1'0'
iconAddr dc a4'characters'
dc i'2'
iRec dc i'0,0,8,8'
end
****************************************************************
*
* DrawOneLine - Redraw a line on a non-split screen
*
* Inputs:
* line - line number of line to draw
*
****************************************************************
*
DrawOneLine start
using BufferCommon
selectStart equ 0 start disp of selected text
selectEnd equ 4 end disp of selected text
startPtr equ 8 ptr to first char to be drawn
numChars equ 8 max # of characters
cp equ 10 character pointer
disp equ 14 disp into character array
yDisp equ 16 y disp into window, in pixels
col equ 18 column #
startChar equ 20 char in col 0
numBlanks equ 22 number of blanks left in tab field
tabIndex equ 24 index into tab line
subroutine (2:line),26
;
; Decide which method to use
;
! Common initialization...
jsr SetCharacters get the current breakpoint and auto-go characters
_HideCursor
stz point get the location of the top left byte
stz point+2
ph4 #point
_LocalToGlobal
move4 currentFile+pageStart,startPtr set the selection displacements
jsr SetSelection
lda line quit if off of screen
cmp currentFile+height
jge en1
sec set numChars to the number of characters
lda currentFile+buffEnd available, or to 65535, whichever is
sbc currentFile+pageStart smaller
sta numChars
lda currentFile+buffEnd+2
sbc currentFile+pageStart+2
beq dc1
lda #$FFFF
sta numChars
dc1 move4 currentFile+pageStart,cp index in by the proper # of lines
ldy #0
ldx line
beq dc5
short M
lda #return
dc2 cmp [cp],Y
bne dc3
dex
beq dc4
dc3 iny
cpy numChars
blt dc2
dey
dey
dc4 iny
dc5 long M
lda #' ' set the start character
sta startChar
lda [cp],Y
and #$00FF
cmp breakChar
beq dc5a
cmp skipChar
bne dc5b
dc5a sta startChar
iny
dc5b stz tabIndex set up tab counters
stz numBlanks
ldx currentFile+leftColumn index in by leftColumn characters
beq dc7
dc6 lda numBlanks
bne aa1
lda [cp],Y
and #$00FF
cmp #return
beq dc7
cmp #tab
bne aa2
jsr CountTabs
iny
aa1 dec numBlanks
dey
aa2 iny
inc tabIndex
dex
bne dc6
dc7 sty disp
long M
pha use QuickDraw if we are not drawing
pha in the front window
_FrontWindow
pla
plx
cmp currentFile+wPtr
bne qd1
cpx currentFile+wPtr+2
bne qd1
lda screenPtr
cmp #$2000
bne qd1
lda screenPtr+2
cmp #$00E1
bne qd1
jsr OnScreen
jcs fs1
;
; Use QuickDraw
;
qd1 lda currentFile+cursorRow set disp into the window
asl a
asl a
asl a
sec
adc currentFile+dispFromTop
sta yDisp
lda currentFile+width set width of drawing rectangle
inc a
asl a
asl a
asl a
sta rect+6
lda startChar set first character
jsr SetFirst
ldx #0 set disp into line array
stz col column # is 0
lb2 ldy disp get the next char to write
lda numBlanks
beq bb1
dec numBlanks
dec disp
lda #' '
bra bb2
bb1 lda [cp],Y
and #$00FF
cmp #RETURN
jeq lb3
cmp #tab
bne bb2
jsr CountTabs
inc disp
bra lb2
bb2 asl a convert to disp into character bit maps
asl a
asl a
asl a
cpy selectStart branch if not in selection
blt lb2b
cpy selectEnd if at end of selection, use normal
blt lb2a characters
lda #$FFFF
sta selectStart
bra lb2b
lb2a tay place inverted char in line buffer
lda characters,Y
eor #$FFFF
sta line1+2,X
lda characters+2,Y
eor #$FFFF
sta line2+2,X
lda characters+4,Y
eor #$FFFF
sta line3+2,X
lda characters+6,Y
eor #$FFFF
sta line4+2,X
lda characters+8,Y
eor #$FFFF
sta line5+2,X
lda characters+10,Y
eor #$FFFF
sta line6+2,X
lda characters+12,Y
eor #$FFFF
sta line7+2,X
lda characters+14,Y
eor #$FFFF
sta line8+2,X
bra lb2c
lb2b tay place character in line buffer
lda characters,Y
sta line1+2,X
lda characters+2,Y
sta line2+2,X
lda characters+4,Y
sta line3+2,X
lda characters+6,Y
sta line4+2,X
lda characters+8,Y
sta line5+2,X
lda characters+10,Y
sta line6+2,X
lda characters+12,Y
sta line7+2,X
lda characters+14,Y
sta line8+2,X
lb2c inc disp update disp into character table
inx update disp into lines
inx
inc tabIndex update disp into tab line
inc col update column number
lda col
cmp currentFile+width
jlt lb2
bra lb5
lb3 lda #$FFFF write spaces to the end of the line
ldy disp
cmp selectStart
blt lb3a
cmp selectEnd
bge lb3a
lda #0
lb3a ldy col
lb4 cpy currentFile+width
bge lb5
sta line1+2,X
sta line2+2,X
sta line3+2,X
sta line4+2,X
sta line5+2,X
sta line6+2,X
sta line7+2,X
sta line8+2,X
inx
inx
iny
bra lb4
lb5 ph4 #locRec write the line
ph4 #rect
lda point+2
and #$0003
pha
ph2 yDisp
ph2 #0
_PPToPort
brl en1
;
; Use the 'fast' draw
;
fs1 lda line add in 8*line count
asl a
asl a
asl a
clc
adc point
sec multiply Y+1+dipFromtop by 160
adc currentFile+dispFromTop
ldx #160
jsl ~mul2
sta yDisp add in x disp div 4 + 2
lda point+2
inc a
inc a
inc a
lsr a
lsr a
inc a
sec
adc yDisp
sta yDisp ...result is initial disp in line
lda startChar
ldx yDisp
jsr SetFirstFast
stz col col := 0;
ldx yDisp X := yDisp;
fs2 ldy col while (startChar[disp] <> return)
cpy currentFile+width and (col < w) do begin
jeq fs3
ldy disp
lda numBlanks
beq dd1
dec numBlanks
dec disp
lda #' '
bra dd2
dd1 lda [cp],Y
and #$00FF
cmp #return
jeq fs3
cmp #tab
bne dd2
jsr CountTabs
inc disp
bra fs2
dd2 asl a <write char to screen>
asl a
asl a
asl a
cpy selectStart branch if not in selection
blt fs2b
cpy selectEnd if at end of selection, use normal
blt fs2a characters
lda #$FFFF
sta selectStart
bra fs2b
fs2a tay place inverted char on screen
lda characters,Y
eor #$FFFF
sta $E12000,X
lda characters+2,Y
eor #$FFFF
sta $E12000+160,X
lda characters+4,Y
eor #$FFFF
sta $E12000+320,X
lda characters+6,Y
eor #$FFFF
sta $E12000+480,X
lda characters+8,Y
eor #$FFFF
sta $E12000+640,X
lda characters+10,Y
eor #$FFFF
sta $E12000+800,X
lda characters+12,Y
eor #$FFFF
sta $E12000+960,X
lda characters+14,Y
eor #$FFFF
sta $E12000+1120,X
bra fs2c
fs2b tay place normal char on screen
lda characters,Y
sta $E12000,X
lda characters+2,Y
sta $E12000+160,X
lda characters+4,Y
sta $E12000+320,X
lda characters+6,Y
sta $E12000+480,X
lda characters+8,Y
sta $E12000+640,X
lda characters+10,Y
sta $E12000+800,X
lda characters+12,Y
sta $E12000+960,X
lda characters+14,Y
sta $E12000+1120,X
fs2c inx X += 2
inx
inc tabIndex tabIndex++;
inc col col++;
inc disp disp++
brl fs2 end; {while}
fs3 anop 1:
sec while col < width do begin
lda currentFile+width <write ' ' to screen>
sbc col ++col;
bmi en1 end; {while}
beq en1
tay
lda disp
cmp selectStart
blt fs3a
cmp selectEnd
bge fs3a
lda #0
bra fs4
fs3a lda #$FFFF
fs4 sta $E12000,X
sta $E12000+160,X
sta $E12000+320,X
sta $E12000+480,X
sta $E12000+640,X
sta $E12000+800,X
sta $E12000+960,X
sta $E12000+1120,X
inx
inx
dey
bne fs4
;
; Return to the caller
;
en1 _ShowCursor
_ObscureCursor
return
;
; CountTabs - count the blanks to insert for this tab
;
CountTabs anop
phx save caller's regs
phy
ldy tabIndex
ldx #0
ct1 inx
iny
cpy #256
bge ct2
lda currentFile+ruler,Y
and #$00FF
beq ct1
ct2 stx numBlanks
ply
plx
rts
end
****************************************************************
*
* DrawOneScreen - Redraw one of the screens - either the main or the split
*
* Inputs:
* w,h - width, height of the screen, in characters
* dispFromTop - # pixels to space down for first line
* left - leftmost column on display
* startChar - pointer to first char on the screen
* maxChar - pointer to one past the last valid character
* wp - pointer to window to draw in
* tabs - pointer to the tab line
*
****************************************************************
*
DrawOneScreen start
using BufferCommon
selectStart equ 0 start disp of selected text
selectEnd equ 4 end disp of selected text
startPtr equ 8 ptr to first char to be drawn
col equ 8 column #
row equ 10 row #
disp equ 12 disp into character array
yDisp equ 14 y disp into window, in pixels
numChars equ 16 max # of characters
grafDisp equ 10 disp into graphics screen
leftLoop equ 18 left edge loop counter
tabIndex equ 20 index into tab line
numBlanks equ 22 number of blanks in the tab field
port equ 24 grafPort on entry
subroutine (2:w,2:h,2:lDispFromTop,2:left,4:startChar,4:maxChar,4:wp,4:tabs),28
;
; Decide which method to use
;
! Common initialization...
jsr SetCharacters get the current breakpoint and auto-go characters
lda disableScreenUpdates
jne en2
_HideCursor hide the cursor
pha make this port active
pha
_GetPort
pl4 port
ph4 wp
_SetPort
stz point get the location of the top left byte
stz point+2
ph4 #point
_LocalToGlobal
move4 startChar,startPtr set the selection displacements
jsr SetSelection
sec set numChars to the number of characters
lda maxChar available, or to 65535, whichever is
sbc startChar smaller
sta numChars
lda maxChar+2
sbc startChar+2
beq dc1
lda #$FFFF
sta numChars
dc1 pha use QuickDraw if we are not drawing
pha in the front window
_FrontWindow
pla
plx
cmp wp
bne qd1
cpx wp+2
bne qd1
lda screenPtr
cmp #$2000
bne qd1
lda screenPtr+2
cmp #$00E1
bne qd1
jsr OnScreen
jcs fs1
;
; Use QuickDraw
;
qd1 stz disp disp past startChar is 0
lda lDispFromTop disp from top of window is
inc a 1+lDispFromTop
sta yDisp
stz row row number is 0
lda w set width of drawing rectangle
inc a
asl a
asl a
asl a
sta rect+6
lb1 stz col column number is 0
ldy disp if at end of file, write a blank line
cpy numChars
blt ee1
lda #' '
jsr SetFirst
ldx #0
brl lb3
ee1 lda [startChar],Y set first character
jsr SetFirst
ldy disp if first char is a debug char then
lda [startChar],Y
and #$00FF
cmp breakChar
beq ee2 skip it
cmp skipChar
bne dd1
ee2 inc disp
dd1 stz numBlanks set up for tabs
stz tabIndex
lda left skip chars to left of window
beq lb1b
sta leftLoop
ldx #0
ldy disp
lb1a lda numBlanks
bne bb0
lda [startChar],Y
and #$00FF
cmp #RETURN
jeq lb3
cmp #tab handle tabs during skip
bne bb1
jsr CountTabs
iny
bb0 dey
dec numBlanks
bb1 iny increment counters for one char
sty disp
inc tabIndex
dec leftLoop
bne lb1a
lb1b ldx #0 set disp into line array
lb2 ldy disp get the next char to write
cpy numChars
jge lb3
lda numBlanks
beq cc1
dec disp
dec numBlanks
lda #' '
ldy disp
bra cc2
cc1 lda [startChar],Y
and #$00FF
cmp #RETURN
jeq lb3
cmp #TAB
bne cc2
jsr CountTabs
inc disp
bra lb2
cc2 asl a convert to disp into character bit maps
asl a
asl a
asl a
cpy selectStart branch if not in selection
blt lb2b
cpy selectEnd if at end of selection, use normal
blt lb2a characters
ldy #$FFFF
sty selectStart
bra lb2b
lb2a tay place inverted char in line buffer
lda characters,Y
eor #$FFFF
sta line1+2,X
lda characters+2,Y
eor #$FFFF
sta line2+2,X
lda characters+4,Y
eor #$FFFF
sta line3+2,X
lda characters+6,Y
eor #$FFFF
sta line4+2,X
lda characters+8,Y
eor #$FFFF
sta line5+2,X
lda characters+10,Y
eor #$FFFF
sta line6+2,X
lda characters+12,Y
eor #$FFFF
sta line7+2,X
lda characters+14,Y
eor #$FFFF
sta line8+2,X
bra lb2c
lb2b tay place character in line buffer
lda characters,Y
sta line1+2,X
lda characters+2,Y
sta line2+2,X
lda characters+4,Y
sta line3+2,X
lda characters+6,Y
sta line4+2,X
lda characters+8,Y
sta line5+2,X
lda characters+10,Y
sta line6+2,X
lda characters+12,Y
sta line7+2,X
lda characters+14,Y
sta line8+2,X
lb2c inc disp update disp into character table
inx update disp into lines
inx
inc tabIndex update tab column number
inc col update column number
lda col
cmp w
jlt lb2
ldy disp skip to eol
lb2d lda [startChar],Y
and #$00FF
cmp #RETURN
beq lb5
iny
sty disp
bne lb2d
lb3 lda #$FFFF write spaces to the end of the line
ldy disp
cpy selectStart
blt lb3a
cpy selectEnd
blt lb3b
sta selectStart
bra lb3a
lb3b lda #0
lb3a ldy col
lb4 cpy w
bge lb5
sta line1+2,X
sta line2+2,X
sta line3+2,X
sta line4+2,X
sta line5+2,X
sta line6+2,X
sta line7+2,X
sta line8+2,X
inx
inx
iny
bra lb4
lb5 ph4 #locRec write the character
ph4 #rect
lda point+2
and #$0003
pha
ph2 yDisp
ph2 #0
_PPToPort
inc disp next line
add2 yDisp,#8
inc row
lda row
cmp h
jlt lb1
brl en1
;
; Use the 'fast' draw
;
fs1 lda point multiply Y+1+lDispFromTop by 160
sec
adc lDispFromTop
ldx #160
jsl ~mul2
sta grafDisp add in x disp div 4 + 2
lda point+2
inc a
inc a
inc a
lsr a
lsr a
inc a
sec
adc grafDisp
sta grafDisp ...result is initial disp in line
stz disp disp := 0;
fs2 lda h while h > 0 do begin
jeq en1
stz col col := 0;
ldy disp write first char
cpy numChars
blt ff1
lda #' '
ldx grafDisp
jsr SetFirstFast
ldx grafDisp
brl fs8
ff1 lda [startChar],Y
and #$00FF
cmp breakChar
beq ff2
cmp skipChar
bne fs2a
ff2 inc disp
fs2a lda [startChar],Y
ldx grafDisp
jsr SetFirstFast
ldx grafDisp {in case jump taken}
ldy disp y := disp;
stz tabIndex tabIndex := 0;
stz numBlanks numBlanks := 0;
lda left for x := left downto 1 do begin
beq fs4
sta leftLoop
fs3 cpy numChars if y > numChars then goto 1;
jge fs8
lda numBlanks if numBlanks <> 0 then
beq fs3a
dec numBlanks numBlanks--
bra fs3d loop
fs3a lda [startChar],Y if startChar[Y] = return then
and #$00FF
cmp #return
jeq fs8 goto 1;
cmp #tab if startChar[Y] = tab then
bne fs3c
jsr CountTabs count the spaces to insert
dec numBlanks numBlanks--
fs3c iny y++;
sty disp disp++;
fs3d inc tabIndex tabIndex++;
dec leftLoop end; {for}
bne fs3
fs4 ldx grafDisp X := grafDisp;
fs5 ldy col while (startChar[disp] <> return)
cpy w and (col < w) do begin
jeq fs6
lda numBlanks if numBlanks <> 0 then
beq tb0
dec disp --disp
dec numBlanks --numBlanks
lda #' ' print space
ldy disp
bra tb1
tb0 ldy disp
lda [startChar],Y
and #$00FF
cmp #return
jeq fs8
cpy numChars if y > numChars then goto 1;
jge fs8
cmp #tab if startChar[disp] = tab then