Jump to content

Photo

60 fps video using SIDE 2


207 replies to this topic

#1 phaeron OFFLINE  

phaeron

    River Patroller

  • 2,238 posts
  • Location:USA

Posted Fri Apr 26, 2013 11:59 PM

For the "stupid Atari tricks" section: by abusing IR mode 2 addressing, I figured out a way to get ANTIC to DMA playfield data straight out of an IDE interface of a SIDE 2 cartridge. This allows reading off the CompactFlash cartridge at 360KB/sec instead of 86KB/sec and in this way I was able to boost the frame rate of my old video player all the way to 60 fps, while still playing 15KHz audio:



Kind of useless other than for novelty purposes, but I was surprised that the hack worked.

#2 wood_jl OFFLINE  

wood_jl

    Quadrunner

  • 6,796 posts
  • Location:West TN, USA

Posted Sat Apr 27, 2013 12:13 AM

HOLY MOLY!


it's been a little while since the A8 made my jaw drop, but this is one of those moments. It's amazing that in 2013, people are still making the ol' machine do that. THANKS SO MUCH FOR SHARING!!!!! Love it!!!

#3 Rybags OFFLINE  

Rybags

    Quadrunner

  • 15,109 posts
  • Location:Australia

Posted Sat Apr 27, 2013 12:14 AM

Cool stuff. For removable fast media it is useful, always good for a demo for shows etc.

#4 Xuel OFFLINE  

Xuel

    Dragonstomper

  • 604 posts
  • Location:US

Posted Sat Apr 27, 2013 1:10 AM

As a lover an fellow perpetrator of stupid Atari tricks, this is absolutely brilliant! It appears this works on a stock Atari, no? What graphics mode did you use? Do you issue new sector fetches during vertical blank?

Edited by Xuel, Sat Apr 27, 2013 1:10 AM.


#5 phaeron OFFLINE  

phaeron

    River Patroller

  • Topic Starter
  • 2,238 posts
  • Location:USA

Posted Sat Apr 27, 2013 1:42 AM

Yes, it's stock 64K 800XL hardware... well, except for the cartridge with the IDE interface in it that provides the register that magically feeds 30MB of data. No PBI devices attached, though.

The screen is IR mode 2 (40 column hires) toggled between modes 9 and 11 via PRIOR on each scanline. The trick is to position the character set over the IDE registers and use the right character to select the correct 8-byte window. From there, the trick is to get ANTIC to use the right row so it only reads a single address over and over. Well, the IDE data register is at offset 0. By using vertical scrolling we can shorten all the mode lines to a single scanline, alternating between rows 0 and 7, and using the vertical reflect bit the row 7 accesses can be redirected to row 0. The register flips and the audio are all driven by a full-screen kernel, which issues a 12 byte sector read to the IDE device per frame. ANTIC DMAs in 5824 bytes of video over 182 narrow width scanlines, and then the CPU reads in another 320 bytes containing 262 bytes of sound data over 32 more scanlines. The IDE device has the remaining 3ms to prepare for the next read command. Source is attached.

I was originally using normal width scanlines and had the CPU reading interleaved audio in horizontal blank, but ran into a problem on the real hardware that didn't manifest in the emulator that I thought was related to a delay on the device between sectors. As such, I had to go to narrow width to give the IDE device ~30 cycles between each sector. I later found the actual problems that were causing the corrupted reads, so I might be able to go back to that setup. In theory that would boost the read rate from 360KB/sec to almost 500KB/sec.

Here's a video with a bit more color:

Attached Files



#6 Xuel OFFLINE  

Xuel

    Dragonstomper

  • 604 posts
  • Location:US

Posted Sat Apr 27, 2013 2:03 AM

Awesome work! It's great that SIDE2 is fast enough to fill its buffer during vblank. Genius using Char mode, VSCROL, and CHACTL to get ANTIC to hammer the read register for bitmap data. How lucky that $47 and $c0 are the perfect values to twiddle between for three different hardware registers for each pair of lines. :) Absolutely love it.

#7 DamageX OFFLINE  

DamageX

    Chopper Commander

  • 245 posts

Posted Sat Apr 27, 2013 2:14 AM

now that is one seriously awesome hack.

#8 drac030 OFFLINE  

drac030

    Stargunner

  • 1,805 posts
  • Location:Warszawa, Poland

Posted Sat Apr 27, 2013 4:22 AM

Very nice.

#9 flashjazzcat OFFLINE  

flashjazzcat

    Quadrunner

  • 12,584 posts
  • Location:United Kingdom

Posted Sat Apr 27, 2013 4:23 AM

Absolutely fantastic stuff.

#10 TheNameOfTheGame OFFLINE  

TheNameOfTheGame

    Dragonstomper

  • 605 posts
  • Location:Almost Heaven, West Virginia

Posted Sat Apr 27, 2013 4:59 AM

