Prev: 43355 Up: Map Next: 43445
43408: Rotate And Extract Character Code
Unpacks the next character code from the bit-packed dictionary word.
Input
HL Pointer to bit-packed character data
C Rotation count (bit offset within the data)
Output
A Character code (96-127)
C Updated rotation count
RotateAndExtractCharacterCode 43408 PUSH DE Read the word at HL into DE with the bytes swapped, and jump to RotateAndExtractCharacterCode_UpdateRotation if C is zero.
Read two bytes from the bit-packed data.
43409 LD D,(HL)
43410 INC HL
43411 LD E,(HL)
43412 DEC HL
43413 LD A,C
43414 AND A
43415 JR Z,RotateAndExtractCharacterCode_UpdateRotation
Rotate the two bytes left by the rotation count.
RotateAndExtractCharacterCode_RotateLoop 43417 SLA E Move the packed character one bit and repeat from RotateAndExtractCharacterCode_RotateLoop until the bit offset is used up.
43419 RL D
43421 DEC A
43422 JR NZ,RotateAndExtractCharacterCode_RotateLoop
Update the rotation count for the next character extraction.
RotateAndExtractCharacterCode_UpdateRotation 43424 LD A,C Jump ahead to RotateAndExtractCharacterCode_Extract if the rotation count plus 5 is still below 8.
43425 ADD A,5
43427 CP 8
43429 JR C,RotateAndExtractCharacterCode_Extract
43431 SUB 8 Drop 8 from the count and step to the next character.
43433 INC HL
RotateAndExtractCharacterCode_Extract 43434 LD C,A Store the result in the low byte of the count.
43435 LD A,D Read the high byte of the token.
43436 POP DE Restore the saved source from the stack.
Extract the 5-bit character code from the rotated byte.
43437 RRCA Move the bottom bit of the result up to the top.
43438 RRCA Move the bottom bit of the result up to the top.
43439 RRCA Move the bottom bit of the result up to the top.
43440 AND %00011111 Keep only bits 0-4 (extract the 5-bit character code).
43442 ADD A,96 Advance the result by 96.
43444 RET Return.
Prev: 43355 Up: Map Next: 43445