Use newer library version

This commit is contained in:
Simon Gellis 2024-10-06 17:19:14 -04:00
parent e320dc59f4
commit de92335134
2 changed files with 19 additions and 9 deletions

23
main.c
View File

@ -339,10 +339,12 @@ int readROM(VB *sim, char *filename) {
return 1; return 1;
} }
sim->cart.rom = malloc(size); uint8_t *rom = malloc(size);
sim->cart.romMask = size - 1; if (!rom) {
perror("could not allocate ROM");
fread(sim->cart.rom, 1, size, file); return 1;
}
fread(rom, 1, size, file);
if (ferror(file)) { if (ferror(file)) {
perror("could not read file"); perror("could not read file");
return 1; return 1;
@ -351,6 +353,7 @@ int readROM(VB *sim, char *filename) {
perror("could not close file"); perror("could not close file");
return 1; return 1;
} }
vbSetCartROM(sim, rom, size);
return 0; return 0;
} }
@ -360,11 +363,15 @@ int main(int argc, char** argv) {
fprintf(stderr, "Please pass a ROM file\n"); fprintf(stderr, "Please pass a ROM file\n");
return 1; return 1;
} }
VB sim; VB *sim = malloc(vbSizeOf());
if (readROM(&sim, argv[1])) { if (!sim) {
return 1; return 1;
} }
vbSetProgramCounter(&sim, 0x07000000); vbInit(sim);
if (readROM(sim, argv[1])) {
return 1;
}
vbSetProgramCounter(sim, 0x07000000);
short port; short port;
if (argc > 2) { if (argc > 2) {
@ -409,7 +416,7 @@ int main(int argc, char** argv) {
} }
printf("connected\n"); printf("connected\n");
int response = server(connfd, &sim); int response = server(connfd, sim);
return close(connfd) return close(connfd)
|| close(fd) || close(fd)
|| response; || response;

View File

@ -1,6 +1,9 @@
build: build:
@mkdir -p build @mkdir -p build
@gcc main.c client.c ../vbtest/vb.c -I include -I ../vbtest -Werror -Wall -Wextra -o ./build/rdb @gcc main.c client.c ../vbtest/vb.c -I include -I ../vbtest \
-Werror -Wall -Wextra -Wpedantic \
-Wno-unused-parameter -Wno-unused-function \
-o ./build/rdb
clean: clean:
@rm -rf build @rm -rf build
.PHONY: build clean .PHONY: build clean