Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmake/sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ set(
JOYBUS_SOURCES
${LIBJOYBUS_ROOT_DIR}/src/bus.c
${LIBJOYBUS_ROOT_DIR}/src/checksum.c
${LIBJOYBUS_ROOT_DIR}/src/n64_pak_fs.c
${LIBJOYBUS_ROOT_DIR}/src/host/common.c
${LIBJOYBUS_ROOT_DIR}/src/host/gcn.c
${LIBJOYBUS_ROOT_DIR}/src/host/n64.c
Expand Down
8 changes: 2 additions & 6 deletions examples/esp32/n64-target-cpak/main/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <esp_random.h>
#include <freertos/FreeRTOS.h>

#include <joybus/joybus.h>
Expand All @@ -24,12 +23,9 @@ void app_main(void)
// Initialize a N64 controller target as a standard controller.
joybus_target_n64_controller_init(&n64_controller);

// Format the pak, since RAM starts empty on every boot.
joybus_n64_pak_fs_format(pak_memory, 1, esp_random());

// Initialize a single bank controller pak over that memory and plug it into the controller.
joybus_target_n64_pak_controller_init(&controller_pak, 1);
joybus_target_n64_pak_controller_set_memory(&controller_pak, pak_memory);
joybus_target_n64_pak_controller_init(&controller_pak);
joybus_target_n64_pak_controller_set_memory(&controller_pak, pak_memory, 1);
joybus_target_n64_controller_attach_pak(&n64_controller, JOYBUS_TARGET_N64_PAK(&controller_pak));

// Attach the target to the bus.
Expand Down
2 changes: 1 addition & 1 deletion examples/pico-sdk/n64-target-cpak/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ add_subdirectory(${LIBJOYBUS_ROOT} ${CMAKE_BINARY_DIR}/_deps/libjoybus-build)
add_executable(n64-target-cpak main.c)

# Link with the standard library and libjoybus
target_link_libraries(n64-target-cpak pico_stdlib pico_rand joybus)
target_link_libraries(n64-target-cpak pico_stdlib joybus)

# Generate additional binary outputs
pico_add_extra_outputs(n64-target-cpak)
2 changes: 1 addition & 1 deletion examples/pico-sdk/n64-target-cpak/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Act as a N64 controller with a Controller Pak on Pi Pico device using the Pico SDK. The controller has no inputs wired up, see the `n64-target` example for those.

The Controller Pak is a single bank held in RAM. It is formatted at boot, so a console sees an empty pak, and its contents are lost on reset.
The Controller Pak is a single bank held in RAM, so its contents are lost on reset.

## Building

Expand Down
8 changes: 2 additions & 6 deletions examples/pico-sdk/n64-target-cpak/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "pico/rand.h"
#include "pico/stdlib.h"

#include <joybus/joybus.h>
Expand All @@ -24,12 +23,9 @@ int main()
// Initialize a N64 controller target as a standard controller
joybus_target_n64_controller_init(&n64_controller);

// Format the pak, since RAM starts empty on every boot
joybus_n64_pak_fs_format(pak_memory, 1, get_rand_32());

// Initialize a single bank controller pak over that memory and plug it into the controller
joybus_target_n64_pak_controller_init(&controller_pak, 1);
joybus_target_n64_pak_controller_set_memory(&controller_pak, pak_memory);
joybus_target_n64_pak_controller_init(&controller_pak);
joybus_target_n64_pak_controller_set_memory(&controller_pak, pak_memory, 1);
joybus_target_n64_controller_attach_pak(&n64_controller, JOYBUS_TARGET_N64_PAK(&controller_pak));

// Attach the target to the bus
Expand Down
116 changes: 0 additions & 116 deletions include/joybus/common/n64_pak_fs.h

This file was deleted.

1 change: 0 additions & 1 deletion include/joybus/joybus.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <joybus/common/gcn_controller.h>
#include <joybus/common/n64_controller.h>
#include <joybus/common/n64_pak.h>
#include <joybus/common/n64_pak_fs.h>
#include <joybus/target.h>
#include <joybus/host/common.h>
#include <joybus/host/gcn.h>
Expand Down
26 changes: 13 additions & 13 deletions include/joybus/target/n64_pak_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
* An original pak is one 32 KB bank, which a console formats and mounts on
* its own. Larger third party paks hold several banks and present one at a
* time, switched by a write to the probe area at 0x8000. A banked pak from
* this target must be formatted with joybus_n64_pak_fs_format() before use.
* this target must already hold a filesystem for that many banks before use.
* A select past the last bank is ignored, which keeps an accessory probe from
* moving the bank but also stops a console counting the banks of a blank pak.
*
* A write to an ID block that names another bank count is refused with a
* transfer error, so the pak cannot be reformatted to a different shape.
*
* @{
*/

Expand Down Expand Up @@ -109,7 +106,7 @@ struct joybus_target_n64_pak_controller {
/// Callback for block written events
joybus_target_n64_pak_controller_written_cb on_written;

/// Banks the pak presents, 1 for an original pak
/// Banks the storage holds, 1 for an original pak
uint8_t banks;

/// Bank the console has selected, always 0 on a one bank pak
Expand All @@ -123,24 +120,25 @@ struct joybus_target_n64_pak_controller {
* joybus_target_n64_pak_controller_set_storage() or
* joybus_target_n64_pak_controller_set_memory().
*
* @param pak the controller pak to initialize
* @param banks how many banks it presents, 1 to ::JOYBUS_N64_PAK_FS_MAX_BANKS, not checked here
* @param pak the controller pak to initialize
*/
void joybus_target_n64_pak_controller_init(struct joybus_target_n64_pak_controller *pak, uint8_t banks);
void joybus_target_n64_pak_controller_init(struct joybus_target_n64_pak_controller *pak);

/**
* Set the storage behind the pak.
*
* For a pak that cannot be held in memory, such as one of many banks kept in
* flash. The callbacks may answer busy while a bank is fetched, which the
* console retries.
* console retries. Setting storage again swaps the pak, which then starts on
* bank 0.
*
* @param pak the controller pak
* @param banks how many banks the storage holds, 1 to 62, not checked here
* @param read callback that reads a block of a bank
* @param write callback that writes a block of a bank
* @param user_data pointer handed back to the callbacks through `pak->user_data`
*/
void joybus_target_n64_pak_controller_set_storage(struct joybus_target_n64_pak_controller *pak,
void joybus_target_n64_pak_controller_set_storage(struct joybus_target_n64_pak_controller *pak, uint8_t banks,
joybus_target_n64_pak_controller_read_cb read,
joybus_target_n64_pak_controller_write_cb write, void *user_data);

Expand All @@ -149,13 +147,15 @@ void joybus_target_n64_pak_controller_set_storage(struct joybus_target_n64_pak_c
*
* The buffer is read and written in place, so persisting it is up to the
* caller, which the written callback helps with. A fresh buffer needs a
* filesystem before a console will mount it, see joybus_n64_pak_fs_format().
* A console can format a one bank pak itself, a banked pak it cannot.
* filesystem before a console will mount it. A console can format a one bank
* pak itself, a banked pak it cannot.
*
* @param pak the controller pak
* @param memory the banks, back to back
* @param banks how many banks the memory holds, 1 to 62, not checked here
*/
void joybus_target_n64_pak_controller_set_memory(struct joybus_target_n64_pak_controller *pak, uint8_t *memory);
void joybus_target_n64_pak_controller_set_memory(struct joybus_target_n64_pak_controller *pak, uint8_t *memory,
uint8_t banks);

/**
* Set the bank select callback for the controller pak.
Expand Down
1 change: 0 additions & 1 deletion libjoybus.slcc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ include:
source:
- path: src/bus.c
- path: src/checksum.c
- path: src/n64_pak_fs.c
- path: src/backend/gecko_sdk/joybus.c
- path: src/host/common.c
- path: src/host/gcn.c
Expand Down
Loading
Loading