Author |
Message |
|
cjgone Aw3s0m3
Active Member
Joined: 24 May 2006 Posts: 693
|
Posted: 13 Jul 2008 09:28:20 pm Post subject: |
|
|
What is the masked sprite routine for and\or?
The routine in 28 days is typoed. Plz respond ASAP.
gr, i want to update my prog but i can't without knowin the masked sprite routine..!!11!!!!!
Last edited by Guest on 13 Jul 2008 09:34:33 pm; edited 1 time in total |
|
Back to top |
|
|
cjgone Aw3s0m3
Active Member
Joined: 24 May 2006 Posts: 693
|
Posted: 13 Jul 2008 10:50:17 pm Post subject: |
|
|
So desperate i'm gonna double post. UGHHH.
I really need to know the AND\OR sprite routine so I can do my secret project.
Last edited by Guest on 13 Jul 2008 11:00:03 pm; edited 1 time in total |
|
Back to top |
|
|
magicdanw pcGuru()
Calc Guru
Joined: 14 Feb 2007 Posts: 1110
|
|
Back to top |
|
|
cjgone Aw3s0m3
Active Member
Joined: 24 May 2006 Posts: 693
|
Posted: 13 Jul 2008 11:38:33 pm Post subject: |
|
|
Thank you <3. |
|
Back to top |
|
|
WikiGuru ADOS (Attention deficit... Oh! Shiny!)
Elite
Joined: 15 Sep 2005 Posts: 923
|
Posted: 14 Jul 2008 12:09:57 am Post subject: |
|
|
I wrote one a while back. I can't seem to find it, though. |
|
Back to top |
|
|
cjgone Aw3s0m3
Active Member
Joined: 24 May 2006 Posts: 693
|
Posted: 14 Jul 2008 12:42:39 am Post subject: |
|
|
dan, aren't those clipped sprite routines ?:S
I need an unclipped Mask routine. :o
[edit] yer, wrong person
Last edited by Guest on 14 Jul 2008 03:49:36 pm; edited 1 time in total |
|
Back to top |
|
|
tr1p1ea
Elite
Joined: 03 Aug 2003 Posts: 870
|
Posted: 14 Jul 2008 02:46:24 am Post subject: |
|
|
When you AND something to the graph buffer anything black will show through and anything white will be overwritten since thats the nature of AND. A small mod of your sprite routine to AND the mask before ORing the sprite should suffice. Then again, arent you using RGP? I thought jim included a masked sprite routine? |
|
Back to top |
|
|
magicdanw pcGuru()
Calc Guru
Joined: 14 Feb 2007 Posts: 1110
|
Posted: 14 Jul 2008 03:39:16 am Post subject: |
|
|
TheStorm? Do you mean magicdanw? Yes, they're clipped, but there is one routine in there that is a clipped and masked routine. And clipped doesn't hurt, unless you absolutely need more speed..... |
|
Back to top |
|
|
tr1p1ea
Elite
Joined: 03 Aug 2003 Posts: 870
|
Posted: 16 Jul 2008 08:11:40 am Post subject: |
|
|
I wrote you a *very simple* example for an 8*8 masked sprite routine to illustrate how it can be done. It should work as advertised though its only b&w:
Code: ;-------------------------------------------------
; 8*8 Masked Sprite
;-------------------------------------------------
; a = x
; l = y
; ix = mask followed by sprite data
;
; note: this could be easily modified to an 8*n
; routine with a tiny bit of smc to change the
; ix offset when moving from mask to sprite data
;
putMaskedSprite:
ld e,l
ld h,0
ld d,h
add hl,hl
add hl,de
add hl,hl
add hl,hl
ld e,a
and %00000111
ld c,a
srl e
srl e
srl e
add hl,de ; hl = (y * 12) + x
ld de,plotsScreen
add hl,de
ld b,8
_sprloop:
push bc
ld a,c
ld d,(ix + 0) ; mask
ld b,(ix + 8) ; sprite (modify for 8*n)
ld e,%11111111
ld c,0
or a
jr z,_copyloop
_shiftloop:
srl d ; shift mask
set 7,d ; i know :S
rr e
srl b ; shift sprite
rr c
dec a
jr nz,_shiftloop
_copyloop:
ld a,(hl)
and d ; and mask
or b ; or sprite
ld (hl),a
inc hl
ld a,(hl)
and e ; and mask
or c ; or sprite
ld (hl),a
ld de,11
add hl,de
inc ix
pop bc
djnz _sprloop
ret
Example mask/sprite data:
Code: sprData:
.db %11100111 ; mask
.db %11000011 ; 1 = transparent
.db %10000001 ; 0 = opaque
.db %00000000
.db %00000000
.db %10000001
.db %11000011
.db %11100111
.db %00011000 ; sprite
.db %00111100
.db %01111110
.db %11111111
.db %11111111
.db %01111110
.db %00111100
.db %00011000
|
|
Back to top |
|
|
cjgone Aw3s0m3
Active Member
Joined: 24 May 2006 Posts: 693
|
Posted: 16 Jul 2008 01:32:48 pm Post subject: |
|
|
thanks. |
|
Back to top |
|
|
Liazon title goes here
Bandwidth Hog
Joined: 01 Nov 2005 Posts: 2007
|
Posted: 16 Jul 2008 07:49:24 pm Post subject: |
|
|
tr1p1ea wrote: Then again, arent you using RGP? I thought jim included a masked sprite routine?
[post="125241"]<{POST_SNAPBACK}>[/post]
don't think so. iirc it was aligned but masked. |
|
Back to top |
|
|
Cryzbl
Newbie
Joined: 20 Jun 2008 Posts: 46
|
Posted: 16 Jul 2008 08:51:20 pm Post subject: |
|
|
Took a quick look at the routine:
Code: PutSpriteMask:
; Displays an 8x8 masked sprite
; A = x coordinate
; E = y coordinate
; IX = address of sprite
; IX + 8 = address of mask
LD H, 0
LD D, H
LD E, L; <-- !!
ADD HL, HL
ADD HL, DE
ADD HL, HL
ADD HL, HL
It says input row in E, yet it is overwritten by L. Should be the other way around. Didn't test whether that was the only bug.
:)
Though just use sigma's Best D*mn Sprite Routine Period routines. They truly are amazing (especially the masked one).
Last edited by Guest on 16 Jul 2008 08:54:43 pm; edited 1 time in total |
|
Back to top |
|
|
cjgone Aw3s0m3
Active Member
Joined: 24 May 2006 Posts: 693
|
Posted: 16 Jul 2008 10:22:27 pm Post subject: |
|
|
Yup, a few typos in sigma's routines ;o |
|
Back to top |
|
|
tr1p1ea
Elite
Joined: 03 Aug 2003 Posts: 870
|
Posted: 17 Jul 2008 01:24:17 am Post subject: |
|
|
In case you were wondering, to modify that routine to an 8*n one you can just use some smc to change the offset when grabbing the sprite byte like so:
Code: ;-------------------------------------------------
; 8*8 Masked Sprite
;-------------------------------------------------
; a = x
; l = y
; b = height
; ix = mask followed by sprite data
;
putMaskedSprite:
ld e,l
ld h,0
ld d,h
add hl,hl
add hl,de
add hl,hl
add hl,hl
ld e,a
and %00000111
ld c,a
srl e
srl e
srl e
add hl,de ; hl = (y * 12) + x
ld de,plotsScreen
add hl,de
ld a,b
ld (_sprloop + 7),a ; modify height
_sprloop:
push bc
ld a,c
ld d,(ix + 0) ; mask
ld b,(ix + 8) ; sprite (modified height)
ld e,%11111111
ld c,0
or a
jr z,_copyloop
_shiftloop:
srl d ; shift mask
set 7,d ; i know :S
rr e
srl b ; shift sprite
rr c
dec a
jr nz,_shiftloop
_copyloop:
ld a,(hl)
and d ; and mask
or b ; or sprite
ld (hl),a
inc hl
ld a,(hl)
and e ; and mask
or c ; or sprite
ld (hl),a
ld de,11
add hl,de
inc ix
pop bc
djnz _sprloop
ret
Last edited by Guest on 17 Jul 2008 01:25:19 am; edited 1 time in total |
|
Back to top |
|
|
Cryzbl
Newbie
Joined: 20 Jun 2008 Posts: 46
|
Posted: 17 Jul 2008 08:51:32 am Post subject: |
|
|
tr1p1ea wrote: Code: ; ...
_shiftloop:
srl d ; shift mask
set 7,d ; i know :S
; ...
Can't that be optimized to
Code: _shiftloop:
scf
rr d
And instead of OR'ing the sprite, you should XOR it for more options
Yeah, I know that wasn't the point of your modification, but I felt I had to point those out.
Last edited by Guest on 17 Jul 2008 08:53:57 am; edited 1 time in total |
|
Back to top |
|
|
tr1p1ea
Elite
Joined: 03 Aug 2003 Posts: 870
|
Posted: 17 Jul 2008 09:56:04 am Post subject: |
|
|
I was waiting for someone to point that out .
Bare in mind that the routine in purely educational. I was debating on what exactly to use there since i was trying to show what needs to be done in a masked sprite routine, specifically the need to set bit 7 when shifting the mask. In hindsight i guess setting the carry before a rotate makes just as much sense, i just didnt think it would be as clear.
I personally would never have a shifting loop like that in the first place anyway *hides*. |
|
Back to top |
|
|
Cryzbl
Newbie
Joined: 20 Jun 2008 Posts: 46
|
Posted: 18 Jul 2008 05:16:57 am Post subject: |
|
|
tr1p1ea wrote: I personally would never have a shifting loop like that in the first place anyway *hides*.
[post="125385"]<{POST_SNAPBACK}>[/post]
Hehe, agreed. Sigma's trick is the way to go. |
|
Back to top |
|
|
hotdog1234
Advanced Member
Joined: 14 Aug 2009 Posts: 291
|
Posted: 02 Sep 2009 07:52:41 pm Post subject: |
|
|
Sigma's code seems to have self-modifying code. I could be wrong, but my question is, has anyone tested the routine on Applications rather than ASM programs? |
|
Back to top |
|
|
simplethinker snjwffl
Active Member
Joined: 25 Jul 2006 Posts: 700
|
Posted: 02 Sep 2009 08:06:44 pm Post subject: |
|
|
Hot Dog wrote: Sigma's code seems to have self-modifying code. I could be wrong, but my question is, has anyone tested the routine on Applications rather than ASM programs?
Are you talking about the ld (HL),A 's in the code? In the code, HL points to the graph buffer which is always in RAM. It doesn't modify any of the code that's executing and even in an app there's no chance of it trying to write to flash.
Last edited by Guest on 05 Jul 2010 08:08:17 am; edited 1 time in total |
|
Back to top |
|
|
hotdog1234
Advanced Member
Joined: 14 Aug 2009 Posts: 291
|
Posted: 02 Sep 2009 08:12:53 pm Post subject: |
|
|
Quote: Are you talking about the ld (HL),A 's in the code?
Actually, I'm talking about this:
_Jump =$+1
JR $
M_PIXEL_SHIFT
M_PIXEL_SHIFT
M_PIXEL_SHIFT
...
And then:
ADD A,A
ADD A,A
LD (_Jump), A
I could be wrong, but it SEEMS that the program modifies itself with LD (_Jump). The same thing happens with _Save. |
|
Back to top |
|
|
|