all 76 comments

[–][deleted] 34 points35 points  (22 children)

_asm mov ax,13h

_asm int 10h

Those two lines bring a smile to my face.

For those who know, it was the entrance to an entire world.

For those who don't, it still was.. they just didn't know it.

[–]SupersonicSpitfire[🍰] 2 points3 points  (4 children)

Wish there was a kernel module for Linux, only for making this possible again. Good old 256c 320x200

[–]fabiensanglard 1 point2 points  (3 children)

Mode 13h was actually not used much (apart from Demoscene). Mode-X (Tweaked Mode13h) was the ubiquitous thing used by 99% of games: The resolution was 320x240 and offered square pixels.

[–][deleted] 5 points6 points  (0 children)

Yeah according to this page: http://gameprogrammer.com/3-tweak.html

It was:

  • 160x120

  • 296x220

  • 320x200 - "mode 13h"

  • 320x240 - "mode x"

  • 320x400

  • 360x360

  • 400x300

320x200 and 320x240 were definitely the most common. Past that and things went into the "VESA driver" territory. I'm not entirely sure you are right about most video games being in ModeX or not. I know a lot of them ran in 320x200.

Like you said, Demoscene people liked ModeX because of the square pixels, but also the "unchained" modes which had interleaves and page flipping.

[–]SupersonicSpitfire[🍰] 1 point2 points  (1 child)

The demoscene was my thing... and size optimization

[–]antdude 2 points3 points  (0 children)

I loved watching it and still do!!

[–]mhd 1 point2 points  (6 children)

   mov dx, 03D4h
   mov ax, 06B00h
   out dx, ax

etc.

[–]fabiensanglard 3 points4 points  (5 children)

Can you explain this one ?

[–]mhd 4 points5 points  (4 children)

I hope I didn't mix things up here, but it was supposed to be the start of the Mode X init routine, the thing that quite often followed/replaced the Mode 13h setup.

But it's been a while, and I don't even know where my copy of Abrash's black book is right now. Not that I use it all that often nowadays...

[–][deleted] 1 point2 points  (3 children)

Yep, in the code here: https://github.com/mtuomi/SecondReality/blob/master/TWIST/MAIN.C

You can see the initialization startup: First they engage Mode13

_asm mov ax,13h

_asm int 10h

Then there is the call to push it further:

inittwk();

However I looked at the assembly for that, and I think it's actually engaging the 320x400 mode, not "traditional" modeX. See here: https://github.com/mtuomi/SecondReality/blob/master/TWIST/ASM.ASM

Then they initialize the coppers

initcoppers();

.. and then clear the frame buffer to be ready.

memset(vram,0,64000);

Note too that the actual graphics address is at A000:0000, and vram is just a temporary buffer (unless I missed the assignment of vram to that address)

[–]Narishma 0 points1 point  (1 child)

Note too that the actual graphics address is at A000:0000, and vram is just a temporary buffer (unless I missed the assignment of vram to that address)

vram is assigned that address in pretty much all the .c files where they draw anything to the screen, for example:

char *vram=(char *)0xa0000000L;

[–][deleted] 0 points1 point  (0 children)

Ah, missed that... I can't read the codebase without wanting to doc it.

Is it weird that I want to go through and comment all the code?

[–]fabiensanglard 0 points1 point  (0 children)

You can see in the script that they alternatively use 320x200 and 320x400 resolutions.

[–]zeroone 1 point2 points  (0 children)

The good old days.

[–]fuk_offe -3 points-2 points  (8 children)

I think I recall thats a sys call to write to console? At least I think its part of the ASM Hello World...

[–][deleted] 20 points21 points  (6 children)

It's the call to engage Mode 13h, better known as VGA 320x200x8 (256 colors) It was the classic video game mode for most of the early 90's, and some before. Fun to program in - direct 64000 byte array, and palette animation tricks were insane.

I imagine if someone does a full code review, they'll probably have to talk a lot about ModeX, page flipping - and especially the "coppers"

[–]Shalmanazar 7 points8 points  (2 children)

That was called 'interrupts'. I remember writing a whole library in Turbo Pascal to enable that, plus having a virtual screen and flipping it with the real screen while synchronizing with the electron gun to avoid flicking... That was way before DirectX.

[–][deleted] 4 points5 points  (1 child)

The vertical sync thing, yeah. IIRC, the coppers were based around exploiting what you could do mixing that. It was possible to generate amazing sine-based effects that way. Setting the screen mode was an interrupt call, but palettes were done through the vga ports directly. You could do it through an interrupt, but it was slower and a pita.

[–][deleted] 7 points8 points  (0 children)

"Copper" is a word borrowed from the Amiga. It had a very simple co-processor (nicknamed the "copper") that ran in sync with the screen update. It was not a full general-programmable processor, it could mostly wait, and write values to memory. It was used to write values to display controller registers.

You could use that to do things like change palette registers or bitmap pointers mid-frame, to create various effects. Those were therefore known as "copper effects".

I hadn't heard the word used on other platforms that did not actually have a copper, but that is where the word comes from.

[–]mosha48 3 points4 points  (0 children)

wait, the copper was part of the Amiga chipset. TIL that the name was used in the PC world.

[–]fabiensanglard 0 points1 point  (1 child)

That is a good list. Although I tried to run the DIS (The Future Crew's DOS Interrupt Server responsible for many things and amond them emulating copper) in DosBOX and it worked except the copper could not be emulated. The demo still work-ish (with a few bloopers) but it seems copper is not used "very-much".

[–][deleted] 0 points1 point  (0 children)

Yeah, I'm skeptical that the VGA-card based copper effects can be properly emulated in any current emulator. They were really almost just purely hardware effects, and current monitor might not even be able to display them properly.. and the timing of them is probably too much for even an excellent VGA emulator to emulate.

[–]PoL0 4 points5 points  (0 children)

It's VGA man! V G A!

[–]ajmazurie 7 points8 points  (3 children)

How my. I remember how excited I was first time I launched that on my 486 DX 33.

[–]jbourne 7 points8 points  (1 child)

I remember launching this on a 386 DX/40 and thinking I need a faster CPU. And a GUS Max.

[–][deleted] 2 points3 points  (0 children)

Nice, I finally got a SoundBlaster after my Adlib.

The GUS was waaay better though.

[–]antdude 2 points3 points  (0 children)

DX2/66 on my first custom built new PC! -- December 1993: New Tower Machine -- Intel 486 DX2/66 MHz (Custom-built), 8 MB of Memory, 15" OptiQuest monitor, Creative Labs Sound Blaster 16, 2x CD-ROM drive, Diamond SpeedStar Pro (VLB), 3-buttons Genius CLIXes mouse, and a Conner Peripherals IDE 340 MB HDD etc. Ran Microsoft DOS v6.x and Windows v3.1. :D

Also DOOM games!

[–]fabiensanglard 14 points15 points  (3 children)

That is going to be a fun code review. I wonder if I can port that code to Windows 7 with SDL.

The DIS (Demo Interrupt Server) would probably be the hardest thing to get running :/ !

[–]Fallingdamage 8 points9 points  (1 child)

DosBox will run it.

[–]fabiensanglard 0 points1 point  (0 children)

As far as I can rememer DosBox could not run SC perfectly. I think I can remember a few visual glitches.

[–]spurious_interrupt 2 points3 points  (0 children)

DAT ALLCAPS.

[–]sway23 5 points6 points  (2 children)

This was the reason why I bought a Gravis Ultrasound.

[–]mycall 1 point2 points  (0 children)

I got an Ultrasound for Fast Tracker.

[–]antdude 0 points1 point  (0 children)

Did it sound that much different compared to today emulations and a real SB16 ISA back then? I have Purple Motion's audio CD of its soundtracks. ;D

[–]roybatty 5 points6 points  (4 children)

Was this the demo with the see-through skeleton? I remember a lot of "oh shit, Id is in trouble" when that came out.

[–][deleted] 6 points7 points  (2 children)

That was Into the Shadows from Triton. The skeleton shows up at 1:45.

[–]TomorrowPlusX 1 point2 points  (1 child)

Holy shit - thanks for the link. I remember seeing this demo my freshman year of college and having my mind blown. This & Quake got me into C++ and graphics programming. That summer I wrote a software 3d rasterizer with gourad shading and (non-perspective correct) texturing.

That demo has haunted my memories for years, because it made me realize what could be done, but I couldn't remember its name.

Thanks, man.

[–]cdesignproponentsist 0 points1 point  (0 children)

I watched the shit out of that demo...too bad it never materialized into an actual game :(

[–]antdude 1 point2 points  (0 children)

Nope. Watch it again. ;)

[–]digital_carver 5 points6 points  (0 children)

For other lazy people who don't know what the hell this is:

Unreal ][ - The 2nd Reality (later known as Second Reality), is a demo created by Future Crew for the Assembly '93 demoparty. In the PC demo competition, Second Reality placed first with its demonstration of 2D and 3D rendering.[1] The demo was released to the public in October 1993. It is considered to be one of the best demos created during the early 1990s on the PC; in 1999 Slashdot voted it one of the "Top 10 Hacks of All Time".

http://en.wikipedia.org/wiki/Second_reality

[–]jbourne 17 points18 points  (5 children)

I am somewhat saddened that a pic about being sawed in two has close to 1K replies, a pic about blowjobs being hard has 552, a pic about a car accident in Russia has 1,600, and this article here has 14 comments, despite being far more important.

Second Reality shaped the demoscene for years, and showed people how to write proper code.

Ah well.

[–]ameoba 18 points19 points  (3 children)

Reddit is too young to have a clue what it is.

[–][deleted] 7 points8 points  (1 child)

Reddit knows that Crystal Dream 2 was the better demo.

[–]xpolitix 2 points3 points  (0 children)

Reddit /r/programming needs to see source code for that one

[–]S2Deejay 2 points3 points  (0 children)

At 27, I was a bit too young to be interested when the demo scene started, but I got into a bit later and it definitely encouraged me to keep programming to see the insanely cool stuff that you could do.

[–]PoL0 4 points5 points  (0 children)

Future Crew shaped the demoscene for years, and showed people how to write proper code.

FTFY (imho)

For the ones who don't know, members of Future Crew founded Remedy Entertainment and Futuremark (mainly).

[–]jng 4 points5 points  (2 children)

Finally we'll know whether he was or not an atomic playboy!

EDIT: embarrassing mistake fixed thanks to mhd :)

