VirtualCBM

You need an actual VIC.

Moderator: Moderators

User avatar
Schlowski
NoMess!
Posts: 893
Joined: Tue Jun 08, 2004 12:20 pm

VirtualCBM

Post by Schlowski »

While working on BasEdit and implementing the syntax check I thought to myself that it couldn't be so hard to enhance that to a full blown Basic Interpreter.
Ok, that was a bit of an underestimation of the required changes, but after 2 weeks of hard work I have something created which I dubbed the Virtual CBM.
It's not an emulator - there are more then enough very good emulators already out there, but basically it's an environment in which a Basic V2 program can run at full speed on your PC.
So there is no graphics modes, no sprites and no sound, no UDFs etc. but only pure Basic with PRINT commands!
While working on that environment I realized that most existing programs will at least peek and poke colors and characters, so I decided to make some sort of compatible environments available for the VIC and the C64:

ImageImage

I implemented the complete Basic V2 with the following exclusions:
CMD - not implemented
USR - not implemented
SYS - not implemented
DEF FN - not implemented
FileIO - not implemented (this regards OPEN/CLOSE/INPUT#/PRINT#/GET#)
NEXT var1,var2,... - not working -> use NEXT:NEXT:... or NEXT var1:NEXT var2:...

LOAD and SAVE are working, you need no device no as they simply ignore it and always use the current directory.
LOAD can be used with ,8,1 to load absolute
if load address<>basic start address this will simply load some data in virtual RAM for PEEK and POKE

LOAD"$" loads directory which can be shown with LIST as usual :-)

Fullscreen editor is working, I didn't restricted the logical lines to 4 (for the VIC) or 2 (for the C64). So you can enter lines as long as you want but be aware that if you generate lines longer than 255 bytes they won't run on the original machines!

PEEK and POKE is working, but since there is no emulation of the VIC or VIC-II chips this only means that you can POKE some values into memory and read them back with PEEK .
Ok, that's not the complete truth, there are some locations which behave a little bit like the original:

- PEEK & POKE 646: foreground color
- PEEK & POKE 198: # of characters in keyboard buffer
- POKE 214 : set cursor row
- VIC: PEEK & POKE $900F for background and border colors
- C64: PEEK & POKE $D020 and $D021 for background and border colors
- C64: POKE 53265,PEEK(53265) AND 239 .... turn off screen display
- C64: POKE 53265,PEEK(53265) OR 16 ..... turn on screen display

VirtualCBM can be started with the following commandline parameters:
machine=VIC|C64
ram=unexp|unexpanded
trueemu=on|off (on=restrict integers to 16 bit, of=32 bit integers)
(case doesn't matter)

reals are always double precision floats from the .NET framework, so these CBM's have a higher precision than the originals!

Examples for start parameters:
a) VirtualCBM machine=VIC ram=UnExp TrueEmu=On -> start as VIC with screen and color RAM at unexpanded locations ($1C00 and $9800), integers are 16 bit
b) VirtualCBM machine=VIC -> start as VIC with screen and color RAM at expanded locations ($1000 and $9400), integers are 32 bit
c) VirtualCBM machine=C64 -> start as C64, integers=32 bit

If you simply start VirtualCBM without any parameter it starts in a true virtual mode which will be enhanced later, using 32 bit integers and (for the moment) screen, color RAM and VIC-II pokes like the C64.

As long as I can remember I missed the simple operating environment a Commodore offers. If I need a small program or a simple routine I don't want to start something like VB.NET, create a form, add textfields, buttons, add a listbox as a "scrolling screen" for my output and so on. It's so much easier to write a little Basic program which has some INPUT commands, some calculations and a PRINT at the end, maybe enveloped by a little loop.
This is the main reason behind VirtualCBM, my goal is to have an icon on my desktop so I have by a simple double click a complete nice Basic environment at hand for such tasks.
(And I will enhance that mode with more basic keywords and some sort of file I/O with text and binary modes etc.)

Nevertheless it is vital that the Basic Interpreter is doing it's job reliable so I decided to start with the VIC (and C64) environments as testbeds.
I finally managed to get my Videopoker to work beside the missing sound.

Oh, I nearly forgot, here's the link to the actual version of VirtualCBM :
http://www.stojalowski.de/VirtualCBM/VirtualCBM.NET.zip

After these two weeks I have to admit that I'm deeply impressed by the features of the Basic V2 Interpreter, trying to rebuild all this from scratch proved to be not an easy task, even with all the power and tools of todays hard- and software.

Wow, long post, that should be enough for now, maybe someone finds this useful or interesting enough to play with it - I would appreciate every form of feedback!
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Re: VirtualCBM

Post by nbla000 »

Schlowski wrote:While working on BasEdit and implementing the syntax check...
Again my guilt :wink:

Very nice work :D
Mega-Cart: the cartridge you plug in once and for all.
User avatar
Schlowski
NoMess!
Posts: 893
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

