Advertisement
Guest User

StingRay startup code

a guest
Mar 18th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ***************************************************************************
  2. * v2.26       /                                                           *
  3. *       _____.__ _                                         .___.          *
  4. *      /    /_____________.  _________.__________.________ |   |________  *
  5. *  ___/____      /    ____|_/         |         /|        \|   ._      /  *
  6. *  \     \/      \    \     \    /    |    :___/Ż|    \    \   |/     /   *
  7. *   \_____________\___/_____/___/_____|____|     |____|\_____________/    *
  8. *     -========================/===========|______\================-      *
  9. *                                                                         *
  10. *   .---.----(*(             [S]carab Demo System           )*)---.---.   *
  11. *   `-./                                                           \.-'   *
  12. *              Non-System StartUp Code            *
  13. *              -----------------------            *
  14. *                                     *
  15. *       This is the short version, no FX-Lib required         *
  16. *                                     *
  17. *      Part of FX-Lib (c) 1998-2oo5 by StingRay/[S]carab^Scoopex      *
  18. *                                                                         *
  19. ***************************************************************************
  20.  
  21. INTENASET   = %1100000000100000
  22. ;          ab-------cdefg--
  23. ;   a: SET/CLR Bit
  24. ;   b: Master Bit
  25. ;   c: Blitter Int
  26. ;   d: Vert Blank Int
  27. ;   e: Copper Int
  28. ;   f: IO Ports/Timers
  29. ;   g: Software Int
  30.  
  31. DMASET      = %1000001111100000
  32. ;          a----bcdefghi--j
  33. ;   a: SET/CLR Bit
  34. ;   b: Blitter Priority
  35. ;   c: Enable DMA
  36. ;   d: Bit Plane DMA
  37. ;   e: Copper DMA
  38. ;   f: Blitter DMA
  39. ;   g: Sprite DMA
  40. ;   h: Disk DMA
  41. ;   i..j: Audio Channel 0-3
  42.  
  43. ;   PRINTT
  44. ;   PRINTT  "MINI STARTUP BY STINGRAY/[S]CARAB^SCOOPEX"
  45. ;   PRINTT  "             .oO LAST CHANGE: THU, 2o-AUG-2oo5 Oo."
  46. ;   PRINTT
  47.  
  48.  
  49. ***************************************************
  50. *** MACRO DEFINITION                ***
  51. ***************************************************
  52.  
  53. WAITBLIT    MACRO
  54.         tst.b   $02(a6)
  55. .\@     btst    #6,$02(a6)
  56.         bne.b   .\@
  57.         ENDM
  58.        
  59.  
  60. ***************************************************
  61. *** CLOSE DOWN SYSTEM - INIT PROGRAM        ***
  62. ***************************************************
  63.  
  64. START   movem.l d0-a6,-(a7)
  65.     move.l  $4.w,a6
  66.     lea .VARS_HW(pc),a5
  67.     lea .GFXname(pc),a1
  68.     moveq   #0,d0
  69.     jsr -552(a6)            ; OpenLibrary()
  70.     move.l  d0,.GFXbase-.VARS_HW(a5)
  71.     beq.b   .END
  72.     move.l  d0,a6
  73.     move.l  34(a6),.OldView-.VARS_HW(a5)
  74.     sub.l   a1,a1
  75.     bsr.w   .DoView
  76.     move.l  $26(a6),.OldCop1-.VARS_HW(a5)   ; Store old CL 1
  77.     move.l  $32(a6),.OldCop2-.VARS_HW(a5)   ; Store old CL 2
  78.     bsr .GetVBR
  79.     move.l  d0,.VBRptr-.VARS_HW(a5)
  80.     move.l  d0,a0
  81.  
  82.     *** Store Custom Regs   ***
  83.  
  84.     lea $dff000,a6          ; base address
  85.     move.w  $10(a6),.ADK-.VARS_HW(a5)   ; Store old ADKCON
  86.     move.w  $1C(a6),.INTENA-.VARS_HW(a5)    ; Store old INTENA
  87.     move.w  $02(a6),.DMA-.VARS_HW(a5)   ; Store old DMA
  88.     move.w  #$7FFF,d0
  89.     bsr WaitRaster
  90.     move.w  d0,$9A(a6)          ; Disable Interrupts
  91.     move.w  d0,$96(a6)          ; Clear all DMA channels
  92.     move.w  d0,$9C(a6)          ; Clear all INT requests
  93.  
  94.     move.l  $6c(a0),.OldVBI-.VARS_HW(a5)
  95.     lea .NewVBI(pc),a1
  96.     move.l  a1,$6c(a0)
  97.  
  98.     move.w  #INTENASET!$C000,$9A(a6)    ; set Interrupts+ BIT 14/15
  99.     move.w  #DMASET!$8200,$96(a6)       ; set DMA   + BIT 09/15
  100.     bsr MAIN
  101.  
  102.    
  103. ***************************************************
  104. *** Restore Sytem Parameter etc.        ***
  105. ***************************************************
  106.  
  107. .END    lea .VARS_HW(pc),a5
  108.     lea $dff000,a6
  109.     clr.l   VBIptr-.VARS_HW(a5)
  110.  
  111.     move.w  #$8000,d0
  112.     or.w    d0,.INTENA-.VARS_HW(a5)     ; SET/CLR-Bit to 1
  113.     or.w    d0,.DMA-.VARS_HW(a5)        ; SET/CLR-Bit to 1
  114.     or.w    d0,.ADK-.VARS_HW(a5)        ; SET/CLR-Bit to 1
  115.     subq.w  #1,d0
  116.     bsr WaitRaster
  117.     move.w  d0,$9A(a6)          ; Clear all INT bits
  118.     move.w  d0,$96(a6)          ; Clear all DMA channels
  119.     move.w  d0,$9C(a6)          ; Clear all INT requests
  120.  
  121.     move.l  .VBRptr(pc),a0
  122.     move.l  .OldVBI(pc),$6c(a0)
  123.  
  124.     move.l  .OldCop1(pc),$80(a6)        ; Restore old CL 1
  125.     move.l  .OldCop2(pc),$84(a6)        ; Restore old CL 2
  126.     move.w  d0,$88(a6)          ; start copper1
  127.     move.w  .INTENA(pc),$9A(a6)     ; Restore INTENA
  128.     move.w  .DMA(pc),$96(a6)        ; Restore DMAcon
  129.     move.w  .ADK(pc),$9E(a6)        ; Restore ADKcon
  130.  
  131.     move.l  .GFXbase(pc),a6
  132.     move.l  .OldView(pc),a1         ; restore old viewport
  133.     bsr.b   .DoView
  134.  
  135.     move.l  a6,a1
  136.     move.l  $4.w,a6
  137.     jsr -414(a6)            ; Closelibrary()
  138.     movem.l (a7)+,d0-a6
  139.     moveq   #0,d0
  140.     rts
  141.  
  142.  
  143. .DoView jsr -222(a6)            ; LoadView()
  144.     jsr -270(a6)            ; WaitTOF()
  145.     jmp -270(a6)
  146.  
  147.  
  148. *******************************************
  149. *** Get Address of the VBR      ***
  150. *******************************************
  151.  
  152. .GetVBR move.l  a5,-(a7)
  153.     moveq   #0,d0           ; default at $0
  154.     move.l  $4.w,a6
  155.     btst    #0,296+1(a6)        ; 68010+?
  156.     beq.b   .is68k          ; nope.
  157.     lea .getit(pc),a5
  158.     jsr -30(a6)         ; SuperVisor()
  159. .is68k  move.l  (a7)+,a5
  160.     rts
  161.  
  162. .getit  movec   vbr,d0
  163.     rte             ; back to user state code
  164.    
  165.  
  166. *******************************************
  167. *** VERTICAL BLANK (VBI)        ***
  168. *******************************************
  169.  
  170. .NewVBI movem.l d0-a6,-(a7)
  171.     move.l  VBIptr(pc),d0
  172.     beq.b   .noVBI
  173.     move.l  d0,a0
  174.     jsr (a0)
  175. .noVBI  lea $dff09c,a6
  176.     moveq   #$20,d0
  177.     move.w  d0,(a6)
  178.     move.w  d0,(a6)         ; twice to avoid a4k hw bug
  179.     movem.l (a7)+,d0-a6
  180.     rte
  181.  
  182. *******************************************
  183. *** DATA AREA       FAST        ***
  184. *******************************************
  185.  
  186. .VARS_HW
  187. .GFXname    dc.b    'graphics.library',0,0
  188. .GFXbase    dc.l    0
  189. .OldView    dc.l    0
  190. .OldCop1    dc.l    0
  191. .OldCop2    dc.l    0
  192. .VBRptr     dc.l    0
  193. .OldVBI     dc.l    0
  194. .ADK        dc.w    0
  195. .INTENA     dc.w    0
  196. .DMA        dc.w    0
  197.  
  198. VBIptr      dc.l    0
  199.  
  200. WaitRaster
  201.     move.l  d0,-(a7)
  202. .loop   move.l  $dff004,d0
  203.     and.l   #$1ff00,d0
  204.     cmp.l   #303<<8,d0
  205.     bne.b   .loop
  206.     move.l  (a7)+,d0
  207.     rts
  208.  
  209. WaitRasterEnd
  210.     move.l  d0,-(a7)
  211. .loop   move.l  $dff004,d0
  212.     and.l   #$1ff00,d0
  213.     cmp.l   #303<<8,d0
  214.     beq.b   .loop
  215.     move.l  (a7)+,d0
  216.     rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement