Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Demon on July 31, 2006, 03:24:00 pm

Title: [83+ xLIB] Scrolling Past the Screen in xLIB
Post by: Demon on July 31, 2006, 03:24:00 pm
What is a very fast way to scroll through a tilemap in xLIB when your cursor hits the edge of the screen?

I - Cursor size.
N - Where to start drawing tilemap - horiz.
O - Where to start drawign tilemap - vert.
L - cursor's horiz. coord (byte).
M - cursor's vert. coord (byte).

c1-->
CODE
ec1...
8:prgmPTMH
Repeat Ans
real(8
End
Ans->K
8:prgmPTMH
prgmPTMK
...c2
ec2
prgmPTMHc1
-->
CODE
ec1real(12,Ans,LB,MB,B-1+LB,B-1+MBc2
ec2
prgmPTMKc1
-->
CODE
ec1If K<5:Then
L+(K=3)-(K=2)->L
M+(K=1)-(K=4)->M
If L<0:Then
1->L
N-1->N
prgmPTMU
End
If L>10:Then
1->L
N+1->N
prgmPTMU
End
If M<0:Then
1->M
O-1->O
prgmPTMU
End
If M<8:Then
8->M
O+1->O
prgmPTMU
End
Endc2
ec2
prgmPTMHc1
-->
CODE
ec1real(2,1,N,O,L,M,0,J6,0,J4,Q,0,16/J
c2
ec2
Title: [83+ xLIB] Scrolling Past the Screen in xLIB
Post by: Zeromus on August 01, 2006, 03:15:00 am
That may be a possiblity. When I was doing T14 (nonGS) I was going to use 256 sprites (-54125+255) and I just made my sprite editor scroll down when the cursor hit the edge (to the next pic)
Title: [83+ xLIB] Scrolling Past the Screen in xLIB
Post by: Demon on August 01, 2006, 12:14:00 pm
Well I optimized it a bunch last night.  But I think it could be better...

B - Sprite size (8 or 16)
C - Sprite size - max bytes (2 for 8x8, 1 for 16x16)
H and V - Cursor coordinates.
I and J - The dimensions of the tilemap matrix.
L and M - Where to start drawing the tilemap from the matrix.
Q - The initial picture to get sprites from.

prgmPTMH - Deleted; now using PSE's hilite sub:
c1-->
CODE
ec1real(12,Ans,HB,VB,B+HB-1,B+VB-1c2
ec2

prgmPTMH
c1
-->
CODE
ec1If K<5:Then
H+(K=3)-(K=2->H
V+(K=1)-(K=4->V
(H>C6-1)-(H<->Y
If Ans:Then
(C6-1)(Ans=1->H
L+Y
Ans(Ans>=0)-(C6+Ans)I->L
prgmAPTMU:End
(V>C3-1)-(V<->Y
If Ans:Then
(C4-1)(Ans=1->V
M+Y
Ans(Ans>0)-(C4+Ans>J->M
prgmAPTMU:End
End
...c2
ec2

prgmAPTMU
c1
-->
CODE
ec1real(2,1,L,M,I,J,0,C6,0,C4,Q,0,16/Cc2
ec2
Title: [83+ xLIB] Scrolling Past the Screen in xLIB
Post by: kalan_vod on August 01, 2006, 04:44:00 pm
You could do that, or if you wanted you could input which pic at the start of the program.
Title: [83+ xLIB] Scrolling Past the Screen in xLIB
Post by: DJ Omnimaga on August 02, 2006, 03:49:00 am
change

Ans(Ans>=0)-(C6+Ans)I->L

to
Ans(Ans>=0)-I(C6+Ans->L

save one more byte ^^
Title: [83+ xLIB] Scrolling Past the Screen in xLIB
Post by: threefingeredguy on August 02, 2006, 10:07:00 am
-IC6-IAns+.5(Ans+abs(Ans->L

Not smaller, but it may be faster.
Title: [83+ xLIB] Scrolling Past the Screen in xLIB
Post by: kalan_vod on August 02, 2006, 02:56:00 pm
QuoteBegin-threefingeredguy+Aug 2 2006, 04:07 PM-->
QUOTE (threefingeredguy @ Aug 2 2006, 04:07 PM)
-IC6-IAns+.5(Ans+abs(Ans->L

Not smaller, but it may be faster.  

 Seems like it is over complicating things a bit.
Title: [83+ xLIB] Scrolling Past the Screen in xLIB
Post by: DJ Omnimaga on August 02, 2006, 02:59:00 pm
no clue, but i think he want it optimised for speed anyway, make sure he get what it means tho >.>
Title: [83+ xLIB] Scrolling Past the Screen in xLIB
Post by: kalan_vod on August 02, 2006, 03:07:00 pm
I think TFGs would be slower.
Title: [83+ xLIB] Scrolling Past the Screen in xLIB
Post by: DJ Omnimaga on August 02, 2006, 03:16:00 pm
aah I c, I dont know all optiomising tricks >.< *xlibman
Title: [83+ xLIB] Scrolling Past the Screen in xLIB
Post by: Dragon__lance on August 03, 2006, 05:58:00 am
yeah,for sure, TFG's is slower,i tested on the calc. /w xlibman's optimisations,it runs at 19 ticks,compared to 22 ticks ;)wink.gif