Backup RAM not emulated correctly

بواسطة Accumulator

Champion (351)

صورة Accumulator

04-04-2023, 05:03

Backup RAM port #43H to #47H not emulated correctly (S1985, Way to detect OpenMSX)

When accessing Backup RAM and reading and writing to it, reg #41h and #43H, #44h and #45H give similar results, values, in real MSX
Reg #46 and #47 are writeable and you can get values you write to those registers.

OpenMSX returns values you write to reg #46h, others return the value 255

OpenMSX gives correct values when writing to Backup RAM #40h - 42H and reading them. Even when you give a reset (defusr=0:a=usr(0))

Login أوregister لوضع تعليقاتك

بواسطة wouter_

Hero (535)

صورة wouter_

04-04-2023, 14:00

Hi, thanks for your comment!

The S1985 datasheet is pretty cryptic when describing the 'backup RAM' and 'bitmap' functionality. Though, to the best of my knowledge, openMSX correctly implements the documented behavior of these functions.

If I have to be honest: your comment is also pretty cryptic. What I think you're saying is that the openMSX behavior is not correct when reading ports 0x41, 0x43, 0x44, 0x45, 0x46, right? But none of these ports have any documented behavior on read.

Also did I understand correctly that, according to your tests reading from ports 0x41, 0x43, 0x44 and 0x45 (always) gives the same result as reading from the (documented) port 0x42? In other words: these are all mirrors of port 0x42. And similarly reading port 0x46 is a mirror of the (documented) port 0x47?

Did you also test whether there's any (the same) mirroring for port 0x41-0x45 on write? (Ports 0x46 and 0x47 have a different function on write, so those cannot mirror).

بواسطة Accumulator

Champion (351)

صورة Accumulator

04-04-2023, 18:34

For example (For Sony hb-f700) (Service manual, describes value FF written to port &h40, reading 01H, writing 0xH to port #40H and reading #42H. As you know this is incorrect.

Out &h40,&Hfe: ? inp(&H40) -> returns 1 (as openMSX does).
This opens the ports of #40H-#47H.

Out &H41,0xH (0-15)
out &h42,xxH (write to Backup Ram)

out &h40,254 (sony hb f700 / 900)
out &h41,xH (0-15)
? inp(&h42) ( This is correct behaviour of OpenMSX, even after a reset, the correct values are returned..)

for i=&h40 to &h47
? inp (i)
next i

In this example the values of port #41H and #43H to #46H are the same , #42H and #47H are (sometimes same)

I noticed there is a bug in basic (maybe it is the 2+ rom in my machine).
I have to convert it to assembly for more accuracy and running again, because:
If I run basic: (part of my IO checker)

10 FOR Y=0 TO 15
20 FOR X=0 TO 15
30 LOCATE X*2,Y
40 ? RIGHT("0"+HEX$(INP((Y*16)+X),2)
50 NEXT X
60 NEXT Y

The result of 40 gives a lot of 02H , and not the real value of the port. The calculation has to be on another line.
The first result of #41H is 01, second time I read the port is 02
Whether basic is correct or incorrect, the same values including changing of values occur in #41H and #43H-#45H
The Bit Map is tricky and I had 5 different results:
1 - The value written to port #46 ended up in #47
2 - The value written to port #47 sticks for only 1 time reading
3 - The value written to port #47 sticks , even when resetting the machine.
4 - The value of Port #46H , stays at 02H
5 - The value of Port #46H sticks

Doing more testing to get accurate and definite results.

OpenMSX returns the value of 255 when reading port #43H to #45# and #47H

بواسطة Accumulator

Champion (351)

صورة Accumulator

07-04-2023, 00:02

To get correct values:
modify line 40 to:

40 ? RIGHT("0"+HEX$(INP(VAL(STR$((Y*16)+X))))),2)

Bit map issue has been resolved...

Have tested PORT #43 to PORT #45 on write and read...
When fully completed I will publish the file (BASIC and Assembly)

بواسطة Accumulator

Champion (351)

صورة Accumulator

08-04-2023, 01:53

Backup Ram seems correct in OpenMSX, however some ports are seemingly incorrect..

BASIC file :
BackupRAM test