[TI ASM] 16x16 masked sprite
Moderator: MaxCoderz Staff
- kv83
- Maxcoderz Staff
- Posts: 2735
- Joined: Wed 15 Dec, 2004 7:26 pm
- Location: The Hague, Netherlands
- Contact:
[TI ASM] 16x16 masked sprite
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!
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!
-
- Calc King
- Posts: 2195
- Joined: Sun 27 Mar, 2005 4:06 am
- Location: sleeping
- Contact:
- Jim e
- Calc King
- Posts: 2457
- Joined: Sun 26 Dec, 2004 5:27 am
- Location: SXIOPO = Infinite lives for both players
- Contact:
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.
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.
- kv83
- Maxcoderz Staff
- Posts: 2735
- Joined: Wed 15 Dec, 2004 7:26 pm
- Location: The Hague, Netherlands
- Contact:
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 toobenryves 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).
anyway, can you send me the source? pretty please?
- kv83
- Maxcoderz Staff
- Posts: 2735
- Joined: Wed 15 Dec, 2004 7:26 pm
- Location: The Hague, Netherlands
- Contact:
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?
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
- Jim e
- Calc King
- Posts: 2457
- Joined: Sun 26 Dec, 2004 5:27 am
- Location: SXIOPO = Infinite lives for both players
- Contact:
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.
It'd be easier to modify this and
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