mfld-fr / emu86

Intel IA16 emulator for embedded development
35 stars 6 forks source link

Emulate text video adaptor RAM in SDL console #50

Closed ghaerr closed 3 years ago

ghaerr commented 3 years ago

Note: this PR is not ready for merge yet. It is a working proof of concept, shown for discussion purposes.

This PR implements emulating EGA adaptor RAM as text characters, allowing programs that write directly to adaptor RAM at segment B800h to display on SDL console.

Works with ELKS direct console for display.

Also implements BIOS console by updating video adaptor RAM on BIOS INT 10h text out/scroll calls.

Emulates Motorola 6845 CRT Controller for cursor display.

Emulates BIOS Data Area (BDA) necessary for ELKS Direct Console to operate.

Implements bounding box for fastest conversion of changed adaptor RAM to SDL pixels each update cycle. This means that adaptor RAM can be changed quickly without display, and during the next update cycle (every 10,000 instructions), the adaptor RAM is inspected, and only the bounding box of changed RAM is converted to text pixels in the SDL buffer and output. With no console output, current implementation only redraws the cursor each cycle. This may be able to be optimized out as well.

Bright/color attributes not implemented yet. Only emulates EGA adaptor, not MDA (yet).

@mfld-fr : this may require some cleanup at your discretion after merge, regarding some variables made global for sharing, as well as where to put target-specific implementations. I will probably leave these to you, unless directed before merge. The main purpose of this preview is for you to take a look at it for comment.

Tested on ELKS Direct and BIOS consoles, not tested on Emscripten/browser yet. Various lines of code are still left commented in, until debugging complete before merge.

The biggest problem, not yet solved, is that the ELKS Direct Console is married to the IRQ 1 keyboard handler, which is a big job to emulate, because of the delivery of keystrokes via scan codes. I plan on making a change in ELKS to allow compilation of Direct Console but using the scheduler timer callback to poll INT 16h for keyboard input just as headless and BIOS console does. Because of this, running EMU86 with Direct Console only properly displays the screen, but doesn't actually work, since keyboard input is not operational.

ghaerr commented 3 years ago

Fixes issue when running vi which sounds PC speaker for "bell" tone, which also uses the 8253/8254 PIT.

Configurable I/O device base addresses in mem-io-elks.h.

Fixes optimized cursor operation.

ghaerr commented 3 years ago

Now works with unmodified ELKS (disk and ROM) kernel, after ELKS PR https://github.com/jbruchon/elks/pull/933 which allows configuring ELKS to use Direct Console but BIOS INT 16h polling keyboard (rather than IRQ 1 scancode keyboard).

Ready for merge.

Tested on ELKS Direct Console and BIOS Console.

The remaining 6845 CRTC and EGA pixel memory boundary rect calculation file code locations can be cleaned up after merge (by me), since there's getting to be a lot of changes in this PR.

After commit, I plan on the following enhancements:

ghaerr commented 3 years ago

@mfld-fr : I'm still getting default.yml workflow builds (on setup) on my repo. How does one retry the pipe?

mfld-fr commented 3 years ago

Build fails because of package downloading error:

Err:3 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 libasound2-dev amd64 1.2.2-2.1ubuntu2.3
  404  Not Found [IP: 52.250.76.244 80]

That's GitHub's business, no problem with the EMU86 code.

mfld-fr commented 3 years ago

Well done ! Let me merge that big improvement.