Prev: 48320 Up: Map Next: 48466
48330: Handle Crosshair
Type 3: the crosshair, which the player moves about the screen in the duel to aim at the outlaw. It is moved by the controls, and stays between limits. When the fire control is pressed it fires the revolver.
Reload the revolver if it needs it.
HandleCrosshair 48330 CALL ReloadRevolver Call ReloadRevolver.
48333 LD L,(IX+2) Fetch the horizontal position into L.
48336 LD H,(IX+4) Fetch the vertical position into H.
48339 LD E,(IX+5) Fetch the speed into E.
Read the controls.
48342 CALL ReadControls Call ReadControls.
Move left or right, but not past the edges.
48345 LD A,B Fetch the controls into A.
48346 AND %00000011 Keep the two bits.
48348 JR Z,HandleCrosshair_Vertical Jump to HandleCrosshair_Vertical if neither or both are pressed.
48350 CP 3 Jump to HandleCrosshair_Vertical if both are pressed.
48352 JR Z,HandleCrosshair_Vertical
48354 CP 1 Jump to MoveCrosshairLeft to move left if left is pressed.
48356 JR Z,MoveCrosshairLeft
48358 LD A,L Fetch the horizontal position.
48359 ADD A,E Add the speed.
48360 CP 197 Jump to HandleCrosshair_SetHorizontal if the crosshair is not past it.
48362 JR C,HandleCrosshair_SetHorizontal
48364 LD A,196 Stop at the right limit.
This entry point is used by the routine at MoveCrosshairLeft.
HandleCrosshair_SetHorizontal 48366 LD L,A Set the horizontal position.
See whether the controls are the keyboard.
HandleCrosshair_Vertical 48367 LD A,(41500) Fetch Options.
48370 RRCA Move the bits for the controls into the low bits.
48371 AND %00000011 Keep the two bits.
48373 JP Z,HandleCrosshair_Keyboard Jump to HandleCrosshair_Keyboard if the controls are the keyboard.
Copy the joystick bits for up, down and fire into B.
48376 LD A,B Fetch the controls into A.
48377 LD B,0 Clear B.
48379 BIT 2,A Jump to HandleCrosshair_TestDown if up is not pressed.
48381 JR Z,HandleCrosshair_TestDown
48383 SET 1,B Set the bit for up.
HandleCrosshair_TestDown 48385 BIT 4,A Jump to HandleCrosshair_TestFire if down is not pressed.
48387 JR Z,HandleCrosshair_TestFire
48389 SET 0,B Set the bit for down.
HandleCrosshair_TestFire 48391 BIT 3,A Jump to HandleCrosshair_MoveVertical if the fire control is not pressed.
48393 JR Z,HandleCrosshair_MoveVertical
48395 SET 3,B Set the bit for fire.
Move up or down, but not past the edges.
HandleCrosshair_MoveVertical 48397 LD A,B Fetch the controls.
48398 AND %00000011 Keep the up and down bits.
48400 JR Z,HandleCrosshair_SetPosition Jump to HandleCrosshair_SetPosition if neither or both are pressed.
48402 CP 3 Jump to HandleCrosshair_SetPosition if both are pressed.
48404 JR Z,HandleCrosshair_SetPosition
48406 CP 1 Jump to MoveCrosshairDown to move down if down is pressed.
48408 JR Z,MoveCrosshairDown
48410 LD A,H Fetch the vertical position.
48411 ADD A,E Add the speed.
48412 CP 173 Jump to HandleCrosshair_SetVertical if the crosshair is not past it.
48414 JR C,HandleCrosshair_SetVertical
48416 LD A,172 Stop at the upper limit.
This entry point is used by the routine at MoveCrosshairDown.
HandleCrosshair_SetVertical 48418 LD H,A Set the vertical position.
Store the new position.
HandleCrosshair_SetPosition 48419 LD (IX+2),L Set the horizontal position of the crosshair.
48422 LD (IX+4),H Set the vertical position of the crosshair.
Set the position for drawing.
48425 LD A,H Fetch the vertical position and clear H.
48426 LD H,0
48428 LD (41550),HL Set ScreenHorizontalPosition.
48431 LD L,A Copy the vertical position into L.
48432 LD (41552),HL Set ScreenVerticalPosition.
Fire the revolver if the fire control is pressed, then draw the crosshair.
48435 LD E,B Pass the controls to the routine which fires the revolver.
48436 CALL FireRevolver Call FireRevolver.
48439 JP DrawSpriteList Jump to DrawSpriteList.
The controls are the keyboard, which sets the bits for down and up the other way round to the joysticks.
HandleCrosshair_Keyboard 48442 LD A,B Fetch the controls.
48443 LD B,0 Clear B.
48445 BIT 2,A Jump to HandleCrosshair_KeyboardTestUp if down is not pressed.
48447 JR Z,HandleCrosshair_KeyboardTestUp
48449 SET 0,B Set the bit for down.
HandleCrosshair_KeyboardTestUp 48451 BIT 3,A Jump to HandleCrosshair_KeyboardTestFire if up is not pressed.
48453 JR Z,HandleCrosshair_KeyboardTestFire
48455 SET 1,B Set the bit for up.
HandleCrosshair_KeyboardTestFire 48457 BIT 4,A Jump to HandleCrosshair_KeyboardMove if the fire control is not pressed.
48459 JR Z,HandleCrosshair_KeyboardMove
48461 SET 3,B Set the bit for fire.
Move the crosshair up or down.
HandleCrosshair_KeyboardMove 48463 JP HandleCrosshair_MoveVertical Jump to HandleCrosshair_MoveVertical.
Prev: 48320 Up: Map Next: 48466