/* DOS (int 21h, version DOS/4GW 32 bits), DPMI (int 31h), BIOS (10h, 16h), souris (33h), MSCDEX (2Fh). * * Fichiers : les chemins du jeu (« d:\tucker\speech\sam0001.wav », « loc01.pcx », « c:\g.in ») sont * ramenés au dossier du CD, au dossier installé ou à la racine C:, en lecture seule. Seules les * sauvegardes (savegm.NN, nofiles.dta) sont écrites, dans un dossier à part. */ #include #include #include #include #include #include "cpu.h" #include "rt.h" #include "mods.h" #include "hd.h" #include "sprites.h" RtConfig rt_cfg; static void set_cf(int c) { set_eflags((get_eflags() & ~1u) | (c ? 1u : 0u)); } static void dos_error(uint16_t code) { R(0) = code; set_cf(1); } #define LIN(seg, off) (SB(seg) + (off)) /* ------------------------------------------------------------------ sélecteurs */ #define NSEL 1024 static uint32_t sel_tab_base[NSEL]; static uint8_t sel_used[NSEL]; uint32_t sel_base(uint16_t sel) { unsigned i = sel >> 3; return i < NSEL ? sel_tab_base[i] : 0; } uint16_t sel_alloc(uint32_t base, uint32_t limit) { unsigned i; (void)limit; for (i = 0x40; i < NSEL; i++) if (!sel_used[i]) { sel_used[i] = 1; sel_tab_base[i] = base; return (uint16_t)(i << 3 | 7); } rt_fatal("plus de sélecteurs"); return 0; } static void sel_fixed(uint16_t sel, uint32_t base) { sel_used[sel >> 3] = 1; sel_tab_base[sel >> 3] = base; } void set_seg(int s, uint16_t sel) { cpu.seg[s] = sel; cpu.sb[s] = sel_base(sel); } /* ------------------------------------------------------------------ fichiers */ #define NFILES 40 static FILE *files[NFILES]; static char file_rel[NFILES][64]; /* chemin relatif dans le jeu (sprites HD) */ static char file_host[NFILES][300]; /* chemin réel */ static int file_writable[NFILES]; static uint32_t dta = 0; static void read_str(uint32_t a, char *out, size_t n) { size_t i; for (i = 0; i + 1 < n; i++) { out[i] = (char)RD8(a + (uint32_t)i); if (!out[i]) break; } out[n - 1] = 0; } static int is_save_name(const char *base) { return !strncmp(base, "SAVEGM.", 7) || !strcmp(base, "NOFILES.DTA"); } /* nom DOS -> chemin relatif dans le dossier du jeu, en majuscules (« C:\TUCKER\speech\x.wav » -> « SPEECH\X.WAV ») */ static char *game_rel(const char *dos, char *p, size_t n) { char *s; size_t k; for (k = 0; dos[k] && k + 1 < n; k++) p[k] = (char)toupper((unsigned char)(dos[k] == '/' ? '\\' : dos[k])); p[k] = 0; s = p; if (s[0] && s[1] == ':') s += 2; while (*s == '\\') s++; if (!strncmp(s, "TUCKER\\", 7)) s += 7; return s; } /* nom DOS -> chemin hôte ; renvoie 0 si introuvable (lecture). Ordre : sauvegardes, mods, jeu installé, CD, racine */ int dos_map_path(const char *dos, char *out, size_t n, int for_write) { char p[260], *s, *base; const char *dirs[3]; int i; size_t k; s = game_rel(dos, p, sizeof p); base = strrchr(s, '\\'); base = base ? base + 1 : s; if (is_save_name(base)) { snprintf(out, n, "%s/%s", rt_cfg.save_dir, base); return 1; } if (for_write) return 0; if (!strcmp(s, "G.IN") && rt_cfg.mute) return 0; if (mods_find_file(s, out, n)) { if (rt_cfg.verbose) fprintf(stderr, "[mods] %s -> %s\n", s, out); return 1; } dirs[0] = rt_cfg.hd_dir; dirs[1] = rt_cfg.cd_dir; dirs[2] = rt_cfg.root_dir; for (i = 0; i < 3; i++) { FILE *f; if (!dirs[i]) continue; snprintf(out, n, "%s/%s", dirs[i], s); for (k = 0; out[k]; k++) if (out[k] == '\\') out[k] = '/'; f = fopen(out, "rb"); if (f) { fclose(f); return 1; } } return 0; } static int alloc_handle(FILE *f, int w) { int h; for (h = 5; h < NFILES; h++) if (!files[h]) { files[h] = f; file_writable[h] = w; return h; } fclose(f); return -1; } static void dos_open(int create) { char name[260], path[300], rel[260] = ""; FILE *f; int h, mode = BL_(0) & 3; read_str(LIN(S_DS, R(2)), name, sizeof name); if (create || mode != 0) { if (!dos_map_path(name, path, sizeof path, 1)) { if (rt_cfg.verbose) fprintf(stderr, "[dos] écriture refusée : %s\n", name); dos_error(5); return; } f = fopen(path, create ? "wb+" : "rb+"); if (!f && !create) f = fopen(path, "wb+"); } else { if (!dos_map_path(name, path, sizeof path, 0)) { if (rt_cfg.verbose) fprintf(stderr, "[dos] introuvable : %s\n", name); dos_error(2); return; } f = fopen(path, "rb"); if (f) hd_file_opened(game_rel(name, rel, sizeof rel), path); } if (!f) { dos_error(2); return; } h = alloc_handle(f, create || mode != 0); if (h < 0) { dos_error(4); return; } snprintf(file_rel[h], sizeof file_rel[h], "%s", rel); snprintf(file_host[h], sizeof file_host[h], "%s", path); if (rt_cfg.verbose) fprintf(stderr, "[dos] ouvre %s -> %d\n", name, h); R(0) = (uint32_t)h; set_cf(0); } static FILE *handle(int h) { return (h >= 0 && h < NFILES) ? files[h] : NULL; } /* recherche de fichiers (4Eh/4Fh) : seulement les sauvegardes et les noms exacts */ static void find_file(int first) { char spec[260], path[300]; FILE *f; long size; const char *base; if (!first) { dos_error(18); return; } read_str(LIN(S_DS, R(2)), spec, sizeof spec); if (strchr(spec, '*') || strchr(spec, '?') || !dos_map_path(spec, path, sizeof path, 0)) { dos_error(18); return; } f = fopen(path, "rb"); if (!f) { dos_error(18); return; } fseek(f, 0, SEEK_END); size = ftell(f); fclose(f); base = strrchr(spec, '\\'); base = base ? base + 1 : spec; WR8(dta + 0x15, 0x20); WR16(dta + 0x16, 0); WR16(dta + 0x18, (16 << 9) | (1 << 5) | 1); WR32(dta + 0x1a, (uint32_t)size); { int i; for (i = 0; i < 12 && base[i]; i++) WR8(dta + 0x1e + (uint32_t)i, (uint8_t)toupper((unsigned char)base[i])); WR8(dta + 0x1e + (uint32_t)i, 0); } R(0) = 0; set_cf(0); } void dos_init(const char *exe_dos) { static const char env_head[] = "PATH=C:\\\0COMSPEC=C:\\COMMAND.COM\0DOS4G=QUIET\0\0\1\0"; char env[160]; size_t n = sizeof env_head - 1, m = strlen(exe_dos); memcpy(env, env_head, n); if (m > sizeof env - n - 1) m = sizeof env - n - 1; memcpy(env + n, exe_dos, m); env[n + m] = 0; sel_fixed(SEL_CODE, 0); sel_fixed(SEL_DATA, 0); sel_fixed(SEL_PSP, PSP_BASE); sel_fixed(SEL_ENV, ENV_BASE); memset(M + PSP_BASE, 0, 256); WR16(PSP_BASE, 0x20cd); WR16(PSP_BASE + 0x2c, SEL_ENV); WR32(PSP_BASE + 0x5c, HEAP_BASE); WR8(PSP_BASE + 0x80, 0); WR8(PSP_BASE + 0x81, '\r'); memcpy(M + ENV_BASE, env, n + m + 1); dta = PSP_BASE + 0x80; { time_t t = time(NULL); (void)t; } } /* ------------------------------------------------------------------ int 21h */ void dos_int21(void) { uint8_t ah = BH_(0), al = BL_(0); FILE *f; switch (ah) { case 0x02: putchar(BL_(2)); break; case 0x06: if (BL_(2) == 0xff) { BL_(0) = 0; LF_ZF(1); } else putchar(BL_(2)); break; case 0x09: { uint32_t a = LIN(S_DS, R(2)); while (RD8(a) != '$') putchar(RD8(a++)); break; } case 0x0b: BL_(0) = 0; break; case 0x0e: BL_(0) = 26; break; case 0x19: BL_(0) = 2; break; /* C: */ case 0x1a: dta = LIN(S_DS, R(2)); break; case 0x25: pm_vec_off[al] = R(2); pm_vec_sel[al] = SEGR(S_DS); if (rt_cfg.verbose) fprintf(stderr, "[dos] vecteur %02x -> %08x\n", al, R(2)); break; case 0x2a: { time_t t = time(NULL); struct tm *tm = localtime(&t); W(1) = (uint16_t)(tm->tm_year + 1900); BH_(2) = (uint8_t)(tm->tm_mon + 1); BL_(2) = (uint8_t)tm->tm_mday; BL_(0) = (uint8_t)tm->tm_wday; break; } case 0x2c: { uint64_t us = host_time_us(); time_t t = time(NULL); struct tm *tm = localtime(&t); BH_(1) = (uint8_t)tm->tm_hour; BL_(1) = (uint8_t)tm->tm_min; BH_(2) = (uint8_t)tm->tm_sec; BL_(2) = (uint8_t)((us / 10000) % 100); break; } case 0x2f: set_seg(S_ES, SEL_DATA); R(3) = dta; break; case 0x30: R(0) = 0x0005u; break; /* DOS 5.0, pas Phar Lap */ case 0x35: R(3) = pm_vec_off[al]; set_seg(S_ES, pm_vec_sel[al] ? pm_vec_sel[al] : SEL_CODE); break; case 0x36: W(0) = 8; W(3) = 0x4000; W(1) = 512; W(2) = 0x8000; break; case 0x3b: set_cf(0); break; case 0x3c: dos_open(1); return; case 0x3d: dos_open(0); return; case 0x3e: f = handle(W(3)); if (W(3) < 5) { set_cf(0); return; } if (!f) { dos_error(6); return; } fclose(f); files[W(3)] = NULL; set_cf(0); return; case 0x3f: { size_t got; f = handle(W(3)); if (!f) { if (W(3) == 0) { R(0) = 0; set_cf(0); } else dos_error(6); return; } long at = ftell(f); got = fread(M + (LIN(S_DS, R(2)) & MEM_MASK), 1, R(1), f); if (file_rel[W(3)][0]) spr_file_read(file_rel[W(3)], file_host[W(3)], at, LIN(S_DS, R(2)) & MEM_MASK, (uint32_t)got); R(0) = (uint32_t)got; set_cf(0); return; } case 0x40: { uint32_t a = LIN(S_DS, R(2)), i; if (W(3) == 1 || W(3) == 2) { for (i = 0; i < R(1); i++) fputc(RD8(a + i), W(3) == 1 ? stdout : stderr); R(0) = R(1); set_cf(0); return; } f = handle(W(3)); if (!f || !file_writable[W(3)]) { dos_error(5); return; } R(0) = (uint32_t)fwrite(M + (a & MEM_MASK), 1, R(1), f); fflush(f); set_cf(0); return; } case 0x41: dos_error(5); return; case 0x42: { long off = (long)(((uint32_t)W(1) << 16) | W(2)); f = handle(W(3)); if (!f) { dos_error(6); return; } fseek(f, off, al == 0 ? SEEK_SET : al == 1 ? SEEK_CUR : SEEK_END); off = ftell(f); W(0) = (uint16_t)off; W(2) = (uint16_t)((uint32_t)off >> 16); set_cf(0); return; } case 0x43: { char name[260], path[300]; read_str(LIN(S_DS, R(2)), name, sizeof name); if (dos_map_path(name, path, sizeof path, 0)) { W(1) = 0x20; set_cf(0); } else dos_error(2); return; } case 0x44: if (al == 0) { W(2) = W(3) < 3 ? 0x80d3 : 0x0002; set_cf(0); return; } if (al == 8) { R(0) = 1; set_cf(0); return; } dos_error(1); return; case 0x47: { const char *cwd = "TUCKER"; uint32_t a = LIN(S_DS, R(6)), i; for (i = 0; i <= strlen(cwd); i++) WR8(a + i, (uint8_t)cwd[i]); set_cf(0); return; } case 0x48: dos_error(8); return; case 0x49: set_cf(0); return; case 0x4a: set_cf(0); return; case 0x4c: rt_exit(al); return; case 0x4e: find_file(1); return; case 0x4f: find_file(0); return; case 0x57: W(1) = 0; W(2) = (16 << 9) | (1 << 5) | 1; set_cf(0); return; case 0xff: if (W(0) == 0xff00 && W(2) == 0x78) { R(0) = 0x4734ff47u; return; } /* DOS/4G présent */ break; default: fprintf(stderr, "[dos] int 21h AH=%02Xh non géré (EAX=%08x)\n", ah, R(0)); dos_error(1); return; } set_cf(0); } /* ------------------------------------------------------------------ DPMI */ uint32_t pm_vec_off[256]; uint16_t pm_vec_sel[256]; static uint32_t rm_vec[256]; static uint32_t heap_top = HEAP_BASE; static uint32_t low_top = LOWMEM_BASE; static uint32_t heap_alloc(uint32_t size) { uint32_t a = (heap_top + 0xfffu) & ~0xfffu; if (a + size > MEM_SIZE - 0x10000u) return 0; heap_top = a + size; return a; } static void real_mode_int(uint8_t n, uint32_t rs); void dpmi_int31(void) { uint16_t ax = W(0); set_cf(0); switch (ax) { case 0x0000: { unsigned i; uint16_t first = 0; for (i = 0; i < W(1); i++) { uint16_t s = sel_alloc(0, 0xffffffffu); if (!i) first = s; } W(0) = first; return; } case 0x0001: return; case 0x0002: W(0) = sel_alloc((uint32_t)W(3) << 4, 0xffff); return; case 0x0003: W(0) = 8; return; case 0x0006: { uint32_t b = sel_base(W(3)); W(1) = (uint16_t)(b >> 16); W(2) = (uint16_t)b; return; } case 0x0007: sel_tab_base[(W(3) >> 3) % NSEL] = ((uint32_t)W(1) << 16) | W(2); { int s; for (s = 0; s < 6; s++) if (cpu.seg[s] == W(3)) cpu.sb[s] = sel_base(W(3)); } return; case 0x0008: case 0x0009: case 0x000c: return; case 0x000a: W(0) = sel_alloc(sel_base(W(3)), 0xffffffffu); return; case 0x000b: { uint32_t a = LIN(S_ES, R(7)), i; for (i = 0; i < 8; i++) WR8(a + i, 0); WR16(a, 0xffff); WR16(a + 2, (uint16_t)sel_base(W(3))); WR8(a + 4, (uint8_t)(sel_base(W(3)) >> 16)); WR8(a + 5, 0xf2); WR8(a + 6, 0xcf); WR8(a + 7, (uint8_t)(sel_base(W(3)) >> 24)); return; } case 0x0100: { uint32_t size = (uint32_t)W(3) << 4, a = (low_top + 15u) & ~15u; if (a + size > LOWMEM_END) { W(0) = 8; W(3) = (uint16_t)((LOWMEM_END - a) >> 4); set_cf(1); return; } low_top = a + size; W(0) = (uint16_t)(a >> 4); W(2) = sel_alloc(a, size); return; } case 0x0101: case 0x0102: return; case 0x0200: W(1) = (uint16_t)(rm_vec[BL_(3)] >> 16); W(2) = (uint16_t)rm_vec[BL_(3)]; return; case 0x0201: rm_vec[BL_(3)] = ((uint32_t)W(1) << 16) | W(2); return; case 0x0202: case 0x0203: return; case 0x0204: W(1) = pm_vec_sel[BL_(3)] ? pm_vec_sel[BL_(3)] : SEL_CODE; R(2) = pm_vec_off[BL_(3)]; return; case 0x0205: pm_vec_sel[BL_(3)] = W(1); pm_vec_off[BL_(3)] = R(2); if (rt_cfg.verbose) fprintf(stderr, "[dpmi] vecteur %02x -> %04x:%08x\n", BL_(3), W(1), R(2)); return; case 0x0300: real_mode_int(BL_(3), LIN(S_ES, R(7))); return; case 0x0301: case 0x0302: fprintf(stderr, "[dpmi] appel en mode réel %04x non géré\n", ax); set_cf(1); return; case 0x0303: W(1) = 0xf000; W(2) = 0x0100; return; case 0x0304: return; case 0x0400: W(0) = 0x005a; W(3) = 0x0005; BL_(1) = 4; BH_(2) = 0x08; BL_(2) = 0x70; return; case 0x0500: { uint32_t a = LIN(S_ES, R(7)), i, fr = (MEM_SIZE - heap_top) ; for (i = 0; i < 48; i += 4) WR32(a + i, 0xffffffffu); WR32(a, fr); WR32(a + 4, fr >> 12); WR32(a + 8, fr >> 12); WR32(a + 0x14, fr >> 12); WR32(a + 0x18, MEM_SIZE >> 12); WR32(a + 0x1c, fr >> 12); return; } case 0x0501: { uint32_t size = ((uint32_t)W(3) << 16) | W(1), a = heap_alloc(size); if (!a) { set_cf(1); W(0) = 0x8013; return; } W(3) = (uint16_t)(a >> 16); W(1) = (uint16_t)a; W(6) = (uint16_t)(a >> 16); W(7) = (uint16_t)a; return; } case 0x0502: return; case 0x0503: { uint32_t size = ((uint32_t)W(3) << 16) | W(1), old = ((uint32_t)W(6) << 16) | W(7); uint32_t a = heap_alloc(size); if (!a) { set_cf(1); W(0) = 0x8013; return; } memmove(M + a, M + old, size); W(3) = (uint16_t)(a >> 16); W(1) = (uint16_t)a; W(6) = (uint16_t)(a >> 16); W(7) = (uint16_t)a; return; } case 0x0600: case 0x0601: case 0x0602: case 0x0603: case 0x0702: case 0x0703: return; case 0x0604: W(3) = 0; W(1) = 0x1000; return; case 0x0800: return; /* adresse physique = linéaire */ case 0x0801: return; case 0x0900: case 0x0901: case 0x0902: BL_(0) = 1; return; default: fprintf(stderr, "[dpmi] int 31h AX=%04Xh non géré\n", ax); set_cf(1); return; } } /* DPMI 0300h : structure d'appel en mode réel */ static void real_mode_int(uint8_t n, uint32_t rs) { Cpu saved = cpu; uint32_t es_base; R(7) = RD32(rs); R(6) = RD32(rs + 4); R(5) = RD32(rs + 8); R(3) = RD32(rs + 0x10); R(2) = RD32(rs + 0x14); R(1) = RD32(rs + 0x18); R(0) = RD32(rs + 0x1c); es_base = (uint32_t)RD16(rs + 0x22) << 4; cpu.sb[S_ES] = es_base; cpu.sb[S_DS] = (uint32_t)RD16(rs + 0x24) << 4; set_eflags(0x202); rt_int(n); WR32(rs, R(7)); WR32(rs + 4, R(6)); WR32(rs + 8, R(5)); WR32(rs + 0x10, R(3)); WR32(rs + 0x14, R(2)); WR32(rs + 0x18, R(1)); WR32(rs + 0x1c, R(0)); WR16(rs + 0x20, (uint16_t)get_eflags()); cpu = saved; set_cf(0); } /* ------------------------------------------------------------------ BIOS */ int vga_mode = 3; void bios_int10(void) { switch (BH_(0)) { case 0x00: vga_mode = BL_(0) & 0x7f; if (!(BL_(0) & 0x80) && vga_mode == 0x13) memset(M + VGA_BASE, 0, 64000); break; case 0x0f: BL_(0) = (uint8_t)vga_mode; BH_(0) = 40; BH_(3) = 0; break; case 0x10: if (BL_(0) == 0x10) { vga_dac[BL_(3) * 3] = BH_(2) & 63; vga_dac[BL_(3) * 3 + 1] = BH_(1) & 63; vga_dac[BL_(3) * 3 + 2] = BL_(1) & 63; } else if (BL_(0) == 0x12) { uint32_t i, a = LIN(S_ES, R(2)); for (i = 0; i < (uint32_t)W(1) * 3 && W(3) * 3 + i < 768; i++) vga_dac[W(3) * 3 + i] = RD8(a + i) & 63; } else if (BL_(0) == 0x17) { uint32_t i, a = LIN(S_ES, R(2)); for (i = 0; i < (uint32_t)W(1) * 3 && W(3) * 3 + i < 768; i++) WR8(a + i, vga_dac[W(3) * 3 + i]); } break; case 0x1a: BL_(0) = 0x1a; W(3) = 0x0008; break; default: break; } } /* le BIOS ne garde que les appuis : on jette les relâchements en tête de file */ static int bios_peek(uint8_t *sc) { while (host_key_peek(sc)) { if (!(*sc & 0x80)) return 1; host_key_pop(sc); } return 0; } static const char kbd_ascii[0x3a] = { 0, 27, '1','2','3','4','5','6','7','8','9','0','-','=', 8, 9, 'q','w','e','r','t','y','u','i','o','p','[',']', 13, 0, 'a','s', 'd','f','g','h','j','k','l',';', 39, '`', 0, 92, 'z','x','c','v', 'b','n','m',',','.','/', 0, '*', 0, ' ' }; void bios_int16(void) { uint8_t sc; switch (BH_(0)) { case 0x00: case 0x10: while (!bios_peek(&sc)) { host_pump(); if (host_quit) rt_exit(0); rt_poll(); } host_key_pop(&sc); W(0) = (uint16_t)(sc << 8 | (sc < 0x3a ? (uint8_t)kbd_ascii[sc] : 0)); return; case 0x01: case 0x11: if (bios_peek(&sc)) { W(0) = (uint16_t)(sc << 8 | (sc < 0x3a ? (uint8_t)kbd_ascii[sc] : 0)); LF_ZF(0); } else LF_ZF(1); return; case 0x02: BL_(0) = 0; return; default: return; } } static int mouse_minx = 0, mouse_maxx = 639, mouse_miny = 0, mouse_maxy = 199; static int mouse_lastx, mouse_lasty; /* Le jeu lit une position absolue en pixels 320x200 (fonction 3, rangée en ADR_SOURIS_X / ADR_SOURIS_Y) * et ne fixe pas de plage : on renvoie donc la position de l'hôte telle quelle, bornée à la plage * éventuelle. La fonction 4 (le jeu bloque le curseur à x <= 307, y <= 195) est sans effet : l'hôte * ne peut pas déplacer le pointeur, et le jeu borne lui-même ce qu'il lit. */ static int clampi(int v, int lo, int hi) { return v < lo ? lo : v > hi ? hi : v; } void mouse_int33(void) { int x, y, b; host_mouse(&x, &y, &b); b = game_mouse_buttons(b); x = clampi(x, mouse_minx, mouse_maxx); y = clampi(y, mouse_miny, mouse_maxy); switch (W(0)) { case 0x00: W(0) = 0xffff; W(3) = 2; break; case 0x01: case 0x02: break; case 0x03: W(3) = (uint16_t)b; W(1) = (uint16_t)x; W(2) = (uint16_t)y; break; case 0x04: break; case 0x05: case 0x06: W(0) = (uint16_t)b; W(3) = 0; W(1) = (uint16_t)x; W(2) = (uint16_t)y; break; case 0x07: mouse_minx = (int16_t)W(1); mouse_maxx = (int16_t)W(2); break; case 0x08: mouse_miny = (int16_t)W(1); mouse_maxy = (int16_t)W(2); break; case 0x0b: W(1) = (uint16_t)(x - mouse_lastx); W(2) = (uint16_t)(y - mouse_lasty); mouse_lastx = x; mouse_lasty = y; break; case 0x0c: fprintf(stderr, "[souris] gestionnaire d'événements demandé (non géré)\n"); break; case 0x0f: case 0x1a: case 0x1d: break; case 0x21: W(0) = 0xffff; W(3) = 2; break; case 0x24: W(3) = 0x0626; BH_(1) = 4; BL_(1) = 0; break; default: fprintf(stderr, "[souris] fonction %04x non gérée\n", W(0)); break; } } /* ------------------------------------------------------------------ aiguillage des interruptions */ void rt_int(uint32_t n) { switch (n) { case 0x21: dos_int21(); break; case 0x31: dpmi_int31(); break; case 0x10: bios_int10(); break; case 0x16: bios_int16(); break; case 0x33: mouse_int33(); break; case 0x2f: if (W(0) == 0x1500) { W(3) = 1; W(1) = 3; } /* MSCDEX : un lecteur, D: */ else if (W(0) == 0x150b) { W(0) = 1; W(3) = 0xadad; } else if (W(0) == 0x1687) { W(0) = 1; } /* pas d'hôte DPMI réel */ break; case 0x1a: { uint32_t t = RD32(0x46c); W(1) = (uint16_t)(t >> 16); W(2) = (uint16_t)t; BL_(0) = 0; break; } default: fprintf(stderr, "[int] interruption %02x non gérée (EAX=%08x)\n", n, R(0)); break; } } /* remet DOS / DPMI / souris dans l'état d'un démarrage, avant de lancer un autre programme */ void dos_reset(void) { int i; for (i = 5; i < NFILES; i++) if (files[i]) { fclose(files[i]); files[i] = NULL; } memset(file_writable, 0, sizeof file_writable); hd_reset(); spr_reset(); memset(sel_tab_base, 0, sizeof sel_tab_base); memset(sel_used, 0, sizeof sel_used); memset(pm_vec_off, 0, sizeof pm_vec_off); memset(pm_vec_sel, 0, sizeof pm_vec_sel); memset(rm_vec, 0, sizeof rm_vec); heap_top = HEAP_BASE; low_top = LOWMEM_BASE; vga_mode = 3; mouse_minx = 0; mouse_maxx = 639; mouse_miny = 0; mouse_maxy = 199; }