Jump to content
IGNORED

The Celery Game (was:"Screen rolls at the start")


Recommended Posts

 

How would I make it so the game starts once the fire button is pressed and then LET GO OF? Or is that even possible?

ProcessSwitches:
        ldx EndNoise
        cpx #63
        bcc StartOfFrame

        lda INPT4          ; read the player's fire button value    
        bmi StartOfFrame
        
StartTheGame:
        ;starting variables begin here.

 

 

 

Use a RAM value to keep track of the button state. If it used to be pressed, but isn't anymore, then start the game.

Link to comment
Share on other sites

The pattern is: Check, then set. That is, check your variable, then branch if not equal (or BMI, since you're checking bit 7...it'll be equivalent in this case) to your game start if it doesn't match...regardless of which, you need to set the variable after you check it, so that when you check INPT4 the next go-around, you can see a discrepancy.

 

-Thom

Link to comment
Share on other sites

Tried, failed. I guess I'm just stupid is it.

 

You're not stupid.

 

Here's an example what I did for Flappy Bird for the Colecovision.

if(cdown!=0){cdown--;}//automatically count down if cooldown number is not equal zero

if(refire==0 && cdown==0){ //branch when it is zero
if(joypad_1!=0){ //checks if the joypad is not zero. Any direction joypad or button being pressed will run this branch.
birdp=-5;cdown=6; //bird projection variable is -5 which makes him point upward, cooldown to keep from misfiring the button to soon.
refire=1;}}// set refire flag to 1

if(joypad_1==0){refire=0;} //check if joypad or fire button not being press.  If not be pressed it will reset refire to zero.
Link to comment
Share on other sites

So why won't this work?

#1 - since you used LDA you need to use CMP, not CPX

#2 - do the StartTheGame check after you've determined that the firebutton is not currently pressed:

 

        lda INPT4     ; check firebutton
        bmi StartOfFrameFireIsPressed ; branch if it is currently pressed

        lda FirePressed  ; fire is not currently pressed
        cmp #1           ; so see if it was pressed on the prior frame
        beq StartTheGame ; if so, branch and start the game

        jmp StartOfFrame
 
StartOfFrameFireIsPressed:
        lda #1
        sta FirePressed
        
        jmp StartOfFrame

Link to comment
Share on other sites

I fixed it! And a few other things as well. Like the flashing of the items before they appear for good. By the way, the first video isn't up any more. The second one was informative, but the music annoyed me a little. Thanks for making it.

celery25b.zip

Edited by atari2600land
Link to comment
Share on other sites

First video:

 

and the second part:

Well done! Three comments:

 

 

1) Any value drawn with a red background with green text is a value that changed since the last debugger screen refresh (ie: after you clicked Step, Trace, Exit, etc). So at the time of this screenshot:

post-3056-0-99548000-1469286168_thumb.png

 

these values changed:

  • PC (program counter)
  • A (accumulator)
  • Source Address for Y
  • sign is now positive (the lowercase n in PS - Processor Status)
  • RAM locations $8C, $FC and $FD changed to $07, $C9, and $F9 respectively.


2) The Processor Status (link to a nice article about each status flag) is denoted by the case, not the red background (which denotes a changed value):

post-3056-0-75509800-1469286393_thumb.png

  • n = negative (sign) sign. Lowercase so positive (BPL would be taken, BMI would not)
  • v = overflow flag. Lowercase so no overflow (BVC would be taken, BVS would not)
  • B = break flag
  • d = decimal flag
  • I = interrupt mask
  • Z = zero flag. Uppercase so set (BEQ would be taken, BNE would not))
  • c = carry flag. Lowercase so clear (BCC would be taken, BCS would not)

post-3056-0-55741900-1469286460_thumb.png

  • N = negative. Uppercase so negative (BMI would be taken, BPL would not)
  • v = overflow flag.
  • B = break flag
  • d = decimal flag
  • I = interrupt mask
  • z = zero flag. Lowercase so clear(BNE would be taken, BEQ would not)
  • c = carry flag


3) What the Drive unused TIA pins randomly on a read/peek is used for - on the input registers any line not used is not connected to the databus. So for these registers:

post-3056-0-86219600-1469287198_thumb.png

 

bits 7 and 6 are connected for most of the collision registers while only bit 7 is connected for the INPTx (paddle ports and fire buttons) and CXBLPF registers.

 

On most 2600s the unconnected lines end up taking on the value left over by the address used to read the input register. So LDA INPT4 (which reads address $0C) when you're not pressing fire will return $8C while LDA INPT5 will return $8D. On some 2600s you'll get random values, which can expose bugs in programs. By checking the Drive unused TA pins.. Stella will emulate those other systems and instead of getting back $8C from INPT4 (if fire isn't pressed) you'll get back other values such as: $AF, $8F, $BD, etc. were only the value in bit 7 can be counted on.

 

There are mirror addresses, so INPT4 could also be read via other addresses such as $1C, $2C, $3C, etc. When using a mirror such as $3C to read INPT4 the value returned when fire is not held would be $BC. Stella's aware of the mirrors and will helpfully show you when they're being used:

post-3056-0-45775200-1469287885_thumb.png

 

  • Like 2
Link to comment
Share on other sites

Is that OK? I mean the game works and all, but I am wondering.

 

The stack usage? Yes, that's OK.

 

More complex games need to use more RAM to keep track of things, which means there's less RAM available for stack usage. For those you just limit the usage of JSR calls to only those things that need to be called from multiple places, such as PosObject or Random.

Link to comment
Share on other sites

Yeah it's not a problem. I was just trying to get a better understanding of the stack and also just confirm it is where I thought it is. And I did. It never occurred to me that it was holding 16 bit numbers... But of course it does. So now I know the stack is twice as big as I thought. Still, three routines deep surprises me a little for this game.

Link to comment
Share on other sites

The stack can hold 8 bit values as well.

  • PHA - takes the 8 bit value in the Accumulator and saves it in the stack
  • PLA - takes an 8 bit value off the stack and puts it in the Accumulator
  • PHP - takes the 8 bit value that holds the Processor Status and saves it in the stack
  • PLP - takes an 8 bit value off the stack and puts it in the Processor Status
Link to comment
Share on other sites

PHP is a very nifty instruction if you can get things arranged correctly, You can literally use it to quickly thwack the enables of missiles and ball registers both in succession and in constant time by placing the stack pointer over the top of them, (so long as you have the carry bit set correctly by EORing Y scanlines, for example)...This trick is used in more than a few classic VCS titles, first in Combat, and again in Pole Position (to be able to get the top most road stripe line thwacked on/off quickly enough.)

 

(just remember to save and restore your stack, otherwise your program will go off into the weeds...)

 

I know I've mentioned it before, but that is one of my favorite tricks here on the VCS, and it shows two things:

 

(1) neat things happen when the hardware guys and the software guys are not only friends, but help each other develop the product. See also, the Atari 400/800 and the Amiga.

(2) neat things happen for you when you think outside the box. :)

 

-Thom

Edited by tschak909
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...