Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 97891bd

Browse files
committed
Readme update and some file rearrangements
1 parent 6ececec commit 97891bd

File tree

4 files changed

+57
-34
lines changed

4 files changed

+57
-34
lines changed

README.md

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Dov Grobgeld
44
5-
Last edited: 2024-09-10 Tue
5+
Last edited: 2024-09-11 Wed
66

77
# License
88

@@ -133,46 +133,46 @@ Even though the R36S is using a standard SDL, there are a few specifics that you
133133
2. All the input controls are mapped as joystick buttons and axes. You can read the state of the joystick by the standard SDL2 joystick functions. In order to use the joystick you need to open it as follows in C:
134134

135135
```c
136-
// Initialize SDL before everything else, so other SDL libraries can be safely initialized
137-
if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_JOYSTICK ) < 0 ) {
138-
printf("Error : failed to initialize SDL (%s).\n", SDL_GetError());
136+
// Initialize SDL before everything else, so other SDL libraries can be safely initialized
137+
if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_JOYSTICK ) < 0 ) {
138+
printf("Error : failed to initialize SDL (%s).\n", SDL_GetError());
139+
return EXIT_FAILURE;
140+
}
141+
142+
// Check for joysticks
143+
if (SDL_NumJoysticks() < 1) {
144+
printf( "Warning: No joysticks connected!\n" );
145+
return EXIT_FAILURE;
146+
}
147+
else {
148+
// Load joystick
149+
gGameController = SDL_JoystickOpen( 0 );
150+
if (gGameController == NULL) {
151+
printf( "Warning: Unable to open game controller! SDL Error: %s\n", SDL_GetError() );
139152
return EXIT_FAILURE;
140153
}
141-
142-
// Check for joysticks
143-
if (SDL_NumJoysticks() < 1) {
144-
printf( "Warning: No joysticks connected!\n" );
145-
return EXIT_FAILURE;
146-
}
147-
else {
148-
// Load joystick
149-
gGameController = SDL_JoystickOpen( 0 );
150-
if (gGameController == NULL) {
151-
printf( "Warning: Unable to open game controller! SDL Error: %s\n", SDL_GetError() );
152-
return EXIT_FAILURE;
153-
}
154-
}
154+
}
155155

156156
```
157157

158158
Once this is done, you can read the state of the joystick by the standard SDL2 joystick functions:
159159

160160
```c
161-
while (SDL_PollEvent(&Event)) {
162-
switch (Event.type) {
163-
case SDL_JOYAXISMOTION:
164-
printf("axis = %d value = %d\n",
165-
Event.jaxis.axis, Event.jaxis.value);
166-
// Handle Joystick Motion
167-
break;
168-
case SDL_JOYBUTTONDOWN:
169-
printf("JoyButtonDown %d\n", Event.jbutton.button);
170-
break;
171-
case SDL_JOYBUTTONUP:
172-
printf("JoyButtonUp %d\n", Event.jbutton.button);
173-
break;
174-
}
161+
while (SDL_PollEvent(&Event)) {
162+
switch (Event.type) {
163+
case SDL_JOYAXISMOTION:
164+
printf("axis = %d value = %d\n",
165+
Event.jaxis.axis, Event.jaxis.value);
166+
// Handle Joystick Motion
167+
break;
168+
case SDL_JOYBUTTONDOWN:
169+
printf("JoyButtonDown %d\n", Event.jbutton.button);
170+
break;
171+
case SDL_JOYBUTTONUP:
172+
printf("JoyButtonUp %d\n", Event.jbutton.button);
173+
break;
175174
}
175+
}
176176
```
177177

178178
# Mapping of the R36S controls
@@ -224,7 +224,7 @@ It is possible to setup EmulationStation to support our native games. This is do
224224
* `/etc/emulationstation/es_systems.cfg` - This file contains a list of our "emulators". We will add a new system "native" to this file.
225225
* `/etc/emulationstation/themes/es-theme-nes-box/` - Contains themes for the various emulators. We want to add a theme for our "native" system. If you are using another theme, you will want to modify the destination.
226226

227-
To simplify this, enter the `scripts` sub directery of this repository and run the script `install-native-emulator.sh` as follows:
227+
To simplify this, enter the `scripts` sub directery of this repository and run the script `install-native-emulator.py` as follows:
228228

229229
```
230230
cd ~/git/r36-programming/scripts
@@ -245,6 +245,12 @@ And if you enter it, you will see the c++ sdl program listed as a "game".
245245

246246
The "native" theme images were created by me and are free to use and copy.
247247

248+
## Installing files in native roms directory
249+
250+
To install additional programs in native, you need to copy them to your roms directory, either `/roms/native` or `/roms2/native`. In addition, you must give it the extension `.exec`. On Linux, the extension of a binary doesn't have any meaning, as the properties are determined inside the file through the first few bytes of the file, also known as a "magic number". However, EmulationStation needs an adentifier for its "Roms", and I chose the `.exec` extension.
251+
252+
EmulationStation will pick up your binaries next time you restart it. Either by rebooting the system, or by Option→Quit→Restart Emulation System.
253+
248254
# Final thoughts
249255

250256
First of all, this repository, and this article is work in progress. I hope to expand it as time allows.
File renamed without changes.

roms/native/run.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
cd /roms2/native
4+
5+
SELECTED="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
6+
7+
FILES=`ls -I "*.sh" -I "*.xml" -I "*.old"`
8+
for f in $FILES
9+
do
10+
FULLPATH="$(cd "$(dirname "$f")" && pwd)/$(basename "$f")"
11+
if [ ! "$SELECTED" = "$FULLPATH" ]; then
12+
ALL="$ALL $FULLPATH"
13+
fi
14+
done
15+
16+
$SELECTED
17+

scripts/install-native-emulator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def create_roms_directory(roms_dir):
7070
roms_dir = Path(roms_dir)
7171
if not roms_dir.exists():
7272
roms_dir.mkdir(0o755)
73-
os.system(f'rsync -av ../binaries/*.xec {roms_dir}')
73+
os.system(f'rsync -av ../roms/native {roms_dir}')
7474

7575

7676
if __name__ == '__main__':

0 commit comments

Comments
 (0)