-- *********************************************************************** -- * * -- * WELCOME.E The Happy Hippy (C) 1998 * -- * * -- *********************************************************************** constant VERSION = 1.00 -- DO NOT CHANGE THIS VALUE OR CODE WON'T RUN ! -- *********************************************************************** -- * * -- * Description : A Euphoria Pixel Bot Project Welcome Interface * -- * Version : 1.00 - 14th November 1998 * -- * * -- * Filename : welcome.e * -- * Source Code : Euphoria 2.00 * -- * * -- * Author : The Happy Hippy * -- * Copyright : The Happy Hippy (C) 1998 * -- * Contact : hippy@psynet.net * -- * * -- * Licence : You are granted the free right to use the code * -- * within this file as the basis of any Pixel Bot * -- * Project welcome interface that you are designing * -- * providing that you do not use the code exactly as * -- * it is without including all comments in their * -- * original format. * -- * * -- * You may modify this code and comments as you wish * -- * and may use it as the basis of any Pixel Bot * -- * welcome interface that you develop free of charge * -- * and royalties. * -- * * -- * Trademarks : See http://www.psynet.net/hippy/pixelbot.htm for * -- * details of Copyright and Trademark assignments. * -- * * -- * Y2K Issues : This code does not use dates for any purpose and * -- * is therefore, by default, millennium compliant. * -- * * -- * For further information about the Euphoria Pixel Bot project * -- * please look at http://www.psynet.net/hippy/pixelbot.htm * -- * * -- * For further information about the Euphoria language please look * -- * at http://members.aol.com/FilesEu * -- * * -- *********************************************************************** -- *********************************************************************** -- * * -- * KNOWN BUGS * -- * * -- * None * -- * * -- *********************************************************************** -- *********************************************************************** -- * * -- * RELEASE HISTORY * -- * * -- * 1.00 14 Nov 1998 First public release. * -- * * -- *********************************************************************** -- *********************************************************************** -- * * -- * NOTES * -- * * -- * 1) Don't modify this code whilst it is still a version 1.XX; * -- * there are likely to be a lot of day-to-day changes and it * -- * will be difficult to keep up with changes that are happening * -- * in the Arena program. * -- * * -- * 2) Don't declare and constants, variables or functions as * -- * global other than the Welcome_Enquiry() function and the * -- * Welcome() routine. * -- * * -- *********************************************************************** -- *********************************************************************** -- * * -- * -- * * -- *********************************************************************** sequence Option integer Max_Clones -- *********************************************************************** -- * * -- * -- * * -- *********************************************************************** procedure Set_Default_Options() -- 123456789 Option = " *XX *X" Max_Clones = 99 end procedure -- *********************************************************************** -- * * -- * -- * * -- *********************************************************************** procedure Cursor_On() machine_proc(6,#0607) end procedure procedure Cursor_Off() machine_proc(6,#2000) end procedure procedure Bar(integer count,integer lhs,integer mid,integer rhs) while count > 0 do puts(1,lhs) puts(1,repeat(mid,78)) puts(1,rhs) count = count - 1 end while end procedure procedure At(integer Row,integer Col,sequence s) position(Row,Col) puts(1,s) end procedure procedure Show_Option(integer Row, integer Which) At(Row,20,{ Option[Which] }) end procedure function Toggle(integer Which) if Option[Which] = ' ' then return 'X' else return ' ' end if end function function Status(integer Which) if Option[Which] = ' ' then return FALSE else return TRUE end if end function procedure Show_Options() Show_Option( 7,1) Show_Option( 8,2) Show_Option( 9,3) Show_Option(11,4) Show_Option(13,5) Show_Option(15,6) Show_Option(16,7) Show_Option(17,8) Show_Option(19,9) At(13,58,sprintf("%d",Max_Clones)) At(24,1, "") end procedure -- *********************************************************************** -- * * -- * -- * * -- *********************************************************************** procedure Show_Welcome_Screen() -- Clear the screen clear_screen() -- Put up a nice border Bar( 1, 201 , 205 , 187 ) Bar( 3, 186 , 32 , 186 ) Bar( 1, 204 , 205 , 185 ) Bar(15, 186 , 32 , 186 ) Bar( 1, 199 , 196 , 182 ) Bar( 1, 186 , 32 , 186 ) Bar( 1, 200 , 205 , 188 ) -- Put up the text At( 3,25 , "Welcome to the Pixel Bot Arena") At( 7,15 , "1 : [ ] Goal is to be the first to find the maze exit") At( 8,15 , "2 : [ ] Goal is to kill all other Pixel Bots") At( 9,15 , "3 : [ ] There is no goal; wander around aimlessly") At(11,15 , "4 : [ ] Include a maze in the arena") At(13,15 , "5 : [ ] Pixel Bots can be cloned 0 : [ ] Maximum") At(15,15 , "6 : [ ] Weapons are not allowed") At(16,15 , "7 : [ ] Weapons self-destruct on use") At(17,15 , "8 : [ ] Weapons are allowed") At(19,15 , "9 : [ ] Pixel Bots cannot die") At(22,10 , "Press a Number Key to select an option - Press Space to start") -- Show the current options Show_Options() end procedure -- *********************************************************************** -- * * -- * -- * * -- *********************************************************************** procedure Change_Options() integer Char Cursor_Off() Char = get_key() while Char != ' ' do if Char > 0 then Char = Char - '0' if Char = 0 then Max_Clones = Max_Clones + 10 if Max_Clones >= 109 then Max_Clones = 10 else if Max_Clones > 99 then Max_Clones = 99 end if end if elsif Char = 1 then Option[1] = '*' Option[2] = ' ' Option[3] = ' ' Option[4] = 'X' Option[5] = ' ' Option[6] = '*' Option[7] = ' ' Option[8] = ' ' Option[9] = 'X' elsif Char = 2 then Option[1] = ' ' Option[2] = '*' Option[3] = ' ' Option[6] = ' ' Option[7] = ' ' Option[8] = '*' Option[9] = ' ' elsif Char = 3 then Option[1] = ' ' Option[2] = ' ' Option[3] = '*' elsif Char = 4 then Option[4] = Toggle(4) elsif Char = 5 then Option[5] = Toggle(5) elsif Char = 6 then Option[6] = '*' Option[7] = ' ' Option[8] = ' ' elsif Char = 7 then Option[6] = ' ' Option[7] = '*' Option[8] = ' ' elsif Char = 8 then Option[6] = ' ' Option[7] = ' ' Option[8] = '*' elsif Char = 9 then Option[9] = Toggle(9) end if Show_Options() end if Char = get_key() end while Cursor_On() end procedure procedure Read_Options_From_Disk(sequence Filename) integer File_Handle integer Char File_Handle = open(Filename, "r") if File_Handle >= 0 then Option = "" Char = getc( File_Handle ) while ( Char >= 0 ) and ( Char != '\n' ) do Char = getc( File_Handle ) end while if Char = '\n' then Max_Clones = getc( File_Handle ) Char = getc( File_Handle ) while ( Char >= 0 ) and ( length(Option) < 9 ) do Option = Option & Char Char = getc( File_Handle ) end while close(File_Handle) else Set_Default_Options() end if else Set_Default_Options() end if end procedure procedure Write_Options_To_Disk(sequence Filename) integer File_Handle File_Handle = open(Filename, "w") if File_Handle >= 0 then puts(File_Handle, "< DO NOT EDIT THIS FILE BY HAND >\n" ) puts(File_Handle, Max_Clones & Option ) close(File_Handle) end if end procedure function Option_Setting(sequence s) if compare(s,"CREATE MAZE EXIT") = 0 then return Status(1) elsif compare(s,"DEATH MATCH") = 0 then return Status(2) elsif compare(s,"CREATE MAZE") = 0 then return Status(4) elsif compare(s,"WEAPONS SELF-DESTRUCT") = 0 then return Status(7) elsif compare(s,"WEAPONS ARE ALLOWED") = 0 then return Status(7) or Status(8) elsif compare(s,"PIXEL BOTS CAN DIE") = 0 then return not Status(9) elsif compare(s,"MAXIMUM CLONES ALLOWED") = 0 then if Status(5) then return Max_Clones else return 0 end if else puts(1,"\nWelcome_Return(Return_Options,"&s&")\n\n") abort(1) end if end function -- *********************************************************************** -- * * -- * INTERFACE TO / FROM ARENA PROGRAM * -- * * -- *********************************************************************** -- This function is called to return an identifying number of the routines -- that are available in the Welcome Interface. Only available routines -- must be requested. -- The identifying numbers are then used by the arena program by calling -- the Welcome() routine to activate the relevant routine call indirectly. -- This means that the arena program ( and consequently Pixel Bots ) will -- only be able to refer to Welcome_Enquiry() and Welcome() as all other -- routines remain local to the Welcome Interface. -- Of course, it goes without saying that, a Pixel Bot should never call -- the Welcome_Enquiry() or Welcome() routines directly. global function Welcome_Enquiry(sequence Proc_Name) if compare(Proc_Name,"Version")=0 then return VERSION else if routine_id(Proc_Name) < 0 then puts(1,"\n\nWelcome_Enquiry(" & Proc_Name & ")\n\n") abort(1) end if return routine_id(Proc_Name) end if end function -- The Welcome() routine is used to direct a call from the arena program -- to the actual Welcome Interface routine that will do the job that has -- been requested. global procedure Welcome(integer Proc_Id,sequence Proc_Args) call_proc(Proc_Id,Proc_Args) end procedure global function Welcome_Return(integer Proc_Id,sequence Proc_Args) return call_func(Proc_Id,Proc_Args) end function -- *********************************************************************** -- * * -- * END OF WELCOME INTERFACE * -- * * -- ***********************************************************************