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 | |
| CHAR_16 | #0034 | 4 | Default KANJI range. Copied to KANJTABLE by the DiskBIOS on boot. |
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 |
|---|---|---|---|
| KANJTABLE | #F30F | 4 | Two pairs of limits for the first bytes of Shift-JIS characters. See here and here for more information. |
| 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) |
| MASTER | #F348 | 1 | Main DiskROM slot address |
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 | #F3BD | 2 | BASE(5) - SCREEN 1 name table | ||||||||||
| T32COL | #F3BF | 2 | BASE(6) - SCREEN 1 color table | ||||||||||
| T32CGP | #F3C1 | 2 | BASE(7) - SCREEN 1 character pattern table | ||||||||||
| T32ATR | #F3C3 | 2 | BASE(8) - SCREEN 1 sprite attribute table | ||||||||||
| T32PAT | #F3C5 | 2 | BASE(9) - SCREEN 1 sprite pattern table | ||||||||||
| GRPNAM | #F3C7 | 2 | BASE(10) - SCREEN 2 name table | ||||||||||
| GRPCOL | #F3C9 | 2 | BASE(11) - SCREEN 2 color table | ||||||||||
| GRPCGP | #F3CB | 2 | BASE(12) - SCREEN 2 character pattern table | ||||||||||
| GRPATR | #F3CD | 2 | BASE(13) - SCREEN 2 sprite attribute table | ||||||||||
| GRPPAT | #F3CF | 2 | BASE(14) - SCREEN 2 sprite pattern table | ||||||||||
| MLTNAM | #F3D1 | 2 | BASE(15) - SCREEN 3 name table | ||||||||||
| MLTCOL | #F3D3 | 2 | BASE(16) - SCREEN 3 color table | ||||||||||
| MLTCGP | #F3D5 | 2 | BASE(17) - SCREEN 3 character pattern table | ||||||||||
| MLTATR | #F3D7 | 2 | BASE(18) - SCREEN 3 sprite attribute table | ||||||||||
| MLTPAT | #F3D9 | 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 | Mirror of VDP register 0 (Basic: VDP(0)) |
||||||||||
| RG1SAV | #F3E0 | 1 | Mirror of VDP register 1 (Basic: VDP(1)) |
||||||||||
| RG2SAV | #F3E1 | 1 | Mirror of VDP register 2 (Basic: VDP(2)) |
||||||||||
| RG3SAV | #F3E2 | 1 | Mirror of VDP register 3 (Basic: VDP(3)) |
||||||||||
| RG4SAV | #F3E3 | 1 | Mirror of VDP register 4 (Basic: VDP(4)) |
||||||||||
| RG5SAV | #F3E4 | 1 | Mirror of VDP register 5 (Basic: VDP(5)) |
||||||||||
| RG6SAV | #F3E5 | 1 | Mirror of VDP register 6 (Basic: VDP(6)) |
||||||||||
| RG7SAV | #F3E6 | 1 | Mirror of VDP register 7 (Basic: VDP(7)) |
||||||||||
| STATFL | #F3E7 | 1 | Mirror 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 | Queue table address, see QUETAB (initial value). | ||||||||||
| 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 | Printer head position 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 | ||||||||||
| QUETAB | #F959 | 24 | Queue-table containing queue information. There are four queues in total, three PLAY queues and one RS232 queue, with 6-byte information blocks per queue:
|
||||||||||
| #F91F | 1 | Character set SlotID | |||||||||||
| #F920 | 2 | Character set address | |||||||||||
| EXBRSA | #FAF8 | 1 | SUBROM slot address (EXtended Bios-Rom Slot Address) | ||||||||||
| XSAVE | #FAFE | 1 | Light pen X coordinate read from the device (internal use only). | ||||||||||
| XOFFS | #FAFF | 1 | Light pen X calibration offset
|
||||||||||
| YSAVE | #FB00 | 1 | Light pen Y coordinate read from the device (internal use only). | ||||||||||
| YOFFS | #FB01 | 1 | Light pen Y calibration offset
|
||||||||||
| 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 main BIOS-ROM slot address. | ||||||||||
| #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. | |||||||||||
| RG8SAV | #FFE7 | 1 | Mirror of VDP register 8 (Basic: VDP(9), note: +1) |
||||||||||
| RG9SAV | #FFE8 | 1 | Mirror of VDP register 9 (Basic: VDP(10), note: +1) |
||||||||||
| RG10SA | #FFE9 | 1 | Mirror of VDP register 10 (Basic: VDP(11), note: +1) |
||||||||||
| RG11SA | #FFEA | 1 | Mirror of VDP register 11 (Basic: VDP(12), note: +1) |
||||||||||
| RG12SA | #FFEB | 1 | Mirror of VDP register 12 (Basic: VDP(13), note: +1) |
||||||||||
| RG13SA | #FFEC | 1 | Mirror of VDP register 13 (Basic: VDP(14), note: +1) |
||||||||||
| RG14SA | #FFED | 1 | Mirror of VDP register 14 (Basic: VDP(15), note: +1) |
||||||||||
| RG15SA | #FFEE | 1 | Mirror of VDP register 15 (Basic: VDP(16), note: +1) |
||||||||||
| RG16SA | #FFEF | 1 | Mirror of VDP register 16 (Basic: VDP(17), note: +1) |
||||||||||
| RG17SA | #FFF0 | 1 | Mirror of VDP register 17 (Basic: VDP(18), note: +1) |
||||||||||
| RG18SA | #FFF1 | 1 | Mirror of VDP register 18 (Basic: VDP(19), note: +1) |
||||||||||
| RG19SA | #FFF2 | 1 | Mirror of VDP register 19 (Basic: VDP(20), note: +1) |
||||||||||
| RG20SA | #FFF3 | 1 | Mirror of VDP register 20 (Basic: VDP(21), note: +1) |
||||||||||
| RG21SA | #FFF4 | 1 | Mirror of VDP register 21 (Basic: VDP(22), note: +1) |
||||||||||
| RG22SA | #FFF5 | 1 | Mirror of VDP register 22 (Basic: VDP(23), note: +1) |
||||||||||
| RG23SA | #FFF6 | 1 | Mirror of VDP register 23 (Basic: VDP(24), note: +1) |
||||||||||
| ROMSLT | #FFF7 | 1 | Main BIOS slot ID. (MSX2 and up only) | ||||||||||
| RG25SA | #FFFA | 1 | Mirror of VDP register 25 (Basic: VDP(26), note: +1) |
||||||||||
| RG26SA | #FFFB | 1 | Mirror of VDP register 26 (Basic: VDP(27), note: +1) |
||||||||||
| RG27SA | #FFFC | 1 | Mirror of VDP register 27 (Basic: VDP(28), note: +1) |
||||||||||
| #FFFD | 2 | Temporary stack pointer for CHGCPU. | |||||||||||
| #FFFF | 1 |
Secondary slot select register, if the slot is expanded. 7 6 5 4 3 2 1 0 │ │ │ │ │ │ └─┴── Secondary slot for page 0 (#0000-#3FFF) │ │ │ │ └─┴────── Secondary slot for page 1 (#4000-#7FFF) │ │ └─┴────────── Secondary slot for page 2 (#8000-#BFFF) └─┴────────────── Secondary slot for page 3 (#C000-#FFFF) Reading returns the inverse of the current subslot selection. Values are mirrored in SLTTBL for convenience. Note that each expanded primary slot has its own register. To access a specific primary slot’s register, you need to select it in page 3 before reading the value. |
BiFi