Jump to content
IGNORED

Backtab clarifications


Alkadian

Recommended Posts

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!

Link to comment
Share on other sites

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

  • Thanks 1
Link to comment
Share on other sites

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!

  • Like 1
Link to comment
Share on other sites

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.

  • Thanks 1
Link to comment
Share on other sites

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.

 

 

  • Thanks 1
Link to comment
Share on other sites

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! 

  • Like 1
Link to comment
Share on other sites

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 by Alkadian
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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! :)

  • Like 1
Link to comment
Share on other sites

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