Prev: 56040 Up: Map Next: 56150
56047: Parse A Time
Used by the routine at TestCommonWord.
Reads hours, an optional ":" and minutes into B/C, then an "A" or "P" plus "M" suffix. "A" sets bit 6 of B; "P" sets bit 6 of C for PM.
ParseATime 56047 CALL ParseInputNumber Call ParseInputNumber to start from an empty length.
56050 LD B,A Jump ahead to ParseATime_CheckHours if this byte is 58.
56051 LD A,(HL)
56052 CP 58
56054 JR Z,ParseATime_CheckHours
56056 CP 65 Jump ahead to ParseATime_CheckHours when the input character is A.
56058 JR Z,ParseATime_CheckHours
56060 CP 80 Jump ahead to ParseATime_CheckHours when the input character is P.
56062 JR Z,ParseATime_CheckHours
56064 CALL TestFullStop_TestReturnsCharacterSentence Jump ahead to StartParsedNumber unless the character is a full stop, a comma or a space.
56067 JR NZ,StartParsedNumber
ParseATime_CheckHours 56069 LD A,B Jump ahead to ParseATime_SignalNothingMatched if the count is at least 60.
56070 CP 60
56072 JR NC,ParseATime_SignalNothingMatched
56074 SET 7,B Set bit 7 of the count.
56076 LD C,0 Start the number at zero, read the input character, and parse it.
56078 LD A,(HL)
56079 CALL TestFullStop_TestReturnsCharacterSentence
56082 JR Z,TestComma_0 Go to TestComma_0 if the character is a full stop, a comma or a space.
ParseATime_ReadMinutes 56084 CP 58 Jump ahead to ParseATime_CheckSuffix if the character is not 58.
56086 JR NZ,ParseATime_CheckSuffix
56088 INC HL Step to the next character and call ParseInputNumber to read a number.
56089 CALL ParseInputNumber
56092 LD C,A Jump ahead to ParseATime_SignalNothingMatched if the number is at least 60.
56093 CP 60
56095 JR NC,ParseATime_SignalNothingMatched
ParseATime_CheckSuffix 56097 LD A,(HL) Jump ahead to TestComma_0 if the character is a full stop, a comma or a space.
56098 CALL TestFullStop_TestReturnsCharacterSentence
56101 JR Z,TestComma_0
56103 CP 65 Jump ahead to ParseATime_AMPM if the character is not 65.
56105 JR NZ,ParseATime_AMPM
56107 SET 6,B Set bit 6 of the count.
56109 INC HL Step to the next input character and continue at ParseATime_CheckM.
56110 JR ParseATime_CheckM
Accept "AM" or "PM": "A" has already set bit 6 of B, and "P" sets bit 6 of C for PM; both then require "M".
ParseATime_AMPM 56112 CP 80 Jump ahead to ParseATime_SignalNothingMatched if the character is not 80.
56114 JR NZ,ParseATime_SignalNothingMatched
56116 SET 6,C Set bit 6 of C for PM and step to the next character.
56118 INC HL
ParseATime_CheckM 56119 LD A,(HL) Jump ahead to ParseATime_SignalNothingMatched if this byte is not 77.
56120 CP 77
56122 JR NZ,ParseATime_SignalNothingMatched
ParseATime_TestStepEntry 56124 INC HL Step to the next entry.
This entry point is used by the routine at StartParsedNumber.
ParseATime_0 56125 LD A,(HL) Jump back to ParseATime_TestStepEntry if this byte is 46.
56126 CP 46
56128 JR Z,ParseATime_TestStepEntry
56130 CALL TestComma Jump ahead to TestComma_0 if the character is a comma or a space.
56133 JR Z,TestComma_0
56135 CP 13 Jump to TestComma_TestStepOneByte if the player pressed "ENTER".
56137 JR Z,TestComma_TestStepOneByte
56139 CP 34 Jump ahead to TestComma_TestStepOneByte if the character is 34.
56141 JR Z,TestComma_TestStepOneByte
This entry point is used by the routine at StartParsedNumber.
ParseATime_SignalNothingMatched 56143 XOR A Set the zero flag.
56144 LD A,208 Leave 208 as the result.
56146 LD BC,0 Clear BC (no time was given).
56149 RET Return.
Prev: 56040 Up: Map Next: 56150