home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / Asm / Blitter / ClearWorm.s < prev    next >
Encoding:
Text File  |  1997-02-16  |  5.9 KB  |  279 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Test routine for ClearBOB()
  3. ;---------------------------
  4.  
  5.  
  6.     INCDIR    "INCLUDES:"
  7.     INCLUDE    "exec/exec_lib.i"
  8.     INCLUDE    "games/games_lib.i"
  9.     INCLUDE    "games/games.i"
  10.  
  11. CALL    MACRO
  12.     jsr    _LVO\1(a6)
  13.     ENDM
  14.  
  15.     SECTION    "ClearBOB",CODE
  16.  
  17. ;===========================================================================;
  18. ;                             INITIALISE DEMO
  19. ;===========================================================================;
  20.  
  21. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  22.     move.l    ($4).w,a6
  23.     lea    GMS_Name(pc),a1
  24.     moveq    #$00,d0
  25.     CALL    OpenLibrary
  26.     move.l    d0,GMS_Base
  27.     beq    .Error_GMS
  28.  
  29.     move.l    GMS_Base(pc),a6    ;Activate user preferences.
  30.     sub.l    a0,a0
  31.     CALL    SetUserPrefs
  32.  
  33.     CALL    AllocBlitter    ;Allocate the blitter.
  34.     tst.w    d0
  35.     bne    .Error_Blitter
  36.  
  37.     CALL    AllocAudio
  38.     tst.w    d0
  39.     bne    .Error_Audio
  40.  
  41.     lea    Screen(pc),a0    ;Initialise the screen.
  42.     CALL    AddScreen
  43.     tst.w    d0
  44.     bne.s    .Error_Screen
  45.  
  46.     lea    PIC_Background(pc),a1    ;Load the picture.
  47.     move.l    GS_MemPtr1(a0),PIC_Data(a1)
  48.     CALL    LoadPic
  49.     tst.w    d0
  50.     bne.s    .Error_Picture
  51.  
  52.     move.l    PIC_Palette(a1),GS_Palette(a0)
  53.     CALL    UpdatePalette
  54.  
  55.     lea    PIC_Bobs(pc),a1    ;Load the picture that contains
  56.     CALL    LoadPic    ;our BOB.
  57.     tst.w    d0
  58.     bne.s    .Error_BOBPic
  59.  
  60.     lea    Screen(pc),a0    ;Initialise the BOB so that it is
  61.     lea    BOB_Rambo(pc),a1    ;ready for drawing.
  62.     CALL    InitBOB
  63.     tst.w    d0
  64.     bne.s    .Error_BOB
  65.  
  66.     lea    SND_Rambo(pc),a0
  67.     CALL    InitSound
  68.     tst.w    d0
  69.     bne.s    .Error_Sound
  70.  
  71.     lea    Screen(pc),a0
  72.     CALL    ShowScreen
  73.  
  74.     bsr.s    Main
  75.  
  76. .ReturnToDOS
  77.     move.l    GMS_Base(pc),a6
  78.     lea    SND_Rambo(pc),a0
  79.     CALL    FreeSound
  80. .Error_Sound
  81.     lea    BOB_Rambo(pc),a1
  82.     CALL    FreeBOB
  83. .Error_BOB
  84.     lea    PIC_Bobs(pc),a1
  85.     CALL    FreePic
  86. .Error_BOBPic
  87.     lea    PIC_Background(pc),a1
  88.     CALL    FreePic
  89. .Error_Picture
  90.     lea    Screen(pc),a0
  91.     CALL    DeleteScreen
  92. .Error_Screen
  93.     CALL    FreeAudio
  94. .Error_Audio
  95.     CALL    FreeBlitter
  96. .Error_Blitter
  97.     move.l    GMS_Base(pc),a1
  98.     move.l    ($4).w,a6
  99.     CALL    CloseLibrary
  100. .Error_GMS
  101.     MOVEM.L    (SP)+,A0-A6/D1-D7
  102.     moveq    #$00,d0
  103.     rts
  104.  
  105. ;===========================================================================;
  106. ;                                MAIN LOOP
  107. ;===========================================================================;
  108.  
  109. SPEED    =    5
  110. FIRESPEED =    1
  111.  
  112. Main:    move.l    GMS_Base(pc),a6
  113.     CALL    InitJoyPorts
  114.     moveq    #$00,d7
  115.  
  116. .Loop    lea    Screen(pc),a0
  117.     lea    BOB_Rambo(pc),a1
  118.     move.w    #BUFFER1,d0
  119.     CALL    ClearBOB    ;Blit the bob.
  120.     CALL    WaitSVBL    ;Wait for VBL.
  121.     CALL    SwapBuffers
  122.     addq.w    #1,d7
  123.  
  124.     tst.b    FireState
  125.     bne.s    .FireOn
  126.  
  127.     cmp.w    #SPEED,d7
  128.     ble.s    .Move
  129.     moveq    #$00,d7
  130.     addq.w    #1,BOB_Frame(a1)
  131.     cmp.w    #9,BOB_Frame(a1)
  132.     blt.s    .Move
  133.     clr.w    BOB_Frame(a1)
  134.     bra.s    .Move
  135.  
  136. .FireOn    cmp.w    #FIRESPEED,d7
  137.     ble.s    .Move
  138.     moveq    #$00,d7
  139.     cmp.w    #10,BOB_Frame(a1)
  140.     bge.s    .On
  141.     move.w    #9,BOB_Frame(a1)
  142.  
  143. .On    addq.w    #1,BOB_Frame(a1)
  144.     cmp.w    #13,BOB_Frame(a1)
  145.     blt.s    .Move
  146.  
  147.     lea    SND_Rambo(pc),a0
  148.     CALL    PlaySound
  149.  
  150.     btst    #MB_LMB,d0
  151.     beq.s    .Off
  152.     move.w    #11,BOB_Frame(a1)
  153.     bra.s    .Move
  154.  
  155. .Off    clr.w    BOB_Frame(a1)
  156.     clr.b    FireState
  157.  
  158. .Move    moveq    #JPORT1,d0    ;Read the mouse, then update the
  159.     moveq    #JT_ZBXY,d1    ;BOB's X and Y co-ordinates.
  160.     CALL    ReadJoyPort
  161.     move.w    d0,d1
  162.     ext.w    d0
  163.     add.w    d0,BOB_YPos(a1)
  164.     asr.w    #8,d1
  165.     add.w    d1,BOB_XPos(a1)
  166.  
  167.     btst    #MB_LMB,d0
  168.     beq.s    .chkRMB
  169.     st    FireState    ;Set fire to on.
  170. .chkRMB    btst    #MB_RMB,d0
  171.     beq    .Loop
  172.     rts
  173.  
  174. FireState:
  175.     dc.b    0
  176.     even
  177.  
  178. ;===========================================================================;
  179. ;                                  DATA
  180. ;===========================================================================;
  181.  
  182. GMS_Name:     dc.b  "games.library",0
  183.           even
  184. GMS_Base:     dc.l  0
  185.  
  186. AMT_PLANES =    5
  187.  
  188. Screen:    dc.l    GSV1,0    ;Structure version.
  189.     dc.l    0,0,0    ;Screen_Mem1/2/3
  190.     dc.l    0    ;Screen link.
  191.     dc.l    0    ;Address of screen palette.
  192.     dc.l    0    ;Address of rasterlist.
  193.     dc.l    0    ;Amt of colours in palette.
  194.     dc.w    320,256    ;Screen Width and Height.
  195.     dc.w    320,320/8,256    ;Picture Width and Height.
  196.     dc.w    AMT_PLANES    ;Amt of planes.
  197.     dc.w    0,0    ;X/Y screen offset.
  198.     dc.w    0,0    ;X/Y picture offset.
  199.     dc.l    0    ;Special attributes.
  200.     dc.w    LORES|COL12BIT    ;Screen Mode.
  201.     dc.w    PLANAR    ;Screen Type
  202.     even
  203.  
  204. PIC_Background:
  205.     dc.l    PCV1,0    ;Version header.
  206.     dc.l    0    ;Source data.
  207.     dc.w    320,320/8,256    ;Width, Height.
  208.     dc.w    AMT_PLANES    ;Amount of Planes.
  209.     dc.l    0    ;Amount of colours.
  210.     dc.l    0    ;Source palette (remap).
  211.     dc.w    LORES|COL12BIT    ;Screen mode.
  212.     dc.w    PLANAR    ;Destination
  213.     dc.l    GETPALETTE    ;Parameters.
  214.     dc.l    .File
  215. .File    dc.b    "GAMESLIB:data/IFF.Pic320",0
  216.     even
  217.  
  218. ;---------------------------------------------------------------------------;
  219.  
  220. PIC_Bobs:
  221.     dc.l    PCV1,0    ;Version header.
  222.     dc.l    0    ;Source data.
  223.     dc.w    0,0,0    ;Width, Height.
  224.     dc.w    AMT_PLANES    ;Amount of Planes.
  225.     dc.l    0    ;Amount of colours.
  226.     dc.l    0    ;Source palette.
  227.     dc.w    LORES|COL12BIT    ;Screen mode.
  228.     dc.w    PLANAR    ;Destination
  229.     dc.l    VIDEOMEM    ;Parameters.
  230.     dc.l    .File
  231. .File    dc.b    "GAMESLIB:data/IFF.Rambo",0
  232.     even
  233.  
  234. BOB_Rambo:
  235.     dc.l    BBV1,0    ;Structure version.
  236.     dc.w    0    ;Current frame.
  237.     dc.l    0,0    ;Graphics data.
  238.     dc.l    .Frames    ;Pointer to frame list.
  239.     dc.w    0    ;Modulo (skip in source) in bytes.
  240.     dc.w    32,32/8,24    ;Width, Width in bytes, Height.
  241.     dc.w    66,66    ;X/Y destination.
  242.     dc.w    0,32    ;Border restriction LeftX,TopY.
  243.     dc.w    0,256-32    ;Border restrictions RightX,EndY.
  244.     dc.w    0,5    ;Amount of planes.
  245.     dc.l    0    ;Size of plane, not required.
  246.     dc.l    CLRMASK|GENMASKS|CLIP    ;Attributes.
  247.     dc.l    PIC_Bobs    ;Picture struct (Bob origin).
  248. .Frames    dc.w    000,000,0,0    ;0 X/Y Graphic, X/Y Mask
  249.     dc.w    032,000,0,0    ;1 ...
  250.     dc.w    064,000,0,0    ;2
  251.     dc.w    096,000,0,0    ;3
  252.     dc.w    128,000,0,0    ;4
  253.     dc.w    160,000,0,0    ;5
  254.     dc.w    192,000,0,0    ;6
  255.     dc.w    224,000,0,0    ;7
  256.     dc.w    256,000,0,0    ;8
  257.     dc.w    288,000,0,0    ;9
  258.     dc.w    000,048,0,0    ;10
  259.     dc.w    032,048,0,0    ;11
  260.     dc.w    064,048,0,0    ;12
  261.     dc.l    -1
  262.  
  263. SND_Rambo:
  264.     dc.l    SMV1,0    ;Structure version.
  265.     dc.w    CHANNEL1    ;Channel to play through.
  266.     dc.w    0    ;Priority.
  267.     dc.l    0    ;Sample header
  268.     dc.l    0    ;Sample address.
  269.     dc.l    0    ;Sample length.
  270.     dc.w    OCT_C2S    ;Sample period.
  271.     dc.w    100    ;Sample volume.
  272.     dc.l    0    ;Sound attributes.
  273.     dc.l    .File    ;Sound file.
  274. .File    dc.b    "GAMESLIB:data/SND.Rambo",0
  275.     even
  276.  
  277. ;---------------------------------------------------------------------------;
  278.  
  279.