Correct usage of VDP ports following the standard

Page 1/18
| 2 | 3 | 4 | 5 | 6

By DarkSchneider

Paladin (801)

DarkSchneider's picture

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 http://map.grauw.nl/resources/msxsystemvars.php where, for the next point:
VDP.DR = n
VDP.DW = n'

2) From them, we can get all the others with http://www.konamiman.com/msx/msx2th/th-4a.txt look at section 1.3, table 4.3:

Quote:

----------------------------------------------------------------------
| 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 or register to post comments

By Wlcracks

Champion (315)

Wlcracks's picture

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 (436)

ricbit's picture

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

Enlighted (8079)

Grauw's picture

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

Champion (315)

Wlcracks's picture

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??
Wink
Joke.. Thanks grauw for the info in your site, helped me a lot with my small project. Coming soon...

By Grauw

Enlighted (8079)

Grauw's picture

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.)

By ARTRAG

Enlighted (6181)

ARTRAG's picture

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

Prophet (3300)

PingPong's picture

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 (3014)

sd_snatcher's picture

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

Champion (315)

Wlcracks's picture

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 (15457)

Manuel's picture

01-06-2017, 21:49

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

Page 1/18
| 2 | 3 | 4 | 5 | 6