PDA

View Full Version : Bad Apple for PC's



evildragon
July 21st, 2012, 10:01 PM
I've been seeing a lot of people making 8-bit and 16-bit game console versions of this video: http://www.youtube.com/watch?v=VzEUeWnV73U

Can this be done on the original PC also? Sure, could use a sound card, but I don't have one, or a slot available for one.. I'd like to see this be played on my model 25, via the PC-Speaker.

That would be awesome!

My model 25 has 640x480 1-bit mode, that I think will be AWESOME for this video, crisp quality.

pearce_jj
July 21st, 2012, 11:32 PM
Have a search for '8088 corruption'!

That video though lends itself to such a conversion, since it's obviously monochrome but has nice big shapes that could be rendered at low resolution.

But, I think the data rate (25fps @ 640x480 plus audio would be close to 1MB/s) I think would be beyond an 8086. Does the model-25 have 16-bit ISA slots?

evildragon
July 21st, 2012, 11:35 PM
Only 2 8-bit isa slots and both are used. One by an xt IDE and the other my Ethernet card.

8088 corruption won't load without a sound card.

pearce_jj
July 22nd, 2012, 12:06 AM
Yes the sound card interrupts are used to trigger screen updates (hence it's needed). With 8-bit slots there simply isn't enough bandwidth to retrieve data from disk at that rate, let alone anything else.

evildragon
July 22nd, 2012, 06:32 AM
Yes the sound card interrupts are used to trigger screen updates (hence it's needed). With 8-bit slots there simply isn't enough bandwidth to retrieve data from disk at that rate, let alone anything else.

Well we can lower the refresh rate of the video, that would be fine, or even, just use the 320x200 mode then, but still as a 1-bit image, so that way it goes fast.

For example, the Sega Genesis version of this video, a machine with 64KB RAM and 64KB VRAM, and a 8MHz CPU, did it, but sacrifices were made too: http://www.youtube.com/watch?v=lbAxuFgQyHQ

That person managed it on that hardware.. I just can't imagine the PC not being able to do this though. The Sega doesn't even have a frame buffer, the model 25 has this as an advantage.

Pepinno
July 22nd, 2012, 09:20 AM
Bad Apple for 8-bit NES:
http://www.youtube.com/watch?v=ZMbAEjPPf7w

Bad Apple for a "laser scanner": http://www.youtube.com/watch?v=uJaAYD0YT44

That Bad Apple video and music are amazing, and it has to be doable on evildragon's Model 25.

evildragon
July 22nd, 2012, 09:56 AM
I was able to pull off a simple 64x64 pixel animation of a couple scenes from it, in 320x200 mode, but it has a slow draw rate even at that size, and doesn't play at proper speed.

Then again, I am NOT a good programmer and am using BIOS calls, not direct hardware access.

No sound btw.

I'll video tape it later.

Next thing you know they will have Atari 2600's doing this demo, and our old PC's still haven't done it.

This has to be do-able, and at a good quality too, even if with a PC speaker..

EDIT: See, we don't even need a sound card! http://www.youtube.com/watch?v=hkZbAJHeu9w

commodorejohn
July 22nd, 2012, 10:21 AM
Oh Lordy. Do not use BIOS video calls under any circumstances, ever. They're just horrible. I've had Pentium IIs perform like 286s on software based around BIOS video calls.

As for the idea...I dunno. 8088 Corruption is an impressive bit of work, but it does rely more on finding what can be done within a few specific parameters than trying to squash something down to fit. The advantage to text mode is that you can get an 80x50-pixel 16-color bitmap without even breaking a sweat, and it's only 4000 bytes/frame. Bitmapped mode, though...even if there's a way to hack the CGA into doing a monochrome 320x200 mode (might be, but I'm no expert on nonstandard CGA trickery,) that's still 8000 bytes/frame, although it'd be more amenable to compression on a video like this. If there isn't a way to get monochrome 320x200, you might as well just go with 640x200, since you'd be transferring the same amount of data anyway and you'd get higher resolution out of it, but either way that'd crank the whole thing up to 16000 bytes/frame, and I'm not really sure what kind of FPS you can expect shoving that much data through 8-bit ISA.

Still, sure can't hurt to try, just don't use the BIOS video routines, for the love of God!

evildragon
July 22nd, 2012, 10:34 AM
Though my model 25 has 8-bit ISA slots, it's MCGA graphics I think is on a 16-bit bus tied to the 8086. Because it works faster than an ISA VGA card in the 8-bit slot.

Perhaps a 1-bit monochrome version of 320x200 can't be done, so 640x200 could work as a substitute.

I don't know how to use MCGA directly, so I won't be able to do that.

evildragon
July 22nd, 2012, 10:56 AM
Here's what I got so far: http://www.youtube.com/watch?v=idK4meBnUJw

I will try and learn how to access video directly.

commodorejohn
July 22nd, 2012, 11:08 AM
You don't want to use MCGA mode, that's 8 bits per pixel - way more data than you need. An introduction to CGA programming is here. (http://webpages.charter.net/danrollins/techhelp/0066.HTM) It's a bit odd, in that even and odd-numbered lines are grouped in separate framebuffers for some reason; the even lines start at B800:0000, the odd ones at B800:2000 (or BA00:0000, if you like.) Other than that it's pretty simple. The leftmost pixel is in the highest bit(s) of each byte. For your purposes, you shouldn't even need to do any individual pixel-drawing; you could just run-length compress bytes that are all-black or all-white, and you'd save a whole lot of disk bandwidth.

evildragon
July 22nd, 2012, 11:19 AM
I read up on that.

Right now I'm still working on compressing the video.. I'm just using this one clip as a test as I have gotten it down to about 40KB now.. On the video I posted, it still had some shades of grey. I have removed that and made it a simple 1-bit image now. I have both a high resolution version (for 640x480 1-bit) and low resolution (for 640x200 1-bit)..

After I have found the best match for this, I will then work on accessing the video hardware directly.

commodorejohn
July 22nd, 2012, 11:27 AM
How many frames in that 40KB? What are you using for compression? (As I said, even simple RLE should do pretty well on that particular video, and it's easy to implement with a REP STOSB or REP STOSW on the 8086...)

evildragon
July 22nd, 2012, 11:32 AM
It's about 100 frames, with LZW compression..

Would RLE be better than LZW? Or could that be also why it's so slow?

Right now the images are 82x61 pixels..

evildragon
July 22nd, 2012, 12:27 PM
I modified the video file.

1-bit monochrome now, no shades of grey wasting resources. I couldn't get 640x200 to work, 640x480 1-bit is FAR too slow, it's terrible actually.

So I am using CGA mode 320x200.

http://youtu.be/lm_mgy9c4aQ

I also interleaved the video data so it appeared smoother.

Still reading up on directly accessing hardware.

commodorejohn
July 22nd, 2012, 01:03 PM
LZW is going to give you better compression, but it's also going to take a lot more work to decompress. On your target hardware, it's probably not worth the trade-off. Given that your video can probably achieve pretty good compression with RLE, I'd suggest giving that a try instead.

evildragon
July 22nd, 2012, 01:07 PM
LZW is going to give you better compression, but it's also going to take a lot more work to decompress. On your target hardware, it's probably not worth the trade-off. Given that your video can probably achieve pretty good compression with RLE, I'd suggest giving that a try instead.

Ok, I'll do that, I'll switch to RLE.

commodorejohn
July 22nd, 2012, 01:46 PM
I'd switch to direct hardware access first, though, that's easily going to make the most difference in performance. Even using a simpler compression scheme won't help much when you're drawing every pixel individually by the slowest possible method. With direct hardware access and RLE, you can slab eight pixels per memory access on the solid-color areas (or sixteen, even,) and only have to fetch new data bytes on the boundaries.

evildragon
July 22nd, 2012, 03:52 PM
Wow so directly accessing video hardware isn't that hard at all. Pretty easy, especially the way I'm going to be using it.

Now I'm still interleaving the video to memory, just seems to work a LOT better, but with RLE, and directly accessing video, a video with 64x48 pixel video played FULL speed! It had some garbage in the interleaving, but it worked!

Too bad it's not full screen. I'm working on compiling the full video right now, and running it on real hardware, and will tape it, with the music.

commodorejohn
July 22nd, 2012, 04:08 PM
Great to hear :) What's "garbage in the interleaving?"

evildragon
July 22nd, 2012, 05:01 PM
Great to hear :) What's "garbage in the interleaving?"

You'll see what I mean..

http://www.youtube.com/watch?v=OKyolreDW04

If it's high enough motion, there appears to be some skipping of lines it does, as if it's forgetting to even draw a field...

evildragon
July 22nd, 2012, 05:29 PM
Well this ain't good. After I played this demo, I had a problem accessing my DOS prompt, got a general error reading drive C:.. Rebooted, and got the missing command.com prompt.. Sooooooooo.. I used my boot disk, sys'ed C:, and it's booting, ran a scan disk, and have a few bad sectors..

I don't know if thats coincidence, or a major bug in my program.

njroadfan
July 22nd, 2012, 05:35 PM
Looks like interlacing artifacts like you would see if you view 480i video on a computer monitor.

evildragon
July 22nd, 2012, 05:43 PM
Looks like interlacing artifacts like you would see if you view 480i video on a computer monitor.

Well, there's an extra effect, but I think I know what it is.. I wrote in the program, to skip video writes, if the CPU is falling behind, and I think this is the extra effect I'm seeing..

What I see every once in a while is this. If the CPU isn't going to be fast enough to output the 2 fields one after enough, it'll output one "half" of a field.. Essentially a field with only half the information but spaced correctly. Leaving this effect.
http://img.photobucket.com/albums/v395/Evilweredragon/ScreenShot2012-07-22at94015PM.png

Those interleaved scanlines are not every other line, but every 3rd line.. (or 4th it would appear, im not counting)

basman74
July 22nd, 2012, 09:06 PM
@evildragon
Although it probably isn't within the Model 25's default MCGA capabilities, you could also consider using 320x200 EGA to render the video. Here's why:

1.) You only need to update 8KBytes of video RAM (located @ A000:0000 -> A000:1FFF)
2.) Unlike CGA, the address mapping is completely linear
3.) Like 620x200 CGA mode, every pixel is represented by one bit..

