40 |
|
|
41 |
|
|
42 |
|
// List of supported video modes |
43 |
< |
std::vector<video_mode> VideoModes; |
43 |
> |
vector<video_mode> VideoModes; |
44 |
|
|
45 |
|
// Description of the main monitor |
46 |
|
monitor_desc VideoMonitor; |
52 |
|
bool luminance_mapping; // Luminance mapping on/off |
53 |
|
bool interrupts_enabled; // VBL interrupts on/off |
54 |
|
uint32 gamma_table; // Mac address of gamma table |
55 |
+ |
int alloc_gamma_table_size; // Allocated size of gamma table |
56 |
|
uint16 current_mode; // Currently selected depth/resolution |
57 |
|
uint32 current_id; |
58 |
|
uint16 preferred_mode; // Preferred depth/resolution |
59 |
|
uint32 preferred_id; |
60 |
< |
uint32 sp; // Mac address of Slot Manager parameter block |
60 |
> |
uint32 slot_param; // Mac address of Slot Manager parameter block |
61 |
|
} VidLocal; |
62 |
|
|
63 |
|
|
67 |
|
|
68 |
|
static bool has_resolution(uint32 id) |
69 |
|
{ |
70 |
< |
std::vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end(); |
71 |
< |
while (i != end) { |
70 |
> |
vector<video_mode>::const_iterator i, end = VideoModes.end(); |
71 |
> |
for (i = VideoModes.begin(); i != end; ++i) { |
72 |
|
if (i->resolution_id == id) |
73 |
|
return true; |
73 |
– |
++i; |
74 |
|
} |
75 |
|
return false; |
76 |
|
} |
80 |
|
* Find specified mode (depth/resolution) (or VideoModes.end() if not found) |
81 |
|
*/ |
82 |
|
|
83 |
< |
static std::vector<video_mode>::const_iterator find_mode(uint16 mode, uint32 id) |
83 |
> |
static vector<video_mode>::const_iterator find_mode(uint16 mode, uint32 id) |
84 |
|
{ |
85 |
< |
std::vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end(); |
86 |
< |
while (i != end) { |
85 |
> |
vector<video_mode>::const_iterator i, end = VideoModes.end(); |
86 |
> |
for (i = VideoModes.begin(); i != end; ++i) { |
87 |
|
if (i->resolution_id == id && DepthToAppleMode(i->depth) == mode) |
88 |
|
return i; |
89 |
– |
++i; |
89 |
|
} |
90 |
|
return i; |
91 |
|
} |
98 |
|
static video_depth max_depth_of_resolution(uint32 id) |
99 |
|
{ |
100 |
|
video_depth m = VDEPTH_1BIT; |
101 |
< |
std::vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end(); |
102 |
< |
while (i != end) { |
101 |
> |
vector<video_mode>::const_iterator i, end = VideoModes.end(); |
102 |
> |
for (i = VideoModes.begin(); i != end; ++i) { |
103 |
|
if (i->depth > m) |
104 |
|
m = i->depth; |
106 |
– |
++i; |
105 |
|
} |
106 |
|
return m; |
107 |
|
} |
113 |
|
|
114 |
|
static void get_size_of_resolution(uint32 id, uint32 &x, uint32 &y) |
115 |
|
{ |
116 |
< |
std::vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end(); |
117 |
< |
while (i != end) { |
116 |
> |
vector<video_mode>::const_iterator i, end = VideoModes.end(); |
117 |
> |
for (i = VideoModes.begin(); i != end; ++i) { |
118 |
|
if (i->resolution_id == id) { |
119 |
|
x = i->x; |
120 |
|
y = i->y; |
121 |
|
return; |
122 |
|
} |
125 |
– |
++i; |
123 |
|
} |
124 |
|
} |
125 |
|
|
130 |
|
|
131 |
|
static void set_gray_palette(void) |
132 |
|
{ |
133 |
< |
if (!IsDirectMode(VidLocal.current_mode)) { |
134 |
< |
for (int i=0; i<256; i++) { |
135 |
< |
VidLocal.palette[i * 3 + 0] = 127; |
136 |
< |
VidLocal.palette[i * 3 + 1] = 127; |
137 |
< |
VidLocal.palette[i * 3 + 2] = 127; |
133 |
> |
for (int i=0; i<256; i++) { |
134 |
> |
VidLocal.palette[i * 3 + 0] = 127; |
135 |
> |
VidLocal.palette[i * 3 + 1] = 127; |
136 |
> |
VidLocal.palette[i * 3 + 2] = 127; |
137 |
> |
} |
138 |
> |
video_set_palette(VidLocal.palette); |
139 |
> |
} |
140 |
> |
|
141 |
> |
|
142 |
> |
/* |
143 |
> |
* Load gamma-corrected black-to-white ramp to palette for direct-color mode |
144 |
> |
*/ |
145 |
> |
|
146 |
> |
static void load_ramp_palette(void) |
147 |
> |
{ |
148 |
> |
// Find tables for gamma correction |
149 |
> |
uint8 *red_gamma, *green_gamma, *blue_gamma; |
150 |
> |
bool have_gamma = false; |
151 |
> |
int data_width = 0; |
152 |
> |
if (VidLocal.gamma_table) { |
153 |
> |
uint32 table = VidLocal.gamma_table; |
154 |
> |
red_gamma = Mac2HostAddr(table + gFormulaData + ReadMacInt16(table + gFormulaSize)); |
155 |
> |
int chan_cnt = ReadMacInt16(table + gChanCnt); |
156 |
> |
if (chan_cnt == 1) |
157 |
> |
green_gamma = blue_gamma = red_gamma; |
158 |
> |
else { |
159 |
> |
int ofs = ReadMacInt16(table + gDataCnt); |
160 |
> |
green_gamma = red_gamma + ofs; |
161 |
> |
blue_gamma = green_gamma + ofs; |
162 |
|
} |
163 |
< |
video_set_palette(VidLocal.palette); |
163 |
> |
data_width = ReadMacInt16(table + gDataWidth); |
164 |
> |
have_gamma = true; |
165 |
> |
} |
166 |
> |
|
167 |
> |
int num = (VidLocal.desc->mode.depth == VDEPTH_16BIT ? 32 : 256); |
168 |
> |
uint8 *p = VidLocal.palette; |
169 |
> |
for (int i=0; i<num; i++) { |
170 |
> |
uint8 red = (i * 256 / num), green = red, blue = red; |
171 |
> |
if (have_gamma) { |
172 |
> |
red = red_gamma[red >> (8 - data_width)]; |
173 |
> |
green = green_gamma[green >> (8 - data_width)]; |
174 |
> |
blue = blue_gamma[blue >> (8 - data_width)]; |
175 |
> |
} |
176 |
> |
*p++ = red; |
177 |
> |
*p++ = green; |
178 |
> |
*p++ = blue; |
179 |
> |
} |
180 |
> |
|
181 |
> |
video_set_palette(VidLocal.palette); |
182 |
> |
} |
183 |
> |
|
184 |
> |
|
185 |
> |
/* |
186 |
> |
* Allocate gamma table of specified size |
187 |
> |
*/ |
188 |
> |
|
189 |
> |
static bool allocate_gamma_table(int size) |
190 |
> |
{ |
191 |
> |
M68kRegisters r; |
192 |
> |
|
193 |
> |
if (size > VidLocal.alloc_gamma_table_size) { |
194 |
> |
if (VidLocal.gamma_table) { |
195 |
> |
r.a[0] = VidLocal.gamma_table; |
196 |
> |
Execute68kTrap(0xa01f, &r); // DisposePtr() |
197 |
> |
VidLocal.gamma_table = 0; |
198 |
> |
VidLocal.alloc_gamma_table_size = 0; |
199 |
> |
} |
200 |
> |
r.d[0] = size; |
201 |
> |
Execute68kTrap(0xa71e, &r); // NewPtrSysClear() |
202 |
> |
if (r.a[0] == 0) |
203 |
> |
return false; |
204 |
> |
VidLocal.gamma_table = r.a[0]; |
205 |
> |
VidLocal.alloc_gamma_table_size = size; |
206 |
> |
} |
207 |
> |
return true; |
208 |
> |
} |
209 |
> |
|
210 |
> |
|
211 |
> |
/* |
212 |
> |
* Set gamma table (0 = build linear ramp) |
213 |
> |
*/ |
214 |
> |
|
215 |
> |
static bool set_gamma_table(uint32 user_table) |
216 |
> |
{ |
217 |
> |
if (user_table == 0) { // Build linear ramp, 256 entries |
218 |
> |
|
219 |
> |
// Allocate new table, if necessary |
220 |
> |
if (!allocate_gamma_table(SIZEOF_GammaTbl + 256)) |
221 |
> |
return memFullErr; |
222 |
> |
uint32 table = VidLocal.gamma_table; |
223 |
> |
|
224 |
> |
// Initialize header |
225 |
> |
WriteMacInt16(table + gVersion, 0); |
226 |
> |
WriteMacInt16(table + gType, 0); |
227 |
> |
WriteMacInt16(table + gFormulaSize, 0); |
228 |
> |
WriteMacInt16(table + gChanCnt, 1); |
229 |
> |
WriteMacInt16(table + gDataCnt, 256); |
230 |
> |
WriteMacInt16(table + gDataWidth, 8); |
231 |
> |
|
232 |
> |
// Build ramp |
233 |
> |
uint32 p = table + gFormulaData; |
234 |
> |
for (int i=0; i<256; i++) |
235 |
> |
WriteMacInt8(p + i, i); |
236 |
> |
|
237 |
> |
} else { // User-supplied gamma table |
238 |
> |
|
239 |
> |
// Validate header |
240 |
> |
if (ReadMacInt16(user_table + gVersion)) |
241 |
> |
return paramErr; |
242 |
> |
if (ReadMacInt16(user_table + gType)) |
243 |
> |
return paramErr; |
244 |
> |
int chan_cnt = ReadMacInt16(user_table + gChanCnt); |
245 |
> |
if (chan_cnt != 1 && chan_cnt != 3) |
246 |
> |
return paramErr; |
247 |
> |
int data_width = ReadMacInt16(user_table + gDataWidth); |
248 |
> |
if (data_width > 8) |
249 |
> |
return paramErr; |
250 |
> |
int data_cnt = ReadMacInt16(user_table + gDataCnt); |
251 |
> |
if (data_cnt != (1 << data_width)) |
252 |
> |
return paramErr; |
253 |
> |
|
254 |
> |
// Allocate new table, if necessary |
255 |
> |
int size = SIZEOF_GammaTbl + ReadMacInt16(user_table + gFormulaSize) + chan_cnt * data_cnt; |
256 |
> |
if (!allocate_gamma_table(size)) |
257 |
> |
return memFullErr; |
258 |
> |
uint32 table = VidLocal.gamma_table; |
259 |
> |
|
260 |
> |
// Copy table |
261 |
> |
Mac2Mac_memcpy(table, user_table, size); |
262 |
|
} |
263 |
+ |
|
264 |
+ |
if (IsDirectMode(VidLocal.current_mode)) |
265 |
+ |
load_ramp_palette(); |
266 |
+ |
|
267 |
+ |
return true; |
268 |
+ |
} |
269 |
+ |
|
270 |
+ |
|
271 |
+ |
/* |
272 |
+ |
* Switch video mode |
273 |
+ |
*/ |
274 |
+ |
|
275 |
+ |
static void switch_mode(const video_mode &mode, uint32 param, uint32 dce) |
276 |
+ |
{ |
277 |
+ |
// Switch mode |
278 |
+ |
set_gray_palette(); |
279 |
+ |
video_switch_to_mode(mode); |
280 |
+ |
|
281 |
+ |
// Update VidLocal |
282 |
+ |
VidLocal.current_mode = DepthToAppleMode(mode.depth); |
283 |
+ |
VidLocal.current_id = mode.resolution_id; |
284 |
+ |
|
285 |
+ |
uint32 frame_base = VidLocal.desc->mac_frame_base; |
286 |
+ |
|
287 |
+ |
M68kRegisters r; |
288 |
+ |
uint32 sp = VidLocal.slot_param; |
289 |
+ |
r.a[0] = sp; |
290 |
+ |
|
291 |
+ |
// Find functional sResource for this display |
292 |
+ |
WriteMacInt8(sp + spSlot, ReadMacInt8(dce + dCtlSlot)); |
293 |
+ |
WriteMacInt8(sp + spID, ReadMacInt8(dce + dCtlSlotId)); |
294 |
+ |
WriteMacInt8(sp + spExtDev, 0); |
295 |
+ |
r.d[0] = 0x0016; |
296 |
+ |
Execute68kTrap(0xa06e, &r); // SRsrcInfo() |
297 |
+ |
uint32 rsrc = ReadMacInt32(sp + spPointer); |
298 |
+ |
|
299 |
+ |
// Patch minorBase (otherwise rebooting won't work) |
300 |
+ |
WriteMacInt8(sp + spID, 0x0a); // minorBase |
301 |
+ |
r.d[0] = 0x0006; |
302 |
+ |
Execute68kTrap(0xa06e, &r); // SFindStruct() |
303 |
+ |
uint32 minor_base = ReadMacInt32(sp + spPointer) - ROMBaseMac; |
304 |
+ |
ROMBaseHost[minor_base + 0] = frame_base >> 24; |
305 |
+ |
ROMBaseHost[minor_base + 1] = frame_base >> 16; |
306 |
+ |
ROMBaseHost[minor_base + 2] = frame_base >> 8; |
307 |
+ |
ROMBaseHost[minor_base + 3] = frame_base; |
308 |
+ |
|
309 |
+ |
// Patch video mode parameter table |
310 |
+ |
WriteMacInt32(sp + spPointer, rsrc); |
311 |
+ |
WriteMacInt8(sp + spID, DepthToAppleMode(mode.depth)); |
312 |
+ |
r.d[0] = 0x0006; |
313 |
+ |
Execute68kTrap(0xa06e, &r); // SFindStruct() |
314 |
+ |
WriteMacInt8(sp + spID, 0x01); |
315 |
+ |
r.d[0] = 0x0006; |
316 |
+ |
Execute68kTrap(0xa06e, &r); // SFindStruct() |
317 |
+ |
uint32 p = ReadMacInt32(sp + spPointer) - ROMBaseMac; |
318 |
+ |
ROMBaseHost[p + 8] = mode.bytes_per_row >> 8; |
319 |
+ |
ROMBaseHost[p + 9] = mode.bytes_per_row; |
320 |
+ |
ROMBaseHost[p + 14] = mode.y >> 8; |
321 |
+ |
ROMBaseHost[p + 15] = mode.y; |
322 |
+ |
ROMBaseHost[p + 16] = mode.x >> 8; |
323 |
+ |
ROMBaseHost[p + 17] = mode.x; |
324 |
+ |
|
325 |
+ |
// Recalculate slot ROM checksum |
326 |
+ |
ChecksumSlotROM(); |
327 |
+ |
|
328 |
+ |
// Update sResource |
329 |
+ |
WriteMacInt8(sp + spID, ReadMacInt8(dce + dCtlSlotId)); |
330 |
+ |
r.d[0] = 0x002b; |
331 |
+ |
Execute68kTrap(0xa06e, &r); // SUpdateSRT() |
332 |
+ |
|
333 |
+ |
// Update frame buffer base in DCE and param block |
334 |
+ |
WriteMacInt32(dce + dCtlDevBase, frame_base); |
335 |
+ |
WriteMacInt32(param + csBaseAddr, frame_base); |
336 |
|
} |
337 |
|
|
338 |
|
|
363 |
|
Execute68kTrap(0xa71e, &r); // NewPtrSysClear() |
364 |
|
if (r.a[0] == 0) |
365 |
|
return memFullErr; |
366 |
< |
VidLocal.sp = r.a[0]; |
367 |
< |
D(bug("SPBlock at %08x\n", VidLocal.sp)); |
366 |
> |
VidLocal.slot_param = r.a[0]; |
367 |
> |
D(bug("SPBlock at %08x\n", VidLocal.slot_param)); |
368 |
|
|
369 |
|
// Find and set default gamma table |
370 |
< |
VidLocal.gamma_table = 0; //!! |
370 |
> |
VidLocal.gamma_table = 0; |
371 |
> |
VidLocal.alloc_gamma_table_size = 0; |
372 |
> |
set_gamma_table(0); |
373 |
|
|
374 |
|
// Init color palette (solid gray) |
375 |
|
set_gray_palette(); |
399 |
|
return paramErr; |
400 |
|
|
401 |
|
if (mode != VidLocal.current_mode) { |
402 |
< |
std::vector<video_mode>::const_iterator i = find_mode(mode, VidLocal.current_id); |
402 |
> |
vector<video_mode>::const_iterator i = find_mode(mode, VidLocal.current_id); |
403 |
|
if (i == VideoModes.end()) |
404 |
|
return paramErr; |
405 |
< |
set_gray_palette(); |
212 |
< |
video_switch_to_mode(*i); |
213 |
< |
VidLocal.current_mode = mode; |
214 |
< |
WriteMacInt32(param + csBaseAddr, VidLocal.desc->mac_frame_base); |
215 |
< |
WriteMacInt32(dce + dCtlDevBase, VidLocal.desc->mac_frame_base); |
405 |
> |
switch_mode(*i, param, dce); |
406 |
|
} |
407 |
|
D(bug(" base %08x\n", VidLocal.desc->mac_frame_base)); |
408 |
|
return noErr; |
409 |
|
} |
410 |
|
|
411 |
< |
case cscSetEntries: { // Set palette |
412 |
< |
D(bug(" SetEntries table %08x, count %d, start %d\n", ReadMacInt32(param + csTable), ReadMacInt16(param + csCount), ReadMacInt16(param + csStart))); |
413 |
< |
if (IsDirectMode(VidLocal.current_mode)) |
411 |
> |
case cscSetEntries: // Set palette |
412 |
> |
case cscDirectSetEntries: { |
413 |
> |
D(bug(" (Direct)SetEntries table %08x, count %d, start %d\n", ReadMacInt32(param + csTable), ReadMacInt16(param + csCount), ReadMacInt16(param + csStart))); |
414 |
> |
bool is_direct = IsDirectMode(VidLocal.current_mode); |
415 |
> |
if (code == cscSetEntries && is_direct) |
416 |
> |
return controlErr; |
417 |
> |
if (code == cscDirectSetEntries && !is_direct) |
418 |
|
return controlErr; |
419 |
|
|
420 |
|
uint32 s_pal = ReadMacInt32(param + csTable); // Source palette |
424 |
|
if (s_pal == 0 || count > 255) |
425 |
|
return paramErr; |
426 |
|
|
427 |
+ |
// Find tables for gamma correction |
428 |
+ |
uint8 *red_gamma, *green_gamma, *blue_gamma; |
429 |
+ |
bool have_gamma = false; |
430 |
+ |
int data_width = 0; |
431 |
+ |
if (VidLocal.gamma_table) { |
432 |
+ |
uint32 table = VidLocal.gamma_table; |
433 |
+ |
red_gamma = Mac2HostAddr(table + gFormulaData + ReadMacInt16(table + gFormulaSize)); |
434 |
+ |
int chan_cnt = ReadMacInt16(table + gChanCnt); |
435 |
+ |
if (chan_cnt == 1) |
436 |
+ |
green_gamma = blue_gamma = red_gamma; |
437 |
+ |
else { |
438 |
+ |
int ofs = ReadMacInt16(table + gDataCnt); |
439 |
+ |
green_gamma = red_gamma + ofs; |
440 |
+ |
blue_gamma = green_gamma + ofs; |
441 |
+ |
} |
442 |
+ |
data_width = ReadMacInt16(table + gDataWidth); |
443 |
+ |
have_gamma = true; |
444 |
+ |
} |
445 |
+ |
|
446 |
+ |
// Convert palette |
447 |
|
if (start == 0xffff) { // Indexed |
448 |
|
for (uint32 i=0; i<=count; i++) { |
449 |
|
d_pal = VidLocal.palette + (ReadMacInt16(s_pal) & 0xff) * 3; |
450 |
|
uint8 red = (uint16)ReadMacInt16(s_pal + 2) >> 8; |
451 |
|
uint8 green = (uint16)ReadMacInt16(s_pal + 4) >> 8; |
452 |
|
uint8 blue = (uint16)ReadMacInt16(s_pal + 6) >> 8; |
453 |
< |
if (VidLocal.luminance_mapping) |
453 |
> |
if (VidLocal.luminance_mapping && !is_direct) |
454 |
|
red = green = blue = (red * 0x4ccc + green * 0x970a + blue * 0x1c29) >> 16; |
455 |
< |
//!! gamma correction |
455 |
> |
if (have_gamma) { |
456 |
> |
red = red_gamma[red >> (8 - data_width)]; |
457 |
> |
green = green_gamma[green >> (8 - data_width)]; |
458 |
> |
blue = blue_gamma[blue >> (8 - data_width)]; |
459 |
> |
} |
460 |
|
*d_pal++ = red; |
461 |
|
*d_pal++ = green; |
462 |
|
*d_pal++ = blue; |
470 |
|
uint8 red = (uint16)ReadMacInt16(s_pal + 2) >> 8; |
471 |
|
uint8 green = (uint16)ReadMacInt16(s_pal + 4) >> 8; |
472 |
|
uint8 blue = (uint16)ReadMacInt16(s_pal + 6) >> 8; |
473 |
< |
if (VidLocal.luminance_mapping) |
473 |
> |
if (VidLocal.luminance_mapping && !is_direct) |
474 |
|
red = green = blue = (red * 0x4ccc + green * 0x970a + blue * 0x1c29) >> 16; |
475 |
< |
//!! gamma correction |
475 |
> |
if (have_gamma) { |
476 |
> |
red = red_gamma[red >> (8 - data_width)]; |
477 |
> |
green = green_gamma[green >> (8 - data_width)]; |
478 |
> |
blue = blue_gamma[blue >> (8 - data_width)]; |
479 |
> |
} |
480 |
|
*d_pal++ = red; |
481 |
|
*d_pal++ = green; |
482 |
|
*d_pal++ = blue; |
487 |
|
return noErr; |
488 |
|
} |
489 |
|
|
490 |
< |
case cscSetGamma: // Set gamma table |
491 |
< |
D(bug(" SetGamma\n")); |
492 |
< |
//!! |
493 |
< |
return controlErr; |
490 |
> |
case cscSetGamma: { // Set gamma table |
491 |
> |
uint32 user_table = ReadMacInt32(param + csGTable); |
492 |
> |
D(bug(" SetGamma %08x\n", user_table)); |
493 |
> |
return set_gamma_table(user_table) ? noErr : memFullErr; |
494 |
> |
} |
495 |
|
|
496 |
|
case cscGrayPage: { // Fill page with dithered gray pattern |
497 |
|
D(bug(" GrayPage %d\n", ReadMacInt16(param + csPage))); |
518 |
|
p += VidLocal.desc->mode.bytes_per_row; |
519 |
|
pat = ~pat; |
520 |
|
} |
521 |
< |
//!! if direct mode, load gamma table to CLUT |
521 |
> |
|
522 |
> |
if (IsDirectMode(VidLocal.current_mode)) |
523 |
> |
load_ramp_palette(); |
524 |
> |
|
525 |
|
return noErr; |
526 |
|
} |
527 |
|
|
554 |
|
return paramErr; |
555 |
|
|
556 |
|
if (mode != VidLocal.current_mode || id != VidLocal.current_id) { |
557 |
< |
std::vector<video_mode>::const_iterator i = find_mode(mode, id); |
557 |
> |
vector<video_mode>::const_iterator i = find_mode(mode, id); |
558 |
|
if (i == VideoModes.end()) |
559 |
|
return paramErr; |
560 |
< |
set_gray_palette(); |
335 |
< |
video_switch_to_mode(*i); |
336 |
< |
VidLocal.current_mode = mode; |
337 |
< |
VidLocal.current_id = id; |
338 |
< |
uint32 frame_base = VidLocal.desc->mac_frame_base; |
339 |
< |
WriteMacInt32(param + csBaseAddr, frame_base); |
340 |
< |
|
341 |
< |
M68kRegisters r; |
342 |
< |
uint32 sp = VidLocal.sp; |
343 |
< |
r.a[0] = sp; |
344 |
< |
|
345 |
< |
// Find functional sResource for this display |
346 |
< |
WriteMacInt8(sp + spSlot, ReadMacInt8(dce + dCtlSlot)); |
347 |
< |
WriteMacInt8(sp + spID, ReadMacInt8(dce + dCtlSlotId)); |
348 |
< |
WriteMacInt8(sp + spExtDev, 0); |
349 |
< |
r.d[0] = 0x0016; |
350 |
< |
Execute68kTrap(0xa06e, &r); // SRsrcInfo() |
351 |
< |
uint32 rsrc = ReadMacInt32(sp + spPointer); |
352 |
< |
|
353 |
< |
// Patch minorBase (otherwise rebooting won't work) |
354 |
< |
WriteMacInt8(sp + spID, 0x0a); // minorBase |
355 |
< |
r.d[0] = 0x0006; |
356 |
< |
Execute68kTrap(0xa06e, &r); // SFindStruct() |
357 |
< |
uint32 minor_base = ReadMacInt32(sp + spPointer) - ROMBaseMac; |
358 |
< |
ROMBaseHost[minor_base + 0] = frame_base >> 24; |
359 |
< |
ROMBaseHost[minor_base + 1] = frame_base >> 16; |
360 |
< |
ROMBaseHost[minor_base + 2] = frame_base >> 8; |
361 |
< |
ROMBaseHost[minor_base + 3] = frame_base; |
362 |
< |
|
363 |
< |
// Patch video mode parameter table |
364 |
< |
WriteMacInt32(sp + spPointer, rsrc); |
365 |
< |
WriteMacInt8(sp + spID, mode); |
366 |
< |
r.d[0] = 0x0006; |
367 |
< |
Execute68kTrap(0xa06e, &r); // SFindStruct() |
368 |
< |
WriteMacInt8(sp + spID, 0x01); |
369 |
< |
r.d[0] = 0x0006; |
370 |
< |
Execute68kTrap(0xa06e, &r); // SFindStruct() |
371 |
< |
uint32 p = ReadMacInt32(sp + spPointer) - ROMBaseMac; |
372 |
< |
ROMBaseHost[p + 8] = i->bytes_per_row >> 8; |
373 |
< |
ROMBaseHost[p + 9] = i->bytes_per_row; |
374 |
< |
ROMBaseHost[p + 14] = i->y >> 8; |
375 |
< |
ROMBaseHost[p + 15] = i->y; |
376 |
< |
ROMBaseHost[p + 16] = i->x >> 8; |
377 |
< |
ROMBaseHost[p + 17] = i->x; |
378 |
< |
|
379 |
< |
// Recalculate slot ROM checksum |
380 |
< |
ChecksumSlotROM(); |
381 |
< |
|
382 |
< |
// Update sResource |
383 |
< |
WriteMacInt8(sp + spID, ReadMacInt8(dce + dCtlSlotId)); |
384 |
< |
r.d[0] = 0x002b; |
385 |
< |
Execute68kTrap(0xa06e, &r); // SUpdateSRT() |
386 |
< |
|
387 |
< |
// Update frame buffer base in DCE |
388 |
< |
WriteMacInt32(dce + dCtlDevBase, frame_base); |
560 |
> |
switch_mode(*i, param, dce); |
561 |
|
} |
562 |
|
D(bug(" base %08x\n", VidLocal.desc->mac_frame_base)); |
563 |
|
return noErr; |
659 |
|
return noErr; |
660 |
|
|
661 |
|
case cscGetGamma: |
662 |
< |
D(bug(" GetGamma -> \n")); |
663 |
< |
//!! |
664 |
< |
return statusErr; |
662 |
> |
D(bug(" GetGamma -> %08x\n", VidLocal.gamma_table)); |
663 |
> |
WriteMacInt32(param + csGTable, VidLocal.gamma_table); |
664 |
> |
return noErr; |
665 |
|
|
666 |
|
case cscGetDefaultMode: // Get default color depth |
667 |
|
D(bug(" GetDefaultMode -> %04x\n", VidLocal.preferred_mode)); |
757 |
|
uint16 mode = ReadMacInt16(param + csDepthMode); |
758 |
|
D(bug(" GetVideoParameters %04x/%08x\n", mode, id)); |
759 |
|
|
760 |
< |
std::vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end(); |
761 |
< |
while (i != end) { |
760 |
> |
vector<video_mode>::const_iterator i, end = VideoModes.end(); |
761 |
> |
for (i = VideoModes.begin(); i != end; ++i) { |
762 |
|
if (DepthToAppleMode(i->depth) == mode && i->resolution_id == id) { |
763 |
|
uint32 vp = ReadMacInt32(param + csVPBlockPtr); |
764 |
|
WriteMacInt32(vp + vpBaseOffset, 0); |
813 |
|
WriteMacInt32(param + csDeviceType, dev_type); |
814 |
|
return noErr; |
815 |
|
} |
644 |
– |
++i; |
816 |
|
} |
817 |
|
return paramErr; // specified resolution/depth not supported |
818 |
|
} |