ADVRAM |
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.
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:
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.
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.
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.
LD A,value 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.
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:
You may want to read the source code to check if I indeed followed
these guidelines.
All tests are performed in 10 seconds, and the program counts
how many times the routine has executed.
The tests were performed in three configurations:
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:
This routine must draw a single pixel in SCREEN 8.
H = Y coordinate of the pixel (0<Y<192)
This routine must draw a single pixel in SCREEN 5.
H = Y coordinate of the pixel (0<Y<192)
This routine must copy a full width horizontal line from RAM to VRAM
in SCREEN 8.
HL = address of line in RAM
This routine must copy a 8x8 block from RAM to VRAM
in SCREEN 5, and the coordinates must be multiples of 8.
HL = address of block in RAM
This routine must copy a 8x8 block from RAM to VRAM
in SCREEN 8, and the coordinates must be multiples of 8.
HL = address of block in RAM
This routine must copy a 8x8 block from RAM to VRAM
in SCREEN 8. Values "0" should be treated as transparent.
HL = address of block in RAM
|
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. |