Compare commits

...

2 Commits

Author SHA1 Message Date
rameonweb f26bf18ebf *add SendElf to the WL installer for large WAD files
*add extra context for wad files (Send to Wii [SendElf])
2009-08-02 22:34:06 +00:00
dimok321 38ff283e3d *Fix for Language Download Button (SubFolderCreation which fixes codedump when folder is not available)
*Moved WiiLoad Installer to branches
2009-08-01 06:40:47 +00:00
394 changed files with 426 additions and 72938 deletions

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<app version="1">
<name>USB Loader GX</name>
<coder>dimok nIxx cyrex giantpune Hungyip84 NeoRame WiiShizzza ardi</coder>
<version>1.0</version>
<release_date>20090118030000</release_date>
<short_description>Loads games from USB-devices</short_description>
<long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times. The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller. Features are automatic widescreen detection, coverdownload, parental control, theme support and many more.</long_description>
</app>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

View File

@ -1,401 +0,0 @@
__,,__, ,__wywyywvyyyyywvywvyam,,_, _,,_
_uWB&#MBM$Wg&MQ$#$K&RMKMA0$&xNH&&MN@2W&#MM&#$KQg
JN&B&MM#MQ$gM#Q$N#R&&#N$M$#&#0E$##V$WKG###B&$&NW#b
j8W0##&M$W&$###&#0##&$0MN#BX&5&#$xA$A$#$#&#z$MNQWK#L
3#$$& N$&WK& XN#$&~~ ^VM#&#A~`^`"~^~"'K###2$M
SQN$# 9MB#@) $$$# ***, $&mR _,_ NU#$M
&0N## #M$$M# NA4 ****** *$g# *0$Q&H! ]$N$#
M\w&F ##&#@$ #W8- ~v"&N8&*#$# 0QB#&$& !#&$K
$QNNC E&M$0# g&&&_ "*$&QM #$MN$#
j$$0L $M@WWK #W&#M&k,,_ ~&$$ _,_ $NQN(
i&M4( N$K2## M#NNF$&####& 0#$ *0$Q&H! W#$(
j$B#N V&#AMS SRW $8$0M& 3M$ 0QB#&$& #N$I
jQ0&NL ""^ JB&ML '~^ jQ*A ` j##KF
K#$##& _#B#WNKM_ ,vB&#M _ _wp#&QAF
"&NAQAN&#$&MW#&###B#x$3@&$BA#WWWH$#KMM&K&NK###g&$#
*WN$&$$8QWNMMM#MM&<&A#&M$K&#WK@QM5#&*A$N&$&WM#@2
"M*^&N##&$W8$2B#&MB&DWR0#$$0#W>&&M$#QQMN#&""
\eeee6 F**A1
jM0$e4 ?**G\!
imw{Q- x%%%m \%z%%e mxx _%*%@& -ve/v mmm\ wvm
V3Q%m& /#0^0E&~/&\ $&E/&%1e^"E 55t7JcVsm0-\ &^#l@&}&-" $7MAE&&%/
$%x/z Wc&&t7-w&E4^ %VVM~1^\&$&&} e$&$$%$zQMxw w-v-#^ Q\W44 %-/%/\QS
et-SC e^00^ iF&E$- !%%$$%A*v 5^^4 EEZ/0 )%%0%4fimmEt" "$S8V
(WJ^%i m&MM#} /%\%%L 4Q\w WQ/Q\ &m<wS \v"v1 \74~1zM%&%/6s wEw//
&ssSs?s%wt&&-~~MM#& e1/'m% &5^jW &mw&\ SmVw^ S1&mw \^A5FE j7F*5, ~S3m%
j3Q"/&-&w&M%& ^^4$w^7QSQ@ t&&&%-"5w&E} e8"&&&&/%\W &5%1\%V*\0M &&7M
~?VW^$ ?&\81? ?mQ&&&- 00%%^~EE4E \&00 ^M43^ ^'"#5&$-^ ~wEE}
__ ,_
__ggggggggggggggg& jggggg#p gMMMMMMM
&MMMMMMMMMMMMMMMMMMF "MMMMMMM& j#MMMMMMP
#MMMMMMMMMMMMMMMMMMMF #MMMMM&g#MMMMMMP
#MMMMMF "MMMMMMMMMMM#^
#MMMMML pgppggggggp $MMMMMMMMF
$MMMMML 4#M#NRMMMMMF jMMMMMMMMMQ
$MMMMMF #MMMMF pMMMMMMMMMMMMp
4MMMMMMNNN#MMMMMMMMMF jMMMMMMF MMMMMM&_
MMMMMMMMMMMMMMMMMM& #MMMMM@~ ~MMMMMM&
"""""""""""""""" """""" """"""^
Congratulations. You are the proud Beta Tester for USB Loader GX. That's right. Beta Tester. That means that you are using Beta software. This program is still under heavy development. Not everything works perfectly. If you are expecting it to, stop and look else where. Some of the features covered here may be removed in your version of the application. And likewise, there may be features in your revision that are not covered here.
By using a Beta revision, you are agreeing to not be an idiot. Most of the features should be self explanatory. The rest of them can be figured out by clicking around a trying stuff out. There is no button or combination of buttons that you can click that will brick your wii or make irreparable changes to your wii so please try out all the features to see which options need to be enabled for your wii/tv/game combination.
This was written 6/15/2009 regarding revision 525
Official site
http://code.google.com/p/usbloader-gui/
changelog
http://code.google.com/p/usbloader-gui/source/list
sourcecode checkout
http://usbloader-gui.googlecode.com/svn/trunk/
game compatibility chart
http://wiki.gbatemp.net/wiki/index.php/USB_Loader_v1.x_Game_Compatibility
Other crap that you may find useful is here
http://usbloadergx.koureio.net/help
[1]prerequisites
[1a]files & paths
[2]usage
[3]adding games
[4]main menu
[4a]controls
[4b]Buttons & shit
[4c]view
[4d]game info
[4e]game prompt
[5]exit menu
[6]settings
[6a]gui settings
app language
display
clock
tooltips
flipx
prompts/buttons
keyboard
wiilight
rumble
unicode fix
titles from xml
[6b]game load
video mode
vidTVpatch
language
patch country strings
ocarina
boot/standard
quick boot
error 002fix
[6c]parental control
console
password
control level
[6d]sound
background music
music volume
SFX volume
[6e]custom paths
[6f]update
[6g]default settings
[6h]credits
[7]game settings
video mode
vidTV patch
language
ocarina
ios
parental control
error002 fix
online fix
patch country strings
default settings
alternate dol
The ocarina button
[8]Themes
[9]Cheatmanager
[10]Troubleshooting
###################################################################################
[1]Prerequisites and setup
To use this application, you will need a Wii that has been hacked and is able to run homebrew software. DO NOT ASK US HOW TO HACK YOUR WII. THERE ARE THOUSANDS OF TUTORIALS FOR THIS. You will need to have any 1 or more of cIOS 249rev9 or greater, cIOS222, or cIOS 223. There are advantages and disadvantages for each of the different cIOS. It is up to you to research and decide which one you want to use. It is also up to you to know about the bugs which are known bugs of the cIOS.
For the initial setup you will need to use a PC to format a USB drive to either FAT or NTFS. If you are going to use the USB device to store other data for this application besides games (images, settings, ect) now will be a good time to create a Secondary partition. 1gb is plenty for the second partition for what we are going to use it for. The second partition should be FAT (FAT32 /16 should work fine as well). Mark your partitions primary and active and if you want your PC to be able to interact with this drive, assign it a drive letter.
Now plug your drive into your wii and use your desired method of booting homebrew to launch our application. If everything was done right, you will be prompted to format your main partition to WBSF to use with this loader. Just follow the instructions on screen.
[1a]Files & paths
There are other files that are not necessary to the core functionality of this loader, but are used for extra features. The dev team have defined the following paths, most of which are configurable in the settings.
SD:/config/ this is where the application will create files to save settings and statistics. All the files it makes start with GX to make them easy to find. GxGlobal.cfg is the main settings and configuration for the loader. GXGameFavorites.cfg contains individual settings for games. GXGameCount.cfg stores the game play count and favorites choices. Also in this folder you can put a file called titles.txt to change the names of the games as seen in the loader if you are too much of a pussy to edit them directly on the WBFS filesystem. A database of information about each game can be stored in this folder as well. Get you hands on wiitb.zip (which contains wiitdb.xml) and put it here.
SD:/images/ This is where box art is downloaded to and displayed from. All images must be sized in multiples of 4 or they won't show up.
SD:/images/disc/ This is where pictures of the actual game discs are downloaded to and displayed from. All images must be sized in multiples of 4 or they won't show up.
SD:/config/backgroundmusic/ This is the default folder for custom bg music.
SD:/theme/(SD:/wtheme for widescreen wii) This is the default theme location.
SD:/codes/ This is the folder to put your gct cheat files. These fiiles should be named wich the 6 character ID of the game they are meant for.
SD:/txtcodes/ This is the folder to put your txt cheat files. They should be in the standard format for homebrew/ocarina. Some examples are available in the downloads section at the googlecode URL above.
SD:/ This is where replacement dols used to fix certain broken games go.
###################################################################################
[2]Usage
Using this application is simple. Launch it in the same manner that you did in the initial setup, pick a game (if you have any installed), and play the game. This is open source software. You are free to modify it, distribute it, and do anything you want with it. All we demand is that you do not claim our work as yours. We worked long and hard on this and let you use it for free. It would be a real bitch move if you put your name on it and said it was your own. You are also free to distribute the software/source code as you like as long as this file (or a similar one approved by the dev team) companies it. If you don't follow these guidelines, you are a douche-bag.
###################################################################################
[3]Adding games*****
To add a game to your drive using this program, click the install(+) button on the main screen and follow the on screen prompts. Games are automatically scrubbed (shrunk) and brickblocked (update partition removed) when adding them to the drive. Because of the way WBFS and the application work, you are only allowed to install 1 game for each game ID. If you do use another application to install 2 games with the same 6 character ID, only the first one one the drive will be loaded by our program. If the installation freezes ( doesn't move for over 2 minutes) you can simply hold the power button on the Wii to turn it off. There is no danger of bricking your wii. The data that was written during the failed install is still present on the drive, but not marked as active so it will be treated as free space. It does not get added into the used space displayed on the screen and it will overwritten next time you install a game.
###################################################################################
[4]main menu
This is the main screen, the first one you see when you start the program. It looks a lot like the Wii system menu.
[4a]controls
User input for the main menu is accepted through WiiMote, nunchuk, gamecube controller, and classic controller. While input is accepted from all these methods, the fastest and easiest method is with a WiiMote. Just point to the screen and click on shit. A is the main action button. B (for the most part) is back/cancel. The D-pad is used to highlight different options. Press 2 to view game info (with the xml file listed above in place).
[4b]Buttons & shit
Install--***** The + button in the lower left corner of the screen. Press to add games to your HDD from the Wii's DVD drive.
Settings-- The gear button to the right of the install button. Use it to access all the settings and options.
Exit-- The button in the lower right corner that says "wii". Press this to view the exit menu.
Power-- The button furthest to the right in the lower corner. I bet you can figure out what it does.
Download--***** When you are in the list view, click a game box to download stuff.
Reload-- This button looks like an SD card. Press it to reload your SD contents.
Sort bar--
Favorites-- the star button. Press it to hide all games that are not marked as a favorite.
Abc-- the button that says "ABC". Press it to sort games alphabetically.
Count-- the chart button. Press it to sort games by the number of times you have launched them from this application.
Games with the same count are sorted alphabetically.
List-- Press it to see games listed by name and any available box art for 1 game at a time.
Grid-- Press this button to see your games arranged in a grid. The number of rows available depends on how many games are on you drive. 39 games can be seen at the most.
Carousel-- Press this to see you games arranged in a rotating fan array. 7 games can be seen at a time.
clock-- This looks like a clock. Coincidently, it functions like a clock.
Hdd Info-- This shows some information about your connected HDD (only the WBFS partition). Free & total space in GB as well as the game count. GB is defined here as 1024MB. When you bought your drive, the manufacturer probably used 1000MB for GB so the size displayed here will be less than what your drive was advertised as. The game count will reflect the games you are choosing to display, not the actual amount of games on your drive. If you are hiding games with parental controls/favorites, they will not be added into this total.
[4c]view
There are 3 different ways to view your games.
List-- Games are listed by name (up to 9 at a time) box art for the selected game is displayed. This is currently the only screen you can initiate a download for artwork from. Also on this screen The B button has a slightly different use. If there are scrollbars present on your gamelist, holding B and moving the cursor scrolls the list.
grid-- Games are aranged in a grid (up to 320). The number of rows available depends on how many games are on you drive. By default, it is 3X14 (with the last column hidden)if there arent enough games to fill all 42 spots, it changes to 2x8 (2x7 shown on screen). Again, if there arent enough games to fil it up, the number of rows decreases. Currently there is no 4/3 support for this view.
carousel-- Games are arranged in a rotating fan array (up to 320). 7 games can be seen at a time.
[4d]Game Info
Pressing 2 (or x on GC an CC input) brings a prompt with information about the selected game. This info is read from the zipped xml file discussed earlier. Among the displayed information are the following:
Accessories-- the supported accessories for the game are shown in the lower left. The max number of players is shown on the image of the WiiMote. Any required accessories are shown in light blue.
Rating system-- the rating for the game is shown in the lower left of the screen. It is converted internally between PEGI,ESRB, and CERO( though not used for anything yet).
Wifi Shit-- the number of online players is displayed to the right of the accessories. Any other wifi features are listed above the accessories.
synopsis-- if a synopsis is present in the xml file, it can be viewed by pressing A on the game info screen.
[4e]Game Prompt
This is the prompt that comes up when a game is selected (if the quickboot option is not selected).
settings-- brings up a menu of settings for this game only
play-- Click the spinning disc to launch this game
rename--***** Click the title of the game in the top of the prompt to rename it directly on the WBFS file system. If you are using titles.txt or letting the XML rename the games, this will have no (visible) effect.
back-- closes this prompt
favorite-- Click the star to add/remove this game from your favorites.
size-- the amount of space that the game ocupies on the WBFS filesystem
count-- the number of times you have launched this game from this application
settings--*****Here is where you go to enter settings that will be used for this game only.
###################################################################################
[5]Exit Menu
This is the screen that appears when you press the home button on the WiiMote or the exit button in the main screen.
return to loader-- if you launched USB Loader GX from HBC, LoadMii, or similar chain loading application, you will see this button. Pressing it will take you back to the application that you came from.
Wii Menu-- exits to the Wii System Menu
batteries-- Status for all connected WiiMotes is displayed here
close-- closes this screen and returns you to where you were in the application before this screen was called
###################################################################################
[6]settings
This is where you customize the behavior of the program.
[6a]Gui settings
These are the settings that affect the behavior and feel of the GUI. Your settings are saved when exiting back to the main screen, change custom paths, change views in the main screen, and a few other times.
app language-- *****If you have a language file to translate this program, you can select it here. You can change the path by clicking it at the top of the screen. The button in the lower right will restore the defualt (english).
display-- In the list view, you can chose to display the selected game's region and ID here.
clock-- Chose how you want the clock displayed.
tooltips-- enable tooltip help with this.
flipx-- this changes the behavior of left and right on the gameprompt. if it feels un-natural, change this setting.
prompts/buttons-- Select weather or not to apply the widescreen fix to prompt windows and certain buttons in the GUI.
keyboard-- Chose between different layouts for the on screen keyboard used in the GUI.
wiilight-- Change the behavior of the disc slot light.
rumble-- turn rumble on/off
unicodefix-- Use this only if you have compiled the application with a Chinese,Japanese, etc font that does not display correctly.
titles from xml-- chose if you want to ignore the titles stored on the xml file and use the ones stored in the WBFS.
[6b]Gameload
Change settings that have to do with the way games are booted. These will be use as default if you don't set any spacific settings for that game.
videomode-- select the video mode use for games. Most games work with disc default. If this doesn't work, then try console default. Then if you still need to, try forcing your region.
vidTVpatch-- patches the signal after the game has rendered it in the mode selected in videomode. If none of the video modes work then try this.
language-- the language that is passed to the game when it is booted. if the language is supported by the game, it will be used in game.
patch country strings-- use this for Japanese games playing imports.
ocarina-- turn on/off the ocarina cheat engine. You need gct files in the cheatcode path mentioned earlier.
boot/standard-- *****Select the cIOS that is used to boot the program into.
quickboot-- Chose if you want to skip the gameprompt when starting games.
error 002fix-- with certain IOS, some games show an error that says "blablabla, 002, blablabla. Don't be a pirate." Turn this on to fix it. For certain games running under older cIOS versions, you will need to set this to anti for the games to boot.
[6c]Parental control
Settings for parents to control what content their kids see. Everything in this file with ***** beside it is hidden when the application is locked.
console--***** click here to lock/unlock advanced features.
password-- *****click here to set a password.
control level--***** set the level of parental control here. games will be excluded from the game list based on this and the settings you have for them in the game-specific settings.
[6d]sound
Settings related to audio are here
background music-- You can chose custom BG music to be heard in the application here. Click the path at the top to change it. Format is OGG. Keep in ming that bigger songs will result in decreased memory available for other functions. It is possible to completely crash the loader with big files. Try to keep it <3MB to be safe. If you want to rock out to your music, use a media player. This is a game loader.
music volume-- pick the volume for the BG music within this application, not in the games that are booted.
SFX volume-- Pick the volume for the sound effects within this application, not in the games that are booted.
[6e]Custom paths*****
Some of the paths the program uses are customizable. All paths should start with "SD:/" or "USB:/" (without quotes). USB paths will be on the first available FAT USB partition.
covers-- *****for boxart
discimage--***** for DVD art
themepath--*****for theme shit
titles.txt--*****for title.txt and wiitdb.zip
update--***** used for updating the dol. If you are using our forwarder, it loads dols from this path.
cheatcodes-- *****for gct & ocarina use
txtcheat path-*****for txt files holding the codes for your gams.
dolpath—*****for replacement dols for certain broken games.
[6f]Update*****
Click to get updates from online. Just because there is a newer revision than what you are using does not mean that it will be on the update server. Also, you get the choice to update your dol or the entire HBC package. If you are using a full channel (not a forwarder channel), you won't get the option to update all. It will just download a wad file and install that on your wii over top of the old version and then kick you out to the system menu so you can restart with the new version. This is assuming that the person that created the channel took the necessary steps when they made it. If you are using the full channel and you get the option to update all, then they fucked up and the update will do you no good.
[6g]default settings*****
Click here to restore default settings.
[6h]credits
Look at the people that made this application possible. You get to rock out to some cool music, too. In the upper right corner is displayed your rev# and the cIOS that your are currently running.
###################################################################################
[7]gamesettings
Settings are available on a per-game basis from the prompt window. These settings have the same effect as the global settings but are only used for the selected game. After making changes, you must click the save button for them to take effect.
videomode
vidTV patch
language
ocarina
ios
parental control
error002 fix
online fix --if you have attempted to use any online features of this application, the online features of any game you boot will not work. In order to fix this we can reload the IOS. Unfortunately, reloading IOS results in random blackscreens with certain IOS versions. Turn this option on to reload the IOS and risk random black screens.
patch country strings
alternate dol-- this is for advanced users only. There are certain games which do not run because they they reload IOS and this causes the USB to be dropped. If you extract the proper dol from the ISO and name it with the 6 character game ID and put in the dolpath, you can use enable this option to play these games.
default settings-- delete any saved settings for this game. After you press this, there is no need to press save.
save-- writes the settings that are on the screen right now to the GXGameSettings file with the current game ID
uninstall-- Delete the selected game from the WBFS table. The data is not erased from the drive, it is just marked as free space.
back-- Lose any unsaved changes and return to the previous screen.
ocarina button-- this is that blue thing in the upper right. If you have a txt file for the selected game in the txtcheat folder, click this button to go to the code selection page. You will see a list of the cheats in the txt file and you can turn them on and off. When you are happy with the codes you have selected, click the button to generate a gct file. This will make a gct file with only the codes that are turned on and put it in the proper folder. Then make sure you turn ocarina on or your cheats won't be used.
###################################################################################
[8]Themes
Is it possible to theme this program. Theme elements may include font, images, sounds, and GXtheme.cfg. If anything is not included in the theme path, the default will be used. For image names, look in the source. Not every image can be themed, but this is a good place to look for the names of the ones that can be. All images must be sized in multiples of 4 or they will not be displayed. To move elements of the gui around, you can use GXtheme.cfg. I template can be found here http://code.google.com/p/usbloader-gui/wiki/ThemeSettings. For More accurate list of themable elements, look in cfg.c from the source
###################################################################################
[9]Cheatmanager
The Cheatmanager makes it possible to directly convert TXT Cheat Codes files into GCT for Ocarina.
You can find the Cheatmanager in the Game Settings (click on the Ocarina Icon) select the Cheat you want to use and create the GCT file.
The TXT Files should look like this
GameID
GameTitle
Cheat1
*here the hexvalues*
Comment (actually only one line of comment is supported otherwise the GCT file will be messed up)
Cheat2
*here the hexvalues*
Comment
Cheat3
and so on
###################################################################################
[10]Troubleshooting
I get black screen when loading games.
check the game compatibility list, unhook extra controllers, turn off ocarina, play with video settings. If the list says the game works, then try different video settings if the game is not from the same region as your tv/wii.
Also try without ocarina. Unless you made the codes yourself, you don't know that they work. And you don't know which codes work together. Using codes from a different region will also fuck shit up.
Some games don't like it if you have certain controllers plugged in. Remove GC & CC controllers and try again.
If all else fails, rip the game again. It may have gotten messed up in the process.
I get a black screen with a bunch of numbers on it
This is a code dump. It is not bad for your wii. It just means that the program crashed. This is beta software, it happens. Different revs can have this happen at certain times. Just press reset on your wii. If you find that this happens every time you start the application, rename your config folder and restart it. This will cause the loader to use default settings. If it fixes the problem then you can copy the game settings and favorites files back into the config directory.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

182
Makefile
View File

@ -1,182 +0,0 @@
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>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 := boot
BUILD := build
SOURCES := source source/libwiigui source/images source/fonts source/sounds \
source/libwbfs source/unzip source/language source/mload source/patches \
source/usbloader source/xml source/network source/settings source/prompts \
source/ramdisc source/wad source/banner source/cheats source/homebrewboot
DATA := data
INCLUDES := source
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -g -O2 -save-temps -Wall $(MACHDEP) $(INCLUDE)
CXXFLAGS = -Xassembler -aln=$@.lst $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x8090a000
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lfat -lpngu -lpng -lm -lz -lwiiuse -lbte -lasnd -logc -lfreetype -ltremor -lmxml
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(DEVKITPPC)/lib $(CURDIR)
#---------------------------------------------------------------------------------
# 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 PROJECTDIR := $(CURDIR)
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(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
#---------------------------------------------------------------------------------
SVNREV := $(shell bash ./svnrev.sh)
export CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
export 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)/*.*)))
TTFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ttf)))
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
OGGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ogg)))
PCMFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pcm)))
#---------------------------------------------------------------------------------
# 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) \
$(TTFFILES:.ttf=.ttf.o) $(PNGFILES:.png=.png.o) \
$(OGGFILES:.ogg=.ogg.o) $(PCMFILES:.pcm=.pcm.o)
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(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:
make
@echo Done building ...
@echo Now Run That Shit ...
wiiload $(OUTPUT).dol
#---------------------------------------------------------------------------------
reload:
wiiload -r $(OUTPUT).dol
#---------------------------------------------------------------------------------
release:
make
cp boot.dol ./hbc/boot.dol
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf language
$(OUTPUT).elf: $(OFILES)
language: $(wildcard $(PROJECTDIR)/Languages/*.lang)
#---------------------------------------------------------------------------------
# This rule links in binary data with .ttf, .png, and .mp3 extensions
#---------------------------------------------------------------------------------
%.ttf.o : %.ttf
@echo $(notdir $<)
$(bin2o)
%.png.o : %.png
@echo $(notdir $<)
$(bin2o)
%.ogg.o : %.ogg
@echo $(notdir $<)
$(bin2o)
%.pcm.o : %.pcm
@echo $(notdir $<)
$(bin2o)
%.certs.o : %.certs
@echo $(notdir $<)
$(bin2o)
%.dat.o : %.dat
@echo $(notdir $<)
$(bin2o)
export PATH := $(PROJECTDIR)/gettext-bin:$(PATH)
%.pot: $(CFILES) $(CPPFILES)
@echo Update Language-Files ...
@xgettext -C -cTRANSLATORS --from-code=utf-8 --sort-output --no-wrap --no-location -k -ktr -ktrNOOP -o $@ $^
%.lang: $(PROJECTDIR)/Languages/$(TARGET).pot
@msgmerge -U -N --no-wrap --no-location --backup=none -q $@ $<
@touch $@
-include $(DEPENDS)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

29
ReadMe.txt Normal file
View File

@ -0,0 +1,29 @@
;Wiiload - Easy Setup for Dummys! [Installer for windows.]
;Copyright 2009 NeoRame
;This program is free software: you can redistribute it and/or modify
;it under the terms of the GNU General Public License as published by
;the Free Software Foundation, either version 3 of the License, or
;(at your option) any later version.
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;GNU General Public License for more details.
;You should have received a copy of the GNU General Public License
;along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.html.
For compiling use NSIS 2.xx and compile the *.nsi
http://nsis.sourceforge.net/Download
Installer created by NeoRame, #gui-usbloader-chat abjects.net
Wiiload 0.4 coded by dhewg, #wiidev efnet
SendElf v4 coded by henke37, dasda
SendElf is a graphical client that sends files over TCP from windows computers to Wii consoles. May require the .NET framework and does require the visual studio runtime.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
<pd><ViewState><e p="gui\source\mload" x="false"></e><e p="gui\source\settings" x="false"></e><e p="gui\source\images" x="false"></e><e p="gui\source\prompts" x="true"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="false"></e><e p="gui\source\network" x="false"></e><e p="gui\source\unzip" x="false"></e><e p="gui\source\usbloader" x="false"></e><e p="gui\source\xml" x="false"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\ramdisc" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\wad" x="true"></e><e p="gui" x="true"></e><e p="gui\source\homebrewboot" x="false"></e><e p="gui\source\language" x="false"></e><e p="gui\source" x="true"></e><e p="gui\source\libwbfs" x="false"></e><e p="gui\source\libwiigui" x="false"></e><e p="gui\source\patches" x="false"></e></ViewState></pd>

View File

@ -1,818 +0,0 @@
/*
* FreeTypeGX is a wrapper class for libFreeType which renders a compiled
* FreeType parsable font into a GX texture for Wii homebrew development.
* Copyright (C) 2008 Armin Tamzarian
* Modified by Tantric, 2009
*
* This file is part of FreeTypeGX.
*
* FreeTypeGX is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FreeTypeGX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FreeTypeGX. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sys/stat.h>
#include "FreeTypeGX.h"
#include "settings/cfg.h"
#include "main.h"
/*! \struct ftgxCharData_
*
* Font face character glyph relevant data structure.
*/
typedef struct ftgxCharData_ {
int16_t renderOffsetX; /**< Texture X axis bearing offset. */
uint16_t glyphAdvanceX; /**< Character glyph X coordinate advance in pixels. */
uint16_t glyphIndex; /**< Charachter glyph index in the font face. */
uint16_t textureWidth; /**< Texture width in pixels/bytes. */
uint16_t textureHeight; /**< Texture glyph height in pixels/bytes. */
int16_t renderOffsetY; /**< Texture Y axis bearing offset. */
int16_t renderOffsetMax; /**< Texture Y axis bearing maximum value. */
int16_t renderOffsetMin; /**< Texture Y axis bearing minimum value. */
uint32_t* glyphDataTexture; /**< Glyph texture bitmap data buffer. */
} ftgxCharData;
/*! \struct ftgxDataOffset_
*
* Offset structure which hold both a maximum and minimum value.
*/
typedef struct ftgxDataOffset_ {
int16_t ascender; /**< Maximum data offset. */
int16_t descender; /**< Minimum data offset. */
int16_t max; /**< Maximum data offset. */
int16_t min; /**< Minimum data offset. */
} ftgxDataOffset;
/**
* Default constructor for the FreeTypeGX class.
*
* @param textureFormat Optional format (GX_TF_*) of the texture as defined by the libogc gx.h header file. If not specified default value is GX_TF_RGBA8.
* @param vertexIndex Optional vertex format index (GX_VTXFMT*) of the glyph textures as defined by the libogc gx.h header file. If not specified default value is GX_VTXFMT1.
*/
FreeTypeGX::FreeTypeGX(uint8_t textureFormat, uint8_t vertexIndex) : ftFace(NULL), ftFace_fromFile(NULL) {
FT_Init_FreeType(&this->ftLibrary);
this->textureFormat = textureFormat;
this->setVertexFormat(vertexIndex);
this->setCompatibilityMode(FTGX_COMPATIBILITY_NONE);
}
/**
* Default destructor for the FreeTypeGX class.
*/
FreeTypeGX::~FreeTypeGX() {
this->unloadFont();
FT_Done_FreeType(this->ftLibrary);
}
/**
* Convert a short char sctring to a wide char string.
*
* This routine converts a supplied shot character string into a wide character string.
* Note that it is the user's responsibility to clear the returned buffer once it is no longer needed.
*
* @param strChar Character string to be converted.
* @return Wide character representation of supplied character string.
*/
wchar_t* FreeTypeGX::charToWideChar(char* strChar) {
wchar_t *strWChar;
strWChar = new wchar_t[strlen(strChar) + 1];
// UTF-8
int bt;
bt = mbstowcs(strWChar, strChar, strlen(strChar));
if (bt > 0) {
strWChar[bt] = (wchar_t)'\0';
return strWChar;
}
char *tempSrc = strChar;
wchar_t *tempDest = strWChar;
while ((*tempDest++ = *tempSrc++));
return strWChar;
}
/**
*
* \overload
*/
wchar_t* FreeTypeGX::charToWideChar(const char* strChar) {
return FreeTypeGX::charToWideChar((char*) strChar);
}
/**
* Setup the vertex attribute formats for the glyph textures.
*
* This function sets up the vertex format for the glyph texture on the specified vertex format index.
* Note that this function should not need to be called except if the vertex formats are cleared or the specified
* vertex format index is modified.
*
* @param vertexIndex Vertex format index (GX_VTXFMT*) of the glyph textures as defined by the libogc gx.h header file.
*/
void FreeTypeGX::setVertexFormat(uint8_t vertexIndex) {
this->vertexIndex = vertexIndex;
GX_SetVtxAttrFmt(this->vertexIndex, GX_VA_POS, GX_POS_XY, GX_S16, 0);
GX_SetVtxAttrFmt(this->vertexIndex, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
GX_SetVtxAttrFmt(this->vertexIndex, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
}
/**
* Sets the TEV and VTX rendering compatibility requirements for the class.
*
* This sets up the default TEV opertion and VTX descriptions rendering values for the class. This ensures that FreeTypeGX
* can remain compatible with external liraries or project code. Certain external libraries or code by design or lack of
* foresight assume that the TEV opertion and VTX descriptions values will remain constant or are always returned to a
* certain value. This will enable compatibility with those libraries and any other code which cannot or will not be changed.
*
* @param compatibilityMode Compatibility descritor (FTGX_COMPATIBILITY_*) as defined in FreeTypeGX.h
*/
void FreeTypeGX::setCompatibilityMode(uint32_t compatibilityMode) {
this->compatibilityMode = compatibilityMode;
}
/**
* Sets the TEV operation and VTX descriptor values after texture rendering it complete.
*
* This function calls the GX_SetTevOp and GX_SetVtxDesc functions with the compatibility parameters specified
* in setCompatibilityMode.
*/
void FreeTypeGX::setDefaultMode() {
if (this->compatibilityMode) {
switch (this->compatibilityMode & 0x00FF) {
case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE:
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
break;
case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_DECAL:
GX_SetTevOp(GX_TEVSTAGE0, GX_DECAL);
break;
case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_BLEND:
GX_SetTevOp(GX_TEVSTAGE0, GX_BLEND);
break;
case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_REPLACE:
GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE);
break;
case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR:
GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
break;
default:
break;
}
switch (this->compatibilityMode & 0xFF00) {
case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE:
GX_SetVtxDesc(GX_VA_TEX0, GX_NONE);
break;
case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_DIRECT:
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
break;
case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_INDEX8:
GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX8);
break;
case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_INDEX16:
GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX16);
break;
default:
break;
}
}
}
/**
* Loads and processes a specified true type font buffer to a specific point size.
*
* This routine takes a precompiled true type font buffer and loads the necessary processed data into memory. This routine should be called before drawText will succeed.
*
* @param fontPath filename with path to load font from file in memory.
* @param fontBuffer A pointer in memory to a precompiled true type font buffer.
* @param bufferSize Size of the true type font buffer in bytes.
* @param pointSize The desired point size this wrapper's configured font face.
* @param cacheAll Optional flag to specify if all font characters should be cached when the class object is created. If specified as false the characters only become cached the first time they are used. If not specified default value is false.
*/
uint16_t FreeTypeGX::loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) {
this->unloadFont();
this->ftPointSize = pointSize;
struct stat st;
if (fontPath && (stat(fontPath, &st)==0)) {
FILE *fontfile = fopen(fontPath, "rb");
if (fontfile) {
FT_Long ftFace_fromFile_Size;
fseek(fontfile, 0, SEEK_END);
ftFace_fromFile_Size = ftell(fontfile);
fseek(fontfile, 0, SEEK_SET);
ftFace_fromFile = (uint8_t*)malloc(ftFace_fromFile_Size);
if (ftFace_fromFile != NULL) {
fread(ftFace_fromFile, 1, ftFace_fromFile_Size, fontfile);
FT_New_Memory_Face(this->ftLibrary, ftFace_fromFile, ftFace_fromFile_Size, 0, &this->ftFace);
}
fclose(fontfile);
}
}
if (ftFace_fromFile == NULL)
FT_New_Memory_Face(this->ftLibrary, (FT_Byte *)fontBuffer, bufferSize, 0, &this->ftFace);
if (this->ftPointSize > 0)
FT_Set_Pixel_Sizes(this->ftFace, 0, this->ftPointSize);
this->ftSlot = this->ftFace->glyph;
this->ftKerningEnabled = FT_HAS_KERNING(this->ftFace);
if (cacheAll) {
return this->cacheGlyphDataComplete();
}
return 0;
}
/**
*
* \overload
*/
uint16_t FreeTypeGX::loadFont(const char* fontPath, const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) {
return this->loadFont((char*)fontPath, (uint8_t *)fontBuffer, bufferSize, pointSize, cacheAll);
}
void FreeTypeGX::unloadFont() {
clearGlyphData();
if (this->ftFace) {
FT_Done_Face(this->ftFace);
this->ftFace = NULL;
}
if (this->ftFace_fromFile) {
free(this->ftFace_fromFile);
this->ftFace_fromFile = NULL;
}
}
/**
* Clears all loaded font glyph data.
*
* This routine clears all members of the font map structure and frees all allocated memory back to the system.
*/
void FreeTypeGX::clearGlyphData() {
if (this->fontData.size() == 0)
return;
GX_DrawDone();
GX_Flush();
for ( std::map<wchar_t, ftgxCharData>::iterator i = this->fontData.begin(); i != this->fontData.end(); i++) {
free(i->second.glyphDataTexture);
}
this->fontData.clear();
}
void FreeTypeGX::changeSize(FT_UInt vPointSize, FT_UInt hPointSize/*=0*/) {
this->clearGlyphData();
this->ftPointSize = vPointSize;
FT_Set_Pixel_Sizes(this->ftFace, hPointSize, this->ftPointSize);
}
/**
* Adjusts the texture data buffer to necessary width for a given texture format.
*
* This routine determines adjusts the given texture width into the required width to hold the necessary texture data for proper alignment.
*
* @param textureWidth The initial guess for the texture width.
* @param textureFormat The texture format to which the data is to be converted.
* @return The correctly adjusted texture width.
*/
uint16_t FreeTypeGX::adjustTextureWidth(uint16_t textureWidth, uint8_t textureFormat) {
uint16_t alignment;
switch (textureFormat) {
case GX_TF_I4: /* 8x8 Tiles - 4-bit Intensity */
case GX_TF_I8: /* 8x4 Tiles - 8-bit Intensity */
case GX_TF_IA4: /* 8x4 Tiles - 4-bit Intensity, , 4-bit Alpha */
alignment = 8;
break;
case GX_TF_IA8: /* 4x4 Tiles - 8-bit Intensity, 8-bit Alpha */
case GX_TF_RGB565: /* 4x4 Tiles - RGB565 Format */
case GX_TF_RGB5A3: /* 4x4 Tiles - RGB5A3 Format */
case GX_TF_RGBA8: /* 4x4 Tiles - RGBA8 Dual Cache Line Format */
default:
alignment = 4;
break;
}
return textureWidth % alignment == 0 ? textureWidth : alignment + textureWidth - (textureWidth % alignment);
}
/**
* Adjusts the texture data buffer to necessary height for a given texture format.
*
* This routine determines adjusts the given texture height into the required height to hold the necessary texture data for proper alignment.
*
* @param textureHeight The initial guess for the texture height.
* @param textureFormat The texture format to which the data is to be converted.
* @return The correctly adjusted texture height.
*/
uint16_t FreeTypeGX::adjustTextureHeight(uint16_t textureHeight, uint8_t textureFormat) {
uint16_t alignment;
switch (textureFormat) {
case GX_TF_I4: /* 8x8 Tiles - 4-bit Intensity */
alignment = 8;
break;
case GX_TF_I8: /* 8x4 Tiles - 8-bit Intensity */
case GX_TF_IA4: /* 8x4 Tiles - 4-bit Intensity, , 4-bit Alpha */
case GX_TF_IA8: /* 4x4 Tiles - 8-bit Intensity, 8-bit Alpha */
case GX_TF_RGB565: /* 4x4 Tiles - RGB565 Format */
case GX_TF_RGB5A3: /* 4x4 Tiles - RGB5A3 Format */
case GX_TF_RGBA8: /* 4x4 Tiles - RGBA8 Dual Cache Line Format */
default:
alignment = 4;
break;
}
return textureHeight % alignment == 0 ? textureHeight : alignment + textureHeight - (textureHeight % alignment);
}
/**
* Caches the given font glyph in the instance font texture buffer.
*
* This routine renders and stores the requested glyph's bitmap and relevant information into its own quickly addressible
* structure within an instance-specific map.
*
* @param charCode The requested glyph's character code.
* @return A pointer to the allocated font structure.
*/
ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode) {
FT_UInt gIndex;
uint16_t textureWidth = 0, textureHeight = 0;
gIndex = FT_Get_Char_Index( this->ftFace, charCode );
if (!FT_Load_Glyph(this->ftFace, gIndex, FT_LOAD_DEFAULT )) {
FT_Render_Glyph( this->ftSlot, FT_RENDER_MODE_NORMAL );
if (this->ftSlot->format == FT_GLYPH_FORMAT_BITMAP) {
FT_Bitmap *glyphBitmap = &this->ftSlot->bitmap;
textureWidth = adjustTextureWidth(glyphBitmap->width, this->textureFormat);
textureHeight = adjustTextureHeight(glyphBitmap->rows, this->textureFormat);
this->fontData[charCode] = (ftgxCharData) {
this->ftSlot->bitmap_left,
this->ftSlot->advance.x >> 6,
gIndex,
textureWidth,
textureHeight,
this->ftSlot->bitmap_top,
this->ftSlot->bitmap_top,
glyphBitmap->rows - this->ftSlot->bitmap_top,
NULL
};
this->loadGlyphData(glyphBitmap, &this->fontData[charCode]);
return &this->fontData[charCode];
}
}
return NULL;
}
/**
* Locates each character in this wrapper's configured font face and proccess them.
*
* This routine locates each character in the configured font face and renders the glyph's bitmap.
* Each bitmap and relevant information is loaded into its own quickly addressible structure within an instance-specific map.
*/
uint16_t FreeTypeGX::cacheGlyphDataComplete() {
uint16_t i = 0;
FT_UInt gIndex;
FT_ULong charCode = FT_Get_First_Char( this->ftFace, &gIndex );
while ( gIndex != 0 ) {
if (this->cacheGlyphData(charCode) != NULL) {
i++;
}
charCode = FT_Get_Next_Char( this->ftFace, charCode, &gIndex );
}
return i;
}
/**
* Loads the rendered bitmap into the relevant structure's data buffer.
*
* This routine does a simple byte-wise copy of the glyph's rendered 8-bit grayscale bitmap into the structure's buffer.
* Each byte is converted from the bitmap's intensity value into the a uint32_t RGBA value.
*
* @param bmp A pointer to the most recently rendered glyph's bitmap.
* @param charData A pointer to an allocated ftgxCharData structure whose data represent that of the last rendered glyph.
*/
void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData) {
uint32_t *glyphData = (uint32_t *)memalign(32, charData->textureWidth * charData->textureHeight * 4);
memset(glyphData, 0x00, charData->textureWidth * charData->textureHeight * 4);
for (uint16_t imagePosY = 0; imagePosY < bmp->rows; imagePosY++) {
for (uint16_t imagePosX = 0; imagePosX < bmp->width; imagePosX++) {
uint32_t pixel = (uint32_t) bmp->buffer[imagePosY * bmp->width + imagePosX];
glyphData[imagePosY * charData->textureWidth + imagePosX] = 0x00000000 | (pixel << 24) | (pixel << 16) | (pixel << 8) | pixel;
}
}
switch (this->textureFormat) {
case GX_TF_I4:
charData->glyphDataTexture = Metaphrasis::convertBufferToI4(glyphData, charData->textureWidth, charData->textureHeight);
break;
case GX_TF_I8:
charData->glyphDataTexture = Metaphrasis::convertBufferToI8(glyphData, charData->textureWidth, charData->textureHeight);
break;
case GX_TF_IA4:
charData->glyphDataTexture = Metaphrasis::convertBufferToIA4(glyphData, charData->textureWidth, charData->textureHeight);
break;
case GX_TF_IA8:
charData->glyphDataTexture = Metaphrasis::convertBufferToIA8(glyphData, charData->textureWidth, charData->textureHeight);
break;
case GX_TF_RGB565:
charData->glyphDataTexture = Metaphrasis::convertBufferToRGB565(glyphData, charData->textureWidth, charData->textureHeight);
break;
case GX_TF_RGB5A3:
charData->glyphDataTexture = Metaphrasis::convertBufferToRGB5A3(glyphData, charData->textureWidth, charData->textureHeight);
break;
case GX_TF_RGBA8:
default:
charData->glyphDataTexture = Metaphrasis::convertBufferToRGBA8(glyphData, charData->textureWidth, charData->textureHeight);
break;
}
free(glyphData);
}
/**
* Determines the x offset of the rendered string.
*
* This routine calculates the x offset of the rendered string based off of a supplied positional format parameter.
*
* @param width Current pixel width of the string.
* @param format Positional format of the string.
*/
int16_t FreeTypeGX::getStyleOffsetWidth(uint16_t width, uint16_t format) {
switch (format & FTGX_JUSTIFY_MASK) {
case FTGX_JUSTIFY_LEFT:
return 0;
default:
case FTGX_JUSTIFY_CENTER:
return -(width >> 1);
case FTGX_JUSTIFY_RIGHT:
return -width;
}
return 0;
}
/**
* Determines the y offset of the rendered string.
*
* This routine calculates the y offset of the rendered string based off of a supplied positional format parameter.
*
* @param offset Current pixel offset data of the string.
* @param format Positional format of the string.
*/
int16_t FreeTypeGX::getStyleOffsetHeight(ftgxDataOffset *offset, uint16_t format) {
switch (format & FTGX_ALIGN_MASK) {
case FTGX_ALIGN_TOP:
return offset->ascender;
default:
case FTGX_ALIGN_MIDDLE:
return (offset->ascender + offset->descender + 1) >> 1;
case FTGX_ALIGN_BOTTOM:
return offset->descender;
case FTGX_ALIGN_BASELINE:
return 0;
case FTGX_ALIGN_GLYPH_TOP:
return offset->max;
case FTGX_ALIGN_GLYPH_MIDDLE:
return (offset->max + offset->min + 1) >> 1;
case FTGX_ALIGN_GLYPH_BOTTOM:
return offset->min;
}
return 0;
}
/**
* Processes the supplied text string and prints the results at the specified coordinates.
*
* This routine processes each character of the supplied text string, loads the relevant preprocessed bitmap buffer,
* a texture from said buffer, and loads the resultant texture into the EFB.
*
* @param x Screen X coordinate at which to output the text.
* @param y Screen Y coordinate at which to output the text. Note that this value corresponds to the text string origin and not the top or bottom of the glyphs.
* @param text NULL terminated string to output.
* @param color Optional color to apply to the text characters. If not specified default value is ftgxWhite: (GXColor){0xff, 0xff, 0xff, 0xff}
* @param textStyle Flags which specify any styling which should be applied to the rendered string.
* @return The number of characters printed.
*/
uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t *text, GXColor color, uint16_t textStyle) {
uint16_t strLength = wcslen(text);
uint16_t x_pos = x, printed = 0;
uint16_t x_offset = 0, y_offset = 0;
GXTexObj glyphTexture;
FT_Vector pairDelta;
ftgxDataOffset offset;
if (textStyle & FTGX_JUSTIFY_MASK) {
x_offset = this->getStyleOffsetWidth(this->getWidth(text), textStyle);
}
if (textStyle & FTGX_ALIGN_MASK) {
y_offset = this->getStyleOffsetHeight(this->getOffset(text, &offset), textStyle);
}
for (uint16_t i = 0; i < strLength; i++) {
ftgxCharData* glyphData = NULL;
if ( this->fontData.find(text[i]) != this->fontData.end() ) {
glyphData = &this->fontData[text[i]];
} else {
glyphData = this->cacheGlyphData(text[i]);
}
if (glyphData != NULL) {
if (this->ftKerningEnabled && i) {
FT_Get_Kerning( this->ftFace, this->fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta );
x_pos += pairDelta.x >> 6;
}
GX_InitTexObj(&glyphTexture, glyphData->glyphDataTexture, glyphData->textureWidth, glyphData->textureHeight, this->textureFormat, GX_CLAMP, GX_CLAMP, GX_FALSE);
this->copyTextureToFramebuffer(&glyphTexture, glyphData->textureWidth, glyphData->textureHeight, x_pos + glyphData->renderOffsetX + x_offset, y - glyphData->renderOffsetY + y_offset, color);
x_pos += glyphData->glyphAdvanceX;
printed++;
}
}
if (textStyle & FTGX_STYLE_MASK) {
this->drawTextFeature(x + x_offset, y + y_offset, this->getWidth(text), this->getOffset(text, &offset), textStyle, color);
}
return printed;
}
/**
* \overload
*/
uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t const *text, GXColor color, uint16_t textStyle) {
return this->drawText(x, y, (wchar_t *)text, color, textStyle);
}
void FreeTypeGX::drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataOffset *offsetData, uint16_t format, GXColor color) {
uint16_t featureHeight = this->ftPointSize >> 4 > 0 ? this->ftPointSize >> 4 : 1;
if (format & FTGX_STYLE_UNDERLINE ) {
switch (format & FTGX_ALIGN_MASK) {
/*
case FTGX_ALIGN_TOP:
this->copyFeatureToFramebuffer(width, featureHeight, x, y + offsetData->max + 1, color);
break;
case FTGX_ALIGN_MIDDLE:
this->copyFeatureToFramebuffer(width, featureHeight, x, y + ((offsetData->max - offsetData->min + 1) >> 1), color);
break;
case FTGX_ALIGN_BOTTOM:
this->copyFeatureToFramebuffer(width, featureHeight, x, y - offsetData->min, color);
break;
*/
default:
this->copyFeatureToFramebuffer(width, featureHeight, x, y + 1, color);
break;
}
}
if (format & FTGX_STYLE_STRIKE ) {
switch (format & FTGX_ALIGN_MASK) {
/*
case FTGX_ALIGN_TOP:
this->copyFeatureToFramebuffer(width, featureHeight, x, y + ((offsetData->max - offsetData->min + 1) >> 1), color);
break;
case FTGX_ALIGN_MIDDLE:
this->copyFeatureToFramebuffer(width, featureHeight, x, y, color);
break;
case FTGX_ALIGN_BOTTOM:
this->copyFeatureToFramebuffer(width, featureHeight, x, y - ((offsetData->max + offsetData->min) >> 1), color);
break;
*/
default:
// this->copyFeatureToFramebuffer(width, featureHeight, x, y - ((offsetData->max - offsetData->min) >> 1), color);
this->copyFeatureToFramebuffer(width, featureHeight, x, y - ((offsetData->max) >> 1), color);
break;
}
}
}
/**
* Processes the supplied string and return the width of the string in pixels.
*
* This routine processes each character of the supplied text string and calculates the width of the entire string.
* Note that if precaching of the entire font set is not enabled any uncached glyph will be cached after the call to this function.
*
* @param text NULL terminated string to calculate.
* @return The width of the text string in pixels.
*/
uint16_t FreeTypeGX::getWidth(wchar_t *text) {
uint16_t strLength = wcslen(text);
uint16_t strWidth = 0;
FT_Vector pairDelta;
for (uint16_t i = 0; i < strLength; i++) {
ftgxCharData* glyphData = NULL;
if ( this->fontData.find(text[i]) != this->fontData.end() ) {
glyphData = &this->fontData[text[i]];
} else {
glyphData = this->cacheGlyphData(text[i]);
}
if (glyphData != NULL) {
if (this->ftKerningEnabled && (i > 0)) {
FT_Get_Kerning( this->ftFace, this->fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta );
strWidth += pairDelta.x >> 6;
}
strWidth += glyphData->glyphAdvanceX;
}
}
return strWidth;
}
/**
*
* \overload
*/
uint16_t FreeTypeGX::getWidth(wchar_t const *text) {
return this->getWidth((wchar_t *)text);
}
/**
* Processes the supplied string and return the height of the string in pixels.
*
* This routine processes each character of the supplied text string and calculates the height of the entire string.
* Note that if precaching of the entire font set is not enabled any uncached glyph will be cached after the call to this function.
*
* @param text NULL terminated string to calculate.
* @return The height of the text string in pixels.
*/
uint16_t FreeTypeGX::getHeight(wchar_t *text) {
ftgxDataOffset offset;
this->getOffset(text, &offset);
return offset.max - offset.min;
}
/**
*
* \overload
*/
uint16_t FreeTypeGX::getHeight(wchar_t const *text) {
return this->getHeight((wchar_t *)text);
}
/**
* Get the maximum offset above and minimum offset below the font origin line.
*
* This function calculates the maximum pixel height above the font origin line and the minimum
* pixel height below the font origin line and returns the values in an addressible structure.
*
* @param text NULL terminated string to calculate.
* @param offset returns the max and min values above and below the font origin line
*
*/
ftgxDataOffset* FreeTypeGX::getOffset(wchar_t *text, ftgxDataOffset* offset) {
uint16_t strLength = wcslen(text);
int16_t strMax = 0, strMin = 9999;
for (uint16_t i = 0; i < strLength; i++) {
ftgxCharData* glyphData = NULL;
if ( this->fontData.find(text[i]) != this->fontData.end() ) {
glyphData = &this->fontData[text[i]];
} else {
glyphData = this->cacheGlyphData(text[i]);
}
if (glyphData != NULL) {
strMax = glyphData->renderOffsetMax > strMax ? glyphData->renderOffsetMax : strMax;
strMin = glyphData->renderOffsetMin < strMin ? glyphData->renderOffsetMin : strMin;
}
}
offset->ascender = this->ftFace->size->metrics.ascender>>6;
offset->descender = this->ftFace->size->metrics.descender>>6;
offset->max = strMax;
offset->min = strMin;
return offset;
}
/**
*
* \overload
*/
ftgxDataOffset* FreeTypeGX::getOffset(wchar_t const *text, ftgxDataOffset* offset) {
return this->getOffset(text, offset);
}
/**
* Copies the supplied texture quad to the EFB.
*
* This routine uses the in-built GX quad builder functions to define the texture bounds and location on the EFB target.
*
* @param texObj A pointer to the glyph's initialized texture object.
* @param texWidth The pixel width of the texture object.
* @param texHeight The pixel height of the texture object.
* @param screenX The screen X coordinate at which to output the rendered texture.
* @param screenY The screen Y coordinate at which to output the rendered texture.
* @param color Color to apply to the texture.
*/
void FreeTypeGX::copyTextureToFramebuffer(GXTexObj *texObj, f32 texWidth, f32 texHeight, int16_t screenX, int16_t screenY, GXColor color) {
GX_LoadTexObj(texObj, GX_TEXMAP0);
GX_InvalidateTexAll();
GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT);
GX_Begin(GX_QUADS, this->vertexIndex, 4);
GX_Position2s16(screenX, screenY);
GX_Color4u8(color.r, color.g, color.b, color.a);
GX_TexCoord2f32(0.0f, 0.0f);
GX_Position2s16(texWidth + screenX, screenY);
GX_Color4u8(color.r, color.g, color.b, color.a);
GX_TexCoord2f32(1.0f, 0.0f);
GX_Position2s16(texWidth + screenX, texHeight + screenY);
GX_Color4u8(color.r, color.g, color.b, color.a);
GX_TexCoord2f32(1.0f, 1.0f);
GX_Position2s16(screenX, texHeight + screenY);
GX_Color4u8(color.r, color.g, color.b, color.a);
GX_TexCoord2f32(0.0f, 1.0f);
GX_End();
this->setDefaultMode();
}
/**
* Creates a feature quad to the EFB.
*
* This function creates a simple quad for displaying underline or strikeout text styling.
*
* @param featureWidth The pixel width of the quad.
* @param featureHeight The pixel height of the quad.
* @param screenX The screen X coordinate at which to output the quad.
* @param screenY The screen Y coordinate at which to output the quad.
* @param color Color to apply to the texture.
*/
void FreeTypeGX::copyFeatureToFramebuffer(f32 featureWidth, f32 featureHeight, int16_t screenX, int16_t screenY, GXColor color) {
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
GX_Begin(GX_QUADS, this->vertexIndex, 4);
GX_Position2s16(screenX, screenY);
GX_Color4u8(color.r, color.g, color.b, color.a);
GX_Position2s16(featureWidth + screenX, screenY);
GX_Color4u8(color.r, color.g, color.b, color.a);
GX_Position2s16(featureWidth + screenX, featureHeight + screenY);
GX_Color4u8(color.r, color.g, color.b, color.a);
GX_Position2s16(screenX, featureHeight + screenY);
GX_Color4u8(color.r, color.g, color.b, color.a);
GX_End();
this->setDefaultMode();
}

View File

@ -1,277 +0,0 @@
/*
* FreeTypeGX is a wrapper class for libFreeType which renders a compiled
* FreeType parsable font into a GX texture for Wii homebrew development.
* Copyright (C) 2008 Armin Tamzarian
* Modified by Tantric, 2009
*
* This file is part of FreeTypeGX.
*
* FreeTypeGX is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FreeTypeGX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FreeTypeGX. If not, see <http://www.gnu.org/licenses/>.
*/
/** \mainpage FreeTypeGX
*
* \section sec_intro Introduction
*
* FreeTypeGX is a wrapper class for libFreeType which renders a compiled FreeType parsable font into a GX texture for Wii homebrew development.
* <br>
* FreeTypeGX is written in C++ and makes use of a selectable pre-buffered or buffer-on-demand methodology to allow fast and efficient printing of text to the EFB.
* <p>
* This library was developed in-full by Armin Tamzarian with the support of developers in \#wiibrew on EFnet.
*
* \section sec_installation_source Installation (Source Code)
*
* -# Ensure that you have the <a href = "http://www.tehskeen.com/forums/showthread.php?t=9404">libFreeType</a> Wii library installed in your development environment with the library added to your Makefile where appropriate.
* -# Ensure that you have the <a href = "http://code.google.com/p/metaphrasis">Metaphrasis</a> library installed in your development environment with the library added to your Makefile where appropriate.
* -# Extract the FreeTypeGX archive.
* -# Copy the contents of the <i>src</i> directory into your project's development path.
* -# Include the FreeTypeGX header file in your code using syntax such as the following:
* \code
* #include "FreeTypeGX.h"
* \endcode
*
* \section sec_installation_library Installation (Library)
*
* -# Ensure that you have the <a href = "http://www.tehskeen.com/forums/showthread.php?t=9404">libFreeType</a> Wii library installed in your development environment with the library added to your Makefile where appropriate.
* -# Ensure that you have the <a href = "http://code.google.com/p/metaphrasis">Metaphrasis</a> library installed in your development environment with the library added to your Makefile where appropriate.
* -# Extract the FreeTypeGX archive.
* -# Copy the contents of the <i>lib</i> directory into your <i>devKitPro/libogc</i> directory.
* -# Include the FreeTypeGX header file in your code using syntax such as the following:
* \code
* #include "FreeTypeGX.h"
* \endcode
*
* \section sec_freetypegx_prerequisites FreeTypeGX Prerequisites
*
* Before you begin using FreeTypeGX in your project you must ensure that the desired font in compiled into your project. For this example I will assume you are building your project with a Makefile using devKitPro evironment and are attempting to include a font whose filename is rursus_compact_mono.ttf.
*
* -# Copy the font into a directory which will be processed by the project's Makefile. If you are unsure about where you should place your font just copy the it into your project's source directory.
* \n\n
* -# Modify the Makefile to convert the font into an object file:
* \code
* %.ttf.o : %.ttf
* @echo $(notdir $<)
* $(bin2o)
* \endcode
* \n
* -# Include the font object's generated header file in your source code:
* \code
* #include "rursus_compact_mono_ttf.h"
* \endcode
* This header file defines the two variables that you will need for use within your project:
* \code
* extern const u8 rursus_compact_mono_ttf[]; A pointer to the font buffer within the compiled project.
* extern const u32 rursus_compact_mono_ttf_size; The size of the font's buffer in bytes.
* \endcode
*
* \section sec_freetypegx_usage FreeTypeGX Usage
*
* -# Within the file you included the FreeTypeGX.h header create an instance object of the FreeTypeGX class:
* \code
* FreeTypeGX *freeTypeGX = new FreeTypeGX();
* \endcode
* Alternately you can specify a texture format to which you would like to render the font characters. Note that the default value for this parameter is GX_TF_RGBA8.
* \code
* FreeTypeGX *freeTypeGX = new FreeTypeGX(GX_TF_RGB565);
* \endcode
* Furthermore, you can also specify a vertex format index to avoid conflicts with concurrent libraries or other systems. Note that the default value for this parameter is GX_VTXFMT1.
* \code
* FreeTypeGX *freeTypeGX = new FreeTypeGX(GX_TF_RGB565, GX_VTXFMT1);
* \endcode
* \n
* Currently supported textures are:
* \li <i>GX_TF_I4</i>
* \li <i>GX_TF_I8</i>
* \li <i>GX_TF_IA4</i>
* \li <i>GX_TF_IA8</i>
* \li <i>GX_TF_RGB565</i>
* \li <i>GX_TF_RGB5A3</i>
* \li <i>GX_TF_RGBA8</i>
*
* \n
* -# Using the allocated FreeTypeGX instance object call the loadFont function to load the font from the compiled buffer and specify the desired point size. Note that this function can be called multiple times to load a new:
* \code
* freeTypeGX->loadFont(rursus_compact_mono_ttf, rursus_compact_mono_ttf_size, 64);
* \endcode
* Alternately you can specify a flag which will load and cache all available font glyphs immidiately. Note that on large font sets enabling this feature could take a significant amount of time.
* \code
* freeTypeGX->loadFont(rursus_compact_mono_ttf, rursus_compact_mono_ttf_size, 64, true);
* \endcode
* \n
* -# If necessary you can enable compatibility modes with concurrent libraries or systems. For more information on this feature see the documentation for setCompatibilityMode:
* \code
* freeTypeGX->setCompatibilityMode(FTGX_COMPATIBILITY_GRRLIB);
* \endcode
* -# Using the allocated FreeTypeGX instance object call the drawText function to print a string at the specified screen X and Y coordinates to the current EFB:
* \code
* freeTypeGX->drawText(10, 25, _TEXT("FreeTypeGX Rocks!"));
* \endcode
* Alternately you can specify a <i>GXColor</i> object you would like to apply to the printed characters:
* \code
* freeTypeGX->drawText(10, 25, _TEXT("FreeTypeGX Rocks!"),
* (GXColor){0xff, 0xee, 0xaa, 0xff});
* \endcode
* Furthermore you can also specify a group of styling parameters which will modify the positioning or style of the text:
* \code
* freeTypeGX->drawText(10, 25, _TEXT("FreeTypeGX Rocks!"),
* (GXColor){0xff, 0xee, 0xaa, 0xff},
* FTGX_JUSTIFY_CENTER | FTGX_ALIGN_BOTTOM | FTGX_STYLE_UNDERLINE);
* \endcode
* \n
* Currently style parameters are:
* \li <i>FTGX_JUSTIFY_LEFT</i>
* \li <i>FTGX_JUSTIFY_CENTER</i>
* \li <i>FTGX_JUSTIFY_RIGHT</i>
* \li <i>FTGX_ALIGN_TOP</i>
* \li <i>FTGX_ALIGN_MIDDLE</i>
* \li <i>FTGX_ALIGN_BOTTOM</i>
* \li <i>FTGX_STYLE_UNDERLINE</i>
* \li <i>FTGX_STYLE_STRIKE</i>
*
* \section sec_license License
*
* FreeTypeGX is distributed under the GNU Lesser General Public License.
*
* \section sec_contact Contact
*
* If you have any suggestions, questions, or comments regarding this library feel free to e-mail me at tamzarian1989 [at] gmail [dawt] com.
*/
#ifndef FREETYPEGX_H_
#define FREETYPEGX_H_
#include <gccore.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_BITMAP_H
#include "Metaphrasis.h"
#include <malloc.h>
#include <string.h>
#include <map>
/*! forward deklaration of private structures
*
*/
typedef struct ftgxCharData_ ftgxCharData;
typedef struct ftgxDataOffset_ ftgxDataOffset;
#define _TEXT(t) L ## t /**< Unicode helper macro. */
#define FTGX_NULL 0x0000
#define FTGX_JUSTIFY_LEFT 0x0001
#define FTGX_JUSTIFY_CENTER 0x0002
#define FTGX_JUSTIFY_RIGHT 0x0003
#define FTGX_JUSTIFY_MASK 0x000f
#define FTGX_ALIGN_TOP 0x0010
#define FTGX_ALIGN_MIDDLE 0x0020
#define FTGX_ALIGN_BOTTOM 0x0030
#define FTGX_ALIGN_BASELINE 0x0040
#define FTGX_ALIGN_GLYPH_TOP 0x0050
#define FTGX_ALIGN_GLYPH_MIDDLE 0x0060
#define FTGX_ALIGN_GLYPH_BOTTOM 0x0070
#define FTGX_ALIGN_MASK 0x00f0
#define FTGX_STYLE_UNDERLINE 0x0100
#define FTGX_STYLE_STRIKE 0x0200
#define FTGX_STYLE_MASK 0x0f00
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE 0X0001
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_DECAL 0X0002
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_BLEND 0X0004
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_REPLACE 0X0008
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR 0X0010
#define FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE 0X0100
#define FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_DIRECT 0X0200
#define FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_INDEX8 0X0400
#define FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_INDEX16 0X0800
#define FTGX_COMPATIBILITY_NONE 0x0000
#define FTGX_COMPATIBILITY_GRRLIB FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE
#define FTGX_COMPATIBILITY_LIBWIISPRITE FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_DIRECT
const GXColor ftgxWhite = (GXColor) {
0xff, 0xff, 0xff, 0xff
}
; /**< Constant color value used only to sanitize Doxygen documentation. */
/*! \class FreeTypeGX
* \brief Wrapper class for the libFreeType library with GX rendering.
* \author Armin Tamzarian
* \version 0.2.4
*
* FreeTypeGX acts as a wrapper class for the libFreeType library. It supports precaching of transformed glyph data into
* a specified texture format. Rendering of the data to the EFB is accomplished through the application of high performance
* GX texture functions resulting in high throughput of string rendering.
*/
class FreeTypeGX {
private:
FT_Library ftLibrary; /**< FreeType FT_Library instance. */
FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */
FT_Byte *ftFace_fromFile;
FT_GlyphSlot ftSlot; /**< FreeType reusable FT_GlyphSlot glyph container object. */
FT_UInt ftPointSize; /**< Requested size of the rendered font. */
bool ftKerningEnabled; /**< Flag indicating the availability of font kerning data. */
uint8_t textureFormat; /**< Defined texture format of the target EFB. */
uint8_t vertexIndex; /**< Vertex format descriptor index. */
uint32_t compatibilityMode; /**< Compatibility mode for default tev operations and vertex descriptors. */
std::map<wchar_t, ftgxCharData> fontData; /**< Map which holds the glyph data structures for the corresponding characters. */
static uint16_t adjustTextureWidth(uint16_t textureWidth, uint8_t textureFormat);
static uint16_t adjustTextureHeight(uint16_t textureHeight, uint8_t textureFormat);
static int16_t getStyleOffsetWidth(uint16_t width, uint16_t format);
static int16_t getStyleOffsetHeight(ftgxDataOffset *offset, uint16_t format);
void unloadFont();
void clearGlyphData();
ftgxCharData *cacheGlyphData(wchar_t charCode);
uint16_t cacheGlyphDataComplete();
void loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData);
void setDefaultMode();
void drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataOffset *offsetData, uint16_t format, GXColor color);
void copyTextureToFramebuffer(GXTexObj *texObj, f32 texWidth, f32 texHeight, int16_t screenX, int16_t screenY, GXColor color);
void copyFeatureToFramebuffer(f32 featureWidth, f32 featureHeight, int16_t screenX, int16_t screenY, GXColor color);
public:
FreeTypeGX(uint8_t textureFormat = GX_TF_RGBA8, uint8_t vertexIndex = GX_VTXFMT1);
~FreeTypeGX();
static wchar_t* charToWideChar(char* p);
static wchar_t* charToWideChar(const char* p);
void setVertexFormat(uint8_t vertexIndex);
void setCompatibilityMode(uint32_t compatibilityMode);
uint16_t loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll = false);
uint16_t loadFont(const char* fontPath, const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll = false);
void changeSize(FT_UInt vPointSize, FT_UInt hPointSize=0);
uint16_t drawText(int16_t x, int16_t y, wchar_t *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL);
uint16_t drawText(int16_t x, int16_t y, wchar_t const *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL);
uint16_t getWidth(wchar_t *text);
uint16_t getWidth(wchar_t const *text);
uint16_t getHeight(wchar_t *text);
uint16_t getHeight(wchar_t const *text);
ftgxDataOffset* getOffset(wchar_t *text, ftgxDataOffset* offset);
ftgxDataOffset* getOffset(wchar_t const *text, ftgxDataOffset* offset);
};
#endif /* FREETYPEGX_H_ */

97
source/IPPage.ini Normal file
View File

@ -0,0 +1,97 @@
[Settings]
NumFields=11
=
BackEnabled=0
[Field 1]
Type=GroupBox
Left=0
Right=-1
Top=0
Bottom=-9
Text="Please Enter your Wii IP address"
[Field 2]
Type=Label
Text=*NOTE* You can find your Wii IP address when you press the Home button\r\n in your Homebrew Channel.
Left=20
Right=-20
Top=44
Bottom=60
[Field 3]
Type=Text
MaxLen=3
Flags=ONLY_NUMBERS
Left=100
Right=120
Top=25
Bottom=36
[Field 4]
Type=Text
MaxLen=3
Flags=ONLY_NUMBERS
Left=125
Right=145
Top=25
Bottom=36
[Field 5]
Type=Text
MaxLen=3
Flags=ONLY_NUMBERS
Left=150
Right=170
Top=25
Bottom=36
[Field 6]
Type=Text
MaxLen=3
Flags=ONLY_NUMBERS
Left=175
Right=195
Top=25
Bottom=36
[Field 7]
Type=Label
Text=.
Left=122
Right=124
Top=27
Bottom=35
[Field 8]
Type=Label
Text=.
Left=147
Right=150
Top=27
Bottom=35
[Field 9]
Type=Label
Text=.
Left=172
Right=174
Top=27
Bottom=35
[Field 10]
Type=Label
Text=IP:
Left=88
Right=96
Top=27
Bottom=35
[Field 11]
Type=Unknown
Text=Unknown
Left=0
Right=0
Top=0
Bottom=0

View File

@ -0,0 +1,29 @@
;Website: http://code.google.com/p/usbloader-gui/
;Copyright 2009 NeoRame
;This program is free software: you can redistribute it and/or modify
;it under the terms of the GNU General Public License as published by
;the Free Software Foundation, either version 3 of the License, or
;(at your option) any later version.
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;GNU General Public License for more details.
;You should have received a copy of the GNU General Public License
;along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.html.
;== Basic Information. Basic information about the portable app
!define NAME "Wiiload"
!define NAME2 "Wiiload"
!define SHORTNAME "Wiiload"
!define VERSION "1.00.0.0"
!define SHORTVERSION "1.0"
!define FILENAME "${NAME}_${SHORTVERSION}_Installer"
!define URL "http://code.google.com/p/usbloader-gui/"
!define TEAM "Team USB Loader GX"
!define INSTALLERLANGUAGE "ENGLISH" ;one of the NSIS pre-defined languages supported: English, French, Italian, German, Japanese, SimpChinese

View File

@ -1,382 +0,0 @@
/*
* Metaphrasis is a static conversion class for transforming RGBA image
* buffers into verious GX texture formats for Wii homebrew development.
* Copyright (C) 2008 Armin Tamzarian
*
* This file is part of Metaphrasis.
*
* Metaphrasis is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Metaphrasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Metaphrasis. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Metaphrasis.h"
/**
* Default constructor for the Metaphrasis class.
*/
Metaphrasis::Metaphrasis() {
}
/**
* Default destructor for the Metaphrasis class.
*/
Metaphrasis::~Metaphrasis() {
}
/**
* Convert the specified RGBA data buffer into the I4 texture format
*
* This routine converts the RGBA data buffer into the I4 texture format and returns a pointer to the converted buffer.
*
* @param rgbaBuffer Buffer containing the temporarily rendered RGBA data.
* @param bufferWidth Pixel width of the data buffer.
* @param bufferHeight Pixel height of the data buffer.
* @return A pointer to the allocated buffer.
*/
uint32_t* Metaphrasis::convertBufferToI4(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) {
uint32_t bufferSize = bufferWidth * bufferHeight >> 1;
uint32_t* dataBufferI4 = (uint32_t *)memalign(32, bufferSize);
memset(dataBufferI4, 0x00, bufferSize);
uint32_t *src = (uint32_t *)rgbaBuffer;
uint8_t *dst = (uint8_t *)dataBufferI4;
for (uint16_t y = 0; y < bufferHeight; y += 8) {
for (uint16_t x = 0; x < bufferWidth; x += 8) {
for (uint16_t rows = 0; rows < 8; rows++) {
*dst++ = (src[((y + rows) * bufferWidth) + (x + 0)] & 0xf0) | ((src[((y + rows) * bufferWidth) + (x + 1)] & 0xf0) >> 4);
*dst++ = (src[((y + rows) * bufferWidth) + (x + 2)] & 0xf0) | ((src[((y + rows) * bufferWidth) + (x + 3)] & 0xf0) >> 4);
*dst++ = (src[((y + rows) * bufferWidth) + (x + 4)] & 0xf0) | ((src[((y + rows) * bufferWidth) + (x + 5)] & 0xf0) >> 4);
*dst++ = (src[((y + rows) * bufferWidth) + (x + 5)] & 0xf0) | ((src[((y + rows) * bufferWidth) + (x + 7)] & 0xf0) >> 4);
}
}
}
DCFlushRange(dataBufferI4, bufferSize);
return dataBufferI4;
}
/**
* Convert the specified RGBA data buffer into the I8 texture format
*
* This routine converts the RGBA data buffer into the I8 texture format and returns a pointer to the converted buffer.
*
* @param rgbaBuffer Buffer containing the temporarily rendered RGBA data.
* @param bufferWidth Pixel width of the data buffer.
* @param bufferHeight Pixel height of the data buffer.
* @return A pointer to the allocated buffer.
*/
uint32_t* Metaphrasis::convertBufferToI8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) {
uint32_t bufferSize = bufferWidth * bufferHeight;
uint32_t* dataBufferI8 = (uint32_t *)memalign(32, bufferSize);
memset(dataBufferI8, 0x00, bufferSize);
uint32_t *src = (uint32_t *)rgbaBuffer;
uint8_t *dst = (uint8_t *)dataBufferI8;
for (uint16_t y = 0; y < bufferHeight; y += 4) {
for (uint16_t x = 0; x < bufferWidth; x += 8) {
for (uint16_t rows = 0; rows < 4; rows++) {
*dst++ = src[((y + rows) * bufferWidth) + (x + 0)] & 0xff;
*dst++ = src[((y + rows) * bufferWidth) + (x + 1)] & 0xff;
*dst++ = src[((y + rows) * bufferWidth) + (x + 2)] & 0xff;
*dst++ = src[((y + rows) * bufferWidth) + (x + 3)] & 0xff;
*dst++ = src[((y + rows) * bufferWidth) + (x + 4)] & 0xff;
*dst++ = src[((y + rows) * bufferWidth) + (x + 5)] & 0xff;
*dst++ = src[((y + rows) * bufferWidth) + (x + 6)] & 0xff;
*dst++ = src[((y + rows) * bufferWidth) + (x + 7)] & 0xff;
}
}
}
DCFlushRange(dataBufferI8, bufferSize);
return dataBufferI8;
}
/**
* Downsample the specified RGBA value data buffer to an IA4 value.
*
* This routine downsamples the given RGBA data value into the IA4 texture data format.
*
* @param rgba A 32-bit RGBA value to convert to the IA4 format.
* @return The IA4 value of the given RGBA value.
*/
uint8_t Metaphrasis::convertRGBAToIA4(uint32_t rgba) {
uint8_t i, a;
i = (rgba >> 8) & 0xf0;
a = (rgba ) & 0xff;
return i | (a >> 4);
}
/**
* Convert the specified RGBA data buffer into the IA4 texture format
*
* This routine converts the RGBA data buffer into the IA4 texture format and returns a pointer to the converted buffer.
*
* @param rgbaBuffer Buffer containing the temporarily rendered RGBA data.
* @param bufferWidth Pixel width of the data buffer.
* @param bufferHeight Pixel height of the data buffer.
* @return A pointer to the allocated buffer.
*/
uint32_t* Metaphrasis::convertBufferToIA4(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) {
uint32_t bufferSize = bufferWidth * bufferHeight;
uint32_t* dataBufferIA4 = (uint32_t *)memalign(32, bufferSize);
memset(dataBufferIA4, 0x00, bufferSize);
uint32_t *src = (uint32_t *)rgbaBuffer;
uint8_t *dst = (uint8_t *)dataBufferIA4;
for (uint16_t y = 0; y < bufferHeight; y += 4) {
for (uint16_t x = 0; x < bufferWidth; x += 8) {
for (uint16_t rows = 0; rows < 4; rows++) {
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 0)]);
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 1)]);
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 2)]);
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 3)]);
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 4)]);
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 5)]);
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 6)]);
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 7)]);
}
}
}
DCFlushRange(dataBufferIA4, bufferSize);
return dataBufferIA4;
}
/**
* Downsample the specified RGBA value data buffer to an IA8 value.
*
* This routine downsamples the given RGBA data value into the IA8 texture data format.
*
* @param rgba A 32-bit RGBA value to convert to the IA8 format.
* @return The IA8 value of the given RGBA value.
*/
uint16_t Metaphrasis::convertRGBAToIA8(uint32_t rgba) {
uint8_t i, a;
i = (rgba >> 8) & 0xff;
a = (rgba ) & 0xff;
return (i << 8) | a;
}
/**
* Convert the specified RGBA data buffer into the IA8 texture format
*
* This routine converts the RGBA data buffer into the IA8 texture format and returns a pointer to the converted buffer.
*
* @param rgbaBuffer Buffer containing the temporarily rendered RGBA data.
* @param bufferWidth Pixel width of the data buffer.
* @param bufferHeight Pixel height of the data buffer.
* @return A pointer to the allocated buffer.
*/
uint32_t* Metaphrasis::convertBufferToIA8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) {
uint32_t bufferSize = (bufferWidth * bufferHeight) << 1;
uint32_t* dataBufferIA8 = (uint32_t *)memalign(32, bufferSize);
memset(dataBufferIA8, 0x00, bufferSize);
uint32_t *src = (uint32_t *)rgbaBuffer;
uint16_t *dst = (uint16_t *)dataBufferIA8;
for (uint16_t y = 0; y < bufferHeight; y += 4) {
for (uint16_t x = 0; x < bufferWidth; x += 4) {
for (uint16_t rows = 0; rows < 4; rows++) {
*dst++ = Metaphrasis::convertRGBAToIA8(src[((y + rows) * bufferWidth) + (x + 0)]);
*dst++ = Metaphrasis::convertRGBAToIA8(src[((y + rows) * bufferWidth) + (x + 1)]);
*dst++ = Metaphrasis::convertRGBAToIA8(src[((y + rows) * bufferWidth) + (x + 2)]);
*dst++ = Metaphrasis::convertRGBAToIA8(src[((y + rows) * bufferWidth) + (x + 3)]);
}
}
}
DCFlushRange(dataBufferIA8, bufferSize);
return dataBufferIA8;
}
/**
* Convert the specified RGBA data buffer into the RGBA8 texture format
*
* This routine converts the RGBA data buffer into the RGBA8 texture format and returns a pointer to the converted buffer.
*
* @param rgbaBuffer Buffer containing the temporarily rendered RGBA data.
* @param bufferWidth Pixel width of the data buffer.
* @param bufferHeight Pixel height of the data buffer.
* @return A pointer to the allocated buffer.
*/
uint32_t* Metaphrasis::convertBufferToRGBA8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) {
uint32_t bufferSize = (bufferWidth * bufferHeight) << 2;
uint32_t* dataBufferRGBA8 = (uint32_t *)memalign(32, bufferSize);
memset(dataBufferRGBA8, 0x00, bufferSize);
uint8_t *src = (uint8_t *)rgbaBuffer;
uint8_t *dst = (uint8_t *)dataBufferRGBA8;
for (uint16_t block = 0; block < bufferHeight; block += 4) {
for (uint16_t i = 0; i < bufferWidth; i += 4) {
for (uint16_t c = 0; c < 4; c++) {
for (uint16_t ar = 0; ar < 4; ar++) {
*dst++ = src[(((i + ar) + ((block + c) * bufferWidth)) * 4) + 3];
*dst++ = src[((i + ar) + ((block + c) * bufferWidth)) * 4];
}
}
for (uint16_t c = 0; c < 4; c++) {
for (uint16_t gb = 0; gb < 4; gb++) {
*dst++ = src[(((i + gb) + ((block + c) * bufferWidth)) * 4) + 1];
*dst++ = src[(((i + gb) + ((block + c) * bufferWidth)) * 4) + 2];
}
}
}
}
DCFlushRange(dataBufferRGBA8, bufferSize);
return dataBufferRGBA8;
}
/**
* Downsample the specified RGBA value data buffer to an RGB565 value.
*
* This routine downsamples the given RGBA data value into the RGB565 texture data format.
* Attribution for this routine is given fully to NoNameNo of GRRLIB Wii library.
*
* @param rgba A 32-bit RGBA value to convert to the RGB565 format.
* @return The RGB565 value of the given RGBA value.
*/
uint16_t Metaphrasis::convertRGBAToRGB565(uint32_t rgba) {
uint8_t r, g, b;
r = (((rgba >> 24) & 0xff) * 31) / 255;
g = (((rgba >> 16) & 0xff) * 63) / 255;
b = (((rgba >> 8) & 0xff) * 31) / 255;
return (((r << 6) | g ) << 5 ) | b;
}
/**
* Convert the specified RGBA data buffer into the RGB565 texture format
*
* This routine converts the RGBA data buffer into the RGB565 texture format and returns a pointer to the converted buffer.
*
* @param rgbaBuffer Buffer containing the temporarily rendered RGBA data.
* @param bufferWidth Pixel width of the data buffer.
* @param bufferHeight Pixel height of the data buffer.
* @return A pointer to the allocated buffer.
*/
uint32_t* Metaphrasis::convertBufferToRGB565(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) {
uint32_t bufferSize = (bufferWidth * bufferHeight) << 1;
uint32_t* dataBufferRGB565 = (uint32_t *)memalign(32, bufferSize);
memset(dataBufferRGB565, 0x00, bufferSize);
uint32_t *src = (uint32_t *)rgbaBuffer;
uint16_t *dst = (uint16_t *)dataBufferRGB565;
for (uint16_t y = 0; y < bufferHeight; y += 4) {
for (uint16_t x = 0; x < bufferWidth; x += 4) {
for (uint16_t rows = 0; rows < 4; rows++) {
*dst++ = Metaphrasis::convertRGBAToRGB565(src[((y + rows) * bufferWidth) + (x + 0)]);
*dst++ = Metaphrasis::convertRGBAToRGB565(src[((y + rows) * bufferWidth) + (x + 1)]);
*dst++ = Metaphrasis::convertRGBAToRGB565(src[((y + rows) * bufferWidth) + (x + 2)]);
*dst++ = Metaphrasis::convertRGBAToRGB565(src[((y + rows) * bufferWidth) + (x + 3)]);
}
}
}
DCFlushRange(dataBufferRGB565, bufferSize);
return dataBufferRGB565;
}
/**
* Downsample the specified RGBA value data buffer to an RGB5A3 value.
*
* This routine downsamples the given RGBA data value into the RGB5A3 texture data format.
* Attribution for this routine is given fully to WiiGator via the TehSkeen forum.
*
* @param rgba A 32-bit RGBA value to convert to the RGB5A3 format.
* @return The RGB5A3 value of the given RGBA value.
*/
uint16_t Metaphrasis::convertRGBAToRGB5A3(uint32_t rgba) {
uint32_t r, g, b, a;
uint16_t color;
r = (rgba >> 24) & 0xff;
g = (rgba >> 16) & 0xff;
b = (rgba >> 8) & 0xff;
a = (rgba ) & 0xff;
if (a > 0xe0) {
r = r >> 3;
g = g >> 3;
b = b >> 3;
color = (r << 10) | (g << 5) | b;
color |= 0x8000;
} else {
r = r >> 4;
g = g >> 4;
b = b >> 4;
a = a >> 5;
color = (a << 12) | (r << 8) | (g << 4) | b;
}
return color;
}
/**
* Convert the specified RGBA data buffer into the RGB5A3 texture format
*
* This routine converts the RGBA data buffer into the RGB5A3 texture format and returns a pointer to the converted buffer.
*
* @param rgbaBuffer Buffer containing the temporarily rendered RGBA data.
* @param bufferWidth Pixel width of the data buffer.
* @param bufferHeight Pixel height of the data buffer.
* @return A pointer to the allocated buffer.
*/
uint32_t* Metaphrasis::convertBufferToRGB5A3(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) {
uint32_t bufferSize = (bufferWidth * bufferHeight) << 1;
uint32_t* dataBufferRGB5A3 = (uint32_t *)memalign(32, bufferSize);
memset(dataBufferRGB5A3, 0x00, bufferSize);
uint32_t *src = (uint32_t *)rgbaBuffer;
uint16_t *dst = (uint16_t *)dataBufferRGB5A3;
for (uint16_t y = 0; y < bufferHeight; y += 4) {
for (uint16_t x = 0; x < bufferWidth; x += 4) {
for (uint16_t rows = 0; rows < 4; rows++) {
*dst++ = Metaphrasis::convertRGBAToRGB5A3(src[((y + rows) * bufferWidth) + (x + 0)]);
*dst++ = Metaphrasis::convertRGBAToRGB5A3(src[((y + rows) * bufferWidth) + (x + 1)]);
*dst++ = Metaphrasis::convertRGBAToRGB5A3(src[((y + rows) * bufferWidth) + (x + 2)]);
*dst++ = Metaphrasis::convertRGBAToRGB5A3(src[((y + rows) * bufferWidth) + (x + 3)]);
}
}
}
DCFlushRange(dataBufferRGB5A3, bufferSize);
return dataBufferRGB5A3;
}

View File

@ -1,116 +0,0 @@
/*
* Metaphrasis is a static conversion class for transforming RGBA image
* buffers into verious GX texture formats for Wii homebrew development.
* Copyright (C) 2008 Armin Tamzarian
*
* This file is part of Metaphrasis.
*
* Metaphrasis is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Metaphrasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Metaphrasis. If not, see <http://www.gnu.org/licenses/>.
*/
/** \mainpage Metaphrasis
*
* \section sec_intro Introduction
*
* Metaphrasis is a static conversion class for transforming RGBA image buffers into verious GX texture formats for Wii homebrew development.
* <br>
* Metaphrasis is written in C++ and makes use of a community standard and newly developed algorithms for conversion of 32-bit RGBA data buffers into various GX texture formats common to both the Gamecube and Wii platforms.
* <p>
* This library was developed in-full by Armin Tamzarian with the support of developers in \#wiibrew on EFnet, Chaosteil of libwiisprite, and DrTwox of GRRLIB.
*
* \section sec_installation_source Installation (Source Code)
*
* -# Extract the Metaphrasis archive.
* -# Copy the contents of the <i>src</i> directory into your project's development path.
* -# Include the Metaphrasis header file in your code using syntax such as the following:
* \code
* #include "Metaphrasis.h"
* \endcode
*
* \section sec_installation_library Installation (Library)
*
* -# Extract the Metaphrasis archive.
* -# Copy the contents of the <i>lib</i> directory into your <i>devKitPro/libogc</i> directory.
* -# Include the Metaphrasis header file in your code using syntax such as the following:
* \code
* #include "Metaphrasis.h"
* \endcode
*
* \section sec_usage Usage
*
* -# Create a buffer full of 32-bit RGBA values noting both the pixel height and width of the buffer.
* -# Call one of the many conversion routines from within your code. (Note: All methods within the Metaphrasis class are static and thus no class instance need be allocated)
* \code
* uint32_t* rgba8Buffer = Metaphrasis::convertBufferToRGBA8(rgbaBuffer, bufferWidth, bufferHeight);
* \endcode
* -# Free your temporary RGBA value buffer if you no longer need said values.
*
* Currently supported conversion routines are as follows:
* \li convertBufferToI4
* \li convertBufferToI8
* \li convertBufferToIA4
* \li convertBufferToIA8
* \li convertBufferToRGBA8
* \li convertBufferToRGB565
* \li convertBufferToRGB5A3
*
* \section sec_license License
*
* Metaphrasis is distributed under the GNU Lesser General Public License.
*
* \section sec_contact Contact
*
* If you have any suggestions, questions, or comments regarding this library feel free to e-mail me at tamzarian1989 [at] gmail [dawt] com.
*/
#ifndef METAPHRASIS_H_
#define METAPHRASIS_H_
#include <gccore.h>
#include <stdint.h>
#include <malloc.h>
#include <string.h>
/*! \class Metaphrasis
* \brief A static conversion class for transforming RGBA image buffers into verious GX texture formats for
* Wii homebrew development.
* \author Armin Tamzarian
* \version 0.1.0
*
* Metaphrasis is a static conversion class for transforming RGBA image buffers into verious GX texture formats for
* Wii homebrew development. Metaphrasis is written in C++ and makes use of a community standard and newly developed
* algorithms for conversion of 32-bit RGBA data buffers into various GX texture formats common to both the Gamecube
* and Wii platforms.
*/
class Metaphrasis {
public:
Metaphrasis();
virtual ~Metaphrasis();
static uint32_t* convertBufferToI4(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight);
static uint32_t* convertBufferToI8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight);
static uint32_t* convertBufferToIA4(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight);
static uint32_t* convertBufferToIA8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight);
static uint32_t* convertBufferToRGBA8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight);
static uint32_t* convertBufferToRGB565(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight);
static uint32_t* convertBufferToRGB5A3(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight);
static uint8_t convertRGBAToIA4(uint32_t rgba);
static uint16_t convertRGBAToIA8(uint32_t rgba);
static uint16_t convertRGBAToRGB565(uint32_t rgba);
static uint16_t convertRGBAToRGB5A3(uint32_t rgba);
};
#endif /*METAPHRASIS_H_*/

BIN
source/Wiiload.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

271
source/Wiiload.nsi Normal file
View File

@ -0,0 +1,271 @@
;Website: http://code.google.com/p/usbloader-gui/
;Copyright 2009 NeoRame
;This program is free software: you can redistribute it and/or modify
;it under the terms of the GNU General Public License as published by
;the Free Software Foundation, either version 3 of the License, or
;(at your option) any later version.
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;GNU General Public License for more details.
;You should have received a copy of the GNU General Public License
;along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.html.
!define TEMP2 $R1 ;Temp variable
!define TEMP3 $R2 ;Temp variable
!define TEMP4 $R3 ;Temp variable
!define TEMP5 $R4 ;Temp variable
!include "InstallOptions.nsh"
!include "LogicLib.nsh"
!include InstallerConfig.nsh
!define SHCNE_ASSOCCHANGED 0x08000000
!define SHCNF_IDLIST 0
;=== Program Details
Name "${NAME2}"
OutFile "..\${FILENAME}.exe"
InstallDir "$PROGRAMFILES\${NAME}"
Caption "${NAME2} Installer"
VIProductVersion "${VERSION}"
VIAddVersionKey ProductName "${NAME2}"
VIAddVersionKey Comments "For more informations please visit http://code.google.com/p/usbloader-gui/"
VIAddVersionKey CompanyName "${TEAM}"
VIAddVersionKey LegalCopyright "${TEAM}"
VIAddVersionKey FileDescription "${NAME2}"
VIAddVersionKey FileVersion "${VERSION}"
VIAddVersionKey ProductVersion "${VERSION}"
VIAddVersionKey InternalName "${NAME}"
VIAddVersionKey LegalTrademarks "${NAME2} installer created by ${TEAM}."
VIAddVersionKey OriginalFilename "${FILENAME}.exe"
;=== Runtime Switches
SetCompressor /SOLID lzma
CRCCheck on
AutoCloseWindow True
ShowInstDetails nevershow
ShowUnInstDetails nevershow
;=== Include Modern UI
!include "MUI.nsh"
;=== General
;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\${NAME}" ""
;=== Interface Settings
!define MUI_ABORTWARNING
;===Language Selection Dialog Settings
;Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "Software\${NAME}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
;=== Program Icon
Icon "files\${NAME}.ico"
;=== Icon & Style ===
!define MUI_ICON "files\${NAME}.ico"
BrandingText "${NAME2} - Easy Setup for Dummys!"
!define MUI_WELCOMEFINISHPAGE_BITMAP ${NAME}.bmp
!insertmacro MUI_PAGE_WELCOME
Page custom SetCustom ValidateCustom ": Enter IP" ;Custom page. InstallOptions gets called in SetCustom.
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
;=== Languages
!insertmacro MUI_LANGUAGE "ENGLISH" ;first language is the default language
;Things that need to be extracted on startup (keep these lines before ;any File command!)
;Use ReserveFile for your own InstallOptions INI files too!
ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
ReserveFile "IPPage.ini"
;=====Install Section
Section "Components"
;Get Install Options dialog user input
ReadINIStr ${TEMP2} "$PLUGINSDIR\IPPage.ini" "Field 3" "State"
ReadINIStr ${TEMP3} "$PLUGINSDIR\IPPage.ini" "Field 4" "State"
ReadINIStr ${TEMP4} "$PLUGINSDIR\IPPage.ini" "Field 5" "State"
ReadINIStr ${TEMP5} "$PLUGINSDIR\IPPage.ini" "Field 6" "State"
; App Install
SetOutPath $SYSDIR
File /r "Files\${NAME}.exe"
SetOutPath $INSTDIR
File /r "Files\*.ico"
File /r "Files\*SendElf.exe"
CreateDirectory "$SMPROGRAMS\${NAME}"
WriteUninstaller $INSTDIR\Uninstall.exe
CreateShortCut "$SMPROGRAMS\${NAME}\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
CreateShortCut "$SMPROGRAMS\${NAME}\SendElf.lnk" "$INSTDIR\SendElf.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "DisplayName" "${NAME}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "DisplayVersion" "${VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "Publisher" "${TEAM}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "URLInfoAbout" "${URL}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "DisplayIcon" "$INSTDIR\${NAME}.ico"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
WriteRegStr HKCU "SOFTWARE\TCP Loader" 'Ip' '${TEMP2}.${TEMP3}.${TEMP4}.${TEMP5}'
WriteRegStr HKCU "SOFTWARE\TCP Loader" 'Port' '4299'
WriteRegStr HKCU "SOFTWARE\TCP Loader" 'File' ''
;=== WIILOAD TCP Stuff
; include for some of the windows messages defines
!include "winmessages.nsh"
; HKLM (all users) vs HKCU (current user) defines
!define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
!define env_hkcu 'HKCU "Environment"'
; set variable
WriteRegExpandStr ${env_hkcu} WIILOAD tcp:${TEMP2}.${TEMP3}.${TEMP4}.${TEMP5}
; make sure windows knows about the change
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
;=== Context Menu (Send to Wii)
WriteRegStr HKCR ".dol" "" ""
WriteRegStr HKCR ".dol\DefaultIcon" "" "$PROGRAMFILES\${NAME}\DOL.ico"
WriteRegStr HKCR ".dol\shell\Send to Wii\command" "" `c:\windows\system32\wiiload.exe "%1"`
WriteRegStr HKCR ".elf" "" ""
WriteRegStr HKCR ".elf\DefaultIcon" "" "$PROGRAMFILES\${NAME}\ELF.ico"
WriteRegStr HKCR ".elf\shell\Send to Wii\command" "" `c:\windows\system32\wiiload.exe "%1"`
WriteRegStr HKCR ".wad" "" ""
WriteRegStr HKCR ".wad\DefaultIcon" "" "$PROGRAMFILES\${NAME}\WAD.ico"
WriteRegStr HKCR ".wad\shell\Send to Wii\command" "" `c:\windows\system32\wiiload.exe "%1"`
;=== Context Menu (Send to Wii [SendElf])
WriteRegStr HKCR ".wad\shell\Send to Wii [SendElf]\command" "" `$PROGRAMFILES\${NAME}\SendElf.exe /send /noshow /file "%1"`
Delete $exedir\.ini
Call RefreshShellIcons
SectionEnd
;=== Functions
Function .onInit
;Extract InstallOptions files
;$PLUGINSDIR will automatically be removed when the installer closes
InitPluginsDir
File /oname=$PLUGINSDIR\IPPage.ini "IPPage.ini"
FunctionEnd
Function SetCustom
;Display the InstallOptions dialog
InstallOptions::dialog "$PLUGINSDIR\IPPage.ini"
FunctionEnd
; Textbfields Input check
Function ValidateCustom
!insertmacro INSTALLOPTIONS_READ ${TEMP2} "IPPage.ini" "Field 3" "State"
StrCmp ${TEMP2} "" 0 +3
MessageBox MB_ICONEXCLAMATION|MB_OK "Please enter your Wii IP."
Abort
!insertmacro INSTALLOPTIONS_READ ${TEMP3} "IPPage.ini" "Field 4" "State"
StrCmp ${TEMP3} "" 0 +3
MessageBox MB_ICONEXCLAMATION|MB_OK "Please enter your Wii IP."
Abort
!insertmacro INSTALLOPTIONS_READ ${TEMP4} "IPPage.ini" "Field 5" "State"
StrCmp ${TEMP4} "" 0 +3
MessageBox MB_ICONEXCLAMATION|MB_OK "Please enter your Wii IP."
Abort
!insertmacro INSTALLOPTIONS_READ ${TEMP5} "IPPage.ini" "Field 6" "State"
StrCmp ${TEMP5} "" 0 +3
MessageBox MB_ICONEXCLAMATION|MB_OK "Please enter your Wii IP."
Abort
FunctionEnd
; Funtion Icon refresh
Function RefreshShellIcons
; By jerome tremblay - april 2003
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v \
(${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
FunctionEnd
;=== Uninstaller Section ===
;=== Unistall Functions
Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
FunctionEnd
; Funtion Icon refresh
Function Un.RefreshShellIcons
; By jerome tremblay - april 2003
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v \
(${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
FunctionEnd
; Messagebox Done!
Function un.onUninstSuccess
MessageBox MB_OK "${NAME} uninstalled successfully."
FunctionEnd
;=== Uninstaller
Section "Uninstall"
; delete App and his stuff
Delete "$SMPROGRAMS\${NAME}\Uninstall.lnk"
Delete "$SMPROGRAMS\${NAME}\SendElf.lnk"
Delete "$INSTDIR\*.*"
Delete "$SYSDIR\${NAME}.exe"
RMDir "$SMPROGRAMS\${NAME}"
RMDir $INSTDIR
SetAutoClose true
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\${NAME}"
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}"
DeleteRegKey /ifempty HKCU "Software\${NAME}"
;=== WIILOAD TCP Uninstall Stuff
; delete variable
DeleteRegValue ${env_hkcu} WIILOAD
; make sure windows knows about the change
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
; delete RegKeys
DeleteRegkey HKCR ".dol\shell\Send to Wii\command"
DeleteRegkey HKCR ".dol\shell\Send to Wii"
DeleteRegkey HKCR ".dol\DefaultIcon"
DeleteRegkey HKCR ".dol\shell"
DeleteRegkey HKCR ".dol"
DeleteRegkey HKCR ".elf\shell\Send to Wii\command"
DeleteRegkey HKCR ".elf\shell\Send to Wii"
DeleteRegkey HKCR ".elf\DefaultIcon"
DeleteRegkey HKCR ".elf\shell"
DeleteRegkey HKCR ".elf"
DeleteRegkey HKCR ".wad\shell\Send to Wii\command"
DeleteRegkey HKCR ".wad\shell\Send to Wii"
DeleteRegkey HKCR ".wad\shell\Send to Wii [SendElf]\command"
DeleteRegkey HKCR ".wad\shell\Send to Wii [SendElf]"
DeleteRegkey HKCR ".wad\DefaultIcon"
DeleteRegkey HKCR ".wad\shell"
DeleteRegkey HKCR ".wad"
DeleteRegkey HKCU "SOFTWARE\TCP Loader"
; Icon refresh
Call Un.RefreshShellIcons
SectionEnd

View File

@ -1,33 +0,0 @@
/****************************************************************************
* libwiigui Template
* Tantric 2009
*
* audio.cpp
* Audio support
***************************************************************************/
#include <gccore.h>
#include <ogcsys.h>
#include <asndlib.h>
/****************************************************************************
* InitAudio
*
* Initializes the Wii's audio subsystem
***************************************************************************/
void InitAudio() {
AUDIO_Init(NULL);
ASND_Init();
ASND_Pause(0);
}
/****************************************************************************
* ShutdownAudio
*
* Shuts down audio subsystem. Useful to avoid unpleasant sounds if a
* crash occurs during shutdown.
***************************************************************************/
void ShutdownAudio() {
ASND_Pause(1);
ASND_End();
}

View File

@ -1,15 +0,0 @@
/****************************************************************************
* libwiigui Template
* Tantric 2009
*
* audio.h
* Audio support
***************************************************************************/
#ifndef _AUDIO_H_
#define _AUDIO_H_
void InitAudio();
void ShutdownAudio();
#endif

View File

@ -1,592 +0,0 @@
/* ========================================================================== **
*
* MD5.c
*
* Copyright:
* Copyright (C) 2003-2005 by Christopher R. Hertel
*
* Email: crh@ubiqx.mn.org
*
* $Id: MD5.c,v 0.6 2005/06/08 18:35:59 crh Exp $
*
*
* Modified by dimok
*
* -------------------------------------------------------------------------- **
*
* Description:
* Implements the MD5 hash algorithm, as described in RFC 1321.
*
* -------------------------------------------------------------------------- **
*
* License:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* -------------------------------------------------------------------------- **
*
* Notes:
*
* None of this will make any sense unless you're studying RFC 1321 as you
* read the code.
*
* MD5 is described in RFC 1321.
* The MD*4* algorithm is described in RFC 1320 (that's 1321 - 1).
* MD5 is very similar to MD4, but not quite similar enough to justify
* putting the two into a single module. Besides, I wanted to add a few
* extra functions to this one to expand its usability.
*
* There are three primary motivations for this particular implementation.
* 1) Programmer's pride. I wanted to be able to say I'd done it, and I
* wanted to learn from the experience.
* 2) Portability. I wanted an implementation that I knew to be portable
* to a reasonable number of platforms. In particular, the algorithm is
* designed with little-endian platforms in mind, but I wanted an
* endian-agnostic implementation.
* 3) Compactness. While not an overriding goal, I thought it worth-while
* to see if I could reduce the overall size of the result. This is in
* keeping with my hopes that this library will be suitable for use in
* some embedded environments.
* Beyond that, cleanliness and clarity are always worth pursuing.
*
* As mentioned above, the code really only makes sense if you are familiar
* with the MD5 algorithm or are using RFC 1321 as a guide. This code is
* quirky, however, so you'll want to be reading carefully.
*
* Yeah...most of the comments are cut-and-paste from my MD4 implementation.
*
* -------------------------------------------------------------------------- **
*
* References:
* IETF RFC 1321: The MD5 Message-Digest Algorithm
* Ron Rivest. IETF, April, 1992
*
* ========================================================================== **
*/
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <ogcsys.h>
#include "MD5.h"
/* -------------------------------------------------------------------------- **
* Static Constants:
*
* K[][] - In round one, the values of k (which are used to index
* particular four-byte sequences in the input) are simply
* sequential. In later rounds, however, they are a bit more
* varied. Rather than calculate the values of k (which may
* or may not be possible--I haven't though about it) the
* values are stored in this array.
*
* S[][] - In each round there is a left rotate operation performed as
* part of the 16 permutations. The number of bits varies in
* a repeating patter. This array keeps track of the patterns
* used in each round.
*
* T[][] - There are four rounds of 16 permutations for a total of 64.
* In each of these 64 permutation operations, a different
* constant value is added to the mix. The constants are
* based on the sine function...read RFC 1321 for more detail.
* In any case, the correct constants are stored in the T[][]
* array. They're divided up into four groups of 16.
*/
static const uint8_t K[3][16] =
{
/* Round 1: skipped (since it is simply sequential). */
{ 1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12 }, /* R2 */
{ 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2 }, /* R3 */
{ 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9 } /* R4 */
};
static const uint8_t S[4][4] =
{
{ 7, 12, 17, 22 }, /* Round 1 */
{ 5, 9, 14, 20 }, /* Round 2 */
{ 4, 11, 16, 23 }, /* Round 3 */
{ 6, 10, 15, 21 } /* Round 4 */
};
static const uint32_t T[4][16] =
{
{ 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, /* Round 1 */
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821 },
{ 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, /* Round 2 */
0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a },
{ 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, /* Round 3 */
0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665 },
{ 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, /* Round 4 */
0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 },
};
/* -------------------------------------------------------------------------- **
* Macros:
* md5F(), md5G(), md5H(), and md5I() are described in RFC 1321.
* All of these operations are bitwise, and so not impacted by endian-ness.
*
* GetLongByte()
* Extract one byte from a (32-bit) longword. A value of 0 for <idx>
* indicates the lowest order byte, while 3 indicates the highest order
* byte.
*
*/
#define md5F( X, Y, Z ) ( ((X) & (Y)) | ((~(X)) & (Z)) )
#define md5G( X, Y, Z ) ( ((X) & (Z)) | ((Y) & (~(Z))) )
#define md5H( X, Y, Z ) ( (X) ^ (Y) ^ (Z) )
#define md5I( X, Y, Z ) ( (Y) ^ ((X) | (~(Z))) )
#define GetLongByte( L, idx ) ((unsigned char)(( L >> (((idx) & 0x03) << 3) ) & 0xFF))
/* -------------------------------------------------------------------------- **
* Static Functions:
*/
static void Permute( uint32_t ABCD[4], const unsigned char block[64] )
/* ------------------------------------------------------------------------ **
* Permute the ABCD "registers" using the 64-byte <block> as a driver.
*
* Input: ABCD - Pointer to an array of four unsigned longwords.
* block - An array of bytes, 64 bytes in size.
*
* Output: none.
*
* Notes: The MD5 algorithm operates on a set of four longwords stored
* (conceptually) in four "registers". It is easy to imagine a
* simple MD4/5 chip that would operate this way. In any case,
* the mangling of the contents of those registers is driven by
* the input message. The message is chopped and finally padded
* into 64-byte chunks and each chunk is used to manipulate the
* contents of the registers.
*
* The MD5 Algorithm calls for padding the input to ensure that
* it is a multiple of 64 bytes in length. The last 16 bytes
* of the padding space are used to store the message length
* (the length of the original message, before padding, expressed
* in terms of bits). If there is not enough room for 16 bytes
* worth of bitcount (eg., if the original message was 122 bytes
* long) then the block is padded to the end with zeros and
* passed to this function. Then *another* block is filled with
* zeros except for the last 16 bytes which contain the length.
*
* Oh... and the algorithm requires that there be at least one
* padding byte. The first padding byte has a value of 0x80,
* and any others are 0x00.
*
* ------------------------------------------------------------------------ **
*/
{
int round;
int i, j;
uint8_t s;
uint32_t a, b, c, d;
uint32_t KeepABCD[4];
uint32_t X[16];
/* Store the current ABCD values for later re-use.
*/
for( i = 0; i < 4; i++ )
KeepABCD[i] = ABCD[i];
/* Convert the input block into an array of unsigned longs, taking care
* to read the block in Little Endian order (the algorithm assumes this).
* The uint32_t values are then handled in host order.
*/
for( i = 0, j = 0; i < 16; i++ )
{
X[i] = (uint32_t)block[j++];
X[i] |= ((uint32_t)block[j++] << 8);
X[i] |= ((uint32_t)block[j++] << 16);
X[i] |= ((uint32_t)block[j++] << 24);
}
/* This loop performs the four rounds of permutations.
* The rounds are each very similar. The differences are in three areas:
* - The function (F, G, H, or I) used to perform bitwise permutations
* on the registers,
* - The order in which values from X[] are chosen.
* - Changes to the number of bits by which the registers are rotated.
* This implementation uses a switch statement to deal with some of the
* differences between rounds. Other differences are handled by storing
* values in arrays and using the round number to select the correct set
* of values.
*
* (My implementation appears to be a poor compromise between speed, size,
* and clarity. Ugh. [crh])
*/
for( round = 0; round < 4; round++ )
{
for( i = 0; i < 16; i++ )
{
j = (4 - (i % 4)) & 0x3; /* <j> handles the rotation of ABCD. */
s = S[round][i%4]; /* <s> is the bit shift for this iteration. */
b = ABCD[(j+1) & 0x3]; /* Copy the b,c,d values per ABCD rotation. */
c = ABCD[(j+2) & 0x3]; /* This isn't really necessary, it just looks */
d = ABCD[(j+3) & 0x3]; /* clean & will hopefully be optimized away. */
/* The actual perumation function.
* This is broken out to minimize the code within the switch().
*/
switch( round )
{
case 0:
/* round 1 */
a = md5F( b, c, d ) + X[i];
break;
case 1:
/* round 2 */
a = md5G( b, c, d ) + X[ K[0][i] ];
break;
case 2:
/* round 3 */
a = md5H( b, c, d ) + X[ K[1][i] ];
break;
default:
/* round 4 */
a = md5I( b, c, d ) + X[ K[2][i] ];
break;
}
a = 0xFFFFFFFF & ( ABCD[j] + a + T[round][i] );
ABCD[j] = b + (0xFFFFFFFF & (( a << s ) | ( a >> (32 - s) )));
}
}
/* Use the stored original A, B, C, D values to perform
* one last convolution.
*/
for( i = 0; i < 4; i++ )
ABCD[i] = 0xFFFFFFFF & ( ABCD[i] + KeepABCD[i] );
} /* Permute */
/* -------------------------------------------------------------------------- **
* Functions:
*/
auth_md5Ctx *auth_md5InitCtx( auth_md5Ctx *ctx )
/* ------------------------------------------------------------------------ **
* Initialize an MD5 context.
*
* Input: ctx - A pointer to the MD5 context structure to be initialized.
* Contexts are typically created thusly:
* ctx = (auth_md5Ctx *)malloc( sizeof(auth_md5Ctx) );
*
* Output: A pointer to the initialized context (same as <ctx>).
*
* Notes: The purpose of the context is to make it possible to generate
* an MD5 Message Digest in stages, rather than having to pass a
* single large block to a single MD5 function. The context
* structure keeps track of various bits of state information.
*
* Once the context is initialized, the blocks of message data
* are passed to the <auth_md5SumCtx()> function. Once the
* final bit of data has been handed to <auth_md5SumCtx()> the
* context can be closed out by calling <auth_md5CloseCtx()>,
* which also calculates the final MD5 result.
*
* Don't forget to free an allocated context structure when
* you've finished using it.
*
* See Also: <auth_md5SumCtx()>, <auth_md5CloseCtx()>
*
* ------------------------------------------------------------------------ **
*/
{
ctx->len = 0;
ctx->b_used = 0;
ctx->ABCD[0] = 0x67452301; /* The array ABCD[] contains the four 4-byte */
ctx->ABCD[1] = 0xefcdab89; /* "registers" that are manipulated to */
ctx->ABCD[2] = 0x98badcfe; /* produce the MD5 digest. The input acts */
ctx->ABCD[3] = 0x10325476; /* upon the registers, not the other way */
/* 'round. The initial values are those */
/* given in RFC 1321 (pg. 4). Note, however, that RFC 1321 */
/* provides these values as bytes, not as longwords, and the */
/* bytes are arranged in little-endian order as if they were */
/* the bytes of (little endian) 32-bit ints. That's */
/* confusing as all getout (to me, anyway). The values given */
/* here are provided as 32-bit values in C language format, */
/* so they are endian-agnostic. */
return( ctx );
} /* auth_md5InitCtx */
auth_md5Ctx *auth_md5SumCtx( auth_md5Ctx *ctx,
const unsigned char *src,
const int len )
/* ------------------------------------------------------------------------ **
* Build an MD5 Message Digest within the given context.
*
* Input: ctx - Pointer to the context in which the MD5 sum is being
* built.
* src - A chunk of source data. This will be used to drive
* the MD5 algorithm.
* len - The number of bytes in <src>.
*
* Output: A pointer to the updated context (same as <ctx>).
*
* See Also: <auth_md5InitCtx()>, <auth_md5CloseCtx()>, <auth_md5Sum()>
*
* ------------------------------------------------------------------------ **
*/
{
int i;
/* Add the new block's length to the total length.
*/
ctx->len += (uint32_t)len;
/* Copy the new block's data into the context block.
* Call the Permute() function whenever the context block is full.
*/
for( i = 0; i < len; i++ )
{
ctx->block[ ctx->b_used ] = src[i];
(ctx->b_used)++;
if( 64 == ctx->b_used )
{
Permute( ctx->ABCD, ctx->block );
ctx->b_used = 0;
}
}
/* Return the updated context.
*/
return( ctx );
} /* auth_md5SumCtx */
auth_md5Ctx *auth_md5CloseCtx( auth_md5Ctx *ctx, unsigned char *dst )
/* ------------------------------------------------------------------------ **
* Close an MD5 Message Digest context and generate the final MD5 sum.
*
* Input: ctx - Pointer to the context in which the MD5 sum is being
* built.
* dst - A pointer to at least 16 bytes of memory, which will
* receive the finished MD5 sum.
*
* Output: A pointer to the closed context (same as <ctx>).
* You might use this to free a malloc'd context structure. :)
*
* Notes: The context (<ctx>) is returned in an undefined state.
* It must be re-initialized before re-use.
*
* See Also: <auth_md5InitCtx()>, <auth_md5SumCtx()>
*
* ------------------------------------------------------------------------ **
*/
{
int i;
uint32_t l;
/* Add the required 0x80 padding initiator byte.
* The auth_md5SumCtx() function always permutes and resets the context
* block when it gets full, so we know that there must be at least one
* free byte in the context block.
*/
ctx->block[ctx->b_used] = 0x80;
(ctx->b_used)++;
/* Zero out any remaining free bytes in the context block.
*/
for( i = ctx->b_used; i < 64; i++ )
ctx->block[i] = 0;
/* We need 8 bytes to store the length field.
* If we don't have 8, call Permute() and reset the context block.
*/
if( 56 < ctx->b_used )
{
Permute( ctx->ABCD, ctx->block );
for( i = 0; i < 64; i++ )
ctx->block[i] = 0;
}
/* Add the total length and perform the final perumation.
* Note: The 60'th byte is read from the *original* <ctx->len> value
* and shifted to the correct position. This neatly avoids
* any MAXINT numeric overflow issues.
*/
l = ctx->len << 3;
for( i = 0; i < 4; i++ )
ctx->block[56+i] |= GetLongByte( l, i );
ctx->block[60] = ((GetLongByte( ctx->len, 3 ) & 0xE0) >> 5); /* See Above! */
Permute( ctx->ABCD, ctx->block );
/* Now copy the result into the output buffer and we're done.
*/
for( i = 0; i < 4; i++ )
{
dst[ 0+i] = GetLongByte( ctx->ABCD[0], i );
dst[ 4+i] = GetLongByte( ctx->ABCD[1], i );
dst[ 8+i] = GetLongByte( ctx->ABCD[2], i );
dst[12+i] = GetLongByte( ctx->ABCD[3], i );
}
/* Return the context.
* This is done for compatibility with the other auth_md5*Ctx() functions.
*/
return( ctx );
} /* auth_md5CloseCtx */
unsigned char * MD5(unsigned char *dst, const unsigned char *src, const int len )
/* ------------------------------------------------------------------------ **
* Compute an MD5 message digest.
*
* Input: dst - Destination buffer into which the result will be written.
* Must be 16 bytes, minimum.
* src - Source data block to be MD5'd.
* len - The length, in bytes, of the source block.
* (Note that the length is given in bytes, not bits.)
*
* Output: A pointer to <dst>, which will contain the calculated 16-byte
* MD5 message digest.
*
* Notes: This function is a shortcut. It takes a single input block.
* For more drawn-out operations, see <auth_md5InitCtx()>.
*
* This function is interface-compatible with the
* <auth_md4Sum()> function in the MD4 module.
*
* The MD5 algorithm is designed to work on data with an
* arbitrary *bit* length. Most implementations, this one
* included, handle the input data in byte-sized chunks.
*
* The MD5 algorithm does much of its work using four-byte
* words, and so can be tuned for speed based on the endian-ness
* of the host. This implementation is intended to be
* endian-neutral, which may make it a teeny bit slower than
* others. ...maybe.
*
* See Also: <auth_md5InitCtx()>
*
* ------------------------------------------------------------------------ **
*/
{
auth_md5Ctx ctx[1];
(void)auth_md5InitCtx( ctx ); /* Open a context. */
(void)auth_md5SumCtx( ctx, src, len ); /* Pass only one block. */
(void)auth_md5CloseCtx( ctx, dst ); /* Close the context. */
return( dst ); /* Makes life easy. */
} /* auth_md5Sum */
unsigned char * MD5fromFile(unsigned char *dst, const char *src)
/* ------------------------------------------------------------------------ **
* Compute an MD5 message digest.
*
* Input: dst - Destination buffer into which the result will be written.
* Must be 16 bytes, minimum.
* src - filepath of the file to be checked
*
* Output: A pointer to <dst>, which will contain the calculated 16-byte
* MD5 message digest.
*
* Notes: This function is a shortcut. It takes a single input block.
* For more drawn-out operations, see <auth_md5InitCtx()>.
*
* This function is interface-compatible with the
* <auth_md4Sum()> function in the MD4 module.
*
* The MD5 algorithm is designed to work on data with an
* arbitrary *bit* length. Most implementations, this one
* included, handle the input data in byte-sized chunks.
*
* The MD5 algorithm does much of its work using four-byte
* words, and so can be tuned for speed based on the endian-ness
* of the host. This implementation is intended to be
* endian-neutral, which may make it a teeny bit slower than
* others. ...maybe.
*
* See Also: <auth_md5InitCtx()>
*
* ------------------------------------------------------------------------ **
*/
{
auth_md5Ctx ctx[1];
FILE * file;
u32 blksize = 0;
u32 read = 0;
file = fopen(src, "rb");
if (file==NULL){
return NULL;
}
(void)auth_md5InitCtx( ctx ); /* Open a context. */
fseek (file , 0 , SEEK_END);
u64 filesize = ftell(file);
rewind (file);
if(filesize < 1048576) //1MB cache for files bigger than 1 MB
blksize = filesize;
else
blksize = 1048576;
unsigned char * buffer = malloc(blksize);
if(buffer == NULL){
//no memory
fclose(file);
return NULL;
}
do
{
read = fread(buffer, 1, blksize, file);
(void)auth_md5SumCtx( ctx, buffer, read ); /* Pass only one block. */
} while(read > 0);
fclose(file);
free(buffer);
(void)auth_md5CloseCtx( ctx, dst ); /* Close the context. */
return( dst ); /* Makes life easy. */
} /* auth_md5Sum */
/* ========================================================================== */

View File

@ -1,242 +0,0 @@
#ifndef MD5_H
#define MD5_H
#ifdef __cplusplus
extern "C"
{
#endif
/* ========================================================================== **
*
* MD5.h
*
* Copyright:
* Copyright (C) 2003-2005 by Christopher R. Hertel
*
* Email: crh@ubiqx.mn.org
*
* $Id: MD5.h,v 0.6 2005/06/08 18:35:59 crh Exp $
*
* -------------------------------------------------------------------------- **
*
* Description:
* Implements the MD5 hash algorithm, as described in RFC 1321.
*
* -------------------------------------------------------------------------- **
*
* License:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* -------------------------------------------------------------------------- **
*
* Notes:
*
* None of this will make any sense unless you're studying RFC 1321 as you
* read the code.
*
* MD5 is described in RFC 1321.
* The MD*4* algorithm is described in RFC 1320 (that's 1321 - 1).
* MD5 is very similar to MD4, but not quite similar enough to justify
* putting the two into a single module. Besides, I wanted to add a few
* extra functions to this one to expand its usability.
*
* There are three primary motivations for this particular implementation.
* 1) Programmer's pride. I wanted to be able to say I'd done it, and I
* wanted to learn from the experience.
* 2) Portability. I wanted an implementation that I knew to be portable
* to a reasonable number of platforms. In particular, the algorithm is
* designed with little-endian platforms in mind, but I wanted an
* endian-agnostic implementation.
* 3) Compactness. While not an overriding goal, I thought it worth-while
* to see if I could reduce the overall size of the result. This is in
* keeping with my hopes that this library will be suitable for use in
* some embedded environments.
* Beyond that, cleanliness and clarity are always worth pursuing.
*
* As mentioned above, the code really only makes sense if you are familiar
* with the MD5 algorithm or are using RFC 1321 as a guide. This code is
* quirky, however, so you'll want to be reading carefully.
*
* Yeah...most of the comments are cut-and-paste from my MD4 implementation.
*
* -------------------------------------------------------------------------- **
*
* References:
* IETF RFC 1321: The MD5 Message-Digest Algorithm
* Ron Rivest. IETF, April, 1992
*
* ========================================================================== **
*/
/* -------------------------------------------------------------------------- **
* Typedefs:
*/
typedef struct
{
uint32_t len;
uint32_t ABCD[4];
int b_used;
unsigned char block[64];
} auth_md5Ctx;
/* -------------------------------------------------------------------------- **
* Functions:
*/
auth_md5Ctx *auth_md5InitCtx( auth_md5Ctx *ctx );
/* ------------------------------------------------------------------------ **
* Initialize an MD5 context.
*
* Input: ctx - A pointer to the MD5 context structure to be initialized.
* Contexts are typically created thusly:
* ctx = (auth_md5Ctx *)malloc( sizeof(auth_md5Ctx) );
*
* Output: A pointer to the initialized context (same as <ctx>).
*
* Notes: The purpose of the context is to make it possible to generate
* an MD5 Message Digest in stages, rather than having to pass a
* single large block to a single MD5 function. The context
* structure keeps track of various bits of state information.
*
* Once the context is initialized, the blocks of message data
* are passed to the <auth_md5SumCtx()> function. Once the
* final bit of data has been handed to <auth_md5SumCtx()> the
* context can be closed out by calling <auth_md5CloseCtx()>,
* which also calculates the final MD5 result.
*
* Don't forget to free an allocated context structure when
* you've finished using it.
*
* See Also: <auth_md5SumCtx()>, <auth_md5CloseCtx()>
*
* ------------------------------------------------------------------------ **
*/
auth_md5Ctx *auth_md5SumCtx( auth_md5Ctx *ctx,
const unsigned char *src,
const int len );
/* ------------------------------------------------------------------------ **
* Build an MD5 Message Digest within the given context.
*
* Input: ctx - Pointer to the context in which the MD5 sum is being
* built.
* src - A chunk of source data. This will be used to drive
* the MD5 algorithm.
* len - The number of bytes in <src>.
*
* Output: A pointer to the updated context (same as <ctx>).
*
* See Also: <auth_md5InitCtx()>, <auth_md5CloseCtx()>, <auth_md5Sum()>
*
* ------------------------------------------------------------------------ **
*/
auth_md5Ctx *auth_md5CloseCtx( auth_md5Ctx *ctx, unsigned char *dst );
/* ------------------------------------------------------------------------ **
* Close an MD5 Message Digest context and generate the final MD5 sum.
*
* Input: ctx - Pointer to the context in which the MD5 sum is being
* built.
* dst - A pointer to at least 16 bytes of memory, which will
* receive the finished MD5 sum.
*
* Output: A pointer to the closed context (same as <ctx>).
* You might use this to free a malloc'd context structure. :)
*
* Notes: The context (<ctx>) is returned in an undefined state.
* It must be re-initialized before re-use.
*
* See Also: <auth_md5InitCtx()>, <auth_md5SumCtx()>
*
* ------------------------------------------------------------------------ **
*/
unsigned char * MD5(unsigned char * hash, const unsigned char *src, const int len );
/* ------------------------------------------------------------------------ **
* Compute an MD5 message digest.
*
* Input: dst - Destination buffer into which the result will be written.
* Must be 16 bytes, minimum.
* src - Source data block to be MD5'd.
* len - The length, in bytes, of the source block.
* (Note that the length is given in bytes, not bits.)
*
* Output: A pointer to <dst>, which will contain the calculated 16-byte
* MD5 message digest.
*
* Notes: This function is a shortcut. It takes a single input block.
* For more drawn-out operations, see <auth_md5InitCtx()>.
*
* This function is interface-compatible with the
* <auth_md4Sum()> function in the MD4 module.
*
* The MD5 algorithm is designed to work on data with an
* arbitrary *bit* length. Most implementations, this one
* included, handle the input data in byte-sized chunks.
*
* The MD5 algorithm does much of its work using four-byte
* words, and so can be tuned for speed based on the endian-ness
* of the host. This implementation is intended to be
* endian-neutral, which may make it a teeny bit slower than
* others. ...maybe.
*
* See Also: <auth_md5InitCtx()>
*
* ------------------------------------------------------------------------ **
*/
unsigned char * MD5fromFile(unsigned char *dst, const char *src);
/* ------------------------------------------------------------------------ **
* Compute an MD5 message digest.
*
* Input: dst - Destination buffer into which the result will be written.
* Must be 16 bytes, minimum.
* src - filepath to the file to be MD5'd.
*
* Output: A pointer to <dst>, which will contain the calculated 16-byte
* MD5 message digest.
*
* Notes: This function is a shortcut. It takes a single input block.
* For more drawn-out operations, see <auth_md5InitCtx()>.
*
* This function is interface-compatible with the
* <auth_md4Sum()> function in the MD4 module.
*
* The MD5 algorithm is designed to work on data with an
* arbitrary *bit* length. Most implementations, this one
* included, handle the input data in byte-sized chunks.
*
* The MD5 algorithm does much of its work using four-byte
* words, and so can be tuned for speed based on the endian-ness
* of the host. This implementation is intended to be
* endian-neutral, which may make it a teeny bit slower than
* others. ...maybe.
*
* See Also: <auth_md5InitCtx()>
*
* ------------------------------------------------------------------------ **
*/
/* ========================================================================== */
#ifdef __cplusplus
}
#endif
#endif /* AUTH_MD5_H */

View File

@ -1,126 +0,0 @@
/****************************************************************************
* USB Loader GX Team
* banner.c
*
* Dump opening.bnr thanks to Wiipower
***************************************************************************/
#include <gctypes.h>
#include <gccore.h>
#include <ogcsys.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <malloc.h>
#include <fat.h>
#include "fatmounter.h"
#include "usbloader/wdvd.h"
#include "usbloader/disc.h"
#include "banner.h"
#include "patches/fst.h"
#include "usbloader/fstfile.h"
s32 dump_banner(const char * discid,const char * dest)
{
// Mount the disc
//Disc_SetWBFS(1, (u8*)discid);
Disc_SetUSB((u8*)discid);
Disc_Open();
u64 offset;
s32 ret;
ret = __Disc_FindPartition(&offset);
if (ret < 0)
return ret;
ret = WDVD_OpenPartition(offset);
if (ret < 0) {
//printf("ERROR: OpenPartition(0x%llx) %d\n", offset, ret);
return ret;
}
// Read where to find the fst.bin
u32 *buffer = memalign(32, 0x20);
if (buffer == NULL)
{
//Out of memory
return -1;
}
ret = WDVD_Read(buffer, 0x20, 0x420);
if (ret < 0)
return ret;
// Read fst.bin
void *fstbuffer = memalign(32, buffer[2]*4);
FST_ENTRY *fst = (FST_ENTRY *)fstbuffer;
if (fst == NULL)
{
//Out of memory
free(buffer);
return -1;
}
ret = WDVD_Read(fstbuffer, buffer[2]*4, buffer[1]*4);
if (ret < 0)
return ret;
free(buffer);
// Search the fst.bin
u32 count = fst[0].filelen;
int i;
u32 index = 0;
for (i=1;i<count;i++)
{
if (strstr(fstfiles(fst, i), "opening.bnr") != NULL)
{
index = i;
}
}
if (index == 0)
{
//opening.bnr not found
free(fstbuffer);
return -1;
}
// Load the .bnr
u8 *banner = memalign(32, fst[index].filelen);
if (banner == NULL)
{
//Out of memory
free(fstbuffer);
return -1;
}
ret = WDVD_Read((void *)banner, fst[index].filelen, fst[index].fileoffset * 4);
if (ret < 0)
return ret;
//fatInitDefault();
//SDCard_Init();
FILE *fp = NULL;
fp = fopen(dest, "wb");
fwrite(banner, 1, fst[index].filelen, fp);
fclose(fp);
free(fstbuffer);
free(banner);
return 1;
}

View File

@ -1,22 +0,0 @@
/****************************************************************************
* USB Loader GX Team
* banner.h
*
* Dump opening.bnr thanks to Wiipower
***************************************************************************/
#ifndef BANNER_H
#define BANNER_H
#ifdef __cplusplus
extern "C"
{
#endif
s32 dump_banner(const char * discid,const char * dest);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,214 +0,0 @@
/*
* brlan.c
* BannerPlayer
*
* Created by Alex Marshall on 09/03/16.
* Copyright 2009 __MyCompanyName__. All rights reserved.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "brlan.h"
//#include "endian.h"
char* BRLAN_rootpath = NULL;
u8* BRLAN_file = NULL;
u32 BRLAN_filesize = 0;
u8* BRLAN_startfile = NULL;
u32 BRLAN_startfilesize = 0;
int BRLAN_looping = 0;
void BRLAN_Initialize(char rootpath[])
{
char brlanpath[256];
sprintf(brlanpath, "%s/arc/anim/banner.brlan", rootpath);
FILE* fp = fopen(brlanpath, "rb");
if(fp == NULL) {
fprintf(stderr, "Couldn't find banner.brlan. Let's assume it's a looping banner then.\n");
BRLAN_looping = 1;
sprintf(brlanpath, "%s/arc/anim/banner_start.brlan", rootpath);
fp = fopen(brlanpath, "rb");
if(fp == NULL) {
fprintf(stderr, "No BRLAN file found. Quitting.\n");
exit(1);
}
fseek(fp, 0, SEEK_END);
BRLAN_startfilesize = ftell(fp);
fseek(fp, 0, SEEK_SET);
fread(BRLAN_startfile, BRLAN_startfilesize, 1, fp);
fclose(fp);
sprintf(brlanpath, "%s/arc/anim/banner_loop.brlan", rootpath);
fp = fopen(brlanpath, "rb");
if(fp == NULL) {
fprintf(stderr, "No BRLAN file found. Quitting.\n");
exit(1);
}
}else
BRLAN_looping = 0;
fseek(fp, 0, SEEK_END);
BRLAN_filesize = ftell(fp);
fseek(fp, 0, SEEK_SET);
fread(BRLAN_file, BRLAN_filesize, 1, fp);
fclose(fp);
}
#define MAXIMUM_TAGS_SIZE (0x1000)
fourcc tag_FourCCs[] = { "RLPA", "RLTS", "RLVI", "RLVC", "RLMC", "RLTP" };
static size_t BRLAN_fileoffset = 0;
static void BRLAN_ReadDataFromMemoryX(void* destination, void* input, size_t size)
{
u8* out = (u8*)destination;
u8* in = ((u8*)input) + BRLAN_fileoffset;
memcpy(out, in, size);
}
static void BRLAN_ReadDataFromMemory(void* destination, void* input, size_t size)
{
BRLAN_ReadDataFromMemoryX(destination, input, size);
BRLAN_fileoffset += size;
}
static void CreateGlobal_pai1(brlan_pai1_header_type2 *pai1_header, brlan_pai1_header_type1 pai1_header1,
brlan_pai1_header_type2 pai1_header2, int pai1_header_type)
{
if(pai1_header_type == 1) {
pai1_header->magic[0] = pai1_header1.magic[0];
pai1_header->magic[1] = pai1_header1.magic[1];
pai1_header->magic[2] = pai1_header1.magic[2];
pai1_header->magic[3] = pai1_header1.magic[3];
pai1_header->size = pai1_header1.size;
pai1_header->framesize = pai1_header1.framesize;
pai1_header->flags = pai1_header1.flags;
pai1_header->unk1 = pai1_header1.unk1;
pai1_header->num_timgs = pai1_header1.num_timgs;
pai1_header->num_entries = pai1_header1.num_entries;
pai1_header->unk2 = 0;
pai1_header->entry_offset = pai1_header1.entry_offset;
}else
memcpy(pai1_header, &pai1_header2, sizeof(brlan_pai1_header_type2));
}
static int FourCCsMatch(fourcc cc1, fourcc cc2)
{
if((cc1[0] == cc2[0]) && (cc1[1] == cc2[1]) && (cc1[2] == cc2[2]) && (cc1[3] == cc2[3]))
return 1;
else
return 0;
}
static int FourCCInList(fourcc cc)
{
int i;
for(i = 0; i < 6; i++)
if(FourCCsMatch(cc, tag_FourCCs[i])) return 1;
return 0;
}
static void ReadTagFromBRLAN(BRLAN_animation **anims, int idx)
{
int taghead_location = BRLAN_fileoffset;
tag_header head;
tag_entry* entries;
tag_entryinfo* entryinfo;
BRLAN_ReadDataFromMemory(&head, BRLAN_file, sizeof(tag_header));
memcpy(anims[idx]->type, head.magic, 4);
anims[idx]->entrycount = head.entry_count;
int i, z;
entries = (tag_entry*)calloc(anims[idx]->entrycount, sizeof(tag_entry));
entryinfo = (tag_entryinfo*)calloc(anims[idx]->entrycount, sizeof(tag_entryinfo));
for(i = 0; i < anims[idx]->entrycount; i++) {
BRLAN_ReadDataFromMemory(&entries[i], BRLAN_file, sizeof(tag_entry));
}
for(i = 0; i < anims[idx]->entrycount; i++) {
BRLAN_fileoffset = be32(entries[i].offset) + taghead_location;
BRLAN_ReadDataFromMemory(&entryinfo[i], BRLAN_file, sizeof(tag_entryinfo));
anims[idx]->entries[i].animtype = be16(entryinfo[i].type);
anims[idx]->entries[i].tripletcount = be16(entryinfo[i].coord_count);
for(z = 0; z < be16(entryinfo[i].coord_count); z++) {
BRLAN_ReadDataFromMemory(&anims[idx]->entries[i].triplets[z], BRLAN_file, sizeof(f32) * 3);
anims[idx]->entries[i].triplets[z].frame = le32(anims[idx]->entries[i].triplets[z].frame);
anims[idx]->entries[i].triplets[z].value = le32(anims[idx]->entries[i].triplets[z].value);
anims[idx]->entries[i].triplets[z].blend = le32(anims[idx]->entries[i].triplets[z].blend);
}
}
free(entries);
free(entryinfo);
}
u16 BRLAN_ReadAnimations(BRLAN_animation **anims)
{
BRLAN_fileoffset = 0;
brlan_header header;
BRLAN_ReadDataFromMemoryX(&header, BRLAN_file, sizeof(brlan_header));
BRLAN_fileoffset = be16(header.pai1_offset);
brlan_pai1_universal universal;
BRLAN_ReadDataFromMemoryX(&universal, BRLAN_file, sizeof(brlan_pai1_universal));
int pai1_header_type;
brlan_pai1_header_type1 pai1_header1;
brlan_pai1_header_type2 pai1_header2;
brlan_pai1_header_type2 pai1_header;
if((be32(universal.flags) & (1 << 25)) >= 1) {
pai1_header_type = 2;
BRLAN_ReadDataFromMemory(&pai1_header2, BRLAN_file, sizeof(brlan_pai1_header_type2));
} else {
pai1_header_type = 1;
BRLAN_ReadDataFromMemory(&pai1_header1, BRLAN_file, sizeof(brlan_pai1_header_type1));
}
CreateGlobal_pai1(&pai1_header, pai1_header1, pai1_header2, pai1_header_type);
int tagcount = be16(pai1_header.num_entries);
u32 *taglocations = (u32*)calloc(tagcount, sizeof(u32));
*anims = (BRLAN_animation*)calloc(tagcount, sizeof(BRLAN_animation));
fourcc CCs[256];
memset(CCs, 0, 256*4);
BRLAN_fileoffset = be32(pai1_header.entry_offset) + be16(header.pai1_offset);
BRLAN_ReadDataFromMemory(taglocations, BRLAN_file, tagcount * sizeof(u32));
int animcnt = 1;
int i;
for(i = 0; i < tagcount; i++) {
BRLAN_fileoffset = be32(taglocations[i]) + be16(header.pai1_offset);
brlan_entry tmpentry;
BRLAN_ReadDataFromMemory(&tmpentry, BRLAN_file, sizeof(brlan_entry));
if((be32(tmpentry.flags) & (1 << 25)) >= 1)
BRLAN_fileoffset += sizeof(u32);
memcpy(anims[animcnt]->name, tmpentry.name, 20);
fourcc magick;
BRLAN_ReadDataFromMemoryX(magick, BRLAN_file, 4);
memcpy(CCs[i], magick, 4);
if(FourCCInList(CCs[i]) == 1) {
anims[animcnt]->offset = BRLAN_fileoffset;
ReadTagFromBRLAN(anims, animcnt);
animcnt++;
}
}
return tagcount;
}
void BRLAN_Finish()
{
if(BRLAN_file != NULL)
free(BRLAN_file);
if(BRLAN_startfile != NULL)
free(BRLAN_startfile);
}

View File

@ -1,146 +0,0 @@
/*
* brlan.h
* BannerPlayer
*
* Created by Alex Marshall on 09/03/16.
* Copyright 2009 __MyCompanyName__. All rights reserved.
*
*/
#ifndef _BRLAN_H_
#define _BRLAN_H_
#include <gctypes.h>
typedef char fourcc[4];
#define le16 be16
#define le32 be32
#define le64 be64
u16 be16(u16 x);
u32 be32(u32 x);
u64 be64(u64 x);
typedef enum
{
RLPA_ENTRY = 0,
RLTS_ENTRY = 1,
RLVI_ENTRY = 2,
RLVC_ENTRY = 3,
RLMC_ENTRY = 4,
RLTP_ENTRY = 5
} brlan_entry_type;
typedef struct
{
fourcc magic; // "pai1" in ASCII.
u32 size; // Size of section, which is rest of the file. (header.file_size - header.offset_pai1)
u16 framesize; // Framesize
u8 flags; // Flags
u8 unk1; // Unknown
u16 num_timgs; // Number of timgs?
u16 num_entries; // Number of tags in the brlan.
u32 unk2; // Only if bit 25 of flags is set.
u32 entry_offset; // Offset to entries. (Relative to start of pai1 header.)
} brlan_pai1_header_type2;
typedef struct
{
fourcc magic; // "RLAN" in ASCII.
u32 unk1; // Always 0xFEFF 0x0008. Possibly a versioning string.
u32 file_size; // Size of whole file, including the header.
u16 pai1_offset; // The offset to the pai1 header from the start of file.
u16 pai1_count; // How many pai1 sections there are (duh, only 1... wtf?)
} brlan_header;
typedef struct
{
fourcc magic; // "pai1" in ASCII.
u32 size; // Size of section, which is rest of the file. (header.file_size - header.offset_pai1)
u16 framesize; // Framesize
u8 flags; // Flags
u8 unk1; // Unknown
u16 num_timgs; // Number of timgs?
u16 num_entries; // Number of tags in the brlan.
} brlan_pai1_universal;
typedef struct
{
fourcc magic; // "pai1" in ASCII.
u32 size; // Size of section, which is rest of the file. (header.file_size - header.offset_pai1)
u16 framesize; // Framesize
u8 flags; // Flags
u8 unk1; // Unknown
u16 num_timgs; // Number of timgs?
u16 num_entries; // Number of tags in the brlan.
u32 entry_offset; // Offset to entries. (Relative to start of pai1 header.)
} brlan_pai1_header_type1;
typedef struct
{
char name[20]; // Name of the BRLAN entry. (Must be defined in the BRLYT)
u32 flags; // Flags? (If bit 25 is set, we have another u32 after the entry. It's use is unknown.)
u32 anim_header_len; // Length of the animation header which is directly after this entry.
} brlan_entry;
typedef struct
{
fourcc magic;
u8 entry_count; // How many entries in this chunk.
u8 pad1; // All cases I've seen is zero.
u8 pad2; // All cases I've seen is zero.
u8 pad3; // All cases I've seen is zero.
} tag_header;
typedef struct
{
u32 offset; // Offset to the data pointed to by this entry.
// Relative to the start of the RLPA header.
} tag_entry;
typedef struct
{
u16 type; // Type (look at animtypes)
u16 unk1; // ??? Every case has been 0x0200
u16 coord_count; // How many coordinates.
u16 pad1; // All cases I've seen is zero.
u32 unk2; // ??? In every case I've seen, it is 0x0000000C.
} tag_entryinfo;
typedef struct
{ // Bits not listed here are currently unknown.
u32 part1; // If Bit 9 is set in flags, this is an f32, with a coordinate. (Bit 17 seems to act the same)
u32 part2; // If Bit 16 is set in flags, this is an f32, with another coordinate. (Bit 17 seems to act the same)
u32 part3; // With Bit 16 set in flags, this seems to be yet another coordinate. (Bit 17 seems to act the same)
} tag_data;
typedef struct BRLAN_trip
{
f32 frame; // Frame number.
f32 value; // Value at the frame.
f32 blend; // Interpolation value.
} BRLAN_triplets;
typedef struct BRLAN_entr
{
u16 animtype; // What subtype of animation.
u16 tripletcount; // Number of triplets.
BRLAN_triplets triplets[20]; // Shouldn't ever be more than 20.
} BRLAN_entries;
typedef struct BRLAN_anims
{
char type[4]; // The type of animation (FourCC from BRLAN file)
char name[20]; // Name.
u32 offset; // Offset into the BRLAN file to find this animation.
u16 entrycount; // How many entries.
BRLAN_entries entries[20]; // The entries. Shouldn't ever be more than 20.
} BRLAN_animation;
void BRLAN_Initialize(char rootpath[]);
u16 BRLAN_ReadAnimations(BRLAN_animation **anims);
void BRLAN_Finish();
#endif //_BRLAN_H_

View File

@ -1,213 +0,0 @@
/*
* brlyt.h
* Parses brlyt file
*
* by nIxx
* http://wiibrew.org/wiki/Wii_Animations#Textures_and_Material_lists_.28.2A.brlyt.29
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fat.h>
#include "brlyt.h"
#include "openingbnr.h"
brlyt_header brlytheader;
lyt1_header lyt1header;
txl1_header txl1header;
txl1_offset **txl1offsets;
tpl_files **tplss;
mat1_header mat1header;
mat1_offset **mat1offsets;
mat1_material **mat1materials;
pic1_header **pic1header;
pae1_header pae1header;
grp1_header grp1header;
int BRLYT_Initialize(const char *rootpath)
{
//fatInitDefault();
FILE * fp = fopen(rootpath,"rb");
if (fp == NULL) return 0;
fread((void*)&brlytheader,1,sizeof(brlytheader),fp);
fread((void*)&lyt1header,1,sizeof(lyt1header),fp);
fread((void*)&txl1header,1,sizeof(txl1header),fp);
//printf("Filesize: %i\n",be32((u8*)&brlytheader.file_size));
//printf("Num Textures: %i\n",be16((u8*)&txl1header.num_textures));
txl1offsets = (txl1_offset**)malloc(sizeof(txl1_offset*)*be16((u8*)&txl1header.num_textures));
if(txl1offsets == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
int i = 0;
for(i = 0; i < be16((u8*)&txl1header.num_textures); i++)
{
txl1offsets[i] = (txl1_offset*)malloc(sizeof(txl1_offset));
if(txl1offsets[i] == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
fread(txl1offsets[i],1,sizeof(*txl1offsets[i]),fp);
//printf("Offset Filename: %i\n",be32((u8*)&txl1offsets[i]->offset_filename));
}
tplss = (tpl_files**)malloc(sizeof(tpl_files*)*be16((u8*)&txl1header.num_textures));
if(tplss == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
for(i = 0; i < be16((u8*)&txl1header.num_textures); i++)
{
tplss[i] = (tpl_files*)malloc(sizeof(tpl_files));
if(tplss[i] == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
fseek(fp,0x30+ be32((u8*)&txl1offsets[i]->offset_filename),SEEK_SET);
fread(tplss[i],1,sizeof(*tplss[i]),fp);
//printf("%i. Filename: %s\n",i,tplss[i]->tplfilename);
}
fseek(fp,0x10+be32((u8*)&lyt1header.size_header)+be32((u8*)&txl1header.size_section),SEEK_SET);
mat1_header mat1header;
fread((void*)&mat1header,1,sizeof(mat1header),fp);
//printf("Sig: %s SizeHeader:%i Num materials%i\n",mat1header.sig ,be32((u8*)&mat1header.size_section) ,be16((u8*)&mat1header.num_materials) );
mat1_offset **mat1offsets = (mat1_offset**)malloc(sizeof(mat1_offset*)*be16((u8*)&mat1header.num_materials));
if(mat1offsets == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
for(i = 0; i < be16((u8*)&mat1header.num_materials); i++)
{
mat1offsets[i] = (mat1_offset*)malloc(sizeof(mat1_offset));
if(mat1offsets[i] == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
fread(mat1offsets[i],1,sizeof(*mat1offsets[i]),fp);
//printf("%i. Material Offset: %X\n",i,be32((u8*)&mat1offsets[i]->offset));
}
mat1materials = (mat1_material**)malloc(sizeof(mat1_material*)*be16((u8*)&mat1header.num_materials));
if(mat1materials == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
for(i = 0; i < be16((u8*)&mat1header.num_materials); i++)
{
mat1materials[i] = (mat1_material*)malloc(sizeof(mat1_material));
if(mat1materials[i] == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
fseek(fp,0x10+be32((u8*)&lyt1header.size_header)+be32((u8*)&txl1header.size_section)+be32((u8*)&mat1offsets[i]->offset),SEEK_SET);
fread(mat1materials[i],1,sizeof(*mat1materials[i]),fp);
//printf("%i. Material Names: %s\n",i,mat1materials[i]->name);
}
fseek(fp,0x10+be32((u8*)&lyt1header.size_header)+be32((u8*)&txl1header.size_section)+be32((u8*)&mat1header.size_section),SEEK_SET);
pan1_header pan1header;
fread((void*)&pan1header,1,sizeof(pan1header),fp);
pas1_header pas1header;
fread((void*)&pas1header,1,sizeof(pas1header),fp);
pic1_header **pic1header = (pic1_header**)malloc(sizeof(pic1_header*)*be16((u8*)&mat1header.num_materials));
if(pic1header == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
for(i = 0; i < be16((u8*)&mat1header.num_materials); i++)
{
pic1header[i] = (pic1_header*)malloc(sizeof(pic1_header));
if(pic1header[i] == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
fpos_t pos;
fgetpos(fp,&pos);
fread(pic1header[i],1,sizeof(*pic1header[i]),fp);
fseek(fp,pos+be32((u8*)&pic1header[i]->size_section),SEEK_SET);
// printf("%i. Pic1 Names: %s\n",i,pic1header[i]->name);
}
fread((void*)&pae1header,1,sizeof(pae1header),fp);
fread((void*)&grp1header,1,sizeof(grp1header),fp);
//Close File
fclose(fp);
return 1;
}
int BRLYT_ReadObjects(BRLYT_object** objs)
{
return 0;
}
void BRLYT_Finish()
{
}
void BRLYT_FreeMem()
{
int i = 0;
//free memory
for(i = 0; i < be16((u8*)&txl1header.num_textures); i++)
free(txl1offsets[i]);
free(txl1offsets);
for(i = 0; i < be16((u8*)&txl1header.num_textures); i++)
free(tplss[i]);
free(tplss);
for(i = 0; i < be16((u8*)&mat1header.num_materials); i++)
free(mat1offsets[i]);
free(mat1offsets);
for(i = 0; i < be16((u8*)&mat1header.num_materials); i++)
free(mat1materials[i]);
free(mat1materials);
for(i = 0; i < be16((u8*)&mat1header.num_materials); i++)
free(pic1header[i]);
free(pic1header);
}

View File

@ -1,153 +0,0 @@
/*
* brlyt.h
* Parses brlyt file
*
* by nIxx
* Infos: http://wiibrew.org/wiki/Wii_Animations#Textures_and_Material_lists_.28.2A.brlyt.29
*
*/
#ifndef _BRLYT_H_
#define _BRLYT_H_
#include <gctypes.h>
#ifdef __cplusplus
extern "C"
{
#endif
int BRLYT_Initialize(const char *rootpath);
typedef struct BRLYT_objs
{
char type[4]; // The type of object (FourCC from BRLYT file)
u32 offset; // Offset into the BRLYT file to find this object.
} BRLYT_object;
int BRLYT_ReadObjects(BRLYT_object** objs);
void BRLYT_Finish();
typedef struct
{
char sig [4]; // "RLYT" in ASCII
u32 unk; // Always 0xFE 0xFF 0x 00 0x08.
u32 file_size; // Size of whole file, including the header.
u32 num; // number of sections
} brlyt_header;
typedef struct
{
char sig [4]; // "lyt1" in ASCII.
u32 size_header;
u32 a;
u32 width;
u32 height;
} lyt1_header;
typedef struct
{
char sig [4]; // "txl1" in ASCII.
u32 size_section; // Size of the whole section.
u16 num_textures; // Number of textures in list.
u16 unk2; // Always zero?
} txl1_header;
typedef struct
{
u32 offset_filename; // Offset to a null-terminated ASCII string containing the filename.
// The offset-base should be after the txl1-header.
u32 unk; // Always zero?
} txl1_offset;
typedef struct
{
char sig [4]; // "mat1" in ASCII.
u32 size_section; // // Size of the whole section.
u16 num_materials; //
u16 size_header; // Offset to list start. Always zero
} mat1_header;
typedef struct
{
u32 offset; // Offset from beginning of mat1-section.
} mat1_offset;
typedef struct
{
char name[20];
s16 black_color[4];
s16 white_color[4];
s16 unk_color_2[4];
u32 tev_kcolor[4];
u32 flags;
} mat1_material;
typedef struct
{
char sig [4]; // "pan1" in ASCII.
u32 size_section;
u16 flag;
u16 alpha;
char pane_name [0x18]; // Pane name in ASCII.
float x;
float y;
float z;
float xFlip;
float yFlip;
float zFlip; //rotate
float xMag; //Zoom
float yMag;
float width;
float height;
} pan1_header;
typedef struct
{
char sig [4]; // "pas1" in ASCII.
u32 size_section;
} pas1_header;
typedef struct
{
char sig [4]; // "pic1" in ASCII.
u32 size_section;
u16 flags;
u16 alpha;
char name[0x18];
float x;
float y;
float z;
float xFlip;
float yFlip;
float zFlip; //rotate
float xMag;
float yMag; //zoom
float width;
float height;
} pic1_header;
typedef struct
{
char sig [4]; // "pae1" in ASCII.
u32 size_section;
} pae1_header;
typedef struct {
char sig [4]; // "grp1" in ASCII.
u32 size_section;
char name[16];
u16 numsubs;
u16 unk1;
} grp1_header;
typedef struct
{
char tplfilename[40];
} tpl_files;
#ifdef __cplusplus
}
#endif
#endif //_BRLYT_H_

View File

@ -1,114 +0,0 @@
/****************************************************************************
* USB Loader GX Team
* gui_banner.cpp
*
* Shows TPL Banner images
***************************************************************************/
#include "gui_banner.h"
GuiBanner::GuiBanner(const char *tplfilepath)
{
memory = NULL;
tplfilesize = 0;
width = 0;
height = 0;
FILE *tplfp = fopen(tplfilepath,"rb");
if(tplfp !=NULL) {
unsigned short heighttemp = 0;
unsigned short widthtemp = 0;
fseek(tplfp , 0x14, SEEK_SET);
fread((void*)&heighttemp,1,2,tplfp);
fread((void*)&widthtemp,1,2,tplfp);
fseek (tplfp , 0 , SEEK_END);
tplfilesize = ftell (tplfp);
rewind (tplfp);
memory = memalign(32, tplfilesize);
if(!memory) {
fclose(tplfp);
return;
}
fread(memory, 1, tplfilesize, tplfp);
fclose(tplfp);
TPLFile tplfile;
int ret;
ret = TPL_OpenTPLFromMemory(&tplfile, memory, tplfilesize);
if(ret < 0) {
free(memory);
memory = NULL;
return;
}
ret = TPL_GetTexture(&tplfile,0,&texObj);
if(ret < 0) {
free(memory);
memory = NULL;
return;
}
TPL_CloseTPLFile(&tplfile);
width = widthtemp;
height = heighttemp;
widescreen = 0;
filecheck = true;
} else {
filecheck = false;
fclose(tplfp);
}
}
GuiBanner::GuiBanner(void *mem, u32 len, int w, int h)
{
if(!mem || !len)
return;
memory = mem;
tplfilesize = len;
width = w;
height = h;
TPLFile tplfile;
int ret;
ret = TPL_OpenTPLFromMemory(&tplfile, memory, tplfilesize);
if(ret < 0) {
free(memory);
memory = NULL;
return;
}
ret = TPL_GetTexture(&tplfile,0,&texObj);
if(ret < 0) {
free(memory);
memory = NULL;
return;
}
TPL_CloseTPLFile(&tplfile);
filecheck = true;
}
GuiBanner::~GuiBanner()
{
if(memory != NULL) {
free(memory);
memory = NULL;
}
}
void GuiBanner::Draw()
{
LOCK(this);
if(!filecheck ||!this->IsVisible())
return;
float currScale = this->GetScale();
Menu_DrawTPLImg(this->GetLeft(), this->GetTop(), 0, width, height, &texObj, imageangle, widescreen ? currScale*0.80 : currScale, currScale, this->GetAlpha(), xx1,yy1,xx2,yy2,xx3,yy3,xx4,yy4);
this->UpdateEffects();
}

View File

@ -1,35 +0,0 @@
/****************************************************************************
* USB Loader GX Team
* gui_banner.h
*
* Shows TPL Banner images
***************************************************************************/
#ifndef _GUIBANNER_H_
#define _GUIBANNER_H_
#include "libwiigui/gui.h"
class GuiBanner : public GuiImage
{
public:
//!Constructor
//!\param tplfilepath Path of the tpl file
GuiBanner(const char *tplfilepath);
//!Constructor
//!\param mem Memory of the loaded tpl
//!\param len Filesize of the tpl
//!\param w Width of the tpl
//!\param h Height of the tpl
GuiBanner(void *mem, u32 len, int w, int h);
//!Destructor
~GuiBanner();
void Draw();
protected:
void * memory;
bool filecheck;
u32 tplfilesize;
GXTexObj texObj;
};
#endif /* _GUIBANNER_H_ */

View File

@ -1,459 +0,0 @@
/****************************************************************************
* USB Loader GX Team
* openingbnr
*
* Extract opening.bnr/banner.bin/sound.bin/icon.bin
*
* Copyright 2008 Magicus <magicus@gmail.com>
* Licensed under the terms of the GNU GPL, version 2
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
* Version 1.0 Initial release
***************************************************************************/
#define _GNU_SOURCE
#include <ogcsys.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <fat.h>
#include "MD5.h"
#include "banner.h"
u16 be16(const u8 *p)
{
return (p[0] << 8) | p[1];
}
u32 be32(const u8 *p)
{
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
}
u64 be64(const u8 *p)
{
return ((u64)be32(p) << 32) | be32(p + 4);
}
u64 be34(const u8 *p)
{
return 4 * (u64)be32(p);
}
void wbe16(u8 *p, u16 x)
{
p[0] = x >> 8;
p[1] = x;
}
void wbe32(u8 *p, u32 x)
{
wbe16(p, x >> 16);
wbe16(p + 2, x);
}
void wbe64(u8 *p, u64 x)
{
wbe32(p, x >> 32);
wbe32(p + 4, x);
}
void md5(u8 *data, u32 len, u8 *hash)
{
MD5(hash, data, len);
}
static FILE *fp;
typedef struct {
u8 zeroes[0x40];
u32 imet; // "IMET"
u8 zero_six_zero_three[8]; // fixed, unknown purpose
u32 sizes[3];
u32 flag1;
u16 name_jp[0x2a]; // might be empty
u16 name_en[0x2a];
u16 name_de[0x2a];
u16 name_fr[0x2a];
u16 name_es[0x2a];
u16 name_it[0x2a];
u16 name_nl[0x2a];
u8 zeroes_2[0x348];
u8 crypto[0x10];
} imet_data_t;
typedef struct {
u32 imd5_tag; // 0x494D4435 "IMD5";
u32 size; // size of the rest of part B, starting from next field.
u8 zeroes[8];
u8 md5[16];
u32 payload_tag; // 0x4C5A3737 "LZ77" if this is lz77
u32 payload_data;
} imd5_header_t;
typedef struct
{
u16 type;
u16 name_offset;
u32 data_offset; // == absolut offset från U.8- headerns början
u32 size; // last included file num for directories
} U8_node;
typedef struct
{
u32 tag; // 0x55AA382D "U.8-"
u32 rootnode_offset; // offset to root_node, always 0x20.
u32 header_size; // size of header from root_node to end of string table.
u32 data_offset; // offset to data -- this is rootnode_offset + header_size, aligned to 0x40.
u8 zeroes[16];
} U8_archive_header;
static void write_file(void* data, size_t size, char* name)
{
FILE *out;
out = fopen(name, "wb");
fwrite(data, 1, size, out);
fclose(out);
}
u8* decompress_lz77(u8 *data, size_t data_size, size_t* decompressed_size)
{
u8 *data_end;
u8 *decompressed_data;
size_t unpacked_size;
u8 *in_ptr;
u8 *out_ptr;
u8 *out_end;
in_ptr = data;
data_end = data + data_size;
// Assume this for now and grow when needed
unpacked_size = data_size;
decompressed_data = malloc(unpacked_size);
out_end = decompressed_data + unpacked_size;
out_ptr = decompressed_data;
while (in_ptr < data_end) {
int bit;
u8 bitmask = *in_ptr;
in_ptr++;
for (bit = 0x80; bit != 0; bit >>= 1) {
if (bitmask & bit) {
// Next section is compressed
u8 rep_length;
u16 rep_offset;
rep_length = (*in_ptr >> 4) + 3;
rep_offset = *in_ptr & 0x0f;
in_ptr++;
rep_offset = *in_ptr | (rep_offset << 8);
in_ptr++;
if (out_ptr-decompressed_data < rep_offset) {
return NULL;
}
for ( ; rep_length > 0; rep_length--) {
*out_ptr = out_ptr[-rep_offset-1];
out_ptr++;
if (out_ptr >= out_end) {
// Need to grow buffer
decompressed_data = realloc(decompressed_data, unpacked_size*2);
out_ptr = decompressed_data + unpacked_size;
unpacked_size *= 2;
out_end = decompressed_data + unpacked_size;
}
}
} else {
// Just copy byte
*out_ptr = *in_ptr;
out_ptr++;
if (out_ptr >= out_end) {
// Need to grow buffer
decompressed_data = realloc(decompressed_data, unpacked_size*2);
out_ptr = decompressed_data + unpacked_size;
unpacked_size *= 2;
out_end = decompressed_data + unpacked_size;
}
in_ptr++;
}
}
}
*decompressed_size = (out_ptr - decompressed_data);
return decompressed_data;
}
static int write_imd5_lz77(u8* data, size_t size, char* outname)
{
imd5_header_t* header = (imd5_header_t*) data;
u32 tag;
u32 size_in_imd5;
u8 md5_calc[16];
u8 *decompressed_data;
size_t decompressed_size;
tag = be32((u8*) &header->imd5_tag);
if (tag != 0x494D4435) {
return -4;
}
md5(data+32, size-32, md5_calc);
if (memcmp(&header->md5, md5_calc, 0x10)) {
return -5;
}
size_in_imd5 = be32((u8*) &header->size);
if (size_in_imd5 != size - 32) {
return -6;
}
tag = be32((u8*) &header->payload_tag);
if (tag == 0x4C5A3737) {
// "LZ77" - uncompress
decompressed_data = decompress_lz77(data + sizeof(imd5_header_t), size - sizeof(imd5_header_t), &decompressed_size);
if(decompressed_data == NULL)
return -7;
write_file(decompressed_data, decompressed_size, outname);
//printf(", uncompressed %d bytes, md5 ok", decompressed_size);
free(decompressed_data);
} else {
write_file(&header->payload_tag, size-32, outname);
//printf(", md5 ok");
}
return 0;
}
static int do_U8_archive(void)
{
U8_archive_header header;
U8_node root_node;
u32 tag;
u32 num_nodes;
U8_node* nodes;
u8* string_table;
size_t rest_size;
unsigned int i;
u32 data_offset;
u32 current_offset;
u16 dir_stack[16];
int dir_index = 0;
fread(&header, 1, sizeof header, fp);
tag = be32((u8*) &header.tag);
if (tag != 0x55AA382D) {
return -1;
}
fread(&root_node, 1, sizeof(root_node), fp);
num_nodes = be32((u8*) &root_node.size) - 1;
//printf("Number of files: %d\n", num_nodes);
nodes = malloc(sizeof(U8_node) * (num_nodes));
fread(nodes, 1, num_nodes * sizeof(U8_node), fp);
data_offset = be32((u8*) &header.data_offset);
rest_size = data_offset - sizeof(header) - (num_nodes+1)*sizeof(U8_node);
string_table = malloc(rest_size);
fread(string_table, 1, rest_size, fp);
current_offset = data_offset;
for (i = 0; i < num_nodes; i++) {
U8_node* node = &nodes[i];
u16 type = be16((u8*)&node->type);
u16 name_offset = be16((u8*)&node->name_offset);
u32 my_data_offset = be32((u8*)&node->data_offset);
u32 size = be32((u8*)&node->size);
char* name = (char*) &string_table[name_offset];
u8* file_data;
if (type == 0x0100) {
// Directory
mkdir(name, 0777);
chdir(name);
dir_stack[++dir_index] = size;
//printf("%*s%s/\n", dir_index, "", name);
} else {
// Normal file
u8 padding[32];
if (type != 0x0000) {
return -2;
}
if (current_offset < my_data_offset) {
int diff = my_data_offset - current_offset;
if (diff > 32) {
return -3;
}
fread(padding, 1, diff, fp);
current_offset += diff;
}
file_data = malloc(size);
fread(file_data, 1, size, fp);
//printf("%*s %s (%d bytes", dir_index, "", name, size);
int result;
result = write_imd5_lz77(file_data, size, name);
if(result < 0)
return result;
//printf(")\n");
current_offset += size;
}
while (dir_stack[dir_index] == i+2 && dir_index > 0) {
chdir("..");
dir_index--;
}
}
return 0;
}
static void do_imet_header(void)
{
imet_data_t header;
fread(&header, 1, sizeof header, fp);
write_file(&header, sizeof(header), "header.imet");
}
void do_U8_archivebanner(FILE *fp)
{
U8_archive_header header;
U8_node root_node;
u32 tag;
u32 num_nodes;
U8_node* nodes;
u8* string_table;
size_t rest_size;
unsigned int i;
u32 data_offset;
u16 dir_stack[16];
int dir_index = 0;
fread(&header, 1, sizeof header, fp);
tag = be32((u8*) &header.tag);
if (tag != 0x55AA382D) {
//printf("No U8 tag");
exit(0);
}
fread(&root_node, 1, sizeof(root_node), fp);
num_nodes = be32((u8*) &root_node.size) - 1;
printf("Number of files: %d\n", num_nodes);
nodes = malloc(sizeof(U8_node) * (num_nodes));
fread(nodes, 1, num_nodes * sizeof(U8_node), fp);
data_offset = be32((u8*) &header.data_offset);
rest_size = data_offset - sizeof(header) - (num_nodes+1)*sizeof(U8_node);
string_table = malloc(rest_size);
fread(string_table, 1, rest_size, fp);
for (i = 0; i < num_nodes; i++) {
U8_node* node = &nodes[i];
u16 type = be16((u8*)&node->type);
u16 name_offset = be16((u8*)&node->name_offset);
u32 my_data_offset = be32((u8*)&node->data_offset);
u32 size = be32((u8*)&node->size);
char* name = (char*) &string_table[name_offset];
u8* file_data;
if (type == 0x0100) {
// Directory
mkdir(name, 0777);
chdir(name);
dir_stack[++dir_index] = size;
//printf("%*s%s/\n", dir_index, "", name);
} else {
// Normal file
if (type != 0x0000) {
printf("Unknown type");
exit(0);
}
fseek(fp, my_data_offset, SEEK_SET);
file_data = malloc(size);
fread(file_data, 1, size, fp);
write_file(file_data, size, name);
free(file_data);
//printf("%*s %s (%d bytes)\n", dir_index, "", name, size);
}
while (dir_stack[dir_index] == i+2 && dir_index > 0) {
chdir("..");
dir_index--;
}
}
}
int extractbnrfile(const char * filepath, const char * destpath)
{
int ret;
fp = fopen(filepath, "rb");
mkdir(destpath, 0777);
chdir(destpath);
do_imet_header();
ret = do_U8_archive();
fclose(fp);
return ret;
}
int unpackBin(const char * filename,const char * outdir)
{
FILE *fp;
fp = fopen(filename,"rb");
if(fp!=NULL)
{
mkdir(outdir, 0777);
chdir(outdir);
do_U8_archivebanner(fp);
fclose(fp);
return 1;
}
return 0;
}
int unpackBanner(char * gameid, char * outdir)
{
s32 ret = dump_banner(gameid,"SD:/opening.bnr");
if (ret != 1) return -1;
ret = extractbnrfile("SD:/opening.bnr","SD:/neu");
if (ret != 0) return -1;
remove("SD:/opening.bnr");
char iconpath[60];
snprintf(iconpath,sizeof(iconpath),"%s/meta/icon.bin",outdir);
ret = unpackBin(iconpath,"SD:/icon");
if (ret != 1) return -1;
if (unlink("/neu/meta/banner.bin") == -1) return -1;
if (unlink("/neu/meta/icon.bin") == -1) return -1;
if (unlink("/neu/meta/sound.bin") == -1) return -1;
if (unlink("/neu/header.imet") == -1) return -1;
if (unlink("/neu/meta") == -1) return -1;
if (unlink("/neu") == -1) return -1;
return 1;
}

View File

@ -1,44 +0,0 @@
/****************************************************************************
* USB Loader GX Team
* openingbnr
*
* Extract opening.bnr/banner.bin/sound.bin/icon.bin
***************************************************************************/
#ifndef _OPENINGBNR_H_
#define _OPENINGBNR_H_
#ifdef __cplusplus
extern "C"
{
#endif
/***********************************************************
* Error description:
* 0 Successfully extracted
* -1 No U8 tag
* -2 Unknown type
* -3 Archive inconsistency, too much padding
* -4 No IMD5 tag
* -5 MD5 mismatch
* -6 Size mismatch
* -7 Inconsistency in LZ77 encoding
************************************************************/
//! Extract opening.bnr from filepath to destpath
//! Files extracted: banner.bin icon.bin and sound.bin
int extractbnrfile(const char * filepath, const char * destpath);
int unpackBin(const char * filename,const char * outdir);
//int unpackBanner(const char * filename,const char * outdir);
int unpackBanner(const char * gameid, const char * outdir);
//! Extract the lz77 compressed banner, icon and sound .bin
u8* decompress_lz77(u8 *data, size_t data_size, size_t* decompressed_size);
u16 be16(const u8 *p);
u32 be32(const u8 *p);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,289 +0,0 @@
/****************************************************************************
* USB Loader GX Team
* buffer.cpp
*
* Loading covers in a background thread
***************************************************************************/
#include <gccore.h>
#include <unistd.h>
#include "libwiigui/gui.h"
#include "usbloader/disc.h"
#include "settings/cfg.h"
#include "buffer.h"
#include "main.h"
#define BUFFERSIZE 9
extern struct discHdr * gameList;
extern u32 gameCnt;
static lwp_t bufferthread = LWP_THREAD_NULL;
static bool BufferHalt = true;
static int loading = 0;
static int offset = 0;
static int direction = 1;
static bool changed = false;
static bool firstime = true;
static GuiImageData NoCoverData(nocover_png);
static GuiImageData * cover[BUFFERSIZE];
static GuiImage * coverImg[BUFFERSIZE];
static GuiImage * NoCover[BUFFERSIZE];
GuiImage * ImageBuffer(int imagenumber) {
if ((BUFFERSIZE-1 > imagenumber) && direction >= 0) {
return coverImg[imagenumber];
}
if ((0 < imagenumber) && direction < 0) {
return coverImg[imagenumber];
}
if (loading == BUFFERSIZE) {
return coverImg[imagenumber];
}
return NoCover[imagenumber];
}
void LoadImages() {
if (!changed || BufferHalt)
return;
char ID[4];
char IDfull[7];
char imgPath[200];
for (u32 i = offset; (int) i < offset+BUFFERSIZE; i++) {
struct discHdr *header;
if (i > gameCnt-1)
header = &gameList[i-gameCnt];
else
header = &gameList[i];
snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]);
snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]);
snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, IDfull); //Load full id image
//firsttime loading images into memory
if (firstime) {
if (coverImg[loading]) {
delete coverImg[loading];
coverImg[loading] = NULL;
}
if (cover[loading]) {
delete cover[loading];
cover[loading] = NULL;
}
cover[loading] = new GuiImageData(imgPath,0);
if (!cover[loading]->GetImage()) {
delete cover[loading];
cover[loading] = NULL;
snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, ID); //Load short id image
cover[loading] = new GuiImageData(imgPath, 0);
if (!cover[loading]->GetImage()) {
delete cover[loading];
cover[loading] = NULL;
snprintf(imgPath, sizeof(imgPath), "%snoimage.png", CFG.theme_path); //Load no image
cover[loading] = new GuiImageData(imgPath, nocover_png);
}
}
coverImg[loading] = new GuiImage(cover[loading]);
} else {
if (direction >= 0) {
if (loading < BUFFERSIZE-1) {
if (coverImg[loading]) {
delete coverImg[loading];
coverImg[loading] = NULL;
}
if (loading == 0) {
if (cover[loading]) {
delete cover[loading];
cover[loading] = NULL;
}
cover[loading] = new GuiImageData(NULL, 0);
cover[loading] = cover[loading+1];
} else {
cover[loading] = cover[loading+1];
}
coverImg[loading] = new GuiImage(cover[loading]);
} else {
cover[loading] = new GuiImageData(imgPath,0);
if (!cover[loading]->GetImage()) {
delete cover[loading];
cover[loading] = NULL;
snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, ID); //Load short id image
cover[loading] = new GuiImageData(imgPath, 0);
if (!cover[loading]->GetImage()) {
delete cover[loading];
cover[loading] = NULL;
snprintf(imgPath, sizeof(imgPath), "%snoimage.png", Settings.covers_path); //Load no image
cover[loading] = new GuiImageData(imgPath, nocover_png);
}
}
if (coverImg[loading]) {
delete coverImg[loading];
coverImg[loading] = NULL;
}
coverImg[loading] = new GuiImage(cover[loading]);
}
} else if (direction < 0) {
if (BUFFERSIZE-loading-1 > 0) {
if (coverImg[BUFFERSIZE-loading-1]) {
delete coverImg[BUFFERSIZE-loading-1];
coverImg[BUFFERSIZE-loading-1] = NULL;
}
if (BUFFERSIZE-loading-1 == BUFFERSIZE-1) {
if (cover[BUFFERSIZE-loading-1]) {
delete cover[BUFFERSIZE-loading-1];
cover[BUFFERSIZE-loading-1] = NULL;
}
cover[BUFFERSIZE-loading-1] = new GuiImageData(NULL, 0);
cover[BUFFERSIZE-loading-1] = cover[BUFFERSIZE-loading-1-1];
} else {
cover[BUFFERSIZE-loading-1] = cover[BUFFERSIZE-loading-1-1];
coverImg[BUFFERSIZE-loading-1] = new GuiImage(cover[BUFFERSIZE-loading-1]);
}
} else {
header = &gameList[offset];
snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]);
snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]);
snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, IDfull); //Load full id image
cover[0] = new GuiImageData(imgPath,0);
if (!cover[0]->GetImage()) {
delete cover[0];
cover[0] = NULL;
snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, ID); //Load short id image
cover[0] = new GuiImageData(imgPath, 0);
if (!cover[0]->GetImage()) {
delete cover[0];
cover[0] = NULL;
snprintf(imgPath, sizeof(imgPath), "%snoimage.png", Settings.covers_path); //Load no image
cover[0] = new GuiImageData(imgPath, nocover_png);
}
}
if (coverImg[0]) {
delete coverImg[0];
coverImg[0] = NULL;
}
coverImg[0] = new GuiImage(cover[0]);
}
}
}
loading++;
}
loading = BUFFERSIZE;
changed = false;
firstime = false;
}
void NewOffset(int off, int d) {
if (offset == off || loading < BUFFERSIZE)
return;
direction = d;
offset = off;
loading = 0;
changed = true;
}
/****************************************************************************
* HaltBuffer
***************************************************************************/
void HaltBufferThread() {
BufferHalt = true;
firstime = true;
changed = true;
loading = 0;
offset = 0;
direction = 0;
// wait for thread to finish
while (!LWP_ThreadIsSuspended(bufferthread))
usleep(100);
for (int i = 0; i < BUFFERSIZE; i++) {
delete cover[i];
cover[i] = NULL;
delete coverImg[i];
coverImg[i] = NULL;
delete NoCover[i];
NoCover[i] = NULL;
}
}
/****************************************************************************
* ResumeBufferThread
***************************************************************************/
void ResumeBufferThread(int offset) {
BufferHalt = false;
firstime = true;
changed = true;
loading = 0;
offset = offset;
direction = 0;
for (u8 i = 0; i < BUFFERSIZE; i++) {
if (NoCover[i] != NULL) {
delete NoCover[i];
NoCover[i] = NULL;
}
NoCover[i] = new GuiImage(&NoCoverData);
}
LWP_ResumeThread(bufferthread);
}
/*********************************************************************************
* Bufferthread
*********************************************************************************/
static void * bufferinitcallback(void *arg) {
while (1) {
if (BufferHalt)
LWP_SuspendThread(bufferthread);
LoadImages();
}
return NULL;
}
/****************************************************************************
* InitBufferThread with priority 50
***************************************************************************/
void InitBufferThread() {
LWP_CreateThread(&bufferthread, bufferinitcallback, NULL, NULL, 0, 50);
}
/****************************************************************************
* ShutdownThread
***************************************************************************/
void ShutdownBufferThread() {
LWP_JoinThread (bufferthread, NULL);
bufferthread = LWP_THREAD_NULL;
}

View File

@ -1,18 +0,0 @@
/****************************************************************************
* USB Loader GX Team
* buffer.cpp
*
* Loading covers in a background thread
***************************************************************************/
#ifndef _BUFFER_H_
#define _BUFFER_H_
GuiImage * ImageBuffer(int imagenumber);
void NewOffset(int off, int d);
void InitBufferThread();
void ShutdownBufferThread();
void ResumeBufferThread(int offset);
void HaltBufferThread();
#endif

View File

@ -1,153 +0,0 @@
#include <string.h>
#include <unistd.h>
#include <fat.h>
#include "libwiigui/gui.h"
#include "libwiigui/gui_customoptionbrowser.h"
#include "prompts/PromptWindows.h"
#include "language/gettext.h"
#include "fatmounter.h"
#include "menu.h"
#include "filelist.h"
#include "sys.h"
#include "gct.h"
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
/*** Extern variables ***/
extern GuiWindow * mainWindow;
/****************************************************************************
* CheatMenu
***************************************************************************/
int CheatMenu(const char * gameID) {
int choice = 0;
bool exit = false;
int ret = 1;
GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume);
char imgPath[100];
snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path);
GuiImageData btnOutline(imgPath, button_dialogue_box_png);
snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path);
GuiImageData settingsbg(imgPath, settings_background_png);
GuiImage settingsbackground(&settingsbg);
GuiTrigger trigA;
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
GuiTrigger trigB;
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
GuiText backBtnTxt(tr("Back") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage backBtnImg(&btnOutline);
GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -140, 400, &trigA, NULL, &btnClick,1);
backBtn.SetLabel(&backBtnTxt);
backBtn.SetTrigger(&trigB);
GuiText createBtnTxt(tr("Create") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
createBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage createBtnImg(&btnOutline);
GuiButton createBtn(&createBtnImg,&createBtnImg, 2, 3, 160, 400, &trigA, NULL, &btnClick,1);
createBtn.SetLabel(&createBtnTxt);
char txtfilename[55];
snprintf(txtfilename,sizeof(txtfilename),"%s%s.txt",Settings.TxtCheatcodespath,gameID);
GCTCheats c;
int check = c.openTxtfile(txtfilename);
int download =0;
switch (check) {
case -1:
WindowPrompt(tr("Error"),tr("Cheatfile is blank"),tr("OK"));
break;
case 0:
download = WindowPrompt(tr("Error"),tr("No Cheatfile found"),tr("OK"),tr("Download Now"));
if (download==0)
download = CodeDownload(gameID);
break;
case 1:
int cntcheats = c.getCnt();
customOptionList cheatslst(cntcheats);
GuiCustomOptionBrowser chtBrowser(400, 280, &cheatslst, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 1, 90);
chtBrowser.SetPosition(0, 90);
chtBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
chtBrowser.SetClickable(true);
GuiText titleTxt(c.getGameName().c_str(), 28, (GXColor) {0, 0, 0, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetMaxWidth(350, GuiText::SCROLL);
titleTxt.SetPosition(12,40);
for (int i = 0; i <= cntcheats; i++) {
cheatslst.SetValue(i, "%s",c.getCheatName(i).c_str());
cheatslst.SetName(i, "OFF");
}
HaltGui();
GuiWindow w(screenwidth, screenheight);
w.Append(&settingsbackground);
w.Append(&titleTxt);
w.Append(&backBtn);
w.Append(&createBtn);
w.Append(&chtBrowser);
mainWindow->SetState(STATE_DISABLED);
mainWindow->ChangeFocus(&w);
mainWindow->Append(&w);
ResumeGui();
while (!exit) {
VIDEO_WaitVSync ();
ret = chtBrowser.GetClickedOption();
if (ret != -1) {
const char *strCheck = cheatslst.GetName(ret);
if (strncmp(strCheck,"ON",2) == 0) {
cheatslst.SetName(ret,"%s","OFF");
} else if (strncmp(strCheck,"OFF",3) == 0) {
cheatslst.SetName(ret,"%s","ON");
}
}
if (createBtn.GetState() == STATE_CLICKED) {
createBtn.ResetState();
if (cntcheats > 0) {
int selectednrs[30];
int x = 0;
for (int i = 0; i <= cntcheats; i++) {
const char *strCheck = cheatslst.GetName(i);
if (strncmp(strCheck,"ON",2) == 0) {
selectednrs[x] = i;
x++;
}
}
string chtpath = Settings.Cheatcodespath;
string gctfname = chtpath + c.getGameID() + ".gct";
c.createGCT(selectednrs,x,gctfname.c_str());
WindowPrompt(tr("GCT File created"),NULL,tr("OK"));
exit = true;
break;
} else WindowPrompt(tr("Error"),tr("Could not create GCT file"),tr("OK"));
}
if (backBtn.GetState() == STATE_CLICKED) {
backBtn.ResetState();
exit = true;
break;
}
}
HaltGui();
mainWindow->SetState(STATE_DEFAULT);
mainWindow->Remove(&w);
ResumeGui();
break;
}
return choice;
}

View File

@ -1,13 +0,0 @@
/****************************************************************************
* Cheat Menu
* USB Loader GX 2009
*
* cheatmenu.h
***************************************************************************/
#ifndef _CHEATMENU_H_
#define _CHEATMENU_H_
int CheatMenu(const char * gameID);
#endif

View File

@ -1,218 +0,0 @@
/*
* gct.h
* Class to handle Ocarina TXT Cheatfiles
* nIxx
*/
#include <iostream>
#include <fstream>
#include "gct.h"
#define ERRORRANGE "Error: CheatNr out of range"
GCTCheats::GCTCheats(void) {
iCntCheats = 0;
}
GCTCheats::~GCTCheats(void) {
string sGameID ="";
string sGameTitle = "";
/*string sCheatName[MAXCHEATS];
string sCheats[MAXCHEATS];
string sCheatComment[MAXCHEATS];*/
}
int GCTCheats::getCnt() {
return iCntCheats;
}
string GCTCheats::getGameName(void) {
return sGameTitle;
}
string GCTCheats::getGameID(void) {
return sGameID;
}
string GCTCheats::getCheat(int nr) {
if (nr <= (iCntCheats-1)) {
return sCheats[nr];
} else {
return ERRORRANGE;
}
}
string GCTCheats::getCheatName(int nr) {
if (nr <= (iCntCheats-1)) {
return sCheatName[nr];
} else {
return ERRORRANGE;
}
}
string GCTCheats::getCheatComment(int nr) {
if (nr <= (iCntCheats-1)) {
return sCheatComment[nr];
} else {
return ERRORRANGE;
}
}
int GCTCheats::createGCT(int nr,const char * filename) {
ofstream filestr;
filestr.open(filename);
if (filestr.fail())
return 0;
//Header and Footer
char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde};
char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
string buf = getCheat(nr);
filestr.write(header,sizeof(header));
int x = 0;
long int li;
int len = buf.size();
while (x < len) {
string temp = buf.substr(x,2);
li = strtol(temp.c_str(),NULL,16);
temp = li;
filestr.write(temp.c_str(),1);
x +=2;
}
filestr.write(footer,sizeof(footer));
filestr.close();
return 1;
}
int GCTCheats::createGCT(const char * chtbuffer,const char * filename) {
ofstream filestr;
filestr.open(filename);
if (filestr.fail())
return 0;
//Header and Footer
char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde};
char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
string buf = chtbuffer;
filestr.write(header,sizeof(header));
int x = 0;
long int li;
int len = buf.size();
while (x < len) {
string temp = buf.substr(x,2);
li = strtol(temp.c_str(),NULL,16);
temp = li;
filestr.write(temp.c_str(),1);
x +=2;
}
filestr.write(footer,sizeof(footer));
filestr.close();
return 1;
}
int GCTCheats::createGCT(int nr[],int cnt,const char * filename) {
ofstream filestr;
filestr.open(filename);
if (filestr.fail())
return 0;
//Header and Footer
char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde};
char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
filestr.write(header,sizeof(header));
int c = 0;
while (c != cnt) {
int actnr = nr[c];
string buf = getCheat(actnr);
long int li;
int len = buf.size();
int x = 0;
while (x < len) {
string temp = buf.substr(x,2);
li = strtol(temp.c_str(),NULL,16);
temp = li;
filestr.write(temp.c_str(),1);
x +=2;
}
c++;
}
filestr.write(footer,sizeof(footer));
filestr.close();
return 1;
}
int GCTCheats::openTxtfile(const char * filename) {
ifstream filestr;
int i = 0;
string str;
filestr.open(filename);
if (filestr.fail())
return 0;
filestr.seekg(0,ios_base::end);
int size = filestr.tellg();
if (size <= 0) return -1;
filestr.seekg(0,ios_base::beg);
getline(filestr,sGameID);
getline(filestr,sGameTitle);
filestr.ignore();
while (!filestr.eof()) {
getline(filestr,sCheatName[i]);
string cheatdata;
bool emptyline = false;
bool isComment = false;
do {
getline(filestr,str,'\n');
//cheatdata.append(str);
if (str == "") {
emptyline = true;
break;
}
if (str.size() <= 16 || str.size() > 17 ) {
isComment = true;
printf ("%i",str.size());
}
if (!isComment) {
cheatdata.append(str);
size_t found=cheatdata.find(' ');
cheatdata.replace(found,1,"");
} else {
sCheatComment[i] = str;
}
if (filestr.eof()) break;
} while (!emptyline);
sCheats[i] = cheatdata;
i++;
}
iCntCheats = i;
filestr.close();
return 1;
}

View File

@ -1,71 +0,0 @@
/*
* gct.h
* Class to handle Ocarina TXT Cheatfiles
*
*/
#ifndef _GCT_H
#define _GCT_H
#include <sstream>
#define MAXCHEATS 40
using namespace std;
//!Handles Ocarina TXT Cheatfiles
class GCTCheats {
private:
string sGameID;
string sGameTitle;
string sCheatName[MAXCHEATS];
string sCheats[MAXCHEATS];
string sCheatComment[MAXCHEATS];
int iCntCheats;
public:
//!Constructor
GCTCheats(void);
//!Destructor
~GCTCheats(void);
//!Open txt file with cheats
//!\param filename name of TXT file
//!\return error code
int openTxtfile(const char * filename);
//!Creates GCT file for one cheat
//!\param nr selected Cheat Numbers
//!\param filename name of GCT file
//!\return error code
int createGCT(int nr,const char * filename);
//!Creates GCT file from a buffer
//!\param chtbuffer buffer that holds the cheat data
//!\param filename name of GCT file
//!\return error code
int createGCT(const char * chtbuffer,const char * filename);
//!Creates GCT file
//!\param nr[] array of selected Cheat Numbers
//!\param cnt size of array
//!\param filename name of GCT file
//!\return error code
int createGCT(int nr[],int cnt,const char * filename);
//!Gets Count cheats
//!\return Count cheats
int getCnt();
//!Gets Game Name
//!\return Game Name
string getGameName(void);
//!Gets GameID
//!\return GameID
string getGameID(void);
//!Gets cheat data
//!\return cheat data
string getCheat(int nr);
//!Gets Cheat Name
//!\return Cheat Name
string getCheatName(int nr);
//!Gets Cheat Comment
//!\return Cheat Comment
string getCheatComment(int nr);
};
#endif /* _GCT_H */

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

View File

@ -1,56 +0,0 @@
#include <fat.h>
#include <string.h>
#include <ogc/lwp_watchdog.h>
#include <ogc/mutex.h>
#include <ogc/system.h>
#include <ogc/usbstorage.h>
#include <sdcard/wiisd_io.h>
#include "usbloader/usbstorage.h"
//these are the only stable and speed is good
#define CACHE 8
#define SECTORS 64
int USBDevice_Init() {
//closing all open Files write back the cache and then shutdown em!
fatUnmount("USB:/");
//right now mounts first FAT-partition
if (fatMount("USB", &__io_wiiums, 0, CACHE, SECTORS)) {
//try first mount with cIOS
return 1;
} else if (fatMount("USB", &__io_usbstorage, 0, CACHE, SECTORS)) {
//try now mount with libogc
return 1;
}
return -1;
}
void USBDevice_deInit() {
//closing all open Files write back the cache and then shutdown em!
fatUnmount("USB:/");
}
int isSdInserted() {
return __io_wiisd.isInserted();
}
int isInserted(const char *path) {
if (!strncmp(path, "USB:", 4))
return 1;
return __io_wiisd.isInserted();
}
int SDCard_Init() {
//closing all open Files write back the cache and then shutdown em!
fatUnmount("SD:/");
//right now mounts first FAT-partition
if (fatMount("SD", &__io_wiisd, 0, CACHE, SECTORS))
return 1;
return -1;
}
void SDCard_deInit() {
//closing all open Files write back the cache and then shutdown em!
fatUnmount("SD:/");
}

View File

@ -1,19 +0,0 @@
#ifndef _FATMOUNTER_H_
#define _FATMOUNTER_H_
#ifdef __cplusplus
extern "C" {
#endif
int USBDevice_Init();
void USBDevice_deInit();
int isSdInserted();
int isInserted(const char *path);
int SDCard_Init();
void SDCard_deInit();
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,475 +0,0 @@
/****************************************************************************
* libwiigui Template
* Tantric 2009
*
* imagelist.h
* Contains a list of all of the files in the images, fonts, sounds folders
***************************************************************************/
#ifndef _FILELIST_H_
#define _FILELIST_H_
#include <gccore.h>
extern const u8 font_ttf[];
extern const u32 font_ttf_size;
extern const u8 clock_ttf[];
extern const u32 clock_ttf_size;
extern const u8 closebutton_png[];
extern const u32 closebutton_png_size;
extern const u8 gxlogo_png[];
extern const u32 gxlogo_png_size;
extern const u8 sdcard_png[];
extern const u32 sdcard_png_size;
extern const u8 sdcard_over_png[];
extern const u32 sdcard_over_png_size;
extern const u8 Wifi_btn_png[];
extern const u32 Wifi_btn_png_size;
extern const u8 Channel_btn_png[];
extern const u32 Channel_btn_png_size;
extern const u8 wiimote_png[];
extern const u32 wiimote_png_size;
extern const u8 bg_music_ogg[];
extern const u32 bg_music_ogg_size;
extern const u8 credits_music_ogg[];
extern const u32 credits_music_ogg_size;
extern const u8 gameinfo1_png[];
extern const u32 gameinfo1_png_size;
extern const u8 gameinfo2_png[];
extern const u32 gameinfo2_png_size;
extern const u8 gameinfo1a_png[];
extern const u32 gameinfo1a_png_size;
extern const u8 gameinfo2a_png[];
extern const u32 gameinfo2a_png_size;
extern const u8 menuin_ogg[];
extern const u32 menuin_ogg_size;
extern const u8 menuout_ogg[];
extern const u32 menuout_ogg_size;
extern const u8 credits_button_png[];
extern const u32 credits_button_png_size;
extern const u8 credits_button_over_png[];
extern const u32 credits_button_over_png_size;
extern const u8 button_over_pcm[];
extern const u32 button_over_pcm_size;
extern const u8 button_click_pcm[];
extern const u32 button_click_pcm_size;
extern const u8 button_click2_pcm[];
extern const u32 button_click2_pcm_size;
extern const u8 tooltip_left_png[];
extern const u32 tooltip_left_png_size;
extern const u8 tooltip_tile_png[];
extern const u32 tooltip_tile_png_size;
extern const u8 tooltip_right_png[];
extern const u32 tooltip_right_png_size;
extern const u8 startgame_arrow_left_png[];
extern const u32 startgame_arrow_left_png_size;
extern const u8 startgame_arrow_right_png[];
extern const u32 startgame_arrow_right_png_size;
extern const u8 credits_bg_png[];
extern const u32 credits_bg_png_size;
extern const u8 little_star_png[];
extern const u32 little_star_png_size;
extern const u8 background_png[];
extern const u32 background_png_size;
extern const u8 wbackground_png[];
extern const u32 wbackground_png_size;
extern const u8 bg_options_settings_png[];
extern const u32 bg_options_settings_png_size;
extern const u8 settings_background_png[];
extern const u32 settings_background_png_size;
extern const u8 bg_browser_png[];
extern const u32 bg_browser_png_size;
extern const u8 folder_png[];
extern const u32 folder_png_size;
extern const u8 bg_browser_selection_png[];
extern const u32 bg_browser_selection_png_size;
extern const u8 addressbar_textbox_png[];
extern const u32 addressbar_textbox_png_size;
extern const u8 browser_png[];
extern const u32 browser_png_size;
extern const u8 browser_over_png[];
extern const u32 browser_over_png_size;
extern const u8 nocover_png[];
extern const u32 nocover_png_size;
extern const u8 nocoverFlat_png[];
extern const u32 nocoverFlat_png_size;
extern const u8 nodisc_png[];
extern const u32 nodisc_png_size;
extern const u8 button_install_png[];
extern const u32 button_install_png_size;
extern const u8 button_install_over_png[];
extern const u32 button_install_over_png_size;
extern const u8 dialogue_box_startgame_png[];
extern const u32 dialogue_box_startgame_png_size;
extern const u8 wdialogue_box_startgame_png[];
extern const u32 wdialogue_box_startgame_png_size;
extern const u8 button_dialogue_box_startgame_png[];
extern const u32 button_dialogue_box_startgame_size;
extern const u8 button_dialogue_box_png[];
extern const u32 button_dialogue_box_size;
extern const u8 keyboard_textbox_png[];
extern const u32 keyboard_textbox_png_size;
extern const u8 keyboard_key_png[];
extern const u32 keyboard_key_png_size;
extern const u8 keyboard_key_over_png[];
extern const u32 keyboard_key_over_png_size;
extern const u8 keyboard_mediumkey_over_png[];
extern const u32 keyboard_mediumkey_over_png_size;
extern const u8 keyboard_largekey_over_png[];
extern const u32 keyboard_largekey_over_png_size;
extern const u8 menu_button_png[];
extern const u32 menu_button_size;
extern const u8 menu_button_over_png[];
extern const u32 menu_button_over_size;
extern const u8 settings_button_png[];
extern const u32 settings_button_size;
extern const u8 settings_button_over_png[];
extern const u32 settings_button_over_size;
extern const u8 settings_menu_button_png[];
extern const u32 settings_menu_button_size;
extern const u8 wiimote_poweroff_png[];
extern const u32 wiimote_poweroff_png_size;
extern const u8 dialogue_box_png[];
extern const u32 dialogue_box_png_size;
extern const u8 wiimote_poweroff_over_png[];
extern const u32 wiimote_poweroff_over_png_size;
extern const u8 bg_options_png[];
extern const u32 bg_options_png_size;
extern const u8 bg_options_entry_png[];
extern const u32 bg_options_entry_png_size;
extern const u8 scrollbar_png[];
extern const u32 scrollbar_png_size;
extern const u8 scrollbar_arrowup_png[];
extern const u32 scrollbar_arrowup_png_size;
extern const u8 scrollbar_arrowup_over_png[];
extern const u32 scrollbar_arrowup_over_png_size;
extern const u8 scrollbar_arrowdown_png[];
extern const u32 scrollbar_arrowdown_png_size;
extern const u8 scrollbar_arrowdown_over_png[];
extern const u32 scrollbar_arrowdown_over_png_size;
extern const u8 scrollbar_box_png[];
extern const u32 scrollbar_box_png_size;
extern const u8 scrollbar_box_over_png[];
extern const u32 scrollbar_box_over_png_size;
extern const u8 progressbar_png[];
extern const u32 progressbar_png_size;
extern const u8 progressbar_empty_png[];
extern const u32 progressbar_empty_png_size;
extern const u8 progressbar_outline_png[];
extern const u32 progressbar_outline_png_size;
extern const u8 player1_point_png[];
extern const u32 player1_point_png_size;
extern const u8 player2_point_png[];
extern const u32 player2_point_png_size;
extern const u8 player3_point_png[];
extern const u32 player3_point_png_size;
extern const u8 player4_point_png[];
extern const u32 player4_point_png_size;
extern const u8 rplayer1_point_png[];
extern const u32 rplayer1_point_png_size;
extern const u8 rplayer2_point_png[];
extern const u32 rplayer2_point_png_size;
extern const u8 rplayer3_point_png[];
extern const u32 rplayer3_point_png_size;
extern const u8 rplayer4_point_png[];
extern const u32 rplayer4_point_png_size;
extern const u8 battery_png[];
extern const u32 battery_png_size;
extern const u8 battery_bar_png[];
extern const u32 battery_bar_png_size;
extern const u8 battery_white_png[];
extern const u32 battery_white_png_size;
extern const u8 battery_bar_white_png[];
extern const u32 battery_bar_white_png_size;
extern const u8 battery_red_png[];
extern const u32 battery_red_png_size;
extern const u8 arrow_next_png[];
extern const u32 arrow_next_png_size;
extern const u8 arrow_previous_png[];
extern const u32 arrow_previous_png_size;
extern const u8 mp3_pause_png[];
extern const u32 mp3_pause_png_size;
extern const u8 exit_top_png[];
extern const u32 exit_top_png_size;
extern const u8 exit_top_over_png[];
extern const u32 exit_top_over_png_size;
extern const u8 exit_bottom_png[];
extern const u32 exit_bottom_png_size;
extern const u8 exit_bottom_over_png[];
extern const u32 exit_bottom_over_png_size;
extern const u8 exit_button_png[];
extern const u32 exit_button_png_size;
extern const u8 mp3_stop_png[];
extern const u32 mp3_stop_png_size;
extern const u8 favorite_png[];
extern const u32 favorite_png_size;
extern const u8 not_favorite_png[];
extern const u32 not_favorite_png_size;
extern const u8 favIcon_png[];
extern const u32 favIcon_png_size;
extern const u8 abcIcon_png[];
extern const u32 abcIcon_png_size;
extern const u8 playCountIcon_png[];
extern const u32 playCountIcon_png_size;
extern const u8 arrangeList_png[];
extern const u32 arrangeList_png_size;
extern const u8 arrangeGrid_png[];
extern const u32 arrangeGrid_png_size;
extern const u8 arrangeCarousel_png[];
extern const u32 arrangeCarousel_png_size;
extern const u8 favIcon_gray_png[];
extern const u32 favIcon_gray_png_size;
extern const u8 abcIcon_gray_png[];
extern const u32 abcIcon_gray_png_size;
extern const u8 playCountIcon_gray_png[];
extern const u32 playCountIcon_gray_png_size;
extern const u8 arrangeGrid_gray_png[];
extern const u32 arrangeGrid_gray_png_size;
extern const u8 arrangeList_gray_png[];
extern const u32 arrangeList_gray_png_size;
extern const u8 arrangeCarousel_gray_png[];
extern const u32 arrangeCarousel_gray_png_size;
extern const u8 settings_title_png[];
extern const u32 settings_title_png_size;
extern const u8 settings_title_over_png[];
extern const u32 settings_title_over_png_size;
extern const u8 pageindicator_png[];
extern const u32 pageindicator_png_size;
extern const u8 Wiimote1_png[];
extern const u32 Wiimote1_png_size;
extern const u8 Wiimote2_png[];
extern const u32 Wiimote2_png_size;
extern const u8 wifi1_png[];
extern const u32 wifi1_png_size;
extern const u8 wifi2_png[];
extern const u32 wifi2png_size;
extern const u8 wifi3_png[];
extern const u32 wifi3_png_size;
extern const u8 wifi4_png[];
extern const u32 wifi4_png_size;
extern const u8 wifi8_png[];
extern const u32 wifi8_png_size;
extern const u8 Wiimote4_png[];
extern const u32 Wiimote4_png_size;
extern const u8 norating_png[];
extern const u32 norating_png_size;
extern const u8 guitar_png[];
extern const u32 guitar_png_size;
extern const u8 guitarR_png[];
extern const u32 guitarR_png_size;
extern const u8 microphone_png[];
extern const u32 microphone_png_size;
extern const u8 microphoneR_png[];
extern const u32 microphoneR_png_size;
extern const u8 gcncontroller_png[];
extern const u32 gcncontroller_png_size;
extern const u8 gcncontrollerR_png[];
extern const u32 gcncontrollerR_png_size;
extern const u8 classiccontroller_png[];
extern const u32 classiccontroller_png_size;
extern const u8 classiccontrollerR_png[];
extern const u32 classiccontrollerR_png_size;
extern const u8 nunchuk_png[];
extern const u32 nunchuk_png_size;
extern const u8 nunchukR_png[];
extern const u32 nunchukR_png_size;
extern const u8 dancepadR_png[];
extern const u32 dancepadR_size;
extern const u8 dancepad_png[];
extern const u32 dancepad_png_size;
extern const u8 balanceboard_png[];
extern const u32 balanceboard_png_size;
extern const u8 balanceboardR_png[];
extern const u32 balanceboardR_png_size;
extern const u8 drums_png[];
extern const u32 drums_png_size;
extern const u8 drumsR_png[];
extern const u32 drumsR_png_size;
extern const u8 motionplus_png[];
extern const u32 motionplus_png_size;
extern const u8 motionplusR_png[];
extern const u32 motionplusR_png_size;
extern const u8 wheel_png[];
extern const u32 wheel_png_size;
extern const u8 wheelR_png[];
extern const u32 wheelR_png_size;
extern const u8 esrb_ec_png[];
extern const u32 esrb_ec_png_size;
extern const u8 esrb_e_png[];
extern const u32 esrb_e_png_size;
extern const u8 esrb_eten_png[];
extern const u32 esrb_eten_png_size;
extern const u8 esrb_t_png[];
extern const u32 esrb_t_png_size;
extern const u8 esrb_m_png[];
extern const u32 esrb_m_png_size;
extern const u8 esrb_ao_png[];
extern const u32 esrb_ao_png_size;
extern const u8 cero_a_png[];
extern const u32 cero_a_png_size;
extern const u8 cero_b_png[];
extern const u32 cero_b_png_size;
extern const u8 cero_c_png[];
extern const u32 cero_c_png_size;
extern const u8 cero_d_png[];
extern const u32 cero_d_png_size;
extern const u8 cero_z_png[];
extern const u32 cero_z_png_size;
extern const u8 pegi_3_png[];
extern const u32 pegi_3_png_size;
extern const u8 pegi_7_png[];
extern const u32 pegi_7_png_size;
extern const u8 pegi_12_png[];
extern const u32 pegi_12_png_size;
extern const u8 pegi_16_png[];
extern const u32 pegi_16_png_size;
extern const u8 pegi_18_png[];
extern const u32 pegi_18_png_size;
#endif

BIN
source/files/DOL.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

BIN
source/files/ELF.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

BIN
source/files/SendElf.exe Normal file

Binary file not shown.

BIN
source/files/WAD.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

BIN
source/files/Wiiload.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
source/files/wiiload.exe Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,144 +0,0 @@
#include <gccore.h>
#include <ogcsys.h>
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <ogc/machine/processor.h>
#include <wiiuse/wpad.h>
#include "fatmounter.h"
#include "dolloader.h"
#include "elfloader.h"
void *innetbuffer = NULL;
int AllocHomebrewMemory(u32 filesize) {
innetbuffer = malloc(filesize);
if (!innetbuffer)
return -1;
return 1;
}
void FreeHomebrewBuffer() {
free(innetbuffer);
innetbuffer = NULL;
}
void CopyHomebrewMemory(u32 read, u8 *temp, u32 len) {
memcpy(((u8 *) innetbuffer)+read, temp, len);
}
int BootHomebrew(char * path) {
void *buffer = NULL;
u32 filesize = 0;
entrypoint entry;
u32 cpu_isr;
FILE * file = fopen(path, "rb");
if (!file) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
fseek (file, 0, SEEK_END);
filesize = ftell(file);
rewind(file);
buffer = malloc(filesize);
if (fread (buffer, 1, filesize, file) != filesize) {
fclose (file);
free(buffer);
SDCard_deInit();
USBDevice_deInit();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}
fclose (file);
struct __argv args;
bzero(&args, sizeof(args));
args.argvMagic = ARGV_MAGIC;
args.length = strlen(path) + 2;
args.commandLine = (char*)malloc(args.length);
if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
strcpy(args.commandLine, path);
args.commandLine[args.length - 1] = '\0';
args.argc = 1;
args.argv = &args.commandLine;
args.endARGV = args.argv + 1;
int ret = valid_elf_image(buffer);
if (ret == 1)
entry = (entrypoint) load_elf_image(buffer);
else
entry = (entrypoint) load_dol(buffer, &args);
free(buffer);
if (!entry) {
SDCard_deInit();
USBDevice_deInit();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}
SDCard_deInit();
USBDevice_deInit();
WPAD_Flush(0);
WPAD_Disconnect(0);
WPAD_Shutdown();
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
_CPU_ISR_Disable (cpu_isr);
__exception_closeall();
entry();
_CPU_ISR_Restore (cpu_isr);
return 0;
}
int BootHomebrewFromMem() {
entrypoint entry;
u32 cpu_isr;
if (!innetbuffer) {
SDCard_deInit();
USBDevice_deInit();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}
struct __argv args;
int ret = valid_elf_image(innetbuffer);
if (ret == 1)
entry = (entrypoint) load_elf_image(innetbuffer);
else
entry = (entrypoint) load_dol(innetbuffer, &args);
free(innetbuffer);
if (!entry) {
SDCard_deInit();
USBDevice_deInit();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}
SDCard_deInit();
USBDevice_deInit();
WPAD_Flush(0);
WPAD_Disconnect(0);
WPAD_Shutdown();
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
_CPU_ISR_Disable (cpu_isr);
__exception_closeall();
entry();
_CPU_ISR_Restore (cpu_isr);
return 0;
}

View File

@ -1,18 +0,0 @@
#ifndef _BOOTHOMEBREW_H_
#define _BOOTHOMEBREW_H_
#ifdef __cplusplus
extern "C" {
#endif
int BootHomebrew(char * path);
int BootHomebrewFromMem();
void CopyHomebrewMemory(u32 read, u8 *temp, u32 len);
int AllocHomebrewMemory(u32 filesize);
void FreeHomebrewBuffer();
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,911 +0,0 @@
/****************************************************************************
* HomebrewBrowse
* USB Loader GX 2009
*
* Homebrew launcher for USB Loader GX
*
* homebrewbrowse.cpp
***************************************************************************/
#include <string.h>
#include <unistd.h>
#include "language/gettext.h"
#include "libwiigui/gui.h"
#include "prompts/TitleBrowser.h"
#include "prompts/PromptWindows.h"
#include "prompts/ProgressWindow.h"
#include "homebrewboot/HomebrewFiles.h"
#include "homebrewboot/HomebrewXML.h"
#include "homebrewboot/BootHomebrew.h"
#include "network/networkops.h"
#include "menu.h"
#include "filelist.h"
#include "sys.h"
#include "network/http.h"
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
/*** Extern variables ***/
extern GuiWindow * mainWindow;
extern GuiSound * bgMusic;
extern GuiImage * bgImg;
extern u32 infilesize;
extern u8 shutdown;
extern u8 reset;
/*** Variables used elsewhere ***/
u8 boothomebrew = 0;
/****************************************************************************
* roundup Function
***************************************************************************/
int roundup(float number) {
if (number == (int) number)
return (int) number;
else
return (int) (number+1);
}
/****************************************************************************
* MenuHomebrewBrowse
***************************************************************************/
int MenuHomebrewBrowse() {
int menu = MENU_NONE;
int choice = 0;
HomebrewFiles HomebrewFiles(Settings.homebrewapps_path);
u32 filecount = HomebrewFiles.GetFilecount();
if (!filecount) {
WindowPrompt(tr("No .dol or .elf files found."),0, tr("OK"));
return MENU_DISCLIST;
}
enum {
FADE,
LEFT,
RIGHT
};
if (IsNetworkInit())
ResumeNetworkWait();
int slidedirection = FADE;
/*** Sound Variables ***/
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume);
GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume);
GuiSound btnClick1(button_click_pcm, button_click_pcm_size, SOUND_PCM, Settings.sfxvolume);
/*** Image Variables ***/
char imgPath[150];
snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path);
GuiImageData btnOutline(imgPath, button_dialogue_box_png);
snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path);
GuiImageData bgData(imgPath, settings_background_png);
snprintf(imgPath, sizeof(imgPath), "%ssettings_title.png", CFG.theme_path);
GuiImageData MainButtonImgData(imgPath, settings_title_png);
snprintf(imgPath, sizeof(imgPath), "%ssettings_title_over.png", CFG.theme_path);
GuiImageData MainButtonImgOverData(imgPath, settings_title_over_png);
snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_left.png", CFG.theme_path);
GuiImageData arrow_left(imgPath, startgame_arrow_left_png);
snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path);
GuiImageData arrow_right(imgPath, startgame_arrow_right_png);
snprintf(imgPath, sizeof(imgPath), "%sWifi_btn.png", CFG.theme_path);
GuiImageData wifiImgData(imgPath, Wifi_btn_png);
snprintf(imgPath, sizeof(imgPath), "%sChannel_btn.png", CFG.theme_path);
GuiImageData channelImgData(imgPath, Channel_btn_png);
GuiImage background(&bgData);
/*** Trigger Variables ***/
GuiTrigger trigA;
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
GuiTrigger trigHome;
trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0);
GuiTrigger trigB;
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
GuiTrigger trigL;
trigL.SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT);
GuiTrigger trigR;
trigR.SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT);
GuiTrigger trigMinus;
trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
GuiTrigger trigPlus;
trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0);
GuiText titleTxt(tr("Homebrew Launcher"), 28, (GXColor) {0, 0, 0, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(0,40);
GuiImageData *IconData[4];
GuiImage *IconImg[4];
for (int i = 0; i < 4; i++) {
IconData[i] = NULL;
IconImg[i] = NULL;
}
/*** Buttons ***/
GuiText backBtnTxt(tr("Back") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage backBtnImg(&btnOutline);
if (Settings.wsprompt == yes) {
backBtnTxt.SetWidescreen(CFG.widescreen);
backBtnImg.SetWidescreen(CFG.widescreen);
}
GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -180, 400, &trigA, &btnSoundOver, &btnClick,1);
backBtn.SetLabel(&backBtnTxt);
backBtn.SetTrigger(&trigB);
GuiButton homo(1,1);
homo.SetTrigger(&trigHome);
GuiImage GoLeftImg(&arrow_left);
GuiButton GoLeftBtn(GoLeftImg.GetWidth(), GoLeftImg.GetHeight());
GoLeftBtn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
GoLeftBtn.SetPosition(25, -25);
GoLeftBtn.SetImage(&GoLeftImg);
GoLeftBtn.SetSoundOver(&btnSoundOver);
GoLeftBtn.SetSoundClick(&btnClick);
GoLeftBtn.SetEffectGrow();
GoLeftBtn.SetTrigger(&trigA);
GoLeftBtn.SetTrigger(&trigL);
GoLeftBtn.SetTrigger(&trigMinus);
GuiImage GoRightImg(&arrow_right);
GuiButton GoRightBtn(GoRightImg.GetWidth(), GoRightImg.GetHeight());
GoRightBtn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
GoRightBtn.SetPosition(-25, -25);
GoRightBtn.SetImage(&GoRightImg);
GoRightBtn.SetSoundOver(&btnSoundOver);
GoRightBtn.SetSoundClick(&btnClick);
GoRightBtn.SetEffectGrow();
GoRightBtn.SetTrigger(&trigA);
GoRightBtn.SetTrigger(&trigR);
GoRightBtn.SetTrigger(&trigPlus);
char MainButtonText[50];
snprintf(MainButtonText, sizeof(MainButtonText), "%s", " ");
GuiImage MainButton1Img(&MainButtonImgData);
GuiImage MainButton1ImgOver(&MainButtonImgOverData);
GuiText MainButton1Txt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
MainButton1Txt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::DOTTED);
MainButton1Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton1Txt.SetPosition(148, -12);
GuiText MainButton1DescTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
MainButton1DescTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::DOTTED);
MainButton1DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton1DescTxt.SetPosition(148, 15);
GuiText MainButton1DescOverTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
MainButton1DescOverTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::SCROLL);
MainButton1DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton1DescOverTxt.SetPosition(148, 15);
GuiButton MainButton1(MainButton1Img.GetWidth(), MainButton1Img.GetHeight());
MainButton1.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
MainButton1.SetPosition(0, 90);
MainButton1.SetImage(&MainButton1Img);
MainButton1.SetImageOver(&MainButton1ImgOver);
MainButton1.SetLabel(&MainButton1Txt);
MainButton1.SetLabel(&MainButton1DescTxt,1);
MainButton1.SetLabelOver(&MainButton1DescOverTxt,1);
MainButton1.SetSoundOver(&btnSoundOver);
MainButton1.SetSoundClick(&btnClick1);
MainButton1.SetEffectGrow();
MainButton1.SetTrigger(&trigA);
GuiImage MainButton2Img(&MainButtonImgData);
GuiImage MainButton2ImgOver(&MainButtonImgOverData);
GuiText MainButton2Txt(MainButtonText, 18, (GXColor) {0, 0, 0, 255 });
MainButton2Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton2Txt.SetPosition(148, -12);
MainButton2Txt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton2DescTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
MainButton2DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton2DescTxt.SetPosition(148, 15);
MainButton2DescTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton2DescOverTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
MainButton2DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton2DescOverTxt.SetPosition(148, 15);
MainButton2DescOverTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::SCROLL);
GuiButton MainButton2(MainButton2Img.GetWidth(), MainButton2Img.GetHeight());
MainButton2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
MainButton2.SetPosition(0, 160);
MainButton2.SetImage(&MainButton2Img);
MainButton2.SetImageOver(&MainButton2ImgOver);
MainButton2.SetLabel(&MainButton2Txt);
MainButton2.SetLabel(&MainButton2DescTxt,1);
MainButton2.SetLabelOver(&MainButton2DescOverTxt,1);
MainButton2.SetSoundOver(&btnSoundOver);
MainButton2.SetSoundClick(&btnClick1);
MainButton2.SetEffectGrow();
MainButton2.SetTrigger(&trigA);
GuiImage MainButton3Img(&MainButtonImgData);
GuiImage MainButton3ImgOver(&MainButtonImgOverData);
GuiText MainButton3Txt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
MainButton3Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton3Txt.SetPosition(148, -12);
MainButton3Txt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton3DescTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
MainButton3DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton3DescTxt.SetPosition(148, 15);
MainButton3DescTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton3DescOverTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255 });
MainButton3DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton3DescOverTxt.SetPosition(148, 15);
MainButton3DescOverTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::SCROLL);
GuiButton MainButton3(MainButton3Img.GetWidth(), MainButton3Img.GetHeight());
MainButton3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
MainButton3.SetPosition(0, 230);
MainButton3.SetImage(&MainButton3Img);
MainButton3.SetImageOver(&MainButton3ImgOver);
MainButton3.SetLabel(&MainButton3Txt);
MainButton3.SetLabel(&MainButton3DescTxt,1);
MainButton3.SetLabelOver(&MainButton3DescOverTxt,1);
MainButton3.SetSoundOver(&btnSoundOver);
MainButton3.SetSoundClick(&btnClick1);
MainButton3.SetEffectGrow();
MainButton3.SetTrigger(&trigA);
GuiImage MainButton4Img(&MainButtonImgData);
GuiImage MainButton4ImgOver(&MainButtonImgOverData);
GuiText MainButton4Txt(MainButtonText, 18, (GXColor) {0, 0, 0, 255} );
MainButton4Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton4Txt.SetPosition(148, -12);
MainButton4Txt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton4DescTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
MainButton4DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton4DescTxt.SetPosition(148, 15);
MainButton4DescTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton4DescOverTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
MainButton4DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton4DescOverTxt.SetPosition(148, 15);
MainButton4DescOverTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::SCROLL);
GuiButton MainButton4(MainButton4Img.GetWidth(), MainButton4Img.GetHeight());
MainButton4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
MainButton4.SetPosition(0, 300);
MainButton4.SetImage(&MainButton4Img);
MainButton4.SetImageOver(&MainButton4ImgOver);
MainButton4.SetLabel(&MainButton4Txt);
MainButton4.SetLabel(&MainButton4DescTxt,1);
MainButton4.SetLabelOver(&MainButton4DescOverTxt,1);
MainButton4.SetSoundOver(&btnSoundOver);
MainButton4.SetSoundClick(&btnClick1);
MainButton4.SetEffectGrow();
MainButton4.SetTrigger(&trigA);
GuiImage wifiImg(&wifiImgData);
if (Settings.wsprompt == yes) {
wifiImg.SetWidescreen(CFG.widescreen);
}
GuiButton wifiBtn(wifiImg.GetWidth(), wifiImg.GetHeight());
wifiBtn.SetImage(&wifiImg);
wifiBtn.SetPosition(500, 400);
wifiBtn.SetSoundOver(&btnSoundOver);
wifiBtn.SetSoundClick(&btnClick1);
wifiBtn.SetEffectGrow();
wifiBtn.SetAlpha(80);
wifiBtn.SetTrigger(&trigA);
GuiImage channelBtnImg(&channelImgData);
channelBtnImg.SetWidescreen(CFG.widescreen);
GuiButton channelBtn(channelBtnImg.GetWidth(), channelBtnImg.GetHeight());
channelBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
channelBtn.SetPosition(440, 400);
channelBtn.SetImage(&channelBtnImg);
channelBtn.SetSoundOver(&btnSoundOver);
channelBtn.SetSoundClick(&btnClick);
channelBtn.SetEffectGrow();
channelBtn.SetTrigger(&trigA);
GuiTooltip * titleTT = NULL;
GuiWindow w(screenwidth, screenheight);
/*** XML Variables ***/
HomebrewXML XMLInfo[4];
int pageToDisplay = 1;
const int pages = roundup(filecount/4.0f);
bool wifi_btn_loaded=false;
while (menu == MENU_NONE) { //set pageToDisplay to 0 to quit
VIDEO_WaitVSync ();
menu = MENU_NONE;
bool changed = false;
int fileoffset = pageToDisplay*4-4;
/** Standard procedure made in all pages **/
MainButton1.StopEffect();
MainButton2.StopEffect();
MainButton3.StopEffect();
MainButton4.StopEffect();
if (slidedirection == RIGHT) {
MainButton1.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35);
MainButton2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35);
MainButton3.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35);
MainButton4.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35);
while (MainButton1.GetEffect()>0) usleep(50);
} else if (slidedirection == LEFT) {
MainButton1.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35);
MainButton2.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35);
MainButton3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35);
MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35);
while (MainButton1.GetEffect()>0) usleep(50);
}
HaltGui();
mainWindow->RemoveAll();
/** Set new icons **/
for (int i = 0; i < 4; i++) {
if (IconData[i] != NULL) {
delete IconData[i];
IconData[i] = NULL;
}
if (IconImg[i] != NULL) {
delete IconImg[i];
IconImg[i] = NULL;
}
if (fileoffset+i < (int) filecount) {
char iconpath[200];
snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+i));
IconData[i] = new GuiImageData(iconpath, 0);
if (IconData[i]->GetImage()) {
IconImg[i] = new GuiImage(IconData[i]);
IconImg[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
IconImg[i]->SetPosition(12, 0);
IconImg[i]->SetScale(0.95);
}
}
}
if (IconImg[0] != 0)
MainButton1.SetIcon(IconImg[0]);
else
MainButton1.SetIcon(NULL);
if (IconImg[1] != 0)
MainButton2.SetIcon(IconImg[1]);
else
MainButton2.SetIcon(NULL);
if (IconImg[2] != 0)
MainButton3.SetIcon(IconImg[2]);
else
MainButton3.SetIcon(NULL);
if (IconImg[3] != 0)
MainButton4.SetIcon(IconImg[3]);
else
MainButton4.SetIcon(NULL);
mainWindow->Append(&w);
w.RemoveAll();
w.Append(&background);
w.Append(&titleTxt);
w.Append(&backBtn);
w.Append(&homo);
w.Append(&wifiBtn);
w.Append(&channelBtn);
w.Append(&GoRightBtn);
w.Append(&GoLeftBtn);
if (pageToDisplay == pages) {
int buttonsleft = filecount-(pages-1)*4;
char * shortpath = NULL;
char temp[200];
if (buttonsleft > 0) {
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset));
if (XMLInfo[0].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[0].GetName());
MainButton1Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[0].GetShortDescription());
MainButton1DescTxt.SetText(MainButtonText);
MainButton1DescOverTxt.SetText(MainButtonText);
} else {
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset)), "%s", HomebrewFiles.GetFilepath(fileoffset));
shortpath = strrchr(temp, '/');
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset));
XMLInfo[0].SetName(MainButtonText);
MainButton1Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), " ");
MainButton1DescTxt.SetText(MainButtonText);
MainButton1DescOverTxt.SetText(MainButtonText);
}
w.Append(&MainButton1);
}
if (buttonsleft > 1) {
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1));
if (XMLInfo[1].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[1].GetName());
MainButton2Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[1].GetShortDescription());
MainButton2DescTxt.SetText(MainButtonText);
MainButton2DescOverTxt.SetText(MainButtonText);
} else {
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+1)), "%s", HomebrewFiles.GetFilepath(fileoffset+1));
shortpath = strrchr(temp, '/');
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+1));
XMLInfo[1].SetName(MainButtonText);
MainButton2Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), " ");
MainButton2DescTxt.SetText(MainButtonText);
MainButton2DescOverTxt.SetText(MainButtonText);
}
w.Append(&MainButton2);
}
if (buttonsleft > 2) {
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2));
if (XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
MainButton3Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
MainButton3DescTxt.SetText(MainButtonText);
MainButton3DescOverTxt.SetText(MainButtonText);
} else {
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2));
shortpath = strrchr(temp, '/');
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2));
XMLInfo[2].SetName(MainButtonText);
MainButton3Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), " ");
MainButton3DescTxt.SetText(MainButtonText);
MainButton3DescOverTxt.SetText(MainButtonText);
}
w.Append(&MainButton3);
}
if (buttonsleft > 3) {
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+3));
if (XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
MainButton4Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
MainButton4DescTxt.SetText(MainButtonText);
MainButton4DescOverTxt.SetText(MainButtonText);
} else {
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+3)), "%s", HomebrewFiles.GetFilepath(fileoffset+3));
shortpath = strrchr(temp, '/');
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+3));
XMLInfo[3].SetName(MainButtonText);
MainButton4Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), " ");
MainButton4DescTxt.SetText(MainButtonText);
MainButton4DescOverTxt.SetText(MainButtonText);
}
w.Append(&MainButton4);
}
} else {
char temp[200];
char *shortpath = NULL;
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset));
if (XMLInfo[0].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[0].GetName());
MainButton1Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[0].GetShortDescription());
MainButton1DescTxt.SetText(MainButtonText);
MainButton1DescOverTxt.SetText(MainButtonText);
} else {
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset)), "%s", HomebrewFiles.GetFilepath(fileoffset));
shortpath = strrchr(temp, '/');
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset));
XMLInfo[0].SetName(MainButtonText);
MainButton1Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), " ");
MainButton1DescTxt.SetText(MainButtonText);
MainButton1DescOverTxt.SetText(MainButtonText);
}
w.Append(&MainButton1);
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1));
if (XMLInfo[1].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[1].GetName());
MainButton2Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[1].GetShortDescription());
MainButton2DescTxt.SetText(MainButtonText);
MainButton2DescOverTxt.SetText(MainButtonText);
} else {
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+1)), "%s", HomebrewFiles.GetFilepath(fileoffset+1));
shortpath = strrchr(temp, '/');
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+1));
XMLInfo[1].SetName(MainButtonText);
MainButton2Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), " ");
MainButton2DescTxt.SetText(MainButtonText);
MainButton2DescOverTxt.SetText(MainButtonText);
}
w.Append(&MainButton2);
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2));
if (XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
MainButton3Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
MainButton3DescTxt.SetText(MainButtonText);
MainButton3DescOverTxt.SetText(MainButtonText);
} else {
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2));
shortpath = strrchr(temp, '/');
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2));
XMLInfo[2].SetName(MainButtonText);
MainButton3Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), " ");
MainButton3DescTxt.SetText(MainButtonText);
MainButton3DescOverTxt.SetText(MainButtonText);
}
w.Append(&MainButton3);
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+3));
if (XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
MainButton4Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
MainButton4DescTxt.SetText(MainButtonText);
MainButton4DescOverTxt.SetText(MainButtonText);
} else {
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+3)), "%s", HomebrewFiles.GetFilepath(fileoffset+3));
shortpath = strrchr(temp, '/');
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+3));
XMLInfo[3].SetName(MainButtonText);
MainButton4Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), " ");
MainButton4DescTxt.SetText(MainButtonText);
MainButton4DescOverTxt.SetText(MainButtonText);
}
w.Append(&MainButton4);
}
MainButton1.StopEffect();
MainButton2.StopEffect();
MainButton3.StopEffect();
MainButton4.StopEffect();
MainButton1.SetEffectGrow();
MainButton2.SetEffectGrow();
MainButton3.SetEffectGrow();
MainButton4.SetEffectGrow();
if (slidedirection == FADE) {
MainButton1.SetEffect(EFFECT_FADE, 20);
MainButton2.SetEffect(EFFECT_FADE, 20);
MainButton3.SetEffect(EFFECT_FADE, 20);
MainButton4.SetEffect(EFFECT_FADE, 20);
} else if (slidedirection == LEFT) {
MainButton1.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35);
MainButton2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35);
MainButton3.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35);
MainButton4.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35);
} else if (slidedirection == RIGHT) {
MainButton1.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35);
MainButton2.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35);
MainButton3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35);
MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35);
}
mainWindow->Append(&w);
ResumeGui();
while (MainButton1.GetEffect() > 0) usleep(50);
while (!changed) {
VIDEO_WaitVSync ();
if (MainButton1.GetState() == STATE_CLICKED) {
char temp[200];
char iconpath[200];
char metapath[200];
char * shortpath = NULL;
//write iconpath
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset));
//write iconpath
snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset));
//get filesize
u64 filesize = HomebrewFiles.GetFilesize(fileoffset);
//write short filename
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset)), "%s", HomebrewFiles.GetFilepath(fileoffset));
shortpath = strrchr(temp, '/');
snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset));
int choice = HBCWindowPrompt(XMLInfo[0].GetName(), XMLInfo[0].GetCoder(), XMLInfo[0].GetVersion(), XMLInfo[0].GetReleasedate(), XMLInfo[0].GetLongDescription(), iconpath, filesize);
if (choice == 1) {
boothomebrew = 1;
menu = MENU_EXIT;
snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s", HomebrewFiles.GetFilepath(fileoffset), HomebrewFiles.GetFilename(fileoffset));
break;
}
MainButton1.ResetState();
} else if (MainButton2.GetState() == STATE_CLICKED) {
char temp[200];
char iconpath[200];
char metapath[200];
char * shortpath = NULL;
//write iconpath
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1));
//write iconpath
snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+1));
//get filesize
u64 filesize = HomebrewFiles.GetFilesize(fileoffset+1);
//write short filename
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+1)), "%s", HomebrewFiles.GetFilepath(fileoffset+1));
shortpath = strrchr(temp, '/');
snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+1));
int choice = HBCWindowPrompt(XMLInfo[1].GetName(), XMLInfo[1].GetCoder(), XMLInfo[1].GetVersion(), XMLInfo[1].GetReleasedate(), XMLInfo[1].GetLongDescription(), iconpath, filesize);
if (choice == 1) {
boothomebrew = 1;
menu = MENU_EXIT;
snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s", HomebrewFiles.GetFilepath(fileoffset+1), HomebrewFiles.GetFilename(fileoffset+1));
break;
}
MainButton2.ResetState();
} else if (MainButton3.GetState() == STATE_CLICKED) {
char temp[200];
char iconpath[200];
char metapath[200];
char * shortpath = NULL;
//write iconpath
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2));
//write iconpath
snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+2));
//get filesize
u64 filesize = HomebrewFiles.GetFilesize(fileoffset+2);
//write short filename
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2));
shortpath = strrchr(temp, '/');
snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2));
int choice = HBCWindowPrompt(XMLInfo[2].GetName(), XMLInfo[2].GetCoder(), XMLInfo[2].GetVersion(), XMLInfo[2].GetReleasedate(), XMLInfo[2].GetLongDescription(), iconpath, filesize);
if (choice == 1) {
boothomebrew = 1;
menu = MENU_EXIT;
snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s", HomebrewFiles.GetFilepath(fileoffset+2), HomebrewFiles.GetFilename(fileoffset+2));
break;
}
MainButton3.ResetState();
} else if (MainButton4.GetState() == STATE_CLICKED) {
char temp[200];
char iconpath[200];
char metapath[200];
char * shortpath = NULL;
//write iconpath
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+3));
//write iconpath
snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+3));
//get filesize
u64 filesize = HomebrewFiles.GetFilesize(fileoffset+3);
//write short filename
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+3)), "%s", HomebrewFiles.GetFilepath(fileoffset+3));
shortpath = strrchr(temp, '/');
snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+3));
int choice = HBCWindowPrompt(XMLInfo[3].GetName(), XMLInfo[3].GetCoder(), XMLInfo[3].GetVersion(), XMLInfo[3].GetReleasedate(), XMLInfo[3].GetLongDescription(), iconpath, filesize);
if (choice == 1) {
boothomebrew = 1;
menu = MENU_EXIT;
snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s", HomebrewFiles.GetFilepath(fileoffset+3), HomebrewFiles.GetFilename(fileoffset+3));
break;
}
MainButton4.ResetState();
}
else if (shutdown == 1)
Sys_Shutdown();
else if (reset == 1)
Sys_Reboot();
else if (backBtn.GetState() == STATE_CLICKED) {
menu = MENU_DISCLIST;
changed = true;
}
else if (GoLeftBtn.GetState() == STATE_CLICKED) {
pageToDisplay--;
/** Change direction of the flying buttons **/
if (pageToDisplay < 1)
pageToDisplay = pages;
slidedirection = LEFT;
changed = true;
GoLeftBtn.ResetState();
}
else if (GoRightBtn.GetState() == STATE_CLICKED) {
pageToDisplay++;
/** Change direction of the flying buttons **/
if (pageToDisplay > pages)
pageToDisplay = 1;
slidedirection = RIGHT;
changed = true;
GoRightBtn.ResetState();
}
else if (wifiBtn.GetState() == STATE_CLICKED) {
ResumeNetworkWait();
wifiBtn.ResetState();
}
else if (homo.GetState() == STATE_CLICKED) {
cfg_save_global();
s32 thetimeofbg = bgMusic->GetPlayTime();
bgMusic->Stop();
choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0);
if (!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path)) {
bgMusic->Play();
} else {
bgMusic->PlayOggFile(Settings.ogg_path);
}
bgMusic->SetPlayTime(thetimeofbg);
SetVolumeOgg(255*(Settings.volume/100.0));
if (choice == 3) {
Sys_LoadMenu(); // Back to System Menu
} else if (choice == 2) {
Sys_BackToLoader();
} else {
homo.ResetState();
}
}
else if (infilesize > 0) {
char filesizetxt[50];
char temp[50];
if (infilesize < MBSIZE)
snprintf(filesizetxt, sizeof(filesizetxt), tr("Incoming file %0.2fKB"), infilesize/KBSIZE);
else
snprintf(filesizetxt, sizeof(filesizetxt), tr("Incoming file %0.2fMB"), infilesize/MBSIZE);
snprintf(temp, sizeof(temp), tr("Load file from: %s ?"), GetIncommingIP());
int choice = WindowPrompt(filesizetxt, temp, tr("OK"), tr("Cancel"));
if (choice == 1) {
int res = AllocHomebrewMemory(infilesize);
if (res < 0) {
CloseConnection();
WindowPrompt(tr("Not enough free memory"), 0, tr("OK"));
} else {
u32 read = 0;
u8 *temp = NULL;
int len = NETWORKBLOCKSIZE;
temp = (u8*) malloc(len);
while (read < infilesize) {
ShowProgress(tr("Receiving file from:"), GetIncommingIP(), NULL, read, infilesize, true);
if (infilesize - read < (u32) len)
len = infilesize-read;
else
len = NETWORKBLOCKSIZE;
int result = network_read(temp, len);
if (result < 0) {
WindowPrompt(tr("Error while transfering data."), 0, tr("OK"));
FreeHomebrewBuffer();
break;
}
if (!result)
break;
CopyHomebrewMemory(read, temp, len);
read += result;
}
free(temp);
ProgressStop();
if (read != infilesize) {
WindowPrompt(tr("Error:"), tr("No data could be read."), tr("OK"));
FreeHomebrewBuffer();
} else {
char filename[101];
network_read((u8*) &filename, 100);
if (strstr(filename,".dol") || strstr(filename,".DOL")
|| strstr(filename,".elf") || strstr(filename,".ELF")) {
boothomebrew = 2;
menu = MENU_EXIT;
CloseConnection();
break;
} else {
FreeHomebrewBuffer();
WindowPrompt(tr("ERROR:"), tr("Not a dol/elf file."), tr("OK"));
}
}
}
}
CloseConnection();
ResumeNetworkWait();
}
else if (channelBtn.GetState() == STATE_CLICKED) {
w.SetState(STATE_DISABLED);
//10001 are the channels that are installed as channels, not including shop channel/mii channel etc
u32 num = 0x00010001;
TitleBrowser(num);
//if they didn't boot a channel reset this window
w.SetState(STATE_DEFAULT);
channelBtn.ResetState();
}
if (IsNetworkInit()) {
if (!wifi_btn_loaded) {
wifiBtn.SetAlpha(255);
titleTT = new GuiTooltip(GetNetworkIP());
titleTT->SetAlpha(THEME.tooltipAlpha);
wifiBtn.SetToolTip(titleTT,0,-50,0,5);
wifi_btn_loaded=true;
}
}
}
}
w.SetEffect(EFFECT_FADE, -20);
while (w.GetEffect()>0) usleep(50);
HaltGui();
for (int i = 0; i < 4; i++) {
if (IconData[i] != NULL) {
delete IconData[i];
IconData[i] = NULL;
}
if (IconImg[i] != NULL) {
delete IconImg[i];
IconImg[i] = NULL;
}
}
delete titleTT;
titleTT = NULL;
if (IsNetworkInit())
HaltNetworkThread();
mainWindow->RemoveAll();
mainWindow->Append(bgImg);
ResumeGui();
return menu;
}

View File

@ -1,15 +0,0 @@
/****************************************************************************
* HomebrewBrowse
* USB Loader GX 2009
*
* Homebrew launcher for USB Loader GX
*
* homebrewbrowse.h
***************************************************************************/
#ifndef _HOMEBREWBROWSE_H_
#define _HOMEBREWBROWSE_H_
int MenuHomebrewBrowse();
#endif

View File

@ -1,116 +0,0 @@
/****************************************************************************
* HomebrewFiles Class
* for USB Loader GX
***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/dir.h>
#include "HomebrewFiles.h"
HomebrewFiles::HomebrewFiles(const char * path) {
filecount = 0;
FileInfo = (FileInfos *) malloc(sizeof(FileInfos));
if (!FileInfo) {
return;
}
memset(&FileInfo[filecount], 0, sizeof(FileInfos));
this->LoadPath(path);
this->SortList();
}
HomebrewFiles::~HomebrewFiles() {
if (FileInfo) {
free(FileInfo);
FileInfo = NULL;
}
}
bool HomebrewFiles::LoadPath(const char * folderpath) {
struct stat st;
DIR_ITER *dir = NULL;
char filename[1024];
dir = diropen(folderpath);
if (dir == NULL) {
return false;
}
while (dirnext(dir,filename,&st) == 0) {
if ((st.st_mode & S_IFDIR) != 0) {
if (strcmp(filename,".") != 0 && strcmp(filename,"..") != 0) {
char currentname[200];
snprintf(currentname, sizeof(currentname), "%s%s/", folderpath, filename);
this->LoadPath(currentname);
}
} else {
char temp[5];
for (int i = 0; i < 5; i++) {
temp[i] = filename[strlen(filename)-4+i];
}
if ((strncasecmp(temp, ".dol", 4) == 0 || strncasecmp(temp, ".elf", 4) == 0)
&& filecount < MAXHOMEBREWS && filename[0]!='.') {
FileInfo = (FileInfos *) realloc(FileInfo, (filecount+1)*sizeof(FileInfos));
if (!FileInfo) {
free(FileInfo);
FileInfo = NULL;
filecount = 0;
dirclose(dir);
return false;
}
memset(&(FileInfo[filecount]), 0, sizeof(FileInfo));
strncpy(FileInfo[filecount].FilePath, folderpath, sizeof(FileInfo[filecount].FilePath));
strncpy(FileInfo[filecount].FileName, filename, sizeof(FileInfo[filecount].FileName));
FileInfo[filecount].FileSize = st.st_size;
filecount++;
}
}
}
dirclose(dir);
return true;
}
char * HomebrewFiles::GetFilename(int ind) {
if (ind > filecount)
return NULL;
else
return FileInfo[ind].FileName;
}
char * HomebrewFiles::GetFilepath(int ind) {
if (ind > filecount)
return NULL;
else
return FileInfo[ind].FilePath;
}
unsigned int HomebrewFiles::GetFilesize(int ind) {
if (ind > filecount || !filecount || !FileInfo)
return NULL;
else
return FileInfo[ind].FileSize;
}
int HomebrewFiles::GetFilecount() {
return filecount;
}
static int ListCompare(const void *a, const void *b) {
FileInfos *ab = (FileInfos*) a;
FileInfos *bb = (FileInfos*) b;
return stricmp((char *) ab->FilePath, (char *) bb->FilePath);
}
void HomebrewFiles::SortList() {
qsort(FileInfo, filecount, sizeof(FileInfos), ListCompare);
}

View File

@ -1,44 +0,0 @@
/****************************************************************************
* HomebrewFiles Class
* for USB Loader GX
***************************************************************************/
#ifndef ___HOMEBREWFILES_H_
#define ___HOMEBREWFILES_H_
#define MAXHOMEBREWS 500
typedef struct {
char FileName[100];
char FilePath[150];
unsigned int FileSize;
} FileInfos;
class HomebrewFiles {
public:
//!Constructor
//!\param path Path where to check for homebrew files
HomebrewFiles(const char * path);
//!Destructor
~HomebrewFiles();
//! Load the dol/elf list of a path
//!\param path Path where to check for homebrew files
bool LoadPath(const char * path);
//! Get the a filename of the list
//!\param list index
char * GetFilename(int index);
//! Get the a filepath of the list
//!\param list index
char * GetFilepath(int index);
//! Get the a filesize of the list
//!\param list index
unsigned int GetFilesize(int index);
//! Get the filecount of the whole list
int GetFilecount();
//! Sort list by filepath
void SortList();
protected:
int filecount;
FileInfos *FileInfo;
};
#endif

View File

@ -1,67 +0,0 @@
/****************************************************************************
* HomebrewXML Class
* for USB Loader GX
***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "xml/xml.h"
#include "HomebrewXML.h"
HomebrewXML::HomebrewXML() {
strcpy(name,"");
strcpy(coder,"");
strcpy(version,"");
strcpy(releasedate,"");
strcpy(shortdescription,"");
strcpy(longdescription,"");
}
HomebrewXML::~HomebrewXML() {
}
int HomebrewXML::LoadHomebrewXMLData(const char* filename) {
mxml_node_t *nodedataHB = NULL;
mxml_node_t *nodetreeHB = NULL;
char tmp1[40];
/* Load XML file */
FILE *filexml;
filexml = fopen(filename, "rb");
if (!filexml) {
return -1;
}
nodetreeHB = mxmlLoadFile(NULL, filexml, MXML_NO_CALLBACK);
fclose(filexml);
if (nodetreeHB == NULL) {
return -2;
}
nodedataHB = mxmlFindElement(nodetreeHB, nodetreeHB, "app", NULL, NULL, MXML_DESCEND);
if (nodedataHB == NULL) {
return -5;
}
GetTextFromNode(nodedataHB, nodedataHB, (char*) "name", NULL, NULL, MXML_DESCEND, name,sizeof(name));
GetTextFromNode(nodedataHB, nodedataHB, (char*) "coder", NULL, NULL, MXML_DESCEND, coder,sizeof(coder));
GetTextFromNode(nodedataHB, nodedataHB, (char*) "version", NULL, NULL, MXML_DESCEND, version,sizeof(version));
GetTextFromNode(nodedataHB, nodedataHB, (char*) "release_date", NULL, NULL, MXML_DESCEND, tmp1,sizeof(tmp1));
GetTextFromNode(nodedataHB, nodedataHB, (char*) "short_description", NULL, NULL, MXML_DESCEND, shortdescription,sizeof(shortdescription));
GetTextFromNode(nodedataHB, nodedataHB, (char*) "long_description", NULL, NULL, MXML_DESCEND, longdescription,sizeof(longdescription));
int len = (strlen(tmp1)-6); //length of the date string without the 200000 at the end
if (len == 8)
snprintf(releasedate, sizeof(releasedate), "%c%c/%c%c/%c%c%c%c", tmp1[4],tmp1[5],tmp1[6],tmp1[7],tmp1[0],tmp1[1],tmp1[2],tmp1[3]);
else if (len == 6)
snprintf(releasedate, sizeof(releasedate), "%c%c/%c%c%c%c", tmp1[4],tmp1[5],tmp1[0],tmp1[1],tmp1[2],tmp1[3]);
else snprintf(releasedate, sizeof(releasedate), "%s", tmp1);
free(nodedataHB);
free(nodetreeHB);
return 1;
}

View File

@ -1,54 +0,0 @@
/****************************************************************************
* HomebrewXML Class
* for USB Loader GX
***************************************************************************/
#ifndef ___HOMEBREWXML_H_
#define ___HOMEBREWXML_H_
class HomebrewXML {
public:
//!Constructor
//!\param path Path for the xml file
HomebrewXML();
//!Destructor
~HomebrewXML();
//!\param filename Filepath of the XML file
int LoadHomebrewXMLData(const char* filename);
//! Get name
char * GetName() {
return name;
}
//! Get coder
char * GetCoder() {
return coder;
}
//! Get version
char * GetVersion() {
return version;
}
//! Get releasedate
char * GetReleasedate() {
return releasedate;
}
//! Get shortdescription
char * GetShortDescription() {
return shortdescription;
}
//! Get longdescription
char * GetLongDescription() {
return longdescription;
}
//! Set Name
void SetName(char * path) {
strncpy(name, path, sizeof(name));
}
protected:
char name[50];
char coder[100];
char version[30];
char releasedate[30];
char shortdescription[150];
char longdescription[500];
};
#endif

View File

@ -1,55 +0,0 @@
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <ogc/machine/processor.h>
#include <gccore.h>
#include <dirent.h>
#include <string.h>
#include "dolloader.h"
typedef struct _dolheader {
u32 text_pos[7];
u32 data_pos[11];
u32 text_start[7];
u32 data_start[11];
u32 text_size[7];
u32 data_size[11];
u32 bss_start;
u32 bss_size;
u32 entry_point;
} dolheader;
u32 load_dol(void *dolstart, struct __argv *argv) {
u32 i;
dolheader *dolfile;
if (dolstart) {
dolfile = (dolheader *) dolstart;
for (i = 0; i < 7; i++) {
if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) continue;
VIDEO_WaitVSync();
ICInvalidateRange ((void *) dolfile->text_start[i],dolfile->text_size[i]);
memmove ((void *) dolfile->text_start[i],dolstart+dolfile->text_pos[i],dolfile->text_size[i]);
}
for (i = 0; i < 11; i++) {
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) continue;
VIDEO_WaitVSync();
memmove ((void *) dolfile->data_start[i],dolstart+dolfile->data_pos[i],dolfile->data_size[i]);
DCFlushRangeNoSync ((void *) dolfile->data_start[i],dolfile->data_size[i]);
}
memset ((void *) dolfile->bss_start, 0, dolfile->bss_size);
DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size);
if (argv && argv->argvMagic == ARGV_MAGIC) {
void *new_argv = (void *)(dolfile->entry_point + 8);
memmove(new_argv, argv, sizeof(*argv));
DCFlushRange(new_argv, sizeof(*argv));
}
return dolfile->entry_point;
}
return 0;
}

View File

@ -1,18 +0,0 @@
#ifndef _DOLLOADER_H_
#define _DOLLOADER_H_
#ifdef __cplusplus
extern "C" {
#endif
extern void __exception_closeall();
typedef void (*entrypoint) (void);
u32 load_dol(void *dolstart, struct __argv *argv);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,590 +0,0 @@
/*
* Copyright (c) 1995, 1996, 2001, 2002
* Erik Theisen. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This is the ELF ABI header file
* formerly known as "elf_abi.h".
*/
#ifndef _ELF_ABI_H
#define _ELF_ABI_H
#include <gctypes.h>
/*
* This version doesn't work for 64-bit ABIs - Erik.
*/
/*
* These typedefs need to be handled better.
*/
typedef u32 Elf32_Addr; /* Unsigned program address */
typedef u32 Elf32_Off; /* Unsigned file offset */
typedef s32 Elf32_Sword; /* Signed large integer */
typedef u32 Elf32_Word; /* Unsigned large integer */
typedef u16 Elf32_Half; /* Unsigned medium integer */
/* e_ident[] identification indexes */
#define EI_MAG0 0 /* file ID */
#define EI_MAG1 1 /* file ID */
#define EI_MAG2 2 /* file ID */
#define EI_MAG3 3 /* file ID */
#define EI_CLASS 4 /* file class */
#define EI_DATA 5 /* data encoding */
#define EI_VERSION 6 /* ELF header version */
#define EI_OSABI 7 /* OS/ABI specific ELF extensions */
#define EI_ABIVERSION 8 /* ABI target version */
#define EI_PAD 9 /* start of pad bytes */
#define EI_NIDENT 16 /* Size of e_ident[] */
/* e_ident[] magic number */
#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
#define ELFMAG1 'E' /* e_ident[EI_MAG1] */
#define ELFMAG2 'L' /* e_ident[EI_MAG2] */
#define ELFMAG3 'F' /* e_ident[EI_MAG3] */
#define ELFMAG "\177ELF" /* magic */
#define SELFMAG 4 /* size of magic */
/* e_ident[] file class */
#define ELFCLASSNONE 0 /* invalid */
#define ELFCLASS32 1 /* 32-bit objs */
#define ELFCLASS64 2 /* 64-bit objs */
#define ELFCLASSNUM 3 /* number of classes */
/* e_ident[] data encoding */
#define ELFDATANONE 0 /* invalid */
#define ELFDATA2LSB 1 /* Little-Endian */
#define ELFDATA2MSB 2 /* Big-Endian */
#define ELFDATANUM 3 /* number of data encode defines */
/* e_ident[] OS/ABI specific ELF extensions */
#define ELFOSABI_NONE 0 /* No extension specified */
#define ELFOSABI_HPUX 1 /* Hewlett-Packard HP-UX */
#define ELFOSABI_NETBSD 2 /* NetBSD */
#define ELFOSABI_LINUX 3 /* Linux */
#define ELFOSABI_SOLARIS 6 /* Sun Solaris */
#define ELFOSABI_AIX 7 /* AIX */
#define ELFOSABI_IRIX 8 /* IRIX */
#define ELFOSABI_FREEBSD 9 /* FreeBSD */
#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX */
#define ELFOSABI_MODESTO 11 /* Novell Modesto */
#define ELFOSABI_OPENBSD 12 /* OpenBSD */
/* 64-255 Architecture-specific value range */
/* e_ident[] ABI Version */
#define ELFABIVERSION 0
/* e_ident */
#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
(ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
(ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
(ehdr).e_ident[EI_MAG3] == ELFMAG3)
/* ELF Header */
typedef struct elfhdr {
unsigned char e_ident[EI_NIDENT]; /* ELF Identification */
Elf32_Half e_type; /* object file type */
Elf32_Half e_machine; /* machine */
Elf32_Word e_version; /* object file version */
Elf32_Addr e_entry; /* virtual entry point */
Elf32_Off e_phoff; /* program header table offset */
Elf32_Off e_shoff; /* section header table offset */
Elf32_Word e_flags; /* processor-specific flags */
Elf32_Half e_ehsize; /* ELF header size */
Elf32_Half e_phentsize; /* program header entry size */
Elf32_Half e_phnum; /* number of program header entries */
Elf32_Half e_shentsize; /* section header entry size */
Elf32_Half e_shnum; /* number of section header entries */
Elf32_Half e_shstrndx; /* section header table's "section
header string table" entry offset */
} Elf32_Ehdr;
/* e_type */
#define ET_NONE 0 /* No file type */
#define ET_REL 1 /* relocatable file */
#define ET_EXEC 2 /* executable file */
#define ET_DYN 3 /* shared object file */
#define ET_CORE 4 /* core file */
#define ET_NUM 5 /* number of types */
#define ET_LOOS 0xfe00 /* reserved range for operating */
#define ET_HIOS 0xfeff /* system specific e_type */
#define ET_LOPROC 0xff00 /* reserved range for processor */
#define ET_HIPROC 0xffff /* specific e_type */
/* e_machine */
#define EM_NONE 0 /* No Machine */
#define EM_M32 1 /* AT&T WE 32100 */
#define EM_SPARC 2 /* SPARC */
#define EM_386 3 /* Intel 80386 */
#define EM_68K 4 /* Motorola 68000 */
#define EM_88K 5 /* Motorola 88000 */
#if 0
#define EM_486 6 /* RESERVED - was Intel 80486 */
#endif
#define EM_860 7 /* Intel 80860 */
#define EM_MIPS 8 /* MIPS R3000 Big-Endian only */
#define EM_S370 9 /* IBM System/370 Processor */
#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */
#if 0
#define EM_SPARC64 11 /* RESERVED - was SPARC v9
64-bit unoffical */
#endif
/* RESERVED 11-14 for future use */
#define EM_PARISC 15 /* HPPA */
/* RESERVED 16 for future use */
#define EM_VPP500 17 /* Fujitsu VPP500 */
#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
#define EM_960 19 /* Intel 80960 */
#define EM_PPC 20 /* PowerPC */
#define EM_PPC64 21 /* 64-bit PowerPC */
#define EM_S390 22 /* IBM System/390 Processor */
/* RESERVED 23-35 for future use */
#define EM_V800 36 /* NEC V800 */
#define EM_FR20 37 /* Fujitsu FR20 */
#define EM_RH32 38 /* TRW RH-32 */
#define EM_RCE 39 /* Motorola RCE */
#define EM_ARM 40 /* Advanced Risc Machines ARM */
#define EM_ALPHA 41 /* Digital Alpha */
#define EM_SH 42 /* Hitachi SH */
#define EM_SPARCV9 43 /* SPARC Version 9 */
#define EM_TRICORE 44 /* Siemens TriCore embedded processor */
#define EM_ARC 45 /* Argonaut RISC Core */
#define EM_H8_300 46 /* Hitachi H8/300 */
#define EM_H8_300H 47 /* Hitachi H8/300H */
#define EM_H8S 48 /* Hitachi H8S */
#define EM_H8_500 49 /* Hitachi H8/500 */
#define EM_IA_64 50 /* Intel Merced */
#define EM_MIPS_X 51 /* Stanford MIPS-X */
#define EM_COLDFIRE 52 /* Motorola Coldfire */
#define EM_68HC12 53 /* Motorola M68HC12 */
#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
#define EM_PCP 55 /* Siemens PCP */
#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
#define EM_NDR1 57 /* Denso NDR1 microprocessor */
#define EM_STARCORE 58 /* Motorola Start*Core processor */
#define EM_ME16 59 /* Toyota ME16 processor */
#define EM_ST100 60 /* STMicroelectronic ST100 processor */
#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
#define EM_X86_64 62 /* AMD x86-64 */
#define EM_PDSP 63 /* Sony DSP Processor */
/* RESERVED 64,65 for future use */
#define EM_FX66 66 /* Siemens FX66 microcontroller */
#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
#define EM_SVX 73 /* Silicon Graphics SVx */
#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */
#define EM_VAX 75 /* Digital VAX */
#define EM_CHRIS 76 /* Axis Communications embedded proc. */
#define EM_JAVELIN 77 /* Infineon Technologies emb. proc. */
#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
#define EM_MMIX 80 /* Donald Knuth's edu 64-bit proc. */
#define EM_HUANY 81 /* Harvard University mach-indep objs */
#define EM_PRISM 82 /* SiTera Prism */
#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
#define EM_FR30 84 /* Fujitsu FR30 */
#define EM_D10V 85 /* Mitsubishi DV10V */
#define EM_D30V 86 /* Mitsubishi DV30V */
#define EM_V850 87 /* NEC v850 */
#define EM_M32R 88 /* Mitsubishi M32R */
#define EM_MN10300 89 /* Matsushita MN10200 */
#define EM_MN10200 90 /* Matsushita MN10200 */
#define EM_PJ 91 /* picoJava */
#define EM_NUM 92 /* number of machine types */
/* Version */
#define EV_NONE 0 /* Invalid */
#define EV_CURRENT 1 /* Current */
#define EV_NUM 2 /* number of versions */
/* Section Header */
typedef struct {
Elf32_Word sh_name; /* name - index into section header
string table section */
Elf32_Word sh_type; /* type */
Elf32_Word sh_flags; /* flags */
Elf32_Addr sh_addr; /* address */
Elf32_Off sh_offset; /* file offset */
Elf32_Word sh_size; /* section size */
Elf32_Word sh_link; /* section header table index link */
Elf32_Word sh_info; /* extra information */
Elf32_Word sh_addralign; /* address alignment */
Elf32_Word sh_entsize; /* section entry size */
} Elf32_Shdr;
/* Special Section Indexes */
#define SHN_UNDEF 0 /* undefined */
#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */
#define SHN_LOPROC 0xff00 /* reserved range for processor */
#define SHN_HIPROC 0xff1f /* specific section indexes */
#define SHN_LOOS 0xff20 /* reserved range for operating */
#define SHN_HIOS 0xff3f /* specific semantics */
#define SHN_ABS 0xfff1 /* absolute value */
#define SHN_COMMON 0xfff2 /* common symbol */
#define SHN_XINDEX 0xffff /* Index is an extra table */
#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */
/* sh_type */
#define SHT_NULL 0 /* inactive */
#define SHT_PROGBITS 1 /* program defined information */
#define SHT_SYMTAB 2 /* symbol table section */
#define SHT_STRTAB 3 /* string table section */
#define SHT_RELA 4 /* relocation section with addends*/
#define SHT_HASH 5 /* symbol hash table section */
#define SHT_DYNAMIC 6 /* dynamic section */
#define SHT_NOTE 7 /* note section */
#define SHT_NOBITS 8 /* no space section */
#define SHT_REL 9 /* relation section without addends */
#define SHT_SHLIB 10 /* reserved - purpose unknown */
#define SHT_DYNSYM 11 /* dynamic symbol table section */
#define SHT_INIT_ARRAY 14 /* Array of constructors */
#define SHT_FINI_ARRAY 15 /* Array of destructors */
#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */
#define SHT_GROUP 17 /* Section group */
#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */
#define SHT_NUM 19 /* number of section types */
#define SHT_LOOS 0x60000000 /* Start OS-specific */
#define SHT_HIOS 0x6fffffff /* End OS-specific */
#define SHT_LOPROC 0x70000000 /* reserved range for processor */
#define SHT_HIPROC 0x7fffffff /* specific section header types */
#define SHT_LOUSER 0x80000000 /* reserved range for application */
#define SHT_HIUSER 0xffffffff /* specific indexes */
/* Section names */
#define ELF_BSS ".bss" /* uninitialized data */
#define ELF_COMMENT ".comment" /* version control information */
#define ELF_DATA ".data" /* initialized data */
#define ELF_DATA1 ".data1" /* initialized data */
#define ELF_DEBUG ".debug" /* debug */
#define ELF_DYNAMIC ".dynamic" /* dynamic linking information */
#define ELF_DYNSTR ".dynstr" /* dynamic string table */
#define ELF_DYNSYM ".dynsym" /* dynamic symbol table */
#define ELF_FINI ".fini" /* termination code */
#define ELF_FINI_ARRAY ".fini_array" /* Array of destructors */
#define ELF_GOT ".got" /* global offset table */
#define ELF_HASH ".hash" /* symbol hash table */
#define ELF_INIT ".init" /* initialization code */
#define ELF_INIT_ARRAY ".init_array" /* Array of constuctors */
#define ELF_INTERP ".interp" /* Pathname of program interpreter */
#define ELF_LINE ".line" /* Symbolic line numnber information */
#define ELF_NOTE ".note" /* Contains note section */
#define ELF_PLT ".plt" /* Procedure linkage table */
#define ELF_PREINIT_ARRAY ".preinit_array" /* Array of pre-constructors */
#define ELF_REL_DATA ".rel.data" /* relocation data */
#define ELF_REL_FINI ".rel.fini" /* relocation termination code */
#define ELF_REL_INIT ".rel.init" /* relocation initialization code */
#define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */
#define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */
#define ELF_REL_TEXT ".rel.text" /* relocation code */
#define ELF_RODATA ".rodata" /* read-only data */
#define ELF_RODATA1 ".rodata1" /* read-only data */
#define ELF_SHSTRTAB ".shstrtab" /* section header string table */
#define ELF_STRTAB ".strtab" /* string table */
#define ELF_SYMTAB ".symtab" /* symbol table */
#define ELF_SYMTAB_SHNDX ".symtab_shndx"/* symbol table section index */
#define ELF_TBSS ".tbss" /* thread local uninit data */
#define ELF_TDATA ".tdata" /* thread local init data */
#define ELF_TDATA1 ".tdata1" /* thread local init data */
#define ELF_TEXT ".text" /* code */
/* Section Attribute Flags - sh_flags */
#define SHF_WRITE 0x1 /* Writable */
#define SHF_ALLOC 0x2 /* occupies memory */
#define SHF_EXECINSTR 0x4 /* executable */
#define SHF_MERGE 0x10 /* Might be merged */
#define SHF_STRINGS 0x20 /* Contains NULL terminated strings */
#define SHF_INFO_LINK 0x40 /* sh_info contains SHT index */
#define SHF_LINK_ORDER 0x80 /* Preserve order after combining*/
#define SHF_OS_NONCONFORMING 0x100 /* Non-standard OS specific handling */
#define SHF_GROUP 0x200 /* Member of section group */
#define SHF_TLS 0x400 /* Thread local storage */
#define SHF_MASKOS 0x0ff00000 /* OS specific */
#define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */
/* specific section attributes */
/* Section Group Flags */
#define GRP_COMDAT 0x1 /* COMDAT group */
#define GRP_MASKOS 0x0ff00000 /* Mask OS specific flags */
#define GRP_MASKPROC 0xf0000000 /* Mask processor specific flags */
/* Symbol Table Entry */
typedef struct elf32_sym {
Elf32_Word st_name; /* name - index into string table */
Elf32_Addr st_value; /* symbol value */
Elf32_Word st_size; /* symbol size */
unsigned char st_info; /* type and binding */
unsigned char st_other; /* 0 - no defined meaning */
Elf32_Half st_shndx; /* section header index */
} Elf32_Sym;
/* Symbol table index */
#define STN_UNDEF 0 /* undefined */
/* Extract symbol info - st_info */
#define ELF32_ST_BIND(x) ((x) >> 4)
#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
#define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
#define ELF32_ST_VISIBILITY(x) ((x) & 0x3)
/* Symbol Binding - ELF32_ST_BIND - st_info */
#define STB_LOCAL 0 /* Local symbol */
#define STB_GLOBAL 1 /* Global symbol */
#define STB_WEAK 2 /* like global - lower precedence */
#define STB_NUM 3 /* number of symbol bindings */
#define STB_LOOS 10 /* reserved range for operating */
#define STB_HIOS 12 /* system specific symbol bindings */
#define STB_LOPROC 13 /* reserved range for processor */
#define STB_HIPROC 15 /* specific symbol bindings */
/* Symbol type - ELF32_ST_TYPE - st_info */
#define STT_NOTYPE 0 /* not specified */
#define STT_OBJECT 1 /* data object */
#define STT_FUNC 2 /* function */
#define STT_SECTION 3 /* section */
#define STT_FILE 4 /* file */
#define STT_NUM 5 /* number of symbol types */
#define STT_TLS 6 /* Thread local storage symbol */
#define STT_LOOS 10 /* reserved range for operating */
#define STT_HIOS 12 /* system specific symbol types */
#define STT_LOPROC 13 /* reserved range for processor */
#define STT_HIPROC 15 /* specific symbol types */
/* Symbol visibility - ELF32_ST_VISIBILITY - st_other */
#define STV_DEFAULT 0 /* Normal visibility rules */
#define STV_INTERNAL 1 /* Processor specific hidden class */
#define STV_HIDDEN 2 /* Symbol unavailable in other mods */
#define STV_PROTECTED 3 /* Not preemptible, not exported */
/* Relocation entry with implicit addend */
typedef struct {
Elf32_Addr r_offset; /* offset of relocation */
Elf32_Word r_info; /* symbol table index and type */
} Elf32_Rel;
/* Relocation entry with explicit addend */
typedef struct {
Elf32_Addr r_offset; /* offset of relocation */
Elf32_Word r_info; /* symbol table index and type */
Elf32_Sword r_addend;
} Elf32_Rela;
/* Extract relocation info - r_info */
#define ELF32_R_SYM(i) ((i) >> 8)
#define ELF32_R_TYPE(i) ((unsigned char) (i))
#define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t))
/* Program Header */
typedef struct {
Elf32_Word p_type; /* segment type */
Elf32_Off p_offset; /* segment offset */
Elf32_Addr p_vaddr; /* virtual address of segment */
Elf32_Addr p_paddr; /* physical address - ignored? */
Elf32_Word p_filesz; /* number of bytes in file for seg. */
Elf32_Word p_memsz; /* number of bytes in mem. for seg. */
Elf32_Word p_flags; /* flags */
Elf32_Word p_align; /* memory alignment */
} Elf32_Phdr;
/* Segment types - p_type */
#define PT_NULL 0 /* unused */
#define PT_LOAD 1 /* loadable segment */
#define PT_DYNAMIC 2 /* dynamic linking section */
#define PT_INTERP 3 /* the RTLD */
#define PT_NOTE 4 /* auxiliary information */
#define PT_SHLIB 5 /* reserved - purpose undefined */
#define PT_PHDR 6 /* program header */
#define PT_TLS 7 /* Thread local storage template */
#define PT_NUM 8 /* Number of segment types */
#define PT_LOOS 0x60000000 /* reserved range for operating */
#define PT_HIOS 0x6fffffff /* system specific segment types */
#define PT_LOPROC 0x70000000 /* reserved range for processor */
#define PT_HIPROC 0x7fffffff /* specific segment types */
/* Segment flags - p_flags */
#define PF_X 0x1 /* Executable */
#define PF_W 0x2 /* Writable */
#define PF_R 0x4 /* Readable */
#define PF_MASKOS 0x0ff00000 /* OS specific segment flags */
#define PF_MASKPROC 0xf0000000 /* reserved bits for processor */
/* specific segment flags */
/* Dynamic structure */
typedef struct {
Elf32_Sword d_tag; /* controls meaning of d_val */
union {
Elf32_Word d_val; /* Multiple meanings - see d_tag */
Elf32_Addr d_ptr; /* program virtual address */
} d_un;
} Elf32_Dyn;
extern Elf32_Dyn _DYNAMIC[];
/* Dynamic Array Tags - d_tag */
#define DT_NULL 0 /* marks end of _DYNAMIC array */
#define DT_NEEDED 1 /* string table offset of needed lib */
#define DT_PLTRELSZ 2 /* size of relocation entries in PLT */
#define DT_PLTGOT 3 /* address PLT/GOT */
#define DT_HASH 4 /* address of symbol hash table */
#define DT_STRTAB 5 /* address of string table */
#define DT_SYMTAB 6 /* address of symbol table */
#define DT_RELA 7 /* address of relocation table */
#define DT_RELASZ 8 /* size of relocation table */
#define DT_RELAENT 9 /* size of relocation entry */
#define DT_STRSZ 10 /* size of string table */
#define DT_SYMENT 11 /* size of symbol table entry */
#define DT_INIT 12 /* address of initialization func. */
#define DT_FINI 13 /* address of termination function */
#define DT_SONAME 14 /* string table offset of shared obj */
#define DT_RPATH 15 /* string table offset of library
search path */
#define DT_SYMBOLIC 16 /* start sym search in shared obj. */
#define DT_REL 17 /* address of rel. tbl. w addends */
#define DT_RELSZ 18 /* size of DT_REL relocation table */
#define DT_RELENT 19 /* size of DT_REL relocation entry */
#define DT_PLTREL 20 /* PLT referenced relocation entry */
#define DT_DEBUG 21 /* bugger */
#define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */
#define DT_JMPREL 23 /* add. of PLT's relocation entries */
#define DT_BIND_NOW 24 /* Process relocations of object */
#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */
#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */
#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
#define DT_RUNPATH 29 /* Library search path */
#define DT_FLAGS 30 /* Flags for the object being loaded */
#define DT_ENCODING 32 /* Start of encoded range */
#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/
#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */
#define DT_NUM 34 /* Number used. */
#define DT_LOOS 0x60000000 /* reserved range for OS */
#define DT_HIOS 0x6fffffff /* specific dynamic array tags */
#define DT_LOPROC 0x70000000 /* reserved range for processor */
#define DT_HIPROC 0x7fffffff /* specific dynamic array tags */
/* Dynamic Tag Flags - d_un.d_val */
#define DF_ORIGIN 0x01 /* Object may use DF_ORIGIN */
#define DF_SYMBOLIC 0x02 /* Symbol resolutions starts here */
#define DF_TEXTREL 0x04 /* Object contains text relocations */
#define DF_BIND_NOW 0x08 /* No lazy binding for this object */
#define DF_STATIC_TLS 0x10 /* Static thread local storage */
/* Standard ELF hashing function */
unsigned long elf_hash(const unsigned char *name);
#define ELF_TARG_VER 1 /* The ver for which this code is intended */
/*
* XXX - PowerPC defines really don't belong in here,
* but we'll put them in for simplicity.
*/
/* Values for Elf32/64_Ehdr.e_flags. */
#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */
/* Cygnus local bits below */
#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/
#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib
flag */
/* PowerPC relocations defined by the ABIs */
#define R_PPC_NONE 0
#define R_PPC_ADDR32 1 /* 32bit absolute address */
#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */
#define R_PPC_ADDR16 3 /* 16bit absolute address */
#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */
#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */
#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */
#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */
#define R_PPC_ADDR14_BRTAKEN 8
#define R_PPC_ADDR14_BRNTAKEN 9
#define R_PPC_REL24 10 /* PC relative 26 bit */
#define R_PPC_REL14 11 /* PC relative 16 bit */
#define R_PPC_REL14_BRTAKEN 12
#define R_PPC_REL14_BRNTAKEN 13
#define R_PPC_GOT16 14
#define R_PPC_GOT16_LO 15
#define R_PPC_GOT16_HI 16
#define R_PPC_GOT16_HA 17
#define R_PPC_PLTREL24 18
#define R_PPC_COPY 19
#define R_PPC_GLOB_DAT 20
#define R_PPC_JMP_SLOT 21
#define R_PPC_RELATIVE 22
#define R_PPC_LOCAL24PC 23
#define R_PPC_UADDR32 24
#define R_PPC_UADDR16 25
#define R_PPC_REL32 26
#define R_PPC_PLT32 27
#define R_PPC_PLTREL32 28
#define R_PPC_PLT16_LO 29
#define R_PPC_PLT16_HI 30
#define R_PPC_PLT16_HA 31
#define R_PPC_SDAREL16 32
#define R_PPC_SECTOFF 33
#define R_PPC_SECTOFF_LO 34
#define R_PPC_SECTOFF_HI 35
#define R_PPC_SECTOFF_HA 36
/* Keep this the last entry. */
#define R_PPC_NUM 37
/* The remaining relocs are from the Embedded ELF ABI, and are not
in the SVR4 ELF ABI. */
#define R_PPC_EMB_NADDR32 101
#define R_PPC_EMB_NADDR16 102
#define R_PPC_EMB_NADDR16_LO 103
#define R_PPC_EMB_NADDR16_HI 104
#define R_PPC_EMB_NADDR16_HA 105
#define R_PPC_EMB_SDAI16 106
#define R_PPC_EMB_SDA2I16 107
#define R_PPC_EMB_SDA2REL 108
#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */
#define R_PPC_EMB_MRKREF 110
#define R_PPC_EMB_RELSEC16 111
#define R_PPC_EMB_RELST_LO 112
#define R_PPC_EMB_RELST_HI 113
#define R_PPC_EMB_RELST_HA 114
#define R_PPC_EMB_BIT_FLD 115
#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */
/* Diab tool relocations. */
#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */
#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */
#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */
#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */
#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */
#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */
/* This is a phony reloc to handle any old fashioned TOC16 references
that may still be in object files. */
#define R_PPC_TOC16 255
#endif /* _ELF_H */

View File

@ -1,101 +0,0 @@
/*
* Copyright (c) 2001 William L. Pitts
* Modifications (c) 2004 Felix Domke
* All rights reserved.
*
* Redistribution and use in source and binary forms are freely
* permitted provided that the above copyright notice and this
* paragraph and the following disclaimer are duplicated in all
* such forms.
*
* This software is provided "AS IS" and without any express or
* implied warranties, including, without limitation, the implied
* warranties of merchantability and fitness for a particular
* purpose.
*/
#include <stdio.h>
#include <string.h>
#include <gccore.h>
#include "elf_abi.h"
/* ======================================================================
* Determine if a valid ELF image exists at the given memory location.
* First looks at the ELF header magic field, the makes sure that it is
* executable and makes sure that it is for a PowerPC.
* ====================================================================== */
s32 valid_elf_image (void *addr) {
Elf32_Ehdr *ehdr; /* Elf header structure pointer */
ehdr = (Elf32_Ehdr *) addr;
if (!IS_ELF (*ehdr))
return 0;
if (ehdr->e_type != ET_EXEC)
return -1;
if (ehdr->e_machine != EM_PPC)
return -1;
return 1;
}
/* ======================================================================
* A very simple elf loader, assumes the image is valid, returns the
* entry point address.
* ====================================================================== */
u32 load_elf_image (void *addr) {
Elf32_Ehdr *ehdr;
Elf32_Shdr *shdr;
u8 *strtab = 0;
u8 *image;
int i;
ehdr = (Elf32_Ehdr *) addr;
/* Find the section header string table for output info */
shdr = (Elf32_Shdr *) (addr + ehdr->e_shoff +
(ehdr->e_shstrndx * sizeof (Elf32_Shdr)));
if (shdr->sh_type == SHT_STRTAB)
strtab = (u8 *) (addr + shdr->sh_offset);
/* Load each appropriate section */
for (i = 0; i < ehdr->e_shnum; ++i) {
shdr = (Elf32_Shdr *) (addr + ehdr->e_shoff +
(i * sizeof (Elf32_Shdr)));
if (!(shdr->sh_flags & SHF_ALLOC)
|| shdr->sh_addr == 0 || shdr->sh_size == 0) {
continue;
}
shdr->sh_addr &= 0x3FFFFFFF;
shdr->sh_addr |= 0x80000000;
if (strtab) {
/*printf ("%sing section %s @ 0x%08x (0x%08x bytes)\n",
(shdr->sh_type == SHT_NOBITS) ?
"clear" : "load",
&strtab[shdr->sh_name],
(u32) shdr->sh_addr,
(u32) shdr->sh_size);*/
}
if (shdr->sh_type == SHT_NOBITS) {
memset ((void *) shdr->sh_addr, 0, shdr->sh_size);
} else {
image = (u8 *) addr + shdr->sh_offset;
memcpy ((void *) shdr->sh_addr,
(const void *) image,
shdr->sh_size);
}
DCFlushRangeNoSync ((void *) shdr->sh_addr, shdr->sh_size);
}
return (ehdr->e_entry & 0x3FFFFFFF) | 0x80000000;
}

View File

@ -1,17 +0,0 @@
#ifndef _ELFLOADER_H_
#define _ELFLOADER_H_
#include <wiiuse/wpad.h>
#ifdef __cplusplus
extern "C" {
#endif
s32 valid_elf_image (void *addr);
u32 load_elf_image (void *addr);
#ifdef __cplusplus
}
#endif
#endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 930 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 957 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 937 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 813 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Some files were not shown because too many files have changed in this diff Show More