示例#1
0
EXTROMH extromio_open(const OEMCHAR *filename, UINT type) {

	EXTROMH	ret;
	HRSRC	hrsrc;
	HGLOBAL hg;

	ret = (EXTROMH)_MALLOC(sizeof(_EXTROMH), filename);
	if (ret == NULL) {
		goto erope_err1;
	}
	ret->type = type;
	if (type == EXTROMIO_FILE) {
		ret->fh = (void *)file_open_c(filename);
		if ((FILEH)ret->fh != FILEH_INVALID) {
			return(ret);
		}
	}
	else if (type == EXTROMIO_RES) {
#if defined(OSLANG_UTF8)
		TCHAR tchr[MAX_PATH];
		oemtotchar(tchr, NELEMENTS(tchr), filename, -1);
		hrsrc = FindResource(hInst, tchr, str_extrom);
#else
		hrsrc = FindResource(hInst, filename, str_extrom);
#endif
		if (hrsrc) {
			hg = LoadResource(hInst, hrsrc);
			ret->fh = (void *)LockResource(hg);
			ret->pos = 0;
			ret->size = SizeofResource(hInst, hrsrc);
			return(ret);
		}
	}
	_MFREE(ret);

erope_err1:
	return(NULL);
}
示例#2
0
文件: bios.c 项目: LasDesu/np2debug
void bios_initialize(void) {

	BOOL	biosrom;
	OEMCHAR	path[MAX_PATH];
	FILEH	fh;
	UINT	i;
	UINT32	tmp;
	UINT	pos;

	biosrom = FALSE;
	getbiospath(path, str_biosrom, NELEMENTS(path));
	fh = file_open_rb(path);
	if (fh != FILEH_INVALID) {
		biosrom = (file_read(fh, mem + 0x0e8000, 0x18000) == 0x18000);
		file_close(fh);
	}
	if (biosrom) {
		TRACEOUT(("load bios.rom"));
		pccore.rom |= PCROM_BIOS;
		// PnP BIOSを潰す
		for (i=0; i<0x10000; i+=0x10) {
			tmp = LOADINTELDWORD(mem + 0xf0000 + i);
			if (tmp == 0x506e5024) {
				TRACEOUT(("found PnP BIOS at %.5x", 0xf0000 + i));
				mem[0xf0000 + i] = 0x6e;
				mem[0xf0002 + i] = 0x24;
				break;
			}
		}
	}
	else {
		CopyMemory(mem + 0x0e8000, nosyscode, sizeof(nosyscode));
		if ((!biosrom) && (!(pccore.model & PCMODEL_EPSON))) {
			CopyMemory(mem + 0xe8dd8, neccheck, 0x25);
			pos = LOADINTELWORD(itfrom + 2);
			CopyMemory(mem + 0xf538e, itfrom + pos, 0x27);
		}
		setbiosseed(mem + 0x0e8000, 0x10000, 0xb1f0);
	}

#if defined(SUPPORT_PC9821)
	getbiospath(path, OEMTEXT("bios9821.rom"), sizeof(path));
	fh = file_open_rb(path);
	if (fh != FILEH_INVALID) {
		if (file_read(fh, mem + 0x0d8000, 0x2000) == 0x2000) {
			// IDE BIOSを潰す
			TRACEOUT(("load bios9821.rom"));
			STOREINTELWORD(mem + 0x0d8009, 0);
		}
		file_close(fh);
	}
#if defined(BIOS_SIMULATE)
	mem[0xf8e80] = 0x98;
	mem[0xf8e81] = 0x21;
	mem[0xf8e82] = 0x1f;
	mem[0xf8e83] = 0x20;	// Model Number?
	mem[0xf8e84] = 0x2c;
	mem[0xf8e85] = 0xb0;

	// mem[0xf8eaf] = 0x21;		// <- これって何だっけ?
#endif
#endif

#if defined(BIOS_SIMULATE)
	CopyMemory(mem + BIOS_BASE, biosfd80, sizeof(biosfd80));
	if (!biosrom) {
		lio_initialize();
	}

	for (i=0; i<8; i+=2) {
		STOREINTELWORD(mem + 0xfd800 + 0x1aaf + i, 0x1ab7);
		STOREINTELWORD(mem + 0xfd800 + 0x1ad7 + i, 0x1adf);
		STOREINTELWORD(mem + 0xfd800 + 0x2361 + i, 0x1980);
	}
	CopyMemory(mem + 0xfd800 + 0x1ab7, fdfmt2hd, sizeof(fdfmt2hd));
	CopyMemory(mem + 0xfd800 + 0x1adf, fdfmt2dd, sizeof(fdfmt2dd));
	CopyMemory(mem + 0xfd800 + 0x1980, fdfmt144, sizeof(fdfmt144));

	SETBIOSMEM16(0xfffe8, 0xcb90);
	SETBIOSMEM16(0xfffec, 0xcb90);
	mem[0xffff0] = 0xea;
	STOREINTELDWORD(mem + 0xffff1, 0xfd800000);

	CopyMemory(mem + 0x0fd800 + 0x0e00, keytable[0], 0x300);

	CopyMemory(mem + ITF_ADRS, itfrom, sizeof(itfrom));
	mem[ITF_ADRS + 0x7ff0] = 0xea;
	STOREINTELDWORD(mem + ITF_ADRS + 0x7ff1, 0xf8000000);
	if (pccore.model & PCMODEL_EPSON) {
		mem[ITF_ADRS + 0x7ff1] = 0x04;
	}
	else if ((pccore.model & PCMODELMASK) == PCMODEL_VM) {
		mem[ITF_ADRS + 0x7ff1] = 0x08;
	}
	setbiosseed(mem + 0x0f8000, 0x08000, 0x7ffe);
#else
	fh = file_open_c("itf.rom");
	if (fh != FILEH_INVALID) {
		file_read(fh, mem + ITF_ADRS, 0x8000);
		file_close(fh);
		TRACEOUT(("load itf.rom"));
	}
#endif

	CopyMemory(mem + 0x1c0000, mem + ITF_ADRS, 0x08000);
	CopyMemory(mem + 0x1e8000, mem + 0x0e8000, 0x10000);
}