Re: A86: Saving Memory


[Prev][Next][Index][Thread]

Re: A86: Saving Memory




At 03:09 PM 11/15/98 -0500, you wrote:
>Hello,
>    I was working on Brix and thinking about this.. my maps in Brix are like
>this:
>
>Level:
>.db 1,1,1,1,1,1,1,1,1,1,1,1,1
>.db 1,1,1,1,1,1,1,1,1,1,1,1,1
> .db 1,1,1,1,1,1,1,1,1,1,1,1,1
> .db 1,1,1,1,1,1,1,1,1,1,1,1,1
> .db 1,1,1,1,1,1,1,1,1,1,1,1,1
> .db 1,1,1,1,1,1,1,1,1,1,1,1,1
> .db 1,1,1,1,1,1,1,1,1,1,1,1,1
> .db 1,1,1,1,1,1,1,1,1,1,1,1,1
>
>which is 88 bytes [8x11, 11 sprites horizontally..]  each number represents
>a sprite [ex. 1=block, 2=....]  there is a way to compress them, but I am
>not sure how to.. any suggestions? Thanks.
>-Ahmed

There are two different ways to compress your levels.  Both ways use a
buffer to extract the level into, but most of the time the program is made
smaller.  I personally like to use the PCX format to compress my levels
since it is easier to understand.  HUFFLIB (I think this is the right name)
compression is the other technique which is said to work better.  I've
never tested the library since it is not for the 82 platform (which is the
platform I use).  If you want to take the time to convert my PCX-like
loader over to the 86, then I'll send the code to you in its current state.
 I use a much more advanced loader system than what you need it for, but it
will work none-the-less.  Under the current code, your level would have to
look like this:

NumLevels:
.db 1

Level1:
.db 8, 8
.db 1,1,1,1,1,1,1,1,1,1,1,1,1
.db 1,1,1,1,1,1,1,1,1,1,1,1,1
.db 1,1,1,1,1,1,1,1,1,1,1,1,1
.db 1,1,1,1,1,1,1,1,1,1,1,1,1
.db 1,1,1,1,1,1,1,1,1,1,1,1,1
.db 1,1,1,1,1,1,1,1,1,1,1,1,1
.db 1,1,1,1,1,1,1,1,1,1,1,1,1
.db 1,1,1,1,1,1,1,1,1,1,1,1,1,255
.dw Level2
  ret

Level2:


I know the level is not compressed (I'm too lazy I guess), but you see why
you would need to change the code.  The current game engine that I'm
developing copies the level into the buffer (in this case it would be 8 * 8
= 64 bytes needed) and runs the code following the level (allows for easy
custom level development...notice the ret).  Well, I hope this helps.


                 Thomas J. Hruska -- thruska@tir.com
Shining Light Productions -- "Meeting the needs of fellow programmers"
         http://www.geocities.com/SiliconValley/Heights/8504
                    http://shinelight.home.ml.org


References: