MSX System Variables
This is an overview of the system variables which you can use. They are official, unless mentioned otherwise.
VDP Registers: R#0-R#7, R#8-R#23, R#25-R#27, R#32-R#45 (not mirrored in system ram), S#0.
MSX System Variables located in Main ROM
| Name | Address | Length | Description |
|---|---|---|---|
| CGTABL | #0004 | 2 | Base address of the MSX character set in ROM |
| VDP.DR | #0006 | 1 | Base port address for VDP data read |
| VDP.DW | #0007 | 1 | Base port address for VDP data write |
| #002B | 1 | Basic ROM version
7 6 5 4 3 2 1 0
| | | | +-+-+-+-- Character set
| | | | 0 = Japanese, 1 = International, 2=Korean
| +-+-+---------- Date format
| 0 = Y-M-D, 1 = M-D-Y, 2 = D-M-Y
+---------------- Default interrupt frequency
0 = 60Hz, 1 = 50Hz
|
|
| #002C | 1 | Basic ROM version
7 6 5 4 3 2 1 0
| | | | +-+-+-+-- Keyboard type
| | | | 0 = Japanese, 1 = International
| | | | 2 = French (AZERTY), 3 = UK, 4 = German (DIN)
+-+-+-+---------- Basic version
0 = Japanese, 1 = International
|
|
| #002D | 1 | MSX version number 0 = MSX 1 1 = MSX 2 2 = MSX 2+ 3 = MSX turbo R |
|
| #002E | 1 | Bit 0: if 1 then MSX-MIDI is present internally (MSX turbo R only) | |
| #002F | 1 | Reserved |
MSX System Variables located in Sub ROM
| Name | Address | Length | Description |
|---|---|---|---|
| #0000 | 2 | String "CD", identification of MSX Sub ROM | |
| #0002 | 2 | Execution address for the startup screen on MSX 2, MSX 2+ or MSX turbo R. This is unofficial and undocumented. |
MSX-DOS (DiskROM) System Variables located in RAM
These addresses are only initialized when a DiskROM is present (e.g. when the machine has a diskdrive or a harddisk interface connected).
| Name | Address | Length | Description |
|---|---|---|---|
| RAMAD0 | #F341 | 1 | Slot address of RAM in page 0 (DOS) |
| RAMAD1 | #F342 | 1 | Slot address of RAM in page 1 (DOS) |
| RAMAD2 | #F343 | 1 | Slot address of RAM in page 2 (DOS/BASIC) |
| RAMAD3 | #F344 | 1 | Slot address of RAM in page 3 (DOS/BASIC) |
| #F348 | 1 | Slot address of the main DiskROM |
MSX System Variables located in RAM
This is the start of the MSX BIOS system area.
| Name | Address | Length | Description |
|---|---|---|---|
| RDPRIM | #F380 | 5 | Routine that reads from a primary slot |
| WRPRIM | #F385 | 7 | Routine that writes to a primary slot |
| CLPRIM | #F38C | 14 | Routine that calls a routine in a primary slot |
| USRTAB | #F39A | 2 | Address to call with Basic USR0 |
| #F39C | 2 | Address to call with Basic USR1 | |
| #F39E | 2 | Address to call with Basic USR2 | |
| #F3A0 | 2 | Address to call with Basic USR3 | |
| #F3A2 | 2 | Address to call with Basic USR4 | |
| #F3A4 | 2 | Address to call with Basic USR5 | |
| #F3A6 | 2 | Address to call with Basic USR6 | |
| #F3A8 | 2 | Address to call with Basic USR7 | |
| #F3AA | 2 | Address to call with Basic USR8 | |
| #F3AC | 2 | Address to call with Basic USR9 | |
| LINL40 | #F3AE | 1 | Width for SCREEN 0 (default 37) |
| LINL32 | #F3AF | 1 | Width for SCREEN 1 (default 29) |
| LINLEN | #F3B0 | 1 | Width for the current text mode |
| CRTCNT | #F3B1 | 1 | Number of lines on screen |
| CLMLST | #F3B2 | 1 | Column space. It’s uncertain what this address actually stores |
| TXTNAM | #F3B3 | 2 | BASE(0) - SCREEN 0 name table |
| TXTCOL | #F3B5 | 2 | BASE(1) - SCREEN 0 color table |
| TXTCGP | #F3B7 | 2 | BASE(2) - SCREEN 0 character pattern table |
| TXTATR | #F3B9 | 2 | BASE(3) - SCREEN 0 Sprite Attribute Table |
| TXTPAT | #F3BB | 2 | BASE(4) - SCREEN 0 Sprite Pattern Table |
| T32NAM | #F3B3 | 2 | BASE(5) - SCREEN 1 name table |
| T32COL | #F3B5 | 2 | BASE(6) - SCREEN 1 color table |
| T32CGP | #F3B7 | 2 | BASE(7) - SCREEN 1 character pattern table |
| T32ATR | #F3B9 | 2 | BASE(8) - SCREEN 1 sprite attribute table |
| T32PAT | #F3BB | 2 | BASE(9) - SCREEN 1 sprite pattern table |
| GRPNAM | #F3B3 | 2 | BASE(10) - SCREEN 2 name table |
| GRPCOL | #F3B5 | 2 | BASE(11) - SCREEN 2 color table |
| GRPCGP | #F3B7 | 2 | BASE(12) - SCREEN 2 character pattern table |
| GRPATR | #F3B9 | 2 | BASE(13) - SCREEN 2 sprite attribute table |
| GRPPAT | #F3BB | 2 | BASE(14) - SCREEN 2 sprite pattern table |
| MLTNAM | #F3B3 | 2 | BASE(15) - SCREEN 3 name table |
| MLTCOL | #F3B5 | 2 | BASE(16) - SCREEN 3 color table |
| MLTCGP | #F3B7 | 2 | BASE(17) - SCREEN 3 character pattern table |
| MLTATR | #F3B9 | 2 | BASE(18) - SCREEN 3 sprite attribute table |
| MLTPAT | #F3BB | 2 | BASE(19) - SCREEN 3 sprite pattern table |
| CLIKSW | #F3DB | 1 | =0 when key press click disabled =1 when key press click enabled SCREEN ,,n will write to this address |
| CSRY | #F3DC | 1 | Current row-position of the cursor |
| CSRX | #F3DD | 1 | Current column-position of the cursor |
| CNSDFG | #F3DE | 1 | =0 when function keys are not displayed =1 when function keys are displayed |
| RG0SAV | #F3DF | 1 | Content of VDP(0) register (R#0) |
| RG1SAV | #F3E0 | 1 | Content of VDP(1) register (R#1) |
| RG2SAV | #F3E1 | 1 | Content of VDP(2) register (R#2) |
| RG3SAV | #F3E2 | 1 | Content of VDP(3) register (R#3) |
| RG4SAV | #F3E3 | 1 | Content of VDP(4) register (R#4) |
| RG5SAV | #F3E4 | 1 | Content of VDP(5) register (R#5) |
| RG6SAV | #F3E5 | 1 | Content of VDP(6) register (R#6) |
| RG7SAV | #F3E6 | 1 | Content of VDP(7) register (R#7) |
| STATFL | #F3E7 | 1 | Content of VDP(8) status register (S#0) |
| TRGFLG | #F3E8 | 1 | Information about trigger buttons and space bar state
7 6 5 4 3 2 1 0 | | | | +-- Space bar, trig(0) (0 = pressed) | | | +---------- Stick 1, Trigger 1 (0 = pressed) | | +------------ Stick 1, Trigger 2 (0 = pressed) | +-------------- Stick 2, Trigger 1 (0 = pressed) +---------------- Stick 2, Trigger 2 (0 = pressed) |
| FORCLR | #F3E9 | 1 | Foreground color |
| BAKCLR | #F3EA | 1 | Background color |
| BDRCLR | #F3EB | 1 | Border color |
| MAXUPD | #F3EC | 3 | Jump instruction used by Basic LINE command. The routines used are: RIGHTC, LEFTC, UPC and DOWNC |
| MINUPD | #F3EF | 3 | Jump instruction used by Basic LINE command. The routines used are: RIGHTC, LEFTC, UPC and DOWNC |
| ATRBYT | #F3F2 | 1 | Attribute byte (for graphical routines it’s used to read the color) |
| QUEUES | #F3F3 | 2 | Address of the queue table |
| FRCNEW | #F3F5 | 1 | CLOAD flag =0 when CLOAD =255 when CLOAD? |
| SCNCNT | #F3F6 | 1 | Key scan timing When it’s zero, the key scan routine will scan for pressed keys so characters can be written to the keyboard buffer |
| REPCNT | #F3F7 | 1 | This is the key repeat delay counter When it reaches zero, the key will repeat |
| PUTPNT | #F3F8 | 2 | Address in the keyboard buffer where a character will be written |
| GETPNT | #F3FA | 2 | Address in the keyboard buffer where the next character is read |
| CS120 | #F3FC | 5 | Cassette I/O parameters to use for 1200 baud |
| CS240 | #F401 | 5 | Cassette I/O parameters to use for 2400 baud |
| LOW | #F406 | 2 | Signal delay when writing a 0 to tape |
| HIGH | #F408 | 2 | Signal delay when writing a 1 to tape |
| HEADER | #F40A | 1 | Delay of tape header (sync.) block |
| ASPCT1 | #F40B | 2 | Horizontal / Vertical aspect for CIRCLE command |
| ASPCT2 | #F40D | 2 | Horizontal / Vertical aspect for CIRCLE command |
| ENDPRG | #F40F | 5 | Pointer for the RESUME NEXT command |
| ERRFLG | #F414 | 1 | Basic Error code |
| LPTPOS | #F415 | 1 | Position of the printer head Is read by Basic function LPOS and used by LPRINT Basic command |
| PRTFLG | #F416 | 1 | Printer output flag is read by
OUTDO =0 to print to screen =1 to print to printer |
| NTMSXP | #F417 | 1 | Printer type is read by
OUTDO.
SCREEN ,,,n writes to this address =0 for MSX printer =1 for non-MSX printer |
| RAWPRT | #F418 | 1 | Raw printer output is read by
OUTDO =0 to convert tabs and unknown characters to spaces and remove graphical headers =1 to send data just like it gets it |
| VLZADR | #F419 | 2 | Address of data that is temporarilly replaced by ‘O’ when Basic function VAL("") is running |
| VLZDAT | #F41B | 1 | Original value that was in the address pointed to with VLZADR |
| CURLIN | #F41C | 2 | Line number the Basic interpreter is working on, in direct mode it will be filled with #FFFF |
| #F91F | 1 | Character set SlotID | |
| #F920 | 2 | Character set address | |
| EXBRSA | #FAF8 | 1 | Slot address of the SUBROM (EXtended Bios-Rom Slot Address) |
| DRVINF | #FB21 | 1 | Nr. of drives connected to disk interface 1 |
| #FB22 | 1 | Slot address of disk interface 1 | |
| #FB23 | 1 | Nr. of drives connected to disk interface 2 | |
| #FB24 | 1 | Slot address of disk interface 2 | |
| #FB25 | 1 | Nr. of drives connected to disk interface 3 | |
| #FB26 | 1 | Slot address of disk interface 3 | |
| #FB27 | 1 | Nr. of drives connected to disk interface 4 | |
| #FB28 | 1 | Slot address of disk interface 4 | |
| EXPTBL | #FCC1 | 1 | Slot 0: #80 = expanded, 0 = not expanded. Also slot address of the main BIOS-ROM. |
| #FCC2 | 1 | Slot 1: #80 = expanded, 0 = not expanded. | |
| #FCC3 | 1 | Slot 2: #80 = expanded, 0 = not expanded. | |
| #FCC4 | 1 | Slot 3: #80 = expanded, 0 = not expanded. | |
| SLTTBL | #FCC5 | 1 | Mirror of slot 0 secondary slot selection register. |
| #FCC6 | 1 | Mirror of slot 1 secondary slot selection register. | |
| #FCC7 | 1 | Mirror of slot 2 secondary slot selection register. | |
| #FCC8 | 1 | Mirror of slot 3 secondary slot selection register. | |
| #FFFF (all slots) | 1 | Secondary slot select register. Reading returns the inverted previously written value. |