Jump to content
Jet Set Willy & Manic Miner Community

The AND, OR and XOR instructions


jetsetdanny

Recommended Posts

'AND #C0' sets the zero flag if A holds any value from 0 to 63 (00-3F), and 'AND #E0' sets the zero flag if A holds any value from 0 to 31 (00-1F).

 

Note that you can't use 'AND N-1' to set the zero flag on every Nth pass through a loop that increments A unless N is 1, 2, 4, 8, 16, 32, 64, 128 or 256.

Or to put it in a way that's easy to follow during the game by watching the 'lives' indicator dancing in the status bar (assuming that the in-game music is on):

 

With the AND C0 instruction in effect, whatever the thing that the PV makes happen, occurs [or doesn't occur, depending on the polarity of the 'check'] every tick during the first half of the first rendition of 'Rich Man' in every 256-tick cycle (sixteen 'dance steps'), and then doesn't occur [or does!] during the second half of the tune and throughout the next full tune rendition. Then the effect resumes at the beginning of the third rendition of the tune (lasting again for half the tune's length).

 

AND E0 means that the effect only lasts [or is disabled] for the first quarter of the tune (eight 'dance steps').

 

N.B. Willy's lives make 64 dance steps (progressing through the four frames of animation sixteen times) during each 256-tick game cycle.

Edited by IRF
Link to comment
Share on other sites

Danny, I forgot to mention that when I set the operand of the AND command to D0, I altered it from the original value which you had set of E0, which is one of the values that you mentioned at the start of this thread - and that's what made me wonder if it was indeed the Screen Flash Patch Vector that you were having trouble summarising in the readme?

 

It is the Screen Flash PV (which I call the Flashing Screen PV in "WNM SE"'s Readme), indeed, and its cousin, the Coloured Screen PV.

 

I offer a disassembly of all of my PVs in the Readme, and these two go as quoted below.

 

 

The descriptions in red are obviously wrong and need to be modified. If you have any suggestions as to what specifically should be put / would make sense there, please let me know  :) .

 

 

Flashing Screen

 

This PV works by setting the value of the screen flash counter and thus activating the screen flash routine (which is unused in the original "JSW", where it resides at #8A11

Link to comment
Share on other sites

Danny, I believe both PV's amount to the same thing, except that one lasts longer than the other (due to the C0 versus E0 operand), one 'hardly flashes' because the value of another variable is set so low (thus when it is loaded up to the Screen Flash Counter, it doesn't take long to decrement to zero), and of course you've modified one version so it can be adapted differently for different rooms.

 

But I think they're the same in essence. It's late now but I'll try and give a detailed description of how they work tomorrow.

 

For now, I'll just point out that the reason you need to add 1 to your chosen colour value, is because the original Screen Flash routine decrements the current value of A immediately before loading it up to the Screen Flash Counter variable, so you're effectively countering that.

Edited by IRF
Link to comment
Share on other sites

Danny, at the start of this thread you seemed to suggest that these routines of yours didn't quite do what you had originally anticipated?  I wonder if the following alternative code implements what you were initially trying to achieve?  (I understand you're happy with the resulting product that you ended up with, so this is purely for the point of academic discussion.)

 

3A CB 85 - LD A, (#85CB) - load the 'tick counter' to the A register

E6 1F - AND #1F - the AND operand (00011111 in binary) is 255 (#FF) minus your chosen operand of 224 (#E0)

C8 - RET Z - note that the conditionality of the check upon which the Return command is based, is the opposite to the C0 command in your PV

3A CD 85 - LD A, (#85CD) - load the current value of the Screen Flash Counter from #85CD to the A register

3C - INC A - increment the A register by one

32 CD 85 - load the value of the A register back to the Screen Flash Counter at #85CD

C9 - RETURN

 

(With the value of the Screen Flash Counter at #85CD initialised to a high value such as #FF, so the Screen Flash effect can be witnessed for a long period.)

 

The above has the effect of slowing down the screen flash routine, so that the colour change only happens once every 32 'ticks' (or every 8 'dance steps'), instead of every tick.  Other than the speed, it cycles through the colours in the usual way.

 

If the operand of the AND command was set to #3F (which is 255 minus 192, or #FF minus #C0 which was your other chosen value for the AND operand), then the colour change would occur every 64 ticks.

 

Furthermore, AND 0F would cause the screen colour to change every 16 ticks; AND 07 every 8 ticks; AND 03 every 4 ticks; AND 01 every 2 ticks; AND #7F every 128 ticks.

 

I still intend to provide a detailed explanation of how it all works, but hopefully the above gives you some insight!

Edited by IRF
Link to comment
Share on other sites

  • 3 weeks later...

Danny, did you pick up the document I forwarded via a PM (it fell at the end of a 'page' of messages so you may have missed it).

 

If so, did it help you to formulate the appropriate words for your readme?

 

Not yet, but I am aware of it and I will work on it when I'm done with the code in "WNM SE", which should be very soon, hopefully.

 

Thanks in advance for the document  :) .

Link to comment
Share on other sites

  • 5 months later...

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

Important Information

By using this site, you agree to our Terms of Use.