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 |
+ |
VideoMonitor.mode = mode; |
210 |
+ |
} |
211 |
+ |
|
212 |
+ |
|
213 |
|
bool VideoInit(bool classic) |
214 |
|
{ |
215 |
|
// Create semaphore |
465 |
|
the_bitmap = new BBitmap(frame, B_COLOR_8_BIT); |
466 |
|
the_buffer = new uint8[x * (y + 2)]; // "y + 2" for safety |
467 |
|
|
468 |
< |
// Set VideoMonitor |
468 |
> |
// Add resolution and set VideoMonitor |
469 |
> |
set_video_monitor(x, y, x, 8); |
470 |
|
#if REAL_ADDRESSING |
471 |
|
VideoMonitor.mac_frame_base = (uint32)the_buffer; |
472 |
|
#else |
473 |
|
VideoMonitor.mac_frame_base = MacFrameBaseMac; |
474 |
|
#endif |
433 |
– |
VideoMonitor.bytes_per_row = x; |
434 |
– |
VideoMonitor.x = x; |
435 |
– |
VideoMonitor.y = y; |
436 |
– |
VideoMonitor.mode = VMODE_8BIT; |
475 |
|
|
476 |
|
#if !REAL_ADDRESSING |
477 |
|
// Set variables for UAE memory mapping |
478 |
|
MacFrameBaseHost = the_buffer; |
479 |
< |
MacFrameSize = VideoMonitor.bytes_per_row * VideoMonitor.y; |
479 |
> |
MacFrameSize = x * y; |
480 |
|
MacFrameLayout = FLAYOUT_DIRECT; |
481 |
|
#endif |
482 |
|
|
648 |
|
// Convert Mac screen buffer to BeOS palette and blit |
649 |
|
uint8 *source = the_buffer - 1; |
650 |
|
uint8 *dest = (uint8 *)the_bitmap->Bits() - 1; |
651 |
< |
uint32 length = VideoMonitor.bytes_per_row * VideoMonitor.y; |
651 |
> |
uint32 length = VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y; |
652 |
|
for (int i=0; i<length; i++) |
653 |
|
*++dest = remap_mac_be[*++source]; |
654 |
< |
BRect update_rect = BRect(0, 0, VideoMonitor.x-1, VideoMonitor.y-1); |
654 |
> |
BRect update_rect = BRect(0, 0, VideoMonitor.mode.x-1, VideoMonitor.mode.y-1); |
655 |
|
main_view->DrawBitmapAsync(the_bitmap, update_rect, update_rect); |
656 |
|
break; |
657 |
|
} |
771 |
|
uint8 *source = obj->the_buffer - 1; |
772 |
|
uint8 *dest = (uint8 *)obj->bits; |
773 |
|
uint32 bytes_per_row = obj->bytes_per_row; |
774 |
< |
int xsize = VideoMonitor.x; |
775 |
< |
int ysize = VideoMonitor.y; |
774 |
> |
int xsize = VideoMonitor.mode.x; |
775 |
> |
int ysize = VideoMonitor.mode.y; |
776 |
|
for (int y=0; y<ysize; y++) { |
777 |
|
uint32 *p = (uint32 *)dest - 1; |
778 |
|
for (int x=0; x<xsize/4; x++) { |
833 |
|
frame_backup = NULL; |
834 |
|
palette_changed = false; |
835 |
|
screen_active = false; |
836 |
+ |
first_time = true; |
837 |
|
quitting = false; |
838 |
|
|
839 |
|
// Set relative mouse mode |
895 |
|
|
896 |
|
if (active == true) { |
897 |
|
|
898 |
+ |
// Add resolution and set VideoMonitor |
899 |
+ |
if (first_time) { |
900 |
+ |
set_video_monitor(info->width, info->height, info->bytes_per_row, info->bits_per_pixel); |
901 |
+ |
first_time = false; |
902 |
+ |
} |
903 |
+ |
|
904 |
|
// Set VideoMonitor |
905 |
|
#if REAL_ADDRESSING |
906 |
|
VideoMonitor.mac_frame_base = (uint32)info->frame_buffer; |
907 |
|
#else |
908 |
|
VideoMonitor.mac_frame_base = MacFrameBaseMac; |
909 |
|
#endif |
865 |
– |
VideoMonitor.bytes_per_row = info->bytes_per_row; |
866 |
– |
VideoMonitor.x = info->width; |
867 |
– |
VideoMonitor.y = info->height; |
868 |
– |
switch (info->bits_per_pixel) { |
869 |
– |
case 8: |
870 |
– |
VideoMonitor.mode = VMODE_8BIT; |
871 |
– |
break; |
872 |
– |
case 15: |
873 |
– |
case 16: |
874 |
– |
VideoMonitor.mode = VMODE_16BIT; |
875 |
– |
break; |
876 |
– |
case 32: |
877 |
– |
VideoMonitor.mode = VMODE_32BIT; |
878 |
– |
break; |
879 |
– |
default: |
880 |
– |
VideoMonitor.mode = VMODE_8BIT; |
881 |
– |
break; |
882 |
– |
} |
910 |
|
|
911 |
|
#if !REAL_ADDRESSING |
912 |
|
// Set variables for UAE memory mapping |
913 |
|
MacFrameBaseHost = (uint8 *)info->frame_buffer; |
914 |
< |
MacFrameSize = VideoMonitor.bytes_per_row * VideoMonitor.y; |
914 |
> |
MacFrameSize = VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y; |
915 |
|
switch (info->bits_per_pixel) { |
916 |
|
case 15: |
917 |
|
MacFrameLayout = FLAYOUT_HOST_555; |
930 |
|
|
931 |
|
// Copy from backup store to frame buffer |
932 |
|
if (frame_backup != NULL) { |
933 |
< |
memcpy(info->frame_buffer, frame_backup, VideoMonitor.bytes_per_row * VideoMonitor.y); |
933 |
> |
memcpy(info->frame_buffer, frame_backup, VideoMonitor.bytes_per_row * VideoMonitor.mode.y); |
934 |
|
delete[] frame_backup; |
935 |
|
frame_backup = NULL; |
936 |
|
} |
937 |
|
|
938 |
|
// Restore palette |
939 |
< |
if (VideoMonitor.mode == VMODE_8BIT) |
939 |
> |
if (VideoMonitor.depth == VDEPTH_8BIT) |
940 |
|
SetColorList(palette); |
941 |
|
|
942 |
|
// Restart/signal emulator thread |
950 |
|
acquire_sem(mac_os_lock); |
951 |
|
|
952 |
|
// Create backup store and save frame buffer |
953 |
< |
frame_backup = new uint8[VideoMonitor.bytes_per_row * VideoMonitor.y]; |
954 |
< |
memcpy(frame_backup, info->frame_buffer, VideoMonitor.bytes_per_row * VideoMonitor.y); |
953 |
> |
frame_backup = new uint8[VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y]; |
954 |
> |
memcpy(frame_backup, info->frame_buffer, VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y); |
955 |
|
} |
956 |
|
} |
957 |
|
} |