Loading...
> Drawing Sprites To The Screen
View Course

Question by Thomas Treffry

Please may you provide more information regarding the `const char* sprite` argument in `chip8_screen_draw_sprite`? I am a little confused by this.

When we call `chip8_screen_draw_sprite` from `main.c`, we are passing in a pointer to the first element of the memory array, `&chip8.memory.memory[0x00]`. Due to the `memcpy` call in `chip8_init`, the first element of the chip8.memory.memory array should be the same as the first element of the `chip8_default_character_set`. Does that make sense?

If so, the value of the `sprite` argument would be `0xf0`. However, I don't think that is accurate because we then do an index lookup `char c = sprite[ly]`. How does this work and where am I going wrong with my logic?

Answered by Daniel McCarthy

Hi,
I don't quite understand what your asking me can you break down a little further your problem

Answered By Instructor

Followup question by Thomas Treffry

Hi Daniel, I dug into this over Christmas and identified a knowledge gap with C pointers. Now that I understand pointers, the code makes sense. Thanks for a great course, I am enjoying it!

Question Author

Answered by Daniel McCarthy

Your very welcome Thomas all the best please reach out if theirs anything else

Answered By Instructor