ADVRAM MSX Rating
Introduction
ADVRAM is a new hardware standard for MSX.

Its main feature is to allow programmers to use the VRAM just like any other RAM in the system.
With ADVRAM, you can use LD instructions to read/write in the VRAM, and forget about the INs and OUTs !!
The name ADVRAM means, in portuguese, "Acesso Direto à VRAM" and translates to "Direct Access to VRAM".

In this page you will find technical info for ADVRAM programmers, benchmarks of ADVRAM when compared to other methods of accessing VRAM, and sample programs.

Technical Info
When developing ADVRAM, we wanted to avoid the common problems with other MSX hardware. For instance, I never liked to search all slots to find where the Mapper is, and we also didn't want to waste another of the limited MSX I/O ports in this project. The basic idea in this project was to make the hardware simple and easy to program.

Based on these guidelines, our solutions to these problems were:

ADVRAM Slot

The ADVRAM will always be on the page 2 (08000h-0BFFFh) of the slot where the MainROM is. You can get this value by reading the contents of the EXPTBL system variable (0FCC1h). This value will be either 00h (slot 0, in common MSXs) or 80h (slot 0.0, in the Turbo-R).

We choose this slot because, except for that Korean machine with V9948, no one places ROM in this area. So this is a free area in almost all MSX, and we don't need to spend an extra slot with ADVRAM.

ADVRAM Bank Switching

As you can see, ADVRAM uses only 16kb of the MainROM slot. Since the MSX-2 VRAM has 128kb, some kind of bank switching must be done.

We choose to use the same I/O port used by the Memory Mapper. This means you just need to make an OUT(0FEh),A to choose which portion of the VRAM you want to map into RAM.

This has a side effect of switching the main Mapper of the system, but this also happens every time you add another Mapper to your system. Just think of ADVRAM as another Mapper, but one with the special feature of mirroring the VRAM.

ADVRAM Control Register

Since ADVRAM behaves like a Memory Mapper, some programs could get confused and try to use it to store data. But this do not happen because the ADVRAM can be switched ON and OFF, and the default state when the MSX start is OFF.

To turn the ADVRAM ON, you must use its control register.
To store a value in the control register, you must use this sequence:

LD A,value
IN A,(09Ah)

I know it sounds strange, to write a value using an IN instruction, but it works. Let me explain what happens: most programmers use to think that the Z80 can map 256 different I/O ports. This is not true. The Z80 has a 16-bit I/O bus. The 09Ah specify the lower 8-bits of the 16-bit value, and the higher 8-bits are the contents of the accumulator. If you are using the IN A,(C), then the value placed in the higher 8-bits is not the accumulator, but instead the Z80 register B.

ADVRAM reads the value of the control register from the higher 8-bits of the I/O address. There's no side effect here, since port 09Ah is a write-only port in a normal MSX system.

Of the 8 bits of the control register, only two are actually used:

Control Register: TD000000

The T (bit 7) is the Turn-on bit. Set it to "1" and the ADVRAM will be enabled. Set it to "0" and the ADVRAM will be disabled (this means you will not be able to read/write in its area, and bank switching will not work).

The D (bit 6) is the Deinterlace bit. People with knowledge of MSX hardware know that, in the SCREENs 7 to 12, the VRAM is interlaced, which means consecutive pixels are stored in different chips of VRAM. Programmers usually never notice that, because the VDP handles it in a way the VRAM looks linear. If you set the D bit to "1", ADVRAM will have the same behaviour, and you can program in higher SCREENs the same way you always programmed.

ADVRAM Usage

There's no trick here. ADVRAM behaves like a Mapper in every aspect, so you can use LD and even LDIR to write and read from it. You can even execute Z80 code from the VRAM!

Another nice feature is that you can execute VDP commands while writing/reading from ADVRAM! You get no corrupted data and the VDP commands will not be slowed down.

ADVRAM replaces the dynamic RAM used in the VRAMs with the same static RAM used as cache in PC machines, so the speed of ADVRAM is great even on MSX with high clock ( 7 MHz and even higher! )

Availabilty
Ademir Carchano is producing 30 units of ADVRAM.
You can contact him through his page: http://www.carchano.com.br

The price is R$ 130.00, which is something like US$ 73.00

