Applied all mainline commits; Moved all declarations to not be in the middle of code; SVGA linear reads and writes now account for linear base; Fixed a bug with the Compaq ATI 28800.

This commit is contained in:
OBattler
2016-08-01 19:14:54 +02:00
parent d50a7e9449
commit 114bbdfc6d
29 changed files with 305 additions and 171 deletions

View File

@@ -1144,15 +1144,19 @@ int xout=0;
int divl(uint32_t val)
{
uint64_t num;
uint64_t quo;
uint32_t rem;
uint32_t quo32;
if (val==0)
{
divexcp();
return 1;
}
uint64_t num=(((uint64_t)EDX)<<32)|EAX;
uint64_t quo=num/val;
uint32_t rem=num%val;
uint32_t quo32=(uint32_t)(quo&0xFFFFFFFF);
num=(((uint64_t)EDX)<<32)|EAX;
quo=num/val;
rem=num%val;
quo32=(uint32_t)(quo&0xFFFFFFFF);
if (quo!=(uint64_t)quo32)
{
divexcp();
@@ -1164,15 +1168,19 @@ int divl(uint32_t val)
}
int idivl(int32_t val)
{
int64_t num;
int64_t quo;
int32_t rem;
int32_t quo32;
if (val==0)
{
divexcp();
return 1;
}
int64_t num=(((uint64_t)EDX)<<32)|EAX;
int64_t quo=num/val;
int32_t rem=num%val;
int32_t quo32=(int32_t)(quo&0xFFFFFFFF);
num=(((uint64_t)EDX)<<32)|EAX;
quo=num/val;
rem=num%val;
quo32=(int32_t)(quo&0xFFFFFFFF);
if (quo!=(int64_t)quo32)
{
divexcp();

View File

@@ -329,6 +329,8 @@ void iso_reset()
int iso_open(char *fn)
{
struct stat st;
if (strcmp(fn, iso_path) != 0)
{
iso_changed = 1;
@@ -348,7 +350,6 @@ int iso_open(char *fn)
fclose(iso_image);
}
struct stat st;
stat(iso_path, &st);
image_size = st.st_size;

View File

@@ -284,6 +284,8 @@ void codegen_block_init(uint32_t phys_addr)
block->was_recompiled = 0;
recomp_page = block->phys & ~0xfff;
codeblock_tree_add(block);
}

View File

@@ -284,6 +284,8 @@ void codegen_block_init(uint32_t phys_addr)
block->was_recompiled = 0;
recomp_page = block->phys & ~0xfff;
codeblock_tree_add(block);
}

View File

@@ -156,12 +156,16 @@ int disc_byteperiod(int drive)
double disc_real_period()
{
int64_t dbp = disc_byteperiod(disc_drivesel ^ fdd_swap);
double ddbp = (double) dbp;
int64_t dbp;
double ddbp;
double dusec;
dbp = disc_byteperiod(disc_drivesel ^ fdd_swap);
ddbp = (double) dbp;
if (dbp == 26) ddbp = 160.0 / 6.0;
double dusec = (double) TIMER_USEC;
dusec = (double) TIMER_USEC;
return (ddbp * dusec);
}

View File

@@ -566,6 +566,8 @@ void img_seek(int drive, int track)
int current_xdft = img[drive].xdf_type - 1;
uint8_t sectors_fat, effective_sectors, sector_gap; /* Needed for XDF */
int sector, current_pos, sh, sr, spos, sside;
if (!img[drive].f)
return;
@@ -598,8 +600,6 @@ void img_seek(int drive, int track)
disc_sector_reset(drive, 0);
disc_sector_reset(drive, 1);
int sector, current_pos, sh, sr, spos, sside;
if (img[drive].xdf_type)
{
sectors_fat = xdf_track0[current_xdft][0];

View File

@@ -70,14 +70,22 @@ FILE *df;
void update_cga16_color(cga_t *cga) {
int x;
Bit32u x2;
double i0, i3, mode_saturation, c, i, v, r, g, b, q, a, s, iq_adjust_i, iq_adjust_q;
static const double ri = 0.9563;
static const double rq = 0.6210;
static const double gi = -0.2721;
static const double gq = -0.6474;
static const double bi = -1.1069;
static const double bq = 1.7046;
if (!new_cga) {
min_v = chroma_multiplexer[0] + intensity[0];
max_v = chroma_multiplexer[255] + intensity[3];
}
else {
double i0 = intensity[0];
double i3 = intensity[3];
i0 = intensity[0];
i3 = intensity[3];
min_v = NEW_CGA(chroma_multiplexer[0], i0, i0, i0, i0);
max_v = NEW_CGA(chroma_multiplexer[255], i3, i3, i3, i3);
}
@@ -90,7 +98,7 @@ void update_cga16_color(cga_t *cga) {
mode_contrast *= contrast * (new_cga ? 1.2 : 1)/100; // new CGA: 120%
mode_brightness += (new_cga ? brightness-10 : brightness)*5; // new CGA: -10
double mode_saturation = (new_cga ? 4.35 : 2.9)*saturation/100; // new CGA: 150%
mode_saturation = (new_cga ? 4.35 : 2.9)*saturation/100; // new CGA: 150%
for (x = 0; x < 1024; ++x) {
int phase = x & 3;
@@ -102,38 +110,29 @@ void update_cga16_color(cga_t *cga) {
rc = (right & 8) | ((right & 7) != 0 ? 7 : 0);
lc = (left & 8) | ((left & 7) != 0 ? 7 : 0);
}
double c =
chroma_multiplexer[((lc & 7) << 5) | ((rc & 7) << 2) | phase];
double i = intensity[(left >> 3) | ((right >> 2) & 2)];
double v;
c = chroma_multiplexer[((lc & 7) << 5) | ((rc & 7) << 2) | phase];
i = intensity[(left >> 3) | ((right >> 2) & 2)];
if (!new_cga)
v = c + i;
else {
double r = intensity[((left >> 2) & 1) | ((right >> 1) & 2)];
double g = intensity[((left >> 1) & 1) | (right & 2)];
double b = intensity[(left & 1) | ((right << 1) & 2)];
r = intensity[((left >> 2) & 1) | ((right >> 1) & 2)];
g = intensity[((left >> 1) & 1) | (right & 2)];
b = intensity[(left & 1) | ((right << 1) & 2)];
v = NEW_CGA(c, i, r, g, b);
}
CGA_Composite_Table[x] = (int) (v*mode_contrast + mode_brightness);
}
double i = CGA_Composite_Table[6*68] - CGA_Composite_Table[6*68 + 2];
double q = CGA_Composite_Table[6*68 + 1] - CGA_Composite_Table[6*68 + 3];
i = CGA_Composite_Table[6*68] - CGA_Composite_Table[6*68 + 2];
q = CGA_Composite_Table[6*68 + 1] - CGA_Composite_Table[6*68 + 3];
double a = tau*(33 + 90 + hue_offset + mode_hue)/360.0;
double c = cos(a);
double s = sin(a);
double r = 256*mode_saturation/sqrt(i*i+q*q);
a = tau*(33 + 90 + hue_offset + mode_hue)/360.0;
c = cos(a);
s = sin(a);
r = 256*mode_saturation/sqrt(i*i+q*q);
double iq_adjust_i = -(i*c + q*s)*r;
double iq_adjust_q = (q*c - i*s)*r;
static const double ri = 0.9563;
static const double rq = 0.6210;
static const double gi = -0.2721;
static const double gq = -0.6474;
static const double bi = -1.1069;
static const double bq = 1.7046;
iq_adjust_i = -(i*c + q*s)*r;
iq_adjust_q = (q*c - i*s)*r;
video_ri = (int) (ri*iq_adjust_i + rq*iq_adjust_q);
video_rq = (int) (-ri*iq_adjust_q + rq*iq_adjust_i);
@@ -186,6 +185,8 @@ Bit8u * Composite_Process(cga_t *cga, Bit8u border, Bit32u blocks/*, bool double
int* o = temp;
Bit8u* rgbi = TempLine;
int* b = &CGA_Composite_Table[border*68];
int *i, *ap, *bp;
Bit32u* srgb;
for (x = 0; x < 4; ++x)
OUT(b[(x+3)&3]);
OUT(CGA_Composite_Table[(border<<6) | ((*rgbi)<<2) | 3]);
@@ -199,8 +200,8 @@ Bit8u * Composite_Process(cga_t *cga, Bit8u border, Bit32u blocks/*, bool double
if ((cga->cgamode & 4) != 0) {
// Decode
int* i = temp + 5;
Bit32u* srgb = (Bit32u *)TempLine;
i = temp + 5;
srgb = (Bit32u *)TempLine;
for (x2 = 0; x2 < blocks*4; ++x2) {
int c = (i[0]+i[0])<<3;
int d = (i[-1]+i[1])<<3;
@@ -212,9 +213,9 @@ Bit8u * Composite_Process(cga_t *cga, Bit8u border, Bit32u blocks/*, bool double
}
else {
// Store chroma
int* i = temp + 4;
int* ap = atemp + 1;
int* bp = btemp + 1;
i = temp + 4;
ap = atemp + 1;
bp = btemp + 1;
for (x = -1; x < w + 1; ++x) {
ap[x] = i[-4]-((i[-2]-i[0]+i[2])<<1)+i[4];
bp[x] = (i[-3]-i[-1]+i[1]-i[3])<<1;
@@ -225,7 +226,7 @@ Bit8u * Composite_Process(cga_t *cga, Bit8u border, Bit32u blocks/*, bool double
i = temp + 5;
i[-1] = (i[-1]<<3) - ap[-1];
i[0] = (i[0]<<3) - ap[0];
Bit32u* srgb = (Bit32u *)TempLine;
srgb = (Bit32u *)TempLine;
for (x2 = 0; x2 < blocks; ++x2) {
int y,a,b,c,d,rr,gg,bb;
COMPOSITE_CONVERT(a, b);

View File

@@ -2129,6 +2129,10 @@ static void atapicommand(int ide_board)
int temp_command;
int alloc_length;
int completed;
uint8_t index = 0;
int media;
int format;
int ret;
#ifndef RPCEMU_IDE
pclog("New ATAPI command %02X %i\n",idebufferb[0],ins);
@@ -2529,7 +2533,7 @@ static void atapicommand(int ide_board)
len = (idebufferb[7]<<8)|idebufferb[8];
alloc_length = len;
uint8_t index = 0;
index = 0;
/* only feature 0 is supported */
if (idebufferb[2] != 0 || idebufferb[3] != 0)
@@ -2768,9 +2772,8 @@ static void atapicommand(int ide_board)
case GPCMD_READ_DVD_STRUCTURE:
temp_command = idebufferb[0];
int media = idebufferb[1];
int format = idebufferb[7];
int ret;
media = idebufferb[1];
format = idebufferb[7];
len = (((uint32_t) idebufferb[6])<<24)|(((uint32_t) idebufferb[7])<<16)|(((uint32_t) idebufferb[8])<<8)|((uint32_t) idebufferb[9]);
alloc_length = len;

View File

@@ -274,11 +274,10 @@ static void ne2000_setirq(ne2000_t *ne2000, int irq)
static void ne2000_reset(int type, void *p)
{
ne2000_t *ne2000 = (ne2000_t *)p;
int i;
pclog("ne2000 reset\n");
int i;
// Initialise the mac address area by doubling the physical address
ne2000->macaddr[0] = ne2000->physaddr[0];
ne2000->macaddr[1] = ne2000->physaddr[0];
@@ -535,9 +534,9 @@ void ne2000_reset_write(uint32_t offset, uint16_t value, void *p)
uint16_t ne2000_read(uint32_t address, void *p)
{
ne2000_t *ne2000 = (ne2000_t *)p;
int ret;
pclog("read addr %x\n", address);
int ret;
address &= 0xf;
@@ -1661,11 +1660,11 @@ void *ne2000_init()
int rc;
int config_net_type;
int net_type;
uint16_t addr = 0xC000;
ne2000_t *ne2000 = malloc(sizeof(ne2000_t));
memset(ne2000, 0, sizeof(ne2000_t));
uint16_t addr = 0xC000;
if (network_card_current == 1) addr = device_get_config_int("addr");
disable_netbios = device_get_config_int("disable_netbios");
io_base = addr;

View File

@@ -129,6 +129,12 @@ void slirp_cleanup(void)
int slirp_init(void)
{
struct in_addr myaddr;
int rc;
char* category = "SLiRP Port Forwarding";
char key[32];
int i = 0, udp, from, to;
#ifdef SLIRP_DEBUG
// debug_init("/tmp/slirp.log", DEBUG_DEFAULT);
// debug_init("slirplog.txt",DEBUG_DEFAULT);
@@ -162,13 +168,8 @@ debug_init("slirplog.txt",DEBUG_DEFAULT);
alias_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
getouraddr();
struct in_addr myaddr;
int rc;
inet_aton("10.0.2.15",&myaddr);
char* category = "SLiRP Port Forwarding";
char key[32];
int i = 0, udp, from, to;
while (1) {
sprintf(key, "%d_udp", i);
udp = config_get_int(category, key, 0);

View File

@@ -155,9 +155,10 @@ void ati28800_recalctimings(svga_t *svga)
void *ati28800_init()
{
uint32_t memory = 512;
if (gfxcard == GFX_VGAWONDERXL) device_get_config_int("memory");
ati28800_t *ati28800;
if (gfxcard == GFX_VGAWONDERXL) memory = device_get_config_int("memory");
memory <<= 10;
ati28800_t *ati28800 = malloc(sizeof(ati28800_t));
ati28800 = malloc(sizeof(ati28800_t));
memset(ati28800, 0, sizeof(ati28800_t));
if (gfxcard == GFX_VGAWONDERXL)

View File

@@ -473,6 +473,7 @@ void mach64_updatemapping(mach64_t *mach64)
mem_mapping_set_addr(&mach64->linear_mapping, (mach64->linear_base & 0xffc00000), (4 << 20) - 0x4000);
mem_mapping_set_addr(&mach64->mmio_linear_mapping, (mach64->linear_base & 0xffc00000) + ((4 << 20) - 0x4000), 0x4000);
}
svga->linear_base = mach64->linear_base;
}
else
{
@@ -2593,9 +2594,8 @@ void *mach64gx_init()
{
int c;
mach64_t *mach64 = malloc(sizeof(mach64_t));
memset(mach64, 0, sizeof(mach64_t));
uint32_t vram_amount = 0;
memset(mach64, 0, sizeof(mach64_t));
mach64->vram_size = device_get_config_int("memory");
vram_amount = (mach64-> vram_size == 0) ? (1 << 19) : (mach64->vram_size << 20);

View File

@@ -116,6 +116,7 @@ void et4000_recalctimings(svga_t *svga)
et4000_t *et4000 = (et4000_t *)svga->p;
svga->ma_latch |= (svga->crtc[0x33]&3)<<16;
if (svga->crtc[0x35] & 1) svga->vblankstart += 0x400;
if (svga->crtc[0x35] & 2) svga->vtotal += 0x400;
if (svga->crtc[0x35] & 4) svga->dispend += 0x400;
if (svga->crtc[0x35] & 8) svga->vsyncstart += 0x400;

View File

@@ -374,6 +374,7 @@ void et4000w32p_recalcmapping(et4000w32p_t *et4000)
if (svga->crtc[0x36] & 0x10) /*Linear frame buffer*/
{
mem_mapping_set_addr(&et4000->linear_mapping, et4000->linearbase, 0x200000);
svga->linear_base = et4000->linearbase;
mem_mapping_disable(&svga->mapping);
mem_mapping_disable(&et4000->mmu_mapping);
}
@@ -1087,9 +1088,9 @@ void et4000w32p_hwcursor_draw(svga_t *svga, int displine)
{
int x, offset;
uint8_t dat;
offset = svga->hwcursor_latch.xoff;
int y_add = enable_overscan ? 16 : 0;
int x_add = enable_overscan ? 8 : 0;
offset = svga->hwcursor_latch.xoff;
for (x = 0; x < 64 - svga->hwcursor_latch.xoff; x += 4)
{
dat = svga->vram[svga->hwcursor_latch.addr + (offset >> 2)];

View File

@@ -230,9 +230,9 @@ uint8_t incolor_in(uint16_t addr, void *p)
void incolor_write(uint32_t addr, uint8_t val, void *p)
{
incolor_t *incolor = (incolor_t *)p;
egawrites++;
int plane;
unsigned char wmask = incolor->crtc[INCOLOR_CRTC_MASK];
unsigned char wmode = incolor->crtc[INCOLOR_CRTC_RWCTRL] & INCOLOR_RWCTRL_WRMODE;
unsigned char fg = incolor->crtc[INCOLOR_CRTC_RWCOL] & 0x0F;
@@ -242,6 +242,8 @@ void incolor_write(uint32_t addr, uint8_t val, void *p)
unsigned char pmask; /* Mask of plane within colour value */
unsigned char latch;
egawrites++;
/* Horrible hack, I know, but it's the only way to fix the 440FX BIOS filling the VRAM with garbage until Tom fixes the memory emulation. */
if ((cs == 0xE0000) && (cpu_state.pc == 0xBF2F) && (romset == ROM_440FX)) return;
if ((cs == 0xE0000) && (cpu_state.pc == 0xBF77) && (romset == ROM_440FX)) return;
@@ -301,7 +303,6 @@ void incolor_write(uint32_t addr, uint8_t val, void *p)
uint8_t incolor_read(uint32_t addr, void *p)
{
incolor_t *incolor = (incolor_t *)p;
egareads++;
unsigned plane;
unsigned char lp = incolor->crtc[INCOLOR_CRTC_PROTECT];
unsigned char value = 0;
@@ -310,6 +311,8 @@ uint8_t incolor_read(uint32_t addr, void *p)
unsigned char fg;
unsigned char mask, pmask;
egareads++;
addr &= 0xFFFF;
/* Read the four planes into latches */
for (plane = 0; plane < 4; plane++, addr += 0x10000)

View File

@@ -285,6 +285,8 @@ void *paradise_pvga1a_init()
svga->bpp = 8;
svga->miscout = 1;
svga->linear_base = 0;
paradise->type = PVGA1A;
@@ -319,6 +321,8 @@ void *paradise_wd90c11_init()
svga->bpp = 8;
svga->miscout = 1;
svga->linear_base = 0;
paradise->type = WD90C11;
return paradise;

View File

@@ -1057,6 +1057,7 @@ void s3_updatemapping(s3_t *s3)
break;
}
s3->linear_base &= ~(s3->linear_size - 1);
svga->linear_base = s3->linear_base;
// pclog("%08X %08X %02X %02X %02X\n", linear_base, linear_size, crtc[0x58], crtc[0x59], crtc[0x5a]);
// pclog("Linear framebuffer at %08X size %08X\n", s3->linear_base, s3->linear_size);
if (s3->linear_base == 0xa0000)

View File

@@ -672,6 +672,7 @@ static void s3_virge_updatemapping(virge_t *virge)
break;
}
virge->linear_base &= ~(virge->linear_size - 1);
svga->linear_base = virge->linear_base;
// pclog("%08X %08X %02X %02X %02X\n", linear_base, linear_size, crtc[0x58], crtc[0x59], crtc[0x5a]);
pclog("Linear framebuffer at %08X size %08X\n", virge->linear_base, virge->linear_size);
if (virge->linear_base == 0xa0000)

View File

@@ -1027,8 +1027,8 @@ uint8_t svga_read(uint32_t addr, void *p)
addr &= svga->banked_mask;
addr += svga->read_bank;
// latch_addr = (addr << 2) % svga->vram_limit;
latch_addr = (addr << 2);
latch_addr = (addr << 2) % svga->vram_limit;
// latch_addr = (addr << 2);
// pclog("%05X %i %04X:%04X %02X %02X %i\n",addr,svga->chain4,CS,pc, vram[addr & 0x7fffff], vram[(addr << 2) & 0x7fffff], svga->readmode);
// pclog("%i\n", svga->readmode);
@@ -1097,6 +1097,7 @@ void svga_write_linear(uint32_t addr, uint8_t val, void *p)
if (svga_output) pclog("Write LFB %08X %02X ", addr, val);
if (!(svga->gdcreg[6] & 1))
svga->fullchange = 2;
addr -= svga->linear_base;
if (svga->chain4 || svga->fb_only)
{
writemask2=1<<(addr&3);
@@ -1281,6 +1282,8 @@ uint8_t svga_read_linear(uint32_t addr, void *p)
cycles_lost += video_timing_b;
egareads++;
addr -= svga->linear_base;
if (svga->chain4 || svga->fb_only)
{
@@ -1522,6 +1525,7 @@ void svga_writew_linear(uint32_t addr, uint16_t val, void *p)
if (svga_output) pclog("Write LFBw %08X %04X\n", addr, val);
// addr %= svga->vram_limit;
addr -= svga->linear_base;
if ((!svga->extvram) && (addr >= 0x10000)) return;
if (addr >= svga->vram_limit)
return;
@@ -1551,6 +1555,7 @@ void svga_writel_linear(uint32_t addr, uint32_t val, void *p)
if (svga_output) pclog("Write LFBl %08X %08X\n", addr, val);
// addr %= svga->vram_limit;
addr -= svga->linear_base;
if ((!svga->extvram) && (addr >= 0x10000)) return;
if (addr >= svga->vram_limit)
return;
@@ -1573,6 +1578,7 @@ uint16_t svga_readw_linear(uint32_t addr, void *p)
cycles_lost += video_timing_w;
// addr %= svga->vram_limit;
addr -= svga->linear_base;
if ((!svga->extvram) && (addr >= 0x10000)) return 0xffff;
if (addr >= svga->vram_limit) return 0xffff;
@@ -1594,6 +1600,7 @@ uint32_t svga_readl_linear(uint32_t addr, void *p)
cycles_lost += video_timing_l;
// addr %= svga->vram_limit;
addr -= svga->linear_base;
if ((!svga->extvram) && (addr >= 0x10000)) return 0xffffffff;
if (addr >= svga->vram_limit) return 0xffffffff;

View File

@@ -113,6 +113,8 @@ typedef struct svga_t
card should not attempt to display anything */
int override;
void *p;
uint32_t linear_base;
} svga_t;
extern int svga_init(svga_t *svga, void *p, int memsize,

View File

@@ -401,6 +401,7 @@ void tgui_recalcmapping(tgui_t *tgui)
{
mem_mapping_disable(&svga->mapping);
mem_mapping_set_addr(&tgui->linear_mapping, tgui->linear_base, tgui->linear_size);
svga->linear_base = tgui->linear_base;
// pclog("Trident linear framebuffer at %08X - size %06X\n", tgui->linear_base, tgui->linear_size);
mem_mapping_enable(&tgui->accel_mapping);
}

View File

@@ -906,16 +906,19 @@ HHOOK hKeyboardHook;
LRESULT CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM lParam )
{
BOOL bControlKeyDown;
KBDLLHOOKSTRUCT* p;
if (nCode < 0 || nCode != HC_ACTION || (!mousecapture && !video_fullscreen))
return CallNextHookEx( hKeyboardHook, nCode, wParam, lParam);
KBDLLHOOKSTRUCT* p = (KBDLLHOOKSTRUCT*)lParam;
p = (KBDLLHOOKSTRUCT*)lParam;
if (p->vkCode == VK_TAB && p->flags & LLKHF_ALTDOWN) return 1; //disable alt-tab
if (p->vkCode == VK_SPACE && p->flags & LLKHF_ALTDOWN) return 1; //disable alt-tab
if((p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)) return 1;//disable windows keys
if (p->vkCode == VK_ESCAPE && p->flags & LLKHF_ALTDOWN) return 1;//disable alt-escape
BOOL bControlKeyDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);//checks ctrl key pressed
bControlKeyDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);//checks ctrl key pressed
if (p->vkCode == VK_ESCAPE && bControlKeyDown) return 1; //disable ctrl-escape
return CallNextHookEx( hKeyboardHook, nCode, wParam, lParam );

View File

@@ -1,20 +1,22 @@
#define OP_ARITH(name, operation, setflags, flagops, gettempc) \
static int op ## name ## _b_rmw_a16(uint32_t fetchdat) \
{ \
uint8_t dst; \
uint8_t src; \
if (gettempc) tempc = CF_SET() ? 1 : 0; \
fetch_ea_16(fetchdat); \
if (mod == 3) \
{ \
uint8_t dst = getr8(rm); \
uint8_t src = getr8(reg); \
dst = getr8(rm); \
src = getr8(reg); \
setflags ## 8 flagops; \
setr8(rm, operation); \
CLOCK_CYCLES(timing_rr); \
} \
else \
{ \
uint8_t dst = geteab(); if (abrt) return 1; \
uint8_t src = getr8(reg); \
dst = geteab(); if (abrt) return 1; \
src = getr8(reg); \
seteab(operation); if (abrt) return 1; \
setflags ## 8 flagops; \
CLOCK_CYCLES(timing_mr); \
@@ -23,20 +25,22 @@
} \
static int op ## name ## _b_rmw_a32(uint32_t fetchdat) \
{ \
uint8_t dst; \
uint8_t src; \
if (gettempc) tempc = CF_SET() ? 1 : 0; \
fetch_ea_32(fetchdat); \
if (mod == 3) \
{ \
uint8_t dst = getr8(rm); \
uint8_t src = getr8(reg); \
dst = getr8(rm); \
src = getr8(reg); \
setflags ## 8 flagops; \
setr8(rm, operation); \
CLOCK_CYCLES(timing_rr); \
} \
else \
{ \
uint8_t dst = geteab(); if (abrt) return 1; \
uint8_t src = getr8(reg); \
dst = geteab(); if (abrt) return 1; \
src = getr8(reg); \
seteab(operation); if (abrt) return 1; \
setflags ## 8 flagops; \
CLOCK_CYCLES(timing_mr); \
@@ -46,20 +50,22 @@
\
static int op ## name ## _w_rmw_a16(uint32_t fetchdat) \
{ \
uint16_t dst; \
uint16_t src; \
if (gettempc) tempc = CF_SET() ? 1 : 0; \
fetch_ea_16(fetchdat); \
if (mod == 3) \
{ \
uint16_t dst = cpu_state.regs[rm].w; \
uint16_t src = cpu_state.regs[reg].w; \
dst = cpu_state.regs[rm].w; \
src = cpu_state.regs[reg].w; \
setflags ## 16 flagops; \
cpu_state.regs[rm].w = operation; \
CLOCK_CYCLES(timing_rr); \
} \
else \
{ \
uint16_t dst = geteaw(); if (abrt) return 1; \
uint16_t src = cpu_state.regs[reg].w; \
dst = geteaw(); if (abrt) return 1; \
src = cpu_state.regs[reg].w; \
seteaw(operation); if (abrt) return 1; \
setflags ## 16 flagops; \
CLOCK_CYCLES(timing_mr); \
@@ -68,20 +74,22 @@
} \
static int op ## name ## _w_rmw_a32(uint32_t fetchdat) \
{ \
uint16_t dst; \
uint16_t src; \
if (gettempc) tempc = CF_SET() ? 1 : 0; \
fetch_ea_32(fetchdat); \
if (mod == 3) \
{ \
uint16_t dst = cpu_state.regs[rm].w; \
uint16_t src = cpu_state.regs[reg].w; \
dst = cpu_state.regs[rm].w; \
src = cpu_state.regs[reg].w; \
setflags ## 16 flagops; \
cpu_state.regs[rm].w = operation; \
CLOCK_CYCLES(timing_rr); \
} \
else \
{ \
uint16_t dst = geteaw(); if (abrt) return 1; \
uint16_t src = cpu_state.regs[reg].w; \
dst = geteaw(); if (abrt) return 1; \
src = cpu_state.regs[reg].w; \
seteaw(operation); if (abrt) return 1; \
setflags ## 16 flagops; \
CLOCK_CYCLES(timing_mr); \
@@ -91,20 +99,22 @@
\
static int op ## name ## _l_rmw_a16(uint32_t fetchdat) \
{ \
uint32_t dst; \
uint32_t src; \
if (gettempc) tempc = CF_SET() ? 1 : 0; \
fetch_ea_16(fetchdat); \
if (mod == 3) \
{ \
uint32_t dst = cpu_state.regs[rm].l; \
uint32_t src = cpu_state.regs[reg].l; \
dst = cpu_state.regs[rm].l; \
src = cpu_state.regs[reg].l; \
setflags ## 32 flagops; \
cpu_state.regs[rm].l = operation; \
CLOCK_CYCLES(timing_rr); \
} \
else \
{ \
uint32_t dst = geteal(); if (abrt) return 1; \
uint32_t src = cpu_state.regs[reg].l; \
dst = geteal(); if (abrt) return 1; \
src = cpu_state.regs[reg].l; \
seteal(operation); if (abrt) return 1; \
setflags ## 32 flagops; \
CLOCK_CYCLES(timing_mrl); \
@@ -113,20 +123,22 @@
} \
static int op ## name ## _l_rmw_a32(uint32_t fetchdat) \
{ \
uint32_t dst; \
uint32_t src; \
if (gettempc) tempc = CF_SET() ? 1 : 0; \
fetch_ea_32(fetchdat); \
if (mod == 3) \
{ \
uint32_t dst = cpu_state.regs[rm].l; \
uint32_t src = cpu_state.regs[reg].l; \
dst = cpu_state.regs[rm].l; \
src = cpu_state.regs[reg].l; \
setflags ## 32 flagops; \
cpu_state.regs[rm].l = operation; \
CLOCK_CYCLES(timing_rr); \
} \
else \
{ \
uint32_t dst = geteal(); if (abrt) return 1; \
uint32_t src = cpu_state.regs[reg].l; \
dst = geteal(); if (abrt) return 1; \
src = cpu_state.regs[reg].l; \
seteal(operation); if (abrt) return 1; \
setflags ## 32 flagops; \
CLOCK_CYCLES(timing_mrl); \

View File

@@ -18,7 +18,8 @@
#define opJ(condition) \
static int opJ ## condition(uint32_t fetchdat) \
{ \
int8_t offset = (int8_t)getbytef(); \
int8_t offset; \
offset = (int8_t)getbytef(); \
CLOCK_CYCLES(timing_bnt); \
if (cond_ ## condition) \
{ \
@@ -32,7 +33,8 @@
\
static int opJ ## condition ## _w(uint32_t fetchdat) \
{ \
int16_t offset = (int16_t)getwordf(); \
int16_t offset; \
offset = (int16_t)getwordf(); \
CLOCK_CYCLES(timing_bnt); \
if (cond_ ## condition) \
{ \
@@ -46,7 +48,8 @@
\
static int opJ ## condition ## _l(uint32_t fetchdat) \
{ \
uint32_t offset = getlong(); if (abrt) return 1; \
uint32_t offset; \
offset = getlong(); if (abrt) return 1; \
CLOCK_CYCLES(timing_bnt); \
if (cond_ ## condition) \
{ \
@@ -79,7 +82,8 @@ opJ(NLE)
static int opLOOPNE_w(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
int8_t offset;
offset = (int8_t)getbytef();
CX--;
CLOCK_CYCLES((is486) ? 7 : 11);
if (CX && !ZF_SET())
@@ -92,7 +96,8 @@ static int opLOOPNE_w(uint32_t fetchdat)
}
static int opLOOPNE_l(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
int8_t offset;
offset = (int8_t)getbytef();
ECX--;
CLOCK_CYCLES((is486) ? 7 : 11);
if (ECX && !ZF_SET())
@@ -106,7 +111,8 @@ static int opLOOPNE_l(uint32_t fetchdat)
static int opLOOPE_w(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
int8_t offset;
offset = (int8_t)getbytef();
CX--;
CLOCK_CYCLES((is486) ? 7 : 11);
if (CX && ZF_SET())
@@ -119,7 +125,8 @@ static int opLOOPE_w(uint32_t fetchdat)
}
static int opLOOPE_l(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
int8_t offset;
offset = (int8_t)getbytef();
ECX--;
CLOCK_CYCLES((is486) ? 7 : 11);
if (ECX && ZF_SET())
@@ -133,7 +140,8 @@ static int opLOOPE_l(uint32_t fetchdat)
static int opLOOP_w(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
int8_t offset;
offset = (int8_t)getbytef();
CX--;
CLOCK_CYCLES((is486) ? 7 : 11);
if (CX)
@@ -146,7 +154,8 @@ static int opLOOP_w(uint32_t fetchdat)
}
static int opLOOP_l(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
int8_t offset;
offset = (int8_t)getbytef();
ECX--;
CLOCK_CYCLES((is486) ? 7 : 11);
if (ECX)
@@ -160,7 +169,8 @@ static int opLOOP_l(uint32_t fetchdat)
static int opJCXZ(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
int8_t offset;
offset = (int8_t)getbytef();
CLOCK_CYCLES(5);
if (!CX)
{
@@ -173,7 +183,8 @@ static int opJCXZ(uint32_t fetchdat)
}
static int opJECXZ(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
int8_t offset;
offset = (int8_t)getbytef();
CLOCK_CYCLES(5);
if (!ECX)
{
@@ -188,7 +199,8 @@ static int opJECXZ(uint32_t fetchdat)
static int opJMP_r8(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
int8_t offset;
offset = (int8_t)getbytef();
cpu_state.pc += offset;
CPU_BLOCK_END();
CLOCK_CYCLES((is486) ? 3 : 7);
@@ -196,7 +208,8 @@ static int opJMP_r8(uint32_t fetchdat)
}
static int opJMP_r16(uint32_t fetchdat)
{
int16_t offset = (int16_t)getwordf();
int16_t offset;
offset = (int16_t)getwordf();
cpu_state.pc += offset;
CPU_BLOCK_END();
CLOCK_CYCLES((is486) ? 3 : 7);
@@ -204,7 +217,8 @@ static int opJMP_r16(uint32_t fetchdat)
}
static int opJMP_r32(uint32_t fetchdat)
{
int32_t offset = (int32_t)getlong(); if (abrt) return 1;
int32_t offset;
offset = (int32_t)getlong(); if (abrt) return 1;
cpu_state.pc += offset;
CPU_BLOCK_END();
CLOCK_CYCLES((is486) ? 3 : 7);
@@ -213,9 +227,12 @@ static int opJMP_r32(uint32_t fetchdat)
static int opJMP_far_a16(uint32_t fetchdat)
{
uint16_t addr = getwordf();
uint16_t seg = getword(); if (abrt) return 1;
uint32_t oxpc = cpu_state.pc;
uint16_t addr;
uint16_t seg;
uint32_t oxpc;
addr = getwordf();
seg = getword(); if (abrt) return 1;
oxpc = cpu_state.pc;
cpu_state.pc = addr;
loadcsjmp(seg, oxpc);
CPU_BLOCK_END();
@@ -223,9 +240,12 @@ static int opJMP_far_a16(uint32_t fetchdat)
}
static int opJMP_far_a32(uint32_t fetchdat)
{
uint32_t addr = getlong();
uint16_t seg = getword(); if (abrt) return 1;
uint32_t oxpc = cpu_state.pc;
uint32_t addr;
uint16_t seg;
uint32_t oxpc;
addr = getlong();
seg = getword(); if (abrt) return 1;
oxpc = cpu_state.pc;
cpu_state.pc = addr;
loadcsjmp(seg, oxpc);
CPU_BLOCK_END();
@@ -234,7 +254,8 @@ static int opJMP_far_a32(uint32_t fetchdat)
static int opCALL_r16(uint32_t fetchdat)
{
int16_t addr = (int16_t)getwordf();
int16_t addr;
addr = (int16_t)getwordf();
PUSH_W(cpu_state.pc);
cpu_state.pc += addr;
CPU_BLOCK_END();
@@ -243,7 +264,8 @@ static int opCALL_r16(uint32_t fetchdat)
}
static int opCALL_r32(uint32_t fetchdat)
{
int32_t addr = getlong(); if (abrt) return 1;
int32_t addr;
addr = getlong(); if (abrt) return 1;
PUSH_L(cpu_state.pc);
cpu_state.pc += addr;
CPU_BLOCK_END();
@@ -276,8 +298,9 @@ static int opRET_l(uint32_t fetchdat)
static int opRET_w_imm(uint32_t fetchdat)
{
uint16_t offset = getwordf();
uint16_t offset;
uint16_t ret;
offset = getwordf();
ret = POP_W(); if (abrt) return 1;
if (stack32) ESP += offset;
@@ -290,8 +313,9 @@ static int opRET_w_imm(uint32_t fetchdat)
}
static int opRET_l_imm(uint32_t fetchdat)
{
uint16_t offset = getwordf();
uint16_t offset;
uint32_t ret;
offset = getwordf();
ret = POP_L(); if (abrt) return 1;
if (stack32) ESP += offset;

View File

@@ -213,48 +213,62 @@ static int opMOV_l_imm_a32(uint32_t fetchdat)
static int opMOV_AL_a16(uint32_t fetchdat)
{
uint16_t addr = getwordf();
uint8_t temp = readmemb(ea_seg->base, addr); if (abrt) return 1;
uint16_t addr;
uint8_t temp;
addr = getwordf();
temp = readmemb(ea_seg->base, addr);
if (abrt) return 1;
AL = temp;
CLOCK_CYCLES((is486) ? 1 : 4);
return 0;
}
static int opMOV_AL_a32(uint32_t fetchdat)
{
uint32_t addr = getlong();
uint8_t temp = readmemb(ea_seg->base, addr); if (abrt) return 1;
uint32_t addr;
uint8_t temp;
addr = getlong();
temp = readmemb(ea_seg->base, addr);
if (abrt) return 1;
AL = temp;
CLOCK_CYCLES((is486) ? 1 : 4);
return 0;
}
static int opMOV_AX_a16(uint32_t fetchdat)
{
uint16_t addr = getwordf();
uint16_t temp = readmemw(ea_seg->base, addr); if (abrt) return 1;
uint16_t addr;
uint16_t temp;
addr = getwordf();
temp = readmemw(ea_seg->base, addr); if (abrt) return 1;
AX = temp;
CLOCK_CYCLES((is486) ? 1 : 4);
return 0;
}
static int opMOV_AX_a32(uint32_t fetchdat)
{
uint32_t addr = getlong();
uint16_t temp = readmemw(ea_seg->base, addr); if (abrt) return 1;
uint32_t addr;
uint16_t temp;
addr = getlong();
temp = readmemw(ea_seg->base, addr); if (abrt) return 1;
AX = temp;
CLOCK_CYCLES((is486) ? 1 : 4);
return 0;
}
static int opMOV_EAX_a16(uint32_t fetchdat)
{
uint16_t addr = getwordf();
uint32_t temp = readmeml(ea_seg->base, addr); if (abrt) return 1;
uint16_t addr;
uint32_t temp;
addr = getwordf();
temp = readmeml(ea_seg->base, addr); if (abrt) return 1;
EAX = temp;
CLOCK_CYCLES((is486) ? 1 : 4);
return 0;
}
static int opMOV_EAX_a32(uint32_t fetchdat)
{
uint32_t addr = getlong();
uint32_t temp = readmeml(ea_seg->base, addr); if (abrt) return 1;
uint32_t addr;
uint32_t temp;
addr = getlong();
temp = readmeml(ea_seg->base, addr); if (abrt) return 1;
EAX = temp;
CLOCK_CYCLES((is486) ? 1 : 4);
return 0;
@@ -262,42 +276,50 @@ static int opMOV_EAX_a32(uint32_t fetchdat)
static int opMOV_a16_AL(uint32_t fetchdat)
{
uint16_t addr = getwordf();
uint16_t addr;
addr = getwordf();
writememb(ea_seg->base, addr, AL);
CLOCK_CYCLES((is486) ? 1 : 2);
return abrt;
}
static int opMOV_a32_AL(uint32_t fetchdat)
{
uint32_t addr = getlong();
uint32_t addr;
addr = getlong();
writememb(ea_seg->base, addr, AL);
CLOCK_CYCLES((is486) ? 1 : 2);
return abrt;
}
static int opMOV_a16_AX(uint32_t fetchdat)
{
uint16_t addr = getwordf();
uint16_t addr;
addr = getwordf();
writememw(ea_seg->base, addr, AX);
CLOCK_CYCLES((is486) ? 1 : 2);
return abrt;
}
static int opMOV_a32_AX(uint32_t fetchdat)
{
uint32_t addr = getlong(); if (abrt) return 1;
uint32_t addr;
addr = getlong();
if (abrt) return 1;
writememw(ea_seg->base, addr, AX);
CLOCK_CYCLES((is486) ? 1 : 2);
return abrt;
}
static int opMOV_a16_EAX(uint32_t fetchdat)
{
uint16_t addr = getwordf();
uint16_t addr;
addr = getwordf();
writememl(ea_seg->base, addr, EAX);
CLOCK_CYCLES((is486) ? 1 : 2);
return abrt;
}
static int opMOV_a32_EAX(uint32_t fetchdat)
{
uint32_t addr = getlong(); if (abrt) return 1;
uint32_t addr;
addr = getlong();
if (abrt) return 1;
writememl(ea_seg->base, addr, EAX);
CLOCK_CYCLES((is486) ? 1 : 2);
return abrt;
@@ -343,7 +365,9 @@ static int opLEA_l_a32(uint32_t fetchdat)
static int opXLAT_a16(uint32_t fetchdat)
{
uint32_t addr = (BX + AL)&0xFFFF;
uint8_t temp = readmemb(ea_seg->base, addr); if (abrt) return 1;
uint8_t temp;
temp = readmemb(ea_seg->base, addr);
if (abrt) return 1;
AL = temp;
CLOCK_CYCLES(5);
return 0;
@@ -351,7 +375,9 @@ static int opXLAT_a16(uint32_t fetchdat)
static int opXLAT_a32(uint32_t fetchdat)
{
uint32_t addr = EBX + AL;
uint8_t temp = readmemb(ea_seg->base, addr); if (abrt) return 1;
uint8_t temp;
temp = readmemb(ea_seg->base, addr);
if (abrt) return 1;
AL = temp;
CLOCK_CYCLES(5);
return 0;

View File

@@ -470,9 +470,11 @@ static int opD3_l_a32(uint32_t fetchdat)
#define SHLD_w() \
if (count) \
{ \
uint16_t tempw = geteaw(); if (abrt) return 1; \
int tempc = ((tempw << (count - 1)) & (1 << 15)) ? 1 : 0; \
uint32_t templ = (tempw << 16) | cpu_state.regs[reg].w; \
uint16_t tempw = geteaw(); \
int tempc; uint32_t templ; \
if (abrt) return 1; \
tempc = ((tempw << (count - 1)) & (1 << 15)) ? 1 : 0; \
templ = (tempw << 16) | cpu_state.regs[reg].w; \
if (count <= 16) tempw = templ >> (16 - count); \
else tempw = (templ << count) >> 16; \
seteaw(tempw); if (abrt) return 1; \
@@ -484,8 +486,10 @@ static int opD3_l_a32(uint32_t fetchdat)
#define SHLD_l() \
if (count) \
{ \
uint32_t templ = geteal(); if (abrt) return 1; \
int tempc = ((templ << (count - 1)) & (1 << 31)) ? 1 : 0; \
uint32_t templ = geteal(); \
int tempc; \
if (abrt) return 1; \
tempc = ((templ << (count - 1)) & (1 << 31)) ? 1 : 0; \
templ = (templ << count) | (cpu_state.regs[reg].l >> (32 - count)); \
seteal(templ); if (abrt) return 1; \
setznp32(templ); \
@@ -497,9 +501,11 @@ static int opD3_l_a32(uint32_t fetchdat)
#define SHRD_w() \
if (count) \
{ \
uint16_t tempw = geteaw(); if (abrt) return 1; \
int tempc = (tempw >> (count - 1)) & 1; \
uint32_t templ = tempw | (cpu_state.regs[reg].w << 16); \
uint16_t tempw = geteaw(); \
int tempc; uint32_t templ; \
if (abrt) return 1; \
tempc = (tempw >> (count - 1)) & 1; \
templ = tempw | (cpu_state.regs[reg].w << 16); \
tempw = templ >> count; \
seteaw(tempw); if (abrt) return 1; \
setznp16(tempw); \
@@ -510,8 +516,10 @@ static int opD3_l_a32(uint32_t fetchdat)
#define SHRD_l() \
if (count) \
{ \
uint32_t templ = geteal(); if (abrt) return 1; \
int tempc = (templ >> (count - 1)) & 1; \
uint32_t templ = geteal(); \
int tempc; \
if (abrt) return 1; \
tempc = (templ >> (count - 1)) & 1; \
templ = (templ >> count) | (cpu_state.regs[reg].l << (32 - count)); \
seteal(templ); if (abrt) return 1; \
setznp32(templ); \

View File

@@ -294,9 +294,13 @@ static int opPOPL_a32(uint32_t fetchdat)
static int opENTER_w(uint32_t fetchdat)
{
uint16_t offset = getwordf();
int count = (fetchdat >> 16) & 0xff; cpu_state.pc++;
uint32_t tempEBP = EBP, tempESP = ESP, frame_ptr;
uint16_t offset;
int count;
uint32_t tempEBP, tempESP, frame_ptr;
offset = getwordf();
count = (fetchdat >> 16) & 0xff;
tempEBP = EBP, tempESP = ESP;
cpu_state.pc++;
PUSH_W(BP); if (abrt) return 1;
frame_ptr = ESP;
@@ -327,9 +331,13 @@ static int opENTER_w(uint32_t fetchdat)
}
static int opENTER_l(uint32_t fetchdat)
{
uint16_t offset = getwordf();
int count = (fetchdat >> 16) & 0xff; cpu_state.pc++;
uint32_t tempEBP = EBP, tempESP = ESP, frame_ptr;
uint16_t offset;
int count;
uint32_t tempEBP, tempESP, frame_ptr;
offset = getwordf();
count = (fetchdat >> 16) & 0xff;
tempEBP = EBP, tempESP = ESP;
cpu_state.pc++;
PUSH_L(EBP); if (abrt) return 1;
frame_ptr = ESP;

View File

@@ -37,18 +37,14 @@ void pmodeint(int num, int soft);
FILE *pclogf;
void x86abort(const char *format, ...)
{
char buf[256];
// return;
if (!pclogf)
pclogf=fopen("pclog.txt","wt");
//return;
va_list ap;
va_start(ap, format);
vsprintf(buf, format, ap);
vprintf(format, ap);
va_end(ap);
fputs(buf,pclogf);
fflush(pclogf);
fflush(stdout);
savenvr();
dumpregs();
fflush(stdout);
exit(-1);
}

View File

@@ -100,16 +100,24 @@ static inline double x87_ld80()
uint64_t ll;
} eind;
} test;
int64_t exp64;
int64_t blah;
int64_t exp64final;
int64_t mant64;
int64_t sign;
test.eind.ll = readmeml(easeg,eaaddr);
test.eind.ll |= (uint64_t)readmeml(easeg,eaaddr+4)<<32;
test.begin = readmemw(easeg,eaaddr+8);
int64_t exp64 = (((test.begin&0x7fff) - BIAS80));
int64_t blah = ((exp64 >0)?exp64:-exp64)&0x3ff;
int64_t exp64final = ((exp64 >0)?blah:-blah) +BIAS64;
exp64 = (((test.begin&0x7fff) - BIAS80));
blah = ((exp64 >0)?exp64:-exp64)&0x3ff;
exp64final = ((exp64 >0)?blah:-blah) +BIAS64;
int64_t mant64 = (test.eind.ll >> 11) & (0xfffffffffffff);
int64_t sign = (test.begin&0x8000)?1:0;
mant64 = (test.eind.ll >> 11) & (0xfffffffffffff);
sign = (test.begin&0x8000)?1:0;
if ((test.begin & 0x7fff) == 0x7fff)
exp64final = 0x7ff;
@@ -134,13 +142,19 @@ static inline void x87_st80(double d)
} eind;
} test;
int64_t sign80;
int64_t exp80;
int64_t exp80final;
int64_t mant80;
int64_t mant80final;
test.eind.d=d;
int64_t sign80 = (test.eind.ll&(0x8000000000000000))?1:0;
int64_t exp80 = test.eind.ll&(0x7ff0000000000000);
int64_t exp80final = (exp80>>52);
int64_t mant80 = test.eind.ll&(0x000fffffffffffff);
int64_t mant80final = (mant80 << 11);
sign80 = (test.eind.ll&(0x8000000000000000))?1:0;
exp80 = test.eind.ll&(0x7ff0000000000000);
exp80final = (exp80>>52);
mant80 = test.eind.ll&(0x000fffffffffffff);
mant80final = (mant80 << 11);
if (exp80final == 0x7ff) /*Infinity / Nan*/
{