GithubHelp home page GithubHelp logo

(SDL) Required files. about sameboy HOT 9 CLOSED

liji32 avatar liji32 commented on May 13, 2024
(SDL) Required files.

from sameboy.

Comments (9)

meithecatte avatar meithecatte commented on May 13, 2024 1

@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.

LIJI32 avatar LIJI32 commented on May 13, 2024

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.

orbea avatar orbea commented on May 13, 2024

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.

orbea avatar orbea commented on May 13, 2024

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.

LIJI32 avatar LIJI32 commented on May 13, 2024

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.

orbea avatar orbea commented on May 13, 2024

/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.

orbea avatar orbea commented on May 13, 2024

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.

orbea avatar orbea commented on May 13, 2024

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.

orbea avatar orbea commented on May 13, 2024

The core of this issue is resolved, the other issues should be brought up in new issues. Thanks!

from sameboy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.