sonarlint voodoo stuff

This commit is contained in:
Jasmine Iwanek
2023-07-31 18:57:52 -04:00
parent b8993e3282
commit b52df9e201
9 changed files with 275 additions and 178 deletions

View File

@@ -160,8 +160,8 @@ voodoo_readw(uint32_t addr, void *priv)
if ((addr & 0xc00000) == 0x400000) /*Framebuffer*/ if ((addr & 0xc00000) == 0x400000) /*Framebuffer*/
{ {
if (SLI_ENABLED) { if (SLI_ENABLED) {
voodoo_set_t *set = voodoo->set; const voodoo_set_t *set = voodoo->set;
int y = (addr >> 11) & 0x3ff; int y = (addr >> 11) & 0x3ff;
if (y & 1) if (y & 1)
voodoo = set->voodoos[1]; voodoo = set->voodoos[1];
@@ -194,13 +194,12 @@ voodoo_readl(uint32_t addr, void *priv)
cycles -= voodoo->read_time; cycles -= voodoo->read_time;
if (addr & 0x800000) /*Texture*/ if (addr & 0x800000) { /*Texture*/
{
} else if (addr & 0x400000) /*Framebuffer*/ } else if (addr & 0x400000) /*Framebuffer*/
{ {
if (SLI_ENABLED) { if (SLI_ENABLED) {
voodoo_set_t *set = voodoo->set; const voodoo_set_t *set = voodoo->set;
int y = (addr >> 11) & 0x3ff; int y = (addr >> 11) & 0x3ff;
if (y & 1) if (y & 1)
voodoo = set->voodoos[1]; voodoo = set->voodoos[1];
@@ -429,7 +428,9 @@ voodoo_writel(uint32_t addr, uint32_t val, void *priv)
{ {
voodoo_queue_command(voodoo, addr | FIFO_WRITEL_FB, val); voodoo_queue_command(voodoo, addr | FIFO_WRITEL_FB, val);
} else if ((addr & 0x200000) && (voodoo->fbiInit7 & FBIINIT7_CMDFIFO_ENABLE)) { } else if ((addr & 0x200000) && (voodoo->fbiInit7 & FBIINIT7_CMDFIFO_ENABLE)) {
// voodoo_log("Write CMDFIFO %08x(%08x) %08x %08x\n", addr, voodoo->cmdfifo_base + (addr & 0x3fffc), val, (voodoo->cmdfifo_base + (addr & 0x3fffc)) & voodoo->fb_mask); #if 0
voodoo_log("Write CMDFIFO %08x(%08x) %08x %08x\n", addr, voodoo->cmdfifo_base + (addr & 0x3fffc), val, (voodoo->cmdfifo_base + (addr & 0x3fffc)) & voodoo->fb_mask);
#endif
*(uint32_t *) &voodoo->fb_mem[(voodoo->cmdfifo_base + (addr & 0x3fffc)) & voodoo->fb_mask] = val; *(uint32_t *) &voodoo->fb_mem[(voodoo->cmdfifo_base + (addr & 0x3fffc)) & voodoo->fb_mask] = val;
voodoo->cmdfifo_depth_wr++; voodoo->cmdfifo_depth_wr++;
if ((voodoo->cmdfifo_depth_wr - voodoo->cmdfifo_depth_rd) < 20) if ((voodoo->cmdfifo_depth_wr - voodoo->cmdfifo_depth_rd) < 20)
@@ -492,7 +493,9 @@ voodoo_writel(uint32_t addr, uint32_t val, void *priv)
if (voodoo->initEnable & 0x01) { if (voodoo->initEnable & 0x01) {
voodoo->fbiInit4 = val; voodoo->fbiInit4 = val;
voodoo->read_time = pci_nonburst_time + pci_burst_time * ((voodoo->fbiInit4 & 1) ? 2 : 1); voodoo->read_time = pci_nonburst_time + pci_burst_time * ((voodoo->fbiInit4 & 1) ? 2 : 1);
// voodoo_log("fbiInit4 write %08x - read_time=%i\n", val, voodoo->read_time); #if 0
voodoo_log("fbiInit4 write %08x - read_time=%i\n", val, voodoo->read_time);
#endif
} }
break; break;
case SST_backPorch: case SST_backPorch:
@@ -538,7 +541,9 @@ voodoo_writel(uint32_t addr, uint32_t val, void *priv)
voodoo->fbiInit1 = (val & ~5) | (voodoo->fbiInit1 & 5); voodoo->fbiInit1 = (val & ~5) | (voodoo->fbiInit1 & 5);
voodoo->write_time = pci_nonburst_time + pci_burst_time * ((voodoo->fbiInit1 & 2) ? 1 : 0); voodoo->write_time = pci_nonburst_time + pci_burst_time * ((voodoo->fbiInit1 & 2) ? 1 : 0);
voodoo->burst_time = pci_burst_time * ((voodoo->fbiInit1 & 2) ? 2 : 1); voodoo->burst_time = pci_burst_time * ((voodoo->fbiInit1 & 2) ? 2 : 1);
// voodoo_log("fbiInit1 write %08x - write_time=%i burst_time=%i\n", val, voodoo->write_time, voodoo->burst_time); #if 0
voodoo_log("fbiInit1 write %08x - write_time=%i burst_time=%i\n", val, voodoo->write_time, voodoo->burst_time);
#endif
} }
break; break;
case SST_fbiInit2: case SST_fbiInit2:
@@ -590,6 +595,9 @@ voodoo_writel(uint32_t addr, uint32_t val, void *priv)
case 0x0b: case 0x0b:
voodoo->dac_readdata = 0x79; voodoo->dac_readdata = 0x79;
break; break;
default:
break;
} }
} else } else
voodoo->dac_readdata = voodoo->dac_data[voodoo->dac_readdata & 7]; voodoo->dac_readdata = voodoo->dac_data[voodoo->dac_readdata & 7];
@@ -599,7 +607,9 @@ voodoo_writel(uint32_t addr, uint32_t val, void *priv)
voodoo->dac_pll_regs[voodoo->dac_data[4] & 0xf] = (voodoo->dac_pll_regs[voodoo->dac_data[4] & 0xf] & 0xff00) | val; voodoo->dac_pll_regs[voodoo->dac_data[4] & 0xf] = (voodoo->dac_pll_regs[voodoo->dac_data[4] & 0xf] & 0xff00) | val;
else else
voodoo->dac_pll_regs[voodoo->dac_data[4] & 0xf] = (voodoo->dac_pll_regs[voodoo->dac_data[4] & 0xf] & 0xff) | (val << 8); voodoo->dac_pll_regs[voodoo->dac_data[4] & 0xf] = (voodoo->dac_pll_regs[voodoo->dac_data[4] & 0xf] & 0xff) | (val << 8);
// voodoo_log("Write PLL reg %x %04x\n", voodoo->dac_data[4] & 0xf, voodoo->dac_pll_regs[voodoo->dac_data[4] & 0xf]); #if 0
voodoo_log("Write PLL reg %x %04x\n", voodoo->dac_data[4] & 0xf, voodoo->dac_pll_regs[voodoo->dac_data[4] & 0xf]);
#endif
voodoo->dac_reg_ff = !voodoo->dac_reg_ff; voodoo->dac_reg_ff = !voodoo->dac_reg_ff;
if (!voodoo->dac_reg_ff) if (!voodoo->dac_reg_ff)
voodoo->dac_data[4]++; voodoo->dac_data[4]++;
@@ -642,7 +652,9 @@ voodoo_writel(uint32_t addr, uint32_t val, void *priv)
case SST_cmdFifoBaseAddr: case SST_cmdFifoBaseAddr:
voodoo->cmdfifo_base = (val & 0x3ff) << 12; voodoo->cmdfifo_base = (val & 0x3ff) << 12;
voodoo->cmdfifo_end = ((val >> 16) & 0x3ff) << 12; voodoo->cmdfifo_end = ((val >> 16) & 0x3ff) << 12;
// voodoo_log("CMDFIFO base=%08x end=%08x\n", voodoo->cmdfifo_base, voodoo->cmdfifo_end); #if 0
voodoo_log("CMDFIFO base=%08x end=%08x\n", voodoo->cmdfifo_base, voodoo->cmdfifo_end);
#endif
break; break;
case SST_cmdFifoRdPtr: case SST_cmdFifoRdPtr:
@@ -672,14 +684,14 @@ voodoo_writel(uint32_t addr, uint32_t val, void *priv)
static uint16_t static uint16_t
voodoo_snoop_readw(uint32_t addr, void *priv) voodoo_snoop_readw(uint32_t addr, void *priv)
{ {
voodoo_set_t *set = (voodoo_set_t *) priv; const voodoo_set_t *set = (voodoo_set_t *) priv;
return voodoo_readw(addr, set->voodoos[0]); return voodoo_readw(addr, set->voodoos[0]);
} }
static uint32_t static uint32_t
voodoo_snoop_readl(uint32_t addr, void *priv) voodoo_snoop_readl(uint32_t addr, void *priv)
{ {
voodoo_set_t *set = (voodoo_set_t *) priv; const voodoo_set_t *set = (voodoo_set_t *) priv;
return voodoo_readl(addr, set->voodoos[0]); return voodoo_readl(addr, set->voodoos[0]);
} }
@@ -687,7 +699,7 @@ voodoo_snoop_readl(uint32_t addr, void *priv)
static void static void
voodoo_snoop_writew(uint32_t addr, uint16_t val, void *priv) voodoo_snoop_writew(uint32_t addr, uint16_t val, void *priv)
{ {
voodoo_set_t *set = (voodoo_set_t *) priv; const voodoo_set_t *set = (voodoo_set_t *) priv;
voodoo_writew(addr, val, set->voodoos[0]); voodoo_writew(addr, val, set->voodoos[0]);
voodoo_writew(addr, val, set->voodoos[1]); voodoo_writew(addr, val, set->voodoos[1]);
@@ -695,7 +707,7 @@ voodoo_snoop_writew(uint32_t addr, uint16_t val, void *priv)
static void static void
voodoo_snoop_writel(uint32_t addr, uint32_t val, void *priv) voodoo_snoop_writel(uint32_t addr, uint32_t val, void *priv)
{ {
voodoo_set_t *set = (voodoo_set_t *) priv; const voodoo_set_t *set = (voodoo_set_t *) priv;
voodoo_writel(addr, val, set->voodoos[0]); voodoo_writel(addr, val, set->voodoos[0]);
voodoo_writel(addr, val, set->voodoos[1]); voodoo_writel(addr, val, set->voodoos[1]);
@@ -749,7 +761,7 @@ voodoo_recalcmapping(voodoo_set_t *set)
uint8_t uint8_t
voodoo_pci_read(int func, int addr, void *priv) voodoo_pci_read(int func, int addr, void *priv)
{ {
voodoo_t *voodoo = (voodoo_t *) priv; const voodoo_t *voodoo = (voodoo_t *) priv;
if (func) if (func)
return 0; return 0;
@@ -803,6 +815,9 @@ voodoo_pci_read(int func, int addr, void *priv)
return (voodoo->initEnable >> 16) & 0xff; return (voodoo->initEnable >> 16) & 0xff;
case 0x43: case 0x43:
return (voodoo->initEnable >> 24) & 0xff; return (voodoo->initEnable >> 24) & 0xff;
default:
break;
} }
return 0; return 0;
} }
@@ -844,13 +859,16 @@ voodoo_pci_write(int func, int addr, uint8_t val, void *priv)
voodoo->initEnable = (voodoo->initEnable & ~0xff000000) | (val << 24); voodoo->initEnable = (voodoo->initEnable & ~0xff000000) | (val << 24);
voodoo_recalcmapping(voodoo->set); voodoo_recalcmapping(voodoo->set);
break; break;
default:
break;
} }
} }
static void static void
voodoo_speed_changed(void *priv) voodoo_speed_changed(void *priv)
{ {
voodoo_set_t *voodoo_set = (voodoo_set_t *) priv; const voodoo_set_t *voodoo_set = (voodoo_set_t *) priv;
voodoo_pixelclock_update(voodoo_set->voodoos[0]); voodoo_pixelclock_update(voodoo_set->voodoos[0]);
voodoo_set->voodoos[0]->read_time = pci_nonburst_time + pci_burst_time * ((voodoo_set->voodoos[0]->fbiInit4 & 1) ? 2 : 1); voodoo_set->voodoos[0]->read_time = pci_nonburst_time + pci_burst_time * ((voodoo_set->voodoos[0]->fbiInit4 & 1) ? 2 : 1);
@@ -870,7 +888,7 @@ voodoo_speed_changed(void *priv)
static void static void
voodoo_force_blit(void *priv) voodoo_force_blit(void *priv)
{ {
voodoo_set_t *voodoo_set = (voodoo_set_t *) priv; const voodoo_set_t *voodoo_set = (voodoo_set_t *) priv;
thread_wait_mutex(voodoo_set->voodoos[0]->force_blit_mutex); thread_wait_mutex(voodoo_set->voodoos[0]->force_blit_mutex);
if (voodoo_set->voodoos[0]->can_blit) { if (voodoo_set->voodoos[0]->can_blit) {
@@ -916,6 +934,9 @@ voodoo_card_init(void)
case VOODOO_2: case VOODOO_2:
voodoo->dual_tmus = 1; voodoo->dual_tmus = 1;
break; break;
default:
break;
} }
if (voodoo->type == VOODOO_2) /*generate filter lookup tables*/ if (voodoo->type == VOODOO_2) /*generate filter lookup tables*/
@@ -1163,7 +1184,7 @@ voodoo_2d3d_card_init(int type)
} }
void * void *
voodoo_init(const device_t *info) voodoo_init(UNUSED(const device_t *info))
{ {
voodoo_set_t *voodoo_set = malloc(sizeof(voodoo_set_t)); voodoo_set_t *voodoo_set = malloc(sizeof(voodoo_set_t));
uint32_t tmuConfig = 1; uint32_t tmuConfig = 1;
@@ -1205,6 +1226,9 @@ voodoo_init(const device_t *info)
case VOODOO_2: case VOODOO_2:
tmuConfig = 1 | (3 << 6); tmuConfig = 1 | (3 << 6);
break; break;
default:
break;
} }
voodoo_set->voodoos[0]->tmuConfig = tmuConfig; voodoo_set->voodoos[0]->tmuConfig = tmuConfig;

View File

@@ -373,6 +373,9 @@ banshee_out(uint16_t addr, uint8_t val, void *priv)
} }
} }
break; break;
default:
break;
} }
svga_out(addr, val, svga); svga_out(addr, val, svga);
} }
@@ -433,8 +436,7 @@ banshee_updatemapping(banshee_t *banshee)
} }
banshee_log("Update mapping - bank %02X ", svga->gdcreg[6] & 0xc); banshee_log("Update mapping - bank %02X ", svga->gdcreg[6] & 0xc);
switch (svga->gdcreg[6] & 0xc) /*Banked framebuffer*/ switch (svga->gdcreg[6] & 0xc) { /*Banked framebuffer*/
{
case 0x0: /*128k at A0000*/ case 0x0: /*128k at A0000*/
mem_mapping_set_addr(&svga->mapping, 0xa0000, 0x20000); mem_mapping_set_addr(&svga->mapping, 0xa0000, 0x20000);
svga->banked_mask = 0xffff; svga->banked_mask = 0xffff;
@@ -451,6 +453,9 @@ banshee_updatemapping(banshee_t *banshee)
mem_mapping_set_addr(&svga->mapping, 0xb8000, 0x08000); mem_mapping_set_addr(&svga->mapping, 0xb8000, 0x08000);
svga->banked_mask = 0x7fff; svga->banked_mask = 0x7fff;
break; break;
default:
break;
} }
banshee_log("Linear framebuffer %08X ", banshee->memBaseAddr1); banshee_log("Linear framebuffer %08X ", banshee->memBaseAddr1);
@@ -464,7 +469,7 @@ static void
banshee_render_16bpp_tiled(svga_t *svga) banshee_render_16bpp_tiled(svga_t *svga)
{ {
banshee_t *banshee = (banshee_t *) svga->priv; banshee_t *banshee = (banshee_t *) svga->priv;
uint32_t *p = &((uint32_t *) svga->monitor->target_buffer->line[svga->displine + svga->y_add])[svga->x_add]; uint32_t *p = &(svga->monitor->target_buffer->line[svga->displine + svga->y_add])[svga->x_add];
uint32_t addr; uint32_t addr;
int drawn = 0; int drawn = 0;
@@ -480,7 +485,7 @@ banshee_render_16bpp_tiled(svga_t *svga)
if (svga->hwcursor_on || svga->overlay_on) if (svga->hwcursor_on || svga->overlay_on)
svga->changedvram[addr >> 12] = 2; svga->changedvram[addr >> 12] = 2;
if (svga->changedvram[addr >> 12] || svga->fullchange) { if (svga->changedvram[addr >> 12] || svga->fullchange) {
uint16_t *vram_p = (uint16_t *) &svga->vram[addr & svga->vram_display_mask]; const uint16_t *vram_p = (uint16_t *) &svga->vram[addr & svga->vram_display_mask];
for (uint8_t xx = 0; xx < 64; xx++) for (uint8_t xx = 0; xx < 64; xx++)
*p++ = video_16to32[*vram_p++]; *p++ = video_16to32[*vram_p++];
@@ -503,8 +508,8 @@ banshee_render_16bpp_tiled(svga_t *svga)
static void static void
banshee_recalctimings(svga_t *svga) banshee_recalctimings(svga_t *svga)
{ {
banshee_t *banshee = (banshee_t *) svga->priv; banshee_t *banshee = (banshee_t *) svga->priv;
voodoo_t *voodoo = banshee->voodoo; const voodoo_t *voodoo = banshee->voodoo;
/*7 R/W Horizontal Retrace End bit 5. - /*7 R/W Horizontal Retrace End bit 5. -
6 R/W Horizontal Retrace Start bit 8 0x4 6 R/W Horizontal Retrace Start bit 8 0x4
@@ -908,10 +913,11 @@ banshee_ext_outl(uint16_t addr, uint32_t val, void *priv)
svga->fullchange = changeframecount; svga->fullchange = changeframecount;
svga_recalctimings(svga); svga_recalctimings(svga);
break; break;
#if 0
default: default:
#if 0
fatal("bad banshee_ext_outl: addr=%04x val=%08x\n", addr, val); fatal("bad banshee_ext_outl: addr=%04x val=%08x\n", addr, val);
#endif #endif
break;
} }
} }
@@ -999,15 +1005,14 @@ banshee_ext_in(uint16_t addr, void *priv)
static uint32_t static uint32_t
banshee_status(banshee_t *banshee) banshee_status(banshee_t *banshee)
{ {
voodoo_t *voodoo = banshee->voodoo; voodoo_t *voodoo = banshee->voodoo;
svga_t *svga = &banshee->svga; const svga_t *svga = &banshee->svga;
int fifo_entries = FIFO_ENTRIES; int fifo_entries = FIFO_ENTRIES;
int swap_count = voodoo->swap_count; int swap_count = voodoo->swap_count;
int written = voodoo->cmd_written + voodoo->cmd_written_fifo; int written = voodoo->cmd_written + voodoo->cmd_written_fifo;
int busy = (written - voodoo->cmd_read) || (voodoo->cmdfifo_depth_rd != voodoo->cmdfifo_depth_wr) || voodoo->render_voodoo_busy[0] || voodoo->render_voodoo_busy[1] || voodoo->render_voodoo_busy[2] || voodoo->render_voodoo_busy[3] || voodoo->voodoo_busy; int busy = (written - voodoo->cmd_read) || (voodoo->cmdfifo_depth_rd != voodoo->cmdfifo_depth_wr) || voodoo->render_voodoo_busy[0] || voodoo->render_voodoo_busy[1] || voodoo->render_voodoo_busy[2] || voodoo->render_voodoo_busy[3] || voodoo->voodoo_busy;
uint32_t ret; uint32_t ret = 0;
ret = 0;
if (fifo_entries < 0x20) if (fifo_entries < 0x20)
ret |= 0x1f - fifo_entries; ret |= 0x1f - fifo_entries;
else else
@@ -1040,10 +1045,10 @@ banshee_status(banshee_t *banshee)
static uint32_t static uint32_t
banshee_ext_inl(uint16_t addr, void *priv) banshee_ext_inl(uint16_t addr, void *priv)
{ {
banshee_t *banshee = (banshee_t *) priv; banshee_t *banshee = (banshee_t *) priv;
voodoo_t *voodoo = banshee->voodoo; const voodoo_t *voodoo = banshee->voodoo;
svga_t *svga = &banshee->svga; const svga_t *svga = &banshee->svga;
uint32_t ret = 0xffffffff; uint32_t ret = 0xffffffff;
cycles -= voodoo->read_time; cycles -= voodoo->read_time;
@@ -1215,8 +1220,8 @@ banshee_reg_readw(uint32_t addr, void *priv)
static uint32_t static uint32_t
banshee_cmd_read(banshee_t *banshee, uint32_t addr) banshee_cmd_read(banshee_t *banshee, uint32_t addr)
{ {
voodoo_t *voodoo = banshee->voodoo; const voodoo_t *voodoo = banshee->voodoo;
uint32_t ret = 0xffffffff; uint32_t ret = 0xffffffff;
switch (addr & 0x1fc) { switch (addr & 0x1fc) {
case Agp_agpHostAddressLow: case Agp_agpHostAddressLow:
@@ -1422,6 +1427,9 @@ banshee_reg_readl(uint32_t addr, void *priv)
break; break;
} }
break; break;
default:
break;
} }
#if 0 #if 0
@@ -1470,6 +1478,9 @@ banshee_reg_writew(uint32_t addr, uint16_t val, void *priv)
case 0x1f00000: case 0x1f00000:
voodoo_queue_command(voodoo, (addr & 0xffffff) | FIFO_WRITEW_FB, val); voodoo_queue_command(voodoo, (addr & 0xffffff) | FIFO_WRITEW_FB, val);
break; break;
default:
break;
} }
} }
@@ -1682,15 +1693,18 @@ banshee_reg_writel(uint32_t addr, uint32_t val, void *priv)
case 0x1f00000: case 0x1f00000:
voodoo_queue_command(voodoo, (addr & 0xfffffc) | FIFO_WRITEL_FB, val); voodoo_queue_command(voodoo, (addr & 0xfffffc) | FIFO_WRITEL_FB, val);
break; break;
default:
break;
} }
} }
static uint8_t static uint8_t
banshee_read_linear(uint32_t addr, void *priv) banshee_read_linear(uint32_t addr, void *priv)
{ {
banshee_t *banshee = (banshee_t *) priv; banshee_t *banshee = (banshee_t *) priv;
voodoo_t *voodoo = banshee->voodoo; const voodoo_t *voodoo = banshee->voodoo;
svga_t *svga = &banshee->svga; const svga_t *svga = &banshee->svga;
cycles -= voodoo->read_time; cycles -= voodoo->read_time;
@@ -1726,9 +1740,9 @@ banshee_read_linear(uint32_t addr, void *priv)
static uint16_t static uint16_t
banshee_read_linear_w(uint32_t addr, void *priv) banshee_read_linear_w(uint32_t addr, void *priv)
{ {
banshee_t *banshee = (banshee_t *) priv; banshee_t *banshee = (banshee_t *) priv;
voodoo_t *voodoo = banshee->voodoo; const voodoo_t *voodoo = banshee->voodoo;
svga_t *svga = &banshee->svga; svga_t *svga = &banshee->svga;
if (addr & 1) if (addr & 1)
return banshee_read_linear(addr, priv) | (banshee_read_linear(addr + 1, priv) << 8); return banshee_read_linear(addr, priv) | (banshee_read_linear(addr + 1, priv) << 8);
@@ -1766,9 +1780,9 @@ banshee_read_linear_w(uint32_t addr, void *priv)
static uint32_t static uint32_t
banshee_read_linear_l(uint32_t addr, void *priv) banshee_read_linear_l(uint32_t addr, void *priv)
{ {
banshee_t *banshee = (banshee_t *) priv; banshee_t *banshee = (banshee_t *) priv;
voodoo_t *voodoo = banshee->voodoo; const voodoo_t *voodoo = banshee->voodoo;
svga_t *svga = &banshee->svga; svga_t *svga = &banshee->svga;
if (addr & 3) if (addr & 3)
return banshee_read_linear_w(addr, priv) | (banshee_read_linear_w(addr + 2, priv) << 16); return banshee_read_linear_w(addr, priv) | (banshee_read_linear_w(addr + 2, priv) << 16);
@@ -1807,9 +1821,9 @@ banshee_read_linear_l(uint32_t addr, void *priv)
static void static void
banshee_write_linear(uint32_t addr, uint8_t val, void *priv) banshee_write_linear(uint32_t addr, uint8_t val, void *priv)
{ {
banshee_t *banshee = (banshee_t *) priv; banshee_t *banshee = (banshee_t *) priv;
voodoo_t *voodoo = banshee->voodoo; const voodoo_t *voodoo = banshee->voodoo;
svga_t *svga = &banshee->svga; svga_t *svga = &banshee->svga;
cycles -= voodoo->write_time; cycles -= voodoo->write_time;
@@ -1842,9 +1856,9 @@ banshee_write_linear(uint32_t addr, uint8_t val, void *priv)
static void static void
banshee_write_linear_w(uint32_t addr, uint16_t val, void *priv) banshee_write_linear_w(uint32_t addr, uint16_t val, void *priv)
{ {
banshee_t *banshee = (banshee_t *) priv; banshee_t *banshee = (banshee_t *) priv;
voodoo_t *voodoo = banshee->voodoo; const voodoo_t *voodoo = banshee->voodoo;
svga_t *svga = &banshee->svga; svga_t *svga = &banshee->svga;
if (addr & 1) { if (addr & 1) {
banshee_write_linear(addr, val, priv); banshee_write_linear(addr, val, priv);
@@ -1984,14 +1998,14 @@ banshee_write_linear_l(uint32_t addr, uint32_t val, void *priv)
void void
banshee_hwcursor_draw(svga_t *svga, int displine) banshee_hwcursor_draw(svga_t *svga, int displine)
{ {
banshee_t *banshee = (banshee_t *) svga->priv; const banshee_t *banshee = (banshee_t *) svga->priv;
int x; int x;
int x_off; int x_off;
int xx; int xx;
uint32_t col0 = banshee->hwCurC0; uint32_t col0 = banshee->hwCurC0;
uint32_t col1 = banshee->hwCurC1; uint32_t col1 = banshee->hwCurC1;
uint8_t plane0[8]; uint8_t plane0[8];
uint8_t plane1[8]; uint8_t plane1[8];
for (uint8_t c = 0; c < 8; c++) for (uint8_t c = 0; c < 8; c++)
plane0[c] = svga->vram[svga->hwcursor_latch.addr + c]; plane0[c] = svga->vram[svga->hwcursor_latch.addr + c];
@@ -2007,7 +2021,7 @@ banshee_hwcursor_draw(svga_t *svga, int displine)
if (x_off > -8) { if (x_off > -8) {
for (xx = 0; xx < 8; xx++) { for (xx = 0; xx < 8; xx++) {
if (plane0[x >> 3] & (1 << 7)) if (plane0[x >> 3] & (1 << 7))
((uint32_t *) svga->monitor->target_buffer->line[displine])[x_off + xx + svga->x_add] = (plane1[x >> 3] & (1 << 7)) ? col1 : col0; (svga->monitor->target_buffer->line[displine])[x_off + xx + svga->x_add] = (plane1[x >> 3] & (1 << 7)) ? col1 : col0;
plane0[x >> 3] <<= 1; plane0[x >> 3] <<= 1;
plane1[x >> 3] <<= 1; plane1[x >> 3] <<= 1;
@@ -2022,9 +2036,9 @@ banshee_hwcursor_draw(svga_t *svga, int displine)
if (x_off > -8) { if (x_off > -8) {
for (xx = 0; xx < 8; xx++) { for (xx = 0; xx < 8; xx++) {
if (!(plane0[x >> 3] & (1 << 7))) if (!(plane0[x >> 3] & (1 << 7)))
((uint32_t *) svga->monitor->target_buffer->line[displine])[x_off + xx + svga->x_add] = (plane1[x >> 3] & (1 << 7)) ? col1 : col0; (svga->monitor->target_buffer->line[displine])[x_off + xx + svga->x_add] = (plane1[x >> 3] & (1 << 7)) ? col1 : col0;
else if (plane1[x >> 3] & (1 << 7)) else if (plane1[x >> 3] & (1 << 7))
((uint32_t *) svga->monitor->target_buffer->line[displine])[x_off + xx + svga->x_add] ^= 0xffffff; (svga->monitor->target_buffer->line[displine])[x_off + xx + svga->x_add] ^= 0xffffff;
plane0[x >> 3] <<= 1; plane0[x >> 3] <<= 1;
plane1[x >> 3] <<= 1; plane1[x >> 3] <<= 1;
@@ -2189,8 +2203,6 @@ banshee_hwcursor_draw(svga_t *svga, int displine)
void void
voodoo_generate_vb_filters(voodoo_t *voodoo, int fcr, int fcg) voodoo_generate_vb_filters(voodoo_t *voodoo, int fcr, int fcg)
{ {
int g;
int h;
float difference; float difference;
float diffg; float diffg;
float thiscol; float thiscol;
@@ -2204,10 +2216,8 @@ voodoo_generate_vb_filters(voodoo_t *voodoo, int fcr, int fcg)
fcg *= hack; fcg *= hack;
/* box prefilter */ /* box prefilter */
for (g = 0; g < 256; g++) // pixel 1 - our target pixel we want to bleed into for (uint16_t g = 0; g < 256; g++) { // pixel 1 - our target pixel we want to bleed into
{ for (uint16_t h = 0; h < 256; h++) { // pixel 2 - our main pixel
for (h = 0; h < 256; h++) // pixel 2 - our main pixel
{
float avg; float avg;
float avgdiff; float avgdiff;
@@ -2289,10 +2299,8 @@ voodoo_generate_vb_filters(voodoo_t *voodoo, int fcr, int fcg)
fcg *= 6; fcg *= 6;
#endif #endif
for (g = 0; g < 256; g++) // pixel 1 for (uint16_t g = 0; g < 256; g++) { // pixel 1
{ for (uint16_t h = 0; h < 256; h++) { // pixel 2
for (h = 0; h < 256; h++) // pixel 2
{
difference = (float) (h - g); difference = (float) (h - g);
diffg = difference; diffg = difference;
@@ -2332,18 +2340,18 @@ voodoo_generate_vb_filters(voodoo_t *voodoo, int fcr, int fcg)
static void static void
banshee_overlay_draw(svga_t *svga, int displine) banshee_overlay_draw(svga_t *svga, int displine)
{ {
banshee_t *banshee = (banshee_t *) svga->priv; banshee_t *banshee = (banshee_t *) svga->priv;
voodoo_t *voodoo = banshee->voodoo; voodoo_t *voodoo = banshee->voodoo;
uint32_t *p; uint32_t *p;
int x; int x;
int y = voodoo->overlay.src_y >> 20; int y = voodoo->overlay.src_y >> 20;
uint32_t src_addr = svga->overlay_latch.addr + ((banshee->vidProcCfg & VIDPROCCFG_OVERLAY_TILE) ? ((y & 31) * 128 + (y >> 5) * svga->overlay_latch.pitch) : y * svga->overlay_latch.pitch); uint32_t src_addr = svga->overlay_latch.addr + ((banshee->vidProcCfg & VIDPROCCFG_OVERLAY_TILE) ? ((y & 31) * 128 + (y >> 5) * svga->overlay_latch.pitch) : y * svga->overlay_latch.pitch);
uint32_t src_addr2 = svga->overlay_latch.addr + ((banshee->vidProcCfg & VIDPROCCFG_OVERLAY_TILE) ? (((y + 1) & 31) * 128 + ((y + 1) >> 5) * svga->overlay_latch.pitch) : (y + 1) * svga->overlay_latch.pitch); uint32_t src_addr2 = svga->overlay_latch.addr + ((banshee->vidProcCfg & VIDPROCCFG_OVERLAY_TILE) ? (((y + 1) & 31) * 128 + ((y + 1) >> 5) * svga->overlay_latch.pitch) : (y + 1) * svga->overlay_latch.pitch);
uint8_t *src = &svga->vram[src_addr & svga->vram_mask]; uint8_t *src = &svga->vram[src_addr & svga->vram_mask];
uint32_t src_x = 0; uint32_t src_x = 0;
unsigned int y_coeff = (voodoo->overlay.src_y & 0xfffff) >> 4; unsigned int y_coeff = (voodoo->overlay.src_y & 0xfffff) >> 4;
int skip_filtering; int skip_filtering;
uint32_t *clut = &svga->pallook[(banshee->vidProcCfg & VIDPROCCFG_OVERLAY_CLUT_SEL) ? 256 : 0]; const uint32_t *clut = &svga->pallook[(banshee->vidProcCfg & VIDPROCCFG_OVERLAY_CLUT_SEL) ? 256 : 0];
if (svga->render == svga_render_null && !svga->changedvram[src_addr >> 12] && !svga->changedvram[src_addr2 >> 12] && !svga->fullchange && ((voodoo->overlay.src_y >> 20) < 2048 && !voodoo->dirty_line[voodoo->overlay.src_y >> 20]) && !(banshee->vidProcCfg & VIDPROCCFG_V_SCALE_ENABLE)) { if (svga->render == svga_render_null && !svga->changedvram[src_addr >> 12] && !svga->changedvram[src_addr2 >> 12] && !svga->fullchange && ((voodoo->overlay.src_y >> 20) < 2048 && !voodoo->dirty_line[voodoo->overlay.src_y >> 20]) && !(banshee->vidProcCfg & VIDPROCCFG_V_SCALE_ENABLE)) {
voodoo->overlay.src_y += (1 << 20); voodoo->overlay.src_y += (1 << 20);
@@ -2357,7 +2365,7 @@ banshee_overlay_draw(svga_t *svga, int displine)
if (src_addr >= 0x800000) if (src_addr >= 0x800000)
fatal("overlay out of range!\n"); fatal("overlay out of range!\n");
#endif #endif
p = &((uint32_t *) svga->monitor->target_buffer->line[displine])[svga->overlay_latch.x + svga->x_add]; p = &(svga->monitor->target_buffer->line[displine])[svga->overlay_latch.x + svga->x_add];
if (banshee->voodoo->scrfilter && banshee->voodoo->scrfilterEnabled) if (banshee->voodoo->scrfilter && banshee->voodoo->scrfilterEnabled)
skip_filtering = ((banshee->vidProcCfg & VIDPROCCFG_FILTER_MODE_MASK) != VIDPROCCFG_FILTER_MODE_BILINEAR && !(banshee->vidProcCfg & VIDPROCCFG_H_SCALE_ENABLE) && !(banshee->vidProcCfg & VIDPROCCFG_FILTER_MODE_DITHER_4X4) && !(banshee->vidProcCfg & VIDPROCCFG_FILTER_MODE_DITHER_2X2)); skip_filtering = ((banshee->vidProcCfg & VIDPROCCFG_FILTER_MODE_MASK) != VIDPROCCFG_FILTER_MODE_BILINEAR && !(banshee->vidProcCfg & VIDPROCCFG_H_SCALE_ENABLE) && !(banshee->vidProcCfg & VIDPROCCFG_FILTER_MODE_DITHER_4X4) && !(banshee->vidProcCfg & VIDPROCCFG_FILTER_MODE_DITHER_2X2));
@@ -2611,7 +2619,7 @@ banshee_vsync_callback(svga_t *svga)
static uint8_t static uint8_t
banshee_pci_read(int func, int addr, void *priv) banshee_pci_read(int func, int addr, void *priv)
{ {
banshee_t *banshee = (banshee_t *) priv; const banshee_t *banshee = (banshee_t *) priv;
#if 0 #if 0
svga_t *svga = &banshee->svga; svga_t *svga = &banshee->svga;
#endif #endif
@@ -2806,6 +2814,9 @@ banshee_pci_read(int func, int addr, void *priv)
case 0x67: case 0x67:
ret = banshee->pci_regs[0x67]; ret = banshee->pci_regs[0x67];
break; break;
default:
break;
} }
#if 0 #if 0
banshee_log("%02X\n", ret); banshee_log("%02X\n", ret);
@@ -2935,6 +2946,9 @@ banshee_pci_write(int func, int addr, uint8_t val, void *priv)
case 0x66: case 0x66:
banshee->pci_regs[0x66] = val & 0xc0; banshee->pci_regs[0x66] = val & 0xc0;
return; return;
default:
break;
} }
} }
@@ -3244,6 +3258,9 @@ banshee_init_common(const device_t *info, char *fn, int has_sgram, int type, int
banshee->pci_regs[0x2e] = 0x54; banshee->pci_regs[0x2e] = 0x54;
banshee->pci_regs[0x2f] = 0x00; banshee->pci_regs[0x2f] = 0x00;
break; break;
default:
break;
} }
video_inform(VIDEO_FLAG_TYPE_SPECIAL, banshee->agp ? &timing_banshee_agp : &timing_banshee); video_inform(VIDEO_FLAG_TYPE_SPECIAL, banshee->agp ? &timing_banshee_agp : &timing_banshee);

View File

@@ -250,6 +250,9 @@ PLOT(voodoo_t *voodoo, int x, int y, int pat_x, int pat_y, uint8_t pattern_mask,
voodoo->changedvram[addr >> 12] = changeframecount; voodoo->changedvram[addr >> 12] = changeframecount;
break; break;
} }
default:
break;
} }
} }
@@ -293,6 +296,9 @@ PLOT_LINE(voodoo_t *voodoo, int x, int y, UNUSED(uint8_t rop), uint32_t pattern,
voodoo->changedvram[addr >> 12] = changeframecount; voodoo->changedvram[addr >> 12] = changeframecount;
break; break;
} }
default:
break;
} }
} }
@@ -364,6 +370,9 @@ update_src_stride(voodoo_t *voodoo)
bansheeblt_log("Dword packing %08x %08x\n", voodoo->banshee_blt.src_stride_dest, voodoo->banshee_blt.host_data_size_dest); bansheeblt_log("Dword packing %08x %08x\n", voodoo->banshee_blt.src_stride_dest, voodoo->banshee_blt.host_data_size_dest);
#endif #endif
break; break;
default:
break;
} }
} }
@@ -385,12 +394,12 @@ end_command(voodoo_t *voodoo)
static void static void
banshee_do_rectfill(voodoo_t *voodoo) banshee_do_rectfill(voodoo_t *voodoo)
{ {
clip_t *clip = &voodoo->banshee_blt.clip[(voodoo->banshee_blt.command & COMMAND_CLIP_SEL) ? 1 : 0]; const clip_t *clip = &voodoo->banshee_blt.clip[(voodoo->banshee_blt.command & COMMAND_CLIP_SEL) ? 1 : 0];
int dst_y = voodoo->banshee_blt.dstY; int dst_y = voodoo->banshee_blt.dstY;
uint8_t *pattern_mono = (uint8_t *) voodoo->banshee_blt.colorPattern; const uint8_t *pattern_mono = (uint8_t *) voodoo->banshee_blt.colorPattern;
int pat_y = (voodoo->banshee_blt.commandExtra & CMDEXTRA_FORCE_PAT_ROW0) ? 0 : (voodoo->banshee_blt.patoff_y + voodoo->banshee_blt.dstY); int pat_y = (voodoo->banshee_blt.commandExtra & CMDEXTRA_FORCE_PAT_ROW0) ? 0 : (voodoo->banshee_blt.patoff_y + voodoo->banshee_blt.dstY);
int use_pattern_trans = (voodoo->banshee_blt.command & (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO)) == (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO); int use_pattern_trans = (voodoo->banshee_blt.command & (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO)) == (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO);
uint8_t rop = voodoo->banshee_blt.command >> 24; uint8_t rop = voodoo->banshee_blt.command >> 24;
#if 0 #if 0
bansheeblt_log("banshee_do_rectfill: size=%i,%i dst=%i,%i\n", voodoo->banshee_blt.dstSizeX, voodoo->banshee_blt.dstSizeY, voodoo->banshee_blt.dstX, voodoo->banshee_blt.dstY); bansheeblt_log("banshee_do_rectfill: size=%i,%i dst=%i,%i\n", voodoo->banshee_blt.dstSizeX, voodoo->banshee_blt.dstSizeY, voodoo->banshee_blt.dstX, voodoo->banshee_blt.dstY);
@@ -519,13 +528,13 @@ DECODE_YUYV422_16BPP(uint16_t *buf, uint8_t *src)
static void static void
do_screen_to_screen_line(voodoo_t *voodoo, uint8_t *src_p, int use_x_dir, int src_x, int src_tiled) do_screen_to_screen_line(voodoo_t *voodoo, uint8_t *src_p, int use_x_dir, int src_x, int src_tiled)
{ {
clip_t *clip = &voodoo->banshee_blt.clip[(voodoo->banshee_blt.command & COMMAND_CLIP_SEL) ? 1 : 0]; const clip_t *clip = &voodoo->banshee_blt.clip[(voodoo->banshee_blt.command & COMMAND_CLIP_SEL) ? 1 : 0];
int dst_y = voodoo->banshee_blt.dstY; int dst_y = voodoo->banshee_blt.dstY;
int pat_y = (voodoo->banshee_blt.commandExtra & CMDEXTRA_FORCE_PAT_ROW0) ? 0 : (voodoo->banshee_blt.patoff_y + voodoo->banshee_blt.dstY); int pat_y = (voodoo->banshee_blt.commandExtra & CMDEXTRA_FORCE_PAT_ROW0) ? 0 : (voodoo->banshee_blt.patoff_y + voodoo->banshee_blt.dstY);
uint8_t *pattern_mono = (uint8_t *) voodoo->banshee_blt.colorPattern; const uint8_t *pattern_mono = (uint8_t *) voodoo->banshee_blt.colorPattern;
int use_pattern_trans = (voodoo->banshee_blt.command & (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO)) == (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO); int use_pattern_trans = (voodoo->banshee_blt.command & (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO)) == (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO);
uint8_t rop = voodoo->banshee_blt.command >> 24; uint8_t rop = voodoo->banshee_blt.command >> 24;
int src_colorkey; int src_colorkey;
switch (voodoo->banshee_blt.srcFormat & SRC_FORMAT_COL_MASK) { switch (voodoo->banshee_blt.srcFormat & SRC_FORMAT_COL_MASK) {
case SRC_FORMAT_COL_8_BPP: case SRC_FORMAT_COL_8_BPP:
@@ -601,6 +610,9 @@ do_screen_to_screen_line(voodoo_t *voodoo, uint8_t *src_p, int use_x_dir, int sr
voodoo->changedvram[dst_addr >> 12] = changeframecount; voodoo->changedvram[dst_addr >> 12] = changeframecount;
break; break;
} }
default:
break;
} }
} }
if (use_x_dir) { if (use_x_dir) {
@@ -619,7 +631,9 @@ do_screen_to_screen_line(voodoo_t *voodoo, uint8_t *src_p, int use_x_dir, int sr
} else { } else {
/*Conversion required*/ /*Conversion required*/
if (dst_y >= clip->y_min && dst_y < clip->y_max) { if (dst_y >= clip->y_min && dst_y < clip->y_max) {
// int src_x = voodoo->banshee_blt.srcX; #if 0
int src_x = voodoo->banshee_blt.srcX;
#endif
int dst_x = voodoo->banshee_blt.dstX; int dst_x = voodoo->banshee_blt.dstX;
int pat_x = voodoo->banshee_blt.patoff_x + voodoo->banshee_blt.dstX; int pat_x = voodoo->banshee_blt.patoff_x + voodoo->banshee_blt.dstX;
uint8_t pattern_mask = pattern_mono[pat_y & 7]; uint8_t pattern_mask = pattern_mono[pat_y & 7];
@@ -777,7 +791,7 @@ banshee_do_screen_to_screen_blt(voodoo_t *voodoo)
} }
static void static void
banshee_do_host_to_screen_blt(voodoo_t *voodoo, int count, uint32_t data) banshee_do_host_to_screen_blt(voodoo_t *voodoo, UNUSED(int count), uint32_t data)
{ {
#if 0 #if 0
if (voodoo->banshee_blt.dstBaseAddr == 0xee5194) if (voodoo->banshee_blt.dstBaseAddr == 0xee5194)
@@ -849,15 +863,15 @@ banshee_do_host_to_screen_blt(voodoo_t *voodoo, int count, uint32_t data)
static void static void
do_screen_to_screen_stretch_line(voodoo_t *voodoo, uint8_t *src_p, int src_x, int *src_y) do_screen_to_screen_stretch_line(voodoo_t *voodoo, uint8_t *src_p, int src_x, int *src_y)
{ {
clip_t *clip = &voodoo->banshee_blt.clip[(voodoo->banshee_blt.command & COMMAND_CLIP_SEL) ? 1 : 0]; const clip_t *clip = &voodoo->banshee_blt.clip[(voodoo->banshee_blt.command & COMMAND_CLIP_SEL) ? 1 : 0];
#if 0 #if 0
int src_y = voodoo->banshee_blt.srcY; int src_y = voodoo->banshee_blt.srcY;
#endif #endif
int dst_y = voodoo->banshee_blt.dstY; int dst_y = voodoo->banshee_blt.dstY;
int pat_y = (voodoo->banshee_blt.commandExtra & CMDEXTRA_FORCE_PAT_ROW0) ? 0 : (voodoo->banshee_blt.patoff_y + voodoo->banshee_blt.dstY); int pat_y = (voodoo->banshee_blt.commandExtra & CMDEXTRA_FORCE_PAT_ROW0) ? 0 : (voodoo->banshee_blt.patoff_y + voodoo->banshee_blt.dstY);
uint8_t *pattern_mono = (uint8_t *) voodoo->banshee_blt.colorPattern; const uint8_t *pattern_mono = (uint8_t *) voodoo->banshee_blt.colorPattern;
int use_pattern_trans = (voodoo->banshee_blt.command & (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO)) == (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO); int use_pattern_trans = (voodoo->banshee_blt.command & (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO)) == (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO);
uint32_t *colorPattern = voodoo->banshee_blt.colorPattern; const uint32_t *colorPattern = voodoo->banshee_blt.colorPattern;
#if 0 #if 0
int error_y = voodoo->banshee_blt.dstSizeY / 2; int error_y = voodoo->banshee_blt.dstSizeY / 2;
@@ -891,7 +905,9 @@ do_screen_to_screen_stretch_line(voodoo_t *voodoo, uint8_t *src_p, int src_x, in
uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : colorPattern[(pat_x & 7) + (pat_y & 7) * 8]; uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : colorPattern[(pat_x & 7) + (pat_y & 7) * 8];
voodoo->vram[dst_addr] = MIX(voodoo, dest, src, pattern, COLORKEY_8, COLORKEY_8); voodoo->vram[dst_addr] = MIX(voodoo, dest, src, pattern, COLORKEY_8, COLORKEY_8);
// bansheeblt_log("%i,%i : sdp=%02x,%02x,%02x res=%02x\n", voodoo->banshee_blt.cur_x, voodoo->banshee_blt.cur_y, src, dest, pattern, voodoo->vram[dst_addr]); #if 0
bansheeblt_log("%i,%i : sdp=%02x,%02x,%02x res=%02x\n", voodoo->banshee_blt.cur_x, voodoo->banshee_blt.cur_y, src, dest, pattern, voodoo->vram[dst_addr]);
#endif
voodoo->changedvram[dst_addr >> 12] = changeframecount; voodoo->changedvram[dst_addr >> 12] = changeframecount;
break; break;
} }
@@ -937,6 +953,9 @@ do_screen_to_screen_stretch_line(voodoo_t *voodoo, uint8_t *src_p, int src_x, in
voodoo->changedvram[dst_addr >> 12] = changeframecount; voodoo->changedvram[dst_addr >> 12] = changeframecount;
break; break;
} }
default:
break;
} }
} }
@@ -1063,16 +1082,16 @@ step_line(voodoo_t *voodoo)
static void static void
banshee_do_line(voodoo_t *voodoo, int draw_last_pixel) banshee_do_line(voodoo_t *voodoo, int draw_last_pixel)
{ {
clip_t *clip = &voodoo->banshee_blt.clip[(voodoo->banshee_blt.command & COMMAND_CLIP_SEL) ? 1 : 0]; const clip_t *clip = &voodoo->banshee_blt.clip[(voodoo->banshee_blt.command & COMMAND_CLIP_SEL) ? 1 : 0];
uint8_t rop = voodoo->banshee_blt.command >> 24; uint8_t rop = voodoo->banshee_blt.command >> 24;
int dx = ABS(voodoo->banshee_blt.dstX - voodoo->banshee_blt.srcX); int dx = ABS(voodoo->banshee_blt.dstX - voodoo->banshee_blt.srcX);
int dy = ABS(voodoo->banshee_blt.dstY - voodoo->banshee_blt.srcY); int dy = ABS(voodoo->banshee_blt.dstY - voodoo->banshee_blt.srcY);
int x_inc = (voodoo->banshee_blt.dstX > voodoo->banshee_blt.srcX) ? 1 : -1; int x_inc = (voodoo->banshee_blt.dstX > voodoo->banshee_blt.srcX) ? 1 : -1;
int y_inc = (voodoo->banshee_blt.dstY > voodoo->banshee_blt.srcY) ? 1 : -1; int y_inc = (voodoo->banshee_blt.dstY > voodoo->banshee_blt.srcY) ? 1 : -1;
int x = voodoo->banshee_blt.srcX; int x = voodoo->banshee_blt.srcX;
int y = voodoo->banshee_blt.srcY; int y = voodoo->banshee_blt.srcY;
int error; int error;
uint32_t stipple = (voodoo->banshee_blt.command & COMMAND_STIPPLE_LINE) ? voodoo->banshee_blt.lineStipple : ~0; uint32_t stipple = (voodoo->banshee_blt.command & COMMAND_STIPPLE_LINE) ? voodoo->banshee_blt.lineStipple : ~0;
if (dx > dy) /*X major*/ if (dx > dy) /*X major*/
{ {
@@ -1143,12 +1162,12 @@ banshee_polyfill_start(voodoo_t *voodoo)
static void static void
banshee_polyfill_continue(voodoo_t *voodoo, uint32_t data) banshee_polyfill_continue(voodoo_t *voodoo, uint32_t data)
{ {
clip_t *clip = &voodoo->banshee_blt.clip[(voodoo->banshee_blt.command & COMMAND_CLIP_SEL) ? 1 : 0]; const clip_t *clip = &voodoo->banshee_blt.clip[(voodoo->banshee_blt.command & COMMAND_CLIP_SEL) ? 1 : 0];
uint8_t *pattern_mono = (uint8_t *) voodoo->banshee_blt.colorPattern; const uint8_t *pattern_mono = (uint8_t *) voodoo->banshee_blt.colorPattern;
int use_pattern_trans = (voodoo->banshee_blt.command & (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO)) == (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO); int use_pattern_trans = (voodoo->banshee_blt.command & (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO)) == (COMMAND_PATTERN_MONO | COMMAND_TRANS_MONO);
uint8_t rop = voodoo->banshee_blt.command >> 24; uint8_t rop = voodoo->banshee_blt.command >> 24;
int y = MAX(voodoo->banshee_blt.ly[0], voodoo->banshee_blt.ry[0]); int y = MAX(voodoo->banshee_blt.ly[0], voodoo->banshee_blt.ry[0]);
int y_end; int y_end;
#if 0 #if 0
bansheeblt_log("Polyfill : data %08x\n", data); bansheeblt_log("Polyfill : data %08x\n", data);

View File

@@ -163,8 +163,6 @@ voodoo_v2_blit_start(voodoo_t *voodoo)
int dst_stride = (voodoo->bltCommand & BLTCMD_DST_TILED) ? ((voodoo->bltDstXYStride & 0x3f) * 32 * 2) : (voodoo->bltDstXYStride & 0xff8); int dst_stride = (voodoo->bltCommand & BLTCMD_DST_TILED) ? ((voodoo->bltDstXYStride & 0x3f) * 32 * 2) : (voodoo->bltDstXYStride & 0xff8);
uint32_t src_base_addr = (voodoo->bltCommand & BLTCMD_SRC_TILED) ? ((voodoo->bltSrcBaseAddr & 0x3ff) << 12) : (voodoo->bltSrcBaseAddr & 0x3ffff8); uint32_t src_base_addr = (voodoo->bltCommand & BLTCMD_SRC_TILED) ? ((voodoo->bltSrcBaseAddr & 0x3ff) << 12) : (voodoo->bltSrcBaseAddr & 0x3ffff8);
uint32_t dst_base_addr = (voodoo->bltCommand & BLTCMD_DST_TILED) ? ((voodoo->bltDstBaseAddr & 0x3ff) << 12) : (voodoo->bltDstBaseAddr & 0x3ffff8); uint32_t dst_base_addr = (voodoo->bltCommand & BLTCMD_DST_TILED) ? ((voodoo->bltDstBaseAddr & 0x3ff) << 12) : (voodoo->bltDstBaseAddr & 0x3ffff8);
int x;
int y;
#if 0 #if 0
voodooblt_log("blit_start: command=%08x srcX=%i srcY=%i dstX=%i dstY=%i sizeX=%i sizeY=%i color=%04x,%04x\n", voodooblt_log("blit_start: command=%08x srcX=%i srcY=%i dstX=%i dstY=%i sizeX=%i sizeY=%i color=%04x,%04x\n",
@@ -175,13 +173,13 @@ voodoo_v2_blit_start(voodoo_t *voodoo)
switch (voodoo->bltCommand & BLIT_COMMAND_MASK) { switch (voodoo->bltCommand & BLIT_COMMAND_MASK) {
case BLIT_COMMAND_SCREEN_TO_SCREEN: case BLIT_COMMAND_SCREEN_TO_SCREEN:
for (y = 0; y <= size_y; y++) { for (int y = 0; y <= size_y; y++) {
uint16_t *src = (uint16_t *) &voodoo->fb_mem[src_base_addr + src_y * src_stride]; const uint16_t *src = (uint16_t *) &voodoo->fb_mem[src_base_addr + src_y * src_stride];
uint16_t *dst = (uint16_t *) &voodoo->fb_mem[dst_base_addr + dst_y * dst_stride]; uint16_t *dst = (uint16_t *) &voodoo->fb_mem[dst_base_addr + dst_y * dst_stride];
int src_x = voodoo->bltSrcX; int src_x = voodoo->bltSrcX;
int dst_x = voodoo->bltDstX; int dst_x = voodoo->bltDstX;
for (x = 0; x <= size_x; x++) { for (int x = 0; x <= size_x; x++) {
uint16_t src_dat = src[src_x]; uint16_t src_dat = src[src_x];
uint16_t dst_dat = dst[dst_x]; uint16_t dst_dat = dst[dst_x];
int rop = 0; int rop = 0;
@@ -233,7 +231,7 @@ skip_pixel_blit:
break; break;
case BLIT_COMMAND_RECT_FILL: case BLIT_COMMAND_RECT_FILL:
for (y = 0; y <= size_y; y++) { for (int y = 0; y <= size_y; y++) {
uint16_t *dst; uint16_t *dst;
int dst_x = voodoo->bltDstX; int dst_x = voodoo->bltDstX;
@@ -244,7 +242,7 @@ skip_pixel_blit:
} else } else
dst = (uint16_t *) &voodoo->fb_mem[dst_base_addr + dst_y * dst_stride]; dst = (uint16_t *) &voodoo->fb_mem[dst_base_addr + dst_y * dst_stride];
for (x = 0; x <= size_x; x++) { for (int x = 0; x <= size_x; x++) {
if (voodoo->bltCommand & BLIT_CLIPPING_ENABLED) { if (voodoo->bltCommand & BLIT_CLIPPING_ENABLED) {
if (dst_x < voodoo->bltClipLeft || dst_x >= voodoo->bltClipRight || dst_y < voodoo->bltClipLowY || dst_y >= voodoo->bltClipHighY) if (dst_x < voodoo->bltClipLeft || dst_x >= voodoo->bltClipRight || dst_y < voodoo->bltClipLowY || dst_y >= voodoo->bltClipHighY)
goto skip_pixel_fill; goto skip_pixel_fill;
@@ -267,7 +265,7 @@ skip_line_fill:
dat64 = voodoo->bltColorFg | ((uint64_t) voodoo->bltColorFg << 16) | ((uint64_t) voodoo->bltColorFg << 32) | ((uint64_t) voodoo->bltColorFg << 48); dat64 = voodoo->bltColorFg | ((uint64_t) voodoo->bltColorFg << 16) | ((uint64_t) voodoo->bltColorFg << 32) | ((uint64_t) voodoo->bltColorFg << 48);
for (y = 0; y <= size_y; y++) { for (int y = 0; y <= size_y; y++) {
uint64_t *dst; uint64_t *dst;
/*This may be wrong*/ /*This may be wrong*/
@@ -284,7 +282,7 @@ skip_line_fill:
dst = (uint64_t *) &voodoo->fb_mem[(dst_y * 512 * 8 + dst_x * 8) & voodoo->fb_mask]; dst = (uint64_t *) &voodoo->fb_mem[(dst_y * 512 * 8 + dst_x * 8) & voodoo->fb_mask];
for (x = 0; x <= size_x; x++) for (int x = 0; x <= size_x; x++)
dst[x] = dat64; dst[x] = dat64;
dst_y++; dst_y++;
@@ -347,6 +345,9 @@ voodoo_v2_blit_data(voodoo_t *voodoo, uint32_t data)
case BLIT_SRC_RGB_BGRA: case BLIT_SRC_RGB_BGRA:
src_dat = ((data & 0xf800) >> 11) | (data & 0x07c0) | ((data & 0x0038) << 11); src_dat = ((data & 0xf800) >> 11) | (data & 0x07c0) | ((data & 0x0038) << 11);
break; break;
default:
break;
} }
data >>= 16; data >>= 16;
src_bits -= 16; src_bits -= 16;
@@ -375,6 +376,9 @@ voodoo_v2_blit_data(voodoo_t *voodoo, uint32_t data)
g = (data >> 16) & 0xff; g = (data >> 16) & 0xff;
b = (data >> 24) & 0xff; b = (data >> 24) & 0xff;
break; break;
default:
break;
} }
switch (voodoo->bltCommand & BLIT_SRC_FORMAT) { switch (voodoo->bltCommand & BLIT_SRC_FORMAT) {
case BLIT_SRC_24BPP: case BLIT_SRC_24BPP:
@@ -392,9 +396,15 @@ voodoo_v2_blit_data(voodoo_t *voodoo, uint32_t data)
b = dither_rb[b][voodoo->blt.dst_y & 3][x & 3]; b = dither_rb[b][voodoo->blt.dst_y & 3][x & 3];
src_dat = (b >> 3) | ((g & 0xfc) << 3) | ((r & 0xf8) << 8); src_dat = (b >> 3) | ((g & 0xfc) << 3) | ((r & 0xf8) << 8);
break; break;
default:
break;
} }
src_bits = 0; src_bits = 0;
break; break;
default:
break;
} }
if (SLI_ENABLED) { if (SLI_ENABLED) {

View File

@@ -509,8 +509,8 @@ voodoo_filterline_v2(voodoo_t *voodoo, uint8_t *fil, int column, uint16_t *src,
void void
voodoo_callback(void *priv) voodoo_callback(void *priv)
{ {
voodoo_t *voodoo = (voodoo_t *) priv; voodoo_t *voodoo = (voodoo_t *) priv;
monitor_t *monitor = &monitors[voodoo->monitor_index]; const monitor_t *monitor = &monitors[voodoo->monitor_index];
if (voodoo->fbiInit0 & FBIINIT0_VGA_PASS) { if (voodoo->fbiInit0 & FBIINIT0_VGA_PASS) {
if (voodoo->line < voodoo->v_disp) { if (voodoo->line < voodoo->v_disp) {

View File

@@ -76,7 +76,7 @@ voodoo_fb_readw(uint32_t addr, void *priv)
} }
if (SLI_ENABLED) { if (SLI_ENABLED) {
voodoo_set_t *set = voodoo->set; const voodoo_set_t *set = voodoo->set;
if (y & 1) if (y & 1)
voodoo = set->voodoos[1]; voodoo = set->voodoos[1];
@@ -117,7 +117,7 @@ voodoo_fb_readl(uint32_t addr, void *priv)
} }
if (SLI_ENABLED) { if (SLI_ENABLED) {
voodoo_set_t *set = voodoo->set; const voodoo_set_t *set = voodoo->set;
if (y & 1) if (y & 1)
voodoo = set->voodoos[1]; voodoo = set->voodoos[1];
@@ -170,16 +170,16 @@ do_dither(voodoo_params_t *params, rgba8_t col, int x, int y)
void void
voodoo_fb_writew(uint32_t addr, uint16_t val, void *priv) voodoo_fb_writew(uint32_t addr, uint16_t val, void *priv)
{ {
voodoo_t *voodoo = (voodoo_t *) priv; voodoo_t *voodoo = (voodoo_t *) priv;
voodoo_params_t *params = &voodoo->params; const voodoo_params_t *params = &voodoo->params;
int x; int x;
int y; int y;
uint32_t write_addr; uint32_t write_addr;
uint32_t write_addr_aux; uint32_t write_addr_aux;
rgba8_t colour_data; rgba8_t colour_data;
uint16_t depth_data; uint16_t depth_data;
uint8_t alpha_data; uint8_t alpha_data;
int write_mask = 0; int write_mask = 0;
colour_data.r = colour_data.g = colour_data.b = colour_data.a = 0; colour_data.r = colour_data.g = colour_data.b = colour_data.a = 0;
@@ -310,17 +310,17 @@ skip_pixel:
void void
voodoo_fb_writel(uint32_t addr, uint32_t val, void *priv) voodoo_fb_writel(uint32_t addr, uint32_t val, void *priv)
{ {
voodoo_t *voodoo = (voodoo_t *) priv; voodoo_t *voodoo = (voodoo_t *) priv;
voodoo_params_t *params = &voodoo->params; const voodoo_params_t *params = &voodoo->params;
int x; int x;
int y; int y;
uint32_t write_addr; uint32_t write_addr;
uint32_t write_addr_aux; uint32_t write_addr_aux;
rgba8_t colour_data[2]; rgba8_t colour_data[2];
uint16_t depth_data[2]; uint16_t depth_data[2];
uint8_t alpha_data[2]; uint8_t alpha_data[2];
int write_mask = 0; int write_mask = 0;
int count = 1; int count = 1;
depth_data[0] = depth_data[1] = voodoo->params.zaColor & 0xffff; depth_data[0] = depth_data[1] = voodoo->params.zaColor & 0xffff;
alpha_data[0] = alpha_data[1] = voodoo->params.zaColor >> 24; alpha_data[0] = alpha_data[1] = voodoo->params.zaColor >> 24;

View File

@@ -1121,6 +1121,7 @@ voodoo_reg_writel(uint32_t addr, uint32_t val, void *priv)
} }
break; break;
} }
[[fallthrough]];
case SST_nccTable0_I2: case SST_nccTable0_I2:
if (!(val & (1 << 31))) { if (!(val & (1 << 31))) {
if (chip & CHIP_TREX0) { if (chip & CHIP_TREX0) {
@@ -1359,5 +1360,8 @@ voodoo_reg_writel(uint32_t addr, uint32_t val, void *priv)
case SST_leftOverlayBuf: case SST_leftOverlayBuf:
voodoo->leftOverlayBuf = val; voodoo->leftOverlayBuf = val;
break; break;
default:
break;
} }
} }

View File

@@ -475,6 +475,9 @@ voodoo_tmu_fetch_and_blend(voodoo_t *voodoo, voodoo_params_t *params, voodoo_sta
case TC_MSELECT_LOD_FRAC: case TC_MSELECT_LOD_FRAC:
factor_r = factor_g = factor_b = state->lod_frac[1]; factor_r = factor_g = factor_b = state->lod_frac[1];
break; break;
default:
break;
} }
if (!c_reverse) { if (!c_reverse) {
r = (-state->tex_r[1] * (factor_r + 1)) >> 8; r = (-state->tex_r[1] * (factor_r + 1)) >> 8;
@@ -520,6 +523,9 @@ voodoo_tmu_fetch_and_blend(voodoo_t *voodoo, voodoo_params_t *params, voodoo_sta
case TCA_MSELECT_LOD_FRAC: case TCA_MSELECT_LOD_FRAC:
factor_a = state->lod_frac[1]; factor_a = state->lod_frac[1];
break; break;
default:
break;
} }
if (!a_reverse) if (!a_reverse)
a = (-state->tex_a[1] * ((factor_a ^ 0xff) + 1)) >> 8; a = (-state->tex_a[1] * ((factor_a ^ 0xff) + 1)) >> 8;
@@ -575,6 +581,9 @@ voodoo_tmu_fetch_and_blend(voodoo_t *voodoo, voodoo_params_t *params, voodoo_sta
case TC_MSELECT_LOD_FRAC: case TC_MSELECT_LOD_FRAC:
factor_r = factor_g = factor_b = state->lod_frac[0]; factor_r = factor_g = factor_b = state->lod_frac[0];
break; break;
default:
break;
} }
if (!c_reverse) { if (!c_reverse) {
r = (r * (factor_r + 1)) >> 8; r = (r * (factor_r + 1)) >> 8;
@@ -622,6 +631,9 @@ voodoo_tmu_fetch_and_blend(voodoo_t *voodoo, voodoo_params_t *params, voodoo_sta
case TCA_MSELECT_LOD_FRAC: case TCA_MSELECT_LOD_FRAC:
factor_a = state->lod_frac[0]; factor_a = state->lod_frac[0];
break; break;
default:
break;
} }
if (a_reverse) if (a_reverse)
a = (a * ((factor_a ^ 0xff) + 1)) >> 8; a = (a * ((factor_a ^ 0xff) + 1)) >> 8;
@@ -1073,6 +1085,9 @@ voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t *
cother_g = src_g; cother_g = src_g;
cother_b = src_b; cother_b = src_b;
break; break;
default:
break;
} }
switch (cca_localselect) { switch (cca_localselect) {
@@ -1460,15 +1475,15 @@ voodoo_triangle(voodoo_t *voodoo, voodoo_params_t *params, int odd_even)
vertexCy_adjusted = (state.vertexCy + 7) >> 4; vertexCy_adjusted = (state.vertexCy + 7) >> 4;
if (state.vertexBy - state.vertexAy) if (state.vertexBy - state.vertexAy)
state.dxAB = (int) ((((int64_t) state.vertexBx << 12) - ((int64_t) state.vertexAx << 12)) << 4) / (int) (state.vertexBy - state.vertexAy); state.dxAB = (int) ((((int64_t) state.vertexBx << 12) - ((int64_t) state.vertexAx << 12)) << 4) / (state.vertexBy - state.vertexAy);
else else
state.dxAB = 0; state.dxAB = 0;
if (state.vertexCy - state.vertexAy) if (state.vertexCy - state.vertexAy)
state.dxAC = (int) ((((int64_t) state.vertexCx << 12) - ((int64_t) state.vertexAx << 12)) << 4) / (int) (state.vertexCy - state.vertexAy); state.dxAC = (int) ((((int64_t) state.vertexCx << 12) - ((int64_t) state.vertexAx << 12)) << 4) / (state.vertexCy - state.vertexAy);
else else
state.dxAC = 0; state.dxAC = 0;
if (state.vertexCy - state.vertexBy) if (state.vertexCy - state.vertexBy)
state.dxBC = (int) ((((int64_t) state.vertexCx << 12) - ((int64_t) state.vertexBx << 12)) << 4) / (int) (state.vertexCy - state.vertexBy); state.dxBC = (int) ((((int64_t) state.vertexCx << 12) - ((int64_t) state.vertexBx << 12)) << 4) / (state.vertexCy - state.vertexBy);
else else
state.dxBC = 0; state.dxBC = 0;

View File

@@ -192,7 +192,9 @@ voodoo_recalc_tex3(voodoo_t *voodoo, int tmu)
if ((voodoo->params.textureMode[tmu] & TEXTUREMODE_TRILINEAR) && (voodoo->params.tLOD[tmu] & LOD_ODD)) if ((voodoo->params.textureMode[tmu] & TEXTUREMODE_TRILINEAR) && (voodoo->params.tLOD[tmu] & LOD_ODD))
tex_lod++; /*Skip LOD 0*/ tex_lod++; /*Skip LOD 0*/
// voodoo_texture_log("TMU %i: %08x\n", tmu, voodoo->params.textureMode[tmu]); #if 0
voodoo_texture_log("TMU %i: %08x\n", tmu, voodoo->params.textureMode[tmu]);
#endif
for (lod = 0; lod <= LOD_MAX + 1; lod++) { for (lod = 0; lod <= LOD_MAX + 1; lod++) {
if (voodoo->params.tLOD[tmu] & LOD_TMULTIBASEADDR) { if (voodoo->params.tLOD[tmu] & LOD_TMULTIBASEADDR) {
switch (tex_lod) { switch (tex_lod) {
@@ -302,18 +304,22 @@ voodoo_use_texture(voodoo_t *voodoo, voodoo_params_t *params, int tmu)
lod_min = (params->tLOD[tmu] >> 2) & 15; lod_min = (params->tLOD[tmu] >> 2) & 15;
lod_max = (params->tLOD[tmu] >> 8) & 15; lod_max = (params->tLOD[tmu] >> 8) & 15;
// voodoo_texture_log(" add new texture to %i tformat=%i %08x LOD=%i-%i tmu=%i\n", c, voodoo->params.tformat[tmu], params->texBaseAddr[tmu], lod_min, lod_max, tmu); #if 0
voodoo_texture_log(" add new texture to %i tformat=%i %08x LOD=%i-%i tmu=%i\n", c, voodoo->params.tformat[tmu], params->texBaseAddr[tmu], lod_min, lod_max, tmu);
#endif
lod_min = MIN(lod_min, 8); lod_min = MIN(lod_min, 8);
lod_max = MIN(lod_max, 8); lod_max = MIN(lod_max, 8);
for (int lod = lod_min; lod <= lod_max; lod++) { for (int lod = lod_min; lod <= lod_max; lod++) {
uint32_t *base = &voodoo->texture_cache[tmu][c].data[texture_offset[lod]]; uint32_t *base = &voodoo->texture_cache[tmu][c].data[texture_offset[lod]];
uint32_t tex_addr = params->tex_base[tmu][lod] & voodoo->texture_mask; uint32_t tex_addr = params->tex_base[tmu][lod] & voodoo->texture_mask;
int x; int x;
int y; int y;
int shift = 8 - params->tex_lod[tmu][lod]; int shift = 8 - params->tex_lod[tmu][lod];
rgba_u *pal; const rgba_u *pal;
// voodoo_texture_log(" LOD %i : %08x - %08x %i %i,%i\n", lod, params->tex_base[tmu][lod] & voodoo->texture_mask, addr, voodoo->params.tformat[tmu], voodoo->params.tex_w_mask[tmu][lod],voodoo->params.tex_h_mask[tmu][lod]); #if 0
voodoo_texture_log(" LOD %i : %08x - %08x %i %i,%i\n", lod, params->tex_base[tmu][lod] & voodoo->texture_mask, addr, voodoo->params.tformat[tmu], voodoo->params.tex_w_mask[tmu][lod],voodoo->params.tex_h_mask[tmu][lod]);
#endif
switch (params->tformat[tmu]) { switch (params->tformat[tmu]) {
case TEX_RGB332: case TEX_RGB332:
@@ -566,7 +572,9 @@ flush_texture_cache(voodoo_t *voodoo, uint32_t dirty_addr, int tmu)
if (addr_end_masked < addr_start_masked) if (addr_end_masked < addr_start_masked)
addr_end_masked = voodoo->texture_mask + 1; addr_end_masked = voodoo->texture_mask + 1;
if (dirty_addr >= addr_start_masked && dirty_addr < addr_end_masked) { if (dirty_addr >= addr_start_masked && dirty_addr < addr_end_masked) {
// voodoo_texture_log(" Evict texture %i %08x\n", c, voodoo->texture_cache[tmu][c].base); #if 0
voodoo_texture_log(" Evict texture %i %08x\n", c, voodoo->texture_cache[tmu][c].base);
#endif
if (voodoo->texture_cache[tmu][c].refcount != voodoo->texture_cache[tmu][c].refcount_r[0] || (voodoo->render_threads == 2 && voodoo->texture_cache[tmu][c].refcount != voodoo->texture_cache[tmu][c].refcount_r[1])) if (voodoo->texture_cache[tmu][c].refcount != voodoo->texture_cache[tmu][c].refcount_r[0] || (voodoo->render_threads == 2 && voodoo->texture_cache[tmu][c].refcount != voodoo->texture_cache[tmu][c].refcount_r[1]))
wait_for_idle = 1; wait_for_idle = 1;