From 49586cd33c5b5c9bcf3ed71ba1f820d26e59aa26 Mon Sep 17 00:00:00 2001 From: Fabio Cavallo Date: Sun, 3 Mar 2024 18:11:31 +0100 Subject: [PATCH] [NSFe] Fixed initialization of scroll->x variable. --- src/core/nsf.c | 6 ++++-- src/gui/draw_on_screen.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/nsf.c b/src/core/nsf.c index b990c6019..5497c69c2 100644 --- a/src/core/nsf.c +++ b/src/core/nsf.c @@ -566,7 +566,6 @@ void nsf_after_load_rom(void) { nsf.scroll_info_nsf.rect.h = 16; nsf.scroll_info_nsf.timer = 4.0f; nsf.scroll_info_nsf.reload = 4.0f; - nsf.scroll_info_nsf.x = SCR_COLUMNS; nsf.scroll_info_nsf.velocity = 6; nsf.scroll_title_song.rect.x = 0; @@ -575,7 +574,6 @@ void nsf_after_load_rom(void) { nsf.scroll_title_song.rect.h = NSF_GUI_TITLE_H; nsf.scroll_title_song.timer = 4.0f; nsf.scroll_title_song.reload = 4.0f; - nsf.scroll_title_song.x = NSF_GUI_TITLE_W; nsf.scroll_title_song.velocity = 6; nsf.curtain_title_song.reload.r1 = 50; @@ -1698,6 +1696,10 @@ static void nsf_reset_song_variables(void) { nsf.current_song.time = -1; nsf.current_song.fade = -1; } + if (nsf.scroll_title_song.pimage.data) { + free(nsf.scroll_title_song.pimage.data); + nsf.scroll_title_song.pimage.data = NULL; + } nsf_reset_song_title(); } static void ustrncat(uTCHAR *buffer, size_t buffer_size, const uTCHAR *fmt, ...) { diff --git a/src/gui/draw_on_screen.cpp b/src/gui/draw_on_screen.cpp index f4041c8d0..be80a737d 100644 --- a/src/gui/draw_on_screen.cpp +++ b/src/gui/draw_on_screen.cpp @@ -305,10 +305,10 @@ void dos_text_scroll_tick(BYTE nidx, int ppu_x, int ppu_y, const WORD fg_def, co if (!scroll->pimage.data) { dos_text_pixels_size(&scroll->pimage.w, &scroll->pimage.h, font_family, font_size, &text[0]); - if (!scroll->pimage.w || !scroll->pimage.h) { return; } + scroll->x = -(scroll->pimage.w - scroll->velocity); scroll->pimage.w += scroll->rect.w; scroll->pimage.data = _dos_text_to_ppu_image(0, 0, scroll->pimage.w, scroll->pimage.h, fg_def, bg_def, font_family, font_size, &text[0]);