Jump to content

lives minikernel weirdness


Recommended Posts

Can anyone explain why, in the following code, does lives=lives-16 gets rid of one life instead of lives=lives-32? And while you're at it, make the cars never stop. ;)


The lives variable is actually two variables in one. The top three bits are the number of lives. and the bottom five bits are a pointer to the sprite data, like so:


128 64 32 16 8 4 2 1

| Lives | Pointer |



If the pointer data happens to be less than 15, then subtracting sixteen will cause a carry, which will then subtract 1 from the Lives portion. Of course this should also mess up your Pointer and make the sprite look all wrong.


Why did you use =16 anyway?

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.

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...