Warhawk DS (HK & Flash's DS Diary)

flash · 259201

Offline headkaze

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 7838
Reply #60 on: January 03, 2009, 03:16:04 pm
Okay I got the scrolling working by breaking each screen up into their own routines with their own y offset.



Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #61 on: January 04, 2009, 11:00:14 am
Just made the level 1 background with the colour key FF00FF set for the transparency. Hopefully I will get a chance to play with code to add another layer later tonight

Coding for the love of it!


Offline headkaze

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 7838
Reply #62 on: January 04, 2009, 02:18:23 pm
I got that level working with transparency using the following options (since it's in X1R5G5B5 format that makes magenta 0x7C1F)

Code: [Select]
#-------------------------------------------------------
# graphics in tile format
#-------------------------------------------------------
-gt

#-------------------------------------------------------
# trasparent color
#-------------------------------------------------------
-gT7C1F

#-------------------------------------------------------
# tile reduction
#-------------------------------------------------------
-mRtpf

#-------------------------------------------------------
# map output
#-------------------------------------------------------
-m

#-------------------------------------------------------
# graphics bit depth is 4 (16 color)
#-------------------------------------------------------
-gB4

#-------------------------------------------------------
# Map layout for regular backgrounds. 16-bit entries, broken down into screenblocks.
#-------------------------------------------------------
-mLs



Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #63 on: January 04, 2009, 08:46:17 pm
Following on from the attempts to get multiple backgrounds working, major headache. I am wondering if we are missing something?
I have modified the original code and based on that was expecting these modifications to work in the extent of displaying the backgrounds. The relevence of the Tile_Base on BG1 should not matter as at the moment it does not really matter what is displayed

Code: [Select]
ldr r0, =VRAM_A_CR @ Set VRAM A to be main bg address 0x06000000
ldr r1, =(VRAM_ENABLE | VRAM_A_MAIN_BG_0x06000000)
strb r1, [r0]

ldr r0, =VRAM_C_CR @ Set VRAM C to be sub bg address 0x06200000
ldr r1, =(VRAM_ENABLE | VRAM_C_SUB_BG_0x06200000)
strb r1, [r0]

mov r0, #REG_DISPCNT @ Main screen to Mode 0 with BG0 & BG1 active
ldr r1, =(MODE_0_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG1_ACTIVE)
str r1, [r0]

ldr r0, =REG_DISPCNT_SUB @ Sub screen to Mode 0 with BG0  & BG1 active
ldr r1, =(MODE_0_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG1_ACTIVE)
str r1, [r0]

ldr r0, =REG_BG0CNT @ Set main screen BG0 format to be 64x64 tiles at base address
ldr r1, =(BG_COLOR_16 | BG_64x64 | BG_MAP_BASE(0) | BG_TILE_BASE(1) | BG_PRIORITY(1))
str r1, [r0]

ldr r0, =REG_BG0CNT_SUB @ Set sub screen BG0 format to be 64x64 tiles at base address
ldr r1, =(BG_COLOR_16 | BG_64x64 | BG_MAP_BASE(0) | BG_TILE_BASE(1) | BG_PRIORITY(1))
str r1, [r0]

ldr r0, =REG_BG1CNT @ Set main screen BG0 format to be 64x64 tiles at base address
ldr r1, =(BG_COLOR_16 | BG_32x64 | BG_MAP_BASE(4) | BG_TILE_BASE(1) | BG_PRIORITY(3))
str r1, [r0]

ldr r0, =REG_BG1CNT_SUB @ Set sub screen BG0 format to be 64x64 tiles at base address
ldr r1, =(BG_COLOR_16 | BG_32x64 | BG_MAP_BASE(4) | BG_TILE_BASE(1) | BG_PRIORITY(3))
str r1, [r0]

Looking through video.h I have perhaps done a bit more to confuse myself. I was looking bacause of reading through the tutorial on http://dev-scene.com/NDS/Tutorials. I take it that BG_MAP_BASE and BG_BMP_BASE are pretty much the equivs for tile and framebuffer screens! But, what is DISPLAY_CHAR_BASE?
Also, setting priorities for BG0 and BG1 to 1 and 3 respectivley results in BG1 becoming above BG0
BG_MAP_BASE on BG1 (and sub) kills the display of BG0 regardless of ANY setting (0-31) this is something that I really do not understand.
Is there settings that we also need to do to get this working, leading to the thought that omitting them made a single background work by using the settings defaults? By adding a second layer the defaults are no longer valid?

Or (as more usually the case) is it just me?

Added here is the leveltest code that is slightly modified and also contains the test png for the half speed star background.
« Last Edit: January 04, 2009, 08:58:27 pm by Flash »

Coding for the love of it!


Offline headkaze

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 7838
Reply #64 on: January 07, 2009, 10:27:42 am
Okay sorry that I haven't used your updated level code with the stars but I just wanted to see if changing to using variables instead of reading the scroll registers would change anything. And guess what? It did, now we have perfect scrolling with vblank. Just tested this on hardware and it works great ;)

Now all you have to do is integrate your new code with this. I did change quite a bit around I'm afraid so sorry about that. But I needed to do that to help me understand the code better.

I think gbadev.org will be really helpful for this project. Lot's of knowledgable folks over there :) (Thanks to dovoto and eKid for help with this)



Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #65 on: January 07, 2009, 10:33:57 am
It works GREAT! That is bloody strange :)

Don't worry about the code, I only did that as a test anyway, It was a way of working out the memory banks more than anything! The final idea is to use a background for the level as a bitmap to allow lots of stars at many different speeds. The code it looking trickier that first envisioned. But if it works, it will be the first time anyone has mixed a framebuffer type mode with tilemode ;)

I cannot believe we missed the halfword in the inits! I bloody spent hours going through the .h files to try and find out why bg1 and bg3 did not work - at least i was on the right tracks with them being paired (sort of)

Coding for the love of it!


Offline headkaze

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 7838
Reply #66 on: January 07, 2009, 10:46:00 am
Yes very strange because I swore I checked all the sizes of the registers and I thought those REG_BGxCNT regs were 32-bit. Can't believe we missed that as I thought we checked them all.

Anyway it feels good were back on track. I would not use a framebuffer mode mixed with a tilemode, it just wouldn't work. What we should do is find some nice star sprites and just build a map like the level map using stars and maybe some planets and things for the background. Maybe we could have two layers for the background, something like stars on one and planets on the other and scroll them at different speeds.



Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #67 on: January 07, 2009, 10:56:28 am
Yes very strange because I swore I checked all the sizes of the registers and I thought those REG_BGxCNT regs were 32-bit. Can't believe we missed that as I thought we checked them all.

Anyway it feels good were back on track. I would not use a framebuffer mode mixed with a tilemode, it just wouldn't work. What we should do is find some nice star sprites and just build a map like the level map using stars and maybe some planets and things for the background. Maybe we could have two layers for the background, something like stars on one and planets on the other and scroll them at different speeds.
You misunderstood me,
What i meant was to use a tilemap as a bitmap, adressing each blank tile to map a star (non scroll). Make this transparent and lay another planet background behind that scrolling a nice space picture.
It would be tricky as for both screens it would really need 768*2 tiles. So, it would have to be a single map on both screens.
I thought it would be a nice effect?

Coding for the love of it!


Offline headkaze

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 7838
Reply #68 on: January 07, 2009, 11:05:19 am
It would be possible to write directly to tile data but it would be difficult IMHO. You would have to keep track of each star and each tile the current star is in and so on. I've heard people talk about doing that before but its really not what a tile mode is designed for. Anyway running that demo you did with the stars looks great to me anyway. With updated graphics it would look even nicer. Perhaps rather than just stars we could even have another level map (with destructable objects?). Or a star layer with another level layer. Anyway there are a few different ways we can go.



Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #69 on: January 07, 2009, 11:12:40 am
I was going to use a star x,y and speed table and plot directly? It could work...
I just wanted to do something that had no been done before! But perhaps you are right!

In Warhawk the main level has destructible bases on it that are counted as destroyed and a bonus given if you get them all. Detecting them against the scroller may prove hard though - have not thought about it yet ;)

