From c7cb4466840e154d53bb6c1aa5278676a27454d0 Mon Sep 17 00:00:00 2001 From: waltje Date: Wed, 11 Oct 2017 05:40:44 -0400 Subject: [PATCH] Another round of cleanups - the main code no longer refers to, let alone uses, anything in the platform folder - completely separated! --- src/Makefile.mingw | 15 +- src/cdrom/cdrom.c | 20 + src/config.c | 6 +- src/game/gameport.c | 2 +- src/game/joystick_ch_flightstick_pro.c | 2 +- src/game/joystick_standard.c | 2 +- src/game/joystick_sw_pad.c | 2 +- src/game/joystick_tm_fcs.c | 2 +- src/keyboard.c | 4 +- src/mouse_ps2.c | 2 +- src/network/net_pcap.c | 8 +- src/network/net_slirp.c | 6 +- src/network/pcap_if.c | 4 +- src/pc.c | 12 +- src/pit.c | 2 +- src/plat.h | 33 +- src/{win => }/plat_dir.h | 0 src/{win => }/plat_dynld.h | 0 src/{win => }/plat_joystick.h | 0 src/{win => }/plat_keyboard.h | 0 src/{win => }/plat_midi.h | 0 src/{win => }/plat_mouse.h | 0 src/{win => }/plat_serial.h | 2 +- src/ppi.c | 4 +- src/scsi/scsi_aha154x.c | 6 +- src/scsi/scsi_buslogic.c | 7 +- src/scsi/scsi_ncr5380.c | 4 +- src/sound/midi.c | 4 +- src/sound/midi_mt32.c | 2 +- src/sound/midi_system.c | 3 +- src/sound/sound.c | 15 +- src/video/vid_ati18800.c | 37 +- src/video/vid_ati28800.c | 45 +- src/video/vid_ati68860_ramdac.c | 59 +- src/video/vid_ati_eeprom.c | 21 +- src/video/vid_ati_mach64.c | 5 +- src/video/vid_bt485_ramdac.c | 28 +- src/video/vid_cga.c | 6 +- src/video/vid_cga_comp.c | 5 +- src/video/vid_cl_gd.c | 18 + src/video/vid_cl_gd_blit.c | 17 +- src/video/vid_cl_ramdac.c | 16 + src/video/vid_colorplus.c | 19 +- src/video/vid_ega.c | 5 +- src/video/vid_ega_render.c | 3 +- src/video/vid_et4000.c | 22 +- src/video/vid_et4000w32.c | 27 +- src/video/vid_et4000w32i.c | 31 +- src/video/vid_genius.c | 23 +- src/video/vid_hercules.c | 25 +- src/video/vid_herculesplus.c | 22 +- src/video/vid_icd2061.c | 27 +- src/video/vid_ics2595.c | 23 +- src/video/vid_incolor.c | 23 +- src/video/vid_mda.c | 25 +- src/video/vid_nv_riva128.c | 24 +- src/video/vid_olivetti_m24.c | 23 +- src/video/vid_oti067.c | 525 +++++----- src/video/vid_paradise.c | 28 +- src/video/vid_pc1512.c | 36 +- src/video/vid_pc1640.c | 24 +- src/video/vid_pc200.c | 26 +- src/video/vid_pcjr.c | 18 + src/video/vid_ps1_svga.c | 35 +- src/video/vid_s3.c | 21 +- src/video/vid_s3_virge.c | 24 +- src/video/vid_sc1502x_ramdac.c | 27 +- src/video/vid_sdac_ramdac.c | 25 +- src/video/vid_stg_ramdac.c | 22 +- src/video/vid_svga.c | 3 +- src/video/vid_svga_render.c | 4 +- src/video/vid_table.c | 298 ++++++ src/video/vid_tandy.c | 18 + src/video/vid_tandysl.c | 21 +- src/video/vid_tgui9440.c | 24 +- src/video/vid_tkd8001_ramdac.c | 22 +- src/video/vid_tvga.c | 22 +- src/video/vid_vga.c | 22 +- src/video/vid_voodoo.c | 22 +- src/video/vid_wy700.c | 19 +- src/video/video.c | 1231 +++++++++++------------- src/video/video.h | 204 ++-- src/win/plat_dinput.h | 4 - src/win/plat_thread.h | 32 - src/win/plat_ticks.h | 2 - src/win/win.c | 70 +- src/win/win_cgapal.h | 29 - src/win/win_d3d.cc | 11 +- src/win/win_d3d.h | 9 +- src/win/win_d3d_fs.cc | 125 +-- src/win/win_ddraw.cc | 7 +- src/win/win_ddraw.h | 1 + src/win/win_ddraw_fs.cc | 6 +- src/win/win_deviceconfig.c | 4 +- src/win/win_dynld.c | 5 +- src/win/win_joystick.cc | 6 +- src/win/win_joystickconfig.c | 3 +- src/win/win_keyboard.c | 19 +- src/win/win_midi.c | 7 +- src/win/win_mouse.cc | 6 +- src/win/win_opendir.c | 6 +- src/win/win_serial.c | 19 +- src/win/win_settings.c | 2 +- src/win/win_thread.c | 5 +- src/win/win_video.c | 57 -- 105 files changed, 2319 insertions(+), 1585 deletions(-) rename src/{win => }/plat_dir.h (100%) rename src/{win => }/plat_dynld.h (100%) rename src/{win => }/plat_joystick.h (100%) rename src/{win => }/plat_keyboard.h (100%) rename src/{win => }/plat_midi.h (100%) rename src/{win => }/plat_mouse.h (100%) rename src/{win => }/plat_serial.h (98%) create mode 100644 src/video/vid_table.c delete mode 100644 src/win/plat_dinput.h delete mode 100644 src/win/plat_thread.h delete mode 100644 src/win/plat_ticks.h delete mode 100644 src/win/win_cgapal.h delete mode 100644 src/win/win_video.c diff --git a/src/Makefile.mingw b/src/Makefile.mingw index c4712b04e..7c6a6bd3f 100644 --- a/src/Makefile.mingw +++ b/src/Makefile.mingw @@ -8,7 +8,7 @@ # # Modified Makefile for Win32 (MinGW32) environment. # -# Version: @(#)Makefile.mingw 1.0.55 2017/10/09 +# Version: @(#)Makefile.mingw 1.0.56 2017/10/10 # # Authors: Miran Grca, # Fred N. van Kempen, @@ -327,6 +327,7 @@ SNDOBJ := sound.o \ snd_ym7128.o VIDOBJ := video.o \ + vid_table.o \ vid_cga.o vid_cga_comp.o vid_mda.o \ vid_ega.o vid_ega_render.o \ vid_vga.o vid_svga.o vid_svga_render.o \ @@ -353,18 +354,18 @@ VIDOBJ := video.o \ vid_pc200.o \ vid_tandy.o vid_tandysl.o -WINOBJ := win.o \ +PLATOBJ := win.o \ win_ddraw.o win_ddraw_fs.o win_d3d.o win_d3d_fs.o \ + win_dynld.o win_thread.o $(WSERIAL) win_cdrom.o win_cdrom_ioctl.o \ + win_keyboard.o win_mouse.o win_joystick.o win_midi.o \ win_dialog.o win_about.o win_status.o win_stbar.o \ - win_settings.o $(OPENDIR) win_dynld.o win_video.o \ - $(WSERIAL) win_keyboard.o win_mouse.o win_joystick.o \ - win_midi.o win_cdrom.o win_cdrom_ioctl.o \ - win_thread.o win_deviceconfig.o win_joystickconfig.o + win_settings.o win_deviceconfig.o win_joystickconfig.o \ + $(OPENDIR) OBJ := $(MAINOBJ) $(CPUOBJ) $(MCHOBJ) $(DEVOBJ) \ $(FDDOBJ) $(CDROMOBJ) $(HDDOBJ) \ $(USBOBJ) $(NETOBJ) $(SCSIOBJ) $(SNDOBJ) $(VIDOBJ) \ - $(WINOBJ) $(DEVBROBJ) + $(PLATOBJ) $(DEVBROBJ) ifdef EXOBJ OBJ += $(EXOBJ) endif diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index 5606cb9e5..82792156c 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -22,6 +22,7 @@ #include #include #include "../86box.h" +#include "../config.h" #include "../ibm.h" #include "../timer.h" #include "../device.h" @@ -4012,3 +4013,22 @@ void cdrom_general_init(void) } } } + + +void +cdrom_close(uint8_t id) +{ + switch (cdrom_drives[id].host_drive) { + case 0: + null_close(id); + break; + + case 200: + image_close(id); + break; + + default: + ioctl_close(id); + break; + } +} diff --git a/src/config.c b/src/config.c index fb2fa9174..6d33c0675 100644 --- a/src/config.c +++ b/src/config.c @@ -8,7 +8,7 @@ * * Configuration file handler. * - * Version: @(#)config.c 1.0.15 2017/10/09 + * Version: @(#)config.c 1.0.16 2017/10/10 * * Authors: Sarah Walker, * Miran Grca, @@ -54,8 +54,8 @@ #include "sound/sound.h" #include "video/video.h" #include "ui.h" -#include "win/plat_joystick.h" -#include "win/plat_midi.h" +#include "plat_joystick.h" +#include "plat_midi.h" typedef struct _list_ { diff --git a/src/game/gameport.c b/src/game/gameport.c index 624955027..7410abdd9 100644 --- a/src/game/gameport.c +++ b/src/game/gameport.c @@ -16,7 +16,7 @@ #include "joystick_standard.h" #include "joystick_sw_pad.h" #include "joystick_tm_fcs.h" -#include "../win/plat_joystick.h" +#include "../plat_joystick.h" int joystick_type; diff --git a/src/game/joystick_ch_flightstick_pro.c b/src/game/joystick_ch_flightstick_pro.c index 8e62e268f..ffec5e7bf 100644 --- a/src/game/joystick_ch_flightstick_pro.c +++ b/src/game/joystick_ch_flightstick_pro.c @@ -6,7 +6,7 @@ #include "../ibm.h" #include "../device.h" #include "../timer.h" -#include "../win/plat_joystick.h" +#include "../plat_joystick.h" #include "gameport.h" #include "joystick_standard.h" diff --git a/src/game/joystick_standard.c b/src/game/joystick_standard.c index 582cdcdb3..329355d0e 100644 --- a/src/game/joystick_standard.c +++ b/src/game/joystick_standard.c @@ -6,7 +6,7 @@ #include "../ibm.h" #include "../device.h" #include "../timer.h" -#include "../win/plat_joystick.h" +#include "../plat_joystick.h" #include "gameport.h" #include "joystick_standard.h" diff --git a/src/game/joystick_sw_pad.c b/src/game/joystick_sw_pad.c index 842931629..f127d2f49 100644 --- a/src/game/joystick_sw_pad.c +++ b/src/game/joystick_sw_pad.c @@ -27,7 +27,7 @@ #include "../ibm.h" #include "../device.h" #include "../timer.h" -#include "../win/plat_joystick.h" +#include "../plat_joystick.h" #include "gameport.h" #include "joystick_sw_pad.h" diff --git a/src/game/joystick_tm_fcs.c b/src/game/joystick_tm_fcs.c index eda1da086..2fcbe4920 100644 --- a/src/game/joystick_tm_fcs.c +++ b/src/game/joystick_tm_fcs.c @@ -6,7 +6,7 @@ #include "../ibm.h" #include "../device.h" #include "../timer.h" -#include "../win/plat_joystick.h" +#include "../plat_joystick.h" #include "gameport.h" #include "joystick_standard.h" diff --git a/src/keyboard.c b/src/keyboard.c index 950b6ccec..8a4bbdf5b 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -8,7 +8,7 @@ * * Host to guest keyboard interface and keyboard scan code sets. * - * Version: @(#)keyboard.c 1.0.3 2017/10/09 + * Version: @(#)keyboard.c 1.0.4 2017/10/10 * * Authors: Sarah Walker, * Miran Grca, @@ -21,7 +21,7 @@ #include #include #include "ibm.h" -#include "win/plat_keyboard.h" +#include "plat_keyboard.h" #include "keyboard.h" diff --git a/src/mouse_ps2.c b/src/mouse_ps2.c index 00cda945d..a7dd4319a 100644 --- a/src/mouse_ps2.c +++ b/src/mouse_ps2.c @@ -6,7 +6,7 @@ #include "ibm.h" #include "keyboard_at.h" #include "mouse.h" -#include "win/plat_mouse.h" +#include "plat_mouse.h" int mouse_scan = 0; diff --git a/src/network/net_pcap.c b/src/network/net_pcap.c index 3003c765f..c1831e1b7 100644 --- a/src/network/net_pcap.c +++ b/src/network/net_pcap.c @@ -8,9 +8,11 @@ * * Handle WinPcap library processing. * - * Version: @(#)net_pcap.c 1.0.7 2017/10/09 + * Version: @(#)net_pcap.c 1.0.8 2017/10/10 * * Author: Fred N. van Kempen, + * + * Copyright 2017 Fred N. van Kempen. */ #include #include @@ -21,8 +23,8 @@ #include "../ibm.h" #include "../config.h" #include "../device.h" -#include "../win/plat_dynld.h" -#include "../win/plat_thread.h" +#include "../plat.h" +#include "../plat_dynld.h" #include "network.h" diff --git a/src/network/net_slirp.c b/src/network/net_slirp.c index 1299d89c6..ce5f1cc43 100644 --- a/src/network/net_slirp.c +++ b/src/network/net_slirp.c @@ -8,9 +8,11 @@ * * Handle SLiRP library processing. * - * Version: @(#)net_slirp.c 1.0.6 2017/10/09 + * Version: @(#)net_slirp.c 1.0.7 2017/10/10 * * Author: Fred N. van Kempen, + * + * Copyright 2017 Fred N. van Kempen. */ #include #include @@ -22,7 +24,7 @@ #include "../ibm.h" #include "../config.h" #include "../device.h" -#include "../win/plat_thread.h" +#include "../plat.h" #include "network.h" diff --git a/src/network/pcap_if.c b/src/network/pcap_if.c index 7122e5ff4..2d1c525d1 100644 --- a/src/network/pcap_if.c +++ b/src/network/pcap_if.c @@ -10,7 +10,7 @@ * * Based on the "libpcap" examples. * - * Version: @(#)pcap_if.c 1.0.4 2017/10/09 + * Version: @(#)pcap_if.c 1.0.5 2017/10/10 * * Author: Fred N. van Kempen, * @@ -21,7 +21,7 @@ #include #include #include -#include "../win/plat_dynld.h" +#include "../plat_dynld.h" static void *pcap_handle; /* handle to WinPcap DLL */ diff --git a/src/pc.c b/src/pc.c index 9591355e4..047c4c0dc 100644 --- a/src/pc.c +++ b/src/pc.c @@ -8,7 +8,7 @@ * * Emulation core dispatcher. * - * Version: @(#)pc.c 1.0.21 2017/10/10 + * Version: @(#)pc.c 1.0.22 2017/10/10 * * Authors: Sarah Walker, * Miran Grca, @@ -70,15 +70,15 @@ #ifdef WALTJE # define UNICODE # include -# include "win/plat_dir.h" +# include "plat_dir.h" # undef UNICODE #endif #include "ui.h" #include "plat.h" -#include "win/plat_joystick.h" -#include "win/plat_keyboard.h" -#include "win/plat_midi.h" -#include "win/plat_mouse.h" +#include "plat_joystick.h" +#include "plat_keyboard.h" +#include "plat_midi.h" +#include "plat_mouse.h" int window_w, window_h, window_x, window_y, window_remember; diff --git a/src/pit.c b/src/pit.c index ea0a798e1..493e0a130 100644 --- a/src/pit.c +++ b/src/pit.c @@ -43,7 +43,7 @@ void setpitclock(float clock) VGACONST2=(clock/28322000.0); isa_timing = clock/8000000.0; bus_timing = clock/(double)cpu_busspeed; - video_updatetiming(); + video_update_timing(); xt_cpu_multi = (int64_t)((14318184.0*(double)(1 << TIMER_SHIFT)) / (double)machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed); RTCCONST=clock/32768.0; diff --git a/src/plat.h b/src/plat.h index 282a02436..e49a29fe0 100644 --- a/src/plat.h +++ b/src/plat.h @@ -8,7 +8,7 @@ * * Define the various platform support functions. * - * Version: @(#)plat.h 1.0.2 2017/10/09 + * Version: @(#)plat.h 1.0.3 2017/10/10 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -34,6 +34,7 @@ extern int dir_check_exist(wchar_t *path); extern int dir_create(wchar_t *path); extern void leave_fullscreen(void); + /* Resource management. */ extern wchar_t *plat_get_string(int id); extern wchar_t *plat_get_string_from_string(char *str); @@ -56,14 +57,44 @@ extern void ioctl_reset(uint8_t id); extern void ioctl_close(uint8_t id); +/* Thread support. */ +typedef void thread_t; +typedef void event_t; + +extern thread_t *thread_create(void (*thread_rout)(void *param), void *param); +extern void thread_kill(thread_t *handle); + +extern event_t *thread_create_event(void); +extern void thread_set_event(event_t *event); +extern void thread_reset_event(event_t *_event); +extern int thread_wait_event(event_t *event, int timeout); +extern void thread_destroy_event(event_t *_event); + +extern void thread_sleep(int t); + +extern void *thread_create_mutex(wchar_t *name); +extern void thread_close_mutex(void *mutex); +extern uint8_t thread_wait_mutex(void *mutex); +extern uint8_t thread_release_mutex(void *mutex); + + /* Other stuff. */ extern void startblit(void); extern void endblit(void); +extern void take_screenshot(void); + + +extern uint32_t get_ticks(void); +extern void delay_ms(uint32_t count); #ifdef __cplusplus } #endif +extern void startslirp(void); +extern void endslirp(void); + + #endif /*EMU_PLAT_H*/ diff --git a/src/win/plat_dir.h b/src/plat_dir.h similarity index 100% rename from src/win/plat_dir.h rename to src/plat_dir.h diff --git a/src/win/plat_dynld.h b/src/plat_dynld.h similarity index 100% rename from src/win/plat_dynld.h rename to src/plat_dynld.h diff --git a/src/win/plat_joystick.h b/src/plat_joystick.h similarity index 100% rename from src/win/plat_joystick.h rename to src/plat_joystick.h diff --git a/src/win/plat_keyboard.h b/src/plat_keyboard.h similarity index 100% rename from src/win/plat_keyboard.h rename to src/plat_keyboard.h diff --git a/src/win/plat_midi.h b/src/plat_midi.h similarity index 100% rename from src/win/plat_midi.h rename to src/plat_midi.h diff --git a/src/win/plat_mouse.h b/src/plat_mouse.h similarity index 100% rename from src/win/plat_mouse.h rename to src/plat_mouse.h diff --git a/src/win/plat_serial.h b/src/plat_serial.h similarity index 98% rename from src/win/plat_serial.h rename to src/plat_serial.h index 56cf08126..dc3fc338b 100644 --- a/src/win/plat_serial.h +++ b/src/plat_serial.h @@ -21,7 +21,7 @@ typedef struct { char name[80]; /* name of open port */ void (*rd_done)(void *, int); void *rd_arg; -#ifdef BHTTY_C +#ifdef PLAT_SERIAL_C HANDLE handle; OVERLAPPED rov, /* READ and WRITE events */ wov; diff --git a/src/ppi.c b/src/ppi.c index 2b92eb9aa..2fb10ec21 100644 --- a/src/ppi.c +++ b/src/ppi.c @@ -13,8 +13,8 @@ #include #include "ibm.h" #include "pit.h" -#include "win/plat_keyboard.h" -#include "win/plat_mouse.h" +#include "plat_keyboard.h" +#include "plat_mouse.h" PPI ppi; diff --git a/src/scsi/scsi_aha154x.c b/src/scsi/scsi_aha154x.c index b896ccb16..02021a4fd 100644 --- a/src/scsi/scsi_aha154x.c +++ b/src/scsi/scsi_aha154x.c @@ -12,7 +12,7 @@ * * NOTE: THIS IS CURRENTLY A MESS, but will be cleaned up as I go. * - * Version: @(#)scsi_aha154x.c 1.0.25 2017/10/10 + * Version: @(#)scsi_aha154x.c 1.0.26 2017/10/10 * * Authors: Fred N. van Kempen, * Original Buslogic version by SA1988 and Miran Grca. @@ -36,7 +36,7 @@ #include "../pic.h" #include "../timer.h" #include "../device.h" -#include "../win/plat_thread.h" +#include "../plat.h" #include "scsi.h" #include "scsi_bios_command.h" #include "scsi_device.h" @@ -449,7 +449,7 @@ static void aha_cmd_thread(void *priv); static thread_t *poll_tid; -#if ENABLE_AHA154X_LOG +#ifdef ENABLE_AHA154X_LOG int aha_do_log = ENABLE_AHA154X_LOG; #endif diff --git a/src/scsi/scsi_buslogic.c b/src/scsi/scsi_buslogic.c index 9745bf26f..5e6666b7b 100644 --- a/src/scsi/scsi_buslogic.c +++ b/src/scsi/scsi_buslogic.c @@ -10,11 +10,12 @@ * 0 - BT-545C ISA; * 1 - BT-958D PCI (but BT-545C ISA on non-PCI machines) * - * Version: @(#)scsi_buslogic.c 1.0.20 2017/10/10 + * Version: @(#)scsi_buslogic.c 1.0.21 2017/10/10 * * Authors: TheCollector1995, * Miran Grca, * Fred N. van Kempen, + * * Copyright 2016,2017 Miran Grca. * Copyright 2017 Fred N. van Kempen. */ @@ -34,7 +35,7 @@ #include "../pci.h" #include "../timer.h" #include "../device.h" -#include "../win/plat_thread.h" +#include "../plat.h" #include "scsi.h" #include "scsi_bios_command.h" #include "scsi_device.h" @@ -530,7 +531,7 @@ enum { CHIP_BUSLOGIC_PCI }; -#if ENABLE_BUSLOGIC_LOG +#ifdef ENABLE_BUSLOGIC_LOG int buslogic_do_log = ENABLE_BUSLOGIC_LOG; #endif diff --git a/src/scsi/scsi_ncr5380.c b/src/scsi/scsi_ncr5380.c index d0c897677..27c5c442c 100644 --- a/src/scsi/scsi_ncr5380.c +++ b/src/scsi/scsi_ncr5380.c @@ -9,7 +9,7 @@ * Implementation of the NCR 5380 series of SCSI Host Adapters * made by NCR. These controllers were designed for the ISA bus. * - * Version: @(#)scsi_ncr5380.c 1.0.2 2017/10/08 + * Version: @(#)scsi_ncr5380.c 1.0.3 2017/10/10 * * Authors: Sarah Walker, * TheCollector1995, @@ -31,7 +31,7 @@ #include "../pic.h" #include "../timer.h" #include "../device.h" -#include "../win/plat_thread.h" +#include "../plat.h" #include "scsi.h" #include "scsi_device.h" #include "scsi_ncr5380.h" diff --git a/src/sound/midi.c b/src/sound/midi.c index 1c53875a5..1c70b252d 100644 --- a/src/sound/midi.c +++ b/src/sound/midi.c @@ -5,8 +5,8 @@ #include #include "../device.h" #include "../ibm.h" -#include "../win/plat_midi.h" -#include "../win/plat_ticks.h" +#include "../plat.h" +#include "../plat_midi.h" #include "midi.h" #include "midi_system.h" #ifdef USE_FLUIDSYNTH diff --git a/src/sound/midi_mt32.c b/src/sound/midi_mt32.c index 7bfcddd63..eab3e7dab 100644 --- a/src/sound/midi_mt32.c +++ b/src/sound/midi_mt32.c @@ -4,11 +4,11 @@ #include #include #include "munt/c_interface/c_interface.h" -#include "../win/plat_thread.h" #include "../ibm.h" #include "../device.h" #include "../mem.h" #include "../rom.h" +#include "../plat.h" #include "sound.h" #include "midi.h" #include "midi_mt32.h" diff --git a/src/sound/midi_system.c b/src/sound/midi_system.c index f8c20f29a..982049bdc 100644 --- a/src/sound/midi_system.c +++ b/src/sound/midi_system.c @@ -4,7 +4,8 @@ #include #include #include "../device.h" -#include "../win/plat_midi.h" +#include "../plat.h" +#include "../plat_midi.h" #include "midi.h" #include "midi_system.h" diff --git a/src/sound/sound.c b/src/sound/sound.c index 83a1f18d8..a45a88df1 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -8,10 +8,11 @@ * * Sound emulation core. * - * Version: @(#)sound.c 1.0.4 2017/09/24 + * Version: @(#)sound.c 1.0.5 2017/10/10 * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ @@ -24,16 +25,14 @@ #include "../device.h" #include "../timer.h" #include "../cdrom/cdrom.h" -#include "../win/plat_thread.h" +#include "../plat.h" #include "sound.h" #include "midi.h" #include "snd_opl.h" #include "snd_adlib.h" #include "snd_adlibgold.h" -#ifdef DEV_BRANCH -# ifdef USE_PAS16 -# include "snd_pas16.h" -# endif +#if defined(DEV_BRANCH) && defined(USE_PAS16) +# include "snd_pas16.h" #endif #include "snd_sb.h" #include "snd_sb_dsp.h" @@ -64,10 +63,8 @@ static SOUND_CARD sound_cards[] = { "[ISA] Sound Blaster Pro v2", "sbprov2", &sb_pro_v2_device }, { "[ISA] Sound Blaster 16", "sb16", &sb_16_device }, { "[ISA] Sound Blaster AWE32", "sbawe32", &sb_awe32_device }, -#ifdef DEV_BRANCH -#ifdef USE_PAS16 +#if defined(DEV_BRANCH) && defined(USE_PAS16) { "[ISA] Pro Audio Spectrum 16","pas16", &pas16_device }, -#endif #endif { "[ISA] Windows Sound System", "wss", &wss_device }, { "[MCA] Adlib", "adlib_mca", &adlib_mca_device }, diff --git a/src/video/vid_ati18800.c b/src/video/vid_ati18800.c index cb69788cb..8794af217 100644 --- a/src/video/vid_ati18800.c +++ b/src/video/vid_ati18800.c @@ -1,7 +1,21 @@ -/* Copyright holders: Sarah Walker, Melissa Goad - see COPYING for more details -*/ -/*ATI 18800 emulation (VGA Edge-16)*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * ATI 18800 emulation (VGA Edge-16) + * + * Version: @(#)vid_ati18800.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include @@ -29,7 +43,8 @@ typedef struct ati18800_t int index; } ati18800_t; -void ati18800_out(uint16_t addr, uint8_t val, void *p) + +static void ati18800_out(uint16_t addr, uint8_t val, void *p) { ati18800_t *ati18800 = (ati18800_t *)p; svga_t *svga = &ati18800->svga; @@ -103,7 +118,7 @@ void ati18800_out(uint16_t addr, uint8_t val, void *p) svga_out(addr, val, svga); } -uint8_t ati18800_in(uint16_t addr, void *p) +static uint8_t ati18800_in(uint16_t addr, void *p) { ati18800_t *ati18800 = (ati18800_t *)p; svga_t *svga = &ati18800->svga; @@ -162,7 +177,7 @@ void ati18800_recalctimings(svga_t *svga) } } -void *ati18800_init(device_t *info) +static void *ati18800_init(device_t *info) { ati18800_t *ati18800 = malloc(sizeof(ati18800_t)); memset(ati18800, 0, sizeof(ati18800_t)); @@ -190,7 +205,7 @@ static int ati18800_available(void) return rom_present(L"roms/video/ati18800/vga88.BIN"); } -void ati18800_close(void *p) +static void ati18800_close(void *p) { ati18800_t *ati18800 = (ati18800_t *)p; @@ -199,21 +214,21 @@ void ati18800_close(void *p) free(ati18800); } -void ati18800_speed_changed(void *p) +static void ati18800_speed_changed(void *p) { ati18800_t *ati18800 = (ati18800_t *)p; svga_recalctimings(&ati18800->svga); } -void ati18800_force_redraw(void *p) +static void ati18800_force_redraw(void *p) { ati18800_t *ati18800 = (ati18800_t *)p; ati18800->svga.fullchange = changeframecount; } -void ati18800_add_status_info(char *s, int max_len, void *p) +static void ati18800_add_status_info(char *s, int max_len, void *p) { ati18800_t *ati18800 = (ati18800_t *)p; diff --git a/src/video/vid_ati28800.c b/src/video/vid_ati28800.c index a1a015ae4..99709def8 100644 --- a/src/video/vid_ati28800.c +++ b/src/video/vid_ati28800.c @@ -1,7 +1,21 @@ -/* Copyright holders: Sarah Walker, Tenshi - see COPYING for more details -*/ -/*ATI 28800 emulation (VGA Charger)*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * ATI 28800 emulation (VGA Charger) + * + * Version: @(#)vid_ati28800.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include @@ -31,9 +45,11 @@ typedef struct ati28800_t int index; } ati28800_t; -void ati28800_svga_recalctimings(ati28800_t *ati28800); -void ati28800_out(uint16_t addr, uint8_t val, void *p) +static void ati28800_svga_recalctimings(ati28800_t *ati28800); + + +static void ati28800_out(uint16_t addr, uint8_t val, void *p) { ati28800_t *ati28800 = (ati28800_t *)p; svga_t *svga = &ati28800->svga; @@ -101,7 +117,7 @@ void ati28800_out(uint16_t addr, uint8_t val, void *p) svga_out(addr, val, svga); } -uint8_t ati28800_in(uint16_t addr, void *p) +static uint8_t ati28800_in(uint16_t addr, void *p) { ati28800_t *ati28800 = (ati28800_t *)p; svga_t *svga = &ati28800->svga; @@ -155,7 +171,7 @@ uint8_t ati28800_in(uint16_t addr, void *p) return temp; } -void ati28800_svga_recalctimings(ati28800_t *ati28800) +static void ati28800_svga_recalctimings(ati28800_t *ati28800) { double crtcconst; double _dispontime, _dispofftime, disptime; @@ -307,7 +323,8 @@ void ati28800_svga_recalctimings(ati28800_t *ati28800) pclog("svga->render %08X\n", svga->render);*/ } -void ati28800_recalctimings(svga_t *svga) + +static void ati28800_recalctimings(svga_t *svga) { ati28800_t *ati28800 = (ati28800_t *)svga->p; uint8_t clock_sel = (svga->miscout >> 2) & 3; @@ -354,7 +371,7 @@ void ati28800_recalctimings(svga_t *svga) } } -void *ati28800_init(device_t *info) +static void *ati28800_init(device_t *info) { uint32_t memory = 512; ati28800_t *ati28800; @@ -411,7 +428,7 @@ static int ati28800_wonderxl24_available(void) return (rom_present(L"roms/video/ati28800/112-14318-102.bin") && rom_present(L"roms/video/ati28800/112-14319-102.bin")); } -void ati28800_close(void *p) +static void ati28800_close(void *p) { ati28800_t *ati28800 = (ati28800_t *)p; @@ -420,21 +437,21 @@ void ati28800_close(void *p) free(ati28800); } -void ati28800_speed_changed(void *p) +static void ati28800_speed_changed(void *p) { ati28800_t *ati28800 = (ati28800_t *)p; ati28800_svga_recalctimings(ati28800); } -void ati28800_force_redraw(void *p) +static void ati28800_force_redraw(void *p) { ati28800_t *ati28800 = (ati28800_t *)p; ati28800->svga.fullchange = changeframecount; } -void ati28800_add_status_info(char *s, int max_len, void *p) +static void ati28800_add_status_info(char *s, int max_len, void *p) { ati28800_t *ati28800 = (ati28800_t *)p; diff --git a/src/video/vid_ati68860_ramdac.c b/src/video/vid_ati68860_ramdac.c index d67c90652..c82dbc4bc 100644 --- a/src/video/vid_ati68860_ramdac.c +++ b/src/video/vid_ati68860_ramdac.c @@ -1,26 +1,41 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -/*ATI 68860 RAMDAC emulation (for Mach64)*/ /* -ATI 68860/68880 Truecolor DACs: -REG08 (R/W): -bit 0-? Always 2 ?? - -REG0A (R/W): -bit 0-? Always 1Dh ?? - -REG0B (R/W): (GMR ?) -bit 0-7 Mode. 82h: 4bpp, 83h: 8bpp, A0h: 15bpp, A1h: 16bpp, C0h: 24bpp, - E3h: 32bpp (80h for VGA modes ?) - -REG0C (R/W): Device Setup Register A -bit 0 Controls 6/8bit DAC. 0: 8bit DAC/LUT, 1: 6bit DAC/LUT - 2-3 Depends on Video memory (= VRAM width ?) . 1: Less than 1Mb, 2: 1Mb, - 3: > 1Mb - 5-6 Always set ? - 7 If set can remove "snow" in some cases (A860_Delay_L ?) ?? -*/ + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * ATI 68860 RAMDAC emulation (for Mach64) + * + * ATI 68860/68880 Truecolor DACs: + * REG08 (R/W): + * bit 0-? Always 2 ?? + * + * REG0A (R/W): + * bit 0-? Always 1Dh ?? + * + * REG0B (R/W): (GMR ?) + * bit 0-7 Mode. 82h: 4bpp, 83h: 8bpp, + * A0h: 15bpp, A1h: 16bpp, C0h: 24bpp, + * E3h: 32bpp (80h for VGA modes ?) + * + * REG0C (R/W): Device Setup Register A + * bit 0 Controls 6/8bit DAC. 0: 8bit DAC/LUT, 1: 6bit DAC/LUT + * 2-3 Depends on Video memory (= VRAM width ?) . + * 1: Less than 1Mb, 2: 1Mb, 3: > 1Mb + * 5-6 Always set ? + * 7 If set can remove "snow" in some cases + * (A860_Delay_L ?) ?? + * + * Version: @(#)vid_ati68860.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_ati_eeprom.c b/src/video/vid_ati_eeprom.c index fdb819761..b2d5ae6c8 100644 --- a/src/video/vid_ati_eeprom.c +++ b/src/video/vid_ati_eeprom.c @@ -1,6 +1,21 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Emulation of the EEPROM on select ATI cards. + * + * Version: @(#)vid_ati_eeprom.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_ati_mach64.c b/src/video/vid_ati_mach64.c index 2ab02f2de..3f707d8cf 100644 --- a/src/video/vid_ati_mach64.c +++ b/src/video/vid_ati_mach64.c @@ -8,10 +8,11 @@ * * ATi Mach64 graphics card emulation. * - * Version: @(#)vid_ati_mach64.c 1.0.3 2017/10/04 + * Version: @(#)vid_ati_mach64.c 1.0.4 2017/10/10 * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ @@ -26,7 +27,7 @@ #include "../mem.h" #include "../pci.h" #include "../rom.h" -#include "../win/plat_thread.h" +#include "../plat.h" #include "video.h" #include "vid_svga.h" #include "vid_svga_render.h" diff --git a/src/video/vid_bt485_ramdac.c b/src/video/vid_bt485_ramdac.c index b53ab7bf4..ee97b6d60 100644 --- a/src/video/vid_bt485_ramdac.c +++ b/src/video/vid_bt485_ramdac.c @@ -1,13 +1,29 @@ -/* Copyright holders: Tenshi - see COPYING for more details -*/ -/*Brooktree BT485 true colour RAMDAC emulation*/ -/*Currently only a dummy stub for logging and passing output to the generic SVGA handler*/ -#include "../ibm.h" +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Brooktree BT485 true colour RAMDAC emulation. + * + * Currently only a dummy stub for logging and passing output + * to the generic SVGA handler. + * + * Version: @(#)vid_bt485_ramdac.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include #include +#include "../ibm.h" #include "../mem.h" #include "video.h" #include "vid_svga.h" diff --git a/src/video/vid_cga.c b/src/video/vid_cga.c index 54825fb77..d63e9c0e6 100644 --- a/src/video/vid_cga.c +++ b/src/video/vid_cga.c @@ -8,10 +8,11 @@ * * Emulation of the old and new IBM CGA graphics cards. * - * Version: @(#)vid_cga.c 1.0.3 2017/10/04 + * Version: @(#)vid_cga.c 1.0.4 2017/10/10 * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ @@ -30,9 +31,6 @@ #include "video.h" #include "vid_cga.h" #include "vid_cga_comp.h" -#ifndef __unix -# include "../win/win_cgapal.h" /*YUCK*/ -#endif #define CGA_RGB 0 diff --git a/src/video/vid_cga_comp.c b/src/video/vid_cga_comp.c index de243e019..407e38726 100644 --- a/src/video/vid_cga_comp.c +++ b/src/video/vid_cga_comp.c @@ -9,12 +9,13 @@ * IBM CGA composite filter, borrowed from reenigne's DOSBox * patch and ported to C. * - * Version: @(#)vid_cga.c 1.0.1 2017/09/24 + * Version: @(#)vid_cga_comp.c 1.0.2 2017/10/10 * * Authors: reenigne, * Miran Grca, + * * Copyright 2015-2017 reenigne. - * Copyright 2015,2017 Miran Grca. + * Copyright 2015-2017 Miran Grca. */ #include #include diff --git a/src/video/vid_cl_gd.c b/src/video/vid_cl_gd.c index 61339f2b3..ffb58f4b3 100644 --- a/src/video/vid_cl_gd.c +++ b/src/video/vid_cl_gd.c @@ -1,3 +1,21 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Emulation of select Cirrus Logic cards. + * + * Version: @(#)vid_cl_gd.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_cl_gd_blit.c b/src/video/vid_cl_gd_blit.c index 4e17e94a3..28c58b692 100644 --- a/src/video/vid_cl_gd_blit.c +++ b/src/video/vid_cl_gd_blit.c @@ -1,4 +1,19 @@ -/*This is the CL-GD 5446 blitter, directly from QEMU*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * This is the CL-GD 5446 blitter, directly from QEMU. + * + * Version: @(#)vid_cl_gd_blit.c 1.0.1 2017/10/10 + * + * Author: Miran Grca, + * + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_cl_ramdac.c b/src/video/vid_cl_ramdac.c index 4c1ae1801..d33d0a7eb 100644 --- a/src/video/vid_cl_ramdac.c +++ b/src/video/vid_cl_ramdac.c @@ -1,3 +1,19 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Emulation of the Cirrus Logic RAMDAC. + * + * Version: @(#)vid_cl_ramdac.c 1.0.1 2017/10/10 + * + * Author: Miran Grca, + * + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_colorplus.c b/src/video/vid_colorplus.c index d5faea076..df85e2f9e 100644 --- a/src/video/vid_colorplus.c +++ b/src/video/vid_colorplus.c @@ -1,4 +1,21 @@ -/*Plantronics ColorPlus emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Plantronics ColorPlus emulation. + * + * Version: @(#)vid_colorplus.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_ega.c b/src/video/vid_ega.c index 0ce61656b..b199431f1 100644 --- a/src/video/vid_ega.c +++ b/src/video/vid_ega.c @@ -9,11 +9,12 @@ * Emulation of the EGA, Chips & Technologies SuperEGA, and * AX JEGA graphics cards. * - * Version: @(#)vid_ega.c 1.0.5 2017/10/04 + * Version: @(#)vid_ega.c 1.0.6 2017/10/10 * * Authors: Sarah Walker, * Miran Grca, - * akm, + * akm + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ diff --git a/src/video/vid_ega_render.c b/src/video/vid_ega_render.c index 8ea732ec2..2e6ca4357 100644 --- a/src/video/vid_ega_render.c +++ b/src/video/vid_ega_render.c @@ -8,10 +8,11 @@ * * EGA renderers. * - * Version: @(#)vid_ega_render.c 1.0.2 2017/09/24 + * Version: @(#)vid_ega_render.c 1.0.3 2017/10/10 * * Author: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ diff --git a/src/video/vid_et4000.c b/src/video/vid_et4000.c index 6fc099cb4..3b809da20 100644 --- a/src/video/vid_et4000.c +++ b/src/video/vid_et4000.c @@ -1,7 +1,21 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -/*ET4000 emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Emulation of the Tseng Labs ET4000. + * + * Version: @(#)vid_et4000.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_et4000w32.c b/src/video/vid_et4000w32.c index 21b5fb933..fda5e2ff1 100644 --- a/src/video/vid_et4000w32.c +++ b/src/video/vid_et4000w32.c @@ -1,8 +1,23 @@ -/*ET4000/W32p emulation (Diamond Stealth 32)*/ -/*Known bugs : - - - Accelerator doesn't work in planar modes -*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * ET4000/W32p emulation (Diamond Stealth 32) + * + * Known bugs: Accelerator doesn't work in planar modes + * + * Version: @(#)vid_et4000w32.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include @@ -14,7 +29,7 @@ #include "../pci.h" #include "../rom.h" #include "../device.h" -#include "../win/plat_thread.h" +#include "../plat.h" #include "video.h" #include "vid_svga.h" #include "vid_icd2061.h" diff --git a/src/video/vid_et4000w32i.c b/src/video/vid_et4000w32i.c index ccb13adca..d4208eaa2 100644 --- a/src/video/vid_et4000w32i.c +++ b/src/video/vid_et4000w32i.c @@ -1,12 +1,25 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -/*The below is (with some removals) a reasonable emulation of the ET4000/W32i blitter. - Unfortunately the Diamond Stealth 32 is actually an ET4000/W32p! Which has a different - blitter. If only I'd dug out and looked at the card before trying to emulate it. - - This might be of use for an attempt at emulating an ET4000/W32i. - */ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * The below is (with some removals) a reasonable emulation + * of the ET4000/W32i blitter. Unfortunately the Diamond + * Stealth 32 is actually an ET4000/W32p! Which has a different + * blitter. If only I'd dug out and looked at the card before + * trying to emulate it. + * + * This might be of use for an attempt at an ET4000/W32i. + * + * Version: @(#)vid_et4000w32i.c 1.0.1 2017/10/10 + * + * Author: Sarah Walker, + * + * Copyright 2008-2017 Sarah Walker. + */ #if 0 #include diff --git a/src/video/vid_genius.c b/src/video/vid_genius.c index 523b4a906..de2ac599c 100644 --- a/src/video/vid_genius.c +++ b/src/video/vid_genius.c @@ -1,4 +1,21 @@ -/* MDSI Genius VHR emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * MDSI Genius VHR emulation. + * + * Version: @(#)vid_genius.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include @@ -10,6 +27,7 @@ #include "../rom.h" #include "../timer.h" #include "../device.h" +#include "../plat.h" #include "video.h" #include "vid_genius.h" @@ -18,10 +36,9 @@ #define GENIUS_YSIZE 1008 -void updatewindowsize(int x, int y); - extern uint8_t fontdat8x12[256][16]; + /* I'm at something of a disadvantage writing this emulation: I don't have an * MDSI Genius card, nor do I have the BIOS extension (VHRBIOS.SYS) that came * with it. What I do have are the GEM and Windows 1.04 drivers, plus a driver diff --git a/src/video/vid_hercules.c b/src/video/vid_hercules.c index 23f5c7134..ad1dfafb4 100644 --- a/src/video/vid_hercules.c +++ b/src/video/vid_hercules.c @@ -1,7 +1,21 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -/*Hercules emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Hercules emulation. + * + * Version: @(#)vid_hercules.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include @@ -15,9 +29,6 @@ #include "../device.h" #include "video.h" #include "vid_hercules.h" -#ifndef __unix -# include "../win/win_cgapal.h" /*YUCK*/ -#endif typedef struct hercules_t diff --git a/src/video/vid_herculesplus.c b/src/video/vid_herculesplus.c index fda0e1568..c9ef61bd9 100644 --- a/src/video/vid_herculesplus.c +++ b/src/video/vid_herculesplus.c @@ -1,7 +1,21 @@ -/* Copyright holders: John Elliott - see COPYING for more details -*/ -/*Hercules InColor emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Hercules InColor emulation. + * + * Version: @(#)vid_herculesplus.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_icd2061.c b/src/video/vid_icd2061.c index a2ed97f1b..1292752b0 100644 --- a/src/video/vid_icd2061.c +++ b/src/video/vid_icd2061.c @@ -1,10 +1,23 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -/*PCem v8.1 by Tom Walker - - ICD2061 clock generator emulation - Used by ET4000w32/p (Diamond Stealth 32)*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * ICD2061 clock generator emulation. + * + * Used by ET4000w32/p (Diamond Stealth 32) + * + * Version: @(#)vid_icd2061.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_ics2595.c b/src/video/vid_ics2595.c index 48ddafdb5..eb2aaf4a1 100644 --- a/src/video/vid_ics2595.c +++ b/src/video/vid_ics2595.c @@ -1,8 +1,21 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -/*ICS2595 clock chip emulation - Used by ATI Mach64*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * ICS2595 clock chip emulation. Used by ATI Mach64. + * + * Version: @(#)vid_ics2595.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_incolor.c b/src/video/vid_incolor.c index 7b32e2020..6fdee5417 100644 --- a/src/video/vid_incolor.c +++ b/src/video/vid_incolor.c @@ -1,7 +1,21 @@ -/* Copyright holders: John Elliott - see COPYING for more details -*/ -/*Hercules InColor emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Hercules InColor emulation. + * + * Version: @(#)vid_incolor.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include @@ -18,7 +32,6 @@ /* extended CRTC registers */ - #define INCOLOR_CRTC_XMODE 20 /* xMode register */ #define INCOLOR_CRTC_UNDER 21 /* Underline */ #define INCOLOR_CRTC_OVER 22 /* Overstrike */ diff --git a/src/video/vid_mda.c b/src/video/vid_mda.c index d3eec8553..e456da414 100644 --- a/src/video/vid_mda.c +++ b/src/video/vid_mda.c @@ -1,7 +1,21 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -/*MDA emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * MDA emulation. + * + * Version: @(#)vid_mda.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include @@ -15,9 +29,6 @@ #include "../device.h" #include "video.h" #include "vid_mda.h" -#ifndef __unix -# include "../win/win_cgapal.h" /*YUCK*/ -#endif typedef struct mda_t diff --git a/src/video/vid_nv_riva128.c b/src/video/vid_nv_riva128.c index b79a50807..c935cea45 100644 --- a/src/video/vid_nv_riva128.c +++ b/src/video/vid_nv_riva128.c @@ -1,7 +1,21 @@ -/* Copyright holders: Melissa Goad, Tenshi - see COPYING for more details -*/ -/*nVidia RIVA 128 emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * nVidia RIVA 128 emulation. + * + * Version: @(#)vid_nv_riva128.c 1.0.1 2017/10/10 + * + * Author: Melissa Goad + * Miran Grca, + * + * Copyright 2017 Melissa Goad. + * Copyright 2017 Miran Grca. + */ #include #include #include @@ -15,7 +29,7 @@ #include "../rom.h" #include "../timer.h" #include "../device.h" -#include "../win/plat_thread.h" +#include "../plat.h" #include "video.h" #include "vid_nv_riva128.h" #include "vid_svga.h" diff --git a/src/video/vid_olivetti_m24.c b/src/video/vid_olivetti_m24.c index 81129b3f7..5db33a6d2 100644 --- a/src/video/vid_olivetti_m24.c +++ b/src/video/vid_olivetti_m24.c @@ -1,8 +1,21 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -/*Olivetti M24 video emulation - Essentially double-res CGA*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Olivetti M24 video emulation- essentially double-res CGA. + * + * Version: @(#)vid_olivetti_m24.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_oti067.c b/src/video/vid_oti067.c index a6b45f743..4b0c45135 100644 --- a/src/video/vid_oti067.c +++ b/src/video/vid_oti067.c @@ -1,7 +1,21 @@ -/* Copyright holders: Sarah Walker, Tenshi - see COPYING for more details -*/ -/*Oak OTI067 emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Oak OTI067/077 emulation. + * + * Version: @(#)vid_oti067.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include @@ -17,298 +31,339 @@ #include "vid_svga.h" -typedef struct oti067_t +typedef struct { + svga_t svga; + + rom_t bios_rom; + + int index; + uint8_t regs[32]; + + uint8_t pos; + + uint32_t vram_size; + uint32_t vram_mask; + + uint8_t chip_id; +} oti_t; + + +static void +oti_out(uint16_t addr, uint8_t val, void *p) { - svga_t svga; - - rom_t bios_rom; - - int index; - uint8_t regs[32]; - - uint8_t pos; - - uint32_t vram_size; - uint32_t vram_mask; + oti_t *oti = (oti_t *)p; + svga_t *svga = &oti->svga; + uint8_t old; - uint8_t chip_id; -} oti067_t; + if ((((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && addr < 0x3de) && + !(svga->miscout & 1)) addr ^= 0x60; -void oti067_out(uint16_t addr, uint8_t val, void *p) -{ - oti067_t *oti067 = (oti067_t *)p; - svga_t *svga = &oti067->svga; - uint8_t old; + switch (addr) { + case 0x3D4: + svga->crtcreg = val & 31; + return; - if ((((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && addr < 0x3de) && !(svga->miscout & 1)) addr ^= 0x60; - - switch (addr) - { - case 0x3D4: - svga->crtcreg = val & 31; - return; - case 0x3D5: + case 0x3D5: if (svga->crtcreg <= 0x18) val &= mask_crtc[svga->crtcreg]; - if ((svga->crtcreg < 7) && (svga->crtc[0x11] & 0x80)) - return; - if ((svga->crtcreg == 7) && (svga->crtc[0x11] & 0x80)) - val = (svga->crtc[7] & ~0x10) | (val & 0x10); - old = svga->crtc[svga->crtcreg]; - svga->crtc[svga->crtcreg] = val; - if (old != val) - { - if (svga->crtcreg < 0xE || svga->crtcreg > 0x10) - { - svga->fullchange = changeframecount; - svga_recalctimings(svga); - } - } - break; + if ((svga->crtcreg < 7) && (svga->crtc[0x11] & 0x80)) + return; + if ((svga->crtcreg == 7) && (svga->crtc[0x11] & 0x80)) + val = (svga->crtc[7] & ~0x10) | (val & 0x10); + old = svga->crtc[svga->crtcreg]; + svga->crtc[svga->crtcreg] = val; + if (old != val) { + if (svga->crtcreg < 0xE || svga->crtcreg > 0x10) { + svga->fullchange = changeframecount; + svga_recalctimings(svga); + } + } + break; - case 0x3DE: - oti067->index = val & 0x1f; - return; - case 0x3DF: - oti067->regs[oti067->index] = val; - switch (oti067->index) - { - case 0xD: - svga->vrammask = (val & 0xc) ? oti067->vram_mask : 0x3ffff; - if ((val & 0x80) && oti067->vram_size == 256) - mem_mapping_disable(&svga->mapping); - else - mem_mapping_enable(&svga->mapping); - if (!(val & 0x80)) - svga->vrammask = 0x3ffff; - break; - case 0x11: - svga->read_bank = (val & 0xf) * 65536; - svga->write_bank = (val >> 4) * 65536; - break; - } - return; - } - svga_out(addr, val, svga); + case 0x3DE: + oti->index = val & 0x1f; + return; + + case 0x3DF: + oti->regs[oti->index] = val; + switch (oti->index) { + case 0xD: + svga->vrammask = (val & 0xc) ? oti->vram_mask : 0x3ffff; + if ((val & 0x80) && oti->vram_size == 256) + mem_mapping_disable(&svga->mapping); + else + mem_mapping_enable(&svga->mapping); + if (!(val & 0x80)) + svga->vrammask = 0x3ffff; + break; + + case 0x11: + svga->read_bank = (val & 0xf) * 65536; + svga->write_bank = (val >> 4) * 65536; + break; + } + return; + } + + svga_out(addr, val, svga); } -uint8_t oti067_in(uint16_t addr, void *p) -{ - oti067_t *oti067 = (oti067_t *)p; - svga_t *svga = &oti067->svga; - uint8_t temp; - - if ((((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && addr < 0x3de) && !(svga->miscout & 1)) addr ^= 0x60; - - switch (addr) - { - case 0x3D4: - temp = svga->crtcreg; - break; - case 0x3D5: - temp = svga->crtc[svga->crtcreg]; - break; - - case 0x3DE: - temp = oti067->index | (oti067->chip_id << 5); - break; - case 0x3DF: - if (oti067->index==0x10) temp = 0x18; - else temp = oti067->regs[oti067->index]; - break; - default: - temp = svga_in(addr, svga); - break; - } - return temp; +static uint8_t +oti_in(uint16_t addr, void *p) +{ + oti_t *oti = (oti_t *)p; + svga_t *svga = &oti->svga; + uint8_t temp; + + if ((((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && addr < 0x3de) && + !(svga->miscout & 1)) addr ^= 0x60; + + switch (addr) { + case 0x3D4: + temp = svga->crtcreg; + break; + + case 0x3D5: + temp = svga->crtc[svga->crtcreg]; + break; + + case 0x3DE: + temp = oti->index | (oti->chip_id << 5); + break; + + case 0x3DF: + if (oti->index==0x10) + temp = 0x18; + else + temp = oti->regs[oti->index]; + break; + + default: + temp = svga_in(addr, svga); + break; + } + + return(temp); } -void oti067_pos_out(uint16_t addr, uint8_t val, void *p) -{ - oti067_t *oti067 = (oti067_t *)p; - if ((val & 8) != (oti067->pos & 8)) - { - if (val & 8) - io_sethandler(0x03c0, 0x0020, oti067_in, NULL, NULL, oti067_out, NULL, NULL, oti067); - else - io_removehandler(0x03c0, 0x0020, oti067_in, NULL, NULL, oti067_out, NULL, NULL, oti067); - } - - oti067->pos = val; +static void +oti_pos_out(uint16_t addr, uint8_t val, void *p) +{ + oti_t *oti = (oti_t *)p; + + if ((val & 8) != (oti->pos & 8)) { + if (val & 8) + io_sethandler(0x03c0, 32, oti_in, NULL, NULL, + oti_out, NULL, NULL, oti); + else + io_removehandler(0x03c0, 32, oti_in, NULL, NULL, + oti_out, NULL, NULL, oti); + } + + oti->pos = val; } -uint8_t oti067_pos_in(uint16_t addr, void *p) -{ - oti067_t *oti067 = (oti067_t *)p; - return oti067->pos; -} - -void oti067_recalctimings(svga_t *svga) +static uint8_t +oti_pos_in(uint16_t addr, void *p) { - oti067_t *oti067 = (oti067_t *)svga->p; - - if (oti067->regs[0x14] & 0x08) svga->ma_latch |= 0x10000; - if (oti067->regs[0x0d] & 0x0c) svga->rowoffset <<= 1; - if (oti067->regs[0x14] & 0x80) - { - svga->vtotal *= 2; - svga->dispend *= 2; - svga->vblankstart *= 2; - svga->vsyncstart *=2; - svga->split *= 2; - } + oti_t *oti = (oti_t *)p; + + return(oti->pos); +} + + +static void +oti_recalctimings(svga_t *svga) +{ + oti_t *oti = (oti_t *)svga->p; + + if (oti->regs[0x14] & 0x08) svga->ma_latch |= 0x10000; + + if (oti->regs[0x0d] & 0x0c) svga->rowoffset <<= 1; + + if (oti->regs[0x14] & 0x80) { + svga->vtotal *= 2; + svga->dispend *= 2; + svga->vblankstart *= 2; + svga->vsyncstart *=2; + svga->split *= 2; + } } -void *oti067_common_init(wchar_t *bios_fn, int vram_size, int chip_id) + +static void * +oti_common_init(wchar_t *bios_fn, int vram_size, int chip_id) { - oti067_t *oti067 = malloc(sizeof(oti067_t)); - memset(oti067, 0, sizeof(oti067_t)); - - rom_init(&oti067->bios_rom, bios_fn, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + oti_t *oti = malloc(sizeof(oti_t)); - oti067->vram_size = vram_size; - oti067->vram_mask = (vram_size << 10) - 1; + memset(oti, 0x00, sizeof(oti_t)); - oti067->chip_id = chip_id; - - svga_init(&oti067->svga, oti067, vram_size << 10, - oti067_recalctimings, - oti067_in, oti067_out, - NULL, - NULL); + rom_init(&oti->bios_rom, bios_fn, + 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); - io_sethandler(0x03c0, 0x0020, oti067_in, NULL, NULL, oti067_out, NULL, NULL, oti067); - io_sethandler(0x46e8, 0x0001, oti067_pos_in, NULL, NULL, oti067_pos_out, NULL, NULL, oti067); - - oti067->svga.miscout = 1; - return oti067; + oti->vram_size = vram_size; + oti->vram_mask = (vram_size << 10) - 1; + + oti->chip_id = chip_id; + + svga_init(&oti->svga, oti, vram_size << 10, + oti_recalctimings, oti_in, oti_out, NULL, NULL); + + io_sethandler(0x03c0, 32, + oti_in, NULL, NULL, oti_out, NULL, NULL, oti); + io_sethandler(0x46e8, 1, oti_pos_in,NULL,NULL, oti_pos_out,NULL,NULL, oti); + + oti->svga.miscout = 1; + + return(oti); } -void *oti067_init(device_t *info) + +static void * +oti067_init(device_t *info) { - int vram_size = device_get_config_int("memory"); - return oti067_common_init(L"roms/video/oti/bios.bin", vram_size, 2); + int vram_size = device_get_config_int("memory"); + + return(oti_common_init(L"roms/video/oti/bios.bin", vram_size, 2)); } -void *oti077_init(device_t *info) + +static void * +oti077_init(device_t *info) { - int vram_size = device_get_config_int("memory"); - return oti067_common_init(L"roms/video/oti/oti077.vbi", vram_size, 5); + int vram_size = device_get_config_int("memory"); + + return(oti_common_init(L"roms/video/oti/oti077.vbi", vram_size, 5)); } -static int oti067_available(void) + +static int +oti067_available(void) { - return rom_present(L"roms/video/oti/bios.bin"); + return(rom_present(L"roms/video/oti/bios.bin")); } -static int oti077_available(void) + +static int +oti077_available(void) { - return rom_present(L"roms/video/oti/oti077.vbi"); + return(rom_present(L"roms/video/oti/oti077.vbi")); } -static void oti067_close(void *p) -{ - oti067_t *oti067 = (oti067_t *)p; - svga_close(&oti067->svga); - - free(oti067); +static void +oti_close(void *p) +{ + oti_t *oti = (oti_t *)p; + + svga_close(&oti->svga); + + free(oti); } -static void oti067_speed_changed(void *p) -{ - oti067_t *oti067 = (oti067_t *)p; - - svga_recalctimings(&oti067->svga); -} - -static void oti067_force_redraw(void *p) -{ - oti067_t *oti067 = (oti067_t *)p; - oti067->svga.fullchange = changeframecount; +static void +oti_speed_changed(void *p) +{ + oti_t *oti = (oti_t *)p; + + svga_recalctimings(&oti->svga); +} + + +static void +oti_force_redraw(void *p) +{ + oti_t *oti = (oti_t *)p; + + oti->svga.fullchange = changeframecount; } -static void oti067_add_status_info(char *s, int max_len, void *p) + +static void +oti_add_status_info(char *s, int max_len, void *p) { - oti067_t *oti067 = (oti067_t *)p; - - svga_add_status_info(s, max_len, &oti067->svga); + oti_t *oti = (oti_t *)p; + + svga_add_status_info(s, max_len, &oti->svga); } + static device_config_t oti067_config[] = { - { - "memory", "Memory size", CONFIG_SELECTION, "", 512, - { - { - "256 kB", 256 - }, - { - "512 kB", 512 - }, - { - "" - } - } - }, - { - "", "", -1 - } + { + "memory", "Memory size", CONFIG_SELECTION, "", 512, + { + { + "256 kB", 256 + }, + { + "512 kB", 512 + }, + { + "" + } + } + }, + { + "", "", -1 + } }; static device_config_t oti077_config[] = { - { - "memory", "Memory size", CONFIG_SELECTION, "", 1024, - { - { - "256 kB", 256 - }, - { - "512 kB", 512 - }, - { - "1 MB", 1024 - }, - { - "" - } - } - }, - { - "", "", -1 - } + { + "memory", "Memory size", CONFIG_SELECTION, "", 1024, + { + { + "256 kB", 256 + }, + { + "512 kB", 512 + }, + { + "1 MB", 1024 + }, + { + "" + } + } + }, + { + "", "", -1 + } }; + device_t oti067_device = { - "Oak OTI-067", - DEVICE_ISA, + "Oak OTI-067", + DEVICE_ISA, 0, - oti067_init, - oti067_close, + oti067_init, + oti_close, NULL, - oti067_available, - oti067_speed_changed, - oti067_force_redraw, - oti067_add_status_info, - oti067_config + oti067_available, + oti_speed_changed, + oti_force_redraw, + oti_add_status_info, + oti067_config }; + device_t oti077_device = { - "Oak OTI-077", - DEVICE_ISA, + "Oak OTI-077", + DEVICE_ISA, 0, - oti077_init, - oti067_close, + oti077_init, + oti_close, NULL, - oti077_available, - oti067_speed_changed, - oti067_force_redraw, - oti067_add_status_info, - oti077_config + oti077_available, + oti_speed_changed, + oti_force_redraw, + oti_add_status_info, + oti077_config }; diff --git a/src/video/vid_paradise.c b/src/video/vid_paradise.c index 649d31735..744341afc 100644 --- a/src/video/vid_paradise.c +++ b/src/video/vid_paradise.c @@ -1,11 +1,23 @@ -/* Copyright holders: Sarah Walker, Tenshi - see COPYING for more details -*/ -/*Paradise VGA emulation - - PC2086, PC3086 use PVGA1A - MegaPC uses W90C11A - */ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Paradise VGA emulation + * PC2086, PC3086 use PVGA1A + * MegaPC uses W90C11A + * + * Version: @(#)vid_paradise.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_pc1512.c b/src/video/vid_pc1512.c index 20069c7ba..5bfce6251 100644 --- a/src/video/vid_pc1512.c +++ b/src/video/vid_pc1512.c @@ -1,14 +1,28 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -/*PC1512 CGA emulation - - The PC1512 extends CGA with a bit-planar 640x200x16 mode. - - Most CRTC registers are fixed. - - The Technical Reference Manual lists the video waitstate time as between 12 - and 46 cycles. PCem currently always uses the lower number.*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * PC1512 CGA emulation + * + * The PC1512 extends CGA with a bit-planar 640x200x16 mode. + * Most CRTC registers are fixed. + * + * The Technical Reference Manual lists the video waitstate + * time as between 12 and 46 cycles. We currently always use + * the lower number. + * + * Version: @(#)vid_pc1512.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_pc1640.c b/src/video/vid_pc1640.c index 2b7290384..77e4d0940 100644 --- a/src/video/vid_pc1640.c +++ b/src/video/vid_pc1640.c @@ -1,8 +1,22 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -/*PC1640 video emulation. - Mostly standard EGA, but with CGA & Hercules emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * PC1640 video emulation. + * Mostly standard EGA, but with CGA & Hercules emulation. + * + * Version: @(#)vid_pc1640.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_pc200.c b/src/video/vid_pc200.c index e3d1da2ed..32811e8ea 100644 --- a/src/video/vid_pc200.c +++ b/src/video/vid_pc200.c @@ -1,9 +1,23 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -/*PC200 video emulation. - CGA with some NMI stuff. But we don't need that as it's only used for TV and - LCD displays, and we're emulating a CRT*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * PC200 video emulation. + * CGA with some NMI stuff. But we don't need that as it's only + * used for TV and LCD displays, and we're emulating a CRT. + * + * Version: @(#)vid_pc200.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_pcjr.c b/src/video/vid_pcjr.c index 44faa9542..7610a5db7 100644 --- a/src/video/vid_pcjr.c +++ b/src/video/vid_pcjr.c @@ -1,3 +1,21 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Video emulation for IBM PCjr. + * + * Version: @(#)vid_pcjr.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_ps1_svga.c b/src/video/vid_ps1_svga.c index 5b90805fb..93aff8732 100644 --- a/src/video/vid_ps1_svga.c +++ b/src/video/vid_ps1_svga.c @@ -1,12 +1,29 @@ -/*Emulation of the SVGA chip in the IBM PS/1 Model 2121, or at least the - 20 MHz version. - - I am not entirely sure what this chip actually is, possibly a CF62011? I can - not find any documentation on the chip so have implemented enough to pass - self-test in the PS/1 BIOS. It has 512kb video memory but I have not found any - native drivers for any operating system and there is no VBE implementation, so - it's just a VGA for now. -*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Emulation of the SVGA chip in the IBM PS/1 Model 2121, or + * at least the 20 MHz version. + * + * I am not entirely sure what this chip actually is, possibly + * a CF62011? I can not find any documentation on the chip so + * have implemented enough to pass self-test in the PS/1 BIOS. + * It has 512kb video memory but I have not found any native + * drivers for any operating system and there is no VBE + * implementation, so it's just a VGA for now. + * + * Version: @(#)vid_ps1_svga.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_s3.c b/src/video/vid_s3.c index b7921e8e4..11c0221a1 100644 --- a/src/video/vid_s3.c +++ b/src/video/vid_s3.c @@ -1,4 +1,21 @@ -/*S3 emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * S3 emulation. + * + * Version: @(#)vid_s3.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include @@ -10,7 +27,7 @@ #include "../mem.h" #include "../pci.h" #include "../rom.h" -#include "../win/plat_thread.h" +#include "../plat.h" #include "video.h" #include "vid_s3.h" #include "vid_svga.h" diff --git a/src/video/vid_s3_virge.c b/src/video/vid_s3_virge.c index 5176fe1b3..b8937a349 100644 --- a/src/video/vid_s3_virge.c +++ b/src/video/vid_s3_virge.c @@ -1,7 +1,21 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -/*S3 ViRGE emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * S3 ViRGE emulation. + * + * Version: @(#)vid_s3_virge.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include @@ -13,7 +27,7 @@ #include "../pci.h" #include "../rom.h" #include "../device.h" -#include "../win/plat_thread.h" +#include "../plat.h" #include "video.h" #include "vid_s3_virge.h" #include "vid_svga.h" diff --git a/src/video/vid_sc1502x_ramdac.c b/src/video/vid_sc1502x_ramdac.c index ca080321e..3ef8830ac 100644 --- a/src/video/vid_sc1502x_ramdac.c +++ b/src/video/vid_sc1502x_ramdac.c @@ -1,10 +1,23 @@ -/* Copyright holders: Sarah Walker, Tenshi - see COPYING for more details -*/ -/*It is unknown exactly what RAMDAC this is - It is possibly a Sierra 1502x - It's addressed by the TLIVESA1 driver for ET4000*/ -/* Note by Tenshi: Not possibly, this *IS* a Sierra 1502x. */ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Emulation of a Sierra SC1502X RAMDAC. + * + * Used by the TLIVESA1 driver for ET4000. + * + * Version: @(#)vid_sc1502x_ramdac.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_sdac_ramdac.c b/src/video/vid_sdac_ramdac.c index 28ce0c931..2dbcdabbf 100644 --- a/src/video/vid_sdac_ramdac.c +++ b/src/video/vid_sdac_ramdac.c @@ -1,8 +1,23 @@ -/* Copyright holders: Sarah Walker, Tenshi - see COPYING for more details -*/ -/*87C716 'SDAC' true colour RAMDAC emulation*/ -/*Misidentifies as AT&T 21C504*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * 87C716 'SDAC' true colour RAMDAC emulation. + * + * Misidentifies as AT&T 21C504. + * + * Version: @(#)vid_sdac_ramdac.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_stg_ramdac.c b/src/video/vid_stg_ramdac.c index 4fb1517a1..a2200163a 100644 --- a/src/video/vid_stg_ramdac.c +++ b/src/video/vid_stg_ramdac.c @@ -1,7 +1,21 @@ -/* Copyright holders: Sarah Walker, Tenshi - see COPYING for more details -*/ -/*STG1702 true colour RAMDAC emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * STG1702 true colour RAMDAC emulation. + * + * Version: @(#)vid_stg_ramdac.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 1898fe8c6..27e61cbc4 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -11,10 +11,11 @@ * This is intended to be used by another SVGA driver, * and not as a card in it's own right. * - * Version: @(#)vid_svga.c 1.0.4 2017/10/02 + * Version: @(#)vid_svga.c 1.0.5 2017/10/10 * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ diff --git a/src/video/vid_svga_render.c b/src/video/vid_svga_render.c index 3f40c7374..145e26a26 100644 --- a/src/video/vid_svga_render.c +++ b/src/video/vid_svga_render.c @@ -8,10 +8,11 @@ * * SVGA renderers. * - * Version: @(#)vid_svga_render.c 1.0.1 2017/09/24 + * Version: @(#)vid_svga_render.c 1.0.2 2017/10/10 * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ @@ -30,6 +31,7 @@ int invert_display = 0; int video_grayscale = 0; int video_graytype = 0; + uint32_t shade[5][256] = { {0}, // RGB Color (unused) diff --git a/src/video/vid_table.c b/src/video/vid_table.c new file mode 100644 index 000000000..470a82abd --- /dev/null +++ b/src/video/vid_table.c @@ -0,0 +1,298 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Define all known video cards. + * + * Version: @(#)vid_table.c 1.0.1 2017/10/10 + * + * Authors: Miran Grca, + * Fred N. van Kempen, + * + * Copyright 2016,2017 Miran Grca. + * Copyright 2017 Fred N. van Kempen. + */ +#include +#include +#include +#include +#include +#include "../ibm.h" +#include "../mem.h" +#include "../rom.h" +#include "../device.h" +#include "../timer.h" +#include "../plat.h" +#include "video.h" +#include "vid_svga.h" + +#include "vid_ati18800.h" +#include "vid_ati28800.h" +#include "vid_ati_mach64.h" +#include "vid_cga.h" +#ifdef DEV_BRANCH +# ifdef USE_CIRRUS +# include "vid_cl_ramdac.h" /* vid_cl_gd.c needs this */ +# include "vid_cl_gd.h" +# endif +#endif +#include "vid_ega.h" +#include "vid_et4000.h" +#include "vid_et4000w32.h" +#include "vid_genius.h" +#include "vid_hercules.h" +#include "vid_herculesplus.h" +#include "vid_incolor.h" +#include "vid_colorplus.h" +#include "vid_mda.h" +#ifdef DEV_BRANCH +# ifdef USE_RIVA +# include "vid_nv_riva128.h" +# endif +#endif +#include "vid_olivetti_m24.h" +#include "vid_oti067.h" +#include "vid_paradise.h" +#include "vid_pc1512.h" +#include "vid_pc1640.h" +#include "vid_pc200.h" +#include "vid_pcjr.h" +#include "vid_ps1_svga.h" +#include "vid_s3.h" +#include "vid_s3_virge.h" +#include "vid_tandy.h" +#include "vid_tandysl.h" +#include "vid_tgui9440.h" +#include "vid_tvga.h" +#include "vid_vga.h" +#include "vid_wy700.h" + + +typedef struct { + char name[64]; + char internal_name[24]; + device_t *device; + int legacy_id; +} VIDEO_CARD; + + +static VIDEO_CARD +video_cards[] = { + {"[ISA] ATI VGA Charger (ATI-28800-5)", "ati28800", &ati28800_device, GFX_VGACHARGER }, + {"[ISA] ATI VGA Wonder XL24 (ATI-28800-6)", "ati28800w", &ati28800_wonderxl24_device, GFX_VGAWONDERXL24 }, + {"[ISA] ATI VGA Edge-16 (ATI-18800)", "ati18800", &ati18800_device, GFX_VGAEDGE16 }, + {"[ISA] CGA", "cga", &cga_device, GFX_CGA }, + {"[ISA] Chips & Technologies SuperEGA", "superega", &sega_device, GFX_SUPER_EGA }, + {"[ISA] Compaq ATI VGA Wonder XL (ATI-28800-5)","compaq_ati28800", &compaq_ati28800_device, GFX_VGAWONDERXL }, + {"[ISA] Compaq EGA", "compaq_ega", &cpqega_device, GFX_COMPAQ_EGA }, + {"[ISA] EGA", "ega", &ega_device, GFX_EGA }, + {"[ISA] Hercules", "hercules", &hercules_device, GFX_HERCULES }, + {"[ISA] Hercules Plus", "hercules_plus", &herculesplus_device, GFX_HERCULESPLUS }, + {"[ISA] Hercules InColor", "incolor", &incolor_device, GFX_INCOLOR }, + {"[ISA] MDA", "mda", &mda_device, GFX_MDA }, + {"[ISA] MDSI Genius", "genius", &genius_device, GFX_GENIUS }, + {"[ISA] OAK OTI-067", "oti067", &oti067_device, GFX_OTI067 }, + {"[ISA] OAK OTI-077", "oti077", &oti077_device, GFX_OTI077 }, + {"[ISA] Paradise WD90C11", "wd90c11", ¶dise_wd90c11_device, GFX_WD90C11 }, + {"[ISA] Plantronics ColorPlus", "plantronics", &colorplus_device, GFX_COLORPLUS }, + {"[ISA] Trident TVGA8900D", "tvga8900d", &tvga8900d_device, GFX_TVGA }, + {"[ISA] Tseng ET4000AX", "et4000ax", &et4000_device, GFX_ET4000 }, + {"[ISA] VGA", "vga", &vga_device, GFX_VGA }, + {"[ISA] Wyse 700", "wy700", &wy700_device, GFX_WY700 }, + {"[VLB] ATI Graphics Pro Turbo (Mach64 GX)", "mach64x_vlb", &mach64gx_vlb_device, GFX_MACH64GX_VLB }, + {"[VLB] Diamond Stealth 32 (Tseng ET4000/w32p)","stealth32_vlb", &et4000w32p_vlb_device, GFX_ET4000W32_VLB }, + {"[VLB] Diamond Stealth 3D 2000 (S3 ViRGE)", "stealth3d_2000_vlb", &s3_virge_vlb_device, GFX_VIRGE_VLB }, + {"[VLB] Diamond Stealth 3D 3000 (S3 ViRGE/VX)", "stealth3d_3000_vlb", &s3_virge_988_vlb_device, GFX_VIRGEVX_VLB }, + {"[VLB] Diamond Stealth 64 DRAM (S3 Trio64)", "stealth64d_vlb", &s3_diamond_stealth64_vlb_device, GFX_STEALTH64_VLB }, + {"[VLB] Number Nine 9FX (S3 Trio64)", "n9_9fx_vlb", &s3_9fx_vlb_device, GFX_N9_9FX_VLB }, + {"[VLB] Paradise Bahamas 64 (S3 Vision864)", "bahamas64_vlb", &s3_bahamas64_vlb_device, GFX_BAHAMAS64_VLB }, + {"[VLB] Phoenix S3 Vision864", "px_vision864_vlb", &s3_phoenix_vision864_vlb_device, GFX_PHOENIX_VISION864_VLB }, + {"[VLB] Phoenix S3 Trio32", "px_trio32_vlb", &s3_phoenix_trio32_vlb_device, GFX_PHOENIX_TRIO32_VLB }, + {"[VLB] Phoenix S3 Trio64", "px_trio64_vlb", &s3_phoenix_trio64_vlb_device, GFX_PHOENIX_TRIO64_VLB }, + {"[VLB] S3 ViRGE/DX", "virge375_vlb", &s3_virge_375_vlb_device, GFX_VIRGEDX_VLB }, + {"[VLB] S3 ViRGE/DX (VBE 2.0)", "virge375_vbe20_vlb", &s3_virge_375_4_vlb_device, GFX_VIRGEDX4_VLB }, + {"[VLB] Trident TGUI9440", "tgui9440_vlb", &tgui9440_vlb_device, GFX_TGUI9440_VLB }, + {"[PCI] ATI Graphics Pro Turbo (Mach64 GX)", "mach64x_pci", &mach64gx_pci_device, GFX_MACH64GX_PCI }, + {"[PCI] ATI Video Xpression (Mach64 VT2)", "mach64vt2", &mach64vt2_device, GFX_MACH64VT2 }, + {"[PCI] Diamond Stealth 32 (Tseng ET4000/w32p)","stealth32_pci", &et4000w32p_pci_device, GFX_ET4000W32_PCI }, + {"[PCI] Diamond Stealth 3D 2000 (S3 ViRGE)", "stealth3d_2000_pci", &s3_virge_pci_device, GFX_VIRGE_PCI }, + {"[PCI] Diamond Stealth 3D 3000 (S3 ViRGE/VX)", "stealth3d_3000_pci", &s3_virge_988_pci_device, GFX_VIRGEVX_PCI }, + {"[PCI] Diamond Stealth 64 DRAM (S3 Trio64)", "stealth64d_pci", &s3_diamond_stealth64_pci_device, GFX_STEALTH64_PCI }, +#if defined(DEV_BRANCH) && defined(USE_RIVA) + {"[PCI] nVidia RIVA 128", "riva128", &riva128_device, GFX_RIVA128 }, + {"[PCI] nVidia RIVA TNT", "rivatnt", &rivatnt_device, GFX_RIVATNT }, + {"[PCI] nVidia RIVA TNT2", "rivatnt2", &rivatnt2_device, GFX_RIVATNT2 }, +#endif + {"[PCI] Number Nine 9FX (S3 Trio64)", "n9_9fx_pci", &s3_9fx_pci_device, GFX_N9_9FX_PCI }, + {"[PCI] Paradise Bahamas 64 (S3 Vision864)", "bahamas64_pci", &s3_bahamas64_pci_device, GFX_BAHAMAS64_PCI }, + {"[PCI] Phoenix S3 Vision864", "px_vision864_pci", &s3_phoenix_vision864_pci_device, GFX_PHOENIX_VISION864_PCI }, + {"[PCI] Phoenix S3 Trio32", "px_trio32_pci", &s3_phoenix_trio32_pci_device, GFX_PHOENIX_TRIO32_PCI }, + {"[PCI] Phoenix S3 Trio64", "px_trio64_pci", &s3_phoenix_trio64_pci_device, GFX_PHOENIX_TRIO64_PCI }, + {"[PCI] S3 ViRGE/DX", "virge375_pci", &s3_virge_375_pci_device, GFX_VIRGEDX_PCI }, + {"[PCI] S3 ViRGE/DX (VBE 2.0)", "virge375_vbe20_pci", &s3_virge_375_4_pci_device, GFX_VIRGEDX4_PCI }, + {"[PCI] Trident TGUI9440", "tgui9440_pci", &tgui9440_pci_device, GFX_TGUI9440_PCI }, + {"", "", NULL, 0 } +}; + + +/* This will be merged into machine.c soon. --FvK */ +void +video_reset_device(int rs, int gc) +{ + pclog("Video_reset_device(rom=%i, gfx=%i)\n", rs, gc); + + switch (rs) { + case ROM_IBMPCJR: + device_add(&pcjr_video_device); + return; + + case ROM_TANDY: + case ROM_TANDY1000HX: + device_add(&tandy_device); + return; + + case ROM_TANDY1000SL2: + device_add(&tandysl_device); + return; + + case ROM_PC1512: + device_add(&pc1512_device); + return; + + case ROM_PC1640: + device_add(&pc1640_device); + return; + + case ROM_PC200: + device_add(&pc200_device); + return; + + case ROM_OLIM24: + device_add(&m24_device); + return; + + case ROM_PC2086: + device_add(¶dise_pvga1a_pc2086_device); + return; + + case ROM_PC3086: + device_add(¶dise_pvga1a_pc3086_device); + return; + + case ROM_MEGAPC: + device_add(¶dise_wd90c11_megapc_device); + return; + + case ROM_ACER386: + device_add(&oti067_device); + return; + + case ROM_IBMPS1_2011: + case ROM_IBMPS2_M30_286: + case ROM_IBMPS2_M50: + case ROM_IBMPS2_M55SX: + case ROM_IBMPS2_M80: + device_add(&ps1vga_device); + return; + + case ROM_IBMPS1_2121: + device_add(&ps1_m2121_svga_device); + return; + } + + device_add(video_cards[video_old_to_new(gc)].device); +} + + +int +video_card_available(int card) +{ + if (video_cards[card].device) + return(device_available(video_cards[card].device)); + + return(1); +} + + +char * +video_card_getname(int card) +{ + return(video_cards[card].name); +} + + +device_t * +video_card_getdevice(int card) +{ + return(video_cards[card].device); +} + + +int +video_card_has_config(int card) +{ + return(video_cards[card].device->config ? 1 : 0); +} + + +int +video_card_getid(char *s) +{ + int c = 0; + + while (video_cards[c].device) { + if (!strcmp(video_cards[c].name, s)) + return(c); + c++; + } + + return(0); +} + + +int +video_old_to_new(int card) +{ + int c = 0; + + while (video_cards[c].device) { + if (video_cards[c].legacy_id == card) + return(c); + c++; + } + + return(0); +} + + +int +video_new_to_old(int card) +{ + return(video_cards[card].legacy_id); +} + + +char * +video_get_internal_name(int card) +{ + return(video_cards[card].internal_name); +} + + +int +video_get_video_from_internal_name(char *s) +{ + int c = 0; + + while (video_cards[c].legacy_id != -1) { + if (!strcmp(video_cards[c].internal_name, s)) + return(video_cards[c].legacy_id); + c++; + } + + return(0); +} diff --git a/src/video/vid_tandy.c b/src/video/vid_tandy.c index cddd6dc92..a83e32377 100644 --- a/src/video/vid_tandy.c +++ b/src/video/vid_tandy.c @@ -1,3 +1,21 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Emulation of the Tandy Model 1000 video. + * + * Version: @(#)vid_tandy.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_tandysl.c b/src/video/vid_tandysl.c index cfe9f7b79..84d21a3f7 100644 --- a/src/video/vid_tandysl.c +++ b/src/video/vid_tandysl.c @@ -1,6 +1,21 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Emulation of the Tandy Model 1000/SL video. + * + * Version: @(#)vid_tandysl.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_tgui9440.c b/src/video/vid_tgui9440.c index 61edd08c3..a51922a28 100644 --- a/src/video/vid_tgui9440.c +++ b/src/video/vid_tgui9440.c @@ -1,7 +1,21 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -/*Trident TGUI9440 emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Trident TGUI9440 emulation. + * + * Version: @(#)vid_tgui9440.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include @@ -13,7 +27,7 @@ #include "../pci.h" #include "../rom.h" #include "../device.h" -#include "../win/plat_thread.h" +#include "../plat.h" #include "video.h" #include "vid_svga.h" #include "vid_svga_render.h" diff --git a/src/video/vid_tkd8001_ramdac.c b/src/video/vid_tkd8001_ramdac.c index 38d3cdde5..123c9e118 100644 --- a/src/video/vid_tkd8001_ramdac.c +++ b/src/video/vid_tkd8001_ramdac.c @@ -1,7 +1,21 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -/*Trident TKD8001 RAMDAC emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Trident TKD8001 RAMDAC emulation. + * + * Version: @(#)vid_tkd8001_ramdac.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_tvga.c b/src/video/vid_tvga.c index 6ae361969..1112fd3fb 100644 --- a/src/video/vid_tvga.c +++ b/src/video/vid_tvga.c @@ -1,7 +1,21 @@ -/* Copyright holders: Sarah Walker, SA1988 - see COPYING for more details -*/ -/*Trident TVGA (8900D) emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Trident TVGA (8900D) emulation. + * + * Version: @(#)vid_tvga.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_vga.c b/src/video/vid_vga.c index 76f7e6358..f11a4a81a 100644 --- a/src/video/vid_vga.c +++ b/src/video/vid_vga.c @@ -1,7 +1,21 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -/*IBM VGA emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * IBM VGA emulation. + * + * Version: @(#)vid_vga.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/vid_voodoo.c b/src/video/vid_voodoo.c index 62263036d..bb85028a5 100644 --- a/src/video/vid_voodoo.c +++ b/src/video/vid_voodoo.c @@ -1,3 +1,20 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Emulation of the 3DFX Voodoo Graphics controller. + * + * Version: @(#)vid_voodoo.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * leilei + * + * Copyright 2008-2017 Sarah Walker. + */ #include #include #include @@ -11,12 +28,13 @@ #include "../pci.h" #include "../timer.h" #include "../device.h" -#include "../win/plat_thread.h" +#include "../plat.h" #include "video.h" #include "vid_svga.h" #include "vid_voodoo.h" #include "vid_voodoo_dither.h" + #ifdef MIN #undef MIN #endif @@ -38,6 +56,7 @@ #define TEX_CACHE_MAX 64 + enum { VOODOO_1 = 0, @@ -45,6 +64,7 @@ enum VOODOO_2 = 2 }; + static uint32_t texture_offset[LOD_MAX+3] = { 0, diff --git a/src/video/vid_wy700.c b/src/video/vid_wy700.c index dcd432fd6..1cf02cb6c 100644 --- a/src/video/vid_wy700.c +++ b/src/video/vid_wy700.c @@ -1,4 +1,21 @@ -/* Wyse-700 emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Wyse-700 emulation. + * + * Version: @(#)vid_wy700.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include diff --git a/src/video/video.c b/src/video/video.c index b846311cd..faf0e2378 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -1,13 +1,59 @@ -/* Copyright holders: Sarah Walker, Tenshi - see COPYING for more details -*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Main video-rendering module. + * + * Video timing settings - + * + * 8-bit - 1mb/sec + * B = 8 ISA clocks + * W = 16 ISA clocks + * L = 32 ISA clocks + * + * Slow 16-bit - 2mb/sec + * B = 6 ISA clocks + * W = 8 ISA clocks + * L = 16 ISA clocks + * + * Fast 16-bit - 4mb/sec + * B = 3 ISA clocks + * W = 3 ISA clocks + * L = 6 ISA clocks + * + * Slow VLB/PCI - 8mb/sec (ish) + * B = 4 bus clocks + * W = 8 bus clocks + * L = 16 bus clocks + * + * Mid VLB/PCI - + * B = 4 bus clocks + * W = 5 bus clocks + * L = 10 bus clocks + * + * Fast VLB/PCI - + * B = 3 bus clocks + * W = 3 bus clocks + * L = 4 bus clocks + * + * Version: @(#)video.c 1.0.1 2017/10/10 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include #include #include #include -#include #include "../86box.h" #include "../ibm.h" #include "../cpu/cpu.h" @@ -15,736 +61,573 @@ #include "../mem.h" #include "../rom.h" #include "../config.h" -#include "../device.h" #include "../timer.h" -#include "../win/plat_thread.h" #include "../plat.h" #include "video.h" #include "vid_svga.h" -#ifndef __unix -# include "../win/win_cgapal.h" /*YUCK*/ -#endif -#include "vid_ati18800.h" -#include "vid_ati28800.h" -#include "vid_ati_mach64.h" -#include "vid_cga.h" -#ifdef DEV_BRANCH -# ifdef USE_CIRRUS -# include "vid_cl_ramdac.h" /* vid_cl_gd.c needs this */ -# include "vid_cl_gd.h" -# endif -#endif -#include "vid_ega.h" -#include "vid_et4000.h" -#include "vid_et4000w32.h" -#include "vid_genius.h" -#include "vid_hercules.h" -#include "vid_herculesplus.h" -#include "vid_incolor.h" -#include "vid_colorplus.h" -#include "vid_mda.h" -#ifdef DEV_BRANCH -# ifdef USE_RIVA -# include "vid_nv_riva128.h" -# endif -#endif -#include "vid_olivetti_m24.h" -#include "vid_oti067.h" -#include "vid_paradise.h" -#include "vid_pc1512.h" -#include "vid_pc1640.h" -#include "vid_pc200.h" -#include "vid_pcjr.h" -#include "vid_ps1_svga.h" -#include "vid_s3.h" -#include "vid_s3_virge.h" -#include "vid_tandy.h" -#include "vid_tandysl.h" -#include "vid_tgui9440.h" -#include "vid_tvga.h" -#include "vid_vga.h" -#include "vid_wy700.h" - - -int vid_cga_contrast = 0; -int cga_palette = 0; - -typedef struct -{ - char name[64]; - char internal_name[24]; - device_t *device; - int legacy_id; -} VIDEO_CARD; - -static VIDEO_CARD video_cards[] = -{ - {"[ISA] ATI VGA Charger (ATI-28800-5)", "ati28800", &ati28800_device, GFX_VGACHARGER}, - {"[ISA] ATI VGA Wonder XL24 (ATI-28800-6)", "ati28800w", &ati28800_wonderxl24_device, GFX_VGAWONDERXL24}, - {"[ISA] ATI VGA Edge-16 (ATI-18800)", "ati18800", &ati18800_device, GFX_VGAEDGE16}, - {"[ISA] CGA", "cga", &cga_device, GFX_CGA}, - {"[ISA] Chips & Technologies SuperEGA", "superega", &sega_device, GFX_SUPER_EGA}, - {"[ISA] Compaq ATI VGA Wonder XL (ATI-28800-5)","compaq_ati28800", &compaq_ati28800_device, GFX_VGAWONDERXL}, - {"[ISA] Compaq EGA", "compaq_ega", &cpqega_device, GFX_COMPAQ_EGA}, - {"[ISA] EGA", "ega", &ega_device, GFX_EGA}, - {"[ISA] Hercules", "hercules", &hercules_device, GFX_HERCULES}, - {"[ISA] Hercules Plus", "hercules_plus", &herculesplus_device, GFX_HERCULESPLUS}, - {"[ISA] Hercules InColor", "incolor", &incolor_device, GFX_INCOLOR}, - {"[ISA] MDA", "mda", &mda_device, GFX_MDA}, - {"[ISA] MDSI Genius", "genius", &genius_device, GFX_GENIUS}, - {"[ISA] OAK OTI-067", "oti067", &oti067_device, GFX_OTI067}, - {"[ISA] OAK OTI-077", "oti077", &oti077_device, GFX_OTI077}, - {"[ISA] Paradise WD90C11", "wd90c11", ¶dise_wd90c11_device, GFX_WD90C11}, - {"[ISA] Plantronics ColorPlus", "plantronics", &colorplus_device, GFX_COLORPLUS}, - {"[ISA] Trident TVGA8900D", "tvga8900d", &tvga8900d_device, GFX_TVGA}, - {"[ISA] Tseng ET4000AX", "et4000ax", &et4000_device, GFX_ET4000}, - {"[ISA] VGA", "vga", &vga_device, GFX_VGA}, - {"[ISA] Wyse 700", "wy700", &wy700_device, GFX_WY700}, - {"[VLB] ATI Graphics Pro Turbo (Mach64 GX)", "mach64x_vlb", &mach64gx_vlb_device, GFX_MACH64GX_VLB}, - {"[VLB] Diamond Stealth 32 (Tseng ET4000/w32p)","stealth32_vlb", &et4000w32p_vlb_device, GFX_ET4000W32_VLB}, - {"[VLB] Diamond Stealth 3D 2000 (S3 ViRGE)", "stealth3d_2000_vlb", &s3_virge_vlb_device, GFX_VIRGE_VLB}, - {"[VLB] Diamond Stealth 3D 3000 (S3 ViRGE/VX)", "stealth3d_3000_vlb", &s3_virge_988_vlb_device, GFX_VIRGEVX_VLB}, - {"[VLB] Diamond Stealth 64 DRAM (S3 Trio64)", "stealth64d_vlb", &s3_diamond_stealth64_vlb_device, GFX_STEALTH64_VLB}, - {"[VLB] Number Nine 9FX (S3 Trio64)", "n9_9fx_vlb", &s3_9fx_vlb_device, GFX_N9_9FX_VLB}, - {"[VLB] Paradise Bahamas 64 (S3 Vision864)", "bahamas64_vlb", &s3_bahamas64_vlb_device, GFX_BAHAMAS64_VLB}, - {"[VLB] Phoenix S3 Vision864", "px_vision864_vlb", &s3_phoenix_vision864_vlb_device, GFX_PHOENIX_VISION864_VLB}, - {"[VLB] Phoenix S3 Trio32", "px_trio32_vlb", &s3_phoenix_trio32_vlb_device, GFX_PHOENIX_TRIO32_VLB}, - {"[VLB] Phoenix S3 Trio64", "px_trio64_vlb", &s3_phoenix_trio64_vlb_device, GFX_PHOENIX_TRIO64_VLB}, - {"[VLB] S3 ViRGE/DX", "virge375_vlb", &s3_virge_375_vlb_device, GFX_VIRGEDX_VLB}, - {"[VLB] S3 ViRGE/DX (VBE 2.0)", "virge375_vbe20_vlb", &s3_virge_375_4_vlb_device, GFX_VIRGEDX4_VLB}, - {"[VLB] Trident TGUI9440", "tgui9440_vlb", &tgui9440_vlb_device, GFX_TGUI9440_VLB}, - {"[PCI] ATI Graphics Pro Turbo (Mach64 GX)", "mach64x_pci", &mach64gx_pci_device, GFX_MACH64GX_PCI}, - {"[PCI] ATI Video Xpression (Mach64 VT2)", "mach64vt2", &mach64vt2_device, GFX_MACH64VT2}, - {"[PCI] Diamond Stealth 32 (Tseng ET4000/w32p)","stealth32_pci", &et4000w32p_pci_device, GFX_ET4000W32_PCI}, - {"[PCI] Diamond Stealth 3D 2000 (S3 ViRGE)", "stealth3d_2000_pci", &s3_virge_pci_device, GFX_VIRGE_PCI}, - {"[PCI] Diamond Stealth 3D 3000 (S3 ViRGE/VX)", "stealth3d_3000_pci", &s3_virge_988_pci_device, GFX_VIRGEVX_PCI}, - {"[PCI] Diamond Stealth 64 DRAM (S3 Trio64)", "stealth64d_pci", &s3_diamond_stealth64_pci_device, GFX_STEALTH64_PCI}, -#if defined(DEV_BRANCH) && defined(USE_RIVA) - {"[PCI] nVidia RIVA 128", "riva128", &riva128_device, GFX_RIVA128}, - {"[PCI] nVidia RIVA TNT", "rivatnt", &rivatnt_device, GFX_RIVATNT}, - {"[PCI] nVidia RIVA TNT2", "rivatnt2", &rivatnt2_device, GFX_RIVATNT2}, -#endif - {"[PCI] Number Nine 9FX (S3 Trio64)", "n9_9fx_pci", &s3_9fx_pci_device, GFX_N9_9FX_PCI}, - {"[PCI] Paradise Bahamas 64 (S3 Vision864)", "bahamas64_pci", &s3_bahamas64_pci_device, GFX_BAHAMAS64_PCI}, - {"[PCI] Phoenix S3 Vision864", "px_vision864_pci", &s3_phoenix_vision864_pci_device, GFX_PHOENIX_VISION864_PCI}, - {"[PCI] Phoenix S3 Trio32", "px_trio32_pci", &s3_phoenix_trio32_pci_device, GFX_PHOENIX_TRIO32_PCI}, - {"[PCI] Phoenix S3 Trio64", "px_trio64_pci", &s3_phoenix_trio64_pci_device, GFX_PHOENIX_TRIO64_PCI}, - {"[PCI] S3 ViRGE/DX", "virge375_pci", &s3_virge_375_pci_device, GFX_VIRGEDX_PCI}, - {"[PCI] S3 ViRGE/DX (VBE 2.0)", "virge375_vbe20_pci", &s3_virge_375_4_pci_device, GFX_VIRGEDX4_PCI}, - {"[PCI] Trident TGUI9440", "tgui9440_pci", &tgui9440_pci_device, GFX_TGUI9440_PCI}, - {"", "", NULL, 0} +enum { + VIDEO_ISA = 0, + VIDEO_BUS }; -int video_card_available(int card) -{ - if (video_cards[card].device) - return device_available(video_cards[card].device); - return 1; -} - -char *video_card_getname(int card) -{ - return video_cards[card].name; -} - -device_t *video_card_getdevice(int card) -{ - return video_cards[card].device; -} - -int video_card_has_config(int card) -{ - return video_cards[card].device->config ? 1 : 0; -} - -int video_card_getid(char *s) -{ - int c = 0; - - while (video_cards[c].device) - { - if (!strcmp(video_cards[c].name, s)) - return c; - c++; - } - - return 0; -} - -int video_old_to_new(int card) -{ - int c = 0; - - while (video_cards[c].device) - { - if (video_cards[c].legacy_id == card) - return c; - c++; - } - - return 0; -} - -int video_new_to_old(int card) -{ - return video_cards[card].legacy_id; -} - -char *video_get_internal_name(int card) -{ - return video_cards[card].internal_name; -} - -int video_get_video_from_internal_name(char *s) -{ - int c = 0; - - while (video_cards[c].legacy_id != -1) - { - if (!strcmp(video_cards[c].internal_name, s)) - return video_cards[c].legacy_id; - c++; - } - - return 0; -} - -int video_fullscreen = 0, video_fullscreen_scale, video_fullscreen_first; -uint32_t *video_6to8, *video_15to32, *video_16to32; - -int egareads=0,egawrites=0; -int changeframecount=2; - -uint8_t rotatevga[8][256]; - -int frames = 0; - -int fullchange; - -uint8_t edatlookup[4][4]; - -int enable_overscan; -int overscan_x, overscan_y; - -int force_43; - -/*Video timing settings - - -8-bit - 1mb/sec - B = 8 ISA clocks - W = 16 ISA clocks - L = 32 ISA clocks - -Slow 16-bit - 2mb/sec - B = 6 ISA clocks - W = 8 ISA clocks - L = 16 ISA clocks - -Fast 16-bit - 4mb/sec - B = 3 ISA clocks - W = 3 ISA clocks - L = 6 ISA clocks - -Slow VLB/PCI - 8mb/sec (ish) - B = 4 bus clocks - W = 8 bus clocks - L = 16 bus clocks - -Mid VLB/PCI - - B = 4 bus clocks - W = 5 bus clocks - L = 10 bus clocks - -Fast VLB/PCI - - B = 3 bus clocks - W = 3 bus clocks - L = 4 bus clocks -*/ - -enum -{ - VIDEO_ISA = 0, - VIDEO_BUS +int vid_cga_contrast = 0; +int cga_palette = 0; +int video_fullscreen = 0, + video_fullscreen_scale, + video_fullscreen_first; +uint32_t *video_6to8, + *video_15to32, + *video_16to32; +BITMAP *screen; +int egareads = 0, + egawrites = 0, + changeframecount = 2; +uint8_t rotatevga[8][256]; +int frames = 0; +int fullchange; +uint8_t edatlookup[4][4]; +int enable_overscan; +int overscan_x, + overscan_y; +int force_43; +int video_timing_b, + video_timing_w, + video_timing_l; +int video_res_x, + video_res_y, + video_bpp; +int video_speed = 0; +int video_timing[6][4] = { + { VIDEO_ISA, 8, 16, 32 }, + { VIDEO_ISA, 6, 8, 16 }, + { VIDEO_ISA, 3, 3, 6 }, + { VIDEO_BUS, 4, 8, 16 }, + { VIDEO_BUS, 4, 5, 10 }, + { VIDEO_BUS, 3, 3, 4 } }; +BITMAP *buffer, + *buffer32; +uint8_t fontdat[256][8]; +uint8_t fontdatm[256][16]; +uint8_t fontdatw[512][32]; /* Wyse700 font */ +uint8_t fontdat8x12[256][16]; /* MDSI Genius font */ +int xsize=1, + ysize=1; +PALETTE cgapal = { + {0,0,0}, {0,42,0}, {42,0,0}, {42,21,0}, + {0,0,0}, {0,42,42}, {42,0,42}, {42,42,42}, + {0,0,0}, {21,63,21}, {63,21,21}, {63,63,21}, + {0,0,0}, {21,63,63}, {63,21,63}, {63,63,63}, -int video_speed = 0; -int video_timing[6][4] = -{ - {VIDEO_ISA, 8, 16, 32}, - {VIDEO_ISA, 6, 8, 16}, - {VIDEO_ISA, 3, 3, 6}, - {VIDEO_BUS, 4, 8, 16}, - {VIDEO_BUS, 4, 5, 10}, - {VIDEO_BUS, 3, 3, 4} + {0,0,0}, {0,0,42}, {0,42,0}, {0,42,42}, + {42,0,0}, {42,0,42}, {42,21,00}, {42,42,42}, + {21,21,21}, {21,21,63}, {21,63,21}, {21,63,63}, + {63,21,21}, {63,21,63}, {63,63,21}, {63,63,63}, + + {0,0,0}, {0,21,0}, {0,0,42}, {0,42,42}, + {42,0,21}, {21,10,21}, {42,0,42}, {42,0,63}, + {21,21,21}, {21,63,21}, {42,21,42}, {21,63,63}, + {63,0,0}, {42,42,0}, {63,21,42}, {41,41,41}, + + {0,0,0}, {0,42,42}, {42,0,0}, {42,42,42}, + {0,0,0}, {0,42,42}, {42,0,0}, {42,42,42}, + {0,0,0}, {0,63,63}, {63,0,0}, {63,63,63}, + {0,0,0}, {0,63,63}, {63,0,0}, {63,63,63}, }; +PALETTE cgapal_mono[6] = { + { /* 0 - green, 4-color-optimized contrast. */ + {0x00,0x00,0x00},{0x00,0x0d,0x03},{0x01,0x17,0x05}, + {0x01,0x1a,0x06},{0x02,0x28,0x09},{0x02,0x2c,0x0a}, + {0x03,0x39,0x0d},{0x03,0x3c,0x0e},{0x00,0x07,0x01}, + {0x01,0x13,0x04},{0x01,0x1f,0x07},{0x01,0x23,0x08}, + {0x02,0x31,0x0b},{0x02,0x35,0x0c},{0x05,0x3f,0x11},{0x0d,0x3f,0x17}, + }, + { /* 1 - green, 16-color-optimized contrast. */ + {0x00,0x00,0x00},{0x00,0x0d,0x03},{0x01,0x15,0x05}, + {0x01,0x17,0x05},{0x01,0x21,0x08},{0x01,0x24,0x08}, + {0x02,0x2e,0x0b},{0x02,0x31,0x0b},{0x01,0x22,0x08}, + {0x02,0x28,0x09},{0x02,0x30,0x0b},{0x02,0x32,0x0c}, + {0x03,0x39,0x0d},{0x03,0x3b,0x0e},{0x09,0x3f,0x14},{0x0d,0x3f,0x17}, + }, + { /* 2 - amber, 4-color-optimized contrast. */ + {0x00,0x00,0x00},{0x15,0x05,0x00},{0x20,0x0b,0x00}, + {0x24,0x0d,0x00},{0x33,0x18,0x00},{0x37,0x1b,0x00}, + {0x3f,0x26,0x01},{0x3f,0x2b,0x06},{0x0b,0x02,0x00}, + {0x1b,0x08,0x00},{0x29,0x11,0x00},{0x2e,0x14,0x00}, + {0x3b,0x1e,0x00},{0x3e,0x21,0x00},{0x3f,0x32,0x0a},{0x3f,0x38,0x0d}, + }, + { /* 3 - amber, 16-color-optimized contrast. */ + {0x00,0x00,0x00},{0x15,0x05,0x00},{0x1e,0x09,0x00}, + {0x21,0x0b,0x00},{0x2b,0x12,0x00},{0x2f,0x15,0x00}, + {0x38,0x1c,0x00},{0x3b,0x1e,0x00},{0x2c,0x13,0x00}, + {0x32,0x17,0x00},{0x3a,0x1e,0x00},{0x3c,0x1f,0x00}, + {0x3f,0x27,0x01},{0x3f,0x2a,0x04},{0x3f,0x36,0x0c},{0x3f,0x38,0x0d}, + }, + { /* 4 - grey, 4-color-optimized contrast. */ + {0x00,0x00,0x00},{0x0e,0x0f,0x10},{0x15,0x17,0x18}, + {0x18,0x1a,0x1b},{0x24,0x25,0x25},{0x27,0x28,0x28}, + {0x33,0x34,0x32},{0x37,0x38,0x35},{0x09,0x0a,0x0b}, + {0x11,0x12,0x13},{0x1c,0x1e,0x1e},{0x20,0x22,0x22}, + {0x2c,0x2d,0x2c},{0x2f,0x30,0x2f},{0x3c,0x3c,0x38},{0x3f,0x3f,0x3b}, + }, + { /* 5 - grey, 16-color-optimized contrast. */ + {0x00,0x00,0x00},{0x0e,0x0f,0x10},{0x13,0x14,0x15}, + {0x15,0x17,0x18},{0x1e,0x20,0x20},{0x20,0x22,0x22}, + {0x29,0x2a,0x2a},{0x2c,0x2d,0x2c},{0x1f,0x21,0x21}, + {0x23,0x25,0x25},{0x2b,0x2c,0x2b},{0x2d,0x2e,0x2d}, + {0x34,0x35,0x33},{0x37,0x37,0x34},{0x3e,0x3e,0x3a},{0x3f,0x3f,0x3b}, + } +}; +uint32_t pal_lookup[256]; -void video_updatetiming(void) -{ - if (video_timing[video_speed][0] == VIDEO_ISA) - { - video_timing_b = (int)(isa_timing * video_timing[video_speed][1]); - video_timing_w = (int)(isa_timing * video_timing[video_speed][2]); - video_timing_l = (int)(isa_timing * video_timing[video_speed][3]); - } - else - { - video_timing_b = (int)(bus_timing * video_timing[video_speed][1]); - video_timing_w = (int)(bus_timing * video_timing[video_speed][2]); - video_timing_l = (int)(bus_timing * video_timing[video_speed][3]); - } - if (cpu_16bitbus) - video_timing_l = video_timing_w * 2; -} -int video_timing_b, video_timing_w, video_timing_l; +static struct { + int x, y, y1, y2, w, h, blit8; + int busy; + int buffer_in_use; + + thread_t *blit_thread; + event_t *wake_blit_thread; + event_t *blit_complete; + event_t *buffer_not_in_use; +} blit_data; -int video_res_x, video_res_y, video_bpp; void (*video_blit_memtoscreen_func)(int x, int y, int y1, int y2, int w, int h); void (*video_blit_memtoscreen_8_func)(int x, int y, int w, int h); -void -video_reset(void) +static +void blit_thread(void *param) { - pclog("Video_reset(rom=%i, gfx=%i)\n", romset, gfxcard); + while (1) { + thread_wait_event(blit_data.wake_blit_thread, -1); + thread_reset_event(blit_data.wake_blit_thread); -#ifndef __unix - cga_palette = 0; - cgapal_rebuild(); -#endif - - switch (romset) - { - case ROM_IBMPCJR: - device_add(&pcjr_video_device); - return; - - case ROM_TANDY: - case ROM_TANDY1000HX: - device_add(&tandy_device); - return; - - case ROM_TANDY1000SL2: - device_add(&tandysl_device); - return; - - case ROM_PC1512: - device_add(&pc1512_device); - return; - - case ROM_PC1640: - device_add(&pc1640_device); - return; - - case ROM_PC200: - device_add(&pc200_device); - return; - - case ROM_OLIM24: - device_add(&m24_device); - return; - - case ROM_PC2086: - device_add(¶dise_pvga1a_pc2086_device); - return; - - case ROM_PC3086: - device_add(¶dise_pvga1a_pc3086_device); - return; - - case ROM_MEGAPC: - device_add(¶dise_wd90c11_megapc_device); - return; - - case ROM_ACER386: - device_add(&oti067_device); - return; - - case ROM_IBMPS1_2011: - case ROM_IBMPS2_M30_286: - case ROM_IBMPS2_M50: - case ROM_IBMPS2_M55SX: - case ROM_IBMPS2_M80: - device_add(&ps1vga_device); - return; - - case ROM_IBMPS1_2121: - device_add(&ps1_m2121_svga_device); - return; - } - device_add(video_cards[video_old_to_new(gfxcard)].device); -} - - -BITMAP *buffer, *buffer32; - -uint8_t fontdat[256][8]; -uint8_t fontdatm[256][16]; -uint8_t fontdatw[512][32]; /* Wyse700 font */ -uint8_t fontdat8x12[256][16]; /* MDSI Genius font */ - -int xsize=1,ysize=1; - -PALETTE cgapal; - -void loadfont(wchar_t *s, int format) -{ - FILE *f=rom_fopen(s,L"rb"); - int c,d; - if (!f) - { - return; - } - switch (format) - { - case 0: /* MDA */ - for (c=0;c<256;c++) - { - for (d=0;d<8;d++) - { - fontdatm[c][d]=getc(f); - } - } - for (c=0;c<256;c++) - { - for (d=0;d<8;d++) - { - fontdatm[c][d+8]=getc(f); - } - } - fseek(f,4096+2048,SEEK_SET); - for (c=0;c<256;c++) - { - for (d=0;d<8;d++) - { - fontdat[c][d]=getc(f); - } - } - break; - case 1: /* PC200 */ - for (c=0;c<256;c++) - { - for (d=0;d<8;d++) - { - fontdatm[c][d]=getc(f); - } - } - for (c=0;c<256;c++) - { - for (d=0;d<8;d++) - { - fontdatm[c][d+8]=getc(f); - } - } - fseek(f, 4096, SEEK_SET); - for (c=0;c<256;c++) - { - for (d=0;d<8;d++) - { - fontdat[c][d]=getc(f); - } - for (d=0;d<8;d++) getc(f); - } - break; - default: - case 2: /* CGA */ - for (c=0;c<256;c++) - { - for (d=0;d<8;d++) - { - fontdat[c][d]=getc(f); - } - } - break; - case 3: /* Wyse 700 */ - for (c=0;c<512;c++) - { - for (d=0;d<32;d++) - { - fontdatw[c][d]=getc(f); - } - } - break; - case 4: /* MDSI Genius */ - for (c=0;c<256;c++) - { - for (d=0;d<16;d++) - { - fontdat8x12[c][d]=getc(f); - } - } - break; - - } - fclose(f); -} - -static struct -{ - int x, y, y1, y2, w, h, blit8; - int busy; - int buffer_in_use; - - thread_t *blit_thread; - event_t *wake_blit_thread; - event_t *blit_complete; - event_t *buffer_not_in_use; -} blit_data; - -static void blit_thread(void *param); - -int calc_6to8(int c) -{ - int ic, i8; - double d8; - ic = c; - if (ic == 64) - { - ic = 63; - } + if (blit_data.blit8) + video_blit_memtoscreen_8_func(blit_data.x, blit_data.y, blit_data.w, blit_data.h); else - { - ic &= 0x3f; + video_blit_memtoscreen_func(blit_data.x, blit_data.y, blit_data.y1, blit_data.y2, blit_data.w, blit_data.h); + + blit_data.busy = 0; + thread_set_event(blit_data.blit_complete); + } +} + + +void +video_blit_complete(void) +{ + blit_data.buffer_in_use = 0; + + thread_set_event(blit_data.buffer_not_in_use); +} + + +void +video_wait_for_blit(void) +{ + while (blit_data.busy) + thread_wait_event(blit_data.blit_complete, -1); + thread_reset_event(blit_data.blit_complete); +} + + +void +video_wait_for_buffer(void) +{ + while (blit_data.buffer_in_use) + thread_wait_event(blit_data.buffer_not_in_use, -1); + thread_reset_event(blit_data.buffer_not_in_use); +} + + +void +video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) +{ + if (h <= 0) return; + + video_wait_for_blit(); + + blit_data.busy = 1; + blit_data.buffer_in_use = 1; + blit_data.x = x; + blit_data.y = y; + blit_data.y1 = y1; + blit_data.y2 = y2; + blit_data.w = w; + blit_data.h = h; + blit_data.blit8 = 0; + + thread_set_event(blit_data.wake_blit_thread); +} + + +void +video_blit_memtoscreen_8(int x, int y, int w, int h) +{ + if (h <= 0) return; + + video_wait_for_blit(); + + blit_data.busy = 1; + blit_data.x = x; + blit_data.y = y; + blit_data.w = w; + blit_data.h = h; + blit_data.blit8 = 1; + + thread_set_event(blit_data.wake_blit_thread); +} + + +void +cgapal_rebuild(void) +{ + int c; + + for (c=0; c<256; c++) { + pal_lookup[c] = makecol(video_6to8[cgapal[c].r], + video_6to8[cgapal[c].g], + video_6to8[cgapal[c].b]); + } + + if ((cga_palette > 1) && (cga_palette < 8)) { + if (vid_cga_contrast != 0) { + for (c=0; c<16; c++) { + pal_lookup[c] = makecol(video_6to8[cgapal_mono[cga_palette - 2][c].r], + video_6to8[cgapal_mono[cga_palette - 2][c].g], + video_6to8[cgapal_mono[cga_palette - 2][c].b]); + pal_lookup[c+16] = makecol(video_6to8[cgapal_mono[cga_palette - 2][c].r], + video_6to8[cgapal_mono[cga_palette - 2][c].g], + video_6to8[cgapal_mono[cga_palette - 2][c].b]); + pal_lookup[c+32] = makecol(video_6to8[cgapal_mono[cga_palette - 2][c].r], + video_6to8[cgapal_mono[cga_palette - 2][c].g], + video_6to8[cgapal_mono[cga_palette - 2][c].b]); + pal_lookup[c+48] = makecol(video_6to8[cgapal_mono[cga_palette - 2][c].r], + video_6to8[cgapal_mono[cga_palette - 2][c].g], + video_6to8[cgapal_mono[cga_palette - 2][c].b]); + } + } else { + for (c=0; c<16; c++) { + pal_lookup[c] = makecol(video_6to8[cgapal_mono[cga_palette - 1][c].r], + video_6to8[cgapal_mono[cga_palette - 1][c].g], + video_6to8[cgapal_mono[cga_palette - 1][c].b]); + pal_lookup[c+16] = makecol(video_6to8[cgapal_mono[cga_palette - 1][c].r], + video_6to8[cgapal_mono[cga_palette - 1][c].g], + video_6to8[cgapal_mono[cga_palette - 1][c].b]); + pal_lookup[c+32] = makecol(video_6to8[cgapal_mono[cga_palette - 1][c].r], + video_6to8[cgapal_mono[cga_palette - 1][c].g], + video_6to8[cgapal_mono[cga_palette - 1][c].b]); + pal_lookup[c+48] = makecol(video_6to8[cgapal_mono[cga_palette - 1][c].r], + video_6to8[cgapal_mono[cga_palette - 1][c].g], + video_6to8[cgapal_mono[cga_palette - 1][c].b]); + } } - d8 = (ic / 63.0) * 255.0; - i8 = (int) d8; - return i8 & 0xff; + } + + if (cga_palette == 8) + pal_lookup[0x16] = makecol(video_6to8[42],video_6to8[42],video_6to8[0]); } -int calc_15to32(int c) + +void +video_update_timing(void) { - int b, g, r; - double db, dg, dr; - b = (c & 31); - g = ((c >> 5) & 31); - r = ((c >> 10) & 31); - db = (((double) b) / 31.0) * 255.0; - dg = (((double) g) / 31.0) * 255.0; - dr = (((double) r) / 31.0) * 255.0; - b = (int) db; - g = ((int) dg) << 8; - r = ((int) dr) << 16; - return (b | g | r); + if (video_timing[video_speed][0] == VIDEO_ISA) { + video_timing_b = (int)(isa_timing * video_timing[video_speed][1]); + video_timing_w = (int)(isa_timing * video_timing[video_speed][2]); + video_timing_l = (int)(isa_timing * video_timing[video_speed][3]); + } else { + video_timing_b = (int)(bus_timing * video_timing[video_speed][1]); + video_timing_w = (int)(bus_timing * video_timing[video_speed][2]); + video_timing_l = (int)(bus_timing * video_timing[video_speed][3]); + } + + if (cpu_16bitbus) + video_timing_l = video_timing_w * 2; } -int calc_16to32(int c) + +int +calc_6to8(int c) { - int b, g, r; - double db, dg, dr; - b = (c & 31); - g = ((c >> 5) & 63); - r = ((c >> 11) & 31); - db = (((double) b) / 31.0) * 255.0; - dg = (((double) g) / 63.0) * 255.0; - dr = (((double) r) / 31.0) * 255.0; - b = (int) db; - g = ((int) dg) << 8; - r = ((int) dr) << 16; - return (b | g | r); + int ic, i8; + double d8; + + ic = c; + if (ic == 64) + ic = 63; + else + ic &= 0x3f; + d8 = (ic / 63.0) * 255.0; + i8 = (int) d8; + + return(i8 & 0xff); } + +int +calc_15to32(int c) +{ + int b, g, r; + double db, dg, dr; + + b = (c & 31); + g = ((c >> 5) & 31); + r = ((c >> 10) & 31); + db = (((double) b) / 31.0) * 255.0; + dg = (((double) g) / 31.0) * 255.0; + dr = (((double) r) / 31.0) * 255.0; + b = (int) db; + g = ((int) dg) << 8; + r = ((int) dr) << 16; + + return(b | g | r); +} + + +int +calc_16to32(int c) +{ + int b, g, r; + double db, dg, dr; + + b = (c & 31); + g = ((c >> 5) & 63); + r = ((c >> 11) & 31); + db = (((double) b) / 31.0) * 255.0; + dg = (((double) g) / 63.0) * 255.0; + dr = (((double) r) / 31.0) * 255.0; + b = (int) db; + g = ((int) dg) << 8; + r = ((int) dr) << 16; + + return(b | g | r); +} + + +void +hline(BITMAP *b, int x1, int y, int x2, uint32_t col) +{ + if (y < 0 || y >= buffer->h) + return; + + if (b == buffer) + memset(&b->line[y][x1], col, x2 - x1); + else + memset(&((uint32_t *)b->line[y])[x1], col, (x2 - x1) * 4); +} + + +void +blit(BITMAP *src, BITMAP *dst, int x1, int y1, int x2, int y2, int xs, int ys) +{ +} + + +void +stretch_blit(BITMAP *src, BITMAP *dst, int x1, int y1, int xs1, int ys1, int x2, int y2, int xs2, int ys2) +{ +} + + +void +rectfill(BITMAP *b, int x1, int y1, int x2, int y2, uint32_t col) +{ +} + + +void +set_palette(PALETTE p) +{ +} + + +void +destroy_bitmap(BITMAP *b) +{ +} + + +BITMAP * +create_bitmap(int x, int y) +{ + BITMAP *b = malloc(sizeof(BITMAP) + (y * sizeof(uint8_t *))); + int c; + + b->dat = malloc(x * y * 4); + for (c = 0; c < y; c++) + b->line[c] = b->dat + (c * x * 4); + b->w = x; + b->h = y; + + return(b); +} + + void video_init(void) { - int c, d, e; + int c, d, e; - /* Account for overscan. */ - buffer32 = create_bitmap(2048, 2048); + /* Account for overscan. */ + buffer32 = create_bitmap(2048, 2048); - buffer = create_bitmap(2048, 2048); + buffer = create_bitmap(2048, 2048); + for (c = 0; c < 64; c++) { + cgapal[c + 64].r = (((c & 4) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21; + cgapal[c + 64].g = (((c & 2) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21; + cgapal[c + 64].b = (((c & 1) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21; + if ((c & 0x17) == 6) + cgapal[c + 64].g >>= 1; + } + for (c = 0; c < 64; c++) { + cgapal[c + 128].r = (((c & 4) ? 2 : 0) | ((c & 0x20) ? 1 : 0)) * 21; + cgapal[c + 128].g = (((c & 2) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21; + cgapal[c + 128].b = (((c & 1) ? 2 : 0) | ((c & 0x08) ? 1 : 0)) * 21; + } - for (c = 0; c < 64; c++) - { - cgapal[c + 64].r = (((c & 4) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21; - cgapal[c + 64].g = (((c & 2) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21; - cgapal[c + 64].b = (((c & 1) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21; - if ((c & 0x17) == 6) - cgapal[c + 64].g >>= 1; - } - for (c = 0; c < 64; c++) - { - cgapal[c + 128].r = (((c & 4) ? 2 : 0) | ((c & 0x20) ? 1 : 0)) * 21; - cgapal[c + 128].g = (((c & 2) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21; - cgapal[c + 128].b = (((c & 1) ? 2 : 0) | ((c & 0x08) ? 1 : 0)) * 21; - } + for (c = 0; c < 256; c++) { + e = c; + for (d = 0; d < 8; d++) { + rotatevga[d][c] = e; + e = (e >> 1) | ((e & 1) ? 0x80 : 0); + } + } + for (c = 0; c < 4; c++) { + for (d = 0; d < 4; d++) { + edatlookup[c][d] = 0; + if (c & 1) edatlookup[c][d] |= 1; + if (d & 1) edatlookup[c][d] |= 2; + if (c & 2) edatlookup[c][d] |= 0x10; + if (d & 2) edatlookup[c][d] |= 0x20; + } + } - for (c = 0; c < 256; c++) - { - e = c; - for (d = 0; d < 8; d++) - { - rotatevga[d][c] = e; - e = (e >> 1) | ((e & 1) ? 0x80 : 0); - } - } - for (c = 0; c < 4; c++) - { - for (d = 0; d < 4; d++) - { - edatlookup[c][d] = 0; - if (c & 1) edatlookup[c][d] |= 1; - if (d & 1) edatlookup[c][d] |= 2; - if (c & 2) edatlookup[c][d] |= 0x10; - if (d & 2) edatlookup[c][d] |= 0x20; - } - } - - video_6to8 = malloc(4 * 256); - for (c = 0; c < 256; c++) - video_6to8[c] = calc_6to8(c); - - video_15to32 = malloc(4 * 65536); + video_6to8 = malloc(4 * 256); + for (c = 0; c < 256; c++) + video_6to8[c] = calc_6to8(c); + video_15to32 = malloc(4 * 65536); #if 0 - for (c = 0; c < 65536; c++) - video_15to32[c] = ((c & 31) << 3) | (((c >> 5) & 31) << 11) | (((c >> 10) & 31) << 19); + for (c = 0; c < 65536; c++) + video_15to32[c] = ((c & 31) << 3) | (((c >> 5) & 31) << 11) | (((c >> 10) & 31) << 19); #endif - for (c = 0; c < 65536; c++) - video_15to32[c] = calc_15to32(c); + for (c = 0; c < 65536; c++) + video_15to32[c] = calc_15to32(c); - video_16to32 = malloc(4 * 65536); + video_16to32 = malloc(4 * 65536); #if 0 - for (c = 0; c < 65536; c++) - video_16to32[c] = ((c & 31) << 3) | (((c >> 5) & 63) << 10) | (((c >> 11) & 31) << 19); + for (c = 0; c < 65536; c++) + video_16to32[c] = ((c & 31) << 3) | (((c >> 5) & 63) << 10) | (((c >> 11) & 31) << 19); #endif - for (c = 0; c < 65536; c++) - video_16to32[c] = calc_16to32(c); + for (c = 0; c < 65536; c++) + video_16to32[c] = calc_16to32(c); - blit_data.wake_blit_thread = thread_create_event(); - blit_data.blit_complete = thread_create_event(); - blit_data.buffer_not_in_use = thread_create_event(); - blit_data.blit_thread = thread_create(blit_thread, NULL); + blit_data.wake_blit_thread = thread_create_event(); + blit_data.blit_complete = thread_create_event(); + blit_data.buffer_not_in_use = thread_create_event(); + blit_data.blit_thread = thread_create(blit_thread, NULL); } + void video_close(void) { - thread_kill(blit_data.blit_thread); - thread_destroy_event(blit_data.buffer_not_in_use); - thread_destroy_event(blit_data.blit_complete); - thread_destroy_event(blit_data.wake_blit_thread); + thread_kill(blit_data.blit_thread); + thread_destroy_event(blit_data.buffer_not_in_use); + thread_destroy_event(blit_data.blit_complete); + thread_destroy_event(blit_data.wake_blit_thread); - free(video_6to8); - free(video_15to32); - free(video_16to32); - destroy_bitmap(buffer); - destroy_bitmap(buffer32); -} + free(video_6to8); + free(video_15to32); + free(video_16to32); - -static void blit_thread(void *param) -{ - while (1) - { - thread_wait_event(blit_data.wake_blit_thread, -1); - thread_reset_event(blit_data.wake_blit_thread); - - if (blit_data.blit8) - video_blit_memtoscreen_8_func(blit_data.x, blit_data.y, blit_data.w, blit_data.h); - else - video_blit_memtoscreen_func(blit_data.x, blit_data.y, blit_data.y1, blit_data.y2, blit_data.w, blit_data.h); - - blit_data.busy = 0; - thread_set_event(blit_data.blit_complete); - } -} - -void video_blit_complete(void) -{ - blit_data.buffer_in_use = 0; - thread_set_event(blit_data.buffer_not_in_use); -} - -void video_wait_for_blit(void) -{ - while (blit_data.busy) - thread_wait_event(blit_data.blit_complete, -1); - thread_reset_event(blit_data.blit_complete); -} -void video_wait_for_buffer(void) -{ - while (blit_data.buffer_in_use) - thread_wait_event(blit_data.buffer_not_in_use, -1); - thread_reset_event(blit_data.buffer_not_in_use); -} - -void video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) -{ - if (h <= 0) - return; - video_wait_for_blit(); - blit_data.busy = 1; - blit_data.buffer_in_use = 1; - blit_data.x = x; - blit_data.y = y; - blit_data.y1 = y1; - blit_data.y2 = y2; - blit_data.w = w; - blit_data.h = h; - blit_data.blit8 = 0; - thread_set_event(blit_data.wake_blit_thread); -} - -void video_blit_memtoscreen_8(int x, int y, int w, int h) -{ - if (h <= 0) - return; - video_wait_for_blit(); - blit_data.busy = 1; - blit_data.x = x; - blit_data.y = y; - blit_data.w = w; - blit_data.h = h; - blit_data.blit8 = 1; - thread_set_event(blit_data.wake_blit_thread); + destroy_bitmap(buffer); + destroy_bitmap(buffer32); } void -take_screenshot(void) +video_reset(void) { - wchar_t path[1024], fn[128]; - struct tm *info; - time_t now; + pclog("Video_reset(rom=%i, gfx=%i)\n", romset, gfxcard); - pclog("Screenshot: video API is: %i\n", vid_api); - if ((vid_api < 0) || (vid_api > 1)) return; - - memset(fn, 0, sizeof(fn)); - memset(path, 0, sizeof(path)); - - (void)time(&now); - info = localtime(&now); - - append_filename_w(path, cfg_path, SCREENSHOT_PATH, sizeof(path)-2); - - if (! dir_check_exist(path)) - dir_create(path); - -#ifdef WIN32 - wcscat(path, L"\\"); -#else - wcscat(path, L"/"); +#ifndef __unix + cga_palette = 0; + cgapal_rebuild(); #endif - if (vid_api == 1) { - wcsftime(fn, 128, L"%Y%m%d_%H%M%S.png", info); - append_filename_w(path, cfg_path, fn, 1024); - if (video_fullscreen) - d3d_fs_take_screenshot(path); - else - d3d_take_screenshot(path); - } else if (vid_api == 0) { - wcsftime(path, 128, L"%Y%m%d_%H%M%S.bmp", info); - append_filename_w(path, cfg_path, fn, 1024); - if (video_fullscreen) - ddraw_fs_take_screenshot(path); - else - ddraw_take_screenshot(path); + /* + * Add and initialize the selected video card device. + * + * This will soon be moved into machine.c. + */ + video_reset_device(romset, gfxcard); +} + + +void +loadfont(wchar_t *s, int format) +{ + FILE *f; + int c,d; + + f = rom_fopen(s, L"rb"); + if (f == NULL) return; + + switch (format) { + case 0: /* MDA */ + for (c=0; c<256; c++) + for (d=0; d<8; d++) + fontdatm[c][d] = fgetc(f); + for (c=0; c<256; c++) + for (d=0; d<8; d++) + fontdatm[c][d+8] = fgetc(f); + (void)fseek(f, 4096+2048, SEEK_SET); + for (c=0; c<256; c++) + for (d=0; d<8; d++) + fontdat[c][d] = fgetc(f); + break; + + case 1: /* PC200 */ + for (c=0; c<256; c++) + for (d=0; d<8; d++) + fontdatm[c][d] = fgetc(f); + for (c=0; c<256; c++) + for (d=0; d<8; d++) + fontdatm[c][d+8] = fgetc(f); + (void)fseek(f, 4096, SEEK_SET); + for (c=0; c<256; c++) { + for (d=0; d<8; d++) + fontdat[c][d] = fgetc(f); + for (d=0; d<8; d++) (void)fgetc(f); + } + break; + + default: + case 2: /* CGA */ + for (c=0; c<256; c++) + for (d=0; d<8; d++) + fontdat[c][d] = fgetc(f); + break; + + case 3: /* Wyse 700 */ + for (c=0; c<512; c++) + for (d=0; d<32; d++) + fontdatw[c][d] = fgetc(f); + break; + + case 4: /* MDSI Genius */ + for (c=0; c<256; c++) + for (d=0; d<16; d++) + fontdat8x12[c][d] = fgetc(f); + break; + } - pclog("Screenshot: fn='%ws'\n", path); + (void)fclose(f); } diff --git a/src/video/video.h b/src/video/video.h index 0291810dd..ebec35101 100644 --- a/src/video/video.h +++ b/src/video/video.h @@ -1,132 +1,126 @@ -/* Copyright holders: Sarah Walker, Tenshi - see COPYING for more details -*/ #ifndef EMU_VIDEO_H # define EMU_VIDEO_H -typedef struct -{ - int w, h; - uint8_t *dat; - uint8_t *line[]; -} BITMAP; - -extern BITMAP *screen; - -BITMAP *create_bitmap(int w, int h); - -typedef struct -{ - uint8_t r, g, b; -} RGB; - -typedef RGB PALETTE[256]; - #define makecol(r, g, b) ((b) | ((g) << 8) | ((r) << 16)) #define makecol32(r, g, b) ((b) | ((g) << 8) | ((r) << 16)) -extern BITMAP *buffer, *buffer32; - -int video_card_available(int card); -char *video_card_getname(int card); -#ifdef EMU_DEVICE_H -device_t *video_card_getdevice(int card); -#endif -int video_card_has_config(int card); -int video_card_getid(char *s); -int video_old_to_new(int card); -int video_new_to_old(int card); -char *video_get_internal_name(int card); -int video_get_video_from_internal_name(char *s); - -extern int video_fullscreen, video_fullscreen_scale, video_fullscreen_first; - -enum -{ - FULLSCR_SCALE_FULL = 0, - FULLSCR_SCALE_43, - FULLSCR_SCALE_SQ, - FULLSCR_SCALE_INT +enum { + FULLSCR_SCALE_FULL = 0, + FULLSCR_SCALE_43, + FULLSCR_SCALE_SQ, + FULLSCR_SCALE_INT }; -extern int egareads,egawrites; -extern int fullchange; -extern int changeframecount; +typedef struct { + int w, h; + uint8_t *dat; + uint8_t *line[]; +} BITMAP; -extern uint8_t fontdat[256][8]; -extern uint8_t fontdatm[256][16]; +typedef struct { + uint8_t r, g, b; +} RGB; + +typedef RGB PALETTE[256]; -extern uint32_t *video_6to8, *video_15to32, *video_16to32; -extern int xsize,ysize; +extern BITMAP *screen, + *buffer, + *buffer32; +extern PALETTE cgapal, + cgapal_mono[6]; +extern uint32_t pal_lookup[256]; +extern int video_fullscreen, + video_fullscreen_scale, + video_fullscreen_first; +extern int egareads,egawrites; +extern int fullchange; +extern int changeframecount; +extern uint8_t fontdat[256][8]; +extern uint8_t fontdatm[256][16]; +extern uint32_t *video_6to8, + *video_15to32, + *video_16to32; +extern int xsize,ysize; +extern int enable_overscan; +extern int overscan_x, + overscan_y; +extern int force_43; +extern int video_timing_b, + video_timing_w, + video_timing_l; +extern int video_speed; +extern int video_res_x, + video_res_y, + video_bpp; +extern int vid_resize; +extern int winsizex, + winsizey; +extern int cga_palette; +extern int vid_cga_contrast; +extern int video_grayscale; +extern int video_graytype; -extern float cpuclock; +extern float cpuclock; +extern int emu_fps, + frames; +extern int readflash; -extern int emu_fps, frames; - -extern int readflash; - -extern void (*video_recalctimings)(); - -void video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h); -void video_blit_memtoscreen_8(int x, int y, int w, int h); - -extern void (*video_blit_memtoscreen_func)(int x, int y, int y1, int y2, int w, int h); -extern void (*video_blit_memtoscreen_8_func)(int x, int y, int w, int h); - -/* Enable EGA/(S)VGA overscan border. */ -extern int enable_overscan; -extern int overscan_x, overscan_y; - -/* Forcibly stretch emulated video output to 4:3 or not. */ -extern int force_43; - -extern int video_timing_b, video_timing_w, video_timing_l; -extern int video_speed; - -extern int video_res_x, video_res_y, video_bpp; - -extern int vid_resize; - -void video_wait_for_blit(void); -void video_wait_for_buffer(void); - -extern int winsizex,winsizey; #ifdef __cplusplus extern "C" { #endif -void take_screenshot(void); -void d3d_take_screenshot(wchar_t *fn); -void d3d_fs_take_screenshot(wchar_t *fn); -void ddraw_take_screenshot(wchar_t *fn); -void ddraw_fs_take_screenshot(wchar_t *fn); +/* Function handler pointers. */ +extern void (*video_recalctimings)(void); +extern void (*video_blit_memtoscreen_func)(int x, int y, int y1, int y2, int w, int h); +extern void (*video_blit_memtoscreen_8_func)(int x, int y, int w, int h); + + +/* Table functions. */ +extern int video_card_available(int card); +extern char *video_card_getname(int card); +#ifdef EMU_DEVICE_H +extern device_t *video_card_getdevice(int card); +#endif +extern int video_card_has_config(int card); +extern int video_card_getid(char *s); +extern int video_old_to_new(int card); +extern int video_new_to_old(int card); +extern char *video_get_internal_name(int card); +extern int video_get_video_from_internal_name(char *s); + + +extern void video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h); +extern void video_blit_memtoscreen_8(int x, int y, int w, int h); +extern void video_wait_for_blit(void); +extern void video_wait_for_buffer(void); + +extern BITMAP *create_bitmap(int w, int h); +extern void destroy_bitmap(BITMAP *b); +extern void cgapal_rebuild(void); +extern void hline(BITMAP *b, int x1, int y, int x2, uint32_t col); +extern void updatewindowsize(int x, int y); + +extern void video_init(void); +extern void video_close(void); +extern void video_reset(void); +extern void video_reset_device(int, int); +extern void video_update_timing(void); + +extern void loadfont(wchar_t *s, int format); + +#ifdef ENABLE_VRAM_DUMP +extern void svga_dump_vram(void); +#endif + #ifdef __cplusplus } #endif -extern int cga_palette; -extern int vid_cga_contrast; - -extern int video_grayscale; -extern int video_graytype; - -void loadfont(wchar_t *s, int format); -void video_init(void); -void video_close(void); -void video_reset(void); -void video_updatetiming(void); - -void hline(BITMAP *b, int x1, int y, int x2, uint32_t col); -void updatewindowsize(int x, int y); - -#ifdef ENABLE_VRAM_DUMP -void svga_dump_vram(void); -#endif - #endif /*EMU_VIDEO_H*/ + diff --git a/src/win/plat_dinput.h b/src/win/plat_dinput.h deleted file mode 100644 index b5d7eca06..000000000 --- a/src/win/plat_dinput.h +++ /dev/null @@ -1,4 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -extern LPDIRECTINPUT lpdi; diff --git a/src/win/plat_thread.h b/src/win/plat_thread.h deleted file mode 100644 index db9fac030..000000000 --- a/src/win/plat_thread.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -#ifndef PLAT_THREAD_H -# define PLAT_THREAD_H - - -typedef void thread_t; -typedef void event_t; - - -extern thread_t *thread_create(void (*thread_rout)(void *param), void *param); -extern void thread_kill(thread_t *handle); - -extern event_t *thread_create_event(void); -extern void thread_set_event(event_t *event); -extern void thread_reset_event(event_t *_event); -extern int thread_wait_event(event_t *event, int timeout); -extern void thread_destroy_event(event_t *_event); - -extern void thread_sleep(int t); - -extern void *thread_create_mutex(wchar_t *name); -extern void thread_close_mutex(void *mutex); -extern uint8_t thread_wait_mutex(void *mutex); -extern uint8_t thread_release_mutex(void *mutex); - -extern void startslirp(void); -extern void endslirp(void); - - -#endif /*PLAT_THREAD_H*/ diff --git a/src/win/plat_ticks.h b/src/win/plat_ticks.h deleted file mode 100644 index d6e48f37a..000000000 --- a/src/win/plat_ticks.h +++ /dev/null @@ -1,2 +0,0 @@ -uint32_t get_ticks(void); -void delay_ms(uint32_t count); diff --git a/src/win/win.c b/src/win/win.c index e227c58ff..c0ab892c1 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -8,7 +8,7 @@ * * The Emulator's Windows core. * - * Version: @(#)win.c 1.0.19 2017/10/09 + * Version: @(#)win.c 1.0.20 2017/10/10 * * Authors: Sarah Walker, * Miran Grca, @@ -33,6 +33,7 @@ #include #include #include +#include #include #include "../86box.h" #include "../config.h" @@ -53,14 +54,11 @@ #include "../sound/sound.h" #include "../sound/snd_dbopl.h" #include "../plat.h" +#include "../plat_keyboard.h" +#include "../plat_mouse.h" +#include "../plat_midi.h" #include "../ui.h" -#include "plat_keyboard.h" -#include "plat_mouse.h" -#include "plat_midi.h" -#include "plat_thread.h" -#include "plat_ticks.h" #include "win.h" -#include "win_cgapal.h" #include "win_ddraw.h" #include "win_d3d.h" @@ -527,10 +525,10 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_VID_D3D: startblit(); video_wait_for_blit(); - CheckMenuItem(hmenu, IDM_VID_DDRAW + vid_api, MF_UNCHECKED); + CheckMenuItem(hmenu, IDM_VID_DDRAW+vid_api, MF_UNCHECKED); vid_apis[0][vid_api].close(); vid_api = LOWORD(wParam) - IDM_VID_DDRAW; - CheckMenuItem(hmenu, IDM_VID_DDRAW + vid_api, MF_CHECKED); + CheckMenuItem(hmenu, IDM_VID_DDRAW+vid_api, MF_CHECKED); vid_apis[0][vid_api].init(hwndRender); endblit(); config_save(); @@ -1469,6 +1467,60 @@ plat_get_string_from_string(char *str) } + +/* If these are in the headers, doesn't work...? --FvK */ +//extern void ddraw_take_screenshot(wchar_t *); +//extern void ddraw_fs_take_screenshot(wchar_t *); +//extern void d3d_take_screenshot(wchar_t *); +//extern void d3d_fs_take_screenshot(wchar_t *); + +void +take_screenshot(void) +{ + wchar_t path[1024], fn[128]; + struct tm *info; + time_t now; + + pclog("Screenshot: video API is: %i\n", vid_api); + if ((vid_api < 0) || (vid_api > 1)) return; + + memset(fn, 0, sizeof(fn)); + memset(path, 0, sizeof(path)); + + (void)time(&now); + info = localtime(&now); + + append_filename_w(path, cfg_path, SCREENSHOT_PATH, sizeof(path)-2); + + if (! dir_check_exist(path)) + dir_create(path); + +#ifdef WIN32 + wcscat(path, L"\\"); +#else + wcscat(path, L"/"); +#endif + + if (vid_api == 1) { + wcsftime(fn, 128, L"%Y%m%d_%H%M%S.png", info); + append_filename_w(path, cfg_path, fn, 1024); + if (video_fullscreen) + d3d_fs_take_screenshot(path); + else + d3d_take_screenshot(path); + } else if (vid_api == 0) { + wcsftime(path, 128, L"%Y%m%d_%H%M%S.bmp", info); + append_filename_w(path, cfg_path, fn, 1024); + if (video_fullscreen) + ddraw_fs_take_screenshot(path); + else + ddraw_take_screenshot(path); + } + + pclog("Screenshot: fn='%ws'\n", path); +} + + void startblit(void) { diff --git a/src/win/win_cgapal.h b/src/win/win_cgapal.h deleted file mode 100644 index 0388cde27..000000000 --- a/src/win/win_cgapal.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * The Windows CGA palette handler header. - * - * Version: @(#)win_cgapal.h 1.0.0 2017/05/30 - * - * Author: Miran Grca, - * Copyright 2016-2017 Miran Grca. - */ - -extern PALETTE cgapal; -extern PALETTE cgapal_mono[6]; - -extern uint32_t pal_lookup[256]; - -#ifdef __cplusplus -extern "C" { -#endif -void cgapal_rebuild(); -void destroy_bitmap(BITMAP *b); -#ifdef __cplusplus -} -#endif diff --git a/src/win/win_d3d.cc b/src/win/win_d3d.cc index 3b7740d56..93252c691 100644 --- a/src/win/win_d3d.cc +++ b/src/win/win_d3d.cc @@ -8,10 +8,11 @@ * * Direct3D 9 rendererer and screenshots taking. * - * Version: @(#)win_d3d.cc 1.0.1 2017/08/23 + * Version: @(#)win_d3d.cc 1.0.2 2017/10/10 * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ @@ -19,7 +20,6 @@ #include "../video/video.h" #include "win.h" #include "win_d3d.h" -#include "win_cgapal.h" extern "C" void fatal(const char *format, ...); @@ -28,6 +28,7 @@ extern "C" void pclog(const char *format, ...); extern "C" void device_force_redraw(void); extern "C" void video_blit_complete(void); +extern "C" void d3d_take_screenshot(wchar_t *fn); void d3d_init_objects(void); void d3d_close_objects(void); @@ -99,9 +100,13 @@ int d3d_init(HWND h) fatal("CreateDevice failed\n"); d3d_init_objects(); - + +#if 0 + video_setblit(d3d_blit_memtoscreen_8, d3d_blit_memtoscreen); +#else video_blit_memtoscreen_func = d3d_blit_memtoscreen; video_blit_memtoscreen_8_func = d3d_blit_memtoscreen_8; +#endif return 1; } diff --git a/src/win/win_d3d.h b/src/win/win_d3d.h index 7829d08a7..a57c2bb80 100644 --- a/src/win/win_d3d.h +++ b/src/win/win_d3d.h @@ -8,14 +8,14 @@ * * Direct3D 9 rendererer and screenshots taking. * - * Version: @(#)win_d3d.h 1.0.0 2017/05/30 + * Version: @(#)win_d3d.h 1.0.1 2017/10/10 * - * Author: Sarah Walker, + * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. - * Copyright 2016-2017 Miran Grca. + * Copyright 2016,2017 Miran Grca. */ - #ifndef WIN_D3D_H # define WIN_D3D_H # define UNICODE @@ -39,6 +39,7 @@ extern int d3d_fs_init(HWND h); extern void d3d_fs_close(void); extern void d3d_fs_reset(void); extern void d3d_fs_resize(int x, int y); +extern void d3d_fs_take_screenshot(wchar_t *fn); #ifdef __cplusplus } diff --git a/src/win/win_d3d_fs.cc b/src/win/win_d3d_fs.cc index 4bdef9c9a..71d7b3cc8 100644 --- a/src/win/win_d3d_fs.cc +++ b/src/win/win_d3d_fs.cc @@ -8,10 +8,11 @@ * * Direct3D 9 full-screen rendererer. * - * Version: @(#)win_d3d_fs.cc 1.0.3 2017/10/05 + * Version: @(#)win_d3d_fs.cc 1.0.4 2017/10/10 * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ @@ -21,7 +22,6 @@ #include "../video/video.h" #include "win.h" #include "win_d3d.h" -#include "win_cgapal.h" extern "C" void fatal(const char *format, ...); @@ -29,13 +29,15 @@ extern "C" void pclog(const char *format, ...); extern "C" void device_force_redraw(void); +extern "C" void video_blit_complete(void); + +extern "C" void d3d_fs_take_screenshot(wchar_t *fn); + static void d3d_fs_init_objects(void); static void d3d_fs_close_objects(void); static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h); static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h); -extern "C" void video_blit_complete(void); - static LPDIRECT3D9 d3d = NULL; static LPDIRECT3DDEVICE9 d3ddev = NULL; @@ -56,75 +58,6 @@ struct CUSTOMVERTEX }; -PALETTE cgapal = { - {0,0,0},{0,42,0},{42,0,0},{42,21,0}, - {0,0,0},{0,42,42},{42,0,42},{42,42,42}, - {0,0,0},{21,63,21},{63,21,21},{63,63,21}, - {0,0,0},{21,63,63},{63,21,63},{63,63,63}, - - {0,0,0},{0,0,42},{0,42,0},{0,42,42}, - {42,0,0},{42,0,42},{42,21,00},{42,42,42}, - {21,21,21},{21,21,63},{21,63,21},{21,63,63}, - {63,21,21},{63,21,63},{63,63,21},{63,63,63}, - - {0,0,0},{0,21,0},{0,0,42},{0,42,42}, - {42,0,21},{21,10,21},{42,0,42},{42,0,63}, - {21,21,21},{21,63,21},{42,21,42},{21,63,63}, - {63,0,0},{42,42,0},{63,21,42},{41,41,41}, - - {0,0,0},{0,42,42},{42,0,0},{42,42,42}, - {0,0,0},{0,42,42},{42,0,0},{42,42,42}, - {0,0,0},{0,63,63},{63,0,0},{63,63,63}, - {0,0,0},{0,63,63},{63,0,0},{63,63,63}, -}; - -PALETTE cgapal_mono[6] = { - { /* 0 - green, 4-color-optimized contrast. */ - {0x00,0x00,0x00},{0x00,0x0d,0x03},{0x01,0x17,0x05}, - {0x01,0x1a,0x06},{0x02,0x28,0x09},{0x02,0x2c,0x0a}, - {0x03,0x39,0x0d},{0x03,0x3c,0x0e},{0x00,0x07,0x01}, - {0x01,0x13,0x04},{0x01,0x1f,0x07},{0x01,0x23,0x08}, - {0x02,0x31,0x0b},{0x02,0x35,0x0c},{0x05,0x3f,0x11},{0x0d,0x3f,0x17}, - }, - { /* 1 - green, 16-color-optimized contrast. */ - {0x00,0x00,0x00},{0x00,0x0d,0x03},{0x01,0x15,0x05}, - {0x01,0x17,0x05},{0x01,0x21,0x08},{0x01,0x24,0x08}, - {0x02,0x2e,0x0b},{0x02,0x31,0x0b},{0x01,0x22,0x08}, - {0x02,0x28,0x09},{0x02,0x30,0x0b},{0x02,0x32,0x0c}, - {0x03,0x39,0x0d},{0x03,0x3b,0x0e},{0x09,0x3f,0x14},{0x0d,0x3f,0x17}, - }, - { /* 2 - amber, 4-color-optimized contrast. */ - {0x00,0x00,0x00},{0x15,0x05,0x00},{0x20,0x0b,0x00}, - {0x24,0x0d,0x00},{0x33,0x18,0x00},{0x37,0x1b,0x00}, - {0x3f,0x26,0x01},{0x3f,0x2b,0x06},{0x0b,0x02,0x00}, - {0x1b,0x08,0x00},{0x29,0x11,0x00},{0x2e,0x14,0x00}, - {0x3b,0x1e,0x00},{0x3e,0x21,0x00},{0x3f,0x32,0x0a},{0x3f,0x38,0x0d}, - }, - { /* 3 - amber, 16-color-optimized contrast. */ - {0x00,0x00,0x00},{0x15,0x05,0x00},{0x1e,0x09,0x00}, - {0x21,0x0b,0x00},{0x2b,0x12,0x00},{0x2f,0x15,0x00}, - {0x38,0x1c,0x00},{0x3b,0x1e,0x00},{0x2c,0x13,0x00}, - {0x32,0x17,0x00},{0x3a,0x1e,0x00},{0x3c,0x1f,0x00}, - {0x3f,0x27,0x01},{0x3f,0x2a,0x04},{0x3f,0x36,0x0c},{0x3f,0x38,0x0d}, - }, - { /* 4 - grey, 4-color-optimized contrast. */ - {0x00,0x00,0x00},{0x0e,0x0f,0x10},{0x15,0x17,0x18}, - {0x18,0x1a,0x1b},{0x24,0x25,0x25},{0x27,0x28,0x28}, - {0x33,0x34,0x32},{0x37,0x38,0x35},{0x09,0x0a,0x0b}, - {0x11,0x12,0x13},{0x1c,0x1e,0x1e},{0x20,0x22,0x22}, - {0x2c,0x2d,0x2c},{0x2f,0x30,0x2f},{0x3c,0x3c,0x38},{0x3f,0x3f,0x3b}, - }, - { /* 5 - grey, 16-color-optimized contrast. */ - {0x00,0x00,0x00},{0x0e,0x0f,0x10},{0x13,0x14,0x15}, - {0x15,0x17,0x18},{0x1e,0x20,0x20},{0x20,0x22,0x22}, - {0x29,0x2a,0x2a},{0x2c,0x2d,0x2c},{0x1f,0x21,0x21}, - {0x23,0x25,0x25},{0x2b,0x2c,0x2b},{0x2d,0x2e,0x2d}, - {0x34,0x35,0x33},{0x37,0x37,0x34},{0x3e,0x3e,0x3a},{0x3f,0x3f,0x3b}, - } -}; - -uint32_t pal_lookup[256]; - static CUSTOMVERTEX d3d_verts[] = { { 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f}, @@ -145,43 +78,6 @@ static CUSTOMVERTEX d3d_verts[] = }; -void cgapal_rebuild(void) -{ - int c; - for (c = 0; c < 256; c++) - { - pal_lookup[c] = makecol(video_6to8[cgapal[c].r], video_6to8[cgapal[c].g], video_6to8[cgapal[c].b]); - } - if ((cga_palette > 1) && (cga_palette < 8)) - { - if (vid_cga_contrast != 0) - { - for (c = 0; c < 16; c++) - { - pal_lookup[c] = makecol(video_6to8[cgapal_mono[cga_palette - 2][c].r], video_6to8[cgapal_mono[cga_palette - 2][c].g], video_6to8[cgapal_mono[cga_palette - 2][c].b]); - pal_lookup[c + 16] = makecol(video_6to8[cgapal_mono[cga_palette - 2][c].r], video_6to8[cgapal_mono[cga_palette - 2][c].g], video_6to8[cgapal_mono[cga_palette - 2][c].b]); - pal_lookup[c + 32] = makecol(video_6to8[cgapal_mono[cga_palette - 2][c].r], video_6to8[cgapal_mono[cga_palette - 2][c].g], video_6to8[cgapal_mono[cga_palette - 2][c].b]); - pal_lookup[c + 48] = makecol(video_6to8[cgapal_mono[cga_palette - 2][c].r], video_6to8[cgapal_mono[cga_palette - 2][c].g], video_6to8[cgapal_mono[cga_palette - 2][c].b]); - } - } - else - { - for (c = 0; c < 16; c++) - { - pal_lookup[c] = makecol(video_6to8[cgapal_mono[cga_palette - 1][c].r], video_6to8[cgapal_mono[cga_palette - 1][c].g], video_6to8[cgapal_mono[cga_palette - 1][c].b]); - pal_lookup[c + 16] = makecol(video_6to8[cgapal_mono[cga_palette - 1][c].r], video_6to8[cgapal_mono[cga_palette - 1][c].g], video_6to8[cgapal_mono[cga_palette - 1][c].b]); - pal_lookup[c + 32] = makecol(video_6to8[cgapal_mono[cga_palette - 1][c].r], video_6to8[cgapal_mono[cga_palette - 1][c].g], video_6to8[cgapal_mono[cga_palette - 1][c].b]); - pal_lookup[c + 48] = makecol(video_6to8[cgapal_mono[cga_palette - 1][c].r], video_6to8[cgapal_mono[cga_palette - 1][c].g], video_6to8[cgapal_mono[cga_palette - 1][c].b]); - } - } - } - - if (cga_palette == 8) - { - pal_lookup[0x16] = makecol(video_6to8[42], video_6to8[42], video_6to8[0]); - } -} - int d3d_fs_init(HWND h) { int c; @@ -190,11 +86,10 @@ int d3d_fs_init(HWND h) d3d_fs_w = GetSystemMetrics(SM_CXSCREEN); d3d_fs_h = GetSystemMetrics(SM_CYSCREEN); + d3d_hwnd = h; for (c = 0; c < 256; c++) pal_lookup[c] = makecol(cgapal[c].r << 2, cgapal[c].g << 2, cgapal[c].b << 2); - d3d_hwnd = h; - /*FIXME: should be done once, in win.c */ _swprintf(emulator_title, L"%s v%s", EMU_NAME_W, EMU_VERSION_W); d3d_device_window = CreateWindowEx ( @@ -234,9 +129,13 @@ int d3d_fs_init(HWND h) fatal("CreateDevice failed\n"); d3d_fs_init_objects(); - + +#if 0 + video_setblit(d3d_fs_blit_memtoscreen_8, d3d_fs_blit_memtoscreen); +#else video_blit_memtoscreen_func = d3d_fs_blit_memtoscreen; video_blit_memtoscreen_8_func = d3d_fs_blit_memtoscreen_8; +#endif return 1; } diff --git a/src/win/win_ddraw.cc b/src/win/win_ddraw.cc index 1cda4e892..f1bada1e8 100644 --- a/src/win/win_ddraw.cc +++ b/src/win/win_ddraw.cc @@ -11,7 +11,6 @@ #include "../plat.h" #include "../ui.h" #include "win_ddraw.h" -#include "win_cgapal.h" #include "win.h" @@ -22,6 +21,7 @@ extern "C" void device_force_redraw(void); extern "C" int ddraw_init(HWND h); extern "C" void ddraw_close(void); +extern "C" void ddraw_take_screenshot(wchar_t *fn); extern "C" void video_blit_complete(void); @@ -365,8 +365,13 @@ ddraw_init(HWND h) if (FAILED(lpdds_pri->SetClipper(lpdd_clipper))) return(0); ddraw_hwnd = h; + +#if 0 + video_setblit(ddraw_blit_memtoscreen_8, ddraw_blit_memtoscreen); +#else video_blit_memtoscreen_func = ddraw_blit_memtoscreen; video_blit_memtoscreen_8_func = ddraw_blit_memtoscreen_8; +#endif return(1); } diff --git a/src/win/win_ddraw.h b/src/win/win_ddraw.h index 93041ff88..921300739 100644 --- a/src/win/win_ddraw.h +++ b/src/win/win_ddraw.h @@ -19,6 +19,7 @@ extern void ddraw_take_screenshot(wchar_t *fn); extern int ddraw_fs_init(HWND h); extern void ddraw_fs_close(void); +extern void ddraw_fs_take_screenshot(wchar_t *fn); #ifdef __cplusplus } diff --git a/src/win/win_ddraw_fs.cc b/src/win/win_ddraw_fs.cc index 9687e21b5..777fa4f3a 100644 --- a/src/win/win_ddraw_fs.cc +++ b/src/win/win_ddraw_fs.cc @@ -4,7 +4,6 @@ #include #include "../video/video.h" #include "win_ddraw.h" -#include "win_cgapal.h" static LPDIRECTDRAW lpdd = NULL; @@ -25,6 +24,7 @@ extern "C" void device_force_redraw(void); extern "C" int ddraw_fs_init(HWND h); extern "C" void ddraw_fs_close(void); +extern "C" void ddraw_fs_take_screenshot(wchar_t *fn); extern void ddraw_common_take_screenshot(wchar_t *fn, IDirectDrawSurface7 *pDDSurface); @@ -92,8 +92,12 @@ int ddraw_fs_init(HWND h) pclog("DDRAW_INIT complete\n"); ddraw_hwnd = h; +#if 0 + video_setblit(ddraw_fs_blit_memtoscreen_8, ddraw_fs_blit_memtoscreen); +#else video_blit_memtoscreen_func = ddraw_fs_blit_memtoscreen; video_blit_memtoscreen_8_func = ddraw_fs_blit_memtoscreen_8; +#endif return 1; } diff --git a/src/win/win_deviceconfig.c b/src/win/win_deviceconfig.c index df7c6d36b..531a2867d 100644 --- a/src/win/win_deviceconfig.c +++ b/src/win/win_deviceconfig.c @@ -8,7 +8,7 @@ * * Windows device configuration dialog implementation. * - * Version: @(#)win_deviceconfig.c 1.0.5 2017/10/09 + * Version: @(#)win_deviceconfig.c 1.0.7 2017/10/10 * * Authors: Sarah Walker, * Miran Grca, @@ -24,8 +24,8 @@ #include "../config.h" #include "../device.h" #include "../plat.h" +#include "../plat_midi.h" #include "../ui.h" -#include "plat_midi.h" #include "win.h" #include diff --git a/src/win/win_dynld.c b/src/win/win_dynld.c index e6b5571ef..fd1553a38 100644 --- a/src/win/win_dynld.c +++ b/src/win/win_dynld.c @@ -8,9 +8,10 @@ * * Try to load a support DLL. * - * Version: @(#)win_dynld.c 1.0.3 2017/09/24 + * Version: @(#)win_dynld.c 1.0.4 2017/10/10 * * Author: Fred N. van Kempen, + * * Copyright 2017 Fred N. van Kempen */ #include @@ -20,8 +21,8 @@ #include #include #include -#include "plat_dynld.h" #include "../ibm.h" +#include "../plat_dynld.h" void * diff --git a/src/win/win_joystick.cc b/src/win/win_joystick.cc index 469da1b4a..d34fe68cb 100644 --- a/src/win/win_joystick.cc +++ b/src/win/win_joystick.cc @@ -8,10 +8,11 @@ * * Joystick interface to host device. * - * Version: @(#)win_joystick.cc 1.0.2 2017/10/01 + * Version: @(#)win_joystick.cc 1.0.3 2017/10/10 * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ @@ -23,7 +24,8 @@ extern "C" { #include "../device.h" #include "../game/gameport.h" } -#include "plat_joystick.h" +#include "../plat.h" +#include "../plat_joystick.h" #include "win.h" extern "C" int video_fullscreen; diff --git a/src/win/win_joystickconfig.c b/src/win/win_joystickconfig.c index eb8b7f152..28c300629 100644 --- a/src/win/win_joystickconfig.c +++ b/src/win/win_joystickconfig.c @@ -13,7 +13,8 @@ #include "../config.h" #include "../device.h" #include "../game/gameport.h" -#include "plat_joystick.h" +#include "../plat.h" +#include "../plat_joystick.h" #include "win.h" diff --git a/src/win/win_keyboard.c b/src/win/win_keyboard.c index 4bf2203d6..75bc80e6a 100644 --- a/src/win/win_keyboard.c +++ b/src/win/win_keyboard.c @@ -8,28 +8,27 @@ * * Windows raw keyboard input handler. * - * Version: @(#)win_d3d.cc 1.0.1 2017/09/24 + * Version: @(#)win_keyboard.c 1.0.2 2017/10/10 * * Author: Miran Grca, + * * Copyright 2016-2017 Miran Grca. */ - #define UNICODE #define _WIN32_WINNT 0x0501 #define BITMAP WINDOWS_BITMAP #include #include #undef BITMAP -#include -#include -#include -#include -#include -#include -#include +//#include +//#include #include +#include +#include +#include #include "../device.h" -#include "plat_keyboard.h" +#include "../plat.h" +#include "../plat_keyboard.h" #include "win.h" diff --git a/src/win/win_midi.c b/src/win/win_midi.c index a01d0cd9d..0d49bf81e 100644 --- a/src/win/win_midi.c +++ b/src/win/win_midi.c @@ -7,13 +7,14 @@ #include "../ibm.h" #include "../config.h" #include "../sound/midi.h" -#include "plat_midi.h" +#include "../plat.h" +#include "../plat_midi.h" + int midi_id = 0; -static HMIDIOUT midi_out_device = NULL; - HANDLE m_event; +static HMIDIOUT midi_out_device = NULL; static uint8_t midi_rt_buf[1024]; static uint8_t midi_cmd_buf[1024]; static int midi_cmd_pos = 0; diff --git a/src/win/win_mouse.cc b/src/win/win_mouse.cc index 574b301dc..5b23e421d 100644 --- a/src/win/win_mouse.cc +++ b/src/win/win_mouse.cc @@ -8,17 +8,19 @@ * * Mouse interface to host device. * - * Version: @(#)win_mouse.cc 1.0.2 2017/09/24 + * Version: @(#)win_mouse.cc 1.0.3 2017/10/10 * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ #define DIRECTINPUT_VERSION 0x0800 #include #include -#include "plat_mouse.h" +#include "../plat.h" +#include "../plat_mouse.h" #include "win.h" diff --git a/src/win/win_opendir.c b/src/win/win_opendir.c index 941a07a9c..ba8430a86 100644 --- a/src/win/win_opendir.c +++ b/src/win/win_opendir.c @@ -10,9 +10,10 @@ * * Based on old original code @(#)dir_win32.c 1.2.0 2007/04/19 * - * Version: @(#)win_opendir.c 1.0.2 2017/09/24 + * Version: @(#)win_opendir.c 1.0.3 2017/10/10 * * Author: Fred N. van Kempen, + * * Copyright 1998-2007 MicroWalt Corporation * Copyright 2017 Fred N. van Kempen */ @@ -25,7 +26,8 @@ #include #include #include "../ibm.h" -#include "plat_dir.h" +#include "../plat.h" +#include "../plat_dir.h" #ifdef UNICODE diff --git a/src/win/win_serial.c b/src/win/win_serial.c index a5ab56f66..df5823171 100644 --- a/src/win/win_serial.c +++ b/src/win/win_serial.c @@ -12,21 +12,20 @@ * Windows and UNIX systems, with support for FTDI and Prolific * USB ports. Support for these has been removed. * - * Version: @(#)win_serial.c 1.0.4 2017/09/12 + * Version: @(#)win_serial.c 1.0.6 2017/10/10 * * Author: Fred N. van Kempen, + * * Copyright 2017 Fred N. van Kempen. */ #include #include #include #include -#include "plat_thread.h" -#define BHTTY_C -#include "plat_serial.h" - - -extern void pclog(char *__fmt, ...); +#define PLAT_SERIAL_C +#include "../ibm.h" +#include "../plat.h" +#include "../plat_serial.h" /* Handle the receiving of data from the host port. */ @@ -324,10 +323,10 @@ int bhtty_flush(BHTTY *pp) { DWORD dwErrs; - COMSTAT cs; + COMSTAT cst; /* First, clear any errors. */ - (void)ClearCommError(pp->handle, &dwErrs, &cs); + (void)ClearCommError(pp->handle, &dwErrs, &cst); /* Now flush all buffers. */ if (PurgeComm(pp->handle, @@ -338,7 +337,7 @@ bhtty_flush(BHTTY *pp) } /* Re-clear any errors. */ - if (ClearCommError(pp->handle, &dwErrs, &cs) == FALSE) { + if (ClearCommError(pp->handle, &dwErrs, &cst) == FALSE) { pclog("%s: clear errors: %d\n", pp->name, GetLastError()); return(-1); } diff --git a/src/win/win_settings.c b/src/win/win_settings.c index e421d9bbd..11dcaf072 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -51,8 +51,8 @@ #include "../video/video.h" #include "../video/vid_voodoo.h" #include "../plat.h" +#include "../plat_midi.h" #include "../ui.h" -#include "plat_midi.h" #include "win.h" diff --git a/src/win/win_thread.c b/src/win/win_thread.c index 14610c8fd..4a62fc393 100644 --- a/src/win/win_thread.c +++ b/src/win/win_thread.c @@ -8,10 +8,11 @@ * * Implement threads and mutexes for the Win32 platform. * - * Version: @(#)win_thread.c 1.0.1 2017/10/05 + * Version: @(#)win_thread.c 1.0.2 2017/10/10 * * Authors: Sarah Walker, * Fred N. van Kempen, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2017 Fred N. van Kempen. */ @@ -27,7 +28,7 @@ #include #include #include "../ibm.h" -#include "plat_thread.h" +#include "../plat.h" typedef struct { diff --git a/src/win/win_video.c b/src/win/win_video.c deleted file mode 100644 index 3a50f7b9f..000000000 --- a/src/win/win_video.c +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -#include -#include -#include -#include "../video/video.h" -#include "win_cgapal.h" - - -BITMAP *screen; - - -void hline(BITMAP *b, int x1, int y, int x2, uint32_t col) -{ - if (y < 0 || y >= buffer->h) - return; - - if (b == buffer) - memset(&b->line[y][x1], col, x2 - x1); - else - memset(&((uint32_t *)b->line[y])[x1], col, (x2 - x1) * 4); -} - -void blit(BITMAP *src, BITMAP *dst, int x1, int y1, int x2, int y2, int xs, int ys) -{ -} - -void stretch_blit(BITMAP *src, BITMAP *dst, int x1, int y1, int xs1, int ys1, int x2, int y2, int xs2, int ys2) -{ -} - -void rectfill(BITMAP *b, int x1, int y1, int x2, int y2, uint32_t col) -{ -} - -void set_palette(PALETTE p) -{ -} - -void destroy_bitmap(BITMAP *b) -{ -} - -BITMAP *create_bitmap(int x, int y) -{ - BITMAP *b = malloc(sizeof(BITMAP) + (y * sizeof(uint8_t *))); - int c; - b->dat = malloc(x * y * 4); - for (c = 0; c < y; c++) - { - b->line[c] = b->dat + (c * x * 4); - } - b->w = x; - b->h = y; - return b; -}