nesemu/gui/pattern_display.h

48 lines
1.2 KiB
C

//
// Created by william on 12/07/24.
//
#ifndef NES_EMULATOR_PATTERN_DISPLAY_H
#define NES_EMULATOR_PATTERN_DISPLAY_H
#include <SDL.h>
#include "../include/types.h"
#define PATTERN_DISPLAY_STATIC SDL_TEXTUREACCESS_STATIC
#define PATTERN_DISPLAY_DYNAMIC SDL_TEXTUREACCESS_STREAMING
#define PATTERN_SIZE 8
#define PATTERN_BORDER_WIDTH 1
#define PATTERN_BORDER_COLOR 0xff2223b2
#define PATTERN_DRAW_SIZE (PATTERN_SIZE + PATTERN_BORDER_WIDTH)
typedef unsigned int pixel;
typedef byte *(*read_func)(address, void *);
typedef struct pattern_tile {
byte data_low[8];
byte data_high[8];
} PatternTile;
typedef struct pattern_display {
SDL_Texture *texture;
PatternTile *tiles;
int width;
int height;
} PatternDisplay;
static inline int pattern_display_get_size(int tile_count) {
return tile_count * PATTERN_DRAW_SIZE + PATTERN_BORDER_WIDTH;
}
void pattern_display_init(PatternDisplay *display, SDL_Renderer *renderer, int tiles_x, int tiles_y, int display_type);
void pattern_display_uninit(PatternDisplay *display);
void pattern_display_build(PatternDisplay *display, read_func read_func, void *read_func_data);
void pattern_display_render(PatternDisplay *display, SDL_Renderer *renderer);
#endif //NES_EMULATOR_PATTERN_DISPLAY_H