Skip to content

Commit

Permalink
Merge branch 'jmlee337-slippi' into slippi
Browse files Browse the repository at this point in the history
  • Loading branch information
JLaferri committed Feb 27, 2019
2 parents fde0850 + 7eec4d8 commit 0de54e7
Show file tree
Hide file tree
Showing 24 changed files with 200 additions and 754 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ codehandler/*.h
.vscode/*
.idea/*
!kernel/gecko/*.bin
kernel/gecko/*.h
kernel/bin2h/bin2h
72 changes: 21 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
Download the `.zip` from the [latest release](https://github.com/project-slippi/Nintendont/releases/latest)

## Nintendont Slippi
This is a fork of [FIX94/Nintendont](https://github.com/FIX94/Nintendont) specifically
used for supporting Project Slippi. [See documentation in SLIPPI.md for more information](SLIPPI.md).
used for supporting Project Slippi.

## Users
See [README.md](https://github.com/FIX94/Nintendont/blob/master/README.md) for standard Nintendont if you're new to Nintendont.

### Replays
See documentation in [SLIPPI.md](SLIPPI.md) for more information.

-------------------------------------------
### Kadano's Wii softmodding guide
I recommend using [Kadano's guide](https://docs.google.com/document/d/1iaPI7Mb5fCzsLLLuEeQuR9-BeR8AOwvHyU-FM8GKmEs) if you're new to Wii homebrew. Many guides in the wild are out of date or weren't very good to begin with.

### Nintendont
A Wii Homebrew Project to play GC Games on Wii and vWii on Wii U
### Installation Summary
1. Download the `.zip` from the [latest release](https://github.com/project-slippi/Nintendont/releases/latest). Unzip to the root of your SD card such that `boot.dol`, `meta.xml`, and `icon.png` all end up under `/apps/Nintendont Melee`.
2. Copy your vanilla Melee (NTSC 1.02) ISO (as well as any special versions like [Training Mode](https://www.patreon.com/UnclePunch)) to `/games/`.
3. Combine with [Priiloader](http://wiibrew.org/wiki/Priiloader) and [Nintendont Forwarder for Priiloader](https://github.com/jmlee337/Nintendont-Forwarder-for-Priiloader) to autoboot from power-on to Nintendont.
4. Turn on autoboot in Nintendont settings to autoboot all the way to Melee.

## Developers
See [README.md](https://github.com/FIX94/Nintendont/blob/master/README.md) for standard Nintendont if you're new to Nintendont.

### Build Requirements
You will need to install part of the devkitPro toolchain to build Nintendont. Visit [the getting started page](https://devkitpro.org/wiki/Getting_Started) and find the instructions for your system. I recommend installing GBA, Wii, and GC packages. GBA is required to get `devkitARM` which isn't provided in the others. You effectively need `devkitARM` `devkitPPC` and `libogc`.

### Building on Windows
To build on windows, you need to run the `Incremental Build.bat` file in the Nintendont root.

#### Troubleshooting
### Troubleshooting
libwinpthread-1.dll error:
```
make -C multidol
Expand All @@ -23,49 +39,3 @@ make[1]: Leaving directory '/home/Jas/Documents/GitHub/Nintendont/multidol'
make: *** [Makefile:34: multidol] Error 2
```
For some reason my devkitPro installer did not install things quite correctly for me. In order to fix the above error, you will need to go to your `devkitPPC/bin` directory, grab the file called `libwinpthread-1.dll`. You will need to copy this file to `devkitPPC/libexec/gcc/powerpc-eabi/8.2.0`. Repeat the same thing for the `devkitARM` directory, this should fix the issue.

### Features:
* Works on Wii and Wii U (in vWii mode)
* Full-speed loading from a USB device or an SD card.
* Loads 1:1 and shrunken .GCM/.ISO disc images.
* Loads games as extracted files (FST format)
* Loads CISO-format disc images. (uLoader CISO format)
* Memory card emulation
* Play audio via disc audio streaming
* Bluetooth controller support (Classic Controller (Pro), Wii U Pro Controller)
* HID controller support via USB
* Custom button layout when using HID controllers
* Cheat code support
* Changeable configuration of various settings
* Reset/Power off via button combo (R + Z + Start) (R + Z + B + D-Pad Down)
* Advanced video mode patching, force progressive and force 16:9 widescreen
* Auto boot from loader
* Disc switching
* Use the official Nintendo GameCube controller adapter

### Features: (Wii only)
* Play retail discs
* Play backups from writable DVD media (Old Wii only)
* Use real memory cards
* GBA-Link cable
* WiiRd
* Allow use of the Nintendo GameCube Microphone

### What Nintendont doesn't do yet:
* BBA/Modem support

### What Nintendont will never support:
* Game Boy Player

### Quick Installation:
1. Get the [loader.dol](loader/loader.dol?raw=true), rename it to boot.dol and put it in /apps/Nintendont/ along with the files [meta.xml](nintendont/meta.xml?raw=true) and [icon.png](nintendont/icon.png?raw=true).
2. Copy your GameCube games to the /games/ directory. Subdirectories are optional for 1-disc games in ISO/GCM and CISO format.
* For 2-disc games, you should create a subdirectory /games/MYGAME/ (where MYGAME can be anything), then name disc 1 as "game.iso" and disc 2 as "disc2.iso".
* For extracted FST, the FST must be located in a subdirectory, e.g. /games/FSTgame/sys/boot.bin .
3. Connect your storage device to your Wii or Wii U and start The Homebrew Channel.
4. Select Nintendont.

### Notes
* The Wii and Wii U SD card slot is known to be slow. If you're using an SD card and are having performance issues, consider either using a USB SD reader or a USB hard drive.
* USB flash drives are known to be problematic.
* Nintendont runs best with storage devices formatted with 32 KB clusters. (Use either FAT32 or exFAT.)
24 changes: 14 additions & 10 deletions common/include/CommonConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "NintendontVersion.h"
#include "Metadata.h"

#define NIN_CFG_VERSION 0x00000008
#define NIN_CFG_VERSION 0x00000009

#define NIN_CFG_MAXPAD 4

Expand Down Expand Up @@ -46,18 +46,20 @@ enum ninconfigbitpos
NIN_CFG_BIT_REMLIMIT = (6), // New Versions
NIN_CFG_BIT_OSREPORT = (7),
NIN_CFG_BIT_LOG = (8),
NIN_CFG_BIT_LAST = (9),
NIN_CFG_BIT_LED = (9),
NIN_CFG_BIT_AUTO_BOOT = (10),
NIN_CFG_BIT_LAST = (11),

NIN_CFG_BIT_MC_MULTI = (9),
NIN_CFG_BIT_SKIP_IPL = (10),
NIN_CFG_BIT_NETWORK = (11),
NIN_CFG_BIT_SLIPPI_FILE_WRITE = (12),
NIN_CFG_BIT_SLIPPI_PORT_A = (13),
NIN_CFG_BIT_MC_MULTI = (11),
NIN_CFG_BIT_SKIP_IPL = (12),
NIN_CFG_BIT_NETWORK = (13),
NIN_CFG_BIT_SLIPPI_FILE_WRITE = (14),
NIN_CFG_BIT_SLIPPI_PORT_A = (15),

// "On" or "Off" Melee patches
NIN_CFG_BIT_MELEE_PAL = (14),
NIN_CFG_BIT_MELEE_QOL = (15),
NIN_CFG_BIT_MELEE_SPAWN = (16),
NIN_CFG_BIT_MELEE_PAL = (16),
NIN_CFG_BIT_MELEE_QOL = (17),
NIN_CFG_BIT_MELEE_SPAWN = (18),

// Internal kernel settings.
NIN_CFG_BIT_MC_SLOTB = (31), // Slot B image is loaded
Expand All @@ -74,6 +76,8 @@ enum ninconfig
NIN_CFG_REMLIMIT = (1<<NIN_CFG_BIT_REMLIMIT),
NIN_CFG_OSREPORT = (1<<NIN_CFG_BIT_OSREPORT),
NIN_CFG_LOG = (1<<NIN_CFG_BIT_LOG),
NIN_CFG_LED = (1<<NIN_CFG_BIT_LED),
NIN_CFG_AUTO_BOOT = (1<<NIN_CFG_BIT_AUTO_BOOT),

NIN_CFG_MC_MULTI = (1<<NIN_CFG_BIT_MC_MULTI),
NIN_CFG_SKIP_IPL = (1<<NIN_CFG_BIT_SKIP_IPL),
Expand Down
2 changes: 2 additions & 0 deletions common/include/CommonConfigStrings.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const char* OptionStrings[] =
"Unlock Read Speed",
"OSReport",
"Log",
"Drive Access LED",
"Auto Boot",

"Language",
"Video",
Expand Down
2 changes: 1 addition & 1 deletion common/include/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define __META_DATA_H__

#define META_NAME "Nintendont Slippi"
#define META_AUTHOR "FIX94, crediar, Fizzi, metaconstruct"
#define META_AUTHOR "FIX94, crediar, Fizzi, metaconstruct, jmlee337"

#define META_LONG1 "Commiters: GerbilSoft, JoostinOnline, GreyRogue, Howard, Cyan \r\n\r\n Project website: https://github.com/project-slippi/Nintendont "
#define META_LONG2 "Nintendont allows you to run GameCube games on a Wii or Wii U from an SD or HDD device."
Expand Down
107 changes: 6 additions & 101 deletions kernel/ISO.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,13 @@ typedef struct
u8 *Data;
} DataCache;

static u32 CacheInited = 0;
static u32 TempCacheCount = 0;
static u32 DataCacheOffset = 0;
static u8 *DCCache = CACHE_START;
static u32 DCacheLimit = CACHE_SIZE;
static DataCache DC[CACHE_MAX];

extern u32 USBReadTimer;
static FIL GameFile;
static u64 LastOffset64 = ~0ULL;
bool Datel = false;

// Used by kernel/Patch.c
char GAME_TITLENAME[0x100];
// char GAME_TITLENAME[0x100];

// CISO: On-disc structure.
// Temporarily loaded into cache memory.
Expand Down Expand Up @@ -355,10 +348,7 @@ bool ISOInit()
memcpy(&BI2region, isoTmpBuf, sizeof(BI2region));

// Save ISO game string; we use this to distinguish Melee images from 20XX images
ISOReadDirect(&GAME_TITLENAME, 0x100, 0x20 + ISOShift64);

/* Reset Cache */
CacheInited = 0;
// ISOReadDirect(&GAME_TITLENAME, 0x100, 0x20 + ISOShift64);

