Merge pull request #2 from vgmoose/master

update for 5.x and latest libtransistor
This commit is contained in:
Maschell 2018-07-22 11:29:50 +02:00 committed by GitHub
commit ae12ae4a2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 42 additions and 54 deletions

View File

@ -16,7 +16,7 @@ all: $(PROGRAM).nro
$(AS) $(AS_FLAGS) $< -filetype=obj -o $@ $(AS) $(AS_FLAGS) $< -filetype=obj -o $@
$(PROGRAM).nro.so: ${OBJ} $(LIBTRANSITOR_NRO_LIB) $(LIBTRANSISTOR_COMMON_LIBS) $(PROGRAM).nro.so: ${OBJ} $(LIBTRANSITOR_NRO_LIB) $(LIBTRANSISTOR_COMMON_LIBS)
$(LD) $(LD_FLAGS) -o $@ ${OBJ} $(LIBTRANSISTOR_NRO_LDFLAGS) $(LD) $(LD_FLAGS) -lSDL2 -o $@ ${OBJ} $(LIBTRANSISTOR_NRO_LDFLAGS)
clean: clean:
rm -rf *.o *.nso *.nro *.so rm -rf *.o *.nso *.nro *.so

View File

@ -13,36 +13,25 @@ Huge thanks to vgmoose, based on his examples!.
#### For Switch #### For Switch
Clone and setup libtransistor, for more detail [see this post](https://reswitchedweekly.github.io/Development-Setup/). Clone and setup libtransistor, for more detail [see this post](https://reswitchedweekly.github.io/Development-Setup/).
``` ```
git clone --recursive -b graphics-experimental-fs https://github.com/reswitched/libtransistor.git git clone --recursive https://github.com/reswitched/libtransistor.git
cd libtransistor cd libtransistor
make make
cd .. cd ..
``` ```
Then export an environment variable pointing to your libtransistor build, and run `make`: Setup sdl-libtransistor and export an environment variable pointing to your libtransistor build:
```
export LIBTRANSISTOR_HOME=/opt/libtransistor
git clone https://github.com/reswitched/sdl-libtransistor.git
cd sdl-libtransistor
make -f switch.mk
cd ..
```
Compile with make:
``` ```
export LIBTRANSISTOR_HOME=./libtransistor
make make
``` ```
### Running ### Running
The below instructions are for 3.0.0, written on 12/30/2017: See [these instructions](https://gbatemp.net/threads/switch-hacking-101-how-to-launch-the-homebrew-menu-on-all-fw.504012/) on how to use Fusee Gelee to run this homebrew on most Switches as of this time of writing (22/07/2018).
Build ace_loader in `./projects/ace_loader` of libtransistor, by running `make`
Copy the built `ace.nro` into Pegaswitch's `nros` directory (overwrite the existing one)
Run [Pegaswitch](https://github.com/reswitched/pegaswitch) on your computer, and set your Switch's DNS server to your computer's.
Once pegaswitch connects, run ace_loader with `runnro nros/ace.nro`. If this is your first time running Pegaswitch, use `evalfile usefulscripts/SetupNew.js` first.
If successful, the Switch should be back at the Wifi menu, and frozen. From here:
```
nc <SWITCHIP> 2991 < hello.nro
```
Where `<SWITCHIP>` is the IP of your switch.
See [here](https://github.com/reswitched/pegaswitch#usage) for more on Pegaswitch, and [here](https://github.com/reswitched/libtransistor) on ace_loader.
[See this post](https://reswitchedweekly.github.io/Development-Setup/) for more troubleshooting

3
draw.c
View File

@ -30,8 +30,7 @@ Graphics* init()
void deinit(struct Graphics* g) void deinit(struct Graphics* g)
{ {
SDL_Delay(1); SDL_VideoQuit();
SDL_DestroyWindow(g->window);
SDL_Quit(); SDL_Quit();
free(g); free(g);

16
hello.c
View File

@ -36,16 +36,16 @@ int main(){
buttons_r = (last_buttons & (~pad_data.btns_h)); buttons_r = (last_buttons & (~pad_data.btns_h));
/*if(pad_data.btns_h & BUTTON_LEFT){ /*if(pad_data.btns_h & PAD_BUTTON_LEFT){
x--; x--;
} }
if(pad_data.btns_h & BUTTON_RIGHT){ if(pad_data.btns_h & PAD_BUTTON_RIGHT){
x++; x++;
} }
if(pad_data.btns_h & BUTTON_DOWN){ if(pad_data.btns_h & PAD_BUTTON_DOWN){
y++; y++;
} }
if(pad_data.btns_h & BUTTON_UP){ if(pad_data.btns_h & PAD_BUTTON_UP){
y--; y--;
}*/ }*/
@ -57,12 +57,12 @@ int main(){
if(game_state == IDLE){ if(game_state == IDLE){
drawStringf(g, x, y, "Press MINUS to start!"); drawStringf(g, x, y, "Press MINUS to start!");
if(pad_data.btns_h & BUTTON_MINUS){ if(pad_data.btns_h & PAD_BUTTON_MINUS){
game_state = IN_GAME; game_state = IN_GAME;
} }
}else if(game_state == IN_GAME){ }else if(game_state == IN_GAME){
frame_counter++; frame_counter++;
if(buttons_r & BUTTON_A){ if(buttons_r & PAD_BUTTON_A){
button_count++; button_count++;
} }
float secLeft = (round_duration - frame_counter) /60.0f; float secLeft = (round_duration - frame_counter) /60.0f;
@ -85,13 +85,13 @@ int main(){
if(isHighscore){ if(isHighscore){
drawStringf(g, x, y+4,"NEW HIGHSCORE!"); drawStringf(g, x, y+4,"NEW HIGHSCORE!");
} }
if(pad_data.btns_h & BUTTON_MINUS){ if(pad_data.btns_h & PAD_BUTTON_MINUS){
game_state = IN_GAME; game_state = IN_GAME;
isHighscore = 0; isHighscore = 0;
} }
} }
if(pad_data.btns_h & BUTTON_PLUS){ if(pad_data.btns_h & PAD_BUTTON_PLUS){
break; break;
} }
update(g); update(g);

BIN
hello.nro

Binary file not shown.

16
input.c
View File

@ -10,14 +10,14 @@ void PADDestroy(){
} }
static void readInputInternal(struct PADData* data,hid_controller_state_entry_t ent ){ static void readInputInternal(struct PADData* data,hid_controller_state_entry_t ent ){
data->btns_h |= ((ent.button_state & JOYPAD_A)? BUTTON_A : 0); data->btns_h |= ((ent.button_state & JOYPAD_A)? PAD_BUTTON_A : 0);
data->btns_h |= ((ent.button_state & JOYPAD_B)? BUTTON_B : 0); data->btns_h |= ((ent.button_state & JOYPAD_B)? PAD_BUTTON_B : 0);
data->btns_h |= ((ent.button_state & JOYPAD_UP)? BUTTON_UP : 0); data->btns_h |= ((ent.button_state & JOYPAD_UP)? PAD_BUTTON_UP : 0);
data->btns_h |= ((ent.button_state & JOYPAD_DOWN)? BUTTON_DOWN : 0); data->btns_h |= ((ent.button_state & JOYPAD_DOWN)? PAD_BUTTON_DOWN : 0);
data->btns_h |= ((ent.button_state & JOYPAD_LEFT)? BUTTON_LEFT : 0); data->btns_h |= ((ent.button_state & JOYPAD_LEFT)? PAD_BUTTON_LEFT : 0);
data->btns_h |= ((ent.button_state & JOYPAD_RIGHT)? BUTTON_RIGHT : 0); data->btns_h |= ((ent.button_state & JOYPAD_RIGHT)? PAD_BUTTON_RIGHT : 0);
data->btns_h |= ((ent.button_state & JOYPAD_START)? BUTTON_PLUS : 0); data->btns_h |= ((ent.button_state & JOYPAD_START)? PAD_BUTTON_PLUS : 0);
data->btns_h |= ((ent.button_state & JOYPAD_SELECT)? BUTTON_MINUS : 0); data->btns_h |= ((ent.button_state & JOYPAD_SELECT)? PAD_BUTTON_MINUS : 0);
} }
void PADRead(struct PADData* data){ void PADRead(struct PADData* data){

16
input.h
View File

@ -1,14 +1,14 @@
// "PAD" controls (unique to us) // "PAD" controls (unique to us)
#define BUTTON_LEFT 0b00000001 #define PAD_BUTTON_LEFT 0b00000001
#define BUTTON_RIGHT 0b00000010 #define PAD_BUTTON_RIGHT 0b00000010
#define BUTTON_UP 0b00000100 #define PAD_BUTTON_UP 0b00000100
#define BUTTON_DOWN 0b00001000 #define PAD_BUTTON_DOWN 0b00001000
#define BUTTON_MINUS 0b00010000 #define PAD_BUTTON_MINUS 0b00010000
#define BUTTON_PLUS 0b00100000 #define PAD_BUTTON_PLUS 0b00100000
#define BUTTON_A 0b01000000 #define PAD_BUTTON_A 0b01000000
#define BUTTON_B 0b10000000 #define PAD_BUTTON_B 0b10000000
// switch controls // switch controls
#define JOYPAD_LEFT 0x1000 #define JOYPAD_LEFT 0x1000