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 > Problems with GBAguy tutorials

#12036 - dagamer34 - Mon Oct 27, 2003 9:36 pm

I am having some problems with the GBAguy's tutorials. I have gotten them to assemble successfully but they don't do what they are supposed to. Maybe i mistyped something (several times) or he has it just plain wrong. Using version 1.7 of the Goldroad Assembler if that matters.

Here's the code:

@include screen.h
@textarea

ldr r1, =REG_DISPCNT
ldr r2, =(MODE_3|BG2_ENABLE)
str r2,[r1]
ldr r1,=0x0FF
ldr r2,=VRAM+2410
str r1,[r2]

label1
B label1

@pool
@endarea

Simplest program possible (i guess it could be simpler, but it needs to do something). Please find my error (if any).
_________________
Little kids and Playstation 2's don't mix. :(

#12038 - poslundc - Mon Oct 27, 2003 10:05 pm

What happens when you try to run it, versus what the tutorial says should happen?

(At first glance, it looks like it should paint a single orange pixel somewhere on the screen.)

Dan.

#12039 - dagamer34 - Mon Oct 27, 2003 10:12 pm

Hmm... that's funny. It worked. It looks like the problem is with my emulator, VisualBoyAdvance. It seems that my "demo" only works when VBA is run from command-line. Any of you had that problem also?

This really isn't a problem if it will run in hardware, though, i guess.
_________________
Little kids and Playstation 2's don't mix. :(

#12042 - dagamer34 - Mon Oct 27, 2003 11:29 pm

Cannot seem to get day 5 to work properly. I get some junk data instead of my 16 color bitmap. My code (again):

@include screen.h
@include sprites.h
b start
@include sprit.asm
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_16|10)<<16)
str r1,[r0]+4!
ldr r1,=0
str r1,[r0]

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,=obj

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

infiniteloop
b infiniteloop

Anydoy got a clue on what is wrong?
_________________
Little kids and Playstation 2's don't mix. :(

#12044 - sajiimori - Mon Oct 27, 2003 11:55 pm

Code:

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

If I'm not mistaken, that will write to the second half of the first sprite and the first half of the second sprite, instead of writing both parts of the first sprite (edit: I was mistaken. It writes to the second half of the first sprite twice.). I think the correct code is:
Code:

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

There's a similar problem with palloop and sprloop. Because they add 4 to the source and destination right away, they skip the first 4 bytes. Try initializing the source and destination pointers to 4 bytes before the data you want.

Don't shoot me if I'm wrong though...I haven't written much ARM asm.