#99148 - MaHe - Sat Aug 19, 2006 8:08 pm
I started programming with PA_Lib in quickly got hang of it. But I was a bit annoyed with it - it sure is easy to use, but it's got it's own limitations, and since Mollusk isn't the main coder anymore, it's really buggy. I've decided to move to libnds and figured out, that I'm actually still a newbie. I didn't know zilch. So here's a 'Hello, World' code I wrote for myself:
(yes, the comments are wrong, but I don't care just yet)
This will output 'Pozdravljen, svet!' (Hello, world in my language) on the touch-screen. I'm fine with that, but now I'd like to put it on the top screen. So, I've modified the code:
Now, this won't work. It only colors the top screen to black, but won't output anything.
Now, I'm sure this is very, very stupid to most of you, experienced coders, but I want to know what have I overlooked ... ?
Thanks in advance! =)
_________________
[ Crimson and Black Nintendo DS Lite | CycloDS Evolution | EZ-Flash 3-in-1 | 1 GB Transcend microSD ]
Code: |
/*********************************************
Name: Hello, world! Author: Matjaz 'MaHe' Hegedic Version: 0.01 **********************************************/ // Includes // #include <nds.h> // Include 'libnds' in our application #include <nds/arm9/console.h> // Include the basic print functionality in our application #include <stdio.h> // Include 'stdio' in our application // Functions // int main() { videoSetMode(0); // Use the top screen only videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); // Use subbackground 0 to display text vramSetBankC(VRAM_C_SUB_BG); // Map VRAM bank C to subbackground SUB_BG0_CR = BG_MAP_BASE(31); // Set subbackground 0 to 'black' BG_PALETTE_SUB[255] = RGB15(31,31,31); // Set the text color to 'white' // Initialise the default console settings for the text output consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); // Output 'Pozdravljen, svet' to the screen iprintf("Pozdravljen, svet!"); // Loop infinitely while(1) { swiWaitForVBlank(); } return 0; } |
This will output 'Pozdravljen, svet!' (Hello, world in my language) on the touch-screen. I'm fine with that, but now I'd like to put it on the top screen. So, I've modified the code:
Code: |
int main() {
videoSetMode(MODE_0_2D | DISPLAY_BG0_ACTIVE); videoSetModeSub(0); vramSetBankC(VRAM_C_MAIN_BG); BG0_CR = BG_MAP_BASE(31); BG_PALETTE[255] = RGB15(31,31,31); // Initialise the default console settings for the text output consoleInitDefault((u16*)SCREEN_BASE_BLOCK(31), (u16*)CHAR_BASE_BLOCK(0), 16); // Output 'Pozdravljen, svet' to the screen iprintf("Pozdravljen, svet!"); // Loop infinitely while(1) { swiWaitForVBlank(); } return 0; } |
Now, I'm sure this is very, very stupid to most of you, experienced coders, but I want to know what have I overlooked ... ?
Thanks in advance! =)
_________________
[ Crimson and Black Nintendo DS Lite | CycloDS Evolution | EZ-Flash 3-in-1 | 1 GB Transcend microSD ]