diff --git a/src/sys/ags.cpp b/src/sys/ags.cpp index f921590..5d6ff4f 100644 --- a/src/sys/ags.cpp +++ b/src/sys/ags.cpp @@ -48,7 +48,6 @@ AGS::AGS(const Config& config, const GameId& game_id) : game_id(game_id), dirty( window_width = screen_width = 640; window_height = screen_height = 400; } - scroll = screen_height; SDL_SetWindowSize(g_window, window_width, window_height); SDL_RenderSetLogicalSize(g_renderer, window_width, window_height); @@ -425,12 +424,7 @@ void AGS::draw_screen(int sx, int sy, int width, int height) void AGS::invalidate_screen(int sx, int sy, int width, int height) { - int top = screen_height == 400 ? sy + (scroll - 400) : sy; - if (top < 0) { - height += top; - top = 0; - } - uint32* pixels = surface_line(hBmpDest, top) + sx; + uint32* pixels = surface_line(hBmpDest, sy) + sx; if (sy + height > screen_height) height = screen_height - sy; if (sx + width > hBmpDest->w) @@ -445,7 +439,18 @@ void AGS::update_screen() if (!dirty) return; SDL_RenderClear(g_renderer); - SDL_RenderCopy(g_renderer, sdlTexture, NULL, NULL); + + SDL_Rect src = {0, 0, screen_width, screen_height}; + SDL_Rect dest = {0, 0, screen_width, screen_height}; + if (scroll > 0) { + src.y = scroll; + src.h = dest.h = screen_height - scroll; + } else if (scroll < 0) { + dest.y = -scroll; + src.h = dest.h = screen_height + scroll; + } + SDL_RenderCopy(g_renderer, sdlTexture, &src, &dest); + if (fade_level) { SDL_SetRenderDrawBlendMode(g_renderer, SDL_BLENDMODE_BLEND); SDL_SetRenderDrawColor(g_renderer, fade_color, fade_color, fade_color, fade_level); diff --git a/src/sys/ags.h b/src/sys/ags.h index b060c40..ead6c0f 100644 --- a/src/sys/ags.h +++ b/src/sys/ags.h @@ -149,7 +149,7 @@ public: int src_screen; int dest_screen; - int scroll; + int scroll = 0; int window_width, window_height; int screen_width, screen_height; diff --git a/src/sys/nact_sys3.cpp b/src/sys/nact_sys3.cpp index 9425965..7b964a7 100644 --- a/src/sys/nact_sys3.cpp +++ b/src/sys/nact_sys3.cpp @@ -863,7 +863,7 @@ void NACT_Sys3::cmd_y() ags->extract_cg = (param & 1) ? true : false; break; case 60: - ags->scroll = param; + ags->scroll = param - 400; ags->flush_screen(false); break; case 61: