diff options
| author | 2019-10-14 23:36:31 -0400 | |
|---|---|---|
| committer | 2019-10-14 23:36:31 -0400 | |
| commit | 1530351408e88d60bd9c5f73927181cfee4c1500 (patch) | |
| tree | b09e7f46ed30802237f381f931fcdd4dd9de2974 | |
| parent | 4c5482d30566124e18930a56153c636527b67971 (diff) | |
| download | chip8-1530351408e88d60bd9c5f73927181cfee4c1500.tar.gz chip8-1530351408e88d60bd9c5f73927181cfee4c1500.tar.bz2 chip8-1530351408e88d60bd9c5f73927181cfee4c1500.zip | |
fix screen size and comment draw code
| -rw-r--r-- | chip8.c | 7 | ||||
| -rw-r--r-- | chip8.h | 2 |
2 files changed, 8 insertions, 1 deletions
@@ -197,6 +197,8 @@ void vm_step() { vm.Vx[0xF] = 0; for (u32 i = 0; i < (in&0xF); i++) { for (u32 s = 0; s < 8; s++) { + + // 0x80 = 10000000 u8 pix = (vm.ram[vm.I + i] & (0x80 >> s)) != 0; if (pix) { @@ -204,8 +206,13 @@ void vm_step() { u8 x = (vm.Vx[in>>8&0xF] + s)&0x3F; u32 byte = y * 64 + x; + + // put the single 1 bit in the position + // that is relative to the pixel u32 bit = 1 << (byte & 0x07); + // byte>>3 ~ byte / 8 + // used to get the index of byte to xor if (vm.screen[byte>>3] & bit) { vm.Vx[0xF] = 1; } @@ -23,7 +23,7 @@ typedef struct { u8 keyboard[16]; - u8 screen[0x3F*0x1F]; + u8 screen[250]; } chip8_vm; extern chip8_vm vm; |