nesemu/gui/pattern_display.h

48 lines
1.2 KiB
C
Raw Normal View History

2024-07-12 13:07:16 -04:00
//
// 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"
2024-07-12 18:52:54 -04:00
#define PATTERN_DISPLAY_STATIC SDL_TEXTUREACCESS_STATIC
#define PATTERN_DISPLAY_DYNAMIC SDL_TEXTUREACCESS_STREAMING
2024-07-12 13:07:16 -04:00
#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;
2024-07-12 18:52:54 -04:00
typedef byte *(*read_func)(address, void *);
2024-07-12 13:07:16 -04:00
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;
}
2024-07-12 18:52:54 -04:00
void pattern_display_init(PatternDisplay *display, SDL_Renderer *renderer, int tiles_x, int tiles_y, int display_type);
2024-07-12 13:07:16 -04:00
void pattern_display_uninit(PatternDisplay *display);
2024-07-12 18:52:54 -04:00
void pattern_display_build(PatternDisplay *display, read_func read_func, void *read_func_data);
2024-07-12 13:07:16 -04:00
void pattern_display_render(PatternDisplay *display, SDL_Renderer *renderer);
#endif //NES_EMULATOR_PATTERN_DISPLAY_H