int main(int argc,char **argv,char **envp) { char tmp[128]; probe_dos(); detect_windows(); if (windows_mode == WINDOWS_NT) { printf("This program is not compatible with Windows NT\n"); return 1; } if (!probe_dosbox_id()) { printf("DOSBox integration device not found\n"); return 1; } printf("DOSBox integration device found at I/O port %xh\n",dosbox_id_baseio); if (probe_dosbox_id_version_string(tmp,sizeof(tmp))) printf("DOSBox version string: '%s'\n",tmp); else printf("DOSBox version string N/A\n"); dosbox_id_debug_message("This is a debug message\n"); dosbox_id_debug_message("This is a multi-line debug message\n(second line here)\n"); return 0; }
int main(int argc,char **argv) { struct vrl1_vgax_header *vrl_header; vrl1_vgax_offset_t *vrl_lineoffs; unsigned char *buffer; unsigned int bufsz; int fd; if (argc < 3) { fprintf(stderr,"drawvrl <VRL file> <palette file>\n"); return 1; } fd = open(argv[1],O_RDONLY|O_BINARY); if (fd < 0) { fprintf(stderr,"Unable to open '%s'\n",argv[1]); return 1; } { unsigned long sz = lseek(fd,0,SEEK_END); if (sz < sizeof(*vrl_header)) return 1; if (sz >= 65535UL) return 1; bufsz = (unsigned int)sz; buffer = malloc(bufsz); if (buffer == NULL) return 1; lseek(fd,0,SEEK_SET); if ((unsigned int)read(fd,buffer,bufsz) < bufsz) return 1; vrl_header = (struct vrl1_vgax_header*)buffer; if (memcmp(vrl_header->vrl_sig,"VRL1",4) || memcmp(vrl_header->fmt_sig,"VGAX",4)) return 1; if (vrl_header->width == 0 || vrl_header->height == 0) return 1; } close(fd); probe_dos(); if (!probe_vga()) { printf("VGA probe failed\n"); return 1; } int10_setmode(19); update_state_from_vga(); vga_enable_256color_modex(); // VGA mode X /* load color palette */ fd = open(argv[2],O_RDONLY|O_BINARY); if (fd >= 0) { unsigned int i; read(fd,palette,768); close(fd); vga_palette_lseek(0); for (i=0;i < 256;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2); }
int main(int argc,char **argv,char **envp) { uint32_t tmp,tmp2; char tmps[128]; probe_dos(); detect_windows(); if (windows_mode == WINDOWS_NT) { printf("This program is not compatible with Windows NT\n"); return 1; } if (!probe_dosbox_id()) { printf("DOSBox integration device not found\n"); return 1; } printf("DOSBox integration device found at I/O port %xh\n",dosbox_id_baseio); if (probe_dosbox_id_version_string(tmps,sizeof(tmps))) printf("DOSBox version string: '%s'\n",tmps); else printf("DOSBox version string N/A\n"); /* first check that the screenshot function is available */ dosbox_id_write_regsel(DOSBOX_ID_REG_SCREENSHOT_TRIGGER); tmp = tmp2 = dosbox_id_read_data(); if (tmp & DOSBOX_ID_SCREENSHOT_STATUS_NOT_AVAILABLE) { printf("DOSBox screenshot control register not available\n"); return 1; } else if (tmp & DOSBOX_ID_SCREENSHOT_STATUS_NOT_ENABLED) { printf("DOSBox screenshot control register not enabled\n"); return 1; } /* trigger it */ dosbox_id_write_regsel(DOSBOX_ID_REG_SCREENSHOT_TRIGGER); dosbox_id_write_data(DOSBOX_ID_SCREENSHOT_VIDEO); /* make sure it toggled */ dosbox_id_write_regsel(DOSBOX_ID_REG_SCREENSHOT_TRIGGER); tmp = dosbox_id_read_data(); if (((tmp^tmp2) & DOSBOX_ID_SCREENSHOT_STATUS_VIDEO_IN_PROGRESS) == 0) { printf("DOSBox video trigger failed.\n"); return 1; } if (tmp & DOSBOX_ID_SCREENSHOT_STATUS_VIDEO_IN_PROGRESS) printf("DOSBox video capture is running\n"); else printf("DOSBox video capture stopped\n"); return 0; }
int main() { #if TARGET_MSDOS == 16 cpu_probe(); probe_dos(); printf("DOS version %x.%02u\n",dos_version>>8,dos_version&0xFF); if (detect_windows()) { printf("I am running under Windows.\n"); printf(" Mode: %s\n",windows_mode_str(windows_mode)); printf(" Ver: %x.%02u\n",windows_version>>8,windows_version&0xFF); } else {
int main() { size_t message_l = strlen(message),message2_l = strlen(message2); probe_dos(); printf("DOS version %x.%02u\n",dos_version>>8,dos_version&0xFF); if (detect_windows()) { printf("I am running under Windows.\n"); printf(" Mode: %s\n",windows_mode_str(windows_mode)); printf(" Ver: %x.%02u\n",windows_version>>8,windows_version&0xFF); } else {
int i_am_ntvdm_client() { probe_dos(); if (cpu_basic_level < 0) cpu_probe(); detect_windows(); #if defined(TARGET_WINDOWS) /* WINE (Wine Is Not an Emulator) tends to run the code in * a more direct fashion */ if (windows_emulation == WINEMU_WINE) return 0; #endif if (windows_mode == WINDOWS_NT) return 1; return 0; }
int main(int argc,char **argv) { if (!probe_apic()) { printf("APIC not detected. Reason: %s\n",apic_error_str); return 1; } printf("APIC base address: 0x%08lx\n",(unsigned long)apic_base); printf("APIC global enable: %u\n",(unsigned int)(apic_flags&APIC_FLAG_GLOBAL_ENABLE?1:0)); printf("Read from bootstrap CPU: %u\n",(unsigned int)(apic_flags&APIC_FLAG_PROBE_ON_BOOT_CPU?1:1)); #if TARGET_MSDOS == 32 dos_ltp_probe(); /* TODO: If LTP probe indicates we shouldn't assume physical<->linear addresses (i.e paging) then bail out */ #else probe_dos(); detect_windows(); if (!flatrealmode_setup(FLATREALMODE_4GB)) { printf("Cannot enter flat real mode\n"); return 1; } #endif { unsigned int i; /* NTS: For safe access on Intel processors always read on 16-byte aligned boundary, 32-bit at all times. * Intel warns the undefined bytes 4-15 between the regs are undefined and may cause undefined behavior. */ printf("APIC dump:\n"); for (i=0x0;i < 0x400;i += 16) { if ((i&0x7F) == 0) printf("0x%03x:",i); printf("%08lx ",(unsigned long)apic_readd(i)); if ((i&0x7F) == 0x70) printf("\n"); } } return 0; }
int main(int argc,char **argv) { struct acpi_rsdt_header sdth; acpi_memaddr_t addr; unsigned long i,max; uint32_t tmp32,tmplen; char tmp[32]; for (i=1;i < (unsigned long)argc;) { const char *a = argv[(unsigned int)(i++)]; if (*a == '-' || *a == '/') { do { a++; } while (*a == '-' || *a == '/'); if (!strcmp(a,"?") || !strcmp(a,"h") || !strcmp(a,"help")) { help(); return 1; } else if (!strcmp(a,"32")) { acpi_use_rsdt_32 = 1; } else { fprintf(stderr,"Unknown switch '%s'\n",a); help(); return 1; } } else { fprintf(stderr,"Unknown arg '%s'\n",a); help(); return 1; } } if (!probe_8254()) { printf("Cannot init 8254 timer\n"); return 1; } if (!probe_8259()) { printf("Cannot init 8259 PIC\n"); return 1; } cpu_probe(); probe_dos(); detect_windows(); #if TARGET_MSDOS == 32 probe_dpmi(); dos_ltp_probe(); #endif #if TARGET_MSDOS == 16 if (!flatrealmode_setup(FLATREALMODE_4GB)) { printf("Unable to set up flat real mode (needed for 16-bit builds)\n"); printf("Most ACPI functions require access to the full 4GB range.\n"); return 1; } #endif if (!acpi_probe()) { printf("ACPI BIOS not found\n"); return 1; } assert(acpi_rsdp != NULL); printf("ACPI %u.0 structure at 0x%05lX\n",acpi_rsdp->revision+1,(unsigned long)acpi_rsdp_location); memcpy(tmp,(char*)(&(acpi_rsdp->OEM_id)),6); tmp[6]=0; printf("ACPI OEM ID '%s', RSDT address (32-bit) 0x%08lX Length %lu\n",tmp, (unsigned long)(acpi_rsdp->rsdt_address), (unsigned long)(acpi_rsdp->length)); if (acpi_rsdp->revision != 0) printf(" XSDT address (64-bit) 0x%016llX\n", (unsigned long long)(acpi_rsdp->xsdt_address)); printf("Chosen RSDT/XSDT at 0x%08llX\n",(unsigned long long)acpi_rsdt_location); if (acpi_rsdt != NULL) { memcpy(tmp,(void*)(acpi_rsdt->signature),4); tmp[4] = 0; printf(" '%s': len=%lu rev=%u\n",tmp,(unsigned long)acpi_rsdt->length, acpi_rsdt->revision); memcpy(tmp,(void*)(acpi_rsdt->OEM_id),6); tmp[6] = 0; printf(" OEM id: '%s'\n",tmp); memcpy(tmp,(void*)(acpi_rsdt->OEM_table_id),8); tmp[8] = 0; printf(" OEM table id: '%s' rev %lu\n",tmp, (unsigned long)acpi_rsdt->OEM_revision); memcpy(tmp,(void*)(&(acpi_rsdt->creator_id)),4); tmp[4] = 0; printf(" Creator: '%s' rev %lu\n",tmp, (unsigned long)acpi_rsdt->creator_revision); } max = acpi_rsdt_entries(); if (acpi_rsdt_is_xsdt()) { printf("Showing XSDT, %lu entries\n",max); } else { printf("Showing RSDT, %lu entries\n",max); } for (i=0;i < max;i++) { addr = acpi_rsdt_entry(i); printf(" [%lu] 0x%08llX ",i,(unsigned long long)addr); if (addr != 0ULL) { tmp32 = acpi_mem_readd(addr); tmplen = 0; memcpy(tmp,&tmp32,4); tmp[4] = 0; if (acpi_probe_rsdt_check(addr,tmp32,&tmplen)) { acpi_memcpy_from_phys(&sdth,addr,sizeof(struct acpi_rsdt_header)); printf("'%s' len=0x%lX rev=%u ",tmp,(unsigned long)tmplen,sdth.revision); memcpy(tmp,&sdth.OEM_id,6); tmp[6] = 0; printf("OEM id: '%s'\n",tmp); memcpy(tmp,&sdth.OEM_table_id,8); tmp[8] = 0; printf("OEM table id: '%s' rev %u ",tmp,sdth.OEM_revision); memcpy(tmp,&sdth.creator_id,4); tmp[4] = 0; printf("Creator id: '%s' rev %u",tmp,sdth.creator_revision); if (!memcmp(sdth.signature,"MCFG",4)) { struct acpi_mcfg_entry entry; uint64_t o = addr + 44; unsigned int count; printf("\nPCI Express map:"); assert(sizeof(struct acpi_mcfg_entry) == 16); count = (unsigned int)(tmplen / sizeof(struct acpi_mcfg_entry)); while (count != 0) { acpi_memcpy_from_phys(&entry,o,sizeof(struct acpi_mcfg_entry)); o += sizeof(struct acpi_mcfg_entry); /* Some bioses I test against seem to return enough for 3 but fill in only 1? */ if (entry.base_address != 0ULL || entry.start_pci_bus_number != 0 || entry.end_pci_bus_number != 0) { uint64_t sz; if (entry.start_pci_bus_number > entry.end_pci_bus_number) entry.start_pci_bus_number = entry.end_pci_bus_number; sz = (((unsigned long long)(entry.end_pci_bus_number - entry.start_pci_bus_number)) + 1ULL) << 20ULL; printf("\n @0x%08llX-0x%08llX seg=%u bus=%u-%u", (unsigned long long)entry.base_address, (unsigned long long)(entry.base_address + sz - 1ULL), (unsigned int)entry.pci_segment_group_number, (unsigned int)entry.start_pci_bus_number, (unsigned int)entry.end_pci_bus_number); } count--; } } } else { printf("'%s' check failed",tmp); } } printf("\n"); } acpi_free(); return 0; }
int main(int argc,char **argv) { unsigned int req_ver = 0; unsigned int dont_disconnect = 0; unsigned int req_mode = APM_CONNECT_NONE; const char *action = NULL; int i; for (i=1;i < argc;) { const char *a = argv[i++]; if (*a == '/' || *a == '-') { do { a++; } while (*a == '/' || *a == '-'); if (!strncmp(a,"v1.",3)) { a += 3; req_ver = 0x100 + (atoi(a) & 0xFF); } else if (!strcmp(a,"vn")) { req_ver = REQ_VER_NONE; } else if (!strcmp(a,"nd")) { dont_disconnect = 1; } else if (!strcmp(a,"h") || !strcmp(a,"help")) { help(); } else if (!strncmp(a,"if:",3)) { a += 3; if (!strcmp(a,"real")) req_mode = APM_CONNECT_REALMODE; else if (!strcmp(a,"16pm")) req_mode = APM_CONNECT_16_PM; else if (!strcmp(a,"32pm")) req_mode = APM_CONNECT_32_PM; else { fprintf(stderr,"Unknown interface %s\n",a); return 1; } } else { fprintf(stderr,"Unknown param '%s'\n",a); help(); return 1; } } else if (action == NULL) { action = a; } else { fprintf(stderr,"Unknown param\n"); return 1; } } if (!probe_8254()) { printf("Cannot init 8254 timer\n"); return 1; } if (!probe_8259()) { printf("Cannot init 8259 PIC\n"); return 1; } probe_dos(); detect_windows(); if (!apm_bios_probe()) { printf("APM BIOS not found\n"); return 1; } if (req_mode == APM_CONNECT_NONE) req_mode = APM_CONNECT_REALMODE; printf("APM BIOS v%u.%u: ",apm_bios->major,apm_bios->minor); if (apm_bios->flags & APM_FL_16BIT_PM) printf("[16-bit pm] "); if (apm_bios->flags & APM_FL_32BIT_PM) printf("[32-bit pm] "); if (apm_bios->flags & APM_FL_CPU_IDLE_SLOWS) printf("[cpu-idle-slow] "); if (apm_bios->flags & APM_FL_PM_DISABLED) printf("[disabled] "); if (apm_bios->flags & APM_FL_PM_DISENGAGED) printf("[disengaged] "); printf("\n"); if (req_ver >= 0x100) apm_bios->version_want = req_ver; if (req_ver != REQ_VER_NONE) { if (!apm_bios_connect(req_mode)) { fprintf(stderr,"Failed to connect to APM BIOS (last=0x%02X)\n",apm_bios->last_error); return 1; } printf("Connected to APM BIOS v%u.%u interface\n",apm_bios->major_neg,apm_bios->minor_neg); printf(" batteries: %u\n",apm_bios->batteries); printf(" capabilities:\n"); if (apm_bios->capabilities & 1) printf(" Can enter global standby state\n"); if (apm_bios->capabilities & 2) printf(" Can enter global suspend state\n"); if (apm_bios->capabilities & 4) printf(" Resume timer will wake from standby\n"); if (apm_bios->capabilities & 8) printf(" Resume timer will wake from suspend\n"); if (apm_bios->capabilities & 16) printf(" Resume on ring will wake from standby\n"); if (apm_bios->capabilities & 32) printf(" Resume on ring will wake from suspend\n"); if (apm_bios->capabilities & 64) printf(" PCMCIA ring indicator will wake up from standby\n"); if (apm_bios->capabilities & 128) printf(" PCMCIA ring indicator will wake up from suspend\n"); printf("\n"); } if (action == NULL) { } else if (!strcmp(action,"cpu-idle")) { printf("Issuing CPU idle command\n"); if (!apm_bios_cpu_idle()) fprintf(stderr,"CPU Idle failed\n"); } else if (!strcmp(action,"cpu-busy")) { printf("Issuing CPU busy command\n"); if (!apm_bios_cpu_busy()) fprintf(stderr,"CPU Busy failed\n"); } else if (!strcmp(action,"events")) { while (1) { signed long ev = apm_bios_pm_evnet(); if (ev >= 0LL) { printf("Event 0x%04X\n",(unsigned int)ev); } if (kbhit()) { if (getch() == 27) break; } } } else if (!strcmp(action,"status")) { apm_bios_update_status(); printf("AC=0x%X Batt=0x%X BattFlag=0x%X BattPercent=%u BattLife=%u%s\n", apm_bios->status_ac, apm_bios->status_battery, apm_bios->status_battery_flag, apm_bios->status_battery_life, apm_bios->status_battery_time&0x7FFF, (apm_bios->status_battery_time&0x8000)?"m":"s"); } else if (!strcmp(action,"standby")) { if (!apm_bios_power_state(APM_POWER_STANDBY)) fprintf(stderr,"Unable to set power state\n"); } else if (!strcmp(action,"suspend")) { if (!apm_bios_power_state(APM_POWER_SUSPEND)) fprintf(stderr,"Unable to set power state\n"); } else if (!strcmp(action,"off")) { if (!apm_bios_power_state(APM_POWER_OFF)) fprintf(stderr,"Unable to set power state\n"); } if (req_ver != REQ_VER_NONE && !dont_disconnect) { if (!apm_bios_connect(APM_CONNECT_NONE)) { fprintf(stderr,"Failed to disconnect\n"); } printf("Disconnected APM BIOS\n"); } return 0; }
int detect_virtualbox_emu() { #if defined(TARGET_OS2) /* TODO: So... how does one read the ROM BIOS area from OS/2? */ return 0; #elif defined(TARGET_WINDOWS) /* TODO: I know that from within Windows there are various ways to scan the ROM BIOS area. * Windows 1.x and 2.x (if real mode) we can just use MK_FP as we do under DOS, but * we have to use alternate means if Windows is in protected mode. Windows 2.x/3.x protected * mode (and because of compatibility, Windows 95/98/ME), there are two methods open to us: * One is to use selector constants that are hidden away in KRNL386.EXE with names like _A0000, * _B0000, etc. They are data selectors that when loaded into the segment registers point to * their respective parts of DOS adapter ROM and BIOS ROM. Another way is to use the Win16 * API to create a data selector that points to the BIOS. Windows 386 Enhanced mode may map * additional things over the unused parts of adapter ROM, but experience shows that it never * relocates or messes with the VGA BIOS or with the ROM BIOS, * * My memory is foggy at this point, but I remember that under Windows XP SP2, one of the * above Win16 methods still worked even from under the NT kernel. * * For Win32 applications, if the host OS is Windows 3.1 Win32s or Windows 95/98/ME, we can * take advantage of a strange quirk in the way the kernel maps the lower 1MB. For whatever * reason, the VGA RAM, adapter ROM, and ROM BIOS areas are left open even for Win32 applications * with no protection. Thus, a Win32 programmer can just make a pointer like * char *a = (char*)0xA0000 and scribble on legacy VGA RAM to his heart's content (though on * modern PCI SVGA hardware the driver probably instructs the card to disable VGA compatible * mapping). In fact, this ability to scribble on RAM directly is at the heart of one of Microsoft's * earliest and hackiest "Direct Draw" interfaces known as "DISPDIB.DLL", a not-to-well documented * library responsible for those Windows 3.1 multimedia apps and games that were somehow able to * run full-screen 320x200x256 color VGA despite being Windows GDI-based apps. Ever wonder how the * MCI AVI player was able to go full-screen when DirectX and WinG were not invented yet? Now you * know :) * * There are some VFW codecs out there as well, that also like to abuse DISPDIB.DLL for "fullscreen" * modes. One good example is the old "Motion Pixels" codec, that when asked to go fullscreen, * uses DISPDIB.DLL and direct VGA I/O port trickery to effectively set up a 320x480 256-color mode, * which it then draws on "fake hicolor" style to display the video (though a bit dim since you're * sort of watching a video through a dithered mesh, but...) * * In case you were probably wondering, no, Windows NT doesn't allow Win32 applications the same * privilege. Win32 apps writing to 0xA0000 would page fault and crash. Curiously enough though, * NTVDM.EXE does seem to open up the 0xA0000-0xFFFFF memory area to Win16 applications if they * use the right selectors and API calls. */ return 0; #else int i,j; # if TARGET_MSDOS == 32 const char *scan; # else const char far *scan; # endif probe_dos(); if (virtualbox_detect_cache >= 0) return (int)virtualbox_detect_cache; virtualbox_detect_cache=0; # if TARGET_MSDOS == 32 if (dos_flavor == DOS_FLAVOR_FREEDOS) { /* FIXME: I have no idea why but FreeDOS 1.0 has a strange conflict with DOS32a where if this code * tries to read the ROM BIOS it causes a GPF and crashes (or sometimes runs off into the * weeds leaving a little garbage on the screen). DOS32a's register dump seems to imply that * at one point our segment limits were suddenly limited to 1MB (0xFFFFF). I have no clue * what the hell is triggering it, but I know from testing we can avoid that crash by not * scanning. */ if (freedos_kernel_version == 0x000024UL) /* 0.0.36 */ return (virtualbox_detect_cache=0); } # endif /* test #1: the ROM BIOS region just prior to 0xF0000 is all zeros. * NTS: VirtualBox 4.1.8 also seems to have the ACPI tables at 0xE000:0x0000 */ # if TARGET_MSDOS == 32 scan = (const char*)0xEFF00; # else scan = (const char far*)MK_FP(0xE000,0xFF00); # endif for (i=0;i < 256;i++) { if (scan[i] != 0) return virtualbox_detect_cache; } /* test #2: somewhere within the first 4KB, are the strings "BIOS: " and * "VirtualBox " side by side separated by a NUL. The "VirtualBox" string is * followed by the version number, and "_OSE" if the open source version. */ # if TARGET_MSDOS == 32 scan = (const char*)0xF0000; # else scan = (const char far*)MK_FP(0xF000,0x0000); # endif for (i=0,j=0;i < 4096;i++) { if (scan[i] == virtualbox_bios_str[j]) { j++; if (virtualbox_bios_str[j] == 0 && scan[i+1] == 0) { /* good. found it. stop there. */ i++; break; } } else { j=0; } } /* if we didn't find the first string, then give up */ if (i >= 4096) return virtualbox_detect_cache; /* make sure the next string is "VirtualBox " */ for (/*do not reset 'i'*/j=0;i < 4096;i++) { if (scan[i] == virtualbox_vb_str[j]) { j++; if (virtualbox_vb_str[j] == 0) { /* good. found it. stop there. */ virtualbox_detect_cache = 1; break; } } else { j=0; } } if (i >= 4096) return virtualbox_detect_cache; /* 'i' now points at the version part of the string. copy it down */ while (i < 4096 && scan[i] == ' ') i++; for (j=0;j < (sizeof(virtualbox_version_str)-1) && i < 4096;) virtualbox_version_str[j++] = scan[i++]; virtualbox_version_str[j] = 0; return virtualbox_detect_cache; #endif }
int main() { #if defined(TARGET_WINDOWS) HWND hwnd; #endif unsigned char redraw; int c; probe_dos(); detect_windows(); #if !defined(TARGET_WINDOWS) if (!probe_8254()) { printf("8254 not found (I need this for time-sensitive portions of the driver)\n"); return 1; } #endif #if defined(TARGET_WINDOWS) # ifdef WIN_STDOUT_CONSOLE hwnd = _win_hwnd(); # else hwnd = GetFocus(); printf("WARNING: The Win32 console version is experimental. It generally works...\n"); printf(" but can run into problems if focus is taken or if the console window\n"); printf(" is started minimized or maximized. ENTER to continue, ESC to cancel.\n"); printf(" If this console is full-screen, hit ALT+ENTER to switch to window.\n"); do { c = getch(); if (c == 27) return 1; } while (c != 13); # endif # if TARGET_WINDOWS == 32 if (!InitWin16EB()) { MessageBox(hwnd,"Failed to init win16eb","Win16eb",MB_OK); return 1; } # endif /* setup DISPDIB */ if (DisplayDibLoadDLL()) { MessageBox(hwnd,dispDibLastError,"Failed to load DISPDIB.DLL",MB_OK); return 1; } if (DisplayDibCreateWindow(hwnd)) { MessageBox(hwnd,dispDibLastError,"Failed to create DispDib window",MB_OK); return 1; } if (DisplayDibGenerateTestImage()) { MessageBox(hwnd,dispDibLastError,"Failed to generate test card",MB_OK); return 1; } if (DisplayDibDoBegin()) { MessageBox(hwnd,dispDibLastError,"Failed to begin display",MB_OK); return 1; } #endif if (!probe_vga()) { #if defined(TARGET_WINDOWS) DisplayDibDoEnd(); DisplayDibUnloadDLL(); MessageBox(hwnd,"Probe failed","VGA lib",MB_OK); #else printf("VGA probe failed\n"); #endif return 1; } int10_setmode(3); update_state_from_vga(); redraw = 1; while (1) { if (redraw) { /* position the cursor to home */ vga_moveto(0,0); vga_sync_bios_cursor(); printf("ESC Exit to DOS A. 320x200x256 VGA\n"); } c = getch(); if (c == 27) break; else if (c == 'a' || c == 'A') v320x200x256_VGA_menu(); } #if defined(TARGET_WINDOWS) DisplayDibDoEnd(); if (DisplayDibUnloadDLL()) MessageBox(hwnd,dispDibLastError,"Failed to unload DISPDIB.DLL",MB_OK); # if TARGET_MSDOS == 32 FreeWin16EB(); # endif #endif return 0; }
int main(int argc,char **argv,char **envp) { unsigned int patience; char tmps[128]; uint32_t tmp; probe_dos(); detect_windows(); if (windows_mode == WINDOWS_NT) { printf("This program is not compatible with Windows NT\n"); return 1; } #if defined(TARGET_WINDOWS) && TARGET_MSDOS == 32 && !defined(WIN386) #else if (!probe_8254()) { printf("8254 not found (I need this for time-sensitive portions of the driver)\n"); return 1; } #endif if (!probe_dosbox_id()) { printf("DOSBox integration device not found\n"); return 1; } printf("DOSBox integration device found at I/O port %xh\n",dosbox_id_baseio); if (probe_dosbox_id_version_string(tmps,sizeof(tmps))) printf("DOSBox version string: '%s'\n",tmps); else printf("DOSBox version string N/A\n"); /* first check that the screenshot function is available */ dosbox_id_write_regsel(DOSBOX_ID_REG_SCREENSHOT_TRIGGER); tmp = dosbox_id_read_data(); if (tmp & DOSBOX_ID_SCREENSHOT_STATUS_NOT_AVAILABLE) { printf("DOSBox screenshot control register not available\n"); return 1; } else if (tmp & DOSBOX_ID_SCREENSHOT_STATUS_NOT_ENABLED) { printf("DOSBox screenshot control register not enabled\n"); return 1; } if (tmp & DOSBOX_ID_SCREENSHOT_STATUS_IMAGE_IN_PROGRESS) printf("WARNING: Screenshot already in progress\n"); printf("Triggering DOSBox screenshot function\n"); dosbox_id_debug_message("Triggering screenshot function\n"); /* trigger it */ dosbox_id_write_regsel(DOSBOX_ID_REG_SCREENSHOT_TRIGGER); dosbox_id_write_data(DOSBOX_ID_SCREENSHOT_IMAGE); /* did it trigger it? */ dosbox_id_write_regsel(DOSBOX_ID_REG_SCREENSHOT_TRIGGER); tmp = dosbox_id_read_data(); if (!(tmp & DOSBOX_ID_SCREENSHOT_STATUS_IMAGE_IN_PROGRESS)) { printf("DOSBox screenshot trigger failed.\n"); return 1; } /* wait for the screenshot to happen. * DOSBox will write the screenshot when VGA vertical retrace happens, which should be 1/70th of a second. * So if it doesn't happen within 1 second, then it failed. */ #if defined(TARGET_WINDOWS) && TARGET_MSDOS == 32 && !defined(WIN386) patience = 10; /* 1 second (10 x 100ms) (Windows 9x scheduler isn't THAT good!) */ #else patience = 1000; /* 1 second (1000 x 1ms) */ #endif do { if (--patience == 0) { printf("DOSBox failed to take screenshot (timeout)\n"); return 1; } #if defined(TARGET_WINDOWS) && TARGET_MSDOS == 32 && !defined(WIN386) Sleep(100); /* 100ms */ #else t8254_wait(t8254_us2ticks(1000)); /* 1ms */ #endif dosbox_id_write_regsel(DOSBOX_ID_REG_SCREENSHOT_TRIGGER); tmp = dosbox_id_read_data(); } while (tmp & DOSBOX_ID_SCREENSHOT_STATUS_IMAGE_IN_PROGRESS); printf("Screenshot done\n"); return 0; }
int main(int argc,char **argv) { probe_dos(); #ifdef TARGET_PC98 if (!probe_nec_pc98()) { printf("Sorry, your system is not PC-98\n"); return 1; } #else if (!probe_vga()) { printf("VGA probe failed\n"); return 1; } #endif if (!utty_init()) { printf("utty init fail\n"); return 1; } #ifdef TARGET_PC98 if (!utty_init_pc98()) { printf("utty init vga fail\n"); return 1; } #else if (!utty_init_vgalib()) { printf("utty init vga fail\n"); return 1; } #endif if (!utty_con_init()) { printf("utty con init\n"); return 1; } #if TARGET_MSDOS == 32 printf("Alpha ptr: %p\n",utty_funcs.vram); #else printf("Alpha ptr: %Fp\n",utty_funcs.vram); #endif printf("Size: %u x %u (stride=%u)\n",utty_funcs.w,utty_funcs.h,utty_funcs.stride); { const char *msg = "Hello world"; utty_offset_t o = utty_offset_getofs(4/*row*/,4/*col*/); UTTY_ALPHA_CHAR uch; unsigned char c; uch.f.at = UTTY_COLOR_MAKE_INTENSITY_FG(UTTY_COLOR_FB(/*f*/UTTY_COLOR_RED,/*b*/UTTY_COLOR_BLACK)); while ((c=(*msg++)) != 0) { uch.f.ch = c; o = utty_funcs.setchar(o,uch); } } { const char *msg = "Hello world"; utty_offset_t o = utty_offset_getofs(5/*row*/,4/*col*/); UTTY_ALPHA_CHAR uach[12],uch; unsigned int i=0; unsigned char c; uch.f.at = UTTY_COLOR_MAKE_INTENSITY_FG(UTTY_COLOR_FB(/*f*/UTTY_COLOR_GREEN,/*b*/UTTY_COLOR_BLACK)); while ((c=(*msg++)) != 0) { uch.f.ch = c; uach[i++] = uch; } assert(i < 12); utty_funcs.setcharblock(o,uach,i); } { #ifdef TARGET_PC98 const char *msg = "Hello world \x82\xb1\x82\xea\x82\xcd\x93\xfa\x96\x7b\x8c\xea\x82\xc5\x82\xb7"; #else const char *msg = "Hello world"; #endif utty_offset_t o = utty_offset_getofs(6/*row*/,4/*col*/); UTTY_ALPHA_CHAR uach[40],uch = UTTY_BLANK_CHAR; unsigned int i=0; uch.f.at = UTTY_COLOR_MAKE_INTENSITY_FG(UTTY_COLOR_FB(/*f*/UTTY_COLOR_BLUE,/*b*/UTTY_COLOR_BLACK)); i = utty_string2ac_const(uach,UTTY_ARRAY_LEN(uach),msg,uch); assert(i < 40); utty_funcs.setcharblock(o,uach,i); } { #ifdef TARGET_PC98 const char *msg = "Hello world \x82\xb1\x82\xea\x82\xcd\x93\xfa\x96\x7b\x8c\xea\x82\xc5\x82\xb7"; #else const char *msg = "Hello world"; #endif utty_offset_t o = utty_offset_getofs(7/*row*/,4/*col*/); UTTY_ALPHA_CHAR uach[UTTY_MAX_CHAR_WIDTH],uch = UTTY_BLANK_CHAR; const char *scan = msg,*scanfence = msg + strlen(msg); unsigned int i=0; uch.f.at = UTTY_COLOR_MAKE_INTENSITY_FG(UTTY_COLOR_FB(/*f*/UTTY_COLOR_WHITE,/*b*/UTTY_COLOR_BLACK)); while (*scan != 0) { i = utty_string2ac(uach,UTTY_ARRAY_LEN(uach),&scan,uch); assert(i <= UTTY_MAX_CHAR_WIDTH); utty_funcs.setcharblock(o,uach,i); o = utty_offset_advance(o,i); assert(scan <= scanfence); } } { #ifdef TARGET_PC98 const char *msg = "Hello world \x82\xb1\x82\xea\x82\xcd\x93\xfa\x96\x7b\x8c\xea\x82\xc5\x82\xb7"; #else const char *msg = "Hello world"; #endif utty_offset_t o = utty_offset_getofs(8/*row*/,4/*col*/); UTTY_ALPHA_CHAR uch = UTTY_BLANK_CHAR; #ifdef TARGET_PC98 uch.f.at = 0x00C1u; // yellow #else uch.f.at = 0x0Eu; // yellow #endif utty_printat_const(o,msg,uch); } { #ifdef TARGET_PC98 const char *msg = "Hello world \x82\xb1\x82\xea\x82\xcd\x93\xfa\x96\x7b\x8c\xea\x82\xc5\x82\xb7"; #else const char *msg = "Hello world"; #endif utty_offset_t o = utty_offset_getofs(9/*row*/,4/*col*/),ostp; UTTY_ALPHA_CHAR uch = UTTY_BLANK_CHAR; uch.f.at = UTTY_COLOR_FB(/*f*/UTTY_COLOR_BLACK,/*b*/UTTY_COLOR_YELLOW); ostp = utty_offset_advance(o,32); o = utty_printat_const(o,msg,uch); while (o < ostp) o = utty_funcs.setchar(o,uch); } { utty_con_poscurs(10/*row*/,0/*col*/); utty_con_write("Hello world\nHow are you?\n\nHello.\nThis is fun. Hello. Hello. Yay!\n"); #ifdef TARGET_PC98 utty_con_write("Hello world \x82\xb1\x82\xea\x82\xcd\x93\xfa\x96\x7b\x8c\xea\x82\xc5\x82\xb7\n"); #endif utty_con_write("Very very very very very long long long long long very very long longlonglonglonglonglong long long long too long\n"); #ifdef TARGET_PC98 // we purposely make the console split the "kore wa nihongo desu" string on an odd column to test wraparound utty_con_write("Hello world very very very very very very long long long long too long \x82\xb1\x82\xea\x82\xcd\x93\xfa\x96\x7b\x8c\xea\x82\xc5\x82\xb7\n"); utty_con_write("Hello world very very very very very very long long long long too longg \x82\xb1\x82\xea\x82\xcd\x93\xfa\x96\x7b\x8c\xea\x82\xc5\x82\xb7\n"); #endif } getch(); { unsigned int i; char tmp[64]; for (i=0;i < 25;i++) { sprintf(tmp,"Line. Line. Line. %u\n",i); utty_con_write(tmp); getch(); } } { unsigned int i; for (i=0;i < 5;i++) { getch(); utty_funcs.scroll( /*dofs*/utty_offset_getofs(utty_con.top ,utty_con.left), /*sofs*/utty_offset_getofs(utty_con.top+1u,utty_con.left), /*w*/utty_con.right - utty_con.left + 1u, /*h*/utty_con.bottom - utty_con.top); } } { unsigned int i; for (i=0;i < 5;i++) { getch(); utty_funcs.scroll( /*sofs*/utty_offset_getofs(utty_con.top+1u,utty_con.left), /*dofs*/utty_offset_getofs(utty_con.top ,utty_con.left), /*w*/utty_con.right - utty_con.left + 1u, /*h*/utty_con.bottom - utty_con.top); } } { unsigned int i; for (i=0;i < 3;i++) { getch(); utty_funcs.scroll( /*dofs*/utty_offset_getofs(utty_con.top+5u,utty_con.left+16u), /*sofs*/utty_offset_getofs(utty_con.top+6u,utty_con.left+16u), /*w*/5u, /*h*/5u); } } { unsigned int i; for (i=0;i < 3;i++) { getch(); utty_funcs.scroll( /*sofs*/utty_offset_getofs(utty_con.top+6u,utty_con.left+16u), /*dofs*/utty_offset_getofs(utty_con.top+5u,utty_con.left+16u), /*w*/5u, /*h*/5u); } } return 0; }