![]() |
Routines |
| Prev: A95B | Up: Map | Next: A9B5 |
|
||||||||||||||||
| RotateAndExtractCharacterCode | A990 | PUSH DE | Stash DE on the stack. | |||||||||||||
|
Read two bytes from the bit-packed data.
|
||||||||||||||||
| A991 | LD D,(HL) | Load two bytes from the bit-packed data into DE. | ||||||||||||||
| A992 | INC HL | |||||||||||||||
| A993 | LD E,(HL) | |||||||||||||||
| A994 | DEC HL | Decrease HL by one (restore the pointer). | ||||||||||||||
| A995 | LD A,C | Jump to RotateAndExtractCharacterCode_UpdateRotation if no rotation is needed. | ||||||||||||||
| A996 | AND A | |||||||||||||||
| A997 | JR Z,RotateAndExtractCharacterCode_UpdateRotation | |||||||||||||||
|
Rotate the two bytes left by the rotation count.
|
||||||||||||||||
| RotateAndExtractCharacterCode_RotateLoop | A999 | SLA E | Shift E left (with carry) (move bit from high byte to carry). | |||||||||||||
| A99B | RL D | Rotate D left (move carry bit into low byte). | ||||||||||||||
| A99D | DEC A | Decrease A (the rotation counter) by one. | ||||||||||||||
| A99E | JR NZ,RotateAndExtractCharacterCode_RotateLoop | Jump to RotateAndExtractCharacterCode_RotateLoop if more rotations are needed. | ||||||||||||||
|
Update the rotation count for the next character extraction.
|
||||||||||||||||
| RotateAndExtractCharacterCode_UpdateRotation | A9A0 | LD A,C | A=C (load the current rotation count). | |||||||||||||
| A9A1 | ADD A,$05 | A+=05 (add 5 bits for the character we're extracting). | ||||||||||||||
| A9A3 | CP $08 | Jump to RotateAndExtractCharacterCode_Extract if we haven't crossed a byte boundary (A is less than 08). | ||||||||||||||
| A9A5 | JR C,RotateAndExtractCharacterCode_Extract | |||||||||||||||
| A9A7 | SUB $08 | A-=08 (wrap around within the byte). | ||||||||||||||
| A9A9 | INC HL | Increment HL by one (move to the next byte for the next character). | ||||||||||||||
| RotateAndExtractCharacterCode_Extract | A9AA | LD C,A | C=A (store the updated rotation count). | |||||||||||||
| A9AB | LD A,D | A=D (load the rotated low byte). | ||||||||||||||
| A9AC | POP DE | Restore DE from the stack. | ||||||||||||||
|
Extract the 5-bit character code from the rotated byte.
|
||||||||||||||||
| A9AD | RRCA | RRCA three times (shift right by 3 bits to align the 5-bit code). | ||||||||||||||
| A9AE | RRCA | |||||||||||||||
| A9AF | RRCA | |||||||||||||||
| A9B0 | AND %00011111 | Keep only bits 0-4 (extract the 5-bit character code). | ||||||||||||||
| A9B2 | ADD A,$60 | A+=60 (convert to ASCII character code range 60-7F). | ||||||||||||||
| A9B4 | RET | Return. | ||||||||||||||
| Prev: A95B | Up: Map | Next: A9B5 |