Beispiel #1
0
void bios0x1c(void) {

	UINT8	buf[6];

	switch(CPU_AH) {
		case 0x00:					// get system timer
			calendar_get(buf);
			MEMR_WRITES(CPU_ES, CPU_BX, buf, 6);
			break;

		case 0x01:					// put system timer
			MEMR_READS(CPU_ES, CPU_BX, buf, 6);
			mem[MEMB_MSW8] = buf[0];
			calendar_set(buf);
			break;

		case 0x02:					// set interval timer (single)
			SETBIOSMEM16(0x0001c, CPU_BX);
			SETBIOSMEM16(0x0001e, CPU_ES);
			SETBIOSMEM16(0x0058a, CPU_CX);
			iocore_out8(0x77, 0x36);
			/* through */

		case 0x03:					// continue interval timer
			iocore_out8(0x71, 0x00);
			if (pccore.cpumode & CPUMODE_8MHZ) {
				iocore_out8(0x71, 0x4e);				// 4MHz
			}
			else {
				iocore_out8(0x71, 0x60);				// 5MHz
			}
			pic.pi[0].imr &= ~(PIC_SYSTEMTIMER);
			break;
	}
}
Beispiel #2
0
static void bios_itfcall(void) {

	int		i;

	bios_itfprepare();
	bios_memclear();
	bios_vectorset();
	bios0x09_init();
	bios_reinitbyswitch();
	bios0x18_0c();

	if (!np2cfg.ITF_WORK) {
		for (i=0; i<8; i++) {
			mem[MEMX_MSW + (i*4)] = msw_default[i];
		}
		CPU_FLAGL |= C_FLAG;
	}
	else {
		CPU_DX = 0x43d;
		CPU_AL = 0x10;
		mem[0x004f8] = 0xee;		// out	dx, al
		mem[0x004f9] = 0xea;		// call	far
		SETBIOSMEM16(0x004fa, 0x0000);
		SETBIOSMEM16(0x004fc, 0xffff);
		CPU_FLAGL &= ~C_FLAG;
	}
}
Beispiel #3
0
void bios0x09_init(void) {

	iocore_out8(0x43, 0x3a);		// keyboard reset-high
	iocore_out8(0x43, 0x32);		// keyboard reset-low
	iocore_out8(0x43, 0x16);		// error reset
	ZeroMemory(mem + 0x00502, 0x20);
	ZeroMemory(mem + 0x00528, 0x13);
	SETBIOSMEM16(MEMW_KB_SHIFT_TBL, 0x0e00);
	SETBIOSMEM16(MEMW_KB_BUF_HEAD, 0x0502);
	SETBIOSMEM16(MEMW_KB_BUF_TAIL, 0x0502);
	SETBIOSMEM16(MEMW_KB_CODE_OFF, 0x0e00);
	SETBIOSMEM16(MEMW_KB_CODE_SEG, 0xfd80);
}
Beispiel #4
0
static void bios_vectorset(void) {

	UINT	i;

	for (i=0; i<0x20; i++) {
		*(UINT16 *)(mem + (i*4)) = *(UINT16 *)(mem + BIOS_BASE + BIOS_TABLE + (i*2));
		SETBIOSMEM16((i * 4) + 2, BIOS_SEG);
	}
	SETBIOSMEM32(0x1e*4, 0xe8000000);
}
Beispiel #5
0
static void updateshiftkey(void) {

	UINT8	shiftsts;
	UINT	base;

	shiftsts = mem[MEMB_SHIFT_STS];
	mem[MEMB_MSW6] &= 0x3f;							// KEYBOARD LED
	mem[MEMB_MSW6] |= (UINT8)(shiftsts << 5);
	if (shiftsts & 0x10) {
		base = 7;
	}
	else if (shiftsts & 0x08) {
		base = 6;
	}
	else {
		base = shiftsts & 7;
		if (base >= 6) {
			base -= 2;
		}
	}
	base = 0x0e00 + (base * 0x60);
	SETBIOSMEM16(MEMW_KB_SHIFT_TBL, base);
}
Beispiel #6
0
void bios0x09(void) {

	UINT8	key;
	UINT	pos;
	UINT8	bit;
	UINT16	code;
	UINT32	base;
	UINT	kbbuftail;

	key = CPU_AL;
	pos = (key & 0x7f) >> 3;
	bit = 1 << (key & 7);
	if (!(key & 0x80)) {
		mem[MEMX_KB_KY_STS + pos] |= bit;
		code = 0xffff;
		base = GETBIOSMEM16(MEMW_KB_SHIFT_TBL);
		base += 0xfd800;
		if (key <= 0x51) {
			if ((key == 0x51) || (key == 0x35) || (key == 0x3e)) {
				code = mem[base + key] << 8;
				if (code == 0xff00) {
					code = 0xffff;
				}
			}
			else {
				code = mem[base + key];
				if (code != 0xff) {
					code += key << 8;
				}
				else {
					code = 0xffff;
				}
			}
		}
		else if (key < 0x60) {
			if (key == 0x5e) {								// home
				code = 0xae00;
			}
		}
		else {
			if (key == 0x60) {
//				CPU_INTERRUPT(6, -1);
			}
			else if (key == 0x61) {
//				CPU_INTERRUPT(5, -1);
			}
			else if (key < 0x70) {
				code = mem[base + key - 0x0c] << 8;
				if (code == 0xff00) {
					code = 0xffff;
				}
			}
			else if (key < 0x75) {
				mem[MEMB_SHIFT_STS] |= bit;
				updateshiftkey();
			}
		}
		if (code != 0xffff) {
			if (mem[MEMB_KB_COUNT] < 0x10) {
				mem[MEMB_KB_COUNT]++;
				kbbuftail = GETBIOSMEM16(MEMW_KB_BUF_TAIL);
#if defined(BYTESEX_LITTLE) && defined(MEMOPTIMIZE)
				mem[kbbuftail] = (UINT8)(code);
				mem[kbbuftail+1] = (UINT8)((code) >> 8);
#else
				SETBIOSMEM16(kbbuftail, code);
#endif
				kbbuftail += 2;
				if (kbbuftail >= 0x522) {
					kbbuftail = 0x502;
				}
				SETBIOSMEM16(MEMW_KB_BUF_TAIL, kbbuftail);
			}
		}
Beispiel #7
0
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);
}