Correct usage of VDP ports following the standard

Page 8/18
1 | 2 | 3 | 4 | 5 | 6 | 7 | | 9 | 10 | 11 | 12 | 13

By Grauw

Ascended (8317)

Grauw's picture

06-06-2017, 01:02

DarkSchneider wrote:
Grauw wrote:

(Also on a side note the standard does not allow accessing I/O port 0A8H directly Big smile.)

In fact, it allows: th-5b.txt
Point 7.1.2. In this case it is really hardcoded in the system. Also notice that the function checks for expanded bit. "Not recommended", but possible, but for page 0 there is no other alternative but using the ISR, the other one way.

Well fuck, now I’m confused, I thought no direct I/O was permitted with the sole exception of the VDP. And then I wasn’t even sure if they meant just the VRAM read/write or literally all access. This is getting too troublesome Big smile. How am I supposed to know what is and isn’t good! Next you tell me I need to read all three volumes of the MSX Datapack in Japanese. I might just find a reference there to say, the PSG ports, and then it is ok for me to access directly as well!

I’m just going to stick to using the BIOS when it is convenient for me, and not using it when it’s not. If others want to collect good citizen stickers they can be my guest. I don’t really see much point in letting ASCII engineers from the 80s dictate my coding style Smile.

By ARTRAG

Enlighted (6229)

ARTRAG's picture

06-06-2017, 08:03

Grauw, it is a religious matter, you must obey to the sacred standard, do not think or discuss.
Ascii said that in the sacred book, believe and obey, the msx faith first.
No matter if those rules were set in a totally different context, 30 years ago, while the msx were produced by multiple manufacturers and that today they have more archeological value than other, as the last msx computers have ceased their production and commercial life in 90's.
Ah, I committed blasphemy! I will burn in the hell now... oO

By PingPong

Prophet (3417)

PingPong's picture

05-06-2017, 22:59

ARTRAG wrote:

Ah, I committed blasphemy! I will burn in the hell now... oO

Repent and Penance, Repent and Penance my dear son, or you will be damned and for the eternity condemned to write slow BIOS for msx machines ...... ;-)

By DarkSchneider

Paladin (854)

DarkSchneider's picture

06-06-2017, 08:56

What I meant are a good ammount of calls (27 LDIRVM + setting the VDP registers) in only the ISR time, notice the 212 lines are used, so it had to finish before or it would have tearing. So not much penalty for the calls themselves. But as always everything is seen from the bad side.

@Grauw you could check this if interested, I think is enough. The MSX Datapack in Japanese could be too much, and I think is more device oriented (like MSX-Music).
http://www.konamiman.com/msx/msx-e.html
At MSX2 Technical Handbook

@ARTRAG I supposed something like that, VDP moving the current content to the backbuffer, and CPU generating the borders at the same time. The main concept of that is not the direct access itself, is the use of paralelism CPU/VDP. If with direct access, plus overriding the 38H is what you need to get the exact time for make it to work in a Z80A, with max of the sprites already shown and etc.etc. then fine, I will not discuss it.
But also think that following the official way (even not overriding the 38H) you can reach the same, but with at some minor speed (it would slows down sometimes to wait for border generation probably, or at a lower step fps like 20 instead 30, or 30 instead 60, to give it room, in this case it will have more room also to do other things as there is too much extra room). That is not the same it can't be made at all. Because the real speed up of the process is the use of paralelism, the others gets you the timming to run it at certain fps in the base Z80A. So the real gain is, as said, because you look at architecture and see, at higher level, how to take advantage.
It would be interesting to see the result of using the blitter ops of BIOS, the VDP access with OUT (C), and not overriding the 38H result. Probably you are not interested on testing it, so don't worry.

Also think that, targeting something so specific, you are closing to only ROMs (the only where you can override the 38H) for 64KB RAM computers. But I talk from the beginning about SOFTWARE, only SOFTWARE, not ROMs for a certain computer config.

So I put the official way to use it, and the topic of the thread was much varied. Even with little related things, specially I'm not religious. For me the topic is over. End of off-topic.

By Grauw

Ascended (8317)

Grauw's picture

06-06-2017, 08:52

You can override 38H very easily in DOS. And otherwise you can use IM 2. (Although I would recommend to still call the original ISR when you do.)

By DarkSchneider

Paladin (854)

DarkSchneider's picture

06-06-2017, 09:48

Grauw wrote:

You can override 38H very easily in DOS. And otherwise you can use IM 2. (Although I would recommend to still call the original ISR when you do.)

It changes the page 0 or keep the RAM?

Mmm, anyway looking at it, I think I prefer the original routine as it is customized for the system (like the PAUSE key). In normal environment I think overriding the routine is not good and can be cause of many bugs or system crashes, as we can't know how is exactly the system made. We could have a system that calls the disk controller update within the routine itself instead at the calling function at the hook.

But I think it is an interesting way to use it as direct BIOS access putting it in a temporary way. You create your alternative routine that calls all the same (your vblank and line interrupt functions) and set IM2 when needed for a short period of time. Then return to IM1. But this if the IM2 also put BIOS at page 0 of course.

Quote:

MSX-DOS only provides a handler for ‘normal’ interrupts. This routine enables the BIOS in page 0 and invokes its interrupt routine

Is there a way to force the DOS interrupt handler from code?

For a ROM is another story, your binary has full control of the system from the beginning.

By Grauw

Ascended (8317)

Grauw's picture

06-06-2017, 09:51

In DOS you can simply write "jp nnnn" to 38H Big smile. This nnnn should be in 0C000H-0FFFFH region.

It is most useful for responding much faster to interrupts (e.g. from the VDP or MIDI / RS232 devices), the BIOS takes quite a long time before it reaches the 0FD9AH (H.KEYI) hook. Pushing all registers, and in DOS it also changes the stack and does an interslot call.

In principle this is safe, as long as you still call the original ISR that was replaced (just like a hook).

If you don’t, there can indeed be some side-effects that you may not anticipate, most commonly that floppy drives keep spinning (which you wouldn’t notice this on emulators or on HDD / SD / CF interfaces). In theory you could avoid this specific one by continueing to call H.KEYI and H.TIMI from your custom ISR (other hacky workarounds also exist), but yeah... best not to, the next thing to break is just around the corner, could be very machine-specific things, TSRs too (e.g. joymega support).

By DarkSchneider

Paladin (854)

DarkSchneider's picture

06-06-2017, 09:57

Grauw wrote:

In DOS you can simply write "jp nnnn" to 38H Big smile. This nnnn should be in 0C000H-0FFFFH region.

It is most useful for responding much faster to interrupts (e.g. from the VDP or MIDI / RS232 devices), the BIOS takes quite a long time before it reaches the 0FD9AH (H.KEYI) hook. Pushing all registers, and in DOS it also changes the stack and does an interslot call.

Right, do your stuff and then call to the original ISR. But remember not to read S#0.

I put it again as the original message was edited and could be not seen.
Is there a way to force the DOS interrupt handler from code?

By Grauw

Ascended (8317)

Grauw's picture

06-06-2017, 10:01

Just call 38H. And if you replaced it, like any hook, just copy the original 38H-3AH values to some location in RAM page 3 and call it at the end of your ISR.

I wanted to add to my previous message, the code needs to be in page 3 because the ISR may also be called during BIOS or DiskROM calls. Also noteworthy, obviously if you do a BIOS call and an interrupt occurs your custom ISR won’t be called. So even in DOS IM 2 may be the superior (though more troublesome) choice, it depends. The H.KEYI hook also doesn’t have this issue, obviously.

By DarkSchneider

Paladin (854)

DarkSchneider's picture

06-06-2017, 10:13

The setting BIOS at page 0, where is done? At the 38h routine itself, at another place in DOS...

Page 8/18
1 | 2 | 3 | 4 | 5 | 6 | 7 | | 9 | 10 | 11 | 12 | 13