/[projet1]/users/dbug/demos/256bytes/main.s
Defence Force logotype

Contents of /users/dbug/demos/256bytes/main.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (show annotations)
Sun Feb 22 19:54:35 2009 UTC (11 years, 3 months ago) by dbug
File size: 4785 byte(s)
Added a 256 bytes demo (never released)
1
2 ;// --------------------------------------
3 ;// 256b moving backgound (Working title)
4 ;// --------------------------------------
5 ;// (c) 2006 Mickael Pointier
6 ;// This code is provided as-is.
7 ;// I do not assume any responsability
8 ;// concerning the fact this is a bug-free
9 ;// software !!!
10 ;// Except that, you can use this example
11 ;// without any limitation !
12 ;// If you manage to do something with that
13 ;// please, contact me.
14 ;// --------------------------------------
15 ;// Note: This text was typed with a Win32
16 ;// editor. So perhaps the text will not be
17 ;// displayed correctly with other OS.
18
19
20 ;#define DEBUGMODE
21
22
23
24 ;//
25 ;// ROM system defines
26 ;// (Works only on ROM 1.1)
27 ;//
28 #define _rom_hires $ec33
29 //#define _rom_text $ec21
30
31 #define _rom_ink $f210
32 #define _rom_paper $f204
33
34 #define _rom_ping $fa9f
35 #define _rom_shoot $fab5
36 #define _rom_zap $fae1
37 #define _rom_explode $facb
38
39 #define _rom_kbdclick1 $fb14
40 #define _rom_kbdclick2 $fb2a
41
42 //#define _rom_cls $ccce
43 //#define _rom_lores0 $d9ed
44 //#define _rom_lores1 $d9ea
45
46 #define _rom_curset $f0c8
47 #define _rom_curmov $f0fd
48 #define _rom_draw $f110
49 #define _rom_fill $f268
50 #define _rom_circle $f37f
51
52 #define _rom_redef_chars $f8d0
53
54 #define KEY_NONE $38
55 #define KEY_UP 11 //$9c
56 #define KEY_DOWN 10 //$b4
57 #define KEY_LEFT 8 //$ac
58 #define KEY_RIGHT 9 //$bc
59 #define KEY_SPACE 32 //$84
60 #define KEY_P 80 //$9d
61 #define KEY_DELETE 127
62 #define KEY_ESCAPE 27 //$a9
63 #define KEY_ENTER 13
64
65
66 ;//
67 ;// Page two definition
68 ;//
69 #define ROM_CURX $219
70 #define ROM_CURY $21a
71
72 ;//
73 ;// Zero page definition
74 ;//
75
76 .zero
77
78 *= $50
79
80 ;// Some two byte values
81 _zp_start_
82
83 circle_ray .dsb 1
84
85 tmp0 .dsb 1
86 tmp1 .dsb 1
87
88 ptr_src .dsb 2
89 ptr_src2 .dsb 2
90
91 ptr_dst .dsb 2
92
93
94 param .dsb 1
95 param_x .dsb 2
96 param_y .dsb 2
97 param_fb .dsb 2
98
99
100
101 _zp_end_
102
103
104
105
106 .text
107
108 _main
109 ;
110 ; Switch to hires
111 ;
112 #ifndef DEBUGMODE
113 jsr _rom_hires
114 #endif
115
116 ;
117 ; Erase the parameter area
118 ;
119 .(
120 lda #0
121 ldx #7
122 loop
123 sta $2e0-1,x
124 dex
125 bne loop
126 .)
127
128
129 ;
130 ; Force "manualy" text mode
131 ;
132 lda #26 ; 50hz TEXT switch
133 sta $bfdf
134
135 ;
136 ; More CPU time, and no more blinking cursor !
137 ;
138 sei
139
140 .(
141 ;
142 ; Let's fill screen with a pattern of characters, for example that:
143 ;
144 ; @CFI
145 ; ADGJ
146 ; BEHK
147 ;
148 lda #0
149 sta tmp0
150 sta tmp1
151
152 lda #<$bb80
153 sta ptr_src+0
154 lda #>$bb80
155 sta ptr_src+1
156
157 ldx #28
158 loop_y
159 ldy #39
160 loop_x
161
162 .(
163 lda tmp0
164 bne skip
165 lda #12
166 skip
167 sec
168 sbc #3
169 sta tmp0
170 .)
171
172 clc
173 lda #"@"
174 adc tmp0
175 adc tmp1
176
177 ; Write character in video memory
178 sta (ptr_src),y
179
180 dey
181 bne loop_x
182
183 sty tmp0
184
185 ; End of line, we write the color attribute at the begining,
186 ; and update line pointers...
187 lda #4 ; BLUE INK
188 sta (ptr_src),y
189
190 .(
191 clc
192 lda tmp1
193 adc #1
194 cmp #3
195 bne skip
196 lda #0
197 skip
198 sta tmp1
199 .)
200
201 jsr IncPtrSrc
202
203 dex
204 bne loop_y
205 .)
206
207 #ifdef DEBUGMODE
208 Breakkk
209 jmp Breakkk
210 #endif
211
212 lda #1
213 sta $2e0+3 ; Set the FB parameter to "draw"
214 BigLoop
215 .(
216 ;
217 ; Draw a first animated circle
218 ;
219 ldx circle_ray
220 inx
221 txa
222 and #15
223 sta circle_ray
224
225 ;
226 ; Draw two circles
227 ;
228 ldx #2
229 loop_circle
230 stx tmp0
231
232 lda CircleData-1,x
233 sta ROM_CURX
234 sta ROM_CURY
235
236 ldx circle_ray
237 inx
238 stx $2e0+1
239
240 jsr _rom_circle
241
242 ldx tmp0
243 dex
244 bne loop_circle
245
246 .)
247
248 ; Pattern register
249 inc $213
250
251 .(
252 ;
253 ; Let's dump a 24x24 pixels area of the HIRES screen to the redefined characters area :D
254 ;
255 #define SCREEN_SRC $a000
256 #define SCREEN_DST $b400+8*"@"
257
258 #define SCREEN_SRC_OFFSET (-40*24)+1
259
260 lda #<SCREEN_SRC
261 sta ptr_src+0
262 lda #>SCREEN_SRC
263 sta ptr_src+1
264
265 lda #<SCREEN_DST
266 sta ptr_dst+0
267 lda #>SCREEN_DST
268 sta ptr_dst+1
269
270 ldx #4
271 loop_x
272 stx tmp0
273
274 ldx #24
275 loop_y
276 ; Compute the secondary pointer to access the tiled versions
277 ; of HIRES bitmap
278 clc
279 lda ptr_src+0
280 adc #<40*24
281 sta ptr_src2+0
282 lda ptr_src+1
283 adc #>40*24
284 sta ptr_src2+1
285
286 ldy #4
287 lda (ptr_src),y
288 ora (ptr_src2),y
289 ldy #0
290 ora (ptr_src),y
291 ora (ptr_src2),y
292
293 ; Update the char map
294 sta (ptr_dst),y
295
296 ; Clean the HIRES buffer
297 lda #64
298 sta (ptr_src),y
299 sta (ptr_src2),y
300 ldy #4
301 sta (ptr_src),y
302 sta (ptr_src2),y
303
304 jsr IncPtrSrc
305
306 .(
307 inc ptr_dst+0
308 bne skip
309 inc ptr_dst+1
310 skip
311 .)
312
313 dex
314 bne loop_y
315
316 .(
317 clc
318 lda ptr_src+0
319 adc #<SCREEN_SRC_OFFSET
320 sta ptr_src+0
321 lda ptr_src+1
322 adc #>SCREEN_SRC_OFFSET
323 sta ptr_src+1
324 .)
325
326 ldx tmp0
327 dex
328 bne loop_x
329 .)
330 jmp BigLoop
331
332
333 IncPtrSrc
334 .(
335 clc
336 lda ptr_src+0
337 adc #40
338 sta ptr_src+0
339 bcc skip
340 inc ptr_src+1
341 skip
342 .)
343 rts
344
345 CircleData .byt 12,24
346

  ViewVC Help
Powered by ViewVC 1.1.26