/[projet1]/public/oric/demos/assembly_2002/makedisk/loader.asm
Defence Force logotype

Contents of /public/oric/demos/assembly_2002/makedisk/loader.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 473 - (show annotations)
Fri Apr 29 22:00:16 2011 UTC (8 years, 10 months ago) by dbug
File size: 8991 byte(s)
Added the Assembly 2002 demo, it's very messy, need some cleanup, but well
1 #include "asm2k2.h"
2
3
4
5 #define FDC_command $0310
6 #define FDC_status $0310
7 #define FDC_track $0311
8 #define FDC_sector $0312
9 #define FDC_data $0313
10 #define MICRODISC $0314
11
12
13
14
15
16
17 *=location_loader
18
19
20
21 Initialize
22 SEI ; Stop IRQ CPU
23 lda #$7F ; Stop VIA interrupt
24 sta $030D
25
26 /*ASM2K2 Loader !*/
27
28
29
30 /**********************************************************************************************************************/
31 /* MAIN */
32 /**********************************************************************************************************************/
33 /*
34 Memory: C000-C72A (1834 Bytes)
35 Init Call: C010 (Will not set IRQ vector)
36 IRQ Address: C035
37 */
38
39 ; Prevents reset !
40 lda #<irq_reset
41 sta $fffa
42 sta $fffc
43 lda #>irq_reset
44 sta $fffb
45 sta $fffd
46 jsr SOFT_HIRES
47
48 SEI
49 ldx #1 ; First picture
50 jsr begin_loading
51 jsr execute
52 ; jsr wait
53 ;jsr wait
54
55 ldx #0 ; load the Music
56 jsr begin_loading
57
58
59 ;jsr wait
60 ;jsr wait
61 ldx #2
62 jsr begin_loading
63
64 lda #$60
65 sta $400
66
67 SEI
68
69 jsr start_6522 ;this will setup the 6522 (Not the music, as u said!)
70 LDA #<new_irq ;Redirect (Low) IRQ vector to the address of new_irq
71 sta $fffe
72 lda #>new_irq ;Redirect (High) IRQ vector to the address of new_irq
73 sta $ffff
74 jsr $c010 ;This will setup for Music Pattern 1, and CLI!!
75
76
77
78
79
80
81 jsr $600
82 loop
83
84 jmp loop
85
86 new_irq
87 PHA
88 TXA
89 PHA
90 TYA
91 PHA
92 JSR $400 ;No need to worry about restoring registers!
93 LDA $0304
94 pla
95 tay
96 pla
97 tax
98 pla
99 jmp $c035 ;This will process music then finish the irq (RTI)
100
101
102
103 ;
104
105
106 start_6522
107 lda #247
108 sta $302
109 LDA #255
110 STA $0303 ;SET DDRA TO ALL OUT
111 LDA #$7F ;DISABLE ALL IRQ'S
112 STA $030E
113 LDA #$C0 ;ENABLE JUST T1 IRQ
114 STA $030E
115 LDA #$40 ;SET T1 MODE TO CONTINUOUS IRQ'S
116 STA $030B
117 LDA #$10 ;SET T1 LATCH TO 10,000
118 STA $0306
119 LDA #$27
120 STA $0307
121 LDA #$DD
122 STA $030C
123 rts
124
125 irq_reset
126 .byt $40 ; RTI opcode
127
128
129 /*Execute first effect*/
130
131
132
133
134
135
136
137 /**********************************************************************************************************************/
138 /* FIN_MAIN */
139 /**********************************************************************************************************************/
140
141
142
143
144
145
146
147 stop_music
148 LDA #>opcode_rti
149 STA $FFFE
150 LDA #<opcode_rti
151 STA $FFFF
152
153
154
155 SILENCE_SOUND
156 LDY #$DD
157 STY $030C
158 LDX #$0A
159 SS_01
160 STX $030F
161 LDA #$FF
162 STA $030C
163 STY $030C
164 LDA AY_TABLE,X
165 STA $030F
166 LDA #$FD
167 STA $030C
168 STY $030C
169 DEX
170 BPL SS_01
171 rts
172 AY_TABLE
173 .byt 00,00,00,00,00,00,00,$7F,00,00,00
174
175
176
177
178
179 /**********************************************************************************************************************/
180 /* LECTURE */
181 /**********************************************************************************************************************/
182
183
184
185
186 /*Lecture************************************************************/
187
188 readlinsect
189
190 lda current_sector
191
192 cmp #18 ; On a dépassé une piste
193 bne s_set_sector
194
195 inc current_track ; oui on augmente la track
196
197
198 lda #1 ; on remet à zéro le secteur à un ?
199 sta current_sector
200 ;lda #21
201 ;sta 49000+40
202
203
204 s_set_sector
205
206 lda current_track
207
208 sec
209 sbc #128 ; On change de face ?
210 bmi stay_on_the_good_side
211 lda #%00010000
212 sta current_side ; We change the side to 1 !
213 lda #0
214 sta current_track ; now we are in track 0 side 2 !
215 lda #1
216 sta current_sector
217 ;lda #20
218 ;sta $bb80
219 stay_on_the_good_side
220 lda current_sector
221 sta FDC_sector
222 inc current_sector
223
224
225
226 lda current_track
227 cmp FDC_track ; On regarde si on est bien sur la bonne piste
228
229 beq stay_on_the_track
230
231
232 sta FDC_data ;on set la piste
233
234
235 lda #$1F ; ordre de chgt de track
236 sta FDC_command
237
238 jsr wait_completion
239
240 lda #%10000101 ; on force les le Microdisk en side0, drive A ... Set le bit de données !!!
241 ora current_side
242 sta MICRODISC
243
244 stay_on_the_track
245 lda #$80
246 command
247 sta FDC_command
248
249
250 waitcommand_again
251 ldy #wait_status_floppy
252 waitcommand
253 nop
254 nop
255 dey
256
257 bne waitcommand
258
259
260
261 readbyte
262 ;cli
263
264 ldy #0
265 microdisc_read_data
266 lda $0318
267 bmi microdisc_read_data
268
269 lda $313
270 page_to_load
271 sta $c000,y
272 iny
273
274
275 ;jmp microdisc_read_data
276
277 ;lda FDC_status
278 ;and #3
279 ;lsr
280
281 bne microdisc_read_data
282
283 lda FDC_status
284 and #$1C
285
286 rts
287
288
289
290
291
292 /*On inite !*/
293
294
295 irq_handler
296 pla ; get rid of IRQ context
297 pla
298 pla
299 lda #%10000101
300 ora current_side
301 sta $0314 ; disables disk irq
302 lda $0310 ; gets status and resets irq
303
304 rts
305
306
307
308
309
310
311
312 /*Lecture du secteur !*/
313
314 start_read
315
316
317
318 sectreadloop
319 lda #4
320 sta retry
321
322 readretryloop
323 ;jsr stop_music
324 jsr readlinsect
325 ;lda music_during_loading
326 ;beq encore_incremente
327 ;jsr start_music
328 ;jsr wait
329
330 ; beq sectreadok
331 ; dec retry
332 ; bne readretryloop
333
334 /*Ptet mettre un wait au cas ou ICI ?!*/
335 ; sec
336 ; rts
337
338 sectreadok
339 ; lda #<txt_sector
340 ; ldx #>txt_sector
341 ; jsr display_string
342
343
344
345 encore_incremente
346 inc page_to_load+2
347 dec pages
348 bne sectreadloop
349
350 ;sei
351 /*
352 lda #%10000101
353 sta $0314
354
355 */
356 rts
357
358 begin_loading
359
360 sei
361 lda #$7F
362 sta $030D
363
364 ldy #<irq_handler
365 lda #>irq_handler
366 sty $fffe
367 sta $ffff
368
369 ;X contains the program to load !
370 lda adresse_chargement_high,x
371 sta execute+2 ; set high adress (Execute)
372 sta page_to_load+2 ; on inite l'adresse de chargement
373
374
375 lda adresse_chargement_low,x
376 sta execute+1
377 sta page_to_load+1 ; on inite l'adresse de chargement
378
379
380 lda #0 ; We go to side 0
381 sta current_side
382
383 lda datas_piste,x
384 sta temp
385
386 sec
387 sbc #128 ; Is it the 2nd side ?
388 bmi good_side ; No we are in side 1
389 sta temp
390
391 lda #%00010000 ; We set the second side b4==16
392 sta current_side
393 ;lda #20
394 ;sta 49000
395
396 good_side
397 lda temp
398 sta current_track
399
400 lda datas_secteur,x
401 sta current_sector
402
403 lda nombre_secteur,x ; nb of page à charger
404 sta pages
405 jsr start_read
406
407 ;sei
408 lda #$84
409 ora current_side
410 sta $0314
411
412 rts
413 execute
414 jsr $a000
415 ;jsr attente_touche
416 rts
417
418
419
420 /**********************************************************************************************************************/
421 /* FIN_LECTURE */
422 /**********************************************************************************************************************/
423
424
425
426
427
428 /**********************************************************************************************************************/
429 /* UN pack */
430 /**********************************************************************************************************************/
431
432 ;#include "unpack.asm"
433 /**********************************************************************************************************************/
434 /* FIN_Un pack */
435 /**********************************************************************************************************************/
436
437 /**************************************************/
438
439 wait_completion
440 ldy #4
441 r_wait_completion
442 dey
443 bne r_wait_completion
444 r2_wait_completion
445 lda $0310
446 lsr
447 bcs r2_wait_completion
448 asl
449 rts
450
451
452
453
454 SOFT_HIRES
455 LDY #$00 ;COPY CHARSET
456 HM_03
457 LDA $B500,Y
458 STA $9900,Y
459 LDA $B600,Y
460 STA $9A00,Y
461 LDA $B700,Y
462 STA $9B00,Y
463 LDA $B900,Y
464 STA $9D00,Y
465 LDA $BA00,Y
466 STA $9E00,Y
467 LDA $BB00,Y
468 STA $9F00,Y
469 DEY
470 BNE HM_03
471 LDA #$A0 ;CLEAR DOWN ALL MEMORY AREA WITH ZERO
472 STA $01
473 LDA #$00
474 STA $00
475 LDX #$20
476 HM_01 STA ($00),Y
477 INY
478 BNE HM_01
479 INC $01
480 DEX
481 BNE HM_01
482 LDA #30 ;WRITE HIRES SWITCH
483 STA $BF40
484 LDA #$A0 ;CLEAR HIRES WITH #$40
485 STA $01
486 LDX #$20
487 LDX #64
488 HM_04
489 LDY #124
490 HM_05
491 LDA #$40
492 STA ($00),Y
493 DEY
494 BPL HM_05
495 LDA $00
496 ADC #125
497 STA $00
498 BCC HM_02
499 INC $01
500 HM_02 DEX
501 BNE HM_04
502 RTS
503
504 wait
505 .(
506 /*empile les registres*/
507
508 pha
509 txa
510 pha
511 tya
512 pha
513 incrementation2
514 ldy #$0
515 incrementation22
516 ry2
517 ldx #$0
518 rx2
519 NOP
520 NOP
521 NOP
522 NOP
523 NOP
524 NOP
525 NOP
526 NOP
527 NOP
528 NOP
529 NOP
530 NOP
531 NOP
532 NOP
533 NOP
534 NOP
535 NOP
536 NOP
537 NOP
538 NOP
539 dex
540
541 bne rx2
542 dey
543 bne ry2
544
545 pla
546 tay
547 pla
548 tax
549 pla
550
551 rts
552
553 .)
554
555
556
557
558
559 prgm_en_cours
560 .byt 0
561
562
563 #include<loader.cod>
564 opcode_rti
565 .byt $40
566
567 sect_low
568 .byt 0
569 sect_hi
570 .byt 0
571 pages
572 .byt 0
573 retry
574 .byt 0
575 temp
576 .byt 0
577 current_track
578 .byt 0
579 current_sector
580 .byt 0
581 current_side
582 .byt 0
583 music_during_loading
584 .byt 0

  ViewVC Help
Powered by ViewVC 1.1.26