Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; IRQ pointer list from the header
- dc.l master_irq ; Level 1 IRQ
- dc.l master_irq ; Level 2 & 3 IRQ's
- dc.l master_irq ; Level 4 & 5 IRQ's
- dc.l master_irq ; PWM interupt
- dc.l master_irq ; Command interupt
- dc.l master_irq ; H Blank interupt
- dc.l master_irq ; V Blank interupt
- dc.l master_irq ; Reset Button
- dc.l master_irq ; (CUSTOM) Watchdog jump
- ; Then the actual IRQ pointers:
- dc.l m_irq_bad,m_irq_bad
- dc.l m_irq_bad,m_irq_bad
- dc.l m_irq_bad,m_irq_custom ; <-- irq_custom
- dc.l m_irq_pwm,m_irq_pwm
- dc.l m_irq_cmd,m_irq_cmd
- dc.l m_irq_h,m_irq_h
- dc.l m_irq_v,m_irq_v
- dc.l m_irq_vres,m_irq_vres
- ; Entry point (works for both Master and Slave)
- mov #_FRT,r1 ; FreeRunTimer stuff
- mov #0,r0
- mov.b r0,@(0,r1)
- mov #$FFFFFFE2,r0
- mov.b r0,@(7,r1)
- mov #0,r0
- mov.b r0,@(4,r1)
- mov #1,r0
- mov.b r0,@(5,r1)
- mov #0,r0
- mov.b r0,@(6,r1)
- mov #1,r0
- mov.b r0,@(1,r1)
- mov #0,r0
- mov.b r0,@(3,r1)
- mov.b r0,@(2,r1)
- mov.l #$FFFFFEE2,r0 ; Watchdog: Set interrupt priority bits (IPRA)
- mov #%0101<<4,r1
- mov.w r1,@r0
- mov.l #$FFFFFEE4,r0
- mov #$120/4,r1 ; Watchdog: Set jump pointer (VBR + this/4) (WITV)
- shll8 r1
- mov.w r1,@r0
- ;
- MAINLOOP:
- mov #MarsVideo_SetWatchdog,r0 ; Enable watchdog on the background
- jsr @r0
- nop
- ; Code that slices polygons to pieces goes
- ; here
- .wait_pz: mov.w @(marsGbl_PzListCntr,gbr),r0 ; Any pieces remaining on interrupt?
- cmp/eq #0,r0
- bf .wait_pz
- .wait_task: mov.w @(marsGbl_DrwTask,gbr),r0 ; Any draw task active?
- cmp/eq #0,r0
- bf .wait_task
- mov.l #$FFFFFE80,r1 ; Stop watchdog
- mov.w #$A518,r0
- mov.w r0,@r1
- mov #_vdpreg,r1
- .waitfb: mov.w @(vdpsts,r1),r0 ; Wait until linefills are done.
- tst #%10,r0
- bf .waitfb
- mov.b @(framectl,r1),r0 ; Frameswap request
- xor #1,r0 ; Watchdog will check for it later
- mov.b r0,@(framectl,r1)
- mov.b r0,@(marsGbl_CurrFb,gbr) ; Save new bit
- bra MAINLOOP
- nop
- ; ------------------------------------------------
- ; MarsVideo_SetWatchdog
- ;
- ; Initialize watchdog interrupt with
- ; default settings
- ; ------------------------------------------------
- ; gbr: somewhere in ram that stores temporal values
- ; Cach_ClrLines: LONG (dc.l) counter in RAM
- MarsVideo_SetWatchdog:
- mov #RAM_Mars_VdpDrwList,r0 ; Reset the piece-drawing pointer
- mov r0,@(marsGbl_PlyPzList_R,gbr) ; on both READ and WRITE pointers
- mov r0,@(marsGbl_PlyPzList_W,gbr)
- mov #0,r0 ; Reset polygon pieces counter
- mov.w r0,@(marsGbl_PzListCntr,gbr)
- mov #Cach_ClrLines,r1 ; Line counter for the framebuffer-clear routine
- mov #224,r0
- mov r0,@r1
- mov #8,r0 ; Set starting watchdog task to $08 (Clear framebuffer)
- mov.w r0,@(marsGbl_DrwTask,gbr)
- mov #_vdpreg,r1
- .wait_fb: mov.w @($A,r1),r0 ; Wait until framebuffer is unlocked
- tst #2,r0
- bf .wait_fb
- mov.w #$A1,r0 ; Pre-start SVDP fill line at address $A1
- mov.w r0,@(6,r1) ; $5F gets added on watchdog: $A1+$5F=$100
- mov #$FFFFFE80,r1
- mov.w #$5AFF,r0 ; Watchdog timer
- mov.w r0,@r1
- mov.w #$A538,r0 ; Enable this watchdog
- mov.w r0,@r1
- rts
- nop
- align 4
- ltorg
- ; ------------------------------------------------
- ; WATCHDOG interrupt
- ; ------------------------------------------------
- m_irq_custom:
- mov #_FRT,r1
- mov.b @(7,r1), r0
- xor #2,r0
- mov.b r0,@(7,r1)
- mov.w @(marsGbl_DrwTask,gbr),r0 ; Framebuffer clear request ($08)?
- cmp/eq #8,r0
- bf maindrw_tasks
- ; --------------------------------
- ; TASK $08 - Clear Framebuffer
- ; --------------------------------
- ; .task_08:
- mov r2,@-r15
- mov #_vdpreg,r1
- mov.b @(marsGbl_CurrFb,gbr),r0
- mov r0,r2
- .wait_frmswp: mov.b @(framectl,r1),r0
- cmp/eq r0,r2
- bf .on_clr
- .wait_fb: mov.w @($A,r1), r0 ; Framebuffer free?
- tst #2,r0
- bf .wait_fb
- mov.w @(6,r1),r0 ; SVDP-fill address
- add #$5F,r0 ; Preincrement
- mov.w r0,@(6,r1)
- mov.w #320/2,r0 ; SVDP-fill size (320 pixels)
- mov.w r0,@(4,r1)
- mov #0,r0 ; SVDP-fill pixel data and start filling
- mov.w r0,@(8,r1) ; After finishing, SVDP-address got updated
- mov.l #$FFFFFE80,r1
- mov.w #$A518,r0 ; OFF
- mov.w r0,@r1
- or #$20,r0 ; ON
- mov.w r0,@r1
- mov.w #$5A10,r0 ; Timer before next watchdog
- mov.w r0,@r1
- mov #Cach_ClrLines,r1 ; Decrement a line to progress
- mov @r1,r0
- dt r0
- bf/s .on_clr
- mov r0,@r1
- mov #1,r0 ; If finished: set task $01
- mov.w r0,@(marsGbl_DrwTask,gbr)
- .on_clr:
- mov @r15+,r2
- rts
- nop
- align 4
- ltorg
- ; --------------------------------
- ; Main drawing routine
- ; --------------------------------
- maindrw_tasks:
- shll2 r0
- mov #.list,r1
- mov @(r1,r0),r0
- jmp @r0
- nop
- align 4
- .list:
- dc.l drwtsk_01 ; (null entry)
- dc.l drwtsk_01 ; Main drawing routine
- dc.l drwtsk_02 ; Resume from solid color
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement