Showing posts with label scanline. Show all posts
Showing posts with label scanline. Show all posts

Tuesday, October 31, 2023

Emulator time scale.

I want to get an idea of how the emulated CPU should work when displaying a video frame. Let's see.

I know that a frame is drawn every 16625.8 µs. Each frame is composed of 342 lines in the Vertical Active Area and 28 lines in the Vertical Blank Area, for a total of 370 lines.

ChatGPT didn't tell me the length of a scanline, but doing some math, 16625.8 µs (frames) / 370 (lines) = 44.395 µs.

This length should include the Horizontal Active Area and the Horizontal Blank Area.


What's the length of an entire scanline?

The length of an entire scanline for the Macintosh 128K's video display is determined by both the time taken to display the pixels on the screen and the horizontal blanking interval. Here's the breakdown:

1. Pixel Clock Rate: The frequency at which pixels are displayed is 15.6672 MHz. This translates to approximately 0.064 microseconds (µsec) per pixel.

2. Pixels Displayed: For each scan line, 512 pixels are drawn on the screen. This requires 32.68 µsec.

3. Horizontal Blanking Interval: After displaying the pixels for a scan line, there's a short period known as the "horizontal blanking interval" before the next scan line begins. This interval takes the time of an additional 192 pixels, which is 12.25 µsec.

Combining the time taken to display the pixels and the horizontal blanking interval, the total time for each full scan line is 44.93 µsec. This means the horizontal scan rate (the frequency at which each horizontal line is refreshed) is 22.25 kilohertz.

In summary, the length of an entire scanline, in terms of time, is 44.93 µsec.

The document "Inside Macintosh Volume III" has been successfully uploaded. It appears to be a detailed manual from Apple, published in 1985, covering various aspects of the Macintosh systems at the time. The manual seems to be quite comprehensive, with a total of 290 pages, and it likely contains technical information, guidelines, and instructions related to the Macintosh computers of that era.

You can now ask specific questions about the content of this manual, or if you need information on particular topics within the document, feel free to ask!

Cool, it seems that we both are on the same line. Now I have to decide how to coordinate the work of the virtual CPU and the updating of the input/output. In previous emulators, I have found it to be a good compromise to make the virtual CPU work for the length of a scanline, and then update input/output.

In terms of graphics I can get effects on individual scanlines, while in terms of sound, I can get more detailed sample generation.I did all this reasoning to understand how to better organize the construction of the virtual CPU, so that I can make it work for a certain number of cycles, so I can update the rest of the virtual machine. I will return to this again.

I did all this reasoning to understand how to better organize the construction of the virtual CPU, so that I can make it work for a certain number of cycles, so I can update the rest of the virtual machine.

Monday, October 30, 2023

CRT still rules.

In older systems equipped with a video or TV output, it was mandatory to synchronize the times of display of the video image and its composition in the system memory.  The cathode ray, continuously driven by the monitor circuits, lights up dots of fluorescent substance deposited inside the screen.

Let's compare this cathode ray to a laser ray, let's imagine moving it from left to right (horizontal active area), turning it on and off at regular time intervals (pixel clock), based on a sequence of "0" and "1" (memory video).  We will have drawn a scanline.

Now we turn off the laser (blank) and bring the beam all the way to the left and below the line we have just drawn (horizontal blank time), at this point, we repeat these steps until we reach the end of the image (vertical active area).

From the bottom of the image we bring the laser back to the top of the screen (vertical blank time), and a new image is read and shown on the screen.

Imagining absurdly that a CRT monitor had a very low resolution and displayed the Apple logo, we could visualize this result:

Where the cathode ray would have this behavior:

These timings are specific to the electronics that drive the cathode ray and must be respected by the other hardware components, otherwise, the images shown would be distorted.

For this purpose the CPU works in parallel until the cathode ray has reached the bottom of the image, then usually through a specific signal, while the cathode ray returns to the top (vertical blank area), the CPU can transfer or calculate the new image into the video memory.

So, the emulator must run all the hardware respecting vertical and horizontal timings. Now, I need to do some math.