bonzini 2 days ago

Jazz Jackrabbit employs some really unique VGA programming to do fast blitting. Relatively many people are familiar with linear mode (64K of usable memory, fast blitting but no double buffering) and mode X (256K memory, complicated or slow blitting, and double buffering at 320x240).

Jazz was as far as I know the only game to use odd/even mode, which is normally used for text mode, for 256 color graphics. It gives 128K of memory, extremely fast blitting and double buffering at 320x200 and is a super interesting hack, but it's almost completely undocumented. I only found out because QEMU made a mess of it until I decided I wanted to play some Jazz. :)

  • bananaboy 2 days ago

    It’s not really that unusual. It’s a tweaked mode-x. The original programmer Arjan Brussee even says this https://retrocomputing.stackexchange.com/a/14403/25183

    • bonzini a day ago

      I am not aware of any other game using the variant with odd/even mode, nor of any documentation of how the blitting worked. Maybe someone should ask Arjan about the source code that he mentioned on stackexchange. :)

      • bananaboy 14 hours ago

        I guess he never did release it but it would be pretty cool if he did!

  • Cumpiler69 2 days ago

    >Jazz Jackrabbit employs some really unique VGA programming to do fast blitting

    Isn't this similar(identical?) to the tricks John Carmack used to get side scrolling Mario clones like Commander Keen working on the PC platform, who's rudimentary graphics system couldn't do that back then?

    • bonzini 2 days ago

      No, it's not. Keen 1 was a 16 color game; 16 color games pack 8 pixels in a byte and spread the color information across 4 planes. Accessing the different planes requires programming the video card's registers and there isn't really a way to change the representation of the pixels in memory, what Carmack did was write fast blitting routines and use the hardware's smooth scrolling capabilities. All these were hiding in plane sight in the EGA/VGA manuals, they are exactly how the hardware was supposed to be used even though nobody had done it before Keen.

      256 color modes are a different beast. The VGA can only load four bytes at a time but those four bytes must have the same address and come from the four planes. So whereas the 16 color mode split the color information across planes, 256 color modes put a whole pixel in a byte and four adjacent pixels go into four planes. Normally you want 1 byte per pixel and ignore planes completely, so the hardware is programmed to remap bits 0-1 of the address to the planes and do some magic so that reads also work as intended. You can still do smooth scrolling in this mode, but double buffering requires more expensive copies from VRAM to main memory.

      Michael Abrash then noticed that this is absolutely not necessary and you can use planes in 256 colors mode. Unlike Carmack's Keen, this was completely undocumented. In retrospect it's quite obvious: the VGA was composed of two completely independent pieces of hardware dealing respectively with CPU accesses to VRAM and creating the video output from VRAM contents, and as long as the two are programmed in a compatibile manner things just work. But still it's not how you were supposed to do 256 color graphics on the VGA.

      This was called "mode X" and it gives you several benefits: VRAM to VRAM copies are cheaper, which you can use for both blitting and double buffering, and you have access to 256K of memory which enables higher resolutions (theoretically up to 360x480, in practice everybody used 320x240). This worked well for games like DOOM or Wolfenstein 3D that redrew the whole screen at once, however the wins for blitting were a lot less clear because dealing with the 4 planes meant more complicated routines and a lot of writing to the card's registers.

      So what Jazz does is use a middle ground mode where you have bit 0 of the address used to pick 2 planes and the other 2 are picked through the video card's registers. Normally this is used in text mode so that even bytes describe characters and odd bytes describe colors, hence odd/even mode. Jazz applies it to 256 color mode and then it only addresses pairs of pixels at once, so that it doesn't have to program the video card registers as much as in 4-plane mode X. Essentially the graphics mode is a 160x200 matrix where each of the 160 horizontal cells is composed of two pixels.

      • phire a day ago

        > All these were hiding in plane sight in the EGA/VGA manuals, they are exactly how the hardware was supposed to be used

        Well...

        Keen 1-3 only scrolled by a maximum of 16 pixels. After that, it would reset the scroll and copy the entire screen over by 16 pixels (one tile). In order to reduce the amount of copying, the levels were all designed with repeating patterns to minimise the number of changed tiles on each scroll.

        Why? Because the documentation didn't say what happened if the hardware scrolling wrapped around, and Carmack carefully designed the engine to avoid this potential edge case. They named the technique "Adaptive tile refresh".

        For episodes 4-6, Carmack was confident enough in the wrapping behaviour of hardware scrolling, and the engine was redesigned to take advantage of this. I guess they had tested enough 3rd party EGA cards to be sure they all behaved in the same way.

        This removed the need for repeating patterns in the level, allowing for much improved graphics. Though they did need to add a compatibly mode that avoided wrapping across the 64KB boundaries, as some SVGA cards did the wrong thing.

        So the scrolling was documented, but perhaps not well enough.

        • bonzini a day ago

          Indeed, wrapping around the end of VRAM is another thing that I had to fix in QEMU[1]. :)

          > So the scrolling was documented, but perhaps not well enough.

          That's certainly possible - 10% inspiration and 90% perspiration, as they say. However, the same video card features were present on a lot of 80s hardware and the basic techniques were used for side scroller games on other platforms as well, especially the Amiga with its excellent offloading of VRAM copies.

          For example, Turrican II[2] was released around the same time as Keen. http://uridiumauthor.blogspot.com/2017/12/scrolling-on-amiga... says:

          "to get the screen scrolling sideways [...] all we had to do was allocate a few extra bytes at the end of our buffer, as many as we wanted to scroll one pixel row sideways from one side of the map to the other, in fact, say 20x2x10 bytes, i.e. 400 bytes per buffer, not much at all."

          "So, starting from top left, we start smooth scrolling by 1 pixel to the right. This is done with the hardware scroll X register. What it's really doing is throwing away the number of pixels you tell it, from 0 to 15, before it starts displaying the screen picture. Our screen buffers always support one more character wide and high than the screen is; because in 15 out of 16 cases that extra character row or column is partially visible."

          "When you get to 16 pixels across you reset the Scroll X position to 0, and add one word (16 bits/pixels to the pointers to the start of the buffer display [...] At this point we need to build the incoming column of characters to the right"

          [1] https://lore.kernel.org/all/20231231093918.239549-4-pbonzini...

          [2] https://en.wikipedia.org/wiki/Turrican_II:_The_Final_Fight

          • phire a day ago

            From what I can tell, the reason that games using smooth scrolling are rare on IBM PC is that while fine scrolling was documented on EGA, it wasn't possible on CGA without undocumented demoscene style hacks. Amega and all the consoles had smooth scrolling in the base configuration, so many games used it.

            While EGA was introduced all the way back in 1984, most games were designed for CGA first, as there was a massive install base of CGA cards, with enhanced EGA/VGA versions. So really, the major innovation of the Keen 1-3 engine was actually the fact that it dropped support for CGA, allowing it to finally take advantage of EGA's smooth scrolling.

            Ironically, CGA was still popular enough that they released CGA versions of Keen 4-6 (1991). They simply scroll in 4 pixel (one byte) increments.

