2024-08-03 21:51:31 -04:00
|
|
|
//
|
|
|
|
// Created by william on 7/28/24.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include "dbg_palette.h"
|
|
|
|
#include "../include/ppu.h"
|
2024-08-13 17:32:54 -04:00
|
|
|
#include "../ppu/colors.h"
|
2024-08-03 21:51:31 -04:00
|
|
|
|
|
|
|
DebugPaletteMemory palette_memory;
|
2024-08-13 17:32:54 -04:00
|
|
|
pixel dbg_color_list[0x40] = COLOR_LIST;
|
2024-08-03 21:51:31 -04:00
|
|
|
|
|
|
|
#define COPY_PALETTE(memory, dest) memcpy(&(dest), &(memory), sizeof(DebugPalette))
|
|
|
|
#define COPY_PALETTES(memory, base_addr, dest) \
|
|
|
|
COPY_PALETTE((memory)[(base_addr) + 0x1], (dest)[0]); \
|
|
|
|
COPY_PALETTE((memory)[(base_addr) + 0x5], (dest)[1]); \
|
|
|
|
COPY_PALETTE((memory)[(base_addr) + 0x9], (dest)[2]); \
|
|
|
|
COPY_PALETTE((memory)[(base_addr) + 0xd], (dest)[3]) \
|
|
|
|
|
|
|
|
|
2024-10-03 19:24:03 -04:00
|
|
|
void dbg_palette_update() {
|
2024-08-03 21:51:31 -04:00
|
|
|
byte *memory = ppu_get_state()->memory.palette;
|
|
|
|
|
|
|
|
palette_memory.universal_background_color = memory[0];
|
|
|
|
|
|
|
|
COPY_PALETTES(memory, 0, palette_memory.background_palettes);
|
|
|
|
COPY_PALETTES(memory, 0x10, palette_memory.sprite_palettes);
|
|
|
|
}
|
|
|
|
|
|
|
|
pixel dbg_get_background_color(byte palette, byte data) {
|
|
|
|
if (data == 0) {
|
|
|
|
return palette_memory.universal_background_color;
|
|
|
|
}
|
|
|
|
|
|
|
|
int color = palette_memory.background_palettes[palette][data - 1];
|
2024-08-13 17:32:54 -04:00
|
|
|
return dbg_color_list[color];
|
2024-08-03 21:51:31 -04:00
|
|
|
}
|