From 173aa569c422bb9a06af6d7dd52862d412824cf0 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Sun, 19 Apr 2009 17:00:48 +0000 Subject: [PATCH] add a simple test to try and list contents of an wii SD card git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3006 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/TestSuite/ARAM/ARAM.vcproj | 20 +-- Source/TestSuite/AX/AX.vcproj | 20 +-- Source/TestSuite/EXI/EXI.vcproj | 20 +-- Source/TestSuite/GX/GX.vcproj | 20 +-- Source/TestSuite/PAD/PAD.vcproj | 20 +-- Source/TestSuite/RTC/RTC.vcproj | 20 +-- Source/TestSuite/SI/SI.vcproj | 20 +-- Source/TestSuite/TestSuite.sln | 9 ++ Source/TestSuite/WPAD/WPAD.vcproj | 20 +-- Source/TestSuite/WRTC/WRTC.vcproj | 20 +-- Source/TestSuite/WSD/Makefile | 135 ++++++++++++++++++ Source/TestSuite/WSD/WSD.vcproj | 55 +++++++ .../TestSuite/WSD/source/dolphintest_wsd.cpp | 127 ++++++++++++++++ 13 files changed, 380 insertions(+), 126 deletions(-) create mode 100644 Source/TestSuite/WSD/Makefile create mode 100644 Source/TestSuite/WSD/WSD.vcproj create mode 100644 Source/TestSuite/WSD/source/dolphintest_wsd.cpp diff --git a/Source/TestSuite/ARAM/ARAM.vcproj b/Source/TestSuite/ARAM/ARAM.vcproj index 39cc48d578..765d4d3fcc 100644 --- a/Source/TestSuite/ARAM/ARAM.vcproj +++ b/Source/TestSuite/ARAM/ARAM.vcproj @@ -41,22 +41,14 @@ - - - - - + - + diff --git a/Source/TestSuite/AX/AX.vcproj b/Source/TestSuite/AX/AX.vcproj index a2521c2658..24507f6dfa 100644 --- a/Source/TestSuite/AX/AX.vcproj +++ b/Source/TestSuite/AX/AX.vcproj @@ -41,22 +41,14 @@ - - - - - + - + diff --git a/Source/TestSuite/EXI/EXI.vcproj b/Source/TestSuite/EXI/EXI.vcproj index 15935d7919..519b801133 100644 --- a/Source/TestSuite/EXI/EXI.vcproj +++ b/Source/TestSuite/EXI/EXI.vcproj @@ -62,22 +62,14 @@ - - - - - + - + diff --git a/Source/TestSuite/GX/GX.vcproj b/Source/TestSuite/GX/GX.vcproj index 1ebb5008f5..ef2b628a39 100644 --- a/Source/TestSuite/GX/GX.vcproj +++ b/Source/TestSuite/GX/GX.vcproj @@ -41,22 +41,14 @@ - - - - - + - + diff --git a/Source/TestSuite/PAD/PAD.vcproj b/Source/TestSuite/PAD/PAD.vcproj index f07b7e3186..474929ce47 100644 --- a/Source/TestSuite/PAD/PAD.vcproj +++ b/Source/TestSuite/PAD/PAD.vcproj @@ -41,22 +41,14 @@ - - - - - + - + diff --git a/Source/TestSuite/RTC/RTC.vcproj b/Source/TestSuite/RTC/RTC.vcproj index 31b800261f..1c41e253a0 100644 --- a/Source/TestSuite/RTC/RTC.vcproj +++ b/Source/TestSuite/RTC/RTC.vcproj @@ -41,22 +41,14 @@ - - - - - + - + diff --git a/Source/TestSuite/SI/SI.vcproj b/Source/TestSuite/SI/SI.vcproj index 5fab3699ad..ed7378f7fa 100644 --- a/Source/TestSuite/SI/SI.vcproj +++ b/Source/TestSuite/SI/SI.vcproj @@ -41,22 +41,14 @@ - - - - - + - + diff --git a/Source/TestSuite/TestSuite.sln b/Source/TestSuite/TestSuite.sln index f7ac55233c..1faec53616 100644 --- a/Source/TestSuite/TestSuite.sln +++ b/Source/TestSuite/TestSuite.sln @@ -19,6 +19,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WPAD", "WPAD\WPAD.vcproj", EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WRTC", "WRTC\WRTC.vcproj", "{F75021E3-73BF-425C-BA57-3FE7E2F6E02C}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WSD", "WSD\WSD.vcproj", "{F250A358-225C-4B50-ABAE-5B3D4EC9DC4E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{057B2E90-B8A7-431E-9FA2-68AC8ABABCC5}" + ProjectSection(SolutionItems) = preProject + Makefile = Makefile + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Release|Win32 = Release|Win32 @@ -42,6 +49,8 @@ Global {BB88F4D5-EB0D-4429-94C3-93B0191BD3DD}.Release|Win32.Build.0 = Release|Win32 {F75021E3-73BF-425C-BA57-3FE7E2F6E02C}.Release|Win32.ActiveCfg = Release|Win32 {F75021E3-73BF-425C-BA57-3FE7E2F6E02C}.Release|Win32.Build.0 = Release|Win32 + {F250A358-225C-4B50-ABAE-5B3D4EC9DC4E}.Release|Win32.ActiveCfg = Release|Win32 + {F250A358-225C-4B50-ABAE-5B3D4EC9DC4E}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Source/TestSuite/WPAD/WPAD.vcproj b/Source/TestSuite/WPAD/WPAD.vcproj index 9a8aaa53b2..e46dd8f3fd 100644 --- a/Source/TestSuite/WPAD/WPAD.vcproj +++ b/Source/TestSuite/WPAD/WPAD.vcproj @@ -41,22 +41,14 @@ - - - - - + - + diff --git a/Source/TestSuite/WRTC/WRTC.vcproj b/Source/TestSuite/WRTC/WRTC.vcproj index 81554d35de..3e39e52dcc 100644 --- a/Source/TestSuite/WRTC/WRTC.vcproj +++ b/Source/TestSuite/WRTC/WRTC.vcproj @@ -41,22 +41,14 @@ - - - - - + - + diff --git a/Source/TestSuite/WSD/Makefile b/Source/TestSuite/WSD/Makefile new file mode 100644 index 0000000000..cc2028af36 --- /dev/null +++ b/Source/TestSuite/WSD/Makefile @@ -0,0 +1,135 @@ +#--------------------------------------------------------------------------------- +# Clear the implicit built in rules +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- +ifeq ($(strip $(DEVKITPPC)),) +$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") +endif + +include $(DEVKITPPC)/wii_rules + +#--------------------------------------------------------------------------------- +# TARGET is the name of the output +# BUILD is the directory where object files & intermediate files will be placed +# SOURCES is a list of directories containing source code +# INCLUDES is a list of directories containing extra header files +#--------------------------------------------------------------------------------- +TARGET := $(notdir $(CURDIR)) +BUILD := build +SOURCES := source +DATA := data +INCLUDES := + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- + +CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) +CXXFLAGS = $(CFLAGS) + +LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project +#--------------------------------------------------------------------------------- +LIBS := -lwiiuse -lbte -lfat -logc -lm + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) + +export DEPSDIR := $(CURDIR)/$(BUILD) + +#--------------------------------------------------------------------------------- +# automatically build a list of object files for our project +#--------------------------------------------------------------------------------- +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) + export LD := $(CC) +else + export LD := $(CXX) +endif + +export OFILES := $(addsuffix .o,$(BINFILES)) \ + $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ + $(sFILES:.s=.o) $(SFILES:.S=.o) + +#--------------------------------------------------------------------------------- +# build a list of include paths +#--------------------------------------------------------------------------------- +export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) \ + -I$(LIBOGC_INC) + +#--------------------------------------------------------------------------------- +# build a list of library paths +#--------------------------------------------------------------------------------- +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ + -L$(LIBOGC_LIB) + +export OUTPUT := $(CURDIR)/$(TARGET) +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol + +#--------------------------------------------------------------------------------- +run: + wiiload $(TARGET).dol + + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).dol: $(OUTPUT).elf +$(OUTPUT).elf: $(OFILES) + +#--------------------------------------------------------------------------------- +# This rule links in binary data with the .jpg extension +#--------------------------------------------------------------------------------- +%.jpg.o : %.jpg +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + $(bin2o) + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- diff --git a/Source/TestSuite/WSD/WSD.vcproj b/Source/TestSuite/WSD/WSD.vcproj new file mode 100644 index 0000000000..030e203bdb --- /dev/null +++ b/Source/TestSuite/WSD/WSD.vcproj @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/TestSuite/WSD/source/dolphintest_wsd.cpp b/Source/TestSuite/WSD/source/dolphintest_wsd.cpp new file mode 100644 index 0000000000..8cd2011f04 --- /dev/null +++ b/Source/TestSuite/WSD/source/dolphintest_wsd.cpp @@ -0,0 +1,127 @@ +// Thanks to: +// SD Card Directory Listing Demo +// Updated 12/19/2008 by PunMaster + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +static void *xfb = NULL; + +u32 first_frame = 1; +GXRModeObj *rmode; + +void Initialise() +{ + // Initialise the video system + VIDEO_Init(); + + // This function initialises the attached controllers + PAD_Init(); + + // Obtain the preferred video mode from the system + // This will correspond to the settings in the Wii menu + rmode = VIDEO_GetPreferredMode(NULL); + + // Allocate memory for the display in the uncached region + xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); + + // Initialise the console, required for printf + console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); + + // Set up the video registers with the chosen mode + VIDEO_Configure(rmode); + + // Tell the video hardware where our display memory is + VIDEO_SetNextFramebuffer(xfb); + + // Make the display visible + VIDEO_SetBlack(FALSE); + + // Flush the video register changes to the hardware + VIDEO_Flush(); + + // Wait for Video setup to complete + VIDEO_WaitVSync(); + if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); +} + +void dirlist(char* path) +{ + DIR* pdir = opendir(path); + + if (pdir != NULL) + { + while(true) + { + struct dirent* pent = readdir(pdir); + if(pent == NULL) break; + + if(strcmp(".", pent->d_name) != 0 && strcmp("..", pent->d_name) != 0) + { + char dnbuf[260]; + sprintf(dnbuf, "%s/%s", path, pent->d_name); + + struct stat statbuf; + stat(dnbuf, &statbuf); + + if(S_ISDIR(statbuf.st_mode)) + { + printf("%s \n", dnbuf); + dirlist(dnbuf); + } + else + { + printf("%s (%d)\n", dnbuf, (int)statbuf.st_size); + } + + } + } + + closedir(pdir); + } + else + { + printf("opendir() failure.\n"); + } +} + +int main() +{ + Initialise(); + + if(fatInitDefault()) + dirlist("/"); + else + printf("fatInitDefault() failure.\n"); + + while(1) + { + // Call WPAD_ScanPads each loop, this reads the latest controller states + WPAD_ScanPads(); + + // WPAD_ButtonsDown tells us which buttons were pressed in this loop + // this is a "one shot" state which will not fire again until the button has been released + u32 pressed = WPAD_ButtonsDown(0); + + // We return to the launcher application via exit + if (pressed & WPAD_BUTTON_HOME) + exit(0); + + // Wait for the next frame + VIDEO_WaitVSync(); + } + + return 0; +}