Add alt code to 2013/cable3 + other fixes

The alt code _should_ (keyword :-) ) run in Windows. This code is based
on the author's remarks. It is done by (at the compiler line) undefining
KB and defining it in the source code (cable3.alt.c) as the author
suggested.

The cable3.c now #includes unistd.h: this is because the author
suggested in some systems it might be necessary though the example the
author gave no longer exists for current versions (the last 32-bit macOS
to support 32-bit binaries was version 0.14 Mojave and even that was
64-bit and Mojave was released in 2018 with a new version released each
year since then). This does trigger a warning in macOS but we now
silence that warning as well.

The runme script now passes shellcheck (make '[ .. ]' '[[ .. ]]').

Format fixes in README.md including a few links where this seemed like a
good idea (for instance websites).

Updated .gitignore: added cable3.alt.

As as of yesterday there is no need to #undef localtime any more (if
there ever was: the fix I made to let it compile did not in the end need
it but it was the first thing I had done so I kept it in) this has been
removed as well.

The screenshots provided by the author have been linked into the
README.md file so that they should display in the html version.

At least one file was changed in name (in the README.md file) to what I
believe is the correct name (it was a non-existent file).

Updated bugs.md to refer to a file that is not found that the author
referred to.

Add bios.asm that author referred to: found at the GitHub repo for the
entry which the README.md now links to (was another website that no
longer exists).
This commit is contained in:
Cody Boone Ferguson committed 2023-10-09 03:32:09 -07:00
1 parent 88d566e985
commit 856dd9dced
9 files changed
+4112 -61

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
cable3
cable.alt
cable3.orig
prog.orig
+6 -3
View File
@@ -44,7 +44,7 @@ CSILENCE= -Wno-bitwise-op-parentheses -Wno-bool-operation \
-Wno-incompatible-pointer-types -Wno-logical-not-parentheses \
-Wno-logical-op-parentheses -Wno-parentheses -Wno-shift-op-parentheses \
-Wno-sign-compare -Wno-unsequenced -Wno-unused-parameter \
-Wno-deprecated-non-prototype -Wno-return-type
-Wno-deprecated-non-prototype -Wno-return-type -Wno-pointer-type-mismatch
# Common C compiler warning flags
#
@@ -123,8 +123,8 @@ DATA= bios fd.img runme sc-ioccc.terminal screenshot_autocad.png \
screenshot_simcity.png screenshot_win3_on_macosx.png
TARGET= ${PROG}
#
ALT_OBJ=
ALT_TARGET=
ALT_OBJ= ${PROG}.alt.o
ALT_TARGET= ${PROG}.alt
#################
@@ -146,6 +146,9 @@ ${PROG}: ${PROG}.c
alt: data ${ALT_TARGET}
@${TRUE}
${PROG}.alt: ${PROG}.alt.c
${CC} ${CFLAGS} -UKB $< -o $@ ${LDFLAGS}
# data files
#
data: ${DATA}
+199 -52
View File
@@ -10,6 +10,8 @@ Adrian Cable<br>
make
```
An alternate version that should compile in Windows/MS Visual Studio is
available. See the [Alternate code](#alternate-code) section below.
## To run:
@@ -26,6 +28,17 @@ make
NOTE: to quit the program type `QUITEMU`.
### Alternate code:
An alternate version, which should compile in Windows, is provided. To use try:
```sh
make alt
```
Use `cable3.alt` as you would `cable3` above.
## Judges' remarks:
@@ -34,8 +47,14 @@ bits). It manages to implement most of the hardware in a 1980's era
IBM-PC using a few hundred fewer bits than the total number of
transistors used to implement the original 8086 CPU.
If you are using macOS, the included sc-ioccc.terminal configuration file will
correctly display console applications that use ANSI graphics.
If you are using macOS, the included [sc-ioccc.terminal](sc-ioccc.terminal)
configuration file will correctly display console applications that use ANSI
graphics.
NOTE: the author remarked that in some systems one might need to `#include
<unistd.h>`. This has been done in the entry but not the alternate version. This
should not affect the usability of the program but will trigger a warning which
we have disabled in the Makefile.
Update: This entry now has its own website:
<https://github.com/adriancable/8086tiny>
@@ -56,7 +75,8 @@ IBM-compatible PC, consisting of:
- 1MB RAM
- 8072A 3.5" floppy disk controller (1.44MB/720KB)
- Fixed disk controller (supports a single hard drive up to 528MB)
- Hercules graphics card with 720x348 2-color graphics (64KB video RAM), and CGA
- Hercules graphics card with 720x348 2-color graphics (64KB video RAM), and
[CGA](https://en.wikipedia.org/wiki/Color_Graphics_Adapter)
80x25 16-color text mode support
- 8253 programmable interval timer (PIT)
- 8259 programmable interrupt controller (PIC)
@@ -64,24 +84,25 @@ IBM-compatible PC, consisting of:
- MC146818 real-time clock
- PC speaker
The emulator uses the SDL graphics library for portability, and compiles for
Windows, macOS, Linux and probably most other 32-bit/64-bit systems too.
The emulator uses the [SDL graphics library](https://www.libsdl.org) for
portability, and compiles for Windows, macOS, Linux and probably most other
32-bit/64-bit systems too.
If you like living on the edge you can try building the emulator on a big endian
machine, and you will get an emulation of a big endian 8086, a rather bizarre
and somewhat useless beast. For everyone else, please run the emulator on a
little endian machine.
*RULE 2 ABUSE DISCLAIMER*
### RULE 2 ABUSE DISCLAIMER
- `cable3.c` is 4043 bytes in length (half an 8086)
- [cable3.c](cable3.c) is 4043 bytes in length (half an 8086).
- `iocccsize -i < cable3.c` returns 1977 (the year the 4.77 MHz 8086 CPU was announced)
- Therefore, any suspicions the judges may have regarding rule 2 non-compliance may be well-intentioned but are groundless.
- Therefore, any suspicions the judges may have regarding rule 2 non-compliance
might be well-intentioned but are groundless.
- Nonetheless, the author would like to apologise to the judges for the
one-big-block-of-code nature of this entry, which turned out to be unavoidable.
Hopefully the joys of this entry will make up for its shortcomings.
*/RULE 2 ABUSE DISCLAIMER*
### Why is this entry obfuscated/interesting?
@@ -121,15 +142,15 @@ competition (see above).
This entry has been tested on Windows (compiled with MS Visual Studio 2010 and
2013), Mac OS X (clang and gcc), and Linux (clang and gcc). The Makefile
supplied is good for Mac OS X, Linux and probably other UNIXes. I have received
supplied is good for Mac OS X, Linux and probably other Unices. I have received
reports that the emulator works on Raspberry Pi/Android/ARM (you will need to
compile with -fsigned-char) and iOS. You will need to adjust the Makefile if
your system lacks sdl-config to correctly point to the SDL libraries and header
files.
compile with `-fsigned-char`) and iOS. You will need to adjust the
[Makefile](Makefile) if your system lacks `sdl-config` to correctly point to the
SDL libraries and header files.
On UNIX-based systems we can get raw keystrokes using `stty`. However Windows
has no `stty`. Therefore the Makefile includes a `-D` option to define a
`"keyboard driver"` KB which as it stands is suitable for UNIXes, but maybe not
"keyboard driver" `KB` which as it stands is suitable for Unices, but maybe not
non-UNIX platforms. For example, for Windows/MS Visual Studio, instead of the
Makefile definition of KB, use something slightly different - add the following
entry to the Preprocessor Definitions list in the Project Properties page:
@@ -138,6 +159,8 @@ entry to the Preprocessor Definitions list in the Project Properties page:
KB=(kb=H(8),kbhit())&&(r[1190]=getch(),H(7))
```
NOTE: this is done in the [Alternate code](#alternate-code).
### POSIX portability note
The code as supplied uses implicit function declarations for POSIX file I/O and
@@ -151,13 +174,15 @@ include to the top of the source:
#include <unistd.h>
```
NOTE: this has been done in [cable3.c](cable3.c).
### Usage
```sh
./cable3 bios-image-file floppy-image-file [harddisk-image-file]
```
PLEASE NOTE that under UNIXes the keyboard must be in raw mode for the emulator
PLEASE NOTE that under Unices the keyboard must be in raw mode for the emulator
to work properly. Therefore the emulator is best run from a shell script that
looks something like:
@@ -191,7 +216,7 @@ Easiest to start with is to try a ready-made 40MB hard disk image containing a
whole bunch of software: <http://bitly.com/1bU8URK>
For the more adventurous, you can start off with (for example) a blank 40MB
image file called hd.img made using e.g. mkfile. Then use:
image file called hd.img made using e.g. Makefile. Then use:
```sh
stty cbreak raw -echo min 0
@@ -199,80 +224,171 @@ stty cbreak raw -echo min 0
stty cooked echo
```
Preparing the hard disk for use in the emulator is done just like a real PC. Boot the emulator, and use FDISK to partition the hard disk. When it's done FDISK will reboot the emulator. Then you can use FORMAT C: and you are done. The resulting disk image is in the right format to be mounted on a real Windows PC using e.g. OSFMount, on a Mac using hdiutil, or on Linux using mount, providing an easy way to copy files and programs to and from the disk image. Or, you can install programs from regular floppy disk images (see "Floppy disk support" below).
Preparing the hard disk for use in the emulator is done just like a real PC.
Boot the emulator, and use `FDISK` to partition the hard disk. When it's done
`FDISK` will reboot the emulator. Then you can use `FORMAT C:` and you are done. The
resulting disk image is in the right format to be mounted on a real Windows PC
using e.g. `OSFMount` (Windows), `hdiutil` (macOS), or `mount` (linux/unix), providing
an easy way to copy files and programs to and from the disk image. Or, you can
install programs from regular floppy disk images (see [Floppy disk
support](#floppy-disk-support) below).
### Keyboard emulation
The emulator simulates an XT-style keyboard controlled by an Intel 8042 chip on I/O port 0x60, generating IRQ1 and then interrupt 9 on each keypress. This is harder than it sounds because a real 8042 returns scan codes rather than the ASCII characters which the C standard I/O functions return. Rather than make the emulator less portable and use ioctl or platform-dependent equivalents to obtain real scan codes from the keyboard, the emulator BIOS does the reverse of a real PC BIOS and converts ASCII characters to scancodes, simulating press/release of the modifier keys (e.g. shift) as necessary to work like a "real" keyboard. The OS (DOS/Windows) then converts them back to ASCII characters and normally this process works seamlessly (although don't be surprised if there are issues, for example, with non-QWERTY e.g. international keyboards).
The emulator simulates an XT-style keyboard controlled by an Intel 8042 chip on
I/O port 0x60, generating IRQ1 and then interrupt 9 on each key press. This is
harder than it sounds because a real 8042 returns scan codes rather than the
ASCII characters which the C standard I/O functions return. Rather than make the
emulator less portable and use `ioctl(2)` or platform-dependent equivalents to obtain
real scan codes from the keyboard, the emulator BIOS does the reverse of a real
PC BIOS and converts ASCII characters to scan codes, simulating depress/release of
the modifier keys (e.g. shift) as necessary to work like a "real" keyboard. The
OS (DOS/Windows) then converts them back to ASCII characters and although this
process normally works seamlessly don't be surprised if there are issues, for
example, with non-QWERTY e.g. international keyboards.
Most of the time you can just type normally, but there are special sequences to get Alt+xxx and Fxxx.
Most of the time you can just type normally, but there are special sequences to
get `Alt+xxx` and `Fxxx`.
To send an Alt+XXX key combination, press Ctrl+A then the key, so for example to type Alt+F, press Ctrl+A then F.
To send an `Alt+XXX` key combination, press (`^A` or `Ctrl+A`) then the key, so for example to
type `Alt+F`, press (`^A` / `Ctrl+A`) then `F`.
To send an Fxx key, press Ctrl+F then a number key. For example, to get the F4 key, press Ctrl+F then 4. To get F10, press Ctrl+F then 0.
To send an `Fxx` key, press `^F` / `Ctrl+F` then a number key. For example, to
get the `F4` key, press `^F` / `Ctrl+F` then `4`. To get `F10`, press `^F` /
`Ctrl+F` then `0`.
To send a Page Down key, press Ctrl+F then O. To send a Page Up key, press Ctrl+F then E. Other key combinations are left for the discovery of the user.
To send a `Page Down` key, press `^F` / `Ctrl+F` then `O` (letter O, not digit
zero). To send a `Page Up` key, press `^F` / `Ctrl+F` then `E`. Other key
combinations are left for the discovery of the user.
### Text mode support
The emulator supports both text output via the standard BIOS interrupt 0x10 interface, and also direct video memory access (one page, 4KB video RAM at segment B800) in 80x25 CGA 16-color text mode.
The emulator supports both text output via the standard BIOS interrupt 0x10
interface, and also direct video memory access (one page, 4KB video RAM at
segment `B800`) in `80x25 CGA 16-color` text mode.
BIOS text output calls are converted to simple writes to stdout. Direct video memory accesses for the 80x25 CGA color text mode are converted to ANSI terminal escape sequences. If you are using a terminal which does not support ANSI (e.g. you are compiling the emulator with MS VC++ and running in a Windows console window) then PC applications that directly write to video memory in text mode may be unusable.
BIOS text output calls are converted to simple writes to `stdout`. Direct video
memory accesses for the `80x25 CGA color` text mode are converted to ANSI
terminal escape sequences. If you are using a terminal which does not support
ANSI (e.g. you are compiling the emulator with `MS VC++` and running in a
Windows console window) then PC applications that directly write to video memory
in text mode might be unusable.
Most CGA I/O ports are not supported except for the CGA refresh register at 0x3DA, which some applications use for timing or synchronisation.
Most `CGA I/O` ports are not supported except for the `CGA refresh` register at
`0x3DA`, which some applications use for timing or synchronisation.
The regular PC character code page (437) includes various extended ASCII characters for things like line drawing. You might want to set the font in your terminal program to something that includes these (e.g. on Mac OS X there is a freeware font called Perfect DOS VGA 437 which does the trick).
The regular PC character code page (`437`) includes various extended ASCII
characters for things like line drawing. You might want to set the font in your
terminal program to something that includes these (e.g. on Mac OS X there is a
freeware font called [Perfect DOS VGA
437](https://www.dafont.com/perfect-dos-vga-437.font) which does the trick).
Occasionally a DOS application on exit will leave the video hardware in an odd state which confuses the emulator, resulting in subsequent text output being invisible. If this happens, just use the DOS CLS command to clear the screen and all will be well again.
Occasionally a DOS application on exit will leave the video hardware in an odd
state which confuses the emulator, resulting in subsequent text output being
invisible. If this happens, just use the DOS `CLS` command to clear the screen
and all will be well again.
### Graphics mode support
Hercules 720x348 monochrome graphics mode emulation is implemented using SDL. Most Hercules features are supported via the normal I/O interface on ports 0x3B8 and 0x3BA including video memory bank switching (segments B000/B800), which some games use for double-buffered graphics. CGA graphics modes are not supported.
[Hercules 720x348 monochrome graphics
mode](https://en.wikipedia.org/wiki/Hercules_Graphics_Card) emulation is
implemented using SDL. Most Hercules features are supported via the normal I/O
interface on ports `0x3B8` and `0x3BA` including video memory bank switching
(segments `B000`/`B800`), which some games use for double-buffered graphics. CGA
graphics modes are not supported.
When an application enters graphics mode, the emulator will open an SDL window (which will be closed when the application goes back to text mode). Including code to redirect keystrokes from the SDL window to the main terminal window would have busted the IOCCC size limits, so you need to keep the main emulator terminal window in focus at all times even when you are doing graphics (sounds a little odd but you will get used to it).
When an application enters graphics mode, the emulator will open an SDL window
(which will be closed when the application goes back to text mode). Including
code to redirect keystrokes from the SDL window to the main terminal window
would have busted the IOCCC size limits, so you need to keep the main emulator
terminal window in focus at all times even when you are doing graphics (sounds a
little odd but you will get used to it).
On UNIXes, SDL will automatically output graphics via X11 if the DISPLAY environment variable is set up.
On Unices, SDL will automatically output graphics via X11 if the DISPLAY
environment variable is set up.
### Dual graphics card support
Some applications (e.g. AutoCAD) support a PC configuration with a CGA card and a Hercules card, for simultaneous text and graphics output on different displays. The emulator simulates this configuration, too, using separate windows for the (terminal) text and (SDL) graphics displays.
Some applications (e.g. AutoCAD) support a PC configuration with a CGA card and
a Hercules card, for simultaneous text and graphics output on different
displays. The emulator simulates this configuration, too, using separate windows
for the (terminal) text and (SDL) graphics displays.
### BIOS
Like a real PC, the emulator needs a BIOS to do anything useful. Here we use a custom BIOS, written from scratch specifically for the emulator. Source code for the BIOS (written in 8086 assembly language) which compiles with the freely-available NASM x86 assembler is available from the author on request.
Like a real PC, the emulator needs a BIOS to do anything useful. Here we use a
custom BIOS, written from scratch specifically for the emulator. Source code for
the BIOS (written in 8086 assembly language) which compiles with the
freely-available NASM x86 assembler is in [bios.asm](bios.asm).
The BIOS implements the standard interrupt interfaces for video, disk, timer, clock and so on, much as a "real" PC BIOS does, and also a small timer-controlled video driver to convert video memory formatting into ANSI escape sequences when the emulator is in text mode.
The BIOS implements the standard interrupt interfaces for video, disk, timer,
clock and so on, much as a "real" PC BIOS does, and also a small
timer-controlled video driver to convert video memory formatting into ANSI
escape sequences when the emulator is in text mode.
### CPU and memory emulation
Memory map is largely as per a real PC, with interrupt vector table at 0:0, BIOS data area including keyboard buffer at 40:0, CGA text video memory at B800:0, Hercules dual-bank graphics memory at B000/B800:0, and BIOS at F000:100. Unlike a real PC, in the emulator the CPU registers are memory-mapped (at F000:0), which enables considerable optimisation of the emulator's instruction execution unit by permitting the unification of memory and register operations, while remaining invisible to the running software.
Memory map is largely as per a real PC, with interrupt vector table at `0:0`,
BIOS data area including keyboard buffer at `40:0`, CGA text video memory at
`B800:0`, Hercules dual-bank graphics memory at `B000`/`B800:0`, and BIOS at
`F000:100`. Unlike a real PC, in the emulator the CPU registers are
memory-mapped (at `F000:0`), which enables considerable optimisation of the
emulator's instruction execution unit by permitting the unification of memory
and register operations, while remaining invisible to the running software.
CPU supports the full 8086/186 instruction set. Due to the complexities of the 8086's arbitrary-length instruction decoding and flags, 8086 instructions are first converted to a simpler intermediate format before being executed. This conversion, along with instruction lengths and how each instruction modifies the flags, is assisted by some lookup tables which form part of the BIOS binary.
CPU supports the full 8086/186 instruction set. Due to the complexities of the
8086's arbitrary-length instruction decoding and flags, 8086 instructions are
first converted to a simpler intermediate format before being executed. This
conversion, along with instruction lengths and how each instruction modifies the
flags, is assisted by some lookup tables which form part of the BIOS binary.
The CPU also implements some "special" two-byte opcodes to help the emulator talk with the outside world. These are:
0F 00 - output character in register AL to terminal
0F 01 - write real-time clock data (as returned by localtime) to memory location ES:BX
0F 02 - read AX bytes from disk at offset 512*(16*SI+BP) into memory location ES:BX. Disk is specified in DL (0 = hard disk, 1 = floppy disk)
0F 03 - write AX bytes at memory location ES:BX to disk at offset 512*(16*SI+BP). Disk is specified in DL as per 0F 02
Emulator exit is triggered if CS:IP == 0:0 (which would be nonsensical in real software since this is where the interrupt vector table lives). The supplied Dos6.22.img disk includes a small program QUITEMU.COM which contains a single JMP 0:0 instruction, to allow the user to easily quit the emulator without shutting down the terminal.
- `0F 00` - output character in register AL to terminal.
- `0F 01` - write real-time clock data (as returned by `localtime()`) to memory
location `ES:BX`.
- `0F 02` - read AX bytes from disk at offset `512*(16*SI+BP)` into memory
location `ES:BX`. Disk is specified in `DL` (`0` = hard disk, `1` = floppy
disk).
- `0F 03` - write AX bytes at memory location `ES:BX` to disk at offset
`512*(16*SI+BP)`. Disk is specified in `DL` as per `0F 02`.
Emulator exit is triggered if `CS:IP == 0:0` (which would be nonsensical in real
software since this is where the interrupt vector table lives). The supplied
`fd.img` disk includes a small program `QUITEMU.COM` which contains a single
`JMP 0:0` instruction, to allow the user to easily quit the emulator without
shutting down the terminal.
### Floppy disk support
Emulates a 3.5" high-density floppy drive. Can read, write and format 1.44MB disks (18 sectors per track, 2 heads) and 720KB disks (9 sectors per track, 2 heads).
Emulates a 3.5" high-density floppy drive. Can read, write and format 1.44MB
disks (18 sectors per track, 2 heads) and 720KB disks (9 sectors per track, 2
heads).
If you want to install your own software from floppy images (downloaded from e.g. Vetusware), the easiest way to "change disks" is to copy each disk image in turn over the floppy image file you specify on the command line. Don't forget to put your original boot disk back at the end!
If you want to install your own software from floppy images (downloaded from
e.g. [Vetusware](https://vetusware.com)), the easiest way to "change disks" is
to copy each disk image in turn over the floppy image file you specify on the
command line. Don't forget to put your original boot disk back at the end!
### Hard disk support
Supports up to 1023 cylinders, 63 sectors per track, 63 heads for disks up to 528MB.
Supports up to 1023 cylinders, 63 sectors per track, 63 heads for disks up to
528MB.
Disk image format used is a subset of the standard "raw" format used by most disk image mount tools. In general, disk images prepared by the emulator will work with disk image tools and other emulators, but not the other way around.
Disk image format used is a subset of the standard "raw" format used by most
disk image mount tools. In general, disk images prepared by the emulator will
work with disk image tools and other emulators, but not the other way around.
The emulator uses a particularly dumb algorithm to derive a simulated cylinder/sector/head geometry from the disk image file's size. This algorithm often results in not all the space in the image file being available for disk partitions. For example, creating a 40,000,000 byte image file results in DOS FDISK seeing only 31.9MB as the volume size.
The emulator uses a particularly dumb algorithm to derive a simulated
cylinder/sector/head geometry from the disk image file's size. This algorithm
often results in not all the space in the image file being available for disk
partitions. For example, creating a 40,000,000 byte image file results in `DOS
FDISK` seeing only 31.9MB as the volume size.
Note that unlike a real PC, the emulator cannot boot from a hard disk (image). Therefore, you will always need to use a bootable floppy image, even if after boot everything runs from the HD.
Note that unlike a real PC, the emulator cannot boot from a hard disk (image).
Therefore, you will always need to use a bootable floppy image, even if after
boot everything runs from the HD.
### Mouse
@@ -280,13 +396,21 @@ No mouse is emulated.
### Real-time clock
Reading the RTC (both time and date) is emulated via the standard BIOS clock interface, pulling the time/date from the host computer. Setting the time or date is not supported.
Reading the [RTC](https://en.wikipedia.org/wiki/Real-time_clock) (both time and
date) is emulated via the standard BIOS clock interface, pulling the time/date
from the host computer. Setting the time or date is not supported.
### Timers
A countdown timer on I/O port 0x40 is simulated in a broken way which is good enough for most software. On a real PC this has a default period of 55ms and is programmable. No programmability is supported in the emulator and the period may be about right or completely wrong depending on the actual speed of your computer.
A countdown timer on I/O port `0x40` is simulated in a broken way which is good
enough for most software. On a real PC this has a default period of 55ms and is
programmable. No programmability is supported in the emulator and the period may
be about right or completely wrong depending on the actual speed of your
computer.
On a real PC, IRQ0 and interrupt 8 are fired every 55ms. The emulator tries to do the same but again, the delay period is uncalibrated so you get what you get.
On a real PC, IRQ 0 and interrupt 8 are fired every 55ms. The emulator tries to
do the same but again, the delay period is not calibrated so you get what you
get.
### PC speaker
@@ -294,13 +418,36 @@ Beeps only, through the console.
### Software supported
The emulator will run practically any software a real PC (of the spec listed at the top of this file) can. The author has tested a number of OSes/GUIs (MS-DOS 6.22, FreeDOS 0.82pl3, Windows 3.0, DESQview 2.8), professional software (Lotus 1-2-3 2.4 and AsEasyAs 5.7 for DOS, Excel 2.1 for Windows, AutoCAD 2.5, WordStar 4), programming languages (QBASIC, GWBASIC, Turbo C++), games (Carrier Command, Police Quest, and a bunch of freeware Windows games), and diagnostic/benchmark software (Manifest, Microsoft MSD, InfoSpot, CheckIt) and all of them run well.
The emulator will run practically any software a real PC (of the spec listed at
the top of this file) can. The author has tested a number of OSes/GUIs (MS-DOS
6.22, FreeDOS 0.82pl3, Windows 3.0, DESQview 2.8), professional software (Lotus
1-2-3 2.4 and AsEasyAs 5.7 for DOS, Excel 2.1 for Windows, AutoCAD 2.5, WordStar
4), programming languages (QBASIC, GWBASIC, Turbo C++), games (Carrier Command,
Police Quest, and a bunch of freeware Windows games), and diagnostic/benchmark
software (Manifest, Microsoft MSD, InfoSpot, CheckIt) and all of them run well.
Screenshots of some of these applications running (on Mac OS X) are provided for
the impatient.
![AutoCAD](screenshot_autocad.png)
![Flight Simulator 4](screenshot_flightsim4.png)
![Lotus 123](screenshot_lotus123.png)
![QBASIC](screenshot_qbasic.png)
![SimCity](screenshot_simcity.png)
![Windows 3 on macOS](screenshot_win3_on_macosx.png)
Screenshots of some of these applications running (on Mac OS X) are provided for the impatient.
### Compiler warnings
A lot of compiler warnings are produced by clang. Missing type specifiers, control reaching the end of functions without returning values, incompatible pointer type assignments, and some precedence warnings, all necessary to keep the source size down. Other compilers are likely to produce similar warnings.
A lot of compiler warnings are produced by clang. Missing type specifiers,
control reaching the end of functions without returning values, incompatible
pointer type assignments, and some precedence warnings, all necessary to keep
the source size down. Other compilers are likely to produce similar warnings.
## Copyright and CC BY-SA 4.0 License:
+3851
View File
File diff suppressed because it is too large. Load diff
+28
View File
@@ -0,0 +1,28 @@
#include "SDL.h"
#define KB (kb=H(8),kbhit())&&(r[1190]=getch(),H(7))
#define $ for(O=9
#define CX M+=(T%3+2*!(!T*t-6))
#define x ,A=4*!T,O=t,W=h=T<3?u(Q?p:D(A+3),D(A),D(A+1)[i]+D(A+2)*g+):K(t),U=V=K(a),o?U=h,W=V:V,
#define C 8*-~L
#define Z short
#define y a(Z)Y[++O]
#define B ),a--||(
#define _ ),e--||(
#define V(I,D,E)(O=a(I)h[r])&&!(A=(D)(V=(1[E+L]<<16)+*i)/O,A-(I)A)?1[E+L]=V-O*(*E=A):H(0)
#define i(B,M)B(o){return M;}
#define R(O,M,_)(S=L?a(I Z)O:O,N=L?a(I Z)O M(f=a(I Z)_):(O M(f=a(I n)_)))
#define T(_)R(r[u(10,L=4,--)],=,_)
#define u(a,r,T)16*i[a]+(I Z)(T i[r])
#define a(_)*(_*)&
#define L(_)M(W,_,U)
#define M(S,F,T)R(r[S],F,r[T])
#define A(_)(i[L=4]+=2,R(_,=,r[u(10,4,-2+)]))
#define c(R,T)(1[u=19,L+T]=(N=a(R)h[r]*(R)*T)>>16,*i=N,G(F(N-(R)N)))
#define h(_)(1&(L?a(Z)_:_)>>C-1)
#define I unsigned
#define n char
#define e(_)v(F(40[L(_##=40[E]+),E]&N==S|_ N<_(int)S))
I n t,e,l[80186],*E,m,u,L,a,T,o,r[1<<21],X,*Y,b,Q,R;I Z*i,M,p,q=3;I f,S,kb,h,W,U,c,g,d,V,A;N,O,P=983040,j[5];SDL_Surface*k;i(F,40[E]=!!o)i(z,42[E]=!!o)i(D,r[a(I)E[259+4*o]+O])i(w,i[o]+=~(-2*47[E])*~L)i(v,G(N-S&&1&(40[z((f^=S^N)&16),E]^f>>C-1)))J(){V=61442;$;O--;)V+=40[E+O]<<D(25);}i(H,(46[u=76,J(),T(V),T(9[i]),T(M),M(P+18,=,4*o+2),R(M,=,r[4*o]),E]=0))s(o){$;O--;)40[E+O]=1&&1<<D(25)&o;}i(BP,(*i+=262*o*z(F((*E&15)>9|42[E])),*E&=15))i(SP,(w(7),R&&--1[i]&&o?R++,Q&&Q++,M--:0))DX(){$,O*=27840;O--;)O[(I*)k->pixels]=-!!(1<<7-O%8&r[O/2880*90+O%720/8+(88+952[l]/128*4+O/720%4<<13)]);SDL_Flip(k);}main(BX,nE)n**nE;{9[i=E=r+P]=P>>4;$;q;)j[--q]=*++nE?open(*nE,32898):0;read(2[a(I)*i=*j?lseek(*j,0,2)>>9:0,j],E+(M=256),P);$;Y=r+16*9[i]+M,Y-r;Q|R||kb&46[E]&&KB)--64[T=1[O=32[L=(X=*Y&7)&1,o=X/2&1,l]=0,t=(c=y)&7,a=c/8&7,Y]>>6,g=~-T?y:(n)y,d=BX=y,l],!T*t-6&&T-2?T-1?d=g:0:(d=y),Q&&Q--,R&&R--x(O=*Y,O=u=D(51),e=D(8),m=D(14)_ O=*Y/2&7,M+=(n)c*(L^(D(m)[E]|D(22)[E]|D(23)[E]^D(24)[E]))_ L=*Y&8,R(K(X)[r],=,c)_ L=e+=3,o=0,a=X x a=m _ T(X[i])_ A(X[i])_ a<2?M(U,+=1-2*a+,P+24),v(f=1),G(S+1-a==1<<C-1),u=u&4?19:57:a-6?CX+2,a-3||T(9[i]),a&2&&T(M),a&1&&M(P+18,=,U+2),R(M,=,U[r]),u=67:T(h[r])_(W=U B u=m,M-=~L,R(W[r],&,d)B 0 B L(=~)B L(=-),S=0,u=22,F(N>S)B L?c(I Z,i):c(I n,E)B/**/L?c(Z,i):c(n,E)B L?V(I Z,I,i):V(I n,I Z,E)B L?V(Z,int,i):V(n,Z,E))_++e,h=P,d=c,T=3,a=m,M--_++e,13[W=h,i]=(o|=!L)?(n)d:d,U=P+26,M-=~!o,u=17+(m=a)_(a=m B L(+=),F(N<S)B L(|=)B e(+)B e(-)B L(&=)B L(-=),F(N>S)B L(^=)B L(-),F(N>S)B L(=))_!L?L=a+=8 x L(=):!o?Q=1,R(r[p=m x V],=,h):A(h[r])_ T=a=0,t=6,g=c x M(U,=,W)_(A=h(h[r]),V=m?++M,(n)g:o?31&2[E]:1)&&(a<4?V%=a/2+C,R(A,=,h[r]):0,a&1?R(h[r],>>=,V):R(h[r],<<=,V),a>3?u=19:0,a<5?0:F(S>>V-1&1)B R(h[r],+=,A>>C-V),G(h(N)^F(N&1))B A&=(1<<V)-1,R(h[r],+=,A<<C-V),G(h(N*2)^F(h(N)))B R(h[r],+=(40[E]<<V-1)+,A>>1+C-V),G(h(N)^F(A&1<<C-V))B R(h[r],+=(40[E]<<C-V)+,A<<1+C-V),F(A&1<<V-1),G(h(N)^h(N*2))B G(h(N)^F(h(S<<V-1)))B G(h(S))B 0 B V<C||F(A),G(0),R(h[r],+=,A*=~((1<<C)-1>>V)))_(V=!!--1[a=X,i]B V&=!m[E]B V&=m[E]B 0 B V=!++1[i]),M+=V*(n)c _ M+=3-o,L?0:o?9[M=0,i]=BX:T(M),M+=o*L?(n)c:c _ M(U,&,W)_ L=e+=8,W=P,U=K(X)_!R||1[i]?M(m<2?u(8,7,):P,=,m&1?P:u(Q?p:11,6,)),m&1||w(6),m&2||SP(1):0 _!R||1[i]?M(m?P:u(Q?p:11,6,),-,u(8,7,)),43[u=92,E]=!N,F(N>S),m||w(6),SP(!N==b):0 _ o=L,A(M),m&&A(9[i]),m&2?s(A(V)):o||(4[i]+=c)_ R(U[r],=,d)_ 986[l]^=9,R(*E,=,l[m?2[i]:(n)c])_ R(l[m?2[i]:(n)c],=,*E)_ R=2,b=L,Q&&Q++_ W-U?L(^=),M(U,^=,W),L(^=):0 _ T(m[i])_ A(m[i])_ Q=2,p=m,R&&R++_ L=0,O=*E,F(D(m+=3*42[E]+6*40[E])),z(D(1+m)),N=*E=D(m-1)_ N=BP(m-1)_ 1[E]=-h(*E)_ 2[i]=-h(*i)_ 9[T(9[i]),T(M+5),i]=BX,M=c _ J(),T(V)_ s(A(V))_ J(),s((V&~m)+1[E])_ J(),1[E]=V _ L=o=1 x L(=),M(P+m,=,h+2)_++M,H(3)_ M+=2,H(c&m)_++M,m[E]&&H(4)_(c&=m)?1[E]=*E/c,N=*E%=c:H(0)_*i=N=m&E[L=0]+c*1[E]_*E=-m[E]_*E=r[u(Q?p:m,3,*E+)]_ m[E]^=1 _ E[m/2]=m&1 _ R(*E,&,c)_(a=c B write(1,E,1)B time(j+3),memcpy(r+u(8,3,),localtime(j+3),m)),a<2?*E=~lseek(O=4[E][j],a(I)5[i]<<9,0)?((I(*)())(a?write:read))(O,r+u(8,3,),*i):0:0),O=u,D(16)?v(0):D(17)&&G(F(0)),CX*D(20)+D(18)-D(19)*~!!L,D(15)?O=m=N,41[43[44[E]=h(N),E]=!N,E]=D(50):0,!++q?kb=1,*l?SDL_PumpEvents(),k=k?k:SDL_SetVideoMode(720,348,32,0),DX():k?SDL_Quit(),k=0:0:0;}i(G,48[E]=o)i(K,P+(L?2*o:2*o+o/4&7))
+1 -1
View File
@@ -1,5 +1,5 @@
#include "SDL.h"
#undef localtime
#include <unistd.h>
#define $ for(O=9
#define CX M+=(T%3+2*!(!T*t-6))
#define x ,A=4*!T,O=t,W=h=T<3?u(Q?p:D(A+3),D(A),D(A+1)[i]+D(A+2)*g+):K(t),U=V=K(a),o?U=h,W=V:V,
+1 -1
View File
@@ -2,7 +2,7 @@
make clobber all || exit 1
clear
stty cbreak raw -echo min 0
if [ -f hd.img ]
if [[ -f hd.img ]]
then
./cable3 bios fd.img hd.img
else
+10
View File
@@ -1829,6 +1829,16 @@ fire](https://en.wikipedia.org/wiki/Halt_and_Catch_Fire_(computing)) :-)
# 2013
## [2013/cable3](2013/cable3/cable3.c) ([README.md](2013/cable3/README.md))
## STATUS: missing files - please provide them
Many fixes and improvements were made by Cody but he observed that the author
referred to a file that is nowhere to be found: not in the directory or the
archive.
The file is `hd.img`.
Do you have it? Please provide it!
# 2014
+15 -4
View File
@@ -1592,12 +1592,23 @@ This meant that at one point to be strictly technical, the removal of
`localtime()` wasn't necessary but this change was left in place anyway.
Later on in an updated macOS (problem discovered in macOS Sonoma) the entry
failed to compile again also due to `localtime()` so the prototype was
completely removed to solve the problem.
failed to compile again also due to `localtime()` so he removed the prototype
entirely to solve the problem.
He also slightly improved the `runme` script to not assume that the program has
been compiled by running `make clobber all || exit 1`.
Cody also slightly improved the `runme` script to not assume that the program has
been compiled by running `make clobber all || exit 1` and he also made it pass
`shellcheck` (using `[[ .. ]]` over `[ .. ]`).
As well, based on the author's remarks, Cody added the [alternate
code](2013/cable3/cable3.alt.c) which should be compilable for Windows/MS Visual
Studio. This is done by in the compile line undefining `KB` (`-UKB`) and then in
the source code defining `KB` to what the author suggested,
`(kb=H(8),kbhit())&&(r[1190]=getch(),H(7))`. It need hardly be mentioned that
this will not link in Unix systems (including macOS).
Finally Cody provided the [bios.asm](2013/cable3/bios.asm) that the author
referred to, found at the [GitHub repo for the
entry](https://github.com/adriancable/8086tiny/tree/master).
## [2013/hou](2013/hou/hou.c) ([README.md](2013/hou/README.md))