#128686 - evilsanta - Mon May 14, 2007 1:46 am
EDIT: See 2nd Post... this post was very ignorant. :)
I am having some problems using the console, and also writing pixels to the same screen as the console, I realize I have to set it to the proper VRam... but currently I can only get the console to work using ConsoleInitDemo... which I obviously cant use if I want to alter the BG and stuff of the screen.
Right now this is my code... currently some blue lines appear, so it seems the text is being scewed, sadly I do not know exactly what is going on so I cant possible fix it.
Any help would be appreciated...
(CODE REMOVED TO MAKE THREAD SHORTER)
Last edited by evilsanta on Wed May 16, 2007 1:01 am; edited 3 times in total
#128850 - evilsanta - Tue May 15, 2007 10:45 pm
Ok, now after a couple days of doing much research... I have discovered that I shouldnt be using FB mode...
I altered my code, I can draw things to both screens fairly easily... but I am having trouble adding the text to a new background... whenever I add it the text looks garbled, if I do a full screen draw (say solid red) I get black vertical lines. What exactly could be happening here?
#128853 - dovoto - Tue May 15, 2007 10:58 pm
Black horizontal lines normally are the result of attempting to render to VRAM using 8 bit writes. VRAM must be written to in 16 bit increments.
As for fuxoring up the console you should be fine if you avoid VRAM C and palette entry 255 of the subdisplay (assuming you have used consoleDemoInit()).
If you need to use VRAM C take a look at the more verbose version of the console init function (LIBNDS_DIR/nds/arm9/console.h). It will allow you to specify the location of console memory explicitly.
_________________
www.drunkencoders.com
#128856 - evilsanta - Tue May 15, 2007 11:03 pm
Thanks for the reply, yeah I am currently using consoleinitDefault... and I am also using vram_c.
Here, ill post my code... for a while I was trying to set it to VRAM_H but I had the same problem. Any help would be appreciated...
EDIT: Ok, after adding BG_PALETTE_SUB[255] = RGB15(3,15,11); I can see the text, however when I add Background 3 I get garbled pixels as seen here...
http://img180.imageshack.us/img180/5048/untitledjn0.jpg
Code: |
powerON(POWER_ALL);
irqInit();
irqSet(IRQ_VBLANK, 0);
//vramSetMainBanks(VRAM_A_MAIN_BG, VRAM_B_LCD, VRAM_C_SUB_BG , VRAM_D_LCD); //REMOVE
u16* vidBuffA = (u16*)BG_BMP_RAM(0); //Point a video buffer to the start of the BG
videoSetMode(MODE_5_2D | DISPLAY_BG2_ACTIVE); //Set mode to 5, with BG2 active
vramSetBankA(VRAM_A_MAIN_BG); //Store it in vram_a
//Initialize BG
BG2_CR = BG_BMP16_256x256;
BG2_XDX = 1<<8;
BG2_XDY = 0;
BG2_YDX = 0;
BG2_YDY = 1<<8;
BG2_CY = 0;
BG2_CX = 0;
u16* vidBuffC = (u16*)BG_BMP_RAM_SUB(0);
videoSetModeSub(MODE_5_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG3_ACTIVE);
vramSetBankC(VRAM_C_SUB_BG);
SUB_BG3_CR = BG_BMP16_256x256 | BG_BMP_BASE(0) | BG_PRIORITY(3);
//attributes of the affine translation matrix
SUB_BG3_XDX = 1 << 8; //scale x
SUB_BG3_XDY = 0; //rotation x
SUB_BG3_YDX = 0; //scale y
SUB_BG3_YDY = 1 << 8; //scale y
SUB_BG3_CX = 0; //translation x
SUB_BG3_CY = 0; //translation y
SUB_BG0_CR = BG_MAP_BASE(31) | BG_PRIORITY(0);//use bg0 for the text
consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
|
#128880 - Dark Knight ez - Wed May 16, 2007 10:24 am
Easy one. Your BG3's graphics are using the same place as the console's graphics.
You use BG_BMP_BASE(0) for the former and CHAR_BASE_BLOCK_SUB(0) for the latter, effectively being the same place.
I'd suggest moving the console's map further to the front of the VRAM (I think there was a limit to where you can place maps, can't place it further down the VRAM) and just put BG3's graphics somewhat back in VRAM.
Quote: |
SUB_BG0_CR = BG_MAP_BASE(3) | BG_PRIORITY(0); // graphics at start, and map at 6kb into VRAM
consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(3), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
SUB_BG3_CR = BG_BMP16_256x256 | BG_BMP_BASE(2) | BG_PRIORITY(3); // graphics at 32kb into VRAM, should still be enough for your insanely VRAM-consuming background. |
_________________
AmplituDS website
#128937 - evilsanta - Wed May 16, 2007 9:15 pm
Thank you for your reply, it is working much better now...
However, when I do a full BG fill of the sub screen
Code: |
for(int i = 0; i < 256*256; i++)
vidBuffC[i] = RGB15(0,0,31) | BIT(15);
|
Then the text does not display...
Also I was wondering about something, when I set my BG3s location in VRAM to anything above the console, it doesnt work... is this because the mapping for the console takes up a lot?
EDIT: found that if I remove this consoleClear(); from my main loop it works... I have not yet tested it on actual hardware, but I have a guess as to how I can fix it, double buffering correct?
EDIT AGAIN: I have also just tested it on hardware, the text appears very faded and transparent... any ideas?
EDIT: Nvrmind, heh just shouldnt have consoleClear(). Thanks everyone for all the help! :)
#129024 - evilsanta - Fri May 18, 2007 12:51 am
Hello, So far all had been going well... I had a bitmap bg on the mainscreen and subscreen, and the subscreen had a console setup... but now then wanted to add a console to the mainscreen, and then I started getting random black shapes on the bottom screen...
Currently my memory map looks like this
Main BG 2 - BG_BMP_BASE(3)
Main BG 0 - BG_MAP_BASE(5) (console)
Sub BG 3 - BG_BMP_BASE(2)
Sub BG 0 - BG_MAP_BASE(4) (console)
Does my memory layout look ok? Im thinking it might just be the emulator I am using...
#129040 - Dark Knight ez - Fri May 18, 2007 9:54 am
o.O'
You use printf or iprintf to write to the console... how were you possibly going to make those calls know if you meant printing to your main- or subscreen?
_________________
AmplituDS website
#129121 - evilsanta - Sat May 19, 2007 3:11 am
I am sorry, but I do not know what you mean, do I not just change the consoleinit to the proper memory each time I want to write to that screen? Because so far it appears to be working just fine on hardware...
Code: |
consoleInitDefault((u16*)SCREEN_BASE_BLOCK(5), (u16*)CHAR_BASE_BLOCK(0), 16);
printf("Hello Top Screen");
consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(4), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
printf("Hello Bottom Screen");
|
#129130 - Dark Knight ez - Sat May 19, 2007 11:00 am
I see... quite the hassle.
Anyway, show the code you added for the mainscreen's console.
_________________
AmplituDS website
#129139 - evilsanta - Sat May 19, 2007 4:17 pm
Well, it seems to work on hardware, I was just wondering if my memory setup would cause anyproblems...
But is there a better way to enable the console on both the bottom and top screen? Anyways if you wanted to see my code...
Code: |
///////////////
//MAIN //
///////////////
u16* vidBuffA = (u16*)BG_BMP_RAM(3); //Point a video buffer to the start of BG 2
videoSetMode(MODE_5_2D | DISPLAY_BG2_ACTIVE | DISPLAY_BG0_ACTIVE); //Set mode to 5, with BG2 active
//Initialize BG
BG2_CR = BG_BMP16_256x256 | BG_BMP_BASE(3) | BG_PRIORITY(2);
BG2_XDX = 1<<8;
BG2_XDY = 0;
BG2_YDX = 0;
BG2_YDY = 1<<8;
BG2_CY = 0;
BG2_CX = 0;
//dmaCopy(Splash_bin, (u16*)BG_BMP_RAM(3), Splash_bin_size);
//CONSOLE
BG0_CR = BG_MAP_BASE(5) | BG_PRIORITY(0);//use bg0 for the text
//consoleInitDefault((u16*)SCREEN_BASE_BLOCK(5), (u16*)CHAR_BASE_BLOCK(0), 16);
BG_PALETTE[255] = RGB15(31,31,31); //change color of text
|
#129158 - Dark Knight ez - Sat May 19, 2007 10:01 pm
Apart from writing your own code, I don't think there is.
And if it works on hardware, then there's no need for me to look through your code... emulators aren't perfect, you realised that yourself. :)
_________________
AmplituDS website
#129172 - tepples - Sun May 20, 2007 1:21 am
If it works on hardware but not on an emulator, then please simplify the code to the minimal program that produces this behavior, and send the source code and binary to the emulator's maintainer as a test case.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#129175 - odelot - Sun May 20, 2007 1:46 am
hey... i am trying to do almost the same thing that you want... but i couldnt put text to work yet..
i am using bank A and bank B for framebuffer on main screen (to make double buffering) and C for the framebuffer of subscreen
Code: |
//initializing the bank A, B and C. Note that C bank is set to be used in sub screen
vramSetBankA (VRAM_A_MAIN_BG_0x06000000);
vramSetBankB (VRAM_B_MAIN_BG_0x06020000);
vramSetBankC (VRAM_C_SUB_BG_0x06200000); |
what banks can I use to for text backgrounds on each screen?? how are you doing this???