diff --git a/build.sh b/build.sh index 9cd0c1f..96a3c38 100755 --- a/build.sh +++ b/build.sh @@ -12,14 +12,14 @@ if [ "${1}" = '--install' ]; then echo "Installing.." gcc src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/file.c src/devices/datetime.c src/uxn11.c -D_POSIX_C_SOURCE=199309L -DNDEBUG -Os -g0 -s -o bin/uxn11 -lX11 - gcc src/uxn.c src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c -D_POSIX_C_SOURCE=199309L -DNDEBUG -Os -g0 -s -o bin/uxncli + # gcc src/uxn.c src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c -D_POSIX_C_SOURCE=199309L -DNDEBUG -Os -g0 -s -o bin/uxncli cp bin/uxn11 ~/bin else gcc -std=c89 -D_POSIX_C_SOURCE=199309L -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/file.c src/devices/datetime.c src/uxn11.c -o bin/uxn11 -lX11 - gcc -std=c89 -D_POSIX_C_SOURCE=199309L -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c -o bin/uxncli + # gcc -std=c89 -D_POSIX_C_SOURCE=199309L -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c -o bin/uxncli fi echo "Done." # echo "Running.." -bin/uxn11 ~/roms/left.rom +bin/uxn11 ~/roms/catclock.rom diff --git a/src/devices/datetime.c b/src/devices/datetime.c index b933377..8b3c1f8 100644 --- a/src/devices/datetime.c +++ b/src/devices/datetime.c @@ -16,7 +16,7 @@ WITH REGARD TO THIS SOFTWARE. */ Uint8 -datetime_dei(Device *d, Uint8 port) +datetime_dei(Uint8 *d, Uint8 port) { time_t seconds = time(NULL); struct tm zt = {0}; @@ -35,6 +35,6 @@ datetime_dei(Device *d, Uint8 port) case 0x8: return t->tm_yday >> 8; case 0x9: return t->tm_yday; case 0xa: return t->tm_isdst; - default: return d->dat[port]; + default: return d[port]; } } diff --git a/src/devices/datetime.h b/src/devices/datetime.h index 95a3739..15f5f59 100644 --- a/src/devices/datetime.h +++ b/src/devices/datetime.h @@ -10,4 +10,4 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ -Uint8 datetime_dei(Device *d, Uint8 port); +Uint8 datetime_dei(Uint8 *d, Uint8 port); diff --git a/src/uxn.c b/src/uxn.c index 60bad6f..5b2707d 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -32,7 +32,6 @@ uxn_eval(Uxn *u, Uint16 pc) unsigned int a, b, c, j, k, bs, instr, errcode; Uint8 kptr, *sp; Stack *src, *dst; - Device *dev; if(!pc || u->dev[0].dat[0xf]) return 0; while((instr = u->ram[pc++])) { /* Return Mode */ diff --git a/src/uxn11.c b/src/uxn11.c index bc5e91a..a61cd8a 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -64,10 +64,10 @@ uxn11_dei(struct Uxn *u, Uint8 addr) Uint8 p = addr & 0x0f; Device *d = &u->dev[addr >> 4]; switch(addr & 0xf0) { - case 0x20: screen_dei(d, p); break; - case 0xa0: file_dei(d, p); break; - case 0xb0: file_dei(d, p); break; - case 0xc0: datetime_dei(d, p); break; + case 0x20: return screen_dei(d, p); break; + case 0xa0: return file_dei(d, p); break; + case 0xb0: return file_dei(d, p); break; + case 0xc0: return datetime_dei(d->dat, p); break; } return d->dat[p]; } @@ -204,7 +204,7 @@ start(Uxn *u, char *rom) /* mouse */ devmouse = uxn_port(u, 0x9, nil_dei, nil_deo); /* file0 */ uxn_port(u, 0xa, file_dei, file_deo); /* file1 */ uxn_port(u, 0xb, file_dei, file_deo); - /* datetime */ uxn_port(u, 0xc, datetime_dei, nil_deo); + /* datetime */ uxn_port(u, 0xc, nil_dei, nil_deo); /* empty */ uxn_port(u, 0xd, nil_dei, nil_deo); /* reserved */ uxn_port(u, 0xe, nil_dei, nil_deo); /* reserved */ uxn_port(u, 0xf, nil_dei, nil_deo);