VIC-2000 Expander. Modern Power Using Retro Parts!

Modding and Technical Issues

Moderator: Moderators

User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: VIC-2000 Expander. Modern Power Using Retro Parts!

Post by Mike »

Radical Brad wrote:I also have a rule to never use anyone else's code in my projects.
Sigh. :(
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VIC-2000 Expander. Modern Power Using Retro Parts!

Post by Radical Brad »

Now having said that, it only applies to the "VIC20" side of this project.
When this thing is done, I look forward to converting all of the great games and demos to work on the "65C02" side.

It would be cool to see other 6502 coders write something for my system as well.

But until everything is working, I intend to force myself into self directed learning.
I am only using the original 1980's VIC and 6502 texts as a reference.

To be honest, the old 1980's books are WAY more accurate than a LOT of the stuff I found on the net.
.... go figure!

Brad
Mike wrote:
Radical Brad wrote:I also have a rule to never use anyone else's code in my projects.
Sigh. :(
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: VIC-2000 Expander. Modern Power Using Retro Parts!

Post by Mike »

Look, I've been in the field of programming for over 30 years now. That skill not only involves writing good code, but also being able to read, understand and value other people's code.

Exactly that statement "I [...] never use anyone else's code in my projects" tells me, that however good you might program, and however you rate your own skills, you're effectively excluding yourself to learn from others.

As an example, I once found an exceptionally well thought out method to convert a number from binary to BCD using the decimal mode of the 6502. It is listed on 6502.org somewhere in its code repository, written by Andrew Jacobs. My client application uses it in a directory viewer to display the number of blocks for each file. I had no issues crediting Andrew for this routine in the manual of MINIPAINT.
Radical Brad wrote:I look forward to converting all of the great games and demos to work on the "65C02" side.
The point being ...?
It would be cool to see other 6502 coders write something for my system as well.
Unlikely, given its prospected one-of-a-kind nature, given that it would only solve your problems, not theirs.

...

I'll continue to follow this thread, sure - but you won't read that much anymore from me concerning your project.
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VIC-2000 Expander. Modern Power Using Retro Parts!

Post by Radical Brad »

Well, yes and no to that.

Everything I know about 6502 came from others.
A lot of effort went into all of the 1980's books I am currently using to learn from.

But yes, I am limiting myself to only information that requires a lot of self directed "some assembly required" learning.
I would never hit google for "VIC-20 keyboard routine", and use any code I found.
My keyscan routine is based on some of the info I found here regarding the VIA drive and port addresses.
The rest, I worked out for myself.

When I go back to optimize all of my code, I am sure I will learn a lot more as well.

I work in a machine shop for a living, and do not need to be the best 6502 programmer possible, as it is just a hobby for me.
This project is for fun only, and fun to me means being way over my head and constantly challenged.
For this reason, I only seek assistance when I am at the utter end of my frustration limits.

Ok, now back to the task at hand... thousands of wires, hundreds if ICs, and code I must learn.

Brad
Mike wrote: Exactly that statement "I [...] never use anyone else's code in my projects" tells me, that however good you might program, and however you rate your own skills, you're effectively excluding yourself to learn from others.
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VIC-2000 Expander. Modern Power Using Retro Parts!

Post by Radical Brad »

So far it looks like my 512K paging scheme will work.

I added a latch to the upper 4 bits of the 512K SRAM that boots and runs the Operating System, and I can have the VIC swap out the upper 32K on the fly. This offers 16 pages of 32K segments, each with a seperate part of the Operating System.

On power up, the VIC will boot to a "User Console", which looks and feels much like the original Basic console.
Using functions keys, any of the other 16 pages can be instantly swapped.
F1 might bring up the Assembly IDE, and maybe F2 will bring up a Sprite Editor.

Just have to tidy up the wiring and make a schematic.
I typically do not bother with schematics, as this kind of thing is mostly instinct, but it is going to get quite complex.

Will post a few schematics soon, showing where the project is at.

Cheers!
Radical Brad
norm8332
Vic 20 Nerd
Posts: 626
Joined: Sun Nov 13, 2016 11:04 am
Location: USA

Re: VIC-2000 Expander. Modern Power Using Retro Parts!

Post by norm8332 »

If you made a schematic, I'm wondering if the whole thing or most of it could be done in a FPGA...that would be cool as well. This is an exciting project and I'm sure a lot of people are following this based on views, but it just fly's over a lot of their heads (as well as mine). :D
“In religion and politics people’s beliefs and convictions are in almost every case gotten at second-hand, and without examination... whose opinions about them were not worth a brass farthing.”

-Autobiography of Mark Twain
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VIC-2000 Expander. Modern Power Using Retro Parts!

Post by Radical Brad »

Thanks for your comments.
I build mechanical things for a living, so I often fly over my head as well.
Not knowing any better is sometimes an advantage, because I try anyhow.
Many times, with positive results!

It absolutely can be done in a single FPGA, and a few months ago I did that exact thing...

https://www.youtube.com/watch?v=CNVghL233FI

That is a real 65C02 talking to the FPGA, which is simulating most of the logic on the massive breadboard.
My original "Vulcan-74" project is similar to this current one (logic section), but used only a 65C02.
This project should offer a lot more, since the VIC-20 is in control!

I hacked up a MOJO FPGA board, and added 2MB of SRAM for graphics storage...

Image
The chip in the bottom right is a 65C02

The results were not bad, but nothing compared to what the retro logic board could do.
Ironic, but there is simply no (affordable) FPGA that has the IO required to emulate my breadboard.

I usually rate many of my graphics projects on how many balls it can move!
The FPGA variant could swing 16 boing balls of 100x100 size, and 256 colors...

Image
16 Boing Power!

In comparison, the 1980's logic based breadboard could easily move 100 balls of the same size with 4096 colors!!
I expect the same or better results from this V2K project, as I have learned a few new tricks since then.

I stopped using modern parts like FPGAs and Micro-controllers for my retro projects, as it took a lot of the challenge from it!
For me, the fun part is doing something on a breadboard that the experts say cannot be done.
40MHz clock speed, insane capacitance, endless cross-talk, and wires up to 2 feet in length!
Hackers do not fear "the rules"!

Verilog is actually easier to learn than even C, so it is a great way to put power in your hands if you want to experiment with seemingly endless speed. The MOJO FPGA board is a nice starting kit as well.

The 6502 enjoyed commanding 1000 Sprites!...

https://www.youtube.com/watch?v=GrsY4SpFpHs

So to answer your question... hell yeah it can be done in a single low end FPGA like a Spartan-6!
There was even enough room left in that FPGA to emulate the 6502 as well.
.... but that would be wrong, just wrong!

Cheers,
Radical Brad

norm8332 wrote:If you made a schematic, I'm wondering if the whole thing or most of it could be done in a FPGA...that would be cool as well. This is an exciting project and I'm sure a lot of people are following this based on views, but it just fly's over a lot of their heads (as well as mine). :D
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VIC-2000 Expander. Modern Power Using Retro Parts!

Post by Radical Brad »

Over the week, I managed to pick away at the first part of the schematic (The Memory Expansion System).
There are some untested changes I hope to verify this weekend, but most of it is know to work...

Image
The Memory Expansion System - right click on View Image for larger view.

This section is really just the extended memory that the VIC runs the new OS from.
The 512K is broken into 16 pages of 32K, each having a different "hot swappable" program.

Since the internal VIC memory is shared, I can hot switch between pages to transfer information.

An example of this might be during the creation of a new game, I will swap from the Assembler IDE into the Sprite Editor, and then return with a set of graphics coordinates to place in the code. I could pop out to the 6502 Help Page to check out the cycle count for a certain instruction, and then swap over to the Music Tracker to work on the game into music.

With 16 pages (Applications) available, I should have a very complete development environment running on my VIC-20!

Some explanation of how the posted schematic works...

245.01 and 02 are bidirectional Data Bus buffers. 01 controls access to the OS Memory, and 02 sends read or write requests to what will be the multiple memory mapped devices such as Sync Memory, 6502 Memory, and low level logic functions.

245.03 and 04 are the address buffers.
These buffers keep load driving to a minimum for the VIC, and being 74HC logic, are almost invisible anyhow.

157.01 controls the Boot Mode, and has the job of holding the VIC in reset as the OS memory is populated on power up.
The OS Memory is SRAM, but it is boot loaded by ROM on power up.
This lets me use self modifying code and easily upgrade the OS when required.
Once the OS Memory is loaded, the 157 swaps all functions back to the VIC, and takes it out of reset.

574.01 is a data latch to the current page of the OS Memory. 16 pages requires 4 bits from the Data Bus.

To achieve seamless hot swapping of OS Memory pages, I have a common "Kernal2K" routine in the internal VIC memory that is accessed to control page swapping. This way, the changeover of memory does not cause any glitches in the operation. The secondary 65C02 that will run the assembled code also uses this banking scheme to get access to more memory, 8 pages of 64K in that case.

One other feture of this system is that it can be totally disabled without unplugging from the expansion port, leaving the VIC-20 starting up in unexpanded mode. There is a "Run" button on the V2K system that triggers the Boot Mode, so the VIC actually starts up unaware that it has super powers. Since I also like to program in "native" mode, this was a requirement.

If I get my chores done today, I might have time to put down all the new wires and run some tests tonight.
I pulled up all chips and wires the other day, as I didn't like where the VIC-20 plug was located on the breadboard.
Yeah, like I said... this is a project that will require mucho patience!

Cheers!
Radical Brad
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VIC-2000 Expander. Modern Power Using Retro Parts!

Post by Radical Brad »

Doing multiple R/W tests on 32,768 memory locations takes some time in Basic!

Image

Oh well, I am cleaning my lab today, so the VIC can churn away while I work.

Once the memory tests are good, I plan on adding some final wiring.
After that, the second external 6502 gets put down.

Brad
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VIC-2000 Expander. Modern Power Using Retro Parts!

Post by Radical Brad »

Forgot to mention that I also have 2.2K pullups on all TTL outputs from the VIC.
This brings up the level to the 3.5V low threshold of CMOS logic.

... some laws I cannot break as much as I try!

I know there are 74HCT devices available, but they are not easy to find in DIP format.
Resistors do the job just as well.

Brad
User avatar
mingle
Vic 20 Dabbler
Posts: 89
Joined: Sun Sep 25, 2016 2:38 am
Location: Melbourne, Australia

Re: VIC-2000 Expander. Modern Power Using Retro Parts!

Post by mingle »

Great Stuff Brad!

I'm no hardware-hacker (I'm barely a BASIC programmer!), but find this stuff fascinating, as do many other members, I'm sure.

I reckon you were born to late - you would've been a champ back in the CBM hey-days!

Cheers,

Mike.
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VIC-2000 Expander. Modern Power Using Retro Parts!

Post by Radical Brad »

Thanks!

It's great to see my VIC coming to life again after so many years in the original box!

I have read the amazing book "On The Edge : The Spectacular Rise and Fall of Commodore" at least 10 times now, and do wish I was working there in the rebellious days. That would have certainly been a good fit.

The response to this project has been unexpected for sure.
I have been contacted several times regarding the FPGA "Sub Project" I started, and have decided to keep it on the burner as well.
This will work out nicely, as I often have time away from my basement lab so I could be working on a portable side project.

I will start a new thread for that one soon, and give it a name as well.
The concept is similar (retargeted and expanded graphics to VGA), but can be easily reproduced.
And like this project, the VIC will remain 100% stock.

Time is scarce again for a while, but I will try to post something interesting again soon.

Cheers, and thanks for the comments.
Radical Brad


mingle wrote:Great Stuff Brad!
I'm no hardware-hacker (I'm barely a BASIC programmer!), but find this stuff fascinating, as do many other members, I'm sure.
I reckon you were born to late - you would've been a champ back in the CBM hey-days!
Cheers,
Mike.
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VIC-2000 Expander. Modern Power Using Retro Parts!

