Advertisement
GenesisFan64

Untitled

May 25th, 2021
2,828
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; IRQ pointer list from the header
  2.         dc.l master_irq         ; Level 1 IRQ
  3.         dc.l master_irq         ; Level 2 & 3 IRQ's
  4.         dc.l master_irq         ; Level 4 & 5 IRQ's
  5.         dc.l master_irq         ; PWM interupt
  6.         dc.l master_irq         ; Command interupt
  7.         dc.l master_irq         ; H Blank interupt
  8.         dc.l master_irq         ; V Blank interupt
  9.         dc.l master_irq         ; Reset Button
  10.         dc.l master_irq         ; (CUSTOM) Watchdog jump
  11.        
  12.  
  13. ; Then the actual IRQ pointers:
  14.         dc.l m_irq_bad,m_irq_bad
  15.         dc.l m_irq_bad,m_irq_bad
  16.         dc.l m_irq_bad,m_irq_custom           ; <-- irq_custom
  17.         dc.l m_irq_pwm,m_irq_pwm
  18.         dc.l m_irq_cmd,m_irq_cmd
  19.         dc.l m_irq_h,m_irq_h
  20.         dc.l m_irq_v,m_irq_v
  21.         dc.l m_irq_vres,m_irq_vres
  22.        
  23.  
  24. ; Entry point (works for both Master and Slave)
  25.         mov #_FRT,r1            ; FreeRunTimer stuff
  26.         mov     #0,r0
  27.         mov.b   r0,@(0,r1)
  28.         mov     #$FFFFFFE2,r0
  29.         mov.b   r0,@(7,r1)
  30.         mov     #0,r0
  31.         mov.b   r0,@(4,r1)
  32.         mov     #1,r0
  33.         mov.b   r0,@(5,r1)
  34.         mov     #0,r0
  35.         mov.b   r0,@(6,r1)
  36.         mov     #1,r0
  37.         mov.b   r0,@(1,r1)
  38.         mov     #0,r0
  39.         mov.b   r0,@(3,r1)
  40.         mov.b   r0,@(2,r1)
  41.         mov.l   #$FFFFFEE2,r0           ; Watchdog: Set interrupt priority bits (IPRA)
  42.         mov     #%0101<<4,r1
  43.         mov.w   r1,@r0
  44.         mov.l   #$FFFFFEE4,r0
  45.         mov     #$120/4,r1          ; Watchdog: Set jump pointer (VBR + this/4) (WITV)
  46.         shll8   r1
  47.         mov.w   r1,@r0
  48.        
  49. ;
  50. MAINLOOP:
  51.         mov #MarsVideo_SetWatchdog,r0       ; Enable watchdog on the background
  52.         jsr @r0
  53.         nop
  54.    
  55.     ; Code that slices polygons to pieces goes
  56.     ; here
  57.  
  58. .wait_pz:   mov.w   @(marsGbl_PzListCntr,gbr),r0    ; Any pieces remaining on interrupt?
  59.         cmp/eq  #0,r0
  60.         bf  .wait_pz
  61. .wait_task: mov.w   @(marsGbl_DrwTask,gbr),r0   ; Any draw task active?
  62.         cmp/eq  #0,r0
  63.         bf  .wait_task
  64.        
  65.         mov.l   #$FFFFFE80,r1           ; Stop watchdog
  66.         mov.w   #$A518,r0
  67.         mov.w   r0,@r1
  68.         mov #_vdpreg,r1
  69. .waitfb:    mov.w   @(vdpsts,r1),r0         ; Wait until linefills are done.
  70.         tst #%10,r0
  71.         bf  .waitfb
  72.         mov.b   @(framectl,r1),r0       ; Frameswap request
  73.         xor #1,r0               ; Watchdog will check for it later
  74.         mov.b   r0,@(framectl,r1)
  75.         mov.b   r0,@(marsGbl_CurrFb,gbr)    ; Save new bit
  76.  
  77.         bra     MAINLOOP
  78.         nop
  79.  
  80. ; ------------------------------------------------
  81. ; MarsVideo_SetWatchdog
  82. ;
  83. ; Initialize watchdog interrupt with
  84. ; default settings
  85. ; ------------------------------------------------
  86.  
  87. ; gbr: somewhere in ram that stores temporal values
  88. ; Cach_ClrLines: LONG (dc.l) counter in RAM
  89.  
  90. MarsVideo_SetWatchdog:
  91.         mov #RAM_Mars_VdpDrwList,r0     ; Reset the piece-drawing pointer
  92.         mov r0,@(marsGbl_PlyPzList_R,gbr)   ; on both READ and WRITE pointers
  93.         mov r0,@(marsGbl_PlyPzList_W,gbr)
  94.         mov #0,r0               ; Reset polygon pieces counter
  95.         mov.w   r0,@(marsGbl_PzListCntr,gbr)
  96.         mov #Cach_ClrLines,r1       ; Line counter for the framebuffer-clear routine
  97.         mov #224,r0
  98.         mov r0,@r1
  99.         mov #8,r0               ; Set starting watchdog task to $08 (Clear framebuffer)
  100.         mov.w   r0,@(marsGbl_DrwTask,gbr)
  101.         mov #_vdpreg,r1
  102. .wait_fb:   mov.w   @($A,r1),r0         ; Wait until framebuffer is unlocked
  103.         tst #2,r0
  104.         bf  .wait_fb
  105.         mov.w   #$A1,r0             ; Pre-start SVDP fill line at address $A1
  106.         mov.w   r0,@(6,r1)          ; $5F gets added on watchdog: $A1+$5F=$100
  107.         mov #$FFFFFE80,r1
  108.         mov.w   #$5AFF,r0           ; Watchdog timer
  109.         mov.w   r0,@r1
  110.         mov.w   #$A538,r0           ; Enable this watchdog
  111.         mov.w   r0,@r1
  112.         rts
  113.         nop
  114.         align 4
  115.         ltorg
  116.        
  117.        
  118. ; ------------------------------------------------
  119. ; WATCHDOG interrupt
  120. ; ------------------------------------------------
  121.  
  122. m_irq_custom:
  123.         mov #_FRT,r1
  124.         mov.b   @(7,r1), r0
  125.         xor #2,r0
  126.         mov.b   r0,@(7,r1)
  127.         mov.w   @(marsGbl_DrwTask,gbr),r0   ; Framebuffer clear request ($08)?
  128.         cmp/eq  #8,r0
  129.         bf  maindrw_tasks
  130.  
  131. ; --------------------------------
  132. ; TASK $08 - Clear Framebuffer
  133. ; --------------------------------
  134.  
  135. ; .task_08:
  136.         mov r2,@-r15
  137.         mov #_vdpreg,r1
  138.         mov.b   @(marsGbl_CurrFb,gbr),r0
  139.         mov r0,r2
  140. .wait_frmswp:   mov.b   @(framectl,r1),r0
  141.         cmp/eq  r0,r2
  142.         bf  .on_clr
  143. .wait_fb:   mov.w   @($A,r1), r0        ; Framebuffer free?
  144.         tst     #2,r0
  145.         bf      .wait_fb
  146.         mov.w   @(6,r1),r0      ; SVDP-fill address
  147.         add     #$5F,r0         ; Preincrement
  148.         mov.w   r0,@(6,r1)
  149.         mov.w   #320/2,r0       ; SVDP-fill size (320 pixels)
  150.         mov.w   r0,@(4,r1)
  151.         mov     #0,r0           ; SVDP-fill pixel data and start filling
  152.         mov.w   r0,@(8,r1)      ; After finishing, SVDP-address got updated
  153.         mov.l   #$FFFFFE80,r1
  154.         mov.w   #$A518,r0       ; OFF
  155.         mov.w   r0,@r1
  156.         or      #$20,r0         ; ON
  157.         mov.w   r0,@r1
  158.         mov.w   #$5A10,r0       ; Timer before next watchdog
  159.         mov.w   r0,@r1
  160.         mov #Cach_ClrLines,r1   ; Decrement a line to progress
  161.         mov @r1,r0
  162.         dt  r0
  163.         bf/s    .on_clr
  164.         mov r0,@r1
  165.         mov #1,r0           ; If finished: set task $01
  166.         mov.w   r0,@(marsGbl_DrwTask,gbr)
  167. .on_clr:
  168.         mov @r15+,r2
  169.         rts
  170.         nop
  171.         align 4
  172.         ltorg
  173.  
  174. ; --------------------------------
  175. ; Main drawing routine
  176. ; --------------------------------
  177.  
  178. maindrw_tasks:
  179.         shll2   r0
  180.         mov #.list,r1
  181.         mov @(r1,r0),r0
  182.         jmp @r0
  183.         nop
  184.         align 4
  185. .list:
  186.         dc.l drwtsk_01      ; (null entry)
  187.         dc.l drwtsk_01      ; Main drawing routine
  188.         dc.l drwtsk_02      ; Resume from solid color
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement