- [NEW] Ctrl+Q tanca el emu

- [NEW] Pantalla LCD verda
This commit is contained in:
2025-01-30 14:35:35 +01:00
parent dc6b3b6a78
commit dffbb9c741

View File

@@ -16,9 +16,9 @@ namespace gbscreen
uint8_t y, x, tile, attr; uint8_t y, x, tile, attr;
}; };
uint32_t palette[4] = { uint32_t palette[2][4] = {
//0xFFFFFF, 0xFF0000, 0x00FF00, 0x0000FF { 0xFFFFFF, 0xAAAAAA, 0x555555, 0x000000 },
0xFFFFFF, 0xAAAAAA, 0x555555, 0x000000 { 0xA0AA05, 0x749527, 0x487F49, 0x2E4326/*0x1D6A6B*/ }
}; };
SDL_Window *win = nullptr; SDL_Window *win = nullptr;
SDL_Renderer *ren = nullptr; SDL_Renderer *ren = nullptr;
@@ -29,7 +29,8 @@ namespace gbscreen
uint32_t t_states_per_scanline = 456; uint32_t t_states_per_scanline = 456;
uint32_t vsync_lines = 10; uint32_t vsync_lines = 10;
uint8_t zoom = 2; uint8_t zoom = 3;
uint8_t use_palette=1;
bool fullscreen = false; bool fullscreen = false;
bool full_refresh = true; bool full_refresh = true;
int fullscreen_scale = 1; int fullscreen_scale = 1;
@@ -102,6 +103,8 @@ namespace gbscreen
//zx_tape::play(); //zx_tape::play();
} else if (e->key.keysym.scancode==SDL_SCANCODE_F7) { } else if (e->key.keysym.scancode==SDL_SCANCODE_F7) {
//zx_tape::rewind(); //zx_tape::rewind();
} else if (e->key.keysym.scancode==SDL_SCANCODE_Q && e->key.keysym.mod & KMOD_CTRL) {
return false;
} }
} }
} }
@@ -319,7 +322,8 @@ namespace gbscreen
if ( (STAT&0x3)==3) { if ( (STAT&0x3)==3) {
uint16_t current_pixel = dots_in_scanline-80; uint16_t current_pixel = dots_in_scanline-80;
if (current_pixel<160) { if (current_pixel<160) {
gb_pixels[current_pixel+LY*160] = line_buffer[current_pixel]; uint8_t pixel = gb_pixels[current_pixel+LY*160];
gb_pixels[current_pixel+LY*160] = pixel > line_buffer[current_pixel] ? pixel-1 : line_buffer[current_pixel];
} }
} }
@@ -405,7 +409,7 @@ namespace gbscreen
Uint32* pixels; Uint32* pixels;
int pitch; int pitch;
SDL_LockTexture(tex, NULL, (void**)&pixels, &pitch); SDL_LockTexture(tex, NULL, (void**)&pixels, &pitch);
for (int i=0; i<160*144;++i) *(pixels++) = palette[gb_pixels[i]]; for (int i=0; i<160*144;++i) *(pixels++) = palette[use_palette][gb_pixels[i]];
SDL_UnlockTexture(tex); SDL_UnlockTexture(tex);
if (fullscreen) if (fullscreen)
@@ -417,6 +421,14 @@ namespace gbscreen
// Pintem la textura a pantalla // Pintem la textura a pantalla
SDL_RenderCopy(ren, tex, NULL, &dest_rect); SDL_RenderCopy(ren, tex, NULL, &dest_rect);
// Pintem les ralles dels pixels
if (zoom>2) {
SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND);
SDL_SetRenderDrawColor(ren, 160, 170, 5, 96);
for (int i=0;i<144;++i) SDL_RenderDrawLine(ren, 0, i*zoom, 159*zoom, i*zoom);
for (int i=0;i<160;++i) SDL_RenderDrawLine(ren, i*zoom, 0, i*zoom, 139*zoom);
}
if (present) if (present)
SDL_RenderPresent(ren); SDL_RenderPresent(ren);
else else