/[projet1]/users/dbug/DungeonOSDK/GRAF.S
Defence Force logotype

Contents of /users/dbug/DungeonOSDK/GRAF.S

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1377 - (show annotations)
Thu Jul 28 18:17:03 2016 UTC (3 years, 10 months ago) by dbug
File size: 6430 byte(s)
Trying to port the old Dungeon Demo to the OSDK.
Problems found so far:
- "a" after rotation instructions (rol a, asr a, etc... instead of just rol, asr, ...)
- "BYTE" and "WORD" instead of .byt and .word
- "RESERVE" instead of ".dsb"
and that's about it :D
1 ;
2 ;
3 ; Fastgraf 6502 assembly library
4 ; (c) 1996 Micka‰l POINTIER (Dbug from NeXT)
5 ;
6 ;
7
8 _cling
9 lda #0 ; Fine tuning (0-255)
10 ldx #7
11 jsr $f590
12
13 lda #1 ; High (0-15)
14 ldx #7
15 jsr $f590
16
17 lda #7
18 ldx #8+16+32 ; No Noise
19 jsr $f590
20
21 lda #8
22 ldx #15
23 jsr $f590
24 rts
25
26
27 _DisplayBuffer
28 .dsb 3900
29
30
31
32 _SymTable .dsb 256
33
34
35
36 ;
37 ; Le but est d'inverser les 6 bits de poids faible,
38 ; tout en gardant les 2 bits de poids fort identiques
39 ;
40 _CreateSymTable
41 ldx #0
42 createsym_loop_value
43 lda #0
44 sta _SymTable,x
45
46 txa
47 and #64
48 beq createsym_attribut
49
50 createsym_graphics
51 rol ; Bit d'inversion video
52 rol _SymTable,x
53 rol ; Bit de flag d'attribut
54 rol _SymTable,x
55
56 txa
57 ldy #6 ; 6 bits de graph
58 createsym_loop_shift
59 ror
60 rol _SymTable,x
61 dey
62 bne createsym_loop_shift
63
64 inx
65 bne createsym_loop_value
66 rts
67
68 createsym_attribut
69 txa
70 sta _SymTable,x
71 inx
72 bne createsym_loop_value
73 rts
74
75
76
77
78 _ClearDisplayBuffer
79 lda #64
80 ldx #0
81 clear_display_loop
82 sta _DisplayBuffer+256*0,x ; 0-255
83 sta _DisplayBuffer+256*1,x ; 256-511
84 sta _DisplayBuffer+256*2,x ; 512
85 sta _DisplayBuffer+256*3,x ; 768
86 sta _DisplayBuffer+256*4,x ; 1024
87 sta _DisplayBuffer+256*5,x ; 1280
88 sta _DisplayBuffer+256*6,x ; 1536
89 sta _DisplayBuffer+256*7,x ; 1792
90 sta _DisplayBuffer+256*8,x ; 2048
91 sta _DisplayBuffer+256*9,x ; 2304
92 sta _DisplayBuffer+256*10,x ; 2560
93 sta _DisplayBuffer+256*11,x ; 2816
94 sta _DisplayBuffer+256*12,x ; 3072
95 sta _DisplayBuffer+256*13,x ; 3328
96 sta _DisplayBuffer+256*14,x ; 3584-3839
97 sta _DisplayBuffer+3644,x ; 3644-3899
98 dex
99 bne clear_display_loop
100 rts
101
102
103
104 ;
105 ; The first text line in hires is at adress $bf68
106 ;
107 ; void AddMessage(char *message,char color)
108 ;
109 _AddMessage
110 ;
111 ; Commence par faire scroller d'une ligne
112 ; vers le haut de l'‚cran
113 ;
114 ldx #0
115 scroll_loop
116 lda $bf90,x ; line 1
117 sta $bf68,x ; line 0
118 inx
119 cpx #80
120 bne scroll_loop
121
122 ;
123 ; Effacement de la troisieme ligne
124 ; sauf le premier caractere qui est un Attribut
125 ;
126 ldx #40
127 erase_loop
128 sta $bfb8,x ; line 2
129 dex
130 bne erase_loop
131
132 ;
133 ; Inscription de l'attribut couleur
134 ; Puis affichage en colonne 2 du texte
135 ;
136 ldy #0
137 lda (sp),y
138 sta print_loop+1
139
140 iny
141 lda (sp),y
142 sta print_loop+2
143
144 iny
145 lda (sp),y
146 sta $bfb8 ; Met l'attribut couleur
147
148 ldx #0
149 print_loop
150 lda $2211,x ; source
151 beq exit
152 sta $bfb9,x ; destination
153 inx
154 bne print_loop
155 exit
156 rts
157
158
159
160 ;
161 ; void SetScreenSize(unsigned int largeur);
162 ;
163 _SetScreenSize
164 ldy #0
165 lda (sp),y ; largeur ‚cran
166 sta auto_dst+1 ; DrawSprite
167 sta text_dst+1 ; AffText
168 sta column_dst+1 ; FillColumn
169 sta box_dst+1 ; FillBox
170 rts
171
172
173
174
175 ;
176 ; void AffText(ptr_screen,ptr_chaine)
177 ;
178 ; Nb: L'adresse de base de la fonte en Hires est $9800 (std) ou $9c00 (alt)
179 ; Chaque jeu de caracteres fait 1Ko.
180 ; Le jeu alternate est effac‚ sur 256 octets (32 premiers caracteres) et
181 ; contient une table de saut sur chaque caractere de la fonte standard
182 ;
183 _AffText
184 ldy #0
185 lda (sp),y
186 sta text_screen_adr+1
187
188 iny
189 lda (sp),y
190 sta text_screen_adr+2
191
192
193 iny
194 lda (sp),y
195 sta text_string+1
196
197 iny
198 lda (sp),y
199 sta text_string+2
200
201
202 ldy #0
203 text_string
204 lda $2211,y ; a=[127-0]
205 beq text_exit
206
207 asl ; a*2 a=[255-0] (Nb: 'Carry' forcement nulle !)
208 tax ; x=offset sur adresse de base
209 lda $9c00,x
210 sta text_loop_car+1
211 lda $9c01,x
212 sta text_loop_car+2
213
214 ldx #0
215 text_loop_car
216 lda $2211,x
217 ora #64
218 text_screen_adr
219 sta $a000
220
221 clc ; Screen+=40
222 lda text_screen_adr+1
223 text_dst
224 adc #40
225 sta text_screen_adr+1
226 lda text_screen_adr+2
227 adc #0
228 sta text_screen_adr+2
229
230 inx
231 cpx #8
232 bne text_loop_car
233
234 sec ; Screen-=(40*8-1)
235 lda text_screen_adr+1
236 sbc #$3f
237 sta text_screen_adr+1
238 lda text_screen_adr+2
239 sbc #$01
240 sta text_screen_adr+2
241
242 iny
243 jmp text_string
244 text_exit
245 rts
246
247
248
249
250 ;
251 ; void FillColumn(ptr_screen,height,value)
252 ;
253 _FillColumn
254 ldy #0
255 lda (sp),y
256 sta loop_y+1 ; dest
257
258 iny
259 lda (sp),y
260 sta loop_y+2 ; dest
261
262 iny
263 lda (sp),y
264 sta auto_hh+1 ; hauteur
265 iny
266
267 iny
268 lda (sp),y ; value
269 tax
270
271 auto_hh
272 ldy #5
273 loop_y
274 stx $2211 ; destination
275 clc
276 lda loop_y+1
277 column_dst
278 adc #40
279 sta loop_y+1
280 bcc next_loop
281 lda loop_y+2
282 adc #0
283 sta loop_y+2
284
285 next_loop
286 dey
287 bne loop_y
288 rts
289
290
291
292
293
294 ;
295 ; void FillBox(ptr_screen-1,(largeur|hauteur),value)
296 ;
297 _FillBox
298 ldy #0
299 lda (sp),y
300 sta loop_x_fillbox+1 ; dest
301
302 iny
303 lda (sp),y
304 sta loop_x_fillbox+2 ; dest
305
306 iny
307 lda (sp),y
308 sta auto_l_fillbox+1 ; largeur
309 iny
310 lda (sp),y
311 sta auto_h_fillbox+1 ; hauteur
312
313 iny
314 lda (sp),y ; value
315 sta auto_v_fillbox+1
316
317 auto_h_fillbox
318 ldy #22
319 loop_y_fillbox
320 auto_l_fillbox
321 ldx #5
322 auto_v_fillbox
323 lda #3
324 loop_x_fillbox
325 sta $2211,x ; destination
326 dex
327 bne loop_x_fillbox
328
329 clc
330 lda loop_x_fillbox+1
331 box_dst
332 adc #40
333 sta loop_x_fillbox+1
334 bcc next_loop_fill
335 lda loop_x_fillbox+2
336 adc #0
337 sta loop_x_fillbox+2
338
339 next_loop_fill
340 dey
341 bne loop_y_fillbox
342 rts
343
344
345
346
347
348 ;
349 ; void SetSpriteSize(unsigned int (offset_src|largeur),unsigned int hauteur);
350 ;
351 _SetSpriteSize
352 ldy #0
353 lda (sp),y ; l
354 sta auto_l+1
355 sta auto_src+1
356
357 iny
358 lda (sp),y ; offset (si 0, on touche pas !)
359 beq end_offset
360 clc
361 adc auto_src+1
362 sta auto_src+1
363 end_offset
364
365 iny
366 lda (sp),y ; h
367 sta auto_h+1
368 rts
369
370
371
372
373 ;
374 ; void DrawSprite(ptr_dst-1,ptr_src-1)
375 ;
376 _DrawSprite
377 ldy #0
378 lda (sp),y
379 sta draw_sprite_dst+1 ; dest
380
381 iny
382 lda (sp),y
383 sta draw_sprite_dst+2 ; dest
384
385 iny
386 lda (sp),y
387 sta draw_sprite_loop_x+1 ; source
388
389 iny
390 lda (sp),y
391 sta draw_sprite_loop_x+2 ; source
392
393 auto_h
394 ldy #22
395
396 draw_sprite_loop_y
397
398 auto_l
399 ldx #5
400
401 draw_sprite_loop_x
402 lda $2211,x ; source
403 ;
404 ;sty _memoy
405 ;tay
406 ;lda _SymTable,y
407 ;ldy _memoy
408 ;
409 draw_sprite_dst
410 sta $5544,x ; destination
411 dex
412 bne draw_sprite_loop_x
413
414 clc
415 lda draw_sprite_loop_x+1
416 auto_src
417 adc #5
418 sta draw_sprite_loop_x+1
419 bcc go_dest
420 lda draw_sprite_loop_x+2
421 adc #0
422 sta draw_sprite_loop_x+2
423
424 go_dest
425 clc
426 lda draw_sprite_dst+1
427 auto_dst
428 adc #40
429 sta draw_sprite_dst+1
430 bcc go_end
431 lda draw_sprite_dst+2
432 adc #0
433 sta draw_sprite_dst+2
434 go_end
435 dey
436 bne draw_sprite_loop_y
437 rts
438 _memoy
439
440

  ViewVC Help
Powered by ViewVC 1.1.26