   }
 
   // Set instruction time to the base/min
-  CYCLES = *(cycletable_CB + opcode);
+  CYCLES += *(cycletable_CB + opcode);
 
   // Execute instruction
   (*(optable_CB + opcode))();

    // BGP – Background Palette (R/W)
    gpu_palette = value;
  } else {
    // printf("warn: unhandled write to GPU register: $%04X ($%02X)\n",
      // address, value);
  }
}

def gpu_dump_tile(filename: str, tile: uint8) {
  let stream = fopen(filename, "wb");

  let y = 0;
  while y < 8 {
    let x = 0;
    while x < 8 {
      fprintf(stream, "%02x ",
        *(*(*(gpu_tiles + tile) + y) + x)
      );

      x += 1;
    }
    fprintf(stream, "\n");
    y += 1;
  }

  fclose(stream);
}

// =============================================================================

    // GPU VRAM
    *(vram + (address & 0x1FFF)) = value;

    return;
  }

  // External RAM: $A000 – $BFFF
  if (address & 0xF000) <= 0xB000 {
    // printf("warn: unhandled write to external ram: $%04X ($%02X)\n", address, value);
    return;
  }

  // Work RAM: $C000 – $DFFF
  // ECHO (of Work RAM): $E000 – $FDFF
  if (address & 0xF000) <= 0xD000 or address <= 0xFDFF {
    // WRAM
    *(wram + (address & 0x1FFF)) = value;
    return;
  }

  // Sprite Attribute Table (OAM): $FE00 – $FE9F
  if (address >= 0xFE00) and (address <= 0xFE9F) {
    // TODO: OAM
    // *(oam + (address & 0xFF)) = value;
    return;
  }

