Z80 Assembly programming for the MSX and MSX2

The MSX and later the MSX2 were an attermpt to create a 'PC' before the PC!... based around the 8-bit processor, an 'industry standard' compatible computer specification was created, and any manufacturer could realease compatible hardware.

With 2 extension slots, the machine was upgradable, and the end user could be confident that their hardware and software would work whatever MSX machine they had!

The last generation MSX - the Turbo-R was hugely powerful, and it's upgradability means the MSX now has the V9990... combining the Turbo-R and the V9990 (V9K) we effectively have what would have been the MSX3 if it had not been cancelled
Because each MSX has different hardware, we can only generalize, but here's the hardware specification you can expect to see!
Specs:

MSX MSX2 Turbo-R V9990
Cpu 3.5mhz Z80 3.5mhz Z80 7mhz R800 (28mhz effective)
Ram 16k 64k 256k / 512k
Vram 16k 128k 128k 512k (9x MSX2 speed)
Resolution 256x192 256x212 256x212 256x212
Colors 16 16 256 256
Sprites 32 sprites
8x8 or 16x16



Sound chip AY AY AY + PCM

The V9990 can be used with the MSX, or MSX2 as well! - not just the Turbo-R

Although the Turbo-R does not use a Z80, the R800 has effectively perfect compatibility, although it's 'only'  7mhz , it uses memory caching, and in optimum circumstances can perform 4x the speed of a 7mhz Z80


ChibiAkumas Tutorials


Lesson H3 - Hello World on the MSX / MSX2

Lesson S5 - Easy Sprites on the MSX2
    Lesson P1 - Basic Firmware Text functions

Lesson P2 - More Text Functions, Improvements... and the Sam Coupe!

Lesson P5 - Bitmap graphics on the TI-83 and MSX

Lesson P7 - Keyreading on the MSX, Enterprise and TI-83

Lesson P10 - Tilemap graphics on the MSX1

Lesson P11 - Tilemap graphics on the MSX2

Lesson P15 - Palette definitions on the MSX2 and V9990

Lesson P18 - Making Sound with the AY-3-8910 on the Amstrad CPC, MSX,ZX Spectrum.... and NeoGeo + Atari ST!!

Lesson P25 - Bankswitching and hardware detection on the MSX

Lesson P31 - Hardware Sprites on the Master System / Game Gear and MSX1!

Lesson P35 - Playing Digital Sound with WAV on the AY-3-8910!

Lesson P48 - All MSX2 Bitmap Commands - Part 1/2

Lesson P49 - All MSX2 Bitmap Commands - Part 2/2

Lesson P50 - Alternative Bitmap modes... HighRes, 256 color, YJK (MSX2+) and Interlaced!

Lesson P52 - MSX1 mode G2 for 768 onscreen tiles

Lesson P59 - Hardware scrolling on the MSX 1/2/2+

Lesson P64 - Mouse reading on the MSX

Lesson P69 - ChibiSound PRO on the CPC, MSX and Spectrum (128 - AY) [CPC] [MSX] [ZXS]


Default Memory Map

CBIOS MSX1
With cartridge in Slot 1/A

&0000-&3FFF Rom Slot 0
&4000-&7FFF Cart Slot 1
&8000-&BFFF Ram Slot 3
&C000-&FFFF Ram Slot 3
Panasonic FS-A1F MSX2
With cartridge in Slot 1/A

&0000-&3FFF Rom Slot 0
&4000-&7FFF Cart Slot 1
&8000-&BFFF Ram Slot 3-0
&C000-&FFFF Ram Slot 3-0
Panasonic FS-A1F MSX2
In basic

&0000-&3FFF Rom Slot 0
&4000-&7FFF Rom Slot 0
&8000-&BFFF Ram Slot 3-0
&C000-&FFFF Ram Slot 3-0

MSX Banks, Slots and Subslots... Oh my!:
The MSX memory layout is far more advanced and powerful than other 8 bits... unfortunately that tends to just mean that it's more annoying!

Take a look at an MSX! You'll see it has 1 or usually 2 cartridge slots... right?... well actually there are two extra slots! 0 and 3 are 'internal' slots used by the system itself... so we have slots 0-3... simple right... actually no!

A 'Slot' can (but is not always) be split into 4 subslots... also numbered 0 to 3
EVERYTHING is in a slot, so RAM and ROM are in a slot somewhere... but unfortunately they aren't in the same place on all machines!... Slot 1 and 2 are always the cartridge slots, but the RAM could be in slot 3, or in slot 0-2 (slot 0 subslot 2)

It's all quite annoying!

The MSX memory map is split into 4 16K chunks, and each bank can be 'pointed' to one of the 3 slots... If the slot is expanded, each of these banks can be set to a different subslot... so bank 0 can point to 0-0 (slot 0 subslot 0), and bank 1 can point to 0-2 (slot 0 subslot 2)... while banks 2 and 3 could point to slot 3!

It needs to be understood that each slot has 4 banks for a full 64k - so when bank 0 and 1  points to slot 3-0... they are different 16k chunks... also in this case it is not possible to swap them round... Bank 0 (&0000-&3FFF) of the Z80 memory cannot point to bank 1 (&4000-&7FFF) of the Slot

So suppose we have the following set up:


Subslots
Slot 0 0-0 0-1 0-2 0-3
Slot 1 1 Unexpanded slot
Slot 2 2-0 2-1 2-2 2-3
Slot 3 3-0 3-1 3-2 3-3

ROM  
RAM  
Cartridge  
Empty

Z80 Banks
The Z80 address range is split into 4 banks of 16k
We may see a systems setup at boot in the following... .Remember Slot 3-0 will have 4 different memory banks, but they can only be mapped into the matching positions of the Z80 address range.

*** We can only map a Z80 bank to the MATCHING slot bank!

Slot Selection Register
Which Slot the Z80 will see in each bank is defined by the slot selection register at port &A8... it's 8 bits define all 4 banks slot number... each 2 bits define the slot number for an area of the address range

Port &A8 Bits 7 6 5 4 3 2 1 0
Bank number     3 (&C000-&FFFF)     2 (&8000-&BFFF)     1 (&4000-&7FFF)     0 (&0000-&3FFF)  

Sub-Slot Selection
Not all slots are expanded.... but it's easy to tell if they are, on boot addresses &FCC1-&FCC4 will be configured to record if slots 0-3 are expanded... the top bit (bit 7) will be 1 if they are

If a slot IS expanded... there will be a memory mapped register at memory address &FFFF

the format is the same as the slot selection register

Slot 0 &FFFF Bits 7 6 5 4 3 2 1 0
Subslot number     3 (&C000-&FFFF)     2 (&8000-&BFFF)     1 (&4000-&7FFF)     0 (&0000-&3FFF)  

Memory Mappers
As mentioned, we can only map a bank of ram in a slot to the matching bank in the Z80 range... wouldn't it be nice if we could map a bank of ram to ANY bank of the Z80 range?

Well actually we can!... in theory!
A slot CAN have something called a 'Memory Mapper'... what's this? well it allows exactly what I just mentioned... any one of the 16k banks in the slot can be mapped to the that slots position...  we still need to map in the slot (and subslot if required) but that slot can expose any bank of memory... this also allows us to address more than 64k... we can have up to 512k!

We select a slots memory mapping using 4 ports...  note we can only write to these - we cannot rely on reading from them
Port   Z80 Address range Default value
&FC &0000-&3FFF 3
&FD &4000-&7FFF 2
&FE &8000-&BFFF 1
&FF &C000-&FFFF 0
A system may have more than one Memory mapper...one internal, and one in an upgrade... but they will all set at the same time with these ports... we will still need to page in the slot-subslot using the usual method to get access to the memory.

So Memory mappers are more flexible, and allow more memory... what's not to like?.... well almost NO MSXes have them... even with the MSX2+, most MSXes do not have them... so unless your game is Turbo-R only, you're not going to be able to use them!

Cartridge Mappers
Cartridges also have 'mappers'... though they work differently - we just WRITE the bank number to a special address in the ROM, and the ROM will switch it's bank for us!

