nesemu/gui/nametable_window.c

38 lines
1.2 KiB
C
Raw Normal View History

2024-07-12 13:07:16 -04:00
//
// Created by william on 12/07/24.
//
2024-07-12 18:52:54 -04:00
#include <assert.h>
2024-07-12 13:07:16 -04:00
#include "nametable_window.h"
2024-07-12 18:52:54 -04:00
#define NAMETABLE_BANK_SIZE 0x0400
2024-07-23 18:50:11 -04:00
#define NW_WIDTH (NW_ROW_TILE_COUNT * PATTERN_DRAW_SIZE)
#define NW_HEIGHT (NW_ROW_COUNT * PATTERN_DRAW_SIZE)
2024-07-12 18:52:54 -04:00
2024-07-21 16:41:38 -04:00
void nametable_window_init(NesNametableWindow *window) {
2024-07-12 13:07:16 -04:00
int win_size = pattern_display_get_size(NW_ROW_TILE_COUNT);
window->sdl_context = window_init("Nametable", win_size, win_size, NW_SCALE);
2024-07-23 18:50:11 -04:00
window->texture = SDL_CreateTexture(window->sdl_context.renderer, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING, NW_WIDTH, NW_HEIGHT);
2024-07-12 13:07:16 -04:00
}
void nametable_window_uninit(NesNametableWindow *window) {
2024-07-23 18:50:11 -04:00
SDL_DestroyTexture(window->texture);
2024-07-12 13:07:16 -04:00
window_uninit(window->sdl_context);
}
2024-07-21 16:41:38 -04:00
void nametable_window_update(NesNametableWindow *window, byte *nametable_0, byte *nametable_1) {
byte **nametables[2];
nametables[0] = &nametable_0;
nametables[1] = &nametable_1;
2024-07-12 13:07:16 -04:00
}
void nametable_window_render(NesNametableWindow *window) {
SDL_RenderClear(window->sdl_context.renderer);
2024-07-23 18:50:11 -04:00
SDL_RenderCopy(window->sdl_context.renderer, window->texture, NULL, NULL);
2024-07-12 13:07:16 -04:00
}
void nametable_window_present(NesNametableWindow *window) {
SDL_RenderPresent(window->sdl_context.renderer);
}