Player::Player( sf::Vector2i&& position, const sf::IntRect& rect, std::shared_ptr< const Texture > texture, SpriteGroup& group, Physics& physics, const GameplaySettings& settings, std::function< void( ) > onPlayerKilled ) : m_position( std::make_shared< PositionComponent >( *this, std::move( position ) ) ) , m_moveIntent( std::make_shared< MoveIntentComponent >( *this, settings.GetMoveIntentParameters() ) ) , m_halfSize( settings.playerOffset + ( sf::Vector2i( settings.playerSize.x, settings.playerSize.y ) / 2 ) ) { AddComponent( m_position ); AddComponent( m_moveIntent ); AddComponent( std::make_shared< SpriteComponent >( *this, texture, group ) ); AddComponent( std::make_shared< RectComponent >( *this, rect ) ); auto healthComponent( std::make_shared< HealthComponent >( *this, 1 ) ); healthComponent->SetKillCallback( onPlayerKilled ); AddComponent( healthComponent ); // TODO: Player Health > 1? std::weak_ptr< HealthComponent > weakHC( healthComponent ); auto movableComponent = std::make_shared< MovableComponent >( *this, physics ); movableComponent->SetMaxStep( settings.stepHeight ); // die on contact with enemy movableComponent->SetCollideCallback( [ weakHC ]( Entity& other ) { if( other.HasGroup( Entity::Group::Enemy ) ) { auto healthComp( weakHC.lock() ); if( healthComp ) healthComp->Kill(); } } ); AddComponent( movableComponent ); AddComponent( std::make_shared< GravityComponent >( *this, settings.gravity ) ); AddGroup( Group::Player ); InitComponents(); }
void ActorFactory::LoadFile(const char* i_szFilename) { if(!i_szFilename) { MGD_LOG::LOGManager::GetSingleton().WriteLog(MGD_LOG::MGD_ERROR, ACTOR_FACTORY_CONTEXT, "File name incorrect: %s", i_szFilename); return; } tinyxml2::XMLDocument oDocument; tinyxml2::XMLError oErr = oDocument.LoadFile(i_szFilename); if(oErr != tinyxml2::XML_NO_ERROR) { MGD_LOG::LOGManager::GetSingleton().WriteLog(MGD_LOG::MGD_ERROR, ACTOR_FACTORY_CONTEXT, "Error loading file: %s", i_szFilename); return; } const tinyxml2::XMLElement* pRoot = oDocument.RootElement(); if(pRoot) { MGDVector<Component*> oNewComponents; //CREATE ACTOR TEMPLATES for (const tinyxml2::XMLElement* pTemplateActor = pRoot->FirstChildElement("TemplateActor"); pTemplateActor; pTemplateActor = pTemplateActor->NextSiblingElement("TemplateActor")) { CreateTemplateActor(pTemplateActor); } //CREATE ACTOR for (const tinyxml2::XMLElement* pActor = pRoot->FirstChildElement("Actor"); pActor; pActor = pActor->NextSiblingElement("Actor")) { CreateActor(pActor, oNewComponents); } InitComponents(oNewComponents); } }
LineChartPane::LineChartPane(wxWindow *parent, ChartParams params, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) : wxPanel( parent, id, pos, size, style, name), m_chartParams(params) { InitComponents(); }
GPSPane::GPSPane(wxWindow *parent, ChartParams chartParams, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) : wxPanel( parent, id, pos, size, style, name), m_chartParams(chartParams), m_currentLatitude(0), m_currentLongitude(0) { InitComponents(); }
MainFrame(wxApp& app, const wxString& example_name) : wxFrame( (wxWindow*)0, wxID_ANY, wxT("OGLplus example"), wxDefaultPosition, wxSize(300, 600)) , status_bar(new wxStatusBar(this)) , tmp_canvas(new wxGLCanvas( (wxWindow*)this, wxID_ANY, GLConfig(), wxDefaultPosition, wxDefaultSize)) , gl_context(tmp_canvas) , api_init(nullptr) , example_frame(nullptr) { InitComponents(example_name); Show(); SetStatus(wxT("Initializing GL")); gl_context.SetCurrent(*tmp_canvas); api_init = new oglplus::GLAPIInitializer(); delete tmp_canvas; SetStatus(wxT("Ready")); Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(MainFrame::OnClose)); example_frame = new ExampleFrame( app, (wxWindow*)this, example_name, (ExampleInfoDisplay*)this, &gl_context); SetStatus(wxT("Running")); }
void ActorFactory::CreateActorFromTemplate(const char* i_pTemplateActorName, const char* i_pActorName) { if (i_pTemplateActorName && strlen(i_pTemplateActorName) > 0 && i_pActorName && strlen(i_pActorName) > 0) { MGDVector<Component*> pTemplateComponents; SystemManager::GetSingleton().GetComponentsFromTemplate(ObjectId(i_pTemplateActorName), pTemplateComponents); MGDVector<Component*> pNewComponents; for (uint32 uiIndex = 0; uiIndex < pTemplateComponents.size(); ++uiIndex) { Component* pComponent = GetSingleton().m_Factory.Create(pTemplateComponents[uiIndex]->GetID(), i_pActorName, true); if (pComponent) { pComponent->CreateFromTemplate(pTemplateComponents[uiIndex], ObjectId(i_pActorName)); SystemManager::GetSingleton().AddComponent(pComponent, ObjectId(i_pActorName)); pNewComponents.push_back(pComponent); } } InitComponents(pNewComponents); } }
s32 SelectGame() { u32 keys; s32 loadst = 0; s32 menu_state = 0; s32 menu_pos = 0; s8* newpackfile = NULL; gp2x_video_RGB_clearscreen16(); gp2x_video_flip(); #if 1 for(;;) { gp2x_video_RGB_clearscreen16(); backg(); //exems(); //gp2x_timer_delay(500000); keys = gp2x_joystick_read(); gp2x_printf(NULL, 10, (menu_pos * 10) + PSX4ALL_MENU_START_POS, PSX4ALL_ROW2); if( keys & GP2X_UP ) { if( menu_pos > 0 ) menu_pos--; } switch(menu_state) { case PSX4ALL_MENU_DEFAULT_STATE: if( keys & GP2X_DOWN ) { if (psx4all_emulating) { if( menu_pos < 4 ) menu_pos++; }else{ if( menu_pos < 3 ) menu_pos++; } } break; case PSX4ALL_MENU_OPTIONS_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 2 ) menu_pos++; } break; case PSX4ALL_MENU_GPU_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 15 ) menu_pos++; } break; case PSX4ALL_MENU_SPU_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 1 ) menu_pos++; } break; /*case PSX4ALL_MENU_ABOUT_STATE: if( keys & GP2X_B ) { if( menu_pos < 0 ) menu_pos++; } break;*/ case PSX4ALL_MENU_GAMESTATE_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 4 ) menu_pos++; } break; } switch(menu_state) { case PSX4ALL_MENU_DEFAULT_STATE: gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 0, PSX4ALL_OPT); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 10, PSX4ALL_FO); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 20, PSX4ALL_ABOUT); if (psx4all_emulating) { gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 30, PSX4ALL_RES); if(psx4all_emulating){ gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 40, PSX4ALL_QT); break; } }else { gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 30, PSX4ALL_QT); } break; case PSX4ALL_MENU_OPTIONS_STATE: gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 0, PSX4ALL_GS); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 10, PSX4ALL_SS); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 20, PSX4ALL_BK); break; case PSX4ALL_MENU_GPU_STATE: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, PSX4ALL_FPS, (displayFrameInfo == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 10, PSX4ALL_GPU, (displayGpuStats == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 20, PSX4ALL_MEM, (displayVideoMemory == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 30, PSX4ALL_GPUS, (activeNullGPU == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 40, PSX4ALL_IC, linesInterlace_user ); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 50, PSX4ALL_FL, (enableFrameLimit == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 60, PSX4ALL_SKIP, skipCount, skipRate); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 70, PSX4ALL_HACK, (enableAbbeyHack == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 80, PSX4ALL_CM, PsxCycleMult); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 90, PSX4ALL_FRL, hardframeskip_line ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 100, PSX4ALL_FPL, hardframeskip_poly ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 110, PSX4ALL_FST, hardframeskip_sprite ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 120, PSX4ALL_FIM, hardframeskip_image ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 130, PSX4ALL_FBT, hardframeskip_blit ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 140, PSX4ALL_WTM, use_wall_clock_time ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 150, PSX4ALL_BK); break; case PSX4ALL_MENU_SPU_STATE: gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 0, PSX4ALL_SND, (iSoundMuted == 0 ? "ON" : "OFF")); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 10, PSX4ALL_BK); break; case PSX4ALL_MENU_GAMESTATE_STATE: gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 0, PSX4ALL_SST); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 10, PSX4ALL_LST); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 20, PSX4ALL_LG); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 30, PSX4ALL_LGW); gp2x_printf(NULL, 100, PSX4ALL_MENU_START_POS + 40, PSX4ALL_BK); break; case PSX4ALL_MENU_ABOUT_STATE: gp2x_printf(NULL, 0, 50, PSX4ALL_NAME " V " PSX4ALL_VERSION "." PSX4ALL_BUILD " By " PSX4ALL_BY); gp2x_printf(NULL, 0, 60, PSX4ALL_CREDITS); gp2x_printf(NULL, 0, 70, PSX4ALL_PORT); gp2x_printf(NULL, 0, 80, PSX4ALL_PTI " " PSX4ALL_PLAT); gp2x_printf(NULL, 0, 100, PSX4ALL_PRM); break; } switch(menu_state) { case PSX4ALL_MENU_DEFAULT_STATE: if (psx4all_emulating) { if( keys & GP2X_B ) { switch(menu_pos) { case 0: menu_state = PSX4ALL_MENU_OPTIONS_STATE; menu_pos = 0; break; case 1: menu_state = PSX4ALL_MENU_GAMESTATE_STATE; menu_pos = 0; break; case 2: menu_state = PSX4ALL_MENU_ABOUT_STATE; menu_pos = 0; break; case 3: gp2x_video_RGB_clearscreen16(); return 0; case 4: SDL_Quit(); default: break; } } }else{ if( keys & GP2X_B ) { switch(menu_pos) { case 0: menu_state = PSX4ALL_MENU_OPTIONS_STATE; menu_pos = 0; break; case 1: menu_state = PSX4ALL_MENU_GAMESTATE_STATE; menu_pos = 0; break; case 2: menu_state = PSX4ALL_MENU_ABOUT_STATE; menu_pos = 0; break; case 3: gp2x_video_RGB_clearscreen16(); return 0; default: break; } } } if (keys & GP2X_L && psx4all_emulating) { gp2x_video_RGB_clearscreen16(); return 0; } break; case PSX4ALL_MENU_OPTIONS_STATE: switch(menu_pos) { case 0: if (keys & GP2X_B){ menu_state = PSX4ALL_MENU_GPU_STATE; menu_pos = 0; }break; case 1: if( keys & GP2X_B){ menu_state = PSX4ALL_MENU_SPU_STATE; menu_pos = 0; } break; case 2: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; default: break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; case PSX4ALL_MENU_GPU_STATE: switch(menu_pos) { case 0: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { displayFrameInfo = !displayFrameInfo; } break; case 1: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { displayGpuStats = !displayGpuStats; } break; case 2: if( keys & GP2X_B ) { displayVideoMemory = !displayVideoMemory; } break; case 3: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { activeNullGPU = !activeNullGPU; } break; case 4: if ( keys & GP2X_LEFT && linesInterlace_user > 0) linesInterlace_user--; if ( keys & GP2X_RIGHT && linesInterlace_user < 7) linesInterlace_user++; break; case 5: if( keys & GP2X_B ) { enableFrameLimit = !enableFrameLimit; } break; case 6: if( keys & GP2X_LEFT ) { if( skipValue > 0 ) { skipValue--; skipCount = skipCountTable[skipValue]; skipRate = skipRateTable[skipValue]; } } if( keys & GP2X_RIGHT ) { if( skipValue < 8 ) { skipValue++; skipCount = skipCountTable[skipValue]; skipRate = skipRateTable[skipValue]; } } break; case 7: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { enableAbbeyHack = !enableAbbeyHack; } break; case 8: if ( keys & GP2X_LEFT && PsxCycleMult > 1) PsxCycleMult--; if ( keys & GP2X_RIGHT && PsxCycleMult < 10) PsxCycleMult++; break; case 9: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { hardframeskip_line = !hardframeskip_line; } break; case 10: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { hardframeskip_poly = !hardframeskip_poly; } break; case 11: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { hardframeskip_sprite = !hardframeskip_sprite; } break; case 12: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { hardframeskip_image = !hardframeskip_image; } break; case 13: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { hardframeskip_blit = !hardframeskip_blit; } break; case 14: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { use_wall_clock_time = !use_wall_clock_time; } break; case 15: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_OPTIONS_STATE; menu_pos = 0; } break; default: break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_OPTIONS_STATE; menu_pos = 0; } break; case PSX4ALL_MENU_SPU_STATE: switch(menu_pos) { case 0: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { #ifndef NOSOUND iSoundMuted = !iSoundMuted; #endif } break; case 1: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_OPTIONS_STATE; menu_pos = 0; } break; default: break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_OPTIONS_STATE; menu_pos = 0; } break; case PSX4ALL_MENU_GAMESTATE_STATE: switch(menu_pos) { case 0: if( keys & GP2X_B ) { #ifndef IPHONE if( 1 == psx4all_emulating ) { s32 ret; char buffer[360]; char filename[260]; struct stat s; for(int count = 1;; count++) { sprintf(filename, "%s-%04d.svs", packfile, count); if (stat(filename, &s)) break; } gp2x_printf(NULL, 100, 130, PSX4ALL_SV); gp2x_video_flip(); GPU_freeze(2, NULL); ret = SaveState(filename); if (ret == 0) sprintf(buffer, PSX4ALL_SVD); else sprintf(buffer, PSX4ALL_ESV); gp2x_printf(NULL, 100, 140, PSX4ALL_STR, buffer); gp2x_video_flip(); gp2x_timer_delay(900); } #endif } break; case 1: if( keys & GP2X_B ) { #ifndef IPHONE gp2x_timer_delay(500); newpackfile = FileReq(NULL, FORMAT_SV); #endif } break; case 2: if( keys & GP2X_B ) { #ifndef IPHONE Config.HLE = 0; gp2x_timer_delay(500); newpackfile = FileReq(NULL, NULL); #endif } break; case 3: if( keys & GP2X_B ) { #ifndef IPHONE Config.HLE = 1; gp2x_timer_delay(500); newpackfile = FileReq(NULL, NULL); #endif } break; case 4: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; default: break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; case PSX4ALL_MENU_ABOUT_STATE: switch(menu_pos) { case 0: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; default: break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; } if( newpackfile != NULL ) { break; } gp2x_video_flip(); gp2x_timer_delay(90); if(keys & (GP2X_A|GP2X_B|GP2X_X|GP2X_Y|GP2X_L|GP2X_R|GP2X_PUSH| GP2X_LEFT|GP2X_RIGHT|GP2X_UP|GP2X_DOWN) ) { gp2x_timer_delay(50); } } #else Config.HLE = 1; //newpackfile = "Cotton Jap.cbn"; #endif DEBUGF("loaded "PSX4ALL_STR, newpackfile); packfile = newpackfile; gp2x_video_RGB_clearscreen16(); keys = gp2x_joystick_read(); backg(); LoadCdBios = 0; if( (!strcasecmp(packfile + (strlen(packfile)-4), FORMAT_SV)) ) { char *pos; loadst = 1; sprintf(svsfilename, PSX4ALL_STR, packfile); pos = strrchr(packfile, '-'); if (pos) *pos = '\0'; } else { loadst = 0; } if( loadst > 0 ) { gp2x_printf(NULL, 120, 90, PSX4ALL_LDG); } else { gp2x_printf(NULL, 120, 90, PSX4ALL_LDB); } gp2x_video_flip(); if( 1 == psx4all_emulating ) { psxShutdown(); CloseComponents(); } if (SysInit() == -1) { gp2x_deinit(); return 0; } if (InitComponents() == -1) { gp2x_deinit(); return 0; } SysReset(); CheckCdrom(); if( Config.HLE ) { LoadCdBios = 0; if( LoadCdrom() == -1 ) { gp2x_printf(NULL, 120, 120, PSX4ALL_LDD); gp2x_video_flip(); gp2x_timer_delay(2000); gp2x_video_RGB_clearscreen16(); backg(); return 0; } } else { gp2x_printf(NULL, 120, 120, PSX4ALL_LDY); gp2x_video_flip(); gp2x_timer_delay(90); backg(); } if (loadst) { if( LoadState(svsfilename) == -1 ) { gp2x_printf(NULL, 120, 120, PSX4ALL_LSF); gp2x_video_flip(); gp2x_timer_delay(2000); gp2x_video_RGB_clearscreen16(); return 0; } } return 1; }
int main(int argc, char *argv[]) #endif { #ifndef IPHONE #if defined(ARM_ARCH) ChangeWorkingDirectory(argv[0]); getcwd(gamepath, 256); #else #if defined(__WIN32__) if(argc == 1) strncpy(gamepath,"E:\\ps1",256); else strncpy(gamepath,argv[1],256); #else strncpy(gamepath,ROM_PREFIX,256); #endif #endif #endif #ifdef PSP sprintf(gamepath,""); #endif #ifdef IPHONE sprintf(gamepath,""); #endif memset(&Config, 0, sizeof(PsxConfig)); Config.PsxAuto = 1; Config.Cdda = 1; Config.Xa = 0; #ifdef DYNAREC Config.Cpu = 0; #else Config.Cpu = 1; #endif #ifdef WITH_HLE Config.HLE = 1; #else Config.HLE = 0; #endif Config.Mdec = 0; Config.PsxOut = 0; Config.PsxType = 0; Config.QKeys = 0; Config.RCntFix = 0; Config.Sio = 0; Config.SpuIrq = 1; Config.VSyncWA = 0; #if defined(PSP) || defined(SDL) || defined(IPHONE) sprintf(Config.BiosDir, "%s/Media/ROMs/PSX/", appworkdir); sprintf(Config.Bios, "scph1001.bin"); sprintf(Config.Mcd1, "mcd001.mcr"); sprintf(Config.Mcd2, "mcd002.mcr"); #else sprintf(Config.BiosDir, PSX4ALL_STR, gamepath); sprintf(Config.Bios, "/bios/scph1000.bin"); sprintf(Config.Mcd1, "%s/memory_card/mcd001.mcr", gamepath); sprintf(Config.Mcd2, "%s/memory_card/mcd002.mcr", gamepath); #endif gp2x_init(900, 16, 11025, 16, 1, 60, 1); #ifndef GP2X gp2x_video_flip_single(); #endif #ifdef IPHONE u32 loadsvs = 0; linesInterlace_user = preferences.interlace; skipCount = skipCountTablePhone[preferences.frameSkip]; skipRate = skipRateTablePhone[preferences.frameSkip]; iSoundMuted = preferences.muted; Config.Cdda = preferences.muted; Config.Xa = preferences.muted; #ifdef WITH_HLE Config.HLE = !preferences.bios; #else Config.HLE = 0; #endif if( (!strcasecmp(filename + (strlen(filename)-4), FORMAT_SV )) ) { u32 pos; loadsvs = 1; sprintf(svsfilename, PSX4ALL_STR, filename); sprintf(iphonefile, PSX4ALL_STR, filename); pos = strlen(iphonefile)-18; iphonefile[pos] = '\0'; packfile = iphonefile; } else { loadsvs = 0; sprintf(iphonefile, PSX4ALL_STR, filename); packfile = iphonefile; } gp2x_video_RGB_clearscreen16(); LoadCdBios = 0; if (SysInit() == -1) { gp2x_deinit(); return 0; } if (InitComponents() == -1) { gp2x_deinit(); return 0; } SysReset(); CheckCdrom(); if( Config.HLE ) { LoadCdBios = 0; if( LoadCdrom() == -1 ) { gp2x_printf(NULL, 120, 120, PSX4ALL_LDD); gp2x_video_flip(); gp2x_timer_delay(2000); gp2x_video_RGB_clearscreen16(); return 0; } } if (loadsvs) { if( LoadState(svsfilename) == -1 ) { gp2x_printf(NULL, 120, 120, PSX4ALL_LSF); gp2x_video_flip(); gp2x_timer_delay(2000); gp2x_video_RGB_clearscreen16(); psxShutdown(); CloseComponents(); gp2x_deinit(); pthread_exit(NULL); } } psx4all_emulating=1; psx4all_prof_start(PROFILER_TOTAL); psxCpu->Execute(); psx4all_prof_end(PROFILER_TOTAL); psx4all_emulating=0; psx4all_prof_show(); #else if( 0 != SelectGame() ) { psx4all_emulating=1; psx4all_prof_start(PROFILER_TOTAL); psxCpu->Execute(); psx4all_prof_end(PROFILER_TOTAL); psx4all_emulating=0; psx4all_prof_show(); } #endif gp2x_deinit(); return 0; }
SpectraDocumentFrame::SpectraDocumentFrame( SpectraApp& app, SpectraMainFrame* parent, wxGLContext* parent_ctxt, const SpectraDocumentFrame::VisualisationGetter& get_doc_vis, const SpectraDocumentFrame::RendererGetter& get_renderer ): wxFrame( (wxWindow*)parent, wxID_ANY, wxGetTranslation(wxT("Opening document")), wxDefaultPosition, wxDefaultSize ), parent_app(app) , main_frame(parent) , main_menu(new wxMenuBar()) , main_panel( new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize ) ), status_bar(new wxStatusBar(this)) , parent_context(parent_ctxt) , gl_canvas( new SpectraDocumentCanvas( (wxEvtHandler*)this, (wxWindow*)main_panel ) ), document_vis() , renderer() , idle_call_count(0) { assert(gl_canvas); InitMainMenu(); InitComponents(); Show(); document_vis = get_doc_vis( parent_app, main_frame, gl_canvas, parent_context ); assert(document_vis); document_vis->AddCanvas(gl_canvas); renderer = get_renderer( parent_app, main_frame, document_vis, gl_canvas ); assert(renderer); document_view.SetMaxTime(document_vis->Document().MaxTime()); ConnectEventHandlers(); HandleResize(); SetTitle(document_vis->Name()); SetStatus(wxT("TODO: short document info")); }
SpectraMainFrame::SpectraMainFrame(SpectraApp& app) : wxFrame( (wxWindow*)nullptr, wxID_ANY, wxT("OGLplus Spectra"), wxDefaultPosition, wxSize(300, 400) ), parent_app(app) , main_menu(new wxMenuBar()) , status_bar(new wxStatusBar(this)) , gl_canvas( new wxGLCanvas( (wxWindow*)this, wxID_ANY, SpectraGLConfig(), wxDefaultPosition, wxDefaultSize ) ), gl_context(gl_canvas) , gl_api_init() , shared_objects() , coroutine_exec() { InitMainMenu(); InitComponents(); Show(); coroutine_exec = std::make_shared<SpectraCoroutineExecutor>( parent_app, this //TODO progress panel + sizer ); SetStatus(wxGetTranslation(wxT("Initializing GL"), wxT("Status"))); gl_context.SetCurrent(*gl_canvas); gl_api_init.reset(new oglplus::GLAPIInitializer()); gl_canvas->Hide(); gl_vendor->SetLabel(wxString( (const char*)glGetString(GL_VENDOR), wxConvUTF8 )); gl_renderer->SetLabel(wxString( (const char*)glGetString(GL_RENDERER), wxConvUTF8 )); gl_version->SetLabel(wxString( (const char*)glGetString(GL_VERSION), wxConvUTF8 )); sl_version->SetLabel(wxString( (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION), wxConvUTF8 )); SetStatus(wxGetTranslation(wxT("Creating shared objects"), wxT("Status"))); shared_objects = std::make_shared<SpectraSharedObjects>(&gl_context, gl_canvas); SetStatus(wxGetTranslation(wxT("Ready"), wxT("Status"))); ConnectEventHandlers(); SetStatus(wxGetTranslation(wxT("Running"), wxT("Status"))); }
cTimeDateDisplay::cTimeDateDisplay(QWidget *parent) : QGroupBox (parent) //QWidget(parent) { InitComponents(); Update(); }
StaticSprite::StaticSprite( sf::Vector2i&& position, std::shared_ptr< const Texture > texture, SpriteGroup& group ) { AddComponent( std::make_shared< PositionComponent >( *this, std::move( position ) ) ); AddComponent( std::make_shared< SpriteComponent >( *this, texture, group ) ); InitComponents(); }
void MoveableEntity::Init() { InitComponents(); mVel = NVector(0, 0); }
s32 SelectGame() { u32 keys; s32 loadst = 0; s32 menu_state = 0; s32 menu_pos = 0; s8* newpackfile = NULL; gp2x_video_RGB_clearscreen16(); gp2x_video_flip(); #if 1 // pick a game for(;;) { gp2x_video_RGB_clearscreen16(); gp2x_printf(NULL, 0, 10, "psx4all http://github.com/uli/psx4all-dingoo"); gp2x_printf(NULL, 0, 20, "CREDITS: UNAI - ZODTTD - HLIDE - CHUI - TINNUS"); gp2x_printf(NULL, 0, 30, "Dingoo/MIPS port by Ulrich Hecht"); keys = gp2x_joystick_read(); // draw arrow gp2x_printf(NULL, 10, (menu_pos * 10) + PSX4ALL_MENU_START_POS, "----> "); // read key input for up and down for menu position if( keys & GP2X_UP ) { if( menu_pos > 0 ) menu_pos--; } switch(menu_state) { case PSX4ALL_MENU_DEFAULT_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 4 ) menu_pos++; } break; case PSX4ALL_MENU_GPU_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 15 ) menu_pos++; } break; case PSX4ALL_MENU_SPU_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 1 ) menu_pos++; } break; case PSX4ALL_MENU_BIOS_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 1 ) menu_pos++; } break; case PSX4ALL_MENU_GAMESTATE_STATE: if( keys & GP2X_DOWN ) { if( menu_pos < 4 ) menu_pos++; } break; } // text to display for each option switch(menu_state) { case PSX4ALL_MENU_DEFAULT_STATE: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "GRAPHICS OPTIONS"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 10, "SOUND OPTIONS"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 20, "BIOS OPTIONS"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 30, "FILE OPTIONS"); if (psx4all_emulating) gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 40, "RESUME EMULATION"); else gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 40, "QUIT"); break; case PSX4ALL_MENU_GPU_STATE: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Show FPS %s", (displayFrameInfo == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 10, "Show GPU Stats %s", (displayGpuStats == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 20, "Display Video Memory %s", (displayVideoMemory == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 30, "Set NULL GPU %s", (activeNullGPU == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 40, "Interlace Count %d", linesInterlace_user ); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 50, "Frame Limit %s", (enableFrameLimit == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 60, "Frame Skip %d/%d", skipCount, skipRate); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 70, "Abe's Oddysee Fix %s", (enableAbbeyHack == false ? "OFF" : "ON")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 80, "Cycle Multiplier %d", PsxCycleMult); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 90, "Frameskip: Line %s", hardframeskip_line ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 100, "Frameskip: Poly %s", hardframeskip_poly ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 110, "Frameskip: Sprite %s", hardframeskip_sprite ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 120, "Frameskip: Image %s", hardframeskip_image ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 130, "Frameskip: Blit %s", hardframeskip_blit ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 140, "Wall Clock Timing %s", use_wall_clock_time ? "ON" : "OFF"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 150, "<-Back"); break; case PSX4ALL_MENU_SPU_STATE: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "SOUND IS %s", (iSoundMuted == 0 ? "ON" : "OFF")); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 10, "BACK"); break; case PSX4ALL_MENU_BIOS_STATE: switch(biosVersion) { case 0: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph1000 (Japanese)"); break; case 1: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph1001 (North American)"); break; case 2: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph1002 (European)"); break; case 3: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph5500 (Japanese)"); break; case 4: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph5501 (North American)"); break; case 5: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph5502 (European)"); break; case 6: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph7001 (North American)"); break; case 7: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph7002 (European)"); break; case 8: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph7003 (Asian)"); break; case 9: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph7500 (Japanese)"); break; case 10: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph7501 (North American)"); break; case 11: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph7502 (European)"); break; case 12: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "Bios file: scph7503 (Japanese updated)"); break; default: break; } gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 10, "BACK"); break; case PSX4ALL_MENU_GAMESTATE_STATE: gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 0, "SAVE GAME STATE" ); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 10, "LOAD GAME STATE"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 20, "LOAD A GAME"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 30, "LOAD A GAME WITHOUT BIOS"); gp2x_printf(NULL, 80, PSX4ALL_MENU_START_POS + 40, "BACK"); break; } // logic for each option switch(menu_state) { case PSX4ALL_MENU_DEFAULT_STATE: if( keys & GP2X_B ) { switch(menu_pos) { case 0: menu_state = PSX4ALL_MENU_GPU_STATE; menu_pos = 0; break; case 1: menu_state = PSX4ALL_MENU_SPU_STATE; menu_pos = 0; break; case 2: menu_state = PSX4ALL_MENU_BIOS_STATE; menu_pos = 0; break; case 3: menu_state = PSX4ALL_MENU_GAMESTATE_STATE; menu_pos = 0; break; case 4: // clear screen so interlaced screens look ok gp2x_video_RGB_clearscreen16(); return 0; default: break; } } if (keys & GP2X_L && psx4all_emulating) { gp2x_video_RGB_clearscreen16(); return 0; } break; case PSX4ALL_MENU_GPU_STATE: switch(menu_pos) { case 0: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { displayFrameInfo = !displayFrameInfo; } break; case 1: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { displayGpuStats = !displayGpuStats; } break; case 2: if( keys & GP2X_B ) { displayVideoMemory = !displayVideoMemory; } break; case 3: if( keys & GP2X_B ) { activeNullGPU = !activeNullGPU; } break; case 4: if( keys & GP2X_LEFT ) { switch( linesInterlace_user ) { case 0: linesInterlace_user = 7; break; case 1: linesInterlace_user = 0; break; case 3: linesInterlace_user = 1; break; case 7: linesInterlace_user = 3; break; } } if( keys & GP2X_RIGHT ) { switch( linesInterlace_user ) { case 0: linesInterlace_user = 1; break; case 1: linesInterlace_user = 3; break; case 3: linesInterlace_user = 7; break; case 7: linesInterlace_user = 0; break; } } break; case 5: if( keys & GP2X_B ) { enableFrameLimit = !enableFrameLimit; } break; case 6: if( keys & GP2X_LEFT ) { if( skipValue > 0 ) { skipValue--; skipCount = skipCountTable[skipValue]; skipRate = skipRateTable[skipValue]; } } if( keys & GP2X_RIGHT ) { if( skipValue < 8 ) { skipValue++; skipCount = skipCountTable[skipValue]; skipRate = skipRateTable[skipValue]; } } break; case 7: if( keys & GP2X_B ) { enableAbbeyHack = !enableAbbeyHack; } break; case 8: if (keys & GP2X_LEFT && PsxCycleMult > 1) PsxCycleMult--; if (keys & GP2X_RIGHT && PsxCycleMult < 10) PsxCycleMult++; break; case 9: if( keys & GP2X_B ) { hardframeskip_line = !hardframeskip_line; } break; case 10: if( keys & GP2X_B ) { hardframeskip_poly = !hardframeskip_poly; } break; case 11: if( keys & GP2X_B ) { hardframeskip_sprite = !hardframeskip_sprite; } break; case 12: if( keys & GP2X_B ) { hardframeskip_image = !hardframeskip_image; } break; case 13: if( keys & GP2X_B ) { hardframeskip_blit = !hardframeskip_blit; } break; case 14: if( keys & GP2X_B ) { use_wall_clock_time = !use_wall_clock_time; } break; case 15: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; default: break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; case PSX4ALL_MENU_SPU_STATE: switch(menu_pos) { case 0: if( keys & GP2X_B || keys & GP2X_LEFT || keys & GP2X_RIGHT ) { #ifndef NOSOUND iSoundMuted = !iSoundMuted; #endif } break; case 1: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; case PSX4ALL_MENU_BIOS_STATE: switch(menu_pos) { case 0: if( keys & GP2X_B || keys & GP2X_RIGHT ) { biosVersion++; } else if( keys & GP2X_LEFT) { biosVersion--; } if(biosVersion < 0) biosVersion = 12; if(biosVersion > 12) biosVersion = 0; switch(biosVersion) { case 0: sprintf(Config.Bios, "/scph1000.bin"); break; case 1: sprintf(Config.Bios, "/scph1001.bin"); break; case 2: sprintf(Config.Bios, "/scph1002.bin"); break; case 3: sprintf(Config.Bios, "/scph5500.bin"); break; case 4: sprintf(Config.Bios, "/scph5501.bin"); break; case 5: sprintf(Config.Bios, "/scph5502.bin"); break; case 6: sprintf(Config.Bios, "/scph7001.bin"); break; case 7: sprintf(Config.Bios, "/scph7002.bin"); break; case 8: sprintf(Config.Bios, "/scph7003.bin"); break; case 9: sprintf(Config.Bios, "/scph7500.bin"); break; case 10: sprintf(Config.Bios, "/scph7501.bin"); break; case 11: sprintf(Config.Bios, "/scph7502.bin"); break; case 12: sprintf(Config.Bios, "/scph7503.bin"); break; default: break; } break; case 1: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; case PSX4ALL_MENU_GAMESTATE_STATE: switch(menu_pos) { case 0: if( keys & GP2X_B ) { #ifndef IPHONE if( 1 == psx4all_emulating ) { s32 ret; char buffer[360]; char filename[260]; struct stat s; for(int count = 1;; count++) { sprintf(filename, "%s-%04d.svs", packfile, count); if (stat(filename, &s)) break; } gp2x_printf(NULL, 80, 130, "Saving..."); gp2x_video_flip(); GPU_freeze(2, NULL); ret = SaveState(filename); if (ret == 0) sprintf(buffer, "Saved!"); else sprintf(buffer, "Error Saving!"); gp2x_printf(NULL, 80, 140, "%s", buffer); gp2x_video_flip(); gp2x_timer_delay(1000); } #endif } break; case 1: if( keys & GP2X_B ) { #ifndef IPHONE // pause so keys won't be accidently inputted in FileReq gp2x_timer_delay(500); newpackfile = FileReq(NULL, ".svs"); #endif } break; case 2: if( keys & GP2X_B ) { #ifndef IPHONE Config.HLE = 0; // pause so keys won't be accidently inputted in FileReq gp2x_timer_delay(500); newpackfile = FileReq(NULL, NULL); #endif } break; case 3: if( keys & GP2X_B ) { #ifndef IPHONE Config.HLE = 1; // pause so keys won't be accidently inputted in FileReq gp2x_timer_delay(500); newpackfile = FileReq(NULL, NULL); #endif } break; case 4: if( keys & GP2X_B ) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; } if (keys & GP2X_L) { menu_state = PSX4ALL_MENU_DEFAULT_STATE; menu_pos = 0; } break; } if( newpackfile != NULL ) { break; } gp2x_video_flip(); gp2x_timer_delay(100); if(keys & (GP2X_A|GP2X_B|GP2X_X|GP2X_Y|GP2X_L|GP2X_R|GP2X_PUSH| GP2X_LEFT|GP2X_RIGHT|GP2X_UP|GP2X_DOWN) ) { //gp2x_video_flip(); gp2x_timer_delay(50); } } #else //newpackfile = "Einhander.bin"; //newpackfile = "Einhander.cbn"; Config.HLE = 1; //newpackfile = "Cotton Jap.bin"; newpackfile = "Cotton Jap.cbn"; #endif DEBUGF("loaded %s", newpackfile); packfile = newpackfile; // clear screen gp2x_video_RGB_clearscreen16(); keys = gp2x_joystick_read(); LoadCdBios = 0; if( (!strcasecmp(packfile + (strlen(packfile)-4), ".svs")) ) { char *pos; loadst = 1; sprintf(svsfilename, "%s", packfile); pos = strrchr(packfile, '-'); if (pos) *pos = '\0'; } else { loadst = 0; } if( loadst > 0 ) { gp2x_printf(NULL, 120, 100, "LOADING SAVE STATE"); } else { gp2x_printf(NULL, 120, 100, "LOADING BIOS"); } gp2x_video_flip(); if( 1 == psx4all_emulating ) { psxShutdown(); CloseComponents(); } if (SysInit() == -1) { gp2x_deinit(); return 0; } if (InitComponents() == -1) { gp2x_deinit(); return 0; } SysReset(); CheckCdrom(); if( Config.HLE ) { LoadCdBios = 0; if( LoadCdrom() == -1 ) { gp2x_printf(NULL, 120, 120, "LOAD FAILED"); gp2x_video_flip(); gp2x_timer_delay(2000); // clear screen gp2x_video_RGB_clearscreen16(); return 0; } } else { gp2x_printf(NULL, 120, 120, "LOADED!"); gp2x_video_flip(); gp2x_timer_delay(100); } if (loadst) { if( LoadState(svsfilename) == -1 ) { gp2x_printf(NULL, 120, 120, "LOAD SAVE FAILED"); gp2x_video_flip(); gp2x_timer_delay(2000); // clear screen gp2x_video_RGB_clearscreen16(); return 0; } } return 1; }