trsvid - A video player for TRS-80 Model 1, 3 and 4

Choose Your Adventure

Here's a video of trsvid in action:What you see there is 60 frame per second, full-screen video. Well, on the Model 4. The Model III manages just over 54 frames/second and the Model I just over 51 frames/second. What you hear is about 15 Khz audio with effectively 5 or 6 bits per sample.While there's nothing wrong with reading this page straight through, there's a lot to cover. If you've got something particular in mind here's a handy list of places to jump ahead.Model 3 playing A-ha's "Take On Me". By way of a compliment YouTube has muted the audio because they think it sounds like the original. How high is trsvid's fidelity? Enough to be considered copyright infringement!Model 3 playing the intro sequence to "Doctor Who" (the 4th Doctor). Yeah, it's the same one I did from floppy disk , but on the Model 3 instead of the 4P.Model 3 playing The Pogue's "Fairytale of New York".

Sorry, no video! Amazingly YouTube considered it too similar in audio and video to the original and blocked it. Banned in every country. Scroll down and watch the Model I version which is about the same. I think it got flagged because I had the Model 3 filling most of the frame.

Model 3 playing a Radio Shack TV ad for its successor the Model 4.Model 3 playing the classic intro sequence to "The Six Million Dollar Man".Model 4P playing A-ha's "Take On Me". No audio because YouTube muted it for being a copyright violation.Model 4P playing the intro sequence to "Doctor Who" (the 4th Doctor). Yeah, it's the same one I did from floppy disk Same as above but the 4P is playing the Model I version.Model 4P playing The Pogue's "Fairytale of New York". Another victory for fidelity; they'll let me play it but they get all the money. Bad deal for them because I wasn't getting any money. Except they'll probably put an ad into it so the joke's on me.Model 4P playing a Radio Shack TV ad for the Model 4.Same as above but with the ad encoded in ".tv1" format for the Model I.Model 4P playing the classic intro sequence to "The Six Million Dollar Man".Same as above but the ".tv1" version on the Model 4P.Model I playing A-ha's "Take On Me". Once again, muted for sounding too good.Model I playing the intro sequence to "Doctor Who" (the 4th Doctor). Yeah, it's the same one I did from floppy disk , but on the Model I instead of the 4P.Model I playing The Pogue's "Fairytale of New York". As before, it sounded so nice they put an ad on it.Model I playing a Radio Shack TV ad for its grandchild the Model 4.Model I playing the classic intro sequence to "The Six Million Dollar Man".While getting a TRS-80 set up to play videos is not easy, trsvid itself is simple to use. It auto-detects your hardware so there's only one version of the program to download

If a FreHD hard drive emulator is not attached it will print a message to that effect and also list what video file formats your TRS-80 can play: .tv1 and/or .tv3 and/or .tv6 . If you have a FreHD but without the enhanced firmware then you'll still be able to browse the SD card for video files and see the preview images, you just won't be able to play any of them.

Once trsvid/cmd is running you can use the up and down arrow keys to select from a list of files in the current directory which is displayed on the top status line. Notice the right-angle bracket ">" which denotes the current selection. When a video file is selected trsvid will automatically display the preview image in the main window and the title of the video and playing time in the status line.

Model I users will notice black bars on the screen when a video preview is shown. But fear not, just tap the left or right arrow key a few times to move them out of the way. I had the choice between that and rolling static. I decided to go with the bars since it'll give the best display if you move them out of the way.

Directories are shown in the file list with a trailing "/". Press the space-bar to enter a directory. The special directory entry ".." is used to go up to the parent directory. As well, there is a "-=TRSVID=-" entry that will go right to the top of the SD card. If you want to change SD cards, select "-=TRSVID=-", switch cards and then press space-bar. That way trsvid will read the new card. This is important because if you switch cards in any other fashion trsvid will crash or print some message about an error talking to FreHD. There are some rough edges here.

