==========================程序的源代码===================================
/* firstexample.c
* example sourcecode for compiler-testing and first-step tutorial
*/
#include
void display_screen(char *str)
{
int xpos, ypos, offset;
char current;
xpos = 2;
ypos = 1;
while(*str)
{
// Calculation of Screenoffset from Position
offset = (xpos*12) + ((ypos* (24+4)) * 640);
// Grab the next Element from the String and increase pointer
current=*str++;
// If we have a normal character then print it to screen
if(current != '\n')
{
bfont_draw(vram_s + offset,640, 0, current);
xpos++;
}
// If we have a '\n' then start at a new line
else
{
xpos = 2;
ypos ++;
}
}
}
int main(int argc, char **argv)
{
cont_cond_t cond;
char cOutput[] = "Hello World...\n\n"
" Sorry, couldn't resist. The line above haunts\n"
"me since the beginning of my programming efforts\n"
"on the good old Commodore 64.\n\n"
"But if you are able to see this text you success-\n"
"fully compiled GCC, BinUtils, Newlib, KOS and this\n"
"tiny example\n\n"
"This really serves no purpose except showing that\n"
"everything worked so far ;)\n\n"
"Happy coding......";
// First we initialize KallistiOS with no ROMDISK
kos_init_all(NONE_ENABLE, ROMDISK_NONE);
// Now we set the 640x480 Videomode on the DC
vid_set_mode(DM_640x480, PM_RGB565);
// Now we use the self-written primitive screen displayer
display_screen(cOutput);
// Wait for user pressing start
while(1)
{
if (cont_get_cond(maple_first_controller(), &cond) < 0)
break;
if (!(cond.buttons & CONT_START))
break;
// We have to do *something* in this loop otherwise the compiler
// will make some crazy things (just terminating because it
// can't read the condition of the Controlle:w
timer_spin_sleep(10);
}
// Shut down KallistiOS
kos_shutdown_all();
return 0;
}
=============================结束=================================
<