Prev: E41B Up: Map Next: E48B
E41C: Fill Strip With Pattern
Used by the routines at EndSegment and FillSlopeEdge.
Fills a strip of screen bytes with a pattern of two bytes, going up two pixel rows at a time, and then moves along to the next column of the strip by the amount in ColumnStep. The strip is not drawn where the column is within one character of the edge of the screen, and its height is reduced where it would go past the bottom of the screen or above the top of the terrain.
Input
B' Number of columns
C' Number of pairs of pixel rows
DE Pattern: the first byte in D and the second in E
HL' Screen address of the bottom of the first column
FillStripWithPattern E41C EXX Switch to the alternate registers.
E41D LD B,C B=C.
E41E LD A,L A=L.
E41F AND %00011111 Keep the bits of A that are set in 1F.
E421 DEC A Step A back.
E422 CP $1C Jump to FillStripWithPattern_Skip if A is 1C or more.
E424 JR NC,FillStripWithPattern_Skip
E426 LD A,($CE44) The segment row.
E429 CP $B8 Jump to FillStripWithPattern_Height if A is less than B8.
E42B JR C,FillStripWithPattern_Height
E42D JR Z,FillStripWithPattern_Height Jump to FillStripWithPattern_Height if the zero flag is set.
E42F SUB $B7 Subtract B7 from A.
E431 SRL A Shift A right.
E433 NEG Negate A.
E435 ADD A,B A gains B.
E436 LD B,A B=A.
E437 LD H,$57 H=57.
E439 LD A,L A=L.
E43A AND %00011111 Keep the bits of A that are set in 1F.
E43C OR %11000000 Set the bits of A that are set in C0.
E43E LD L,A L=A.
E43F JP FillStripWithPattern_Draw Jump to FillStripWithPattern_Draw.
FillStripWithPattern_Height E442 LD B,A B=A.
E443 LD A,($CE5A) The vertical step copy.
E446 NEG Negate A.
E448 ADD A,B A gains B.
E449 SUB $18 Subtract 18 from A.
E44B LD B,C B=C.
E44C JR NC,FillStripWithPattern_Draw Jump to FillStripWithPattern_Draw if the carry flag is clear.
E44E CPL Invert A.
E44F SRL A Shift A right.
E451 NEG Negate A.
E453 ADD A,B A gains B.
E454 LD B,A B=A.
FillStripWithPattern_Draw E455 LD A,($CE44) The segment row.
E458 SLA C Shift C left.
E45A SUB C Subtract C from A.
E45B SRL C Shift C right.
E45D LD ($CE44),A Update the segment row.
FillStripWithPattern_Rows E460 LD (HL),D Write D where HL points.
E461 DEC H Step H back.
E462 LD (HL),E Write E where HL points.
E463 CALL MoveUpARow Call MoveUpARow.
E466 DJNZ FillStripWithPattern_Rows Decrease B and jump to FillStripWithPattern_Rows until none remain.
E468 LD A,($CE36) The column step.
E46B ADD A,L A gains L.
E46C LD L,A L=A.
E46D EXX Switch to the alternate registers.
E46E DJNZ FillStripWithPattern Decrease B and jump to FillStripWithPattern until none remain.
E470 RET Return.
FillStripWithPattern_Skip E471 LD A,($CE44) The segment row.
E474 SLA B Shift B left.
E476 SUB B Subtract B from A.
E477 SRL B Shift B right.
E479 LD ($CE44),A Update the segment row.
E47C LD A,($CE36) The column step.
E47F ADD A,L A gains L.
E480 LD L,A L=A.
FillStripWithPattern_SkipRows E481 DEC H Step H back.
E482 CALL MoveUpARow Call MoveUpARow.
E485 DJNZ FillStripWithPattern_SkipRows Decrease B and jump to FillStripWithPattern_SkipRows until none remain.
E487 EXX Switch to the alternate registers.
E488 DJNZ FillStripWithPattern Decrease B and jump to FillStripWithPattern until none remain.
E48A RET Return.
Prev: E41B Up: Map Next: E48B