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 > Newbie- problems displaying a sprite.

#3468 - Saj - Tue Feb 25, 2003 4:27 pm

Here is the code;
(I'm using goldroad 1.7 to compile it)
(gifs2sprites to convert it.)
(CtoASM to convert it.)
(VBA(win) to test it)
:-

It just displays 4 vertical lines (grey and blue) instead of a 16 color,32x32 picture of a head. What gives?!
Code:

@include screen.h
@include sprites.h

b start
@include manhead.h
start:

Init_Sprites   

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

ldr r0,=OAM
ldr r1,=(SQUARE|COLOR_16|10)|((SIZE_32|10)<<16)
str r1,[r0]+4!
ldr r1,=0
str r1,[r0]

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

ldr r1,=OBJPAL
ldr r2,=128
ldr r3,=pallete

palloop:
ldr r7,[r3]+4!
str r7,[r1]+4!
subs r2,r2,1
bne palloop

ldr r1,=CHARMEM
ldr r2,=128
ldr r3,=obj0

sprloop:
ldr r7,[r3]+4!
str r7,[r1]+4!
subs r2,r2,1
bne sprloop

infiniteloop
b infiniteloop


and here is the sprite (manhead.h) :-
Code:

pallete:
@DCW (( 0)+( 0<<5)+( 0<<10))
@DCW (( 0)+( 0<<5)+( 0<<10))
@DCW (( 8)+( 5<<5)+( 0<<10))
@DCW ((30)+(17<<5)+(12<<10))
@DCW ((30)+(30<<5)+( 0<<10))
@DCW (( 0)+(17<<5)+(26<<10))
@DCW ((28)+(17<<5)+( 5<<10))
@DCW ((30)+( 0<<5)+( 3<<10))
@DCW ((30)+(30<<5)+(30<<10))
obj:
@DCW 0x4211, 0x6442
@DCW 0x2421, 0x4644
@DCW 0x6211, 0x6464
@DCW 0x2111, 0x6446
@DCW 0x1111, 0x2322
@DCW 0x1111, 0x8332
@DCW 0x2111, 0x3333
@DCW 0x1111, 0x3332
@DCW 0x2244, 0x1111
@DCW 0x6464, 0x1112
@DCW 0x4644, 0x1126
@DCW 0x6446, 0x1124
@DCW 0x3468, 0x1124
@DCW 0x3438, 0x1123
@DCW 0x3333, 0x1112
@DCW 0x2333, 0x1111
@DCW 0x1111, 0x7721
@DCW 0x1111, 0x3321
@DCW 0x1111, 0x2211
@DCW 0x1111, 0x8211
@DCW 0x1111, 0x7821
@DCW 0x1111, 0x5521
@DCW 0x1111, 0x5582
@DCW 0x2211, 0x2221
@DCW 0x1233, 0x1111
@DCW 0x2533, 0x1111
@DCW 0x5553, 0x1112
@DCW 0x5555, 0x1125
@DCW 0x7555, 0x1127
@DCW 0x5777, 0x1125
@DCW 0x5333, 0x1125
@DCW 0x1111, 0x1111

#3506 - TurboHz - Wed Feb 26, 2003 9:28 am

I'm also a newbie, and something that has been extremely helpful for me is using the tools in VBA.

First of all I'll check if you can see the tiles in "Tile viewer"... use the palette slider to select the right palette for the tiles. Go to th "Palette viewer" to see if the palette has been set and if its been set as tile or sprite palette.

Finally have a peek at the "OAM viewer" to check if the sprite has been well defined.

Just as a last comment, I'm not sure of this one, but I had trouble converting 16 colour sprites with many of those utilities (gif2sprites and many others are written only for 256 colour image data). I'm now using bmp2raw to convert 16 colour data, and it works (just make sure the bmp has a bit depth of 4 and the pallete is used, 'cos some image packages apply a standard palette to 4bit bmps...).

Good luck!

#3852 - Saj - Mon Mar 10, 2003 8:58 pm

Thanks, I'm now using pcxgba and it seems to be fine.

My artist is using gifs so one of these days I want to write a windows program that :-

Step 1. Cuts up the individual frames of the animated gif.

Step 2. Converts each frame into individual PCX files.

Step 3. Converts each PCX file into a usable C/Header file.

Step 4. Combines the seperate header files into one for easy
use as a 1D array for programing.

Step 5. rewards me by making me a nice cup of tea.

Unless you guys know of a program that does this....


Last edited by Saj on Tue Mar 11, 2003 10:33 am; edited 1 time in total

#3856 - Lord Graga - Mon Mar 10, 2003 10:01 pm

Shouldn't it be:

palloop:
ldr r7,[r3]+4!
str r7,[r1]+4!
subs r2,r2,1
cmp r2, 0
bne palloop

#3872 - arundel - Tue Mar 11, 2003 12:02 pm

Lord Graga wrote:
Shouldn't it be:

Code:
palloop:
ldr r7,[r3]+4!
str r7,[r1]+4!
subs r2,r2,1
cmp r2, 0
bne palloop


either
Code:
palloop:
ldr r7,[r3]+4!
str r7,[r1]+4!
sub r2,r2,1
cmp r2, 0
bne palloop


or

Code:
palloop:
ldr r7,[r3]+4!
str r7,[r1]+4!
subs r2,r2,1
bne palloop

_________________
http://www.nausicaa.net

#3875 - Kay - Tue Mar 11, 2003 1:51 pm

The good question is why do you use OR 10 to setup the sprite ???


Code:

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



-- Kay

#3881 - tepples - Tue Mar 11, 2003 5:20 pm

Kay wrote:
The good question is why do you use OR 10 to setup the sprite ???

to place the sprite at (10, 10) on screen, apparently
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#3882 - tepples - Tue Mar 11, 2003 5:29 pm

Saj:

ImageMagick can do steps 1 and 2.

Steps 3 and 4: convert images to binary files, 'cat' the binary files, and then either convert them to a .s file or place them in a GBFS archive.

Oh, and by the way, ask your artist to switch from GIF to MNG because of the advantages MNG has over GIF (better compression, no patent problems anywhere on earth, gamma correction, alpha blending, true color, etc) in every area other than IE browser support (IE can display only the still version).

And for step 5, just buy a case of canned Lipton iced tea. (Note: this is for the USA; do they even drink iced tea in the UK?)
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#3888 - Kay - Tue Mar 11, 2003 9:00 pm

My latest reply to this post was a mistake (badly click to submit instead of preview), please read:

Why do you put this line 2 times ?

Code:
ldr r1,=(SQUARE|COLOR_16|10)|((SIZE_32|10)<<16)


And please notice that Obj parameters are halfword (16 bits).
Writting a Word results in inversion of bytes order due to indianness of bytes storage of GBA ARM7.

Simply try to write halfwords.


-- Kay

#3889 - Kay - Tue Mar 11, 2003 9:00 pm

My latest reply to this post was a mistake (badly click to submit instead of preview), please read:

Why do you put this line 2 times ?

Code:
ldr r1,=(SQUARE|COLOR_16|10)|((SIZE_32|10)<<16)


And please notice that Obj parameters are halfword (16 bits).
Writting a Word results in inversion of bytes order due to indianness of bytes storage of GBA ARM7.

Simply try to write halfwords.


-- Kay

#3897 - FluBBa - Wed Mar 12, 2003 8:31 am

Where does CHARMEM point to?
_________________
I probably suck, my not is a programmer.

#3963 - Saj - Thu Mar 13, 2003 8:49 pm

Tepples, you da man!!!

Should've known I'd get a great response from you!

I'll get ImageMagick asap & NO, What is ice tea?!?

Good ol' Earl grey served up from a type 4 replicator's the good stuff!!

#4696 - idle - Mon Apr 07, 2003 5:35 am

Saj wrote:

ldr r3,=obj0
-------------------
obj:
[/code]


the solution is actually quite a lot simpler.

see those two quoted lines?

they don't match.

change the first to ldr r3,=obj or change the label in the included file to read obj0: and it'll work.