예제 #1
0
파일: main.c 프로젝트: Mapleaph/LH1008
int main(void)
{                               
	const int flash_burn = 0;

	int testcpu;

	initboard();
	initsdram();
	com_init();
	
	sendtocom0("LH-1008 Satellite Navigation System\n\n\n");

	initmodules();

	//TestCPU
	testcpu = (0xabcddcba * 0x56899865 + 0xccdd) / 0xaabb;
	testcpu <<= 16;
	testcpu = ~testcpu;

	if (testcpu == 0x11DCFFFF) {

		sendtocom0("Satellite Navigation System Start\n\n");

	}

	//Test Flash
	if (flash_burn == 1) {

		Flash_Chip_Erase();
		printf("Flash Erase Complete\n");

		Flash_Writem(FLASH_BASE_ADDR, 0x000, 0x48);
		Flash_Writem(FLASH_BASE_ADDR+0x400, (Uint32*)0x400, 0x5b30);
		printf("Flash Write Complete\n");
	}

	test_entry();

/*
	printf("TEST SDRAMing... Write 0x00000000\t\n");

	for (i=0; i<0x1000000; i++)
		write16((0x80000000 + i*2), 0x0);

	for (i=0; i<0x1000000; i++) {

		tmptest = read16(0x80000000 + i*2);

		if (tmptest != 0) {

			printf("SDRAM Check failed...\t\n");
			printf("i=0x%x\r\n", i);
			printf("tmptest=0x%x\r\n", tmptest);
			printf("testram=0x%x\r\n", testram);
		}
	}

	printf("SDRAM Check 0x00000000 OK\t\n");

	printf("TEST SDRAMing... Write 0xFFFFFFFF\t\n");

	for (i=0; i<0x1000000; i++)
		write16((0x80000000 + i*2), 0xffff);

	for (i=0; i<0x1000000; i++) {

		tmptest = read16(0x80000000 + i*2);

		if (tmptest != 0xffff) {

			printf("SDRAM Check failed...\t\n");
			printf("i=0x%x\r\n", i);
			printf("tmptest=0x%x\r\n", tmptest);
			printf("testram=0x%x\r\n", testram);
		}
	}

	printf("SDRAM Check 0xFFFFFFFF OK\t\n");

	printf("TEST SDRAMing... Write 0xAAAAAAAA\t\n");

	for (i=0;i<0x1000000; i++)
		write16((0x80000000 + i*2), 0xaaaa);

	for (i=0; i<0x1000000; i++) {

		tmptest = read16(0x80000000 + i*2);

		if (tmptest != 0xaaaa) {

			printf("SDRAM Check failed...\t\n");
			printf("i=0x%x\r\n", i);
			printf("tmptest=0x%x\r\n", tmptest);
			printf("testram=0x%x\r\n", testram);

		}
	}

	printf("SDRAM Check 0xAAAAAAAA OK\t\n");

	printf("TEST SDRAMing... Write 0x55555555\t\n");

	for (i=0; i<0x1000000; i++)
		write16((0x80000000 + i*2), 0x5555);

	for (i=0; i<0x1000000; i++) {

		tmptest = read16(0x80000000 + i*2);

		if (tmptest != 0x5555) {

			printf("SDRAM Check failed...\t\n");
			printf("i=0x%x\r\n", i);
			printf("tmptest=0x%x\r\n", tmptest);
			printf("testram=0x%x\r\n", testram);

		}
	}

	printf("SDRAM Check 0x55555555 OK\t\n");

	printf("TEST SDRAMing...Write Accumulation \t\n");

	for (i=0, testram=TESTCOUNT; i<0x1000000; i++, testram--)
		write16((0x80000000 + i*2), testram);

	for (i=0, testram=TESTCOUNT; i<0x1000000; i++, testram--) {

		tmptest = read16(0x80000000 + i*2);

		if (tmptest != testram) {

			printf("SDRAM Check failed...\t\n");
			printf("i=0x%x\r\n", i);
			printf("tmptest=0x%x\r\n", tmptest);
			printf("testram=0x%x\r\n", testram);

		}
	}

	printf("SDRAM Test good\n");

	initsdram();
*/

}
예제 #2
0
int main ( int argc, char** argv )
{
    int done, pause, bookmark;
    int joypads[NJOYSTICKS];

    mastersystem *sms = NULL;
    appenv *environment = NULL;
    romspecs *rspecs = NULL;

    display screen;
    SDL_version sdlvers;

    char *romfilename=NULL;
    int nosound = 0;
    int codemasters = 0;

    tmachine machine = UNDEFINED;
    video_mode vmode = UNDEFINED;

    screen.fullscreen = 0;
    screen.scale = DEFAULT_SCALE;
    screen.minscale = (float)224.0 / 192;

#ifndef DEBUG
    assert(0);
#endif

    environment = getappenv();
    initmodules(environment->basedir);

    log4me_print("-==| %s version %s |==-\n", PACKAGE, VERSION);
#ifdef DEBUG
    log4me_print("  => DEBUG version\n");
#endif
    readoptions(argc, argv, &romfilename, &screen.fullscreen, &machine, &vmode, &nosound, &screen.scale, &codemasters);

    SDL_GetVersion(&sdlvers);
    log4me_print("SDL : %d.%d.%d\n", sdlvers.major, sdlvers.minor, sdlvers.patch);
    log4me_print("SDL : Video driver (%s)\n", getcurrentvideodriver());
    log4me_print("SDL : Rendered driver (%s)\n", getcurrentrendererdriver());
    log4me_print("SDL : Audio driver (%s)\n", SDL_GetCurrentAudioDriver());

    // Init joypads
    int i;
    for(i=0;i<NJOYSTICKS;i++) joypads[i] = input_new_pad();

    // Display joypads informations
    if(input_pad_detected()) {
        padinfos infos;
        for(i=0;i<NJOYSTICKS;i++) {
            if(joypads[i]==NO_JOYPAD) continue;
            input_pad_getinfos(joypads[i], &infos);
            log4me_print("SDL : Player %d joystick detected => %s\n", i+1, infos.name);
            log4me_print("\tButtons : %d, Axis : %d, Hats : %d\n", infos.buttons, infos.axis, infos.hats);
        }
    } else
        log4me_print("SDL : No joystick detected\n");

    rspecs = getromspecs(romfilename, machine, vmode, codemasters);
    machine = getrommachine(rspecs);
    vmode = getromvideomode(rspecs);

    assert((machine==JAPAN) || (machine==EXPORT));
    assert((vmode==VM_NTSC) || (vmode==VM_PAL));
    log4me_print("SMS : Use %s machine with %s video mode\n", machine==EXPORT ? "Export" : "Japan", vmode==VM_PAL ? "PAL" : "NTSC");

    switch(getromgameconsole(rspecs)) {
        case GC_SMS:
            screen.width = 256;
            screen.height = 192;
            screen.margin = DEFAULT_MARGIN;
            break;
        case GC_GG:
            screen.width = 160;
            screen.height = 144;
            screen.margin = 0;
            break;
        default:
            assert(0);
            break;
    }
    setvideomode(&screen);

    sms = ms_init(&screen, rspecs, nosound ? SND_OFF : SND_ON, joypads[0], joypads[1], environment->backup);
    if(sms==NULL) {
        log4me_error(LOG_EMU_MAIN, "Unable to allocate and initialize the SMS emulator.\n");
        exit(EXIT_FAILURE);
    }

    SDL_SetWindowTitle(screen.window, CSTR(sms->romname));

    done = pause = bookmark = 0;

    ms_start(sms);
    while (!done)
    {
        SDL_Event event;
        while(SDL_PollEvent(&event)) {
            input_process_event(&event);
            done |= (event.type==SDL_QUIT);
        }

        done |= input_key_pressed(SDL_SCANCODE_ESCAPE);

        if(input_key_down(SDL_SCANCODE_PAUSE)) {
            pause ^= 1;
            ms_pause(sms, pause);
        }

        if(input_key_down(SDL_SCANCODE_F9))
            takesnapshot(sms, environment->snapshots);

        if(input_key_down(SDL_SCANCODE_F10))
            takescreenshot(sms, environment->screenshots);

        if(input_key_down(SDL_SCANCODE_F2)) {
            ms_pause(sms, 1);
            screen.scale -= 0.2;
            setvideomode(&screen);
            ms_pause(sms, 0);
        }

        if(input_key_down(SDL_SCANCODE_F3)) {
            ms_pause(sms, 1);
            screen.scale += 0.2;
            setvideomode(&screen);
            ms_pause(sms, 0);
        }

        if(input_key_down(SDL_SCANCODE_F4)) {
            ms_pause(sms, 1);
            screen.fullscreen ^= 1;
            setvideomode(&screen);
            ms_pause(sms, 0);
        }

#ifdef DEBUG
        if(input_key_down(SDL_SCANCODE_B))
            log4me_print("[BKM] %d\n", bookmark++);

        if(input_key_down(SDL_SCANCODE_F5))
            savetiles(sms, environment->debug);

        if(input_key_down(SDL_SCANCODE_F6))
            tms9918a_toggledisplaypalette(&sms->vdp);
#endif

        if(!ms_ispaused(sms)) ms_execute(sms);
    }

    releaseobject(sms);
    releaseobject(rspecs);
    for(i=0;i<NJOYSTICKS;i++) input_release_pad(joypads[i]);

    releaseobject(environment);

    return 0;
}