A83: Re: Animation with _ILine
[Prev][Next][Index][Thread]
A83: Re: Animation with _ILine
Hi!
I just wanted to thank you for your support. Especially Dan Englender whose
routine I'm now using in my program instead of ILine. What can I say: It
works. And it works fine and fast. It's a pity that the LCD-display is so
slow, so that I have to slow down the routine to make the hexagon visible.
But that's just a minor disadvantage compared to having such a fast line
drawing routine. :-) Perhaps I'll try Harper's routine as well as soon as I
get it.
I've added the code like it is now at the end of the mail. If you like to
you're invited to try it out. I hope it's the right version, if not please
tell me.
Good night, Alexander Mann
---
Code: (yes, maybe it looks a little bit messy)
.NOLIST
#define end .end
#define END .end
#define equ .equ
#define EQU .equ
#include "ti83asm.inc"
#include "tokens.inc"
.LIST
.org 9327h ;*** Hauptprogramm ***/main program
MainLoop:
ld a,18 ;Zähler auf 18 setzen/set counter to 18
ld hl,Daten
GLoop:
push af
push hl
ld de,PLOTSSCREEN+1
ld hl,PLOTSSCREEN
ld (hl),0
ld bc,768
ldir
;call _GRBUFCPY_V ;Puffer-->Screen
ld a,0FFh ;* Tastaturabfrage * (Tastaturreset)
out (1),a
ld a,0FDh ;Tastengruppe 2/key group 2
out (1),a
in a,(1)
cp 191 ;=Clear gedrückt/"clear" pressed
jr z,Exit ;-->Exit
ld b,3 ;Schleifenzähler
DreiHexagons: ;zeichnet drei Hexagons/draw three hexagons
pop hl ;Datenzeiger/data pointer
ld d,(hl) ;Koord. 1. Endpunkt nach DE
inc hl
ld e,(hl)
inc hl
push hl
push bc
call DrawAnim ;Hexagon zeichnen/draw the hexagon
pop bc
djnz DreiHexagons
pop hl ;HL-=4
dec hl
dec hl
dec hl
dec hl
push hl
call _GRBUFCPY_V ;Puffer-->Screen
ld bc,1000h
DelayLoop:
dec bc ;6
ld a,b ;4
or c ;4
jr nz,DelayLoop ;7
pop hl ;fertig->Datenzeiger holen/get data pointer
pop af
dec a ;A--
jr nz,GLoop
xor a
jr MainLoop
Exit:
pop hl
pop af
ret
;Animation
DrawAnim:
ld bc,47*256+50 ;1. Startpunkt
call Linie ;1. Linie
ld d,b ;2. Endpunkt: X bleibt gleich, Y=63-Ye1
ld a,63 ;63-->A = A=63
sub c ;-C = A=63-Ye1
ld e,a ;A-->E = Ye2=63-Ye1
push de ;Koordinaten brauchen wir nochmal
call Linie ;2. Linie
ld de,47*256+14 ;3. Endpunkt
call Linie ;3. Linie
pop de ;4. Endpunkt: X=94-Xe1, Y bleibt gleich (d.h. Y=Ye2=63-Ye1)
ld a,94 ;94-->A
sub d ;-D = A=94-Xe2
ld d,a ;A-->D = Xe4=94-Xe2
call Linie ;4. Linie
ld d,b ;5. Endpunkt: X bleibt gleich, Y=63-Ye4
ld a,63 ;63-->A = A=63
sub c ;-C = A=63-Ye4
ld e,a ;A-->E = Ye5=63-Ye4
call Linie ;5. Linie
ld de,47*256+50 ;1. Startpunkt = 6. Endpunkt
;Übergang in Linie
Linie:
push bc ;BC->HL
pop hl
push de
call fastline
pop bc ;n. Endpunkt = (n+1). Startpunkt/second point of line n=first
point of line (n+1)
ret
fastline: ;Dan Englender's routine
;displays a line to the graphbuffer
;input
;hl=x1, y1
;de=x2, y2
;output
;line is drawn to the graphbuffer
di
ld a,1
ld (xdir),a
ld (ydir),a
ld a,d
sub h
ld b,a
jp nc,flokx
neg
ld b,a
ld a,255
ld (xdir),a
flokx:
ld a,e
sub l
ld c,a
jp nc,floky
neg
ld c,a
ld a,255
ld (ydir),a
floky:
ld e,0 ;error
ld a,b
cp c
jp c,fly
ld d,b ;resx
inc b
fllx:
call pixelonfl
ld a,(xdir)
add a,h
ld h,a
ld a,e
add a,c
ld e,a
cp d
jp c,flxok
sub d
ld e,a
ld a,(ydir)
add a,l
ld l,a
flxok:
djnz fllx
ret
fly:
ld a,b
ld b,c
ld c,a
ld d,b
inc b
flly:
call pixelonfl
ld a,(ydir)
add a,l
ld l,a
ld a,e
add a,c
ld e,a
cp d
jp c,flyok
sub d
ld e,a
ld a,(xdir)
add a,h
ld h,a
flyok:
djnz flly
ret
pixelonfl:
push hl
exx
pop de
ld a,d
call getpix ;getpix == Ion get pixel routine
or (hl)
ld (hl),a
exx
ret
getPix: ;from the Ion shell
ld d,$00
ld h,d
ld l,e
add hl,de
add hl,de
add hl,hl
add hl,hl
ld de,PLOTSSCREEN
add hl,de
ld b,$00
ld c,a
and %00000111
srl c
srl c
srl c
add hl,bc
ld b,a
inc b
ld a,%00000001
getPixelLoop:
rrca
djnz getPixelLoop
ret
Daten:;data
.db 77,39, 75,39, 73,40, 70,40, 66,40, 62,40, 57,40, 52,40, 47,40
.db 42,40, 37,40, 37,40, 32,40, 28,40, 24,40, 21,40, 19,39, 17,39
.db 77,39, 75,39
xdir: ;for Dan Englender's routine
.db 0
ydir:
.db 0
.end
END