if ((read32(0) == 0x474E4845) && (read32(4) == 0x35640000))
{
Expand Down Expand Up @@ -390,47 +380,6 @@ void ISOClose()
ISO_IsCISO = false;
}

void ISOSetupCache()
{
if(ISOFileOpen == 0 || CacheInited)
return;

DCCache = CACHE_START;
DCacheLimit = CACHE_SIZE;
/* Setup Caching */
if(TRIGame)
{
//AMBB buffer is before cache
DCCache += 0x10000;
DCacheLimit -= 0x10000;
//triforce buffer is after cache
DCacheLimit -= 0x300000;
}
else
{
u32 MemCardSize = 0;
if (ConfigGetConfig(NIN_CFG_MEMCARDEMU))
{
// Get the total card size from GCNCard.c.
MemCardSize = GCNCard_GetTotalSize();
}
DCCache += MemCardSize; //memcard is before cache
DCacheLimit -= MemCardSize;

/* Avoid overlapping this cache with Slippi's memory region
* that we've stolen from the Triforce DIMM implementation.
* Leave 0x10000 bytes of padding between them. */
DCacheLimit -= 0x310000;
}
dbgprintf("DCCache: %X, DCacheLimit: %X\r\n", DCCache, DCacheLimit);
memset32(DC, 0, sizeof(DataCache)* CACHE_MAX);

DataCacheOffset = 0;
TempCacheCount = 0;

CacheInited = 1;
}