There are various mappers, but we'll look at "Konami with SCC" (Konami5) , it provides 4 rom areas that can be reconfigured - note they do not cover the whole Z80 range - as the bottom bank is assumed to be ROM, and the top bank is assumed to be RAM

Area   Z80 Address Range   Write Address
to change bank
Default Value
1 &4000-&5FFF &5000 0
2 &6000-&7FFF &7000 1
3 &8000-&9FFF &9000 2
4 &A000-&BFFF &B000 3

Minimum MSX configurations
So what can we expect from our MSXes memory wise, well here's what you need to assume you'll have!
System     MSX1   MSX2   MSX2+   Turbo-R  
Memory 16k 64k 64k 256K
Disk System?   NO NO (sometimes) NO (usually - not always) YES
Mapper? NO NO NO (sometimes) YES
Soooo.... Effectively on the MSX1 we're pretty much going to have to rely on using Cartrige ROM, and we won't be able to use a Memory Mapper unless we're using the Turbo-R as the minimum requirement.

Joystick Reading

On the MSX the joysticks are connected to the AY data port.
We select an AY register with port &A0, we set one with port &A1, and read one with port &A2

First we need to set the bottom 4 bits of AY register 15 to 1 - this is to enable input of pins 6/7 of the joysick and to select Joystick 0.

Next we select AY register 14 - This will allow us to read in from the joystick.

Finally we read in from port &A2, this gets the actual state of the joystick and it's two fires in the format %--21RLDU

The MSX1 VDP

The MSX1 VDP has 16 KB of memory

The Tile Pattern definitions use 1 byte per line for 1 bit pixel data, and 1 byte per line in the Colormap area to define color, one nibble for Foreground, and one nibble for background, in the format &FB

The Tilemap has 2 modes... normal mode uses 256 definitions, in the area &0000-&07FF...

Alternate mode uses 3 Pattern definitions, one for the first 1/3rd of the screen, another for the 2nd 3rd, and the final for the last 3rd... this allows us to simualte a bitmap screen, as we have enough tiles for each block of the screen to be unique, while only having one byte per tile in the tilemap!
From To Meaning
0000 07FF VRAM: Main Tile Patterns (1/3)
0800 0FFF VRAM: Extra Tile Patterns (2/3)
1000 17FF VRAM: Extra Tile Patterns (3/3)
1800 1AFF VRAM: Tilemap
1B00 1B7F VRAM: Sprite Attributes
1B80 1BAF VRAM: Palette Table
2000 37FF VRAM: Colormap
3800 3FFF VRAM: Sprite Patterns

The color palette is fixed, and there are no brightness or other limitations (unlike the speccy!)
   0       1       2       3       4       5       6       7   
8 9 A B C D E F
Note: Color 0 is transparent.

MSX1 Sprites
the MSX1 is capable of 32 onscreen sprites (max 4 on one line), that are 8x8 or 16x16 pixel size, each is one single color(not one color per line)
By default Sprite patterns are held at &3800 - there is enough ram for 64 16x16 sprite patterns, or 256 8x8 sprites.

Reg Meaning Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
R#1 mode register #1 0 BL IE0 M1 M2 0 SI MAG SI=16x16 sprites / MAG = Big Sprites
R#5 sprite attribute table (LOW) A14 A13 A12 A11 A10 A9 A8 A7
R#6 sprite pattern generator table 0 0 A16 A15 A14 A13 A12 A11
R#8 mode register #2 MS LP TP CB VR 0 SPD BW

SI in R#1 is the Spritesize 0=8x8 1=16x16
MAG in R#1 will double the size of the sprites
SPD in R#8 will DISABLE the sprites - if this is set sprites will not work!
R#5 is the address of the sprite bitmap data
R#6 is the address of the sprite attributes

MSX1 Sprite Attributes
Address Sprite Bits Details
$1B00 0 YYYYYYYY  Y=Ypos
$1B01 0 XXXXXXXX  X=Xpos
$1B02 0 PPPPPPPP  P=Patternnum
$1B03 0 E---CCCC  E=Extended X C=Color
$1B04 1 YYYYYYYY  Y=Ypos
$1B05 1 XXXXXXXX  X=Xpos
$1B06 1 PPPPPPPP  P=Patternnum
$1B07 1 E---CCCC  E=Extended X C=Color
.. .. .. . .
$1BFD 31 YYYYYYYY  Y=Ypos
$1BFC 31 XXXXXXXX  X=Xpos
$1BFE 31 PPPPPPPP  P=Patternnum
$1BFF 31 E---CCCC  E=Extended X C=Color
The position and bitmap data of MSX1 sprites is defined by the attribute table, each sprite has 4 attributes...
Note the sepecial 'E' attribute in byte 4... this allows a sprite to be 'further left' than X=0 for sprites going off the left hand side of the screen

Pattern number can be from 0-255 for 8x8 tile mode....
for 16x16 tile mode it is 0-63...
NOTE... the 8x8 tiles need to be in a different order for this mode... imagine 4 8x8 blocks in a 16x16 sprite... they need to be in the following order:p
 1  3
 2  4
There is a special exporter in AkuSprite editor called 'Save RAW MSX1 16x16 Sprite'

The MSX2 VDP
The MSX2 GPU has to be controlled via it's ports via OUT commands.
MSX 2 - V9938 Ports
Port When Read When Written
&98 Read Data Write Data
&99 Control Status
&9A
Palette (use R#16 to select Palette entry)
&9B
Indirect register
V9990
Port When Read When Written
&60 Read Data Write Data
&61
Palette
&62
Command
&63
Regsiter Data
&64
Register Select
&65 Status
&66 Interrupt Flag
&67
System
&6F
Superimpose

To control the MSX2 GPU, we have to set it's registers, and then send a command to register 46

To Set a register, first send the value to put in the register  to the control port, then send the register number +128 to the control port.

EG lets set Reg 15 to 2...
    ld a,2
    out (&99),a
    ld a,15+128
    out (&99)dd
28 is an instruction meaning 'This is a register number'
Some registers like R#14 need more than 1 byte, just send these after the 14+128 command has been sent - the VDP will be expecting the extra data!

V9938 (MSX2) - Ports, Registers and Commands

Commands
Name Command From To Units ByteCode Function (USE)
HMMC High Spd Move CPU VRAM bytes %11110000 (&F0) Fill Bytes from OUTI (Define Sprites / CPU render)
YMMM High Spd MoveY VRAM VRAM bytes %11100000 (&E0) Copy an area from Vram to Vram
only changing Y (Draw Background / Vscroll)
HMMM High Spd Move VRAM VRAM bytes %11010000 (&D0) Copy an area from Vram to Vram fast
(blit Sprites / Scroll)
HMMV High Spd Move VDP VRAM bytes %11000000 (&C0) Fast fill a square with a single byte (Clear Areas)
LMMC Logical Move CPU VRAM dots %10110000 (&B0)
LMCM Logical Move VRAM CPU dots %10100000 (&A0)
LMMM Logical Move VRAM VRAM dots %10010000 (&90) Copy an area of Vram 
with Logical conditions (Transparency)
LMMV Logical Move VDP VRAM dots %10000000 (&80)
LINE Line VDP VRAM dots %01110000 (&70)
SRCH Search VDP VRAM dots %01100000 (&60)
PSET Pset VDP VRAM dots %01010000 (&50)
POINT Point VDP VRAM dots %01000000 (&40)
STOP Stop


%00000000 (&00) Stop processing current task

If you want to know all the details, you should download the v9938 documentation here


Status Registers
Reg Meaning Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
S#0 Status 0 F 5S C 5SN 5SN 5SN 5SN 5SN
S#1 Status 1 FL LPS ID ID ID ID ID FH
S#2 Status 2 TR VR HR BD 1 1 EO CE
S#3 Status 3 X7 X6 X5 X4 X3 X2 X1 X0
S#4 Status 4 1 1 1 1 1 1 1 X8
S#5 Status 5 Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
S#6 Status 6 1 1 1 1 1 1 Y9 Y8
S#7 Status 7 C7 C6 C5 C4 C3 C2 C1 C0
S#8 Status 8 BX7 BX6 BX5 BX4 BX3 BX2 BX1 BX0
S#9 Status 9 1 1 1 1 1 1 1 BX8
             
Note:
The firmware expects status register S#0 to be selected in R#15

Interrupts will fire until S#0 is read... so you must do this if you write your own interrupt handler!

Registers
... MSX1 MSX2 MSX2+
Reg Meaning Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
R#0 mode register #0 0 DG IE2 IE1 M5 M4 M3 0
R#1 mode register #1 (IE0= IM1 on)
0 BL IE0 M1 M2 0 SI MAG
R#2 pattern name table 0 A16 A15 A14 A13 A12 A11 A10
R#3 color table (LOW) A13 A12 A11 A10 A9 A8 A7 A6
R#4 pattern generator table 0 0 A16 A15 A14 A13 A12 A11
R#5 sprite attribute table (LOW) A14 A13 A12 A11 A10 A9 A8 A7
R#6 sprite pattern generator table 0 0 A16 A15 A14 A13 A12 A11
R#7 border color/character color at text mode TC3 TC2 TC1 TC0 BD3 BD2 BD1 BD0
R#8 mode register #2 MS LP TP CB VR 0 SPD BW
R#9 mode register #3 LN 0 S1 S0 IL E0 *NT DC
R#10 color table (HIGH) 0 0 0 0 0 A16 A15 A14
R#11 sprite attribute table (HIGH) 0 0 0 0 0 0 A16 A15
R#12 character color at text blinks T23 T22 T21 T20 BC3 BC2 BC1 BC0
R#13 blinking period ON3 ON2 ON1 ON0 OF3 OF2 OF1  OF0
R#14 VRAM access address (HIGH) 0 0 0 0 0 A16 A15 A14


A7 A6 A5 A4 A3 A2 A1 A0


0 RW A13 A12 A11 A10 A9 A8
R#15 indirect specification of S#n 0 0 0 0 S3 S2 S1 S0
R#16 indirect specification of P#n (Palette)
0 0 0 0 C3 C2 C1 C0
R#17 indirect specification of R#n AII 0 R5 R4 R3 R2 R1 R0
R#18 screen location adjustment (ADJUST) (Scroll)
V3 V2 V1 V0 H3 H2 H1 H0
R#19 scanning line number when the interrupt occurs IL7 IL6 IL5 IL4 IL3 IL2 IL1 IL0
R#20 color burst signal 1 0 0 0 0 0 0 0 0
R#21 color burst signal 2 0 0 1 1 1 0 1 1
R#22 color burst signal 3 0 0 0 0 0 1 0 1
R#23 screen hard V-scroll
DO7 DO6 DO5 DO4 DO3 DO2 DO1 DO0
R#25
Scroll Options (left side Mask / 2 page) 0 0 0 0 0 0 MSK SP2
R#26
Screen H-scroll (Bits 8-3) 0 0 H08 H07 H06 H05 H04 H03
R#27 Screen H-scroll (Bits 2-0) 0 0 0 0 0 H02 H01 H00
R#32 SX: X-coordinate to be transferred (LOW) SX7 SX6 SX5 SX4 SX3 SX2 SX1 SX0
R#33 SX: X-coordinate to be transferred (HIGH) 0 0 0 0 0 0 0 SX8
R#34 SY: Y-coordinate to be transferred (LOW) SY7 SY6 SY5 SY4 SY3 SY2 SY1 SY0
R#35 SY: Y-coordinate to be transferred (HIGH) 0 0 0 0 0 0 SY9 SY8
R#36 DX: X-coordinate to be transferred to (LOW) DX7 DX6 DX5 DX4 DX3 DX2 DX1 DX0
R#37 DX: X-coordinate to be transferred to (HIGH) 0 0 0 0 0 0 0 DX8
R#38 DY: Y-coordinate to be transferred to (LOW) DY7 DY6 DY5 DY4 DY3 DY2 DY1 DY0
R#39 DY: Y-coordinate to be transferred to (HIGH) 0 0 0 0 0 0 DY9 DY8
R#40 NX: num. of dots to be transferred in X direction (LOW) NX7 NX6 NX5 NX4 NX3 NX2 NX1 NX0
R#41 NX: num. of dots to be transferred in X direction (HIGH) 0 0 0 0 0 0 0 NX8
R#42 NY: num. of dots to be transferred in Y direction (LOW) NY7 NY6 NY5 NY4 NY3 NY2 NY1 NY0
R#43 NY: num. of dots to be transferred in Y direction (HIGH) 0 0 0 0 0 0 NY9 NY8
R#44 CLR: for transferring data to CPU - - - - C3 C2 C1 C0


- - - - - C1 C0 G5


C7 C6 C5 C4 C3 C2 C1 C0
R#45 ARG: bank switching between VRAM and expanded VRAM
Comparison (EQ) / Draw Direction (MAJ)
0 MXC MXD MXS DIY DIX EQ MAJ
R#46 CMR: send VDP command CMD CMD CMD CMD MSK MSK MSK MSK

Masks (R46 bits 0-3)

Code Function Bits
IMP
PSET %0000 (&00)
AND
Mask %0001 (&01)
OR

%0010 (&02)
XOR 
XOR draw %0011 (&03)
NOT

%0100 (&00)



TIMP Color 0 = Transparent   %1000 (&08)
TAND  

%1001 (&09)
TOR
%1010 (&0A)
TXOR
%1011 (&0B)
TNOT
%1100 (&0C)

Draw Direction (R45 bits 2/3)

Direction Bits
DownRight 
%00 (&00)
DownLeft %01 (&04)
UpRight %10 (&08)
UpLeft %11 (&0C)

V9938 (MSX2) Command/Register usage



HMMC
(Define)
HMMV
(Fill)
HMMM
(Draw
sprite)
LMMM
(Draw
Transp)

First Used Register: 36
36
32
32
R#32 SX: X-coordinate to be transferred (LOW)

SX-L SX-L
R#33 SX: X-coordinate to be transferred (HIGH)

SX-H SX-H
R#34 SY: Y-coordinate to be transferred (LOW)

SY-L SY-L
R#35 SY: Y-coordinate to be transferred (HIGH)

SY-H SY-H
R#36 DX: X-coordinate to be transferred to (LOW) DX-L DX-L DX-L DX-L
R#37 DX: X-coordinate to be transferred to (HIGH) DX-H DX-H DX-H DX-H
R#38 DY: Y-coordinate to be transferred to (LOW) DY-L DY-L DY-L DY-L
R#39 DY: Y-coordinate to be transferred to (HIGH) DY-H DY-H DY-H DY-H
R#40 NX: num. of dots to be transferred in X direction (LOW) Width-L Width-L Width-L Width-L
R#41 NX: num. of dots to be transferred in X direction (HIGH) Width-H Width-H Width-H Width-H
R#42 NY: num. of dots to be transferred in Y direction (LOW) Height-L Height-L Height-L Height-L
R#43 NY: num. of dots to be transferred in Y direction (HIGH) Height-H Height-H Height-H Height-H
R#44 CLR: for transferring data to CPU FirstByte - - -
R#45 ARG: bank switching between VRAM and expanded VRAM 0 0 0 0
R#46 CMR: send VDP command &F0 &C0 &D0 &98
(8=TIMP)

Fields marked - can be anything / Empty fields do not need setting



V9990 - Ports, Registers and Commands

V9990 Commands
Name Command From To Units ByteCode Function
STOP Stop


%00000000 Stop processing current task
LMMC Logical Move CPU VRAM
%00010000 Fill Bytes from OUTI
LMMV Logical Move VDP VRAM
%00100000 Flood fill a square with a single byte
LMCM Logical Move VRAM CPU
%00110000
LMMM Logical Move VRAM VRAM dots %01000000 Copy an area from Vram to Vram fast (blit)
CMMC Color-Develop CPU VRAM
%01010000







CMMM Color-Develop VRAM VRAM
%01110000
BMXL Linear BMP L-VRAM VRAM
%10000000
BMLX Linear BMP VRAM L-VRAM
%10010000
BMLL Linear BMP L-VRAM L-VRAM
%10100000
LINE Line


%10110000
SEARCH Search


%11000000
POINT Point


%11010000
PSET Pset


%11100000
ADVANCE



%11110000

If you want to know all the details, you should download the v9938 documentation here

V9990 Status 
Reg Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Port &65 TR VR HR BD 0 MCS EO CE
         
Check CE to see if VDP is busy...
   
Note:
Even if you:re using the VDP, you need to check the MSX status port in your interrupt handler as usual!

V9990 Registers
Reg Meaning Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
R#0 Vram Write L L L L L L L L L
R#1 Vram Write H H H H H H H H H
R#2 Vram Write X X X X X X X X X
R#3 Vram Read L L L L L L L L L
R#4 Vram Read H H H H H H H H H
R#5 Vram Read X X X X X X X X X
R#6 Screen Mode D D C C X X B B
R#7 Screen Mode







R#8 Control D S Y S W 0 1 0
R#9 Interrupt







R#10 Interrupt







R#11 Interrupt







R#12 Interrupt







R#13 Palette Control







R#14 Palette Pointer (autoinc) Num Num Num Num Num Num Chn Chn
R#15 Back drop color - - B B B B B B
R#16 Display Adjust V V V V H H H H
R#17 Scroll Control







R#18 Scroll Control







R#19 Scroll Control







R#20 Scroll Control







R#21 Scroll Control







R#22 Scroll Control







R#23 Scroll Control







R#24 Scroll Control







R#25 Sprite Generator Base Address







R#26 LCD Control







R#27 Priority Control







R#28 Cursor Sprite Palette Offset







R#32 SX L L L L L L L L L
R#33 SX H H H H H H H H H
R#34 SY L L L L L L L L L
R#35 SY H H H H H H H H H
R#36 DX L L L L L L L L L
R#37 DX H H H H H H H H H
R#38 DY L L L L L L L L L
R#39 DY H H H H H H H H H
R#40 NX L L L L L L L L L
R#41 NX H H H H H H H H H
R#42 NY L L L L L L L L L
R#43 NY H H H H H H H H H
R#44 Move 0 0 0 0 DIY DIX NEQ NAJ
R#45 Logical Operation 0 0 0 TP L11 L10 L01 L00
R#46 Write Mask L L L L L L L L L
R#47 Write Mask H H H H H H H H H
R#48 Foreground Font Color L L L L L L L L L
R#49 Foreground Font Color H H H H H H H H H
R#50 Background Font Color L L L L L L L L L
R#51 Background Font Color H H H H H H H H H
R#52 Operation Code C C C C - - - -
R#53 Search Command B B B B B B B B
R#54 Search Command - - - - - B B B


AY Sound Chip:

Register Meaning Bit Meaning Details
0 Tone Pitch L - Channel A LLLLLLLL Lower value = Higher pitch
1 Tone Pitch H - Channel A ----HHHH Lower value = Higher pitch
2 Tone Pitch L - Channel B LLLLLLLL Lower value = Higher pitch
3 Tone Pitch H - Channel B ----HHHH Lower value = Higher pitch
4 Tone Pitch L - Channel C LLLLLLLL Lower value = Higher pitch
5 Tone Pitch H - Channel C ----HHHH Lower value = Higher pitch
6 Noise Generator ---NNNNN Higer = Faster noise
7 Mixer  --NNNTTT   N=Noise T=Tone (Channel --CBACBA 1=mute 0=normal)
8 Amplitude - Channel A ---EVVVV E=Envelope (1=Enabled) VVVV=Volume
9 Amplitude - Channel B ---EVVVV E=Envelope (1=Enabled) VVVV=Volume
10 Amplitude - Channel C ---EVVVV E=Envelope (1=Enabled) VVVV=Volume
11 Envelope L (Volume over time)  LLLLLLLL Lower=Faster Envelope
12 Envelope H (Volume over time)  HHHHHHHH Lower=Faster Envelope
13 Envelope Selection ----EEEE Envelope number (See PDF)

For more details, please see the AY sound chip PDF

Ram Variables:
Section Address Name Details
Rom 0000H CHKRAM RST0: tests RAM and sets RAM slot for the system

0008H SYNCHR RST1: tests whether the character of [HL] is the specified

000CH RDSLT selects the slot corresponding to the value of A and reads

0010H CHRGTR RST2: gets a character or a token from BASIC text

0014H WRSLT selects the slot corresponding to the value of A and writes one byte

0018H OUTDO RST3: sends the value to current device

001CH CALSLT calls the routine in another slot inter-slot call

0020H DCOMPR RST4: compares the contents of HL and DE

0024H ENASLT selects the slot corresponding to the value of A and enables the slot to be used

0028H GETYPR RST5: returns the type of DAC decimal accumulator

0030H CALLF RST6: calls the routine in another slot.

0038H KEYINT RST7: executes the timer interrupt process routine

003BH INITIO initialises the device

003EH INIFNK initialises the contents of function keys

0041H DISSCR inhibits the screen display

0044H ENASCR displays the screen

0047H WRTVDP writes data in the VDP register

004AH RDVRM reads the contents of VRAM.

004DH WRTVRM writes data in VRAM

0050H SETRD sets VRAM address to VDP and enables it to be read.

0053H SETWRT sets VRAM address to VDP and enables it to be written.

0056H FILVRM fills the specified VRAM area with the same data.

0059H LDIRMV block transfer from VRAM to memory

005CH LDIRVM block transfer from memory to VRAM

005FH CHGMOD changes the screen mode. The palette is not initialised.

0062H CHGCLR changes the screen color

0066H NMI executes NMI Non-Maskable Interrupt handling routine

0069H CLRSPR initialises all sprites.

006CH INITXT initialises the screen to TEXT1 mode 40 x 24

006FH INIT32 initialises the screen to GRAPHIC1 mode 32x24

0072H INIGRP initialises the screen to the high-resolution graphics mode.

0075H INIMLT initialises the screen to MULTI color mode.

0078H SETTXT set only VDP in TEXT1 mode 40x24

007BH SETT32 set only VDP in GRAPHIC1 mode 32x24

007EH SETGRP set only VDP in GRAPHIC2 mode

0081H SETMLT set only VDP in MULTI color mode

0084H CALPAT returns the address of the sprite generator table

0087H CALATR returns the address of the sprite attribute table

008AH GSPSIZ returns the current sprite size

008DH GRPPRT displays a character on the graphic screen

0090H GICINI initialises PSG and sets the initial value for the PLAY statement

0093H WRTPSG writes data in the PSG register

0096H RDPSG reads the PSG register value

0099H STRTMS tests whether the PLAY statement is being executed as a background task.

009CH CHSNS tests the status of the keyboard buffer

009FH CHGET one character input waiting

00A2H CHPUT displays the character

00A5H LPTOUT sends one character to the printer

00A8H LPTSTT tests the printer status

00ABH CNVCHR test for the graphic header and transforms the code

00AEH PINLIN stores in the specified buffer the character codes input till STOP key.

00B1H INLIN same as PINLIN except that AUTFLG F6AAH is set

00B4H QINLIN executes INLIN with displaying "?" and one space

00B7H BREAKX tests Ctrl-STOP key. In this routine, interrupts are inhibited.

00C0H BEEP generates BEEP

00C3H CLS clears the screen

00C6H POSIT moves the cursor

00C9H FNKSB tests whether the function key display is active FNKFLG

00CCH ERAFNK erases the function key display

00CFH DSPFNK displays the function keys

00D2H TOTEXT forces the screen to be in the text mode

00D5H GTSTCK returns the joystick status

00D8H GTTRIG returns the trigger button status

00DBH GTPAD returns the touch pad status

00DEH GTPDL returns the paddle value

00E1H TAPION reads the header block after turning the cassette motor ON.

00E4H TAPIN reads data from the tape

00E7H TAPIOF stops reading the tape

00EAH TAPOON writes the header block after turning the cassette motor ON

00EDH TAPOUT writes data on the tape

00F0H TAPOOF stops writing to the tape

00F3H STMOTR sets the cassette motor action

0132H CHGCAP alternates the CAP lamp status

0135H CHGSND alternates the 1-bit sound port status

0138H RSLREG reads the contents of current output to the basic slot register

013BH WSLREG writes to the primary slot register

013EH RDVDP reads VDP status register

0141H SNSMAT reads the value of the specified line from the keyboard matrix

0144H PHYDIO Physical input/output for disk devices

014AH ISFLIO tests whether the device is active

014DH OUTDLP printer output

0156H KILBUF clears the keyboard buffer

0159H CALBAS executes inter-slot call to the routine in BASIC interpreter
MSX2 015CH SUBROM executes inter-slot call to SUB-ROM

015FH EXTROM executes inter-slot call to SUB-ROM

0168H EOL deletes to the end of the line

016BH BIGFIL same function as FILVRM.

016EH NSETRD enables VRAM to be read by setting the address

0171H NSTWRT enables VRAM to be written by setting the address

0174H NRDVRM reads the contents of VRAM

0177H NWRVRM writes data in VRAM
Sub-Rom 0089H GRPRT one character output to the graphic screen active only in screen modes 5 to 8

00C9H NVBXLN draws a box

00CDH NVBXFL draws a painted box

00D1H CHGMOD changes the screen mode

00D5H INITXT initialises the screen to TEXT1 mode 40 x 24

00D9H INIT32 initialises the screen to GRAPHIC1 mode 32x24

00DDH INIGRP initialises the screen to the high-resolution graphics mode

00E1H INIMLT initialises the screen to MULTI color mode

00E5H SETTXT sets VDP in the text mode 40x24

00E9H SETT32 ses VDP in the text mode 32x24

00EDH SETGRP sets VDP in the high-resolution mode

00F1H SETMLT sets VDP in MULTI color mode

00F5H CLRSPR initialises all sprites.

00F9H CALPAT returns the address of the sprite generator table

00FDH CALATR returns the address of the sprite attribute table

0101H GSPSIZ returns the current sprite size

0105H GETPAT returns the character pattern

0109H WRTVRM writes data in VRAM

010DH RDVRM reads the contents of VRAM

0111H CHGCLR changes the screen color

0115H CLSSUB clears the screen

011DH DSPFNK displays the function keys

012DH WRTVDP writes data in the VDP register

0131H VDPSTA reads the VDP register

013DH SETPAG switches the page

0141H INIPLT initialises the palette(the current palette is saved in VRAM

0145H RSTPLT restores the palette from VRAM

0149H GETPLT obtains the color code from the palette

014DH SETPLT sets the color code to the palette

017DH BEEP generates BEEP

0181H PROMPT displays the prompt

01ADH NEWPAD reads the status of mouse or light pen

01B5H CHGMDP changes VDP mode. The palette is initialised.

01BDH KNJPRT sends a kanki to the graphic screen modes 5 to 8

01F5H REDCLK reads the clock data

01F9H WRTCLK writes the clock data
Interslot F380H RDPRIM read from basic slot

F385H WRPRIM write to basic slot

F38CH CLPRIM basic slot call
USR F39AH USRTAB initial value: FCERR contents: starting address of assembly language program of USR function 0 to 9 ; the value before defining assembly language program

F3AEH LINL40 initial value: 39 contents: screen width per line at SCREEN 0 set by WIDTH statement at SCREEN 0

F3AfH LINL32 initial value: 32 contents: screen width per line at SCREEN 1 set by WIDTH statement at SCREEN 1

F3B0H LINLEN initial value: 29 contents: current screen width per line

F3B1H CRTCNT initial value: 24 contents: number of lines of current screen

F3B2H CLMLST initial value: 14 contents: horizontal location in the case that items are divided by commas in PRINT statement
Screen 0 F3B3H TXTNAM initial value: 0000H contents: pattern name table

F3B5H TXTCOL contents: unused

F3B7H TXTCGP initial value: 0800H contents: pattern generator table

F3B9H TXTATR contents: unused

F3BBH TXTPAT contents: unused
Screen 1 F3BDH T32NAM initial value: 1800H contents: pattern name table

F3BFH T32COL initial value: 2000H contents: color table

F3C1H T32CGP initial value: 0000H contents: pattern generator table

F3C3H T32ATR initial value: 1B00H contents: sprite attribute table

F3C5H T32PAT initial value: 3800H contents: sprite generator table
Screen 2 F3C7H GRPNAM initial value: 1800H contents: pattern name table

F3C9H GRPCOL initial value: 2000H contents: color table

F3CBH GRPCGP initial value: 0000H contents: pattern generator table

F3CDH GRPATR initial value: 1B00H contents: sprite attribute table

F3CFH GRPPAT initial value: 3800H contents: sprite generator table
Screen 3 F3D1H MLTNAM initial value: 0800H contents: pattern name table

F3D3H MLTCOL contents: unused

F3D5H MLTCGP initial value: 0000H contents: pattern generator table

F3D7H MLTATR initial value: 1B00H contents: sprite attribute table

F3D9H MLTPAT initial value: 3800H contents: sprite generator table
Screen Extra F3DBH CLIKSW initial value: 1 contents: key click switch 0 = OFF, otherwise = ON , set by <key click switch> of SCREEN statement

F3DCH CSRY initial value: 1 contents: Y-coordinate of cursor

F3DDH CSRX initial value: 1 contents: X-coordinate of cursor

F3DEH CNSDFG initial value: 0 contents: function key display switch 0 = display, otherwise = no display , set by KEY ON/OFF statement
VDP bak F3DFH RG0SAV initial value: 0

F3E0H RG1SAV initial value: E0H

F3E1H RG2SAV initial value: 0

F3E2H RG3SAV initial value: 0

F3E3H RG4SAV initial value: 0

F3E4H RG5SAV initial value: 0

F3E5H RG6SAV initial value: 0

F3E6H RG7SAV initial value: 0

F3E7H STATFL initial value: 0 contents: stores VDP status contents of status register 0, in MSX2

F3E8H TRGFLG initial value: FFH contents: stores trigger button status of joystick

F3E9H FORCLR initial value: 15 contents: foreground color; set by color statement

F3EAH BAKCLR initial value: 4 contents: background color; set by color statement

F3EBH BDRCLR initial value: 7 contents: border color; set by color statement

F3ECH MAXUPD initial value: JP 0000H C3H, 00H, 00H contents: used by CIRCLE statement internally

F3EFH MINUPD initial value: JP 0000H C3H, 00H, 00H contents: used by CIRCLE statement internally

F3F2H ATRBYT initial value: 15 contents: color code in using graphics
PLAY F3F3H QUEUES initial value: QUETAB F959H contents: points to queue table at the execution of PLAY statement

F3F5H FRCNEW , 1 initial value: 255 contents: used by BASIC interpreter internally
Key Input F3F6H SCNCNT initial value: 1 contents: interval for the key scan

F3F7H REPCNT initial value: 50 contents: delay until the auto-repeat of the key begins

F3F8H PUTPNT initial value: KEYBUF FBF0H contents: points to address to write in the key buffer

F3FAH GETPNT initial value: KEYBUF FBF0H contents: points to address to read from key buffer
Casette F3FCH CS120 - 1200 baud contents: 83 LOW01 ............ Low width representing bit 0

F406H LOW initial value: LOW01, HIGH01 by default, 1200 baud contents: width of LOW and HIGH which represents bit 0 of current baud rate; set by <cassette baud rate> of SCREEN statement

F408H HIGH initial value: LOW11, HIGH11 by default, 1200 baud contents: width of LOW and HIGH which represents bit 1 of current baud rate; set by <cassette baud rate> of SCREEN statement

F40AH HEADER initial value: HEADLEN * 2/256 by default, 1200 baud contents: header bit for the short header of current baud rate HEADLEN = 2000

F40BH ASPCT1 contents: 256/aspect ratio; set by SCREEN statement to use in CIRCLE statement

F40DH ASPCT2 contents: 256 * aspect ratio; set by SCREEN statement to use in CIRCLE statement

F40FH ENDPRG initial value: ":" contents: false end of program for RESUME NEXT statement
BASIC F414H ERRFLG area to store the error number

F415H LPTPOS initial value: 0 contents: printer head location

F416H PRTFLG flag whether to send to printer

F417H NTMSXP printer 0 = printer for MSX, otherwise not

F418H RAWPRT non-zero when printing in raw-mode

F419H VLZADR address of character to be replaced by VAL function

F41BH VLZDAT character to be replaced with 0 by VAL function

F41CH CURLIN currently executing line number of BASIC

F41FH KBUF crunch buffer; translated into intermediate language from BUF F55EH

F55DH BUFMIN initial value: "," contents: used in INPUT statement

F55EH BUF buffer to store characters typed; where direct statements are stored in ASCII code

F660H ENDBUF prevents overflow of BUF F55EH

F661H TTYPOS virtual cursor location internally retained by BASIC

F662H DIMFLG used by BASIC internally

F663H VALTYP used to identify the type of variable

F664H DORES indicates whether stored word can be crunched

F665H DONUM flag for crunch

F666H CONTXT stores text address used by CHRGET

F668H CONSAV stores token of constant after calling CHRGET

F669H CONTYP type of stored constant

F66AH CONLO value of stored constant

F672H MEMSIZ highest address of memory used by BASIC

F674H STKTOP address used as stack by BASIC; depending on CLEAR statement

F676H TXTTAB starting address of BASIC text area

F768H TEMPPT initial value: TEMPST F67AH contents: starting address of unused area of temporary descriptor

F67AH TEMPST area for NUMTEMP

F698H DSCTMP string descriptor which is the result of string function

F69BH FRETOP starting address of unused area of string area

F69DH TEMP3 used for garbage collection or by USR function

F69FH TEMP8 for garbage collection

F6A1H ENDFOR stores next address of FOR statement to begin execution from the next of FOR statement at loops

F6A3H DATLIN line number of DATA statement read by READ statement

F6A5H SUBFLG flag for array for USR function

F6A6H FLGINP flag used in INPUT or READ

F6A7H TEMP location for temporary reservation for statement code; used for variable pointer, text address, and others

F6A9H PTRFLG 0 if there is not a line number to be converted,otherwise not

F6AAH AUTFLG flag for AUTO command validity non-zero = valid, otherwise invalid

F6ABH AUTLIN last input line number

F6ADH AUTINC initial value: 10 contents: increment value of line number of AUTO command

F6AFH SAVTXT area to store address of currently executing text; mainly used for error recovery by RESUME statement

F6B3H ERRLIN line number where an error occurred

F6B5H DOT last line number which was displayed in screen or entered

F6B7H ERRTXT text address which caused an error; mainly used for error recovery by RESUME statement

F6B9H ONELIN text address to which control jumps at error; set by ON ERROR GOTO statement

F6BBH ONEFLG flag which indicates error routine execution non-zero = in execution, otherwise not

F6BCH TEMP2 for temporary storage

F6BEH OLDLIN line number which was terminated by Ctrl+STOP, STOP instruction, END instruction, or was executed last

F6C0H OLDTXT address to be executed next

F6C2H VARTAB starting address of simple variable; executing NEW statement causes [contents of TXTTAB(F676H + 2] to be set

F6C4H ARYTAB starting address of array table

F6C6H STREND last address of memory in use as text area or variable area

F6C8H DATPTR text address of data read by executing READ statement

F6CAH DEFTBL area to store type of variable for one alphabetical character; depends on type declaration such as CLEAR, DEFSTR,!, or #
User Func F6E4H PRMSTK previous definition block on stack for garbage collection

F6E6H PRMLEN number of bytes of objective data

F6E8H PARM1 objective parameter definition table; PRMSIZ is number of bytes of definition block, initial value is 100

F74CH PRMPRV initial value: PRMSTK contents: pointer to previous parameter block for garbage collection

F74EH PRMLN2 size of parameter block

F750H PARM2 for parameter storage

F7B4H PRMFLG flag to indicate whether PARM1 was searched

F7B5H ARYTA2 end point of search

F7B7H NOFUNS 0 if there is not an objective function

F7B8H TEMP9 location of temporary storage for garbage collection

F7BAH FUNACT number of objective functions

F7BCH SWPTMP location of temporary storage of the value of the first variable of SWAP statement

F7C4H TRCFLG trace flag non-zero = TRACE ON, 0 = TRACE OFF
Math Pack F7C5H FBUFFR used internally by Math-Pack

F7F0H DECTMP used to transform decimal integer to floating-point number

F7F2H DECTM2 used at division routine execution

F7F4H DECCNT used at division routine execution

F7F6H DAC area to set the value to be calculated

F806H HOLD8 register storage area for decimal multiplication

F836H HOLD2 used internally by Math-Pack

F83EH HOLD used internally by Math-Pack

F847H ARG area to set the value to be calculated with DAC F7F6H

F857H RNDX stores last random number in double precision real number; set by RND function
Basic Interpreter F85FH MAXFIL maximum file number; set by MAXFILES statement

F860H FILTAB starting address of file data area

F862H NULBUF points to buffer used in SAVE and LOAD by BASIC interpreter

F864H PTRFIL address of file data of currently accessing file

F866H RUNFLG non-zero value if program was loaded and executed; used by R option of LOAD statement

F866H FILNAM area to store filename

F871H FILNM2 area to store filename

F87CH NLONLY non-zero value if program is being loaded

F87DH SAVEND end address of assembly language program to be saved

F87FH FNKSTR area to store function key string 16 character x 10

F91FH CGPNT address to store character font on ROM

F922H NAMBAS base address of current pattern name table

F924H CGPBAS base address of current pattern generator table

F926H PATBAS base address of current sprite generator table

F928H ATRBAS base address of current sprite attribute table

F92AH CLOC used internally by graphic routine

F92CH CMASK used internally by graphic routine

F92DH MINDEL used internally by graphic routine

F92FH MAXDEL used internally by graphic routine
Basic Circle F931H ASPECT aspect ratio of the circle; set by <ratio> of CIRCLE statement

F933H CENCNT used internally by CIRCLE statement

F935H CLINEF flag whether a line is drawn toward the center; specified by <angle> of CIRCLE statement

F936H CNPNTS point to be plotted

F938H CPLOTF used internally by CIRCLE statement

F939H CPCNT number of one eight of the circle

F93BH CPNCNT8 used internally by CIRCLE statement

F93DH CPCSUM used internally by CIRCLE statement

F93FH CSTCNT used internally by CIRCLE statement

F941H CSCLXY scale of x and y

F942H CSAVEA reservation area of ADVGRP

F944H CSAVEM reservation area of ADVGRP

F945H CXOFF x offset from the center

F947H CYOFF y offset from the center
Basic Paint F949H LOHMSK used internally by PAINT statement

F94AH LOHDIR used internally by PAINT statement

F94BH LOHADR used internally by PAINT statement

F94DH LOHCNT used internally by PAINT statement

F94FH SKPCNT skip count

F951H MIVCNT movement count

F953H PDIREC direction of the paint

F954H LFPROG used internally by PAINT statement

F955H RTPROG used internally by PAINT statement
Basic Play F956H MCLTAB points to the top of the table of PLAY macro or DRAW macro

F958H MCLFLG assignment of PLAY/DRAW

F959H QUETAB queue table

F971H QUEBAK used in BCKQ

F975H VOICAQ queue of voice 1 (A)

F9F5H VOICBQ queue of voice 2 (B)

FA75H VOICCQ queue of voice 3 �

FAF5H DPPAGE display page number

FAF6H ACPAGE active page number

FAF7H AVCSAV reserves AV control port

FAF8H EXBRSA SUB-ROM slot address

FAF9H CHRCNT character counter in the buffer; used in Roman-kana translation value is 0 <=n <=2

FAFAH ROMA area to store character in the buffer; used in Roman-kana translation Japan version only

FAFCH MODE mode switch for VRAM size

FAFDH NORUSE unused

FAFEH XSAVE [ I OOOOOOO XXXXXXXX ]

FB00H YSAVE [ x OOOOOOO YYYYYYYY ]

FB02H LOGOPR logical operation code

FB03H RSTMP work area for RS-232C or disk

FB03H TOCNT used internally by RS-232C routine

FB04H RSFCB FB04H + 0: LOW address of RS-232C FB04H + 1: HIGH address of RS-232C

FB06H RSIQLN used internally by RS-232C routine

FB07H MEXBIH FB07H +0: RST 30H 0F7H

FB0CH OLDSTT FB0CH +0: RST 30H 0F7H

FB12H OLDINT FB12H +0: RST 30H 0F7H

FB17H DEVNUM used internally by RS-232C routine

FB18H DATCNT FB18H +0: byte data

FB1BH ERRORS used internally by RS-232C routine

FB1CH FLAGS used internally by RS-232C routine

FB1DH ESTBLS used internally by RS-232C routine

FB1EH COMMSK used internally by RS-232C routine

FB1FH LSTCOM used internally by RS-232C routine

FB20H LSTMOD used internally by RS-232C routine
DOS FB21H to FB34H reserved used by DOS
PLAY FB35H PRSCNT D1 to D0 string parse D7 = 0 1 pass

FB36H SAVSP reserves stack pointer in play

FB38H VOICEN current interpreted voice

FB39H SAVVOL reserves volume for the pause

FB3BH MCLLEN used internally by PLAY statement

FB3CH MCLPTR used internally by PLAY statement

FB3EH QUEUEN used internally by PLAY statement

FC3FH MUSICF interrupt flag for playing music

FB40H PLYCNT number of PLAY statements stored in the queue
Voice FB41H VCBA static data for voice 0

FB66H VCBB static data for voice 1

FB8BH VCBC static data for voice 2
Data FBB0H ENSTOP flag to enable warm start by [SHIFT+Ctrl+Kana key] 0 = disable, otherwise enable

FBB1H BASROM indicates BASIC text location 0 = on RAM, otherwise in ROM

FBB2H LINTTB line terminal table; area to keep information about each line of text screen

FBCAH FSTPOS first character location of line from INLIN 00B1H of BIOS

FBCCH CODSAV area to reserve the character where the cursor is stacked

FBCDH FNKSW1 indicates which function key is displayed at KEY ON

FBCEH FNKFLG contents: area to allow, inhibit, or stop the execution of the line defined in ON KEY GOSUB statement, or to reserve it for each function key; set by KEY(n ON/OFF/STOP statement

FBD8H ONGSBF flag to indicate whether event waiting in TRPTBL FC4CH occurred

FBD9H CLIKFL key click flag

FBDAH OLDKEY key matrix status old

FBE5H NEWKEY key matrix status new

FBF0H KEYBUF key code buffer

FC18H LINWRK temporary reservation location used by screen handler

FC40H PATWRK temporary reservation location used by pattern converter

FC48H BOTTOM installed RAM starting low address; ordinarily 8000H in MSX2

FC4AH HIMEM highest address of available memory; set by <memory upper limit> of CLEAR statement

FC4CH TRAPTBL trap table used to handle interrupt; one table consists of three bytes, where first byte indicates ON/OFF/STOP status and the rest indicate the text address to be jumped to

FC9AH RTYCNT used internally by BASIC

FC9BH INTFLG if Ctrl+STOP is pressed, setting 03H here causes a stop

FC9CH PADY Y-coordinate of the paddle

FC9DH PADX X-coordinate of the paddle

FC9EH JIFFY used internally by PLAY statement

FCA0H INTVAL interval period; set by ON INTERVAL GOSUB statement

FCA2H INTCNT counter for interval

FCA4H LOWLIM used during reading from cassette tape

FCA5H WINWID used during reading from cassette tape

FCA6H GRPHED flag to send graphic character 1 = graphic character, 0 = normal character

FCA7H ESCCNT area to count from escape code

FCA8H INSFLG flag to indicate insert mode 0 = normal mode, otherwise = insert mode

FCA9H CSRSW whether cursor is displayed 0 = no, otherwise = yes ; set by <cursor swicth> of LOCATE statement

FCAAH CSTYLE cursor shape 0 = block, otherwise = underline

FCABH CAPST CAPS key status 0 = CAP OFF, otherwise = CAP ON

FCACH KANAST kana key status 0 = kaka OFF, otherwise = kana ON

FCADH KANAMD kana key arrangement status 0 = 50-sound arrangement, otherwise = JIS arrangement

FCAEH FLBMEM 0 when loading BASIC program

FCAFH SCRMOD current screen mode number

FCB0H OLDSCR screen mode reservation area

FCB1H CASPRV character reservation area used by CAS:

FCB2H BRDATR border color code used by PAINT; set by <border color> in PAINT statement

FCB3H GXPOS X-coordinate

FCB5H GYPOS Y-coordinate

FCB7H GRPACX graphic accumulator X-coordinate

FCB9H GRPACY graphic accumulator Y-coordinate

FCBBH DRWFLG flag used in DRAW statement

FCBCH DRWSCL DRAW scaling factor 0 = no scaling, otherwise = scaling

FCBDH DRWANG angle at DRAW

FCBEH RUNBNF flag to indicate BLOAD in progress, BSAVE in progress, or neither

FCBFH SAVENT starting address of BSAVE

FCC1H EXPTBL flag table for expansion slot; whether the slot is expanded

FCC1H * EXPTBL ........... whether the basic slot is expanded or not [FCC1H-FCC4H = bit 7= expanded or not

FCC5H SLTTBL current slot selection status for each expansion slot register

FCC9H SLTATR reserves attribute for each slot

FD09H SLTWRK allocates specific work area for each slot

FD89H PROCNM stores name of expanded statement after CALL statement or expansion device after CALL statement or expansion device

FD99H DEVICE used to identify cartridge device

FD9AH H.KEYI beginning of MSXIO interrupt handling purpose: adds the interrupt operation such as RS-232C

FD9FH H.TIMI MSXIO timer interrupt handling purpose: adds the timer interrupt handling

FDA4H H.CHPH beginning of MSXIO CHPUT one character output purpose: connects other console device

FDA9H H.DSPC beginning of MSXIO DSPCSR cursor display purpose: connects other console device

FDAEH H.ERAC beginning of MSXIO ERACSR erase cursor purpose: connects other console device

FDB3H H.DSPF beginning of MSXIO DSPFNK function key display purpose: connects other console device

FDB8H H.ERAF beginning of MSXIO ERAFNK erase function key purpose: connects other console device

FDBDH H.TOTE beginning of MSXIO TOTEXT set screen in text mode purpose: connects other console device

FDC2H H.CHGE beginning of MSXIO CHGET get one character purpose: connects other console device

FDC7H H.INIP beginning of MSXIO INIPAT character pattern initialisation purpose: uses other character set

FDCCH H.KEYC beginning of MSXIO KEYCOD key code translation purpose: uses other key arrangement

FDD1H H.KYEA beginning of MSXIO NMI routine Key Easy purpose: uses other key arrangement

FDD6H H.NMI beginning of MSXIO NMI non-maskable interrupt purpose: handles NMI

FDDBH H.PINL beginning of MSXIO PINLIN one line input purpose: uses other console input device or other input method

FDE0H H.QINL beginning of MSXINL QINLIN one line input displaying "?" purpose: uses other console input device or other input method

FDE5H H.INLI beginning of MSXINL INLIN one line input purpose: uses other console input device or other input method

FDEAH H.ONGO beginning of MSXSTS INGOTP ON GOTO purpose: uses other interrupt handling device

FDEFH H.DSKO beginning of MSXSTS DSKO$ disk output purpose: connects disk device

FDF4H H.SETS beginning of MSXSTS SETS set attribute purpose: connects disk device

FDF9H H.NAME beginning of MSXSTS NAME rename purpose: connects disk device

FDFEH H.KILL beginning of MSXSTS KILL delete file purpose: connects disk device

FE03H H.IPL beginning of MSXSTS IPL initial program loading purpose: connects disk device

FE08H H.COPY beginning of MSXSTS COPY file copy purpose: connects disk device

FE0DH H.CMD beginning of MSXSTS CMD expanded command purpose: connects disk device

FE12H H.DSKF beginning of MSXSTS DSKF unusde disk space purpose: connects disk device

FE17H H.DSKI beginning of MSXSTS DSKI disk input purpose: connects disk device

FE1CH H.ATTR beginning of MSXSTS ATTR$ attribute purpose: connects disk device

FE21H H.LSET beginning of MSXSTS LSET left-padded assignment purpose: connects disk device

FE26H H.RSET beginning of MSXSTS RSET right-padded assignment purpose: connects disk device

FE2BH H.FIEL beginning of MSXSTS FIELD field purpose: connects disk device

FE30H H.MKI$ beginning of MSXSTS MKI$ create integer purpose: connects disk device

FE35H H.MKS$ beginning of MSXSTS MKS$ create single precision real purpose: connects disk device

FE3AH H.MKD$ beginning of MSXSTS MKD$ create double precision real purpose: connects disk device

FE3FH H.CVI beginning of MSXSTS CVI convert integer purpose: connects disk device

FE44H H.CVS beginning of MSXSTS CVS convert single precision real purpose: connects disk device

FE49H H.CVD beginning of MSXSTS CVS convert double precision real purpose: connects disk device

FE4EH H.GETP SPDSK GETPTR get file pointer purpose: connects disk device

FE53H H.SETF SPCDSK SETFIL set file pointer purpose: connects disk device

FE58H H.NOFO SPDSK NOFOR OPEN statement without FOR purpose: connects disk device

FE5DH H.NULO SPCDSK NULOPN open unused file purpose: connects disk device

FE62H H.NTFL SPCDSK NTFLO file number is not 0 purpose: connects disk device

FE67H H.MERG SPCDSK MERGE program file merge purpose: connects disk device

FE6CH H.SAVE SPCDSK SAVE save purpose: connects disk device

FE71H H.BINS SPCDSK BINSAV save in binary purpose: connects disk device

FE76H H.BINL SPCDSK BINLOD load in binary purpose: connects disk device

FD7BH H.FILE SPCDSK FILES displey filename purpose: connects disk device

FE80H H.DGET SPCDSK DGET disk GET purpose: connects disk device

FE85H H.FILO SPCDSK FILOU1 file output purpose: connects disk device

FE8AH H.INDS SPCDSK INDSKC disk attribute input purpose: connects disk device

FE8FH H.RSLF SPCDSK; re-select previous drive purpose: connects disk device

FE94H H.SAVD SPCDSK; reserve current disk purpose: connects disk device

FE99H H.LOC SPCDSK LOC function indicate location purpose: connects disk device

FE9EH H.LOF SPCDSK LOC function file length purpose: connects disk device

FEA3H H.EOF SPCDSK EOF function end of file purpose: connects disk device

FEA8H H.FPOS SPCDSK FPOS function file location purpose: connects disk device

FEADH H.BAKU SPCDSK BAKUPT backup purpose: connects disk device

FEB2H H.PARD SPCDEV PARDEV get peripheral name purpose: expands logical device name

FEB7H H.NODE SPCDEV NODEVN no device name purpose: sets default device name to other device

FEBCH H.POSD SPCDEV POSDSK purpose: connects disk device

FEC1H H.DEVN SPCDEV DEVNAM process device name purpose: expands logical device name

FEC6H H.GEND SPCDEV GENDSP FEC6H purpose: expands logical device name

FECBH H.RUNC BIMISC RUNC clear for RUN

FED0H H.CLEAR BIMISC CLEARC clear for CLEAR statement

FED5H H.LOPD BIMISC LOPDFT set loop and default value purpose: uses other default value for variable

FEDAH H.STKE BIMISC STKERR stack error

FEDFH H.ISFL BIMISC ISFLIO file input-output or not

FEE4H H.OUTD meaning: BIO OUTDO execute OUT

FEE9H H.CRDO BIO CRDO execute CRLF

FEEEH H.DSKC BIO DSKCHI input disk attribute

FEF3H H.DOGR GENGRP DOGRPH execute graphic operation

FEF8H H.PRGE BINTRP PRGEND program end

FEFDH H.ERRP BINTRP ERRPTR error display

FF02H H.ERRF BINTRP

FF07H H.READ BINTRP READY

FF0CH H.MAIN BINTRP MAIN

FF11H H.DIRD BINTRP DIRDO execute direct statement

FF16H H.FINI BINTRP

FF1BH H.FINE BINTRP

FF20H H.CRUN BINTRP

FF20H H.CRUN BINTRP

FF25H H.CRUS BINTRP

FF2AH H.ISRE BINTRP

FF2FH H.NTFN BINTRP

FF34H H.NOTR BINTRP

FF39H H.SNGF BINTRP

FF3EH H.NEWS BINTRP

FF43H H.GONE BINTRP

FF48H H.CHRG BINTRP

FF4DH H.RETU BINTRP

FF52H H.PRTF BINTRP

FF57H H.COMP BINTRP

FF5CH H.FINP BINTRP

FF61H H.TRMN BINTRP

FF66H H.FRME BINTRP

FF6BH H.NTPL BINTRP

FF70H H.EVAL BINTRP

FF75H H.OKNO BINTRP

FF7AH H.FING BINTRP

FF7FH H.ISMI BINTRP ISMID$ MID$ or not

FF84H H.WIDT BINTRP WIDTHS WIDTH

FF89H H.LIST BINTRP LIST

FF8EH H.BUFL BINTRP BUFLIN buffer line

FF93H H.FRQI BINTRP FRQINT

FF98H H.SCNE BINTRP

FF9DH H.FRET BINTRP FRETMP

FFA2H H.PTRG BIPTRG PTRGET get pointer purpose: uses variable other than default value

FFA7H H.PHYD MSXIO PHYDIO physical disk input-output purpose: connects disk device

FFACH H.FORM MSXIO FORMAT format disk purpose: connects disk device

FFB1H H.ERRO BINTRP ERROR purpose: error handling for application program

FFB6H H.LPTO MSXIO LPTOUT printer output purpose: uses printer other than default value

FFBBH H.LPTS MSXIO LPTSTT printer status purpose: uses printer other than default value

FFC0H H.SCRE MSXSTS SCREEN statement entry purpose: expands SCREEN statement

FFC5H H.PLAY MSXSTS PLAY statement entry purpose: expands PLAY statement

FFCAH FCALL hook used by expanded BIOS

FFCFH DISINT used by DOS

FFD4H ENAINT used by DOS

Cartridge Header

Address Bytes Purpose Detail Sample
&0000 2 ID Fixed AB
&0002 2 INIT Start Address &4010
&0004 2 STATEMENT Call address &0000
&0006 2 DEVICE Dev address &0000
&0008 2 TEXT Basic Address &0000
&0010
Program Code�


Disk File Header

Position Bytes Content Details Example
&0000 1 &FE Magic Number &FE
&0001 2 Load address Address to load into memory &810A
&0003 2 End Address Last address in memory (Load address+Size) &910A
&0005 2 Execute Address Address to call program &810A
&0007 Program Code


MSX and MSX2 Programming Tutorials:

Lesson P5 - Bitmap graphics on the TI-83 and MSX
Lesson P7 - Keyreading on the MSX, Enterprise and TI-83
Lesson P10 - Tilemap graphics on the MSX1
Lesson P11 - Tilemap graphics on the MSX2

General Z80 Assembly Tutorials:
B. Beginner series - Learn the basics
A. Advanced series - In more detail
M. Multiplatform series - programming methods that work on all systems


MSX and MSX2 Links:

OpenMSX - The best MSX emulator - you'll need to find your own roms for disk system emulaton (For disk images I reccomend emulating the hb-f1xdj)
Grauw.nl
- great resources and samplecode for MSX development
MSX2 Technical Handbook - full breakdown of the MSX2 hardware - all the info you will need for development purposes
Basic Manual - You'll want to know at least enough basic to do calls and operate the computer
V9938 Programmer?s Guide - Detailed manual on programming the MSX2 V9938 GPU
MSX.Org
- Web community full of helpful people!