diff directcolor.s68 @ 11:19226d79f839

Add direct color DMA demo and converter
author Mike Pavone <pavone@retrodev.com>
date Fri, 06 Sep 2013 19:09:19 -0700
parents
children 30f1d4c90900
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/directcolor.s68	Fri Sep 06 19:09:19 2013 -0700
@@ -0,0 +1,191 @@
+	dc.l $0, start
+	dc.l empty_handler
+	dc.l empty_handler
+	;$10
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	;$20
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	;$30
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	;$40
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	;$50
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	;$60
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	;$70
+	dc.l HINT
+	dc.l empty_handler
+	dc.l VINT
+	dc.l empty_handler
+	;$80
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	;$90
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	;$A0
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	;$B0
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	;$C0
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	;$D0
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	;$E0
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	;$F0
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.l empty_handler
+	dc.b "SEGA"
+empty_handler:
+	rte
+start:
+;background and sprite test
+
+ButtonState	equ	$FFFFEFF0
+ButtonStateNew	equ	ButtonState+2
+PalAddress equ ButtonStateNew+2
+
+CRAMXferSizeCmd equ $9308
+CRAMDMACmd equ $C0000080
+
+	move.b  #$40, $A10009
+	move.l	#$C00000, a4
+	move.l	#$c00004, a5
+
+	move.l	#$0, a7
+
+	move.w	#$8004, (a5)
+	move.w	#$8104, (a5)	;turn off display
+	move.w	#$8200, (a5)	;Table A = 0000
+	move.w	#$8400, (a5)	;Table B = 0000
+	move.w	#$857C, (a5)	;Sprite Table = F800
+	move.w	#$8B00, (a5)		;set full screen vertical and horizontal scrolling
+	move.w  #$8C01, (a5)    ;H40 mode, no shadow/hilight, no interlace
+	move.w	#$8D3F, (a5)	;H Scroll = FC00
+	move.w	#$9001, (a5)	;64x32 scroll tables
+
+
+
+
+
+	move #$2300, SR
+
+Top:
+	lea	BgData(pc), a0 ;set DMA source address
+	move.l a0, d7
+	sub.l	#258, d7
+	move.w	#$9500, d6
+	ror.l	#1, d7
+	move.b	d7, d6
+	move.w	d6, (a5)
+	ror.l	#8, d7
+	move.b	d7, d6
+	add.w	#$100, d6
+	move.w	d6,(a5)
+	ror.l	#8, d7
+	move.b	d7, d6
+	add.w	#$100, d6
+	and.b	#$7F, d6
+	move.w	d6,(a5)
+
+	move.l  #$94AE9342, (a5) ;set DMA length
+
+	move.w #$8F00, (a5) ;set auto-increment to 0
+
+	move.w	#$8174, (a5)
+
+
+	move.l #$40000000, (a5) ;Setup VRAM writes
+	addq #1, a5
+WaitVBlank:
+	btst.b #3, (a5)
+	beq.s WaitVBlank
+WaitActive:
+	btst.b #3, (a5)
+	bne.s   WaitActive
+
+	move.l d0, (a4) ;fill FIFO
+	move.l d0, (a4)
+	move.w d0, (a4)
+	subq #1, a5
+	move.w #$8114, (a5) ;turn off display
+	nop
+	nop
+	nop
+	nop
+	move.l #$C0000080, (a5)
+
+	bra Top
+
+
+
+HINT:
+	rte
+VINT:
+	bsr	ReadPad
+	rte
+
+
+ReadPad:
+	move.b	#$FF, $a10003	;set TH for controller A
+	move.b	$a10003, d0	;CBRLUD
+	andi.b	#$3F, d0
+	move.b	#0, $a10003
+	move.b	$a10003, d1	;SA00UD
+	andi.b	#$30, d1
+	lsl.b	#2, d1
+	or.b	d1, d0		;SACBRLUD
+	not.b	d0
+	move.b	(ButtonState).w, d1
+	eor.b	d0, d1
+	and.b	d0, d1
+	move.b	d0, (ButtonState).w
+	move.b	d1, (ButtonStateNew).w
+
+	rts
+
+
+BgData:
+	incbin  dcolor.bin
+