Comments (9)
@orbea you can leave the CWD as the user's directory, the resources are loaded by reading the link at /proc/self/exe. Or, you can use the DATA_DIR
build variable that's available on the master branch.
from sameboy.
To avoid platform-specific paths (E.g. Windows does not have /usr/share
), all resources SameBoy uses are relative to the binary path and should follow the same structure as ./build/bin/SDL
. I agree this can get messy if you actually want to install SameBoy into /usr/local/bin
as you'll have to include the resources in the bin
folder this way, so I might have to find a better solution for Linux/BSD.
from sameboy.
Yea, that would not work for Slackware unfortunately. I guess being able to overwrite the paths during compile could work and then fall back to the current defaults if the user does not set it.
from sameboy.
I've come up with a temporary workaround although it is not ideal and I would love to be able to not use it.
In short build/bin/SDL
is installed to /usr/share/games/sameboy
and this wrapper script is installed to /usr/games/sameboy
.
#!/bin/sh
set -euf
CWD="$(pwd)"
cd /usr/share/games/sameboy
if [ "${1:-}" ]; then
case "$1" in
/* ) ./sameboy "$1" ;;
* ) ./sameboy "$CWD/$1" ;;
esac
else
./sameboy
fi
from sameboy.
I'm confused, why can't you just copy build/bin/SDL
directly into /usr/games
? Also, those cd
hacks are not required, sameboy
does not use CWD when looking for resources.
(Nonetheless, a better Linux solution is still required)
from sameboy.
/usr/games
is only for game binaries while build/bin/SDL
contains a lot of other things that do not belong there.
usr/share/
usr/share/games/
usr/share/games/sameboy/
usr/share/games/sameboy/LICENSE
usr/share/games/sameboy/Shaders/
usr/share/games/sameboy/Shaders/AAOmniScaleLegacy.fsh
usr/share/games/sameboy/Shaders/AAScale2x.fsh
usr/share/games/sameboy/Shaders/AAScale4x.fsh
usr/share/games/sameboy/Shaders/Bilinear.fsh
usr/share/games/sameboy/Shaders/HQ2x.fsh
usr/share/games/sameboy/Shaders/LCD.fsh
usr/share/games/sameboy/Shaders/MasterShader.fsh
usr/share/games/sameboy/Shaders/NearestNeighbor.fsh
usr/share/games/sameboy/Shaders/OmniScale.fsh
usr/share/games/sameboy/Shaders/OmniScaleLegacy.fsh
usr/share/games/sameboy/Shaders/Scale2x.fsh
usr/share/games/sameboy/Shaders/Scale4x.fsh
usr/share/games/sameboy/Shaders/SmoothBilinear.fsh
usr/share/games/sameboy/agb_boot.bin
usr/share/games/sameboy/background.bmp
usr/share/games/sameboy/cgb_boot.bin
usr/share/games/sameboy/dmg_boot.bin
usr/share/games/sameboy/registers.sym
usr/share/games/sameboy/sameboy
The idea behind CWD
is to support relative paths. If the script is launched with any arguments it will append $(pwd)
to any relative paths, but if its an absolute path it does not need that. This variable needs to be set before it changes to /usr/share/games/sameboy
.
from sameboy.
The launcher script should be preferably removed altogether and was made only as a temporary measure.
That said as a test I tried to build sameboy with make DATA_DIR=/tmp/SDL
and the moved build/bin/SDL
to /tmp/SDL
and then /tmp/SDL/sameboy
to /tmp/sameboy
.
Sameboy will proceed to crash as if the DATA_DIR was missing.
Thread 1 "sameboy" received signal SIGSEGV, Segmentation fault.
0x0000000000425f48 in run_gui (is_running=false) at SDL/gui.c:750
750 SDL_SetPaletteColors(background->format->palette, gui_palette, 0, 4);
(gdb) bt
#0 0x0000000000425f48 in run_gui (is_running=false) at SDL/gui.c:750
#1 0x00000000004282bb in main (argc=1, argv=0x7fffffffe268) at SDL/main.c:611
(gdb) bt full
#0 0x0000000000425f48 in run_gui (is_running=false) at SDL/gui.c:750
background = 0x0
converted_background = 0x0
axis_active = {false, false}
pixels = <error reading variable pixels (value requires 92160 bytes, which is more than max-value-size)>
event = {type = 0, common = {type = 0, timestamp = 0}, display = {
type = 0, timestamp = 0, display = 0, event = 0 '\000',
padding1 = 0 '\000', padding2 = 0 '\000', padding3 = 0 '\000',
data1 = 0}, window = {type = 0, timestamp = 0, windowID = 0,
event = 0 '\000', padding1 = 0 '\000', padding2 = 0 '\000',
padding3 = 0 '\000', data1 = 0, data2 = 0}, key = {type = 0,
timestamp = 0, windowID = 0, state = 0 '\000', repeat = 0 '\000',
padding2 = 0 '\000', padding3 = 0 '\000', keysym = {
scancode = SDL_SCANCODE_UNKNOWN, sym = 0, mod = 0, unused = 0}},
edit = {type = 0, timestamp = 0, windowID = 0,
text = '\000' <repeats 31 times>, start = 0, length = 0}, text = {
type = 0, timestamp = 0, windowID = 0,
text = '\000' <repeats 31 times>}, motion = {type = 0,
timestamp = 0, windowID = 0, which = 0, state = 0, x = 0, y = 0,
xrel = 0, yrel = 0}, button = {type = 0, timestamp = 0,
windowID = 0, which = 0, button = 0 '\000', state = 0 '\000',
clicks = 0 '\000', padding1 = 0 '\000', x = 0, y = 0}, wheel = {
type = 0, timestamp = 0, windowID = 0, which = 0, x = 0, y = 0,
direction = 0}, jaxis = {type = 0, timestamp = 0, which = 0,
axis = 0 '\000', padding1 = 0 '\000', padding2 = 0 '\000',
padding3 = 0 '\000', value = 0, padding4 = 0}, jball = {type = 0,
timestamp = 0, which = 0, ball = 0 '\000', padding1 = 0 '\000',
padding2 = 0 '\000', padding3 = 0 '\000', xrel = 0, yrel = 0},
jhat = {type = 0, timestamp = 0, which = 0, hat = 0 '\000',
value = 0 '\000', padding1 = 0 '\000', padding2 = 0 '\000'},
jbutton = {type = 0, timestamp = 0, which = 0, button = 0 '\000',
state = 0 '\000', padding1 = 0 '\000', padding2 = 0 '\000'},
jdevice = {type = 0, timestamp = 0, which = 0}, caxis = {type = 0,
timestamp = 0, which = 0, axis = 0 '\000', padding1 = 0 '\000',
padding2 = 0 '\000', padding3 = 0 '\000', value = 0, padding4 = 0},
cbutton = {type = 0, timestamp = 0, which = 0, button = 0 '\000',
state = 0 '\000', padding1 = 0 '\000', padding2 = 0 '\000'},
cdevice = {type = 0, timestamp = 0, which = 0}, adevice = {type = 0,
timestamp = 0, which = 0, iscapture = 0 '\000', padding1 = 0 '\000',
padding2 = 0 '\000', padding3 = 0 '\000'}, sensor = {type = 0,
timestamp = 0, which = 0, data = {0, 0, 0, 0, 0, 0}}, quit = {
type = 0, timestamp = 0}, user = {type = 0, timestamp = 0,
windowID = 0, code = 0, data1 = 0x0, data2 = 0x0}, syswm = {
type = 0, timestamp = 0, msg = 0x0}, tfinger = {type = 0,
timestamp = 0, touchId = 0, fingerId = 0, x = 0, y = 0, dx = 0,
dy = 0, pressure = 0}, mgesture = {type = 0, timestamp = 0,
touchId = 0, dTheta = 0, dDist = 0, x = 0, y = 0, numFingers = 0,
padding = 0}, dgesture = {type = 0, timestamp = 0, touchId = 0,
gestureId = 0, numFingers = 0, error = 0, x = 0, y = 0}, drop = {
type = 0, timestamp = 0, file = 0x0, windowID = 0},
padding = '\000' <repeats 55 times>}
should_render = false
#1 0x00000000004282bb in main (argc=1, argv=0x7fffffffe268) at SDL/main.c:611
fullscreen = false
gl_context = 0x535d00
major = 4
minor = 5
prefs_dir = 0x64e190 "Sony PLAYSTATION(R)3 Controller"
prefs_file = 0x520420
I tested this with commit 969fb5a.
from sameboy.
Actually the problem is the lack of a trailing /
. Sameboy will not crash when built with DATA_DIR=/tmp/SDL/
while it will crash with DATA_DIR=/tmp/SDL
.
I would also suggest adding some logic to make sure the data directory actually exists and the correct files are there to avoid crashes altogether.
from sameboy.
The core of this issue is resolved, the other issues should be brought up in new issues. Thanks!
from sameboy.
Related Issues (20)
- Sameduck Libretro Ant Soldiers issue
- Windows/Linux Version: SO MANY FEATURES MISSING
- SameBoy iOS Installation? HOT 5
- [GBS] Aladdin (Game Boy Color, 2000) - no audio
- Option to change Super Game Boy palettes HOT 1
- Hang when starting a ROM in a non-writable dir HOT 3
- Put automation results in a separate repo? HOT 3
- Library access to raw APU channel volumes HOT 4
- iOS App Feature Requests HOT 2
- IOS Rom Library HOT 3
- Custom borders feature request (libretro)
- Cannot undo load state on the auto-loaded state (RetroArch/Libretro) HOT 2
- Better SGB+GBC support (RetroArch/libretro) HOT 4
- PCM playback buzz audible in SameBoy but not on GBA SP
- android question HOT 1
- Documentation about command line arguments HOT 1
- Controller not detected if connected while SameBoy is running. HOT 2
- Add VGM logging support
- Pocket Monsters - Pikachu has graphical issues when played on CGB mode HOT 4
- VRAM Viewer tabs not present in MacOS Sonoma
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sameboy.