Actions

SCHG How-to

SCHG How-to:Optimize Sonic 3 & Knuckles's Sound Driver

From Sonic Retro

Revision as of 01:55, 29 August 2018 by Shadow05 (talk | contribs) (Created page with "Some people like the Sonic 3 (& Knuckles) as is but there's somethings that are just weird. ==Optimizing YM2612 Data Send== At ''zWriteFMI'' and ''zWriteFMII'' you'll see thi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Some people like the Sonic 3 (& Knuckles) as is but there's somethings that are just weird.

Optimizing YM2612 Data Send

At zWriteFMI and zWriteFMII you'll see this.

; =============== S U B	R O U T	I N E =======================================
;
; Writes a reg/data pair to part I
;
; Input:  a    Value for register
;         c    Value for data

;sub_C2
zWriteFMI:
		ld	(zYM2612_A0), a					; Select YM2612 register
		nop									; Wait
		ld	a, c							; a = data to send
		ld	(zYM2612_D0), a					; Send data to register
		ret
; End of function zWriteFMI
; ---------------------------------------------------------------------------

;loc_CB
zWriteFMII_reduced:
		sub	4								; Strip 'bound to part II regs' bit
; ---------------------------------------------------------------------------

; =============== S U B	R O U T	I N E =======================================
;
; Writes a reg/data pair to part II
;
; Input:  a    Value for register
;         c    Value for data

;sub_CD
zWriteFMII:
		ld	(zYM2612_A1), a					; Select YM2612 register
		nop									; Wait
		ld	a, c							; a = data to send
		ld	(zYM2612_D1), a					; Send data to register
		ret
; End of function zWriteFMII

You see those nops?, these are mean't to wait for the Z80 but in the Knuckles Chaotix driver (disassembled by ValleyBell) you'll see this.

; =============== S U B	R O U T	I N E =======================================


WriteFMI:				; CODE XREF: SendFMFreq+37�p
					; SendFMFreq+3E�p ...
		ld	(4000h), a
		ld	a, c
		ld	(4001h), a
		ret
; End of function WriteFMI

; ---------------------------------------------------------------------------
; START	OF FUNCTION CHUNK FOR WriteFMIorII

WriteFMIIPart:				; CODE XREF: WriteFMIorII+C�j
		sub	4
; END OF FUNCTION CHUNK	FOR WriteFMIorII

; =============== S U B	R O U T	I N E =======================================


WriteFMII:				; CODE XREF: DoPause+11E�p
		ld	(4002h), a
		ld	a, c
		ld	(4003h), a
		ret
; End of function WriteFMII

As you can see the Knuckles Chaotix driver removes the nop so delete them in the S3K driver.

SCHG How-To Guide: Sonic the Hedgehog 3 and Knuckles
Fixing Bugs
Fix Blue Knuckles | Fix Tails' Respawn Speeds | Fix Super Sonic Bugs
Design Choices
Fix Scattered Rings' Underwater Physics | Edit Level Select Text & Pointers | Work with Water | Make the Slots Bonus Game Rotate Smoothly
Adding Features
Restore (Sonic 2) Options Menu