Merge remote-tracking branch 'refs/remotes/OBattler/master'
This commit is contained in:
@@ -426,7 +426,6 @@ void loadseg(uint16_t seg, x86seg *s)
|
||||
if (s->base == 0 && s->limit_low == 0 && s->limit_high == 0xffffffff)
|
||||
cpu_cur_status |= CPU_STATUS_FLATDS;
|
||||
else
|
||||
|
||||
cpu_cur_status &= ~CPU_STATUS_FLATDS;
|
||||
}
|
||||
if (s == &_ss)
|
||||
@@ -625,6 +624,7 @@ void loadcsjmp(uint16_t seg, uint32_t oxpc)
|
||||
{
|
||||
if (!(segdat[2]&0x8000))
|
||||
{
|
||||
x86np("Load CS JMP system selector not present\n", seg & 0xfffc);
|
||||
return;
|
||||
}
|
||||
type=segdat[2]&0xF00;
|
||||
@@ -637,14 +637,12 @@ void loadcsjmp(uint16_t seg, uint32_t oxpc)
|
||||
cgate32=(type&0x800);
|
||||
cgate16=!cgate32;
|
||||
oldcs=CS;
|
||||
cpu_state.oldpc=cpu_state.pc;
|
||||
#if 0
|
||||
cpu_state.oldpc = cpu_state.pc;
|
||||
if ((DPL < CPL) || (DPL < (seg&3)))
|
||||
{
|
||||
x86gpf(NULL,seg&~3);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (DPL < CPL)
|
||||
{
|
||||
x86gpf("loadcsjmp(): ex DPL < CPL",seg&~3);
|
||||
@@ -939,7 +937,7 @@ void loadcscall(uint16_t seg)
|
||||
cgate16=!cgate32;
|
||||
oldcs=CS;
|
||||
count=segdat[2]&31;
|
||||
if ((DPL < CPL))
|
||||
if (DPL < CPL)
|
||||
{
|
||||
x86gpf("loadcscall(): ex DPL < CPL",seg&~3);
|
||||
return;
|
||||
|
||||
@@ -131,6 +131,15 @@ PLATCG = codegen_x86.o
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(WALTJE), y)
|
||||
SERIAL = serial.o
|
||||
WSERIAL = win_serial.o
|
||||
WFLAGS = -DWALTJE
|
||||
else
|
||||
SERIAL = serial_old.o
|
||||
endif
|
||||
|
||||
|
||||
MAINOBJ = pc.o config.o device.o timer.o dma.o io.o nmi.o pic.o \
|
||||
mca.o mcr.o pit.o ppi.o pci.o sio.o intel.o rom.o mem.o \
|
||||
memregs.o intel_flash.o rtc.o nvr.o ps2_nvr.o
|
||||
@@ -153,7 +162,7 @@ SYSOBJ = model.o \
|
||||
compaq.o laserxt.o jim.o \
|
||||
olivetti_m24.o ps1.o ps2.o ps2_mca.o \
|
||||
tandy_eeprom.o tandy_rom.o
|
||||
DEVOBJ = bugger.o lpt.o serial.o \
|
||||
DEVOBJ = bugger.o lpt.o $(SERIAL) \
|
||||
fdc37c665.o fdc37c669.o fdc37c932fr.o \
|
||||
pc87306.o sis85c471.o w83877f.o \
|
||||
keyboard.o \
|
||||
@@ -233,7 +242,7 @@ WINOBJ = win.o \
|
||||
win_ddraw.o win_ddraw_fs.o win_ddraw_screenshot.o \
|
||||
win_d3d.o win_d3d_fs.o \
|
||||
win_language.o win_status.o win_opendir.o win_dynld.o \
|
||||
win_video.o win_serial.o win_keyboard.o win_mouse.o \
|
||||
win_video.o $(WSERIAL) win_keyboard.o win_mouse.o \
|
||||
win_iodev.o win_joystick.o win_midi.o \
|
||||
win_settings.o win_deviceconfig.o win_joystickconfig.o \
|
||||
86Box.res
|
||||
@@ -252,15 +261,15 @@ LIBS = -mwindows \
|
||||
# Build rules.
|
||||
%.o: %.c
|
||||
@echo $<
|
||||
@$(CC) $(CFLAGS) -c $<
|
||||
@$(CC) $(CFLAGS) $(WFLAGS) -c $<
|
||||
|
||||
%.o: %.cc
|
||||
@echo $<
|
||||
@$(CPP) $(CFLAGS) -c $<
|
||||
@$(CPP) $(CFLAGS) $(WFLAGS) -c $<
|
||||
|
||||
%.o: %.cpp
|
||||
@echo $<
|
||||
@$(CPP) $(CFLAGS) -c $<
|
||||
@$(CPP) $(CFLAGS) $(WFLAGS) -c $<
|
||||
|
||||
all: $(PROG).exe pcap_if.exe
|
||||
|
||||
|
||||
@@ -591,6 +591,8 @@ void ega_poll(void *p)
|
||||
if (ega->sc == (ega->crtc[9] & 31))
|
||||
{
|
||||
ega->sc = 0;
|
||||
if (ega->sc == (ega->crtc[11] & 31))
|
||||
ega->con = 0;
|
||||
|
||||
ega->maback += (ega->rowoffset << 3);
|
||||
ega->maback &= ega->vrammask;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "../ibm.h"
|
||||
#include "../mem.h"
|
||||
#include "video.h"
|
||||
@@ -25,21 +26,69 @@
|
||||
|
||||
|
||||
int invert_display = 0;
|
||||
|
||||
int video_grayscale = 0;
|
||||
|
||||
uint32_t svga_color_transform(uint32_t color)
|
||||
{
|
||||
uint32_t temp = 0;
|
||||
temp = color;
|
||||
if (video_grayscale != 0)
|
||||
{
|
||||
temp = ((77 * (color & 0xff0000)) >> 24) + ((150 * (color & 0xff00)) >> 16) + ((29 * (color & 0xff)) >> 8);
|
||||
if (temp > 0xff)
|
||||
temp = 0xff;
|
||||
|
||||
float temp_r = 0;
|
||||
float temp_g = 0;
|
||||
float temp_b = 0;
|
||||
temp_r = temp_g = temp_b = ((float)temp) / 256;
|
||||
switch (video_grayscale)
|
||||
{
|
||||
case 2:
|
||||
temp_r = pow(temp_r, 0.6);
|
||||
temp_g = 0.9 * pow(temp_g, 2);
|
||||
temp_b = 0.2 * pow(temp_b, 6);
|
||||
break;
|
||||
case 3:
|
||||
temp_r = 0.225 * pow(temp_r, 4);
|
||||
temp_g = pow(temp_g, 0.75);
|
||||
temp_b = 0.375 * pow(temp_b, 2);
|
||||
break;
|
||||
case 4:
|
||||
temp_r = pow(temp_r, 1.05);
|
||||
temp_g = 0.99 * temp_g;
|
||||
temp_b = 0.925 * pow(temp_b, 0.9);
|
||||
break;
|
||||
}
|
||||
if (temp_r >= 1)
|
||||
temp = 0xff0000;
|
||||
else if (temp_r <= 0)
|
||||
temp = 0x000000;
|
||||
else
|
||||
temp = (int)(temp_r * 256) << 16;
|
||||
|
||||
if (temp_g >= 1)
|
||||
temp |= 0x00ff00;
|
||||
else if (temp_g <= 0)
|
||||
temp &= 0xff00ff;
|
||||
else
|
||||
temp = temp + ((int)(temp_g * 256) << 8);
|
||||
|
||||
if (temp_b >= 1)
|
||||
temp |= 0x0000ff;
|
||||
else if (temp_b <= 0)
|
||||
temp &= 0xffff00;
|
||||
else
|
||||
temp = temp + (int)(temp_b * 256);
|
||||
|
||||
color = temp;
|
||||
}
|
||||
if (invert_display)
|
||||
{
|
||||
temp |= (0xff - (color & 0xff));
|
||||
temp = (0xff - (color & 0xff));
|
||||
temp |= (0xff00 - (color & 0xff00));
|
||||
temp |= (0xff0000 - (color & 0xff0000));
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = color;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
@@ -643,6 +643,8 @@ void video_wait_for_buffer()
|
||||
|
||||
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;
|
||||
@@ -658,6 +660,8 @@ 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)
|
||||
{
|
||||
if (h <= 0)
|
||||
return;
|
||||
video_wait_for_blit();
|
||||
blit_data.busy = 1;
|
||||
blit_data.x = x;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* 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
|
||||
@@ -46,7 +46,7 @@ BEGIN
|
||||
BEGIN
|
||||
MENUITEM "&Hard Reset", IDM_ACTION_HRESET
|
||||
MENUITEM "&Ctrl+Alt+Del\tCtrl+F12", IDM_ACTION_RESET_CAD
|
||||
MENUITEM "&Ctrl+Alt+Esc", IDM_ACTION_CTRL_ALT_ESC
|
||||
MENUITEM "Ctrl+Alt+&Esc", IDM_ACTION_CTRL_ALT_ESC
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", IDM_ACTION_EXIT
|
||||
END
|
||||
@@ -81,6 +81,14 @@ BEGIN
|
||||
BEGIN
|
||||
MENUITEM "&Inverted VGA monitor", IDM_VID_INVERT
|
||||
MENUITEM "E&GA/(S)VGA overscan", IDM_VID_OVERSCAN
|
||||
POPUP "VGA Screen &type"
|
||||
BEGIN
|
||||
MENUITEM "RGB &Color", IDM_VID_GRAY_RGB
|
||||
MENUITEM "&RGB Grayscale", IDM_VID_GRAY_MONO
|
||||
MENUITEM "&Amber monitor", IDM_VID_GRAY_AMBER
|
||||
MENUITEM "&Green monitor", IDM_VID_GRAY_GREEN
|
||||
MENUITEM "&White monitor", IDM_VID_GRAY_WHITE
|
||||
END
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "F&orce 4:3 display ratio", IDM_VID_FORCE43
|
||||
@@ -248,7 +256,7 @@ BEGIN
|
||||
LTEXT "MB",IDT_1705,123,64,10,10
|
||||
LTEXT "Memory:",IDT_1706,7,64,30,10
|
||||
LTEXT "NVR Path:",IDT_1700,7,83,60,10
|
||||
EDITTEXT IDC_EDIT_NVR_PATH,71,82,138,12
|
||||
EDITTEXT IDC_EDIT_NVR_PATH,71,82,138,12,ES_AUTOHSCROLL
|
||||
PUSHBUTTON "&Specify...",IDC_BUTTON_NVR_PATH,214,82,46,12
|
||||
CONTROL "Dynamic Recompiler",IDC_CHECK_DYNAREC,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,7,100,94,10
|
||||
@@ -279,7 +287,7 @@ STYLE DS_CONTROL | WS_CHILD
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
LTEXT "Mouse :",IDT_1709,7,8,57,10
|
||||
COMBOBOX IDC_COMBO_MOUSE,71,7,189,120,CBS_DROPDOWN | WS_VSCROLL |
|
||||
COMBOBOX IDC_COMBO_MOUSE,71,7,189,120,CBS_DROPDOWNLIST | WS_VSCROLL |
|
||||
WS_TABSTOP
|
||||
LTEXT "Joystick :",IDT_1710,7,26,58,10
|
||||
COMBOBOX IDC_COMBO_JOYSTICK,71,25,189,120,CBS_DROPDOWNLIST |
|
||||
@@ -917,7 +925,7 @@ BEGIN
|
||||
VALUE "FileDescription", "86Box - an emulator for X86-based systems\0"
|
||||
VALUE "FileVersion", "2.00\0"
|
||||
VALUE "InternalName", "86Box\0"
|
||||
VALUE "LegalCopyright", "Copyright <20> SoftHistory, Sarah Walker, 2007-2017, Released under the GNU GPL v2\0"
|
||||
VALUE "LegalCopyright", "Copyright <20> SoftHistory, Sarah Walker, 2007-2017, Released under the GNU GPL v2\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "86Box.exe\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
|
||||
@@ -410,6 +410,11 @@
|
||||
#define IDM_VID_OVERSCAN 40076
|
||||
#define IDM_VID_INVERT 40079
|
||||
#define IDM_VID_CGACON 40080
|
||||
#define IDM_VID_GRAY_RGB 40090
|
||||
#define IDM_VID_GRAY_MONO 40091
|
||||
#define IDM_VID_GRAY_AMBER 40092
|
||||
#define IDM_VID_GRAY_GREEN 40093
|
||||
#define IDM_VID_GRAY_WHITE 40094
|
||||
|
||||
#define IDM_LOG_BREAKPOINT 51201
|
||||
#define IDM_DUMP_VRAM 51202 // should be an Action
|
||||
|
||||
@@ -1532,6 +1532,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz
|
||||
CheckMenuItem(menu, IDM_VID_SCALE_1X + scale, MF_CHECKED);
|
||||
|
||||
CheckMenuItem(menu, IDM_VID_CGACON, vid_cga_contrast ? MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(menu, IDM_VID_GRAY_RGB + video_grayscale, MF_CHECKED);
|
||||
|
||||
d=romset;
|
||||
for (c=0;c<ROM_MAX;c++)
|
||||
@@ -1970,6 +1971,18 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||
saveconfig();
|
||||
break;
|
||||
|
||||
case IDM_VID_GRAY_RGB:
|
||||
case IDM_VID_GRAY_MONO:
|
||||
case IDM_VID_GRAY_AMBER:
|
||||
case IDM_VID_GRAY_GREEN:
|
||||
case IDM_VID_GRAY_WHITE:
|
||||
CheckMenuItem(hmenu, IDM_VID_GRAY_RGB + video_grayscale, MF_UNCHECKED);
|
||||
video_grayscale = LOWORD(wParam) - IDM_VID_GRAY_RGB;
|
||||
CheckMenuItem(hmenu, IDM_VID_GRAY_RGB + video_grayscale, MF_CHECKED);
|
||||
saveconfig();
|
||||
device_force_redraw();
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_LOG_TOGGLES
|
||||
#ifdef ENABLE_BUSLOGIC_LOG
|
||||
case IDM_LOG_BUSLOGIC:
|
||||
|
||||
11
src/config.c
11
src/config.c
@@ -804,7 +804,7 @@ static void loadconfig_general(void)
|
||||
}
|
||||
enable_overscan = !!config_get_int(cat, "enable_overscan", 0);
|
||||
vid_cga_contrast = !!config_get_int(cat, "vid_cga_contrast", 0);
|
||||
|
||||
video_grayscale = config_get_int(cat, "video_grayscale", 0);
|
||||
|
||||
window_remember = config_get_int(cat, "window_remember", 0);
|
||||
|
||||
@@ -1801,6 +1801,15 @@ static void saveconfig_general(void)
|
||||
config_set_int(cat, "vid_cga_contrast", vid_cga_contrast);
|
||||
}
|
||||
|
||||
if (video_grayscale == 0)
|
||||
{
|
||||
config_delete_var(cat, "video_grayscale");
|
||||
}
|
||||
else
|
||||
{
|
||||
config_set_int(cat, "video_grayscale", video_grayscale);
|
||||
}
|
||||
|
||||
|
||||
if (window_remember)
|
||||
{
|
||||
|
||||
@@ -204,7 +204,7 @@ void gameport_update_joystick_type()
|
||||
|
||||
void *gameport_init()
|
||||
{
|
||||
gameport_t *gameport;
|
||||
gameport_t *gameport = NULL;
|
||||
|
||||
if (joystick_type == 7)
|
||||
{
|
||||
|
||||
@@ -737,6 +737,7 @@ extern int serial_enabled[2];
|
||||
extern int lpt_enabled, bugger_enabled;
|
||||
|
||||
extern int invert_display;
|
||||
extern int video_grayscale;
|
||||
|
||||
uint32_t svga_color_transform(uint32_t color);
|
||||
|
||||
|
||||
12
src/mem.c
12
src/mem.c
@@ -97,8 +97,8 @@ int loadbios()
|
||||
FILE *f=NULL,*ff=NULL;
|
||||
int c;
|
||||
|
||||
loadfont(L"roms/graphics/mda/mda.rom", 0);
|
||||
loadfont(L"roms/graphics/wyse700/wy700.rom", 3);
|
||||
loadfont(L"roms/video/mda/mda.rom", 0);
|
||||
loadfont(L"roms/video/wyse700/wy700.rom", 3);
|
||||
|
||||
biosmask = 0xffff;
|
||||
|
||||
@@ -2179,7 +2179,12 @@ void mem_init()
|
||||
if (mem_size > 768)
|
||||
mem_mapping_add(&ram_mid_mapping, 0xc0000, 0x40000, mem_read_ram, mem_read_ramw, mem_read_raml, mem_write_ram, mem_write_ramw, mem_write_raml, ram + 0xc0000, MEM_MAPPING_INTERNAL, NULL);
|
||||
|
||||
mem_mapping_add(&romext_mapping, 0xc8000, 0x08000, mem_read_romext, mem_read_romextw, mem_read_romextl, NULL, NULL, NULL, romext, 0, NULL);
|
||||
if (romset == ROM_IBMPS1_2011)
|
||||
mem_mapping_add(&romext_mapping, 0xc8000, 0x08000, mem_read_romext, mem_read_romextw, mem_read_romextl, NULL, NULL, NULL, romext, 0, NULL);
|
||||
|
||||
mem_a20_key = 2;
|
||||
mem_a20_alt = 0;
|
||||
mem_a20_recalc();
|
||||
}
|
||||
|
||||
static void mem_remap_top(int max_size)
|
||||
@@ -2274,6 +2279,7 @@ void mem_resize()
|
||||
mem_mapping_add(&romext_mapping, 0xc8000, 0x08000, mem_read_romext, mem_read_romextw, mem_read_romextl, NULL, NULL, NULL, romext, 0, NULL);
|
||||
|
||||
mem_a20_key = 2;
|
||||
mem_a20_alt = 0;
|
||||
mem_a20_recalc();
|
||||
}
|
||||
|
||||
|
||||
@@ -415,7 +415,6 @@ void xt_laserxt_init(void)
|
||||
void at_init(void)
|
||||
{
|
||||
AT = 1;
|
||||
mem_a20_key = mem_a20_alt = 0;
|
||||
common_init();
|
||||
if (lpt_enabled)
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "mouse_serial.h"
|
||||
|
||||
|
||||
#ifdef WALTJE
|
||||
#define SERMOUSE_TYPE_MSYSTEMS 1 /* Mouse Systems */
|
||||
#define SERMOUSE_TYPE_MICROSOFT 2 /* Microsoft */
|
||||
#define SERMOUSE_TYPE_LOGITECH 3 /* Logitech */
|
||||
@@ -228,3 +229,195 @@ mouse_t mouse_serial_logitech = {
|
||||
sermouse_close,
|
||||
sermouse_poll
|
||||
};
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
typedef struct mouse_serial_t
|
||||
{
|
||||
int mousepos, mousedelay;
|
||||
int oldb;
|
||||
int type;
|
||||
SERIAL *serial;
|
||||
} mouse_serial_t;
|
||||
|
||||
uint8_t mouse_serial_poll(int x, int y, int z, int b, void *p)
|
||||
{
|
||||
mouse_serial_t *mouse = (mouse_serial_t *)p;
|
||||
SERIAL *serial = mouse->serial;
|
||||
uint8_t mousedat[4];
|
||||
|
||||
if (!(serial->ier & 1))
|
||||
return 0xff;
|
||||
if (!x && !y && b == mouse->oldb)
|
||||
return 0xff;
|
||||
|
||||
mouse->oldb = b;
|
||||
if (x>127) x=127;
|
||||
if (y>127) y=127;
|
||||
if (x<-128) x=-128;
|
||||
if (y<-128) y=-128;
|
||||
|
||||
/*Use Microsoft format*/
|
||||
mousedat[0]=0x40;
|
||||
mousedat[0]|=(((y>>6)&3)<<2);
|
||||
mousedat[0]|=((x>>6)&3);
|
||||
if (b&1) mousedat[0]|=0x20;
|
||||
if (b&2) mousedat[0]|=0x10;
|
||||
mousedat[1]=x&0x3F;
|
||||
mousedat[2]=y&0x3F;
|
||||
|
||||
if (!(serial->mctrl & 0x10))
|
||||
{
|
||||
serial_write_fifo(mouse->serial, mousedat[0]);
|
||||
serial_write_fifo(mouse->serial, mousedat[1]);
|
||||
serial_write_fifo(mouse->serial, mousedat[2]);
|
||||
if ((b&0x04) && mouse->type)
|
||||
{
|
||||
serial_write_fifo(mouse->serial, 0x20);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t mouse_serial_msystems_poll(int x, int y, int z, int b, void *p)
|
||||
{
|
||||
mouse_serial_t *mouse = (mouse_serial_t *)p;
|
||||
SERIAL *serial = mouse->serial;
|
||||
uint8_t mousedat[4];
|
||||
|
||||
if (!(serial->ier & 1))
|
||||
return 0xff;
|
||||
if (!x && !y && b == mouse->oldb)
|
||||
return 0xff;
|
||||
|
||||
y = -y;
|
||||
|
||||
mouse->oldb = b;
|
||||
if (x>127) x=127;
|
||||
if (y>127) y=127;
|
||||
if (x<-128) x=-128;
|
||||
if (y<-128) y=-128;
|
||||
|
||||
/*Use Mouse Systems format*/
|
||||
mousedat[0] = 0x80;
|
||||
mousedat[0] |= (b&0x01) ? 0x00 : 0x04; /* left button */
|
||||
mousedat[0] |= (b&0x02) ? 0x00 : 0x01; /* middle button */
|
||||
mousedat[0] |= (b&0x04) ? 0x00 : 0x02; /* right button */
|
||||
mousedat[1] = x;
|
||||
mousedat[2] = y;
|
||||
mousedat[3] = x; /* same as byte 1 */
|
||||
mousedat[4] = y; /* same as byte 2 */
|
||||
|
||||
if (!(serial->mctrl & 0x10))
|
||||
{
|
||||
serial_write_fifo(mouse->serial, mousedat[0]);
|
||||
serial_write_fifo(mouse->serial, mousedat[1]);
|
||||
serial_write_fifo(mouse->serial, mousedat[2]);
|
||||
serial_write_fifo(mouse->serial, mousedat[3]);
|
||||
serial_write_fifo(mouse->serial, mousedat[4]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mouse_serial_rcr(struct SERIAL *serial, void *p)
|
||||
{
|
||||
mouse_serial_t *mouse = (mouse_serial_t *)p;
|
||||
|
||||
mouse->mousepos = -1;
|
||||
mouse->mousedelay = 5000 * (1 << TIMER_SHIFT);
|
||||
}
|
||||
|
||||
void mousecallback(void *p)
|
||||
{
|
||||
mouse_serial_t *mouse = (mouse_serial_t *)p;
|
||||
|
||||
mouse->mousedelay = 0;
|
||||
if (mouse->mousepos == -1)
|
||||
{
|
||||
mouse->mousepos = 0;
|
||||
if (mouse->type < 2)
|
||||
{
|
||||
serial_write_fifo(mouse->serial, 'M');
|
||||
if (mouse->type == 1)
|
||||
{
|
||||
serial_write_fifo(mouse->serial, '3');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void *mouse_serial_common_init(int type)
|
||||
{
|
||||
mouse_serial_t *mouse = (mouse_serial_t *)malloc(sizeof(mouse_serial_t));
|
||||
memset(mouse, 0, sizeof(mouse_serial_t));
|
||||
|
||||
mouse->serial = &serial1;
|
||||
serial1.rcr_callback = mouse_serial_rcr;
|
||||
serial1.rcr_callback_p = mouse;
|
||||
timer_add(mousecallback, &mouse->mousedelay, &mouse->mousedelay, mouse);
|
||||
|
||||
mouse->type = type;
|
||||
|
||||
return mouse;
|
||||
}
|
||||
|
||||
void *mouse_serial_init()
|
||||
{
|
||||
return mouse_serial_common_init(0);
|
||||
}
|
||||
|
||||
void *mouse_serial_logitech_init()
|
||||
{
|
||||
return mouse_serial_common_init(1);
|
||||
}
|
||||
|
||||
void *mouse_serial_msystems_init()
|
||||
{
|
||||
return mouse_serial_common_init(2);
|
||||
}
|
||||
|
||||
void mouse_serial_close(void *p)
|
||||
{
|
||||
mouse_serial_t *mouse = (mouse_serial_t *)p;
|
||||
|
||||
free(mouse);
|
||||
|
||||
serial1.rcr_callback = NULL;
|
||||
}
|
||||
|
||||
mouse_t mouse_serial_microsoft =
|
||||
{
|
||||
"Microsoft 2-button mouse (serial)",
|
||||
"msserial",
|
||||
MOUSE_TYPE_SERIAL,
|
||||
mouse_serial_init,
|
||||
mouse_serial_close,
|
||||
mouse_serial_poll
|
||||
};
|
||||
|
||||
mouse_t mouse_serial_logitech =
|
||||
{
|
||||
"Logitech 3-button mouse (serial)",
|
||||
"lserial",
|
||||
MOUSE_TYPE_SERIAL | MOUSE_TYPE_3BUTTON,
|
||||
mouse_serial_logitech_init,
|
||||
mouse_serial_close,
|
||||
mouse_serial_poll
|
||||
};
|
||||
|
||||
mouse_t mouse_msystems =
|
||||
{
|
||||
"Mouse Systems Mouse (serial)",
|
||||
"mssystems",
|
||||
MOUSE_TYPE_MSYSTEMS,
|
||||
mouse_serial_msystems_init,
|
||||
mouse_serial_close,
|
||||
mouse_serial_msystems_poll
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
5
src/pc.c
5
src/pc.c
@@ -366,7 +366,9 @@ void initmodules(void)
|
||||
/* Initialize modules. */
|
||||
network_init();
|
||||
mouse_init();
|
||||
#ifdef WALTJE
|
||||
serial_init();
|
||||
#endif
|
||||
disc_random_init();
|
||||
|
||||
joystick_init();
|
||||
@@ -512,6 +514,9 @@ void resetpchard_init(void)
|
||||
fdc_init();
|
||||
disc_reset();
|
||||
|
||||
#ifndef WALTJE
|
||||
serial_init();
|
||||
#endif
|
||||
model_init();
|
||||
video_init();
|
||||
speaker_init();
|
||||
|
||||
44
src/serial.h
44
src/serial.h
@@ -17,6 +17,7 @@
|
||||
# define EMU_SERIAL_H
|
||||
|
||||
|
||||
#ifdef WALTJE
|
||||
/* Default settings for the standard ports. */
|
||||
#define SERIAL1_ADDR 0x03f8
|
||||
#define SERIAL1_IRQ 4
|
||||
@@ -72,4 +73,45 @@ extern int serial_link(int, char *);
|
||||
extern void serial_write_fifo(SERIAL *, uint8_t, int);
|
||||
|
||||
|
||||
#endif /*EMU_SERIAL_H*/
|
||||
#else
|
||||
|
||||
|
||||
void serial_remove(int port);
|
||||
void serial_setup(int port, uint16_t addr, int irq);
|
||||
void serial_init(void);
|
||||
void serial_reset();
|
||||
|
||||
struct SERIAL;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t lsr,thr,mctrl,rcr,iir,ier,lcr,msr;
|
||||
uint8_t dlab1,dlab2;
|
||||
uint8_t dat;
|
||||
uint8_t int_status;
|
||||
uint8_t scratch;
|
||||
uint8_t fcr;
|
||||
|
||||
int irq;
|
||||
|
||||
void (*rcr_callback)(struct SERIAL *serial, void *p);
|
||||
void *rcr_callback_p;
|
||||
uint8_t fifo[256];
|
||||
int fifo_read, fifo_write;
|
||||
|
||||
int recieve_delay;
|
||||
} SERIAL;
|
||||
|
||||
void serial_write_fifo(SERIAL *serial, uint8_t dat);
|
||||
|
||||
extern SERIAL serial1, serial2;
|
||||
|
||||
/* Default settings for the standard ports. */
|
||||
#define SERIAL1_ADDR 0x03f8
|
||||
#define SERIAL1_IRQ 4
|
||||
#define SERIAL2_ADDR 0x02f8
|
||||
#define SERIAL2_IRQ 3
|
||||
#endif
|
||||
|
||||
|
||||
#endif /*EMU_SERIAL_H*/
|
||||
341
src/serial_old.c
Normal file
341
src/serial_old.c
Normal file
@@ -0,0 +1,341 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ibm.h"
|
||||
#include "io.h"
|
||||
#include "mouse.h"
|
||||
#include "pic.h"
|
||||
#include "serial.h"
|
||||
#include "timer.h"
|
||||
|
||||
enum
|
||||
{
|
||||
SERIAL_INT_LSR = 1,
|
||||
SERIAL_INT_RECEIVE = 2,
|
||||
SERIAL_INT_TRANSMIT = 4,
|
||||
SERIAL_INT_MSR = 8
|
||||
};
|
||||
|
||||
SERIAL serial1, serial2;
|
||||
|
||||
|
||||
void serial_reset()
|
||||
{
|
||||
serial1.iir = serial1.ier = serial1.lcr = 0;
|
||||
serial2.iir = serial2.ier = serial2.lcr = 0;
|
||||
serial1.fifo_read = serial1.fifo_write = 0;
|
||||
serial2.fifo_read = serial2.fifo_write = 0;
|
||||
}
|
||||
|
||||
void serial_update_ints(SERIAL *serial)
|
||||
{
|
||||
int stat = 0;
|
||||
|
||||
serial->iir = 1;
|
||||
|
||||
if ((serial->ier & 4) && (serial->int_status & SERIAL_INT_LSR)) /*Line status interrupt*/
|
||||
{
|
||||
stat = 1;
|
||||
serial->iir = 6;
|
||||
}
|
||||
else if ((serial->ier & 1) && (serial->int_status & SERIAL_INT_RECEIVE)) /*Recieved data available*/
|
||||
{
|
||||
stat = 1;
|
||||
serial->iir = 4;
|
||||
}
|
||||
else if ((serial->ier & 2) && (serial->int_status & SERIAL_INT_TRANSMIT)) /*Transmit data empty*/
|
||||
{
|
||||
stat = 1;
|
||||
serial->iir = 2;
|
||||
}
|
||||
else if ((serial->ier & 8) && (serial->int_status & SERIAL_INT_MSR)) /*Modem status interrupt*/
|
||||
{
|
||||
stat = 1;
|
||||
serial->iir = 0;
|
||||
}
|
||||
|
||||
if (stat && ((serial->mctrl & 8) || PCJR))
|
||||
picintlevel(1 << serial->irq);
|
||||
else
|
||||
picintc(1 << serial->irq);
|
||||
}
|
||||
|
||||
void serial_write_fifo(SERIAL *serial, uint8_t dat)
|
||||
{
|
||||
serial->fifo[serial->fifo_write] = dat;
|
||||
serial->fifo_write = (serial->fifo_write + 1) & 0xFF;
|
||||
if (!(serial->lsr & 1))
|
||||
{
|
||||
serial->lsr |= 1;
|
||||
serial->int_status |= SERIAL_INT_RECEIVE;
|
||||
serial_update_ints(serial);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t serial_read_fifo(SERIAL *serial)
|
||||
{
|
||||
if (serial->fifo_read != serial->fifo_write)
|
||||
{
|
||||
serial->dat = serial->fifo[serial->fifo_read];
|
||||
serial->fifo_read = (serial->fifo_read + 1) & 0xFF;
|
||||
}
|
||||
return serial->dat;
|
||||
}
|
||||
|
||||
void serial_write(uint16_t addr, uint8_t val, void *p)
|
||||
{
|
||||
SERIAL *serial = (SERIAL *)p;
|
||||
switch (addr&7)
|
||||
{
|
||||
case 0:
|
||||
if (serial->lcr & 0x80)
|
||||
{
|
||||
serial->dlab1 = val;
|
||||
return;
|
||||
}
|
||||
serial->thr = val;
|
||||
serial->lsr |= 0x20;
|
||||
serial->int_status |= SERIAL_INT_TRANSMIT;
|
||||
serial_update_ints(serial);
|
||||
if (serial->mctrl & 0x10)
|
||||
{
|
||||
serial_write_fifo(serial, val);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (serial->lcr & 0x80)
|
||||
{
|
||||
serial->dlab2 = val;
|
||||
return;
|
||||
}
|
||||
serial->ier = val & 0xf;
|
||||
serial_update_ints(serial);
|
||||
break;
|
||||
case 2:
|
||||
serial->fcr = val;
|
||||
break;
|
||||
case 3:
|
||||
serial->lcr = val;
|
||||
break;
|
||||
case 4:
|
||||
if ((val & 2) && !(serial->mctrl & 2))
|
||||
{
|
||||
if (serial->rcr_callback)
|
||||
serial->rcr_callback((struct SERIAL *)serial, serial->rcr_callback_p);
|
||||
}
|
||||
serial->mctrl = val;
|
||||
if (val & 0x10)
|
||||
{
|
||||
uint8_t new_msr;
|
||||
|
||||
new_msr = (val & 0x0c) << 4;
|
||||
new_msr |= (val & 0x02) ? 0x10: 0;
|
||||
new_msr |= (val & 0x01) ? 0x20: 0;
|
||||
|
||||
if ((serial->msr ^ new_msr) & 0x10)
|
||||
new_msr |= 0x01;
|
||||
if ((serial->msr ^ new_msr) & 0x20)
|
||||
new_msr |= 0x02;
|
||||
if ((serial->msr ^ new_msr) & 0x80)
|
||||
new_msr |= 0x08;
|
||||
if ((serial->msr & 0x40) && !(new_msr & 0x40))
|
||||
new_msr |= 0x04;
|
||||
|
||||
serial->msr = new_msr;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
serial->lsr = val;
|
||||
if (serial->lsr & 0x01)
|
||||
serial->int_status |= SERIAL_INT_RECEIVE;
|
||||
if (serial->lsr & 0x1e)
|
||||
serial->int_status |= SERIAL_INT_LSR;
|
||||
if (serial->lsr & 0x20)
|
||||
serial->int_status |= SERIAL_INT_TRANSMIT;
|
||||
serial_update_ints(serial);
|
||||
break;
|
||||
case 6:
|
||||
serial->msr = val;
|
||||
if (serial->msr & 0x0f)
|
||||
serial->int_status |= SERIAL_INT_MSR;
|
||||
serial_update_ints(serial);
|
||||
break;
|
||||
case 7:
|
||||
serial->scratch = val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t serial_read(uint16_t addr, void *p)
|
||||
{
|
||||
SERIAL *serial = (SERIAL *)p;
|
||||
uint8_t temp = 0;
|
||||
switch (addr&7)
|
||||
{
|
||||
case 0:
|
||||
if (serial->lcr & 0x80)
|
||||
{
|
||||
temp = serial->dlab1;
|
||||
break;
|
||||
}
|
||||
|
||||
serial->lsr &= ~1;
|
||||
serial->int_status &= ~SERIAL_INT_RECEIVE;
|
||||
serial_update_ints(serial);
|
||||
temp = serial_read_fifo(serial);
|
||||
if (serial->fifo_read != serial->fifo_write)
|
||||
serial->recieve_delay = 1000 * TIMER_USEC;
|
||||
break;
|
||||
case 1:
|
||||
if (serial->lcr & 0x80)
|
||||
temp = serial->dlab2;
|
||||
else
|
||||
temp = serial->ier;
|
||||
break;
|
||||
case 2:
|
||||
temp = serial->iir;
|
||||
if ((temp & 0xe) == 2)
|
||||
{
|
||||
serial->int_status &= ~SERIAL_INT_TRANSMIT;
|
||||
serial_update_ints(serial);
|
||||
}
|
||||
if (serial->fcr & 1)
|
||||
temp |= 0xc0;
|
||||
break;
|
||||
case 3:
|
||||
temp = serial->lcr;
|
||||
break;
|
||||
case 4:
|
||||
temp = serial->mctrl;
|
||||
break;
|
||||
case 5:
|
||||
if (serial->lsr & 0x20)
|
||||
serial->lsr |= 0x40;
|
||||
serial->lsr |= 0x20;
|
||||
temp = serial->lsr;
|
||||
if (serial->lsr & 0x1f)
|
||||
serial->lsr &= ~0x1e;
|
||||
serial->int_status &= ~SERIAL_INT_LSR;
|
||||
serial_update_ints(serial);
|
||||
break;
|
||||
case 6:
|
||||
temp = serial->msr;
|
||||
serial->msr &= ~0x0f;
|
||||
serial->int_status &= ~SERIAL_INT_MSR;
|
||||
serial_update_ints(serial);
|
||||
break;
|
||||
case 7:
|
||||
temp = serial->scratch;
|
||||
break;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
void serial_recieve_callback(void *p)
|
||||
{
|
||||
SERIAL *serial = (SERIAL *)p;
|
||||
|
||||
serial->recieve_delay = 0;
|
||||
|
||||
if (serial->fifo_read != serial->fifo_write)
|
||||
{
|
||||
serial->lsr |= 1;
|
||||
serial->int_status |= SERIAL_INT_RECEIVE;
|
||||
serial_update_ints(serial);
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t base_address[2] = { 0x0000, 0x0000 };
|
||||
|
||||
void serial_remove(int port)
|
||||
{
|
||||
if ((port < 1) || (port > 2))
|
||||
{
|
||||
fatal("serial_remove(): Invalid serial port: %i\n", port);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (!serial_enabled[port - 1])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!base_address[port - 1])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pclog("Removing serial port %i at %04X...\n", port, base_address[port - 1]);
|
||||
|
||||
switch(port)
|
||||
{
|
||||
case 1:
|
||||
io_removehandler(base_address[0], 0x0008, serial_read, NULL, NULL, serial_write, NULL, NULL, &serial1);
|
||||
base_address[0] = 0x0000;
|
||||
break;
|
||||
case 2:
|
||||
io_removehandler(base_address[1], 0x0008, serial_read, NULL, NULL, serial_write, NULL, NULL, &serial2);
|
||||
base_address[1] = 0x0000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void serial_setup(int port, uint16_t addr, int irq)
|
||||
{
|
||||
pclog("Adding serial port %i at %04X...\n", port, addr);
|
||||
|
||||
switch(port)
|
||||
{
|
||||
case 1:
|
||||
if (base_address[0] != 0x0000)
|
||||
{
|
||||
serial_remove(port);
|
||||
}
|
||||
if (addr != 0x0000)
|
||||
{
|
||||
base_address[0] = addr;
|
||||
io_sethandler(addr, 0x0008, serial_read, NULL, NULL, serial_write, NULL, NULL, &serial1);
|
||||
}
|
||||
serial1.irq = irq;
|
||||
break;
|
||||
case 2:
|
||||
if (base_address[1] != 0x0000)
|
||||
{
|
||||
serial_remove(port);
|
||||
}
|
||||
if (addr != 0x0000)
|
||||
{
|
||||
base_address[1] = addr;
|
||||
io_sethandler(addr, 0x0008, serial_read, NULL, NULL, serial_write, NULL, NULL, &serial2);
|
||||
}
|
||||
serial2.irq = irq;
|
||||
break;
|
||||
default:
|
||||
fatal("serial_setup(): Invalid serial port: %i\n", port);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void serial_init(void)
|
||||
{
|
||||
base_address[0] = 0x03f8;
|
||||
base_address[1] = 0x02f8;
|
||||
|
||||
if (serial_enabled[0])
|
||||
{
|
||||
pclog("Adding serial port 1...\n");
|
||||
memset(&serial1, 0, sizeof(serial1));
|
||||
io_sethandler(0x3f8, 0x0008, serial_read, NULL, NULL, serial_write, NULL, NULL, &serial1);
|
||||
serial1.irq = 4;
|
||||
serial1.rcr_callback = NULL;
|
||||
timer_add(serial_recieve_callback, &serial1.recieve_delay, &serial1.recieve_delay, &serial1);
|
||||
}
|
||||
if (serial_enabled[1])
|
||||
{
|
||||
pclog("Adding serial port 2...\n");
|
||||
memset(&serial2, 0, sizeof(serial2));
|
||||
io_sethandler(0x2f8, 0x0008, serial_read, NULL, NULL, serial_write, NULL, NULL, &serial2);
|
||||
serial2.irq = 3;
|
||||
serial2.rcr_callback = NULL;
|
||||
timer_add(serial_recieve_callback, &serial2.recieve_delay, &serial2.recieve_delay, &serial2);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "sound_wss.h"*/
|
||||
#include "timer.h"
|
||||
|
||||
#define TIMERS_MAX 32
|
||||
#define TIMERS_MAX 64
|
||||
|
||||
int TIMER_USEC;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user