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