home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / Asm / UsingObjects / OBJScreen.s next >
Encoding:
Text File  |  1997-02-04  |  4.2 KB  |  146 lines

  1. ;-------T-------T------------------------T---------------------------------;
  2. ;Open a screen using an external OBJect file.
  3. ;--------------------------------------------
  4. ;This demo will open a screen, based on the parameters in an external object
  5. ;file.  This allows a VERY high level of external editing that will alter
  6. ;how this program behaves, without having to reassemble it.
  7. ;
  8. ;This feature is highly important as it allows up to 100% configurability of
  9. ;your game, which previously has only been available to applications using
  10. ;libraries such as MUI.  However, it is even more powerful than this as
  11. ;graphic artists could not only create new datasets for your game, but also
  12. ;alter the dimensions, colours, resolution, attributes (and more) of your
  13. ;BOBs and screens.  Support for PC relative CODE segments is also available,
  14. ;so any external functions could be altered and improved by programmers.
  15. ;This will ensure that your game has a long lasting future as it keeps up
  16. ;with current technology and additions to GMS.
  17. ;
  18. ;To see the object data, view OBJScreenData.s
  19.  
  20.     INCDIR    "INCLUDES:"
  21.     INCLUDE    "exec/exec_lib.i"
  22.     INCLUDE    "games/games_lib.i"
  23.     INCLUDE    "games/games.i"
  24.  
  25. CALL    MACRO
  26.     jsr    _LVO\1(a6)
  27.     ENDM
  28.  
  29.     SECTION    "Objects!",CODE
  30.  
  31. ;===========================================================================;
  32. ;                             INITIALISE DEMO
  33. ;===========================================================================;
  34.  
  35. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  36.     move.l    ($4).w,a6
  37.     lea    GMS_Name(pc),a1
  38.     moveq    #$00,d0
  39.     CALL    OpenLibrary
  40.     move.l    d0,GMS_Base
  41.     beq    .Error_GMS
  42.  
  43.     move.l    GMS_Base(pc),a6
  44.     sub.l    a0,a0
  45.     CALL    SetUserPrefs
  46.  
  47. ;---------------------------------------------------------------------------;
  48. ;Load in the objects file and get pointers to the structures that we need.
  49.  
  50.     lea    OBJ_FileName(pc),a0    ;a0 = Object FileName.
  51.     CALL    LoadObjectFile    ;>> = Go and load them.
  52.     move.l    d0,OBJ_Base    ;MA = Save the Object Base.
  53.     beq    .Error_ObjectFile    ;>> = If error.
  54.  
  55.     move.l    OBJ_Base(pc),a0    ;a0 = Object Base.
  56.     lea    TXT_ScreenName(pc),a1    ;a1 = The name of the screen to get.
  57.     CALL    GetObject    ;>> = Get our GameScreen object.
  58.     move.l    d0,Screen    ;MA = Save pointer to screen struct.
  59.     beq.s    .Error_Objects    ;>> = Quit if error.
  60.  
  61.     lea    TXT_PictureName(pc),a1    ;a1 = The name of the picture to get.
  62.     CALL    GetObject    ;>> = Get our Picture object.
  63.     move.l    d0,Picture    ;MA = Save pointer to picture struct.
  64.     beq.s    .Error_Objects    ;>> = Quit if error.
  65.  
  66. ;---------------------------------------------------------------------------;
  67. ;Now initialise the two structures and display the picture.
  68.  
  69.     move.l    Picture(pc),a1
  70.     CALL    LoadPic
  71.     tst.w    d0
  72.     bne.s    .Error_Picture
  73.  
  74.     move.l    Screen(pc),a0
  75.     move.w    PIC_Width(a1),GS_PicWidth(a0)
  76.     move.w    PIC_Height(a1),GS_PicHeight(a0)
  77.     move.w    PIC_Planes(a1),GS_Planes(a0)
  78.     move.l    PIC_ScrMode(a1),GS_ScrMode(a0)
  79.     move.w    PIC_ScrType(a1),GS_ScrType(a0)
  80.     move.l    PIC_Data(a1),GS_MemPtr1(a0)
  81.     move.l    PIC_Palette(a1),GS_Palette(a0)
  82.     CALL    AddScreen
  83.     tst.l    d0
  84.     bne.s    .Error_Screen
  85.  
  86.     CALL    ShowScreen
  87.  
  88. .loop    CALL    WaitSVBL
  89.     moveq    #JPORT1,d0
  90.     CALL    ReadMouse
  91.     btst    #MB_LMB,d0
  92.     beq.s    .loop
  93.  
  94. ;===========================================================================;
  95. ;                                  RETURN TO DOS
  96. ;===========================================================================;
  97.  
  98. .ReturnToDOS
  99.     move.l    GMS_Base(pc),a6
  100.     move.l    Picture(pc),a1
  101.     CALL    FreePic
  102. .Error_Picture
  103.     move.l    Screen(pc),a0
  104.     CALL    DeleteScreen
  105. .Error_Screen
  106. .Error_Objects
  107.     move.l    OBJ_Base(pc),a0
  108.     CALL    FreeObjectFile
  109. .Error_ObjectFile
  110.     move.l    GMS_Base(pc),a1
  111.     move.l    ($4).w,a6
  112.     CALL    CloseLibrary
  113. .Error_GMS
  114.     MOVEM.L    (SP)+,A0-A6/D1-D7
  115.     moveq    #$00,d0
  116.     rts
  117.  
  118. ;===========================================================================;
  119. ;                                  DATA
  120. ;===========================================================================;
  121.  
  122. GMS_Name:
  123.     dc.b    "games.library",0
  124.     even
  125. GMS_Base:
  126.     dc.l    0
  127.  
  128. Screen:  dc.l    0
  129. Picture: dc.l    0
  130.  
  131. ;===========================================================================;
  132. ;                                 OBJECT FILE DATA
  133. ;===========================================================================;
  134.  
  135. TXT_ScreenName:
  136.     dc.b    "DemoScreen",0
  137.     even
  138. TXT_PictureName:
  139.     dc.b    "DemoPicture",0
  140.     even
  141.  
  142. OBJ_FileName:
  143.     dc.b  "GAMESLIB:data/OBJ.Screen"
  144. OBJ_Base:
  145.     dc.l    0
  146.