示例#1
0
文件: main.c 项目: Almamu/c2c
int main(int argc,char **argv)
{
	EMU_Init();
	EMU_Invoke(0x80049DC4,0);
}
示例#2
0
int main(int _argc, char **_argv) {
    int framecount=0;
    int sramcount=0;

    argc=_argc, argv=_argv;
    defaultExceptionHandler();

    fifoSendValue32(FIFO_USER_06, (u32)ipc_region);

    DS_init(); //DS init.
#ifndef ROM_EMBEDED
    active_interface = fatInitDefault(); //init file operations to your external card.

    initNiFi();
#endif
    EMU_Init(); //emulation init.

    irqSet(IRQ_VBLANK, vblankinterrupt);
    irqEnable(IRQ_HBLANK);
    //fifoSetValue32Handler(FIFO_USER_06, aliveinterrupt, 0);
    //fifoSetValue32Handler(FIFO_USER_05, reg4015interrupt, 0);

    IPC_ALIVE = 0;
    IPC_APUIRQ = 0;
    IPC_REG4015 = 0;

    consoleinit(); //init subscreen to show chars.
    crcinit();	//init the crc table.

    //pre-alocate memory....
    //IPC_FILES = malloc(MAXFILES * 256 + MAXFILES * 4);
    //IPC_ROM = malloc(ROM_MAX_SIZE);

#ifndef ROM_EMBEDED
    if(!bootext()) {
        //chdir("/");
        do_rommenu(); //show a menu selecting rom files.
    }
#else
    do_romebd();
#endif

    //__emuflags |= PALSYNC;

    while(1) { // main loop to do the emulation
        framecount++;
        if(__emuflags & PALTIMING && global_playcount == 0) {
            framecount--;
        }
        if(debuginfo[VBLS]>59) {
            debuginfo[VBLS]-=60;
            debuginfo[1] = debuginfo[0];
            debuginfo[0] = 0;
            debuginfo[FPS]=framecount;
            framecount=0;
        }

        scanKeys();
        IPC_KEYS = keysCurrent();

        //change nsf states
        if(__emuflags & NSFFILE) {
            static int oldkey = 0;
            int keydown = IPC_KEYS & (~oldkey);
            oldkey = IPC_KEYS;

            if(keydown & KEY_LEFT) {
                if(__nsfsongno == 0) {
                    __nsfsongno = nsfheader.TotalSong-1;
                } else {
                    __nsfsongno--;
                }
            }
            if(keydown & KEY_RIGHT) {
                if(++__nsfsongno > nsfheader.TotalSong-1) {
                    __nsfsongno = 0;
                }
            }
            if(keydown & KEY_UP) {
                __nsfplay = 1;
                __nsfinit = 1;
            }
            if(keydown & KEY_DOWN) {
                __nsfplay = 0;
                Sound_reset();
            }
        }

        do_shortcuts();
        if((__emuflags & AUTOSRAM)) {
            if(__emuflags & NEEDSRAM) {
                sramcount = 1;
                __emuflags&=~NEEDSRAM;
            }
            if(sramcount > 0)
                sramcount++;
            if(sramcount > 120) {		//need auto save for sram.
                sramcount = 0;
                save_sram();
            }
        }

        touch_update(); // do menu functions.
        do_menu();	//do control menu.

        do_multi();
        if(nifi_stat == 0 || nifi_stat >= 5)
            play(); //emulate a frame of the NES game.
        else
            swiWaitForVBlank();
    }
}