Jump to content
IGNORED

how does this program know "smiling_face" is a SPRITE 0


Recommended Posts

Hi everyone, so i have this code example from the intybasic book..   I'm hopping @nanochess doesn't mind me quoting examples from the book..  this is all stuff I have typed out myself. 

 

so the original main_loop has one approach to how the smiling face moves.. it uses something called #backtab..  and some other values..  

 

 

    ' Example 1
  

    CLS ' Clears the screen
    DEFINE 5,1,smiling_face ' Define card 5 as a smiling face

    C = 0

 

main_loop:
    #backtab(c) = $807 + 5 * 8 ' Place it on the screen
    wait ' wait for a frame
    wait ' wait for a frame
    wait ' wait for a frame
    wait ' wait for a frame
    wait ' wait for a frame
    #backtab(c) = 0           ' remove it from the screen
    c = c + 1           ' Increase value of the C by 1
    IF c = 240 THEN c = 0        ' If c equals 240 then make it zero
    GOTO main_loop

 

smiling_face:
    BITMAP "..XXXX.."
    BITMAP ".X....X."
    BITMAP "x.x..x.x"
    BITMAP "x......x"
    BITMAP "x.x..x.x"
    BITMAP "x..xx..x"
    BITMAP ".x....x."
    BITMAP "..xxxx.."

 

 

 

but then in sample too it calls on sprite 0 and some other values but in this new example (which does work) i'm not clear i get how SPTIE 0 is associated with smiling_face

 

    ' Example 2
    
    CLS ' Clears the screen
    DEFINE 5,1,smiling_face ' Define card 5 as a smiling face

    C = 0

 

main_loop:
    SPRITE 0, $0300 + c, $100 + 8, $0807 + 5 * 8
    wait ' wait for a frame

    c = c + 1           ' Increase value of the C by 1
    IF c = 240 THEN c = 0        ' If c equals 240 then make it zero
    GOTO main_loop

 

Link to comment
Share on other sites

ok interesting..  so if i change:

 

DEFINE 5,1,smiling_face ' Define card 5 as a smiling face 

 

to 

 

DEFINE 4,1,smiling_face ' Define card 4 as a smiling face

 

i did test it and it appeared to work.. doing:

 

main_loop:
    SPRITE 0, $0300 + c, $100 + 8, $0807 + 4 * 8
 

i'm just wondering now why the example would have chosen 5 and not say.. 0 or 1.. or 4.. or any other number? is it a best practice thing or something else?  

 

 

Link to comment
Share on other sites

I suppose 5 makes up for a better example than 0, since 0*8 = 0 and it wouldn't be as clear. 1 would work too but a bigger number probably makes it more obvious.

 

Btw, the X coordinate goes up to 168 but I suppose values up to 240 won't make any bad impact since the interaction bit is #8 = 256 (hex $0100 which is part of the $0300 constant).

Link to comment
Share on other sites

Why multiplied by 8, you may ask?  It's because the card index field in a BACKTAB word, or in a Sprite's Attrubute register, is offset by three bits from the right.

 

For instance, the BACKTAB word is a 16-bit record where various groups of bits, or fields, represent the background card attributes, as illustrated below (highlighted in green):


