Shop OBEX P1 Docs P2 Docs Learn Events
FemtoBasic for Hydra — Parallax Forums

FemtoBasic for Hydra

Mike GreenMike Green Posts: 23,101
edited 2008-03-09 03:34 in Propeller 1
Brian asked that I post this on the Hydra forum as well. The source will compile for either the Demo Board or the Hydra with a change in one constant near the beginning. I've included both binaries in the archive for convenience. Any future changes I'll just post in the main Propeller forum rather than always doing duplicate posts.
Mike

Comments

  • Brian_BBrian_B Posts: 842
    edited 2007-02-04 06:26
    Thank you Mike.
  • KeeblerKeebler Posts: 58
    edited 2007-02-04 19:20
    Nice job Mike!

    I was able to write some minimal programs without even reading the RTF [noparse]:)[/noparse]

    One question though, is there a way to delete a single line? For example, I was playing around and typed 8888 / (meaningless) and I couldn't get rid of it without starting over.

    I would recommend that you find a single upload location and keep the current version there. Maybe SourceForge?
    It can get a little hard to keep up with all the changes when you're attaching new versions throughout the thread. Just a thought.

    Thanks for the update,
    Rich
  • AndreLAndreL Posts: 1,004
    edited 2007-02-16 02:09
    Even if you type 8888 enter?
    If not, that sounds like a bug [noparse]:)[/noparse]

    Andre'
  • fred2fred2 Posts: 47
    edited 2007-02-16 13:28
    The Basic looks great! Any chance for a PEEK and POKE implementation?

    Fred2
  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-16 14:35
    Fred2,
    There's already a PEEK/POKE like operation, but based on Spin and allowing for the different size items (byte, word, long word). They're BYTE, WORD, and LONG and are always followed by an address in square brackets like "BYTE[noparse][[/noparse]x]". These can occur in expressions for a PEEK function or can occur on the left side of "=" for a POKE function.
  • fred2fred2 Posts: 47
    edited 2007-02-16 18:17
    Thanks, Mike!

    One of my fascinations with Basic was being able to do PEEKS and POKES.
    This will open all kinds of fun things...

    Fred2
  • AndreLAndreL Posts: 1,004
    edited 2007-02-17 05:16
    One thing I used to like to do with the Atari 800 is create a controlled "virus", I would set up a tile graphics mode and then scroll thru memory and "watch" data move around, algorithms run, etc. since I could see memory, then when you pressed the fire button, I could fire a "data bomb" and it would start at the current address where a sprite cursor was and move up one screen width of data a cycle, so you would see the missile file of "data" and then it would kill things and they would stop. Many times the system would crash immediately or shortly after, but it was like exploring another world...

    Andre'
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2007-02-17 05:57
    AndreL,

    "...One thing I used to like to do with the Atari 800 is create a controlled "virus", I would set up a tile graphics mode and then scroll thru memory and "watch" data move around..." Sounds like a hacking method
    I have used on the PC. Actually, when Windows 95 came along that's the same method I used to find out where the COM ports had been re-mapped to. Understanding, the mapping offset allowed an EXE or COM
    program to “test” this condition and determine if you were running in DOS or Windows mode. Visualizing "Live" Memory is an excellent debugging tool that can be used toward many other applications.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • AndreLAndreL Posts: 1,004
    edited 2007-02-17 09:17
    Yup, a lot of programmers program blind and literally program by trial and error which is so bad. All I need to do is "see" what I am doing and you can fix problems very quickly.

    Andre'
  • fred2fred2 Posts: 47
    edited 2007-02-23 00:50
    I have· had good success with FemtoBasic -- the source code is the best tutorial I have seen

    to learn SPIN.· I am having trouble· with assigning ASCII characters to variables, whenever I

    enter something like c="X", I get a "Missing closing quote" error.· I tried ending the quote with

    a number of ", but I still get the error.· Is there any workaround to get ASCII characters into

    variables?

    I am having a lot of fun with FemtoBasic, it is a great application!!!



    Fred2
  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-23 01:05
    fred2,
    I often use quoted character values in my FemtoBasic programs and don't get an error. Could you post the rest of the code that's giving the error? What version does FemtoBasic display when it starts up? There was an earlier version that had some problems with quoted strings. The one posted here is 1.043.
    Mike
  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-23 03:58
    I'm posting a new version of FemtoBasic to the Propeller forum. It has the ability to load Spin programs from an SD card. I did check and it seems to handle quoted character constants properly.
  • fred2fred2 Posts: 47
    edited 2007-02-23 10:51
    The version displayed is 1.043.

    I have reloaded a fresh copy and I do not get the "missing closing quote" error. I can enter c="A" and
    it accepts with "OK". Then if I type "print c" I get "65". I tried c$="A" and I get "Syntax Error".
    If it is printing the ASCII value, shouldn't it be 61 instead of 65?

    Otherwise the Basic is great! I am fooling around with writing a memory dump.

    I will rustle through my files and get my copy of DDJ with the Tiny Basic article and review the specs.

    And I will download the newer posting.

    fred2
  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-23 15:35
    Fred2,
    There are no string variables in FemtoBasic (with "$" after the name), only the 26 letters which are 32-bit integer variables. You're getting the syntax error because of the "$".

    The value of "A" is indeed 65. "@" is 64 and the uppercase letters start next.

    This version includes a memory dump (DUMP <address>,<length>).
    Mike
  • mahjonggmahjongg Posts: 141
    edited 2007-02-26 17:37
    Thanks Mike, FemtoBasic works great on my hydra (after I thought about setting the Hydra flag to enable, and the others to disable).

    It brings back memories of the tiny basic I used with my KIM1!

    I have just one question, and a suggestion.

    1) is there no PAL version of the tile based TV driver yet? Not that is immediately needed because I don't see how you can change the display color anyway, except maybe by using the Byte[noparse][[/noparse]x] (etc) command, or by using SPIN. But maybe the next FemtoBasic can have a color statement tongue.gif

    2) A cursor would be nice.

    Ill start studying the source code of femtobasic, maybe I can write a cursor routine.

    Mahjongg
  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-26 18:21
    1) The current FemtoBasic uses the windowed text driver for the TV (tv_wtext.spin) and the TV driver from the Propeller Tool library. If you look in the DAT section at the end of tv_wtext.spin, you'll see a table labelled tv_params. The documentation for the table is at the end of TV.spin and includes values for PAL. Modify tv_wtext.spin appropriately, recompile, and you will have a PAL version. If you look at the display control codes comments in tv_wtext.spin, you'll see a control code "Color". The DISPLAY statement in FemtoBasic allows you to send any of these control sequences to the display driver. "DISPLAY 7,5" will set the current window's color to #5 which will be used for all subsequent characters displayed in the current window. At the end of tv_wtext.spin, you can file a table called "palette" which has the default colors listed. You can changes these with the "SetColor" control code.

    2) A cursor for the TV driver is on my list. I'll be switching to the VGA tiled driver in the next release since it's compatible with the TV driver and can do tiled graphics like the TV driver and the VGA tiled driver has cursor support. I plan to add the same to the TV driver. It'll take a while. I've also got mouse support on the list ... integrated into the existing keyboard driver so it won't need another cog.

    All of this is in preparation for another release of the Propeller OS which is essentially the same I/O as used in FemtoBasic with a simple command interpreter instead of the FemtoBasic interpreter.
  • mahjonggmahjongg Posts: 141
    edited 2007-02-27 00:56
    Thanks again Mike,

    It works fine now. I can't believe I read over the tv_params table, I was looking for it and it's exactly where I expected it to be.
    FemtoBasic is just the eight program or so I tried, and in most of the other demo's I did find the tv_params table, and could change it to display PAL.

    That said, PAL works now, but the letters are much smaller than in NTSC mode, and the picture is a bit wavy and unstable. Perhaps it's a limitation in the PAL system, or maybe the parameters in TV.SPIN are not 100% OK. I tried, but It's not solvable with the tv_parameters, (I found the meaning of these in the TV.SPIN source). I took a long look at TV.SPIN to see what the problem could be, but for the moment that program is still over my head.

    The ANSII like escape codes work fine too.
    DISPLAY 7,12 gives black letters on a green background, reminiscent to the old Tandy color computer (and Dragon32 etc), but with a much nicer font.

    Regarding the cursor, ok if the cursor support will be available in the next "tiled VGA driver", then its not necessary for me to try to create one myself. I take it the cursor can be turned off when not needed (while running a program).

    Which VGA driver are you talking about, I only see three in my propeller tool library (v0.98.1), and none of them seems to also support composite video.

    What use will a mouse have for FemtoBasic? Will you only be able to read x,y offsets and key codes? Without any graphics support I don't see the use for it at the moment. Except maybe to highlight text.

    What do you mean by the Propeller OS, do you mean you are going to build FemtoBasic on top of a small OS you will write, or does a Propeller OS already exist.

    Sorry that your answers only lead to more questions eyes.gif, but it's fun to learn something new.

    Mahjongg
  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-27 03:02
    1) Chip wrote a VGA tiled driver (at the end of this thread http://forums.parallax.com/showthread.php?p=615350) that uses 2 cogs for the display and optionally a cog to do a superimposed cursor. I plan to implement the same kind of cursor for the TV driver and some other changes so the two drivers are strictly compatible with each other. They both provide a matrix of "tiles" which can be pointers into the ROM font tables for text or used for bit-mapped graphics. The only problem is that the tile format is different between the two drivers, but some minor changes to the TV driver will fix that. The cursor may be doable without an additional cog. The timing constraints on the TV driver are not as severe as with VGA.

    2) The mouse would be optional and would provide the same information that the current mouse driver provides. I think there's room in the cog to add the mouse code and it would be nice for control. As long as the cursor works even with a pure text display, it could be used for controlling text buttons.

    3) The Propeller OS is another project to provide a basic set of integrated I/O drivers (for keyboard, TV or VGA display, optional mouse, and I2C/SPI I/O with a boot loading capability) along with a simple command interpreter to run programs off mass storage (EEPROM or SD card) as well as some basic utility functions (like copy/delete programs). It's really the same underlying I/O routines with a little "window dressing". The other idea behind this is, once the I/O routines are loaded into their cogs, the assembly stuff doesn't need to be around any more. When other programs are overlaid, there may be another 6K or more of space available.
  • RinksCustomsRinksCustoms Posts: 531
    edited 2008-02-29 03:17
    mouse support, there's an idea [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    E3 = Thought

    http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
  • AndreLAndreL Posts: 1,004
    edited 2008-03-08 05:27
    Mike,

    Are you considering re-writing the basic in ASM? It's double interrpretted at this point. It would be quite a bit of work, but worth it. I guess you can wait for the C compiler to get finished and then compile it in that, but that might be a long time.

    Andre'
  • JT CookJT Cook Posts: 487
    edited 2008-03-08 15:07
    Mike Green said...
    1) Chip wrote a VGA tiled driver (at the end of this thread http://forums.parallax.com/showthread.php?p=615350) that uses 2 cogs for the display and optionally a cog to do a superimposed cursor. I plan to implement the same kind of cursor for the TV driver and some other changes so the two drivers are strictly compatible with each other. They both provide a matrix of "tiles" which can be pointers into the ROM font tables for text or used for bit-mapped graphics. The only problem is that the tile format is different between the two drivers, but some minor changes to the TV driver will fix that. The cursor may be doable without an additional cog. The timing constraints on the TV driver are not as severe as with VGA.
    Why use the TV driver for a cursor? Why not just print a character that is a square block for the cursor and just have it blink on and off (write a "clear" tile, then write a solid tile). Or just not have it blink at all.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-09 03:34
    Andre',
    I actually started writing a Parallax Basic variant to Large Memory Model compiler in Spin. It'll have to be a multi-phase compiler and the SD card routines need to be improved so that multiple files can be opened and random access is supported (to be used for the compiler files). I've gotten busier with other facets of my life, so progress is slow.
Sign In or Register to comment.