Sherlock: annotated disassembly

Routines

Prev: DAE8 Up: Map Next: DB56
DAEF: Read a time, or a number that may turn out to be money
A number followed by ':' (minutes), 'A' or 'P' (then 'M') is a time: B = the hour with bit 7 set and bit 6 for AM, C = the minutes with bit 6 for PM. Anything else goes to the money reader at DB84 (so '2/6' and '3S' need no '£'). Returns A = $F0 for a number token, or $D0 and BC = 0 if it makes no sense.
Input
HL The number
Output
A $F0 (a number) or $D0 (not understood)
B, C The time, or 0
HL Past it
DAEF CALL $DBF7 Call the routine "Read a decimal number at HL into A" (DBF7) - B = the first number (DBF7)
DAF2 LD B,A Copy A into B
DAF3 LD A,(HL) Read the byte HL points at into A - Followed by ':', 'A' or 'P' it is a time; otherwise money (DB56)
DAF4 CP $3A Compare A with $3A
DAF6 JR Z,$DB05 If A equals $3A, skip ahead to DB05
DAF8 CP $41 Compare A with $41
DAFA JR Z,$DB05 If A equals $41, skip ahead to DB05
DAFC CP $50 Compare A with $50
DAFE JR Z,$DB05 If A equals $50, skip ahead to DB05
DB00 CALL $DB56 Call the routine "Is A a separator (full stop, comma or space)? Z if so" (DB56)
DB03 JR NZ,$DB84 If the zero flag is clear, jump on to DB84
DB05 LD A,B Copy B into A - The hour must be below 60 - the same test as the minutes; bit 7 marks it as a time
DB06 CP $3C Compare A with $3C
DB08 JR NC,$DB4F If A is $3C or more, jump on to DB4F
DB0A SET 7,B Set bit 7 of B
DB0C LD C,$00 Load C with $00
DB0E LD A,(HL) Read the byte HL points at into A - ':' and the minutes in C
DB0F CALL $DB56 Call the routine "Is A a separator (full stop, comma or space)? Z if so" (DB56)
DB12 JR Z,$DB60 If the zero flag is set, jump on to DB60
DB14 CP $3A Compare A with $3A
DB16 JR NZ,$DB21 If A differs from $3A, skip ahead to DB21
DB18 INC HL Step HL on to the next byte
DB19 CALL $DBF7 Call the routine "Read a decimal number at HL into A" (DBF7)
DB1C LD C,A Copy A into C
DB1D CP $3C Compare A with $3C
DB1F JR NC,$DB4F If A is $3C or more, jump on to DB4F
DB21 LD A,(HL) Read the byte HL points at into A - 'A': bit 6 of the hour; 'P': bit 6 of the minutes
DB22 CALL $DB56 Call the routine "Is A a separator (full stop, comma or space)? Z if so" (DB56)
DB25 JR Z,$DB60 If the zero flag is set, jump on to DB60
DB27 CP $41 Compare A with $41
DB29 JR NZ,$DB30 If A differs from $41, skip ahead to DB30
DB2B SET 6,B Set bit 6 of B
DB2D INC HL Step HL on to the next byte
DB2E JR $DB37 Skip ahead to DB37
DB30 CP $50 Compare A with $50
DB32 JR NZ,$DB4F If A differs from $50, skip ahead to DB4F
DB34 SET 6,C Set bit 6 of C
DB36 INC HL Step HL on to the next byte
DB37 LD A,(HL) Read the byte HL points at into A - then 'M'
DB38 CP $4D Compare A with $4D
DB3A JR NZ,$DB4F If A differs from $4D, skip ahead to DB4F
DB3C INC HL Step HL on to the next byte - Skip full stops; the time must end the word
This entry point is used by the routine at DB67.
DB3D LD A,(HL) Read the byte HL points at into A
DB3E CP $2E Compare A with $2E
DB40 JR Z,$DB3C If A equals $2E, go back to DB3C
DB42 CALL $DB59 Call DB59 (inside "Is A a separator (full stop, comma or...")
DB45 JR Z,$DB60 If the zero flag is set, skip ahead to DB60
DB47 CP $0D Compare A with $0D
DB49 JR Z,$DB5F If A equals $0D, skip ahead to the routine "Step HL back one and return Z with A = $F0" (DB5F)
DB4B CP $22 Compare A with $22
DB4D JR Z,$DB5F If A equals $22, skip ahead to the routine "Step HL back one and return Z with A = $F0" (DB5F)
This entry point is used by the routine at DB67.
DB4F XOR A Clear A to zero (and the carry flag) - Not a time: a $D0 token (not understood)
DB50 LD A,$D0 Load A with $D0
DB52 LD BC,$0000 Load BC with $0000
DB55 RET Return to the caller
Prev: DAE8 Up: Map Next: DB56