home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI03.ARJ / ictari.03 / ASSEMBLY / BORDER / TOP.S < prev   
Text File  |  1989-04-06  |  3KB  |  133 lines

  1. ; Top border removal (50Hz only)
  2. ; (C)1993 Glenn Edwards
  3.  
  4.      opt    o+
  5.  
  6. ; If the top border flickers (or doesn't work at all!!) on your ST/STe,
  7. ; you must alter the value below. Increment it or decrement it by 1 until
  8. ; the top border is stable.
  9.  
  10. delay    EQU    1435
  11.     
  12. start    movem.l    d0-d7/a0-a6,-(sp)        ;Store registers
  13.     bsr.s    super
  14.     bsr.s    setup                ;Setup ST
  15.     bsr.s    main                ;Call main loop
  16.     bsr    restore                ;Restore ST
  17.     bsr.s    user
  18.     movem.l    (sp)+,d0-d7/a0-a6        ;Restore registers
  19. exit    clr.w    -(sp)
  20.     trap    #1
  21.     
  22. main    bsr    wvbl                ;Wait for VBI
  23.     cmp.b    #$39,$fffffc02.w        ;Has space been pressed?
  24.     bne.s    main                ;No, then loop
  25.     rts
  26.  
  27. newvbi    move.w    #1435,d0            ;Pause until in the correct
  28.     dbra    d0,*                ;place for Hz switch
  29.     clr.b    $ffff820a.w            ;60Hz
  30.     nop
  31.     nop
  32.     nop                    ;Pause a while
  33.     nop
  34.     nop
  35.     nop
  36.     move.b    #2,$ffff820a.w            ;50Hz
  37.     st    vbiflag                ;Flag that vbi has occured
  38.     rte
  39.  
  40. super    clr.l    -(sp)
  41.     move.w    #$20,-(sp)
  42.     trap    #1                ;Enter supervisor more
  43.     addq.l    #6,sp
  44.     move.l    d0,oldsp
  45.     rts
  46.     
  47. user    move.l    oldsp(pc),-(sp)
  48.     move.w    #$20,-(sp)
  49.     trap    #1                ;Enter user more
  50.     addq.l    #6,sp
  51.     rts
  52.  
  53. setup    move.l    $44e.w,oldscr            ;Store physbase
  54.     bsr    newscr                ;Setup new screen    
  55.     movem.l    $ffff8240.w,d0-d7        ;Store palette
  56.     movem.l    d0-d7,oldpal
  57.     movem.l    newpal(pc),d0-d7        :Install new palette
  58.     movem.l    d0-d7,$ffff8240.w
  59.     move.l    $70.w,oldvbi            ;Store old vbi
  60.     move.l    #newvbi,$70.w            ;Install new vbi
  61.     move.b    $ffff8260.w,oldres        ;Store old resolution
  62.     bsr    wvbl                ;Wait for vbi
  63.     clr.b    $ffff8260.w            ;Go into low res
  64.  
  65.     move.l    $fffffa06.w,ierab        ;Store MFP ierab
  66.     clr.l    $fffffa06.w            ;Stop all MFP interrupts
  67.     rts
  68.  
  69. restore    move.l    ierab(pc),$fffffa06.w        ;Restore MFP interrupts
  70.  
  71.     bsr    wvbl                ;Wait for vbi
  72.     move.b    oldres(pc),$ffff8260.w        ;Restore old resolution
  73.     move.l    oldvbi(pc),$70.w        ;Restore old vbi
  74.     movem.l    oldpal(pc),d0-d7        :Restore old palette
  75.     movem.l    d0-d7,$ffff8240.w
  76.     move.l    oldscr(pc),d0
  77.     bsr.s    setscr                ;Restore original screen
  78.     rts
  79.  
  80. newscr    move.l    #screen1,d0            ;Get address of new screen
  81.     add.l    #256,d0
  82.     and.l    #$ffffff00,d0            ;Put on 256 byte boundary
  83.     bsr.s    setscr                ;Set screen
  84.     rts
  85.  
  86. setscr    lsr #8,d0
  87.     move.l d0,$ffff8200.w            ;Set up new physbase
  88.     rts        
  89.  
  90. wvbl    sf    vbiflag                ;Wait for a VBI
  91. wait    tst.w    vbiflag
  92.     beq.s    wait
  93.     rts
  94.  
  95. cls    movem.l    d0-d7/a0-a6,-(sp)        ;Quick cls
  96.     lea    32000(a0),a0
  97.     moveq    #0,d1                ;Clear 13 registers
  98.     moveq    #0,d2
  99.     moveq    #0,d3
  100.     moveq    #0,d4
  101.     moveq    #0,d5
  102.     moveq    #0,d6
  103.     moveq    #0,d7
  104.     move.l    d1,a1
  105.     move.l    d1,a2
  106.     move.l    d1,a3
  107.     move.l    d1,a4
  108.     move.l    d1,a5
  109.     move.l    d1,a6
  110.     move.w    #204,d0
  111.  
  112. cs_loop    movem.l    d1-d7/a1-a6,-(a0)    ;do it
  113.     movem.l    d1-d7/a1-a6,-(a0)    ;3 times for a
  114.     movem.l    d1-d7/a1-a6,-(a0)    ;very minor speedup
  115.     dbra    d0,cs_loop
  116.     movem.l d1-d5,-(a0)        ;do the odd 20 bytes (5 regs)
  117.     movem.l    (sp)+,d0-d7/a0-a6
  118.     rts
  119.     
  120. newpal    dc.w    $000,$000,$000,$000,$000,$000,$000,$000
  121.     dc.w    $000,$000,$000,$000,$000,$000,$000,$000
  122.  
  123.     section    bss
  124. oldpal    ds.w    16
  125. oldscr    ds.l    1
  126. oldvbi    ds.l    1
  127. oldsp    ds.l    1
  128. ierab    ds.l    1
  129. vbiflag    ds.w    1
  130. oldres    ds.b    1
  131.     even
  132. screen1    ds.b    40000
  133.