' SIMPLE WINDOWS LIBRARY FOR SCRIPTBASIC (sw.inc) by PETER WIRBELAUER
DECLARE SUB LoadMap ALIAS "loadstring" LIB "t"
DECLARE SUB DLLC_File ALIAS "dllfile" LIB "DLLC"
DECLARE SUB DLLC_Proc ALIAS "dllproc" LIB "DLLC"
DECLARE SUB DLLC_Call ALIAS "dllcall" LIB "DLLC"
DECLARE SUB DLLC_OleStr ALIAS "dllostr" LIB "DLLC"
DECLARE SUB DLLC_DelOle ALIAS "dlldelo" LIB "DLLC"
GLOBAL CONST WHITE = 0xFFFFFF
GLOBAL CONST DKGRAY = 0x404040
GLOBAL CONST BLUE = 0xFF0000
GLOBAL CONST BOLD = 700
' Key Defs
GLOBAL CONST vk_space = 0x20
GLOBAL CONST vk_right = 0x27
GLOBAL CONST vk_left = 0x25
GLOBAL CONST vk_up = 0x26
GLOBAL CONST vk_down = 0x28
sw = DLLC_File("sw.dll")
ms = DLLC_File("winmm.dll")
' Simple Windows function definitions
Window = DLLC_Proc(sw, "Window i = (i width, i height, i mode)")
SetCaption = DLLC_Proc(sw, "SetCaption i = (c*capText)")
GetWidth = DLLC_Proc(sw, "GetWidth 1 = ()")
GetHeight = DLLC_Proc(sw, "GetHeight i = ()")
Key = DLLC_Proc(sw, "Key i = (i mKey)")
WaitKey = DLLC_Proc(sw, "WaitKey i = ( )")
GetKey = DLLC_Proc(sw, "GetKey i = ( )")
xMouse = DLLC_Proc(sw, "xMouse i = ( )")
Wait = DLLC_Proc(sw, "Wait i = (i msec)")
yMouse = DLLC_Proc(sw, "yMouse i = ( )")
MouseButton = DLLC_Proc(sw, "MouseButton i = ( )")
Cls = DLLC_Proc(sw, "Cls i = (i color)")
DrawLine = DLLC_Proc(sw, "Line i = (i xPos, i yPos, i a, i b, i thickness, i color)")
DrawPoint = DLLC_Proc(sw, "DrawPoint i = (i xPos, i yPos, i width, i height, i color)")
SetPixel = DLLC_Proc(sw, "SetPixel i = (i xPos, i yPos, i color)")
Box = DLLC_Proc(sw, "Box i = (i xPos, i yPos, i w, i h, i thickness, i color)")
Circle = DLLC_Proc(sw, "Circle i = (i xPos, i yPos, i r1, i thickness, i color)")
FillCircle = DLLC_Proc(sw, "FillCircle i = (i xPos, i yPos, i r1, i color)")
Ellipse = DLLC_Proc(sw, "Ellipse i = (i xPos, i yPos, i r1, i r2, i thickness, i color)")
RGB = DLLC_Proc(sw, "RGB i = (i rValue, i gValue, i bValue)")
Rand = DLLC_Proc(sw, "Rnd i = (i minNumber, i maxNumber)")
SetText = DLLC_Proc(sw, "SetText i = (i xPos, i yPos, o text, i color)")
SetFont = DLLC_Proc(sw, "SetFont i = (i width, i height, i style, c*fontName)")
LoadBmp = DLLC_Proc(sw, "LoadBmp i = (c*bmpFile, i frames)")
Sprite = DLLC_Proc(sw, "Sprite i = (i idBmp, i xPos, i yPos, i frames)")
BmpText = DLLC_Proc(sw, "BmpText i = (i idBmp, i xPos, i yPos, o iText, i Zoom, i yZoom)")
DrawBmp = DLLC_Proc(sw, "DrawBmp i = (i idBmp, i xPos, i yPos, i xZoom, i yZoom, i frames)")
Sync = DLLC_Proc(sw, "Sync ( )")
Redraw = DLLC_Proc(sw, "Redraw ( )")
SetFps = DLLC_Proc(sw, "SetFps i = (i frames)")
PlayWav = DLLC_Proc(ms, "sndPlaySoundA i = (c*wavFile, i sync)")
CloseWindow = DLLC_Proc(sw, "CloseWindow i = ( )")
' Simple Windows wrapper functions
SUB SW_Window(width, height, mode)
DLLC_Call(Window, width, height, mode)
END SUB
SUB SW_SetCaption(capText)
DLLC_Call(SetCaption, capText)
END SUB
FUNCTION SW_GetWidth
SW_GetWidth = DLLC_Call(GetWidth)
END FUNCTION
FUNCTION SW_GetHeight
SW_GetHeight = DLLC_Call(GetHeight)
END FUNCTION
FUNCTION SW_Key(mKey)
SW_Key = DLLC_Call(Key, mKey)
END FUNCTION
SUB SW_WaitKey
DLLC_Call(WaitKey)
END SUB
FUNCTION SW_GetKey
SW_GetKey = DLLC_Call(GetKey)
END FUNCTION
SUB SW_Wait(msec)
DLLC_Call(Wait, msec)
END SUB
FUNCTION SW_xMouse
SW_xMouse = DLLC_Call(xMouse)
END FUNCTION
FUNCTION SW_yMouse
SW_yMouse = DLLC_Call(yMouse)
END FUNCTION
FUNCTION SW_MouseButton
SW_MouseButton = DLLC_Call(MouseButton)
END FUNCTION
SUB SW_Cls(color)
DLLC_Call(Cls, color)
END SUB
SUB SW_Line(xPos, yPos, a, b, thickness, color)
DLLC_Call(DrawLine, xPos, yPos, a, b, thickness, color)
END SUB
SUB SW_DrawPoint(xPos, yPos, width, height, color)
DLLC_Call(DrawPoint, xPos, yPos, width, height, color)
END SUB
SUB SW_SetPixel(xPos, yPos, color)
DLLC_Call(SetPixel, xPos, yPos, color)
END SUB
SUB SW_Box(xPos, yPos, w, h, thickness, color)
DLLC_Call(Box, xPos, yPos, w, h, thickness, color)
END SUB
SUB SW_Circle(xPos, yPos, r1, thickness, color)
DLLC_Call(Circle, xPos, yPos, r1, thickness, color)
END SUB
SUB SW_FillCircle(xPos, yPos, r1, color)
DLLC_Call(FillCircle, xPos, yPos, r1, color)
END SUB
SUB SW_Ellipse(xPos, yPos, r1, r2, thickness, color)
DLLC_Call(Ellipse, xPos, yPos, r1, r2, thickness, color)
END SUB
FUNCTION SW_RGB(rValue, gValue, bValue)
SW_RGB = DLLC_Call(RGB, rValue, gValue, bValue)
END FUNCTION
FUNCTION SW_Rnd(minNumber, maxNumber)
SW_Rnd = DLLC_Call(Rand, minNumber, maxNumber)
END FUNCTION
SUB SW_SetText(xPos, yPos, text, color)
LOCAL ole_text
ole_text = DLLC_OleStr(text)
DLLC_Call(SetText, xPos, yPos, ole_text, color)
DLLC_DelOle(ole_text)
END SUB
SUB SW_SetFont(width, height, style, fontName)
DLLC_Call(SetFont, width, height, style, fontName)
END SUB
FUNCTION SW_LoadBmp(bmpFile, frames)
SW_LoadBmp = DLLC_Call(LoadBmp, bmpFile, frames)
END FUNCTION
SUB SW_LoadBytes(nName, Destination)
LOCAL tmpstr
tmpstr = LoadMap(nName)
SPLITA tmpstr BY "" TO Destination
END SUB
SUB SW_Sprite(idBmp, xPos, yPos, frames)
DLLC_Call(Sprite, idBmp, xPos, yPos, frames)
END SUB
SUB SW_BmpText(idBmp, xPos, yPos, sb_iText, Zoom, yZoom)
LOCAL ole_iText
ole_iText = DLLC_OleStr(sb_iText)
DLLC_Call(BmpText, idBmp, xPos, yPos, ole_iText, Zoom, yZoom)
DLLC_DelOle(ole_iText)
END SUB
SUB SW_DrawBmp(idBmp, xPos, yPos, xZoom, yZoom, frames)
DLLC_Call(DrawBmp, idBmp, xPos, yPos, xZoom, yZoom, frames)
END SUB
SUB SW_Sync
DLLC_Call(Sync)
END SUB
SUB SW_Redraw
DLLC_Call(Redraw)
END SUB
SUB SW_SetFps(frames)
DLLC_Call(SetFps, frames)
END SUB
SUB SW_PlayWav(sfn)
DLLC_Call(PlayWav, sfn, 1)
END SUB
SUB SW_CloseWindow
DLLC_Call(CloseWindow)
END SUB