45 |
|
// Description of the main monitor |
46 |
|
monitor_desc VideoMonitor; |
47 |
|
|
48 |
+ |
// Depth code -> Apple mode mapping |
49 |
+ |
uint16 apple_mode_for_depth[6]; |
50 |
+ |
|
51 |
|
// Local variables (per monitor) |
52 |
|
struct { |
53 |
|
monitor_desc *desc; // Pointer to description of monitor handled by this instance of the driver |
54 |
|
uint8 palette[256 * 3]; // Color palette, 256 entries, RGB |
55 |
|
bool luminance_mapping; // Luminance mapping on/off |
56 |
|
bool interrupts_enabled; // VBL interrupts on/off |
57 |
+ |
bool dm_present; // We received a GetVideoParameters call, so the Display Manager seems to be present |
58 |
|
uint32 gamma_table; // Mac address of gamma table |
59 |
|
int alloc_gamma_table_size; // Allocated size of gamma table |
60 |
|
uint16 current_mode; // Currently selected depth/resolution |
66 |
|
|
67 |
|
|
68 |
|
/* |
69 |
+ |
* Initialize apple_mode_for_depth[] array from VideoModes list |
70 |
+ |
*/ |
71 |
+ |
|
72 |
+ |
void video_init_depth_list(void) |
73 |
+ |
{ |
74 |
+ |
uint16 mode = 0x80; |
75 |
+ |
for (int depth = VDEPTH_1BIT; depth <= VDEPTH_32BIT; depth++) { |
76 |
+ |
if (video_has_depth(video_depth(depth))) |
77 |
+ |
apple_mode_for_depth[depth] = mode++; |
78 |
+ |
else |
79 |
+ |
apple_mode_for_depth[depth] = 0; |
80 |
+ |
} |
81 |
+ |
} |
82 |
+ |
|
83 |
+ |
|
84 |
+ |
/* |
85 |
+ |
* Check whether a mode with the specified depth exists |
86 |
+ |
*/ |
87 |
+ |
|
88 |
+ |
bool video_has_depth(video_depth depth) |
89 |
+ |
{ |
90 |
+ |
vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end(); |
91 |
+ |
while (i != end) { |
92 |
+ |
if (i->depth == depth) |
93 |
+ |
return true; |
94 |
+ |
++i; |
95 |
+ |
} |
96 |
+ |
return false; |
97 |
+ |
} |
98 |
+ |
|
99 |
+ |
|
100 |
+ |
/* |
101 |
|
* Check whether specified resolution ID is one of the supported resolutions |
102 |
|
*/ |
103 |
|
|
157 |
|
return; |
158 |
|
} |
159 |
|
} |
160 |
+ |
x = y = 0; |
161 |
+ |
} |
162 |
+ |
|
163 |
+ |
|
164 |
+ |
/* |
165 |
+ |
* Get bytes-per-row value for specified resolution/depth |
166 |
+ |
*/ |
167 |
+ |
|
168 |
+ |
uint32 video_bytes_per_row(video_depth depth, uint32 id) |
169 |
+ |
{ |
170 |
+ |
vector<video_mode>::const_iterator i, end = VideoModes.end(); |
171 |
+ |
for (i = VideoModes.begin(); i != end; ++i) { |
172 |
+ |
if (i->depth == depth && i->resolution_id == id) |
173 |
+ |
return i->bytes_per_row; |
174 |
+ |
} |
175 |
+ |
uint32 x, y; |
176 |
+ |
get_size_of_resolution(id, x, y); |
177 |
+ |
return TrivialBytesPerRow(x, depth); |
178 |
|
} |
179 |
|
|
180 |
|
|
333 |
|
Mac2Mac_memcpy(table, user_table, size); |
334 |
|
} |
335 |
|
|
336 |
< |
if (IsDirectMode(VidLocal.current_mode)) |
336 |
> |
if (IsDirectMode(VidLocal.desc->mode)) |
337 |
|
load_ramp_palette(); |
338 |
|
|
339 |
|
return true; |
405 |
|
// Update frame buffer base in DCE and param block |
406 |
|
WriteMacInt32(dce + dCtlDevBase, frame_base); |
407 |
|
WriteMacInt32(param + csBaseAddr, frame_base); |
408 |
+ |
|
409 |
+ |
// Patch frame buffer base address for MacOS versions <7.6 |
410 |
+ |
if (!VidLocal.dm_present) { // Only do this when no Display Manager seems to be present; otherwise, the screen will not get redrawn |
411 |
+ |
WriteMacInt32(0x824, frame_base); // ScrnBase |
412 |
+ |
uint32 gdev = ReadMacInt32(0x8a4); // MainDevice |
413 |
+ |
gdev = ReadMacInt32(gdev); |
414 |
+ |
uint32 pmap = ReadMacInt32(gdev + 0x16); // gdPMap |
415 |
+ |
pmap = ReadMacInt32(pmap); |
416 |
+ |
WriteMacInt32(pmap, frame_base); // baseAddr |
417 |
+ |
} |
418 |
|
} |
419 |
|
|
420 |
|
|
438 |
|
VidLocal.current_id = VidLocal.desc->mode.resolution_id; |
439 |
|
VidLocal.preferred_mode = VidLocal.current_mode; |
440 |
|
VidLocal.preferred_id = VidLocal.current_id; |
441 |
+ |
VidLocal.dm_present = false; |
442 |
|
|
443 |
|
// Allocate Slot Manager parameter block in Mac RAM |
444 |
|
M68kRegisters r; |
494 |
|
case cscSetEntries: // Set palette |
495 |
|
case cscDirectSetEntries: { |
496 |
|
D(bug(" (Direct)SetEntries table %08x, count %d, start %d\n", ReadMacInt32(param + csTable), ReadMacInt16(param + csCount), ReadMacInt16(param + csStart))); |
497 |
< |
bool is_direct = IsDirectMode(VidLocal.current_mode); |
497 |
> |
bool is_direct = IsDirectMode(VidLocal.desc->mode); |
498 |
|
if (code == cscSetEntries && is_direct) |
499 |
|
return controlErr; |
500 |
|
if (code == cscDirectSetEntries && !is_direct) |
589 |
|
0xffff0000, // 16 bpp |
590 |
|
0xffffffff // 32 bpp |
591 |
|
}; |
592 |
< |
uint32 p = VidLocal.desc->mac_frame_base; |
592 |
> |
uint32 frame_base = VidLocal.desc->mac_frame_base; |
593 |
|
uint32 pat = pattern[VidLocal.desc->mode.depth]; |
594 |
|
bool invert = (VidLocal.desc->mode.depth == VDEPTH_32BIT); |
595 |
|
for (uint32 y=0; y<VidLocal.desc->mode.y; y++) { |
596 |
|
for (uint32 x=0; x<VidLocal.desc->mode.bytes_per_row; x+=4) { |
597 |
< |
WriteMacInt32(p + x, pat); |
597 |
> |
WriteMacInt32(frame_base + x, pat); |
598 |
|
if (invert) |
599 |
|
pat = ~pat; |
600 |
|
} |
601 |
< |
p += VidLocal.desc->mode.bytes_per_row; |
601 |
> |
frame_base += VidLocal.desc->mode.bytes_per_row; |
602 |
|
pat = ~pat; |
603 |
|
} |
604 |
|
|
605 |
< |
if (IsDirectMode(VidLocal.current_mode)) |
605 |
> |
if (IsDirectMode(VidLocal.desc->mode)) |
606 |
|
load_ramp_palette(); |
607 |
|
|
608 |
|
return noErr; |
839 |
|
uint32 id = ReadMacInt32(param + csDisplayModeID); |
840 |
|
uint16 mode = ReadMacInt16(param + csDepthMode); |
841 |
|
D(bug(" GetVideoParameters %04x/%08x\n", mode, id)); |
842 |
+ |
VidLocal.dm_present = true; // Display Manager seems to be present |
843 |
|
|
844 |
|
vector<video_mode>::const_iterator i, end = VideoModes.end(); |
845 |
|
for (i = VideoModes.begin(); i != end; ++i) { |