-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathgraphic.src
160 lines (138 loc) · 3.44 KB
/
graphic.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
.page
.subttl GRAPHIC Command
;*************************************************************
;
; set graphic mode
;
; syntax: graphic n [[,c] ,s]
; or
; graphic clr
;
; where : n = 0 for 40 column text mode
; n = 1 for hi res mode
; n = 2 for hi res split screen mode
; n = 3 for multicolor mode
; n = 4 for multicolor split screen mode
; n = 5 for 80 column text mode
; n = 6 for 80 column bit map mode
;
; optionally, c = 0 for 'don't clear screen' (default)
; c = 1 for 'clear screen'
;
; s = number of first line of text in split screen modes (0..24).
; (default = 19)
;
; If 'graphic n' is executed, where 0<n<5, a 10k block of memory for bit map
; screen and color bytes is allocated, if it has not previously been allocated.
; This ram remains reserved until a 'graphic clear' command is executed.
;
;*****************************************************************
graphic cmp #clrtk ;test if hi-res ram is to be de-allocated
bne graphic01 ;no, go on to set up new mode
jsr clrhir ;de-allocate ram
jsr chrget ;skip over clr token
lda #0 ;force to text screen
sta _graphm
graph80_clr
jsr init_plot_vec ;install vic indirects
jsr put_io_in_map
ldx #25 ;put 8563 into text mode
jsr vdcin
and #$7f
jsr vdcout
ldx #13 ;start of text display data: $0000
lda #<$0000
jsr vdcout
dex
jsr vdcout
ldx #21
jsr vdcout ;start of attribute data: $0800
dex
lda #>$0800
jmp vdcout ;rts
graphic01
jsr getbyt ;get new mode
cpx #6
beq graph80 ;branch if 'go to 80 col bmm' wedge
txa
pha ;save in case there is a 'clear'
cpx #5 ;in range?
beq 50$ ;branch if 'go to 80 col'
bcs graper ;illegal value
lda modes,x ;set up for one of the graphic modes
20$ sta _graphm
beq 26$ ;branch if 'goto 40'
jsr sethir ;..else set up graphic area
25$ bit _graphm ;is this a split screen mode?
bvc 30$ ;no, don't force into 40 column
26$ bit _mode
bpl 30$ ;branch if already in 40 column
22$ jsr _swapper
30$ jsr optzer ;get optional clear flag (def=0)
cpx #2
bcs graper ;arg can only be 0 or 1
txa
pha ;save it
40$ ldx #20 ;get (optional) line to start text
jsr optbyt
cpx #26
bcs graper ;bad value
txa
asl a ;multiply times 8
asl a
asl a
adc #$30 ;add offset to first line
sta _split
pla ;get back clear flag
tay ;..hold on a sec...
pla ;get original mode argument
tax ;set up for scnclr
tya ;test clear arg
beq 45$ ;if zero, don't clear screen
jsr scnclr_1 ;special entry into screen clear routine
45$ lda #0
sta scalem ;turn off scaling to force new defaults
rts
50$ jsr graph80_clr ;put 8563 into text mode, reset indirects
bit _mode ;test if already 80 column
bmi 30$ ;yes, don't do anything
lda _graphm ;if we're in a split mode, force mode to all graphic
and #%10111111
sta _graphm
jmp 22$
graper jmp fcerr
modes .byte 0,$20,$60,$a0,$e0 ;text,hir,hir/s,mcm,mcm/s
.page
graph80
ldx #20$-10$-1 ;install 80-col graphic indirects
1$ lda 10$,x
sta plot_point,x
dex
bpl 1$
jsr optzer ;clear it?
cpx #0
beq 2$ ;...no
jsr scnclr_80 ;...yes
2$ jsr optbyt ;eat last param
lda #0
sta scalem ;reset scaling
jsr put_io_in_map
ldx #25 ;put 8563 into bit map mode
jsr vdcin
ora #$80
jsr vdcout
ldx #13 ;start of bit map data: $8000
lda #<$8000
jsr vdcout
dex
lda #>$8000
jsr vdcout
ldx #21 ;start of bit map color data: $c000
lda #<$c000
jsr vdcout
dex
lda #>$c000
jmp vdcout ;rts
10$ .wor plot_80,color_80,read_80
20$
;.end