Page 2 of 2

Posted: Tue Jan 02, 2007 11:49 am
by Pascal
here's how i setup dma, for transfering a palette to CRAM palette 0
d0 = address of the palette to transfert

Code: Select all

   VDP_SetRegister	$13,((16)&$ff)			; set length
	VDP_SetRegister	$14,((0)&$ff)

	lsr.l	#1,d0			; low source d0 source
	move.w	#$9500,d3
	move.b	d0,d3
	move.w	d3,VDP_CTRL
	
	lsr.l	#8,d0			; mid source
	move.w	#$9600,d3
	move.b	d0,d3
	move.w	d3,VDP_CTRL

	lsr.l	#8,d0			; high source
	move.w	#$9700,d3
	move.b	d0,d3
	andi.b	#$7f,d3
	move.w	d3,VDP_CTRL

0:	move.b	VDP_CTRL,d0		; wait dma
	btst	#1,d0
	beq	0

	VDP_SetCRAMWriteAddrFlag 0,VDP_CTRL,$80	; command flag


*******************************************************************************
* MACRO:	VDP_SetCRAMWriteAddrMode(Adresse,Destination)
* DESCRIPTION:	Sets up the VDP for cram Write, calcs an address for
*		the CRAM write.
* PARAMETERS:	\1 address of CRAM,
*		\2 Where to store the result - long! (will typically be VCTRL)
*		\3 mode to or
*******************************************************************************
VDP_SetCRAMWriteAddrFlag macro
	move.l	#$C0000000|((\1&$3fff)<<16)|((\1>>14)&3)|\3,\2
	endm

*******************************************************************************
* MACRO         SetVdpRegister REGISTER,VALUE
* DESCRIPTION:  Puts a value into one of the Genesis's VDP registers.
*               This macro only works for CONSTANTS.
* PARAMETERS:   VDP Register #,
*               Value to place into the register
*******************************************************************************
VDP_SetRegister	macro
	move.w  #$8000|(\1<<8)|\2,VDP_CTRL	; check out the SEGA manual
	endm


Posted: Tue Jan 02, 2007 3:36 pm
by Stef
Try this way :
- prepare your DMA transfert (writing DMA reg values)
- wait for the HBlank (Hblank flag = 1)
- do the DMA

Another better method :
- prepare your DMA transfert (writing DMA reg values)
- test the H counter to be > X
- disable VDP display
- do DMA
- enable VDP

Mickey Mania does that in the stag's race level to maximise the DMA capabilities.
By the way, you don't need to test for the DMA completion.
The 68K is frozen during all the DMA operation in case of a external memory -> VRAM / CRAM / VSRAM DMA.

Anyway 16 colors during a single scanline seems to be a bit optimist, try to lower to 8 colors only.

Posted: Tue Jan 02, 2007 8:07 pm
by ob1
Stef wrote:Try this way :
- prepare your DMA transfert (writing DMA reg values)
- wait for the HBlank (Hblank flag = 1)
- do the DMA
Wht a clever way ! I'll try it.
Stef wrote:Anyway 16 colors during a single scanline seems to be a bit optimist, try to lower to 8 colors only.
Ouch !!! It's going to be quite hard, so !!!

Posted: Wed Jan 03, 2007 9:32 am
by TmEE co.(TM)
ob1, your site is down... I'm not sure what the text says (I don't understand French) but it is related to "unavailable" I guess.

Posted: Wed Jan 03, 2007 10:56 am
by Stef
Site isn't down :
http://perso.orange.fr/olivier.brosseron

ob1 forgot to remove the ending point and the URL became wrong.

Posted: Wed Jan 03, 2007 2:13 pm
by TmEE co.(TM)
now it works. Too bad that I don't know French language... none of you know Estonian so we're even

Posted: Wed Jan 03, 2007 4:28 pm
by ob1
Stef wrote:ob1 forgot to remove the ending point and the URL became wrong.
Thanks Stef' for pointing it out.
It's corrected now.