Version 2.4

Added SMB support
This commit is contained in:
fabio.olimpieri 2011-08-08 11:21:52 +00:00
parent bee0dea293
commit 285d304f01
19 changed files with 568 additions and 293 deletions

View File

@ -1,5 +1,38 @@
TODO: Add ability to select files to load from disks in
a menu
c64-network.org, v2.4:
* Added SMB support
-- Oibaf, fabio.olimpieri@tin.it,
c64-network.org, v2.3:
* Added usb fat support
* Added wiimote rumble support
-- Oibaf, fabio.olimpieri@tin.it,
c64-network.org,v2.2:
* Several bug fixes
* Window zooming
* General preferences saved manually
* Added items in info menu
* Option to emulate joystick with arrows keys
-- Oibaf, fabio.olimpieri@tin.it,
c64-network.org, v2.1:
* Compiled with libogc 1.8.6
* Fix option menu
-- Oibaf, fabio.olimpieri@tin.it,
c64-network.org, v2:
* Fix sound when paused
@ -13,6 +46,8 @@ c64-network.org, v2:
* Fix joystick input on the virtual keyboard
-- Simon Kagstrom simon.kagstrom@gmail.com,
c64-network.org, v1:
* Sound is transferred in network play now

View File

@ -35,7 +35,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lSDL_ttf -lSDL_image -lpng -ljpeg -lz -lSDL -lfreetype -lfat -lwiiuse -lbte -logc -lm -lwiikeyboard
LIBS := -lSDL_ttf -lSDL_image -lpng -ljpeg -lz -lSDL -lfreetype -lfat -lwiiuse -lbte -logc -lm -lwiikeyboard -ltinysmb
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
@ -96,6 +96,7 @@ export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
-I$(CURDIR)/Src \
-I$(PORTLIBS)/include
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------

View File

@ -1009,14 +1009,14 @@ uint8 C64::poll_joystick_buttons(int port, uint8 *table, bool *has_event)
fire_pressed[port]=false;
}
if (((cur_ticks - last_ticks[port] > 150) && rumble_on[port] && !fire_pressed[port]) ||(!cur && (kc == 0x50) && !rumble_on[port] && fire_pressed[port]))
if (((cur_ticks - last_ticks[port] > 120) && rumble_on[port] && !fire_pressed[port]) ||(!cur && (kc == 0x50) && !rumble_on[port] && fire_pressed[port]))
{
WPAD_Rumble(port, false);
rumble_on[port]=false;
fire_pressed[port]=false;
joystickbutton_fire[port]=-1;
}
if ((cur_ticks - last_ticks[port] > 150) && rumble_on[port] && fire_pressed[port])
if ((cur_ticks - last_ticks[port] > 120) && rumble_on[port] && fire_pressed[port])
{
WPAD_Rumble(port, false);
rumble_on[port]=false;

View File

@ -114,8 +114,6 @@ Network::Network(const char *remote_host, int port)
{
const size_t size = NETWORK_UPDATE_SIZE;
this->InitNetwork();
this->is_master = true; /* Assume true */
this->connected = false;
@ -1247,7 +1245,7 @@ void Network::Disconnect()
/* Add a stop at the end of the update */
this->AddNetworkUpdate(disconnect);
this->SendPeerUpdate();
if (!&this->peer_addr) this->SendPeerUpdate();
this->SendServerUpdate();
}

View File

@ -298,7 +298,6 @@ public:
bool is_master; /* Some peers are more equal than others */
void InitNetwork();
void ShutdownNetwork();

View File

@ -90,10 +90,6 @@ void Network::CloseSocket()
close(this->sock);
}
void Network::InitNetwork()
{
/* Do nothing */
}
void Network::ShutdownNetwork()
{

View File

@ -86,19 +86,6 @@ void Network::CloseSocket()
net_close(this->sock);
}
void Network::InitNetwork()
{
char myIP[16];
memset(myIP, 0, sizeof(myIP));
Gui::gui->status_bar->queueMessage("Getting IP address via DHCP...");
if (if_config(myIP, NULL, NULL, true) < 0) {
Gui::gui->status_bar->queueMessage("No DHCP reply");
return;
}
Gui::gui->status_bar->queueMessage("Got an address");
}
void Network::ShutdownNetwork()
{

View File

@ -108,7 +108,7 @@ Prefs::Prefs()
AlwaysCopy = false;
SystemKeys = true;
ShowLEDs = true;
Usbport = false;
Port = PORT_SD;
Rumble = false;
this->SetupJoystickDefaults();
@ -123,6 +123,11 @@ Prefs::Prefs()
this->CursorKeysForJoystick = true;
strcpy(this->Theme, "DEFAULT");
strcpy(SmbUser, "User");
strcpy(SmbPwd, "Password");
strcpy(SmbShare, "Share");
strcpy(SmbIp,"192.168.0.1");
}
@ -314,6 +319,8 @@ bool Prefs::operator==(const Prefs &rhs) const
&& AlwaysCopy == rhs.AlwaysCopy
&& SystemKeys == rhs.SystemKeys
&& ShowLEDs == rhs.ShowLEDs
&& Port == rhs.Port
&& Rumble == rhs.Rumble
&& this->MsPerFrame == rhs.MsPerFrame
&& this->NetworkKey == rhs.NetworkKey
&& this->NetworkPort == rhs.NetworkPort
@ -323,6 +330,10 @@ bool Prefs::operator==(const Prefs &rhs) const
&& strcmp(this->Theme, rhs.Theme) == 0
&& this->NetworkAvatar == rhs.NetworkAvatar
&& this->CursorKeysForJoystick == rhs.CursorKeysForJoystick
&& strcmp(this->SmbUser, rhs.SmbUser) == 0
&& strcmp(this->SmbPwd, rhs.SmbPwd) == 0
&& strcmp(this->SmbShare, rhs.SmbShare) == 0
&& strcmp(this->SmbIp, rhs.SmbIp) == 0
);
}
@ -529,10 +540,20 @@ void Prefs::Load(const char *filename)
strcpy(Theme, value);
else if (!strcmp(keyword, "CursorKeysForJoystick"))
CursorKeysForJoystick = !strcmp(value, "TRUE");
else if (!strcmp(keyword, "Usbport"))
Usbport = !strcmp(value, "TRUE");
else if (!strcmp(keyword, "Port")) {
if (!strcmp(value, "USB")) Port = PORT_USB;
else if (!strcmp(value, "SMB")) Port = PORT_SMB;
else Port = PORT_SD; }
else if (!strcmp(keyword, "Rumble"))
Rumble = !strcmp(value, "TRUE");
else if (!strcmp(keyword, "SmbUser"))
strcpy(SmbUser, value);
else if (!strcmp(keyword, "SmbPwd"))
strcpy(SmbPwd, value);
else if (!strcmp(keyword, "SmbShare"))
strcpy(SmbShare, value);
else if (!strcmp(keyword, "SmbIp"))
strcpy(SmbIp, value);
}
}
fclose(file);
@ -646,8 +667,28 @@ bool Prefs::Save(const char *filename)
maybe_write(file, NetworkRegion != TheDefaultPrefs.NetworkRegion, "NetworkRegion = %d\n", NetworkRegion);
maybe_write(file, strcmp(Theme, TheDefaultPrefs.Theme) != 0, "Theme = %s\n", Theme);
maybe_write(file, CursorKeysForJoystick != TheDefaultPrefs.CursorKeysForJoystick, "CursorKeysForJoystick = %s\n", CursorKeysForJoystick ? "TRUE" : "FALSE");
maybe_write(file, Usbport != TheDefaultPrefs.Usbport, "Usbport = %s\n", Usbport ? "TRUE" : "FALSE");
if (Port != TheDefaultPrefs.Port)
{
fprintf(file, "Port = ");
switch (Port) {
case PORT_SD:
fprintf(file, "SD\n");
break;
case PORT_USB:
fprintf(file, "USB\n");
break;
case PORT_SMB:
fprintf(file, "SMB\n");
break;
}
}
maybe_write(file, Rumble != TheDefaultPrefs.Rumble, "Rumble = %s\n", Rumble ? "TRUE" : "FALSE");
maybe_write(file, strcmp(SmbUser, TheDefaultPrefs.SmbUser) != 0, "SmbUser = %s\n", SmbUser);
maybe_write(file, strcmp(SmbPwd, TheDefaultPrefs.SmbPwd) != 0, "SmbPwd = %s\n", SmbPwd);
maybe_write(file, strcmp(SmbShare, TheDefaultPrefs.SmbShare) != 0, "SmbShare = %s\n", SmbShare);
maybe_write(file, strcmp(SmbIp, TheDefaultPrefs.SmbIp) != 0, "SmbIp = %s\n", SmbIp);
fclose(file);
ThePrefsOnDisk = *this;
return true;

View File

@ -94,7 +94,12 @@ enum {
N_WIIMOTE_BINDINGS
};
// Device Port
enum {
PORT_SD, // Load from SD card
PORT_USB, // Load from USB port
PORT_SMB //Load from network
};
// Preferences data
class Prefs {
@ -155,7 +160,6 @@ public:
bool AlwaysCopy; // Always use a work surface (Win32)
bool SystemKeys; // Enable system keys and menu keys (Win32)
bool ShowLEDs; // Show LEDs (Win32)
bool Usbport; // Load from usb port
bool Rumble; // Enable Rumble for WII
uint32 MsPerFrame;
@ -177,6 +181,12 @@ public:
char Theme[128];
bool CursorKeysForJoystick;
int Port; //SD, USB or SMB
char SmbUser[32];
char SmbPwd[32];
char SmbShare[32];
char SmbIp[32];
};

View File

@ -25,6 +25,7 @@ extern SDL_Surface *screen;
#define METADATA_ROOT_PATH "/frodo/metadata"
#define GAME_ROOT_PATH "/frodo/images"
#define GAME_ROOT_PATH_USB "usb:/"
#define GAME_ROOT_PATH_SMB "smb:/"
#define TMP_ROOT_PATH "/frodo/tmp"
#define SAVE_GAME_ROOT_PATH "/frodo/saves"
#else
@ -109,6 +110,7 @@ Gui::Gui()
this->metadata_base_path = METADATA_ROOT_PATH;
this->game_base_path = GAME_ROOT_PATH;
this->game_base_path_usb = GAME_ROOT_PATH_USB;
this->game_base_path_smb = GAME_ROOT_PATH_SMB;
this->tmp_path = TMP_ROOT_PATH;
this->save_game_path = SAVE_GAME_ROOT_PATH;

View File

@ -130,6 +130,7 @@ public:
const char *theme_base_path;
const char *game_base_path;
const char *game_base_path_usb;
const char *game_base_path_smb;
const char *tmp_path;
const char *save_game_path;

View File

