![]() |
aplib decompressor for ZX Basic. - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: How-To & Tutorials (https://www.boriel.com/forum/forumdisplay.php?fid=13) +---- Thread: aplib decompressor for ZX Basic. (/showthread.php?tid=484) Pages:
1
2
|
aplib decompressor for ZX Basic. - na_th_an - 08-02-2012 1. Download the compressor -> <!-- m --><a class="postlink" href="http://www.mojontwins.com/warehouse/apack.zip">http://www.mojontwins.com/warehouse/apack.zip</a><!-- m --> 2. Pack your binaries using it: Code: > apack.exe input.bin output.bin Code: packed: Code: #include once "aplib.bas" Code: aplibUnpack (@packed, 16384) Here's aplib.bas: Code: '' aplib.bas Happy coding! Re: aplib decompressor for ZX Basic. - slenkar - 08-02-2012 do you have an example? What kind of data can be packed? (bytes,ints,strings?) Re: aplib decompressor for ZX Basic. - boriel - 08-02-2012 This will be in the ZX Library. May I bundle it with the compiler? :?: If so, in the Mojon Twins directory? Re: aplib decompressor for ZX Basic. - slenkar - 08-02-2012 how does someone know where to unpack a bin? How do I know where there is empty space in RAM? Re: aplib decompressor for ZX Basic. - na_th_an - 08-03-2012 You can pack whatever binary data. how does someone know where to unpack a bin? - You unpack it where you need it to be. For example, you can pack a .scr picture (6912 bytes usually compress to under 3 Kb, and even less if the screen is not very complex: I've gotten ~500 bytes for a logo or a frame) and then unpack it to 16384 to display it. You can pack your map data, and have several maps stored in memory, and then unpack the current level to your reserved space. For example, say that you are using rectangular maps for 4x4 screens of 15x10 tiles each. Your map would be a 4x4x15x10=2400 bytes binary. You have to store somewhere, and have several compressed maps (depending on map complexity, you can save quite a bunch of bytes: Code: Sub mapContainer () To unpack level1 and use it, just... Code: ' unpack level 1: Then your engine reads the current level map data from @mapdata. When the player finished level 1 and level 2 is needed, you just unpack from @level2 to @mapdata and you have a brand new map. Stuff like that. I use it all the time for almost everything. As for examples, I have to clean up the source code of this game, which I hope to be sharing with you all very soon - and you'll have a working example (the logo and the backdrop are compressed images). @Boriel: do as you wish - but the code is not mine, I just interfaced it. I'm releasing a 128K version soon - an easy way to use the extra RAM pages to store data - like some kind of "virtual storage". We use this for our 128K games in C: several levels, tilesets, and spritesets are stored compressed in the extra RAM. Mapdata, tileset and spriteset for the current level are decompressed from there to low ram buffers when entering a level. Afterwards, the game behaves like a 48K game. It's a good solution which works great and helps you avoid multi-loads ![]() Re: aplib decompressor for ZX Basic. - slenkar - 08-04-2012 thanks for the explanation, how is @mapdata first defined? is it an array,a memory address? and how do you turn all those bytes into a BIN file? Re: aplib decompressor for ZX Basic. - britlion - 08-04-2012 I've used the compressor in the zx basic library to do the same thing. ( <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:MegaLZ.bas">http://www.boriel.com/wiki/en/index.php ... MegaLZ.bas</a><!-- m --> ) - it works exactly the same way. I'll have to compare and see if this one squishes better, or runs faster ![]() Slenkar: What you do is compress the data outside an emulator. For example, one game I'm working on (it may even get finished one day) puts up 1/3 of the screen banner graphics by decompressing to the screen memory. 1/3 of the screen is a handy size, because 2K of data fits there neatly, so it's just like doing a full screen in effect. How do I do that? Well, I design the screen in a graphics package, and when it's together I test it on an emulated spectrum to make sure it looks right. Then, in spin, I export the data from 16384 (the screen memory) for 2K to a file. I then compress this file with megalz using a command prompt on my PC. Na_th_an's aplib works the same way, but obviously it's different code. Then you can #include the compressed code inside an asm context, and add in the decompressor code, and voila - zipped up graphics. Re: aplib decompressor for ZX Basic. - britlion - 08-04-2012 na_th_an Wrote:1. Download the compressor -> <!-- m --><a class="postlink" href="http://www.mojontwins.com/warehouse/apack.exe">http://www.mojontwins.com/warehouse/apack.exe</a><!-- m --> I don't think this link is working, Na_th_an? Re: aplib decompressor for ZX Basic. - slenkar - 08-04-2012 britlion Wrote:I've used the compressor in the zx basic library to do the same thing. ( <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:MegaLZ.bas">http://www.boriel.com/wiki/en/index.php ... MegaLZ.bas</a><!-- m --> ) - it works exactly the same way. I'll have to compare and see if this one squishes better, or runs faster yes graphics packages export to BIN thankfully, but like what about some level data like a bunch of bytes how do I get the BIN file? Re: aplib decompressor for ZX Basic. - LCD - 08-05-2012 slenkar Wrote:yes graphics packages export to BIN thankfully, but like what about some level data like a bunch of bytesWhat do you use to create levels? Does it have binary export? Re: aplib decompressor for ZX Basic. - slenkar - 08-05-2012 I would probably input the numbers manually or make a tool myself Re: aplib decompressor for ZX Basic. - LCD - 08-05-2012 slenkar Wrote:I would probably input the numbers manually or make a tool myselfThen you can use: Code: label: Re: aplib decompressor for ZX Basic. - slenkar - 08-05-2012 If I input the number into the .bas file like this Code: label: it wont be compressed, I have to somehow make a BIN file out of these numbers to run through the compressor Re: aplib decompressor for ZX Basic. - LCD - 08-05-2012 slenkar Wrote:If I input the number into the .bas file like thisNot if you use the BorIDE's build in MegaLZ compressor... After you enter these and are happy with level design, select all the DEFB Statements and select "Edit" -> "DEFB Modificaton" -> "MegaLZ Compression". This will replace all DEFB with compressed version. I will add ApLib compression later too. Re: aplib decompressor for ZX Basic. - britlion - 08-05-2012 Boride gets better and better. Going to add in aplib support too? ![]() Slenkar - you can still do it by hand. Compile the defb statements in, run spin, load the file, export the bin file out from the right address. You can use the debugger to find out where it is if you can't work that out. Done. |