To play a video simply select it and press space-bar. Note that trsvid will show the preview image of a video even if it cannot play it. A "<Not playable on this TRS-80>" message will be shown if either the video format is not supported (for example, a .tv3 file on a Model I) or if your FreHD hard drive emulator does not have the enhanced firmware in which case no videos will be playable.

While a video is playing you can hold the space-bar to pause the video until you release the space-bar. Or press "W" (or almost any key but "W" is mnemonic) to pause the video until you press another key. You can press the BREAK key at any time to stop video playback. When paused the video will show a progress bar at the bottom indicating how much of the video has been played and a "MM:SS" amount played indicator. There's currently no way to start in the middle of a video or rewind or fast-forward. No technical reason why that can't be done, I just got lazy.

TRS-80 Model I and 3 computers can only output audio through the cassette port. TRS-80 Model 4P computers only have an internal speaker. Model 4 computers have both an internal speaker (I think all model 4's do) and a cassette port. So on the Model 4 it will show a "(S)peaker ---> (C)assette" line showing where audio output goes. You press "S" to change to the speaker and "C" to change to the cassette port. You cannot do this when a video is playing or even when a video is paused. Again, pure sloth on me, the programmer's part.

trsvid can only handle about 75 entries per directory. Use sub-directories if, for some amazing reason, you have more video files than that.

trsvid shows a little information about what TRS-80 Model computer you have, what the video refresh rate is (60 or 50 Hz) and the relative CPU speed on Model 4 or 4P machines. Not something you really need to know, but good info for our customer support staff. However, note that only Model 4 machines with "CPU: fast" can play .tv6 files. Other Model 4's will be limted to .tv1 and .tv3 videos.

Since trsvid uses pretty much all the memory and generally takes over the machine there's no way to exit back to TRS-DOS or LDOS or whatever DOS. You'll just have to reset or power-cycle or trip a circuit-breaker to exit.

The trsvid player uses Einar Saukas' zx7 compression library. Not on the video data, mind you, but internally to keep the executable size down.

Some half-decent Windows PC to run the emulator.

trs80gp: trs80gp-1.9.7.zip

trsvid itself: trsvid.zip

One or more video files: tv1.zip, tv3.zip, tv6.zip

trs80gp.exe

trsvid.cmd

.tv1

.tv3

.tv6

trs80gp -m4p -frehd trsvid.cmd

-m1

-m4p

-m3

Most TRS-80 emulators can't run trsvid because they don't emulate a FreHD. Best case is that trsvid would run, print a "sorry, no Frehd" sort of message and exit back to DOS. By absolutely no coincidence, my trs80gp emulator works. Here's what you'll need:Extract files and putand one or more of theorfiles into a directory and then run:If you'd like to see how it goes on a TRS-80 Model I then useinstead of. Orto see it as it would be on a Model 3. Though there isn't much to it, you may want to read the trsvid manual . For that matter, couldn't hurt to look at the trs80gp documentation

I daresay the emulator does a reasonable job of showing what the real thing is like. However, the sound quality is worse and the sound pitch will be off on the Model 4 machines (this is due to incomplete understanding of video wait state timing). And despite my efforts modern LCD screens are just not the same as CRTs.

The emulator is a good training ground if you want to try the real thing and a fast and excellent way to see if your own videos are coming out OK.

You'll notice that FreHD emulator inside trs80gp is essentially treating the current directory as the SD card. Just a word to the wise that while trsvid can browse up and down directories it is rather limited in the size of directory it can handle. If you think the directory is truncated that is not a bug. And if the directory path gets too long it will crash. And trs80gp won't re-scan directories so don't expect files to show up magically if you add them while it is running.

A TRS-80 Model I with 48K

or a TRS-80 Model 3 with 48K

or a TRS-80 Model 4 with 64K

A FreHD hard drive emulator

trsvid itself: trsvid.zip

One or more video files: tv1.zip, tv3.zip, tv6.zip

To actually watch videos on your TRS-80 you'll need the enhanced FreHD firmware and special care in copying video files . But trsvid will run with an unenhanced FreHD or no FreHD at all. The latter is useful if you want to find out what video formats your TRS-80 could handle. You'll still get to browse files and see the preview images. Think of it like just watching arcade games when you were a kid and didn't have a quarter. You'll need:If you're feeling conservative, just download tv1.zip to get video files that will play on any supported TRS-80. Otherwise you can run trsvid/cmd on your TRS-80 first to see which formats it supports and therefore which files you need to download and copy to the SD card. The zip archives are 30 to 50 MB in size. Generally considered small by today's standards but still far from instantaneous downloads.

Get trsvid.cmd onto your emulated FreHD hard drive in whatever way you usually copy files. Probably the easiest is to copy trsvid.cmd to the SD card you put into the FreHD and use the import2 utility from within TRS-DOS or LDOS to get it onto the emulated hard drive.

The video files are to be copied onto the SD card. They do not go onto the FreHD emulated hard drive.

Then just run trsvid and read the manual if anything is confusing from there on out.

A TRS-80 Model I with 48K

or a TRS-80 Model 3 with 48K

or a TRS-80 Model 4 with 64K

A FreHD hard drive emulator

trsvid itself: trsvid.zip which includes the ehanced FreHD firmware.

Some way to flash the new firmware to the FreHD's PIC

A Windows PC and the contig utilty.

or some special care when writing files to the SD card.

One or more video files: tv1.zip, tv3.zip, tv6.zip

Oh, boy, I'm glad you're here. Let me tell you this is what all the cool kids are doing these days. And I'm afraid there's a reason it's so cool -- it's not going to be easy. The tricky bit is that your FreHD will need to be ugraded to the enhanced firmware and it can't be done via the TRS-80 itself. I wish it could but the enhancements required changes to the bootloader. Here's what you'll need:Right up front let me tell you that I'm more than willing to help anybody who tries this. I'm even willing to flash PIC chips for you if that's what it takes. My e-mail address is at the bottom of this page.

I think it's always best to do the hardest and riskiest part of a project first. So the first thing to do is pull the enhanced FreHD firmware FreHD_3.00.hex out of the trsvid.zip archive. Pull the PIC chip (it's the big one) off your FreHD board and flash the new firmware on it. Put the PIC chip back and verify that your FreHD still works. Everything should work the same and vhdutl (ver) will show it having firmware version 3.00 .

