VOGONS


First post, by Scali

User metadata
Rank l33t
Rank
l33t

I posted this thread on VCF a few days ago, but figured there may be people with a Hercules or clone and/or who are interested.
http://www.vcfed.org/forum/showthread.php?522 … equency-Kenneth

Basically I'm playing around with Hercules programming somewhat.
I am interested in any PDFs or other resources on the topic by the way.

One thing that struck me so far is that the CRTC values for graphics mode and text mode yield slightly different resolutions.
So, I made a small test program to measure the time per frame with the PIT: https://www.dropbox.com/s/lo7p9ravnq0407n/HERCTIME.zip?dl=0
On my system I indeed got different values for graphics and textmode (see attachment).
So I did the maths:
Measured (ATi Small Wonder, 16.257 MHz crystal):
Graphics: ~23440 ticks
Text: ~23923 ticks

Total pixels:
Graphics: 864*370 = 319680
Text: 882*370 = 326340

319680/326340 = 0.97959183673469387755102040816327
23440/23923 = 0.97981022447017514525770179325335

Apparently there is a 2% difference in number of pixels... and also a 2% difference in frame time (which is expected, since the clock is the same, so each pixel takes the same amount of time).

But one thing I am interested in at this point: Original IBM MDA cards have a 16.257 MHz crystal.
My ATi Small Wonder and Paradise PVC4 clones also have a 16.257 MHz crystal.
However, I have images of original Hercules cards online, and they use a 16.000 MHz crystal. I've also seen various clones with a 16.000 MHz crystal. So I would expect those to have slightly longer frame times than mine, because the pixel clock is slower.

If you have a Hercules or clone, could you check which crystal is on there, and/or run my test program and see what values it gives?

http://scalibq.wordpress.com/just-keeping-it- … ro-programming/

Reply 1 of 9, by konc

User metadata
Rank l33t
Rank
l33t

I can try this later today on a Small Wonder (does it make any sense? You've already measured this one) and a Schneider EuroPC.
I also own the IBM's "Monochrome Display and Printer Adapter", but it doesn't fit in any of my XT cases. The EuroPC is obviously one of them 😀

Reply 2 of 9, by Scali

User metadata
Rank l33t
Rank
l33t

I don't think my program will run on an MDA card. Aside from the Hercules graphics mode not working, I don't think the MDA card has a vsync bit in the status register. So my program will get into an endless loop waiting for the bit to change.

http://scalibq.wordpress.com/just-keeping-it- … ro-programming/

Reply 3 of 9, by Jepael

User metadata
Rank Oldbie
Rank
Oldbie
Scali wrote:
Graphics: ~23440 ticks Text: ~23923 ticks […]
Show full quote

Graphics: ~23440 ticks
Text: ~23923 ticks

Total pixels:
Graphics: 864*370 = 319680
Text: 882*370 = 326340

I don't own a Hercules card, but I find the graphics value quite odd.
The last time I did research about the register values, the horizontal total is 98*9=882 in text mode, and it should be 110*8=55*16=880 in graphics mode.

But when typing this, I realized the HGC graphics mode is set by user not the BIOS, so where did you get the values to set up the graphics mode?

Edit: I also realized the Fractint Hercules driver uses 864, but some other sources use 880.
Oh well, so one needs to write the register settings, and then measure with PIT what's the vsync rate to get the pixel clock. Then use other settings for the other pixel clock. I don't know what the monitor likes about slightly incorrect timing, but it appears you need a certain vsync rate for something. Do I smell a Hercules demo at some easter-time demo party ?-)

Reply 4 of 9, by Jo22

User metadata
Rank l33t++
Rank
l33t++

Be careful with timing on a real MDA monitor.. It's very sensitive.
I heard stories about joke programs which destroyed the fly-back transformer within a few seconds.
Better try it on a VGA card in HGC emulation mode first and use a LCD monitor.

"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//

Reply 5 of 9, by Scali

User metadata
Rank l33t
Rank
l33t
Jepael wrote:

But when typing this, I realized the HGC graphics mode is set by user not the BIOS, so where did you get the values to set up the graphics mode?

I got them from the INIT.ASM file included here: http://www.minuszerodegrees.net/software/hercplus.zip
These should be the original disks included with the HCG Plus card, so they should come straight from the horse's mouth.
Indeed, the first thing I thought when I analysed the CRTC values, is that they could have increased the horizontal total by one to get 880 instead of 864.

