fire/main.c

66 lines
1.1 KiB
C
Raw Normal View History

2019-12-12 14:08:35 -08:00
#include <stdlib.h>
2019-12-12 15:46:24 -08:00
#include "bool.h"
2019-12-12 19:27:13 -08:00
#include "output.h"
#include "draw.h"
#include "types.h"
#include "termbox.h"
#include "args.h"
2019-12-12 18:18:56 -08:00
2019-12-12 19:39:35 -08:00
#define VERSION "0.1.0"
2019-12-12 19:27:13 -08:00
// argument parsing (args.h)
char *argv0;
struct Options *opts;
2019-12-12 14:08:35 -08:00
int
2019-12-12 19:39:35 -08:00
main ( int argc, char *argv[] )
2019-12-12 14:08:35 -08:00
{
2019-12-12 19:39:35 -08:00
// argument parsing
argv0 = argv[0];
ARGBEGIN {
case 'V':
PRINT("%s %s\n", argv0, VERSION);
exit(0);
case 'h':
default:
PRINT("fire %s\n(c) Kied Llaentenn and contributors\n", VERSION);
PRINT("https://github.com/lptstr/fire\n");
PRINT("\nUSAGE:\n\t$ fire\n\n");
PRINT("OPTIONS:\n\t-V\tshow version and exit.\n");
PRINT("\t-h\tshow this help message and exit.\n\n");
exit(1);
} ARGEND
2019-12-12 15:46:24 -08:00
// initialize termbox
tb_init();
tb_select_output_mode(TB_OUTPUT_NORMAL);
tb_clear();
2019-12-12 19:27:13 -08:00
struct buffer buf;
2019-12-12 15:46:24 -08:00
2019-12-12 18:18:56 -08:00
// initialize drawing
init(&buf);
2019-12-12 14:08:35 -08:00
2019-12-12 18:18:56 -08:00
// animate
while (TRUE)
{
2019-12-12 19:27:13 -08:00
// clear the screen
2019-12-12 18:18:56 -08:00
tb_clear();
2019-12-12 19:27:13 -08:00
// update framebuffer
2019-12-12 18:18:56 -08:00
dofire(&buf);
2019-12-12 19:27:13 -08:00
// draw framebuffer to terminal
2019-12-12 18:18:56 -08:00
tb_present();
}
2019-12-12 15:46:24 -08:00
// cleanup termbox
tb_shutdown();
2019-12-12 19:27:13 -08:00
// cleanup framebuffer
2019-12-12 19:39:35 -08:00
free(buf.buf);
2019-12-12 15:46:24 -08:00
2019-12-12 14:08:35 -08:00
return 0;
}