Jump to content
IGNORED

How do you change m and p separately in NUSIZ0?


Recommended Posts

I'm talking about this part of the bB page:

 

https://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#nusiz

 

I'm updating a bB example program and need to dynamically change the setting for the missile without messing with the setting for the sprite (and the other way around).

 

I tried adapting part of the Nybble Me This, Batman! code, but I can't get it to work.

10 minutes ago, Random Terrain said:

I'm talking about this part of the bB page:

 

https://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#nusiz

 

I'm updating a bB example program and need to dynamically change the setting for the missile without messing with the setting for the sprite (and the other way around).

 

I tried adapting part of the Nybble Me This, Batman! code, but I can't get it to work.

Hey there,

 

You need to first clear the existing value nibble using AND and then OR in your updated value.

 

Here's an assembly code example; you should be able to do something similar in bB:

 

	; update M0 nusiz for P0 without changing the player nusiz:

	lda NUSIZ0		; get existing value
	and #$0F		; clear out the high nibble 4 bits that store the missile nusiz
	ora #MSBL_SIZE4	; example for how to set the MSBL size to 4
	sta NUSIZ

	; update player nusize for P0 without changing M0 nusiz:

	lda NUSIZ0		; get existing value
	and #$F0		; clear out the lower nibble 4 bits that store the player nusiz
	ora #TWO_COPIES	; example for how to set the player copies to TWO_COPIES
	sta NUSIZ

	

Hope that helps!

  • Like 1

Thanks. So far I have this:

 

   ;***************************************************************
   ;
   ;  Sets the size of sprite0.
   ;
   NUSIZ0 = NUSIZ0 & $0F

   NUSIZ0 = NUSIZ0 | _Data_Sprite_Size[_Sprite0_Size]


   . . .

   . . .

   . . .


   ;***************************************************************
   ;
   ;  Sprite size data for use with NUSIZ0 and NUSIZ1.
   ;
   data _Data_Sprite_Size
   $00, $05, $07
end

 

The sprite looks fine when using $05 and $07, but when it's supposed to be using $00, I get two wide sprites as if it's set to $04.

 

As a test, I used this "NUSIZ0 = NUSIZ0 | $00" to see what would happen and I still get two wide sprites.

Just now, RevEng said:

If you read from NUSIZ0, you're actually getting CXM0FB, a collision register. NUSIZ0 is write-only, so you can't pull previously written values from it.

 

Thanks. After all these years, I'm still not used to OR. I should probably put a note on the bB page that OR (and I'm guessing XOR) actually read the register, so if the register can't be read, OR and XOR won't work properly.

15 minutes ago, Random Terrain said:

 

Thanks. After all these years, I'm still not used to OR. I should probably put a note on the bB page that OR (and I'm guessing XOR) actually read the register, so if the register can't be read, OR and XOR won't work properly.

It's a bit more mundane. If the register is anywhere on the right side of the "=" in an assignment, it will cause the register to be read, regardless of the operations used.

  • Like 1

If you need to change these registers on the fly, you will need to sacrifice a variable to hold the current value of the register, and set the real register to the variable's value every frame. Then you can do any operations you need to the variable to achieve the same effect. 

  • Like 2
1 hour ago, bogax said:

NUSIZ0 = NUSIZ0 & $0F

 

Your mask is inverted.

 

You're clearing the missile nybble and retaining the player nybble.

 

You end up with the old player nybble ORed with the new player nybble

 

Thanks. That fixed a problem I was having with my variable.

Seems to be working correctly now:

 

   ;***************************************************************
   ;
   ;  Player0/missile0 width.
   ;
   ;```````````````````````````````````````````````````````````````
   ;  Prepares player0 width for NUSIZ0.
   ;
   _My_NUSIZ0 = _My_NUSIZ0 & $F0
   _My_NUSIZ0 = _My_NUSIZ0 | _Data_Player_Width[_Player0_Width]

   ;```````````````````````````````````````````````````````````````
   ;  Prepares missile0 width for NUSIZ0.
   ;
   _My_NUSIZ0 = _My_NUSIZ0 & $0F
   _My_NUSIZ0 = _My_NUSIZ0 | _Data_MB_Width[_Missile0_Width]

   ;```````````````````````````````````````````````````````````````
   ;  Sets player0 width and missile0 width.
   ;
   NUSIZ0 = _My_NUSIZ0

   ;```````````````````````````````````````````````````````````````
   ;  Sets missile0 height using data.
   ;
   missile0height = _Data_MB_Height[_Missile0_Width]


   . . .

   . . .

   . . .


   ;***************************************************************
   ;
   ;  Player0/player1 width data for use with NUSIZ0 and NUSIZ1.
   ;
   data _Data_Player_Width
   $00, $05, $07
end



   ;***************************************************************
   ;
   ;  Missile/ball width data.
   ;
   data _Data_MB_Width
   $00, $10, $20, $30
end

 

Thanks.

  • Like 2

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