Prev: A95B Up: Map Next: A9B5
A990: 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 (60-7F)
C Updated rotation count
RotateAndExtractCharacterCode A990 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.
A991 LD D,(HL)
A992 INC HL
A993 LD E,(HL)
A994 DEC HL
A995 LD A,C
A996 AND A
A997 JR Z,RotateAndExtractCharacterCode_UpdateRotation
Rotate the two bytes left by the rotation count.
RotateAndExtractCharacterCode_RotateLoop A999 SLA E Move the packed character one bit and repeat from RotateAndExtractCharacterCode_RotateLoop until the bit offset is used up.
A99B RL D
A99D DEC A
A99E JR NZ,RotateAndExtractCharacterCode_RotateLoop
Update the rotation count for the next character extraction.
RotateAndExtractCharacterCode_UpdateRotation A9A0 LD A,C Jump ahead to RotateAndExtractCharacterCode_Extract if the rotation count plus 05 is still below 08.
A9A1 ADD A,$05
A9A3 CP $08
A9A5 JR C,RotateAndExtractCharacterCode_Extract
A9A7 SUB $08 Drop 08 from the count and step to the next character.
A9A9 INC HL
RotateAndExtractCharacterCode_Extract A9AA LD C,A Store the result in the low byte of the count.
A9AB LD A,D Read the high byte of the token.
A9AC POP DE Restore the saved source from the stack.
Extract the 5-bit character code from the rotated byte.
A9AD RRCA Move the bottom bit of the result up to the top.
A9AE RRCA Move the bottom bit of the result up to the top.
A9AF RRCA Move the bottom bit of the result up to the top.
A9B0 AND %00011111 Keep only bits 0-4 (extract the 5-bit character code).
A9B2 ADD A,$60 Advance the result by 60.
A9B4 RET Return.
Prev: A95B Up: Map Next: A9B5