@@ -4065,17 +4065,13 @@ int main(int argc, char *argv[], char *envp[])
40654065 main_thread_id = GetCurrentThreadId();
40664066 }
40674067
4068- get_console_buffer_success = (MyGetConsoleScreenBufferInfo(hStdout, &csbi) != 0);
4069- get_console_cursor_success = use_vt ? false : (GetConsoleCursorInfo(hStdout, &ci) != 0);
40704068 if(set_code_page) {
40714069 set_input_code_page(code_page);
40724070 set_output_code_page(code_page);
40734071 }
4074- get_console_font_success = get_console_font_info(&fi);
4072+ get_console_buffer_success = (MyGetConsoleScreenBufferInfo(hStdout, &csbi) != 0);
4073+ get_console_cursor_success = use_vt ? false : (GetConsoleCursorInfo(hStdout, &ci) != 0); get_console_font_success = get_console_font_info(&fi);
40754074
4076- if(!get_console_cursor_success) {
4077- ci.bVisible = TRUE;
4078- }
40794075 if(!get_console_cursor_success) {
40804076 ci.bVisible = TRUE;
40814077 }
@@ -4440,6 +4436,7 @@ bool update_console_input()
44404436 };
44414437 bool prev_status = mouse.buttons[j].status;
44424438 mouse.buttons[j].status = ((ir[i].Event.MouseEvent.dwButtonState & bits[j]) != 0);
4439+
44434440 if(!prev_status && mouse.buttons[j].status) {
44444441 mouse.buttons[j].pressed_times++;
44454442 mouse.buttons[j].pressed_position.x = mouse.position.x;
@@ -4693,6 +4690,7 @@ bool update_console_input()
46934690 result = key_changed = true;
46944691 // IME may be on and it may causes screen scroll up and cursor position change
46954692 cursor_moved = true;
4693+
46964694 if(ir[i].Event.KeyEvent.dwControlKeyState == 0x80000000) {
46974695 ir[i].Event.KeyEvent.bKeyDown = FALSE;
46984696 ir[i].Event.KeyEvent.dwControlKeyState = 0;
@@ -5532,7 +5530,6 @@ bool msdos_is_device_path(const char *path)
55325530 if(!strnicmp(path, "\\DEV\\", 5)) {
55335531 path += 5;
55345532 }
5535-
55365533 if(GetFullPathNameA(path, MAX_PATH, full, &name) != 0) {
55375534 if(_stricmp(full, "\\\\.\\AUX" ) == 0 ||
55385535 _stricmp(full, "\\\\.\\CON" ) == 0 ||
@@ -5945,11 +5942,10 @@ int msdos_open_device(const char *path, int oflag, int *sio_port, int *lpt_port)
59455942 int fd = -1;
59465943
59475944 *sio_port = *lpt_port = 0;
5948-
5945+
59495946 if(!strnicmp(path, "\\DEV\\", 5)) {
59505947 path += 5;
59515948 }
5952-
59535949 if(msdos_is_con_path(path)) {
59545950 // MODE.COM opens CON device with read/write mode :-(
59555951 if((oflag & (_O_RDONLY | _O_WRONLY | _O_RDWR)) == _O_RDWR) {
@@ -5979,7 +5975,6 @@ UINT16 msdos_device_info(const char *path)
59795975 if(!strnicmp(path, "\\DEV\\", 5)) {
59805976 path += 5;
59815977 }
5982-
59835978 if(msdos_is_con_path(path)) {
59845979 return(0x80d3);
59855980 } else if(msdos_is_comm_path(path)) {
@@ -9018,29 +9013,33 @@ void pcbios_update_cursor_position()
90189013 mem[0x451 + mem[0x462] * 2] = csbi.dwCursorPosition.Y - scr_top;
90199014}
90209015
9016+ int get_scan_lines()
9017+ {
9018+ switch(mem[0x489] & 0x90) {
9019+ case 0x00:
9020+ return 350;
9021+ case 0x10:
9022+ return 400;
9023+ case 0x80:
9024+ return 200;
9025+ // case 0x90:
9026+ // return 480;
9027+ }
9028+ return 400;
9029+ }
9030+
90219031inline void pcbios_int_10h_00h()
90229032{
90239033 switch(CPU_AL & 0x7f) {
90249034 case 0x70: // V-Text Mode
90259035 case 0x71: // Extended CGA V-Text Mode
90269036 pcbios_set_console_size(scr_width, scr_height, !(CPU_AL & 0x80));
90279037 break;
9028- case 0x03: { // CGA Text Mode
9029- int lines = 400;
9030- switch(mem[0x489] & 0x90)
9031- {
9032- case 0x00:
9033- lines = 350;
9034- break;
9035- case 0x80:
9036- lines = 200;
9037- break;
9038- }
9038+ case 0x03: // CGA Text Mode
90399039 change_console_size(80, 25); // for Windows10
90409040 pcbios_set_font_size(font_width, font_height);
9041- pcbios_set_console_size(80, lines / 16, !(CPU_AL & 0x80));
9041+ pcbios_set_console_size(80, get_scan_lines() / 16, !(CPU_AL & 0x80));
90429042 break;
9043- }
90449043 case 0x73: // Extended CGA Text Mode
90459044 case 0x64: // J-3100 DCGA (mono)
90469045 case 0x65: // J-3100 DCGA
@@ -9436,10 +9435,27 @@ inline void pcbios_int_10h_0fh()
94369435
94379436inline void pcbios_int_10h_10h()
94389437{
9438+ static UINT8 palette[17] = {
9439+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
9440+ 0x00
9441+ };
9442+
94399443 switch(CPU_AL) {
9444+ case 0x01:
9445+ palette[16] = CPU_BH;
9446+ break;
9447+ case 0x02:
9448+ memcpy(palette, mem + CPU_ES_BASE + CPU_DX, sizeof(palette));
9449+ break;
94409450 case 0x03:
94419451 mem[0x465] &= ~0x20 | (CPU_BL << 5);
94429452 break;
9453+ case 0x08:
9454+ CPU_BH = palette[16];
9455+ break;
9456+ case 0x09:
9457+ memcpy(mem + CPU_ES_BASE + CPU_DX, palette, sizeof(palette));
9458+ break;
94439459 default:
94449460 unimplemented_10h("int %02Xh (AX=%04X BX=%04X CX=%04X DX=%04X SI=%04X DI=%04X DS=%04X ES=%04X)\n", 0x10, CPU_AX, CPU_BX, CPU_CX, CPU_DX, CPU_SI, CPU_DI, CPU_DS, CPU_ES);
94459461 CPU_SET_C_FLAG(1);
@@ -9473,7 +9489,7 @@ inline void pcbios_int_10h_11h()
94739489 }
94749490 }
94759491 }
9476- pcbios_set_console_size(80, lines / CPU_BH, true);
9492+ pcbios_set_console_size(80, get_scan_lines() / CPU_BH, true);
94779493 }
94789494 break;
94799495 case 0x01:
@@ -9488,7 +9504,7 @@ inline void pcbios_int_10h_11h()
94889504 }
94899505 }
94909506 }
9491- pcbios_set_console_size(80, lines / 14, true); // 28 = 25 * 16 / 14
9507+ pcbios_set_console_size(80, get_scan_lines() / 14, true);
94929508 break;
94939509 case 0x02:
94949510 case 0x12:
@@ -9507,13 +9523,13 @@ inline void pcbios_int_10h_11h()
95079523 pcbios_set_font_size(font_width, font_height);
95089524 }
95099525 }
9510- pcbios_set_console_size(80, lines / 8, true); // 50 = 25 * 16 / 8
9526+ pcbios_set_console_size(80, get_scan_lines() / 8, true);
95119527 break;
95129528 case 0x04:
95139529 case 0x14:
95149530 change_console_size(80, 25); // for Windows10
95159531 pcbios_set_font_size(font_width, font_height);
9516- pcbios_set_console_size(80, lines / 16, true);
9532+ pcbios_set_console_size(80, get_scan_lines() / 16, true);
95179533 break;
95189534 case 0x18:
95199535 change_console_size(80, 25); // for Windows10
@@ -9535,27 +9551,31 @@ inline void pcbios_int_10h_11h()
95359551
95369552inline void pcbios_int_10h_12h()
95379553{
9554+ UINT8 modebits;
9555+
95389556 switch(CPU_BL) {
95399557 case 0x10:
95409558 CPU_BX = 0x0003;
95419559 CPU_CX = 0x0009;
95429560 break;
95439561 case 0x30:
9544- UINT8 modebits;
9562+ modebits = mem[0x489] & 0x90 ;
95459563 switch(CPU_AL) {
9546- case 0:
9547- modebits = 0x80;
9548- break;
9549- case 1:
9550- modebits = 0x00;
9551- break;
9552- case 2:
9553- modebits = 0x10;
9554- break;
9555- default:
9556- return;
9564+ case 0:
9565+ modebits = 0x80;
9566+ break;
9567+ case 1:
9568+ modebits = 0x00;
9569+ break;
9570+ case 2:
9571+ modebits = 0x10;
9572+ break;
9573+ // case 3:
9574+ // modebits = 0x90;
9575+ // break;
95579576 }
9558- mem[0x489] |= (mem[0x489] & ~0x90) | modebits;
9577+ mem[0x489] = (mem[0x489] & ~0x90) | modebits;
9578+ CPU_AL = 0x12; // success
95599579 break;
95609580 }
95619581}
@@ -9580,8 +9600,10 @@ inline void pcbios_int_10h_13h()
95809600 MyGetConsoleScreenBufferInfo(hStdout, &csbi);
95819601 MySetConsoleCursorPosition(hStdout, co);
95829602
9583- MySetConsoleTextAttribute(hStdout, CPU_BL);
9584- WriteConsoleA(hStdout, &mem[ofs], CPU_CX, NULL, NULL);
9603+ if(csbi.wAttributes != CPU_BL) {
9604+ MySetConsoleTextAttribute(hStdout, CPU_BL);
9605+ }
9606+ WriteConsoleA(hStdout, &mem[ofs], CPU_CX, &num, NULL);
95859607
95869608 if(csbi.wAttributes != CPU_BL) {
95879609 MySetConsoleTextAttribute(hStdout, csbi.wAttributes);
@@ -9942,9 +9964,14 @@ inline void pcbios_int_10h_efh()
99429964
99439965inline void pcbios_int_10h_fah()
99449966{
9945- // just return something, used for mouse driver detection
9946- CPU_LOAD_SREG(CPU_ES_INDEX, 0xffff);
9947- CPU_BX = 0x0005;
9967+ if(CPU_BX == 0x0000) {
9968+ // just return something, used for mouse driver detection
9969+ CPU_LOAD_SREG(CPU_ES_INDEX, 0xffff);
9970+ CPU_BX = 0x0005;
9971+ } else {
9972+ unimplemented_10h("int %02Xh (AX=%04X BX=%04X CX=%04X DX=%04X SI=%04X DI=%04X DS=%04X ES=%04X)\n", 0x10, CPU_AX, CPU_BX, CPU_CX, CPU_DX, CPU_SI, CPU_DI, CPU_DS, CPU_ES);
9973+ CPU_SET_C_FLAG(1);
9974+ }
99489975}
99499976
99509977inline void pcbios_int_10h_feh()
0 commit comments