[TI ASM] 16x16 masked sprite

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

[TI ASM] 16x16 masked sprite

Post by kv83 »

Does anyone know of a good 16x16 masked sprite routine? I could only find the "The Best Damn Sprite Routine Period (Mask Version)" by Sigma, but unfortunatly that routine is only for 8x*...

So if you have one, and would like to share, please do so. A clipped one would be even more awesome, but not neccesary :)

Thanks!
Image
threefingeredguy
Calc King
Posts: 2195
Joined: Sun 27 Mar, 2005 4:06 am
Location: sleeping
Contact:

Post by threefingeredguy »

Jim e made one for his GS package that can be easily adapted to this purpose.
Image
User avatar
Jim e
Calc King
Posts: 2457
Joined: Sun 26 Dec, 2004 5:27 am
Location: SXIOPO = Infinite lives for both players
Contact:

Post by Jim e »

It was actually a bit of a change, This is just a modified version of the one I had with RGP. It makes the grey scale into a clipped BW masked sprite routine.

http://www.txjim.com/cliptest.z80

I doubt its quite as fast as sigmas but most people aren't willing to interlace there sprites.

Edit:Stupid me, I just noticed 16x16.
Image
leofox
Calc Master
Posts: 1064
Joined: Fri 17 Dec, 2004 3:22 pm
Location: Probably playing DDR
Contact:

Post by leofox »

you can easily use a couple of 8x8 sprite routines for 16x16. Shouldn't be too slow either if you use sigma's routine for example.
Image
Image
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

leofox wrote:you can easily use a couple of 8x8 sprite routines for 16x16. Shouldn't be too slow either if you use sigma's routine for example.
problem is that I have to manualy edit all my 16x16 sprites to do that. (btw; 8x16 is even easier, but the same problem...)
Image
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

I have one but it's probably not the world's fastest and it stores the mask in a strange format for speed reasons (it 'interlaces' the mask and image data, rather than being two sprites, one for mask and one for image).
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

benryves wrote:I have one but it's probably not the world's fastest and it stores the mask in a strange format for speed reasons (it 'interlaces' the mask and image data, rather than being two sprites, one for mask and one for image).
if it's sprite_row, mask_row, sprite row, mask_row, etc. , etc. ... than you are not the only one who uses that format, since Sigma uses that format too

anyway, can you send me the source? pretty please?
Image
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

I'll dig it out, then - you'll have to wait until tomorrow for it, though (sorry).
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

benryves wrote:I'll dig it out, then - you'll have to wait until tomorrow for it, though (sorry).
np
Image
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

I have a few masked 16x16 routines lying around somewhere ... but you'l have to wait until i get home too :).

I though that you would be able to write one anyway kv83?
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

I though that you would be able to write one anyway kv83?
I guess I am, but why reinvite the wheel? It's just another source for errors, debugging and slowing down the progress of my project :)

would be nice if I can choose between different ones :D thnx guys
Image
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

Hey guys, no need anymore. I got around to re-adjust sigma's routine, so thanks anyway :)
Image
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

Good thing too, as I forgot entirely about it. :oops:
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

Hmmm... i feel so noobish. I am still stucked with the 16x16 routine. I mean, I am able to make a workaround (by drawing to 8x16 sprites), but i want the routine just to be able to accept 16x16...

Below is the code. Any pointers/idea's what part should be changed to make it 16x16?

Code: Select all

; The Best Damn Sprite Routine Period (Mask Version)
; 
; AUTHOR: Sean McLaughlin (sigma_zk@yahoo.com)
;
; DESCRIPTION:
;	Masks a sprite to PlotSScreen with clipping.
;
; INPUT:
;	D	Abscissa (x)
;	E	Ordinate (y)
;	HL	Pointer to start of sprite data:
;		number of rows; sprite row 1, mask row 1; sprite row 2, mask row 2; et cetera.
; DESTROYS:
;	AF BC DE HL IX
;	Interrupts are disabled
;
.MODULE _TBDSRP_M
#define	M_PIXEL_SHIFT	.DB $CB,$31,$17,$29	; SLL C\  RLA\  ADD HL,HL
ClipSprite_MASK:
	LD	B,16
	DEC    HL
	LD	A,E
	CP	$80
	JR	C,_PosY
	NEG
	CP	B
	RET	P
	LD	C,A
	NEG
	ADD	A,B
	LD	B,0
	SLA	C
	ADD	HL,BC
	LD	E,B
	LD	B,A
_PosY:
	CP	64
	RET	NC
_ClipBtm:
	ADD	A,B
	SUB	65
	JR	C,_DoHoriz
	SUB	B
	CPL
	LD	B,A
_DoHoriz:
	LD	A,D
	CP	$80
	JR	C,_PosX
	CP	-7
	RET	C
	LD	IX,_ClipLeft
	JR	_Patch
