Sonic and Sega Retro Message Board: Sonic 1 "Mega PCM" driver - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
  • 4 Pages +
  • ◄ First
  • 2
  • 3
  • 4
    Locked
    Locked Forum

Sonic 1 "Mega PCM" driver A new DAC driver for Sonic 1, version 1.1 is out!

#46 User is offline redquebec 

Posted 30 April 2014 - 01:30 PM

  • Posts: 17
  • Joined: 29-April 14
Thank you vlad, it's been a while since the DAC drivers didn't got some love. Amazing work. Thanks again

#47 User is offline Clownacy 

Posted 04 November 2014 - 09:44 AM

  • Needs to make an avatar
  • Posts: 309
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
So, while working with my driver, I found myself making a pair of size optimisations that don't affect speed to Mega PCM's code:

  • Removed two of the three 'di' instructions at the beginning of the driver.
  • Moved DPCM_DeltaArray from address 200h to 100h. This was done by moving DPCM_DeltaArray and its align to above InitBankSwitching. This reduces the amount of padding needed for the align.


While DPCM_DeltaArray's padding negates the space saved by the removal of the 'di's, the resulting binary's size is reduced from 210h bytes to 1EEh bytes. Size can also be reduced by compressing the binary file and making SoundDriverLoad decompress the data to Z80 RAM. Flamewing's koscmp works well for compressing.

EDIT: Actually, it seems I can take this even further:

At the end of both Process_PCM and Process_DPCM is this code:

	; Quit playback loop
+	exx
	jp	Event_EndPlayback


It's the exact same between the two, and doesn't call back into their respective routines. So, we can make the driver use only one copy of this code, and we can make it occupy the space otherwise used by DPCM_DeltaArray's padding.

So, for example, above DPCM_DeltaArray, you can have this:

; ---------------------------------------------------------------
; Quit playback loop (used by Process_PCM/Process_DPCM)
; ---------------------------------------------------------------

QuitPlaybackLoop:
	exx
	jp	Event_EndPlayback


And, in Process_PCM/Process_DPCM, you can replace this:

	jp	p,+++			; 10	; if yes, quit playback loop


...with this:

	jp	p,QuitPlaybackLoop	; 10	; if yes, quit playback loop


And you can delete both of these:

	; Quit playback loop
+	exx
	jp	Event_EndPlayback


Doing this will reduce the driver's size from 1EEh bytes to 1E6h bytes.

EDIT2: Here's another optimisation. This improves the speed and size of LoadDAC.

Move this...

	ld	b,0h


...above this:

	ld	(hl),0h


And then make both that line, and the 'ld h,0h' use register b instead of using the 0h. Doing this should save space and cycles. Unfortunately, the space freed will be padded by the align, and the optimisation is not in a cycle-intensive area.
This post has been edited by Clownacy: 01 December 2014 - 06:44 PM

  • 4 Pages +
  • ◄ First
  • 2
  • 3
  • 4
    Locked
    Locked Forum

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