diff --git a/Makefile b/Makefile index 7dc3253..4115f58 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ all: $(PROGRAM).nro $(AS) $(AS_FLAGS) $< -filetype=obj -o $@ $(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: - rm -rf *.o *.nso *.nro *.so \ No newline at end of file + rm -rf *.o *.nso *.nro *.so diff --git a/draw.c b/draw.c index c068295..a084239 100644 --- a/draw.c +++ b/draw.c @@ -30,8 +30,7 @@ Graphics* init() void deinit(struct Graphics* g) { - SDL_Delay(1); - SDL_DestroyWindow(g->window); + SDL_VideoQuit(); SDL_Quit(); free(g); diff --git a/hello.c b/hello.c index e869222..ba8110d 100644 --- a/hello.c +++ b/hello.c @@ -36,16 +36,16 @@ int main(){ buttons_r = (last_buttons & (~pad_data.btns_h)); - /*if(pad_data.btns_h & BUTTON_LEFT){ + /*if(pad_data.btns_h & PAD_BUTTON_LEFT){ x--; } - if(pad_data.btns_h & BUTTON_RIGHT){ + if(pad_data.btns_h & PAD_BUTTON_RIGHT){ x++; } - if(pad_data.btns_h & BUTTON_DOWN){ + if(pad_data.btns_h & PAD_BUTTON_DOWN){ y++; } - if(pad_data.btns_h & BUTTON_UP){ + if(pad_data.btns_h & PAD_BUTTON_UP){ y--; }*/ @@ -57,12 +57,12 @@ int main(){ if(game_state == IDLE){ 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; } }else if(game_state == IN_GAME){ frame_counter++; - if(buttons_r & BUTTON_A){ + if(buttons_r & PAD_BUTTON_A){ button_count++; } float secLeft = (round_duration - frame_counter) /60.0f; @@ -85,13 +85,13 @@ int main(){ if(isHighscore){ 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; isHighscore = 0; } } - if(pad_data.btns_h & BUTTON_PLUS){ + if(pad_data.btns_h & PAD_BUTTON_PLUS){ break; } update(g); diff --git a/hello.nro b/hello.nro index 939fc67..69314f8 100644 Binary files a/hello.nro and b/hello.nro differ diff --git a/input.c b/input.c index 96ea246..86b9273 100644 --- a/input.c +++ b/input.c @@ -10,14 +10,14 @@ void PADDestroy(){ } 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_B)? BUTTON_B : 0); - data->btns_h |= ((ent.button_state & JOYPAD_UP)? BUTTON_UP : 0); - data->btns_h |= ((ent.button_state & JOYPAD_DOWN)? BUTTON_DOWN : 0); - data->btns_h |= ((ent.button_state & JOYPAD_LEFT)? BUTTON_LEFT : 0); - data->btns_h |= ((ent.button_state & JOYPAD_RIGHT)? BUTTON_RIGHT : 0); - data->btns_h |= ((ent.button_state & JOYPAD_START)? BUTTON_PLUS : 0); - data->btns_h |= ((ent.button_state & JOYPAD_SELECT)? BUTTON_MINUS : 0); + data->btns_h |= ((ent.button_state & JOYPAD_A)? PAD_BUTTON_A : 0); + data->btns_h |= ((ent.button_state & JOYPAD_B)? PAD_BUTTON_B : 0); + data->btns_h |= ((ent.button_state & JOYPAD_UP)? PAD_BUTTON_UP : 0); + data->btns_h |= ((ent.button_state & JOYPAD_DOWN)? PAD_BUTTON_DOWN : 0); + data->btns_h |= ((ent.button_state & JOYPAD_LEFT)? PAD_BUTTON_LEFT : 0); + data->btns_h |= ((ent.button_state & JOYPAD_RIGHT)? PAD_BUTTON_RIGHT : 0); + data->btns_h |= ((ent.button_state & JOYPAD_START)? PAD_BUTTON_PLUS : 0); + data->btns_h |= ((ent.button_state & JOYPAD_SELECT)? PAD_BUTTON_MINUS : 0); } void PADRead(struct PADData* data){ diff --git a/input.h b/input.h index 69631ce..18d4588 100644 --- a/input.h +++ b/input.h @@ -1,14 +1,14 @@ // "PAD" controls (unique to us) -#define BUTTON_LEFT 0b00000001 -#define BUTTON_RIGHT 0b00000010 -#define BUTTON_UP 0b00000100 -#define BUTTON_DOWN 0b00001000 +#define PAD_BUTTON_LEFT 0b00000001 +#define PAD_BUTTON_RIGHT 0b00000010 +#define PAD_BUTTON_UP 0b00000100 +#define PAD_BUTTON_DOWN 0b00001000 -#define BUTTON_MINUS 0b00010000 -#define BUTTON_PLUS 0b00100000 +#define PAD_BUTTON_MINUS 0b00010000 +#define PAD_BUTTON_PLUS 0b00100000 -#define BUTTON_A 0b01000000 -#define BUTTON_B 0b10000000 +#define PAD_BUTTON_A 0b01000000 +#define PAD_BUTTON_B 0b10000000 // switch controls #define JOYPAD_LEFT 0x1000