Programming tips for Turbo Pascal

when using GEMBIND

written by Heinz Rath


First one information that is missing in the original documentation don't include crt!
Because when the unit crt is included Turbo Pascal switches to Textmode when starting.
The informations in this document i have found out threw looking into the source of GEMBIND
and threw reading the AES and VDI documentation from John Eliott

And dont forget to rename the exe to app!
GEMBIND was originaly written by Jan Willamowius. Wind_Calc was added by Ben A L Jemmett

This document is still under construction


This is a inclomplete list of GEMBIND pascal calls and the original C calls

Turbo Pascal C
Init_Gem appl_init
Exit_Gem appl_exit
Load_Resource rsrc_load
Begin_Update wind_update(BEG_UPDATE)
End_Update wind_update(END_UPDATE)
Set_WName wind_set(handle,WF_NAME,...);
Set_WInfo wind_set(handle,WF_INFO,...);
Init_Mouse v_show_c(handle,0);
Do_Alert show_alert(defbutton,text);
Free_Resource rsrc_free();
Wind_Set wind_set(...);
Wind_Get wind_get(...);
Get_Event evnt_multi(...);
Get_In_File fsel_input(...);
Get_Out_File Not exisiting under C is a own Dialog of GEMBIND
Open_Window wind_open(...);
New_Window wind_create(...);
Find_Menu rsrc_gaddr(R_TREE,resource number,menuhandle)
Draw_Menu menu_bar(...);
Erase_Menu menu_bar(...);
Front_Window wind_get(...);
Set_Window wind_set(...);
Line_Color vsl_color(...);
AES_VERSION not existing in C
GEM_Installed aescheck();
Set_Mouse graf_mouse
Get_Ex_In_File fsel_ex_input(); Is only included when compiling for ATARI
Load_Fonts vst_load_fonts
Unload_Fonts vst_unloads_fonts
Set_Font vst_font
Mouse_Position Not exisiting C
Move_To Not exisiting C
Line_To Not exisiting C
Hide_Mouse Not exisiting C
Show_Mouse Not exisiting C
Bring_To_Front Not exisiting C
Alpha_Text v_alpha_text
Form_Advance v_form_adv
Get_Window Not exisiting C
Draw_Mode vswr_mode

Commands where on the C side stands not existing means not that it is impossible to make such things in C. This only means that inside of GEMBIND when the command is called there are other commands used to make the effect you wanted

Functions not exisiting in GEMBIND but exisiting in C


appl_init(X_BUF_V2); The advanced version of appl_init that is used in FreeGEM is not available under GEMBIND. fsel_ex_input(); Is implemented but outdefined when not running on Atari v_bez_on Bezier routines are missing because they are not existing v_bez_off on Atari v_bezfill v_bez_qual All XM/GEM commands All EMSLIB commands At the end of this document there you find the source to implement this functions to GEMBIND. All DOSLIB commands scrp_read At the end of this document there you find the source scrp_write to implement this functions to GEMBIND. scrp_clear wind_calc shel_write On the ATARI the equal command has a other name All WA_... constants are missing on the end of this file the are documented ALL SCRAP_... constants are missing on the end of this file the are documented


Different named constans

Turbo Pascal C
E_Keyboard MU_KEYBD
E_Button MU_BUTTON
E_Mouse1 MU_M1
E_Mouse2 MU_M2
E_Message MU_MESAG
E_Timer MU_TIMER
G_Name NAME
G_Close CLOSER
G_Full FULLER
G_Move MOVER
G_Info INFO
G_Size SIZER
G_UpArrow UPARROW
G_DnArrow DNARROW
G_VSlide VSLIDE
G_LArrow LFARROW
G_RArrow RTARROW
G_HSlide HSLIDE
G_All Does not exist in C but you can write 256
L_White DWHITE
L_Black DBLACK
L_Red DRED
L_Green DGREEN
L_Blue DBLUE
L_Cyan DCYAN
L_Yellow DYELLOW
L_Magenta DMAGENTA
GEM_Object Object
Solid SOLID
LongDash LONGDASH
Dotted DOT
DashDot DASHDOT
Dashed DAST
DashDotDot DASH2DOT
Normal TXT_NORMAL
Thickened TXT_THICKENED
Lightened TXT_LIGHT
Slanted TXT_SKEWED
Underlined TXT_UNDERLINED
Outlined TXT_OUTLINED
Shadowed TXT_SHADOWED
M_Arrow ARROW
M_Text_Curs TEXT_CRSR
M_Bee HOURGLASS
M_Point_Hand POINT_HAND
M_Flat_Hand FLAT_HAND
M_Thin_Cross THIN_CROSS
M_Thick_Cross THICK_CROSS
M_Outln_Cross OUTLN_CROSS



Messages from AES