Color Stack Mode (Mode #0):

image.thumb.png.cf65f87e4b98d5aaeb5a5e5b6ab3baf8.png


Foreground/Background Mode (Mode #1):

image.thumb.png.882e911d10c4f05f724ec5a7b59d55b0.png


 

This means that you must shift the card index by three bits to the left.  This is the same as multiplying the index by 23, or 8.


The Attributes register of a MOB is laid out in a similar way.


In fact, the all arguments to the SPRITE statement are expression to assign values to the three main MOB registers: X (position), Y (position), and A (attributes), respectively.


I'm sure the book describes all this, and you can find additional details in the Intellivision Wiki, which is whence I took those images.
 

   dZ.

Edited by DZ-Jay
Link to comment
Share on other sites

I tend to write thinking in different people.

 

Some people likes to find nitpicks and learns through it. So the 5 was choosen to differ from all other constants in the program.

 

Other people learns by reading the text of the book, and put little to none attention to source code.

 

And other people will refer to it because the DEFINE statement, but one way or other the people learns ;)

 

 

Edited by nanochess
Link to comment
Share on other sites

7 hours ago, carlsson said:

168 but I suppose values up to 240

well in the prior version it was 240 because of the cards..  when they had us switch to a sprite but didn't change that value..   I later changed the value to "IF c = 167 THEN c = 0" to create a nice seamless sprite roll over.. this allows the sprite to leave the screen and smoothly come back on the screen.  

 

7 hours ago, artrag said:

No idea why, but if you read the book probably you will find Oscar is explaining how sprite parameters work and how gram positions are used by sprites

it's true the book explains things, but not every aspect of everything.  i'm taking my time and picking each part apart to make sure i don't just do it, i want to understand things more thoroughly.  the book would probably be 3x larger if it was written for me.. lol :)

 

5 hours ago, DZ-Jay said:

is means that you must shift the c

I appreciate the breakdown!   I know at some point i'll be coming back to this, so it's not information i can avoid for long.

 

4 hours ago, nanochess said:

I tend to write thinking in different people.

yea believe me i'm dense.. i have to beat concepts into my head over and over for them to stick..  i've struggled for years learning to program and i think most people "just get it" the first time.. and concepts just soak in, but for me i have to just really don't do well when i "skip ahead"..  but then i have to be sure not to overwhelm either (like DZ-Jay's fantastic breakdown).  So yea i'm loving this book and I'm grateful for this form (and that you're on it @nanochess !)  i'm loving the book and i can't wait to comprehend it and get the second book and forge ahead!   I'm typing this with the book in my lap and i'm working on the controller example next. 

 

my next challenge is seeing how to get my ultimate pc interface to work with jzintv..  i have openemu which configures easy and i tested one of my roms with it so it ran fine.  just not sure how it's done yet.  have to look up some info on it.  

  • Like 1
Link to comment
Share on other sites

For what it's worth, I am also slow to grasp complex subjects.  I just have been doing Intellivision programming for over 10 years now, so I get a sizable bit of it now.

 

In my explanations, I aim to break down concepts into smaller bits and explain them in greater detail, little by little, and going down to first principles -- mostly because that is how I learn things myself.  I also try to include why things are like they are, also because that is what would help me.


As long as it is useful to someone, I don't mind doing so.  :)

 

   dZ.

Link to comment
Share on other sites

actually i'm happy to report the ultimate game controller "just works" thank god!  i was able to move my happy face around successfully.  

 

Screenflick Movie 2.gif

 

11 minutes ago, DZ-Jay said:

break down concepts

 

absolutely, i'm sure i'm going to be back at these threads soon about this stuff because i know it's a core concept to how pretty much everything works with the graphics in intellivision!  

 

11 minutes ago, DZ-Jay said:

As long as it is useful to someone

absolutely!  you all have been incredibly supportive!   

 

Edited by Caleb Garner
  • Like 2
Link to comment
Share on other sites

10 hours ago, Caleb Garner said:

game controller "just works" thank god!

well i spoke too soon.. the disk works, but the keypad / side buttons are not responding.  I'll have to dig deeper to figure out how it works.  i mean for quick testing i can see how the keyboard is configured.  Just be nice to test with a real controller..  i'm using my second sears game controller.  

Link to comment
Share on other sites

Also, as long as you are doing things by hand, you can explore the SDK-1600 (the distribution that includes the jzIntv emulator and as1600 assembler) for sample programs in the “examples” folder.

 

I believe there is one program in there for testing the hand-controllers.  It is an Assembly Language program (as is everything in that distribution), so you will have to assemble it into a binary first.


And, like @artrag mentioned, you should review the documents in the “docs” folder in that distribution, which provide extensive technical details about the hardware components.

 

Specifically, you should check out the files for “stict.txt” and “psg.txt” for insight into the video and sound devices, respectively.

 

Those documents are also available in the IntyBASIC SDK installation, within the “Documents” folder; and in the Intellivision Wiki referenced earlier.

 

     dZ.

Edited by DZ-Jay
Link to comment
Share on other sites

On 8/29/2021 at 9:48 AM, Caleb Garner said:

i'm just wondering now why the example would have chosen 5 and not say.. 0 or 1.. or 4.. or any other number? is it a best practice thing or something else?  

Actually, the topic of any best practices that might exist when it comes to choosing where to load things on GRAM is an interesting one. At least for more complex programs.

But I'd say that is not something you need to worry too much about for now.

Edited by cmadruga
Link to comment
Share on other sites

On 8/29/2021 at 2:30 PM, nanochess said:

I tend to write thinking in different people.

 

Some people likes to find nitpicks and learns through it. So the 5 was choosen to differ from all other constants in the program.

 

Other people learns by reading the text of the book, and put little to none attention to source code.

 

And other people will refer to it because the DEFINE statement, but one way or other the people learns ;)

 

 