Please have a little play with the c64 one and see if this gives you any ideas - we just have to make it better - ho ho

Coding for the love of it!


Offline headkaze

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 7838
Reply #70 on: January 08, 2009, 02:04:26 pm
Boy was that frustrating and I couldn't get the palette offsets working either. Maybe grit can't do that?

I tried these two options

Code: [Select]
-ga <n>
Pixel offset for non-zero pixels. Useful if the associated palette is at an offset.

-ps <n>
Starting palette entry. -ps 16 would start the export at color 16. Works together with -pe and -pn.

Both options don't work. And there are no BG_PALETTE(n) macro's so we need to add the offset. Okay here is my update, didn't fix the palette issue I'm afraid :(



Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #71 on: January 08, 2009, 02:54:10 pm
Well done HK, it was a worthy effort...

Perhaps if I can make a palette in photoshop that we are going to use and save it as a indexed png, i could pre-map all the graphics to the same palette and set all to 256 colour to match. Hmmm...

I will give that a try when I get home.

PS. I see you had the same problem as me with the scroll matching and the blank areas. I am going to make all the bloody 3 layers the same size... There - that's told Mr. Arm... :)

Coding for the love of it!


Offline headkaze

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 7838
Reply #72 on: January 08, 2009, 07:06:58 pm
PS. I see you had the same problem as me with the scroll matching and the blank areas. I am going to make all the bloody 3 layers the same size... There - that's told Mr. Arm... :)

Actually I didn't even get around to looking at that - too busy trying to get the palettes to work  ::)



Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #73 on: January 08, 2009, 07:51:43 pm
I have got the palettes working now and will see what I can do with adding the main ship to the scroll code!

I will post it later.

Have not had a chance to look into rotation of sprites yet, but hopefully will get time tonight!

Have made the 3 layers the same and this will be handy as I can start them scrolling before the main level (fire starts game) and then allow them to wrap! This is better overall. At some point we are going to have to think of a way to change the levels :) (levels and tilemaps, perhaps keep the same mid scroll and change the back one per level).
I have made a photoshop CLUT to map the colours.
« Last Edit: January 08, 2009, 07:54:07 pm by Flash »

