Sprite output program
ZXNet echo conference «code.zx»
From Yura Nazarenko → To All 15 April 2000
Hello, All!
I decided to throw in a sprite output program for general use.
It is unlikely to be suitable for displaying sprites with changing
coordinates, and for animations with fixed sizes and
coordinates - just right! Here is the text itself with detailed
remarks.
=== cut ==========================================================
ORG 24576
CALL ZAPTAB ;Filling screen addresses
;Test part
LD IX,SPEED ;IX - output procedure address
LD BC,#8020 ;BC - dimensions in X and Y. X - text, Y - in
pixel
LD HL,#0000 ;HL - X and Y coordinates. X - text, Y -
by pixel
CALL ZAPVIV ;creating a withdrawal procedure
;sprite output
LD HL,0 ;sprite address
CALL SPEED ;output
RET ;output
;creating a sprite output procedure
ZAPVIV LD (IX),#F3 ;DI
INC IX
LD DE,STACK
LD (IX),#ED ;LD (STACK),SP
INC IX
LD (IX),#73
INC IX
LD(IX),E
INC IX
LD(IX),D
INC IX
LD (IX),#F9 ;LD SP,HL
INC IXLD (SIZE),BC ;remember the size and coordinates
LD (KOOR),HL
LD A,(SIZE+1);in A dimension along Y
LD B,A; in B we enter counter A
LD A,(KOOR+1);in A Y coordinate
ZAPVIV1 PUSH BC,AF ;remember the counter and Y coordinate
LD IY,TABLE ;in IY table address
LD B,0 ;BC = A
LD C,A
ADD IY,BC ;calculate table address
ADD IY,BC
LD H,(IY) ;take the desired address from the table
LD L,(IY+1)
LD A,(KOOR) ;add offset along X
SRL A
ADD A,L
LD L,A
LD A,(SIZE) ;in A size in X
SRL A ;divide by 2
LD B,A ;into B add counter A
ZAPVIV2 LD (IX),#E1 ;POP HL
INC IX
LD (IX),#22 ;LD (SCR_ADR),HL
INC IX
LD(IX),L
INC IX
LD(IX),H
INC IX
INC HL
INC HL
DJNZ ZAPVIV2 ;fill to the required size along X
POP AF,BC ;restore the Y coordinate and counterINC A ;increase the Y coordinate
DJNZ ZAPVIV1 ;fill to the required size along Y
LD DE,STACK
LD (IX),#ED ;LD SP,(STACK)
INC IX
LD (IX),#7B
INC IX
LD(IX),E
INC IX
LD(IX),D
INC IX
LD (IX),#FB ;EI
INC IX
LD (IX),#C9 ;RET
RET ;output
SIZE DS 2 ;buffer for size
KOOR DS 2 ;buffer for coordinates
;filling screen addresses
ZAPTAB LD IX,TABLE ;in IX where to fill
LD HL,#4000 ;first third
CALL ZAPADR
LD HL,#4800 ;second third
CALL ZAPADR
LD HL,#5000 ;third third
ZAPADR LD C,8;in C number of lines in thirds
LD DE,32 ;in DE offset to next line
ZAPADR1 PUSH HL ;remember the screen address
LD B,8 ;in B how many pixels are in a line
ZAPADR2 LD (IX),H ;put the screen address in IX
LD (IX+1),L
INC H
INC IX
INC IX
DJNZ ZAPADR2 ;out of pixels?POP HL ;yes! restore screen address
ADD HL,DE ;add offset to next line
DEC C ;decrease stitch counter
JR NZ,ZAPADR1;last line?
RET ;yes! exit
STACK DS 2 ;buffer for stack when sprite output
TABLE DS 384 ;buffer for screen address table
SPEED ;the output procedure will be here
=== cut ==========================================================
The subject manages to display 2/3 of the screen in one interruption. Or maybe
more.
All the best to you, All!
Yuri Nazarenko/Rezident/N-Discovery
e-mail: Yura_Nazarenko.sp0251@zxnet.spb.ru
From Aleksey Malov → To Yura Nazarenko 28 April 2000
Greetings, Yura!
Sat 15 Apr 2000 at 21:29:00 Yura Nazarenko and All were talking
on the topic Sprite output program.
YN> The subject manages to display 2/3 of the screen in one interruption. Or maybe
What's the point of storing 4 kilobytes per frame? You have a maximum of 24 frames in 128
You can put it in kilobytes.
I advise you to watch Antares' demo Devition - there is animation in full screen
in real-time it is unpacked in 1 interrupt (although for normal speed there
it is displayed 25 times per second). And it was done not in chunks, but in hi-resolution.
As I expected, it was not entire frames that were stored there, but the difference between them in
packaged. All animation in this demo is unpacked
more than 1 Mb, and the demo itself on disk is 200Kb. So learn to crank your progs.
YN> more.
Yeah! And why did the X-Trade people go on and on in RAGE about all this stuff?
optimization - people still don’t listen (or don’t know how to read). Which
it makes sense to use IX in a derailleur if you can do without it - both faster and
will take up less space.
I wish you health, happiness and creative Uzbeks.
Aleksey Malov aka VIVID/Brainwave.