reading sc5 file in C

Page 3/3
1 | 2 |

By albs_br

Champion (337)

albs_br's picture

26-09-2021, 22:07

Hi guys, sorry for digging up such an old thread.

I'm playing with MSX2BMP and it generates a .SC5 file with exactly 30,375 bytes.

But 256x212 / 2 = 27,136 bytes

I know about the 7-byte header and the 32-byte palette data at the file end.
But what about those extra 3k bytes?

By Sandy Brand

Master (243)

Sandy Brand's picture

26-09-2021, 22:42

The pixel data in Screen 5 is from &H0000 .. &H69FF (= 27136 bytes).
The palette data is from &H7680 .. &H769F (= 32 bytes).

As you mention, the .sc5 file is basically a .bin file, which is nothing more than a contiguous data stream that will be loaded in one go into (V)RAM.

So the gap between &H69FF .. &H7680 has to be stored in it it as well.
This totals to &H769F - &H0000 + 1 = 30368 bytes.
Add your 7 bytes .bin header and it equals to 30375 bytes. Smile

By albs_br

Champion (337)

albs_br's picture

26-09-2021, 23:18

WOW! I didn't know there was palette data stored in VRAM. The VDP registers are not enought?

Anyway, thanks. This info should solve my problem for now.

By Sandy Brand

Master (243)

Sandy Brand's picture

27-09-2021, 00:35

Storing the palette in VRAM is only a convention that the authors of MSX-BASIC implemented in order to be able to load/save complete images easily, it has no effect when just stored in VRAM.

It is up to programs themselves to actually somehow read the palette from VRAM and writing it to appropriate VDP registers to make the palette used for drawing the screen. This is basically what COLOR=RESTORE BASIC command does for you Smile

Page 3/3
1 | 2 |