Correct usage of VDP ports following the standard

Страница 1/18
| 2 | 3 | 4 | 5 | 6

By DarkSchneider

Paragon (1030)

Аватар пользователя DarkSchneider

01-06-2017, 14:19

For those who like to program following the platform standard, probably met the doubt about where are the VDP ports instead hardcoding them in the code.
Well, here is the response:

1) We can get the base ports from BIOS where, for the next point:
VDP.DR = n
VDP.DW = n'

2) From them, we can get all the others with look at section 1.3, table 4.3:


| Port | Address | Function |
| port #0 (READ) | n | read data from VRAM |
| port #0 (WRITE) | n' | write data to VRAM |
| port #1 (READ) | n + 1 | read status register |
| port #1 (WRITE) | n'+ 1 | write to control register |
| port #2 (WRITE) | n'+ 2 | write to palette register |
| port #3 (WRITE) | n'+ 3 | write to indirectly specified register |

Remember that we already have n and n' from before.

3) Use the indirect port access Z80 instruction: in/out (C), r instead the hardcoded one, putting in C the port number.

Для того, чтобы оставить комментарий, необходимо регистрация или !login

By Wlcracks

Hero (572)

Аватар пользователя Wlcracks

01-06-2017, 17:04

Ok very nice but

Looking back to the past how many msx computers did not have the 99 98 port? Like 1?
Looking forward to the future, what hardware could be used, witch has been new developed for other ports. Seem to me developing hardware not use 99 98 seem a bit asking for problems? Or just using dedicated software anyways?

Not sure what the advantage could be. Disadvantage speed... when writing roms you cannot change the code in preprocessing.

By ricbit

Champion (438)

Аватар пользователя ricbit

01-06-2017, 17:32

Neos MA-20 doesn't use ports 98-99, and there are clones of MA-20 developed recently or under development.

By Grauw

Ascended (10818)

Аватар пользователя Grauw

01-06-2017, 17:54

Supposedly the MSX2+ standard does hardcode the ports to 98H. I suspect the modifiable I/O ports were there mostly to support MSX1 to MSX2 upgrade cartridges, and they dropped support for this kind of hardware afterwards. So if you're making an MSX2+ or turboR title it should be fine to hardcode the ports.

Nevertheless it is probably still a good idea to get the base ports from the BIOS, indeed because of some interesting recent hardware developments as well as because I got this information second hand a few years back and can't quote an official source (maybe in the datapack somewhere...).

By Wlcracks

Hero (572)

Аватар пользователя Wlcracks

01-06-2017, 18:23

Time to update the grauw site for the fastest an most efficient code for working with port read out from the bios??
Joke.. Thanks grauw for the info in your site, helped me a lot with my small project. Coming soon...

By Grauw

Ascended (10818)

Аватар пользователя Grauw

01-06-2017, 19:28

Not a bad idea. In principle you can just get the value from the BIOS with RDSLT once and store it in a more easily accessible location (e.g. if your code is running from DOS), or have a set of utility routines in RAM which are self-modified on program start.

Indeed on the MAP there are probably articles and code examples which hardcode the VDP I/O address instead of retrieving it from the BIOS, both because they were written back when this wasn’t common practice in the scene at all, and also because even today I’m not fully convinced that it is really necessary so I haven’t really felt hard pressed to update them. For my software I might just use the excuse that it is MSX2+ software and that any MSX2 capable of running it is purely coincidental Tongue. Or just bite the bullet and do it the official way Big smile, it’s the nice thing to do after all!

That table 4.3 is nice btw, I hadn’t noticed it before and was always wondering about how those two separate read and write address values were supposed to be mapped to the other three I/O addresses, and why not just a single base address. (My impression was that originally on MSX1 the direct VDP I/O was only really permitted for VRAM read/write, and you were supposed to use the BIOS for setting registers etc.)


Enlighted (6976)

Аватар пользователя ARTRAG

01-06-2017, 20:34

Ports 98h and 99h are hardcoded in msx2+ and TR definitions and adopted by all existing stand alone machines.
Better to define a new label telling "MA-20 compatible" instead of pretending to alterate 30 years of history of developments from the msx community.

By PingPong

Enlighted (4155)

Аватар пользователя PingPong

01-06-2017, 20:30

the vdp interaction is already slow. no need to get the 'correct' address from ROM when pratically 98h is de.facto standard

By sd_snatcher

Prophet (3675)

Аватар пользователя sd_snatcher

01-06-2017, 21:02

ARTRAG wrote:

Ports 98h and 99h are hardcoded in msx2+ and TR definitions and adopted by all existing stand alone machines.

Can you cite the official references for this affirmation? Otherwise it can be said that it's just misinformation being repeated from mouth to mouth.

Without that, it would be more honest to put a disclaimer "This software doesn't follow the MSX standard strictly and may not run on all MSX compliant models and extensions."

This way the user will know that their hardware is not faulty.

By Wlcracks

Hero (572)

Аватар пользователя Wlcracks

01-06-2017, 21:48

Just took a random konami game, circus charlie. Disassembled to look how they addressed the vdp. They use bios to set the vdp start. Then read the address 0007 and use out(c). They do not appear to use the bios for block writes. BTW Looks like the whole game is running on the interrupt.

Hummm damn back to the drawing board for only one module lol.

By Manuel

Ascended (19674)

Аватар пользователя Manuel

01-06-2017, 21:49

How much slower is out(c) again compared to out 0x98?

Страница 1/18
| 2 | 3 | 4 | 5 | 6