The ADVRAM is NOT a cartridge. It is a small circuit board which must be connected inside your MSX.

You must have some knowledge of hardware to make that, but these days, every MSX user who don't know about hardware has a friend who does.

If you want to try it before buying, get the emulator BrMSX 2.5, which has ADVRAM emulation.

Benchmark
When the concept of ADVRAM was first presented on the MSX international mailing list, people were sceptic about its advantages. Based on this, I made a program to test and compare ADVRAM to other methods of accessing VRAM.

Since you may not believe in the incredible results obtained, download Video Test 1.0 and try the program by yourself.

This program executes six graphic tests, using three different methods: ADVRAM, writing/reading through port 098h, and VDP commands. The main core of the program is the same, you just need to change a EQU in the beggining of the source to select which video engine you want. The package include the source code, and the three precompiled executables: ADVRAM.COM, OUT98H.COM and VDPCMD.COM.

To make the result fair and unbiased, some guidelines were followed when designing the routines:

  1. The routines must be as optimized as possible
  2. The routines make no checking to test if its arguments are valid
  3. The routines must not modify any Z80 register. Every register used must be saved with PUSH and POP
  4. VDP commands used must not use VRAM->VRAM transfers. (This means no HMMM, YMMM or LMMM)
  5. No look-up tables are permitted
  6. No memory variables are permitted
  7. Secret Z80 instructions and R800-only opcodes are forbidden
  8. Loop unrolling is OK

You may want to read the source code to check if I indeed followed these guidelines.
If you can optimize further any of the routines, please send me a patch.

All tests are performed in 10 seconds, and the program counts how many times the routine has executed.
Higher results means higher speed.

The tests were performed in three configurations:

  1. BrMSX 2.5, which has a very good timing and can be used for comparison. If you don't trust me, just get the emulator source code and check it by yourself.
  2. A real MSX2+ CIEL-Turbo, which is a standard MSX2+ with Z80, and user-selected clock of 3.57MHz or 7.14MHz.
  3. A real MSX Turbo-R GT in Z80 and R800/DRAM modes.

The last thing I must talk before presenting the results is that sometimes the VDP is too slow to receive data in the high-speed I'm sending, causing strange video behaviour, and locking the machine after the test. When this happens, just start the program again and press ESC to skip this test. In the tables below, this case will be marked as too slow.

Now let's see the results:


Generic SCREEN 8 Point

This routine must draw a single pixel in SCREEN 8.
The VDP command used was PSET.
The inputs are:

H = Y coordinate of the pixel (0<Y<192)
L = X coordinate of the pixel (0<X<256)
C = color of the pixel (0<C<256)

ADVRAMOUT98HVDPCMD
BrMSX @ 3.57144181121467110494
MSX2+ @ 3.57none122327111276
Turbo-R Z80none120204108512
BrMSX @ 7.14288721243236221262
MSX2+ @ 7.14none245090222947
Turbo-R R800none222363141905

ADVRAM 7.14MHz: 288721
Best MSX2+ result (OUT98H @ 7.14): 245090
Best Turbo-R result (OUT98H @ R800): 222363
The ADVRAM was 17% faster than the MSX2+
The ADVRAM was 29% faster than the Turbo-R


Generic SCREEN 5 Point

This routine must draw a single pixel in SCREEN 5.
The VDP command used was PSET.
The inputs are:

H = Y coordinate of the pixel (0<Y<192)
L = X coordinate of the pixel (0<X<256)
C = color of the pixel (0<C<16)

ADVRAMOUT98HVDPCMD
BrMSX @ 3.5711101278644107807
MSX2+ @ 3.57none79175108534
Turbo-R Z80none77701105830
BrMSX @ 7.14222301157483215881
MSX2+ @ 7.14none156975217697
Turbo-R R800none136346141212

ADVRAM 7.14MHz: 222301
Best MSX2+ result (VDPCMD @ 7.14): 217697
Best Turbo-R result (VDPCMD @ R800): 141212
The ADVRAM was 2% faster than the MSX2+
The ADVRAM was 57% faster than the Turbo-R


SCREEN 8 Burst Copy

This routine must copy a full width horizontal line from RAM to VRAM in SCREEN 8.
The VDP command used was HMMC.
The inputs are:

HL = address of line in RAM
D = Y coordinate of the line (0<Y<192)

ADVRAMOUT98HVDPCMD
BrMSX @ 3.57725772367000
MSX2+ @ 3.57none72927054
Turbo-R Z80none69166690
BrMSX @ 7.14145311448914018
MSX2+ @ 7.14none13084too slow
Turbo-R R800none44304264

ADVRAM 7.14MHz: 14531
Best MSX2+ result (OUT98H @ 7.14): 13084
Best Turbo-R result (OUT98H @ Z80): 6916
The ADVRAM was 11% faster than the MSX2+
The ADVRAM was 110% faster than the Turbo-R


SCREEN 5 Aligned 8x8 Block Copy

This routine must copy a 8x8 block from RAM to VRAM in SCREEN 5, and the coordinates must be multiples of 8.
The VDP command used was HMMC.
The inputs are:

HL = address of block in RAM
D = Y coordinate of the line (0<Y<=184, must be a multiple of 8)
E = X coordinate of the line (0<X<=248, must be a multiple of 8)

ADVRAMOUT98HVDPCMD
BrMSX @ 3.57340942577232207
MSX2+ @ 3.57none2594632424
Turbo-R Z80none2500631087
BrMSX @ 7.14682735160764493
MSX2+ @ 7.14none50282too slow
Turbo-R R800none2270524737

ADVRAM 7.14MHz: 68273
Best MSX2+ result (OUT98H @ 7.14): 50282
Best Turbo-R result (VDPCMD @ Z80): 31087
The ADVRAM was 35% faster than the MSX2+
The ADVRAM was 119% faster than the Turbo-R


SCREEN 8 Aligned 8x8 Block Copy

This routine must copy a 8x8 block from RAM to VRAM in SCREEN 8, and the coordinates must be multiples of 8.
The VDP command used was HMMC.
The inputs are:

HL = address of block in RAM
D = Y coordinate of the line (0<Y<=184, must be a multiple of 8)
E = X coordinate of the line (0<X<=248, must be a multiple of 8)

ADVRAMOUT98HVDPCMD
BrMSX @ 3.57227441870621149
MSX2+ @ 3.57none1885021311
Turbo-R Z80none1804820341
BrMSX @ 7.14455433745942350
MSX2+ @ 7.14none35635too slow
Turbo-R R800none1390214666

ADVRAM 7.14MHz: 45543
Best MSX2+ result (OUT98H @ 7.14): 35635
Best Turbo-R result (VDPCMD @ Z80): 20341
The ADVRAM was 27% faster than the MSX2+
The ADVRAM was 123% faster than the Turbo-R


SCREEN 8 Generic Transparent 8x8 Block Copy

This routine must copy a 8x8 block from RAM to VRAM in SCREEN 8. Values "0" should be treated as transparent.
The VDP command used was LMMC.
The inputs are:

HL = address of block in RAM
D = Y coordinate of the line (0<Y<=184)
E = X coordinate of the line (0<X<=248)

ADVRAMOUT98HVDPCMD
BrMSX @ 3.5711370897420579
MSX2+ @ 3.57none9042too slow
Turbo-R Z80none8848too slow
BrMSX @ 7.14227671796941209
MSX2+ @ 7.14none18100too slow
Turbo-R R800none1385214639

ADVRAM 7.14MHz: 22767
Best MSX2+ result (OUT98H @ 7.14): 18100
Best Turbo-R result (VDPCMD @ R800): 14639
The ADVRAM was 25% faster than the MSX2+
The ADVRAM was 55% faster than the Turbo-R

Credits
This page was created and maintened by Ricardo Bittencourt

Last update: 23/4/2000

The ADVRAM original idea was told to me by Márcio of the Other Side MSX Club, during the ExpoSALT 2000 meeting.

I liked the idea and told it to Ademir Carchano, who implemented the first hardware prototype in only four months.

All the Turbo-R tests were performed in a machine donated to me by Takamichi Suzukawa.

All the tests in the CIEL2+ were performed by Luciano Sturaro.

Many thanks to the people who contributed to the standard including Daniel Caetano, Werner Kai, Leonard Oliveira, and the people from the #msxzone IRC channel.