I would not say guilt, I would say you gave me the needed push :-)

In the meantime I implemented file I/O and ironed out some bugs. I will upload a new version in the evening.

I had some interesting times to fiddle out what tab widths to use with PRINT A,B - the VIC uses 11, the C64 uses 10, but when using PRINT#1,A,B the VIC uses 14 and the C64 uses 13. This is totally confusing, I should check if the C128 and the Plus/4 have different tab widths.

It's a really interesting feeling if you use the VirtualCBM in VIC mode, it looks like a VIC but is so much faster - and it's not like VICE running in warp mode which always feels wrong because of the hectic cursor etc.
Printing on screen is so fast that in Videopoker you cannot see that the cards will be drawn with the backsides first and then the frontsides one after another, but they pop up immediately. I'm really thinking about UDFs right now, there is some sort of idea how to solve that problem in my head.

I always dreamed about a VIC with 2 or 4 or 8MHZ and how cool that would be - but since I'm a software guy I have to write my own system instead of soldering a new machine. I think this project will be a part of my spare time for a long time...
User avatar
Diddl
Vic 20 Afficionado
Posts: 426
Joined: Wed Jun 10, 2009 3:18 am
Website: https://oe7twj.at/
Location: Austria
Occupation: software engineer

Post by Diddl »

Schlowski wrote:I always dreamed about a VIC with 2 or 4 or 8MHZ and how cool that would be - but since I'm a software guy I have to write my own system instead of soldering a new machine.
look here

It is 12MHz for a PET, but it would work for your VIC also ... ;)
User avatar
Schlowski
NoMess!
Posts: 893
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

Oh, nice one... I will keep an eye on that!
User avatar
Schlowski
NoMess!
Posts: 893
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

Ok as promised I uploaded a new version.
File I/O as far as it concerns sequential files is implemented.
I never made anything with files on the real machine so I had to do some research on this topic, but finally after nearly 30 years I build some basic understanding for these things.

Code: Select all

10 open1,8,0,"test"
20 ifstatusand64then100
30 input#1,a$:printa$
40 goto20
100 close1
110 print"<eof>"
120 end
Funny thing was my first attempt had line 20 as follows:

Code: Select all

20 ifstand64then100
And I got some really irritating errors until I discovered that my parser tokenized a TAN in the middle of that statement. Luckily for me the real machine has the same problems and now I understand why in all documents they use STATUS instead of ST :-)
User avatar
Schema
factor
Posts: 1440
Joined: Tue Mar 23, 2004 7:07 am
Website: http://www.jammingsignal.com
Location: Toronto, Ontario

Post by Schema »

Schlowski wrote:I always dreamed about a VIC with 2 or 4 or 8MHZ and how cool that would be - but since I'm a software guy I have to write my own system instead of soldering a new machine. I think this project will be a part of my spare time for a long time...
The CoCo community had the same idea for their CoCo4 - rather than try to design new hardware, they planned to create a next-gen CoCo in emulation. Sadly, the project fizzled out last year.

Your project reminds me a bit of Admiral 64 which was also intended to bring BASIC to a PC/Mac.
User avatar
Schlowski
NoMess!
Posts: 893
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

Yeah, Admiral64 started out very interesting but seems to be dead by now - unfortunately there had been no progress since a very long time.
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

I tried my basic benchmark program to see how fast it was, and got this:
Image

http://user.tninet.se/~pug510w/datormuseum/qbench.html
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
Schlowski
NoMess!
Posts: 893
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

NEXT var1,var2,... - not working -> use NEXT:NEXT:... or NEXT var1:NEXT var2:...
I think your are the only one using this form of NEXT, which is 1. slower, 2. uses more bytes and 3. does not work with my interpreter right now :-)

I had the same problems when trying to get Videopoker to run, I had to change your NEXTX,Y,Z commands - even if sound does not do any sound, the loops have to run...
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Ok, I will try to change that then. How can it use more bytes? NEXTX,Y would take 4 bytes. NEXTX:NEXTY would take 5 bytes, or?
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Aha ok, NEXT:NEXT... 3 bytes
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

It seems to run about 4 times faster than running VICE in warp mode.

Maybe you should continue to develop this into an emulator of a fantasy dream Commodore machine! That would be cool. :-) The easiness of the Vic-20 (or maybe with a more complex basic like the Plus/4) combined with the speed of today.

Btw, If you close the window while a program is running, the process continues to run.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

I think it's really cool that you have created a fast working Basic environment and coded it all in Visual Basic! A basic in basic.... :)
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Boray wrote:Maybe you should continue to develop this into an emulator of a fantasy dream Commodore machine! That would be cool. :-) The easiness of the Vic-20 (or maybe with a more complex basic like the Plus/4) combined with the speed of today.
But I guess that is what this project is, just that it only runs basic and no ML. Some sort of graphics and sound and maybe user defined characters could be a good idea.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Post Reply