home *** CD-ROM | disk | FTP | other *** search
/ Fujiology Archive / fujiology_archive_v1_0.iso / S / SHAPESFT / SSSOURCE.ZIP / SSSOURCE.MSA / EXAMPLE / CHAIN4.S < prev    next >
Encoding:
Text File  |  1985-11-20  |  5.9 KB  |  224 lines

  1. *  Budgie UK    chain4.s   last updated Aug 6 1990
  2. *  
  3. *  a chain program which loads a tune, then a picture,
  4. *  waits for a key. When hit, scrolls screen down,
  5. *  cuts out the music interrupt, but stores it in $210
  6. *  waits for key again. When hit, scrolls screen back up 
  7. *  recalls the interrupt: move.l $210,$4ce+4
  8. *  or, in Basic, Loke $4ce+4,leek($210)
  9. *  Some earlier music by Goth was slotted in $4de.
  10. *  This latest bath (August 1990) uses the V/b slot at $4ce+4
  11. *  (ie $4d2) so please note.
  12.  
  13. *  View in medium res *
  14. *  comments (;) always FOLLOW the instructions
  15. *  Devpac 2 required to assemble
  16. *  Aug 2 1990   Music by Goth of The Shapeshifters
  17. * (c) Budgie UK , Camy Maertens and Shapeshifters
  18. *------------------------------------------**
  19.  
  20. * reallocate unused memory to Gemdos
  21. m_shrink
  22.     movea.l    A7,A5    
  23.     move.l     #stack,A7    
  24.     movea.l    4(A5),A5    
  25.     move.l    12(A5),D0    
  26.     add.l    20(A5),D0    
  27.     add.l    28(A5),D0    
  28.     addi.l    #256,D0        
  29.     move.l    D0,-(A7)    
  30.      move.l    A5,-(A7)    
  31.     clr.w    -(A7)        
  32.     move.w    #$4A,-(A7)    
  33.     trap    #1        
  34.     lea    $0C(A7),A7
  35. ; the above is the STANDARD gem start. We will only use the ram
  36. ; space that is strictly required. The rest may go back to gem.
  37.  
  38.     bra.s    start
  39.  
  40. name    dc.b    "a:\example\title.pi1",0  change d to a if necessary
  41. name1    dc.b    "a:\tunes_2\bel*.prg",0   this is the tune. 
  42.     even
  43. ; bra.s start means 'branch (short) to start'
  44. ; in order to skip the above labels, which are not instructions
  45. ; dc.b  means declare bytes
  46.  
  47. start    clr.l    -(sp)        Budgie progs ALWAYS run in supervisor
  48.      move.w #$20,-(sp)     
  49.      trap #1
  50.      addq.l #6,SP
  51.      move.l d0,super
  52.  
  53.     move.w  #4,-(sp)    get res
  54.     trap    #14
  55.     addq.l  #2,sp
  56.     move.w  d0,res        and save it
  57.  
  58.     movem.l    $ff8240,d0-d7     save palette
  59.     movem.l    d0-d7,palette
  60.  
  61.     move.l    #environment,-(sp)    call program one ie music
  62.     move.l    #environment,-(sp)  
  63.     pea    name1            whatever it is
  64.     move.w    #0,-(sp)    chain this routine
  65.     move.w    #$4b,-(sp)    execute it
  66.     trap    #1        
  67.     adda.l    #$10,sp
  68. ; above 'chained' prog can be anything.
  69.  
  70. setlowrez
  71.     clr.w    -(a7)        0=low res
  72.     move.l    $44e,-(A7)    -1=ignore physbase
  73.     move.l    $44e,-(A7)    -1=ignore logbase
  74.     move.w    #5,-(A7)
  75.     trap    #14        
  76.     lea    12(A7),A7
  77.  
  78.     dc.w    $a000
  79.     movea.l    8(a0),a0
  80.     clr.w    (a0)
  81.     dc.w    $a00a        hidemouse
  82.  
  83.     move.l    $44e,d0
  84.     move.l    d0,physbase    save original 'physbase'
  85.     sub.l    #32768,d0
  86.     move.l    d0,$45e        show blank screen
  87.  
  88. vsync    
  89.     move.w    #37,-(sp)
  90.     trap    #14
  91.     addq.l    #2,sp
  92.  
  93. * load a degas picture at a specific address 
  94.     move.w    #0,-(A7)    0 for open a file
  95.     move.l    #name,-(A7)    name of picture to be loaded
  96.     move.w    #$3D,-(A7)    code for open
  97.     trap    #1        ask o/s to do it
  98.     add.l    #8,sp        adjust stack pointer
  99.     move.w    d0,handle    store 'handle' returned in d0, in a safe place
  100.     tst.w    d0        test if negative by any chance...
  101.     bmi    error        if so: file not found: branch to error
  102.     move.w    #$007,$ff8240
  103.  
  104.     move.l    physbase,d0    load direct to this address
  105.     sub.l    #34,d0        or more precisely, here.
  106.     move.l    d0,-(sp)    pass load address to stack
  107.     move.l    #32066,-(A7)    read 32066 bytes (ie a degas picture)
  108.     move.w    handle,-(A7)    retrieve that handle    
  109.     move.w    #$3F,-(A7)    code for read    
  110.     trap    #1        ask o/s to do it
  111.     adda.l    #$C,A7        adjust stack pointer when all done
  112.  
  113.     move.w     handle,-(SP)    retrieve handle again
  114.     move.w     #$3E,-(SP)    code for close
  115.     trap     #1        ok do it
  116.     addq.l     #4,SP        adjust stack as ususal
  117.  
  118.     move.l    physbase,d0    put physbase address in a0
  119.     sub.l    #32,d0        deduct 16 words from it
  120.     move.l    d0,-(SP)    that's where the palette starts  
  121.     move.w    #6,-(SP)    call 'change palette' routine
  122.     trap    #14        ok
  123.     addq.l    #6,SP        all done
  124.  
  125.     move.l    physbase,$45e
  126.  
  127.     move.w    #37,-(SP)    vsync routine
  128.     trap    #14        ok do it
  129.     addq.l    #2,SP        adjust stack
  130. ; wait for v/b to be certain
  131.  
  132.     move.w    #$07,-(sp)        getkey code
  133.     trap    #1        call o/s
  134.     addq.l    #2,sp
  135.  
  136.     move.l    $4ce+4,$210    store vector in a safe place like $210
  137.     clr.l    $4ce+4        kill vector: music stops
  138.     lea    $ff8800,a0    get sound chip address
  139.     move.b    #7,(a0)
  140.     move.b    #%11111111,2(a0) cut out any lingering noise...
  141.  
  142.     move.w    #37,-(SP)    vsync routine
  143.     trap    #14        ok do it
  144.     addq.l    #2,SP        adjust stack
  145. ; wait for v/b to be certain
  146.  
  147.     move.l #$8000000,$ff8800 
  148.     move.l #$9000000,$ff8800 
  149.     move.l #$a000000,$ff8800 
  150.  
  151. scrolldown
  152.     move.w    #27,d7        loop: 28 times
  153. .loop    move.l    $44e,a0        $44e is current screen
  154.     add.l    #-1280,a0    1280 is DIVISIBLE by 256 AND 160 !
  155.     move.l    a0,$45e        $45e is NEW screen pointer
  156.     move.w    #37,-(sp)    vsync call: during this interrupt, 
  157.     trap    #14        the value inside $45e will become 
  158.     addq.l    #2,sp        EFFECTIVE.
  159.     dbra    d7,.loop    d7 unlikely to be corrupted by call
  160.  
  161.     move.w    #$07,-(sp)        getkey
  162.     trap    #1        
  163.     addq.l    #2,sp
  164.  
  165.     move.l    $210,$4ce+4    retrieve vector: music restarts 
  166.  
  167. scrollup
  168.     move.w    #27,d7
  169. .loop    move.l    $44e,a0        this time, we scroll
  170.     add.l    #1280,a0    the other way
  171.     move.l    a0,$45e
  172.     move.w    #37,-(sp)    vsync 
  173.     trap    #14    
  174.     addq.l    #2,sp
  175.     dbra    d7,.loop    
  176.  
  177.     move.w    #$07,-(sp)        getkey
  178.     trap    #1        
  179.     addq.l    #2,sp
  180. error
  181.     
  182. quit
  183.     move.l    #0,$4ce+4    music off    
  184.     lea    $ff8800,a0    get sound chip 
  185.     move.b    #7,(a0)
  186.     move.b    #%11111111,2(a0) cut out lingering noise
  187.     move.l #$8000000,$ff8800 
  188.     move.l #$9000000,$ff8800 
  189.     move.l #$a000000,$ff8800 
  190.  
  191.     move.w  res,-(sp)    old resolution back
  192.     move.l  #-1,-(sp)    no change in screen locations
  193.     move.l  #-1,-(sp)    physical or otherwise
  194.     move.w  #5,-(sp)
  195.     trap    #14        call o/s
  196.     add.l   #12,sp        ok screen now back as we found it
  197.  
  198.     movem.l    palette,d0-d7    get those original palette colours again
  199.     movem.l    d0-d7,$ff8240    and pass them to video chip
  200.     
  201. superout
  202.      move.l     super,-(SP)    retrieve user stack pointer
  203.      move.w     #$20,-(SP)
  204.      trap     #1
  205.      addq.l     #6,SP        we're now back in user mode
  206.  
  207.     clr.w    -(sp)        exit to desktop
  208.     trap    #1
  209.  
  210. *-------------------------------------
  211.  
  212. environment
  213.     dc.b    0,0,0,0,0,0 
  214.  
  215.     even
  216.  
  217. res    dc.w    0    the original resolution
  218. handle    dc.l    0    needed for opening files
  219. super    dc.l    0    the original stack pointer
  220. physbase    
  221.     dc.l    0    the original screen address at start of prog
  222. palette    ds.w    18
  223.     ds.w     256    512 bytes (more than enough) for our stack
  224. stack    dc.l     0    our private stack