/[projet1]/public/oric/demos/SlideShowDemo/code/loader.asm
Defence Force logotype

Diff of /public/oric/demos/SlideShowDemo/code/loader.asm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1015 by dbug, Thu Dec 12 20:53:08 2013 UTC revision 1025 by dbug, Sun Dec 15 11:47:51 2013 UTC
# Line 3  Line 3 
3    
4  #define COLOR(color) pha:lda #16+(color&7):sta $bb80+40*27:pla  #define COLOR(color) pha:lda #16+(color&7):sta $bb80+40*27:pla
5  #define STOP(color) pha:lda #16+(color&7):sta $bb80+40*27:jmp *:pla  #define STOP(color) pha:lda #16+(color&7):sta $bb80+40*27:jmp *:pla
 #define INSTALL_HANDLER(address,callback) lda #$4c:sta address:lda #<callback:sta address+1:lda #>callback:sta address+2        ; jmp=$4c  
6    
7          .zero          .zero
8                    
# Line 18  irq_save_a                     .dsb 1      ; To preserve t Line 17  irq_save_a                     .dsb 1      ; To preserve t
17    
18          .text          .text
19    
 ; FFF7-FFF9 - Load File (JMP/LOW/HIGH) - file to load in X register  
 ; FFFA-FFFB - NMI Vector (Usually points to $0247)  
 ; FFFC-FFFD - RESET Vector (Usually points to $F88F)  
 ; FFFE-FFFF - IRQ Vector (Normally points to $0244)  
 ;  
   
20          *=location_loader          *=location_loader
21    
22    
23  Initialize  Initialize
24          jmp StartUp          jmp StartUp
25    
26    #define LOADER
27    
28  ; This file is generated by the floppy builder  ; This file is generated by the floppy builder
29  #include "floppy_description.h"  #include "floppy_description.h"
30    
31  ; Some local variables we need  ; Some local variables we need
32    
33  StartUp  StartUp
34          ; Set-up a safe irq that does nothing (just contains a RTI instruction)          ;jmp StartUp
         ; This helps avoiding crashes if the user presses RESET for example :)  
         lda #<IrqDoNothing    ; NMI vector  
         sta $fffa  
         sta $fffc  
         lda #>IrqDoNothing        ; RESET vector  
         sta $fffb  
         sta $fffd  
   
         ; Install our API (top of memory function calls)  
     INSTALL_HANDLER($FFF7,LoadData)  
   
35          jsr SetUpIrqHandlers              jsr SetUpIrqHandlers    
36          jsr SoftHiresWithCopyCharset          jsr SoftHiresWithCopyCharset
37    
   
38          ;ldx #LOADER_FIRST_PICTURE          ;ldx #LOADER_FIRST_PICTURE
39          ;jsr LoadData          ;jsr LoadData
40          ;STOP(1)          ;STOP(1)
# Line 67  StartUp Line 50  StartUp
50          ; End of demo - Just stay there doing nothing          ; End of demo - Just stay there doing nothing
51          ;          ;
52          sei          sei
53  .(        loop_forever_demo_finished
54  loop          jmp loop_forever_demo_finished
         jmp loop  
 .)  
55                    
56                    
57  ClearZeroPage  ClearZeroPage
# Line 87  loop Line 68  loop
68                    
69  SetUpIrqHandlers  SetUpIrqHandlers
70          sei          sei
71                            
         ldy #<IrqHandler  
         lda #>IrqHandler  
     sty $fffe  
         sta $ffff  
           
72          ; Make sure the microdisc IRQ is disabled                ; Make sure the microdisc IRQ is disabled      
73          jsr WaitCompletion          jsr WaitCompletion
74                    
# Line 133  from_brk Line 109  from_brk
109          jmp from_brk          jmp from_brk
110    
111    
112                    
113                    
114  HexData .byt "0123456789ABCDEF"  ; X=File index
115            ; A=Low
116            ; Y=High
117    SetLoadAddress
118            sta FileLoadAdressLow,x
119            tya
120            sta FileLoadAdressHigh,x
121            rts
122    
123    
124  ; X=File index  ; X=File index
125  LoadData  LoadData
126          sei          sei
# Line 176  first_side Line 160  first_side
160          lda FileStartSector,x          lda FileStartSector,x
161          sta current_sector          sta current_sector
162    
163        ; FileSizeLow/FileSizeHigh
164          ; Number of sectors to load          ; Number of sectors to load
165          lda FileSectorCount,x            lda FileSizeHigh,x      
166          sta sectors_to_go          sta sectors_to_go
167            lda FileSizeLow,x
168            beq skip
169            inc sectors_to_go
170    skip    
171                    
172          ;          ;
173          ; Loop to read all the sectors            ; Loop to read all the sectors  
# Line 301  r2_wait_completion Line 290  r2_wait_completion
290          rts          rts
291    
292  #ifdef LOADER_SHOW_DEBUGINFO      #ifdef LOADER_SHOW_DEBUGINFO    
293    HexData .byt "0123456789ABCDEF"
294    
295  DisplayPosition  DisplayPosition
296          .(          .(
297          lda current_side                  lda current_side        
# Line 409  hm_02 Line 400  hm_02
400          bne hm_04          bne hm_04
401          rts          rts
402    
403    _EndLoaderCode
404    
405    ;
406    ; This is free memory that can be used, when it reaches zero then the loader start address should be changed
407    ;
408    
409            .dsb $FFF4 - _EndLoaderCode
410    
411    _Vectors
412    
413    #if ( _Vectors <> $FFF4 )
414    #error - Vector address is incorrect, loader will crash
415    #else
416    
417    ;
418    ; Here are the functions that the user can call from his own application
419    ;
420    _ApiSetLoadAddress      .byt $4c,<SetLoadAddress,>SetLoadAddress        ; $FFF4
421    _ApiSetLoadData         .byt $4c,<LoadData,>LoadData                            ; $FFF7
422    
423    ;
424    ; These three HAVE to be at these precise adresses, they map to hardware registers
425    ;
426    _VectorNMI                      .word IrqDoNothing              ; FFFA-FFFB - NMI Vector (Usually points to $0247)
427    _VectorReset            .word IrqDoNothing              ; FFFC-FFFD - RESET Vector (Usually points to $F88F)
428    _VectorIRQ                      .word IrqHandler                ; FFFE-FFFF - IRQ Vector (Normally points to $0244)
429    
430    #echo Remaining space in the loader code:
431    #print (_Vectors - _EndLoaderCode)
432    
433    #endif
434    
435    ; End of the loader - Nothing should come after because it's out of the addressable memory range :)
436    

Legend:
Removed from v.1015  
changed lines
  Added in v.1025

  ViewVC Help
Powered by ViewVC 1.1.26