Skip to content

Commit

Permalink
Merge pull request #49 from fhoedemakers/development
Browse files Browse the repository at this point in the history
Added support for two player games by adding a second NES controller port
  • Loading branch information
fhoedemakers authored Aug 18, 2024
2 parents e2f827d + e1d0bb9 commit 49bd454
Show file tree
Hide file tree
Showing 14 changed files with 363 additions and 129 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ Binaries for each configuration are at the end of this page.

# Release notes

## v0.13

Features:

- Two player games can now be played. An extra NES controller port can be added to any configuration. Controller port 1 can be a USB or NES controller, controller 2 must be a NES controller. At the moment, no second USB controller can be connected.

Fixes:

- none

Technical changes:

- Pimoroni Pico DV Demo Base: uart output fore debug printf messages is disabled, because gpio1 is needed for the seconc NES controller port.


## v0.12

Features:
Expand Down
67 changes: 53 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ if (NOT INFONES_PLUS_HW_CONFIG)
set(INFONES_PLUS_HW_CONFIG 1 CACHE STRING "Select the hardware configuration for your board")
endif()
if ( INFONES_PLUS_HW_CONFIG EQUAL 1 )
# This default Config is for Pimoroni Pico DV Demo Base
# This default Config is for Pimoroni Pico DV Demo Base, note uart is disabled because gpio 1 is used for NES controller
set(DVICONFIG "dviConfig_PimoroniDemoDVSock" CACHE STRING
"Select a default pin configuration from common_dvi_pin_configs.h")
set(LED_GPIO_PIN "25" CACHE STRING "Select the GPIO pin for LED")
Expand All @@ -72,11 +72,17 @@ if ( INFONES_PLUS_HW_CONFIG EQUAL 1 )
set(NES_CLK "14" CACHE STRING "Select the Clock GPIO pin for NES controller")
set(NES_DATA "15" CACHE STRING "Select the Data GPIO pin for NES controller")
set(NES_LAT "16" CACHE STRING "Select the Latch GPIO pin for NES controller")
set(NES_PIO "pio0" CACHE STRING "Select the PIO for NES controller")
set(NES_CLK_1 "1" CACHE STRING "Select the Clock GPIO pin for second NES controller")
set(NES_DATA_1 "21" CACHE STRING "Select the Data GPIO pin for second NES controller")
set(NES_LAT_1 "20" CACHE STRING "Select the Latch GPIO pin for second NES controller")
set(NES_PIO_1 "pio1" CACHE STRING "Select the PIO for second NES controller")
set(WII_SDA "-1" CACHE STRING "Select the SDA GPIO pin for Wii Classic controller")
set(WII_SCL "-1" CACHE STRING "Select the SCL GPIO pin for Wii Classic controller")
elseif ( INFONES_PLUS_HW_CONFIG EQUAL 2 )
# --------------------------------------------------------------------
# Alternate config for use with different SDcard reader and HDMI board
# Use also for Printed Circuit Board (PCB) version.
# --------------------------------------------------------------------
# Adafruit DVI Breakout For HDMI Source Devices https://www.adafruit.com/product/4984
set(DVICONFIG "dviConfig_PicoDVISock" CACHE STRING
Expand All @@ -90,6 +96,11 @@ elseif ( INFONES_PLUS_HW_CONFIG EQUAL 2 )
set(NES_CLK "6" CACHE STRING "Select the Clock GPIO pin for NES controller")
set(NES_DATA "7" CACHE STRING "Select the Data GPIO pin for NES controller")
set(NES_LAT "8" CACHE STRING "Select the Latch GPIO pin for NES controller")
set(NES_PIO "pio0" CACHE STRING "Select the PIO for NES controller")
set(NES_CLK_1 "9" CACHE STRING "Select the Clock GPIO pin for second NES controller")
set(NES_DATA_1 "10" CACHE STRING "Select the Data GPIO pin for second NES controller")
set(NES_LAT_1 "11" CACHE STRING "Select the Latch GPIO pin for second NES controller")
set(NES_PIO_1 "pio1" CACHE STRING "Select the PIO for second NES controller")
set(WII_SDA "-1" CACHE STRING "Select the SDA GPIO pin for Wii Classic controller")
set(WII_SCL "-1" CACHE STRING "Select the SCL GPIO pin for Wii Classic controller")
elseif ( INFONES_PLUS_HW_CONFIG EQUAL 3 )
Expand All @@ -106,6 +117,11 @@ elseif ( INFONES_PLUS_HW_CONFIG EQUAL 3 )
set(NES_CLK "5" CACHE STRING "Select the Clock GPIO pin for NES controller")
set(NES_DATA "6" CACHE STRING "Select the Data GPIO pin for NES controller")
set(NES_LAT "9" CACHE STRING "Select the Latch GPIO pin for NES controller")
set(NES_PIO "pio0" CACHE STRING "Select the PIO for NES controller")
set(NES_CLK_1 "26" CACHE STRING "Select the Clock GPIO pin for second NES controller")
set(NES_DATA_1 "28" CACHE STRING "Select the Data GPIO pin for second NES controller")
set(NES_LAT_1 "27" CACHE STRING "Select the Latch GPIO pin for second NES controller")
set(NES_PIO_1 "pio1" CACHE STRING "Select the PIO for second NES controller")
set(WII_SDA "2" CACHE STRING "Select the SDA GPIO pin for Wii Classic controller")
set(WII_SCL "3" CACHE STRING "Select the SCL GPIO pin for Wii Classic controller")
elseif ( INFONES_PLUS_HW_CONFIG EQUAL 4 )
Expand All @@ -122,22 +138,32 @@ elseif ( INFONES_PLUS_HW_CONFIG EQUAL 4 )
set(NES_CLK "5" CACHE STRING "Select the Clock GPIO pin for NES controller")
set(NES_DATA "6" CACHE STRING "Select the Data GPIO pin for NES controller")
set(NES_LAT "9" CACHE STRING "Select the Latch GPIO pin for NES controller")
set(NES_PIO "pio0" CACHE STRING "Select the PIO for NES controller")
set(NES_CLK_1 "10" CACHE STRING "Select the Clock GPIO pin for second NES controller")
set(NES_DATA_1 "12" CACHE STRING "Select the Data GPIO pin for second NES controller")
set(NES_LAT_1 "11" CACHE STRING "Select the Latch GPIO pin for second NES controller")
set(NES_PIO_1 "pio1" CACHE STRING "Select the PIO for second NES controller")
set(WII_SDA "-1" CACHE STRING "Select the SDA GPIO pin for Wii Classic controller")
set(WII_SCL "-1" CACHE STRING "Select the SCL GPIO pin for Wii Classic controller")
endif ( )

# --------------------------------------------------------------------
message("HDMI board type : ${DVICONFIG}")
message("SD card CS : ${SD_CS}")
message("SD card SCK : ${SD_SCK}")
message("SD card MOSI : ${SD_MOSI}")
message("SD card MISO : ${SD_MISO}")
message("NES controller CLK : ${NES_CLK}")
message("NES controller DATA : ${NES_DATA}")
message("NES controller LAT : ${NES_LAT}")
message("Wii controller SDA : ${WII_SDA}")
message("Wii controller SCL : ${WII_SCL}")
message("LED pin : ${LED_GPIO_PIN}")
message("HDMI board type : ${DVICONFIG}")
message("SD card CS : ${SD_CS}")
message("SD card SCK : ${SD_SCK}")
message("SD card MOSI : ${SD_MOSI}")
message("SD card MISO : ${SD_MISO}")
message("NES controller 0 CLK : ${NES_CLK}")
message("NES controller 0 DATA : ${NES_DATA}")
message("NES controller 0 LAT : ${NES_LAT}")
message("NES controller 0 PIO : ${NES_PIO}")
message("NES controller 1 CLK : ${NES_CLK_1}")
message("NES controller 1 DATA : ${NES_DATA_1}")
message("NES controller 1 LAT : ${NES_LAT_1}")
message("NES controller 1 PIO : ${NES_PIO_1}")
message("Wii controller SDA : ${WII_SDA}")
message("Wii controller SCL : ${WII_SCL}")
message("LED pin : ${LED_GPIO_PIN}")

add_executable(piconesPlus
main.cpp
Expand All @@ -154,7 +180,15 @@ add_executable(piconesPlus
pico_set_program_name(piconesPlus "piconesPlus")
pico_set_program_version(piconesPlus "0.8")

pico_enable_stdio_uart(piconesPlus 1)
# disable uart output for Pimoronis Pico DV Demo Base, as gpio 1 is used for NES controller
# so debug messages will not be visible on the serial console.
if ( INFONES_PLUS_HW_CONFIG EQUAL 1 )
message("Disabling UART output for Pimoroni Pico DV Demo Base")
pico_enable_stdio_uart(piconesPlus 0)
else()
pico_enable_stdio_uart(piconesPlus 1)
endif()

pico_enable_stdio_usb(piconesPlus 0)

# tinyusb
Expand All @@ -171,10 +205,15 @@ target_compile_definitions(piconesPlus PRIVATE
SDCARD_PIN_SPI0_MOSI=${SD_MOSI}
SDCARD_PIN_SPI0_MISO=${SD_MISO}
SDCARD_PIO=pio1
SDCARD_PIO_SM=0
# SDCARD_PIO_SM=1 # Let the driver decide what state machine to use.
NES_PIN_CLK=${NES_CLK}
NES_PIN_DATA=${NES_DATA}
NES_PIN_LAT=${NES_LAT}
NES_PIO=${NES_PIO}
NES_PIN_CLK_1=${NES_CLK_1}
NES_PIN_DATA_1=${NES_DATA_1}
NES_PIN_LAT_1=${NES_LAT_1}
NES_PIO_1=${NES_PIO_1}
WII_PIN_SDA=${WII_SDA}
WII_PIN_SCL=${WII_SCL}
LED_GPIO_PIN=${LED_GPIO_PIN}
Expand Down
Loading

0 comments on commit 49bd454

Please sign in to comment.