Skip to content

Commit f4045f2

Browse files
authored
Merge pull request #720 from TheTrackerCouncil/717-etecoon-sample-loop
#717: Loop the Etecoons Cry sample
2 parents 367bf61 + 56b2b90 commit f4045f2

File tree

1 file changed

+48
-15
lines changed

1 file changed

+48
-15
lines changed

src/TrackerCouncil.Smz3.SeedGenerator/FileData/Patches/EtecoonsJinglePatch.cs

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class EtecoonsJinglePatch : RomPatch
2121
{
2222
internal class Jingle
2323
{
24+
public required bool Loop { get; init; }
2425
public required Voice Voice1 { get; init; }
2526
public Voice? Voice2 { get; init; }
2627
}
@@ -81,6 +82,7 @@ public List<byte> ToBytes()
8182
{
8283
EtecoonsJingle.Vanilla, new Jingle
8384
{
85+
Loop = false,
8486
Voice1 = new Voice
8587
{
8688
Notes =
@@ -117,6 +119,7 @@ public List<byte> ToBytes()
117119
{
118120
EtecoonsJingle.BlueBadger, new Jingle
119121
{
122+
Loop = true,
120123
Voice1 = new Voice
121124
{
122125
Notes =
@@ -225,6 +228,7 @@ public List<byte> ToBytes()
225228
{
226229
EtecoonsJingle.SMB1, new Jingle
227230
{
231+
Loop = false,
228232
Voice1 = new Voice
229233
{
230234
Notes =
@@ -256,33 +260,35 @@ public List<byte> ToBytes()
256260
{
257261
EtecoonsJingle.ZeldaSecret, new Jingle
258262
{
263+
Loop = true,
259264
Voice1 = new Voice
260265
{
261266
Notes =
262267
[
263-
new Note { Value = NoteValue.E4, Duration = 0x12, Volume = 0x70, Pan = 0x08 },
264-
new Note { Value = NoteValue.C4, Duration = 0x12, Volume = 0x70, Pan = 0x08 },
265-
new Note { Value = NoteValue.F3, Duration = 0x12, Volume = 0x70, Pan = 0x08 },
266-
new Note { Value = NoteValue.F4, Duration = 0x12, Volume = 0x70, Pan = 0x08 }
268+
new Note { Value = NoteValue.G4, Duration = 0x14, Volume = 0x70, Pan = 0x08 },
269+
new Note { Value = NoteValue.Ds4, Duration = 0x14, Volume = 0x70, Pan = 0x08 },
270+
new Note { Value = NoteValue.Gs3, Duration = 0x14, Volume = 0x70, Pan = 0x08 },
271+
new Note { Value = NoteValue.Gs4, Duration = 0x14, Volume = 0x70, Pan = 0x08 }
267272
]
268273
},
269274
Voice2 = new Voice
270275
{
271276
Notes =
272277
[
273-
new Note { Value = NoteValue.Ds4, Duration = 0x0A, Volume = 0x00, Pan = 0x0B },
274-
new Note { Value = NoteValue.Ds4, Duration = 0x12, Volume = 0x70, Pan = 0x0B },
275-
new Note { Value = NoteValue.Fs3, Duration = 0x12, Volume = 0x70, Pan = 0x0B },
276-
new Note { Value = NoteValue.Cs4, Duration = 0x12, Volume = 0x70, Pan = 0x0B },
277-
new Note { Value = NoteValue.A4, Duration = 0x12, Volume = 0x70, Pan = 0x0B },
278-
new Note { Value = NoteValue.A4, Duration = 0x12, Volume = 0x20, Pan = 0x0B }
278+
new Note { Value = NoteValue.Fs4, Duration = 0x0A, Volume = 0x00, Pan = 0x0B },
279+
new Note { Value = NoteValue.Fs4, Duration = 0x14, Volume = 0x70, Pan = 0x0B },
280+
new Note { Value = NoteValue.A3, Duration = 0x14, Volume = 0x70, Pan = 0x0B },
281+
new Note { Value = NoteValue.E4, Duration = 0x14, Volume = 0x70, Pan = 0x0B },
282+
new Note { Value = NoteValue.C5, Duration = 0x14, Volume = 0x70, Pan = 0x0B },
283+
new Note { Value = NoteValue.C5, Duration = 0x14, Volume = 0x20, Pan = 0x0B }
279284
]
280285
}
281286
}
282287
},
283288
{
284289
EtecoonsJingle.SariasSong, new Jingle
285290
{
291+
Loop = true,
286292
Voice1 = new Voice
287293
{
288294
Notes =
@@ -313,6 +319,7 @@ public List<byte> ToBytes()
313319
{
314320
EtecoonsJingle.KQVTown, new Jingle
315321
{
322+
Loop = false,
316323
Voice1 = new Voice
317324
{
318325
Notes =
@@ -354,6 +361,7 @@ public List<byte> ToBytes()
354361
{
355362
EtecoonsJingle.ManbosMambo, new Jingle
356363
{
364+
Loop = true,
357365
Voice1 = new Voice
358366
{
359367
Notes =
@@ -391,6 +399,7 @@ public List<byte> ToBytes()
391399
{
392400
EtecoonsJingle.Sonic2Bonus, new Jingle
393401
{
402+
Loop = true,
394403
Voice1 = new Voice
395404
{
396405
Notes =
@@ -428,6 +437,7 @@ public List<byte> ToBytes()
428437
{
429438
EtecoonsJingle.FFVictory, new Jingle
430439
{
440+
Loop = true,
431441
Voice1 = new Voice
432442
{
433443
Notes =
@@ -463,6 +473,7 @@ public List<byte> ToBytes()
463473
{
464474
EtecoonsJingle.YICastle, new Jingle
465475
{
476+
Loop = true,
466477
Voice1 = new Voice
467478
{
468479
Notes =
@@ -472,7 +483,7 @@ public List<byte> ToBytes()
472483
new Note { Value = NoteValue.G4, Duration = 0x12, Volume = 0x60, },
473484
new Note { Value = NoteValue.Fs4, Duration = 0x12, Volume = 0x60, },
474485
new Note { Value = NoteValue.A4, Duration = 0x24, Volume = 0x60, },
475-
486+
476487
new Note { Value = NoteValue.As4, Duration = 0x1B, Volume = 0x60, },
477488
new Note { Value = NoteValue.C5, Duration = 0x09, Volume = 0x60, },
478489
new Note { Value = NoteValue.As4, Duration = 0x09, Volume = 0x60, },
@@ -503,6 +514,7 @@ public List<byte> ToBytes()
503514
{
504515
EtecoonsJingle.Shadowgate, new Jingle
505516
{
517+
Loop = true,
506518
Voice1 = new Voice
507519
{
508520
Notes =
@@ -514,7 +526,7 @@ public List<byte> ToBytes()
514526
new Note { Value = NoteValue.G4, Duration = 0x0C, Volume = 0x70, },
515527
new Note { Value = NoteValue.As4, Duration = 0x0C, Volume = 0x70, },
516528
new Note { Value = NoteValue.D5, Duration = 0x18, Volume = 0x70, },
517-
529+
518530
new Note { Value = NoteValue.E5, Duration = 0x06, Volume = 0x70, },
519531
new Note { Value = NoteValue.F5, Duration = 0x06, Volume = 0x70, },
520532
new Note { Value = NoteValue.E5, Duration = 0x24, Volume = 0x70, },
@@ -544,6 +556,7 @@ public List<byte> ToBytes()
544556
{
545557
EtecoonsJingle.SNAAAKE, new Jingle
546558
{
559+
Loop = true,
547560
Voice1 = new Voice
548561
{
549562
Notes =
@@ -589,6 +602,7 @@ public List<byte> ToBytes()
589602
{
590603
EtecoonsJingle.BattletoadsWin, new Jingle
591604
{
605+
Loop = false,
592606
Voice1 = new Voice
593607
{
594608
Notes =
@@ -628,6 +642,7 @@ public List<byte> ToBytes()
628642
{
629643
EtecoonsJingle.PizzaTime, new Jingle
630644
{
645+
Loop = true,
631646
Voice1 = new Voice
632647
{
633648
Notes =
@@ -656,6 +671,7 @@ public List<byte> ToBytes()
656671
{
657672
EtecoonsJingle.KirbyWin, new Jingle
658673
{
674+
Loop = true,
659675
Voice1 = new Voice
660676
{
661677
Notes =
@@ -683,6 +699,7 @@ public List<byte> ToBytes()
683699
{
684700
EtecoonsJingle.BuffedKirbyWin, new Jingle
685701
{
702+
Loop = true,
686703
Voice1 = new Voice
687704
{
688705
Notes =
@@ -710,6 +727,7 @@ public List<byte> ToBytes()
710727
{
711728
EtecoonsJingle.VampireKiller, new Jingle
712729
{
730+
Loop = true,
713731
Voice1 = new Voice
714732
{
715733
Notes =
@@ -736,13 +754,13 @@ public List<byte> ToBytes()
736754
[
737755
new Note { Value = NoteValue.A3, Duration = 0x18, Volume = 0x60, Pan = 0x0B, },
738756
new Note { Value = NoteValue.A3, Duration = 0x28, Volume = 0x60, Pan = 0x0B, },
739-
757+
740758
new Note { Value = NoteValue.A3, Duration = 0x18, Volume = 0x60, Pan = 0x0B, },
741759
new Note { Value = NoteValue.A3, Duration = 0x28, Volume = 0x60, Pan = 0x0B, },
742-
760+
743761
new Note { Value = NoteValue.F3, Duration = 0x18, Volume = 0x60, Pan = 0x0B, },
744762
new Note { Value = NoteValue.F3, Duration = 0x28, Volume = 0x60, Pan = 0x0B, },
745-
763+
746764
new Note { Value = NoteValue.G3, Duration = 0x40, Volume = 0x60, Pan = 0x0B, }
747765
]
748766
}
@@ -751,6 +769,7 @@ public List<byte> ToBytes()
751769
{
752770
EtecoonsJingle.MegaManBossSelected, new Jingle
753771
{
772+
Loop = false,
754773
Voice1 = new Voice
755774
{
756775
Notes =
@@ -797,6 +816,7 @@ public List<byte> ToBytes()
797816
{
798817
EtecoonsJingle.ThemeOfSuperMetroid, new Jingle
799818
{
819+
Loop = true,
800820
Voice1 = new Voice
801821
{
802822
Notes =
@@ -890,6 +910,19 @@ internal IEnumerable<GeneratedPatch> GetPatch(Jingle jingle)
890910

891911
yield return new GeneratedPatch(Snes(voice1Offset), bytes.ToArray());
892912

913+
if (jingle.Loop)
914+
{
915+
// Enable looping
916+
yield return new GeneratedPatch(Snes(0xD33D00), [0x03]); // 0x01
917+
918+
// Set loop point (must be aligned with a nine-byte BRR block)
919+
yield return new GeneratedPatch(Snes(0xD31356), [0x28, 0xD9]); // 0xDE9B
920+
921+
// Set ADSR envelope (Attack: 0ms, Delay: 1.2s, Sustain Level: 6/8, Sustain Rate: 1.2s)
922+
// See: https://snes.nesdev.org/wiki/DSP_envelopes#ADSR_Envelope
923+
yield return new GeneratedPatch(Snes(0xD35E11), [0x8F, 0xD0]); // 0xFF, 0xE0
924+
}
925+
893926
// Uncomment these lines to make the uncharged power beam sound effect use the Etecoon jingle instead.
894927
// The last two lines should make the Green Brinstar theme play at Samus's ship, which loads the right sample.
895928
// The jingle may play louder than usual, so be sure to check how it sounds in the actual Hell room.

0 commit comments

Comments
 (0)