Moved code to dolphin for network

This commit is contained in:
2026-04-18 17:41:30 -05:00
parent 00d94e3015
commit 7dd3940770
14 changed files with 82 additions and 83 deletions
+6 -1
View File
@@ -2,4 +2,9 @@ include(cmake/targets/dolphin.cmake)
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
DUSK_GAMECUBE
)
)
# Link libraries
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
bba
)
+1 -5
View File
@@ -21,11 +21,7 @@ elseif(DUSK_TARGET_SYSTEM STREQUAL "vita")
add_subdirectory(dusksdl2)
add_subdirectory(duskgl)
elseif(DUSK_TARGET_SYSTEM STREQUAL "wii")
add_subdirectory(duskwii)
add_subdirectory(duskdolphin)
elseif(DUSK_TARGET_SYSTEM STREQUAL "gamecube")
elseif(DUSK_TARGET_SYSTEM STREQUAL "wii" OR DUSK_TARGET_SYSTEM STREQUAL "gamecube")
add_subdirectory(duskdolphin)
endif()
+1 -1
View File
@@ -8,7 +8,7 @@
#pragma once
#include "display/mesh/quad.h"
#define SPRITEBATCH_SPRITES_MAX 240
#define SPRITEBATCH_SPRITES_MAX 32
#define SPRITEBATCH_VERTEX_COUNT (SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT)
#define SPRITEBATCH_FLUSH_COUNT 4
#define SPRITEBATCH_SPRITES_MAX_PER_FLUSH (\
+5 -3
View File
@@ -98,6 +98,8 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
ENGINE.argc = argc;
ENGINE.argv = argv;
assertUnreachable("Here fine");
// Init systems. Order is important.
errorChain(systemInit());
timeInit();
@@ -110,7 +112,7 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
errorChain(sceneInit());
entityManagerInit();
physicsManagerInit();
errorChain(networkInit());
// errorChain(networkInit());
errorChain(gameInit());
sceneLog("Init done, going to queue online in 3 seconds...\n");
@@ -170,7 +172,7 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
}
errorret_t engineUpdate(void) {
errorChain(networkUpdate());
// errorChain(networkUpdate());
timeUpdate();
inputUpdate();
@@ -210,7 +212,7 @@ void engineExit(void) {
}
errorret_t engineDispose(void) {
errorChain(networkDispose());
// errorChain(networkDispose());
sceneDispose();
errorChain(gameDispose());
entityManagerDispose();
+2 -2
View File
@@ -8,8 +8,8 @@
#pragma once
#include "dusk.h"
#define ENTITY_COUNT_MAX 64
#define ENTITY_COMPONENT_COUNT_MAX 16
#define ENTITY_COUNT_MAX 6
#define ENTITY_COMPONENT_COUNT_MAX 6
typedef uint8_t entityid_t;
typedef uint8_t componentid_t;
+1
View File
@@ -19,4 +19,5 @@ add_subdirectory(asset)
add_subdirectory(log)
add_subdirectory(display)
add_subdirectory(input)
add_subdirectory(network)
add_subdirectory(system)
+9 -1
View File
@@ -8,4 +8,12 @@
#pragma once
#include <ogcsys.h>
#include <gccore.h>
#include <malloc.h>
#include <malloc.h>
#ifdef DUSK_GAMECUBE
#define CONF_ASPECT_4_3 0
#define CONF_ASPECT_16_9 1
#define CONF_GetAspectRatio() CONF_ASPECT_4_3
#define CONF_GetLanguage() SYS_GetLanguage()
#endif
@@ -5,5 +5,5 @@
target_sources(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
networkwii.c
networkdolphin.c
)
@@ -1,34 +1,36 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
// /**
// * 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);
errorret_t networkDolphinInit() {
// s32 ret = net_init();
// if(ret < 0) errorThrow("Failed to init network stack: %d", ret);
errorOk();
}
errorret_t networkWiiUpdate() {
errorret_t networkDolphinUpdate() {
errorOk();
}
errorret_t networkWiiDispose() {
net_deinit();
errorret_t networkDolphinDispose() {
// #ifdef DUSK_WII
// net_deinit();
// #endif
errorOk();
}
bool_t networkWiiIsConnected() {
bool_t networkDolphinIsConnected() {
return NETWORK.state == NETWORK_STATE_CONNECTED;
}
void networkWiiRequestConnection(
void networkDolphinRequestConnection(
void (*onConnected)(void *user),
void (*onFailed)(errorret_t error, void *user),
void (*onDisconnect)(errorret_t error, void *user),
@@ -74,13 +76,13 @@ void networkWiiRequestConnection(
&NETWORK.errorState,
ERROR_NOT_OK,
__FILE__, __func__, __LINE__,
"Failed to connect to Wii network"
"Failed to connect to network"
);
NETWORK.platform.onFailed(error, NETWORK.platform.onConnectedUser);
}
}
void networkWiiRequestDisconnection(
void networkDolphinRequestDisconnection(
void (*onComplete)(void *user),
void *user
) {
@@ -93,7 +95,7 @@ void networkWiiRequestDisconnection(
onComplete(user);
}
networkinfo_t networkWiiGetInfo() {
networkinfo_t networkDolphinGetInfo() {
networkinfo_t info;
memoryZero(&info, sizeof(networkinfo_t));
@@ -106,7 +108,7 @@ networkinfo_t networkWiiGetInfo() {
&info.ipv4.ip[2],
&info.ipv4.ip[3]
);
assertTrue(ret == 4, "Failed to parse Wii IP address");
assertTrue(ret == 4, "Failed to parse IP address");
return info;
}
}
@@ -10,46 +10,46 @@
#include "network/networkinfo.h"
#include <network.h>
#define NETWORK_WII_IP_MAX 16
#define NETWORK_DOLPHIN_IP_MAX 16
typedef struct {
char_t ip[NETWORK_WII_IP_MAX];
char_t netmask[NETWORK_WII_IP_MAX];
char_t gateway[NETWORK_WII_IP_MAX];
char_t ip[NETWORK_DOLPHIN_IP_MAX];
char_t netmask[NETWORK_DOLPHIN_IP_MAX];
char_t gateway[NETWORK_DOLPHIN_IP_MAX];
void *onConnectedUser;
void (*onConnected)(void *user);
void (*onFailed)(errorret_t error, void *user);
} networkwii_t;
} networkdolphin_t;
/**
* Initializes the Wii network stack via IOS. Does not connect; use
* networkWiiRequestConnection for that.
* networkDolphinRequestConnection for that.
*
* @return Error state (if any).
*/
errorret_t networkWiiInit();
errorret_t networkDolphinInit();
/**
* Called each frame. No-op on Wii since connection is synchronous.
*
* @return Error state (if any).
*/
errorret_t networkWiiUpdate();
errorret_t networkDolphinUpdate();
/**
* Disposes the Wii network stack.
*
* @return Error state (if any).
*/
errorret_t networkWiiDispose();
errorret_t networkDolphinDispose();
/**
* Returns true if the Wii is connected to a network.
*
* @return True if connected.
*/
bool_t networkWiiIsConnected();
bool_t networkDolphinIsConnected();
/**
* Requests the Wii to connect to the network using the Wi-Fi settings saved
@@ -60,7 +60,7 @@ bool_t networkWiiIsConnected();
* @param onDisconnect Callback when connection is later lost.
* @param user User data passed to all callbacks.
*/
void networkWiiRequestConnection(
void networkDolphinRequestConnection(
void (*onConnected)(void *user),
void (*onFailed)(errorret_t error, void *user),
void (*onDisconnect)(errorret_t error, void *user),
@@ -73,7 +73,7 @@ void networkWiiRequestConnection(
* @param onComplete Callback when disconnection is complete.
* @param user User data passed to the callback.
*/
void networkWiiRequestDisconnection(
void networkDolphinRequestDisconnection(
void (*onComplete)(void *user),
void *user
);
@@ -83,4 +83,4 @@ void networkWiiRequestDisconnection(
*
* @return Network info for the active connection.
*/
networkinfo_t networkWiiGetInfo();
networkinfo_t networkDolphinGetInfo();
+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 "networkdolphin.h"
#define networkPlatformInit networkDolphinInit
#define networkPlatformUpdate networkDolphinUpdate
#define networkPlatformDispose networkDolphinDispose
#define networkPlatformIsConnected networkDolphinIsConnected
#define networkPlatformRequestConnection networkDolphinRequestConnection
#define networkPlatformRequestDisconnection networkDolphinRequestDisconnection
#define networkPlatformGetInfo networkDolphinGetInfo
typedef networkdolphin_t networkplatform_t;
+3
View File
@@ -40,6 +40,9 @@ int32_t systemGetAspectRatioDolphin(void);
* Refer to;
* https://github.com/devkitPro/libogc/blob/20d90e944b83c8991538e88b00b1e5f309428e85/gc/ogc/conf.h#L190
*
* On gamecube, refer to;
* https://libogc.devkitpro.org/system_8h.html
*
* @return System language.
*/
int32_t systemGetLanguageDolphin(void);
-18
View File
@@ -1,18 +0,0 @@
# 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)
-19
View File
@@ -1,19 +0,0 @@
/**
* 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;