Packing/Unpacking MCI time information

Started by José Roca, June 19, 2007, 03:46:35 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca

 
I need to translate some MCI C macros to PowerBASIC. Are all these functions correct?


'/* MCI time format conversion macros */
'#define MCI_MSF_MINUTE(msf)             ((BYTE)(msf))
FUNCTION MCI_MSF_MINUTE (BYVAL msf AS DWORD) AS BYTE
   ! MOV AL, msf[0]
   ! MOV FUNCTION, AL
END FUNCTION

'#define MCI_MSF_SECOND(msf)             ((BYTE)(((WORD)(msf)) >> 8))
FUNCTION MCI_MSF_SECOND (BYVAL msf AS DWORD) AS BYTE
   ! MOV AL, msf[1]
   ! MOV FUNCTION, AL
END FUNCTION

'#define MCI_MSF_FRAME(msf)              ((BYTE)((msf)>>16))
FUNCTION MCI_MSF_FRAME (BYVAL msf AS DWORD) AS BYTE
   ! MOV AL, msf[2]
   ! MOV FUNCTION, AL
END FUNCTION

'#define MCI_MAKE_MSF(m, s, f)           ((DWORD)(((BYTE)(m) | \
'                                                  ((WORD)(s)<<8)) | \
'                                                 (((DWORD)(BYTE)(f))<<16)))
FUNCTION MCI_MAKE_MSF (BYVAL m AS BYTE, BYVAL s AS BYTE, BYVAL f AS BYTE) AS DWORD
   ! MOV AL, m
   ! MOV AH, s
   ! MOV DL, f
   ! Sub DH, DH
   ! MOV FUNCTION[0], AX
   ! MOV FUNCTION[2], DX
END FUNCTION

'#define MCI_TMSF_TRACK(tmsf)            ((BYTE)(tmsf))
FUNCTION MCI_TMSF_TRACK (BYVAL tmsf AS DWORD) AS BYTE
   ! MOV AL, tmsf[0]
   ! MOV FUNCTION, AL
END FUNCTION

'#define MCI_TMSF_MINUTE(tmsf)           ((BYTE)(((WORD)(tmsf)) >> 8))
FUNCTION MCI_TMSF_MINUTE (BYVAL tmsf AS DWORD) AS BYTE
   ! MOV AL, tmsf[1]
   ! MOV FUNCTION, AL
END FUNCTION

'#define MCI_TMSF_SECOND(tmsf)           ((BYTE)((tmsf)>>16))
FUNCTION MCI_TMSF_SECOND (BYVAL tmsf AS DWORD) AS BYTE
   ! MOV AL, tmsf[2]
   ! MOV FUNCTION, AL
END FUNCTION

'#define MCI_TMSF_FRAME(tmsf)            ((BYTE)((tmsf)>>24))
FUNCTION MCI_TMSF_FRAME (BYVAL tmsf AS DWORD) AS BYTE
   ! MOV AL, tmsf[3]
   ! MOV FUNCTION, AL
END FUNCTION

'#define MCI_MAKE_TMSF(t, m, s, f)       ((DWORD)(((BYTE)(t) | \
'                                                  ((WORD)(m)<<8)) | \
'                                                 (((DWORD)(BYTE)(s) | \
'                                                   ((WORD)(f)<<8))<<16)))
FUNCTION MCI_MAKE_TMSF(BYVAL t AS BYTE, BYVAL m AS BYTE, BYVAL s AS BYTE, BYVAL f AS BYTE) AS DWORD
   ! MOV AL, t
   ! MOV AH, m
   ! MOV DL, s
   ! MOV DH, f
   ! MOV FUNCTION[0], AX
   ! MOV FUNCTION[2], DX
END FUNCTION

'#define MCI_HMS_HOUR(hms)               ((BYTE)(hms))
FUNCTION MCI_HMS_HOUR (BYVAL hms AS DWORD) AS BYTE
   ! MOV AL, hms[0]
   ! MOV FUNCTION, AL
END FUNCTION

'#define MCI_HMS_MINUTE(hms)             ((BYTE)(((WORD)(hms)) >> 8))
FUNCTION MCI_HMS_MINUTE (BYVAL hms AS DWORD) AS BYTE
   ! MOV AL, hms[1]
   ! MOV FUNCTION, AL
END FUNCTION

'#define MCI_HMS_SECOND(hms)             ((BYTE)((hms)>>16))
FUNCTION MCI_HMS_SECOND (BYVAL hms AS DWORD) AS BYTE
   ! MOV AL, hms[2]
   ! MOV FUNCTION, AL
END FUNCTION

'#define MCI_MAKE_HMS(h, m, s)           ((DWORD)(((BYTE)(h) | \
'                                                  ((WORD)(m)<<8)) | \
'                                                 (((DWORD)(BYTE)(s))<<16)))
FUNCTION MCI_MAKE_HMS (BYVAL h AS BYTE, BYVAL m AS BYTE, BYVAL s AS BYTE) AS DWORD
   ! MOV AL, h
   ! MOV AH, m
   ! MOV DL, s
   ! Sub DH, DH
   ! MOV FUNCTION[0], AX
   ! MOV FUNCTION[2], DX
END FUNCTION