From 7b61a83340bd7584fb7859cf189372017f28a767 Mon Sep 17 00:00:00 2001 From: Dimitris Panokostas Date: Sun, 2 Apr 2017 15:20:20 +0200 Subject: [PATCH] Internal improvements in screen handling --- VSLinux/Amiberry.vcxproj | 2 +- VSLinux/Amiberry.vcxproj.user | 8 +-- .../Amiberry/Amiberry-Debug.vgdbsettings | 1 + src/custom.cpp | 8 +-- src/osdep/amiberry_gfx.cpp | 70 ++++++++++--------- 5 files changed, 44 insertions(+), 45 deletions(-) diff --git a/VSLinux/Amiberry.vcxproj b/VSLinux/Amiberry.vcxproj index 0aed7b93..6a644aa0 100644 --- a/VSLinux/Amiberry.vcxproj +++ b/VSLinux/Amiberry.vcxproj @@ -544,7 +544,7 @@ - cp ~/projects/Amiberry-sdl2/amiberry-sdl2 ~/projects/amiberry + cp ~/projects/Amiberry/amiberry-sdl2 ~/projects/amiberry Copy binary to launch location diff --git a/VSLinux/Amiberry.vcxproj.user b/VSLinux/Amiberry.vcxproj.user index c6cf3f98..15225acb 100644 --- a/VSLinux/Amiberry.vcxproj.user +++ b/VSLinux/Amiberry.vcxproj.user @@ -4,14 +4,14 @@ ~/projects/amiberry/amiberry-sdl2 ~/projects/amiberry LinuxDebugger - export DISPLAY=:0.0 - gdb + + ~/projects/amiberry/amiberry-sdl2 ~/projects/amiberry LinuxDebugger - export DISPLAY=:0.0 - gdb + + \ No newline at end of file diff --git a/VisualGDB/Amiberry/Amiberry-Debug.vgdbsettings b/VisualGDB/Amiberry/Amiberry-Debug.vgdbsettings index ab680d53..4237630e 100644 --- a/VisualGDB/Amiberry/Amiberry-Debug.vgdbsettings +++ b/VisualGDB/Amiberry/Amiberry-Debug.vgdbsettings @@ -69,6 +69,7 @@ Amiberry.vcxproj + 1 diff --git a/src/custom.cpp b/src/custom.cpp index 9837fcfa..676915a0 100644 --- a/src/custom.cpp +++ b/src/custom.cpp @@ -2697,11 +2697,7 @@ void compute_vsynctime() // vsynctimebase = vsynctimebase_orig = 1; // else vsynctimebase = vsynctimebase_orig = int(syncbase / fake_vblank_hz); -#if 0 - if (!picasso_on) { - updatedisplayarea(); - } -#endif + if (currprefs.produce_sound > 1) { double svpos = maxvpos_nom; @@ -2720,7 +2716,7 @@ void compute_vsynctime() svpos += 1.0; } double clk = svpos * shpos * fake_vblank_hz; - //write_log (_T("SNDRATE %.1f*%.1f*%.6f=%.6f\n"), svpos, shpos, fake_vblank_hz, clk); + update_sound(clk); } } diff --git a/src/osdep/amiberry_gfx.cpp b/src/osdep/amiberry_gfx.cpp index d26de569..b870a745 100644 --- a/src/osdep/amiberry_gfx.cpp +++ b/src/osdep/amiberry_gfx.cpp @@ -53,7 +53,7 @@ int graphics_setup(void) void InitAmigaVidMode(struct uae_prefs* p) { /* Initialize structure for Amiga video modes */ - gfxvidinfo.pixbytes = 2; + gfxvidinfo.pixbytes = screen->format->BytesPerPixel; gfxvidinfo.bufmem = static_cast(screen->pixels); gfxvidinfo.outwidth = screen->w ? screen->w : 640; //p->gfx_size.width; gfxvidinfo.outheight = screen->h ? screen->h : 256; //p->gfx_size.height; @@ -73,6 +73,33 @@ void graphics_subshutdown() } } +void Create_SDL_Surface(int width, int height, int depth) +{ + screen = SDL_CreateRGBSurface(0, width, height, depth, 0, 0, 0, 0); + check_error_sdl(screen == nullptr, "Unable to create a surface"); +} + +void Create_SDL_Texture(int width, int height, int depth) +{ + if (depth == 16) { + // Initialize SDL Texture for the renderer + texture = SDL_CreateTexture(renderer, + SDL_PIXELFORMAT_RGB565, // 16-bit + SDL_TEXTUREACCESS_STREAMING, + width, + height); + } + else if (depth == 32) + { + texture = SDL_CreateTexture(renderer, + SDL_PIXELFORMAT_BGRA32, // 32-bit + SDL_TEXTUREACCESS_STREAMING, + width, + height); + } + check_error_sdl(texture == nullptr, "Unable to create texture"); +} + // Check if the requested Amiga resolution can be displayed with the current Screen mode as a direct multiple // Based on this we make the decision to use Linear (smooth) or Nearest Neighbor (pixelated) scaling bool isModeAspectRatioExact(SDL_DisplayMode* mode, int width, int height) @@ -97,13 +124,13 @@ static void open_screen(struct uae_prefs* p) { int width; int height; + int depth = 16; #ifdef PICASSO96 if (screen_is_picasso) { width = picasso_vidinfo.width; height = picasso_vidinfo.height; - SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); // make the scaled rendering look smoother. } else #endif @@ -127,21 +154,14 @@ static void open_screen(struct uae_prefs* p) graphics_subshutdown(); - screen = SDL_CreateRGBSurface(0, width, height, 16, 0, 0, 0, 0); - check_error_sdl(screen == nullptr, "Unable to create a surface"); + Create_SDL_Surface(width, height, depth); if (screen_is_picasso) SDL_RenderSetLogicalSize(renderer, width, height); else SDL_RenderSetLogicalSize(renderer, width, height*2); - // Initialize SDL Texture for the renderer - texture = SDL_CreateTexture(renderer, - SDL_PIXELFORMAT_RGB565, - SDL_TEXTUREACCESS_STREAMING, - width, - height); - check_error_sdl(texture == nullptr, "Unable to create texture"); + Create_SDL_Texture(width, height, depth); updatedisplayarea(); @@ -307,22 +327,7 @@ const TCHAR *target_get_display_name(int num, bool friendlyname) */ static int get_display_depth() { - // const SDL_VideoInfo *vid_info; - - // int depth = 0; - int depth = 16; - - // if ((vid_info = SDL_GetVideoInfo())) - // { - // depth = vid_info->vfmt->BitsPerPixel; - - /* Don't trust the answer if it's 16 bits; the display - * could actually be 15 bits deep. We'll count the bits - * ourselves */ - // if (depth == 16) - // depth = bitsInMask (vid_info->vfmt->Rmask) + bitsInMask (vid_info->vfmt->Gmask) + bitsInMask (vid_info->vfmt->Bmask); - // } - + int depth = screen->format->BytesPerPixel == 4 ? 32 : 16; return depth; } @@ -641,9 +646,7 @@ void picasso_InitResolutions() int rgbFormat = (bitdepth == 8 ? RGBFB_CLUT : (bitdepth == 16 ? RGBFB_R5G6B5 : RGBFB_R8G8B8A8)); int pixelFormat = 1 << rgbFormat; pixelFormat |= RGBFF_CHUNKY; - // - // if (SDL_VideoModeOK (x_size_table[i], y_size_table[i], 16, SDL_SWSURFACE)) - // { + DisplayModes[count].res.width = x_size_table[i]; DisplayModes[count].res.height = y_size_table[i]; DisplayModes[count].depth = bit_unit >> 3; @@ -655,7 +658,6 @@ void picasso_InitResolutions() DisplayModes[count].res.width, DisplayModes[count].res.height, DisplayModes[count].depth * 8); count++; - // } } } DisplayModes[count].depth = -1; @@ -688,15 +690,15 @@ void gfx_set_picasso_modeinfo(uae_u32 w, uae_u32 h, uae_u32 depth, RGBFTYPE rgbf picasso_vidinfo.selected_rgbformat = rgbfmt; picasso_vidinfo.width = w; picasso_vidinfo.height = h; - picasso_vidinfo.depth = 2; // Native depth + picasso_vidinfo.depth = screen->format->BytesPerPixel; // Native depth picasso_vidinfo.extra_mem = 1; - picasso_vidinfo.pixbytes = 2; // Native bytes + picasso_vidinfo.pixbytes = screen->format->BytesPerPixel; // Native bytes if (screen_is_picasso) { open_screen(&currprefs); picasso_vidinfo.rowbytes = screen->pitch; - picasso_vidinfo.rgbformat = RGBFB_R5G6B5; + picasso_vidinfo.rgbformat = screen->format->BytesPerPixel == 4 ? RGBFB_R8G8B8A8 : RGBFB_R5G6B5; } }