Coding for the love of it!


Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #74 on: January 08, 2009, 11:49:02 pm
Ok,

The latest:-

The game now works with 3 levels of paralax and the palettes are now correct (hurrah)
I have not finished drawing the backdrops yet, but will have a go tomorrow.
The Warhawk ship is now on screen and can be controlled by joypad and fire starts the scroll. There is a jerk on the wait section that I cannot get to the bottom of at the moment. The scroll jerks when waiting.

There are some problems when playing on a real DS - it does not work! The sprite code stops the game playing. I have no idea why at the moment as it is late and my brain has gone a bit wonky. Commenting out the sprite BL's results in it working, though BG2 is not displayed? I have not looked into if it worked on the earlier post (the one with the incorrect palette).
I am sure these are little problems.
HK: one thing I did notice, in the scroll code for each layer, we are pushing a lot onto the stack? not sure if this could cause an overflow on an ARM processor?

Have commented a fair bit of the code (i removed the ldr r0,variable code in the sprite movement code as I wondered if this was the problem - it was not :( ).
Also, I had to move the memory mapping of the sprite vram as it killed the main screen (no scroll) and also the sprite would not appear.

Ok, HK - over to you  :D

EDIT:
Had a look at the original sprites code and this works on a real DS, so i must be something I have done wrong?
The 3 layer scroller with the palette fault does NOT work, layer 2 (starfront) does not display on that either on a real DS.. So WTF!
« Last Edit: January 09, 2009, 07:24:44 am by Flash »

Coding for the love of it!


Offline headkaze

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 7838
Reply #75 on: January 09, 2009, 08:58:59 am
Awesome work! This is what I love about teamwork :)

I see how your using a shared palette, nice easy solution although I would still prefer to have grit take care of it for us. We would have better control over what layers use what colors. I think I'll make a post about it on gbadev and ask if it's a bug or if were using the options wrong. I would like to know the answer as I think having that much control over the palette is important. There is another grit option that sounds interesting

Code: [Select]
-pS
Shared palette data. The colors of the source bitmaps are merged into a single palette. See also -O and -S. NOTE: will alter the order of the original palette (unless the first bitmap happened to have all the colors in it (hint, hint)).

So perhaps that's another thing we can look into. It would be nice to have grit take care of all of this.

Will have a closer look at your demo but what from I've seen so far really impressed with what you've done :)

BTW Your still using BG_PALETTE(0) but BG_PALETTE is not a macro, so that is undefined behaviour. It's defined as

Code: [Select]
#define BG_PALETTE        0x05000000



Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #76 on: January 09, 2009, 09:12:05 am
oops, forgot to change it! Silly bloody fool that I am!! :)

Coding for the love of it!


Offline BaDToaD

  • Proterian
  • Dragon 32
  • *****
    • Posts: 76
Reply #77 on: January 10, 2009, 02:17:58 pm
That's looking sweet.



Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #78 on: January 10, 2009, 02:25:49 pm
You should see it going mate - starting to really look like it always should. Trying to keep the same "BaDToaD" style in the graphics. All I am really doing is adding a bit more to the resolution (no longer need 2 pixels for a colour) to sharpen them up a bit.

Coding for the love of it!


Offline headkaze

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 7838
Reply #79 on: January 11, 2009, 05:39:01 pm
Okay here is a sprite sheet showing what I mean about the energy triangles.
« Last Edit: January 11, 2009, 05:41:53 pm by headkaze »



Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #80 on: January 11, 2009, 05:53:48 pm
Yeap, get ya...

On warhawk is climbs down a line at a time.. I will have a play.

Coding for the love of it!


