How to....

Page 1/2
| 2

By PingPong

Prophet (3514)

PingPong's picture

09-03-2008, 20:14

detect the vdp refresh speed (50hz or 60hz) on a MSX1:

actually i use a void loop and i count the jiffy increments before and after the loop. But i'm looking for a more elegant solution . Any idea?

Login or register to post comments

By GhostwriterP

Hero (528)

GhostwriterP's picture

09-03-2008, 21:13

ld a,(2Bh) And then it is one of the 8 bits Smile
bit 7 I think...

By jltursan

Prophet (2273)

jltursan's picture

09-03-2008, 21:35

Right, bit 7, 0=60Hz & 1=50Hz

By PingPong

Prophet (3514)

PingPong's picture

09-03-2008, 21:58

thx, a lot!!!!!!!!!!!!!!!!!!!!!!!!

By ro

Guardian (4164)

ro's picture

10-03-2008, 09:03

euh, that only works when MSX BIOS is enabled (in page 0) and VDP change has been made via BIOS call. (or if the user updates 0x2B when changing VDP regs)

By pitpan

Prophet (3131)

pitpan's picture

10-03-2008, 09:39

And it won't be reliable in MSX1 machines with MSX1 BIOS installed and featuring V9938 VDP, such as SVI738 and Yamaha CMX5II/128. For these machines, first you should detect them and then read the corresponding VDP register.

Reading the BIOS byte, you'll only know the default retrace frequency. That's OK if it cannot be changed (TMS99xx). If it can be changed, then you'll have to make a guess Wink

By ro

Guardian (4164)

ro's picture

10-03-2008, 10:17

my prev post was a bit fuzzy (aah, whatsinnaname)
VDP regs update to vars is not stored in 2B ofcourse but in VDP buf in Hi-Mem.
2B is initial (default) startup and machine type /BIOS settings.

Basic ROM version
here's an excerpt from MAP: (http://map.tni.nl/resources/msxsystemvars.php)

7 6 5 4 3 2 1 0
| | | | +-+-+-+-- Character set
| | | |           0 = Japanese, 1 = International, 2=Korean
| +-+-+---------- Date format
|                 0 = Y-M-D, 1 = M-D-Y, 2 = D-M-Y
+---------------- Default interrupt frequency
                  0 = 60Hz, 1 = 50Hz

Here's where the BIOS calls and BASIC store any VDP changes (reg 0 till 7 + stat):
#F3DF-#F3E7

By PingPong

Prophet (3514)

PingPong's picture

10-03-2008, 19:31

I will stay to the old solution: delay loop of 1 second (all msx1 have z80 @3.58Mhz) and count of nints....

By dvik

Prophet (2200)

dvik's picture

10-03-2008, 19:39

Here is the one I wrote and have been using in several games and demos:

;;
;; returns 1 in a and clears z flag if vdp is 60Hz
;;
CheckIf60Hz:
    di
    in      a,($99)
    nop
    nop
    nop
vdpSync:
    in      a,($99)
    and     0x80
    jr      z,vdpSync
    
    ld      hl,$900
vdpLoop:
    dec     hl
    ld      a,h
    or      l
    jr      nz,vdpLoop
    
    in      a,($99)
    rlca
    and     1
    ei
    ret

By dvik

Prophet (2200)

dvik's picture

10-03-2008, 19:41

The code starts with syncing to vblank. Then the vdpLoop pretty much loops for around 290 scanlines. If the vblank bit is set after the loop finishes it means that more than one frame has passed (60Hz).

By PingPong

Prophet (3514)

PingPong's picture

10-03-2008, 20:59

The code starts with syncing to vblank. Then the vdpLoop pretty much loops for around 290 scanlines. If the vblank bit is set after the loop finishes it means that more than one frame has passed (60Hz).
thx dvik, this is similar to mine.

Page 1/2
| 2