void GameLoop() { VDP_resetSprites(); playerObject->updateFunction(playerObject); playerObject->lifetime++; LevelManager_UpdateSection(); ObjectManager_UpdateObjects(); LevelManager_UpdateCoinPickup(); LevelManager_UpdateBreakableRocks(); ObjectManager_DrawObjects(); LevelManager_UpdateTilePlanes(); // wait for vsync and then draw if (debugSettings.waitforvsync != FALSE) { MyVDP_waitVSync(); } VDP_updateSprites(); LevelManager_DrawTilePlanes(); if (joyButtonPressedState.start) { OpenInGameMenu(); } }
void text_draw_sprite ( u8 *str, u16 x, u16 y, u16 ms ) { #define TILE _base + _positions[chr] * _width * _height #define ATTR TILE_ATTR_FULL ( _palette, 1, 0, 0, TILE ) u8 chr, i = 0; const u16 size = _genres->size >> 8; const u8 width = _genres->width; while ( (chr = *str++) ) { chr -= ' '; chr = ( chr >= 96 ) ? 0 : chr; if ( ! _positions[chr] ) { _positions[chr] = _counter++; VDP_loadTileData ( _genres->sprites[chr], TILE, size, TRUE ); VDP_waitVSync(); } VDP_setSprite ( i, x+i*width, y, size, ATTR, i+1 ); VDP_updateSprites(); waitMs ( ms ); ++i; } }
void OpenInGameMenu() { currentLoopFunction = InGameMenuLoop; JOY_setEventHandler(joyEventCallback); menuItem = 0; MyVDP_waitVSync(); VDP_setEnable(0); VDP_setReg(0x0b, 0x00); // set scroll mode to plane/plane VDP_resetSprites(); VDP_setVerticalScroll(PLAN_A, 0); VDP_setVerticalScroll(PLAN_B, 0); VDP_setHorizontalScroll(PLAN_A, 0); VDP_setHorizontalScroll(PLAN_B, 0); VDP_updateSprites(); VDP_fillTileMapRect(APLAN, 0, 0, 0, 64, 64); VDP_fillTileMapRect(BPLAN, 0, 0, 0, 64, 64); VDP_setTextPalette(0); DrawText(); VDP_setEnable(1); }
void planHide ( ) { u16 sprite; u16 width = VDP_getScreenWidth() / 8 + 1; s16 desp = VDP_getScreenWidth() == 320 ? 0 : 4; for ( ; width > 0; width-- ) { bool update = false; for ( sprite=0; sprite<MAX_SPRITE; sprite++ ) { if ( vdpSpriteCache[sprite].x/8+2 - 16 + 1 >= width ) { splist_hide_sprite ( sprite ); update = true; } } if ( update ) { VDP_updateSprites(80,1); } SYS_disableInts(); VDP_clearTileMapRect ( PLAN_B, width - 1 + desp, 0, 1, planHeight ); VDP_clearTileMapRect ( PLAN_A, width - 1 + desp, 0, 1, planHeight ); SYS_enableInts(); //waitMs ( PLAN_HIDE_MS ); waitHz(1); } }
void planHide_and_sprites ( ) { u16 w, sprite; const u16 height = VDP_getPlanHeight(); const u16 width = VDP_getScreenWidth() / 8 + 1; const s16 desp = VDP_getScreenWidth() == 320 ? 0 : 4; for ( w = width; w > 0; w-- ) { for ( sprite=0; sprite<MAX_SPRITE; sprite++ ) { if ( vdpSpriteCache[sprite].x/8+2 >= w ) { splist_hide_sprite ( sprite ); } } VDP_updateSprites(80,1); SYS_disableInts(); VDP_clearTileMapRect ( PLAN_B, w-1+desp, 0, 1, height ); VDP_clearTileMapRect ( PLAN_A, w-1+desp, 0, 1, height ); SYS_enableInts ( ); //waitMs ( PLAN_HIDE_MS ); waitHz(1); } }
void stars_draw ( ) { u8 i; vobject_add ( ESTRELLITA1 ); vobject_add ( ESTRELLITA2 ); vobject_add ( ESTRELLITA3 ); vobject_add ( ESTRELLITA4 ); Vect2D_s16 posiciones = { vdpSpriteCache[splist_griel].x - 4-128, vdpSpriteCache[splist_griel].y + 2-128 }; s16 x = posiciones.x; s16 y = posiciones.y; vsprite_set ( sprites[0] = 71, x-12, y-12, ESTRELLITA1 ); vsprite_set ( sprites[1] = 72, x+12, y-12, ESTRELLITA2 ); vsprite_set ( sprites[2] = 73, x-12, y+12, ESTRELLITA3 ); vsprite_set ( sprites[3] = 74, x+12, y+12, ESTRELLITA4 ); u16 duracion = animation_duracion(ESTRELLITA1); while ( duracion-- ) { if ( duracion % 4 == 0 ) { _freeze_objects(); } vobject_update(); vobject_upload ( ); VDP_updateSprites(80,1); VDP_waitVSync(); } vobject_delete ( ESTRELLITA1 ); vobject_delete ( ESTRELLITA2 ); vobject_delete ( ESTRELLITA3 ); vobject_delete ( ESTRELLITA4 ); for ( i=0; i<STARTS_SPRITES; i++ ) { u8 sprite = sprites [ i ] ; splist_hide_sprite ( sprite ); vsprite_animation ( sprite, EMPTY_SPRITE ); sd_delete ( sprite ); } stars_init (); }
void InGameMenuLoop() { VDP_resetSprites(); u16 tileAttr = TILE_ATTR_FULL(PAL0,0,0,0,goplanesLoadedTileInfo.startIndex); VDP_setSprite(0, TILE_TO_PIXEL(12), TILE_TO_PIXEL(9) + TILE_TO_PIXEL(menuItem), SPRITE_SIZE(3,3), tileAttr, 0); MyVDP_waitVSync(); VDP_updateSprites(); if (joyButtonPressedState.b) { CloseInGameMenu(); return; } if (joyButtonPressedState.start || joyButtonPressedState.a) { switch (menuItem) { case MENU_ITEM_RETURN: { CloseInGameMenu(); return; } break; case MENU_ITEM_ENABLE_DEBUG: { if (playerObject->aiState != AI_STATE_DEBUG) { Player_StartDebugMovement(); } else { Player_EndDebugMovement(); } DrawText(); } break; case MENU_ITEM_INVINCIBILITY: debugSettings.invincibility = !debugSettings.invincibility; DrawText(); break; case MENU_ITEM_VSYNC: debugSettings.waitforvsync = !debugSettings.waitforvsync; DrawText(); break; case MENU_ITEM_FPSCOUNTER: debugSettings.showFPSCounter = !debugSettings.showFPSCounter; DrawText(); break; } } }
void CloseInGameMenu() { MyVDP_waitVSync(); VDP_setEnable(0); VDP_resetSprites(); VDP_updateSprites(); currentLoopFunction = GameLoop; LevelManager_SetupBackgroundPlanes(); LevelManager_SetScrollMode(); LevelManager_DrawTilePlanes(); LevelManager_UpdateTilePlanes(); VDP_setEnable(1); }
void initBoard() { int x,y,c; for (y = 0; y != BOARD_Y; y++) { for (x = 0; x != BOARD_X; x++) { c = (custrand() % 4) + 1; board[y][x].id = c; board[y][x].selected = 0; } } VDP_resetSprites(); cursor.posx = 0; cursor.posy = 0; cursor.size = SPRITE_SIZE(2, 2); cursor.tile_attr = TILE_ATTR_FULL(PAL1, PRIORITY_HIGH, FALSE, FALSE, TILE_USERINDEX); cursor.link = 0; VDP_setSpriteP(0, &cursor); VDP_updateSprites(); SND_startPlay_VGM(muz_gameplay1); }
void drawBoard() { int x, y; char score_string[11]; for (y = 0; y != BOARD_Y; y++) { for (x = 0; x != BOARD_X; x++) { if (board[y][x].id) { if (board[y][x].selected) VDP_fillTileMapRectInc(VDP_PLAN_A, TILE_ATTR_FULL(PAL2, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + (4 * board[y][x].id)), CUR(x), CUR(y), SWIRL_WIDTH, SWIRL_HEIGHT); else VDP_fillTileMapRectInc(VDP_PLAN_A, TILE_ATTR_FULL(PAL1, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + (4 * board[y][x].id)), CUR(x), CUR(y), SWIRL_WIDTH, SWIRL_HEIGHT); } else { VDP_clearTileMapRect(VDP_PLAN_A, CUR(x), CUR(y), SWIRL_WIDTH, SWIRL_HEIGHT); } } } VDP_drawText("Level 1", 31, 3); //VDP_drawText("Goals:", 32, 5); //VDP_drawText("0 / 0", 32, 6); VDP_drawText("Score:", 30, 26); intToStr((s32)score, score_string, 1); VDP_clearTileMapRect(VDP_PLAN_A, 30, 27, 10, 1); VDP_drawText(score_string, 30, 27); VDP_updateSprites(); }