Changes

Jump to: navigation, search

ACU March 1985 - Type-ins

4,504 bytes added, 05:47, 27 April 2009
/* Manipulating the Amstrad CPC464 Screen Display */
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><br/>
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><br/>
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><br/>
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>
3,699
edits