Jepael wrote:

Oh well, so one needs to write the register settings, and then measure with PIT what's the vsync rate to get the pixel clock. Then use other settings for the other pixel clock.

Well, the pixel clock is the same, the amount of pixels per frame is different, resulting in slightly different refresh rate.
Another complication is that apparently there are at least two variations of crystal frequencies used on MDA/Hercules-compatible cards. So you have to be careful when using tightly timed routines, that you time it against the actual refresh rate of the card, and not just 'some value that happened to work on my machine'.
CGA doesn't have this problem obviously, since it takes its clock signal from the ISA bus, and therefore is always in sync with the other components running on the same clock (such as DMA, PIT and the CPU, at least on 8088 machines. Later machines may run the CPU asynchronously from the chipset/ISA bus. CGA cards probably don't even work on many later machines, if the ISA bus doesn't deliver a proper NTSC-compatible clockspeed).

http://scalibq.wordpress.com/just-keeping-it- … ro-programming/

Reply 6 of 9, by Scali

User metadata
Rank l33t
Rank
l33t

Over at VCF, user Xacalite ran my timing program on an original Hercules card (type GB102):

Hercules timing - v1.0c
Graphics:
Time 0: 23842
Time 1: 23839
Time 2: 23843
Time 3: 23842
Time 4: 23843
Time 5: 23840
Time 6: 23843
Time 7: 22809
Time 8: 23842
Time 9: 23842
Text:
Time 0: 24338
Time 1: 24338
Time 2: 24337
Time 3: 24338
Time 4: 24338
Time 5: 24340
Time 6: 24337
Time 7: 24337
Time 8: 24339
Time 9: 24342

This is the result of a 16.000 MHz crystal, as opposed to the 16.257 Mhz one on my clone.
The numbers seem to check out, about 1.5% difference in frame time between the two.
So if one wants to be compatible with a wide range of hardware, one should be flexible enough to handle both timings robustly.

http://scalibq.wordpress.com/just-keeping-it- … ro-programming/

Reply 7 of 9, by idspispopd

User metadata
Rank Oldbie
Rank
Oldbie

I don't know if this is relevant, but MDA (or Hercules text mode) uses 350 active scan lines (25 text lines, 14 pixels character height), while Hercules graphics mode uses a resolution of 720x348 pixels. I have even seen a routine in a hardcopy program which uses the difference in frame time (or maybe counts the h-blanks) to differentiate between graphics and text mode. (Hercules registers are write-only so they can't be used for detection, and the BIOS doesn't know about graphics mode, it only knows the card is running mode 7.

Reply 8 of 9, by Scali

User metadata
Rank l33t
Rank
l33t

It is correct that there are more active scanlines in MDA mode than in graphics mode.
However, the difference in frame time is not because of this, because graphics mode is compensated for this in the inactive scanlines, both have a total of 370 scanlines per frame.
The difference in timing is because the scanlines are 864 pixels wide in graphics mode, and 882 pixels wide in textmode.

So you can indeed detect which mode you're in by carefully timing a frame. I did not know that there were programs that actually tried to do this though (I wonder what use that would have, aside perhaps from some kind of debugging/overlay tool, where you want to present some additional information on screen, without changing modes).
It is not a very failsafe method however, because nonstandard graphics modes as seen in various games could throw off the timing.
It also doesn't work if you don't 'calibrate' your timer beforehand, by timing both the text and graphics modes, and recording the values. Because as we've seen, there can be different pixel clocks. If you don't know beforehand which of the two you have, you may mistake textmode for graphics mode, because the pixelclock is higher than you assumed.

http://scalibq.wordpress.com/just-keeping-it- … ro-programming/

Reply 9 of 9, by dr.zeissler

User metadata
Rank l33t
Rank
l33t

Hi scali 😀
Great that you do thing's for hercules. I'll too. My machine is EuroPC(I).
Plattform TASM1.02 (Speedware).

Goals:
1. Getting Hercules-Demo Codes working
2. Converting existing CGA-StarfieldCode to run directly on native Hercules instead of running it with CGA-Emulation on Hercules.
3. ?

I have no experiences in programming, but I am interested in it.
My current problem is, finding out, why the existing Hercules-Code does not work on my machine.

Greetings
Doc

Retro-Gamer 😀 ...on different machines