Archive for November 2013



IIWASHERESTOPMy program to print “I WAS HERE!” allowing the RUN STOP key to break out of the program

Recently, on the blog , which actually helps this blog get more publicity, TMR, who is fluent in 6502 Assembly Language, can probably remember all the hundreds or thousands of significant memory locations to POKE and PEEK on the Commodore 64, and may also have memorised the logarithmic tables wrote the following…

“So the author feels that remembering a four digit alphanumeric value might magically be easier than remembering a five digit numeric one… but hasn’t managed to do either himself so we can safely ignore his uninformed opinion dear reader.”

I first started working with hexadecimal numbers in Locomotive BASIC on an Amstrad CPC computer. This BASIC was written in 1984 and updated in 1984 or 1985, compared to Commodore BASIC V2 on the C64 written in 1977 for the Commodore PET with a small update in 1979. I immediately found hexadecimal numbers easier to remember than the mainly 5 digit decimal numbers on the Commodore 64. I recently read an article published in 1983 which I’d never seen before. This article points out that the VIC-II chip is mapped in to the C64 starting at $D000 (53248), which I think is easy. I can remember it by thinking that the VIC-II chip is on D block. I think the registers end at $D02E. This sounds like the quaint expression “Coooeee!” which a friend often greets me with when he phones. I can imagine being a postman or courier with a package to deliver. I already know I need to deliver it to an address on D block, then the person expecting the package comes out from a door at the end of the street and shouts “Coooeee!”, which reminds me of $D02E. As I walk along the block, I’m being watched by a nosy neighbour at $D012, who’s keeping track of where I am, so that reminds me that $D012 holds the current raster line number. It seems to me that MOST memory locations of chips and their registers on the C64 start with the numbers 532, which in the famous Greco/Roman memory system as described in the book “How To Develop a Super Power Memory” by Harry Lorrayne, are represented by the letters LMN as in lemon, so probably the inspiration for the website name lemon64. As most of the important locations seem to start with 532, it means that system isn’t much good with the Commodore 64. Similarly, lots of or even most C64 Assembly Language routines are located at $C000, so we can call this address Code block.

TMR went on to say…

“The BBC computer literacy project specifically focused on BBC BASIC and no other 8-bit was directly compatible with it, so the author opens himself to even more ridicule by trying to single out the C64. And who, exactly, is responsible for the claimed “misdirection” exactly?