Here's some example code of the above:



; 320x200 EGA quick/dirty write example
; Note: this example and only meant to demonstrate how to
; do simple data writes to the EGA display buffer - assumes one EGA 'video page' is used
;
; By Valentin Angelovski

; To be assembled as a .COM file
org 100h


; Set to 320x200 EGA video mode
mov ax,0Dh
int 10h


; Point to EGA video buffer segment
mov ax,0A000h
mov ds,ax

; Set color mask value to white
mov ch,0Fh

; Now update color mask value
mov al,02h
mov dx,3C4h
out dx,al

mov bx,0

mov dx,3C5h
mov al,ch
out dx,al


; Write 4 rows x 8 pixels to the EGA video buffer (8KB total buffer size, starting from A000:0000h)
mov cl,0FFh ; Set all eight pixels to white
mov [bx],cl ; write to A000:0000
mov bx,28h ; Jump to next scanline


mov cl,055h ; Send pixel pattern #1
mov [bx],cl ; write to A000:0028
add bx,28h ; Jump to next scanline


mov cl,0AAh ; Send pixel pattern #2
mov [bx],cl ; write to A000:0050
add bx,28h ; Jump to next scanline


mov cl,011h ; Set only two pixels out of eight
mov [bx],cl ; write to A000:0078

; wait for key press:
mov ah, 0
int 16h

