Advertisement
hayesmaker

Untitled

Jun 4th, 2020
4,355
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.     TitlesIRQHandler: {
  52.        
  53.         :StoreState()
  54.  
  55.             lda #$00
  56.             sta $d012
  57.             /*
  58.     ; Basics : IRQ
  59. ; @L       Wait for Y-Pos
  60. ;          write (new) Y-Position            
  61. ;          write (new) Sprite-Pointer
  62. ;          set some other registers according to the sprite
  63. ;          wait 21+1 (Spriteheight+1) Rasterlines
  64. ;          JMP @L
  65.             */
  66.             lda $d012
  67.             cmp #100
  68.             bne !skip+
  69.                 inc $d020
  70.                 lda #TitleScreen.FrameA
  71.                 clc
  72.                 adc TitleScreen.GameMode
  73.                 sta TitleScreen.sprite_pointers + 2
  74.  
  75.             !skip:
  76.            
  77.             jsr music_play
  78.             lsr VIC.INTERRUPT_STATUS     // ********************
  79.         :RestoreState()
  80.        
  81.         rti
  82.     }
  83.  
  84.     MainIRQ: {
  85.        
  86.         :StoreState()
  87.             inc Game.GameCounter
  88.             dec Game.GameTimerTick
  89.             dec Game.PushButtonTimer + 1
  90.             dec Game.FallGuyTimer + 1
  91.             dec Game.CementSpillTimer + 1
  92.             dec Game.ScoreBlinkingTimer + 1
  93.             dec Game.CratePourTimer1 + 1
  94.             dec Game.CratePourTimer2 + 1
  95.             //inc $d020
  96.             //dec $d021
  97.             lda #$01
  98.             sta Game.PerformFrameCodeFlag
  99.  
  100.             jsr music_play
  101.             lsr VIC.INTERRUPT_STATUS      // **********************8
  102.         :RestoreState()
  103.        
  104.         rti
  105.     }
  106. }
  107.  
  108. .macro StoreState() {
  109.     pha //A
  110.     txa
  111.     pha //X
  112.     tya
  113.     pha //Y
  114. }
  115.  
  116. .macro RestoreState() {
  117.     pla
  118.     tay
  119.     pla
  120.     tax
  121.     pla
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement