# sdlBasic はシンプルな 2D ゲームを作成するための小規模 BASIC 処理系です。
#
# sdlBasic の動作環境:
#     linux(最新版を推奨)
#     windows (9x と NT-XP ベース)
#     macOSX
#     FreeBSD
#     OpenBSD
#     MorphOS
#     AmigaOS
#
# この BASIC は GPL ライセンスパワーの実証です。
# BASIC インタプリタは LGPL ライセンスで配布されている David Cuny 作の wxBasic ("https://wxbasic.sourceforge.net/") からの派生製品です。
# グラフィックスシステムは GPL ライセンスで配布されている SDL グラフィックスライブラリとその関連製品 ("https://www.libsdl.org/") をベースとしています。
# 初期のグラフィックスエンジンは C で開発されており GPL ライセンスで配布されている aliens デモゲーム ("https://www.libsdl.org/projects/aliens") をベースとしています。
# 後期のグラフィックスエンジンはゼロから完全に書き直してあります。
# putpixel と getpixel ルーチンは SDL チュートリアルの派生品であり、 Gigi Davassi (ジジ・デイバシー) の提案で改良しました。
# オリジナルの線描ルーチンは Alvyn Basic ("https://alvyn.sourceforge.net/") 開発者の使用許諾を得て sdlBasic へ組み込みました。
# LGPL ライセンスで配布されている sdldraw ライブラリ ("https://sdl-draw.sourceforge.net/") のソースコードも使用しております。
#
# sdlBasic からの切り取り、貼り付け、および改変後のコードは GPL の配布条件を遵守してください。
# このソフトウェアは LGPL ライセンスで保護されており、これで作成したプログラムは自由に扱えます。
#
#_________________________________________________________________________________________________________________#
#
# sdlBasic のコマンドと文法リスト:
#
# 詳細情報は総合取扱説明書をお読みください。
#
# セクション:
#    ランタイム
#    サブルーチンと関数
#    制御構造
#    演算子
#    配列
#    文字列
#    算術処理
#    ファイル
#    ディレクトリ
#    Data 関数
#    コンソール出力
#    日付と時刻
#    メモリバンク
#
#    スクリーン
#    グラフィックス
#    ファイルの入出力
#    画像処理
#    画像転送
#    スプライトシステム
#    Bob システム
#    テキストの描画
#    スクリーン出力
#    サウンドとミュージック
#    CD サポート
#    MPEG ビデオ
#    キーボード
#    マウス
#    ジョイスティック
#    SDLtime
#    ソケット
#
#________________________________________________________________________________________________________________
#
# 備考:
# *  	 不動機能
# ** 	 不動機能でありテストが必要
# ?          	 正常に動作しない: 未解決の不具合
# -> 	 廃止予定
#
#________________________________________________________________________________________________________________
# ランタイム

# コマンドライン引数
# --nodefaults	: デフォルトのディスプレイ設定を無効化
# --nosound  	: サウンドの無効化
# --nosocket 	: ソケットサポートの無効化
# --debug    	: ステップ実行モードで sdlBasic を起動
# --version  	: バージョン情報の表示 (ISO 日付)
# --license  	: ライセンス形態を表示
# --copyright	: 作権情報の表示 ( ;-) 当然ですがフリーソフトウェア )
# --help                : 実行オプションのリストを表示
#

const					: declaration of numeric constant
option explicit				: must declare variable
option qbasic				: qbasic mode you can use a function before create in a code
include(filename)			: inclusion of extern source file
argc					: return number of args in caller
argv(index)				: return arg in caller
command [param]				: returns requested arg from command line
command$ [param]			: returns requested arg from command line
argument(optional n)			: returns the arguments sends to sub/function with n=0 or without parameter will be return the arguments count
argument$(optional n)			: returns the arguments sends to sub/function with n=0 or without parameter will be return the arguments count
?setenv(varname,value)			: set a enviremont variable in currently os. if variable exist it will be overwrite
getenv(varname)				: return the value of enviremont variable in currently os
*run					: run command on new thread
shell					: execute command, wait until finished
end					: terminate program and exit
stop					: breakpoint and start debug

os					: return the operative system in work (linux windows macosx etc...)
isfbsd					: return 1 if the current os is FreeBSD
isosx					: return 1 if the current os is MacOSX
islinux					: return 1 if the current os is linux
iswin32					: return 1 if the current os is windows
ismos					: return 1 if the current os is MorphOS
isnetbsd				: return 1 if the current os is NetBSD
isamigaos				: return 1 if the current os is AmigaOS