:-o Wow you made me go into shock!! Amazing technique you developed...good job man, that really blows my mind! :thumbsup:

Edited by TheNameOfTheGame, Sat Apr 27, 2013 5:01 AM.


#11 Larry OFFLINE  

Larry

    River Patroller

  • 3,852 posts
  • Location:U.S. -- Midwest

Posted Sat Apr 27, 2013 6:13 AM

WOW! The neat things you clever programmers can get 1970's technology to do. Absolutely amazing!!!

-Larry

#12 Markdvdman OFFLINE  

Markdvdman

    Space Invader

  • 19 posts

Posted Sat Apr 27, 2013 6:35 AM

Absolutely sensational! We must have thought the 8bit has been stretched to the limit! Not so - fair play - wonderful!

#13 JAC! OFFLINE  

JAC!

    Stargunner

  • 1,516 posts
  • Always looking for GFX and MSX for my demos
  • Location:Lebach, Germany

Posted Sat Apr 27, 2013 12:18 PM

The screen is IR mode 2 (40 column hires) toggled between modes 9 and 11 via PRIOR on each scanline. The trick is to position the character set over the IDE registers and use the right character to select the correct 8-byte window. From there, the trick is to get ANTIC to use the right row so it only reads a single address over and over. Well, the IDE data register is at offset 0. By using vertical scrolling we can shorten all the mode lines to a single scanline, alternating between rows 0 and 7, and using the vertical reflect bit the row 7 accesses can be redirected to row 0. The register flips and the audio are all driven by a full-screen kernel, which issues a 12 byte sector read to the IDE device per frame. ANTIC DMAs in 5824 bytes of video over 182 narrow width scanlines, and then the CPU reads in another 320 bytes containing 262 bytes of sound data over 32 more scanlines. The IDE device has the remaining 3ms to prepare for the next read command. Source is attached.


That's what I call a great hack, the basic idea is not new (see also http://atariage.com/...it-atari-great/ and DPC+) but the execution taking all known ANTIC quirks together is simply brilliant. :thumbsup: :thumbsup: :thumbsup:


EDIT:
Just had a look at the source and found why my attempts to create something similar (different storage though) looked horrible.
I miss about 10 years of writing, well, VirtualDub :-)


float sat0 = red0*red0 + grn0*grn0 + blu0*blu0;
float sat1 = red1*red1 + grn1*grn1 + blu1*blu1;

float fi0 = 0.595f*red0 - 0.274f*grn0 - 0.321f*blu0;
float fq0 = 0.211f*red0 - 0.522f*grn0 + 0.311f*blu0;
float fi1 = 0.595f*red1 - 0.274f*grn1 - 0.321f*blu1;
float fq1 = 0.211f*red1 - 0.522f*grn1 + 0.311f*blu1;

int c1 = (((int)floorf(atan2f(fq0, fi0) * 7.5f / 3.1415926535f + 1.0f + da1) + 15*1000) % 15) + 1;
int c2 = (((int)floorf(atan2f(fq1, fi1) * 7.5f / 3.1415926535f + 1.0f + da2) + 15*1000) % 15) + 1;

Edited by JAC!, Sat Apr 27, 2013 12:35 PM.


#14 roland p OFFLINE  

roland p

    River Patroller

  • 2,395 posts
  • $23
  • Location:The Netherlands

Posted Sat Apr 27, 2013 12:40 PM

Cool! How many colors are we looking at?

#15 candle OFFLINE  

candle

    River Patroller

  • 2,793 posts
  • Location:Lublin, Poland

Posted Sat Apr 27, 2013 1:06 PM

my head almost fell off because i laughted so hard
nice work Avery ;)
any chance to have this over fat32? with some assumptions (ie frame always aligned to cluster, clusters big enough to fit it)

#16 phaeron OFFLINE  

phaeron

    River Patroller

  • Topic Starter
  • 2,238 posts
  • Location:USA

Posted Sat Apr 27, 2013 2:49 PM

I forgot the multiplexer tool to merge the streams -- now included.

Someone asked for how to get this running locally. Well, it's a bit involved, and unfortunately the movie files are waaay too big to attach here. Here's the steps:
  • Resample video to 128x182 at 59.9227 fps, in 4:2:0 progressive YCbCr (YV12) and convert audio to 15.7KHz, unsigned 8-bit mono.
  • Use the encvideo60 tool to convert the video to a raw 64x182 video stream with interleaved Gr.9/11 mode lines. The tool takes the video in on stdin, because it's meant to be used with VirtualDub's external encoder feature, but it should be easy to rig up against another tool like ffmpeg or just with a file as source.
  • Use encaudio60 to convert the audio to a raw AUDF1 value stream.
  • Use mux60 to interleave the two files together to produce a movie stream with 12 sectors (6144 bytes) per frame. The video is straightforward, but the audio layout is a bit crazy. The movie starts at sector 16.
  • Mount the movie file as a hard drive image in SIDE 2 mode in Altirra to test, or write it onto a CompactFlash card for playback on real hardware.
  • Run the movplay60 program on the Atari.
