Shop OBEX P1 Docs P2 Docs Learn Events
PROJECT: Battlez0wned — Parallax Forums

PROJECT: Battlez0wned

mparkmpark Posts: 1,305
edited 2008-12-14 19:40 in Propeller 1
Here's the source for Battlez0wned. Most of it was thrown together in a week, so as you might imagine it needs improvement in several areas. However, being the kind of person I am (i.e., lazy, short attention span) I doubt I'll do much more work on it. I'd really like to see this become a group project, where people make improvements and then post their changes here so we can all benefit.

Requirements:
  • Hydra
  • NTSC TV
  • game pad
  • Optional: another Hydra, another NTSC TV, another game pad

I assume most of you have only one Hydra, so I've defined a constant SOLO = true. You can control either your tank or the enemy tank. Hold down START to control the enemy. It's not a solo game (yet), but at least you can play around with it, shoot yourself, etc.

If you have two Hydras (anyone?), hook them up with phone cord. Change SOLO = true to SOLO = false and download to both Hydras. It might take a few rounds of resets, but eventually both screens will say "HYDRA BATTLEZ0WNED" and one will say "PRESS START". Now you and a friend can blow each other up.

As I said, I really hope some of you will help make the program better. Over the next few days I'll try to post some notes on the code to explain what the heck it's doing (stuff I really should have put in comments); meanwhile, please post questions as they come to you.

