Re:Octojam 7: The CHIP-8 game jam
by sowbug on Wednesday September 23, 2020 @03:57PM
(#24571227)
Can someone explain how the variable i works in the home page's sample source code?
I understand v0 and v1 -- makes sense they're initialized to zero, and the language must not require declarations -- but i is a mystery. ball is assigned to it, but then nobody refers to it again.
[ Parent
| on HN ]
I registrar contains the image to ... sprite. See https://github.com/JohnEarnest/Octo/blob/gh-pages/docs/Begin...
They're not variables, they're CHIP8 registers. The I register is used to hold memory locations; in particular, the operation that displays a sprite reads sprite data from the memory address in I.
Check out this reference: http://devernay.free.fr/hacks/chip8/C8TECH10.HTM
Re:Octojam 7: The CHIP-8 game jam
by meheleventyone on Wednesday September 23, 2020 @04:05PM
(#24571334)
I believe i is a register that in this case points to the location of the sprite data used by the sprite command. In this case the data represents the pixels of the ball.
Re:Octojam 7: The CHIP-8 game jam
by RodgerTheGreat on Wednesday September 23, 2020 @04:18PM
(#24571481)
That's correct. The index register is implicitly used by the CHIP-8 instructions Octo calls `sprite`, `bcd`, `load`, and `store`.