Prev: 61466 Up: Map Next: 61567
61483: Main loop
61483 CALL 61440 Close any doors that need closing, decrement and check the blown fuse delay counters, update the on-screen message if necessary, and increment the score and decrement Sam's cash supply at regular intervals
61486 CALL 61568 Update the icon panel, draw the bullets, and scan the event table at 24544
61489 CALL 61948 Move the characters
61492 LD A,(32764) Pick up Sam's status flags from 32764
61495 AND A Is Sam in the middle of an action?
61496 JR Z,61509 Jump if not
61498 CALL 29912 Otherwise deal with Sam
61501 JR NZ,61549 Jump if Sam has not finished the action yet
This entry point is used by the routines at 24914 and 61630.
61503 LD HL,5 Reset Sam's main action timer and midstride/mid-action timer (in bytes 8 and 9 of his buffer) to 5 and 0 now that he's finished the action
61506 LD (58888),HL
61509 LD HL,58889 Collect Sam's midstride/mid-action timer from byte 9 of his buffer
61512 LD A,(HL)
61513 AND A Is Sam midstride or in the middle of a short action at the moment?
61514 JR NZ,61545 Jump if so
61516 DEC L Point HL at Sam's main action timer in byte 8 of his buffer
61517 DEC (HL) Decrement it
61518 JR NZ,61549 Jump unless it's time to check the keyboard
61520 LD (HL),2 Reset Sam's main action timer to 2
61522 CALL 31126 Check for keypresses
61525 JR Z,61549 Jump if there haven't been any
61527 LD (32765),A Store the offset of the last keypress in 32765
61530 LD H,237 Point HL at the appropriate entry in the table of keypress handling routines at 60672
61532 LD L,A
61533 LD DE,61549 Push the address 61549 (see below) onto the stack so we return there after dealing with the keypress
61536 PUSH DE
61537 LD B,(HL) Copy the address of the routine for dealing with the keypress into BC
61538 DEC L
61539 LD C,(HL)
61540 PUSH BC Push this address onto the stack
61541 LD HL,58880 Point HL at byte 0 of Sam's buffer
61544 RET Make an indirect jump to the relevant keypress-handling routine, and then return to 61549
Sam is midstride or in the middle of a short action (which involves raising his arm or bending his knees) at the moment.
61545 DEC (HL) Decrement Sam's midstride/mid-action timer in byte 9 of his buffer
61546 CALL Z,60539 If it's now zero, move Sam from the midstride/mid-action position, update the SRB, and scroll the screen if necessary
Now that Sam's movements have been dealt with, the main loop continues.
61549 CALL 60032 Update the display
This next section of code ensures that we don't pass through the main loop more than once every 1/50th of a second.
61552 LD HL,32712 HL=32712 (which holds the LSB of the system variable FRAMES as it was when the last pass through the main loop was completed)
61555 LD A,(23672) A=LSB of the system variable FRAMES, which is incremented every 1/50th of a second
61558 SUB (HL) Now A=0 if FRAMES hasn't been incremented since the last pass through the main loop
61559 CP 1 Was FRAMES incremented?
61561 JR C,61555 Jump back if not to check again
61563 ADD A,(HL) Store the current value of the LSB of FRAMES at 32712
61564 LD (HL),A
61565 JR 61483 Jump back to the start of the main loop
Prev: 61466 Up: Map Next: 61567