VIC-2000 Expander. Modern Power Using Retro Parts!

Modding and Technical Issues

Moderator: Moderators

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 »

I considered the S-VID mod since my LCD also has that input, but it violates one of my rules... VIC-20 must remain stock.

I did some testing with an overlay tonight, and think that it may not be possible using the port supplied 1.022727 PH2 clock.
Here is why...

The main system clock is 14.318178 MHz, which is divided by the 6560 like this...

A) Divide by 4 = Color Burst @ 3.579545 MHz
B) Divide by 14 = 6502 Clock @ 1.022727 MHz

I was thinking that I could simply divide PH2 by 64 to lock to a line, but that math is slightly off.
1022727 / 64 = 15980.109375, which yields a 15.980 KHz line frequency.
Unfortunately, the 6560 generates a line frequency of 15.625 KHz.
What would happen is a slight shift to the right along all vertical edges of overlayed graphics.

I cannot think of a way to multiply PH2 by 14 using only 1980's logic components, which would have worked perfectly.
With an FPGA, it would be one line of Verilog, but I ain't doin' this the easy way!

I might get away with sampling the horizontal sync and reset the 6 bit counter on each line, but this might still be visible as a series of serrated edges, much like what you see when you say "POKE 36864,130" to put the VIC into interlace mode.

I may try this divide by 64 and lock to hsync idea anyhow.
It won't be much effort to throw an AVR, 512K of SAM and a few counters on a board to draw a bitmap over the VIC screen.
If it does work with acceptable shift, then I may continue with an overlay design.

If not, back to the VIC-20 dual display.

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 »

Had a few minutes to look through my 74 logic drawers and found an old friend that I have not used for a long time... 74HC4046.

This interesting IC is a PLL and VCO all in one.
If memory serves me correctly, I should be able to multiply the PH2 clock back up to 14.318 MHz.
I would first divide the 1.022MHz PH2 signal by 14 using 2 cascaded 4017 decade counters.
This 72KHz clock would then be fed into the 4046 along with the original 1.022MHz clock.

The result should be an output at 14.318MHz, synced with the original master clock feeding the 6560.
At least, that's how I remember the 4046 working. I may just have to wire one up to test.

If that works, it does solve the overlay problem.

Hope to get some bread-boarding time soon.
Cheers,

Brad
User avatar
eslapion
ultimate expander
Posts: 5458
Joined: Fri Jun 23, 2006 7:50 pm
Location: Canada
Occupation: 8bit addict

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

Post by eslapion »

Radical Brad wrote:I considered the S-VID mod since my LCD also has that input, but it violates one of my rules... VIC-20 must remain stock.
You can keep the VIC-20 'sort of' stock' if you make the S-Video mod as a socket inserted between the VIC-20's board and the 6560. I believe MRR19121970 sells this type of device.

The alternative is that you do your development in pure BW on the 6560 output side.
I did some testing with an overlay tonight, and think that it may not be possible using the port supplied 1.022727 PH2 clock.
Here is why...

The main system clock is 14.318178 MHz, which is divided by the 6560 like this...

A) Divide by 4 = Color Burst @ 3.579545 MHz
B) Divide by 14 = 6502 Clock @ 1.022727 MHz

I was thinking that I could simply divide PH2 by 64 to lock to a line, but that math is slightly off.
1022727 / 64 = 15980.109375, which yields a 15.980 KHz line frequency.
Unfortunately, the 6560 generates a line frequency of 15.625 KHz.
What would happen is a slight shift to the right along all vertical edges of overlayed graphics.
The number, 15.625kHz is not exact. You can see the characters on the VIC screen are well aligned vertically and each one of them requires 2 cycles of the 1.022727MHz clock to display so each scanline uses the same number of cycles to display and this number is certainly an integer.

The actual number of cycles is either 65 or 66, not 64.
I cannot think of a way to multiply PH2 by 14 using only 1980's logic components, which would have worked perfectly.
I can think of many which involves a mixture of digital and analog components, all from the 1980s. The C64 uses a 4/7 clock ratio between it's dot clock and color clock. On boards 250425 and afterwards it's all integrated in the MOS 8701 but boards 326298 and 250407 both use a PLL system which is documented in the publicly available schematics.

You could easily reproduce it and change the ratios.
Be normal.
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 that info. That confirms what I was thinking - that the published line frequency was slightly off.

I think the best way to get an overlay to work would be using a 74HC4046 PLL driven from the 1MHz PH2 clock at the expansion port.

Having access to a VIC synced 14.318MHz clock will be essential to making this work.
If I was allowed to pop the cover, I could just tap the main clock, or replace it completely with a canned oscillator.
... but rules are rules!

It will be important that the PLL generates a 14.318MHz output that is well synced to the 6560 clock, or it will be difficult to issue the new overlay video color burst with any accuracy. When the new video is drawn over the VIC screen, any non alpha pixels will override the original VIC pixels and the original color carrier.

Pins 20 and Y on the expansion port are free, so I may just tap the 14.318MHz clock in the VIC for now so I can do some basic testing to see if this new HD video overlay is going to be worth the effort. Will probably start with a conservative 320x200 overlay.

VIC-20 HAM mode perhaps?

Brad
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:Pins 20 and Y on the expansion port are free, [...]
In the CR variant of the VIC-20 mainboard, pin Y serves as AUDIO IN.
VIC-20 HAM mode perhaps?
You know the benchmark. ;)
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 the info, I will stick with pin 20 if I decide to do this testing.

For resolution, I will probably have my hardware draw a 352 x 200 or 704 x 200 frame over the VIC screen just to make it easier to sync with the original display. Going from my current VGA setup back to NTSC, I have 2 options for color space...


(1) 8 BITS -> L4+C4
This 256 color palette splits nicely as 4 bits for Luma and 4 bits for Chroma, giving 16 shades of 16 colors. I have used this many times in past projects, and it is great for sprites. You can actually store only the first 16 color sprite, and just shift the chroma by 16 to change its shading.

(2) 12 BITS -> L7 + C5
This will offer 4096 colors, and similar to the 8 bit palette, with 128 shades of 32 colors. The chroma generation circuitry is a bit more complex, as there are 32 independent propagation delays to deal with, each needing to be about 7.5 nanoseconds apart.

The reason for choosing only 5 bits for chroma in the second option is because the smallest propagation delay I can reasonably create is about 7-8ns through a 74HC245 buffer. Using 6 bits for color, would require a 64 individual 3.75ns delay steps, and that is more breadboard space than I care to use!

For now, I just plan to try a basic 256 color overlay to see how it looks.
If it works well using the PLL, then I will decide on the color space specifics.

Radar Rat race is going to look amazing with 4096 color sprites on a 320 x 200 screen!
... yeah, I will probably do a few conversions just for fun.

Brad
a4000bear
Vic 20 Amateur
Posts: 57
Joined: Sun Jan 27, 2008 10:01 pm
Location: Australia

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

Post by a4000bear »

Looks like a fascinating project. May even like to build one for myself one day.

Would it be possible for those of us with a PAL VIC-20?
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!
I never actually considered someone else wanting to do this project.
Perhaps, I should lay it all out in a single FPGA first, then it would be easy to duplicate.
I plan on beta testing a lot of it that way anyhow.
Everything would easily fit an older Spartan-3.

PAL should be no issue, just a timing change.
The largest hurdle is the PLL change from 14.318 MHz to 4.436 MHz.

Brad
User avatar
eslapion
ultimate expander
Posts: 5458
Joined: Fri Jun 23, 2006 7:50 pm
Location: Canada
Occupation: 8bit addict

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

Post by eslapion »

Radical Brad wrote:PAL should be no issue, just a timing change.
The largest hurdle is the PLL change from 14.318 MHz to 4.436 MHz.
On the NTSC C64, the color clock is 14.31818MHz which is internally divided by 4 by the VIC-2 to give the 3.579MHz we are familiar with.

On the PAL C64, the color clock is 17.7344MHz which is internally divided by 4 by the VIC-2 to give 4.4336MHz.

No big hurdle there...
Be normal.
MacbthPSW
Vic 20 Afficionado
Posts: 478
Joined: Wed Apr 06, 2005 1:56 pm

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

Post by MacbthPSW »

Hi Brad, Schema mentioned this post to me. I haven't logged in here for a while :) Cool project!

I should be able to set you up with a monitor if you need one, but most likely I've just got spare working 1802s or something like that. I need to take inventory. I think I've only got one working 1084 left. If you know how to repair CRTs you're welcome to a couple broken ones for free too :)
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 Robin, I am still in the drawing board phase on this project, and will may be in the market for a CRT if you do find one.
At this point, I am looking at several options here, and may evolve this project way outside my original plan.

Today I setup an AVR, and synced it to the VIC clock.
I then fed a few images over the original VIC screen, basically doing a genlock.
The image was far from perfect, even at 320 x 200.
NTSC... Never The Same Color!

I don't want to be held back on my graphics, as this is the most important aspect of the project.
Bringing the VIC out of hibernation to use it as my main programming machine requires decent graphics.
I have decided that no matter where this goes now, VGA is the only option.

I also want to keep the VIC hardware untouched, and allow the VIC to run all native software.
I know... this is going to be a difficult mix of priorities!

So for my next stupid VIC trick, I intend to slap together a scan converter in an FPGA.
I will digitize the NTSC signal coming from the VIC, and then lay it over a 640 x 480 VGA screen.
By multiplying the pixel size by 3, I will get 528 x 368 VGA from the VIC's 176 x 184 image.
This actually fits nicely if you consider a 56 pixel boarder all around the 640 x 480 screen.

By digitizing and completely rebuilding the NTSC signal, it will be rock solid on VGA, but also original.
When my new hardware is called upon, it will just assume that the screen is 640 x 480.

So what I will see is an original yet perfectly crisp VIC screen with the ability to use 640 x 480 bitmaps.
A few pokes in basic, and the Amiga Boing Ball will bounce around the VIC screen.
I will also mix the original VIC sound through one of the channels of my new system so all original games work.

And for the purist, my VGA also has a composite input, so I can still display the actual NTSC screen.

This is going to be cool... a custom scan converter that lays pixels in a 176 x 184 grid.
Unlike standard scan converters, mine will not suffer any jitter or phasing whatsoever.
This will probably be the most solid real VIC display ever made. As good as an emulator.

Here is a quick photo and video of the overlay test I did.
Yeah... Boing on the VIC. Looks really bad in 2 bit 320 x 200 resolution!

Image
The red is just an NTSC artifact. Images are only monochrome.

Scary video...
https://youtu.be/tybrUnu3fhY

Not sure when my next hacking time will be.
Until then...
Radical Brad
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 will get 528 x 368 VGA from the VIC's 176 x 184 image. [...] This is going to be cool... a custom scan converter that lays pixels in a 176 x 184 grid.
Maybe you shouldn't fixate too much on the pixel dimensions of the "standard" text screen. The VIC-I is able to re-size and re-position the display window within the display frame. For example, MINIGRAFIK and its assorted tools display 160x192 pixels as bitmap. Other programs (see the pinned post "New Frontiers in VIC-Hires-Graphics (Series)") do a overscan into the whole visible frame.

BTW, 176x184 is a resolution rather inconvenient to use as bitmap, as it requires an odd number of (text) lines, and graphic display modes often use double-height characters to span a bitmap of more than 2 KB size.
PAL should be no issue, just a timing change.
As long as you take into account, that PAL uses YUV instead of NTSC's YIQ, and every second line inverts the phase of the red colour difference signal, I'm fine with that. ;)

Edit:
Boing on the VIC.
Boing on the Amiga has a parabolic trajectory, and doesn't fly along a sine-wave. But then, I'm just nitpicking there. :lol:
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 the info.

Yeah.. that boing test was a real hack, I just coded it in an hour in AVR assembly.
Used a 256 byte sine lookup table to throw the ball around.

I spent some time working out magic frequencies to use for my genlock / digitizer / scan doubler test.
Using 14.31818 MHz into a PLL, I intend to multiply it like so...

(1) Base Clock = 14.31818 MHz
(2) PLL Output = 200.45452 MHz (PLL X 14)
(3) Line Capture = 40.090904 (Divide by 5)
(4) Pixel Clock = 20.045452 (Divide by 10)


The above clocks will drive a 400x300 VGA system that mixes the original VIC signal with the new GPU.
The VGA monitor will see standard timing for 800x600 MHz VGA @ 60Hz.

This timing divides nicely, and at 20.045MHz is more than close enough for any monitor...

Code: Select all

