Exemplo n.º 1
0
void TIM2_IRQHandler(void) {
  uint32_t it_status = TIM3->SR & TIM3->DIER;
  if (it_status & TIM_SR_UIF) {
    TIM3->SR = ~TIM_SR_UIF;
    incTime();
  }
  if (it_status & TIM_SR_CC1IF) {
    TIM3->SR = ~TIM_SR_CC1IF;
    incTime();
  }
}
Exemplo n.º 2
0
/** @brief: Function for handling the RTC1 interrupts.
 * Triggered on TICK and COMPARE0 match.
 */
void RTC1_IRQHandler()
{
/*
    if ((NRF_RTC1->EVENTS_TICK != 0) && 
        ((NRF_RTC1->INTENSET & RTC_INTENSET_TICK_Msk) != 0))
*/
	/*
	if ((NRF_RTC1->EVENTS_COMPARE[0] != 0) && 
      ((NRF_RTC1->INTENSET & RTC_INTENSET_COMPARE0_Msk) != 0))
    {
        NRF_RTC1->EVENTS_COMPARE[0] = 0;
			  NRF_RTC1->CC[0]         = NRF_RTC1->CC[0] + 8; // 8 ticks = 1 second COMPARE_COUNTERTIME * RTC_FREQUENCY;  // Compare0 after approx COMPARE_COUNTERTIME seconds.

        nrf_gpio_pin_toggle(PIN_VCOM);
        // nrf_gpio_pin_toggle(PIN_DISP); // for testing
    }
*/
    if ((NRF_RTC1->EVENTS_COMPARE[0] != 0) && 
        ((NRF_RTC1->INTENSET & RTC_INTENSET_COMPARE0_Msk) != 0))
    {
        NRF_RTC1->EVENTS_COMPARE[0] = 0;
				NRF_RTC1->CC[0] = NRF_RTC1->CC[0] + 8;
			
				display_toggle_COM();

				incTime();
			
				updateDisplay();
    }
}
Exemplo n.º 3
0
static void clockTickHandler( void * p_context )
{
	display_toggle_COM();

	incTime();
			
	updateDisplay();
}
Exemplo n.º 4
0
int LoadCdromFile(const char *filename, EXE_HEADER *head) {
	struct iso_directory_record *dir;
	u8 time[4],*buf;
	u8 mdir[4096], exename[256];
	u32 size, addr;
	void *psxaddr;

	if (sscanf(filename, "cdrom:\\%255s", exename) <= 0)
	{
		// Some games omit backslash (NFS4)
		if (sscanf(filename, "cdrom:%255s", exename) <= 0)
		{
			SysPrintf("LoadCdromFile: EXE NAME PARSING ERROR (%s (%u))\n", filename, strlen(filename));
			exit (1);
		}
	}

	time[0] = itob(0); time[1] = itob(2); time[2] = itob(0x10);

	READTRACK();

	// skip head and sub, and go to the root directory record
	dir = (struct iso_directory_record *)&buf[12 + 156]; 

	mmssdd(dir->extent, (char*)time);

	READDIR(mdir);

	if (GetCdromFile(mdir, time, exename) == -1) return -1;

	READTRACK();

	memcpy(head, buf + 12, sizeof(EXE_HEADER));
	size = head->t_size;
	addr = head->t_addr;

	// Cache clear/invalidate dynarec/int. Fixes startup of Casper/X-Files and possibly others.
	psxCpu->Clear(addr, size / 4);
	psxRegs.ICache_valid = FALSE;

	while (size) {
		incTime();
		READTRACK();

		psxaddr = (void *)PSXM(addr);
		assert(psxaddr != NULL);
		memcpy(psxaddr, buf + 12, 2048);

		size -= 2048;
		addr += 2048;
	}

	return 0;
}
Exemplo n.º 5
0
int LoadCdromFile(const char *filename, EXE_HEADER *head) {
	struct iso_directory_record *dir;
	u8 time[4],*buf;
	u8 mdir[4096];
	char exename[256];
	u32 size, addr;
	void *mem;

	sscanf(filename, "cdrom:\\%256s", exename);

	time[0] = itob(0); time[1] = itob(2); time[2] = itob(0x10);

	READTRACK();

	// skip head and sub, and go to the root directory record
	dir = (struct iso_directory_record *)&buf[12 + 156]; 

	mmssdd(dir->extent, (char*)time);

	READDIR(mdir);

	if (GetCdromFile(mdir, time, exename) == -1) return -1;

	READTRACK();

	memcpy(head, buf + 12, sizeof(EXE_HEADER));
	size = head->t_size;
	addr = head->t_addr;

	psxCpu->Clear(addr, size / 4);

	while (size & ~2047) {
		incTime();
		READTRACK();

		mem = PSXM(addr);
		if (mem)
			memcpy(mem, buf + 12, 2048);

		size -= 2048;
		addr += 2048;
	}

	return 0;
}
Exemplo n.º 6
0
s32 LoadCdromFile(char *filename, EXE_HEADER *head) {
	struct iso_directory_record *dir;
	u8 time[4],*buf;
	u8 mdir[4096], exename[256];
	u32 size, addr;

	sscanf(filename, "cdrom:\\%s", exename);

	time[0] = (0); time[1] = (2); time[2] = (0x10);

	READTRACK();

	// skip head and sub, and go to the root directory record
	dir = (iso_directory_record*) &buf[12+156]; 

	mmssdd((dir->extent), (char*)time);

	READDIR(mdir);

	if (GetCdromFile((u8*)mdir, (u8*)time, (s8*)exename) == -1) return -1;

	READTRACK();

	memcpy(head, buf+12, sizeof(EXE_HEADER));
	size = head->t_size;
	addr = head->t_addr;

	while (size) {
		incTime();
		READTRACK();

		memcpy((void *)PSXM8(addr), buf+12, 2048);

		size -= 2048;
		addr += 2048;
	}

	return 0;
}
Exemplo n.º 7
0
void Game2D::timer(){
    if (pause()) return;

    if (!evec_.size() && state_==1){
        //if (level () >=2) state_=2;
        //else
        nextLevel ();
    }

    if (state_==1){
        bool destroy=0;

        ship_.onFire();
        ship_.timer(direction_, width (), height ());

        for (int i=0; i<evec_.size(); i++){
            int x1=evec_[i].x ();
            int y1=evec_[i].y ();
            int x2=evec_[i].x () + evec_[i].width();
            int y2=evec_[i].y () + evec_[i].height();

            //ship hit in vertical line
            if (direction_==1 || direction_==3){
                if (isInInterval (ship_.y (), y1, y2) ||
                    isInInterval (ship_.y () + ship_.height()/2, y1, y2) ||
                    isInInterval (ship_.y () + ship_.height(), y1, y2)){

                    if (ship_.x() > x1) destroy=ship_.hitMinX(x2); //right
                    else{
                        if (ship_.x() +  ship_.width () > x1) destroy=ship_.hitMaxX(x1-ship_.width ()); //left
                    }
                }
            }

            //ship hit in horizontal line
            if (direction_==0 || direction_==2){
                if (isInInterval (ship_.x (), x1, x2) ||
                    isInInterval (ship_.x () + ship_.width()/2, x1, x2) ||
                    isInInterval (ship_.x () + ship_.width(), x1, x2)){
                    if (ship_.y() > y1) destroy=ship_.hitMinY(y2); //down
                    else{
                        if (ship_.y() +  ship_.height () > y1) destroy=ship_.hitMaxY(y1-ship_.height ()); //up
                    }
                }
            }

            if (ship_.fire()){

                bool damaged=0;
                QRect rc;
                ship_.getFireRect (rc, direction());
                //in fire axis y
                if (direction_==1 || direction_==3){
                    if (isInInterval (rc.y(), y1, y2) || isInInterval (rc.y()+rc.height(), y1, y2)){
                        //cross fire line & left enemy || //cross fire line & right enemy
                        if ((x1 > rc.x() && x1 < rc.x()+rc.width()) || (x2 < rc.x() && x2 > rc.x()+rc.width())){
                            damaged=1;
                        }
                    }
                }

                if (direction_==0 || direction_==2){
                    if (isInInterval (rc.x(), x1, x2) || isInInterval (rc.x()+rc.width(), x1, x2)){
                        //cross fire line & up enemy || //cross fire line & down enemy
                        if ((y1 > rc.y() && y1 < rc.y()+rc.height()) || (y2 < rc.y() && y2 > rc.y()+rc.height())){
                            damaged=1;
                        }
                    }
                }

                if (damaged){
                    ++score_;
                    evec_[i].addHealth (-(ship_.damage ()));
                    if (evec_[i].health () == 0) evec_.erase (evec_.begin () + i);
                }

            }

            if (destroy){
                state_=2;

                /*ship_.addHealth (-1);
                switch(direction_){
                    case 0: direction_=2; break;
                    case 1: direction_=3; break;
                    case 2: direction_=0; break;
                    case 3: direction_=1; break;
                }

                if (ship_.health () == 0) state_=2;
                */
                /*QMessageBox box;
                box.warning(0,"Game over", "Ship destroyed!", 0, 1);
                box.show();
                */
            }
        }

        incTime ();
        if (movable()) moveEnemy ();
    }
}
Exemplo n.º 8
0
int LoadCdrom() {
	EXE_HEADER tmpHead;
	struct iso_directory_record *dir;
	u8 time[4], *buf;
	u8 mdir[4096];
	s8 exename[256];

	if (!Config.HLE) {
		if (!Config.SlowBoot) psxRegs.pc = psxRegs.GPR.n.ra;
		return 0;
	}

	time[0] = itob(0); time[1] = itob(2); time[2] = itob(0x10);

	READTRACK();

	// skip head and sub, and go to the root directory record
	dir = (struct iso_directory_record*) &buf[12+156]; 

	mmssdd(dir->extent, (char*)time);

	READDIR(mdir);

	// Load SYSTEM.CNF and scan for the main executable
	if (GetCdromFile(mdir, time, "SYSTEM.CNF;1") == -1) {
		// if SYSTEM.CNF is missing, start an existing PSX.EXE
		if (GetCdromFile(mdir, time, "PSX.EXE;1") == -1) return -1;

		READTRACK();
	}
	else {
		// read the SYSTEM.CNF
		READTRACK();

		sscanf((char *)buf + 12, "BOOT = cdrom:\\%255s", exename);
		if (GetCdromFile(mdir, time, exename) == -1) {
			sscanf((char *)buf + 12, "BOOT = cdrom:%255s", exename);
			if (GetCdromFile(mdir, time, exename) == -1) {
				char *ptr = strstr(buf + 12, "cdrom:");
				if (ptr != NULL) {
					ptr += 6;
					while (*ptr == '\\' || *ptr == '/') ptr++;
					strncpy(exename, ptr, 255);
					exename[255] = '\0';
					ptr = exename;
					while (*ptr != '\0' && *ptr != '\r' && *ptr != '\n') ptr++;
					*ptr = '\0';
					if (GetCdromFile(mdir, time, exename) == -1)
						return -1;
				} else
					return -1;
			}
		}

		// Read the EXE-Header
		READTRACK();
	}

	memcpy(&tmpHead, buf + 12, sizeof(EXE_HEADER));

	psxRegs.pc = SWAP32(tmpHead.pc0);
	psxRegs.GPR.n.gp = SWAP32(tmpHead.gp0);
	psxRegs.GPR.n.sp = SWAP32(tmpHead.s_addr); 
	if (psxRegs.GPR.n.sp == 0) psxRegs.GPR.n.sp = 0x801fff00;

	tmpHead.t_size = SWAP32(tmpHead.t_size);
	tmpHead.t_addr = SWAP32(tmpHead.t_addr);

	// Read the rest of the main executable
	while (tmpHead.t_size) {
		void *ptr = (void *)PSXM(tmpHead.t_addr);

		incTime();
		READTRACK();

		if (ptr != NULL) memcpy(ptr, buf+12, 2048);

		tmpHead.t_size -= 2048;
		tmpHead.t_addr += 2048;
	}

	return 0;
}
Exemplo n.º 9
0
int LoadCdrom() {
	EXE_HEADER tmpHead;
	struct iso_directory_record *dir;
	u8 time[4],*buf;
	u8 mdir[4096];
	s8 exename[256];
	int i;

	if (!Config.HLE) {
		psxRegs.pc = psxRegs.GPR.n.ra;
		return 0;
	}

	time[0] = itob(0); time[1] = itob(2); time[2] = itob(0x10);

	READTRACK();

	// skip head and sub, and go to the root directory record
	dir = (struct iso_directory_record*) &buf[12+156]; 

	mmssdd(dir->extent, (char*)time);

	READDIR(mdir);

	if (GetCdromFile(mdir, time, "SYSTEM.CNF;1") == -1) {
		if (GetCdromFile(mdir, time, "PSX.EXE;1") == -1) return -1;

		READTRACK();
	}
	else {
		READTRACK();

		sscanf((char*)buf+12, "BOOT = cdrom:\\%s", exename);
		if (GetCdromFile(mdir, time, exename) == -1) {
			sscanf((char*)buf+12, "BOOT = cdrom:%s", exename);
			if (GetCdromFile(mdir, time, exename) == -1) {
				char *ptr = strstr(buf+12, "cdrom:");
				for (i=0; i<32; i++) {
					if (ptr[i] == ' ') continue;
					if (ptr[i] == '\\') continue;
				}
				strcpy(exename, ptr);
				if (GetCdromFile(mdir, time, exename) == -1)
					return -1;
			}
		}

		READTRACK();
	}

	memcpy(&tmpHead, buf+12, sizeof(EXE_HEADER));

#ifdef __MACOSX__
	swapEXE_HEADER(&tmpHead);
#endif

	psxRegs.pc = tmpHead.pc0;
	psxRegs.GPR.n.gp = tmpHead.gp0;
	psxRegs.GPR.n.sp = tmpHead.s_addr; 
	if (psxRegs.GPR.n.sp == 0) psxRegs.GPR.n.sp = 0x801fff00;

	while (tmpHead.t_size) {
		void *ptr = (void *)PSXM(tmpHead.t_addr);

		incTime();
		READTRACK();

		if (ptr != NULL) memcpy(ptr, buf+12, 2048);

		tmpHead.t_size -= 2048;
		tmpHead.t_addr += 2048;
	}

	return 0;
}