pweingar / basic816 Goto Github PK
View Code? Open in Web Editor NEWA BASIC interpreter for the 65C816 processor, targetting the C256 Foenix computer.
License: GNU General Public License v3.0
A BASIC interpreter for the 65C816 processor, targetting the C256 Foenix computer.
License: GNU General Public License v3.0
Version:
KERNEL: v0.4.0-alpha+333 (2021-08-07)
BASIC VERSION: BASIC816 v0.2.0-alpha+411
HARDWARE: Foenix U
Description:
When you try to assign multiple values to an array of String in BASIC the program crashes and takes you to the MONITOR prompt (PROGRAM COUNTER: 1A67B5)
You can use the following code to demonstrate the issue:
Code:
5 DIM N$(10)
10 FOR C%=1 TO 10
20 READ M$
30 N$(C%)=M$
40 NEXT
50 END
1000 DATA "C","C#","D","D#","E","F","F#","G","G#","A","A#","B"
The GET and INPUT statements ignore Ctrl-C when paused for input. They should accept Ctrl-C, interrupt the prompt, and halt the program if running, or return to the prompt having taken no effect on the variable in immediate mode.
(Alt-SysRq does work in these input modes, so there's a workaround.)
Version: Basic816 v0.2.0-alpha+254
Description: you can activate with basic commands one sprite, but when trying to activate a second one the commands seem to be applied to sprite 1 regardless of the number parameter used on the sprite command.
The provided code should show two sprites on screen but when configuring the second sprite the first one disappears and shows only the second one.
After running the program if you execute a SPRITEAT 1,100,100 it moves the recently configured 2nd sprite, this further proves that commands are being applied to sprite 1
Code:
10 CLS
20 GRAPHICS 47
30 spb%=&hb00000: REM sprite base pointer
40 FOR c%=0 to 1024:POKE sbc%+c%,1:NEXT
50 SPRITE 1,0,spb%
60 SPRITEAT 1,100,100
70 SPRITESHOW 1,1
80 PRINT "Press a key to show sprite 2"
90 GET k$:IF k$="" THEN 90
100 SPRITE 2,0,spb%
100 SPRITEAT 2,150,100
120 SPRITESHOW 2,1
The save command refuses to overwrite a file of the same name. I appreciate this design, but I'm wondering whether I'd prefer an iterative workflow that would let me save in place. Moreover, it would be convenient if I didn't have to remember my filename just to checkpoint save my program.
Would there be interest in having BASIC816 remember the most recent load/save filename, and a "resave" command that takes no arguments and overwrites the file with that name? I welcome counterarguments based on ergonomics, I don't know if this is the best or safest solution. One could argue that non-destructive dir, del, and save "filename" are sufficient for avoiding accidental overwrites. One could also argue that load "filename" shouldn't be enough to enable resave, and maybe an explicit save more recent than load should be required.
Hardware: Foenix U
Kernel Version: v0.4.0-alpha+329
Basic Version: v0.2.0-alpha+408
Issue Description: When including a DATA statement in a BASIC program it won't execute and fail with a syntax error
You can replicate the behavior with the following code:
10 FOR c%=1 to 10
20 READ a%
30 PRINT a%
40 NEXT
50 DATA 10,20,30,40,50,11,22,33,44,55
This code fails and produces the following error
Syntax error at 50
In the PDF of the BASIC816 manual, some text intended for describing the LINE statement appears under the MONITOR statement.
https://github.com/pweingar/BASIC816/blob/master/docs/tex/basic816.tex#L524
MONITOR
Enter the machine language monitor.
<plane> is the number of the bitmap plane (0 or 1).
...
Shell scripting on Linux/MacOS support the variable $?
to get the exit/error code of the last process, and DOS/Windows used %ERRORLEVEL%
.
I would like a mechanism to return an exit code from a program launched with BRUN, and to be able to read it from BASIC for scripting purposes.
For example:
10 BRUN "dosometask.prg"
20 IF ERR > 0 THEN GOSUB 50
I propose having the called program place a 16bit value in the A or X register and return to BASIC with a RTL.
See GW-BASIC ERR/ERL for ideas: https://hwiegman.home.xs4all.nl/gw-man/ERRERL.html
See GW-BASIC ON ERROR for ideas: https://hwiegman.home.xs4all.nl/gw-man/ONERROR.html
The not equal <> operator doesn't seem to work in an IF..THEN statement
For example:
140 i=3
141 n=2
145 if (i<>n) then 200
150 end
200 print "not equal"
Background:
If you have it set the DIP switches to boot from a drive, the system will try to load the boot record. If the boot record is executable, it will try to run it. If the boot record isn't executable or the DIP switches are set to BASIC, it will just run BASIC.
Proposal:
The interpreter should check the DIP switches on startup. If the DIP switch is set to boot from drive, then should try to run a startup BASIC file from that drive.
you can try it in immediate mode
input x
? -30
Print x
0
The "del" command (for deleting a file) does not appear in the BASIC816 manual.
Requesting a way to pass parameter data to an executable using BRUN.
BRUN "editor.pgx option1 option2 filename"
or
BRUN "editor.pgx", "option1 option2 filename"
Some proposed solutions by @pweingar on Discord order by complexity:
I prefer option (1), since it lets me populate argv[0] in C.
Support for floating point numbers, operations, functions, and variables needs to be completed.
Statements and functions to support general purpose file I/O need to be implemented, for example:
Comparison when the integer is a negative number results in a Syntax Error
Version:
BASIC816 v0.2.0-alpha+274
Description:
Using Dim command either with an integer variable or a string variable always results in a type mismatch error
Can be reproduced with the Code provided, changing the variable type to x$ on line 10 produces the same type mismatch error
Code:
10 DIM x%(20)
20 for c%=1 to 20:x%(c%)=c%:NEXT
File I/O errors give no indication of the actual fault. Error messages should be more descriptive.
Version:
BASIC816 v0.2.0-alpha+274
Description:
When you peek at a memory address (at least in the graphics area memory &hb0000) the memory position at the location+4 that you peek is zeroed.
For a graphical demo of this behavior the provided code shows sprite 1 on screen and then proceeds to poke 1s to create a solid sprite. Just after this the code peeks at all its values.
You'll see the sprite appear and dissapear magically!
Code:
5 CLS
10 GRAPHICS 47
20 spb%=&hb00000: REM sprite block constant
30 SPRITE 1,0,spb%
40 SPRITEAT 1,100,100
50 SPRITESHOW 1,1
60 FOR c%=0 to 1024:POKE spb%+c%,1:NEXT
70 FOR c%=0 to 1024:a%=PEEK(spb%+c%):NEXT
When I ran this program on my Foenix Rev 3C, it counted from 1 to 430. However instead of 431 coming after 430, it went to 175, then counted back to 430. So it goes 1 -> 430 -> 175 -> 430 -> 175 -> 430. etc. etc.
5 a=1
10 a=a+1
20 print a
30 goto 10
If a negative sign is provided as the input parameter of a function, it crashes the interpreter into the monitor.
Steps to reproduce:
FOR I = 5 TO 1 STEP -1 produces weird results with floats. Should probably be illegal argument.
When interrupting a program that has switched away from a text-supporting graphics mode with Ctrl-C (BASIC interrupt) or Alt+SysRq (Monitor interrupt), the current behavior leaves the graphics mode as is, hiding the BASIC/Monitor prompt and making it difficult to know if the program was successfully interrupted or how to return to a prompt. These interruption methods should change the graphics mode, or do whatever else is needed to be responsive to the interrupt and give the user a way back to a useful prompt.
Version:
KERNEL: v0.4.0-alpha+333 (2021-08-07)
BASIC VERSION: BASIC816 v0.2.0-alpha+411
HARDWARE: Foenix U
Description:
When a BASIC program reaches a size of more than 16K and is saved (on any device) the machine locks up and shows the following number (address?):
1A45E1
You can use the attached file to demonstrate the issue in the following way:
Code:
6100 rem change background color - blue component
6110 bkg%=&haf000d
6120 poke bkg%,colb%
6130 spriteat 7,sx%*4+colb%+32,sy%*44+32
6140 goto 500
SP%=65536
PRINT SP% / 2
Returns a value of 65536 no matter what value the divisor is.
docs/samples/lines.bas is using out-of-date keywords (pixmap, clrpixmap) and command arguments (line).
It'd also be good for lines.bas to use graphics mode &H0F, so that interrupting the program (Ctrl-C) can display the BASIC ready prompt or display syntax errors. As is, these cases are invisible, and a beginner would not know to type "graphics 1" blindly to get back to a prompt.
(In my case I entered the program with the out-of-date keywords, and it switched the graphics mode then terminated with the syntax error, which looked to me like an uninterruptable crash but was actually just an invisible ready prompt.)
version Tested: BASIC816 v.0.2.0-alpha+254
description: There is a new problem with strings when used in an if statement for this version
How to replicate:
10 get k$:if k$="" then goto 10
20 if k$="s" then print "YES!"
30 goto 10
if you press "s" you get a:
Syntax error at 20
Most BASICs start indexing from 1 ; e.g. MID$("ABCDE",2,2) gives "BC" whereas BASIC816 gives "CD"
Hi, I ran in to "Out of range" errors when I tried using the sprites above 17. I was thinking it would support up to sprite 31. Other Sprite commands also failed above sprite number 17 too, so maybe this is something at the system level versus Basic816.
In the reference text for the tile-related statements, there are multiple references to "tile set or tile map," as if they both refer to the same concept. These should be corrected to refer to the proper concept in each instance.
If I'm understanding correctly, a tile set is the collection of up to 256 8x8 bitmaps and an affiliated bitmap LUT, and you can have up to four file sets (0-3). A tile map is a rectangle of two-byte tile IDs (tile number and set number), a visibility status, and a rendering offset, and you can have up to four tile maps (0-3).
This is really a kernel issue, but I'm filing this under BASIC since most people will see it as a BASIC issue.
After a few saves, the SAVE command will fall through to the monitor with an address of $38:434E. The trigger appears to be that the sector for the directory becomes full, and the kernel is attempting to allocate a new cluster for the directory, but it is failing to do so and falling through to an assert-type condition.
This is the source of much discussion in the maths community as to what a^b does for non integer b's especially, but currently -2^2 is -4 not 4. Suggest where the power is even integer the result should be +ve, all others -ve ?
There is no explanation for the optional address parameter for the BITMAP statement. I assume this changes the memory location in VRAM used for the bitmap (set in $AF0101-0103).
Version:
KERNEL: v0.4.0-alpha+329 (2021-06-05)
BASIC VERSION: BASIC816 v0.2.0-alpha+408
HARDWARE: Foenix U
Description:
When you create BASIC code that uses line #5120 the program ends without executing the code on this line number.
You can use the following code to demonstrate the issue:
Code:
10 x%=0
20 GOTO 5000
5000 x%=x%+1
5100 IF x%=5 THEN 5120
5110 GOTO 5000
5120 PRINT x%
To further demostrate the issue, if you change the following lines the code works as expected
5100 IF x%=5 THEN 5130
5130 PRINT x%
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.