Routines
 Prev: 29868 Up: Map Next: 29972
29871: Save the area of the screen that will be overwritten by a lines bubble
Used by the routines at 30464 and 63829. Returns with the carry flag set if the teacher whose coordinates are in DE is off-screen. Otherwise calculates the position of the lines bubble and copies the area of the screen that would be overwritten by the bubble to the buffer at 59904, and returns with DE holding the attribute file address for the top-left corner of the lines bubble.
Input
DE Teacher's coordinates
29871 LD A,(32512) A=leftmost column of the skool on screen (0-64)
29874 LD B,A Copy this to B
29875 LD A,E A=teacher's x-coordinate
29876 AND 248
29878 SUB B Is the teacher off-screen to the left?
29879 RET C Return with the carry flag set if so
29880 CP 32 Is the teacher off-screen to the right?
29882 CCF
29883 RET C Return with the carry flag set if so
The teacher is on screen. First, save the attribute bytes of the area of the screen that will be overwritten by the lines bubble.
29884 LD E,A E=teacher's screen x-coordinate (0-31)
29885 LD A,D A=teacher's y-coordinate (152-169)
29886 SUB 155 A=teacher's screen y-coordinate (0-14)
29888 JR NC,29891
29890 XOR A
29891 RRCA Set DE to the attribute file address of the top left corner of the lines bubble
29892 RRCA
29893 RRCA
29894 LD D,A
29895 AND 224
29898 LD E,A
29899 LD A,D
29900 AND 3
29904 LD D,A
29905 PUSH HL
29906 PUSH DE
29907 LD HL,59904 The buffer at 59904 will store the area of the screen overwritten by the lines bubble
29910 EX DE,HL DE=59904, HL=attribute file address
29911 LD BC,8 Copy the 24 attribute bytes that will be overwritten by the lines bubble from the screen to 59904
29914 LDIR
29916 LD C,24
29919 LD C,8
29921 LDIR
29923 LD C,24
29926 LD C,8
29928 LDIR
Next, save the display file bytes of the area of the screen that will be overwritten by the lines bubble.
29930 POP HL Restore the attribute file address of the top-left corner of the lines bubble to HL
29931 PUSH HL
29932 LD A,H Get the display file address of the top-left corner of the lines bubble in HL
29933 SUB 80
29938 LD H,A
29939 LD BC,3 A lines bubble has 3 rows...
29942 LD A,8 ...and 8 columns; copy the 192 display file bytes that will be overwritten by the lines bubble from the screen to 59928
29944 PUSH BC
29945 PUSH HL
29946 LD C,8
29948 LDIR
29950 POP HL
29951 INC H
29952 DEC A
29953 JR NZ,29945
29955 LD A,L