Alkadian Posted September 14, 2023 Share Posted September 14, 2023 (edited) Hi, Would someone please be kind enough to explain to me the meaning of the 8 at the end of the line code below: #Backtab(c)=$0807 + 5 * 8 Many thanks! Edited September 14, 2023 by Alkadian Quote Link to comment Share on other sites More sharing options...
carlsson Posted September 14, 2023 Share Posted September 14, 2023 Study the illustrations on this page: http://wiki.intellivision.us/index.php?title=STIC $0807 means the GRAM bit is set (the 8), and the foreground color is 7 (white). In order to select which card, you need to multiply it by 8 to push the bits beyond the lowest three that specify the color. 1 Quote Link to comment Share on other sites More sharing options...
Alkadian Posted September 14, 2023 Author Share Posted September 14, 2023 29 minutes ago, carlsson said: Study the illustrations on this page: http://wiki.intellivision.us/index.php?title=STIC $0807 means the GRAM bit is set (the 8), and the foreground color is 7 (white). In order to select which card, you need to multiply it by 8 to push the bits beyond the lowest three that specify the color. Fantastic, many thanks for that. This is exactly was I was looking for! Quote Link to comment Share on other sites More sharing options...
carlsson Posted September 14, 2023 Share Posted September 14, 2023 The jzintv emulator has or at least used to have (in some distributions) a documentation folder with some technical aspects described in text, but like they say, often an image says more than 1000 words. Quote Link to comment Share on other sites More sharing options...
Alkadian Posted September 14, 2023 Author Share Posted September 14, 2023 55 minutes ago, carlsson said: ....but like they say, often an image says more than 1000 words. Absolutely! Thanks again for pointing me into the right direction. I am really enjoying learning intybasic! And this forum is a fantastic place where to learn from! 1 Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted September 15, 2023 Share Posted September 15, 2023 @carlsson's response is spot on, but I just want to add a bit of context. As you will note, the BACKTAB, sprite registers, and many other aspects of the Intellivision accessible to the programmer are composed of "bit-fields" -- that is, a collection of values, each representing one particular characteristic, strung together into a single binary value. In the case of the BACKTAB data word, it includes various characteristics that describe a particular background card, among these are its foreground and background colors, the picture number to use, and whether the picture is located in Graphics ROM (GROM) or Graphics RAM (GRAM), etc. Therefore, to compose a valid BACKTAB data word you need to fill these values up, and place them in their proper field positions. To do this we typically exploit some neat properties of binary numbers. In the example you provided two of these can be seen: Multiplying by a power of 2 will shift the value the number of times corresponding to the exponent. 8 is equal to 2 raised to the 3rd power (8 = 2^3), and so the value is shifted left three times. This is akin to multiplying by powers of ten in our decimal system: 5 x 100 = 500 -- the five is "shifted" to the left two places, corresponding to 10^2. (Note that division by powers of two will do the reverse, and shift the value to the right -- this is also very useful). Adding a binary value properly positioned (shifted) to a field which is cleared to zero, will set the field to that value. This is why you see the addition of "5 * 8" -- the previous value, $0807, has a "hole" of zeroes right where the card picture data value would go, so to set the picture number, you just need to shift it to the proper position and add it. As for the meaning of that $0807 magic number? I think @carlsson also answered that, and the rest you can deduce from the link he provided. All you need to do is convert the Hexadecimal value to Binary and look at the bits with an eye toward the structure described in the STIC document on the wiki page. Of course, if anything is not clear, just ask! dZ. 1 Quote Link to comment Share on other sites More sharing options...
Alkadian Posted September 15, 2023 Author Share Posted September 15, 2023 3 hours ago, DZ-Jay said: @carlsson's response is spot on, but I just want to add a bit of context. As you will note, the BACKTAB, sprite registers, and many other aspects of the Intellivision accessible to the programmer are composed of "bit-fields" -- that is, a collection of values, each representing one particular characteristic, strung together into a single binary value. In the case of the BACKTAB data word, it includes various characteristics that describe a particular background card, among these are its foreground and background colors, the picture number to use, and whether the picture is located in Graphics ROM (GROM) or Graphics GRAM (GRAM), etc. Therefore, to compose a valid BACKTAB data word you need to fill these values up, and place them in their proper field positions. To do this we typically exploit some neat properties of binary numbers. In the example you provided two of these can be seen: Multiplying by a power of 2 will shift the value the number of times corresponding to the exponent. 8 is equal to 2 raised to the 3rd power (8 = 2^3), and so the value is shifted left three times. This is akin to multiplying by powers of ten in our decimal system: 5 x 100 = 500 -- the five is "shifted" to the left two places, corresponding to 10^2. (Note that division by powers of two will do the reverse, and shift the value to the right -- this is also very useful). Adding a binary value properly positioned (shifted) to a field which is cleared to zero, will set the field to that value. This is why you see the addition of "5 * 8" -- the previous value, $0807, has a "hole" of zeroes right where the card picture data value would go, so to set the picture number, you just need to shift it to the proper position and add it. As for the meaning of that $0807 magic number? I think @carlsson also answered that, and the rest you can deduce from the link he provided. All you need to do is convert the Hexadecimal value to Binary and look at the bits with an eye toward the structure described in the STIC document on the wiki page. Of course, if anything is not clear, just ask! dZ. Super! Many thanks for these further clarifications. I do love the techinal aspect of them. It is very important to understand how the hardware works before starting programming on it. So this helped me a lot! 1 Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted September 15, 2023 Share Posted September 15, 2023 Also, if you are using the IntyBASIC SDK (and if not, why?), take a look at the “constants.bas” library module. It contains an entire suite of constants representing the various bit-fields, memory addresses, and other useful numbers in the Intellivision architecture. You can use these to compose the various values required by your program to handle graphics, sound, etc. The idea is to completely eliminate magic numbers and make your code easier to read. For instance, that example you got from the book, could have easily been written as #Backtab(c) = GRAM + CS_WHITE + BG05 (That’s off the top of my head, so I may have gotten the picture constant wrong). It should then be more clear that it is setting background picture #5 from GRAM, with a foreground color of white. dZ. 1 Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted September 15, 2023 Share Posted September 15, 2023 One last thing, just because I do know really know your level of expertise, so I want make sure I do not mislead you. Adding constants together to compose a full bit-field string works just as long as the fields themselves are set to zero. In other words, adding CS_WHITE + GRAM only works because the values do not overlap, and therefore will only fall on their specific slots. Technically, you are performing a bitwise OR operation; it’s just that adding ones to zeroes will give you the same result. The reason we do that is because the OR operator does not exist in the Intellivision machine language, so we use addition instead in these narrow circumstances. (The compiler does support the OR operator, but if you are operating on anything other than actual constant values, the compiler will generate extra code to contrive an OR operation out of other machine instructions.) However, sometimes you need to change the value of a field, and in most of those cases you do not know what is there already. Adding a new value then would actually add the bits together, which may not give you the result you want. Neither would OR’ing the value. For those cases, you will need to first clear the field using a bitmask, and then add the new value. That is a separate topic, which you could post as a new question if you ever need it. I just wanted to clear up that adding the field values together is a proxy for an OR operation, which is not supported natively by the Intellivision; and that it only works if the bits of the values do not overlap, and their fields are already zero. dZ. 1 Quote Link to comment Share on other sites More sharing options...
Alkadian Posted September 15, 2023 Author Share Posted September 15, 2023 3 hours ago, DZ-Jay said: Also, if you are using the IntyBASIC SDK (and if not, why?), take a look at the “constants.bas” library module. It contains an entire suite of constants representing the various bit-fields, memory addresses, and other useful numbers in the Intellivision architecture. You can use these to compose the various values required by your program to handle graphics, sound, etc. The idea is to completely eliminate magic numbers and make your code easier to read. For instance, that example you got from the book, could have easily been written as #Backtab(c) = GRAM + CS_WHITE + BG05 (That’s off the top of my head, so I may have gotten the picture constant wrong). It should then be more clear that it is setting background picture #5 from GRAM, with a foreground color of white. dZ. Brilliant, many thanks! I will definetely look at the SDK. It is so exciting learning new things! 1 Quote Link to comment Share on other sites More sharing options...
Alkadian Posted September 15, 2023 Author Share Posted September 15, 2023 (edited) 3 hours ago, DZ-Jay said: One last thing, just because I do know really know your level of expertise, so I want make sure I do not mislead you. Adding constants together to compose a full bit-field string works just as long as the fields themselves are set to zero. In other words, adding CS_WHITE + GRAM only works because the values do not overlap, and therefore will only fall on their specific slots. Technically, you are performing a bitwise OR operation; it’s just that adding ones to zeroes will give you the same result. The reason we do that is because the OR operator does not exist in the Intellivision machine language, so we use addition instead in these narrow circumstances. (The compiler does support the OR operator, but if you are operating on anything other than actual constant values, the compiler will generate extra code to contrive an OR operation out of other machine instructions.) However, sometimes you need to change the value of a field, and in most of those cases you do not know what is there already. Adding a new value then would actually add the bits together, which may not give you the result you want. Neither would OR’ing the value. For those cases, you will need to first clear the field using a bitmask, and then add the new value. That is a separate topic, which you could post as a new question if you ever need it. I just wanted to clear up that adding the field values together is a proxy for an OR operation, which is not supported natively by the Intellivision; and that it only works if the bits of the values do not overlap, and their fields are already zero. dZ. Super, many thanks for your further notes!! I am so glad it is weekend so that I can digest it all properly and keep practising it till I can get a working game logic. You guys are rocking out in this forum. The knowlodge and expertise is superb! I am proud to be just a member! Programming the Intellivision brings me back to the old and good happy days when I was a kid! Edited September 15, 2023 by Alkadian Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted September 15, 2023 Share Posted September 15, 2023 2 hours ago, Alkadian said: Super, many thanks for your further notes!! I am so glad it is weekend so that I can digest it all properly and keep practising it till I can get a working game logic. You guys are rocking out in this forum. The knowlodge and expertise is superb! I am proud to be just a member! Programming the Intellivision brings me back to the old and good happy days when I was a kid! Well, if all my long-winded technical blather helps anybody make cool games, then by George I'll keep on rambling until the cows come home! 😁 Seriously, feel free to ask anything here. I look forward to seeing what you come up with! 👍🏻 dZ. Quote Link to comment Share on other sites More sharing options...
Alkadian Posted September 15, 2023 Author Share Posted September 15, 2023 1 hour ago, DZ-Jay said: Well, if all my long-winded technical blather helps anybody make cool games, then by George I'll keep on rambling until the cows come home! 😁 Seriously, feel free to ask anything here. I look forward to seeing what you come up with! 👍🏻 dZ. ..lol.. Many thanks. Very much appreciated! That's the plan: 1. Finish reading both Oscar's books. 2. Keep reading threads in the forum. 3. Learn more about the CP1600 architecture and its instructions. So lots of fun Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted September 15, 2023 Share Posted September 15, 2023 2 hours ago, Alkadian said: ..lol.. Many thanks. Very much appreciated! That's the plan: 1. Finish reading both Oscar's books. 2. Keep reading threads in the forum. 3. Learn more about the CP1600 architecture and its instructions. So lots of fun May I suggest that, rather than just reading the books, just jump right in and start working on a project (while you read them). It doesn't have to be anything big or fancy -- as a matter of fact, you'll probably end up throwing it away as you learn more and figure out better techniques. The CP-1600 architecture and instruction set will become apparent to you in due time. After all, experience is the best teacher. Even if you stumble along the way, there are plenty of knowledgeable people here to help. You can post your progress, ask for help or suggestions, or just share what you've learned so far. It's all fair game and everyone will get a kick out of it. -dZ. Quote Link to comment Share on other sites More sharing options...
Alkadian Posted September 16, 2023 Author Share Posted September 16, 2023 10 hours ago, DZ-Jay said: May I suggest that, rather than just reading the books, just jump right in and start working on a project (while you read them). It doesn't have to be anything big or fancy -- as a matter of fact, you'll probably end up throwing it away as you learn more and figure out better techniques. The CP-1600 architecture and instruction set will become apparent to you in due time. After all, experience is the best teacher. Even if you stumble along the way, there are plenty of knowledgeable people here to help. You can post your progress, ask for help or suggestions, or just share what you've learned so far. It's all fair game and everyone will get a kick out of it. -dZ. Hi there dZ, You know what? Your kind suggestion makes absolutely sense to me! I have been spending all day today looking at the examples in the SDK folder to start learning the basic programming techniques! Thanks a lot for your patience! 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.