How exactly do I read pixels from the sprite memory? I can't figure out the math needed to convert the X,Y to the correct pixel location in the sprite memory.
The spritesheet isn't a 128x128 image in the memory, it's 256 consecutive 8x8 4 bit sprites
So, to set/get pixels to the spritesheet try to use these functions
function sset(x,y,c) local addr=0x4000+(x//8+y//8*16)*16 -- get sprite address poke4(addr*2+x%8+y%8*8,c) -- set sprite pixel end
function sget(x,y) local addr=0x4000+(x//8+y//8*16)*16 -- get sprite address return peek4(addr*2+x%8+y%8*8) -- get sprite pixel end
edit:
added the functions to snippets https://github.com/nesbox/tic.computer/wiki/Code-examples-and-snippets#setget-spritesheet-pixel