version0.7.10

This commit is contained in:
Andreas Rumpf 2009-06-08 08:06:25 +02:00
commit 4d4b3b1c04
193 changed files with 9099 additions and 17637 deletions

2522
lib/wrappers/sdl/sdl.nim Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,421 @@
#
# $Id: sdl_gfx.pas,v 1.3 2007/05/29 21:31:04 savage Exp $
#
#
#
# $Log: sdl_gfx.pas,v $
# Revision 1.3 2007/05/29 21:31:04 savage
# Changes as suggested by Almindor for 64bit compatibility.
#
# Revision 1.2 2007/05/20 20:30:18 savage
# Initial Changes to Handle 64 Bits
#
# Revision 1.1 2005/01/03 19:08:32 savage
# Header for the SDL_Gfx library.
#
#
#
#
import
sdl
when defined(windows):
const SDLgfxLibName = "SDL_gfx.dll"
elif defined(macosx):
const SDLgfxLibName = "libSDL_gfx.dylib"
else:
const SDLgfxLibName = "libSDL_gfx.so"
const # Some rates in Hz
FPS_UPPER_LIMIT* = 200
FPS_LOWER_LIMIT* = 1
FPS_DEFAULT* = 30 # ---- Defines
SMOOTHING_OFF* = 0
SMOOTHING_ON* = 1
type
PFPSmanager* = ptr TFPSmanager
TFPSmanager*{.final.} = object # ---- Structures
framecount*: Uint32
rateticks*: float32
lastticks*: Uint32
rate*: Uint32
PColorRGBA* = ptr TColorRGBA
TColorRGBA*{.final.} = object
r*: Uint8
g*: Uint8
b*: Uint8
a*: Uint8
PColorY* = ptr TColorY
TColorY*{.final.} = object #
#
# SDL_framerate: framerate manager
#
# LGPL (c) A. Schiffler
#
#
y*: Uint8
proc SDL_initFramerate*(manager: PFPSmanager){.cdecl, importc, dynlib: SDLgfxLibName.}
proc SDL_setFramerate*(manager: PFPSmanager, rate: int): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
proc SDL_getFramerate*(manager: PFPSmanager): int{.cdecl, importc, dynlib: SDLgfxLibName.}
proc SDL_framerateDelay*(manager: PFPSmanager){.cdecl, importc, dynlib: SDLgfxLibName.}
#
#
# SDL_gfxPrimitives: graphics primitives for SDL
#
# LGPL (c) A. Schiffler
#
#
# Note: all ___Color routines expect the color to be in format 0xRRGGBBAA
# Pixel
proc pixelColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, color: Uint32): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
proc pixelRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, r: Uint8, g: Uint8,
b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# Horizontal line
proc hlineColor*(dst: PSDL_Surface, x1: Sint16, x2: Sint16, y: Sint16,
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
proc hlineRGBA*(dst: PSDL_Surface, x1: Sint16, x2: Sint16, y: Sint16, r: Uint8,
g: Uint8, b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# Vertical line
proc vlineColor*(dst: PSDL_Surface, x: Sint16, y1: Sint16, y2: Sint16,
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
proc vlineRGBA*(dst: PSDL_Surface, x: Sint16, y1: Sint16, y2: Sint16, r: Uint8,
g: Uint8, b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# Rectangle
proc rectangleColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
y2: Sint16, color: Uint32): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
proc rectangleRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
y2: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# Filled rectangle (Box)
proc boxColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
y2: Sint16, color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
proc boxRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, y2: Sint16,
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# Line
proc lineColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
y2: Sint16, color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
proc lineRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
y2: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# AA Line
proc aalineColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
y2: Sint16, color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
proc aalineRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
y2: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# Circle
proc circleColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, r: Sint16,
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
proc circleRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16, r: Uint8,
g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# AA Circle
proc aacircleColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, r: Sint16,
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
proc aacircleRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16,
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# Filled Circle
proc filledCircleColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, r: Sint16,
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
proc filledCircleRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16,
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# Ellipse
proc ellipseColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16,
ry: Sint16, color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
proc ellipseRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16,
ry: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# AA Ellipse
proc aaellipseColor*(dst: PSDL_Surface, xc: Sint16, yc: Sint16, rx: Sint16,
ry: Sint16, color: Uint32): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
proc aaellipseRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16,
ry: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# Filled Ellipse
proc filledEllipseColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16,
ry: Sint16, color: Uint32): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
proc filledEllipseRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16,
ry: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# Pie
proc pieColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16,
start: Sint16, finish: Sint16, color: Uint32): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
proc pieRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16,
start: Sint16, finish: Sint16, r: Uint8, g: Uint8, b: Uint8,
a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# Filled Pie
proc filledPieColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16,
start: Sint16, finish: Sint16, color: Uint32): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
proc filledPieRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16,
start: Sint16, finish: Sint16, r: Uint8, g: Uint8, b: Uint8,
a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# Trigon
proc trigonColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
y2: Sint16, x3: Sint16, y3: Sint16, color: Uint32): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
proc trigonRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
y2: Sint16, x3: Sint16, y3: Sint16, r: Uint8, g: Uint8,
b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# AA-Trigon
proc aatrigonColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
y2: Sint16, x3: Sint16, y3: Sint16, color: Uint32): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
proc aatrigonRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
y2: Sint16, x3: Sint16, y3: Sint16, r: Uint8, g: Uint8,
b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# Filled Trigon
proc filledTrigonColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
y2: Sint16, x3: Sint16, y3: Sint16, color: Uint32): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
proc filledTrigonRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16,
y2: Sint16, x3: Sint16, y3: Sint16, r: Uint8, g: Uint8,
b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# Polygon
proc polygonColor*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int,
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
proc polygonRGBA*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, r: Uint8,
g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# AA-Polygon
proc aapolygonColor*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int,
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
proc aapolygonRGBA*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int,
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# Filled Polygon
proc filledPolygonColor*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int,
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
proc filledPolygonRGBA*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int,
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# Bezier
# s = number of steps
proc bezierColor*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, s: int,
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
proc bezierRGBA*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, s: int,
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# Characters/Strings
proc characterColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, c: char,
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
proc characterRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, c: char, r: Uint8,
g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
proc stringColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, c: cstring,
color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
proc stringRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, c: cstring, r: Uint8,
g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
proc gfxPrimitivesSetFont*(fontdata: Pointer, cw: int, ch: int){.cdecl,
importc, dynlib: SDLgfxLibName.}
#
#
# SDL_imageFilter - bytes-image "filter" routines
# (uses inline x86 MMX optimizations if available)
#
# LGPL (c) A. Schiffler
#
#
# Comments:
# 1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary.
# 2.) Data that is not within an 8 byte boundary is processed using the C routine.
# 3.) Convolution routines do not have C routines at this time.
# Detect MMX capability in CPU
proc SDL_imageFilterMMXdetect*(): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# Force use of MMX off (or turn possible use back on)
proc SDL_imageFilterMMXoff*(){.cdecl, importc, dynlib: SDLgfxLibName.}
proc SDL_imageFilterMMXon*(){.cdecl, importc, dynlib: SDLgfxLibName.}
#
# All routines return:
# 0 OK
# -1 Error (internal error, parameter error)
#
# SDL_imageFilterAdd: D = saturation255(S1 + S2)
proc SDL_imageFilterAdd*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterMean: D = S1/2 + S2/2
proc SDL_imageFilterMean*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterSub: D = saturation0(S1 - S2)
proc SDL_imageFilterSub*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterAbsDiff: D = | S1 - S2 |
proc SDL_imageFilterAbsDiff*(Src1: cstring, Src2: cstring, Dest: cstring,
len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterMult: D = saturation(S1 * S2)
proc SDL_imageFilterMult*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterMultNor: D = S1 * S2 (non-MMX)
proc SDL_imageFilterMultNor*(Src1: cstring, Src2: cstring, Dest: cstring,
len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2)
proc SDL_imageFilterMultDivby2*(Src1: cstring, Src2: cstring, Dest: cstring,
len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2)
proc SDL_imageFilterMultDivby4*(Src1: cstring, Src2: cstring, Dest: cstring,
len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterBitAnd: D = S1 & S2
proc SDL_imageFilterBitAnd*(Src1: cstring, Src2: cstring, Dest: cstring,
len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterBitOr: D = S1 | S2
proc SDL_imageFilterBitOr*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterDiv: D = S1 / S2 (non-MMX)
proc SDL_imageFilterDiv*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterBitNegation: D = !S
proc SDL_imageFilterBitNegation*(Src1: cstring, Dest: cstring, len: int): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterAddByte: D = saturation255(S + C)
proc SDL_imageFilterAddByte*(Src1: cstring, Dest: cstring, len: int, C: char): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterAddUint: D = saturation255(S + (uint)C)
proc SDL_imageFilterAddUint*(Src1: cstring, Dest: cstring, len: int, C: int): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C)
proc SDL_imageFilterAddByteToHalf*(Src1: cstring, Dest: cstring, len: int,
C: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterSubByte: D = saturation0(S - C)
proc SDL_imageFilterSubByte*(Src1: cstring, Dest: cstring, len: int, C: char): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterSubUint: D = saturation0(S - (uint)C)
proc SDL_imageFilterSubUint*(Src1: cstring, Dest: cstring, len: int, C: int): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterShiftRight: D = saturation0(S >> N)
proc SDL_imageFilterShiftRight*(Src1: cstring, Dest: cstring, len: int, N: char): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N)
proc SDL_imageFilterShiftRightUint*(Src1: cstring, Dest: cstring, len: int,
N: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterMultByByte: D = saturation255(S * C)
proc SDL_imageFilterMultByByte*(Src1: cstring, Dest: cstring, len: int, C: char): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C)
proc SDL_imageFilterShiftRightAndMultByByte*(Src1: cstring, Dest: cstring,
len: int, N: char, C: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterShiftLeftByte: D = (S << N)
proc SDL_imageFilterShiftLeftByte*(Src1: cstring, Dest: cstring, len: int,
N: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterShiftLeftUint: D = ((uint)S << N)
proc SDL_imageFilterShiftLeftUint*(Src1: cstring, Dest: cstring, len: int,
N: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterShiftLeft: D = saturation255(S << N)
proc SDL_imageFilterShiftLeft*(Src1: cstring, Dest: cstring, len: int, N: char): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0
proc SDL_imageFilterBinarizeUsingThreshold*(Src1: cstring, Dest: cstring,
len: int, T: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0
proc SDL_imageFilterClipToRange*(Src1: cstring, Dest: cstring, len: int,
Tmin: int8, Tmax: int8): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
proc SDL_imageFilterNormalizeLinear*(Src1: cstring, Dest: cstring, len: int,
Cmin: int, Cmax: int, Nmin: int, Nmax: int): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# !!! NO C-ROUTINE FOR THESE FUNCTIONS YET !!!
# SDL_imageFilterConvolveKernel3x3Divide: Dij = saturation0and255( ... )
proc SDL_imageFilterConvolveKernel3x3Divide*(Src: cstring, Dest: cstring,
rows: int, columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterConvolveKernel5x5Divide: Dij = saturation0and255( ... )
proc SDL_imageFilterConvolveKernel5x5Divide*(Src: cstring, Dest: cstring,
rows: int, columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterConvolveKernel7x7Divide: Dij = saturation0and255( ... )
proc SDL_imageFilterConvolveKernel7x7Divide*(Src: cstring, Dest: cstring,
rows: int, columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterConvolveKernel9x9Divide: Dij = saturation0and255( ... )
proc SDL_imageFilterConvolveKernel9x9Divide*(Src: cstring, Dest: cstring,
rows: int, columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterConvolveKernel3x3ShiftRight: Dij = saturation0and255( ... )
proc SDL_imageFilterConvolveKernel3x3ShiftRight*(Src: cstring, Dest: cstring,
rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterConvolveKernel5x5ShiftRight: Dij = saturation0and255( ... )
proc SDL_imageFilterConvolveKernel5x5ShiftRight*(Src: cstring, Dest: cstring,
rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterConvolveKernel7x7ShiftRight: Dij = saturation0and255( ... )
proc SDL_imageFilterConvolveKernel7x7ShiftRight*(Src: cstring, Dest: cstring,
rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterConvolveKernel9x9ShiftRight: Dij = saturation0and255( ... )
proc SDL_imageFilterConvolveKernel9x9ShiftRight*(Src: cstring, Dest: cstring,
rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl,
importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterSobelX: Dij = saturation255( ... )
proc SDL_imageFilterSobelX*(Src: cstring, Dest: cstring, rows: int, columns: int): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# SDL_imageFilterSobelXShiftRight: Dij = saturation255( ... )
proc SDL_imageFilterSobelXShiftRight*(Src: cstring, Dest: cstring, rows: int,
columns: int, NRightShift: char): int{.
cdecl, importc, dynlib: SDLgfxLibName.}
# Align/restore stack to 32 byte boundary -- Functionality untested! --
proc SDL_imageFilterAlignStack*(){.cdecl, importc, dynlib: SDLgfxLibName.}
proc SDL_imageFilterRestoreStack*(){.cdecl, importc, dynlib: SDLgfxLibName.}
#
#
# SDL_rotozoom - rotozoomer
#
# LGPL (c) A. Schiffler
#
#
#
#
# rotozoomSurface()
#
# Rotates and zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
# 'angle' is the rotation in degrees. 'zoom' a scaling factor. If 'smooth' is 1
# then the destination 32bit surface is anti-aliased. If the surface is not 8bit
# or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
#
#
proc rotozoomSurface*(src: PSDL_Surface, angle: float64, zoom: float64,
smooth: int): PSDL_Surface{.cdecl, importc, dynlib: SDLgfxLibName.}
proc rotozoomSurfaceXY*(src: PSDL_Surface, angle: float64, zoomx: float64,
zoomy: float64, smooth: int): PSDL_Surface{.cdecl,
importc, dynlib: SDLgfxLibName.}
# Returns the size of the target surface for a rotozoomSurface() call
proc rotozoomSurfaceSize*(width: int, height: int, angle: float64,
zoom: float64, dstwidth: var int, dstheight: var int){.
cdecl, importc, dynlib: SDLgfxLibName.}
proc rotozoomSurfaceSizeXY*(width: int, height: int, angle: float64,
zoomx: float64, zoomy: float64, dstwidth: var int,
dstheight: var int){.cdecl, importc, dynlib: SDLgfxLibName.}
#
#
# zoomSurface()
#
# Zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
# 'zoomx' and 'zoomy' are scaling factors for width and height. If 'smooth' is 1
# then the destination 32bit surface is anti-aliased. If the surface is not 8bit
# or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
#
#
proc zoomSurface*(src: PSDL_Surface, zoomx: float64, zoomy: float64, smooth: int): PSDL_Surface{.
cdecl, importc, dynlib: SDLgfxLibName.}
# Returns the size of the target surface for a zoomSurface() call
proc zoomSurfaceSize*(width: int, height: int, zoomx: float64, zoomy: float64,
dstwidth: var int, dstheight: var int){.cdecl,
importc, dynlib: SDLgfxLibName.}
# implementation

View file

@ -0,0 +1,227 @@
#
# $Id: sdl_image.pas,v 1.14 2007/05/29 21:31:13 savage Exp $
#
#
#******************************************************************************
#
# Borland Delphi SDL_Image - An example image loading library for use
# with SDL
# Conversion of the Simple DirectMedia Layer Image Headers
#
# Portions created by Sam Lantinga <slouken@devolution.com> are
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
# 5635-34 Springhouse Dr.
# Pleasanton, CA 94588 (USA)
#
# All Rights Reserved.
#
# The original files are : SDL_image.h
#
# The initial developer of this Pascal code was :
# Matthias Thoma <ma.thoma@gmx.de>
#
# Portions created by Matthias Thoma are
# Copyright (C) 2000 - 2001 Matthias Thoma.
#
#
# Contributor(s)
# --------------
# Dominique Louis <Dominique@SavageSoftware.com.au>
#
# Obtained through:
# Joint Endeavour of Delphi Innovators ( Project JEDI )
#
# You may retrieve the latest version of this file at the Project
# JEDI home page, located at http://delphi-jedi.org
#
# The contents of this file are used with permission, subject to
# the Mozilla Public License Version 1.1 (the "License"); you may
# not use this file except in compliance with the License. You may
# obtain a copy of the License at
# http://www.mozilla.org/MPL/MPL-1.1.html
#
# Software distributed under the License is distributed on an
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# Description
# -----------
# A simple library to load images of various formats as SDL surfaces
#
# Requires
# --------
# SDL.pas in your search path.
#
# Programming Notes
# -----------------
# See the Aliens Demo on how to make use of this libaray
#
# Revision History
# ----------------
# April 02 2001 - MT : Initial Translation
#
# May 08 2001 - DL : Added ExternalSym derectives and copyright header
#
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
# Pascal compilers. Initial support is now included
# for GnuPascal, VirtualPascal, TMT and obviously
# continue support for Delphi Kylix and FreePascal.
#
# April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support
#
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
# better TMT Pascal support and under instruction
# from Prof. Abimbola Olowofoyeku (The African Chief),
# I have added better Gnu Pascal support
#
# April 30 2003 - DL : under instruction from David Mears AKA
# Jason Siletto, I have added FPC Linux support.
# This was compiled with fpc 1.1, so remember to set
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
#
#
# $Log: sdl_image.pas,v $
# Revision 1.14 2007/05/29 21:31:13 savage
# Changes as suggested by Almindor for 64bit compatibility.
#
# Revision 1.13 2007/05/20 20:30:54 savage
# Initial Changes to Handle 64 Bits
#
# Revision 1.12 2006/12/02 00:14:40 savage
# Updated to latest version
#
# Revision 1.11 2005/04/10 18:22:59 savage
# Changes as suggested by Michalis, thanks.
#
# Revision 1.10 2005/04/10 11:48:33 savage
# Changes as suggested by Michalis, thanks.
#
# Revision 1.9 2005/01/05 01:47:07 savage
# Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
#
# Revision 1.8 2005/01/04 23:14:44 savage
# Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
#
# Revision 1.7 2005/01/01 02:03:12 savage
# Updated to v1.2.4
#
# Revision 1.6 2004/08/14 22:54:30 savage
# Updated so that Library name defines are correctly defined for MacOS X.
#
# Revision 1.5 2004/05/10 14:10:04 savage
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
#
# Revision 1.4 2004/04/13 09:32:08 savage
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
#
# Revision 1.3 2004/04/01 20:53:23 savage
# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
#
# Revision 1.2 2004/03/30 20:23:28 savage
# Tidied up use of UNIX compiler directive.
#
# Revision 1.1 2004/02/14 23:35:42 savage
# version 1 of sdl_image, sdl_mixer and smpeg.
#
#
#
#******************************************************************************
import
sdl
when defined(windows):
const SDL_ImageLibName = "SDL_Image.dll"
elif defined(macosx):
const SDL_ImageLibName = "libSDL_image-1.2.0.dylib"
else:
const SDL_ImageLibName = "libSDL_image.so"
const
SDL_IMAGE_MAJOR_VERSION* = 1'i8
SDL_IMAGE_MINOR_VERSION* = 2'i8
SDL_IMAGE_PATCHLEVEL* = 5'i8
# This macro can be used to fill a version structure with the compile-time
# version of the SDL_image library.
proc SDL_IMAGE_VERSION*(X: var TSDL_Version)
# This function gets the version of the dynamically linked SDL_image library.
# it should NOT be used to fill a version structure, instead you should
# use the SDL_IMAGE_VERSION() macro.
#
proc IMG_Linked_Version*(): PSDL_version{.importc, dynlib: SDL_ImageLibName.}
# Load an image from an SDL data source.
# The 'type' may be one of: "BMP", "GIF", "PNG", etc.
#
# If the image format supports a transparent pixel, SDL will set the
# colorkey for the surface. You can enable RLE acceleration on the
# surface afterwards by calling:
# SDL_SetColorKey(image, SDL_RLEACCEL, image.format.colorkey);
#
proc IMG_LoadTyped_RW*(src: PSDL_RWops, freesrc: int, theType: cstring): PSDL_Surface{.
cdecl, importc, dynlib: SDL_ImageLibName.}
# Convenience functions
proc IMG_Load*(theFile: cstring): PSDL_Surface{.cdecl, importc, dynlib: SDL_ImageLibName.}
proc IMG_Load_RW*(src: PSDL_RWops, freesrc: int): PSDL_Surface{.cdecl,
importc, dynlib: SDL_ImageLibName.}
# Invert the alpha of a surface for use with OpenGL
# This function is now a no-op, and only provided for backwards compatibility.
proc IMG_InvertAlpha*(theOn: int): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
# Functions to detect a file type, given a seekable source
proc IMG_isBMP*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
proc IMG_isGIF*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
proc IMG_isJPG*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
proc IMG_isLBM*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
proc IMG_isPCX*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
proc IMG_isPNG*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
proc IMG_isPNM*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
proc IMG_isTIF*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
proc IMG_isXCF*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
proc IMG_isXPM*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
proc IMG_isXV*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
# Individual loading functions
proc IMG_LoadBMP_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
importc, dynlib: SDL_ImageLibName.}
proc IMG_LoadGIF_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
importc, dynlib: SDL_ImageLibName.}
proc IMG_LoadJPG_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
importc, dynlib: SDL_ImageLibName.}
proc IMG_LoadLBM_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
importc, dynlib: SDL_ImageLibName.}
proc IMG_LoadPCX_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
importc, dynlib: SDL_ImageLibName.}
proc IMG_LoadPNM_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
importc, dynlib: SDL_ImageLibName.}
proc IMG_LoadPNG_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
importc, dynlib: SDL_ImageLibName.}
proc IMG_LoadTGA_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
importc, dynlib: SDL_ImageLibName.}
proc IMG_LoadTIF_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
importc, dynlib: SDL_ImageLibName.}
proc IMG_LoadXCF_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
importc, dynlib: SDL_ImageLibName.}
proc IMG_LoadXPM_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
importc, dynlib: SDL_ImageLibName.}
proc IMG_LoadXV_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl,
importc, dynlib: SDL_ImageLibName.}
proc IMG_ReadXPMFromArray*(xpm: cstringArray): PSDL_Surface{.cdecl,
importc, dynlib: SDL_ImageLibName.}
# Error Macros
# We'll use SDL for reporting errors
proc IMG_SetError*(fmt: cstring)
proc IMG_GetError*(): cstring
# implementation
proc SDL_IMAGE_VERSION(X: var TSDL_Version) =
X.major = SDL_IMAGE_MAJOR_VERSION
X.minor = SDL_IMAGE_MINOR_VERSION
X.patch = SDL_IMAGE_PATCHLEVEL
proc IMG_SetError(fmt: cstring) =
SDL_SetError(fmt)
proc IMG_GetError(): cstring =
result = SDL_GetError()

View file

@ -0,0 +1,737 @@
#******************************************************************************
#
# $Id: sdl_mixer.pas,v 1.18 2007/05/29 21:31:44 savage Exp $
#
#
#
# Borland Delphi SDL_Mixer - Simple DirectMedia Layer Mixer Library
# Conversion of the Simple DirectMedia Layer Headers
#
# Portions created by Sam Lantinga <slouken@devolution.com> are
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
# 5635-34 Springhouse Dr.
# Pleasanton, CA 94588 (USA)
#
# All Rights Reserved.
#
# The original files are : SDL_mixer.h
# music_cmd.h
# wavestream.h
# timidity.h
# playmidi.h
# music_ogg.h
# mikmod.h
#
# The initial developer of this Pascal code was :
# Dominqiue Louis <Dominique@SavageSoftware.com.au>
#
# Portions created by Dominqiue Louis are
# Copyright (C) 2000 - 2001 Dominqiue Louis.
#
#
# Contributor(s)
# --------------
# Matthias Thoma <ma.thoma@gmx.de>
#
# Obtained through:
# Joint Endeavour of Delphi Innovators ( Project JEDI )
#
# You may retrieve the latest version of this file at the Project
# JEDI home page, located at http://delphi-jedi.org
#
# The contents of this file are used with permission, subject to
# the Mozilla Public License Version 1.1 (the "License"); you may
# not use this file except in compliance with the License. You may
# obtain a copy of the License at
# http://www.mozilla.org/MPL/MPL-1.1.html
#
# Software distributed under the License is distributed on an
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# Description
# -----------
#
#
#
#
#
#
#
# Requires
# --------
# SDL.pas & SMPEG.pas somewhere within your search path.
#
# Programming Notes
# -----------------
# See the Aliens Demo to see how this library is used
#
# Revision History
# ----------------
# April 02 2001 - DL : Initial Translation
#
# February 02 2002 - DL : Update to version 1.2.1
#
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
# Pascal compilers. Initial support is now included
# for GnuPascal, VirtualPascal, TMT and obviously
# continue support for Delphi Kylix and FreePascal.
#
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
# better TMT Pascal support and under instruction
# from Prof. Abimbola Olowofoyeku (The African Chief),
# I have added better Gnu Pascal support
#
# April 30 2003 - DL : under instruction from David Mears AKA
# Jason Siletto, I have added FPC Linux support.
# This was compiled with fpc 1.1, so remember to set
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
#
#
# $Log: sdl_mixer.pas,v $
# Revision 1.18 2007/05/29 21:31:44 savage
# Changes as suggested by Almindor for 64bit compatibility.
#
# Revision 1.17 2007/05/20 20:31:17 savage
# Initial Changes to Handle 64 Bits
#
# Revision 1.16 2006/12/02 00:16:17 savage
# Updated to latest version
#
# Revision 1.15 2005/04/10 11:48:33 savage
# Changes as suggested by Michalis, thanks.
#
# Revision 1.14 2005/02/24 20:20:07 savage
# Changed definition of MusicType and added GetMusicType function
#
# Revision 1.13 2005/01/05 01:47:09 savage
# Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
#
# Revision 1.12 2005/01/04 23:14:56 savage
# Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
#
# Revision 1.11 2005/01/01 02:05:19 savage
# Updated to v1.2.6
#
# Revision 1.10 2004/09/12 21:45:17 savage
# Robert Reed spotted that Mix_SetMusicPosition was missing from the conversion, so this has now been added.
#
# Revision 1.9 2004/08/27 21:48:24 savage
# IFDEFed out Smpeg support on MacOS X
#
# Revision 1.8 2004/08/14 22:54:30 savage
# Updated so that Library name defines are correctly defined for MacOS X.
#
# Revision 1.7 2004/05/10 14:10:04 savage
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
#
# Revision 1.6 2004/04/13 09:32:08 savage
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
#
# Revision 1.5 2004/04/01 20:53:23 savage
# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
#
# Revision 1.4 2004/03/31 22:20:02 savage
# Windows unit not used in this file, so it was removed to keep the code tidy.
#
# Revision 1.3 2004/03/31 10:05:08 savage
# Better defines for Endianess under FreePascal and Borland compilers.
#
# Revision 1.2 2004/03/30 20:23:28 savage
# Tidied up use of UNIX compiler directive.
#
# Revision 1.1 2004/02/14 23:35:42 savage
# version 1 of sdl_image, sdl_mixer and smpeg.
#
#
#
#******************************************************************************
import
sdl, smpeg
when defined(windows):
const SDL_MixerLibName = "SDL_mixer.dll"
elif defined(macosx):
const SDL_MixerLibName = "libSDL_mixer-1.2.0.dylib"
else:
const SDL_MixerLibName = "libSDL_mixer.so"
const
SDL_MIXER_MAJOR_VERSION* = 1'i8
SDL_MIXER_MINOR_VERSION* = 2'i8
SDL_MIXER_PATCHLEVEL* = 7'i8 # Backwards compatibility
MIX_MAJOR_VERSION* = SDL_MIXER_MAJOR_VERSION
MIX_MINOR_VERSION* = SDL_MIXER_MINOR_VERSION
MIX_PATCHLEVEL* = SDL_MIXER_PATCHLEVEL # SDL_Mixer.h constants
# The default mixer has 8 simultaneous mixing channels
MIX_CHANNELS* = 8 # Good default values for a PC soundcard
MIX_DEFAULT_FREQUENCY* = 22050
when defined(IA32):
const
MIX_DEFAULT_FORMAT* = AUDIO_S16LSB
else:
const
MIX_DEFAULT_FORMAT* = AUDIO_S16MSB
const
MIX_DEFAULT_CHANNELS* = 2
MIX_MAX_VOLUME* = 128 # Volume of a chunk
PATH_MAX* = 255 # mikmod.h constants
#*
# * Library version
# *
LIBMIKMOD_VERSION_MAJOR* = 3
LIBMIKMOD_VERSION_MINOR* = 1
LIBMIKMOD_REVISION* = 8
LIBMIKMOD_VERSION* = ((LIBMIKMOD_VERSION_MAJOR shl 16) or
(LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION))
type #music_cmd.h types
PMusicCMD* = ptr TMusicCMD
TMusicCMD*{.final.} = object #wavestream.h types
filename*: array[0..PATH_MAX - 1, char]
cmd*: array[0..PATH_MAX - 1, char]
pid*: TSYS_ThreadHandle
PWAVStream* = ptr TWAVStream
TWAVStream*{.final.} = object #playmidi.h types
wavefp*: Pointer
start*: int32
stop*: int32
cvt*: TSDL_AudioCVT
PMidiEvent* = ptr TMidiEvent
TMidiEvent*{.final.} = object
time*: int32
channel*: uint8
type_*: uint8
a*: uint8
b*: uint8
PMidiSong* = ptr TMidiSong
TMidiSong*{.final.} = object #music_ogg.h types
samples*: int32
events*: PMidiEvent
POGG_Music* = ptr TOGG_Music
TOGG_Music*{.final.} = object # mikmod.h types
#*
# * Error codes
# *
playing*: int
volume*: int #vf: OggVorbis_File;
section*: int
cvt*: TSDL_AudioCVT
len_available*: int
snd_available*: PUint8
TErrorEnum* = enum
MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING,
MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE,
MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER,
MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM,
MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE,
MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO,
MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW,
MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT,
MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS,
MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED,
MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC,
MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE,
MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT,
MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT,
MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD,
MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY,
MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE,
MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT,
MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX
PMODULE* = ptr TMODULE
TMODULE*{.final.} = object
PUNIMOD* = ptr TUNIMOD
TUNIMOD* = TMODULE #SDL_mixer.h types
# The internal format for an audio chunk
PMix_Chunk* = ptr TMix_Chunk
TMix_Chunk*{.final.} = object
allocated*: int
abuf*: PUint8
alen*: Uint32
volume*: Uint8 # Per-sample volume, 0-128
Mix_Chunk* = TMix_Chunk # The different fading types supported
TMix_Fading* = enum
MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN
Mix_Fading* = TMix_Fading
TMix_MusicType* = enum
MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3
Mix_MusicType* = TMix_MusicType #
# TMusicUnion = record
# case XXX: Byte of
# 0 : ( cmd : PMusicCMD );
# 1 : ( wave : PWAVStream );
# 2 : ( module : PUNIMOD );
# 3 : ( midi : TMidiSong );
# 4 : ( ogg : POGG_music );
# {$IFNDEF DARWIN}
# 5 : ( mp3 : PSMPEG );
# {$ENDIF}
# end;
PMix_Music* = ptr TMix_Music
TMix_Music*{.final.} = object # The internal format for a music chunk interpreted via mikmod
type_*: TMix_MusicType # other fields are not aviable
# data : TMusicUnion;
# fading : TMix_Fading;
# fade_volume : integer;
# fade_step : integer;
# fade_steps : integer;
# error : integer;
TMixFunction* = proc (udata: Pointer, stream: PUint8, length: int): Pointer{.
cdecl.} # This macro can be used to fill a version structure with the compile-time
# version of the SDL_mixer library.
proc SDL_MIXER_VERSION*(X: var TSDL_Version)
# This function gets the version of the dynamically linked SDL_mixer library.
# It should NOT be used to fill a version structure, instead you should use the
# SDL_MIXER_VERSION() macro.
proc Mix_Linked_Version*(): PSDL_version{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Open the mixer with a certain audio format
proc Mix_OpenAudio*(frequency: int, format: Uint16, channels: int,
chunksize: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Dynamically change the number of channels managed by the mixer.
# If decreasing the number of channels, the upper channels are
# stopped.
# This function returns the new number of allocated channels.
#
proc Mix_AllocateChannels*(numchannels: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Find out what the actual audio device parameters are.
# This function returns 1 if the audio has been opened, 0 otherwise.
#
proc Mix_QuerySpec*(frequency: var int, format: var Uint16, channels: var int): int{.
cdecl, importc, dynlib: SDL_MixerLibName.}
# Load a wave file or a music (.mod .s3m .it .xm) file
proc Mix_LoadWAV_RW*(src: PSDL_RWops, freesrc: int): PMix_Chunk{.cdecl,
importc, dynlib: SDL_MixerLibName.}
proc Mix_LoadWAV*(filename: cstring): PMix_Chunk
proc Mix_LoadMUS*(filename: cstring): PMix_Music{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Load a wave file of the mixer format from a memory buffer
proc Mix_QuickLoad_WAV*(mem: PUint8): PMix_Chunk{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Free an audio chunk previously loaded
proc Mix_FreeChunk*(chunk: PMix_Chunk){.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_FreeMusic*(music: PMix_Music){.cdecl, importc, dynlib: SDL_MixerLibName.}
# Find out the music format of a mixer music, or the currently playing
# music, if 'music' is NULL.
proc Mix_GetMusicType*(music: PMix_Music): TMix_MusicType{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Set a function that is called after all mixing is performed.
# This can be used to provide real-time visual display of the audio stream
# or add a custom mixer filter for the stream data.
#
proc Mix_SetPostMix*(mix_func: TMixFunction, arg: Pointer){.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Add your own music player or additional mixer function.
# If 'mix_func' is NULL, the default music player is re-enabled.
#
proc Mix_HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Add your own callback when the music has finished playing.
#
proc Mix_HookMusicFinished*(music_finished: Pointer){.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Get a pointer to the user data for the current music hook
proc Mix_GetMusicHookData*(): Pointer{.cdecl, importc, dynlib: SDL_MixerLibName.}
#* Add your own callback when a channel has finished playing. NULL
# * to disable callback.*
type
TChannel_finished* = proc (channel: int){.cdecl.}
proc Mix_ChannelFinished*(channel_finished: TChannel_finished){.cdecl,
importc, dynlib: SDL_MixerLibName.}
const
MIX_CHANNEL_POST* = - 2
# This is the format of a special effect callback:
# myeffect(int chan, void *stream, int len, void *udata);
#
# (chan) is the channel number that your effect is affecting. (stream) is
# the buffer of data to work upon. (len) is the size of (stream), and
# (udata) is a user-defined bit of data, which you pass as the last arg of
# Mix_RegisterEffect(), and is passed back unmolested to your callback.
# Your effect changes the contents of (stream) based on whatever parameters
# are significant, or just leaves it be, if you prefer. You can do whatever
# you like to the buffer, though, and it will continue in its changed state
# down the mixing pipeline, through any other effect functions, then finally
# to be mixed with the rest of the channels and music for the final output
# stream.
#
type
TMix_EffectFunc* = proc (chan: int, stream: Pointer, length: int,
udata: Pointer): Pointer{.cdecl.}
# * This is a callback that signifies that a channel has finished all its
# * loops and has completed playback. This gets called if the buffer
# * plays out normally, or if you call Mix_HaltChannel(), implicitly stop
# * a channel via Mix_AllocateChannels(), or unregister a callback while
# * it's still playing.
TMix_EffectDone* = proc (chan: int, udata: Pointer): Pointer{.cdecl.}
#* Register a special effect function. At mixing time, the channel data is
# * copied into a buffer and passed through each registered effect function.
# * After it passes through all the functions, it is mixed into the final
# * output stream. The copy to buffer is performed once, then each effect
# * function performs on the output of the previous effect. Understand that
# * this extra copy to a buffer is not performed if there are no effects
# * registered for a given chunk, which saves CPU cycles, and any given
# * effect will be extra cycles, too, so it is crucial that your code run
# * fast. Also note that the data that your function is given is in the
# * format of the sound device, and not the format you gave to Mix_OpenAudio(),
# * although they may in reality be the same. This is an unfortunate but
# * necessary speed concern. Use Mix_QuerySpec() to determine if you can
# * handle the data before you register your effect, and take appropriate
# * actions.
# * You may also specify a callback (Mix_EffectDone_t) that is called when
# * the channel finishes playing. This gives you a more fine-grained control
# * than Mix_ChannelFinished(), in case you need to free effect-specific
# * resources, etc. If you don't need this, you can specify NULL.
# * You may set the callbacks before or after calling Mix_PlayChannel().
# * Things like Mix_SetPanning() are just internal special effect functions,
# * so if you are using that, you've already incurred the overhead of a copy
# * to a separate buffer, and that these effects will be in the queue with
# * any functions you've registered. The list of registered effects for a
# * channel is reset when a chunk finishes playing, so you need to explicitly
# * set them with each call to Mix_PlayChannel*().
# * You may also register a special effect function that is to be run after
# * final mixing occurs. The rules for these callbacks are identical to those
# * in Mix_RegisterEffect, but they are run after all the channels and the
# * music have been mixed into a single stream, whereas channel-specific
# * effects run on a given channel before any other mixing occurs. These
# * global effect callbacks are call "posteffects". Posteffects only have
# * their Mix_EffectDone_t function called when they are unregistered (since
# * the main output stream is never "done" in the same sense as a channel).
# * You must unregister them manually when you've had enough. Your callback
# * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
# * processing is considered a posteffect.
# *
# * After all these effects have finished processing, the callback registered
# * through Mix_SetPostMix() runs, and then the stream goes to the audio
# * device.
# *
# * returns zero if error (no such channel), nonzero if added.
# * Error messages can be retrieved from Mix_GetError().
# *
proc Mix_RegisterEffect*(chan: int, f: TMix_EffectFunc, d: TMix_EffectDone,
arg: Pointer): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
#* You may not need to call this explicitly, unless you need to stop an
# * effect from processing in the middle of a chunk's playback.
# * Posteffects are never implicitly unregistered as they are for channels,
# * but they may be explicitly unregistered through this function by
# * specifying MIX_CHANNEL_POST for a channel.
# * returns zero if error (no such channel or effect), nonzero if removed.
# * Error messages can be retrieved from Mix_GetError().
# *
proc Mix_UnregisterEffect*(channel: int, f: TMix_EffectFunc): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
#* You may not need to call this explicitly, unless you need to stop all
# * effects from processing in the middle of a chunk's playback. Note that
# * this will also shut off some internal effect processing, since
# * Mix_SetPanning( ) and others may use this API under the hood.This is
# * called internally when a channel completes playback.
# * Posteffects are never implicitly unregistered as they are for channels,
# * but they may be explicitly unregistered through this function by
# * specifying MIX_CHANNEL_POST for a channel.
# * returns zero if error( no such channel ), nonzero if all effects removed.
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_UnregisterAllEffects*(channel: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
const
MIX_EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED"
# * These are the internally - defined mixing effects.They use the same API that
# * effects defined in the application use, but are provided here as a
# * convenience.Some effects can reduce their quality or use more memory in
# * the name of speed; to enable this, make sure the environment variable
# * MIX_EFFECTSMAXSPEED( see above ) is defined before you call
# * Mix_OpenAudio( ).
# *
#* set the panning of a channel.The left and right channels are specified
# * as integers between 0 and 255, quietest to loudest, respectively.
# *
# * Technically, this is just individual volume control for a sample with
# * two( stereo )channels, so it can be used for more than just panning.
# * if you want real panning, call it like this :
# *
# * Mix_SetPanning( channel, left, 255 - left );
# *
# * ...which isn't so hard.
# *
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
# * the panning will be done to the final mixed stream before passing it on
# * to the audio device.
# *
# * This uses the Mix_RegisterEffect( )API internally, and returns without
# * registering the effect function if the audio device is not configured
# * for stereo output.Setting both( left ) and ( right ) to 255 causes this
# * effect to be unregistered, since that is the data's normal state.
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if panning effect enabled.Note that an audio device in mono
# * mode is a no - op, but this call will return successful in that case .
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_SetPanning*(channel: int, left: Uint8, right: Uint8): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# * set the position ofa channel.( angle ) is an integer from 0 to 360, that
# * specifies the location of the sound in relation to the listener.( angle )
# * will be reduced as neccesary( 540 becomes 180 degrees, -100 becomes 260 ).
# * Angle 0 is due north, and rotates clockwise as the value increases.
# * for efficiency, the precision of this effect may be limited( angles 1
# * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
# * ( distance ) is an integer between 0 and 255 that specifies the space
# * between the sound and the listener.The larger the number, the further
# * away the sound is .Using 255 does not guarantee that the channel will be
# * culled from the mixing process or be completely silent.For efficiency,
# * the precision of this effect may be limited( distance 0 through 5 might
# * all produce the same effect, 6 through 10 are equal, etc ).Setting( angle )
# * and ( distance ) to 0 unregisters this effect, since the data would be
# * unchanged.
# *
# * if you need more precise positional audio, consider using OpenAL for
# * spatialized effects instead of SDL_mixer.This is only meant to be a
# * basic effect for simple "3D" games.
# *
# * if the audio device is configured for mono output, then you won't get
# * any effectiveness from the angle; however, distance attenuation on the
# * channel will still occur.While this effect will function with stereo
# * voices, it makes more sense to use voices with only one channel of sound,
# * so when they are mixed through this effect, the positioning will sound
# * correct.You can convert them to mono through SDL before giving them to
# * the mixer in the first place if you like.
# *
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
# * the positioning will be done to the final mixed stream before passing it
# * on to the audio device.
# *
# * This is a convenience wrapper over Mix_SetDistance( ) and Mix_SetPanning( ).
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if position effect is enabled.
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_SetPosition*(channel: int, angle: Sint16, distance: Uint8): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
#* set the "distance" of a channel.( distance ) is an integer from 0 to 255
# * that specifies the location of the sound in relation to the listener.
# * Distance 0 is overlapping the listener, and 255 is as far away as possible
# * A distance of 255 does not guarantee silence; in such a case , you might
# * want to try changing the chunk's volume, or just cull the sample from the
# * mixing process with Mix_HaltChannel( ).
# * for efficiency, the precision of this effect may be limited( distances 1
# * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
# * ( distance ) is an integer between 0 and 255 that specifies the space
# * between the sound and the listener.The larger the number, the further
# * away the sound is .
# * Setting( distance ) to 0 unregisters this effect, since the data would be
# * unchanged.
# * if you need more precise positional audio, consider using OpenAL for
# * spatialized effects instead of SDL_mixer.This is only meant to be a
# * basic effect for simple "3D" games.
# *
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
# * the distance attenuation will be done to the final mixed stream before
# * passing it on to the audio device.
# *
# * This uses the Mix_RegisterEffect( )API internally.
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if position effect is enabled.
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_SetDistance*(channel: int, distance: Uint8): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# *
# * !!! FIXME : Haven't implemented, since the effect goes past the
# * end of the sound buffer.Will have to think about this.
# * - -ryan.
# * /
# { if 0
# { * Causes an echo effect to be mixed into a sound.( echo ) is the amount
# * of echo to mix.0 is no echo, 255 is infinite( and probably not
# * what you want ).
# *
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
# * the reverbing will be done to the final mixed stream before passing it on
# * to the audio device.
# *
# * This uses the Mix_RegisterEffect( )API internally.If you specify an echo
# * of zero, the effect is unregistered, as the data is already in that state.
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if reversing effect is enabled.
# * Error messages can be retrieved from Mix_GetError( ).
# *
# extern no_parse_DECLSPEC int Mix_SetReverb( int channel, Uint8 echo );
# #E ndif
# * Causes a channel to reverse its stereo.This is handy if the user has his
# * speakers hooked up backwards, or you would like to have a minor bit of
# * psychedelia in your sound code. : )Calling this function with ( flip )
# * set to non - zero reverses the chunks's usual channels. If (flip) is zero,
# * the effect is unregistered.
# *
# * This uses the Mix_RegisterEffect( )API internally, and thus is probably
# * more CPU intensive than having the user just plug in his speakers
# * correctly.Mix_SetReverseStereo( )returns without registering the effect
# * function if the audio device is not configured for stereo output.
# *
# * if you specify MIX_CHANNEL_POST for ( channel ), then this the effect is used
# * on the final mixed stream before sending it on to the audio device( a
# * posteffect ).
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if reversing effect is enabled.Note that an audio device in mono
# * mode is a no - op, but this call will return successful in that case .
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_SetReverseStereo*(channel: int, flip: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# end of effects API. - -ryan. *
# Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
# them dynamically to the next sample if requested with a -1 value below.
# Returns the number of reserved channels.
#
proc Mix_ReserveChannels*(num: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Channel grouping functions
# Attach a tag to a channel. A tag can be assigned to several mixer
# channels, to form groups of channels.
# If 'tag' is -1, the tag is removed (actually -1 is the tag used to
# represent the group of all the channels).
# Returns true if everything was OK.
#
proc Mix_GroupChannel*(which: int, tag: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Assign several consecutive channels to a group
proc Mix_GroupChannels*(`from`: int, `to`: int, tag: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Finds the first available channel in a group of channels
proc Mix_GroupAvailable*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Returns the number of channels in a group. This is also a subtle
# way to get the total number of channels when 'tag' is -1
#
proc Mix_GroupCount*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Finds the "oldest" sample playing in a group of channels
proc Mix_GroupOldest*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Finds the "most recent" (i.e. last) sample playing in a group of channels
proc Mix_GroupNewer*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# The same as above, but the sound is played at most 'ticks' milliseconds
proc Mix_PlayChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int,
ticks: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Play an audio chunk on a specific channel.
# If the specified channel is -1, play on the first free channel.
# If 'loops' is greater than zero, loop the sound that many times.
# If 'loops' is -1, loop inifinitely (~65000 times).
# Returns which channel was used to play the sound.
#
proc Mix_PlayChannel*(channel: int, chunk: PMix_Chunk, loops: int): int
proc Mix_PlayMusic*(music: PMix_Music, loops: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions
proc Mix_FadeInMusic*(music: PMix_Music, loops: int, ms: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
proc Mix_FadeInChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int,
ms: int, ticks: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
proc Mix_FadeInChannel*(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int
# Set the volume in the range of 0-128 of a specific channel or chunk.
# If the specified channel is -1, set volume for all channels.
# Returns the original volume.
# If the specified volume is -1, just return the current volume.
#
proc Mix_Volume*(channel: int, volume: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
proc Mix_VolumeChunk*(chunk: PMix_Chunk, volume: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
proc Mix_VolumeMusic*(volume: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Halt playing of a particular channel
proc Mix_HaltChannel*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_HaltGroup*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_HaltMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Change the expiration delay for a particular channel.
# The sample will stop playing after the 'ticks' milliseconds have elapsed,
# or remove the expiration if 'ticks' is -1
#
proc Mix_ExpireChannel*(channel: int, ticks: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Halt a channel, fading it out progressively till it's silent
# The ms parameter indicates the number of milliseconds the fading
# will take.
#
proc Mix_FadeOutChannel*(which: int, ms: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
proc Mix_FadeOutGroup*(tag: int, ms: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_FadeOutMusic*(ms: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Query the fading status of a channel
proc Mix_FadingMusic*(): TMix_Fading{.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_FadingChannel*(which: int): TMix_Fading{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Pause/Resume a particular channel
proc Mix_Pause*(channel: int){.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_Resume*(channel: int){.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_Paused*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Pause/Resume the music stream
proc Mix_PauseMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_ResumeMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_RewindMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_PausedMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Set the current position in the music stream.
# This returns 0 if successful, or -1 if it failed or isn't implemented.
# This function is only implemented for MOD music formats (set pattern
# order number) and for OGG music (set position in seconds), at the
# moment.
#
proc Mix_SetMusicPosition*(position: float64): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Check the status of a specific channel.
# If the specified channel is -1, check all channels.
#
proc Mix_Playing*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_PlayingMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Stop music and set external music playback command
proc Mix_SetMusicCMD*(command: cstring): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Synchro value is set by MikMod from modules while playing
proc Mix_SetSynchroValue*(value: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_GetSynchroValue*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
#
# Get the Mix_Chunk currently associated with a mixer channel
# Returns nil if it's an invalid channel, or there's no chunk associated.
#
proc Mix_GetChunk*(channel: int): PMix_Chunk{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Close the mixer, halting all playing audio
proc Mix_CloseAudio*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
# We'll use SDL for reporting errors
proc Mix_SetError*(fmt: cstring)
proc Mix_GetError*(): cstring
# implementation
proc SDL_MIXER_VERSION(X: var TSDL_version) =
X.major = SDL_MIXER_MAJOR_VERSION
X.minor = SDL_MIXER_MINOR_VERSION
X.patch = SDL_MIXER_PATCHLEVEL
proc Mix_LoadWAV(filename: cstring): PMix_Chunk =
result = Mix_LoadWAV_RW(SDL_RWFromFile(filename, "rb"), 1)
proc Mix_PlayChannel(channel: int, chunk: PMix_Chunk, loops: int): int =
result = Mix_PlayChannelTimed(channel, chunk, loops, - 1)
proc Mix_FadeInChannel(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int =
result = Mix_FadeInChannelTimed(channel, chunk, loops, ms, - 1)
proc Mix_SetError(fmt: cstring) =
SDL_SetError(fmt)
proc Mix_GetError(): cstring =
result = SDL_GetError()

View file

@ -0,0 +1,572 @@
#******************************************************************************
# Copy of SDL_Mixer without smpeg dependency and mp3 support
#******************************************************************************
import
sdl
when defined(windows):
const SDL_MixerLibName = "SDL_mixer.dll"
elif defined(macosx):
const SDL_MixerLibName = "libSDL_mixer-1.2.0.dylib"
else:
const SDL_MixerLibName = "libSDL_mixer.so"
const
SDL_MIXER_MAJOR_VERSION* = 1'i8
SDL_MIXER_MINOR_VERSION* = 2'i8
SDL_MIXER_PATCHLEVEL* = 7'i8 # Backwards compatibility
MIX_MAJOR_VERSION* = SDL_MIXER_MAJOR_VERSION
MIX_MINOR_VERSION* = SDL_MIXER_MINOR_VERSION
MIX_PATCHLEVEL* = SDL_MIXER_PATCHLEVEL # SDL_Mixer.h constants
# The default mixer has 8 simultaneous mixing channels
MIX_CHANNELS* = 8 # Good default values for a PC soundcard
MIX_DEFAULT_FREQUENCY* = 22050
when defined(IA32):
const
MIX_DEFAULT_FORMAT* = AUDIO_S16LSB
else:
const
MIX_DEFAULT_FORMAT* = AUDIO_S16MSB
const
MIX_DEFAULT_CHANNELS* = 2
MIX_MAX_VOLUME* = 128 # Volume of a chunk
PATH_MAX* = 255 # mikmod.h constants
#*
# * Library version
# *
LIBMIKMOD_VERSION_MAJOR* = 3
LIBMIKMOD_VERSION_MINOR* = 1
LIBMIKMOD_REVISION* = 8
LIBMIKMOD_VERSION* = ((LIBMIKMOD_VERSION_MAJOR shl 16) or
(LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION))
type #music_cmd.h types
PMusicCMD* = ptr TMusicCMD
TMusicCMD*{.final.} = object #wavestream.h types
filename*: array[0..PATH_MAX - 1, char]
cmd*: array[0..PATH_MAX - 1, char]
pid*: TSYS_ThreadHandle
PWAVStream* = ptr TWAVStream
TWAVStream*{.final.} = object #playmidi.h types
wavefp*: Pointer
start*: int32
stop*: int32
cvt*: TSDL_AudioCVT
PMidiEvent* = ptr TMidiEvent
TMidiEvent*{.final.} = object
time*: int32
channel*: uint8
type_*: uint8
a*: uint8
b*: uint8
PMidiSong* = ptr TMidiSong
TMidiSong*{.final.} = object #music_ogg.h types
samples*: int32
events*: PMidiEvent
POGG_Music* = ptr TOGG_Music
TOGG_Music*{.final.} = object # mikmod.h types
#*
# * Error codes
# *
playing*: int
volume*: int #vf: OggVorbis_File;
section*: int
cvt*: TSDL_AudioCVT
len_available*: int
snd_available*: PUint8
TErrorEnum* = enum
MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING,
MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE,
MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER,
MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM,
MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE,
MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO,
MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW,
MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT,
MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS,
MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED,
MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC,
MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE,
MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT,
MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT,
MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD,
MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY,
MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE,
MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT,
MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX
PMODULE* = ptr TMODULE
TMODULE*{.final.} = object
PUNIMOD* = ptr TUNIMOD
TUNIMOD* = TMODULE #SDL_mixer.h types
# The internal format for an audio chunk
PMix_Chunk* = ptr TMix_Chunk
TMix_Chunk*{.final.} = object
allocated*: int
abuf*: PUint8
alen*: Uint32
volume*: Uint8 # Per-sample volume, 0-128
Mix_Chunk* = TMix_Chunk # The different fading types supported
TMix_Fading* = enum
MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN
Mix_Fading* = TMix_Fading
TMix_MusicType* = enum
MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG
PMix_Music* = ptr TMix_Music
TMix_Music*{.final.} = object
type_*: TMix_MusicType
TMixFunction* = proc (udata: Pointer, stream: PUint8, length: int): Pointer{.
cdecl.} # This macro can be used to fill a version structure with the compile-time
# version of the SDL_mixer library.
proc SDL_MIXER_VERSION*(X: var TSDL_Version)
# This function gets the version of the dynamically linked SDL_mixer library.
# It should NOT be used to fill a version structure, instead you should use the
# SDL_MIXER_VERSION() macro.
proc Mix_Linked_Version*(): PSDL_version{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Open the mixer with a certain audio format
proc Mix_OpenAudio*(frequency: int, format: Uint16, channels: int,
chunksize: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Dynamically change the number of channels managed by the mixer.
# If decreasing the number of channels, the upper channels are
# stopped.
# This function returns the new number of allocated channels.
#
proc Mix_AllocateChannels*(numchannels: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Find out what the actual audio device parameters are.
# This function returns 1 if the audio has been opened, 0 otherwise.
#
proc Mix_QuerySpec*(frequency: var int, format: var Uint16, channels: var int): int{.
cdecl, importc, dynlib: SDL_MixerLibName.}
# Load a wave file or a music (.mod .s3m .it .xm) file
proc Mix_LoadWAV_RW*(src: PSDL_RWops, freesrc: int): PMix_Chunk{.cdecl,
importc, dynlib: SDL_MixerLibName.}
proc Mix_LoadWAV*(filename: cstring): PMix_Chunk
proc Mix_LoadMUS*(filename: cstring): PMix_Music{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Load a wave file of the mixer format from a memory buffer
proc Mix_QuickLoad_WAV*(mem: PUint8): PMix_Chunk{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Free an audio chunk previously loaded
proc Mix_FreeChunk*(chunk: PMix_Chunk){.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_FreeMusic*(music: PMix_Music){.cdecl, importc, dynlib: SDL_MixerLibName.}
# Find out the music format of a mixer music, or the currently playing
# music, if 'music' is NULL.
proc Mix_GetMusicType*(music: PMix_Music): TMix_MusicType{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Set a function that is called after all mixing is performed.
# This can be used to provide real-time visual display of the audio stream
# or add a custom mixer filter for the stream data.
#
proc Mix_SetPostMix*(mix_func: TMixFunction, arg: Pointer){.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Add your own music player or additional mixer function.
# If 'mix_func' is NULL, the default music player is re-enabled.
#
proc Mix_HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Add your own callback when the music has finished playing.
#
proc Mix_HookMusicFinished*(music_finished: Pointer){.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Get a pointer to the user data for the current music hook
proc Mix_GetMusicHookData*(): Pointer{.cdecl, importc, dynlib: SDL_MixerLibName.}
#* Add your own callback when a channel has finished playing. NULL
# * to disable callback.*
type
TChannel_finished* = proc (channel: int){.cdecl.}
proc Mix_ChannelFinished*(channel_finished: TChannel_finished){.cdecl,
importc, dynlib: SDL_MixerLibName.}
const
MIX_CHANNEL_POST* = - 2 #* This is the format of a special effect callback:
# *
# * myeffect(int chan, void *stream, int len, void *udata);
# *
# * (chan) is the channel number that your effect is affecting. (stream) is
# * the buffer of data to work upon. (len) is the size of (stream), and
# * (udata) is a user-defined bit of data, which you pass as the last arg of
# * Mix_RegisterEffect(), and is passed back unmolested to your callback.
# * Your effect changes the contents of (stream) based on whatever parameters
# * are significant, or just leaves it be, if you prefer. You can do whatever
# * you like to the buffer, though, and it will continue in its changed state
# * down the mixing pipeline, through any other effect functions, then finally
# * to be mixed with the rest of the channels and music for the final output
# * stream.
# *
type
TMix_EffectFunc* = proc (chan: int, stream: Pointer, length: int,
udata: Pointer): Pointer{.cdecl.}
# * This is a callback that signifies that a channel has finished all its
# * loops and has completed playback. This gets called if the buffer
# * plays out normally, or if you call Mix_HaltChannel(), implicitly stop
# * a channel via Mix_AllocateChannels(), or unregister a callback while
# * it's still playing.
TMix_EffectDone* = proc (chan: int, udata: Pointer): Pointer{.cdecl.}
#* Register a special effect function. At mixing time, the channel data is
# * copied into a buffer and passed through each registered effect function.
# * After it passes through all the functions, it is mixed into the final
# * output stream. The copy to buffer is performed once, then each effect
# * function performs on the output of the previous effect. Understand that
# * this extra copy to a buffer is not performed if there are no effects
# * registered for a given chunk, which saves CPU cycles, and any given
# * effect will be extra cycles, too, so it is crucial that your code run
# * fast. Also note that the data that your function is given is in the
# * format of the sound device, and not the format you gave to Mix_OpenAudio(),
# * although they may in reality be the same. This is an unfortunate but
# * necessary speed concern. Use Mix_QuerySpec() to determine if you can
# * handle the data before you register your effect, and take appropriate
# * actions.
# * You may also specify a callback (Mix_EffectDone_t) that is called when
# * the channel finishes playing. This gives you a more fine-grained control
# * than Mix_ChannelFinished(), in case you need to free effect-specific
# * resources, etc. If you don't need this, you can specify NULL.
# * You may set the callbacks before or after calling Mix_PlayChannel().
# * Things like Mix_SetPanning() are just internal special effect functions,
# * so if you are using that, you've already incurred the overhead of a copy
# * to a separate buffer, and that these effects will be in the queue with
# * any functions you've registered. The list of registered effects for a
# * channel is reset when a chunk finishes playing, so you need to explicitly
# * set them with each call to Mix_PlayChannel*().
# * You may also register a special effect function that is to be run after
# * final mixing occurs. The rules for these callbacks are identical to those
# * in Mix_RegisterEffect, but they are run after all the channels and the
# * music have been mixed into a single stream, whereas channel-specific
# * effects run on a given channel before any other mixing occurs. These
# * global effect callbacks are call "posteffects". Posteffects only have
# * their Mix_EffectDone_t function called when they are unregistered (since
# * the main output stream is never "done" in the same sense as a channel).
# * You must unregister them manually when you've had enough. Your callback
# * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
# * processing is considered a posteffect.
# *
# * After all these effects have finished processing, the callback registered
# * through Mix_SetPostMix() runs, and then the stream goes to the audio
# * device.
# *
# * returns zero if error (no such channel), nonzero if added.
# * Error messages can be retrieved from Mix_GetError().
proc Mix_RegisterEffect*(chan: int, f: TMix_EffectFunc, d: TMix_EffectDone,
arg: Pointer): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
#* You may not need to call this explicitly, unless you need to stop an
# * effect from processing in the middle of a chunk's playback.
# * Posteffects are never implicitly unregistered as they are for channels,
# * but they may be explicitly unregistered through this function by
# * specifying MIX_CHANNEL_POST for a channel.
# * returns zero if error (no such channel or effect), nonzero if removed.
# * Error messages can be retrieved from Mix_GetError().
# *
proc Mix_UnregisterEffect*(channel: int, f: TMix_EffectFunc): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
#* You may not need to call this explicitly, unless you need to stop all
# * effects from processing in the middle of a chunk's playback. Note that
# * this will also shut off some internal effect processing, since
# * Mix_SetPanning( ) and others may use this API under the hood.This is
# * called internally when a channel completes playback.
# * Posteffects are never implicitly unregistered as they are for channels,
# * but they may be explicitly unregistered through this function by
# * specifying MIX_CHANNEL_POST for a channel.
# * returns zero if error( no such channel ), nonzero if all effects removed.
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_UnregisterAllEffects*(channel: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
const
MIX_EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED"
# * These are the internally - defined mixing effects.They use the same API that
# * effects defined in the application use, but are provided here as a
# * convenience.Some effects can reduce their quality or use more memory in
# * the name of speed; to enable this, make sure the environment variable
# * MIX_EFFECTSMAXSPEED( see above ) is defined before you call
# * Mix_OpenAudio( ).
# *
#* set the panning of a channel.The left and right channels are specified
# * as integers between 0 and 255, quietest to loudest, respectively.
# *
# * Technically, this is just individual volume control for a sample with
# * two( stereo )channels, so it can be used for more than just panning.
# * if you want real panning, call it like this :
# *
# * Mix_SetPanning( channel, left, 255 - left );
# *
# * ...which isn't so hard.
# *
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
# * the panning will be done to the final mixed stream before passing it on
# * to the audio device.
# *
# * This uses the Mix_RegisterEffect( )API internally, and returns without
# * registering the effect function if the audio device is not configured
# * for stereo output.Setting both( left ) and ( right ) to 255 causes this
# * effect to be unregistered, since that is the data's normal state.
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if panning effect enabled.Note that an audio device in mono
# * mode is a no - op, but this call will return successful in that case .
# * Error messages can be retrieved from Mix_GetError( ).
proc Mix_SetPanning*(channel: int, left: Uint8, right: Uint8): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# * set the position ofa channel.( angle ) is an integer from 0 to 360, that
# * specifies the location of the sound in relation to the listener.( angle )
# * will be reduced as neccesary( 540 becomes 180 degrees, -100 becomes 260 ).
# * Angle 0 is due north, and rotates clockwise as the value increases.
# * for efficiency, the precision of this effect may be limited( angles 1
# * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
# * ( distance ) is an integer between 0 and 255 that specifies the space
# * between the sound and the listener.The larger the number, the further
# * away the sound is .Using 255 does not guarantee that the channel will be
# * culled from the mixing process or be completely silent.For efficiency,
# * the precision of this effect may be limited( distance 0 through 5 might
# * all produce the same effect, 6 through 10 are equal, etc ).Setting( angle )
# * and ( distance ) to 0 unregisters this effect, since the data would be
# * unchanged.
# *
# * if you need more precise positional audio, consider using OpenAL for
# * spatialized effects instead of SDL_mixer.This is only meant to be a
# * basic effect for simple "3D" games.
# *
# * if the audio device is configured for mono output, then you won't get
# * any effectiveness from the angle; however, distance attenuation on the
# * channel will still occur.While this effect will function with stereo
# * voices, it makes more sense to use voices with only one channel of sound,
# * so when they are mixed through this effect, the positioning will sound
# * correct.You can convert them to mono through SDL before giving them to
# * the mixer in the first place if you like.
# *
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
# * the positioning will be done to the final mixed stream before passing it
# * on to the audio device.
# *
# * This is a convenience wrapper over Mix_SetDistance( ) and Mix_SetPanning( ).
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if position effect is enabled.
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_SetPosition*(channel: int, angle: Sint16, distance: Uint8): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
#* set the "distance" of a channel.( distance ) is an integer from 0 to 255
# * that specifies the location of the sound in relation to the listener.
# * Distance 0 is overlapping the listener, and 255 is as far away as possible
# * A distance of 255 does not guarantee silence; in such a case , you might
# * want to try changing the chunk's volume, or just cull the sample from the
# * mixing process with Mix_HaltChannel( ).
# * for efficiency, the precision of this effect may be limited( distances 1
# * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
# * ( distance ) is an integer between 0 and 255 that specifies the space
# * between the sound and the listener.The larger the number, the further
# * away the sound is .
# * Setting( distance ) to 0 unregisters this effect, since the data would be
# * unchanged.
# * if you need more precise positional audio, consider using OpenAL for
# * spatialized effects instead of SDL_mixer.This is only meant to be a
# * basic effect for simple "3D" games.
# *
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
# * the distance attenuation will be done to the final mixed stream before
# * passing it on to the audio device.
# *
# * This uses the Mix_RegisterEffect( )API internally.
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if position effect is enabled.
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_SetDistance*(channel: int, distance: Uint8): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# *
# * !!! FIXME : Haven't implemented, since the effect goes past the
# * end of the sound buffer.Will have to think about this.
# * - -ryan.
# * /
# { if 0
# { * Causes an echo effect to be mixed into a sound.( echo ) is the amount
# * of echo to mix.0 is no echo, 255 is infinite( and probably not
# * what you want ).
# *
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
# * the reverbing will be done to the final mixed stream before passing it on
# * to the audio device.
# *
# * This uses the Mix_RegisterEffect( )API internally.If you specify an echo
# * of zero, the effect is unregistered, as the data is already in that state.
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if reversing effect is enabled.
# * Error messages can be retrieved from Mix_GetError( ).
# *
# extern no_parse_DECLSPEC int Mix_SetReverb( int channel, Uint8 echo );
# #E ndif
# * Causes a channel to reverse its stereo.This is handy if the user has his
# * speakers hooked up backwards, or you would like to have a minor bit of
# * psychedelia in your sound code. : )Calling this function with ( flip )
# * set to non - zero reverses the chunks's usual channels. If (flip) is zero,
# * the effect is unregistered.
# *
# * This uses the Mix_RegisterEffect( )API internally, and thus is probably
# * more CPU intensive than having the user just plug in his speakers
# * correctly.Mix_SetReverseStereo( )returns without registering the effect
# * function if the audio device is not configured for stereo output.
# *
# * if you specify MIX_CHANNEL_POST for ( channel ), then this the effect is used
# * on the final mixed stream before sending it on to the audio device( a
# * posteffect ).
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if reversing effect is enabled.Note that an audio device in mono
# * mode is a no - op, but this call will return successful in that case .
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_SetReverseStereo*(channel: int, flip: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# end of effects API. - -ryan. *
# Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
# them dynamically to the next sample if requested with a -1 value below.
# Returns the number of reserved channels.
#
proc Mix_ReserveChannels*(num: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Channel grouping functions
# Attach a tag to a channel. A tag can be assigned to several mixer
# channels, to form groups of channels.
# If 'tag' is -1, the tag is removed (actually -1 is the tag used to
# represent the group of all the channels).
# Returns true if everything was OK.
#
proc Mix_GroupChannel*(which: int, tag: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Assign several consecutive channels to a group
proc Mix_GroupChannels*(`from`: int, `to`: int, tag: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Finds the first available channel in a group of channels
proc Mix_GroupAvailable*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Returns the number of channels in a group. This is also a subtle
# way to get the total number of channels when 'tag' is -1
#
proc Mix_GroupCount*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Finds the "oldest" sample playing in a group of channels
proc Mix_GroupOldest*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Finds the "most recent" (i.e. last) sample playing in a group of channels
proc Mix_GroupNewer*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# The same as above, but the sound is played at most 'ticks' milliseconds
proc Mix_PlayChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int,
ticks: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Play an audio chunk on a specific channel.
# If the specified channel is -1, play on the first free channel.
# If 'loops' is greater than zero, loop the sound that many times.
# If 'loops' is -1, loop inifinitely (~65000 times).
# Returns which channel was used to play the sound.
#
proc Mix_PlayChannel*(channel: int, chunk: PMix_Chunk, loops: int): int
proc Mix_PlayMusic*(music: PMix_Music, loops: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions
proc Mix_FadeInMusic*(music: PMix_Music, loops: int, ms: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
proc Mix_FadeInChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int,
ms: int, ticks: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
proc Mix_FadeInChannel*(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int
# Set the volume in the range of 0-128 of a specific channel or chunk.
# If the specified channel is -1, set volume for all channels.
# Returns the original volume.
# If the specified volume is -1, just return the current volume.
#
proc Mix_Volume*(channel: int, volume: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
proc Mix_VolumeChunk*(chunk: PMix_Chunk, volume: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
proc Mix_VolumeMusic*(volume: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Halt playing of a particular channel
proc Mix_HaltChannel*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_HaltGroup*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_HaltMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Change the expiration delay for a particular channel.
# The sample will stop playing after the 'ticks' milliseconds have elapsed,
# or remove the expiration if 'ticks' is -1
#
proc Mix_ExpireChannel*(channel: int, ticks: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Halt a channel, fading it out progressively till it's silent
# The ms parameter indicates the number of milliseconds the fading
# will take.
#
proc Mix_FadeOutChannel*(which: int, ms: int): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
proc Mix_FadeOutGroup*(tag: int, ms: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_FadeOutMusic*(ms: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Query the fading status of a channel
proc Mix_FadingMusic*(): TMix_Fading{.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_FadingChannel*(which: int): TMix_Fading{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Pause/Resume a particular channel
proc Mix_Pause*(channel: int){.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_Resume*(channel: int){.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_Paused*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Pause/Resume the music stream
proc Mix_PauseMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_ResumeMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_RewindMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_PausedMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Set the current position in the music stream.
# This returns 0 if successful, or -1 if it failed or isn't implemented.
# This function is only implemented for MOD music formats (set pattern
# order number) and for OGG music (set position in seconds), at the
# moment.
#
proc Mix_SetMusicPosition*(position: float64): int{.cdecl,
importc, dynlib: SDL_MixerLibName.}
# Check the status of a specific channel.
# If the specified channel is -1, check all channels.
#
proc Mix_Playing*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_PlayingMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Stop music and set external music playback command
proc Mix_SetMusicCMD*(command: cstring): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Synchro value is set by MikMod from modules while playing
proc Mix_SetSynchroValue*(value: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
proc Mix_GetSynchroValue*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
#
# Get the Mix_Chunk currently associated with a mixer channel
# Returns nil if it's an invalid channel, or there's no chunk associated.
#
proc Mix_GetChunk*(channel: int): PMix_Chunk{.cdecl, importc, dynlib: SDL_MixerLibName.}
# Close the mixer, halting all playing audio
proc Mix_CloseAudio*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
# We'll use SDL for reporting errors
proc Mix_SetError*(fmt: cstring)
proc Mix_GetError*(): cstring
# implementation
proc SDL_MIXER_VERSION(X: var TSDL_version) =
X.major = SDL_MIXER_MAJOR_VERSION
X.minor = SDL_MIXER_MINOR_VERSION
X.patch = SDL_MIXER_PATCHLEVEL
proc Mix_LoadWAV(filename: cstring): PMix_Chunk =
result = Mix_LoadWAV_RW(SDL_RWFromFile(filename, "rb"), 1)
proc Mix_PlayChannel(channel: int, chunk: PMix_Chunk, loops: int): int =
result = Mix_PlayChannelTimed(channel, chunk, loops, - 1)
proc Mix_FadeInChannel(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int =
result = Mix_FadeInChannelTimed(channel, chunk, loops, ms, - 1)
proc Mix_SetError(fmt: cstring) =
SDL_SetError(fmt)
proc Mix_GetError(): cstring =
result = SDL_GetError()

View file

@ -0,0 +1,431 @@
#******************************************************************************
#
# $Id: sdl_net.pas,v 1.7 2005/01/01 02:14:21 savage Exp $
#
#
#
# Borland Delphi SDL_Net - A x-platform network library for use with SDL.
# Conversion of the Simple DirectMedia Layer Network Headers
#
# Portions created by Sam Lantinga <slouken@devolution.com> are
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
# 5635-34 Springhouse Dr.
# Pleasanton, CA 94588 (USA)
#
# All Rights Reserved.
#
# The original files are : SDL_net.h
#
# The initial developer of this Pascal code was :
# Dominqiue Louis <Dominique@SavageSoftware.com.au>
#
# Portions created by Dominqiue Louis are
# Copyright (C) 2000 - 2001 Dominqiue Louis.
#
#
# Contributor(s)
# --------------
# Matthias Thoma <ma.thoma@gmx.de>
#
# Obtained through:
# Joint Endeavour of Delphi Innovators ( Project JEDI )
#
# You may retrieve the latest version of this file at the Project
# JEDI home page, located at http://delphi-jedi.org
#
# The contents of this file are used with permission, subject to
# the Mozilla Public License Version 1.1 (the "License"); you may
# not use this file except in compliance with the License. You may
# obtain a copy of the License at
# http://www.mozilla.org/MPL/MPL-1.1.html
#
# Software distributed under the License is distributed on an
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# Description
# -----------
#
#
#
#
#
#
#
# Requires
# --------
# SDL.pas somehere in your search path
#
# Programming Notes
# -----------------
#
#
#
#
# Revision History
# ----------------
# April 09 2001 - DL : Initial Translation
#
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
# Pascal compilers. Initial support is now included
# for GnuPascal, VirtualPascal, TMT and obviously
# continue support for Delphi Kylix and FreePascal.
#
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
# better TMT Pascal support and under instruction
# from Prof. Abimbola Olowofoyeku (The African Chief),
# I have added better Gnu Pascal support
#
# April 30 2003 - DL : under instruction from David Mears AKA
# Jason Siletto, I have added FPC Linux support.
# This was compiled with fpc 1.1, so remember to set
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
#
#
# $Log: sdl_net.pas,v $
# Revision 1.7 2005/01/01 02:14:21 savage
# Updated to v1.2.5
#
# Revision 1.6 2004/08/14 22:54:30 savage
# Updated so that Library name defines are correctly defined for MacOS X.
#
# Revision 1.5 2004/05/10 14:10:04 savage
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
#
# Revision 1.4 2004/04/13 09:32:08 savage
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
#
# Revision 1.3 2004/04/01 20:53:23 savage
# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
#
# Revision 1.2 2004/03/30 20:23:28 savage
# Tidied up use of UNIX compiler directive.
#
# Revision 1.1 2004/02/16 22:16:40 savage
# v1.0 changes
#
#
#
#******************************************************************************
import
sdl
when defined(windows):
const SDLNetLibName = "SDL_net.dll"
elif defined(macosx):
const SDLNetLibName = "libSDL_net.dylib"
else:
const SDLNetLibName = "libSDL_net.so"
const #* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL *
SDL_NET_MAJOR_VERSION* = 1'i8
SDL_NET_MINOR_VERSION* = 2'i8
SDL_NET_PATCHLEVEL* = 5'i8 # SDL_Net.h constants
#* Resolve a host name and port to an IP address in network form.
# If the function succeeds, it will return 0.
# If the host couldn't be resolved, the host portion of the returned
# address will be INADDR_NONE, and the function will return -1.
# If 'host' is NULL, the resolved host will be set to INADDR_ANY.
# *
INADDR_ANY* = 0x00000000
INADDR_NONE* = 0xFFFFFFFF #***********************************************************************
#* UDP network API *
#***********************************************************************
#* The maximum channels on a a UDP socket *
SDLNET_MAX_UDPCHANNELS* = 32 #* The maximum addresses bound to a single UDP socket channel *
SDLNET_MAX_UDPADDRESSES* = 4
type # SDL_net.h types
#***********************************************************************
#* IPv4 hostname resolution API *
#***********************************************************************
PIPAddress* = ptr TIPAddress
TIPAddress*{.final.} = object #* TCP network API
host*: Uint32 # 32-bit IPv4 host address */
port*: Uint16 # 16-bit protocol port */
PTCPSocket* = ptr TTCPSocket
TTCPSocket*{.final.} = object #***********************************************************************
#* UDP network API *
#***********************************************************************
ready*: int
channel*: int
remoteAddress*: TIPaddress
localAddress*: TIPaddress
sflag*: int
PUDP_Channel* = ptr TUDP_Channel
TUDP_Channel*{.final.} = object
numbound*: int
address*: array[0..SDLNET_MAX_UDPADDRESSES - 1, TIPAddress]
PUDPSocket* = ptr TUDPSocket
TUDPSocket*{.final.} = object
ready*: int
channel*: int
address*: TIPAddress
binding*: array[0..SDLNET_MAX_UDPCHANNELS - 1, TUDP_Channel]
PUDPpacket* = ptr TUDPpacket
PPUDPpacket* = ptr PUDPpacket
TUDPpacket*{.final.} = object #***********************************************************************
#* Hooks for checking sockets for available data *
#***********************************************************************
channel*: int #* The src/dst channel of the packet *
data*: PUint8 #* The packet data *
length*: int #* The length of the packet data *
maxlen*: int #* The size of the data buffer *
status*: int #* packet status after sending *
address*: TIPAddress #* The source/dest address of an incoming/outgoing packet *
PSDLNet_Socket* = ptr TSDLNet_Socket
TSDLNet_Socket*{.final.} = object
ready*: int
channel*: int
PSDLNet_SocketSet* = ptr TSDLNet_SocketSet
TSDLNet_SocketSet*{.final.} = object #* Any network socket can be safely cast to this socket type *
numsockets*: int
maxsockets*: int
sockets*: PSDLNet_Socket
PSDLNet_GenericSocket* = ptr TSDLNet_GenericSocket
TSDLNet_GenericSocket*{.final.} = object # This macro can be used to fill a version structure with the compile-time
# version of the SDL_net library.
ready*: int
proc SDL_NET_VERSION*(X: var TSDL_version)
#* Initialize/Cleanup the network API
# SDL must be initialized before calls to functions in this library,
# because this library uses utility functions from the SDL library.
#*
proc SDLNet_Init*(): int{.cdecl, importc, dynlib: SDLNetLibName.}
proc SDLNet_Quit*(){.cdecl, importc, dynlib: SDLNetLibName.}
#* Resolve a host name and port to an IP address in network form.
# If the function succeeds, it will return 0.
# If the host couldn't be resolved, the host portion of the returned
# address will be INADDR_NONE, and the function will return -1.
# If 'host' is NULL, the resolved host will be set to INADDR_ANY.
# *
proc SDLNet_ResolveHost*(address: var TIPaddress, host: cstring, port: Uint16): int{.
cdecl, importc, dynlib: SDLNetLibName.}
#* Resolve an ip address to a host name in canonical form.
# If the ip couldn't be resolved, this function returns NULL,
# otherwise a pointer to a static buffer containing the hostname
# is returned. Note that this function is not thread-safe.
#*
proc SDLNet_ResolveIP*(ip: var TIPaddress): cstring{.cdecl,
importc, dynlib: SDLNetLibName.}
#***********************************************************************
#* TCP network API *
#***********************************************************************
#* Open a TCP network socket
# If ip.host is INADDR_NONE, this creates a local server socket on the
# given port, otherwise a TCP connection to the remote host and port is
# attempted. The address passed in should already be swapped to network
# byte order (addresses returned from SDLNet_ResolveHost() are already
# in the correct form).
# The newly created socket is returned, or NULL if there was an error.
#*
proc SDLNet_TCP_Open*(ip: var TIPaddress): PTCPSocket{.cdecl,
importc, dynlib: SDLNetLibName.}
#* Accept an incoming connection on the given server socket.
# The newly created socket is returned, or NULL if there was an error.
#*
proc SDLNet_TCP_Accept*(server: PTCPsocket): PTCPSocket{.cdecl,
importc, dynlib: SDLNetLibName.}
#* Get the IP address of the remote system associated with the socket.
# If the socket is a server socket, this function returns NULL.
#*
proc SDLNet_TCP_GetPeerAddress*(sock: PTCPsocket): PIPAddress{.cdecl,
importc, dynlib: SDLNetLibName.}
#* Send 'len' bytes of 'data' over the non-server socket 'sock'
# This function returns the actual amount of data sent. If the return value
# is less than the amount of data sent, then either the remote connection was
# closed, or an unknown socket error occurred.
#*
proc SDLNet_TCP_Send*(sock: PTCPsocket, data: Pointer, length: int): int{.cdecl,
importc, dynlib: SDLNetLibName.}
#* Receive up to 'maxlen' bytes of data over the non-server socket 'sock',
# and store them in the buffer pointed to by 'data'.
# This function returns the actual amount of data received. If the return
# value is less than or equal to zero, then either the remote connection was
# closed, or an unknown socket error occurred.
#*
proc SDLNet_TCP_Recv*(sock: PTCPsocket, data: Pointer, maxlen: int): int{.cdecl,
importc, dynlib: SDLNetLibName.}
#* Close a TCP network socket *
proc SDLNet_TCP_Close*(sock: PTCPsocket){.cdecl, importc, dynlib: SDLNetLibName.}
#***********************************************************************
#* UDP network API *
#***********************************************************************
#* Allocate/resize/free a single UDP packet 'size' bytes long.
# The new packet is returned, or NULL if the function ran out of memory.
# *
proc SDLNet_AllocPacket*(size: int): PUDPpacket{.cdecl, importc, dynlib: SDLNetLibName.}
proc SDLNet_ResizePacket*(packet: PUDPpacket, newsize: int): int{.cdecl,
importc, dynlib: SDLNetLibName.}
proc SDLNet_FreePacket*(packet: PUDPpacket){.cdecl, importc, dynlib: SDLNetLibName.}
#* Allocate/Free a UDP packet vector (array of packets) of 'howmany' packets,
# each 'size' bytes long.
# A pointer to the first packet in the array is returned, or NULL if the
# function ran out of memory.
# *
proc SDLNet_AllocPacketV*(howmany: int, size: int): PUDPpacket{.cdecl,
importc, dynlib: SDLNetLibName.}
proc SDLNet_FreePacketV*(packetV: PUDPpacket){.cdecl, importc, dynlib: SDLNetLibName.}
#* Open a UDP network socket
# If 'port' is non-zero, the UDP socket is bound to a local port.
# This allows other systems to send to this socket via a known port.
#*
proc SDLNet_UDP_Open*(port: Uint16): PUDPsocket{.cdecl, importc, dynlib: SDLNetLibName.}
#* Bind the address 'address' to the requested channel on the UDP socket.
# If the channel is -1, then the first unbound channel will be bound with
# the given address as it's primary address.
# If the channel is already bound, this new address will be added to the
# list of valid source addresses for packets arriving on the channel.
# If the channel is not already bound, then the address becomes the primary
# address, to which all outbound packets on the channel are sent.
# This function returns the channel which was bound, or -1 on error.
#*
proc SDLNet_UDP_Bind*(sock: PUDPsocket, channel: int, address: var TIPaddress): int{.
cdecl, importc, dynlib: SDLNetLibName.}
#* Unbind all addresses from the given channel *
proc SDLNet_UDP_Unbind*(sock: PUDPsocket, channel: int){.cdecl,
importc, dynlib: SDLNetLibName.}
#* Get the primary IP address of the remote system associated with the
# socket and channel. If the channel is -1, then the primary IP port
# of the UDP socket is returned -- this is only meaningful for sockets
# opened with a specific port.
# If the channel is not bound and not -1, this function returns NULL.
# *
proc SDLNet_UDP_GetPeerAddress*(sock: PUDPsocket, channel: int): PIPAddress{.
cdecl, importc, dynlib: SDLNetLibName.}
#* Send a vector of packets to the the channels specified within the packet.
# If the channel specified in the packet is -1, the packet will be sent to
# the address in the 'src' member of the packet.
# Each packet will be updated with the status of the packet after it has
# been sent, -1 if the packet send failed.
# This function returns the number of packets sent.
#*
proc SDLNet_UDP_SendV*(sock: PUDPsocket, packets: PPUDPpacket, npackets: int): int{.
cdecl, importc, dynlib: SDLNetLibName.}
#* Send a single packet to the specified channel.
# If the channel specified in the packet is -1, the packet will be sent to
# the address in the 'src' member of the packet.
# The packet will be updated with the status of the packet after it has
# been sent.
# This function returns 1 if the packet was sent, or 0 on error.
#*
proc SDLNet_UDP_Send*(sock: PUDPsocket, channel: int, packet: PUDPpacket): int{.
cdecl, importc, dynlib: SDLNetLibName.}
#* Receive a vector of pending packets from the UDP socket.
# The returned packets contain the source address and the channel they arrived
# on. If they did not arrive on a bound channel, the the channel will be set
# to -1.
# The channels are checked in highest to lowest order, so if an address is
# bound to multiple channels, the highest channel with the source address
# bound will be returned.
# This function returns the number of packets read from the network, or -1
# on error. This function does not block, so can return 0 packets pending.
#*
proc SDLNet_UDP_RecvV*(sock: PUDPsocket, packets: PPUDPpacket): int{.cdecl,
importc, dynlib: SDLNetLibName.}
#* Receive a single packet from the UDP socket.
# The returned packet contains the source address and the channel it arrived
# on. If it did not arrive on a bound channel, the the channel will be set
# to -1.
# The channels are checked in highest to lowest order, so if an address is
# bound to multiple channels, the highest channel with the source address
# bound will be returned.
# This function returns the number of packets read from the network, or -1
# on error. This function does not block, so can return 0 packets pending.
#*
proc SDLNet_UDP_Recv*(sock: PUDPsocket, packet: PUDPpacket): int{.cdecl,
importc, dynlib: SDLNetLibName.}
#* Close a UDP network socket *
proc SDLNet_UDP_Close*(sock: PUDPsocket){.cdecl, importc, dynlib: SDLNetLibName.}
#***********************************************************************
#* Hooks for checking sockets for available data *
#***********************************************************************
#* Allocate a socket set for use with SDLNet_CheckSockets()
# This returns a socket set for up to 'maxsockets' sockets, or NULL if
# the function ran out of memory.
# *
proc SDLNet_AllocSocketSet*(maxsockets: int): PSDLNet_SocketSet{.cdecl,
importc, dynlib: SDLNetLibName.}
#* Add a socket to a set of sockets to be checked for available data *
proc SDLNet_AddSocket*(theSet: PSDLNet_SocketSet, sock: PSDLNet_GenericSocket): int{.
cdecl, importc, dynlib: SDLNetLibName.}
proc SDLNet_TCP_AddSocket*(theSet: PSDLNet_SocketSet, sock: PTCPSocket): int
proc SDLNet_UDP_AddSocket*(theSet: PSDLNet_SocketSet, sock: PUDPSocket): int
#* Remove a socket from a set of sockets to be checked for available data *
proc SDLNet_DelSocket*(theSet: PSDLNet_SocketSet, sock: PSDLNet_GenericSocket): int{.
cdecl, importc, dynlib: SDLNetLibName.}
proc SDLNet_TCP_DelSocket*(theSet: PSDLNet_SocketSet, sock: PTCPSocket): int
# SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
proc SDLNet_UDP_DelSocket*(theSet: PSDLNet_SocketSet, sock: PUDPSocket): int
#SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
#* This function checks to see if data is available for reading on the
# given set of sockets. If 'timeout' is 0, it performs a quick poll,
# otherwise the function returns when either data is available for
# reading, or the timeout in milliseconds has elapsed, which ever occurs
# first. This function returns the number of sockets ready for reading,
# or -1 if there was an error with the select() system call.
#*
proc SDLNet_CheckSockets*(theSet: PSDLNet_SocketSet, timeout: Sint32): int{.
cdecl, importc, dynlib: SDLNetLibName.}
#* After calling SDLNet_CheckSockets(), you can use this function on a
# socket that was in the socket set, to find out if data is available
# for reading.
#*
proc SDLNet_SocketReady*(sock: PSDLNet_GenericSocket): bool
#* Free a set of sockets allocated by SDL_NetAllocSocketSet() *
proc SDLNet_FreeSocketSet*(theSet: PSDLNet_SocketSet){.cdecl,
importc, dynlib: SDLNetLibName.}
#***********************************************************************
#* Platform-independent data conversion functions *
#***********************************************************************
#* Write a 16/32 bit value to network packet buffer *
proc SDLNet_Write16*(value: Uint16, area: Pointer){.cdecl, importc, dynlib: SDLNetLibName.}
proc SDLNet_Write32*(value: Uint32, area: Pointer){.cdecl, importc, dynlib: SDLNetLibName.}
#* Read a 16/32 bit value from network packet buffer *
proc SDLNet_Read16*(area: Pointer): Uint16{.cdecl, importc, dynlib: SDLNetLibName.}
proc SDLNet_Read32*(area: Pointer): Uint32{.cdecl, importc, dynlib: SDLNetLibName.}
#***********************************************************************
#* Error reporting functions *
#***********************************************************************
#* We'll use SDL's functions for error reporting *
proc SDLNet_SetError*(fmt: cstring)
proc SDLNet_GetError*(): cstring
# implementation
proc SDL_NET_VERSION(X: var TSDL_version) =
X.major = SDL_NET_MAJOR_VERSION
X.minor = SDL_NET_MINOR_VERSION
X.patch = SDL_NET_PATCHLEVEL
proc SDLNet_TCP_AddSocket(theSet: PSDLNet_SocketSet, sock: PTCPSocket): int =
result = SDLNet_AddSocket(theSet, cast[PSDLNet_GenericSocket](sock))
proc SDLNet_UDP_AddSocket(theSet: PSDLNet_SocketSet, sock: PUDPSocket): int =
result = SDLNet_AddSocket(theSet, cast[PSDLNet_GenericSocket](sock))
proc SDLNet_TCP_DelSocket(theSet: PSDLNet_SocketSet, sock: PTCPSocket): int =
result = SDLNet_DelSocket(theSet, cast[PSDLNet_GenericSocket](sock))
proc SDLNet_UDP_DelSocket(theSet: PSDLNet_SocketSet, sock: PUDPSocket): int =
result = SDLNet_DelSocket(theSet, cast[PSDLNet_GenericSocket](sock))
proc SDLNet_SocketReady(sock: PSDLNet_GenericSocket): bool =
result = ((sock != nil) and (sock.ready == 1))
proc SDLNet_SetError(fmt: cstring) =
SDL_SetError(fmt)
proc SDLNet_GetError(): cstring =
result = SDL_GetError()

View file

@ -0,0 +1,346 @@
#
# $Id: sdl_ttf.pas,v 1.18 2007/06/01 11:16:33 savage Exp $
#
#
#******************************************************************************
#
# JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer
# Conversion of the Simple DirectMedia Layer Headers
#
# Portions created by Sam Lantinga <slouken@devolution.com> are
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
# 5635-34 Springhouse Dr.
# Pleasanton, CA 94588 (USA)
#
# All Rights Reserved.
#
# The original files are : SDL_ttf.h
#
# The initial developer of this Pascal code was :
# Dominqiue Louis <Dominique@SavageSoftware.com.au>
#
# Portions created by Dominqiue Louis are
# Copyright (C) 2000 - 2001 Dominqiue Louis.
#
#
# Contributor(s)
# --------------
# Tom Jones <tigertomjones@gmx.de> His Project inspired this conversion
#
# Obtained through:
# Joint Endeavour of Delphi Innovators ( Project JEDI )
#
# You may retrieve the latest version of this file at the Project
# JEDI home page, located at http://delphi-jedi.org
#
# The contents of this file are used with permission, subject to
# the Mozilla Public License Version 1.1 (the "License"); you may
# not use this file except in compliance with the License. You may
# obtain a copy of the License at
# http://www.mozilla.org/MPL/MPL-1.1.html
#
# Software distributed under the License is distributed on an
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# Description
# -----------
#
#
#
#
#
#
#
# Requires
# --------
# The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so
# They are available from...
# http://www.libsdl.org .
#
# Programming Notes
# -----------------
#
#
#
#
# Revision History
# ----------------
# December 08 2002 - DL : Fixed definition of TTF_RenderUnicode_Solid
#
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
# Pascal compilers. Initial support is now included
# for GnuPascal, VirtualPascal, TMT and obviously
# continue support for Delphi Kylix and FreePascal.
#
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
# better TMT Pascal support and under instruction
# from Prof. Abimbola Olowofoyeku (The African Chief),
# I have added better Gnu Pascal support
#
# April 30 2003 - DL : under instruction from David Mears AKA
# Jason Siletto, I have added FPC Linux support.
# This was compiled with fpc 1.1, so remember to set
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
#
#
# $Log: sdl_ttf.pas,v $
# Revision 1.18 2007/06/01 11:16:33 savage
# Added IFDEF UNIX for Workaround.
#
# Revision 1.17 2007/06/01 08:38:21 savage
# Added TTF_RenderText_Solid workaround as suggested by Michalis Kamburelis
#
# Revision 1.16 2007/05/29 21:32:14 savage
# Changes as suggested by Almindor for 64bit compatibility.
#
# Revision 1.15 2007/05/20 20:32:45 savage
# Initial Changes to Handle 64 Bits
#
# Revision 1.14 2006/12/02 00:19:01 savage
# Updated to latest version
#
# Revision 1.13 2005/04/10 11:48:33 savage
# Changes as suggested by Michalis, thanks.
#
# Revision 1.12 2005/01/05 01:47:14 savage
# Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
#
# Revision 1.11 2005/01/04 23:14:57 savage
# Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
#
# Revision 1.10 2005/01/02 19:07:32 savage
# Slight bug fix to use LongInt instead of Long ( Thanks Michalis Kamburelis )
#
# Revision 1.9 2005/01/01 02:15:20 savage
# Updated to v2.0.7
#
# Revision 1.8 2004/10/07 21:02:32 savage
# Fix for FPC
#
# Revision 1.7 2004/09/30 22:39:50 savage
# Added a true type font class which contains a wrap text function.
# Changed the sdl_ttf.pas header to reflect the future of jedi-sdl.
#
# Revision 1.6 2004/08/14 22:54:30 savage
# Updated so that Library name defines are correctly defined for MacOS X.
#
# Revision 1.5 2004/05/10 14:10:04 savage
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
#
# Revision 1.4 2004/04/13 09:32:08 savage
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
#
# Revision 1.3 2004/04/01 20:53:24 savage
# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
#
# Revision 1.2 2004/03/30 20:23:28 savage
# Tidied up use of UNIX compiler directive.
#
# Revision 1.1 2004/02/16 22:16:40 savage
# v1.0 changes
#
#
#
#******************************************************************************
#
# Define this to workaround a known bug in some freetype versions.
# The error manifests as TTF_RenderGlyph_Solid returning nil (error)
# and error message (in SDL_Error) is
# "Failed loading DPMSDisable: /usr/lib/libX11.so.6: undefined symbol: DPMSDisable"
# See [http://lists.libsdl.org/pipermail/sdl-libsdl.org/2007-March/060459.html]
#
import sdl
when defined(windows):
const SDLttfLibName = "SDL_ttf.dll"
elif defined(macosx):
const SDLttfLibName = "libSDL_ttf-2.0.0.dylib"
else:
const SDLttfLibName = "libSDL_ttf.so"
const
SDL_TTF_MAJOR_VERSION* = 2'i8
SDL_TTF_MINOR_VERSION* = 0'i8
SDL_TTF_PATCHLEVEL* = 8'i8 # Backwards compatibility
TTF_MAJOR_VERSION* = SDL_TTF_MAJOR_VERSION
TTF_MINOR_VERSION* = SDL_TTF_MINOR_VERSION
TTF_PATCHLEVEL* = SDL_TTF_PATCHLEVEL #*
# Set and retrieve the font style
# This font style is implemented by modifying the font glyphs, and
# doesn't reflect any inherent properties of the truetype font file.
#*
TTF_STYLE_NORMAL* = 0x00000000
TTF_STYLE_BOLD* = 0x00000001
TTF_STYLE_ITALIC* = 0x00000002
TTF_STYLE_UNDERLINE* = 0x00000004 # ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark)
UNICODE_BOM_NATIVE* = 0x0000FEFF
UNICODE_BOM_SWAPPED* = 0x0000FFFE
type
PTTF_Font* = ptr TTTF_font
TTTF_Font*{.final.} = object # This macro can be used to fill a version structure with the compile-time
# version of the SDL_ttf library.
proc SDL_TTF_VERSION*(X: var TSDL_version)
# This function gets the version of the dynamically linked SDL_ttf library.
# It should NOT be used to fill a version structure, instead you should use the
# SDL_TTF_VERSION() macro.
proc TTF_Linked_Version*(): PSDL_version{.cdecl, importc, dynlib: SDLttfLibName.}
# This function tells the library whether UNICODE text is generally
# byteswapped. A UNICODE BOM character in a string will override
# this setting for the remainder of that string.
#
proc TTF_ByteSwappedUNICODE*(swapped: int){.cdecl, importc, dynlib: SDLttfLibName.}
#returns 0 on succes, -1 if error occurs
proc TTF_Init*(): int{.cdecl, importc, dynlib: SDLttfLibName.}
#
# Open a font file and create a font of the specified point size.
# Some .fon fonts will have several sizes embedded in the file, so the
# point size becomes the index of choosing which size. If the value
# is too high, the last indexed size will be the default.
#
proc TTF_OpenFont*(filename: cstring, ptsize: int): PTTF_Font{.cdecl,
importc, dynlib: SDLttfLibName.}
proc TTF_OpenFontIndex*(filename: cstring, ptsize: int, index: int32): PTTF_Font{.
cdecl, importc, dynlib: SDLttfLibName.}
proc TTF_OpenFontRW*(src: PSDL_RWops, freesrc: int, ptsize: int): PTTF_Font{.
cdecl, importc, dynlib: SDLttfLibName.}
proc TTF_OpenFontIndexRW*(src: PSDL_RWops, freesrc: int, ptsize: int,
index: int32): PTTF_Font{.cdecl, importc, dynlib: SDLttfLibName.}
proc TTF_GetFontStyle*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.}
proc TTF_SetFontStyle*(font: PTTF_Font, style: int){.cdecl,
importc, dynlib: SDLttfLibName.}
# Get the total height of the font - usually equal to point size
proc TTF_FontHeight*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.}
# Get the offset from the baseline to the top of the font
# This is a positive value, relative to the baseline.
#
proc TTF_FontAscent*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.}
# Get the offset from the baseline to the bottom of the font
# This is a negative value, relative to the baseline.
#
proc TTF_FontDescent*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.}
# Get the recommended spacing between lines of text for this font
proc TTF_FontLineSkip*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.}
# Get the number of faces of the font
proc TTF_FontFaces*(font: PTTF_Font): int32{.cdecl, importc, dynlib: SDLttfLibName.}
# Get the font face attributes, if any
proc TTF_FontFaceIsFixedWidth*(font: PTTF_Font): int{.cdecl,
importc, dynlib: SDLttfLibName.}
proc TTF_FontFaceFamilyName*(font: PTTF_Font): cstring{.cdecl,
importc, dynlib: SDLttfLibName.}
proc TTF_FontFaceStyleName*(font: PTTF_Font): cstring{.cdecl,
importc, dynlib: SDLttfLibName.}
# Get the metrics (dimensions) of a glyph
proc TTF_GlyphMetrics*(font: PTTF_Font, ch: Uint16, minx: var int,
maxx: var int, miny: var int, maxy: var int,
advance: var int): int{.cdecl, importc, dynlib: SDLttfLibName.}
# Get the dimensions of a rendered string of text
proc TTF_SizeText*(font: PTTF_Font, text: cstring, w: var int, y: var int): int{.
cdecl, importc, dynlib: SDLttfLibName.}
proc TTF_SizeUTF8*(font: PTTF_Font, text: cstring, w: var int, y: var int): int{.
cdecl, importc, dynlib: SDLttfLibName.}
proc TTF_SizeUNICODE*(font: PTTF_Font, text: PUint16, w: var int, y: var int): int{.
cdecl, importc, dynlib: SDLttfLibName.}
# Create an 8-bit palettized surface and render the given text at
# fast quality with the given font and color. The 0 pixel is the
# colorkey, giving a transparent background, and the 1 pixel is set
# to the text color.
# This function returns the new surface, or NULL if there was an error.
#
proc TTF_RenderUTF8_Solid*(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface{.
cdecl, importc, dynlib: SDLttfLibName.}
proc TTF_RenderUNICODE_Solid*(font: PTTF_Font, text: PUint16, fg: TSDL_Color): PSDL_Surface{.
cdecl, importc, dynlib: SDLttfLibName.}
#
#Create an 8-bit palettized surface and render the given glyph at
# fast quality with the given font and color. The 0 pixel is the
# colorkey, giving a transparent background, and the 1 pixel is set
# to the text color. The glyph is rendered without any padding or
# centering in the X direction, and aligned normally in the Y direction.
# This function returns the new surface, or NULL if there was an error.
#
proc TTF_RenderGlyph_Solid*(font: PTTF_Font, ch: Uint16, fg: TSDL_Color): PSDL_Surface{.
cdecl, importc, dynlib: SDLttfLibName.}
# Create an 8-bit palettized surface and render the given text at
# high quality with the given font and colors. The 0 pixel is background,
# while other pixels have varying degrees of the foreground color.
# This function returns the new surface, or NULL if there was an error.
#
proc TTF_RenderText_Shaded*(font: PTTF_Font, text: cstring, fg: TSDL_Color,
bg: TSDL_Color): PSDL_Surface{.cdecl,
importc, dynlib: SDLttfLibName.}
proc TTF_RenderUTF8_Shaded*(font: PTTF_Font, text: cstring, fg: TSDL_Color,
bg: TSDL_Color): PSDL_Surface{.cdecl,
importc, dynlib: SDLttfLibName.}
proc TTF_RenderUNICODE_Shaded*(font: PTTF_Font, text: PUint16, fg: TSDL_Color,
bg: TSDL_Color): PSDL_Surface{.cdecl,
importc, dynlib: SDLttfLibName.}
# Create an 8-bit palettized surface and render the given glyph at
# high quality with the given font and colors. The 0 pixel is background,
# while other pixels have varying degrees of the foreground color.
# The glyph is rendered without any padding or centering in the X
# direction, and aligned normally in the Y direction.
# This function returns the new surface, or NULL if there was an error.
#
proc TTF_RenderGlyph_Shaded*(font: PTTF_Font, ch: Uint16, fg: TSDL_Color,
bg: TSDL_Color): PSDL_Surface{.cdecl,
importc, dynlib: SDLttfLibName.}
# Create a 32-bit ARGB surface and render the given text at high quality,
# using alpha blending to dither the font with the given color.
# This function returns the new surface, or NULL if there was an error.
#
proc TTF_RenderText_Blended*(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface{.
cdecl, importc, dynlib: SDLttfLibName.}
proc TTF_RenderUTF8_Blended*(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface{.
cdecl, importc, dynlib: SDLttfLibName.}
proc TTF_RenderUNICODE_Blended*(font: PTTF_Font, text: PUint16, fg: TSDL_Color): PSDL_Surface{.
cdecl, importc, dynlib: SDLttfLibName.}
# Create a 32-bit ARGB surface and render the given glyph at high quality,
# using alpha blending to dither the font with the given color.
# The glyph is rendered without any padding or centering in the X
# direction, and aligned normally in the Y direction.
# This function returns the new surface, or NULL if there was an error.
#
proc TTF_RenderGlyph_Blended*(font: PTTF_Font, ch: Uint16, fg: TSDL_Color): PSDL_Surface{.
cdecl, importc, dynlib: SDLttfLibName.}
# For compatibility with previous versions, here are the old functions
##define TTF_RenderText(font, text, fg, bg)
# TTF_RenderText_Shaded(font, text, fg, bg)
##define TTF_RenderUTF8(font, text, fg, bg)
# TTF_RenderUTF8_Shaded(font, text, fg, bg)
##define TTF_RenderUNICODE(font, text, fg, bg)
# TTF_RenderUNICODE_Shaded(font, text, fg, bg)
# Close an opened font file
proc TTF_CloseFont*(font: PTTF_Font){.cdecl, importc, dynlib: SDLttfLibName.}
#De-initialize TTF engine
proc TTF_Quit*(){.cdecl, importc, dynlib: SDLttfLibName.}
# Check if the TTF engine is initialized
proc TTF_WasInit*(): int{.cdecl, importc, dynlib: SDLttfLibName.}
# We'll use SDL for reporting errors
proc TTF_SetError*(fmt: cstring)
proc TTF_GetError*(): cstring
# implementation
proc SDL_TTF_VERSION(X: var TSDL_version) =
X.major = SDL_TTF_MAJOR_VERSION
X.minor = SDL_TTF_MINOR_VERSION
X.patch = SDL_TTF_PATCHLEVEL
proc TTF_SetError(fmt: cstring) =
SDL_SetError(fmt)
proc TTF_GetError(): cstring =
result = SDL_GetError()
when not(defined(Workaround_TTF_RenderText_Solid)):
proc TTF_RenderText_Solid*(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface{.
cdecl, importc, dynlib: SDLttfLibName.}
else:
proc TTF_RenderText_Solid(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface =
var Black: TSDL_Color # initialized to zero
Result = TTF_RenderText_Shaded(font, text, fg, Black)

File diff suppressed because it is too large Load diff

319
lib/wrappers/sdl/smpeg.nim Normal file
View file

@ -0,0 +1,319 @@
#******************************************************************************
#
# $Id: smpeg.pas,v 1.7 2004/08/14 22:54:30 savage Exp $
#
#
#
# Borland Delphi SMPEG - SDL MPEG Player Library
# Conversion of the SMPEG - SDL MPEG Player Library
#
# Portions created by Sam Lantinga <slouken@devolution.com> are
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
# 5635-34 Springhouse Dr.
# Pleasanton, CA 94588 (USA)
#
# All Rights Reserved.
#
# The original files are : smpeg.h
#
# The initial developer of this Pascal code was :
# Matthias Thoma <ma.thoma@gmx.de>
#
# Portions created by Matthias Thoma are
# Copyright (C) 2000 - 2001 Matthias Thoma.
#
#
# Contributor(s)
# --------------
# Tom Jones <tigertomjones@gmx.de> His Project inspired this conversion
# Matthias Thoma <ma.thoma@gmx.de>
#
# Obtained through:
# Joint Endeavour of Delphi Innovators ( Project JEDI )
#
# You may retrieve the latest version of this file at the Project
# JEDI home page, located at http://delphi-jedi.org
#
# The contents of this file are used with permission, subject to
# the Mozilla Public License Version 1.1 (the "License"); you may
# not use this file except in compliance with the License. You may
# obtain a copy of the License at
# http://www.mozilla.org/MPL/MPL-1.1.html
#
# Software distributed under the License is distributed on an
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# Description
# -----------
#
#
#
#
#
#
#
# Requires
# --------
# The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL-1.2.so.0
# They are available from...
# http://www.libsdl.org .
#
# Programming Notes
# -----------------
#
#
#
#
# Revision History
# ----------------
# May 08 2001 - MT : Initial conversion
#
# October 12 2001 - DA : Various changes as suggested by David Acklam
#
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
# Pascal compilers. Initial support is now included
# for GnuPascal, VirtualPascal, TMT and obviously
# continue support for Delphi Kylix and FreePascal.
#
# April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support
# Fixed all invalid calls to DLL.
# Changed constant names to:
# const
# STATUS_SMPEG_ERROR = -1;
# STATUS_SMPEG_STOPPED = 0;
# STATUS_SMPEG_PLAYING = 1;
# because SMPEG_ERROR is a function (_SMPEG_error
# isn't correct), and cannot be two elements with the
# same name
#
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
# better TMT Pascal support and under instruction
# from Prof. Abimbola Olowofoyeku (The African Chief),
# I have added better Gnu Pascal support
#
# April 30 2003 - DL : under instruction from David Mears AKA
# Jason Siletto, I have added FPC Linux support.
# This was compiled with fpc 1.1, so remember to set
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
#
#
# $Log: smpeg.pas,v $
# Revision 1.7 2004/08/14 22:54:30 savage
# Updated so that Library name defines are correctly defined for MacOS X.
#
# Revision 1.6 2004/05/10 14:10:04 savage
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
#
# Revision 1.5 2004/04/13 09:32:08 savage
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
#
# Revision 1.4 2004/04/02 10:40:55 savage
# Changed Linux Shared Object name so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
#
# Revision 1.3 2004/03/31 22:20:02 savage
# Windows unit not used in this file, so it was removed to keep the code tidy.
#
# Revision 1.2 2004/03/30 20:23:28 savage
# Tidied up use of UNIX compiler directive.
#
# Revision 1.1 2004/02/14 23:35:42 savage
# version 1 of sdl_image, sdl_mixer and smpeg.
#
#
#
#******************************************************************************
import
sdl
when defined(windows):
const SmpegLibName = "smpeg.dll"
elif defined(macosx):
const SmpegLibName = "libsmpeg.dylib"
else:
const SmpegLibName = "libsmpeg.so"
const
SMPEG_FILTER_INFO_MB_ERROR* = 1
SMPEG_FILTER_INFO_PIXEL_ERROR* = 2 # Filter info from SMPEG
type
SMPEG_FilterInfo*{.final.} = object
yuv_mb_square_error*: PUint16
yuv_pixel_square_error*: PUint16
TSMPEG_FilterInfo* = SMPEG_FilterInfo
PSMPEG_FilterInfo* = ptr SMPEG_FilterInfo # MPEG filter definition
PSMPEG_Filter* = ptr TSMPEG_Filter # Callback functions for the filter
TSMPEG_FilterCallback* = proc (dest, source: PSDL_Overlay, region: PSDL_Rect,
filter_info: PSMPEG_FilterInfo, data: Pointer): Pointer{.
cdecl.}
TSMPEG_FilterDestroy* = proc (Filter: PSMPEG_Filter): Pointer{.cdecl.} # The filter
# definition itself
TSMPEG_Filter*{.final.} = object # The null filter (default). It simply copies the source rectangle to the video overlay.
flags*: Uint32
data*: Pointer
callback*: TSMPEG_FilterCallback
destroy*: TSMPEG_FilterDestroy
proc SMPEGfilter_null*(): PSMPEG_Filter{.cdecl, importc, dynlib: SmpegLibName.}
# The bilinear filter. A basic low-pass filter that will produce a smoother image.
proc SMPEGfilter_bilinear*(): PSMPEG_Filter{.cdecl, importc, dynlib: SmpegLibName.}
# The deblocking filter. It filters block borders and non-intra coded blocks to reduce blockiness
proc SMPEGfilter_deblocking*(): PSMPEG_Filter{.cdecl, importc, dynlib: SmpegLibName.}
#------------------------------------------------------------------------------
# SMPEG.h
#------------------------------------------------------------------------------
const
SMPEG_MAJOR_VERSION* = 0'i8
SMPEG_MINOR_VERSION* = 4'i8
SMPEG_PATCHLEVEL* = 2'i8
type
SMPEG_version*{.final.} = object
major*: UInt8
minor*: UInt8
patch*: UInt8
TSMPEG_version* = SMPEG_version
PSMPEG_version* = ptr TSMPEG_version # This is the actual SMPEG object
TSMPEG*{.final.} = object
PSMPEG* = ptr TSMPEG # Used to get information about the SMPEG object
TSMPEG_Info*{.final.} = object
has_audio*: int
has_video*: int
width*: int
height*: int
current_frame*: int
current_fps*: float64
audio_string*: array[0..79, char]
audio_current_frame*: int
current_offset*: UInt32
total_size*: UInt32
current_time*: float64
total_time*: float64
PSMPEG_Info* = ptr TSMPEG_Info # Possible MPEG status codes
const
STATUS_SMPEG_ERROR* = - 1
STATUS_SMPEG_STOPPED* = 0
STATUS_SMPEG_PLAYING* = 1
type
TSMPEGstatus* = int
PSMPEGstatus* = ptr int # Matches the declaration of SDL_UpdateRect()
TSMPEG_DisplayCallback* = proc (dst: PSDL_Surface, x, y: int, w, h: int): Pointer{.
cdecl.} # Create a new SMPEG object from an MPEG file.
# On return, if 'info' is not NULL, it will be filled with information
# about the MPEG object.
# This function returns a new SMPEG object. Use SMPEG_error() to find out
# whether or not there was a problem building the MPEG stream.
# The sdl_audio parameter indicates if SMPEG should initialize the SDL audio
# subsystem. If not, you will have to use the SMPEG_playaudio() function below
# to extract the decoded data.
proc SMPEG_new*(theFile: cstring, info: PSMPEG_Info, sdl_audio: int): PSMPEG{.
cdecl, importc, dynlib: SmpegLibName.}
# The same as above for a file descriptor
proc SMPEG_new_descr*(theFile: int, info: PSMPEG_Info, sdl_audio: int): PSMPEG{.
cdecl, importc, dynlib: SmpegLibName.}
# The same as above but for a raw chunk of data. SMPEG makes a copy of the
# data, so the application is free to delete after a successful call to this
# function.
proc SMPEG_new_data*(data: Pointer, size: int, info: PSMPEG_Info, sdl_audio: int): PSMPEG{.
cdecl, importc, dynlib: SmpegLibName.}
# Get current information about an SMPEG object
proc SMPEG_getinfo*(mpeg: PSMPEG, info: PSMPEG_Info){.cdecl,
importc, dynlib: SmpegLibName.}
#procedure SMPEG_getinfo(mpeg: PSMPEG; info: Pointer);
#cdecl; external SmpegLibName;
# Enable or disable audio playback in MPEG stream
proc SMPEG_enableaudio*(mpeg: PSMPEG, enable: int){.cdecl, importc, dynlib: SmpegLibName.}
# Enable or disable video playback in MPEG stream
proc SMPEG_enablevideo*(mpeg: PSMPEG, enable: int){.cdecl, importc, dynlib: SmpegLibName.}
# Delete an SMPEG object
proc SMPEG_delete*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
# Get the current status of an SMPEG object
proc SMPEG_status*(mpeg: PSMPEG): TSMPEGstatus{.cdecl, importc, dynlib: SmpegLibName.}
# status
# Set the audio volume of an MPEG stream, in the range 0-100
proc SMPEG_setvolume*(mpeg: PSMPEG, volume: int){.cdecl, importc, dynlib: SmpegLibName.}
# Set the destination surface for MPEG video playback
# 'surfLock' is a mutex used to synchronize access to 'dst', and can be NULL.
# 'callback' is a function called when an area of 'dst' needs to be updated.
# If 'callback' is NULL, the default function (SDL_UpdateRect) will be used.
proc SMPEG_setdisplay*(mpeg: PSMPEG, dst: PSDL_Surface, surfLock: PSDL_mutex,
callback: TSMPEG_DisplayCallback){.cdecl,
importc, dynlib: SmpegLibName.}
# Set or clear looping play on an SMPEG object
proc SMPEG_loop*(mpeg: PSMPEG, repeat_: int){.cdecl, importc, dynlib: SmpegLibName.}
# Scale pixel display on an SMPEG object
proc SMPEG_scaleXY*(mpeg: PSMPEG, width, height: int){.cdecl,
importc, dynlib: SmpegLibName.}
proc SMPEG_scale*(mpeg: PSMPEG, scale: int){.cdecl, importc, dynlib: SmpegLibName.}
proc SMPEG_Double*(mpeg: PSMPEG, doubleit: bool)
# Move the video display area within the destination surface
proc SMPEG_move*(mpeg: PSMPEG, x, y: int){.cdecl, importc, dynlib: SmpegLibName.}
# Set the region of the video to be shown
proc SMPEG_setdisplayregion*(mpeg: PSMPEG, x, y, w, h: int){.cdecl,
importc, dynlib: SmpegLibName.}
# Play an SMPEG object
proc SMPEG_play*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
# Pause/Resume playback of an SMPEG object
proc SMPEG_pause*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
# Stop playback of an SMPEG object
proc SMPEG_stop*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
# Rewind the play position of an SMPEG object to the beginning of the MPEG
proc SMPEG_rewind*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
# Seek 'bytes' bytes in the MPEG stream
proc SMPEG_seek*(mpeg: PSMPEG, bytes: int){.cdecl, importc, dynlib: SmpegLibName.}
# Skip 'seconds' seconds in the MPEG stream
proc SMPEG_skip*(mpeg: PSMPEG, seconds: float32){.cdecl, importc, dynlib: SmpegLibName.}
# Render a particular frame in the MPEG video
# API CHANGE: This function no longer takes a target surface and position.
# Use SMPEG_setdisplay() and SMPEG_move() to set this information.
proc SMPEG_renderFrame*(mpeg: PSMPEG, framenum: int){.cdecl,
importc, dynlib: SmpegLibName.}
# Render the last frame of an MPEG video
proc SMPEG_renderFinal*(mpeg: PSMPEG, dst: PSDL_Surface, x, y: int){.cdecl,
importc, dynlib: SmpegLibName.}
# Set video filter
proc SMPEG_filter*(mpeg: PSMPEG, filter: PSMPEG_Filter): PSMPEG_Filter{.cdecl,
importc, dynlib: SmpegLibName.}
# Return NULL if there is no error in the MPEG stream, or an error message
# if there was a fatal error in the MPEG stream for the SMPEG object.
proc SMPEG_error*(mpeg: PSMPEG): cstring{.cdecl, importc, dynlib: SmpegLibName.}
# Exported callback function for audio playback.
# The function takes a buffer and the amount of data to fill, and returns
# the amount of data in bytes that was actually written. This will be the
# amount requested unless the MPEG audio has finished.
#
proc SMPEG_playAudio*(mpeg: PSMPEG, stream: PUInt8, length: int): int{.cdecl,
importc, dynlib: SmpegLibName.}
# Wrapper for SMPEG_playAudio() that can be passed to SDL and SDL_mixer
proc SMPEG_playAudioSDL*(mpeg: Pointer, stream: PUInt8, length: int){.cdecl,
importc, dynlib: SmpegLibName.}
# Get the best SDL audio spec for the audio stream
proc SMPEG_wantedSpec*(mpeg: PSMPEG, wanted: PSDL_AudioSpec): int{.cdecl,
importc, dynlib: SmpegLibName.}
# Inform SMPEG of the actual SDL audio spec used for sound playback
proc SMPEG_actualSpec*(mpeg: PSMPEG, spec: PSDL_AudioSpec){.cdecl,
importc, dynlib: SmpegLibName.}
# This macro can be used to fill a version structure with the compile-time
# version of the SDL library.
proc SMPEG_GETVERSION*(X: var TSMPEG_version)
# implementation
proc SMPEG_double(mpeg: PSMPEG, doubleit: bool) =
if doubleit: SMPEG_scale(mpeg, 2)
else: SMPEG_scale(mpeg, 1)
proc SMPEG_GETVERSION(X: var TSMPEG_version) =
X.major = SMPEG_MAJOR_VERSION
X.minor = SMPEG_MINOR_VERSION
X.patch = SMPEG_PATCHLEVEL