ret



Using the above code with REP STOSB together with RLL decoding as mentioned previously, I'm fairly certain it'll be a quick solution..

Regards Valentin

evildragon
July 22nd, 2012, 09:17 PM
MCGA has no EGA modes sadly, otherwise I'd try that.

evildragon
July 22nd, 2012, 10:28 PM
Wow I'm already fighting copyright claims for this video.

That's ironic, it's a remix of a video game tune, how can you legally even copyright a remix of something that was NOT copyrighted in the first place?

ARGH! There are hundreds of others with these same songs in their entirety with no permission and has been there for a few years, yet I get the claim.

I give up, I can't have any good music on my videos. Guess I'm gonna have to make a remix of my own, for the remix, of a game tune.

pearce_jj
July 22nd, 2012, 11:26 PM
Do you have some way to convert the video to an arbitrary resolution? 160x100 1-bit would be ideal for something I've been pondering, but each frame needs to be a straight bit-map, with 22kHz mono audio if possible!

commodorejohn
July 23rd, 2012, 12:21 AM
Wow I'm already fighting copyright claims for this video.

I give up, I can't have any good music on my videos. Guess I'm gonna have to make a remix of my own, for the remix, of a game tune.
Gah, that's nuts...maybe you can get a good FM-head to do an OPL2 cover.

