Shop OBEX P1 Docs P2 Docs Learn Events
PE-Basic Version 0.16 July 11, 2011 - Page 3 — Parallax Forums

PE-Basic Version 0.16 July 11, 2011

13

Comments

  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-02-18 20:25
    That sounds interesting. Kyedos can spawn other .bin programs. It can also pass a command line to the next program via a single line text file the previous program writes on the sd card. I wonder if embedded basic could check if that file exists, then run it?

    Hmm, we really need batch files here. Then you could send commands like "load a file" then "run a file".
  • SeekerSeeker Posts: 58
    edited 2011-02-18 20:36
    Dr_Acula wrote: »
    That sounds interesting. Kyedos can spawn other .bin programs. It can also pass a command line to the next program via a single line text file the previous program writes on the sd card. I wonder if embedded basic could check if that file exists, then run it?

    Hmm, we really need batch files here. Then you could send commands like "load a file" then "run a file".

    Exactly what I am trying to do. Thank you for giving me a good path to follow. ;) Once I ran KyeDOS it really hit me... This is it! Now we need batch files!

    I am still trying to learn the command.txt passing of the next file. I can get it to load first file (obviously, as this is built in to KyeDOS), but how to exit first Basic program and load it with a fresh file... that is where I am at. Now, even if command.txt holds a valid file, when I exit basic I go back to prompt (doing reboot from basic). It does not reload file in command.txt. So even if I can (read: learn how to) rewrite file on SD from basic, it exits gracefully to prompt. By design I am sure. But I like corrupting good designs. ;)
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-02-18 20:42
    Good thinking!

    I wonder if we could borrow the concept of batch files from CP/M and DOS

    Ok, you create a batch file. This is a text file and you could let it end in .BAT. eg MYFILE.BAT

    Next you need a batch file processor. CP/M had a program called SUBMIT. We could call it "BATCH"

    You type BATCH MYFILE

    That then goes and creates a temporary file on the sd card. CP/M creates MYFILE.$$$

    Then each time Kyedos either starts, or returns to the command prompt, you add a little bit of code to see if a $$$ file exists. If it does, then read in the file, store the first line, write back the file with the first line removed, then run that first line. If on the last line, then delete the $$$ file.

    How does that sound?
  • SeekerSeeker Posts: 58
    edited 2011-02-18 20:57
    Perfect! And I am glad I am not the only one old enough to appreciate CP/M. Ahhhhhh, the memories.

    I still have an Apple II+ with a MS CP/M card... and it works!
  • SeekerSeeker Posts: 58
    edited 2011-02-18 21:12
    And as an added plus.... make the next file conditional. Files load in order by default... but can jump to file 7 from file 3 if needed. Of course then the original batch file would have to remain complete, in case you wanted to go back to file 5 next. Maybe a second file... load.txt that contains the number (name) of next file to load. Who knows, might even want to reload same file again (now or later) in some cases, so we would not want to alter the original batch.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-02-18 21:15
    Ok, so two parts:
    1) BATCH.BIN. If you have the kyedos source you will have the source for TYPE which is a generic prototype for a new program with all the building blocks ready to go, eg disk access, display driver. This would be a very simple program. All it actually does is copies MYFILE.BAT to MYFILE.$$$. So at the kyedos prompt you type
    BATCH MYFILE
    which saves the entire line "BATCH MYFILE" in COMMAND.TXT, and then runs BATCH.EXE, which can then read back COMMAND.TXT and hence get the string "MYFILE"

    2) Modifications to Kyedos. I guess it would be a new PUB just before the command prompt?

    BTW you know we have CP/M running on the propeller? And MP/M too.
  • SeekerSeeker Posts: 58
    edited 2011-02-18 21:58
    Dr_Acula wrote: »
    Ok, so two parts:
    1) BATCH.BIN. If you have the kyedos source you will have the source for TYPE which is a generic prototype for a new program with all the building blocks ready to go, eg disk access, display driver. This would be a very simple program. All it actually does is copies MYFILE.BAT to MYFILE.$$$. So at the kyedos prompt you type
    BATCH MYFILE
    which saves the entire line "BATCH MYFILE" in COMMAND.TXT, and then runs BATCH.EXE, which can then read back COMMAND.TXT and hence get the string "MYFILE"

    2) Modifications to Kyedos. I guess it would be a new PUB just before the command prompt?

    BTW you know we have CP/M running on the propeller? And MP/M too.

    Okay... now I need to look closer at 'Type'. I wasn't sure what it could do (and why I downloaded it), I was too wrapped up in the excitement of SD access and a DOS prompt to play with it yet.

    And just an odd thought I can't seem to shake... is it better to wrap KyeDOS around Basic's needs (or any language for that matter)... or Basic around a KyeDOS shell? I know, that sounds obtuse. But it makes sense to me. Of course one of them means a lot more work for Bean. ;)

    And I thought by your Avatar CP/M was an Aussie term for Propellor. I stand corrected. (Sorry, couldn't resist)

    Okay... I admit, I knew it was there (I read a lot here). But I haven't played with it yet. I guess the time is coming soon. It would be a good way of sorting out needs over just interesting questions. It is amazing what can be done with such a simple, but powerful processor. I have been hung up on the memory model... once that is solved, we will have it running Windows CE.... then with the Prop 2 we can move up to XP and Windows 7. ;) (Skip Vista... please)
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-02-19 05:25
    "TYPE" is just an example program of how you can take a simple operating system and add more commands by adding new binary programs on an sd card (rather than by adding more code to the OS). Kyedos fills most of the propeller memory anyway so you have to think about other solutions.

    Probably easiest to modify kyedos rather than asking Bean to code more. Unless something is impossible.

    My avatar is a photo of CP/M running on the propeller, with some ASCII art created from a screen grab of the propeller picture, which originally came from a photo of a propeller chip. There was a bit of image enhancement and scaling done along the way. It was displayed by typing "TYPE PROPART.TXT" from within the CP/M emulation on the propeller.

    We have better graphics now. Even movies in color!

    If you want to write a batch file processor, I think all the building blocks are in Kyedos. eg, open a file, read lines of text, process them, close the file.

    I need to check out Embedded Basic.

    I see you are already thinking of conditional lines in batch files. That starts to become a programming language in its own right. It could get quite powerful, because each of the things you run can be entire self contained spin programs, that can do things like modify text files that following spin programs can also read and write.

    I guess that leads to some generic Batch instructions. Print a message. Get a keypress, or line of text. Compare with other lines of text. Run one program if a match. That could be half the Basic keywords if you wanted.

    All quite intriguing.
  • Jim FouchJim Fouch Posts: 395
    edited 2011-03-07 12:59
    It's very interesting to see this ran the 1 to 10,000 loop in ~0.3 Seconds. I used to do this same test on older computers and my Atari 800XL did it in ~ 20 seconds. That machine had a 1.79 MHz processor and was only 8 bits.

    My current laptop does it in ~52 micro seconds using VB .Net 2010. Then again its a 3.6GHz 6 core i7 980x with 12 GB of ram. lol

    I tried to bring all cores into play and it actually slows down the code. There is an overhead price you pay. It's doesn't payoff until you have a lot of caculations to do. It is very cool when you bring all six cores into play and see the processor really work. :-)
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-03-09 05:32
    How does color work?
    Can someone give a small program example to set bcolor and fcolor?
    I'm running the version from page 1 post 1 but no color.

    I'm updating the manual. Example code is needed.
    A list of colors and their values would be helpful.

    Thank you sincerely.
  • BeanBean Posts: 8,129
    edited 2011-03-09 06:00
    Humanoido,
    Sorry I haven't kept this thread up to date.
    I have just now updated the program in the first post.
    bcolor and fcolor are just "BCOLOR value" and "FCOLOR value". value can be 0 to 15 for the different colors.

    Bean
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-03-09 08:19
    Bean wrote: »
    Humanoido, Sorry I haven't kept this thread up to date. I have just now updated the program in the first post.
    bcolor and fcolor are just "BCOLOR value" and "FCOLOR value". value can be 0 to 15 for the different colors. Bean
    Thanks Bean, the colors are working perfect! But... please do not replace the other post version! The color version font is too small, it is impossible to read on small monitors because the tiny font blurs together. It also has a good case of the shakes and shivers. It looks like I must give up the color version.
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-03-09 08:26
    Actually, if you know how to make the font bigger, let me know how to modify it.

    *** COMPILED WITH PropBasic VERSION 00.01.02 Jul 20, 2010 ***
  • BeanBean Posts: 8,129
    edited 2011-03-09 09:32
    Humanoido,
    Actually there is a version 0.13, but I can't test it until I get home, so I don't want to post untested code.
    Version 0.13 can be compiled for 32 columns (still 25 rows) if that will help you.
    Here are the other changes in version 0.13 (for the help file)...

    ' Version 0.13
    ' Changed POKEB and PEEKB to POKE and PEEK
    ' Added FREE function (free memory)
    ' Added SCREEN function (screen address NTSC ONLY)
    ' Fixed autostart keyboard
    ' Fixed REM and ' tokenizing text

    I have attached the binary for 32 columns if you want to try it (untested).

    Bean
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-03-09 09:56
    Bean wrote: »
    Humanoido, Actually there is a version 0.13, but I can't test it until I get home, so I don't want to post untested code. Version 0.13 can be compiled for 32 columns (still 25 rows) if that will help you. Here are the other changes in version 0.13 (for the help file)...
    ' Version 0.13
    ' Changed POKEB and PEEKB to POKE and PEEK
    ' Added FREE function (free memory)
    ' Added SCREEN function (screen address NTSC ONLY)
    ' Fixed autostart keyboard
    ' Fixed REM and ' tokenizing text
    I have attached the binary for 32 columns if you want to try it (untested). Bean
    Bean, I like the binary. Binaries load ok with the Propeller Tool Software, right? Thanks very much. The fonts are a tiny amount bigger and it's enough to just see most characters. A zero and eight look the same but for the most part, it's workable. Let hope the font can be increased to a larger size in a future version. You're right, it's very beta (mentioned commands do not work like FREE etc.) and needs testing but thanks for this excellent preview. I'm really stoked about the way this remarkable little language is unfolding.
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-03-09 13:23
    I made a version of EmbeddedBasic for SpinSim. The source, binary and a copy of SpinSim.exe are included in the attached ZIP file. This allows EmbeddedBasic to run in a DOS window under Windows. The LOAD and SAVE commands don't work since there is no EEPROM.

    BTW, it looks like there is a problem with xPos, yPos and color not being defined if NTSC is not defined.

    Dave
  • BeanBean Posts: 8,129
    edited 2011-03-09 13:49
    Dave,
    Oh, that is cool. I'll keep that option in future versions.
    I can't wait to try it out.

    P.S. Any reason why you made the SpinSimKeyboard task LMM ?

    Bean
  • BeanBean Posts: 8,129
    edited 2011-03-09 13:55
    Dave,
    It worked right off.
    As for timing: 10,000 FOR...NEXT loops took 2,886 milliseconds on my computer. I assume the speed is computer dependent ?

    Also it only shows uppercase. Is that by design ? When I press caps-lock, I get a colon ":".

    Bean
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-03-09 14:18
    I used LMM for the SpinSimKeyboard task to slow it down. SpinSim uses a lock to make the system I/O functions cog-safe. I was concerned that a pure PASM keyboard task would lock out the character transmit routine. I should just add a delay loop or waitcnt instead. I copied the code from the SerialKeyboard task, where I had commented out the SERIN command. I uncommented all of the lines without realizing that the case translation was intentially commented out. That can be removed from the SpinSimKeyboard task.

    I've never noticed that about the caps-lock before. I use the kbhit() routine, and it must be returning true when the caps-lock is pressed. I'll have to look into that further.

    SpinSim's speed depends on the speed of the host computer. It actually runs Spin programs faster than PASM programs, but it works fine for both as long as speed is not an issue.
  • BeanBean Posts: 8,129
    edited 2011-03-11 08:09
    Dave,
    I have merged your additions to the working version of Embedded Basic. All future version will have support for SpinSim.
    It was easy to remove the code that converts chars to uppercase.

    Is there anyway to do the "LOCATE x,y" function ? How about text colors FCOLOR, BCOLOR, COLOR ?

    Bean
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-03-11 08:28
    Bean,

    I would really like to do X,Y addressing and colors in a DOS window, but it seems like this is yet another function that Microsoft has removed. Earlier versions of Windows allowed using an ANSI.SYS file to support the use of the ANSI terminal escape sequence. However, I have been unable to get this to work unders Windows XP, Vista or 7. If anybody knows how to do this please let me know.

    Linux command windows do support the ANSI terminal commands, so it would be possible to do this under linux.

    BTW, I tried to add file I/O support to the SpinSim version of EmbeddedBasic so that programs could be saved and loaded from progn.bas files. I encountered an error that said that __ELSE_243 was unresolved. Is there a limit on the number of labels that can be generated? It looks like the PropBasic compiler did not generate the __ELSE_243 label.

    Dave
  • BeanBean Posts: 8,129
    edited 2011-03-11 08:32
    Dave,
    Yes, there is a limit. I have sent new files to BradC for him to compile, but I haven't heard anything back for quite a while.
    I'll try to contact him again.

    I ran into the issue when doing a bunch of ELSEIFs that were strung together.

    Bean
  • BeanBean Posts: 8,129
    edited 2011-03-11 19:30
    I have decided to change the name to PEBasic (Propeller Embedded BASIC).

    I have uploaded version 0.14 to the first post.

    The zip file contains the source code, documentation, and binary files for NTSC (demo board), Spinneret, SpinSim and PST.

    Here is a program to try out:
    1 REM Kaleidoscope Display NTSC ONLY
    10 CLS:PlotXY=1000
    20 FOR a=0 TO 128*25-1 STEP 2:POKEW SCREEN+a,3:NEXT a
    99 '
    100 x=RND 31:y=RND 25:col=RND 15
    110 GOSUB PlotXY
    120 x=63-x:GOSUB PlotXY
    130 y=49-y:GOSUB PlotXY
    140 x=63-x:GOSUB PlotXY
    150 GOTO 100
    999 '
    1000 REM PlotXY x,y,col
    1010 adr=SCREEN+(y SHR 1) SHL 7 + x SHL 1 + 1
    1020 IF y & 1 = 1 THEN POKE adr,PEEK adr & 240 | col
    1030 IF y & 1 = 0 THEN POKE adr,PEEK adr & 15 | (col SHL 4)
    1040 RETURN
    

    Hmm, it's starting to look like "real" BASIC...

    Bean
  • BeanBean Posts: 8,129
    edited 2011-03-12 05:31
    Oops, I forgot to put the support objects in the zip file.
    They are in there now.

    Sorry about that.

    Bean
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-03-12 07:37
    Wow, Bean, the PST version is unbelievably fast at 115,200 Baud! I ran my usual benchmark program, the screen flashed, and I was shocked to see numbers in the 100,000 + range in a few seconds. It appears to give a full screen of numbers every second. It just pops on the screen. The PST is big and clear. Is there a way to send this serial information to the TV in giant characters or have a PST in the TV?

    10 n=0
    20 n=n+1
    40 PRINT n;" ";
    50 GOTO 20

    Also what is the syntax on the peek command? I tried peek x but that didn't work.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2011-03-12 08:04
    Just guessing but ..

    Peek is a function, so it has to be peek(x)
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-03-12 08:45
    Try "print peek x" to print the contains of location x, or "a = peek x" to store it in a.
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-03-12 13:01
    Dave Hein wrote: »
    Try "print peek x" to print the contains of location x, or "a = peek x" to store it in a.
    Toby, thank you. The syntax worked perfect. Here's the result.
    10 n = o
    20 n = n + 1
    30 PRINT PEEK (n);" ";
    40 GOTO 20
    OK
    run
    180 196 4 111 204 16 0 248 84 0 85 53 84 4 85 72 84 2 1 37 84 0
    0 72 84 0 0 38 236 191 160 39 232 191 160 14 0 124 92 16 0 0 0 0
     172 252 160 81 236 191 104 81 232 191 104 100 180 252 160 74 17
    8 188 160 241 179 188 128 74 178 188 248 14 180 252 228 40 0 0 0
     37 200 252 160 240 201 188 128 100 202 188 160 101 178 188 160
    89 212 188 0 1 178 252 128 89 214 188 0 1 178 252 128 89 216 188
     0 107 212 188 104 2 202 252 208 108 202 188 208 0 212 124 195 1
    4 0 84 92 64 0 0 0 100 178 188 160 89 212 188 0 1 178 252 128 89
     214 188 0 1 178 252 128 89 216 188 0 1 178 252 128 89 218 188 0
     140 218 124 195 14 0 84 92 172 0 0 0 0 196 252 160 17 0 124 92
    224 48 0 0 200 23 0 0 13 188 252 160 17 0 124 92 132 51 0 0 76 5
    1 0 0 64 188 188 160 240 189 188 128 17 0 124 92 184 51 0 0 136
    51 0 0 13 188 252 160 17 0 124 92 132 51 0 0 76 51 0 0 65 188 18
    8 160 240 189 188 128 17 0 124 92 184 51 0 0 136 51 0 0 13 188 2
    52 160 17 0 124 92 132 51 0 0 76 51 0 0 14 0 124 92 64 1 0 0 66
    188 188 160 240 189 188 128 17 0 124 92 184 51 0 0 136 51 0 0 10
    5 188 188 160 17 0 124 92 156 52 0 0 188 51 0 0 13 188 252 160 1
    7 0 124 92 132 51 0 0 76 51 0 0 49 204 188 160 240 205 188 128 5
    0 178 188 160 240 179 188 128 0 180 252 160 89 180 60 0 67 188 1
    88 160 240 189 188 128 17 0 124 92 184 51 0 0 136 51 0 0 13 188
    252 160 17 0 124 92 132 51 0 0
    
  • BeanBean Posts: 8,129
    edited 2011-07-11 06:57
    I have been doing quite a bit of work on PE-Basic and I have uploaded the latest version.

    Be sure to check out the pdf document.

    I've included several binary files for different configurations: NTSC, Serial (PST), etc. So you don't need to worry about compiling the PropBasic source if you don't want to.

    Any questions or comments are welcomed.

    Thanks, Bean
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-07-14 06:16
    Bean: Thanks for this update! What is the speed of this version and how does it compare to the speed of Femtobasic?
Sign In or Register to comment.