-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcedit.asm
324 lines (309 loc) · 5.35 KB
/
cedit.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
;-----------------------------------------------------------
; Filename: cedit.asm
; Long name: Cursor Editor
; Author: Chipmaster, with Kerm Martian aka Christopher Mitchell
; Last Update: Unknown
;
; Tab functions, mouse hook for GUI, InfoPop and MemoryPop-related
; code, and similar.
;
;Please consult license.txt for the fair use agreement
;implicitly binding by you continuing to read past this
;point. Close and delete this file if you do not agree
;to the terms of the agreement.
;-----------------------------------------------------------
CursorEdit:
xor a
ld (CX),a
ld (CY),a
ld (CGStimer),a
ld hl,40
bcall(_DAVLCheckOffset)
ld de,cMouseMask
ld bc,16
ldir
call displayOuterEdge
cmainloop:
ld hl,CGStimer
inc (hl)
inc hl
inc (hl)
call displayGrid
call displayCursor
call imfastcopy
bcall(_Cn2GetK)
cp 4
jr nz,notMoveUp
ld a,(CY)
or a
jr z,cmainloop
dec a
ld b,1
jp CCursorMove
notMoveUp:
cp 1
jr nz,notMoveDown
ld a,(CY)
cp 7
jr z,cmainloop
inc a
ld b,1
jp CCursorMove
notMoveDown:
cp 3
jr nz,notMoveRight
ld a,(CX)
cp 7
jr z,cmainloop
inc a
ld b,0
jp CCursorMove
notMoveRight:
cp 2
jr nz,notMoveLeft
ld a,(CX)
or a
jp z,cmainloop
dec a
ld b,0
jp CCursorMove
notMoveLeft:
ld b,0
cp 36h ;[2nd]
jr z,modPixelStatus
inc b
cp 30h ;[ALPHA]
jr z,modPixelStatus
inc b
cp 38h ;[DEL]
jr z,modPixelStatus
notChangePixel:
cp 9
ret z
jp cmainloop
;Calls
modPixelStatus:
;White Opaque, Black Opaque, White Trans
;If White Opaque:
;-Change cMouse
;If Black Opaque
;-Change cMouse
;-Change cMouseMask
;If White Trans
;-Change cMouseMask
push bc
; ld a,b
; cp 2 ;deleting (switch to trans)
; jr z,modPixelStatusMask
ld a,(CY)
ld hl,cMouse
ld e,a
ld d,0
add hl,de
ld c,%10000000
ld a,(CX)
or a
jr z,cgetpixelLoopFinish
ld b,a
cgetpixelLoop:
srl c
djnz cgetpixelLoop
cgetpixelLoopFinish: ;c is mask, (hl) is current value
pop af ;a is type
push af
or a ;2nd
jr z,cgetpixelLoopFinish_Black
cgetpixelLoopFinish_White:
ld a,c
cpl ;xor $ff
and (hl)
ld (hl),a
jr modPixelStatusMask
cgetpixelLoopFinish_Black:
ld a,(hl)
or c
ld (hl),a
modPixelStatusMask:
ld a,(CY)
ld hl,cMouseMask
ld e,a
;d = 0, never got a chance to change
add hl,de
ld c,%10000000
ld a,(CX)
or a
jr z,cgetpixelLoop2Finish
ld b,a
cgetpixelLoop2:
srl c
djnz cgetpixelLoop2
cgetpixelLoop2Finish: ;c is mask, (hl) is current value
pop af ;a is type
cp 2
jr z,cgetpixelLoop2Finish_Trans
ld a,c
cpl ;xor $ff
and (hl)
ld (hl),a
jr modPixelStatusEnd
cgetpixelLoop2Finish_Trans:
ld a,(hl)
or c
ld (hl),a
modPixelStatusEnd:
jp cmainLoop
;=====================================================================
displayOuterEdge:
;displays 4 black lines surrounding our grid.
ld hl,39*256+23 ;(23,39) (23,56)
push hl ;-------------
ld d,56 ;| |
ld e,l ;| |
push de ;| |
ld a,1 ;| |
call mos_fastline ;-------------
pop de ;(40,39) (40,56)
ld hl,56*256+40
push hl
ld a,1
call mos_fastline ;doesn't say what's destroyed. Assume all.
pop hl
ld de,39*256+40
push de
ld a,1
call mos_fastline
pop de
pop hl
ld a,1
call mos_fastline
ret
;=====================================================================
displayGrid:
;Displays the current state of pixels
ld b,8
ld hl,cMouse-1
ld e,22
GridOuterLoop:
push bc
inc hl
ld a,38 ;2 less than what it will display first at
inc e
inc e
ld b,%10000000
GridInnerLoop:
push bc
push hl
push de
push af
ld a,(hl)
and b
jr z,GridDisplayBlank
GridBlack:
pop af
pop de
inc a
inc a
push de
push af
ld l,e
ld b,2
ld ix,Block
call imPutSpriteMask
jr DisplayGridJoin
GridDisplayBlank:
ld de,8
or a
sbc hl,de
ld a,(hl)
and b
jr nz,GridDisplayGrey
GridDisplayBlank2:
pop af
pop de
inc a
inc a
push de
push af
ld l,e
ld b,2
ld ix,Blank
call imPutSpriteMask
DisplayGridJoin:
pop af
pop de
pop hl
pop bc
srl b
jr nz,GridInnerLoop
pop bc
djnz GridOuterLoop
ret
GridDisplayGrey:
ld a,(CGStimer)
srl a
jr c,GridDisplayBlank2
jr GridBlack
Block:
.db %00111111
.db %00111111
Blank:
.db %00111111
.db %00111111
Dummy:
.db 0,0,0,0, ;4 bytes of crap
BlockMask:
.db %11000000
.db %11000000
BlankMask:
.db %00000000
.db %00000000
displayCursor:
;flashes cursor at X,Y
ld a,(cblinktmr)
cp 20
jr nc,CursorcblinkOff
CursorOn:
ld ix,Block
displayCursorBack:
ld a,(CY)
add a,a
add a,24
ld l,a
ld a,(CX)
add a,a
add a,40
ld b,2
call imPutSpriteMask
ret
CursorcblinkOff:
cp 40
call nc,resetcblinktmr
CursorOff:
ld ix,Blank
jr displayCursorBack
resetcblinktmr:
xor a
ld (cblinktmr),a
ret
CCursorMove:
;Makes it blank at last spot
;Makes it solid at next spot
;b = 0 lr, b = 1 ud
push af
push bc
xor a
ld (cblinktmr),a
call CursorOff
pop bc
ld a,b
or a
jr z,CCursorMoveLeftRight
pop af
ld (CY),a
call CursorOn
jp cmainloop
CCursorMoveLeftRight:
pop af
ld (CX),a
call CursorOn
jp cmainloop