Skip to content

VDP Command SRCH issue #1960

Closed
Closed

Description

@hra1129

Executing the SRCH command returns the result of whether a boundary was detected in S#2 bit4 (BD).
Testing this on a V9958 (FS-A1GT) hardware unit confirmed that it clears when S#2 is read.
However, in OpenMSX 20, it does not clear no matter how many times it is read.
I am reporting this discovery of such a difference in behavior.

My test program is located below.
https://github.com/hra1129/TangCartMSX/blob/main/RTL/tangnano20k_vdp_cartridge_step7/src/th9958/soft_vdp_test/SC5SRCH.COM
https://github.com/hra1129/TangCartMSX/blob/main/RTL/tangnano20k_vdp_cartridge_step7/src/th9958/soft_vdp_test/sc5srch.asm
https://github.com/hra1129/TangCartMSX/blob/main/RTL/tangnano20k_vdp_cartridge_step7/src/th9958/soft_vdp_test/sc5srch.txt

Result of FS-A1GT
Image

Result of OpenMSX
Image

Activity

  1. m9710797 commented on Aug 30, 2025

    @m9710797
    Contributor

    Thanks a lot for reporting this!
    Also thanks for the test program. My own MSX computers are in storage, so I can't easily run tests on real machines myself. So thanks for including the screenshots.

    I'll try to fix this in openMSX soon (but right now I'm working on other stuff).

    Same for the LINE stuff your reported in #1961. Thanks for that report, I'll also try to look at that soon.

  2. m9710797 commented on Aug 31, 2025

    @m9710797
    Contributor

    Thanks again. I've pushed a fix for openMSX, and now the test program produces 100% the same output on openMSX as on the real machine.


    But I have a follow-up question.
    Today openMSX does the following:

    1. When a SRCH command ends it sets or resets the BD bit if the color was respectively found or not found.
    2. (New since today) After reading S#2 we reset the BD bit.

    But I wonder if step 1 is correct:

    • Does the SRCH command reset the bit when not found, or does it just leave the bit unchanged?
      • E.g. what if I do a SRCH command that sets BD, then NOT read S#2, and perform another SRCH that does not find the color. Is BD now 0 or 1?
    • Maybe SRCH resets BD at the start of the command instead of only at the end?
      • What if we already start reading S#2 while the command is still running? Will that always return 0 (indicating the color has not yet been found)? Or will it return the value from before the command started?
  3. added a commit that references this issue on Aug 31, 2025
  4. m9710797 commented on Sep 1, 2025

    @m9710797
    Contributor

    Thanks for the new test program.
    OpenMSX gives this output for the last 4 tests:

    65280 000 000
    65280 000 017      <-- this one is different from real machine    65280 016 017
    65280 000 017
    65280 000 001
    

    Can you help me interpret this result? What does the value in the 2nd column mean (000 vs 016)? Any idea what to fix in openMSX?

    Thanks!

  5. hra1129 commented on Sep 1, 2025

    @hra1129
    Author

    I'm sorry! I misunderstood.
    The BD flag won't clear even after reading S#2.
    It will clear after reading either S#8 or S#9. I'll confirm which one—S#8 or S#9—it is shortly.

    Image Image
  6. hra1129 commented on Sep 2, 2025

    @hra1129
    Author
    Image

    FS-A1GT Result
    Image

    OpenMSX 20 Result
    Image

    The BD flag is cleared by reading S#9.
    SRCH results are reflected in the BD at the time the SRCH command completes.

    https://github.com/hra1129/TangCartMSX/blob/main/RTL/tangnano20k_vdp_cartridge_step7/src/th9958/soft_vdp_test/SC5SRCH.COM

    The test program has been changed to a hex dump to display more information.
    It has also been rearranged to match the read order as closely as possible.

  7. hra1129 commented on Sep 2, 2025

    @hra1129
    Author

    I fixed a bug in the test program SR5SRCH.

    Result of FS-A1GT
    Image

  8. added a commit that references this issue on Sep 2, 2025
  9. m9710797 commented on Sep 2, 2025

    @m9710797
    Contributor

    Thanks again!

    I made a change in openMSX, and now openMSX matches the output of your test program on FS-A1GT. At least the previous version, before your bug fix. Can you also send that corrected version (you only send a photo of the output)?

    OpenMSX now behaves like this:

    • The BD bit is reset when reading S#9. This is the ONLY condition that resets the bit.
    • The BD bit is set when the SRCH command stops because it found the requested color.

    Note: when the SRCH command stops without finding the requested color, it does NOT reset the BD bit.

    Does this match your interpretation of your test program?

  10. m9710797 commented on Sep 2, 2025

    @m9710797
    Contributor

    OpenMSX also matches the output of the bug-fixed version.
    I'm closing this issue now.
    Thanks a lot for your help!


    While working on fixing openMSX I still noticed this line in the openMSX source code. It's about the execution speed of the SRCH command. At the moment it takes 88 VDP cycles (@ 21.47MHz) per pixel. But this was only a guess (roughly based on the execution speed of the LINE command).

    I'm not asking you to create new tests for this. Only if you happen to know the speed already, then I am interested in that information.

    The execution speed of the LINE and block commands should already be accurate in openMSX.

  11. hra1129 commented on Sep 2, 2025

    @hra1129
    Author

    I'm sorry.
    Regarding the speed, I don't have any information either.

    ==================

    Regarding the BD bit, even if you set BD=1 beforehand and then execute “SRCH expecting BD=0” without clearing it, it seems to maintain BD=1.

    Image

    The section highlighted in red shows the results of test019.
    For test019, BD is set to 1 beforehand.
    That SRCH waits for completion by holding for a fixed time without reading S#2, S#8, or S#9 at all.
    In other words, it does not clear BD=1.
    In that state, executing an SRCH expecting BD=0 and reading S#2 after waiting for a fixed time results in BD=1, CE=0 at completion—this is the first 10h.
    The second instance is the value 10h read from S#2 immediately afterward.
    The third instance is the value 10h read from S#2 again after reading S#8.
    The value to its right is 00h, read from S#2 again after reading S#9.

    From these results, I understand that the BD flag is updated upon SRCH completion to the value obtained by ORing the current BD flag with the resultant BD flag.

  12. added a commit that references this issue on Sep 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions