home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI05.ARJ / ictari.05 / ASSEMBLY / BORDERS / BORDERS.S < prev   
Text File  |  1989-04-06  |  13KB  |  298 lines

  1. ;**************************************************************************
  2. ;                    DEATH TO THE UPPER AND LOWER BORDERS                 *
  3. ;                                                                         *
  4. ;                         © 1993 DIAMOND SOFTWARE                         *
  5. ;                                                                         *
  6. ;                 CODED BY STEVEN JORDAN AND ANDREW MARTIN                *
  7. ;                                                                         *
  8. ; A word of warning - do NOT move the mouse when you press space to quit  *
  9. ; because your ST is likely to crash because the Video Shifter chip gets  *
  10. ; a current surge and blows. Your RAM may also get damaged, so be         *
  11. ; carefull. Only kidding, it is imposible to damage any piece of hardware *
  12. ; using software.                             *
  13. ;                                 *
  14. ;**************************************************************************
  15.  
  16. start
  17.  
  18.     bsr    set_super    ;set supervisor mode
  19.     bsr    save_res    ;check for high res
  20.           bsr       setscreen ;set up the screens for drawing    
  21.     bsr    put_graphics    ;err, what it says!
  22.     bsr       mfp_on     ;turn on all interupts
  23.     bsr    palette     ;set the palette
  24.  
  25. loop_01
  26.     cmp.b    #57,$fffffc02
  27.     bne    loop_01
  28.  
  29.     bra    exit
  30.  
  31. ****************************************************************************
  32.  
  33. exit     
  34.     bsr       mfp_off        ;turn off all interupts
  35.           bsr       resetoldpal        ;reset the old palette
  36.  
  37.           move.w    oldres,-(sp)        ;Set old resolution
  38.           move.l    oldscr,-(sp)        ;old screen address
  39.           move.l    oldscr,-(sp)        ;old screen address
  40.           move.w    #5,-(sp)      ;call setscreen
  41.           trap      #14           ;call xbois
  42.           adda.l    #12,sp        ;adjust the stack
  43.  
  44.           move.l    oldsp,-(sp)         ;reset old stack address
  45.           move.w    #32,-(sp)     ;set in supervisor mode 
  46.           trap      #1            ;call gamdos
  47.           addq.l    #6,sp         ;adjust the stack
  48.  
  49.           clr.l     -(sp)         ;PTERM (Quit)
  50.           trap      #1            ;call gemdos
  51.  
  52. ;**************************************************************************
  53. ; SET SUPERVISOR MODE                                                *
  54. ;**************************************************************************
  55.  
  56. set_super
  57.  
  58.     clr.l     -(sp)        ;get old
  59.           move.w    #32,-(sp)        ;call supervisor
  60.           trap      #1        ;call gemdos
  61.           addq.l    #6,sp        ;adjust the stack
  62.           move.l    d0,oldsp        ;save old supervisor
  63.  
  64.     rts
  65.  
  66. ;**************************************************************************
  67. ; SAVE THE PALETTE                             *                                                       *
  68. ;**************************************************************************
  69.  
  70. palette 
  71.     movem.l   $ffff8240,d0-d7     ;get entire palette
  72.           movem.l   d0-d7,savepal       ;save palette
  73.  
  74.     movem.l    pic1+2,d0-d7    ;get our new palette
  75.     movem.l    d0-d7,$ffff8240    ;set it
  76.  
  77.     rts
  78.  
  79. ;**************************************************************************
  80. ; SAVE THE SCREEN AND CHANGE TO LOW REZ IF WE CAN.            *                                                       *
  81. ;**************************************************************************
  82.  
  83. save_res    move.w    #4,-(sp)        ;get screen        
  84.           trap      #14        ;call XBOIS
  85.           addq.l    #2,sp        ;adjust the stack
  86.  
  87.           cmp.b     #2,d0        ;is it high res        
  88.           bne       pass        ;no, don't quit        
  89.  
  90.           clr.l     -(sp)        ;quit        
  91.           trap      #1        ;call GEMDOS (Bye)
  92.  
  93. pass      move.w    d0,oldres        ;get old res    
  94.  
  95.           rts                         
  96.  
  97. ;**************************************************************************
  98. ; RESET OLD PALETTE                                                       *
  99. ;**************************************************************************
  100.  
  101. resetoldpal  
  102.  
  103.     movem.l    savepal,d0-d7    ;get our old palette
  104.     movem.l    d0-d7,$ffff8240    ;set it
  105.  
  106.           rts       
  107.  
  108. ;**************************************************************************
  109. ; SET LOW RESOLUTION AND PHYSICAL SCREEN ADDRESS                          *
  110. ;**************************************************************************
  111.  
  112. setscreen:          
  113.           move.w    #3,-(sp)      ;get screen address
  114.           trap      #14           ;xbios call
  115.           addq.l    #2,sp         ;tidy stack
  116.           move.l    d0,oldscr     ;save old screen
  117.  
  118.           move.l    #log,d0       ;move our logical screen
  119.           addi.l    #256,d0       ;add 256 
  120.           andi.l    #$ffffff00,d0       ;put it on a 256 byte boundary
  121.           move.l    d0,logscreen        ;get our new logical screen
  122.           move.l    d0,screen     ;also put it on our drawing screen
  123.  
  124.           move.l    #phy,d0       ;move our physical screen 
  125.           addi.l    #256,d0       ;add 256 
  126.           andi.l    #$ffffff00,d0       ;put it on a 256 byte boundary
  127.           move.l    d0,physcreen        ;get new physical screen
  128.  
  129.           move.w    #0,-(sp)      ;put us in low resolution
  130.           move.l    physcreen,-(sp)     ;physical screen address
  131.           move.l    physcreen,-(sp)     ;logical screen address
  132.           move.w    #5,-(sp)      ;now set the screen
  133.           trap      #14           ;call xbois
  134.           adda.l    #12,sp        ;adjust the stack
  135.  
  136.           rts       
  137.  
  138. ;**************************************************************************
  139. ; INSTALL INTERUPTS                                                       *
  140. ;**************************************************************************
  141.  
  142. mfp_on:   lea       mfpstore,a0         ;where to store the mfp registers
  143.           move.b    $fffffa07,(a0)+     ;interupt enable a
  144.           move.b    $fffffa09,(a0)+     ;interupt enable b
  145.           move.b    $fffffa13,(a0)+     ;interupt mask a
  146.           move.b    $fffffa15,(a0)+     ;interupt mask b
  147.           move.b    $fffffa19,(a0)+     ;timer a control
  148.           move.b    $fffffa1b,(a0)+     ;timer b control
  149.           move.b    $fffffa1f,(a0)+     ;timer a data
  150.           move.b    $fffffa21,(a0)+     ;timer b data
  151.           move.l    $68,(a0)+     ;horizontal blank
  152.           move.l    $70,(a0)+     ;vertical blank
  153.           move.l    $120,(a0)+          ;timer b interupt
  154.           move.l    $134,(a0)+          ;timer a interupt
  155.           clr.b     $fffffa1b     ;empty timer b data
  156.           clr.b     $fffffa19     ;empty timer a data
  157.           move.b    #$21,$fffffa07      ;disable interupt a
  158.           clr.b     $fffffa09     ;disable interupt b
  159.           move.b    #$21,$fffffa13      ;set mask a
  160.           clr.b     $fffffa15     ;set mask b
  161.           bclr      #3,$fffffa17        ;reset vector base
  162.           move.l    #topbord,$134       ;put top border rout in timer a
  163.           move.l    #bottom,$120        ;put bottom border rout in timer b
  164.           move.l    #vblank,$70         ;new vertical blank rout
  165.           move.w    #$2300,sr     ;all systems go 
  166.  
  167.           rts               ;return
  168.  
  169. ;**************************************************************************
  170. ; RESET INTERUPTS                                                         *
  171. ;**************************************************************************
  172.  
  173. mfp_off:  move.w    #$2700,sr     ;stop all interupts
  174.           lea       mfpstore,a0         ;address of saved registers
  175.           move.b    (a0)+,$fffffa07     ;interupt enable a (top)
  176.           move.b    (a0)+,$fffffa09     ;interupt enable b (bottom)
  177.           move.b    (a0)+,$fffffa13     ;interupt mask a
  178.           move.b    (a0)+,$fffffa15     ;interupt mask b
  179.           move.b    (a0)+,$fffffa19     ;timer a control
  180.           move.b    (a0)+,$fffffa1b     ;timer b control
  181.           move.b    (a0)+,$fffffa1f     ;timer a data
  182.           move.b    (a0)+,$fffffa21     ;timer b data (scan line)
  183.           move.l    (a0)+,$68     ;Horizontal bank interupt
  184.           move.l    (a0)+,$70     ;A normal Vertical bank
  185.           move.l    (a0)+,$120          ;Ttimer B interupt (BOTTOM BORDER)
  186.           move.l    (a0)+,$134          ;timer A interupt  (TOP BORDER)
  187.           bset      #3,$fffffa17        ;reset mfp vector base
  188.           move.w    #$2300,sr     ;all interupts go 
  189.           rts       
  190.  
  191. ;**************************************************************************
  192. ; TOP BORDER REMOVING ROUTINE                                             *
  193. ;**************************************************************************
  194.  
  195. topbord:  move.w    #$2100,sr     ;set status register
  196.           stop      #$2100        ;wait for interupt
  197.           clr.b     $fffffa19     ;disable timer a
  198.     rept 78                 ;repeat 78 times
  199.           nop                     ;pause for 4*78 Cycles
  200.           endr                  ;end the repeat
  201.           clr.b     $ffff820a     ;change to 60HZ
  202.           nop                     ;pause again
  203.           nop                     ;and again
  204.           move.b    #2,$ffff820a        ;set it back to 50hz. NO TOP BORDER
  205.           rte                     ;return from interupt
  206.  
  207. ;**************************************************************************
  208. ; This just points to an rte so interupts can be removed                  *
  209. ;**************************************************************************
  210.  
  211. phbl:     rte                        ;Return back
  212.  
  213. ;**************************************************************************
  214. ; BOTTOM BORDER REMOVING ROUTINE                                          *
  215. ;**************************************************************************
  216.  
  217. bottom:   move.w    d0,-(sp)      ;Move d0 into the Stack Pointer
  218.           rept 32                 ;Repeat 32 times
  219.           nop                     ;Pause
  220.           endr                  ;End repeat
  221.           clr.w     d0            ;Clear 
  222.           move.b    $ffff8209,d0        ;Get low byte of video address counter
  223.           neg.b     d0            ;Minus it
  224.           addi.b    #192,d0       ;Add 192 to it
  225.           lsl.b     d0,d0         ;Pause to get the correct place
  226.           move.w    #18,d0        ;Loop 18 times
  227. pause:    dbra      d0,pause      ;End of loop
  228.           move.b    #0,$ffff820a        ;Set to 60HZ
  229.           rept 12              ;Repeat 12 times
  230.           nop                     ;Puase
  231.           endr                    ;End repeat
  232.           move.b    #2,$ffff820a        ;Set it back the 50HZ. No Border
  233.           move.w    (sp)+,d0      ;Move the Stack Pointer back to 'd0'
  234.           rte                     ;Retern
  235.  
  236. ;**************************************************************************
  237. ; VBLANK ROUTINE                                                          *
  238. ;**************************************************************************
  239.  
  240. vblank:   clr.b     $fffffa19     ;stop timer A
  241.           move.b    #100,$fffffa1f      ;set timer a data
  242.           move.b    #4,$fffffa19        ;start timer A again
  243.  
  244.           clr.b     $fffffa1b     ;stop timer b
  245.           move.b    #228,$fffffa21      ;scan line 228 is the bottom border
  246.           move.l    #bottom,$120        ;move the no bottom border into scan line 120
  247.           move.b    #8,$fffffa1b        ;start timer B agian
  248.  
  249.           rte                     ;return 
  250.  
  251. ;**************************************************************************
  252. ; PUT THE CONCTACT BIT IN THE TOP BORDER AND THE LOWER BORDER        *                                 
  253. ; PUT THE ADDRESS IN THE MIDDLE OF THE SCREEN                *
  254. ; SCROLL THE NAMES IN THE LEFT AND RIGHT BORDERS ........ NOT             *
  255. ;**************************************************************************
  256.  
  257. put_graphics
  258.  
  259.           lea       pic1+34,a0          ;get our logo
  260.           movea.l   physcreen,a1        ;copy to the physical screen
  261.           adda.l    #0*160,a1           ;draw at line 0
  262.  
  263.           move.w    #4000-1,d6     ;repeat
  264. copy1:    move.l    (a0)+,(a1)+         ;draw our logo
  265.           move.l    (a0)+,(a1)+         ;draw our logo
  266.           dbra      d6,copy1      ;4000 times!
  267.  
  268. * copy to the lower border
  269.  
  270.           lea       pic1+34,a0
  271.           movea.l   physcreen,a1
  272.           adda.l    #230*160,a1
  273.  
  274.           move.w    #700-1,d6
  275. copy3     move.l    (a0)+,(a1)+
  276.           move.l    (a0)+,(a1)+
  277.           dbra      d6,copy3
  278.  
  279.           rts       
  280.  
  281. ;****************************************************************************
  282.  
  283. pic1    incbin    "a:\assembly\borders\address.pi1"
  284.  
  285.     section bss
  286.  
  287. savepal   ds.b     32
  288. mfpstore  ds.b    24
  289. oldsp     ds.l    1
  290. logscreen ds.l    1
  291. physcreen ds.l    1
  292. screen    ds.l    1
  293. oldres    ds.b    2
  294. oldscr    ds.l    4
  295. log    ds.b    43856
  296. phy    ds.b    43856
  297.  
  298.