def install_nsp(nsp_file, usb_drive):
"""Installs an NSP game to a USB drive.
Args:
nsp_file: The path to the NSP file.
usb_drive: The path to the USB drive.
"""
# Create a temporary directory to store the extracted NSP files.
temp_dir = os.path.join(usb_drive, ".nsp_temp")
os.makedirs(temp_dir, exist_ok=True)
# Extract the NSP files to the temporary directory.
nx.archive.extract_nsp(nsp_file, temp_dir)
# Move the NSP files to the appropriate location on the USB drive.
nx.file.move(temp_dir, usb_drive)
# Delete the temporary directory.
os.rmdir(temp_dir)
def run_nsp(nsp_file, usb_drive):
"""Runs an NSP game from a USB drive.
Args:
nsp_file: The path to the NSP file.
usb_drive: The path to the USB drive.
"""
# Mount the USB drive.
nx.mount.mount_usb_drive(usb_drive)
# Start the NSP game.
nx.app.start_title(nsp_file)
# Unmount the USB drive.
nx.mount.unmount_usb_drive(usb_drive)
def main():
"""The main entry point for the homebrew app."""
# Get the path to the USB drive.
usb_drive = nx.interface.get_usb_drive_path()
# If the USB drive is not mounted, prompt the user to insert it.
if not nx.mount.is_usb_drive_mounted(usb_drive):
nx.console.log("Please insert a USB drive.")
nx.input.wait_for_button_press()
# Get the path to the NSP file.
nsp_file = nx.file.select_file()
# Install the NSP game to the USB drive.
install_nsp(nsp_file, usb_drive)
# Run the NSP game from the USB drive.
run_nsp(nsp_file, usb_drive)
if __name__ == "__main__":
main()
It just says:
To compile this Python application into a homebrew app, you can use the following command:
// Install an NSP game to an external USB drive.
void InstallNSPGameToUSB(const char* nsp_file, const char* usb_path) {
// Open the NSP game file.
FILE* file = fopen(nsp_file, "rb");
if (!file) {
return;
}
// Get the file size.
fseek(file, 0, SEEK_END);
size_t size = ftell(file);
fseek(file, 0, SEEK_SET);
// Allocate a buffer to store the NSP game file.
uint8_t* buffer = (uint8_t*)malloc(size);
if (!buffer) {
fclose(file);
return;
}
// Read the NSP game file into the buffer.
fread(buffer, 1, size, file);
fclose(file);
// Open the USB device.
handle_t usb_device;
swipc_usb_open(&usb_device, usb_path);
// Write the NSP game file to the USB device.
swipc_usb_write(usb_device, buffer, size);
// Close the USB device.
swipc_usb_close(usb_device);
// Free the buffer.
free(buffer);
}
// Uninstall an NSP game from an external USB drive.
void UninstallNSPGameFromUSB(const char* usb_path) {
// Open the USB device.
handle_t usb_device;
swipc_usb_open(&usb_device, usb_path);
// Remove the NSP game file from the USB device.
swipc_usb_remove(usb_device, "NSP");
// Close the USB device.
swipc_usb_close(usb_device);
}
// Run an NSP game from an external USB drive.
void RunNSPGameFromUSB(const char* usb_path) {
// Open the USB device.
handle_t usb_device;
swipc_usb_open(&usb_device, usb_path);
// Read the NSP game file from the USB device.
size_t size = swipc_usb_get_file_size(usb_device, "NSP");
uint8_t* buffer = (uint8_t*)malloc(size);
swipc_usb_read(usb_device, buffer, size, 0);
// Close the USB device.
swipc_usb_close(usb_device);
// Load the NSP game file into memory.
nx_applet_load_package_memory(buffer, size, 0);
// Start the NSP game.
nx_applet_start();
// Wait for the NSP game to exit.
nx_applet_wait();
// Free the buffer.
free(buffer);
}
int main(void) {
// Initialize the Nintendo Switch.
switch_init();
// Get the path to the NSP game file.
char* nsp_file = switch_select_file();
if (!nsp_file) {
switch_exit();
return 1;
}
// Get the path to the external USB drive.
char* usb_path = switch_select_path();
if (!usb_path) {
switch_exit();
return 1;
}
// Install the NSP game to the external USB drive.
InstallNSPGameToUSB(nsp_file, usb_path);
// Run the NSP game from the external USB drive.
RunNSPGameFromUSB(usb_path);
// Uninstall the NSP game from the external USB drive.
UninstallNSPGameFromUSB(usb_path);
Developer pepsipu has released technical details for a userland exploit for the Nintendo Switch 2 called ns2jb.
If credible, this is the first software-only, tethered...
Before Thursday, the Switch 2 jailbreak scene was basically non-existent and was even a bit of a running joke. But a single tweet from researcher pepsipu changed all...
May the good times continue in the Switch 2 homebrew scene! Released today by developer Gezine, CivSwitch offers a new entrypoint for homebrew on the system, this...
The Legend of Zelda: Ocarina of Time, the Switch 2 remake has been dumped and is already booting and playable on high-end PCs running on Lichii, an experimental...
The next Nintendo Switch 2 update is here, 23.5.0 (shared also with Switch 1), and with it a fix for the recent FS exploit. If you are interested in homebrew you are...
It's been a turbulent few weeks in the game porting space. We've seen gaming worlds smashed together, as well as games being statically recompiled for every platform...
The Switch 2 scene is moving quickly, and today marks another significant achievement with the release of KaiHEN改变! Kurumuz, who also authored a more stable version...
It's been something of a wild few weeks in the Switch 2 space. For those of you not keeping track, we've seen the first exploit released, utilising SmileBASIC as an...
Announced back in May, Pokemon Monomyth is a brand new ROM hack based on Pokemon Emerald that's more than six years in the making. I hear the cries already, another...
The devs behind Azahar, the 3DS emulator that spawned out of Citra (which was taken down in 2024 after Nintendo went after its developers) has announced that they...
Developer pepsipu has released technical details for a userland exploit for the Nintendo Switch 2 called ns2jb.
If credible, this is the first software-only, tethered...
May the good times continue in the Switch 2 homebrew scene! Released today by developer Gezine, CivSwitch offers a new entrypoint for homebrew on the system, this...
GBAtemp is 24 today!
2 decades, 4 years and still kicking it
It is with a real sense of pride in my chest that I can announce GBAtemp.net has turned 24 today (well...
The review embargo for Rockstar Games' Grand Theft Auto VI lifted today and the verdict is about as close to unanimous praise as it gets.
With more than 145 critic...
According to Fortune, internal projections at Microsoft place the RRP of Microsoft's upcoming Project Helix somewhere between $1200-1800 USD when it releases in the...
Grab your tunic and ocarina, The Legend of Zelda: Ocarina of Time remake lands today on Nintendo Switch 2!
Reviews are looking good with the game sitting on a 95 on...
A collector named Daniel Quadri says he owns what is believed to be the only known playable copy of PokéPark: Tsuri Taikai, also known as PokéPark: Fishing Rally...
Before Thursday, the Switch 2 jailbreak scene was basically non-existent and was even a bit of a running joke. But a single tweet from researcher pepsipu changed all...
Electronic Arts has announced it is shutting down BioWare, who were founded in 1995 and bought by EA in 2007 as part of a wave of layoffs and project cuts. They are...
The Legend of Zelda: Ocarina of Time, the Switch 2 remake has been dumped and is already booting and playable on high-end PCs running on Lichii, an experimental...