-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathgshape.src
141 lines (124 loc) · 3.14 KB
/
gshape.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
.page
.subttl GSHAPE Command
;*******************************************************************
;
; gshape str (, ( p ) , l ) -- place a stored shape on the screen
; str = string variable defining the shape
; p = top left corner of where to restore shape
; default = current position
; l = type of replacement
; 0 : replace ( default )
; 1 : invert and replace
; 2 : 'or' with current screen data
; 3 : 'and' with current screen data
; 4 : 'xor' with current screen data
;
;*******************************************************************
gshape jsr isgrap ;make sure graphics area is allocated
jsr frmstr ;do frmevl, frestr
sta sw_rom_ram0
sta strsz ;save string length
stx index2 ;save string address
sty index2+1
ldx #xdest-vwork
jsr incor2 ;get starting bit-map address
jsr optzer ;get type of replacement (default is 0, 'replace')
cpx #5
bcc 5$ ;branch if ok,
jmp fcerr ;otherwise illegal value
5$ stx gettyp
ldx #3 ;find x, y sizes in last 4 bytes
ldy strsz
cpy #5 ;compare with minimum string size
bcs 20$
rts ;string too small: just exit
20$ dey
lda #index2
jsr indsub_ram1
sta sw_rom_ram0
sta xsize,x ;store in xsize,ysize
dex
bpl 20$
stx strptr ;initialize pointer to position in string
jsr dstpos ;copy xdest,ydest to xpos,ypos
lda xsize ;make a copy of x length
sta xsave
lda xsize+1
sta xsave+1
gsa lda #8 ;read fresh character from string
sta bitcnt
inc strptr
ldy strptr
lda #index2
jsr indsub_ram1
sta sw_rom_ram0
sta newbyt
gsb jsr readpt ;get color at xpos,ypos
sta oldbyt ;old byte with bit(s) of interest right justified
asl newbyt ;move leftmost bit(s) of new value into acc.
rol a
dec bitcnt
bit _graphm
bpl 30$ ;branch if not multicolor
asl newbyt
rol a
dec bitcnt
30$ ldx gettyp ;how shall this new value be used?
cpx #3
bcc 40$ ;branch if 0,1,or 2
beq 35$ ;branch if 3
eor oldbyt ;here for 4,'xor with current value'
bcs 60$ ;always
35$ and oldbyt ;here for 3,'and with current value'
bcs 60$ ;always
40$ cpx #1
bcc 60$ ;branch if 0,'use new value'
beq 50$ ;branch if 1
ora oldbyt ;here for 2,'or with current value'
.byte $2c
50$ eor #$ff ;here for 1,'invert & replace'
60$ and #3 ;isolate bit(s) of interest
bit _graphm
bmi *+4 ;branch if mcm
and #1 ;if hi-res, just 1 bit is necessary
sta colsel
jsr plot01 ;use plot to re-install bit & update color
inc xpos
bne 65$
inc xpos+1
65$ sec ;decrement x counter 1 or 2
lda xsave
bit _graphm
bpl 66$ ;branch if not multicolor
sbc #2
.byte $2c
66$ sbc #1
sta xsave
lda xsave+1
sbc #0
sta xsave+1
bcs 80$ ;if xsave >= 0, keep going
ldx #1 ;else move xsize to xsave, xdest to xpos, & inc ypos
70$ lda xsize,x
sta xsave,x
lda xdest,x
sta xpos,x
dex
bpl 70$
inc ypos
bne 75$
inc ypos+1
75$ sec ;dec ysize, exit if done
lda ysize
sbc #1
sta ysize
lda ysize+1
sbc #0
sta ysize+1
bcs 90$ ;keep going if not < 0 (carry clear)
rts ;bye!
80$ lda bitcnt ;if count=0 then get new character
beq 90$
jmp gsb ;else just loop
90$ jmp gsa
;end