_PosX:
	CP	96
	RET	NC
	CP	89
	LD	IX,_ClipRight
	JR	C,_DoSprite
_Patch:
	LD	(IX),0
_DoSprite:
	DI
	INC	HL
	LD	(_save),SP
	LD	SP,HL
	SLA	E
	SLA	E
	LD	L,E
	LD	H,0
	LD	D,H
	ADD	HL,HL
	ADD	HL,DE
	LD	E,A
	SRA	E
	SRA	E
	SRA	E
	JP	P,_Pos
	DEC	D
_Pos:
	ADD	HL,DE
	LD	DE,PlotSScreen
	ADD	HL,DE

	AND	7
	JR	Z,_Aligned
	DEC	A
	ADD	A,A
	ADD	A,A
	LD	(_Jump),A

_Loop:
	POP	DE
	XOR	A
	LD	C,D
	LD	D,A
	DEC	A
	EX	DE,HL
_Jump	=$+1
	JR	$
	M_PIXEL_SHIFT
	M_PIXEL_SHIFT
	M_PIXEL_SHIFT
	M_PIXEL_SHIFT
	M_PIXEL_SHIFT
	M_PIXEL_SHIFT
	M_PIXEL_SHIFT
	EX	DE,HL
	AND	(HL)
	XOR	D
_ClipLeft:
	LD	(HL),A
	INC	HL
	LD	A,C
	AND	(HL)
	XOR	E
_ClipRight:
	LD	(HL),A
	LD	DE,11
	ADD	HL,DE
	DJNZ	_Loop
	LD	(IX),$77
_Done:
_save	=$+1
	LD	SP,0
	RET

_Aligned:
	LD	DE,12
	LD	A,B
_ALoop:
	POP	BC
	EX	AF,AF'
	LD	A,(HL)
	AND	B
	XOR	C
	LD	(HL),A
	ADD	HL,DE
	EX	AF,AF'
	DEC	A
	JP	NZ,_ALoop
	JP	_Done
Image
User avatar
Jim e
Calc King
Posts: 2457
Joined: Sun 26 Dec, 2004 5:27 am
Location: SXIOPO = Infinite lives for both players
Contact:

Post by Jim e »

Well personally I think Calling anything best this or that is a matter of opinion. Some people may perfer size over speed.

anyway I wrote a grayscale one. So this is a modified version of it. I never finished the cliping, but this *should* work. looks like there is room for optimisation.

Code: Select all

;--------
;ummm....
;Looks like the inputs are
;L = Y
;A = x
;C = width
;B = height
;IX = sprite (mask, then BW)

gsLargeSpritemasked:
	sla l			;*2
	sla l			;*4
	ld e,l
	ld h,$00
	ld d,h
	add hl,de		;*8
	add hl,de		;*12
	ld e,a
	and $07
	xor 7
	ld (gslargerotate2m),a
	add a,a
	ld (gslargerotate1m),a
	ld a,$ff
gslargerotate1m = $+1
	jr $
	srl a
	srl a
	srl a
	srl a
	srl a
	srl a
	srl a
	ld (gslargemask2m),a
	cpl
	ld (gslargemask1m),a
	srl e
	srl e
	srl e
	add hl,de

	ld a,c
	ld (gslargewidthm),a   ;why am I flipping b and c
	ld c,b

	ld a,$a6
	ld (swapmask3l),a
	ld (swapmask4l),a

	ld a,$b2		;or d
	ld (swapmask1l),a

	ld a,$f6		;or *
	ld (swapmask2l),a


	ld	de,gbuf
	add hl,de


	push hl

	push bc
	call gsLargeRowm
	pop bc
	pop hl

	ld a,$b6
	ld (swapmask3l),a
	ld (swapmask4l),a

	ld a,$a2		;and d
	ld (swapmask1l),a

	ld a,$e6		;and *
	ld (swapmask2l),a

	ld a,(gslargemask2m)
	cpl
	ld (gslargemask2m),a
	ld a,(gslargemask1m)
	cpl
	ld (gslargemask1m),a

gsLargeRowm:
	push hl
gslargewidthm = $+1
	ld b,0
gsLargemask1m = $+1
	ld d,0
gsLargeColm:
	ld a,(ix)
	inc ix
gsLargerotate2m = $+1
	jr $
	rrca
	rrca
	rrca
	rrca
	rrca
	rrca
	rrca
	ld e,a
swapmask1l:
	and d
swapmask3l:
	or (hl)
	ld (hl),a
	inc hl
	ld a,e
swapmask2l:
gsLargemask2m = $+1
	and 0
swapmask4l:
	or (hl)
	ld	(hl),a
	djnz gsLargeColm
	pop hl
	ld de,12
	add hl,de
	dec c
	jp nz,gsLargeRowm
	ret
It'd be easier to modify this and
Image
Post Reply