by date
GID j - Black Pixels
GID j - Black Pixels
| Name: | Gary Preston | |
|---|---|---|
| Date Posted: | Apr 10, 2006 | |
| Rating: | Not Rated | |
| Public: | YES | |
| Comments: | YES | |
| RSS Feed: | or Subscribe with . | |
| Profile Page: | View profile page for Gary Preston |
Blog post
NOTE: Full write up can be found on my blog, see end of post for links to the blog entries.
Originally I had planned to do a TGB based GID however Tom mentioned I should do an XGS GID at some point on irc and I thought what the heck.
A GID is hard enough to complete when you know the toolset you're using so I thought I'd have to scale back my goals and I mean really scale back. The goal, to display a single pixel on a PAL tv using the XGS game console. This would probably prove to be quite a challenge considering my limited knowledge of the XGS hardware (zero knowledge of the video hardware) and very little experience with the SX52, but it sounded like a fun challenge.
For those that havn't heard about the XGS, its a console with the main purpose to learn the details of how hardware works and ways of designing game consoles. At the heart of the XGS is the SX52 microprocessor capable of running at a whopping 80Mhz with 292bytes of RAM and 4k EEPROM for program storage. (The XGS has an extra 128k SRAM onboard but that was beyond the scope of my project since I didn't have time to learn both the video hardware and SRAM hardware interfacing).
Plotting a pixel doesn't sound like too hard a task, but then the more I read about how the video hardware worked, the more I realised that perhaps I hadn't scaled my goals back far enough. With the XGS you create video in software, by that I mean you have to generate the waveform that is sent to the TV eg this:

in code.
Generating this signal involved counting the cycles each machine instruction would take to execute and knowing that one cycle @ 80Mhz takes 12.5 nano seconds. So by counting clock cycles and adding extra instructions via lots of loops/nops you can get very accurate timing, although the counting proved tricky with a few cycles out resulting in the follow TV output

Still after a lot of reading (mainly the SX52 manual :P) I managed to get a filled yellow TV screen and with a little more tweaking a nice yellow block in the center. The image I captured is very washed out, you'll have to trust me that it does look yellow on the tv

This in and of itself caused a few headaches since to generate the block I did what amounts to an IF in asm and checked whether the current scanline was greater than 97 but less than 109 in which case we could output the colour yellow, otherwise output black. The problem been these two < and > tests introduced 3 branches into the code and with timing been critical down to the cycle I had to ensure all 3 branches took exactly the same amount of time to execute, which resulted in the following ugly code:
It's late and I'm sure the final code (which I think amounts to about 374bytes) will probably have plenty of bugs, but the end result is a nice yellow square on both my TV and PC digital TV card. So on the whole everything seems to be working and in sync.
A much more detailed coverage can be found on my blog including a few extra screendumps of the debugger and the final source code if you're interested.
The one thing that doing this GID has really taught me is how skilled the original Atari 2600 programmers must have been, I have a whole lot of respect for them.
Blog entries:
00101010.figmentgames.com/2006/04/07/gid-j-black-pixels/
00101010.figmentgames.com/2006/04/08/gid-j-attempt-1-snow/
00101010.figmentgames.com/2006/04/08/gid-j-delay-debugging/
00101010.figmentgames.com/2006/04/09/gid-j-signal-generation/
00101010.figmentgames.com/2006/04/09/gid-j-mission-accomplished/
PS For those wondering why "Black Pixels" and not "Yellow Pixels" go search for a blog about "Black Triangles" :)
Originally I had planned to do a TGB based GID however Tom mentioned I should do an XGS GID at some point on irc and I thought what the heck.
A GID is hard enough to complete when you know the toolset you're using so I thought I'd have to scale back my goals and I mean really scale back. The goal, to display a single pixel on a PAL tv using the XGS game console. This would probably prove to be quite a challenge considering my limited knowledge of the XGS hardware (zero knowledge of the video hardware) and very little experience with the SX52, but it sounded like a fun challenge.
For those that havn't heard about the XGS, its a console with the main purpose to learn the details of how hardware works and ways of designing game consoles. At the heart of the XGS is the SX52 microprocessor capable of running at a whopping 80Mhz with 292bytes of RAM and 4k EEPROM for program storage. (The XGS has an extra 128k SRAM onboard but that was beyond the scope of my project since I didn't have time to learn both the video hardware and SRAM hardware interfacing).
Plotting a pixel doesn't sound like too hard a task, but then the more I read about how the video hardware worked, the more I realised that perhaps I hadn't scaled my goals back far enough. With the XGS you create video in software, by that I mean you have to generate the waveform that is sent to the TV eg this:

