retro_frontend fixes for Tyrquake
- Implement RETRO_ENVIRONMENT_GET_USERNAME callback as a no-op. - Explicitly execute core in libc application context. - Pause audio only when audio is connected. - Fix keys in tyrquake run scenario, use depot packages, disable audio. Fix #76
This commit is contained in:
committed by
Norman Feske
parent
47259f7854
commit
9055c535e7
161
run/tyrquake.run
161
run/tyrquake.run
@@ -12,35 +12,21 @@ if {[expr [have_include "power_on/qemu"] && !$force_qemu]} {
|
||||
set wget [check_installed wget]
|
||||
set unzip [check_installed unzip]
|
||||
|
||||
set build_components {
|
||||
core init
|
||||
create_boot_directory
|
||||
|
||||
import_from_depot \
|
||||
genodelabs/src/[base_src] \
|
||||
genodelabs/pkg/[drivers_interactive_pkg] \
|
||||
genodelabs/src/init \
|
||||
genodelabs/src/report_rom \
|
||||
|
||||
build {
|
||||
app/retro_frontend
|
||||
drivers/audio
|
||||
drivers/framebuffer
|
||||
drivers/input
|
||||
drivers/timer
|
||||
libretro/tyrquake
|
||||
server/fb_upscale
|
||||
server/input_remap
|
||||
server/report_rom
|
||||
}
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
# override default platform driver policy
|
||||
proc platform_drv_policy {} {
|
||||
return {
|
||||
<policy label_prefix="ps2_drv"> <device name="PS2"/> </policy>
|
||||
<policy label_prefix="usb_drv"> <pci class="USB"/> </policy>
|
||||
<policy label_prefix="fb_drv"> <pci class="VGA"/> </policy>
|
||||
<policy label_prefix="audio_drv"> <pci class="AUDIO"/> <pci class="HDAUDIO"/> </policy>}
|
||||
}
|
||||
|
||||
append_platform_drv_build_components
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
@@ -60,58 +46,33 @@ append config {
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>}
|
||||
</default-route>
|
||||
|
||||
append_if [have_spec sdl] config {
|
||||
<start name="fb_sdl">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
|
||||
<start name="drivers" caps="1000">
|
||||
<resource name="RAM" quantum="32M"/>
|
||||
<binary name="init"/>
|
||||
<route>
|
||||
<service name="ROM" label="config"> <parent label="drivers.config"/> </service>
|
||||
<service name="Timer"> <child name="timer"/> </service>
|
||||
<any-service> <parent/> </any-service>
|
||||
</route>
|
||||
<provides>
|
||||
<service name="Input"/>
|
||||
<service name="Framebuffer"/>
|
||||
</provides>
|
||||
</start>
|
||||
<alias name="input_drv" child="fb_sdl"/>
|
||||
<alias name="fb_drv" child="fb_sdl"/>}
|
||||
|
||||
append_platform_drv_config
|
||||
|
||||
append_if [have_spec vesa] config {
|
||||
<start name="fb_drv">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="Framebuffer"/></provides>
|
||||
<config buffered="yes"> </config>
|
||||
<config width="640" height="480"/>
|
||||
</start>}
|
||||
|
||||
append_if [have_spec pl11x] config {
|
||||
<start name="fb_drv">
|
||||
<resource name="RAM" quantum="2M"/>
|
||||
<provides><service name="Framebuffer"/></provides>
|
||||
</start>}
|
||||
|
||||
append_if [have_spec ps2] config {
|
||||
<start name="ps2_drv">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Input"/></provides>
|
||||
</start>
|
||||
<alias name="input_drv" child="ps2_drv"/>}
|
||||
|
||||
append config {
|
||||
<start name="audio_drv">
|
||||
<binary name="} [audio_drv_binary] {"/>
|
||||
<resource name="RAM" quantum="8M"/>
|
||||
<provides> <service name="Audio_out"/> </provides>
|
||||
</start>
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
<start name="fb_upscale">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides> <service name="Framebuffer"/> </provides>
|
||||
<route>
|
||||
<service name="Framebuffer">
|
||||
<child name="fb_drv"/> </service>
|
||||
<child name="drivers"/> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
</start>
|
||||
@@ -119,23 +80,38 @@ append config {
|
||||
<resource name="RAM" quantum="2M"/>
|
||||
<provides> <service name="Input"/> </provides>
|
||||
<config>
|
||||
<!-- Retroarch mappings -->
|
||||
<map from="KEY_Z" to="BTN_B"/>
|
||||
<map from="KEY_A" to="BTN_Y"/>
|
||||
<map from="KEY_X" to="BTN_A"/>
|
||||
<map from="KEY_S" to="BTN_X"/>
|
||||
<!-- Map Genode keys to libretro keys.
|
||||
This is really awkward, keycodes from the 'retro_frontend -> input'
|
||||
report must be cross-referenced from libretro.h to the retro_frontend
|
||||
translation table. In the future the frontend may use logical
|
||||
names in the 'input' report or feature a built-in remapper.
|
||||
-->
|
||||
<map from="KEY_A" to="BTN_LEFT"/>
|
||||
<map from="KEY_W" to="BTN_FORWARD"/>
|
||||
<map from="KEY_S" to="BTN_BACK"/>
|
||||
<map from="KEY_D" to="BTN_RIGHT"/>
|
||||
|
||||
<map from="KEY_RIGHT" to="BTN_B"/>
|
||||
<map from="KEY_DOWN" to="BTN_A"/>
|
||||
<map from="KEY_LEFT" to="BTN_X"/>
|
||||
<map from="KEY_UP" to="BTN_Y"/>
|
||||
|
||||
<map from="KEY_Q" to="BTN_TL"/>
|
||||
<map from="KEY_W" to="BTN_TR"/>
|
||||
<map from="KEY_ENTER" to="BTN_START"/>
|
||||
<map from="KEY_RIGHTSHIFT" to="BTN_SELECT"/>
|
||||
<map from="KEY_LEFT" to="BTN_LEFT"/>
|
||||
<map from="KEY_RIGHT" to="BTN_RIGHT"/>
|
||||
<map from="KEY_UP" to="BTN_FORWARD"/>
|
||||
<map from="KEY_DOWN" to="BTN_BACK"/>
|
||||
<map from="KEY_E" to="BTN_TR"/>
|
||||
|
||||
<map from="KEY_LEFTSHIFT" to="BTN_THUMBL"/>
|
||||
|
||||
<map from="KEY_LEFTCTRL" to="BTN_TR2"/>
|
||||
<map from="KEY_SPACE" to="BTN_TL2"/>
|
||||
|
||||
|
||||
<map from="KEY_GRAVE" to="BTN_SELECT"/>
|
||||
<map from="KEY_ESC" to="BTN_START"/>
|
||||
<map from="KEY_ENTER" to="BTN_A"/>
|
||||
</config>
|
||||
<route>
|
||||
<service name="Input">
|
||||
<child name="input_drv"/> </service>
|
||||
<child name="drivers"/> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
</start>
|
||||
@@ -147,14 +123,13 @@ append config {
|
||||
<start name="retro_frontend">
|
||||
<resource name="RAM" quantum="64M"/>
|
||||
<config core="tyrquake_libretro.lib.so">
|
||||
<libc stdout="/dev/log" stderr="/dev/log">
|
||||
<vfs>
|
||||
<tar name="quake.tar"/>
|
||||
<dir name="dev"> <log/> </dir>
|
||||
<dir name="id1"> <tar name="quake.tar"/> </dir>
|
||||
<ram/>
|
||||
</vfs>
|
||||
</libc>
|
||||
<libc stdout="/dev/log" stderr="/dev/log"/>
|
||||
<vfs>
|
||||
<tar name="quake.tar"/>
|
||||
<dir name="dev"> <log/> </dir>
|
||||
<dir name="id1"> <tar name="quake.tar"/> </dir>
|
||||
<ram/>
|
||||
</vfs>
|
||||
</config>
|
||||
<route>
|
||||
<service name="Framebuffer">
|
||||
@@ -203,32 +178,18 @@ puts $variables_fd {
|
||||
close $variables_fd
|
||||
|
||||
# generic modules
|
||||
append boot_modules {
|
||||
core init ld.lib.so
|
||||
} [audio_drv_binary] {
|
||||
build_boot_image {
|
||||
fb_upscale
|
||||
input_remap
|
||||
libc.lib.so
|
||||
libm.lib.so
|
||||
report_rom
|
||||
quake.tar
|
||||
retro_frontend
|
||||
stdcxx.lib.so
|
||||
timer
|
||||
tyrquake_libretro.lib.so
|
||||
quake.tar
|
||||
variables
|
||||
}
|
||||
|
||||
# platform-specific modules
|
||||
lappend_if [have_spec linux] boot_modules fb_sdl
|
||||
lappend_if [have_spec vesa] boot_modules fb_drv
|
||||
lappend_if [have_spec ps2] boot_modules ps2_drv
|
||||
lappend_if [have_spec pl11x] boot_modules fb_drv
|
||||
|
||||
append_platform_drv_boot_modules
|
||||
|
||||
build_boot_image $boot_modules
|
||||
|
||||
append qemu_args " -soundhw es1370 "
|
||||
|
||||
run_genode_until forever
|
||||
|
||||
@@ -277,6 +277,12 @@ bool environment_callback(unsigned cmd, void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
case RETRO_ENVIRONMENT_GET_USERNAME:
|
||||
{
|
||||
*(char const **)data = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
case RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER:
|
||||
{
|
||||
retro_framebuffer *fb = (retro_framebuffer*)data;
|
||||
|
||||
@@ -58,6 +58,7 @@ Retro_frontend::Frontend::Frontend(Libc::Env &env) : env(env)
|
||||
shared_object.lookup<Retro_set_audio_sample_batch>
|
||||
("retro_set_audio_sample_batch")(audio_sample_batch_callback);
|
||||
} catch (...) {
|
||||
Genode::error("failed to initialize audio");
|
||||
|
||||
shared_object.lookup<Retro_set_audio_sample>
|
||||
("retro_set_audio_sample")(audio_sample_noop);
|
||||
@@ -154,7 +155,8 @@ void Libc::Component::construct(Libc::Env &env)
|
||||
|
||||
init_keyboard_map();
|
||||
|
||||
try { static Frontend inst(env); }
|
||||
/* run the frontend and core initialization in application context */
|
||||
try { Libc::with_libc([&env] () { static Frontend inst(env); }); }
|
||||
|
||||
catch (Shared_object::Invalid_rom_module) {
|
||||
error("failed to load core"); }
|
||||
|
||||
@@ -287,7 +287,7 @@ struct Retro_frontend::Frontend
|
||||
(framebuffer->mode.height() == 0))
|
||||
{
|
||||
Genode::error("zero framebuffer mode received, exiting");
|
||||
exit();
|
||||
Libc::with_libc([&] () { exit(); });
|
||||
env.parent().exit(0);
|
||||
}
|
||||
}
|
||||
@@ -302,7 +302,8 @@ struct Retro_frontend::Frontend
|
||||
Retro_run retro_run =
|
||||
shared_object.lookup<Retro_run>("retro_run");
|
||||
|
||||
void run() { retro_run(); }
|
||||
/* switch to application context and advance the core */
|
||||
void run() { Libc::with_libc([&] () { retro_run(); }); }
|
||||
|
||||
Genode::Signal_handler<Frontend> core_runner
|
||||
{ env.ep(), *this, &Frontend::run };
|
||||
@@ -422,13 +423,14 @@ struct Retro_frontend::Frontend
|
||||
timer.sigh(Genode::Signal_context_capability());
|
||||
|
||||
/* stop playpack */
|
||||
stereo_out->stop_stream();
|
||||
if (stereo_out.constructed())
|
||||
stereo_out->stop_stream();
|
||||
|
||||
/* set signal handler for unpausing */
|
||||
controller.input.sigh(resume_handler);
|
||||
|
||||
/* a good time to flush memory to the FS */
|
||||
save_memory();
|
||||
Libc::with_libc([&] () { save_memory(); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user