home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / Asm / Screens / LoadPicture.s < prev    next >
Encoding:
Text File  |  1997-02-13  |  4.2 KB  |  169 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Load Picture
  3. ;------------
  4. ;This demo will load in a picture of any size/type and if it is larger than
  5. ;the screen width, it scrolls left and right.  This is easily possible due
  6. ;to the fact that GMS likes to fill in fields that have been set at zero
  7. ;on initialisation, which is great for loading/displaying things like
  8. ;pictures.
  9. ;
  10. ;The benefits of this will become more apparent when you want to do things
  11. ;like changing your graphics format from ECS to AGA and vice versa.  The
  12. ;benefits for the user are enormous (full graphical editing capabilities,
  13. ;if you program correctly).  And you don't even need to change a line of
  14. ;code!  Wow!
  15.  
  16.     INCDIR    "INCLUDES:"
  17.     INCLUDE    "exec/exec_lib.i"
  18.     INCLUDE    "games/games_lib.i"
  19.     INCLUDE    "games/games.i"
  20.  
  21. CALL    MACRO
  22.     jsr    _LVO\1(a6)
  23.     ENDM
  24.  
  25. SPEED    =    2
  26.  
  27.     SECTION    "LoadPicture",CODE
  28.  
  29. ;===========================================================================;
  30. ;                             INITIALISE DEMO
  31. ;===========================================================================;
  32.  
  33. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  34.     move.l    ($4).w,a6
  35.     lea    GMS_Name(pc),a1
  36.     moveq    #$00,d0
  37.     CALL    OpenLibrary
  38.     move.l    d0,GMS_Base
  39.     beq.s    .Error_GMS
  40.  
  41.     move.l    GMS_Base(pc),a6
  42.     sub.l    a0,a0
  43.     CALL    SetUserPrefs
  44.  
  45.     lea    Picture(pc),a1        ;Load picture into background.
  46.     CALL    GetPicInfo
  47.     tst.w    d0
  48.     bne.s    .Error_Picture
  49.     lea    Screen(pc),a0
  50.     move.w    PIC_Planes(a1),GS_Planes(a0)
  51.     move.w    PIC_Width(a1),GS_PicWidth(a0)
  52.     move.w    PIC_Height(a1),GS_PicHeight(a0)
  53.     move.l    PIC_AmtColours(a1),GS_AmtColours(a0)
  54.     move.w    PIC_ScrMode(a1),GS_ScrMode(a0)
  55.     move.w    PIC_ScrType(a1),GS_ScrType(a0)
  56.  
  57.     CALL    AddScreen
  58.     tst.l    d0
  59.     bne.s    .Error_Screen
  60.  
  61.     move.l    GS_MemPtr1(a0),PIC_Data(a1)
  62.     CALL    LoadPic
  63.  
  64.     CALL    ShowScreen
  65.  
  66.     bsr.s    Main    ;Go and do the main routine.
  67.  
  68. .ReturnToDOS
  69.     move.l    GMS_Base(pc),a6
  70.     lea    Screen(pc),a0
  71.     CALL    DeleteScreen
  72. .Error_Screen
  73.     lea    Picture(pc),a1
  74.     CALL    FreePic
  75. .Error_Picture
  76.     move.l    ($4).w,a6
  77.     move.l    GMS_Base(pc),a1
  78.     CALL    CloseLibrary
  79. .Error_GMS
  80.     MOVEM.L    (SP)+,A0-A6/D1-D7
  81.     moveq    #$00,d0
  82.     rts
  83.  
  84. ;===========================================================================;
  85. ;                                MAIN LOOP
  86. ;===========================================================================;
  87.  
  88. Main:    move.l    GMS_Base(pc),a6
  89.     lea    Screen(pc),a0
  90.     lea    Picture(pc),a2
  91.  
  92.     moveq    #0,d0    ;d0 = Initialise fader.
  93.     moveq    #2,d1    ;d1 = Speed of fade.
  94.     move.l    PIC_Palette(a2),a1
  95.     moveq    #$000000,d2
  96.     moveq    #0,d3
  97.     move.l    PIC_AmtColours(a2),d4
  98. .Fade1    CALL    WaitSVBL
  99.     CALL    ColourToPalette    ;Do the fade routine.
  100.     tst.w    d0    ;Has the fade finished yet?
  101.     bne.s    .Fade1    ;If not, keep doing it.
  102.  
  103.     lea    Picture(pc),a1
  104.     moveq    #0,d2
  105. .loop    CALL    WaitSVBL
  106.     move.w    GS_ScrWidth(a0),d0    ;Only scroll the picture if is is
  107.     lsr.w    #3,d0    ;bigger than the actual screen.
  108.     cmp.w    GS_PicWidth(a0),d0
  109.     bge.s    .done
  110.  
  111.     tst.w    d2
  112.     bgt.s    .Right
  113. .Left    tst.w    GS_PicXOffset(a0)
  114.     ble.s    .RRight
  115. .RLeft    moveq    #-SPEED,d2
  116.     bra.s    .scroll
  117. .Right    move.w    GS_PicWidth(a0),d0    ;d0 = PicWidth.
  118.     sub.w    #320,d0
  119.     cmp.w    GS_PicXOffset(a0),d0    ;d0 = Is (Width-320 < PicOffset)?
  120.     ble.s    .RLeft
  121. .RRight    moveq    #SPEED,d2
  122. .scroll    add.w    d2,GS_PicXOffset(a0)
  123.     CALL    MovePicture
  124.  
  125. .done    moveq    #JPORT1,d0    ;Port 1 (Mouse)
  126.     moveq    #JT_ZBXY,d1
  127.     CALL    ReadJoyPort
  128.     btst    #MB_LMB,d0
  129.     beq.s    .loop
  130.     rts
  131.  
  132. ;===========================================================================;
  133. ;                                  DATA
  134. ;===========================================================================;
  135.  
  136. GMS_Name:
  137.     dc.b    "games.library",0
  138.     even
  139. GMS_Base:
  140.     dc.l    0
  141.  
  142. Screen:    dc.l    GSV1,0    ;Version header.
  143.     dc.l    0,0,0    ;Screen Memory 1/2/3.
  144.     dc.l    0    ;Screen link.
  145.     dc.l    0    ;Address of palette
  146.     dc.l    0    ;Address of rasterlist.
  147.     dc.l    0    ;Amount of colours in palette.
  148.     dc.w    0,0    ;Screen Width, Height.
  149.     dc.w    0,0,0    ;Picture Widths, Height. 
  150.     dc.w    0    ;Amount of planes.
  151.     dc.w    0,0    ;Screen X/Y offset.
  152.     dc.w    0,0    ;Picture X/Y offset.
  153.     dc.l    HSCROLL    ;Special attributes.
  154.     dc.w    0    ;Screen mode.
  155.     dc.w    0    ;Screen type
  156.  
  157. Picture    dc.l    PCV1,0    ;Version header.
  158.     dc.l    0    ;Source data.
  159.     dc.w    0,0,0    ;Width/8, Height.
  160.     dc.w    0    ;Amount of Planes.
  161.     dc.l    0    ;Amount of colours.
  162.     dc.l    0    ;Palette.
  163.     dc.w    0    ;Screen mode.
  164.     dc.w    0    ;Screen type.
  165.     dc.l    VIDEOMEM|GETPALETTE|GETVMODE
  166.     dc.l    .File
  167. .File    dc.b    "GAMESLIB:data/IFF.Pic640x256",0
  168.     even
  169.