Code cleanup

This commit is contained in:
Dimitris Panokostas 2017-01-29 14:24:34 +01:00
parent 6b7a381995
commit 186a05dfe8
3 changed files with 4599 additions and 3842 deletions

File diff suppressed because it is too large Load diff

View file

@ -35,9 +35,9 @@ static char screenshot_filename_default[255]=
{
'/', 't', 'm', 'p', '/', 'n', 'u', 'l', 'l', '.', 'p', 'n', 'g', '\0'
};
char *screenshot_filename=(char *)&screenshot_filename_default[0];
char* screenshot_filename = static_cast<char *>(&screenshot_filename_default[0]);
FILE* screenshot_file = nullptr;
static void CreateScreenshot(void);
static void CreateScreenshot();
static int save_thumb(char* path);
int delay_savestate_frame = 0;
@ -100,7 +100,7 @@ void InitAmigaVidMode(struct uae_prefs *p)
{
/* Initialize structure for Amiga video modes */
gfxvidinfo.pixbytes = 2;
gfxvidinfo.bufmem = (uae_u8 *)screen->pixels;
gfxvidinfo.bufmem = static_cast<uae_u8 *>(screen->pixels);
gfxvidinfo.outwidth = p->gfx_size.width;
gfxvidinfo.outheight = p->gfx_size.height;
gfxvidinfo.rowbytes = screen->pitch;
@ -113,14 +113,14 @@ void InitAmigaVidMode(struct uae_prefs *p)
#endif
}
void graphics_subshutdown (void)
void graphics_subshutdown()
{
if (screen != NULL)
if (screen != nullptr)
{
SDL_FreeSurface(screen);
screen = NULL;
screen = nullptr;
}
if (texture != NULL)
if (texture != nullptr)
{
SDL_DestroyTexture(texture);
}
@ -162,14 +162,14 @@ static void open_screen(struct uae_prefs *p)
check_error_sdl(texture == nullptr, "Unable to create texture");
// Update the texture from the surface
SDL_UpdateTexture(texture, NULL, screen->pixels, screen->pitch);
SDL_UpdateTexture(texture, nullptr, screen->pixels, screen->pitch);
SDL_RenderClear(renderer);
// Copy the texture on the renderer
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderCopy(renderer, texture, nullptr, nullptr);
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
if (screen != NULL)
if (screen != nullptr)
{
InitAmigaVidMode(p);
init_row_map();
@ -183,7 +183,7 @@ void update_display(struct uae_prefs *p)
framecnt = 1; // Don't draw frame before reset done
}
int check_prefs_changed_gfx (void)
int check_prefs_changed_gfx()
{
int changed = 0;
@ -222,22 +222,21 @@ int check_prefs_changed_gfx (void)
}
int lockscr (void)
int lockscr()
{
SDL_LockSurface(screen);
return 1;
}
void unlockscr (void)
void unlockscr()
{
SDL_UnlockSurface(screen);
}
void wait_for_vsync(void)
void wait_for_vsync()
{
}
@ -286,9 +285,9 @@ void flush_screen ()
// }
// Update the texture from the surface
SDL_UpdateTexture(texture, NULL, screen->pixels, screen->pitch);
SDL_UpdateTexture(texture, nullptr, screen->pixels, screen->pitch);
// Copy the texture on the renderer
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderCopy(renderer, texture, nullptr, nullptr);
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
@ -310,12 +309,11 @@ void flush_screen ()
init_row_map();
}
static void graphics_subinit (void)
static void graphics_subinit()
{
if (screen == NULL)
if (screen == nullptr)
{
fprintf(stderr, "Unable to set video mode: %s\n", SDL_GetError());
return;
}
else
{
@ -348,7 +346,7 @@ STATIC_INLINE int maskShift (unsigned long mask)
return n;
}
static int init_colors (void)
static int init_colors()
{
int i;
int red_bits, green_bits, blue_bits;
@ -372,7 +370,7 @@ static int init_colors (void)
/*
* Find the colour depth of the display
*/
static int get_display_depth (void)
static int get_display_depth()
{
// const SDL_VideoInfo *vid_info;
@ -393,7 +391,7 @@ static int get_display_depth (void)
return depth;
}
int GetSurfacePixelFormat(void)
int GetSurfacePixelFormat()
{
int depth = get_display_depth();
int unit = depth + 1 & 0xF8;
@ -416,7 +414,7 @@ int graphics_init (bool mousecapture)
return 1;
}
void graphics_leave (void)
void graphics_leave()
{
graphics_subshutdown();
@ -437,14 +435,14 @@ static int save_png(SDL_Surface* surface, char *path)
{
int w = surface->w;
int h = surface->h;
unsigned char * pix = (unsigned char *)surface->pixels;
unsigned char* pix = static_cast<unsigned char *>(surface->pixels);
unsigned char writeBuffer[1024 * 3];
FILE* f = fopen(path, "wb");
if (!f) return 0;
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
NULL,
NULL,
NULL);
nullptr,
nullptr,
nullptr);
if (!png_ptr)
{
fclose(f);
@ -481,7 +479,7 @@ static int save_png(SDL_Surface* surface, char *path)
int y;
int x;
unsigned short *p = (unsigned short *)pix;
unsigned short* p = reinterpret_cast<unsigned short *>(pix);
for (y = 0; y < sizeY; y++)
{
for (x = 0; x < sizeX; x++)
@ -505,14 +503,14 @@ static int save_png(SDL_Surface* surface, char *path)
return 1;
}
static void CreateScreenshot(void)
static void CreateScreenshot()
{
int w, h;
if(current_screenshot != NULL)
if (current_screenshot != nullptr)
{
SDL_FreeSurface(current_screenshot);
current_screenshot = NULL;
current_screenshot = nullptr;
}
w = screen->w;
@ -531,11 +529,11 @@ static void CreateScreenshot(void)
static int save_thumb(char* path)
{
int ret = 0;
if(current_screenshot != NULL)
if (current_screenshot != nullptr)
{
ret = save_png(current_screenshot, path);
SDL_FreeSurface(current_screenshot);
current_screenshot = NULL;
current_screenshot = nullptr;
}
return ret;
}
@ -582,9 +580,9 @@ bool vsync_switchmode (int hz)
return true;
}
bool target_graphics_buffer_update (void)
bool target_graphics_buffer_update()
{
bool rate_changed = 0;
bool rate_changed = false;
if (currprefs.gfx_size.height != changed_prefs.gfx_size.height)
{
@ -603,18 +601,20 @@ bool target_graphics_buffer_update (void)
#ifdef PICASSO96
int picasso_palette (void)
int picasso_palette()
{
int i, changed;
changed = 0;
for (i = 0; i < 256; i++) {
for (i = 0; i < 256; i++)
{
int r = picasso96_state.CLUT[i].Red;
int g = picasso96_state.CLUT[i].Green;
int b = picasso96_state.CLUT[i].Blue;
int value = (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;
changed = 1;
}
@ -637,7 +637,7 @@ static int resolution_compare (const void *a, const void *b)
return ma->depth - mb->depth;
}
static void sortmodes (void)
static void sortmodes()
{
int i = 0, idx = -1;
int pw = -1, ph = -1;
@ -656,7 +656,7 @@ static void sortmodes (void)
}
}
static void modesList (void)
static void modesList()
{
int i, j;
@ -677,7 +677,7 @@ static void modesList (void)
}
}
void picasso_InitResolutions (void)
void picasso_InitResolutions()
{
struct MultiDisplay* md1;
int i, count = 0;
@ -765,14 +765,14 @@ void gfx_set_picasso_modeinfo (uae_u32 w, uae_u32 h, uae_u32 depth, RGBFTYPE rgb
}
}
uae_u8 *gfx_lock_picasso (void)
uae_u8* gfx_lock_picasso()
{
SDL_LockSurface(screen);
picasso_vidinfo.rowbytes = screen->pitch;
return (uae_u8 *)screen->pixels;
return static_cast<uae_u8 *>(screen->pixels);
}
void gfx_unlock_picasso (void)
void gfx_unlock_picasso()
{
SDL_UnlockSurface(screen);
}

View file

@ -47,7 +47,7 @@
#include "config.h"
#include "options.h"
#include "threaddep/thread.h"
#include "memory.h"
#include "include/memory.h"
#include "custom.h"
#include "newcpu.h"
#include "xwin.h"