Routines

24684: Print a character square


Used by routines at 25026, 25080 and 25248

H Screen row number (0-20)
L Screen column number (0-31)

24684 E5 PUSH HL
24685 7C LD A,H A=screen row number (0-20)
24686 E618 AND 24
24688 57 LD D,A D=0, 8 or 16
24689 7C LD A,H
24690 0F RRCA
24691 0F RRCA
24692 0F RRCA
24693 67 LD H,A
24694 E6E0 AND 224
24696 85 ADD A,L
24697 5F LD E,A
24698 4F LD C,A
24699 7C LD A,H
24700 E603 AND 3
24702 C658 ADD A,88
24704 47 LD B,A Now BC=appropriate attribute file address
24705 CBF2 SET 6,D Now DE=appropriate display file address
24707 EB EX DE,HL
24708 E3 EX (SP),HL Place display file address on stack and get (row,col) back in HL
24709 3AFF7F LD A,(32767) A=number of leftmost column of play area on screen (0-160)
24712 85 ADD A,L A=column of play area corresponding to character square under consideration
24713 6F LD L,A 0≤L≤191
24714 E5 PUSH HL
24715 7C LD A,H A=screen row number (0-20)
24716 26B5 LD H,181 HL=anything from 46336 to 46527
24718 6E LD L,(HL) 0≤L≤143
24719 C6A0 ADD A,160
24721 67 LD H,A 160≤H≤180
24722 5D LD E,L 0≤E≤143
24723 7D LD A,L 0≤L≤143
24724 1F RRA
24725 381B JR C,24754
24727 C6B4 ADD A,180 180≤A≤251
24729 6F LD L,A
24730 7E LD A,(HL)
24731 E6F0 AND 240 Retain bits 4-7
24733 CB1F RR A
24735 2025 JR NZ,24774
24737 24 INC H
24738 7E LD A,(HL)
24739 E6F0 AND 240 Retain bits 4-7
24741 1F RRA
24742 6F LD L,A L holds PAPER colour and BRIGHT status
24743 7B LD A,E 0≤A≤143
24744 E603 AND 3
24746 2002 JR NZ,24750
24748 C602 ADD A,2 A=2: INK 2
24750 B5 OR L OR on the PAPER colour and BRIGHT status
24751 25 DEC H 160≤H≤180
24752 1814 JR 24774 Jump forward to transfer the attribute byte in A onto the screen
24754 C6B4 ADD A,180 180≤A≤251
24756 6F LD L,A
24757 7E LD A,(HL)
24758 E60F AND 15
24760 2009 JR NZ,24771
24762 24 INC H
24763 7E LD A,(HL)
24764 E60F AND 15
24766 87 ADD A,A
24767 87 ADD A,A
24768 87 ADD A,A
24769 18E3 JR 24742
24771 87 ADD A,A
24772 87 ADD A,A
24773 87 ADD A,A

During startup:
24774 00 NOP No messing with the attributes during startup

During the game (after the POKEs made by the startup routine at 21408):
24774 02 LD (BC),A Poke the attribute byte onto the screen

The routine continues:
24775 6B LD L,E 0≤L≤143, 160≤H≤180
24776 5E LD E,(HL) E=UDG reference number
24777 3E88 LD A,136
24779 CB3D SRL L
24781 3001 JR NC,24784
24783 0F RRCA
24784 CB3D SRL L
24786 3002 JR NC,24790
24788 0F RRCA
24789 0F RRCA
24790 4F LD C,A C=17, 34, 68 or 136
24791 7D LD A,L 0≤A≤35
24792 C690 ADD A,144 144≤A≤179
24794 6F LD L,A 144≤L≤179
24795 79 LD A,C A=17, 34, 68 or 136
24796 A6 AND (HL)
24797 1680 LD D,128
24799 FE10 CP 16
24801 3802 JR C,24805
24803 1690 LD D,144
24805 E60F AND 15
24807 2802 JR Z,24811
24809 CBDA SET 3,D D=128, 136, 144 or 152
24811 2170E1 LD HL,57712
24814 0608 LD B,8

During startup:
24816 AF XOR A A=blank byte: there is no play area during startup!

During the game (after the POKEs made by the startup routine at 21408):
24816 1A LD A,(DE) A=byte of play area graphic data

The routine continues:
24817 14 INC D
24818 77 LD (HL),A Store graphic byte in buffer
24819 2C INC L
24820 10FA DJNZ 24816 Get next graphic byte
24822 26B7 LD H,183 183=character number of little girl no. 1
24824 D1 POP DE D=play area row (0-20), E=play area column (0-191)
24825 3AFF7F LD A,(32767) A=number of leftmost column of play area on screen (0-160)
24828 FE78 CP 120 120=roughly halfway between tree and gate
24830 380B JR C,24843 Jump if columns 144 onwards (girls' skool + half girls' playground) are off-screen
24832 0607 LD B,7 7 little girls
24834 CD0060 CALL 24576 Superimpose graphic bytes for little girls if necessary
24837 26C6 LD H,198 198=character number of little boy no. 9
24839 0611 LD B,17 2 little boys, 11 main characters, plus 211-214
24841 1813 JR 24862
24843 FE50 CP 80 80=assembly hall stage (or thereabouts)
24845 380B JR C,24858 Jump if columns 104 onwards (everything to right of tree, roughly) are off-screen
24847 0603 LD B,3 3 little girls (183-185)
24849 CD0060 CALL 24576 Superimpose graphic bytes for these little girls if necessary
24852 26C1 LD H,193 193=character number of little boy no. 4
24854 0616 LD B,22 7 little boys, 11 main characters, plus 211-214
24856 1804 JR 24862
24858 26BE LD H,190 190=character number of little boy no. 1
24860 0619 LD B,25 All 10 little boys, 11 main characters, plus 211-214
24862 CD0060 CALL 24576 Superimpose graphic bytes for these characters if necessary
24865 2170E1 LD HL,57712 8-byte buffer at 57712 now contains UDG to be transferred to screen
24868 D1 POP DE Retrieve appropriate display file address in DE

This entry point is used by the routine at 26958:
24869 0608 LD B,8 8 bytes per character square
24871 7E LD A,(HL) Transfer the graphic bytes
to the screen
24872 12 LD (DE),A
24873 2C INC L
24874 14 INC D
24875 10FA DJNZ 24871
24877 C9 RET Done