Jump to content
  • entries
    4,945
  • comments
    2,718
  • views
    1,808,460

Yes Celery


atari2600land

587 views

Determined to do what I wanted to, I started with version 44 and rewrote the stuff I had in version 45. It only took me a few hours to get a working version, which was weird. Then I worked for a few more hours, getting a version 44a. I went to sleep happy that I had finally got some form of life counter in there. This was at 6pm or so. I went to sleep for 12 hours (I had only 5 the night before since I had been working on this game), and at 7am woke up to find SpiceWare had added a number counter instead of my dots I had been using. So I went with that one, changed a few things, and now I have a new, working version 46. If I get this released, I'm going to add him as co-programmer in the credits in a manual. One of the things I can't do since I have no room for it, is add a way to increase the life counter. Why not make it 4k? This was to see if I could make a half-way decent game in 2k. That, and I don't know how to bankswitch to 4k yet. By the way, I have an idea for my next Odyssey 2 game. It'll be based on Crazy Taxi, where you pick up passengers and take them where they want. But unfortunately, this is in the time where there's huge monsters invading the city. So not only do you have to get the people to the right place, you also have to dodge the giant monsters. This is just an idea at this point, no actual programming has been done on it yet. I guess I get so frustrated with programming things since I need to take a programming class, but I doubt there are any for 6502 programming, a 30-year-old machine. When you can learn how to program great-looking games, who would bother wanting to learn how to make a block move across a plain screen? I, for one...

1 Comment


Recommended Comments

One of the things I can't do since I have no room for it, is add a way to increase the life counter.

That's when it's time to review your code for places you can optimize it ;)

 

 

You currently have 2 bytes free. I took a quick look and right away spotted this:

Reset
   ; Clear RAM and all TIA registers

        CLEAN_START      

        lda     INPT0       ; DGS
        sta     Controller  ; DGS paddle if D7 = 1
      
       ;------------------------------------------------
       ; Once-only initialisation...

				lda #130
				sta PlayerX+1	

				lda #4
				sta AUDC0
				sta AUDV0

				lda #0
				sta GameRunning
	
				lda #0
				sta Lives
					
				lda #$84
				sta Rand16       ; also use BOX_COLOR ($84) as seed for the LFSR

 

And noticed a bunch of code that's not needed:

Reset
   ; Clear RAM and all TIA registers

        CLEAN_START      

        lda     INPT0       ; DGS
        sta     Controller  ; DGS paddle if D7 = 1
      
       ;------------------------------------------------
       ; Once-only initialisation...

                lda #130
                sta PlayerX+1   

                lda #4
                sta AUDC0
                sta AUDV0
                 
                ; lda #0
                ; sta GameRunning   - already 0 because of CLEAN_START
                ; 
                ; lda #0
                ; sta Lives         - already 0 because of CLEAN_START
                ; 
                ; lda #$84       
                sta Rand16       ; - just has to be a non-zero value, so use 130

now there's 12 bytes free.

 

Another find just a little bit further down in TheGameStarted:

        dec Lives
        ldx Lives
        cpx #255
        bcs GameRestarted2


Looking at the specs for the DEC opcode you'll see this:

DEC (DECrement memory)

Affects Flags: S Z

MODE           SYNTAX       HEX LEN TIM
Zero Page     DEC $44       $C6  2   5
Zero Page,X   DEC $44,X     $D6  2   6
Absolute      DEC $4400     $CE  3   6
Absolute,X    DEC $4400,X   $DE  3   7
 

So DEC updates the S flag for sign, which is also known as N flag for negative(Stella uses N). This means the instruction will set the sign/negative flag if the value becomes negative because of the DECrement. In 8 bit the value of 255 is the same as -1, so we can eliminate the LDX and CPX instructions and use a BMI (Branch MInus) instead.

        dec Lives
;        ldx Lives
;        cpx #255
;        bcs GameRestarted2
        bmi GameRestarted2

now there's 16 bytes free.

 

When you optimize code it's best to make just a few changes at a time then test the program to make sure you didn't break anything. For instance I initially thought the lda #4/sta AUDC0/sta AUDV0 instructions in Reset could be removed, as they're updated elsewhere in the program, but then I tested it and the initial tune didn't play.

Link to comment
Guest
Add a comment...

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