1 |
|
/* |
2 |
|
* video_beos.cpp - Video/graphics emulation, BeOS specific stuff |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
5 |
< |
* Portions (C) 1997-1999 Marc Hellwig |
4 |
> |
* Basilisk II (C) 1997-2008 Christian Bauer |
5 |
> |
* Portions written by Marc Hellwig |
6 |
|
* |
7 |
|
* This program is free software; you can redistribute it and/or modify |
8 |
|
* it under the terms of the GNU General Public License as published by |
34 |
|
#include "adb.h" |
35 |
|
#include "prefs.h" |
36 |
|
#include "user_strings.h" |
37 |
< |
#include "version.h" |
37 |
> |
#include "about_window.h" |
38 |
|
#include "video.h" |
39 |
|
|
40 |
|
#include "m68k.h" |
41 |
|
#include "memory.h" |
42 |
|
#include "readcpu.h" |
43 |
|
#include "newcpu.h" |
44 |
– |
#include "compiler.h" |
44 |
|
|
45 |
|
#define DEBUG 0 |
46 |
|
#include "debug.h" |
136 |
|
|
137 |
|
class MacScreen : public BWindowScreen { |
138 |
|
public: |
139 |
< |
MacScreen(char *name, int mode_bit, status_t *error); |
139 |
> |
MacScreen(const char *name, int mode_bit, status_t *error); |
140 |
|
virtual ~MacScreen(); |
141 |
|
virtual void Quit(void); |
142 |
|
virtual void ScreenConnected(bool active); |
154 |
|
uint8 *frame_backup; // Frame buffer backup when switching from/to different workspace |
155 |
|
bool quitting; // Flag for ScreenConnected: We are quitting, don't pause emulator thread |
156 |
|
bool screen_active; |
157 |
+ |
bool first_time; |
158 |
|
}; |
159 |
|
|
160 |
|
|
170 |
|
* Initialization |
171 |
|
*/ |
172 |
|
|
173 |
+ |
// Add resolution to list of supported modes and set VideoMonitor |
174 |
+ |
static void set_video_monitor(uint32 width, uint32 height, uint32 bytes_per_row, int depth) |
175 |
+ |
{ |
176 |
+ |
video_mode mode; |
177 |
+ |
|
178 |
+ |
mode.x = width; |
179 |
+ |
mode.y = height; |
180 |
+ |
mode.resolution_id = 0x80; |
181 |
+ |
mode.bytes_per_row = bytes_per_row; |
182 |
+ |
|
183 |
+ |
switch (depth) { |
184 |
+ |
case 1: |
185 |
+ |
mode.depth = VDEPTH_1BIT; |
186 |
+ |
break; |
187 |
+ |
case 2: |
188 |
+ |
mode.depth = VDEPTH_2BIT; |
189 |
+ |
break; |
190 |
+ |
case 4: |
191 |
+ |
mode.depth = VDEPTH_4BIT; |
192 |
+ |
break; |
193 |
+ |
case 8: |
194 |
+ |
mode.depth = VDEPTH_8BIT; |
195 |
+ |
break; |
196 |
+ |
case 15: |
197 |
+ |
mode.depth = VDEPTH_16BIT; |
198 |
+ |
break; |
199 |
+ |
case 16: |
200 |
+ |
mode.depth = VDEPTH_16BIT; |
201 |
+ |
break; |
202 |
+ |
case 24: |
203 |
+ |
case 32: |
204 |
+ |
mode.depth = VDEPTH_32BIT; |
205 |
+ |
break; |
206 |
+ |
} |
207 |
+ |
|
208 |
+ |
VideoModes.push_back(mode); |
209 |
+ |
video_init_depth_list(); |
210 |
+ |
VideoMonitor.mode = mode; |
211 |
+ |
} |
212 |
+ |
|
213 |
+ |
|
214 |
|
bool VideoInit(bool classic) |
215 |
|
{ |
216 |
|
// Create semaphore |
242 |
|
the_screen->PostMessage(B_QUIT_REQUESTED); |
243 |
|
while (the_screen) |
244 |
|
snooze(200000); |
245 |
< |
ErrorAlert(GetString(STR_OPEN_SCREEN_ERR)); |
245 |
> |
ErrorAlert(STR_OPEN_SCREEN_ERR); |
246 |
|
return false; |
247 |
|
} else { |
248 |
|
the_screen->Show(); |
288 |
|
* Set palette |
289 |
|
*/ |
290 |
|
|
291 |
< |
void video_set_palette(uint8 *pal) |
291 |
> |
void video_set_palette(uint8 *pal, int num) |
292 |
|
{ |
293 |
|
switch (display_type) { |
294 |
|
case DISPLAY_WINDOW: { |
310 |
|
|
311 |
|
|
312 |
|
/* |
313 |
+ |
* Switch video mode |
314 |
+ |
*/ |
315 |
+ |
|
316 |
+ |
void video_switch_to_mode(const video_mode &mode) |
317 |
+ |
{ |
318 |
+ |
} |
319 |
+ |
|
320 |
+ |
|
321 |
+ |
/* |
322 |
|
* Close down full-screen mode (if bringing up error alerts is unsafe while in full-screen mode) |
323 |
|
*/ |
324 |
|
|
475 |
|
the_bitmap = new BBitmap(frame, B_COLOR_8_BIT); |
476 |
|
the_buffer = new uint8[x * (y + 2)]; // "y + 2" for safety |
477 |
|
|
478 |
< |
// Set VideoMonitor |
478 |
> |
// Add resolution and set VideoMonitor |
479 |
> |
set_video_monitor(x, y, x, 8); |
480 |
|
#if REAL_ADDRESSING |
481 |
|
VideoMonitor.mac_frame_base = (uint32)the_buffer; |
482 |
|
#else |
483 |
|
VideoMonitor.mac_frame_base = MacFrameBaseMac; |
484 |
|
#endif |
434 |
– |
VideoMonitor.bytes_per_row = x; |
435 |
– |
VideoMonitor.x = x; |
436 |
– |
VideoMonitor.y = y; |
437 |
– |
VideoMonitor.mode = VMODE_8BIT; |
485 |
|
|
486 |
|
#if !REAL_ADDRESSING |
487 |
|
// Set variables for UAE memory mapping |
488 |
|
MacFrameBaseHost = the_buffer; |
489 |
< |
MacFrameSize = VideoMonitor.bytes_per_row * VideoMonitor.y; |
489 |
> |
MacFrameSize = x * y; |
490 |
|
MacFrameLayout = FLAYOUT_DIRECT; |
491 |
|
#endif |
492 |
|
|
658 |
|
// Convert Mac screen buffer to BeOS palette and blit |
659 |
|
uint8 *source = the_buffer - 1; |
660 |
|
uint8 *dest = (uint8 *)the_bitmap->Bits() - 1; |
661 |
< |
uint32 length = VideoMonitor.bytes_per_row * VideoMonitor.y; |
661 |
> |
uint32 length = VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y; |
662 |
|
for (int i=0; i<length; i++) |
663 |
|
*++dest = remap_mac_be[*++source]; |
664 |
< |
BRect update_rect = BRect(0, 0, VideoMonitor.x-1, VideoMonitor.y-1); |
664 |
> |
BRect update_rect = BRect(0, 0, VideoMonitor.mode.x-1, VideoMonitor.mode.y-1); |
665 |
|
main_view->DrawBitmapAsync(the_bitmap, update_rect, update_rect); |
666 |
|
break; |
667 |
|
} |
668 |
|
|
669 |
|
case MSG_ABOUT_REQUESTED: { |
670 |
< |
char str[256]; |
624 |
< |
sprintf(str, GetString(STR_ABOUT_TEXT1), VERSION_MAJOR, VERSION_MINOR); |
625 |
< |
strcat(str, " "); |
626 |
< |
strcat(str, GetString(STR_ABOUT_TEXT2)); |
627 |
< |
BAlert *about = new BAlert(GetString(STR_WINDOW_TITLE), str, GetString(STR_OK_BUTTON)); |
628 |
< |
about->Go(); |
670 |
> |
ShowAboutWindow(); |
671 |
|
break; |
672 |
|
} |
673 |
|
|
761 |
|
|
762 |
|
// Yes, set new cursor image if it was changed |
763 |
|
if (memcmp(MacCursor+4, Mac2HostAddr(0x844), 64)) { |
764 |
< |
memcpy(MacCursor+4, Mac2HostAddr(0x844), 64); // Cursor image |
765 |
< |
MacCursor[2] = ReadMacInt8(0x885); // Hotspot |
764 |
> |
Mac2Host_memcpy(MacCursor+4, 0x844, 64); // Cursor image |
765 |
> |
MacCursor[2] = ReadMacInt8(0x885); // Hotspot |
766 |
|
MacCursor[3] = ReadMacInt8(0x887); |
767 |
|
be_app->SetCursor(MacCursor); |
768 |
|
} |
781 |
|
uint8 *source = obj->the_buffer - 1; |
782 |
|
uint8 *dest = (uint8 *)obj->bits; |
783 |
|
uint32 bytes_per_row = obj->bytes_per_row; |
784 |
< |
int xsize = VideoMonitor.x; |
785 |
< |
int ysize = VideoMonitor.y; |
784 |
> |
int xsize = VideoMonitor.mode.x; |
785 |
> |
int ysize = VideoMonitor.mode.y; |
786 |
|
for (int y=0; y<ysize; y++) { |
787 |
|
uint32 *p = (uint32 *)dest - 1; |
788 |
|
for (int x=0; x<xsize/4; x++) { |
837 |
|
* Screen constructor |
838 |
|
*/ |
839 |
|
|
840 |
< |
MacScreen::MacScreen(char *name, int mode_bit, status_t *error) : BWindowScreen(name, 1 << mode_bit, error), tick_thread(-1) |
840 |
> |
MacScreen::MacScreen(const char *name, int mode_bit, status_t *error) : BWindowScreen(name, 1 << mode_bit, error), tick_thread(-1) |
841 |
|
{ |
842 |
|
// Set all variables |
843 |
|
frame_backup = NULL; |
844 |
|
palette_changed = false; |
845 |
|
screen_active = false; |
846 |
+ |
first_time = true; |
847 |
|
quitting = false; |
848 |
|
|
849 |
|
// Set relative mouse mode |
905 |
|
|
906 |
|
if (active == true) { |
907 |
|
|
908 |
+ |
// Add resolution and set VideoMonitor |
909 |
+ |
if (first_time) { |
910 |
+ |
set_video_monitor(info->width, info->height, info->bytes_per_row, info->bits_per_pixel); |
911 |
+ |
first_time = false; |
912 |
+ |
} |
913 |
+ |
|
914 |
|
// Set VideoMonitor |
915 |
|
#if REAL_ADDRESSING |
916 |
|
VideoMonitor.mac_frame_base = (uint32)info->frame_buffer; |
917 |
|
#else |
918 |
|
VideoMonitor.mac_frame_base = MacFrameBaseMac; |
919 |
|
#endif |
871 |
– |
VideoMonitor.bytes_per_row = info->bytes_per_row; |
872 |
– |
VideoMonitor.x = info->width; |
873 |
– |
VideoMonitor.y = info->height; |
874 |
– |
switch (info->bits_per_pixel) { |
875 |
– |
case 8: |
876 |
– |
VideoMonitor.mode = VMODE_8BIT; |
877 |
– |
break; |
878 |
– |
case 15: |
879 |
– |
case 16: |
880 |
– |
VideoMonitor.mode = VMODE_16BIT; |
881 |
– |
break; |
882 |
– |
case 32: |
883 |
– |
VideoMonitor.mode = VMODE_32BIT; |
884 |
– |
break; |
885 |
– |
default: |
886 |
– |
VideoMonitor.mode = VMODE_8BIT; |
887 |
– |
break; |
888 |
– |
} |
920 |
|
|
921 |
|
#if !REAL_ADDRESSING |
922 |
|
// Set variables for UAE memory mapping |
923 |
|
MacFrameBaseHost = (uint8 *)info->frame_buffer; |
924 |
< |
MacFrameSize = VideoMonitor.bytes_per_row * VideoMonitor.y; |
924 |
> |
MacFrameSize = VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y; |
925 |
|
switch (info->bits_per_pixel) { |
926 |
|
case 15: |
927 |
|
MacFrameLayout = FLAYOUT_HOST_555; |
940 |
|
|
941 |
|
// Copy from backup store to frame buffer |
942 |
|
if (frame_backup != NULL) { |
943 |
< |
memcpy(info->frame_buffer, frame_backup, VideoMonitor.bytes_per_row * VideoMonitor.y); |
943 |
> |
memcpy(info->frame_buffer, frame_backup, VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y); |
944 |
|
delete[] frame_backup; |
945 |
|
frame_backup = NULL; |
946 |
|
} |
947 |
|
|
948 |
|
// Restore palette |
949 |
< |
if (VideoMonitor.mode == VMODE_8BIT) |
949 |
> |
if (VideoMonitor.mode.depth == VDEPTH_8BIT) |
950 |
|
SetColorList(palette); |
951 |
|
|
952 |
|
// Restart/signal emulator thread |
960 |
|
acquire_sem(mac_os_lock); |
961 |
|
|
962 |
|
// Create backup store and save frame buffer |
963 |
< |
frame_backup = new uint8[VideoMonitor.bytes_per_row * VideoMonitor.y]; |
964 |
< |
memcpy(frame_backup, info->frame_buffer, VideoMonitor.bytes_per_row * VideoMonitor.y); |
963 |
> |
frame_backup = new uint8[VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y]; |
964 |
> |
memcpy(frame_backup, info->frame_buffer, VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y); |
965 |
|
} |
966 |
|
} |
967 |
|
} |