@ -2,6 +2,7 @@
#include "dialogue_box.hh"
extern bool usbismount;
extern bool smbismount;
class KeyboardTypingListener : public KeyboardListener, TimeoutHandler
{
@ -70,7 +71,8 @@ public:
switch (which)
{
case 0: /* Insert disc */
if (Gui::gui->np->Usbport && usbismount) Gui::gui->dv->setDirectory(Gui::gui->game_base_path_usb);
if (Gui::gui->np->Port == PORT_USB && usbismount) Gui::gui->dv->setDirectory(Gui::gui->game_base_path_usb);
else if (Gui::gui->np->Port == PORT_SMB && smbismount) Gui::gui->dv->setDirectory(Gui::gui->game_base_path_smb);
else Gui::gui->dv->setDirectory(Gui::gui->game_base_path);
Gui::gui->pushView(Gui::gui->dv);

View File

@ -123,6 +123,28 @@ const char *select_analogue_dlg[8] = {
NULL
};
const char *network_is_not_init_dlg[8] = {
/*00*/ "Network not initialized!",
/*01*/ "Enable a DHCP and",
/*02*/ "restart Frodo",
/*03*/ "#",
/*04*/ "#",
/*05*/ "#",
/*06*/ "^|OK",
NULL
};
const char *network_bad_ip_dlg[8] = {
/*00*/ "Please enter a valid IP!",
/*01*/ "#",
/*02*/ "#", /* Empty line */
/*03*/ "#",
/*04*/ "#",
/*05*/ "#",
/*06*/ "^|OK",
NULL
};
const char *frodo_help[11] = {
/*00*/ "Welcome to the C64 network!",
/*01*/ "#",
@ -225,8 +247,8 @@ const char *options_menu_messages[15] = {
/*05*/ "^|window|fullscreen",
/*06*/ "Speed (approx. %)",
/*07*/ "^|95|100|110",
/*08*/ "Usb port",
/*09*/ "^|ON|OFF",
/*08*/ "Port",
/*09*/ "^|SD|USB|SMB",
/*10*/ "Rumble",
/*11*/ "^|ON|OFF",
/*12*/ " ",
@ -280,8 +302,8 @@ const char **options_menu_help[15] = {
},
NULL,
(const char*[]){
"Load games from usb port",
"instead of SD card",
"Load games from SD card,",
"USB port or network",
NULL,
},
NULL,
@ -299,7 +321,7 @@ const char **options_menu_help[15] = {
NULL,
};
const char **network_menu_help[9] = {
const char **network_menu_help[15] = {
(const char*[]){
"Setup username to use on",
"the C64 network. Must be",
@ -344,6 +366,29 @@ const char **network_menu_help[9] = {
NULL,
},
NULL,
(const char*[]){
"Set SMB username",
NULL,
},
(const char*[]){
"Set SMB password",
NULL,
},
(const char*[]){
"Set SMB shared folder",
NULL,
},
(const char*[]){
"Set SMB remote IP",
NULL,
},
(const char*[]){
"Connect to the SMB",
"share, or disconnect if",
"you are already connected.",
NULL,
},
NULL,
};

View File

@ -19,12 +19,14 @@ extern const char *network_port_dialogue_messages[];
extern const char *network_unset_name_dlg[];
extern const char *network_need_connection[];
extern const char *network_need_peer[];
extern const char *network_bad_ip_dlg[];
extern const char *broken_theme_dlg[];
extern const char *select_analogue_dlg[];
extern const char *game_info_bad_year_dlg[];
extern const char *game_info_bad_number_dlg[];
extern const char *genre_dlg[];
extern const char *players_dlg[];
extern const char *network_is_not_init_dlg[];
extern const char *save_state_done[];
extern const char *save_prefs_done[];

View File

@ -6,6 +6,51 @@
#include <sysdeps.h>
#include <C64.h>
#ifdef GEKKO
#include <smb.h>
#endif
/****************************************************************************
* Mount SMB Share
****************************************************************************/
extern bool smbismount;
bool ConnectShare ()
{
if(smbismount)
return true;
#ifdef GEKKO
if(smbInit(ThePrefs.SmbUser, ThePrefs.SmbPwd,ThePrefs.SmbShare, ThePrefs.SmbIp))
smbismount = true;
#endif
if(!smbismount) Gui::gui->status_bar->queueMessage("Failed to connect to SMB share");
else {
Gui::gui->status_bar->queueMessage("Established connection to SMB share");
Gui::gui->np->Port = PORT_SMB;
}
return smbismount;
}
void CloseShare(bool silent)
{
if(smbismount) {
if (!silent) Gui::gui->status_bar->queueMessage("Disconnected from SMB share");
#ifdef GEKKO
smbClose("smb");
#endif
}
smbismount = false;
}
extern bool networkisinit;
class NetworkView;
class NetworkMenu : public Menu, public KeyboardListener
@ -48,6 +93,23 @@ public:
else
Gui::gui->np->NetworkPort = v;
} break;
case 9:
strncpy(Gui::gui->np->SmbUser, str, sizeof(Gui::gui->np->SmbUser));
break;
case 10:
strncpy(Gui::gui->np->SmbPwd, str, sizeof(Gui::gui->np->SmbPwd));
break;
case 11:
strncpy(Gui::gui->np->SmbShare, str, sizeof(Gui::gui->np->SmbShare));
break;
case 12:
if (!inet_aton(str, NULL))
{
DialogueBox *error_dialogue = new DialogueBox(network_bad_ip_dlg);
Gui::gui->pushDialogueBox(error_dialogue);
}
else strncpy(Gui::gui->np->SmbIp, str, sizeof(Gui::gui->np->SmbIp));
break;
default:
panic("Cur sel is %d, not possible!\n", this->cur_sel);
break;
@ -57,7 +119,7 @@ public:
virtual void selectCallback(int which)
{
printf("option entry %d selected: %s\n", which, this->pp_msgs[which]);
//printf("option entry %d selected: %s\n", which, this->pp_msgs[which]);
switch (which)
{
case 0:
@ -69,7 +131,8 @@ public:
Gui::gui->pushView(Gui::gui->nrv);
break;
case 4:
if (TheC64->network)
if (!networkisinit) Gui::gui->pushDialogueBox(new DialogueBox(network_is_not_init_dlg));
else if (TheC64->network)
TheC64->network->Disconnect();
else if ( strncmp(Gui::gui->np->NetworkName, "Unset", strlen("Unset")) == 0)
Gui::gui->pushDialogueBox(new DialogueBox(network_unset_name_dlg));
@ -101,6 +164,18 @@ public:
TheC64->TheDisplay->TypeNetworkMessage();
}
break;
case 9:
case 10:
case 11:
case 12:
VirtualKeyboard::kbd->activate();
VirtualKeyboard::kbd->registerListener(this);
break;
case 13:
if (!networkisinit) Gui::gui->pushDialogueBox(new DialogueBox(network_is_not_init_dlg));
else {if (smbismount) CloseShare(false); else ConnectShare();this->updateMessages();}
break;
default:
break;
}
@ -126,22 +201,36 @@ private:
Gui::gui->np->NetworkServer);
snprintf(this->strs[2], sizeof(this->strs[2]) - 1, "Set region (%s)",
region_to_str(Gui::gui->np->NetworkRegion));
snprintf(this->strs[3], sizeof(this->strs[3]) - 1, "Set SMB user (%s)",
Gui::gui->np->SmbUser);
snprintf(this->strs[4], sizeof(this->strs[4]) - 1, "Set SMB psw (%s)",
Gui::gui->np->SmbPwd);
snprintf(this->strs[5], sizeof(this->strs[5]) - 1, "Set SMB folder (%s)",
Gui::gui->np->SmbShare);
snprintf(this->strs[6], sizeof(this->strs[6]) - 1, "Set SMB IP (%s)",
Gui::gui->np->SmbIp);
this->messages[0] = this->strs[0];
this->messages[1] = this->strs[1];
this->messages[2] = this->strs[2];
this->messages[3] = " ";
this->messages[4] = TheC64->network ? "Disconnect" : "Connect to the network!";
this->messages[4] = TheC64->network ? "Disconnect C64 network" : "Connect to C64 network!";
this->messages[5] = " ";
this->messages[6] = "Post network message";
this->messages[7] = "Post peer message";
this->messages[8] = NULL;
this->messages[8] = " ";
this->messages[9] = this->strs[3];
this->messages[10] = this->strs[4];
this->messages[11] = this->strs[5];
this->messages[12] = this->strs[6];
this->messages[13] = smbismount ? "Disconnect from SMB share" : "Connect to SMB share";
this->messages[14] = NULL;
this->setText(this->messages);
}
char strs[3][255];
const char *messages[9];
char strs[7][255];
const char *messages[15];
HelpBox *help;
};

View File

@ -65,7 +65,18 @@ public:
default:
panic("Impossible submenu value: %d\n", this->p_submenus[3].sel);
}
Gui::gui->np->Usbport = !this->p_submenus[4].sel;
switch (this->p_submenus[4].sel)
{
case 0:
Gui::gui->np->Port = PORT_SD; break;
case 1:
Gui::gui->np->Port = PORT_USB; break;
case 2:
Gui::gui->np->Port = PORT_SMB; break;
default:
panic("Impossible submenu value: %d\n", this->p_submenus[4].sel);
}
Gui::gui->np->Rumble = !this->p_submenus[5].sel;
}
@ -89,7 +100,17 @@ public:
submenu_defs[3] = 1; break;
}
submenu_defs[4] = !Gui::gui->np->Usbport;
switch (Gui::gui->np->Port)
{
case PORT_USB:
submenu_defs[4] = 1; break;
case PORT_SMB:
submenu_defs[4] = 2; break;
default:
/* If it has some other value... SD */
submenu_defs[4] = 0; break;
}
submenu_defs[5] = !Gui::gui->np->Rumble;
this->setText(options_menu_messages, submenu_defs);
}

