Hello my friends,
Im new to this forum and i need some guidance/help. I hope im posting in the right forum.
First, for those who doesnt know the VT100 is an 80's terminal for mainframes built by DEC with a 640x480 monocrome screen (80x24 ASCII chars) and a ASCII keyboard, its controlled by a Serial TTL with 9600 baund rate and it uses ASCII control and characters. It uses a Intel 8080 as main CPU. Basically is the dawn of the Linux terminal... Yeah, i like it alot.
I know that alot of people have done some VT100 emulators using a display and even got colors (something that the original one doesn't have). But i want to display on a real TV.
I know that theres dedicated hardware to do that on a Arduino but they are expensive here and take a long time to arrive, since i need to buy oversea and takes roughly 90 days. So, im decided to do my own implementation.
Well, first i saw the TVOut Library, its awesome but it has only 100 or something pixels wide, and thats its not even close to 640 from VT100. And i know that 2KB is not close to a framebuffer for 640x480 but im thinking about skipping the framebuffer at all.
First of all, i will build a black and white screen, no colors or even grayscale. Because even B&W would be pushing Arduino to the limit.
I read alot about PAL standard, and each horizontal line takes 64us to draw, 12us is the hsync/hblank and 54us is the actuall draw, wich is limited to 650 pixels.
My idea is the follow, hardcoded in the 32KB program ROM i will hard code a character map, with the 256 ASCII characters, since i will use a 8x8 character resolution, each character will use 8 bytes. Using a total of 2048 bytes for character mapping, but that is stored in the ROM, this data is constant, no need to store in RAM.
Insinde the RAM i will just store the 80x24 characters that will be printed on screen, since each character uses 1 byte, i will use 1920 bytes of memory, leaving only 128 bytes free to be used but i think that this is all i need.
On each hsync i will use the free time (12us wich is rougly 200 (12x16) instructions since in the atmega328p datasheet is rougly 1 instruction per cycle) i will load in another 80 bytes of memory (640 bits) the line that will be drawn by using some moving instructions that i previously hardcoded (in the character map).
Then on the 52us i will just do bitshift this 80 bytes data to a pinout that will be doing the white (1v). I think that Arduino cannot bitshift 80 bytes, but it can 1 byte. So every time that i shift a hole byte wich will represent one char i will just load another byte to bitshift, since 52us give me roughly 830 instructions to run, those are 190 more instructions than what is need to draw 640 pixels on screen and i can use that extra instruction to do a byte moving from memory to a "pinout".
Okay, what about keyboard, screen rolling and other stuff that the VT100 does? That will be done while the screen is in vsync, since the vsync take almost 1ms its plenty time to do the rest and if i need a keyboard/screen stack or something i still have those 48 bytes of free memory.
Yes, the controller wont do anything else, im aware of that but the propuse is just to emulate a VT100. Receive commands from the native TTL from arduino (pin 0 and 1), do a simple PS2 keyboard controller and the rest of the pins can be sacrificed to do bitshifting.
Okay, my problems:
I dont know AVR Assembly and i cant find a good material about it, im from Intel Assembly, so 8080, 8086 and 8052 but those are too slow to drive the screen since they arent 1 instruction per cycle.
How is the Atmega RAM mapped? The registers are in memory or they are dedicated? The IO is memory mapped? Because that will be pretty important since i will need to dedicate (if possible) memory from those 48 bytes to that.
I dont know if exists, but i need a document that shows avr instructions and the clock cycles used so i can do the correct timming and optmize the most. Because the datasheet doesnt say that there are one instruction per clock, it says that is close to that. I figure that some instructions would use more than one clock cycle, i just hope that the bitshift one use only one because my hole project depends on that.
MOST IMPORTANT: I need ideas, guidance, anything that you may find it helpful will help me alot. But i dont want to add external hardware because here they are expensive and take too much long time to arrive.
I know that runs a little away from the Arduino instinct because im just trowing away the Arduino C IDE and bootloader. But i will stick with Arduino hardware, the atmega328p and the 16MHz clock crystal.
Im sorry for my bad english because english is not my native language.