Talk:Programming:Fast Sprites

From CPCWiki - THE Amstrad CPC encyclopedia!
Revision as of 05:57, 7 May 2007 by Prodatron (Talk | contribs) (Reverted edits by Gryzor (Talk); changed back to last version by Prodatron)

Jump to: navigation, search

If you have enough memory, the fastest way to plot sprites is to use the "direct addressing" methode: Here is a small example:

LD HL,screen address
LD BC,#800+[most used byte]
LD DE,#C050
LD (HL),byte1:INC HL    ;plot line 1
LD (HL),byte2:INC HL
LD (HL),C
LD A,H:ADD B:LD H,A
JR NC,line2
ADD HL,DE
.line2
LD (HL),byte6:DEC HL    ;plot line 2
LD (HL),C    :DEC HL
LD (HL),byte4
LD A,H:ADD B:LD H,A
JR NC,line3
ADD HL,DE
.line3
LD A,(HL):AND #55:OR byte7:LD (HL),A:INC HL    ;plot line 3 (contains transparent areas)
LD (HL),byte8:INC HL
LD A,(HL):AND #AA:OR byte9:LD (HL),A
RET

In mode 0 you will need two routines for every sprite, but I think there is no faster way to plot sprites on the CPC.