Mutliple backgrounds - How the hell?

flash · 11332

Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
on: January 05, 2009, 08:26:37 pm
I can get backgrounds to work on BG0 and BG2 but totally fail with BG1 and BG3?

This bit of code shows it working on 2 layers (with a bit of wobble for good measure).

This should be a tidy piece of code to work out what is going wrong. Changing the BG0 and BG2 map bases can mess things up though - just to add more confusion to the mix. There is something strange or something that gels certain settings with certain background, I just cannot crack it. This is a bit of a major stumbling block at the moment, but nothing is impossible! :(
PS. I see what you mean with Dualis - though it must be a bug in dualis surely?

HK: One thing I did on this is use 2 256 colour pngs and set grit and the source accordingly. I failed using 16 colour for some reason? The main problem I have is doing one of either matchng the palettes between both png's or setting palettes on a per layer basis? Is there anything you can think of to make the palettes between images match (including transparency?)
« Last Edit: January 05, 2009, 08:28:53 pm by Flash »

Coding for the love of it!


Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #1 on: January 05, 2009, 09:09:00 pm
Ok, trying to iron out the problems.

If you change (MODE_0_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG2_ACTIVE) to (MODE_0_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG3_ACTIVE) and change in REG_BG2CNT to REG_BG3CNT then dualis still shows the map in BG2? These 2 changes SHOULD really be all that is needed to change layer as the tile and map bases should be the same. Also, the display no longer works?

leaving the code as is and swapping REG_BG2CNT to REG_BG0CNT and REG_BG0CNT to REG_BG2CNT results in the 2 layers being swapped as expected :) So, that works at least!

slightly more confusing

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

@ Front.png to here

ldr r0, =REG_BG1CNT @ Set main screen BG0 format to be 32x32 tiles at base address
ldr r1, =(BG_COLOR_256 | BG_32x32 | BG_MAP_BASE(0) | BG_TILE_BASE(1))
str r1, [r0]

@ Back.png to here

ldr r0, =REG_BG2CNT @ Set main screen BG0 format to be 32x32 tiles at base address
ldr r1, =(BG_COLOR_256 | BG_32x32 | BG_MAP_BASE(1) | BG_TILE_BASE(2))
str r1, [r0]
This should not work, but in doing this, BG0 is still displayed as if REG_BG0CNT was used instead of REG_BG1CNT
Very strange?

Also changing the values in BG_MAP_BASE(0) | BG_TILE_BASE(1) for BG1CNT to match BG2CNT causes the BG0? to display the picture from BG2 - MADNESS!

All I can offer HK, is - I hope this helps?
« Last Edit: January 05, 2009, 09:10:33 pm by Flash »

Coding for the love of it!


Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #2 on: January 05, 2009, 09:51:21 pm
Also, have you noticed that using bg0 and bg2 works as I would have expected?

We are not breaking any memory boundries with the png's I have used neither with the map or tile data, This has allowed us to use the obvious:-

BG_MAP_BASE(0) and BG_MAP_BASE(1)
married with -
BG_TILE_BASE(1) and BG_TILE_BASE(2)

though changing TILE_BASE to 0 and 1 respectively results in a messed up display?
2 and 3 work, 3 and 4 work, 4 and 5 work,etc - you just cannot use bank 0?
BG_MAP_BASE can also be paired, and this does allow 0 to be used. Infact, any value in BG_MAP_BASE works becaue there is no map overfill.
So, the problem JUST revolves around the inability to se BG1 and BG3 actve and use them correctly.

I think sonething lies in the VRAM settings somewhere. In the start of main code we set and enable A and C, does this relate somehow to BG0 and BG2?

The main point is that using the LayerTest code, we do have full access to BG0 and BG2 and the rest (except BG_MAP_BASE(0)) on all memory ranges for tiles and maps! but no settings of BG1 or BG3 can get them to work? None of the tutorials make VRAM settings clear, not to me anyway!

Also, totally puzzled by the palettes as the tutorials say that each BG can have an independent palette, though I am unable to assign them?
« Last Edit: January 05, 2009, 09:54:58 pm by Flash »

Coding for the love of it!


Offline flash

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 13180
Reply #3 on: January 06, 2009, 09:49:24 pm
Have been playing again (FOR AGES) trying to get BG1 and BG3 to work - and failed!

I have put a backdrop of stars on the scroll code, though it is a repeating texture that does not roll between both screens as I could not be bothered to do it yet.

BG0 and BG2 are used. This does help me to see what memory has been used for the level and tile data and to work out what cannot now be used!


Coding for the love of it!


Offline headkaze

  • Administrator
  • Blue Gene Super Computer
  • **********
    • Posts: 7838
Reply #4 on: January 07, 2009, 07:29:34 am
Looks good and yes I can't seem to get BG1 or BG3 to work either. I might have more of a play later today.