4 ms·
Can someone explain how the variable i works in the home page's sample source code? : main i := ball loop sprite v0 v1 7 v0 +=
by sowbug 6y ago
Can someone explain how the variable i works in the home page's sample source code?
: main
i := ball
loop
sprite v0 v1 7
v0 += 3
v1 += 5
again
: ball
0x38 0x74 0xFA 0xFE 0xFE 0x7C 0x38
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.
- meheleventyone 6y agoI 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.
- RodgerTheGreat 6y agoThat's correct. The index register is implicitly used by the CHIP-8 instructions Octo calls `sprite`, `bcd`, `load`, and `store`.
- tsukikage 6y agoThey'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 http://devernay.free.fr/hacks/chip8/C8TECH10.HTM
- daitangio 6y agoI registrar contains the image to ... sprite. See https://github.com/JohnEarnest/Octo/blob/gh-pages/docs/BeginnersGuide.md https://github.com/JohnEarnest/Octo/blob/gh-pages/docs/Begin...