Here's are some things people might work on:
  • sound
  • single-player vs AI (Baggers, I'm looking at you)
  • more robust network: the code to determine which machine is the master does not work reliably; also, there is no error-detection or -correction.
  • general code clean-up and refactoring
  • better graphics: low priority, because it's OK as-is IMHO, but there's room for improvement


Attached: Battlez0wned.spin and a cut-down version of graphics_drv. You'll need to supply gamepad_drv from the Hydra sources.

Comments

  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-10-04 13:54
    Some comments:


    You'll also need

    gamepad_drv_001
    tv_drv_010

    I believe these can now be distributed as they were included in the "HYDRA_Demos_Source_Teaser"
    under Fun in the object exchange. (Please correct me if I'm wrong Andre.)

    Also it should be noted that to compile you will need to make sure that your Propeller tool is up-to-date.
    I couldn't get 1.05.5 to compile the source, but 1.05.7 worked perfectly.

    Do you mind a Proto/Demo port of this?

    Oldbitcollector

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.

    — Calvin, of 'Calvin and Hobbes.
  • mparkmpark Posts: 1,305
    edited 2007-10-04 14:51
    Hmm, I'm using 1.05.5. What compilation errors did you see?

    I don't mind a Proto/Demo port at all. You all are free to modify (and hopefully improve) the program. Go nuts. All I ask is that you please consider posting your modified versions to share with the rest of us.
  • ClemensClemens Posts: 236
    edited 2007-10-04 23:44
    I'm using 1.05.5. and it works on my demoboard-clone.
    I'll try to get the keyboard working next... wink.gif
    Thanks mpark, the little spin I learned so far was mainly by trying to get all the games you guys made to run on my board. smile.gif
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-10-05 00:46
    I don't know why it didn't work on my .5 version, but the upgrade fixed the problem. [noparse]:)[/noparse]

    I was thinking of doing some rewrite of the gamedrv file to handle the keyboard..
    (If I can find enough memory...) This way any game using that would be easily adaptable.

    Kudos for good use of almost every long!

    Oldbitcollector

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.

    — Calvin, of 'Calvin and Hobbes.
  • AndreLAndreL Posts: 1,004
    edited 2007-10-06 00:24
    These drivers are fine to distribute:

    gamepad_drv_001
    tv_drv_010

    The former is 50 lines of code and only useful if you have hydra, and the later is the parallax video driver which is public domain.

    Andre'
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-10-06 03:48
    Useful if you built a NES port to HYDRA specs.. [noparse];)[/noparse]

    I just got the game up and running on my frankenstein-Proto/Hydra tonight.. Sweet!
    You've motivated me into building some hydra-net connections..

    Shame we don't have some more memory for Harrison's TCP driver, then we could
    get in some head-to-head play over the Internet. [noparse]:)[/noparse]

    Oldbitcollector

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.

    — Calvin, of 'Calvin and Hobbes.
  • mparkmpark Posts: 1,305
    edited 2007-10-06 07:22
    Way to go, Clemens and OBC! Anyone else got it running yet? Anyone run into difficulties?

    In case you're wondering about that "A" at the top of the screen, it indicates the steering mode. Pressing SELECT toggles steering between mode A and mode B. In mode A, pressing LEFT causes the tank to turn CCW when viewed from above, whether it's stationary, moving forward, or moving in reverse. Mode B is the same except for reversing, when LEFT turns the tank CW.

    Steering mode B had never crossed my mind until I played Atari's online Battlezone: games.atari.com/playgames/arcade/battlezone/battlezone_400.jsp. Something felt strange and I finally realized that it reverses turn direction when reversing (i.e., what I call mode B).

    I grabbed a couple of guys at work and had them drive around in Atari BZ. One of them found reversing completely natural, the other thought it was completely wrong. In talking with them about it, it appears that if you're thinking in terms of aiming the crosshairs, mode A is correct, but if you're thinking more about steering the tank like a car, then mode B is better.

    So I went home and added the A/B option (I should have used my colleagues' initials: D/T). I hoped to do a little survey at NWCGE to see what people preferred but there was too much other stuff going on. People just played in mode A. It only makes a difference when backing up, and that hardly happens anyway.

    But try it both ways; I'd be interested to hear what you prefer.

    Maybe one of you enterprising types will build a two-stick controller for independent tread control and make the question moot.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-10-06 12:27
    Somebody said...
    Maybe one of you enterprising types will build a two-stick controller for independent tread control and make the question moot.

    You really shouldn't say things like that to people like me! Doggoneit! Another project added to my list!
    game_drv_002 (A two atari stick tank control)

    The sick part is that I should be able to hang it off the same pins I used for my original Atari stick driver (Demo/Hydra VGA head) to make it work.

    Oldbitcollector

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.

    — Calvin, of 'Calvin and Hobbes.
  • BaggersBaggers Posts: 3,019
    edited 2007-10-06 14:53
    since most the pad drivers read and give out nespad 1 in first byte and nespad 2 in second byte of pad how about :-

    if pad&NES_UP and pad&(NES_UP<<8)
    'handle forward
    if pad&NES_DOWN and pad&(NES_DOWN<<8)
    'handle reverse
    if pad&NES_DOWN and pad&(NES_UP<<8)
    'handle left
    if pad&NES_UP and pad&(NES_DOWN<<8)
    'handle right

    Baggers.
  • BaggersBaggers Posts: 3,019
    edited 2007-10-06 14:55
    PS, your display driver isn't working with my LCD tv, so when I get a spare 5 mins, I'm gonna put in the parallax driver, ( Don't know what the difference is so far, but it doesn't work with this driver, but all my other stuff does. )
    Then, I can get to work on AI.
  • mparkmpark Posts: 1,305
    edited 2007-10-07 00:31
    I don't know why the display driver isn't working for you, Baggers. It is just the Parallax driver with a lot commented out. I added a function to return the address of the assembly language portion so that I could reuse that memory for the screen buffers, but that shouldn't make it stop working with your TV. Good luck and let us know if you solve the problem.

    Post Edited (mpark) : 10/7/2007 12:36:29 AM GMT
  • BaggersBaggers Posts: 3,019
    edited 2007-10-07 11:53
    Yeah, will do.
  • epmoyerepmoyer Posts: 314
    edited 2007-10-08 16:29
    Nice work! At first I thought there were errors in the line draw routines but it turns out that some of the lines were just too dim to see at the brightness I usually keep my Hydra LCD set to. I cranked it up and everything looks awesome! Love the spewing volcano; that would have been easy to leave out but I'm glad you included it. Very slick all around.

    That's cool that you got to show it off at the expo! It must have been fun to have people come by and play with it.
  • mparkmpark Posts: 1,305
    edited 2007-10-08 17:02
    Thanks, epm. Good to see you back here.

    Apparently you and I keep our LCDs set to similar brightness levels. I was working on BZ with a·5"·LCD, but for the show I got some "real" TVs and when I first saw BZ on a CRT I was a bit shocked at the difference. I had to tone down a lot of things in the code. And turn up the brightness on the LCD.



    ·
  • mparkmpark Posts: 1,305
    edited 2007-10-08 22:16
    Today's installment of "Inside Battlez0wned.spin: What the heck was mpark thinking?" concerns cog usage. Currently all eight cogs are used, as follows (not in cog order):
    • TV driver
    • Gamepad driver
    • Spin interpreter
    • Graphics driver
    • Spin interpreter
    • Graphics driver
    • Spin interpreter

    As you can see, there are three Spin/graphics cog pairs. One pair is responsible for drawing the mountain background, the second pair draws the tank, and the third draws everything else. At one point I had them all working concurrently, but there would be obvious drawing order errors (such as mountains appearing to be in front of a cube). So now the tank-drawing and everything-else-drawing cog-pairs wait until the background-drawing cog-pair is done. There are still drawing order errors among the cubes and pyramids and tanks, but since they are all the same shade of green, you can't tell! Of course when things are hit and start to flash you might see lines crossing on top where they should be under, but for the most part it·looks fine.

    However,·this means that a maximum of two Spin/graphics cog pairs are working concurrently, so what I should have done is have one cog pair do the background and the tank, thereby freeing up a pair of cogs. If you need more cogs, that's what you should do. You just have to arrange things so that the everything-else drawing starts when the tank-drawing does. Or for faster drawing·you could keep the third cog pair and have it draw half the non-tank objects.

    I think it's pretty cool that multiple instances of the Graphics object can work together. I had feared that they would interfere with each other when drawing to the screen, but at least in this case, with the·sparse "vector graphics" look, everything works OK.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-10-08 23:00
    Project added to PROJECT sticky.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-10-09 00:39
    That gamepad object could easily become internal... That'll free up a cog..

    Oldbitcollector

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.

    — Calvin, of 'Calvin and Hobbes.
  • RossHRossH Posts: 5,336
    edited 2008-08-21 10:19
    Hi all,

    Should have posted here earlier. I've created a VGA version of BZ. It supports 640x480 (4 colour), or up to 1024x768 (2 colour).

    See the thread http://forums.parallax.com/forums/default.aspx?f=33&m=286151

    I'd really like someone who has access to two Hydras to let me know if the multi-player mode works ok.

    Ross.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-12-14 19:40
    This is a version of Battlez0wned that works with the Protoboard/Demoboard Setup
    I've included the two missing files (gamepad_drv_001, and tv_drv_010)
    since they are free to distribute. (Thanks Andre!)

    You'll still need the NES controller on p3,p4,p5,p6 just like the Hydra.

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with a Propeller Protoboard?
    Check out: Introduction to the Proboard & Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
Sign In or Register to comment.