Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- U16 opcode = Memory[PC] << 8 | Memory[PC + 1];
- switch(opcode & 0xF000)
- {
- case 0xD000: // DXYN: Draws a sprite at coordinate (VX, VY) that has a width of 8 pixels and a height of N pixels
- U16 x = V[(opcode & 0x0F00) >> 8];
- U16 y = V[(opcode & 0x00F0) >> 4];
- U32 height = opcode & 0x000F;
- U32 pixel;
- cout << x << endl; // outputs 204 WRONG
- cout << y << endl; // outputs 204 WRONG
- cout << height << endl; // outputs 4 CORRECT
- for (int col = 0; col < height; ++col)
- {
- pixel = Memory[I + col];
- for (int row = 0; row < 8; ++row)
- {
- if ((pixel & (0x80 >> row)) != 0)
- {
- pixels[(x + row) + (y + col)] = 0xFFFFFF; // coordinates incorrect for now
- }
- else pixels[(x + row) + (y + col)] = 0x000000;
- }
- }
- PC += 2;
- cin.get();
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement