Do events have (unimplemented) timers?

Questions like: "I can't find the sword" should go here.
Post Reply
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5760
Joined: April 9th, 2009, 10:58 pm

Do events have (unimplemented) timers?

Post by Norbert »

While browsing through my leapop code, I noticed that it combines bits 3-7 of the 2nd events byte for an events timer (arEventsTimer). The code never uses this timer though. The timer appears to be either 0 or 31 (ignoring 9x other values). And 31 is used only for unused events, starting in level 4 for events 41-56. Did we ever discuss this timer on the forum? I do not recall how I even know it's a "timer", it's not documented as such in poirot's specs either.
David
The Prince of Persia
The Prince of Persia
Posts: 2860
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Do events have (unimplemented) timers?

Post by David »

Norbert wrote: January 18th, 2023, 4:47 pm While browsing through my leapop code, I noticed that it combines bits 3-7 of the 2nd events byte for an events timer (arEventsTimer).
[...]
I do not recall how I even know it's a "timer", it's not documented as such in poirot's specs either.
It may come from the SDLPoP source?
https://github.com/NagyD/SDLPoP/blob/80 ... #L713-L722

Or from Mechner's notes for the Apple II PoP source?
https://github.com/jmechner/Prince-of-P ... #L304-L306

Or here?
viewtopic.php?p=14795#p14795


The timer bits are used for deciding if a button with this modifier should be drawn pressed or not.
https://github.com/NagyD/SDLPoP/blob/80 ... #L252-L264
It timer > 1, then the button is drawn pressed.

The timer is decremented in every frame.
https://github.com/NagyD/SDLPoP/blob/80 ... #L783-L786

What I don't know is where is it set to 31 (0x1F) which means "jammed".
https://github.com/NagyD/SDLPoP/blob/80 ... #L752-L756
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5760
Joined: April 9th, 2009, 10:58 pm

Re: Do events have (unimplemented) timers?

Post by Norbert »

David wrote: January 21st, 2023, 4:38 pmIt may come from the SDLPoP source?
https://github.com/NagyD/SDLPoP/blob/80 ... #L713-L722

Or from Mechner's notes for the Apple II PoP source?
https://github.com/jmechner/Prince-of-P ... #L304-L306

Or here?
viewtopic.php?p=14795#p14795
Thanks for the guesses, but I don't think I learned about it from any of these places.
David wrote: January 21st, 2023, 4:38 pmWhat I don't know is where is it set to 31 (0x1F) which means "jammed".
When a guard dies on a drop button? (I didn't look at the code. Just a guess.)
David
The Prince of Persia
The Prince of Persia
Posts: 2860
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Do events have (unimplemented) timers?

Post by David »

Norbert wrote: January 21st, 2023, 9:57 pm
David wrote: January 21st, 2023, 4:38 pmWhat I don't know is where is it set to 31 (0x1F) which means "jammed".
When a guard dies on a drop button? (I didn't look at the code. Just a guess.)
That would be logical, but I can't find any call to set_doorlink_timer() which could to that.

I added a debug printout in animate_button(), before set_doorlink_timer(), to see if perhaps the timer decreases from 0 to -1 and causes an integer overflow.
It doesn't.

Code: Select all

		word timer = get_doorlink_timer(curr_modifier) - 1;
		printf("animate_button: curr_modifier = %d, timer = %d\n", curr_modifier, timer);
		set_doorlink_timer(curr_modifier, timer);
I also added a debug printout in trigger_button(), before the jammed check.

Code: Select all

	sbyte link_timer = get_doorlink_timer(modifier);
	printf("trigger_button: modifier = %d, link_timer = %d\n", modifier, link_timer);
	// is the event jammed?
	if (link_timer != 0x1F) {
The link timer always stays in the 0..5 range.
Post Reply