Showing posts with label Commodore. Show all posts
Showing posts with label Commodore. Show all posts

Sunday, September 16, 2018

Python - The Emperor's New Clothes

I recently posted a couple of examples of a starfield simulation written in BASIC.  One of these was written in Commodore BASIC for the VIC-20.  The other was written in Liberty BASIC for Windows.

BASIC gets a lot of flack from people with a certain kind of snob factor (yes, you know who you are).  And there is the infamous comment by Edsger Dijkstra, and BASIC has never lived it down.  Nowadays when you see people discussing what is the best first language I probably see Python mentioned most.  In these forum discussions someone always seems to snidely denounce BASIC as that old thing with the GOTO and the unreadable spaghetti code.  They don't seem to have a good reason to recommend Python, except that it isn't BASIC.

People also recommend C and it's derivatives such as C++ which also has GOTO.  So go figure.

Wait, here is something scandalous!  On the Python Software Foundation website, in their design and history FAQ page, they actually answer the question about why there is no GOTO in Python by encouraging people to use exception handling as a hack to simulate something like GOTO!  Ummmm.   See for yourself.  https://docs.python.org/3/faq/design.html#why-is-there-no-goto

Okay, getting back to the starfield simulation example.  If you look at the version of the starfield simulation written in Liberty BASIC, it addresses some of the things that BASIC is frowned on about.
  • GOTO - Uh oh, not really.  There is one GOTO, but in this case I'm not sure a WHILE/WEND forever loop is really better, so...  The Commodore BASIC version has three GOTOs.
  • Structure - The Liberty BASIC version uses control structures properly the way modern languages do.
  • Line numbers - Liberty BASIC programs do not require numbers.  You can give your routines meaningful names instead of numbers.
Okay, let's be frank.  Liberty BASIC was not the first version of BASIC to solve these problems.  There are many BASICs with modern features, and so it isn't fair to criticize BASIC as being a bad language for beginners.  BASIC has been a proper language for teaching good programming practices for a very long time now.

What do you think?  Comments welcome.  :-)


Sunday, September 2, 2018

Taking Stock of the Final Expansion 3 Kit

I finally sat down yesterday and printed out the bill of materials for the Final Expansion 3 kit.  The assembly instructions can be found here.  https://www.lemon64.com/forum/viewtopic.php?p=767044

Note: This isn't a kit for the beginner, so if you are one you will have a better chance at success with help from someone with experience.  This is not a knock on the quality of the kit, which seems to be quite good.

So, I carefully examined each part on the bill of materials.  It was easy to identify most parts because they have markings that are listed.  There are three tiny parts without markings.  One is a crystal which is a tiny little metal can with two leads coming out of one end.  The other is a small white cardboard carrier with two tiny little rectangular dots.  These dots are two surface mount capacitors.

There are five surface mounted parts in this kit.  Assembling these is considered an advanced skill.  This will be my first time with surface mount components.  I am eager to give this a go.  YouTube videos showing how to do this are aplenty.

After carefully examining everything, I was able to account for all the parts in the kit.

Here is a photo of the unpopulated board.


I also posted a video about all this. 

Getting Ready to Build the Final Expansion 3 FE3 Kit for the VIC-20



Next stop - Assembly!  :-)

Monday, August 27, 2018

Prelude to a Kit (Final Expansion 3)

Let me just show a few photos of what came in the Final Expansion 3 kit for the VIC-20 (that I ordered from SkydivinGirl over on the Atari Age forum) before I get down to beginning assembly, just so people can see what is in the box.

Here is how it came packaged.  I think this is fine because there is nothing in here that could be considered fragile, at least in the sense that glass is fragile.  ;-)


This is the bare board in a nice bright fire engine red.  You may notice there are a few spots where parts will need to be surface mounted, but its mostly thru-hole.  It should be a pretty easy build.  I used to do a lot of PCB assembly in my youth, so I'm comfortable with this.



The ICs came in this anti static bag. My understanding is that the ROMs are already programmed.


Here are the capacitors, resistors and other parts.


Finally it comes with two different kinds of stickers to choose from for the top of the cartridge case, which is not included.




I decided that I would not buy the optional case, which is more than $20 by itself.  Instead I decided to sacrifice an original VIC-20 Mole Attack! game to provide a cartridge.  I will need to cut some openings for the SIO ports that Final Expansion 3 uses to connect to the VIC-20 serial port and also out to another serial device such as a floppy drive.  Also openings for the SD card slot and for a bank of DIP switches will be needed.



Finally I'll note that the kit doesn't come with any assembly instructions, which surprised me.  Instead I needed to Google for them.  Save a tree?

Here's the link for the instructions.  They are for an older version of the board, but they should suffice.   http://www.lemon64.com/forum/viewtopic.php?p=767044

Saturday, August 25, 2018

Starfield Simulation in Liberty BASIC

Here is the starfield simulation that for the VIC-20 that I posted a few days ago, but ported as simply as possible to Windows using the Liberty BASIC language (http://www.libertybasic.com).  If you compare them side by side you can see that a lot of the original code is preserved across the translation.

Enjoy!

 dim st(9,1)  
 gosub [setup]  
 timer 20, [cycle]  
 [cycle]  
   for c=0 to n  
     xold=st(c,0)  
     yold=st(c,1)  
     st(c,0)=xold*1.23  
     st(c,1)=yold*1.23  
     x=int(st(c,0))  
     y=int(st(c,1))  
     if abs(x)<15 and abs(y)<15 then  
       gosub [clearStar]  
      else  
       if abs(x)>200 or abs(y)>200 then  
         st(c,0)=(rnd(1)-0.5)*3  
         st(c,1)=(rnd(1)-0.5)*3  
        else  
         gosub [drawStar]  
       end if  
     end if  
   next c  
   wait  
   goto [cycle]  
 [clearStar]  
   #starfield "color black ; place "; xCenter + xold; " "; yCenter + yold  
   #starfield "\."  
   return  
 [drawStar]  
   gosub [clearStar]  
   #starfield "color white ; place "; xCenter + x; " "; yCenter + y  
   #starfield "\."  
   return  
 [setup]  
   input"# stars (1-10)";n  
   n=n-1  
   for x=0 to n  
     st(x,0)=(rnd(1)-0.5)*200  
     st(x,1)=(rnd(1)-0.5)*200  
   next x  
   open "starfield" for graphics as #starfield  
   #starfield "home ; posxy xCenter yCenter"  
   #starfield "down ; fill black ; backcolor black"  
   #starfield "trapclose [quit]"  
   return  
 [quit]  
   close #starfield  
   end  

Tuesday, August 21, 2018

Starfield Simulation in Commodore BASIC

I posted a challenge in the VIC-20 group on Facebook.  The idea was to replicate the forward screen of the starship Enterprise from Star Trek.  This shows stars moving from the center of the screen to the edges, simulating forward motion.  It isn't meant to be an accurate 3D simulation.  ;-)

Here is my code of this.  One other person also submitted a version of it.  This could form the basis for a game.

[Update] --- I made a new version of this in Liberty BASIC!  Click to see the new version

 10 gosub 500  
 100 for c=0 to n  
 110 xold=st(c,0)  
 120 yold=st(c,1)  
 130 st(c,0)=xold*1.23  
 140 st(c,1)=yold*1.23  
 150 x=int(st(c,0))  
 160 y=int(st(c,1))  
 165 if abs(x)<2 and abs(y)<2 then 320  
 170 if abs(x)>10 or abs(y)>10 thenst(c,0)=(rnd(1)-.5)*3:st(c,1)=(rnd(1)-.5)*3:goto150  
 180 pstar=center+x+y*22  
 190 poke center+int(xold)+int(yold)*22,32  
 200 poke pstar,108  
 300 next c  
 310 goto 100  
 320 poke center+int(xold)+int(yold)*22,32  
 400 next c  
 410 goto 100  
 500 poke 36879,14  
 501 input"# stars (1-10)";n  
 502 n=n-1  
 505 print"{clrscrn}";  
 510 dim st(9,1)  
 520 for x=0 to n  
 530 st(x,0)=(rnd(1)-.5)*10  
 540 st(x,1)=(rnd(1)-.5)*10  
 550 next x  
 590 center=7932  
 600 return  

Monday, August 20, 2018

Introducing The Friendly Computer!

When Commodore introduced the VIC-20 they called it The Friendly Computer.  This is probably more because of the manual they included with it than because of anything else.  The book was really easy to understand.


Here is my own VIC-20.  This is an early one, with the squared off keys and the two-prong power plug.  I've got it plugged into a Sylvania TV using an RF modulator.

If you look closely at the screen it reports CBM BASIC V2, and 3583 BYTES FREE.  The computer comes with 5K RAM, but it uses some of that to map the screen, and some more for managing the BASIC interpreter.  If they had thought to provide 8K RAM this would have doubled the amount the programmer has access to.  This would have made the VIC-20 a lot more powerful.

Nowadays people wonder how anything could every be written with only 3.5K RAM, but we were so used to this back then.  You might be surprised how much can be done with a little ingenuity.  As a comparison, the original Atari 2600 VCS game console had only 128 bytes of RAM.  The VIC-20 has 28 times more RAM!  In addition, you could plug a RAM expansion cartridge into the VIC-20 to add more RAM.  Commodore made several sizes up to 16K RAM, and other companies made bigger ones.

I also have a Commodore C2N cassette drive.  I also had one of these in the 80's.  I have been using the tape drive to save some small programs.  This is nothing like a floppy drive, but you can save programs by name, and it sure beats retyping in programs every time you want to use them.

I also have a Commodore 1571 floppy drive.  These are great, but they don't make it possible to send and received programs to and from other people on the Internet because the disks have a format that can't be read on Macs or PCs.  I want to share what I'm doing, so I have purchased a kit to build my own SD flash memory adapter that will behave like a floppy drive and also let me use the SD card to copy files to other computers so I can share with others.  I'm very excited about that and I'll blog about it also.

Back to BASICs

Some time ago I began to assemble a small collection of vintage home computers in order to begin blogging about what makes these machines so appealing.  In particular, programming these computers in BASIC in my early years made a huge impression on me and my creation of Liberty BASIC was inspired by my love for BASIC.

I have obtained the following machines in working condition.

Apple //c
Commodore 128 (a Commodore 64 compatible machine which also has a Z80 processor)
Commodore VIC-20
Atari 800XL
TRS-80 Color Computer 2 (not sure I will actually use this one)
And a few less popular computers that might make guest appearances.

To begin with, I am focusing on the Commodore VIC-20.  I have some ideas about very simple and fun projects in BASIC, and some Forth.  Since most of these machine also have a 6502 processor, perhaps there will also be some posts about that.


Friday, October 9, 2009

Strange Computer Stories

The following is a true story. My Commodore VIC-20 suddenly stopped working. Somehow I figured out that the power supply (one of those black bricks) was at fault. I told my boss Mr. Alessi about it. I needed to order a new one. He made an interesting proposal. He happened to be an electrical engineer specializing in power supplies. He had a novel idea. He would make me a new power supply for my computer himself at no charge, for fun.

Okay, I accepted. He explained that he wanted to build me a very special power supply. It would have a standard lightbulb socket on top, into which would be screwed a standard 60 watt bulb. The purpose of this strange addition? It would act as part of a surge protection mechanism. If there was a surge, the filament in the bulb would become hotter and its resistance would go up. A kind of thermistor (look that up). This was useful for regulating the voltage.

The end result was a very plain looking black project box with a two prong power cord going in on one side, and power cable going to the VIC-20 on the other end. On top, to one side was a dimly orange glowing Sylvania lightbulb. The brightness (dimness really) would remain fairly steady. Here and there it would suddenly glow a little brighter, or dimmer. No lie.

Did it work? Seemed to.

Saturday, December 27, 2008

COMPUTE! Magazine

Computer magazines used to be so much fun. First of all most of them had a very strong focus on programming and they would have articles about how to make electronic hardware to plug into your computer. Very much fun indeed.

Since I was the owner of a Commodore VIC-20 I would buy issues of COMPUTE's Gazette which catered specifically to Commodore 8-bit computers.

I remember one issue which included a machine code monitor listing. The program was in BASIC and it would POKE a machine code monitor (in machine code of course) into memory and then it would start up. I experimented with 6502 assembler using this monitor. I would write the assembly code down and then I would translate it myself to hexadecimal numbers and type them carefully in.

This was one of the great things about the computers of those days. A fifteen year old kid could figure this stuff out by reading magazine articles. There's probably no reason why it can't be made relevant to young people today. Why not make a cool and easy game programming tool for the Nintendo DS for example?

Saturday, May 5, 2007

The VIC-20

In 1980 Commodore introduced a new 6502 based $299 home computer called the VIC-20. http://oldcomputers.net/vic20.html

It was essentially a version of the Commodore PET that plugged into a TV set. For the price there was nothing like it. It had Commodore BASIC built-in, color and sound, a joystick port, and a cartridge expansion slot. It didn't have graphical sprites, but it was still capable of video games and it cost about half the price of an Atari 400.

I wrote a lot of software for this machine at NEECO where I hung out. It didn't have full screen graphics, but you could program the graphics characters on the fly. It did have a very low screen resolution (22x23 text mode, 176x184 graphics mode) and it only came with 3.5K of available RAM out of the box, but we were very used to limited memory back then.

Compute! magazine had some really great software listings for this machine, like a graphics character editor for example and a machine code monitor. Just type it in and go. :-)

Sunday, April 22, 2007

NEECO, a computer store

In the late seventees a computer store named NEECO moved from Springfield, MA to Needham, MA where I lived. I'm sure it was my brother Ernie who first brought me to the store. It was at least a two mile walk from our house, but we were in the habit of walking farther than that just to go to You-Do-It Electronics on the edge of town, so this was really nothing to us.

NEECO was to become a central influence in my life for a couple of years. What a store it was. I have many memories of the place.

When I first started visiting the store there were the following models I can remember:
  • Apple II
  • Commodore PET and CBM 8032
  • Intertec Superbrain
  • Hewlett Packard HP-85
  • Atari 800 and 400

There was usually something fun running on each machine, especially the Apple and Atari computers. They also had a magazine rack and lots of software for sale.

I spent a lot of time there. Sometimes I was helpful to the people running the store, but I think they sometimes wish I was somewhere else. I owe them a debt of gratitude at least. ;-)