Changes

Jump to: navigation, search

ACU March 1985 - Type-ins

5,011 bytes removed, 14:48, 31 July 2009
/* Manipulating the Amstrad CPC464 Screen Display */
=Manipulating the Amstrad CPC464 Screen Display=
The SCREEN1.ASM, SCREEN2.ASM, SCREEN3.ASM, SCREEN4.ASM, SCREEN5.ASM contain the Z80 assembler code for the "Manipulating the Amstrad CPC464 Screen Display" article.<br/>See Amstrad Computer User, March 1985, page 103 for more details.<br/><br/>Routine 1<pre> ORG &8000 .start LD HL,XXXX ; address of top left corner of area LD DE,XXXX ; address of store area LD B,8 .loop1 PUSH BC PUSH HL LD B,8 ; number of horizontal lines .loop2 LD A,(HL) LD (DE),A INC DE INC HL DJNZ loop2 POP HL LD BC,&0000 ; add &0800 to screen address ADD HL,BC JR NC,loopend ; jump if total not more than &FFFF LD BC,&3FB0 AND A ; else subtract &3FB0 SBC HL,BC .loopend POP BC DJNZ loop1 RET</pre>Routine 2<pre> ORG &4000 .pixstr DEFB 0 .start LD HL,&C000 ; Address of top-left corner of screen LD E,&88 ; mask for left-most pixel in byte LD B,200 ; number of pixel lies in screen .loop1 PUSH BC PUSH HL ; save address of first byte on stack LD A,(HL) ; get first screen byte AND E ; mask off all pixels except left-most LD (pixstr),A ; store pixel for later CPL AND (HL) ; blank out pixel LD (HL),A ; update screen RLC (HL) ; rotate screen byte left LD B,79 ; number of bytes in line minus one .loop2 INC HL ; next byte LD A,(HL) AND E ; mask off all pixels except left-most LD D,A ; save pixel for later CPL AND (HL) ; blank out pixel LD (HL),A ; update screen RLC (HL) ; rotate screen byte left LD A,D ; recover pixel .loop3 RRC E ; rotate mask right one bit JR C,out1 ; jump out when mask bit rotates out SRL A ; else shift pixel right JR loop3 ; and repeat .out1 DEC HL ; back to previous byte OR (HL) LD (HL),A ; insert pixel into screen byte INC HL ; restore screen address DJNZ loop2 ; jump back unless finished with line LD A,(pixstr) ; recall stored pixel .loop4 RRC E ; rotate mask right one bit JR C,out2 ; jump out when mask bit rotates out SRL A ; else shift pixel right JR loop4 ; and repeat .out2 OR (HL) LD (HL),A ; insert pixel into screen byte POP HL LD BC,&0800 ADD HL,BC ; next line down JR NC,end ; jump if total not greater than &FFFF AND A LD BC,&3FB0 SBC HL,BC ; else subtract &3FB0 .end POP BC DJNZ loop1 ; jump back unless finished RET</pre>Routine 3<pre> ORG &4000 .pixstr DEFB 0 .start LD HL,&C04F ; Address of top-left corner of screen LD E,&11 ; mask for left-most pixel in byte LD B,200 ; number of pixel lies in screen .loop1 PUSH BC PUSH HL ; save address of first byte on stack LD A,(HL) ; get first screen byte AND E ; mask off all pixels except left-most LD (pixstr),A ; store pixel for later CPL AND (HL) ; blank out pixel LD (HL),A ; update screen RRC (HL) ; rotate screen byte left LD B,79 ; number of bytes in line minus one .loop2 DEC HL ; next byte LD A,(HL) AND E ; mask off all pixels except left-most LD D,A ; save pixel for later CPL AND (HL) ; blank out pixel LD (HL),A ; update screen RRC (HL) ; rotate screen byte left LD A,D ; recover pixel .loop3 RLC E ; rotate mask right one bit JR C,out1 ; jump out when mask bit rotates out SLA A ; else shift pixel right JR loop3 ; and repeat .out1 INC HL ; back to previous byte OR (HL) LD (HL),A ; insert pixel into screen byte DEC HL ; restore screen address DJNZ loop2 ; jump back unless finished with line LD A,(pixstr) ; recall stored pixel .loop4 RLC E ; rotate mask right one bit JR C,out2 ; jump out when mask bit rotates out SLA A ; else shift pixel right JR loop4 ; and repeat .out2 OR (HL) LD (HL),A ; insert pixel into screen byte POP HL LD BC,&0800 ADD HL,BC ; next line down JR NC,end ; jump if total not greater than &FFFF AND A LD BC,&3FB0 SBC HL,BC ; else subtract &3FB0 .end POP BC DJNZ loop1 ; jump back unless finished RET</pre>Routine 4<pre> ORG &4000 .start LD HL,&C000 ; top left corner of screen address LD B,200 ; number of pixel lines .loop1 PUSH BC PUSH HL ; save line start address on stack XOR A ; zero accumulator and clear carry flag LD B,80 ; number of bytes in line .loop2 RR (HL) ; rotate right, carry to d7, d0 to array INC HL ; next byte DJNZ loop2 ; loop until finished with line POP HL ; recover address of first byte in line RRA ; rotate last bit from carry into A OR (HL) LD (HL),A ; insert pixel into first byte LD BC,&0800 ADD HL,BC ; next pixel line JR NC,end ; jump if total not greater than &FFFF AND A LD BC,&3FB0 SBC HL,BC ; else subtract &3FB0 .end POP BC DJNZ loop1 ; loop unless finished RET</pre>Routine 5<pre> ORG &4000 .start LD HL,&C04F ; top left corner of screen address LD B,200 ; number of pixel lines .loop1 PUSH BC PUSH HL ; save line start address on stack XOR A ; zero accumulator and clear carry flag LD B,80 ; number of bytes in line .loop2 RL (HL) ; rotate right, carry to d7, d0 to array DEC HL ; next byte DJNZ loop2 ; loop until finished with line POP HL ; recover address of first byte in line RLA ; rotate last bit from carry into A OR (HL) LD (HL),A ; insert pixel into first byte LD BC,&0800 ADD HL,BC ; next pixel line JR NC,end ; jump if total not greater than &FFFF AND A LD BC,&3FB0 SBC HL,BC ; else subtract &3FB0 .end POP BC DJNZ loop1 ; loop unless finished RET</pre>
=Number Sort routine=
3,699
edits