I'm trying to put a compressed image in my game menu but it doesn't work. What am I doing wrong?
1) I create the .scr image with ZXPaintbrush 2) I compress it with Lethargeek Kompakt compressor v1.1 and generate a .bin file 3) I convert the .bin to .tap with bin2tap. 4) I create the following test Basic loader:
10 CLEAR VAL "26999" 20 LOAD ""CODE 27000 30 RANDOMIZE USR VAL "27000" 40 IF INKEY$="" THEN GO TO 40
You won't do anything with RANDOMIZE USR 16384, unless you have some code stored in the screen memory area (yes you can!). You can recall the stored screen as many times as you want, provided that you never overwrite the memory space where you stored it in compressed form. E.g if your compressed screen is stored at, and runs from, 27000 and is 3000 bytes long, you should never write anything in the RAM from 27000 to 29999.
This simple program in machine code will store the content of the screen, i.e pixel and attribute data, in an area in the RAM. Of course you should reserve 6912 bytes for the whole screen.
LD HL, 16384 LD DE, address LD BC, 6912 LDIR RET The whole 6912 bytes of the current screen image will be copied in the RAM starting from address "address". Make sure you have no useful data there, otherwise they will be overwritten!
To retrieve it:
LD HL, address LD DE, 16384 LD BC, 6912 LDIR RET
This simple procedure will let you copy data inside the RAM really fast. Probably you have noticed that HL stores the address of the data to copy, DE their destination and BC the length of the data block. LDIR copies the data and RET returns to the main program or to BASIC, according to cases.
Last Edit: Jul 10, 2020 20:56:38 GMT by alessandro