RWallmow
July 23rd, 2012, 03:53 AM
Gah, that's nuts...maybe you can get a good FM-head to do an OPL2 cover.
I would ask the NES guy if you can use his version of the music, its totally awesome, lol.

Very nice job by the way evildragon, I will have to try it out on my 25.

Are you doing this with the V30 in your 25, or are you back on stock 8086? I would think the V30 might give you a TINY edge over the stock 8086 since I have heard it can execute some of the 8086 instructions in less cycles, though I don't know how relevant those instructions would be to this task.

njroadfan
July 23rd, 2012, 05:29 AM
Wow I'm already fighting copyright claims for this video.

That's ironic, it's a remix of a video game tune, how can you legally even copyright a remix of something that was NOT copyrighted in the first place?

ARGH! There are hundreds of others with these same songs in their entirety with no permission and has been there for a few years, yet I get the claim.

I give up, I can't have any good music on my videos. Guess I'm gonna have to make a remix of my own, for the remix, of a game tune.

Fake copyright claims are rampant on youtube. The fake entities randomly claim videos to divert ad revenue to their pockets. I had a copyright claim on a video that was 100% original content and was just me talking, no music at all. Needless to say they backed off the instant I challenged. They are even trying to claim copyright on commercial works they don't own the rights to. Who was it that is giving your video a hard time?

VileR
July 23rd, 2012, 06:05 AM
For a video like this I really would suggest text mode. 40x25 will give you an effective resolution in the same ballpark as your most recent video, only it would fill the screen instead of being stuck in a corner. If you keep it monochrome the attribute bytes are out and it's only 1000 bytes/frame. 80x50 will quadruple that. And there's no interleaving!

If you need music, there's always Trixter's MONOTONE tracker for the PC speaker. ;) though I don't know if he made any libraries available to programmers?

evildragon
July 23rd, 2012, 06:18 AM
I would ask the NES guy if you can use his version of the music, its totally awesome, lol.

Very nice job by the way evildragon, I will have to try it out on my 25.

Are you doing this with the V30 in your 25, or are you back on stock 8086? I would think the V30 might give you a TINY edge over the stock 8086 since I have heard it can execute some of the 8086 instructions in less cycles, though I don't know how relevant those instructions would be to this task.

I was indeed using the V30. I wasn't using any V30 instructions though.

I'm still trying to figure out why my disk keeps getting corrupt after the video though.. I tried another disk, and same thing, so I don't want to release until I figure that out.

RWallmow
July 23rd, 2012, 06:41 AM
...I'm still trying to figure out why my disk keeps getting corrupt after the video though.. I tried another disk, and same thing, so I don't want to release until I figure that out.

Is this on an XTIDE? Or are you using stock onboard HD controller, or some other hard-card or SCSI card?