Message Description
WM_REDRAW Is sent when the window has to be repainted
WM_TOPPED Is sent when the window is the activated one.
WM_FULLED Is sent when the maximize button is pressed
WM_CLOSED Is sent when the close button is pressed
WM_ARROWED Is sent when a scroll arror or the scrollbar is pressed.
WM_UNTOPPED Is sent when a window is not longer to topmost.
WM_MOVED Is sent when a window is moved
WM_SIZED Is sent when a window is resized
WM_HSLID Is sent when the horizontal scrollbar is used
WM_VSLID Is sent when the vertical scrollbar is used
AC_OPEN Is sent when a ACC is activated
AC_CLOSE Is sent when a ACC is deactivated
MN_SELECTED Is sent when a menu item is selected



Description of Turbo Pascal GEMBIND commands



Function Init_GEM: Integer; If the function fails it returns a number <0 else it contains the application ID The application ID is only needed when writing Desktop Accessories (ACC).
Procedure Exit_GEM; Frees all AES resources used by the program should be called at the end.
Procedure Init_Mouse; Switches the mouse on. This call is normally not needed on PC-GEM
Function Load_Resource(Name: String): Boolean; Loads the resource file returns FALSE if it fails otherwise TRUE.
Procedure Free_Resource; Gives the loaded resource free.
Function Get_Event(emask, bmask, bstate, n_clicks : Integer; ticks : LongInt; m1_flag : Boolean; m1x, m1y, m1w, m1h : Integer; m2_flag : Boolean; m2x, m2y, m2w, m2h : Integer; Var message : Message_Buffer; Var key, brtn, bclick, mx, my, kstate : Integer): Integer; In emask you set the event flags E_Button,E_Mouse1,E_Keyboard and so ...
Variable For what
Message Message Buffer
M1_Flag Mouse rectangle 1 flag
M2_Flag Mouse rectangle 2 flag
m1x X Position for mouse rectangle 1
m1y Y Position for mouse rectangle 1
m1w Wide for mouse rectangle 1
m1h Height for mouse rectangle 1
m2x X Position for mouse rectangle 2
m2y Y Position for mouse rectangle 2
m2w Wide for mouse rectangle 2
m2h Height for mouse rectangle 2
mx X position of mouse
my Y position of mouse
bclick mousebutton


Function Get_In_File(Var Path, Name : Path_Name) : Boolean; Displays a File select box Normal GEM file select box
Function Get_Out_File(Prompt: Str255; Var Name: Path_Name): Boolean; Displays a File select box for saveing is a self drawed Dialog On this screenshot the prompt is TEST.PAS
Procedure Set_WName(Handle : Integer; Var Name : Window_Title); Sets the window title of the window specified threw the handle
Procedure Set_Winfo(Handle : Integer; Var info : Window_Title); Sets the info line of the window specified threw the handle
Procedure Find_Menu(Index: Integer; Var Menu: Menu_Ptr); Sets the Menu pointer to menu inside of the resource specified threw the index.
Procedure Draw_Menu(Menu : Menu_Ptr); Shows the menu specified threw menu. First the menu has to be found with Find_Menu
Procedure Erase_Menu(Menu : Menu_Ptr); Removes the menu bar
Function Do_Alert(Maske: Str255; Btn: Integer): Integer; Shows a alert window Btn is the default button when showing the window 1-3 of button or 0 for none Maske is the message which contains 3 parts [n][text][but] n - Is the Icon number 0 - none 1 - warning 2 - question 3 - stop text - is the text that should appear if you need more than one line make | all after this is written into the next line but - is the text of the button if you want to have more than 1 button write for example [Ok|Cancel] or [Load|Save|Cancel] The function returns the number of the button that was pressed This are the original GEM/3 icons if you use a modified version there maybe other icons Warning Icon Question Icon Stop Icon

Function New_Window(w_type : Integer; Var Title : Window_Title; x_max, y_max, w_max, h_max : Integer): Integer; Creates a window w_type are the flags, title is the title of the window,... Returns a handle to the window Possible Flags G_Name, G_Close, G_Full, G_Move, G_Info, G_Size, G_UpArrow, G_DnArrow, G_VSlide, G_LArrow, G_RArrow, G_HSlide, G_All
procedure Open_window (Handle: Integer;x,y,w,h: Integer); Opens the window specified threw handle at x,y with a width of w and height of h. Before a window can be opened it must be created with New_Window
function Front_Window: Integer; Returns the handle of the topmost window or 0 if no window is open
procedure Set_Window (Handle: Integer); Sets the window specified threw handle to be the topmose one.
procedure Line_Color(color_index: Integer); Sets the color for line drawing
Function GEM_Installed : Boolean; Checks if the AES is in memory. Returns TRUE when the AES is is memory.
Function AES_Version: Integer; Returns the version number of the AES.
Procedure Close_Window(Handle : Integer); Closes the Window. The window can be reopened. Handle is not given free.
Procedure Delete_Window(Handle : Integer); Window is destroyed the handle is given free.
Procedure Plot(x, y: Integer); Sets a pixel at position x,y. Color is the actual line drawing color.
Procedure Pline(x1, y1, x2, y2: Integer); Draws a line from X1,Y1 to X2,Y2
Procedure Menu_Check(Menu : Menu_Ptr; Item : Tree_Index; Checked : Boolean); Marks menu item as checked or unchecked.
Procedure Set_Mouse(M_Type : Mouse_Type); Sets the Mouse cursor type
This are the original GEM/3 icons if you use a modified version there maybe other icons On the Atari GEM there is no hourglass there it is a Bee instead. M_Arrow M_Text_Curs M_Bee M_Point_Hand M_Flat_Hand M_Thin_Cross M_Thick_Cross M_Outln_Cross
Procedure Set_MForm(Var Form : Mouse_Form); Sets the mouse cursor to a user defined form.
Function Load_Fonts: Integer; Returns the number of loaded fonts
Procedure Unload_Fonts; ? Unloads fonts ?
Procedure Clear_Screen; Clears the complete screen with Color White
Procedure Begin_Update; Locks the screen so the AES can't draw on the screen.
Procedure End_Update; UnLocks the screen so the AES can draw on the screen.
Procedure Set_Font(Font : Integer); Selects the font to use. Font can be Small_Font or System_Font. Small_Font is the 6x6 sized font System_Font is the normal font (on VGA 8x16)
Procedure Mouse_Position(x, y: Integer); Sets the mouse to position x,y
Procedure Wind_Get(Handle, request : Integer; Var v1, v2, v3, v4 : Integer); Handle - Handle of window request - one of the following flags v1,v2,v3,v4 - Results
Flag For what
WF_WorkXYWH The area that can be drawen
WF_CurrXYWH The current size of the window
WF_PrevXYWH Previous size or position of window
WF_FullXYWH Full window size or position
WF_NextXYWH Next region that must be redrawn
WF_HSlide Position of horizontal slider
WF_VSlide Position of vertical slider
WF_HSlsize Size of horizontal thumb
WF_VSlsize Size of vertical thumb
WF_Top Handle of topmost window

Procedure Wind_Calc(CalcType, WinType : Integer; Var x, y, w, h : Integer); { BALJ - 20000604 - Wind_Calc routine seemed to be missing }
Procedure Wind_Set(Handle, Request : Integer; v1, v2, v3, v4 : Integer); request - one of the following flags v1,v2,v3,v4 - Parameters to be set
Flag For what
WF_CurrXYWH Sets the size of the window
WF_Name Sets the title of a window
WF_Info Sets the status text of a window
WF_HSlide Sets position of horizontal slider
WF_VSlide Sets position of vertical slider
WF_HSlsize Sets size of horizontal thumb
WF_VSlsize Sets size of vertical thumb
WF_Top Handle of window to be topmost


