1059
|
1 ********************************************************************
|
|
2 * SHDW - Kings Quest III screen rendering module??
|
|
3 * $Id$
|
|
4 *
|
|
5 * Ed. Comments Who YY/MM/DD
|
|
6 * ------------------------------------------------------------------
|
|
7 * 0 Disassembly of original distribution PWZ 03/03/14
|
|
8 * using a combination of disasm v1.6 and
|
|
9 * the os9tools disassembler Os9disasm
|
|
10 *
|
|
11 * Note the header shows a data size of 0
|
|
12 * called from the sierra module and accesses
|
|
13 * data set up in that module
|
|
14 *
|
|
15 * Much credit and thanks is give to Nick Sonneveld and
|
|
16 * the other NAGI folks. Following his sources made it
|
|
17 * so much easier to document what was happening in here.
|
|
18
|
|
19 * This source will assemble byte for byte
|
|
20 * to the original kq3 shdw module.
|
|
21 *
|
|
22 * Header for : shdw
|
|
23 * Module size: $A56 #2646
|
|
24 * Module CRC : $E9E019 (Good)
|
|
25 * Hdr parity : $74
|
|
26 * Exec. off : $0012 #18
|
|
27 * Data size : $0000 #0
|
|
28 * Edition : $00 #0
|
|
29 * Ty/La At/Rv: $11 $81
|
|
30 * Prog mod, 6809 Obj, re-ent, R/O
|
|
31
|
|
32
|
|
33
|
|
34 * Disassembly by Os9disasm of shdw
|
|
35
|
|
36
|
|
37 nam shdw
|
|
38 ttl program module
|
|
39
|
|
40
|
|
41 ifp1
|
|
42 use defsfile
|
|
43 endc
|
|
44
|
|
45 tylg set Prgrm+Objct
|
|
46 atrv set ReEnt+rev
|
|
47 rev set $01
|
|
48 mod eom,name,tylg,atrv,start,size
|
|
49
|
|
50 size equ .
|
|
51
|
|
52 Xffa9 equ $FFA9 task 1 block 2
|
|
53 X01af equ $01AF a state.flag byte
|
|
54 X0551 equ $0551 given_pic_data
|
|
55
|
|
56
|
|
57 * OS9 data area definitions
|
|
58
|
|
59 u001a equ $001A shdw MMU block data
|
|
60 u002e equ $002E Load offset
|
|
61 u0042 equ $0042 Sierra process descriptor block
|
|
62 u0043 equ $0043 Sierra 2nd 8K data block
|
|
63 u005a equ $005A color
|
|
64 u005b equ $005B sbuff_drawmask
|
|
65 u005c equ $005C flag_control
|
|
66 u006b equ $006B pen_status
|
|
67
|
|
68 * these look like gen purpose scratch vars
|
|
69
|
|
70 u009e equ $009E
|
|
71 u009f equ $009F
|
|
72 u00a0 equ $00A0
|
|
73 u00a1 equ $00A1
|
|
74 u00a2 equ $00A2
|
|
75 u00a3 equ $00A3
|
|
76 u00a4 equ $00A4
|
|
77 u00a5 equ $00A5
|
|
78 u00a6 equ $00A6
|
|
79 u00a7 equ $00A7
|
|
80 u00a8 equ $00A8
|
|
81 u00a9 equ $00A9
|
|
82 u00aa equ $00AA
|
|
83 u00ab equ $00AB
|
|
84 u00ac equ $00AC
|
|
85 u00ad equ $00AD
|
|
86 u00ae equ $00AE
|
|
87 u00af equ $00AF
|
|
88 u00b0 equ $00B0
|
|
89 u00b2 equ $00B2
|
|
90 u00b3 equ $00B3
|
|
91
|
|
92
|
|
93
|
|
94
|
|
95 * VIEW OBJECTS FLAGS
|
|
96
|
|
97 O_DRAWN equ $01 * 0 - object has been drawn
|
|
98 O_BLKIGNORE equ $02 * 1 - ignore blocks and condition lines
|
|
99 O_PRIFIXED equ $04 * 2 - fixes priority agi cannot change it based on position
|
|
100 O_HRZNIGNORE equ $08 * 3 - ignore horizon
|
|
101 O_UPDATE equ $10 * 4 - update every cycle
|
|
102 O_CYCLE equ $20 * 5 - the object cycles
|
|
103 O_ANIMATE equ $40 * 6 - animated
|
|
104 O_BLOCK equ $80 * 7 - resting on a block
|
|
105 O_WATER equ $100 * 8 - only allowed on water
|
|
106 O_OBJIGNORE equ $200 * 9 - ignore other objects when determining contacts
|
|
107 O_REPOS equ $400 * 10 - set whenever a obj is repositioned
|
|
108 * that way the interpeter doesn't check it's next movement for one cycle
|
|
109 O_LAND equ $800 * 11 - only allowed on land
|
|
110 O_SKIPUPDATE equ $1000 * 12 - does not update obj for one cycle
|
|
111 O_LOOPFIXED equ $2000 * 13 - agi cannot set the loop depending on direction
|
|
112 O_MOTIONLESS equ $4000 * 14 - no movement.
|
|
113 * if position is same as position in last cycle then this flag is set.
|
|
114 * follow/wander code can then create a new direction
|
|
115 * (ie, if it hits a wall or something)
|
|
116 O_UNUSED equ $8000
|
|
117
|
|
118 * Local Program Defines
|
|
119
|
|
120 PICBUFF_WIDTH equ 160 ($A0)
|
|
121 PICBUFF_HEIGHT equ 168 ($A8)
|
|
122
|
|
123 picb_size equ PICBUFF_WIDTH*PICBUFF_HEIGHT $6900
|
|
124 x_max equ PICBUFF_WIDTH-1 159 ($9F)
|
|
125 y_max equ PICBUFF_HEIGHT-1 167 ($A7)
|
|
126
|
|
127 gfx_picbuff equ $6040 screen buff low address
|
|
128 gbuffend equ gfx_picbuff+picb_size screen buff high address $C940
|
|
129
|
|
130 blit_end equ gfx_picbuff+$6860
|
|
131
|
|
132 cmd_start equ $F0 first command value
|
|
133
|
|
134
|
|
135 name equ *
|
|
136 L000d fcs 'shdw'
|
|
137 fcb $00
|
|
138
|
|
139 * This module is linked to in sierra
|
|
140
|
|
141 start equ *
|
|
142 L0012 lbra L05fb gfx_picbuff_update_remap
|
|
143 lbra L0713 obj_chk_control
|
|
144 lbra L0175 render_pic (which calls pic_cmd_loop)
|
|
145 lbra L0189 pic_cmd_loop
|
|
146 lbra L07be obj_blit
|
|
147 lbra L0927 obj_add_pic_pri
|
|
148 lbra L0a0f blit_restore
|
|
149 lbra L09d8 blit_save
|
|
150 lbra L040e sbuff_fill
|
|
151 lbra L063a blitlist_draw
|
|
152 lbra L0615 blitlist_erase
|
|
153
|
|
154 fcc 'AGI (c) copyright 1988 SIERRA On-Line'
|
|
155 fcc 'CoCo3 version by Chris Iden'
|
|
156 fcb C$NULL
|
|
157
|
|
158 * Twiddles with MMU
|
|
159 * accd is loaded by calling program
|
|
160 *
|
|
161 * u001a = shdw mem block data
|
|
162 * u0042 = sierra process descriptor block
|
|
163 * u0043 = Sierra 2nd 8K data block
|
|
164
|
|
165 L0074 cmpa u001a compare to shdw mem block
|
|
166 beq L008e equal ?? no work to be done move on
|
|
167 orcc #IntMasks turn off interupts
|
|
168 sta u001a store the value passed in by a
|
|
169 lda u0042 get sierra process descriptor map block
|
|
170 sta Xffa9 map it in to $2000-$3FFF
|
|
171 ldu u0043 2nd 8K data block in Sierra
|
|
172 lda u001a load my mem block value
|
|
173 sta ,u save my values at address held in u0043
|
|
174 stb $02,u
|
|
175 std Xffa9 map it to task 1 block 2
|
|
176 andcc #^IntMasks restore the interupts
|
|
177 L008e rts we done
|
|
178
|
|
179 L008f fcb $00 load offsets updated flag
|
|
180
|
|
181 * binary_list[] (pic_render.c)
|
|
182 L0090 fdb $8000
|
|
183 fdb $4000
|
|
184 fdb $2000
|
|
185 fdb $1000
|
|
186 fdb $0800
|
|
187 fdb $0400
|
|
188 fdb $0200
|
|
189 fdb $0100
|
|
190 fdb $0080
|
|
191 fdb $0040
|
|
192 fdb $0020
|
|
193 fdb $0010
|
|
194 fdb $0008
|
|
195 fdb $0004
|
|
196 fdb $0002
|
|
197 fdb $0001
|
|
198
|
|
199 * circle_data[] (pic_render.c)
|
|
200 L00b0 fdb $8000
|
|
201 fdb $e000
|
|
202 fdb $e000
|
|
203 fdb $e000
|
|
204 fdb $7000
|
|
205 fdb $f800
|
|
206 fdb $f800
|
|
207 fdb $f800
|
|
208 fdb $7000
|
|
209 fdb $3800
|
|
210 fdb $7c00
|
|
211 fdb $fe00
|
|
212 fdb $fe00
|
|
213 fdb $fe00
|
|
214 fdb $7c00
|
|
215 fdb $3800
|
|
216 fdb $1c00
|
|
217 fdb $7f00
|
|
218 fdb $ff80
|
|
219 fdb $ff80
|
|
220 fdb $ff80
|
|
221 fdb $ff80
|
|
222 fdb $ff80
|
|
223 fdb $7f00
|
|
224 fdb $1c00
|
|
225 fdb $0e00
|
|
226 fdb $3f80
|
|
227 fdb $7fc0
|
|
228 fdb $7fc0
|
|
229 fdb $ffe0
|
|
230 fdb $ffe0
|
|
231 fdb $ffe0
|
|
232 fdb $7fc0
|
|
233 fdb $7fc0
|
|
234 fdb $3f80
|
|
235 fdb $1f00
|
|
236 fdb $0e00
|
|
237 fdb $0f80
|
|
238 fdb $3fe0
|
|
239 fdb $7ff0
|
|
240 fdb $7ff0
|
|
241 fdb $fff8
|
|
242 fdb $fff8
|
|
243 fdb $fff8
|
|
244 fdb $fff8
|
|
245 fdb $fff8
|
|
246 fdb $7ff0
|
|
247 fdb $7ff0
|
|
248 fdb $3fe0
|
|
249 fdb $0f80
|
|
250 fdb $07c0
|
|
251 fdb $1ff0
|
|
252 fdb $3ff8
|
|
253 fdb $7ffc
|
|
254 fdb $7ffc
|
|
255 fdb $fffe
|
|
256 fdb $fffe
|
|
257 fdb $fffe
|
|
258 fdb $fffe
|
|
259 fdb $fffe
|
|
260 fdb $7ffc
|
|
261 fdb $7ffc
|
|
262 fdb $3ff8
|
|
263 fdb $1ff0
|
|
264 fdb $07c0
|
|
265
|
|
266 * circle_list[] (pic_render.c)
|
|
267 * this data is different in the file
|
|
268 * { 0, 1, 4, 9, 16, 25, 37, 50 }
|
|
269 * These run like a set of numbers**2 {0,1,2,3,4,5,~6,~7}
|
|
270 * ah ha these are multiples 2*(0,1,2,3,4,5,~6,~7)**2)
|
|
271
|
|
272 L0132 fcb $00,$00 0
|
|
273 fcb $00,$02 2
|
|
274 fcb $00,$08 8
|
|
275 fcb $00,$12 18
|
|
276 fcb $00,$20 32
|
|
277 fcb $00,$32 50
|
|
278 fcb $00,$4a 74
|
|
279 fcb $00,$64 100
|
|
280
|
|
281
|
|
282 * select case dispatch table for pic_cmd_loop()
|
|
283
|
|
284 L0142 fdb $01bc enable_pic_draw()
|
|
285 fdb $01c9 disable_pic_draw()
|
|
286 fdb $01d4 enable_pri_draw()
|
|
287 fdb $01e9 disable_pri_draw()
|
|
288 fdb $02de draw_y_corner()
|
|
289 fdb $02d1 draw_x_corner()
|
|
290 fdb $0309 absolute_line()
|
|
291 fdb $031d relative_line()
|
|
292 fdb $0359 pic_fill()
|
|
293 fdb $0211 read_pen_status()
|
|
294 fdb $01f4 plot_with_pen()
|
|
295
|
|
296
|
|
297 * This code adds the load offsets to the program offsets above
|
|
298 *
|
|
299 * u00ab = loop counter
|
|
300 *
|
|
301 L0158 tst L008f,pcr test if we've loaded the offsets already
|
|
302 bne L0174 done once leave
|
|
303 inc L008f,pcr not done set the flag
|
|
304 lda #$0b set our index to 11
|
|
305 sta u00ab stow it in mem since we are going to clobber b
|
|
306 leau >L0142,pcr load table head address
|
|
307 L016a ldd u002e get load offset set in sierra
|
|
308 addd ,u add the load offset
|
|
309 std ,u++ and stow it back, bump pointer
|
|
310 dec u00ab decrement the index
|
|
311 bne L016a ain't done go again
|
|
312 L0174 rts we're out of here
|
|
313
|
|
314
|
|
315 * The interaction between render_pic and pic_cmd_loop is divided
|
|
316 * differently in the NAGI source pic_render.c
|
|
317
|
|
318 * render_pic()
|
|
319 * 4 = proirity and color = F, so the note says
|
|
320 * so the priority is MSnibble and the color is LSnibble
|
|
321
|
|
322 L0175 ldd #$4f4f load the color
|
|
323 pshs d push it on the stack for the pass
|
|
324 lbsr L040e call sbuff_fill routine
|
|
325 leas $02,s reset stack to value at entry
|
|
326 ldd $02,s pull the next word
|
|
327 pshs d push it on top of the stack
|
|
328 lbsr L0189 call pic_cmd_loop()
|
|
329 leas $02,s once we return clean up stack again
|
|
330 rts return
|
|
331
|
|
332 * pic_cmd_loop() (pic_render.c)
|
|
333 *
|
|
334 * u005a = color
|
|
335 * u005b = sbuff_drawmask
|
|
336 * u006b = pen_status
|
|
337
|
|
338 L0189 pshs y
|
|
339 bsr L0158 ensure load offset has been added to table address
|
|
340 lbsr L06fc sbuff_fill()
|
|
341 clra make a zero
|
|
342 sta u005b sbuff_drawmask
|
|
343 sta u006b pen_status
|
|
344 coma make the complement FF
|
|
345 sta u005a store color
|
|
346
|
|
347 ldu 4,s get the word passed in to us on the stack
|
|
348 ldd 5,u pull out the required info for the mmu twiddle
|
|
349 lbsr L0074 twiddle mmu
|
|
350
|
|
351 * pic_cmd_loop() (pic_render.c) starts here
|
|
352 ldx X0551 given_pic_data set in pic_res.c
|
|
353 L01a2 lda ,x+ pic_byte
|
|
354
|
|
355 L01a4 cmpa #$ff if it's FF were done
|
|
356 beq L01b9 so head out
|
|
357 suba #cmd_start first valid cmd = F0 so subtract to get index
|
|
358 blo L01a2 less than F0 ignore it get next byte
|
|
359 cmpa #$0a check for top end
|
|
360 bhi L01a2 greater than FA ignore it get next byte
|
|
361 leau >L0142,pcr load the addr of the dispatch table
|
|
362 asla sign extend multiply by two for double byte offset
|
|
363 jsr [a,u] make the call
|
|
364 bra L01a4 loop again
|
|
365
|
|
366 L01b9 puls y done then fetch the y back
|
|
367 rts and return
|
|
368
|
|
369 * Command $F0 change picture color and enable picture draw
|
|
370 * enable_pic_draw() pic_render.c
|
|
371 * differs slightly with pic_render.c
|
|
372 * does't have colour_render()
|
|
373 * and setting of colour_picpart
|
|
374 *
|
|
375 * u005a = color
|
|
376 * u005b = sbuff_drawmask
|
|
377 *
|
|
378 * x contains pointer to given_pic_data known as the pic_byte
|
|
379 * after ldd
|
|
380 * a contains color
|
|
381 * b contains draw mask
|
|
382 * returns the next pic_byte in a
|
|
383
|
|
384 L01bc ldd u005a pulls in color and sbuff_drawmask
|
|
385 anda #$f0 and color with $F0
|
|
386 ora ,x+ or that result with the pic_byte and bump to next
|
|
387 orb #$0f or the sbuff_drawmask with $0F
|
|
388 std u005a store the updated values
|
|
389 lda ,x+ return value ignored so this just bumps to next pic_byte
|
|
390 rts
|
|
391
|
|
392
|
|
393 * Command $F1 Disable picture draw
|
|
394 * disable_pic_draw()
|
|
395 *
|
|
396 * u005a = color
|
|
397 * u005b = sbuff_drawmask
|
|
398 * x contains pointer to given_pic_data known as the pic_byte
|
|
399 * after ldd
|
|
400 * a contains color
|
|
401 * b contains draw mask
|
|
402 * returns the next pic_byte in a
|
|
403
|
|
404 L01c9 ldd u005a pulls in color and sbuff_drawmask
|
|
405 ora #$0f ors color with $0F (white ??)
|
|
406 andb #$f0 ands draw mask with $F0
|
|
407 std u005a store the updated values
|
|
408 lda ,x+ return value ignored so this just bumps to next pic_byte
|
|
409 rts
|
|
410
|
|
411 * Command $F2 Changes priority color and enables priority draw
|
|
412 * enable_pri_draw() pic_render.c
|
|
413 *
|
|
414 * u005a = color
|
|
415 * u005b = sbuff_drawmask
|
|
416 * x contains pointer to given_pic_data known as the pic_byte
|
|
417 * after ldd
|
|
418 * a contains color
|
|
419 * b contains draw mask
|
|
420 * returns the next pic_byte in a
|
|
421
|
|
422 L01d4 ldd u005a pulls in color and sbuff_drawmask
|
|
423 anda #$0f ands color with $0F
|
|
424 sta u005a save color
|
|
425 lda ,x+ loads pic_byte and bumps to next
|
|
426 asla times 2 with sign extend
|
|
427 asla again times 2
|
|
428 asla and again times 2
|
|
429 asla end result is multiply pic_byte by 16 ($10)
|
|
430 ora u005a or that value with the modified color
|
|
431 orb #$f0 or the sbuff_drawmask with $F0
|
|
432 std u005a store the updated values
|
|
433 lda ,x+ return value ignored so this just bumps to next pic_byte
|
|
434 rts
|
|
435
|
|
436 * Command $F3 Disable priority draw
|
|
437 * diasable_pri_draw() pic_render.c
|
|
438 *
|
|
439 * u005a = color
|
|
440 * u005b = sbuff_drawmask
|
|
441 * x contains pointer to given_pic_data known as the pic_byte
|
|
442 * after ldd
|
|
443 * a contains color
|
|
444 * b contains draw mask
|
|
445 * returns the next pic_byte in a
|
|
446
|
|
447
|
|
448 L1e9 ldd u005a pulls in color and sbuff_drawmask
|
|
449 ora #$f0 or the color with $F0
|
|
450 andb #$0f and the sbuff_drawmask with $0F
|
|
451 std u005a store the updated values
|
|
452 lda ,x+ return value ignored so this just bumps to next pic_byte
|
|
453 rts
|
|
454
|
|
455 * Command $FA plot with pen
|
|
456 * Logic is pic_byte >= 0xF0 in c source.
|
|
457 * Emailed Nick Sonneveld 3/14/ 03
|
|
458 *
|
|
459 * u006b = pen_status
|
|
460 * u00a2 = pen_x position
|
|
461 * u00a3 = pen_y position
|
|
462 * u00a6 = texture_num
|
|
463 *
|
|
464 * x contains pointer to given_pic_data known as the pic_byte
|
|
465 * returns the next pic_byte in a
|
|
466
|
|
467 * plot_with_pen() (pic_render.c)
|
|
468 L01f4 lda u006b pen_status
|
|
469 bita #$20 and but don't change check for pen type solid or splater ($20)
|
|
470 beq L0204 is splater
|
|
471 lda ,x+ load pic_byte (acca) from pic_code and bump pointer
|
|
472 cmpa #cmd_start test against $F0 if a is less than
|
|
473 * based on discussions with Nick this must have been a bug
|
|
474 * in the earlier versions of software...
|
|
475 * if it is less than $F0 it's just a picture byte
|
|
476 * fix next rev.
|
|
477 lblo L02ea branch to a return statement miles away (could be fixed)
|
|
478 sta u00a6 save our pic_byte in texture_num
|
|
479 L0204 lbsr L0364 call read_xy_postion
|
|
480 lblo L02ea far off rts
|
|
481 std u00a2 pen x/y position
|
|
482 bsr L0218 call plot_with_pen2()
|
|
483 bra L01f4 go again ...
|
|
484 * yes there is no rts here in the c source either
|
|
485
|
|
486
|
|
487 * Command $F9 Change pen size and style
|
|
488 * read_pen_status() pic_render.c
|
|
489 *
|
|
490 * u006b = pen_status
|
|
491 *
|
|
492 * x contains pointer to given_pic_data known as the pic_byte
|
|
493 * returns the next pic_byte in a
|
|
494
|
|
495 L0211 lda ,x+ get pic_byte
|
|
496 sta u006b save as pen_status
|
|
497 lda ,x+ return value ignored so this just bumps to next pic_byte
|
|
498 rts
|
|
499
|
|
500
|
|
501 * plot_with_pen2()
|
|
502 * called from plot with pen
|
|
503 * Sets up circle_ptr
|
|
504 *
|
|
505 * u006b = pen_status
|
|
506 * u009e = pos_init_x
|
|
507 * u009f = pos_init_y
|
|
508 * u00a2 = pen_x position
|
|
509 * u00a3 = pen_y position
|
|
510 * u00a4 = pen_final_x
|
|
511 * u00a5 = pen_final_y
|
|
512 * u00a7 = pen.size
|
|
513 * u00a8 = t
|
|
514 * u00a9 = pensize x 2
|
|
515 * u00aa = "
|
|
516 * u00ab = scratch var
|
|
517 * u00ac = scratch var
|
|
518 * u00ad = penwidth
|
|
519 * u00ae = "
|
|
520
|
|
521 L0218 ldb u006b pen_status
|
|
522 andb #$07
|
|
523 stb u00a7 pen.size ?? save for pen_status & $07
|
|
524
|
|
525 clra clear a and condition codes
|
|
526 lslb multiply by 2
|
|
527 std u00a9 pen size x 2
|
|
528 leau L0132,pcr circle_list[]
|
|
529 ldd b,u d now holds one of the circle_list values
|
|
530 leau L00b0,pcr circle_data[]
|
|
531 leau d,u use that to index to a circle_data item
|
|
532 * u now is circle_ptr
|
|
533
|
|
534 * Set up x position
|
|
535 clra
|
|
536 ldb u00a2 load pen_x position
|
|
537 lslb multiply by two
|
|
538 rola
|
|
539 subb u00a7 subtract the pen.size
|
|
540 bcc L023f outcome not less than zero move on
|
|
541 deca
|
|
542 bpl L023f if we still have pos must be 0 or >
|
|
543 ldd #0000
|
|
544 bra L024d
|
|
545 L023f std u00ab store pen_x at scratch
|
|
546
|
|
547 ldd #$0140 start with 320
|
|
548 subd u00a9 subtract 2 x pen.size
|
|
549 cmpd u00ab pen_x to calc
|
|
550 bls L024d if pen_x is greater keep temp calc
|
|
551 ldd u00ab otherwise use pen_x
|
|
552
|
|
553 L024d lsra divide by 2
|
|
554 rorb
|
|
555 stb u00a2 stow at pen_x
|
|
556 stb u00a4 stow at pen_final_x
|
|
557
|
|
558 * Set up y position
|
|
559 lda u00a3 pen_y
|
|
560 suba u00a7 pen.size
|
|
561 bcc L025c >= 0 Ok go stow it
|
|
562 clra otherwise less than zero so set it to 0
|
|
563 bra L0268 go stow it
|
|
564 L025c sta u00ab store pen_y at scratch
|
|
565
|
|
566 lda #y_max start with 167
|
|
567 suba u00aa subtract 2 x pen.size
|
|
568 cmpa u00ab compare to pen_y calced so far
|
|
569 bls L0268 if pen_y > calc use calc and save it
|
|
570 lda u00ab otherwise use pen_y
|
|
571 L0268 sta u00a3 pen_y
|
|
572 sta u00a5 pen_final_y
|
|
573
|
|
574 lda u00a6 texture_num
|
|
575 ora #$01
|
|
576 sta u00a8 t ??
|
|
577
|
|
578 ldb u00aa 2 x pen.size
|
|
579 incb bump it by one
|
|
580 tfr b,a copy b into a
|
|
581 adda u00a5 add value to pen_final_y
|
|
582 sta u00a5 save new pen_final_y
|
|
583 lslb shift b left (multiply by 2)
|
|
584
|
|
585 leax L0090,pcr binary list[]
|
|
586 ldd b,x use 2x pensize + 1 to index into list
|
|
587 std u00ad pen width ???
|
|
588
|
|
589 * this looks like it should have been nested for loops
|
|
590 * but not coded that way in pic_render.c
|
|
591
|
|
592 * new y
|
|
593 L0284 leax L0090,pcr binary_list[]
|
|
594
|
|
595 * new x
|
|
596 L0288 lda u006b pen_status
|
|
597 bita #O_UPDATE and it with $10 but don't change
|
|
598 bne L0298 not equal zero go on to next pen status test
|
|
599 ldd ,u otherwise load data at circle_ptr
|
|
600 anda ,x and that with first element in binary_list
|
|
601 bne L0298 if thats not zero go on to next pen status check
|
|
602
|
|
603 andb $01,x and the second bytes of data at circle_ptr
|
|
604 * and binary_list
|
|
605 beq L02ba that outcome is equ zero head for next calcs
|
|
606
|
|
607 L0298 lda u006b pen_status
|
|
608 bita #$20 anded with $20 but don't change
|
|
609 beq L02af equals zero set up and plot buffer
|
|
610 lda u00a8 otherwise load t (texture_num | $01)
|
|
611 lsra divide by 2
|
|
612 bcc L02a5 no remainder save that number as t
|
|
613 eora #$b8 exclusive or t with $B8
|
|
614 L02a5 sta u00a8 save new t
|
|
615 bita #O_DRAWN anded with 1 but don't change
|
|
616 bne L02ba not equal zero don't plot
|
|
617 bita #O_BLKIGNORE anded with 2 but don't change
|
|
618 beq L02ba does equal zero don't plot
|
|
619
|
|
620 L02af pshs u save current u sbuff_plot uses it
|
|
621 ldd u00a2 load pen_x/pen_y values
|
|
622 std u009e save at pos_init_x/y positions
|
|
623 lbsr L046f head for sbuff_plot()
|
|
624 puls u retrieve u from before call
|
|
625
|
|
626 L02ba inc u00a2 increment pen_x value
|
|
627
|
|
628 leax $04,x move four bytes in the binary_list
|
|
629 cmpx u00ad comapre that value to pen_width
|
|
630 bls L0288 less or same go again
|
|
631
|
|
632 leau $02,u bump circle_ptr to next location in circle_data[]
|
|
633
|
|
634 lda u00a4 load pen_final_x
|
|
635 sta u00a2 store at pen_x
|
|
636 inc u00a3 bump pen_y
|
|
637 lda u00a3 pen_y
|
|
638 cmpa u00a5 compare to pen_final_y
|
|
639 bne L0284 not equal go do the next row
|
|
640 rts
|
|
641
|
|
642
|
|
643 * Command $F5 Draw an X corner
|
|
644 * draw_x_corner() pic_render.c
|
|
645 *
|
|
646 * u009e = pos_init_x
|
|
647 * u009f = pos_init_y
|
|
648
|
|
649 L02d1 lbsr L0364 call read_xy_pos
|
|
650 bcs L02ea next subs rts
|
|
651 std u009e save pos_init_x/y positions
|
|
652 lbsr L046f head for sbuff_plot()
|
|
653 bsr L02eb draw_corner(0)
|
|
654 rts
|
|
655
|
|
656
|
|
657 * Command $F4 Draw a Y corner
|
|
658 * draw_y_corner() pic_render.c
|
|
659 *
|
|
660 * u009e = pos_init_x
|
|
661 * u009f = pos_init_y
|
|
662
|
|
663 L02de lbsr L0364 call read_xy_pos
|
|
664 bcs L02ea return
|
|
665 std u009e save at pos_init_x/y positions
|
|
666 lbsr L046f head for sbuff_plot()
|
|
667 bsr L02f9 draw_corner(1)
|
|
668 L02ea rts
|
|
669
|
|
670
|
|
671
|
|
672 * draw_corner(u8 type) pic_render.c
|
|
673 *
|
|
674 * u009e = pos_init_x
|
|
675 * u009f = pos_init_y
|
|
676 * u00a0 = pos_final_x
|
|
677 * u00a1 = pos_final_y
|
|
678
|
|
679 draw_x:
|
|
680 L02eb lbsr L036f get_x_pos()
|
|
681 bcs L02ea prior subs return
|
|
682 sta u00a0 store as pos_final_x
|
|
683 ldb u009f load pos_init_y
|
|
684 stb u00a1 store as pos_final_y
|
|
685 lbsr L0421 call sbuff_xline()
|
|
686
|
|
687 draw_y:
|
|
688 L02f9 lbsr L0381 get_y_pos
|
|
689 bcs L02ea prior subs return
|
|
690 stb u00a1 save pos_final_y
|
|
691 lda u009e load pos_init_x
|
|
692 sta u00a0 save pos_final_x
|
|
693 lbsr L0447 sbuff_yline()
|
|
694 bra L02eb head for draw_x
|
|
695
|
|
696
|
|
697
|
|
698 * Command $F6 Absolute line
|
|
699 * absolute_line()
|
|
700 * This command is before Draw X corner in nagi source
|
|
701 *
|
|
702 * u009e = pos_init_x
|
|
703 * u009f = pos_init_y
|
|
704 * u00a0 = pos_final_x
|
|
705 * u00a1 = pos_final_y
|
|
706
|
|
707 L0309 bsr L0364 call read_xy_pos
|
|
708 bcs L02ea prior subs return
|
|
709 std u009e save at pos_init_x/y positions
|
|
710 lbsr L046f head for sbuff_plot()
|
|
711 L0312 bsr L0364 call read_xy_pos
|
|
712 bcs L02ea prior subs return
|
|
713 std u00a0 save at pos_final_x/y and passed draw_line in d
|
|
714 lbsr L0394 call draw_line()
|
|
715 bra L0312 go again
|
|
716
|
|
717
|
|
718
|
|
719 * relative_line()
|
|
720 *
|
|
721 * u009e = pos_init_x
|
|
722 * u009f = pos_init_y
|
|
723 * u00a0 = pos_final_x
|
|
724 * u00a1 = pos_final_y
|
|
725
|
|
726 L031D bsr L0364 call read_xy_pos
|
|
727 bcs L02ea prior subs return
|
|
728 std u009e save at pos_init_x/y positions
|
|
729 lbsr L046f head for sbuff_plot()
|
|
730
|
|
731 * calc x
|
|
732 L0326 lda ,x+ get next pic_byte
|
|
733 * and load it in pos_data in c source
|
|
734 cmpa #cmd_start is that equal $F0 or greater
|
|
735 bcc L02ea yep were done so return (we use prior subs return ??)
|
|
736 * that rascal in acca changes names again to x_step
|
|
737 * but it's still the same old data
|
|
738 anda #$70 and that with $70
|
|
739 * (where these values are derived from I haven't a clue, as of yet :-))
|
|
740 lsra divide by 2
|
|
741 lsra and again
|
|
742 lsra once more
|
|
743 lsra and finally another for a /16
|
|
744 ldb -$01,x get the original value
|
|
745 bpl L0337 if original value not negative move on
|
|
746 nega else it was so flip the sign of the computed value
|
|
747 L0337 adda u009e add pos_init_x position
|
|
748 cmpa #x_max compare to 159
|
|
749 bls L033f if it's less or same move on
|
|
750 lda #x_max else cap it at 159
|
|
751 L033f sta u00a0 store as pos_final_x
|
|
752
|
|
753 * calc y
|
|
754 * not quite the same as pic_render.c almost
|
|
755 * we've go the pic_byte ... er pos_data ... now called y_step
|
|
756 * in b so lets calc the y_step
|
|
757 andb #$0f and with $0F (not in pic_render.c)
|
|
758 bitb #$08 and that with $08 but don't change
|
|
759 beq L034a if result = 0 move on
|
|
760 andb #$07 else and it with $07
|
|
761 negb and negate it
|
|
762 L034a addb u009f add calced value to pos_init_y
|
|
763 cmpb #y_max compare to 167
|
|
764 bls L0352 less or same move on
|
|
765 ldb #y_max greater ? cap it
|
|
766 L0352 stb u00a1 pos_final_y
|
|
767
|
|
768 * passes pos_final_x/y in d
|
|
769 lbsr L0394 call draw_line()
|
|
770
|
|
771 bra L0326 go again exit is conditinals inside loop
|
|
772
|
|
773 * Command $F8 Fill
|
|
774 * pic_fill()
|
|
775 *
|
|
776 * u009e = pos_init_x
|
|
777 * u009f = pos_init_y
|
|
778
|
|
779 L0359 bsr L0364 call read_xy_pos
|
|
780 bcs L02ea returned a 1 head for prior subs return
|
|
781 std u009e save at pos_init_x/y position
|
|
782 lbsr L0486 call sbuff_picfill()
|
|
783 bra L0359 loop till we get a 1 back from read_xy_pos
|
|
784
|
|
785 * read_xy_pos()
|
|
786 L0364 lbsr L036f go get x position
|
|
787 lblo L02ea prior subs return
|
|
788 lbsr L0381 go get the y position
|
|
789 rts
|
|
790
|
|
791
|
|
792 * get_x_pos()
|
|
793 L036f lda ,x+ load pic_byte
|
|
794 cmpa #cmd_start is it a command?
|
|
795 bhs L037e if so set CC
|
|
796 cmpa #x_max compare to 159
|
|
797 bls L037b is it less or same clear CC and return
|
|
798 lda #x_max greater than load acca with 159
|
|
799 L037b andcc #$fe clear CC ad return
|
|
800 rts
|
|
801
|
|
802
|
|
803 L037e orcc #1 returns a "1"
|
|
804 rts
|
|
805
|
|
806 * get_y_pos()
|
|
807 L0381 ldb ,x+ load pic_byte
|
|
808 cmpb #cmd_start is it a command
|
|
809 blo L038b nope less than command
|
|
810 lda -$01,x was a command load x back in acca
|
|
811 bra L037e go set CC
|
|
812 L038b cmpb #y_max compare to 167
|
|
813 bls L0391 is it less or same clear CC and return
|
|
814 ldb #y_max greater than load accb with 167
|
|
815 L0391 andcc #$fe clear CC and return
|
|
816 rts
|
|
817
|
|
818
|
|
819 * draw_line() pic_render.c
|
|
820 * while this is a void function() seems pos_final_x/y are passed in d
|
|
821 *
|
|
822 * u009e = pos_init_x
|
|
823 * u009f = pos_init_y
|
|
824 * u00a0 = pos_final_x
|
|
825 * u00a1 = pos_final_y
|
|
826 * u00a2 = x_count
|
|
827 * u00a3 = y_count
|
|
828 * u00a4 = pos_x
|
|
829 * u00a5 = pos_y
|
|
830 * u00a6 = line_x_inc
|
|
831 * u00a7 = line_y_inc
|
|
832 * u00a8 = x_component
|
|
833 * u00a9 = y_component
|
|
834 * u00aa = largest_line
|
|
835 * u00ab = counter
|
|
836
|
|
837 * process straight lines
|
|
838 L0394 cmpb u009f compare pos_final_y with pos_init_y
|
|
839 lbeq L0421 if equal call sbuff_xline() and don't return here
|
|
840 cmpa u009e else compare with pos_init_x position
|
|
841 lbeq L0447 if equal call sbuff_yline() and don't return here
|
|
842
|
|
843 ldd u009e load pos_init_x/y positions
|
|
844 std u00a4 store at pen_final ??? not in pic_render.c version
|
|
845
|
|
846 * process y
|
|
847 lda #$01 line_y_inc
|
|
848
|
|
849 ldb u00a1 load pos_final_y
|
|
850 subb u009f subtract pos_init_y
|
|
851 bcc L03ae greater or equal zero don't negate
|
|
852 * less than zero
|
|
853 nega flip the sign of line_y_inc
|
|
854 negb flip the sign of y_component
|
|
855
|
|
856 L03ae sta u00a7 store line_y_inc
|
|
857 stb u00a9 store y_component
|
|
858
|
|
859 * process x
|
|
860 lda #$01 line_x_inc
|
|
861
|
|
862 ldb u00a0 load pos_final_x
|
|
863 subb u009e subtract pos_init_x
|
|
864 bcc L03bc greater or equal zero don't negate
|
|
865 * less than zero
|
|
866 nega flip the sign of line_x_inc
|
|
867 negb flip the sign of x_component
|
|
868 L03bc sta u00a6 store line_x_inc
|
|
869 stb u00a8 store x_component
|
|
870
|
|
871 * compare x/y components
|
|
872 cmpb u00a9 compare y_component to x_component
|
|
873 blo L03d0 if x_component is smaller move on
|
|
874
|
|
875
|
|
876 * x >= y
|
|
877 * x_component is in b
|
|
878 stb u00ab counter
|
|
879 stb u00aa largest_line
|
|
880 lsrb divide by 2
|
|
881 stb u00a3 store y_count
|
|
882 clra make a zero
|
|
883 sta u00a2 store x_count
|
|
884 bra L03dc move on
|
|
885
|
|
886 * x < y
|
|
887 L03d0 lda u00a9 load y_component
|
|
888 sta u00ab stow as counter
|
|
889 sta u00aa stow as largest line
|
|
890 lsra divide by 2
|
|
891 sta u00a2 store x_count
|
|
892 clrb make a zero
|
|
893 stb u00a3 store as y_count
|
|
894
|
|
895
|
|
896 * loops through the line and uses sbuff_plot to do the screen write
|
|
897 * y_count is in b
|
|
898 L03dc addb u00a9 add in the y_component
|
|
899 stb u00a3 and stow back as y_count
|
|
900 cmpb u00aa compare that with line_largest
|
|
901 blo L03ee if y_count >= line_largest is not the case branch
|
|
902 subb u00aa subtract line_largest
|
|
903 stb u00a3 store as y_count
|
|
904 ldb u00a5 load pos_y
|
|
905 addb u00a7 add line_y_inc
|
|
906 stb u00a5 stow as pos_y
|
|
907
|
|
908 * x_count is in a
|
|
909 L03ee adda u00a8 add in x_component
|
|
910 sta u00a2 store as x_count
|
|
911 cmpa u00aa compare that with line_largest
|
|
912 blo L0400 if x_count >= line_largest is not the case branch
|
|
913 suba u00aa subtract line_longest
|
|
914 sta u00a2 store at x_count
|
|
915 lda u00a4 load pos_x
|
|
916 adda u00a6 add line_x_inc
|
|
917 sta u00a4 stow as pos_x
|
|
918
|
|
919 L0400 ldd u00a4 load computed pos_x/y
|
|
920 std u009e store at pos_init_x/y positions
|
|
921 lbsr L046f head for sbuff_plot()
|
|
922 ldd u00a2 reload x/y_count
|
|
923 dec u00ab decrement counter
|
|
924 bne L03dc if counter not zero go again
|
|
925 rts
|
|
926
|
|
927 ***********************************************************************
|
|
928
|
|
929
|
|
930 * sbuff_fill() sbuf_util.c
|
|
931 * fill color is passed in s register
|
|
932
|
|
933 L040e pshs x save x as we use it for an index
|
|
934 ldu #gbuffend address to write to
|
|
935 ldx #picb_size $6900 bytes to write (26.25K)
|
|
936 * this would be picture buffer width x height
|
|
937 ldd $04,s since we pushed x pull our color input out of the stack
|
|
938 L0418 std ,--u store them and dec dest address
|
|
939 leax -$02,x dec counter
|
|
940 bne L0418 loop till done
|
|
941 puls x fetch the x
|
|
942 rts return
|
|
943
|
|
944
|
|
945 * sbuff_xline() sbuff_util.c
|
|
946 * gets called here with pos_final_x/y in accd
|
|
947 *
|
|
948 * u005a = color
|
|
949 * u005b = sbuff_drawmask
|
|
950 * u009e = pos_init_x
|
|
951 * u009f = pos_init_y
|
|
952 * u00a0 = pos_final_x
|
|
953 * u00a1 = pos_final_y
|
|
954 * u00ac = x_orig
|
|
955
|
|
956 L0421 sta u00ac stow as x_orig
|
|
957 cmpa u009e compare with pos_init_x position
|
|
958 bhs L042d if pos_final_x same or greater branch
|
|
959
|
|
960 * otherwise init > final so swap init and final
|
|
961 ldb u009e load pos_init_x position
|
|
962 stb u00a0 save pos_final_x position
|
|
963 sta u009e save pos_init_x position
|
|
964
|
|
965 L042d bsr L046f head for sbuff_plot() returns pointer in u
|
|
966
|
|
967 ldb u00a0 load pos_final_x
|
|
968 subb u009e subtract pos_init_x position
|
|
969 beq L0442 if they are the same move on
|
|
970 * b now holds the loop counter len
|
|
971 * u is the pointer returned from sbuff_plot
|
|
972 leau $01,u bump the pointer one byte right
|
|
973 L0437 lda ,u get the the byte
|
|
974 ora u005b or it with sbuff_drawmmask
|
|
975 anda u005a and it with the color
|
|
976 sta ,u+ save it back and bump u to next byte
|
|
977 decb decrememnt the loop counter
|
|
978 bne L0437 done them all? Nope loop
|
|
979
|
|
980 L0442 lda u00ac x_orig (pos_final_x)
|
|
981 sta u009e save at pos_init_x position
|
|
982 rts
|
|
983
|
|
984
|
|
985 * sbuff_yline() sbuf_util.c
|
|
986 * gets called here with pos_final_x/y in accd
|
|
987 *
|
|
988 * u005a = color
|
|
989 * u005b = sbuff_drawmask
|
|
990 * u009e = pos_init_x
|
|
991 * u009f = pos_init_y
|
|
992 * u00a0 = pos_final_x
|
|
993 * u00a1 = pos_final_y
|
|
994 * u00ac = y_orig
|
|
995
|
|
996 L0447 stb u00ac stow as y_orig
|
|
997 cmpb u009f compare with pos_init_y
|
|
998 bhs L0453 if pos_final same or greater branch
|
|
999
|
|
1000 * otherwise init > final so swap 'em
|
|
1001 lda u009f load pos_init_y
|
|
1002 sta u00a1 stow as pos_final_y
|
|
1003 stb u009f stow as pos_init_y
|
|
1004
|
|
1005 L0453 bsr L046f head for sbuff_plot() returns pointer in u
|
|
1006 ldb u00a1 load pos_final_y
|
|
1007 subb u009f subtract pos_init_y
|
|
1008 beq L046a if they are the same move on
|
|
1009 * b now holds the loop counter len
|
|
1010 * u is the pointer returned from sbuff_plot
|
|
1011 L045b leau PICBUFF_WIDTH,u bump ptr one line up
|
|
1012 lda ,u get the byte
|
|
1013 ora u005b or it with sbuff_drawmmask
|
|
1014 anda u005a and it with the color
|
|
1015 sta ,u save it back out
|
|
1016 decb decrement the loop counter
|
|
1017 bne L045b done them all ? Nope loop
|
|
1018
|
|
1019 L046a ldb u00ac load y_orig
|
|
1020 stb u009f save it as pos_init_y
|
|
1021 rts
|
|
1022
|
|
1023
|
|
1024 * sbuff_plot() from sbuf_util.c
|
|
1025 * according to agi.h PBUF_MULT(width) ((( (width)<<2) + (width))<<5)
|
|
1026 * which next 3 lines equate to so the $A0 is from 2 x 5
|
|
1027 * pointer is returned in index reg u
|
|
1028 *
|
|
1029 * u005a = color
|
|
1030 * u005b = sbuff_drawmask
|
|
1031 * u009e = pos_init_x
|
|
1032 * u009f = pos_init_y
|
|
1033
|
|
1034 L046f ldb u009f load pos_init_y
|
|
1035 lda #$A0 according to PBUF_MULT()
|
|
1036 mul do the math
|
|
1037 addb u009e add pos_init_x position
|
|
1038 adca #0000 this adds the carry bit in to a
|
|
1039 addd #gfx_picbuff add that to the start of the screen buf $6040
|
|
1040 tfr d,u move this into u
|
|
1041 lda ,u get the byte u points to
|
|
1042 ora u005b or it with sbuff_drawmask
|
|
1043 anda u005a and it with the color
|
|
1044 sta ,u and stow it back at the same place
|
|
1045 rts return
|
|
1046
|
|
1047
|
|
1048
|
|
1049
|
|
1050 * sbuff_picfill(u8 ypos, u8 xpos) sbuf_util.c
|
|
1051 * u005a = color
|
|
1052 * u005b = sbuff_drawmask
|
|
1053 * u009e = pos_init_x
|
|
1054 * u009f = pos_init_y
|
|
1055 * u00a0 = left
|
|
1056 * u00a1 = right
|
|
1057 * u00a2 = old_direction
|
|
1058 * u00a3 = direction
|
|
1059 * u00a4 = old_initx
|
|
1060 * u00a5 = old_inity
|
|
1061 * u00a6 = old_left
|
|
1062 * u00a7 = old_right
|
|
1063 * u00a8 = stack_left
|
|
1064 * u00a9 = stack_right
|
|
1065 * u00aa = toggle
|
|
1066 * u00ab = old_toggle
|
|
1067 * u00ae = color_bl
|
|
1068 * u00af = mask_dl
|
|
1069 * u00b0 = old_buff (word)
|
|
1070 * u00b2 = temp (buff)
|
|
1071
|
|
1072
|
|
1073 colorbl set $4F
|
|
1074 temp_stk set $E000
|
|
1075
|
|
1076 L0486 pshs x save x
|
|
1077 ldx #temp_stk load addr to create a new stack
|
|
1078 sts ,--x store current stack pointer there and decrement x
|
|
1079 tfr x,s make that the stack
|
|
1080 * s is now stack_ptr pointing to fill_stack
|
|
1081
|
|
1082 ldb u009f pos_init_y
|
|
1083 lda #$a0 set up PBUF_MULT
|
|
1084 mul do the math
|
|
1085 addb u009e add pos_init_x
|
|
1086 adca #0000 add in that carry bit
|
|
1087 addd #gfx_picbuff add the start of screen buffer $6040
|
|
1088 tfr d,u move this to u
|
|
1089 * u now is pointer to screen buffer b
|
|
1090
|
|
1091
|
|
1092 ldb u005a load color
|
|
1093 lda u005b load sbuff_drawmask
|
|
1094
|
|
1095 * next 2 lines must have been a if (sbuff_drawmask > 0)
|
|
1096 * not in the nagi source
|
|
1097
|
|
1098 lbeq L05f5 if sbuff_drawmask = 0 we're done
|
|
1099 bpl L04b8 if not negative branch to test color
|
|
1100
|
|
1101 cmpa #cmd_start comp $F0 with sbuff_drawmask
|
|
1102 bne L04b8 not = go test color for $0F
|
|
1103 andb #$f0 and color with $F0
|
|
1104 cmpb #$40 compare that to $40 (input was $4x)
|
|
1105 lbeq L05f5 if so were done
|
|
1106 lda #$f0 set up value for mask_dl
|
|
1107 bra L04c2 go save it
|
|
1108
|
|
1109 L04b8 andb #$0f and color with $0F
|
|
1110 cmpb #$0f was it already $0F
|
|
1111 lbeq L05f5 if so we're done
|
|
1112 lda #$0f set up value for mask_dl
|
|
1113
|
|
1114 L04c2 sta u00af stow as mask_dl
|
|
1115 anda #colorbl and that with $4F
|
|
1116 sta u00ae stow that as color_bl
|
|
1117 lda ,u get byte at screen buffer
|
|
1118 anda u00af and with mask_dl
|
|
1119 cmpa u00ae compare to color_bl
|
|
1120 lbne L05f5 not equal were done
|
|
1121
|
|
1122 ldd #$FFFF push 7 $FF bytes on temp stack
|
|
1123 pshs a,b and set stack_ptr accordingly
|
|
1124 pshs a,b
|
|
1125 pshs a,b
|
|
1126 pshs a
|
|
1127
|
|
1128 lda #$a1 load a with 161
|
|
1129 sta u00a0 stow it at left
|
|
1130 clra make a zero
|
|
1131 sta u00a1 stow it at right
|
|
1132 sta u00aa stow it at toggle
|
|
1133 inca now we want a 1
|
|
1134 sta u00a3 stow it at direction
|
|
1135
|
|
1136 * fill a new line
|
|
1137 L04e9 ldd u00a0 load left/right
|
|
1138 std u00a6 stow at old_left/right
|
|
1139 lda u00aa load toggle
|
|
1140 sta u00ab stow at old_toggle
|
|
1141 ldb u009e load pos_init_x
|
|
1142 stb u00a4 store as old_initx
|
|
1143 incb accb now becomes counter
|
|
1144 stu u00b0 stow current screen byte as old_buff
|
|
1145
|
|
1146 L04f8 lda ,u get the screen byte pointed to by u
|
|
1147 ora u005b or it with sbuff_drawmmask
|
|
1148 anda u005a and that with the color
|
|
1149 sta ,u stow that back
|
|
1150 lda ,-u get the screen byte befor that one
|
|
1151 anda u00af and that with mask_dl
|
|
1152 cmpa u00ae compare result with color_bl
|
|
1153 bne L050b not equal move on
|
|
1154 decb otherwise decrement the counter
|
|
1155 bne L04f8 if were not at zero go again
|
|
1156
|
|
1157 L050b leau 1,u since cranked to zero bump the screen pointer by one
|
|
1158 tfr u,d move that into d
|
|
1159 subd u00b0 subtract old_buff
|
|
1160 addb u009e add pos_init_x
|
|
1161 stb u00a0 stow at left
|
|
1162 lda u009e load pos_init_x
|
|
1163 stb u009e store left at pos_init_x
|
|
1164 stu u00b2 temp buff
|
|
1165 ldu u00b0 load old_buff
|
|
1166 leau 1,u bump to the next byte
|
|
1167 nega negate pos_init_x value
|
|
1168 adda #x_max add that to 159 (subtract pos_init_x)
|
|
1169 beq L0537 that's the new counter and if zero move on
|
|
1170
|
|
1171 L0524 ldb ,u get that screen byte (color_old)
|
|
1172 andb u00af and it with mask_dl
|
|
1173 cmpb u00ae check against color_bl
|
|
1174 bne L0537 not equal move on
|
|
1175 ldb ,u load that byte again to do something with
|
|
1176 orb u005b or it with sbuff_drawmmask
|
|
1177 andb u005a and it with color
|
|
1178 stb ,u+ stow it back and bump the pointer
|
|
1179 deca decrement the counter
|
|
1180 bne L0524 if we haven't hit zero go again
|
|
1181
|
|
1182 L0537 tfr u,d move the screen buff ptr to d
|
|
1183 subd u00b2 subtract that saved old pointer
|
|
1184 decb sunbtract a 1
|
|
1185 addb u00a0 add in the left
|
|
1186 stb u00a1 store as the right
|
|
1187 lda u00a6 load old_left
|
|
1188 cmpa #$a1 compare to 161
|
|
1189 beq L0577 if it is move on
|
|
1190
|
|
1191 cmpb u00a7 if the new right == old right
|
|
1192 beq L0552 then move on
|
|
1193 bhi L0566 not equal and right > old_right
|
|
1194 * otherwise
|
|
1195 stb u00a4 stow right as old_initx
|
|
1196 clr u00aa clear toggle
|
|
1197 bra L056c head for next calc
|
|
1198 * they were equal
|
|
1199 L0552 lda u00a0 load a with left
|
|
1200 cmpa u00a6 compare that to old_left
|
|
1201 bne L0566 move on
|
|
1202 lda #$01 set up a one
|
|
1203 cmpa u00aa compare toggle
|
|
1204 beq L0577 is a one ? go to locnext
|
|
1205 sta u00aa not one ? set it to 1
|
|
1206 lda u00a1 load right
|
|
1207 sta u00a4 stow it as old_initx
|
|
1208 bra L056c head for the next calc
|
|
1209 * right > old_right or left > old left
|
|
1210 L0566 clr u00aa clear toggle
|
|
1211 lda u00a7 load old right
|
|
1212 sta u00a4 save as old_initx
|
|
1213
|
|
1214 * push a bunch on our temp stack
|
|
1215 L056c ldy u00a2 old_direction/direction
|
|
1216 ldx u00a4 old_initx/y
|
|
1217 ldu u00a6 old_left/right
|
|
1218 lda u00ab old_toggle
|
|
1219 pshs a,x,y,u push them on the stack
|
|
1220
|
|
1221 locnext:
|
|
1222 L0577 lda u00a3 load direction
|
|
1223 sta u00a2 stow as old_direction
|
|
1224 ldb u009f load pos_init_y
|
|
1225 stb u00a5 stow as old_inity
|
|
1226
|
|
1227 L057f addb u00a3 add direction to pos_init_y
|
|
1228 stb u009f stow the updated pos_init_y
|
|
1229 cmpb #y_max compare that to 167
|
|
1230 bhi L05c5 greater than 167 go test direction
|
|
1231
|
|
1232 L0587 ldb u009f load pos_init_y
|
|
1233 lda #$A0 according to PBUF_MULT
|
|
1234 mul do the math
|
|
1235 addb u009e add pos_init_x position
|
|
1236 adca #0000 this adds the carry bit into the answer
|
|
1237 addd #gfx_picbuff add that to the screen buff start addr $6040
|
|
1238 tfr d,u move it into u
|
|
1239 lda ,u get the byte pointed to
|
|
1240 anda u00af and with mask_dl
|
|
1241 cmpa u00ae compare with color_bl
|
|
1242 lbeq L04e9 if equal go fill a new line
|
|
1243
|
|
1244 lda u009e load pos_init_x
|
|
1245 ldb u00a3 load direction
|
|
1246 cmpb u00a2 compare to old_direction
|
|
1247 beq L05bc go comapre pos_init_x and right
|
|
1248 tst u00aa test toggle
|
|
1249 bne L05bc not zero go comapre pos_init_x and right
|
|
1250 cmpa u00a8 compare pos_init_x and stack_left
|
|
1251 blo L05bc less than stack_left go comapre pos_init_x and right
|
|
1252 cmpa u00a9 compare it to stack_right
|
|
1253 bhi L05bc greater than go comapre pos_init_x and right
|
|
1254 lda u00a9 load stack_right
|
|
1255 cmpa u00a1 compare to right
|
|
1256 bhs L05c5 greater or equal go check direction
|
|
1257 inca add one to stack_right
|
|
1258 sta u009e stow as pos_init_x
|
|
1259
|
|
1260 L05bc cmpa u00a1 compare updated value to right
|
|
1261 bhs L05c5 go check directions
|
|
1262 inca less than then increment by 1
|
|
1263 sta u009e stow updated value pos_init_x
|
|
1264 bra L0587 loop for next byte
|
|
1265
|
|
1266 * test direction and toggle
|
|
1267 L05c5 lda u00a3 load direction
|
|
1268 cmpa u00a2 compare old_direction
|
|
1269 bne L05dc not equal go pull stacked values
|
|
1270 tst u00aa test toggle
|
|
1271 bne L05dc not zero go pull stack values
|
|
1272 nega negate direction
|
|
1273 sta u00a3 store back at direction
|
|
1274 lda u00a0 load left
|
|
1275 sta u009e stow as pos_init_x
|
|
1276 ldb u00a5 load old_inity
|
|
1277 stb u009f stow at pos_init_y
|
|
1278 bra L05ef go grab off stack and move on
|
|
1279
|
|
1280 * directions not equal
|
|
1281 L05dc puls a,x,y,u grab the stuff off the stack
|
|
1282 cmpa #$FF test toggle for $FF source has test of pos_init_y
|
|
1283 beq L05f5 equal ? clean up stack and return
|
|
1284 sty u00a2 stow old_direction/direction
|
|
1285 stx u009e stow pos_init_x/y
|
|
1286 stu u00a0 stow left/right
|
|
1287 sta u00aa stow toggle
|
|
1288
|
|
1289 ldb u009f load pos_init_y
|
|
1290 stb u00a5 stow old_inity
|
|
1291 L05ef ldx $05,s gets left right off stack
|
|
1292 stx u00a8 stow stack_left/right
|
|
1293 bra L057f always loop
|
|
1294
|
|
1295 L05f5 lds ,s reset stack
|
|
1296 puls x retrieve our x
|
|
1297 rts return
|
|
1298
|
|
1299
|
|
1300 * this routine effective swaps postion of
|
|
1301 * the two nibbles of the byte loaded
|
|
1302 * and returns it to the screen
|
|
1303 * it is the workhorse loop in gfx_picbuff_update gfx.c ???
|
|
1304 * called via remap call in mnln
|
|
1305
|
|
1306 gfx_picbuff_update_remap
|
|
1307 L05fb ldx #gfx_picbuff starting low address of srceen mem
|
|
1308 L05fe lda ,x get the first byte bit order 0,1,2,3,4,5,6,7
|
|
1309 clrb empty b
|
|
1310 lsra shift one bit from a
|
|
1311 rorb into b
|
|
1312 lsra again
|
|
1313 rorb
|
|
1314 lsra and again
|
|
1315 rorb
|
|
1316 lsra and finally once more
|
|
1317 rorb
|
|
1318 stb ,x were changing x anyway so use it for temp storage
|
|
1319 ora ,x or that with acca so now bit order from orig
|
|
1320 * is 4,5,6,7,0,1,2,3
|
|
1321 sta ,x+ put it back at x and go for the next one
|
|
1322 cmpx #gbuffend ending high address of screen mem
|
|
1323 bcs L05fe
|
|
1324 rts
|
|
1325
|
|
1326 * our blit_struct is a bit different from the one in nagi
|
|
1327 *
|
|
1328 * struct blit_struct
|
|
1329 * {
|
|
1330 * struct blit_struct *prev; // 0-1
|
|
1331 * struct blit_struct *next; // 2-3
|
|
1332 * struct view_struct *v; // 4-5
|
|
1333 * s8 x; // 6
|
|
1334 * s8 y; // 7
|
|
1335 * s8 x_size; // 8
|
|
1336 * s8 y_size; // 9
|
|
1337 * u16 *buffer; // A-B
|
|
1338 * u16 *view_data // C-D info for mmu twiddler
|
|
1339 *
|
|
1340 * };
|
|
1341
|
|
1342
|
|
1343 * blitlist_draw(BLIT *b) obj_base.c
|
|
1344 L0615 leas -$02,s make room on the stack
|
|
1345 ldx $04,s get the blit_struct pointer
|
|
1346 ldu $02,x load u with pointer to next blit
|
|
1347
|
|
1348 L061b stu ,s stow it on the stack
|
|
1349 beq L0637 if it's zero we're done
|
|
1350 pshs u push the pointer on the stack
|
|
1351 lbsr L09d8 call blit_save()
|
|
1352 leas $02,s get the pointer back in s
|
|
1353 ldu ,s put it in u
|
|
1354 ldu $04,u get the pointer to view_struct
|
|
1355 pshs u push that on the stack and
|
|
1356 lbsr L07be call obj_blit()
|
|
1357 leas $02,s get the pointer back in s
|
|
1358 ldu ,s put it in u
|
|
1359 ldu $02,u get the pointer to the next one
|
|
1360 bra L061b and go again
|
|
1361
|
|
1362 L0637 leas $02,s clean up stack and leave
|
|
1363 rts
|
|
1364
|
|
1365 * blitlist_erase(BLIT *b) obj_base.c
|
|
1366 * nagi has a return blitlist_free at the end
|
|
1367
|
|
1368 L063a leas -$02,s make room on the stack
|
|
1369 ldx $04,s get the blit_struct pointer
|
|
1370 ldu ,x load u with the prev pointer
|
|
1371 beq L0651 if it's zero we're done
|
|
1372 L0642 stu ,s stow it on the stack
|
|
1373 pshs u push the pointer
|
|
1374 lbsr L0a0f call blit_restore()
|
|
1375 leas $02,s get the pointer back in s
|
|
1376 ldx ,s load x with the pointer
|
|
1377 ldu ,x get the prev from that struct
|
|
1378 bne L0642 loop again
|
|
1379
|
|
1380 L0651 leas $02,s clean up stack and leave
|
|
1381 rts
|
|
1382
|
|
1383 * From obj_picbuff.c the pri_table[172]
|
|
1384 * ours is only 168
|
|
1385 pri_table
|
|
1386 L0654 fcb $00,$00,$00,$00,$00,$00
|
|
1387 fcb $00,$00,$00,$00,$00,$00
|
|
1388 fcb $00,$00,$00,$00,$00,$00
|
|
1389 fcb $00,$00,$00,$00,$00,$00
|
|
1390 fcb $00,$00,$00,$00,$00,$00
|
|
1391 fcb $00,$00,$00,$00,$00,$00
|
|
1392 fcb $00,$00,$00,$00,$00,$00
|
|
1393 fcb $00,$00,$00,$00,$00,$00
|
|
1394
|
|
1395 fcb $00,$00,$00,$00,$00,$00
|
|
1396 fcb $00,$00,$00,$00,$00,$00
|
|
1397
|
|
1398 fcb $00,$00,$00,$00,$00,$00
|
|
1399 fcb $00,$00,$00,$00,$00,$00
|
|
1400
|
|
1401 fcb $00,$00,$00,$00,$00,$00
|
|
1402 fcb $00,$00,$00,$00,$00,$00
|
|
1403
|
|
1404 fcb $00,$00,$00,$00,$00,$00
|
|
1405 fcb $00,$00,$00,$00,$00,$00
|
|
1406
|
|
1407 fcb $00,$00,$00,$00,$00,$00
|
|
1408 fcb $00,$00,$00,$00,$00,$00
|
|
1409
|
|
1410 fcb $00,$00,$00,$00,$00,$00
|
|
1411 fcb $00,$00,$00,$00,$00,$00
|
|
1412
|
|
1413 fcb $00,$00,$00,$00,$00,$00
|
|
1414 fcb $00,$00,$00,$00,$00,$00
|
|
1415
|
|
1416 fcb $00,$00,$00,$00,$00,$00
|
|
1417 fcb $00,$00,$00,$00,$00,$00
|
|
1418
|
|
1419 fcb $00,$00,$00,$00,$00,$00
|
|
1420 fcb $00,$00,$00,$00,$00,$00
|
|
1421
|
|
1422 fcb $00,$00,$00,$00,$00,$00
|
|
1423 fcb $00,$00,$00,$00,$00,$00
|
|
1424
|
|
1425 * loops thru 48 bytes with a = 4
|
|
1426 * bumps a by one load b with 12 this
|
|
1427 * iterates thru ten sets of twelve bytes
|
|
1428 * bumping acca by one as it goes.
|
|
1429
|
|
1430 * table_init() obj_pic_buff.c
|
|
1431 L06fc leax L0654,pcr point to data block
|
|
1432 ldb #$30 load index 48
|
|
1433 lda #4 load acca = 4
|
|
1434 L0704 sta ,x+ save a in buffer
|
|
1435 decb dec the inner loop counter
|
|
1436 bne L0704 go again if loop not finished
|
|
1437 cmpa #$0e get here when inner loop is done
|
|
1438 bcc L0712 did we do 10 loops (e-4)
|
|
1439 inca nope bump data byte
|
|
1440 ldb #$0c set new counter on loops 2-10
|
|
1441 * to do 12 bytes and
|
|
1442 bra L0704 have at it again
|
|
1443 L0712 rts
|
|
1444
|
|
1445
|
|
1446 * obj_chk_control(VIEW *x) obj_picbuff.c
|
|
1447 * our index reg x points to the view structure
|
|
1448 * are 3 = x, 4 = y instead of 3-4 = x & 5-6 = y ???
|
|
1449
|
|
1450 * This routine is passed a pointer to a view_structure
|
|
1451 * from agi.h in the nagi source
|
|
1452 * struct view_struct
|
|
1453 *{
|
|
1454 * u8 step_time; // 0
|
|
1455 * u8 step_count; // 1 // counts down until the next step
|
|
1456 * u8 num; // 2
|
|
1457
|
|
1458 * s16 x; // 3-4 in nagi
|
|
1459 * s16 y; // 5-6 in nagi
|
|
1460
|
|
1461
|
|
1462 * u8 x; // 3 in ours
|
|
1463 * u8 y: // 4 the rest of the offsets hold true
|
|
1464 * u8 dummy1 // 5 who knows what these are
|
|
1465 * u8 dummy2 // 6 maybe just fillers
|
|
1466
|
|
1467
|
|
1468 * u8 view_cur; // 7
|
|
1469 * u8 *view_data; // 8-9
|
|
1470 *
|
|
1471 * u8 loop_cur; // A
|
|
1472 * u8 loop_total; // B
|
|
1473 * u8 *loop_data; // C-D
|
|
1474 *
|
|
1475 * u8 cel_cur; // E
|
|
1476 * u8 cel_total; // F
|
|
1477 * u8 *cel_data; // 10-11
|
|
1478 * u8 cel_prev_width; // new ones added to prevent kq4 crashing
|
|
1479 * u8 cel_prev_height;
|
|
1480 * //u8 *cel_data_prev;// 12-13
|
|
1481 * BLIT *blit; // 14-15
|
|
1482 *
|
|
1483 * s16 x_prev; // 16-17
|
|
1484 * s16 y_prev; // 18-19
|
|
1485 * s16 x_size; // 1A-1B
|
|
1486 * s16 y_size; // 1C-1D
|
|
1487 * u8 step_size; // 1E
|
|
1488 * u8 cycle_time; // 1F
|
|
1489 * u8 cycle_count; // 20 // counts down till next cycle
|
|
1490 * u8 direction; // 21
|
|
1491 * u8 motion; // 22
|
|
1492 * u8 cycle; // 23
|
|
1493 * u8 priority; // 24
|
|
1494 * u16 flags; // 25-26
|
|
1495 *
|
|
1496 * //u8 unknown27; // 27 // these variables depend on the motion
|
|
1497 * //u8 unknown28; // 28 // type set by follow ego, move, obj.. stuff
|
|
1498 * //u8 unknown29; // 29 // like that
|
|
1499 * //u8 unknown2A; // 2A
|
|
1500 *
|
|
1501 * union
|
|
1502 * {
|
|
1503 * struct // move_ego move_obj
|
|
1504 * {
|
|
1505 * s16 x; // 27
|
|
1506 * s16 y; // 28
|
|
1507 * u8 step_size; // 29 // original stepsize
|
|
1508 * u8 flag; // 2A
|
|
1509 * } move;
|
|
1510 *
|
|
1511 * struct // follow_ego
|
|
1512 * {
|
|
1513 * u8 step_size; // 27
|
|
1514 * u8 flag; // 28
|
|
1515 * u8 count; // 29
|
|
1516 * } follow;
|
|
1517 *
|
|
1518 * // wander
|
|
1519 * u8 wander_count; // 27
|
|
1520 *
|
|
1521 * // reverse or end of loop
|
|
1522 * u8 loop_flag; // 27
|
|
1523 * };
|
|
1524 *};
|
|
1525 *typedef struct view_struct VIEW;
|
|
1526
|
|
1527
|
|
1528 * u00a5 = flag_signal
|
|
1529 * u00a6 = flag_water
|
|
1530 * u005c = flag_control
|
|
1531 *
|
|
1532 * X01af is loaction of state.flag
|
|
1533 * see agi.h for definition of state structure
|
|
1534 L0713 pshs y save y
|
|
1535
|
|
1536 ldx $04,s sets up mmu info
|
|
1537 ldd $08,x load view_data passed to mmu twiddler
|
|
1538 lbsr L0074 twiddle mmu
|
|
1539
|
|
1540 ldb $04,x load y
|
|
1541 lda $26,x load flags
|
|
1542 bita #O_PRIFIXED and with $04 but don't change
|
|
1543 bne L072f not zero move on
|
|
1544 * it is zero then
|
|
1545 leau L0654,pcr load buffer address
|
|
1546 clra clear a since we will use d as an index
|
|
1547 lda d,u fetch the data from pri_table
|
|
1548 sta $24,x save as priority
|
|
1549
|
|
1550 L072f lda #$A0 set up PBUF_MULT()
|
|
1551 mul do the math
|
|
1552 addb $03,x add in x
|
|
1553 adca #0000 add in the carry bit
|
|
1554 addd #gfx_picbuff add it to the start of the screen buff addr 6040
|
|
1555 tfr d,u move the pointer pb to u
|
|
1556
|
|
1557 ldy $10,x load y with cel_data ptr
|
|
1558 clra make a zero
|
|
1559 sta u00a6 stow it at flag_water
|
|
1560 sta u00a5 stow it at flag_signal
|
|
1561 inca make a 1
|
|
1562 sta u005c stow it at flag_contro1
|
|
1563 ldb $24,x load priority
|
|
1564 cmpb #$0F compare it with 15
|
|
1565 beq L078b If it equals 15 move on
|
|
1566 * otherwise if not equal 15
|
|
1567 sta u00a6 stow that 1 at flag_water
|
|
1568 ldb ,y cx first byte of cel_data (cel_width)
|
|
1569
|
|
1570 * do while cx != 0
|
|
1571
|
|
1572 L0752 lda ,u+ (pri) put byte at pb in acca and bump pointer
|
|
1573 anda #$F0 and that with $F0 (obstacle ??)
|
|
1574 beq L077a if it equals 0 set flag_control =0 and check_finish
|
|
1575
|
|
1576 cmpa #$30 compare pri to 48 (water ??)
|
|
1577 beq L0766 not equal move to end of loop
|
|
1578 clr u00a6 clear the water flag
|
|
1579 cmpa #$10 compare it with 16 (conditional ??)
|
|
1580 beq L077e if equal go test for observe blocks
|
|
1581 cmpa #$20 compare with 32
|
|
1582 beq L0787
|
|
1583
|
|
1584 L0766 decb decrement cx
|
|
1585 bne L0752 not zero yet loop again
|
|
1586
|
|
1587 lda $25,x load flags in acca
|
|
1588 tst u00a6 test flag_water
|
|
1589 bne L0776 not zero next test
|
|
1590 bita #O_DRAWN should be O_WATER Looks like a BUG in ours
|
|
1591 beq L078b if it equals one head for check_finish
|
|
1592 bra L077a clear that flag control first and leave
|
|
1593 L0776 bita #O_HRZNIGNORE should be O_LAND Looks like a BUG in ours
|
|
1594 beq L078b
|
|
1595
|
|
1596 L077a clr u005c clear flag_control
|
|
1597 bra L078b head for check_finish
|
|
1598
|
|
1599 L077e lda $26,x load flags in acca
|
|
1600 bita #O_BLKIGNORE and with $02 but don't change
|
|
1601 beq L077a equals zero clear flag_control and go check_finish
|
|
1602 bra L0766 then head back in the loop
|
|
1603
|
|
1604 L0787 sta u00a5 store acca at flag signal (obj_picbuff.c has =1)
|
|
1605 bra L0766 continue with loop
|
|
1606
|
|
1607
|
|
1608
|
|
1609 L078b lda $02,x load num
|
|
1610 bne L07bb if not zero were done head out
|
|
1611
|
|
1612 * flag signal test
|
|
1613 lda u00a5 load flag_signal
|
|
1614 * operates on F03_EGOSIGNAL
|
|
1615 beq L079d if its zero go reset the signal
|
|
1616 * otherwise set the flag
|
|
1617 lda X01af load the state.flag element
|
|
1618 ora #$10 set the bits
|
|
1619 sta X01af save it back
|
|
1620 bra L07a5 go test the water flag
|
|
1621 L079d lda X01af load the state.flag element
|
|
1622 anda #$ef reset the bits
|
|
1623 sta X01af save it back
|
|
1624
|
|
1625 * flag_water test
|
|
1626 L07a5 lda u00a6 load flag_water
|
|
1627 beq L07b3 if zero go reset the flag
|
|
1628 * otherwise set it
|
|
1629 lda X01af load the state.flag element
|
|
1630 ora #$80 set the bits
|
|
1631 sta X01af save it back
|
|
1632 bra L07bb baby we're out of here
|
|
1633 L07b3 lda X01af load the state.flag element
|
|
1634 anda #$7f reset the bits
|
|
1635 sta X01af save it back
|
|
1636
|
|
1637 L07bb puls y retrieve our y and leave
|
|
1638 rts
|
|
1639
|
|
1640
|
|
1641 * obj_blit(VIEW *v) obj_blit.c
|
|
1642 * our index reg x points to the view structure
|
|
1643 * are 3 = x, 4 = y instead of 3-4 = x & 5-6 = y ???
|
|
1644 * u00a2 = cel_height
|
|
1645 * u00a7 = cel_trans
|
|
1646 * u00a8 = init (pb)
|
|
1647 * u00ac = cel_invis
|
|
1648 * u00ad = pb_pri
|
|
1649 * u009e = view_pri
|
|
1650 * u009f = col
|
|
1651
|
|
1652 L07be ldx $02,s pull our x pointer off the stack
|
|
1653 ldd $08,x load d with view_data
|
|
1654 lbsr L0074 twiddle mmu
|
|
1655
|
|
1656 ldu $10,x u now is a pointer to cel_data
|
|
1657 lda $02,u cel_data[$02] loaded
|
|
1658 bita #O_Block are we testing against a block or does $80 mean something else here?
|
|
1659 beq L07d1 if zero skip next instruction
|
|
1660
|
|
1661 lbsr L087f otherwise call obj_cell_mirror
|
|
1662
|
|
1663 L07d1 ldd ,u++ load the first 2 bytes of cel_data and bump to next word
|
|
1664 * cel_width is in acca we ignore
|
|
1665 stb u00a2 save as cel_height
|
|
1666 * obj_blit.c has and $0F which is a divide by 16
|
|
1667 * we do a multiply x 16 ???
|
|
1668 lda ,u+ cel_trans
|
|
1669 asla
|
|
1670 asla
|
|
1671 asla
|
|
1672 asla
|
|
1673 sta u00a7 save as cel_tran
|
|
1674
|
|
1675 lda $24,x priority
|
|
1676 asla shift left 4
|
|
1677 asla
|
|
1678 asla
|
|
1679 asla
|
|
1680 sta u009e view_pri
|
|
1681
|
|
1682 ldb $04,x load the y value
|
|
1683 subb u00a2 subtract the cel_height
|
|
1684 incb add 1
|
|
1685 lda #$a0 set up PBUF_MULT()
|
|
1686 mul do the math
|
|
1687 addb $03,x add in the x value
|
|
1688 adca #0000 add in the carry from multiply
|
|
1689 addd #gfx_picbuff add this to the start of the screen buff addr $6040
|
|
1690 std u00a8 pb pointer to the pic buffer
|
|
1691 ldx u00a8 load it in an index reg
|
|
1692
|
|
1693 lda #$01
|
|
1694 sta u00ac set cel_invis to 1 and save
|
|
1695
|
|
1696 bra L0800
|
|
1697 L07ff abx bump the pb pointer
|
|
1698
|
|
1699 L0800 lda ,u+ get the next "chunk"
|
|
1700 beq L082d if zero
|
|
1701 ldb -$01,u not zero load the same byte in accb
|
|
1702 anda #$f0 and chunk with $F0 (col)
|
|
1703 andb #$0f and chunk with $0F (chunk_len)
|
|
1704 cmpa u00a7 compare with cel_trans
|
|
1705 beq L07ff set up and go again color is trasnparent
|
|
1706 lsra shift right 4
|
|
1707 lsra
|
|
1708 lsra
|
|
1709 lsra
|
|
1710 sta u009f save the color
|
|
1711
|
|
1712 L0814 lda ,x get the byte pointed to by pb
|
|
1713 anda #$f0 get the priority portion
|
|
1714 cmpa #$20 compare to $20
|
|
1715 bls L083b less or equal
|
|
1716 cmpa u009e compare to view_pri
|
|
1717 bhi L085b pb_pri > view_pri
|
|
1718 * otherwise
|
|
1719 lda u009e load view_pri
|
|
1720 L0822 ora u009f or it with col
|
|
1721 sta ,x+ store that at pb and bump the pointer
|
|
1722 clr u00ac zero cel_invis
|
|
1723 decb decrement chunk_len
|
|
1724 bne L0814 not equal zero go again inner loop
|
|
1725 bra L0800 go again outer loop
|
|
1726
|
|
1727 L082d dec u00a2 decrement cel_height
|
|
1728 beq L0862 equal zero move on out of cel_height loop
|
|
1729 ldx u00a8 load init
|
|
1730 leax >PICBUFF_WIDTH,x move 160 into screen
|
|
1731 stx u00a8 stow that back as init/pb
|
|
1732 bra L0800 go again
|
|
1733
|
|
1734 L083b stx u00ad save the pointer
|
|
1735 clra set up ch
|
|
1736
|
|
1737 L083e cmpx #blit_end compare to gfx_picbuff+$6860
|
|
1738 bhs L084f not less than then branch out
|
|
1739 * less than the end
|
|
1740 leax >PICBUFF_WIDTH,x bump the pointer by 160
|
|
1741 lda ,x get that byte
|
|
1742 anda #$f0 and it with $F0
|
|
1743 cmpa #$20 test against $20
|
|
1744 bls L083e less or equal go again
|
|
1745
|
|
1746 L084f ldx u00ad load pb_pri
|
|
1747 cmpa u009e compare with view_pri
|
|
1748 bhi L085b pb_pri > view_pri
|
|
1749 lda ,x make the next
|
|
1750 anda #$f0 pb_pri
|
|
1751 bra L0822 go or it with the color
|
|
1752
|
|
1753 L085b leax $01,x bump the pb pointer
|
|
1754 decb decrement chunk_len
|
|
1755 bne L0814 not equal do middle loop again
|
|
1756 bra L0800 go again
|
|
1757
|
|
1758 L0862 ldx $02,s pull our view pointer back off the stack
|
|
1759 lda $02,x get the num
|
|
1760 bne L087e if not zero exit routine
|
|
1761 lda u00ac get the cel_invis value
|
|
1762 beq L0876 reset the flag
|
|
1763
|
|
1764 * set the flag
|
|
1765 lda X01af load the state.flag
|
|
1766 ora #$40 set it
|
|
1767 sta X01af stow it back
|
|
1768 bra L087e exit routine
|
|
1769
|
|
1770 * reset the flag
|
|
1771 L0876 lda X01af load state.flag
|
|
1772 anda #$bf clear it
|
|
1773 sta X01af stow it
|
|
1774 L087e rts
|
|
1775
|
|
1776
|
|
1777 * obj_cel_mirror(View *v) in obj_picbuff.c
|
|
1778 * we use different values from those shown nagi files
|
|
1779 * on entry
|
|
1780 * a contains cell_data[$02] in call from obj_blit()
|
|
1781 * x contains pointer to view data
|
|
1782 * u contains pointer to cel_data
|
|
1783 *
|
|
1784 * saves and restores x,y,u regs on exit
|
|
1785 *
|
|
1786 * u00a1 = width
|
|
1787 * u00a2 = height_count
|
|
1788 * u00a7 = trans transparent color left shifted 4
|
|
1789 * u00aa = tran_size ??
|
|
1790 * u00ab = meat_size
|
|
1791 * u00af = loop_cur << 4
|
|
1792 * u00b0 = al
|
|
1793
|
|
1794
|
|
1795 L087f anda #$30 and that with $30 (nagi has $70)
|
|
1796 lsra shift right 4
|
|
1797 lsra
|
|
1798 lsra
|
|
1799 lsra
|
|
1800 cmpa $0A,x compare that with loop_cur
|
|
1801 lbeq L0926 if equal we're done
|
|
1802
|
|
1803 pshs x,y,u save our view (x) what ever (y) and cel_data (u) pointers
|
|
1804
|
|
1805 lda $0A,x load loop_cur
|
|
1806 asla and shift it 4 left
|
|
1807 asla
|
|
1808 asla
|
|
1809 asla
|
|
1810 sta u00af stow it as ??
|
|
1811 lda #$cf load a with with $CF (nagi has $8F)
|
|
1812 anda $02,u and that with cel[2]
|
|
1813 ora u00af or with loop_cur<<4
|
|
1814 sta $02,u stow it back at cel[2]
|
|
1815
|
|
1816 ldy #gbuffend
|
|
1817
|
|
1818 ldd ,u++ load d with width and hieght
|
|
1819 std u00a1 stow that
|
|
1820 lda ,u+ load a with trans color
|
|
1821 asla and shift left 4
|
|
1822 asla
|
|
1823 asla
|
|
1824 asla
|
|
1825 sta u00a7 stow as trans
|
|
1826 stu u00b0 stow u as al
|
|
1827 L08af clrb make a zero
|
|
1828 stb u00ab stow it as meat_size
|
|
1829
|
|
1830 * nagi code has tran_size set to width and
|
|
1831 * al&$0F subtracted from it.
|
|
1832 * in this loop
|
|
1833
|
|
1834 L08b2 stb u00aa and tran_size
|
|
1835
|
|
1836 lda ,u+ load in the next cel_data byte
|
|
1837 beq L08fc if its a zero leave loop
|
|
1838 ldb -$01,u otherwise fetch the same data into b
|
|
1839 * at this point a & b both have the same data byte
|
|
1840 anda #$f0 and the a copy with $F0
|
|
1841 andb #$0f and the b copy with $0F
|
|
1842 cmpa u00a7 compare byte&$F0 with trans
|
|
1843 bne L08cc not equal branch out of loop
|
|
1844 addb u00aa otherwise add in tran_size
|
|
1845 bra L08b2 and loop
|
|
1846
|
|
1847 L08c6 ldb ,u+ load the nbext byte and bump the pointer
|
|
1848 beq L08d4 if it was zero move on
|
|
1849 andb #$0f otherwise and it with $0F
|
|
1850 L08cc addb u00aa add in tran_size
|
|
1851 stb u00aa save it as tran_size
|
|
1852 inc u00ab bump meat_size
|
|
1853 bra L08c6 loop to the next byte
|
|
1854
|
|
1855 L08d4 lda u00aa load tran_size
|
|
1856 nega negate it
|
|
1857 adda u00a1 add in the width
|
|
1858 beq L08f1 if that is zero move on
|
|
1859
|
|
1860 L08db suba #$0f subtract 15 from it
|
|
1861 bls L08eb less or same move on
|
|
1862 sta u00aa otherwise stow that back as tran_size
|
|
1863 lda u00a7 fetch trans
|
|
1864 ora #$0f or it with 15
|
|
1865 sta ,y+ store it at buff (gbuffend) and bump pointer
|
|
1866 lda u00aa fetch tra_size
|
|
1867 bra L08db loop again
|
|
1868
|
|
1869 L08eb adda #$0f add 15 back into a (tran_size)
|
|
1870 ora u00a7 or that with trans
|
|
1871 sta ,y+ stow that at buff and bump the pointer
|
|
1872
|
|
1873 L08f1 leax -$01,u set x to the last cel_data byte processed
|
|
1874 ldb u00ab load b with the meat_size (the loop counter)
|
|
1875 L08f5 lda ,-x copy from the cel_data end
|
|
1876 sta ,y+ to the buff front
|
|
1877 decb dec the counter
|
|
1878 bne L08f5 not done loop again
|
|
1879
|
|
1880 L08fc stb ,y+ on entry b should always = 0 stow that at the next buff location
|
|
1881 dec u00a2 decrement the height_count
|
|
1882 bne L08af not zero go again
|
|
1883
|
|
1884 * now we are going to copy the backward temp buffer back to the cel
|
|
1885 tfr y,d get the buff pointer in d
|
|
1886 subd #gbuffend subtract the starting value of the buffer
|
|
1887 stb u00b2 save that as the buffer size
|
|
1888 andb #$fe make it an even number
|
|
1889 tfr d,x transfer that to x
|
|
1890 ldu u00b0 al cel_data pointer
|
|
1891 ldy #gbuffend load y start of our temp buffer
|
|
1892
|
|
1893 L0913 ldd ,y++ get a word
|
|
1894 std ,u++ stow a word
|
|
1895 leax -$02,x dec the counter by a word
|
|
1896 bne L0913 not zero go again
|
|
1897 * so we've moved an even number of bytes
|
|
1898 lda u00b2 load the actual byte count
|
|
1899 lsra divide by 2
|
|
1900 bcc L0924 no remainder (not odd) we're done
|
|
1901 lda ,y otherwise move the last
|
|
1902 sta ,u byte
|
|
1903 L0924 puls x,y,u retrieve our x,y,u values
|
|
1904
|
|
1905 L0926 rts and return to caller
|
|
1906
|
|
1907
|
|
1908
|
|
1909 * obj_add_pic_pri(VIEW *v) obj_picbuff.c
|
|
1910 * our index reg x points to the view structure
|
|
1911 *
|
|
1912 * u009e = priority&$F0
|
|
1913 * u00a3 = pri_table[y]
|
|
1914 * u00a4 = pri_table[y]
|
|
1915 * u00a8 = pb (word)
|
|
1916 * u00a9 = "
|
|
1917 * u00b3 = pri_height/height
|
|
1918
|
|
1919 L0927 pshs y save the y
|
|
1920 ldx $04,s get the the pointer to our view
|
|
1921 ldd $08,x load d with view_data ?
|
|
1922 lbsr L0074 twiddle mmu
|
|
1923
|
|
1924 * set up d as pointer to pri_table value
|
|
1925 clra zero a
|
|
1926 ldb $04,x load view y value
|
|
1927 leau L0654,pcr load pri_table address
|
|
1928 lda d,u fetch the pri_table y data
|
|
1929 std u00a3 stow it in a temp
|
|
1930 ldb $24,x load priority
|
|
1931 andb #$0f and that with $0F
|
|
1932 bne L0948 if that equals zero move on
|
|
1933 ora $24,x otherwise or the pri_table[y] with priority
|
|
1934 sta $24,x stow that back as priority
|
|
1935
|
|
1936 L0948 pshs x push the pointer to the view on the stack
|
|
1937 lbsr L07be call obj_blit()
|
|
1938 leas $02,s reset the stack
|
|
1939 ldx $04,s get the pointer to our view
|
|
1940 lda $24,x load priority
|
|
1941 cmpa #$3F compare to $3F
|
|
1942 lbhi L09d5 if greater then nothing to do head out
|
|
1943
|
|
1944 leau L0654,pcr load pri_table address
|
|
1945 ldb u00a4 fetch pri_table[y] (cx)
|
|
1946 clr u00b3 clear pri_height
|
|
1947 L0962 clra zero acca
|
|
1948 inc u00b3 bump pri_hieght
|
|
1949 tstb is pri_table[y]
|
|
1950 beq L096f equal zero if so move on
|
|
1951 decb dec our counter cx
|
|
1952 lda d,u load pri_table[cx]
|
|
1953 cmpa u00a3 compare to pri_table[y]
|
|
1954 beq L0962 if they are equal loop again
|
|
1955
|
|
1956 * set up and execute PBUF_MULT call
|
|
1957 L096f ldb $04,x load the view->y in
|
|
1958 lda #$a0 from pbuf mult
|
|
1959 mul do the math
|
|
1960 addb $03,x add in the x value
|
|
1961 adca #0000 add in the carry
|
|
1962 addd #gfx_picbuff add in the base address $6040
|
|
1963 tfr d,u move that to an index reg (pb)
|
|
1964 stu u00a8 stow it as pb
|
|
1965
|
|
1966 ldy $10,x load y with cel_data pointer
|
|
1967 ldb $01,y get the second byte (height)
|
|
1968 cmpb u00b3 compare to pri_height
|
|
1969 bhi L098b greater move on
|
|
1970 stb u00b3 otherwise save the largest as pri_height
|
|
1971 L098b lda $24,x load the priority again
|
|
1972 anda #$f0 and it with $F0
|
|
1973 sta u009e stow that for later use
|
|
1974
|
|
1975 * bottom line
|
|
1976 ldb ,y load b with the first byte in cel_data (cx)
|
|
1977 L0994 lda ,u get the byte at our pic buff pb
|
|
1978 anda #$0f and it with $0F
|
|
1979 ora u009e or it with priority&F0
|
|
1980 sta ,u+ stow it back and bump the pointer
|
|
1981 decb dec the loop counter cx
|
|
1982 bne L0994 not zero go again
|
|
1983
|
|
1984 * it has a height
|
|
1985 dec u00b3 test "height" for > 1
|
|
1986 beq L09d5 wasn't head no more to do so head out
|
|
1987 ldu u00a8 reset u to our pb pic buff pointer
|
|
1988
|
|
1989 * the sides
|
|
1990 ldb ,y get the first byte of cel_data
|
|
1991 decb subtract 1 (sideoff)
|
|
1992 L09a8 leau -$A0,u decrement pb by 160
|
|
1993 tfr u,x move that value into x
|
|
1994 lda ,u get the data
|
|
1995 anda #$0f and it with $0F
|
|
1996 ora u009e or it priority&$F0
|
|
1997 sta ,u stow it back
|
|
1998 clra zero a so we can use d as a pointer
|
|
1999 lda d,u use "sideoff" as an index into pb
|
|
2000 anda #$0f and that with $0F
|
|
2001 ora u009e or that rascal with priority&$F0
|
|
2002 abx add that value to our x pointer
|
|
2003 sta ,x and store it there
|
|
2004 dec u00b3 dec the height
|
|
2005 bne L09a8 greater than zero go again
|
|
2006
|
|
2007 * the top of the box
|
|
2008
|
|
2009 ldb ,y get the cel_data first byte in b
|
|
2010 subb #$02 subtract 2
|
|
2011 leau $01,u bump the pb pointer
|
|
2012 L09ca lda ,u grab the byte
|
|
2013 anda #$0f and that with $0F
|
|
2014 ora u009e or it with priority &$F0
|
|
2015 sta ,u+ stow it back and bump the pointer
|
|
2016 decb dec our counter
|
|
2017 bne L09ca loop if not finished
|
|
2018
|
|
2019 L09d5 puls y return the y value
|
|
2020 rts return
|
|
2021
|
|
2022
|
|
2023
|
|
2024 * blit_save(BLIT *b) obj_blit.c
|
|
2025 * our blit_struct is a bit different from the one in nagi
|
|
2026 *
|
|
2027 * u00a0 = zeroed and never changed cause we use the next byte :-)
|
|
2028 * u00a1 = x_count (x_size) when cmpx ha ha
|
|
2029 * u00a2 = y_count (y_size)
|
|
2030 * u00a8 = pic buffer start pic_cur
|
|
2031 * u00ad = pic_cur + offset
|
|
2032
|
|
2033 L09d8 ldu $02,s get the pointer to the blit_struct
|
|
2034 ldd $0C,u get the pointer to the view_data for mmu twiddler
|
|
2035 lbsr L0074 twiddle mmu
|
|
2036
|
|
2037 ldu $02,s get the pointer to the blit_struct data back in u
|
|
2038 ldd $08,u load the x/y_size
|
|
2039 std u00a1 stow that at x/y_count
|
|
2040 clr u00a0 zero some adder
|
|
2041 ldb $07,u get the y value
|
|
2042 lda #$a0 set up PBUF_MULT
|
|
2043 mul do the math
|
|
2044 addb $06,u add in x
|
|
2045 adca #0 add in the carry bit
|
|
2046 addd #gfx_picbuff add in pic buff base $6040
|
|
2047
|
|
2048 ldu $0A,u load u with with the buffer pointer blit_cur
|
|
2049 L09f5 std u00a8 save the buffer start pointer pic_cur
|
|
2050 addd u00a0 add in the offset x_size
|
|
2051 std u00ad stow that at pic_cur + offset
|
|
2052 ldx u00a8 load x with pic_cur
|
|
2053 L09fd ldd ,x++ copy 2 bytes at a time
|
|
2054 std ,u++ to the buffer at blit_cur
|
|
2055 cmpx u00ad have we copied it all ??
|
|
2056 blo L09fd nope loop again
|
|
2057
|
|
2058 ldd u00a8 load with pic buffer start
|
|
2059 addd #PICBUFF_WIDTH add 160
|
|
2060 dec u00a2 dec y_count
|
|
2061 bne L09f5 not zero loop again
|
|
2062 rts
|
|
2063
|
|
2064
|
|
2065 * blit_restore(BLIT *b) obj_blit.c
|
|
2066 * blit_save(BLIT *b) obj_blit.c
|
|
2067 * our blit_struct is a bit different from the one in nagi
|
|
2068 *
|
|
2069 * u00a0 = zeroed and never changed cause we use the next byte :-)
|
|
2070 * u00a1 = x_count (x_size) when cmpx ha ha
|
|
2071 * u00a2 = y_count (y_size)
|
|
2072 * u00a8 = pic buffer start pic_cur
|
|
2073 * u00ad = pic_cur + offset
|
|
2074
|
|
2075 L0a0f ldu $02,s get the pointer to the blit structure
|
|
2076 ldd $0C,u
|
|
2077 lbsr L0074 twiddle mmu
|
|
2078
|
|
2079 ldu $02,s get the blit_structure back in u
|
|
2080 ldd $08,u load x/y_size
|
|
2081 std u00a1 stow them at x/y_count
|
|
2082 clr u00a0 clear the byte prior to x_size
|
|
2083 ldb $07,u get the y value
|
|
2084 lda #$a0 set up PBUF_MULT
|
|
2085 mul do the math
|
|
2086 addb $06,u add in the x value
|
|
2087 adca #0 add in the carry bit
|
|
2088 addd #gfx_picbuff add in the base address $6040
|
|
2089
|
|
2090 ldu $0A,u load u with buffer pointer blit_cur
|
|
2091 L0a2c std u00a8 save the screen start buffer pic_cur
|
|
2092 addd u00a0 add in the x_size
|
|
2093 std u00ad stow at pic_cur + offset
|
|
2094 ldx u00a8 load x pic_cur pointer
|
|
2095 L0a34 ldd ,u++ grab em from the buffer
|
|
2096 std ,x++ and send them to the screen
|
|
2097 cmpx u00ad moved them all ??
|
|
2098 blo L0a34 nope then keep on keeping on
|
|
2099
|
|
2100 ldd u00a8 load the pic_cur pointer
|
|
2101 addd #PICBUFF_WIDTH add 160
|
|
2102 dec u00a2 dec the y count
|
|
2103 bne L0a2c not zero move some more
|
|
2104 rts
|
|
2105
|
|
2106 fcb $00,$00,$00,$00
|
|
2107 fcb $00,$00,$00,$00
|
|
2108 fcc "shdw"
|
|
2109 fcb $00
|
|
2110
|
|
2111 emod
|
|
2112
|
|
2113 eom equ *
|
|
2114
|
|
2115 end
|
1049
|
2116 |