JohnGri Posted August 4, 2022 Share Posted August 4, 2022 Hi, I'm still learning 6502 assembly and trying to create an Atari game. I have a few questions regarding the number-size registers. 1) Why does the Stella guide refer to the bits of these registers (and other registers) as D1,D2 etc. for the bits in the register? It seems like B1,B2 etc. ( byte 1, byte 2) would make more sense. 2) How can I set the value of one bit, without affecting the values of other bits. In other words if I set the width of as missile using D4 and D5 Later on, can I set the players copies and size using D0, D1, D2 without affecting D4 & D5? Is that possible or do all those bits have to be set at the same time? This is all I know on how to set the number & size of players lda #%00000011 sta NUSIZ0 Thanks, John Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted August 4, 2022 Share Posted August 4, 2022 Data lines, bits, nibbles, bytes, words, binary and HEX Quote The exponents are often used to designate a bit in a binary number. Bit 0 is on the right end of the byte and bit 7 is on the left end. Bit 0 is the lsb and bit 7 is the msb. Data bits are often abbreviated using the letter D -- D0, D1, D2, etc. use AND then OR. To change player data in D0, D1, D2 do this: lda numsize and #%11111000 ; any 1 bits will stay the same, any 0 bits will be cleared - so this zeros out D0, D1, D2 ora new_player_size_num ; any 0 bits will stay the same, any 1 bits will be set ; expected value of new_player_size_num is 0 - 7, will set D0, D1, D2 sta numsize WARNING - the TIA registers are either READ ONLY or WRITE ONLY - NUSIZ0 and NUSIZ1 are both write only, so you CANNOT DO THIS: lda NUSIZ0 ; WARNING - this will not work - this will really be treated as LDA CXM0FB and #%11111000 ora new_player_size_num ; expected value is 0 - 7 sta NUSIZ0 Quote Link to comment Share on other sites More sharing options...
JohnGri Posted August 5, 2022 Author Share Posted August 5, 2022 2 hours ago, SpiceWare said: Data lines, bits, nibbles, bytes, words, binary and HEX use AND then OR. To change player data in D0, D1, D2 do this: lda numsize and #%11111000 ; any 1 bits will stay the same, any 0 bits will be cleared - so this zeros out D0, D1, D2 ora new_player_size_num ; any 0 bits will stay the same, any 1 bits will be set ; expected value of new_player_size_num is 0 - 7, will set D0, D1, D2 sta numsize WARNING - the TIA registers are either READ ONLY or WRITE ONLY - NUSIZ0 and NUSIZ1 are both write only, so you CANNOT DO THIS: lda NUSIZ0 ; WARNING - this will not work - this will really be treated as LDA CXM0FB and #%11111000 ora new_player_size_num ; expected value is 0 - 7 sta NUSIZ0 Thanks for the reply. Forgive my ignorance. Your first example doesn't store a value in NUSIZ0 so how could it really have any effect? The 2nd example is code that won't work. What am I mis-understanding? Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted August 5, 2022 Share Posted August 5, 2022 The first example is code on how to do the manipulations you were asking about: 3 hours ago, JohnGri said: How can I set the value of one bit, without affecting the values of other bits. The second example is basically an example to point out why that won't work with NUSIZ0, since it's a write-only register, so you have to set all the bits at once. If you want more flexibility, you can use a variable to track the current value, manipulate and save to that and store in NUSIZ0 after you've made changes: lda numsize ;--- load last value and #%11111000 ; any 1 bits will stay the same, any 0 bits will be cleared - so this zeros out D0, D1, D2 ora new_player_size_num ; any 0 bits will stay the same, any 1 bits will be set ; expected value of new_player_size_num is 0 - 7, will set D0, D1, D2 sta numsize ;-- save for later sta NUSIZ0 ;-- update the register 2 1 Quote Link to comment 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.