mirror of
https://github.com/kiedtl/fire.git
synced 2024-12-22 06:06:40 +00:00
remove ccommon dependency
This commit is contained in:
parent
861d806379
commit
bf6ce9452b
7
args.h
7
args.h
@ -13,12 +13,17 @@
|
||||
#define ARGS_INCLUDED
|
||||
#include "bool.h"
|
||||
#include "args.h"
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
#include "sys/types.h"
|
||||
#else
|
||||
#include "types.h"
|
||||
#endif
|
||||
|
||||
extern char *argv0;
|
||||
|
||||
typedef struct Options {
|
||||
usize refresh_rate;
|
||||
size_t refresh_rate;
|
||||
bool truecolor;
|
||||
} Options;
|
||||
|
||||
|
7
colors.h
7
colors.h
@ -1,10 +1,15 @@
|
||||
#ifndef COLORS_INCLUDED
|
||||
#define COLORS_INCLUDED
|
||||
|
||||
#include "types.h"
|
||||
#include "termbox.h"
|
||||
#define CLRS_LEN 13
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
#include "sys/types.h"
|
||||
#else
|
||||
#include "types.h"
|
||||
#endif
|
||||
|
||||
#define RED 0xdd1111
|
||||
#define BLACK 0x000000
|
||||
#define YELLOW 0xff7700
|
||||
|
21
draw.c
21
draw.c
@ -4,11 +4,16 @@
|
||||
|
||||
#include "args.h"
|
||||
#include "termbox.h"
|
||||
#include "types.h"
|
||||
#include "draw.h"
|
||||
#include "colors.h"
|
||||
#include "output.h"
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
#include "sys/types.h"
|
||||
#else
|
||||
#include "types.h"
|
||||
#endif
|
||||
|
||||
// arguments
|
||||
extern struct Options *opts;
|
||||
|
||||
@ -20,8 +25,8 @@ init ( struct buffer *buf )
|
||||
buf->width = tb_width();
|
||||
buf->height = tb_height();
|
||||
|
||||
usize len = buf->width * buf->height;
|
||||
buf->buf = (u8*) malloc(len);
|
||||
size_t len = buf->width * buf->height;
|
||||
buf->buf = (uint8_t*) malloc(len);
|
||||
len -= buf->width;
|
||||
|
||||
if (buf->buf == NULL) {
|
||||
@ -42,15 +47,15 @@ init ( struct buffer *buf )
|
||||
void
|
||||
dofire ( struct buffer *buf )
|
||||
{
|
||||
usize src;
|
||||
usize random;
|
||||
usize dest;
|
||||
size_t src;
|
||||
size_t random;
|
||||
size_t dest;
|
||||
|
||||
struct tb_cell *realbuf = tb_cell_buffer();
|
||||
|
||||
for (usize x = 0; x < buf->width; ++x)
|
||||
for (size_t x = 0; x < buf->width; ++x)
|
||||
{
|
||||
for (usize y = 1; y < buf->height; ++y)
|
||||
for (size_t y = 1; y < buf->height; ++y)
|
||||
{
|
||||
src = y * buf->width + x;
|
||||
random = (rand() % 7) & 3;
|
||||
|
10
draw.h
10
draw.h
@ -1,14 +1,18 @@
|
||||
#ifndef DRAW_INCLUDED
|
||||
#define DRAW_INCLUDED
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
#include "sys/types.h"
|
||||
#else
|
||||
#include "types.h"
|
||||
#endif
|
||||
|
||||
typedef struct buffer
|
||||
{
|
||||
usize width;
|
||||
usize height;
|
||||
size_t width;
|
||||
size_t height;
|
||||
|
||||
u8* buf;
|
||||
uint8_t* buf;
|
||||
} buffer;
|
||||
|
||||
void init ( struct buffer *buf );
|
||||
|
11
main.c
11
main.c
@ -3,10 +3,15 @@
|
||||
#include "bool.h"
|
||||
#include "output.h"
|
||||
#include "draw.h"
|
||||
#include "types.h"
|
||||
#include "termbox.h"
|
||||
#include "args.h"
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
#include "sys/types.h"
|
||||
#else
|
||||
#include "types.h"
|
||||
#endif
|
||||
|
||||
#define VERSION "0.2.0"
|
||||
|
||||
// argument parsing (args.h)
|
||||
@ -25,7 +30,7 @@ main ( int argc, char *argv[] )
|
||||
// default args
|
||||
opts->refresh_rate = 5;
|
||||
opts->truecolor = FALSE;
|
||||
usize output_mode = TB_OUTPUT_NORMAL;
|
||||
size_t output_mode = TB_OUTPUT_NORMAL;
|
||||
|
||||
// argument parsing
|
||||
argv0 = argv[0];
|
||||
@ -75,7 +80,7 @@ main ( int argc, char *argv[] )
|
||||
tb_present();
|
||||
|
||||
// event handling
|
||||
int err = (usize) tb_peek_event(&e, opts->refresh_rate);
|
||||
int err = (size_t) tb_peek_event(&e, opts->refresh_rate);
|
||||
|
||||
if (err < 0)
|
||||
continue;
|
||||
|
2
makefile
2
makefile
@ -8,7 +8,7 @@ NAME = fire
|
||||
WARNING = -Wall -Wextra -pedantic -Wmissing-prototypes \
|
||||
-Wold-style-definition -Werror
|
||||
|
||||
INC = -Isub/termbox_next/src -Isub/ccommon/
|
||||
INC = -Isub/termbox_next/src
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -std=c99 -O3 $(WARNING) $(INC)
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit 4a52d5153f63b20691410debdaba619f7923e493
|
@ -1 +1 @@
|
||||
Subproject commit 2312da153e44face7bb45aa2798ec284289c17ca
|
||||
Subproject commit 7b85905531bf9e5908c67276dac55d3241361f20
|
Loading…
Reference in New Issue
Block a user