# debug : work with option --debug at start or when you press ctrl+c key in interpretation of basic program
# if you press F5 you continue the normal execution
# with F6 you advanced in execution of one step
# with F4 you can see the vale of the prompted variable. For see the value of an array you must enter the name
# of array without the square bracket and at the request you must enter the indexes of record requested.

#_________________________________________________________________________________________________________________________
# サブルーチンと関数

declare [sub | function][name]		: declare a subrutine/function in qbasic mode
sub [name](args...)			: start a subrutine
exit sub 				: break a subrutine
end sub					: terminate a subrutine

function [name](args...)		: start a function
exit function				: break a function
end function				: terminate a function
return [value | variable]		: set the result of a function(can substituite funcname=x)

#_________________________________________________________________________________________________________________________
# 制御構造

while [condition expression]		: start while cycle
wend					: end while cycle
end while				: end while cycle
exit while				: stop while cycle
continue				: terminate the last while cycle

if [condition expression]		: classic if control structure
then					: then must be terminate a command
else					: classic else:it must be a single command
elseif					: elseif is support in sdlBasic
end if					: must terminate a if structure

select case [condition expression]	: similar to c switch (syntax like pascal)
case					: control condition
case else				: default condition
end select				: end select case structure

for[var]=[val1]to[val2][step[vals]]	: classic for-next well implemented
for each [var] in [array]		: for each are well supported warning: report the indexes of array not the value
continue				: force the exit of for next cycle (work only with for each)
exit for				: force the exit of for next cycle
next					: end for loop
end for					: sdlBasic accept end for

do 					: start a do-loop cycle
loop					: the bottom  of do-loop cycle
exit do					: the exit of a do-loop cycle

*repeat					: not implemented yet
*until					: not implemented yet

or					: condition in espression logic or
and					: condition in espression logic and
xor					: condition in espression logic xor
not					: condition in espression logic not


#_________________________________________________________________________________________________________________________
# 演算子

[+]					: 加算演算子
[-]					: 減算演算子
[*]					: 乗算演算子
[/]					: 除算演算子
[^]					: 指数演算子
mod					: 余剰演算子
shl					: 左シフト
shr					: 右シフト

#_________________________________________________________________________________________________________________________
# 配列

dim [name][[index of array]]		: declare an array note: array use [] for parentesis
*redim [name][[index of array]]		: redeclare an array
shared [variable]			: declare variable extern in a subrutine
common	[variable]			: declare variable or array global
lbound	[array]				: returns lower bound of array
*quicksort [array]			: sort an array
ubound [array]				: upperbound of array
erase [array]				: free an array

#_________________________________________________________________________________________________________________________
# 文字列

asc(char)				: returns ascii value of first char in string
chr(v)					: return string corresponding to ascii key value
chr$(v)					: return string corresponding to ascii key value
*format()				: returns formatted string with embedded args
*format$()				: returns formatted string with embedded args
insert(source$,target$,position)	: insert source string to target at index
insert$(source$,target$,position)	: insert source string to target at index
instr(optional start,source$,target$)	: returns position in source that target was found
lcase(string$)				: convert string to lower case
lcase$(string$)				: convert string to lower case
left(string$,number)			: returns leftmost chars in string
left$(string$,number)			: returns leftmost chars in string
len(string$)				: return length of string
length(string$)				: return length of string
ltrim(string$)				: returns string with left whitespace removed
ltrim$(string$)				: returns string with left whitespace removed
mid(string$,start,optional end)		: returns string with chars 1..n from source
mid$(string$,start,optional end)	: returns string with chars 1..n from source
replace(opt index,source$,replace$)	: replace string from source with replace starting at index
replace$(opt index,source$,replace$)	: replace string from source with replace starting at index
replacesubstr(source$,rep$)		: replace substring in source with withstring return the new string
replacesubstr$(source$,rep$)		: replace substring in source with withstring return the new string
reverse(string$)			: reverse a string return the new string
reverse$(string$)			: reverse a string return the new string
right(string$,number)			: returns rightmost chars in string
right$(string$,number)			: returns rightmost chars in string
rinstr(optional start,source$,target$)	: reverse Instr function, search from end to start
rtrim(string$)				: right trim string
rtrim$(string$)				: right trim string
space(n)				: return string with n spaces in it
space$(n)				: return string with n spaces in it
str(value)				: return string representation of numeric expression
str$(value)				: return string representation of numeric expression
strf(value)				: converts a floating point or number value to a string
strf$(value)				: converts a floating point or number value to a string
string(n,string$)			: returns string m chars wide with n in it
string$(n,string$)			: returns string m chars wide with n in it
tally(src$,sub$)			: returns number of occurances of matchstring
trim(string$)				: trim string
trim$(string$)				: trim string
typeof(variable)			: returns string with datatype
typeof$(variable)			: returns string with datatype
ucase(string$)				: convert string to upper case
ucase$(string$)				: convert string to upper case
val(string$)				: returns closest numeric representation of number

