Sonic and Sega Retro Message Board: Chaotix 1207 discussion - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
  • 13 Pages +
  • ◄ First
  • 11
  • 12
  • 13
    Locked
    Locked Forum

Chaotix 1207 discussion

#181 User is offline evilhamwizard 

Posted 14 May 2014 - 10:16 AM

  • Posts: 1262
  • Joined: 16-June 04
  • Gender:Male
  • Wiki edits:109
Ugh bumping. It's been a long time since this all happened. Feels almost like yesterday.

I wanted to see what was going on with the audio. Still unclear as to why it's producing the sound exactly (even though drx mentioned it on the first page), I decided to disassemble the sound driver (z80) based on the great disassembly ValleyBell did on the final (U) version.

You can download the IDB database and an asm output for both here (you need IDA Pro 6.1 to open the database):

http://www.mediafire...disassembly.zip

Note though, my disassembly is pretty much poo because I'm still pretty much an amateur at IDA Pro. So aesthetics aside, the sound driver used in this prototype is almost identical to the final version but there are some differences. I believe all the subroutines are there, but some instructions were added to a handful of them for the final version. Another oddity, which might be due to my inability to use IDA Pro, I think the instructions that reference data locations that come mostly after all the code are all pointing the the wrong locations. Also note that I have no knowledge of the Z80 or how the sound drivers in these games actually work. I really just wanted to mention this just in case someone might want to take a crack at it. If this has any impact on the audio issue, I don't know, but it's a start at least.

Here are some differences I noticed:
1.) At 0x38, "VInt" is missing instructions that loads 0 to register 'a' and adds $80 to 'a' in a loop. The prototype just disables interrupts and calls "ProcessSndQueue" and "sub_A4" right away before returning.
2.) As stated somewhere before, there's a string from the sound driver programmer in every version. The final version however, is truncated possibly due to the added instructions mentioned before. The prototype has the full string - "casablanca version by MILPO". Nothing seems to reference this string AFAIK.
3.) At 0x204, the disassembly for the final version notes that "ex af, af'" is dead code. This code doesn't exist in the prototype, but space for it does exist. I added the line back manually in my database, but note that it wasn't there originally.
4.) At 0x4C1, the final compares $2A with the accumulator and the following instruction jumps to PlayBGM ($00-$29 for a total of 41 music tracks?), while at 0x4C3 if compares $6F with the accumulator and the following instruction jumps to PlaySFX ($2A-$6E for a total of 68 sound effects?). The prototype is slightly different in this regard - the prototype compares $29 instead of $2A making for a possible total of 40 music tracks while also comparing $69 instead of $6F for a total of 63 sound effects if my math is correct.
5.) At 0x500, the beginning of PlayBGM is different. At the start of the label, the final ORs with the accumulator 'a' and returns 'z' (zero flag) and finally decrements the accumulator 'a' before the first "ex af, af'" instruction. The prototype just decrements the accumulator and returns 'm' before the first "ex af, af'" instruction.
6.) At 0x60F, the instruction subtracts $2A in the final and $29 in the prototype from the accumulator, related to sound effects.
7.) At 0x814(final)/0x813(proto), "PauseAudio" doesn't return in the prototype but does in the final. The Final calls sub_E58 after calling "PSGSilenceAll", which does something. The prototype makes no such call after "PSGSilenceAll". The equivalent subroutine to sub_E58 is sub_E53 in the prototype.
8.) Under "ProcessSndQueue", the final does this:

RAM:0885                 jp      m, ShiftSoundQueue ; Jump (conditional & unconditional)
RAM:0888                 sub     2Ah ; '*'       ; Subtract from A
RAM:088A                 jr      c, ShiftSoundQueue ; Jump relative (conditional & unconditional)



While the prototype does this:

ROM:0880                 sub     28h ; '('       ; Subtract from A
ROM:0882                 jp      c, ShiftSoundQueue ; Jump (conditional & unconditional)
ROM:0885                 sub     1               ; Subtract from A



That's pretty much all there is as far as code changes go. I didn't look through the data that comes after all this though.