evildragon
July 23rd, 2012, 06:54 AM
It's happening on the XT-IDE, and the original MFM drive (though the XT-IDE is also present, if that matters).

It seems, wherever it's being run from, it corrupts the disk..

Maybe when I'm directly accessing video, perhaps I have the wrong address somewhere in my code, and am poking data in the wrong spot.

evildragon
July 23rd, 2012, 07:06 AM
Fake copyright claims are rampant on youtube. The fake entities randomly claim videos to divert ad revenue to their pockets. I had a copyright claim on a video that was 100% original content and was just me talking, no music at all. Needless to say they backed off the instant I challenged. They are even trying to claim copyright on commercial works they don't own the rights to. Who was it that is giving your video a hard time?

Unless I'm reading the claim wrong, it looks like its the singer that is issuing the claim. It's not blocked though so I'm confused.

Pepinno
July 23rd, 2012, 09:05 AM
Unless I'm reading the claim wrong, it looks like its the singer that is issuing the claim. It's not blocked though so I'm confused.

Just challenge the claim. Argue your video is a non-profit fan-made derived artwork and at the same time an original creation in itself, and as such protected by copyright exceptions in copyright law.

evildragon
July 23rd, 2012, 09:23 AM
Just challenge the claim. Argue your video is a non-profit fan-made derived artwork and at the same time an original creation in itself, and as such protected by copyright exceptions in copyright law.

Even though the music isn't modified? I think that's where it's getting at. They aren't claiming the video itself, but the audio track. I mean, I kinda get what they mean on that regard, I didn't modify the audio.. But yea, it's non-profit.

When I do a 80x25 text mode version, I'm going to just make my own remix version. I plan on doing that anyway so I'll just make it my own the.

evildragon
July 23rd, 2012, 09:24 AM
For a video like this I really would suggest text mode. 40x25 will give you an effective resolution in the same ballpark as your most recent video, only it would fill the screen instead of being stuck in a corner. If you keep it monochrome the attribute bytes are out and it's only 1000 bytes/frame. 80x50 will quadruple that. And there's no interleaving!

If you need music, there's always Trixter's MONOTONE tracker for the PC speaker. ;) though I don't know if he made any libraries available to programmers?

I'm going to shoot for 80x25.. I think that'll look a little better, but still be do-able.

ChrisCwmbran
July 23rd, 2012, 09:26 AM
Why don't you change the music track? There must be plenty of sources of free to use music around on the net.

evildragon
July 23rd, 2012, 09:35 AM
Why don't you change the music track? There must be plenty of sources of free to use music around on the net.

Because then it's not a Bad Apple!! demo.

Original: http://www.youtube.com/watch?v=VzEUeWnV73U

The animation was designed to go with this music.

commodorejohn
July 23rd, 2012, 09:35 AM
Why don't you change the music track? There must be plenty of sources of free to use music around on the net.
'Cause the point was to convert that particular music video, I'd assume.

ChrisCwmbran
July 23rd, 2012, 09:37 AM
Oh sorry. I thought it was the animation people are interested in.

evildragon
July 23rd, 2012, 09:44 AM
Meh, it's ok. But yea, the animation goes with the music, so it's hard to change the music..

But I just had a thought, if I am going to be using text mode, why don't I just make this a 8088 corruption video file? I'll install a soundcard if I had to, just to do it. (Of which I could technically do, I just have to remove my ethernet card).

Pepinno
July 23rd, 2012, 10:38 AM
But I just had a thought, if I am going to be using text mode, why don't I just make this a 8088 corruption video file? I'll install a soundcard if I had to, just to do it. (Of which I could technically do, I just have to remove my ethernet card).

I say go for it, with the sound card. Also, if you could capture the video output with a video capture card, it would look much better in the youtube video.

Pepinno
July 23rd, 2012, 10:41 AM
OMFG!!! I just have to share this "music remix" with you all:


http://www.youtube.com/watch?v=hkZbAJHeu9w&feature=related

