mirror of
https://github.com/Oibaf66/fbzx-wii.git
synced 2024-11-28 11:04:15 +01:00
Added ftp browsing
This commit is contained in:
parent
b534f8cce1
commit
edf251027e
4
Makefile
4
Makefile
@ -17,7 +17,7 @@ include $(DEVKITPPC)/wii_rules
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
TARGET := fbzx
|
TARGET := fbzx
|
||||||
BUILD := build
|
BUILD := build
|
||||||
SOURCES := src src/z80free src/minizip
|
SOURCES := src src/z80free src/minizip src/tinyFTP
|
||||||
DATA :=
|
DATA :=
|
||||||
INCLUDES :=
|
INCLUDES :=
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ dist: $(BUILD)
|
|||||||
cp keymap.bmp $@/fbzx-wii/fbzx
|
cp keymap.bmp $@/fbzx-wii/fbzx
|
||||||
cp ZXSpectrum48k.png $@/fbzx-wii/fbzx
|
cp ZXSpectrum48k.png $@/fbzx-wii/fbzx
|
||||||
cp FreeMono.ttf $@/fbzx-wii/fbzx
|
cp FreeMono.ttf $@/fbzx-wii/fbzx
|
||||||
cp fbzx.smb $@/fbzx-wii
|
cp fbzx.net $@/fbzx-wii
|
||||||
cp AMSTRAD CAPABILITIES COPYING FAQ README README.TZX VERSIONS VERSIONS.wii $@/apps/fbzx-wii/doc
|
cp AMSTRAD CAPABILITIES COPYING FAQ README README.TZX VERSIONS VERSIONS.wii $@/apps/fbzx-wii/doc
|
||||||
touch $@/fbzx-wii/tapes/dummy
|
touch $@/fbzx-wii/tapes/dummy
|
||||||
touch $@/fbzx-wii/snapshots/dummy
|
touch $@/fbzx-wii/snapshots/dummy
|
||||||
|
19
fbzx.net
Normal file
19
fbzx.net
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# SMB configuration
|
||||||
|
# set to 1 to enable smb
|
||||||
|
smb_enable=0
|
||||||
|
user=USER
|
||||||
|
password=PASSWORD
|
||||||
|
share_name=FOLDER
|
||||||
|
smb_ip=192.168.0.1
|
||||||
|
|
||||||
|
# FTP configuration
|
||||||
|
|
||||||
|
ftp_enable=0
|
||||||
|
# WOS
|
||||||
|
FTPUser=anonymous
|
||||||
|
FTPPassword=anonymous
|
||||||
|
FTPPath=/pub/spectrum
|
||||||
|
FTPIp=194.109.216.226
|
||||||
|
FTPPassive=0
|
||||||
|
FTPPort=21
|
||||||
|
|
@ -229,12 +229,19 @@ struct computer {
|
|||||||
unsigned int joybuttonkey[2][22];
|
unsigned int joybuttonkey[2][22];
|
||||||
unsigned char joypad_as_joystick[2];
|
unsigned char joypad_as_joystick[2];
|
||||||
unsigned char rumble[2];
|
unsigned char rumble[2];
|
||||||
unsigned char port; //SD, USB or SMB
|
unsigned char port; //SD, USB, SMB or FTP
|
||||||
unsigned char smb_enable;
|
unsigned char smb_enable;
|
||||||
unsigned char SmbUser[32];
|
unsigned char SmbUser[32];
|
||||||
unsigned char SmbPwd[32];
|
unsigned char SmbPwd[32];
|
||||||
unsigned char SmbShare[32];
|
unsigned char SmbShare[32];
|
||||||
unsigned char SmbIp[32];
|
unsigned char SmbIp[32];
|
||||||
|
unsigned char ftp_enable;
|
||||||
|
unsigned char FTPUser[32];
|
||||||
|
unsigned char FTPPwd[32];
|
||||||
|
unsigned char FTPPath[512];
|
||||||
|
unsigned char FTPIp[32];
|
||||||
|
unsigned char FTPPassive;
|
||||||
|
unsigned short FTPPort;
|
||||||
unsigned char autoconf;
|
unsigned char autoconf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
108
src/emulator.c
108
src/emulator.c
@ -49,6 +49,7 @@
|
|||||||
#include <smb.h>
|
#include <smb.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "tinyFTP/ftp_devoptab.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -82,6 +83,7 @@ static SDL_Surface *image;
|
|||||||
unsigned char usbismount = 0;
|
unsigned char usbismount = 0;
|
||||||
unsigned char networkisinit = 0;
|
unsigned char networkisinit = 0;
|
||||||
unsigned char smbismount = 0;
|
unsigned char smbismount = 0;
|
||||||
|
unsigned char ftpismount = 0;
|
||||||
unsigned char tmpismade = 0;
|
unsigned char tmpismade = 0;
|
||||||
|
|
||||||
extern int FULL_DISPLAY_X; //640
|
extern int FULL_DISPLAY_X; //640
|
||||||
@ -90,6 +92,48 @@ extern int RATIO;
|
|||||||
|
|
||||||
#if defined(GEKKO)
|
#if defined(GEKKO)
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Connect FTP Server
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
unsigned char ConnectFTP ()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (ftpismount) return 1;
|
||||||
|
|
||||||
|
printf("FTPuser: %s\n", ordenador.FTPUser);
|
||||||
|
printf("FTPpass: %s\n", ordenador.FTPPwd);
|
||||||
|
printf("FTPpath: %s\n", ordenador.FTPPath);
|
||||||
|
printf("FTPip: %s\n", ordenador.FTPIp);
|
||||||
|
printf("FTPPort: %d\n", ordenador.FTPPort);
|
||||||
|
printf("FTPpassive: %d\n", ordenador.FTPPassive);
|
||||||
|
|
||||||
|
int a;
|
||||||
|
for (a=0;a<3;a++)
|
||||||
|
if(ftpInitDevice("ftp", ordenador.FTPUser, ordenador.FTPPwd,ordenador.FTPPath, ordenador.FTPIp, ordenador.FTPPort, ordenador.FTPPassive))
|
||||||
|
{ftpismount = 1; break;}
|
||||||
|
|
||||||
|
|
||||||
|
if(!ftpismount) printf("Failed to connect to Server %s\n", ordenador.FTPIp);
|
||||||
|
else {
|
||||||
|
printf("Established connection to Server %s\n", ordenador.FTPIp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return smbismount;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloseFTP()
|
||||||
|
{
|
||||||
|
|
||||||
|
if(ftpismount) {
|
||||||
|
printf("Disconnected from FTP Server %s\n", ordenador.FTPIp);
|
||||||
|
ftpClose("ftp");
|
||||||
|
}
|
||||||
|
ftpismount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Mount SMB Share
|
* Mount SMB Share
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -660,14 +704,15 @@ int save_config_game(struct computer *object, char *filename, int overwrite) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_config_smb(struct computer *object) {
|
void load_config_network(struct computer *object) {
|
||||||
|
|
||||||
char line[1024],carac,done;
|
char line[1024],carac,done;
|
||||||
int pos;
|
int pos;
|
||||||
FILE *fconfig;
|
FILE *fconfig;
|
||||||
unsigned char smb_enable=0;
|
unsigned char smb_enable=0, ftp_enable=0, FTPPassive=0;
|
||||||
|
unsigned int FTPPort=21;
|
||||||
|
|
||||||
fconfig = fopen("/fbzx-wii/fbzx.smb","r");
|
fconfig = fopen("/fbzx-wii/fbzx.net","r");
|
||||||
if (fconfig==NULL) {
|
if (fconfig==NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -723,6 +768,52 @@ void load_config_smb(struct computer *object) {
|
|||||||
|
|
||||||
if (smb_enable<2) {
|
if (smb_enable<2) {
|
||||||
object->smb_enable=smb_enable;}
|
object->smb_enable=smb_enable;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!strncmp(line,"ftp_enable=",11)) {
|
||||||
|
ftp_enable=line[11]-'0';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!strncmp(line,"FTPUser=",8)) {
|
||||||
|
if (line[8])
|
||||||
|
strcpy (object->FTPUser,line+8);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!strncmp(line,"FTPPassword=",12)) {
|
||||||
|
if (line[12])
|
||||||
|
strcpy (object->FTPPwd,line+12);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!strncmp(line,"FTPPath=",8)) {
|
||||||
|
if (line[8])
|
||||||
|
strcpy (object->FTPPath,line+8);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strncmp(line,"FTPIp=",6)) {
|
||||||
|
if (line[6])
|
||||||
|
strcpy (object->FTPIp,line+6);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strncmp(line,"FTPPassive=",10)) {
|
||||||
|
FTPPassive=line[10]-'0';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strncmp(line,"FTPPort=",7)) {
|
||||||
|
sscanf(line, "FTPPort=%d",&FTPPort);
|
||||||
|
if ((FTPPort<1024) && (FTPPort>0))
|
||||||
|
object->FTPPort=FTPPort;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ftp_enable<2) {
|
||||||
|
object->ftp_enable=ftp_enable;}
|
||||||
|
if (FTPPassive<2) {
|
||||||
|
object->FTPPassive=FTPPassive;}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1149,11 +1240,13 @@ int main(int argc,char *argv[]) {
|
|||||||
#ifdef GEKKO
|
#ifdef GEKKO
|
||||||
usbismount = InitUSB();
|
usbismount = InitUSB();
|
||||||
|
|
||||||
load_config_smb(&ordenador);
|
load_config_network(&ordenador);
|
||||||
|
|
||||||
if (ordenador.smb_enable) networkisinit = InitNetwork();
|
if (ordenador.smb_enable||ordenador.ftp_enable) networkisinit = InitNetwork();
|
||||||
|
|
||||||
if (networkisinit && ordenador.smb_enable) ConnectShare();
|
if (networkisinit && ordenador.smb_enable) ConnectShare();
|
||||||
|
|
||||||
|
if (networkisinit && ordenador.ftp_enable) ConnectFTP();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1335,7 +1428,8 @@ int main(int argc,char *argv[]) {
|
|||||||
if (!chdir(path_tmp)) remove_dir(path_tmp); //remove the tmp directory if it exists
|
if (!chdir(path_tmp)) remove_dir(path_tmp); //remove the tmp directory if it exists
|
||||||
|
|
||||||
#ifdef GEKKO
|
#ifdef GEKKO
|
||||||
if (smbismount) CloseShare ();
|
if (smbismount) CloseShare();
|
||||||
|
if (ftpismount) CloseFTP();
|
||||||
DeInitUSB();
|
DeInitUSB();
|
||||||
fatUnmount(0);
|
fatUnmount(0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,7 +41,7 @@ extern char path_poke[2049];
|
|||||||
extern char path_tmp[2049];
|
extern char path_tmp[2049];
|
||||||
extern unsigned int colors[80];
|
extern unsigned int colors[80];
|
||||||
extern unsigned int jump_frames,curr_frames;
|
extern unsigned int jump_frames,curr_frames;
|
||||||
extern unsigned char usbismount, smbismount, tmpismade;
|
extern unsigned char usbismount, smbismount, tmpismade, ftpismount;
|
||||||
|
|
||||||
void SDL_Fullscreen_Switch(void);
|
void SDL_Fullscreen_Switch(void);
|
||||||
void load_rom(char);
|
void load_rom(char);
|
||||||
|
@ -158,7 +158,7 @@ static const char *tools_messages[] = {
|
|||||||
/*08*/ "Load poke file",
|
/*08*/ "Load poke file",
|
||||||
/*09*/ " ",
|
/*09*/ " ",
|
||||||
/*10*/ "Port",
|
/*10*/ "Port",
|
||||||
/*11*/ "^|sd|usb|smb",
|
/*11*/ "^|sd|usb|smb|ftp",
|
||||||
/*12*/ " ",
|
/*12*/ " ",
|
||||||
/*13*/ "Help",
|
/*13*/ "Help",
|
||||||
NULL
|
NULL
|
||||||
@ -939,6 +939,7 @@ static void load_scr()
|
|||||||
|
|
||||||
switch(retorno) {
|
switch(retorno) {
|
||||||
case 0: // all right
|
case 0: // all right
|
||||||
|
strcpy(ordenador.last_selected_file,filename);
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
msgInfo("Error: Can't load that file",3000,NULL);
|
msgInfo("Error: Can't load that file",3000,NULL);
|
||||||
@ -971,8 +972,21 @@ static void save_scr()
|
|||||||
ptr = strrchr (fb, '.');
|
ptr = strrchr (fb, '.');
|
||||||
if (ptr) *ptr = 0;
|
if (ptr) *ptr = 0;
|
||||||
|
|
||||||
|
//If file is taken from FTP, saves file on SD card
|
||||||
|
if (ordenador.port==3)
|
||||||
|
{
|
||||||
|
int length;
|
||||||
|
strcpy(path_scr,getenv("HOME"));
|
||||||
|
length=strlen(path_scr);
|
||||||
|
if ((length>0)&&(path_scr[length-1]!='/')) strcat(path_scr,"/");
|
||||||
|
strcat(path_scr,"scr");
|
||||||
|
dir=path_scr;
|
||||||
|
}
|
||||||
|
|
||||||
// Save SCR file
|
// Save SCR file
|
||||||
snprintf(db, 255, "%s/%s.scr", dir, fb);
|
snprintf(db, 255, "%s/%s.scr", dir, fb);
|
||||||
|
|
||||||
|
if (ordenador.port==3) strcpy(path_scr,"ftp:");
|
||||||
|
|
||||||
fichero=fopen(db,"r");
|
fichero=fopen(db,"r");
|
||||||
|
|
||||||
@ -1017,17 +1031,22 @@ static void set_port(int which)
|
|||||||
case 0: //PORT_SD
|
case 0: //PORT_SD
|
||||||
strcpy(path_snaps,getenv("HOME"));
|
strcpy(path_snaps,getenv("HOME"));
|
||||||
length=strlen(path_snaps);
|
length=strlen(path_snaps);
|
||||||
if ((length>0)&&(path_snaps[length-1]!='/'))
|
if ((length>0)&&(path_snaps[length-1]!='/')) strcat(path_snaps,"/");
|
||||||
strcat(path_snaps,"/");
|
|
||||||
strcpy(path_taps,path_snaps);
|
strcpy(path_taps,path_snaps);
|
||||||
|
strcpy(path_poke,path_snaps);
|
||||||
|
strcpy(path_scr,path_snaps);
|
||||||
strcat(path_snaps,"snapshots");
|
strcat(path_snaps,"snapshots");
|
||||||
strcat(path_taps,"tapes");
|
strcat(path_taps,"tapes");
|
||||||
|
strcat(path_poke,"poke");
|
||||||
|
strcat(path_scr,"scr");
|
||||||
ordenador.port = which;
|
ordenador.port = which;
|
||||||
break;
|
break;
|
||||||
case 1: //PORT_USB
|
case 1: //PORT_USB
|
||||||
if (usbismount) {
|
if (usbismount) {
|
||||||
strcpy(path_snaps,"usb:/");
|
strcpy(path_snaps,"usb:/");
|
||||||
strcpy(path_taps,"usb:/");
|
strcpy(path_taps,"usb:/");
|
||||||
|
strcpy(path_poke,"usb:/");
|
||||||
|
strcpy(path_scr,"usb:/");
|
||||||
ordenador.port = which;}
|
ordenador.port = which;}
|
||||||
else
|
else
|
||||||
msgInfo("USB is not mounted",3000,NULL);
|
msgInfo("USB is not mounted",3000,NULL);
|
||||||
@ -1036,10 +1055,22 @@ static void set_port(int which)
|
|||||||
if (smbismount) {
|
if (smbismount) {
|
||||||
strcpy(path_snaps,"smb:/");
|
strcpy(path_snaps,"smb:/");
|
||||||
strcpy(path_taps,"smb:/");
|
strcpy(path_taps,"smb:/");
|
||||||
|
strcpy(path_poke,"smb:/");
|
||||||
|
strcpy(path_scr,"smb:/");
|
||||||
ordenador.port = which;}
|
ordenador.port = which;}
|
||||||
else
|
else
|
||||||
msgInfo("SMB is not mounted",3000,NULL);
|
msgInfo("SMB is not mounted",3000,NULL);
|
||||||
break;
|
break;
|
||||||
|
case 3: //PORT_FTP
|
||||||
|
if (ftpismount) {
|
||||||
|
strcpy(path_snaps,"ftp:");
|
||||||
|
strcpy(path_taps,"ftp:");
|
||||||
|
strcpy(path_poke,"ftp:");
|
||||||
|
strcpy(path_scr,"ftp:");
|
||||||
|
ordenador.port = which;}
|
||||||
|
else
|
||||||
|
msgInfo("FTP is not connected",3000,NULL);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1421,7 +1452,17 @@ static void save_load_snapshot(int which)
|
|||||||
free((void*)filename);
|
free((void*)filename);
|
||||||
} break;
|
} break;
|
||||||
case 1: // Save snapshot file
|
case 1: // Save snapshot file
|
||||||
|
if (ordenador.port==3) //If file is taken from FTP, saves file on SD card
|
||||||
|
{
|
||||||
|
int length;
|
||||||
|
strcpy(path_snaps,getenv("HOME"));
|
||||||
|
length=strlen(path_snaps);
|
||||||
|
if ((length>0)&&(path_snaps[length-1]!='/')) strcat(path_snaps,"/");
|
||||||
|
strcat(path_snaps,"snapshots");
|
||||||
|
dir=path_snaps;
|
||||||
|
}
|
||||||
snprintf(db, 255, "%s/%s.z80", dir, fb);
|
snprintf(db, 255, "%s/%s.z80", dir, fb);
|
||||||
|
if (ordenador.port==3) strcpy(path_snaps,"ftp:");
|
||||||
retorno=save_z80(db,0);
|
retorno=save_z80(db,0);
|
||||||
switch(retorno)
|
switch(retorno)
|
||||||
{
|
{
|
||||||
|
2967
src/tinyFTP/ftp_devoptab.c
Normal file
2967
src/tinyFTP/ftp_devoptab.c
Normal file
File diff suppressed because it is too large
Load Diff
31
src/tinyFTP/ftp_devoptab.h
Normal file
31
src/tinyFTP/ftp_devoptab.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef _LIBFTF_H
|
||||||
|
#define _LIBFTF_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MAX_FTP_MOUNTED 10
|
||||||
|
|
||||||
|
#ifdef DEBUG2
|
||||||
|
#define NET_PRINTF(fmt, args...) net_printf(fmt, ##args)
|
||||||
|
#define NET_ASSERT(x) assert(x)
|
||||||
|
#else
|
||||||
|
#define NET_PRINTF(fmt, args...) do{}while(0)
|
||||||
|
#define NET_ASSERT(x) do{}while(0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//devoptab
|
||||||
|
bool ftpInitDevice(const char* name, const char *user, const char *password,
|
||||||
|
const char *share, const char *hostname, unsigned short port,
|
||||||
|
bool ftp_passive);
|
||||||
|
void ftpClose(const char* name);
|
||||||
|
bool CheckFTPConnection(const char* name);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _LIBFTF_H */
|
Loading…
Reference in New Issue
Block a user