View File

@ -40,12 +40,19 @@
// Global variables
extern int init_graphics(void);
extern void CloseShare (bool silent);
// Global variables
C64 *TheC64 = NULL; // Global C64 object
char AppDirPath[1024]; // Path of application directory
bool usbismount = false;
bool networkisinit = false;
bool smbismount = false;
#ifndef GEKKO
networkisinit = true;
#endif
// ROM file names
#ifndef DATADIR
@ -114,6 +121,21 @@ bool InitUSB()
__io_usbstorage.shutdown();
}
bool InitNetwork()
{
char myIP[16];
memset(myIP, 0, sizeof(myIP));
printf("Getting IP address via DHCP...\n\n");
if (if_config(myIP, NULL, NULL, true) < 0) {
printf("No DHCP reply\n");
return false;
}
printf("Got an address: %s\n",myIP);
return true;
}
#endif
/*
@ -188,7 +210,10 @@ extern "C" int main(int argc, char **argv)
printf("USB FAT subsytem initialized\n\n");
else
printf("Impossible to initialize USB FAT subsytem\n\n");
sleep(3);
networkisinit = InitNetwork();
sleep(4);
//create tmp directory if it does not exist
dir_tmp = opendir("/frodo/tmp");
@ -202,6 +227,8 @@ extern "C" int main(int argc, char **argv)
the_app->ReadyToRun();
delete the_app;
if (smbismount) CloseShare (true);
#ifdef GEKKO
DeInitUSB();
fatUnmount(0);

View File

@ -158,7 +158,7 @@ struct png_write_user_struct
static void user_write_fn(png_structp png_ptr, png_bytep bytes, png_size_t sz)
{
struct png_write_user_struct *out = (struct png_write_user_struct *)png_ptr->io_ptr;
struct png_write_user_struct *out = (struct png_write_user_struct *) png_get_io_ptr(png_ptr);
out->data = xrealloc(out->data, out->sz + sz);
memcpy((uint8_t*)out->data + out->sz, bytes, sz);

View File

@ -2,8 +2,27 @@
<app version="2">
<name>C64-network.org (Frodo)</name>
<coder>Simon Kagstrom</coder>
<version>2.3</version>
<release_date>20110622</release_date>
<version>2.4</version>
<release_date>20110808</release_date>
<short_description>Commodore 64 emulator</short_description>
<long_description>C64-network.org is a networked C64 emulator based on Frodo written by Christian Bauer. It supports C64 disk and tape images in the .d64, .t64 and .prg formats. The port to Wii was done by Simon Kagstrom.</long_description>
<long_description>C64-network.org is a networked C64 emulator based on Frodo written by Christian Bauer. It supports C64 disk and tape images in the .d64, .t64 and .prg formats. The port to Wii was done by Simon Kagstrom.
USAGE
------
Put .t64, .d64, prg or p00 files in /frodo/images on your SD card or in any directory on an usb fat disk.
The in-game menu allows you to insert disks/tapes, load them and configure the display, joystick ports etc.
Saves will be stored on the SD card. You can save and load game state.
When you save the game state also some preferences are saved in the state (joystick buttons, screen format, joystick port, 1541 emulation, rumble).
The whole set of preferences is saved from the main in-game menu and it is loaded on Frodo start-up.
Wiimote 1 is by default the joystick in port 1 and wiimote 2 the joystick in port 2, but you can swap this.
If rumble is enabled, the wiimote rumbles each time the fire button is pressed.
You can also load games from your computer through SMB protocol. You should configure and activate the connection in the network menu.
</long_description>
</app>