Fixed framerate problem with vsyc
This commit is contained in:
parent
d4c2ab0884
commit
df3bd366e2
4 changed files with 1530 additions and 1466 deletions
|
@ -10,9 +10,9 @@
|
||||||
<Transport>None</Transport>
|
<Transport>None</Transport>
|
||||||
</BuildHost>
|
</BuildHost>
|
||||||
<DeploymentHost>
|
<DeploymentHost>
|
||||||
<HostName>192.168.1.155</HostName>
|
<HostName>172.16.2.42</HostName>
|
||||||
<Transport>SSH</Transport>
|
<Transport>SSH</Transport>
|
||||||
<UserName>root</UserName>
|
<UserName>pi</UserName>
|
||||||
</DeploymentHost>
|
</DeploymentHost>
|
||||||
<MainSourceTransferCommand>
|
<MainSourceTransferCommand>
|
||||||
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
|
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
|
||||||
|
|
961
src/drawing.cpp
961
src/drawing.cpp
File diff suppressed because it is too large
Load diff
|
@ -23,25 +23,25 @@
|
||||||
#define lores_shift 0
|
#define lores_shift 0
|
||||||
extern bool aga_mode;
|
extern bool aga_mode;
|
||||||
|
|
||||||
STATIC_INLINE int coord_hw_to_window_x (int x)
|
STATIC_INLINE int coord_hw_to_window_x(int x)
|
||||||
{
|
{
|
||||||
x -= DISPLAY_LEFT_SHIFT;
|
x -= DISPLAY_LEFT_SHIFT;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC_INLINE int coord_window_to_hw_x (int x)
|
STATIC_INLINE int coord_window_to_hw_x(int x)
|
||||||
{
|
{
|
||||||
return x + DISPLAY_LEFT_SHIFT;
|
return x + DISPLAY_LEFT_SHIFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC_INLINE int coord_diw_to_window_x (int x)
|
STATIC_INLINE int coord_diw_to_window_x(int x)
|
||||||
{
|
{
|
||||||
return (x - DISPLAY_LEFT_SHIFT + DIW_DDF_OFFSET - 1);
|
return (x - DISPLAY_LEFT_SHIFT + DIW_DDF_OFFSET - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC_INLINE int coord_window_to_diw_x (int x)
|
STATIC_INLINE int coord_window_to_diw_x(int x)
|
||||||
{
|
{
|
||||||
x = coord_window_to_hw_x (x);
|
x = coord_window_to_hw_x(x);
|
||||||
return x - DIW_DDF_OFFSET;
|
return x - DIW_DDF_OFFSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,18 +69,19 @@ struct color_entry {
|
||||||
STATIC_INLINE uae_u16 CONVERT_RGB(uae_u32 c)
|
STATIC_INLINE uae_u16 CONVERT_RGB(uae_u32 c)
|
||||||
{
|
{
|
||||||
uae_u16 ret;
|
uae_u16 ret;
|
||||||
__asm__ (
|
__asm__(
|
||||||
"ubfx r1, %[c], #19, #5 \n\t"
|
"ubfx r1, %[c], #19, #5 \n\t"
|
||||||
"ubfx r2, %[c], #10, #6 \n\t"
|
"ubfx r2, %[c], #10, #6 \n\t"
|
||||||
"ubfx %[v], %[c], #3, #5 \n\t"
|
"ubfx %[v], %[c], #3, #5 \n\t"
|
||||||
"orr %[v], %[v], r1, lsl #11 \n\t"
|
"orr %[v], %[v], r1, lsl #11 \n\t"
|
||||||
"orr %[v], %[v], r2, lsl #5 \n\t"
|
"orr %[v], %[v], r2, lsl #5 \n\t"
|
||||||
: [v] "=r" (ret) : [c] "r" (c) : "r1", "r2" );
|
: [v] "=r" (ret) : [c] "r" (c) : "r1",
|
||||||
|
"r2");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC_INLINE xcolnr getxcolor (int c)
|
STATIC_INLINE xcolnr getxcolor(int c)
|
||||||
{
|
{
|
||||||
if (aga_mode)
|
if (aga_mode)
|
||||||
return CONVERT_RGB(c);
|
return CONVERT_RGB(c);
|
||||||
|
@ -89,7 +90,7 @@ STATIC_INLINE xcolnr getxcolor (int c)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* functions for reading, writing, copying and comparing struct color_entry */
|
/* functions for reading, writing, copying and comparing struct color_entry */
|
||||||
STATIC_INLINE int color_reg_get (struct color_entry *ce, int c)
|
STATIC_INLINE int color_reg_get(struct color_entry *ce, int c)
|
||||||
{
|
{
|
||||||
if (aga_mode)
|
if (aga_mode)
|
||||||
return ce->color_regs_aga[c];
|
return ce->color_regs_aga[c];
|
||||||
|
@ -97,7 +98,7 @@ STATIC_INLINE int color_reg_get (struct color_entry *ce, int c)
|
||||||
return ce->color_regs_ecs[c];
|
return ce->color_regs_ecs[c];
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC_INLINE void color_reg_set (struct color_entry *ce, int c, int v)
|
STATIC_INLINE void color_reg_set(struct color_entry *ce, int c, int v)
|
||||||
{
|
{
|
||||||
if (aga_mode)
|
if (aga_mode)
|
||||||
ce->color_regs_aga[c] = v;
|
ce->color_regs_aga[c] = v;
|
||||||
|
@ -106,12 +107,12 @@ STATIC_INLINE void color_reg_set (struct color_entry *ce, int c, int v)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ugly copy hack, is there better solution? */
|
/* ugly copy hack, is there better solution? */
|
||||||
STATIC_INLINE void color_reg_cpy (struct color_entry *dst, struct color_entry *src)
|
STATIC_INLINE void color_reg_cpy(struct color_entry *dst, struct color_entry *src)
|
||||||
{
|
{
|
||||||
dst->borderblank = src->borderblank;
|
dst->borderblank = src->borderblank;
|
||||||
if (aga_mode)
|
if (aga_mode)
|
||||||
/* copy acolors and color_regs_aga */
|
/* copy acolors and color_regs_aga */
|
||||||
memcpy (dst->acolors, src->acolors, sizeof(struct color_entry) - sizeof(uae_u16) * 32);
|
memcpy(dst->acolors, src->acolors, sizeof(struct color_entry) - sizeof(uae_u16) * 32);
|
||||||
else
|
else
|
||||||
/* copy first 32 acolors and color_regs_ecs */
|
/* copy first 32 acolors and color_regs_ecs */
|
||||||
memcpy(dst->color_regs_ecs, src->color_regs_ecs, sizeof(uae_u16) * 32 + sizeof(xcolnr) * 32);
|
memcpy(dst->color_regs_ecs, src->color_regs_ecs, sizeof(uae_u16) * 32 + sizeof(xcolnr) * 32);
|
||||||
|
@ -197,17 +198,17 @@ extern struct decision line_decisions[2 * (MAXVPOS + 2) + 1];
|
||||||
extern uae_u8 line_data[(MAXVPOS + 2) * 2][MAX_PLANES * MAX_WORDS_PER_LINE * 2];
|
extern uae_u8 line_data[(MAXVPOS + 2) * 2][MAX_PLANES * MAX_WORDS_PER_LINE * 2];
|
||||||
|
|
||||||
/* Functions in drawing.c. */
|
/* Functions in drawing.c. */
|
||||||
extern int coord_native_to_amiga_y (int);
|
extern int coord_native_to_amiga_y(int);
|
||||||
extern int coord_native_to_amiga_x (int);
|
extern int coord_native_to_amiga_x(int);
|
||||||
|
|
||||||
extern void hsync_record_line_state (int lineno);
|
extern void hsync_record_line_state(int lineno);
|
||||||
extern void vsync_handle_redraw (void);
|
extern void vsync_handle_redraw(void);
|
||||||
extern void vsync_handle_check (void);
|
extern void vsync_handle_check(void);
|
||||||
extern void init_hardware_for_drawing_frame (void);
|
extern void init_hardware_for_drawing_frame(void);
|
||||||
extern void reset_drawing (void);
|
extern void reset_drawing(void);
|
||||||
extern void drawing_init (void);
|
extern void drawing_init(void);
|
||||||
|
|
||||||
extern unsigned long time_per_frame;
|
extern long time_per_frame;
|
||||||
extern void adjust_idletime(long ns_waited);
|
extern void adjust_idletime(long ns_waited);
|
||||||
|
|
||||||
/* Finally, stuff that shouldn't really be shared. */
|
/* Finally, stuff that shouldn't really be shared. */
|
||||||
|
@ -218,15 +219,15 @@ extern void adjust_idletime(long ns_waited);
|
||||||
|
|
||||||
extern int inhibit_frame;
|
extern int inhibit_frame;
|
||||||
|
|
||||||
STATIC_INLINE void set_inhibit_frame (int bit)
|
STATIC_INLINE void set_inhibit_frame(int bit)
|
||||||
{
|
{
|
||||||
inhibit_frame |= 1 << bit;
|
inhibit_frame |= 1 << bit;
|
||||||
}
|
}
|
||||||
STATIC_INLINE void clear_inhibit_frame (int bit)
|
STATIC_INLINE void clear_inhibit_frame(int bit)
|
||||||
{
|
{
|
||||||
inhibit_frame &= ~(1 << bit);
|
inhibit_frame &= ~(1 << bit);
|
||||||
}
|
}
|
||||||
STATIC_INLINE void toggle_inhibit_frame (int bit)
|
STATIC_INLINE void toggle_inhibit_frame(int bit)
|
||||||
{
|
{
|
||||||
inhibit_frame ^= 1 << bit;
|
inhibit_frame ^= 1 << bit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "uae.h"
|
#include "uae.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include "include/memory.h"
|
#include "memory.h"
|
||||||
#include "newcpu.h"
|
#include "newcpu.h"
|
||||||
#include "inputdevice.h"
|
#include "inputdevice.h"
|
||||||
#include "custom.h"
|
#include "custom.h"
|
||||||
|
@ -65,10 +65,12 @@ static int save_thumb(char *path);
|
||||||
int delay_savestate_frame = 0;
|
int delay_savestate_frame = 0;
|
||||||
|
|
||||||
int DispManXElementpresent = 0;
|
int DispManXElementpresent = 0;
|
||||||
|
|
||||||
static long next_synctime = 0;
|
static long next_synctime = 0;
|
||||||
|
|
||||||
uae_sem_t vsync_wait_sem;
|
uae_sem_t vsync_wait_sem;
|
||||||
|
|
||||||
|
|
||||||
DISPMANX_DISPLAY_HANDLE_T dispmanxdisplay;
|
DISPMANX_DISPLAY_HANDLE_T dispmanxdisplay;
|
||||||
DISPMANX_MODEINFO_T dispmanxdinfo;
|
DISPMANX_MODEINFO_T dispmanxdinfo;
|
||||||
DISPMANX_RESOURCE_HANDLE_T dispmanxresource_amigafb_1;
|
DISPMANX_RESOURCE_HANDLE_T dispmanxresource_amigafb_1;
|
||||||
|
@ -80,26 +82,28 @@ VC_RECT_T dst_rect;
|
||||||
VC_RECT_T blit_rect;
|
VC_RECT_T blit_rect;
|
||||||
|
|
||||||
unsigned char current_resource_amigafb = 0;
|
unsigned char current_resource_amigafb = 0;
|
||||||
|
|
||||||
unsigned char need_wait_dispmanx_semaphore = 0;
|
unsigned char need_wait_dispmanx_semaphore = 0;
|
||||||
long start;
|
long start;
|
||||||
|
|
||||||
|
|
||||||
void vsync_callback(unsigned int a, void* b)
|
void vsync_callback(unsigned int a, void* b)
|
||||||
{
|
{
|
||||||
uae_sem_post(&vsync_wait_sem);
|
|
||||||
// Here we are synchronized with VSync
|
// Here we are synchronized with VSync
|
||||||
// next_synctime is what we were expected as sync time.
|
// next_synctime is what we were expected as sync time.
|
||||||
last_synctime = read_processor_time();
|
last_synctime = read_processor_time();
|
||||||
// check if we miss a frame (with a margin of 1000 cycles)
|
// Check if we miss a frame (with a margin of 1000 cycles)
|
||||||
if (last_synctime - next_synctime > time_per_frame * (1 + currprefs.gfx_framerate) - (long)1000)
|
if (last_synctime - next_synctime > time_per_frame * (1 + currprefs.gfx_framerate) - (long)1000)
|
||||||
adjust_idletime(-1);
|
adjust_idletime(-1);
|
||||||
else
|
else
|
||||||
adjust_idletime(last_synctime - start);
|
adjust_idletime(last_synctime - start);
|
||||||
// Update next synctime with current sync
|
// Update next synctime with current sync.
|
||||||
next_synctime = last_synctime + time_per_frame * (1 + currprefs.gfx_framerate);
|
next_synctime = last_synctime + time_per_frame * (1 + currprefs.gfx_framerate);
|
||||||
|
|
||||||
uae_sem_post(&vsync_wait_sem);
|
uae_sem_post(&vsync_wait_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int graphics_setup(void)
|
int graphics_setup(void)
|
||||||
{
|
{
|
||||||
#ifdef PICASSO96
|
#ifdef PICASSO96
|
||||||
|
@ -110,6 +114,7 @@ int graphics_setup(void)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InitAmigaVidMode(struct uae_prefs *p)
|
void InitAmigaVidMode(struct uae_prefs *p)
|
||||||
{
|
{
|
||||||
/* Initialize structure for Amiga video modes */
|
/* Initialize structure for Amiga video modes */
|
||||||
|
@ -139,6 +144,7 @@ void graphics_dispmanshutdown(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void graphics_subshutdown(void)
|
void graphics_subshutdown(void)
|
||||||
{
|
{
|
||||||
if (dispmanxresource_amigafb_1 != 0)
|
if (dispmanxresource_amigafb_1 != 0)
|
||||||
|
@ -148,14 +154,20 @@ void graphics_subshutdown(void)
|
||||||
//prSDLScreen = NULL;
|
//prSDLScreen = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void open_screen(struct uae_prefs *p)
|
static void open_screen(struct uae_prefs *p)
|
||||||
{
|
{
|
||||||
|
|
||||||
VC_DISPMANX_ALPHA_T alpha = {
|
VC_DISPMANX_ALPHA_T alpha = {
|
||||||
(DISPMANX_FLAGS_ALPHA_T)(DISPMANX_FLAGS_ALPHA_FROM_SOURCE | DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS),
|
(DISPMANX_FLAGS_ALPHA_T)(DISPMANX_FLAGS_ALPHA_FROM_SOURCE | DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS),
|
||||||
255, /*alpha 0->255*/
|
255, /*alpha 0->255*/
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
uint32_t vc_image_ptr;
|
uint32_t vc_image_ptr;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
@ -174,6 +186,7 @@ static void open_screen(struct uae_prefs *p)
|
||||||
height = p->gfx_size.height;
|
height = p->gfx_size.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//if(prSDLScreen != NULL)
|
//if(prSDLScreen != NULL)
|
||||||
//{
|
//{
|
||||||
// SDL_FreeSurface(prSDLScreen);
|
// SDL_FreeSurface(prSDLScreen);
|
||||||
|
@ -183,9 +196,7 @@ static void open_screen(struct uae_prefs *p)
|
||||||
if (Dummy_prSDLScreen == NULL)
|
if (Dummy_prSDLScreen == NULL)
|
||||||
{
|
{
|
||||||
const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo();
|
const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo();
|
||||||
#ifdef DEBUG
|
|
||||||
printf("DispmanX: Current resolution: %d x %d %d bpp\n", videoInfo->current_w, videoInfo->current_h, videoInfo->vfmt->BitsPerPixel);
|
printf("DispmanX: Current resolution: %d x %d %d bpp\n", videoInfo->current_w, videoInfo->current_h, videoInfo->vfmt->BitsPerPixel);
|
||||||
#endif
|
|
||||||
// For debug, in order to avoid full screen.
|
// For debug, in order to avoid full screen.
|
||||||
Dummy_prSDLScreen = SDL_SetVideoMode(videoInfo->current_w, videoInfo->current_h, 16, SDL_SWSURFACE | SDL_FULLSCREEN);
|
Dummy_prSDLScreen = SDL_SetVideoMode(videoInfo->current_w, videoInfo->current_h, 16, SDL_SWSURFACE | SDL_FULLSCREEN);
|
||||||
//Dummy_prSDLScreen = SDL_SetVideoMode(800,480,16,SDL_SWSURFACE );
|
//Dummy_prSDLScreen = SDL_SetVideoMode(800,480,16,SDL_SWSURFACE );
|
||||||
|
@ -198,9 +209,7 @@ static void open_screen(struct uae_prefs *p)
|
||||||
((blit_rect.width != width) || (blit_rect.height != height) || (currprefs.gfx_correct_aspect != changed_prefs.gfx_correct_aspect) ||
|
((blit_rect.width != width) || (blit_rect.height != height) || (currprefs.gfx_correct_aspect != changed_prefs.gfx_correct_aspect) ||
|
||||||
(currprefs.gfx_fullscreen_ratio != changed_prefs.gfx_fullscreen_ratio)))
|
(currprefs.gfx_fullscreen_ratio != changed_prefs.gfx_fullscreen_ratio)))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
|
||||||
printf("Emulation resolution change detected.\n");
|
printf("Emulation resolution change detected.\n");
|
||||||
#endif
|
|
||||||
if (prSDLScreen != NULL)
|
if (prSDLScreen != NULL)
|
||||||
{
|
{
|
||||||
SDL_FreeSurface(prSDLScreen);
|
SDL_FreeSurface(prSDLScreen);
|
||||||
|
@ -215,9 +224,7 @@ static void open_screen(struct uae_prefs *p)
|
||||||
|
|
||||||
if (dispmanxresource_amigafb_1 == 0)
|
if (dispmanxresource_amigafb_1 == 0)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
|
||||||
printf("Emulation resolution: Width %i Height: %i\n", width, height);
|
printf("Emulation resolution: Width %i Height: %i\n", width, height);
|
||||||
#endif
|
|
||||||
currprefs.gfx_correct_aspect = changed_prefs.gfx_correct_aspect;
|
currprefs.gfx_correct_aspect = changed_prefs.gfx_correct_aspect;
|
||||||
currprefs.gfx_fullscreen_ratio = changed_prefs.gfx_fullscreen_ratio;
|
currprefs.gfx_fullscreen_ratio = changed_prefs.gfx_fullscreen_ratio;
|
||||||
prSDLScreen = SDL_CreateRGBSurface(SDL_SWSURFACE,
|
prSDLScreen = SDL_CreateRGBSurface(SDL_SWSURFACE,
|
||||||
|
@ -301,6 +308,7 @@ static void open_screen(struct uae_prefs *p)
|
||||||
//framecnt = 1; // Don't draw frame before reset done
|
//framecnt = 1; // Don't draw frame before reset done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void update_display(struct uae_prefs *p)
|
void update_display(struct uae_prefs *p)
|
||||||
{
|
{
|
||||||
open_screen(p);
|
open_screen(p);
|
||||||
|
@ -310,6 +318,7 @@ 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;
|
||||||
|
@ -364,8 +373,10 @@ void wait_for_vsync(void)
|
||||||
// Temporary
|
// Temporary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void flush_screen()
|
void flush_screen()
|
||||||
{
|
{
|
||||||
|
//SDL_UnlockSurface (prSDLScreen);
|
||||||
|
|
||||||
if (savestate_state == STATE_DOSAVE)
|
if (savestate_state == STATE_DOSAVE)
|
||||||
{
|
{
|
||||||
|
@ -379,6 +390,11 @@ void flush_screen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//start = read_processor_time();
|
||||||
|
//if(start < next_synctime && next_synctime - start > time_per_frame - 1000)
|
||||||
|
// usleep((next_synctime - start) - 1000);
|
||||||
|
//SDL_Flip(prSDLScreen);
|
||||||
|
|
||||||
if (need_wait_dispmanx_semaphore == 1)
|
if (need_wait_dispmanx_semaphore == 1)
|
||||||
{
|
{
|
||||||
need_wait_dispmanx_semaphore = 0;
|
need_wait_dispmanx_semaphore = 0;
|
||||||
|
@ -386,6 +402,7 @@ void flush_screen()
|
||||||
uae_sem_wait(&vsync_wait_sem);
|
uae_sem_wait(&vsync_wait_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (current_resource_amigafb == 1)
|
if (current_resource_amigafb == 1)
|
||||||
{
|
{
|
||||||
current_resource_amigafb = 0;
|
current_resource_amigafb = 0;
|
||||||
|
@ -414,13 +431,13 @@ void flush_screen()
|
||||||
|
|
||||||
vc_dispmanx_update_submit(dispmanxupdate, vsync_callback, NULL);
|
vc_dispmanx_update_submit(dispmanxupdate, vsync_callback, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
need_wait_dispmanx_semaphore = 1;
|
need_wait_dispmanx_semaphore = 1;
|
||||||
|
|
||||||
init_row_map();
|
init_row_map();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void black_screen_now(void)
|
void black_screen_now(void)
|
||||||
{
|
{
|
||||||
SDL_FillRect(prSDLScreen, NULL, 0);
|
SDL_FillRect(prSDLScreen, NULL, 0);
|
||||||
|
@ -428,6 +445,7 @@ void black_screen_now(void)
|
||||||
flush_screen();
|
flush_screen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void graphics_subinit(void)
|
static void graphics_subinit(void)
|
||||||
{
|
{
|
||||||
if (prSDLScreen == NULL)
|
if (prSDLScreen == NULL)
|
||||||
|
@ -455,6 +473,7 @@ 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 */
|
||||||
|
@ -467,6 +486,7 @@ 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;
|
||||||
|
@ -488,6 +508,7 @@ static int init_colors(void)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the colour depth of the display
|
* Find the colour depth of the display
|
||||||
*/
|
*/
|
||||||
|
@ -496,8 +517,7 @@ static int get_display_depth(void)
|
||||||
const SDL_VideoInfo *vid_info;
|
const SDL_VideoInfo *vid_info;
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
|
|
||||||
if ((vid_info = SDL_GetVideoInfo()))
|
if ((vid_info = SDL_GetVideoInfo())) {
|
||||||
{
|
|
||||||
depth = vid_info->vfmt->BitsPerPixel;
|
depth = vid_info->vfmt->BitsPerPixel;
|
||||||
|
|
||||||
/* Don't trust the answer if it's 16 bits; the display
|
/* Don't trust the answer if it's 16 bits; the display
|
||||||
|
@ -522,6 +542,7 @@ int GetSurfacePixelFormat(void)
|
||||||
: RGBFB_NONE);
|
: RGBFB_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int graphics_init(bool mousecapture)
|
int graphics_init(bool mousecapture)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -530,6 +551,7 @@ int graphics_init(bool mousecapture)
|
||||||
|
|
||||||
graphics_subinit();
|
graphics_subinit();
|
||||||
|
|
||||||
|
|
||||||
if (!init_colors())
|
if (!init_colors())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -547,6 +569,7 @@ void graphics_leave(void)
|
||||||
SDL_VideoQuit();
|
SDL_VideoQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define systemRedShift (prSDLScreen->format->Rshift)
|
#define systemRedShift (prSDLScreen->format->Rshift)
|
||||||
#define systemGreenShift (prSDLScreen->format->Gshift)
|
#define systemGreenShift (prSDLScreen->format->Gshift)
|
||||||
#define systemBlueShift (prSDLScreen->format->Bshift)
|
#define systemBlueShift (prSDLScreen->format->Bshift)
|
||||||
|
@ -566,16 +589,14 @@ static int save_png(SDL_Surface* surface, char *path)
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
if (!png_ptr)
|
if (!png_ptr) {
|
||||||
{
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
png_infop info_ptr = png_create_info_struct(png_ptr);
|
png_infop info_ptr = png_create_info_struct(png_ptr);
|
||||||
|
|
||||||
if (!info_ptr)
|
if (!info_ptr) {
|
||||||
{
|
|
||||||
png_destroy_write_struct(&png_ptr, NULL);
|
png_destroy_write_struct(&png_ptr, NULL);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -626,6 +647,7 @@ 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;
|
||||||
|
@ -649,6 +671,7 @@ static void CreateScreenshot(void)
|
||||||
prSDLScreen->format->Amask);
|
prSDLScreen->format->Amask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int save_thumb(char *path)
|
static int save_thumb(char *path)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -661,6 +684,134 @@ static int save_thumb(char *path)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef PICASSO96
|
||||||
|
|
||||||
|
|
||||||
|
int picasso_palette(void)
|
||||||
|
{
|
||||||
|
int i, changed;
|
||||||
|
|
||||||
|
changed = 0;
|
||||||
|
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]) {
|
||||||
|
picasso_vidinfo.clut[i] = v;
|
||||||
|
changed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int resolution_compare(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
struct PicassoResolution *ma = (struct PicassoResolution *)a;
|
||||||
|
struct PicassoResolution *mb = (struct PicassoResolution *)b;
|
||||||
|
if (ma->res.width < mb->res.width)
|
||||||
|
return -1;
|
||||||
|
if (ma->res.width > mb->res.width)
|
||||||
|
return 1;
|
||||||
|
if (ma->res.height < mb->res.height)
|
||||||
|
return -1;
|
||||||
|
if (ma->res.height > mb->res.height)
|
||||||
|
return 1;
|
||||||
|
return ma->depth - mb->depth;
|
||||||
|
}
|
||||||
|
static void sortmodes(void)
|
||||||
|
{
|
||||||
|
int i = 0, idx = -1;
|
||||||
|
int pw = -1, ph = -1;
|
||||||
|
while (DisplayModes[i].depth >= 0)
|
||||||
|
i++;
|
||||||
|
qsort(DisplayModes, i, sizeof(struct PicassoResolution), resolution_compare);
|
||||||
|
for (i = 0; DisplayModes[i].depth >= 0; i++) {
|
||||||
|
if (DisplayModes[i].res.height != ph || DisplayModes[i].res.width != pw) {
|
||||||
|
ph = DisplayModes[i].res.height;
|
||||||
|
pw = DisplayModes[i].res.width;
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
DisplayModes[i].residx = idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void modesList(void)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (DisplayModes[i].depth >= 0) {
|
||||||
|
write_log("%d: %s (", i, DisplayModes[i].name);
|
||||||
|
j = 0;
|
||||||
|
while (DisplayModes[i].refresh[j] > 0) {
|
||||||
|
if (j > 0)
|
||||||
|
write_log(",");
|
||||||
|
write_log("%d", DisplayModes[i].refresh[j]);
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
write_log(")\n");
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void picasso_InitResolutions(void)
|
||||||
|
{
|
||||||
|
struct MultiDisplay *md1;
|
||||||
|
int i, count = 0;
|
||||||
|
char tmp[200];
|
||||||
|
int bit_idx;
|
||||||
|
int bits[] = { 8, 16, 32 };
|
||||||
|
|
||||||
|
Displays[0].primary = 1;
|
||||||
|
Displays[0].disabled = 0;
|
||||||
|
Displays[0].rect.left = 0;
|
||||||
|
Displays[0].rect.top = 0;
|
||||||
|
Displays[0].rect.right = 800;
|
||||||
|
Displays[0].rect.bottom = 640;
|
||||||
|
sprintf(tmp, "%s (%d*%d)", "Display", Displays[0].rect.right, Displays[0].rect.bottom);
|
||||||
|
Displays[0].name = my_strdup(tmp);
|
||||||
|
Displays[0].name2 = my_strdup("Display");
|
||||||
|
|
||||||
|
md1 = Displays;
|
||||||
|
DisplayModes = md1->DisplayModes = xmalloc(struct PicassoResolution, MAX_PICASSO_MODES);
|
||||||
|
for (i = 0; i < MAX_SCREEN_MODES && count < MAX_PICASSO_MODES; i++) {
|
||||||
|
for (bit_idx = 0; bit_idx < 3; ++bit_idx) {
|
||||||
|
int bitdepth = bits[bit_idx];
|
||||||
|
int bit_unit = (bitdepth + 1) & 0xF8;
|
||||||
|
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;
|
||||||
|
DisplayModes[count].refresh[0] = 50;
|
||||||
|
DisplayModes[count].refresh[1] = 60;
|
||||||
|
DisplayModes[count].refresh[2] = 0;
|
||||||
|
DisplayModes[count].colormodes = pixelFormat;
|
||||||
|
sprintf(DisplayModes[count].name,
|
||||||
|
"%dx%d, %d-bit",
|
||||||
|
DisplayModes[count].res.width,
|
||||||
|
DisplayModes[count].res.height,
|
||||||
|
DisplayModes[count].depth * 8);
|
||||||
|
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DisplayModes[count].depth = -1;
|
||||||
|
sortmodes();
|
||||||
|
modesList();
|
||||||
|
DisplayModes = Displays[0].DisplayModes;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
bool vsync_switchmode(int hz)
|
bool vsync_switchmode(int hz)
|
||||||
{
|
{
|
||||||
int changed_height = changed_prefs.gfx_size.height;
|
int changed_height = changed_prefs.gfx_size.height;
|
||||||
|
@ -673,51 +824,25 @@ bool vsync_switchmode(int hz)
|
||||||
if (hz == 50 && currVSyncRate == 60)
|
if (hz == 50 && currVSyncRate == 60)
|
||||||
{
|
{
|
||||||
// Switch from NTSC -> PAL
|
// Switch from NTSC -> PAL
|
||||||
switch (changed_height)
|
switch (changed_height) {
|
||||||
{
|
case 200: changed_height = 240; break;
|
||||||
case 200:
|
case 216: changed_height = 262; break;
|
||||||
changed_height = 240;
|
case 240: changed_height = 270; break;
|
||||||
break;
|
case 256: changed_height = 270; break;
|
||||||
case 216:
|
case 262: changed_height = 270; break;
|
||||||
changed_height = 262;
|
case 270: changed_height = 270; break;
|
||||||
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)
|
else if (hz == 60 && currVSyncRate == 50)
|
||||||
{
|
{
|
||||||
// Switch from PAL -> NTSC
|
// Switch from PAL -> NTSC
|
||||||
switch (changed_height)
|
switch (changed_height) {
|
||||||
{
|
case 200: changed_height = 200; break;
|
||||||
case 200:
|
case 216: changed_height = 200; break;
|
||||||
changed_height = 200;
|
case 240: changed_height = 200; break;
|
||||||
break;
|
case 256: changed_height = 216; break;
|
||||||
case 216:
|
case 262: changed_height = 216; break;
|
||||||
changed_height = 200;
|
case 270: changed_height = 240; break;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,135 +877,6 @@ bool target_graphics_buffer_update(void)
|
||||||
|
|
||||||
#ifdef PICASSO96
|
#ifdef PICASSO96
|
||||||
|
|
||||||
int picasso_palette(void)
|
|
||||||
{
|
|
||||||
int i, changed;
|
|
||||||
|
|
||||||
changed = 0;
|
|
||||||
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])
|
|
||||||
{
|
|
||||||
picasso_vidinfo.clut[i] = v;
|
|
||||||
changed = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return changed;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int resolution_compare(const void *a, const void *b)
|
|
||||||
{
|
|
||||||
struct PicassoResolution *ma = (struct PicassoResolution *)a;
|
|
||||||
struct PicassoResolution *mb = (struct PicassoResolution *)b;
|
|
||||||
if (ma->res.width < mb->res.width)
|
|
||||||
return -1;
|
|
||||||
if (ma->res.width > mb->res.width)
|
|
||||||
return 1;
|
|
||||||
if (ma->res.height < mb->res.height)
|
|
||||||
return -1;
|
|
||||||
if (ma->res.height > mb->res.height)
|
|
||||||
return 1;
|
|
||||||
return ma->depth - mb->depth;
|
|
||||||
}
|
|
||||||
static void sortmodes(void)
|
|
||||||
{
|
|
||||||
int i = 0, idx = -1;
|
|
||||||
int pw = -1, ph = -1;
|
|
||||||
while (DisplayModes[i].depth >= 0)
|
|
||||||
i++;
|
|
||||||
qsort(DisplayModes, i, sizeof(struct PicassoResolution), resolution_compare);
|
|
||||||
for (i = 0; DisplayModes[i].depth >= 0; i++)
|
|
||||||
{
|
|
||||||
if (DisplayModes[i].res.height != ph || DisplayModes[i].res.width != pw)
|
|
||||||
{
|
|
||||||
ph = DisplayModes[i].res.height;
|
|
||||||
pw = DisplayModes[i].res.width;
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
DisplayModes[i].residx = idx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void modesList(void)
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
while (DisplayModes[i].depth >= 0)
|
|
||||||
{
|
|
||||||
write_log("%d: %s (", i, DisplayModes[i].name);
|
|
||||||
j = 0;
|
|
||||||
while (DisplayModes[i].refresh[j] > 0)
|
|
||||||
{
|
|
||||||
if (j > 0)
|
|
||||||
write_log(",");
|
|
||||||
write_log("%d", DisplayModes[i].refresh[j]);
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
write_log(")\n");
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void picasso_InitResolutions(void)
|
|
||||||
{
|
|
||||||
struct MultiDisplay *md1;
|
|
||||||
int i, count = 0;
|
|
||||||
char tmp[200];
|
|
||||||
int bit_idx;
|
|
||||||
int bits[] = { 8, 16, 32 };
|
|
||||||
|
|
||||||
Displays[0].primary = 1;
|
|
||||||
Displays[0].disabled = 0;
|
|
||||||
Displays[0].rect.left = 0;
|
|
||||||
Displays[0].rect.top = 0;
|
|
||||||
Displays[0].rect.right = 800;
|
|
||||||
Displays[0].rect.bottom = 640;
|
|
||||||
sprintf(tmp, "%s (%d*%d)", "Display", Displays[0].rect.right, Displays[0].rect.bottom);
|
|
||||||
Displays[0].name = my_strdup(tmp);
|
|
||||||
Displays[0].name2 = my_strdup("Display");
|
|
||||||
|
|
||||||
md1 = Displays;
|
|
||||||
DisplayModes = md1->DisplayModes = xmalloc(struct PicassoResolution, MAX_PICASSO_MODES);
|
|
||||||
for (i = 0; i < MAX_SCREEN_MODES && count < MAX_PICASSO_MODES; i++)
|
|
||||||
{
|
|
||||||
for (bit_idx = 0; bit_idx < 3; ++bit_idx)
|
|
||||||
{
|
|
||||||
int bitdepth = bits[bit_idx];
|
|
||||||
int bit_unit = (bitdepth + 1) & 0xF8;
|
|
||||||
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;
|
|
||||||
DisplayModes[count].refresh[0] = 50;
|
|
||||||
DisplayModes[count].refresh[1] = 60;
|
|
||||||
DisplayModes[count].refresh[2] = 0;
|
|
||||||
DisplayModes[count].colormodes = pixelFormat;
|
|
||||||
sprintf(DisplayModes[count].name,
|
|
||||||
"%dx%d, %d-bit",
|
|
||||||
DisplayModes[count].res.width,
|
|
||||||
DisplayModes[count].res.height,
|
|
||||||
DisplayModes[count].depth * 8);
|
|
||||||
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DisplayModes[count].depth = -1;
|
|
||||||
sortmodes();
|
|
||||||
modesList();
|
|
||||||
DisplayModes = Displays[0].DisplayModes;
|
|
||||||
}
|
|
||||||
|
|
||||||
void gfx_set_picasso_state(int on)
|
void gfx_set_picasso_state(int on)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue