6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue Apr 23, 2024 9:25 am

All times are UTC




Post new topic Reply to topic  [ 46 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
PostPosted: Fri Apr 06, 2018 2:29 am 
Offline

Joined: Wed Feb 12, 2014 1:39 am
Posts: 172
Location: Sweden
cbmeeks wrote:
LIV2 wrote:
It’s possible to fit a VGA controller in a 64 macrocell CPLD (Plus a ROM, Shift register and some RAM) I have some VHDL for it but am on vacation at the moment


Are you still on vacation? :-D

I would be interested in seeing the VGA/CPLD code you have.

Thanks!


Hey sorry about this late late late response!
I will post this later today

I've got it doing something like 80x30 Text with colour at 640x480 I think.


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 07, 2018 5:35 am 
Offline

Joined: Wed Feb 12, 2014 1:39 am
Posts: 172
Location: Sweden
My VHDL at the moment is as follows, some friendly posters have given me some tips to improve it and I haven't had time to implement them but it should work as is.

Code:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity vga6502 is

    port
    (
        clk       : in std_logic;
        sl        : out std_logic;
   latch      : out std_logic;
        reset     : in std_logic;
        ma        : out std_logic_vector(11 downto 0);
        ra        : out std_logic_vector(3 downto 0);
        blank      : out std_logic;
        hsync     : out std_logic;
        vsync     : out std_logic
    );

end entity;

architecture behavioral of vga6502 is
signal CLK8:   std_logic := '0';
signal CLKDIV: integer range 0 to 3;
signal SRDIV:  unsigned (2 downto 0);

constant H_TOT: integer := 100;
constant H_FP:  integer := 2;
constant H_BP:  integer := 6;
constant H_SW:  integer := 12;

signal H_CNTR:  integer range 0 to 100;
signal H_END:   std_logic := '0';
signal H_BLANK: std_logic := '0';

constant V_TOT: integer := 525;
constant V_FP:  integer := 10;
constant V_SW:  integer := 2;
constant V_BP:  integer := 33;

signal V_CNTR: integer range 0 to 525;
signal V_BLANK: std_logic := '0';

signal CH_CNTR: integer range 0 to 4096;
signal RW_REG:  integer range 0 to 4096;
signal CH_CLK:  std_logic := '0';
signal SL_CNTR: integer range 0 to 15;

begin

blank <= (V_BLANK OR H_BLANK);

---
--- Clock Divider
--- Divides 25.175 Mhz Pixel clock by 8, i.e to load one character every 8 clocks
---
charclk:
process(clk, reset)
    begin
    if reset = '1' then
        CLKDIV <= 0;
        elsif (rising_edge(clk)) then
        if (CLKDIV = 3) then
            CLK8 <= NOT(CLK8);
            CLKDIV <= 0;
        else
            CLKDIV <= CLKDIV + 1;
        end if;
     end if;
end process;

--
-- Horizontal
--

H_cnt:
process(clk8, reset)
begin
    if (reset = '1') then
         H_CNTR <= 0;
    elsif rising_edge(clk8) then
        if (H_CNTR = (H_TOT - 1)) then
            H_END <= '1';
            H_CNTR <= 0;
        else
            H_END <= '0';
            H_CNTR <= H_CNTR + 1;
        end if;
    end if;
end process;

H_display:
process(clk8)
begin
    if rising_edge(clk8) then
        if (H_CNTR >= (H_SW + H_BP)) AND (H_CNTR < (H_TOT - H_FP)) then
            H_BLANK <= '0';
        else
            H_BLANK <= '1';
        end if;
    end if;
end process;

H_sync:
process(clk)
begin
    if rising_edge(clk) then
        if (H_CNTR < H_SW) then
            HSYNC <= '0';
        else
            HSYNC <= '1';
        end if;
    end if;
end process;

---
--- Vertical
---

V_cnt:
process (H_END, reset)
begin
    if (reset = '1') then
        V_CNTR <= 0;
    elsif falling_edge(H_END) then
        if (V_CNTR = (V_TOT-1)) then
            V_CNTR <= 0;
        else
            V_CNTR <= V_CNTR + 1;
        end if;
    end if;
end process;

V_display:
process(H_END)
begin
    if falling_edge(H_END) then
        if (V_CNTR >= (V_SW + V_BP)) AND (V_CNTR < (V_TOT - V_FP)) then
            V_BLANK <= '0';
        else
            V_BLANK <= '1';
        end if;
    end if;
end process;

V_sync:
process(H_END)
begin
    if falling_edge(H_END) then
        if (V_CNTR < V_SW) then
            VSYNC <= '1';
        else
            VSYNC <= '0';
        end if;
    end if;
end process;

---
--- Scanline Counter
--- Outputs RA row address to Char Rom
---

SL_cnt:
process(H_END, reset)
begin
    if (reset = '1') then
        SL_CNTR <= 0;
    elsif falling_edge(H_END) then
        if (SL_CNTR = 15) or (V_BLANK = '1') then
            SL_CNTR <= 0;
        else
            SL_CNTR <= SL_CNTR + 1;
        end if;
    end if;
end process;

RA <= std_logic_vector(to_unsigned(SL_CNTR, RA'length));

---
--- Char Row Clock, increment row count every 16 scanlines
---
CHCLK:
process(SL_CNTR)
begin
    if (SL_CNTR = 15) then
        CH_CLK <= '1';
    else
        CH_CLK <= '0';
    end if;
end process;


RW_cnt:
process(reset,CH_CLK,V_BLANK)
begin
    if (reset = '1') OR (V_BLANK = '1') then
        RW_REG <= 0;
    elsif falling_edge(CH_CLK) then
        RW_REG <= RW_REG + 80;
    else
        RW_REG <= RW_REG;
    end if;
end process;

---
--- Char Counter
--- Generates linear memory addresses
---

C_cnt:
process(reset,CLK8)
begin
    if (reset = '1') then
        CH_CNTR <= 0;
    elsif rising_edge(CLK8) then
        if (H_CNTR >= (H_SW + H_BP)) AND (H_CNTR < (H_TOT - H_FP)) then
            CH_CNTR <= CH_CNTR + 1;
        else
            CH_CNTR <= RW_REG;
        end if;
    end if;
end process;

MA <= std_logic_vector(to_unsigned(CH_CNTR, MA'length));

---
--- Shift Register control
--- load the shift register every 8 clocks
---

SR_ctrl:
process(reset,clk)
begin
    if reset = '1' then
        SRDIV <= (others => '0');
    elsif rising_edge(clk) then
        if (H_CNTR >= (H_SW + H_BP)) AND (H_CNTR <= (H_TOT - H_FP)) then
            SRDIV <= SRDIV + 1;
        else
            SRDIV <= (others => '0');
        end if;
    end if;
end process;

--- Load shift register
SL <= '0' when (SRDIV = "0" AND (CLK = '1')) else '1';
--- Load color latch
LATCH <= '1' when (SRDIV = "0" AND (CLK = '1')) else '0';

end behavioral;


The circuit I'm using for 16 colors (missing the CPLD itself)
The ROM is the character generator.
If you only want B/W you can omit the top half of the circuit (the top ram holds the color information, the '273 latches this and the 157 switches between upper/lower nibble for foreground/background color
You can simply gate the Q output of the shift register with BLANK and send the result directly to the monitor.
Image


Top
 Profile  
Reply with quote  
 Post subject: Re:
PostPosted: Tue Apr 10, 2018 12:24 am 
Offline

Joined: Fri Jun 03, 2016 3:42 am
Posts: 158
BitWise wrote:
I stumbled across a new PIC chip (24FJ256DA210) that contains an embedded graphics generator, CLUT and 96K of RAM (enough for QVGA 320x240 @ 8 bpp) that looks interesting. Slightly higher resolutions and colour depths are possible if integrated with an external RAM. The graphics controller can do some simple blitter functions, character drawing and image decompression.

Its designed to drive a LCD screen directly but looks like it could be made to output VGA compatible signals. No sprites but you would have almost 100% of 16 MIPS to program anything like that with.

The chip runs at 3V3 but the pins for I2C and SPI are 5V tolerant. The 100pin chips have an EPSP interface that in slave mode would allow them to attached as a 4 addressable memory locations on an 8-bit data bus - all control signals would have to be 3V3 and you couldn't have external RAM.

Not bad for less that $8.

That PIC chip looks pretty awesome! Could be the basis for a game machine.
I don't have any interest in those first-person shooter games --- I think they are a negative influence on society.
I'm thinking about more old-school games.

I wonder if one of the 6502 soft-core processors could be upgraded to simulate the Commodore-64, including graphics and music. I think people who want to write video games would be more interested in starting with a familiar platform, such as the venerable C64, rather than start from scratch with a big learning curve on a new design. The idea would be that the processor would run 6502 code, so it could run the legacy C64 programs. It would have 16-bit registers though, so new games could be written more easily, would run faster, and would take up less memory.

The M65c02A would be a possible basis for this --- I have studied it and I think it is a better target for Forth than the 65c816 --- the code may be more bloaty though, because of all those prebytes.

Are there any other soft-core processors that run old 6502 code, but also have 16-bit registers to allow new programs to be more efficient?

What is the legal status on the C64? Is it legal to build a modern C64 that runs old C64 code?
I wonder what the legal status is of all those old C64 cartridges --- it is possible that the owners would just give away the right to distribute them freely --- it is not like there is any further expectation of making money on them.

I'm familiar with the Apple-IIc, and it didn't really compare very well with the C64 --- it is not worth thinking about today.
I'm not familiar with the Atari-2600 --- I don't think it was quite as good as the C64, but a lot of people liked it --- it might be worth thinking about.

This is a 6502 forum, so everybody here likes the 6502. :)
Other than running legacy 6502 programs though (such as C64 cartridges), why be interested in the 6502? It seems unlikely that anybody would choose to write a new program in 6502 assembly-language when processors such as that PIC chip are available, and are orders of magnitude more capable.


Top
 Profile  
Reply with quote  
 Post subject: Re: Re:
PostPosted: Tue Apr 10, 2018 1:08 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8426
Location: Southern California
Hugh Aguilar wrote:
Other than running legacy 6502 programs though (such as C64 cartridges), why be interested in the 6502? It seems unlikely that anybody would choose to write a new program in 6502 assembly-language when processors such as that PIC chip are available, and are orders of magnitude more capable.

This is from the Intro page of the 6502 primer:

In past topics, billylegota said, "I love the 6502 for its simplicity. It is probably the best microprocessor for beginners who want to be able to build their own microcomputer and understand how the entire thing works;" and further down, Ed replied, "I second this - and it's more or the less the reason most of us are here." commodorejohn added, "The 6502 is the most comfortable, usable minimalistic design I've ever encountered - just enough features and functionality to do pretty much anything you need, and simple enough that it's easy to learn how to put the individual puzzle pieces together to accomplish what you want. Plus, being as cycle-efficient as it is certainly doesn't hurt."

Regarding programming, Michael Barry said, "Yeah, programming the 6502 is like a guilty pleasure for my brain. It seems to know what I'm trying to say, and it just does it without complaining about the atrocious way I said it." And comparing 6502 programming to PIC programming, Icy said, "65x02 is wonderful. Programming 65x02 feels like vacation; you cannot get tired doing that. It is natural, logical, it doesn't give you headache."

See also Embedded Advisor magazine's Nov 2017 issue's article about Western Design Center starting on page 10, and the subsequent article starting on page 14 that ranks WDC in the top 20 IP and design solution providers. Bill Mensch is on the cover.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: Re:
PostPosted: Tue Apr 10, 2018 1:21 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8140
Location: Midwestern USA
Hugh Aguilar wrote:
Other than running legacy 6502 programs though (such as C64 cartridges), why be interested in the 6502? It seems unlikely that anybody would choose to write a new program in 6502 assembly-language when processors such as that PIC chip are available, and are orders of magnitude more capable.

You'd be amazed at how much the 65xx family continues to be used in present-day products. Many 6502s are hidden from view, so the average person doesn't know they are using one.

Incidentally, the W65C02S is one of the very few MPUs certified for use in implantable medical devices, such as defibrillators. It's patent that someone had to write the required software to make the defibrillator work.

As for whether "that PIC chip" is orders of magnitude more capable than a 65C02, that's debatable. The designer who uses a PIC is constrained by what is in the PIC. The designer who uses a 65C02 and the appropriate supporting silicon is limited only by his imagination. The more you integrate things the more inflexible they become.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: Re:
PostPosted: Tue Apr 10, 2018 3:59 am 
Offline

Joined: Fri Jun 03, 2016 3:42 am
Posts: 158
GARTHWILSON wrote:
Regarding programming, Michael Barry said, "Yeah, programming the 6502 is like a guilty pleasure for my brain. ..."

I like the 6502 also! :D The ISA was pretty clever:
  • The (zp),Y addressing-mode was very cool, allowing the processor to access 64KB indirectly while yet having 8-bit registers.
  • The zp,X addressing-mode worked well for the Forth data-stack.
  • Having only three 8-bit registers allowed very fast entrance and exit code in ISRs, making the 6502 useful as a micro-controller, not just in desktop-computers.
By comparison, programming the Z80 was like walking barefoot through a room with broken glass on the floor --- if you watch your step, you can get through it --- if you are not careful, it can be a painful experience.

The 6502 is a guilty pleasure though --- I am reminded of the song "1985" by Bowling for Soup about the woman who is preoccupied with 1985.

I think a game-machine based on the 6502 has potential to find a market, even today. I suggested that it be the C64 so it could run legacy cartridges, but that it have a 16-bit mode so it can be programmed easily and generate efficient code --- realistically, nobody under the age of 50 is going program the 6502 with its 8-bit registers today.
You want the game-machine to be faster than the C64 so the games can have some strategic depth and be fast-moving, but you want the game-machine to be as simple as the C64 so teenagers can figure out how the graphics and music work so they can write their own games --- it is no good if teenagers can't write their own games, but instead buy commercial games written by professionals.
The Arduino has some popularity among teenagers --- but the Arduino is very limited in what it can do --- the Arduino is pretty boring compared to a machine that can play games such as Ms. Pacman and Centipede.

American teenagers spend too much time listening to mysogony-promoting drug-promoting music, playing violence-promoting video-games, and texting each other about how they feel depressed and bored --- if they were introduced to 6502 assembly-language, and wrote their own video-games, they would be happier. :D
I liked the C64 when I was a teenager --- should be liked by modern teenagers too!


Top
 Profile  
Reply with quote  
 Post subject: Re: Re:
PostPosted: Tue Apr 10, 2018 6:15 am 
Offline

Joined: Tue Nov 10, 2015 5:46 am
Posts: 215
Location: San Jose, CA
Hugh Aguilar wrote:
I think a game-machine based on the 6502 has potential to find a market, even today.
https://thec64.com.

Quote:
but you want the game-machine to be as simple as the C64 so teenagers can figure out how the graphics and music work so they can write their own games
Teenagers who want to write games, and then share those games with their friends might not want to learn the details of a computer made before their parents were born. Something like https://www.youtube.com/watch?v=xGmXxpIj6vs might be more appropriate.

Quote:
I liked the C64 when I was a teenager --- should be liked by modern teenagers too!
The C64 was the state of the art in home computers when I was a teenager. That's one of the big reasons that it, and the Atari 8-bits, were so exciting. Every few months a new computer would come to market, and they were all special and exciting in some way. Then came the 16/32 bit era of Atari ST and CBM Amiga. By the early 90s it was the PC era, and then 3Dfx, NVIDIA and others, with expertise out of Silicon Graphics, came out with the hardware 3D graphics era, which became the GPU era.

The 8-bit era remind us of our youth, when technology was new and exciting, and being able to string a few lines of assembly language made us God-like beings in a land of the slow, BASIC, unwashed. Today, teenagers who really want to get into games will pick up the freely available Unity or Unreal engines and play... and learn... just like we used to in the 70s and 80s.

Engineers from the 50s and 60s would tsk at us kids in the 80s and our advanced integrated circuit graphics... playing with this technology with no appreciation of where it came from... what came before. Let me tell you about the first NOR gate... the first flip flop. Let me show you pong on this oscilloscope. Let me tell you about the first frame buffer. You kids with your Commodore 64 think you know something moving those colorful sprites around... but you know nothing.

So here we are, now the kids are programming games straight into their browser windows... or downloading a state-of-the-art 3D game engine and building rich worlds to explore. How dare they.


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 10, 2018 7:14 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10792
Location: England
Hugh: Let's not make every thread we touch a thread about all of our thoughts on everything, please. This is a thread about generating video signals. If you have thoughts about what platforms are of interest to game-writers, find or start a thread about that. If you have thoughts about what is good or bad for society, best to express them somewhere other than this forum. It turns out we all have thoughts about that, and there are different schools of thought, and it helps to keep debates about that to their own spaces.

Garth: if you could split this thread, that would be great.

Everyone: please try not to be led astray.


Top
 Profile  
Reply with quote  
 Post subject: Re: Re:
PostPosted: Tue Apr 10, 2018 7:18 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8426
Location: Southern California
sark02 wrote:
Teenagers who want to write games, and then share those games with their friends might not want to learn the details of a computer made before their parents were born.

Wow, that would be some pretty young parents! The C64 came out in Aug '82, and was discontinued in Apr '94, 24 years ago. Parents of a 13-year-old today would have to have become parents no later than their 11th birthdays! :lol:

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: Re:
PostPosted: Tue Apr 10, 2018 6:25 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8140
Location: Midwestern USA
GARTHWILSON wrote:
Parents of a 13-year-old today would have to have become parents no later than their 11th birthdays! :lol:

That's been known to happen in certain areas of the country. :shock:

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: Re:
PostPosted: Tue Apr 10, 2018 9:24 pm 
Offline

Joined: Tue Nov 10, 2015 5:46 am
Posts: 215
Location: San Jose, CA
BigDumbDinosaur wrote:
GARTHWILSON wrote:
Parents of a 13-year-old today would have to have become parents no later than their 11th birthdays! :lol:

That's been known to happen in certain areas of the country. :shock:
Come on, now... I said "made before", not "discontinued before"... So a 13 year old today (born 2005) could have parents who were 22 (born in '83). Still young, but not egregiously so.


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 10, 2018 9:34 pm 
Offline

Joined: Sun Oct 14, 2012 7:30 pm
Posts: 107
I am using the VS23010 in a project. I am using the parallel and SPI interfaces. It's easy to use and you can do off-screen blitting by setting source/destination pointers and telling it to "go". It takes just a few video clocks to do the copy. The only downside is that it is not a RGB w/lookup. It's a YUV generator. It does have some great tools for color picking though. It's probably the cheapest/best way to generate video for a 6502. You just need to wire in the parallel interface through a '245. The address to read/write is sent as a command through either the SPI or parallel port. So, you really only need the 8 data lines and few extra control lines to get it up and running. It would probably be the easiest to connect the VS23010 to a 6522 and drive it that way. You could then use the 2nd port on the VIA for the control signals.


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 10, 2018 9:57 pm 
Offline
User avatar

Joined: Wed Aug 17, 2005 12:07 am
Posts: 1207
Location: Soddy-Daisy, TN USA
I'm having a hard time finding the VS23010. Do you have datasheets for it? Is it still produced?

_________________
Cat; the other white meat.


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 10, 2018 10:13 pm 
Offline

Joined: Sat Jun 04, 2016 10:22 pm
Posts: 483
Location: Australia
It would appear that they can be obtained here.
The datasheet is here.

From a quick read of the datasheet, it appears that the SPI interface is required if you want the video generator. It's also a 3.3V device, which is worth noting.


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 11, 2018 1:18 am 
Offline

Joined: Sun Oct 14, 2012 7:30 pm
Posts: 107
Yes, you need the SPI port initially for setting up the chip and changing modes. The video data can also be sent via SPI, but it's a LOT faster (especially with a slow computer) to use the parallel port for transferring data to/from the VS23010's 128K of RAM.

Yes, it's a 3.3v part. I forgot about that. I am using a microcontroller in my project. You would need a 74LVC245 or something similar to do the logic level conversion between the 6502 or 6522.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 46 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: