home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI03.ARJ / ictari.03 / ASSEMBLY / BORDER / BOTTOM.S next >
Text File  |  1989-04-06  |  4KB  |  142 lines

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