Example #1
0
/*MENU*/
int menu(){
   u8* memptr;
   int init = 50;
   int pushed =0;
   int cont =0;
   cpct_clearScreen(0);

   memptr = cpct_getScreenPtr(VMEM,10,10);
   cpct_drawSprite(portada1,memptr,60,60);

   //Opciones
   memptr = cpct_getScreenPtr(VMEM,20,90);
   cpct_drawStringM0("Nueva Partida",memptr,1,0);

   memptr = cpct_getScreenPtr(VMEM,20,110);
   cpct_drawStringM0("Creditos",memptr,1,0);

   memptr = cpct_getScreenPtr(VMEM,20,130);
   cpct_drawStringM0("Constroles",memptr,1,0);

   memptr = cpct_getScreenPtr(VMEM,20,150);
   cpct_drawStringM0("Salir",memptr,1,0);

    /*memptr = cpct_getScreenPtr(VMEM,18,180);
   cpct_drawStringM0("Pulsa Intro",memptr,4,5);*/

   //Indicador
   while(1){

      cpct_scanKeyboard();
      if(cpct_isKeyPressed(Key_CursorDown) && cont > 150){
        cpct_drawSolidBox(memptr, 0, 2, 8);
        if(pushed<3) pushed ++;
        cont =0;
      }
      if(cpct_isKeyPressed(Key_CursorUp) && cont > 150){
        cpct_drawSolidBox(memptr, 0, 2, 8);
        if(pushed>0) pushed --;
        cont = 0;
      }

      switch (pushed){
        case 0: init = 90;break;
        case 1: init = 110;break;
        case 2: init = 130;break;
        case 3: init = 150;break;
      }
      memptr = cpct_getScreenPtr(VMEM,15,init);
      cpct_drawSprite(marcador,memptr, 2, 8);
      if(cpct_isKeyPressed(Key_Space)){
        switch (pushed){
        case 0: return 1;break;
        case 1: return 2;break;
        case 2: return 3;break;
        case 3: return 0;break;
      }
      }
      cont++;
   }
}
Example #2
0
void playMenu() {
		u8 option=0;

		cpct_etm_setTileset2x4(g_tile_tileset_bg);
		cpct_etm_drawTilemap2x4_f(MAP_WIDTH_TILES, MAP_HEIGHT_TILES, SCR_VMEM, g_background);

		cpct_drawSprite (g_tile_titulo, getScreenPosition(5, 2), 32, 16);
		cpct_drawStringM0 ("PLAY GAME", getScreenPosition(5, 5), 15, 7);
		cpct_drawStringM0 ("INFINITY MODE", getScreenPosition(6, 7), 15, 7);
		cpct_drawStringM0 ("LEVELS MODE", getScreenPosition(6, 9), 15, 7);

		initScroll();
		initPlayer();
		cpct_scanKeyboard_f ();
		do {
			waitNVSYNCs(3);
			cpct_akp_musicPlay();
			Road();
			drawPlayer();
			if ( cpct_isKeyPressed (Key_Esc)) {
				gameScene=MENUSCREEN;
				return;
			}
			else if ( cpct_isKeyPressed (Key_CursorUp) && option != 0) {
				--option;
			}
			else if ( cpct_isKeyPressed (Key_CursorDown) && option != 1) {
				++option;
			}

			switch (option) {
				case 0:
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(4, 9), 4, 8);
					cpct_drawSprite(sprite_skate, getScreenPosition(4, 7), 4, 8);
					break;
				case 1:
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(4, 7), 4, 8);
					cpct_drawSprite(sprite_skate, getScreenPosition(4, 9), 4, 8);
					break;
			}
			cpct_scanKeyboard_f ();
