Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions .github/workflows/samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
strategy:
fail-fast: false
matrix:
group: [basics, games, services]
group: [ipl, basics, games, services]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
Expand All @@ -95,7 +95,8 @@ jobs:
case "$SAMPLE_GROUP" in
basics) samples="HelloGameCube ManagedGameCube ShaderDemo VideoMode Pong GreenMen" ;;
games) samples="Fox Kart Snake DiscBrowser StorageIntegrity" ;;
services) samples="AsyncNetworking AudioDemo IplResources GoogleLogoAram HttpTexture HardwareDiagnostics" ;;
services) samples="AsyncNetworking AudioDemo GoogleLogoAram HttpTexture HardwareDiagnostics" ;;
ipl) samples="IplResources" ;;
*) echo "Unexpected sample group $SAMPLE_GROUP" >&2; exit 1 ;;
esac
mkdir -p "$RUNNER_TEMP/dnd-aot"
Expand All @@ -122,3 +123,29 @@ jobs:
*/bin/Release/net8.0/*.elf
if-no-files-found: error
retention-days: 14
- name: Stage IPL resource demo download
if: matrix.group == 'ipl'
shell: bash
run: |
mkdir -p "$RUNNER_TEMP/ipl-resources-dol"
cp IplResources/bin/Release/net8.0/IplResources.dol "$RUNNER_TEMP/ipl-resources-dol/IplResources-early-ipl.dol"
sha256sum "$RUNNER_TEMP/ipl-resources-dol/IplResources-early-ipl.dol"
- name: Build IPL hardware diagnostic from the published SDK
if: matrix.group == 'ipl'
run: python3 tools/ipl-diagnostics/build.py --output "${{ runner.temp }}/ipl-diagnostics"
- uses: actions/upload-artifact@v4
if: matrix.group == 'ipl'
with:
name: ipl-hardware-diagnostic
path: |
${{ runner.temp }}/ipl-diagnostics/IplDiagnostics-check01.dol
${{ runner.temp }}/ipl-diagnostics/build.json
if-no-files-found: error
retention-days: 14
- uses: actions/upload-artifact@v4
if: matrix.group == 'ipl'
with:
name: ipl-resources-dol
path: ${{ runner.temp }}/ipl-resources-dol/IplResources-early-ipl.dol
if-no-files-found: error
retention-days: 14
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<!-- Keep this in sync with global.json (MSBuild SDK version). -->
<DndPackageVersion>0.1.0-preview.333.1</DndPackageVersion>
<DndPackageVersion>0.1.0-preview.343.1</DndPackageVersion>
<!-- Shared native sample controls: Z toggles statistics; Start leaves result screens. -->
<DndSampleControls Condition="'$(DndSampleControls)' == ''">true</DndSampleControls>
</PropertyGroup>
Expand Down
6 changes: 6 additions & 0 deletions IplResources/IplResources.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@
<ItemGroup>
<PackageReference Include="DolphinDotNet.GameCube" Version="$(DndPackageVersion)" />
</ItemGroup>
<Target Name="GenerateIplBuildInfo" BeforeTargets="CoreCompile">
<WriteLinesToFile File="$(IntermediateOutputPath)IplBuildInfo.g.cs"
Lines="internal static class IplBuildInfo { internal const string SdkVersion = &quot;$(DndPackageVersion)&quot;%3B }"
Overwrite="true" WriteOnlyWhenDifferent="true" />
<ItemGroup><Compile Include="$(IntermediateOutputPath)IplBuildInfo.g.cs" /></ItemGroup>
</Target>
</Project>
2 changes: 1 addition & 1 deletion IplResources/IplSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal sealed class IplSelection
internal static readonly SystemMenuSound[] Effects={SystemMenuSound.TurnSide,SystemMenuSound.TurnCenter,SystemMenuSound.Select,SystemMenuSound.Back,SystemMenuSound.OptionCancel,SystemMenuSound.OptionConfirm,SystemMenuSound.OptionMove1,SystemMenuSound.OptionMove2,SystemMenuSound.OptionMove3,SystemMenuSound.OptionSelect};
internal static readonly SystemTexture[] Textures={SystemTexture.LogoTop,SystemTexture.LogoLeft,SystemTexture.LogoRight,SystemTexture.Environment,SystemTexture.Tiles,SystemTexture.Wordmark};
internal static readonly string[] TextureNames={"Logo top","Logo left","Logo right","Environment","Tiles","Wordmark"};
internal int Selected {get;private set;}=4;
internal int Selected {get;private set;}
internal int Texture {get;private set;}
internal void Move(int direction)=>Selected=(Selected+direction+Names.Length)%Names.Length;
internal void NextTexture()=>Texture=(Texture+1)%Textures.Length;
Expand Down
21 changes: 15 additions & 6 deletions IplResources/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ internal static IplAudioResources Prepare(CancellationToken cancellation)
using var image=SystemFirmware.ReadConsole(cancellation);
result.Catalog=image.CreateCatalog(FirmwareCatalogOptions.IncludeMenuAudio,cancellation);
if(image.Revision.Contains("Revision 1.2"))result.Revision=image.Revision.Contains("PAL")?"PAL 1.2":"NTSC 1.2";
else result.Revision="EARLY IPL";
for(int i=0;i<result.Sounds.Length;i++)
{
cancellation.ThrowIfCancellationRequested();
Expand All @@ -38,7 +39,7 @@ internal static IplAudioResources Prepare(CancellationToken cancellation)
{
var identity=IplSelection.Effects[i-1];
if(!result.Catalog.TryGetMenuSoundInfo(identity,out var info)||info==null)
{result.Status[i]="UNAVAILABLE";result.Details[i]="IPL profile unsupported";continue;}
{result.Status[i]="UNAVAILABLE";result.Details[i]="Menu profile unsupported";continue;}
// New metadata exposes original instrument IDs, distinct
// from the raw WSYS enumeration order.
string ids=info.SourceWaveCount==1?"Wave ID ":"Wave IDs ";
Expand All @@ -51,7 +52,7 @@ internal static IplAudioResources Prepare(CancellationToken cancellation)
var sound=result.Sounds[i]!;result.Status[i]="READY";
result.Details[i]=(sound.Channels==2?"Stereo":"Mono")+" / "+(sound.SampleRate/1000)+" kHz";
}
catch(NotSupportedException){result.Status[i]="UNAVAILABLE";result.Details[i]="IPL profile unsupported";}
catch(NotSupportedException){result.Status[i]="UNAVAILABLE";result.Details[i]=i==0?"Startup unsupported":"Menu profile unsupported";}
}
DebugOverlay.WriteLine("IPL AUDIO PREPARED "+result.Catalog.MenuAudioRetainedBytes);
return result;
Expand Down Expand Up @@ -86,9 +87,10 @@ private static async Task<int> Main()
Audio.Initialize();DebugOverlay.TextVisible=false;
using var draw=new Draw2D(GraphicsDevice.Default,new Draw2DOptions{Width=640,Height=480});
using var text=new IplText();using var cancellation=new CancellationTokenSource();
string buildLabel="SDK "+IplBuildInfo.SdkVersion+(text.Original?" / IPL font":" / sample font");
var selection=new IplSelection();var textures=new Texture2D?[IplSelection.Textures.Length];
Task<IplAudioResources>? loading=Task.Run(()=>IplAudioResources.Prepare(cancellation.Token));
IplAudioResources? resources=null;SoundChannel? voice=null;string state="LOADING IPL",detail="Reading console resources";
IplAudioResources? resources=null;SoundChannel? voice=null;string state="LOADING IPL",detail="Reading console resources",failureDetail="";
bool exit=false;int playing=-1;bool stickUp=false,stickDown=false;Exception? failure=null;
var rows=new string[IplSelection.Names.Length];var titles=new string[rows.Length];
for(int i=0;i<rows.Length;i++)
Expand Down Expand Up @@ -125,7 +127,12 @@ private static async Task<int> Main()
}
}
catch(OperationCanceledException){state="CANCELLED";}
catch(Exception error){state="IPL UNAVAILABLE";detail=Short(error.Message,27);}
catch(Exception error)
{
state="IPL UNAVAILABLE";detail=Short(error.Message,27);
failureDetail=error.Message.Length>27?Short(error.Message.Substring(27),27):"";
DebugOverlay.WriteLine("IPL LOAD FAILED "+error.Message);
}
loading=null;
}
if(exit&&loading==null)break;
Expand All @@ -147,8 +154,8 @@ private static async Task<int> Main()
}
int selected=selection.Selected;var texture=textures[selection.Texture];
var device=GraphicsDevice.Default;device.BeginFrame(Background);draw.Begin();
text.Draw(draw,"IPL RESOURCES",24,24,25,Color32.White);
text.Draw(draw,text.Original?"Original system font, textures and audio":"System textures and audio - sample font",24,61,12,Muted);
text.Draw(draw,"IPL RESOURCES B03",24,24,25,Color32.White);
text.Draw(draw,buildLabel,24,61,12,Muted);
draw.DrawRectangle(new RectF(465,22,151,29),Muted);
text.Draw(draw,resources?.Revision??"CONSOLE IPL",475,30,12,Muted);
draw.DrawRectangle(new RectF(24,98,290,286),Muted);
Expand Down Expand Up @@ -177,6 +184,8 @@ private static async Task<int> Main()
text.Draw(draw,resources==null?detail:resources.Details[selected],348,328,12,Muted);
if(resources!=null&&resources.Sources[selected]!=null)
text.Draw(draw,resources.Sources[selected],348,347,10,Muted);
else if(resources==null&&failureDetail.Length!=0)
text.Draw(draw,failureDetail,348,347,12,Muted);
text.Draw(draw,"A PLAY",348,367,11,Color32.White);
draw.DrawLine(new Vector2(24,414),new Vector2(616,414),Muted);
text.Draw(draw,"UP DOWN SELECT A PLAY B STOP X TEXTURE START EXIT",24,436,10,Color32.White);
Expand Down
30 changes: 27 additions & 3 deletions IplResources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,27 @@ authored notes and tails. The three movement identities map to
`OptionMove1`, `OptionMove2` and `OptionMove3` respectively.

`SystemFirmware.ReadConsole` reads the configured console ROM through EXI.
On a real GameCube, that ROM is built in: no IPL file needs to be installed.
Build B03 consumes public NuGet SDK/runtime `0.1.0-preview.343.1`, published
after [SDK PR #180](https://github.com/capz/DolphinDotNet/pull/180).
The SDK uses continuous DMA for each 1 KiB ROM page, following libogc's ROM
transfer method. The demo shows the actual published SDK version below the title,
starts with Startup selected, and displays load errors across two lines.
The [hardware diagnostic](../tools/ipl-diagnostics/README.md) found identical
ROM bytes through all five read methods on the reporting PAL console with
GC Loader / CubiBoot: CRC-32 `6DAC1F2A`, matching the early NTSC 1.0 reference.
The console's region alone therefore does not select its resource profile.
The user confirmed Startup and textures working on that console with B02 /
SDK 339. B03 adds the early firmware's ten menu effects through the existing
SDK APIs; no sample-side mapping or replacement audio is needed.
In Dolphin, configure an appropriate original IPL in its regional `GC` user
directory. The app does not download firmware or probe storage for `ipl.bin`.
The menu profile supports NTSC 1.2 and PAL 1.2; other firmware can report
individual resources unavailable. Without an IPL the app shows the failure and
The menu profiles support early NTSC 1.0, NTSC 1.2 and PAL 1.2. The early
profile has its own velocity, envelope clock, effects-send settings and
three-second delay tail. Unknown menu profiles say `Menu profile unsupported`;
this is separate from an `IPL unavailable` acquisition failure.
Other firmware can report individual
resources unavailable. Without an IPL the app shows the failure and
retains the sample font. No firmware, original textures, samples or recordings
are bundled, and no generated tone substitutes for an unavailable effect.

Expand All @@ -43,7 +60,14 @@ The SDK's [API guide](https://github.com/capz/DolphinDotNet/blob/main/docs/syste
and [audio qualification report](https://github.com/capz/DolphinDotNet/blob/main/docs/system-menu-audio-research.md)
describe the supported profiles, preparation budgets and measured output
differences. Menu rendering is deterministic; bit-identical IPL DSP output and
physical-console playback have not been established.
physical-console playback of the ten newly enabled early effects have not
been established. Overlapping short effects can differ in level from the
running IPL because they start at a deterministic sequence phase.

The `ipl-resources-dol` CI artifact contains `IplResources-early-ipl.dol`.
Its dedicated native build group makes this download available while the
other sample builds finish. Confirm `IPL RESOURCES B03` and SDK
`0.1.0-preview.343.1` on screen when testing it.

```sh
dotnet build IplResources/IplResources.sln -c Release
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DolphinDotNet Samples

Run commands from the repository root. These are independent NuGet consumers of [`DolphinDotNet.Sdk`](https://www.nuget.org/packages/DolphinDotNet.Sdk/) and [`DolphinDotNet.GameCube`](https://www.nuget.org/packages/DolphinDotNet.GameCube/). Both are pinned to preview `0.1.0-preview.333.1` in `global.json` and `Directory.Build.props`; the `DolphinDotNet.Core` dependency is resolved transitively. No checkout of the compiler/runtime repository is required. All examples target .NET 8 for compilation;
Run commands from the repository root. These are independent NuGet consumers of [`DolphinDotNet.Sdk`](https://www.nuget.org/packages/DolphinDotNet.Sdk/) and [`DolphinDotNet.GameCube`](https://www.nuget.org/packages/DolphinDotNet.GameCube/). Both are pinned to preview `0.1.0-preview.343.1` in `global.json` and `Directory.Build.props`; the `DolphinDotNet.Core` dependency is resolved transitively. No checkout of the compiler/runtime repository is required. All examples target .NET 8 for compilation;
the GameCube runs generated native code, using only the supported AOT API subset.

| Sample | Demonstrates | Setup / result |
Expand Down
4 changes: 2 additions & 2 deletions ci/validate_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import xml.etree.ElementTree as ET

ROOT = pathlib.Path(__file__).resolve().parents[1]
VERSION = "0.1.0-preview.333.1"
VERSION = "0.1.0-preview.343.1"
sdk = json.loads((ROOT / "global.json").read_text())["msbuild-sdks"]["DolphinDotNet.Sdk"]
props = ET.parse(ROOT / "Directory.Build.props").getroot()
version = props.find(".//DndPackageVersion").text
Expand All @@ -29,7 +29,7 @@
assert not re.search(r"\.\.\\\.\.\\src\\", source), str(sln)
# The required native matrix must explicitly cover all migrated applications.
workflow = (ROOT / ".github/workflows/samples.yml").read_text()
for group in ("basics", "games", "services"):
for group in ("basics", "games", "services", "ipl"):
assert group in workflow, group
for name in sorted(path.stem for path in projects):
assert name in workflow, f"{name} missing from packaged AOT build matrix"
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"msbuild-sdks": {
"DolphinDotNet.Sdk": "0.1.0-preview.333.1"
"DolphinDotNet.Sdk": "0.1.0-preview.343.1"
}
}
2 changes: 1 addition & 1 deletion tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
it includes Common/*.cs in every game, while host tests compile only
targeted sample sources and sometimes supply fake platform dependencies. -->
<PropertyGroup>
<DndPackageVersion>0.1.0-preview.333.1</DndPackageVersion>
<DndPackageVersion>0.1.0-preview.343.1</DndPackageVersion>
</PropertyGroup>
</Project>
9 changes: 9 additions & 0 deletions tools/ipl-diagnostics/IplDiagnostics.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="DolphinDotNet.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DolphinDotNet.GameCube" Version="$(DndPackageVersion)" />
</ItemGroup>
</Project>
21 changes: 21 additions & 0 deletions tools/ipl-diagnostics/LICENSE.cipher.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 supertazon

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
40 changes: 40 additions & 0 deletions tools/ipl-diagnostics/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using Dolphin.Diagnostics;
using Dolphin.System;

// Run the published managed cipher on the actual PowerPC target, independently
// of EXI and Dolphin's already-decoded ROM. Only generated data is used here.
internal static class Program
{
private static int Main()
{
DebugOverlay.WriteLine("IPL CHECK 01 - CHECKING PUBLISHED SDK CIPHER");
var bytes=new byte[FirmwareImage.ImageBytes];
FirmwareImage.Transform(bytes);
uint hash=2166136261;
for(int i=0;i<bytes.Length;i++)hash=unchecked((hash^bytes[i])*16777619);
// Full-image FNV-1a of the independently generated IPL keystream.
if(hash!=0x35795a57u)return 1;
FirmwareImage.Transform(bytes);
for(int i=0;i<bytes.Length;i++)if(bytes[i]!=0)return 2;

const string header="Nintendo GameCube IPL synthetic";
for(int i=0;i<header.Length;i++)bytes[i]=(byte)header[i];
for(int at=4096;at<=8192;at+=4096)
{
// Two separate literal-only, four-byte Yay0 records.
bytes[at]=89;bytes[at+1]=97;bytes[at+2]=121;bytes[at+3]=48;
bytes[at+7]=4;bytes[at+11]=20;bytes[at+15]=20;
bytes[at+16]=240;
for(int i=0;i<4;i++)bytes[at+20+i]=(byte)(65+i);
}
FirmwareImage.Transform(bytes);
using(var image=FirmwareImage.Read(bytes))
using(var catalog=image.CreateCatalog())
{
if(image.Encoding!=FirmwareEncoding.Scrambled||catalog.Count!=2||catalog.Extract(0)[0]!=65)return 3;
}
DebugOverlay.WriteLine("IPL SDK CIPHER AND SCRAMBLED CATALOG PASS");
return 0;
}
}
Loading
Loading