Clean a bit
This commit is contained in:
parent
ac95a4f0b6
commit
614741f6e8
6 changed files with 36 additions and 40 deletions
8
assets.h
8
assets.h
|
@ -18,19 +18,23 @@
|
|||
|
||||
static const char *LCR_texts[] =
|
||||
{
|
||||
// menu tabs:
|
||||
#define LCR_TEXTS_VERSION 0
|
||||
"0.5d", // version string
|
||||
|
||||
#define LCR_TEXTS_TABS 1
|
||||
"main menu",
|
||||
"play map",
|
||||
"view repl",
|
||||
"play repl",
|
||||
|
||||
// main menu items:
|
||||
#define LCR_TEXTS_MAIN_MENU 5
|
||||
"camera: $",
|
||||
"music: $",
|
||||
"sound: $",
|
||||
"save repl",
|
||||
"exit",
|
||||
|
||||
#define LCR_TEXTS_LOADING 10
|
||||
"loading"
|
||||
};
|
||||
|
||||
|
|
26
audio.h
26
audio.h
|
@ -13,7 +13,6 @@
|
|||
|
||||
#define LCR_AUDIO_CRASH_LEN 2048
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
uint32_t frame;
|
||||
|
@ -21,20 +20,12 @@ struct
|
|||
uint8_t soundPlayed;
|
||||
uint16_t soundPlayedFrame;
|
||||
uint32_t noise;
|
||||
|
||||
uint8_t crashSample;
|
||||
|
||||
|
||||
int engineIntensity;
|
||||
int engineOsc;
|
||||
int engineInc;
|
||||
|
||||
|
||||
uint8_t crashSample;
|
||||
int engineIntensity;
|
||||
int engineOsc;
|
||||
int engineInc;
|
||||
} LCR_audio;
|
||||
|
||||
|
||||
|
||||
|
||||
void LCR_audioInit(void)
|
||||
{
|
||||
LCR_LOG0("initializing audio");
|
||||
|
@ -123,9 +114,7 @@ uint8_t LCR_audioGetNextSample(void)
|
|||
LCR_audio.soundPlayedFrame++;
|
||||
else if (LCR_audio.engineIntensity)
|
||||
{
|
||||
LCR_audio.engineOsc +=
|
||||
LCR_audio.engineInc ?
|
||||
(((_LCR_audioNoise() % 256) <
|
||||
LCR_audio.engineOsc += LCR_audio.engineInc ? (((_LCR_audioNoise() % 256) <
|
||||
(10 + LCR_audio.engineIntensity))) : -31;
|
||||
|
||||
if (LCR_audio.engineInc && LCR_audio.engineOsc >
|
||||
|
@ -134,9 +123,8 @@ uint8_t LCR_audioGetNextSample(void)
|
|||
else if ((!LCR_audio.engineInc) && LCR_audio.engineOsc < 10)
|
||||
LCR_audio.engineInc = 1;
|
||||
|
||||
result +=
|
||||
LCR_audio.engineIntensity < 20 ?
|
||||
LCR_audio.engineOsc / 2 : LCR_audio.engineOsc;
|
||||
result += LCR_audio.engineIntensity < 20 ?
|
||||
LCR_audio.engineOsc / 2 : LCR_audio.engineOsc;
|
||||
}
|
||||
|
||||
LCR_audio.frame++;
|
||||
|
|
|
@ -36,4 +36,9 @@
|
|||
#define LCR_RESOURCE_FILE_SEPARATOR '#'
|
||||
#define LCR_RESOURCE_FILE_SEPARATOR2 ';'
|
||||
|
||||
#define LCR_MENU_MAX_ITEMS 9 // don't change
|
||||
#define LCR_RESOURCE_ITEM_CHUNK (LCR_MENU_MAX_ITEMS - 1)
|
||||
#define LCR_MENU_TABS 4
|
||||
#define LCR_MENU_STRING_SIZE 16
|
||||
|
||||
#endif
|
||||
|
|
22
game.h
22
game.h
|
@ -180,14 +180,6 @@ uint8_t LCR_gameGetNextAudioSample(void);
|
|||
#define LCR_GAME_STATE_LOADING_MAP 0x04
|
||||
#define LCR_GAME_STATE_END 0xff
|
||||
|
||||
// TODO: move to consts?
|
||||
#define LCR_MENU_MAX_ITEMS 9 // don't change
|
||||
#define LCR_RESOURCE_ITEM_CHUNK (LCR_MENU_MAX_ITEMS - 1)
|
||||
#define LCR_MENU_TABS 4
|
||||
#define LCR_MENU_STRING_SIZE 16
|
||||
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
uint8_t state;
|
||||
|
@ -214,8 +206,6 @@ struct
|
|||
const char *itemNamePtrs[LCR_MENU_MAX_ITEMS]; ///< helper array
|
||||
} menu;
|
||||
|
||||
// TODO: make menu struct?
|
||||
|
||||
struct
|
||||
{
|
||||
int state; ///< -1 if reading external res. f., else pos.
|
||||
|
@ -422,7 +412,7 @@ void LCR_gameLoadMainMenuItems(void)
|
|||
char replaceChar = i == 0 ? '0' + LCR_game.cameraMode :
|
||||
(i == 1 ? '0' + LCR_game.musicOn : ('0' + LCR_audio.on));
|
||||
|
||||
LCR_gameSetMenuItemStr(i,LCR_texts[4 + i],replaceChar);
|
||||
LCR_gameSetMenuItemStr(i,LCR_texts[LCR_TEXTS_MAIN_MENU + i],replaceChar);
|
||||
}
|
||||
|
||||
LCR_game.menu.itemCount = 4;
|
||||
|
@ -907,9 +897,9 @@ uint8_t LCR_gameStep(uint32_t time)
|
|||
|
||||
if (LCR_game.state == LCR_GAME_STATE_MENU ||
|
||||
LCR_game.state == LCR_GAME_STATE_LOADING_MAP)
|
||||
LCR_rendererDrawMenu(LCR_texts[LCR_game.menu.selectedTab],
|
||||
LCR_game.menu.itemNamePtrs,LCR_game.menu.itemCount + 1,
|
||||
LCR_game.menu.selectedItem);
|
||||
LCR_rendererDrawMenu(LCR_texts[LCR_TEXTS_TABS
|
||||
+ LCR_game.menu.selectedTab],LCR_game.menu.itemNamePtrs,
|
||||
LCR_game.menu.itemCount + 1,LCR_game.menu.selectedItem);
|
||||
else
|
||||
LCR_gameDraw3DView();
|
||||
}
|
||||
|
@ -930,9 +920,9 @@ uint8_t LCR_gameStep(uint32_t time)
|
|||
LCR_EFFECTIVE_RESOLUTION_Y - 2 * LCR_EFFECTIVE_RESOLUTION_Y / 3,
|
||||
0xffff,0);
|
||||
|
||||
LCR_rendererDrawText(LCR_texts[9],
|
||||
LCR_rendererDrawText(LCR_texts[LCR_TEXTS_LOADING],
|
||||
(LCR_EFFECTIVE_RESOLUTION_X -
|
||||
LCR_rendererComputeTextWidth(LCR_texts[9],4)) / 2,
|
||||
LCR_rendererComputeTextWidth(LCR_texts[LCR_TEXTS_LOADING],4)) / 2,
|
||||
(LCR_EFFECTIVE_RESOLUTION_Y -
|
||||
LCR_rendererComputeTextHeight(4)) / 2,0x0000,4);
|
||||
}
|
||||
|
|
|
@ -1444,7 +1444,7 @@ S3L_Unit _LCR_rendererSmoothRot(S3L_Unit angleOld, S3L_Unit angleNew,
|
|||
|
||||
/**
|
||||
Loads the map models with 8 chunks that are nearest to a certain point
|
||||
towards which camera is looking.
|
||||
towards which the camera is looking.
|
||||
*/
|
||||
void _LCR_rendererLoadMapChunks(void)
|
||||
{
|
||||
|
@ -1787,7 +1787,9 @@ void LCR_rendererDrawMenu(const char *tabName,const char **items,
|
|||
LCR_IMAGE_SIZE * (stripHeight / LCR_IMAGE_SIZE)) / 2,0,
|
||||
stripHeight / LCR_IMAGE_SIZE,0xffff);
|
||||
#endif
|
||||
|
||||
|
||||
LCR_rendererDrawText(LCR_texts[LCR_TEXTS_VERSION],5,5,0xffff,2);
|
||||
|
||||
LCR_renderer.frame++;
|
||||
}
|
||||
|
||||
|
@ -1837,7 +1839,8 @@ void LCR_rendererDraw3D(void)
|
|||
_LCR_rendererAnimateCar();
|
||||
#endif
|
||||
|
||||
_LCR_rendererLoadMapChunks(); // TODO: call only once in a while?
|
||||
if (LCR_renderer.frame % LCR_SETTING_MAP_CHUNK_RELOAD_INTERVAL == 0)
|
||||
_LCR_rendererLoadMapChunks();
|
||||
|
||||
LCR_rendererDrawSky(LCR_currentMap.environment,
|
||||
LCR_renderer.scene.camera.transform.rotation.y,
|
||||
|
|
|
@ -187,4 +187,10 @@
|
|||
#define LCR_SETTING_COUNTDOWN_SECONDS 1 // for release make 3
|
||||
#endif
|
||||
|
||||
#ifndef LCR_SETTING_MAP_CHUNK_RELOAD_INTERVAL
|
||||
/** Interval in rendering frames of reloading map chunks, should ideally be
|
||||
kept a power of two, can't be 0. */
|
||||
#define LCR_SETTING_MAP_CHUNK_RELOAD_INTERVAL 16
|
||||
#endif
|
||||
|
||||
#endif // guard
|
||||
|
|
Loading…
Reference in a new issue