johnearnest / c-octo Goto Github PK
View Code? Open in Web Editor NEWA C rewrite of the Octo CHIP-8 IDE
License: MIT License
A C rewrite of the Octo CHIP-8 IDE
License: MIT License
Random instructions generate the same series of values each run. This affects both octo-run
and octo-de
. Web-based Octo does not do this.
I'll be submitting a PR with a quick fix calling srand
with the time as a seed, but it might be worthwhile to allow setting custom seeds as a runtime option to help debugging.
This generates the same value each time it is run.
: main
:breakpoint example
v0 := random 0xFF
v1 := 1
;
I see the web Octo IDE is under the MIT license. A license file for C-Octo would clarify the correct license and usage.
`src/octo_de.c: In function ‘render_text_editor’:
src/octo_de.c:517:69: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size between 230 and 250 [-Werror=format-truncation=]
517 | snprintf(state.text_status,sizeof(state.text_status),"(%d:%d) %s",prog->error_line+1,prog->error_pos+1,prog->error);state.text_err=1;
| ^~
src/octo_de.c:517:7: note: ‘snprintf’ output between 7 and 4122 bytes into a destination of size 256
517 | snprintf(state.text_status,sizeof(state.text_status),"(%d:%d) %s",prog->error_line+1,prog->error_pos+1,prog->error);state.text_err=1;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/octo_de.c:689:65: error: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 250 [-Werror=format-truncation=]
689 | snprintf(state.text_status,sizeof(state.text_status),"Find: %s",trimmed); state.text_err=0;
| ^~ ~~~~~~~
src/octo_de.c:689:5: note: ‘snprintf’ output between 7 and 262 bytes into a destination of size 256
689 | snprintf(state.text_status,sizeof(state.text_status),"Find: %s",trimmed); state.text_err=0;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/octo_de.c: In function ‘open_choose’:
src/octo_de.c:1307:83: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 232 [-Werror=format-truncation=]
1307 | snprintf(state.text_status,sizeof(state.text_status),"Imported CHIP-8 binary '%s'",entry->name);state.text_err=0;
| ^~
src/octo_de.c:1307:5: note: ‘snprintf’ output between 26 and 4121 bytes into a destination of size 256
1307 | snprintf(state.text_status,sizeof(state.text_status),"Imported CHIP-8 binary '%s'",entry->name);state.text_err=0;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/octo_de.c:1287:106: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 235 [-Werror=format-truncation=]
1287 | if(stat(filename,&st)!=0){snprintf(state.text_status,sizeof(state.text_status),"Unable to open file '%s'",entry->name);state.text_err=1;return;}
| ^~
src/octo_de.c:1287:31: note: ‘snprintf’ output between 23 and 4118 bytes into a destination of size 256
1287 | if(stat(filename,&st)!=0){snprintf(state.text_status,sizeof(state.text_status),"Unable to open file '%s'",entry->name);state.text_err=1;return;}
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/octo_de.c:1323:72: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 243 [-Werror=format-truncation=]
1323 | snprintf(state.text_status,sizeof(state.text_status),"Opened file '%s'",entry->name);state.text_err=0;
| ^~
src/octo_de.c:1323:5: note: ‘snprintf’ output between 15 and 4110 bytes into a destination of size 256
1323 | snprintf(state.text_status,sizeof(state.text_status),"Opened file '%s'",entry->name);state.text_err=0;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/octo_de.c:1312:106: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 235 [-Werror=format-truncation=]
1312 | if(stat(filename,&st)!=0){snprintf(state.text_status,sizeof(state.text_status),"Unable to open file '%s'",entry->name);state.text_err=1;return;}
| ^~
src/octo_de.c:1312:31: note: ‘snprintf’ output between 23 and 4118 bytes into a destination of size 256
1312 | if(stat(filename,&st)!=0){snprintf(state.text_status,sizeof(state.text_status),"Unable to open file '%s'",entry->name);state.text_err=1;return;}
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/octo_de.c:1337:76: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 239 [-Werror=format-truncation=]
1337 | snprintf(state.text_status,sizeof(state.text_status),"Opened octocart '%s'",entry->name);state.text_err=0;
| ^~
src/octo_de.c:1337:5: note: ‘snprintf’ output between 19 and 4114 bytes into a destination of size 256
1337 | snprintf(state.text_status,sizeof(state.text_status),"Opened octocart '%s'",entry->name);state.text_err=0;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/octo_de.c:1329:86: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 231 [-Werror=format-truncation=]
1329 | snprintf(state.text_status,sizeof(state.text_status),"Unable to read octocart '%s'",entry->name);state.text_err=1;
| ^~
src/octo_de.c:1329:7: note: ‘snprintf’ output between 27 and 4122 bytes into a destination of size 256
1329 | snprintf(state.text_status,sizeof(state.text_status),"Unable to read octocart '%s'",entry->name);state.text_err=1;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/octo_de.c: In function ‘save_file’:
src/octo_de.c:1375:73: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 240 [-Werror=format-truncation=]
1375 | snprintf(state.text_status,sizeof(state.text_status),"Saved octocart '%s'",state.open_name);state.text_err=0;
| ^~ ~~~~~~~~~~~~~~~
src/octo_de.c:1375:3: note: ‘snprintf’ output between 18 and 4113 bytes into a destination of size 256
1375 | snprintf(state.text_status,sizeof(state.text_status),"Saved octocart '%s'",state.open_name);state.text_err=0;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/octo_de.c:1367:85: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 230 [-Werror=format-truncation=]
1367 | snprintf(state.text_status,sizeof(state.text_status),"Unable to write octocart '%s'",state.open_name);state.text_err=1;
| ^~ ~~~~~~~~~~~~~~~
src/octo_de.c:1367:5: note: ‘snprintf’ output between 28 and 4123 bytes into a destination of size 256
1367 | snprintf(state.text_status,sizeof(state.text_status),"Unable to write octocart '%s'",state.open_name);state.text_err=1;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:42: ide] Error 1`
Removing -Werror from the makefile fixed it for me. A temporary fix that is.
It'd be neat if C-Octo had consistent user flags, like Octo does. Perhaps they could be stored in .octo.rc
– that way it's possible to keep separate user flags for each game too, by using the -c
option.
I'll make a PR soon. ada0845
octo-run, octo-de
:monitor v0 4
: main
i := circle
plane 1
loop
sprite v0 v1 8
v0 += 3
v1 += 5
v2 := key
again
: circle
0x3C 0x7E 0xFF 0xFF 0xFF 0xFF 0x7E 0x3C
Monitors turn off
Monitors don't turn off
It seems that quirks aren't loaded from the config files, although other kinds of settings are.
When confronted with an absent bracket definition for a string mode, the original js-based Octo outputs a helpful syntax error message. For the example code below, Octo produces this message: line 7: Expected '{' for definition of string mode 'text'.
.
: font-5x3
0x60 0xA0 0xA0 0xA0 0xC0
# omitted brackets containing index calculation
:stringmode text "0"
: main
vF := key
jump main
Both octo-de and octo-run crash on the example code above, printing Killed
in the terminal on a new line instead of a syntax error:
$ octo-run bad_stringmode_def.8o
Killed
$
octo-de also hangs for a moment before crashing.
When compiling on macOS 13.5 (Ventura) with clang, the compiler is not happy:
[ 16%] Building C object CMakeFiles/octo-cli.dir/src/octo_cli.c.o
In file included from /Users/cas/src/c-octo/src/octo_cli.c:10:
/Users/cas/src/c-octo/src/octo_compiler.h:178:28: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
octo_macro* octo_make_macro() {octo_macro*r=calloc(1,sizeof(octo_macro));octo_list_init(&r->args),octo_list_init(&r->body);return r;}
^
void
/Users/cas/src/c-octo/src/octo_compiler.h:179:28: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
octo_smode* octo_make_smode() {octo_smode*r=calloc(1,sizeof(octo_smode)); return r;}
^
void
/Users/cas/src/c-octo/src/octo_compiler.h:181:28: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
octo_mon * octo_make_mon () {octo_mon *r=calloc(1,sizeof(octo_mon )); return r;}
^
void
3 errors generated.
make[2]: *** [CMakeFiles/octo-cli.dir/src/octo_cli.c.o] Error 1
make[1]: *** [CMakeFiles/octo-cli.dir/all] Error 2
make: *** [all] Error 2
Information on the compiler:
% clang --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Similar to JohnEarnest/Octo#141, it'd be cool if (at least) the touch modes seg16
and seg16fill
were supported in C-Octo.
It also seems like the option core.touch_mode
is present in the example .octo.rc
file, but it's not mentioned in https://github.com/JohnEarnest/c-octo#configuration-file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.