javascript_terminal_v3
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
javascript_terminal_v3 [2023/11/30 02:27] – appledog | javascript_terminal_v3 [2023/11/30 02:37] (current) – appledog | ||
---|---|---|---|
Line 39: | Line 39: | ||
=== BASIC Interpreter | === BASIC Interpreter | ||
+ | < | ||
+ | 10 PRINT A | ||
+ | 20 GOTO 40 | ||
+ | 30 PRINT B | ||
+ | 40 PRINT C | ||
+ | 50 PRINT D | ||
+ | LIST | ||
+ | RUN | ||
+ | A | ||
+ | C | ||
+ | D | ||
+ | |||
+ | </ | ||
+ | |||
Instead of refactoring into a state machine, I threw together a quick BASIC class which processed commands in a program[] array. It handles print, and goto. Since it is a quick design it can not handle infinite loops or very long programs, since there is no time for the game loop to process updates and render or for the UI to make those changes to canvas. | Instead of refactoring into a state machine, I threw together a quick BASIC class which processed commands in a program[] array. It handles print, and goto. Since it is a quick design it can not handle infinite loops or very long programs, since there is no time for the game loop to process updates and render or for the UI to make those changes to canvas. | ||
Line 75: | Line 89: | ||
} | } | ||
} | } | ||
+ | </ | ||
This example is how to support a large number of opcodes/ | This example is how to support a large number of opcodes/ | ||
== Refactoring Needed | == Refactoring Needed | ||
- | V3 is V2 but with changes made in how terminal is controlled by the main program. The error of processing commands in the terminal was addressed | + | V3 is V2 but with changes made in how terminal is controlled by the main program. The code has also become somewhat spaghetti. I partially |
- | The code has also become somewhat spaghetti. I partially addressed this by removing | + | In a real VM, the code would not be stored in a program[] array but in memory[] and read from there by the interpreter. There are lots of little design clashes between the idea of a VM, the idea of a Game (NetWhack) |
- | And, in a real VM, the code would not be stored in a program[] array but in memory[] and read from there by the interpreter. There are lots of little design clashes between | + | == Bugs |
+ | Well, there are still a few ' | ||
== Final Thoughts | == Final Thoughts |
javascript_terminal_v3.1701311253.txt.gz · Last modified: 2023/11/30 02:27 by appledog