Author Topic: Why is this slow?  (Read 3006 times)

0 Members and 1 Guest are viewing this topic.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Why is this slow?
« on: April 27, 2011, 04:09:20 am »
why is this code so freakin' sloooow?  ??? ???
Code: [Select]
#include "ti83plus.inc"
#include "DCS7.inc"   ;my DCS lib for Mimas, including it works a little different but thats np;
(DCS header here)
Xpos .equ saferam1
ld A,1
out ($20),A
B_CALL _runindicoff
res doneprgm,(IY+kbdFlags)
ld A,44
ld (Xpos),A
Game_Loop:
B_CALL _GrBufClr
ld A,(Xpos)
ld L,60
ld B,3
ld IX,Paddle
CALL isprite
CALL ifastcopy
B_CALL _GetCSC
push AF
CP skright
JP nz, cont
ld A,(Xpos)
CP 88
JP z,cont1
INC A
LD (Xpos), A
Cont:
pop AF
push AF
CP skleft
JP nz,cont1
ld A,(Xpos)
CP 0
JP z,cont1
dec A
ld (Xpos),A
Cont1:
pop AF
CP skclear
ret z
jp Game_Loop
Paddle:
.db %01111110
.db %10000001
.db %01111110
my apologies if I am not accurate with placing capitals in bcalls and if I forget to place an underscore before things, that is cuz I use Mimas.
I tested this and it ran a bit slow. What causes this?
I'm not a nerd but I pretend:

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Why is this slow?
« Reply #1 on: April 27, 2011, 07:20:35 am »
Hmm, how slow are you talking about? Could you post a screeny or the program? At a glance, I don't notice anything wrong with the code...

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Why is this slow?
« Reply #2 on: April 27, 2011, 07:23:18 am »
Its slow in the way that it takes like 10 secs to scroll from the right to the left side on the screen. Souvik (on cemetech) said it has to do with B_CALL _ClrGrBuf, but its slow even if I comment that out.
I'm not a nerd but I pretend:

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Why is this slow?
« Reply #3 on: April 27, 2011, 07:27:13 am »
Hmm, then I am not sure :/

Ashbad

  • Guest
Re: Why is this slow?
« Reply #4 on: April 27, 2011, 08:11:17 am »
To to eliminate GetCSC, all BCALLS are evil XD

though, direct input is a hard thing to learn, but if you understand how Ports/IN/OUT work, it's not horrible ;)

most BCALLS are much slower because they use TIos routines -- other than that there are a few optimizations that can be made in your code but they would add up to only like 1 FPS more :P  here is a good resource for Direct I/O http://z80-heaven.wikidot.com/direct-input-output

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Why is this slow?
« Reply #5 on: April 27, 2011, 08:13:08 am »
Ty, I'll look at that.

EDIT: Solved with direct input, yay!
« Last Edit: April 27, 2011, 11:28:13 am by aeTIos »
I'm not a nerd but I pretend:

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Why is this slow?
« Reply #6 on: April 27, 2011, 05:16:15 pm »
Yes, the problem was the GetCSC, but not for the reason that you think. The problem was not the fact that bcalls are slow. While bcalls are slow (1000 t-states for the actual jump) you have to remember that bcall(_grBufCpy) is >100,000 t-states.

The method that GetCSC uses is the same one that Ti-OS uses. A key check is run every interrupt and the result is placed in memory. GetCSC goes and finds that memory, and returns it. But, what the interrupt actually writes to memory is first parsed to make sure that it is what we want. For instance, if the last key scan showed that [5] was pressed, it doesn't want to return [5] again or else you'll press 5 twice. The same thing happens with arrow keys, except, with arrows, they repeat at a certain frequency. That way, menus aren't impossible to use. :)

The slowness is actually feature. The only problem is that you have much larger distances to travel so you don't want the delayed repeat.

Edit:
    Just think about scrolling while tracing. That's essentially what you are doing.
« Last Edit: April 27, 2011, 05:17:27 pm by thepenguin77 »
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Why is this slow?
« Reply #7 on: April 28, 2011, 03:12:19 am »
Yep, I figured out that it was the delay.
I'm not a nerd but I pretend: