Talk:Mode X

640x400
Removed reference to 640x400 in 256 colours being possible, and reverted to correct 360x480. The contributor may have mistaken the fact that the VGA has enough VRAM to provide a 256 colour 640x400 mode with the fact that the VGA doesn't have enough memory bandwidth to display such a mode.

Nominally, the VGA can display 720 pixels and 480 lines in 16 colours. 256 colour modes require 2 dot clocks as there is twice the bits per pixel as in the 16-colour mode. This reduces the highest supported horizontal width to 360 pixels. While it is true that these specs can be exceeded by taking the video timing outside of specification I doubt any monitor could sync to to the very low refresh rate that would be needed to make a 640x400 mode possible, and besides it would be eye-wateringly, headache inducingly bad.

Funkymonkey Thu 10 Nov, 2005


 * 640x400 should still be possible though; it DOES have enough VRAM. However, the physical resolution of it is 1280x400. Ignoring retrace, you'd get a max vertical refresh rate of 49.4140625 Hz. (And I know this post is ancient, BTW.) --thematrixeatsyou 05:45, 25 November 2007 (UTC)

Source Code
Wikipedia is not sourceforge so it shouldn't contain any source code (maybe a snipet or two in very specific cases where it's warranted). For now I am pasting the code here, but it probably doesn't even belong in the talk page. Is this code even in the public domain? I don't know what the copyright issues are in this specific case. Dori 17:48, Oct 25, 2003 (UTC)

//Video.h unsigned char *v_mem; int v_draw; int v_show;

