Skip to content

Commit

Permalink
Native programs update.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mysticial committed Aug 18, 2024
1 parent 013cc6a commit 7810986
Show file tree
Hide file tree
Showing 12 changed files with 391 additions and 16 deletions.
3 changes: 3 additions & 0 deletions NativePrograms/Cleanup.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ cd %~dp0\PokemonSwSh
cd %~dp0\PokemonBDSP
@call !Cleanup.cmd

cd %~dp0\PokemonSV
@call !Cleanup.cmd


42 changes: 42 additions & 0 deletions NativePrograms/NintendoSwitch/Libraries/NintendoSwitch_GameEntry.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* Pokemon Automation Push Button Framework
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
*/

#ifndef PokemonAutomation_NintendoSwitch_GameEntry_H
#define PokemonAutomation_NintendoSwitch_GameEntry_H

#include "NintendoSwitch_PushButtons.h"

void close_game(void){
// Use mashing to ensure that the X press succeeds. If it fails, the SR
// will fail and can kill a den for the autohosts.
pbf_mash_button(BUTTON_X, 100); // Close game
pbf_mash2_button(BUTTON_X, BUTTON_A, 50); // Confirm close game
pbf_mash_button(BUTTON_X, 50);
pbf_mash_button(BUTTON_B, 350);
}
void resume_game_no_interact(uint16_t delay, bool tolerate_update_menu){
if (tolerate_update_menu){
pbf_press_button(BUTTON_HOME, 10, delay);
pbf_press_dpad(DPAD_DOWN, 10, 10);
pbf_press_dpad(DPAD_UP, 10, 10);
pbf_press_button(BUTTON_A, 10, delay);
}else{
pbf_press_button(BUTTON_HOME, 10, delay);
}
}
void resume_game_back_out(uint16_t delay, bool tolerate_update_menu, uint16_t mash_B_time){
if (tolerate_update_menu){
pbf_press_button(BUTTON_HOME, 10, delay);
pbf_press_dpad(DPAD_DOWN, 10, 10);
pbf_press_dpad(DPAD_UP, 10, 10);
pbf_press_button(BUTTON_A, 10, delay);
pbf_mash_button(BUTTON_B, mash_B_time);
}else{
pbf_press_button(BUTTON_HOME, 10, delay);
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ void pbf_move_right_joystick(uint8_t x, uint8_t y, uint16_t hold_ticks, uint16_t
// specified amount of time.
void pbf_mash_button(Button button, uint16_t ticks);

// Alternately mash 2 buttons.
void pbf_mash2_button(Button button0, Button button1, uint16_t ticks);



Expand Down
36 changes: 36 additions & 0 deletions NativePrograms/NintendoSwitch/Programs/TurboA_Core.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* Pokemon Sword & Shield Arduino Programs
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
*/

#include "Common/PokemonSwSh/PokemonProgramIDs.h"
#include "NativePrograms/DeviceFramework/DeviceSettings.h"
#include "NativePrograms/NintendoSwitch/Libraries/FrameworkSettings.h"
#include "NativePrograms/NintendoSwitch/Libraries/NintendoSwitch_Device.h"
#include "NativePrograms/NintendoSwitch/Libraries/NintendoSwitch_PushButtons.h"
#include "NativePrograms/NintendoSwitch/Libraries/NintendoSwitch_GameEntry.h"
#include "NativePrograms/PokemonSwSh/Libraries/PokemonSwSh_Settings.h"
//#include "NativePrograms/PokemonSwSh/Libraries/PokemonSwSh_GameEntry_Core.h"
#include "NativePrograms/NintendoSwitch/Programs/TurboA.h"

int main(void){
start_program_callback();
initialize_framework(0);

start_program_flash(CONNECT_CONTROLLER_DELAY);
grip_menu_connect_go_home();
resume_game_no_interact(3 * TICKS_PER_SECOND, TOLERATE_SYSTEM_UPDATE_MENU_FAST);

// the resume game sequence opens the camera in Scarlet/Violet
// mashing B closes the camera
pbf_mash_button(BUTTON_B, 100);
while (true){
pbf_press_button(BUTTON_A, 5, 5);
}

pbf_press_button(BUTTON_HOME, 10, PokemonSwSh_GAME_TO_HOME_DELAY_SAFE);
end_program_callback();
end_program_loop();
};

10 changes: 6 additions & 4 deletions NativePrograms/NintendoSwitch/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,32 @@ SRC += $(PATH_PUBLIC)/NativePrograms/NintendoSwitch/FrameworkSettings.c
ifneq ("$(wildcard $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/NintendoSwitch_PushButtons.c)","")
CC_FLAGS += -I$(PATH_INTERNAL)
SRC += $(PATH_PUBLIC)/Common/CRC32.c
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/uart.c
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/HardwareUSB.c
ifeq ($(TARGET), PABotBase)
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/Uart-PABotBase.c
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/CommandQueue.c
else
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/Uart.c
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/CommandQueueNull.c
endif
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/HardwareSerial.c
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/Controller.c
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/NintendoSwitch_PushButtons.c
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/NintendoSwitch_ScalarButtons.c
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/NintendoSwitch_Superscalar.c
else
LD_FLAGS += obj/obj-$(MCU)/CRC32.o
LD_FLAGS += obj/obj-$(MCU)/uart.o
LD_FLAGS += obj/obj-$(MCU)/HardwareUSB.o
ifeq ($(TARGET), PABotBase)
LD_FLAGS += obj/obj-$(MCU)/Uart-PABotBase.o
LD_FLAGS += obj/obj-$(MCU)/CommandQueue.o
else
LD_FLAGS += obj/obj-$(MCU)/Uart.o
LD_FLAGS += obj/obj-$(MCU)/CommandQueueNull.o
endif
LD_FLAGS += obj/obj-$(MCU)/HardwareSerial.o
LD_FLAGS += obj/obj-$(MCU)/Controller.o
LD_FLAGS += obj/obj-$(MCU)/NintendoSwitch_PushButtons.o
LD_FLAGS += obj/obj-$(MCU)/NintendoSwitch_ScalarButtons.o
LD_FLAGS += obj/obj-$(MCU)/NintendoSwitch_Superscalar.o
endif

# Program
Expand Down
133 changes: 133 additions & 0 deletions NativePrograms/PokemonBDSP/Libraries/PokemonBDSP_GameEntry_Core.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/* Game Entry Routines
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
*/

#ifndef PokemonAutomation_PokemonBDSP_GameEntry_Core_H
#define PokemonAutomation_PokemonBDSP_GameEntry_Core_H

#include "NativePrograms/NintendoSwitch/Libraries/FrameworkSettings.h"
#include "NativePrograms/NintendoSwitch/Libraries/NintendoSwitch_PushButtons.h"
#include "NativePrograms/NintendoSwitch/Libraries/NintendoSwitch_GameEntry.h"
#include "NativePrograms/PokemonBDSP/Libraries/PokemonBDSP_Settings.h"

void PokemonBDSP_resume_game_no_interact(bool tolerate_update_menu){
if (tolerate_update_menu){
pbf_press_button(BUTTON_HOME, 10, PokemonBDSP_HOME_TO_GAME_DELAY);
pbf_move_right_joystick(128, 255, 10, 10);
pbf_move_right_joystick(128, 0, 10, 10);
pbf_press_button(BUTTON_A, 10, PokemonBDSP_HOME_TO_GAME_DELAY);
}else{
pbf_press_button(BUTTON_HOME, 10, PokemonBDSP_HOME_TO_GAME_DELAY);
}
}


void PokemonBDSP_openedgame_to_gamemenu(uint16_t timeout){
pbf_wait(timeout);
}
void PokemonBDSP_gamemenu_to_ingame(
uint16_t mash_duration, uint16_t enter_game_timeout
){
pbf_mash_button(BUTTON_A, mash_duration);
pbf_wait(enter_game_timeout);
}
void PokemonBDSP_openedgame_to_ingame(
uint16_t load_game_timeout,
uint16_t mash_duration, uint16_t enter_game_timeout,
uint16_t post_wait_time
){
PokemonBDSP_openedgame_to_gamemenu(load_game_timeout);
PokemonBDSP_gamemenu_to_ingame(mash_duration, enter_game_timeout);
pbf_wait(post_wait_time);
}

void PokemonBDSP_move_to_user(uint8_t user_slot){
if (user_slot != 0){
// Move to correct user.
for (uint8_t c = 0; c < 8; c++){
pbf_press_dpad(DPAD_LEFT, 7, 7);
}
// pbf_wait(50);
for (uint8_t c = 1; c < user_slot; c++){
pbf_press_dpad(DPAD_RIGHT, 7, 7);
}
}
}

void PokemonBDSP_start_game_from_home(
bool tolerate_update_menu,
uint8_t game_slot,
uint8_t user_slot,
uint16_t start_game_mash
){
if (game_slot != 0){
pbf_press_button(BUTTON_HOME, 10, SETTINGS_TO_HOME_DELAY - 10);
for (uint8_t c = 1; c < game_slot; c++){
pbf_press_dpad(DPAD_RIGHT, 5, 5);
}
}

if (tolerate_update_menu){
// If the update menu isn't there, these will get swallowed by the opening
// animation for the select user menu.
pbf_press_button(BUTTON_A, 5, 175); // Choose game
pbf_press_dpad(DPAD_UP, 5, 0); // Skip the update window.
PokemonBDSP_move_to_user(user_slot);
}

// cout << "START_GAME_REQUIRES_INTERNET = " << START_GAME_REQUIRES_INTERNET << endl;
if (!START_GAME_REQUIRES_INTERNET && user_slot == 0){
// Mash your way into the game.
pbf_mash_button(BUTTON_A, start_game_mash);
}else{
pbf_press_button(BUTTON_A, 5, 175); // Enter select user menu.
PokemonBDSP_move_to_user(user_slot);
pbf_press_button(BUTTON_A, 5, 5); // Enter game

// Switch to mashing ZR instead of A to get into the game.
// Mash your way into the game.
uint16_t duration = start_game_mash;
if (START_GAME_REQUIRES_INTERNET){
// Need to wait a bit longer for the internet check.
duration += START_GAME_INTERNET_CHECK_DELAY;
}
pbf_mash_button(BUTTON_ZR, duration);
}
}



void PokemonBDSP_reset_game_from_home(
bool tolerate_update_menu,
uint16_t post_wait_time
){
if (START_GAME_REQUIRES_INTERNET || tolerate_update_menu){
close_game();
PokemonBDSP_start_game_from_home(
tolerate_update_menu,
0, 0,
PokemonBDSP_START_GAME_MASH
);
}else{
pbf_press_button(BUTTON_X, 50, 0);
pbf_mash_button(BUTTON_A, PokemonBDSP_START_GAME_MASH);
}
PokemonBDSP_openedgame_to_ingame(
PokemonBDSP_START_GAME_WAIT,
PokemonBDSP_ENTER_GAME_MASH,
PokemonBDSP_ENTER_GAME_WAIT,
post_wait_time
);
}

void PokemonBDSP_save_game(void){
pbf_press_button(BUTTON_X, 10, PokemonBDSP_OVERWORLD_TO_MENU_DELAY);
pbf_press_button(BUTTON_R, 10, 2 * TICKS_PER_SECOND);
pbf_press_button(BUTTON_A, 10, 5 * TICKS_PER_SECOND);
}


#endif

76 changes: 76 additions & 0 deletions NativePrograms/PokemonBDSP/Programs/MassRelease_Core.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* Pokemon BDSP: Mass Release
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
*/

#include "NativePrograms/DeviceFramework/DeviceSettings.h"
#include "NativePrograms/NintendoSwitch/Libraries/FrameworkSettings.h"
#include "NativePrograms/NintendoSwitch/Libraries/NintendoSwitch_Device.h"
#include "NativePrograms/NintendoSwitch/Libraries/NintendoSwitch_PushButtons.h"
#include "NativePrograms/PokemonBDSP/Libraries/PokemonBDSP_GameEntry_Core.h"
#include "NativePrograms/PokemonBDSP/Programs/MassRelease.h"



void release(void){
pbf_press_button(BUTTON_ZL, 20, 50);
pbf_move_right_joystick(128, 0, 20, 10);
pbf_move_right_joystick(128, 0, 20, 10);
pbf_press_button(BUTTON_ZL, 20, 105);
pbf_move_right_joystick(128, 255, 20, 10);
pbf_mash_button(BUTTON_ZL, 120);
pbf_wait(30);
}
void release_box(uint16_t box_scroll_delay){
for (uint8_t row = 0; row < 5; row++){
if (row != 0){
pbf_press_dpad(DPAD_DOWN, 20, box_scroll_delay);
pbf_press_dpad(DPAD_RIGHT, 20, box_scroll_delay);
pbf_press_dpad(DPAD_RIGHT, 20, box_scroll_delay);
}
for (uint8_t col = 0; col < 6; col++){
if (col != 0){
pbf_press_dpad(DPAD_RIGHT, 20, box_scroll_delay);
}
release();
}
}
}
void release_boxes(
uint8_t boxes,
uint16_t box_scroll_delay,
uint16_t box_change_delay
){
if (boxes == 0){
return;
}
release_box(box_scroll_delay);
for (uint8_t box = 1; box < boxes; box++){
pbf_press_dpad(DPAD_DOWN, 20, box_scroll_delay);
pbf_press_dpad(DPAD_DOWN, 20, box_scroll_delay);
pbf_press_dpad(DPAD_DOWN, 20, box_scroll_delay);
pbf_press_dpad(DPAD_RIGHT, 20, box_scroll_delay);
pbf_press_dpad(DPAD_RIGHT, 20, box_scroll_delay);
pbf_press_button(BUTTON_R, 20, box_change_delay);
release_box(box_scroll_delay);
}
}



int main(void){
start_program_callback();
initialize_framework(0);

start_program_flash(CONNECT_CONTROLLER_DELAY);
grip_menu_connect_go_home();
PokemonBDSP_resume_game_no_interact(DODGE_SYSTEM_UPDATE_WINDOW);

release_boxes(BOXES_TO_RELEASE, PokemonBDSP_BOX_SCROLL_DELAY, PokemonBDSP_BOX_CHANGE_DELAY);
pbf_press_button(BUTTON_HOME, 20, PokemonBDSP_GAME_TO_HOME_DELAY);

end_program_callback();
end_program_loop();
};

10 changes: 6 additions & 4 deletions NativePrograms/PokemonBDSP/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,32 @@ SRC += $(PATH_PUBLIC)/NativePrograms/NintendoSwitch/FrameworkSettings.c
ifneq ("$(wildcard $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/NintendoSwitch_PushButtons.c)","")
CC_FLAGS += -I$(PATH_INTERNAL)
SRC += $(PATH_PUBLIC)/Common/CRC32.c
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/uart.c
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/HardwareUSB.c
ifeq ($(TARGET), PABotBase)
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/Uart-PABotBase.c
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/CommandQueue.c
else
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/Uart.c
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/CommandQueueNull.c
endif
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/HardwareSerial.c
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/Controller.c
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/NintendoSwitch_PushButtons.c
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/NintendoSwitch_ScalarButtons.c
SRC += $(PATH_INTERNAL)/NativePrograms/NintendoSwitch/Framework/NintendoSwitch_Superscalar.c
else
LD_FLAGS += obj/obj-$(MCU)/CRC32.o
LD_FLAGS += obj/obj-$(MCU)/uart.o
LD_FLAGS += obj/obj-$(MCU)/HardwareUSB.o
ifeq ($(TARGET), PABotBase)
LD_FLAGS += obj/obj-$(MCU)/Uart-PABotBase.o
LD_FLAGS += obj/obj-$(MCU)/CommandQueue.o
else
LD_FLAGS += obj/obj-$(MCU)/Uart.o
LD_FLAGS += obj/obj-$(MCU)/CommandQueueNull.o
endif
LD_FLAGS += obj/obj-$(MCU)/HardwareSerial.o
LD_FLAGS += obj/obj-$(MCU)/Controller.o
LD_FLAGS += obj/obj-$(MCU)/NintendoSwitch_PushButtons.o
LD_FLAGS += obj/obj-$(MCU)/NintendoSwitch_ScalarButtons.o
LD_FLAGS += obj/obj-$(MCU)/NintendoSwitch_Superscalar.o
endif

# Program
Expand Down
Loading

0 comments on commit 7810986

Please sign in to comment.