From d1d8393ed68ad6d3ea6d5f0ddc81c4401dbd8984 Mon Sep 17 00:00:00 2001 From: Dimitris Panokostas Date: Sat, 30 Sep 2017 14:31:47 +0200 Subject: [PATCH] - Fixed incorrect colors in ECS screenmodes - Removed some unneeded code - Synced some parts with the SDL1 codebase --- src/custom.cpp | 2 +- src/drawing.cpp | 29 +++++---------- src/osdep/amiberry_gfx.cpp | 76 ++++++++++++++++++-------------------- 3 files changed, 45 insertions(+), 62 deletions(-) diff --git a/src/custom.cpp b/src/custom.cpp index 3a301a6e..619eb2cf 100644 --- a/src/custom.cpp +++ b/src/custom.cpp @@ -34,7 +34,7 @@ #include "gui.h" #include "picasso96.h" #include "drawing.h" -#include "include/ar.h" +#include "ar.h" #include "akiko.h" #include "devices.h" diff --git a/src/drawing.cpp b/src/drawing.cpp index cae77ced..68c77c62 100644 --- a/src/drawing.cpp +++ b/src/drawing.cpp @@ -147,8 +147,10 @@ static uae_u16 ham_linebuf[MAX_PIXELS_PER_LINE * 2]; static uae_u8 *xlinebuffer; +#define MAX_VIDHEIGHT 270 + static int *native2amiga_line_map; -static uae_u8** row_map; +static uae_u8 *row_map[MAX_VIDHEIGHT + 1]; static uae_u8 row_tmp[MAX_PIXELS_PER_LINE * 32 / 8]; /* line_draw_funcs: pfield_do_linetoscr, pfield_do_fill_line, decode_ham */ @@ -1848,30 +1850,15 @@ static void pfield_doline(int lineno) #endif /* USE_ARMNEON */ } -void init_row_map(void) +void init_row_map() { - static uae_u8* oldbufmem; - static int oldheight, oldpitch; int i, j; - if (gfxvidinfo.drawbuffer.outheight > max_uae_height) - { - write_log(_T("Resolution too high, aborting\n")); - abort(); - } - if (!row_map) - row_map = xmalloc(uae_u8*, max_uae_height + 1); - - if (oldbufmem && oldbufmem == gfxvidinfo.drawbuffer.bufmem && - oldheight == gfxvidinfo.drawbuffer.outheight && - oldpitch == gfxvidinfo.drawbuffer.rowbytes) - return; - - j = oldheight == 0 ? max_uae_height : oldheight; - for (i = gfxvidinfo.drawbuffer.outheight; i < max_uae_height + 1 && i < j + 1; i++) + for (i = gfxvidinfo.drawbuffer.outheight; i < MAX_VIDHEIGHT + 1; i++) row_map[i] = row_tmp; - for (i = 0, j = 0; i < gfxvidinfo.drawbuffer.outheight; i++, j += gfxvidinfo.drawbuffer.rowbytes) + for (i = 0, j = 0; i < gfxvidinfo.drawbuffer.outheight; i++, j += gfxvidinfo.drawbuffer.rowbytes) { row_map[i] = gfxvidinfo.drawbuffer.bufmem + j; + } } static void init_aspect_maps() @@ -1906,6 +1893,8 @@ static void init_aspect_maps() /* * One drawing frame has been finished. Tell the graphics code about it. +* Note that the actual flush_screen() call is a no-op for all reasonable +* systems. */ STATIC_INLINE void do_flush_screen() { diff --git a/src/osdep/amiberry_gfx.cpp b/src/osdep/amiberry_gfx.cpp index e5dd066b..467f818d 100644 --- a/src/osdep/amiberry_gfx.cpp +++ b/src/osdep/amiberry_gfx.cpp @@ -23,7 +23,6 @@ SDL_Surface* screen = nullptr; //static unsigned int current_vsync_frame = 0; unsigned long time_per_frame = 20000; // Default for PAL (50 Hz): 20000 microsecs static unsigned long last_synctime; -static unsigned long next_synctime = 0; /* Possible screen modes (x and y resolutions) */ #define MAX_SCREEN_MODES 14 @@ -270,21 +269,12 @@ bool render_screen(bool immediate) void show_screen(int mode) { - //unsigned long start = read_processor_time(); - last_synctime = read_processor_time(); updatedisplayarea(); - //idletime += last_synctime - start; - if (!screen_is_picasso) gfxvidinfo.drawbuffer.bufmem = static_cast(screen->pixels); - - if (last_synctime - next_synctime > time_per_frame - 5000) - next_synctime = last_synctime + time_per_frame * (1 + currprefs.gfx_framerate); - else - next_synctime = next_synctime + time_per_frame * (1 + currprefs.gfx_framerate); } unsigned long target_lastsynctime(void) @@ -349,8 +339,6 @@ static int init_colors() int blue_shift = maskShift(screen->format->Bmask); alloc_colors64k(red_bits, green_bits, blue_bits, red_shift, green_shift, blue_shift, 0); notice_new_xcolors(); - for (int i = 0; i < 4096; i++) - xcolors[i] = xcolors[i] * 0x00010001; return 1; } @@ -518,32 +506,38 @@ bool vsync_switchmode(int hz) else hz = 50; -// if(hz == 50 && currVSyncRate == 60) -// { -// // Switch from NTSC -> PAL -// switch(changed_height) { -// case 200: changed_height = 240; break; -// case 216: changed_height = 262; break; -// case 240: changed_height = 270; break; -// case 256: changed_height = 270; break; -// case 262: changed_height = 270; break; -// case 270: changed_height = 270; break; -// } -// } -// else if(hz == 60 && currVSyncRate == 50) -// { -// // Switch from PAL -> NTSC -// switch(changed_height) { -// case 200: changed_height = 200; break; -// case 216: changed_height = 200; break; -// case 240: changed_height = 200; break; -// case 256: changed_height = 216; break; -// case 262: changed_height = 216; break; -// case 270: changed_height = 240; break; -// } -// } -// + if (hz == 50 && currVSyncRate == 60) + { + // Switch from NTSC -> PAL + switch (changed_height) { + case 200: changed_height = 240; break; + case 216: changed_height = 262; break; + case 240: changed_height = 270; break; + case 256: changed_height = 270; break; + case 262: changed_height = 270; break; + case 270: changed_height = 270; break; + } + } + else if (hz == 60 && currVSyncRate == 50) + { + // Switch from PAL -> NTSC + switch (changed_height) { + case 200: changed_height = 200; break; + case 216: changed_height = 200; break; + case 240: changed_height = 200; break; + case 256: changed_height = 216; break; + case 262: changed_height = 216; break; + case 270: changed_height = 240; break; + } + } + if (hz != currVSyncRate) + { + SetVSyncRate(hz); + fpscounter_reset(); + time_per_frame = 1000 * 1000 / (hz); + } + if (!picasso_on && !picasso_requested_on) changed_prefs.gfx_size.height = changed_height; @@ -704,10 +698,10 @@ void gfx_set_picasso_state(int on) void gfx_set_picasso_modeinfo(uae_u32 w, uae_u32 h, uae_u32 depth, RGBFTYPE rgbfmt) { depth >>= 3; - if ((unsigned(picasso_vidinfo.width) == w) && - (unsigned(picasso_vidinfo.height) == h) && - (unsigned(picasso_vidinfo.depth) == depth) && - (picasso_vidinfo.selected_rgbformat == rgbfmt)) + if (unsigned(picasso_vidinfo.width) == w && + unsigned(picasso_vidinfo.height) == h && + unsigned(picasso_vidinfo.depth) == depth && + picasso_vidinfo.selected_rgbformat == rgbfmt) return; picasso_vidinfo.selected_rgbformat = rgbfmt;