added a little function to initialise the chip8 structure

This commit is contained in:
Ghostie 2025-02-10 19:26:37 -05:00
parent d4944caf67
commit fac5c920de
4 changed files with 16 additions and 1 deletions

View File

@ -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)

View File

@ -15,4 +15,6 @@ struct chip8
struct chip8_keyboard keyboard;
};
void chip8_init (struct chip8 *chip8);
#endif

8
src/chip8.c Normal file
View File

@ -0,0 +1,8 @@
#include "chip8.h"
#include <memory.h>
void
chip8_init (struct chip8 *chip8)
{
memset (chip8, 0, sizeof (struct chip8));
}

View File

@ -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 (