PAL video output from a TI-83 Plus

A General Discussion forum for TI calculators

Moderator: MaxCoderz Staff

User avatar
benryves
Maxcoderz Staff
Posts: 3078
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

PAL video output from a TI-83 Plus

Post by benryves »

(This is a copy of a journal post).

My work with the VDP in the Sega Master System made me more aware of how video signals are generated, so thought it would be an interesting exercise to try and generate them in software. This also gives me a chance to test Brass 3, by actively developing experimental programs.

Image

I'm using a simple 2-bit DAC based on a voltage divider, using the values listed here. This way I can generate 0V (sync), ~0.3V (black), ~0.6V (grey) and 1V (white).

My first test was to output a horizontal sync pulse followed by black, grey, then white, counting clock cycles (based on a 6MHz CPU clock). That's 6 clock cycles per µs.

Image

The fastest way to output data to hardware ports on the Z80 is the outi instruction, which loads a value from the address pointed to by hl, increments hl, decrements b and outputs the value to port c. This takes a rather whopping 16 clock cycles (directly outputting to an immediate port address takes 11 clock cycles, but the overhead comes from loading an immediate value into a which takes a further 7). The time spent creating the picture in PAL is 52µs, which is 312 clock cycles. That's 19.5 outi instructions, and by the time you've factored in the loop overhead that gives you a safe 18 pixel horizontal resolution - which is pretty terrible.

Even with this technique, in the best case scenario you output once every 16 clock cycles which gives you a maximum time resolution of 2.67µs. This is indeed a problem as vertical sync is achieved by transmitting two different types of sync pulse, made of either a 2µs sync followed by 30µs black (short) or 30µs sync followed by 2µs black (long). In my case I plumped for the easiest to time 4µs/28µs and hoped it would work.

Anyhow, I made a small three-colour image for testing: Image

Of course, as I need to output each scanline anyway I end up with a resolution of 304 lines, which gives me rather irregular pixels, so I just stretch the above image up to 20×304. Eagle-eyed readers would have noticed that the horizontal resolution is only 18 pixels, but somewhere in the development process I forgot how to count and so made the image two pixels too wide.

Image

As you can see, it shows (the entire image is shunted to the right). TVs crop the first and last few scanlines (they aren't wasted, though, and can be used for Teletext) so that's why that's missing. :) A widescreen monitor doesn't help the already heavily distorted pixels either, but it does (somewhat surprisingly) work.

With a TI-83+ SE (or higher) you have access to a much faster CPU (15MHz) and more accurate timing (crystal timers rather than an RC circuit that changes speed based on battery levels) as well as better interrupt control, so on an SE calculator you could get at least double the horizontal resolution and output correct vertical sync patterns. You also have better control over the timer interrupts, so you could probably drive hsync via a fixed interrupt, leaving you space to insert a game (the only code I had space for checks to see if the On key is held so you can quit the program - more clock cycle counting). I only have the old 6MHz calculator, though, so I'm pleased enough that it works at all, even if the results are useless!
Last edited by benryves on Wed 14 Nov, 2007 4:08 pm, edited 1 time in total.
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4129
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

You have got to be kidding me Ben, this is an all new milestone for you ... when will you stop!

The knowledge you possess is amazing, this is truely amazing.

:worship:
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

This is awesome! I didn't even know it was possible..
Ben always makes the impossible possible it seems :)
User avatar
DJ_O
Calc King
Posts: 2308
Joined: Mon 20 Dec, 2004 6:47 pm
Location: Quebec (Canada)
Contact:

Post by DJ_O »

post removed
Last edited by DJ_O on Fri 11 Jan, 2008 9:55 pm, edited 1 time in total.
Andy_J
Calc Master
Posts: 1110
Joined: Mon 20 Dec, 2004 10:01 pm
Location: In the state of Roo Fearing
Contact:

Post by Andy_J »

If it's playable at 18x304 with little CPU time for game processing, then yes...
ImageImage
Image
Liazon
Calc Guru
Posts: 962
Joined: Thu 27 Oct, 2005 8:28 pm

Post by Liazon »

o.o sick i wouldn't know where to begin w/ messing w/ hardware
Image Image Image
User avatar
DJ_O
Calc King
Posts: 2308
Joined: Mon 20 Dec, 2004 6:47 pm
Location: Quebec (Canada)
Contact:

