Exemplo n.º 1
0
// Function: main() ======================================================================
int main()
{
  // Variables
  map_fragment_info_ptr bg_background;

  // Initialize HAMlib
  ham_Init();

  // Set system prefetch
  //hel_SysSetPrefetch(TRUE);
 
  // Initialize Splash-Screen System
  hel_SplashInit((void*)g_SplashScreenSystemBuffer);

  // Enter bg mode 4 for the splash screen
  ham_SetBgMode(4);

  // Splashscreen 1
  hel_Splash
    (
       (u16*)ResData(RES_SPLASHSCREEN_RAW),  // pBitmap
       (u16*)ResData(RES_SPLASHSCREEN_PAL),  // pPalette
       RGB(0,0,0),                  // InBlendColor
       RGB(0,0,0),                  // OutBlendColor
       60,                          // BlendDelay
       2000,                        // DisplayDelay
       500,                         // ContinueDelay
       COMPRESSION_TYPE_NONE,       // CompressionType,
       0                            // Flags
    );
  
  // Quit the splashscreen
  hel_SplashQuit();

  // Setup the background mode
  ham_SetBgMode(1);

  // Initialize the text display system
  ham_InitText(0);

  // Initialize the palettes
  ham_LoadBGPal((void*)background_Palette, 256);
  ham_LoadObjPal((void*)object_Palette, 256);

  // Set the Text Color
  ham_SetTextCol(195, 40);
 
  // Setup the tileset for our image
  ham_bg[1].ti = ham_InitTileSet((void*)background_Tiles, SIZEOF_16BIT(background_Tiles), 1, 1);

  // Setup the map for our image
  ham_bg[1].mi = ham_InitMapEmptySet(3,0);
  bg_background = ham_InitMapFragment((void*)background_Map, 60, 20, 0, 0, 60, 20, 0);

  // Copy (the whole) map to BG0 at x=0, y=0
  ham_InsertMapFragment(bg_background, 1, 0, 0);

  // Display the background
  ham_InitBg(1, 1, 2, 1);

  // Setup the array spot
  array_spot = (32768 * dir_dk) + (4096 * animcnt);

  // setup the initial state of the frame bits counter
  frameCounter = 0;

  // Setup the dk
  dk = ham_CreateObj(
       (void *)&dk_Bitmap[array_spot],
       0,3,OBJ_MODE_NORMAL,1,0,0,0,0,0,0,dk_x,dk_y);

  // Start the VBL interrupt handler
  ham_StartIntHandler(INT_TYPE_VBL, (void*)&vbl_func);

  while (1)
  {
    if (newframe)
    {
      // Write some stuff to the screen
      ham_DrawText(1, 1, "480x160 background");
      ham_DrawText(1, 2, "Arrows to scroll left-right");

      ham_DrawText(1, 17, "scroll-x: %5d", map_x);
      ham_DrawText(1, 18, "frame: %5d", frameCounter);

      // Let the user move the map around
      if (F_CTRLINPUT_RIGHT_PRESSED)
      {
        if (map_x < (480 - 240))
          ham_SetBgXY(1, ++map_x, 0);
      }
      if (F_CTRLINPUT_LEFT_PRESSED)
      {
        if (map_x > 0)
          ham_SetBgXY(1, --map_x, 0);
      }
      newframe = 0; // No longer a new frame
    } // End of if(newframe)
  } // End of while(1)

  return 0;
} // End of main()
Exemplo n.º 2
0
Arquivo: game.c Projeto: yxrkt/DigiPen
//**************//
// Game Init    //
//**************//
int GSGame()
{
    map_fragment_info_ptr bg_world;
    
    // setup background
    if ( g_initObjs )
    {
        ham_SetBgMode(1);
        ham_LoadBGPal((void *)world_palette, 256);
        ham_bg[0].ti = ham_InitTileSet((void *)world_tiles, SIZEOF_16BIT(world_tiles), 1, 1);
        ham_bg[0].mi = ham_InitMapEmptySet(3, 0);
        bg_world = ham_InitMapFragment((void *)world_map, 64, 64, 0, 0, 64, 64, 0);
        ham_InsertMapFragment(bg_world, 0, 0, 0);
        ham_InitBg(0, 1, 0, 0);
    }

    // set screen pos
    g_cam_x = 0;
    g_cam_y = 0;

    // setup hippy
    g_hippy.dir       = FACE_DOWN;
    g_hippy.baseFrame = 0;
    g_hippy.frameDif  = 0;
    g_hippy.w         = 32;
    g_hippy.h         = 64;
    g_hippy.x         = SCREEN_WIDTH / 4;
    g_hippy.y         = SCREEN_HEIGHT / 2 - g_hippy.h / 2;
    if ( g_initObjs )
    {
        ham_LoadObjPal((void *)hippy_palette, 256);
        g_hippy.sprite = ham_CreateObj((void *)&hippy_bitmap[0], OBJ_SIZE_32X64, OBJ_MODE_NORMAL, 1, 0, 0, 0, 0, 0, 0, g_hippy.x, g_hippy.y);
    }
    
    // setup poison shroom
    g_shroom.dir       = FACE_DOWN;
    g_shroom.baseFrame = 0;
    g_shroom.frameDif  = 0;
    g_shroom.x         = 230;
    g_shroom.y         = 75;
    g_shroom.w         = 32;
    g_shroom.h         = 32;
    if ( g_initObjs )
    {
        //ham_LoadObjPal((void *)shroom_palette, 256);
        g_shroom.sprite = ham_CreateObj((void *)&shroom_bitmap[0], OBJ_SIZE_32X32, OBJ_MODE_NORMAL, 1, 0, 0, 0, 0, 0, 0, g_shroom.x, g_shroom.y);
    }
    
    // setup key
    g_key.dir       = FACE_DOWN;
    g_key.baseFrame = 0;
    g_key.frameDif  = 0;
    g_key.x         = 262;
    g_key.y         = 75;
    g_key.w         = 16;
    g_key.h         = 16;
    if ( g_initObjs )
    {
        //ham_LoadObjPal((void *)hippy_palette, 256);
        g_key.sprite = ham_CreateObj((void *)&key_bitmap[0], OBJ_SIZE_16X16, OBJ_MODE_NORMAL, 1, 0, 0, 0, 0, 0, 0, g_key.x, g_key.y);
    }
    
    // setup lives
    g_lifeCount.dir       = FACE_DOWN;
    g_lifeCount.baseFrame = g_lives;
    g_lifeCount.frameDif  = 0;
    g_lifeCount.x         = 0;
    g_lifeCount.y         = 0;
    g_lifeCount.w         = 16;
    g_lifeCount.h         = 16;
    if ( g_initObjs )
    {
        //ham_LoadObjPal((void *)hippy_palette, 256);
        g_lifeCount.sprite = ham_CreateObj((void *)&lives_bitmap[0], OBJ_SIZE_16X16, OBJ_MODE_NORMAL, 1, 0, 0, 0, 0, 0, 0, g_lifeCount.x, g_lifeCount.y);
        ham_UpdateObjGfx(g_lifeCount.sprite, (void *)&lives_bitmap[g_lifeCount.w * g_lifeCount.h * g_lives]);
    }
    ham_SetFxMode(FX_LAYER_SELECT(0, 0, 0, 0, 1, 0), FX_LAYER_SELECT(1, 0, 0, 0, 0, 0), FX_MODE_ALPHABLEND);
    ham_SetFxAlphaLevel(15, 8);
    
    // setup fireball
    g_fireBall.dir       = FACE_DOWN;
    g_fireBall.baseFrame = 0;
    g_fireBall.frameDif  = 0;
    g_fireBall.x         = 241;
    g_fireBall.y         = 0;
    g_fireBall.w         = 16;
    g_fireBall.h         = 16;
    if ( g_initObjs )
    {
        g_fireBall.sprite = ham_CreateObj((void *)&fire_bitmap[0], OBJ_SIZE_16X16, OBJ_MODE_NORMAL, 1, 0, 0, 0, 0, 0, 0, g_fireBall.x, g_fireBall.y);
    }
    g_firing = FALSE;
    ham_SetObjRotSetSelect(g_fireBall.sprite, ROTATION_SET);
    ham_SetObjRotEnable(g_fireBall.sprite, 1);

    g_initObjs = FALSE;
    return 1;
}