mirror of
https://github.com/project-slippi/Nintendont.git
synced 2025-10-06 00:22:40 +02:00
-added a very simple multi-dol loader for games like zelda collectors edition
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
@echo off
|
||||
|
||||
cd kernel\asm
|
||||
cd multidol
|
||||
echo.
|
||||
echo Building Multi-DOL Loader
|
||||
echo.
|
||||
make windows=1 clean
|
||||
make windows=1
|
||||
|
||||
cd ..\kernel\asm
|
||||
echo.
|
||||
echo Building asm files
|
||||
echo.
|
||||
|
49
Build.sh
49
Build.sh
@@ -1,81 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd kernel/asm
|
||||
#!/bin/sh
|
||||
|
||||
cd multidol
|
||||
echo " "
|
||||
|
||||
echo "Building asm files"
|
||||
|
||||
echo Building Multi-DOL Loader
|
||||
echo " "
|
||||
|
||||
make clean
|
||||
|
||||
make
|
||||
|
||||
|
||||
cd ../kernel/asm
|
||||
echo " "
|
||||
echo "Building asm files"
|
||||
echo " "
|
||||
make clean
|
||||
make
|
||||
|
||||
cd ../../resetstub
|
||||
|
||||
echo " "
|
||||
|
||||
echo "Building Reset Stub"
|
||||
|
||||
echo " "
|
||||
|
||||
make clean
|
||||
|
||||
make
|
||||
|
||||
|
||||
|
||||
cd ../kernel
|
||||
|
||||
echo " "
|
||||
|
||||
echo "Building Nintendont Kernel (USB)"
|
||||
|
||||
echo " "
|
||||
|
||||
make usb=1 clean
|
||||
|
||||
make usb=1
|
||||
|
||||
|
||||
|
||||
echo " "
|
||||
|
||||
echo "Building Nintendont Kernel (SD)"
|
||||
|
||||
echo " "
|
||||
|
||||
make clean
|
||||
|
||||
make
|
||||
|
||||
|
||||
|
||||
cd ../loader/source/ppc
|
||||
|
||||
echo " "
|
||||
|
||||
echo "Building Nintendont HID"
|
||||
|
||||
echo " "
|
||||
|
||||
sh ./build.sh
|
||||
|
||||
|
||||
|
||||
cd ../../../loader
|
||||
|
||||
echo " "
|
||||
|
||||
echo "Building Nintendont Loader"
|
||||
|
||||
echo " "
|
||||
|
||||
make clean
|
||||
|
||||
make
|
||||
|
||||
echo " "
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#define __NINTENDONT_VERSION_H__
|
||||
|
||||
#define NIN_MAJOR_VERSION 1
|
||||
#define NIN_MINOR_VERSION 110
|
||||
#define NIN_MINOR_VERSION 111
|
||||
|
||||
#define NIN_VERSION ((NIN_MAJOR_VERSION << 16) | NIN_MINOR_VERSION)
|
||||
|
||||
|
57
kernel/DI.c
57
kernel/DI.c
@@ -32,6 +32,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "Patch.h"
|
||||
#include "FST.h"
|
||||
|
||||
#include "asm/multidol_ldr.h"
|
||||
|
||||
#ifndef DEBUG_DI
|
||||
#define dbgprintf(...)
|
||||
#else
|
||||
@@ -717,7 +719,12 @@ void DIUpdateRegisters( void )
|
||||
{
|
||||
CacheInit(FSTBuf, false);
|
||||
DIOK = 1;
|
||||
}
|
||||
} break;
|
||||
case 0xFA:
|
||||
{
|
||||
DIReadTGC_DOL();
|
||||
DIOK = 1;
|
||||
} break;
|
||||
}
|
||||
|
||||
if( DIOK )
|
||||
@@ -741,6 +748,7 @@ void DIUpdateRegisters( void )
|
||||
}
|
||||
|
||||
static u8 *DI_Read_Buffer = (u8*)(0x11200000);
|
||||
u32 tgc_dol_offset = 0, tgc_hdrsize = 0, tgc_offset = 0;
|
||||
u32 DIReadThread(void *arg)
|
||||
{
|
||||
//dbgprintf("DI Thread Running\r\n");
|
||||
@@ -796,18 +804,31 @@ u32 DIReadThread(void *arg)
|
||||
|
||||
case IOS_IOCTL:
|
||||
src = DI_Read_Buffer;
|
||||
dest = (char*)di_msg->ioctl.buffer_io;
|
||||
length = di_msg->ioctl.length_io;
|
||||
offset = (u32)di_msg->ioctl.buffer_in;
|
||||
|
||||
if( FSTMode )
|
||||
FSTRead( GamePath, src, length, offset );
|
||||
if((u32)di_msg->ioctl.buffer_io == 0x01300000)
|
||||
{ //multidol, loader always comes after reading tgc header
|
||||
tgc_dol_offset = offset + *(vu32*)((u8*)dest + 0x1C);
|
||||
tgc_hdrsize = length;
|
||||
tgc_offset = offset;
|
||||
//copy in our own apploader
|
||||
dest = (char*)di_msg->ioctl.buffer_io;
|
||||
memcpy( dest, multidol_ldr, multidol_ldr_size );
|
||||
sync_after_write( dest, multidol_ldr_size );
|
||||
}
|
||||
else
|
||||
src = CacheRead( src, length, offset );
|
||||
{
|
||||
dest = (char*)di_msg->ioctl.buffer_io;
|
||||
length = di_msg->ioctl.length_io;
|
||||
offset = (u32)di_msg->ioctl.buffer_in;
|
||||
|
||||
memcpy( dest, src, length );
|
||||
DoPatches( dest, length, offset );
|
||||
sync_after_write( dest, length );
|
||||
if( FSTMode )
|
||||
FSTRead( GamePath, src, length, offset );
|
||||
else
|
||||
src = CacheRead( src, length, offset );
|
||||
|
||||
memcpy( dest, src, length );
|
||||
DoPatches( dest, length, offset );
|
||||
sync_after_write( dest, length );
|
||||
}
|
||||
mqueue_ack( di_msg, 0 );
|
||||
break;
|
||||
|
||||
@@ -817,3 +838,17 @@ u32 DIReadThread(void *arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
extern u32 PatchState;
|
||||
void DIReadTGC_DOL()
|
||||
{
|
||||
u8 *dest = (u8*)0x10000000;
|
||||
/* dol header to restart patching */
|
||||
PatchState = 0;
|
||||
u8 *dol_hdr = CacheRead( dest, 0x100, tgc_dol_offset );
|
||||
if(dol_hdr != dest)
|
||||
memcpy(dest, dol_hdr, 0x100);
|
||||
|
||||
DoPatches( (char*)dest, 0x100, tgc_dol_offset );
|
||||
write32((u32)dest + 0x100, tgc_dol_offset);
|
||||
sync_after_write( dest, 0x120 );
|
||||
}
|
||||
|
@@ -72,5 +72,5 @@ void DIUnregister(void);
|
||||
u32 DIReadThread(void *arg);
|
||||
void DIChangeDisc( u32 DiscNumber );
|
||||
void DIUpdateRegisters( void );
|
||||
|
||||
void DIReadTGC_DOL(void);
|
||||
#endif
|
@@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "Config.h"
|
||||
#include "global.h"
|
||||
#include "patches.c"
|
||||
#include "SI.h"
|
||||
|
||||
//#define DEBUG_DSP // Very slow!! Replace with raw dumps?
|
||||
|
||||
@@ -36,7 +37,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
u32 CardLowestOff = 0;
|
||||
u32 POffset = 0x2F00;
|
||||
vu32 Region = 0;
|
||||
|
||||
extern FIL GameFile;
|
||||
extern vu32 TRIGame;
|
||||
extern u32 SystemRegion;
|
||||
@@ -632,8 +632,10 @@ void DoPatches( char *Buffer, u32 Length, u32 Offset )
|
||||
u32 value = 0;
|
||||
|
||||
if( (u32)Buffer >= 0x01800000 )
|
||||
return;
|
||||
|
||||
{
|
||||
if((u32)Buffer != 0x10000000)
|
||||
return;
|
||||
}
|
||||
for( i=0; i < Length; i+=4 )
|
||||
{
|
||||
*(vu32*)(Buffer+i) = *(vu32*)(Buffer+i);
|
||||
@@ -1537,7 +1539,7 @@ void DoPatches( char *Buffer, u32 Length, u32 Offset )
|
||||
}
|
||||
#endif
|
||||
|
||||
if( (PatchCount & (1|2|4|8|2048)) != (1|2|4|8|2048) )
|
||||
if( ((PatchCount & (1|2|4|8|2048)) != (1|2|4|8|2048)) )
|
||||
{
|
||||
#ifdef DEBUG_PATCH
|
||||
dbgprintf("Patch:Could not apply all required patches!\r\n");
|
||||
|
Binary file not shown.
Binary file not shown.
@@ -34,13 +34,23 @@ int main (int argc, char **argv)
|
||||
unsigned char *bin = (unsigned char*)malloc(fsize);
|
||||
fread(bin,fsize,1,f);
|
||||
fclose(f);
|
||||
/* generate names */
|
||||
size_t namelen = strrchr(argv[1], '.') - argv[1];
|
||||
char *newname = calloc(namelen+3, sizeof(char));
|
||||
char *basename = calloc(namelen+1, sizeof(char));
|
||||
strncpy(basename, argv[1], namelen);
|
||||
strncpy(newname, basename, namelen);
|
||||
strcpy(newname+namelen, ".h");
|
||||
/* new .h file */
|
||||
size_t newnamelen = strrchr(argv[1], '.') - argv[1];
|
||||
char *newname = calloc(newnamelen+3, sizeof(char));
|
||||
strncpy(newname, argv[1], newnamelen);
|
||||
strcpy(newname + newnamelen, ".h");
|
||||
|
||||
/* name for the .h content */
|
||||
size_t basenamelen = newnamelen;
|
||||
if(strchr(argv[1], '/') != NULL)
|
||||
basenamelen -= (strrchr(argv[1], '/')+1 - argv[1]);
|
||||
|
||||
char *basename = calloc(basenamelen+1, sizeof(char));
|
||||
if(strchr(argv[1], '/') != NULL)
|
||||
strncpy(basename, strrchr(argv[1], '/')+1, basenamelen);
|
||||
else
|
||||
strncpy(basename, argv[1], basenamelen);
|
||||
|
||||
/* get creation time */
|
||||
time_t curtime = time (NULL);
|
||||
struct tm *loctime = localtime (&curtime);
|
||||
@@ -48,11 +58,13 @@ int main (int argc, char **argv)
|
||||
f = fopen(newname, "w");
|
||||
free(newname);
|
||||
fputs("/*\n",f);
|
||||
fprintf(f,"\tFilename : %s\n",argv[1]);
|
||||
fprintf(f,"\tDate created: %s", asctime (loctime));
|
||||
fprintf(f,"\tFilename : %s\n", strchr(argv[1], '/') != NULL ? strrchr(argv[1], '/')+1 : argv[1]);
|
||||
fprintf(f,"\tDate created: %s", asctime(loctime));
|
||||
fputs("*/\n\n",f);
|
||||
fprintf(f,"#define %s_size 0x%x\n\n",basename,fsize);
|
||||
fprintf(f,"const unsigned char %s[] = {",basename);
|
||||
free(basename);
|
||||
|
||||
size_t i = 0;
|
||||
while(i < fsize)
|
||||
{
|
||||
|
@@ -1 +1,2 @@
|
||||
gcc main.c -s -Os -static -o bin2h
|
||||
gcc main.c -s -Os -static -o bin2h.exe
|
||||
pause
|
340
multidol/COPYING
Normal file
340
multidol/COPYING
Normal file
@@ -0,0 +1,340 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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 2 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, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
|
68
multidol/Makefile
Normal file
68
multidol/Makefile
Normal file
@@ -0,0 +1,68 @@
|
||||
|
||||
#PREFIX = powerpc-gekko-
|
||||
PREFIX = $(DEVKITPPC)/bin/powerpc-eabi-
|
||||
#PREFIX = /home/megazig/Wii/bootmii-utils/bin/powerpc-elf-
|
||||
|
||||
AR = $(PREFIX)ar
|
||||
AS = $(PREFIX)as
|
||||
CC = $(PREFIX)gcc
|
||||
CXX = $(PREFIX)g++
|
||||
LD = $(PREFIX)ld
|
||||
OBJCOPY = $(PREFIX)objcopy
|
||||
RANLIB = $(PREFIX)ranlib
|
||||
STRIP = $(PREFIX)strip
|
||||
|
||||
ifeq ($(windows), 1)
|
||||
BIN2H = ../kernel/bin2h/bin2h.exe
|
||||
else
|
||||
BIN2H = ../kernel/bin2h/bin2h
|
||||
endif
|
||||
|
||||
MACHDEP = -mcpu=750 -mno-eabi -mhard-float
|
||||
#CFLAGS = $(MACHDEP) -Os -Wall -pipe -ffunction-sections -finline-functions-called-once -mno-sdata --combine -fwhole-program -ffreestanding
|
||||
CFLAGS = $(MACHDEP) -O1 -s -Werror -Wall -pipe -ffunction-sections -finline-functions-called-once -mno-sdata
|
||||
LDFLAGS = $(MACHDEP) -n -nostartfiles -nostdlib -Wl,-T,openstub.ld -L.
|
||||
ASFLAGS = -D_LANGUAGE_ASSEMBLY -DHW_RVL -DTINY
|
||||
|
||||
TARGET_LINKED = multidol_ldr.elf
|
||||
TARGET = ../kernel/asm/multidol_ldr.bin
|
||||
|
||||
CFILES = utils.c cache.c main.c
|
||||
#OBJS = crt0.o _all.o
|
||||
OBJS = crt0.o utils.o cache.o main.o
|
||||
|
||||
DEPDIR = .deps
|
||||
|
||||
LIBS =
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
%.o: %.s
|
||||
@echo " ASSEMBLE $<"
|
||||
@$(CC) $(CFLAGS) $(DEFINES) $(ASFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.S
|
||||
@echo " ASSEMBLE $<"
|
||||
@$(CC) $(CFLAGS) $(DEFINES) $(ASFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.c
|
||||
@echo " COMPILE $<"
|
||||
@$(CC) $(CFLAGS) $(DEFINES) -c $< -o $@
|
||||
|
||||
#_all.o: $(CFILES)
|
||||
# @echo " COMPILE ALL "
|
||||
# @mkdir -p $(DEPDIR)
|
||||
# @$(CC) $(CFLAGS) $(DEFINES) -Wp,-MMD,$(DEPDIR)/$(*F).d,-MQ,"$@",-MP -c $(CFILES) -o $@
|
||||
|
||||
$(TARGET_LINKED): $(OBJS)
|
||||
@echo " LINK $@"
|
||||
@$(CC) -g -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
|
||||
|
||||
$(TARGET): $(TARGET_LINKED)
|
||||
@echo " OBJCOPY $@"
|
||||
@$(OBJCOPY) -O binary $< $@
|
||||
@echo " BIN2H $@"
|
||||
@$(BIN2H) $(TARGET)
|
||||
|
||||
clean:
|
||||
rm -rf $(TARGET_LINKED) $(TARGET) $(OBJS) $(DEPDIR)
|
131
multidol/README
Normal file
131
multidol/README
Normal file
@@ -0,0 +1,131 @@
|
||||
TinyLoad v0.2
|
||||
A Wii disc game loader in 4096 bytes
|
||||
====================================
|
||||
|
||||
What?
|
||||
=====
|
||||
|
||||
TinyLoad is a simple original Wii game launcher. You run it, it launches
|
||||
whatever's inserted into the drive. Simple. It ignores game regions, so it's
|
||||
region-free. It won't install updates. It won't load burned copies. There are no
|
||||
controls or settings.
|
||||
|
||||
The user interface shows two things: progress, and error status. A white bar
|
||||
across the bottom of the screen shows the current (rough) progress. If an error
|
||||
is detected, a portion of the top of the screen will turn red. It will then
|
||||
attempt to launch The Homebrew Channel (only applies to recent versions with the
|
||||
JODI Title ID). If this fails then it will simply hang.
|
||||
|
||||
If the launcher freezes with the progress bar visible and no red error box, then
|
||||
you've probably hit a bug. Try the debug version if you have a USB Gecko.
|
||||
|
||||
If it freezes with a black screen after the progress bar has reached its
|
||||
endpoint and disappeared, then the game itself is freezing.
|
||||
|
||||
I obviously have only tested this with a few games. Chances are it doesn't work
|
||||
with every Wii game out there.
|
||||
|
||||
The debug version requires a USB Gecko and shows debug messages over it.
|
||||
|
||||
Notes:
|
||||
- TinyLoad sets the PPC timebase correctly according to your Wii's RTC. This
|
||||
fixes date/time issues in games.
|
||||
- The video code makes lots of assumptions. It will only work if VI was left
|
||||
configured in a "standard" mode, with a 640x480-640x574 framebuffer. VI should
|
||||
be blanked; if it isn't, then TinyLoad will not blank it before launching
|
||||
the game so your screen will blink green for a split second as the game
|
||||
initializes VI. It has been tested to work correctly when launched by the
|
||||
Homebrew Channel in at least NTSC 480p and PAL interlaced modes. If these
|
||||
assumptions don't hold then the progress bar display will not work properly,
|
||||
but the rest of the loader should work fine.
|
||||
- TinyLoad does not perform _any_ patching of games. The lowmem video mode
|
||||
setting follows whatever video mode was left set by the application used to
|
||||
launch TinyLoad, except that PAL games are forced to PAL if NTSC is detected.
|
||||
This does not patch the game, it's merely the informative value in low memory;
|
||||
games are free to read SYSCONF/setting.txt and ignore it. I don't really care
|
||||
because I use 480p mode anyway. If you need more advanced options, just use
|
||||
Gecko OS.
|
||||
- Normally, game audio will not work correctly if launched via a loader that
|
||||
was initially launched via BootMii-boot2. This is a bug in libogc (it doesn't
|
||||
know how to initialize the DSP for the first time and leaves it in a broken
|
||||
state), and it affects anything running after the Wii was booted first into
|
||||
a libogc application, including the System Menu's loader. In other words,
|
||||
BootMii-boot2 -> HBC -> System Menu (or Gecko OS) -> Game may cause distorted
|
||||
audio. TinyLoad _does_ work, by resetting the audio hardware to let the game
|
||||
reinitialize it properly. So, BootMii-boot2 -> HBC -> TinyLoad -> Game will
|
||||
work fine. This ought to be worked around in a future release of HBC, at
|
||||
least. I'd suggest fixing libogc, but I know shagkur is just going to rip the
|
||||
proper code from the SDK again. Anyway, launching using TinyLoad will work
|
||||
fine as it contains the workaround.
|
||||
- TinyLoad will load the correct IOS as specified in the partition TMD. It does
|
||||
not support loading any other IOS.
|
||||
- TinyLoad will not install updates. Not having the right IOS for the game will
|
||||
probably result in a red error and reset about halfway through.
|
||||
|
||||
Broken stuff:
|
||||
- I don't think online games work. Not sure why (I do copy the TitleID to the
|
||||
proper spot, I think). If it works for you, let me know. Likewise, if you know
|
||||
what the problem is or you can fix it, please let me know.
|
||||
|
||||
Who?
|
||||
====
|
||||
|
||||
Program:
|
||||
Copyright 2008-2009 Hector Martin (marcan) <marcan@marcansoft.com>
|
||||
|
||||
Supporting code:
|
||||
Copyright 2008-2009 Segher Boessenkool <segher@kernel.crashing.org>
|
||||
Copyright 2008-2009 Andre Heider (dhewg) <dhewg@wiibrew.org>
|
||||
Copyright 2008 Nuke <wiinuke@gmail.com>
|
||||
|
||||
Awesome icon:
|
||||
Copyright 2009 Freddy Leitner (drmr)
|
||||
|
||||
This code is licensed to you under the terms of the GNU GPL, version 2;
|
||||
see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
|
||||
The icon is licensed under CC-BY-NC-SA 3.0:
|
||||
http://creativecommons.org/licenses/by-nc-sa/3.0/
|
||||
|
||||
Why?
|
||||
====
|
||||
|
||||
Because:
|
||||
- System Menu 4.2 forever broke region free via modchips
|
||||
- I have a USA Wii which I regularly use with EUR games
|
||||
- Gecko OS is somewhat annoying and recent versions are unstable (for me anyway)
|
||||
- I refuse to perform retarded firmware mods.
|
||||
- I autoboot HBC via BootMii-boot2 and using the System Menu takes longer
|
||||
anyway.
|
||||
|
||||
I also think that low-level apps that tightly hug the hardware are very
|
||||
educational, so why not. And hey, the code is pretty short, so you ought to be
|
||||
able to read it completely and learn how all this crazy Wii stuff *actually*
|
||||
works :-)
|
||||
|
||||
How?
|
||||
====
|
||||
|
||||
TinyLoad is not compressed. The 4 kilobytes are raw code and data, plus the ELF
|
||||
header. The original loader was fit in 4 kilobytes by avoiding bloated libraries
|
||||
like libogc and instead using a small codebase pieced together from bits of the
|
||||
Twilight Hack and of HBC's reload stub. Extra features (SYSCONF reading, RTC
|
||||
reading, proper lowmem settings, VI stuff, progress bar, etc) were added by
|
||||
making space via a combination of increasingly complex compiler options, manual
|
||||
tweaks, and micro-optimization.
|
||||
|
||||
Nonetheless, there is almost no assembly code and the C code, though compact and
|
||||
odd at times, should be moderately readable. Just keep in mind that I
|
||||
deliberately leave old values floating around and/or use odd initializations in
|
||||
order to simplify the code. Also, I haven't commented most of it. If you're
|
||||
really interested, give me a shout and I'll see what I can do to make it more
|
||||
acceptable.
|
||||
|
||||
If you want some *real* fun, load the ELF in IDA. The function inlining and tail
|
||||
call goodness ought to provide tons of entertainment.
|
||||
|
||||
Where?
|
||||
======
|
||||
|
||||
http://wiibrew.org/TinyLoad
|
||||
http://marcansoft.com/blog/
|
51
multidol/cache.c
Normal file
51
multidol/cache.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
TinyLoad - a simple region free (original) game launcher in 4k
|
||||
|
||||
# This code is licensed to you under the terms of the GNU GPL, version 2;
|
||||
# see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
*/
|
||||
|
||||
/* This code comes from the Twilight Hack */
|
||||
// Copyright 2008-2009 Segher Boessenkool <segher@kernel.crashing.org>
|
||||
// Copyright 2008-2009 Hector Martin <marcan@marcansoft.com>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
void sync_before_read(void *p, u32 len)
|
||||
{
|
||||
u32 a, b;
|
||||
|
||||
a = (u32)p & ~0x1f;
|
||||
b = ((u32)p + len + 0x1f) & ~0x1f;
|
||||
|
||||
for ( ; a < b; a += 32)
|
||||
asm("dcbi 0,%0" : : "b"(a) : "memory");
|
||||
|
||||
asm("sync ; isync");
|
||||
}
|
||||
|
||||
void sync_after_write(const void *p, u32 len)
|
||||
{
|
||||
u32 a, b;
|
||||
|
||||
a = (u32)p & ~0x1f;
|
||||
b = ((u32)p + len + 0x1f) & ~0x1f;
|
||||
|
||||
for ( ; a < b; a += 32)
|
||||
asm("dcbf 0,%0" : : "b"(a));
|
||||
|
||||
asm("sync ; isync");
|
||||
}
|
||||
|
||||
void sync_before_exec(const void *p, u32 len)
|
||||
{
|
||||
u32 a, b;
|
||||
|
||||
a = (u32)p & ~0x1f;
|
||||
b = ((u32)p + len + 0x1f) & ~0x1f;
|
||||
|
||||
for ( ; a < b; a += 32)
|
||||
asm("dcbst 0,%0 ; sync ; icbi 0,%0" : : "b"(a));
|
||||
|
||||
asm("sync ; isync");
|
||||
}
|
22
multidol/cache.h
Normal file
22
multidol/cache.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
TinyLoad - a simple region free (original) game launcher in 4k
|
||||
|
||||
# This code is licensed to you under the terms of the GNU GPL, version 2;
|
||||
# see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
*/
|
||||
|
||||
/* This code comes from the Twilight Hack */
|
||||
// Copyright 2008-2009 Segher Boessenkool <segher@kernel.crashing.org>
|
||||
// Copyright 2008-2009 Hector Martin <marcan@marcansoft.com>
|
||||
|
||||
#ifndef __CACHE_H__
|
||||
#define __CACHE_H__
|
||||
|
||||
#include "types.h"
|
||||
|
||||
void sync_before_read(void *p, u32 len);
|
||||
void sync_after_write(const void *p, u32 len);
|
||||
void sync_before_exec(const void *p, u32 len);
|
||||
|
||||
#endif
|
||||
|
19
multidol/crt0.S
Normal file
19
multidol/crt0.S
Normal file
@@ -0,0 +1,19 @@
|
||||
# Copyright 2008-2009 Segher Boessenkool <segher@kernel.crashing.org>
|
||||
# This code is licensed to you under the terms of the GNU GPL, version 2;
|
||||
# see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
|
||||
.extern _main
|
||||
.globl _start
|
||||
_start:
|
||||
|
||||
# Setup stack.
|
||||
lis 1,__stack_top@ha ; addi 1,1,__stack_top@l ; li 0,0 ; stwu 0,-64(1)
|
||||
|
||||
# Clear BSS.
|
||||
lis 3,__bss_start@ha ; addi 3,3,__bss_start@l
|
||||
li 4,0
|
||||
lis 5,__bss_end@ha ; addi 5,5,__bss_end@l ; sub 5,5,3
|
||||
bl _memset
|
||||
|
||||
# Go!
|
||||
bl _main
|
51
multidol/dip.h
Normal file
51
multidol/dip.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
|
||||
Nintendont (Loader) - Playing Gamecubes in Wii mode on a Wii U
|
||||
|
||||
Copyright (C) 2013 crediar
|
||||
|
||||
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 version 2.
|
||||
|
||||
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, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __DIP_H__
|
||||
#define __DIP_H__
|
||||
|
||||
#define DI_BASE 0xC0002F00
|
||||
|
||||
#define DI_STATUS (*(vu32*)(DI_BASE+0x00))
|
||||
#define DI_COVER (*(vu32*)(DI_BASE+0x04))
|
||||
#define DI_CMD_0 (*(vu32*)(DI_BASE+0x08))
|
||||
#define DI_CMD_1 (*(vu32*)(DI_BASE+0x0C))
|
||||
#define DI_CMD_2 (*(vu32*)(DI_BASE+0x10))
|
||||
#define DI_DMA_ADR (*(vu32*)(DI_BASE+0x14))
|
||||
#define DI_DMA_LEN (*(vu32*)(DI_BASE+0x18))
|
||||
#define DI_CONTROL (*(vu32*)(DI_BASE+0x1C))
|
||||
#define DI_IMM (*(vu32*)(DI_BASE+0x20))
|
||||
#define DI_CONFIG (*(vu32*)(DI_BASE+0x24))
|
||||
|
||||
#define DI_SHADOW (DI_BASE + 0x30)
|
||||
|
||||
#define DI_SSTATUS (*(vu32*)(DI_SHADOW+0x00))
|
||||
#define DI_SCOVER (*(vu32*)(DI_SHADOW+0x04))
|
||||
#define DI_SCMD_0 (*(vu32*)(DI_SHADOW+0x08))
|
||||
#define DI_SCMD_1 (*(vu32*)(DI_SHADOW+0x0C))
|
||||
#define DI_SCMD_2 (*(vu32*)(DI_SHADOW+0x10))
|
||||
#define DI_SDMA_ADR (*(vu32*)(DI_SHADOW+0x14))
|
||||
#define DI_SDMA_LEN (*(vu32*)(DI_SHADOW+0x18))
|
||||
#define DI_SCONTROL (*(vu32*)(DI_SHADOW+0x1C))
|
||||
#define DI_SIMM (*(vu32*)(DI_SHADOW+0x20))
|
||||
#define DI_SCONFIG (*(vu32*)(DI_SHADOW+0x24))
|
||||
|
||||
#endif
|
107
multidol/hw.h
Normal file
107
multidol/hw.h
Normal file
@@ -0,0 +1,107 @@
|
||||
#ifndef __HW_H__
|
||||
#define __HW_H__
|
||||
|
||||
#define MSR_POW (1<<18)
|
||||
#define MSR_ILE (1<<16)
|
||||
#define MSR_EE (1<<15)
|
||||
#define MSR_PR (1<<14)
|
||||
#define MSR_FP (1<<13)
|
||||
#define MSR_ME (1<<12)
|
||||
#define MSR_FE0 (1<<11)
|
||||
#define MSR_SE (1<<10)
|
||||
#define MSR_BE (1<< 9)
|
||||
#define MSR_FE1 (1<< 8)
|
||||
#define MSR_IP (1<< 6)
|
||||
#define MSR_IR (1<< 5)
|
||||
#define MSR_DR (1<< 4)
|
||||
#define MSR_RI (1<< 1)
|
||||
#define MSR_LE (1<< 0)
|
||||
|
||||
#define HID0_EMCP (1<<31)
|
||||
#define HID0_DBP (1<<30)
|
||||
#define HID0_EBA (1<<29)
|
||||
#define HID0_EBD (1<<28)
|
||||
#define HID0_BCLK (1<<27)
|
||||
#define HID0_ECLK (1<<25)
|
||||
#define HID0_PAR (1<<24)
|
||||
#define HID0_DOZE (1<<23)
|
||||
#define HID0_NAP (1<<22)
|
||||
#define HID0_SLEEP (1<<21)
|
||||
#define HID0_DPM (1<<20)
|
||||
#define HID0_NHR (1<<16)
|
||||
#define HID0_ICE (1<<15)
|
||||
#define HID0_DCE (1<<14)
|
||||
#define HID0_ILOCK (1<<13)
|
||||
#define HID0_DLOCK (1<<12)
|
||||
#define HID0_ICFI (1<<11)
|
||||
#define HID0_DCFI (1<<10)
|
||||
#define HID0_SPD (1<< 9)
|
||||
#define HID0_IFEM (1<< 8)
|
||||
#define HID0_SGE (1<< 7)
|
||||
#define HID0_DCFA (1<< 6)
|
||||
#define HID0_BTIC (1<< 5)
|
||||
#define HID0_ABE (1<< 3)
|
||||
#define HID0_BHT (1<< 2)
|
||||
#define HID0_NOOPTI (1<< 0)
|
||||
|
||||
#define HID2_LSQE (1<<31)
|
||||
#define HID2_WPE (1<<30)
|
||||
#define HID2_PSE (1<<29)
|
||||
#define HID2_LCE (1<<28)
|
||||
|
||||
#define L2CR_L2E (1<<31)
|
||||
#define L2CR_L2CE (1<<30)
|
||||
#define L2CR_L2DO (1<<22)
|
||||
#define L2CR_L2I (1<<21)
|
||||
#define L2CR_L2WT (1<<19)
|
||||
#define L2CR_L2TS (1<<18)
|
||||
#define L2CR_L2IP (1<< 0)
|
||||
|
||||
#define DMAU_MEM_ADDR_MASK 0xFFFFFFE0
|
||||
#define DMAU_LENU(x) (x & 0x1F)
|
||||
#define DMAL_LC_ADDR_MASK 0xFFFFFFE0
|
||||
#define DMAL_LD (1<< 4)
|
||||
#define DMAL_LENL(x) (x & 0xC)
|
||||
#define DMAL_T (1<< 1)
|
||||
#define DMAL_F (1<< 0)
|
||||
|
||||
#define BATU_BEPI_MASK 0xFFFC0000
|
||||
#define BATU_BL(x) (x & 0x00001FFC)
|
||||
#define BATU_VS (1<< 1)
|
||||
#define BATU_VP (1<< 0)
|
||||
#define BATL_BRPN_MASK 0xFFFC0000
|
||||
#define BATL_WIMG_MASK 0x78
|
||||
#define BATL_PP (1<< 0)
|
||||
|
||||
// BATU - 0x80001FFF == 256Mbytes
|
||||
// 1000 0000 000x xxx0 0001 1111 1111 11xx
|
||||
// 0x80000000|256Mbytes|VS|VP
|
||||
// BATL - 0x00000002
|
||||
// 0000 0000 0000 000x xxxx xxxx x000 0x10
|
||||
// PP=b10
|
||||
//
|
||||
// BATU - 0xC0001FFF == 256Mbytes
|
||||
// BATL - 0x0000002a
|
||||
// 0000 0000 0000 000x xxxx xxxx x010 1x10
|
||||
// WIMG=b0101|PP=b10
|
||||
//
|
||||
|
||||
#define rHID2 920
|
||||
#define rDMAU 922
|
||||
#define rDMAL 923
|
||||
#define rHID0 1008
|
||||
#define rHID1 1009
|
||||
#define rHID4 1011
|
||||
|
||||
/*
|
||||
* Upper PTE
|
||||
* 0|1-24|25|26-31
|
||||
* V|VSID|H |API
|
||||
*
|
||||
* Lower PTE
|
||||
* 0-19|20-22|23|24|25-28|29|30-31
|
||||
* RPN |000 |R |C |WIMG |0 |PP
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
103
multidol/main.c
Normal file
103
multidol/main.c
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
TinyLoad - a simple region free (original) game launcher in 4k
|
||||
|
||||
# This code is licensed to you under the terms of the GNU GPL, version 2;
|
||||
# see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
*/
|
||||
|
||||
/* This code comes from HBC's stub which was based on dhewg's geckoloader stub */
|
||||
// Copyright 2008-2009 Andre Heider <dhewg@wiibrew.org>
|
||||
// Copyright 2008-2009 Hector Martin <marcan@marcansoft.com>
|
||||
|
||||
#include "utils.h"
|
||||
#include "cache.h"
|
||||
#include "dip.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;
|
||||
|
||||
int di_read(void *ptr, void *offset, u32 len)
|
||||
{
|
||||
DI_STATUS = 0x2A | 0x14; // clear IRQs
|
||||
DI_CMD_0 = 0xA8000000;
|
||||
DI_CMD_1 = ((u32)offset)>>2;
|
||||
DI_CMD_2 = len;
|
||||
DI_DMA_ADR = (u32)ptr;
|
||||
DI_DMA_LEN = len;
|
||||
|
||||
|
||||
//Start cmd!
|
||||
DI_CONTROL = 3;
|
||||
while( DI_CONTROL == 3 );
|
||||
while( DI_SCONTROL & 1 );
|
||||
|
||||
while(1)
|
||||
{
|
||||
if( DI_SSTATUS & 0x04 ) //Error
|
||||
{
|
||||
DI_SSTATUS = 0;
|
||||
return 0;
|
||||
}
|
||||
if( DI_SSTATUS & 0x10 ) //Transfer done
|
||||
{
|
||||
sync_before_read( (void*)ptr, len );
|
||||
|
||||
DI_SSTATUS = 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u32 entrypoint = 0;
|
||||
void _main(void)
|
||||
{
|
||||
/* start reading tgc */
|
||||
DI_CMD_0 = 0xFA000000;
|
||||
DI_CONTROL = 3;
|
||||
|
||||
while( DI_CONTROL == 3 ) ;
|
||||
while( DI_SCONTROL & 1 ) ;
|
||||
usleep(1000);
|
||||
|
||||
/* read dol */
|
||||
u32 i;
|
||||
void *doloffset = (void*)(*(vu32*)0x90000100);
|
||||
dolheader *dolfile = (dolheader *)0x90000000;
|
||||
sync_before_read(dolfile, 0x100);
|
||||
|
||||
dolheader header;
|
||||
_memcpy(&header, dolfile, 0x100);
|
||||
|
||||
entrypoint = header.entry_point;
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
if ((!header.text_size[i]) || (header.text_start[i] < 0x100))
|
||||
continue;
|
||||
di_read((void *) header.text_start[i], doloffset + header.text_pos[i], header.text_size[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 11; i++)
|
||||
{
|
||||
if ((!header.data_size[i]) || (header.data_start[i] < 0x100))
|
||||
continue;
|
||||
di_read((void *) header.data_start[i], doloffset + header.data_pos[i], header.data_size[i]);
|
||||
}
|
||||
|
||||
asm volatile (
|
||||
"lis %r3, entrypoint@h\n"
|
||||
"ori %r3, %r3, entrypoint@l\n"
|
||||
"lwz %r3, 0(%r3)\n"
|
||||
"mtlr %r3\n"
|
||||
"blr\n"
|
||||
);
|
||||
}
|
35
multidol/openstub.ld
Normal file
35
multidol/openstub.ld
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
TinyLoad - a simple region free (original) game launcher in 4k
|
||||
|
||||
# This code is licensed to you under the terms of the GNU GPL, version 2;
|
||||
# see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
*/
|
||||
|
||||
OUTPUT_FORMAT("elf32-powerpc")
|
||||
OUTPUT_ARCH(powerpc:common)
|
||||
|
||||
ENTRY(_start)
|
||||
|
||||
PHDRS {
|
||||
app PT_LOAD FLAGS(7);
|
||||
}
|
||||
|
||||
SECTIONS {
|
||||
. = 0x81300000;
|
||||
|
||||
.text : { *(.text) *(.text.*) } :app
|
||||
|
||||
.data : { *(.data) *(.data.*) }
|
||||
.rodata : { *(.rodata) *(.rodata.*) }
|
||||
|
||||
__bss_start = .;
|
||||
.bss : { *(.bss) *(.bss.*) }
|
||||
__bss_end = .;
|
||||
|
||||
__stack_end = .;
|
||||
.stack : {
|
||||
. = . + 0x10000;
|
||||
__stack_top = .;
|
||||
}
|
||||
}
|
||||
|
33
multidol/types.h
Normal file
33
multidol/types.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
TinyLoad - a simple region free (original) game launcher in 4k
|
||||
|
||||
# This code is licensed to you under the terms of the GNU GPL, version 2;
|
||||
# see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
*/
|
||||
|
||||
// Copyright 2008-2009 Hector Martin <marcan@marcansoft.com>
|
||||
|
||||
#ifndef __TYPES_H__
|
||||
#define __TYPES_H__
|
||||
|
||||
typedef volatile unsigned char vu8;
|
||||
typedef volatile unsigned short vu16;
|
||||
typedef volatile unsigned int vu32;
|
||||
typedef volatile unsigned long long vu64;
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned long long u64;
|
||||
|
||||
typedef char s8;
|
||||
typedef short s16;
|
||||
typedef int s32;
|
||||
typedef long long s64;
|
||||
|
||||
#define NULL ((void *)0)
|
||||
|
||||
#define ALIGNED(n) __attribute__((aligned(n)))
|
||||
|
||||
#endif
|
||||
|
43
multidol/utils.c
Normal file
43
multidol/utils.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
TinyLoad - a simple region free (original) game launcher in 4k
|
||||
|
||||
# This code is licensed to you under the terms of the GNU GPL, version 2;
|
||||
# see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
*/
|
||||
|
||||
/* This code comes from HBC's stub which was based on geckoloader and the Twilight Hack code */
|
||||
/* Some of these routines are from public domain sources */
|
||||
// Copyright 2008-2009 Segher Boessenkool <segher@kernel.crashing.org>
|
||||
// Copyright 2008-2009 Andre Heider <dhewg@wiibrew.org>
|
||||
// Copyright 2008-2009 Hector Martin <marcan@marcansoft.com>
|
||||
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
|
||||
static u32 get_time(void)
|
||||
{
|
||||
u32 x;
|
||||
|
||||
asm volatile("mftb %0" : "=r"(x));
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
void usleep(u32 us)
|
||||
{
|
||||
u32 _start = get_time();
|
||||
while ((get_time() - _start) < (91*us)) ;
|
||||
}
|
||||
|
||||
void _memcpy(void *ptr, const void *src, u32 size)
|
||||
{
|
||||
char* ptr2 = ptr;
|
||||
const char* src2 = src;
|
||||
while(size--) *ptr2++ = *src2++;
|
||||
}
|
||||
|
||||
void _memset(void *ptr, int c, u32 size)
|
||||
{
|
||||
char* ptr2 = ptr;
|
||||
while(size--) *ptr2++ = c;
|
||||
}
|
19
multidol/utils.h
Normal file
19
multidol/utils.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
TinyLoad - a simple region free (original) game launcher in 4k
|
||||
|
||||
# This code is licensed to you under the terms of the GNU GPL, version 2;
|
||||
# see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
*/
|
||||
|
||||
// Copyright 2008-2009 Hector Martin <marcan@marcansoft.com>
|
||||
|
||||
#ifndef __UTILS_H__
|
||||
#define __UTILS_H__
|
||||
|
||||
#include "types.h"
|
||||
|
||||
void usleep(u32 us);
|
||||
void _memcpy(void *ptr, const void *src, u32 size);
|
||||
void _memset(void *ptr, int c, u32 size);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user