Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove gmake dep #2

Merged
merged 2 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion args.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 6 additions & 1 deletion colors.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 13 additions & 8 deletions draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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) {
Expand All @@ -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;
Expand Down
10 changes: 7 additions & 3 deletions draw.h
Original file line number Diff line number Diff line change
@@ -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 );
Expand Down
11 changes: 8 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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];
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -36,7 +36,7 @@ $(TRMBOX):

$(NAME): $(OBJ) $(TRMBOX)
@echo "\tLD\t\t$(NAME)"
@$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
@$(CC) -o $(NAME) $(OBJ) $(TRMBOX) $(CFLAGS) $(LDFLAGS)

install: $(NAME)
@echo "\tINSTALL\t\t$(NAME)\t$(DESTDIR)/$(PREFIX)/bin/$(NAME)"
Expand Down
1 change: 0 additions & 1 deletion sub/ccommon
Submodule ccommon deleted from 4a52d5
2 changes: 1 addition & 1 deletion sub/termbox_next