-
Notifications
You must be signed in to change notification settings - Fork 8
/
mainmem.hgr.s
236 lines (220 loc) · 7.31 KB
/
mainmem.hgr.s
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
* MAINMEM.HGR.S
* (c) Bobbi 2021 GPLv3
*
* Routines for drawing bitmapped text and graphics in HGR mode (280x192)
* Uses the FDraw library to actually do the drawing.
* Call FDraw Clear routine
CLRHGR >>> ENTMAIN
LDA BGCOLOR
STA FDRAWADDR+5
JSR FDRAWADDR+16 ; FDRAW: SetColor
JSR FDRAWADDR+22 ; FDRAW: Clear
LDA FGCOLOR
STA FDRAWADDR+5
JSR FDRAWADDR+16 ; FDRAW: SetColor
>>> XF2AUX,VDU16RET
* Call FDraw SetLineMode routine
SETLINE >>> ENTMAIN
JSR FDRAWADDR+43 ; FDRAW: SetLineMode
>>> XF2AUX,VDU18RET1
* Helper function to set up colors
SETCOLOR LDA PLOTMODE
AND #$03
CMP #$01 ; Draw in foreground colour
BNE :S1
LDA FGCOLOR
BRA :SETCOLOR
:S1 CMP #$02 ; Draw in inverse colour
BNE :S2
SEC
LDA #$07
SBC FGCOLOR
BRA :SETCOLOR
:S2 LDA BGCOLOR ; Draw in background colour
:SETCOLOR STA FDRAWADDR+5
JMP FDRAWADDR+16 ; FDRAW: SetColor
* Call FDraw DrawLine routine
DRAWLINE >>> ENTMAIN
JSR SETCOLOR
JSR FDRAWADDR+28 ; FDRAW: DrawLine
>>> XF2AUX,VDU25RET
* Call FDraw DrawPoint routine
DRAWPNT >>> ENTMAIN
JSR SETCOLOR
JSR FDRAWADDR+25 ; FDRAW: DrawPoint
>>> XF2AUX,VDU25RET
* Call FDraw DrawCircle routine
DRAWCIRC >>> ENTMAIN
JSR SETCOLOR
JSR FDRAWADDR+37 ; FDRAW: DrawCircle
>>> XF2AUX,VDU25RET
* Call FDraw FillCircle routine
FILLCIRC >>> ENTMAIN
JSR SETCOLOR
JSR FDRAWADDR+40 ; FDRAW: FillCircle
>>> XF2AUX,VDU25RET
* Call FDraw FillRect routine
FILLRECT >>> ENTMAIN
JSR SETCOLOR
LDA FDRAWADDR+8 ; Y1
CMP FDRAWADDR+11 ; Y2
BEQ :S1
BCS :SWAPY ; Y1>Y2 then swap
:S1 LDA FDRAWADDR+7 ; MSB of X1
CMP FDRAWADDR+10 ; MSB of X2
BEQ :S2
BCS :SWAPX ; MSB X1 > MSB X2
:S2 LDA FDRAWADDR+6 ; LSB of X1
CMP FDRAWADDR+9 ; MSB of X2
BEQ :S3
BCS :SWAPX ; LSB X1 > LSB X2
:S3 JSR FDRAWADDR+34 ; FDRAW: FillRect
>>> XF2AUX,VDU25RET
:SWAPY LDA FDRAWADDR+8
LDY FDRAWADDR+11
STY FDRAWADDR+8
STA FDRAWADDR+11
BRA :S1
:SWAPX LDA FDRAWADDR+7
LDY FDRAWADDR+10
STY FDRAWADDR+7
STA FDRAWADDR+10
LDA FDRAWADDR+6
LDY FDRAWADDR+9
STY FDRAWADDR+6
STA FDRAWADDR+9
BRA :S3
* Reset colours and linetype
GFXINIT JSR FDRAWADDR+0 ; Initialize FDRAW library
LDA #$20
STA FDRAWADDR+5
JSR FDRAWADDR+19 ; FDRAW: Set page $2000
STZ LINETYPE
STZ FDRAWADDR+5
JSR FDRAWADDR+43 ; FDRAW: SetLineMode
LDA #$07
STA FGCOLOR
STA FDRAWADDR+5
JSR FDRAWADDR+16 ; FDRAW: SetColor
STZ BGCOLOR
* JSR FDRAWADDR+22 ; FDRAW: clear HGR screen
RTS
* Plot bitmap character on the HGR screen
* On entry: char is in A
DRAWCHAR >>> ENTMAIN
* AND #$7F ; Don't!
STA A1L ; A*8 -> A1L,A1H
STZ A1H
ASL A1L
ROL A1H
ASL A1L
ROL A1H
ASL A1L
ROL A1H
CLC ; FONTADDR+A*8 -> A1L,A1H
LDA A1L
ADC #<FONTADDR
STA A1L
LDA A1H
ADC #>FONTADDR
STA A1H
LDA HGRADDR+0 ; HGRADDR -> A4L,A4H
STA A4L
LDA HGRADDR+1
STA A4H
LDY #$00
:L1 LDA (A1L),Y ; Load line of pixels from font
STA (A4L) ; Store them on screen
INC A4H ; Skip 1024 bytes to next row
INC A4H
INC A4H
INC A4H
INY
CPY #$08 ; All eight rows done?
BNE :L1
>>> XF2AUX,PUTCHRET
* Copy text line A+1 to line A
HGRSCR1L >>> ENTMAIN
INC MTXTWINRGT
ASL ; Dest addr->A4L,A4H
TAX
LDA MHGRTAB,X
STA A4L
LDA MHGRTAB+1,X
STA A4H
INX ; Source addr->A1L,A1H
INX
LDA MHGRTAB,X
STA A1L
LDA MHGRTAB+1,X
STA A1H
DOHGRSCR1L LDX #$00
:L1 LDY MTXTWINLFT
:L2 LDA (A1L),Y
STA (A4L),Y
INY
CPY MTXTWINRGT
BNE :L2
INC A1H ; Advance source 1024 bytes
INC A1H
INC A1H
INC A1H
INC A4H ; Advance dest 1024 bytes
INC A4H
INC A4H
INC A4H
INX
CPX #8 ; 8 pixel rows in character
BNE :L1
>>> XF2AUX,HSCR1RET
* Copy text line A to line A+1
HGRRSCR1L >>> ENTMAIN
INC MTXTWINRGT
ASL ; Source addr->A1L,A1H
TAX
LDA MHGRTAB,X
STA A1L
LDA MHGRTAB+1,X
STA A1H
INX ; Dest addr->A4L,A4H
INX
LDA MHGRTAB,X
STA A4L
LDA MHGRTAB+1,X
STA A4H
BRA DOHGRSCR1L
* Clear one text line on HGR screen,
* from current cursor col to text window right limit
HCLREOL >>> ENTMAIN
INC MTXTWINRGT
LDA HGRADDR+0 ; HGRADDR -> A4L,A4H
STA A4L
LDA HGRADDR+1
STA A4H
LDA #$00
LDX #$00
:L1 LDY MVDUTEXTX
:L2 STA (A4L),Y
INY
CPY MTXTWINRGT
BNE :L2
INC A4H
INC A4H
INC A4H
INC A4H
INX
CPX #$08
BNE :L1
>>> XF2AUX,CLRLNRET
FGCOLOR DB $00 ; Foreground colour
BGCOLOR DB $00 ; Background colour
LINETYPE DB $00 ; 0 normal, 1 XOR
PLOTMODE DB $00 ; K value for PLOT K,X,Y
HGRADDR DW $0000 ; Address 1st line of HGR char
MVDUTEXTX DB $00 ; Main mem copy of VDUTEXTX
MTXTWINLFT DB $00 ; Main mem copy of TEXTWINLFT
MTXTWINRGT DB $00 ; Main mem copy of TEXTWINRGT
* Addresses of start of pixel rows in PAGE1
MHGRTAB DW $2000,$2080,$2100,$2180,$2200,$2280,$2300,$2380
DW $2028,$20A8,$2128,$21A8,$2228,$22A8,$2328,$23A8
DW $2050,$20D0,$2150,$21D0,$2250,$22D0,$2350,$23D0