0

Hello everyone so basically im creating a chip8 emulator and im having a bit of trouble implementing the draw instruction. the chip 8 has a screen of 64x32 i have a array of size 32 of uint64_t. chip 8 uses a monochrome display where each bit is whether that pixel is on or off. so now I loop through that array to get that 64 bit row. Issue is I only want to xor the 8 bits corresponding to the xcordinate and after it. Not the whole 64 bit row just the xcordinate and the 7 bits after it with the sprite byte that I have.

This is my code so far for it.

  for(int i = 0; i < num_bytes; i++)
  {
    byte byte_to_draw = memory[registers->I + i];
    for(int j = 0; j < 8; j++)
    {
      // 64 bit number each bit representing on or off
      uint64_t current_row = screen[register_value_y - i];

// I want to xor here
      
    }
  }

lizardcoder
  • 336
  • 3
  • 6
  • 1
    This is way too little infomation to help you. Please show your definitions. How do you store your sprite that you want to draw into that array? How are your bits mapped to coordinates? Which bit corresponds to coordinate x=0? – Gerhardh Feb 23 '22 at 15:13
  • 1
    If your buffer and your sprite have same orientation, you only need to shift your 8bit sprite data into correct position and xor your 64bit line. Convert the 8 bit from the sprite to `uint64-t` first to avoid problems during shifting – Gerhardh Feb 23 '22 at 15:15
  • Im trying your suggestion right now – lizardcoder Feb 23 '22 at 15:17
  • a monochrome screen of 64x32 means either `long long screen[32]` or `long screen[64]`. But you did not provide information about what you want – alinsoar Feb 23 '22 at 15:30
  • @alinsoar is uint64_t screen[32] so basically long long screen[32] – lizardcoder Feb 23 '22 at 15:35
  • 1
    @lizardcoder yes, need details. – alinsoar Feb 23 '22 at 16:26

0 Answers0