Skip to content

Commit deb6357

Browse files
committed
1 parent 31252de commit deb6357

46 files changed

Lines changed: 1173 additions & 1041 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile.menu2_wii

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@ CC =powerpc-eabi-gcc
44
CXX =powerpc-eabi-g++
55
AS =powerpc-eabi-as
66

7-
CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) \
8-
-DCPU_SHUTDOWN -DSPC700_SHUTDOWN -DVAR_CYCLES -DSOUND \
9-
-DNOASM -DNGC -DNOASM -DPIXEL_FORMAT=RGB565 \
7+
CFLAGS = -g -Ofast -Wall $(MACHDEP) $(INCLUDE) \
108
-fno-exceptions -Wno-unused-parameter -pipe \
11-
-DUSE_GUI -DWII -DHW_RVL -DGLN64_GX -DAIDUMP -DUSE_EXPANSION \
12-
-DTHREADED_AUDIO -DUSE_RECOMP_CACHE -DPPC_DYNAREC -DFASTMEM -DMENU_V2\
9+
-DUSE_GUI -DWII -DGLN64_GX -DUSE_EXPANSION \
10+
-DUSE_RECOMP_CACHE -DPPC_DYNAREC -DFASTMEM -DMENU_V2\
1311
-DRELEASE #-DSHOW_DEBUG #-DPRINTGECKO #-DPROFILE #-DDEBUGON #-DUSE_TLB_CACHE \
1412
#-DNO_BT -DUSE_ROM_CACHE_L1 -DPRINTGECKO -DGLN64_SDLOG -DEMBEDDED_FONTS -DUSE_EXPANSION -DSHOW_STATS
1513

16-
MACHDEP = -DGEKKO -mcpu=750 -meabi -mhard-float
17-
LDFLAGS = $(MACHDEP) -mrvl -Wl,-Map,$(notdir $@).map -Wl,--cref
14+
MACHDEP = -DGEKKO -mrvl -msdata
15+
LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref
1816

1917
INCLUDE = -I$(DEVKITPRO)/libogc/include -I$(DEVKITPRO)/libfat/libogc/include
2018
LIBPATHS = -L$(DEVKITPRO)/libogc/lib/wii -L$(DEVKITPRO)/libfat/libogc/lib/wii
@@ -59,6 +57,7 @@ OBJ =main/rom_gc.o \
5957
libgui/MessageBox.o \
6058
libgui/resources.o \
6159
libgui/TextBox.o \
60+
fileBrowser/fileBrowser-SMB.o \
6261
fileBrowser/fileBrowser-DVD.o \
6362
fileBrowser/fileBrowser-CARD.o \
6463
fileBrowser/fileBrowser-libfat.o \
@@ -94,7 +93,8 @@ OBJ =main/rom_gc.o \
9493
main/md5.o \
9594
main/savestates_gc.o \
9695
r4300/profile.o \
97-
main/adler32.o
96+
main/adler32.o \
97+
main/fastmemcpy.o
9898

9999
OBJ_PPC =r4300/ppc/MIPS-to-PPC.o \
100100
r4300/ppc/Recompile.o \
@@ -163,7 +163,7 @@ HEADER =main/rom.h \
163163
r4300/recomp.h \
164164
gc_memory/pif.h
165165

166-
LIB = -ldi -lm -lfat -ldb -lwiiuse -lbte -logc -lz
166+
LIB = -laesnd -ldi -ltinysmb -lwiiuse -lbte -lfat -logc -lz -static
167167

168168
ifeq ($(strip mupen64_GX_gfx/main.cpp),)
169169
export LD := $(CC)
@@ -279,7 +279,7 @@ glN64_GX/F3DWRUS.o: glN64_GX/F3DWRUS.cpp
279279
$(CXX) $(CFLAGS) -D__LINUX__ -D__GX__ -c -o $@ $<
280280

281281
wii64-glN64.elf: $(OBJ) $(OBJ_INPUT) $(OBJ_GLN64_GX) $(OBJ_AUDIO) $(OBJ_RSPHLE) $(OBJ_PPC)
282-
$(LD) $^ $(LDFLAGS) $(LIBPATHS) $(LIB) -Wl -o $@
282+
$(LD) $^ $(LDFLAGS) $(LIBPATHS) $(LIB) -o $@
283283
elf2dol wii64-glN64.elf wii64-glN64.dol
284284

285285
install:

