RTC Block 3

By aoineko

Paladin (902)

aoineko さんの画像

23-01-2023, 20:27

Hi all,
MSX2 Real Time Clock have in Block 3 a register 0 described as:

Data type (0~15):
0 = Title; 1 = Password; 2 = Prompt; 3 to 15 = Undefined as of 02/05/1986

Questions:
- What is the initial state have this register? Depend of machine?
- What ID was really used?
- Is there any other ID used for other purpose?

I'm thinking about to add an option in MSXgl to have a Quick load/Quick save feature to this Block 3 (6 bytes).

ログイン/登録して投稿

By aoineko

Paladin (902)

aoineko さんの画像

24-01-2023, 01:38

On openMSX or Emulicious, the higher 6 registers of Block #3 (registers #7 to #12: 3 bytes) are overwritten after each hard-reboot. :-/
(no problem with soft-reboot)
This is a strange behavior for a SRAM in my pov but I image it's because of BIOS difference between those 2 types of reset.
The strangest thing is that the result is the same if I use the Title or Prompt data type... it's as if only the first 3 characters were usable.

I'll test on real hardware tomorrow...

BTW, as Alarm is not used on MSX, can we safely use some of the registers of Block #1 to store data (only registers #10 and #11 seems to be used) ?

By Accumulator

Master (196)

Accumulator さんの画像

24-01-2023, 02:13

Oeh, what a coincidence. As the documentation of the clockchip datasheet is mentioning the lowest value you can get is 1 second.
However, if you run the basic instruction TIME (print time), the value increases within the second, therefore I think it is possible to get mili/micro time. My issue is, currently, I do not know how to get the value.
I am dissasembling MSX Basic BIOS in order to get the knowledge how to get the value (not using test mode of clockchip) and at same time I stumbled on this topic.
How to read mili/macro seconds using clockchip or other way....

By Manuel

Ascended (19329)

Manuel さんの画像

24-01-2023, 07:41

TIME works without the clock chip. It's just a counter in memory that gets increased each interrupt, called JIFFY. It therefore works on any MSX.

By Manuel

Ascended (19329)

Manuel さんの画像

24-01-2023, 07:43

Aoineko: some games (Thexder 2 IIRC) and the Novaxis SCSI bios use these clock chip bits as well.

By aoineko

Paladin (902)

aoineko さんの画像

24-01-2023, 12:37

If fact, all is working fine.
It was just a code problem on my side and the fact that the RTC content viewer in openMSX only updates when clicked.
I'm going to reserve 2 types of data for MSXgl:
- Type '6' : Save 6 bytes in block #3
- Type '7' : Save 6 bytes in block #3 + application signature (4 bytes) in block #1
I tried Thexder 2, but I didn't see any modification of the RTC viewer in openMSX after the save. Are you sure it uses the RTC?
If you have any info on data types already used by others, tell me, I can still change the 2 numbers I need.

By ducasp

Paladin (677)

ducasp さんの画像

24-01-2023, 13:12

Accumulator wrote:

Oeh, what a coincidence. As the documentation of the clockchip datasheet is mentioning the lowest value you can get is 1 second.
However, if you run the basic instruction TIME (print time), the value increases within the second, therefore I think it is possible to get mili/micro time. My issue is, currently, I do not know how to get the value.
I am dissasembling MSX Basic BIOS in order to get the knowledge how to get the value (not using test mode of clockchip) and at same time I stumbled on this topic.
How to read mili/macro seconds using clockchip or other way....

The closest you get to a high resolution counter is the variable JIFFY that is increasing every 1/60s (NTSC or PAL-M) or every 1/50s (other PAL and SECAM). Although, I would say precision when counting low probably is not great as you have variable functions in bios/interrupt hooks so it might be increased a little bit late or early than expected, but for the big picture is reasonable.

There is no ms counter in a standard MSX, Turbo-R has a counter with higher resolution, or, if you have an OPL3 or 4 you can get its timers and generate a timer with high resolution, or you can use tricks on msx2 with vdp to generate a higher rate than the 1/60s...

If you need more accurate measuring, would recommend a cheap oscilloscope and you can flip bits in the parallel port (it is a simple out) at the start of your routine and at the end of it, with oscilloscope you can see how long it stayed, you decrease the count of one out operation and there you have it...

By larsthe18th

Master (187)

larsthe18th さんの画像

24-01-2023, 14:11

引用:

NYYRIKKI wrote:
FireHawk saves to PAC if one is available (up to 9 save states), but if there is no one, it will save to clock chip. (Only single save state)

Here is a code example in ASM and in Basic to write to the clock chip and
start Thexder 2 'FireHawk' in the final level.
https://github.com/LarsThe18Th/Small-Projects/tree/master/MS...

By aoineko

Paladin (902)

aoineko さんの画像

24-01-2023, 16:59

Thank you.
So, according to the assembly code, Thexder 2 uses 7 registers (28 bits) in Block #1 (not Block #3).
What about the Novaxis SCSI BIOS?
Do you know other examples of game using RTC to store save data?

By Manuel

Ascended (19329)

Manuel さんの画像

24-01-2023, 23:39

A source code snippet:

NOVAXIS clock-chip memory layout:
  Block 2

nibble
       |    B3   |   B2   |   B1   |   B0   |
       +------------------------------------+
     0 |                 MSX                |
       +------------------------------------+
     1 |                 MSX                |
       +------------------------------------+
     2 |                 MSX                |
       +------------------------------------+
     3 |  Target  ID     |        MSX       |
       +------------------------------------+
     4 |                 MSX                |
       +------------------------------------+
     5 |                 MSX                |
       +------------------------------------+
     6 |                 MSX                |
       +------------------------------------+
     7 |                 MSX                |
       +------------------------------------+
     8 |                 MSX                |
       +------------------------------------+
     9 |                 MSX                |
       +------------------------------------+
    10 |                 MSX                |
       +------------------------------------+
    11 | DrvSup  | MulHDD |      MSX        |
       +------------------------------------+
    12 | AVAILA  | ExtPrt |    HOST ID      |
       --------------------------------------

       Nibbles filled with 'MSX' are used by MSX BIOS
       Nibble 12 normaly contains Native code

See novaxis.mac on https://download.file-hunter.com/Technical/Hans%20Otten/

And https://www.msx.org/wiki/Real_Time_Clock_Programming
Perhaps this article can be expanded with more known uses of the clock chip bits, like Thexder 2.

By aoineko

Paladin (902)

aoineko さんの画像

25-01-2023, 01:42

Thanks for the information.
There is 4 free bits on Block #2 and 22 bits on Block #1.
It's strange that they chose to use these blocks when Block #3 seems to be made for this kind of custom data and you can store 6 bytes in it.

For MSXgl, I added 2 modes:
- Data type 6 : Save 6 bytes in block #3
- Data type 7 : Save 6 bytes in block #3 + Application ID in block #1
I don't have the space to put the 4 bytes of application signature in Block #1, so I put 7 bits of each of the first 2 bytes (company ID) and the 4th byte (application ID's LSB). This should be enough to check if a save data in the RTC is compatible with the current application or not.