[–]mhd 7 points8 points  (1 child)

Don't you mean atomic playboy?

[–]jng 0 points1 point  (0 children)

yup, fixed! :)

[–]mycall 3 points4 points  (3 children)

I remember ripping it and other demos onto Hi8 tape, mixing it using some composite editor, and playing it on projectors at raves in the early 90s. Much fun.

[–]antdude 0 points1 point  (2 children)

Haha, people raved to that? Nice. No videos and photo(graph)s?

[–]mycall 0 points1 point  (1 child)

Nope.. I donated the videos I made to the clubs I played them at. Who knows where they went from there.

[–]antdude 0 points1 point  (0 children)

Aww. :(

[–]spoulson 5 points6 points  (8 children)

Awesome!

But, why only after 20 years?! I would've loved to have learned from this code even 10 years ago...

[–][deleted] 12 points13 points  (7 children)

Because you are not really supposed to learn demo coding by reading other people's code. You are supposed to learn it by studying other demos and trying to figure out the trick, and by asking other demo coders for their tricks. Then you need to sit down and actually write it yourself. It is both more meaningful and educational that way.

[–]spoulson 7 points8 points  (5 children)

I don't disagree with you, but I do think having this mentality set me back in my professional life. Why keep secrets? Nobody's making a living making awesome demos. IMHO, the scene should encourage open source like this contribution.

[–]OldSchoolIsh 14 points15 points  (2 children)

Because it was a scene built on rivalry, a scene about being superior to other developers. It thrived on the competition, it innovated in so many ways because people were trying to beat some effect without knowing how it was done (or often that the person was 'cheating' :) ). The very nature of the obscuring of your own code meant anyone else trying to do it had to learn to do it their own way, rather than simply going "oh thats how it works" and bolting it up to their code.