If "flashing a PIC chip" is meaningless or scary to you, I empathize. Heck, if "pulling a PIC chip" is scary then I'm with you on that. I've done this myself (obviously) but my process is essentially non-repeatable. You'd be better off to mail your chip to me and I'll flash it (uh, but e-mail me first before you do so). If you don't believe me, read this cautionary tale.

Next, just import2 or some other method to get trsvid.cmd onto the emulated FreHD hard drive. Then run it so it will show you what video file formats ( .tv1, .tv3, .tv6 ) your TRS-80 supports. You're best to use the highest numbered format supported. You only need to do this for Model 4 machines. A Model I can only handle .tv1 and a Model 3 can only handle .tv3 . A Model 4 might be able to handle .tv6 or maybe only .tv1 and .tv3 files.

Now the only trick is to get the video files onto the SD card. The problem is that for a video file to be playable it must not be fragmented. That is, it must be written to the SD card as a contiguous series of sectors.

If you're using Windows then the contig utility will help you out. Copy a video file to your SD card (say smdm.tv1) and then run contig -a on it. For instance, contig -a J:smdm.tv1 ). If it reports the file as having a single fragment then all is well. Pop it into your FreHD and try and play it. If not there are a few options. One is to use contig to degragment the file with contig j:smdm.tv1 ). That works, but let me tell you it took a long time when I did that once. Like 15 or 20 minutes. The other option is to put another ocpy of the file onto the SD card and see if that copy has only one fragment. If not, try another copy. That sounds a bit silly but chances are you'll quickly be writing the file into free space which hasn't been fragmented so you'll get a contiguous set of sectors. Even though it is slow, having contig defrag the file is better than moving on to the next method for non-Windows computers.

I presume Linux has some program that does what contig does on Windows and there's probably even one for the Mac, but I don't know what they are. But if you start with a freshly formatted SD card then every file copy should be contiguous. So grab an SD card, format it, copy on the files needed by the FreHD itself and then copy on the video files. That should work, but there's no way to be sure. And trsvid itself doesn't have the capability of testing the files. All you can do is try to play them. Even if the file is fragmented it will play fine for a while until the second fragment is hit. At that point trsvid will be reading random data and most likely will crash.

SD cards have little computers in them for managing the flash memory and answering sector read/write requests. They may look like a half stick of gum, but they're complicated. trsvid uses sector streaming to play videos. This isn't a commonly used feature and may not work properly. I've only had one card that I think didn't work, but keep in mind that using a different SD card might be the answer if everything else seems in order.

Congratulations if it works. If you want to level up even further, then try converting your own videos.

What's in the enhanced FreHD Firmware?

Minimize wait states on data read. FAT32 file open returns both file size and starting sector. New command to start and stop sector streaming.

The enhanced FreHD firmware has three new features:The wait state minimization was what required a new bootloader. A stock FreHD makes the Z-80 in a Model 4 wait 25 cycles for each data byte. I found that reduced the raw data rate so much that decent video playback was simply not viable. I managed to get that down to 3 wait states.

Even with that speedup I couldn't make ordinary file reading fast enough. The FreHD (correctly) computes and verifies the CRC for each 512 byte sector read. The CRC routine can be considerably sped up but even then it was quite a hit. But having a mode to skip CRC calculation if a file were opened in unsafe mode was a reasonable workaround. After all, I'd only be reading files so the worst case was a program crash. It wouldn't cause a problem in the file system itself. There were still lengthy delays whenever the FreHD had to read a new cluster sector to find the next data sector. In other words, every so often a read would take a lot longer. Finally, there was a delay every second 256 byte read because the FreHD has to break 512 byte SD card sectors into 256 byte chunks to feed to the TRS-80. I tried a number of different schemes to reduce or hide the overhead but the resulting data throughput was still a lot lower than I'd like. And the lengthy and somewhat unpredictatable delays between 256 byte reads would greatly complicate and slow down the video player itself.

Fortunately I found the sector streaming command. I think the intent of it was for video cameras and other special-purpose devices that needed higher throughput. I suspect it remains largely unused in recent times as ordinary sector reads will suffice as long as your device has a decent CPU. In any case it is perfect for trsvid's needs. All I had to do was have the file open command return the first sector of the file and add a command to initiate sector streaming from that sector. As long as the file was not fragmented everything would work perfectly.

Sector streaming doesn't give a perfect data stream. After each 512 byte sector it sends the CRC (which trsvid ignores, naturally) and then it transmits an undetermined number of "stuff" bytes while the SD card controller gets the next sector ready. Based on a few cards I tested the number of stuff bytes is usually only a small amount like 10 or so. That makes the player surprisingly more complicated but at least the effective data rate remains high.

Once I decided I wanted FreHD firmware improvements I went down the road of figuring out how to recompile the firmware (a journey in itself) and how to flash new firmware on the PIC. My first step was to carefully pry the PIC chip off the board and put a ZIF socket in there. That makes it easy to remove and replace the chip on the PIC board because I'd be doing that frequently. Oh, boy, did I ever.

