//
// Created by william on 6/14/24.
//

#ifndef NES_EMULATOR_PATTERN_WINDOW_H
#define NES_EMULATOR_PATTERN_WINDOW_H

#include "../include/types.h"
#include "components/window.h"

#define PW_SCALE 2
#define PW_ROW_TILE_COUNT 16
#define PW_PALETTE_MAX 3

typedef struct nes_pattern_window {
    Window window;
    SDL_Texture *texture;
    byte palette;
} PatternWindow;

/**
 * Creates a pattern window instance.
 * @return A reference to the created window instance
 */
PatternWindow *pattern_window_create(int *window_id);

/**
 * Destroys a pattern window instance.
 * @param window A reference to the window to destroy
 */
void pattern_window_destroy(PatternWindow *window);

/**
 * Updates the content of a pattern window with the current data from the ROM mapper.
 * @param window A reference to the window to update
 */
void pattern_window_update(PatternWindow *window);

/**
 * Renders a pattern window to the screen.
 * @param window A reference to the window to render
 */
void pattern_window_render(PatternWindow *window);

/**
 * Sends a key up event to a pattern window.
 * @param window A reference to the window to send the event to
 * @param keycode The code of the key of the event
 */
void pattern_window_key_up(PatternWindow *window, SDL_KeyCode keycode);

#endif //NES_EMULATOR_PATTERN_WINDOW_H