Routines

26513: Make character write one letter on a blackboard


Used by routine at 26752

H Character number

26513 CDCE66 CALL 26318 Collect in A the next character code from the message being written on the board

This entry point is used by the routine at 24175 when ERIC's writing on a board:
26516 4F LD C,A
26517 CD5567 CALL 26453 Collect information about the blackboard
26520 79 LD A,C
26521 48 LD C,B
26522 067F LD B,127 Point BC at the blackboard's buffer
26524 A7 AND A Have we reached the end of the message?
26525 2004 JR NZ,26531 Jump if not
26527 3D DEC A A=255
26528 02 LD (BC),A
26529 3C INC A Set zero flag if the end of the message has been reached
26530 C9 RET
26531 FE02 CP 2 Character code 2 is newline
26533 2004 JR NZ,26539 Jump unless starting a new line
26535 3E40 LD A,64 64=pixel column number for start of bottom line of blackboard
26537 18F5 JR 26528
26539 E5 PUSH HL
26540 6F LD L,A Place character code in L
26541 26D7 LD H,215 (HL)=bit width of this character
26543 0A LD A,(BC) A=current pixel column number
26544 E63F AND 63
26546 C6C0 ADD A,192
26548 37 SCF
26549 8E ADC A,(HL)
26550 0A LD A,(BC)
26551 3004 JR NC,26557 Jump if there's enough room on the current line for the character
26553 2F CPL Otherwise move to the other line of the blackboard by setting the current pixel column number to 0 or 64 as appropriate
26554 E640 AND 64
26556 02 LD (BC),A
26557 0F RRCA
26558 0F RRCA
26559 0F RRCA
26560 E60F AND 15
26562 FE08 CP 8
26564 3803 JR C,26569 Jump if on the top line of the board
26566 14 INC D D=4 or 9 (y-coordinate of bottom line of board)
26567 E607 AND 7
26569 83 ADD A,E
26570 5F LD E,A E=x-coordinate of the "piece of chalk"
26571 CD0C67 CALL 26380 Update SRB for blackboard
26574 0A LD A,(BC) A=current pixel column number on blackboard
26575 E607 AND 7 Modify the instruction at 26609 below as appropriate
26577 87 ADD A,A
26578 87 ADD A,A
26579 87 ADD A,A
26580 2F CPL
26581 D641 SUB 65
26583 32F267 LD (26610),A
26586 0A LD A,(BC) A=current pixel column number on board
26587 86 ADD A,(HL) Add bit width of character to be written
26588 3C INC A Add 1 to make a blank vertical pixel line after the letter to be written
26589 02 LD (BC),A Restore pixel column number
26590 4E LD C,(HL) C=bit-width of letter to be written on the board
26591 EB EX DE,HL
26592 7C LD A,H
26593 26B5 LD H,181
26595 6E LD L,(HL)
26596 C6A0 ADD A,160
26598 67 LD H,A
26599 6E LD L,(HL)
26600 2680 LD H,128
26602 14 INC D
26603 1A LD A,(DE) A=vertical pixel line for character
26604 0608 LD B,8 8 horizontal pixel lines in each character square
26606 07 RLCA Should a bit of chalk appear here?
26607 3002 JR NC,26611 Jump if not
26609 CBx RES n,(HL) n=((26610)–134)/8
26611 24 INC H
26612 10F8 DJNZ 26606
26614 3AF267 LD A,(26610)
26617 F640 OR 64
26619 D608 SUB 8
26621 E6BF AND 191
26623 32F267 LD (26610),A
26626 FEBE CP 190 Have we reached the last vertical pixel line in the character square?
26628 2001 JR NZ,26631 Jump if so
26630 2C INC L Point to first pixel line in adjacent character square
26631 0D DEC C
26632 20DE JR NZ,26600 Jump back to do remaining vertical pixel lines
26634 0C INC C Reset zero flag (message not finished yet)
26635 E1 POP HL
26636 C9 RET