Fixes #181 - In color mode, text should be white

This commit is contained in:
Stefan Arentz 2017-10-15 21:30:15 -04:00
parent 31ecfb98f5
commit 3168e11814
4 changed files with 20 additions and 3 deletions

View File

@ -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 x = 6; x >= 0; x--) {
if (character_data[y] & (1 << x)) {
*p++ = chr->green;
*p++ = chr->color;
} else {
*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));
chr->renderer = renderer;
chr->green = ewm_sdl_green(renderer);
chr->color = ewm_sdl_green(renderer);
uint8_t rom_data[2048];
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) {
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;
}
}
}
}
}

View File

@ -31,11 +31,12 @@ struct ewm_chr_t {
SDL_Renderer *renderer;
SDL_Texture *textures[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);
int ewm_chr_width(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

View File

@ -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->white = SDL_MapRGBA(scr->surface->format, 255, 255, 255, 255);
for (int i = 0; i < 4; 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) {
scr->color_scheme = color_scheme;
ewm_chr_set_color(scr->chr, color_scheme == EWM_SCR_COLOR_SCHEME_MONOCHROME ? scr->green : scr->white);
}

View File

@ -49,6 +49,7 @@ struct scr_t {
uint32_t *lgr_bitmaps[256];
uint32_t green;
uint32_t white;
uint32_t hgr_colors1[4];
uint32_t hgr_colors2[4];
};