#_________________________________________________________________________________________________________________________
# Maths

abs(value)				: returns absolute value of number
acos(value)				: returns arccos of number
asin(value)				: returns arcsin of number
atan(value)				: returns arctan of number
bin(value)				: returns binary representation of number
bin$(value)				: returns binary representation of number
cos(value)				: returns cos of number
exp(value)				: returns exponential function
fix(value)				: truncate fractional number, rounding down towards zero
floor(value)				: truncate fractional number, rounding down towards zero
frac(value)				: return fractional portion of number
hex(value)				: returns hexidecimal representation of number
hex$(value)				: returns hexidecimal representation of number
int(value)				: convert to 32 bit integer, truncating decimals
log(value)				: returns natural log of expression
randomize(value)			: reseed the random number generator
rnd(optional upper)			: return an random number
round(value)				: round to nearest integer
sgn(value)				: returns sign of numeric expression
sin(value)				: returns sine of given angle in radians
sqr(value)				: return square root - make sure it's non-negative
tan(value)				: return tanget of given angle in radians
min(value1,value2)			: return min number of the operands
max(value1,value2)			: return max number of the operands
bitwiseand(value1,value2)		: return the logic and of the operands
andbit(value1,value2)			: return the logic and of the operands
bitwiseor(value1,value2)		: return the logic or of the operands
orbit(value1,value2)			: return the logic or of the operands
bitwisexor(value1,value2)		: return the logic xor of the operands
xorbit(value1,value2)			: return the logic xor of the operands

#________________________________________________________________________________________________________________________
# ファイル

open[filename]for{input|output|append}as[stream]: open file stream
file input #[stream]			: read a line from file stream
input #[stream]				: read a line from file stream
file output #[stream]			: print a line in file stream
print #[stream]				: print a line in file stream
close [stream]				: close file stream

eof(stream)				: returns nonzero if Eof
fileexists(filename)			: returns true if the file exists
filecopy(source,dest)			: copy a file
filemove(source,dest)			: move a file
filerename(filename,newname)		: rename a file
freefile()				: return the handle of the next free file
kill(filename)				: delete filename. filename can be then path+filename
filedelete(filename)			: delete filename. filename can be then path+filename
loc(stream)				: returns position in file
lof(stream)				: returns length of file
readbyte(stream)			: return a byte from the file
rename(filename,newname)		: rename file
seek(stream)				: seek file position/return current file position
writebyte(stream,byte)			: write a byte in the file

#_________________________________________________________________________________________________________________________
# ディレクトリ

chdir(path)				: change directory
dir dir$				: returns current path
direxists(path)				: returns true if directory exists
dirfirst(path)				: returns first entry in path dir
dirnext					: returns next entry in path dir
mkdir(path)				: create a new directory
rmdir(path)				: remove directory

#_________________________________________________________________________________________________________________________
# Data 関数

data(optional 0-255 param)		: store the data
read(optional pointer)			: without parameter read a data record with point change the next data loaded

#_________________________________________________________________________________________________________________________
# コンソール出力

print [text|variable|number]		: 標準出力へ式を表示します (デバッグ出力用)

#_________________________________________________________________________________________________________________________
# 日付と時刻

date() 					: returns date in MM-DD-YYYY format
date$()					: returns date in MM-DD-YYYY format
time() 					: return time in HH:MM:SS format
time$()					: return time in HH:MM:SS format
ticks()					: returns current timer value

#_________________________________________________________________________________________________________________________
# メモリバンク


reservebank(bank,size)			: make a raw memory bank. there are 256 bank ( 0 - 255)
baseimage(bank,image)			: link a memorybank from a imagebank bitmap access
baseimageCC(bank,image)			: link a memorybank from a imagebank bitmap access with colorkey trasparency
basescreen(bank,image)			: link a memorybank from a screen bitmap access
basesound(bank,sound)			: link a memory bank with soundb bank

freebase(bank)				: unconnect a memory bank with a image or screen
freebank(bank)				: destroy a memory bank

copybank(s,d)				: copy the bank s in d

loadbank(filename,optional bank)	: load a file in memory bank (if omitted the current )
savebank(filename,optional bank)	: save memory bank in a file

setbank(optional bank)			: set the current bank (if omitted return the current)
currentbank(optional bank)		: set the current bank (if omitted return the current)
sizebank(optional bank)			: return the bank memory size (if omitted return the value of current bank)
banksize(optional bank)			: return the bank memory size (if omitted return the value of current bank)

poke(optional bank,address,value)	: write a byte value in memory bank at specific address
doke(optional bank,address,value)	: write a 16bit value in memory bank at specific address
loke(optional bank,address,value)	: write a 32bit value in memory bank at specific address

peek(optional bank,address)		: read a byte value in memory bank at specific address
deek(optional bank,address)		: read a 16bit value in memory bank at specific address
leek(optional bank,address)		: read a 32bit value in memory bank at specific address

memcopy(sbank,s,dbank,d,size)		: copy a part of bank memory s in d

#_________________________________________________________________________________________________________________________
# スクリーン

setdefaults(w,h,bpp,m)			: open the display, perform initializations on cursor and fonts and sets default values on sprites, bobs and screens system.
setdisplay(w,h,bpp,m)			: open the screen/window in double buffer. 0=fullscreen|1=window|2=resizable|3=fullscreen software|4=window without decoration 
setcaption(title)			: change the display window title
setalphachannel(v)			: activate deactivate alpha channel trasparency
caption()					: return the display window title

systemwidth				: return the native screen width
systemheight				: return the native screen height
displaymode				: return the display mode
displaywidth				: return the display width
displayheight				: return the display height
displaybpp				: return the display color depth

screen(n)				: set the logic screen n without parameter return the current screen
screenz(n,z)				: set the zorder position of screen if z =-1 report actual z position
lastscreen				: return the last screen open
directscreen 				: direct drawing on display like a screen(more fast but sprite and offset does not works)
screenopen(n,w,h,dx,dy,dw,dh,flag)	: open the logic screen n of dimension w,h in display coordinates dx,dy,dw,dh
screenclose(n)				: close the logic screen n

screenclone(n,s,x,y,w,h,flag)		: create a new viewport in logic screen s
screencopy(n,x,y,w,h,nd,xd,yd)		: copy a portion of screen n in a screen nd
screenfade(n,t)				: fade the screen n in t time in multitasking without parameter return 0 if terminate
screenfadeout(n,t)			: fade the screen n in t time in multitasking without parameter return 0 if terminate
screenfadein(n,otional i,optional t)	: fade the screen n to image i in t time in multitasking without parameter return 0 if terminate
screencrossfade(n,i,t)			: fade the screen n from current screen to image i in t time in multitasking without parameter return 0 if terminate
screenalpha(n,a)			: set alpha(trasparency) of screen n
screenlock(n)				: lock the screen n for direct graphics access
screenunlock(n)				: unlock the screen n for direct graphics access

screenrect(x,y,w,h,flag)		: change the display output coordinates of the current screen
screenviewport(x,y,w,h,flag)		: change the display output coordinates of the current screen
xscreenrect				: give the x coordinate of current screen viewport
screenviewportx				: give the x coordinate of current screen viewport
yscreenrect				: give the y coordinate of current screen viewport
screenviewporty				: give the y coordinate of current screen viewport
wscreenrect				: give the w value of current screen viewport
screenviewportw				: give the w value of current screen viewport
hscreenrect				: give the h value of current screen viewport
screenviewporth				: give the h value of current screen viewport
flagscreenrect				: give the flag value of current screen viewport
screenviewportflag			: give the flag value of current screen viewport

screenwidth				: give the current screen width
screenheight				: give the current screen height

offset(x,y)				: set the logical current screen position
screenoffset(x,y)			: set the logical current screen position
xoffset					: give the x coordinate offset in current screen
screenoffsetx				: give the x coordinate offset in current screen
yoffset					: give the y coordinate offset in current screen
screenoffsety				: give the y coordinate offset in current screen

cls 					: clear the current logic screen

screenswap				: update display,bobsystem,spritesystem
autoback(m) 				: enable / disable automatic screenswap  m=0 disable m>0 wait m milliseconds and perform screenswap m<0 perform the invocate in code screenswap after m milliseconds
setautoback(m)				: enable / disable automatic screenswap  m=0 disable m>0 wait m milliseconds and perform screenswap m<0 perform the invocate in code screenswap after m
dualplayfield(optional m)		: set/unset automatic update of a screen upper sprite
waitvbl					: wait automatic screenswap
fps(optional n)				: set/unset or give the current frame rate counter (0/1/none)

#_________________________________________________________________________________________________________________________
# グラフィックス

rgb(r,g,b)				: give current color in Uint32 format
enablepalette(optional state)		: enable disable and check the palettemode in 8 bit display
color (c,optional v)			: set palette color c with value v se missing give the current color c
palette(optional 0-255 param)		: set all palettes color(0,0xff,0xff00,....)
colorcycling(s,e,d=0|1,optional delay)	: move the palette color one color forward or back work only in 8bit display
					  if you set delay automatically colorcycling work on multitasking
colorcycling()				: stop the multitasking colorcycling
ink(c)					: select the current color in Uint32 format

point(x,y)				: give the color of x,y point
getpixel(x,y)				: give the color of x,y point
dot(x,y)				: write x,y point with a current color
setpixel(x,y)				: write x,y point with a current color
putpixel(x,y)				: write x,y point with a current color
plot(x,y,c)				: write x,y point with a c color
line(x,y,x1,y1)				: write a line
box(x,y,x1,y1)				: write a empty rettangle
bar(x,y,x1,y1)				: write a fill rettangle
circle(x,y,r)				: write a circle
fillcircle(x,y,r)			: write a fill circle
ellipse(x,y,rx,ry)			: write a ellipse
fillellipse(x,y,rx,ry)			: write a fill ellipse
paint(x,y)				: fill a close area
triangle(xa,ya,xb,yb,xc,yc)		: draw a fill triangle
polyline(xa,ya,xb,yb,xc,yc,.....)	: draw a perimeter of a polygon
polygon(xa,ya,xb,yb,xc,yc,.....)	: draw a fill polygon

#_________________________________________________________________________________________________________________________
# ファイルの入出力

loadimage(filename,optional n)		: load a graphics file in a slot n if omitted n is the first free return n
loadzipimage(zipfile,filename,opt n)	: load a zipped graphics file in a slot n if omitted n is the first free return n
saveimage(filename,n)			: save slot n in a graphics file(only bmp)
loadsound(filename,opt n)		: load a wave file in a sound slot n
loadzipsound(zipfile,filename,opt n)	: load a zipped wave file in a sound slot n
?savesound(filename,n)			: save a wave file from sound slot n (low quality result)
loadmusic(filename)			: load a music module (mod family,ogg,mp3 and midi)

#_________________________________________________________________________________________________________________________
# 画像処理

hotspot(n,x,y)				: select the point of coordinates in a imageslot (n,0,0=up left(default) | n,1,1=center | n,2,2 =down right)n= image
setcolorkey(c)				: set the colorkey for bitmap transparency if set -1 (default ) will be used the left-up corner color.
colorkey(c)				: set the colorkey for bitmap transparency if set -1 (default ) will be used the left-up corner color.
imageexists(n)				: give 1 if the image buffer n exist 0 if empty
imagewidth(n)				: give the image n width or error if image n if empty
imageheight(n)				: give the image n height or error if image n if empty
deleteimage(n)				: erase the image n of the memory
copyimage(s,d)				: copy image s to image d
setalpha(n,a)				: set trasparency in image n
imagealpha(n,a)				: set trasparency in image n
zoomimage(n,zoomx,zoomy)		: zoom image
rotateimage(n,angle)			: rotate image
rotozoomimage(n,angle,zoom)		: rotate and zoom image
mirrorimage(n,x,y)			: vertical-orizontal mirror

#_________________________________________________________________________________________________________________________
# 画像転送

blt(n,sx,sy,sw,sh,dx,dy)		: copy a part of graphics slot in screen
pastebob(x,y,n)				: copy on screen image n at x,y performing clip
pasteicon(x,y,n)			: copy on screen image n at x,y without colorkey trasparency
grab(n,x,y,w,h)				: grab a a selectarea and copy it in slot n

#_________________________________________________________________________________________________________________________
# Sprite System
#
# In this implementation there are 512 sprites software that are indipendent from the screens