void v_init {  cli; //<<Upgrade by Epp v_mem = (unsigned char*) 0xa0000; int crtc11;

outport(0x3d4, 0x11); // unlock crtc crtc11 = inport(0x3d5) & 0x7f; outport(0x3d4, 0x11); outport(0x3d5, crtc11);

/*width  = 320; height = 240; maxx   = 319; maxy   = 239; pages  = 3; lineSize = 80; pageSize = 76800; modeName = "320x240";*/

outport(0x3c2, 0xe3);  // mor outport(0x3d4, 0x00); // crtc outport(0x3d5, 0x5f);

outport(0x3d4, 0x01); // crtc outport(0x3d5, 0x4f);

outport(0x3d4, 0x02); // crtc outport(0x3d5, 0x50);

outport(0x3d4, 0x03); // crtc outport(0x3d5, 0x82);

outport(0x3d4, 0x04); // crtc outport(0x3d5, 0x54);

outport(0x3d4, 0x05); // crtc outport(0x3d5, 0x80);

outport(0x3d4, 0x06); // crtc outport(0x3d5, 0x0d);

outport(0x3d4, 0x07); // crtc outport(0x3d5, 0x3e);

outport(0x3d4, 0x08); // crtc outport(0x3d5, 0x00);

outport(0x3d4, 0x09); // crtc outport(0x3d5, 0x41);

outport(0x3d4, 0x10); // crtc outport(0x3d5, 0xea);

outport(0x3d4, 0x11); // crtc outport(0x3d5, 0xac);

outport(0x3d4, 0x12); // crtc outport(0x3d5, 0xdf);

outport(0x3d4, 0x13); // crtc outport(0x3d5, 0x28);

outport(0x3d4, 0x14); // crtc outport(0x3d5, 0x00);

outport(0x3d4, 0x15); // crtc outport(0x3d5, 0xe7);

outport(0x3d4, 0x16); // crtc outport(0x3d5, 0x06);

outport(0x3d4, 0x17); // crtc outport(0x3d5, 0xe3);

outport(0x3c4, 0x01); // seq outport(0x3c5, 0x01);

outport(0x3c4, 0x04); // seq outport(0x3c5, 0x06);

outport(0x3ce, 0x05); // gcr outport(0x3cf, 0x40);

outport(0x3ce, 0x06); // gcr outport(0x3cf, 0x05);

inport(0x3da);         // acr outport(0x3c0, 0x10 | 0x20); outport(0x3c0, 0x41);

inport(0x3da);         // acr outport(0x3c0, 0x13 | 0x20); outport(0x3c0, 0x00);

outport(0x3d4, 0x11); // lock crtc crtc11 = inport(0x3d5) | 0x80; outport(0x3d4, 0x11); outport(0x3d5, crtc11); sti; //<<Upgrade by Epp } //Clears ALL THE PAGES void v_clear(unsigned char color) {  cli; //<<Upgrade by Epp unsigned long color4 = ((color) | (color << 8)); color4 = ((color4) | (color4 << 16)); outport(0x3c4, 2); // map mask reg outport(0x3c5, 0xF); // select all planes to wirte to so we can clear them all at once unsigned long *videomem_long = (unsigned long*) 0xa0000; int count; for(count=0;count<((76800)/4);count++) {    videomem_long[count]=color4; }  sti; //<> 8); outport(0x3d4, 0x0d); outport(0x3d5, offset & 0x00ff); // you can spend a lot of CPU time in this little loop while(!(inport(0x3da) & 0x08));   // wait for vertical retrace {  }   sti; //<> 2)] = pc; sti; //<> 2)]; }

void v_flip {  int temp; temp=v_show; v_show=v_draw; v_draw=temp; v_setshowpage(v_show); }

DOCUMENTATION
I am not sure 'MODE X' was mentioned in the VGA specs. Michael Abrash claimed MODE X 'was omitted entirely from IBM's documentation of the VGA'. He claimed that many people discovered it independently.

I also don't understand why this article is flagged for no citations, Michael Abrash's 'Black Book of Graphics Programming' and the Dr. Dobb's article are citations.

Stephen


 * I just rearranged what was there, I don't think I added or took anything away. I'll see if I can find any direct quotes on the matter (anyone know how to find the VGA specs?). It's probably okay to delete the "sources" tags as long as we list the black book under "references", which we don't currently do. - Rainwarrior 17:18, 24 November 2006 (UTC)


 * Okay, putting the VGA into 320x240 isn't documented, no, but the behaviour and purpose of the VGA registers is documented. So... the unchained mode were documented, more or less, though none of its advantages are. I replaced the line with an alternative. - Rainwarrior 18:06, 24 November 2006 (UTC)


 * If you used the vga specs to find out that infomration, you should provide a reference/link to that documentation. Anton, July 7, 2007


 * There's a pretty good reference at http://www.stanford.edu/class/cs140/projects/pintos/specs/freevga/vga/vga.htm. From that site the relevant registers are documented at the list of sequencing registers. I don't know where to find the original VGA documention or exactly what it would have contained at the time though, so actually giving a citation for this is difficult, but unchained mode was not an accident or byproduct. It was put there specifically to give access to the full range of video memory, and that fact would have been documented from the start. The reason it wasn't used for games for a long while is that the classic 13h mode was designed and documented as a convenient way to do 256 color VGA graphics (and easy access to it was built into a DOS interrupt), so very few people had decided to take a hard look at the other possibilities for the hardware. The weird thing is that Mode X is actually the conventional way of using the graphics memory (in terms of how it was done until that point, e.g. EGA was planar), 13h was the oddball here; it was just easier to use. - Rainwarrior 22:41, 7 July 2007 (UTC)


 * I disagree that Mode-X was so obvious. The planar modes were discussed all as 16 colour modes, where each plane represented an individual colour plane (RGBI).  These modes all have corresponding BIOS modes and are discussed in the IBM documentation.  In Mode-X the four planes represent four pixels left to right which is quite a change in terms of how the programmer sees with, and writes algorithms for, the mode.

You can find the proper (but preliminary) IBM reference docs here and I must say they are better written than any other VGA reference I have read on the whole. There is a text file somewhere with the later (non preliminary) docs but they appear to be identical, and the PDF is better presented. Funkymonkey —Preceding comment was added at 17:35, 26 March 2008 (UTC)

Real life example games
Was this mode only of academic interest or were there real games that also and exclusively used this mode? If so, then the article should give a few examples of games. Ideally ones for which a Wikipedia article already exists. 93.229.164.202 (talk) 14:04, 16 November 2023 (UTC)