this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #2079 from AlecTroemel/charlotte_janet_support

janet support

authored by

Vadim Grigoruk and committed by
GitHub
8e06fd11 033f26f9

+1544 -30
+1 -1
.github/workflows/build.yml
··· 685 685 runs-on: ubuntu-latest 686 686 strategy: 687 687 matrix: 688 - script: [lua, moon, fennel, ruby, js, wren, squirrel, wasm] 688 + script: [lua, moon, fennel, ruby, js, wren, squirrel, wasm, janet] 689 689 690 690 steps: 691 691 - name: Download Windows XP artifact
+3
.gitmodules
··· 79 79 [submodule "vendor/wasm3"] 80 80 path = vendor/wasm3 81 81 url = https://github.com/wasm3/wasm3.git 82 + [submodule "vendor/janet"] 83 + path = vendor/janet 84 + url = https://github.com/janet-lang/janet.git
+43 -16
CMakeLists.txt
··· 23 23 OUTPUT_STRIP_TRAILING_WHITESPACE 24 24 ) 25 25 26 + 26 27 string(LENGTH "${RESULT_STRING}" LENGTH_RESULT_STRING) 27 28 28 29 if(${LENGTH_RESULT_STRING} EQUAL 0) ··· 321 322 ################################ 322 323 323 324 set(WASM_DIR ${THIRDPARTY_DIR}/wasm3/source) 324 - set(WASM_SRC 325 + set(WASM_SRC 325 326 ${WASM_DIR}/m3_bind.c 326 327 ${WASM_DIR}/m3_code.c 327 328 ${WASM_DIR}/m3_compile.c ··· 408 409 target_include_directories(duktape INTERFACE ${THIRDPARTY_DIR}/duktape/src) 409 410 410 411 ################################ 412 + # Janet 413 + ################################ 414 + 415 + if(WIN32) 416 + add_custom_command( 417 + OUTPUT ${THIRDPARTY_DIR}/janet/build/c/janet.c 418 + COMMAND ./build_win.bat 419 + WORKING_DIRECTORY ${THIRDPARTY_DIR}/janet/ 420 + ) 421 + else() 422 + add_custom_command( 423 + OUTPUT ${THIRDPARTY_DIR}/janet/build/c/janet.c 424 + COMMAND make build/c/janet.c 425 + WORKING_DIRECTORY ${THIRDPARTY_DIR}/janet/ 426 + ) 427 + endif() 428 + add_library(janet ${THIRDPARTY_DIR}/janet/build/c/janet.c) 429 + target_include_directories(janet PUBLIC ${THIRDPARTY_DIR}/janet/src/include) 430 + target_include_directories(janet PUBLIC ${CMAKE_SOURCE_DIR}/build/janet/) 431 + 432 + 433 + ################################ 411 434 # TIC-80 core 412 435 ################################ 413 436 ··· 421 444 ${TIC80CORE_DIR}/core/io.c 422 445 ${TIC80CORE_DIR}/core/sound.c 423 446 ${TIC80CORE_DIR}/api/js.c 424 - ${TIC80CORE_DIR}/api/lua.c 425 - ${TIC80CORE_DIR}/api/moonscript.c 426 - ${TIC80CORE_DIR}/api/fennel.c 427 - ${TIC80CORE_DIR}/api/wren.c 447 + ${TIC80CORE_DIR}/api/lua.c 448 + ${TIC80CORE_DIR}/api/moonscript.c 449 + ${TIC80CORE_DIR}/api/fennel.c 450 + ${TIC80CORE_DIR}/api/wren.c 428 451 ${TIC80CORE_DIR}/api/wasm.c 429 452 ${TIC80CORE_DIR}/api/squirrel.c 430 453 ${TIC80CORE_DIR}/api/mruby.c 454 + ${TIC80CORE_DIR}/api/janet.c 431 455 ${TIC80CORE_DIR}/tic.c 432 456 ${TIC80CORE_DIR}/cart.c 433 457 ${TIC80CORE_DIR}/tools.c ··· 454 478 ${CMAKE_SOURCE_DIR}/src) 455 479 456 480 target_link_libraries(tic80core${SCRIPT} 457 - lua 458 - lpeg 459 - wren 460 - wasm 461 - squirrel 462 - duktape 463 - blipbuf 481 + lua 482 + lpeg 483 + wren 484 + wasm 485 + squirrel 486 + duktape 487 + blipbuf 464 488 zlib 489 + janet 465 490 ) 466 491 467 492 if(BUILD_WITH_MRUBY) ··· 495 520 MACRO_CORE(ruby TIC_BUILD_WITH_MRUBY FALSE) 496 521 endif() 497 522 MACRO_CORE(wasm TIC_BUILD_WITH_WASM FALSE) 523 + MACRO_CORE(janet TIC_BUILD_WITH_JANET FALSE) 498 524 499 525 endif() 500 526 ··· 649 675 if("${CMAKE_SYSTEM_NAME}" STREQUAL "NintendoWii" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "NintendoGameCube" OR GAMECUBE OR WII OR IS_DOS) 650 676 add_custom_command(TARGET tic80_libretro 651 677 POST_BUILD 652 - COMMAND ${CMAKE_SOURCE_DIR}/build/libretro/merge_static.sh $(AR) ${CMAKE_BINARY_DIR}/lib/tic80_libretro${LIBRETRO_SUFFIX}.${LIBRETRO_EXTENSION} ${CMAKE_BINARY_DIR}/lib/tic80_libretro_partial.a ${CMAKE_BINARY_DIR}/lib/libtic80core.a ${CMAKE_BINARY_DIR}/lib/liblua.a ${CMAKE_BINARY_DIR}/lib/libblipbuf.a ${CMAKE_BINARY_DIR}/lib/libduktape.a ${CMAKE_BINARY_DIR}/lib/libwren.a ${CMAKE_BINARY_DIR}/lib/libwasm.a ${CMAKE_BINARY_DIR}/lib/libsquirrel.a ${CMAKE_BINARY_DIR}/lib/libgiflib.a ${CMAKE_BINARY_DIR}/lib/liblpeg.a ${CMAKE_BINARY_DIR}/lib/libzlib.a ${MRUBY_LIB}) 678 + COMMAND ${CMAKE_SOURCE_DIR}/build/libretro/merge_static.sh $(AR) ${CMAKE_BINARY_DIR}/lib/tic80_libretro${LIBRETRO_SUFFIX}.${LIBRETRO_EXTENSION} ${CMAKE_BINARY_DIR}/lib/tic80_libretro_partial.a ${CMAKE_BINARY_DIR}/lib/libtic80core.a ${CMAKE_BINARY_DIR}/lib/liblua.a ${CMAKE_BINARY_DIR}/lib/libblipbuf.a ${CMAKE_BINARY_DIR}/lib/libduktape.a ${CMAKE_BINARY_DIR}/lib/libwren.a ${CMAKE_BINARY_DIR}/lib/libwasm.a ${CMAKE_BINARY_DIR}/lib/libjanet.a ${CMAKE_BINARY_DIR}/lib/libsquirrel.a ${CMAKE_BINARY_DIR}/lib/libgiflib.a ${CMAKE_BINARY_DIR}/lib/liblpeg.a ${CMAKE_BINARY_DIR}/lib/libzlib.a ${MRUBY_LIB}) 653 679 else() 654 680 add_custom_command(TARGET tic80_libretro 655 681 POST_BUILD 656 - COMMAND ${CMAKE_SOURCE_DIR}/build/libretro/merge_static.sh $(AR) ${CMAKE_BINARY_DIR}/lib/tic80_libretro${LIBRETRO_SUFFIX}.${LIBRETRO_EXTENSION} ${CMAKE_BINARY_DIR}/lib/tic80_libretro_partial.a ${CMAKE_BINARY_DIR}/lib/libtic80core.a ${CMAKE_BINARY_DIR}/lib/liblua.a ${CMAKE_BINARY_DIR}/lib/libblipbuf.a ${CMAKE_BINARY_DIR}/lib/libduktape.a ${CMAKE_BINARY_DIR}/lib/libwren.a ${CMAKE_BINARY_DIR}/lib/libwasm.a ${CMAKE_BINARY_DIR}/lib/libsquirrel.a ${CMAKE_BINARY_DIR}/lib/libgiflib.a ${CMAKE_BINARY_DIR}/lib/liblpeg.a ${MRUBY_LIB}) 682 + COMMAND ${CMAKE_SOURCE_DIR}/build/libretro/merge_static.sh $(AR) ${CMAKE_BINARY_DIR}/lib/tic80_libretro${LIBRETRO_SUFFIX}.${LIBRETRO_EXTENSION} ${CMAKE_BINARY_DIR}/lib/tic80_libretro_partial.a ${CMAKE_BINARY_DIR}/lib/libtic80core.a ${CMAKE_BINARY_DIR}/lib/liblua.a ${CMAKE_BINARY_DIR}/lib/libblipbuf.a ${CMAKE_BINARY_DIR}/lib/libduktape.a ${CMAKE_BINARY_DIR}/lib/libwren.a ${CMAKE_BINARY_DIR}/lib/libwasm.a ${CMAKE_BINARY_DIR}/lib/libsquirrel.a ${CMAKE_BINARY_DIR}/lib/libjanet.a ${CMAKE_BINARY_DIR}/lib/libgiflib.a ${CMAKE_BINARY_DIR}/lib/liblpeg.a ${MRUBY_LIB}) 657 683 endif() 658 684 else() 659 685 add_library(tic80_libretro SHARED ··· 785 811 786 812 # we need to build these separatly combining both the project 787 813 # and the external WASM binary chunk since projects do not 788 - # include BINARY chunks 789 - 814 + # include BINARY chunks 815 + 790 816 file(GLOB WASM_DEMOS 791 817 ${CMAKE_SOURCE_DIR}/demos/wasm/*.wasmp 792 818 ${CMAKE_SOURCE_DIR}/demos/bunny/wasmmark/*.wasmp ··· 1250 1276 MACRO_STUB(js) 1251 1277 MACRO_STUB(wren) 1252 1278 MACRO_STUB(squirrel) 1279 + MACRO_STUB(janet) 1253 1280 MACRO_STUB(ruby) 1254 1281 MACRO_STUB(wasm) 1255 1282
+6 -4
README.md
··· 19 19 [Moonscript](https://moonscript.org), 20 20 [Javascript](https://developer.mozilla.org/en-US/docs/Web/JavaScript), 21 21 [Ruby](https://www.ruby-lang.org/en/), 22 - [Wren](http://wren.io/), [Fennel](https://fennel-lang.org), and 23 - [Squirrel](http://www.squirrel-lang.org). 22 + [Wren](http://wren.io/), 23 + [Fennel](https://fennel-lang.org), 24 + [Squirrel](http://www.squirrel-lang.org), and 25 + [Janet](https://janet-lang.org). 24 26 - Games can have mouse and keyboard as input 25 27 - Games can have up to 4 controllers as input (with up to 8 buttons, each) 26 28 - Built-in editors: for code, sprites, world maps, sound effects and music ··· 84 86 mingw32-make -j4 85 87 ``` 86 88 87 - ## Linux 89 + ## Linux 88 90 ### Ubuntu 14.04 89 91 run the following commands in the Terminal 90 92 ``` ··· 116 118 run the following commands in the Terminal 117 119 ``` 118 120 sudo dnf -y groupinstall "Development Tools" "Development Libraries" 119 - sudo dnf -y install ruby rubygem-{tk{,-doc},rake,test-unit} cmake libglvnd-devel libglvnd-gles freeglut-devel clang libXext-devel SDL_sound pipewire-devel pipewire-jack-audio-connection-kit-devel pulseaudio-libs-devel 121 + sudo dnf -y install ruby rubygem-{tk{,-doc},rake,test-unit} cmake libglvnd-devel libglvnd-gles freeglut-devel clang libXext-devel SDL_sound pipewire-devel pipewire-jack-audio-connection-kit-devel pulseaudio-libs-devel 120 122 git clone --recursive https://github.com/nesbox/TIC-80 && cd TIC-80/build 121 123 cmake .. -DCMAKE_CXX_COMPILER=clang++ -DSDL_ALSA=On 122 124 make -j4
+1
build/assets/janetdemo.tic.dat
··· 1 + 0x78, 0xda, 0xed, 0x51, 0x3d, 0x8f, 0xd3, 0x40, 0x10, 0x75, 0x4e, 0xa2, 0xb1, 0x10, 0x3f, 0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 0xae, 0x74, 0x3c, 0x3b, 0x5a, 0x36, 0x96, 0xf0, 0x59, 0x4b, 0xc4, 0x3b, 0x28, 0x77, 0x65, 0x14, 0x56, 0xb7, 0xa9, 0x98, 0x71, 0x12, 0x39, 0x26, 0x33, 0x10, 0xf8, 0xdb, 0xa9, 0xc9, 0x4d, 0x8b, 0x53, 0x7d, 0x63, 0x25, 0x51, 0xdf, 0x84, 0x9b, 0xfc, 0x86, 0xbc, 0xaf, 0x78, 0x47, 0xd8, 0x69, 0x58, 0xd9, 0x6d, 0x87, 0xd3, 0x5f, 0x87, 0x36, 0x75, 0x03, 0x1c, 0xe7, 0xe4, 0xf7, 0x42, 0xc5, 0x1f, 0x7c, 0xbc, 0xa9, 0x94, 0x66, 0xc6, 0x2f, 0x69, 0x98, 0xb4, 0xc1, 0x6a, 0x85, 0xbf, 0x25, 0x64, 0x92, 0x15, 0x32, 0xfd, 0x0f, 0x68, 0x62, 0x7e, 0x0f,
+1
build/baremetalpi/Makefile
··· 33 33 $(TIC80LIB)/libsquirrel.a \ 34 34 $(TIC80LIB)/libwren.a \ 35 35 $(TIC80LIB)/libwasm.a \ 36 + $(TIC80LIB)/libjanet.a \ 36 37 $(TIC80LIB)/libargparse.a \ 37 38 $(TIC80LIB)/libwave_writer.a \ 38 39 $(TIC80LIB)/libduktape.a \
+68
build/janet/janetconf.h
··· 1 + /* This will be generated by the build system if this file is not used */ 2 + 3 + #ifndef JANETCONF_H 4 + #define JANETCONF_H 5 + 6 + #define JANET_VERSION_MAJOR 1 7 + #define JANET_VERSION_MINOR 26 8 + #define JANET_VERSION_PATCH 1 9 + #define JANET_VERSION_EXTRA "-dev" 10 + #define JANET_VERSION "1.26.1-dev" 11 + 12 + /* #define JANET_BUILD "local" */ 13 + 14 + /* These settings all affect linking, so use cautiously. */ 15 + #define JANET_SINGLE_THREADED 16 + #define JANET_NO_DYNAMIC_MODULES 17 + 18 + /* #define JANET_NO_NANBOX */ 19 + /* #define JANET_API __attribute__((visibility ("default"))) */ 20 + 21 + /* These settings should be specified before amalgamation is 22 + * built. Any build with these set should be considered non-standard, and 23 + * certain Janet libraries should be expected not to work. */ 24 + #define JANET_REDUCED_OS 25 + #define JANET_NO_ASSEMBLER 26 + #define JANET_NO_NET 27 + #define JANET_NO_FFI 28 + #define JANET_NO_FFI_JIT 29 + #define JANET_NO_EV 30 + #define JANET_NO_THREADS 31 + 32 + /* #define JANET_NO_DOCSTRINGS */ 33 + /* #define JANET_NO_SOURCEMAPS */ 34 + /* #define JANET_NO_PEG */ 35 + /* #define JANET_NO_INT_TYPES */ 36 + /* #define JANET_NO_REALPATH */ 37 + /* #define JANET_NO_SYMLINKS */ 38 + /* #define JANET_NO_UMASK */ 39 + /* #define JANET_NO_PROCESSES */ 40 + 41 + /* Other settings */ 42 + /* #define JANET_DEBUG */ 43 + /* #define JANET_PRF */ 44 + /* #define JANET_NO_UTC_MKTIME */ 45 + /* #define JANET_OUT_OF_MEMORY do { printf("janet out of memory\n"); exit(1); } while (0) */ 46 + /* #define JANET_EXIT(msg) do { printf("C assert failed executing janet: %s\n", msg); exit(1); } while (0) */ 47 + /* #define JANET_TOP_LEVEL_SIGNAL(msg) call_my_function((msg), stderr) */ 48 + /* #define JANET_RECURSION_GUARD 1024 */ 49 + /* #define JANET_MAX_PROTO_DEPTH 200 */ 50 + /* #define JANET_MAX_MACRO_EXPAND 200 */ 51 + /* #define JANET_STACK_MAX 16384 */ 52 + /* #define JANET_OS_NAME my-custom-os */ 53 + /* #define JANET_ARCH_NAME pdp-8 */ 54 + /* #define JANET_EV_NO_EPOLL */ 55 + /* #define JANET_EV_NO_KQUEUE */ 56 + /* #define JANET_NO_INTERPRETER_INTERRUPT */ 57 + 58 + /* Custom vm allocator support */ 59 + /* #include <mimalloc.h> */ 60 + /* #define janet_malloc(X) mi_malloc((X)) */ 61 + /* #define janet_realloc(X, Y) mi_realloc((X), (Y)) */ 62 + /* #define janet_calloc(X, Y) mi_calloc((X), (Y)) */ 63 + /* #define janet_free(X) mi_free((X)) */ 64 + 65 + /* Main client settings, does not affect library code */ 66 + /* #define JANET_SIMPLE_GETLINE */ 67 + 68 + #endif /* end of include guard: JANETCONF_H */
+118
demos/bunny/janetmark.janet
··· 1 + # title: Bunnymark in Janet 2 + # author: Alec Troemel; based on the original work of Rob Loach 3 + # desc: Benchmarking tool to see how many bunnies can fly around the screen, using Janet 4 + # input: gamepad 5 + # script: janet 6 + # version: 0.1.0 7 + 8 + (import tic80 :as t) 9 + 10 + (def SCREEN_WIDTH 240) 11 + (def SCREEN_HEIGHT 136) 12 + (def TOOLBAR_HEIGHT 6) 13 + 14 + (var t 0) 15 + (var RNG (math/rng (t/tstamp))) 16 + 17 + (defn random-float [lower greater] 18 + (+ (* (math/rng-uniform RNG) 19 + (- greater lower)) 20 + lower)) 21 + 22 + (defn draw-bunny [self] 23 + (t/spr (self :sprite) 24 + (math/round (self :x)) 25 + (math/round (self :y)) 26 + 1 1 0 0 4 4)) 27 + 28 + (defn update-bunny [self] 29 + (+= (self :x) (self :speed-x)) 30 + (+= (self :y) (self :speed-y)) 31 + 32 + (when (> (+ (self :x) (self :width)) SCREEN_WIDTH) 33 + (put self :x (- SCREEN_WIDTH (self :width))) 34 + (*= (self :speed-x) -1)) 35 + 36 + (when (< (self :x) 0) 37 + (put self :x 0) 38 + (*= (self :speed-x) -1)) 39 + 40 + (when (> (+ (self :y) (self :height)) SCREEN_HEIGHT) 41 + (put self :y (- SCREEN_HEIGHT (self :height))) 42 + (*= (self :speed-y) -1)) 43 + 44 + (when (< (self :y) 0) 45 + (put self :y 0) 46 + (*= (self :speed-y) -1))) 47 + 48 + (defn init-bunny [] 49 + (let [width 26 height 32] 50 + @{:x (random-float 0 (- SCREEN_WIDTH width)) 51 + :y (random-float 0 (- SCREEN_HEIGHT height)) 52 + :speed-x (/ (random-float -100 100) 60) 53 + :speed-y (/ (random-float -100 100) 60) 54 + :width 26 55 + :height 32 56 + :sprite 1 57 + :draw draw-bunny 58 + :update update-bunny})) 59 + 60 + (defn init-fps [] 61 + @{:value 0 62 + :frames 0 63 + :last-time -1000 64 + :get-value (fn fps-get-value [self] 65 + (if (<= (- (t/time) (self :last-time)) 1000) 66 + (+= (self :frames) 1) 67 + (do (put self :value (self :frames)) 68 + (put self :frames 0) 69 + (put self :last-time (t/time)))) 70 + (self :value))}) 71 + 72 + (var fps (init-fps)) 73 + (var bunnies @[(init-bunny)]) 74 + 75 + (defn TIC [] 76 + # Music 77 + (when (= t 0) (t/music 0)) 78 + (when (= t (* 6 64 2.375)) (t/music 1)) 79 + (+= t 1) 80 + 81 + # Input 82 + (cond (t/btn 0) (for i 0 5 (array/push bunnies (init-bunny))) 83 + (t/btn 1) (for i 0 5 (array/pop bunnies))) 84 + 85 + # Update 86 + (each bunny bunnies (:update bunny)) 87 + 88 + # Draw 89 + (t/cls 15) 90 + (each bunny bunnies (:draw bunny)) 91 + (t/rect 0 0 SCREEN_WIDTH TOOLBAR_HEIGHT 0) 92 + (t/print (string/format "Bunnies: %n" (length bunnies)) 93 + 1 0 11 false 1 false) 94 + (t/print (string/format "FPS: %n" (:get-value fps)) 95 + (/ SCREEN_WIDTH 2) 0 11 false 1 false)) 96 + 97 + # <TILES> 98 + # 001:11111100111110dd111110dc111110dc111110dc111110dc111110dd111110dd 99 + # 002:00011110ddd0110dccd0110dccd0110dccd0110dccd0110dcddd00dddddddddd 100 + # 003:00001111dddd0111cccd0111cccd0111cccd0111cccd0111dcdd0111dddd0111 101 + # 004:1111111111111111111111111111111111111111111111111111111111111111 102 + # 017:111110dd111110dd111110dd111110dd10000ddd1eeeeddd1eeeeedd10000eed 103 + # 018:d0ddddddd0ddddddddddddddddd0000dddddccddddddccdddddddddddddddddd 104 + # 019:0ddd01110ddd0111dddd0111dddd0111ddddd000ddddddddddddddddddddd000 105 + # 020:1111111111111111111111111111111101111111d0111111d011111101111111 106 + # 033:111110ee111110ee111110ee111110ee111110ee111110ee111110ee111110ee 107 + # 034:dddcccccddccccccddccccccddccccccddccccccdddcccccdddddddddddddddd 108 + # 035:dddd0111cddd0111cddd0111cddd0111cddd0111dddd0111dddd0111dddd0111 109 + # 036:1111111111111111111111111111111111111111111111111111111111111111 110 + # 049:111110ee111110ee111110ee111110ee111110ee111110ee111110ee11111100 111 + # 050:dddeeeeeddeeeeeed00000000111111101111111011111110111111111111111 112 + # 051:eddd0111eedd01110eed011110ee011110ee011110ee011110ee011111001111 113 + # 052:1111111111111111111111111111111111111111111111111111111111111111 114 + # </TILES> 115 + 116 + # <PALETTE> 117 + # 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57 118 + # </PALETTE>
+46
demos/janetdemo.janet
··· 1 + # title: game title 2 + # author: game developer, email, etc. 3 + # desc: short description 4 + # site: website link 5 + # license: MIT License (change this to your license of choice) 6 + # version: 0.1 7 + # script: janet 8 + # strict: true 9 + 10 + # Unlike other langauges, the tic80 API 11 + # is provided as a module. 12 + (import tic80) 13 + 14 + (var t 0) 15 + (var x 96) 16 + (var y 24) 17 + 18 + (defn TIC [] 19 + (when (tic80/btn 0) (-= y 1)) 20 + (when (tic80/btn 1) (+= y 1)) 21 + (when (tic80/btn 2) (-= x 1)) 22 + (when (tic80/btn 3) (+= x 1)) 23 + (tic80/cls 0) 24 + (tic80/spr (if (> (% t 60) 30) 1 3) 25 + x y 14 3 0 0 2 2) 26 + (tic80/print "HELLO WORLD!" 84 84) 27 + (+= t 1)) 28 + 29 + # <TILES> 30 + # 001:eccccccccc888888caaaaaaaca888888cacccccccacc0ccccacc0ccccacc0ccc 31 + # 002:ccccceee8888cceeaaaa0cee888a0ceeccca0ccc0cca0c0c0cca0c0c0cca0c0c 32 + # 003:eccccccccc888888caaaaaaaca888888cacccccccacccccccacc0ccccacc0ccc 33 + # 004:ccccceee8888cceeaaaa0cee888a0ceeccca0cccccca0c0c0cca0c0c0cca0c0c 34 + # 017:cacccccccaaaaaaacaaacaaacaaaaccccaaaaaaac8888888cc000cccecccccec 35 + # 018:ccca00ccaaaa0ccecaaa0ceeaaaa0ceeaaaa0cee8888ccee000cceeecccceeee 36 + # 019:cacccccccaaaaaaacaaacaaacaaaaccccaaaaaaac8888888cc000cccecccccec 37 + # 020:ccca00ccaaaa0ccecaaa0ceeaaaa0ceeaaaa0cee8888ccee000cceeecccceeee 38 + # </TILES> 39 + 40 + # <PALETTE> 41 + # 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57 42 + # </PALETTE> 43 + 44 + # <TRACKS> 45 + # 000:100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 46 + # </TRACKS>
+3 -1
include/tic80_config.h
··· 28 28 !defined(TIC_BUILD_WITH_JS) && \ 29 29 !defined(TIC_BUILD_WITH_WREN) && \ 30 30 !defined(TIC_BUILD_WITH_SQUIRREL) && \ 31 - !defined(TIC_BUILD_WITH_WASM) 31 + !defined(TIC_BUILD_WITH_WASM) && \ 32 + !defined(TIC_BUILD_WITH_JANET) 32 33 33 34 # define TIC_BUILD_WITH_LUA 1 34 35 # define TIC_BUILD_WITH_MOON 1 ··· 37 38 # define TIC_BUILD_WITH_WREN 1 38 39 # define TIC_BUILD_WITH_SQUIRREL 1 39 40 # define TIC_BUILD_WITH_WASM 1 41 + # define TIC_BUILD_WITH_JANET 1 40 42 41 43 #endif 42 44
+1214
src/api/janet.c
··· 1 + /* 2 + * vim: ts=4 sts=4 sw=4 et 3 + */ 4 + 5 + // MIT License 6 + 7 + // Copyright (c) 2022 Charlotte Koch @dressupgeekout <dressupgeekout@gmail.com> 8 + 9 + // Permission is hereby granted, free of charge, to any person obtaining a copy 10 + // of this software and associated documentation files (the "Software"), to deal 11 + // in the Software without restriction, including without limitation the rights 12 + // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 + // copies of the Software, and to permit persons to whom the Software is 14 + // furnished to do so, subject to the following conditions: 15 + 16 + // The above copyright notice and this permission notice shall be included in all 17 + // copies or substantial portions of the Software. 18 + 19 + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 + // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 + // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 + // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 + // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 + // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 + // SOFTWARE. 26 + 27 + #include "core/core.h" 28 + 29 + #if defined(TIC_BUILD_WITH_JANET) 30 + 31 + #include <janet.h> 32 + 33 + static inline tic_core* getJanetMachine(void); 34 + 35 + static Janet janet_print(int32_t argc, Janet* argv); 36 + static Janet janet_cls(int32_t argc, Janet* argv); 37 + static Janet janet_pix(int32_t argc, Janet* argv); 38 + static Janet janet_line(int32_t argc, Janet* argv); 39 + static Janet janet_rect(int32_t argc, Janet* argv); 40 + static Janet janet_rectb(int32_t argc, Janet* argv); 41 + static Janet janet_spr(int32_t argc, Janet* argv); 42 + static Janet janet_btn(int32_t argc, Janet* argv); 43 + static Janet janet_btnp(int32_t argc, Janet* argv); 44 + static Janet janet_sfx(int32_t argc, Janet* argv); 45 + static Janet janet_map(int32_t argc, Janet* argv); 46 + static Janet janet_mget(int32_t argc, Janet* argv); 47 + static Janet janet_mset(int32_t argc, Janet* argv); 48 + static Janet janet_peek(int32_t argc, Janet* argv); 49 + static Janet janet_poke(int32_t argc, Janet* argv); 50 + static Janet janet_peek1(int32_t argc, Janet* argv); 51 + static Janet janet_poke1(int32_t argc, Janet* argv); 52 + static Janet janet_peek2(int32_t argc, Janet* argv); 53 + static Janet janet_poke2(int32_t argc, Janet* argv); 54 + static Janet janet_peek4(int32_t argc, Janet* argv); 55 + static Janet janet_poke4(int32_t argc, Janet* argv); 56 + static Janet janet_memcpy(int32_t argc, Janet* argv); 57 + static Janet janet_memset(int32_t argc, Janet* argv); 58 + static Janet janet_trace(int32_t argc, Janet* argv); 59 + static Janet janet_pmem(int32_t argc, Janet* argv); 60 + static Janet janet_time(int32_t argc, Janet* argv); 61 + static Janet janet_tstamp(int32_t argc, Janet* argv); 62 + static Janet janet_exit(int32_t argc, Janet* argv); 63 + static Janet janet_font(int32_t argc, Janet* argv); 64 + static Janet janet_mouse(int32_t argc, Janet* argv); 65 + static Janet janet_circ(int32_t argc, Janet* argv); 66 + static Janet janet_circb(int32_t argc, Janet* argv); 67 + static Janet janet_elli(int32_t argc, Janet* argv); 68 + static Janet janet_ellib(int32_t argc, Janet* argv); 69 + static Janet janet_tri(int32_t argc, Janet* argv); 70 + static Janet janet_trib(int32_t argc, Janet* argv); 71 + static Janet janet_ttri(int32_t argc, Janet* argv); 72 + static Janet janet_clip(int32_t argc, Janet* argv); 73 + static Janet janet_music(int32_t argc, Janet* argv); 74 + static Janet janet_sync(int32_t argc, Janet* argv); 75 + static Janet janet_vbank(int32_t argc, Janet* argv); 76 + static Janet janet_reset(int32_t argc, Janet* argv); 77 + static Janet janet_key(int32_t argc, Janet* argv); 78 + static Janet janet_keyp(int32_t argc, Janet* argv); 79 + static Janet janet_fget(int32_t argc, Janet* argv); 80 + static Janet janet_fset(int32_t argc, Janet* argv); 81 + 82 + static void closeJanet(tic_mem* tic); 83 + static bool initJanet(tic_mem* tic, const char* code); 84 + static void evalJanet(tic_mem* tic, const char* code); 85 + static void callJanetTick(tic_mem* tic); 86 + static void callJanetBoot(tic_mem* tic); 87 + static void callJanetIntCallback(tic_mem* memory, s32 value, void* data, const char* name); 88 + static void callJanetScanline(tic_mem* memory, s32 row, void* data); 89 + static void callJanetBorder(tic_mem* memory, s32 row, void* data); 90 + static void callJanetMenu(tic_mem* memory, s32 index, void* data); 91 + static const tic_outline_item* getJanetOutline(const char* code, s32* size); 92 + 93 + /* ***************** */ 94 + 95 + static const JanetReg janet_c_functions[] = 96 + { 97 + {"print", janet_print, NULL}, 98 + {"cls", janet_cls, NULL}, 99 + {"pix", janet_pix, NULL}, 100 + {"line", janet_line, NULL}, 101 + {"rect", janet_rect, NULL}, 102 + {"rectb", janet_rectb, NULL}, 103 + {"spr", janet_spr, NULL}, 104 + {"btn", janet_btn, NULL}, 105 + {"btnp", janet_btnp, NULL}, 106 + {"sfx", janet_sfx, NULL}, 107 + {"tmap", janet_map, NULL}, 108 + {"mget", janet_mget, NULL}, 109 + {"mset", janet_mset, NULL}, 110 + {"peek", janet_peek, NULL}, 111 + {"poke", janet_poke, NULL}, 112 + {"peek1", janet_peek1, NULL}, 113 + {"poke1", janet_poke1, NULL}, 114 + {"peek2", janet_peek2, NULL}, 115 + {"poke2", janet_poke2, NULL}, 116 + {"peek4", janet_peek4, NULL}, 117 + {"poke4", janet_poke4, NULL}, 118 + {"memcpy", janet_memcpy, NULL}, 119 + {"memset", janet_memset, NULL}, 120 + {"trace", janet_trace, NULL}, 121 + {"pmem", janet_pmem, NULL}, 122 + {"time", janet_time, NULL}, 123 + {"tstamp", janet_tstamp, NULL}, 124 + {"exit", janet_exit, NULL}, 125 + {"font", janet_font, NULL}, 126 + {"mouse", janet_mouse, NULL}, 127 + {"circ", janet_circ, NULL}, 128 + {"circb", janet_circb, NULL}, 129 + {"elli", janet_elli, NULL}, 130 + {"ellib", janet_ellib, NULL}, 131 + {"tri", janet_tri, NULL}, 132 + {"trib", janet_trib, NULL}, 133 + {"ttri", janet_ttri, NULL}, 134 + {"clip", janet_clip, NULL}, 135 + {"music", janet_music, NULL}, 136 + {"sync", janet_sync, NULL}, 137 + {"vbank", janet_vbank, NULL}, 138 + {"reset", janet_reset, NULL}, 139 + {"key", janet_key, NULL}, 140 + {"keyp", janet_keyp, NULL}, 141 + {"fget", janet_fget, NULL}, 142 + {"fset", janet_fset, NULL}, 143 + {NULL, NULL, NULL} 144 + }; 145 + 146 + static const char* const JanetKeywords[] = 147 + { 148 + "defmacro", "withsyms", "macex1", "macex", 149 + "do", "values", "break" 150 + "if", "when", "cond", "match", 151 + "each", "for", "loop", "while", 152 + "fn", "defn", "partial", 153 + "def", "var", "set", "defglobal", "let", "set", "put", 154 + "if-let", "when-let", "if-not", 155 + "or", "and", "true", "false", "nil", "not", "not=", "length", 156 + "brshift", "blshift", "bor", "band", "bnot", "bxor", 157 + "#", ":", "->", "->>", "-?>", "-?>>", "$", 158 + "quasiquote", "quote", "unquote", "upscope", 159 + "splice", ";" 160 + }; 161 + 162 + static JanetFiber* GameFiber = NULL; 163 + static JanetBuffer errBuffer; 164 + static tic_core* CurrentMachine = NULL; 165 + 166 + 167 + static inline tic_core* getJanetMachine(void) 168 + { 169 + return CurrentMachine; 170 + } 171 + 172 + /* ***************** */ 173 + 174 + typedef struct 175 + { 176 + s32 note; 177 + s32 octave; 178 + } SFXNote; 179 + 180 + static SFXNote tic_optsfxnote(Janet *argv, int32_t argc, int32_t n) 181 + { 182 + SFXNote sfxNote = {-1, -1}; 183 + 184 + if (argc < n) 185 + { 186 + return sfxNote; 187 + } 188 + else if (janet_checktype(argv[n], JANET_STRING)) 189 + { 190 + const char *noteStr = janet_getcstring(argv, n); 191 + 192 + if (!tic_tool_parse_note(noteStr, &sfxNote.note, &sfxNote.octave)) 193 + { 194 + janet_panicf("invalid note, should be like C#4, got %s\n", noteStr); 195 + } 196 + 197 + return sfxNote; 198 + } 199 + else 200 + { 201 + s32 id = janet_getinteger(argv, n); 202 + sfxNote.note = id % NOTES; 203 + sfxNote.octave = id / NOTES; 204 + return sfxNote; 205 + } 206 + } 207 + 208 + typedef struct 209 + { 210 + u8 colors[TIC_PALETTE_SIZE]; 211 + int32_t count; 212 + } ColorKey; 213 + 214 + static ColorKey tic_optcolorkey(Janet *argv, int32_t argc, int32_t n) 215 + { 216 + ColorKey colorkey = {0}; 217 + colorkey.count = 0; 218 + 219 + if (argc > n) 220 + { 221 + if (janet_checktypes(argv[n], JANET_TFLAG_INDEXED)) 222 + { 223 + JanetView keys = janet_getindexed(argv, n); 224 + s32 list_count = keys.len; 225 + 226 + for(s32 i = 0; i < TIC_PALETTE_SIZE; i++) 227 + { 228 + if (i < list_count) 229 + { 230 + colorkey.colors[i] = (s32)janet_getinteger(keys.items, i);; 231 + colorkey.count++; 232 + } 233 + else 234 + { 235 + break; 236 + } 237 + } 238 + } 239 + else if (janet_checkint(argv[n])) 240 + { 241 + colorkey.colors[0] = (s32)janet_getnumber(argv, n); 242 + colorkey.count = 1; 243 + } 244 + else 245 + { 246 + janet_panic("Error: colorkeys must be either int or list of int"); 247 + } 248 + } 249 + 250 + return colorkey; 251 + } 252 + 253 + typedef struct 254 + { 255 + float z[3]; 256 + bool on; 257 + } TriDepth; 258 + 259 + static TriDepth tic_opttridepth(Janet* argv, int32_t argc, int32_t n) 260 + { 261 + TriDepth depth = {0}; 262 + depth.on = false; 263 + 264 + if (argc > n) 265 + { 266 + depth.on = true; 267 + 268 + depth.z[0] = janet_getnumber(argv, n); 269 + depth.z[1] = janet_getnumber(argv, n+1); 270 + depth.z[2] = janet_getnumber(argv, n+2); 271 + } 272 + 273 + return depth; 274 + } 275 + 276 + /* ***************** */ 277 + 278 + static Janet janet_print(int32_t argc, Janet* argv) 279 + { 280 + janet_arity(argc, 1, 7); 281 + 282 + s32 x = 0; 283 + s32 y = 0; 284 + u8 color = 15; 285 + bool fixed = false; 286 + s32 scale = 1; 287 + bool alt = false; 288 + 289 + const char *text = janet_getcstring(argv, 0); 290 + if (argc >= 2) x = (s32)janet_getinteger(argv, 1); 291 + if (argc >= 3) y = (s32)janet_getinteger(argv, 2); 292 + if (argc >= 4) color = (u8)janet_getinteger(argv, 3); 293 + if (argc >= 5) fixed = janet_getboolean(argv, 4); 294 + if (argc >= 6) scale = (s32)janet_getinteger(argv, 5); 295 + if (argc >= 7) alt = janet_getboolean(argv, 6); 296 + 297 + tic_mem* memory = (tic_mem*)getJanetMachine(); 298 + int32_t width = tic_api_print(memory, text, x, y, color, fixed, scale, alt); 299 + return janet_wrap_integer(width); 300 + } 301 + 302 + static Janet janet_cls(int32_t argc, Janet* argv) 303 + { 304 + janet_arity(argc, 0, 1); 305 + u8 color = 0; 306 + 307 + if (argc > 0) color = (u8)janet_getinteger(argv, 0); 308 + 309 + tic_mem* memory = (tic_mem*)getJanetMachine(); 310 + tic_api_cls(memory, color); 311 + return janet_wrap_nil(); 312 + } 313 + 314 + static Janet janet_pix(int32_t argc, Janet* argv) 315 + { 316 + janet_arity(argc, 2, 3); 317 + 318 + bool get; 319 + u8 color = 0; 320 + 321 + s32 x = (s32)janet_getinteger(argv, 0); 322 + s32 y = (s32)janet_getinteger(argv, 1); 323 + 324 + if (argc == 2) { 325 + get = true; 326 + } else { 327 + color = (u8)janet_getinteger(argv, 2); 328 + get = false; 329 + } 330 + 331 + tic_mem* memory = (tic_mem*)getJanetMachine(); 332 + return janet_wrap_integer(tic_api_pix(memory, x, y, color, get)); 333 + } 334 + 335 + static Janet janet_line(int32_t argc, Janet* argv) 336 + { 337 + janet_fixarity(argc, 5); 338 + 339 + float x1 = (float)janet_getnumber(argv, 0); 340 + float y1 = (float)janet_getnumber(argv, 1); 341 + float x2 = (float)janet_getnumber(argv, 2); 342 + float y2 = (float)janet_getnumber(argv, 3); 343 + u8 color = (u8)janet_getinteger(argv, 4); 344 + 345 + tic_mem* memory = (tic_mem*)getJanetMachine(); 346 + tic_api_line(memory, x1, y1, x2, y2, color); 347 + return janet_wrap_nil(); 348 + } 349 + 350 + static Janet janet_rect(int32_t argc, Janet* argv) 351 + { 352 + janet_fixarity(argc, 5); 353 + 354 + s32 x = (s32)janet_getinteger(argv, 0); 355 + s32 y = (s32)janet_getinteger(argv, 1); 356 + s32 width = (s32)janet_getinteger(argv, 2); 357 + s32 height = (s32)janet_getinteger(argv, 3); 358 + u8 color = (u8)janet_getinteger(argv, 4); 359 + 360 + tic_mem* memory = (tic_mem*)getJanetMachine(); 361 + tic_api_rect(memory, x, y, width, height, color); 362 + return janet_wrap_nil(); 363 + } 364 + 365 + static Janet janet_rectb(int32_t argc, Janet* argv) 366 + { 367 + janet_fixarity(argc, 5); 368 + 369 + s32 x = (s32)janet_getinteger(argv, 0); 370 + s32 y = (s32)janet_getinteger(argv, 1); 371 + s32 width = (s32)janet_getinteger(argv, 2); 372 + s32 height = (s32)janet_getinteger(argv, 3); 373 + u8 color = (u8)janet_getinteger(argv, 4); 374 + 375 + tic_mem* memory = (tic_mem*)getJanetMachine(); 376 + tic_api_rectb(memory, x, y, width, height, color); 377 + return janet_wrap_nil(); 378 + } 379 + 380 + static Janet janet_spr(int32_t argc, Janet* argv) 381 + { 382 + janet_arity(argc, 3, 9); 383 + 384 + s32 index = (s32)janet_getinteger(argv, 0); 385 + s32 x = (s32)janet_getinteger(argv, 1); 386 + s32 y = (s32)janet_getinteger(argv, 2); 387 + 388 + ColorKey colorkey = tic_optcolorkey(argv, argc, 3); 389 + 390 + s32 scale = (s32)janet_optnumber(argv, argc, 4, 1); 391 + tic_flip flip = (s32)janet_optnumber(argv, argc, 5, tic_no_flip); 392 + tic_rotate rotate = (s32)janet_optnumber(argv, argc, 6, tic_no_rotate); 393 + s32 w = (s32)janet_optnumber(argv, argc, 7, 1); 394 + s32 h = (s32)janet_optnumber(argv, argc, 8, 1); 395 + 396 + tic_mem* memory = (tic_mem*)getJanetMachine(); 397 + tic_api_spr(memory, index, x, y, w, h, 398 + colorkey.colors, colorkey.count, 399 + scale, flip, rotate); 400 + 401 + return janet_wrap_nil(); 402 + } 403 + 404 + static Janet janet_btn(int32_t argc, Janet* argv) 405 + { 406 + janet_fixarity(argc, 1); 407 + 408 + s32 id = (s32)janet_getinteger(argv, 0); 409 + 410 + tic_mem* memory = (tic_mem*)getJanetMachine(); 411 + return janet_wrap_boolean(tic_api_btn(memory, id)); 412 + } 413 + 414 + static Janet janet_btnp(int32_t argc, Janet* argv) 415 + { 416 + janet_arity(argc, 1, 3); 417 + 418 + s32 id = (s32)janet_getinteger(argv, 0); 419 + s32 hold = (s32)janet_optinteger(argv, argc, 1, -1); 420 + s32 period = (s32)janet_optinteger(argv, argc, 2, -1); 421 + 422 + tic_mem* memory = (tic_mem*)getJanetMachine(); 423 + 424 + return janet_wrap_boolean(tic_api_btnp(memory, id, hold, period)); 425 + } 426 + 427 + static Janet janet_sfx(int32_t argc, Janet* argv) 428 + { 429 + janet_arity(argc, 1, 6); 430 + 431 + s32 index = (s32)janet_getinteger(argv, 0); 432 + SFXNote sfxNote = tic_optsfxnote(argv, argc, 1); 433 + s32 duration = (s32)janet_optinteger(argv, argc, 2, -1); 434 + s32 channel = (s32)janet_optinteger(argv, argc, 3, 0); 435 + 436 + s32 volumes[TIC80_SAMPLE_CHANNELS] = {0}; 437 + volumes[0] = (s32)janet_optinteger(argv, argc, 4, MAX_VOLUME); 438 + volumes[1] = volumes[0]; 439 + 440 + s32 speed = (s32)janet_optinteger(argv, argc, 5, SFX_DEF_SPEED); 441 + 442 + tic_mem* memory = (tic_mem*)getJanetMachine(); 443 + tic_api_sfx(memory, index, 444 + sfxNote.note, sfxNote.octave, 445 + duration, channel, 446 + volumes[0] & 0xf, volumes[1] & 0xf, 447 + speed); 448 + return janet_wrap_nil(); 449 + } 450 + 451 + static void remapCallback(void* data, s32 x, s32 y, RemapResult* result) 452 + { 453 + JanetFunction* remap_fn = (JanetFunction*)data; 454 + 455 + Janet *argv = janet_tuple_begin(3); 456 + argv[0] = janet_wrap_integer(result->index); 457 + argv[1] = janet_wrap_integer(x); 458 + argv[2] = janet_wrap_integer(y); 459 + janet_tuple_end(argv); 460 + 461 + Janet jresult = janet_call(remap_fn, 3, argv); 462 + 463 + if (janet_checktypes(jresult, JANET_TFLAG_INDEXED)) 464 + { 465 + const Janet *jresult_tuple = janet_unwrap_tuple(jresult); 466 + u8 retc = janet_tuple_length(jresult_tuple); 467 + result->index = janet_getinteger(jresult_tuple, 0); 468 + result->flip = janet_optinteger(jresult_tuple, retc, 1, 0); 469 + result->rotate = janet_optinteger(jresult_tuple, retc, 2, 0); 470 + } 471 + else if (janet_checkint(jresult)) 472 + { 473 + result->index = janet_unwrap_integer(jresult); 474 + } 475 + } 476 + 477 + static Janet janet_map(int32_t argc, Janet* argv) 478 + { 479 + janet_arity(argc, 0, 9); 480 + 481 + s32 x = (s32)janet_optinteger(argv, argc, 0, 0); 482 + s32 y = (s32)janet_optinteger(argv, argc, 1, 0); 483 + 484 + s32 w = (s32)janet_optinteger(argv, argc, 2, 30); 485 + s32 h = (s32)janet_optinteger(argv, argc, 3, 17); 486 + 487 + s32 sx = (s32)janet_optinteger(argv, argc, 4, 0); 488 + s32 sy = (s32)janet_optinteger(argv, argc, 5, 0); 489 + 490 + ColorKey colorkey = tic_optcolorkey(argv, argc, 6); 491 + 492 + s32 scale = (s32)janet_optnumber(argv, argc, 7, 1); 493 + 494 + tic_mem* memory = (tic_mem*)getJanetMachine(); 495 + 496 + if (argc < 9) 497 + { 498 + tic_api_map(memory, x, y, w, h, sx, sy, 499 + colorkey.colors, colorkey.count, 500 + scale, NULL, NULL); 501 + } 502 + else 503 + { 504 + JanetFunction *remap = janet_getfunction(argv, 8); 505 + tic_api_map(memory, x, y, w, h, sx, sy, 506 + colorkey.colors, colorkey.count, 507 + scale, 508 + remapCallback, remap); 509 + } 510 + 511 + return janet_wrap_nil(); 512 + } 513 + 514 + static Janet janet_mget(int32_t argc, Janet* argv) 515 + { 516 + janet_fixarity(argc, 2); 517 + 518 + s32 x = (s32)janet_getinteger(argv, 0); 519 + s32 y = (s32)janet_getinteger(argv, 1); 520 + 521 + tic_mem* memory = (tic_mem*)getJanetMachine(); 522 + return janet_wrap_integer(tic_api_mget(memory, x, y)); 523 + } 524 + 525 + static Janet janet_mset(int32_t argc, Janet* argv) 526 + { 527 + janet_fixarity(argc, 3); 528 + 529 + s32 x = (s32)janet_getinteger(argv, 0); 530 + s32 y = (s32)janet_getinteger(argv, 1); 531 + u8 value = (u8)janet_getinteger(argv, 2); 532 + 533 + tic_mem* memory = (tic_mem*)getJanetMachine(); 534 + tic_api_mset(memory, x, y, value); 535 + return janet_wrap_nil(); 536 + } 537 + 538 + static Janet janet_peek(int32_t argc, Janet* argv) 539 + { 540 + janet_arity(argc, 1, 2); 541 + s32 address = (s32)janet_getinteger(argv, 0); 542 + s32 bits = (s32)janet_optinteger(argv, argc, 1, BITS_IN_BYTE); 543 + 544 + tic_mem* memory = (tic_mem*)getJanetMachine(); 545 + return janet_wrap_integer(tic_api_peek(memory, address, bits)); 546 + } 547 + 548 + static Janet janet_poke(int32_t argc, Janet* argv) 549 + { 550 + janet_arity(argc, 2, 3); 551 + s32 address = (s32)janet_getinteger(argv, 0); 552 + u8 value = (s32)janet_getinteger(argv, 1); 553 + s32 bits = (s32)janet_optinteger(argv, argc, 2, BITS_IN_BYTE); 554 + 555 + tic_mem* memory = (tic_mem*)getJanetMachine(); 556 + tic_api_poke(memory, address, value, bits); 557 + 558 + return janet_wrap_nil(); 559 + } 560 + 561 + static Janet janet_peek1(int32_t argc, Janet* argv) 562 + { 563 + janet_fixarity(argc, 1); 564 + 565 + u8 address = (u8)janet_getinteger(argv, 0); 566 + 567 + tic_mem* memory = (tic_mem*)getJanetMachine(); 568 + return janet_wrap_integer(tic_api_peek1(memory, address)); 569 + } 570 + 571 + static Janet janet_poke1(int32_t argc, Janet* argv) 572 + { 573 + janet_fixarity(argc, 2); 574 + 575 + s32 address = (s32)janet_getinteger(argv, 0); 576 + u8 value = (u8)janet_getinteger(argv, 1); 577 + 578 + tic_mem* memory = (tic_mem*)getJanetMachine(); 579 + tic_api_poke1(memory, address, value); 580 + return janet_wrap_nil(); 581 + } 582 + 583 + static Janet janet_peek2(int32_t argc, Janet* argv) 584 + { 585 + janet_fixarity(argc, 1); 586 + 587 + s32 address = janet_getinteger(argv, 0); 588 + 589 + tic_mem* memory = (tic_mem*)getJanetMachine(); 590 + return janet_wrap_integer(tic_api_peek2(memory, address)); 591 + } 592 + 593 + static Janet janet_poke2(int32_t argc, Janet* argv) 594 + { 595 + janet_fixarity(argc, 2); 596 + 597 + s32 address = janet_getinteger(argv, 0); 598 + u8 value = janet_getinteger(argv, 1); 599 + 600 + tic_mem* memory = (tic_mem*)getJanetMachine(); 601 + tic_api_poke2(memory, address, value); 602 + return janet_wrap_nil(); 603 + } 604 + 605 + static Janet janet_peek4(int32_t argc, Janet* argv) 606 + { 607 + janet_fixarity(argc, 1); 608 + 609 + s32 address = janet_getinteger(argv, 0); 610 + 611 + tic_mem* memory = (tic_mem*)getJanetMachine(); 612 + return janet_wrap_integer(tic_api_peek4(memory, address)); 613 + } 614 + 615 + static Janet janet_poke4(int32_t argc, Janet* argv) 616 + { 617 + janet_fixarity(argc, 2); 618 + 619 + s32 address = janet_getinteger(argv, 0); 620 + u8 value = janet_getinteger(argv, 1); 621 + 622 + tic_mem* memory = (tic_mem*)getJanetMachine(); 623 + tic_api_poke4(memory, address, value); 624 + return janet_wrap_nil(); 625 + } 626 + 627 + static Janet janet_memcpy(int32_t argc, Janet* argv) 628 + { 629 + janet_fixarity(argc, 3); 630 + 631 + s32 dst = janet_getinteger(argv, 0); 632 + s32 src = janet_getinteger(argv, 1); 633 + s32 size = janet_getinteger(argv, 2); 634 + 635 + tic_mem* memory = (tic_mem*)getJanetMachine(); 636 + tic_api_memcpy(memory, dst, src, size); 637 + return janet_wrap_nil(); 638 + } 639 + 640 + static Janet janet_memset(int32_t argc, Janet* argv) 641 + { 642 + janet_fixarity(argc, 3); 643 + 644 + s32 dst = janet_getinteger(argv, 0); 645 + u8 val = janet_getinteger(argv, 1); 646 + s32 size = janet_getinteger(argv, 2); 647 + 648 + tic_mem* memory = (tic_mem*)getJanetMachine(); 649 + tic_api_memset(memory, dst, val, size); 650 + return janet_wrap_nil(); 651 + } 652 + 653 + static Janet janet_trace(int32_t argc, Janet* argv) 654 + { 655 + janet_arity(argc, 1, 2); 656 + u8 color = 15; 657 + 658 + const char *message = janet_getcstring(argv, 0); 659 + 660 + if (argc > 1) { 661 + color = janet_getinteger(argv, 1); 662 + } 663 + 664 + tic_mem* memory = (tic_mem*)getJanetMachine(); 665 + tic_api_trace(memory, message, color); 666 + return janet_wrap_nil(); 667 + } 668 + 669 + static Janet janet_pmem(int32_t argc, Janet* argv) 670 + { 671 + janet_arity(argc, 1, 2); 672 + s32 index; 673 + u32 value; 674 + bool get = true; 675 + 676 + index = janet_getinteger(argv, 0); 677 + 678 + if (argc >= 2) { 679 + value = janet_getinteger(argv, 1); 680 + get = false; 681 + } 682 + 683 + tic_mem* memory = (tic_mem*)getJanetMachine(); 684 + return janet_wrap_integer(tic_api_pmem(memory, index, value, 685 + get)); 686 + } 687 + 688 + static Janet janet_time(int32_t argc, Janet* argv) 689 + { 690 + janet_fixarity(argc, 0); 691 + tic_mem* memory = (tic_mem*)getJanetMachine(); 692 + return janet_wrap_number(tic_api_time(memory)); 693 + } 694 + 695 + static Janet janet_tstamp(int32_t argc, Janet* argv) 696 + { 697 + janet_fixarity(argc, 0); 698 + tic_mem* memory = (tic_mem*)getJanetMachine(); 699 + return janet_wrap_integer(tic_api_tstamp(memory)); 700 + } 701 + 702 + static Janet janet_exit(int32_t argc, Janet* argv) 703 + { 704 + janet_fixarity(argc, 0); 705 + tic_mem* memory = (tic_mem*)getJanetMachine(); 706 + tic_api_exit(memory); 707 + return janet_wrap_nil(); 708 + } 709 + 710 + static Janet janet_font(int32_t argc, Janet* argv) 711 + { 712 + janet_arity(argc, 3, 9); 713 + 714 + const char* text = janet_getcstring(argv, 0); 715 + s32 x = (s32)janet_getinteger(argv, 1); 716 + s32 y = (s32)janet_getinteger(argv, 2); 717 + 718 + u8 chromakey = (u8)janet_optinteger(argv, argc, 3, 0); 719 + s32 w= (s32)janet_optinteger(argv, argc, 4, 0); 720 + s32 h = (s32)janet_optinteger(argv, argc, 5, 0); 721 + bool fixed = janet_optboolean(argv, argc, 6, false); 722 + s32 scale = (s32)janet_optinteger(argv, argc, 7, 1); 723 + bool alt = janet_optboolean(argv, argc, 8, false); 724 + 725 + tic_mem* memory = (tic_mem*)getJanetMachine(); 726 + int32_t width = tic_api_font(memory, 727 + text, x, y, &chromakey, 1, 728 + w, h, fixed, scale, alt); 729 + return janet_wrap_integer(width); 730 + } 731 + 732 + static Janet janet_mouse(int32_t argc, Janet* argv) 733 + { 734 + janet_fixarity(argc, 0); 735 + 736 + tic_mem* memory = (tic_mem*)getJanetMachine(); 737 + Janet result[7]; 738 + 739 + { 740 + tic_point point = tic_api_mouse(memory); 741 + result[0] = janet_wrap_integer(point.x); 742 + result[1] = janet_wrap_integer(point.y); 743 + } 744 + 745 + tic_core* core = getJanetMachine(); 746 + const tic80_mouse* mouse = &core->memory.ram->input.mouse; 747 + result[2] = janet_wrap_boolean(mouse->left); 748 + result[3] = janet_wrap_boolean(mouse->middle); 749 + result[4] = janet_wrap_boolean(mouse->right); 750 + result[5] = janet_wrap_number(mouse->scrollx); 751 + result[6] = janet_wrap_number(mouse->scrolly); 752 + 753 + return janet_wrap_tuple(janet_tuple_n(result, 7)); 754 + } 755 + 756 + static Janet janet_circ(int32_t argc, Janet* argv) 757 + { 758 + janet_fixarity(argc, 4); 759 + 760 + s32 x = janet_getinteger(argv, 0); 761 + s32 y = janet_getinteger(argv, 1); 762 + s32 radius = janet_getinteger(argv, 2); 763 + u8 color = janet_getinteger(argv, 3); 764 + 765 + tic_mem* memory = (tic_mem*)getJanetMachine(); 766 + tic_api_circ(memory, x, y, radius, color); 767 + return janet_wrap_nil(); 768 + } 769 + 770 + static Janet janet_circb(int32_t argc, Janet* argv) 771 + { 772 + janet_fixarity(argc, 4); 773 + 774 + s32 x = janet_getinteger(argv, 0); 775 + s32 y = janet_getinteger(argv, 1); 776 + s32 radius = janet_getinteger(argv, 2); 777 + u8 color = janet_getinteger(argv, 3); 778 + 779 + tic_mem* memory = (tic_mem*)getJanetMachine(); 780 + tic_api_circb(memory, x, y, radius, color); 781 + return janet_wrap_nil(); 782 + } 783 + 784 + static Janet janet_elli(int32_t argc, Janet* argv) 785 + { 786 + janet_fixarity(argc, 5); 787 + 788 + s32 x = janet_getinteger(argv, 0); 789 + s32 y = janet_getinteger(argv, 1); 790 + s32 a = janet_getinteger(argv, 2); 791 + s32 b = janet_getinteger(argv, 3); 792 + u8 color = janet_getinteger(argv, 4); 793 + 794 + tic_mem* memory = (tic_mem*)getJanetMachine(); 795 + tic_api_elli(memory, x, y, a, b, color); 796 + return janet_wrap_nil(); 797 + } 798 + 799 + static Janet janet_ellib(int32_t argc, Janet* argv) 800 + { 801 + janet_fixarity(argc, 5); 802 + 803 + s32 x = janet_getinteger(argv, 0); 804 + s32 y = janet_getinteger(argv, 1); 805 + s32 a = janet_getinteger(argv, 2); 806 + s32 b = janet_getinteger(argv, 3); 807 + u8 color = janet_getinteger(argv, 4); 808 + 809 + tic_mem* memory = (tic_mem*)getJanetMachine(); 810 + tic_api_ellib(memory, x, y, a, b, color); 811 + return janet_wrap_nil(); 812 + } 813 + 814 + static Janet janet_tri(int32_t argc, Janet* argv) 815 + { 816 + janet_fixarity(argc, 7); 817 + 818 + float x1 = janet_getnumber(argv, 0); 819 + float y1 = janet_getnumber(argv, 1); 820 + float x2 = janet_getnumber(argv, 2); 821 + float y2 = janet_getnumber(argv, 3); 822 + float x3 = janet_getnumber(argv, 4); 823 + float y3 = janet_getnumber(argv, 5); 824 + u8 color = janet_getnumber(argv, 6); 825 + 826 + tic_mem* memory = (tic_mem*)getJanetMachine(); 827 + tic_api_tri(memory, x1, y1, x2, y2, x3, y3, color); 828 + return janet_wrap_nil(); 829 + } 830 + 831 + static Janet janet_trib(int32_t argc, Janet* argv) 832 + { 833 + janet_fixarity(argc, 7); 834 + 835 + float x1 = janet_getnumber(argv, 0); 836 + float y1 = janet_getnumber(argv, 1); 837 + float x2 = janet_getnumber(argv, 2); 838 + float y2 = janet_getnumber(argv, 3); 839 + float x3 = janet_getnumber(argv, 4); 840 + float y3 = janet_getnumber(argv, 5); 841 + u8 color = janet_getnumber(argv, 6); 842 + 843 + tic_mem* memory = (tic_mem*)getJanetMachine(); 844 + tic_api_trib(memory, x1, y1, x2, y2, x3, y3, color); 845 + return janet_wrap_nil(); 846 + } 847 + 848 + static Janet janet_ttri(int32_t argc, Janet* argv) 849 + { 850 + janet_arity(argc, 12, 17); 851 + 852 + float x1 = janet_getnumber(argv, 0); 853 + float y1 = janet_getnumber(argv, 1); 854 + float x2 = janet_getnumber(argv, 2); 855 + float y2 = janet_getnumber(argv, 3); 856 + float x3 = janet_getnumber(argv, 4); 857 + float y3 = janet_getnumber(argv, 5); 858 + 859 + float u1 = janet_getnumber(argv, 6); 860 + float v1 = janet_getnumber(argv, 7); 861 + float u2 = janet_getnumber(argv, 8); 862 + float v2 = janet_getnumber(argv, 9); 863 + float u3 = janet_getnumber(argv, 10); 864 + float v3 = janet_getnumber(argv, 11); 865 + 866 + tic_texture_src src = tic_tiles_texture; 867 + if (janet_optboolean(argv, argc, 12, false)) { 868 + src = tic_map_texture; 869 + } 870 + 871 + ColorKey trans = tic_optcolorkey(argv, argc, 13); 872 + TriDepth depth = tic_opttridepth(argv, argc, 14); 873 + 874 + tic_mem* memory = (tic_mem*)getJanetMachine(); 875 + tic_api_ttri(memory, 876 + x1, y1, 877 + x2, y2, 878 + x3, y3, 879 + u1, v1, 880 + u2, v2, 881 + u3, v3, 882 + src, 883 + trans.colors, trans.count, 884 + depth.z[0], depth.z[1], depth.z[2], depth.on); 885 + 886 + return janet_wrap_nil(); 887 + } 888 + 889 + static Janet janet_clip(int32_t argc, Janet* argv) 890 + { 891 + janet_arity(argc, 0, 4); 892 + 893 + tic_mem* memory = (tic_mem*)getJanetMachine(); 894 + 895 + if (argc == 0) { 896 + tic_api_clip(memory, 0, 0, TIC80_WIDTH, TIC80_HEIGHT); 897 + } else if (argc == 4) { 898 + s32 x = janet_getinteger(argv, 0); 899 + s32 y = janet_getinteger(argv, 1); 900 + s32 w = janet_getinteger(argv, 2); 901 + s32 h = janet_getinteger(argv, 3); 902 + tic_api_clip(memory, x, y, w, h); 903 + } else { 904 + janet_panic("Error: must provide exactly 0 or 4 args."); 905 + } 906 + 907 + return janet_wrap_nil(); 908 + } 909 + 910 + static Janet janet_music(int32_t argc, Janet* argv) 911 + { 912 + janet_arity(argc, 0, 7); 913 + 914 + s32 track = janet_optinteger(argv, argc, 0, -1); 915 + s32 frame = janet_optinteger(argv, argc, 1, -1); 916 + s32 row = janet_optinteger(argv, argc, 2, -1); 917 + bool loop = janet_optboolean(argv, argc, 3, true); 918 + bool sustain = janet_optboolean(argv, argc, 4, true); 919 + s32 tempo = janet_optinteger(argv, argc, 5, -1); 920 + s32 speed = janet_optinteger(argv, argc, 6, -1); 921 + 922 + tic_mem* memory = (tic_mem*)getJanetMachine(); 923 + tic_api_music(memory, track, frame, row, loop, sustain, tempo, speed); 924 + 925 + return janet_wrap_nil(); 926 + } 927 + 928 + static Janet janet_sync(int32_t argc, Janet* argv) 929 + { 930 + janet_arity(argc, 0, 3); 931 + 932 + u32 mask = janet_optinteger(argv, argc, 0, 0); 933 + s32 bank = janet_optinteger(argv, argc, 1, 0); 934 + bool toCart = janet_optboolean(argv, argc, 2, false); 935 + 936 + tic_mem* memory = (tic_mem*)getJanetMachine(); 937 + tic_api_sync(memory, mask, bank, toCart); 938 + return janet_wrap_nil(); 939 + } 940 + 941 + static Janet janet_vbank(int32_t argc, Janet* argv) 942 + { 943 + janet_fixarity(argc, 1); 944 + 945 + s32 bank = janet_getinteger(argv, 0); 946 + 947 + tic_mem* memory = (tic_mem*)getJanetMachine(); 948 + return janet_wrap_integer(tic_api_vbank(memory, bank)); 949 + } 950 + 951 + static Janet janet_reset(int32_t argc, Janet* argv) 952 + { 953 + janet_fixarity(argc, 0); 954 + tic_core* machine = getJanetMachine(); 955 + machine->state.initialized = false; 956 + return janet_wrap_nil(); 957 + } 958 + 959 + static Janet janet_key(int32_t argc, Janet* argv) 960 + { 961 + janet_arity(argc, 0, 1); 962 + tic_key key = -1; 963 + 964 + if (argc >= 1) key = (tic_key)janet_getinteger(argv, 0); 965 + 966 + tic_mem* memory = (tic_mem*)getJanetMachine(); 967 + return janet_wrap_boolean(tic_api_key(memory, key)); 968 + } 969 + 970 + static Janet janet_keyp(int32_t argc, Janet* argv) 971 + { 972 + janet_arity(argc, 0, 3); 973 + tic_key key = -1; 974 + s32 hold = -1; 975 + s32 period = -1; 976 + 977 + if (argc >= 1) key = (tic_key)janet_getinteger(argv, 0); 978 + if (argc >= 2) hold = janet_getinteger(argv, 1); 979 + if (argc >= 3) period = janet_getinteger(argv, 2); 980 + 981 + tic_mem* memory = (tic_mem*)getJanetMachine(); 982 + return janet_wrap_boolean(tic_api_keyp(memory, key, hold, period)); 983 + } 984 + 985 + static Janet janet_fget(int32_t argc, Janet* argv) 986 + { 987 + janet_fixarity(argc, 2); 988 + 989 + s32 index = janet_getinteger(argv, 0); 990 + u8 flag = janet_getinteger(argv, 1); 991 + 992 + tic_mem* memory = (tic_mem*)getJanetMachine(); 993 + return janet_wrap_boolean(tic_api_fget(memory, index, flag)); 994 + } 995 + 996 + 997 + static Janet janet_fset(int32_t argc, Janet* argv) 998 + { 999 + janet_fixarity(argc, 3); 1000 + 1001 + s32 index = janet_getinteger(argv, 0); 1002 + u8 flag = janet_getinteger(argv, 1); 1003 + bool value = janet_getboolean(argv, 2); 1004 + 1005 + tic_mem* memory = (tic_mem*)getJanetMachine(); 1006 + tic_api_fset(memory, index, flag, value); 1007 + return janet_wrap_nil(); 1008 + } 1009 + 1010 + /* ***************** */ 1011 + static void reportError(tic_core* core, Janet result) 1012 + { 1013 + janet_stacktrace(GameFiber, result); 1014 + janet_buffer_push_u8(&errBuffer, 0); 1015 + core->data->error(core->data->data, errBuffer.data); 1016 + } 1017 + 1018 + 1019 + static void closeJanet(tic_mem* tic) 1020 + { 1021 + tic_core* core = (tic_core*)tic; 1022 + 1023 + if (core->currentVM) { 1024 + janet_deinit(); 1025 + core->currentVM = NULL; 1026 + CurrentMachine = NULL; 1027 + janet_buffer_deinit(&errBuffer); 1028 + GameFiber = NULL; 1029 + } 1030 + } 1031 + 1032 + static bool initJanet(tic_mem* tic, const char* code) 1033 + { 1034 + closeJanet(tic); 1035 + janet_init(); 1036 + 1037 + JanetTable *env = janet_core_env(NULL); 1038 + JanetTable *sub_env = janet_table(0); 1039 + janet_cfuns(sub_env, "tic80", janet_c_functions); 1040 + 1041 + // Provide the tic80 api as a module 1042 + Janet module_cache = janet_resolve_core("module/cache"); 1043 + janet_table_put(janet_unwrap_table(module_cache), janet_cstringv("tic80"), janet_wrap_table(sub_env)); 1044 + 1045 + tic_core* core = (tic_core*)tic; 1046 + CurrentMachine = core; 1047 + core->currentVM = (JanetTable*)janet_core_env(NULL); 1048 + 1049 + // override the dynamic err to a buffer, so that we can get errors later 1050 + janet_buffer_init(&errBuffer, 1028); 1051 + janet_setdyn("err", janet_wrap_buffer(&errBuffer)); 1052 + 1053 + GameFiber = janet_current_fiber(); 1054 + Janet result; 1055 + 1056 + // Load the game source code 1057 + if (janet_dostring(core->currentVM, code, "main", &result)) { 1058 + reportError(core, result); 1059 + return false; 1060 + } 1061 + 1062 + return true; 1063 + } 1064 + 1065 + 1066 + static void evalJanet(tic_mem* tic, const char* code) 1067 + { 1068 + tic_core* core = (tic_core*)tic; 1069 + 1070 + Janet result = janet_wrap_nil(); 1071 + if (janet_dostring(core->currentVM, code, "main", &result)) { 1072 + reportError(core, result); 1073 + } 1074 + } 1075 + 1076 + 1077 + /* 1078 + * Find a function called TIC_FN and execute it. If we can't find it, then 1079 + * it is a problem. 1080 + */ 1081 + static void callJanetTick(tic_mem* tic) 1082 + { 1083 + tic_core* core = (tic_core*)tic; 1084 + 1085 + // Load the TIC function 1086 + Janet pre_fn; 1087 + (void)janet_resolve(core->currentVM, janet_csymbol(TIC_FN), &pre_fn); 1088 + 1089 + if (janet_type(pre_fn) != JANET_FUNCTION) { 1090 + core->data->error(core->data->data, "(TIC) isn't found :("); 1091 + return; 1092 + } 1093 + 1094 + JanetFunction *tic_fn = janet_unwrap_function(pre_fn); 1095 + Janet result = janet_wrap_nil(); 1096 + JanetSignal status = janet_pcall(tic_fn, 0, NULL, &result, &GameFiber); 1097 + 1098 + if (status != JANET_SIGNAL_OK) { 1099 + reportError(core, result); 1100 + } 1101 + } 1102 + 1103 + /* 1104 + * Find a function called BOOT_FN and execute it. If we can't find it, then 1105 + * it's not a problem. 1106 + */ 1107 + static void callJanetBoot(tic_mem* tic) 1108 + { 1109 + tic_core* core = (tic_core*)tic; 1110 + 1111 + Janet pre_fn; 1112 + (void)janet_resolve(core->currentVM, janet_csymbol(BOOT_FN), &pre_fn); 1113 + 1114 + if (janet_type(pre_fn) != JANET_FUNCTION) { 1115 + return; 1116 + } 1117 + 1118 + Janet result = janet_wrap_nil(); 1119 + JanetFunction *boot_fn = janet_unwrap_function(pre_fn); 1120 + JanetSignal status = janet_pcall(boot_fn, 0, NULL, &result, &GameFiber); 1121 + 1122 + if (status != JANET_SIGNAL_OK) { 1123 + reportError(core, result); 1124 + } 1125 + } 1126 + 1127 + /* 1128 + * Find a function with the given name and execute it with the given value. 1129 + * If we can't find it, then it's not a problem. 1130 + */ 1131 + static void callJanetIntCallback(tic_mem* tic, s32 value, void* data, const char* name) 1132 + { 1133 + tic_core* core = (tic_core*)tic; 1134 + 1135 + Janet pre_fn; 1136 + (void)janet_resolve(core->currentVM, janet_csymbol(name), &pre_fn); 1137 + 1138 + if (janet_type(pre_fn) != JANET_FUNCTION) { 1139 + return; 1140 + } 1141 + 1142 + Janet result = janet_wrap_nil(); 1143 + Janet argv[] = { janet_wrap_integer(value), }; 1144 + JanetFunction *fn = janet_unwrap_function(pre_fn); 1145 + JanetSignal status = janet_pcall(fn, 1, argv, &result, &GameFiber); 1146 + 1147 + if (status != JANET_SIGNAL_OK) { 1148 + reportError(core, result); 1149 + } 1150 + } 1151 + 1152 + static void callJanetScanline(tic_mem* tic, s32 row, void* data) 1153 + { 1154 + callJanetIntCallback(tic, row, data, SCN_FN); 1155 + callJanetIntCallback(tic, row, data, "scanline"); 1156 + } 1157 + 1158 + static void callJanetBorder(tic_mem* tic, s32 row, void* data) 1159 + { 1160 + callJanetIntCallback(tic, row, data, BDR_FN); 1161 + } 1162 + 1163 + static void callJanetMenu(tic_mem* tic, s32 index, void* data) 1164 + { 1165 + callJanetIntCallback(tic, index, data, MENU_FN); 1166 + } 1167 + 1168 + static const tic_outline_item* getJanetOutline(const char* code, s32* size) 1169 + { 1170 + static tic_outline_item* items = NULL; 1171 + if (items) { 1172 + free(items); 1173 + items = NULL; 1174 + } 1175 + return items; 1176 + } 1177 + 1178 + /* ***************** */ 1179 + 1180 + const tic_script_config JanetSyntaxConfig = 1181 + { 1182 + .id = 18, 1183 + .name = "janet", 1184 + .fileExtension = ".janet", 1185 + .projectComment = "#", 1186 + .init = initJanet, 1187 + .close = closeJanet, 1188 + .tick = callJanetTick, 1189 + .boot = callJanetBoot, 1190 + 1191 + .callback = 1192 + { 1193 + .scanline = callJanetScanline, 1194 + .border = callJanetBorder, 1195 + .menu = callJanetMenu, 1196 + }, 1197 + 1198 + .getOutline = getJanetOutline, 1199 + .eval = evalJanet, 1200 + 1201 + .blockCommentStart = NULL, 1202 + .blockCommentEnd = NULL, 1203 + .blockCommentStart2 = NULL, 1204 + .blockCommentEnd2 = NULL, 1205 + .singleComment = "#", 1206 + .blockStringStart = NULL, 1207 + .blockStringEnd = NULL, 1208 + .blockEnd = NULL, 1209 + 1210 + .keywords = JanetKeywords, 1211 + .keywordsCount = COUNT_OF(JanetKeywords), 1212 + }; 1213 + 1214 + #endif /* defined(TIC_BUILD_WITH_JANET) */
+12 -5
src/core/languages.c
··· 33 33 extern tic_script_config WasmSyntaxConfig; 34 34 #endif 35 35 36 + #if defined(TIC_BUILD_WITH_JANET) 37 + extern tic_script_config JanetSyntaxConfig; 38 + #endif 39 + 36 40 37 41 tic_script_config* Languages[] = { 38 42 ··· 40 44 &LuaSyntaxConfig, 41 45 #endif 42 46 43 - #if defined(TIC_BUILD_WITH_MRUBY) 44 - &MRubySyntaxConfig, 45 - #endif 47 + #if defined(TIC_BUILD_WITH_MRUBY) 48 + &MRubySyntaxConfig, 49 + #endif 46 50 47 51 #if defined(TIC_BUILD_WITH_JS) 48 52 &JsSyntaxConfig, ··· 64 68 &WrenSyntaxConfig, 65 69 #endif 66 70 67 - #if defined(TIC_BUILD_WITH_WASM) 71 + #if defined(TIC_BUILD_WITH_WASM) 68 72 &WasmSyntaxConfig, 69 73 #endif 70 74 75 + #if defined(TIC_BUILD_WITH_JANET) 76 + &JanetSyntaxConfig, 77 + #endif 78 + 71 79 NULL}; 72 -
+27 -3
src/studio/demos.c
··· 178 178 179 179 #endif 180 180 181 + #if defined(TIC_BUILD_WITH_JANET) 182 + 183 + static const u8 JanetDemoRom[] = 184 + { 185 + #include "../build/assets/janetdemo.tic.dat" 186 + }; 187 + 188 + static const u8 janetmark[] = 189 + { 190 + #include "../build/assets/janetmark.tic.dat" 191 + }; 192 + 193 + tic_script_config_extra JanetSyntaxConfigExtra = 194 + { 195 + .name = "janet", 196 + .demoRom = JanetDemoRom, 197 + .demoRomSize = sizeof JanetDemoRom, 198 + .markRom = janetmark, 199 + .markRomSize = sizeof janetmark, 200 + }; 201 + 202 + #endif 203 + 181 204 tic_script_config_extra* getConfigExtra(const tic_script_config* config) 182 205 { 183 206 184 - for (tic_script_config_extra** conf = LanguagesExtra ; *conf != NULL; conf++ ) { 207 + for (tic_script_config_extra** conf = LanguagesExtra ; *conf != NULL; conf++ ) { 185 208 tic_script_config_extra* ln = *conf; 186 209 if (strcmp(config->name, ln->name) == 0) 187 210 { ··· 216 239 #if defined(TIC_BUILD_WITH_WASM) 217 240 &WasmSyntaxConfigExtra, 218 241 #endif 242 + #if defined(TIC_BUILD_WITH_WASM) 243 + &JanetSyntaxConfigExtra, 244 + #endif 219 245 NULL 220 246 }; 221 - 222 -