rem: LOG(8,("cmd 'calculate and set PLL 32bit REG $%08x for %fMHz'\n", reg, (data / 100.0)));
add: LOG(8,("cmd 'calculate and set PLL 32bit REG $%08x for %.3fMHz'\n", reg, (data / 100.0)));
context: static status_t exec_type1_script(uint8* rom, uint16 adress, int16* size){	status_t result = B_OK;	bool end = false;	bool exec = true;	uint8 index, byte, safe;	uint32 reg, data, data2, and_out, or_in, safe32;	LOG(8,("\nINFO: executing type1 script at adress $%04x...\n", adress));	while (!end)	{		LOG(8,("INFO: $%04x ($%02x); ", adress, rom[adress]));		//fixme: complete...		switch (rom[adress])		{		case 0x59:			*size -= 7;			if (*size < 0)			{				LOG(8,("script size error, aborting!\n\n"));				end = true;				result = B_ERROR;				break;			}			/* execute */			adress += 1;			reg = *((uint32*)(&(rom[adress])));			adress += 4;			data = *((uint16*)(&(rom[adress])));			adress += 2;			data2 = *((uint16*)(&(rom[data])));			LOG(8,("cmd 'calculate indirect and set PLL 32bit REG $%08x for %fMHz'\n",				reg, ((float)data2)));			if (exec)			{				//fixme: setup core and RAM PLL calc routine(s), now (mis)using DAC's...				display_mode target;				float calced_clk;				uint8 m, n, p;				target.timing.pixel_clock = (data2 * 1000);				nv_dac_pix_pll_find(target, &calced_clk, &m, &n, &p, 0);				NV_REG32(reg) = ((p << 16) | (n << 8) | m);//fixme?				/* program 2nd set N and M scalers if they exist (b31=1 enables them) *///				if ((si->ps.card_type == NV31) || (si->ps.card_type == NV36))//					DACW(PIXPLLC2, 0x80000401);			}			log_pll(reg);			break;		case 0x5a:			LOG(8,("xxx cmd, skipping...\n"));			*size -= 7;			if (*size < 0)			{				LOG(8,("script size error, aborting!\n\n"));				end = true;				result = B_ERROR;				break;			}			adress += 7;			break;		case 0x63:			LOG(8,("xxx cmd, skipping...\n"));			*size -= 1;			if (*size < 0)			{				LOG(8,("script size error, aborting!\n\n"));				end = true;				result = B_ERROR;				break;			}			adress += 1;			break;		case 0x65:			*size -= 13;			if (*size < 0)			{				LOG(8,("script size error, aborting!\n\n"));				end = true;				result = B_ERROR;				break;			}			/* execute */			adress += 1;			reg = *((uint32*)(&(rom[adress])));			adress += 4;			data = *((uint32*)(&(rom[adress])));			adress += 4;			data2 = *((uint32*)(&(rom[adress])));			adress += 4;			LOG(8,("cmd 'WR 32bit REG $%08x with $%08x, then with $%08x'\n", reg, data, data2));			if (exec)			{				/* alternate NV-specific access to PCI config space registers: */				safe32 = NV_REG32(0x00001800 + NVCFG_AGPCMD);				NV_REG32(0x00001800 + NVCFG_AGPCMD) = 0x00000000;				NV_REG32(reg) = data;				NV_REG32(reg) = data2;				NV_REG32(0x00001800 + NVCFG_AGPCMD) = safe32;				NV_REG32(0x00001800 + NVCFG_ROMSHADOW) &= 0xfffffffe;			}			break;		case 0x66: /* new on NV11 */			LOG(8,("NV11+ xxx cmd, skipping...\n"));			*size -= 1;			if (*size < 0)			{				LOG(8,("script size error, aborting!\n\n"));				end = true;				result = B_ERROR;				break;			}			adress += 1;			break;		case 0x67: /* new on NV11 */			LOG(8,("NV11+ xxx cmd, skipping...\n"));			*size -= 1;			if (*size < 0)			{				LOG(8,("script size error, aborting!\n\n"));				end = true;				result = B_ERROR;				break;			}			adress += 1;			break;		case 0x68: /* new on NV11 */			LOG(8,("NV11+ xxx cmd, skipping...\n"));			*size -= 1;			if (*size < 0)			{				LOG(8,("script size error, aborting!\n\n"));				end = true;				result = B_ERROR;				break;			}			adress += 1;			break;		case 0x6e:			*size -= 13;			if (*size < 0)			{				LOG(8,("script size error, aborting!\n\n"));				end = true;				result = B_ERROR;				break;			}			/* execute */			adress += 1;			reg = *((uint32*)(&(rom[adress])));			adress += 4;			and_out = *((uint32*)(&(rom[adress])));			adress += 4;			or_in = *((uint32*)(&(rom[adress])));			adress += 4;			LOG(8,("cmd 'RD 32bit REG $%08x, AND-out = $%08x, OR-in = $%08x, WR-bk'\n",				reg, and_out, or_in));			if (exec)			{				data = NV_REG32(reg);				data &= and_out;				data |= or_in;				NV_REG32(reg) = data;			}			break;		case 0x71:			LOG(8,("cmd 'END', execution completed.\n\n"));			end = true;			*size -= 1;			if (*size < 0)			{				LOG(8,("script size error!\n\n"));				result = B_ERROR;			}			break;		case 0x74:			*size -= 3;			if (*size < 0)			{				LOG(8,("script size error, aborting!\n\n"));				end = true;				result = B_ERROR;				break;			}			/* execute */			adress += 1;			data = *((uint16*)(&(rom[adress])));			adress += 2;			LOG(8,("cmd 'SNOOZE for %d ($%04x) microSeconds'\n", data, data));			if (exec) snooze(data);			break;		case 0x77:			*size -= 7;			if (*size < 0)			{				LOG(8,("script size error, aborting!\n\n"));				end = true;				result = B_ERROR;				break;			}			/* execute */			adress += 1;			reg = *((uint32*)(&(rom[adress])));			adress += 4;			data = *((uint16*)(&(rom[adress])));			adress += 2;			LOG(8,("cmd 'WR 32bit REG' $%08x = $%08x (b31-16 = '0', b15-0 = data)\n",				reg, data));			if (exec) NV_REG32(reg) = data;			break;		case 0x78:			*size -= 6;			if (*size < 0)			{				LOG(8,("script size error, aborting!\n\n"));				end = true;				result = B_ERROR;				break;			}			/* execute */			adress += 1;			reg = *((uint16*)(&(rom[adress])));			adress += 2;			index = *((uint8*)(&(rom[adress])));			adress += 1;			and_out = *((uint8*)(&(rom[adress])));			adress += 1;			or_in = *((uint8*)(&(rom[adress])));			adress += 1;			LOG(8,("cmd 'RD 8bit indexed REG $%02x via $%04x, AND-out = $%02x, OR-in = $%02x, WR-bk'\n",				index, reg, and_out, or_in));			if (exec)			{				safe = NV_REG8(0x00601000 + reg);				NV_REG8(0x00601000 + reg) = index;				byte = NV_REG8(0x00601000 + reg + 1);				byte &= (uint8)and_out;				byte |= (uint8)or_in;				NV_REG8(0x00601000 + reg + 1) = byte;				NV_REG8(0x00601000 + reg) = safe;			}			break;		case 0x79:			*size -= 7;			if (*size < 0)			{				LOG(8,("script size error, aborting!\n\n"));				end = true;				result = B_ERROR;				break;			}			/* execute */			adress += 1;			reg = *((uint32*)(&(rom[adress])));			adress += 4;			data = *((uint16*)(&(rom[adress])));			adress += 2;			LOG(8,("cmd 'calculate and set PLL 32bit REG $%08x for %fMHz'\n", reg, (data / 100.0)));			if (exec)			{				//fixme: setup core and RAM PLL calc routine(s), now (mis)using DAC's...				display_mode target;				float calced_clk;				uint8 m, n, p;				target.timing.pixel_clock = (data * 10);				nv_dac_pix_pll_find(target, &calced_clk, &m, &n, &p, 0);				NV_REG32(reg) = ((p << 16) | (n << 8) | m);//fixme?				/* program 2nd set N and M scalers if they exist (b31=1 enables them) *///				if ((si->ps.card_type == NV31) || (si->ps.card_type == NV36))//					DACW(PIXPLLC2, 0x80000401);			}			log_pll(reg);			break;		case 0x7a:			*size -= 9;			if (*size < 0)			{				LOG(8,("script size error, aborting!\n\n"));				end = true;				result = B_ERROR;				break;			}			/* execute */			adress += 1;			reg = *((uint32*)(&(rom[adress])));			adress += 4;			data = *((uint32*)(&(rom[adress])));			adress += 4;			LOG(8,("cmd 'WR 32bit REG' $%08x = $%08x\n", reg, data));			if (exec) NV_REG32(reg) = data;			break;		default:			LOG(8,("unknown cmd, aborting!\n\n"));			end = true;			result = B_ERROR;			break;		}	}	return result;}