Forth#2947
Conversation
|
(made with the help of Claude code) |
pforth cell_t = uintptr_t, so the pre-compiled dictionary is cell-size-dependent (64-bit on x86-64, 32-bit on WASM). Loading a 64-bit dictionary in a 32-bit runtime corrupts all addresses and freezes the HTML player. - cmake/pfdicdat_32.h: new 32-bit dictionary (generated with gcc -m32) - cmake/forth.cmake: select pfdicdat_32.h when CMAKE_SIZEOF_VOID_P == 4
|
Note: OP had the courtesy to open a discussion (#2938) regarding the project's AI contribution policy before vibe-coding this payload. Resolving the policy matter should probably be considered a prerequisite to reviewing this PR. |
MineRobber9000
left a comment
There was a problem hiding this comment.
I don't know enough about pforth to critique the actual implementation of the API, but there are definitely some spots in here that I am concerned about.
| message(STATUS "Forth: copying bundled ${_PFORTH_DICDAT_BUNDLED} to ${PFORTH_DICDAT}") | ||
| configure_file(${_PFORTH_DICDAT_BUNDLED} ${PFORTH_DICDAT} COPYONLY) | ||
| else() | ||
| message(STATUS "Forth: pfdicdat.h not found — bootstrapping pforth to generate it...") |
There was a problem hiding this comment.
If we can use pforth to bootstrap the pfdicdat.h generation, why are we bundling a version of this data anyways? What happens if pforth updates in a way that adds more stuff to the dictionary, and now our bundled data is out of date?
There was a problem hiding this comment.
@MineRobber9000 that's a good question. I've initially let it generate the pfdicdat.h and pfdicdat_32.h from pforth but there was a problem with some targets (nintendo3D and rpi) do I've included those headers but it's not ideal.
It should be fixed now. I've tested the nintendo 3DS build and it's working fine.
| \ license: MIT License | ||
| \ script: forth | ||
| \ | ||
| \ -- TIC-80 Forth API -------------------------------------------------- |
There was a problem hiding this comment.
You don't need to leave this API reference in the code.
| ; | ||
|
|
||
| \ -- Demo 2 : sprite + arrow keys ------------------------------------- | ||
| : demo02 |
There was a problem hiding this comment.
This is the only one you actually need to have. The others are all just clutter that a user would have to delete before starting their own game.
There was a problem hiding this comment.
sure. I've removed all that, including the API references and additional examples. Do you think it should be better to include such informations in an additional file in the demos/ folder under a new name, or leave this to the wiki, or even somewhere else? I see in the demos folder some lua samples like fire.lua or tetris.lua so I don't know
|
|
||
| : BOOT | ||
| 96 px ! 24 py ! | ||
| S" Forth BOOT" 12 TRACE |
There was a problem hiding this comment.
Remove this, no other language does this. (EDIT: to clarify, since GH shows a seemingly random collection of lines and not the one you explicitly select in the interface, this is referring to tracing "Forth BOOT" in the BOOT callback.)
There was a problem hiding this comment.
ok. I've just kept the BOOT procedure for initialising the variables, and kept the "demo01" word outside of the TIC loop, so people can just comment the demo and start creating new words.
| @@ -0,0 +1,129 @@ | |||
| // MIT License | |||
There was a problem hiding this comment.
This should also go in forth.c. In general, all languages should be one C file apiece; the only exception are the Lua languages (Lua, MoonScript, Yue, and Fennel), since they all share the same plumbing underneath and only differ in how they're initialized.
There was a problem hiding this comment.
it has been merged into the forth.c
removing cmake/pfdicdat.h and cmake/pfdicdat_32.h from tree updating cmake/forth.cmake for bootstraping pfdicdat
|
How did you manage to |
oops, long story short I needed to edit some files from another (local) account (on my computer). I can try to revert the 755 to 644 if you wish, but that will trigger a new build for nothing. |
|
You definitely should undo it. I can't review the PR in this state since I'd have to scroll through basically every file in the repo just to see what you actually changed. |
Ok, i've fixed it, I'm just working on another problem (wrong/misleading message during a stack underflow) and I'll commit that ASAP |
fix "stack underflow" message
| : demo01 | ||
| 0 BTN IF py @ 1- py ! THEN | ||
| 1 BTN IF py @ 1+ py ! THEN | ||
| 2 BTN IF px @ 1- px ! THEN | ||
| 3 BTN IF px @ 1+ px ! THEN | ||
| 13 CLS | ||
| 1 px @ py @ 14 3 0 0 2 2 SPR | ||
| S" Hello Forth!" 84 84 15 FALSE 1 FALSE PRINT DROP | ||
| ; | ||
|
|
||
| : TIC | ||
| demo01 | ||
| ; |
There was a problem hiding this comment.
| : demo01 | |
| 0 BTN IF py @ 1- py ! THEN | |
| 1 BTN IF py @ 1+ py ! THEN | |
| 2 BTN IF px @ 1- px ! THEN | |
| 3 BTN IF px @ 1+ px ! THEN | |
| 13 CLS | |
| 1 px @ py @ 14 3 0 0 2 2 SPR | |
| S" Hello Forth!" 84 84 15 FALSE 1 FALSE PRINT DROP | |
| ; | |
| : TIC | |
| demo01 | |
| ; | |
| : TIC | |
| 0 BTN IF py @ 1- py ! THEN | |
| 1 BTN IF py @ 1+ py ! THEN | |
| 2 BTN IF px @ 1- px ! THEN | |
| 3 BTN IF px @ 1+ px ! THEN | |
| 13 CLS | |
| 1 px @ py @ 14 3 0 0 2 2 SPR | |
| S" Hello Forth!" 84 84 15 FALSE 1 FALSE PRINT DROP | |
| ; |
If the user wants to write their own code, they'll probably want to just delete the whole demo code, so having it be a separate word is just clutter.
|
Also, you forgot to install |
fix mac os build by limiting the number of parallel processes
- Remove references to committed cmake/pfdicdat.h and pfdicdat_32.h (deleted in PR nesbox#2947 forth branch) - Document that cmake/forth.cmake now always regenerates pfdicdat.h at configure time via file(REMOVE) + bootstrap - Add critical warning: a stale 32-bit dict in a 64-bit binary causes a silent segfault when selecting "new forth" (root cause documented) - Update platform/cell-size matrix (WASM/3DS/RPI = 32-bit) - Remove now-outdated manual regeneration instructions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: minerobber <milesrobert374@gmail.com>
Co-authored-by: minerobber <milesrobert374@gmail.com>
Co-authored-by: minerobber <milesrobert374@gmail.com>
Co-authored-by: minerobber <milesrobert374@gmail.com>
adding Forth langages to TIC-80 (using pforth)