![]() |
Routines |
| Prev: 32632 | Up: Map | Next: 33006 |
|
Used by the routine at Drawing.
Reads picture commands. 0 ends the picture, 8 moves the pen, bit 7 draws a line, and the other bytes fill or paint.
|
||||
|
Drawing routines.
|
||||
| DrawingSetup | 32679 | PUSH IY | Save the picture registers and clear the window when the place is dark. | |
| 32681 | PUSH HL | |||
| 32682 | PUSH HL | |||
| 32683 | POP IY | |||
| 32685 | PUSH DE | |||
| 32686 | PUSH BC | |||
| 32687 | CALL DrawingClear | |||
| 32690 | LD D,127 | Start the high coordinate at 127. | ||
| 32692 | LD E,63 | Start the low coordinate at 63. | ||
| 32694 | LD B,1 | Start the step count at 1. | ||
| 32696 | LD C,1 | Start the direction at 1. | ||
| 32698 | LD L,1 | Start the length at 1. | ||
| Drawing_Loop | 32700 | LD A,(IY+0) | Fetch the next drawing instruction. | |
| 32703 | AND A | If the drawing instruction is zero, jump to Drawing_End. | ||
| 32704 | JP Z,Drawing_End | |||
| 32707 | INC IY | Increment the graphics data pointer by one. | ||
| 32709 | CP 8 | If the graphics data value which was fetched is not 8 (move to X/Y) jump to DrawingSetup_TestForALine. | ||
| 32711 | JR NZ,DrawingSetup_TestForALine | |||
|
Moves the "pen" held in DE to a screen location.
|
||||
| 32713 | LD D,(IY+0) | Populate DE with two values from the graphics data and increment the pointer by two. | ||
| 32716 | INC IY | |||
| 32718 | LD E,(IY+0) | |||
| 32721 | INC IY | |||
| 32723 | JR Drawing_Loop | Jump back to Drawing_Loop for the next drawing instruction. | ||
| DrawingSetup_TestForALine | 32725 | BIT 7,A | If bit 7 is clear, jump to DrawingSetup_TestForAFill. A set bit 7 is a line. | |
| 32727 | JR Z,DrawingSetup_TestForAFill | |||
| 32729 | LD B,A | Keep the line command. | ||
| 32730 | AND %00000111 | The low three bits are the direction. | ||
| 32732 | LD C,A | Store the direction in C. | ||
| 32733 | LD A,B | Bring the line command back. | ||
| 32734 | RRCA | |||
| 32735 | AND 60 | |||
| 32737 | LD B,A | Store this in B. | ||
| 32738 | LD A,(IY+0) | Read the length byte of the line. | ||
| 32741 | AND %00111111 | The low six bits are the length. | ||
| 32743 | LD L,A | Store that length. | ||
| 32744 | INC L | A stored length of zero draws one pixel. | ||
| 32745 | LD A,(IY+0) | Read the length byte again for the step spacing. | ||
| 32748 | INC IY | Increment the graphics data pointer by one. | ||
| 32750 | RLCA | Move bits 6-7 down to bits 0-1. | ||
| 32751 | RLCA | |||
| 32752 | AND 3 | |||
| 32754 | OR B | Combine the step spacing from both command bytes. | ||
| 32755 | LD B,A | Store the step spacing. | ||
| 32756 | INC B | A stored spacing of zero steps every pixel. | ||
| 32757 | CALL Drawing_PlotTheSelectedPixel | Call Drawing_PlotTheSelectedPixel to plot the line. | ||
| 32760 | JR Drawing_Loop | Jump back to Drawing_Loop for the next drawing instruction. | ||
|
A set bit 6 is a fill.
|
||||
| DrawingSetup_TestForAFill | 32762 | BIT 6,A | Jump to DrawingSetup_RepeatWhileBitFiveIsClear if bit 6 is clear. | |
| 32764 | JR Z,DrawingSetup_RepeatWhileBitFiveIsClear | |||
| 32766 | AND %00000111 | The low three bits are the fill ink. | ||
| 32768 | PUSH DE | Read the fill's X coordinate. | ||
| 32769 | LD D,(IY+0) | |||
| 32772 | INC IY | Advance the graphics pointer. | ||
| 32774 | LD E,(IY+0) | Read the fill's other coordinate. | ||
| 32777 | INC IY | Advance the graphics pointer. | ||
|
Flood-fill from the point in DE.
|
||||
| 32779 | CALL DrawingSetup_0 | Call DrawingSetup_0 to flood-fill from that point. | ||
| 32782 | POP DE | Jump back to Drawing_Loop to fetch the next drawing instruction. | ||
| 32783 | JP Drawing_Loop | |||
| DrawingSetup_RepeatWhileBitFiveIsClear | 32786 | BIT 5,A | Jump back to Drawing_Loop if bit 5 of this picture command is clear. | |
| 32788 | JP Z,Drawing_Loop | |||
| 32791 | AND %00000111 | The low three bits are the ink to paint. | ||
| 32793 | RLCA | Shift the ink towards the paper bits. | ||
| 32794 | RLCA | Shift the ink towards the paper bits. | ||
| 32795 | RLCA | Shift the ink into the paper bits. | ||
| 32796 | PUSH HL | Save HL, DE and BC, and keep the scaled bits in C. | ||
| 32797 | PUSH DE | |||
| 32798 | PUSH BC | |||
| 32799 | LD C,A | |||
| 32800 | LD H,(IY+0) | Read the attribute address high byte into H. | ||
| 32803 | INC IY | Advance the graphics pointer. | ||
| 32805 | LD L,(IY+0) | Read the attribute address low byte into L. | ||
| 32808 | INC IY | Advance the graphics pointer. | ||
| DrawingSetup_ReadTheNextAttributeByte | 32810 | LD A,(IY+0) | Read the next attribute byte. | |
| 32813 | INC IY | Advance the graphics pointer. | ||
| 32815 | CP 255 | Jump to DrawingSetup_FetchTheNextDrawingInstruction at the 255 terminator. | ||
| 32817 | JR Z,DrawingSetup_FetchTheNextDrawingInstruction | |||
| 32819 | LD B,A | Copy the result into B. | ||
| 32820 | AND %00000011 | The low two bits choose which way this attribute run steps. | ||
| 32822 | LD E,A | Store that step. | ||
| 32823 | LD A,B | Shift the length down two bits. | ||
| 32824 | RRCA | |||
| 32825 | RRCA | |||
| 32826 | AND 63 | |||
| 32828 | INC A | A stored length of zero paints one cell. | ||
| 32829 | LD B,A | Copy the result into B. | ||
| DrawingSetup_Loop | 32830 | LD A,(HL) | Read the next byte. | |
| 32831 | AND %00000111 | Jump to DrawingSetup_StoreTheAttribute when this cell's ink is not the ink being replaced. | ||
| 32833 | RLCA | |||
| 32834 | RLCA | |||
| 32835 | RLCA | |||
| 32836 | CP C | |||
| 32837 | JR NZ,DrawingSetup_StoreTheAttribute | |||
| 32839 | XOR 56 | Flip the bits selected by 56. | ||
| DrawingSetup_StoreTheAttribute | 32841 | RRCA | Shift the ink back into bits 0-2, merge it with C and store the attribute; then call Drawing_StepUpOneRow if the direction in E is 0. | |
| 32842 | RRCA | |||
| 32843 | RRCA | |||
| 32844 | OR C | |||
| 32845 | LD (HL),A | |||
| 32846 | LD A,E | |||
| 32847 | AND A | |||
| 32848 | CALL Z,Drawing_StepUpOneRow | |||
| 32851 | DEC A | Call Drawing_StepRightOnePixel if the direction is 1. | ||
| 32852 | CALL Z,Drawing_StepRightOnePixel | |||
| 32855 | DEC A | Call Drawing_StepDownOneRow if the direction is 2. | ||
| 32856 | CALL Z,Drawing_StepDownOneRow | |||
| 32859 | DEC A | Call Drawing_StepLeftOnePixel if the direction is 3. | ||
| 32860 | CALL Z,Drawing_StepLeftOnePixel | |||
| 32863 | DJNZ DrawingSetup_Loop | Loop back to DrawingSetup_Loop until the count runs out. | ||
| 32865 | JR DrawingSetup_ReadTheNextAttributeByte | Jump back to DrawingSetup_ReadTheNextAttributeByte for the next attribute byte. | ||
|
Restore the registers saved for this shape.
|
||||
| DrawingSetup_FetchTheNextDrawingInstruction | 32867 | POP BC | Restore BC, DE and HL from the stack, then jump to Drawing_Loop for the next drawing instruction. | |
| 32868 | POP DE | |||
| 32869 | POP HL | |||
| 32870 | JP Drawing_Loop | |||
|
This entry point is used by the routine at DrawingClear.
|
||||
| Drawing_End | 32873 | POP BC | Restore BC, DE, HL and IY from the stack. | |
| 32874 | POP DE | |||
| 32875 | POP HL | |||
| 32876 | POP IY | |||
| 32878 | RET | Return. | ||
| 32879 | DEFB 0,0 | |||
| DrawingSetup_0 | 32881 | LD (33358),A | Store the result at 33358. | |
| 32884 | PUSH DE | Allow 128 steps of this flood fill. | ||
| 32885 | PUSH HL | |||
| 32886 | LD HL,128 | |||
| 32889 | PUSH HL | |||
| DrawingSetup_MaskOneScreenByte | 32890 | CALL Drawing_MaskOneScreenByte | Call Drawing_MaskOneScreenByte to mask one screen byte. | |
| 32893 | JR NZ,DrawingSetup_AddressThePixel | Jump to DrawingSetup_AddressThePixel if Drawing_MaskOneScreenByte found the masked screen byte set. | ||
| 32895 | CALL Drawing_RetreatTheHighCoordinate | Call Drawing_RetreatTheHighCoordinate to retreat the high coordinate. | ||
| 32898 | JR NZ,DrawingSetup_MaskOneScreenByte | Jump back to DrawingSetup_MaskOneScreenByte if Drawing_RetreatTheHighCoordinate did not wrap the high coordinate. | ||
| 32900 | JR DrawingSetup_ClearTheFloodFillCount | Jump to DrawingSetup_ClearTheFloodFillCount to clear the saved coordinate, because the high coordinate wrapped. | ||
| DrawingSetup_AddressThePixel | 32902 | CALL Drawing_AddressThePixel | Call Drawing_AddressThePixel to address the pixel. | |
| 32905 | CALL Drawing_AdvanceTheHighCoordinate | Call Drawing_AdvanceTheHighCoordinate to advance the high coordinate. | ||
| DrawingSetup_ClearTheFloodFillCount | 32908 | LD HL,0 | Store 0000 in *32879. | |
| 32911 | LD (32879),HL | |||
| DrawingSetup_AdvanceTheLowCoordinate | 32914 | CALL Drawing_AdvanceTheLowCoordinate | Call Drawing_AdvanceTheLowCoordinate to advance the low coordinate. | |
| 32917 | LD A,0 | Take zero and jump to DrawingSetup_StoreTheResultAtFloodFillCount if Drawing_AdvanceTheLowCoordinate wrapped the low coordinate. | ||
| 32919 | JR Z,DrawingSetup_StoreTheResultAtFloodFillCount | |||
| 32921 | CALL Drawing_MaskOneScreenByte | Call Drawing_MaskOneScreenByte to mask one screen byte. | ||
| 32924 | LD A,0 | Take zero and jump to DrawingSetup_RetreatTheLowCoordinate if Drawing_MaskOneScreenByte found the masked screen byte set. | ||
| 32926 | JR NZ,DrawingSetup_RetreatTheLowCoordinate | |||
|
Test this flag.
|
||||
| 32928 | LD A,(32879) | Jump to DrawingSetup_RetreatTheLowCoordinate if *32879 is not zero. | ||
| 32931 | AND A | |||
| 32932 | JR NZ,DrawingSetup_RetreatTheLowCoordinate | |||
| 32934 | PUSH DE | Use 1 when the coordinate was zero. | ||
| 32935 | LD A,1 | |||
| DrawingSetup_RetreatTheLowCoordinate | 32937 | PUSH AF | Call Drawing_RetreatTheLowCoordinate to retreat the low coordinate, then restore AF from the stack. | |
| 32938 | CALL Drawing_RetreatTheLowCoordinate | |||
| 32941 | POP AF | |||
| DrawingSetup_StoreTheResultAtFloodFillCount | 32942 | LD (32879),A | Store the result at 32879. | |
| 32945 | CALL Drawing_RetreatTheLowCoordinate | Call Drawing_RetreatTheLowCoordinate to retreat the low coordinate. | ||
| 32948 | LD A,0 | Take zero, and jump to DrawingSetup_StoreTheHighCoordinate if Drawing_RetreatTheLowCoordinate returned with the zero flag set. | ||
| 32950 | JR Z,DrawingSetup_StoreTheHighCoordinate | |||
| 32952 | CALL Drawing_MaskOneScreenByte | Call Drawing_MaskOneScreenByte to mask one screen byte. | ||
| 32955 | LD A,0 | Take zero, and jump to DrawingSetup_AdvanceAndRestore if Drawing_MaskOneScreenByte found the masked screen byte set. | ||
| 32957 | JR NZ,DrawingSetup_AdvanceAndRestore | |||
|
Test this flag.
|
||||
| 32959 | LD A,(32880) | Jump to DrawingSetup_AdvanceAndRestore if the drawing scratch is not zero. | ||
| 32962 | AND A | |||
| 32963 | JR NZ,DrawingSetup_AdvanceAndRestore | |||
| 32965 | PUSH DE | Use 1 when the coordinate was zero. | ||
| 32966 | LD A,1 | |||
| DrawingSetup_AdvanceAndRestore | 32968 | PUSH AF | Call Drawing_AdvanceTheLowCoordinate to advance the low coordinate, then restore AF from the stack. | |
| 32969 | CALL Drawing_AdvanceTheLowCoordinate | |||
| 32972 | POP AF | |||
| DrawingSetup_StoreTheHighCoordinate | 32973 | LD (32880),A | Store the result at 32880. | |
| 32976 | CALL Drawing_AddressThePixel | Call Drawing_AddressThePixel to address the pixel. | ||
| 32979 | CALL Drawing_AdvanceTheHighCoordinate | Call Drawing_AdvanceTheHighCoordinate to advance the high coordinate. | ||
| 32982 | JR Z,DrawingSetup_TestTheFloodFillCount | Jump to DrawingSetup_TestTheFloodFillCount if Drawing_AdvanceTheHighCoordinate wrapped the high coordinate. | ||
| 32984 | CALL Drawing_MaskOneScreenByte | Call Drawing_MaskOneScreenByte to mask one screen byte. | ||
| 32987 | JR Z,DrawingSetup_AdvanceTheLowCoordinate | Jump back to DrawingSetup_AdvanceTheLowCoordinate if Drawing_MaskOneScreenByte found the masked screen byte clear. | ||
| 32989 | CALL Drawing_AddressThePixel | Call Drawing_AddressThePixel to address the pixel. | ||
| DrawingSetup_TestTheFloodFillCount | 32992 | POP DE | Jump back to DrawingSetup_MaskOneScreenByte unless the flood-fill count is 128. | |
| 32993 | LD A,E | |||
| 32994 | CP 128 | |||
| 32996 | JR NZ,DrawingSetup_MaskOneScreenByte | |||
| 32998 | LD A,0 | Write 0 to *33358. | ||
| 33000 | LD (33358),A | |||
| 33003 | POP HL | Restore HL and DE from the stack. | ||
| 33004 | POP DE | |||
| 33005 | RET | Return. | ||
|
View the equivalent code in;
|
||||
| Prev: 32632 | Up: Map | Next: 33006 |