Author Topic: Is mode x much faster then mode 13h?  (Read 14545 times)

Offline Tobiasz Stamborski

  • Jr. Member
  • *
  • Posts: 7
Is mode x much faster then mode 13h?
« on: July 13, 2023, 05:40:32 PM »
Hello,

Some time ago I wanted to make in nasm a game for ms-dos. I decided to try a widely known graphical mode 13h. And I have experienced that it's reeeally slow, especially if you want to have double buffering. I was doing a double buffering by simply writing in loop (during vertical blank) from other buffer to video memory at 0xA0000. And I feel it's definitely to slow for making even a simple platformer, maybe good for a snake game or something like that.

Question No. 1: Do I not understand something or it's really so slow?

Question No. 2: I have read somewhat about "Mode X" which allows a 320x240 resolution and a real double buffering. Is it enough fast to make a platformer game?

Question No. 3: Which graphical mode was used by most of old ms-dos games?

Offline fredericopissarra

  • Full Member
  • **
  • Posts: 373
  • Country: br
Re: Is mode x much faster then mode 13h?
« Reply #1 on: July 13, 2023, 07:15:54 PM »
Mode 0x13 is not that slow and Mode X is not that fast.

The differences are:
- For 4:3 aspect ratio, mode X pixels are perfect squares (320/240 = 4/3) - 320x200 isn't.
- In Mode X you have to work with planes, each plane has 1 pixel (in sequence): Plano 0: pixels 0, 4, 8, 12..., Plane 1: 1, 5, 9, 13; Plane 2: 2, 6, 10, 14 and plane 3: 3, 7, 11, 15...

So, (320/4)*240 = 19200 bytes, which gives us 3 "pages" per plane in VRAM and 7936 extra bytes.

On old machines Video Memory (physical addresses from 0xA0000 to 0xBFFFF) were VERY slow. On those old machines it pays off if you keep an offscreen buffer in System memory. Since some SuperVGA cards, 0 wait state video memory was available.

Old MS-DOS games avoid spending too much time updating VRAM with techniques like "dirty rectangles", for example.

I really recommend, if you want to play with those old hardwares, you search for "Zen of Graphics Programming Black Book", by Michael Abrash.

Offline Tobiasz Stamborski

  • Jr. Member
  • *
  • Posts: 7
Re: Is mode x much faster then mode 13h?
« Reply #2 on: July 13, 2023, 08:41:42 PM »
Thanks, this book will be very helpful. :) Worse that seemingly a lot of learning before me. :-\

I have one question more - if i would target a machine with SVGA card, would that make things easier for me?

Offline fredericopissarra

  • Full Member
  • **
  • Posts: 373
  • Country: br
Re: Is mode x much faster then mode 13h?
« Reply #3 on: July 13, 2023, 08:51:25 PM »
Thanks, this book will be very helpful. :) Worse that seemingly a lot of learning before me. :-\

I have one question more - if i would target a machine with SVGA card, would that make things easier for me?
Nope... SVGA is not a de facto standard. VGA and XGA are. That's why modern PCHs (Platform Controller Hubs) still supports VGA and XGA. Notice Mode X is a VGA (modified) mode, which takes some characteristics available in all VGA hardware to make it work.

Read Abrash book and find IBM's VGA standard (Google it)...

And I do recommend to learn Digital Electronics...

PS: VESA modes are de facto standard, but they are restricted to 4:3 aspect ratio monitors (old CRTs). You cannot get a 16:9 aspect ratio mode using VBE (VESA BIOS Extensions) like 1280x720 or 1920x1080...
« Last Edit: July 13, 2023, 08:53:57 PM by fredericopissarra »

Offline Tobiasz Stamborski

  • Jr. Member
  • *
  • Posts: 7
Re: Is mode x much faster then mode 13h?
« Reply #4 on: July 13, 2023, 09:17:32 PM »
Thanks again for your explanations. I have found Abrash book just didn't read it yet (I've only taken a look at table of contents).

BTW: Yes I mistakenly thought SVGA is a standard the same way as VESA is.

Offline fredericopissarra

  • Full Member
  • **
  • Posts: 373
  • Country: br
Re: Is mode x much faster then mode 13h?
« Reply #5 on: July 13, 2023, 09:22:42 PM »
Thanks again for your explanations. I have found Abrash book just didn't read it yet (I've only taken a look at table of contents).

BTW: Yes I mistakenly thought SVGA is a standard the same way as VESA is.
For your study (and I don't know if it is against the forum's rules), here's a book I took many years to get my hands on. I had the old "Programmer's Guide to EGA and VGA", but this covers SuperVGA as well...
Programmer's Guide to EGA, VGA and SuperVGA Cards - Richard E. Ferraro

Offline Tobiasz Stamborski

  • Jr. Member
  • *
  • Posts: 7
Re: Is mode x much faster then mode 13h?
« Reply #6 on: July 13, 2023, 09:35:53 PM »
Thank you, but it will take the time to read an Abrash book at least. :)

Regards.

Offline debs3759

  • Global Moderator
  • Full Member
  • *****
  • Posts: 224
  • Country: gb
    • GPUZoo
Re: Is mode x much faster then mode 13h?
« Reply #7 on: July 14, 2023, 12:18:51 AM »
Thanks again for your explanations. I have found Abrash book just didn't read it yet (I've only taken a look at table of contents).

BTW: Yes I mistakenly thought SVGA is a standard the same way as VESA is.
For your study (and I don't know if it is against the forum's rules), here's a book I took many years to get my hands on. I had the old "Programmer's Guide to EGA and VGA", but this covers SuperVGA as well...
Programmer's Guide to EGA, VGA and SuperVGA Cards - Richard E. Ferraro

I have that book as well (and the Michael Abrash book), but haven't been able to contact the writer to find out whether the associated CD with extra source code is still available. I don't suppose you have a copy of it?
My graphics card database: www.gpuzoo.com