home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / STAMPEDE / STAMP4_1.MSA / HINTS4.S < prev    next >
Text File  |  1985-11-19  |  9KB  |  323 lines

  1.  
  2. **************************************************************************
  3.  
  4. ;HITS AND TIPS FOR STAMPEDE ATARI ST AUGUST ISSUE 4 1990.
  5. ;Compiled by Stew.
  6.  
  7. ;This requires a full working version of Devpac to run
  8.  
  9. ;the following code is aimed at new comers to the 68000.
  10. ;all the routines below may be freely used and we hope that
  11. ;you find the comments very useful.
  12.  
  13. ;The program is a very basic scroll.
  14.  
  15.  
  16. ;first lets assign some variables using the EQUate function.
  17.  
  18. lowres    equ    0
  19. medres    equ    1
  20. hires    equ    2
  21.  
  22. ;now the code begins. the entire program has been split up
  23. ;into routines which are called using BSR (branch to subroutine)
  24. ;and the routine is finished using RTS (return from subroutine)
  25.  
  26. codego    bsr    supermode    ;allow access to the hardware
  27.     dc.w    $a00a        ;turn off mouse
  28.     bsr    setpalette    ;program palette set here
  29.     bsr    setscreen    ;set the screen mode
  30.     bsr    getscreenbase    ;where we will place data
  31.     bsr    message        ;show text message
  32.     bsr    goscroller    ;activate scroller
  33.     bsr    restorepalette    ;restore gem palette
  34.     bsr    usermode    ;back to user mode
  35.     clr.w    -(sp)        ;function 0-terminate program
  36.     trap    #1        ;now go back to gem
  37.  
  38. ;before any of the st's hardware registers can be used, we must
  39. ;place the 68000 into supervisor mode.
  40. ;the super mode instruction effects the status register bit #13.
  41. ;note: the trap #1 call with paramater $0020 actually toggles
  42. ;  the user mode/super mode status. so calling the routine
  43. ;  twice will restore the processor to its previous state.
  44.  
  45. supermode
  46.     clr.l    -(sp)        ;push parameters for supermode
  47.     move.w    #$0020,-(sp)    ;onto the stack
  48.     trap    #1        ;call the gemdos routine
  49.     addq.w    #6,sp        ;correct the stack
  50.     move.l    d0,savesp    ;save the old stack value
  51.     rts            ;exit the routine
  52.  
  53. ;once the program has been executed, we place the 68000 back
  54. ;into usermode ready for the return to gem. this actually
  55. ;clears the supervisor mode bit in the status register.
  56.  
  57. usermode
  58.     move.l    savesp,-(sp)    ;push on old stack value
  59.     move.w    #$0020,-(sp)    ;function $0020-user mode
  60.     trap    #1        ;put 68000 into user mode
  61.     addq.w    #6,sp        ;correct stack after the 2 pushes
  62.     rts
  63.  
  64. ;dump the main message out onto the screen using printline
  65.  
  66. message
  67.     pea    text
  68.     move.w    #9,-(sp)
  69.     trap    #1
  70.     addq.w    #6,sp
  71.     rts
  72.  
  73. ;now the main scroller call routine. this simply calls the flyback
  74. ;routine then executes the scroll twice and checks the keyboard.
  75. ;if space is pressed then the program quits.
  76.  
  77. goscroller
  78.     bsr    flyback        ;vertical blank
  79.     bsr    doscroll    ;scroll the screen
  80.     bsr    doscroll
  81.     move.w    #$00ff,-(sp)
  82.     move.w    #6,-(sp)
  83.     trap    #1
  84.     addq.w    #4,sp
  85.     cmp.b    #" ",d0        ;space pressed ?
  86.     bne    goscroller    ;no, loop again
  87.     rts
  88.  
  89. ;wait till the raster beam hits the vertical blanking area before
  90. ;we start the scroll. This is done through trap 14, function $25
  91.  
  92. flyback
  93.     move.w    #$25,-(sp)
  94.     trap    #14
  95.     addq.w    #2,sp
  96.     rts
  97.  
  98. ;now comes the main scroll routine. this is broken down into 2 section,
  99. ;the shifter and the updater.
  100.  
  101. doscroll
  102.     bsr    shift
  103.     bsr    update
  104.     rts
  105.  
  106. ;now comes the main scroller routine. this uses a 68000 called roxl.
  107. ;the 'roxl' shift data in a special way. bits coming out from the left
  108. ;go into the carry and new data comes into the right hand side.
  109. ;2 address registers are used here, a0 for the screen data and a1
  110. ;is used to point to a buffer where the new scroll data is stored.
  111. ;shiftbuffer is actually a dummy area which is actually used to
  112. ;bring new data in. Note: the scroll area is 16 pixels high
  113.  
  114. shift
  115.     move.l    screenbase,a0        ;screen start addr.
  116.     lea    shiftbuffer,a1        ;buffer start
  117.     moveq    #16-1,d7        ;height
  118. scrolllp
  119.     roxl.w    (a1)+            ;shift buffer data
  120.     roxl.w    152(a0)            ;shift all screen data
  121.     roxl.w    144(a0)
  122.     roxl.w    136(a0)
  123.     roxl.w    128(a0)
  124.     roxl.w    120(a0)
  125.     roxl.w    112(a0)
  126.     roxl.w    104(a0)
  127.     roxl.w    96(a0)
  128.     roxl.w    88(a0)
  129.     roxl.w    80(a0)
  130.     roxl.w    72(a0)
  131.     roxl.w    64(a0)
  132.     roxl.w    56(a0)
  133.     roxl.w    48(a0)
  134.     roxl.w    40(a0)
  135.     roxl.w    32(a0)
  136.     roxl.w    24(a0)
  137.     roxl.w    16(a0)
  138.     roxl.w    8(a0)
  139.     roxl.w    (a0)
  140.     add.l    #160,a0            ;down to next line
  141.     dbra    d7,scrolllp        ;loop for a
  142.     rts
  143.  
  144. ;once the data in the dummy buffer area has been shifted on using the
  145. ;roxl we must update the next character. each character is 16 pixels
  146. ;wide so we have a counter (charcount) which indicates which to change
  147. ;the buffer.
  148.  
  149. update
  150.     addq.w    #1,charcount        ;adjust counter
  151.     and.w    #$000f,charcount    ;clip value 0-15
  152. ;    cmp.w    #0,charcount        ;check for end of scroller
  153.     bne.s    noupdate
  154.  
  155.     move.l    address,a0        ;string pointer
  156.     moveq    #0,d0            ;clear out d0 ready for byte
  157.     move.b    (a0)+,d0        ;string data
  158.     bpl.s    notend            ;not end of string!
  159.     lea    string,a0        ;reset pointer
  160.     move.b    (a0)+,d0        ;pull first character
  161. notend    move.l    a0,address        ;restore pointer
  162.  
  163. ;    mulu.w    #32,d0
  164.     lsl.w    #5,d0            ;offset into font
  165.     lea    font,a0            ;start of font data
  166.     add.w    d0,a0            ;calculate data start
  167.     lea    shiftbuffer,a1        ;buffer start
  168.     moveq    #16-1,d7        ;height of character
  169. cop    move.w    (a0)+,(a1)+        ;copy data
  170.     dbra    d7,cop            ;do all data
  171. noupdate
  172.     rts                ;quit updater
  173.  
  174. ;now we set the screen mode using function 5-trap 14. this also
  175. ;allows us to set where the st fetches the data for the screen.
  176.  
  177. setscreen
  178.     move.w    #lowres,-(sp)    ;place mode required on stack
  179.     move.l    #-1,-(sp)    ;dont effect screen address
  180.     move.l    #-1,-(sp)    ;dont effect screen address
  181.     move.w    #$0005,-(sp)    ;function 5-setscreen
  182.     trap    #14        ;set the screen resolution
  183.     add.w    #12,sp
  184.     rts
  185.  
  186. ;the following two routines simply set the st's screen
  187. ;colours using trap #14, function 6. the colours are
  188. ;actually placed into the hardware locations $ffff8240.
  189.  
  190. setpalette
  191.     move.l    #mypal,-(sp)    ;address of palette in memory
  192.     move.w    #$0006,-(sp)    ;function 6-setpalette
  193.     trap    #14        ;set the palette
  194.     addq.w    #6,sp
  195.     rts
  196.  
  197. restorepalette
  198.     move.l    #gempal,-(sp)    ;address of palette in memory
  199.     move.w    #$0006,-(sp)    ;function 6-setpalette
  200.     trap    #14        ;set the palette
  201.     addq.w    #6,sp
  202.     rts
  203.  
  204. ;for us to draw anything on the screen we must first located the
  205. ;top of the screen in memory. this is done using function 2-
  206. ;trap 14. the top of the screen is returned in a long word in
  207. ;data register d0. this will vary in different machines as the
  208. ;520 st's are located at $78000 and the 1040 st's are at $f8000.
  209.  
  210. getscreenbase
  211.     move.w    #$0002,-(sp)    ;function 2-physbase
  212.     trap    #14        ;calculate the address
  213.     addq.w    #2,sp        ;correct the stack
  214.     move.l    d0,screenbase    ;save the base address for later
  215.     rts
  216.  
  217. **************************************************************************
  218.  
  219. ;reserved space for variables
  220.  
  221. shiftbuffer
  222.     ds.w    16
  223. savesp
  224.     dc.l    0    ;storage for stack in memory
  225. screenbase
  226.     dc.l    0    ;where the top of the screen is located
  227. charcount
  228.     dc.w    0    ;pixel no. 0-15
  229.  
  230. mypal
  231.     dc.w    $007,$777,$000,$777,$000,$000,$000,$000
  232.     dc.w    $707,$770,$000,$000,$000,$000,$000,$777
  233.  
  234. gempal
  235.     dc.w    $777,$700,$070,$000,$111,$222,$333,$444
  236.     dc.w    $555,$000,$001,$010,$100,$200,$020,$002
  237.  
  238. font
  239. letta    dc.w    %0111111111111110
  240.     dc.w    %0100000000000010
  241.     dc.w    %0100000000000010
  242.     dc.w    %0100000000000010
  243.     dc.w    %0100000000000010
  244.     dc.w    %0100000000000010
  245.     dc.w    %0100000000000010
  246.     dc.w    %0111111111111110
  247.     dc.w    %0100000000000010
  248.     dc.w    %0100000000000010
  249.     dc.w    %0100000000000010
  250.     dc.w    %0100000000000010
  251.     dc.w    %0100000000000010
  252.     dc.w    %0100000000000010
  253.     dc.w    %0100000000000010
  254.     dc.w    %0000000000000000
  255.  
  256. lettb    dc.w    %0111111111111100
  257.     dc.w    %0100000000000010
  258.     dc.w    %0100000000000010
  259.     dc.w    %0100000000000010
  260.     dc.w    %0100000000000010
  261.     dc.w    %0100000000000010
  262.     dc.w    %0100000000000010
  263.     dc.w    %0111111111111110
  264.     dc.w    %0100000000000010
  265.     dc.w    %0100000000000010
  266.     dc.w    %0100000000000010
  267.     dc.w    %0100000000000010
  268.     dc.w    %0100000000000010
  269.     dc.w    %0100000000000010
  270.     dc.w    %0111111111111100
  271.     dc.w    %0000000000000000
  272.  
  273. lettc    dc.w    %0111111111111110
  274.     dc.w    %0100000000000000
  275.     dc.w    %0100000000000000
  276.     dc.w    %0100000000000000
  277.     dc.w    %0100000000000000
  278.     dc.w    %0100000000000000
  279.     dc.w    %0100000000000000
  280.     dc.w    %0100000000000000
  281.     dc.w    %0100000000000000
  282.     dc.w    %0100000000000000
  283.     dc.w    %0100000000000000
  284.     dc.w    %0100000000000000
  285.     dc.w    %0100000000000000
  286.     dc.w    %0100000000000000
  287.     dc.w    %0111111111111110
  288.     dc.w    %0000000000000000
  289.  
  290. lettd    dc.w    %0111111111111000
  291.     dc.w    %0100000000000100
  292.     dc.w    %0100000000000010
  293.     dc.w    %0100000000000010
  294.     dc.w    %0100000000000010
  295.     dc.w    %0100000000000010
  296.     dc.w    %0100000000000010
  297.     dc.w    %0100000000000010
  298.     dc.w    %0100000000000010
  299.     dc.w    %0100000000000010
  300.     dc.w    %0100000000000010
  301.     dc.w    %0100000000000010
  302.     dc.w    %0100000000000010
  303.     dc.w    %0100000000000100
  304.     dc.w    %0111111111111000
  305.     dc.w    %0000000000000000
  306.  
  307. address
  308.     dc.l    string
  309.  
  310. text    dc.b    13,10,10,10
  311.     dc.b    "                STAMPEDE",13,10,10
  312.     dc.b    "          HINTS 'N' TIPS FILE",13,10
  313.     dc.b    "              AUGUST 1990",13,10
  314.     dc.b    "                BY STEW",13,10,10
  315.  
  316.     dc.b    "          PRESS SPACE TO QUIT",13,10
  317.     dc.b    0
  318.  
  319. string
  320.     dc.b    0,1,0,1,0,2,3
  321.     dc.b    $ff
  322.     even
  323.