/[projet1]/users/barnsey123/HNEFATAFL/draw.s
Defence Force logotype

Contents of /users/barnsey123/HNEFATAFL/draw.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 794 - (show annotations)
Thu Feb 2 21:59:54 2012 UTC (8 years, 1 month ago) by dbug
File size: 6775 byte(s)
Added game.s to handle optimized game routines.
Converted the board drawing code to assembler.
Size -> 36039
1
2
3
4
5 .zero
6
7 .text
8 #define _rom_curset $f0c8
9 #define _rom_curmov $f0fd
10 #define _rom_draw $f110
11 #define _rom_fill $f268
12 #define _rom_circle $f37f
13 #define _params $2e0
14 #define _rom_pattern $213
15
16 ; draws the border
17 /*
18 _drawborder
19 .(
20 ;curset(12,198,1)
21 lda #12
22 sta _params+1
23 lda #$c6
24 sta _params+3
25 lda #0
26 sta _params+2
27 sta _params+4
28 lda #1
29 sta _params+5
30 jsr _rom_curset
31
32 ; draw(198,0,1)
33 lda #$c6
34 sta _params+1
35 lda #0
36 sta _params+2
37 sta _params+3
38 sta _params+4
39 lda #1
40 sta _params+5
41 jsr _rom_draw
42
43 ; draw(0,-198,1)
44 lda #0
45 sta _params+1
46 sta _params+2
47 sec
48 sbc #$c6
49 sta _params+3
50 lda #$ff
51 sta _params+4
52 lda #1
53 sta _params+5
54 jmp _rom_draw
55 .)
56 */
57 ;
58 ; draws a box
59 /*
60 _drawbox
61 .(
62 ; curset(tilex,tiley,3);
63 lda #12
64 sta _params+1
65 lda #198
66 sta _params+3
67 lda #0
68 sta _params+2
69 sta _params+4
70 lda #3
71 sta _params+5
72 jsr _rom_curset
73
74 ; draw(size,0,fb);
75 lda #196
76 sta _params+1
77 lda #0
78 sta _params+2
79 sta _params+3
80 sta _params+4
81 lda #1
82 sta _params+5
83 jsr _rom_draw
84
85 ; draw(0,size,fb);
86 lda #0
87 sta _params+1
88 sta _params+2
89 sta _params+4
90 lda #196
91 sta _params+3
92 lda #1
93 sta _params+5
94 jsr _rom_draw
95
96 ; draw(-size,0,fb);
97 lda #0
98 sta _params+3
99 sta _params+4
100 sec
101 sbc #196
102 sta _params+1
103 lda #$ff
104 sta _params+2
105 lda _fb
106 sta _params+5
107 jsr _rom_draw
108
109 ; draw(0,-size,fb);
110 lda #0
111 sta _params+1
112 sta _params+2
113 sec
114 sbc #196
115 sta _params+3
116 lda #$ff
117 sta _params+4
118 lda #1
119 sta _params+5
120 jmp _rom_draw
121 .)
122 */
123
124 /*
125 ; draw a diamond at x,y size z, foreground or background
126 _drawdiamond
127 .(
128 ; curset(tilex,tiley,fb);
129 lda _tilex
130 sta _params+1
131 lda _tiley
132 sta _params+3
133 lda #0
134 sta _params+2
135 sta _params+4
136 lda #3
137 sta _params+5
138 jsr _rom_curset
139
140 ; draw(size,size,fb);
141 lda _size
142 sta _params+1
143 sta _params+3
144 lda #0
145 sta _params+2
146 sta _params+4
147 lda _fb
148 sta _params+5
149 jsr _rom_draw
150
151 ; draw(-size,size,fb);
152 lda #0
153 sta _params+4
154 sec
155 sbc _size
156 sta _params+1
157 lda #$ff
158 sta _params+2
159 lda _size
160 sta _params+3
161 lda _fb
162 sta _params+5
163 jsr _rom_draw
164
165 ; draw(-size,-size,fb);
166 lda #0
167 sec
168 sbc _size
169 sta _params+1
170 sta _params+3
171 lda #$ff
172 sta _params+2
173 sta _params+4
174 lda _fb
175 sta _params+5
176 jsr _rom_draw
177
178 ; draw(size,-size,fb);
179 lda _size
180 sta _params+1
181 lda #0
182 sta _params+2
183 sec
184 sbc _size
185 sta _params+3
186 lda #$ff
187 sta _params+4
188 lda _fb
189 sta _params+5
190 jmp _rom_draw
191 .)
192 */
193 /*
194 void drawcursor()
195 {
196 // - draw the cursor at cx,cy size z, foreground/background color (1 or 0)
197 char z=boxsize-2;
198 pattern(170);
199 curset(cx,cy,fb);
200 draw(z,0,fb);
201 draw(0,z,fb);
202 draw(-z,0,fb);
203 draw(0,-z,fb);
204 pattern(255);
205 }
206 */
207
208 _drawcursor
209 .(
210 ; char z=boxsize-2;
211 ldx _boxsize
212 dex
213 dex
214 stx tmp
215
216 ; pattern(170);
217 lda #170
218 sta _rom_pattern
219
220 ; curset(cx,cy,fb);
221 lda _cx
222 sta _params+1
223 lda _cy
224 sta _params+3
225 lda #0
226 sta _params+2
227 sta _params+4
228 lda _fb
229 sta _params+5
230 jsr _rom_curset
231
232 ; draw(z,0,fb);
233 lda tmp
234 sta _params+1
235 lda #0
236 sta _params+2
237 sta _params+3
238 sta _params+4
239 lda _fb
240 sta _params+5
241 jsr _rom_draw
242
243 ; draw(0,z,fb);
244 lda #0
245 sta _params+1
246 sta _params+2
247 sta _params+4
248 lda tmp
249 sta _params+3
250 lda _fb
251 sta _params+5
252 jsr _rom_draw
253
254 ; draw(-z,0,fb);
255 lda #0
256 sta _params+3
257 sta _params+4
258 sec
259 sbc tmp
260 sta _params+1
261 lda #$ff
262 sta _params+2
263 lda _fb
264 sta _params+5
265 jsr _rom_draw
266
267 ; draw(0,-z,fb);
268 lda #0
269 sta _params+1
270 sta _params+2
271 sec
272 sbc tmp
273 sta _params+3
274 lda #$ff
275 sta _params+4
276 lda _fb
277 sta _params+5
278 jsr _rom_draw
279
280 ; pattern(255);
281 lda #255
282 sta _rom_pattern
283 rts
284 .)
285
286
287 /*
288 _drawattackertile
289 .(
290 lda #13 ; line length
291 sta _size
292 jmp _drawbox ; drawbox at x,y position
293 .)
294 */
295
296
297
298 /*
299 void tileloop()
300 {
301 ptr_draw=(unsigned char*)0xa002; // pointer to start of board
302 ptr_draw+=(col*3)+(row*720); // 720=18*40 starting screen coordinate
303 for (counter=0;counter<18;inccounter()) //tileheight=pixels (e.g. 18)
304 {
305 //for (x=0;x<tilewidth;x++)
306 // {
307 // ptr_draw[x]=ptr_graph[x];
308 // }
309 ptr_draw[0]=ptr_graph[0];
310 ptr_draw[1]=ptr_graph[1];
311 ptr_draw[2]=ptr_graph[2];
312 ptr_draw+=40; // number of 6pixel "units" to advance (+40=next line down, same position across)
313 ptr_graph+=3; // + unit of measurement (how many 6pixel chunks "across" in graphic file)
314 }
315 }
316 */
317 _tileloop
318 .(
319 lda _ptr_graph+0
320 sta tmp0+0
321 lda _ptr_graph+1
322 sta tmp0+1
323
324 lda #<$a002
325 sta tmp1+0
326 lda #>$a002
327 sta tmp1+1
328
329 ; +col*3
330 .(
331 ldx _col
332 loop
333 beq end
334 clc
335 lda tmp1+0
336 adc #3
337 sta tmp1+0
338 lda tmp1+1
339 adc #0
340 sta tmp1+1
341 dex
342 jmp loop
343 end
344 .)
345
346 ; +row*720
347 .(
348 ldx _row
349 loop
350 beq end
351 clc
352 lda tmp1+0
353 adc #<720
354 sta tmp1+0
355 lda tmp1+1
356 adc #>720
357 sta tmp1+1
358 dex
359 jmp loop
360 end
361 .)
362
363
364 ; Draw loop
365 .(
366 ldx #18
367 loop
368 ldy #0
369 lda (tmp0),y
370 sta (tmp1),y
371 iny
372 lda (tmp0),y
373 sta (tmp1),y
374 iny
375 lda (tmp0),y
376 sta (tmp1),y
377
378 .(
379 clc
380 lda tmp0+0
381 adc #3
382 sta tmp0+0
383 bcc skip
384 inc tmp0+1
385 skip
386 .)
387
388 .(
389 clc
390 lda tmp1+0
391 adc #40
392 sta tmp1+0
393 bcc skip
394 inc tmp1+1
395 skip
396 .)
397
398 dex
399 bne loop
400 .)
401
402 ; Update ptr_graph (for animation purpose)
403 lda tmp0+0
404 sta _ptr_graph+0
405 lda tmp0+1
406 sta _ptr_graph+1
407
408 rts
409 .)
410
411
412
413 /*
414 void drawtile() // draws a board tile, player piece or "arrow"
415 {
416 startpos=tiletodraw*54; // 54=3*18 calc how many lines "down" in the graphic file to print from
417 ptr_graph+=startpos; // set start position in graphic file
418 tileloop();
419 }
420 */
421 _drawtile
422 .(
423 ; ptr_graph+=tiletodraw*54
424 .(
425 ldx _tiletodraw
426 loop
427 beq end
428 clc
429 lda _ptr_graph+0
430 adc #<54
431 sta _ptr_graph+0
432 bcc skip
433 inc _ptr_graph+1
434 skip
435 dex
436 jmp loop
437 end
438 .)
439
440 jmp _tileloop
441 .)
442
443
444
445 /*
446 void drawtiles() // DRAW ALL THE TILES ON THE BOARD
447 {
448 for (row=0;row<11;row++)
449 {
450 for (col=0;col<11;col++)
451 {
452 players[row][col]=tiles[row][col]; // populate players array
453 ptr_graph=PictureTiles; // pointer to Picture Tiles graphics
454 tiletodraw=tiles[row][col];
455 if ( tiletodraw==4 ) { tiletodraw=3;}
456 drawtile();
457 }
458 }
459 }
460 */
461 _drawtiles
462 .(
463 ldy #0
464
465 ldx #0
466 loop_row
467 stx _row
468
469 ldx #0
470 loop_col
471 stx _col
472
473 lda _tiles,y
474 sta _players,y
475 cmp #4
476 bne set_tile_to_draw
477 lda #3
478 set_tile_to_draw
479 sta _tiletodraw
480
481 lda #<_PictureTiles
482 sta _ptr_graph+0
483 lda #>_PictureTiles
484 sta _ptr_graph+1
485
486 tya
487 pha
488
489 jsr _drawtile
490
491 pla
492 tay
493 iny
494
495 ldx _col
496 inx
497 cpx #11
498 bne loop_col
499
500 ldx _row
501 inx
502 cpx #11
503 bne loop_row
504
505 rts
506 .)
507

  ViewVC Help
Powered by ViewVC 1.1.26