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 15:20]
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 92: Line 100:
   * ''​TRY''​ statement:   * ''​TRY''​ statement:
     * ''​TRY <​statement>​ [THEN <​success-clause>​] [ELSE <​fail-clause>​]''​     * ''​TRY <​statement>​ [THEN <​success-clause>​] [ELSE <​fail-clause>​]''​
-    * ''​ERRNO(n)''​ is populated. +    * ''​ERRNO(1)''​ is populated ​per the below table. 
-    * ''​TRY''​ ... ''​THEN''​/''​ELSE'' ​doesn'​t work well with ''​PRINT'',​ ''​INPUT'',​ and statements that don't evaluate expression arguments. ​ For those, use a ''​TRY'' ​without the conditional clause ​and check ''​ERRNO(1)'',​ or wrap in a subroutine (e.g. ''​TRY GOSUB 1000 ELSE ...''​).+      * If ERRNO(1) is nonzero, ERRNO(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 ^^ ^ ''​ERRNO(1)''​ Values ^^
Line 128: Line 142:
  
   * 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 184: 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 194: 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 202: 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>​
 +