Code Monkey home page Code Monkey logo

c-octo's People

Contributors

effix avatar ephphatha avatar johnearnest avatar pushfoo avatar tobiasvl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

c-octo's Issues

Random instruction always generates identical PRNG return values

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.

code to replicate

This generates the same value each time it is run.

: main
	:breakpoint example
	v0 := random 0xFF
	v1 := 1
;

License File

I see the web Octo IDE is under the MIT license. A license file for C-Octo would clarify the correct license and usage.

A few errors whilist building

`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.

Persistent user flags

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.

Bug: Key waiting state blocks hiding monitors

I'll make a PR soon. ada0845

Affected

octo-run, octo-de

Steps to replicate

  1. Run code below
: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
  1. press m to engage monitor
  2. press m to disengage monitor

Expected behavior

Monitors turn off

Actual Behavior

Monitors don't turn off

Malformed text mode definitions crash instead of displaying a syntax error

Expected behavior

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

Current behavior

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.

error: a function declaration without a prototype is deprecated in all versions of C

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.