PDA

View Full Version : "poke" and "peek"



hitsware
04-12-2007, 09:06 AM
What is the nearest way to do this in PBasic ?
(refering back to the Basic on a Vic 20 )
??????

Mike Green
04-12-2007, 09:17 AM
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.

hitsware
04-12-2007, 09:58 AM
So for:

for x =0 to 3
print x' debug ?
next x

Mike Green
04-12-2007, 10:07 AM
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.

hitsware
04-12-2007, 10:58 AM
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

curious1
04-12-2007, 11:02 AM
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 Green
04-12-2007, 11:03 AM
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 Green
04-12-2007, 11:15 AM
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 Bates
04-12-2007, 03:09 PM
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

hitsware
04-13-2007, 05:41 AM
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 :))
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 :)
Ě

allanlane5
04-13-2007, 06:36 AM
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.

hitsware
04-13-2007, 08:59 AM
>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':))
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 :)

hitsware
04-13-2007, 09:35 AM
what i mean is that they were 'hardwired' for Basic.....
like a BIOS

allanlane5
04-13-2007, 07:35 PM
Well, then the BS2 shares the 'powerfulness' of the Vic20, because it too boots up in PBasic.

hitsware
04-13-2007, 09:15 PM
Except you have to have a PC to access it.

Mike Green
04-13-2007, 09:32 PM
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.

allanlane5
04-13-2007, 09:38 PM
No, you only need a PC to program it. It can run stand-alone after that.

hitsware
04-13-2007, 11:14 PM
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. :)

Mike Green
04-13-2007, 11:27 PM
"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.

allanlane5
04-14-2007, 01:55 AM
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.

hitsware
04-14-2007, 07:34 AM
>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 ? :)
(the $129 one (IIRC) ????

Mike Green
04-14-2007, 10:05 AM
I think allanlane5 was indeed referring to the $130 XGameStation Micro Edition with the SX processor and 128K SRAM.

hitsware
04-14-2007, 05:37 PM
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 ?

Forrest
04-14-2007, 06:22 PM
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 (http://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/ (http://galaxy22.dyndns.org/dtv/)

hitsware
04-14-2007, 10:23 PM
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.

allanlane5
04-14-2007, 10:36 PM
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 Green
04-14-2007, 10:46 PM
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.

Forrest
04-14-2007, 10:57 PM
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.

hitsware
04-15-2007, 12:00 AM
Allan,
My main 'thing' is algorhithmic music. (finding the equation for the 'lost chord' :) )
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 :)

Forrest,
Thanks. I'll look again, I must have missed something.

Forrest
05-05-2007, 05:44 AM
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/ (http://www.bigmech.com/misc/minic64/)