Saturday, May 7, 2022

Turn Any TiddlyWiki into a Lightweight BASIC Anywhere Machine

AND:  Add a "Clock" BASIC program to the TiddlyWiki Sidebar.




🆕 FIX function

The FIX function truncates a real number resulting from a numeric expression into a whole number.

🪲Fix to DRAW and LINE

Back on April 25th and without posting about it, I uploaded a new version of BASIC Anywhere Machine that fixed a problem with the LINE statement, and did not realize until today that the fix to LINE had broken DRAW.

Yesterday, I uploaded a new version of BASIC Anywhere Machine to fix the problem I caused with DRAW, so that now both LINE and DRAW seem to be behaving correctly.

I need to take some time and thoroughly test everything having to do with graphics statements.


Details:

The problem fixed with LINE

A bug in wwwBASIC causes it to not apply last known Graphics Pen Position when a graphics statement calls for it.

Example: LINE - (x2,y2)

Normally, that is supposed to create a line starting at the last known pen position.  However, wwwBASIC will always start the line at x1 = 0 and y1 = 0.  (And: wwwBASIC does not attempt to remember pen position at the end of a LINE statement.)

BASIC Anywhere Machine fixes this issue.  (And:  BASIC Anywhere Machine does record the end coordinates of a LINE statement as last known graphics pen position as the potential starting point for the next line statement. )

The problem with DRAW

After the change to LINE behaviour described above, each starting pen movement within a chain of them in one DRAW comment was not starting at the end position of the previous movement.

I had not realized that LINE and DRAW were using some common code, and the change in that code to fix LINE was messing things up for DRAW.  So I've duplicated the common code, one version for LINE and what it needed, and one for DRAW as per the wwwBASIC version of that code.

Now all seems well.

Friday, May 6, 2022

🪲 Fix to CINT Function

 CINT was behaving like INT.


INT truncates a number to the the next lowest integer.  CINT was doing the same thing. 

CINT is supposed to round numbers, which it now does.


Thursday, April 28, 2022

🕹Wumpus !

From Wikipedia:

Hunt the Wumpus is a text-based adventure game developed by Gregory Yob in 1973. In the game, the player moves through a series of connected caves, arranged as the vertices of a dodecahedron, as they hunt a monster named the Wumpus. The turn-based game has the player trying to avoid fatal bottomless pits and "super bats" that will move them around the cave system; the goal is to fire one of their "crooked arrows" through the caves to kill the Wumpus. Yob created the game in early 1973 due to his annoyance at the multiple hide-and-seek games set in caves in a grid pattern, and multiple variations of the game were sold via mail order by Yob and the People's Computer Company. The source code to the game was published in Creative Computing in 1975 and republished in The Best of Creative Computing the following year.

The game sparked multiple variations and expanded versions and was ported to several systems, including the TI-99/4A home computer. It has been cited as an early example of the survival horror genre, and was listed in 2012 on Time's All-Time 100 greatest video games list. The Wumpus monster has appeared in several forms in media since 1973, including other video games, a novella, and Magic: The Gathering cards.

BASIC Anywhere Machine version of Wumpus:




Friday, April 22, 2022

⏱ Removed program throttling (for now)

I had not realized that wwwBASIC was throttling BASIC programs.

That does make sense to do so, because so many classic games from the golden years of BASIC would not be playable without throttling.

For the moment, I've significantly reduced the impact of throttling.  Not being too confident of my javascript skills and not quite sure what the javascript code (in wwwBASIC) is doing, I made a simple change that does not break the interpreter but does speed things up significantly.

You'll find a "Benchmark Test" program in the latest version of BASIC Anywhere Machine.  The benchmark results will be different between computers/devices/browsers.  On my Chromebook (Intel Pentium CPU N4200 @ 1.10GHz, 4GB RAM), the benchmark program now completes in about 5.25 seconds, versus the 22.5-ish seconds before the throttling change I made today.

On my TODO list: setup an interface (i.e. widgets in BASIC Anywhere Machine) to adjust throttle settings for every program.

Something like that.

Cheers !

Sunday, April 3, 2022

🆕 _NEWIMAGE Keyword (for the SCREEN Statement)

 References:


I've implemented _NEWIMAGE such that it is somewhat compatible with the function in QB64.

Although I may implement _NEWIMAGE differently in the future, I decided to go with a no fuss no muss, quick and easy, approach.

In BASIC Anywhere Machine:
  • _NEWIMAGE is not a stand-alone function.  It is simply a keyword recognized by the SCREEN statement, but a keyword made to look like a function
    • Syntax:  SCREEN _NEWIMAGE(width, height, mode)
    • "Parameters":
      • width: the screen width, in pixels, of the console window
      • height: the screen height, in pixels, of the console window
      • mode: the base screen mode to use, width and height parameters overriding the default width and height of the mode
  • The original alternative syntax for the screen statement:
    • SCREEN mode
The SCREEN documentation in the programming reference discusses the attributes for each available screen mode.  For your convenience, refer to this (small HTML file) export of the "SCREEN Modes" documentation.


🖥 Ardi's Graph

A port and mod of a program shared by Ardi Ardi with the "BASIC Programming Language" Facebook group via this post . This program ...