//			waitNVSYNCs(5);
	} while (!cpct_isKeyPressed(Key_Return));

		switch (option) {
			case 0:
				cpct_akp_stop();
				gameScene=PLAYGAMESCREEN;
				break;
			case 1:
				cpct_akp_stop();
				gameScene=NEXTLEVELSCREEN;
				break;
		}
}
Example #3
0
////////////////////////////////////////////////////////////////////////////////
// Initializes elements of the screen on the initialization of a new game
//
void initializeGameScreen(u16 hiscore) {
   u8* pscr;   // Pointer to the screen location where we want to draw
   u8  c;      // Colour pattern to draw
   u8  str[6]; // Score
   
   // Clear the screen
   cpct_clearScreen(0);

   //
   // Draw backgrounds and Hi-Score
   //
   c = cpct_px2byteM0(8,8);  // Colour pattern 8-8 (black-black)
   
   // Draw black background for scoreboard
   pscr = cpct_getScreenPtr(CPCT_VMEM_START, 54,   0);  
   cpct_drawSolidBox(pscr, c, 26, 200);

   // Draw "HI" string 
   pscr = cpct_getScreenPtr(CPCT_VMEM_START, 60,  16);   
   cpct_drawStringM0("HI", pscr, 3, 8);

   // Draw HI-Score
   pscr = cpct_getScreenPtr(CPCT_VMEM_START, 60,  24);
   sprintf(str, "%5u", hiscore);
   cpct_drawStringM0(str, pscr, 15, 8);

   // Draw Credits
   pscr = cpct_getScreenPtr(CPCT_VMEM_START, 60, 172);
   cpct_drawSprite(G_credits, pscr, 20, 27);

   // Draw tiled frame around playing area
   drawFrame(CPCT_VMEM_START, 0);
}
Example #4
0
//////////////////////////////////////////////////////////////////
// drawMenu
//
//
//
// Returns:
//    void
//
void drawMenu() {
    u8* pvmem;

    cpct_waitVSYNC();

    cpct_memset(CPCT_VMEM_START, cpct_px2byteM0(0, 0), 0x4000);

    //Small Logo
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 23, 0);
    cpct_drawSprite(logo_micro, pvmem, 5, 18);

    drawText("AMSTHREES", 30, 4, 0);

    // Session Highest Card
    drawText("SESSION", 1, 57, 0);
    drawText("HIGH", 5, 72, 0);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 7, 92);
    cpct_drawSprite(cards[highestCardAll], pvmem, CARD_W, CARD_H);

    drawFrame(23, 43, 76, 151);

    //Camelot Mode Badgae
    if (camelotMode) {
        pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 80 - G_CAMELOTBADGE_W, 8);
        cpct_drawSpriteMaskedAlignedTable(g_camelotBadge, pvmem, G_CAMELOTBADGE_W, G_CAMELOTBADGE_H, am_tablatrans);
    }

    drawText("REDEFINE", 38, 60, 0);
    drawText("MUSIC", 38, 80, 0);
    if (playing)
        drawText("OFF", 56, 80, 0);
    else
        drawText("ON", 56, 80, 0);
    drawText("HELP", 38, 100, 0);
    drawText("PLAY", 38, 120, 0);

    drawNumber(1, 1, 31, 60);
    drawNumber(2, 1, 31, 80);
    drawNumber(3, 1, 31, 100);
    drawNumber(4, 1, 31, 120);


    drawText("JOHN LOBO", 25, 170, 1);
    drawText("@ GLASNOST CORP 2016", 11, 185, 1);

    drawMarker();
}
Example #5
0
void mainMenu() {
		u8 option=0;
		cpct_etm_setTileset2x4(g_tile_tileset_bg);
		cpct_etm_drawTilemap2x4_f(MAP_WIDTH_TILES, MAP_HEIGHT_TILES, SCR_VMEM, g_background);

		cpct_drawSprite (g_tile_titulo, getScreenPosition(5, 2), 32, 16);
		cpct_drawStringM0 ("PLAY GAME", getScreenPosition(5, 5), 15, 7);
		cpct_drawStringM0 ("CONTROLS", getScreenPosition(5, 7), 15, 7);
		cpct_drawStringM0 ("CREDITS", getScreenPosition(5, 9), 15, 7);

		initScroll();
		initPlayer();
		cpct_scanKeyboard_f ();
		do {
		    waitNVSYNCs(3);
			cpct_akp_musicPlay();

			Road();
			drawPlayer();
			if ( cpct_isKeyPressed (Key_CursorUp) && option != 0) {
				--option;
			}
			else if ( cpct_isKeyPressed (Key_CursorDown) && option != 2) {
				++option;
			}

			switch (option) {
				case 0:
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(3, 7), 4, 8);
					cpct_drawSprite(sprite_skate, getScreenPosition(3, 5), 4, 8);
					break;
				case 1:
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(3, 5), 4, 8);
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(3, 9), 4, 8);
					cpct_drawSprite(sprite_skate, getScreenPosition(3, 7), 4, 8);
					break;
				case 2:
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(3, 7), 4, 8);
					cpct_drawSprite(sprite_skate, getScreenPosition(3, 9), 4, 8);
					break;
			}
			cpct_scanKeyboard_f ();