spriteclip(x,y,w,h)			: set the visibilty area of sprites
sprite(n,x,y,fr)			: set or move the sprite n at x,y with image fr
deletesprite(n)				: unset sprite n
xsprite(n)				: give the x of sprite n
spritex(n)				: give the x of sprite n
ysprite(n)				: give the y of sprite n
spritey(n)				: give the y of sprite n
spritewidth(n)				: give the width of sprite n
spriteheight(n)				: give the height of sprite n
frsprite(n)				: give the frame of sprite n
spriteimage(n)				: give the frame of sprite n
livesprite(n)				: give 1 if sprite n is "live"
spriteexist(n)				: give 1 if sprite n is "live"
spritehit(n,optional x)			: give 1 if sprite n have a collission with sprite x if x=-1 with any
spritez(n,z)				: set the zorder position of sprite if z omitted or-1 report actual z position
lastsprite				: return the last sprite active
autoupdatesprite(m)			: set/ unset automatic sprites update at screenswap
updatesprite				: manual sprites updates at next screenswap

#_________________________________________________________________________________________________________________________
# Bob System
#
# In this implementation there are 512 bobs software that are dipendent from the screens and performs
# background preserve

setbob(n,scr)				: set bob n at logic screen scr
bob(n,x,y,fr)				: set or move bob n at x,y with frame fr
deletebob(n)				: unset bob n
xbob(n)					: give x of bob n
bobx(n)					: give x of bob n
ybob(n)					: give y of bob n
boby(n)					: give y of bob n
bobwidth(n)				: give width of bob n
bobheight(n)				: give height of bob n
frbob(n)				: give the frame of bob n
bobimage(n)				: give the frame of bob n
livebob(n)				: give 1 if bob n is "live"
bobexist(n)				: give 1 if bob n is "live"
bobhit(n,optional x)			: give 1 if bob n have a collision with bob x if x=-1 with any
bobz(n,z)				: set the zorder position of bob if z =-1 report actual z position
lastbob					: return the last bob active
autoupdatebob(m)			: set/ unset automatic bobs update at screenswap
updatebob				: manual bobs updates at next screenswap

#_________________________________________________________________________________________________________________________
# グラフィックス

text(x,y,s,testo,optional type)		: print the text testo on current screen with s size The type of render can be default=solid 1=Shaded 2=blended
setfont(path)				: select the font
getfont()				: return the current font
textrender(testo,s,optional n,optional type) : make an image slot n with the text write with a current font and size s if n is omitted use and return first free The type of render can be default=solid 1=Shaded 2=blended

#_________________________________________________________________________________________________________________________
# スクリーン出力

pen(c)					: set prints color (without parameter give the current color)
paper(c)				: set caractere back color (without parameter give the current color)
fprints(testo)				: print a text monospace without cariage return
prints(testo)				: print a text monospace
locate(x,y)				: move the cursor at x y
atx					: give x of cursor
aty					: give y of cursor
curson					: show the text cursor on screen at(atx,aty)
cursoff					: hide the text cursor
inputs(prompt,defs)			: give the string insert to keyboard(default is default text)
zoneinputs(x,y,l,default)		: give the string insert to keyboard in x,y coordinates with l lenght

#_________________________________________________________________________________________________________________________
# サウンドとミュージック

isenabledsound()			: return 1 if sdlsound was enabled
soundenabled()				: return 1 if sdlsound was enabled

soundexists(n)				: give 1 if the sound buffer n exist 0 if empty
deletesound(n)				: delete from memory sound n
copysound(s,d)				: copy sound bank s in sound bank d

musicexists()				: give 1 if the music is load 0 if empty

playsound(n,c,optional l)		: play the sound n in channel c l loops
playfreqsound(n,c,pitch,optional l)	: play the sound n in channel with pitch resampling frequency c l loops
volumesound(c,optional v)		: change the volume of channel c (-1 all) at value v (0-128) without v or -1 give the current volume
soundvolume(c,optional v)		: change the volume of channel c (-1 all) at value v (0-128) without v or -1 give the current volume
stopsound(optional c)			: stop the wave play in channel c (-1 or none =all)
pausesound(optional c)			: paused channel c (-1 or none =all)
resumesound(optional c)			: unpaused channel c (-1 or none =all)
?vumetersound(optional c)		: give the current state of sound channel (-1 or none=all)
sound3d(c,angle,dist)			: position sound in 3d space
positionsound(c,angle,dist)		: position sound in 3d space
soundchannels(n)			: dinamically change the number of channells managed by sdlBasic

playmusic(n)				: play track xm,mod,ogg,mp3 n=number of ripetition(-1 always)
positionmusic(p)			: move the execution at p second
stopmusic				: terminate the music play
pausemusic				: set pause of the current music
resumemusic				: unset pause of musica
rewindmusic				: report at start the music
fademusic(t)				: music fade
volumemusic(optional v)			: change the volume of music (0-128) -1 or none give the current volume
musicvolume(optional v)			: change the volume of music (0-128) -1 or none give the current volume
speedmusic(v)				: change the speed of music
musicspeed(v)				: change the speed of music

#_________________________________________________________________________________________________________________________
#CD サポート

numdrivescd() 				: returns the number of cd-rom drives on the system.
countcddrives()				: returns the number of cd-rom drives on the system.
namecd(drive)				: returns a human-readable, system-dependent identifier for the cd-rom.
cdname(drive)				: returns a human-readable, system-dependent identifier for the cd-rom.
opencd(n,drive)				: opens a cd-rom drive for access.
indrivecd(n)				: return 1 if cd is in driver
cdinserted(n)				: return 1 if cd is in driver
trackscd(n) 				: return the number of tracks in cd
countcdtracks(n) 				: return the number of tracks in cd
curtrackcd(n)				: return the current track in cd
cdcurtrack(n)				: return the current track in cd
curframecd(n)				: return the current frame in cd
cdcurframe(n)				: return the current frame in cd
playcd(n,s,l) 				: play a cd
playtrackscd(n,trk1,fr1,ntrks,nfrs)	: play the given cd track(s) from frame fr1 of trrack trk1 for ntrks/nfrs
playtrackscd(n,trk1,ntrks)		: play the given cd track(s)from trk1 for ntracks
playtrackscd(n)				: play all cd track(s)
playcdtracks(n,trk1,fr1,ntrks,nfrs)	: play the given cd track(s) from frame fr1 of trrack trk1 for ntrks/nfrs
playcdtracks(n,trk1,ntrks)		: play the given cd track(s)from trk1 for ntracks
playcdtracks(n)				: play all cd track(s)
pausecd(n) 				: pauses a cdrom
resumecd(n) 				: resumes a cdrom
stopcd(n)				: stops a cdrom
ejectcd(n) 				: ejects a cdrom
closecd(n) 				: closes a cd handle
tracktypecd(n,t)			: return SDL_AUDIO_TRACK(0...) or SDL_DATA_TRACK(1...)
cdtracktype(n,t)			: return SDL_AUDIO_TRACK(0...) or SDL_DATA_TRACK(1...)
tracklengthcd(n,t)			: return the length of track t
cdtracklength(n,t)			: return the length of track t
trackoffsetcd(n,t)			: return the offset to the beginning of this track in frames
cdtrackoffset(n,t)			: return the offset to the beginning of this track in frames

#________________________________________________________________________________________________________________________
# MPEG ビデオ

loadmpeg(fname,usesound)		: load a mpeg video
plaympeg(optional loop)			: play a mpeg1 video
stopmpeg()				: terminate the video play
deletempeg()				: unload mpeg video
pausempeg()				: Pause/Resume playback of an SMPEG object
rewindmpeg()				: Rewind the play position of an SMPEG object to the beginning of the MPEG
seekmpeg(p)				: Seek 'bytes' bytes in the MPEG stream
skipmpeg(s)				: Skip 'seconds' seconds in the MPEG stream
statusmpeg()				: return 1 if plaympeg work or 0 in other case

#_________________________________________________________________________________________________________________________
# キーボード

key(keycode)				: give 1 if is press the key keycode
inkey					: give ascii code of key press
waitkey(optional keycode)		: wait a key pression (0 =any key)

#_________________________________________________________________________________________________________________________
# マウス

xmouse					: give mouse x coordinate on display
ymouse					: give mouse y coordinate on display
mousex					: give mouse x coordinate on display
mousey					: give mouse y coordinate on display
xmousescreen(n)				: give mouse x coordinate on screen
ymousescreen(n)				: give mouse y coordinate on screen
mousescreenx(n)				: give mouse x coordinate on screen
mousescreeny(n)				: give mouse y coordinate on screen
bmouse 					: give the buttonclick on the mouse
mousebutton 				: give the buttonclick on the mouse
changemouse(optional n)			: change mouse from default(0) to emulate with sprite 0 - image 0 (1,2,3)without n return current pointer
mousepointer(optional n)		: change mouse from default(0) to emulate with sprite 0 - image 0 (1,2,3)without n return current pointer
locatemouse(x,y)			: move mouse at x y coordinates
placemouse(x,y)				: move mouse at x y coordinates
mouseshow				: show the mouse cursor
howmouse				: show the mouse cursor
mousehide				: hide the mouse cursor
hidemouse				: hide the mouse cursor
mousezone(x,y,w,h)			: give 1 if the mouse pointer is in rectangle(xy with size wh)

