6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 11:33 pm

All times are UTC




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sun Nov 04, 2012 5:55 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
A while ago while watching one of the videos that BigEd probably posted i heard the racing the beam concept where the cpu in the Atari generated the video signal on the fly. Few years ago i tried to display a square on the tv with a pic mcu, but i couldn't get the sync right.
I looked at the pal specs, but i am still not exactly sure how to make it work smoothly.
So how was the Atari able to generate video on the fly with no framebuffer and still keep it all synced?


Last edited by Dajgoro on Sun Nov 04, 2012 3:05 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 04, 2012 12:07 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
It has a frame buffer but only for a single line (in fact only half a line which is repeated or mirrored - I think).

Its not the hard to generate on a PIC. I used a 32uS reoccurring interrupt for the timing and a huge jump table to quickly get a to piece of code that does the correct action for the period (e.g. short pulse, long pulse, scan line, blank line).

I used the hardware SPI module to generate the pixels while the code worked out the next character pattern. I use a macro to work out the next group of 8 pixels (including inverse video and flashing) ...
Code:
; The PIXEL macro computes the next set of 8 pixels that need to be shifted out
; by the SPI module while peripheral is busy with the last set. The SSPBUF
; register must be both read and written at exactly the right time.

PIXEL           macro   FBIT,IBIT,IREG
                movff   POSTINC1,FSR2L          ; +0
                bcf     FSR1H,.2                ; +2
                clrf    WREG                    ; +3
                btfsc   INDF0,FBIT              ; +4
                btfsc   FLASH_STATE,.0          ; +5
                xorwf   INDF2,W                 ; +6
                btfsc   IREG,IBIT               ; +7
                comf    WREG,F                  ; +8
                nop                             ; +9
                xorwf   SSPBUF,W                ; +10
                xorwf   SSPBUF,F                ; +11
                endm                            ; +12

... then use it 40 times to generate a line.
Code:
; Draw a complete line of pixels for the current display row taking into account
; the attribute bits that go with each character.

DrawLine:
                PIXEL   .7,.6,INDF0             ; 0
                PIXEL   .5,.4,INDF0
                PIXEL   .3,.2,INDF0
                PIXEL   .1,.0,POSTINC0
                PIXEL   .7,.6,INDF0
                PIXEL   .5,.4,INDF0
                PIXEL   .3,.2,INDF0
                PIXEL   .1,.0,POSTINC0
                PIXEL   .7,.6,INDF0
                PIXEL   .5,.4,INDF0

                PIXEL   .3,.2,INDF0             ; 10
                PIXEL   .1,.0,POSTINC0
                PIXEL   .7,.6,INDF0
                PIXEL   .5,.4,INDF0
                PIXEL   .3,.2,INDF0
                PIXEL   .1,.0,POSTINC0
                PIXEL   .7,.6,INDF0
                PIXEL   .5,.4,INDF0
                PIXEL   .3,.2,INDF0
                PIXEL   .1,.0,POSTINC0

                PIXEL   .7,.6,INDF0             ; 20
                PIXEL   .5,.4,INDF0
                PIXEL   .3,.2,INDF0
                PIXEL   .1,.0,POSTINC0
                PIXEL   .7,.6,INDF0
                PIXEL   .5,.4,INDF0
                PIXEL   .3,.2,INDF0
                PIXEL   .1,.0,POSTINC0
                PIXEL   .7,.6,INDF0
                PIXEL   .5,.4,INDF0

                PIXEL   .3,.2,INDF0             ; 30
                PIXEL   .1,.0,POSTINC0
                PIXEL   .7,.6,INDF0
                PIXEL   .5,.4,INDF0
                PIXEL   .3,.2,INDF0
                PIXEL   .1,.0,POSTINC0
                PIXEL   .7,.6,INDF0
                PIXEL   .5,.4,INDF0
                PIXEL   .3,.2,INDF0
                PIXEL   .1,.0,POSTINC0

                return

Which in turn is called from the routine that generate the signals for the entire scan line
Code:
PALScanLine0:
                bcf     SYNC_LATCH,SYNC_BIT     ; Generate 4uS sync pulse
                movff   FSR0L,HI_FSR0L
                movff   FSR0H,HI_FSR0H
                movff   FSR1L,HI_FSR1L
                movff   FSR1H,HI_FSR1H
                movff   FSR2L,HI_FSR2L
                movff   FSR2H,HI_FSR2H
                DELAY   .4,.13
                bsf     SYNC_LATCH,SYNC_BIT
                movff   ROW_PTR+.0,FSR1L        ; Reload start of row pointer
                movff   ROW_PTR+.1,FSR1H
                movff   ATR_PTR+.0,FSR0L
                movff   ATR_PTR+.1,FSR0H
                movlw   high (SHAPES0)          ; Point FSR2 at shape page
                movwf   FSR2H
                DELAY   .12,.23                  ; Back Porch
                rcall   DrawLine
                movff   HI_FSR0L,FSR0L
                movff   HI_FSR0H,FSR0H
                movff   HI_FSR1L,FSR1L
                movff   HI_FSR1H,FSR1H
                movff   HI_FSR2L,FSR2L
                movff   HI_FSR2H,FSR2H
                bcf     PIR1,TMR2IF             ; Clear interrupt and return
                retfie  FAST

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 04, 2012 12:21 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
BitWise wrote:
It has a frame buffer but only for a single line (in fact only half a line which is repeated or mirrored - I think).

Even less than that, in that the 20-bit 'playfield' register controls 4 pixels with each bit. As you say, it can be repeated or mirrored, so the 80 pixels (at quarter resolution - 20 chunky strips) control the whole 160 pixel line.

The other visible elements are all, in today's terminology, one-pixel-high sprites, and 8 bits wide.

In fact it's probably best to say that the whole screen is sprites, each a single pixel high, so it's normal to update one or more sprite on every line, or every other line. If you don't update, you get the same pixels lit on subsequent video lines, which stretches the pattern vertically. (A full-screen vertical wall needs no update.)

See http://en.wikipedia.org/wiki/Television ... ess_design

Cheers
Ed


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 04, 2012 3:19 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
Thanks everyone for explaining the tia, and for the link.
I have the CXA1645P that i bought for the cpld video generator, which i don't think i am going to build.
I looked at the CXA1645P datasheet, and it is not complicated, it has r,g,b inputs and sync input, and composite out.
How do i exactly sync using that ic with a mcu/cpu? It should be easier?


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 06, 2012 2:26 am 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
Dajgoro wrote:
i heard the racing the beam concept where the cpu in the Atari generated the video signal on the fly. Few years ago i tried to display a square on the tv with a pic mcu, but i couldn't get the sync right.

Dunno if Atari used it, but "cheap video" is a racing-the-beam techique that lets a CPU generate video with very little extra hardware. The Z80 version was mentioned just recently on 6502.org here There's also a related article on my web site.

With this technique sync pulses are generated strictly in software (typically by toggling a bit in a parallel output port). The horizontal video scans are also done in software, and it can be challenging/maddening to get the whole deal correct in terms of correct (and unvarying) cycle counts. The payoff is real, though.

Cheap video doesn't commit you to any particular modulation technique. For example the CXA1645P you mentioned could be employed. Or, for black-and-white (or gray-scale) a simple resistor ladder can serve as your composite-sync output stage.

cheers,
Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 06, 2012 3:29 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
Ill try again, but this time with an atmega32. If it works, i could attach a ram ic to it, and make a mini video controller.


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 07, 2012 10:23 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
If i use the pic18f4455 and the 8.86MHz crystal as clock and pll i should get 8 mips, same thing with the atmega32, but the atmega doesn't have the parallel slave port, so i can't interface it.
I also should add an external ram to act as a framebuffer. The 16f877 is much simpler, but it is slower as well, and i wonder what would be the max resolution if the mcu has only 2mpis.


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 07, 2012 10:33 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
Since i went off topic, lets discuss the mips issue back in my old topic.
viewtopic.php?f=4&t=2104&start=15


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 14, 2013 8:30 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
I've been having another go at video generation this time using 3V3 Microchip 16-bit cores. The result is much better, I can generate a full 80x25 character image (with 8x10 font glyphs) with blinking and inverse video.
Image
I'm going to rewrite the code a little to support double height and/or double width and underlining so I can do VT220 emulation.

I think it may be possible to do bold as well if I use two output pins for the pixels but the code is already very tight on cycles.
Code:
Bold ---|>|---/\/\/\---+
               560?    |
Norm ---|>|---/\/\/\---+
               680?    |
Sync ---------/\/\/\---+----> Composite
               220

The interface will be serial using the 5V tolerant I/O pins.
Not bad for a $3 chip, a 10Mhz crystal and a few passives.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 14, 2013 1:58 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
What mcu exactly is that?


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 14, 2013 4:54 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
It's a 24EP128GP202

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 14, 2013 8:02 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
Google doesn't give me too much concrete information about it, and ebay gives me 0 results.
I tend to stick to the 16/18F you gave me(half of them are already used in various projects). :D


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 14, 2013 8:34 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Try http://www.microchip.com/wwwproducts/De ... e=en558705
Cheers
Ed


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 14, 2013 8:36 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
Dajgoro wrote:
Google doesn't give me too much concrete information about it, and ebay gives me 0 results.
I tend to stick to the 16/18F you gave me(half of them are already used in various projects). :D


http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en558705

70MIP 3v3 device. 16K of RAM. 128K of Flash.

I'm overclocking to 75MIPs at the moment .

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 14, 2013 8:48 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
70 MIPS, you should be able to get a nice resolution with such speed.


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 91 guests


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: