Prev: 59751 Up: Map Next: 59887
59793: Blit Display Buffer To Screen
Used by the routine at GameStart.
Compare the primary and secondary display buffers and blit changed tiles to the Spectrum screen. Tiles with attribute bit 7 set are horizontally mirrored via BitmapMirrorLookup (see Blit_DisplayBufferRowLoop).
Choose which display buffer is "live" versus "previous" from DisplayBufferSelectFlag.
Blit_DisplayBuffer 59793 LD IX,22528 Point IX at the attribute file (22528 (attribute buffer)).
59797 LD HL,25504 Point HL at Primary Display Buffer (PrimaryDisplayBuffer).
59800 LD DE,27424 Point DE at Secondary Display Buffer (SecondaryDisplayBuffer).
59803 LD A,(29418) Load A with the display-buffer select flag (DisplayBufferSelectFlag).
59806 OR A Is the display-buffer select flag (DisplayBufferSelectFlag) zero? If so, jump to Blit_DisplayBuffer_AfterSelect.
59807 JR Z,Blit_DisplayBuffer_AfterSelect
59809 EX DE,HL Exchange DE and HL.
After selecting primary/secondary, walk 20 rows × 32 columns for dirty tiles.
Blit_DisplayBuffer_AfterSelect 59810 PUSH DE Copy DE into IY (using the stack).
59811 POP IY
59813 LD B,20 Load B with 20.
Begin one display-buffer row of 32 tile comparisons.
Blit_DisplayBufferLoop 59815 PUSH BC Stash BC on the stack.
59816 LD B,32 Load B with loop count 32.
Compare one tile's graphic-set / type / attribute triple against the secondary buffer.
Blit_DisplayBufferLoopB 59818 PUSH BC Stash BC on the stack.
59819 LD A,(HL) Fetch the next primary-buffer graphic-set byte.
59820 INC HL Advance the display-buffer pointer in HL by one byte.
59821 OR A Is A zero? If so, jump to Blit_DisplayBufferLoopB6.
59822 JP Z,Blit_DisplayBufferLoopB6
59825 LD C,A Keep the remaining count in C.
59826 LD E,0 Load E with 0.
59828 CP (IY+0) Does A match the referenced entity's type? If not, jump to Blit_DisplayBufferLoopB2.
59831 JR NZ,Blit_DisplayBufferLoopB2
59833 INC E Advance the low byte of the pointer/offset in DE.
Match the tile's entity-type byte; count matches in E.
Blit_DisplayBufferLoopB2 59834 LD A,(HL) Fetch the next script byte.
59835 OR A Is the next script byte zero? If so, jump to Blit_DisplayBufferLoopB6.
59836 JR Z,Blit_DisplayBufferLoopB6
59838 LD B,A Keep a copy of A in B.
59839 CP (IY+1) Does A match the referenced entity's flags byte 1? If not, jump to Blit_DisplayBufferLoopB3.
59842 JR NZ,Blit_DisplayBufferLoopB3
59844 INC E Advance the low byte of the pointer/offset in DE.
Match the tile's attribute byte; blit via Blit_DisplayBufferRow unless both prior bytes already matched.
Blit_DisplayBufferLoopB3 59845 INC HL Advance the display-buffer pointer in HL by one byte.
59846 LD A,(HL) Fetch the next script byte.
59847 CP (IY+2) Does A match the referenced entity's flags byte 2? If not, jump to Blit_DisplayBufferLoopB4.
59850 JR NZ,Blit_DisplayBufferLoopB4
59852 BIT 1,E Is bit 1 of E set? If so, jump to Blit_DisplayBufferLoopB5.
59854 JR NZ,Blit_DisplayBufferLoopB5
Blit this changed tile to the Spectrum screen through Blit_DisplayBufferRow.
Blit_DisplayBufferLoopB4 59856 PUSH HL Stash HL on the stack.
59857 CALL Blit_DisplayBufferRow Call Blit_DisplayBufferRow to blit Display Buffer Row.
59860 POP HL Restore HL from the stack.
Advance past this tile's triple and move to the next attribute column.
Blit_DisplayBufferLoopB5 59861 INC HL Advance the display-buffer pointer in HL by one byte.
59862 INC IX Advance IX to the next attribute-file column.
59864 LD DE,3 Load DE with 0003.
59867 ADD IY,DE IY+=DE.
59869 POP BC Restore BC from the stack.
59870 DJNZ Blit_DisplayBufferLoopB Decrease the loop counter in B and jump to Blit_DisplayBufferLoopB if more iterations remain.
59872 POP BC Restore BC from the stack.
59873 DEC B Decrease B by one.
59874 JP NZ,Blit_DisplayBufferLoop Jump to Blit_DisplayBufferLoop to continue if the comparison did not match.
59877 RET Return.
Treat a zero graphic-set as "blank": force bit 6 and skip the blit.
Blit_DisplayBufferLoopB6 59878 INC HL Advance the display-buffer pointer in HL by one byte.
59879 LD A,(HL) Fetch the next script byte.
59880 SET 6,A Set bit 6 of A.
59882 LD (IX+0),A Set the current entity's entity type.
59885 JR Blit_DisplayBufferLoopB5 Jump to Blit_DisplayBufferLoopB5 to continue the loop.
Prev: 59751 Up: Map Next: 59887