Dolphin compiles, network untested

This commit is contained in:
2026-04-17 22:53:49 -05:00
parent acea610773
commit 1dd2efa182
13 changed files with 316 additions and 4 deletions
+5 -1
View File
@@ -21,7 +21,11 @@ elseif(DUSK_TARGET_SYSTEM STREQUAL "vita")
add_subdirectory(dusksdl2) add_subdirectory(dusksdl2)
add_subdirectory(duskgl) add_subdirectory(duskgl)
elseif(DUSK_TARGET_SYSTEM STREQUAL "gamecube" OR DUSK_TARGET_SYSTEM STREQUAL "wii") elseif(DUSK_TARGET_SYSTEM STREQUAL "wii")
add_subdirectory(duskwii)
add_subdirectory(duskdolphin)
elseif(DUSK_TARGET_SYSTEM STREQUAL "gamecube")
add_subdirectory(duskdolphin) add_subdirectory(duskdolphin)
endif() endif()
+1 -1
View File
@@ -77,4 +77,4 @@ add_subdirectory(time)
add_subdirectory(ui) add_subdirectory(ui)
add_subdirectory(network) add_subdirectory(network)
add_subdirectory(util) add_subdirectory(util)
add_subdirectory(thread) # add_subdirectory(thread)
+1 -1
View File
@@ -127,7 +127,7 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
(vec3){ distance, distance, distance } (vec3){ distance, distance, distance }
); );
componentid_t camCam = entityAddComponent(cam, COMPONENT_TYPE_CAMERA); componentid_t camCam = entityAddComponent(cam, COMPONENT_TYPE_CAMERA);
entityCameraSetZFar(cam, camCam, distance * 6.0f); entityCameraSetZFar(cam, camCam, 100.0f);
// Floor // Floor
entityid_t floorEnt = entityManagerAdd(); entityid_t floorEnt = entityManagerAdd();
+2 -1
View File
@@ -18,4 +18,5 @@ target_sources(${DUSK_BINARY_TARGET_NAME}
add_subdirectory(asset) add_subdirectory(asset)
add_subdirectory(log) add_subdirectory(log)
add_subdirectory(display) add_subdirectory(display)
add_subdirectory(input) add_subdirectory(input)
add_subdirectory(system)
+9
View File
@@ -0,0 +1,9 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
target_sources(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
systemdolphin.c
)
+19
View File
@@ -0,0 +1,19 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "systemdolphin.h"
#include "input/input.h"
#include "util/string.h"
#include "assert/assert.h"
errorret_t systemInitDolphin(void) {
errorOk();
}
systemdialogtype_t systemGetActiveDialogTypeDolphin(void) {
return SYSTEM_DIALOG_TYPE_NONE;
}
+23
View File
@@ -0,0 +1,23 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "system/system.h"
/**
* Initializes the Dolphin system module.
*
* @return Error code indicating success or failure.
*/
errorret_t systemInitDolphin(void);
/**
* Returns which Dolphin system dialog is currently open (if any).
*
* @return Currently open system dialog type.
*/
systemdialogtype_t systemGetActiveDialogTypeDolphin(void);
+12
View File
@@ -0,0 +1,12 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "system/systemdolphin.h"
#define systemInitPlatform systemInitDolphin
#define systemGetActiveDialogTypePlatform systemGetActiveDialogTypeDolphin
+18
View File
@@ -0,0 +1,18 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Includes
target_include_directories(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
# Sources
target_sources(${DUSK_BINARY_TARGET_NAME}
PUBLIC
)
# Subdirs
add_subdirectory(network)
+9
View File
@@ -0,0 +1,9 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
target_sources(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
networkwii.c
)
+19
View File
@@ -0,0 +1,19 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "networkwii.h"
#define networkPlatformInit networkWiiInit
#define networkPlatformUpdate networkWiiUpdate
#define networkPlatformDispose networkWiiDispose
#define networkPlatformIsConnected networkWiiIsConnected
#define networkPlatformRequestConnection networkWiiRequestConnection
#define networkPlatformRequestDisconnection networkWiiRequestDisconnection
#define networkPlatformGetInfo networkWiiGetInfo
typedef networkwii_t networkplatform_t;
+112
View File
@@ -0,0 +1,112 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "network/network.h"
#include "util/memory.h"
#include "assert/assert.h"
errorret_t networkWiiInit() {
s32 ret = net_init();
if(ret < 0) errorThrow("Failed to init Wii network stack: %d", ret);
errorOk();
}
errorret_t networkWiiUpdate() {
errorOk();
}
errorret_t networkWiiDispose() {
net_deinit();
errorOk();
}
bool_t networkWiiIsConnected() {
return NETWORK.state == NETWORK_STATE_CONNECTED;
}
void networkWiiRequestConnection(
void (*onConnected)(void *user),
void (*onFailed)(errorret_t error, void *user),
void (*onDisconnect)(errorret_t error, void *user),
void *user
) {
assertTrue(
NETWORK.state == NETWORK_STATE_CONNECTING,
"Network host should be in a connecting state."
);
NETWORK.platform.onConnected = onConnected;
NETWORK.platform.onFailed = onFailed;
NETWORK.platform.onConnectedUser = user;
memoryZero(NETWORK.platform.ip, NETWORK_WII_IP_MAX);
memoryZero(NETWORK.platform.netmask, NETWORK_WII_IP_MAX);
memoryZero(NETWORK.platform.gateway, NETWORK_WII_IP_MAX);
// Negotiate DHCP using the Wi-Fi settings saved in Wii System Menu.
// This call blocks until the interface is configured or times out.
s32 ret = if_config(
NETWORK.platform.ip,
NETWORK.platform.netmask,
NETWORK.platform.gateway,
true,
20
);
if(ret >= 0) {
NETWORK.state = NETWORK_STATE_CONNECTED;
assertNotNull(
NETWORK.platform.onConnected,
"Network platform onConnected callback should be set."
);
NETWORK.platform.onConnected(NETWORK.platform.onConnectedUser);
} else {
NETWORK.state = NETWORK_STATE_DISCONNECTED;
assertNotNull(
NETWORK.platform.onFailed,
"Network platform onFailed callback should be set."
);
errorret_t error = errorThrowImpl(
&NETWORK.errorState,
ERROR_NOT_OK,
__FILE__, __func__, __LINE__,
"Failed to connect to Wii network"
);
NETWORK.platform.onFailed(error, NETWORK.platform.onConnectedUser);
}
}
void networkWiiRequestDisconnection(
void (*onComplete)(void *user),
void *user
) {
assertTrue(
NETWORK.state == NETWORK_STATE_DISCONNECTING,
"Network host should be in a disconnecting state."
);
NETWORK.state = NETWORK_STATE_DISCONNECTED;
onComplete(user);
}
networkinfo_t networkWiiGetInfo() {
networkinfo_t info;
memoryZero(&info, sizeof(networkinfo_t));
info.type = NETWORK_TYPE_IPV4;
int ret = sscanf(
NETWORK.platform.ip,
"%hhu.%hhu.%hhu.%hhu",
&info.ipv4.ip[0],
&info.ipv4.ip[1],
&info.ipv4.ip[2],
&info.ipv4.ip[3]
);
assertTrue(ret == 4, "Failed to parse Wii IP address");
return info;
}
+86
View File
@@ -0,0 +1,86 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "error/error.h"
#include "network/networkinfo.h"
#include <network.h>
#define NETWORK_WII_IP_MAX 16
typedef struct {
char ip[NETWORK_WII_IP_MAX];
char netmask[NETWORK_WII_IP_MAX];
char gateway[NETWORK_WII_IP_MAX];
void *onConnectedUser;
void (*onConnected)(void *user);
void (*onFailed)(errorret_t error, void *user);
} networkwii_t;
/**
* Initializes the Wii network stack via IOS. Does not connect; use
* networkWiiRequestConnection for that.
*
* @return Error state (if any).
*/
errorret_t networkWiiInit();
/**
* Called each frame. No-op on Wii since connection is synchronous.
*
* @return Error state (if any).
*/
errorret_t networkWiiUpdate();
/**
* Disposes the Wii network stack.
*
* @return Error state (if any).
*/
errorret_t networkWiiDispose();
/**
* Returns true if the Wii is connected to a network.
*
* @return True if connected.
*/
bool_t networkWiiIsConnected();
/**
* Requests the Wii to connect to the network using the Wi-Fi settings saved
* in the Wii System Menu. Blocks until connected or failed.
*
* @param onConnected Callback on successful connection.
* @param onFailed Callback if connection fails.
* @param onDisconnect Callback when connection is later lost.
* @param user User data passed to all callbacks.
*/
void networkWiiRequestConnection(
void (*onConnected)(void *user),
void (*onFailed)(errorret_t error, void *user),
void (*onDisconnect)(errorret_t error, void *user),
void *user
);
/**
* Requests the Wii to disconnect from the network.
*
* @param onComplete Callback when disconnection is complete.
* @param user User data passed to the callback.
*/
void networkWiiRequestDisconnection(
void (*onComplete)(void *user),
void *user
);
/**
* Returns the current network IP information.
*
* @return Network info for the active connection.
*/
networkinfo_t networkWiiGetInfo();