+Random Terrain Posted February 12, 2022 Share Posted February 12, 2022 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. Quote Link to comment https://forums.atariage.com/topic/331179-how-do-you-change-m-and-p-separately-in-nusiz0/ Share on other sites More sharing options...
+johnnywc Posted February 12, 2022 Share Posted February 12, 2022 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! 1 Quote Link to comment https://forums.atariage.com/topic/331179-how-do-you-change-m-and-p-separately-in-nusiz0/#findComment-5003245 Share on other sites More sharing options...
+Random Terrain Posted February 12, 2022 Author Share Posted February 12, 2022 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. Quote Link to comment https://forums.atariage.com/topic/331179-how-do-you-change-m-and-p-separately-in-nusiz0/#findComment-5003258 Share on other sites More sharing options...
RevEng Posted February 12, 2022 Share Posted February 12, 2022 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. 1 Quote Link to comment https://forums.atariage.com/topic/331179-how-do-you-change-m-and-p-separately-in-nusiz0/#findComment-5003263 Share on other sites More sharing options...
+Random Terrain Posted February 12, 2022 Author Share Posted February 12, 2022 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. Quote Link to comment https://forums.atariage.com/topic/331179-how-do-you-change-m-and-p-separately-in-nusiz0/#findComment-5003271 Share on other sites More sharing options...
RevEng Posted February 12, 2022 Share Posted February 12, 2022 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. 1 Quote Link to comment https://forums.atariage.com/topic/331179-how-do-you-change-m-and-p-separately-in-nusiz0/#findComment-5003274 Share on other sites More sharing options...
+Karl G Posted February 12, 2022 Share Posted February 12, 2022 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. 2 Quote Link to comment https://forums.atariage.com/topic/331179-how-do-you-change-m-and-p-separately-in-nusiz0/#findComment-5003278 Share on other sites More sharing options...
bogax Posted February 12, 2022 Share Posted February 12, 2022 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 1 Quote Link to comment https://forums.atariage.com/topic/331179-how-do-you-change-m-and-p-separately-in-nusiz0/#findComment-5003291 Share on other sites More sharing options...
+Random Terrain Posted February 12, 2022 Author Share Posted February 12, 2022 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. Quote Link to comment https://forums.atariage.com/topic/331179-how-do-you-change-m-and-p-separately-in-nusiz0/#findComment-5003329 Share on other sites More sharing options...
+Random Terrain Posted February 12, 2022 Author Share Posted February 12, 2022 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. 2 Quote Link to comment https://forums.atariage.com/topic/331179-how-do-you-change-m-and-p-separately-in-nusiz0/#findComment-5003437 Share on other sites More sharing options...
Recommended Posts
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.