Post by Radical Brad »

Waiting for parts to arrive is like waiting for paint dry!

I did end up finding a stable multi-source for actively produced level translators in DIP format, so I put hardware design on hold until I could get a few for testing.

74LVC245

Available at my 2 favorite suppliers as active stock...

https://www.digikey.ca/product-detail/e ... -ND/377483
https://ca.mouser.com/ProductDetail/Tex ... UzQAbVc%3d

This is basically a TTL <-> CMOS friendly version of the bidirectional 74HC245 buffer I often use.
This level translator will work on both my 5V COMS based logic board as well as my 3.3V FPGA version.

I decided to use a proper level translator after noticing how weak the drive from the 6502 bus really was.
The resistors I used to pull-up levels required some tweaking on the 3 different VIC-20 units I tested.

Sometimes you just have to do things the "proper" way, even on the Hacker's Workbench.

Until I get my new hardware, I am continuing to work on the VIC-20 Operating System.

Later,
Radical Brad
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VIC-2000 Expander. Modern Power Using Retro Parts!

Post by Radical Brad »

After a bit of a break, my VIC-2000 Project is back on the bench.

The FPGA based tangent project has flattened out my learning curve quite a bit, as I was able to rapidly design and test ideas that can now be made into real hardware using the 7400 logic gates. It was fun to see how far I could push the VIC Expansion Port timing to see where it would start to come apart. The VIC is quite robust.

