Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework USB64 for portability #47

Open
wants to merge 121 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
a419fbe
Input: Refactor input type checks
Ryzee119 Nov 22, 2021
c961283
FileIO: Rework for portability
Ryzee119 Nov 22, 2021
75415cf
Memory: Rework for portability
Ryzee119 Nov 23, 2021
14f7159
T4: Move HAL wrapper to Teensy folder
Ryzee119 Nov 23, 2021
dd6a03c
Main: Rework for portability
Ryzee119 Nov 23, 2021
ab96e7e
TFT: Rework for portability. Implement GuiLite
Ryzee119 Nov 24, 2021
5aacff9
FileIO: Add status check function
Ryzee119 Nov 24, 2021
d5328e4
HAL: Update GPIO read wrapper
Ryzee119 Nov 24, 2021
e76849d
AStick: Remove Arduino header
Ryzee119 Nov 24, 2021
f6533f1
HAL: Add global interrupt functions
Ryzee119 Nov 24, 2021
e546997
Memory: Remove remaining Arduino specific code
Ryzee119 Nov 24, 2021
94225b5
N64: Remove Arduino headers
Ryzee119 Nov 24, 2021
a9cf44b
usb64: Clean up includes
Ryzee119 Nov 24, 2021
fa945b4
TFT: Move TFT code to src folder
Ryzee119 Nov 24, 2021
b1032b3
usb64: Refactor folders
Ryzee119 Nov 24, 2021
5ff0b3c
USBH: Replace USB Stack with TinyUSB
Ryzee119 Nov 29, 2021
2899542
TinyUSB: Update submodule
Ryzee119 Nov 30, 2021
3e6a1e1
USBH: Add Teensy4 TinyUSB driver
Ryzee119 Nov 30, 2021
a8709a8
USBH: Add xinput driver
Ryzee119 Nov 30, 2021
2b49305
Input: Rework for TinyUSB backend
Ryzee119 Nov 30, 2021
c3a540c
Main: Update for new input backend
Ryzee119 Nov 30, 2021
348095d
Build: Update CI for TinyUSB
Ryzee119 Nov 30, 2021
9dbdb34
USBH: Disable debug output
Ryzee119 Nov 30, 2021
4389122
Input: Fix warnings and remove debug messages
Ryzee119 Nov 30, 2021
1a1b349
Input: Replace ASCII defines with TinyUSB
Ryzee119 Nov 30, 2021
caeab54
FileIO: Return 0 on success
Ryzee119 Nov 30, 2021
87e7d71
HAL: Add milli tick wrapper
Ryzee119 Nov 30, 2021
cd6214d
Conf: Fix printf wrapper linkage errors
Ryzee119 Nov 30, 2021
06015cd
usb64: Fix warnings
Ryzee119 Nov 30, 2021
5586e20
T4: Clean up includes
Ryzee119 Nov 30, 2021
c739ec1
usb64: Add null device
Ryzee119 Nov 30, 2021
8e810cc
TinyUSB: Update submodule
Ryzee119 Nov 30, 2021
3215f86
n64: Use my own sprintf
Ryzee119 Nov 30, 2021
2e5f0d5
USBH: Add HID driver stub
Ryzee119 Nov 30, 2021
a578c3b
Xinput: Format driver
Ryzee119 Nov 30, 2021
0957387
usb64: Rename port folders
Ryzee119 Nov 30, 2021
95d8a85
Build: build all environments
Ryzee119 Nov 30, 2021
b950558
HID: Use inbuilt hid header
Ryzee119 Nov 30, 2021
fadbb2e
TFT: Rework and allow use with no framebuffer
Ryzee119 Nov 30, 2021
0045a89
Null: Comment all functions for porting
Ryzee119 Nov 30, 2021
6abe568
N64: Fix confict with stdio
Ryzee119 Nov 30, 2021
724e2fc
Remove printf submodule
Ryzee119 Nov 30, 2021
3c69cd1
Build: Link lpthread for linux test build
Ryzee119 Nov 30, 2021
dbf6043
Printf: Readd with mods
Ryzee119 Nov 30, 2021
7583ec6
TFT: Dont set pointer twice
Ryzee119 Nov 30, 2021
755ab5b
Main: Dont use stdio vprintf
Ryzee119 Nov 30, 2021
c1cbf57
TinyUSB: Use my own TinyUSB fork
Ryzee119 Nov 30, 2021
7d693b2
TinyUSB: Update submodule
Ryzee119 Nov 30, 2021
d81ccd9
GuiLite: Suppress warnings
Ryzee119 Nov 30, 2021
f456672
usb64: Fix some warnings
Ryzee119 Nov 30, 2021
d049e34
null: Add millis to HAL
Ryzee119 Dec 3, 2021
5907584
T4: Move usb64_conf file to port fodler
Ryzee119 Dec 4, 2021
d1c8a35
Main: Loop properly when not using Arduino
Ryzee119 Dec 4, 2021
4d16a8c
TFT: Store font on ext flash
Ryzee119 Dec 4, 2021
99fb76c
Input: Store randnet map on ext flash
Ryzee119 Dec 4, 2021
f5f7bb0
N64: Store constant virtual mempak on ext flash
Ryzee119 Dec 4, 2021
5e5f8af
Main: Assert rumble pin for HW controller
Ryzee119 Dec 6, 2021
ca4d229
TFT: Refactor TFT background colour def
Ryzee119 Dec 6, 2021
c313475
Ports: Add FLASHMEM define
Ryzee119 Dec 6, 2021
152ca04
usb64: Make init functions execute from flash where possible
Ryzee119 Dec 6, 2021
11a174e
N64: Bracket calc to prevent overflow
Ryzee119 Dec 6, 2021
421c798
usb64: Refactor GPIO for better portability
Ryzee119 Dec 7, 2021
6281b48
null: Update backend for GPIO refactor
Ryzee119 Dec 7, 2021
921ff7e
t4: Update backend for GPIO refactor
Ryzee119 Dec 7, 2021
428021a
usb64: Refactor GPIO for better portability
Ryzee119 Dec 7, 2021
0d9641a
TFT: Reset update flag after draw
Ryzee119 Dec 11, 2021
2fade24
TFT: Update on usb connection
Ryzee119 Dec 11, 2021
b24f497
TFT: Move log generation to flush
Ryzee119 Dec 14, 2021
1fd4bed
usb64: Rework includes and port configuration (again)
Ryzee119 Dec 14, 2021
593ad2d
TFT: Flag update after device disconncet
Ryzee119 Dec 15, 2021
5a4ce00
TFT: Check malloc before use
Ryzee119 Dec 15, 2021
17ca983
N64: Make CRC function weak
Ryzee119 Dec 15, 2021
fda0269
TFT: Use memory malloc function
Ryzee119 Dec 16, 2021
414b6ee
Null: Add malloc wrappers
Ryzee119 Dec 16, 2021
ca45e9a
T4: Add malloc wrappers
Ryzee119 Dec 16, 2021
8f04762
N64: Use n64 malloc wrappers
Ryzee119 Dec 16, 2021
7363515
N64: Add malloc wrappers to header
Ryzee119 Dec 16, 2021
2699534
TinyUSBH: Update submodule
Ryzee119 Dec 16, 2021
f120483
usb64: Add stm32f7 port
Ryzee119 Dec 16, 2021
bffa184
usb64: Update platformio.ini
Ryzee119 Dec 16, 2021
730e89b
TFT: Use standard malloc for tft log, stop recursive logging
Ryzee119 Dec 20, 2021
b280e81
tuh: Allow multiple hubs
Ryzee119 Dec 20, 2021
4f33489
TinyUSB: Update submodule
Ryzee119 Dec 20, 2021
ca1bda9
XINPUT: Dont parse callback if error
Ryzee119 Jan 6, 2022
aa2add7
STM32F7 USBH: Rework, multiport hubs work, more devices at once
Ryzee119 Jan 6, 2022
32eed1d
Tinyusb: Update submodule
Ryzee119 Jan 6, 2022
77933bf
stm32f7: Disable USB IRQ too
Ryzee119 Jan 6, 2022
85a6ab0
TinyUSB: Update submodule
Ryzee119 Jan 9, 2022
532d03d
USBH: Increase enumeration buffer size
Ryzee119 Jan 9, 2022
1e8faf2
stm32f7 usbh: Share control pipe, refactor functions
Ryzee119 Jan 9, 2022
7a054e7
TinyUSB: Update submodule
Ryzee119 Jan 9, 2022
71727a1
Input: Correctly handle wireless 360 controllers
Ryzee119 Jan 11, 2022
c993a61
TinyUSB: Update submodule
Ryzee119 Jan 11, 2022
6cd69d8
TinyUSB: Update submodule
Ryzee119 Jan 11, 2022
e224a71
Input: Add HID mouse input driver
Ryzee119 Jan 12, 2022
3b6ff4b
Improve CI to upload dev artefacts
networkfusion Jan 15, 2022
820506d
usb64: Add stm32f769i-dk environment
Ryzee119 Jan 9, 2022
b30e231
STM32F769i: Initial commit
Ryzee119 Jan 9, 2022
daf90c2
STM32F768i: Boots now
Ryzee119 Jan 15, 2022
b7e18a3
STM32F768i: Support USB HS port
Ryzee119 Jan 15, 2022
f284583
stm32f7 usbh: Force full speed mode, properly handle transfer speeds
Ryzee119 Jan 15, 2022
d4a3d3a
TinyUSB: Update submodule
Ryzee119 Jan 15, 2022
9c56fe5
STM32F769I: Re-add custom linker
Ryzee119 Jan 15, 2022
1c605a0
STM32F769I: Fix GPIO interrupts
Ryzee119 Jan 15, 2022
82f3d01
STM32F769I: Disable USB HS interrupt for critical code
Ryzee119 Jan 15, 2022
cb39d06
STM32F769I: Clear pending interrupts before leaving
Ryzee119 Jan 15, 2022
4141387
STM32F769I: Use uart1 VCP for debugging over USB
Ryzee119 Jan 16, 2022
8a0454c
STM32: Remove main.h header
Ryzee119 Jan 16, 2022
879ebb6
N64: Add ED64 game identifier packet
Ryzee119 Jan 17, 2022
810ed20
TFT: Print current game name on TFT
Ryzee119 Jan 17, 2022
be68372
STM32F789I: Reduce SD speed
Ryzee119 Jan 17, 2022
af0abb5
STM32F7: Move common bsp port code to folder
Ryzee119 Jan 17, 2022
1477c83
Generate hex output
networkfusion Jan 15, 2022
a062025
Input: Re-add RANDNET emulation
Ryzee119 Jan 19, 2022
192ab74
TFT: Scale output on large LCDs
Ryzee119 Jan 21, 2022
bd3faf4
STM32FXX: Add builds to CI
networkfusion Jan 26, 2022
a627e9b
N64 :Refactor mempak title to cpak
networkfusion Jan 27, 2022
f07995d
N64: Rename n64_mempak files
networkfusion Jan 28, 2022
36bba0a
Update submodules
Ryzee119 Aug 8, 2022
c13bc0c
TFT: Use lvgl instead of guilite
Ryzee119 Sep 20, 2022
dc5da42
Input: Add xinput lib
Ryzee119 Aug 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
43 changes: 35 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
push:
branches:
- master
- dev*