The BBC computer literacy project started before the BBC Micro was released or had sold many units. The book “30 Hour BASIC” was written in a subset of Microsoft BASIC, designed to be compatible with as many computers as possible, although some specific versions were produced for particular computers, because the book was designed for complete beginners, who wouldn’t even know the difference between PRINT and DATA, which I didn’t know when I was trying to write one of my first programs, guided by the Commodore 64 course “An Introduction to BASIC”. This meant that simple things such as brackets placed in the wrong places, commands such as CLS, MODE [number], RANDOMIZE, etc, could cause programs on various computers to stop with an error message, The programs were tested on a Commodore PET, as well as on a prototype BBC Micro. In the BBC series “The Computer Programme” (1982, copies of which have been uploaded to and deleted from Youtube, then more copies uploaded), Commodore PET computers were featured, as well as the BBC Micro. Also, even in the first episode of the BBC series “Making The Most of the Micro” (1983, which you might also find on Youtube) a disabled student was featured writing documents on an Apple ][, as well as controlling electrical equipment with a 20 column screen display like a Commodore VIC-20, with what looked like a Commodore 64 sitting next to the Apple ][, and there were at least 2 Commodore PET computers shown during that episode. As for “misdirection” I recently found what I can only describe as a semi secret stash of information, which was hidden from me when I owned a Commodore 64. I think this information should have been republished by Commodore in books with their official C= or more like C< “chickenhead” logo and made widely available. As a Commodore 64 owner or Commodore 64 victim, amazingly enough, I looked for magazines with the name Commodore, or Commodore 64, in their title, although I also bought some non specialised computer magazines which were widely available. One magazine I didn't buy had a series of amazing articles or exposés about the secrets of how to program hires graphics, sprites, sound effects and music on the Commodore 64 by a team of people who had used computers before the C64 came out and who seemed dedicated to fixing the Commodore BASIC V2 mess. Unfortunately, this magazine didn't have the name Commodore or even 64 in its title! Apart from this, the magazine may not have been widely available in London where I lived, but during my time as a Commodore 64 victim I'm fairly sure I visited Silica Shop in Sidcup, London Borough of Bexley, SE London, as well as Foyle's book shop in Charing Cross Road, London W1 and some newsagents near there in the West End of London, but I didn't notice this magazine. Some of the articles were also compiled into books and republished with the name Commodore 64 on their covers! These books should have been available at Foyle's or WH Smith's if anywhere, but I don't remember seeing them. Can anyone guess what magazine or book publisher I'm talking about? If so, then how or when did you hear about them?

TMR also wrote…

“Your correspondent has previously done some digging around Apple II disk images to understand the process behind making an auto-booting program for the machine and, whilst some of the boot loaders are BASIC at least on the pirated versions available to download, the majority of those games were machine code. That might be wrong of course[1], but unless the author can produce verifiable statistics…”

I wrote that most Apple ][ software was written in BASIC. I was actually talking about applications, not games. I read a story that it was essential for Apple to renew their licence for Applesoft BASIC from Microsoft, otherwise they may have had to stop selling the Apple][, because MOST software (except games) for that computer was written in Applesoft BASIC .

“Of course it wasn’t possible to save a BASIC 8 program out and give it to a friend with a C128 who didn’t have the BASIC 8 package… this has previously been a massive issue for the author when talking about the C64, so your correspondent is “surprised” that he failed to mention it in relation to the C128 – anyone would think he has some bias!”

DataBeckerC128InternC128 Internals in the original Data Becker German version

I never said that I approved of Commodore failing yet again to provide BASIC commands to control new hardware. I was just stating a fact. It is possible to program the VDC chip using 6502 Assembly Language, which is a language that looks easier to me every day, but unfortunately, the VDC is more difficult to program than the VIC-II chip. I think this is bad and so far I haven't even seen the VDC display from my C128, because I haven't yet bought a compatible cable. Various programmers in Germany who worked for Data Becker publishers were good at investigating and reverse engineering computers. It was them who found out how to program the VDC in detail, then they published this information in a Data Becker book in German. Unfortunately, these books weren't widely available or not at all in Britain, although some people would have understood them, so people here had to wait until translations were published by Abacus Books in the USA, then imported. It was the same for their Amiga and Atari ST books, which they’re mainly known for. I never saw any British editions, although Data Becker did set up an office over here. I think it's much easier, even a Kinderspiel, to understand German than the Alptraum which is Commodore BASIC V2, because I found it easy to learn German before getting a Commodore 64, and I continued studying German while struggling with the Commodore 64, as well as after I sold the C64. A high percentage of German words are the same or very similar to English words, such as Bier, Butter, Arm, Hand , Finger, Milch, Computer, Schule, Schuh, Jacke, Stuhl, and Maus. There was even software available for the Commodore 64 when I owned one which taught German. For more information see and .

DataBeckerC64GrafikThe C64 Graphics Book by Data Becker in German

I said previously…

“I think it would have been a great idea if the Commodore 128 had come out some time before 1985 or even in 1982 instead of the Commodore 64. It seems to be a case of missing the boat. It ended up being overshadowed not only by the Amiga, but also by the Commodore 64 not being discontinued, which should have happened in or before 1985. Unfortunately, the C128 ceased production in 1989, although the Commodore 64 continued until 1994, when Commodore went bust”.

TMR replied…

“It might seem a “great idea” but the C128 simply wouldn’t have been financially viable as a commercial product in 1982; in fact the price tag was more reasonable by 1985 but still put it out of reach for the majority of home users, especially in the UK where cost was an important factor. The C64 kept selling because it’s a popular computer, despite what the author claims”.

Of course, Commodore were making a big profit on every C64 they sold. According to ads in old magazines, the Commodore 64 was selling in Britain during 1983 for around £344, then came down to £199 in 1984. The reasons for the crap BASIC V2 were just to avoid paying Microsoft $3 or even $10 per C64 sold, Commodore owned the chip manufacturer MOS who made most of the chips in the C64, and there's no real way of knowing how much profit they were making on it. A lot of the Commodore 64 computers sold in Britain were actually made here, so they avoided import duties as well. It would certainly have been possible to produce a computer with at least some of the features of the C128 as prices of RAM and other costs came down, but Commodore didn't do this, because they just didn't care. Sinclair discontinued its 48K Spectrum, replacing it with the Spectrum 128K, Atari replaced its 400 and 800 models, replacing them with their XL range, while Apple had various upgraded versions of their original Apple ][ computer. I don't think they waited to see if the public agreed with them before discontinuing these models. Atari made a big mistake with their 1200XL, so then it was revamped into the 600XL and 800XL.

I wrote…

“The differences between those computers summed up are whereabouts in RAM to place your Assembly Language/Machine Code programs, the ASCII/ATASCII/PETSCII codes for specific alphanumeric characters, where is the screen memory located, and if you use any ROM based routines, then the addresses of these routines will be different on different computers, so you have to look them up and replace them..”

TMR replied…

“This is a worryingly naïve way of looking at 6502 machine code and no, it really isn’t anywhere near as simple as the author is trying to imply”.

I'm basing this on the examples in the book “Machine Language for Beginners” on , as well as the knlowledge that software houses often or usually developed software for various computers which shared the same or compatible processors.

TMR wrote…

“The irony is that in the author’s fantasy the Spectrum Simulator couldn’t save or load files in a form compatible with a real Spectrum whilst in reality it could do exactly that; BASIC programs or even SCREEN$ files could be exchanged between the two machines and a teenage version of your correspondent occasionally did so to convert a friend’s Spectrum-drawn graphics (created with the OCP Art Studio before the author starts dribbling about Spectrum BASIC again) to the C64”.

It's a pity this wasn't widely known. This information was obviously covered up! I read that even the Commodore 16/Commodore Plus/4 cassette data recorders were incompatible with the C64, which prevented me from buying a third party extended BASIC that was “language compatible” with BASIC 3.5.

TMR wrote…

“This is one of those trade offs that happens in 8-bit computer design; at the same resolution the Amstrad CPC or BBC Micro only get four colours for the entire display where the Spectrum has fifteen and the C64 gets sixteen. That’s why it can do things like this if the artist uses a graphics tool:”

The BBC Micro, and Amstrad CPC both used the 6845 video chip, which the Acorn Electron used a compatible chip. These chips all had a feature called “individual pixel clarity”, meaning that however many or few colours there are on the screen, each pixel can be any one of these colours, regardless or what colours the neighbouring pixels are. This means no colour bleed, although the Commodore 64, Spectrum, and Commodore 128 all had this. MSX computers, as well as other computers which used the same or compatible Texas Instruments 9918/9928/9929 video chip, also suffered from colour bleed/attribute mode, but only in horizontal 8 pixel lines, instead of 8×8 pixel squares. These are all much better systems than the Commodore 64.

TMR wrote…

“The VDC has only two colours per 8×8 pixel attribute cell, but they’re half the width of the C64 ones and it’s worth remembering, however, that all of the other machines with a comparable mode (the Amstrad CPC or BBC Micro for example) only have two colours where the C128 VDC has sixteen”.

I haven't been criticising the VDC, because that chip wasn't used in the Commodore 64, so this comment is irrelevant. The Commodore 128 is much better than the Commodore 64. Unfortunately, I still haven't seen the output of this chip from my Commodore 128, because I haven't yet bought this right lead, although the BBC Micro and Acorn Electron could display their highest resolution modes on a TV, while the Amstrad CPC was sold with a green screen or colour monitor and required a plug in RF modulator/PSU for this.

TMR wrote…

“The lack of understanding is purely the authors; calling $FFE1 doesn’t “re enable” the Run/Stop key as the author claimed previously, it merely checks the key and the author’s code is then exiting on a positive response. In real world programs (as opposed to the tiny fragments the author is offering up) just exiting to BASIC without resetting the registers like that is pretty much useless because they do things like turn on the hardware sprites, change where the character set or screen pointers are looking and so on”.

It's not possible to use just the RUN STOP key without calling $FFE1. I'm writing fairly simple 6502 Assembly Language programs so far, which means that I don't want to reset everything by pressing RUN STOP and RESTORE.

Finally, TMR shows us a screen shot of five POKEs to consecutive RAM locations starting at 8192, followed by a SYS 8192 call, which cause a flashing ripple border effect. I think this shows clearly how difficult Commodore BASIC V2 on the C64 is to read and understand and how 6502 Assembly Language is easier in this case. I hope to crack the Commodore 64's secrets in the near future. I now see this as a challenge to restore my confidence before I move on to bigger and better things. This may include writing a replacement BASIC for the C64, which could be similar to the BASIC on another computer, instead of Commodore BASIC 3.5. It should run faster than extended BASICs, because C64 BASIC is very slow. If I manage this, then I'll release it as Shareware without any features being disabled, because I'm not obsessed with money, unlike Jack Tramiel!

Posted November 16, 2013 by C64hater in Uncategorized



C1281My Commodore 128

Based on my research, it seems that Commodore BASIC V2 on the C64 is such a load of crap that it’s probably easier to learn 6502 Assembly Language! Of course, the problem with that may be trying to think like a computer, as well as yet again trying to remember lots of numbers representing memory locations. At least these are in hexadecimal, though, which may make it easier. Based on things I’ve heard about programming in 6502 Assembly Language on Atari 8 bit computers, people usually use a file with a long list of EQU equate directives, to replace the numbers with meaningful official Atari names for the various routines. I haven’t seen this approach on the C64 yet, so I don’t know if it’s used at all. Of course, the Atari range of computers could be programmed in Atari BASIC, although users required POKEs and PEEKs to use the Player Missile Graphics or sprites.

AFAIK, just about every Commodore 64 magazine which wasn’t only about games said that Commodore BASIC V2 was poor, old fashioned, Neanderthal, etc, as well as having listings and/or ads for “Extended BASICs”, to supply the missing commands.

I think that a lot of the problems with the Commodore 64 are due to misdirection, meaning a similar technique to that used by magicians so that people don’t notice how their tricks work. I was told by the BBC with their big computer literacy campaign on TV as well as books, access to BBC Micro computers, etc that all computers used the language BASIC and that you had to learn that language. I think there was a similar message around the World (e.g. in Compute! magazine in the USA available to download on , as well as COMputer magazine in Denmark which you can download from Apart from this, I heard that I should later learn Assembly Language/Machine Code, but start by incorporating some Machine Code routines into my programs. In spite of this, I recently heard that Apple ][ programs were often or even mostly written in Applesoft BASIC. I also heard that Logo was an easier language with a different attitude to BASIC. I read later on in 1984 that it was actually an amazing, underestimated language which was based on Lisp and a good alternative to BASIC. I was drooling over a Logo demo at the 64 Software Centre in London, where I bought a copy of Turbo BASIC, because I realised I needed an extended BASIC and felt that was all I could afford (i.e. £14.99?). Unfortunately, Commodore Logo was disk only, but to write commercial programs in Logo, you’d need a compiler or a runtime version of Logo, otherwise the programs could only be used by people with a copy of Logo. I never heard about any Logo compiler or runtime version for the Commodore 64. I’ve just bought a copy of Commodore 64 Logo from eBay, so I’ll make a post about how amazing it is soon and show you why the Commodore 64 and MOST computers should have come with Logo built in instead of BASIC!

1541IIFDDMy Commodore 1541 II disk drive which I could never afford in 1984-1985

The famous “Rotating Squares” program, as used in classic Doctor Who on the TARDIS console screen to represent the time vortex used logical colour switching, to create an effect like a flashing neon sign. I can’t find the original listing for this at the moment. Logical colour switching means that although your colours are numbered 0-15, each numbered colour can be ANY actual colour available in your palette, so by changing the actual colours of these numbered colours, you can produce animation. The BBC Micro used the 6845 video chip, allowing each pixel to be a different colour from its neighbours, called “individual pixel clarity”. I was able to recreate this animation effect on an Amstrad CPC, using the knowledge gained from the BASIC conversion course in “MSX User” magazine, because it used the same 6845 graphics chip and Amstrad’s Locomotive BASIC also had this colour switching facility. I’m not sure if this is possible with the VIC-II chip, because although the Commodore 64 has colours numbered 0-15, these colours are fixed, at least in Commodore BASIC V2. Looking at the Commodore BASIC V7 graphics commands with their colour “sources” parameters, I’m beginning to think that option may exist. Perhaps this effect could be simulated if a fast enough routine could be developed. Unfortunately, this would probably need to be in Machine Code, especially as the Commodore 64 is much slower than the Atari 8 bit and the BBC Micro.

I’ve recently read old ads from 1984 and 1985 about extended BASICs or other languages such as Video BASIC 64 by Adamsoft, as well as White Lightning and Machine Lightning by Oasis, SCOPE by ISP, and ACOS+ by Melbourne House, which all claimed to be able to produce stand alone programs. I didn’t read about most of these when I owned a Commodore 64, because by the time ads for them appeared I’d totally given up on the Commodore 64 and no longer bothered to read magazines about it. Unfortunately, buyers of these programs would probably only have had the documentation that came with them to learn these languages from. White Lightning and Machine Lightning also claimed to be FORTH type languages. FORTH isn’t like BASIC and the whole idea of FORTH is to write your own extensions. As for the software “Game Maker”, which left Commodore 64 owners with only 4K and didn’t involve programming, it sounded ridiculous to me! I thought I had 64K, then I was told I only had 38K, then finally to have this reduced to 4K and not be able to program it at all was like cheating or beyond a joke to me!

The Commodore 128 also seems to be the beginning of a new look, as well as technology which became associated with the Amiga range of computers. Commodore not only abandoned the C64 “breadbox” casing, but also developed or adopted new video signals and monitors called RGBi, standing for Red Green Blue intensity, which was somehow compatible with CGA, although the original Amiga had 4,096 colours. The RGBi signal was output by a new additional video chip in the C128 called the VDC, although the Commodore 128 also included the VIC-II chip. Unfortunately, Commodore BASIC V7 had no commands to support the VDC chip, then Walrusoft brought out an improved BASIC called BASIC 8 to make use of the VDC! Commodore also brought out a mouse for the C128, which looked identical to the original Amiga mouse widely called a “tank mouse”. The 128K RAM used a technique called “bank switching”, also used by Amstrad and some others, where because only a total of 64K RAM could be seen by the 8 bit 8502 CPU at any one time, the 128 was divided into banks of RAM which were only seen when they needed to be. I’ve read that there were only 2 banks of 64K, but several different memory configurations. The maximum RAM on the C128 could have been 512K or even 1Mb! They also supplied CP/M Plus with this computer or at least with versions that incorporated a disk drive, and/or with disk drives designed for it. Having 128K and CP/M Plus were both things it shared with the Amstrad CPC6128 computer, which also came out in 1985. That computer uses bank switching by switching out a 16K bank, then switching in one of the other 16K banks, but at the moment I’m not sure how the C128 does it.

I think it would have been a great idea if the Commodore 128 had come out some time before 1985 or even in 1982 instead of the Commodore 64. It seems to be a case of missing the boat. It ended up being overshadowed not only by the Amiga, but also by the Commodore 64 not being discontinued, which should have happened in or before 1985. Unfortunately, the C128 ceased production in 1989, although the Commodore 64 continued until 1994, when Commodore went bust.

I’ve finally come to the conclusion that various Commodore 64 magazines, as well as Commodore themselves should have given people the clear message that Commodore BASIC V2 is only suitable for writing text based programs, like a pocket calculator only with text labels, or text only adventure games. It can easily produce coloured text by inserting control codes into PRINT statements, but that’s all. They could have heavily promoted either Simons’ BASIC or the Super Expander 64 as an essential piece of software with reader discounts. One of these cartridges could have been bundled with the C64 to increase their market share. When it comes to writing programs that use graphics and/or sound it’s easier to use 6502/6510 Assembly Language than Commodore BASIC V2. I think this means that the magazines should have promoted Assembly Language and Assemblers more heavily as well. Not only that, but by using 6502 Assembler, you can draw on a mass of information written for other 6502 based computers, such as the Apple ][, Atari 8 bit, Acorn Atom/BBC/Electron, Tangerine Microtan 65, Tangerine Oric 1/Oric Atmos, or non specific books about programming the 6502 wherever this kind of CPU may be embedded. The differences between those computers summed up are whereabouts in RAM to place your Assembly Language/Machine Code programs, the ASCII/ATASCII/PETSCII codes for specific alphanumeric characters, where is the screen memory located, and if you use any ROM based routines, then the addresses of these routines will be different on different computers, so you have to look them up and replace them. I have never seen or heard of any third party books about Simons’ BASIC, Scope, ACOS+, Video BASIC 64, White Lightning, or Machine Lightning. After reading the manuals, you were probably on your own. One ad I read recently which I don’t remember reading ever before was for some C64 software called “Sinclair Spectrum Simulator”. I think I would have bought this if I’d seen it advertised. Then I’d have been able to read and use a whole load of books and magazines about Sinclair Spectrum BASIC, which hardly used any POKEs or PEEKs compared to Commodore BASIC V2. I recently had a fantasy of reading an ad about it while sitting near my Dad in the living room, shouting out the details in amazement, seeing my chance to be free of Commodore BASIC V2 and into the Spectrum marketplace, then having meetings with Spectrum owners to retype my Sinclair Spectrum BASIC listings into their computers, because I seriously doubt that these programs saved by a C64 compatible data recorder would have been compatible with the Spectrum.

Embroidery1The output of the Embroidery program below

INPUT magazine Issue No. 3 more or less wrote off Commodore BASIC V2 when it came to graphics, by saying that it would be very difficult to get it to do a patchwork or a embroidery design like the Sinclair Spectrum, BBC Micro, and Acorn Electron. Later on, they featured listings in Simons’ BASIC. It produced a constantly changing and evolving pattern you could watch for ages! Here’s that program converted by me from BBC BASIC into Commodore BASIC V7. I used the SCALE command to make the Commodore 128 use the same cartesian coordinates as the BBC Micro instead of converting them.

10 COLOR 4,3
30 SCALE 1,1279,1023
40 FOR N=1 TO 1279 STEP 88
50 C=INT(RND(1)*15+1):COLOR 1,C
60 IF C<2 THEN 50
70 DRAW 1,1,1 TO N,1023
80 DRAW 1,1279,1 TO 1279-N,1023
90 DRAW 1,1,1023 TO N,0
100 DRAW 1,1279,1023 TO 1279-N,4
110 NEXT N
120 GOTO 40

Embroidery2Screenshot of the Embroidery program later on in its run

Unfortunately, this program shows the limitations of the Commodore VIC-II chip. In hires mode GRAPHIC 1 (320×200) it soon starts to suffer from attributes or artefacts where the lines in each 8×8 pixel square change to the same colour, the same as on the Sinclair Spectrum. This is with a scaled step size of 88 in line 40 and worse if the step size is reduced. It even happens in the lores multicolour GRAPHIC 3 (160×200) mode, which I assume occurs whenever a line is drawn through any 8×8 pixel square that already contains 3 lines each of a different colour. So far, I haven’t seen any display from the higher resolution VDC chip, because I haven’t yet bought the right kind of monitor lead. I wouldn’t be able to program it without BASIC 8, though. I own an Amiga compatible Commodore monitor, which I think is compatible with the C128, but I’ve also seen 3 ended leads which plug into both VIC-II and VDC outputs, then feed these to a SCART plug which can be connected to a TV. I think the display from these is only mono, though. More news about this when I get a suitable lead, as well as a new computer desk or trolley to put it all onto!

BorderFlash1A flashing border program in 6502 Assembly Language made easy, thanks to the C128 MONITOR program

Before I go, I should point out that it’s fairly easy to make the screen border flash and ripple with the short listing on screen in the pic above. It’s partly due to not synchronising with the screen refresh rate, otherwise the screen would just change colour 50 or 60 times per second. If you click on the pic above once, you’ll get an enlarged version, then once more for an even bigger enlargement, but here’s a listing anyway.

LDA #$00
STA $D020
INC $D020
BEQ $1810
JMP $1805

I should point out that $D020 is 53280 in decimal (i.e. border colour memory location) and $FFE1 is a ROM routine I think is called STOPIN, which allows the user to break out of the program just by pressing the RUN STOP key (like ESC on other computers), instead of pressing RUN STOP and RESTORE, which resets the computer, including colours and variables, although your program would still be intact in RAM. TMR didn’t seem to understand this!

So, to sum up, the Commodore 128 was everything the Commodore 64 SHOULD have been!

Posted November 4, 2013 by C64hater in Uncategorized