March 01, 2021, 10:51:12 PM

Author Topic: [bb] Cache Map / Edge Update Scroller by Dr Derek Doctors [ 1+ years ago ]  (Read 452 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : Cache Map / Edge Update Scroller
Author : Dr Derek Doctors
Posted : 1+ years ago

Description : Okay, well most of the description is in the comments of the code but basically this is a fast bit of code which trades memory for speedy tilemap scrolling. Instead of spending a bunch of your frame time redrawing the same background as loads of tiles it uses several HUGE blits instead which is a lot faster. Also when you scroll it only updates the edges of the screen in the cached bitmap and so it maintains a very good performance. Aw hell, read the code already...

Code :
Code: BlitzBasic
  1. ; Cache Map - Copyright 2003 - Graham Goring (AKA Dr Derek Doctors)
  2.  
  3. ; For lovely smooth scrolling when using titchy tiles with none of the horrid processor overhead associated with a bazillion
  4. ; blit instructions.
  5.  
  6. ; The reason I wrote this code was because I was writing a scrolling game which had 16x16 pixel tiles in it and it was
  7. ; taking a good few milliseconds just to draw a single layer of the screen. With something like 5 layers I was chewing up
  8. ; all of my frame time on something that I didn't even want to spend a tenth of that time on. And so I realised that
  9. ; I could save a lot of time at the expense of a little memory if I dumped the tiles I drew into a dummy image and then
  10. ; just drew that every frame, updating the contents of that image whenever I scrolled. However you can't have images wider
  11. ; than the screen with some video cards and so getting it all to fit into an image that's precisely the size of the screen
  12. ; when you've got fractions of tiles meant I had to do a bit of thinking and ask a few colleagues what they'd recommend.
  13.  
  14. ; Anyhoo, this is what I came up with and it works a treat. During normal operation I can happily draw 4 layers of 16x16
  15. ; tiles in about a millisecond on my home PC. It obviously slows down a bit when you scroll the screen, but unless I
  16. ; moved the screen by more than a few tiles every frame (which is VERY fast) then it didn't tick over the 2 milliseconds mark.
  17.  
  18. ; And so, in a display of generosity and goodwill I share this code with everyone else in Blitz land, so that you might
  19. ; produce a game which runs happily on a P2-300 instead of an Athlon 1.2Ghz T-bird.
  20.  
  21. ; The dependancies of this code is that your map array has at least 3 dimensions, those being x and y, naturally, and
  22. ; also a layer. Now it might well be that you don't want multiple map layers in your game (what? no parallax?! For shame!)
  23. ; so just DIM the array as "map (width,height,0)" and the functions won't need altering at all. Alternatively you could
  24. ; strip all the layer bumph out of this code, which should only entail buggering about with the "CMAP_fill_boxes" function.
  25.  
  26. ; Note that all functions are prefixed with "CMAP_" and all arrays, constants and globals with "cm_" so that you don't
  27. ; get any conflicts. Unless you inexplicably chose to prefix your own stuff with this, too, in which case all I can say
  28. ; is "Woooh! S-s-spooky!".
  29.  
  30. ; Oh, and it only uses square tiles. You could adapt it to rectangular ones I expect, but what the hell would you be using
  31. ; those for?! And you can't have maps smaller than the screen. Well, I don't think so. It'd probably fall over if you did.
  32.  
  33. ; Now, to get this working you'll need to pop over to the "CMAP_fill_boxes" function and alter the bit which draws the tiles
  34. ; to the screen so that it uses the correct image handle and also the tile array conforms to the name and format of your own
  35. ; one. Also note if you're using offset tiles (ie, tiles can be drawn off-grid to allow for more organic levels) then the
  36. ; there's a little bit of overdraw built into the routine to allow for this, but you should only be offsetting your tiles
  37. ; down-right (which is easist, anyway).
  38.  
  39. ; After that just replace the 6 ?'s below with suitable values or constants.
  40.  
  41. ; To set up a map layer, simply call "CMAP_create_layer" followed by "CMAP_initialise_layer" with the attendant parameters. Look at
  42. ; the functions for more of an explanation.
  43.  
  44. ; Then you just need to call "CMAP_scroll_display" for each layer with the distances that they've moved every frame, then
  45. ; just "CMAP_blit" each layer (note that you can supply a pair of offsets to the bltting routine if you have a panel at the top or
  46. ; left of the screen).
  47.  
  48. ; Note that all the functions are called on a layer by layer basis so if you have 3 layers you'll need to call it 3 times for
  49. ; layers 0, 1 and 2 with the appropriate parameters. I didn't want to automate this at all with parallax code built in so
  50. ; that you were free to do whatever you liked with the layers.
  51.  
  52. ; There are no restrictions for the use of this code, however I completely wash my hands of it if you manage to blow up
  53. ; your computer due to it's sheer excellence or bizarrely murder someone as a result of using it. You may change it as you
  54. ; wish however I ask that you give me a credit for the code if you ever release anything using it (in fact if you make
  55. ; something commercial with it I *insist* on a credit because I ain't getting any wonga out of the deal) and that you
  56. ; don't redistribute it or claim that you wrote it. If you do I'll squeeze your head until it pops like a water balloon full
  57. ; of liquefied meat.
  58.  
  59. ; Oh, in case you're wondering what all the references to "offset tiles" means, it's when you have a pair of values in
  60. ; the map array for each tile which say how far it's offset from it's default position (usually it's a value from 0 to TILESIZE-1)
  61. ; on each axis. To be honest, it's not often used because it's easy to carve odd holes in your map with it, but it can
  62. ; have its applications.
  63.  
  64. Const cm_map_width = ? ; width of the map array in tiles - probably be set to another constant in your own code
  65. Const cm_map_height = ? ; height of the map array in tiles - probably be set to another constant in your own code
  66.  
  67. Const cm_max_cache_map_layers = ? ; this is the number of layers in the cache map minus one (because arrays start at 0)
  68. Const cm_display_width = ? ; this is the width of the display and must be a multiple of the tilesize or it all goes kerplooey
  69. Const cm_display_height = ? ; this is the height of the display and must be a multiple of the tilesize or it all goes kerplooey
  70.  
  71. Const cm_tilesize = ? ; this is the width and height of the tiles in your tileset.
  72.  
  73. Type cm_box
  74.         Field tlx,tly,width,height,tilex,tiley
  75. End Type
  76.  
  77. Type cm_cachemapglobals
  78.         Field x_divider [cm_max_cache_map_layers] ; this and the below variable point to the vertical and horizontal dividers of the cache tilemap
  79.         Field y_divider [cm_max_cache_map_layers]
  80.         Field x_offset [cm_max_cache_map_layers] ; this and the below variable point to the position within the tilemap of the current top-left block of the image
  81.         Field y_offset [cm_max_cache_map_layers]
  82.         Field temp_x_offset [cm_max_cache_map_layers] ; this is used to store the old position of the offset and is very important. Least I think so...
  83.         Field temp_y_offset [cm_max_cache_map_layers]
  84.         Field img [cm_max_cache_map_layers] ; this is a table of pointers to images used to store the cached images
  85.         Field array_start_layer [cm_max_cache_map_layers] ; this is the start layer of the map array from which the tiles for this display layer are gotten from
  86.         Field array_end_layer [cm_max_cache_map_layers] ; and this is the end layer of same
  87. End Type
  88.  
  89. Global cm_cmg.cm_cachemapglobals = New cm_cachemapglobals ; this is the global structure which contains all the operating variables of the cache map functions
  90.  
  91. ;CMAP_create_layer (0,0,0) ; creates a layer which should be done for every layer at the start of the game taking the layer number,
  92.         ; the first and last array layers which contribute to the layer and three optional values for Red, Green and Blue
  93.         ; mask components. It defaults to bright pink (255,0,255)
  94.        
  95. ; After calling the create layer stuff for each display layer (remember each layer uses up a fair chunk of memory - if you're running in
  96. ; 16bit mode and at 640,480 then it'll use 600K) then you'll probably want to correct each of the cmgx_offset[layer] and cmgy_offset[layer]
  97. ; to point to the correct place for the start of your game and then refresh the screen using the relevant function (refresh_screen (layer))
  98.  
  99. ; Then it's just a case of keeping track of how far it scrolls in any direction and pushing the image appropriately. I'd suggest
  100. ; keeping an array like layer_positions (cm_max_cache_map_layers,1,1) where you store the x and y of each layer and the previous frames x and y
  101. ; too and then see how far it's changed and push away.
  102.  
  103.  
  104.  
  105. Function CMAP_scroll_display (x_push,y_push,layer)
  106.         ; This routine is called every frame with the distances you want to scroll the screen
  107.         ; on the x and y axis. It deals with horizontal and vertical movement separately to
  108.         ; avoid rogue blocks appearing. It took a little while to fix that bug down despite my
  109.         ; knowing exactly what was causing it from the outset. But then that's the joy of
  110.         ; programming, innit?
  111.        
  112.         ; Oh, except don't bother calling it if you've not moved the screen as it won't create any
  113.         ; boxes at all and will just be a waste of time.
  114.  
  115.         cm_cmg  emp_x_offset[layer] = cm_cmgx_offset[layer]
  116.         cm_cmg  emp_y_offset[layer] = cm_cmgy_offset[layer]
  117.         cm_cmgx_offset[layer] = cm_cmgx_offset[layer] + x_push
  118.         cm_cmgy_offset[layer] = cm_cmgy_offset[layer] + y_push
  119.  
  120.         If (x_push<>0)
  121.                 CMAP_push_horizontal(x_push,layer)
  122.                 CMAP_split_boxes()
  123.                 CMAP_fill_boxes(layer)
  124.         EndIf
  125.  
  126.         cm_cmgx_divider[layer] = (cm_cmgx_divider[layer] + x_push + cm_display_width) Mod cm_display_width
  127.         cm_cmg  emp_x_offset[layer] = cm_cmgx_offset[layer]
  128.  
  129.         If (y_push<>0)
  130.                 CMAP_push_vertical(y_push,layer)
  131.                 CMAP_split_boxes()
  132.                 CMAP_fill_boxes(layer)
  133.         EndIf
  134.  
  135.         cm_cmgy_divider[layer] = (cm_cmgy_divider[layer] + y_push + cm_display_height) Mod cm_display_height
  136.  
  137. End Function
  138.  
  139.  
  140.  
  141. Function CMAP_push_horizontal (x_push,layer)
  142.         ; This routine defines the necessary blocks to scroll the screen left or right. ie,
  143.         ; those areas of the screen which need to be redrawn to accomodate the new position
  144.         ; of the x_divider (the line which says where the left edge of the screen is in the
  145.         ; image "cm_cmgimg[layer]")
  146.  
  147.         If (x_push>0)
  148.                 b.cm_box = New cm_box
  149.                 b       lx = cm_cmgx_divider[layer]
  150.                 b       ly = cm_cmgy_divider[layer]
  151.                 bwidth = x_push
  152.                 bheight = cm_display_height
  153.                 b       ilex = cm_cmg   emp_x_offset[layer] + cm_display_width
  154.                 b       iley = cm_cmg   emp_y_offset[layer]
  155.         EndIf
  156.  
  157.         If (x_push<0)
  158.                 b.cm_box = New cm_box
  159.                 b       lx = cm_cmgx_divider[layer] + x_push
  160.                 b       ly = cm_cmgy_divider[layer]
  161.                 bwidth = Abs (x_push)
  162.                 bheight = cm_display_height
  163.                 b       ilex = cm_cmgx_offset[layer]
  164.                 b       iley = cm_cmg   emp_y_offset[layer]
  165.         EndIf  
  166.        
  167. End Function
  168.  
  169.  
  170.  
  171. Function CMAP_push_vertical (y_push,layer)
  172.         ; This routine defines the necessary blocks to scroll the screen up or down. ie,
  173.         ; those areas of the screen which need to be redrawn to accomodate the new position
  174.         ; of the y_divider (the line which says where the top edge of the screen is in the
  175.         ; image "cm_cmgimg[layer]").
  176.  
  177.  
  178.         If (y_push>0)  
  179.                 b.cm_box = New cm_box
  180.                 b       ly = cm_cmgy_divider[layer]
  181.                 b       lx = cm_cmgx_divider[layer]
  182.                 bheight = y_push
  183.                 bwidth = cm_display_width
  184.                 b       iley = cm_cmg   emp_y_offset[layer] + cm_display_height
  185.                 b       ilex = cm_cmg   emp_x_offset[layer]
  186.         EndIf
  187.        
  188.         If (y_push<0)
  189.                 b.cm_box = New cm_box
  190.                 b       ly = cm_cmgy_divider[layer] + y_push
  191.                 b       lx = cm_cmgx_divider[layer]
  192.                 bheight = Abs (y_push)
  193.                 bwidth = cm_display_width
  194.                 b       iley = cm_cmgy_offset[layer]
  195.                 b       ilex = cm_cmg   emp_x_offset[layer]
  196.         EndIf
  197.  
  198. End Function
  199.  
  200.  
  201.  
  202. Function CMAP_split_boxes ()
  203.         ; This routine moves those boxes which are completely outside the edge of the screen
  204.         ; so that they are within it, and also breaks those boxes which go over the edge of
  205.         ; the screen into two new boxes. It works recursively so as to chop up every last box
  206.         ; if necessary, though I suspect the recursive part of it really isn't necessary - I'm
  207.         ; just too scared to take it out... ;)
  208.        
  209.         Repeat
  210.        
  211.                 flag=0
  212.  
  213.                 For b.cm_box=Each cm_box
  214.        
  215.                         If ( (b lx < 0) And (b  lx+bwidth-1 < 0) ) Or ( (b      lx > cm_display_width-1) And (b lx+bwidth-1 > cm_display_width-1) )
  216.                                 b       lx=(b   lx+cm_display_width) Mod cm_display_width
  217.                                 flag=1
  218.                         EndIf
  219.                
  220.                         If ( (b ly < 0) And (b  ly+bheight-1 < 0) ) Or ( (b     ly > cm_display_width-1) And (b ly+bheight-1 > cm_display_width-1) )
  221.                                 b       ly=(b   ly+cm_display_height) Mod cm_display_height
  222.                                 flag=1
  223.                         EndIf
  224.                
  225.                         If (b   lx < 0) ; box starts off the left edge of screen
  226.                                 b       lx=b    lx+cm_display_width ; bumps it forward so the next line catches it. Easier for me. :)
  227.                         EndIf
  228.                
  229.                         If (b   lx+bwidth > cm_display_width) ; box goes off right edge of screen
  230.                                 a.cm_box = New cm_box
  231.                                 a       lx = 0
  232.                                 a       ly = b  ly
  233.                                 awidth = (b     lx + bwidth) - cm_display_width
  234.                                 aheight = bheight
  235.                                 bwidth = bwidth - awidth
  236.                                 a       iley = b        iley
  237.                                 a       ilex = b        ilex+bwidth
  238.                                 flag = 1
  239.                         EndIf
  240.                
  241.                         If (b   ly < 0) ; box starts off the top edge of screen
  242.                                 b       ly=b    ly+cm_display_height ; bumps it forward so the next line catches it. Easier for me. :)
  243.                         EndIf
  244.                
  245.                         If (b   ly+bheight > cm_display_height) ; box goes off bottom edge of screen
  246.                                 a.cm_box = New cm_box
  247.                                 a       ly = 0
  248.                                 a       lx = b  lx
  249.                                 aheight = (b    ly + bheight) - cm_display_height
  250.                                 awidth = bwidth
  251.                                 bheight = bheight - aheight
  252.                                 a       ilex = b        ilex
  253.                                 a       iley = b        iley+bheight
  254.                                 flag = 1
  255.                         EndIf
  256.                
  257.                 Next
  258.        
  259.         Until (flag=0)
  260.                
  261. End Function
  262.  
  263.  
  264.  
  265. Function CMAP_fill_boxes (layer)
  266.         ; This plonks the relevant tiles into the boxes defined by the other routines. You'll most likely need to alter
  267.         ; the line "DrawImage gfx_handle,xx*cm_tilesize,yy*cm_tilesize,map(tx,ty,l,0)" unless there's been an astounding
  268.         ; coincidence...
  269.  
  270.         SetBuffer ImageBuffer(cm_cmgimg[layer])
  271.        
  272.         For b.cm_box = Each cm_box
  273.        
  274.                 Viewport b      lx , b  ly , bwidth , bheight
  275.                
  276.                 Cls
  277.                
  278.                 For l=cm_cmgarray_start_layer [layer] To cm_cmgarray_end_layer [layer] ; comment out if no layers!
  279.                         For xx=(b       lx/cm_tilesize)-1 To ((b        lx+bwidth-1)/cm_tilesize)      
  280.                                 For yy=(b       ly/cm_tilesize)-1 To ((b        ly+bheight-1)/cm_tilesize)
  281.                                
  282.                                         tx=(b   ilex/cm_tilesize) + ( xx - (b   lx/cm_tilesize) )
  283.                                         ty=(b   iley/cm_tilesize) + ( yy - (b   ly/cm_tilesize) )
  284.                
  285.                                         If (tx>=0) And (ty>=0) And (tx<cm_map_width) And (ty<cm_map_height)
  286.                                                 DrawImage gfx_handle,xx*cm_tilesize,yy*cm_tilesize,map(tx,ty,l,0) ; alter this line to match the graphic handle and map array of your program
  287.                                         EndIf
  288.                                
  289.                                 Next
  290.                         Next
  291.                 Next ; comment out if no layers!
  292.        
  293.                 Delete b
  294.        
  295.         Next
  296.        
  297.         SetBuffer BackBuffer()
  298.  
  299. End Function
  300.  
  301.  
  302.  
  303. Function CMAP_refresh_tiles (x,y,width,height,layer)
  304.         ; This function is for when you want to refresh part of the display without the hassle
  305.         ; of re-drawing the whole caboodle - which is obviously what we wanted to avoid in writing
  306.         ; this whole damn shebang.
  307.         ; First of all it chops off any edges of the refreshed area that are outside the visible
  308.         ; screen and then it creates a "cm_box", which is passed through the regular splitting and
  309.         ; filling functions.
  310.        
  311.         ; A practical example of when you'd use this is when you blow up a tile in your game that's
  312.         ; currently on-screen. Unless you refresh that part of the display it won't actually disappear
  313.         ; despite your updating of the map array.
  314.        
  315.         ; In instances where you have offset tiles you'll obviously want to refresh a slightly larger box so that
  316.         ; offset tiles aren't chopped off, which would be a tragedy of immense proportions, possibly leading to
  317.         ; downfall of Rome (if that hasn't already happened).
  318.        
  319.         ; The variables passed to it are full-size world co-ordinates (ie, not divided by tilesize).
  320.        
  321.         If (x < cm_cmgx_offset[layer]) ; if the box starts off the left of the screen we need to chop that edge off of it.
  322.                 width = width - (cm_cmgx_offset[layer] - x)
  323.                 x = cm_cmgx_offset[layer]
  324.         EndIf
  325.  
  326.         If (y < cm_cmgy_offset[layer]) ; if the box starts off the top of the screen, chop!
  327.                 height = height - (cm_cmgy_offset[layer] - y)
  328.                 y = cm_cmgy_offset[layer]
  329.         EndIf
  330.  
  331.         If (x + width >= cm_display_width + cm_cmgx_offset[layer]) ; if it trails off the right of the screen...
  332.                 width = (cm_display_width + cm_cmgx_offset[layer]) - x
  333.         EndIf
  334.  
  335.         If (y + height >= cm_display_height + cm_cmgy_offset[layer]) ; if it trails off the bottom of the screen...
  336.                 height = (cm_display_height + cm_cmgy_offset[layer]) - y
  337.         EndIf
  338.  
  339.         If (width>0) And (height>0) And (x < cm_display_width + cm_cmgx_offset[layer]) And (y < cm_display_height + cm_cmgy_offset[layer]) ; if the box is actually anywhere on the screen
  340.  
  341.                 b.cm_box = New cm_box
  342.        
  343.                 b       ilex = x
  344.                 b       iley = y
  345.                 b       lx = (x - cm_cmgx_offset[layer]) + cm_cmgx_divider[layer]
  346.                 b       ly = (y - cm_cmgy_offset[layer]) + cm_cmgy_divider[layer]
  347.                 bwidth = width
  348.                 bheight = height
  349.        
  350.                 CMAP_split_boxes()
  351.                 CMAP_fill_boxes(layer)
  352.  
  353.         EndIf
  354.  
  355. End Function
  356.  
  357.  
  358.  
  359. Function CMAP_refresh_screen (layer)
  360.         ; Just a shorthand to make refreshing the whole screen easier for first timers.
  361.  
  362.         CMAP_refresh_tiles (cm_cmgx_offset[layer],cm_cmgy_offset[layer],cm_display_width,cm_display_height,layer)
  363.  
  364. End Function
  365.  
  366.  
  367.  
  368. Function CMAP_blit (layer,offsetx=0,offsety=0)
  369.         ; This plonks the contents of "img" to the screen at the right places, though the contents
  370.         ; of the "img" drawn as-is looks kinda' odd as it will appear to have been rolled in the x
  371.         ; and y axis.
  372.        
  373.         ; Try un-commenting the following line to see exactly how the screen display works and it'll
  374.         ; help you gain a better understanding of why this method of scrolling is so fast (you'll need
  375.         ; to comment out the four following lines as well or they'll just draw over it).
  376.        
  377. ;       DrawImageRect cmgimg[layer],0,0,0,0,screenwidth,screenheight
  378.  
  379.         DrawImageRect cm_cmgimg[layer] , offsetx , offsety , cm_cmgx_divider[layer] , cm_cmgy_divider[layer] , cm_display_width-cm_cmgx_divider[layer] , cm_display_height-cm_cmgy_divider[layer] ; bottom-right chunk of the screen
  380.        
  381.         DrawImageRect cm_cmgimg[layer] , (cm_display_width-cm_cmgx_divider[layer])+offsetx , (cm_display_height-cm_cmgy_divider[layer])+offsety , 0 , 0 , cm_cmgx_divider[layer] , cm_cmgy_divider[layer] ; top-left chunk of the screen
  382.  
  383.         DrawImageRect cm_cmgimg[layer] , offsetx , (cm_display_height-cm_cmgy_divider[layer])+offsety , cm_cmgx_divider[layer] , 0 , cm_display_width-cm_cmgx_divider[layer] , cm_cmgy_divider[layer] ; bottom-left chunk of the screen (I think)
  384.  
  385.         DrawImageRect cm_cmgimg[layer] , (cm_display_width-cm_cmgx_divider[layer])+offsetx , offsety , 0 , cm_cmgy_divider[layer] , cm_cmgx_divider[layer] , cm_display_height-cm_cmgy_divider[layer] ; top-right chunk of the screen (again, I think)
  386.  
  387. End Function
  388.  
  389.  
  390.  
  391. Function CMAP_clear_layer (layer)
  392.         ; Clear the given layer
  393.  
  394.         SetBuffer ImageBuffer(cm_cmgimg[layer])
  395.         Cls
  396.         SetBuffer BackBuffer()
  397.        
  398. End Function
  399.  
  400.        
  401.  
  402. Function CMAP_create_layer (layer,start_array,end_array,maskr=0,maskg=0,maskb=0)
  403.         ; Should be called to set up the globals. If you don't call it then a horrible monster will eat your eyes out.
  404.        
  405.         ; layer = The raster layer number
  406.         ; start_array = This is the first layer in the array where tiles for this layer are drawn from
  407.         ; end_array = This is the last layer in the array where tiles for this layer are drawn from
  408.         ; maskr, maskg and maskb are preset to bright pink and are the mask colours for this layer
  409.        
  410.         ; For instance, assume your map structure has 5 layers to it (numbered 0 to 4 naturally) and you want the third
  411.         ; drawn (rastered) layer (which in an array would be number 2) to contain a composite of map layers 2 to 4, with
  412.         ; preset mask colours, you'd call:
  413.        
  414.         ; CMAP_create_layer (2,2,4)
  415.  
  416.         cm_cmgx_divider [layer] = 0
  417.         cm_cmgy_divider [layer] = 0
  418.         cm_cmgx_offset [layer] = 0
  419.         cm_cmgy_offset [layer] = 0
  420.         cm_cmgarray_start_layer [layer] = start_array
  421.         cm_cmgarray_end_layer [layer] = end_array
  422.        
  423.         cm_cmgimg [layer] = CreateImage (cm_display_width, cm_display_height)
  424.         MaskImage cm_cmgimg[layer],maskr,maskg,maskb
  425.  
  426. End Function
  427.  
  428.  
  429.  
  430. Function CMAP_initialise_layer (layer,x,y)
  431.         ; This will erase the contents of a layer, set it's new position, reset the divider and then fill it with tiles again.
  432.         ; As with "CMAP_refresh_tiles" the co-ordinates are world co-ordinates.
  433.  
  434.         cm_cmgx_divider [layer] = 0
  435.         cm_cmgy_divider [layer] = 0
  436.         cm_cmgx_offset [layer] = x
  437.         cm_cmgy_offset [layer] = y
  438.  
  439.         CMAP_clear_layer (layer)
  440.         CMAP_refresh_screen (layer)
  441.  
  442. End Function
  443.  
  444.  
  445.  
  446. Function CMAP_destroy_layer (layer)
  447.         ; This will free up the memory used by the cached image for this layer. Call this function after Game Over so you haven't
  448.         ; got a few meg of images clogging up the RAM when you don't need them.
  449.  
  450.         If cm_cmgimg [layer] > 0
  451.                 FreeImage cm_cmgimg [layer]
  452.                 cm_cmgimg [layer] = 0
  453.         EndIf
  454.  
  455. End Function


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal