x86 programming for Ms Dos
Computers in CGA , EGA and VGA
The IBM 8086 took the world by storm!
Although inferior to the 68000 - the x86 soon took over, and is the
basis for all the computers we have today...
Starting with the 8086, and soon moving to the 286, 386 and so on...
each iteration has added more commands and power, and along the way
the PC has gained functionality...
In these tutorials, we'll take a look at the early basic
machines, and learn how we can use Assembly to write games that can
be used in MSDos via DosBox!
We'll cover 3 graphics modes...
CGA
320x200 4 color (Cyan,Magenta,White or Green,Red,Yellow)
EGA
320x200 16 color fixed palette
VGA
320x200 256 color palette
If you want to learn 8086 get theCheatsheet! it has all the 8086 commands, It will help you
get started with ASM programming, and let you quickly look up
commands when you get confused!
The ADLIB sound card usesd OPL2, which is also supported by the
full SoundBlaster range, it uses a range of registers to make its
sounds, each sound channel is formed by a combination of two Operators
NOTE: OPL3 doubled the number of registers, with an 'Advanced'
set... for simplicity (and my sanity) we'll just be covering the basic
OPL2 set, which are supported by OPL3 as well!
There are a total of up to 9 sound channels... each sound is the
combination of two "OP signals"... we should set both to get a sound
from a channel! How the OPs are combined is defined by bit 0 of
registers C0h-C8h... see the pdf documents for more info.
Channel
Signal
1
2
3
4
5
6
7
(Ryt)
8
(Ryt)
9
(Ryt)
OP1 Slot 1
Signal
1
2
3
7
8
9
13
14
15
OP2 Slot 2
Signal
4
5
6
10
11
12
16
17
18
Register settings
for slot
20
21
22
28
29
2A
30
31
32
23
24
25
2B
2C
2D
33
34
35
40
41
42
48
49
4A
50
51
52
43
44
45
4B
4C
4D
53
54
55
60
61
62
68
69
6A
70
71
72
63
64
65
6B
6C
6D
73
74
75
80
81
82
88
89
8A
90
91
92
83
84
85
8B
8C
8D
93
94
95
E0
E1
E2
E8
E9
EA
F0
F1
F2
E3
E4
E5
EB
EC
ED
F3
F4
F5
Register settings for
the channel
A0
A1
A2
A3
A4
A5
A6
A7
A8
B0
B1
B2
B3
B4
B5
B6
B7
B8
C0
C1
C2
C3
C4
C5
C6
C7
C8
Channels 7,8,9 can be toggled as Rhythm effects by setting bit 5 of
0BDh to 1
In this mode bits 0-4 of 0BDh will 'fire' the effects... each
effect uses some of the signal slots, the registers for this slot will
need to be set up as usual
BDh bits %DDRBSTCH
R=Rhythm enabled (channel 7-9 no
longer normal FM sound)
Bit / Rhythm sound
OP / Signal Slots used
B=Bass
13 & 16
S=Snare
17
T=Tom
15
C=Cymbal
18
H=Hihat
14
Sound over time
The OPs define how the sound level changes over time... K-On and K-Off
mimic the way piano keys work.. when the key is struck the sound will
start (Attack), and fade slowly (Decay) to a constant tone (Sustain), when
the key is lifted, it will fade quickly (Release)
Adlib OPL2 Registers and bits
Register
Details
Bits
Details
01h
Test
--WDDDDD
W=Wave select
Enable (opl2) / D=Test Data
02h
Timer 1
Setting 80-20.4us
TTTTTTTT
T=Timer
03h
Timer 2
Setting 320-82 us
TTTTTTTT
T=Timer
04h
Timer 1/2
control
RMM---SS
R=Reset
M=Mask S=?
08h
Speech Synth
/ Keyboard Split NoteSel
CS------
C=CSM Speech
synth mode / S=note Select
20h
- 35h
Multi / Key
Scale Rate / EG-Type Tone / Vibrato / AM modulation