; ---------------------------------------------------------------------- ; -- ; -- Blitz_Basic_Endian.bb ; -- ; -- Functions for converting between endian formats. ; -- ; -- Author : Phil Newton (http://www.sodaware.net/) ; -- Licence : Free to use & modify. Credit appreciated but not required. ; -- Version : 1.0 ; -- ; ---------------------------------------------------------------------- ; -------------------------------------------------- ; -- Quick Function Reference ; -------------------------------------------------- ; Endian_ConvertShort ; Endian_ConvertLong ; -------------------------------------------------- ; -- API Functions ; -------------------------------------------------- ;;; Convert a short value to a different endian value. ;;; The short to change. ;;; If true, it's a signed short. ;;; The converted short. ;;; Blitz.Basic Function Endian_ConvertShort(short, isSigned = True) short = ((short And $ff00) Shr 8) Or ((short And $ff) Shl 8) ; Fix signed values If isSigned And short >= $8000 Then Return short - $10000 Else Return short EndIf End Function ;;; Convert a long value to a different endian value. ;;; The long to change. ;;; If true, it's a signed long. ;;; The converted long. ;;; Blitz.Basic Function Endian_ConvertLong(long, isSigned = True) long = (long Shr 24) Or ((long Shl 8) And $FF0000) Or ((long Shr 8) And $ff00) Or (long Shl 24) ; Fix signed values If isSigned And long >= $800000 Return long - $1000000 Else Return long End If End Function