Shop OBEX P1 Docs P2 Docs Learn Events
Converting HYDRA specific programs to other boards — Parallax Forums

Converting HYDRA specific programs to other boards

Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
edited 2007-04-20 23:41 in Propeller 1
This thread is started for those that are considering buying the HYDRA or just the HYDRA book, this thread will give hints how to convert programs that are on the hydra CD and in the text to make sure they work on other propeller based boards.

Some guidelines:

If you are posting a how-to conversion of HydraCD programs, please do not post the entire .spin code as these are copyrighted works. Instead post the 2-5 lines that need to be addressed, or areas where code needs to be added.

This would be a good thread to discuss the differences in pin configuration between Hydra and other propeller products.

Thanks to Andre for encouraging this thread and discussion.

Oldbitcollector

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -Albert Einstein

Comments

  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-04-18 02:22
    Assuming you have the Hydra gaming book, there are several demos that demonstrate the propeller/hydra's basic graphics ability.
    (These are before the discussion of the HEL driver)

    They can be altered slightly to make them run on other propeller-based boards.

    Make the following changes: (Example /sources/hydra/screen_saver_10)

    Near the top of the file: [noparse][[/noparse]clock settings]

    Change:
      _clkmode = xtal2 + pll8x            ' enable external clock and pll times 4
      _xinfreq = 10_000_000 + 0000        ' set frequency to 10 MHZ plus some error
    
    



    to

      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
    




    Now, look a little further in OBJ section.
    (Use the graphics.spin & tv.spin from the Propeller Library)

    Change
      tv    : "tv_drv_010.spin"          ' instantiate a tv object
      gr    : "graphics_drv_010.spin"    ' instantiate a graphics object
    
    



    to

      tv    : "tv"        ' instantiate a tv object
      gr    : "graphics"  ' instantiate a graphics object
    
    




    Now scroll down the nealy the bottom of the file and look for this:
    (Change video pins)

    Change:
    tvparams                long    0               'status
                            long    1               'enable
                            long    %011_0000       'pins
    
    



    to

    tvparams                long    0               'status
                            long    1               'enable
                            long    %001_0101       'pins
    
    




    These changes can be done to several of the demos in the introduction to the "graphics" driver

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -Albert Einstein
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-04-18 04:36
    [noparse][[/noparse]NOTE: Not coming from an expert! I'm still learning how this does what this does and why!]

    If you want to play with the HEL_GFX_ENGINE* files, I've found the following changes get things up and running,
    and makes the /sources/hydra/pacman_tile_demo* a lot more interesting. [noparse]:)[/noparse]

    Open HEL_GFX_ENGINE_040 (Used in /sources/hydra/pacman_tile_demo_005)

    Find in the CON section
     VIDEO_PINMASK    = %0000_0111    
     VIDEO_PINGROUP   = 3             
     VIDEO_SETUP      = %0_10_1_01_000
     VIDEO_CNTR_SETUP = %00001_111    
    
    



    Change it to:
    VIDEO_PINMASK    = %0111_0000 
    VIDEO_PINGROUP   = 5          
    VIDEO_SETUP      = %1111_1100 
    VIDEO_CNTR_SETUP = %00001_111 
    
    




    Find (near the bottom) (Thank you Andre!)
    tvport_mask    long      %0000_0111 << 24   
    
    



    Change it to:
    tvport_mask    long      %0000_0111 << 12   
    
    




    (Proof that a million monkeys with a million propeller chips *could* write Shakespeare!)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The comments and code above are proof that a million monkeys with a million propeller chips *could* write Shakespeare!

    Post Edited (Oldbitcollector) : 4/19/2007 2:31:15 AM GMT
  • fred2fred2 Posts: 47
    edited 2007-04-18 22:00
    This is a superb idea!

    I find the DEMO board more instructive at the moment and it is wonderful that all those

    HYDRA programs can be ported over -- or at least many of them.



    I have a problem with the HEL conversion listed, the suggested change of VIDEO_SETUP

    to a new value has 9 bits instead of 8 -- discovered after I tried running it.· Could be

    the problem???



    Fred2
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-04-19 02:31
    Ouch! Thats what I get for doing this late at night.. (I'm EST BTW)

    I've correctly the entry, and it *should* work correctly now. <fingers-crossed>

    Oldbitcollector

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The comments and code above are proof that a million monkeys with a million propeller chips *could* write Shakespeare!
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-04-19 02:41
    One of the most impressive demos on the Hydra book/CD is the Xracer Game, A 3d driving game which demonstrates
    clean crisp multicolor sprites as well as music. I have this running using my Atari Joystick (on the VGA header) but I'm still working on cleaning up my joystick code. Anyway, here are some simple changes to get the graphics & sound up and running.

    /sources/hydra/JTC_Xracer_010

    Inital changes are very much like the first demo in this thread...

    Change the clock settings to:

    CON                           
                                  
      _clkmode = xtal1 + pll16x   
      _xinfreq = 5_000_000 
    
    



    and the tvparms (pins) to (near the bottom of JTC_Xracer_010.spin)

    tvparams                long    0               'status  
                            long    1               'enable  
                            long    %001_0101       'pins    
    
    



    For sound look for the following:

      'start sound driver
      snd.start(7)
    
    



    and change the 7 to a 10

    This should get it up and on the screen. More later on controls..

    Oldbitcollector

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The comments and code above are proof that a million monkeys with a million propeller chips *could* write Shakespeare!
  • fred2fred2 Posts: 47
    edited 2007-04-19 09:24
    Modifications worked fine -- got a beautiful picture from the DEMO board. No joystick control
    of course but it is neat just showing the static scene!

    Had to do some searching through the code, but it is a fabulous program -- could be studied
    for weeks....

    fred2
  • AndreLAndreL Posts: 1,004
    edited 2007-04-19 21:52
    Yup, took months to make. Lots to learn by studying it.

    Andre'
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-04-20 04:07
    Time for some joystick controls! Virtual Hydra NES controls. Version 1.0

    One bit thing that the Hydra has over us Demo/Proto users is those nice NES ports built in.
    Here's our chance to "come up to the Jones"

    This file contains a drop-in snippet of code for those Hydra demos which use a PUB section
    for reading the NES controls as well as a replacement gamepad_drv_001 for those that call
    on it.

    I've tested the snippet on the Xracer demo, the fire button alternates between START/SELECT
    so it works with the button limitation. The additional gamepad_drv_001 has been tested with
    the pacman tile demo and seems to work perfectly.

    It's a little building, but for less than $10 worth of parts, in an hour you'll have game controls.

    Let me know about bugs when you find them. [noparse]:)[/noparse]

    Oldbitcollector

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The comments and code above are proof that a million monkeys with a million propeller chips *could* write Shakespeare!

    Post Edited (Oldbitcollector) : 4/20/2007 5:11:27 AM GMT
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-04-20 05:19
    Ok, got that Atari Joystick adapter working? Time for some Hydris.

    /sources/hydra/RB_Tetis_010.spin

    There are several things to do here, so take your time and knock them out one by one.

    First as always, convert the clock settings in CON to:

      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000  
    
    



    Drop down to OBJ and adjust them to use the Propeller Library items, as well as Mike Green's comboKeyboard Driver.

      tv    : "tv"          ' instantiate a tv object
      gr    : "graphics"    ' instantiate a graphics object
      key   : "comboKeyboard"    ' instantiate a keyboard object
      'mouse : "mouse_iso_010.spin"      ' instantiate a mouse object
    
    



    Next dig out the key.start(3) and change it to: (It's in PUB start)
      key.start(26)   
    
    



    [noparse][[/noparse]Note the remerked mouse driver Hmm..]

    Just when I thought I had Andre figured out on the NES controller thing,
    I discover some of the code was only written for a single NES controller.
    No worries, this one works fine.

    Here's a replacement PUB that works well..
    PUB NES_Read_Gamepad : nes_bits   |       i
    
    'This is intended as a replacement for code which contain
    'an embedded NES_Read_Gamepad function.  Simple overwrite
    'the entire 'PUB NES_Read_Gamepad' with the contents of this file.
    
    'Adjust remarked entries as required.
    'This is designed for the adapter: 'atari_vga_schematic.jpg"
    
      if ina[noparse][[/noparse]16] == 1 'Read Fire alternate between Select & Start
         nes_bits := %00010000
    
      if ina[noparse][[/noparse]17] == 1 'Read RIGHT show as NES_DPAD Right
         nes_bits := %00000001
    
      if ina[noparse][[/noparse]19] == 1 'Read LEFT  show as NES0_DPAD Left
         nes_bits := %00000010
    
    '  if ina[noparse][[/noparse]21] == 1 'Read DOWN  show as NES0_B button
    '     nes_bits := %01000000
    
      if ina[noparse][[/noparse]21] == 1 'Read Down  show as NES0_DPAD down
         nes_bits := %00000100 
    
      if ina[noparse][[/noparse]23] == 1 'Read UP    show as NES0_A button
         nes_bits := %10000000
    
    '  if ina[noparse][[/noparse]23] == 1 'Read UP    show as NES0_DPAD up
    '     nes_bits := %00001000 
    nes_bits := (nes_bits & $FFFF)
    
    



    One more thing to change, tvparms...

    tvparams                long    0               'status
                            long    1               'enable
                            long    %001_0101       'pins
                            long    %0000           'mode
                            long    0               'screen
                            long    0               'colors
                            long    x_tiles         'hc
                            long    y_tiles         'vc
                            long    10              'hx timing stretch
                            long    1               'vx
                            long    0               'ho
                            long    0               'vo
                            long    0      'broadcast on channel 2 VHF, each channel is 6 MHZ above the previous
                            long    0               'auralcog
    
    



    Controls, joystick L/R to select level, button to start. L/R, UP=rotate, DOWN

    There is keyboard and sound support, but for some reason I haven't gotten them right yet.,. more later

    Oldbitcollector

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The comments and code above are proof that a million monkeys with a million propeller chips *could* write Shakespeare!

    Post Edited (Oldbitcollector) : 4/20/2007 6:19:40 AM GMT
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-04-20 06:29
    Hydris Keyboard Support.....


    Ok, so you didn't build yourself an Atari Joystick Adapter yet.. Here's some additional code to get the keyboard working.

    Look for this section:

      ' Keyboard (mapped onto NES buttons)
        if(key.keystate($C2))
          nes_buttons|=NES_UP
        if(key.keystate($C3))
          nes_buttons|=NES_DOWN
        if(key.keystate($C0))
          nes_buttons|=NES_LEFT
        if(key.keystate($C1))
          nes_buttons|=NES_RIGHT
    
    



    Add the following two controls...

        if(key.keystate($0D))
          nes_buttons|=NES_START
        if(key.keystate($20))
          nes_buttons|=NES_A
    
    



    Right/Left Cursor = Select Level, Enter to start, SPACE to rotate.

    Enjoy
    Oldbitcollector

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The comments and code above are proof that a million monkeys with a million propeller chips *could* write Shakespeare!
  • JT CookJT Cook Posts: 487
    edited 2007-04-20 23:41
    One thing you might want to try for X-Racer is to control the gas and brake with the fire button. So if you hold down the fire button it will act as gas, and if you release it, it will act as brake. I remember playing a lot racing games on the C64 and I was never fond of the up for gas and down for brake (at least not after I got my NES). smile.gif
  • laurent974laurent974 Posts: 77
    edited 2017-03-28 19:17
    resurrecting an old thread from the grave, is anyone has tried to port that hydra game to VGA? i failed to adapt those tv params to their VGA counterpart. I wish to try pacman on my PropBoe
  • If you have the source code for the pacman game, you may just be able to substitute the obj for the vga port for the obj for the tv port.
    Jim
  • i wish that would be simple as you said, but the code relies on HEL_GFX_Engine. Porting this engine to VGA is really out of my reach.

    it's sad because these source codes are really a marvel to read, but no more hardware supports that.
Sign In or Register to comment.