Free Game Downloads -- Sodaware.net

Free Game Downloads -- Role Playing Games, Puzzle Games and Action Games.

Blitz_Basic_Endian.bb

Name: Blitz_Basic_Endian.bb
Version: 1.0
Released: October 26th, 2007
Description: Functions for converting between endian formats.
Direct Download: Download Now (1.78KB)

; ----------------------------------------------------------------------
; --
; -- 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
; --------------------------------------------------

;;; <summary>Convert a short value to a different endian value.</summary>
;;; <param name="short">The short to change.</param>
;;; <param name="isSigned">If true, it's a signed short.</param>
;;; <returns>The converted short.</returns>
;;; <subsystem>Blitz.Basic</subsystem>
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

;;; <summary>Convert a long value to a different endian value.</summary>
;;; <param name="long">The long to change.</param>
;;; <param name="isSigned">If true, it's a signed long.</param>
;;; <returns>The converted long.</returns>
;;; <subsystem>Blitz.Basic</subsystem>
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

Free Game Downloads | Site Map | Links | Anonymous Feedback | Contact Us

© 2005-2007 Sodaware. All rights reserved. About Us | Privacy Policy