home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI03.ARJ / ictari.03 / ASSEMBLY / BORDER / TOP_BOT.S < prev    next >
Text File  |  1989-07-29  |  4KB  |  167 lines

  1. ; Top & bottom border removal (50Hz only)
  2. ; (C)1993 Glenn Edwards
  3. ;
  4. ; This is basically a combination of the two methods used in
  5. ; TOP.S and BOTTOM.S
  6. ;
  7.  
  8.      opt    o+
  9.     
  10. ; If the top border flickers (or doesn't work at all!!) on your ST/STe,
  11. ; you must alter the value below. Increment it or decrement it by 1 until
  12. ; the top border is stable.
  13.  
  14. delay    EQU    1435
  15.  
  16. start    movem.l    d0-d7/a0-a6,-(sp)        ;Store registers
  17.     bsr.s    super
  18.     bsr    setup                ;Setup ST
  19.     bsr.s    main                ;Call main loop
  20.     bsr    restore                ;Restore ST
  21.     bsr.s    user
  22.     movem.l    (sp)+,d0-d7/a0-a6        ;Restore registers
  23. exit    clr.w    -(sp)
  24.     trap    #1
  25.     
  26. main    bsr    wvbl                ;Wait for VBI
  27.     cmp.b    #$39,$fffffc02.w        ;Has space been pressed?
  28.     bne.s    main                ;No, then loop
  29.     rts
  30.  
  31. newvbi    move.w    #delay,d0            ;Pause until in the correct
  32.     dbra    d0,*                ;place for Hz switch
  33.     clr.b    $ffff820a.w            ;60Hz
  34.     nop
  35.     nop
  36.     nop                    ;Pause a while
  37.     nop
  38.     nop
  39.     nop
  40.     move.b    #2,$ffff820a.w            ;50Hz
  41.  
  42.     move.b    #229,$fffffa21.w        ;Interrupt on line 229
  43.     move.b    #8,$fffffa1b.w            ;Timer B event-count mode
  44.     st    vbiflag                ;Flag that vbi has occured
  45.     rte
  46.  
  47. tmrb    eori.b    #2,$ffff820a.w            ;Toggle hertz rate
  48.     nop
  49.     nop                    ;Pause a while
  50.     nop
  51.     nop
  52.     eori.b    #2,$ffff820a.w            ;Toggle hertz rate
  53.     clr.b    $fffffa1b.w            ;Stop timer B
  54.     bclr    #0,$fffffa0f.w            ;Signal end of interrupt
  55.     rte
  56.  
  57. super    clr.l    -(sp)
  58.     move.w    #$20,-(sp)
  59.     trap    #1                ;Enter supervisor more
  60.     addq.l    #6,sp
  61.     move.l    d0,oldsp
  62.     rts
  63.     
  64. user    move.l    oldsp(pc),-(sp)
  65.     move.w    #$20,-(sp)
  66.     trap    #1                ;Enter user more
  67.     addq.l    #6,sp
  68.     rts
  69.  
  70. setup    move.l    $44e.w,oldscr            ;Store physbase
  71.     bsr    newscr                ;Setup new screen    
  72.     movem.l    $ffff8240.w,d0-d7        ;Store palette
  73.     movem.l    d0-d7,oldpal
  74.     movem.l    pic+4(pc),d0-d7            ;Install new palette
  75.     movem.l    d0-d7,$ffff8240.w
  76.      move.l    #screen1,a0
  77.     move.l    #pic+128,a1
  78.     move.w    #16000,d0
  79. .loop    move.w    (a1)+,(a0)+
  80.     dbra    d0,.loop
  81.     move.l    $70.w,oldvbi            ;Store old vbi
  82.     move.l    #newvbi,$70.w            ;Install new vbi
  83.     move.l    $120.w,oldtmrb            ;Store old timer B
  84.     move.l    #tmrb,$120.w            ;Store new timer B
  85.     move.b    $ffff8260.w,oldres        ;Store old resolution
  86.     bsr    wvbl                ;Wait for vbi
  87.     clr.b    $ffff8260.w            ;Go into low res
  88.  
  89.     move.l    $fffffa06.w,ierab        ;Store MFP ierab
  90.     move.b    $fffffa13.w,imska        ;Store MFP imska
  91.     move.b    $fffffa1b.w,tmrBctl        ;Store MFP timer B ctrl
  92.  
  93.     move.b    #1,$fffffa07.w            ;Enable only MFP timer B
  94.     move.b    #1,$fffffa13.w            ;Set mask to allow timer B
  95.     clr.b    $fffffa09.w            ;Stop other MFP interrupts
  96.     rts
  97.  
  98. restore    move.b    tmrBctl(pc),$fffffa1b.w        ;Restore MFP timer B ctrl
  99.     move.b    imska(pc),$fffffa13.w        ;Restore MFP imska
  100.     move.l    ierab(pc),$fffffa06.w        ;Restore MFP interrupts
  101.  
  102.     bsr    wvbl                ;Wait for vbi
  103.     move.b    oldres(pc),$ffff8260.w        ;Restore old resolution
  104.     move.l    oldtmrb(pc),$120.w        ;Restore timer b
  105.     move.l    oldvbi(pc),$70.w        ;Restore old vbi
  106.     movem.l    oldpal(pc),d0-d7        :Restore old palette
  107.     movem.l    d0-d7,$ffff8240.w
  108.     move.l    oldscr(pc),d0
  109.     bsr.s    setscr                ;Restore original screen
  110.     rts
  111.  
  112. newscr    move.l    #screen1,d0            ;Get address of new screen
  113.     add.l    #256,d0
  114.     and.l    #$ffffff00,d0            ;Put on 256 byte boundary
  115.     bsr.s    setscr                ;Set screen
  116.     rts
  117.  
  118. setscr    lsr #8,d0
  119.     move.l d0,$ffff8200.w            ;Set up new physbase
  120.     rts        
  121.  
  122. wvbl    sf    vbiflag                ;Wait for a VBI
  123. wait    tst.w    vbiflag
  124.     beq.s    wait
  125.     rts
  126.  
  127. cls    movem.l    d0-d7/a0-a6,-(sp)        ;Quick cls
  128.     lea    32000(a0),a0
  129.     moveq    #0,d1                ;Clear 13 registers
  130.     moveq    #0,d2
  131.     moveq    #0,d3
  132.     moveq    #0,d4
  133.     moveq    #0,d5
  134.     moveq    #0,d6
  135.     moveq    #0,d7
  136.     move.l    d1,a1
  137.     move.l    d1,a2
  138.     move.l    d1,a3
  139.     move.l    d1,a4
  140.     move.l    d1,a5
  141.     move.l    d1,a6
  142.     move.w    #204,d0
  143.  
  144. cs_loop    movem.l    d1-d7/a1-a6,-(a0)    ;do it
  145.     movem.l    d1-d7/a1-a6,-(a0)    ;3 times for a
  146.     movem.l    d1-d7/a1-a6,-(a0)    ;very minor speedup
  147.     dbra    d0,cs_loop
  148.     movem.l d1-d5,-(a0)        ;do the odd 20 bytes (5 regs)
  149.     movem.l    (sp)+,d0-d7/a0-a6
  150.     rts
  151.     
  152. pic    incbin    "a:\ictari.neo"
  153.  
  154.     section    bss
  155. oldpal    ds.w    16
  156. oldscr    ds.l    1
  157. oldvbi    ds.l    1
  158. oldtmrb    ds.l    1
  159. oldsp    ds.l    1
  160. ierab    ds.l    1
  161. vbiflag    ds.w    1
  162. imska    ds.b    1
  163. tmrBctl    ds.b    1
  164. oldres    ds.b    1
  165.     even
  166. screen1    ds.b    40000
  167.