Update teminal

This commit is contained in:
Miloslav Číž 2020-10-10 22:25:57 +02:00
parent 4263c7454f
commit 7cb6bd749a
2 changed files with 30 additions and 10 deletions

5
game.h
View File

@ -1712,7 +1712,7 @@ void SFG_init()
else else
{ {
SFG_LOG("saving/loading not possible"); SFG_LOG("saving/loading not possible");
SFG_game.save[0] = SFG_NUMBER_OF_LEVELS | 0xf0; // revealed all levels SFG_game.save[0] = (SFG_NUMBER_OF_LEVELS - 1) | 0xf0; // revealed all levels
} }
SFG_enableMusic(SFG_game.settings & 0x02); SFG_enableMusic(SFG_game.settings & 0x02);
@ -3734,7 +3734,7 @@ void SFG_gameStepMenu()
SFG_player.ammo[1] = SFG_game.save[4]; SFG_player.ammo[1] = SFG_game.save[4];
SFG_player.ammo[2] = SFG_game.save[5]; SFG_player.ammo[2] = SFG_game.save[5];
SFG_playerRotateWeapon(0); // this chooses weapon with ammo available SFG_playerRotateWeapon(1); // this chooses weapon with ammo available
break; break;
} }
@ -4069,6 +4069,7 @@ void SFG_drawStoryText()
SFG_clearScreen(clearColor); SFG_clearScreen(clearColor);
if (SFG_GAME_RESOLUTION_Y > 50)
SFG_blitImage(SFG_monsterSprites + sprite * SFG_TEXTURE_STORE_SIZE, SFG_blitImage(SFG_monsterSprites + sprite * SFG_TEXTURE_STORE_SIZE,
(SFG_GAME_RESOLUTION_X - SFG_TEXTURE_SIZE * SFG_FONT_SIZE_SMALL) / 2, (SFG_GAME_RESOLUTION_X - SFG_TEXTURE_SIZE * SFG_FONT_SIZE_SMALL) / 2,
SFG_GAME_RESOLUTION_Y - (SFG_TEXTURE_SIZE + 3) * SFG_FONT_SIZE_SMALL, SFG_GAME_RESOLUTION_Y - (SFG_TEXTURE_SIZE + 3) * SFG_FONT_SIZE_SMALL,

View File

@ -17,6 +17,7 @@
#include <stdint.h> #include <stdint.h>
#include <unistd.h> #include <unistd.h>
#include <signal.h>
#include <fcntl.h> #include <fcntl.h>
#include <linux/input.h> #include <linux/input.h>
#include <stdio.h> #include <stdio.h>
@ -26,7 +27,7 @@
#define SFG_SCREEN_RESOLUTION_X 127 #define SFG_SCREEN_RESOLUTION_X 127
#define SFG_SCREEN_RESOLUTION_Y 42 #define SFG_SCREEN_RESOLUTION_Y 42
#define SFG_DITHERED_SHADOW 1 #define SFG_DITHERED_SHADOW 1
#define SFG_FPS 20 #define SFG_FPS 30
#include "game.h" #include "game.h"
@ -134,10 +135,22 @@ void SFG_playSound(uint8_t soundIndex, uint8_t volume)
{ {
} }
int running = 1;
void handleSignal(int signal)
{
puts("\033[?25h"); // show cursor
running = 0;
}
int main() int main()
{ {
int devFile; int devFile;
signal(SIGINT,handleSignal);
signal(SIGQUIT,handleSignal);
signal(SIGTERM,handleSignal);
timeStart = getTime(); timeStart = getTime();
devFile = open("/dev/input/event0",O_RDONLY); devFile = open("/dev/input/event0",O_RDONLY);
@ -157,7 +170,12 @@ int main()
setvbuf(stdout, NULL, _IOFBF, SCREENSIZE + 1); setvbuf(stdout, NULL, _IOFBF, SCREENSIZE + 1);
while (1) for (uint8_t i = 0; i < 100; ++i) // clear screen
putchar('\n');
puts("\033[?25l"); // hide cursor
while (running)
{ {
while (1) while (1)
{ {
@ -178,11 +196,12 @@ int main()
} }
puts("\033[0;0H"); // move cursor to 0;0 puts("\033[0;0H"); // move cursor to 0;0
puts(screen); puts(screen);
fflush(stdout); fflush(stdout);
if (!SFG_mainLoopBody()) if (!SFG_mainLoopBody())
break; running = 0;
} }
puts("\033[?25h"); // show cursor
} }