# HG changeset patch # User Laurens Holst # Date 1625322335 -7200 # Sat Jul 03 16:25:35 2021 +0200 # Node ID 2258b32fa1a7a94a5f41076873b2e005a8e4c600 # Parent 8891b6a16771a67ca133c208684f2eb0a25e38de vdp_detection: Elaborate a bit more. diff --git a/sources/vdp_detection.php b/sources/vdp_detection.php --- a/sources/vdp_detection.php +++ b/sources/vdp_detection.php @@ -8,11 +8,10 @@ - -

Detecting VDP version

-

Here’s a routine to help you detect the VDP version.

+

Here’s a routine to help you detect the VDP version. It takes about a frame +to complete, so it is recommended to do it once at the start of the program.

;
 ; Detect VDP version
@@ -41,11 +40,8 @@
     ret nz               ; return VDP ID for V9958 or higher
     inc a                ; return 1 for V9938
     ret
-
-

The TMS9918A has no VDP ID, so we use a different way to detect it…

- -
;
+;
 ; Test if the VDP is a TMS9918A.
 ;
 ; The VDP ID number was only introduced in the V9938, so we have to use a
@@ -57,11 +53,11 @@
 ; f <- z: TMS9918A, nz: V99X8
 ;
 VDP_IsTMS9918A:
-    in a,(99H)           ; read s#0, make sure interrupt flag is reset
+    in a,(99H)           ; read s#0, make sure interrupt flag (F) is reset
     di
 VDP_IsTMS9918A_Wait:
     in a,(99H)           ; read s#0
-    and a                ; wait until interrupt flag is set
+    and a                ; wait until interrupt flag (F) is set
     jp p,VDP_IsTMS9918A_Wait
     ld a,2               ; select s#2 on V9938
     out (99H),a
@@ -73,7 +69,7 @@
     out (99H),a
     ld a,15 + 128
     out (99H),a
-    ld a,(0F3E6H)
+    ld a,(0F3E6H)        ; RG7SAV
     out (99H),a          ; restore r#7 if it mirrored (small flash visible)
     ld a,7 + 128
     ei
@@ -83,9 +79,13 @@
     ret
 
+

Note: As you may know, the MSX VDPs have a race condition in the design of +the F, FH and FL interrupt flags, which makes polling unreliable since the flag +can be missed occasionally. If that situation occurs the detection will take a +frame longer to complete, but still provide the correct result.

- +

Grauw

- \ No newline at end of file +