//			waitNVSYNCs(5);
	} while (!cpct_isKeyPressed(Key_Return));

		switch (option) {
    		case 0:	playMenu();
				break;
    		case 1: 
				gameScene=CONTROLSSCREEN;
				break;
		    case 2: 
				gameScene=CREDITSSCEENE;
				break;
		}
}
Example #6
0
////////////////////////////////////////////////////////////////////////////////////////////////
// Draw a frame around play area, using frame tiles.
//    pscr: Pointer to the upper-left corner of the screen / buffer where frame is to be drawn
//       x: X coordinate where the frame starts
//
void drawFrame(u8* pscr, u8 x) {
   u8 *pvmem;     // Pointer to video memory (used for drawing tiles)
   u8 i;          // Counter for loops

   //------ Draw Up-Left and Up-Right Corners
   pvmem = cpct_getScreenPtr(pscr, x, 0);
   cpct_drawTileAligned4x8(G_frameUpLeftCorner,  pvmem);       // Up-Left
   cpct_drawTileAligned4x8(G_frameUpRightCorner, pvmem + 54);  // Up-Right
   
   //------ Draw left and right borders
   for(i=8; i < 192; i += 8) {
      pvmem = cpct_getScreenPtr(pscr, x, i);
      cpct_drawTileAligned4x8(G_frameLeft,  pvmem);      // Left border
      cpct_drawTileAligned4x8(G_frameRight, pvmem + 54); // Right border
   }

   //------ Draw upper border
   pvmem = cpct_getScreenPtr(pscr, x, 0);
   for(i=4; i < 28; i += 4) {
      pvmem += 4;
      cpct_drawTileAligned4x8(G_frameUp, pvmem);       // Left part 
      cpct_drawTileAligned4x8(G_frameUp, pvmem + 26);  // Right part
   }
   cpct_drawSprite(G_frameUpCenter, pvmem + 2, 6, 8);  // Central tile
   
   //------ Draw down border
   pvmem = cpct_getScreenPtr(pscr, x, 192);
   for(i=4; i < 28; i += 4) {
      pvmem += 4;
      cpct_drawTileAligned4x8(G_frameDown, pvmem);       // Left part
      cpct_drawTileAligned4x8(G_frameDown, pvmem + 26);  // Right part
   }
   cpct_drawSprite(G_frameDownCenter, pvmem + 2, 6, 8);  // Central tile

   //------ Draw Down-Left and Down-Right Corners
   pvmem = cpct_getScreenPtr(pscr, x, 192);
   cpct_drawTileAligned4x8(G_frameDownLeftCorner,  pvmem);        // Down-Left
   cpct_drawTileAligned4x8(G_frameDownRightCorner, pvmem + 54);   // Down-Right
}
Example #7
0
//
// EXAMPLE: Measuring free cycles after moving an sprite
//
void main(void) {
   u8  i;                        // Loop index
   u8  x=0, y=0;                 // Sprite coordinates (in bytes)
   u8* pvideomem = (u8*)0xC000;  // Sprite initial video memory byte location (where it will be drawn)
   u16 avc = 0;                  // Available cycles until next VSYNC, after all main loop calculations

   // First, disable firmware to prevent it from intercepting our palette and video mode settings (and,
   // at the same time, winning some speed not having to process firmware code at every interrupt)
   cpct_disableFirmware();
   // Set palette and Screen Border (transform firmware to hardware colours and then set them)
   cpct_fw2hw     (G_palette, 4);
   cpct_setPalette(G_palette, 4);
   cpct_setBorder (G_palette[1]);
   // Ensure MODE 1 is set
   cpct_setVideoMode(1);

   // Main Loop
   while(1) {
      // First, wait VSYNC monitor signal to synchronize the loop with it. We'll start doing
      // calculations always at the same time (when VSYNC is first detected)
      cpct_waitVSYNC();

      // Scan Keyboard and change sprite location if cursor keys are pressed
      cpct_scanKeyboard_f();
      if      (cpct_isKeyPressed(Key_CursorRight) && x <  80 - SPR_W) { x++; pvideomem++; }
      else if (cpct_isKeyPressed(Key_CursorLeft)  && x >   0        ) { x--; pvideomem--; }
      if      (cpct_isKeyPressed(Key_CursorUp)    && y >   0        ) { pvideomem -= (y-- & 7) ? 0x0800 : 0xC850; }
      else if (cpct_isKeyPressed(Key_CursorDown)  && y < 200 - SPR_H) { pvideomem += (++y & 7) ? 0x0800 : 0xC850; }

      // Draw the sprite at its new location on screen. 
      // Sprite automatically erases previous copy of itself on the screen because it moves 
      // 1 byte at a time and has a 0x00 border that overwrites previous colours on that place
      cpct_drawSprite(G_death, pvideomem, SPR_W, SPR_H);
      
      // Wait to next VSYNC signal, calculating the amount of free cycles (time we wait for VSYNC)
      // As documented on <cpct_count2VSYNC>, function returns number of loop iterations (L), and 
      // cycles shall be calculated doing 22 + 34*L
      avc = 22 + 34 * cpct_count2VSYNC();

      // Print 5 digits on the upper right corner of the screen, 
      // with the amount of free cycles calculated in previous step. 
      // Digits will be printed at screen locations (0xC046, 0xC048, 0xC04A, 0xC04C, 0xC04E)
      for(i=0; i<5; i++) {
         u8 digit = '0' + (avc % 10);
         cpct_drawCharM1_f((void*)(0xC04E - 2*i), 3, 0, digit);
         avc /= 10;
      }
   }
}
Example #8
0
//
// Draw CPCtelera's Squared Banner (Mode 0)
//
void drawBanner() {
    // Video memory pointers for the 2 sprites that form the Squared banner
    u8 *pvideo_s1, *pvideo_s2;

    // Clear the screen filling it up with 0's
    cpct_clearScreen_f64(0);

    // Set Mode 0 Squared Banner palette and change to Mode 0
    cpct_setPalette  (G_banner_palette, 16);
    cpct_setVideoMode(0);

    // Draw CPCtelera's Squared Banner in 2 parts of 80x96 pixels (40x96 bytes in mode 0)
    // We have to draw it in two parts because cpct_drawSprite function cannot 
    // draw sprites wider than 63 bytes. 
    // Remember: in Mode 0, 1 byte = 2 pixels

    // Draw left part at screen byte coordinates  ( 0, 52) (pixel coordinates ( 0, 52))
    pvideo_s1 = cpct_getScreenPtr(SCR_VMEM,  0, 52);
    cpct_drawSprite(G_CPCt_left,  pvideo_s1, BANNER_W, BANNER_H);

    // Draw right part at screen byte coordinates (40, 52) (pixel coordinates (80, 52))
    pvideo_s2 = cpct_getScreenPtr(SCR_VMEM, 40, 52);
    cpct_drawSprite(G_CPCt_right, pvideo_s2, BANNER_W, BANNER_H);
}
Example #9
0
///////////////////////////////////////////////////////////////////////////////////////////////////
// Draw a given animated entity on the screen
//
void drawAnimEntity (TEntity* e) {
   // Check if needs to be redrawn
   if ( e->draw ) {
      // Get the entity values from its current animation status
      TAnimation* anim  = &e->graph.anim;
      TAnimFrame* frame = anim->frames[anim->frame_id];
   
      // Remove trails 
      cpct_drawSolidBox(e->pscreen, 0x00, e->pw, e->ph);

      // Draw the entity
      cpct_drawSprite(frame->sprite, e->npscreen, frame->width, frame->height);

      e->draw = 0;
   }
}
Example #10
0
//
// Draw CPCtelera's Logo (Mode 1)
//
void drawLogo() {
    // Pointer to video memory location where the logo will be drawn
    u8* pvideo;

    // Clear the screen filling it up with 0's
    cpct_clearScreen_f64(0);

    // Set Mode 1 Logo palette and change to Mode 1
    cpct_setPalette(G_logo_palette, 4);
    cpct_setVideoMode(1);     

    // Draw CPCtelera's Logo as one unique sprite 160x191 pixels (40x191 bytes in mode 1)
    // Remember: in Mode 1, 1 byte = 4 pixels    

    // Draw the sprite at screen byte coordinates (20, 4) (pixel coordinates (80, 4))
    pvideo = cpct_getScreenPtr(SCR_VMEM, 20, 4);
    cpct_drawSprite(G_CPCt_logo, pvideo, LOGO_W, LOGO_H);
}
Example #11
0
//
// MAIN: Using keyboard to move a sprite example
//
void main(void) {
   u8 x=20;                     // Sprite horizontal coordinate
   u8 lookingAt = LOOK_RIGHT;   // Know where the sprite is looking at 
   u8 nowLookingAt = lookingAt; // New looking direction after keypress

   // Initialize the Amstrad CPC
   initialize();

   // 
   // Infinite moving loop
   //
   while(1) {
      u8* pvideomem; // Pointer to video memory

      // Scan Keyboard (fastest routine)
      // The Keyboard has to be scanned to obtain pressed / not pressed status of
      // every key before checking each individual key's status.
      cpct_scanKeyboard_f();

      // Check if user has pressed a Cursor Key and, if so, move the sprite if
      // it will still be inside screen boundaries
      if (cpct_isKeyPressed(Key_CursorRight) && x < (SCR_W - SP_W) ) {
         ++x;
         nowLookingAt = LOOK_RIGHT;
      } else if (cpct_isKeyPressed(Key_CursorLeft)  && x > 0) {
         --x; 
         nowLookingAt = LOOK_LEFT;
      }

      // Check if we have changed looking direction      
      if (lookingAt != nowLookingAt) {
         lookingAt = nowLookingAt;
         cpct_hflipSpriteM0(SP_W, SP_H, g_spirit);
      }

      // Get video memory byte for coordinates x, y of the sprite (in bytes)
      pvideomem = cpct_getScreenPtr(CPCT_VMEM_START, x, FLOOR_Y - SP_H);

      // Draw the sprite in the video memory location got from coordinates x, y
      cpct_drawSprite(g_spirit, pvideomem, SP_W, SP_H);
   }
}
Example #12
0
//
// MAIN: Using keyboard to move a sprite example
//
void main(void) {
   u8  x=10, y=10;   // Sprite coordinates
   u8* pvideomem;    // Pointer to video memory

   //
   // Set up the screen
   //
   // Disable firmware to prevent it from interfering with setPalette and setVideoMode
   cpct_disableFirmware();

   // Set the colour palette
   cpct_fw2hw     (G_palette, 4); // Convert our palette from firmware to hardware colours 
   cpct_setPalette(G_palette, 4); // Set up the hardware palette using hardware colours
   
   // Set video mode 1 (320x200, 4 colours)
   cpct_setVideoMode(1);

   // 
   // Infinite moving loop
   //
   while(1) {
      // Scan Keyboard (fastest routine)
      // The Keyboard has to be scanned to obtain pressed / not pressed status of
      // every key before checking each individual key's status.
      cpct_scanKeyboard_f();

      // Check if user has pressed a Cursor Key and, if so, move the sprite if
      // it will still be inside screen boundaries
      if      (cpct_isKeyPressed(Key_CursorRight) && x < (SCR_W - SP_W) ) ++x; 
      else if (cpct_isKeyPressed(Key_CursorLeft)  && x > 0              ) --x; 
      if      (cpct_isKeyPressed(Key_CursorUp)    && y > 0              ) --y;
      else if (cpct_isKeyPressed(Key_CursorDown)  && y < (SCR_H - SP_H) ) ++y;
      
      // Get video memory byte for coordinates x, y of the sprite (in bytes)
      pvideomem = cpct_getScreenPtr(CPCT_VMEM_START, x, y);

      // Draw the sprite in the video memory location got from coordinates x, y
      cpct_drawSprite(G_spriteLogoCT, pvideomem, SP_W, SP_H);
   }
}
Example #13
0
void printCells() {
    u8 i;
    u8 j;
    u8 x;
    u8 y;
    u8* pvmem;  // Pointer to video memory

    for (i = 0; i < 4; i++) {
        //y = 30 + (i * 10);
        y = 4 + (i * 48);

        for (j = 0; j < 4; j++) {
            //  x = 3 + (j * 12);
            x = 6 + (j * 12);
            if (cells[i][j] > 0) {
                pvmem = cpct_getScreenPtr(CPCT_VMEM_START, x, y);
                cpct_drawSpriteMaskedAlignedTable(cards[cells[i][j]], pvmem, CARD_W, CARD_H, am_tablatrans);
            }
        }
    }
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 63, 18);
    cpct_drawSprite(cards[cardBag[currentCard]], pvmem, CARD_W, CARD_H);
}
Example #14
0
/*GAME OVER*/
void gameOver(){
    u8* memptr;
  cpct_clearScreen(0);
  memptr = cpct_getScreenPtr(VMEM,10,10);
  cpct_drawStringM0("Lounge Gladiator",memptr,1,0);

    memptr = cpct_getScreenPtr(VMEM,10,50);
   cpct_drawSprite(gameover,memptr,60,28);


  memptr = cpct_getScreenPtr(VMEM, 12, 175); 
  cpct_drawStringM0("Pulsa espacio", memptr, 1, 0); 



  while (1){
    cpct_scanKeyboard_f();
     if(cpct_isKeyPressed(Key_Space)) {

        return;
      }

   }
}
Example #15
0
void getName() {
    u8* pvmem;
    u8 moved, pos, chr;
    u8 markerX, markerY;

    drawFrame(9, 60, 73, 150);

    drawText("NEW HIGH SCORE", 20, 70, 1);
    drawText("ENTER YOUR NAME", 18, 85, 1);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 11, 100);
    cpct_drawSprite(g_tile_symbols_1, pvmem, 3, 11);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 14, 100);
    cpct_drawSprite(g_tile_symbols_2, pvmem, 3, 11);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 17, 100);
    cpct_drawSprite(g_tile_symbols_3, pvmem, 3, 11);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 20, 100);
    cpct_drawSprite(g_tile_symbols_4, pvmem, 3, 11);
    drawText("CHANGE LETTER", 24, 100, 0);
    drawText(" _ TO END", 20, 115, 1);
    drawFrame(12, 130, 70, 160);
    strcpy(newNameHighScore, "A");
    drawText(newNameHighScore, 16, 140, 0);

    markerX = 15;
    markerY = 138;
    cpct_setBlendMode(CPCT_BLEND_XOR);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, markerX, markerY);
    cpct_drawSpriteBlended(pvmem, AM_MARKER_H, AM_MARKER_W, am_marker);
    pos = 0;
    chr = 65;
    moved = 0;
    while (1) {
        delay(24);

        if ((cpct_isKeyPressed(Joy0_Down)) || (cpct_isKeyPressed(keys.down))) {
            chr++;
            moved = 1;
        } else if ((cpct_isKeyPressed(Joy0_Up)) || (cpct_isKeyPressed(keys.up))) {
            chr--;
            moved = 1;
        } else if ((pos < 14) && ((cpct_isKeyPressed(Joy0_Right)) || (cpct_isKeyPressed(Joy0_Fire1)) || (cpct_isKeyPressed(keys.right)))) {
            if (chr == 95) {
                newNameHighScore[pos] = '\0';
                break;
            }
            else {
                pos++;
                newNameHighScore[pos] = 65;
                newNameHighScore[pos + 1] = '\0';
                chr = 65;
                moved = 1;
            }

        } else if ((pos > 0) && ((cpct_isKeyPressed(Joy0_Left)) || (cpct_isKeyPressed(keys.left)))) {
            newNameHighScore[pos] = '\0';
            pos--;
            chr = newNameHighScore[pos];
            moved = 1;
        } else if (cpct_isKeyPressed(keys.abort)) {
            break;
        }
        if (moved) {
            moved = 0;
            if (chr > 95)
                chr = 65;
            else if (chr < 65)
                chr = 95;
            newNameHighScore[pos] = chr;
            pvmem = cpct_getScreenPtr(CPCT_VMEM_START, markerX, markerY);
            cpct_drawSpriteBlended(pvmem, AM_MARKER_H, AM_MARKER_W, am_marker);
            pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 16, 140);
            cpct_drawSolidBox(pvmem, #0, 45, 11);
            drawText(newNameHighScore, 16, 140, 0);
            markerX = 15 + (pos * 3);
            pvmem = cpct_getScreenPtr(CPCT_VMEM_START, markerX, markerY);
            cpct_drawSpriteBlended(pvmem, AM_MARKER_H, AM_MARKER_W, am_marker);
        }
    }

}
Example #16
0
void animate(u8 dir)
{
    u8 i, j;
    u8 *pvmem;
    u8 tempx, tempy;
    i8 shiftx = 0;
    i8 shifty = 0;
    u8 *pStartTable;  // Pointer to video memory

    pStartTable = cpct_getScreenPtr(CPCT_VMEM_START, 2, 0);

    switch (dir)    {
    case LEFT:
        shiftx = -1;
        break;
    case RIGHT:
        shiftx = 1;
        break;
    case UP:
        shifty = -1;
        break;
    case DOWN:
        shifty = 1;
        break;
    }
    //Step 1
    //Erase changed slots and print the moved card

//    for (i = 0; i < changedCards.number; i++) {
    i = 0;
    j = changedCards.number;
    cpct_waitVSYNC();
    while (i < j) {
        if ((changedCards.cards[i].x <= 3) && (changedCards.cards[i].y <= 3)) {
            tempx = changedCards.cards[i].x;
            tempy = changedCards.cards[i].y;
            cpct_waitVSYNC();
            cpct_etm_drawTileBox2x4 (2 + (tempx * 6), 1 + (tempy * 12), (CARD_W / 2), (CARD_H / 4), MAP_WIDTH, pStartTable, tmx);

            //multiply by 6 and 22 to reuse shift in next step
            pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 6 + (tempx * 12) + (shiftx * 6), 4 + (tempy * 48) + (shifty * 24));
            cpct_drawSpriteMaskedAlignedTable(cards[changedCards.cards[i].prev], pvmem, CARD_W, CARD_H, am_tablatrans);
        }
        i++;
    }
    //Step 2
    //Erase moved card and print animation end for sigle movements

//  for (i = 0; i < changedCards.number; i++){
    i = 0;
    j = changedCards.number;
    cpct_waitVSYNC();
    while (i < j) {
        tempx = changedCards.cards[i].x;
        tempy = changedCards.cards[i].y;
        if ((changedCards.cards[i].x <= 3) && (changedCards.cards[i].y <= 3)) {
            cpct_waitVSYNC();
            //Restore touched tiles
            switch (dir)
            {
            case LEFT:
                cpct_etm_drawTileBox2x4 (2 + ((tempx - 1) * 6), 1 + (tempy * 12), (CARD_W), (CARD_H / 4), MAP_WIDTH, pStartTable, tmx);
                break;
            case RIGHT:
                cpct_etm_drawTileBox2x4 (2 + (tempx * 6), 1 + (tempy * 12), (CARD_W), (CARD_H / 4), MAP_WIDTH, pStartTable, tmx);
                break;
            case UP:
                cpct_etm_drawTileBox2x4 (2 + (tempx * 6), 1 + ((tempy - 1) * 12), (CARD_W / 2), (CARD_H / 2), MAP_WIDTH, pStartTable, tmx);
                break;
            case DOWN:
                cpct_etm_drawTileBox2x4 (2 + (tempx * 6), 1 + (tempy * 12), (CARD_W / 2), (CARD_H / 2), MAP_WIDTH, pStartTable, tmx);
                break;
            }
        }
        cpct_waitVSYNC();
        //If no upgrade is necessary, print card in final position
        //if (changedCards.cards[i].prev == changedCards.cards[i].post) {
        pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 6 + (tempx * 12) + (shiftx * 12), 4 + (tempy * 48) + (shifty * 48));
        cpct_drawSpriteMaskedAlignedTable(cards[changedCards.cards[i].post], pvmem, CARD_W, CARD_H, am_tablatrans);
        //}
        i++;

    }
    //Print next card
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 63, 18);
    cpct_drawSprite(cards[cardBag[currentCard]], pvmem, CARD_W, CARD_H);

}
Example #17
0
void help() {
    u8* pvmem;

    clearScreen();
    drawText("MOVE THE TABLE     ", 0, 0, 1);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 57, 0);
    cpct_drawSprite(g_tile_symbols_1, pvmem, 3, 11);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 60, 0);
    cpct_drawSprite(g_tile_symbols_2, pvmem, 3, 11);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 63, 0);
    cpct_drawSprite(g_tile_symbols_3, pvmem, 3, 11);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 66, 0);
    cpct_drawSprite(g_tile_symbols_4, pvmem, 3, 11);
    drawText("TO COMBINE TWO CARDS", 0, 15, 1);
    drawText("AND CREATE A NEW ONE", 0, 30, 1);

    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 15, 58);
    cpct_drawSprite(cards[1], pvmem, CARD_W, CARD_H);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 29, 78);
    cpct_drawSprite(ic_icons_2, pvmem, IC_ICONS_2_W, IC_ICONS_2_H);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 35, 58);
    cpct_drawSprite(cards[2], pvmem, CARD_W, CARD_H);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 49, 78);
    cpct_drawSprite(ic_icons_3, pvmem, IC_ICONS_3_W, IC_ICONS_3_H);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 55, 58);
    cpct_drawSprite(cards[3], pvmem, CARD_W, CARD_H);

    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 15, 108);
    cpct_drawSprite(cards[3], pvmem, CARD_W, CARD_H);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 29, 128);
    cpct_drawSprite(ic_icons_2, pvmem, IC_ICONS_2_W, IC_ICONS_2_H);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 35, 108);
    cpct_drawSprite(cards[3], pvmem, CARD_W, CARD_H);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 49, 128);
    cpct_drawSprite(ic_icons_3, pvmem, IC_ICONS_3_W, IC_ICONS_3_H);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 55, 105);
    cpct_drawSprite(cards[4], pvmem, CARD_W, CARD_H);

    drawText("WHICH IS THE HIGHEST CARD", 0, 170, 1);
    drawText("YOU CAN GET??", 0, 185, 1);
    wait4UserKeypress();
}
Example #18
0
//////////////////////////////////////////////////////////////////
// game
//
//
//
// Returns:
//    void
//
void game(void) {
    u8 moved;
    u8 *pvmem;
    u8 dir = 0;


    initGame();

    // Clear Screen
    clearScreen();

    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 61, 72);
    cpct_drawSprite(logo_small, pvmem, 15, 55);

    //drawFrame(2, 1, 49, 182);
    drawTable();
    drawText("NEXT", 62, 2, 0);
    printCells();
    highestCardGame = getHighestCard();
    drawText("HIGHEST", 59, 138, 0);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 63, 154);
    cpct_drawSprite(cards[highestCardGame], pvmem, CARD_W, CARD_H);

    moved = 0;
    // Loop forever
    while (1) {
        delay(24);

        rotatedCells = 0;

        if ((cpct_isKeyPressed(Joy0_Right)) || (cpct_isKeyPressed(keys.right))) {
            if (rotateCellsRight() > 0) {
                dir = RIGHT;
                addRandomCellTurn(RIGHT);
                moved = 1;
            }
        } else if ((cpct_isKeyPressed(Joy0_Left)) || (cpct_isKeyPressed(keys.left))) {
            if (rotateCellsLeft() > 0) {
                dir = LEFT;
                addRandomCellTurn(LEFT);
                moved = 1;
            }
        } else if ((cpct_isKeyPressed(Joy0_Down)) || (cpct_isKeyPressed(keys.down))) {
            if (rotateCellsDown() > 0) {
                dir = DOWN;
                addRandomCellTurn(DOWN);
                moved = 1;
            }
        } else if ((cpct_isKeyPressed(Joy0_Up)) || (cpct_isKeyPressed(keys.up))) {
            if (rotateCellsUp() > 0) {
                dir = UP;
                addRandomCellTurn(UP);
                moved = 1;
            }

        } else if ( cpct_isKeyPressed(keys.music)) {
            if (!playing) {
                activateMusic();
            } else {
                deActivateMusic();
            }
        } else if (cpct_isKeyPressed(keys.abort))
            break;

        if (moved) {
            //Empty the rotated cells buffer after ending the animation
            //cpct_waitVSYNC();

            if (changedCards.number > 0) {
                animate(dir);
                resetChangedCards();

                highestCardGame = getHighestCard();
                pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 63, 154);
                cpct_drawSprite(cards[highestCardGame], pvmem, CARD_W, CARD_H);

                // Play sound Effect
                cpct_akp_SFXPlay(3, 14, 50 + (highestCardGame * 2), 1, 0, AY_CHANNEL_A);

            }

            moved = 0;
            if (anyMovesLeft() == 0) {
                cpct_akp_stop();
                cpct_akp_musicInit(song05);
                cpct_akp_musicPlay();
                drawScore();
                wait4UserKeypress();
                drawFrame(14, 60, 68, 130);
                drawText("NO MORE MOVES", 20, 70, 1);
                drawText("GAME OVER", 22, 90, 1);
                sprintf(aux_txt, "SCORE  %d", score);
                drawText(aux_txt, 22, 110, 1);
                delay(200);
                wait4UserKeypress();
                setHighScore(score);
                drawScoreBoard();
                cpct_akp_stop();
                cpct_akp_musicInit(song02);
                cpct_akp_musicPlay();
                break;
            }
        }

    }
}