#_________________________________________________________________________________________________________________________
# ジョイスティック

numjoysticks 				: 利用可能なジョイスティックの台数を返します。
namejoystick(index)			: ジョイスティックの名称を取得します。
numaxesjoystick(i) 			: ジョイスティックで利用可能なアナログ軸の搭載数を取得します。
numballsjoystick(i) 			: ジョイスティックで利用可能なトラックボールの搭載数を取得します。
numhatsjoystick(i) 			: ジョイスティックで利用可能なハットの搭載数を取得します。
numbuttonsjoystick(i) 			: ジョイスティックで利用可能なボタンの搭載数を取得します。
getaxisjoystick(i,a) 			: アナログ軸に関する現在の状態を取得します。
gethatjoystick(i,a)			: ハットに関する現在の状態を取得します。
getbuttonjoystick(i,a)			: 指定されたジョイスティックのボタンに関する状態を取得します。
xgetballjoystick(i,a)			: トラックボールの移動を相対 x 座標で取得します。
ygetballjoystick(i,a)			: トラックボールの移動を相対 y 座標で取得します。
joy(i)					: ジョイスティックのスティックに関する座標を論理値 (ブーリアン) で返します。
bjoy(i)					: ジョイスティックで押されたボタンを論理値 (ブーリアン) の式で返します。
joybuttons(i)				: ジョイスティックで押されたボタンを論理値 (ブーリアン) の式で返します。
fire(i)					: ジョイスティックで押されたボタンを論理値 (ブーリアン) の式で返します。
waitbjoy(b,optional i)			: ジョイスティックのボタン (またはキーボードによるエミュレート) が押されるまで待機します。

#_________________________________________________________________________________________________________________________
# SDLtime

wait(t)					:  t ミリ秒間待機します。
timer					: 現在のティックを取得します。

#_________________________________________________________________________________________________________________________
# ソケット

isenabledsock()				: sdlnet が有効であれば 1 を返します。

sock=getfreesock()			: sdlSocket 配列にある最初の空き sock (ソック) を返します。
sock=OpenSock(port) 			: 指定されたポート番号によりソケットをリスニングモード (着信待ち受け) で開きます。sdlBasic では最大 256 ソケットストリームまで利用可能です。
					  概念上、ストリームの処理は sdlBasic のファイル操作との類似性があります。
clientsock=AcceptSock(serversock)	: Accept the client connection
IsServerReady(Sock)			: True/False if server is sending data
sock=ConnectSock(ServerName,port)	: client side socket connection
*ConnectionReadySock(sock)		: the server have accepted the connection
IsClientReady(Sock)			: True/False if client is sending data
CloseSock(sock)				: Close the socket connection. クライアントとサーバーサイドともに動作します。
*PeekSock(Sock, NumBytes)		: ソケットから得た情報を参照します (消去はしません)。
ReadSock(Sock, NumBytes)		: 指定されたバイト数をソケットから読み取ります。
ReadByteSock(Sock)			: 指定されたソケットから単バイトを読み取ります。
ReadLineSock(Sock)			: 指定されたソケットから一行まるごと読み取ります。
WriteSock(Sock, Message, NumBytes)	: 文字列から指定されたバイト数をソケットへ送信します。
WriteByteSock(Sock, Byte)		              : 指定されたソケットから単バイトを読み取ります。
WriteLineSock(Sock, Message)		: メッセージを送信します。
getremoteip(sock)			: 接続されたクライアントのリモート IP アドレスを返します。
getremoteport(sock)			: 接続されたクライアントのリモートポートアドレスを返します。
?getlocalip()				: ローカル IP アドレスを返します (Windows では動作しません)。

#_________________________________________________________________________________________________________________________
#  Sqlite データベース

SqlOpen( filename, n )		:
SqlClose( n )				:
SqlPrepare( n, pnum, sql )
SqlFinalize( n )
SqlStep( n )
SqlGetRows( n )
SqlGetColumns( n )
SqlGetText( n, col )
SqlGetImage( n, col, imageslot )



#_________________________________________________________________________________________________________________________
#
 