~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to languages/cpp/app_templates/chello_gba/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%{CPP_TEMPLATE}
2
 
 
3
 
#include "main.h"
4
 
 
5
 
int main(){
6
 
  initTextMode();
7
 
  print("HELLO WORLD",9,9);
8
 
  while(1){}    //loop forever
9
 
   
10
 
}
11
 
 
12
 
 
13
 
void print(char* text,u16 x,u16 y){
14
 
  u16 i=0;
15
 
  u16* ScreenBase = (u16*)0x6004000;
16
 
  ScreenBase = ScreenBase + x + y*32;
17
 
  while ( *text != '\0' ){
18
 
 
19
 
    *ScreenBase++ = (u16)*text-'A'+1;
20
 
    i++;
21
 
    text++;
22
 
  }
23
 
}
24
 
 
25
 
void initTextMode(){
26
 
  REG_DISPCNT = (MODE0 | BG2_ENABLE);  //this sets the screen mode to mode 0 and enables background 2
27
 
  
28
 
  // 256 colors and charscreenbase 0, screenbase 8
29
 
  // default size is 256x256 pixel
30
 
  REG_BG2CNT = (1 << 7 | 0 << 2 | 8 << 8); 
31
 
  
32
 
  
33
 
  u16* palDest=(u16*)BGPaletteMem; //0x5000000
34
 
  u16* palSource = (u16*)Master_Palette;
35
 
  // copy the palette info (256 colors a 15/16 Bit) into the desired address 
36
 
  u16 i=0;
37
 
  for (;i<256;i++) {
38
 
    *palDest++ = *palSource++;
39
 
  }
40
 
  
41
 
  // copy the tiles to charbase 0, (0x6000000 start of the videobuffer)
42
 
  u16* fontDest = (u16*)VideoBuffer; //this is the start of video memory
43
 
  u16* fontSource = (u16*)font_Tiles;
44
 
  i=0;
45
 
  for(;i<1920;i=i+2){
46
 
    *fontDest++ = *fontSource++;
47
 
  }
48
 
}
49
 
 
50