// [20 MHZ / 50 NS HORIZONTAL VIDEO TIMING FOR 800]
// HBP : 044 FROM 000 TO 043
// HPX : 400 FROM 044 TO 443 (9 BITS)
// HFP : 020 FROM 444 TO 463
// HSP : 064 FROM 464 TO 527(+)
// TOT : 528 (10 BITS)

// [60 HZ VERTICAL LINE TIMING FOR 600]
// VBP : 023 FROM 000 TO 022
// VLN : 600 FROM 023 TO 622 (10 BITS)
// VFP : 001 FROM 623 TO 623
// VSP : 004 FROM 624 TO 627 (+)
// TOT : 628 (10 BITS)

Clock (1) is the original VIC system clock frequency, and this will feed a Spartan-6 FPGA.
Clock (2) is the internal FPGA speed. All GPU logic will run at 200MHz.
Clock (3) will be used as a double speed line buffer, reading from external SRAM.
Clock (4) will drive the 400x300 VGA frame, which is half the normal 40MHz required for 800x600.


This fast timing will allow the digitizer 56 full cycles (200.45452 / 3.579545) for every VIC pixel it has to capture.
At this speed, the digitizer can easily make timing adjustments after each frame to ensure a dead solid lock.
The original VIC 176x184 display will be 100% rock solid on the new VGA output.

So the end result will be this...

- Original 6560 output of 176 x 184 displayed perfectly on a VGA monitor.
- New 400 x 300 or 400 x 600 GPU images overlayed on the VIC screen with pixel accuracy.

So much like the C64, the new images will be like sprites, fully independent of the original display, and alpha aware.

I have butchered one of my FPGA boards and bolted up 1 meg of 10ns SRAM for this test.
Here is the board with a new 14.318MHz clock, and wiring to a 4096 color R2R DAC...

Image

A meg of SRAM made by stacking parallel chips with CE lines separated...

Image

This simple platform should be great for all testing I need to do.
Since I woke up today to this view out the front window, I should get a bit more indoor time...

Image

Yeah... winter in October in the Great White North!
Looking on the bright side, I won't have to mow 10 acres of lawn for a while.

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 »

Had a few minutes in the basement lab tonight, and managed to get the VGA to display a screen full of random pixels from the SRAM attached to the FPGA. The monitor shows a perfect 800x600@60Hz signal, so my PLL math was good.

I was considering how to safely feed the output from the EL4581 sync separator (5V) to the FPGA (3.3v), and then I realized...

Why bother? I have the power of a 200MHz chip at my control, and it has endless LVDS inputs!
I will just look for the falling edge of the sync signals, and then time them into HSync and VSync.
How hard can that be? It should actually be better than the old-school approach as it will by synchronous to the clock.

Next time I have an hour to burn down here, I will whip up some Verilog and see how well that works.
I will use the VIC composite signal to extract the sync, and then use that to align my 400x300 video frame.
If I draw a single pixel vertical line to the VGA screen, it should be jitter free if this works.

Since my FPGA is now clocked at 200MHz, I have 56 cycles to sample every VIC pixel... it's almost an eternity!
It will be nice to see the original VIC up on the VGA with a rock solid display with zero artifacts and jitter.
Genlocked, digitized, remapped, and then scan doubled, all for the sake of my aging eyes.
I simply cannot imagine spending 5 hours coding 6502 assembly while looking at a glass CRT these days!

Later,
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 a few more tests with the PLL lock on the 14.318 VIC clock, it is suprising how close to the 800x600 VGA standard I managed to get.

Image

The correct line frequency for 800x600 is 37.879KHz, and the monitor is showing 37.9KHz.
It may just be rounding off the number for the menu display.

I am finding this VIC-20 hacking to be very interesting, and want to dig even deeper into my favorite machine.
In order to further my VIC understanding, I have decided to go off on a tangent project...

Vampire 6560 made from an FPGA!

Yeah, that should certainly increase my understanding of what goes on under the hood.
My new "Super 6560" will simply leech the original signals, leaving the VIC-20 unmodified.
This way, the original VIC NTSC output is left untouched and fully functioning.

My new video system will echo the VIC screen in crisp VGA, but have a built in GPU that is accessible to the VIC using some unused memory mapped space.

This should be a fun journey.
Looking over the 6560 datasheets now.

Radical Brad
Post Reply