mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-26 10:49:21 +00:00
Merge pull request #68 from pulkomandy/master
Fix BeOS build and add Haiku support.
This commit is contained in:
commit
eb3ef0bd01
@ -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
|
||||
@ -116,14 +116,14 @@ SYMBOLS =
|
||||
DEBUGGER =
|
||||
|
||||
# specify additional compiler flags for all files
|
||||
COMPILER_FLAGS =
|
||||
COMPILER_FLAGS = -fomit-frame-pointer -fno-PIC
|
||||
|
||||
# specify additional linker flags
|
||||
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
|
||||
|
@ -1,4 +1,4 @@
|
||||
\/*
|
||||
/*
|
||||
* about_window.cpp - "About" window
|
||||
*
|
||||
* Basilisk II (C) 1997-2008 Christian Bauer
|
||||
|
@ -31,6 +31,11 @@
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#ifdef __HAIKU__
|
||||
#include <sys/select.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include "cpu_emulation.h"
|
||||
#include "main.h"
|
||||
#include "prefs.h"
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include <fs_attr.h>
|
||||
#include <support/TypeConstants.h>
|
||||
#include <support/UTF8.h>
|
||||
#include <storage/Mime.h>
|
||||
|
||||
#include "extfs.h"
|
||||
@ -458,3 +459,31 @@ 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);
|
||||
buffer[size] = 0;
|
||||
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);
|
||||
buffer[size] = 0;
|
||||
return buffer;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,11 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <device/scsi.h>
|
||||
#ifdef __HAIKU__
|
||||
#include <CAM.h>
|
||||
#else
|
||||
#include <drivers/CAM.h>
|
||||
#endif
|
||||
|
||||
#include "sysdeps.h"
|
||||
#include "main.h"
|
||||
|
@ -40,6 +40,11 @@
|
||||
#define DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
#ifdef __HAIKU__
|
||||
#include <fs_volume.h>
|
||||
#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
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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<video_mode> VideoModes; // Supported video modes
|
||||
|
||||
/*
|
||||
* monitor_desc subclass for BeOS display
|
||||
*/
|
||||
|
||||
class BeOS_monitor_desc : public monitor_desc {
|
||||
public:
|
||||
BeOS_monitor_desc(const vector<video_mode> &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);
|
||||
@ -116,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;
|
||||
|
||||
@ -127,6 +147,8 @@ private:
|
||||
int32 bytes_per_row;
|
||||
color_space pixel_format;
|
||||
bool unclipped;
|
||||
|
||||
BeOS_monitor_desc monitor;
|
||||
};
|
||||
|
||||
|
||||
@ -136,7 +158,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 +177,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 +194,149 @@ 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)
|
||||
{
|
||||
#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);
|
||||
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);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 BeOS depth
|
||||
video_depth default_depth = VDEPTH_1BIT;
|
||||
switch (BScreen().ColorSpace()) {
|
||||
case B_CMAP8:
|
||||
default_depth = VDEPTH_8BIT;
|
||||
break;
|
||||
case B_RGB15:
|
||||
default_depth = VDEPTH_16BIT;
|
||||
break;
|
||||
case B_RGB32:
|
||||
default_depth = VDEPTH_32BIT;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown color space!");
|
||||
}
|
||||
|
||||
// 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)))
|
||||
add_window_modes(video_depth(d));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} 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<video_mode>::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 +387,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 +412,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 +560,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,21 +573,38 @@ 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
|
||||
int fbsize = x * y;
|
||||
const video_mode &mode = monitor.get_current_mode();
|
||||
switch (mode.depth) {
|
||||
case VDEPTH_1BIT:
|
||||
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");
|
||||
}
|
||||
|
||||
// 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_bitmap->Bits());
|
||||
#else
|
||||
VideoMonitor.mac_frame_base = MacFrameBaseMac;
|
||||
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
|
||||
|
||||
@ -603,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;
|
||||
@ -656,12 +773,8 @@ void MacWindow::MessageReceived(BMessage *msg)
|
||||
MessageQueue()->Unlock();
|
||||
|
||||
// Convert Mac screen buffer to BeOS palette and blit
|
||||
uint8 *source = the_buffer - 1;
|
||||
uint8 *dest = (uint8 *)the_bitmap->Bits() - 1;
|
||||
uint32 length = VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y;
|
||||
for (int i=0; i<length; i++)
|
||||
*++dest = remap_mac_be[*++source];
|
||||
BRect update_rect = BRect(0, 0, VideoMonitor.mode.x-1, VideoMonitor.mode.y-1);
|
||||
const video_mode &mode = monitor.get_current_mode();
|
||||
BRect update_rect = BRect(0, 0, mode.x-1, mode.y-1);
|
||||
main_view->DrawBitmapAsync(the_bitmap, update_rect, update_rect);
|
||||
break;
|
||||
}
|
||||
@ -770,42 +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;
|
||||
int xsize = VideoMonitor.mode.x;
|
||||
int ysize = VideoMonitor.mode.y;
|
||||
for (int y=0; y<ysize; y++) {
|
||||
uint32 *p = (uint32 *)dest - 1;
|
||||
for (int x=0; x<xsize/4; x++) {
|
||||
#if B_HOST_IS_BENDIAN
|
||||
uint32 c = obj->remap_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);
|
||||
@ -837,7 +915,9 @@ void BitmapView::MouseMoved(BPoint point, uint32 transit, const BMessage *messag
|
||||
* Screen constructor
|
||||
*/
|
||||
|
||||
MacScreen::MacScreen(const char *name, int mode_bit, status_t *error) : BWindowScreen(name, 1 << mode_bit, error), tick_thread(-1)
|
||||
MacScreen::MacScreen(const BeOS_monitor_desc& monitor, const char *name, int mode_bit, status_t *error)
|
||||
: BWindowScreen(name, 1 << mode_bit, error), tick_thread(-1)
|
||||
, monitor(monitor)
|
||||
{
|
||||
// Set all variables
|
||||
frame_backup = NULL;
|
||||
@ -902,26 +982,21 @@ void MacScreen::ScreenConnected(bool active)
|
||||
{
|
||||
graphics_card_info *info = CardInfo();
|
||||
screen_active = active;
|
||||
const video_mode &mode = monitor.get_current_mode();
|
||||
|
||||
if (active == true) {
|
||||
|
||||
// Add resolution and set VideoMonitor
|
||||
if (first_time) {
|
||||
set_video_monitor(info->width, 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 +1015,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 +1035,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -136,6 +136,7 @@
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "sysdeps.h"
|
||||
|
Loading…
Reference in New Issue
Block a user