Advertisement
hayesmaker

Untitled

Jun 4th, 2020
4,569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. IRQ: {
  2.     Setup: {
  3.         sei
  4.  
  5.         //disable CIA Interrupts
  6.         lda #$7f
  7.         sta $dc0d
  8.         sta $dd0d
  9.  
  10.         lda $dc0d                                          // read interupts to clear them
  11.         lda $dd0d
  12.  
  13.         // enable vbl interrupt
  14. //      lda VIC.INTERRUPT_CONTROL
  15. //      ora #%00000001
  16. //      sta VIC.INTERRUPT_CONTROL
  17.  
  18.         lda #1
  19.         sta $d01a
  20.  
  21.         //routine called when interrupt triggers
  22.         lda #<TitlesIRQHandler
  23.         ldx #>TitlesIRQHandler
  24.         sta $fffe //0314
  25.         stx $ffff //0315
  26.  
  27.         lda #$00
  28.         sta VIC.RASTER_Y
  29. //      lda VIC.SCREEN_CONTROL_1
  30. //      and #%01111111
  31. //      sta VIC.SCREEN_CONTROL_1
  32.        
  33.         asl VIC.INTERRUPT_STATUS
  34.         cli
  35.  
  36.         rts
  37.     }
  38.  
  39.     SwitchToGame: {
  40.         sei
  41.         //routine called when interrupt triggers
  42.         lda #<MainIRQ
  43.         ldx #>MainIRQ
  44.         sta $fffe //0314
  45.         stx $ffff //0315
  46.  
  47.         cli
  48.         rts
  49.     }
  50.  
  51.     TitlesIRQHandler2: {
  52.  
  53.         :StoreState()
  54.  
  55.         jsr TitleScreen.setGameModeSprite
  56.  
  57.  
  58.         lda #$00
  59.         sta $d012
  60.         lda #<TitlesIRQHandler
  61.         ldx #>TitlesIRQHandler
  62.         sta $fffe //0314
  63.         stx $ffff //0315
  64.         lsr VIC.INTERRUPT_STATUS
  65.         :RestoreState()
  66.        
  67.         rti
  68.     }
  69.  
  70.     TitlesIRQHandler: {
  71.        
  72.         :StoreState()
  73.  
  74.                     /*
  75.             ; Basics : IRQ
  76.         ; @L       Wait for Y-Pos
  77.         ;          write (new) Y-Position            
  78.         ;          write (new) Sprite-Pointer
  79.         ;          set some other registers according to the sprite
  80.         ;          wait 21+1 (Spriteheight+1) Rasterlines
  81.         ;          JMP @L
  82.                     */
  83.            
  84.             jsr TitleScreen.setTitleSprites
  85.             jsr TitleScreen.AnimateTitle
  86.  
  87.             jsr music_play
  88.             lda #$00
  89.             sta $d012
  90.             lda #<TitlesIRQHandler2
  91.             ldx #>TitlesIRQHandler2
  92.             sta $fffe //0314
  93.             stx $ffff //0315
  94.             lsr VIC.INTERRUPT_STATUS     // Acknowledge
  95.         :RestoreState()
  96.        
  97.         rti
  98.     }
  99.  
  100.     MainIRQ: {
  101.        
  102.         :StoreState()
  103.             inc Game.GameCounter
  104.             dec Game.GameTimerTick
  105.             dec Game.PushButtonTimer + 1
  106.             dec Game.FallGuyTimer + 1
  107.             dec Game.CementSpillTimer + 1
  108.             dec Game.ScoreBlinkingTimer + 1
  109.             dec Game.CratePourTimer1 + 1
  110.             dec Game.CratePourTimer2 + 1
  111.             //inc $d020
  112.             //dec $d021
  113.             lda #$01
  114.             sta Game.PerformFrameCodeFlag
  115.  
  116.             jsr music_play
  117.             lsr VIC.INTERRUPT_STATUS      // **********************8
  118.         :RestoreState()
  119.        
  120.         rti
  121.     }
  122. }
  123.  
  124. .macro StoreState() {
  125.     pha //A
  126.     txa
  127.     pha //X
  128.     tya
  129.     pha //Y
  130. }
  131.  
  132. .macro RestoreState() {
  133.     pla
  134.     tay
  135.     pla
  136.     tax
  137.     pla
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement