Skip to content

Commit

Permalink
ARM: fix nec cpu (irem, raiden...)
Browse files Browse the repository at this point in the history
add frameskip as a menu option (frameskip disabled by default now)
  • Loading branch information
Cpasjuste committed Jan 24, 2017
1 parent abd1229 commit 580cb93
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 119 deletions.
21 changes: 13 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,12 @@ set(FLAGS
-DBUILD_SDL -DBUILD_M68K
-DTOAPLAN_SOUND_SAMPLES_HACK
-Wno-write-strings -Wno-narrowing
-D_fastcall= -D__fastcall= -D__fastcall__=
-fforce-addr -fcheck-new -finline-limit=1200
-DFASTCALL -U__fastcall -D_fastcall= -D__fastcall= -D__fastcall__=
"-DINLINE=static inline" "-DSH2_INLINE=static inline"
)
if (BUILD_DEBUG)
list(APPEND FLAGS -g -DDEBUG)
list(APPEND FLAGS -g -O0 -DDEBUG)
else ()
list(APPEND FLAGS -O3 -DNDEBUG)
endif (BUILD_DEBUG)
Expand All @@ -324,17 +325,21 @@ if (BUILD_PSP2)
pfba/cpu/cyclone/Cyclone.s
)
list(APPEND SRC_PFBA ${SRC_PSP2})
list(APPEND FLAGS -Wl,-q -D__PSP2__ -DBUILD_C68K -DUSE_FILE32API)
list(APPEND FLAGS
-Wl,-q -D__PSP2__
-DBUILD_C68K -DUSE_FILE32API)
if (BUILD_DEBUG)
list(APPEND FLAGS -D__PSP2_DEBUG__ -O1
-marm -mfpu=neon -mcpu=cortex-a9 -march=armv7-a)
else ()
list(APPEND FLAGS
-D__PSP2_DEBUG__ -D__ARM__ # TODO: cyclone arm asm core not working without O2/O3
)
else ()
list(APPEND FLAGS -D__ARM__
-marm -mfpu=neon -mcpu=cortex-a9 -march=armv7-a -mfloat-abi=hard -ffast-math
-fno-asynchronous-unwind-tables -funroll-loops
-mword-relocations -fno-unwind-tables -fno-optimize-sibling-calls
-mvectorize-with-neon-quad -funsafe-math-optimizations
-mlittle-endian -munaligned-access
-fsingle-precision-constant
)
endif (BUILD_DEBUG)
set(LDFLAGS
Expand Down Expand Up @@ -393,7 +398,7 @@ else ()
list(APPEND SRC_PFBA ${SRC_RPI})
# rpi3 compile flags
list(APPEND FLAGS
-D__RPI__ -DBUILD_C68K -DUSE_FILE32API
-D__RPI__ -D__ARM__ -DBUILD_C68K -DUSE_FILE32API
-march=armv8-a -mcpu=cortex-a53 -mtune=cortex-a53 -mfpu=neon-fp-armv8
-mfloat-abi=hard -mvectorize-with-neon-quad -funsafe-math-optimizations
-ffast-math -mlittle-endian -munaligned-access
Expand Down Expand Up @@ -434,7 +439,7 @@ add_custom_target(${PROJECT_NAME}.vpk
DEPENDS ${PROJECT_NAME}
COMMAND rm -rf vpk && mkdir -p vpk/sce_sys
COMMAND ${VITASDK}/bin/vita-elf-create ${PROJECT_NAME} ${PROJECT_NAME}.velf
COMMAND ${VITASDK}/bin/vita-make-fself -c ${PROJECT_NAME}.velf vpk/eboot.bin
COMMAND ${VITASDK}/bin/vita-make-fself -c -s ${PROJECT_NAME}.velf vpk/eboot.bin
COMMAND ${VITASDK}/bin/vita-mksfoex -s TITLE_ID=${TITLE_ID} "${PROJECT_NAME}" vpk/sce_sys/param.sfo
COMMAND cp -r ${CMAKE_SOURCE_DIR}/pfba/gui/skin vpk/
COMMAND cp -r ${CMAKE_SOURCE_DIR}/pfba/psp2/data/* vpk
Expand Down
4 changes: 2 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The linux and rpi3 ports currently run in fullscreen mode, doesn't support filte

>- mkdir cmake-build
>- cd cmake-build
>- cmake -DCMAKE_BUILD_TYPE=Release ..
>- cmake -DBUILD_SDL2=ON -DCMAKE_BUILD_TYPE=Release ..
>- make pfba.deps
>- make pfba
Expand All @@ -63,7 +63,7 @@ The linux and rpi3 ports currently run in fullscreen mode, doesn't support filte

>- mkdir cmake-build
>- cd cmake-build
>- cmake -DBUILD_RPI=ON -DCMAKE_BUILD_TYPE=Release ..
>- cmake -DBUILD_RPI=ON -DBUILD_SDL2=ON -DCMAKE_BUILD_TYPE=Release ..
>- make pfba.deps
>- make pfba
Expand Down
27 changes: 15 additions & 12 deletions pfba/TODO.TXT
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
# COMMON
========

add analog inputs (Super Hang-On, Outrun, Turbo Outrun, Power Drift...)
PSP2: load roms from ur0: ?
PSP2: add "disable right stick" option
add "EnableHiscores" option
add favorites section in hardware list
add joystick axis input configuration in gui
add > 1 joystick support
add help screen
PSP2: fix crash with non working roms (cps2 wrong set, ...) identified as 68K CycloneRun crash

# NEXT RELEASE
fix: clear buttons when exiting menu
add: service button switch (SELECT+SQUARE)
add: 1P+2P button switch (SELECT+TRIANGLE)
add: SELECT+LEFT/RIGHT = change shading
add: SELECT+UP/DOWN = change scaling
psp2: fix input button bg background in game (caused by shader)
fix: really fix arm m68k savestates (cyclone) by implenting CyclonePack/Unpack
fix: default input scheme not restored when exiting game
fix: default input scheme not restored when savestate called with START+L
ARM: fix nec cpu (irem, raiden...)
add frameskip as a menu option

# OLD RELEASES
DONE // fix: clear buttons when exiting menu
DONE // add: service button switch (SELECT+SQUARE)
DONE // add: 1P+2P button switch (SELECT+TRIANGLE)
DONE // add: SELECT+LEFT/RIGHT = change shading
DONE // add: SELECT+UP/DOWN = change scaling
DONE // psp2: fix input button bg background in game (caused by shader)
DONE // fix: really fix arm m68k savestates (cyclone) by implenting CyclonePack/Unpack
DONE // fix: default input scheme not restored when exiting game
DONE // fix: default input scheme not restored when savestate called with START+L
DONE // add: per platform input button name/icon in option ui
DONE // fix randrom fire1/fire2 inverted in menu ?!
DONE // fix "FIT" mode on vertical games
Expand All @@ -42,9 +48,6 @@ DONE // EMU: add disable audio option
DONE // GUI: hide rotation option if not needed
DONE // GUI: fix screenshot dismiss on gui option return

# PSP2
=====================


# RPI (raspbian jessy)
=====================
Expand Down
1 change: 1 addition & 0 deletions pfba/gui/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Config::Config(const std::string &cfgPath) {
Option("SHADER", {"NONE", "SHARP", "SHARP+SCAN", "LCD3X", "AAA", "SCALE2X"}, 2, Option::Index::ROM_SHADER));
options_gui.push_back(Option("ROTATION", {"OFF", "ON"}, 0, Option::Index::ROM_ROTATION));
options_gui.push_back(Option("SHOW_FPS", {"NO", "YES"}, 0, Option::Index::ROM_SHOW_FPS));
options_gui.push_back(Option("FRAMESKIP", {"OFF", "ON"}, 0, Option::Index::ROM_FRAMESKIP));
//options_gui.push_back(Option("M68K", {"ASM", "C"}, 0, Option::Index::ROM_M68K));
options_gui.push_back(Option("FORCE_60HZ", {"OFF", "ON"}, 0, Option::Index::ROM_FORCE_60HZ));
options_gui.push_back(
Expand Down
1 change: 1 addition & 0 deletions pfba/gui/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Option {
ROM_ROTATION,
ROM_SHOW_FPS,
//ROM_M68K,
ROM_FRAMESKIP,
ROM_FORCE_60HZ,
ROM_AUDIO_FREQ,
ROM_AUDIO_INTERPOLATION,
Expand Down
217 changes: 120 additions & 97 deletions pfba/run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,100 +60,96 @@ int RunReset() {
return 0;
}


int RunOneFrame(bool bDraw, int bDrawFps, int fps) {

inputServiceSwitch = 0;
inputP1P2Switch = 0;

if (bDraw) {

int rotation = gui->GetConfig()->GetRomValue(Option::Index::ROM_ROTATION);
bool rotate = (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) && !rotation;
Input::Player *players = gui->GetInput()->Update(rotate);
int rotation = gui->GetConfig()->GetRomValue(Option::Index::ROM_ROTATION);
bool rotate = (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) && !rotation;
Input::Player *players = gui->GetInput()->Update(rotate);

// process menu
if ((players[0].state & Input::Key::KEY_COIN)
&& (players[0].state & Input::Key::KEY_START)) {
bPauseOn = true;
if (audio) {
audio->Pause(1);
}
// set default control scheme
gui->UpdateInputMapping(false);
gui->RunOptionMenu(true);
// restore rom control scheme
gui->UpdateInputMapping(true);
if (audio) {
audio->Pause(0);
}
bPauseOn = false;
} else if ((players[0].state & Input::Key::KEY_COIN)
&& (players[0].state & Input::Key::KEY_FIRE5)) {
bPauseOn = true;
if (audio) {
audio->Pause(1);
}
// set default control scheme
gui->UpdateInputMapping(false);
gui->RunStatesMenu();
// restore rom control scheme
gui->UpdateInputMapping(true);
if (audio) {
audio->Pause(0);
}
bPauseOn = false;
} else if ((players[0].state & Input::Key::KEY_COIN)
&& (players[0].state & Input::Key::KEY_FIRE3)) {
inputServiceSwitch = 1;
} else if ((players[0].state & Input::Key::KEY_COIN)
&& (players[0].state & Input::Key::KEY_FIRE4)) {
inputP1P2Switch = 1;
} else if ((players[0].state & Input::Key::KEY_COIN)
&& (players[0].state & Input::Key::KEY_UP)) {
int scaling = gui->GetConfig()->GetRomValue(Option::Index::ROM_SCALING) + 1;
if (scaling <= 3) {
int index = gui->GetConfig()->GetOptionPos(gui->GetConfig()->GetRomOptions(),
Option::Index::ROM_SCALING);
gui->GetConfig()->GetRomOptions()->at(index).value = scaling;
video->Scale();
gui->GetRenderer()->Delay(500);
}
} else if ((players[0].state & Input::Key::KEY_COIN)
&& (players[0].state & Input::Key::KEY_DOWN)) {
int scaling = gui->GetConfig()->GetRomValue(Option::Index::ROM_SCALING) - 1;
if (scaling >= 0) {
int index = gui->GetConfig()->GetOptionPos(gui->GetConfig()->GetRomOptions(),
Option::Index::ROM_SCALING);
gui->GetConfig()->GetRomOptions()->at(index).value = scaling;
video->Scale();
gui->GetRenderer()->Delay(500);
}
} else if ((players[0].state & Input::Key::KEY_COIN)
&& (players[0].state & Input::Key::KEY_RIGHT)) {
int shader = gui->GetConfig()->GetRomValue(Option::Index::ROM_SHADER) + 1;
if (shader < gui->GetRenderer()->shaderCount) {
int index = gui->GetConfig()->GetOptionPos(gui->GetConfig()->GetRomOptions(),
Option::Index::ROM_SHADER);
gui->GetConfig()->GetRomOptions()->at(index).value = shader;
gui->GetRenderer()->SetShader(shader);
gui->GetRenderer()->Delay(500);
}
} else if ((players[0].state & Input::Key::KEY_COIN)
&& (players[0].state & Input::Key::KEY_LEFT)) {
int shader = gui->GetConfig()->GetRomValue(Option::Index::ROM_SHADER) - 1;
if (shader >= 0) {
int index = gui->GetConfig()->GetOptionPos(gui->GetConfig()->GetRomOptions(),
Option::Index::ROM_SHADER);
gui->GetConfig()->GetRomOptions()->at(index).value = shader;
gui->GetRenderer()->SetShader(shader);
gui->GetRenderer()->Delay(500);
}
// process menu
if ((players[0].state & Input::Key::KEY_COIN)
&& (players[0].state & Input::Key::KEY_START)) {
bPauseOn = true;
if (audio) {
audio->Pause(1);
}
// set default control scheme
gui->UpdateInputMapping(false);
gui->RunOptionMenu(true);
// restore rom control scheme
gui->UpdateInputMapping(true);
if (audio) {
audio->Pause(0);
}
bPauseOn = false;
} else if ((players[0].state & Input::Key::KEY_COIN)
&& (players[0].state & Input::Key::KEY_FIRE5)) {
bPauseOn = true;
if (audio) {
audio->Pause(1);
}
// set default control scheme
gui->UpdateInputMapping(false);
gui->RunStatesMenu();
// restore rom control scheme
gui->UpdateInputMapping(true);
if (audio) {
audio->Pause(0);
}
bPauseOn = false;
} else if ((players[0].state & Input::Key::KEY_COIN)
&& (players[0].state & Input::Key::KEY_FIRE3)) {
inputServiceSwitch = 1;
} else if ((players[0].state & Input::Key::KEY_COIN)
&& (players[0].state & Input::Key::KEY_FIRE4)) {
inputP1P2Switch = 1;
} else if ((players[0].state & Input::Key::KEY_COIN)
&& (players[0].state & Input::Key::KEY_UP)) {
int scaling = gui->GetConfig()->GetRomValue(Option::Index::ROM_SCALING) + 1;
if (scaling <= 3) {
int index = gui->GetConfig()->GetOptionPos(gui->GetConfig()->GetRomOptions(),
Option::Index::ROM_SCALING);
gui->GetConfig()->GetRomOptions()->at(index).value = scaling;
video->Scale();
gui->GetRenderer()->Delay(500);
}
} else if ((players[0].state & Input::Key::KEY_COIN)
&& (players[0].state & Input::Key::KEY_DOWN)) {
int scaling = gui->GetConfig()->GetRomValue(Option::Index::ROM_SCALING) - 1;
if (scaling >= 0) {
int index = gui->GetConfig()->GetOptionPos(gui->GetConfig()->GetRomOptions(),
Option::Index::ROM_SCALING);
gui->GetConfig()->GetRomOptions()->at(index).value = scaling;
video->Scale();
gui->GetRenderer()->Delay(500);
}
} else if ((players[0].state & Input::Key::KEY_COIN)
&& (players[0].state & Input::Key::KEY_RIGHT)) {
int shader = gui->GetConfig()->GetRomValue(Option::Index::ROM_SHADER) + 1;
if (shader < gui->GetRenderer()->shaderCount) {
int index = gui->GetConfig()->GetOptionPos(gui->GetConfig()->GetRomOptions(),
Option::Index::ROM_SHADER);
gui->GetConfig()->GetRomOptions()->at(index).value = shader;
gui->GetRenderer()->SetShader(shader);
gui->GetRenderer()->Delay(500);
}
} else if ((players[0].state & Input::Key::KEY_COIN)
&& (players[0].state & Input::Key::KEY_LEFT)) {
int shader = gui->GetConfig()->GetRomValue(Option::Index::ROM_SHADER) - 1;
if (shader >= 0) {
int index = gui->GetConfig()->GetOptionPos(gui->GetConfig()->GetRomOptions(),
Option::Index::ROM_SHADER);
gui->GetConfig()->GetRomOptions()->at(index).value = shader;
gui->GetRenderer()->SetShader(shader);
gui->GetRenderer()->Delay(500);
}

InpMake(players);
}

InpMake(players);

if (!bPauseOn) {
nFramesEmulated++;
nCurrentFrame++;
Expand Down Expand Up @@ -286,29 +282,56 @@ void RunEmulator(Gui *g, int drvnum) {

RunReset();

int timer = 0, tick = 0, fps = 0;

GameLooping = true;
StartTicks();
int frame_limit = nBurnFPS / 100, frametime = 100000000 / nBurnFPS;
int now = 0, done = 0, timer = 0, tick = 0, ticks = 0, fps = 0;

printf("---- PFBA EMU START ----\n\n");

StartTicks(); // no frameskip

GameLooping = true;
while (GameLooping) {

int showFps = gui->GetConfig()->GetRomValue(Option::Index::ROM_SHOW_FPS);
int frameSkip = gui->GetConfig()->GetRomValue(Option::Index::ROM_FRAMESKIP);

if (showFps) {
timer = GetTicks();
if (timer - tick > 1000000) {
if (frameSkip) {
timer = GetTicks() / frametime;
if (timer - tick > frame_limit && showFps) {
fps = nFramesRendered;
nFramesRendered = 0;
tick = timer;
}
}

RunOneFrame(true, showFps, fps);
if(audio) {
audio->Play();
now = timer;
ticks = now - done;
if (ticks < 1) continue;
if (ticks > 10) ticks = 10;
for (int i = 0; i < ticks - 1; i++) {
RunOneFrame(false, showFps, fps);
if (audio) {
audio->Play();
}
}
if (ticks >= 1) {
RunOneFrame(true, showFps, fps);
if (audio) {
audio->Play();
}
}
done = now;
} else {
if (showFps) {
timer = GetTicks();
if (timer - tick > 1000000) {
fps = nFramesRendered;
nFramesRendered = 0;
tick = timer;
}
}
RunOneFrame(true, showFps, fps);
if (audio) {
audio->Play();
}
}
}

Expand Down
Loading

0 comments on commit 580cb93

Please sign in to comment.