diff --git a/modules/Gpx/cg.c b/modules/Gpx/cg.c index 94e6367..209a55c 100644 --- a/modules/Gpx/cg.c +++ b/modules/Gpx/cg.c @@ -73,21 +73,21 @@ static surface_t *sf_getcg(void *b, size_t size) { cg->alpha = cg->pic; cg->pic = NULL; sf = sf_create_alpha(cg->width, cg->height); - sdl_drawImageAlphaMap(cg, sf, 0, 0); + gfx_drawImageAlphaMap(cg, sf, 0, 0); break; case ALCG_PMS16: cg = pms64k_extract(b); sf = cg->alpha ? sf_create_surface(cg->width, cg->height) : sf_create_pixel(cg->width, cg->height); - sdl_drawImage16(cg, sf, 0, 0, 255, false); + gfx_drawImage16(cg, sf, 0, 0, 255, false); break; case ALCG_QNT: cg = qnt_extract(b); sf = cg->alpha ? sf_create_surface(cg->width, cg->height) : sf_create_pixel(cg->width, cg->height); - sdl_drawImage24(cg, sf, 0, 0, 255); + gfx_drawImage24(cg, sf, 0, 0, 255); break; default: WARNING("Unknown Cg Type"); diff --git a/modules/Gpx/graph.c b/modules/Gpx/graph.c index e3a5ba6..3bdcd54 100644 --- a/modules/Gpx/graph.c +++ b/modules/Gpx/graph.c @@ -75,7 +75,7 @@ void gr_copy(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int if (dst == src) { SDL_Rect r; if (SDL_IntersectRect(&src_rect, &dst_rect, &r)) { - SDL_Surface *view = sdl_createSurfaceView(src->sdl_surface, sx, sy, sw, sh); + SDL_Surface *view = gfx_createSurfaceView(src->sdl_surface, sx, sy, sw, sh); SDL_Surface *tmp = SDL_ConvertSurface(view, dst->sdl_surface->format, 0); src_rect.x = 0; src_rect.y = 0; diff --git a/modules/NIGHTDLL/sprite_eupdate.c b/modules/NIGHTDLL/sprite_eupdate.c index c49c1b8..7f0a094 100644 --- a/modules/NIGHTDLL/sprite_eupdate.c +++ b/modules/NIGHTDLL/sprite_eupdate.c @@ -50,7 +50,7 @@ void nt_sp_eupdate(int no, int time, int cancel) { type = EFFECT_CROSSFADE; } SDL_Rect rect = { 0, 0, main_surface->w, main_surface->h }; - struct sdl_effect *eff = sdl_effect_init(&rect, NULL, 0, 0, sdl_getDIB(), 0, 0, type); + struct sdl_effect *eff = sdl_effect_init(&rect, NULL, 0, 0, gfx_getDIB(), 0, 0, type); int sttime, curtime; sttime = curtime = sdl_getTicks(); diff --git a/modules/NightDemonDemo/NightDemonDemo.c b/modules/NightDemonDemo/NightDemonDemo.c index 28c76e7..dbf7732 100644 --- a/modules/NightDemonDemo/NightDemonDemo.c +++ b/modules/NightDemonDemo/NightDemonDemo.c @@ -74,7 +74,7 @@ static void ndd_run(int demonum) { if (sys_keywait(wait_ms, KEYWAIT_CANCELABLE)) break; } else { - sdl_updateScreen(); + gfx_updateScreen(); if (sys_getInputInfo()) break; } diff --git a/modules/SACT/sactamask.c b/modules/SACT/sactamask.c index f4d03bc..289e46a 100644 --- a/modules/SACT/sactamask.c +++ b/modules/SACT/sactamask.c @@ -91,7 +91,7 @@ void sp_eupdate_amap(int index, int time, int cancel) { return; } SDL_Surface *mask_sf = SDL_CreateRGBSurfaceFrom(mask->pic, mask->width, mask->height, 8, mask->width, 0, 0, 0, 0); - sp_update_all(false); // old = sdl_texture, new = main_surface + sp_update_all(false); // old = gfx_texture, new = main_surface struct sdl_effect *eff = sdl_effect_sactamask_init(mask_sf); ags_runEffect(time * 10, cancel, (ags_EffectStepFunc)sdl_effect_step, eff); sdl_effect_finish(eff); diff --git a/modules/SACT/sactcg.c b/modules/SACT/sactcg.c index e72f568..1106b82 100644 --- a/modules/SACT/sactcg.c +++ b/modules/SACT/sactcg.c @@ -118,9 +118,9 @@ void scg_create_reverse(int wNumCG, int wNumSrcCG, int wReverseX, int wReverseY) SDL_Surface *sf = SDL_ConvertSurface(src->sf, src->sf->format, 0); if (wReverseX) - sdl_FlipSurfaceHorizontal(sf); + gfx_FlipSurfaceHorizontal(sf); if (wReverseY) - sdl_FlipSurfaceVertical(sf); + gfx_FlipSurfaceVertical(sf); scg_new(CG_REVERSE, wNumCG, sf); } diff --git a/modules/SACT/sprite_eupdate.c b/modules/SACT/sprite_eupdate.c index c4fe050..9d2a7b1 100644 --- a/modules/SACT/sprite_eupdate.c +++ b/modules/SACT/sprite_eupdate.c @@ -51,7 +51,7 @@ void sp_eupdate(int type, int time, int cancel) { type = EFFECT_CROSSFADE; } SDL_Rect rect = { 0, 0, main_surface->w, main_surface->h }; - struct sdl_effect *eff = sdl_effect_init(&rect, NULL, 0, 0, sdl_getDIB(), 0, 0, sdl_effect); + struct sdl_effect *eff = sdl_effect_init(&rect, NULL, 0, 0, gfx_getDIB(), 0, 0, sdl_effect); int sttime, curtime; sttime = curtime = sdl_getTicks(); diff --git a/modules/tDemo/tDemo.c b/modules/tDemo/tDemo.c index f4ebb4d..040cf6d 100644 --- a/modules/tDemo/tDemo.c +++ b/modules/tDemo/tDemo.c @@ -94,7 +94,7 @@ static void Run() { if (sys_keywait(wait_ms, KEYWAIT_CANCELABLE)) break; } else { - sdl_updateScreen(); + gfx_updateScreen(); if (sys_getInputInfo()) break; } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5752b94..17b3c5d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -62,6 +62,9 @@ target_sources(xsystem35 PRIVATE filecheck.c font.c hacks.c + gfx_draw.c + gfx_image.c + gfx_video.c image.c input.c jpeg.c @@ -83,11 +86,8 @@ target_sources(xsystem35 PRIVATE scenario.c scheduler.c sdl_cursor.c - sdl_draw.c sdl_effect.c sdl_event.c - sdl_image.c - sdl_video.c selection.c texthook.c variable.c diff --git a/src/ags.c b/src/ags.c index b4e3bb0..50fae95 100644 --- a/src/ags.c +++ b/src/ags.c @@ -81,7 +81,7 @@ static void initPal(void) { for (int i = 0; i < 256; i++) { nact->ags.pal[i].a = 255; } - sdl_setPalette(nact->ags.pal, 0, 256); + gfx_setPalette(nact->ags.pal, 0, 256); palette_changed(); } @@ -139,7 +139,7 @@ void ags_init(const char *render_driver, bool enable_zb) { nact->ags.enable_zb = enable_zb; nact->ags.font_weight = enable_zb ? FONT_WEIGHT_BOLD : FONT_WEIGHT_NORMAL; - sdl_Initialize(render_driver); + gfx_Initialize(render_driver); font_init(); initPal(); @@ -148,7 +148,7 @@ void ags_init(const char *render_driver, bool enable_zb) { void ags_remove(void) { ags_autorepeat(true); - sdl_Remove(); + gfx_Remove(); } void ags_reset(void) { @@ -168,9 +168,9 @@ void ags_setWorldSize(int width, int height, int depth) { nact->ags.dib->alpha = NULL; } - sdl_setWorldSize(width, height, depth); + gfx_setWorldSize(width, height, depth); - nact->ags.dib = sdl_getDIB(); + nact->ags.dib = gfx_getDIB(); /* DIBが8以上の場合は、alpha plane を用意 */ if (depth > 8) { @@ -188,13 +188,13 @@ void ags_setViewArea(int x, int y, int width, int height) { nact->ags.view_area.y = y; nact->ags.view_area.w = width; nact->ags.view_area.h = height; - sdl_setWindowSize(width, height); + gfx_setWindowSize(width, height); } void ags_setWindowTitle(const char *title_utf8) { char buf[256]; snprintf(buf, sizeof(buf), "XSystem35 Version %s: %s", VERSION, title_utf8); - sdl_setWindowTitle(buf); + gfx_setWindowTitle(buf); } void ags_getDIBInfo(DispInfo *info) { @@ -204,13 +204,13 @@ void ags_getDIBInfo(DispInfo *info) { } void ags_getViewAreaInfo(DispInfo *info) { - sdl_getWindowInfo(info); + gfx_getWindowInfo(info); info->width = nact->ags.view_area.w; info->height = nact->ags.view_area.h; } void ags_getWindowInfo(DispInfo *info) { - sdl_getWindowInfo(info); + gfx_getWindowInfo(info); } void ags_setExposeSwitch(bool expose) { @@ -227,7 +227,7 @@ void ags_updateArea(int x, int y, int w, int h) { update.x - nact->ags.view_area.x, update.y - nact->ags.view_area.y }; - sdl_updateArea(&update, &p); + gfx_updateArea(&update, &p); } } @@ -242,7 +242,7 @@ void ags_updateFull() { min(nact->ags.view_area.h, nact->ags.world_size.height) }; MyPoint p = {0, 0}; - sdl_updateArea(&r, &p); + gfx_updateArea(&r, &p); } void ags_setPalettes(SDL_Color *src, int dst, int cnt) { @@ -261,47 +261,47 @@ void ags_setPalette(int no, int red, int green, int blue) { void ags_setPaletteToSystem(int src, int cnt) { if (!fade_outed) - sdl_setPalette(nact->ags.pal, src, cnt); + gfx_setPalette(nact->ags.pal, src, cnt); } void ags_drawRectangle(int x, int y, int w, int h, int col) { if (!ags_check_param(&x, &y, &w, &h)) return; - sdl_drawRectangle(x, y, w, h, col); + gfx_drawRectangle(x, y, w, h, col); } void ags_fillRectangle(int x, int y, int w, int h, int col) { if (!ags_check_param(&x, &y, &w, &h)) return; - sdl_fillRectangle(x, y, w, h, col); + gfx_fillRectangle(x, y, w, h, col); } void ags_drawLine(int x0, int y0, int x1, int y1, int col) { if (!ags_check_param_xy(&x0, &y0)) return; if (!ags_check_param_xy(&x1, &y1)) return; - sdl_drawLine(x0, y0, x1, y1, col); + gfx_drawLine(x0, y0, x1, y1, col); } void ags_copyArea(int sx, int sy, int w, int h, int dx, int dy) { if (!ags_check_param(&sx, &sy, &w, &h)) return; if (!ags_check_param(&dx, &dy, &w, &h)) return; - sdl_copyArea(sx, sy, w, h, dx, dy); + gfx_copyArea(sx, sy, w, h, dx, dy); } void ags_scaledCopyArea(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mirror_sw) { if (!ags_check_param(&sx, &sy, &sw, &sh)) return; if (!ags_check_param(&dx, &dy, &dw, &dh)) return; - sdl_scaledCopyArea(sx, sy, sw, sh, dx, dy, dw, dh, mirror_sw); + gfx_scaledCopyArea(sx, sy, sw, sh, dx, dy, dw, dh, mirror_sw); } void ags_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, int col) { if (!ags_check_param(&sx, &sy, &w, &h)) return; if (!ags_check_param(&dx, &dy, &w, &h)) return; - sdl_copyAreaSP(sx, sy, w, h, dx, dy, col); + gfx_copyAreaSP(sx, sy, w, h, dx, dy, col); } void ags_wrapColor(int x, int y, int w, int h, int p1, int p2) { @@ -309,13 +309,13 @@ void ags_wrapColor(int x, int y, int w, int h, int p1, int p2) { if (!ags_check_param(&x, &y, &w, &h)) return; - sdl_wrapColor(x, y, w, h, p1, p2); + gfx_wrapColor(x, y, w, h, p1, p2); } void ags_getPixel(int x, int y, Palette *cell) { if (!ags_check_param_xy(&x, &y)) return; - sdl_getPixel(x, y, cell); + gfx_getPixel(x, y, cell); } void ags_copyPaletteShift(int sx, int sy, int w, int h, int dx, int dy, uint8_t sprite) { @@ -357,7 +357,7 @@ void ags_changeColorArea(int sx, int sy, int w, int h, int dst, int src, int cnt void* ags_saveRegion(int x, int y, int w, int h) { if (!ags_check_param(&x, &y, &w, &h)) return NULL; - return (void *)sdl_saveRegion(x, y, w, h); + return (void *)gfx_saveRegion(x, y, w, h); } void ags_restoreRegion(void *region, int x, int y) { @@ -365,7 +365,7 @@ void ags_restoreRegion(void *region, int x, int y) { if (!ags_check_param_xy(&x, &y)) return; - sdl_restoreRegion(region, x, y); + gfx_restoreRegion(region, x, y); } void ags_putRegion(void *region, int x, int y) { @@ -373,13 +373,13 @@ void ags_putRegion(void *region, int x, int y) { if (!ags_check_param_xy(&x, &y)) return; - sdl_putRegion(region, x, y); + gfx_putRegion(region, x, y); } void ags_delRegion(void *region) { if (region == NULL) return; - sdl_delRegion(region); + gfx_delRegion(region); } int ags_drawString(int x, int y, const char *src, int col, MyRectangle *rect_out) { @@ -401,46 +401,46 @@ int ags_drawString(int x, int y, const char *src, int col, MyRectangle *rect_out adj.x = 0; adj.y = 0; adj.w = 0; adj.h = 0; break; case TEXT_DECORATION_DROP_SHADOW_BOTTOM: - sdl_drawString(x, y +1, utf8, nact->ags.text_decoration_color); + gfx_drawString(x, y +1, utf8, nact->ags.text_decoration_color); adj.x = 0; adj.y = 0; adj.w = 0; adj.h = 1; break; case TEXT_DECORATION_DROP_SHADOW_RIGHT: - sdl_drawString(x +1, y, utf8, nact->ags.text_decoration_color); + gfx_drawString(x +1, y, utf8, nact->ags.text_decoration_color); adj.x = 0; adj.y = 0; adj.w = 1; adj.h = 0; break; case TEXT_DECORATION_DROP_SHADOW_BOTTOM_RIGHT: - sdl_drawString(x +1, y +1, utf8, nact->ags.text_decoration_color); + gfx_drawString(x +1, y +1, utf8, nact->ags.text_decoration_color); adj.x = 0; adj.y = 0; adj.w = 1; adj.h = 1; break; case TEXT_DECORATION_OUTLINE: - sdl_drawString(x -1, y, utf8, nact->ags.text_decoration_color); - sdl_drawString(x +1, y, utf8, nact->ags.text_decoration_color); - sdl_drawString(x, y -1, utf8, nact->ags.text_decoration_color); - sdl_drawString(x, y +1, utf8, nact->ags.text_decoration_color); + gfx_drawString(x -1, y, utf8, nact->ags.text_decoration_color); + gfx_drawString(x +1, y, utf8, nact->ags.text_decoration_color); + gfx_drawString(x, y -1, utf8, nact->ags.text_decoration_color); + gfx_drawString(x, y +1, utf8, nact->ags.text_decoration_color); adj.x = -1; adj.y = -1; adj.w = 2; adj.h = 2; break; case TEXT_DECORATION_BOLD_HORIZONTAL: - sdl_drawString(x +1, y, utf8, col); + gfx_drawString(x +1, y, utf8, col); adj.x = 0; adj.y = 0; adj.w = 1; adj.h = 0; break; case TEXT_DECORATION_BOLD_VERTICAL: - sdl_drawString(x, y +1, utf8, col); + gfx_drawString(x, y +1, utf8, col); adj.x = 0; adj.y = 0; adj.w = 0; adj.h = 1; break; case TEXT_DECORATION_BOLD_HORIZONTAL_VERTICAL: - sdl_drawString(x +1, y +1, utf8, col); + gfx_drawString(x +1, y +1, utf8, col); adj.x = 0; adj.y = 0; adj.w = 1; adj.h = 1; break; case TEXT_DECORATION_DROP_SHADOW_OUTLINE: - sdl_drawString(x -1, y , utf8, nact->ags.text_decoration_color); - sdl_drawString(x +1, y , utf8, nact->ags.text_decoration_color); - sdl_drawString(x , y -1, utf8, nact->ags.text_decoration_color); - sdl_drawString(x , y +1, utf8, nact->ags.text_decoration_color); - sdl_drawString(x +2, y +2, utf8, nact->ags.text_decoration_color); + gfx_drawString(x -1, y , utf8, nact->ags.text_decoration_color); + gfx_drawString(x +1, y , utf8, nact->ags.text_decoration_color); + gfx_drawString(x , y -1, utf8, nact->ags.text_decoration_color); + gfx_drawString(x , y +1, utf8, nact->ags.text_decoration_color); + gfx_drawString(x +2, y +2, utf8, nact->ags.text_decoration_color); adj.x = -1; adj.y = -1; adj.w = 3; adj.h = 3; break; } - SDL_Rect r = sdl_drawString(x, y, utf8, col); + SDL_Rect r = gfx_drawString(x, y, utf8, col); if (rect_out) { rect_out->x = r.x + adj.x; rect_out->y = r.y + adj.y; @@ -461,13 +461,13 @@ SDL_Surface *ags_drawStringToSurface(const char *str, int r, int g, int b) { void ags_drawCg(cgdata *cg, int x, int y, int brightness, int sprite_color, bool alpha_blend) { switch (cg->depth) { case 8: - sdl_drawImage8(cg, x, y, sprite_color); + gfx_drawImage8(cg, x, y, sprite_color); break; case 16: - sdl_drawImage16(cg, nact->ags.dib, x, y, brightness, alpha_blend); + gfx_drawImage16(cg, nact->ags.dib, x, y, brightness, alpha_blend); break; case 24: - sdl_drawImage24(cg, nact->ags.dib, x, y, brightness); + gfx_drawImage24(cg, nact->ags.dib, x, y, brightness); break; } } @@ -478,7 +478,7 @@ void ags_copyArea_shadow(int sx, int sy, int w, int h, int dx, int dy) { if (!ags_check_param(&sx, &sy, &w, &h)) return; if (!ags_check_param(&dx, &dy, &w, &h)) return; - sdl_copyAreaSP16_shadow(sx, sy, w, h, dx, dy, 255); + gfx_copyAreaSP16_shadow(sx, sy, w, h, dx, dy, 255); } void ags_copyArea_transparent(int sx, int sy, int w, int h, int dx, int dy, int col) { @@ -487,7 +487,7 @@ void ags_copyArea_transparent(int sx, int sy, int w, int h, int dx, int dy, int if (!ags_check_param(&sx, &sy, &w, &h)) return; if (!ags_check_param(&dx, &dy, &w, &h)) return; - sdl_copyAreaSP(sx, sy, w, h, dx, dy, col); + gfx_copyAreaSP(sx, sy, w, h, dx, dy, col); } void ags_copyArea_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, int lv) { @@ -496,7 +496,7 @@ void ags_copyArea_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, int l if (!ags_check_param(&sx, &sy, &w, &h)) return; if (!ags_check_param(&dx, &dy, &w, &h)) return; - sdl_copyAreaSP16_alphaLevel(sx, sy, w, h, dx, dy, lv); + gfx_copyAreaSP16_alphaLevel(sx, sy, w, h, dx, dy, lv); } void ags_copyArea_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int lv) { @@ -505,14 +505,14 @@ void ags_copyArea_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int l if (!ags_check_param(&sx, &sy, &w, &h)) return; if (!ags_check_param(&dx, &dy, &w, &h)) return; - sdl_copyAreaSP16_alphaBlend(sx, sy, w, h, dx, dy, lv); + gfx_copyAreaSP16_alphaBlend(sx, sy, w, h, dx, dy, lv); } MyRectangle ags_floodFill(int x, int y, int col) { if (!ags_check_param_xy(&x, &y)) return (MyRectangle){}; - return sdl_floodFill(x, y, col); + return gfx_floodFill(x, y, col); } void ags_copyFromAlpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flg) { @@ -521,7 +521,7 @@ void ags_copyFromAlpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_C if (!ags_check_param(&sx, &sy, &w, &h)) return; if (!ags_check_param(&dx, &dy, &w, &h)) return; - sdl_copy_from_alpha(sx, sy, w, h, dx, dy, flg); + gfx_copy_from_alpha(sx, sy, w, h, dx, dy, flg); } void ags_copyToAlpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flg) { @@ -530,7 +530,7 @@ void ags_copyToAlpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COP if (!ags_check_param(&sx, &sy, &w, &h)) return; if (!ags_check_param(&dx, &dy, &w, &h)) return; - sdl_copy_to_alpha(sx, sy, w, h, dx, dy, flg); + gfx_copy_to_alpha(sx, sy, w, h, dx, dy, flg); } void ags_alpha_uppercut(int sx, int sy, int w, int h, int s, int d) { @@ -610,7 +610,7 @@ static void fade(int duration, bool cancelable, enum sdl_effect_type type) { SDL_Rect rect = {0, 0, nact->ags.view_area.w, nact->ags.view_area.h}; struct sdl_effect *eff = sdl_effect_init( &rect, NULL, 0, 0, - sdl_getDIB(), nact->ags.view_area.x, nact->ags.view_area.y, + gfx_getDIB(), nact->ags.view_area.x, nact->ags.view_area.y, type); ags_runEffect(duration, cancelable, (ags_EffectStepFunc)sdl_effect_step, eff); sdl_effect_finish(eff); @@ -619,7 +619,7 @@ static void fade(int duration, bool cancelable, enum sdl_effect_type type) { void ags_fadeIn(int rate, bool flag) { fade_outed = false; if (nact->ags.world_depth == 8) - sdl_setPalette(nact->ags.pal, 0, 256); + gfx_setPalette(nact->ags.pal, 0, 256); if (!need_update) return; @@ -627,7 +627,7 @@ void ags_fadeIn(int rate, bool flag) { int duration = rate * 16 * 1000 / 60; fade(duration, flag, nact->ags.world_depth == 8 ? EFFECT_FADEIN : EFFECT_DITHERING_FADEIN); - sdl_updateAll(&nact->ags.view_area); + gfx_updateAll(&nact->ags.view_area); } void ags_fadeOut(int rate, bool flag) { @@ -642,14 +642,14 @@ void ags_fadeOut(int rate, bool flag) { for (int i = 0; i < 256; i++) { pal[i] = (SDL_Color){0, 0, 0, 255}; } - sdl_setPalette(pal, 0, 256); + gfx_setPalette(pal, 0, 256); } } void ags_whiteIn(int rate, bool flag) { fade_outed = false; if (nact->ags.world_depth == 8) - sdl_setPalette(nact->ags.pal, 0, 256); + gfx_setPalette(nact->ags.pal, 0, 256); if (!need_update) return; @@ -657,7 +657,7 @@ void ags_whiteIn(int rate, bool flag) { int duration = rate * 16 * 1000 / 60; fade(duration, flag, nact->ags.world_depth == 8 ? EFFECT_WHITEIN : EFFECT_DITHERING_WHITEIN); - sdl_updateAll(&nact->ags.view_area); + gfx_updateAll(&nact->ags.view_area); } void ags_whiteOut(int rate, bool flag) { @@ -670,7 +670,7 @@ void ags_whiteOut(int rate, bool flag) { if (nact->ags.world_depth == 8) { SDL_Color pal[256]; memset(&pal, 255, sizeof(pal)); - sdl_setPalette(pal, 0, 256); + gfx_setPalette(pal, 0, 256); } } @@ -758,7 +758,7 @@ void ags_copyArea_shadow_withrate(int sx, int sy, int w, int h, int dx, int dy, if (!ags_check_param(&sx, &sy, &w, &h)) return; if (!ags_check_param(&dx, &dy, &w, &h)) return; - sdl_copyAreaSP16_shadow(sx, sy, w, h, dx, dy, lv); + gfx_copyAreaSP16_shadow(sx, sy, w, h, dx, dy, lv); } void ags_setCursorMoveTime(int msec) { diff --git a/src/cmd2F.c b/src/cmd2F.c index d3cd3c0..705f38a 100644 --- a/src/cmd2F.c +++ b/src/cmd2F.c @@ -706,7 +706,7 @@ void commands2F43() { int eLength = getCaliValue(); int eColor = getCaliValue(); - sdl_fillCircle(eX, eY, eLength, eColor); + gfx_fillCircle(eX, eY, eLength, eColor); ags_updateArea(eX, eY, eLength, eLength); TRACE("grDrawFillCircle %d, %d, %d, %d:", eX, eY, eLength, eColor); @@ -784,7 +784,7 @@ void commands2F4C() { MyRectangle r = {eSrcX, eSrcY, eWidth, eHeight}; MyPoint p = {eX, eY}; - sdl_updateArea(&r, &p); + gfx_updateArea(&r, &p); TRACE("grBlt %d, %d, %d, %d, %d, %d:", eX, eY, eSrcX, eSrcY, eWidth, eHeight); diff --git a/src/cmd_check.c b/src/cmd_check.c index 37f4ec3..61a7bc5 100644 --- a/src/cmd_check.c +++ b/src/cmd_check.c @@ -181,7 +181,7 @@ void exec_command(void) { int c0 = sl_getc(); if (c0 == BREAKPOINT) { - sdl_updateScreen(); + gfx_updateScreen(); c0 = dbg_handle_breakpoint(sl_getPage(), sl_getIndex() - 1); } diff --git a/src/cmdz.c b/src/cmdz.c index 258e2c1..8dc26bc 100644 --- a/src/cmdz.c +++ b/src/cmdz.c @@ -462,7 +462,7 @@ void commandZZ10() { /* スクリーンモードを取得する */ int *var = getCaliVariable(); - *var = sdl_isFullscreen() ? 1 : 0; + *var = gfx_isFullscreen() ? 1 : 0; TRACE("ZZ10 %d:",*var); } diff --git a/src/debugger_dap.c b/src/debugger_dap.c index 3ea581e..e42f283 100644 --- a/src/debugger_dap.c +++ b/src/debugger_dap.c @@ -296,7 +296,7 @@ static void cmd_evaluate(cJSON *args, cJSON *resp) { } static void cmd_continue(cJSON *args, cJSON *resp) { - sdl_raiseWindow(); + gfx_raiseWindow(); cJSON_AddBoolToObject(resp, "success", true); } diff --git a/src/ecopy.c b/src/ecopy.c index 929b833..d057358 100644 --- a/src/ecopy.c +++ b/src/ecopy.c @@ -51,7 +51,7 @@ static void eCopyUpdateArea(int sx, int sy, int w, int h, int dx, int dy) { dx - nact->ags.view_area.x, dy - nact->ags.view_area.y }; - sdl_updateArea(&src, &dst); + gfx_updateArea(&src, &dst); } static int eCopyArea5(int sx, int sy, int w, int h, int dx, int dy, int opt) { @@ -110,13 +110,13 @@ static int eCopyArea9(int sx, int sy, int w, int h, int dx, int dy, int opt) { cnt+=waitcnt; for (y = 0; y < h -15; y+=16) { for (x = 0; x < (w -7); x+=16) { - sdl_copyArea(sx + x + hintX[i],sy + y + hintY[i], 8, 8, dx + x + hintX[i], dy + y + hintY[i]); + gfx_copyArea(sx + x + hintX[i],sy + y + hintY[i], 8, 8, dx + x + hintX[i], dy + y + hintY[i]); } } ags_updateArea(dx, dy, w, h); EC_WAIT; } - sdl_copyArea(sx, sy, w, h, dx, dy); + gfx_copyArea(sx, sy, w, h, dx, dy); ags_updateArea(dx, dy, w, h); return key; } @@ -189,7 +189,7 @@ static int eCopyArea23(int sx, int sy, int w, int h, int dx, int dy, int opt) { cnt += waitcnt; for (y = 0; y < (h -3); y+=4) { for (x = 0; x < (w -3); x+=4) { - sdl_copyArea(sx + x + hintX[i], sy + y + hintY[i], 2, 2, + gfx_copyArea(sx + x + hintX[i], sy + y + hintY[i], 2, 2, dx + x + hintX[i], dy + y + hintY[i]); } } @@ -207,7 +207,7 @@ static int eCopyArea1000(int sx, int sy, int w, int h, int dx, int dy, int opt) } static int eCopyArea2000(int sx, int sy, int w, int h, int dx, int dy, int opt) { - sdl_fillRectangleRGB(dx, dy, w, h, 0, 0, 0); + gfx_fillRectangleRGB(dx, dy, w, h, 0, 0, 0); ags_copyArea_alphaLevel(sx, sy, w, h, dx, dy, opt); ags_updateArea(dx, dy, w, h); return sys_getInputInfo(); @@ -315,7 +315,7 @@ void ags_eCopyArea(int sx, int sy, int w, int h, int dx, int dy, int sw, int opt if (sw == NACT_EFFECT_MAGNIFY) { SDL_Rect target_rect = { sx, sy, w, h }; - struct sdl_effect *eff = sdl_effect_magnify_init(sdl_getDIB(), &nact->ags.view_area, &target_rect); + struct sdl_effect *eff = sdl_effect_magnify_init(gfx_getDIB(), &nact->ags.view_area, &target_rect); ags_runEffect(duration(sw, opt, NULL), cancel, (ags_EffectStepFunc)sdl_effect_step, eff); sdl_effect_finish(eff); // Actual copy. @@ -329,21 +329,21 @@ void ags_eCopyArea(int sx, int sy, int w, int h, int dx, int dy, int sw, int opt enum sdl_effect_type sdl_effect = from_nact_effect(sw); if (sdl_effect != EFFECT_INVALID) { SDL_Rect rect = { dx - nact->ags.view_area.x, dy - nact->ags.view_area.y, w, h }; - // Note that we specify NULL (which means sdl_texture) for the old - // surface rather than sdl_getDIB(). This is to use the current display + // Note that we specify NULL (which means gfx_texture) for the old + // surface rather than gfx_getDIB(). This is to use the current display // contents, not reflecting uncommitted palette changes. - struct sdl_effect *eff = sdl_effect_init(&rect, NULL, rect.x, rect.y, sdl_getDIB(), sx, sy, sdl_effect); + struct sdl_effect *eff = sdl_effect_init(&rect, NULL, rect.x, rect.y, gfx_getDIB(), sx, sy, sdl_effect); ags_runEffect(duration(sw, opt, &rect), cancel, (ags_EffectStepFunc)sdl_effect_step, eff); sdl_effect_finish(eff); // Actual copy. switch (sw) { case NACT_EFFECT_FADEOUT: - sdl_fillRectangleRGB(dx, dy, w, h, 0, 0, 0); + gfx_fillRectangleRGB(dx, dy, w, h, 0, 0, 0); ags_updateArea(dx, dy, w, h); break; case NACT_EFFECT_WHITEOUT: - sdl_fillRectangleRGB(dx, dy, w, h, 255, 255, 255); + gfx_fillRectangleRGB(dx, dy, w, h, 255, 255, 255); ags_updateArea(dx, dy, w, h); break; default: diff --git a/src/flood.h b/src/flood.h index d4107c9..e432704 100644 --- a/src/flood.h +++ b/src/flood.h @@ -19,7 +19,7 @@ #define CONCATENATE(x, y) x ## y #define CONCAT(x, y) CONCATENATE(x, y) -static SDL_Rect CONCAT(sdl_floodFill_, TYPE)(int x, int y, Uint32 col) { +static SDL_Rect CONCAT(gfx_floodFill_, TYPE)(int x, int y, Uint32 col) { int old_color = *(TYPE *)PIXEL_AT(main_surface, x, y); if (old_color == col) return (SDL_Rect){}; diff --git a/src/font.c b/src/font.c index 8d43704..a2fb6c7 100644 --- a/src/font.c +++ b/src/font.c @@ -35,7 +35,7 @@ #include "portab.h" #include "system.h" #include "font.h" -#include "sdl_private.h" +#include "gfx_private.h" #include "hacks.h" typedef struct { @@ -130,9 +130,9 @@ SDL_Surface *font_get_glyph(const char *str_utf8, int r, int g, int b) { } // SDL can't blit ARGB to an indexed bitmap properly, so we do it ourselves. -static void sdl_drawAntiAlias_8bpp(int dstx, int dsty, SDL_Surface *src, uint8_t col) +static void gfx_drawAntiAlias_8bpp(int dstx, int dsty, SDL_Surface *src, uint8_t col) { - const SDL_Color* palette = sdl_palette->colors; + const SDL_Color* palette = gfx_palette->colors; Uint8 cache[256*7]; memset(cache, 0, 256); @@ -154,7 +154,7 @@ static void sdl_drawAntiAlias_8bpp(int dstx, int dsty, SDL_Surface *src, uint8_t } else { // find nearest color in palette cache[*dp] |= 1 << alpha; - int c = sdl_nearest_color( + int c = gfx_nearest_color( (palette[col].r * alpha + palette[*dp].r * (7 - alpha)) / 7, (palette[col].g * alpha + palette[*dp].g * (7 - alpha)) / 7, (palette[col].b * alpha + palette[*dp].b * (7 - alpha)) / 7); @@ -186,9 +186,9 @@ SDL_Rect font_draw_glyph(int x, int y, const char *str_utf8, uint8_t cl) { antialias = false; if (antialias) { - fs = TTF_RenderUTF8_Blended(fontset->id, str_utf8, sdl_palette->colors[cl]); + fs = TTF_RenderUTF8_Blended(fontset->id, str_utf8, gfx_palette->colors[cl]); } else { - fs = TTF_RenderUTF8_Solid(fontset->id, str_utf8, sdl_palette->colors[cl]); + fs = TTF_RenderUTF8_Solid(fontset->id, str_utf8, gfx_palette->colors[cl]); } if (!fs) { WARNING("Text rendering failed: %s", TTF_GetError()); @@ -201,7 +201,7 @@ SDL_Rect font_draw_glyph(int x, int y, const char *str_utf8, uint8_t cl) { r_dst = (SDL_Rect){x, y, w, h}; if (main_surface->format->BitsPerPixel == 8 && antialias) { - sdl_drawAntiAlias_8bpp(x, y, fs, cl); + gfx_drawAntiAlias_8bpp(x, y, fs, cl); } else { r_src = (SDL_Rect){0, 0, w, h}; SDL_BlitSurface(fs, &r_src, main_surface, &r_dst); diff --git a/src/sdl_draw.c b/src/gfx_draw.c similarity index 70% rename from src/sdl_draw.c rename to src/gfx_draw.c index 6518d74..2edeb66 100644 --- a/src/sdl_draw.c +++ b/src/gfx_draw.c @@ -1,5 +1,5 @@ /* - * sdl_darw.c SDL draw to surface + * gfx_draw.c SDL draw to surface * * Copyright (C) 2000- Fumihiko Murata * @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ -/* $Id: sdl_draw.c,v 1.13 2003/01/25 01:34:50 chikama Exp $ */ +/* $Id: gfx_draw.c,v 1.13 2003/01/25 01:34:50 chikama Exp $ */ #include "config.h" @@ -35,7 +35,7 @@ #include "portab.h" #include "system.h" #include "sdl_core.h" -#include "sdl_private.h" +#include "gfx_private.h" #include "scheduler.h" #include "font.h" #include "ags.h" @@ -43,26 +43,26 @@ #include "nact.h" #include "debugger.h" -static void sdl_pal_check(void) { +static void gfx_pal_check(void) { if (nact->ags.pal_changed) { nact->ags.pal_changed = false; - sdl_setPalette(nact->ags.pal, 0, 256); + gfx_setPalette(nact->ags.pal, 0, 256); } } static Uint32 palette_color(uint8_t c) { if (main_surface->format->BitsPerPixel == 8) return c; - return SDL_MapRGB(main_surface->format, sdl_palette->colors[c].r, sdl_palette->colors[c].g, sdl_palette->colors[c].b); + return SDL_MapRGB(main_surface->format, gfx_palette->colors[c].r, gfx_palette->colors[c].g, gfx_palette->colors[c].b); } -void sdl_updateScreen(void) { - if (!sdl_dirty) +void gfx_updateScreen(void) { + if (!gfx_dirty) return; - SDL_RenderClear(sdl_renderer); - SDL_RenderCopy(sdl_renderer, sdl_texture, NULL, NULL); - SDL_RenderPresent(sdl_renderer); - sdl_dirty = false; + SDL_RenderClear(gfx_renderer); + SDL_RenderCopy(gfx_renderer, gfx_texture, NULL, NULL); + SDL_RenderPresent(gfx_renderer); + gfx_dirty = false; } uint32_t sdl_getTicks(void) { @@ -70,7 +70,7 @@ uint32_t sdl_getTicks(void) { } void sdl_sleep(int msec) { - sdl_updateScreen(); + gfx_updateScreen(); dbg_onsleep(); #ifdef __EMSCRIPTEN__ emscripten_sleep(msec); @@ -92,7 +92,7 @@ EM_JS(void, wait_vsync, (void), { #endif void sdl_wait_vsync() { - sdl_updateScreen(); + gfx_updateScreen(); dbg_onsleep(); #ifdef __EMSCRIPTEN__ wait_vsync(); @@ -103,7 +103,7 @@ void sdl_wait_vsync() { } /* off-screen の指定領域を Main Window へ転送 */ -void sdl_updateArea(MyRectangle *rect, MyPoint *dst) { +void gfx_updateArea(MyRectangle *rect, MyPoint *dst) { SDL_Rect sw = {0, 0, main_surface->w, main_surface->h}; SDL_Rect dw = {0, 0, view_w, view_h}; SDL_Rect sr = {rect->x, rect->y, rect->w, rect->h}; @@ -114,26 +114,26 @@ void sdl_updateArea(MyRectangle *rect, MyPoint *dst) { dr.h = sr.h; SDL_Surface *sf; - SDL_LockTextureToSurface(sdl_texture, &dr, &sf); + SDL_LockTextureToSurface(gfx_texture, &dr, &sf); SDL_BlitSurface(main_surface, &sr, sf, NULL); - SDL_UnlockTexture(sdl_texture); + SDL_UnlockTexture(gfx_texture); - sdl_dirty = true; + gfx_dirty = true; } /* 全画面更新 */ -void sdl_updateAll(MyRectangle *view_rect) { - sdl_updateArea(view_rect, &(MyPoint){0, 0}); +void gfx_updateAll(MyRectangle *view_rect) { + gfx_updateArea(view_rect, &(MyPoint){0, 0}); } /* Color の複数個指定 */ -void sdl_setPalette(SDL_Color *pal, int first, int count) { - SDL_SetPaletteColors(sdl_palette, pal + first, first, count); +void gfx_setPalette(SDL_Color *pal, int first, int count) { + SDL_SetPaletteColors(gfx_palette, pal + first, first, count); } /* 矩形の描画 */ -void sdl_drawRectangle(int x, int y, int w, int h, uint8_t c) { - sdl_pal_check(); +void gfx_drawRectangle(int x, int y, int w, int h, uint8_t c) { + gfx_pal_check(); Uint32 col = palette_color(c); SDL_Rect rect = {x, y, w, 1}; @@ -150,14 +150,14 @@ void sdl_drawRectangle(int x, int y, int w, int h, uint8_t c) { } /* 矩形塗りつぶし */ -void sdl_fillRectangle(int x, int y, int w, int h, uint8_t c) { - sdl_pal_check(); +void gfx_fillRectangle(int x, int y, int w, int h, uint8_t c) { + gfx_pal_check(); SDL_Rect rect = {x, y, w, h}; SDL_FillRect(main_surface, &rect, palette_color(c)); } -void sdl_fillRectangleRGB(int x, int y, int w, int h, uint8_t r, uint8_t g, uint8_t b) { +void gfx_fillRectangleRGB(int x, int y, int w, int h, uint8_t r, uint8_t g, uint8_t b) { if (main_surface->format->BitsPerPixel == 8) return; @@ -165,7 +165,7 @@ void sdl_fillRectangleRGB(int x, int y, int w, int h, uint8_t r, uint8_t g, uint SDL_FillRect(main_surface, &rect, SDL_MapRGB(main_surface->format, r, g, b)); } -void sdl_fillCircle(int left, int top, int diameter, uint8_t c) { +void gfx_fillCircle(int left, int top, int diameter, uint8_t c) { diameter &= ~1; if (diameter <= 0) return; @@ -188,7 +188,7 @@ void sdl_fillCircle(int left, int top, int diameter, uint8_t c) { } /* 領域コピー */ -void sdl_copyArea(int sx, int sy, int w, int h, int dx, int dy) { +void gfx_copyArea(int sx, int sy, int w, int h, int dx, int dy) { if (sx == dx && sy == dy) return; @@ -197,15 +197,15 @@ void sdl_copyArea(int sx, int sy, int w, int h, int dx, int dy) { SDL_Rect intersect; if (SDL_IntersectRect(&r_src, &r_dst, &intersect)) { - void* region = sdl_saveRegion(sx, sy, w, h); - sdl_restoreRegion(region, dx, dy); + void* region = gfx_saveRegion(sx, sy, w, h); + gfx_restoreRegion(region, dx, dy); } else { SDL_BlitSurface(main_surface, &r_src, main_surface, &r_dst); } } -static void sdl_dib_sprite_copy(SDL_Surface *dst, int sx, int sy, int w, int h, int dx, int dy, uint8_t sp) { - sdl_pal_check(); +static void gfx_dib_sprite_copy(SDL_Surface *dst, int sx, int sy, int w, int h, int dx, int dy, uint8_t sp) { + gfx_pal_check(); Uint32 col = palette_color(sp); SDL_SetColorKey(main_surface, SDL_TRUE, col); @@ -220,29 +220,29 @@ static void sdl_dib_sprite_copy(SDL_Surface *dst, int sx, int sy, int w, int h, /* * dib に指定のパレット sp を抜いてコピー */ -void sdl_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, uint8_t sp) { - sdl_dib_sprite_copy(main_surface, sx, sy, w, h, dx, dy, sp); +void gfx_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, uint8_t sp) { + gfx_dib_sprite_copy(main_surface, sx, sy, w, h, dx, dy, sp); } -SDL_Surface *sdl_dib_to_surface_colorkey(int x, int y, int w, int h, int sp) { +SDL_Surface *gfx_dib_to_surface_colorkey(int x, int y, int w, int h, int sp) { SDL_Surface *s = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, SDL_PIXELFORMAT_ARGB8888); SDL_FillRect(s, NULL, 0); - sdl_dib_sprite_copy(s, x, y, w, h, 0, 0, sp); + gfx_dib_sprite_copy(s, x, y, w, h, 0, 0, sp); return s; } -void sdl_drawImage8(cgdata *cg, int dx, int dy, int sprite_color) { +void gfx_drawImage8(cgdata *cg, int dx, int dy, int sprite_color) { int w = cg->width; int h = cg->height; SDL_Surface *s = SDL_CreateRGBSurfaceWithFormatFrom( cg->pic, w, h, 8, w, SDL_PIXELFORMAT_INDEX8); - sdl_pal_check(); + gfx_pal_check(); if (main_surface->format->BitsPerPixel > 8 && cg->pal) { SDL_SetPaletteColors(s->format->palette, cg->pal, 0, 256); } else { - SDL_SetSurfacePalette(s, sdl_palette); + SDL_SetSurfacePalette(s, gfx_palette); } if (sprite_color != -1) @@ -255,11 +255,11 @@ void sdl_drawImage8(cgdata *cg, int dx, int dy, int sprite_color) { } /* 直線描画 */ -void sdl_drawLine(int x1, int y1, int x2, int y2, uint8_t c) { - sdl_pal_check(); +void gfx_drawLine(int x1, int y1, int x2, int y2, uint8_t c) { + gfx_pal_check(); SDL_Renderer *renderer = SDL_CreateSoftwareRenderer(main_surface); - SDL_SetRenderDrawColor(renderer, sdl_palette->colors[c].r, sdl_palette->colors[c].g, sdl_palette->colors[c].b, SDL_ALPHA_OPAQUE); + SDL_SetRenderDrawColor(renderer, gfx_palette->colors[c].r, gfx_palette->colors[c].g, gfx_palette->colors[c].b, SDL_ALPHA_OPAQUE); SDL_RenderDrawLine(renderer, x1, y1, x2, y2); SDL_DestroyRenderer(renderer); } @@ -274,28 +274,28 @@ void sdl_drawLine(int x1, int y1, int x2, int y2, uint8_t c) { #include "flood.h" #undef TYPE -SDL_Rect sdl_floodFill(int x, int y, int c) { +SDL_Rect gfx_floodFill(int x, int y, int c) { Uint32 col = palette_color(c); switch (main_surface->format->BytesPerPixel) { case 1: - return sdl_floodFill_uint8_t(x, y, col); + return gfx_floodFill_uint8_t(x, y, col); case 2: - return sdl_floodFill_uint16_t(x, y, col); + return gfx_floodFill_uint16_t(x, y, col); case 4: - return sdl_floodFill_uint32_t(x, y, col); + return gfx_floodFill_uint32_t(x, y, col); default: - WARNING("sdl_floodFill: unsupported DIB format"); + WARNING("gfx_floodFill: unsupported DIB format"); return (SDL_Rect){}; } } -int sdl_nearest_color(int r, int g, int b) { +int gfx_nearest_color(int r, int g, int b) { int i, col, mind = INT_MAX; for (i = 0; i < 256; i++) { - int dr = r - sdl_palette->colors[i].r; - int dg = g - sdl_palette->colors[i].g; - int db = b - sdl_palette->colors[i].b; + int dr = r - gfx_palette->colors[i].r; + int dg = g - gfx_palette->colors[i].g; + int db = b - gfx_palette->colors[i].b; int d = dr*dr*30 + dg*dg*59 + db*db*11; if (d < mind) { mind = d; @@ -305,15 +305,15 @@ int sdl_nearest_color(int r, int g, int b) { return col; } -SDL_Rect sdl_drawString(int x, int y, const char *str_utf8, uint8_t col) { - sdl_pal_check(); +SDL_Rect gfx_drawString(int x, int y, const char *str_utf8, uint8_t col) { + gfx_pal_check(); return font_draw_glyph(x, y, str_utf8, col); } /* * 指定範囲にパレット col を rate の割合で重ねる CK1 */ -void sdl_wrapColor(int sx, int sy, int w, int h, uint8_t c, int rate) { +void gfx_wrapColor(int sx, int sy, int w, int h, uint8_t c, int rate) { SDL_Surface *s = SDL_CreateRGBSurfaceWithFormat(0, w, h, main_surface->format->BitsPerPixel, main_surface->format->format); assert(s->format->BitsPerPixel > 8); diff --git a/src/sdl_image.c b/src/gfx_image.c similarity index 83% rename from src/sdl_image.c rename to src/gfx_image.c index 0b8d0dd..2c74cd5 100644 --- a/src/sdl_image.c +++ b/src/gfx_image.c @@ -1,5 +1,5 @@ /* - * sdl_image.c image操作 for SDL + * gfx_image.c image操作 for SDL * * Copyright (C) 2000- Fumihiko Murata * @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ -/* $Id: sdl_image.c,v 1.23 2003/07/20 19:30:16 chikama Exp $ */ +/* $Id: gfx_image.c,v 1.23 2003/07/20 19:30:16 chikama Exp $ */ #include "config.h" @@ -29,13 +29,13 @@ #include "portab.h" #include "system.h" #include "sdl_core.h" -#include "sdl_private.h" +#include "gfx_private.h" #include "cg.h" #include "nact.h" #include "alpha_plane.h" #include "image.h" -void sdl_FlipSurfaceHorizontal(SDL_Surface *s) { +void gfx_FlipSurfaceHorizontal(SDL_Surface *s) { #if SDL_VERSION_ATLEAST(3, 2, 0) SDL_FlipSurface(s, SDL_FLIP_HORIZONTAL); #else @@ -57,7 +57,7 @@ void sdl_FlipSurfaceHorizontal(SDL_Surface *s) { #endif } -void sdl_FlipSurfaceVertical(SDL_Surface *s) { +void gfx_FlipSurfaceVertical(SDL_Surface *s) { #if SDL_VERSION_ATLEAST(3, 2, 0) SDL_FlipSurface(s, SDL_FLIP_VERTICAL); #else @@ -76,28 +76,28 @@ void sdl_FlipSurfaceVertical(SDL_Surface *s) { } // Scaled copy in main_surface -void sdl_scaledCopyArea(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mirror) { +void gfx_scaledCopyArea(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mirror) { SDL_Rect src_rect = {sx, sy, sw, sh}; SDL_Rect dst_rect = {dx, dy, dw, dh}; // NOTE: SDL_BlitScaled() does not support 8-bit surfaces. SDL_SoftStretch(main_surface, &src_rect, main_surface, &dst_rect); if (mirror) { SDL_IntersectRect(&dst_rect, &(SDL_Rect){0, 0, main_surface->w, main_surface->h}, &dst_rect); - SDL_Surface *view = sdl_createSurfaceView(main_surface, dst_rect.x, dst_rect.y, dst_rect.w, dst_rect.h); + SDL_Surface *view = gfx_createSurfaceView(main_surface, dst_rect.x, dst_rect.y, dst_rect.w, dst_rect.h); if (mirror & 1) - sdl_FlipSurfaceVertical(view); + gfx_FlipSurfaceVertical(view); if (mirror & 2) - sdl_FlipSurfaceHorizontal(view); + gfx_FlipSurfaceHorizontal(view); SDL_FreeSurface(view); } } -void sdl_drawImage16(cgdata *cg, surface_t *sf, int dx, int dy, int brightness, bool alpha_blend) { +void gfx_drawImage16(cgdata *cg, surface_t *sf, int dx, int dy, int brightness, bool alpha_blend) { int w = cg->width; int h = cg->height; if (cg->alpha && !alpha_blend) { - sdl_drawImageAlphaMap(cg, sf, dx, dy); + gfx_drawImageAlphaMap(cg, sf, dx, dy); } SDL_Surface *s; @@ -136,9 +136,9 @@ void sdl_drawImage16(cgdata *cg, surface_t *sf, int dx, int dy, int brightness, SDL_FreeSurface(s); } -void sdl_drawImage24(cgdata *cg, surface_t *sf, int x, int y, int brightness) { +void gfx_drawImage24(cgdata *cg, surface_t *sf, int x, int y, int brightness) { if (cg->alpha) { - sdl_drawImageAlphaMap(cg, sf, x, y); + gfx_drawImageAlphaMap(cg, sf, x, y); } SDL_Surface *s = SDL_CreateRGBSurfaceWithFormatFrom( @@ -151,7 +151,7 @@ void sdl_drawImage24(cgdata *cg, surface_t *sf, int x, int y, int brightness) { SDL_FreeSurface(s); } -void sdl_drawImageAlphaMap(cgdata *cg, surface_t *sf, int x, int y) { +void gfx_drawImageAlphaMap(cgdata *cg, surface_t *sf, int x, int y) { if (!cg->alpha || !sf->alpha) return; uint8_t *a_src = cg->alpha; @@ -164,14 +164,14 @@ void sdl_drawImageAlphaMap(cgdata *cg, surface_t *sf, int x, int y) { } } -SDL_Surface *sdl_dib_to_surface_with_alpha(int x, int y, int w, int h) { +SDL_Surface *gfx_dib_to_surface_with_alpha(int x, int y, int w, int h) { SDL_Surface *s = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, SDL_PIXELFORMAT_ARGB8888); SDL_Rect r_src = {x, y, w, h}; SDL_BlitSurface(main_surface, &r_src, s, NULL); uint8_t *p_ds = ALPHA_AT(s, 0, 0); - uint8_t *adata = GETOFFSET_ALPHA(sdl_dibinfo, x, y); + uint8_t *adata = GETOFFSET_ALPHA(gfx_dibinfo, x, y); for (int y = 0; y < h; y++) { uint8_t *p_src = adata; uint8_t *p_dst = p_ds; @@ -179,14 +179,14 @@ SDL_Surface *sdl_dib_to_surface_with_alpha(int x, int y, int w, int h) { *p_dst = *(p_src++); p_dst += 4; } - adata += sdl_dibinfo->width; + adata += gfx_dibinfo->width; p_ds += s->pitch; } return s; } -void sdl_copyAreaSP16_shadow(int sx, int sy, int w, int h, int dx, int dy, int lv) { - SDL_Surface *s = sdl_dib_to_surface_with_alpha(sx, sy, w, h); +void gfx_copyAreaSP16_shadow(int sx, int sy, int w, int h, int dx, int dy, int lv) { + SDL_Surface *s = gfx_dib_to_surface_with_alpha(sx, sy, w, h); if (lv < 255) SDL_SetSurfaceAlphaMod(s, lv); @@ -195,7 +195,7 @@ void sdl_copyAreaSP16_shadow(int sx, int sy, int w, int h, int dx, int dy, int l SDL_FreeSurface(s); } -void sdl_copyAreaSP16_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int lv) { +void gfx_copyAreaSP16_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int lv) { SDL_Rect r_src = {sx, sy, w, h}; SDL_Rect r_dst = {dx, dy, w, h}; SDL_SetSurfaceBlendMode(main_surface, SDL_BLENDMODE_BLEND); @@ -205,7 +205,7 @@ void sdl_copyAreaSP16_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, i SDL_SetSurfaceBlendMode(main_surface, SDL_BLENDMODE_NONE); } -void sdl_copyAreaSP16_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, int lv) { +void gfx_copyAreaSP16_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, int lv) { SDL_Rect r_src = {sx, sy, w, h}; SDL_Rect r_dst = {dx, dy, w, h}; SDL_SetSurfaceBlendMode(main_surface, SDL_BLENDMODE_BLEND); @@ -216,18 +216,18 @@ void sdl_copyAreaSP16_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, i SDL_SetSurfaceBlendMode(main_surface, SDL_BLENDMODE_NONE); } -void sdl_copy_from_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag) { +void gfx_copy_from_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag) { image_copy_from_alpha(nact->ags.dib, sx, sy, w, h, dx, dy, flag); } -void sdl_copy_to_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag) { +void gfx_copy_to_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag) { image_copy_to_alpha(nact->ags.dib, sx, sy, w, h, dx, dy, flag); } /* * dib のピクセル情報を取得 */ -void sdl_getPixel(int x, int y, Palette *cell) { +void gfx_getPixel(int x, int y, Palette *cell) { uint8_t *p = PIXEL_AT(main_surface, x, y); if (main_surface->format->BitsPerPixel == 8) { cell->pixel = *p; @@ -262,7 +262,7 @@ void sdl_getPixel(int x, int y, Palette *cell) { /* * dib から領域の切り出し */ -void* sdl_saveRegion(int x, int y, int w, int h) { +void* gfx_saveRegion(int x, int y, int w, int h) { SDL_Surface *s = SDL_CreateRGBSurfaceWithFormat(0, w, h, main_surface->format->BitsPerPixel, main_surface->format->format); if (main_surface->format->BitsPerPixel == 8) memcpy(s->format->palette->colors, main_surface->format->palette->colors, @@ -276,14 +276,14 @@ void* sdl_saveRegion(int x, int y, int w, int h) { /* * セーブした領域を破棄 */ -void sdl_delRegion(void *psrc) { +void gfx_delRegion(void *psrc) { SDL_FreeSurface((SDL_Surface *)psrc); } /* * dib にセーブした領域を回復 */ -void sdl_putRegion(void *psrc, int x, int y) { +void gfx_putRegion(void *psrc, int x, int y) { SDL_Surface *src = (SDL_Surface *)psrc; SDL_Rect r_src = {0, 0, src->w, src->h}; @@ -295,8 +295,8 @@ void sdl_putRegion(void *psrc, int x, int y) { /* * dib に dstを描画後、後始末 */ -void sdl_restoreRegion(void *psrc, int x, int y) { +void gfx_restoreRegion(void *psrc, int x, int y) { SDL_Surface *src = (SDL_Surface *)psrc; - sdl_putRegion(src, x ,y); + gfx_putRegion(src, x ,y); SDL_FreeSurface(src); } diff --git a/src/sdl_private.h b/src/gfx_private.h similarity index 70% rename from src/sdl_private.h rename to src/gfx_private.h index ebb6ed7..1b7461f 100644 --- a/src/sdl_private.h +++ b/src/gfx_private.h @@ -1,5 +1,5 @@ /* - * sdl_private.h SDL only private data + * gfx_private.h SDL only private data * * Copyright (C) 2000- Fumihiko Murata * @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ -/* $Id: sdl_private.h,v 1.4 2002/04/29 05:48:21 chikama Exp $ */ +/* $Id: gfx_private.h,v 1.4 2002/04/29 05:48:21 chikama Exp $ */ #ifndef __SDL_PRIVATE_H__ #define __SDL_PRIVATE_H__ @@ -30,22 +30,22 @@ #include "portab.h" #include "ags.h" -extern SDL_Window *sdl_window; -extern SDL_Renderer *sdl_renderer; -extern SDL_Texture *sdl_texture; -extern SDL_Palette *sdl_palette; -extern surface_t *sdl_dibinfo; +extern SDL_Window *gfx_window; +extern SDL_Renderer *gfx_renderer; +extern SDL_Texture *gfx_texture; +extern SDL_Palette *gfx_palette; +extern surface_t *gfx_dibinfo; extern int view_w; extern int view_h; -extern bool sdl_dirty; -extern bool sdl_fs_on; +extern bool gfx_dirty; +extern bool gfx_fullscreen; extern bool (*sdl_custom_event_handler)(const SDL_Event *); void sdl_event_init(void); void sdl_cursor_init(void); -int sdl_nearest_color(int r, int g, int b); +int gfx_nearest_color(int r, int g, int b); bool sdl_joy_open(int index); -SDL_Surface *sdl_dib_to_surface_with_alpha(int x, int y, int w, int h); -SDL_Surface *sdl_dib_to_surface_colorkey(int x, int y, int w, int h, int col); +SDL_Surface *gfx_dib_to_surface_with_alpha(int x, int y, int w, int h); +SDL_Surface *gfx_dib_to_surface_colorkey(int x, int y, int w, int h, int col); #endif /* __SDL_PRIVATE_H__ */ diff --git a/src/sdl_video.c b/src/gfx_video.c similarity index 74% rename from src/sdl_video.c rename to src/gfx_video.c index 5e8678a..89974d7 100644 --- a/src/sdl_video.c +++ b/src/gfx_video.c @@ -1,5 +1,5 @@ /* - * sdl_video.c SDL video init + * gfx_video.c SDL video init * * Copyright (C) 2000- Fumihiko Murata * @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ -/* $Id: sdl_video.c,v 1.11 2003/01/04 17:01:02 chikama Exp $ */ +/* $Id: gfx_video.c,v 1.11 2003/01/04 17:01:02 chikama Exp $ */ #include "config.h" @@ -32,20 +32,20 @@ #include "portab.h" #include "system.h" #include "sdl_core.h" -#include "sdl_private.h" +#include "gfx_private.h" #include "xsystem35.h" #include "image.h" -SDL_Window *sdl_window; -SDL_Renderer *sdl_renderer; -SDL_Texture *sdl_texture; +SDL_Window *gfx_window; +SDL_Renderer *gfx_renderer; +SDL_Texture *gfx_texture; SDL_Surface *main_surface; // offscreen surface -SDL_Palette *sdl_palette; -surface_t *sdl_dibinfo; +SDL_Palette *gfx_palette; +surface_t *gfx_dibinfo; int view_w; int view_h; -bool sdl_dirty; -bool sdl_fs_on; +bool gfx_dirty; +bool gfx_fullscreen; bool (*sdl_custom_event_handler)(const SDL_Event *); static void window_init(const char *render_driver); @@ -83,7 +83,7 @@ static bool joy_open(void) { } /* SDL の初期化 */ -int sdl_Initialize(const char *render_driver) { +int gfx_Initialize(const char *render_driver) { window_init(render_driver); /* offscreen Pixmap */ @@ -92,7 +92,7 @@ int sdl_Initialize(const char *render_driver) { sdl_event_init(); sdl_cursor_init(); - sdl_setWindowSize(SYS35_DEFAULT_WIDTH, SYS35_DEFAULT_HEIGHT); + gfx_setWindowSize(SYS35_DEFAULT_WIDTH, SYS35_DEFAULT_HEIGHT); #ifdef __EMSCRIPTEN__ // Prevent SDL from calling emscripten_exit_fullscreen on visibilitychange @@ -103,13 +103,13 @@ int sdl_Initialize(const char *render_driver) { return 0; } -void sdl_Remove(void) { - if (sdl_palette) - SDL_FreePalette(sdl_palette); +void gfx_Remove(void) { + if (gfx_palette) + SDL_FreePalette(gfx_palette); if (main_surface) SDL_FreeSurface(main_surface); - if (sdl_renderer) - SDL_DestroyRenderer(sdl_renderer); + if (gfx_renderer) + SDL_DestroyRenderer(gfx_renderer); if (js) SDL_JoystickClose(js); SDL_Quit(); @@ -117,12 +117,12 @@ void sdl_Remove(void) { /* name is UTF-8 */ #ifdef __EMSCRIPTEN__ -EM_JS(void, sdl_setWindowTitle, (char *name), { +EM_JS(void, gfx_setWindowTitle, (char *name), { xsystem35.shell.setWindowTitle(UTF8ToString(name)); }); #else -void sdl_setWindowTitle(char *name) { - SDL_SetWindowTitle(sdl_window, name); +void gfx_setWindowTitle(char *name) { + SDL_SetWindowTitle(gfx_window, name); } #endif @@ -153,12 +153,12 @@ static void window_init(const char *render_driver) { #else Uint32 flags = SDL_WINDOW_RESIZABLE; #endif - sdl_window = SDL_CreateWindow( + gfx_window = SDL_CreateWindow( title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SYS35_DEFAULT_WIDTH, SYS35_DEFAULT_HEIGHT, flags); - sdl_renderer = SDL_CreateRenderer(sdl_window, -1, 0); - SDL_SetRenderDrawColor(sdl_renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); - sdl_palette = SDL_AllocPalette(256); + gfx_renderer = SDL_CreateRenderer(gfx_window, -1, 0); + SDL_SetRenderDrawColor(gfx_renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); + gfx_palette = SDL_AllocPalette(256); } static void makeDIB(int width, int height, int depth) { @@ -187,30 +187,30 @@ static void makeDIB(int width, int height, int depth) { main_surface = SDL_CreateRGBSurfaceWithFormat(0, width, height, depth, format); if (main_surface->format->BitsPerPixel == 8) { - SDL_SetSurfacePalette(main_surface, sdl_palette); + SDL_SetSurfacePalette(main_surface, gfx_palette); } - if (sdl_dibinfo) { - free(sdl_dibinfo); + if (gfx_dibinfo) { + free(gfx_dibinfo); } - sdl_dibinfo = calloc(1, sizeof(surface_t)); - sdl_dibinfo->width = width; - sdl_dibinfo->height = height; - sdl_dibinfo->alpha = NULL; - sdl_dibinfo->sdl_surface = main_surface; + gfx_dibinfo = calloc(1, sizeof(surface_t)); + gfx_dibinfo->width = width; + gfx_dibinfo->height = height; + gfx_dibinfo->alpha = NULL; + gfx_dibinfo->sdl_surface = main_surface; image_setdepth(main_surface->format->BitsPerPixel); } /* offscreen の設定 */ -void sdl_setWorldSize(int width, int height, int depth) { +void gfx_setWorldSize(int width, int height, int depth) { makeDIB(width, height, depth); SDL_FillRect(main_surface, NULL, 0); } /* display の size と depth の取得 */ -void sdl_getWindowInfo(DispInfo *info) { +void gfx_getWindowInfo(DispInfo *info) { SDL_DisplayMode dm; SDL_GetCurrentDisplayMode(0, &dm); info->width = dm.w; @@ -219,11 +219,11 @@ void sdl_getWindowInfo(DispInfo *info) { } /* DIBの取得 */ -surface_t *sdl_getDIB(void) { - return sdl_dibinfo; +surface_t *gfx_getDIB(void) { + return gfx_dibinfo; } -SDL_Surface *sdl_createSurfaceView(SDL_Surface *sf, int x, int y, int w, int h) { +SDL_Surface *gfx_createSurfaceView(SDL_Surface *sf, int x, int y, int w, int h) { uint8_t *pixels = sf->pixels; pixels += y * sf->pitch + x * sf->format->BytesPerPixel; SDL_Surface *view = SDL_CreateRGBSurfaceWithFormatFrom( @@ -242,37 +242,37 @@ void sdl_setAutoRepeat(bool enable) { } } -void sdl_setFullscreen(bool on) { +void gfx_setFullscreen(bool on) { #ifndef __EMSCRIPTEN__ - if (on == sdl_fs_on) + if (on == gfx_fullscreen) return; - SDL_SetWindowFullscreen(sdl_window, on ? SDL_WINDOW_FULLSCREEN_DESKTOP: 0); - sdl_fs_on = on; + SDL_SetWindowFullscreen(gfx_window, on ? SDL_WINDOW_FULLSCREEN_DESKTOP: 0); + gfx_fullscreen = on; #endif } -bool sdl_isFullscreen(void) { - return sdl_fs_on; +bool gfx_isFullscreen(void) { + return gfx_fullscreen; } -void sdl_raiseWindow(void) { - SDL_RaiseWindow(sdl_window); +void gfx_raiseWindow(void) { + SDL_RaiseWindow(gfx_window); } -void sdl_setWindowSize(int w, int h) { +void gfx_setWindowSize(int w, int h) { if (w == view_w && h == view_h) return; view_w = w; view_h = h; #ifndef __ANDROID__ - SDL_SetWindowSize(sdl_window, w, h); + SDL_SetWindowSize(gfx_window, w, h); #endif - SDL_RenderSetLogicalSize(sdl_renderer, w, h); - if (sdl_texture) - SDL_DestroyTexture(sdl_texture); - sdl_texture = SDL_CreateTexture( - sdl_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, w, h); + SDL_RenderSetLogicalSize(gfx_renderer, w, h); + if (gfx_texture) + SDL_DestroyTexture(gfx_texture); + gfx_texture = SDL_CreateTexture( + gfx_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, w, h); #ifdef __EMSCRIPTEN__ EM_ASM( xsystem35.shell.windowSizeChanged(); ); @@ -286,20 +286,20 @@ void sdl_showMessageBox(enum messagebox_type type, const char* title_utf8, const case MESSAGEBOX_WARNING: flags = SDL_MESSAGEBOX_WARNING; break; case MESSAGEBOX_INFO: flags = SDL_MESSAGEBOX_INFORMATION; break; } - SDL_ShowSimpleMessageBox(flags, title_utf8, message_utf8, sdl_window); + SDL_ShowSimpleMessageBox(flags, title_utf8, message_utf8, gfx_window); } void sdl_setJoyDeviceIndex(int index) { joy_device_index = index; } -void sdl_setIntegerScaling(bool enable) { - SDL_RenderSetIntegerScale(sdl_renderer, enable); +void gfx_setIntegerScaling(bool enable) { + SDL_RenderSetIntegerScale(gfx_renderer, enable); } bool EMSCRIPTEN_KEEPALIVE save_screenshot(const char* path) { SDL_Rect *r = &nact->ags.view_area; - SDL_Surface *view = sdl_createSurfaceView(main_surface, r->x, r->y, r->w, r->h); + SDL_Surface *view = gfx_createSurfaceView(main_surface, r->x, r->y, r->w, r->h); bool ok = SDL_SaveBMP(view, path) == 0; SDL_FreeSurface(view); return ok; diff --git a/src/menu_sdl.c b/src/menu_sdl.c index d2b25a3..2335c7d 100644 --- a/src/menu_sdl.c +++ b/src/menu_sdl.c @@ -28,7 +28,7 @@ #include "nact.h" #include "menu.h" #include "sdl_core.h" -#include "sdl_private.h" +#include "gfx_private.h" #ifdef _WIN32 #include "win/dialog.h" #endif @@ -44,7 +44,7 @@ void menu_quitmenu_open(void) { }; const SDL_MessageBoxData messagebox_data = { .flags = SDL_MESSAGEBOX_INFORMATION, - .window = sdl_window, + .window = gfx_window, .title = "Confirm", .message = "Quit xsystem35?", .numbuttons = SDL_arraysize(buttons), @@ -67,7 +67,7 @@ void menu_resetmenu_open(void) { }; const SDL_MessageBoxData messagebox_data = { .flags = SDL_MESSAGEBOX_INFORMATION, - .window = sdl_window, + .window = gfx_window, .title = "Confirm", .message = "Restart the game?", .numbuttons = SDL_arraysize(buttons), diff --git a/src/nact.c b/src/nact.c index aa0c17e..0dfc43e 100644 --- a/src/nact.c +++ b/src/nact.c @@ -112,7 +112,7 @@ void nact_main() { nact->current_page = sl_getPage(); nact->current_addr = sl_getIndex(); if (dbg_trapped()) { - sdl_updateScreen(); + gfx_updateScreen(); dbg_main(0); } diff --git a/src/sdl_core.h b/src/sdl_core.h index 13a3fb8..65d2e21 100644 --- a/src/sdl_core.h +++ b/src/sdl_core.h @@ -35,57 +35,57 @@ struct inputstring_param; /* 初期化関係 */ -extern int sdl_Initialize(const char *render_driver); -extern void sdl_Remove(void); +extern int gfx_Initialize(const char *render_driver); +extern void gfx_Remove(void); /* ウィンド関係 */ -extern void sdl_setWorldSize(int width, int height, int depth); -extern void sdl_setWindowSize(int w, int h); -extern void sdl_setWindowTitle(char *name); -extern void sdl_getWindowInfo(DispInfo *info); -extern void sdl_setFullscreen(bool on); -extern bool sdl_isFullscreen(void); -extern void sdl_raiseWindow(void); -extern surface_t *sdl_getDIB(void); -extern void sdl_setIntegerScaling(bool enable); -extern SDL_Surface *sdl_createSurfaceView(SDL_Surface *sf, int x, int y, int w, int h); +extern void gfx_setWorldSize(int width, int height, int depth); +extern void gfx_setWindowSize(int w, int h); +extern void gfx_setWindowTitle(char *name); +extern void gfx_getWindowInfo(DispInfo *info); +extern void gfx_setFullscreen(bool on); +extern bool gfx_isFullscreen(void); +extern void gfx_raiseWindow(void); +extern surface_t *gfx_getDIB(void); +extern void gfx_setIntegerScaling(bool enable); +extern SDL_Surface *gfx_createSurfaceView(SDL_Surface *sf, int x, int y, int w, int h); /* 画面更新 */ -extern void sdl_updateArea(MyRectangle *src, MyPoint *dst); -extern void sdl_updateAll(MyRectangle *view_rect); -extern void sdl_updateScreen(void); +extern void gfx_updateArea(MyRectangle *src, MyPoint *dst); +extern void gfx_updateAll(MyRectangle *view_rect); +extern void gfx_updateScreen(void); /* パレット関係 */ -extern void sdl_setPalette(SDL_Color *pal, int first, int count); +extern void gfx_setPalette(SDL_Color *pal, int first, int count); /* 描画関係 */ -extern void sdl_drawRectangle(int x, int y, int w, int h, uint8_t c); -extern void sdl_fillRectangle(int x, int y, int w, int h, uint8_t c); -extern void sdl_fillRectangleRGB(int x, int y, int w, int h, uint8_t r, uint8_t g, uint8_t b); -extern void sdl_fillCircle(int left, int top, int diameter, uint8_t c); -extern void sdl_drawLine(int x1, int y1, int x2, int y2, uint8_t c); -extern SDL_Rect sdl_floodFill(int x, int y, int col); -extern SDL_Rect sdl_drawString(int x, int y, const char *str_utf8, uint8_t col); -extern void sdl_copyArea(int sx,int sy, int w, int h, int dx, int dy); -extern void sdl_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, uint8_t sp); -extern void sdl_wrapColor(int sx, int sy, int w, int h, uint8_t cl, int rate); -extern void sdl_scaledCopyArea(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mirror); -extern void sdl_drawImage8(cgdata *cg, int x, int y, int sprite_color); -extern void sdl_drawImage16(cgdata *cg, surface_t *sf, int x, int y, int brightness, bool alpha_blend); -extern void sdl_drawImage24(cgdata *cg, surface_t *sf, int x, int y, int brightness); -extern void sdl_drawImageAlphaMap(cgdata *cg, surface_t *sf, int x, int y); -extern void sdl_copyAreaSP16_shadow(int sx, int sy, int w, int h, int dx, int dy, int lv); -extern void sdl_copyAreaSP16_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int lv); -extern void sdl_copyAreaSP16_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, int lv); -extern void sdl_copy_from_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag); -extern void sdl_copy_to_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag); -extern void sdl_getPixel(int x, int y, Palette *cell); -extern void sdl_putRegion(void *src, int x, int y); -extern void sdl_restoreRegion(void *src, int x, int y); -extern void* sdl_saveRegion(int x, int y, int w, int h); -extern void sdl_delRegion(void *src); -void sdl_FlipSurfaceHorizontal(SDL_Surface *s); -void sdl_FlipSurfaceVertical(SDL_Surface *s); +extern void gfx_drawRectangle(int x, int y, int w, int h, uint8_t c); +extern void gfx_fillRectangle(int x, int y, int w, int h, uint8_t c); +extern void gfx_fillRectangleRGB(int x, int y, int w, int h, uint8_t r, uint8_t g, uint8_t b); +extern void gfx_fillCircle(int left, int top, int diameter, uint8_t c); +extern void gfx_drawLine(int x1, int y1, int x2, int y2, uint8_t c); +extern SDL_Rect gfx_floodFill(int x, int y, int col); +extern SDL_Rect gfx_drawString(int x, int y, const char *str_utf8, uint8_t col); +extern void gfx_copyArea(int sx,int sy, int w, int h, int dx, int dy); +extern void gfx_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, uint8_t sp); +extern void gfx_wrapColor(int sx, int sy, int w, int h, uint8_t cl, int rate); +extern void gfx_scaledCopyArea(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mirror); +extern void gfx_drawImage8(cgdata *cg, int x, int y, int sprite_color); +extern void gfx_drawImage16(cgdata *cg, surface_t *sf, int x, int y, int brightness, bool alpha_blend); +extern void gfx_drawImage24(cgdata *cg, surface_t *sf, int x, int y, int brightness); +extern void gfx_drawImageAlphaMap(cgdata *cg, surface_t *sf, int x, int y); +extern void gfx_copyAreaSP16_shadow(int sx, int sy, int w, int h, int dx, int dy, int lv); +extern void gfx_copyAreaSP16_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int lv); +extern void gfx_copyAreaSP16_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, int lv); +extern void gfx_copy_from_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag); +extern void gfx_copy_to_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag); +extern void gfx_getPixel(int x, int y, Palette *cell); +extern void gfx_putRegion(void *src, int x, int y); +extern void gfx_restoreRegion(void *src, int x, int y); +extern void* gfx_saveRegion(int x, int y, int w, int h); +extern void gfx_delRegion(void *src); +void gfx_FlipSurfaceHorizontal(SDL_Surface *s); +void gfx_FlipSurfaceVertical(SDL_Surface *s); /* Effects */ struct sdl_effect; diff --git a/src/sdl_cursor.c b/src/sdl_cursor.c index ecc4387..d11af91 100644 --- a/src/sdl_cursor.c +++ b/src/sdl_cursor.c @@ -27,7 +27,7 @@ #include "portab.h" #include "system.h" #include "cursor.h" -#include "sdl_private.h" +#include "gfx_private.h" /* マウスカーソルフォントイメージ*/ #include "bitmaps/cursor_uparrow.xpm" @@ -141,20 +141,20 @@ bool sdl_cursorNew(uint8_t* data, int no, CursorImage *cursorImage, TCursorDirEn MyPoint sdl_translateMouseCoords(int x, int y) { // scale mouse x and y float scalex, scaley; - SDL_RenderGetScale(sdl_renderer, &scalex, &scaley); + SDL_RenderGetScale(gfx_renderer, &scalex, &scaley); x *= scalex; y *= scaley; // calculate window borders int logw, logh; - SDL_RenderGetLogicalSize(sdl_renderer, &logw, &logh); + SDL_RenderGetLogicalSize(gfx_renderer, &logw, &logh); float scalew, scaleh; scalew = logw * scalex; scaleh = logh * scaley; int winw, winh; - SDL_GetWindowSize(sdl_window, &winw, &winh); + SDL_GetWindowSize(gfx_window, &winw, &winh); float border_left = (winw - scalew) / 2; float border_top = (winh - scaleh) / 2; @@ -170,7 +170,7 @@ MyPoint sdl_translateMouseCoords(int x, int y) { /* マウスの位置の移動 */ void sdl_setCursorLocation(int x, int y) { MyPoint t = sdl_translateMouseCoords(x, y); - SDL_WarpMouseInWindow(sdl_window, t.x, t.y); + SDL_WarpMouseInWindow(gfx_window, t.x, t.y); } /* マウスカーソルの形状の設定 */ diff --git a/src/sdl_effect.c b/src/sdl_effect.c index 3330684..81aba8c 100644 --- a/src/sdl_effect.c +++ b/src/sdl_effect.c @@ -25,7 +25,7 @@ #include "system.h" #include "sdl_core.h" -#include "sdl_private.h" +#include "gfx_private.h" #define M_PIf ((float)M_PI) #define HAS_SDL_RenderGeometry SDL_VERSION_ATLEAST(2, 0, 18) @@ -134,11 +134,11 @@ typedef struct { static EffectTexture *create_effect_texture(surface_t *as, int x, int y, int w, int h) { EffectTexture *t = calloc(1, sizeof(EffectTexture)); if (!as) { - t->tx = sdl_texture; + t->tx = gfx_texture; t->rect = (SDL_Rect){ x, y, w, h }; } else { - SDL_Surface *sf = sdl_createSurfaceView(as->sdl_surface, x, y, w, h); - t->tx = SDL_CreateTextureFromSurface(sdl_renderer, sf); + SDL_Surface *sf = gfx_createSurfaceView(as->sdl_surface, x, y, w, h); + t->tx = SDL_CreateTextureFromSurface(gfx_renderer, sf); SDL_FreeSurface(sf); t->rect = (SDL_Rect){ 0, 0, w, h }; } @@ -147,7 +147,7 @@ static EffectTexture *create_effect_texture(surface_t *as, int x, int y, int w, static EffectTexture *create_effect_texture_from_surface(SDL_Surface *sf) { EffectTexture *t = calloc(1, sizeof(EffectTexture)); - t->tx = SDL_CreateTextureFromSurface(sdl_renderer, sf); + t->tx = SDL_CreateTextureFromSurface(gfx_renderer, sf); t->rect = (SDL_Rect){ 0, 0, sf->w, sf->h }; return t; } @@ -155,7 +155,7 @@ static EffectTexture *create_effect_texture_from_surface(SDL_Surface *sf) { static void destroy_effect_texture(EffectTexture *t) { if (!t) return; - if (t->tx && t->tx != sdl_texture) + if (t->tx && t->tx != gfx_texture) SDL_DestroyTexture(t->tx); free(t); } @@ -169,7 +169,7 @@ static int render_effect_texture(EffectTexture *t, const SDL_Rect* srcrect, cons real_srcrect.x += t->rect.x; real_srcrect.y += t->rect.y; } - return SDL_RenderCopy(sdl_renderer, t->tx, &real_srcrect, dstrect); + return SDL_RenderCopy(gfx_renderer, t->tx, &real_srcrect, dstrect); } struct sdl_effect { @@ -190,16 +190,16 @@ static void effect_init(struct sdl_effect *eff, SDL_Rect *rect, EffectTexture *o eff->tx_new = new; if (!eff->is_fullscreen) - sdl_updateScreen(); // Flush pending display changes. + gfx_updateScreen(); // Flush pending display changes. } static void effect_finish(struct sdl_effect *eff, bool present) { if (present) { - SDL_RenderClear(sdl_renderer); + SDL_RenderClear(gfx_renderer); if (!eff->is_fullscreen) - SDL_RenderCopy(sdl_renderer, sdl_texture, NULL, NULL); + SDL_RenderCopy(gfx_renderer, gfx_texture, NULL, NULL); render_effect_texture(eff->tx_new, NULL, &eff->dst_rect); - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } destroy_effect_texture(eff->tx_old); destroy_effect_texture(eff->tx_new); @@ -249,7 +249,7 @@ static void crossfade_step(struct sdl_effect *eff, float progress) { render_effect_texture(eff->tx_new, NULL, &eff->dst_rect); SDL_SetTextureAlphaMod(eff->tx_new->tx, 255); SDL_SetTextureBlendMode(eff->tx_new->tx, SDL_BLENDMODE_NONE); - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void crossfade_free(struct sdl_effect *eff) { @@ -365,7 +365,7 @@ static void crossfade_animation_step(struct sdl_effect *eff, float progress) { assert(!"Cannot happen"); } - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void crossfade_animation_free(struct sdl_effect *eff) { @@ -384,16 +384,16 @@ static void mosaic_step(struct sdl_effect *eff, float progress); static void mosaic_free(struct sdl_effect *eff); static struct sdl_effect *mosaic_new(SDL_Rect *rect, EffectTexture *old, EffectTexture *new, enum sdl_effect_type type) { - if (!SDL_RenderTargetSupported(sdl_renderer)) + if (!SDL_RenderTargetSupported(gfx_renderer)) return fallback_effect_new(rect, old, new, type); struct mosaic_effect *eff = calloc(1, sizeof(struct mosaic_effect)); if (!eff) NOMEMERR(); effect_init(&eff->eff, rect, old, new, type); - eff->tmp_old = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, rect->w, rect->h); - eff->tmp_new = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, rect->w, rect->h); - eff->tx_mosaic = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, rect->w, rect->h); + eff->tmp_old = SDL_CreateTexture(gfx_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, rect->w, rect->h); + eff->tmp_new = SDL_CreateTexture(gfx_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, rect->w, rect->h); + eff->tx_mosaic = SDL_CreateTexture(gfx_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, rect->w, rect->h); eff->eff.step = mosaic_step; eff->eff.finish = mosaic_free; return &eff->eff; @@ -408,8 +408,8 @@ static void mosaic(EffectTexture *src, SDL_Texture *tmp, SDL_Texture *dst, int w .w = w / scale, .h = h / scale, }; - SDL_SetRenderTarget(sdl_renderer, tmp); - SDL_RenderCopyF(sdl_renderer, src->tx, &src->rect, &fr); + SDL_SetRenderTarget(gfx_renderer, tmp); + SDL_RenderCopyF(gfx_renderer, src->tx, &src->rect, &fr); SDL_Rect dstr = { .x = w * (1 - scale) / 2, @@ -417,15 +417,15 @@ static void mosaic(EffectTexture *src, SDL_Texture *tmp, SDL_Texture *dst, int w .w = w * scale, .h = h * scale, }; - SDL_SetRenderTarget(sdl_renderer, dst); + SDL_SetRenderTarget(gfx_renderer, dst); #if SDL_VERSION_ATLEAST(2, 0, 12) SDL_SetTextureScaleMode(tmp, SDL_ScaleModeNearest); #else // Should be okay because nearest is the default scaling mode. #endif - SDL_RenderCopy(sdl_renderer, tmp, NULL, &dstr); - SDL_SetRenderTarget(sdl_renderer, NULL); + SDL_RenderCopy(gfx_renderer, tmp, NULL, &dstr); + SDL_SetRenderTarget(gfx_renderer, NULL); } static void mosaic_step(struct sdl_effect *eff, float progress) { @@ -435,22 +435,22 @@ static void mosaic_step(struct sdl_effect *eff, float progress) { const int max_scale = 80; int scale = (1.f - progress) * (max_scale - 1) + 1; mosaic(eff->tx_new, this->tmp_new, this->tx_mosaic, eff->dst_rect.w, eff->dst_rect.h, scale); - SDL_RenderCopy(sdl_renderer, this->tx_mosaic, NULL, &eff->dst_rect); + SDL_RenderCopy(gfx_renderer, this->tx_mosaic, NULL, &eff->dst_rect); } else if (eff->type == EFFECT_CROSSFADE_MOSAIC) { const int max_scale = 96; float scale = (progress < 0.5f ? progress : 1.f - progress) * 2 * (max_scale - 1) + 1; mosaic(eff->tx_old, this->tmp_old, this->tx_mosaic, eff->dst_rect.w, eff->dst_rect.h, scale); - SDL_RenderCopy(sdl_renderer, this->tx_mosaic, NULL, &eff->dst_rect); + SDL_RenderCopy(gfx_renderer, this->tx_mosaic, NULL, &eff->dst_rect); mosaic(eff->tx_new, this->tmp_new, this->tx_mosaic, eff->dst_rect.w, eff->dst_rect.h, scale); SDL_SetTextureBlendMode(this->tx_mosaic, SDL_BLENDMODE_BLEND); SDL_SetTextureAlphaMod(this->tx_mosaic, progress * 255); - SDL_RenderCopy(sdl_renderer, this->tx_mosaic, NULL, &eff->dst_rect); + SDL_RenderCopy(gfx_renderer, this->tx_mosaic, NULL, &eff->dst_rect); SDL_SetTextureBlendMode(this->tx_mosaic, SDL_BLENDMODE_NONE); } else { assert(!"Cannot happen"); } - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void mosaic_free(struct sdl_effect *eff) { @@ -516,12 +516,12 @@ static void brightness_step(struct sdl_effect *eff, float progress) { assert(!"Cannot happen"); } render_effect_texture(texture, NULL, &eff->dst_rect); - SDL_SetRenderDrawBlendMode(sdl_renderer, SDL_BLENDMODE_BLEND); - SDL_SetRenderDrawColor(sdl_renderer, color, color, color, alpha); - SDL_RenderFillRect(sdl_renderer, &eff->dst_rect); - SDL_SetRenderDrawBlendMode(sdl_renderer, SDL_BLENDMODE_NONE); - SDL_SetRenderDrawColor(sdl_renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); - SDL_RenderPresent(sdl_renderer); + SDL_SetRenderDrawBlendMode(gfx_renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(gfx_renderer, color, color, color, alpha); + SDL_RenderFillRect(gfx_renderer, &eff->dst_rect); + SDL_SetRenderDrawBlendMode(gfx_renderer, SDL_BLENDMODE_NONE); + SDL_SetRenderDrawColor(gfx_renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); + SDL_RenderPresent(gfx_renderer); } static void brightness_free(struct sdl_effect *eff) { @@ -549,7 +549,7 @@ static EffectTexture *create_dither_pattern_texture(int w, int h, int val) { } EffectTexture *t = calloc(1, sizeof(EffectTexture)); - t->tx = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, w, h); + t->tx = SDL_CreateTexture(gfx_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, w, h); SDL_UpdateTexture(t->tx, NULL, pixels, w * 4); free(pixels); SDL_SetTextureBlendMode(t->tx, SDL_BLENDMODE_BLEND); @@ -608,16 +608,16 @@ static void dithering_fade_step(struct sdl_effect *eff, float progress) { render_effect_texture(eff->tx_new, NULL, &dr); } - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void dithering_fade_free(struct sdl_effect *eff) { if (eff->type == EFFECT_DITHERING_FADEOUT) { - SDL_SetRenderDrawColor(sdl_renderer, 0, 0, 0, 255); - SDL_RenderFillRect(sdl_renderer, &eff->dst_rect); + SDL_SetRenderDrawColor(gfx_renderer, 0, 0, 0, 255); + SDL_RenderFillRect(gfx_renderer, &eff->dst_rect); } else if (eff->type == EFFECT_DITHERING_WHITEOUT) { - SDL_SetRenderDrawColor(sdl_renderer, 255, 255, 255, 255); - SDL_RenderFillRect(sdl_renderer, &eff->dst_rect); + SDL_SetRenderDrawColor(gfx_renderer, 255, 255, 255, 255); + SDL_RenderFillRect(gfx_renderer, &eff->dst_rect); } effect_finish(eff, false); free(eff); @@ -652,7 +652,7 @@ static void pan_in_step(struct sdl_effect *eff, float progress) { } render_effect_texture(eff->tx_new, &sr, &dr); - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void pan_in_free(struct sdl_effect *eff) { @@ -716,7 +716,7 @@ static void skip_line_step(struct sdl_effect *eff, float progress) { } } - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void skip_line_free(struct sdl_effect *eff) { @@ -790,7 +790,7 @@ static void wipe_step(struct sdl_effect *eff, float progress) { } render_effect_texture(fg, &sr, &dr); - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void wipe_free(struct sdl_effect *eff) { @@ -840,7 +840,7 @@ static void circle_wipe_step(struct sdl_effect *eff, float progress) { } } - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void circle_wipe_free(struct sdl_effect *eff) { @@ -942,7 +942,7 @@ static void blind_step(struct sdl_effect *eff, float progress) { } } - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void blind_free(struct sdl_effect *eff) { @@ -1002,7 +1002,7 @@ static void blend_animation_step(struct sdl_effect *eff, float progress) { SDL_SetTextureAlphaMod(fg->tx, 255); SDL_SetTextureBlendMode(fg->tx, SDL_BLENDMODE_NONE); - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void blend_animation_free(struct sdl_effect *eff) { @@ -1024,7 +1024,7 @@ static void zoom_blend_blur_step(struct sdl_effect *eff, float progress); static void zoom_blend_blur_free(struct sdl_effect *eff); static struct sdl_effect *zoom_blend_blur_new(SDL_Rect *rect, EffectTexture *old, EffectTexture *new) { - if (!SDL_RenderTargetSupported(sdl_renderer)) + if (!SDL_RenderTargetSupported(gfx_renderer)) return fallback_effect_new(rect, old, new, EFFECT_ZOOM_BLEND_BLUR); struct zoom_blend_blur_effect *eff = calloc(1, sizeof(struct zoom_blend_blur_effect)); @@ -1040,7 +1040,7 @@ static void zoom_blend_blur_step(struct sdl_effect *eff, float progress) { struct zoom_blend_blur_effect *this = (struct zoom_blend_blur_effect *)eff; if (!this->tx[this->index]) { - this->tx[this->index] = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, eff->dst_rect.w, eff->dst_rect.h); + this->tx[this->index] = SDL_CreateTexture(gfx_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, eff->dst_rect.w, eff->dst_rect.h); } float scale = (progress < 0.5f ? 1 - progress * 2 : (progress - 0.5f) * 2) * 0.9f + 0.1f; // 0.1 - 1.0 @@ -1052,13 +1052,13 @@ static void zoom_blend_blur_step(struct sdl_effect *eff, float progress) { .w = w, .h = h }; - SDL_SetRenderTarget(sdl_renderer, this->tx[this->index]); + SDL_SetRenderTarget(gfx_renderer, this->tx[this->index]); render_effect_texture(eff->tx_new, &r, NULL); - SDL_SetRenderTarget(sdl_renderer, NULL); + SDL_SetRenderTarget(gfx_renderer, NULL); this->index = (this->index + 1) % ZOOM_BLEND_BLUR_STEPS; - SDL_RenderFillRect(sdl_renderer, &eff->dst_rect); + SDL_RenderFillRect(gfx_renderer, &eff->dst_rect); EffectTexture texture_rect = { NULL, { 0, 0, eff->dst_rect.w, eff->dst_rect.h } }; for (int i = 0; i < ZOOM_BLEND_BLUR_STEPS; i++) { texture_rect.tx = this->tx[i]; @@ -1069,7 +1069,7 @@ static void zoom_blend_blur_step(struct sdl_effect *eff, float progress) { SDL_SetTextureBlendMode(t->tx, SDL_BLENDMODE_NONE); SDL_SetTextureAlphaMod(t->tx, 255); } - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void zoom_blend_blur_free(struct sdl_effect *eff) { @@ -1096,7 +1096,7 @@ static void linear_blur_step(struct sdl_effect *eff, float progress); static void linear_blur_free(struct sdl_effect *eff); static struct sdl_effect *linear_blur_new(SDL_Rect *rect, EffectTexture *old, EffectTexture *new, enum sdl_effect_type type) { - if (!SDL_RenderTargetSupported(sdl_renderer)) + if (!SDL_RenderTargetSupported(gfx_renderer)) return fallback_effect_new(rect, old, new, type); struct linear_blur_effect *lbe = calloc(1, sizeof(struct linear_blur_effect)); @@ -1113,11 +1113,11 @@ static EffectTexture *blur(struct linear_blur_effect *this, EffectTexture *src, int w = this->eff.dst_rect.w; int h = this->eff.dst_rect.h; EffectTexture *dst = calloc(1, sizeof(EffectTexture)); - dst->tx = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, w, h); + dst->tx = SDL_CreateTexture(gfx_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, w, h); dst->rect = (SDL_Rect){0, 0, w, h}; - SDL_SetRenderTarget(sdl_renderer, dst->tx); - SDL_RenderClear(sdl_renderer); + SDL_SetRenderTarget(gfx_renderer, dst->tx); + SDL_RenderClear(gfx_renderer); SDL_SetTextureBlendMode(src->tx, SDL_BLENDMODE_ADD); SDL_SetTextureAlphaMod(src->tx, 127); @@ -1145,7 +1145,7 @@ static EffectTexture *blur(struct linear_blur_effect *this, EffectTexture *src, SDL_SetTextureAlphaMod(src->tx, 255); SDL_SetTextureBlendMode(src->tx, SDL_BLENDMODE_NONE); - SDL_SetRenderTarget(sdl_renderer, NULL); + SDL_SetRenderTarget(gfx_renderer, NULL); return dst; } @@ -1156,7 +1156,7 @@ static void linear_blur_step(struct sdl_effect *eff, float progress) { int step = progress * LINEAR_BLUR_STEPS * 2; if (step == LINEAR_BLUR_STEPS * 2) { render_effect_texture(eff->tx_new, NULL, NULL); - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); return; } @@ -1174,7 +1174,7 @@ static void linear_blur_step(struct sdl_effect *eff, float progress) { SDL_SetTextureBlendMode(new->tx, SDL_BLENDMODE_BLEND); SDL_SetTextureAlphaMod(new->tx, 255 * progress); render_effect_texture(new, NULL, &eff->dst_rect); - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void linear_blur_free(struct sdl_effect *eff) { @@ -1201,12 +1201,12 @@ static void polygon_mask_free(struct sdl_effect *eff); static struct sdl_effect *polygon_mask_new(SDL_Rect *rect, EffectTexture *old, EffectTexture *new, enum sdl_effect_type type) { #if HAS_SDL_RenderGeometry - if (SDL_RenderTargetSupported(sdl_renderer)) { + if (SDL_RenderTargetSupported(gfx_renderer)) { struct polygon_mask_effect *pmf = calloc(1, sizeof(struct polygon_mask_effect)); if (!pmf) NOMEMERR(); effect_init(&pmf->f, rect, old, new, type); - pmf->tx_tmp = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, rect->w, rect->h); + pmf->tx_tmp = SDL_CreateTexture(gfx_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, rect->w, rect->h); pmf->f.step = polygon_mask_step; pmf->f.finish = polygon_mask_free; return &pmf->f; @@ -1246,7 +1246,7 @@ static void draw_pentagram(int center_x, int center_y, float radius, float rotat 6, 9, 3, 8, 1, 5 }; - SDL_RenderGeometry(sdl_renderer, NULL, v, 10, indices, 15); + SDL_RenderGeometry(gfx_renderer, NULL, v, 10, indices, 15); } static void draw_hexagram(int center_x, int center_y, float radius, float rotate) { @@ -1267,7 +1267,7 @@ static void draw_hexagram(int center_x, int center_y, float radius, float rotate v[i].position.y = radius * (p[i].x * sin_r + p[i].y * cos_r) + center_y; v[i].color = (SDL_Color){0, 0, 0, 0}; } - SDL_RenderGeometry(sdl_renderer, NULL, v, 6, NULL, 0); + SDL_RenderGeometry(gfx_renderer, NULL, v, 6, NULL, 0); } static void draw_windmill_90(int w, int h, float theta) { @@ -1305,7 +1305,7 @@ static void draw_windmill_90(int w, int h, float theta) { 0, 7, 9, 0, 10, 12 }; - SDL_RenderGeometry(sdl_renderer, NULL, v, 13, indices, 12); + SDL_RenderGeometry(gfx_renderer, NULL, v, 13, indices, 12); } else { const int indices[24] = { 0, 1, 2, @@ -1317,7 +1317,7 @@ static void draw_windmill_90(int w, int h, float theta) { 0, 10, 11, 0, 11, 12 }; - SDL_RenderGeometry(sdl_renderer, NULL, v, 13, indices, 24); + SDL_RenderGeometry(gfx_renderer, NULL, v, 13, indices, 24); } } @@ -1365,7 +1365,7 @@ static void draw_windmill_180(int w, int h, float theta) { } indices[i++] = 10; // theta+M_PIf - SDL_RenderGeometry(sdl_renderer, NULL, v, 11, indices, i); + SDL_RenderGeometry(gfx_renderer, NULL, v, 11, indices, i); } static void draw_windmill_360(int w, int h, float theta) { @@ -1399,14 +1399,14 @@ static void draw_windmill_360(int w, int h, float theta) { indices[i++] = j; } indices[i++] = 9; // theta - SDL_RenderGeometry(sdl_renderer, NULL, v, 10, indices, i); + SDL_RenderGeometry(gfx_renderer, NULL, v, 10, indices, i); } static void polygon_mask_step(struct sdl_effect *eff, float progress) { struct polygon_mask_effect *this = (struct polygon_mask_effect *)eff; int w = eff->dst_rect.w; int h = eff->dst_rect.h; - SDL_SetRenderTarget(sdl_renderer, this->tx_tmp); + SDL_SetRenderTarget(gfx_renderer, this->tx_tmp); render_effect_texture(eff->tx_old, NULL, NULL); switch (eff->type) { case EFFECT_PENTAGRAM_IN_OUT: @@ -1433,11 +1433,11 @@ static void polygon_mask_step(struct sdl_effect *eff, float progress) { default: assert(!"Cannot happen"); } - SDL_SetRenderTarget(sdl_renderer, NULL); + SDL_SetRenderTarget(gfx_renderer, NULL); render_effect_texture(eff->tx_new, NULL, &eff->dst_rect); SDL_SetTextureBlendMode(this->tx_tmp, SDL_BLENDMODE_BLEND); - SDL_RenderCopy(sdl_renderer, this->tx_tmp, NULL, &eff->dst_rect); - SDL_RenderPresent(sdl_renderer); + SDL_RenderCopy(gfx_renderer, this->tx_tmp, NULL, &eff->dst_rect); + SDL_RenderPresent(gfx_renderer); } static void polygon_mask_free(struct sdl_effect *eff) { @@ -1503,8 +1503,8 @@ static void rotate_step(struct sdl_effect *eff, float progress) { r.w *= scale; r.h *= scale; render_effect_texture(bg_texture, NULL, &eff->dst_rect); - SDL_RenderCopyEx(sdl_renderer, fg_texture->tx, &fg_texture->rect, &r, angle, NULL, SDL_FLIP_NONE); - SDL_RenderPresent(sdl_renderer); + SDL_RenderCopyEx(gfx_renderer, fg_texture->tx, &fg_texture->rect, &r, angle, NULL, SDL_FLIP_NONE); + SDL_RenderPresent(gfx_renderer); } static void rotate_free(struct sdl_effect *eff) { @@ -1564,7 +1564,7 @@ static void polygon_rotate_step(struct sdl_effect *eff, float progress) { render_effect_texture(texture, &sr, &dr); } - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void polygon_rotate_free(struct sdl_effect *eff) { @@ -1583,23 +1583,23 @@ static void zigzag_crossfade_step(struct sdl_effect *eff, float progress); static void zigzag_crossfade_free(struct sdl_effect *eff); static struct sdl_effect *zigzag_crossfade_new(SDL_Rect *rect, EffectTexture *old, EffectTexture *new) { - if (!SDL_RenderTargetSupported(sdl_renderer)) + if (!SDL_RenderTargetSupported(gfx_renderer)) return fallback_effect_new(rect, old, new, EFFECT_ZIGZAG_CROSSFADE); struct zigzag_crossfade_effect *eff = calloc(1, sizeof(struct zigzag_crossfade_effect)); if (!eff) NOMEMERR(); effect_init(&eff->eff, rect, old, new, EFFECT_ZIGZAG_CROSSFADE); - eff->tmp1 = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, rect->w, rect->h); - eff->tmp2 = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, rect->w, rect->h); + eff->tmp1 = SDL_CreateTexture(gfx_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, rect->w, rect->h); + eff->tmp2 = SDL_CreateTexture(gfx_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, rect->w, rect->h); eff->eff.step = zigzag_crossfade_step; eff->eff.finish = zigzag_crossfade_free; return &eff->eff; } static void wave_warp_h(EffectTexture *src, SDL_Texture *dst, int w, int h, float amplitude, float length, float phase) { - SDL_SetRenderTarget(sdl_renderer, dst); - SDL_RenderClear(sdl_renderer); + SDL_SetRenderTarget(gfx_renderer, dst); + SDL_RenderClear(gfx_renderer); SDL_Rect sr = {0, 0, w, 1}; SDL_Rect dr = {0, 0, w, 1}; for (int y = 0; y < h; y++) { @@ -1607,20 +1607,20 @@ static void wave_warp_h(EffectTexture *src, SDL_Texture *dst, int w, int h, floa dr.x = sinf(phase + y * (2 * M_PIf / 360 * length)) * amplitude; render_effect_texture(src, &sr, &dr); } - SDL_SetRenderTarget(sdl_renderer, NULL); + SDL_SetRenderTarget(gfx_renderer, NULL); } static void wave_warp_v(SDL_Texture *src, SDL_Texture *dst, int w, int h, float amplitude, float length, float phase) { - SDL_SetRenderTarget(sdl_renderer, dst); - SDL_RenderClear(sdl_renderer); + SDL_SetRenderTarget(gfx_renderer, dst); + SDL_RenderClear(gfx_renderer); SDL_Rect sr = {0, 0, 1, h}; SDL_Rect dr = {0, 0, 1, h}; for (int x = 0; x < w; x++) { sr.x = dr.x = x; dr.y = sinf(phase + x * (2 * M_PIf / 360 * length)) * amplitude; - SDL_RenderCopy(sdl_renderer, src, &sr, &dr); + SDL_RenderCopy(gfx_renderer, src, &sr, &dr); } - SDL_SetRenderTarget(sdl_renderer, NULL); + SDL_SetRenderTarget(gfx_renderer, NULL); } static void zigzag_crossfade_step(struct sdl_effect *eff, float progress) { @@ -1632,16 +1632,16 @@ static void zigzag_crossfade_step(struct sdl_effect *eff, float progress) { wave_warp_h(eff->tx_old, this->tmp1, eff->dst_rect.w, eff->dst_rect.h, amp, len, phase); wave_warp_v(this->tmp1, this->tmp2, eff->dst_rect.w, eff->dst_rect.h, amp, len, phase); - SDL_RenderCopy(sdl_renderer, this->tmp2, NULL, &eff->dst_rect); + SDL_RenderCopy(gfx_renderer, this->tmp2, NULL, &eff->dst_rect); wave_warp_h(eff->tx_new, this->tmp1, eff->dst_rect.w, eff->dst_rect.h, amp, len, phase); wave_warp_v(this->tmp1, this->tmp2, eff->dst_rect.w, eff->dst_rect.h, amp, len, phase); SDL_SetTextureBlendMode(this->tmp2, SDL_BLENDMODE_BLEND); SDL_SetTextureAlphaMod(this->tmp2, progress * 255); - SDL_RenderCopy(sdl_renderer, this->tmp2, NULL, &eff->dst_rect); + SDL_RenderCopy(gfx_renderer, this->tmp2, NULL, &eff->dst_rect); SDL_SetTextureBlendMode(this->tmp2, SDL_BLENDMODE_NONE); - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void zigzag_crossfade_free(struct sdl_effect *eff) { @@ -1684,7 +1684,7 @@ static void magnify_step(struct sdl_effect *eff, float progress) { .h = or->h + (nr->h - or->h) * progress, }; render_effect_texture(eff->tx_old, &r, NULL); - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void magnify_free(struct sdl_effect *eff) { @@ -1698,7 +1698,7 @@ static void raster_blend_step(struct sdl_effect *eff, float progress); static void raster_blend_free(struct sdl_effect *eff); static struct sdl_effect *raster_blend_new(SDL_Rect *rect, int sx, int sy) { - SDL_Surface *sprite = sdl_dib_to_surface_with_alpha(sx, sy, rect->w, rect->h); + SDL_Surface *sprite = gfx_dib_to_surface_with_alpha(sx, sy, rect->w, rect->h); EffectTexture *texture = create_effect_texture_from_surface(sprite); SDL_FreeSurface(sprite); struct sdl_effect *eff = calloc(1, sizeof(struct sdl_effect)); @@ -1721,7 +1721,7 @@ static void raster_blend_step(struct sdl_effect *eff, float progress) { s_rect.y++; d_rect.y++; } - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void raster_blend_free(struct sdl_effect *eff) { @@ -1746,7 +1746,7 @@ static struct sdl_effect *sactamask_new(EffectTexture *tx_old, SDL_Surface *sf_n NOMEMERR(); EffectTexture *tx_new = calloc(1, sizeof(EffectTexture)); - tx_new->tx = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, sf_new->w, sf_new->h); + tx_new->tx = SDL_CreateTexture(gfx_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, sf_new->w, sf_new->h); tx_new->rect = (SDL_Rect){ 0, 0, sf_new->w, sf_new->h }; SDL_SetTextureBlendMode(tx_new->tx, SDL_BLENDMODE_BLEND); @@ -1781,7 +1781,7 @@ static void sactamask_step(struct sdl_effect *eff, float progress) { SDL_UnlockTexture(eff->tx_new->tx); render_effect_texture(eff->tx_old, NULL, &eff->dst_rect); render_effect_texture(eff->tx_new, NULL, &eff->dst_rect); - SDL_RenderPresent(sdl_renderer); + SDL_RenderPresent(gfx_renderer); } static void sactamask_free(struct sdl_effect *eff) { @@ -1883,8 +1883,8 @@ struct sdl_effect *sdl_effect_init(SDL_Rect *rect, surface_t *old, int ox, int o } struct sdl_effect *sdl_sprite_effect_init(SDL_Rect *rect, int dx, int dy, int sx, int sy, int col, enum sdl_effect_type type) { - EffectTexture *tx_old = create_effect_texture(sdl_dibinfo, dx, dy, rect->w, rect->h); - SDL_Surface *sprite = sdl_dib_to_surface_colorkey(sx, sy, rect->w, rect->h, col); + EffectTexture *tx_old = create_effect_texture(gfx_dibinfo, dx, dy, rect->w, rect->h); + SDL_Surface *sprite = gfx_dib_to_surface_colorkey(sx, sy, rect->w, rect->h, col); EffectTexture *tx_new = create_effect_texture_from_surface(sprite); SDL_FreeSurface(sprite); @@ -1914,9 +1914,9 @@ struct sdl_effect *sdl_effect_sactamask_init(SDL_Surface *mask) { } void sdl_effect_step(struct sdl_effect *eff, float progress) { - SDL_RenderClear(sdl_renderer); + SDL_RenderClear(gfx_renderer); if (!eff->is_fullscreen) - SDL_RenderCopy(sdl_renderer, sdl_texture, NULL, NULL); + SDL_RenderCopy(gfx_renderer, gfx_texture, NULL, NULL); eff->step(eff, progress); } diff --git a/src/sdl_event.c b/src/sdl_event.c index a5e3677..7f4edf7 100644 --- a/src/sdl_event.c +++ b/src/sdl_event.c @@ -36,7 +36,7 @@ #include "debugger.h" #include "nact.h" #include "sdl_core.h" -#include "sdl_private.h" +#include "gfx_private.h" #include "scheduler.h" #include "menu.h" #include "input.h" @@ -293,7 +293,7 @@ void sdl_handle_event(SDL_Event *e) { case SDL_WINDOWEVENT: switch (e->window.event) { case SDL_WINDOWEVENT_EXPOSED: - sdl_dirty = true; + gfx_dirty = true; break; } break; @@ -303,7 +303,7 @@ void sdl_handle_event(SDL_Event *e) { break; #endif case SDL_APP_DIDENTERFOREGROUND: - sdl_dirty = true; + gfx_dirty = true; break; case SDL_KEYDOWN: keyEventProsess(&e->key, true); @@ -315,7 +315,7 @@ void sdl_handle_event(SDL_Event *e) { msgskip_activate(!msgskip_isActivated()); break; case SDLK_F4: - sdl_setFullscreen(!sdl_fs_on); + gfx_setFullscreen(!gfx_fullscreen); break; } #ifdef __ANDROID__ diff --git a/src/sdl_input.c b/src/sdl_input.c index 4b0abf3..3456ba3 100644 --- a/src/sdl_input.c +++ b/src/sdl_input.c @@ -22,7 +22,7 @@ #include #include "sdl_core.h" -#include "sdl_private.h" +#include "gfx_private.h" #include "menu.h" #include "nact.h" @@ -53,13 +53,13 @@ static void redraw() { }; if (*input->text) { - int w = sdl_drawString(r.x, r.y, input->text, fgcolor).w; + int w = gfx_drawString(r.x, r.y, input->text, fgcolor).w; r.x += w; r.w -= w; } if (*input->composingText) { - int w = sdl_drawString(r.x, r.y, input->composingText, fgcolor).w; + int w = gfx_drawString(r.x, r.y, input->composingText, fgcolor).w; ags_fillRectangle(r.x, r.y + r.h, w, 2, fgcolor); // underline } diff --git a/src/win/dialog.c b/src/win/dialog.c index 0bbea86..97720b8 100644 --- a/src/win/dialog.c +++ b/src/win/dialog.c @@ -22,7 +22,7 @@ #undef max #include #include "menu.h" -#include "sdl_private.h" +#include "gfx_private.h" #include "resources.h" static HWND get_hwnd(SDL_Window *window) { @@ -141,7 +141,7 @@ bool input_string(INPUTSTRING_PARAM *p) { DialogBoxParamW( GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_TEXTINPUT), - get_hwnd(sdl_window), + get_hwnd(gfx_window), text_dialog_proc, (LPARAM)p); return true; @@ -152,7 +152,7 @@ bool input_number(INPUTNUM_PARAM *p) { INT_PTR ret = DialogBoxParamW( GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_NUMINPUT), - get_hwnd(sdl_window), + get_hwnd(gfx_window), num_dialog_proc, (LPARAM)p); return ret == IDOK; diff --git a/src/win/menubar.c b/src/win/menubar.c index 1904c69..e2517f7 100644 --- a/src/win/menubar.c +++ b/src/win/menubar.c @@ -25,7 +25,7 @@ #include "menu.h" #include "nact.h" #include "sdl_core.h" -#include "sdl_private.h" +#include "gfx_private.h" #include "resources.h" #include "msgskip.h" #include "texthook.h" @@ -47,7 +47,7 @@ static void saveScreenshot(void) { OPENFILENAME ofn = { .lStructSize = sizeof(OPENFILENAME), - .hwndOwner = get_hwnd(sdl_window), + .hwndOwner = get_hwnd(gfx_window), .lpstrFilter = "Bitmap files (*.bmp)\0*.bmp\0All files (*.*)\0*.*\0", .lpstrFile = pathbuf, .nMaxFile = MAX_PATH, @@ -82,10 +82,10 @@ static bool toggle_menu_item(UINT id, bool *checked_out) { void win_menu_init(void) { HINSTANCE hinst = (HINSTANCE)GetModuleHandle(NULL); hmenu = LoadMenu(hinst, MAKEINTRESOURCE(IDR_MENU1)); - SetMenu(get_hwnd(sdl_window), hmenu); + SetMenu(get_hwnd(gfx_window), hmenu); SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); // Let SDL recalc the window size, taking menu height into account. - SDL_SetWindowSize(sdl_window, view_w, view_h); + SDL_SetWindowSize(gfx_window, view_w, view_h); CheckMenuItem(hmenu, ID_OPTION_MOUSE_MOVE, MF_BYCOMMAND | MFS_CHECKED); } @@ -104,16 +104,16 @@ void win_menu_onSysWMEvent(SDL_SysWMmsg* msg) { menu_quitmenu_open(); break; case ID_SCREEN_WINDOW: - sdl_setFullscreen(false); - SetMenu(get_hwnd(sdl_window), hmenu); + gfx_setFullscreen(false); + SetMenu(get_hwnd(gfx_window), hmenu); break; case ID_SCREEN_FULL: - sdl_setFullscreen(true); - SetMenu(get_hwnd(sdl_window), NULL); + gfx_setFullscreen(true); + SetMenu(get_hwnd(gfx_window), NULL); break; case ID_SCREEN_INTEGER_SCALING: if (toggle_menu_item(ID_SCREEN_INTEGER_SCALING, &checked)) - sdl_setIntegerScaling(checked); + gfx_setIntegerScaling(checked); break; case ID_OPTION_MOUSE_MOVE: if (toggle_menu_item(ID_OPTION_MOUSE_MOVE, &checked)) @@ -132,13 +132,13 @@ void win_menu_onSysWMEvent(SDL_SysWMmsg* msg) { } void win_menu_onMouseMotion(int x, int y) { - if (!sdl_isFullscreen()) + if (!gfx_isFullscreen()) return; - SetMenu(get_hwnd(sdl_window), y > 0 ? NULL : hmenu); + SetMenu(get_hwnd(gfx_window), y > 0 ? NULL : hmenu); } void menu_setSkipState(bool enabled, bool activated) { - HWND hwnd = get_hwnd(sdl_window); + HWND hwnd = get_hwnd(gfx_window); EnableMenuItem(hmenu, ID_MSGSKIP, enabled ? MF_ENABLED : MF_GRAYED); diff --git a/src/xsystem35.c b/src/xsystem35.c index 24b881b..7c00a43 100644 --- a/src/xsystem35.c +++ b/src/xsystem35.c @@ -217,7 +217,7 @@ static void sys35_init() { for (i = 0; i < FONTTYPEMAX; i++) font_set_name_and_index(i, fontname_tt[i], fontface[i]); - sdl_setFullscreen(fs_on); + gfx_setFullscreen(fs_on); nact->ags.noantialias = font_noantialias; ags_setAntialiasedStringMode(!font_noantialias); @@ -543,7 +543,7 @@ int main(int argc, char **argv) { sys35_init(); if (integer_scaling) - sdl_setIntegerScaling(true); + gfx_setIntegerScaling(true); #ifdef ENABLE_GTK gtk_init(&argc, &argv);