VDP Tools ? (calc)

For anything related to VDP (plane, color, sprite, tiles)

Moderators: BigEvilCorporation, Mask of Destiny

Post Reply
Nainain
Interested
Posts: 14
Joined: Sat Oct 11, 2014 3:34 pm

VDP Tools ? (calc)

Post by Nainain » Mon Oct 24, 2016 6:42 pm

Hello SpritesMind,

I continue to learn the "low level" stuff on Megadrive ...
Have u some VPD tools (calc, registers helper) ?

I ve starting the coding of a tool for help me to dealing with vdp, but maybe you ve something already finished (forge vdp packet ..., registers ... ) ?
i ve found this http://www.hacking-cult.org/?vdp

Please share with me your "VDP tools" ...

User avatar
Natsumi
Very interested
Posts: 81
Joined: Mon Oct 05, 2015 3:00 pm
Location: 0x0
Contact:

Re: VDP Tools ? (calc)

Post by Natsumi » Thu Oct 27, 2016 2:23 pm

A lot of the time I use this bot called DocScratch (also ChaosGamma) on irc.badnik.zone that has a !vdp command, to convert from and to VDP commands. I also have the following macros for laziness' sake;

Code: Select all

vdpComm		macro ins,addr,type,rwd,end,end2
	if narg=5
		\ins #(((\type&\rwd)&3)<<30)|(((\addr)&$3FFF)<<16)|(((\type&\rwd)&$FC)<<2)|(((\addr)&$C000)>>14), \end

	elseif narg=6
		\ins #(((((\type&\rwd)&3)<<30)|(((\addr)&$3FFF)<<16)|(((\type&\rwd)&$FC)<<2)|(((\addr)&$C000)>>14))\end, \end2

	else
		\ins (((\type&\rwd)&3)<<30)|(((\addr)&$3FFF)<<16)|(((\type&\rwd)&$FC)<<2)|(((\addr)&$C000)>>14)
	endif
    endm
 
; ===========================================================================
; values for the type argument
VRAM =  %100001
CRAM =  %101011
VSRAM = %100101

; values for the rwd argument
READ =  %001100
WRITE = %000111
DMA =   %100111

; ===========================================================================
; tells the VDP to copy a region of 68k memory to VRAM or CRAM or VSRAM
dma68kToVDP macro source,dest,length,type
		move.l	#(($9400|((((length)>>1)&$FF00)>>8))<<16)|($9300|(((length)>>1)&$FF)),(a5)
		move.l	#(($9600|((((source)>>1)&$FF00)>>8))<<16)|($9500|(((source)>>1)&$FF)),(a5)
		move.w	#$9700|(((((source)>>1)&$FF0000)>>16)&$7F),(a5)
	vdpComm	move.l,\dest,\type,DMA,(a5)
    endm
; ===========================================================================

vdpcomm move.l,4,CRAM,WRITE,(a6)
vdpcomm dc.l,$20,VSRAM,WRITE
vdpcomm ori.l,$1234,VRAM,DMA,d2
vdpcomm move.w,$1234,VRAM,DMA,>>16)&$FFFF,$FFFF8234.w
dma68kToVDP SomeArt,$1234,$400,VRAM
Do note that this macro is made for ASM68K specifically, so you probably need to modify it for any other assembler/compiler.

User avatar
Sik
Very interested
Posts: 705
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: VDP Tools ? (calc)

Post by Sik » Thu Oct 27, 2016 4:50 pm

Jeeeeeeeez that vdpComm macro looks like a mess O.O I normally use something like this instead, it may be more limited as it only does MOVE but I never had the need for anything else (and for that matter, that \where argument can be anything, e.g. ($C00004), 4(a0) or d7):

Code: Select all

SetXRAMAddr: macro addr, where, cmd
    move.l  (\cmd)|(((\addr)&$3FFF)<<16)|((\addr)>>14), \where
    endm

SetVRAMAddr: macro addr, where
    SetXRAMAddr \addr, \where, $40000000
    endm

SetCRAMAddr: macro addr, where
    SetXRAMAddr \addr, \where, $C0000000
    endm

SetVSRAMAddr: macro addr, where
    SetXRAMAddr \addr, \where, $40000010
    endm
My DMA macros these days are more like yours, though again they follow the same pattern of multiple macros piggybacking on another generic one.

EDIT: oh by the way, if you ever need to calculate a command on the fly, you can always resort to something like this (optimize or change as needed):

Code: Select all

    and.l   #$FFFF, d0
    lsl.l   #2, d0
    lsr.w   #2, d0
    or.w    #$4000, d0
    swap    d0
Sik is pronounced as "seek", not as "sick".

User avatar
Natsumi
Very interested
Posts: 81
Joined: Mon Oct 05, 2015 3:00 pm
Location: 0x0
Contact:

Re: VDP Tools ? (calc)

Post by Natsumi » Thu Oct 27, 2016 8:00 pm

Yes it is a mess, but it is also very versatile. You can replicate any possible combination of instructions and modifiers to do anything you like. You could do that or.w #$4000,d0 with the macro too, and make it "easier to edit" :P

Nainain
Interested
Posts: 14
Joined: Sat Oct 11, 2014 3:34 pm

Re: VDP Tools ? (calc)

Post by Nainain » Sun Nov 13, 2016 3:19 pm

Thanks, cool these macros

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests