Wednesday, August 24, 2016

Snake Rock 'n' Roll: The Location of the Tapes

You see something very odd when you look at the character ROM (CHR ROM) for Snake Rattle 'n' Roll:

CHR Pages 0 & 1 CHR pages 2 & 3 CHR pages 4 & 5 CHR pages 6 & 7

In these images, the upper half corresponds to the first page number listed, and the bottom half to the second page number listed.

In these renderings, you can see areas that look like corrupted data, or static. Pages two and six are the most noticeable, being entirely 'snow', but every page except for page zero contains at least some snow. What is going on here? Anyone who has played the game knows that this visual corruption never actually appears while playing, so something else must be going on.

At the risk of spoilers, it has to do with the audio module. I am pretty sure that you figured that out from the theme of this blog series; I just wanted to eliminate all doubt.

In the PRG ROM, starting at address $9505, is a nine-element list which will be of some interest to us:

Song #Song Name$9505
0Level 1 $02
1Levels 5 and 8 $02
2Levels 6, 9 and 10 $06
3Level 2 $02
4Level 3 $02
5Levels 4 and 7 $02
6Time Out $03
7Game Over $03
8Main Titles and End Credits$06

This table suggests that the tape data specifying the background music is actually stored in character ROM, not program ROM. Now, knowing the page number is nice, but which of the 4096 bytes in a page is the start of the tape? Another list (actually, two) comes to the rescue. These lists are each 36 (9x4) entries long. They start at $DE42 and $DE43, and you must increment your table index by four to get each successive element:

Song #Song NamePulse 1Pulse 2TriangleNoise
$DE42$DE43$DE46$DE47$DE4A$DE4B$DE4E$DE4F
0Level 1 $00$00 $01$07 $02$30 $02$BF
1Levels 5 and 8 $0C$8D $0C$FC $0E$44 $0E$B6
2Levels 6, 9 and 10 $00$00 $00$D9 $01$4D $01$82
3Level 2 $03$2B $03$FD $04$D8 $05$62
4Level 3 $05$98 $06$D0 $07$D0 $08$7F
5Levels 4 and 7 $08$CB $0A$43 $0B$63 $0C$26
6Time Out $01$F0 $02$11 $02$32 $02$45
7Game Over $02$46 $02$63 $02$80 $02$45
8Main Titles and End Credits $03$96 $04$DB $06$14 $06$60

This table provides the address on the corresponding table where the tape data for each track begins. Note that the list data is stored at $DE42 + $10 * SongNumber + TrackNumber, and likewise for the $DE43 list.

We now know that if we wanted to examine the tape data for the audio for the pulse 2 channel on level 3, we should start looking at $06D0 on CHR ROM page 2. In the next post, we will examine the file format of the tape data.

No comments:

Post a Comment