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>
@@ -69,62 +69,63 @@ 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 (rs2)
sdac_control_write(ramdac, svga, val);
else {
if (ramdac->magic_count == 4) if (ramdac->magic_count == 4)
sdac_control_write(ramdac, svga, val); sdac_control_write(ramdac, svga, val);
ramdac->magic_count = 0; ramdac->magic_count = 0;
}
break; break;
case 3: case 0x3C7:
ramdac->magic_count = 0; if (rs2) {
break;
case 0:
ramdac->magic_count = 0;
break;
case 1:
ramdac->magic_count = 0;
break;
case 4:
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->rindex = val;
ramdac->reg_ff = 0; ramdac->reg_ff = 0;
}
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; break;
} }
if (!(addr & 4))
{ svga_out(addr, val, svga);
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 (rs2)
return ramdac->command;
else {
if (ramdac->magic_count < 5) if (ramdac->magic_count < 5)
ramdac->magic_count++; ramdac->magic_count++;
if (ramdac->magic_count == 4) if (ramdac->magic_count == 4)
{ {
temp = 0x70; /*SDAC ID*/ temp = 0x70; /*SDAC ID*/
ramdac->rs2 = 1;
} }
if (ramdac->magic_count == 5) if (ramdac->magic_count == 5)
{ {
@@ -132,33 +133,32 @@ uint8_t sdac_ramdac_in(uint16_t addr, sdac_ramdac_t *ramdac, svga_t *svga)
ramdac->magic_count = 0; ramdac->magic_count = 0;
} }
return temp; return temp;
case 3: }
ramdac->magic_count=0;
break; break;
case 0:
ramdac->magic_count=0; case 0x3C7:
break; if (rs2)
case 1: return ramdac->rindex;
else
ramdac->magic_count=0; ramdac->magic_count=0;
break; break;
case 4: case 0x3C8:
if (rs2)
return ramdac->windex; return ramdac->windex;
case 5:
return sdac_reg_read(ramdac, ramdac->rindex & 0xff);
case 6:
return ramdac->command;
case 7:
return ramdac->rindex;
}
if (!(addr & 4))
{
if (addr < 2)
return svga_in(addr + 0x3c8, svga);
else else
return svga_in(addr + 0x3c4, svga); ramdac->magic_count=0;
break;
case 0x3C9:
if (rs2)
return sdac_reg_read(ramdac, ramdac->rindex & 0xff);
else
ramdac->magic_count=0;
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);