I also figured out why I was getting failures when Boot Loading some cartridge images. Seems that some of them actually try writing to their own code-space, which is in ROM! Seems very strange that a programmer would do a write to a location they know has to be in ROM, but that was certainly the problem. Once I added a "ROM Lock" feature, all came carts worked perfectly. I will now be adding this feature to this project as well. I could only come up with 2 possible explanations for this ROM writing peculiarity; sloppy coding, or some kind of dorky copy protection scheme. Dorky because it would take no effort at all to simply scan the binary for any instruction trying to write to BLK1,2,3,5 and then fill the space with NOPs.

I have also decided to take one last shot at getting the full 640x480 screen with 4096 simultaneous colors.
Right now, my timing can only produce 400x300, but I have a new idea to try.

Ironically, the FPGA could only manage 265 colors at 400 x 300 due to the way the memory was shared between VGA Generator, Sync generator, GPU, Sound System, and VIC-20. To come close to what the Logic based version will be capable of, I would have needed an FPGA with 300+ IO Pins! The little Spartan-6 I was using only gave me 86 IO pins, and every last one was accounted for.

My Logic based version has no such limitations, and actually has 6 individual dedicated memory buses, one being as large as 16 Bits of Data, and 20 bits of Address, running at 25MHz. Even the Double Buffers in the Frame Generator are completely independent from all other memory paths, so the VIC-20 never has to wait to do anything.

