#96159 - Dark Knight ez - Tue Aug 01, 2006 7:05 pm
Hey all.
I have code running to show a background image.
It works fine on my flashcard, but it appears that it does not on M3.
Everything else does work fine on the M3... just not the background.
Does someone know how to fix this?
My code for it is currently:
Code: |
videoSetModeSub(MODE_5_2D |
DISPLAY_SPR_ACTIVE | //turn on sprites
DISPLAY_BG3_ACTIVE | //turn on background 0
DISPLAY_SPR_1D | //this is used when in tile mode
DISPLAY_SPR_1D_BMP //and this in bitmap mode
);
SUB_BG3_CR = BG_BMP8_256x256;
memcpy(BG_GFX_SUB, bg_bin, 256*256);
memcpy(BG_PALETTE_SUB, bg_pal_bin, 256*2);
|
Like I said, this _does_ work on my flashcard. Is there something the M3 expects differently, or is my code wrong and my flashcard doesn't mind that?
Any help would greatly be appreciated.
#96174 - knight0fdragon - Tue Aug 01, 2006 7:44 pm
add powerON(POWER_ALL_2D);
_________________
http://www.myspace.com/knight0fdragonds
MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206
#96243 - Dark Knight ez - Wed Aug 02, 2006 12:43 am
I have this line already before doing anything:
Code: |
powerON(POWER_ALL); |
That does even more than your suggestion.
POWER_ALL according to libnds:
Code: |
#define POWER_ALL (POWER_ALL_2D | POWER_3D_CORE | POWER_MATRIX) |
Any other suggestions?
#96319 - josath - Wed Aug 02, 2006 3:52 pm
M3 does some weird stuff, leaving things in odd states which is non-standard. I have a similar problem (the text background in my app does not show for people with M3 SD).
Apparently, a workaround is to launch your app from Moonshell
#96334 - Dark Knight ez - Wed Aug 02, 2006 5:48 pm
I was told that Moonshell can not boot NDS files on an M3...
And that the revision of Moonshell made by the M3 team can't even do that.
#96335 - pepsiman - Wed Aug 02, 2006 6:01 pm
Dark Knight ez wrote: |
My code for it is currently:
Code: | videoSetModeSub(MODE_5_2D |
DISPLAY_SPR_ACTIVE | //turn on sprites
DISPLAY_BG3_ACTIVE | //turn on background 0
DISPLAY_SPR_1D | //this is used when in tile mode
DISPLAY_SPR_1D_BMP //and this in bitmap mode
);
SUB_BG3_CR = BG_BMP8_256x256;
memcpy(BG_GFX_SUB, bg_bin, 256*256);
memcpy(BG_PALETTE_SUB, bg_pal_bin, 256*2);
|
|
No VRAM bank setup?
#96338 - Dark Knight ez - Wed Aug 02, 2006 6:25 pm
Bank C for the background actually. Should've mentioned that.
Code: |
vramSetBankC(VRAM_C_SUB_BG); |
#96924 - omaremad - Sun Aug 06, 2006 4:44 pm
pepsi man has an m3 loader see drunken coder's tools
#96989 - HyperHacker - Mon Aug 07, 2006 5:57 am
Dark Knight ez wrote: |
I have this line already before doing anything:
Code: | powerON(POWER_ALL); |
That does even more than your suggestion.
POWER_ALL according to libnds:
Code: | #define POWER_ALL (POWER_ALL_2D | POWER_3D_CORE | POWER_MATRIX) |
Any other suggestions? |
By using POWER_ALL you're turning on the 3D core and matrix processor... if you don't use these, then you're just wasting batteries.
_________________
I'm a PSP hacker now, but I still <3 DS.
#97781 - Dark Knight ez - Fri Aug 11, 2006 2:53 pm
I do use them, actually. You'll get to see it in a week or two.
#103828 - Dark Knight ez - Sun Sep 24, 2006 9:31 pm
Wanted to let everyone know that I've found the solution to this problem.
You should _not_ use memcpy to put the background graphics and palette into their respective registers.
Use 16-bit writes in a for-loop.
I believe a lot of tutorials used memcpy, and are wrong. I don't know which ones I used for this, but I suggest the ones that do use memcpy be updated to reflect this.
Note:
I discovered what the problem was, after not being able to alter the background palette somewhat further ingame in AmplituDS. 16-bit writes fixed that.
So beware that memcpy might work sometimes (on my setup the background did display correctly with memcpy's), but can screw up at other people's homebrew setups (M3 in this case) and/or when used in other locations in the code (after initializing the game, in this case).
I hope this is of some help to people for future reference.
#103830 - tepples - Sun Sep 24, 2006 9:46 pm
This contradicts the findings of other people who have tested memcpy(). If the source and destination are aligned, and above a specific size threshold, it uses 32-bit writes.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#103831 - Lick - Sun Sep 24, 2006 9:47 pm
I think it's because you didn't set the 15th bit (alpha bit) for each pixel. [edit] Which is required for the 3rd background in Mode5.
- Lick
_________________
http://licklick.wordpress.com
#103836 - Dark Knight ez - Sun Sep 24, 2006 9:55 pm
Tepples:
I know. I was amazed to find this out myself too. I stumbled upon it.
And if people don't believe me, their choice. There's no harm in switching to 16-bit writes instead of using memcpy though.
Lick:
This is different. I'm loading in the background from an included file, and it uses the background palette. I'm not doing direct pixel writes by creating the colours on the fly, so to speak.
#103935 - Lick - Mon Sep 25, 2006 3:11 pm
Hmm.. I'm a bit confused to be honest. This line 'SUB_BG3_CR = BG_BMP8_256x256;' doesn't that mean you -are- using a bitmap mode?
- Lick
_________________
http://licklick.wordpress.com
#103939 - Dark Knight ez - Mon Sep 25, 2006 3:43 pm
I -am-.
However, the way I use it (an 8-bit background image which uses a palette) I do not have to worry about bit 15 and put that explicitly in my code.
When I would use it as a framebuffer (writing RGB(15,0,0) to a pixel for example) then I will have to explicitly OR it with bit 15. I'm not sure if and how that utilizes the background palette. I don't think it does.
#103941 - Sektor - Mon Sep 25, 2006 4:01 pm
Try clearing the VRAM after setting up the VRAM banks. It helped for txtWriter on M3.
Code: |
for (i = 0; i < (131072); i++)
{
BG_GFX[i] = 0;
}
|
_________________
GTAMP.com/DS
#103942 - Dark Knight ez - Mon Sep 25, 2006 4:08 pm
I have no issues with backgrounds anymore.
My solution was to use only 16-bit writes instead of memcpy. See a few replies up.
VRAM clearing is actually kind of pointless in my case, when I'm going to write an entire background to it anyway. I can see it being useful in other cases though.