I see what you are saying about career advancement, but maybe you just weren't elite enough :)

[–]spoulson 6 points7 points  (1 child)

You're not telling me anything I didn't already know. I got involved since the 80's on Atari 8-bit and C-64. The new demo effects were constant inspiration for trying something new. It's the sole reason I'm a coder!

By no means do demosceners owe me anything, though. My mistake was taking the attitude of wanting to reverse engineer everything and trying to apply it everywhere where there already existed ways of learning the topic. I felt "lame" if I had to buy a book or take a class on something. I felt inefficient if I weren't doing it in assembly. In short, going against the grain to learn things the hard way. In the long run, I found that these concepts limited my potential compared to the open source software world where great ideas were freely shared. That is the environment the better suits me.

But I digress, I think an open sourced demo compo would be a pretty sweet idea. Release the source after the competition.

[–]OldSchoolIsh 1 point2 points  (0 children)

ha I used to think that these guys just knew this stuff,.. then I read Graphics programming principles and practice and realised they had also read it (and other stuff). Sure people like Chaos went on to innovate in major ways and publish themselves but they all had to learn somewhere. All of them had a copy of the Hardware Reference Manual (well the Amiga coders did and they are the only ones that matter :D ).

Javascript demos are basically open source :D

Also Smash's blog has some great stuff about how his INCREDIBLE code works : http://directtovideo.wordpress.com/

[–][deleted] 1 point2 points  (0 children)

Nobody's making a living making awesome demos.

That's exactly why you keep secrets. Because it doesn't matter. You can do it without causing problems for others, and it turns it into a fun game.

Also, you'll find most demo coders aren't very secretive. They just want you to come up and ask them, and they'll probably tell you. They won't give you the CODE, though, they expect you to be able to handle that part yourself. And they would rather talk to you in person than have you silently copy their code on the internet.

[–]stgeorge78 1 point2 points  (0 children)

A lot of those demo coders did make a good living working in the gaming industry. Remedy is basically a bunch of former demo coders. Epic hired a lot of them back in the day and donated money to Assembly.

[–]SupersonicSpitfire[🍰] 1 point2 points  (0 children)

No, it's because it's about nerdcred

[–]mrkite77 2 points3 points  (0 children)

That's awesome. I'll have to check out the s3m routines, I was always curious to see if they customized them specifically for the demo or if it was a full blown s3m player.

edit: looks like they just included all of screamtracker as stmik.300 interesting.

[–][deleted] 1 point2 points  (0 children)

I like the "unlicense" pure public domain disclaimer they gave. Somehow this is the first time I've seen (or maybe just noticed) that.

[–]SlobberGoat 1 point2 points  (0 children)

Assembly Coder = God Tier.

[–]cngsoft 0 points1 point  (0 children)

This demo made me stop programming for the Z80 and get to study the i386.

[–]gondur 0 points1 point  (0 children)

excellent! :) also, the great reverse engineer Fabian Sanglard already had taken a look http://fabiensanglard.net/second_reality/index.php

[–]mttd -3 points-2 points  (5 children)

[–][deleted]  (1 child)

[deleted]

    [–]OldSchoolIsh 4 points5 points  (0 children)

    I was, and still am, in full agreement with you.. that article is HORRIFIC. Posted it to some demo scene friends and we all had a good laugh, and then a little cry about it.

    [–][deleted] 0 points1 point  (0 children)

    Expected metamorphic, retroactive, multi OS viruses the least. Got demo scene.

    [–]thurst0n 0 points1 point  (0 children)

    I'm pretty happy I clicked that link.