diff --git a/game.h b/game.h index 0753cdf..a8d6d29 100755 --- a/game.h +++ b/game.h @@ -77,7 +77,8 @@ int8_t SFG_keyPressed(uint8_t key); Optinal function for mouse/analog controls, gets mouse x and y offset in pixels from the game screen center (to achieve classic FPS mouse controls the platform should center the mouse at the end). If the platform isn't using a - mouse, this function should simply return [0,0] offets at each call. + mouse, this function can simply return [0,0] offets at each call, or even + do nothing (leave the variables as are). */ void SFG_getMouseOffset(int16_t *x, int16_t *y); @@ -3154,7 +3155,7 @@ void SFG_gameStepPlaying() } } - int16_t mouseX, mouseY; + int16_t mouseX = 0, mouseY = 0; SFG_getMouseOffset(&mouseX,&mouseY); @@ -3502,12 +3503,30 @@ void SFG_gameStepPlaying() #endif } +/** + This function defines which items are displayed in the menu. +*/ uint8_t SFG_getMenuItem(uint8_t index) { - uint8_t start = (SFG_currentLevel.levelPointer == 0) ? 2 : 0; + uint8_t current = 0; - if (index <= (SFG_MENU_ITEM_EXIT - start)) - return start + index; + while (1) // find first legitimate item + { + if ( // skip non-legitimate items + ((current <= SFG_MENU_ITEM_MAP) && (SFG_currentLevel.levelPointer == 0)) + || ((current == SFG_MENU_ITEM_LOAD) && ((SFG_game.save[0] >> 4) == 0x0f))) + { + current++; + continue; + } + + if (index == 0) + return (current <= (SFG_MENU_ITEM_EXIT - (SFG_CAN_EXIT ? 0 : 1)) + ) ? current : SFG_MENU_ITEM_NONE; + + current++; + index--; + } return SFG_MENU_ITEM_NONE; } @@ -3548,9 +3567,9 @@ void SFG_gameStepMenu() SFG_setAndInitLevel(SFG_game.save[0] >> 4); SFG_player.health = SFG_game.save[2]; - SFG_game.save[3] = SFG_player.ammo[3]; - SFG_game.save[4] = SFG_player.ammo[4]; - SFG_game.save[5] = SFG_player.ammo[5]; + SFG_game.save[3] = SFG_player.ammo[0]; + SFG_game.save[4] = SFG_player.ammo[1]; + SFG_game.save[5] = SFG_player.ammo[2]; break; @@ -3748,7 +3767,7 @@ void SFG_gameStep() { SFG_updateLevel(); - int16_t x,y; + int16_t x = 0, y = 0; SFG_getMouseOffset(&x,&y); // this keeps centering the mouse diff --git a/main_pokitto.cpp b/main_pokitto.cpp index 4684eeb..13f3d75 100644 --- a/main_pokitto.cpp +++ b/main_pokitto.cpp @@ -19,6 +19,7 @@ #define SFG_START_LEVEL 8 #define SFG_FPS 25 +#define SFG_CAN_EXIT 0 //#define SFG_TEXTURE_DISTANCE 6000 #define SFG_SCREEN_RESOLUTION_X 110 #define SFG_SCREEN_RESOLUTION_Y 88 @@ -72,8 +73,15 @@ int8_t SFG_keyPressed(uint8_t key) void SFG_getMouseOffset(int16_t *x, int16_t *y) { - *x = 0; - *y = 0; +} + +void SFG_save(uint8_t data[SFG_SAVE_SIZE]) +{ +} + +uint8_t SFG_load(uint8_t data[SFG_SAVE_SIZE]) +{ + return 0; } uint8_t audioBuff[SFG_SFX_SAMPLE_COUNT]; @@ -128,14 +136,15 @@ void timerInit(uint32_t samplingRate) void SFG_playSound(uint8_t soundIndex, uint8_t volume) { - uint8_t volumeStep = volume / 16; + uint8_t volumeShift = 7 - volume / 32; + uint16_t baseLevel = 128 - (128 >> volumeShift); uint16_t pos = audioPos; for (int i = 0; i < SFG_SFX_SAMPLE_COUNT; ++i) { - audioBuff[pos] = - mixSamples(audioBuff[pos],SFG_GET_SFX_SAMPLE(soundIndex,i) * volumeStep); + audioBuff[pos] = mixSamples(audioBuff[pos],SFG_GET_SFX_SAMPLE(soundIndex,i) + >> volumeShift); pos = (pos < SFG_SFX_SAMPLE_COUNT - 1) ? (pos + 1) : 0; } @@ -145,7 +154,7 @@ int main() { pokitto.begin(); -// timerInit(8000); + timerInit(8000); for (uint16_t i = 0; i < SFG_SFX_SAMPLE_COUNT; ++i) audioBuff[i] = 127; diff --git a/settings.h b/settings.h index 543f05a..ae5fc7e 100644 --- a/settings.h +++ b/settings.h @@ -323,6 +323,15 @@ #define SFG_MENU_CLICK_VOLUME 220 #endif +/** + Says whether the exit item should be showed in the menu. Platforms that can't + exit (such as some gaming consoles that simply use power off button) can + define this to 0. +*/ +#ifndef SFG_CAN_EXIT + #define SFG_CAN_EXIT 1 +#endif + //------ developer/debug settings ------ /**