Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 11th, 2012  |  syntax: C  |  size: 1.71 KB  |  views: 107  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <gb\gb.h>
  2. #include "Export.h"
  3.  
  4. // Sprite palletes colours. There are eight possible palletes to choose from.
  5. UWORD pcolours[] =
  6. {
  7.         TileLabelCGBPal0c0,TileLabelCGBPal0c1,TileLabelCGBPal0c2,TileLabelCGBPal0c3,
  8.         TileLabelCGBPal1c0,TileLabelCGBPal1c1,TileLabelCGBPal1c2,TileLabelCGBPal1c3,
  9.         TileLabelCGBPal2c0,TileLabelCGBPal2c1,TileLabelCGBPal2c2,TileLabelCGBPal2c3,
  10.         TileLabelCGBPal3c0,TileLabelCGBPal3c1,TileLabelCGBPal3c2,TileLabelCGBPal3c3,
  11.         TileLabelCGBPal4c0,TileLabelCGBPal4c1,TileLabelCGBPal4c2,TileLabelCGBPal4c3,
  12.         TileLabelCGBPal5c0,TileLabelCGBPal5c1,TileLabelCGBPal5c2,TileLabelCGBPal5c3,
  13.         TileLabelCGBPal6c0,TileLabelCGBPal6c1,TileLabelCGBPal6c2,TileLabelCGBPal6c3,
  14.         TileLabelCGBPal7c0,TileLabelCGBPal7c1,TileLabelCGBPal7c2,TileLabelCGBPal7c3,
  15. };
  16.  
  17. // init_pallete() loads the pallete colours to VRAM
  18. void init_palette()
  19. {
  20.         set_sprite_palette( 0, 8, pcolours);            // loads the 8 palletes stored in
  21.                                                         // array pcolours
  22.  
  23.  
  24. }
  25.  
  26. void main()
  27. {
  28.         DISPLAY_OFF;
  29.        
  30.         SPRITES_8x16;                           // sets sprites to 8x16 mode
  31.  
  32.         init_palette();                                 // loads the pallete colours
  33.  
  34.         VBK_REG = 0;                                    // switch to Video Bank register 0
  35.        
  36.                 set_sprite_data(0, 2, TileLabel);       // load two tiles, starting at zero
  37.                
  38.                 //set_sprite_tile(0, 0);                        // link sprite 0 to tile 0 (NOTE: since
  39.                                                         // the GBC is in 8x16 mode, the next tile
  40.                                                         // is automatically linked to 0 as well
  41.                                                        
  42.         VBK_REG = 1;                                    // switch to Video Bank register 1
  43.        
  44.                 set_sprite_prop(0, TileLabelCGB[0]);            // assign the pallete for sprite 0 to be
  45.                                                         // the 0th entry in the pallete list
  46.  
  47.  
  48.         move_sprite(0, 80, 80);                         // move sprite 0 to (80, 80) which is the
  49.                                                         // centre of the screen
  50.  
  51.  
  52.  
  53.         SHOW_SPRITES;
  54.        
  55.         DISPLAY_ON;
  56. }