Advertisement
captmicro

CHIP8 OPCODES

Sep 2nd, 2010
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.32 KB | None | 0 0
  1. void CHIP8_0NNN(C8, VNNN) { return; }
  2. void CHIP8_00E0(C8) { _CHIP8_MEMSET(cpu->display, 0, 64*32); }
  3. void CHIP8_00EE(C8) { cpu->PC = _CHIP8_POP(cpu); }
  4. void CHIP8_1NNN(C8, VNNN) { cpu->PC = NNN; }
  5. void CHIP8_2NNN(C8, VNNN) { _CHIP8_PUSH(cpu, cpu->PC+2); cpu->PC = NNN; }
  6. void CHIP8_3XNN(C8, VXNN) { if (cpu->V[X] == NN) cpu->PC += 2; }
  7. void CHIP8_4XNN(C8, VXNN) { if (cpu->V[X] != NN) cpu->PC += 2; }
  8. void CHIP8_5XY0(C8, VXY) { if (cpu->V[X] == cpu->V[Y]) cpu->PC += 2; }
  9. void CHIP8_6XNN(C8, VXNN) { cpu->V[X] = NN; }
  10. void CHIP8_7XNN(C8, VXNN) { cpu->V[X] += NN; }
  11. void CHIP8_8XY0(C8, VXY) { cpu->V[X] = cpu->V[Y]; }
  12. void CHIP8_8XY1(C8, VXY) { cpu->V[X] = cpu->V[X] | cpu->V[Y]; }
  13. void CHIP8_8XY2(C8, VXY) { cpu->V[X] = cpu->V[X] & cpu->V[Y]; }
  14. void CHIP8_8XY3(C8, VXY) { cpu->V[X] = cpu->V[X] ^ cpu->V[Y]; }
  15. void CHIP8_8XY4(C8, VXY) { cpu->V[X] += cpu->V[Y]; cpu->V[0xF] = (cpu->V[X] < cpu->V[Y]); }
  16. void CHIP8_8XY5(C8, VXY) { cpu->V[X] -= cpu->V[Y]; cpu->V[0xF] = /*borrow*/0; }
  17. void CHIP8_8XY6(C8, VXY) { cpu->V[0xF] = /*LSB*/0; cpu->V[X] = cpu->V[X] >> 1; }
  18. void CHIP8_8XY7(C8, VXY) { cpu->V[X] = cpu->V[Y] - cpu->V[X]; cpu->V[0xF] = /*borrow*/0; }
  19. void CHIP8_8XYE(C8, VXY) { cpu->V[0xF] = /*MSB*/0; cpu->V[X] = cpu->V[X] << 1; }
  20. void CHIP8_9XY0(C8, VXY) { if (cpu->V[X] != cpu->V[Y]) cpu->PC += 2; }
  21. void CHIP8_ANNN(C8, VNNN) { cpu->I = NNN; }
  22. void CHIP8_BNNN(C8, VNNN) { cpu->PC = NNN + cpu->V[0x0]; }
  23. void CHIP8_CXNN(C8, VXNN) { cpu->V[X] = (/*rand*/0 & NN); }
  24. void CHIP8_DXYN(C8, VXYN) { cpu->V[0xF] = CHIP8_DRAWSPRITE(X, Y, cpu->mem + cpu->I, N); }
  25. void CHIP8_EX9E(C8, VX) { if (cpu->input[X] == 0xFF) cpu->PC += 2; }
  26. void CHIP8_EXA1(C8, VX) { if (cpu->input[X] == 0x00) cpu->PC += 2; }
  27. void CHIP8_FX07(C8, VX) { cpu->V[X] = cpu->delaytimer; }
  28. void CHIP8_FX0A(C8, VX) { BYTE i = 0; for (i = 0; i < 0xF; i++) if (cpu->input[i] == 0xFF) cpu->V[X] = i; }
  29. void CHIP8_FX15(C8, VX) { cpu->delaytimer = cpu->V[X]; }
  30. void CHIP8_FX18(C8, VX) { cpu->soundtimer = cpu->V[X]; }
  31. void CHIP8_FX1E(C8, VX) { cpu->I += cpu->V[X]; }
  32. void CHIP8_FX29(C8, VX) { cpu->I = 0x000 + (cpu->V[X] * 5); }
  33. void CHIP8_FX33(C8, VX) { /*not implemented*/ }
  34. void CHIP8_FX55(C8, VX) { BYTE i = 0; for (i = 0; i < 0xF; i++) *(cpu->mem + cpu->I + i) = cpu->V[i]; }
  35. void CHIP8_FX65(C8, VX) { BYTE i = 0; for (i = 0; i < 0xF; i++) cpu->V[i] = *(cpu->mem + cpu->I + i); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement