diff --git a/.github/workflows/samples.yml b/.github/workflows/samples.yml index 7f265f0..dbf30ad 100644 --- a/.github/workflows/samples.yml +++ b/.github/workflows/samples.yml @@ -128,8 +128,8 @@ jobs: 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" + cp IplResources/bin/Release/net8.0/IplResources.dol "$RUNNER_TEMP/ipl-resources-dol/IplResources.dol" + sha256sum "$RUNNER_TEMP/ipl-resources-dol/IplResources.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" @@ -146,6 +146,6 @@ jobs: if: matrix.group == 'ipl' with: name: ipl-resources-dol - path: ${{ runner.temp }}/ipl-resources-dol/IplResources-early-ipl.dol + path: ${{ runner.temp }}/ipl-resources-dol/IplResources.dol if-no-files-found: error retention-days: 14 diff --git a/Directory.Build.props b/Directory.Build.props index d57e84f..56d681b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 0.1.0-preview.349.1 + 0.1.0-preview.361.1 true diff --git a/IplResources/Design/approved-complete-audio.png b/IplResources/Design/approved-complete-audio.png new file mode 100644 index 0000000..fda63ea Binary files /dev/null and b/IplResources/Design/approved-complete-audio.png differ diff --git a/IplResources/IplAudioResources.cs b/IplResources/IplAudioResources.cs new file mode 100644 index 0000000..ae5c49a --- /dev/null +++ b/IplResources/IplAudioResources.cs @@ -0,0 +1,103 @@ +using System; +using System.Threading; +using Dolphin.Audio; +using Dolphin.Diagnostics; +using Dolphin.System; + +internal sealed class IplAudioResources : IDisposable +{ + internal FirmwareCatalog? Catalog; + internal SystemAudioSession? Session; + internal SystemAudioCueInfo[] Cues=new SystemAudioCueInfo[0]; + internal string AudioFailure=""; + internal readonly Sound?[] Sounds=new Sound?[13]; + internal readonly string[] Status=new string[13],Details=new string[13]; + internal readonly string[] Sources=new string[13]; + internal FirmwareAudioSampleInfo[] Samples=new FirmwareAudioSampleInfo[0]; + internal string[] SampleNames=new string[0],SampleDetails=new string[0],SampleStatus=new string[0]; + internal string Revision="CONSOLE IPL"; + internal static IplAudioResources Prepare(CancellationToken cancellation) + { + var result=new IplAudioResources(); + try + { + // Reads the configured console/emulator ROM through EXI. No file + // probes, embedded Nintendo assets, synthetic sound or WAV fallback. + using var image=SystemFirmware.ReadConsole(cancellation); + result.Catalog=image.CreateCatalog(FirmwareCatalogOptions.IncludeSystemAudio,cancellation); + if(result.Catalog.SupportsAudioSession) + { + try {result.Session=SystemResources.CreateAudioSession(result.Catalog,cancellation);result.Cues=result.Catalog.GetAudioCues();} + catch(OperationCanceledException){throw;} + catch(Exception error){result.AudioFailure=error.Message;DebugOverlay.WriteLine("IPL SESSION FAILED "+error.Message);} + } + if(result.Session!=null) + { + result.Samples=new FirmwareAudioSampleInfo[result.Session.SampleCount]; + // PlaySample accepts descriptors owned by this prepared session. + for(int i=0;iresources.Session; + private SystemAudioPlayback? playback; + private SoundChannel? voice; + private SystemAudioSample? sample; + private Task? pending; + private int sampleIndex=-1,pendingIndex=-1; + private bool autoplay,startup; + private int motion=-1; + private long motionStart,warmStart,nextStats; + internal int PlayingCategory {get;private set;}=-1; + internal int PlayingIndex {get;private set;}=-1; + internal bool AmbienceEnabled {get;private set;} + internal bool Warming=>AmbienceEnabled&&!startup&&Clock.Timestamp-warmStart<5000000; + internal bool Pending=>pending!=null; + internal string Error {get;private set;}=""; + internal SystemAudioStatistics? Statistics {get;private set;} + internal IplPlayback(IplAudioResources resources,CancellationToken cancellation) + {this.resources=resources;this.cancellation=cancellation;} + private void ClearAudition() + { + playback?.Dispose();playback=null;voice?.Dispose();voice=null;autoplay=false; + PlayingCategory=-1;PlayingIndex=-1; + if(motion>=0&&Session!=null&&Session.State==SystemAudioSessionState.Playing) + { + Session.SetControl(SystemAudioControl.CubeMotion,0); + Session.SetControl(SystemAudioControl.SubmenuMotion,0); + } + motion=-1; + } + internal void Stop() + { + ClearAudition();Session?.Stop();startup=false;AmbienceEnabled=false;Error=""; + DebugOverlay.WriteLine("IPL STOP"); + } + private void StartIdle() + { + if(startup){Session!.Stop();startup=false;} + bool stopped=Session!.State==SystemAudioSessionState.Stopped; + Session.Start();Session.SetControl(SystemAudioControl.AmbienceEnabled,AmbienceEnabled?1:0); + if(stopped)warmStart=Clock.Timestamp; + } + internal void Play(int category,int index) + { + if(pending!=null)return; + Error="";ClearAudition(); + try + { + if(Session!=null) + { + if(category==0) + { + Session.PlayStartup((SystemStartupSoundVariant)index); + startup=true;AmbienceEnabled=true; + } + else if(category==3) + { + AmbienceEnabled=true;StartIdle(); + if(index==1||index==2){motion=index-1;motionStart=Clock.Timestamp;} + else if(index>=3)Session.OutputMode=index==3?SystemAudioOutputMode.Stereo:SystemAudioOutputMode.Mono; + } + else + { + StartIdle(); + playback=category==4?Session.PlaySample(resources.Samples[index]): + Session.PlayCue((SystemAudioCue)(category==1?index:index+12)); + } + PlayingCategory=category;PlayingIndex=index; + } + else if(category==4) + { + if(sample!=null&&sampleIndex==index) + {voice=sample.Play();PlayingCategory=4;PlayingIndex=index;} + else + { + sample?.Dispose();sample=null;sampleIndex=-1;pendingIndex=index;autoplay=true; + pending=SystemResources.CreateAudioSampleAsync(resources.Catalog!,resources.Samples[index],cancellation); + } + } + else if(category<2) + { + int sound=category==0?index:index+3; + if(resources.Sounds[sound]!=null) + {voice=resources.Sounds[sound]!.Play();PlayingCategory=category;PlayingIndex=index;} + } + DebugOverlay.WriteLine("IPL PLAY "+category+"/"+index); + } + catch(Exception error){Error=error.Message;DebugOverlay.WriteLine("IPL PLAY FAILED "+error.Message);} + } + internal void ToggleAmbience() + { + if(Session==null)return; + try + { + Error="";AmbienceEnabled=!AmbienceEnabled; + if(!startup) + { + bool stopped=Session.State==SystemAudioSessionState.Stopped; + Session.SetControl(SystemAudioControl.AmbienceEnabled,AmbienceEnabled?1:0); + if(stopped||AmbienceEnabled)warmStart=Clock.Timestamp; + } + DebugOverlay.WriteLine(AmbienceEnabled?"IPL AMBIENCE ON":"IPL AMBIENCE OFF"); + } + catch(Exception error){Error=error.Message;DebugOverlay.WriteLine("IPL CONTROL FAILED "+error.Message);} + } + internal void Update(bool exiting) + { + if(pending!=null&&pending.IsCompleted) + { + try + { + var prepared=pending.GetAwaiter().GetResult(); + if(exiting)prepared.Dispose(); + else + { + sample=prepared;sampleIndex=pendingIndex; + if(autoplay){voice=sample.Play();PlayingCategory=4;PlayingIndex=sampleIndex;} + } + } + catch(OperationCanceledException){} + catch(Exception error){Error=error.Message;resources.SampleStatus[pendingIndex]="UNAVAILABLE";} + pending=null;pendingIndex=-1;autoplay=false; + } + if(exiting)return; + if(voice!=null&&!voice.IsPlaying||playback!=null&&!playback.IsPlaying) + { + DebugOverlay.WriteLine("IPL ENDED "+PlayingCategory+"/"+PlayingIndex); + voice?.Dispose();voice=null;playback?.Dispose();playback=null;PlayingCategory=-1;PlayingIndex=-1; + } + if(Session==null)return; + long now=Clock.Timestamp; + if(Session.State==SystemAudioSessionState.Faulted){Error="Audio fault - restart demo";motion=-1;startup=false;} + else + { + if(startup&&!Session.IsStartupPlaying) + { + startup=false;warmStart=now;PlayingCategory=-1;PlayingIndex=-1; + Session.SetControl(SystemAudioControl.AmbienceEnabled,AmbienceEnabled?1:0); + DebugOverlay.WriteLine("IPL STARTUP HANDOVER"); + } + if(motion>=0) + { + // Animate the verified original motion control, not audio loops. + float phase=(float)((now-motionStart)%4000000)/2000000; + Session.SetControl(motion==0?SystemAudioControl.CubeMotion:SystemAudioControl.SubmenuMotion,phase<=1?phase:2-phase); + } + } + if(now>=nextStats){Statistics=Session.GetStatistics();nextStats=now+250000;} + } + internal string Status(int category,int index) + { + if(Error.Length!=0)return "PLAYBACK FAILED"; + if(Session!=null) + { + if(Session.State==SystemAudioSessionState.Faulted)return "AUDIO FAULT"; + if(category==3&&AmbienceEnabled)return Warming?"STARTING AMBIENCE":"PLAYING"; + return PlayingCategory==category&&PlayingIndex==index?"PLAYING":"READY"; + } + if(category==4)return pendingIndex==index?"PREPARING":PlayingCategory==4&&PlayingIndex==index?"PLAYING":resources.SampleStatus[index]; + return PlayingCategory==category&&PlayingIndex==index?"PLAYING":resources.Status[category==0?index:index+3]; + } + internal string Details(int category,int index) + { + if(Error.Length!=0)return Error; + if(category==4)return resources.SampleDetails[index]; + if(Session==null)return resources.Details[category==0?index:index+3]; + if(category==0)return "Original stereo startup score"; + if(category==3)return Session.OutputMode==SystemAudioOutputMode.Mono?"Original ambience / mono":"Original ambience / stereo"; + return "Original sequenced cue"; + } + internal string Repeat(int category,int index) + { + if(category==4)return resources.Samples[index].HasLoop?"LOOPS AUTOMATICALLY":"PLAYS ONCE"; + if(Session==null)return resources.Sources[category==0?index:index+3]??""; + if(category==0)return "THEN IDLE AMBIENCE"; + if(category==3)return AmbienceEnabled?"CONTINUOUS / Y TO MUTE":"Y TO ENABLE AMBIENCE"; + var cue=(SystemAudioCue)(category==1?index:index+12); + foreach(var info in resources.Cues)if(info.Cue==cue)return info.RepeatsUntilStopped?"REPEATS UNTIL STOPPED":"PLAYS ONCE"; + return "UNAVAILABLE"; + } + internal async Task CloseAsync() + { + if(pending!=null){try{(await pending).Dispose();}catch(Exception){}pending=null;} + Stop();sample?.Dispose();sample=null; + } +} diff --git a/IplResources/IplSelection.cs b/IplResources/IplSelection.cs index 087e7a5..a4bdfe9 100644 --- a/IplResources/IplSelection.cs +++ b/IplResources/IplSelection.cs @@ -3,12 +3,38 @@ // Pure navigation shared with host tests; resource creation stays in Program. internal sealed class IplSelection { - internal static readonly string[] Names={"Startup","Turn side","Turn center","Enter menu","Back","Cancel edit","Confirm edit","Change value","Change field","Change row","Open editor"}; + internal static readonly string[] Categories={"STARTUP","MENU","CARDS","AMBIENCE","SAMPLES"}; + internal const int VisibleRows=6; + internal static readonly string[] Names={"Normal","One controller Z","Four controller Z","Turn side","Turn center","Enter menu","Back","Cancel edit","Confirm edit","Change value","Change field","Change row","Open editor"}; + internal static readonly string[] CardNames={"Erase / move done","Copy / format done","Transfer from A","Transfer from B","Copy transfer done","Move to B done","Move to A done"}; + internal static readonly string[] AmbienceNames={"Idle ambience","Cube motion","Submenu motion","Stereo output","Mono output"}; + internal static string GetName(int category,int index) + { + if(category==0)return Names[index]; + if(category==1)return index<10?Names[index+3]:index==10?"Press Start":"Error"; + if(category==2)return CardNames[index]; + if(category==3)return AmbienceNames[index]; + throw new System.ArgumentOutOfRangeException(nameof(category)); + } 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;} + private readonly int[] selected=new int[5]; + private readonly int[] counts={3,10,0,0,0}; + internal int Category {get;private set;} + internal int Selected=>selected[Category]; + internal int Count=>counts[Category]; + internal int FirstVisible=>Selected/VisibleRows*VisibleRows; internal int Texture {get;private set;} - internal void Move(int direction)=>Selected=(Selected+direction+Names.Length)%Names.Length; + internal void SetCompleteAudio(bool supported) + { + counts[1]=supported?12:10;counts[2]=supported?CardNames.Length:0;counts[3]=supported?AmbienceNames.Length:0; + for(int i=1;i<=3;i++)if(selected[i]>=counts[i])selected[i]=0; + } + internal void SetSampleCount(int count) + {counts[4]=count;if(selected[4]>=count)selected[4]=0;} + internal void Move(int direction) + {int count=Count;if(count>0)selected[Category]=(Selected+direction+count)%count;} + internal void NextCategory(int direction)=>Category=(Category+direction+Categories.Length)%Categories.Length; internal void NextTexture()=>Texture=(Texture+1)%Textures.Length; } diff --git a/IplResources/IplText.cs b/IplResources/IplText.cs new file mode 100644 index 0000000..4774d9b --- /dev/null +++ b/IplResources/IplText.cs @@ -0,0 +1,19 @@ +using System; +using Dolphin.Graphics; +using Dolphin.System; + +internal sealed class IplText : IDisposable +{ + private readonly SampleText fallback=new SampleText(); + private readonly SystemFont? font; + internal bool Original=>font!=null; + internal IplText() + {try{font=SystemFont.Load();}catch(NotSupportedException){}catch(InvalidOperationException){}} + internal void Draw(Draw2D draw,string value,float x,float y,float height,Color32 color) + { + if(font!=null)font.Draw(draw,value,new Vector2(x,y),color,height/font.CellHeight); + else fallback.Draw(draw,value,x,y,height/5,color); + } + public void Dispose(){font?.Dispose();fallback.Dispose();} +} + diff --git a/IplResources/Program.cs b/IplResources/Program.cs index c5d04da..72844d2 100644 --- a/IplResources/Program.cs +++ b/IplResources/Program.cs @@ -7,80 +7,10 @@ using Dolphin.Input; using Dolphin.System; -internal sealed class IplAudioResources : IDisposable -{ - internal FirmwareCatalog? Catalog; - internal readonly Sound?[] Sounds=new Sound?[11]; - internal readonly string[] Status=new string[11],Details=new string[11]; - internal readonly string[] Sources=new string[11]; - internal string Revision="CONSOLE IPL"; - internal static IplAudioResources Prepare(CancellationToken cancellation) - { - var result=new IplAudioResources(); - try - { - // Reads the configured console/emulator ROM through EXI. No file - // probes, embedded Nintendo assets, synthetic sound or WAV fallback. - 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;ifont!=null; - internal IplText() - {try{font=SystemFont.Load();}catch(NotSupportedException){}catch(InvalidOperationException){}} - internal void Draw(Draw2D draw,string value,float x,float y,float height,Color32 color) - { - if(font!=null)font.Draw(draw,value,new Vector2(x,y),color,height/font.CellHeight); - else fallback.Draw(draw,value,x,y,height/5,color); - } - public void Dispose(){font?.Dispose();fallback.Dispose();} -} - internal static class Program { private static readonly Color32 Background=new Color32(18,25,40),Muted=new Color32(155,174,203),Accent=new Color32(174,145,245); + private static readonly float[] TabX={34,99,144,194,261},TabWidth={62,42,47,64,49}; private static string Short(string value,int limit)=>value.Length>limit?value.Substring(0,limit):value; private static async Task Main() { @@ -90,11 +20,10 @@ private static async Task Main() string buildLabel="SDK "+IplBuildInfo.SdkVersion+(text.Original?" / IPL font":" / sample font"); var selection=new IplSelection();var textures=new Texture2D?[IplSelection.Textures.Length]; Task? loading=Task.Run(()=>IplAudioResources.Prepare(cancellation.Token)); - 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 Main() try { resources=loading.GetAwaiter().GetResult(); - try + selection.SetSampleCount(resources.Samples.Length); + selection.SetCompleteAudio(resources.Session!=null); + if(!exit) { - if(!exit) + // Publish graphics between frames on the app executor. + for(int i=0;i27?Short(error.Message.Substring(27),27):""; + state="IPL UNAVAILABLE";detail=Short(error.Message,29); + failureDetail=error.Message.Length>29?Short(error.Message.Substring(29),29):""; DebugOverlay.WriteLine("IPL LOAD FAILED "+error.Message); } loading=null; } - if(exit&&loading==null)break; + player?.Update(exit); + if(exit&&loading==null&&(player==null||!player.Pending))break; if(!exit) { bool up=pad.Stick.Y>.55f,down=pad.Stick.Y<-.55f; if(pad.DPadUp.WasPressed||up&&!stickUp)selection.Move(-1); if(pad.DPadDown.WasPressed||down&&!stickDown)selection.Move(1); stickUp=up;stickDown=down; - if(pad.X.WasPressed)selection.NextTexture(); - if(voice!=null&&!voice.IsPlaying){voice.Dispose();voice=null;playing=-1;} - if(pad.B.WasPressed){voice?.Dispose();voice=null;playing=-1;} - if(pad.A.WasPressed&&resources!=null&&resources.Sounds[selection.Selected]!=null) - { - voice?.Dispose();voice=null;playing=-1; - try{voice=resources.Sounds[selection.Selected]!.Play();playing=selection.Selected;} - catch(Exception error){resources.Status[selection.Selected]="PLAYBACK FAILED";resources.Details[selection.Selected]=Short(error.Message,27);} - } + if(pad.L.WasPressed)selection.NextCategory(-1); + if(pad.R.WasPressed)selection.NextCategory(1); + if(pad.X.WasPressed){selection.NextTexture();DebugOverlay.WriteLine("IPL TEXTURE "+selection.Texture);} + if(pad.Z.WasPressed)showStats=!showStats; + if(pad.B.WasPressed)player?.Stop(); + if(pad.Y.WasPressed)player?.ToggleAmbience(); + if(pad.A.WasPressed&&selection.Count>0)player?.Play(selection.Category,selection.Selected); + } + if(player?.Statistics!=null&&!ReferenceEquals(lastStats,player.Statistics)) + { + lastStats=player.Statistics; + statsLine=(lastStats.NativeBytes/1024)+" KB / "+lastStats.ActiveVoices+" voices"; + healthLine="Queue "+lastStats.BufferedFrames+" / drops "+lastStats.Underruns+" / fault "+lastStats.FaultCode; } int selected=selection.Selected;var texture=textures[selection.Texture]; var device=GraphicsDevice.Default;device.BeginFrame(Background);draw.Begin(); - text.Draw(draw,"IPL RESOURCES B03",24,24,25,Color32.White); + text.Draw(draw,"IPL RESOURCES B05",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); - for(int i=0;i Main() text.Draw(draw,IplSelection.TextureNames[selection.Texture],469,151,11,Muted); text.Draw(draw,"X NEXT TEXTURE",469,203,9,Color32.White); draw.DrawRectangle(new RectF(332,256,284,128),Muted); - text.Draw(draw,titles[selected],348,269,19,Color32.White); - string ready=resources==null?state:playing==selected?"PLAYING":resources.Status[selected]; + bool available=selection.Count>0; + string title=selection.Category==4?"SOURCE SAMPLE":available?IplSelection.GetName(selection.Category,selected).ToUpperInvariant():IplSelection.Categories[selection.Category]; + text.Draw(draw,Short(title,24),348,269,19,Color32.White); + string ready=player==null?state:!available?"UNAVAILABLE":player.Status(selection.Category,selected); draw.FillRectangle(new RectF(349,305,7,7),ready=="READY"||ready=="PLAYING"?new Color32(104,210,110):Muted); text.Draw(draw,ready,365,301,12,Muted); - 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); + string info=player==null?detail:!available?"":player.Details(selection.Category,selected); + string repeat=player==null?failureDetail:!available?"":player.Repeat(selection.Category,selected); + text.Draw(draw,Short(showStats&&lastStats!=null?statsLine:info,31),348,328,12,Muted); + text.Draw(draw,Short(showStats&&lastStats!=null?healthLine:repeat,35),348,347,10,Color32.White); + text.Draw(draw,"A PLAY / RESTART B STOP",348,367,10,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); + text.Draw(draw,"UP DOWN SELECT L R CATEGORY A PLAY B STOP",24,429,10,Color32.White); + text.Draw(draw,"X TEXTURE Y AMBIENCE Z STATS START EXIT",24,450,10,Color32.White); draw.End();device.EndFrame();await Task.Delay(1); } } catch(Exception error){failure=error;} - // Keep awaited cancellation outside finally, as in AudioDemo: the - // GameCube AOT subset does not implement ExceptionDispatchInfo. + // Await cancellation outside finally: the target AOT subset does not + // implement ExceptionDispatchInfo. Dispose playback before its session. cancellation.Cancel(); if(loading!=null){try{(await loading).Dispose();}catch(Exception){}} - voice?.Dispose();resources?.Dispose();foreach(var texture in textures)texture?.Dispose(); + if(player!=null)await player.CloseAsync(); + resources?.Dispose();foreach(var texture in textures)texture?.Dispose(); + DebugOverlay.WriteLine("IPL DEMO DISPOSED"); if(failure!=null)throw failure; return 0; } diff --git a/IplResources/README.md b/IplResources/README.md index 6a9e124..1f65bb5 100644 --- a/IplResources/README.md +++ b/IplResources/README.md @@ -1,80 +1,74 @@ # IPL resource explorer -Run a single demo of the console's original font, six firmware textures, the -startup sound and ten complete menu effects. It uses the published -`DolphinDotNet.GameCube` NuGet package through `DolphinDotNet.Sdk`; no SDK source -checkout is needed. +Build B05 consumes the published SDK/runtime `0.1.0-preview.361.1`. It explores +the console's original font, six textures, all three startup score paths, +twelve menu/error cues, seven card cues, continuous ambience and twelve source +samples. No SDK source checkout or private package feed is required. -- Up/down on the main stick or D-pad selects a sound. -- A plays the selection; B stops the current voice. +- L/R switches categories; Up/down selects an entry in the scrolling list. +- A plays or restarts the selection; B stops all session playback. - X cycles Logo top/left/right, Environment, Tiles and Wordmark textures. -- Start cancels loading and exits; Z toggles the shared statistics panel. +- Y enables or mutes ambience. Z shows native memory, voices, queue and health + alongside the shared SDK statistics. Start cancels loading and exits. -The list includes the existing Turn side, Turn center and Enter menu sounds, -plus Back, Cancel edit, Confirm edit, Change value, Change field, Change row and -Open editor. Each selection plays the complete prepared effect, including its -authored notes and tails. The three movement identities map to -`OptionMove1`, `OptionMove2` and `OptionMove3` respectively. +Startup contains Normal, One controller Z and Four controller Z. Each plays the +original score and automatically hands over to idle ambience. Y can disable +that handover's ambience without interrupting the startup. Ambience has the +original lead-in of about four seconds; `STARTING AMBIENCE` reports this delay. -`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 introduced public NuGet SDK/runtime `0.1.0-preview.343.1`, published -after [SDK PR #180](https://github.com/capz/DolphinDotNet/pull/180). The repository -now consumes `0.1.0-preview.349.1`. -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 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. +Menu contains the ten existing actions plus Press Start and Error. Cards adds +erase/move completion, copy/format completion, repeating transfer from A/B, +copy-transfer completion and move-to-A/B completion. A replaces the previous +audition; the two progress cues repeat until B or the next audition. These are +audio auditions: the demo performs no memory-card operations. -Audio preparation runs on `Task.Run` while the screen remains responsive. -`CreateMenuSound` produces ordinary caller-owned `Sound` resources; -`TryGetMenuSoundInfo`, `SourceWaveCount` and `GetSourceWaveId` report the prepared -effect and original instrument IDs, shown in the selected sound's panel and -debug log. These IDs differ from flat WSYS indices. -Textures and the `SystemFont` are published on the graphics executor between -frames. The input image and catalog are disposed before interactive playback; -each texture and sound owns its data. The demo retains eleven clips, below the -sixteen-slot audio limit, and one playback channel at a time. +Ambience exposes idle ambience, animated cube/submenu motion and session-local +stereo/mono output. Samples shows each original wave ID, codec/rate and read-only +repeat status. The three looping sources play their intro and then repeat their +authored section automatically. Neither the app nor its caller supplies loop +flags, endpoints or a repeat scheduler. -Start cancels pending preparation. Failure and partial loading dispose prepared -sounds, and shutdown disposes the voice before sounds, textures and fonts. -Continuous IPL ambience and alternate startup variants are not represented by -the finite menu-effect list. +`SystemFirmware.ReadConsole` reads the built-in ROM through EXI on a GameCube. +No IPL file needs to be installed on a console. In Dolphin, configure an original +IPL in its regional `GC` user directory. The app does not download firmware or +probe storage for `ipl.bin`. The reporting PAL console with GC Loader / CubiBoot +returned CRC-32 `6DAC1F2A`, matching the early reference profile; region alone does +not select the resource profile. -The SDK's [API guide](https://github.com/capz/DolphinDotNet/blob/main/docs/system-firmware-resources.md) -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 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. +Preparation runs in the background using `IncludeSystemAudio`, +`FirmwareCatalog.SupportsAudioSession` and `SystemResources.CreateAudioSession`. +A prepared session initially remains stopped. The demo uses `PlayStartup`, +`PlayCue`, `PlaySample`, `SetControl`, `OutputMode` and `GetStatistics` directly. +`GetAudioCues` supplies read-only repeat metadata. Sample descriptors come from +`session.GetSample`, so their ownership matches `session.PlaySample`. -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 -the repository's pinned SDK version on screen when testing it. +The input image is disposed after preparation. Textures are published between +frames on the graphics executor, then the full-session path also disposes the +catalog. Its session owns an independent decoded cache. Stop releases the +current playback handle and clears session voices/tails while keeping the cache +prepared. Shutdown cancels and waits for pending preparation, stops playback, +then disposes the session, textures and font. + +Partial profiles preserve the existing qualified startup/menu factories and +lazy `CreateAudioSampleAsync` / parameterless `SystemAudioSample.Play()` path. +The catalog stays alive for that lazy extraction and only one standalone raw +sample is cached. Unsupported resources report their availability independently. +A failed complete-session preparation is reported explicitly. No firmware, +original textures, samples, recordings or substitute tones are bundled. + +Complete audio profiles cover early NTSC 1.0, NTSC 1.2 and PAL 1.2. The SDK's +original-score fidelity and sustained-playback qualification is recorded in its +[qualification ledger](https://github.com/capz/DolphinDotNet/blob/main/docs/ipl-complete-audio-progress.md). +New session playback on physical hardware remains to be confirmed. + +The `ipl-resources-dol` CI artifact contains `IplResources.dol`. Confirm +`IPL RESOURCES B05` and SDK `0.1.0-preview.361.1` on screen. ```sh dotnet build IplResources/IplResources.sln -c Release dotnet run --project IplResources -c Release --no-build ``` -The [approved mockup](Design/approved-mockup.png) is a design reference, not an -emulator screenshot. The implementation reuses the sample palette and fallback -font, and loads original visual resources locally through the SDK. +The [approved revised mockup](Design/approved-complete-audio.png) is a design +reference, not an emulator screenshot. The SDK [API guide](https://github.com/capz/DolphinDotNet/blob/main/docs/system-firmware-resources.md) +describes extraction, profile qualification, ownership and native budgets. diff --git a/README.md b/README.md index 74e960f..85ebf37 100644 --- a/README.md +++ b/README.md @@ -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.349.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.361.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 | @@ -19,7 +19,7 @@ the GameCube runs generated native code, using only the supported AOT API subset | [Snake](Snake/README.md) | Classic Snake with Continue/New Game title menu, checked native memory-card saves and two-minute autosave | GameCube memory card A or B recommended; works without card but cannot persist | | [Pong](Pong/README.md) | Complete two-player Pong: controller input, delta-time physics, 2D rectangles, generated PCM8 sounds | Self-contained GameCube DOL; two controllers, no storage/asset files | | [AudioDemo](AudioDemo/Program.cs) | AESND WAV effects and looping PCM music with async loading | Mount an SD device containing `audio/laser.wav` and `audio/theme.wav` (PCM WAV) | -| [IplResources](IplResources/README.md) | Original IPL font/textures, startup audio and ten prepared menu effects | Configured console IPL; Up/down selects, A plays, B stops, X changes texture, Start exits | +| [IplResources](IplResources/README.md) | Original IPL font/textures, three startup scores, nineteen cues, continuous ambience and twelve source samples | Configured console IPL; L/R category, Up/down selects, A plays, B stops, X texture, Y ambience, Z stats, Start exits | | [GoogleLogoAram](GoogleLogoAram/README.md) | Streamed HTTP to `AramStream` with standard `Stream.CopyToAsync`; partial-read-safe PNG signature verification | Run the PC relay and configure its LAN address; returns 0 on success, otherwise 1 | ## Shared controls diff --git a/ci/validate_sample_tests.py b/ci/validate_sample_tests.py index ca183af..c57f65e 100644 --- a/ci/validate_sample_tests.py +++ b/ci/validate_sample_tests.py @@ -9,7 +9,7 @@ 'DiscBrowserNavigationTests', 'FoxRulesSmoke', 'GreenMenRulesSmoke', 'KartInputSmoke', 'KartItemSmoke', 'KartNetworkSmoke', 'KartRulesSmoke', 'PongRulesSmoke', 'SampleDownloadTests', 'SampleRecordsTests', - 'SnakeRulesSmoke', 'VideoModeMenuTests', 'VideoModeAudioTests', + 'SnakeRulesSmoke', 'VideoModeMenuTests', 'VideoModeAudioTests', 'IplResourcesNavigationTests', } projects = list((root / 'tests').glob('*/*.csproj')) names = {project.parent.name for project in projects} diff --git a/ci/validate_samples.py b/ci/validate_samples.py index 33a2328..bae06b4 100644 --- a/ci/validate_samples.py +++ b/ci/validate_samples.py @@ -6,7 +6,7 @@ import xml.etree.ElementTree as ET ROOT = pathlib.Path(__file__).resolve().parents[1] -VERSION = "0.1.0-preview.349.1" +VERSION = "0.1.0-preview.361.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 diff --git a/ci/verify_aot.py b/ci/verify_aot.py index 733361e..dfab24b 100644 --- a/ci/verify_aot.py +++ b/ci/verify_aot.py @@ -13,9 +13,17 @@ def check(name: str, configuration: str, generated_c: Path) -> None: raise RuntimeError(f"{name}: AOT C is missing the managed entry point") if name == "IplResources": for api in ("SystemFirmware_ReadConsole", "SystemResources_CreateMenuSound", - "SystemResources_CreateStartupSound", "SystemResources_CreateTexture", + "SystemResources_CreateStartupSound", "SystemResources_CreateStartupVariantSound", "FirmwareCatalog_TryGetStartupSoundInfo", "SystemResources_CreateTexture", "SystemFont_Load", "SystemMenuSoundInfo_get_SourceWaveCount", - "SystemMenuSoundInfo_GetSourceWaveId"): + "SystemMenuSoundInfo_GetSourceWaveId", "SystemResources_CreateAudioSampleAsync", + "SystemAudioSample_Play", "FirmwareCatalog_GetAudioSamples", + "FirmwareAudioSampleInfo_get_HasLoop", "SystemResources_CreateAudioSession", + "FirmwareCatalog_get_SupportsAudioSession", "FirmwareCatalog_GetAudioCues", + "SystemAudioSession_GetSample", "SystemAudioSession_PlaySample", + "SystemAudioSession_PlayCue", "SystemAudioSession_PlayStartup", + "SystemAudioSession_SetControl", "SystemAudioSession_GetStatistics", + "SystemAudioSession_get_IsStartupPlaying", "SystemAudioSession_set_OutputMode", + "SystemAudioCueInfo_get_RepeatsUntilStopped", "SystemAudioPlayback_Dispose"): if api not in c: raise RuntimeError(f"IplResources: published firmware API is not reachable: {api}") if name == "VideoMode": diff --git a/global.json b/global.json index cde6af6..7117ae0 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "DolphinDotNet.Sdk": "0.1.0-preview.349.1" + "DolphinDotNet.Sdk": "0.1.0-preview.361.1" } } diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 7762baa..c8550b1 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -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. --> - 0.1.0-preview.349.1 + 0.1.0-preview.361.1 diff --git a/tests/IplResourcesNavigationTests/IplResourcesNavigationTests.csproj b/tests/IplResourcesNavigationTests/IplResourcesNavigationTests.csproj new file mode 100644 index 0000000..64de8d6 --- /dev/null +++ b/tests/IplResourcesNavigationTests/IplResourcesNavigationTests.csproj @@ -0,0 +1,7 @@ + + Exenet8.0 + + + + + diff --git a/tests/IplResourcesNavigationTests/Program.cs b/tests/IplResourcesNavigationTests/Program.cs new file mode 100644 index 0000000..cab9b7d --- /dev/null +++ b/tests/IplResourcesNavigationTests/Program.cs @@ -0,0 +1,37 @@ +using System; + +static void Check(bool value){if(!value)throw new Exception("IPL resource navigation failed");} +var selection=new IplSelection(); +Check(selection.Category==0&&selection.Count==3&&selection.Selected==0); +selection.Move(-1);Check(selection.Selected==2);selection.Move(1);Check(selection.Selected==0); +selection.NextCategory(1);selection.Move(-1); +Check(selection.Category==1&&selection.Selected==9&&selection.FirstVisible==6); +selection.NextCategory(1);selection.Move(1);selection.Move(-1); +Check(selection.Category==2&&selection.Count==0&&selection.Selected==0); +selection.NextCategory(1);Check(selection.Category==3&&selection.Count==0); +selection.NextCategory(1);selection.SetSampleCount(12); +for(int i=0;i<12;i++) +{ + Check(selection.Selected==i&&selection.Selected>=selection.FirstVisible&&selection.Selected