home *** CD-ROM | disk | FTP | other *** search
/ TCE Demo 2 / TCE_DEMO_CD2.iso / demo_cd_.2 / mags / dba / dba_13.arj / dba-13 / GOODIES / DISTORT.S < prev    next >
Text File  |  1993-08-17  |  9KB  |  234 lines

  1. *************************************************************************
  2. *                                                                       *
  3. *                              DISTORTING TEXT                          *
  4. *                       CODED BY O.T.M. OF THE D.B.A.                   *
  5. *                                                                       *
  6. *************************************************************************
  7.  
  8.         section text
  9.  
  10.         bsr.s   init
  11.         bsr     main
  12.         bsr     quit
  13.  
  14. init:
  15.         clr.l   -(sp)           ; supervisor
  16.         move.w  #$20,-(sp)      ; get/set/inquire supervisor
  17.         trap    #1              ; Gemdos
  18.         addq    #6,sp           ; correct the stack
  19.         move.l  d0,ssp          ; save ssp
  20.         
  21.         move.w  #2,-(sp)        ; get the physloc
  22.         trap    #14             ; xbios
  23.         addq.l  #2,sp           ; correct the stack
  24.         move.l  d0,physloc      ; save the physloc
  25.  
  26.         move.w  #3,-(sp)        ; get the logloc
  27.         trap    #14             ; xbios
  28.         addq    #2,sp           ; correct the stack
  29.         move.l  d0,logloc       ; save the logloc
  30.         
  31.         move.w  #4,-(sp)        ; get the resolution
  32.         trap    #14             ; xbios
  33.         addq    #2,sp           ; correct the stack
  34.         move.w  d0,getrez       ; save the resolution
  35.  
  36.         cmp.w   #2,d0           ; check on high rez
  37.         bne.s   rez_is_good     ; at least the resolution is good
  38.  
  39.         pea     high_text       ; naughty boy runs my program in high rez
  40.         move.w  #9,-(sp)        ; show shit
  41.         trap    #1              ; Gemdos (It's slow but good)
  42.         addq    #6,sp           ; correct the stack again
  43.         
  44.         move.w  #7,-(sp)        ; wait for a key
  45.         trap    #1              ; Gemdos (what the heck)
  46.         addq    #2,sp           ; correct the stack
  47.         bra     exit            ; and leave quite neatly
  48.  
  49. rez_is_good:
  50.         clr.w   -(sp)           ; enter low rez at all circumstances
  51.         move.l  #-1,-(sp)       ; keep the physloc
  52.         move.l  #-1,-(sp)       ; keep the logloc
  53.         move.w  #5,-(sp)        ; set screen
  54.         trap    #14             ; xbios 
  55.         lea     $c(sp),sp       ; correct the stack
  56.  
  57.         lea     $ffff8240,a0    ; the old palette
  58.         lea     colbuf,a1       ; buffer to store it in
  59.         move.w  #15,d0          ; counter for the number of the colours
  60. sav_col:
  61.         move.w  (a0)+,(a1)+     ; copy from one to another
  62.         dbf     d0,sav_col
  63.  
  64.         pea     pic+2           ; get the new palette
  65.         move.w  #6,-(sp)        ; setpalette
  66.         trap    #14             ; xbios
  67.         addq.l  #6,sp           ; correct the stack
  68.         
  69.         dc.w    $a00a
  70.         
  71.         move.l  #screen1,scr1   ; get the address, and not the value    
  72.         move.l  #screen2,scr2   ; get the address, and not the value
  73.     move.l    scr1,d0        ; get the screenaddress
  74.     addi.l    #255,d0        ; put it in a wordboundery
  75.     and.l    #$ffffff00,d0    ; now it's ready for use
  76.     move.l    scr2,d0        ; and the same for the second screen
  77.     addi.l    #255,d0        ; put it in a wordboundery
  78.     and.l    #$ffffff00,d0    ; ready.
  79.  
  80.  
  81.         move.w  #7999,d0        ; counter
  82.         move.l  logloc,a0       ; the screen
  83.         move.l  scr1,a1 ; this will be the physloc
  84.         move.l  scr2,a2 ; this will be the logloc
  85. cls:
  86.         clr.l   (a0)+           ; clear it
  87.         clr.l   (a1)+           ; clear this one two
  88.         clr.l   (a2)+           ; and even this one 
  89.         dbf     d0,cls          ; do until clean
  90.  
  91.         rts
  92.  
  93. main:
  94.         bsr.s   vsync           ; wait till vsync happens and give rast(if wanted)
  95.         bsr.s   swapscreen      ; no flickering logo's
  96.         bsr     clear_piece     ; and clear some bits
  97.         bsr     distort         ; do this piece of code
  98.         moveq   #0,d0           ; cleare this register for no false rast
  99.         cmp.b   #$62,$fffffc02.w; see if <HELP> is pressed
  100.         bne.s   test_space      ; not pressed
  101.         moveq   #-1,d0          ; it's pressed so do some rasts
  102. test_space:
  103.         cmp.b   #$39,$fffffc02.w; test if <SPACE> is pressed
  104.         bne.s   main            ; thank God you did not!!
  105.         rts                     ; let's quit
  106.  
  107. vsync:
  108.         movem.l d0-a7,-(sp)     ; save the registers
  109.  
  110.         tst.w   d0              ; test d0
  111.         beq.s   no_rast         ; HELP isn't pressed
  112.         move.w  #$777,$ffff8240.w;white
  113. no_rast:
  114.         move.w  #$25,-(sp)      ; official vsync
  115.         trap    #14             ; xbios
  116.         addq    #2,sp           ; correct the stack
  117.  
  118.         clr.w   $ffff8240.w     ; black
  119.  
  120.         movem.l (sp)+,d0-a7     ; give the regs back
  121.         rts                     ; and the subroutine is done
  122.  
  123. swapscreen:
  124.         movem.l d0-a7,-(sp)     ; save the regs
  125.         move.l  scr1,d0         ; save the first screen
  126.         move.l  scr2,scr1       ; swap the two screens
  127.         move.l  d0,scr2         ; and now the first is the second
  128.  
  129.         move.w  #-1,-(sp)       ; keep low rez
  130.         move.l  scr1,-(sp)      ; physloc
  131.         move.l  scr2,-(sp)      ; logloc
  132.         move.w  #5,-(sp)        ; setscreen
  133.         trap    #14             ; xbios
  134.         lea     $c(sp),sp       ; correct the stack
  135.  
  136.         movem.l (sp)+,d0-a7     ; give the regs back
  137.         rts
  138.  
  139. clear_piece:
  140.         move.w  #35,d0          ; number of lines to clear
  141.         move.w  #19,d1          ; this is on line
  142.         move.l  scr1,a0         ; screen in place
  143. clear_it:
  144.         clr.w   (a0)            ; clear it
  145.         addq.l  #8,a0           ; next word in same plane
  146.         dbf     d1,clear_it     ; do until line complete
  147.         move.w  #19,d1          ; new line-counter
  148.         dbf     d0,clear_it     ; do until complete
  149.         rts
  150.  
  151. distort:
  152.         lea     pic+34,a1       ; get the original logo
  153.         move.l  scr1,a2         ; and finally the screen.
  154.         addq.l  #8,a2           ; this one is to centre the text 
  155.         move.w  #17,d0          ; number of letters (18)
  156. do_distort:
  157.         moveq   #0,d2           ; clear the register
  158.         move.w  #16,d1          ; counter for the lines
  159.         movea.l sinpoint,a0     ; get the data
  160.         move.b  (a0),d2         ; get the current offset in the data
  161.         addq.l  #1,sinpoint     ; increase it
  162.         cmp.b   #-1,d2          ; test on overflow
  163.         bne.s   continue        ; no overflow
  164.         move.l  #data,sinpoint  ; on overflow restart
  165.         add.l   #18,sinpoint    ; correct it 
  166.         moveq   #0,d2           ; and don't bomb
  167. continue:
  168.         mulu.w  #160,d2         ; calculate the offset for screenuse
  169.         adda.l  d2,a2           ; add offset to the screen
  170. place_lettre:
  171.         move.w  (a1),(a2)       ; copy the letter
  172.         adda    #$a0,a1         ; next line in the same plane
  173.         adda    #$a0,a2         ; next line in dito plane
  174.         dbf     d1,place_lettre ; do until complete
  175.         suba.l  #17*160-8,a1    ; go to the next letter
  176.         suba.l  #17*160-8,a2    ; go to the next letter
  177.         suba.l  d2,a2           ; back to the top of the screen
  178.         dbf     d0,do_distort   ; do until all letters are done
  179.         sub.l   #17,sinpoint    ; correct the pointer for nicer sine
  180.         rts                     ; that should be about it so return.
  181.  
  182. quit:
  183.         lea     colbuf,a0       ; get the old colours
  184.         lea     $ffff8240,a1    ; get the address for the colours
  185.         move.w  #15,d0          ; counter for the colours
  186. old_col:
  187.         move.w  (a0)+,(a1)+     ; copy them 
  188.         dbf     d0,old_col      ; do until all colours are copied.
  189.  
  190.         move.w  getrez,-(sp)    ; restore the resolution
  191.         move.l  physloc,-(sp)   ; keep physbase
  192.         move.l  logloc,-(sp)    ; keep logloc
  193.         move.w  #5,-(sp)        ; setscreen
  194.         trap    #14             ; xbios
  195.         lea     $c(sp),sp       ; correct the stack
  196.  
  197.         dc.w    $a009           ; you can use your mouse now
  198.  
  199.         move.l  ssp,-(sp)       ; old stack on stack
  200.         move.w  #$20,-(sp)      ; set the stack back
  201.         trap    #1              ; stack is user now
  202.         addq    #6,sp           ; correct the "new" stack
  203.  
  204. exit:
  205.         clr.w   -(sp)           ; stop the program
  206.         trap    #1              ; Gemdos
  207.         addq    #2,sp           ; this is useless
  208.  
  209.         section  data
  210.  
  211. high_text:
  212.         dc.b    27,"E Hello, you fool, this program doesn't support mono so bugger off.",0
  213.  
  214. data:   incbin  'a:\sinus.dat'   
  215.         dc.b    -1
  216.         even
  217. sinpoint:
  218.         dc.l    data
  219. pic:    incbin  'a:\disttest.pi1'
  220.  
  221.         section bss
  222.  
  223. ssp:    ds.l    1
  224. physloc:ds.l    1
  225. logloc: ds.l    1
  226. getrez: ds.w    1
  227. colbuf: ds.b    32
  228. screen1:ds.b    32000           ; the two screens 
  229. screen2:ds.b    32000
  230. scr1:   ds.l    1               ; the addresses of the two screens
  231. scr2:   ds.l    1
  232.  
  233.         end
  234.