Need help testing 32X Sandbox

Announce (tech) demos or games releases

Moderator: Mask of Destiny

Chilly Willy
Very interested
Posts: 2593
Joined: Fri Aug 17, 2007 9:33 pm

Re: Need help testing 32X Sandbox

Post by Chilly Willy » Sun Jul 30, 2017 1:59 pm

Good morning! Yes, alignment is important on the SH2. No words there aren't on word-aligned, and no longs that aren't long-aligned.

This rom doesn't hang, but at least one instrument is wrong - it's a squeal rather than what it should be, like the pointer to the data is off... or perhaps the loop point. It sounds right in fusion, but not real hardware, so you've still got a cache issue in there. If the master loads the patch, the slave needs to flush the area of that loaded patch.

So you're even closer to having this work on real hardware... now you see why only using emulators means that some homebrew doesn't work on real hardware. There are certain things emulators ignore for speed, like alignment issues, and things it's nearly impossible to emulate, like caches.

KillaMaaki
Very interested
Posts: 58
Joined: Sat Feb 28, 2015 9:22 pm

Re: Need help testing 32X Sandbox

Post by KillaMaaki » Sun Jul 30, 2017 8:57 pm

Yeah, I sort of decided to sink the time into getting this up and running on REAL hardware because IMHO I don't feel like I can call my stuff 32X homebrew if it doesn't actually run on a 32X. If it only runs in Fusion then it's really just Fusion homebrew, isn't it? ;)

So here's another version to try. Cache clears the sample pointer before mixing voices, but ALSO I did more tinkering with alignment. Gave me an opportunity to fix something I'd been meaning to anyway - I had a loop flag in there which indicated whether or not a sample looped, but having taken your voice mixing code, all that did was set the loop length to 0 if loop was false. I'd been meaning to tear that out anyway, this just gave me a good reason to do so - because that loop flag was one byte, and that could easily have still been throwing off my alignment. So now my sample data struct just looks like this:

Code: Select all

typedef struct _PatchData
{
	u32 SampleStep;
	u32 LoopCorrect;
	u32 SampleLength;
	// there was a one byte loop flag right here, almost certainly threw my alignment off.
	u8	Attack;
	u8	Decay;
	u8	Sustain;
	u8	Release;
	u8	SampleData[0];
} PatchData;
Each of the first three values is longword sized and aligned, then four values for ADSR which fits neatly within a longword so whatever comes next is longword aligned, and then sample data which is padded out with zero bytes to be longword aligned so that whatever comes next is still longword aligned. This should make absolute sure my patches are properly longword aligned in memory.
The loop byte wouldn't have been a problem ofc if it weren't for the fact that my content builder didn't take header alignment into account when padding the sampledata. So it pads sampledata to a multiple of four bytes, but that still means the header could be misaligned.

So try this one and see if that fixes it (plus the fact that it does now cache clear a voice's patch pointer before mixing)
Attachments
OutRom.zip
(234.89 KiB) Downloaded 31 times

Chilly Willy
Very interested
Posts: 2593
Joined: Fri Aug 17, 2007 9:33 pm

Re: Need help testing 32X Sandbox

Post by Chilly Willy » Sun Jul 30, 2017 11:05 pm

And it works fine now. Good job! This isn't easy as I can attest, and you did it without even having actual hardware. 8)

So, you got tossed into the deep end of the pool as far as homebrew goes... I think the rest will be easier.

KillaMaaki
Very interested
Posts: 58
Joined: Sat Feb 28, 2015 9:22 pm

Re: Need help testing 32X Sandbox

Post by KillaMaaki » Mon Jul 31, 2017 4:36 am

Fantastic!
Also threw back in the sound effects and the echo buffer, which another guy on Discord also reported working on his 32X.
FINALLY.
Looking forward to hopefully never touching this particular section of code again, lol.

Thank you for your help!

Chilly Willy
Very interested
Posts: 2593
Joined: Fri Aug 17, 2007 9:33 pm

Re: Need help testing 32X Sandbox

Post by Chilly Willy » Mon Jul 31, 2017 5:08 am

No problem. Just glad it all got worked out. We need more 32X homebrew.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest