#165773 - headspin - Tue Jan 06, 2009 3:46 pm
A friend and I decided to try and rewrite an old C64 game he wrote (Warhawk) to the NDS. I wanted to use the very latest DevKitPro and have got a few demos working so far. Since there are very few examples written in pure asm for DS (that we can find) we are learning as we go. We wanted to write it in asm because he has a background in assembly and for the challenge. My background is C so I'm learning asm as I go.
Now we are at the point where we want a level of the game scrolling up both screens. The demo is using a 64x64 tile mode and doing dmaCopy's each 256 lines scrolled for maximum speed. We are using grit's -mLs option so the data is stored in screen blocks ready for dmaCopy'ing. For some reason when I try to scroll BG1 where I'm writing the map data to (as stated in the REG_BG1CNT / REG_BG1CNT_SUB registers) it's actually writing the data to BG0. I can tell this because when I change the scroll registers to REG_BG0VOFS / REG_BG0VOFS_SUB it starts scrolling the map. It just doesn't match up with how the BG's have been assigned. It leads us to believe that the BG's must use certain areas in VRAM but I can't find any documenation to back that theory up.
So I decided to write the demo in C to see if we had messed up in some way. Apart from the screens needing an lcdSwap() the C code seemed to work fine. It's written a bit strangely to keep the code as close to the asm version as possible.
Another thing is we can't seem to get vblank working on hardware. Even running the C version on hardware it does not wait for vblank. That is using the "combined template" example from DevKitPro as the starting point. It scrolls the entire level in under a second. It runs fine in an emulator.
I'm going to attach both the asm and C version so hopefully someone can take a look and help in some way. Thanks for your time :)
[Images not permitted - Click here to view it]
leveltest_asm.zip
leveltest_c.zip
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game
Now we are at the point where we want a level of the game scrolling up both screens. The demo is using a 64x64 tile mode and doing dmaCopy's each 256 lines scrolled for maximum speed. We are using grit's -mLs option so the data is stored in screen blocks ready for dmaCopy'ing. For some reason when I try to scroll BG1 where I'm writing the map data to (as stated in the REG_BG1CNT / REG_BG1CNT_SUB registers) it's actually writing the data to BG0. I can tell this because when I change the scroll registers to REG_BG0VOFS / REG_BG0VOFS_SUB it starts scrolling the map. It just doesn't match up with how the BG's have been assigned. It leads us to believe that the BG's must use certain areas in VRAM but I can't find any documenation to back that theory up.
So I decided to write the demo in C to see if we had messed up in some way. Apart from the screens needing an lcdSwap() the C code seemed to work fine. It's written a bit strangely to keep the code as close to the asm version as possible.
Another thing is we can't seem to get vblank working on hardware. Even running the C version on hardware it does not wait for vblank. That is using the "combined template" example from DevKitPro as the starting point. It scrolls the entire level in under a second. It runs fine in an emulator.
I'm going to attach both the asm and C version so hopefully someone can take a look and help in some way. Thanks for your time :)
[Images not permitted - Click here to view it]
leveltest_asm.zip
leveltest_c.zip
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game