Jump to content
IGNORED

Questions about NUSIZ1


Rabbit 2600

Recommended Posts

I just discovered the wonders of NUSIZ1 = 33. I love that it gets me multiple clones on the screen. There is however 1 thing I'm having issues with:

How do I make it so that when 1 of the clones is hit by the missile only that one gets destroyed instead of all of them?

Link to comment
Share on other sites

You need to figure out which copy was hit, then update NUSIZ1 and possibly the X position.

 

based on this:

            D2   D1   D0               Description
           0    0    0    X           one copy
           0    0    1    X X         two copies - close
           0    1    0    X   X       two copies - med
           0    1    1    X X X       three copies - close

 

 

 

If you start out with NUSIZ1 = $x3 (x = any hex value) then you're showing 3 copies close. If you hit one of them then you have 3 possible things to do:

 

1st copy hit:

change NUSIZ1 to $x1 (for two copies close)

add 16 to X position

 

2nd copy hit:

change NUSIZ1 to $x2 (for two copies medium)

X not changed

 

3rd copy hit:

change NUSIZ1 to $x1 (for two copies close)

X not changed.

 

To figure out which one was hit, do some comparisons. If you're using missile0 then do something like:

 

temp = missile0_x - player1_x

if temp < 8 then 1st copy hit

else if temp < 24 then 2nd copy hit

else 3rd copy hit

Edited by SpiceWare
Link to comment
Share on other sites

Hm, I understand the workings, but not how to write it out. I can't get it to work.

Here's a simple example I threw together. It's messy-- I didn't try to consolidate RAM space by dimming bit variables, for example, and I'm sure someone can find ways to improve the logic-- but it works.

 

Edit: Minor correction to the player1_1st_copy_hit routine. I'm attaching the updated files.

simple_shooter_example.bas

simple_shooter_example.bas.bin

Edited by SeaGtGruff
Link to comment
Share on other sites

Wouldn't compile for me.

Doesn't like the if statement on line 96

if player1x + temp1 > 154 then player1x = 153 - temp1 : player1_motion = 255

 

Some versions of bB won't let you do math in an if-then. You have to do something like this:

 

  temp5 = player1x + temp1
  if temp5 > 154 then player1x = 153 - temp1 : player1_motion = 255

Link to comment
Share on other sites

Wouldn't compile for me.

Doesn't like the if statement on line 96

I seem to have all kinds of trouble getting if statements to compile sometimes-- and I swear a lot of the time the logic is the same as what used to work in earlier versions of bB. Usually when I have a problem it seems like the compiler is trying to interpret a logical combination as a complex math statement. That's why several of the ifs in my example program use nested ifs rather than &s. And IIRC the compiler has trouble handling elses the way you'd expect, like "if a then b else c : d : e"-- my expectation is that "c : d : e" would all be part of the else, but instead only c is the else and "d : e" execute regardless, as though there were an endif after c. I guess that's fair (as in "turnabout is fair play") if you can't do something like "if a then b : c : d else e." Yet the compiler usually has no trouble handling "if a then b : c : d" without an else. It would be awesome to eventually have true "if-then-else-endif" statements that let us use multiline thens and elses-- it would help simplify a lot of cases where you end up having to invert the if and use a goto to jump over what would have been a lengthy then.

 

As far as why that particular line wouldn't compile for you-- I don't know. Sometimes a statement won't compile in one updated version, but then I try a slightly different updated version and it works. I get a headache trying to juggle around all the minor updates. It's gotten to be a mess. :(

Link to comment
Share on other sites

Probably not worth the bother

but it saves 10 bytes

 

it's totally worth the bother - saving memory, even "just" 10 bytes for a single routine, is a crucial part of 2600 development.

 

I spend a lot of time reviewing my code to find space savings. One way is to overlap data, you'll find 582 instances of "overlap" in the source for Space Rocks - that's over 1/2 K saved in a 32K game. Most of those overlaps are single bytes, such as these 4 bytes saved by overlapping the UFO data:

UFO_Solid0:
       .byte zz___X____ ; 0
       .byte zz__X_X___ ; 1
       .byte zz__XXX___ ; 2
       .byte zz_X___X__ ; 3
       .byte zz__XXX___ ; 4
;       .byte zz___X____ ; 5 overlap with 1
UFO_Solid0Height = * - UFO_Solid0 + 1
UFO_Solid1:
       .byte zz___X____ ; 0
       .byte zz__X_X___ ; 1
       .byte zz__XXX___ ; 2
       .byte zz_X__XX__ ; 3
       .byte zz__XXX___ ; 4
;       .byte zz___X____ ; 5 overlap with 2
UFO_Solid1Height = * - UFO_Solid1 + 1
UFO_Solid2:
       .byte zz___X____ ; 0
       .byte zz__X_X___ ; 1
       .byte zz__XXX___ ; 2
       .byte zz_X_XXX__ ; 3
       .byte zz__XXX___ ; 4
;       .byte zz___X____ ; 5 overlap with 3
UFO_Solid2Height = * - UFO_Solid2 + 1
UFO_Solid3:
       .byte zz___X____ ; 0
       .byte zz__X_X___ ; 1
       .byte zz__XXX___ ; 2
       .byte zz_XXX_X__ ; 3
       .byte zz__XXX___ ; 4
;       .byte zz___X____ ; 5 overlap with 4
UFO_Solid3Height = * - UFO_Solid3 + 1
UFO_Solid4:
       .byte zz___X____ ; 0
       .byte zz__X_X___ ; 1
       .byte zz__XXX___ ; 2
       .byte zz_XX__X__ ; 3
       .byte zz__XXX___ ; 4
       .byte zz___X____ ; 5
UFO_Solid4Height = * - UFO_Solid4

 

though some are larger such as these 8 bytes saved in the large asteroid HMOVE shift data:

        .byte HMOVE_0  |  0
       .byte HMOVE_0  |  0
;       .byte HMOVE_R1 |  1 ; overlap with A20
;       .byte HMOVE_0  |  1 ; overlap with A20
;       .byte HMOVE_L1 |  0 ; overlap with A20
;       .byte HMOVE_R1 |  1 ; overlap with A20
;       .byte HMOVE_0  |  1 ; overlap with A20
;       .byte HMOVE_0  |  1 ; overlap with A20
;       .byte HMOVE_L1 |  0 ; overlap with A20
;       .byte HMOVE_0  |  0 ; overlap with A20
Shift_LargeAsteroid_A20:
;        .byte HMOVE_0  |  0
       .byte HMOVE_R1 |  1
       .byte HMOVE_0  |  1
       .byte HMOVE_L1 |  0
       .byte HMOVE_R1 |  1
       .byte HMOVE_0  |  1
       .byte HMOVE_0  |  1
       .byte HMOVE_L1 |  0
       .byte HMOVE_0  |  0
       .byte HMOVE_0  |  0
       .byte HMOVE_0  |  0
       .byte HMOVE_0  |  0

Edited by SpiceWare
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...