#182 User is offline ValleyBell 

Posted 22 May 2014 - 04:09 AM

  • Posts: 227
  • Joined: 08-September 10
  • Gender:Male
  • Project:researching SMPS sound drivers
  • Wiki edits:10
I relabelled the Chaotix disassembly a while ago so that it uses the same labels and names as all the other disassemblies I did. You can download the "new" disassembly here.
It also includes a Chaotix 1207 with the new labels, a Sonic Crackers disassembly and a disassembly of the Chaotix PWM driver. The offsets of this one are wrong though, I'm working on redoing that one.

So let's list the changes:
1. Beta:
VInt:
		di
		call	DoSoundQueue
		call	UpdateAll
		ret

Final:
VInt:
		di
		call	loc_3C
loc_3C:					; DATA XREF: RAM:loc_40w
		ld	a, 0
		add	a, 80h
loc_40:
		ld	(loc_3C+1), a
		jr	nc, locret_4B
		call	DoSoundQueue
		call	UpdateAll
locret_4B:				; CODE XREF: RAM:0043j
		ret

I haven't check this in the PAL version yet, but I assume the added code is responsible for the PAL tempo fix.

2. I have nothing to add here.

3. The dead code exists in almost all SMPS Z80 drivers. That includes the Chatoix beta. The Z80 instruction " ex af, af' " has the code byte 08. (In IDA, click on the "db 8" and press 'C' to turn it into code.)

4. Beta:
PlaySoundID:				; CODE XREF: UpdateAll+9p
		ld	a, (byte_1C09)	; read Sound ID
		cp	29h
		jp	c, PlayMusic	; 00-28	- Music
		cp	69h
		jp	c, PlaySFX	; 29-68	- SFX

Final:
PlaySoundID:				; CODE XREF: UpdateAll+9p
		ld	a, (byte_1C09)	; read Sound ID
		cp	2Ah
		jp	c, PlayMusic	; 00-29	- Music
		cp	6Fh
		jp	c, PlaySFX	; 2A-6E	- SFX

I think the comments make it obvious what they changed - they added 1 song and 5 SFX.

5. Beta:
PlayMusic:				; CODE XREF: PlaySoundID+5j
		dec	a
		ret	m

Final:
PlayMusic:				; CODE XREF: PlaySoundID+5j
		or	a
		ret	z
		dec	a

The code does exactly the same in both versions. I have no idea why they changed it. It makes sure that Sound ID 00 does nothing. (The Beta code would also do nothing for 81-FF, but PlayMusic is never called for these IDs.)

6. Beta:
PlaySFX:				; CODE XREF: PlaySoundID+Aj
	...
		ex	af, af'
		sub	29h		; Sound	ID -> SFX Index
		ex	af, af'

Final:
PlaySFX:				; CODE XREF: PlaySoundID+Aj
	...
		ex	af, af'
		sub	2Ah		; Sound	ID -> SFX Index
		ex	af, af'


7. Beta:
SilenceAll:				; CODE XREF: DoPause+Ej
		call	PSGSilenceAll
		push	bc

Final:
SilenceAll:				; CODE XREF: DoPause+Ej
		call	PSGSilenceAll
		call	SendPSGState
		push	bc

In the beta, the PSGSilenceAll has no effect, because all PSG commands are stored in a buffer. The added instruction in the final makes sure that the PSG commands are sent to the chip and all PSG notes are stopped.
The added "ret" instruction at the end of the DoPause routine is a small optimization. In the beta it just falls through to the next code and executes PSGSilenceAll again.

8. Beta:
DoSoundQueue:				; CODE XREF: RAM:0039p
	...
		sub	28h
		jp	c, DequeueSound
		sub	1	; Here it effectively did "sub 29h

Final:
DoSoundQueue:				; CODE XREF: RAM:0039p
	...
		jp	m, DequeueSound	; jump if 80-FF
		sub	2Ah
		jr	c, DequeueSound

In the final, it makes sure that sound commands (FadeOutMusic, StopAllSound, etc., they have the IDs E0-FF) are ignored by the sound priority system. The beta only ignores songs.

The data for modulation envelopes and PSG instruments is the same.

btw: Most of the information in the wiki about changed songs between the 1207 beta and the final version of Chaotix is wrong. There are 3 songs with major differences. I'll just quote my .txt file:
- The intro of "Oriental Legend" is a lot longer than in the final.
- "Decision" is split into 2 parts in the final. In this beta it just loops once and finishes then.
- In the final, "This Horizon" has an additional intro that is missing here.
- All other songs either match exactly or have a slightly higher PSG 3 volume.


The actual issue with the sound is caused by the PWM driver. So far I was able to port the beta PWM driver to Chaotix final (after fixing some offsets). Considering how it sounds I assume that it is unable to play "silence" correctly.


The Chaotix sound driver is pretty much the same as the one in Sonic Crackers, just without the DAC channel and with 4 additional PWM channels.
This post has been edited by ValleyBell: 22 May 2014 - 04:44 AM

#183 User is offline ValleyBell 

Posted 18 June 2016 - 08:55 AM

  • Posts: 227
  • Joined: 08-September 10
  • Gender:Male
  • Project:researching SMPS sound drivers
  • Wiki edits:10
Since this was mentioned recently (and is popping up from time to time), let me correct this popular wrong fact:

The PWM noises you hear in the Chaotix prototypes are not caused by different hardware revisions.
The actual cause is a bug in the PWM driver. (I did some research in 2014 when I added the Chaotix proto to my SMPS archive.)

The PWM driver used by Chatoix does 4-channel mixing and also performs a linear interpolation when upsampling from the internal 11 KHz processing rate to the 22 KHz sample rate sent to the PWM FIFO.
During that process, it uses the registers R4-R7 to store the current sample values. (R4/R5 = first sample for L/R speaker, R6/R7 = second sample for L/R speaker)
Due to buggy/incomplete interpolation code, registers R4/R5 aren't always written, introducing bad samples depending on the sample rate. (R4/R5 aren't even initialized, but that's not the main problem.)


Anyway, there is an easy way to fix this.
  • search for D013 4420 4620
  • replace 2041 2061 with 2061 2061
  • 6 bytes later, replace 2051 2071 with 2071 2071
  • fix the checksum by adding $0040 to it.


In the spoiler you can find the ASM code of what you just changed, for those who are interested.
Spoiler

In order to debug the PWM driver, I ported it from the Chaotix 1207 proto to the final version, because the proto doesn't boot in MAME/MESS. I can upload an IPS patch of the patched final Chaotix with proto PWM driver if anyone is interested.

#184 User is offline ICEknight 

Posted 22 July 2016 - 05:44 PM

  • Posts: 10272
  • Joined: 11-January 03
  • Gender:Male
  • Location:Spain
  • Wiki edits:18

View PostValleyBell, on 18 June 2016 - 08:55 AM, said:

In order to debug the PWM driver, I ported it from the Chaotix 1207 proto to the final version, because the proto doesn't boot in MAME/MESS. I can upload an IPS patch of the patched final Chaotix with proto PWM driver if anyone is interested.
That could be a good addition to its page at hidden-palace.org, seeing how it carries some fixes for other prototypes as well.

#185 User is online Laura 

Posted 25 September 2016 - 06:14 AM

  • Brightened Eyes
  • Posts: 296
  • Joined: 01-November 12
  • Gender:Female
  • Location:England
Sorry to come charging in but I have something that might be useful.

For years people have assumed that Sonic Studium is a typo for Stadium. However, studium is actually a Latin word and means 'study' or 'devotion', so somewhat translatable as "a Sonic study". As in, a Sonic prototype or experiment. I know Latin and the expression works.

I know it sounds maybe stretched but it makes far more sense than Sonic Stadium, which has nothing to do with Sonic Crackers. Also, Japanese developers sometimes use Latin as internal names (look at the Final Fantasy series).

Perhaps worth a thought :v:

#186 User is online Dandaman 

