What's new

Chip-8 Sprite System question

KaioShin

New member
Hi!

I am working on a Chip-8 Emulator (like many before) in Delphi. I am not a complete n00b but also not a expert either. I have all Arithmetic/ Logic and Jump/condition opcodes working and are stuck at the sprites now. I just don't understand the whole sprite-system.
DXYN Draws a Sprite at the coordinates V[x],V[y] (right?), located at M(I). How does a sprite look like in the memory?
 

Doomulation

?????????????????????????
Hi KaioShin,

the answer you seek is this:
This opcode draws the sprite at the X and Y coordinates specified in the opcode. D-X-coordinate-Y-coordinate-Height of sprite.
The data for the sprite is aquired from memory where the I register points. The data is bit encoded, which means that if a bit is set, then it should XOR that pixel, and if it is 0, then it shall do nothing.

So you need to check every bit of the data found in memory to see if a pixel should be written. And remember that the chip8 drawing systems XOR pixels. So if a pixel is already written to the position where you're trying to put a pixel, it will remove that pixel, and the other way around if it's not there, of course.

You can also check out some sources of existing chip8 emulators. Some can be found in the chip8 thread.
 
OP
KaioShin

KaioShin

New member
Thanks a lot!

I think I actually understand the system now, although i had problems implementing it. After looking into Chippys sourcecode I managed to do it. It still doesn't work 100% though, it seems as if it only draws in the upper left corner and not on the whole screen and the output is partially garbage (depends on the rom if its garbage or just incomplete). I haven't pinpoint the problem yet as it seems as if it does not appear in very simple testroms like setting single pixels and its hard to follow up "normal" roms through x loops.

I have a last question about the font loading. Is the font hardcoded in some chip-8 rom or is it set inside a rom ???
 

Top