Offline headkaze

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 7838
Reply #81 on: January 12, 2009, 01:47:45 am
Okay got BG2 working. I'm not sure exactly what was going wrong but it looks like the tile data was overlapping other map or tile data but by my calculations there should have been plenty of space for it. So I just made more room. Did a few other odds and ends as I wasn't sure exactly what was causing it. I also fixed the crash on No$GBA when the demo ends, and the other crash after a few seconds in.

Also I noticed the movement code doesn't work on hardware but didn't get around to finding out why.
« Last Edit: January 12, 2009, 06:45:27 am by headkaze »



Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #82 on: January 12, 2009, 09:56:47 pm
Okay got BG2 working. I'm not sure exactly what was going wrong but it looks like the tile data was overlapping other map or tile data but by my calculations there should have been plenty of space for it. So I just made more room. Did a few other odds and ends as I wasn't sure exactly what was causing it. I also fixed the crash on No$GBA when the demo ends, and the other crash after a few seconds in.

Also I noticed the movement code doesn't work on hardware but didn't get around to finding out why.
Did you find out why it fails on hardware? I was going to, but after playing with the title screen, I had had too much wine (it is my birthday after all :) )

Ok, done some major changes to the title code (have not added to the V.xx numbers as I have been doing this bit myself - up till now!). All works and am randomly generating stars. I must have some kind of 42 year old mental block, but for the life of me I cannot get a random word to fix to a 1-6 or a 0-191 value. Perhaps my "ands" are a little scratchy? I thought I had it working, but when I expand the stars to 512, I can see that every other line (y) is missing? Also, regenerating a random upon star exit (<0) fails to work correctly, so have disabled it.
One thing you may want to try. If you double the star data, and double the move and draw stars to 1024, you get tons of errors about offsets... Try it as you may understand more, coming from the IDE background? or perhaps it is a quirk.
Played a bit with the sprites also and never realised you could not expand or rotate a sprite out of it's boundries (dimensions). When you look at the games and see a sprite zoomed off the screen you just think this is a simple zoom operation in hardware - far from it!

Anyway, here is the latest title. PS. you can now upload .nds files without the need of zipping them up!

Oh, another ps, perhaps after getting the main code running on real DS, we should look at adding music to the title screen??

   


Coding for the love of it!


Offline BaDToaD

  • Proterian
  • Dragon 32
  • *****
    • Posts: 76
Reply #83 on: January 13, 2009, 12:39:14 pm
Happy Birthday Flash!

I'll download this evening if I get a chance.

 



Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #84 on: January 13, 2009, 12:54:54 pm
Thanks mate :)

40 bloody 2 - god! soon be older than you ;)

Coding for the love of it!


Offline techno_wiz_oz

  • ZX80
  • *
    • Posts: 19
Reply #85 on: January 14, 2009, 03:33:58 am
Hitting the metal in assembler...I like it  ;D

Looking very nice indeed. Reading about a C64 game on the DS reminds me of the use of Robocop tune for the Ariston adverts, which is a direct rip of the Gameboy version of that SID classic hehe.



Offline headkaze

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 7838
Reply #86 on: January 15, 2009, 01:39:16 pm
Looking sweet!  8)



Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #87 on: January 15, 2009, 02:29:27 pm
This is the latest build of the game code.

Still some strange things involving sprites that fail to update on a real ds, but for the time being Ideas runs it as intended.

We now have horizontal movement of the levels - hurrah! Apears more solid now, getting more like a game. Also the ship now moves at the correct speed.

Several other changes far too dull to list, oh! except - let the game scroll to the end for a nice effect for the boss battles.

Coding for the love of it!


Offline headkaze

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 7838
Reply #88 on: January 15, 2009, 03:02:30 pm
Looks great! I haven't tried it on hardware yet. I like the end of level effect too. Remember color cycling in deluxe paint? I was thinking what would be cool is to add color cycling for the end of level boss. It would be quite simple just copy entry 0 then dmacopy from entry 0 to entry 1 (with size of 254) and then copy entry 0 to entry 255 then loop.

I'm going to look into getting a compressed wav file playing next. I'll be doing it as a demo. I think this will be the first time we will need to use shared ram with the ARM7 so it should be interesting.



Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #89 on: January 15, 2009, 03:13:34 pm
I dont think the shared ram will be a problem, just using it like flags (or a remote control) to init/stop things. It is the use of the sound registers that scare me, when everything is in that nasty C language contraption... :)

Have done another modify of the main code... Sorry!

Decided that 64x64 screens were a waste for the stars and have decided to make them both 32x64.. Saved a bit of memory and a lot o vram... Could help in the longrun??

PS. What is the vote on the horiz scroll, does it work ok to you lot (er - one)?

« Last Edit: January 15, 2009, 03:15:15 pm by Flash »

Coding for the love of it!