diff --git a/gtk3/main.c b/gtk3/main.c
index 17105df..b5ce8b3 100644
--- a/gtk3/main.c
+++ b/gtk3/main.c
@@ -1015,15 +1015,60 @@ static void vblank(GB_gameboy_t *gb) {
}
if (vram_viewer_visible) {
- // TODO: Only update what is needed
- GB_draw_tileset(gb, tileset_buffer, GB_PALETTE_NONE, 0);
- GB_draw_tilemap(gb, tilemap_buffer, GB_PALETTE_AUTO, 0, GB_MAP_AUTO, GB_TILESET_AUTO);
+ const gchar *active = gtk_stack_get_visible_child_name(builder_get(GTK_STACK, "vram_viewer_stack"));
- scrollRect = (Rect){
- GB_read_memory(gb, 0xFF00 | GB_IO_SCX),
- GB_read_memory(gb, 0xFF00 | GB_IO_SCY),
- 160, 144
- };
+ if (g_strcmp0("vram_viewer_tileset", active) == 0) {
+ const gchar *palette_id = gtk_combo_box_get_active_id(builder_get(GTK_COMBO_BOX, "vram_viewer_tileset_palette_selector"));
+
+ GB_palette_type_t palette_type = g_str_has_prefix(palette_id, "bg")? GB_PALETTE_BACKGROUND : GB_PALETTE_OAM;
+ uint8_t palette_index = g_ascii_digit_value(palette_id[palette_type == GB_PALETTE_OAM ? 3 : 2]);
+
+ GB_draw_tileset(gb, tileset_buffer,
+ palette_type,
+ palette_index
+ );
+ }
+ else if (g_strcmp0("vram_viewer_tilemap", active) == 0) {
+ const gchar *palette_id = gtk_combo_box_get_active_id(builder_get(GTK_COMBO_BOX, "vram_viewer_tilemap_palette_selector"));
+ uint8_t palette_index = 0;
+ GB_palette_type_t palette_type = GB_PALETTE_AUTO;
+
+ if (g_strcmp0("auto", palette_id) != 0) {
+ palette_type = g_str_has_prefix(palette_id, "bg")? GB_PALETTE_BACKGROUND : GB_PALETTE_OAM;
+ palette_index = g_ascii_digit_value(palette_id[palette_type == GB_PALETTE_OAM ? 3 : 2]);
+ }
+
+ GB_map_type_t map_type = GB_MAP_AUTO;
+ const gchar *map_type_id = gtk_combo_box_get_active_id(builder_get(GTK_COMBO_BOX, "vram_viewer_tilemap_tilemap_selector"));
+ if (g_strcmp0("auto", map_type_id) != 0) {
+ map_type = (g_strcmp0("9800", map_type_id) == 0)? GB_MAP_9800 : GB_MAP_9C00;
+ }
+
+ GB_tileset_type_t tileset_type = GB_TILESET_AUTO;
+ const gchar *tileset_type_id = gtk_combo_box_get_active_id(builder_get(GTK_COMBO_BOX, "vram_viewer_tilemap_tileset_selector"));
+ if (g_strcmp0("auto", tileset_type_id) != 0) {
+ tileset_type = (g_strcmp0("8800", tileset_type_id) == 0)? GB_TILESET_8800 : GB_TILESET_8000;
+ }
+
+ GB_draw_tilemap(gb, tilemap_buffer,
+ palette_type,
+ palette_index,
+ map_type,
+ tileset_type
+ );
+
+ scrollRect = (Rect){
+ GB_read_memory(gb, 0xFF00 | GB_IO_SCX),
+ GB_read_memory(gb, 0xFF00 | GB_IO_SCY),
+ 160, 144
+ };
+ }
+ else if (g_strcmp0("vram_viewer_sprites", active) == 0) {
+
+ }
+ else if (g_strcmp0("vram_viewer_palettes", active) == 0) {
+
+ }
// Queue a redraw of the VRAM viewer
gtk_widget_queue_draw(GTK_WIDGET(vram_viewer));
diff --git a/gtk3/resources/ui/window.ui b/gtk3/resources/ui/window.ui
index f207480..35045f8 100644
--- a/gtk3/resources/ui/window.ui
+++ b/gtk3/resources/ui/window.ui
@@ -1203,7 +1203,6 @@ Maximilian Mader https://github.com/max-m
True
False
0
- fgngfn
bg0
- Background Palette 0
@@ -1289,7 +1288,7 @@ Maximilian Mader https://github.com/max-m
6
3
-
-
+
True
False
0
@@ -1373,7 +1372,7 @@ Maximilian Mader https://github.com/max-m
-
+
True
False
0