diff --git a/.bin/4nxci b/.bin/4nxci new file mode 100755 index 0000000..44e9837 Binary files /dev/null and b/.bin/4nxci differ diff --git a/.bin/NSP_NX.py b/.bin/NSP_NX.py new file mode 100755 index 0000000..404bf6b --- /dev/null +++ b/.bin/NSP_NX.py @@ -0,0 +1,165 @@ +# This script depends on PyUSB. You can get it with pip install pyusb. +# You will also need libusb installed + +# My sincere apologies for this process being overly complicated. Apparently Python and Windows +# aren't very friendly :( +# Windows Instructions: +# 1. Download Zadig from https://zadig.akeo.ie/. +# 2. With your switch plugged in and on the Tinfoil USB install menu, +# choose "List All Devices" under the options menu in Zadig, and select libnx USB comms. +# 3. Choose libusbK from the driver list and click the "Replace Driver" button. +# 4. Run this script + +# macOS Instructions: +# 1. Install Homebrew https://brew.sh +# 2. Install Python 3 +# sudo mkdir /usr/local/Frameworks +# sudo chown $(whoami) /usr/local/Frameworks +# brew install python +# 3. Install PyUSB +# pip3 install pyusb +# 4. Install libusb +# brew install libusb +# 5. Plug in your Switch and go to Tinfoil > Title Management > USB Install NSP +# 6. Run this script +# python3 usb_install_pc.py + +import usb.core +import usb.util +import struct +import sys +from binascii import hexlify as hx, unhexlify as uhx +from pathlib import Path + +CMD_ID_EXIT = 0 +CMD_ID_FILE_RANGE = 1 +CMD_ID_FILE_RANGE_PADDED = 2 + +CMD_TYPE_RESPONSE = 1 + +BUFFER_SEGMENT_DATA_SIZE = 0x100000 +PADDING_SIZE = 0x1000 + +def send_response_header(out_ep, cmd_id, data_size): + out_ep.write(b'TUC0') # Tinfoil USB Command 0 + out_ep.write(struct.pack('= end_off: + read_size = end_off - curr_off + + buf = f.read(read_size) + if (padding): + buf = b'\x00' * PADDING_SIZE + buf + out_ep.write(data=buf, timeout=0) + curr_off += read_size + +def poll_commands(nsp_dir, in_ep, out_ep): + while True: + cmd_header = bytes(in_ep.read(0x20, timeout=0)) + magic = cmd_header[:4] + print('Magic: {}'.format(magic), flush=True) + + if magic != b'TUC0': # Tinfoil USB Command 0 + continue + + cmd_type = struct.unpack('""") + +if __name__ == '__main__': + if len(sys.argv) != 2: + print_usage() + sys.exit(1) + + nsp_dir = Path(sys.argv[1]) + + if not nsp_dir.is_dir(): + raise ValueError('1st argument must be a directory') + + # Find the switch + dev = usb.core.find(idVendor=0x057E, idProduct=0x3000) + + if dev is None: + raise ValueError('Switch is not found!') + + dev.reset() + dev.set_configuration() + cfg = dev.get_active_configuration() + + is_out_ep = lambda ep: usb.util.endpoint_direction(ep.bEndpointAddress) == usb.util.ENDPOINT_OUT + is_in_ep = lambda ep: usb.util.endpoint_direction(ep.bEndpointAddress) == usb.util.ENDPOINT_IN + out_ep = usb.util.find_descriptor(cfg[(0,0)], custom_match=is_out_ep) + in_ep = usb.util.find_descriptor(cfg[(0,0)], custom_match=is_in_ep) + + assert out_ep is not None + assert in_ep is not None + + send_nsp_list(nsp_dir, out_ep) + poll_commands(nsp_dir, in_ep, out_ep) diff --git a/.bin/NX2OGG.py b/.bin/NX2OGG.py new file mode 100755 index 0000000..78b3625 --- /dev/null +++ b/.bin/NX2OGG.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +""" +Converts .lopus to .ogg via vgmstream & ffmpeg +""" + +__author__ = "Melon Bread" +__version__ = "0.5.0" +__license__ = "MIT" + +import argparse +import os +import subprocess + + +def main(args): + file = args.input[:-6] + + try: + print("Converting .lpous to .wav via vgmstream-cli...") + subprocess.Popen(['vgmstream-cli', '-o', + '{}.wav'.format(file), args.input]).wait() + pass + except Exception as e: + print("ERROR: Please make sure 'vgmstream-cli' is in the PATH!") + raise + + try: + print("Converting .wav to .ogg via ffmpeg...") + subprocess.Popen(['ffmpeg', '-i', '{}.wav'.format(file), '-acodec', + 'libvorbis', '{}.ogg'.format(file)]).wait() + pass + except Exception as e: + print("ERROR: Please make sure 'ffmpeg' is in the PATH!") + raise + + print("Removing .wav file...") + os.remove("{}.wav".format(file)) + + +if __name__ == "__main__": + """ This is executed when run from the command line """ + parser = argparse.ArgumentParser() + + parser.add_argument('-i', '--input', metavar='STRING', required=True, + help='.lopus file your want to convert to .ogg') + + args = parser.parse_args() + main(args) diff --git a/.bin/Pipgrade.sh b/.bin/Pipgrade.sh new file mode 100644 index 0000000..d8fff31 --- /dev/null +++ b/.bin/Pipgrade.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +echo 'Updating all user installed pip packages...' +pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install --user -U diff --git a/.bin/pico8 b/.bin/pico8 new file mode 120000 index 0000000..177c39e --- /dev/null +++ b/.bin/pico8 @@ -0,0 +1 @@ +/home/melon/Games/Linux/pico-8/pico8 \ No newline at end of file