mirror of
https://github.com/st3fan/ewm.git
synced 2024-06-11 00:29:30 +00:00
Fixes #181 - In color mode, text should be white
This commit is contained in:
parent
31ecfb98f5
commit
3168e11814
17
src/chr.c
17
src/chr.c
|
@ -114,7 +114,7 @@ static uint32_t *_generate_bitmap(struct ewm_chr_t *chr, uint8_t rom_data[2048],
|
||||||
for (int y = 0; y < 8; y++) {
|
for (int y = 0; y < 8; y++) {
|
||||||
for (int x = 6; x >= 0; x--) {
|
for (int x = 6; x >= 0; x--) {
|
||||||
if (character_data[y] & (1 << x)) {
|
if (character_data[y] & (1 << x)) {
|
||||||
*p++ = chr->green;
|
*p++ = chr->color;
|
||||||
} else {
|
} else {
|
||||||
*p++ = 0x00000000;
|
*p++ = 0x00000000;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ static int ewm_chr_init(struct ewm_chr_t *chr, char *rom_path, int rom_type, SDL
|
||||||
memset(chr, 0x00, sizeof(struct ewm_chr_t));
|
memset(chr, 0x00, sizeof(struct ewm_chr_t));
|
||||||
|
|
||||||
chr->renderer = renderer;
|
chr->renderer = renderer;
|
||||||
chr->green = ewm_sdl_green(renderer);
|
chr->color = ewm_sdl_green(renderer);
|
||||||
|
|
||||||
uint8_t rom_data[2048];
|
uint8_t rom_data[2048];
|
||||||
if (_load_rom_data(rom_path, rom_data) != 0) {
|
if (_load_rom_data(rom_path, rom_data) != 0) {
|
||||||
|
@ -211,3 +211,16 @@ int ewm_chr_width(struct ewm_chr_t* chr) {
|
||||||
int ewm_chr_height(struct ewm_chr_t* chr) {
|
int ewm_chr_height(struct ewm_chr_t* chr) {
|
||||||
return 8; // TODO Should be based on the ROM type?
|
return 8; // TODO Should be based on the ROM type?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ewm_chr_set_color(struct ewm_chr_t* chr, uint32_t color) {
|
||||||
|
for (int i = 0; i < 255; i++) {
|
||||||
|
uint32_t *bitmap = chr->bitmaps[i];
|
||||||
|
if (bitmap != NULL) {
|
||||||
|
for (int j = 0; j < ewm_chr_width(chr) * ewm_chr_height(chr); j++) {
|
||||||
|
if (bitmap[j] != 0) {
|
||||||
|
bitmap[j] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -31,11 +31,12 @@ struct ewm_chr_t {
|
||||||
SDL_Renderer *renderer;
|
SDL_Renderer *renderer;
|
||||||
SDL_Texture *textures[256];
|
SDL_Texture *textures[256];
|
||||||
uint32_t *bitmaps[256];
|
uint32_t *bitmaps[256];
|
||||||
uint32_t green;
|
uint32_t color;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ewm_chr_t* ewm_chr_create(char *rom_path, int rom_type, SDL_Renderer *renderer);
|
struct ewm_chr_t* ewm_chr_create(char *rom_path, int rom_type, SDL_Renderer *renderer);
|
||||||
int ewm_chr_width(struct ewm_chr_t* chr);
|
int ewm_chr_width(struct ewm_chr_t* chr);
|
||||||
int ewm_chr_height(struct ewm_chr_t* chr);
|
int ewm_chr_height(struct ewm_chr_t* chr);
|
||||||
|
void ewm_chr_set_color(struct ewm_chr_t* chr, uint32_t color);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -302,6 +302,7 @@ static int ewm_scr_init(struct scr_t *scr, struct ewm_two_t *two, SDL_Renderer *
|
||||||
}
|
}
|
||||||
|
|
||||||
scr->green = SDL_MapRGBA(scr->surface->format, 0, 255, 0, 255);
|
scr->green = SDL_MapRGBA(scr->surface->format, 0, 255, 0, 255);
|
||||||
|
scr->white = SDL_MapRGBA(scr->surface->format, 255, 255, 255, 255);
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
SDL_Color c = hgr_colors1[i];
|
SDL_Color c = hgr_colors1[i];
|
||||||
|
@ -354,4 +355,5 @@ void ewm_scr_update(struct scr_t *scr, int phase, int fps) {
|
||||||
|
|
||||||
void ewm_scr_set_color_scheme(struct scr_t *scr, int color_scheme) {
|
void ewm_scr_set_color_scheme(struct scr_t *scr, int color_scheme) {
|
||||||
scr->color_scheme = color_scheme;
|
scr->color_scheme = color_scheme;
|
||||||
|
ewm_chr_set_color(scr->chr, color_scheme == EWM_SCR_COLOR_SCHEME_MONOCHROME ? scr->green : scr->white);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user