Sonic and Sega Retro Message Board: Making Sonic 2's sound driver good - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
Page 1 of 1
    Locked
    Locked Forum

Making Sonic 2's sound driver good A collection of guides too short for their own topics

#1 User is offline Clownacy 

  Posted 17 March 2015 - 06:31 PM

  • Needs to make an avatar
  • Posts: 309
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
Because of its relation to S1's driver (it's a fixed Z80 port of it), I've been fooling around with S2's driver more than ever, and I've found some interesting things. So what say we give this driver some level of technical competence?

I have quite a few changes here that eventually link with each other, so if you're gonna follow along, don't skip anything. Also, flamewing's stuff ties into this, so check that out beforehand. It doesn't hurt to check out the other improvements scattered around my driver's topic (and here, and here, and here).

Optimising zWriteFMI/zWriteFMII
Spoiler


Adding common bankswitch subroutine
Spoiler


Improving common bankswitch subroutine
Spoiler


Optimising DAC playback loop
Spoiler


Adding multiple DAC banks
Spoiler


Adding automatic DAC bankswitching
Spoiler


From here, these are just small changes that don't impact each other.

Saving a bank
Spoiler


Making the jump tables smaller
Spoiler

This post has been edited by Clownacy: 18 March 2015 - 12:26 PM

#2 User is offline flamewing 

Posted 18 March 2015 - 11:52 AM

  • Emerald Hunter
  • Posts: 831
  • Joined: 11-October 10
  • Gender:Male
  • Location:Brasil
  • Project:Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
  • Wiki edits:12

View PostClownacy, on 17 March 2015 - 06:31 PM, said:

In zWriteToDAC, you can see that each half of the playback loop writes 2Ah to zYM2612_A0. This is done constantly in case zYM2612_A0 has been set to something else, usually by zWriteFMI or zWriteFMII. The problem is that this is done in the playback loop, affecting playback speed. It would be better to make it so that, whenever zYM2612_A0 is changed by something, it's set back to 2Ah once it's done.

Start by removing the two 'ld a,2Ah' + 'ld (zYM2612_A0),a' pairs, and then go to zWriteFMI and zWriteFMII, and, before the 'pop af', add this:

	ld	a,2Ah
	ld	(zYM2612_A0),a

This one makes perfect sense for MegaPCM, but is a bit excessive in the context of z80 drivers, such as S2: you actually need to do this only in the z80 V-Int function when it is about to return. The reason is that all calls to zWriteFMI and zWriteFMII will happen during V-Int, and the DAC playback loop will be halted for its duration; so it is immaterial. Mega PCM, on the other hand, is still running its DAC loop while the 68k updates songs, so every YM2612 command it sends needs to restore the register to the correct value.

Other than this, excellent stuff.
This post has been edited by flamewing: 19 March 2015 - 04:00 PM

Page 1 of 1
    Locked
    Locked Forum

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