home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / misc / grime_v12.lha / source / Example.Amos / Example.amosSourceCode
Encoding:
AMOS Source Code  |  1994-11-20  |  2.5 KB  |  114 lines

  1. ' Example AMOS routines for using GRIME Maps 
  2. '
  3. '
  4. '
  5. '
  6. '
  7. ' Load the map data (GRIME format) into an AMOS bank 
  8. '
  9. A$="GRIME:Maps/newcheesey.grime"
  10. Open In 1,A$ : L=Lof(1) : Close 1
  11. Reserve As Work 10,L
  12. Bload A$,Start(10)
  13.  
  14. '
  15. ' Load a block screen (IFF) into an AMOS screen
  16. '
  17. Load Iff "GRIME:IFFs/cheeseygrimegrafx.iff",0
  18. Screen Hide 0
  19.  
  20. '
  21. ' Open an AMOS screen to draw our map onto 
  22. '
  23. Screen Open 1,320,256,8,Lowres
  24. Curs Off : Paper 0 : Flash Off : Cls 0
  25. Get Palette 0
  26.  
  27. '
  28. ' Make these variables global so that we can get the information from a
  29. ' GRIME map using the _GETGRIMEINFO routine
  30. '
  31. Global BLOCKX,BLOCKY,MAPX,MAPY,BASE_BLOCK
  32. Global HEADEROFFSET,POSY,POSX
  33. HEADEROFFSET=20
  34.  
  35. '
  36. ' Grab the information from the GRIME header and display it for the user 
  37. '
  38. _GETGRIMEINFO[10]
  39. Print "Information for current Map..."
  40. Print : Print "Blocks are ";BLOCKX;" x ";BLOCKY
  41. Print "Map is ";MAPX;" x ";MAPY
  42. Print "Base Block is ";BASE_BLOCK
  43. Print : Print "Press a key to view map"
  44. Wait Key 
  45.  
  46. '
  47. ' Display the map on the screen using different offsets within the map 
  48. '
  49. POSX=0 : POSY=0 : DISPLAYMAP
  50. Wait 20
  51. POSX=10 : POSY=0 : DISPLAYMAP
  52. Wait 20
  53. POSX=0 : POSY=12 : DISPLAYMAP
  54. Wait 20
  55. POSX=10 : POSY=12 : DISPLAYMAP
  56.  
  57.  
  58. '
  59. ' Procedures.....
  60. '
  61.  
  62. Procedure DISPLAYMAP
  63.  
  64.    '
  65.    ' Make sure we are in the correct drawing mode and grab the screen width 
  66.    ' of the block screen (Needed for calculations in the main loop
  67.    '
  68.    Gr Writing 0 : Ink 0
  69.    SCRW=Screen Width(0)
  70.  
  71.    '
  72.    ' Our Loop for displaying the map
  73.    '
  74.    For Y=0 To 7
  75.       For X=0 To 9
  76.          '
  77.          ' Get the block number for this map position 
  78.          '
  79.          '           Map Base   Header       Y Position       X Position
  80.          BLOCK=Deek(Start(10)+HEADEROFFSET+((((POSY+Y)*MAPX)+(POSX+X))*2))
  81.  
  82.          '
  83.          ' Calculate the position of this block on our block screen 
  84.          '
  85.          GRPHX=BLOCK*BLOCKX : GRPHY=0
  86.          While GRPHX+BLOCKX>SCRW
  87.             Add GRPHY,BLOCKY
  88.             Add GRPHX,-SCRW
  89.          Wend 
  90.  
  91.          '
  92.          ' Now copy from the block screen onto our map screen 
  93.          '
  94.          Screen Copy 0,GRPHX,GRPHY,GRPHX+BLOCKX,GRPHY+BLOCKY To 1,X*BLOCKX,Y*BLOCKY
  95.  
  96.          '
  97.          ' This provides a number overlay (Just like GRIME :) 
  98.          '
  99.          Text X*BLOCKX,Y*BLOCKY+8,Str$(BLOCK)
  100.  
  101.       Next X
  102.    Next Y
  103. End Proc
  104.  
  105. Procedure _GETGRIMEINFO[MAP]
  106.    '
  107.    ' Grab some information from the GRIME header
  108.    '
  109.    BLOCKX=Deek(Start(MAP)+6)
  110.    BLOCKY=Deek(Start(MAP)+8)
  111.    MAPX=Deek(Start(MAP)+10)
  112.    MAPY=Deek(Start(MAP)+12)
  113.    BASE_BLOCK=Deek(Start(MAP)+14)
  114. End Proc