and then some of us are just really SLOW learners.....  :)   

 

your code for PUMPKINS is really helping me at the moment, but man the code to do enemy patterns is daunting stuff. 

  • Like 1
Link to comment
Share on other sites

9 minutes ago, Mik's Arcade said:

some of us are just really SLOW learners

I'm definitely not a sponge.. i have to beat this stuff into my head and probably ask things more than once sometimes..  

 

I don't envy what you must be figuring out with enemy movement.. i know i'm going to have my work cut out for me for I, Killbot and Road Defender.  

Link to comment
Share on other sites

23 hours ago, Caleb Garner said:

I'm definitely not a sponge.. i have to beat this stuff into my head and probably ask things more than once sometimes..  

 

I don't envy what you must be figuring out with enemy movement.. i know i'm going to have my work cut out for me for I, Killbot and Road Defender.  

yeah, the problem is we have all the ideas, but lack the programming chops to back it up.  Plus, we are working with limitations as well.  My first game was way too complicated for me to try.  I need to keep it simple and make a few basic games before i get into the more creative projects.  baby steps...haha.  I go through ebbs and flows. I need to do consistent work. I'll go a over a week without doing anything and then carve out only a couple of hours on a weekend.  I can't do those marathon coding sessions like I did back in my high school days.

 

good luck!

Link to comment
Share on other sites

16 minutes ago, Mik's Arcade said:

lack the programming chops to back it up. 

indeed.. i'm chewing on this pong game.. discouraging when you can't even figure out why something is orange (9?) when there's only 3 9's in the whole body of code and none of them effect the paddle color.. lol..  but not discouraged, just humbled and staying at it till i figure it out.  :)

 

 

Screen Shot 2021-09-02 at 9.08.17 PM.png

Link to comment
Share on other sites

14 minutes ago, Caleb Garner said:

indeed.. i'm chewing on this pong game.. discouraging when you can't even figure out why something is orange (9?) when there's only 3 9's in the whole body of code and none of them effect the paddle color.. lol..  but not discouraged, just humbled and staying at it till i figure it out.  :)

 

 

Screen Shot 2021-09-02 at 9.08.17 PM.png

Show some code, and perhaps someone may be able to answer the question.

Link to comment
Share on other sites

7 minutes ago, DZ-Jay said:

Show some code,

ok here goes! :)   I figured out the color thing..  so it's in the sprite (which makes sense) but i don't really understand this well..  but i know more in the book will explain it so i'll be patient..  i haven't explored the sprite stuff but i understand somehow you can add parameters together and the total will give the desired result..  that will take some rote practice to feel that one out.  

 

    SPRITE 0, $0708 + x1, $0208 + y1, $0800 + 5 * 8 + 2    ' the 2 is (bad) red and 3 is the light green.  
    SPRITE 1, $0708 + x2, $0208 + y2, $0800 + 5 * 8 + 3

 

    PRINT AT 27 COLOR 2,<>score1                    ' left score 
    PRINT AT 31 COLOR 3,<>score2                    ' right score

 

 

 

Screen Shot 2021-09-02 at 9.44.18 PM.png

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