Function Name: DMA CALL

Purpose: Send command to DMA device
Call address: $FF50 (hex) 65360 (decimal)

	Registers:	.X = bank (0-15)
			.Y = DMA controller command
	Memory:		DMA registers set up system map
	Flags:		none
	Calls:		none
	Registers:	.A used
			.X used
	Memory:		changed as per command
	Flags:		none

Description: DMA CALL is designed to communicate with an external expansion car- tridge capable of DMA and mapped into system memory at 102 ($DFxx). The DMA CALL converts the logical C128 bank parameter to MMU configuration via GETCFG, OR's in the I/O enable bit, and transfers control to RAM code at $3F0. Here the C128 bank specified is brought into context, and the user's command is issued to the DMA controller. The actual DMA transfer is performed at this point, with the 8502 kept off the bus in a wait state. As soon as the DMA controller releases the processor, memory is reconfigured to the state it was in at the time of the call and control is returned to the caller. The user must analyze the completion status by reading the DMA status register at $DF00.
Care should be taken in the utilization of the C128 RAM expansion product by any application using the built-in Kernal interface. This includes especially the use of the C128 BASIC commands FETCH, STASH and SWAP. In the routine that prepares a DMA request for the user, the Kernal forces the I/O block to be always in context. Consequently, data from the DMA device is likely to corrupt sensitive I/O devices. Users should either bypass the Kernal DMA routine by providing their own interface, or limit the DMA data transfers to the areas above and below the I/O block. Only strict observance of the latter will guarantee proper utilization of the BASIC commands. The following code, used instead of the DMA CALL in the above example, illustrates a work-around:

	LDX	#$00	;C128 bank
	LDY	#$84	;DMA command to "STASH"
	JSR	$3F0	;execute DMA command


	LDA	#$00	;setup C128 base address
	STA	$DF02	;low
	LDA	#$20
	STA	$DF03	;high

	LDA	#$00	;setup expansion RAM address
	STA	$DF04	;low
	STA	$DF05	;high
	STA	$DF06	;bank (0-n, where n = 3 if 256K)

	LDA	#$40	;setup number of bytes
	STA	$DF07	;low
	LDA	#$1F
	STA	$DF08	;high

	LDX	#$00	;C128 bank
	LDY	#$84	;DMA command to "STASH"
	JSR	$FF50	;execute DMA command