Shop OBEX P1 Docs P2 Docs Learn Events
"poke" and "peek" — Parallax Forums

"poke" and "peek"

hitswarehitsware Posts: 156
edited 2007-05-04 22:44 in BASIC Stamp
What is the nearest way to do this in PBasic ?
(refering back to the Basic on a Vic 20 )
??????

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-12 02:17
    There are three separate memories in the Stamps. Each is accessed with different statements documented in the PBasic manual.
    1) The program memory in an EEPROM. It can be read with a READ statement and written with a WRITE statement.
    2) The data memory (for variables). This can be accessed directly using various variable names like W0 through W12 for word access or B0 through B25 for byte access. You can also access this or parts of this as a word array, byte array, nibble (4-bit) array, or an array of individual bits. See the PBasic manual for details.
    3) Scratchpad RAM is available on all Stamp models except the BS1 and BS2. This is an area on the order of 64 or 128 bytes that's accessible with the GET and PUT statements.
  • hitswarehitsware Posts: 156
    edited 2007-04-12 02:58
    So for:

    for x =0 to 3
    print x' debug ?
    next x
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-12 03:07
    I can't tell what you're asking. How about a bit more explicit and fleshed out question with some explanation of what you would like to accomplish?

    I believe you would see what's possible if you were to read the sections of the manual I suggested.
  • hitswarehitsware Posts: 156
    edited 2007-04-12 03:58
    Is it possible to transcend "declaring the variables" in PBasic ..... I.E.....
    From GWBasic:

    10 for x=0 to 3
    20 ? x
    30 next x
  • curious1curious1 Posts: 104
    edited 2007-04-12 04:02
    Hi Mike,
    I read the items in the BS ref. man., I have a similar product, RevEd, that's manual warns of "Special Function Registers" reserved for interperter and controller functions, that if altered, could adversely affect the IC by using the PEEK and POKE commands.
    Are these SFR's acessible in the BS ? Just want to be sure to avoid them.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-12 04:03
    In PBasic, you must declare variables before using them. The exceptions are the predefined variables like the I/O registers (INS/INL/INH, OUTS/OUTL/OUTH, DIRS/DIRL/DIRH) and the names W0 through W12 and B0 through B25 which are the word and byte variable names for the 13 words of variable storage that exist on the Stamp.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-12 04:15
    curious1,
    The SFRs are not accessable from PBasic. As far as you're concerned, they don't exist. The nice thing about the Stamp is that you can't get it into a "weird" state through programming that you can't get out of. If you have some minimal protective series resistors on the I/O pins (like 220 ohm), it's really hard to destroy the device, at least with +5V or lower exposure. All bets are off if you've got +12V or higher lying around or if you shuffle your feet around on your rug in the dry winter and poke your finger on an I/O pin. This is really great in an educational environment. It certainly works for many customers, including a number with significant industrial control products.

    The flip side of this is that you can't use all the capability of the underlying hardware (SX or PIC) should you want to. On the other hand, Parallax does market the Javalin Stamp, various incarnations of the SX processor, and the Propeller, all of which are faster, more capable, more complex than the BS1 or BS2 series Stamps.

    Post Edited (Mike Green) : 4/12/2007 4:20:44 AM GMT
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-04-12 08:09
    curious1 -

    Such "registers" exist, but as long as you stay away from the following data name constructs, you shouldn't have any problems:

    Wn - As in W0, W1, W2, through W12
    Bn· - As in B0, B1, B2, through B12

    Moreover, you should be aware of the PBASIC Reserved Word list as found in Appendix B of the PBASIC Reference Manual. W0-W12 are mentioned therein.

    Regards,

    Bruce Bates

    Post Edited (Bruce Bates) : 4/12/2007 8:20:50 AM GMT
  • hitswarehitsware Posts: 156
    edited 2007-04-12 22:41
    Mike Green said...
    There are three separate memories in the Stamps. Each is accessed with different statements documented in the PBasic manual.
    1) The program memory in an EEPROM. It can be read with a READ statement and written with a WRITE statement.
    2) The data memory (for variables). This can be accessed directly using various variable names like W0 through W12 for word access or B0 through B25 for byte access. You can also access this or parts of this as a word array, byte array, nibble (4-bit) array, or an array of individual bits. See the PBasic manual for details.
    3) Scratchpad RAM is available on all Stamp models except the BS1 and BS2. This is an area on the order of 64 or 128 bytes that's accessible with the GET and PUT statements.
    My problem is with the DATA and READ statements.
    I can make them work using your previous (thank you [noparse]:)[/noparse])
    example, but (because I have used QBasic so long ?)·can't get
    a real grip on what's happening with PBasic in creating arrays.
    I have the manual but still don't quite get it.
    There seems to be some paradyme shift between these 2 Basics ?
    Again(QBasic):
    for x=0 to 3
    read n(x)
    next x
    data 1,2,3,4
    for x=0 to 3
    print·n(x)
    next x
    'prints:
    1
    2
    3
    4
    Declaring the variables is no problem nor is DEBUG vs. "print"
    I guess it will come to me.............. Just got my PWMPAL [noparse]:)[/noparse]
    ·
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-04-12 23:36
    Yup, a definite paradigm shift.

    The BS2 has 26 bytes (26 BYTES) of memory -- actually, this is "register" memory. It also has 2,000 bytes of eeprom, which is both where your DATA values are stored, and where your 'tokenized' code is stored. Those are all the resources your programs have access to.

    In a way, the VIC20 was more powerful. For one thing, it put out video that went to your screen. And you could plug in a cartridge that had a PROM in it, and I believe it had 22 KBytes of RAM, AND you could 'peek' and 'poke' registers on the sound generator, keyboard interface, and video interface chips.

    However, you couldn't mount the VIC20 in a 24-pin socket and have it do anything useful, which the BS2 can.

    Now, on the BS2, an 'array' is two or more 'register' memory locations. Also, you can address that memory as BITS, NIBBLES (4 bits), BYTE (8 bits) or WORD (16 bits).

    Note that most people use the EEPROM ONLY for program storage. You can only write to each location a million times -- which is a lot if you're programming it once every 5 minutes, but isn't a lot if you WRITE to it under program control. 'READ'ing from it is free, though, so you're probably still in good shape.
  • hitswarehitsware Posts: 156
    edited 2007-04-13 01:59
    >In a way, the VIC20 was more powerful.

    I figure ((with a PWMPAL and a BS2)for sound generation)
    I can do what the VIC20 did.
    3 seperate freerunning 'squarewave oscillators'
    (even a little bit of 'wave shaping'[noparse]:)[/noparse])
    Enough left over pins to drive Vactrols.

    The 'powerfullness' of the VIC20 and the C64 and
    the 1rst IBMPC was that they booted up in BASIC
    sans OS ....... IMO [noparse]:)[/noparse]
  • hitswarehitsware Posts: 156
    edited 2007-04-13 02:35
    what i mean is that they were 'hardwired' for Basic.....
    like a BIOS
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-04-13 12:35
    Well, then the BS2 shares the 'powerfulness' of the Vic20, because it too boots up in PBasic.
  • hitswarehitsware Posts: 156
    edited 2007-04-13 14:15
    Except you have to have a PC to access it.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-13 14:32
    That's true. The smaller PIC processors (which the BS2 is based on) are more than a little underpowered to support a Basic source compiler/interpreter. The Propeller is more along the lines of a self-supporting processor like the VIC20 since it can provide the keyboard/display I/O controller, Basic interpreter, mass storage interface, sound synthesis, etc.
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-04-13 14:38
    No, you only need a PC to program it. It can run stand-alone after that.
  • hitswarehitsware Posts: 156
    edited 2007-04-13 16:14
    But to 'play' with it you need the pc.
    It would be neat to have a piggyback (like the PWMPAL)
    with a (ps2)keyboard in and vga out and and enough
    memory and whatever else it takes to make the
    whole thing run standalone. [noparse]:)[/noparse]
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-13 16:27
    "Neat" doesn't make something economically viable. That doesn't necessarily stop a determined hobbyist who doesn't have to recoup costs and doesn't have to be paid for time spent. There are some 80186 based simple embedded controllers ($100-$150) that can run DOS, therefore will run the very old DOS-based Stamp IDEs for the BS1, BS2, BS2e, and BS2p. A Propeller Protoboard can provide the PS/2 keyboard and VGA display interfaces ($40) with a serial console port that will interface to the 80186 controller. The whole thing could fit in a box maybe 50% bigger than the Protoboard. The keyboard and VGA display and the display's power brick would be huge by comparison.
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-04-13 18:55
    Well, for what I spent for a C64 in 1983 ($600 main unit, $300 floppy drive) you can get a really nice 2 Ghz desktop PC, with VGA display, USB ports, 100 Gigabyte hard drive, and 1 Gig of ram, and a mouse.

    Adding all that to a lowly BS2 is WAY over-gilding the lily.

    However, look into what Andre LaMoth is doing with the SX processor -- that may be more what you're looking for.
  • hitswarehitsware Posts: 156
    edited 2007-04-14 00:34
    >However, look into what Andre LaMoth
    > is doing with the SX processor --
    >that may be more what you're looking for.

    The 'Hydra?' ?
    NO!
    His older model maybe ? [noparse]:)[/noparse]
    (the $129 one (IIRC) ????
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-14 03:05
    I think allanlane5 was indeed referring to the $130 XGameStation Micro Edition with the SX processor and 128K SRAM.
  • hitswarehitsware Posts: 156
    edited 2007-04-14 10:37
    What would it take to configure one of those to a 'VIC20' type computer?
    I.E. boots up in basic and runs standalone?
    1) ps2 keyboard
    2) ntsc monitor
    3) ???? storage of programs (like the cassette with the VIC20)
    4) the Basic would be on a cartridge ?
  • ForrestForrest Posts: 1,341
    edited 2007-04-14 11:22
    The XGS does 1 and 2 and 3 can be accomplished with EEPROM or Flash RAM. But all programming/development is done on a PC (typically SX assembly languaage) and then the program is sent to the SX processor thru the on-board programming hardware or SX-Key. See www.xgamestation.com/view_product.php?id=12

    If you really want to program a Commodore computer - suggest you start with one of the portable Commodore 64 systems such as the DTV/Hummer galaxy22.dyndns.org/dtv/
  • hitswarehitsware Posts: 156
    edited 2007-04-14 15:23
    So if I wanted it to run in Basic, I'd have to write it myself ? ..... Beyond me.
    Looks like the "Commodore 64" is only a game gizmo.
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-04-14 15:36
    I'm not sure what you're trying to accomplish, 'hitsware'. The Vic20 was a very limited function computer, quickly replaced with the C64.

    The PC platform makes a MUCH better game system computer. Try REALbasic if you want a nice IDE basic for doing games with.

    If you want a programmable game machine, using a PC platform or the LaMothe platform are it. If you want to teach with a simple basic, download QBasic and run it on a PC.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-14 15:46
    hitsware,
    The Propeller can function like a VIC20 with a PS/2 keyboard, NTSC monitor, SD card for PC compatible program storage and a simple Basic in EEPROM (known as FemtoBasic). All you need is a Demo Board, Protoboard with the Accessories Kit, or Hydra along with a breakout board for the SD card and a couple of wires from the breakout board to some I/O pins. You need to load the Basic interpreter once into EEPROM, then the whole thing is standalone. The current FemtoBasic is integer only and is more limited than the VIC20 Basic. It's more like PBasic in its abilities ... cost you under $100 for all the pieces.
  • ForrestForrest Posts: 1,341
    edited 2007-04-14 15:57
    The DTV/Hummer game system is a complete Commodore C64 on a chip. If you follow the links on my page link, you'll find you can easily add a PS/2 keyboard, floppy disk drives, flash memory reader, etc.
  • hitswarehitsware Posts: 156
    edited 2007-04-14 17:00
    Allan,
    My main 'thing' is algorhithmic music. (finding the equation for the 'lost chord' [noparse]:)[/noparse] )
    The VIC20 was a little too limited in waveshapes (and frequencies), but I liked the simplicity. (set the note(s) and fire external envelopes).
    I have been using a PC with QBasic and an OPL3 and this works very well, but the necessary commands are sort of tedious. (the Hydra synth looks good from this aspect)
    Here's an example of one of my pieces done on a PC with Zel (a midi language):
    http://home.comcast.net/~mnjmiller/koto.mid

    Mike,
    The Propeller is what got me started here. But I would need Win2k to load the Basic onto the EEPROM right. I do not at this time want to change OS (Win98) The pc I use in my lab (studio) is in fact dos only which makes the Stamps attractive. Also it would appear that the waveshapes need to be mapped and PWM'd out? I went through that with an Amiga and that was tedious also. Too much time spent on getting the sound is time away from getting the music. I could perhaps use the PWM (in FemtoBasic?) the same way I plan to with the PWMPAL (simply to set a frequency and assemitry of an (un)squarewave)
    Geez the possibilities are endless [noparse]:)[/noparse]

    Forrest,
    Thanks. I'll look again, I must have missed something.
  • ForrestForrest Posts: 1,341
    edited 2007-05-04 22:44
    Today I found out that even though www.radioshack.com doesn't list the Hummer Off-Road Racing game anymore, doesn't mean they're not available. I was wondering around my local Radio Shack and was surprised to find (3) new Hummer Off-Road Racing games! They were marked down to $9.97 - I couldn't resist and bought one on the spot.

    Here's another site that shows more hacks on this unit www.bigmech.com/misc/minic64/
Sign In or Register to comment.