Add even MORE bullshit to RIVA 128 context switching

This commit is contained in:
Melissa Goad
2017-01-12 21:50:18 -06:00
parent 3fe0b7545b
commit 1ef1b459a7

View File

@@ -978,6 +978,14 @@ static void riva128_pgraph_invalid_interrupt(int num, void *p)
riva128_pgraph_interrupt(0, riva128);
}
static void riva128_pgraph_volatile_reset(void *p)
{
riva128_t *riva128 = (riva128_t *)p;
svga_t *svga = &riva128->svga;
//TODO
}
static uint8_t riva128_pramdac_read(uint32_t addr, void *p)
{
riva128_t *riva128 = (riva128_t *)p;
@@ -1088,44 +1096,49 @@ static void riva128_puller_exec_method(int chanid, int subchanid, int offset, ui
riva128_t *riva128 = (riva128_t *)p;
svga_t *svga = &riva128->svga;
pclog("RIVA 128 Puller executing method %04X on channel %01X[%01X] %04X:%08X\n", offset, chanid, subchanid, val, CS, cpu_state.pc);
if(offset < 0x100)
if(riva128->card_id == 0x03)
{
if(offset == 0)
uint32_t tmp = riva128_ramht_lookup(val, riva128);
riva128->pgraph.instance = (tmp & 0xffff) << 4;
unsigned old_subc = (riva128->pgraph.ctx_user >> 13) & 7;
unsigned new_subc = subchanid & 7;
if((old_subc != new_subc) || !offset)
{
if(riva128->card_id == 0x03)
uint32_t tmp_ctx = riva128->pramin[riva128->pgraph.instance];
if(!offset) riva128->pgraph.ctx_cache[new_subc][0] = tmp_ctx & 0x3ff3f71f;
riva128->pgraph.ctx_user &= 0x1fe000;
riva128->pgraph.ctx_user |= tmp & 0x1f0000;
riva128->pgraph.ctx_user |= new_subc << 13;
if(riva128->pgraph.debug[1] & 0x100000) riva128->pgraph.ctx_switch[0] = riva128->pgraph.ctx_cache[new_subc][0];
if(riva128->pgraph.debug[2] & 0x10000000)
{
uint32_t tmp = riva128_ramht_lookup(val, riva128);
riva128->pgraph.instance = (tmp & 0xffff) << 4;
riva128->pgraph.ctx_switch[0] = riva128->pgraph.ctx_cache[subchanid][0] = riva128->pramin[riva128->pgraph.instance];
riva128->pgraph.ctx_user = (chanid << 24) | (tmp & 0x1f0000) | (subchanid << 13);
riva128_pgraph_volatile_reset(riva128);
riva128->pgraph.debug[1] |= 1;
}
else if(riva128->card_id >= 0x04 && riva128->card_id < 0x10)
else riva128->pgraph.debug[1] &= ~1;
if(riva128->pgraph.notify & 0x10000)
{
riva128->pgraph.ctx_switch[3] = (riva128_ramht_lookup(val, riva128) & 0xffff) << 4;
riva128->pgraph.ctx_switch[0] = riva128->pgraph.ctx_cache[subchanid][0] = riva128->pramin[riva128->pgraph.ctx_switch[3]];
riva128->pgraph.ctx_switch[1] = riva128->pgraph.ctx_cache[subchanid][1] = riva128->pramin[riva128->pgraph.ctx_switch[3] + 4];
riva128->pgraph.ctx_switch[2] = riva128->pgraph.ctx_cache[subchanid][2] = riva128->pramin[riva128->pgraph.ctx_switch[3] + 8];
riva128->pgraph.ctx_user = (chanid << 24) | (subchanid << 13);
}
else if(riva128->card_id >= 0x10 && riva128->card_id < 0x40)
{
riva128->pgraph.ctx_switch[3] = (riva128_ramht_lookup(val, riva128) & 0xffff) << 4;
riva128->pgraph.ctx_switch[0] = riva128->pgraph.ctx_cache[subchanid][0] = riva128->pramin[riva128->pgraph.ctx_switch[3]];
riva128->pgraph.ctx_switch[1] = riva128->pgraph.ctx_cache[subchanid][1] = riva128->pramin[riva128->pgraph.ctx_switch[3] + 4];
riva128->pgraph.ctx_switch[2] = riva128->pgraph.ctx_cache[subchanid][2] = riva128->pramin[riva128->pgraph.ctx_switch[3] + 8];
riva128->pgraph.ctx_switch[4] = riva128->pgraph.ctx_cache[subchanid][4] = riva128->pramin[riva128->pgraph.ctx_switch[3] + 12];
riva128->pgraph.ctx_user = (chanid << 24) | (subchanid << 13);
riva128_pgraph_invalid_interrupt(16, riva128);
riva128->pgraph.fifo_enable = 0;
}
}
}
if(riva128->pgraph.pgraph_speedhack)
{
}
else
{
pclog("RIVA 128 That was a bad idea, turning off the PGRAPH speedhack.\n");
if(!riva128->pgraph.invalid && (((riva128->pgraph.debug[3] >> 20) & 3) == 3) && offset)
{
riva128_pgraph_invalid_interrupt(4, riva128);
riva128->pgraph.fifo_enable = 0;
}
unsigned new_class = (tmp >> 16) & 0x1f;
if(riva128->pgraph.debug[1] & 0x10000 && ((riva128->pgraph.instance >> 4)) != riva128->pgraph.ctx_switch[3] && (new_class == 0x0d || new_class == 0x0e || new_class == 0x14 || new_class == 0x17 || offset == 0x0104)
{
riva128->pgraph.ctx_switch[3] = riva128->pgraph.instance >> 4;
riva128->pgraph.ctx_switch[1] = riva128->pramin[riva128->pgraph.instance + 4] & 0xffff;
riva128->pgraph.notify &= 0xf10000;
riva128->pgraph.notify |= (riva128->pramin[riva128->pgraph.instance + 4] >> 16) & 0xffff;
riva128->pgraph.ctx_switch[2] = riva128->pramin[riva128->pgraph.instance + 8] & 0x1ffff;
}
}
}