67 |
|
|
68 |
|
static bool has_resolution(uint32 id) |
69 |
|
{ |
70 |
< |
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; |
74 |
– |
++i; |
74 |
|
} |
75 |
|
return false; |
76 |
|
} |
82 |
|
|
83 |
|
static vector<video_mode>::const_iterator find_mode(uint16 mode, uint32 id) |
84 |
|
{ |
85 |
< |
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; |
90 |
– |
++i; |
89 |
|
} |
90 |
|
return i; |
91 |
|
} |
98 |
|
static video_depth max_depth_of_resolution(uint32 id) |
99 |
|
{ |
100 |
|
video_depth m = VDEPTH_1BIT; |
101 |
< |
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; |
107 |
– |
++i; |
105 |
|
} |
106 |
|
return m; |
107 |
|
} |
113 |
|
|
114 |
|
static void get_size_of_resolution(uint32 id, uint32 &x, uint32 &y) |
115 |
|
{ |
116 |
< |
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 |
|
} |
126 |
– |
++i; |
123 |
|
} |
124 |
|
} |
125 |
|
|
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 |
+ |
|
339 |
+ |
/* |
340 |
|
* Driver Open() routine |
341 |
|
*/ |
342 |
|
|
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(); |
342 |
< |
video_switch_to_mode(*i); |
343 |
< |
VidLocal.current_mode = mode; |
344 |
< |
WriteMacInt32(param + csBaseAddr, VidLocal.desc->mac_frame_base); |
345 |
< |
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; |
557 |
|
vector<video_mode>::const_iterator i = find_mode(mode, id); |
558 |
|
if (i == VideoModes.end()) |
559 |
|
return paramErr; |
560 |
< |
set_gray_palette(); |
501 |
< |
video_switch_to_mode(*i); |
502 |
< |
VidLocal.current_mode = mode; |
503 |
< |
VidLocal.current_id = id; |
504 |
< |
uint32 frame_base = VidLocal.desc->mac_frame_base; |
505 |
< |
WriteMacInt32(param + csBaseAddr, frame_base); |
506 |
< |
|
507 |
< |
M68kRegisters r; |
508 |
< |
uint32 sp = VidLocal.slot_param; |
509 |
< |
r.a[0] = sp; |
510 |
< |
|
511 |
< |
// Find functional sResource for this display |
512 |
< |
WriteMacInt8(sp + spSlot, ReadMacInt8(dce + dCtlSlot)); |
513 |
< |
WriteMacInt8(sp + spID, ReadMacInt8(dce + dCtlSlotId)); |
514 |
< |
WriteMacInt8(sp + spExtDev, 0); |
515 |
< |
r.d[0] = 0x0016; |
516 |
< |
Execute68kTrap(0xa06e, &r); // SRsrcInfo() |
517 |
< |
uint32 rsrc = ReadMacInt32(sp + spPointer); |
518 |
< |
|
519 |
< |
// Patch minorBase (otherwise rebooting won't work) |
520 |
< |
WriteMacInt8(sp + spID, 0x0a); // minorBase |
521 |
< |
r.d[0] = 0x0006; |
522 |
< |
Execute68kTrap(0xa06e, &r); // SFindStruct() |
523 |
< |
uint32 minor_base = ReadMacInt32(sp + spPointer) - ROMBaseMac; |
524 |
< |
ROMBaseHost[minor_base + 0] = frame_base >> 24; |
525 |
< |
ROMBaseHost[minor_base + 1] = frame_base >> 16; |
526 |
< |
ROMBaseHost[minor_base + 2] = frame_base >> 8; |
527 |
< |
ROMBaseHost[minor_base + 3] = frame_base; |
528 |
< |
|
529 |
< |
// Patch video mode parameter table |
530 |
< |
WriteMacInt32(sp + spPointer, rsrc); |
531 |
< |
WriteMacInt8(sp + spID, mode); |
532 |
< |
r.d[0] = 0x0006; |
533 |
< |
Execute68kTrap(0xa06e, &r); // SFindStruct() |
534 |
< |
WriteMacInt8(sp + spID, 0x01); |
535 |
< |
r.d[0] = 0x0006; |
536 |
< |
Execute68kTrap(0xa06e, &r); // SFindStruct() |
537 |
< |
uint32 p = ReadMacInt32(sp + spPointer) - ROMBaseMac; |
538 |
< |
ROMBaseHost[p + 8] = i->bytes_per_row >> 8; |
539 |
< |
ROMBaseHost[p + 9] = i->bytes_per_row; |
540 |
< |
ROMBaseHost[p + 14] = i->y >> 8; |
541 |
< |
ROMBaseHost[p + 15] = i->y; |
542 |
< |
ROMBaseHost[p + 16] = i->x >> 8; |
543 |
< |
ROMBaseHost[p + 17] = i->x; |
544 |
< |
|
545 |
< |
// Recalculate slot ROM checksum |
546 |
< |
ChecksumSlotROM(); |
547 |
< |
|
548 |
< |
// Update sResource |
549 |
< |
WriteMacInt8(sp + spID, ReadMacInt8(dce + dCtlSlotId)); |
550 |
< |
r.d[0] = 0x002b; |
551 |
< |
Execute68kTrap(0xa06e, &r); // SUpdateSRT() |
552 |
< |
|
553 |
< |
// Update frame buffer base in DCE |
554 |
< |
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; |
757 |
|
uint16 mode = ReadMacInt16(param + csDepthMode); |
758 |
|
D(bug(" GetVideoParameters %04x/%08x\n", mode, id)); |
759 |
|
|
760 |
< |
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 |
|
} |
810 |
– |
++i; |
816 |
|
} |
817 |
|
return paramErr; // specified resolution/depth not supported |
818 |
|
} |