This commit is contained in:
Seth Polsley 2020-09-01 20:09:56 -05:00
commit 07880c76ed
13 changed files with 183 additions and 23 deletions

View File

@ -1108,6 +1108,7 @@
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = (
"-Wl,-no_pie",
"-pagezero_size",
0x1000,
);
@ -1168,6 +1169,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.7;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = (
"-Wl,-no_pie",
"-pagezero_size",
0x1000,
);

View File

@ -1,7 +1,7 @@
SRC = $(PROJECT_DIR)/../uae_cpu
DST = $(BUILT_PRODUCTS_DIR)/gencpu_output
VPATH = $(SRC) $(SRC)/compiler
CFLAGS = -DUSE_XCODE=1 -I. -I../uae_cpu -I../UNIX
CFLAGS = -DUSE_JIT_FPU -I. -I../uae_cpu -I../UNIX
CXXFLAGS = -stdlib=libc++ $(CFLAGS)
all: $(DST)/gencpu $(DST)/gencomp

View File

@ -155,6 +155,11 @@ static SDL_mutex *frame_buffer_lock = NULL;
#define LOCK_FRAME_BUFFER SDL_LockMutex(frame_buffer_lock)
#define UNLOCK_FRAME_BUFFER SDL_UnlockMutex(frame_buffer_lock)
// Previously set gamma tables
static uint16 last_gamma_red[256];
static uint16 last_gamma_green[256];
static uint16 last_gamma_blue[256];
// Video refresh function
static void VideoRefreshInit(void);
static void (*video_refresh)(void);
@ -1363,9 +1368,51 @@ void SDL_monitor_desc::set_palette(uint8 *pal, int num_in)
{
const VIDEO_MODE &mode = get_current_mode();
// FIXME: how can we handle the gamma ramp?
if ((int)VIDEO_MODE_DEPTH > VIDEO_DEPTH_8BIT)
if ((int)VIDEO_MODE_DEPTH > VIDEO_DEPTH_8BIT) {
// handle the gamma ramp
if (pal[0] == 127 && pal[num_in*3-1] == 127) // solid grey
return; // ignore
uint16 red[256];
uint16 green[256];
uint16 blue[256];
int repeats = 256 / num_in;
for (int i = 0; i < num_in; i++) {
for (int j = 0; j < repeats; j++) {
red[i*repeats + j] = pal[i*3 + 0] << 8;
green[i*repeats + j] = pal[i*3 + 1] << 8;
blue[i*repeats + j] = pal[i*3 + 2] << 8;
}
}
// fill remaining entries (if any) with last value
for (int i = num_in * repeats; i < 256; i++) {
red[i] = pal[(num_in - 1) * 3] << 8;
green[i] = pal[(num_in - 1) * 3 + 1] << 8;
blue[i] = pal[(num_in - 1) * 3 + 2] << 8;
}
bool changed = (memcmp(red, last_gamma_red, 512) != 0 ||
memcmp(green, last_gamma_green, 512) != 0 ||
memcmp(blue, last_gamma_blue, 512) != 0);
if (changed) {
int result = SDL_SetGammaRamp(red, green, blue);
if (result < 0) {
fprintf(stderr, "SDL_SetGammaRamp returned %d, SDL error: %s\n", result, SDL_GetError());
}
memcpy(last_gamma_red, red, 512);
memcpy(last_gamma_green, green, 512);
memcpy(last_gamma_blue, blue, 512);
}
return;
}
LOCK_PALETTE;

View File

@ -168,6 +168,11 @@ static SDL_mutex *frame_buffer_lock = NULL;
#define LOCK_FRAME_BUFFER SDL_LockMutex(frame_buffer_lock)
#define UNLOCK_FRAME_BUFFER SDL_UnlockMutex(frame_buffer_lock)
// Previously set gamma tables
static uint16 last_gamma_red[256];
static uint16 last_gamma_green[256];
static uint16 last_gamma_blue[256];
// Video refresh function
static void VideoRefreshInit(void);
static void (*video_refresh)(void);
@ -700,6 +705,12 @@ static void shutdown_sdl_video()
delete_sdl_video_window();
}
static int get_mag_rate()
{
int m = PrefsFindInt32("mag_rate");
return m < 1 ? 1 : m > 4 ? 4 : m;
}
static SDL_Surface * init_sdl_video(int width, int height, int bpp, Uint32 flags)
{
if (guest_surface) {
@ -746,12 +757,13 @@ static SDL_Surface * init_sdl_video(int width, int height, int bpp, Uint32 flags
window_flags |= SDL_WINDOW_RESIZABLE;
*/
if (!sdl_window) {
int m = get_mag_rate();
sdl_window = SDL_CreateWindow(
"Basilisk II",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
window_width,
window_height,
m * window_width,
m * window_height,
window_flags);
if (!sdl_window) {
shutdown_sdl_video();
@ -1039,7 +1051,7 @@ void driver_base::init()
// set default B/W palette
sdl_palette = SDL_AllocPalette(256);
sdl_palette->colors[1] = (SDL_Color){ .r = 0, .g = 0, .b = 0 };
sdl_palette->colors[1] = (SDL_Color){ .r = 0, .g = 0, .b = 0, .a = 255 };
SDL_SetSurfacePalette(s, sdl_palette);
}
@ -1621,7 +1633,8 @@ static void do_toggle_fullscreen(void)
display_type = DISPLAY_WINDOW;
SDL_SetWindowFullscreen(sdl_window, 0);
const VIDEO_MODE &mode = drv->mode;
SDL_SetWindowSize(sdl_window, VIDEO_MODE_X, VIDEO_MODE_Y);
int m = get_mag_rate();
SDL_SetWindowSize(sdl_window, m * VIDEO_MODE_X, m * VIDEO_MODE_Y);
SDL_SetWindowGrab(sdl_window, SDL_FALSE);
} else {
display_type = DISPLAY_SCREEN;
@ -1751,9 +1764,51 @@ void SDL_monitor_desc::set_palette(uint8 *pal, int num_in)
{
const VIDEO_MODE &mode = get_current_mode();
// FIXME: how can we handle the gamma ramp?
if ((int)VIDEO_MODE_DEPTH > VIDEO_DEPTH_8BIT)
if ((int)VIDEO_MODE_DEPTH > VIDEO_DEPTH_8BIT) {
// handle the gamma ramp
if (pal[0] == 127 && pal[num_in*3-1] == 127) // solid grey
return; // ignore
uint16 red[256];
uint16 green[256];
uint16 blue[256];
int repeats = 256 / num_in;
for (int i = 0; i < num_in; i++) {
for (int j = 0; j < repeats; j++) {
red[i*repeats + j] = pal[i*3 + 0] << 8;
green[i*repeats + j] = pal[i*3 + 1] << 8;
blue[i*repeats + j] = pal[i*3 + 2] << 8;
}
}
// fill remaining entries (if any) with last value
for (int i = num_in * repeats; i < 256; i++) {
red[i] = pal[(num_in - 1) * 3] << 8;
green[i] = pal[(num_in - 1) * 3 + 1] << 8;
blue[i] = pal[(num_in - 1) * 3 + 2] << 8;
}
bool changed = (memcmp(red, last_gamma_red, 512) != 0 ||
memcmp(green, last_gamma_green, 512) != 0 ||
memcmp(blue, last_gamma_blue, 512) != 0);
if (changed && sdl_window) {
int result = SDL_SetWindowGammaRamp(sdl_window, red, green, blue);
if (result < 0) {
fprintf(stderr, "SDL_SetWindowGammaRamp returned %d, SDL error: %s\n", result, SDL_GetError());
}
memcpy(last_gamma_red, red, 512);
memcpy(last_gamma_green, green, 512);
memcpy(last_gamma_blue, blue, 512);
}
return;
}
LOCK_PALETTE;

View File

@ -39,7 +39,7 @@ AC_ARG_ENABLE(sdl-framework-prefix, [ --enable-sdl-framework-prefix=PFX d
AC_ARG_WITH(sdl1, [ --with-sdl1 use SDL 1.x, rather than SDL 2.x [default=no]], [WANT_SDL_VERSION_MAJOR=1], [])
dnl JIT compiler options.
AC_ARG_ENABLE(jit-compiler, [ --enable-jit-compiler enable JIT compiler [default=no]], [WANT_JIT=$enableval], [WANT_JIT=no])
AC_ARG_ENABLE(jit-compiler, [ --enable-jit-compiler enable JIT compiler [default=yes]], [WANT_JIT=$enableval], [WANT_JIT=yes])
AC_ARG_ENABLE(jit-debug, [ --enable-jit-debug activate native code disassemblers [default=no]], [WANT_JIT_DEBUG=$enableval], [WANT_JIT_DEBUG=no])
dnl FPU emulation core.
@ -612,7 +612,6 @@ mips-sony-bsd|mips-sony-newsos4)
;;
*-*-darwin*)
no_dev_ptmx=1
LIBS="$LIBS -lstdc++"
;;
*-*-freebsd*)
no_dev_ptmx=1
@ -1466,6 +1465,11 @@ if [[ "x$WANT_JIT" = "xyes" -a "x$ADDRESSING_MODE" = "xmemory banks" ]]; then
AC_MSG_ERROR([Sorry, the JIT Compiler requires Direct Addressing, at least])
fi
if [[ "x$OS_TYPE" = "xdarwin" ]]; then
WANT_VOSF=no
LDFLAGS="$LDFLAGS -Wl,-no_pie -pagezero_size 0x1000"
fi
dnl Enable VOSF screen updates with this feature is requested and feasible
if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])

View File

@ -280,10 +280,13 @@ if [[ "x$HAVE_GCC30" = "xyes" ]]; then
AC_CACHE_CHECK([whether the compiler supports -fno-strict-aliasing],
ac_cv_gcc_no_strict_aliasing, [
AC_TRY_COMPILE([],[],
[ac_cv_gcc_no_strict_aliasing=yes; AC_SUBST(SLIRP_CFLAGS, "-fno-strict-aliasing")],
[ac_cv_gcc_no_strict_aliasing=yes],
[ac_cv_gcc_no_strict_aliasing=no])
])
CFLAGS="$SAVED_CFLAGS"
if test "x$ac_cv_gcc_no_strict_aliasing" = xyes; then
AC_SUBST(SLIRP_CFLAGS, "-fno-strict-aliasing")
fi
fi
dnl Select appropriate CPU source and REGPARAM define.
@ -540,7 +543,8 @@ CPUINCLUDES="-I../uae_cpu"
CPUSRCS="../uae_cpu/basilisk_glue.cpp ../uae_cpu/memory.cpp ../uae_cpu/newcpu.cpp ../uae_cpu/readcpu.cpp $FPUSRCS cpustbl.cpp cpudefs.cpp $CPUSRCS $JITSRCS"
dnl We really want SDL for now
AC_CHECK_TOOL(sdl_config, sdl2-config, [AC_MSG_ERROR([Sorry, you currently need SDL for this port])])
AC_CHECK_TOOL(sdl_config, sdl2-config, no)
AS_IF([test "x$sdl_config" = xno], [AC_MSG_ERROR([Sorry, you currently need SDL for this port])])
SDL_CFLAGS=`$sdl_config --cflags`
AC_SUBST(SDL_CFLAGS)
#if [[ "x$WANT_SDL_STATIC" = "xyes" ]]; then

View File

@ -77,6 +77,7 @@ prefs_desc common_prefs_items[] = {
{"scale_integer",TYPE_BOOLEAN,false,"integer scaling"},
{"yearofs", TYPE_INT32, 0, "year offset"},
{"dayofs", TYPE_INT32, 0, "day offset"},
{"mag_rate", TYPE_INT32, 0, "rate of magnification"},
{NULL, TYPE_END, false, NULL} // End of list
};

View File

@ -1,6 +1,6 @@
#### BasiliskII
```
macOS 64-bit ---
macOS 64-bit JIT
Linux 32-bit JIT
MinGW 32-bit JIT
```

View File

@ -37,9 +37,6 @@ prefs_desc platform_prefs_items[] = {
{"mousewheellines", TYPE_INT32, false, "number of lines to scroll in mouse wheel mode 1"},
{"dsp", TYPE_STRING, false, "audio output (dsp) device name"},
{"mixer", TYPE_STRING, false, "audio mixer device name"},
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
{"ignoresegv", TYPE_BOOLEAN, false, "ignore illegal memory accesses"},
#endif
{"idlewait", TYPE_BOOLEAN, false, "sleep when idle"},
#ifdef USE_SDL_VIDEO
{"sdlrender", TYPE_STRING, false, "SDL_Renderer driver (\"auto\", \"software\" (may be faster), etc.)"},
@ -135,9 +132,6 @@ void AddPlatformPrefsDefaults(void)
#else
PrefsReplaceString("dsp", "/dev/dsp");
PrefsReplaceString("mixer", "/dev/mixer");
#endif
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
PrefsAddBool("ignoresegv", false);
#endif
PrefsAddBool("idlewait", true);
}

View File

@ -189,10 +189,13 @@ if [[ "x$HAVE_GCC30" = "xyes" ]]; then
AC_CACHE_CHECK([whether the compiler supports -fno-strict-aliasing],
ac_cv_gcc_no_strict_aliasing, [
AC_TRY_COMPILE([],[],
[ac_cv_gcc_no_strict_aliasing=yes; AC_SUBST(SLIRP_CFLAGS, "-fno-strict-aliasing")],
[ac_cv_gcc_no_strict_aliasing=yes],
[ac_cv_gcc_no_strict_aliasing=no])
])
CFLAGS="$SAVED_CFLAGS"
if test "x$ac_cv_gcc_no_strict_aliasing" = xyes; then
AC_SUBST(SLIRP_CFLAGS, "-fno-strict-aliasing")
fi
fi
case $host_os in
@ -272,7 +275,8 @@ dnl Use the dummy prefs file.
CPUSRCS="$CPUSRCS ../dummy/prefs_dummy.cpp"
dnl We really want SDL for now
AC_CHECK_TOOL(sdl_config, sdl2-config, [AC_MSG_ERROR([Sorry, you currently need SDL for this port])])
AC_CHECK_TOOL(sdl_config, sdl2-config, no)
AS_IF([test "x$sdl_config" = xno], [AC_MSG_ERROR([Sorry, you currently need SDL for this port])])
SDL_CFLAGS=`$sdl_config --cflags`
AC_SUBST(SDL_CFLAGS)
SDL_LIBS=`$sdl_config --static-libs`

View File

@ -765,6 +765,10 @@ static void dump_disassembly(const uint32 pc, const int prefix_count, const int
}
}
static bool isSegvBinCue(uint32 a) {
return a == 0x389e00 || a == 0x389e08 || a == 0x389fe0 || a == 0x489e00 || a == 0x489e08 || a == 0x489fe0;
}
sigsegv_return_t sigsegv_handler(sigsegv_info_t *sip)
{
#if ENABLE_VOSF
@ -816,6 +820,9 @@ sigsegv_return_t sigsegv_handler(sigsegv_info_t *sip)
else if ((uint32)(addr - SheepMem::ZeroPage()) < (uint32)SheepMem::PageSize())
return SIGSEGV_RETURN_SKIP_INSTRUCTION;
else if (ROMType == ROMTYPE_NEWWORLD && isSegvBinCue(pc - ROMBase))
return SIGSEGV_RETURN_SKIP_INSTRUCTION;
// Ignore all other faults, if requested
if (PrefsFindBool("ignoresegv"))
return SIGSEGV_RETURN_SKIP_INSTRUCTION;

View File

@ -65,6 +65,7 @@ prefs_desc common_prefs_items[] = {
{"cpuclock", TYPE_INT32, 0, "CPU clock [MHz] of system info"},
{"yearofs", TYPE_INT32, 0, "year offset"},
{"dayofs", TYPE_INT32, 0, "day offset"},
{"mag_rate", TYPE_INT32, 0, "rate of magnification"},
{NULL, TYPE_END, false, NULL} // End of list
};

View File

@ -211,6 +211,10 @@ static bool allocate_gamma_table(VidLocals *csSave, uint32 size)
return true;
}
static inline uint8 max(uint8 a, uint8 b) {
return a > b? a : b;
}
static int16 set_gamma(VidLocals *csSave, uint32 gamma)
{
if (gamma == 0) { // Build linear ramp, 256 entries
@ -229,8 +233,11 @@ static int16 set_gamma(VidLocals *csSave, uint32 gamma)
// Build the linear ramp
uint32 p = csSave->gammaTable + gFormulaData;
for (int i=0; i<256; i++)
for (int i=0; i<256; i++) {
WriteMacInt8(p + i, i);
mac_pal[i].red = mac_pal[i].green = mac_pal[i].blue = i;
}
} else { // User-supplied gamma table
@ -256,7 +263,41 @@ static int16 set_gamma(VidLocals *csSave, uint32 gamma)
// Copy table
Mac2Mac_memcpy(csSave->gammaTable, gamma, size);
// Save new gamma data for video impl
if (data_width != 8) {
// FIXME: handle bit-packed data
} else {
uint32 p = csSave->gammaTable + gFormulaData + gFormulaSize;
uint32 p_red;
uint32 p_green;
uint32 p_blue;
// make values increasing as some implementations really don't like it when gamma tables aren't
uint8 max_red = 0;
uint8 max_green = 0;
uint8 max_blue = 0;
if (chan_cnt == 3) {
p_red = p;
p_green = p + data_cnt;
p_blue = p + data_cnt * 2;
} else {
p_red = p_green = p_blue = p;
}
for (int i=0; i < data_cnt; i++) {
max_red = max(max_red, ReadMacInt8(p_red++));
max_green = max(max_green, ReadMacInt8(p_green++));
max_blue = max(max_blue, ReadMacInt8(p_blue++));
mac_pal[i].red = max_red;
mac_pal[i].green = max_green;
mac_pal[i].blue = max_blue;
}
}
}
video_set_palette();
return noErr;
}