Best way to write a graphics decompressor?

Hey, ProgrammerGuy here. I'm pretty new to C++, but I've read a couple basic tutorials and done a little bit of programming.

But the main reason I started learning C++ was to make a graphics decompressor for an old video game...

I know it would require reading hex bytes from the game, as well as inserting hex bytes to the game. So how would I go about writing hex bytes to a certain position of the game and reading hex bytes from the game to an array?

Also, how would I go about deleting and inserting hex bytes using C++?

Basically, knowing the stuff I mentioned above, would make it easier for me to write the decompressor as I already know how the routine works in ASM. Even if you guys just link to tutorials, it will help.

The end program would basically take a compressed graphics file from a game and decompress it.
Last edited on
What sort of "Old" video game?
and just how old are you talking about?

Is it DOS? Is it PRE-DOS/ Post DOS? Is it Encrypted, and if so, then do you already the the required keys?

Have you considered streaming the output to a file for editing and re-working?

Do you have access to the source code?

Sure, you can insert bites into compiled code, but it ain't an easy task, as you're more likely to crash it than not. - Provided you can locate it's data store.

Maybe you might try to de-compile it and post it - (provided that that is allowed in this forum- chk with admin 1st) and then de-bugging THAT code wold be a lot easier.

Last edited on
Well, it's an old NES game really. It uses simple RLE compression.

Basically I need to be able to insert 16 00's after every line to decompress it, which would require being able to insert hex.

But I would also like to know how to read hex from a file, so I can compare it to another hex value.
You just need to open the file for input in binary mode.

The concept of hex here is just a convenience to make the data legible to humans.

You simply read the byte or bytes from the file. After that your program can compare it to another byte. If you choose to specify the value in hex or decimal makes no difference to the end result, since by the time it has been compiled, it is in binary format in any case.
sounds like something like this.

Open input file (Read mode, Binary mode)
Open output file (Write Mode)

While NOT EOF() do

read CHAR string into ARRAY to EOL() // do while not End of Line

// now a_orig_strng[] is pointing to the end of line of original line of code..

// now begin the appending of 16 00's to EOL

for i_zeros =0; i_zeros < 16; i_zeros++)
a_orig_strng[ i_zeros] = 0x00 // just add a zero

// rem to add a EOL char "/o" to the EOL

Write the array " a_orig_strng[ ] " to the output file
and get the next line of code

Last edited on
Topic archived. No new replies allowed.