void ISOSeek(u32 Offset)
{
if(ISOFileOpen == 0)
Expand Down Expand Up @@ -469,54 +418,10 @@ void ISOSeek(u32 Offset)

const u8 *ISORead(u32* Length, u32 Offset)
{
if(CacheInited == 0)
{
if (*Length > DI_READ_BUFFER_LENGTH)
*Length = DI_READ_BUFFER_LENGTH;
ISOReadDirect(DI_READ_BUFFER, *Length, Offset);
return DI_READ_BUFFER;
}
u32 i;

for( i = 0; i < CACHE_MAX; ++i )
{
if(DC[i].Size == 0) continue;
if( Offset >= DC[i].Offset && Offset + *Length <= DC[i].Offset + DC[i].Size )
{
//dbgprintf("DI: Cached Read Offset:%08X Size:%08X Buffer:%p\r\n", DC[i].Offset, DC[i].Size, DC[i].Data );
return DC[i].Data + (Offset - DC[i].Offset);
}
}

u64 Offset64 = Offset + ISOShift64;
if( (Offset64 == LastOffset64) && (*Length < 0x8000) )
{ //pre-load data, guessing
u32 OriLength = *Length;
while((*Length += OriLength) < 0x10000) ;
}

// case we ran out of positions
if( TempCacheCount >= CACHE_MAX )
TempCacheCount = 0;

// case we filled up the cache
if( (DataCacheOffset + *Length) >= DCacheLimit )
if (*Length > DI_READ_BUFFER_LENGTH)
{
for( i = 0; i < CACHE_MAX; ++i )
DC[i].Size = 0; //quickly delete old cache content
DataCacheOffset = 0;
TempCacheCount = 0;
*Length = DI_READ_BUFFER_LENGTH;
}

u32 pos = TempCacheCount;
TempCacheCount++;

DC[pos].Data = DCCache + DataCacheOffset;
DC[pos].Offset = Offset;
DC[pos].Size = *Length;

ISOReadDirect(DC[pos].Data, *Length, Offset64);

DataCacheOffset += *Length;
return DC[pos].Data;
ISOReadDirect(DI_READ_BUFFER, *Length, Offset);
return DI_READ_BUFFER;
}
1 change: 0 additions & 1 deletion kernel/ISO.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ extern bool Datel;

bool ISOInit();
void ISOClose();
void ISOSetupCache();
const u8 *ISORead(u32* Length, u32 Offset);
void ISOSeek(u32 Offset);

Expand Down
7 changes: 2 additions & 5 deletions kernel/Patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ static const char GCT_HEADER[8] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0x
static const char GCT_FOOTER[8] = { 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };

// First 0x100 bytes of the ISO title string, filled out in kernel/ISO.c
extern char GAME_TITLENAME[0x100];
static const char TITLE_20XX[] = "Super Smash Bros Melee 20XX";
// extern char GAME_TITLENAME[0x100];
// static const char TITLE_20XX[] = "Super Smash Bros Melee 20XX";

#define MELEE_VERSION_NONE 0
#define MELEE_VERSION_NTSC_0 1
Expand Down Expand Up @@ -3978,9 +3978,6 @@ void PatchGame()
DoPatches( (void*)DOLMinOff, FullLength, 0 );
// Some games need special timings
EXISetTimings(TITLE_ID, GAME_ID & 0xFF);
// Init Cache if its a new ISO
if(TRIGame != TRI_SB)
ISOSetupCache();
// Reset SI status
SIInit();
u32 SiInitSet = 0;
Expand Down
7 changes: 7 additions & 0 deletions kernel/RealDI.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ void ClearRealDiscBuffer(void)
sync_after_write(DISC_DRIVE_BUFFER, DISC_DRIVE_BUFFER_LENGTH);
}

extern bool access_led;
extern u64 ISOShift64;
const u8 *ReadRealDisc(u32 *Length, u32 Offset, bool NeedSync)
{
Expand Down Expand Up @@ -210,6 +211,9 @@ const u8 *ReadRealDisc(u32 *Length, u32 Offset, bool NeedSync)
udelay(20);
}

//turn on drive led
if (access_led) set32(HW_GPIO_OUT, GPIO_SLOT_LED);

if (TmpLen > DISC_DRIVE_BUFFER_LENGTH - ReadDiff)
{
TmpLen = DISC_DRIVE_BUFFER_LENGTH - ReadDiff;
Expand Down Expand Up @@ -259,6 +263,9 @@ const u8 *ReadRealDisc(u32 *Length, u32 Offset, bool NeedSync)
udelay(70);
}

//turn off drive led
if (access_led) clear32(HW_GPIO_OUT, GPIO_SLOT_LED);

if(RealDiscCMD == DIP_CMD_DVDR)
{
u64 LastBlockStart = ((u64)(read32(DIP_CMD_2)) - 1) << 11;
Expand Down
Loading

0 comments on commit 0de54e7

Please sign in to comment.