Added a configuration to switch monitor types

This commit is contained in:
Akamaki
2025-02-06 17:20:58 +09:00
committed by GitHub
parent f12b975eba
commit 3bfd2a6b16

View File

@@ -59,6 +59,8 @@
//#define DA2_DCONFIG_FONT_HANG 1 /* for Code page 934 Hangul */
//#define DA2_DCONFIG_FONT_HANS 2 /* for Code page 936 Simplified Chinese */
#define DA2_DCONFIG_FONT_HANT 3 /* for Code page 938 Traditional Chinese */
#define DA2_DCONFIG_MONTYPE_COLOR 0x0A
#define DA2_DCONFIG_MONTYPE_MONO 0x09
#define DA2_BLT_CIDLE 0
#define DA2_BLT_CFILLRECT 1
@@ -102,8 +104,10 @@
| EFD8h | Display Adapter /J | | | X | X | X |
*/
/* IO 3E0/3E1:0Ah Hardware Configuration Value L (imported from OS/2 DDK) */
//2501
//2500 mono
#define OldLSI 0x20 /* DA-2 or DA-3,5 */
#define Mon_ID3 0x10
//#define Mon_ID3 0x10
#define FontCard 0x08 /* ? */
/* Page Number Mask : Memory Size? = (110b and 111b): vram size is 512k (256 color mode is not supported). */
#define Page_One 0x06 /* 80000h 110b */
@@ -112,14 +116,14 @@
/* IO 3E0/3E1:0Bh Hardware Configuration Value H (imported from OS/2 DDK) */
#define AddPage 0x08 /* ? */
#define Mon_ID2 0x04
#define Mon_ID1 0x02
#define Mon_ID0 0x01
//#define Mon_ID2 0x04
//#define Mon_ID1 0x02
//#define Mon_ID0 0x01
/* Monitor ID (imported from OS/2 DDK 1.2) */
//#define StarbuckC 0x0A //1010b IBM 8514, 9518 color 1040x768
//#define StarbuckM 0x09 //1001b x grayscale
//#define Lark_B 0x02 //0010b IBM 9517 color 1040x768
//#define Dallas 0x0B //1011b IBM 8515, 9515 color 1040x740 B palette
//#define StarbuckC 0x0A //1 010b IBM 8514, 9518 color 1040x768
//#define StarbuckM 0x09 //1 001b IBM 8507, 8604 grayscale
//#define Lark_B 0x02 //0 010b IBM 9517 color 1040x768 but 4pp
//#define Dallas 0x0B //1 011b IBM 8515, 9515 color 1040x740 B palette
/* DA2 Registers (imported from OS/2 DDK) */
#define AC_REG 0x3EE
@@ -400,8 +404,7 @@ typedef struct da2_t
uint8_t pos_regs[8];
svga_t *mb_vga;
//int vidsys_ena;
uint8_t monitorid;
int old_pos2;
} da2_t;
@@ -1256,12 +1259,25 @@ uint16_t da2_in(uint16_t addr, void *p)
if (da2->ioctladdr > 0xf) return DA2_INVALIDACCESS8;
temp = da2->ioctl[da2->ioctladdr];
if (da2->ioctladdr == LS_STATUS) { /* Status register */
if ((da2->vgapal[0].r + da2->vgapal[0].g + da2->vgapal[0].b) >= 0x50 && da2->attrc[LV_COMPATIBILITY] & 0x08)
temp &= 0x7F; /* Inactive when the RGB output voltage is high(or the cable is not connected to the color monitor). */
else
temp |= 0x80; /* Active when the RGB output voltage is lowand the cable is connected to the color monitor.
If the cable or the monitor is wrong, it becomes inactive. */
temp &= 0xf6;//idle
if (da2->attrc[LV_COMPATIBILITY] & 0x08) { /* for detecting monitor type and cable wiring */
if (da2->monitorid == DA2_DCONFIG_MONTYPE_MONO) {
/* grayscale monitor */
if ((da2->vgapal[0].r >= 10) || (da2->vgapal[0].g >= 40) || (da2->vgapal[0].b >= 10))
temp &= 0x7F; /* Inactive when the RGB output voltage is high (or the cable is not connected to a color monitor). */
else
temp |= 0x80; /* Active when the RGB output voltage is low and the cable is connected to a color monitor.
If the cable or the monitor is wrong, it becomes inactive. */
} else {
/* color monitor */
if ((da2->vgapal[0].r + da2->vgapal[0].g + da2->vgapal[0].b) >= 80)
temp &= 0x7F;
else
temp |= 0x80;
}
} else {
temp |= 0x80;
}
temp &= 0xf6;//clear busy bits
if (da2->bitblt.indata) /* for OS/2 J1.3 */
da2_bitblt_dopayload(da2);
if (da2->bitblt.exec != DA2_BLT_CIDLE)
@@ -2959,8 +2975,9 @@ da2_reset(void* priv)
da2->pos_regs[0] = DA2_POSID_L; /* Adapter Identification Byte (Low byte) */
da2->pos_regs[1] = DA2_POSID_H; /* Adapter Identification Byte (High byte) */
da2->pos_regs[2] = 0x40; /* Bit 7-5: 010=Mono, 100=Color, Bit 0 : Card Enable (they are changed by system software) */
da2->ioctl[LS_CONFIG1] = OldLSI | Mon_ID3 | Page_Two; /* Configuration(Low) : DA - 2, Monitor ID 3, 1024 KB */
da2->ioctl[LS_CONFIG2] = Mon_ID1; /* Configuration (High): Monitor ID 0-2 */
da2->ioctl[LS_CONFIG1] = OldLSI | Page_Two; /* Configuration 1 : DA - 2, 1024 KB */
da2->ioctl[LS_CONFIG1] |= ((da2->monitorid & 0x8 ) << 2); /* Configuration 1 : Monitor ID 3 */
da2->ioctl[LS_CONFIG2] = (da2->monitorid & 0x7); /* Configuration 2: Monitor ID 0-2 */
da2->fctl[0] = 0x2b; /* 3E3h:0 */
da2->fctl[LF_MMIO_MODE] = 0xb0; /* 3E3h:0bh */
da2->attrc[LV_CURSOR_COLOR] = 0x0f; /* cursor color */
@@ -3000,6 +3017,7 @@ static void *da2_init()
da2->cram = malloc(0x1000);
da2->vram_display_mask = DA2_MASK_CRAM;
da2->changedvram = malloc(/*(memsize >> 12) << 1*/0x1000000 >> 12);//XX000h
da2->monitorid = device_get_config_int("montype"); /* Configuration for Monitor ID (aaaa) -> (xxax xxxx, xxxx xaaa) */
int fonttype = device_get_config_int("font");
switch(fonttype)
@@ -3145,12 +3163,9 @@ static const device_config_t da2_configuration[] = {
// clang-format off
{
.name = "font",
.description = "Font",
.description = "Charset",
.type = CONFIG_SELECTION,
.default_string = "",
.default_int = 0,
.file_filter = "",
.spinner = { 0 },
.default_int = DA2_DCONFIG_FONT_JPAN,
.selection = {
{
.description = "CP932 (Japanese)",
@@ -3163,6 +3178,23 @@ static const device_config_t da2_configuration[] = {
{ .description = "" }
}
},
{
.name = "montype",
.description = "Monitor type",
.type = CONFIG_SELECTION,
.default_int = DA2_DCONFIG_MONTYPE_COLOR,
.selection = {
{
.description = "Color",
.value = DA2_DCONFIG_MONTYPE_COLOR
},
{
.description = "Grayscale",
.value = DA2_DCONFIG_MONTYPE_MONO
},
{ .description = "" }
}
},
{ .name = "", .description = "", .type = CONFIG_END }
// clang-format on
};