DOS VGA Tricks

Discussion of development of software for any "obsolete" computer or video game system. See the WSdev wiki and ObscureDev wiki for more information on certain platforms.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: DOS VGA Tricks

Post by lidnariq »

I wouldn't have expected 3d4/C and D to have worked - after all, there'd be less point in 3d4/18h if so. But it does sound like, based on what you're saying, that 3c0/13h is working... if not particularly interesting.
Mills
Posts: 43
Joined: Tue Jul 01, 2014 3:30 am

Re: DOS VGA Tricks

Post by Mills »

lidnariq wrote: Wed Jan 12, 2022 1:24 pm I wouldn't have expected 3d4/C and D to have worked - after all, there'd be less point in 3d4/18h if so. But it does sound like, based on what you're saying, that 3c0/13h is working... if not particularly interesting.
So, I got this in dosbox:
game_013.png
game_013.png (56.21 KiB) Viewed 1858 times
This program displaces some lines at the top part of the image.
Real VGA and PCem show black lines interlaced with displaced ones. 3c0 register works very strange, I think I understand it, but I can't move the lines the amount I want, only 0 or 4 pixels.

I just found more info:
Port-Index: 08h Port: 03d4h, 03b4h
bits 6 5 = Byte panning control

is used to control byte panning. This register together with attribute controller register 13h, allows for up to 31 pixels of panning in double word modes
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: DOS VGA Tricks

Post by lidnariq »

According to VGA.TXT, you should be able to get fine X scrolls from 0 to 3 by writing 0/2/4/6 to 3c0h/13h, not 4...
Mills
Posts: 43
Joined: Tue Jul 01, 2014 3:30 am

Re: DOS VGA Tricks

Post by Mills »

lidnariq wrote: Fri Jan 14, 2022 12:44 pm According to VGA.TXT, you should be able to get fine X scrolls from 0 to 3 by writing 0/2/4/6 to 3c0h/13h, not 4...
I know, I wrote it wrong.

So I understand 3c0 register works like this, I used assembly for the tests, but it will look better in C here:

Code: Select all

//this resets a flip flop in VGA card, and sets 3C0 to write index mode
inp(0x03DA); 

//write index 13 to 3c0 port, also activate bit 5 to keep screen on. Port flips to write data mode
outportb(0x03C0,0x13 + 0x20);

//write panning (6 = 3 pixel displacement), also activate bit 3 (+0x08), I noticed it was there, it looks like it does not matter.
outportb(0x03C0,0x02 + 0x08);
I did a lot of tests, and panning is set to any value the card reads from the register when it reaches a vertical blank. The only thing I can do in the middle of a frame, is disable bit 5 of 3c0 register, to turn off colors resulting in black lines (real hardware and pcem). Dosbox shows the lines with 0 panning, no matter what value I try to write, producing that picture I posted.

I read about other registers modifying panning behaviour, but none of them worked in the middle of a frame.
User avatar
Nikku4211
Posts: 569
Joined: Sun Dec 15, 2019 1:28 pm
Location: Florida
Contact:

Re: DOS VGA Tricks

Post by Nikku4211 »

Mills wrote: Tue Jan 11, 2022 6:43 am Sorry for posting on an old thread, but I just loved it.
I never knew you were on NESDev forums. Probably because you're using a different name from what you use in YouTube.
lidnariq wrote: Tue Jan 11, 2022 11:10 am At best, it might be possible to update the fine X scroll register (3C0h/13h) each scanline, but I don't have the hardware to check against.
Hardware to check against meaning you don't have an MS-DOS computer with VGA, or meaning you don't have a VGA CRT?

Because I happen to have an MS-DOS laptop, and though its screen is a terrible STN LCD with ghosting, it supports SVGA and has a VGA port, though I sadly don't have a CRT that supports VGA, only LCDs that support VGA. I'm still willing to test it, though.
lidnariq wrote: Tue Jan 11, 2022 11:10 am The hsync pulses can be moved around with 4px precision (3d4h index 4), while index 13h is 8px precision... but at least index 13h will work at all on a flat panel, or in a VM.
So most of these cool VGA tricks only work on CRTs and not on LCDs? I'm sure it's always a YMMV thing, but still.
Mills wrote: Wed Jan 12, 2022 6:08 am I have a real VGA to test, I might try later.
As in a real VGA MS-DOS computer, or a real VGA CRT, or a real VGA monitor in general?
I have an ASD, so empathy is not natural for me. If I hurt you, I apologise.
Mills
Posts: 43
Joined: Tue Jul 01, 2014 3:30 am

Re: DOS VGA Tricks

Post by Mills »

Nikku4211 wrote:
lidnariq wrote: Tue Jan 11, 2022 11:10 am The hsync pulses can be moved around with 4px precision (3d4h index 4), while index 13h is 8px precision... but at least index 13h will work at all on a flat panel, or in a VM.
So most of these cool VGA tricks only work on CRTs and not on LCDs? I'm sure it's always a YMMV thing, but still.
3d4h index 4 only works on CRT, 3d4h index 13 works on all monitors, it is an internal VGA VRAM thing, not related to hsync or anything.
Nikku4211 wrote: As in a real VGA MS-DOS computer, or a real VGA CRT, or a real VGA monitor in general?
A real 286 with VGA (not SVGA) card, and I have no CRT, only LCD. Anyway, PCem is so precise, you can test weird things there and they will be the same on real machines most of the time.
User avatar
Nikku4211
Posts: 569
Joined: Sun Dec 15, 2019 1:28 pm
Location: Florida
Contact:

Re: DOS VGA Tricks

Post by Nikku4211 »

Mills wrote: Sat Jan 15, 2022 3:18 am
Nikku4211 wrote:
lidnariq wrote: Tue Jan 11, 2022 11:10 am The hsync pulses can be moved around with 4px precision (3d4h index 4), while index 13h is 8px precision... but at least index 13h will work at all on a flat panel, or in a VM.
So most of these cool VGA tricks only work on CRTs and not on LCDs? I'm sure it's always a YMMV thing, but still.
3d4h index 4 only works on CRT, 3d4h index 13 works on all monitors, it is an internal VGA VRAM thing, not related to hsync or anything.
Alright then, guess I'll try to find a small VGA CRT that I can more easily carry around my apartment for a good price.
Mills wrote: Sat Jan 15, 2022 3:18 am
Nikku4211 wrote: As in a real VGA MS-DOS computer, or a real VGA CRT, or a real VGA monitor in general?
A real 286 with VGA (not SVGA) card, and I have no CRT, only LCD. Anyway, PCem is so precise, you can test weird things there and they will be the same on real machines most of the time.
Oh cool, I'm thinking of trying PCem then.
I have an ASD, so empathy is not natural for me. If I hurt you, I apologise.
pan069
Posts: 2
Joined: Mon Jun 27, 2022 3:19 am

Re: DOS VGA Tricks

Post by pan069 »

Hi guys,

Appologies for reviving an older thread but I tumbled across this and have been reading with great interest.

A question for you guys...

For many years I have been trying to figure out how the sine wave scroller in No Lamers Allowed by Paranoids works. The demo looks unsophisticed at first but when you start digging, trying to figure out how it was done, it actually turns out to be a pretty nifty technical challange. The demo runs very well on my 8Mhz 286 which indicates to me that the sine wave effect is a hardware effect of some sort since there simply isn't enough bandwidth the push that many pixels at that speed. My thinking is that the effect it based around the split screen, triggered within a single scan line (even mutiple times).

What do you guys think?

Not the best capture: https://www.youtube.com/watch?v=iqnATx8oqKw

The real thing in DOSBox: https://archive.org/details/demoscene_N ... -Paranoids

Pouët: https://www.pouet.net/prod.php?which=4124
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: DOS VGA Tricks

Post by rainwarrior »

pan069 wrote: Mon Jun 27, 2022 3:33 amThe demo runs very well on my 8Mhz 286 which indicates to me that the sine wave effect is a hardware effect of some sort since there simply isn't enough bandwidth the push that many pixels at that speed. My thinking is that the effect it based around the split screen, triggered within a single scan line (even mutiple times).
I'm not sure it really needs to do that.

To update the sine wave, it only needs to replace the background at its leading/trailing edge on each frame.

The actual coverage of the sine wave text is a relatively small portion of the screen, and similarly the pixel flag is so sparse it also doesn't have much real coverage.

So between all that, I suspect the bandwidth is actually low enough to get by with updating only what you need to?

Also, probably all source graphics for this demo screen can fit within VGA RAM, so using the hardware latch for "fast" VGA to VGA copy could have been on the table too.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: DOS VGA Tricks

Post by lidnariq »

My extra-verbose-logging DOSBOX doesn't show any VGA register writes during that effect.
pan069
Posts: 2
Joined: Mon Jun 27, 2022 3:19 am

Re: DOS VGA Tricks

Post by pan069 »

rainwarrior wrote: Mon Jun 27, 2022 10:17 am
pan069 wrote: Mon Jun 27, 2022 3:33 amThe demo runs very well on my 8Mhz 286 which indicates to me that the sine wave effect is a hardware effect of some sort since there simply isn't enough bandwidth the push that many pixels at that speed. My thinking is that the effect it based around the split screen, triggered within a single scan line (even mutiple times).
I'm not sure it really needs to do that.

To update the sine wave, it only needs to replace the background at its leading/trailing edge on each frame.
Thanks for the response. Would you be able to elborate on that?

With a "simple" scroller (e.g. one with a static background color) you can just block copy columns 1 to 319 over to columns 0 to 318 and update column 319 with new data, rinse and repeat. But this scroller cleary doesn't do that otherwise the background would move along with the scroller. This to me it seems to indicate that the entire area in which the scoller occurs is updated.

From what I can tell by looking at it, the sine wave moves from left to right and the text moves from right to left. However, this could be a optical illusion, one where my brain simply isn't locking into the correct flow...
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: DOS VGA Tricks

Post by rainwarrior »

pan069 wrote: Wed Jun 29, 2022 2:26 pmThanks for the response. Would you be able to elborate on that?
The "sine" thing is 24 pixels high. On any given frame let's say it might move up or down ~6 pixels since the last frame. That means that each vertical span you have to redraw the 24 pixels of the sine text + 6 pixels of background restore. So, about 9600 pixels.

On top of this there is the waving pixel flag with seems to be 20x20 points. So, that's another 400 pixels + 400 more to restore the background for the previous points.

So, in total we're asking to update about 10,000 pixels out of 64,000. On top of that, running in DOSBox, it seems to animate at 45hz (every second frame).

5000 pixels a frame is something I think a 286 is probably capable of without needing special tricks, just reasonably efficient code.
Post Reply