News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

CPCBasic Unchained

Started by mv, 13:54, 26 September 19

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

mv

I just learned that the transparent background mode  GRAPHICS PEN ,1  also affects DRAW with MASK.
You can see the effect in the linemask example:
https://benchmarko.github.io/CPCBasic/cpcbasic.html?example=test/linemask

Now the searchlight in the Amstrad CPC 6128 Demo also works:
https://github.com/benchmarko/CPCBasicApps#amstrad-cpc-6128-demo

AMSDOS

Quote from: mv on 17:34, 29 October 20
I just learned that the transparent background mode  GRAPHICS PEN ,1  also affects DRAW with MASK.
You can see the effect in the linemask example:
https://benchmarko.github.io/CPCBasic/cpcbasic.html?example=test/linemask

Now the searchlight in the Amstrad CPC 6128 Demo also works:
https://github.com/benchmarko/CPCBasicApps#amstrad-cpc-6128-demo


Its used to set the Graphic Write Mode, though in the firmware it's part of the Screen Pack (SCR ACCESS), with 0 = Normal, 1 = XOR, 2 = AND and 3 = OR. All the Graphical Statements adbide by it though, PLOT, DRAW, etc. On a 464 it's only accessable with PRINT CHR$(23);CHR$(n); with 'n' representing one of those values. I used the OR writing mode a couple of years ago to write Red's Exit, which helped produce that Maze effect. So essentually this is the Graphical equivalent of Transparent Mode CHR$(22); though a little different, XOR can be used to create Multicoloured Images like Transparent Mode, though can be cleared by simply printing over the Image again.
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

mv

I am working on a pretty print feature for BASIC. It seems to work pretty well already.
For testing purpose, the differences are put in the JavaScript window (except for lowercase and uppercase).
Undo and redo is also possible.

It has a fixed style with an extra space inserted between commands and arguments. But not always. If there is a stream, no space is inserted:
10 INPUT"key";a$ :'not pretty
20 INPUT "key";a$:'pretty
30 INPUT#2,"key";a$:'pretty

Not sure if this a good approach.

For arithmetic operations, it only keeps the necessary parentheses determined from the operator precedences.
This could be an issue, if parentheses are used to prevent an overflow, e.g.10 ?1E+38*(10/100)
20 ?1E+38*10/100


Maybe the pretty print feature can also be used to minify BASIC later...

genesis8

I would like to add CPCBasic Unchained on my web site, and load ascii basic files while calling CPCBasic, is it possible ?
____________
Amstrad news site at Genesis8 Amstrad Page

mv

Quote from: genesis8 on 22:16, 15 November 20
I would like to add CPCBasic Unchained on my web site, and load ascii basic files while calling CPCBasic, is it possible ?
Good point.
If you are happy with the current CPCBasic UI, you can put it in an IFrame like:
https://benchmarko.github.io/CPCBasic/test/testIFrames.html

To get your own examples, set the parameter databaseDirs as I did in https://github.com/benchmarko/CPCBasic/blob/master/cpcconfig.js:
databaseDirs: "examples,https://benchmarko.github.io/CPCBasicApps/apps,storage"

This parameter can also be used as an URL parameter, e.g.
https://benchmarko.github.io/CPCBasic/cpcbasic.html?databaseDirs=https://<mySite>/myExamples

From this location, a file 0index.js is loaded with the "diectory" of the samples:
https://github.com/benchmarko/CPCBasic/blob/master/examples/0index.js

cpcBasic.addIndex("./examples", function () { /*
[
    {
        "key": "1st",
        "title": "First Program (empty)"
    },
...
    {
        "key": "archi/archidr",
        "title": "Little Architect Draw (BASIC)"
    },
    {
        "key": "archi/archi1.bil",
        "title": "Drawing Set 1",
        "meta": "D"
    },
...
]
*/ });


Use meta: "D" to mark a file containing data, not be selectable on the UI.


As files, you can use plain ASCII/BASIC, or BASE64 encoded files with a prefix containing file type ASCII (A), tokenized BASIC (T) or Binary (B) and the format:
CPCBasic;<file type>;<load addess>;<length>;<entry>;base64;<BASE64 encoded data>

- Plain ASCII, BASIC:
https://github.com/benchmarko/CPCBasic/blob/master/examples/blkedit.js

cpcBasic.addItem("", function () { /*
10 rem blkedit - Block Editor
...
*/ });


- Tokenized BASIC (T;<load addess>;<length>;<entry>;base64;<BASE64 encoded data>):
https://github.com/benchmarko/CPCBasic/blob/master/examples/math/ninedig2.js

cpcBasic.addItem("", function () { /*
CPCBasic;T;368;1126;0;base64,EgBkA...
*/ });


- Binary (B;<load addess>;<length>;<entry>;base64;<BASE64 encoded data>):
https://github.com/benchmarko/CPCBasic/blob/master/examples/archi/archi1.bil.js

cpcBasic.addItem("", function () { /*
CPCBasic;B;16384;3728;0;base64,Dl8ANg...
*/ });


If you plan to create your own UI for CPCBasic, please tell me. Maybe we can define an API to make it easier.
And if you prefer, you can also put the whole stuff on your site.

mv

In the meantime I have implemented CpcBasic in TypeScript.
Mainly to learn TypeScript, but also to add some new functionality.
It is now possible to generate and download BASIC programs in tokenized form.
(At the moment, superfluous spaces are ignored.)
If you want to try it:
https://benchmarko.github.io/CPCBasicTS/

genesis8

My bad, I am so slow...

I finally added CPCBasicTS on my web site, first example is the sound of waves and gulls in the news page.

Expect way more of course, like the actual 10lines basic contest.

Thanks for your work.

If there is a new version, can you announce it here please (even if I follow your repository, thanks).

Happy new year !
____________
Amstrad news site at Genesis8 Amstrad Page

Powered by SMFPacks Menu Editor Mod