IGNORED

# Adventures of the Stalk of Celery (Channel F)

## Recommended Posts

Not sure the routine is used the way it was intended.

At start of game you should seed which number in the pedefined scrambled numbers loop you want to start with.

An easy seed method is running a counter and save it in the register used by the random routine while waiting for user input (wait for no input first to prevent "cheating").

Doing a "ds REG" in the loop waiting for input is probably shortest/quickest. "ds S" if scratchpad is set/used.

After your seed number is set you don't change it again, only the random routine changes that register (0o25 in this case). It takes one step at the time in the predefined scrambled order of 256 values - without repeats.

When you need to use a new number for the single particular function, call the routine and there will be a new number in the register.

It's possible to create a different order of numbers by using another mask in the routine (wiki has 16 possible options).

Not using the randomizer the way it was meant to be used might mess with the "randomness".

When using just 2 bits, pure random would give 25% for any direction, 6.5% for two in a row... 1.6% for three in a row.

The subroutine only mixes eight bits with no repeats, it's quite possible you can get the same number several times in a row when just keeping two bits.

My suggestion is that you save the previous number and fetch a new random number if it's the same (the two used bits) as last time and keep getting a new random number until it's different - or just try X amount of times before using that number anyway, or do an operation (sr 1 or sr 4 or com or inc... )

... or setup a data table  that has a good mix and start at a seeded number in that set to mix up the start position.

The pseudorandom numbers routine is just a compacted table, saves some space not needing a 256 byte table.

##### Share on other sites

So, what I mean is you should use a "set seed wait for action routine" and then don't touch octal register any more, only let "pi Random" change it.

In "Golf" there's a key and controller check in the PlaySong2 routine, you could add a "ds" to an unused register and then copy it to octal register 25 upon exiting the intro screen - to save some cycles.

As far as I can see these registers are used in that routine:
4, 5, 6, 7 - so any other. But I don't know how you do it now, I'm guessing something similar.

No no, ah ah:

```    lisu  2
lisl  5
lr  A, S
inc
lr  S, A

pi  Random```

Yes:

`	pi Random`

The seeding would need to be placed somewhere where there's a chance it can change all over the 256 values, preferrably.

Perhaps while waiting for keypress, while it's pressed and while waiting for release?

```ds	0	; Placed cleverly
.
.
.

; Last thing before starting the actual game
lr	A, 0	; Get the seed number from temporary register
lisu	2
lisl	5
lr	S, A	; Set seed number in the random number register```

##### Share on other sites

• 2 weeks later...

Ok, I guess I misunderstood how the routine worked. I thought o25 needed to have one added to make a new random number from the "list". Here is a new version with corrections, let me know what you think.

##### Share on other sites

I will be working some more on this. I just got an idea for level 4. It will be like the Game and Watch game "Manhole." Instead of the man, though, it's Mr. Celery.

##### Share on other sites

I decided to get rid of the music on the title screen.

I discovered if you press fire to start on the same note, the same result happened. You could have used that to your advantage. So I decided that if no note plays, the result was a lot more random since you didn't know which note it was playing. Honestly, I thought the addition of o25 would be faster than that. Oh well.

##### Share on other sites

If you keep the music and then do the seed after input waiting for release of controller... or keep it in waiting stage as well.

Release time is likely to vary.

To speed things up, just read the used port (not both), decrease a low register and then store the value in o25 (register used in Random, could be any you choose - or in RAM).

; routine for one of the controllers

; decrease r1

ds 1

