-
Notifications
You must be signed in to change notification settings - Fork 82
/
routines.src
179 lines (148 loc) · 3.9 KB
/
routines.src
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
.page
.subttl 80-column editor routines (01/17/85)
swap
sta lstchr ;<escape> entry: must update 'lstchr' BEFORE swap!
swapper
ldx #.swapend-.swapbeg
1$ ldy .swapout,x
lda .swapbeg,x ;swap local editor variables
sta .swapout,x
tya
sta .swapbeg,x
dex
bpl 1$
ldx #13
2$ ldy .swapmap,x ;swap tab map and line wrap tables
lda tabmap,x
sta .swapmap,x
tya
sta tabmap,x
dex
bpl 2$
lda mode ;toggle 40/80 device mode flag
eor #$80
sta mode
swrts rts
.page \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
cursor bit mode ;move the 8563 cursor
bpl swrts ;...branch if 80-col swapped out & rts
ldx #14 ;update the 8563 hardware cursor position
clc
lda pnt
adc pntr
pha ;cursor position low
lda pnt+1
adc #0
jsr vdcout ;cursor position high
inx
pla
jmp vdcout ;& rts
crsron bit mode ;enable the cursor on current screen
bpl crsr40 ;...branch if 40-column screen active
jsr scolor
ldy pntr ;set 'user' & .y to current position
jsr getusr ;read attribute byte at cursor
jsr vdcget
sta curcol ;save it
and #$f0
sta saver ;strip off color but save other attributes
jsr getusr
lda color ;get current attribute byte
and #$0f ;strip off special attributes but save color
ora saver ;merge existing specials with current color
jsr vdcput ;make cursor blink in current color
crsrdo ldx #10 ;//////entry from 'escape' functions here
lda curmod ;8563 cursor mode
jmp vdcout ;enable 80-column hardware cursor & rts
crsr40 lda #0
sta blnsw ;enable 40-column software cursor
rts
crsrof bit mode ;disable the cursor on current screen
bpl 1$ ;...branch if 40-column screen active
jsr getusr ;'user' & .y already point to cursor position
lda curcol
jsr vdcput ;restore attribute byte under cursor
ldx #10
lda #$20
jmp vdcout ;disable 80-column hardware cursor & rts
1$ sta blnsw ;disable 40-column software cursor (.a>0)
lda blnon
bpl 2$ ;...branch if cursor not visible at this time
and #$40
sta blnon ;flag vic cursor as not visible
lda gdbln ;get saved character
ldx gdcol ;get saved color
jsr disply ;restore corrected screen data at cursor position
2$ rts
.page \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
vdcput ldx #31 ;update data register
vdcout stx vdcadr ;update 8563 register in .x with data in .a
vdc_so bit vdcadr ;////// entry to write next sequential byte
bpl vdc_so
sta vdcdat
rts
vdcget ldx #31 ;read data register
vdcin stx vdcadr ;read 8563 register in .x, pass data in .a
vdc_si bit vdcadr ;////// entry to read next sequential byte
bpl vdc_si
lda vdcdat
rts
getpnt ;setup 8563 update registers (18,19) with PNT + .Y
ldx #18 ;calculate absolute destination = PNT + colm ptr
clc
tya ;column pointer
adc pnt
pha
lda #0
adc pnt+1
jsr vdcout ;8563 text screen memory address hi
pla
inx
jmp vdcout ;8563 text screen memory address lo & rts
getusr ;setup 8563 update registers (18,19) with USER + .Y
ldx #18 ;calculate absolute destination = USER + colm ptr
clc
tya ;column pointer
adc user
pha
lda #0
adc user+1
jsr vdcout ;8563 attribute memory address hi
pla
inx
jmp vdcout ;8563 attribute memory address lo & rts
.page \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
init80
lda #<vicchr ;set up pointers to vic character rom
ldy #>vicchr
sta sedsal
sty sedsal+1
ldx #18
lda #>vdcchr
jsr vdcout ;initialize 8563 update register high
inx
lda #<vdcchr
jsr vdcout ;low
ldy #0
1$ ldx #14 ;bank where vic character rom can be read
lda #sedsal ;vector into character rom (.y is the index)
jsr _fetch ;get a byte
jsr vdcput
iny
cpy #8
bcc 1$ ;...loop until character is transfered
lda #0
2$ jsr vdcput ;pad with nulls to fill out 8563 chr definition
dey
bne 2$ ;...loop until done a character
clc
lda sedsal ;increment pointer to next character in rom
adc #8
sta sedsal
bcc 1$
inc sedsal+1
lda sedsal+1
cmp #>vicchr+$10
bcc 1$ ;...loop until done all characters
rts
;.end