Post by DJ_O »

post removed
Last edited by DJ_O on Fri 11 Jan, 2008 9:55 pm, edited 1 time in total.
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

At least the bear came in clear ;)
netham45
New Member
Posts: 6
Joined: Sun 19 Nov, 2006 11:31 pm

Post by netham45 »

I am your slave. :P

I have an 84+, and access to a TV(I musta missed it, that is RCA, correct?) and a basic understanding of circuts/access to stuff. If you can get my schematics, I can try this on my 84+, willingly. :)

E-Mail me at Netham45 (DIE SPAMBOTS) at (DIE SPAMBOTS) gmail.com

Mabye it would be possible to couple this with MSD8x and get video output?

Edit: Missed the PAL part, the TV I have is NTSC.
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4129
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

Well i have an 84+SE and live in PAL territory :). But i think this is best left up to the master.

You could try the old 'overclock your calc' move?
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
benryves
Maxcoderz Staff
Posts: 3078
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

Cheers, gents. :)
DJ Omnimaga wrote:oh wait i missed the 18x304 part then x.x I wish it could be any res
As do I. :) The problem comes from not being able to change the voltage levels quickly enough; a scanline (the image is scanned from left-to-right, top-to-bottom) has 52µs worth of time for image data. An outi instruction (for reading a value to memory and dumping it out of the link port) takes 16 CPU clock cycles, which comes to about 2.67µs per outi, giving us 19.5 pixels per scanline. By factoring in a bit of extra CPU time to handle the loop you come to the 18 pixel horizontal resolution answer.

A 15MHz SE (15 clock cycles per µs) would only take 1.067µs per outi, 48.75 pixels horizontal. 48 pixels wide would be pretty decent. :)

The 304 pixel vertical resolution is simply because I trace every scanline. I only sync one field (I use the same vertical sync pattern every frame) so the resolution is half that of what it could be (interlaced). I don't think anyone would complain about 304 pixels high resolution, anyway.

The problem is getting usable software into there. I don't know much about the 83+SE and higher's interrupt system, but if you could trigger an interrupt every 64µs (that's once a scanline) you could very easily mix in some game logic.

The logic behind that would be that you wouldn't have to draw every scanline. You could, say, take the central 192* scanlines and treat those as the active display (ie, write out a signal for those lines). For the scanlines above and below you could just output the hsync pulse (4µs at sync level) then output black then return prematurely, leaving you with 60µs free (minus loop overhead) for some game logic out of every 64µs scanline.
netham45 wrote:I have an 84+, and access to a TV(I musta missed it, that is RCA, correct?) and a basic understanding of circuts/access to stuff. If you can get my schematics, I can try this on my 84+, willingly. :)
I'll release the source soon. Sorry, I would have done earlier but I'm trying to get Brass out at the same time and would like to do a couple more tests first. This project is more "look, it can be badly done on an 83+, maybe some nice person with an SE can turn it into something usable". ;)
Edit: Missed the PAL part, the TV I have is NTSC.
I believe that the timing is much the same on NTSC. The colour format is different, but that doesn't matter as I'm not outputting colour signals anyway. Also, whilst NTSC is a lower vertical resolution, it has a higher refresh rate to compensate. My tests (inputting a PAL signal to an NTSC device) just crop the image.

I'd like to develop this on an SE, but don't have one (and they're rather expensive here on eBay). :(

* Master System Resolution = 192 active scanlines.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

I don't think you could do it exactly with interrupts on a SE
disclaimer: I have no idea what I'm talking about really :P
the fastest normal rate (cpu speed independent) is about 1.43 times too slow and the slowest cpu-clock-divider rate is almost 23 times too fast (at 15MHz)
Combining 2 timers may not be accurate enough, so that leaves skipping 22 interrupts out of 23
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4129
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

Crystal timers can generate interrupts on the SE's, you can check out the frequencies here: http://wikiti.denglend.net/index.php?ti ... s:Ports:30
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
benryves
Maxcoderz Staff
Posts: 3078
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

PAL.zip

It's an experiment, so the timing is wrong but it "works on my machine". ;)

Image
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4129
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

Wow Ben, this has got me so excited!

Im going to whip the schematic up *digs through parts draw*

Have you uploaded this to ticalc.org? I think this would gain a lot of interest :).
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
Post Reply