RWallmow
July 23rd, 2012, 10:56 AM
...Also, if you could capture the video output with a video capture card, it would look much better in the youtube video.
The model 25 doesn't have a video out or even a monitor plug, he would have to hack into the internal video lines, and I am not sure he would want to do that.

RWallmow
July 23rd, 2012, 10:57 AM
OMFG!!! I just have to share this "music remix" with you all:


http://www.youtube.com/watch?v=hkZbAJHeu9w&feature=related

That is awesome, was linked earlier up in the thread. Gotta love all the different music these guys have floppy drives playing with an audrino, makes me want to buy one and learn how to program it, lol.

commodorejohn
July 23rd, 2012, 11:36 AM
Meh, it's ok. But yea, the animation goes with the music, so it's hard to change the music..

But I just had a thought, if I am going to be using text mode, why don't I just make this a 8088 corruption video file? I'll install a soundcard if I had to, just to do it. (Of which I could technically do, I just have to remove my ethernet card).
I dunno, I'd say keep pursuing the monochrome bitmap idea. It's a great concept, and with a video this simple, I think it could really work.

If you don't, I might have to ;)

evildragon
July 23rd, 2012, 11:49 AM
Well what I have right now is all I've been able to push. It was 14MB though, and that's with RLE compression. It probably could be optimized better, like how I order the frames in the executable, but I'm hitting a limit, on how fast the computer can actually draw.

Now, is it possible, at all to do what old game systems can do, kill the raster after a certain spot to free up DMA time? I couldn't find much on that for MCGA, or what effect it would do to the screen.

commodorejohn
July 23rd, 2012, 12:28 PM
I don't know too much about the internal architecture of MCGA PCs, but unless it's built like Tandy 1000 systems where the video actually steals system memory, then it shouldn't be stealing CPU cycles for DMA. In any case, raster-timing stuff is a lot trickier on the PC; only the EGA and VGA even have a split-screen facility, as far as I know. Probably not worth the trouble.

The thing about RLE is that with a video like that, it's likely to get much more efficient as you size it up, in terms of disk bandwidth, since you have many more solid-color bytes in a row that can be compressed down. With a 64 x whatever bitmap, the most you can hope for is to squash an eight-byte line down to two (maybe one if you tweak your compression technique to allow for long stretches of solid pixels, or you could also allow it to extend a run of bytes past the end of a line and onto the beginning of another.) With a 640 x 200 bitmap, on the other hand, you could go so far as to get an 80-byte solid-color line down to one or two bytes - a much greater savings.

That doesn't address the issue of how much data the CPU can push over ISA, but still, it might be worth a shot.

Tronix
December 14th, 2012, 12:26 AM
Hi guys,

I really like SEGA bad apple demo, so i want try to code 'bad apple' for XT with full screen CGA resolution 320x200. I am downloaded original bad-apple video, crap size to 320x200, then with help VirtualDub save images sequence. As result i get ~6500 bitmaps. Then i write simple converter from BMP file to CGA memory format:

11301

My main idea - minimum operation in result program, only copy pre-calculated image to video segment B800:0000. (rep stosw) But One CGA file have fixed size 16384 bytes. Too much for 6500 frames. I am try use simple RLE encoding alghoritm from PCX format:


1. if both bits are 1, the byte is interpreted as the run length. This leaves 6 bits for the actual run length value, i.e. a value range of 0-63
2. in any other case, the byte is interpreted as a single pixel value. This leaves all value for which bit #7 and bit #8 are not 1 at the same time. This requirement is not met by all values of 192 (binary 11000000) and above.


I compress all frames with PCX RLE to ~13 Mb, but i think it is too bad for XT. Each frame compress from 16Kb to 600-3000 bytes. Need more effictive compression alghorithm...

commodorejohn
December 14th, 2012, 07:56 AM
I made some suggestions earlier in the thread, but it mostly boils down to coming up with something that's tailored for CGA, not adapted from a VGA compression algorithm. RLE would be a good choice for this video, just not when it thinks in terms of byte pixels.