fileBrowser/fileBrowser-SMB.c

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
/**
2+
* WiiSX - fileBrowser-SMB.c
3+
* Copyright (C) 2010 emu_kidid
4+
*
5+
* fileBrowser module for Samba based shares
6+
*
7+
* WiiSX homepage: http://www.emulatemii.com
8+
* email address: emukidid@gmail.com
9+
*
10+
*
11+
* This program is free software; you can redistribute it and/
12+
* or modify it under the terms of the GNU General Public Li-
13+
* cence as published by the Free Software Foundation; either
14+
* version 2 of the Licence, or any later version.
15+
*
16+
* This program is distributed in the hope that it will be use-
17+
* ful, but WITHOUT ANY WARRANTY; without even the implied war-
18+
* ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19+
* See the GNU General Public Licence for more details.
20+
*
21+
**/
22+
23+
#ifdef HW_RVL
24+
25+
#include <string.h>
26+
#include <unistd.h>
27+
#include <malloc.h>
28+
#include <network.h>
29+
#include <ogcsys.h>
30+
#include <smb.h>
31+
#include "fileBrowser.h"
32+
#include "fileBrowser-libfat.h"
33+
#include "fileBrowser-SMB.h"
34+
35+
/* SMB Globals */
36+
int net_initialized = 0;
37+
int smb_initialized = 0;
38+
// net init thread
39+
static lwp_t initnetthread = LWP_THREAD_NULL;
40+
static int netInitHalted = 0;
41+
static int netInitPending = 0;
42+
43+
extern char smbUserName[];
44+
extern char smbPassWord[];
45+
extern char smbShareName[];
46+
extern char smbIpAddr[];
47+
48+
fileBrowser_file topLevel_SMB =
49+
{ "smb:/", // file name
50+
0ULL, // discoffset (u64)
51+
0, // offset
52+
0, // size
53+
FILE_BROWSER_ATTR_DIR
54+
};
55+
56+
void resume_netinit_thread() {
57+
if(initnetthread != LWP_THREAD_NULL) {
58+
netInitHalted = 0;
59+
LWP_ResumeThread(initnetthread);
60+
}
61+
}
62+
63+
void pause_netinit_thread() {
64+
if(initnetthread != LWP_THREAD_NULL) {
65+
netInitHalted = 1;
66+
67+
if(netInitPending) {
68+
return;
69+
}
70+
71+
// until it's completed for this iteration.
72+
while(!LWP_ThreadIsSuspended(initnetthread)) {
73+
usleep(100);
74+
}
75+
}
76+
}
77+
78+
79+
// Init the GC/Wii net interface (wifi/bba/etc)
80+
static void* init_network(void *args) {
81+
82+
char ip[16];
83+
int res = 0, netsleep = 1*1000*1000;
84+
85+
while(netsleep > 0) {
86+
if(netInitHalted) {
87+
LWP_SuspendThread(initnetthread);
88+
}
89+
usleep(100);
90+
netsleep -= 100;
91+
}
92+
93+
while(1) {
94+
95+
if(!net_initialized) {
96+
netInitPending = 1;
97+
res = if_config(ip, NULL, NULL, true);
98+
if(res >= 0) {
99+
net_initialized = 1;
100+
}
101+
else {
102+
net_initialized = 0;
103+
}
104+
netInitPending = 0;
105+
}
106+
107+
netsleep = 1000*1000; // 1 sec
108+
while(netsleep > 0) {
109+
if(netInitHalted) {
110+
LWP_SuspendThread(initnetthread);
111+
}
112+
usleep(100);
113+
netsleep -= 100;
114+
}
115+
}
116+
return NULL;
117+
}
118+
119+
void init_network_thread() {
120+
LWP_CreateThread (&initnetthread, init_network, NULL, NULL, 0, 40);
121+
}
122+
123+
// Connect to the share specified in settings.cfg
124+
void init_samba() {
125+
126+
int res = 0;
127+
128+
if(smb_initialized) {
129+
return;
130+
}
131+
res = smbInit(&smbUserName[0], &smbPassWord[0], &smbShareName[0], &smbIpAddr[0]);
132+
if(res) {
133+
smb_initialized = 1;
134+
}
135+
else {
136+
smb_initialized = 0;
137+
}
138+
}
139+
140+
141+
int fileBrowser_SMB_readDir(fileBrowser_file* ffile, fileBrowser_file** dir){
142+
143+
// We need at least a share name and ip addr in the settings filled out
144+
if(!strlen(&smbShareName[0]) || !strlen(&smbIpAddr[0])) {
145+
return SMB_SMBCFGERR;
146+
}
147+
148+
if(!net_initialized) { //Init if we have to
149+
return SMB_NETINITERR;
150+
}
151+
152+
if(!smb_initialized) { //Connect to the share
153+
init_samba();
154+
if(!smb_initialized) {
155+
return SMB_SMBERR; //fail
156+
}
157+
}
158+
159+
// Call the corresponding FAT function
160+
return fileBrowser_libfat_readDir(ffile, dir);
161+
}
162+
163+
int fileBrowser_SMB_seekFile(fileBrowser_file* file, unsigned int where, unsigned int type){
164+
return fileBrowser_libfat_seekFile(file,where,type);
165+
}
166+
167+
int fileBrowser_SMB_readFile(fileBrowser_file* file, void* buffer, unsigned int length){
168+
return fileBrowser_libfatROM_readFile(file,buffer,length);
169+
}
170+
171+
int fileBrowser_SMB_init(fileBrowser_file* file){
172+
return 0;
173+
}
174+
175+
int fileBrowser_SMB_deinit(fileBrowser_file* file) {
176+
/*if(smb_initialized) {
177+
smbClose("smb");
178+
smb_initialized = 0;
179+
}*/
180+
return fileBrowser_libfatROM_deinit(file);
181+
}
182+
183+
#endif

