Fix Moria state file

This commit is contained in:
Jeff Parsons 2015-12-21 14:46:00 -08:00
commit 57d58e1b79
11 changed files with 490 additions and 13 deletions

File diff suppressed because one or more lines are too long

View file

@ -15,7 +15,7 @@ Below are selected demos of classic IBM PC applications running on [PCjs](/docs/
* [Executive Suite (1982)](1982/esuite/)
* [Rogue (1985)](1985/rogue/)
* [ThinkTank (1987)](1987/thinktank/)
* The Dungeons of Moria (1988, [1992](1992/moria/))
* [The Dungeons of Moria (1992)](1992/moria/)
Additional software is available in the [IBM PC Disk Archive](/disks/pc/).

7
docs/6502/README.md Normal file
View file

@ -0,0 +1,7 @@
---
layout: page
title: 6502 Documentation
permalink: /docs/6502/
---
Placeholder for future 6502 documentation.

View file

@ -9,4 +9,13 @@ permalink: /docs/
Documentation
---
Documentation for [PCjs](/docs/pcjs/) and [C1Pjs](/docs/c1pjs/) is now available.
Documentation is available for the following JavaScript Machines:
+ [PCjs](/docs/pcjs/)
+ [C1Pjs](/docs/c1pjs/)
Assorted documentation is also available for programming the machines:
+ [6502 Instructions](/docs/6502/)
+ [x86 Instructions](/docs/x86/)
+ [OS/2 Programming Guides](/docs/os2/)

14
docs/os2/README.md Normal file
View file

@ -0,0 +1,14 @@
---
layout: page
title: "OS/2 Programming Guides"
permalink: /docs/os2/
---
OS/2 Programming Guides
---
For OS/2 1.0:
* [Microsoft® Operating System/2 Programmers Toolkit](/docs/os2/microsoft/1.0/)
Note that the above guide is a work-in-progress (converting the PDF text to Markdown).

View file

@ -0,0 +1,120 @@
---
layout: page
title: "Microsoft OS/2 Programmer's Learning Guide"
permalink: /docs/os2/microsoft/1.0/plguide/
---
Programmer's Toolkit
---
Programmer's Learning Guide
---
Version 1.0
---
### Contents
* 1.0 [Introduction](/docs/os2/microsoft/1.0/plguide/chapter1/)
* 1.1 [Overview](/docs/os2/microsoft/1.0/plguide/chapter1/#overview)
* 1.2 [What You Need to Start](/docs/os2/microsoft/1.0/plguide/chapter1/#what-you-need-to-start)
* 1.3 [What This Guide Covers](/docs/os2/microsoft/1.0/plguide/chapter1/#what-this-guide-covers)
* 1.4 [The Lqh Sample Program](/docs/os2/microsoft/1.0/plguide/chapter1/#the-lqh-sample-program)
* 1.5 [MS OS/2 Sample Programs](/docs/os2/microsoft/1.0/plguide/chapter1/#ms-os2-sample-programs)
* 1.6 [MS OS/2 and the C Run-time Library](/docs/os2/microsoft/1.0/plguide/chapter1/#ms-os2-and-the-c-run-time-library)
* 2.0 Overview
* 2.1 Introduction
* 2.2 Creating an MS OS/2 Program
* 2.3 C-Language Header Files
* 2.4 A Simple Program: Echoing the Command Line
* 2.5 Using the MS OS/2 Naming Conventions
* 2.6 Using Structures: Getting the Time of Day
* 2.7 Using Bit Masks
* 2.8 Sharing Resources: Playing a Tune
* 3.0 Input and Output
* 3.1 Introduction
* 3.2 Opening Files
* 3.3 Reading and Writing to Files
* 3.4 Creating a File
* 3.5 Closing a File
* 3.6 Standard Input and Output Files
* 3.7 Redirecting Standard Files
* 3.8 Wildcards in Filenames
* 3.9 Asynchronous Reading and Writing
* 3.10 Moving the File Pointer
* 3.11 Redirecting Standard Files
* 3.12 Devices
* 3.13 Input and Output Control
* 4.0 Keyboard, Mouse, and Screen
* 4.1 Introduction
* 4.2 Reading Keystrokes
* 4.3 Displaying a Character
* 4.4 Writing a Character to a Specific Location
* 4.5 Reading Extended ASCII Keys
* 4.6 Using the Mouse
* 4.7 Selecting the Events to be Queued
* 4.8 Reading a String of Characters from the Keyboard
* 4.9 Writing a String of Characters to the Screen
* 4.10 Writing Character Cells to the Screen
* 4.11 Moving and Hiding the Cursor
* 4.12 Reading Characters from the Screen
* 4.13 Scrolling the Screen
* 4.14 Using the ANSI Display Mode
* 4.15 Opening and Using Logical Keyboards
* 4.16 Flushing the Keyboard Buffer
* 4.17 Setting the Keyboard Input Mode
* 5.0 Memory Management
* 5.1 Introduction
* 5.2 Allocating and Using Segments
* 5.3 General-Protection Faults and Segment Violations
* 5.4 Reallocating a Segment
* 5.5 Moving and Swapping
* 6.0 Processes and Threads
* 6.1 Introduction
* 6.2 Running an Asynchronous Child Process
* 6.3 Waiting for a Child Process to End
* 6.4 Retrieving the Termination Status of a Child Process
* 6.5 Ending a Process
* 6.6 Terminating a Process
* 6.7 Cleaning Up Before Ending a Process
* 6.8 Creating a Thread
* 6.9 Controlling the Execution of a Thread
* 6.10 Changing the Priority of a Process
* 7.0 Lqh: A Sample Program
* 7.1 Introduction
* 7.2 Lqh Files
* 7.3 About the Microsoft Help Library
* 7.4 The Lqh Program
* 7.5 The Lqhbox Dynamic-Link Library
---
This is a Markdown conversion of the document entitled:
>Microsoft® Operating System/2
>Programmer's Toolkit
>Programmer's Learning Guide
>Version 1.0
That document includes the following copyright and trademark information:
>Information in this document is subject to change without notice and does not represent a commitment on the part
of Microsoft Corporation. The software and/or databases described in this document are furnished under a license
agreement or nondisclosure agreement. The software and/or databases may be used or copied only in accordance with
the terms of the agreement. The purchaser may make one copy of the software for backup purposes. No part of this
manual and/or database may be reproduced or transmitted in any form or by any means, electronic or mechanical,
including photocopying, recording, or information storage and retrieval systems, for any purpose other than the
purchaser's personal use, without the written permission of Microsoft Corporation.
>© Copyright Microsoft Corporation, 1988. All rights reserved. Simultaneously published in the U.S. and Canada.
>Microsoft®, MS®, and the Microsoft logo are registered trademarks of Microsoft Corporation.
>Intel® is a registered trademark of Intel Corporation.
>Hayes® is a registered trademark of Hayes Microcomputer Products, Inc.
>Document No. 060060004-100-R00-0388

View file

@ -0,0 +1,137 @@
---
layout: page
title: "Microsoft OS/2 Programmer's Learning Guide: Introduction"
permalink: /docs/os2/microsoft/1.0/plguide/chapter1/
---
Microsoft OS/2 Programmer's Learning Guide
---
Introduction
---
### 1.1 Overview
The *Microsoft® Operating System/2 Programmer's Learning Guide* is intended to help the experienced C programmer
make the transition to writing programs that use the Microsoft Operating System 2 application programming interface.
The guide provides explanations of how to use the MS® OS/2 functions, types, and data structures to carry out useful
tasks, and illustrates these explanations with program samples that you can compile and run with MS OS/2.
### 1.2 What You Need to Start
To start using this guide, you need the following:
+ Experience using MS OS/2
+ Experience writing C-language programs
The C programming language is the preferred development language for MS OS/2 programs. Many of the programming
features of MS OS/2 were designed with C and other high-level languages in mind. MS OS/2 programs can also be
developed in Pascal, FORTRAN, BASIC, and assembly language, but C is the most straightforward and easiest language
to use to access MS OS/2 functions. For this reason, all program samples in this guide are written in the C
programming language.
Before you start any development, you should review the *Microsoft Operating System/2 Programmer's Reference*.
The reference introduces the basic concepts of MS OS/2 and fully defines each MS OS/2 system function. Also, for
an explanation of what development tools you need to compile, link, and debug MS OS/2 programs, read the *Microsoft
Operating System/2 Programming Tools* manual.
### 1.3 What This Guide Covers
This guide shows how to use many features of MS OS/2. In particular, it shows how to do the following:
+ Use the file-system functions to open, read from, and write to files.
+ Use text-based video-input and -output functions to write text to and control the format of the system screen.
+ Use the mouse input functions to read events from the mouse, such as mouse motions and button clicks.
+ Use the keyboard-input functions to read characters and keystrokes from the system keyboard.
+ Use memory-allocation functions to allocate additional memory for your program.
+ Use process-control functions to start child processes and threads.
This guide does not cover some of the advanced features of MS OS/2. For example, it does not show how to use monitors,
dynamic linking, queues, subsystem registration, or national-language code-page support. However, there are several
MS OS/2 sample programs provided with the *MS OS/2 Programmer's Toolkit* that do illustrate these features.
### 1.4 The Lqh Sample Program
This guide shows how to build a sample program similar to the QuickHelp on-line help program provided with the MS OS/2
Programmer's Toolkit. Chapter 7, "Lqh: A Sample Program," contains an overview of the **lqh** source and an explanation
of how the MS OS/2 functions are used in the program.
The **lqh** source files are provided on disk.
### 1.5 MS OS/2 Sample Programs
In addition to the **lqh** program presented in this guide, there are many additional sample program sources on the disks
provided with the MS OS/2 Programmer's Toolkit. These small sample programs demonstrate the features of MS OS/2,
including features not described in this guide, such as monitors, dynamic linking, queues, and binding.
The following list briefly describes the MS OS/2 sample programs included in the MS OS/2 Programmer's Toolkit:
**Program** | **Description**
:------------ | :-------------
alloc | Allocates memory (bound).
argument | Passes parameters to threads.
asmexmpl | Creates and manages threads in assembly language.
asyncio | Shows how to use asynchronous input and output functions to write to the screen.
beepc | Beeps the speaker (bound).
config | Displays the machine configuration (bound).
country | Displays the current country information (bound).
critsec | Uses a critical section to prevent conflict between two threads that are using the **printf** function.
csalias | Creates alias code segments.
cwait | Waits for a child process to exit.
datetime | Prints the date and time (bound).
dosexit | Uses the **DosExit** function to exit threads.
dynlink | Shows how to create C and assembly-language dynamic­link libraries (bound).
exitlist | Sets up an exit routine and then exits.
fsinfo | Gets and sets volume information for drive A (bound).
getenv | Prints the first element of the environment (bound).
hello | Writes "Hello, world" to the screen (bound).
huge | Allocates "huge" memory (bound).
infoseg | Prints information about a process.
iopl | Gets and displays the current cursor position.
keys | Prints keycodes by using the **KbdCharIn** function (bound).
kill | Uses the **DosKillProcess** function to terminate a thread.
machmode | Displays the machine mode (bound).
monitors | Registers and terminates monitors.
move | Moves files (bound).
pipes | Uses pipes.
qhtype | Opens les and prints out handle information (bound).
queues | Uses queues to transfer data between consumer and server processes.
realloc | Increases and decreases the size of a segment.
session | Uses the session-manager functions.
setmaxfh | Sets the maximum number of file handles to 30.
setvec | Modifies the interrupt-vector table (bound).
share | Passes keystrokes between processes that are using shared memory.
signal | Uses a signal handler to catch the CONTROL+C key (bound).
sleep | Sleeps for a while (bound).
suballoc | Uses the suballocation functions (bound).
suspend | Suspends and resumes a thread.
threads | Creates and manages threads.
timer | Sleeps and then beeps three times.
version | Prints the DOS version (bound).
vioreg | Registers a Vio subsystem.
The following sample programs are extended examples that combine many of the features illustrated in the previous
samples:
**Program** | **Description**
:------------ | :-------------
terminal | Emulates a terminal and can be used with a direct connection to a host or through a Hayes modem.
sse | Edits text (bound).
cpgrep | Searches strings, using threads to make the speed of the search as fast possible.
ds | Displays and moves directory trees, and creates and uses an initialization file in the directory specified by the environment variable USER.
filelist | Lists files in a directory (bound).
life | Demonstrates how to use the the mouse interface in a bound program (bound).
mandel | Displays the Mandelbrot set, using EGA high-resolution graphics.
bigben | Displays a digital clock, demonstrating the Vio functions (bound).
setega | Sets 25/43-line mode (bound).
chaser | Demonstrates the use of threads (requires a mouse).
### 1.6 MS OS/2 and the C Run-time Library
Many of the sample programs included in the MS OS/2 Programmer's Toolkit combine both MS OS/2 and C run-time functions
to carry out their tasks. Although you can use C run-time functions in MS OS/2 programs, the program samples in this
guide use MS OS/2 functions exclusively.
In general, there are no special restrictions on using C run-time functions, as long as you use the appropriate version
of the C run-time library. For more information about using C run-time functions with MS OS/2 programs, see the
*Microsoft C Optimizing Compiler Version 5.1 Update*.

View file

@ -0,0 +1,38 @@
---
layout: page
title: "Microsoft OS/2: Welcome"
permalink: /docs/os2/microsoft/1.0/
---
Welcome
---
The Microsoft® Operating System/2 Programmer's Toolkit contains the latest tools, documentation, and sample programs
for developers writing MS® OS/2 programs. The software for the toolkit is distributed on four disks labeled Tools,
Applications, Examples, and QuickHelp.
### Documentation
To help you find the information that you need, the following list briefly explains the contents of each manual in the
MS OS/2 Programmer's Toolkit:
+ *Microsoft Operating System/2 Programming Tools* describes the programming tools found in the MS OS/2 Programmer's
Toolkit. You can use these tools to develop OS/2 programs.
+ *[Microsoft Operating System/2 Programmer's Learning Guide](/docs/os2/microsoft/1.0/plguide/)* teaches you the
fundamentals of programming for MS OS/2. You will be led through the steps necessary to create your first MS OS/2
program and dynamic-link library.
+ *Microsoft Operating System/2 Programmer's Reference* gives the syntax and parameters of each MS OS/2 function,
and provides examples of how to use each function.
### Installing the MS OS/2 Programmer's Toolkit
To help you install the software for the toolkit, a **setup** program is provided on the Tools disk. This program
prompts you for setup information, then loads the software onto your system. To run **setup**, type the following at
the A: prompt:
setup
After running **setup**, make sure that you modify your PATH, INCLUDE, and LIB environment variables as directed by
the program.

View file

@ -4,12 +4,86 @@ title: x86 Documentation
permalink: /docs/x86/
---
x86 Documentation
Placeholder for future x86 documentation.
x86 Instructions
---
First Header | Second Header
------------- | -------------
Content Cell | Content Cell
Content Cell | Content Cell
More to come...
[AAA](/docs/x86/ops/aaa/)
AAD
AAM
AAS
ADC
ADD
AND
CALL
CBW
CLC
CLD
CLI
CMC
CMP
CMPS
CWD
DAA
DAS
DEC
DIV
ESC
HLT
IDIV
IMUL
IN
INC
INT 3
INT
INTO
IRET
Jcc
JMP
LAHF
LDS
LEA
LES
LOCK
LODS
LOOP
LOOPZ
LOOPNZ
MOV
MOVS
MUL
NEG
NOP
NOT
OR
OUT
POP
POPF
PUSH
PUSHF
RCL
RCR
REP
REPZ
REPNZ
RET
ROL
ROR
SAHF
SAL
SAR
SBB
SCAS
SHL
SHR
STC
STD
STI
STOS
SUB
TEST
WAIT
XCHG
XLAT
XOR

74
docs/x86/ops/aaa.md Normal file
View file

@ -0,0 +1,74 @@
---
layout: page
title: "x86 Instructions: AAA"
permalink: /docs/x86/ops/aaa/
---
AAA (0x37)
---
### Description
AAA converts the result of the addition of two valid unpacked BCD digits to a valid 2-digit BCD number and
takes the AL register as its implicit operand.
For the previous addition to have had any meaning, each of the two operands of the addition must have had its
lower 4 bits contain a number in the range from 0 to 9. The AAA instruction then adjusts AL so that it contains
a correct BCD digit. If the addition produced a decimal carry (AF=1), the AH register is incremented and the carry
(CF) and auxiliary carry (AF) flags are set to 1. If the addition did not produce a decimal carry, CF and AF are
cleared to 0 and AH is not altered. In both cases, the high-order 4 bits of AL are cleared to 0.
Traditionally, this instruction is labeled as ASCII Adjust After Addition. And AAA will adjust the result of the
addition of two ASCII characters that were in the range from 30h ("0") to 39h ("9"). This is because the lower 4 bits
of those characters fall in the range from 0 to 9. The result of the addition, however, is not an ASCII character;
it is a BCD digit.
The following example shows how to add BCD numbers then adjust the result:
MOV AH,0 ;Clear AH for most significant digit
MOV AL,6 ;BCD 6 in AL
ADD AL,5 ;Add BCD 5 to digit in AL
AAA ;AH=1, AL=1 representing BCD 11.
### Algorithm
IF ((AL AND 0Fh)>9 OR (AF=1) THEN
IF (8086 OR 8088) THEN ;See note 1
AL=AL+6
ELSE ;80286 or later
AX=AX+6
ENDIF
AH=AH+1
AF=1
CF=1
ELSE
AF=0
CF=0
ENDIF
AL=AL AND 0FH
### Notes
1. The 8086 and 8088 implement AAA differently than later processors. On the 80286 and later processors,
the first addition is performed on AX instead of AL, incrementing the AH register if a carry is generated out
of AL. If AX contains OOFFh, executing AAA on an 8088 will leave AX=0105h. On an 80386, the same operation
will leave AX=0205h. Despite the different implementation, this instruction does operate as intended for all
valid operands.
2. The upper 4 bits of the AL register are always cleared to 0. This is not noted correctly in Intel's
documentation for the 80386 and 80486.
### Flags
**O** | **D** | **I** | **T** | **S** | **Z** | **A** | **P** | **C**
:---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---:
- | | | | - | - | * | - | *
### Timing
Operands | **x** | **88** | **86** | **286** | **386** | **486**
---------- | :---: | :----: | :----: | :-----: | :-----: | :-----:
none | 0 | 8 | 8 | 3 | 4 | 3
---
Source: PC Magazine "Programmer's Technical Reference: The Processor and Coprocessor," by Robert L. Hummel.

View file

@ -764,13 +764,17 @@ X86.opAAA = function()
var AL = this.regEAX & 0xff;
var AH = (this.regEAX >> 8) & 0xff;
if ((AL & 0xf) > 9 || this.getAF()) {
AL = (AL + 0x6) & 0xf;
AH = (AH + 1) & 0xff;
AL += 6;
/*
* Simulate the fact that the 80286 and higher actually add 6 to AX rather than AL.
*/
if (this.model >= X86.MODEL_80286 && AL > 0xff) AH++;
AH++;
CF = AF = 1;
} else {
CF = AF = 0;
}
this.regEAX = (this.regEAX & ~0xffff) | ((AH << 8) | AL);
this.regEAX = (this.regEAX & ~0xffff) | (((AH << 8) | AL) & 0xff0f);
if (CF) this.setCF(); else this.clearCF();
if (AF) this.setAF(); else this.clearAF();
this.nStepCycles -= this.cycleCounts.nOpCyclesAAA;