mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-02-17 06:31:14 +00:00
AmigaOS: Improved video mode switching - more strict error checking
This commit is contained in:
parent
583f0cdbbf
commit
e3e86a68a9
@ -188,6 +188,12 @@ int main(int argc, char **argv)
|
|||||||
QuitEmulator();
|
QuitEmulator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FindTask((UBYTE *) "« Enforcer »"))
|
||||||
|
{
|
||||||
|
ErrorAlert(STR_ENFORCER_RUNNING_ERR);
|
||||||
|
QuitEmulator();
|
||||||
|
}
|
||||||
|
|
||||||
// These two can fail (the respective gfx support won't be available, then)
|
// These two can fail (the respective gfx support won't be available, then)
|
||||||
P96Base = OpenLibrary((UBYTE *)"Picasso96API.library", 2);
|
P96Base = OpenLibrary((UBYTE *)"Picasso96API.library", 2);
|
||||||
CyberGfxBase = OpenLibrary((UBYTE *)"cybergraphics.library", 2);
|
CyberGfxBase = OpenLibrary((UBYTE *)"cybergraphics.library", 2);
|
||||||
|
@ -40,6 +40,8 @@ user_string_def platform_strings[] = {
|
|||||||
{STR_NO_VIDEO_MODE_ERR, "Cannot obtain selected video mode."},
|
{STR_NO_VIDEO_MODE_ERR, "Cannot obtain selected video mode."},
|
||||||
{STR_WRONG_SCREEN_DEPTH_ERR, "Basilisk II only supports 8, 16 or 24 bit screens."},
|
{STR_WRONG_SCREEN_DEPTH_ERR, "Basilisk II only supports 8, 16 or 24 bit screens."},
|
||||||
{STR_WRONG_SCREEN_FORMAT_ERR, "Basilisk II only supports big-endian chunky ARGB screen modes."},
|
{STR_WRONG_SCREEN_FORMAT_ERR, "Basilisk II only supports big-endian chunky ARGB screen modes."},
|
||||||
|
{STR_ENFORCER_RUNNING_ERR, "Enforcer/CyberGuard is running. Remove and then try again to start Basilisk II."},
|
||||||
|
|
||||||
{STR_NOT_ETHERNET_WARN, "The selected network device is not an Ethernet device. Networking will be disabled."},
|
{STR_NOT_ETHERNET_WARN, "The selected network device is not an Ethernet device. Networking will be disabled."},
|
||||||
{STR_NO_MULTICAST_WARN, "Your Ethernet card does not support multicast and is not usable with AppleTalk. Please report this to the manufacturer of the card."},
|
{STR_NO_MULTICAST_WARN, "Your Ethernet card does not support multicast and is not usable with AppleTalk. Please report this to the manufacturer of the card."},
|
||||||
{STR_NO_GTLAYOUT_LIB_WARN, "Cannot open gtlayout.library V39. The preferences editor GUI will not be available."},
|
{STR_NO_GTLAYOUT_LIB_WARN, "Cannot open gtlayout.library V39. The preferences editor GUI will not be available."},
|
||||||
|
@ -31,6 +31,7 @@ enum {
|
|||||||
STR_NO_VIDEO_MODE_ERR,
|
STR_NO_VIDEO_MODE_ERR,
|
||||||
STR_WRONG_SCREEN_DEPTH_ERR,
|
STR_WRONG_SCREEN_DEPTH_ERR,
|
||||||
STR_WRONG_SCREEN_FORMAT_ERR,
|
STR_WRONG_SCREEN_FORMAT_ERR,
|
||||||
|
STR_ENFORCER_RUNNING_ERR,
|
||||||
|
|
||||||
STR_NOT_ETHERNET_WARN,
|
STR_NOT_ETHERNET_WARN,
|
||||||
STR_NO_MULTICAST_WARN,
|
STR_NO_MULTICAST_WARN,
|
||||||
|
@ -97,6 +97,9 @@ static void add_mode(uint32 width, uint32 height, uint32 resolution_id, uint32 b
|
|||||||
static void add_modes(uint32 width, uint32 height, video_depth depth);
|
static void add_modes(uint32 width, uint32 height, video_depth depth);
|
||||||
static ULONG find_mode_for_depth(uint32 width, uint32 height, uint32 depth);
|
static ULONG find_mode_for_depth(uint32 width, uint32 height, uint32 depth);
|
||||||
static ULONG bits_from_depth(video_depth depth);
|
static ULONG bits_from_depth(video_depth depth);
|
||||||
|
static bool is_valid_modeid(int display_type, ULONG mode_id);
|
||||||
|
static bool check_modeid_p96(ULONG mode_id);
|
||||||
|
static bool check_modeid_cgfx(ULONG mode_id);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -197,32 +200,14 @@ static bool init_screen_p96(ULONG mode_id)
|
|||||||
ADBSetRelMouseMode(true);
|
ADBSetRelMouseMode(true);
|
||||||
|
|
||||||
// Check if the mode is one we can handle
|
// Check if the mode is one we can handle
|
||||||
uint32 depth = p96GetModeIDAttr(mode_id, P96IDA_DEPTH);
|
if (!check_modeid_p96(mode_id))
|
||||||
uint32 format = p96GetModeIDAttr(mode_id, P96IDA_RGBFORMAT);
|
{
|
||||||
|
ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR);
|
||||||
switch (depth) {
|
return false;
|
||||||
case 8:
|
}
|
||||||
break;
|
|
||||||
case 15:
|
|
||||||
case 16:
|
|
||||||
if (format != RGBFB_R5G5B5) {
|
|
||||||
ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 24:
|
|
||||||
case 32:
|
|
||||||
if (format != RGBFB_A8R8G8B8) {
|
|
||||||
ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ErrorAlert(STR_WRONG_SCREEN_DEPTH_ERR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Yes, get width and height
|
// Yes, get width and height
|
||||||
|
uint32 depth = p96GetModeIDAttr(mode_id, P96IDA_DEPTH);
|
||||||
uint32 width = p96GetModeIDAttr(mode_id, P96IDA_WIDTH);
|
uint32 width = p96GetModeIDAttr(mode_id, P96IDA_WIDTH);
|
||||||
uint32 height = p96GetModeIDAttr(mode_id, P96IDA_HEIGHT);
|
uint32 height = p96GetModeIDAttr(mode_id, P96IDA_HEIGHT);
|
||||||
|
|
||||||
@ -274,33 +259,14 @@ static bool init_screen_cgfx(ULONG mode_id)
|
|||||||
ADBSetRelMouseMode(true);
|
ADBSetRelMouseMode(true);
|
||||||
|
|
||||||
// Check if the mode is one we can handle
|
// Check if the mode is one we can handle
|
||||||
uint32 depth = GetCyberIDAttr(CYBRIDATTR_DEPTH, mode_id);
|
if (!check_modeid_cgfx(mode_id))
|
||||||
uint32 format = GetCyberIDAttr(CYBRIDATTR_PIXFMT, mode_id);
|
{
|
||||||
|
ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR);
|
||||||
switch (depth) {
|
return false;
|
||||||
case 8:
|
}
|
||||||
break;
|
|
||||||
case 15:
|
|
||||||
case 16:
|
|
||||||
// !!! PIXFMT_RGB15 is correct !!!
|
|
||||||
if (format != PIXFMT_RGB15) {
|
|
||||||
ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 24:
|
|
||||||
case 32:
|
|
||||||
if (format != PIXFMT_ARGB32) {
|
|
||||||
ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ErrorAlert(STR_WRONG_SCREEN_DEPTH_ERR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Yes, get width and height
|
// Yes, get width and height
|
||||||
|
uint32 depth = GetCyberIDAttr(CYBRIDATTR_DEPTH, mode_id);
|
||||||
uint32 width = GetCyberIDAttr(CYBRIDATTR_WIDTH, mode_id);
|
uint32 width = GetCyberIDAttr(CYBRIDATTR_WIDTH, mode_id);
|
||||||
uint32 height = GetCyberIDAttr(CYBRIDATTR_HEIGHT, mode_id);
|
uint32 height = GetCyberIDAttr(CYBRIDATTR_HEIGHT, mode_id);
|
||||||
|
|
||||||
@ -429,9 +395,11 @@ bool VideoInit(bool classic)
|
|||||||
default_height = 1 + dimInfo.Nominal.MaxY - dimInfo.Nominal.MinY;
|
default_height = 1 + dimInfo.Nominal.MaxY - dimInfo.Nominal.MinY;
|
||||||
default_depth = dimInfo.MaxDepth;
|
default_depth = dimInfo.MaxDepth;
|
||||||
|
|
||||||
for (unsigned d=VDEPTH_1BIT; d<=VDEPTH_32BIT; d++)
|
for (unsigned d=VDEPTH_8BIT; d<=VDEPTH_32BIT; d++)
|
||||||
{
|
{
|
||||||
if (INVALID_ID != find_mode_for_depth(default_width, default_height, bits_from_depth(video_depth(d))))
|
ULONG mode_id = find_mode_for_depth(default_width, default_height, bits_from_depth(video_depth(d)));
|
||||||
|
|
||||||
|
if (is_valid_modeid(display_type, mode_id))
|
||||||
{
|
{
|
||||||
add_modes(default_width, default_height, video_depth(d));
|
add_modes(default_width, default_height, video_depth(d));
|
||||||
}
|
}
|
||||||
@ -877,6 +845,7 @@ static ULONG find_mode_for_depth(uint32 width, uint32 height, uint32 depth)
|
|||||||
ULONG ID = BestModeID(BIDTAG_NominalWidth, width,
|
ULONG ID = BestModeID(BIDTAG_NominalWidth, width,
|
||||||
BIDTAG_NominalHeight, height,
|
BIDTAG_NominalHeight, height,
|
||||||
BIDTAG_Depth, depth,
|
BIDTAG_Depth, depth,
|
||||||
|
BIDTAG_DIPFMustNotHave, DIPF_IS_ECS | DIPF_IS_HAM | DIPF_IS_AA,
|
||||||
TAG_END);
|
TAG_END);
|
||||||
|
|
||||||
return ID;
|
return ID;
|
||||||
@ -894,3 +863,85 @@ static ULONG bits_from_depth(video_depth depth)
|
|||||||
return bits;
|
return bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool is_valid_modeid(int display_type, ULONG mode_id)
|
||||||
|
{
|
||||||
|
if (INVALID_ID == mode_id)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch (display_type)
|
||||||
|
{
|
||||||
|
case DISPLAY_SCREEN_P96:
|
||||||
|
return check_modeid_p96(mode_id);
|
||||||
|
break;
|
||||||
|
case DISPLAY_SCREEN_CGFX:
|
||||||
|
return check_modeid_cgfx(mode_id);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool check_modeid_p96(ULONG mode_id)
|
||||||
|
{
|
||||||
|
// Check if the mode is one we can handle
|
||||||
|
uint32 depth = p96GetModeIDAttr(mode_id, P96IDA_DEPTH);
|
||||||
|
uint32 format = p96GetModeIDAttr(mode_id, P96IDA_RGBFORMAT);
|
||||||
|
|
||||||
|
if (!p96GetModeIDAttr(screen_mode_id, P96IDA_ISP96))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch (depth) {
|
||||||
|
case 8:
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
case 16:
|
||||||
|
if (format != RGBFB_R5G5B5)
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
case 32:
|
||||||
|
if (format != RGBFB_A8R8G8B8)
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool check_modeid_cgfx(ULONG mode_id)
|
||||||
|
{
|
||||||
|
uint32 depth = GetCyberIDAttr(CYBRIDATTR_DEPTH, mode_id);
|
||||||
|
uint32 format = GetCyberIDAttr(CYBRIDATTR_PIXFMT, mode_id);
|
||||||
|
|
||||||
|
D(bug("init_screen_cgfx: mode_id=%08lx depth=%ld format=%ld\n", mode_id, depth, format));
|
||||||
|
|
||||||
|
if (!IsCyberModeID(mode_id))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch (depth) {
|
||||||
|
case 8:
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
case 16:
|
||||||
|
// !!! PIXFMT_RGB15 is correct !!!
|
||||||
|
if (format != PIXFMT_RGB15)
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
case 32:
|
||||||
|
if (format != PIXFMT_ARGB32)
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user