gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

ASM > Problem to have multiple sprites on screen

#23503 - matrix960 - Wed Jul 14, 2004 10:57 am

Hi everybody!

I start to code this week on ASM for GBA using that tutorial : http://k2pts.home.comcast.net/gbaguy/gbaasm.htm

My main problem is that I can't have multiple sprites on screen. I can have 1 sprite (without those strange effect), but since I try to have 2, then 1 sprite is on screen, and disappears and the other is on screen....
Help me!!!!

Here's my code :

@include screen.h
@include sprites.h
@include dma.h
b start:
@include sprit.asm
@include sprit1.asm
start:


Init_Sprites

ldr r1,=REG_DISPCNT
ldr r2,=(MODE_0|BG2_ENABLE|OBJ_ENABLE|OBJ_MAP_1D)
str r2,[r1]




loop1
ldr r0,=OAM

ldr r1,=(SQUARE|COLOR_16|10)|((SIZE_8|10)<<16)

str r1,[r0]+4!
ldr r1,=0
str r1,[r0]


ldr r1,=pallete ; \
ldr r2,=REG_DMA3SAD ; -give source address in DMA Source Address register
str r1,[r2] ; /

ldr r1,=OBJPAL ; \
ldr r2,=REG_DMA3DAD ; -give destination address in DMA Destination Address register
str r1,[r2] ; /


ldr r1,=(128|DMA_32NOW) ; \
ldr r2,=REG_DMA3CNT ; - tell control register amount of data to transfer and
str r1,[r2] ; to transfer in 32bit or 16bit chunks (we use 32bit chunks here)

ldr r8,=200000
ldr r9,=0
loop2
subs r8,r8,1
Bne loop2

ldr r1,=obj ; \
ldr r2,=REG_DMA3SAD ; -give source address in DMA Source Address register
str r1,[r2] ; /


ldr r1,=CHARMEM ; \
ldr r2,=REG_DMA3DAD ; -give destination address in DMA Destination Address register
str r1,[r2] ; /


ldr r1,=(128|DMA_32NOW) ; \
ldr r2,=REG_DMA3CNT ; - tell control register amount of data to transfer and
str r1,[r2] ; to transfer in 32bit or 16bit chunks (we use 32bit chunks here)





ldr r0,=OAM
ldr r1,=(SQUARE|COLOR_16|100)|((SIZE_8|100)<<16)

str r1,[r0]+4!
ldr r1,=0
str r1,[r0]


ldr r1,=pallete1 ; \
ldr r2,=REG_DMA3SAD ; -give source address in DMA Source Address register
str r1,[r2] ; /

ldr r1,=OBJPAL ; \
ldr r2,=REG_DMA3DAD ; -give destination address in DMA Destination Address register
str r1,[r2] ; /


ldr r1,=(128|DMA_32NOW) ; \
ldr r2,=REG_DMA3CNT ; - tell control register amount of data to transfer and
str r1,[r2] ; to transfer in 32bit or 16bit chunks (we use 32bit chunks here)


ldr r8,=200000
ldr r9,=0
loop
subs r8,r8,1
Bne loop

ldr r1,=obj1 ; \
ldr r2,=REG_DMA3SAD ; -give source address in DMA Source Address register
str r1,[r2] ; /


ldr r1,=CHARMEM ; \
ldr r2,=REG_DMA3DAD ; -give destination address in DMA Destination Address register
str r1,[r2] ; /


ldr r1,=(128|DMA_32NOW) ; \
ldr r2,=REG_DMA3CNT ; - tell control register amount of data to transfer and
str r1,[r2] ; to transfer in 32bit or 16bit chunks (we use 32bit chunks here)



b loop1

@pool

@endarea

#23511 - FluBBa - Wed Jul 14, 2004 2:47 pm

You only set attributes for sprite 0 and write the 2 graphic sets to the same address in (I suppose) VRAM.
_________________
I probably suck, my not is a programmer.

#23519 - matrix960 - Wed Jul 14, 2004 4:57 pm

At the begining, I had Sprite 0 and Sprite 1. but the result were worse.... And how do I change the address with that on mind?

#23563 - FluBBa - Thu Jul 15, 2004 9:41 am

Check out the VBA tile viewer and make sure what you see there is what you'd expect.
Start with one sprite and make sure you can change what tile it uses and move it around before starting with another one...
A 8x8 16color tile is 32 bytes big or 8 "longwords" (which you should use when starting the DMA and not 128 "longwords").
_________________
I probably suck, my not is a programmer.