VOGONS


First post, by clb

User metadata
Rank Member
Rank
Member

Hey all,

While scouring some VGA docs from Headland, http://www.bitsavers.org/components/video7/70 … anual_Jun88.pdf (which starts with a cool "With Contributions from Michael Abrash" note),

I found a mention about their VGA card implementing emulation for EGA Light Pen hardware registers, and making a remark that "maybe it's good for random number generation if nothing else".

Well, googling "vga light pen random numbers" did not find any hits to read more about this, so of course had to give it a go.

I have a Headland HT208 VGA card, as shown attached. Indeed, with a little bit of C code, I was able to build a random number generator that sources its randomness from the Headland VGA card Light Pen Address registers. Rock on! 😁

Superficial litmus testing of randomness does say "looks legit", although further statistical testing would naturally be warranted.

Didn't test other cards in my lab yet, except for a WDC Paradise PVGA1A-JK that I had connected in the PC first, which I find does not support this kind of feature.

Will this be a Headland exclusive "we threw this in and the kitchen sink because being IBM hardware compatible is a marketing point", or will other VGA cards also be able to support hardware number generation? No idea.. but I do kinda like this "who's the fairest of them all" take on VGA compatibility. ¯\_(ツ)_/¯

If you'd like to give your VGA card a go, compiled program and source code are available at GitHub:
- Direct Download: https://github.com/juj/crt_terminator/raw/mai … DOS/bin/RNG.zip
- Browse Code: https://github.com/juj/crt_terminator/blob/ma … DOS/RNG/RNG.CPP

I would absolutely love to get my hands on original IBM EGA and VGA graphics adapters, but those seem to be super rare 🙁 If someone has one to test, would be interesting to hear what the results are.

----------------------------------

TLDR Summary of tested cards:

So far, the following cards have been verified to provide this kind of Hardware RNG:
- Headland HT208 ISA (my card in this post)
- Chips&Technologies F65545 PCI Vendor/Device 102Ch/00D8h integrated on a motherboard (DerBaum's card in Re: Can your VGA card provide a hardware source for random numbers?)
- Chips&Technologies F65548 PCI Vendor/Device 102Ch/00DCh integrated on a motherboard (DerBaum's card in the same comment above)
- 3Dfx Voodoo 3 2000 (PCI) (ViTi95 in Re: Can your VGA card provide a hardware source for random numbers?)
- 3Dfx Voodoo 3 (AGP) (b_w in Re: SNOOP.EXE: (S)VGA adapter info tool and CRT Terminator config utility )
- Ahead V5000B (my card in Re: Can your VGA card provide a hardware source for random numbers? )

Graphics cards from the following manufacturers have been tested to NOT implement this quirky feature:
- 3Dfx Voodoo Rush (ViTi95 in Re: Can your VGA card provide a hardware source for random numbers? )
- Acumos, Cirrus Logic (my Acumos AVGA1 card in Re: Can your VGA card provide a hardware source for random numbers? , Cirrus Logic 5420 DerBaum in Re: Can your VGA card provide a hardware source for random numbers? and ViTi95 further in the thread)
- Alliance Semiconductor (ProMotion AT25, ViTi95)
- ARK Logic (1000PV, ViTi95)
- Ati (DerBaum)
- BrookTree (DerBaum)
- HMC (HM86314Q, ViTi95: Re: Can your VGA card provide a hardware source for random numbers? )
- IBM EGA adapter (User modem7 over at VCFED: Re: Can your VGA card provide a hardware source for random numbers? )
- Macronix (MX86251FC, ViTi95)
- Matrox (DerBaum)
- NVidia (TNT2 M64, badmojo in Re: Can your VGA card provide a hardware source for random numbers? )
- Oak (Oak OTI067, DerBaum in Re: Can your VGA card provide a hardware source for random numbers?)
- Paradise, WDC (WDC Paradise PVGA1A-JK, my card tested in this post)
- RealTek (RTG3106, DerBaum, RTG3105iEH by ViTi95 in Re: Can your VGA card provide a hardware source for random numbers? )
- S3 (Vision, Trio64, Virge, DerBaum)
- Trident (my card 8900C, Pierre32 in Re: Can your VGA card provide a hardware source for random numbers? )
- Tseng (ET4000AX, DerBaum)

It is a safe assumption to make that if a given card did not have this quirk, then any later cards from the same manufacturer are quite unlikely to have it either, since the lack of this "feature" would never ever have made it to the "oops, we better fix that in the next hardware iteration" list.

Cards still unknown:
- Original IBM VGA adapter
- IBM 8514, PGA and XGA adapters
- other manufacturers not listed above?

Attachments

Last edited by clb on 2023-09-12, 10:09. Edited 8 times in total.

Reply 3 of 57, by clb

User metadata
Rank Member
Rank
Member
maxtherabbit wrote on 2023-08-18, 23:38:

pretty cool

Heh, yeah, not sure why I got to geeking out over this, I guess it's a good little weekend project if nothing else.

Updated the code to measure generated RNG kbits/second performance, a coin flip run length test (frequency of runs of consecutive heads or tails), and added a visualization of the Monte Carlo pi search. The visualization should converge to display the top-right quadrant of a quarter-circle.

That visual image makes me think that maybe things are not quite perfectly random, those small horizontal clumps that occassionally appear feel a bit suspect. Oh well, better not look too deep into it 😜

Tried out an Acumos AVGA1 card and a Trident 8900C, and at least neither of those supported this. So it could be that this was just Headland engineers being super nerdy. Still would be cool to know if the original IBM VGA card had this, and if this works on EGA cards as well. (although now that I went and added Mode-X visualization into the program, running the EXE on EGA might not be all that happy)

Pierre32 wrote on 2023-08-19, 04:17:

More fun stuff to run when I set up my SNOOP testbench. Although, do you think there's any point trying this with PCI cards?

I am starting to get a feeling that this support would be pretty rare. But maybe there's another unicorn chip out there 😀

Attachments

  • monte_carlo_vis.png
    Filename
    monte_carlo_vis.png
    File size
    1.36 MiB
    Views
    2449 views
    File license
    Public domain
  • rng_updated.png
    Filename
    rng_updated.png
    File size
    218.2 KiB
    Views
    2449 views
    File license
    Public domain
Last edited by clb on 2023-08-19, 09:48. Edited 1 time in total.

Reply 4 of 57, by Pierre32

User metadata
Rank Oldbie
Rank
Oldbie
clb wrote on 2023-08-19, 09:20:

I am starting to get a feeling that this support would be pretty rare. But maybe there's another unicorn chip out there 😀

Well I will add my data to the research! I do have a few ISA cards to try while I'm at it too.

Reply 5 of 57, by clb

User metadata
Rank Member
Rank
Member

Oops, looks like the horizontal streaks came from a bug in the visualization code. I forgot to update the VGA Read Map Select when doing a readback from video memory. Updated that, fixed visualization does not have those streaks any more.

Attachments

  • pi_vis_fixed.png
    Filename
    pi_vis_fixed.png
    File size
    1.52 MiB
    Views
    2390 views
    File license
    Public domain

Reply 6 of 57, by clb

User metadata
Rank Member
Rank
Member

Googled up two different NIST Randomness test battery based testing frameworks,
- https://github.com/stevenang/randomness_testsuite and
- https://mzsoltmolnar.github.io/random-bitstream-tester/

and generated 8*1024*1024 random bits from three different generators:
- Borland Turbo C++ 3.0 rand() function,
- Headland's Light Pen hardware generator, and
- my own hardware random number generator that I dabbled together into CRT Terminator.

First as reference, Turbo C++'s standard random number generator. rand() test fails on the Runs Test on one of the suite, but passes on the other. To my understanding the two test suites should implement identical tests, since they are based on the same NIST test battery. So one of the test suites is buggy. For some reason, the online test suite gives an internal error on the last two tests as well. From what I gather out of all this, the rand() implementation in Borland Turbo C++ 3.0 is pretty good.

Attachments

Reply 7 of 57, by clb

User metadata
Rank Member
Rank
Member

Then the Headland HT208 Light Pen Address based hardware RNG.

Too bad, it does not quite get through the test suites. It fails on 8/16 of the tests in randomness_testsuite, so passes 50% of them, random.. (that does make it more random than rand(), right? 😁 )

Attachments

Reply 8 of 57, by clb

User metadata
Rank Member
Rank
Member

Then finally, my own hardware RNG implementation.

It passes all the tests in randomness_testsuite, as well as all the tests in random-bitstream-tester, except that the two last tests give a "Error", rather than "Failed". This gives an impression that those tests would internally fail, and not result in the random number generator not producing random values.

Attachments

Reply 9 of 57, by DerBaum

User metadata
Rank Oldbie
Rank
Oldbie

I have some noob questions:

Is it ok if i test my cards an post the results here?
Is there a range where it is most likely implemented? Only ISA ? Maybe VLB? Any specific chipset manufacturer?
Is there a real usecase for this (not only at the moment but later on)?

FCKGW-RHQQ2

Reply 10 of 57, by clb

User metadata
Rank Member
Rank
Member
DerBaum wrote on 2023-08-19, 17:14:

Is it ok if i test my cards an post the results here?

Please do. What I like about the forum is that it is well searchable by both Vogons search and Google search, so accumulating a collective knowledge base here is useful to extend the information spread well.

DerBaum wrote on 2023-08-19, 17:14:

Is there a range where it is most likely implemented? Only ISA ? Maybe VLB? Any specific chipset manufacturer?

Gut feeling says that if any, the older ISA cards might be more likely to have it, since they would be closer to the era when EGA cards were still also in their prime. It could well be that only the IBM VGA card and Headland only ever had this.

DerBaum wrote on 2023-08-19, 17:14:

Is there a real usecase for this (not only at the moment but later on)?

Typically, such a hardware RNG can be used as a mechanism to seed a PRNG for game development, for game types where the game seed would benefit from being a high number of bits. For example, shuffling a card deck for poker or solitaire games - Freecell, Minesweeper, etc. A famous bug with competitive Minesweeper was that they used a narrow number of bits in the seeding of the rng, which limited the number of possible games, and generated memorizable cycles. https://minesweepergame.com/website/usman-lat … mineident1.html is a collection of blog posts that illustrate the limitation.

Reply 11 of 57, by clb

User metadata
Rank Member
Rank
Member

I am proud to present, very likely the first ever developed game that utilizes this hardware RNG feature: the EGA/VGA Hardware RNG Space Adventure! 😁

It provides about few trillion trillion unique game boards to play, you will never encounter the same game board twice.

Download it at https://github.com/juj/crt_terminator/raw/mai … DOS/bin/RNG.zip

It requires a graphics card that supports this Light Pen RNG. Absolutely wouldn't be able to be made to run without that kind of RNG source. Nope. Not. No way.

Assuming Headland's comment in their technical manual is correct, the game should only run on authentic IBM EGA & VGA graphics cards, or fully 100% IBM Compatible VGA adapters like Headland. It won't work on any of them Cheap Clones(TM) that did not bother to implement such a mission critical part of the IBM spec like Light Pen support. (or hmm, if I interpret Headland's technical manual a little differently, there is also a chance that it will only run on IBM VGA cards, but not on EGA cards because those actually do implement Light Pen support.. not sure which. Well, either it works or doesn't work on EGA)

Sorry in advance if anyone manages to actually get it to work. It is 2AM and it was made in a day. 😀

Attachments

Last edited by clb on 2023-09-05, 14:31. Edited 1 time in total.

Reply 14 of 57, by DerBaum

User metadata
Rank Oldbie
Rank
Oldbie

Is it supposed to not work on hardware that doesnt support it?
Or will it work without the RNG part?

Because it works on my SBC with integrated CHIPS graphics...

2023-08-21 00.36.42.jpg
Filename
2023-08-21 00.36.42.jpg
File size
342.48 KiB
Views
2140 views
File license
CC-BY-4.0

FCKGW-RHQQ2

Reply 15 of 57, by clb

User metadata
Rank Member
Rank
Member

Ooh cool, you got it to work! Absolutely Awesome 😀

The game will not start up at all if the RNG is not supported, but it will print a message about no hardware RNG being available. So since it started up, it means it did find the RNG. Awesome, that is the second card that I find this feature being available on.

Something that would be cool if you can run the RNG.zip on that card and compare the text logs and the Monte Carlo picture against the ones I posted. I.e. do the results look as similarly random for you?

Also, it would be cool if you could run the SNOOP.EXE program on that card and post the results. Is it a CHIPS EGA or a VGA integrated graphics card? Do you have a picture of the graphics IC chip from the motherboard?

Reply 17 of 57, by DerBaum

User metadata
Rank Oldbie
Rank
Oldbie

Ok... Now i am confused...

Both CHIPS F65545 and F65548 seem to support this...

2023-08-20 22.35.34.jpg
Filename
2023-08-20 22.35.34.jpg
File size
1.83 MiB
Views
2112 views
File license
CC-BY-4.0
2023-08-21 01.00.01.jpg
Filename
2023-08-21 01.00.01.jpg
File size
1.56 MiB
Views
2112 views
File license
CC-BY-4.0
2023-08-21 01.02.18.jpg
Filename
2023-08-21 01.02.18.jpg
File size
1.83 MiB
Views
2112 views
File license
CC-BY-4.0
2023-08-21 01.02.32.jpg
Filename
2023-08-21 01.02.32.jpg
File size
1.5 MiB
Views
2112 views
File license
CC-BY-4.0
2023-08-21 00.59.51.jpg
Filename
2023-08-21 00.59.51.jpg
File size
1.52 MiB
Views
2112 views
File license
CC-BY-4.0

FCKGW-RHQQ2

Reply 18 of 57, by clb

User metadata
Rank Member
Rank
Member

Thanks! Oww, the results are not so random. Awesome patterns though. That picture is looking directly into the heart of the running memory address counter inside the card. Visually glancing, looks good enough for the game though. That does make me wonder if the generation code could be modified to improve the randomization.

Reply 19 of 57, by DerBaum

User metadata
Rank Oldbie
Rank
Oldbie
clb wrote on 2023-08-20, 23:12:

Thanks! Oww, the results are not so random. Awesome patterns though. That picture is looking directly into the heart of the running memory address counter inside the card. Visually glancing, looks good enough for the game though.

Yes. I actually love the "visuals". Awesome work.

On one card they are always "straight" and on the other not (but always similar shaped like in my pictures)... Really interesting.

FCKGW-RHQQ2