diff genesis.s68 @ 3:97ec271a513f

Bunch of changes
author Mike Pavone <pavone@retrodev.com>
date Mon, 02 Sep 2013 21:22:47 -0700
parents
children 4ffd621f1d0c
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genesis.s68	Mon Sep 02 21:22:47 2013 -0700
@@ -0,0 +1,393 @@
+	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 $C0100080
+StaticColors equ 8
+
+USE_HINT equ 0
+	move.b  #$40, $A10009
+	move.l	#$C00000, a4
+	move.l	#$c00004, a5
+
+	move.l	#$0, a7
+
+	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
+
+
+
+	lea	BgData(pc), a0
+	move.w	(a0)+, d0	;size in words
+	move.w	(a0)+, d1	;width in cells
+	move.w	(a0)+, d2	;height in cells
+	move.w d2, d7
+
+	subq	#1, d0		;adjust for 68K dbra routine
+	move.w	#$8f02, (a5)	;autoincrement = 2
+	move.l	#$50200000, (a5);beginning of background tile area
+CopyTiles:
+	move.w	(a0)+, (a4)	;copy tiles to VRAM
+	dbra	d0, CopyTiles
+
+	move.l	#$40000000, d4	;beginning of Plane A Name table
+	move.l	#$00800000, d5	;delta between lines
+	move.w	#$81, d6
+	subq	#1, d1
+	subq	#1, d2
+	move.w	d1, d3
+WriteNamesY:
+	move.l	d4, (a5)
+	move.w	d3, d1
+
+WriteNamesX:
+	move.w	d6, (a4)
+	addq	#1, d6
+	dbra	d1, WriteNamesX
+
+	add.l	d5, d4
+	dbra	d2, WriteNamesY
+
+	move.l	#$C0000000, (a5)	;setup writes to CRAM
+	moveq	#(StaticColors-1), d0			;copy first 12 colors (static pallete)
+CopyColors:
+	move.w	(a0)+, (a4)
+	dbra	d0, CopyColors
+
+	move.l a0, (PalAddress).w
+
+
+	move.l	#$60000010, (a5)	;setup writes to VSRAM
+	move.w	#$0, (a4)		;vscroll = 0
+
+	move.l	#$7C000003, (a5)	;setup writes to HScroll Table FC00
+	move.w	#0, (a4)		;Plane A&B HScroll = 0;
+	move.w	#0, (a4)		;
+
+	move.l	#$78000003, (a5)	;clear sprite table
+	move.l	#0, (a4)
+	move.l	#0, (a4)
+
+	move.w	#$8114, (a5)		;turn on DMA
+
+	bsr	InitSprites
+	bsr	AddSprite
+
+	move.w	#$0, (a0)
+
+	bsr	LoadSpritePal
+	bsr	InitFrameBigSprite
+	moveq	#0, d3
+	bsr	ChangeFrameBigSprite
+
+
+
+
+	move.l	#CRAMDMACmd, d5		;setup DMA command word
+
+	move.w	#CRAMXferSizeCmd, (a5)		;set Transfer length
+	move.w	#$9400, (a5)
+
+	move.w	#$8114, d6
+	move.w	#$8174, d7
+
+	if USE_HINT
+
+		move.w	#$8014, (a5)
+		move.w	#$8A00, (a5)		;HINT occurs on every line
+	endif
+
+	move.w	#$8174, (a5)
+	move #$2300, SR
+
+
+Loop:
+	if USE_HINT
+		bra Loop
+	endif
+WaitTop:
+	cmpi.b  #$FF, 4(a5)
+	bne.s   WaitTop
+
+LineDone:
+	move.b	4(a5), d0
+WaitNextLine:
+	cmp.b	4(a5), d0
+	beq	WaitNextLine
+
+
+
+HINT:
+	;move.w	d6, (a5)
+	;move.l	d5, (a5)		;start DMA
+	;move.w	d7, (a5)
+	move.l d6, (a5)
+	move.l d7, (a5)
+	move.w	#CRAMXferSizeCmd, (a5)		;set Transfer length
+	move.w	#$9400, (a5)
+
+	if USE_HINT
+		rte
+	endif
+
+	cmp.b	#223, 4(a5)
+	beq	WaitTop
+
+	bra	LineDone
+
+VINT:
+	if USE_HINT
+		move.w	#$8144, (a5)
+	endif
+	bsr	SpriteCopyVRAM
+
+	bsr	ReadPad
+
+	bsr	Player1Vint
+
+	move.l	(PalAddress).w, d7			;setup DMA source address
+	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	d5, (a5)		;do DMA for first line
+
+	move.w	#CRAMXferSizeCmd, (a5)		;set Transfer length
+	move.w	#$9400, (a5)
+
+	move.w	#$8114, d6		;VDP commands to turn screen on and off during HBlank
+	swap d6
+	swap d5
+	move.w d5, d6
+	swap d5
+	move.w d5, d7
+	swap d7
+	move.w	#$8174, d7
+	if USE_HINT
+		move.w	d7, (a5)
+	endif
+	rte
+
+LoadSpritePal:
+	move.l	#$C0200000, (a5)
+	moveq	#$F, d0
+	lea	SpriteData, a0
+PalLoop:
+	move.w	(a0)+, (a4)
+	dbra	d0, PalLoop
+	rts
+
+Player1Vint:
+	move.b	(ButtonState).w, d2
+	move.b	(ButtonStateNew).w, d3
+
+	moveq	#0, d0
+	move.w	d0, d1
+
+	btst	#5, d2
+	bne	ScrollRight
+
+	btst	#7, d2
+	bne	ScrollLeft
+
+	btst	#4, d3
+	bne	IncrementFrame
+
+
+	btst	#6, d3
+	bne	DecrementFrame
+
+	btst	#2, d2
+	beq	PlayerShipNotLeft
+	subq	#1, d0
+PlayerShipNotLeft:
+
+	btst	#3, d2
+	beq	PlayerShipNotRight
+	addq	#1, d0
+PlayerShipNotRight:
+
+	btst	#0, d2
+	beq	PlayerShipNotDown
+	subq	#1, d1
+PlayerShipNotDown:
+
+	btst	#1, d2
+	beq	PlayerShipNotUp
+	addq	#1, d1
+PlayerShipNotUp:
+
+	bsr	MoveBigSprite
+
+	rts
+IncrementFrame:
+	move.w	(PlayerShipFrame), d3
+	addq	#1, d3
+	move.w	d3, (PlayerShipFrame)
+	bsr	ChangeFrameBigSprite
+
+	rts
+
+DecrementFrame:
+
+	move.w	(PlayerShipFrame), d3
+	subq	#1, d3
+	move.w	d3, (PlayerShipFrame)
+	bsr	ChangeFrameBigSprite
+
+	rts
+
+ScrollRight:
+	move.w	(ScrollValue), d0
+	subq	#1, d0
+	move.l	#$7C000003, (a5)	;setup writes to HScroll Table FC00
+	move.w	d0, (a4)
+	move.w	d0, (a4)
+	move.w	d0, (ScrollValue)
+
+	rts
+
+ScrollLeft:
+	move.w	(ScrollValue), d0
+	addq	#1, d0
+	move.l	#$7C000003, (a5)	;setup writes to HScroll Table FC00
+	move.w	d0, (a4)
+	move.w	d0, (a4)
+	move.w	d0, (ScrollValue)
+
+	rts
+
+	include	sprites.s68
+
+PlayerShipFrame:
+	dc.w 	0
+
+
+ScrollValue:
+	dc.w	0
+
+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
+
+
+SpriteData:
+	incbin	bultest.bin
+BgData:
+	incbin  logo.bin
+