jobs:
build:
Expand All @@ -16,12 +17,24 @@ jobs:
BUILD_TAG: 0

runs-on: ubuntu-latest
strategy:
matrix:
board: [teensy41,disco_f769ni,disco_f750n8,template]

steps:
- name: Checkout repo
uses: actions/checkout@v1
with:
submodules: recursive

- name: Get submoduiles
run: |
git submodule init
git submodule update
# If manually get TinyUSBs submodules we need otherwise its a huge repo
cd src/lib/tinyusb
# Teensy41 Specific
git submodule init hw/mcu/nxp/mcux-sdk
git submodule update
cd ../../../

- name: Set up Python
uses: actions/setup-python@v1
Expand All @@ -34,9 +47,23 @@ jobs:
echo "BUILD_TAG=$BUILD_TAG" >> $GITHUB_ENV

- name: Compile code
run: platformio run -e teensy41
run: |
platformio platform update
platformio run -e ${{ matrix.board }}
# platformio system prune --force

- if: matrix.board != 'template'
name: Upload firmware artifact to current run
uses: actions/upload-artifact@v2
with:
name: test-firmware-${{ matrix.board }}
path: |
.pio/build/**/*.hex
# .pio/build/**/*.bin # Should not be required for any boards, and makes upload file size incorrect!
.pio/build/**/*.elf
# .pio/build/**/*.map # Currently not generated.

- if: github.event_name == 'push'
- if: github.event_name == 'push' && github.ref == 'refs/heads/master' #TODO handle previews
name: Create Release
id: create_release
uses: "actions/create-release@v1"
Expand All @@ -46,12 +73,12 @@ jobs:
draft: false
prerelease: false

- if: github.event_name == 'push'
name: Upload binary to release
- if: github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.board != 'template' #TODO handle previews
name: Upload binary for release
id: upload-release-asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: .pio/build/teensy41/firmware.hex
asset_name: firmware-teensy41.hex
asset_path: .pio/build/${{ matrix.board }}/firmware.hex
asset_name: firmware-${{ matrix.board }}.hex
asset_content_type: application/hex
24 changes: 14 additions & 10 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
[submodule "src/printf"]
path = src/printf
url = https://github.com/mpaland/printf

[submodule "src/USBHost_t36"]
path = src/USBHost_t36
url = https://github.com/Ryzee119/USBHost_t36.git

[submodule "src/ILI9341_t3n"]
path = src/ILI9341_t3n
[submodule "src/lib/tinyusb"]
path = src/lib/tinyusb
url = https://github.com/Ryzee119/tinyusb.git
[submodule "src/teensy41/ILI9341_t3n"]
path = src/port_teensy41/ILI9341_t3n
url = https://github.com/KurtE/ILI9341_t3n.git
[submodule "src/lib/tinyalloc"]
path = src/lib/tinyalloc
url = https://github.com/thi-ng/tinyalloc.git
[submodule "src/lib/tusb_xinput"]
path = src/lib/tusb_xinput
url = https://github.com/Ryzee119/tusb_xinput.git
[submodule "src/lib/lvgl"]
path = src/lib/lvgl
url = https://github.com/lvgl/lvgl.git
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Precompiled binaries can be downloaded from [Releases](https://github.com/Ryzee1
**NOTE: This project is still in development, PRs and ideas are welcome. See todo list for ideas.**

- [x] N64 controller emulation (up to four controllers at once!).
- [x] Rumblepak emulation.
- [x] Mempak emulation with four selectable banks. Technically unlimited.
- [x] Transferpak emulation. Put Gameboy ROMS on an SD Card!
- [x] Rumble Pak emulation.
- [x] Controller Pak emulation with four selectable banks. Technically unlimited.
- [x] Transfer Pak emulation. Put Gameboy ROMS on an SD Card!
- [x] N64 mouse emulation. Use a USB Mouse!
- [x] N64 Randnet emulation. Use a USB keyboard!
- [x] Configurable deadzones and sensitivity from the N64 Console.
- [x] True dual analog sticks with GoldenEye and Perfect Dark.
- [x] SD card driver with FATFS support for storage/backup of Gameboy ROMS, mempaks etc.
- [x] SD card driver with FATFS support for storage/backup of Gameboy ROMS, controller paks etc.
- [x] A single hardwired controller interface for ultimate hacking.
- [x] Optional TFT LCD Support.

Expand All @@ -36,10 +36,10 @@ Precompiled binaries can be downloaded from [Releases](https://github.com/Ryzee1
- A hardwired controller, use your own buttons etc.

## Controls
- Back + D-Pad = Insert Mempak banks 1 to 4
- Back + D-Pad = Insert Controller Pak banks 0 to 3
- Back + LB = Insert Rumblepak
- Back + RB = Insert Transferpak
- Back + Start = Select *virtual pak* (Use in-game mempak managers to configure the device)
- Back + Start = Select *virtual pak* (Use in-game Controller Pak managers to configure the device)
- Back + B = Switch to true dual-analog stick more for GoldenEye 007/Perfect Dark
- Back + A = Backup buffered memory to SD Card **(DO THIS BEFORE POWER OFF!)**

Expand Down
22 changes: 11 additions & 11 deletions USAGE.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
# Usage
* [Mempaks](#mempaks)
* [Rumblepaks](#rumblepaks)
* [Transferpaks](#transferpaks)
* [Virtualpak](#virtualpak)
* [Controller Paks](#controller-paks)
* [Rumble Paks](#rumble-paks)
* [Transfer Paks](#transfer-paks)
* [Virtual Pak](#virtual-pak)
* [Dual Stick Mode](#dual-stick-mode)
* [N64 Mouse](#n64-mouse)
* [TFT LCD Display](#tft-lcd-display)
* [Debug](#debug)

## Mempaks
## Controller Paks
* usb64 can simulate four Mempaks simultaneously. To select a Mempak press `BACK+D-PAD` direction to select the respective bank.
* Two controllers cannot have the same bank selected. The second controller will revert to a Rumblepak.
* Do not unplug the usb64's power before turning off the n64 console to prevent data loss. The usb64 senses the n64 console turning off and flushes data to the SD Card.
* Inserting the SD card into your PC will show Mempaks as `MEMPAKXX.MPK` where XX is the bank number. You can back these up to your PC.

## Rumblepaks
## Rumble Paks
* usb64 can simulate four Rumblepaks simultaneously. Rumblepaks are the default peripheral on power up. To select a Rumblepak press `BACK+LB`.
* The usb controller must support force feedback.

## Transferpaks
## Transfer Paks
* usb64 can simulate four transferpaks simulateneously. The select a Transferpak press `BACK+RB`. The transferpak will attempt to load the previously set Gameboy or Gameboy Colour ROM from the SD Card.
* To select the ROM to load, you must first use the [*VirtualPak*](#virtualpak). If a ROM isn't selected, or fails to load, it will revert to a Rumblepak.
* Avoid having two controllers access the same ROM at once.
* Do not unplug the usb64's power before turning off the n64 console to prevent data loss. The usb64 senses the n64 console turning off and flushes data to the SD Card.
* Gameboy saves can be copied over to the SD Card for use with the Transferpak. The file name must match the ROM save with a `.SAV` extension.
* You can simulate four transferpaks, with four difference ROMS, with four different save files! <p align="center"><img src="./images/tpak_6.png" alt="tpak_6" width="35%"/> <img src="./images/tpak_7.png" alt="tpak_7" width="35%"/></p> <p align="center"><img src="./images/silver.gif" alt="silver" width="35%"/> <img src="./images/tpak_1.png" alt="tpak_1" width="35%"/></p> <p align="center"><img src="./images/tpak_5.png" alt="tpak_5" width="35%"/> <img src="./images/tpak_8.png" alt="tpak_8" width="35%"/></p>

## Virtualpak
* The Virtualpak is one of my favourite features. It's like a Mempak, but is not used for save files. It exploits the Mempak managers built into some N64 games to configure the usb64 device!
## Virtual Pak
* The VirtualCpak is one of my favourite features. It's like a Controller Pak, but is not used for save files. It exploits the Mempak managers built into some N64 games to configure the usb64 device!
* To select the Virtualpak press `BACK+START`.
* To use the Virtualpak, boot into a game that has a Mempak manager. Some games will work better than others. `Army Men: Air Combat` is a good one. `Perfect Dark` works well too. Hold START whilst the game is booting to access the Mempak manager. The follow screens show `Army Men: Air Combat` and `Perfect Dark` as an example. <p align="center"><img src="./images/vp_main.png" alt="vp_main" width="35%"/> <img src="./images/vp_perfectdark.png" alt="vp_perfectdark" width="35%"/></p>
* To select an item, you actually delete that note from the Mempak. usb64 detects what row you selected as if navigating a menu!
* To use the Virtualpak, boot into a game that has a Contrroller Pak manager. Some games will work better than others. `Army Men: Air Combat` is a good one. `Perfect Dark` works well too. Hold START whilst the game is booting to access the Controller Pak manager. The follow screens show `Army Men: Air Combat` and `Perfect Dark` as an example. <p align="center"><img src="./images/vp_main.png" alt="vp_main" width="35%"/> <img src="./images/vp_perfectdark.png" alt="vp_perfectdark" width="35%"/></p>
* To select an item, you actually delete that note from the Controller Pak. usb64 detects what row you selected as if navigating a menu!
* **TPAK SETTINGS** is used to configure what ROM to load into the Transferpak. This will scan the SD card for files with `.gb` and `.gbc` extensions. A `*` will print next to the currently set ROM. You can have up to ten ROMs on the SD card. After this they will just get ignored. <p align="center"><img src="./images/vp_tpak.png" alt="vp_tpak" width="35%"/></p>
* **CONT SETTINGS** is used to configure the controller. You can change deadzone, Sensitivity, toggle on/off snapping to 45deg angles and toggle on/off a octagonal N64 stick correction. The set values is shown as a number next to the row. Each controller can be configured individually. Note: Some controllers will have deadzones or 45 degree angle snapping built in. For these, usb64 can't disable it. <p align="center"><img src="./images/vp_cont.png" alt="vp_cont" width="35%"/></p>
* **USB64 INFO1** shows what controller is connected to that port. <p align="center"><img src="./images/vp_info1.png" alt="vp_info1" width="35%"/></p>
Expand Down
44 changes: 44 additions & 0 deletions boards/disco_f750n8_extflash.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"build": {
"cpu": "cortex-m7",
"extra_flags": "-DSTM32F750xx",
"f_cpu": "216000000L",
"mcu": "stm32f750n8h6",
"product_line": "STM32F750xx"
},
"connectivity": [
"can",
"ethernet"
],
"debug": {
"default_tools": [
"stlink"
],
"jlink_device": "STM32F750N8",
"onboard_tools": [
"stlink"
],
"openocd_board": "stm32f7discovery",
"openocd_target": "stm32f7x",
"svd_path": "STM32F750x.svd"
},
"frameworks": [
"cmsis",
"stm32cube",
"libopencm3"
],
"name": "STM32F7508-DK",
"upload": {
"maximum_ram_size": 327680,
"maximum_size": 16777216,
"protocol": "stlink",
"protocols": [
"jlink",
"cmsis-dap",
"stlink",
"blackmagic"
]
},
"url": "https://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-mpu-eval-tools/stm32-mcu-mpu-eval-tools/stm32-discovery-kits/stm32f7508-dk.html",
"vendor": "ST"
}
10 changes: 10 additions & 0 deletions hex_from_elf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Import("env")

# Custom HEX from ELF
env.AddPostAction(
"$BUILD_DIR/${PROGNAME}.elf",
env.VerboseAction(" ".join([
"$OBJCOPY", "-O", "ihex", "-R", ".eeprom",
"$BUILD_DIR/${PROGNAME}.elf", "$BUILD_DIR/${PROGNAME}.hex"
]), "Building $BUILD_DIR/${PROGNAME}.hex")
)
Loading