fileBrowser/fileBrowser-SMB.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* WiiSX - fileBrowser-SMB.h
3+
* Copyright (C) 2010 emu_kidid
4+
*
5+
* fileBrowser module for Samba based shares
6+
*
7+
* WiiSX homepage: http://www.emulatemii.com
8+
* email address: emukidid@gmail.com
9+
*
10+
*
11+
* This program is free software; you can redistribute it and/
12+
* or modify it under the terms of the GNU General Public Li-
13+
* cence as published by the Free Software Foundation; either
14+
* version 2 of the Licence, or any later version.
15+
*
16+
* This program is distributed in the hope that it will be use-
17+
* ful, but WITHOUT ANY WARRANTY; without even the implied war-
18+
* ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19+
* See the GNU General Public Licence for more details.
20+
*
21+
**/
22+
23+
24+
#ifndef FILE_BROWSER_SMB_H
25+
#define FILE_BROWSER_SMB_H
26+
27+
#include "fileBrowser.h"
28+
29+
// error codes
30+
#define SMB_NETINITERR -110
31+
#define SMB_SMBCFGERR -111
32+
#define SMB_SMBERR -112
33+
34+
extern fileBrowser_file topLevel_SMB;
35+
36+
int fileBrowser_SMB_readDir(fileBrowser_file*, fileBrowser_file**);
37+
int fileBrowser_SMB_readFile(fileBrowser_file*, void*, unsigned int);
38+
int fileBrowser_SMB_seekFile(fileBrowser_file*, unsigned int, unsigned int);
39+
int fileBrowser_SMB_init(fileBrowser_file* file);
40+
int fileBrowser_SMB_deinit(fileBrowser_file* file);
41+
42+
void init_network_thread();
43+
void pause_netinit_thread();
44+
void resume_netinit_thread();
45+
46+
#endif
47+

fileBrowser/fileBrowser-libfat.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,30 +186,31 @@ int fileBrowser_libfat_readDir(fileBrowser_file* file, fileBrowser_file** dir){
186186

187187
pauseRemovalThread();
188188

189-
DIR_ITER* dp = diropen( file->name );
189+
DIR* dp = opendir( file->name );
190190
if(!dp) return FILE_BROWSER_ERROR;
191+
struct dirent* ent;
191192
struct stat fstat;
192193

193194
// Set everything up to read
194-
char filename[MAXPATHLEN];
195195
int num_entries = 2, i = 0;
196196
*dir = malloc( num_entries * sizeof(fileBrowser_file) );
197197
// Read each entry of the directory
198-
while( dirnext(dp, filename, &fstat) == 0 ){
198+
while( (ent = readdir(dp)) ){
199199
// Make sure we have room for this one
200200
if(i == num_entries){
201201
++num_entries;
202202
*dir = realloc( *dir, num_entries * sizeof(fileBrowser_file) );
203203
}
204-
sprintf((*dir)[i].name, "%s/%s", file->name, filename);
204+
sprintf((*dir)[i].name, "%s/%s", file->name, ent->d_name);
205+
stat((*dir)[i].name, &fstat);
205206
(*dir)[i].offset = 0;
206207
(*dir)[i].size = fstat.st_size;
207-
(*dir)[i].attr = (fstat.st_mode & S_IFDIR) ?
208+
(*dir)[i].attr = S_ISDIR(fstat.st_mode) ?
208209
FILE_BROWSER_ATTR_DIR : 0;
209210
++i;
210211
}
211212

212-
dirclose(dp);
213+
closedir(dp);
213214
continueRemovalThread();
214215

215216
return num_entries;

0 commit comments

Comments
 (0)