Code cleanup

This commit is contained in:
Dimitris Panokostas 2017-01-21 18:59:24 +01:00
parent 42e9e309e0
commit c58a66d065

View file

@ -26,9 +26,6 @@ SDL_Surface *screen = NULL;
static int x_size_table[MAX_SCREEN_MODES] = { 640, 640, 720, 800, 800, 960, 1024, 1280, 1280, 1680, 1920 }; static int x_size_table[MAX_SCREEN_MODES] = { 640, 640, 720, 800, 800, 960, 1024, 1280, 1280, 1680, 1920 };
static int y_size_table[MAX_SCREEN_MODES] = { 400, 480, 400, 480, 600, 540, 768, 720, 800, 1050, 1080 }; static int y_size_table[MAX_SCREEN_MODES] = { 400, 480, 400, 480, 600, 540, 768, 720, 800, 1050, 1080 };
static int red_bits, green_bits, blue_bits;
static int red_shift, green_shift, blue_shift;
struct PicassoResolution *DisplayModes; struct PicassoResolution *DisplayModes;
struct MultiDisplay Displays[MAX_DISPLAYS]; struct MultiDisplay Displays[MAX_DISPLAYS];
@ -45,8 +42,6 @@ static void CreateScreenshot(void);
static int save_thumb(char *path); static int save_thumb(char *path);
int delay_savestate_frame = 0; int delay_savestate_frame = 0;
static unsigned long next_synctime = 0;
int graphics_setup (void) int graphics_setup (void)
{ {
#ifdef PICASSO96 #ifdef PICASSO96
@ -119,7 +114,6 @@ void InitAmigaVidMode(struct uae_prefs *p)
#endif #endif
} }
void graphics_subshutdown (void) void graphics_subshutdown (void)
{ {
if (screen != NULL) if (screen != NULL)
@ -131,8 +125,8 @@ void graphics_subshutdown (void)
static void open_screen(struct uae_prefs *p) static void open_screen(struct uae_prefs *p)
{ {
int width; int width;
int height; int height;
#ifdef PICASSO96 #ifdef PICASSO96
if (screen_is_picasso) if (screen_is_picasso)
@ -148,45 +142,36 @@ static void open_screen(struct uae_prefs *p)
height = p->gfx_size.height; height = p->gfx_size.height;
} }
#ifdef ANDROIDSDL graphics_subshutdown();
update_onscreen();
#endif
if (screen == NULL || screen->w != width || screen->h != height) screen = SDL_CreateRGBSurface(0, width, height, 16, 0, 0, 0, 0);
{ check_error_sdl(screen == nullptr, "Unable to create a surface");
graphics_subshutdown();
screen = SDL_CreateRGBSurface(0, width, height, 16, 0, 0, 0, 0);
check_error_sdl(screen == nullptr, "Unable to create a surface");
// make the scaled rendering look smoother. // make the scaled rendering look smoother.
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
SDL_RenderSetLogicalSize(renderer, width, height); SDL_RenderSetLogicalSize(renderer, width, height);
// Initialize SDL Texture for the renderer // Initialize SDL Texture for the renderer
texture = SDL_CreateTexture(renderer, texture = SDL_CreateTexture(renderer,
SDL_PIXELFORMAT_RGB565, SDL_PIXELFORMAT_RGB565,
SDL_TEXTUREACCESS_STREAMING, SDL_TEXTUREACCESS_STREAMING,
width, width,
height); height);
check_error_sdl(texture == nullptr, "Unable to create texture"); check_error_sdl(texture == nullptr, "Unable to create texture");
}
if (screen != NULL)
{
InitAmigaVidMode(p);
init_row_map();
}
// Update the texture from the surface // Update the texture from the surface
SDL_UpdateTexture(texture, NULL, screen->pixels, screen->pitch); SDL_UpdateTexture(texture, NULL, screen->pixels, screen->pitch);
// Wipe out the existing video framebuffer
// SDL_RenderClear(renderer);
// Copy the texture on the renderer // Copy the texture on the renderer
SDL_RenderCopy(renderer, texture, NULL, NULL); SDL_RenderCopy(renderer, texture, NULL, NULL);
// Update the window surface (show the renderer) // Update the window surface (show the renderer)
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
}
if (screen != NULL)
{
InitAmigaVidMode(p);
init_row_map();
}
}
void update_display(struct uae_prefs *p) void update_display(struct uae_prefs *p)
{ {
@ -195,7 +180,6 @@ void update_display(struct uae_prefs *p)
framecnt = 1; // Don't draw frame before reset done framecnt = 1; // Don't draw frame before reset done
} }
int check_prefs_changed_gfx (void) int check_prefs_changed_gfx (void)
{ {
int changed = 0; int changed = 0;
@ -300,17 +284,15 @@ void flush_screen ()
// Update the texture from the surface // Update the texture from the surface
SDL_UpdateTexture(texture, NULL, screen->pixels, screen->pitch); SDL_UpdateTexture(texture, NULL, screen->pixels, screen->pitch);
// Wipe out the existing video framebuffer
// SDL_RenderClear(renderer);
// Copy the texture on the renderer // Copy the texture on the renderer
SDL_RenderCopy(renderer, texture, NULL, NULL); SDL_RenderCopy(renderer, texture, NULL, NULL);
// Update the window surface (show the renderer) // Update the window surface (show the renderer)
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
last_synctime = read_processor_time(); // last_synctime = read_processor_time();
if(!screen_is_picasso) // if(!screen_is_picasso)
gfxvidinfo.bufmem = (uae_u8 *)screen->pixels; // gfxvidinfo.bufmem = (uae_u8 *)screen->pixels;
// if(last_synctime - next_synctime > time_per_frame * (1 + currprefs.gfx_framerate) - 1000 || next_synctime < start) // if(last_synctime - next_synctime > time_per_frame * (1 + currprefs.gfx_framerate) - 1000 || next_synctime < start)
// adjust_idletime(0); // adjust_idletime(0);
@ -325,14 +307,12 @@ void flush_screen ()
init_row_map(); init_row_map();
} }
void black_screen_now(void) void black_screen_now(void)
{ {
SDL_FillRect(screen, NULL, 0); SDL_FillRect(screen, NULL, 0);
flush_screen(); flush_screen();
} }
static void graphics_subinit (void) static void graphics_subinit (void)
{ {
if (screen == NULL) if (screen == NULL)
@ -342,17 +322,7 @@ static void graphics_subinit (void)
} }
else else
{ {
// Update the texture from the surface
SDL_UpdateTexture(texture, NULL, screen->pixels, screen->pitch);
// Wipe out the existing video framebuffer
// SDL_RenderClear(renderer);
// Copy the texture on the renderer
SDL_RenderCopy(renderer, texture, NULL, NULL);
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
InitAmigaVidMode(&currprefs); InitAmigaVidMode(&currprefs);
} }
} }
@ -369,7 +339,6 @@ STATIC_INLINE int bitsInMask (unsigned long mask)
return n; return n;
} }
STATIC_INLINE int maskShift (unsigned long mask) STATIC_INLINE int maskShift (unsigned long mask)
{ {
/* determine how far mask is shifted */ /* determine how far mask is shifted */
@ -382,7 +351,6 @@ STATIC_INLINE int maskShift (unsigned long mask)
return n; return n;
} }
static int init_colors (void) static int init_colors (void)
{ {
int i; int i;
@ -404,7 +372,6 @@ static int init_colors (void)
return 1; return 1;
} }
/* /*
* Find the colour depth of the display * Find the colour depth of the display
*/ */
@ -429,7 +396,6 @@ static int get_display_depth (void)
return depth; return depth;
} }
int GetSurfacePixelFormat(void) int GetSurfacePixelFormat(void)
{ {
int depth = get_display_depth(); int depth = get_display_depth();
@ -443,7 +409,6 @@ int GetSurfacePixelFormat(void)
: RGBFB_NONE); : RGBFB_NONE);
} }
int graphics_init (bool mousecapture) int graphics_init (bool mousecapture)
{ {
graphics_subinit (); graphics_subinit ();
@ -464,7 +429,6 @@ void graphics_leave (void)
SDL_VideoQuit(); SDL_VideoQuit();
} }
#define systemRedShift (screen->format->Rshift) #define systemRedShift (screen->format->Rshift)
#define systemGreenShift (screen->format->Gshift) #define systemGreenShift (screen->format->Gshift)
#define systemBlueShift (screen->format->Bshift) #define systemBlueShift (screen->format->Bshift)
@ -544,7 +508,6 @@ static int save_png(SDL_Surface* surface, char *path)
return 1; return 1;
} }
static void CreateScreenshot(void) static void CreateScreenshot(void)
{ {
int w, h; int w, h;
@ -568,7 +531,6 @@ static void CreateScreenshot(void)
screen->format->Amask); screen->format->Amask);
} }
static int save_thumb(char *path) static int save_thumb(char *path)
{ {
int ret = 0; int ret = 0;
@ -649,20 +611,19 @@ int picasso_palette (void)
{ {
int i, changed; int i, changed;
changed = 0; changed = 0;
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++) {
{ int r = picasso96_state.CLUT[i].Red;
int r = picasso96_state.CLUT[i].Red; int g = picasso96_state.CLUT[i].Green;
int g = picasso96_state.CLUT[i].Green; int b = picasso96_state.CLUT[i].Blue;
int b = picasso96_state.CLUT[i].Blue; int value = (r << 16 | g << 8 | b);
uae_u32 v = CONVERT_RGB(r << 16 | g << 8 | b); uae_u32 v = CONVERT_RGB(value);
if (v != picasso_vidinfo.clut[i]) if (v != picasso_vidinfo.clut[i]) {
{ picasso_vidinfo.clut[i] = v;
picasso_vidinfo.clut[i] = v; changed = 1;
changed = 1; }
} }
} return changed;
return changed;
} }
static int resolution_compare (const void *a, const void *b) static int resolution_compare (const void *a, const void *b)