home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / programs / emulaton / utilities / magicasm / pce_code / asm / init < prev    next >
Encoding:
Text File  |  1998-04-14  |  1.9 KB  |  112 lines

  1. ; INIT.C
  2.  
  3.     .include "library.inc"
  4.     .include "macro.inc"
  5.     .include "equ.inc"
  6.     .nomlist
  7.     .list
  8.  
  9. ; variables
  10.  
  11.     .rsset $2000
  12. vsync:    .rs   1        ; VBL counter, increased 60 times per seconde
  13.  
  14.     ;...
  15.  
  16.  
  17. ;±±±[ STARTUP CODE ]±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
  18.  
  19. ; initialize the interrupt vectors
  20.  
  21.     .bank 0
  22.     .org  $FFF6
  23.  
  24.     .dw null_int    ; IRQ2,  used by the BRK instruction
  25.     .dw vdc_int    ; IRQ1,  interrupt from the VDC
  26.     .dw null_int    ; TIMER, not used in this demo
  27.     .dw null_int    ; NMI,   never used
  28.     .dw reset_int    ; RESET, the most important one :)
  29.  
  30.     .org $E000
  31.  
  32. null_int:
  33.     rti
  34.  
  35. ; reset_int:
  36. ; ---------
  37. ; it's here that everything starts!
  38.  
  39. reset_int:
  40.     sei            ; disable interrupts 
  41.     csh            ; select the 7.16 MHz clock
  42.     cld            ; clear the decimal flag 
  43.     ldx   #$FF        ; initialize the stack
  44.     txs 
  45.     lda   #$FF        ; map the first page to the I/O bank
  46.     tam   #0
  47.     lda   #$F8        ; and the second to the RAM bank
  48.     tam   #1
  49.     stz   $2000        ; clear all the RAM
  50.     tii   $2000,$2001,$1FFF
  51.     jsr   init_vdc        ; initialize the video controller
  52.     jsr   init_psg        ; and the sound generator
  53.     stz   $C01        ; stop the timer
  54.     stz   $1402        ; unmask and enable interrupts
  55.     cli
  56.  
  57.  
  58. ;±±±[ USER PROGRAM ]±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
  59.  
  60.     ;...
  61.  
  62.  
  63. ;±±±[ INTERRUPT CODE ]±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
  64.  
  65. ; vdc_int:
  66. ; -------
  67. ; interrupt for the VDC
  68.  
  69. vdc_int:
  70.     pha
  71.     phx
  72.     phy
  73.     lda   $0000        ; load the status register
  74.  
  75. ; vertical blanking interrupt code
  76.  
  77. .vbl:    bit   #$20        ; vbl?
  78.     beq   .hbl
  79.  
  80.     ;...            ; user vbl code
  81.  
  82.     inc   <vsync        ; update the vsync flag
  83.     jmp   .exit
  84.  
  85. ; scanline interrupt code
  86.  
  87. .hbl:    bit   #$04        ; scanline?
  88.     beq   .exit
  89.  
  90.     ;...            ; user hbl code
  91.  
  92. ; exit the interrupt handler
  93.  
  94. .exit:    lda   <_vreg
  95.     sta   $0000
  96.     ply
  97.     plx
  98.     pla
  99.     rti
  100.  
  101.  
  102. ;±±[ LIBRARY ]±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
  103.  
  104.     .include "library.asm"
  105.  
  106. ;±±±[ USER DATA ]±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
  107.  
  108.  
  109.  
  110.  
  111.  
  112.