68k/Z80 communication: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
Line 12: Line 12:


Many drivers acknowledge sound commands by echoing them back with bit 7 set to 1 when they are processed.
Many drivers acknowledge sound commands by echoing them back with bit 7 set to 1 when they are processed.
[[Catégorie:Audio system]]


== Special cases ==
== Special cases ==
Line 41: Line 39:
retn ; RETN to 0
retn ; RETN to 0
</pre>
</pre>
[[Category:Audio system]]

Revision as of 08:15, 7 February 2011

68k to Z80

Writes to the Z80 are byte-wide and made through $320001.
Any byte can be sent, their meaning are only determined by the way the Z80 code handles them except for 3 special cases, as seen below.

When a byte is sent, the corresponding value is buffered in either the NEO-SUD or NEO-G0 chip, and an NMI is generated on the Z80. It can then be read on port $00.

Z80 to 68k

Port $0C is used to reply to the 68K. The value is also buffered in the same chips, but there's no interrupts generated. The value can be read by using the same register, $320001.

Many drivers acknowledge sound commands by echoing them back with bit 7 set to 1 when they are processed.

Special cases

Commands $01 and $03 are always expected to be implemented as they are used by the BIOSes for initialization purposes. Typically, if the Z80 doesn't reply to command $01 in time, the "Z80 ERROR" message is displayed and the system locks up.

Command $03 is then sent to ask for a soft reset of the Z80, but no replies are expected.

Command $02 is used by cartridge systems to play the boot music. The pattern (melody) was certainly imposed by SNK, but developers often chose their own instruments parameters. Boot music.

These are sufficient handlers for both init commands:

Command01_Handler:		; with the command in A
	di			; disable interrupts
	ld   sp, $FFFF		; clear call stack
	out ($0C),a		; echo the command
	jr NMI_End		; usually POPs, then RETN
Command03_Handler:		; with the command in A
	di			; disable interrupts
	ld   sp, $FFFF		; clear call stack
	ld hl,0
	push hl
	retn			; RETN to 0