Gormo 2 days ago

Looks and sounds great, and works at resolutions greater than 320x200! The game content consists of raster tiles and sprites, so I've just set to to 640x400, which works great on my 1920x1200 display.

Although that website contains what must be the most egregious misuse of a hamburger menu I've ever seen.

  • mvdtnz 2 days ago

    Where are the raster tiles and sprites in the source code? I'm struggling to find them.

all2 2 days ago

I have the original floppy of this, plus packaging, sitting in the other room.

I remember sinking hours into this on my parents' Windows 3.1 machine (maybe it was an old dos box).

johnorourke 2 days ago

I remember downloading this on a 9.6kbaud modem from a local BBS... and being absolutely blown away by it! My little brother played it to death, so much so that it inspired my first attempt at a game - "kill jazz", where you simply kill Jazz many times over.

gareth_untether 2 days ago

The music gave me a nostalgic hit and I never played the game! The developers were clearly inspired by Sonic which was released three years earlier for the Mega Drive in 1991.

ajsnigrutin 2 days ago

Not sure if projects are related, but this also exists:

https://deat.tk/jazz2/

  • Joel_Mckay 2 days ago

    Nice, they seemed to get the frame rate right unlike the Earthworm Jim players:

    https://arcadespot.com/game/earthworm-jim/

    I think Jazz was the first game that ran smoothly on old hardware. Could be fun to pick up a full retro CD set like the Doom collection. The publisher should still consider the Steam store, as on a Deck the lower resolution wouldn't seem as dated.

    Fun games =3

pezezin 2 days ago

Ha, last week I finally finished assembling my retro PC, and just yesterday I was showing Jazz Jackrabbit to my girlfriend's son. He liked it, and he was surprised to see the "Epic Megagames" logo, he didn't know it was such an old company xD

As for me, playing one of my favourite childhood games on real hardware again, with a good CRT and a Sound Blaster, almost made me cry, the nostalgia hit was enormous :S

  • accrual 2 days ago

    Awesome story! I also enjoy the real hardware nostalgia. I got an Am386-DX40 up and running this afternoon after replacing the Varta battery and adding a CF card. What hardware did you use for your build?

    • pezezin 2 days ago

      Thank you! I wanted a machine that could play both MS-DOS and Windows 9x games with good performance, so I set myself the goal of trying to get the coolest hardware up to 1999.

      - Pentium 2 at 300 MHz

      - 384 MB of RAM

      - Nvidia TNT2 Ultra

      - Sound Blaster AWE64 Gold (the last ISA model, a PITA to get it working because modern ATX power supplies don't provide the -5V required by ISA cards, so I had to find an old enough PSU)

      - 32 GB CompactFlash

      - The cheapest CD drive, floppy drive, PS/2 keyboard and ball mouse, and speakers that I could find at my nearest junk store

      - Sony Multiscan E200 that I got for free from a very generous office colleague!

      - A proper beige box

      - Windows 98 SE

      The total cost was around 300 bucks, with the AWE64 being the most expensive component at 100 bucks. Not cheap, but well worth it for the nostalgia trip.

      I would also like to find a Voodoo and a GUS, but they are ridiculously expensive nowadays.

      • prmoustache 2 days ago

        That sounds very pricey for an old computer that virtually nobody want except a few geek.

        I swear this is the kind of computer that sell for 30€ around here without the gpu (that you can get for 10€). Indeed the awe32 seems to be the most costly part but you can find it way under 100 bucks.

        Might be regional.

        • pezezin 2 days ago

          I just checked it and the total cost has been 35 000 yen, which is around 250 euros.

          Here in Japan PC gaming was not that popular and it is more difficult to find old hardware. Also, it was not until Windows 95 that IBM compatible PCs start to become popular, before that the NEC PC-98 dominated. I also guess I could have bought a full computer for less, but I wanted to assemble it myself to my specifications.

          On the other hand consoles are much cheaper here than in Western countries. The sad thing is that I am not very interested in consoles except for the Megadrive, which was not very successful in Japan so its games are more difficult to find and more expensive than for other consoles like the SNES.

          I guess I am just stupid to focus on two of the most expensive platforms here xD