Before rebuilding the firmware I better make sure I can flash an existing version. So I did a little research and got some advice from Andrew Quinn. I heard that something called a PICkit would do the trick. I also read a lot about how the PICkit 2 was great but Microchip was phasing it out for the PICkit 3 so it was hard to get them and their software tending toward not working with the old version. Deciding to save a few bucks I ordered a PICkit 3 clone from some random eBay seller. It came with a little circuit board and its own ZIF socket. Just wire the board up to the PICkit, drop the chip in, plug the PICkit to your PC's USB port and run the burning software.

Again, various Google searches and embedded programming messages boards didn't give me a warm and cozy glow. Most of it were complaints that the old, simple burning software wasn't available or didn't work with the PICkit 3 and that you had to use Microchip's fancy new MPLAB X IDE which is one of these soup-to-nuts things that will compile your C code, assemble your assembler, edit your files, link it all up and burn what remains to a PIC. Great! But all I had was a .hex file. Nonetheless it wasn't too hard to drill through the IDE and make it happy with a mere .hex file. I also had to tell it exactly what PIC chip I had. Sounds easy but there are a million different PIC chips and their names look all the same.

I can't remmeber exacty what I did next, but let me emphasize very carefully that it was all my fault. Andrew's guidance was nothing but sound. It seems that for reasons no doubt involving electrons and other non-software entities the PICkit 3 itself needs to be flashed with firmware depending on what PIC it means to program. The message boards mention this as one of the many faults of the PICkit 3 over the PICkit 2. I don't know if I chose poorly, picked the wrong chip, panicked and pulled a cable too soon or what but after a failed attempt to flash the PICkit the IDE kept saying that I had no PICkit attached. Fiddling with mysterious IDE settings and generally pleading did nothing to resolve this. My PICkit 3 was bricked.

Cursing my stupidity and/or luck, I ordered a somewhat more expensive but real Microchip brand PICkit 3. It didn't come with a little board so the original wasn't a total loss. And the message boards assured me that with a tiny bit of soldering my new PICkit 3 could be used to flash the dead PICkit 3 and bring it back to life. Maybe someday I'll do that, but at the time it just sounded like a new and exciting way to brick my new PICkit.

Fortunately this time around the flash of the PICkit 3 worked. It was ready to program my chip. I super carefully looked up which of the 5 (of 6) wires that came out of the PICkit needed to be hooked up to the pins of the chip. Made all the necessary connections, checked them thrice (at least) and tried again. Checked the connections several more times. After a while I realized that I'd wired the PICkit to the wrong row of header pins on the board. Looking at the board again I can't quite see what my mistake was, but it meant that the PICkit was wired to pins on the board that didn't go to the chip.

Once I got that wiring problem sorted out it worked. Mostly. I got it to burn once or twice but then it said something like "USB isn't giving me enough volts to get the job done." More Googling and UI poking ensues. While the recommended power setting for my PIC was 5 volts it seemed that a lower voltage would work. So I turned the voltage setting in the IDE down to 4.5 V and it didn't complain about the power yet still flashed the chip.

And now it works perfectly. And by perfectly I mean sometimes it still complains about the power but unplugging the USB cable and plugging it back in will usually clear up that error. And sometimes it complains about how there's a short detected so it can't do anything. That just means I haven't used it in a few months and have forgotten which way to put in the chip. The chip survived! It also survived being put in backwards to the FreHD and didn't even kill the FreHD. Who says you have to be careful with hardware?

Anyhow, that's my process for flashing PIC chips. Give it a try if you like, but maybe you should find someone who knows what the hell they're doing.

Awesome as they are, I'm sure you'll tire of the 5 sample videos I provide. trsvid includes the utility programs I use to convert video files to its format. Most of the heavy lifting is done by a generic video processing tool called ffmpeg . The rest are some fairly simple C programs to marshal the data into .tv1, .tv3 or .tv6 format. To do this you'll need:If you can compile C programs then I think this is all easily doable on Mac or Linux. They both will have perl already installed and you'll find versions of ffmpeg for them in the same place as shown for the PC. You'll just need to compile the C programs from trsvid/convert.