Obviously this is not a polished pipeline, so expect some difficulties. You need an NTSC computer to do this, as currently the audio layout is set up for 262 scanlines. No reason it couldn't be done in PAL, just that the player and multiplexer need to be modified and the hue mappings in the video converter would need tweaking. The existing player works on SIDE and SIDE 2, and could probably be modified to work on MyIDE or IDEPlus by changing the IDE register base and init paths.

The audio quality is about as good as it'll get, being about 6.5 bit PWM with error diffusion during the conversion. Classic 4-bit volume audio could be done too -- it would give better bass and less hiss at the cost of sounding a bit muffled.

The video conversion, on the other hand, could use some improvement. Currently encvideo60 converts the luma by applying a 2:1 reduction box filter and then Floyd-Steinberg error diffusion to go to 4-bit, while the chroma goes through a 4x4 ordered dither. I originally wrote this when the best I could do was 7.6 fps, so this could be improved by adding error diffusion to the chroma path and also doing temporal dithering (2-frame flicker). With regard to the wacky math in the chroma path, it is first converting the Cb/Cr to RGB and then to I/Q, then converting that vector to polar form to extract Atari hue. Dither is then applied both to the hue and to saturation (i.e. color or no color).

I didn't even think about FAT32, but that seems doable and a good idea. It would need 8KB sectors with the current video format. There's not really enough time to read FAT sectors during playback but there's plenty of memory to buffer up a minute or so of sector start numbers.

Attached Files



#17 Stephen J. Carden OFFLINE  

Stephen J. Carden

    Moonsweeper

  • 251 posts
  • Location:Augusta Georgia

Posted Sat Apr 27, 2013 10:58 PM

This is some of the coolest work I have seen to date! Good Job in showing us yet another thing our little 8-bit can do!

Stephen J. Carden

#18 fibrewire OFFLINE  

fibrewire

    Stargunner

  • 1,623 posts
  • Location:Southern California

Posted Sat Apr 27, 2013 11:38 PM

So you're saying that there will be CUT SCENES for the soon-to-be-released Atari Strip Poker Game?!?!

:D

Edited by fibrewire, Sat Apr 27, 2013 11:38 PM.


#19 phaeron OFFLINE  

phaeron

    River Patroller

  • Topic Starter
  • 2,238 posts
  • Location:USA

Posted Sun Apr 28, 2013 12:11 AM

Here's a test hard drive image. Up to this point I've had to upsample 24-30 fps sources to 60 fps. I wanted to test with a real 60 fps source, so I captured myself going around the track really sloppily in Gran Turismo 3.

http://www.mediafire...amr7qnxb82z8q75

To test in Altirra, go to System > Hard Disk, enable HD, set Hardware to SIDE 2, select solid-state device mode, select the extracted testhd.bin, enter 256 as Resulting Size (MB). Then boot movplay60.obx.

#20 pixelmischief OFFLINE  

pixelmischief

    Dragonstomper

  • 921 posts

Posted Sun Apr 28, 2013 12:29 AM

Holy fuck-knuckles! We're gonna get FMV gaming on the Atari 8!

#21 Xuel OFFLINE  

Xuel

    Dragonstomper

  • 604 posts
  • Location:US

Posted Sun Apr 28, 2013 12:50 AM

Cool! Looks even more awesome with PAL blending enabled.

movplay.png

Here's a compiled movplay60.obx for anyone who needs it:

Attached File  movplay60.obx   1.38KB   288 downloads

#22 seban OFFLINE  

seban

    Space Invader

  • 21 posts
  • Location:Warszawa, Poland

Posted Sun Apr 28, 2013 4:58 AM

Hi!

I never thought I'd see the day, in which the 8-bit Atari will be able to play high-quality video! Fantastic Idea and great work Avery! :)

greetings
Seban

#23 flashjazzcat OFFLINE  

flashjazzcat

    Quadrunner

  • 12,584 posts
  • Location:United Kingdom

Posted Sun Apr 28, 2013 5:22 AM

What's especially wonderful about this is that it's done entirely in software without any add-on DMA controllers. Simply great lateral thinking and using the power of the existing hardware in inventive ways. This is a tremendous win for the A8. :)

#24 TMR ONLINE  

TMR

    River Patroller

  • 3,349 posts
  • Beeping the horn on the data bus
  • Location:Leeds, U.K.

Posted Sun Apr 28, 2013 5:27 AM

So... game with pre-rendered backgrounds done using this when...? =-)

#25 Irgendwer OFFLINE  

Irgendwer

    Stargunner

  • 1,178 posts
  • Location:Germany

Posted Sun Apr 28, 2013 6:29 AM

Great and fascinating!
Who likes to do a 'Dragon's Lair' conversion?




0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users