in code.
Generating this signal involved counting the cycles each machine instruction would take to execute and knowing that one cycle @ 80Mhz takes 12.5 nano seconds. So by counting clock cycles and adding extra instructions via lots of loops/nops you can get very accurate timing, although the counting proved tricky with a few cycles out resulting in the follow TV output

Still after a lot of reading (mainly the SX52 manual :P) I managed to get a filled yellow TV screen and with a little more tweaking a nice yellow block in the center. The image I captured is very washed out, you'll have to trust me that it does look yellow on the tv
This in and of itself caused a few headaches since to generate the block I did what amounts to an IF in asm and checked whether the current scanline was greater than 97 but less than 109 in which case we could output the colour yellow, otherwise output black. The problem been these two < and > tests introduced 3 branches into the code and with timing been critical down to the cycle I had to ensure all 3 branches took exactly the same amount of time to execute, which resulted in the following ugly code:
; black for 141 pixels (2037 cycles) and color for 12 (174 cycles)
mov RE, #VID_BLACK ; 2
; color for 12 pixels (174 cycles)
cjb scanline, #97, :skipcolor1 ; 4/6
cja scanline, #109, :skipcolor2 ; 4/6
DELAY(2037-10)
mov RE, #TEMP_COLOUR ; 2 setup pixel colour
jmp :color ; 3
:skipcolor2
DELAY(2037-12)
nop
nop
jmp :color ; 3
:skipcolor1
DELAY(2037-6)
nop
nop
jmp :color ; 3
:color
DELAY( 174-5 )
; black for 141 pixels (2037 cycles)
mov RE, #VID_BLACK ; 2 setup pixel colour
DELAY(2037-6) ; inc following jump
djnz scanline, :scanline_loop ; 2/4 (extra 2 from 4 is unaccounted for!)
It's late and I'm sure the final code (which I think amounts to about 374bytes) will probably have plenty of bugs, but the end result is a nice yellow square on both my TV and PC digital TV card. So on the whole everything seems to be working and in sync.
A much more detailed coverage can be found on my blog including a few extra screendumps of the debugger and the final source code if you're interested.
The one thing that doing this GID has really taught me is how skilled the original Atari 2600 programmers must have been, I have a whole lot of respect for them.
Blog entries:
00101010.figmentgames.com/2006/04/07/gid-j-black-pixels/
00101010.figmentgames.com/2006/04/08/gid-j-attempt-1-snow/
00101010.figmentgames.com/2006/04/08/gid-j-delay-debugging/
00101010.figmentgames.com/2006/04/09/gid-j-signal-generation/
00101010.figmentgames.com/2006/04/09/gid-j-mission-accomplished/
PS For those wondering why "Black Pixels" and not "Yellow Pixels" go search for a blog about "Black Triangles" :)
Recent Blog Posts
| List: | 06/27/08 - Shelled! Online Soft Launch 12/17/06 - Shelled! A Postmortem 04/10/06 - GID j - Black Pixels 07/18/05 - Plan for Gary Preston 05/09/05 - Plan for Gary Preston 03/15/05 - Plan for Gary Preston |
|---|
Submit your own resources!| Paul /*Wedge*/ DElia (Apr 10, 2006 at 01:49 GMT) |
| Joshua Dallman (Apr 10, 2006 at 04:54 GMT) |
| Phil Carlisle (Apr 10, 2006 at 08:51 GMT) |
| Gary Preston (Apr 10, 2006 at 11:53 GMT) |
Still its fun to work with now and then, maybe I'm just a masochist but counting cycles was kinda relaxing, at least in small chunks and not when overly tired :)
You must be a member and be logged in to either append comments or rate this resource.


Not Rated