Function Open_Workstation(Id, Mode, Size: Integer): Integer; Opens a Workstation and returns a handle to it. Id - specifies the driver type and can be one of the following 1 - 9 Screen 11 - 19 Plotter 21 - 29 Printer 32 - 39 GKS metafile Mode - Is Mode 1 - NDC 2 - Pixel
Procedure Close_Workstation; Closes the workstation
Procedure Clear_Workstation; Clears the current picture in the buffer
Procedure Update_Workstation; Reprints everything to be sure evenrything is shown.
Procedure Form_Advance; Throws a page on a printer device
Procedure Alpha_Text(t: Str255); Sends the text t to the printer
Procedure Hide_Mouse; Turns Mouse Pointer off
Procedure Show_Mouse; Turns Mouse Pointer on
Procedure Find_Dialog(Index: Integer; Var Dial: Dialog_Ptr); Sets the Dialog_Ptr Dial to the Dialog with index Index
Procedure Find_Alert(Index: Integer; Var Alert: Str255);
Function Find_Resource(R_Type, R_Index: Integer): Tree_Ptr; Returns a Tree_Ptr to the rescoure from type R_Type with index R_Index. R_Type can be one of the following R_Tree R_Object R_Tedinfo R_Iconblock R_Bitblk R_String
Procedure Form_Dial(flag,litx,lity,litw,lith,bigx,bigy,bigw,bigh: Integer);
Function Form_Do(Dialog: Dialog_Ptr; Ed_Start: Integer): Integer;
Procedure Obj_Draw(Dialog: Dialog_Ptr; Start, Tiefe, x,y,w,h: Integer);
Function Do_Dialog(Dialog: Dialog_Ptr; Ed_Start: Integer): Integer; Shows a dialog on screen Dialog.....Pointer to dialog Ed_Start...? Returns the index of the object that cause the dialog to end
Function Redo_Dialog(Dial: Dialog_Ptr; Ed_Start: Integer): Integer;
Procedure Show_Dialog(Dialog: Dialog_Ptr); Shows the Dialog
Procedure Center_Dialog(Dial: Dialog_Ptr); Centers the dialog on screen.
Procedure End_Dialog(Dialog: Dialog_Ptr); Closes Dialog
Procedure Set_DText(Dial: Dialog_Ptr; Item: Tree_Index; s: Str255; Font: Integer; Just: TE_Just); Sets a text string in a Dialog Dial.........Pointer to dialog Tree_Index...Index number returned from Add_Ditem s............Text to output Font.........Font to use Just.........Can be TE_LEFT,TE_RIGHT,TE_CENTER
Procedure Set_DEdit(Dial: Dialog_Ptr; Item: Tree_Index; Template, Valid, Initial: Str255; Font: Integer; Just: TE_Just); Sets a text into e edito box of a dialog Dial......Pointer to dialog Item......Index number of edit box Template.. Valid..... Initial... Font......Font to use (normally System_Font) Just......Justification of text (normally TE_LEFT)
Procedure Obj_SetState(Dial: Dialog_Ptr; Index: Tree_Index; State: Integer; Redraw: Boolean); Sets the stale of dialog item (for example to set a button back to normal after pressing). Dial....Pointer to dialog Index...Index of Item (for example button) State...State of item Redraw..If the the item should be redrawn (Normally set to true)
Function Obj_State(Dial: Dialog_Ptr; Index: Integer): Integer;
Procedure Obj_SetFlags(Dial: Dialog_Ptr; Index: Tree_Index; Flags: Integer);
Function Obj_Flags(Dial : Dialog_Ptr; Index : Integer) : Integer;
Procedure Get_DEdit(Dial : Dialog_Ptr; Item : Tree_Index; Var s : Str255); Returns the content of a Edit box from a dialog. Dial......Pointer to dialog Item......Item number of editbox Name......Content of edit box
Procedure Menu_Hilight(Menu : Menu_Ptr; Title : Tree_Index); Sets the menu as selected
Procedure Menu_Normal(Menu : Menu_Ptr; Title : Tree_Index); Sets the menu as not selected
Procedure Menu_Enable(Menu : Menu_Ptr; Item : Tree_Index); Marks menu item Item as enabled
Procedure Menu_Disable(Menu : Menu_Ptr; Item : Tree_Index); Marks menu item Item as disabled
Procedure Menu_Text(Menu: Menu_Ptr; Item: Tree_Index; MText: Str255);
Function Menu_Register(Id : Integer; Var Name : Str255) : Integer; Adds the name of ACC to the Desk menu. Id = Id of the acc Name = Name to show in the menu Returns the id number of the menu item or -1 for error
Procedure Menu_Unregister(Id: Integer); Removes a ACC from the Desk menu. Id is the number returned by Menu_register
Function Menu_Click(Click, Setit: Integer): Integer;
Procedure Work_Rect(Handle : Integer; Var x, y, w, h : Integer); Returns the area of the window on which it can be drawn. Handle......Handle of window X...........X position of drawing rectangle Y...........Y position of drawing rectangle W...........W Wide H...........H height
Procedure Bring_To_Front(Handle : Integer); Sets the window specified threw handle to be the topmost.
Function Get_Window: Integer; Returns the active Window
Procedure Rubberbox(x, y, w1, h1 : Integer; Var w2, h2 : Integer);
Procedure Movebox(x1, y1, w, h, x2, y2 : Integer);
Procedure Dragbox(x1,y1,w1,h1,x2,y2,w2,h2 : Integer; Var Endx, Endy : Integer);
Procedure Growbox(stx, sty, stw, sth, fix, fiy, fiw, fih : Integer); Draws a growing Box from stx,sty,stw,sth to fix,fiy,fiw,fih. If a GEM Version < 2 is used this routine calls the Original routine In GEM Version 2 and higher this call is simulated threw 2 other calls. The Original functions can be reitgerated to newer GEM versions to the GROWBOX.ACC. But GEMBIND will not notice that and still simulate it.
Procedure Shrinkbox(stx, sty, stw, sth, fix, fiy, fiw, fih : Integer); Draws a shrinking Box from stx,sty,stw,sth to fix,fiy,fiw,fih This is the revers function of GrowBox If a GEM Version < 2 is used this routine calls the Original routine In GEM Version 2 and higher this call is simulated threw 2 other calls. The Original functions can be reitgerated to newer GEM versions to the GROWBOX.ACC. But GEMBIND will not notice that and still simulate it.
Function Slidebox(Dialog : Dialog_Ptr; Vater,Sohn,Modus:Integer):Integer;
Procedure Xgrf_Stepcalc(stw, sth, xc, yc, w, h : Integer; Var cx, cy, cnt, xstep, ystep : Integer);
Procedure Xgrf_2Box(xc, yc, w, h : Integer; corners : Boolean; cnt, xstep, ystep : Integer; doubled : Boolean);
Procedure Set_Clip(x, y, w, h: Integer);
Procedure Draw_String(x, y :Integer; s: Str255); Writes the string s at position x,y
Procedure Justified_Text(x, y, len, wrd, Chr :Integer; s: Str255);
Procedure Text_Alignment(h, v : Integer);
Procedure Set_Color(Color : Integer; Red, Green, Blue : Integer); Sets the Red, Green, Blue value of the color index threw Color.
Procedure Line_Width(width: Integer);
Procedure Draw_Mode(Mode: Integer); Sets the drawing mode. Can be set to the following modes REPLACE_MODE TRANS_MODE
Procedure Paint_Color(Color_Index: Integer); Sets the fill color
Procedure Paint_Style(Style_Index: Integer); Sets the fill style Solid LongDash Dotted DashDot Dashed DashDotDot
Procedure Paint_Outline(On : Boolean);
Procedure Paint_Rect(x, y, w, h: Integer); Fills the rectangle from x,y to x+w,y+h. With the paint style set with Paint_Style and the color set with Paint_Color
Procedure Line_Endstyle(beg_Style, End_Style: Integer);
Procedure Line_Style(Style: Integer); Selects a style to draw a line.
Procedure Move_To(x, y : Integer); (For turtle graphics) Sets the Drawposition to x,y without drawing
Procedure Line_To(x, y : Integer); (For turtle graphics) Draws a line from the last position to x,y
Procedure Frame_Rect(x, y, w, h: Integer); Draws a rectangle from x,y with wide w and height h
Procedure Text_Heigth(Height: Integer);
Function Text_Point(Height: Integer): Integer; Sets the height of the text output. Height is entered in pixels. Normal sizes are 8x16 Font = 14 Pixels (With 16 it looks not ok why ? ) (VGA) 8x14 Font = 11 Pixels (With 14 it looks not ok why ? ) (EGA) 8x8 Font = 7 Pixels (With 8 it looks not ok why ? ) (CGA,Hercules)
Procedure Text_Color(Color : Integer); Sets the colors for text output
Procedure Text_Style(Style: Integer); Sets a text style also more than one at a time can be used via or.
Procedure Text_Rotation(Angle: Integer); Angle is the degree to turn textoutput. 0 = Normal
Procedure First_Rect(Hand: Integer; VAR x, y, w, h: Integer);
Procedure Next_Rect(Hand: Integer; VAR x, y, w, h: Integer);
Function Rect_Intersect(x1, y1, w1, h1: Integer; VAR x2, y2, w2, h2: Integer): Boolean;
Procedure Set_WSize(hand, x, y, w, h: Integer); Sets the window specified threw hand to the new size x,y,w,h
Procedure Sys_Font_Size(VAR wchar, hchar, wbox, hbox: Integer); Gets the sizes of the font that is used at the moment wchar...X-Size of a char hchar...Y-Size of a char
Procedure Begin_Mouse; Takes full control over mouse like Modal Dialog
Procedure End_Mouse; Releases the mouse again
Procedure Paint_Oval(x, y, x_rad, y_rad: Integer); Paints a ellipse or circle that is filled. If you want to draw a circle simple set the x_rad=y_rad
Procedure Frame_Oval(x, y, x_rad, y_rad: Integer); Paints a ellipse or circle. If you want to draw a circle simple set the x_rad=y_rad
Procedure Paint_Round_Rect(x, y, w, h : Integer); Draws a filled rectangle with rounded corners
Procedure Frame_Round_Rect(x, y, w, h : Integer); Draws a rectangle with round corners
Procedure Paint_Arc(x, y, x_rad, y_rad, beg_ang, end_ang : Integer); Draws a filled arc
Procedure Frame_Arc(x, y, x_rad, y_rad, beg_ang, end_ang : Integer); Draws a arc
Procedure Border_Rect(Handle: Integer; Var x, y, w, h: Integer);
Function Obj_Find(Dial: Dialog_Ptr; Start, Depth, x, y : Integer): Integer;
Procedure Obj_Offset(Dial: Dialog_Ptr; Index: Integer; VAR x, y: Integer);
Procedure Obj_Size(Dial: Dialog_Ptr; Index: Integer; Var x, y, w, h: Integer);
Procedure Obj_Redraw(Dial: Dialog_Ptr; Item: Tree_Index);
Function Find_Window(x, y: Integer): Integer;
Procedure Obj_Add(Dial: Tree_Ptr; Parent, Child: Integer);
Procedure Rsrc_Obfix(Dial: Tree_Ptr; Obj: Integer);
Function D_Color(Border, Text: Integer; Mode: Boolean; Pattern, Inside: Integer): Integer;
Function New_Dialog(N_Items, x, y, w, h: Integer): Dialog_Ptr; N_Items....Number of items in dialog (simply set here a number thats hight enough if you don't know) x,y........X,Y position of Dialog w,h........Wide and Height of the dialog The function returns Dialog_ptr to the dialog
Function Add_DItem(Dial: Dialog_Ptr; Obj_Type, Flags: Integer; x, y, w, h: Integer; Border, Color: Integer): Tree_Index; Adds a item to the dialog. Dial.......Pointer to dialog Obj_Type...Can be one of the following G_Box,G_Text,G_BoxText,G_Image,G_ProgDef,G_UserDef, G_IBox,G_Button,G_Boxchar,G_String,G_FText,G_FBoxText, G_Icon,G_Title Flags......Attributs (used by style G_Button for example) can be one of the following None,Selectable,Default,Exit_Btn,Editable,Radio_Btn,Last_Ob, Touch_Exit,Hide_Tree,Indirect x,y........Position of dialog item w,h........Wide and height of the item Border.....0 - No border 1 - Border Color......? Returns the tree index number
Procedure Delete_Dialog(Dial: Dialog_Ptr); Removes Dialog (dial) from memory.
Function New_Menu(N_Items: Integer; About: Str255): Menu_Ptr; I don't know for what N_items is good it is not used inside of the function.
Function Add_MTitle(Menu: Menu_Ptr; Item: Str255): Integer;
Function Add_MItem(Menu: Menu_Ptr; Title: Tree_Index; Item: Str255): Integer;
Procedure Delete_Menu(Menu: Menu_Ptr);
Function Ex_Load_Fonts(Font_Max, Font_Free: Integer): Integer;
Function Font_Name(Font: Integer; Var Name: String): Integer; Returns the name of the Font. Font is the index number of the Font 1=First,2=...,3=... Name is 32 Characters Big Return the FONT ID.
Function Get_Keyboard: Integer; Wait until a keyboard event happens If the Lo byte of the returned number is 0 then the Hi byte is a scancode else the Lo byte is the ASCII Char of the key pressed.
Function Get_Button(bclicks, bmask, bstate: Integer; Var bmx, bmy, bbutton, bkstate: Integer): Integer;
Function Get_Mouse(moflags, mox, moy, mowidth, moheight: Integer; Var momx, momy, mobutton, mokstate: Integer): Integer;
Function Get_Message(Var msg: Message_Buffer): Integer;
Function Get_Timer(ticks: Longint): Integer; Waits until the value given in ticks is over Example: foo:=Get_Timer(50);
Procedure TLine(Winkel, Laenge: Integer); (For turtle graphics) Winkel is the degree and Laenge is the length of the line which is drawed from the position at the moment.
Procedure Font_Info(Var MinADE, MaxADE, dist0, dist1, dist2, dist3, dist4, MaxWidth, eff0, eff1, eff2: Integer);
Function Shel_write(doex,isgem,isover:integer;pcmd,ptail:string):boolean; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included For executing DOS and GEM Programs. doex.....0 - Exit gem after running program, 1 - Return to Desktop isgem....0 - Textmode (Dos), 1 - Graphics mode (GEM) isover...0 - To keep current program in memory 1 - Load program instead of current 2 - Unload AES and restard it after runing the program pcmd.....Program to execute ptail....Parameters ?
Function Scrp_Read:string; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included. Returns the path to the clipboard directory.
Function Scrp_write(name:string):integer; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Sets the path to the clipboard directory
Procedure Scrp_Clear; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Clears the clipboard directory.
Function Ems_Inst:Boolean; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Function checks if EMS memory is installed returns TRUE or FALSE
Function ems_errcode:integer; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Returns the errorcode of the last EMS function
Function ems_num_page:integer; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Returns the number of EMS pages available
Function ems_free_page:Integer; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Returns the number of free EMS pages available
Function ems_frame_seg:Word; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Returns the SEGMENT in which the EMS pages are mirrored in. Acces to EMS memory if Segment is $E000 mem[$E000:0000]:=3; { To set a number} a:=mem[$E000:0000]; { To read a number} Every page has a size of 16384 bytes and goes from 0000 to 16383
Function ems_alloc(Pages:word):Word; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Allocates EMS pages returns a handle to the pages
Function ems_map(Handle,logp,physp:word):Boolean; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Pages in a EMS page. Handle is the handle of the pages logp is the page to page in. Physp you can set to 0 Returns True if everything went okay
Function ems_free(Handle:word):Boolean; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Frees EMS pages. Returns true if everything worked okay. You must do this at the end of a program or the EMS memory will not given free!
Function ems_version:Integer; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Returns the version number of your EMS manager
Function ems_save_map(Handle:Word):boolean; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Saves the mapping of the 4 Physical Pages
Function ems_restore_map(Handle:word):boolean; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Restores the mapping of the 4 Physical Pages
Procedure Volume(vol:word); Doesn't exist in original GEMBIND. Only in versions existing where it is extra included This command only works with driver v0.2 and higher Sets the volume of the sound card. (0-255) 0 - Nothing to hear 255 - Loudest
Procedure SpeakerOn; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Turns the loud speakers on.
Procedure StereoON; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included This command only works with driver v0.2 and higher Switches from Mono mode to Stereo mode. After loading the sound driver the driver is in Mono mode.
Procedure StereoOff; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included This command only works with driver v0.2 and higher Switches from Stereo mode to Mono mode. After loading the sound driver the driver is in Mono mode.
Procedure SpeakerOff; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Turns the speaker off
Procedure WaitForDma; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Waits until the DMA is ready. This commands is needed if you play sound with the playsample command.
Procedure DMAStop; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Switches the DMA off
Procedure PlaySample(a,b,c,d:Word); Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Plays a sample. A...Segment of sample B...Offset of sample C...Size D...Kilo herz
Function PlayWAV(af:string):Boolean; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Plays a wave file. Af...Filename of wave file. Returns TRUE if everything goes okay else it returns false.
Procedure SD_Info; Doesn't exist in original GEMBIND. Only in versions existing where it is extra included Fills the following global variables with infos. SD_Version....Version number of driver Version number system for example $0001 = 00.01 $0002 = 00.02 $0100 = 01.00 $0200 = 02.00 $0205 = 02.05 SD_Type.......Type of driver SD_Base.......Base adress of soundcard SD_Dma........Dma channel of soundcard This parameter exists only in sound drivers v0.2 and higher SD_Options....Options of soundcard Bit 0 ... Stereo Bit 1 ... 16 Bit output (Sound Blaster 16) Bit 2 ... Not used Bit 3 ... Not used Bit 4 ... Not used Bit 5 ... Not used Bit 6 ... Not used Bit 7 ... Not used

1. Source Examples (Programs are written with TP 6.0)


1. Normal APP ground program


Program APP; {$M 16384,0,10000} uses gembind; begin if init_Gem>=0 then begin { Here is the program source } Exit_Gem; end; end.

2. Simple hello world program


Program Hello_World; {$M 16384,0,10000} uses gembind; var apid:integer; btn:integer; begin apid:=Init_Gem; if apid < 0 then {Should not happen normally} begin Exit_Gem; halt(1); end; btn:=Do_Alert('[0][Hello World!][Continue]',1); Exit_Gem; end.

3. Alert Box example


program alert_boxes; {$M 1024, 1024, 1024} uses gembind; var out : str255; foo : integer; begin if init_gem >= 0 then begin foo:=do_alert('[1][ Alert Box Nr. 1 ][ Continue ]',1); foo:=do_alert('[2][ Alert Box Nr. 2 ][ Continue ]',1); foo:=do_alert('[3][ Alert Box Nr. 3 ][ Continue ]',1); foo:=do_alert('[3][ Alert Box Nr. 4 | 2 Lines ][ Continue ]',1); foo:=do_alert('[3][ Alert Box Nr. 5 | 2 Switches ][ Continue | Cont ]',1); foo:=do_alert('[3][ Alert Box Nr. 5 | 2 Switches ][ Continue | Cont ]',2); exit_gem; end; end.

4. Icon example


This example program is only tested with DESKHI.ICN!!
It is a little bit complicate method of showing Icons but the only one that i got to work under pascal out of source. A other method is a dialog in a RSC file that has icons.
{$M 1024,1024,1024} Program Icon_Example; uses gembind; var handle:Integer; x,y,w,h:Integer; foo:Integer; wname:Window_title; Procedure Show_ICN(filename:string;x,y,nr:integer); { Filename...Filename of Icn file x,y........Position where to paint Icon nr.........Number of icon in file to load } var dummy:Word; data:string[32]; B:array [1..5] of byte; fIcon:File; k,j,i,wek,eve,ok:Integer; begin assign(fIcon,filename); reset(fIcon,1); { Format of ICN files WORD start of icon titles table WORD address of begining of the file 72 ICONBLK ( A iconblk has a size 34 Bytes) Then came the bitmaps of the icons. Every line is 4 Bytes. And Every Icon has 32 Lines. The bytes in a line are slight wrong. When showing the order of the 4 loaded bytes must be 2,1,4,3 } seek(ficon,2452+(128*nr)); j:=0; for i:=1 to 32 do begin data:='0000000000000000000000000000000'; k:=0; blockread(ficon,B,4,dummy); b[5]:=b[1]; { Swaping of bytes} b[1]:=b[2]; b[2]:=b[5]; b[5]:=b[3]; b[3]:=b[4]; b[4]:=b[5]; for j:=1 to 4 do begin wek:=b[j]; eve:=128; for ok:=0 to 7 do begin if wek div eve=1 then Plot(x+k,y+i-1); inc(k); if wek div eve=1 then wek:=wek-eve; eve:=eve div 2; end; end; end; close(fIcon); end; begin if init_gem >=0 then begin Set_Mouse(M_Arrow); { Is needed because sometimes mouse is no arrow when starting} wname:='Icon Example'; handle:=New_Window(G_ALL,wname,0,0,0,0); Open_Window(handle, 20, 20, 200, 100); Paint_Style(Solid); Paint_Color(White); Work_Rect(handle,x,y,w,h); Paint_Rect(x,y,w,h); Show_Icn('DESKHI.ICN',x+10,y+10,1); foo:=do_alert('[1][ Press the exit button or RETURN ][ EXIT ]',1); Close_window(handle); Delete_window(handle); Exit_Gem; halt(1); end; end.

2. Clipboard functions (can be included into GEMBIND)


Function Scrp_Read:string; var tmp2,tmp:string; begin int_in[0]:=0; tmp:=#0#0#0#0; Tmp[Length(Tmp)+1] := Chr(0); Addr_In[0]:=Addr(Tmp); AES(80); If Int_Out[1] < > 0 Then C_To_Pas(String_Ptr(Addr(Tmp[1]))^, tmp2); scrp_read:=tmp2; end; Function Scrp_write(name:string):integer; begin int_in[0]:=0; Name[Length(name)+1]:=chr(0); Addr_in[0]:=Addr(name); AES(81); Scrp_write:=int_out[0]; end; Procedure Scrp_Clear; begin AES(82); end;

3. EMS functions (can be included into GEMBIND)


Function Ems_Inst:Boolean; var emm_Name:string; i:word; found:Boolean; begin emm_Name:='EMMXXXX0'; re.ax:=$3567; msdos(re); found:=True; for i:=10 to 17 do begin if chr(mem[re.es:i]) < > emm_name[i-9] then Found:=false; end; ems_inst:=Found; end; Function ems_errcode:word; begin ems_errcode:=emm_error; end; Function ems_num_page:integer; begin Emm_error:=0; Re.ah := $42; Intr($67,Re); if Re.ah<>0 then begin Emm_Error:= Re.ah; Ems_Num_Page:=0; end else Ems_Num_Page:=Re.dx; end; Function ems_free_page:Integer; begin Emm_error:=0; Re.ah:=$42; Intr($67,Re); if Re.ah<>0 then begin Emm_error:=Re.ah; Ems_Free_Page:=0; end else Ems_Free_Page:=Re.bx; end; Function ems_frame_seg:Word; begin Emm_error:=0; Re.ah:=$41; Intr($67,Re); if Re.ah<>0 then begin Emm_error:=Re.ah; Ems_Frame_Seg:=0; end else Ems_Frame_Seg:=Re.bx; end; Function ems_alloc(Pages:word):Word; begin emm_error:=0; Re.ah:=$43; Re.bx:=Pages; Intr($67,Re); if Re.ah <>0 then begin Emm_error:=Re.ah; Ems_Alloc:=0; end else Ems_Alloc:=Re.dx; end; Function ems_map(Handle,logp,physp:word):Boolean; begin Re.ah:=$44; Re.al:=PhysP; Re.bx:=LogP; Re.dx:=Handle; Intr($67,Re); Emm_error:=Re.ah; if re.ah=0 then Ems_Map:=True else Ems_map:=False; end; Function ems_free(Handle:word):Boolean; begin Re.ah:=$45; Re.dx:=handle; Intr($67,Re); Emm_error:=Re.ah; if re.ah=0 then Ems_Free:=True else Ems_Free:=False; end; Function ems_version:Integer; begin Emm_error:=0; Re.ah:=$46; Intr($67,Re); if Re.ah<>0 then begin Emm_error:=Re.ah; Ems_Version:=0; end else Ems_Version:=(Re.al and 15)+(Re.al shr 4)*10; end; Function ems_save_map(Handle:Word):boolean; begin Re.ah:=$47; Re.dx:=handle; Intr($67,Re); Emm_error:=Re.ah; if re.ah=0 then Ems_Save_Map:=True else Ems_Save_Map:=False; end; Function ems_restore_map(Handle:word):boolean; begin Re.ah:=$48; Re.dx:=handle; Intr($67,Re); Emm_error:=Re.ah; if re.ah=0 then Ems_restore_Map:=True else Ems_restore_Map:=False; end;

4. Execute function (can be included into GEMBIND)


Function Shel_write(doex,isgem,isover:integer;pcmd,ptail:string):boolean; begin int_in[0]:=doex; int_in[1]:=isgem; int_in[2]:=isover; pcmd[Length(pcmd)+1]:=chr(0); Addr_in[0]:=Addr(pcmd[1]); ptail[Length(ptail)+1]:=chr(0); Addr_in[1]:=Addr(ptail[1]); AES(121); if int_out[0]=0 then Shel_write:=False else Shel_Write:=true; end;

5. Missing constants


This messages are sent when the scoll arrows of a window are pressed. WA_UPPAGE=1 WA_DNPAGE=2 WA_UPLINE=3 WA_DNLINE=4 WA_LFPAGE=5 WA_RTPAGE=6 WA_LFLINE=7 WA_RTLINE=8 SCRAP_CSV=$1 SCRAP_TXT=$2 SCRAP_GEM=$4 SCRAP_IMG=$8 SCRAP_DCA=$10 SCRAP_USR=$8000

5. Missing command


Procedure Wind_Calc(CalcType, WinType : Integer; Var x, y, w, h : Integer); Begin { BALJ - WIND_CALC missing from original bindings } Int_In[0] := CalcType; Int_In[1] := WinType; Int_In[2] := x; Int_In[3] := y; Int_In[4] := w; Int_In[5] := h; AES(108); x := Int_Out[1]; y := Int_Out[2]; w := Int_Out[3]; h := Int_Out[4]; End;