Posted 07 October 2016 - 12:56 PM

  • Also known as Dandaman955
  • Posts: 82
  • Joined: 30-August 09
  • Gender:Male
  • Location:UK
  • Wiki edits:30

View PostLaura, on 25 September 2016 - 06:14 AM, said:

Sorry to come charging in but I have something that might be useful.

For years people have assumed that Sonic Studium is a typo for Stadium. However, studium is actually a Latin word and means 'study' or 'devotion', so somewhat translatable as "a Sonic study". As in, a Sonic prototype or experiment. I know Latin and the expression works.

I know it sounds maybe stretched but it makes far more sense than Sonic Stadium, which has nothing to do with Sonic Crackers. Also, Japanese developers sometimes use Latin as internal names (look at the Final Fantasy series).

Perhaps worth a thought :v:/>/>


From what I seem to remember, it was similar with Pokemon Crystal's unused text, which called it "MOBILE STUDIUM". It's a much safer bet to assume a mistranslation.

EDIT: Jesus Christ, didn't notice the date.
This post has been edited by Dandaman: 07 October 2016 - 12:57 PM

#187 User is offline Overlord 

Posted 09 October 2016 - 04:28 AM

  • Substitute Meerkovo IT Chief
  • Posts: 16214
  • Joined: 12-January 03
  • Gender:Male
  • Location:Berkshire, England
  • Project:VGDB
  • Wiki edits:3,204
(Don't worry about bumping a topic in the Archives forum, if the information's relevant. You're fine)

#188 User is online Laura 

Posted 07 November 2016 - 04:44 PM

  • Brightened Eyes
  • Posts: 296
  • Joined: 01-November 12
  • Gender:Female
  • Location:England
The ROM Header is called Sonic Zeal and one translation of studium in Latin is zeal (as in a zeal for study).

There might be something to the Latin word 'studium'. I mean, why would Chaotix even be called Stadium?

#189 User is offline ICEknight 

Posted 07 November 2016 - 05:52 PM

  • Posts: 10272
  • Joined: 11-January 03
  • Gender:Male
  • Location:Spain
  • Wiki edits:18

View PostLaura, on 07 November 2016 - 04:44 PM, said:

The ROM Header is called Sonic Zeal
What? Which ROM header?

#190 User is offline Clownacy 

Posted 11 November 2016 - 09:48 PM

  • Layin' the Wax and Spinnin' the Sounds
  • Posts: 631
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland

View PostLaura, on 07 November 2016 - 04:44 PM, said:

I mean, why would Chaotix even be called Stadium?

Why would it be called Sonic Zeal?

#191 User is online Laura 

Posted 12 November 2016 - 01:04 PM

  • Brightened Eyes
  • Posts: 296
  • Joined: 01-November 12
  • Gender:Female
  • Location:England

View PostClownacy, on 11 November 2016 - 09:48 PM, said:

Why would it be called Sonic Zeal?


Because 'zeal' is one translation of 'studium'. However for Sonic Crackers, (and the most general translation) studium would mean a Sonic study or experiment. Makes sense considering what Sonic Crackers was. The guy who wrote the ROM Header probably looked the Latin word studium up and applied an awkward translation.

Also, I'm talking about the ROM Header fo Sonic Crackers (or maybe Chaotix 1207, can't remember for sure but it's one of them).

#192 User is offline evilhamwizard 

Posted 12 November 2016 - 02:05 PM

  • Posts: 1262
  • Joined: 16-June 04
  • Gender:Male
  • Wiki edits:109
There's one internal document from STI that we have from around the time of Crackers that the game was usually referred to Sonic Stadium, not studium, as the next game from SoJ. Although I don't know why the game also used Crackers mostly, it's possible that the game had a different name based on region at some point (with Crackers being the title for Japan, Stadium being the localized one). None of the Chaotix prototypes had Crackers in the header, just the unused art for "SONIC CRACKERS S32X" in this prototype.
This post has been edited by evilhamwizard: 12 November 2016 - 02:06 PM

  • 13 Pages +
  • ◄ First
  • 11
  • 12
  • 13
    Locked
    Locked Forum

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users