I am looking forward to getting back to plugging in real chips and wires rather than simply writing code and pressing the "Synthesize" button on my PC.

it is so much more satisfying to be up against the bare metal (and myself) rather than the Monkey under the hood in the modern compiler, synthesizer, and development tools of the day. I actually find debugging on real hardware to be a lot easier as well. Plug in a wire wrong and your video goes straight to hell. Half a screen? Easy... must be the 10th address bit on the Sync Generator! With FPGA tools and compilers, you are at the mercy of the Synthesizer Monkey to turn your code into something workable. Most of the time I find myself fighting against the tools.

Get ready VIC, the hacking shall now continue!

Radical Brad
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VIC-2000 Expander. Modern Power Using Retro Parts!

Post by Radical Brad »

From here on, I will be creating schematics as I redo my boards since I have done enough testing, and know know what will work and what will not. Timing from 400x300 (20MHz) up to 640x480 (25MHz) may still be a bit of a pipe dream, but the circuitry remains the same either way.

Changing from 400 to 640 only involves swapping the master oscillator, and the rest is done by the VIC-20 on startup, since the Sync Generator is fully programmable. So if 25 MHz breaks my breadboard, I will go back to 400x300 resolution.

The schematic for VIC-2000 will be massive, so I am going to break it into segments as layed out in clusters of breadboard rows, and by general function. This will also help when I get to the point where it's time to hand wire the real "PCB". By PCB, I mean a hand made matrix of interlaced copper strips holding each IC, which is then hand wired point to point. more on that insanity later.

This is where I plan to start...

Image
VIC-2000 Video Data Switcher (VDS) Schematic

This VDS lives at the very top of the board, and is responsible for several functions...

- Driving the 4096 Color Anaolog DAC as 3 sets of 4 bits to the VGA Monitor.
- Driving Horizontal and Vertical Sync to the VGA Monitor.
- Syncing all signals back into alignment with the Master Pixel Clock (CLK.25).
- Switching between two 12 Bit Video Data buses during the V.Sync Period.

The VDS is a simple circuit consisting of only 4 counters, 4 buffers, and 12 resistors.
Signals FLIP.A and FLIP.B turn on 2 of the 4 buffers. The signals are always 0,1 or 0,1.
"FLIP" is a memory mapped command to the VIC-20, and it swaps A with B on the next VSync.
The 12 bit output from the active buffers feed the load inputs on the 4 bit counters.
The counters are clocked by CLK.25, and pass their data to the DAC on the rising edge.
Signal A.LINE is a blanking signal that controls when pixels are allowed to be drawn.
if A.LINE is low, then all data entering the counters is cleared. If hi, then the data passes.

Signals H.SYNC, V.SYNC, and A.LINE come from the Sync memory, which is loaded by the VIC-20.
This circuit has been proven to work well, and should have no problem with the 25MHz clock.

One obvious question would be... why not use 15 bits (3x5) for the color DAC instead of only 12?
There are actually 2 good reasons for using only 12 of the available 16 bits on the VDAT bus.

First, I am using 3 bits of the data for very low level Sprite Generator control.
Data for Sprites includes signals to wrap the X and Y counters. An EOF signal is also included.
This allows the Sprite generator to run at maximum speed thanks to very low propagation.
With only 13 bits remaining, the next even split was 3 sets of 4 bits.

The other reason is because 12 bits compresses nicely into nibbles.
A 64 pixel wide sprite for instance, can fit into 48 pixels per row.
Even though I have 4MB available on this design, it is still important to conserve space.

I will be placing this circuit very soon, since nothing else can be tested until it is working.
This shall now become the first real step in the design of The VIC-2000 Project.

Up to this point, I have been in "smoke testing and learning" mode.
Luckily, there has been more learn than smoke so far, although I did power reverse one buffer!
Seems that bread-boarding with Captain Morgan is not always the best plan.

Cheers!
Radical Brad
Post Reply