Prev: 62370 Up: Map Next: 62606
62402: Drawing
Used by the routine at ProcessTextToken.
Draws one location picture from line, fill and attribute commands. Pictures are not bitmaps. The pen starts at X=127 and Y=63 (Y counts up from the bottom, so this is screen row 112). 0 ends the picture. 8 followed by two bytes moves the pen. Bit 7 draws a line, bit 6 fills, and bit 5 paints attributes.
Keep the caller's state and aim at the picture.
Drawing 62402 PUSH IY Keep the caller's registers and aim IY at the picture passed in HL.
62404 PUSH HL
62405 PUSH HL
62406 POP IY
62408 PUSH DE
62409 PUSH BC
Put the pen at its starting position.
62410 LD D,127 Start the pen at X=127 and Y=63 (screen row 112), with the line counters at 1.
62412 LD E,63
62414 LD B,1
62416 LD C,1
62418 LD L,1
Each command is one byte. 0 ends the picture.
Drawing_Loop 62420 LD A,(IY+0) Finish the picture when the command byte is 0.
62423 AND A
62424 JP Z,Drawing_Finish
8 moves the pen to the two coordinates that follow.
62427 INC IY Step past this command and jump ahead to Drawing_Line unless it is 8.
62429 CP 8
62431 JR NZ,Drawing_Line
62433 LD D,(IY+0) Read the new X and mark it as a move.
62436 SET 7,D
62438 INC IY
62440 LD E,(IY+0) Read the new Y and take the next command.
62443 INC IY
62445 JR Drawing_Loop
A set bit 7 is a line. Bits 0-2 choose the direction, and the next byte's top bits are the step and its low six bits the length.
Drawing_Line 62447 BIT 7,A Jump to Drawing_Fill if this command does not draw a line.
62449 JR Z,Drawing_Fill
62451 LD B,A The line direction is bits 0-2 of the command.
62452 AND 7
62454 LD C,A
62455 LD A,B Keep the command's other line field.
62456 RRCA
62457 AND 60
62459 LD B,A
62460 LD A,(IY+0) The next byte's low six bits are the line length.
62463 AND 63
62465 LD L,A
62466 INC L
62467 LD A,(IY+0) The top bits of that byte choose the step.
62470 INC IY
62472 RLCA
62473 RLCA
62474 AND 3
62476 OR B
62477 LD B,A
62478 INC B
62479 CALL DrawingLine Call DrawingLine to draw the line.
62482 JR Drawing_Loop Jump back to Drawing_Loop for the next command.
A set bit 6 is a fill. Bits 0-2 are the ink, and the next two bytes are the X and Y to fill from.
Drawing_Fill 62484 BIT 6,A Jump to Drawing_Attribute if this command is not a fill.
62486 JR Z,Drawing_Attribute
62488 AND 7 Read the fill X and the ink colour.
62490 PUSH DE
62491 LD D,(IY+0)
62494 SET 7,D
62496 INC IY
62498 LD E,(IY+0) Read the fill Y.
62501 INC IY
62503 CALL DrawingFill Call DrawingFill to fill the shape.
62506 POP DE Restore the pen from the stack.
62507 JP Drawing_Loop Take the next command.
A set bit 5 paints attributes. Bits 0-2 become the paper colour, and the next bytes name the squares to paint.
Drawing_Attribute 62510 BIT 5,A Take the next command unless this one paints attributes.
62512 JP Z,Drawing_Loop
62515 AND 7 Use bits 0-2 as the paper colour.
62517 RLCA
62518 RLCA
62519 RLCA
62520 PUSH HL
62521 PUSH DE
62522 PUSH BC
62523 LD C,A
62524 LD H,(IY+0) Read the attribute address.
62527 INC IY
62529 LD A,(IY+0)
62532 ADD A,16 Add 16 to the low byte of the attribute address.
62534 LD L,A
62535 INC IY
Drawing_Run 62537 LD A,(IY+0) Stop this attribute run when the command is 255.
62540 INC IY
62542 CP 255
62544 JR Z,Drawing_AttributeDone
62546 LD B,A The low two bits are the direction and the rest is the run length.
62547 AND 3
62549 LD E,A
62550 LD A,B
62551 RRCA
62552 RRCA
62553 AND 63
62555 INC A
62556 LD B,A
Drawing_Paint 62557 LD A,(HL) Flip the ink when it matches the paper colour being painted, so it stays visible.
62558 AND 7
62560 RLCA
62561 RLCA
62562 RLCA
62563 CP C
62564 JR NZ,Drawing_0
62566 XOR 56
Drawing_0 62568 RRCA Write the paper colour into the attribute byte.
62569 RRCA
62570 RRCA
62571 OR C
62572 LD (HL),A
62573 LD A,E
62574 AND A
Step up when the direction is up.
Drawing_Step 62575 CALL Z,AttributeUp Call AttributeUp when the direction is up.
Step right when the direction is right.
62578 DEC A Count down to the rightward direction.
62579 CALL Z,AttributeRight Call AttributeRight when the direction is right.
Step down when the direction is down.
62582 DEC A Count down to the downward direction.
62583 CALL Z,AttributeDown Call AttributeDown when the direction is down.
Step left when the direction is left.
62586 DEC A Count down to the leftward direction.
62587 CALL Z,AttributeLeft Call AttributeLeft when the direction is left.
Repeat for every attribute in the run.
62590 DJNZ Drawing_Paint Repeat from Drawing_Paint for the length of the attribute run.
62592 JR Drawing_Run Read the next attribute run.
Join the next step.
The picture is finished.
Drawing_AttributeDone 62594 POP BC Restore the pen from the stack.
62595 POP DE
62596 POP HL
62597 JP Drawing_Loop Take the next picture command.
Return.
Drawing_Finish 62600 POP BC Restore the saved count, the saved source, the saved pointer and the saved picture command from the stack.
62601 POP DE
62602 POP HL
62603 POP IY
62605 RET Return.
View the equivalent code in;
Prev: 62370 Up: Map Next: 62606