; compare to no input value, if not inverting you could "inc" from the \$FF and do "bz" to top (don't think reading port sets flags)

; branch to top if not clear

; store r1 in o25

Don't know how fast that is, you could  check cycles and compare to clock speed.  ;)

Optionally add a second "start stage"  controller press to continue counting seed value.

Save the music!!

##### Share on other sites

I think I have it random enough after putting the title screen music back in. I also finished programing level 4, which you start on. This is the fastest speed Mr. Celery can go. If you see any bugs, please tell me.

##### Share on other sites

Started work on level 5. I am having it be like dodging the pots being thrown at you in the Garfield 2600 prototype.

The thing is Mr. Celery will not duck by pressing down, rather, he'll duck by moving into one of the holes in the fence.

It looks like I can fit all of level 5 into the game and still have it be 16k. I don't know if I will add any more levels, since this is the fifth one and I don't want it to be too long. I'm wondering how I'll move Mr. Celery, though. It will probably look like when right is pressed, Mr. Celery will automatically be 8 pixels ahead instead of showing the celery sliding. It will probably be like level 3, where the celery was automatically placed 9 pixels higher.

##### Share on other sites

This is how it will move. Press right to move the celery right. I got it much smoother than I thought.

##### Share on other sites

On 8/16/2022 at 6:47 AM, atari2600land said:

This is how it will move. Press right to move the celery right. I got it much smoother than I thought.

It looks really good!

##### Share on other sites

Spent the last three hours working on this. I got the enemy in at three different random speeds. No collision detection yet, that comes next.

##### Share on other sites

Level 5 collision detection finished.

##### Share on other sites

#28

I like in Pac-Man it's possible to go through a red "pill" in this game, I was on top and got hit by a fast one - or so I thought. As it and I was moving at the same time there was no collision.

Perhaps collision width needs to be increased relative to the speed?

##### Share on other sites

I changed the collision detection. Try this.

##### Share on other sites

3 hours ago, atari2600land said:

I changed the collision detection. Try this.

I haven't tried 28 but just had a go with 29, I seem to be able to dash through with the fastest speed too if I hold the button down, but can time the transitions on any speed with a bit of luck. its hardest to cheat on the slowest speed.

Are you checking collisions just when the red ball moves? it seems like its not checking it when the celery moves after the ball, with the faster speeds this means when the ball jumps positions it clears the celery even when the celery moved into its position. It does feel though that this would be much harder to do on real hardware, the benefits of having a keyboard in emulation seems to be allowing the cheat by timing - I'm not sure I'd be able to perform the same feat with the regular controller..

Its a fun level though.

Edited by Mikebloke
##### Share on other sites

I'm checking the collision on every frame. This is how:

```check_apple_collision_down
LISU 2
LISL 0

LR A, S ;load the value from that register into A
COM ;complement A (this means A = 255 - A)

LISU 3
LISL 0

AS S    ;add that register to A, so now A contains the value of (Register 2 - Register 6 of bank 3 - 1)

CI 1  ; did celery collide with right side of apple?
BC collision_happened_level_5 ;branch to subLives if carry was clear (Reg. 2 - Reg. 6 <= 3)

CI 251  ; did celery collide with left side of apple?
BNC collision_happened_level_5 ;branch to subLives if carry was set (Reg. 2 - Reg. 6 > -5)	```

##### Share on other sites

23 minutes ago, atari2600land said:

I'm checking the collision on every frame. This is how:

```check_apple_collision_down
LISU 2
LISL 0

LR A, S ;load the value from that register into A
COM ;complement A (this means A = 255 - A)

LISU 3
LISL 0

AS S    ;add that register to A, so now A contains the value of (Register 2 - Register 6 of bank 3 - 1)

CI 1  ; did celery collide with right side of apple?
BC collision_happened_level_5 ;branch to subLives if carry was clear (Reg. 2 - Reg. 6 <= 3)

CI 251  ; did celery collide with left side of apple?
BNC collision_happened_level_5 ;branch to subLives if carry was set (Reg. 2 - Reg. 6 > -5)	```

Sorry I'm probably the least useful person to help, is the use of one's compliment instead of two to compensate for the fact the celery stick is two pixels wide?

I keep wondering if it needs one more pixel check in one direction or another, but I'm not intuitively smart enough to know where to do it (I thought CI 1 would be checking the left side rather than the right side, for example! and wondered if CI 0 would be better... I'd be just adjusting each number till it appeared to work better... wow I really am not good at this!)

##### Share on other sites

I think I got everything working finally. The issue was how I was drawing the celery, multiple frames for multiple scenarios, leaving the collision detection not working as well as I had hoped. Let me know if you can still go through the apple. I'm changing it to a tomato, just because who throws apples at people anyway?

##### Share on other sites

1 hour ago, atari2600land said:

who throws apples at people anyway?

Missy throws apples at her crush when his eye wanders

##### Share on other sites

• 4 months later...

So I was looking through Game and Watch Gallery looking for inspiration for this game. I came across Octopus. I thought the idea was usable, but needed to be displayed differently. Drawing the octopus's tentacles to go out in different ways would be hard for me to do. So I changed his arms to holes in the ground. And what comes out of the holes? Yard gnomes. The idea is this:

Yard gnomes pop out of different various "random" holes and Mr. Celery is going across the screen. The gist is to not make Mr. Celery get poked by the pointy hat the yard gnomes wear.

I need to draw a better yard gnome. The one I have in there doesn't look very good. After I took this snapshot, I added white hands for the gnome. This took a while to do so this is all my work for today.

##### Share on other sites

I separated all the games. They are now accessible via a menu.

##### Share on other sites

Set it to individual selection to "practice mode" and for "compete mode" (with some kind of scoring) you play the entire set.

Edited by e5frog
##### Share on other sites

I think I will make this an underwater scene like Octopus and call it "Squid Pro Quo." (I know a Jumble answer was this, but I thought of it before that).

I did this because I realized the terror had to come from above, not below. The squid tentacles will come from a possible 8 positions (a nice round number computer-wise), and will speed up once the game progresses. I think to start out slow, then move to a medium speed at 50, and then the highest speed at 100. Thoughts?

##### Share on other sites

I can't do this mini-game. It's too complex and hard to program. So I need to think of something else to come up with.

## 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.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.