jhhoward / WolfensteinCGA

Wolfenstein 3D with a CGA renderer
325 stars 10 forks source link

Please support a 640x400 B/W mode #1

Open clausecker opened 1 year ago

clausecker commented 1 year ago

Greetings!

Some old laptops support an extended 640x400 B/W graphics mode (mode 40h). This is needed to address each pixel individually on laptops with 640x400 B/W panels (other graphics modes look blocky or use dithering). Could you add support for this mode?

From the hardware side, this works like mode 6, but interleaved into 4 banks at B800, BA00, BC00, and BE00. So perhaps implementing support for this mode could be done with little extra effort.

The device for which I plan to use this is my trusty Schneider PC 7640 using the Yamaha V6366 graphics controller. I wrote a custom TSR to support mode 40h as available on some other computers.

jhhoward commented 1 year ago

I actually have a Toshiba T1000SE that supports this mode but is currently not switching on. If I can get something like 86box emulating this mode then I could possibly give it a shot.

volkertb commented 1 year ago

Is this the same 640x400 2-color mode that is also supported by the Olivetti M24 (a.k.a. AT&T 6300)? It would indeed be cool if that could be supported as well. Although I wonder what the frame rate ultimately would be, when running this on those machines. They were considerably faster than the original IBM PC, but still... :sweat_smile:

clausecker commented 1 year ago

@volkertb It should be the very same one!

MobyGamer commented 1 year ago

As a fellow AT&T 6300 (Olivetti M24) owner with a working setup, I'm happy to test any mode 40h (640x400) support.

Framerate should be slightly more than double that of an original IBM PC, as the 6300/M24 is an 8 MHz 8086. However, that may also depend on whether or not the proposed 640x400 support actually renders 640 columns (or just 160, as the current version appears to do for all modes).

jhhoward commented 1 year ago

Rendering and blitting double the lines would likely offset the performance gains from the faster CPU to a point.

@MobyGamer do you happen to know if it is possible with the M24 to use a standard resolution CGA mode but then use the extra VRAM for page flipping? Could offer some decent performance gains if possible.

MobyGamer commented 1 year ago

Yes! There's 32K available, and there is a hardware bit to flip them if I'm not mistaken. Let me look at the tech ref to see if I can find it.

MobyGamer commented 1 year ago

Page 5-12 of the Olivetti M21/M24 Theory of Operation manual (one location is at http://ftp.oldskool.org/pub/drivers/ATT/6300/Documentation/Miscellanous%20Information/Olivetti_M21_M24_Theory_of_Operation_Nov84.pdf ) holds the key:

Mode Select Register 2 This is an a bit output only register with address '3DE' hex. Its output is as shown in the table below:

BIT NAME FUNCTION
0 M20 Active high for Non IBM Modes.
1 DEGAUSS Active high for degauss request. (Colour monitor degauss)
2 SETSEL Selects alternate character set when high.
3 PAGESEL Allows use of 2nd set of screen pages in IBM modes
4 -IMODE0 Inverse of MODE0 signal to monitor
5 IMODE1 MODE1 signal to monitor
6 UNDERLINE Allows underline in colour alpha modes when high
7 Z8000CLKE Disable 24MHz clock and enable 19MHz one from Z8000 card

The WD90C00 manual has a slightly friendlier description of these bits:

BIT FUNCTION
0 AT&T MODE ENABLE
1 Active high for degauss request. (Colour monitor degauss)
2 Selects alternate character set when high.
3 Allows use of 2nd set of screen pages in IBM modes
4 RESERVED
5 RESERVED
6 White/Blue Underline
7 RESERVED

Specifically:

Bit 6 Defines underline attribute according to the MDA display requirements. 0 = Underline attribute selects blue foreground in color text modes. 1 = Underline attribute selects white underlined foreground.

Bit 3 Page Select. Selects between one or two 16 Kbyte RAM page for display in 200 line graphics mode. 0 = Display memory address starts at B800:0H (16 KB length). 1 = Display memory address starts at BC00:0H (16 KB length).

Bit 2 Character Set Select. Selects between two character font planes. 0 = Standard character font from plane 2. 1 = Alternate character font from plane 3.

Bit 0 M24 or Non-IBM Graphics Mode. 400 line mode. A 400 line monitor is required for this mode. 0 = 200 line graphics mode active, using paired lines. 1 = AT&T mode enabled for 400 line graphics.

I'm guessing (I've never tried this) the second bank of 16K would be enabled by bits (7 to 0): 0 0 0 0 1 0 0 0

This should probably be tested on real hardware first; I don't know if 86box supports the full functionality of port 3DE. Unfortunately, I can't get to my 6300 hardware for about a week.

clausecker commented 1 year ago

The same page flipping should be possible on the Schneider PC 7640, though the required method would be different and hardware specific.

volkertb commented 1 year ago

Fascinating. I didn't know the M24's integrated graphics allowed for page flipping between the two banks of 16K RAM each, even in the otherwise "CGA-compatible" 320x200 4-color mode.

It gives me an idea. Could this perhaps provide a way to display more than 4 colors at a time? Pick two different 4-color palettes, draw the pixels that should be shown in the colors of the one palette in the first bank, then draw the pixels that should be shown in the other palette in the second (off-screen) bank, and then rapidly switch back and forth, each performing both the bank switch and the palette switch at exactly the same time. if both the palette switch and the bank switch can be performed back and forth near-instantaneously and at a high frequency, at least 30 times per second, it could be doable, right?

(This doesn't just pertain to WolfensteinCGA, but it would be fun to have this be the first game that would try to exploit such a trick, if possible. :slightly_smiling_face:)

MobyGamer commented 1 year ago

Don't want to get this issue off-topic too much, but yes, it would be trivial on M24 hardware to pageflip at 60Hz between two CGA pages, and there's plenty of time to change the background color and palette as well. But the results would flicker quite a bit if the palette and background color changes were too drastic. (The M24 DEB ("display enhancement board") actually has this functionality built in; you can define 16 different "colors" that are mixes of 16-color pallete and the DEB hardware will automatically swap between them. The DEB, however, is incredibly rare; it didn't sell well and had even less support than the M24 640x400 mode.)