⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 custom.c

📁 树大根深三棱尽所标杆ssfsfsa fdsafs
💻 C
📖 第 1 页 / 共 3 页
字号:
static union {	UBYTE x;	struct {		unsigned BD	:7;		unsigned BKEN	:1;	} anon;} db_LBLKC;static union {	UBYTE x;	struct {		unsigned GS	:1;		unsigned PBSIZ	:2;		unsigned 	:5;	} anon;} db_LPICF;static union {	UBYTE x;	struct {		unsigned PCD	:6;		unsigned 	:2;	} anon;} db_LPXCD;static union {	UBYTE x;	struct {		unsigned PCDS	:1;		unsigned DWIDTH	:1;		unsigned WS	:4;		unsigned DMA16	:1;		unsigned LCDCON	:1;	} anon;} db_LCKCON;static union {	UBYTE x;	struct {		unsigned LBAR	:7;		unsigned 	:1;	} anon;} db_LLBAR;static union {	UBYTE x;	struct {		unsigned OTC	:8;	} anon;} db_LOTCR;static union {	UBYTE x;	struct {		unsigned POS	:3;		unsigned BOS	:1;		unsigned 	:4;	} anon;} db_LPOSR;static union {	UBYTE x;	struct {		unsigned YMOD	:4;		unsigned XMOD	:4;	} anon;} db_LFRCM;static union {	UWORD x;	struct {		unsigned G2	:4;		unsigned G3	:4;		unsigned G0	:4;		unsigned G1	:4;	} anon;} db_LGPMR;static union {	ULONG x;	struct {		unsigned SECONDS	:6;		unsigned 	:10;		unsigned MINUTES	:6;		unsigned 	:2;		unsigned HOURS	:5;		unsigned 	:3;	} anon;} db_RTCHMS, db_RTCALARM;static union {	UBYTE x;	struct {		unsigned 	:5;		unsigned REF384	:1;		unsigned 	:1;		unsigned ENABLE	:1;	} anon;} db_RTCCTL;static union {	UBYTE x;	struct {		unsigned SW	:1;		unsigned MININT	:1;		unsigned ALARM	:1;		unsigned HOUR24	:1;		unsigned HZ1	:1;		unsigned 	:3;	} anon;} db_RTCISR, db_RTCIENR;static shared_img *CustShptr = 0;static union {	UWORD	x;	struct {#ifdef WORDS_BIGENDIAN		unsigned FIFO_FULL	:1;		unsigned FIFO_HALF	:1;		unsigned DATA_READY	:1;		unsigned unused		:1;		unsigned OVRUN		:1;		unsigned FRAME_ERROR	:1;		unsigned BREAK		:1;		unsigned PARITY_ERROR	:1;		unsigned DATA		:8;#else /* not WORDS_BIGENDIAN */		unsigned DATA		:8;		unsigned PARITY_ERROR	:1;		unsigned BREAK		:1;		unsigned FRAME_ERROR	:1;		unsigned OVRUN		:1;		unsigned unused		:1;		unsigned DATA_READY	:1;		unsigned FIFO_HALF	:1;		unsigned FIFO_FULL	:1;#endif /* not WORDS_BIGENDIAN */	} anon;} db_URXdb;static UWORD	db_TSTAT1_lastseen;static UWORD	db_TSTAT2_lastseen;static UBYTE	db_PDDATA_edge;static unsigned long cycles;static int pendown = 0;static int penx;static int peny;/* * Exported variable */unsigned long specialflags;static voiddb_reset(void){	db_SCR.x = 0x0c;	db_GRPBASEA.x = 0x0000;	db_GRPBASEC.x = 0x0000;	db_GRPMASKA.x = 0x0000;	db_GRPMASKC.x = 0x0000;	db_CSA0.x = 0x00010006;	db_CSA1.x = 0x00010006;	db_CSA2.x = 0x00010006;	db_CSA3.x = 0x00010006;	db_CSC0.x = 0x00010006;	db_CSC1.x = 0x00010006;	db_CSC2.x = 0x00010006;	db_CSC3.x = 0x00010006;	db_PLLCR.x = 0x2400;	db_PLLFSR.x = 0x0123;	db_PCTLR.x = 0x1f;	db_IVR.x = 0x00;	db_ICR.x = 0x0000;	db_IMR.x = 0x00ffffff;	db_IWR.x = 0x00ffffff;	db_ISR.x = 0x00000000;	db_IPR.x = 0x00000000;	db_PCDIR.x = 0x00;	db_PCDATA.x = 0x00;	db_PCSEL.x = 0x00;	db_PDDIR.x = 0x00;	db_PDDATA.x = 0x00;	db_PDPUEN.x = 0xff;	db_PDPOL.x = 0x00;	db_PDIRQEN.x = 0x00;	db_PDIRQEDGE.x = 0x00;	db_PEDIR.x = 0x00;	db_PEDATA.x = 0x00;	db_PEPUEN.x = 0x80;	db_PESEL.x = 0x80;	db_PFDIR.x = 0x00;	db_PFDATA.x = 0x00;	db_PFPUEN.x = 0xff;	db_PFSEL.x = 0xff;	db_PGDIR.x = 0x00;	db_PGDATA.x = 0x00;	db_PGPUEN.x = 0xff;	db_PGSEL.x = 0xff;	db_PJDIR.x = 0x00;	db_PJDATA.x = 0x00;	db_PJSEL.x = 0x00;	db_PKDIR.x = 0x00;	db_PKDATA.x = 0x00;	db_PKPUEN.x = 0x3f;	db_PKSEL.x = 0x3f;	db_PMDIR.x = 0x00;	db_PMDATA.x = 0x00;	db_PMPUEN.x = 0xff;	db_PMSEL.x = 0x02;	db_PWMC.x = 0x0000;	db_PWMP.x = 0x0000;	db_PWMW.x = 0x0000;	db_TCTL1.x = 0x0000;	db_TPRER1.x = 0x0000;	db_TCMP1.x = 0xffff;	db_TCN1.x = 0x0000;	db_TSTAT1.x = 0x0000;	db_TCTL2.x = 0x0000;	db_TPRER2.x = 0x0000;	db_TCMP2.x = 0xffff;	db_TCN2.x = 0x0000;	db_TSTAT2.x = 0x0000;	db_WCSR.x = 0x0001;	db_WCN.x = 0x0000;	db_SPIMDATA.x = 0x0000;	db_SPIMCONT.x = 0x0000;	db_USTCNT.x = 0x0000;	db_UBAUD.x = 0x003f;	db_URX.x = 0x0000;	db_UTX.x = 0x0000;	db_UMISC.x = 0x0000;	db_LSSA.x = 0x00000000;	db_LVPW.x = 0xff;	db_LXMAX.x = 0x03ff;	db_LYMAX.x = 0x01ff;	db_LCXP.x = 0x0000;	db_LCYP.x = 0x0000;	db_LCWCH.x = 0x0101;	db_LBLKC.x = 0x7f;	db_LPICF.x = 0x00;	db_LPXCD.x = 0x00;	db_LCKCON.x = 0x40;	db_LLBAR.x = 0x3e;	db_LOTCR.x = 0x3f;	db_LPOSR.x = 0x00;	db_LFRCM.x = 0xb9;	db_LGPMR.x = 0x1073;	db_RTCHMS.x = 0x00000000;	db_RTCALARM.x = 0x00000000;	db_RTCCTL.x = 0x00;	db_RTCISR.x = 0x00;	db_RTCIENR.x = 0x00;}voidcustomreset(void){	cycles = 0;	specialflags = 0;	db_TSTAT1_lastseen = 0x0000;	db_TSTAT2_lastseen = 0x0000;	db_PDDATA_edge = 0x00;	db_URXdb.x = 0x0000;	db_reset();}/**************************************** * Handle a key event. The fields	* * keydown and key of the shared image	* * are interpreted, and the dragonball	* * registers updated			* ****************************************/static voiddokey(void){	UBYTE		d;	d = db_PDDATA.x;	if (CustShptr->keydown) {		db_PDDATA.x |= (1 << CustShptr->key);		CustShptr->keydown = 0;		CustShptr->key = -1;	} else if (CustShptr->key >= 0) {		db_PDDATA.x &= ~(1 << CustShptr->key);		CustShptr->key = -1;	}	db_PDDATA_edge |= db_PDDATA.x & ~d;	db_IPR.anon.PEN = CustShptr->pen;	db_IPR.x = (db_IPR.x & 0xffff00ff) |		((((db_PDDATA_edge & db_PDIRQEDGE.x) |		   (db_PDDATA.x & ~db_PDIRQEDGE.x)) & db_PDIRQEN.x) << 8);}voidupdateisr(){	db_IPR.anon.PEN = CustShptr->pen;	db_ISR.x = db_IPR.x & ~db_IMR.x;	if (db_ISR.x) {		specialflags |= SPCFLAG_INT;	}	CustShptr->run_updateisr = 0;}voidmaybe_updateisr(){	if (CustShptr->run_updateisr) {		dokey();		updateisr();	}}intintbase(){	return db_IVR.anon.VECTOR << 3;}intintlev(){	if (db_ISR.anon.IRQ7)	return 7;	if (db_ISR.anon.SPIS)	return 6;	if (db_ISR.anon.TMR1)	return 6;	if (db_ISR.anon.IRQ6)	return 6;	if (db_ISR.anon.PEN)	return 5;	if (db_ISR.anon.SPIM)	return 4;	if (db_ISR.anon.TMR2)	return 4;	if (db_ISR.anon.UART)	return 4;	if (db_ISR.anon.WDT)	return 4;	if (db_ISR.anon.RTC)	return 4;	if (db_ISR.anon.KB)	return 4;	if (db_ISR.anon.PWM)	return 4;	if (db_ISR.anon.INT0)	return 4;	if (db_ISR.anon.INT1)	return 4;	if (db_ISR.anon.INT2)	return 4;	if (db_ISR.anon.INT3)	return 4;	if (db_ISR.anon.INT4)	return 4;	if (db_ISR.anon.INT5)	return 4;	if (db_ISR.anon.INT6)	return 4;	if (db_ISR.anon.INT7)	return 4;	if (db_ISR.anon.IRQ3)	return 3;	if (db_ISR.anon.IRQ2)	return 2;	if (db_ISR.anon.IRQ1)	return 1;	return -1;}static voidpen(int down, int x, int y){	if (!pendown && down) {		db_IPR.anon.PEN = 1;		updateisr();	} else if (pendown && !down) {		db_IPR.anon.PEN = 0;		updateisr();	}	pendown = down;	penx = x;	peny = y;}static voidhotsync(int down){	if (down) {		db_IPR.anon.IRQ1 = 1;	} else {		db_IPR.anon.IRQ1 = 0;	}	updateisr();}/* * custptr is a pointer to a shared memory block which will "back-up" * the register values of the custom circuits, allowing other processes * to look at register values */voidcustom_init(shared_img * shptr){	CustShptr = shptr;	CustShptr->PICF = 0;	CustShptr->VPW = 0xff;	CustShptr->POSR = 0;	CustShptr->grpalette[0] = 1;	CustShptr->grpalette[1] = 0;	CustShptr->grpalette[2] = 3;	CustShptr->grpalette[3] = 7;	CustShptr->quit = 0;	CustShptr->run_updateisr = 0;	CustShptr->LcdPower = lcdOn;	CustShptr->Backlight = 0;	customreset();}voiddo_cycles(int longtime){	if (db_TCTL2.anon.TEN) {		db_TCN2.anon.COUNT++;		if (db_TCN2.anon.COUNT > db_TCMP2.anon.COMPARE || longtime) {			db_TSTAT2.anon.COMP = 1;			if (db_TCTL2.anon.FRR == 0) {				db_TCN2.anon.COUNT = 0;			}			if (db_TCTL2.anon.IRQEN) {				db_IPR.anon.TMR2 = 1;				updateisr();			}		}	}	/*	 * Determine if there are any chars to read from the serial port or	 * debugger	 */	/*	 * WARNING: This uses a shared memory data structure to store the	 * FIFO. The producer is adding things to this _at the same time_ as	 * this is consuming.  Examine main.c and take a course in concurrent	 * programming before modifying this.  :-) - Ian	 */	if (CustShptr->serial.head != CustShptr->serial.tail &&	    db_USTCNT.anon.UART_ENABLE && !db_URX.anon.DATA_READY) {		int	curhead = CustShptr->serial.head;		db_URX.anon.DATA = CustShptr->serial.fifo[curhead];		curhead += 1;		if (curhead == FIFO_SIZE) {			curhead = 0;		}		CustShptr->serial.head = curhead;		db_URX.anon.DATA_READY = 1;		if (db_USTCNT.anon.RX_READY_ENABLE) {			db_IPR.anon.UART = 1;			updateisr();		}	}	if (CustShptr->gdb.head != CustShptr->gdb.tail &&	    db_USTCNT.anon.UART_ENABLE && !db_URXdb.anon.DATA_READY) {		int	curhead = CustShptr->gdb.head;		db_URXdb.anon.DATA = CustShptr->gdb.fifo[curhead];		curhead += 1;		if (curhead == FIFO_SIZE) {			curhead = 0;		}		CustShptr->gdb.head = curhead;		db_URXdb.anon.DATA_READY = 1;	}}struct EventType {	UWORD	eType;	UWORD	penDown;	UWORD	screenX;	UWORD	screenY;	UWORD	data[8];};struct SndCommandType {	UWORD	cmd;	UWORD	param1hi;	UWORD	param1lo;	UWORD	param2;	UWORD	param3;};#define keyDownEvent		4#define sysTrapEvtGetEvent	41245#define sysTrapSndDoCmd		41523intdo_api(int api){	switch (api) {		case sysTrapEvtGetEvent:		if (CustShptr->kbin != CustShptr->kbout) {			struct EventType	*ev;			int			out;			out = CustShptr->kbout;			ev = (struct EventType *) get_real_address(get_long(CustShptr->regs.a[7]));			ev->eType = keyDownEvent;			ev->data[0] = CustShptr->kb[out];			ev->data[1] = 0;			ev->data[2] = 0;			CustShptr->kbout = (out + 1) & 7;			return 1;		}		break;	case sysTrapSndDoCmd:		{			struct SndCommandType *sc;			sc = (struct SndCommandType *)				get_real_address(get_long(CustShptr->regs.a[7] + 4));			if ((sc->cmd >> 8) == 1) {				CustShptr->BellFreq = (sc->param1hi << 16) + sc->param1lo;				CustShptr->BellDur = sc->param2;				CustShptr->BellAmp = sc->param3;				CustShptr->LcdReq = lcdBell;				return 1;			}		}		break;	}	return 0;}static ULONGcustom_lget(CPTR addr){	switch (addr & 0xffff) {	case CSA0:		return db_CSA0.x;	case CSA1:		return db_CSA1.x;	case CSA2:		return db_CSA2.x;	case CSA3:		return db_CSA3.x;	case CSC0:		return db_CSC0.x;	case CSC1:		return db_CSC1.x;	case CSC2:		return db_CSC2.x;	case CSC3:		return db_CSC3.x;	case IMR:		return db_IMR.x;	case IWR:		return db_IWR.x;	case ISR:		return db_ISR.x;	case IPR:		db_IPR.anon.PEN = CustShptr->pen;		return db_IPR.x;	case LSSA:		return db_LSSA.x;	case RTCHMS:		{			struct tm	*st;			time_t		t;			t = time(0);			st = localtime(&t);			db_RTCHMS.anon.HOURS = st->tm_hour;			db_RTCHMS.anon.MINUTES = st->tm_min;			db_RTCHMS.anon.SECONDS = st->tm_sec;		}		return db_RTCHMS.x;	case RTCALARM:		return db_RTCALARM.x;	default:		fprintf(stderr, "%s(0x%x) - %x\r\n",__FUNCTION__,addr,MC68000_getpc());		fatal(__FILE__, __LINE__);		return 0;	}}static voidcustom_lput(CPTR addr, ULONG value){	switch (addr & 0xffff) {	case CSA0:		db_CSA0.x = value;		break;	case CSA1:		db_CSA1.x = value;		sram_protect = (value & 0x0008) != 0;		break;	case CSA2:		db_CSA2.x = value;		break;	case CSA3:		db_CSA3.x = value;		break;	case CSC0:		db_CSC0.x = value;		break;	case CSC1:		db_CSC1.x = value;		break;	case CSC2:		db_CSC2.x = value;		break;	case CSC3:		db_CSC3.x = value;		break;	case IMR:		db_IMR.x = value;		updateisr();		break;	case IWR:		db_IWR.x = value;		break;	case ISR:		if (db_ICR.anon.ET1 && (value & 0x00010000)) {			db_IPR.anon.IRQ1 = 0;			updateisr();		}		if (db_ICR.anon.ET2 && (value & 0x00020000)) {			db_IPR.anon.IRQ2 = 0;			updateisr();		}		if (db_ICR.anon.ET3 && (value & 0x00040000)) {			db_IPR.anon.IRQ3 = 0;			updateisr();		}		if (db_ICR.anon.ET6 && (value & 0x00080000)) {			db_IPR.anon.IRQ6 = 0;			updateisr();		}		if (value & 0x00800000) {			db_IPR.anon.IRQ7 = 0;			updateisr();		}		break;	case IPR:		/* do nothing */		break;	case LSSA:		db_LSSA.x = value;		CustShptr->lssa = value;		break;	case RTCHMS:		db_RTCHMS.x = value;		break;	case RTCALARM:		db_RTCALARM.x = value;		break;	default:		fprintf(stderr, "%s(0x%x, 0x%x) - %x\r\n", __FUNCTION__, addr, value,				MC68000_getpc());		fatal(__FILE__, __LINE__);		break;	}}static UWORDcustom_wget(CPTR addr){	switch (addr & 0xffff) {	case GRPBASEA:		return db_GRPBASEA.x;	case GRPBASEC:		return db_GRPBASEC.x;	case GRPMASKA:		return db_GRPMASKA.x;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -