Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. U16 opcode = Memory[PC] << 8 | Memory[PC + 1];
  2. switch(opcode & 0xF000)
  3. {
  4. case 0xD000: // DXYN: Draws a sprite at coordinate (VX, VY) that has a width of 8 pixels and a height of N pixels
  5. U16 x = V[(opcode & 0x0F00) >> 8];
  6. U16 y = V[(opcode & 0x00F0) >> 4];
  7. U32 height = opcode & 0x000F;
  8. U32 pixel;
  9.  
  10. cout << x << endl; // outputs 204 WRONG
  11. cout << y << endl; // outputs 204 WRONG
  12. cout << height << endl; // outputs 4 CORRECT
  13.  
  14. for (int col = 0; col < height; ++col)
  15. {
  16. pixel = Memory[I + col];
  17. for (int row = 0; row < 8; ++row)
  18. {
  19. if ((pixel & (0x80 >> row)) != 0)
  20. {
  21. pixels[(x + row) + (y + col)] = 0xFFFFFF; // coordinates incorrect for now
  22. }
  23. else pixels[(x + row) + (y + col)] = 0x000000;
  24. }
  25. }
  26.  
  27. PC += 2;
  28. cin.get();
  29. break;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement