34 |
|
#include "video.h" |
35 |
|
#include "video_defs.h" |
36 |
|
|
37 |
< |
#define DEBUG 0 |
37 |
> |
#define DEBUG 1 |
38 |
|
#include "debug.h" |
39 |
|
|
40 |
|
|
63 |
|
|
64 |
|
static bool has_resolution(uint32 id) |
65 |
|
{ |
66 |
< |
vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end(); |
66 |
> |
std::vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end(); |
67 |
|
while (i != end) { |
68 |
|
if (i->resolution_id == id) |
69 |
|
return true; |
74 |
|
|
75 |
|
|
76 |
|
/* |
77 |
+ |
* Find specified mode (depth/resolution) (or VideoModes.end() if not found) |
78 |
+ |
*/ |
79 |
+ |
|
80 |
+ |
static std::vector<video_mode>::const_iterator find_mode(uint16 mode, uint32 id) |
81 |
+ |
{ |
82 |
+ |
std::vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end(); |
83 |
+ |
while (i != end) { |
84 |
+ |
if (i->resolution_id == id && DepthToAppleMode(i->depth) == mode) |
85 |
+ |
return i; |
86 |
+ |
++i; |
87 |
+ |
} |
88 |
+ |
return i; |
89 |
+ |
} |
90 |
+ |
|
91 |
+ |
|
92 |
+ |
/* |
93 |
|
* Find maximum supported depth for given resolution ID |
94 |
|
*/ |
95 |
|
|
172 |
|
case cscSetMode: { // Set color depth |
173 |
|
uint16 mode = ReadMacInt16(param + csMode); |
174 |
|
D(bug(" SetMode %04x\n", mode)); |
175 |
< |
//!! switch mode |
175 |
> |
|
176 |
> |
if (mode != VidLocal.current_mode) { |
177 |
> |
std::vector<video_mode>::const_iterator i = find_mode(mode, VidLocal.current_id); |
178 |
> |
if (i == VideoModes.end()) { |
179 |
> |
WriteMacInt32(param + csBaseAddr, VidLocal.desc->mac_frame_base); |
180 |
> |
return paramErr; |
181 |
> |
} |
182 |
> |
video_switch_to_mode(*i); |
183 |
> |
VidLocal.current_mode = mode; |
184 |
> |
} |
185 |
|
WriteMacInt32(param + csBaseAddr, VidLocal.desc->mac_frame_base); |
186 |
< |
//!! VidLocal.current_mode = mode; |
162 |
< |
if (mode != VidLocal.current_mode) |
163 |
< |
return paramErr; |
164 |
< |
else |
165 |
< |
return noErr; |
186 |
> |
return noErr; |
187 |
|
} |
188 |
|
|
189 |
|
case cscSetEntries: { // Set palette |
283 |
|
uint16 mode = ReadMacInt16(param + csMode); |
284 |
|
uint32 id = ReadMacInt32(param + csData); |
285 |
|
D(bug(" SwitchMode %04x, %08x\n", mode, id)); |
286 |
< |
//!! switch mode |
286 |
> |
|
287 |
> |
if (mode != VidLocal.current_mode || id != VidLocal.current_id) { |
288 |
> |
std::vector<video_mode>::const_iterator i = find_mode(mode, id); |
289 |
> |
if (i == VideoModes.end()) { |
290 |
> |
WriteMacInt32(param + csBaseAddr, VidLocal.desc->mac_frame_base); |
291 |
> |
return paramErr; |
292 |
> |
} |
293 |
> |
video_switch_to_mode(*i); |
294 |
> |
VidLocal.current_mode = mode; |
295 |
> |
VidLocal.current_id = id; |
296 |
> |
} |
297 |
|
WriteMacInt32(param + csBaseAddr, VidLocal.desc->mac_frame_base); |
298 |
< |
//!! VidLocal.current_mode = mode; |
268 |
< |
//!! VidLocal.current_id = id; |
269 |
< |
if (mode != VidLocal.current_mode || id != VidLocal.current_id) |
270 |
< |
return paramErr; |
271 |
< |
else |
272 |
< |
return noErr; |
298 |
> |
return noErr; |
299 |
|
} |
300 |
|
|
301 |
|
case cscSavePreferredConfiguration: { |