Beispiel #1
0
int main(void)
{
 ResetCPU() ;
 /* the above call should never return */
 printf("resetCPU: Failed to reset the system\n") ;
 return(0) ;
}
Beispiel #2
0
int PASCAL WinMain(HANDLE hInst,HANDLE hPrev,LPSTR lpszCmdLine,int nCmdShow)
{
WNDCLASS wc;
MSG Msg;
BOOL QuitMsg;
int n;
hInstance = hInst;
if (hPrev == NULL)
	{
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = (WNDPROC)MainWndProc;
	wc.cbWndExtra = 0;
	wc.cbClsExtra = 0;
	wc.hInstance = hInst;
	wc.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(900));
	wc.hCursor = LoadCursor(NULL,IDC_ARROW);
	wc.hbrBackground = GetStockObject(BLACK_BRUSH);
	wc.lpszMenuName = MAKEINTRESOURCE(999);
	wc.lpszClassName = "Studio2Class";
	RegisterClass(&wc);
	}

lstrcpy(szCartridge,lpszCmdLine);

hWndMain = CreateWindow("Studio2Class",
						"WinSTEM",
						WS_OVERLAPPEDWINDOW | WS_BORDER,
						CW_USEDEFAULT,CW_USEDEFAULT,
						128*SCALE,96*SCALE,
						NULL,
						NULL,
						hInst,NULL);

DragAcceptFiles(hWndMain,TRUE);

ShowWindow(hWndMain,nCmdShow);
EXTInitialise(hInst,hWndMain);
ResetCPU(szCartridge);
SendMessage(hWndMain,WMU_SETTITLE,0,0L);

QuitMsg = FALSE;
while (!QuitMsg)
	{
	if (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
		{
		if (Msg.message == WM_QUIT) QuitMsg = TRUE;
		TranslateMessage(&Msg);
		DispatchMessage(&Msg);
		}
	else
		{
		CompleteFrame(szCartridge);
		CompleteFrame(szCartridge);
		CompleteFrame(szCartridge);
		}
	}
EXTTerminate();
return(0);
}
Beispiel #3
0
LRESULT CALLBACK MainWndProc(HWND hWnd,unsigned iMessage,WORD wParam,LONG lParam)
{
LONG lRet = 0L;
HMENU hMenu;
int   Scale;
RECT  rc,rcc;
OPENFILENAME ofn;
char szBuffer[128],szName[MAXFILE+10];

switch(iMessage)
	{
	case WM_COMMAND:
		switch(wParam)
			{
			case 101:	ResetCPU(szCartridge);
						break;
			case 103:	SendMessage(hWnd,WM_CLOSE,0,0L);
						break;
			case 102:	MessageBox(hWnd,"WinSTEM Studio II Emulator\n\nWritten by Paul Robson 2000","About...",MB_OK | MB_ICONINFORMATION);
						break;
			case 104:
			case 106:	hMenu = GetMenu(hWnd);
						CheckMenuItem(hMenu,104,MF_BYCOMMAND | ((wParam == 104) ? MF_CHECKED : MF_UNCHECKED));
						CheckMenuItem(hMenu,106,MF_BYCOMMAND | ((wParam == 106) ? MF_CHECKED : MF_UNCHECKED));
						_EXTSetColour(wParam == 104);
						break;
			case 108:
			case 109:	Scale = (wParam == 108) ? 4 : 1 ;
						GetWindowRect(hWnd,&rc);
						GetClientRect(hWnd,&rcc);

						SetWindowPos(hWnd,
									 NULL,
									 rc.left,
									 rc.top,
									 (rc.right-rc.left)-rcc.right+rcc.right*Scale/2,
									 (rc.bottom-rc.top)-rcc.bottom+rcc.bottom*Scale/2,
									 SWP_NOZORDER);
						break;
			case 105:
						SetupDialog(hWnd,&ofn);
						if (GetOpenFileName(&ofn) != 0)
							{
							ResetCPU(szCartridge);
							SendMessage(hWndMain,WMU_SETTITLE,0,0L);
							}
						break;
			}
		break;

	case WM_DROPFILES:
		DragQueryFile( (HANDLE)wParam,0,szCartridge,sizeof(szCartridge));
		ResetCPU(szCartridge);
		SendMessage(hWndMain,WMU_SETTITLE,0,0L);
		break;

	case WM_DESTROY:
		PostQuitMessage(0);
		break;

	case WMU_SETTITLE:
		if (lstrlen(szCartridge) == 0)
			SetWindowText(hWnd,"WinStem");
		else
			{
			fnsplit(szCartridge,szBuffer,szBuffer,szName,szBuffer);
			strlwr(szName);
			szName[0] = toupper(szName[0]);
			lstrcat(szName," - WinStem");
			SetWindowText(hWnd,szName);
			}
		break;

	default:
		lRet = DefWindowProc(hWnd,iMessage,wParam,lParam);
		break;
	}
return(lRet);
}
Beispiel #4
0
int main(int argc, const char* argv[])
{
    ARM_CPU cpu;
    ARM_NAND nand;
    ARM_Memory mem;
    ARM_Exception exp;
    uint32_t *pc;
    uint32_t instr_arm;
    uint16_t instr_thumb;
    int type;
    char cmd[10];
    SDL_Event e;
    int quit;
    unsigned long numcycles;
    if(argc != 2){
        printf("Usage: %s <foo.rom>\n", argv[0]);
        return 0;
    }
    
    memset(cmd, '\0', sizeof(char) * 10);
    ResetCPU(&cpu);
    InitNAND(&nand, argv[1]);
    InitMemory(&nand, &mem, 0x02000000);
    DestroyNAND(&nand);
    quit = 0;
    
    /* stack cheat*/
    *cpu.reg[3][SP] = 0x01000000;
    numcycles = 0;
    while(!quit)
    {
#if 0
        scanf("%s", cmd);
        if(strcmp(cmd, "next") && strcmp(cmd, "n"))
            break;
        memset(cmd, '\0', sizeof(char) * 10);
#endif
        if(!cpu.cpubusywait){
            pc = GetProgramCounter(&cpu);
            instr_arm = ReadInstruction32(&cpu, &mem);
            type = ARMV4_ParseInstruction((ARM_Word)instr_arm);
//            PrintInstruction(&cpu, type, *pc);
            cpu.cpubusywait  = ARMV4_ExecuteInstruction(&cpu, &mem, (ARMV4_Instruction)instr_arm, type);
            cpu.cpubusywait = 0; /* test */
            ++numcycles; /* test */
#if 1            
            if(cpu.exception) /* test */
                break;
#endif
            exp = HandleException(&cpu); /*undefined, interrupt, SWI, data abort, etc */

            if(exp == ARM_Exception_Unpredictable){
                printf("Unpredictable behaviour at address %u!\n",*pc);
                break;
            }
            if(!cpu.shouldflush)
                *pc += 4; /* cpu->cpsr.f.thumb ? 2 : 4; */
            else
                cpu.shouldflush = 0;
        }
        else
            --cpu.cpubusywait;
        while(SDL_PollEvent(&e)){
            if(e.type == SDL_QUIT)
                quit = 1;
            if(e.type == SDL_KEYDOWN)
                quit = 1;
        }
        
        if(*pc & 0x3)
            break;
        
    }
    DestroyMemory(&mem);
    printf("Time elapsed: %f\n", (float)SDL_GetTicks() * 0.001f);
    printf("Instructions executed: %lu\n", numcycles);
    printf("MIPS: %f\n",((float)numcycles / ((float)SDL_GetTicks() * 0.001f)) * 0.000001f);
    return 0;
}