diff --git a/Makefile b/Makefile index 3e0a197..528d250 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ ECHO=echo -e CFLAGS=-Wall -Werror -std=gnu99 -O0 -g -Iinclude LIBS=-lSDL2 -FILES=build/main.o build/mem.o build/stack.o build/keyboard.o +FILES=build/main.o build/mem.o build/stack.o build/keyboard.o build/chip8.o OUT=bin/chip8.out all: $(FILES) @@ -26,6 +26,10 @@ build/keyboard.o: src/keyboard.c @$(ECHO) "CC\t\t"$< @$(CC) $(CFLAGS) $< -c -o $@ $(LIBS) +build/chip8.o: src/chip8.c + @$(ECHO) "CC\t\t"$< + @$(CC) $(CFLAGS) $< -c -o $@ $(LIBS) + run: all @$(ECHO) "Runing the Chip8 compiler" @$(OUT) diff --git a/include/chip8.h b/include/chip8.h index 9a93101..95cf038 100644 --- a/include/chip8.h +++ b/include/chip8.h @@ -15,4 +15,6 @@ struct chip8 struct chip8_keyboard keyboard; }; +void chip8_init (struct chip8 *chip8); + #endif diff --git a/src/chip8.c b/src/chip8.c new file mode 100644 index 0000000..5cd565f --- /dev/null +++ b/src/chip8.c @@ -0,0 +1,8 @@ +#include "chip8.h" +#include + +void +chip8_init (struct chip8 *chip8) +{ + memset (chip8, 0, sizeof (struct chip8)); +} diff --git a/src/main.c b/src/main.c index d7376a7..218bb41 100644 --- a/src/main.c +++ b/src/main.c @@ -10,6 +10,7 @@ int main (int argc, char **argv) { struct chip8 chip8; + chip8_init (&chip8); SDL_Init (SDL_INIT_EVERYTHING); SDL_Window *window = SDL_CreateWindow (