Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
projects:ehbasic [2018/02/20 01:00]
M.G. [What is Done]
projects:ehbasic [2018/08/03 13:56] (current)
M.G. [Moire]
Line 61: Line 61:
     * ''​B2P$(<​string>​[,<​lshift>​[,<​or>​])''​ - converts a BASIC string to a Pascal string embedded within a BASIC string. ​ The value used for the length byte is the length of the source string, left-shifted by <​lshift>​ bits, and ORed with <or>.     * ''​B2P$(<​string>​[,<​lshift>​[,<​or>​])''​ - converts a BASIC string to a Pascal string embedded within a BASIC string. ​ The value used for the length byte is the length of the source string, left-shifted by <​lshift>​ bits, and ORed with <or>.
   * ProDOS errors are trapped, appropriate messages displayed for the most common of them, and an attempt to close all open files is made (this will change when error handling is introduced).   * ProDOS errors are trapped, appropriate messages displayed for the most common of them, and an attempt to close all open files is made (this will change when error handling is introduced).
 +
 +=== Pascal I/O Support ===
 +
 +  * Loader scans slots and places pascal entry points into the global page.
 +  * ''​PR#''/''​IN#''​ work.
 +    * suffixing the slot # with a ! will force a re-init of the device (e.g. ''​PR#​3!''​).
 +  * Monitor I/O is redirected to EhBASIC'​s I/O so calling monitor routines is routed to the selected devices.
 +    * If the prompt character changes, e.g. during ''​CALL -151'',​ line feeds are added after each CR (Pascal I/O separates CR/LF functionality). ​
  
 === Text / Graphics Support === === Text / Graphics Support ===
Line 84: Line 92:
     * ''​HPLOT''​ can take a comma instead of ''​TO''​.     * ''​HPLOT''​ can take a comma instead of ''​TO''​.
   * ''​PDL()''​ and ''​BTN()''​ work for game I/O.   * ''​PDL()''​ and ''​BTN()''​ work for game I/O.
-  * ''​ERRNO(n)''​ function where n=0 for line number of error, n=1 for BASIC error #, n=2 for Pascal I/O error #, n=for ProDOS error #.  Fairly useless for now without error trapping.+  * ''​ERRNO(n)''​ function where n=0 for line number of error, n=1 for BASIC error #, n=2 for Pascal I/O error #, n=for ProDOS error #.
   * ''​GLOBAL(n)''​ returns the Nth address of the EhBASIC global page.   * ''​GLOBAL(n)''​ returns the Nth address of the EhBASIC global page.
  
Line 91: Line 99:
   * ''​BEEP [<​pitch>,<​duration>​]''​ beeps the speaker. ​ If the args are omitted, it produces the system bell.   * ''​BEEP [<​pitch>,<​duration>​]''​ beeps the speaker. ​ If the args are omitted, it produces the system bell.
   * ''​TRY''​ statement:   * ''​TRY''​ statement:
-    * ''​TRY <​statement>​ [THEN <​success-statement> [ELSE <fail-statement>]]''​ +    * ''​TRY <​statement>​ [THEN <​success-clause>[ELSE <fail-clause>​]''​ 
-    * ''​ERRNO(n)''​ is populated (note that right now, ''​ERRNO(1)''​=0 does not mean success, this will change).+    * ''​ERRNO(1)''​ is populated ​per the below table. 
 +      * If ERRNO(1) is nonzeroERRNO(0) is valid. 
 +      * If ERRNO(1) is 25, ERRNO(3) is valid. 
 +    * ''​TRY''​ ... ''​THEN''​ sometimes doesn'​t work well with ''​PRINT'',​ ''​INPUT'',​ and statements that don't evaluate expression arguments because they do not expect to be followed by ''​THEN''​ 
 +      * E.g. ''​TRY PRINT "​FOO"​ THEN PRINT "​BAZ"​ ELSE PRINT "​BAR"''​ will print "''​FOOBAR''"​ and ''​ERRNO(1)''​ will reflect a syntax error. 
 +      * For these cases, you can use ''​TRY''​ ... ''​ELSE'',​ ''​TRY''​ with no clauses, or wrap in a subroutine (e.g. ''​TRY GOSUB 1000 THEN''​ ...). 
 +    * Be careful nesting ''​IF''​ inside ''​TRY'',​ that may cause unexpected behavior, especially if there is an ELSE clause. ​ If necessary, a solution is to wrap the conditional in a subroutine. 
 +    * ''​TRY GOTO <​n>''​ doesn'​t work.  ''​TRY GOSUB <​n>''​ does. 
 + 
 +^ ''​ERRNO(1)''​ Values ^^ 
 +^   # ^ Error ^ 
 +|   0 | Success | 
 +|   1 | NEXT without FOR | 
 +|   2 | Syntax | 
 +|   3 | RETURN without GOSUB | 
 +|   4 | Out of Data | 
 +|   5 | Function Call | 
 +|   6 | Overflow | 
 +|   7 | Out of Memory | 
 +|   8 | Undefined Statement | 
 +|   9 | Array Bounds | 
 +|  10 | Double Dimensioned Array | 
 +|  11 | Divide by Zero | 
 +|  12 | Illegal Direct | 
 +|  13 | Type Mismatch | 
 +|  14 | String Too Long | 
 +|  15 | String Too Complex | 
 +|  16 | Continue Error | 
 +|  17 | Undefined Function | 
 +|  18 | LOOP without DO | 
 +|  19 | Undefined Variable | 
 +|  20 | Undimensioned Array | 
 +|  21 | Unimplemented function | 
 +|  22 | Illegal Argument | 
 +|  23 | I/O Error | 
 +|  24 | No Device Connected | 
 +|  25 | ProDOS Error (''​ERRNO(3)''​ contains ProDOS error number) | 
 +|  26 | File Type Mismatch |
  
 === Other features === === Other features ===
  
   * Pressing the tab key when at the beginning of an empty line in immediate mode will generate an automatic line number that is 10 higher than the last one.  Note that due to the way EhBASIC flags immediate mode, it won't work right after a program ends, until something else is entered.   * Pressing the tab key when at the beginning of an empty line in immediate mode will generate an automatic line number that is 10 higher than the last one.  Note that due to the way EhBASIC flags immediate mode, it won't work right after a program ends, until something else is entered.
- 
 ==== What is Planned, but Not Done ==== ==== What is Planned, but Not Done ====
  
Line 123: Line 167:
   * Values below $20 are now additional command tokens (except $00), so the input routine rejects attempts to embed control characters via the keyboard.   * Values below $20 are now additional command tokens (except $00), so the input routine rejects attempts to embed control characters via the keyboard.
  
-==== What Will Not Be Implemented+==== What Will Not Be Implemented ​====
  
   * ''​ON ERROR GOTO''​ and ''​RESUME''​   * ''​ON ERROR GOTO''​ and ''​RESUME''​
Line 136: Line 180:
 Files: Files:
  
-ca. 02/19/2018 22:00 PST+ca. 02/12/2018 12:00 PST
  
-  * MouseText fixed for 80-column catalog+  * Bug fixes in detokenization
-  * Adding an ! after ''​PR#<​s>​''​/''​IN#<​s>​'' ​(i.e. ''​PR#3!'' ​forces re-init of the Pascal firmware on the card. +  * Bug fixes in ''​TRY''​
-  * TRY/​THEN/​ELSE error trapping.+  * ''​TRY''​...''​ELSE'' ​now supported.
  
 {{ :​projects:​ehbasic.po.gz |Gzip-compressed .po file}} //Derived from EhBASIC.// {{ :​projects:​ehbasic.po.gz |Gzip-compressed .po file}} //Derived from EhBASIC.//
Line 153: Line 197:
  
 <​code>​ <​code>​
-10 a$=" "​+" ​ ":REM the + is so EhBASIC won't store the string in program space+10 a$=""​+" ​  ​":REM the + is so EhBASIC won't store the string in program space
 20 POKE SADD(a$),​1:​REM otherwise these pokes do bad things 20 POKE SADD(a$),​1:​REM otherwise these pokes do bad things
 30 DOKE SADD(a$)+1,​$300:​REM we'll use $300 as a buffer 30 DOKE SADD(a$)+1,​$300:​REM we'll use $300 as a buffer
Line 163: Line 207:
  
 <​code>​ <​code>​
-10 a$=" "​+" ​  ​"+10 a$=""​+" ​   "
 20 POKE SADD(a$),​2:​REM 2 params 20 POKE SADD(a$),​2:​REM 2 params
 30 POKE SADD(a$)+1,​$60:​REM unit # 30 POKE SADD(a$)+1,​$60:​REM unit #
Line 171: Line 215:
 70 PRINT "​Volume in slot 6, drive 1 is ";v$ 70 PRINT "​Volume in slot 6, drive 1 is ";v$
 </​code>​ </​code>​
 +
 +==== Woz Signature ====
 +
 +<​code>​
 +10 HGR:​HCOLOR=3:​READ A,B:FOR I=1 TO 9:READ X,Y:HPLOT A,B TO X,​Y:​A=X:​B=Y:​NEXT I
 +15 READ A,B:FOR I=1 TO 16:READ X,Y:HPLOT A,B TO X,​Y:​A=X:​B=Y:​NEXT I
 +20 DATA 75,​50,​69,​57,​76,​62,​71,​88,​53,​118,​87,​71,​130,​31,​76,​111,​116,​66,​143,​44,​132,​82,​
 +123,​83,​108,​95,​104,​104,​112,​107,​130,​94,​133,​80,​154
 +25 DATA 73,​146,​89,​158,​88,​162,​94,​139,​141,​122,​160,​119,​156,​139,​126,​194,​85,​232,​64
 +</​code>​
 +
 +[[https://​www.youtube.com/​watch?​v=tp4gIoTgF-E|Credit]].
 +
 +==== Lo-res Heart ====
 +
 +I forgot where I found this.  If I find out, I will credit it here.
 +
 +<​code>​
 +1 GR:​COLOR=1:​O=5:​P=35:​Y=2:​FOR I=1 TO 4:READ X,Z:HLIN X+O,Z+O AT Y:HLIN P-Z,P-X AT Y:​Y=Y+1:​NEXT I
 +2 FOR I=1 TO 30:READ X:HLIN X+O,P-X AT Y:​Y=Y+1:​NEXT I:​COLOR=15:​HLIN 9,12 AT 5:VLIN 4,7 AT 10:HLIN 24,26 AT 5:VLIN 4,6 AT 25
 +32 DATA 5,​11,​4,​12,​3,​13,​2,​13,​2,​1,​1,​1,​1,​0,​0,​0,​0,​1,​1,​1,​1,​2,​2,​2,​3,​4,​5,​5,​6,​6,​7,​8,​9,​10,​11,​12,​13,​14,​15,​16,​17,​18
 +</​code>​
 +
 +==== Hi-res Sine Wave ====
 +
 +Don't remember where this one came from, either.
 +
 +<​code>​
 +10 HGR:​HCOLOR=3:​LX=0:​LY=80:​FOR I=0 TO 279:​A=SIN(I/​8)*70+80:​PRINT I,A:HPLOT I,A TO LX,​LY:​LX=I:​LY=A:​NEXT
 +</​code>​
 +
 +==== Moire ====
 +
 +My own variant of Brian'​s Theme.
 +
 +<​code>​
 +100 GET a:HGR0
 +105 oc=c
 +110 X=INT(RND(0)*280):​Y=INT(RND(0)*192)
 +115 c=INT(RND(0)*7)+1
 +120 IF c=oc THEN 110
 +125 HCOLOR=c
 +130 s=INT(RND(0)*4)+3
 +140 FOR i=0 TO 279 STEP s:HPLOT i,0 TO X,Y TO 279-i,191
 +145 NEXT
 +150 FOR i=0 TO 191 STEP s:HPLOT 0,191-i TO X,Y TO 279,i
 +155 NEXT
 +170 GET a
 +180 IF a=0 THEN GOTO 105
 +190 TEXT:HOME
 +</​code>​
 +