Please may you provide more information regarding the `const char* sprite` argum...

Thomas Treffry Answered 3 answers
Question by Thomas Treffry 3 years ago

Question

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?

Answers

Answered by Daniel McCarthy

Instructor

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

Follow-up by Thomas Treffry

Question author

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!

Answered by Daniel McCarthy

Instructor

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