Home
        S. Salazar, Adding Functionality to the Hydra Game
         Contents
1.                                     lt  ul gt     lt  li gt    gt    lt p gt    Both of these games require the HYDRA USB driver to compile    which is provided   above with the game source template  lt  p gt    Graphics lt  h3 gt     Game graphics are implemented using object images stored on the  server  The objects   can then be turned on or off and moved around the game screen   Images are in PNG   format  which was chosen primarily for its lossless compression  and transparency    Overall  this provides easy creation of graphics with an image  editor  coupled with   the e editor  coupled with   the  lt a href  http   www libpng org pub png pngintro html   target  _blank  gt advantages lt  a gt    of PNG  lt  p gt           Images must meet these requirements  lt  p gt         lt li gt Images must be in PNG format lt  1li gt     lt li gt Images must be numbered consectutively  starting at 0 and in  the format  amp quot   number   png amp quot     for example     amp quot 3 png  quot    lt  li gt     lt li gt A max of 100 images can be used  numbered 0 99   lt  li gt     lt li gt Higher numbered images display above lower numbered images on   the game screen lt  li gt            gt         The game screen resolution is 240 x 180 pixels  Objects are  positioned by their   x  and y coordinates  which indicate the position of the  object amp  39 s image center   on the game screen  Therefore  images can be placed on the game  screen with as little   as half the width and half
2.                    Salazar            get the file path  String codePath    Assembly GetExecutingAssembly    GetName    CodeBase    String filePath   Path GetDirectoryName  codePath   Substring 6         game_files  game eeprom                  run Propellent for downloaded file       Console Write   Uploading game to HYDRA         HydraPropForm uploadGame  filePath     Console WriteLine   done              send notification that HYDRA upload is complete  connStrm WriteByte  4          close connection with developer  connStrm Close     devConn Close             restart HYDRA serial connection and thread  hydra Open     hydraThread Resume          shut down all player connections  Console Write  Disconnecting players         for  int i   0  i  lt  MAX PLAYERS  i                                if  players i  active       players i  conn GetStream    WriteByte  DEV_FINISHED     players i  conn Close     players i  conn   null   players i  active   false            numPlayers   0    Console WriteLine   done      Console WriteLine   Game upload complete      Console WriteLine                endregion    region Miscellaneous methods     checks for commands from the server console  void commandConsole      Console WriteLine   Type   help   for a list of commands  n     while  true             string str   Console ReadLine   Trim    ToLower      if  str Length    0        continue     34         Salazar       initial blank space  Console WriteLine          if  str CompareTo  help   
3.                   draw players ships left    gr colorwidth  3 0     repeat i from 0 to num_landers 1    gr vec     2000  gt  gt  2   lander_       draw start game text    if  game        LANDI       state             ERS_X_POS   i  lt  lt  3   4  LANDERS_Y_POS   4   0012   model                 GAME_STATE_MENU and    game_counter2  amp   10         gr textmode  2 1 6 5   gr colorwidth  2 0   if  game_counter2  gt  200           else          gr text  4 0   start_string                 gr text  4 0   title_string      copy bitmap to display    gr copy  onscreen_bu         END RENDERING SI          ee       er           ECTION       TEE LEEELELES TITEL PETE LIL EAT ETL ETA ETI TEL IAT ET             GAME_STATE_RUN           clear bitmap    gr clear         INPUT       SECTION          the game is running       LEETETELEEL EL ELL LER ETE ITEST PTT ET TA TTI EET LLL TATTLE    85    1    nes_buttons         AE    IE    1    PT    elseif    1    get       ge   nes_b       u              nes_bu             bounds          END             N    tons  amp  N  lander_angle    ANG_5       ES   F  b    t change in direction  tons  amp  N  lander_angle    ANG_5  else    R          Ka          ESAL       EFT          test ship angle   lander_angle  gt  ANG_360   lander_angle    ANG_360   lander_angle  lt  0   lander_angle   ANG_360    INPUT SECTION       nes controller buttons  Read_Gamepad    IGHT          Salazar    PLELALTTE REEL ITA PLETE IAAT AEST TAA ELLA TIA T DATS ALI EDL    1      
4.           port number is in bits 31 16  return  int   ver  gt  gt  16      public static bool uploadGame  String filePath           verify that the file exists and that it has the correct file    extension  FileInfo fi   new FileInfo filePath    if   fi Exists  amp  amp  fi Extension ToLower       eeprom               39       upload could not continue  return false             create and display the window  HydraPropForm hpf   new HydraPropForm          specifies auto search for serial port  SetSerialSearchMethod  0            specifies DTR for reset signal  SetResetSignal  0         upload the game file    string cfile   filePath ToCharArray     DownloadToPropeller filePath  3               close the window  hpf Close             upload was successful  return true     Salazar    40    A  oe    Salazar    Appendix C  Main Web Site  ASP NET             Page Language  C   AutoEventWireup  true  CodeFile  Default aspx cs     Inherits  _Default    gt         lt  DOCTYPE html PUBLIC     W3C  DTD XHTML 1 0 Transitional  EN         http    www w3 org TR xhtml1 DTD xhtmll transitional dtd  gt      lt html xmlns  http   www w3 org 1999 xhtmlL  gt      lt head id  Head1l  runat  server  gt    lt title gt HydraNet 3 Gaming System lt  title gt                                 lt  head gt    lt body gt    lt form id  forml  runat  server  gt    lt div gt    lt h1 gt   HydraNet 3 Gaming System lt  h1 gt    lt h3 gt   CEN 4935 Senior Software Engineering Project  Spring 2009  lt br   gt   B
5.         abort if upload failed  error message is already displayed       send notification that upload failed  connStrm WriteByte  0         close connections and exit  connStrm Close     conn Close      return             send notification that uploaded files are saved  connStrm WriteByte  3            receive notification that game is uploaded to HYDRA  if  connStrm ReadByte      4              throw new Exception           catch  Exception                uploadStatus   ERROR  connection with server failed      return      finally        close connection with server  connStrm Close     conn Close               the upload was successful  uploadStatus   Success        60    Salazar    bool uploadFiles           folder paths  String rootDir   Page Request PhysicalApplicationPath   gameDir   rootDir    game_files              uploaded file paths          String gameFile   gameDir    game eeprom    graphicsFile   gameDir    graphics zip    manualFile   gameDir    manual txt               graphics folder path  String graphicsFolder   gameDir    graphics                    save the thr files   try      upldGameFile SaveAs  gameFile     upldImagesFile SaveAs  graphicsFile     upldManualFile SaveAs  manualFile                catch  Exception                uploadStatus  ERROR  could not save uploaded files      return false     try          delete the images from previous game  if  Directory Exists  graphicsFolder                  Directory Delete graphicsFolder  true              r
6.      TIAL ALATA LITRE LES PFET EA CPE TELT LITA TAI IATA ELT ILS      draw text       gr textmode  2 1 5 3   gr colorwidth  2 0     1    draw fuel and    num players    gr text  HUD_X_POS  HUD_Y_POS   hud_string     87    Salazar       gr text  LANDERS_X_POS  LANDERS_Y_ POS   landers_string   itoa lander_fuel   sbuffer   gr text  HUD_X_POS  HUD_Y_POS 12      sbuffer                      draw vector objects      draw mountain  static for now  gr colorwidth  1 0   gr plot  96      96    y     80    repeat i from 1 to 20    update y  y    mountain_scape i 1     draw line  gr line  96   i 8 y       finally mountainscape back to horizon  gr line 96  96          draw landing zone   gr colorwidth  3 0    gr plot  96   landing_zone 0    96   landing_zone 2    gr line  96   landing_zone 1    96   landing_zone 2                        Fes      ignore test if already landed  if  game_state  lt  gt  GAME_STATE_LANDED     test for player collision with terrain BEFORE we draw the  player and thruster which would cause erroneous results    scan 4 pixels from centroid of ship down to pierce terrain  repeat i from 0 to 3  pixel_data    Get_Pixel2 96   lander_wp_x  96    lander_wp_y   i  offscreen_buffer                                                                            test the pixel data to see if there is a collision  terrain  if  pixel_data    1     collision has occured  set state to kill player  game_state    GAME_STATE_CRASHED  quit    draw player last  on top of terrain     fir
7.     End section of code for developers    TITTTTTTTTTTTTAT TTA       OBJ  usb   FullDuplexSerial spin    USB driver  PUB start    70    Salazar           111111111 1 1 1 11111111 111111111111111111111111 11111111111 1 1111111      Start section of code for developers  start method         set the number of graphics objects  setGraphicsSize  18       position the backgrounds  2nd background is invisible  setGraphicsObj IMG_BG1  1  getScreenCenterX  getScreenCenterY   setGraphicsObj  IMG_BG2  0  getScreenCenterxX  getScreenCenterY                   End section of code for developers    i IEEE EEE EEE EEE EEE EEE      start the game  startGame    PUB update player  input    pos           111111111 1 1 1 1 1 1 11111111111111 1111111111111 1111111111111 1 1 111111      Start section of code for developers  update method       if input  INPUT_ON    set the player as active  setPlayerStatus  player  1       determine player s starting image  facing left with no turbo                                      if player     playerImage  player    IMG_POL  elseif player  1   playerImage  player    IMG_P1L  elseif player     playerImage  player    IMG_P2L  elseif player  3   x                               playerImage  player    IMG_P3L     enable player s image   setGraphicsObj playerImage player   1  getScreenCenterx   getScreenCenterY                set turbo to off  playerTurbo  player    0       elseif input  INPUT_OFF    set the player as inactive  setPlayerStatus  player  0   setGraph
8.     string key stuff    byte sbu  byte cur      ter  17   r_key    byte temp_key    long dat     on  lon    a    es gamepad vars  g nes_buttons    state variables    Salazar    whole part    decimal part    velocity  angular direction    fuel of lander  number of landers left      terrain collision algorithm             long pix    el_data    PIPE LALLA PPLE AAA LAAU LUA TALES LITE LALA LS POAT LEI SETA LISTS TELE LILLIA          1    1    eee       OBJECT D                ECLARATI    ON    S       ECTI       ON       LIE LAD TA LIAL LIS Il LAAL ULIVA IAL IALA UI VALAA LAL IALA LOST IMT SLIT OTS  IIIS T     O       BJ    tv  gr     tv_drv_010 spin  1   graphics_drv_010 spin     tantiate a tv object  tantiate a graphics object    ins    ins             MET ELETT ELIE ECE PET ELIOT ELIT LEE CEL ELATED PELLET ATT EET LEE EET EF    77    EXPORT P             UBLICS       LEE ETIT ELE ELIT PEE EUD EPI ETL IET ETE TETAS AI EL PI IT PLT   BEET ETELIPE TEL ELE EEL EL LETTE TE LE EEEL EE ETAL ELIT ELA ET ITA TEE EIEL EEL FECES    a    82    Salazar       PUB start   i  j  base  base2  dx  dy  x  y  X2  y2  last_cos   last_sin    1    PALA EAER AE L EET EEE E ALL  TIAEL IE     GLOBAL INITIALIZATION   FLIP EIIEPT ISTE IAL IE ET IAT IS IIL AIT L TA ATT ATTA LISD TIA STI I PETA IEP L  TILT                           start tv   longmove   tv_status   tvparams  paramcount   tv_screen     screen   tv_colors     colors   tv start   tv_status                       init colors  each tile has sam
9.    0              lists all commands and their descriptions   Console WriteLine   Command t tDescription       Console WriteLine    t t tya   Console WriteLine   players t tlists which players are  currently connected      Console Writ ne  help t tprovides a list of commands  for using the server      Console Writ ne  exit t tshuts down connections and  closes the server software                   H                    Ju              else if  str CompareTo  exit      0         shuts down the server program  broadcastToPlayers  SERVER_SHUTDOWN     Environment  Exit  0                            else if  str CompareTo   players      0          display total current player connections  Console WriteLine   Players connected      numPlayers            lists the player connections  for  int i   0  i  lt  MAX PLAYERS  i             Console Write  Player    i          if  players i  active             Console WriteLine   connected             else         Console WriteLine   disconnected                   ending blank space  Console WriteLine          returns the number of PNG graphics present in graphics folder  int getNumGraphics            string filepath            Path GetDirectoryName  Assembly GetExecutingAssembly    GetNa  me     CodeBase    Substring 6       game_files  graphics      DirectoryInfo dir   new DirectoryInfo filepath     return dir GetFiles    png    Length     35    Salazar       returns the IPv4 address of the server  string getIP4Address                    Ad
10.    20  lt  lt  16   lander_y    60  lt  lt  16   lander_dx   0   lander_dy   0   lander_angle    ANG_90   game_state    GAME_STATE_RUN  GAME_STATE_MENU    the game is running        clear bi  gr clear    tmap          1    INPUT SECTION  LEAL LALA LAL ELT ATL ITAL ELT IE            get nes controlle    nes_buttons N       LE ttons  amp  N    TG     nes_bu  game_sta       1    END INPUT SECTION  DEEL ECT LETT EEET TIS IAT IDE ES                1                         RENDERING SECTION  TEE EETE LEE ALETE PL EILTEALTY                draw text  gr textmode  2 1 5 3  gr colorwidth  2 0      draw fuel and num  gr text  HUD_X_POS           ES x  b  B      1 1 1 11 11 11 11 11 11 1 1 11 11 11 111    r buttons  Read_Gamepad    ES_START        GAM     HUD_Y_POS   gr text  LANDERS_X_POS           E_STATE_START       11 11 11 11 11 11 11 11 11111       1 1 11 1 1 11 11 11 11 11 11111         players   hud_string   LANDERS_Y_POS   landers_string        84    Salazar    itoa lander_fuel   sbuffer   gr text  HUD_X_POS  HUD_Y_POS 12   sbuffer       draw vector objects      draw mountain     static for now    gr colorwidth  1 0     gr plot   96     y     80     96     repeat i from 1 to 20    update y  y    mountain_scape i 1     draw line  gr line  96   i 8 y       finall    Ly mountainscape back to horizon  gr line 96  96             draw landing zone   gr colorwidth  3 0    gr plot  96   landing_zone 0    96   landing_zone 2    gr line  96   landing_zone 1    96   landing_zone 2        
11.    27 CPi    4 alla d E  C     3  9 Fy H BIS z A AEIEIHIE EE EIEEE 9 BIE CE CPB       Ej ples   L AIEEE JHH   alle P25  Ca   s s   gt  sje is  gt  s    F  lt e EE      CD D   i HIHIRI al HEISE PEIEE EER EE alsa   a  3 3 HENE allgiisiz   CZ aD   2 2 e 212 2 e aa lell 41 21F elfe 2 elfo aD are   e 9 SIS 9 g   RIS g cz CD  512 X 32 CP   RAM RAM RAM   E C2      CBD  Cis  CP                                                     coe Reset Delay    50 ms   eo Brown Out  sg Detector CLKSEL  cmn RC Oscillator  Pam 12 MHz   20 KHz     Clock PLL  PLLENA 1x  2x      4x  Bx  16x  l  16  must be SOFTRES  aD oye 64   128 MHz  PLLENA  XO  sciliator    DC   80 MHz pecans  OSCENA  4   8MHz OSCMODE  OSCMODE  34 gt   with Clock PLL  CLKSEL    Hub and Cog Interaction    Figure 1 3 Propeller Chip Block Diagram    Salazar    1 2 HYDRA Hardware Description    Propeller Chip  The HYDRA game console was built to work with the Parallax Propeller chip  The chip  architecture is shown in Figure 1 3  The propeller chip was designed by Chip Gracey of Parallax Inc  The  chip consists of eight cores  more commonly called cogs  These cogs are independent of each other  The  chip is a 32 bit RISC like architecture  Moreover  the propeller chip can run assembly language as well as    a more high level language called Spin  3   The chip executes only 32 bit instructions     Main Memory  The amount of main memory provided in the HYDRA console is 64KB  which is  organized in two blocks  each consisting of 32KB  The 
12.    allocate 20 longs for the task stack    DA 777 1111111  12 PUB Start  3   this is the first entry point the system will see when the PChip starts   14   execution ALWAYS starts on the first PUB in the source code for  15    the top level file  1717 spawn 2 COGs each with the Blink function and some stack space  18 COGNEW  Blink  5 988 908   eblink_stack      19 COGNEH  Blink  i 500 002   eblink_stack 10      1  sit in infinite loop  that is do not release COG 0  22 repeat while TRUE    SKI AAA    18    Salazar    Figure 4 1  Code segment a SPIN program    Example 4 is a classical game called Mars Landers  In this game  each player tries to control a  spaceship  in which fuel is limited  The purpose of this game is to try to land in the respective area  before the ship runs out of fuel  This game can be uploaded to the Hydra console from the network but  not played through the Java applet  However  it can still be played in the Hydra console  provided that    its output is connected to a TV through RCA cables     19    Salazar    Section 5  Conclusion    To conclude  several more games have been added to the HydraNet system  Respectively  the  source code  the user manual  the dummy zip files  and the executables have been included in a newly  created folder residing on the server PC  The respective links for downloading these files have been  added to the website as well as shown in Figure 5 1  The reason why a dummy zip file is provided is  because the HydraNet system req
13.    break      else          make the byte by including input and player number  outByte 0     byte   inByte   pNum         send the input byte to the HYDRA  sendToHydra outByte          catch  Exception                end the loop for receiving game inputs  break                close the connection with the player client   try      client Client Close     client Close                      catch  Exception                   do nothing       31    Salazar       send player off input to HYDRA just in case the player did not       actually     transmit it before the connection was terminated  outByte 0     byte   PLAYER_INPUT_OFF   pNum         sendToHydra outByte          Console WriteLine   Player      player playerNumber   1       disconnected           numPlayers       decrement the number of connected players       player conn   null   player active   false     deactivate player          send out player disconnect message  broadcastToPlayers    byte   PLAYERO_DISCONNECT    player playerNumber              T            receives game state from HYDRA and sends to player clients  void hydraToPlayers             byte rec   while  true      try     rec    byte  hydra ReadByte          send game state to all active players  broadcastToPlayers  rec         catch  Exception                do nothing            sends a byte message to all active players   MethodImpl  MethodImplOptions Synchronized     void broadcastToPlayers  byte message         send the byte to all active players  
14.    images  id   x rec           rec lt  254        read a       se          get object s y coordinate  if   rec connIn read     lt 0     return   lse if  rec  255     continue   lse if  rec gt  241  amp  amp   readCommand  rec     continue    lse   images  id   y rec               rec lt  254          read a          se          read the end byte   if   rec connIn read     lt 0     return    selse if  rec gt  241 KK rec lt  254     readCommand  rec      read a  continue            catch  IOException ex     return                redraw the game screen  repaint                end byte was received        end byte was received     Exception ex          stream was terminated and  1 was returned    start over on next packet    command byte       stream was terminated and  1 was returned    start over on next packet    command byte       stream was terminated and  1 was returned    command byte       reacts to commands received from the server    public void readCommand int command     switch  command             case PLAYERO_CONNECT   displayMessage  Player 1 connected  break     true      1  sd       50             pub  pub        pub                                                                                        case PLAYER1 CONNECT   displayMessage   Player  break    case PLAYER2 CONNECT   displayMessage   Player  break    case PLAYER3 CONNECT   displayMessage   Player  break    case PLAYERO_ DISCONNECT   displayMessage   Player  break    case PLAYER1 DISCONNECT   displa
15.   1             Salazar         hex_table   value         FA PPL ALLAN LALLANA I IPE ILAL IAS ATLL PIPL IAT IIS PILI IEEE IAAP IA LL TIPPEE    ESL ELL    DATA SECTION    1             7    7P    DAT         TV PARAMETERS FOR DRIVER  TLILI TAA BLELS IAEA ELELT TAA EEE ELTA EEL ETS LATA E EA PAPEL TS             tvparams      POLYGON OBJECTS                lon  lon  lon  lon  lon  lon  lon  lon  lon  lon  lon  lon  lon  lon          WO 0 0 0 0000 00 00 0 0                0  status   1  enable   011_0000    pins   0000  mode   0  screen   0  colors  x_tiles  he  y_tiles  vc   10  hx timing stretch  1  Vx   0  ho   0  Vo  55_250_000  broadcast  0  auralcog    STRELA ALI DET AL LLALLA LEL T A UALL IS PLAT LAAT LEIA LYS TLL    lander_model    word  word    word  word    word  word    word  word     4000 ANG_0     8000 ANG_120                 8000 ANG_240    94    Salazar    word S8000 ANG_0  word 50  word U                                                      STRING STORAGE   LAILEELIS ISI ELPA ATS EPA PAPI AA LUNII ATI IAAT IAS ELT IAT IAS  hex_table byte  0123456789ABCDEF    hud_string byte  Fuel  lbs    0  text  landers_string byte  Landers  0  text  start_string byte  Press Start  0  text  title_string byte  Mars Lander   0  text  crash_string byte  Crashed   0  text  over_string byte  Game Over   0  text  landed_string byte  Landed   0  text               to show use of data driven rendering  the mars terrain and landing  zone are defined by data    this way you can change the
16.   1  x  Y     1    has to below a threshold  absolute value of    1    angle of the ship must be within 5 degrees of    1    landing is successful     1    1       1    re acquire velocity in new scale     lander_dx   gt  10          lander_dy   gt  10       test for landing zone  the conditions are downward velocity       horizontal vel          ocity has to be below a threshold and the       straight up  don t want to break the landing gear  if a    and processed       a state change is noted here    down stream  also the coordinate structure of    the  landing zone  is used to determine if the ship       is touching down on the landing zone  but we could have    with  however        tested for  green  which is what we paint the landing zone       if we couldn t spare a color to  paint  the                   landing zone for color collision detection then we would    1    exercise    have to do it    the hard way with geometry  so this is a good       if    lander_wp_x  gt   landing_zone 0  96   and  lander_wp_x  lt   one 1  96   and  lander_wp_y  lt   landing_zone 2  92         landing_z          1    7P    1       if    y  lt  0  and  y y  lt  MAX_LANDER_TOUCHDOWN_YVEL  and  x x   lt  MAX_LANDER_TOUCHDOWN_XVEL      gr colorwidth  1 0    gr plot 0  0             the eagle  game_state       END ANIMATION                has landed                   GAME_STATE_LANDED          SECTION                               TITITTTITTL ITAA TAT ATTA TAAL A TATA    RENDERING SECTION     
17.   Console WriteLine                endregion    static void Main string   args             new HydraServer       37    GG  SAG OG SE  SG Ee       si  si  si  si  si  si  si  si  si    Salazar    Appendix B  HydraProp DLL Source Code  C      System  System  System  System  System  System  System  System  System     Ng  Ng  ng  ng  ng  ng  ng  ng  ng     Collections Generic    ComponentModel     Data     Drawing     Text     Windows Forms    Runtime InteropServices   IO              namespace HydraProp         public partial class HydraPropForm        prototypes to permit use of the   region Propellent DLL prototypes   DllImport   Propellent dl1l   CharSe  CallingConvention Calli       li    Form    Propellent dll functions       CharSet Ansi   ngConvention Cdecl     llent  IntPtr WinHandle   h      bool       CharSet Ansi   ngConvention Cdecl          lerVersion       CharSet Ansi   ngConvention Cdecl             SearchMethod uint Value      CharSet Ansi     static extern unsafe void InitPrope  StorePrefs  IntPtr RegPat    DllImport   Propellent dll   CharSe  CallingConvention   Calli   static extern unsafe uint GetPropel    DllImport   Propellent dll   CharSe  CallingConvention   Calli   static extern unsafe void SetSerial    DllImport   Propellent dl1l   CharSet  CallingConvention     static extern u    DllImport   Propellent dl1l   Charset  CallingConvention     static extern u       DownloadCmd        DllImport   Propellent dll    CallingConvention   static exter    endreg
18.   read first bit of each game pad      data is now ready to shift out  1 b    first bit is ready  nes_bits    0             t left controller  nes_bits    INA 5     INA 6   lt  lt  8             step 7  read next 7 bits  repeat i from 0 to 6                   OUTA  3     1   JOY_CLK   1    Delay  1    OUTA  3     0   JOY_CLK   0   nes_bits     nes_bits  lt  lt  1    nes_bits    nes_bits   INA 5     INA 6   lt  lt  8      Delay  1     invert bits to make positive logic    Salazar    92    Salazar    nes_bits      nes_bits  amp  SFFFF     1    7  LE    End NES Game Paddle Read                1    7  AL E    1    7  LE       PUB Delay  count    i  X  Y  Z    delay count times inner loop length  repeat i from 0 to count          U    7  TI EET TA       PUB SinCos op  angle   xy  if  op  COS   angle   800       if angle  amp   1000   if angle  amp   800    angle   angle     7000   xy     word angle  lt  lt  1   else  if angle  amp   800    angle  angle     7000  xy    word angle  lt  lt  1        1    LET T T IAN AAE T AEL LL LILLIA  7P   PUB itoa value  string_ptr    base  factor  i     converts an integer into an ASCIIZ  up to 99_999x     string_ptr points to target storage to store converted string                        10000 s place  base    10_000    repeat i from 5 to 2    factor    value   base  byte 0   string_ptrt       hex_table   factor    value    factor base    93    base    10      1 s position  byte 0   string_ptr      NULL terminate  byte 0   string_ptr           
19.  ANIMATION SECTION             FLELA TAS AI TSI IA TALE IAAT SALT PTAA AT AAA ATI ID AA ITT TASS    1    EE    1       apply thrust model if thruster is down    lander_dx     lander_dy        lander_fuel             lander_fuel      expend fuel     gt  0 and nes_buttons  amp  NES_     SinCos  COS  lander_angl  SinCos  SI     1   1    as  as    t_cos  t_sin             add gravity    lander_dy       GRAVI       TY          B                 N  lander_angl         scale down x y       lander_dx   gt   lander_dy   gt        cache result for later computation  16  16         test for maximum magnitude of thrust    if    1       1 m    lan  lan    lan          lan      x x   y y   gt     slow ship down  lander_dx          ove player  der_x     der_y                       der_wp_x          MAX_LAND       ER V       EL         lander_dx   gt  7   lander_dy     lander_dy   gt  7     lander_dx   lander_dy       cache whole parts    lander_x   gt  1  der_wp_y    lander_y   gt  1         screen bounds test for player    86    if  lander_wp_x    Salazar        gt  SCREEN_WIDTH 2                 lander_x     SCREEN_WIDTH  lt  lt  16              elseif  lander_wp_x  lt   SCREEN_WIDTH 2     if  lander_wp_y                                     lander_x     SCREEN_WIDTH  lt  lt  16                        gt  SCREEN_HEIGHT 2                                lander_y    lander_dy  lt  lt   lander_dy    0  elseif  lander_wp_y  lt   SCREEN_HEIGHT 2   lander_y    lander_dy  lt  lt   lander_dy    0  
20.  ActionListener    ction related variables  Socket conn   InputStream conntin   OutputStream connOut              conn  private  private    private    out       implements KeyListener  Runnable        connection with the server     incoming stream from server    going stream to server       graphics related class and variables                                                                                                                                           private final static int SCREEN_SIZE_X 240  SCREEN_SIZE_Y 180   class GraphicObj   Image img   boolean visible false   int x 0  y 0      private GraphicObj   images   private int numImages   private Image graphicsBuffer   private String message         player input values  private final static int INPUT_ON 240     player on reset  INPUT_OFF 0     player off  INPUT_UP 128     up  INPUT_DOWN 64     down  INPUT_LEFT 32     left  INPUT_RIGHT 16     right  INPUT_FIRE 48     fire     command message values  private final static int PLAYERO_CONNECT   241   PLAYER1_CONNECT   242   PLAYER2_CONNECT   243   PLAYER3_ CONNECT   244   PLAYERO_DISCONNECT   245   PLAYER1_DISCONNECT   246   PLAYER2_DISCONNECT   247   PLAYER3_DISCONNECT   248   DEV_UPLOADING   251   DEV_FINISHED   252   SERVER_SHUTDOWN   254                 46    Salazar       this method is called first  public void init         super       cr  graph    try        co  co  co    catc  di  re    catc  di  re    try          eine  5    eate the graphics buffer  icsBuffer
21.  code short  repeat 1_000_000    transition back to starting state  game_state    GAME _STATE_START  else  if  game_state    GAME_STATE_OVER   repeat 1_000_000    transition back to initialization state  game_state    GAME_STATE_INIT    L  if    1    check if landed    game_s  repeat  transit  game_stat       tate  _000_000  tion back t       GAMI                         E STATE LANDI       initializat    O    ED     ion state             te GAME    C             INI       STATE T       89         END RE             ND       ERI       NG S       ECT         ON       TIPLE EIS EI ALA LISP EE LE PIT AIA SS EPI PEELE I PELL      END MAI          N GAME LOOP R             EPE       AT          BLOCK      11 11 11 11 11 1 1 1 1 11 1 1 11 11 11 1 1 11 1111 11 11 11 111    1    Salazar    LEE EA EEE                                                                               7P  PUB Plot_Pixel x  y  video_buffer  color     video_offset  pixel_value    plot pixel calculation using BYTE aligned calcs 192x192 bitmap   12x12 tiles  video_offset    video_buffer    x  gt  gt  4     192 4      x  amp   1111   gt  gt   2     y  lt  lt  2     read pixel group from memory  pixel_valu   byte video_offset     mask AND out target bits  so color mixing doesn t occur  pixel_value    pixel_value  amp     00000011  lt  lt    x  amp   11   lt  lt  1      OR color with pixel value  pixel_value    pixel_value    color  lt  lt    x  amp   11   lt  lt  1      write pixel back to memory  byte video_offse
22.  createImage  SCREEN_SIZI          Ley                         X  SCREEN _SIZE_Y            connect to server and get network I O streams  nn new Socket  getDocumentBase   getHost    5309    nnin conn getInputStream     nnOut conn getOutputStream      h  UnknownHostException ex      splayMessage   Cannot connect to server    false    turn    h  IOException ex     splayMessage  Cannot connect to server    false    turn                       tell server that this is a player client    connOut write 1    connOut flush           if    check if the connection was accepted by the server   connIn read    1        server was not full  connection accepted       get the number of images and create the array       if   numImages connIn read       0     displayMessage  Error getting images    false    return          images new GraphicObj numImages          this is used to wait for all images to load  MediaTracker tracker new MediaTracker  this            create the images by downloading them from the server  for int i 0  i lt numImages  i     images i  new GraphicObj     images  i   img get Image  getDocumentBase      game_files graphics   it   png      tracker addImage images i  img  0                    wait for all images to load   try   tracker waitForAll       catch InterruptedException e     displayMessage  Could not download graphics    false    return                tell server that image download is complete    47    connOut write 1    connOut flush      U       notify the HYDR
23.  page or dev anew game on the Developer page     There is no need to worry about connecting and disconnecting  If you are seeing this page a  navigate away from this page or close the browser window  To attempt to reconnect or to s    View the game manual  opens in new window   tab    The game controls are     A  Left  D  Right  W  Up  S  Down  J  Action    To play  you must first click within the screen area     Figure 2 2  Hydra Player Web Site    15    Salazar    Section 3  Prospective Solution    Adding more games to the HydraNet3 system consists of building up games in the Spin language     and making them available to players that connect to the system  However  this is not an easy task     Before adding a game  we need to code it  Thankfully  one can find many classic games available  along with their respective source code from the documentation provided with the Hydra Game  Development Kit  Thus for instance  one of these games could be chosen  The source code of the chosen  game would be slightly modified depending on the needs of the HydraNet4 system  A directory  containing all the added games would be added to the HydraNet3 system  Then the compiled files and  the source code for each game would be placed in the newly created games directory  The website  would be slightly modified  First it will provide links to the newly added games  so the client player  would have the ability to choose from a variety of games  Once a player loads a game  the game will    star
24.  the height visible  There are also no  restrictions on   each image size so if an object must be more than halfway  offscreen  a transparent   border can be placed around the image to make it look as though  the object is almost    or completely  off the game screen  This permits development  features such as scrolling       56    Salazar    backgrounds and wrap around player movements rounds and wrap   around player movements  lt  p gt    lt p gt        Players download all graphics from the server before starting the  game so larger  image file sizes  within reason  will not degrade the performance  of the HydraNet  3 game  lt  p gt    lt h3 gt   Code sections for developers lt  h3 gt            lt p gt        There are several sections in the template source code that are  labeled for developer  use  lt  p gt    lt ul gt         lt li gt  lt span class  stylel  gt Constant variables lt  span gt   This section  of code is for declaring  any variables you need that will never change  Adding  constant variables to this  section is preferred over adding them to the regular  variables section  lt  li gt    lt li gt  lt span class  stylel  gt Variables lt  span gt   This section of code  is for declaring any  variables that may need to be updated during game  execution  lt  li gt    lt li gt  lt span class  stylel  gt Start method lt  span gt   This section of  code is used for any initialization   The setGraphicsSize method must be called in this section   This method must be 
25.  the means to upload your games to the  server   lt  p gt    lt p gt   Go back to the  lt a href  Default aspx  gt main page lt  a gt  or play the  current game on  the  lt a href  Player aspx  gt Player page lt  a gt   lt  p gt    lt h2 gt   Game uploader lt  h2 gt    lt p gt   To upload a game for the HydraNet 3 system  three files are  required  lt  p gt    lt ul gt    lt li gt  lt span class  stylel  gt Compiled game file lt  span gt   This file  must be created using  the Propeller Tool software  which is explained in the  tutorial  The file type must  be EEPROM  lt  1i gt    lt li gt  lt span class  stylel  gt Zipped images file lt  span gt   This zip file  must contain only PNG images  which meet the requirements  in the tutorial  These images must be  in the root directory of the zip file and the zip file must  not contain any subfolders   The file type must be ZIP  lt  1i gt    lt li gt  lt span class  stylel  gt Game manual file lt  span gt   This text file  can contain anything    you want the players to know about the game        A link to this    document is provided    53    Salazar    on the main and player pages so that others can understand  the rules and controls  of the game  The file type must be TXT  lt  1i gt         lt  ul gt    lt p gt   Select the files and then click the  amp quot Upload Files  quot   button  lt  p gt         lt p gt   Compiled game file   eeprom  lt br   gt    lt asp FileUpload ID  upldGameFile  runat  server   meta resourcekey  upl
26.  tkk fi  tkarvine pre wrap   css3 mozilla opera ie  html        Browser specific  not valid  styles to make preformatted text wrap    S                pre            white space  pre wrap     css 3                white space   moz pre wrap     Mozilla  since 1999     white space   pre wrap     Opera 4 6     white space   o pre wrap     Opera 7          word wrap  break word     Internet Explorer 5 5          lt  style gt    lt  head gt    lt body gt    lt form id  forml  runat  server  gt    lt div gt    lt pre gt  lt     include virtual  game_files manual txt     gt  lt  pre gt    lt  div gt    lt  form gt    lt  body gt    lt  html gt        63    Salazar    Appendix I  Hydra Game Example 1 Source Code  Spin     V SELIL LLLI EIA LALIE ILLL TIT TATTTI ATT I EE ETT A ALALLA     Game that allows 4 people to play from remote computers over a network         11111111 1111 111111 11 11 1 11 1 1 111 1 11 1 1 1 111111111111 111 11111 1111111 1 1 1 1 111111    CON      set clock mode speed  _clkmode      _xXinf    req      xt    10_      screen size       SCRE    EN _SIZE_             SCRE    EN _SIZE_       Y    X      all   pll8x  000_000    240    180      max number of graphics  GRAPHICS_MAX                                         p    on  INPUT_ON  INPUT_OFF  INPUT_UP  INPUT_DOWN  INPUT_LEFT  INPUT_RIGHT  INPUT_FIRE    max  PLAYER_MAX               100    layer input bit codes  ly uses first 4 bits     1111_0000   0000_0000   1000_0000   0100_0000   0010_0000   0001_0000   0011
27.  tplayerTurbo player     gt  0      RIGHT   ght   playerimg    tGraphicsObjxX  playerImg     2 playerTurbo player     tScreenSizeX            lt            End section of c       1111 1 11111111    EEE LT E TTT    Start section of c    ode for developers    TITTTTTTTTTATTTTAT TATA AAA ATTA AAA AAA AAA AAA ATT TT TTT    ZAE ERT LITLI TUILL LLALL IIL ALILI TT  ode for developers  developer defined methods                                                                   PUB getPlayerGraphicObj  player   if player    return IMG _PLAYERO  elseif player    return IMG PLAYER   elseif player    return IMG _PLAYER2  elseif player    return IMG _PLAYER3    End section of code for developers  t  FLIELI LITLILLTE LELLI LLAL LILII L ALALLE EEE    PUB startGame    usb start  31  30     start the USB connection    0  9600    receive pin  transmit pin  mode  baud rate    start a new cog to read all player inputs  cognew  receiveInput     Q receiveInputsStack     66    Salazar      start a new cog to send game state to players  cognew sendGraphics   sendGraphicsStack     PUB receivelInput   rec  player  input  repeat      receive the byte containing player number and input  rec  usb rxtime  5          get player number  last 4 bits   player  rec  amp   0000_1111      get input code  first 4 bits   input  rec  amp   1111_0000      update the player s position  update  player  input     PUB sendGraphics   id  tempID    send info on active graphics objects    send id  x  y of each active graphi
28. A that player is starting session    connOut write  INPUT_ON    connOut flush          receive player connect message  readCommand conniIn read           start listening for key presses  addKeyListener  this         start receiving graphics info stream  new Thread this  start     jelse      server was full  connection denied    displayMessage  Server is full  Try again later                close the connection  stop           catch  IOException ex                  stores the next game screen into the graphics buffer  public void updateGraphics       Graphics g graphicsBuffer getGraphics     g clearRect  0  0  SCREEN_SIZE_X  SCREEN_SIZE_Y                                    if  images  nul1     for int i 0  i lt numImages  itt     if  images i  visible        calculate image offset to its center  int xOffset images i  img getWidth  this   2   int yOffset images i  img getHeight  this   2              g drawImage images i  img  images i  x xOffset   SCREEN_SIZE_Y images i  y yOffset  this                             display the message if it exists   if  message length   gt 0     g setColor Color RED     g drawString message  5  15                 required for JApplet  paints the applet window  public void paint  Graphics g      updateGraphics      g drawImage graphicsBuffer  0  0  this      Salazar    false      48    Salazar       required for JApplet  runs when the applet closes  public void stop       super stop       try       removes images from cache  which avoids the pro
29. Exception ex     return                displays a message in the top left corner of the game screen   is     true  then the messag  public void displayMessage  String message   this message message   repaint        if  timed     Timer t new Timer 3000  this      t setRepeats  false    t start       if timed    will be displayed for only a short time  boolean timed                              required for ActionListener  clears the displayed message after a    certain time  public void actionPerformed  ActionEvent e             message      repaint        52    Salazar    Appendix F  Developer Web Site  ASP NET            lt    Page Language  C   AutoEventWireup  true  CodeFile  Developer aspx cs           Inherits  Dev  Culture  auto  meta  resourcekey  PageResourcel     UICulture  auto        loper        o  3 gt                                                                  lt  DOCTYPE html PUBLIC     W3C  DTD XHTML 1 0 Transitional  EN    http   www w3 org TR xhtml1 DTD xhtml1 transitional dtd  gt    lt html xmlns  http   www w3 o0org 1999 xhtm1  gt    lt head id  Head1  runat  server  gt    lt title gt HydraNet 3 Developer lt  title gt    lt style type  text css  gt    style1  text decoration  underline       lt  style gt    lt  head gt    lt body gt    lt form id  form1  runat  server  gt    lt div gt    lt h1 gt   HydraNet 3 Developer lt  h1 gt    lt p gt   Welcome to the HydraNet 3 Developer  This page includes a  tutorial on how to develop  games for HydraNet 3 and
30. IL IIA IIE EITAL TAS ATLAS PIPL IAAI IIS PILI NIILL AL IA LEAT I T              0 1 2   of f visible invisible        O0     off on     Sppmmm   pins     Sccinp   chroma  interlace  ntsc pal  swap     pointer to screen  words         pointer to colors  longs      horizontal       cells        vertical cells     horizontal    cell expansion        vertical cell expansion     horizontal offset     vertical offset     broadcast frequency  Hz        aural fm cog    screen x_tiles   y_tiles                    TIER L EL  VAR   long tv_status  only   long tv_enable  only   long tv_pins  only   long tv_mode  only   long tv_screen  only   long tv_colors  only   long tv_hc  only   long tv_vc  only   long tv_hx  only   long tv_vx  only   long tv_ho  only   long tv_vo  only   long tv_broadcast  only   long tv_auralcog  only   word   long colors 64    long lander_state   long lander_x   long lander_y       P    1    f      player s lander all in fixed point 16 16    storage for screen tile map  color look up table       read     writ    writ    writ    writ    writ    writ    writ    writ    writ    writ    writ    writ    writ       81    L          lan  lan    lon  lon          lan  lan  lan    lon  lon  lon                lon  lon    g lan  g num               game  word gam  word gam  word gam         random  byte ran       der_wp_xX  der_wp_y    der_dp_x  der_dp_y    der_dx  der_dy  der_angl       der_fuel  landers    e_ state    e_counterl  e_counter2    stuff  dom_count    Ler     
31. Inc      also included with Propeller Tool download above   lt  li gt               lt  ul gt    lt p gt   Two simple gam xamples are included for you to better  understand how a game is built   or if you wish to restore the HydraNet 3 system to an original  state  lt  p gt         lt ul gt    lt li gt Example 1 shows how to get 4 players to move about a static  background   lt ul gt                                             lt li gt  lt a href  game_examples gam xl eeprom  gt Compiled  game lt  a gt  lt  li gt     lt li gt  lt a href  game_examples gam xl code spin  gt Source  code lt  a gt  lt  1i gt     lt li gt  lt a href  game_examples gam xl images zip  gt Images lt  a gt    zipped   lt  li gt     lt li gt  lt a href  game_examples gam xl manual txt  gt Manual lt  a gt  lt br    gt     lt  li gt     lt  ul gt     lt  li gt         lt li gt Example 2 shows how to get 4 players to move between two  backgrounds and how to  get the player images to change based on movement and turbo  state  lt ul gt     55     lt  ul     lt h3 gt      lt p gt      lt p gt      lt ul gt      lt  ul   lt p gt     Salazar           lt li gt  lt a href  game_examples gam x2 eeprom  gt Compiled  game lt  a gt  lt  1li gt    lt li gt  lt a href  game_examples gam x2 code spin  gt Source  code lt  a gt  lt  1i gt    lt li gt  lt a href  game_examples gam x2 images zip  gt Images lt  a gt    zipped   lt  li gt    lt li gt  lt a href  game_examples gam x2  manual txt  gt Manual lt  a gt  lt  li gt
32. L U          PUB getScree  return SCR    PUB getScree  return SCR    PUB getScr    he player to be active     0000_0001  lt  lt  id    pStatus                                        return get                   PUB getScr  return get             e player to be inactive  s    1111_1110  amp  pStatus  d  1   s    1111_1101  amp  pStatus  d  2   s    1111_1011  amp  pStatus  d  3   s    1111_0111  amp  pStatus  nSizex   EEN_SIZE_X   nSizeyY   KEN SIZE_Y   nCenterX   ScreenSizeX 2   nCentery   ScreenSizeY 2    Salazar    68    Salazar    Appendix J  Hydra Game Example 2 Source Code  Spin     V SELIL LLLI EIA LALIE ILLL TIT TATTTI ATT I EE ETT A ALALLA     Game that allows 4 people to play from remote computers over a network         11111111 1111 111111 11 11 1 11 1 1 111 1 11 1 1 1 111111111111 111 11111 1111111 1 1 1 1 111111    CON    set clock  _clkmode    _xinfreq        screen si       SCREEN_SIZE_  SCREEN_SIZE_                  max numbe       mode speed  xtall   pll8x  10_000_000    Ze  X   240  Y   180    r of graphics    GRAPHICS_MAX   100    layer in  nly uses          PUT_LEFT  PUT_RIGHT  PUT_FIRE          P   O   P O  PUT_OFF  P UP  P D   D   D   D       HHHHHHH      222422242224                         PLAYER_MAX          put bit codes  first 4 bits     1111_0000     0000_0000     1000_0000     0100_0000   0010_0000     0001_0000     0011_0000      4       objects allowed    Since last 4 bits are for player flags    player on reset  player off   up   down   left   r
33. NTAL MARS LANDER DEMO PROGRAM  AUTHOR  Andre  LaMothe   LAST MODIFIED  5 10 06   VERSION 1 1  COMMENTS  implements simple lunar lander  collision works  landing                                                                CONTROLS  gamepad  must be plugged in   Start    Start    Thrust    B   Rotate Right    Dpad Right     Rotate Left             W    fuel works  try adding sound and changing the terrain etc   1  1  1  1  1  1                                     Dpad Left     LILAPEIELI ITS ELI L ALIS ELIT TI IA ILLS PEEL II AA TT I OTL IP CTIA TI IIIT TST EP EE  IIIS TI    1    7  FREES EA      CONSTANTS SECTION   FALTAIAS ED ALE EATALE TA LAT EL ELIT AT IE AA TAS AAT ETA TAD ATA TIT EL PEI A  IIIS T                    CON   _clkmode   xtall   pll amp x   enable external clock and  pll times 4   _xinfregq   10_000_000   0000   set frequency to 10 MHZ plus    some error  _stack     2400    2400    100   gt  gt  2    accomodate display memory and  stack      graphics driver and screen constants                   PARAMCOUNT   14  OE SCREEN BUFFER    3800   offscreen buffer  ONSCREEN_ BUFFER    5C00   onscreen buffer                        size of graphics tile map  X_TILES   12    Y_TILES   12                      78                                                                                              SCREEN_WIDTH   192   SCREEN_HEIGHT   192     text position constants   HUD_X_POS       SCREEN_WIDTH 2   10  HUD_Y_POS   SCREEN_HEIGHT 2   1 14  LANDERS_X_POS   SCREEN_WID
34. OL_DarkGrey  COL_Grey  COL_LightGrey  COL_BrightGre  COL_White   COL _Blue  COL_Blue2  COL_Purple    COL_Magenta   COL_Magenta2  COL_Red  COL_Orange  COL_Brown  COL_Yellow  COL_YelGrn  COL_Green  COL_Green  COL_Green  COL_Cyan   COL_Cyan2  COL_Cyan3                   N       Ww         each palett       ID   0    Ss     CO  W   SCl     C2     C3    SCB     20     0D       odings  S00000001      600000010     00000100   00001000  600010000   00100000   01000000      610000000    Salazar      color constant s to make setting colors for parallax graphics       60000_0010      60000_001      0000_0100     0000_0101  y    0000_0110     0000_0111       60000_1       0001                           60010          0011         60100       ll  o    101       110          ll  ol        ll  o  2  Oy    1       oll  o ol   em e  EF aD    ee a        ll  o   amp        oO          oll  oA o  5  a   Op  La       ll  o  ped  ma ee               ll  o  5  a                o  5                   T ET     T E I OE I T E o  O73 T                              4           e entry is    color 1   color 0  COLOR_O    COL Black  lt  lt        a LONG arranged like so  color 3   color 2      0     80    1    COLO  COLO  COLO       R_1    COL_Green  lt  lt  8   R_2    COL_White  lt  lt  16        R_3    COL_Red     lt  lt  24     Salazar    PIPL ELIDA LIS ELLA ATID RIEL PTS IATL LAI PL I AA I PI SALI II IP EIT APTI SEATTLE    1         LIIITE    VARI          ABLES SECTION                   PAPE LALIT I
35. Salazar    Adding Functionality to the HydraNet3 System  Santiago Salazar  CNT 4104 Software Project in Computer Networks  Dr  Janusz Zalewski  Florida Gulf Coast University    September 19  2011    Table of Contents    Section 1  Introduction   Section 2  Definition of the Problem   Section 3  Prospective Solution   Section 4  Implementation   Section 5  Conclusion   Section 6  References   Appendix A  Use Manual   Appendix B  Server Source Code  C     Appendix C  HydraProp DLL Source Code  C    Appendix D  Main Web Site  ASP NET    Appendix E  Player Web Site  ASP NET    Appendix F  Player Client Applet Source Code  Java   Appendix G  Developer Web Site  ASP NET    Appendix H  Developer Client Source Code  ASP NET   Appendix    Hydra Game Example 1 Source Code  Spin   Appendix J  Hydra Game Example 2 Source Code  Spin   Appendix K  Hydra Game Example 3 Source Code  Spin     Appendix L  Hydra Game Example 4 Source Code  Spin     Salazar    Salazar    Section 1  Introduction    The HYDRA Game Development Kit is a platform used to learn game development  The HYDRA  Game Development Kit was designed by Andre LaMothe  1   He is the founder of Xtreme Games LLC  the  Xtreme Games Developers Conference  and Nurve Networks LLC  This platform is based on a Parallax   s  propeller multiprocessor chip  This platform is known by its easy programmability  and thus game  developers are only assumed to have some basic understanding of any programming language similar to    C  The HYDRA Gam
36. T LOTS                             IIIS SS     PUB Start   1  h   starts      execution ALWAYS starts on    the top level file     spawn 2 COGs each with the  COGNEW  Blink  2_000_000    COGNEW  Blink  20_000_000     sit in infinite loop   repeat while TRUE                that is do not rel    is is the first entry point the syste       Bl    the first PUI       P    ink          0       l     lease COG U    m will see when the PChip  B in the source code for  unction and some stack space     blink_stack 0     blink_stack  1    TILA LAA ET PALLIAT PTET LATTA IA ALT ST PELL AAT ATT AA TIP AAA SIS A ETT ALP EL                                                       LED on the    into       UNE4    is sent as a       the results      1 111 1111   PUB Blink  rate      this is the parallel function  it simple blinks the debug     hydra  note is must set the direction output and then falls     an infinite loop and turns the LED on   off with a delay co     the interesting thing to realize is that the  rate    parm     when we launch the COG  so there will be 2 COGS running this SAME    infinite loop  but each with a differnet blink rate      will be a blinking light that has both one constant blink rate    with another super imposed on it    DI       RA 0     repeat while TRUE    OUTA 0   wal       1        OUTA 0     tent  CNT   rate        77    Salazar    Appendix L  Hydra Game Example 4 Source Code  Spin     1    LEZE EEE EEE ELA VA ECT EEE EEE ELTA TELS ELT  TELL ERY    EXPERIME
37. TH 2   12 2  12  LANDERS_Y_POS   SCREEN_HEIGHT 2   1 14    lander physics model   MAX _LANDER_VEL   4  MAX_LANDER_TOUCHDOWN_YVEL   100  MAX_LANDER_TOUCHDOWN_XVEL   20   GRAVITY    0000_0100     angular constants to make object declarations easier  ANG_O    0000   ANG_360    2000   ANG_240     2000 2 3    ANG_180     2000 2    ANG_120     2000 3    ANG_90     2000 4    ANG_60     2000 6    ANG_45     2000 8    ANG_30     2000 12    ANG_22_5     2000 16    ANG_15     2000 24    ANG_10     2000 36    ANG_5     2000 72                                                                               constants for math functions    SIN         COS   1      game states    0       GAME _ STATE       INIT               GAME _ STATE          GAME _ STATE          GAME _ STATE  GAME _ STATE       GAME _ STATE_                          GAME_STATE_                                                         game object states  OBJECT_STATE_DEAD    OBJECT_STATE_ALIVE    OBJECT_STATE_DYING    OBJECT_STATE_FROZEN               control interface    DOR WNEF CO       00_01     00_02   00_04       00_08       Salazar    79       THRUST_BUTTON_I       FIRE_BUTTON                  control key  KB LEFT ARROW  KB _ RIGHT_ARRO  KB _UP_ARROW  KB DOWN_ARROW  KB  KB  KB                         SPACE  ENTER                  NES bit enc  NES RIGHT    NES_LEFT   NES_DOWN    NES_UP    NES START    NES_SELECT    NES_B    NES_A                                           setup easier                      COL_Black  C
38. _0000    4       objects allowed    since last 4 bits are for player flags    player on reset  player off   up   down   Left   right   fire       number of players allowed    i AIAALL AAAA AAAI AAAA ALAALA AALAN L AAAA AALALA ALALLA      Start section of code for developers  constant variables         graphics object ID values    IMG_BACKGROUND   0    IMG_P  IMG_P  IMG_P  IMG_P    AAYERO  AAYERI1  AAYER2                      me WN EF    AAYER3              End section of code for developers       AE AEAEE AET AE LA T AE ET ATE AA LIE IAE    VAR      number of graphics objects within game  graphicsSize  graphicsVisible GRAPHICS_MAX     byte  byte  byte  byte    graphicsX  GRAPHICS_MAX   graphicsY  GRAPHICS_MAX     64    Salazar    byte containing bit flags for each active player  byte pStatus      stack for receiving player inputs  long receiveInputStack  100          stack for sending graphics  long sendGraphicsStack  100                  11111111 1 1 1 1 1 1 11111111111111 111111111111111111111111111 11 111111      Start section of code for developers  variables         turbo for player movement  byte playerTurbo PLAYER_MAX                End section of code for developers         111111111 1 1 1 1 11 11 11111111111111111111111111111111111111 1 1 1111111       OBJ  usb   FullDuplexSerial spin    USB driver  PUB start       L EEE EEE E EEE EEE EI EEE EEE AEAEE LEE      Start section of code for developers  start method         set the number of graphics objects  setGraphicsSi
39. apted from   http   aspnet  4guysfromrolla com articles 071807 1 aspx       string IP4Address   String Empty     foreach  IPAddress ip in Dns GetHostAddresses  Dns GetHostName            if  ip AddressFamily ToString       InterNetwork       IP4Address   ip ToString     break        if  IP4Address    String Empty        return IP4Address     foreach  IPAddress IPA in  Dns GetHostAddresses  Dns GetHostName           if  IPA AddressFamily ToString       InterNetwork         IP4Address   IPA ToString       break     return IP4Address      endregion     region HYDRA methods     connects to the HYDRA via serial over USB  unsafe void connectToHydra            Console WriteLine     Console WriteLine   Connecting to the HYDRA                      while  true           auto scan for port number  int port   HydraPropForm getHydraComPort           create serial port  hydra   new SerialPort   COM    port  9600  Parity None  8   StopBits One         open serial port  try      hydra Open        36    Salazar    break          catch                 Exception     while  true             check if user wants to try again  Console Write   Could not connect to HYDRA  Try again           by And Z  s  string s   Console ReadLine    ToLower     if  s CompareTo  y      0      break      else if  s CompareTo  n      0      Console WriteLine   Cannot connect to the HYDRA   Closing server      Environment  Exit  0                Console WriteLine   The server is connected to the HYDRA                  
40. ar    Appendix B  Server Source Code  C      Net     Net Sockets    Runtime CompilerServices    Runtime InteropServices        IO   TO Ports       Threading    Reflection     HydraProp     namespace HydraServer         class HydraServer          regi     a    class         on Variables and classes  simple class to store player info  Player    public Thread thread     public       TepClient conn     public int playerNumber   0   public bool active   false                   maximum allowed players    const       va    int  a       va  TcpLi  Playe  TcpC1l  Seria          va    Threa    int MAX_PLAYERS   4        riables to keep track of connected players  umPlayers   0        riables for connections   stener server    r   players   new Player  MAX_PLAYERS    ient devConn    lPort hydra        riables for other threads  d consoleThread  hydraThread        command codes for players  values must be in range of 241 254    const  P  P    D       a O s TD        byte PLAYERO_CONNECT   241   AYER1_CONNECT   242   AYER2 CONNECT   243   AYER3_ CONNECT   244        D                               AYERU0 DTSCONN  AAYER1_DISCONN  AAYER2_DISCONN  AAYER3_DISCONN    CT   245   CT   246   CT   247   CT   248                                         28     endregion    Salazar    OU  Gl  Gl    UPLOADING   251   FINISHED   252              SERV    x        R_SHUTDOWN   254              PLAY     D       R_INPUT_OFF   0     player s off signal       HydraServer               title and welcome messa
41. ayer gaming  However  the game itself is  very simple in nature  since the goal of this project was to achieve multiplayer capabilities through a  client server architecture  In this system  the Hydra console is connected to a server computer  Client  computers can connect to the HydraNet3 system through the following website   http   69 88 163 18 samarks Default aspx  Detailed information about the previous projects can be  found here as well  In order to play with the HydraNet3 system  the server needs to run a program that  constantly checks for incoming connection  The server is set up the server in a way that this program is  constantly running  Then  any computer connected to the Internet can visit the HydraNet3 website and  go to the HydraNet3 player link  A Java applet will open up  and the game is contained there  Then the    user can start playing along with other connected players     One of the most feasible extensions to the HydraNet3 system is to add more games  Respective links  to the new games can be placed in the HydraNet3 system   s web site  Thus  players have the opportunity  to choose from a variety of games when connecting to the HydraNet3 system  However  one has to keep    in mind that the Hydra console can run only one game at any given moment     In order to play  a user needs to go to the following website  http   69 88 163 18  samarks  Default      aspx as shown in the Figure 2 1  Then click on the link     Player page     This would take you to t
42. bControls        public partial class Developer         protected void Page_Load object sender          protected void btnUpload_Click  object s         UlL WebControls WebParts              do nothing       verify that the files exist     upldGameFile     if       System Web UI  Page  EventArgs e   nder  EventArgs e           HasFile    else exit     upldManualFile HasFile            upldiImagesFile HasFile    the method                                                   uploadStatus  ERROR  not enough files were uploaded      return         verify that the files have the correct extensions  else exit the  method  if    checkFileExt  upldGameFile FileName   eeprom         checkFileExt  upldImagesFile FileName   zip          checkFileExt  upldManualFile FileName   txt        uploadStatus  ERROR  at least one file does not have the correct  extension      return             connect to the server  TepClient conn   Stream connStrm     5309    try      conn   new TcpClient   localhost    connStrm   conn GetStream          catch  Exception        1     59    Salazar       uploadStatus   ERROR  could not connect to server      return     try          tell server that this a developer client  connStrm WriteByte  0         send notification that developer is ready to download  connStrm WriteByte  1         receive notification that server has closed other connections  if  connStrm ReadByte      2              throw new Exception               save uploaded files  if   uploadFiles     
43. be found there as well  Thus a mechanism for loading games    to the Hydra console from a remote location is already in existence     This mechanism is slightly modified in such a way  that after the client players chose a game to play   a sequence of instructions is generated to load the game into the Hydra console  After loading the    appropriate game in the Hydra console  the client player can proceed to play the game     Some Spin programs have been successfully loaded into the Hydra console  But only through the    developer tool that comes with the kit  Therefore  at least theoretically  this is possible     Some games and Spin programs have been successfully uploaded to the HydraNet web site as  shown in Figure 4 1  The respective links have been placed there as well  The new games are basically  Example 3 and Example 4  Example 3 is a spin language program that turns ON OFF the debug led in the  Hydra console  Note that in the source code  the frequency can be changed as shown in Figure 4 1  This    frequency determines the speed at which the debug LED turn ON and OFF     For Example 3  a code segment in which the user can change the frequency of the clock ticks is    shown in Figure 4 1     blinkO1         Full Source     Condensed    Summary    Document              _clkmode   xtali   pll  x   enable external clock and pll times 4  _xinfreq   10 000 000   set frequency to 10 MHZ  _stack   40   accomodate display memory and stack       7 VAR  9  long blink_stack 20 
44. ble          B getGraphicsObjxX  id   return graphicsX id        B setGraphicsObjX id  x   graphicsX  id    x       B getGraphicsObjY  id   return graphicsyY id        B setGraphicsObjY id  y   graphicsY id   y    75    Salazar    PUB getPlayerMax  return PLAYER_MAX          PUB getPlayerStatus id    temp    checks to see if the player is active  temp   1  lt  lt  id   amp  pStatus  return  temp  gt  gt  id           PUB setPlayerStatus id  active   if active      sets the player to be active          pStatus    0000_0001  lt  lt  id    pStatus  else     set the player to be inactive  if id     pStatus    1111_1110  amp  pStatus  elseif id  1   pStatus    1111_1101  amp  pStatus  elseif id  2   pStatus    1111_1011  amp  pStatus  elseif id  3   pStatus    1111_0111  amp  pStatus                      PUB getScreenSizexX  return SCREEN_SIZE_X          PUB getScreenSizeY  return SCREEN_SIZE_Y       T                PUB getScreenCenterx  return getScreenSizeXx 2                      PUB getScreenCentery  return getScreenSizeY 2          76    CON    _clkmode  times 4    _xinfreq      _ stack  stack    VAR    Appendix K  Hydra Game Example 3 Source Code  Spin       xtall   pll4x  40_000_000    40       long blink_stack 20     stack      enabl      set      accon    Vos       le external c     frequency to  nodate display memory and       10 MHZ    Salazar    Lock and pll      allocate 20 longs for the task    PLP ELIT RE LE TI LET LNA T AAA LALA IAAT TS TAAL TELAT PPS ADIT IATL EI
45. blem when a new     game is loaded some of the old images are displayed  for int i 0  i lt images length  i       images i  img flush                  notify HYDRA that player is ending session  connOut write  INPUT_OFF     connOut flush          conniIn close     connOut close     conn close      catch  IOException ex     return    catch  NullPointerException ex     return                                  receive graphics stream from HYDRA  public void run       int rec 0  id 0    boolean visible false    do     try    if   rec connIn read     lt 0     return     stream was terminated and  1 was returned           catch  IOException ex     return           swhile rec  255    while  true     try       get object s ID and visibility  if   rec connIn read    lt 0O     return     stream was terminated and  1 was returned  selse if  rec  255     continue     end byte was received  start over on next packet   else if  rec gt  240 KK rec lt  254     readCommand rec      read a command byte  continue   jelse      determine visibility  if rec  gt  gt  7  1     visible true   jelse   visible false                    49       save the id  id rec  amp  127        save the visibility  try      Salazar       id  amp  0111_1111    images  id   visible visible            catch  ArrayIndexOutOfBounds   continue              get object s x coordinate  if   rec connIn read    lt 0O     return   lse if  rec  255     continue   lse if  rec gt  241  amp  amp   readCommand  rec     continue    lse
46. cs object    repeat  if pStatus gt 0   only send if players are connected  repeat id from 0 to graphicsSize 1  if getGraphicsObjVisible  id   tempID  id    1000_0000   indicates that the object is visible  else  tempID  id         send graphics ID number and visibility  usb tx tempID          object s x coordinate  sb tx graphicsxX id      c         object s y coordinate  sb tx graphicsY id         c      send end byte indicating that the next byte    will belong to the next object  usb tx  1111_1111        PUB getGraphicsSize  return graphicsSize    PUB setGraphicsSize  size   graphicsSize  size                PUB setGraphicsObj id  visible  x  y   setGraphicsObjVisible id  visible   setGraphicsObjxX  id  x   setGraphicsObjY  id  y        PUB getGraphicsObjVisible  id   return graphicsVisible id     67    graphicsVi    PUB setGraphicsObjVisible id  visible        sible id   visible       graphicsx        graphicsy      PUB getPlaye                PUB getPlaye    checks L  temp   1  lt   return  te       PUB setPlaye  if active     sets t    PUB getGraphicsobjX  id   return graphicsX id     PUB setGraphicsObjX id  x     id    x    PUB getGraphicsObjY  id   return graphicsyY id        PUB setGraphicsObjY id  y     id    y    rMax       return PLAYER_MAX    rStatus id    temp   o see if the player is active   lt  id   amp  pStatus   mp  gt  gt  id        rStatus id  active        pStatus   else     set th   if id    pStatu  elseif i  DSL aL U  elseif i  pStatu  elseif i   DSL a
47. cture    HYDRA Game System       Application   Game Simulator   PC        Application   Game Simulator   PC     Application   Game Simulator   PC        A    y       A    Vv    A    y          Client Transport Layer Software   PC              Client Transport Layer Software   PC        Client Transport Layer Software   PC              A          A         A          Server Transport Layer Software   PC     A             A       y       Transmitter   USB Driver   HYDRA        A         A          Application   Game   HYDRA           Figure 1 9  Basic Network Layer Organization    11    Salazar    1 3 3 HydraNet 3    This  being the third HYDRA project  is yet again another extension of HydraNet 2  However  this  project was solely created by Scott Marks  In this extension  game graphics and a web interface are  introduced  It also allows developers to create games for the HydraNet system   1   The main website  consists of a player web site and a developer website  The players can play with the Hydra console  through the player   s web site  However  if one want to develop game for the Hydra console  which are  written in Spin language  The developer   s web site provides instruction on how to do so  Thus the users   or better yet  developers  can create their own games  uploaded into the Hydra console thorough the    server  and then start playing their own games     The instructions of how to upload games into the Hydra console from the Internet are as well  provided on the 
48. d to the Hydra console   Since this file has been already compiled by the Propeller Tool  it is guaranteed that the server will    successfully be able to upload that particular file into the Hydra console     Finally  another method that tries to address the issue of safety in regards to the flow of data is that  for the most part  the developers of the Hydra System have total control of the data once it has been  uploaded to the computer server hosting the Hydra console  Although this method is less significant  than the others  it is important to note that no people connected to the Hydra system can in any way  have control of the data flow  except when playing a video game  which is very secure and stable since  there are only a predetermined set of inputs  and a game has specific handlers to take care of those    inputs     22    Salazar    Section 6  References     1     HYDRA Game Development Kit     XGameStation  Video Game System Development  2011  Nurve    Networks  LLC  12 October 2011   lt  http   www xgamestation com view_product php id 33  gt      2 Marks  S  and Haberkamp  R     Programming an Interface for the HYDRA game Development Kit     April  28  2008     HYDRA Network Control and Visualization     December 15  2008  Marks  S     HYDRA    Network Control and Graphics     March 11  2009   lt  http   69 88 163 18 samarks Default aspx gt    Florida Gulf Coast University      3  LaMothe  A  Game Programming for the Propeller Powered HYDRA  2006  Nurve Network
49. dGameFileResourcel    gt               lt  p gt    lt p gt   Zipped images file   zip  lt br   gt    lt asp FileUpload ID  upldiImagesFile  runat  server   meta  resourcekey  upldImagesFileResourcel    gt            lt  p gt    lt p gt   Game manual file   txt  lt br   gt    lt asp FileUpload ID  upldManualFile  runat  server   meta  resourcekey  upldManualFileResourcel    gt         lt  p gt    lt p gt    lt asp Button ID  btnUpload  runat  server   meta  resourcekey  btnUploadResourcel   OnClick  btnUpload_Click   Text  Upload Files  CausesValidation  False    gt     nbsp   amp nbsp  lt asp Label ID  l1blUploadStatus  runat  server   meta  resourcekey  l1b1lUploadStatusResourcel   Text  upload status  Visible  False  Style  font styl  italic  color   CC0000  gt  lt  asp Label gt                                 lt  p gt    lt p gt      amp nbsp   lt  p gt    lt h2 gt   Development tutorial lt  h2 gt    lt h3 gt           Download and install the Propeller IDE lt  h3 gt    lt p gt        The files written in the Spin programming language for the HYDRA  can be edited   in a normal text editor such as Notepad or in the Propeller Tool   However  to upload the game to the HYDRA   it must first be compiled using the Propeller Tool  which can be  downloaded for   free here  lt  p gt            lt dl gt    lt dd gt    lt a href  http   www parallax com tabid 442 Default aspx   target  _blank  gt Download the  Parallax Propeller Tool Software and Propeller   Manual lt  a gt  lt  dd g
50. developer   s web site  The user just basically needs to upload a set of three files into the  system  The first  and most important one  being the executable file of the actual game to program  The  second one being the source code  and possibly a zip file containing pictures if they are used in the  game  Finally  the system requires a text file named manual to be uploaded as well  This is basically a  user   s manual that describes how to play the game  When this set of files are uploaded successfully    through the developer   s page  a message saying    success    is displayed back to the screen     1 3 4 HydraNet 4    This project is the last extension of the Hydra system  It is developed by Jinlong Fan  In this instance   the contents of the Hydra game re enriched  the characters can now move their heads and legs  and the  number of pictures is increased  thus augmenting the graphical aspects of the game  This project  dramatically improves the graphics of the older game  which is implemented in the following way  First   the computation of coordinates is computed by the Hydra console as the player   s input is received   Second  these coordinates are sent back to the server hosting the Hydra console  and the Java applet  takes these coordinates and uses them to display pictures on the screen  Thus the end user is able to see    them in their web browser     12    Salazar    Section 2  Definition of the Problem    Currently  the HydraNet3 system supports online multipl
51. e  gt  gt    x  amp  1111   lt  lt  1                               pixel value will be from 0  3  return  pixel_value           LIAL SEA LIS AELG IA IP TALS EAA ELA L SY PAA PIAL SAAS LSS AIP TALS AIT LET EAL IA LSS  ieee eas          PUB Rand   retval   random_counter     1   random_counter   random_counter  lt  lt  6    random_counter  lt  lt  2   random_counter  lt  lt  7    retval    random_counter       1    7  A    PUB NES_Read_Gamepad   nes_bits                T    7P  T     NES Game Paddle Read   LPEE LEE EECA TIAL EL VETTE A TET TILAPIA TAAL AT ATLA EEA EPL ATL EEL  LILIE     reads both gamepads in parallel encodes 8 bits for each in format     right game pad  1  15  8    left game pad  0  7  0     1               set I O ports to proper direction    91      P3   JOY CLR  4  JOY_SH LDn  5  JOY_DATAOUTO  6    P6   JOY_DATAOUTI  7    ty td  Ow  oll                                                                  NES Bit Encoding   L     RIGHT    00000001     LEFT    00000010     DOWN    00000100     UP    00001000     START    00010000     SELECT    00100000     B    01000000    A  10000000     step 1  set I Os   DIRA  3     1   output   DIRA  4     1   output   DIRA  5     0   input   DIRA  6     0   input     step 2  set clock and latch to 0  OUTA  3     0   JOY_CLK   0  OUTA  4     0   JOY_SH LDn   0   Delay  1      step 3  set latch to 1   OUTA  4     1   JOY_SH LDn   1   Delay  1      step 4  set latch to 0   OUTA  4     0   JOY_SH LDn   0                  step 5
52. e 3 colors  repeat i from 0 to 64  colors i     COLOR_3   COLOR_2   COLOR_1   COLOR 0          init tile screen  repeat dx from 0 to tv_hc   1  repeat dy from 0 to tv_vc   1   screen dy   tv_hc   dx     onscreen_buffer  gt  gt  6   dy   dx      tv_ve     dy  amp  S3F   lt  lt  10             reset game state  game_state    GAME _ STATE_INIT                             start and setup graphics  gr start  gr setup 12  12  96  96  offscreen_buffer       BEGIN GAME LOOP  TILTLILISSITSSLSSSS SSSI TITS TITS TITS TITS TITS TITS TITS TITS                      repeat    MASTER GAME STATE MACHINE  Cae Cede see ee se eeeeee lea Tee hese see cee eooreeeea                          GAME STATE_INIT    this state initializes all GAME related vas       case game_stat                                                          initialize player s ship  lander_state    OBJECT_STATE_ ALIVE  lander_x      20  lt  lt  16   lander_y     60  lt  lt  16  lander_dx    0   lander_dy    0   lander_angle    ANG_90          83             Salazar                                                                                           lander_fuel   999   num_landers   3     seed random counter   random_counter    17     initialize game state counters   game_counterl   0   game_counter2   0     set initial state to menu   game_state    GAME _STATE_MENU  GAME_STATE_START    the game is ready to start  do any   housekeeping and run    re initialize player s ship   lander_state    OBJECT_STATE_ ALIVE   lander_x 
53. e Development Kit can be bought by  199 95 at www xgamestation com     Nintendo NES P Mini Keyboard  Compatible  Game Controller       Figure 1 1 HYDRA Game Development Kit    1 1 HYDRA Game Development Kit Description    The HYDRA Game Development Kit  shown in figure 1 1  comes with everything that is needed in  order to start developing games  It includes    1  Hydra Game Console  HGC    2  PS 2 Mouse   3  PS 2 Keyboard    Salazar    128 KB Game Cartridge  Blank Experimenter Card  Mini USB cable   9V power cord    RCA A V cable    S  200   Sh Oe eh R    Nintendo compatible controller    10  CD ROM    Next  a brief description of each part included in the HYDRA Game Development Kit is given     Hydra Game Console  HGC   This is the main component of the kit  It is basically an electrical board    along with the propeller chip  This is where the games run  See Figure 1 2     PS 2 Mouse and PS 2 Keyboard  These two parts are basically a regular mouse and keyboard  They    can be used to give input to the Hydra Game system     128 KB Game Cartridge and Blank Experimenter Card  The game cartridge  or game card  can be    placed in the expansion port of the Hydra console  The game card can be preloaded with games  Initially   it is preloaded with a game called    Ball Buster     Thus  when the game card is inserted and the console is  turned on  the Hydra will boot from the game card rather than the on board serial EEPROM  If nothing is  present in the game card  then the proces
54. e Hydra console     20    Salazar    Since a TV monitor is not available in the lab  an attempt was made  using several methods  to  display the output of the Hydra console on various Pc monitors  For this reason  a RCA to VGA converter  was purchased  Unfortunately  this did not work  However  the Hydra console was connected to several  TV   s after successfully uploading Mars Landers  As a future extension  more games can be added to the    HydraNet system in a similar way     Several attempts were made to make the newly added games playable online  However  this was  impossible due to the high complexity of the drivers that would be required to send the graphics  generated in the Hydra console back to the server  For instance  most of these games use set of drivers  to send the generated graphics to the regular RCA video output  These drivers are written in the native  assembly language of the Propeller chip  and each of them is several thousands of lines of code   Although  the newly added games are not available to play online  they can be locally played on the    Hydra console using the NES compatible controller     One final aspect that is worth mentioning is that the complete source code including all the previous  reports have been reorganized  along with the new additions of this project  and placed in the C      samarks  directory on the 69 88 163 18 server     Data Analysis    Data analysis is an important aspect of this project because data is flowing all over th
55. e need of any user logging in     Now  the following are the set of steps to set up the Hydra console and start uploading other games    as well as playing  To do this  apply the following procedure   1  Connect the Hydra console to the host PC through the USB cable    2  Inthe host PC  go to C  Inetpub wwwroot smarks    24    Salazar    3  Double click on HydraServer exe  Now the Hydra server should be running and listening for    connections  A screenshot is presented in Figure A 1       ervyer l 4  Welcome to the HydraNet 3 Server     Connecting to the HYDRA     Could not connect to HYDRA  Try again   y n   y  The server is connected to the HYDRA     Server is running       Type    help    for a list of commands        Figure A 1  HydraNet server running    4  The user can type    help    and the hit enter on the command window  and some available    commands will be displayed as shown in Figure A 2        eX HydraNet 3 Serve 3   Welcome to the HydraNet 3 Server    Connecting to the HYDRA      Could not connect to HYDRA  Try again   y n   y  The server is connected to the HYDRA    Server is running          help    for a list of commands     Description    lists which players are currently connected  provides a list of commands for using the server  shuts down connections and closes the server software       25    Salazar    Figure A 2  HydraNet server help command    5  The user can then type players and hit enter to see a list of all currently connected players as    sho
56. e place in the  Hydra System  For instance consider a game developer uploading a game  In this situation  the game  developer has to upload a few files including the source code of the spin program  First  the data flows  from the end user through a network  which then arrives at the server  Then the server takes over  and  uploads the data directly into the Hydra console  Thus  it is important to make sure that the data flowing  at any particular time during the operation of the Hydra system is consistent  To address this issue  the    Hydra system uses a variety of methods     One particular and important method is that when a game developer is going to upload any game  into the Hydra console  the Hydra system checks the validity of these files by checking that they are in  the right format  For example  the system checks that the source code of the game is  spin  If the format    of the files does not coincide with the specifications and requirements  then loading such files will not    21    Salazar    be successful  Notice that in this manner  we can prevent to a certain degree malicious files such as    worms and viruses being uploaded to the server  and consequently to the hydra console     Another particular method used by the Hydra system is that any game to be uploaded has to be ina  compiled format  In other words  besides uploading the source code of a game  it is also required to  upload an object format of the game  This is actually the file that will be uploade
57. ecreate the graphics directory  Directory CreateDirectory  graphicsFolder          unzip the graphics file  using  ZipFile zip   ZipFile Read graphicsFile                   foreach  ZipEntry zipEntry in zip              unzip each file in the zip file to the graphics  folder       overwriting when necessary   zipEntry Extract  graphicsFolder                      catch  Exception                uploadStatus  ERROR  could not extract and save zipped images      return false     61       upload was successful  return true             displays the status of the upload  void uploadStatus  string message                lblUploadStatus Text   message   if  message                lblUploadStatus Visible false      else       lblUploadStatus Visible   true             verifies that the file extension is correct  bool checkFileExt  string fileName  string extension             int dot   fileName LastIndexOf        1   return fileName Substring dot  ToLower      extension ToLower        Salazar    62    Salazar    Appendix H  Game Manual Web Site  C          lt    Page Language  C   AutoEventWireup  true  CodeFile  Manual aspx cs   Inherits  Manual    gt         lt  DOCTYPE html PUBLIC     W3C  DTD XHTML 1 0 Transitional  EN    http   www w3 org TR xhtml1 DTD xhtmll1 transitional dtd  gt    lt html xmlns  http   www w3 org 1999 xhtml  gt    lt head runat  server  gt    lt title gt HydraNet 3 Game Manual lt  title gt    lt style type  text css  gt      CSS code obtained from http   users
58. else  newlmage  IMG_P3R                              change the player s image to face right  changePlayerImage  player  newlImage           PUB setTurbo player  enable    newlImag    do not update turbo if request would put turbo out of bounds  if enable  1  amp  playerTurbo player   TURBO_SIZE   enable  0  amp   playerTurbo  player              73    Salazar    return    T         set the turbo  will set 0 or TURBO_SIZE depending on enable equaling 0 or  1  playerTurbo  player    enable TURBO_SIZI    Gl       enable       determine the player s correct turbo image  newImage  playerImage player  2   else    determine the player s correct regular image  newIlmage  playerImage player  2                              change the player s image  changePlayerImage  player  newlImage           PUB changePlayerImage player  newImage    x  y      save the  x y  position of the player  x  getGraphicsObjxX  playerImage  player     y  getGraphicsObjY  playerImage  player                        remove the current player s image  setGraphicsObjVisible playerImage player   0             enable the player s new image at  x y   setGraphicsObj newImage  1  x  y          change player s stored image value  playeriImage  player    newImag             End section of code for developers    PEE EE T TATA ATTA ATA TTA AAA AAT AAT TTA AAT ATTA TATA ATA TAT AA TTT    PUB startGame      start the USB connection  usb start  31  30  0  9600    receive pin  transmit pin  mode  baud rate      start a new c
59. et1 Data Flow Diagram    In this architecture  each Hydra console is connected to an output screen  However  each of the  consoles is also connected to a PC  which is in a network  or the Internet  Thus  the PC are able to  communicate with each other and exchange information with the respective consoles  The flowchart of  this architecture is depicted in Figure 1 5  it merely describes the network layer organization of the    system  Each Hydra console assume the role of a sending and receiving clients simultaneously  In fact     Salazar    this is more similar to a peer to peer architecture  However  in code  this is implemented as a client     server architecture  A screenshot of the game is shown in Figure1 6                                                           Application   Game  HYDRA  Application   Game  HYDRA   Vv Vv  Transmitter   USB Driver  HYDRA  Transmitter   USB Driver  HYDRA   y y          Transport Layer Software  PC              _ Transport Layer Software  PC                       Figure 1 5  Flowchart of HydraNet1 System       Figure 1 6  Game ScreenShot    1 3 2 HydraNet 2    This is the second HYDRA project developed again by Scott Marks and Rick Haberkamp  The purpose  of this project was to extend the HydraNet 2 to allow multiplayer capabilities  HydraNet 2 also  incorporates a server client architecture  Each player  or client  would connect to a server over the    internet   1     Salazar    A sample screenshot of the server and client running in 
60. first block of memory is Random Access Memory   RAM   and the second block is Read Only Memory  ROM   The ROM contains an interpreter  certain  data tables  and other objects needed for the proper operation of the Propeller chip  The RAM is used to    load the user programs from the PC     128 KB EEPROM  EEPROM stands for Electrically Erasable Programmable Read Only Memory   Usually these chips store small amounts of information in a non volatile way  That is  if the power is no  longer supplied to the unit  the information or data is still saved in the unit  However  this technology  provides the advantage of being erasable and programmable  Thus the data on such units could be    updated as many times as needed  similar to a RW CD     Nintendo NES Compatible Game Ports  The Hydra console provides two Nintendo NES Compatible  Game Ports  The controls connected to these ports send the input data to the game to be processed by  the game console  The data received from the game controllers are parallel  The Hydra console also  provides an LED that indicates whether or not the game controller is plugged into the system  A typical    NES compatible control is shown in Figure 1 4         f0 0    Figure 1 4  NES Game Controller       Salazar    Mini USB Programming Port  This port is the one that allows a connection between a PC and the  Hydra console  A Mini USB cable is provided in the Game Development Kit to realize this connection   Inconveniently  this cable is only about a fo
61. for  int i   0  i  lt  MAX PLAYERS  i                if  players i   null  amp  amp  players i  active             try          players i  conn GetStream    WriteByte  message         catch  Exception                do nothing       32         Salazar       sends a byte message to the HYDRA   MethodImpl  MethodImplOptions Synchronized     void sendToHydra byte   message          try     hydra Write message  0  1       catch  Exception                do nothing    void developerUpload           Console WriteLine     Console WriteLine   Developer uploading new game                               get the developer connection stream  Stream connStrm   devConn GetStream          recieve notification that developer is starting to upload  if  connStrm ReadByte      1           Console WriteLine   Connection with developer failed      return                shut down the player threads and tell players that a new game  is being uploaded  for  int i   0  i  lt  MAX PLAYERS  i          if  players i  active     players i  thread Abort      players i  thread   null   players i  conn GetStream    WriteByte  DEV_UPLOADING                shut down HYDRA thread and serial connection  hydraThread  Suspend      hydra Close          send notification that other connections are stopped  connStrm WriteByte  2         recieve notification that developer has finished saving  uploaded files    if  connStrm ReadByte      3       Console WriteLine   Connection with developer failed      return     33  
62. g  Console Title    HydraNet 3 Server    Console WriteLine   Welcome to the HydraNet 3 Server                    connect to the HYDRA  connectToHydra          start the server     gets the computer s IP address and the port number is 5309       server   new TcpListener IPAddress Any  5309    server Start     Console WriteLine   Server is running    n          create the player objects  for  int i   0  i  lt  MAX_PLAYERS  i                players i    new Player     players i  playerNumber   i                start the command console in a new thread    consoleThread   new Thread commandConsole     consoleThread Start  1               start HYDRA communications in a new thread  hydraThread   new Thread hydraToPlayers     hydraThread Start                 variables to accept new clients  TepClient conn   Stream connStrm      while  true          accept a connection  conn   server AcceptTcpClient      connStrm   conn GetStream          try      int clientType   connStrm ReadByte  j   if  clientType    1  amp  amp  numPlayers  lt  MAX_PLAYERS                 server was not full  accept connection  connStrm WriteByte  1      29       Salazar       send client the number of images it needs to    download       connStrm WriteByte   byte  getNumGraphics              receive all clear from client that downloading is    complete  if  connStrm ReadByte      1             for  int i   0  i  lt  MAX PLAYERS  i          if   players i  active         setup player  players i  conn   conn   p
63. ground  Each player had control over one  sprite  lt  p gt                     lt p gt   View th ntire  lt a href  docs HydraNet1lReport doc  gt HydraNet 1  project report lt  a gt   entitled  amp quot Programming an Internet Interface for the HYDRA  Game Development Kit   amp quot   lt  p gt           42    Salazar     lt p gt      amp nbsp   lt  p gt    lt  div gt    lt  form gt    lt  body gt    lt  html gt     43    Salazar    Appendix D  Player Web Site  ASP NET            lt    Page Language  C   AutoEventWireup  true  CodeFile  Player aspx cs   Inherits  Player    gt      lt  DOCTYPE html PUBLIC     W3C  DTD XHTML 1 0 Transitional  EN    http    www w3 org TR xhtml1 DTD xhtmll transitional dtd  gt    lt html xmlns  http   www w3 org 1999 xhtml  gt    lt head id  Head1l  runat  server  gt    lt title gt HydraNet 3 Player lt  title gt               lt  head gt    lt body gt    lt form id  forml  runat  server  gt    lt div gt    lt hl gt   HydraNet 3 Player lt  h1 gt    lt p gt     Welcome to the HydraNet 3 Player  This page allows you to play  the currently  uploaded game on the HYDRA  lt  p gt    lt p gt   Go back to the  lt a href  Default aspx  gt main page lt  a gt  or develop a  new game on the   lt a href  Developer aspx  gt Developer page lt  a gt   lt  p gt    lt p gt   There is no need to worry about connecting and disconnecting  If  you are seeing  this page and there was an open player slot on the server  then  you are already  connected to the game  To disco
64. he  website shown in Figure 2 2  Then click anywhere inside the Java Applet  and the game will start  The    game controls to move the players are as follows     e A  Move Left    e D  Move Right    e W  Move Up    e S  Move Down    e J  Action Turbo    With these controls  each user can move their own player and have interaction with other currently    connected players     13    Salazar    HydraNet 3 Gaming Syster    eC   fF CNI 4104 Computer Netw   pb N CET       69 88 163 18 samarks Default aspx       ANGEL FGCU EagleMail Hotmail MyPage ZZ Dropbox    Java API Y Suncoast e EEG     HydraNet 3 Gaming System    CEN 4935 Senior Software Engineering Project  Spring 2009   By Scott Marks    The purpose of this project is to expand and improve HydraNet 2 in two ways  the addition of game graph  HydraNet system without a significant reduction in performance  The web interface  with the game embedc    View the entire HydraNet 3 project report entitled  HYDRA Network Control and Graphics    HydraNet 3 Player    The Player page can be used to play the current game   View the game manual  opens in new window   tab    The game controls are     A  Left  D  Right  W  Up  S  Down  J  Action    HydraNet 3 Developer    Figure 2 1  Hydra Main Web Site    14    Salazar    HydraNet 3 Player    ANGEL FGCU EagleMail Hotmail MyPage ZZ Dropbox    Java API Y Sunco       HydraNet 3 Player    Welcome to the HydraNet 3 Player  This page allows you to play the currently uploaded ga  Go back to the main
65. icsObjVisible playerImage player   0              elseif input  INPUT_FIRE    toggle the turbo  if playerTurbo  player      setTurbo player  1   else  setTurbo  player  0              71    Salazar    elseif input  INPUT_UP    move player up  pos  getGraphicsObjY  playerImage player    2 playerTurbo player    lt   getScreenSizeyY 1l  setGraphicsObjY  playerImage player   pos   checkDoor  getGraphicsObjX  playerImage player    pos                             elseif input  INPUT_DOWN    move player down  pos  getGraphicsObjY  playerImage player    2 playerTurbo player     gt  0  setGraphicsObjY  playerImage player   pos   checkDoor  getGraphicsObjX  playerImage player    pos                                elseif input  INPUT_LEFT    move player left  pos  getGraphicsOb xX  playerImage player    2 tplayerTurbo player     gt  0  setGraphicsObjxX  playerImage player   pos   setLeft  player   checkDoor  pos  getGraphicsObjY  playerImage  player                                    elseif input  INPUT_RIGHT    move player right  pos  getGraphicsOb jxX  playerImage player    2 playerTurbo player    lt   getScreenSizex l  setGraphicsObjxX  playerImage player   pos   setRight  player   checkDoor  pos  getGraphicsObjY  playerImage  player                                          End section of code for developers           111111111 111 11 11111111111111111111111111111111111111111 1 1111111    ALILIA EET VALLAL AI ALAIA IAIA ILAI TATA TTT TTT AIAI LILI d    Start section of code for devel
66. ight   fire       max number of players allowed    i ART T AE AT TE A EA ALT PA ALT T      Start section of code for developers  constant variables         backgroun  IMG_BG1   0  IMG_BG2   1    player 0  MG POL    MG_POR  MG_POLT    MG_PORT      HHHH    Ln E w         player 1  IMG_P1L    IMG_P1R    IMG_P1ILT    IMG 7    PIRT           player 2  IMG_P2L                  d images    images    images    LO CoO N    images  10    69    Salazar                         IMG_P2R   11  IMG _P2LT   12  IMG_P2RT   13     player 3 images  IMG_P3L   14  IMG_P3R   15  IMG_P3LT   16  IMG_P3RT   17     door area  DOOR_X_MIN   195  DOOR_X_MAX   225  DOOR_Y_MIN   55  DOOR_Y_MAX   95      number of extra pixels to move when turbo is on    TURBO_SIZE   2             End section of code for developers    TITTTTTTTTTTTTTT TATA    VAR    number of graphics objects within game   byte graphicsSize   byte graphicsVisible GRAPHICS_MAX    byte graphicsX GRAPHICS_MAX    byte graphicsY  GRAPHICS_MAX      byte containing bit flags for each active player   byte pStatus     stack for receiving player inputs   long receiveInputStack  100        stack for sending graphics  long sendGraphicsStack  100                111111111 1 1 1 1 11 11111111111 1 1111111111111111111111111111 1 1 1111111      Start section of code for developers  variables       turbo toggle for player movement  byte playerTurbo PLAYER_MAX        stores current player image for each player  byte playerImage PLAYER_MAX                      
67. ion       the window  PropForm          displays  public Hydra          InitializeComponent      this Activate     this Show       nsafe void DownloadToPropeller string Filename     CallingConvention Cdecl       nsafe void SetResetSignal  byte Value      CharSet Ansi   CallingConvention Cdecl     byte    CharSet CharSet Ansi   CallingConvention Cdecl       n unsafe void FinalizePropellent        38    Salazar       initializes the Propellent DLL file on startup  private void HydraPropForm_Load object sender  EventArgs e                      try        initializes Propellent dll  InitPropellent  this Handle  false  IntPtr Zero            catch  Exception                the Propellent dll file does not exist so show error  message and exit  MessageBox Show  The Propellent dll file was not found      Error    MessageBoxButtons OK  MessageBoxIcon Error     System Environment Exit  1                                   finalizes the Propellent DLL file on shut down  private void HydraPropForm_FormClosing  object sender   FormClosingEventArgs e                FinalizePropellent                gets the COM port that the HYDRA is connected to or  1 if it is  not found  public static int getHydraComPort           create and display the window  HydraPropForm hpf   new HydraPropForm          auto scan for port number  uint ver   HydraPropForm GetPropellerVersion   j              close the window  hpf Close       if  ver    0          vwer 0 when HYDRA was not found  return  l1        else
68. layers i  active   true        start player thread  players i  thread   new  Thread  playerToHydra                players i  thread Start  players i          end search for vacant player slot    break        else if  clientType    0         save the connection  devConn   conn        handle the developer s uploaded files       developerUpload        else       server is full  deny connection  connStrm WriteByte  0      connStrm Close     conn Close          catch  Exception                Console WriteLine   Error connecting client          break           region Client communications      handles communication with player clients  void playerToHydra object p               r    numPlayers       increment the number of connected players    30    Salazar    Player player    Player p        get TcpClient object from parameter             TcepClient client   player conn   Console WriteLine   Player      player playerNumber   1      connected           get stream from player client  Stream connIn   client GetStream                send message to all active players that a new player has  joined   broadcastToPlayers    byte   PLAYERO_CONNECT    player playerNumber              byte   outByte   new byte 1    byte inByte     byte to read player inputs from client  pNum    byte player playerNumber     save player number as  byte  while  true             try          if the stream is closed  stop reading from client    if   inByte    byte  connIn ReadByte     lt  0    inByte   gt  255   
69. lications since the main purpose of  this project was to achieve a communication between the two Hydra consoles  It consisted of two  sprites that moved around the screen  each controlled by one player  The purpose of the game  or    player  is to obtain control over the enemy  namely  the other player   1     Salazar    This project runs multiple threads at the same time  The game itself is a multithreaded program  which utilizes the Propeller   s multiple cores  Moreover  several communication threads were  implemented on each Hydra console  one for receiving and another for sending game state information  from and to the other Hydra console  As for the network interface of the system  which runs on the PC   four threads were required  one for reading the serial port  one sending to the serial port  one for    reading incoming game state information  and finally another for sending game state information     The setup for this multiplayer system is shown in Figure 1 4  The flow of data in this system is clearly  depicted  A Hydra console sends its game video output to a TV  It also sends and receives game state  information by communicating with the host PC  Also each host PC sends and receives each other   s    game state information through the network     Television HYDRA Game System Computer    Bo    NES Controller            f          ar   lt  Tee ar   fole  NES Controller Network Hub   Internet       y       Television HYDRA Game System Computer    Figure 1 4  HydraN
70. m easily                        MOUNTAIN SCAPE delta Y positions for cheesy mountains  Notice  the  Dn S make the landing zone   mountain_scape long 0  10 3 7  10  2 15 20 10  40  0 0  15   T0635  307  O  Dy 667  lU         landing zone data structure in format  xl  x2  y  shows up as green  on top of mars surface dirt  landing_zone long 10  8  12  8  30    95    
71. nnect  simply navigate away from  this page or  close the browser window  To attempt to reconnect or to start  over  click the  browser amp  39 s refresh button  lt  p gt    lt p gt   View the  lt a href  Manual aspx  target  _blank  gt game manual lt  a gt    opens in new  window tab    lt  p gt                 The game controls are  lt  p gt      lt 1li gt A  Left lt  li gt    lt li gt D  Right lt  li gt    lt li gt W  Up lt  li gt    lt    lt    gt              1i gt S  Down lt  li gt   li gt d  Action lt  li gt            lt i gt To play  you must first click within the screen area  lt  i gt  lt  p gt    lt p style  border  solid 1px black  width  240px   gt    lt applet code  HydraPlayer class  width  240px  height  180px  gt    lt PARAM NAME  cache_option  VALUE    lt PARAM NAME  cache_archive  VALUE    gt              44    Salazar              lt  applet gt  lt  p gt    lt p gt   If a developer uploads a new game while you are playing  simply  wait until you  receive a message stating that the new game is running  Then   refresh this web  page to start the new game  lt  p gt    lt p gt      amp nbsp   lt  p gt    lt  div gt    lt  form gt    lt  body gt    lt  html gt     45    im  im  im  im  im    im       pu    Salazar    Appendix E  Player Client Applet Source Code  Java           port java awt      port java awt event      port java io      port java net Socket    port java net UnknownHostException   port javax swing      blic class HydraPlayer extends JApplet   
72. og to read all player inputs  cognew receivelInput   receivelInputStack       start a new cog to send game state to players  cognew sendGraphics   sendGraphicsStack        PUB receivelInput   rec  player  input    repeat    receive the byte containing player number and input  rec  usb rxtime  5          get player number  last 4 bits   player  rec  amp   0000_1111      get input code  first 4 bits   input  rec  amp   1111_0000    74    Salazar      update the player s position  update  player  input     PUB sendGraphics   id  tempID    U             U             U      send info on active graphics objects    send id  x  y of each active graphics object    repeat  if pStatus gt 0   only send if players are connected  repeat id from 0 to graphicsSize 1  if getGraphicsObjVisible  id   tempID  id    1000_0000   indicates that the object is visible  else  tempID  id         send graphics ID number and visibility  usb tx tempID       object s x coordinate  usb tx graphicsX id            object s y coordinate  usb tx graphicsY  id            send end byte indicating that the next byte    will belong to the next object  usb tx  1111_1111        B getGraphicsSize  return graphicsSize    B setGraphicsSize size   graphicsSize  size    B setGraphicsObj id  visible  x  y   setGraphicsObjVisible id  visible   setGraphicsObjX  id  x   setGraphicsObjY  id  y        B getGraphicsObjVisible  id   return graphicsVisible id        B setGraphicsObjVisible id  visible   graphicsVisible id    visi
73. ol software  With the  game source visible  in the software  follow these steps  lt  p gt    lt ol gt    lt li gt Click the  amp quot View Info    amp quot  option in the   amp quot Run amp   quot    amp gt   amp quot Compile  Current  quot  menu or press F8 lt  1li gt    lt li gt Click the  amp quot Show Hex  quot  button lt  1li gt    lt li gt Click the  amp quot Save EEPROM File amp quot  button lt  li gt    lt    lt                                         li gt Pick a file name and location lt  li gt   li gt Save the file lt  li gt        Game manual lt  h3 gt        This manual is meant to teach other players how to play your  game  There are no  limitations to the game manual  other than it must be written as  a text file with  the  txt extension  No HTML coding is required for text and  paragraph spacing  however   HTML tags for bold  italics  etc  can be used  lt  p gt    lt p gt    amp nbsp   lt  p gt            lt  div gt     lt  form gt    lt  body gt    lt  html gt     58    Ce GG See Ghat GP SS SG eG Cea G       si  si  si  si  si  si  si  si  si  si  si  si  si    Ng  Ng  Ng  Ng  ng  ng  ng  ng  ng  ng  ng  ng       ng    System  System  System  System    System     System  System  System  System    System     System  System  Tonic        Salazar    Appendix G  Developer Client Source Code  C       Collections    Configuration     Data     IO     Net     Web    Web    Web   Web    Web    Web     Zip       Sockets    U   Security    Wile  UL HtmlControls   UlL We
74. opers  developer defined methods          PUB checkDoor  x  y    i  if x gt DOOR_X_MIN and x lt DOOR_X_MAX and y gt DOOR_Y_MIN and y lt DOOR_Y_MAX    toggle background 2  if getGraphicsObjVisible  IMG_BG2      setGraphicsObjVisible IMG_BG2  1   else  setGraphicsObjVisible IMG_BG2  0        set all players to center of screen and face them left   repeat i from 0 to PLAYER_MAX 1   if getPlayerStatus  1      setGraphicsObj playerImage i   1  getScreenCenterxX  getScreenCenterY   setLeft  i              PUB setLeft  player    turbo  newlImage    save the turbo status of the player  turbo  playerTurbo player   2       determine the correct new image    72    Salazar    if player    if turbo    newlmage  IMG_POLT  else  newIlmage  IMG_POL  elseif player  1  if turbo    newImage  IMG_P1LT  else  newImage  IMG_P1L  elseif player  2  f turbo    newImage  IMG_P2LT  else  newlmage  IMG_P2L  elseif player  3  if turbo    newlmage  IMG_P3LT  else  newIlmage  IMG_P3L                           change the player s image to face left  changePlayerImage  player  newlImage        PUB setRight  player    turbo  newImage    save the turbo status of the player  turbo  playerTurbo player   2       determine the correct new image  if player     if turbo    newImage  IMG_PORT  else  newImage  IMG_POR  elseif player  1  f turbo    newIlmage  IMG_P1RT  else  newImage  IMG_P1R  elseif player  2  if turbo    newlmage  IMG_P2RT  else  newlmage  IMG_P2R  elseif player  3   if turbo    newIlmage  IMG_P3RT  
75. ot long  However  this type of cable is common  and if    needed  one can find longer Mini USB cables at local stores     1 3 HydraNet Overview    Having described the HYDRA Game Developer Kit  we next present an overview of the previous  projects on the Hydra system  There are in existence three previous HYDRA projects  Thus before a  description of the current project is given  a brief explanation of the accomplishments of the previous    projects is summarized next     At this point and due to the numerous extensions already made on the HydraNet project  it is  difficult to have a concrete problem definition  Nevertheless  some ideas as presented next  but before  we overview the previous projects  HydraNet 1  HydraNet 2  and HydraNet 3  HydraNet 1 is the first  project using the HYDRA console  HydraNet 2 is extension of HydraNet 1  Finally  HydraNet 3 is yet    another extension of HydraNet 2     1 3 1 HydraNet 1    This is the first project on the HYDRA Game Development Kit developed by Scott Marks and Rick  Haberkamp  2   The goal of HydraNet 1 was to develop a game for two players  Each player would play  on its own HYDRA console  and the communication between the HYDRA consoles would be  implemented through a network  or the Internet  HydraNet1 consisted on two main components  The  Hydra game and the computer program realizing the network interface through which the Hydra    consoles would communicate     The game was very simple in nature  This allowed avoiding comp
76. passed  the total number of graphics object within the game  After  calling this method   any initial graphics visibility or positioning should be  handled  lt  1li gt    lt li gt  lt span class  stylel  gt Update method lt  span gt   This section of  code is where the game  occurs  Each time a player sends a game key press  this  update method will be called  to take the appropriate actions for the game to  progress  lt  li gt    lt li gt  lt span class  stylel  gt Other methods lt  span gt   This section is  simply a placeholder  for any additional methods you wish to include  lt  li gt                  lt  ul gt    lt p gt   Of course  the game requires much more code to operate  but these  are the only sections  that are needed for developing a new game  While the other cod  can be revised   deleted or added to  it is strongly discouraged since most of  this code allows the  HYDRA to communicate properly with the server and player  components of the HydraNet  3 system  lt  p gt    lt p gt   Please note that while the server and player applications show  that the players          57    Salazar       are numbered 1 4  they are actually numbered 0 3 within the HYDRA  game template   For example  Player 1 on the server and player client corresponds  with Player 0  in the game code  lt  p gt    lt h3 gt   Compile the game sources lt  h3 gt    lt p gt   Before uploading your game to the HydraNet 3 system  you need to  compile the game  into an EEPROM file using the Propeller To
77. s  LLC      4     Propellent Library     Propellent  Library and Executable   2008  Parallax  Inc  8 Oct 2008    lt http   www parallax com tabid 442 Default aspx gt       5     XGameStation Pico Edition Kit 2 0     XGameStation  Video Game System Development  2008  Nurve    Networks  LLC  13 Oct 2008   lt http   www xgamestation com view_product php id 34 gt       6  Fan  J     Hydra Network Control and Graphics     April 30  2010  Florida Gulf Coast University     23    Salazar    Appendix A  User Manual    First  we describe the steps to set up the server so that the Hydra server runs at system startup  In  this manner  there does not have to be a user logged in order to run the Hydra server  Rather the    computer does this in the background  These steps are described next   1  Open notepad and write the following line  C  Inetpub wwwroot smarks HydraServer exe  2  Save this file as a  bat file    3  Place this file on the following directory     C  Windows System32 GroupPolicy Machine Scripts Startup  4  Click on start gt run and type in    gpedit msc     5  On the window that opens up  Go to Windows Settings  6  Double click on Scripts Startup Shutdown   7  Double click on Startup  8  Click on Add     9  Click on Browse     10  Now go to the directory where you have previously saved the  bat file and select it  11  Click on open  and click ok two consecutive times    Now  every time the server is turned on  the HydraServer exe is executed on the background    without th
78. sor boots up from its main memory  The blank experimenter    card allows to expand the functionality of the Hydra console  and works in a similar manner   Mini USB cable  This cable is used to connect the Hydra console to a computer   9V power cord  This cable is used to connect the Hydra console to a power outlet   RCA A V cable  This cable is used to connect the Hydra console to a compatible TV     Nintendo compatible controller  These controllers are basically the same as the old NES controllers     They provide the player with a device to set input to the Hydra system     CD ROM  This CD contains some developing tools such as the Propeller Tool used to develop    programs for the Propeller chip     Having discussed the HYDRA kit package contents  we proceed to briefly explain the HYDRA    hardware     Salazar           3 3 5 0V Supplies VGA Port RCA Video Connector      Composite NTSC PAL Compatible    Fa    128K EEPROM RCA Audio Connector                Z RJ 11 Networking Port    Propeller Full Duplex 1 5Mbit    Chip    USB2SER Network Noise  Compatible Filter  Programming  Port oN Game Cartridge  Port  Mini USB        Programming Port    PS 2 Keyboard Port    PS 2 Mouse Port    Nintendo NES  Compatible Game Port                                                                                                                      Cog 4 Cog 5 Cog 6 Cog7  I   Pin Directions  D D I I D D   D D I D D l Pin Outputs  27182   TD TD  CAD CPi   C23  OS   L D 1 EE CPZ   K m 5 5 PHE 
79. st draw thruster  if    lander_fuel  gt  0  and  nes_buttons K NES_B  and  Rand K   01       gr colorwidth  2  0    gr plot  lander_wp_x  lander_wp_y    gr line lander_wp_x    last_cos   gt  8   lander_wp_y     last_sin   gt  8                  now ship  gr colorwidth  3 0     88    gr vec  lander_wp_x    lander_model    1                              lander_wp_y     draw players ships left        0020     Salazar    lander_angle                                                                                                                                                           gr colorwidth  3  0   repeat i from 0 to num_landers 1l  gr vec  LANDERS_X_POS   i  lt  lt  3   4  LANDERS_Y_POS   4   0012    2000  gt  gt  2   lander_model     test if state changed to GAME_STATE_CRASHED  if  game_state    GAME_STATE_CRASHED     print out crash  gr textmode  3 1  6 5   gr colorwidth  2 0     used up a player  if  num_landers    1   gr text  4 0   over_string   game_state    GAME_STATE_OVER  else  num_landers         gr text  4 0  crash_string     check if landed  if  game_state    GAME_STATE_LANDED     print out crash  gr textmode  3 1 6 5   gr colorwidth  2 0   gr text  4 0  landed_string    copy bitmap to display  we have to do this here to make sure  to see the last text rendered into the buffer  gr copy  onscreen_buffer   if  game_state    GAME_STATE_CRASHED     stall the event loop  normally you wouldn t want to do  this  but in this case its ok since    we are trying to keep
80. t     lt  dl gt     lt p gt     During the install  you will be given an option to also install a  virtual COM port    54    Salazar             driver for use with the HYDRA console  This driver isn amp  39 t  necessary unless you  have access to a HYDRA console  lt  p gt            lt p gt   The Propeller Manual can also be downloaded directly from that  page  but it is normally  included with the Propeller Tool software under the   amp quot Help   amp quot  menu  lt  p gt         lt h3 gt   Propeller amp  39 s Spin language lt  h3 gt    lt p gt   Games for the HYDRA  or more specifically Parallax amp  39 s  Propeller microcontroller   can be written in Spin  Propeller Assembly or both  Spin is an  object oriented language  Similar to C   with some unique characteristics   Tool software download  includes a manual for programming the Propeller   be accessed from  the Propeller Tool via the  amp quot Help amp quot  menu or directly from  Parallax amp  39 s  Propeller download page  see link above    lt  p gt    lt h3 gt   Source code template and two example games lt  h3 gt    lt p gt   Two source files are required to operate a game on the HydraNet 3  system  lt  p gt                     The Propeller          This manual can                       lt ul gt            lt li gt  lt a href  game_examples game template spin  gt Game source   template lt  a gt  lt  li gt     lt li gt  lt a href  game_examples FullDuplexSerial spin  gt HYDRA USB  driver lt  a gt      Parallax    
81. t     pixel_value    1       7                      color     I II       PUB Plot_Pixel2 x  y  video_buffer   video_offset  pixel_value     plot pixel calculation using LONG aligned  12x12 tiles    video_offset      read pixel group  pixel    _value         ma    ue       pixel      OR    _val    sk AND out target bi    ec    rrom memory    long    ts   ue K       pixel_val    color with pixel value                _value       pixel            pixel_value              write pixel back to memory     video_buffer  gt  gt  2     so col      11     col       x  gt  gt     0   video_offset     or mixing   lt  lt    x  amp              or  lt  lt       x  amp     calcs       4           1    192x192 bitmap     92    y    doesn t occur     1111                2111    fo             1      lt  lt  1       lt  lt  1      90    Salazar    long 0   video_offset     pixel_value    1    AEP ATLET L EEE EEE E TALL  7P       PUB Get_Pixel2 x  y  video_buffer    video_offset   pixel_value    get pixel calculation using LONG aligned calcs 192x192 bitmap   12x12 tiles  video_offset     video_buffer  gt  gt  2     x  gt  gt  4     192    y                              read pixel group from memory  16 pixels  32 bits   pixel_value    long 0   video_offset          mask AND out target bits to extract bits in question  pixel_value    pixel_value  amp    11  lt  lt    x  amp   1111   lt  lt  1                 now shift bits back to right and return pixel value from screen  pixel_value    pixel_valu
82. t    lt h3 gt   HydraNet 2 lt  h3 gt    lt h4 gt   CNT 4104 Computer Network Programming  Fall 2008  lt br   gt   By Scott Marks and Richard Haberkamp lt  h4 gt    lt p gt   The purpose of this project was to develop a multiplayer network  game using a  Single HYDRA  The players would connect to a PC server via player  software on  their computer  The players would send game inputs via the  keyboard and the game  screen would be displayed in the player software  The game  followed the same  format from HydraNet 1  but with two minor differences  First   the player  sprites were simply numbers 1 4  indicating each player amp  39 s  number  instead of  ghost like figures  Second  the maximum number of concurrent  players was  increased from two to four  lt  p gt    lt p gt   View th ntire  lt a href  docs HydraNet2Report doc  gt HydraNet 2  project report lt  a gt   entitled  amp quot HYDRA Network Control and Visualization   amp quot   lt  p gt    lt h3 gt   HydraNet 1 lt  h3 gt    lt h4 gt                 CEN 3213 Embedded Systems Programming  Spring 2008  lt br   gt   By Scott Marks and Richard Haberkamp lt  h4 gt    lt p gt   The purpose of this project was to develop a two player HYDRA  game that could be  played using two HYDRAsS connected over a network or the Internet   A computer  program  which would act as either the server or client  handled  the relaying of  game state between HYDRAs  The game was very basic and included  two sprites that  moved around a black back
83. t to run in the Hydra console     The games would have to be modified in such a way that the input always comes from the client  players computers  which are of course in remote locations  Moreover  the output of the Hydra console    would have to be redirected at each client   s computer through the Java applet     Since for each game  we need four files  the respective links are added to the main web site as  shown in Figure 3 1  The first file is the compiled executable file with the  eeprom extension  The second  file is the source code in  txt format  The third file is just a dummy  zip file  Finally  the fourth file is a user    manual in a  txt extension     16    Salazar       Example 1 shows how to get 4 players to move about a static background   9 C ame  o Source code     Images  zipped   o Manual     Example 2 shows how to get 4 players to move between two backgrounds and how to get the player images to change based on movement and turbo state      Compiled game  o Source code     Images  zipped      Nanna  Example 3 is a sample program that turns ON OFF the debug led in the HYDRA console  o Compiled game     Source code     Images  zipped   o Manual  Example 4 is an classical game         o   ed e       Source code  o Images  zipped   o Manual    Figure 3 1  Links to New Games    17    Salazar    Section 4  Implementation    The HydraNet3 system allows developers to develop and upload games to the Hydra console via its  web site  Instructions of how to do so can 
84. this system is shown in Figure 1 7  As one  can see in the picture  the server  top part  displays an IP address  and chooses a port number to which  it listens for clients trying to connect  The server runs in an infinite while loop  waiting for players to  connect  On the other hand  in the client side  the users inputs the IP address and the port number and  hits enter  Then the connection is established  The architecture of this system is shown in Figure 1 8  As  one can see  several clients can connect to the server PC to which the Hydra console is connected  Thus   this server runs as an interface between the players on the network and the Hydra console  Also  the    network layer organization for this system is shown in Figure 1 9     re you a server  O gt  or a client  1   Enter O or 1      IP Address  192 168 6 1065   hoose port  12345   he server is waiting for the client to connect   onnect to Hydra on COM  3   he serial port is open  Please start the HYDRA            nter a command     O C  Documents and Settings  Jessica Desktop HydraNet HydraNet      of x      re you a server  O  or a client  1   Enter   or 1  1  onnect to cdi 192 168 080 105          onnect to Hydra on COM   he serial port is open  Please start the HYDRA     nter a command  _    Figure 1 7  HydraNet Server  top  and Client  bottom     10    Computer   Client    Computer   Client    Salazar    Computer   Client       Network Hub   Internet       Computer   Server    Figure 1 8  HydraNet2 Archite
85. uires a  zip file when the developer is trying to upload a game into the  Hydra console  Since the new games do not use pictures as a way of generating graphics  the  zip    dummy files are available for download        Example 3 is a sample program that turns ON OFF the debug led in the HYDRA console  Compiled game  Source code  Images  zipped   o Manual       Example 4 is an classical game    Compiled game  Source code  Images  zipped   Manual       Figure 5 1  Respective links to new games    For testing purposes  a special program was created  This program is located under Example 3  The  purpose of this program is to turn ON OFF the debug LED in the Hydra console  With this program  one  can test whether or not games can be successfully loaded into the Hydra console  For instance  if we  load this program successfully  the debug LED of the Hydra console should immediately start blinking at  the frequency set in the source code  Loading this program has been done on several occasions and  from different computers on different networks  This implies that all the games loaded in this manner    are successfully uploaded into the Hydra console     In any case  Example 4  which is a real game  in fact  it is the classical game Mars Landers   have  been successfully loaded several times  Nevertheless  this game does not use pictures to generate game  graphics and thus the output is not sent back to the Java applet  Rather  the output is sent to the regular    video output of th
86. wn in the Figure A 3        c  HydraNet 3 Server l    Connecting to the HYDRA     Could not connect to HYDRA  Try again   y n   y  The server is connected to the HYDRA     Server is running          help    for a list of commands     Description    lists which players are currently connected  provides a list of commands for using the server  shuts down connections and closes the server software    players    Players connected     disconnected  disconnected  disconnected  disconnected       Figure A 3  HydraNet server players command    6  Toclose the server  just type    exit    and then hit enter    7  After the server is running and listening to connections  go to the following website     http   69 88 163 18 samarks Default aspx     8  To play the currently loaded game in the Hydra console  click on the player page link  which    would take you to the following web site  http   69 88 163 18 samarks Player aspx     9  Once in this website click inside the Java applet  Then the game will start as shown in Figure A 4     26    Salazar    View the game manual  opens in new window   tab    The game controls are     e A  Left  s D  Right  s W  Up  s S  Down  e J  Action    To play  you must first click within the screen area       Figure A 4  Java applet containing a game    27       GAG  G S AG OG Ge  IGG    si  si  si  si  si  si  si  si  si  si    Ng  Ng  ng  ng  ng  ng  ng  ng  ng  ng       System   System  System  System  System  System   System   System  System       Salaz
87. y Scott Marks lt  h3 gt    lt p gt   The purpose of this project is to expand and improve HydraNet 2  in two ways   the addition of game graphics and a web interface  Developers now  have the  ability to create high color game graphics for the HydraNet  system without a significant  reduction in performance  The web interface  with the game  embedded as a Java  applet  allows for a better user experience  both to players and  developers  alike  lt  p gt    lt p gt        View th ntire  lt a href  docs HydraNet3Report  doc  gt HydraNet 3  project report lt  a gt   entitled  amp quot  HYDRA Network Control and Graphics   amp quot  lt  p gt    lt h3 gt   HydraNet 3 Player lt  h3 gt    lt p gt   The  lt a href  Player aspx  gt Player page lt  a gt  can be used to play the  current game  lt  p gt    lt p gt   View the  lt a href  Manual aspx  target  _blank  gt game manual lt  a gt    opens in new  window tab    lt  p gt    lt p gt   The game controls are  lt  p gt    lt ul gt    lt li gt A  Left lt  li gt    lt li gt D  Right lt  li gt    lt li gt W  Up lt  li gt    lt    lt    gt              1i gt S  Down lt  1li gt   li gt d  Action lt  li gt        41    Salazar     lt h3 gt   HydraNet 3 Developer lt  h3 gt    lt p gt   The  lt a href  Developer aspx  gt Developer page lt  a gt  can be used to  create and upload  your own games  This page also includes a tutorial on how to  develop a game  lt  p gt            lt p gt    amp nbsp   lt  p gt    lt h2 gt   Past projects lt  h2 g
88. yMessage   Player  break    case PLAYER2 DISCONNECT   displayMessage   Player  break    case PLAYER3_ DISCONNECT   displayMessage   Player  break    case DEV_UPLOADING                       con    con          con    disco    disco    disco    disco    nected       nec    n    n    n          tru  nected     tru  ted    tru    nected       nected       nected          nected       tru    tru    tru       tru    displayMessage   Game stopped by developer     numImages 0     break        case DEV_FINISHED                                                                                               fa    Salazar    lse       set number of images to 0 to c        Lear game screen    displayMessage  Refresh the page to start new game    false    stop       disconnect from server  break   case SERVER_SHUTDOWN   displayMessage  The server was shut down normally    false    stop       disconnect from server  break      required for KeyListener but not used  lic void keyPressed KeyEvent arg0      lic void keyReleased KeyEvent arg0O   L  required for KeyListener  sends game inputs to HYDRA  lic void keyTyped KeyEvent ke     try   switch  Character toUpperCase  ke getKeyChar         case  A    connOut write  INPUT_LEFT     break   case  D      connOut write  INPUT_RIGHT     break   case  W    connOut write  INPUT_UP    break   casen Sts  connOut write  INPUT_DOWN     break   case  J      51    Salazar       GI   lt         connOut write INPUT_FIR  break   default   break       catch  IO
89. ze 5       position the background  setGraphicsObj IMG_BACKGROUND  1  getScreenCenterX  getScreenCenterY                End section of code for developers        EEE EEE EEE EEE EE EEE EEE EL EEE EEE LEE EEE      start the game  startGame    PUB update  player  input    playerImg      AE ELT A EET T E TAE T A LEI tAd       Start section of code for developers  update method          playerImg  getPlayerGraphicObj  player        if input  INPUT_ON    set the player as active  setPlayerStatus  player  1   setGraphicsObj playeriImg  1  getScreenCenterxX  getScreenCenterY   playerTurbo player    0  elseif input  INPUT_OFF    set the player as inactive             65    setPlayerStatus      setGraphicsObjVisible playerImg   f input  INPU  toggle the turbo  playerTurbo  p     elsei    1  if    player   else  playerl  elsel    Turbo  pl       Turbo  pl          move player    setGraphicsObjy      ge    elseif input  INPU 1      move player  setGraphicsObjY     2         elseif input  INPUT_    le  X   2    move player  setGraphicsObj         elseif input  INPUT      ri  X    ge  ge    move player  setGraphicsObj       layer    layer    input  INPUT_UP  up    getGraphicsObjY  playeriImg   2 playerTurbo player       Salazar    player  0     0           D     LRE       layer    0   2    U    playerimg         lt    tScreenSizeyY   L DOWN    down    playeriImg  getGraphicsObjY  playeriImg     tplayerTurbo player     gt  0   LEFT          Et   playeriImg  getGraphicsObjxX  playeriImg    
    
Download Pdf Manuals
 
 
    
Related Search
    
Related Contents
Sandberg LUX-LINE, S-Video M-M 1.8 m  Casio CP-88 Thermal CD Printer  Aquanova  Datenblatt_EN  TABLE OF CONTENTS  DS20424 (U.S.A.) - Schematics Forum  dreamGEAR DGWII-2813 game console accessory    Foundation Fieldbus H1 - Services  正誤表    Copyright © All rights reserved. 
   Failed to retrieve file