Merge pull request #321 from TC1995/master

Minor fixes to the S3 SDAC.
This commit is contained in:
OBattler
2018-09-22 21:15:21 +02:00
committed by GitHub
3 changed files with 94 additions and 94 deletions

View File

@@ -8,7 +8,7 @@
* *
* S3 emulation. * S3 emulation.
* *
* Version: @(#)vid_s3.c 1.0.17 2018/09/21 * Version: @(#)vid_s3.c 1.0.18 2018/09/22
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -1033,9 +1033,9 @@ void s3_out(uint16_t addr, uint8_t val, void *p)
else else
{ {
if ((svga->crtc[0x55] & 1) || (svga->crtc[0x43] & 2)) if ((svga->crtc[0x55] & 1) || (svga->crtc[0x43] & 2))
sdac_ramdac_out((addr & 3) | 4, val, &s3->ramdac, svga); sdac_ramdac_out(addr, 1, val, &s3->ramdac, svga);
else else
sdac_ramdac_out(addr & 3, val, &s3->ramdac, svga); sdac_ramdac_out(addr, 0, val, &s3->ramdac, svga);
} }
return; return;
@@ -1204,8 +1204,8 @@ uint8_t s3_in(uint16_t addr, void *p)
if (s3->chip == S3_TRIO32 || s3->chip == S3_TRIO64) if (s3->chip == S3_TRIO32 || s3->chip == S3_TRIO64)
return svga_in(addr, svga); return svga_in(addr, svga);
if ((svga->crtc[0x55] & 1) || (svga->crtc[0x43] & 2)) if ((svga->crtc[0x55] & 1) || (svga->crtc[0x43] & 2))
return sdac_ramdac_in((addr & 3) | 4, &s3->ramdac, svga); return sdac_ramdac_in(addr, 1, &s3->ramdac, svga);
return sdac_ramdac_in(addr & 3, &s3->ramdac, svga); return sdac_ramdac_in(addr, 0, &s3->ramdac, svga);
case 0x3d4: case 0x3d4:
return svga->crtcreg; return svga->crtcreg;

View File

@@ -8,7 +8,7 @@
* *
* 87C716 'SDAC' true colour RAMDAC emulation. * 87C716 'SDAC' true colour RAMDAC emulation.
* *
* Version: @(#)vid_sdac_ramdac.c 1.0.3 2018/03/21 * Version: @(#)vid_sdac_ramdac.c 1.0.4 2018/03/21
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -34,9 +34,9 @@ static void sdac_control_write(sdac_ramdac_t *ramdac, svga_t *svga, uint8_t val)
case 0x2: case 0x3: case 0xa: svga->bpp = 15; break; case 0x2: case 0x3: case 0xa: svga->bpp = 15; break;
case 0x4: case 0xe: svga->bpp = 24; break; case 0x4: case 0xe: svga->bpp = 24; break;
case 0x5: case 0x6: case 0xc: svga->bpp = 16; break; case 0x5: case 0x6: case 0xc: svga->bpp = 16; break;
case 0x7: svga->bpp = 32; break; case 0x7: svga->bpp = 32; break;
case 0: case 1: default: svga->bpp = 8; break; case 0: case 1: default: svga->bpp = 8; break;
} }
} }
@@ -69,96 +69,96 @@ static uint8_t sdac_reg_read(sdac_ramdac_t *ramdac, int reg)
return temp; return temp;
} }
void sdac_ramdac_out(uint16_t addr, uint8_t val, sdac_ramdac_t *ramdac, svga_t *svga) void sdac_ramdac_out(uint16_t addr, int rs2, uint8_t val, sdac_ramdac_t *ramdac, svga_t *svga)
{ {
switch (addr) switch (addr)
{ {
case 2: case 0x3C6:
if (ramdac->magic_count == 4) if (rs2)
sdac_control_write(ramdac, svga, val); sdac_control_write(ramdac, svga, val);
ramdac->magic_count = 0; else {
break; if (ramdac->magic_count == 4)
sdac_control_write(ramdac, svga, val);
case 3: ramdac->magic_count = 0;
ramdac->magic_count = 0; }
break; break;
case 0:
ramdac->magic_count = 0; case 0x3C7:
break; if (rs2) {
case 1: ramdac->rindex = val;
ramdac->magic_count = 0; ramdac->reg_ff = 0;
break; }
else
ramdac->magic_count = 0;
break;
case 0x3C8:
if (rs2) {
ramdac->windex = val;
ramdac->reg_ff = 0;
}
else
ramdac->magic_count = 0;
break;
case 0x3C9:
if (rs2)
sdac_reg_write(ramdac, ramdac->windex & 0xff, val);
else
ramdac->magic_count = 0;
break;
}
case 4: svga_out(addr, val, svga);
ramdac->windex = val;
ramdac->reg_ff = 0;
break;
case 5:
sdac_reg_write(ramdac, ramdac->windex & 0xff, val);
break;
case 6:
sdac_control_write(ramdac, svga, val);
break;
case 7:
ramdac->rindex = val;
ramdac->reg_ff = 0;
break;
}
if (!(addr & 4))
{
if (addr < 2)
svga_out(addr + 0x3c8, val, svga);
else
svga_out(addr + 0x3c4, val, svga);
}
} }
uint8_t sdac_ramdac_in(uint16_t addr, sdac_ramdac_t *ramdac, svga_t *svga) uint8_t sdac_ramdac_in(uint16_t addr, int rs2, sdac_ramdac_t *ramdac, svga_t *svga)
{ {
uint8_t temp; uint8_t temp;
switch (addr) switch (addr)
{ {
case 2: case 0x3C6:
if (ramdac->magic_count < 5) if (rs2)
ramdac->magic_count++; return ramdac->command;
if (ramdac->magic_count == 4) else {
{ if (ramdac->magic_count < 5)
temp = 0x70; /*SDAC ID*/ ramdac->magic_count++;
ramdac->rs2 = 1; if (ramdac->magic_count == 4)
} {
if (ramdac->magic_count == 5) temp = 0x70; /*SDAC ID*/
{ }
temp = ramdac->command; if (ramdac->magic_count == 5)
ramdac->magic_count = 0; {
} temp = ramdac->command;
return temp; ramdac->magic_count = 0;
case 3: }
ramdac->magic_count=0; return temp;
break; }
case 0: break;
ramdac->magic_count=0;
break; case 0x3C7:
case 1: if (rs2)
ramdac->magic_count=0; return ramdac->rindex;
break; else
ramdac->magic_count=0;
case 4: break;
return ramdac->windex;
case 5: case 0x3C8:
return sdac_reg_read(ramdac, ramdac->rindex & 0xff); if (rs2)
case 6: return ramdac->windex;
return ramdac->command; else
case 7: ramdac->magic_count=0;
return ramdac->rindex; break;
}
if (!(addr & 4)) case 0x3C9:
{ if (rs2)
if (addr < 2) return sdac_reg_read(ramdac, ramdac->rindex & 0xff);
return svga_in(addr + 0x3c8, svga); else
else ramdac->magic_count=0;
return svga_in(addr + 0x3c4, svga); break;
} }
return 0xff;
return svga_in(addr, svga);
} }
float sdac_getclock(int clock, void *p) float sdac_getclock(int clock, void *p)

View File

@@ -13,7 +13,7 @@ typedef struct sdac_ramdac_t
void sdac_init(sdac_ramdac_t *ramdac); void sdac_init(sdac_ramdac_t *ramdac);
void sdac_ramdac_out(uint16_t addr, uint8_t val, sdac_ramdac_t *ramdac, svga_t *svga); void sdac_ramdac_out(uint16_t addr, int rs2, uint8_t val, sdac_ramdac_t *ramdac, svga_t *svga);
uint8_t sdac_ramdac_in(uint16_t addr, sdac_ramdac_t *ramdac, svga_t *svga); uint8_t sdac_ramdac_in(uint16_t addr, int rs2, sdac_ramdac_t *ramdac, svga_t *svga);
float sdac_getclock(int clock, void *p); float sdac_getclock(int clock, void *p);