From 2ad0536d1352df4e27747214008468a3ad4d5bcd Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sat, 25 Apr 2015 09:40:59 +0200 Subject: [PATCH 01/10] Add Haiku support. * Haiku is mostly compatible with BeOS, but there are a few minor changes. --- BasiliskII/src/BeOS/Makefile | 4 ++-- BasiliskII/src/BeOS/ether_beos.cpp | 5 +++++ BasiliskII/src/BeOS/prefs_editor_beos.cpp | 20 +++++++++----------- BasiliskII/src/BeOS/scsi_beos.cpp | 4 ++++ BasiliskII/src/BeOS/sys_beos.cpp | 10 ++++++++++ BasiliskII/src/BeOS/sysdeps.h | 2 ++ 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/BasiliskII/src/BeOS/Makefile b/BasiliskII/src/BeOS/Makefile index 14ae78ac..90793344 100644 --- a/BasiliskII/src/BeOS/Makefile +++ b/BasiliskII/src/BeOS/Makefile @@ -33,7 +33,7 @@ TYPE= APP MACHINE=$(shell uname -m) ifeq ($(MACHINE), BePC) CPUSRCS = ../uae_cpu/basilisk_glue.cpp ../uae_cpu/memory.cpp ../uae_cpu/newcpu.cpp \ - ../uae_cpu/readcpu.cpp ../uae_cpu/fpu/fpu_x86.cpp cpustbl.cpp cpudefs.cpp cpufast.s + ../uae_cpu/readcpu.cpp ../uae_cpu/fpu/fpu_uae.cpp cpustbl.cpp cpudefs.cpp cpufast.s else # CPUSRCS = ../powerrom_cpu/powerrom_cpu.cpp CPUSRCS = ../uae_cpu/basilisk_glue.cpp ../uae_cpu/newcpu.cpp \ @@ -123,7 +123,7 @@ LINKER_FLAGS = ## include the makefile-engine -include /boot/develop/etc/makefile-engine +include /boot/system/develop/etc/makefile-engine # special handling of UAE CPU engine diff --git a/BasiliskII/src/BeOS/ether_beos.cpp b/BasiliskII/src/BeOS/ether_beos.cpp index 42db87f6..ebc85daa 100644 --- a/BasiliskII/src/BeOS/ether_beos.cpp +++ b/BasiliskII/src/BeOS/ether_beos.cpp @@ -31,6 +31,11 @@ #include #include +#ifdef __HAIKU__ +#include +#include +#endif + #include "cpu_emulation.h" #include "main.h" #include "prefs.h" diff --git a/BasiliskII/src/BeOS/prefs_editor_beos.cpp b/BasiliskII/src/BeOS/prefs_editor_beos.cpp index 53affcfa..a40e4748 100644 --- a/BasiliskII/src/BeOS/prefs_editor_beos.cpp +++ b/BasiliskII/src/BeOS/prefs_editor_beos.cpp @@ -625,17 +625,15 @@ void PrefsWindow::add_serial_names(BPopUpMenu *menu, uint32 msg) port->GetDeviceName(i, name); menu->AddItem(new BMenuItem(name, new BMessage(msg))); } - if (sys_info.platform_type == B_BEBOX_PLATFORM) { - BDirectory dir; - BEntry entry; - dir.SetTo("/dev/parallel"); - if (dir.InitCheck() == B_NO_ERROR) { - dir.Rewind(); - while (dir.GetNextEntry(&entry) >= 0) { - if (!entry.IsDirectory()) { - entry.GetName(name); - menu->AddItem(new BMenuItem(name, new BMessage(msg))); - } + BDirectory dir; + BEntry entry; + dir.SetTo("/dev/parallel"); + if (dir.InitCheck() == B_NO_ERROR) { + dir.Rewind(); + while (dir.GetNextEntry(&entry) >= 0) { + if (!entry.IsDirectory()) { + entry.GetName(name); + menu->AddItem(new BMenuItem(name, new BMessage(msg))); } } } diff --git a/BasiliskII/src/BeOS/scsi_beos.cpp b/BasiliskII/src/BeOS/scsi_beos.cpp index 42f44983..75d1e29a 100644 --- a/BasiliskII/src/BeOS/scsi_beos.cpp +++ b/BasiliskII/src/BeOS/scsi_beos.cpp @@ -23,7 +23,11 @@ #include #include #include +#ifdef __HAIKU__ +#include +#else #include +#endif #include "sysdeps.h" #include "main.h" diff --git a/BasiliskII/src/BeOS/sys_beos.cpp b/BasiliskII/src/BeOS/sys_beos.cpp index 7ad5e640..ff6fcb83 100644 --- a/BasiliskII/src/BeOS/sys_beos.cpp +++ b/BasiliskII/src/BeOS/sys_beos.cpp @@ -40,6 +40,11 @@ #define DEBUG 0 #include "debug.h" +#ifdef __HAIKU__ +#include +#define unmount(x) fs_unmount_volume(x, 0) +#endif + // File handles are pointers to these structures struct file_handle { @@ -284,6 +289,10 @@ void SysAddCDROMPrefs(void) void SysAddSerialPrefs(void) { +#ifdef __HAIKU__ + PrefsAddString("seriala", "serial1"); + PrefsAddString("serialb", "serial2"); +#else system_info info; get_system_info(&info); switch (info.platform_type) { @@ -301,6 +310,7 @@ void SysAddSerialPrefs(void) PrefsAddString("serialb", "none"); break; } +#endif } diff --git a/BasiliskII/src/BeOS/sysdeps.h b/BasiliskII/src/BeOS/sysdeps.h index 8280336b..abeadbd3 100644 --- a/BasiliskII/src/BeOS/sysdeps.h +++ b/BasiliskII/src/BeOS/sysdeps.h @@ -63,7 +63,9 @@ typedef off_t loff_t; // Networking types #define PF_INET AF_INET +#ifndef __HAIKU__ typedef int socklen_t; +#endif // UAE CPU data types #define uae_s8 int8 From 2adcbc2694d71f645d502598f5f5683cb025f802 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sat, 25 Apr 2015 10:13:36 +0200 Subject: [PATCH 02/10] Haiku: Set -fomit-frame-pointer and -fno-PIC * This frees some registers and make the x86 assembler code work. * Restore use of fpu_x86 because of this. --- BasiliskII/src/BeOS/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BasiliskII/src/BeOS/Makefile b/BasiliskII/src/BeOS/Makefile index 90793344..16cae87f 100644 --- a/BasiliskII/src/BeOS/Makefile +++ b/BasiliskII/src/BeOS/Makefile @@ -33,7 +33,7 @@ TYPE= APP MACHINE=$(shell uname -m) ifeq ($(MACHINE), BePC) CPUSRCS = ../uae_cpu/basilisk_glue.cpp ../uae_cpu/memory.cpp ../uae_cpu/newcpu.cpp \ - ../uae_cpu/readcpu.cpp ../uae_cpu/fpu/fpu_uae.cpp cpustbl.cpp cpudefs.cpp cpufast.s + ../uae_cpu/readcpu.cpp ../uae_cpu/fpu/fpu_x86.cpp cpustbl.cpp cpudefs.cpp cpufast.s else # CPUSRCS = ../powerrom_cpu/powerrom_cpu.cpp CPUSRCS = ../uae_cpu/basilisk_glue.cpp ../uae_cpu/newcpu.cpp \ @@ -116,7 +116,7 @@ SYMBOLS = DEBUGGER = # specify additional compiler flags for all files -COMPILER_FLAGS = +COMPILER_FLAGS = -fomit-frame-pointer -fno-PIC # specify additional linker flags LINKER_FLAGS = From 66f68a995ae4c69132f8237bc4864a60553b60dd Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 26 Apr 2015 10:37:51 +0200 Subject: [PATCH 03/10] BeOS: WIP update to video mode switching support code. --- BasiliskII/src/BeOS/user_strings_beos.cpp | 1 + BasiliskII/src/BeOS/user_strings_beos.h | 3 +- BasiliskII/src/BeOS/video_beos.cpp | 243 ++++++++++++++++------ 3 files changed, 177 insertions(+), 70 deletions(-) diff --git a/BasiliskII/src/BeOS/user_strings_beos.cpp b/BasiliskII/src/BeOS/user_strings_beos.cpp index 138b0d7e..c3694578 100644 --- a/BasiliskII/src/BeOS/user_strings_beos.cpp +++ b/BasiliskII/src/BeOS/user_strings_beos.cpp @@ -38,6 +38,7 @@ user_string_def platform_strings[] = { {STR_NET_CONFIG_MODIFY_WARN, "To enable Ethernet networking for Basilisk II, your network configuration has to be modified and the network restarted. Do you want this to be done now (selecting \"Cancel\" will disable Ethernet under Basilisk II)?."}, {STR_NET_ADDON_INIT_FAILED, "SheepShaver net server add-on found\nbut there seems to be no network hardware.\nPlease check your network preferences."}, {STR_NET_ADDON_CLONE_FAILED, "Cloning of the network transfer area failed."}, + {STR_VIDEO_FAILED, "Failed to set video mode."}, {-1, NULL} // End marker }; diff --git a/BasiliskII/src/BeOS/user_strings_beos.h b/BasiliskII/src/BeOS/user_strings_beos.h index 87902dea..8de695e9 100644 --- a/BasiliskII/src/BeOS/user_strings_beos.h +++ b/BasiliskII/src/BeOS/user_strings_beos.h @@ -28,7 +28,8 @@ enum { STR_NO_NET_ADDON_WARN, STR_NET_CONFIG_MODIFY_WARN, STR_NET_ADDON_INIT_FAILED, - STR_NET_ADDON_CLONE_FAILED + STR_NET_ADDON_CLONE_FAILED, + STR_VIDEO_FAILED }; #endif diff --git a/BasiliskII/src/BeOS/video_beos.cpp b/BasiliskII/src/BeOS/video_beos.cpp index 1bb1d10d..5e73b9d9 100644 --- a/BasiliskII/src/BeOS/video_beos.cpp +++ b/BasiliskII/src/BeOS/video_beos.cpp @@ -70,6 +70,27 @@ enum { extern void SysCreateVolumeMenu(BMenu *menu, uint32 msg); extern void SysMountVolume(const char *name); +// Global variables +static bool classic_mode = false; // Flag: Classic Mac video mode +static int scr_mode_bit = 0; +static vector VideoModes; // Supported video modes + + /* + * monitor_desc subclass for BeOS display + */ + +class BeOS_monitor_desc : public monitor_desc { +public: + BeOS_monitor_desc(const vector &available_modes, video_depth default_depth, uint32 default_id) : monitor_desc(available_modes, default_depth, default_id) {} + ~BeOS_monitor_desc() {} + + virtual void switch_to_current_mode(void); + virtual void set_palette(uint8 *pal, int num); + + bool video_open(void); + void video_close(void); +}; + /* * A simple view class for blitting a bitmap on the screen @@ -98,7 +119,7 @@ private: class MacWindow : public BDirectWindow { public: - MacWindow(BRect frame); + MacWindow(BRect frame, const BeOS_monitor_desc& monitor); virtual ~MacWindow(); virtual void MessageReceived(BMessage *msg); virtual void DirectConnected(direct_buffer_info *info); @@ -127,6 +148,8 @@ private: int32 bytes_per_row; color_space pixel_format; bool unclipped; + + BeOS_monitor_desc monitor; }; @@ -136,7 +159,7 @@ private: class MacScreen : public BWindowScreen { public: - MacScreen(const char *name, int mode_bit, status_t *error); + MacScreen(const BeOS_monitor_desc& monitor, const char *name, int mode_bit, status_t *error); virtual ~MacScreen(); virtual void Quit(void); virtual void ScreenConnected(bool active); @@ -155,6 +178,8 @@ private: bool quitting; // Flag for ScreenConnected: We are quitting, don't pause emulator thread bool screen_active; bool first_time; + + BeOS_monitor_desc monitor; }; @@ -170,74 +195,144 @@ static uint8 MacCursor[68] = {16, 1}; // Mac cursor image * Initialization */ -// Add resolution to list of supported modes and set VideoMonitor -static void set_video_monitor(uint32 width, uint32 height, uint32 bytes_per_row, int depth) +// Add mode to list of supported modes +static void add_mode(uint32 width, uint32 height, uint32 resolution_id, uint32 bytes_per_row, video_depth depth) { video_mode mode; - mode.x = width; mode.y = height; - mode.resolution_id = 0x80; + mode.resolution_id = resolution_id; mode.bytes_per_row = bytes_per_row; - - switch (depth) { - case 1: - mode.depth = VDEPTH_1BIT; - break; - case 2: - mode.depth = VDEPTH_2BIT; - break; - case 4: - mode.depth = VDEPTH_4BIT; - break; - case 8: - mode.depth = VDEPTH_8BIT; - break; - case 15: - mode.depth = VDEPTH_16BIT; - break; - case 16: - mode.depth = VDEPTH_16BIT; - break; - case 24: - case 32: - mode.depth = VDEPTH_32BIT; - break; - } - + mode.depth = depth; VideoModes.push_back(mode); - video_init_depth_list(); - VideoMonitor.mode = mode; } +// Add standard list of windowed modes for given color depth +static void add_window_modes(video_depth depth) +{ + add_mode(512, 384, 0x80, TrivialBytesPerRow(512, depth), depth); + add_mode(640, 480, 0x81, TrivialBytesPerRow(640, depth), depth); + add_mode(800, 600, 0x82, TrivialBytesPerRow(800, depth), depth); + add_mode(1024, 768, 0x83, TrivialBytesPerRow(1024, depth), depth); + add_mode(1152, 870, 0x84, TrivialBytesPerRow(1152, depth), depth); + add_mode(1280, 1024, 0x85, TrivialBytesPerRow(1280, depth), depth); + add_mode(1600, 1200, 0x86, TrivialBytesPerRow(1600, depth), depth); +} + + bool VideoInit(bool classic) { - // Create semaphore - mac_os_lock = create_sem(0, "MacOS Frame Buffer Lock"); + classic_mode = classic; // Get screen mode from preferences - const char *mode_str = PrefsFindString("screen"); + const char *mode_str; + if (classic_mode) + mode_str = "win/512/342"; + else + mode_str = PrefsFindString("screen"); // Determine type and mode + int default_width = 512, default_height = 384; display_type = DISPLAY_WINDOW; - int width = 512, height = 384; - int scr_mode_bit = 0; if (mode_str) { - if (sscanf(mode_str, "win/%d/%d", &width, &height) == 2) + if (sscanf(mode_str, "win/%d/%d", &default_width, &default_height) == 2) display_type = DISPLAY_WINDOW; else if (sscanf(mode_str, "scr/%d", &scr_mode_bit) == 1) display_type = DISPLAY_SCREEN; } +#if 0 + if (default_width <= 0) + default_width = DisplayWidth(x_display, screen); + else if (default_width > DisplayWidth(x_display, screen)) + default_width = DisplayWidth(x_display, screen); + if (default_height <= 0) + default_height = DisplayHeight(x_display, screen); + else if (default_height > DisplayHeight(x_display, screen)) + default_height = DisplayHeight(x_display, screen); +#endif + + // Mac screen depth follows X depth + video_depth default_depth = VDEPTH_1BIT; +#if 0 + switch (DefaultDepth(x_display, screen)) { + case 8: + default_depth = VDEPTH_8BIT; + break; + case 15: case 16: + default_depth = VDEPTH_16BIT; + break; + case 24: case 32: + default_depth = VDEPTH_32BIT; + break; + } +#endif + + // Construct list of supported modes + if (display_type == DISPLAY_WINDOW) { + if (classic) + add_mode(512, 342, 0x80, 64, VDEPTH_1BIT); + else { + for (unsigned d=VDEPTH_1BIT; d<=VDEPTH_32BIT; d++) { + //if (find_visual_for_depth(video_depth(d))) + add_window_modes(video_depth(d)); + } + } + } else + add_mode(default_width, default_height, 0x80, TrivialBytesPerRow(default_width, default_depth), default_depth); + if (VideoModes.empty()) { + ErrorAlert(STR_VIDEO_FAILED); + return false; + } + + // Find requested default mode with specified dimensions + uint32 default_id; + std::vector::const_iterator i, end = VideoModes.end(); + for (i = VideoModes.begin(); i != end; ++i) { + if (i->x == default_width && i->y == default_height && i->depth == default_depth) { + default_id = i->resolution_id; + break; + } + } + if (i == end) { // not found, use first available mode + default_depth = VideoModes[0].depth; + default_id = VideoModes[0].resolution_id; + } + +#if DEBUG + D(bug("Available video modes:\n")); + for (i = VideoModes.begin(); i != end; ++i) { + int bits = 1 << i->depth; + if (bits == 16) + bits = 15; + else if (bits == 32) + bits = 24; + D(bug(" %dx%d (ID %02x), %d colors\n", i->x, i->y, i->resolution_id, 1 << bits)); + } +#endif + + // Create X11_monitor_desc for this (the only) display + BeOS_monitor_desc *monitor = new BeOS_monitor_desc(VideoModes, default_depth, default_id); + VideoMonitors.push_back(monitor); + + // Open display + return monitor->video_open(); +} + +bool BeOS_monitor_desc::video_open() { + // Create semaphore + mac_os_lock = create_sem(0, "MacOS Frame Buffer Lock"); + + const video_mode &mode = get_current_mode(); // Open display switch (display_type) { case DISPLAY_WINDOW: - the_window = new MacWindow(BRect(0, 0, width-1, height-1)); + the_window = new MacWindow(BRect(0, 0, mode.x-1, mode.y-1), *this); break; case DISPLAY_SCREEN: { status_t screen_error; - the_screen = new MacScreen(GetString(STR_WINDOW_TITLE), scr_mode_bit & 0x1f, &screen_error); + the_screen = new MacScreen(*this, GetString(STR_WINDOW_TITLE), scr_mode_bit & 0x1f, &screen_error); if (screen_error != B_NO_ERROR) { the_screen->PostMessage(B_QUIT_REQUESTED); while (the_screen) @@ -288,7 +383,7 @@ void VideoExit(void) * Set palette */ -void video_set_palette(uint8 *pal, int num) +void BeOS_monitor_desc::set_palette(uint8 *pal, int num) { switch (display_type) { case DISPLAY_WINDOW: { @@ -313,7 +408,7 @@ void video_set_palette(uint8 *pal, int num) * Switch video mode */ -void video_switch_to_mode(const video_mode &mode) +void BeOS_monitor_desc::switch_to_current_mode() { } @@ -461,7 +556,9 @@ static filter_result filter_func(BMessage *msg, BHandler **target, BMessageFilte * Window constructor */ -MacWindow::MacWindow(BRect frame) : BDirectWindow(frame, GetString(STR_WINDOW_TITLE), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE) +MacWindow::MacWindow(BRect frame, const BeOS_monitor_desc& monitor) + : BDirectWindow(frame, GetString(STR_WINDOW_TITLE), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE) + , monitor(monitor) { supports_direct_mode = SupportsWindowMode(); @@ -472,15 +569,24 @@ MacWindow::MacWindow(BRect frame) : BDirectWindow(frame, GetString(STR_WINDOW_TI // Allocate bitmap and Mac frame buffer uint32 x = frame.IntegerWidth() + 1; uint32 y = frame.IntegerHeight() + 1; - the_bitmap = new BBitmap(frame, B_COLOR_8_BIT); - the_buffer = new uint8[x * (y + 2)]; // "y + 2" for safety + const video_mode &mode = monitor.get_current_mode(); + switch (mode.depth) { + case VDEPTH_1BIT: + the_bitmap = new BBitmap(frame, B_RGB16); + break; + case VDEPTH_8BIT: + the_bitmap = new BBitmap(frame, B_CMAP8); + break; + default: + fprintf(stderr, "width: %d", 1 << mode.depth); + debugger("OOPS"); + } + the_buffer = new uint8[x * (y + 2) * 2]; // "y + 2" for safety - // Add resolution and set VideoMonitor - set_video_monitor(x, y, x, 8); #if REAL_ADDRESSING - VideoMonitor.mac_frame_base = (uint32)the_buffer; + monitor.set_mac_frame_base((uint32)the_buffer); #else - VideoMonitor.mac_frame_base = MacFrameBaseMac; + monitor.set_mac_frame_base(MacFrameBaseMac); #endif #if !REAL_ADDRESSING @@ -656,12 +762,13 @@ void MacWindow::MessageReceived(BMessage *msg) MessageQueue()->Unlock(); // Convert Mac screen buffer to BeOS palette and blit + const video_mode &mode = monitor.get_current_mode(); uint8 *source = the_buffer - 1; uint8 *dest = (uint8 *)the_bitmap->Bits() - 1; - uint32 length = VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y; + uint32 length = mode.bytes_per_row * mode.y; for (int i=0; iDrawBitmapAsync(the_bitmap, update_rect, update_rect); break; } @@ -781,8 +888,9 @@ status_t MacWindow::tick_func(void *arg) uint8 *source = obj->the_buffer - 1; uint8 *dest = (uint8 *)obj->bits; uint32 bytes_per_row = obj->bytes_per_row; - int xsize = VideoMonitor.mode.x; - int ysize = VideoMonitor.mode.y; + const video_mode &mode = obj->monitor.get_current_mode(); + int xsize = mode.x; + int ysize = mode.y; for (int y=0; ywidth, info->height, info->bytes_per_row, info->bits_per_pixel); - first_time = false; - } - // Set VideoMonitor #if REAL_ADDRESSING - VideoMonitor.mac_frame_base = (uint32)info->frame_buffer; + monitor.set_mac_frame_base((uint32)info->frame_buffer); #else - VideoMonitor.mac_frame_base = MacFrameBaseMac; + monitor.set_mac_frame_base(MacFrameBaseMac); #endif #if !REAL_ADDRESSING // Set variables for UAE memory mapping MacFrameBaseHost = (uint8 *)info->frame_buffer; - MacFrameSize = VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y; + MacFrameSize = mode.bytes_per_row * mode.y; switch (info->bits_per_pixel) { case 15: MacFrameLayout = FLAYOUT_HOST_555; @@ -940,13 +1045,13 @@ void MacScreen::ScreenConnected(bool active) // Copy from backup store to frame buffer if (frame_backup != NULL) { - memcpy(info->frame_buffer, frame_backup, VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y); + memcpy(info->frame_buffer, frame_backup, mode.bytes_per_row * mode.y); delete[] frame_backup; frame_backup = NULL; } // Restore palette - if (VideoMonitor.mode.depth == VDEPTH_8BIT) + if (mode.depth == VDEPTH_8BIT) SetColorList(palette); // Restart/signal emulator thread @@ -960,8 +1065,8 @@ void MacScreen::ScreenConnected(bool active) acquire_sem(mac_os_lock); // Create backup store and save frame buffer - frame_backup = new uint8[VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y]; - memcpy(frame_backup, info->frame_buffer, VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y); + frame_backup = new uint8[mode.bytes_per_row * mode.y]; + memcpy(frame_backup, info->frame_buffer, mode.bytes_per_row * mode.y); } } } From 09638b25366f6165229ebc156b7d2305e67b825b Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 26 Apr 2015 15:26:11 +0200 Subject: [PATCH 04/10] BeOS: set some required defines for FPU configuration. --- BasiliskII/src/BeOS/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BasiliskII/src/BeOS/Makefile b/BasiliskII/src/BeOS/Makefile index 16cae87f..e7feb636 100644 --- a/BasiliskII/src/BeOS/Makefile +++ b/BasiliskII/src/BeOS/Makefile @@ -97,7 +97,7 @@ OPTIMIZE= FULL # to use. For example, setting DEFINES to "DEBUG=1" will cause the # compiler option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" # would pass "-DDEBUG" on the compiler's command line. -DEFINES= +DEFINES= FPU_X86 SIZEOF_FLOAT=4 SIZEOF_DOUBLE=8 SIZEOF_LONG_DOUBLE=10 # specify special warning levels # if unspecified default warnings will be used From 371d385c6bf77736be7c27aaf90d01587d68c8e9 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 26 Apr 2015 15:31:30 +0200 Subject: [PATCH 05/10] Missing include for memset. --- BasiliskII/src/uae_cpu/fpu/fpu_x86.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/BasiliskII/src/uae_cpu/fpu/fpu_x86.cpp b/BasiliskII/src/uae_cpu/fpu/fpu_x86.cpp index 91b88d33..70e59086 100644 --- a/BasiliskII/src/uae_cpu/fpu/fpu_x86.cpp +++ b/BasiliskII/src/uae_cpu/fpu/fpu_x86.cpp @@ -136,6 +136,7 @@ #include #include +#include #include #include "sysdeps.h" From 83f03d417a7322603e4683c3228121beb8c12d30 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 26 Apr 2015 16:09:31 +0200 Subject: [PATCH 06/10] BeOS: stray backslash in about_window.cpp --- BasiliskII/src/BeOS/about_window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BasiliskII/src/BeOS/about_window.cpp b/BasiliskII/src/BeOS/about_window.cpp index 4866c6e5..94f9944e 100644 --- a/BasiliskII/src/BeOS/about_window.cpp +++ b/BasiliskII/src/BeOS/about_window.cpp @@ -1,4 +1,4 @@ -\/* +/* * about_window.cpp - "About" window * * Basilisk II (C) 1997-2008 Christian Bauer From c97be8dbb292b17fc0021b485c456d9f0cfd5ab1 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 26 Apr 2015 16:56:44 +0200 Subject: [PATCH 07/10] BeOS: implement charset conversion. --- BasiliskII/src/BeOS/extfs_beos.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/BasiliskII/src/BeOS/extfs_beos.cpp b/BasiliskII/src/BeOS/extfs_beos.cpp index 7ee4253b..5f5d7df2 100644 --- a/BasiliskII/src/BeOS/extfs_beos.cpp +++ b/BasiliskII/src/BeOS/extfs_beos.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include "extfs.h" @@ -458,3 +459,29 @@ bool extfs_rename(const char *old_path, const char *new_path) { return rename(old_path, new_path) == 0; } + +/* + * Strings (filenames) conversion + */ + +// Convert from the host OS filename encoding to MacRoman +const char *host_encoding_to_macroman(const char *filename) +{ + int32 state = 0; + static char buffer[512]; + int32 size = sizeof(buffer) - 1; + int32 insize = strlen(filename); + convert_from_utf8(B_MAC_ROMAN_CONVERSION, filename, &insize, buffer, &size, &state); + return buffer; +} + +// Convert from MacRoman to host OS filename encoding +const char *macroman_to_host_encoding(const char *filename) +{ + int32 state = 0; + static char buffer[512]; + int32 insize = strlen(filename); + int32 size = sizeof(buffer) - 1; + convert_to_utf8(B_MAC_ROMAN_CONVERSION, filename, &insize, buffer, &size, &state); + return buffer; +} From c226da6172926ce30f6b9efb946a53296da7d32d Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 26 Apr 2015 17:27:36 +0200 Subject: [PATCH 08/10] BeOS: support for vmdir preferences. --- BasiliskII/src/BeOS/main_beos.cpp | 4 +++- BasiliskII/src/BeOS/prefs_beos.cpp | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/BasiliskII/src/BeOS/main_beos.cpp b/BasiliskII/src/BeOS/main_beos.cpp index c8e19287..507e3bde 100644 --- a/BasiliskII/src/BeOS/main_beos.cpp +++ b/BasiliskII/src/BeOS/main_beos.cpp @@ -118,6 +118,8 @@ private: class file_open_error {}; class file_read_error {}; class rom_size_error {}; + + char* vmdir; }; static BasiliskII *the_app; @@ -178,7 +180,7 @@ void BasiliskII::ReadyToRun(void) // Read preferences int argc = 0; char **argv = NULL; - PrefsInit(argc, argv); + PrefsInit(vmdir, argc, argv); // Init system routines SysInit(); diff --git a/BasiliskII/src/BeOS/prefs_beos.cpp b/BasiliskII/src/BeOS/prefs_beos.cpp index 556ed284..9a74d643 100644 --- a/BasiliskII/src/BeOS/prefs_beos.cpp +++ b/BasiliskII/src/BeOS/prefs_beos.cpp @@ -44,8 +44,23 @@ static BPath prefs_path; * Load preferences from settings file */ -void LoadPrefs(void) +void LoadPrefs(const char* vmdir) { +#if 0 + if (vmdir) { + prefs_path.SetTo(vmdir); + prefs_path.Append("prefs"); + FILE *prefs = fopen(prefs_path.Path(), "r"); + if (!prefs) { + printf("No file at %s found.\n", prefs_path.Path()); + exit(1); + } + LoadPrefsFromStream(prefs); + fclose(prefs); + return; + } +#endif + // Construct prefs path find_directory(B_USER_SETTINGS_DIRECTORY, &prefs_path, true); prefs_path.Append(PREFS_FILE_NAME); From fd49455eec2f873ffaeb610fcd36af146fe79f94 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 26 Apr 2015 18:39:22 +0200 Subject: [PATCH 09/10] BeOS: get video to work again. * The code was hardwired for 8-bit mode, unplug that and set it up for 32bit mode (much simpler). * You need a ROM that supports 32bit mode for now * Mode switching not supported yet. --- BasiliskII/src/BeOS/video_beos.cpp | 84 ++++++++++-------------------- 1 file changed, 27 insertions(+), 57 deletions(-) diff --git a/BasiliskII/src/BeOS/video_beos.cpp b/BasiliskII/src/BeOS/video_beos.cpp index 5e73b9d9..d70ad834 100644 --- a/BasiliskII/src/BeOS/video_beos.cpp +++ b/BasiliskII/src/BeOS/video_beos.cpp @@ -137,7 +137,6 @@ private: BitmapView *main_view; // Main view for bitmap drawing BBitmap *the_bitmap; // Mac screen bitmap - uint8 *the_buffer; // Mac frame buffer uint32 old_scroll_lock_state; @@ -210,6 +209,7 @@ static void add_mode(uint32 width, uint32 height, uint32 resolution_id, uint32 b // Add standard list of windowed modes for given color depth static void add_window_modes(video_depth depth) { +#if 0 add_mode(512, 384, 0x80, TrivialBytesPerRow(512, depth), depth); add_mode(640, 480, 0x81, TrivialBytesPerRow(640, depth), depth); add_mode(800, 600, 0x82, TrivialBytesPerRow(800, depth), depth); @@ -217,6 +217,7 @@ static void add_window_modes(video_depth depth) add_mode(1152, 870, 0x84, TrivialBytesPerRow(1152, depth), depth); add_mode(1280, 1024, 0x85, TrivialBytesPerRow(1280, depth), depth); add_mode(1600, 1200, 0x86, TrivialBytesPerRow(1600, depth), depth); +#endif } @@ -252,31 +253,34 @@ bool VideoInit(bool classic) default_height = DisplayHeight(x_display, screen); #endif - // Mac screen depth follows X depth + // Mac screen depth follows BeOS depth video_depth default_depth = VDEPTH_1BIT; -#if 0 - switch (DefaultDepth(x_display, screen)) { - case 8: + switch (BScreen().ColorSpace()) { + case B_CMAP8: default_depth = VDEPTH_8BIT; break; - case 15: case 16: + case B_RGB15: default_depth = VDEPTH_16BIT; break; - case 24: case 32: + case B_RGB32: default_depth = VDEPTH_32BIT; break; + default: + fprintf(stderr, "Unknown color space!"); } -#endif // Construct list of supported modes if (display_type == DISPLAY_WINDOW) { if (classic) add_mode(512, 342, 0x80, 64, VDEPTH_1BIT); else { + add_mode(default_width, default_height, 0x80, TrivialBytesPerRow(default_width, default_depth), default_depth); +#if 0 for (unsigned d=VDEPTH_1BIT; d<=VDEPTH_32BIT; d++) { - //if (find_visual_for_depth(video_depth(d))) + if (find_visual_for_depth(video_depth(d))) add_window_modes(video_depth(d)); } +#endif } } else add_mode(default_width, default_height, 0x80, TrivialBytesPerRow(default_width, default_depth), default_depth); @@ -569,30 +573,38 @@ MacWindow::MacWindow(BRect frame, const BeOS_monitor_desc& monitor) // Allocate bitmap and Mac frame buffer uint32 x = frame.IntegerWidth() + 1; uint32 y = frame.IntegerHeight() + 1; + int fbsize = x * y; const video_mode &mode = monitor.get_current_mode(); switch (mode.depth) { case VDEPTH_1BIT: - the_bitmap = new BBitmap(frame, B_RGB16); + fprintf(stderr, "1BIT SCREEN CREATED"); + the_bitmap = new BBitmap(frame, B_GRAY1); + fbsize /= 8; break; case VDEPTH_8BIT: + fprintf(stderr, "8BIT SCREEN CREATED"); the_bitmap = new BBitmap(frame, B_CMAP8); break; + case VDEPTH_32BIT: + fprintf(stderr, "32BIT SCREEN CREATED"); + the_bitmap = new BBitmap(frame, B_RGB32_BIG); + fbsize *= 4; + break; default: fprintf(stderr, "width: %d", 1 << mode.depth); debugger("OOPS"); } - the_buffer = new uint8[x * (y + 2) * 2]; // "y + 2" for safety #if REAL_ADDRESSING - monitor.set_mac_frame_base((uint32)the_buffer); + monitor.set_mac_frame_base((uint32)the_bitmap->Bits()); #else monitor.set_mac_frame_base(MacFrameBaseMac); #endif #if !REAL_ADDRESSING // Set variables for UAE memory mapping - MacFrameBaseHost = the_buffer; - MacFrameSize = x * y; + MacFrameBaseHost = (uint8*)the_bitmap->Bits(); + MacFrameSize = fbsize; MacFrameLayout = FLAYOUT_DIRECT; #endif @@ -709,7 +721,6 @@ MacWindow::~MacWindow() // Free bitmap and frame buffer delete the_bitmap; - delete[] the_buffer; // Tell emulator that we're done the_window = NULL; @@ -763,11 +774,6 @@ void MacWindow::MessageReceived(BMessage *msg) // Convert Mac screen buffer to BeOS palette and blit const video_mode &mode = monitor.get_current_mode(); - uint8 *source = the_buffer - 1; - uint8 *dest = (uint8 *)the_bitmap->Bits() - 1; - uint32 length = mode.bytes_per_row * mode.y; - for (int i=0; iDrawBitmapAsync(the_bitmap, update_rect, update_rect); break; @@ -877,43 +883,7 @@ status_t MacWindow::tick_func(void *arg) // Refresh screen unless Scroll Lock is down if (!scroll_lock_state) { - - // If direct frame buffer access is supported and the content area is completely visible, - // convert the Mac screen buffer directly. Otherwise, send a message to the window to do - // it into a bitmap - if (obj->supports_direct_mode) { - if (acquire_sem(obj->drawing_sem) != B_NO_ERROR) - return 0; - if (obj->unclipped && obj->pixel_format == B_CMAP8) { - uint8 *source = obj->the_buffer - 1; - uint8 *dest = (uint8 *)obj->bits; - uint32 bytes_per_row = obj->bytes_per_row; - const video_mode &mode = obj->monitor.get_current_mode(); - int xsize = mode.x; - int ysize = mode.y; - for (int y=0; yremap_mac_be[*++source] << 24; - c |= obj->remap_mac_be[*++source] << 16; - c |= obj->remap_mac_be[*++source] << 8; - c |= obj->remap_mac_be[*++source]; -#else - uint32 c = obj->remap_mac_be[*++source]; - c |= obj->remap_mac_be[*++source] << 8; - c |= obj->remap_mac_be[*++source] << 16; - c |= obj->remap_mac_be[*++source] << 24; -#endif - *++p = c; - } - dest += bytes_per_row; - } - } else - obj->PostMessage(MSG_REDRAW); - release_sem(obj->drawing_sem); - } else - obj->PostMessage(MSG_REDRAW); + obj->PostMessage(MSG_REDRAW); } } snooze(16666); From 80cb8e0cff5e2a44db08c4c4e1bc3e081e7d0953 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 26 Apr 2015 18:42:06 +0200 Subject: [PATCH 10/10] BeOS: null-terminate strings when converting file names. --- BasiliskII/src/BeOS/extfs_beos.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BasiliskII/src/BeOS/extfs_beos.cpp b/BasiliskII/src/BeOS/extfs_beos.cpp index 5f5d7df2..5b7ab4d6 100644 --- a/BasiliskII/src/BeOS/extfs_beos.cpp +++ b/BasiliskII/src/BeOS/extfs_beos.cpp @@ -472,6 +472,7 @@ const char *host_encoding_to_macroman(const char *filename) int32 size = sizeof(buffer) - 1; int32 insize = strlen(filename); convert_from_utf8(B_MAC_ROMAN_CONVERSION, filename, &insize, buffer, &size, &state); + buffer[size] = 0; return buffer; } @@ -483,5 +484,6 @@ const char *macroman_to_host_encoding(const char *filename) int32 insize = strlen(filename); int32 size = sizeof(buffer) - 1; convert_to_utf8(B_MAC_ROMAN_CONVERSION, filename, &insize, buffer, &size, &state); + buffer[size] = 0; return buffer; }