Author Topic: Wait For Keys  (Read 22761 times)

0 Members and 1 Guest are viewing this topic.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Wait For Keys
« Reply #45 on: September 26, 2010, 06:09:12 pm »
By the way, how does the Pause command work? Does it loop NOPs?
« Last Edit: September 26, 2010, 06:09:32 pm by Deep Thought »




Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Wait For Keys
« Reply #46 on: September 26, 2010, 06:17:24 pm »
What happens if you don't? Does it not register the keypresses?
Yeah, like if I'm holding down 2nd it'll go on sometimes. :(

I assume so. Isn't a smaller delay enough, though? Personally I would hate if the delay was too long because then the game starts slowing down, which is bad if you are using grayscale.
I use loops like this in areas like the main menu of Jump!.  Try holding down 2nd on the main menu. :)

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Wait For Keys
« Reply #47 on: September 26, 2010, 07:34:44 pm »
The "Pause" command is a a loop of "djnz $+0" commands which is equivalent to about 850 nop's per pause number.

The original getkey(#) command waited 8 clock cycles which I think is enough for 6MHz.  getkey(0) was a separate routine which only waited 4 clock cycles.  I have now merged the 2 into a single command that waits 13 clock cycles which might be enough for 15MHz.  As a result, the getkey routine is a little larger, but each call to getkey(0) is 3 bytes less now, so the program size would actually go down if you were using it more than once.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Wait For Keys
« Reply #48 on: September 26, 2010, 07:35:55 pm »
What happens if you don't? Does it not register the keypresses?
Yeah, like if I'm holding down 2nd it'll go on sometimes. :(

I see. And I see why adding a pause would work: It wouldn't register the first keypress moment, but after the Pause, it starts registering.

The "Pause" command is a a loop of "djnz $+0" commands which is equivalent to about 850 nop's per pause number.

The original getkey(#) command waited 8 clock cycles which I think is enough for 6MHz.  getkey(0) was a separate routine which only waited 4 clock cycles.  I have now merged the 2 into a single command that waits 13 clock cycles which might be enough for 15MHz.  As a result, the getkey routine is a little larger, but each call to getkey(0) is 3 bytes less now, so the program size would actually go down if you were using it more than once.

Got it, and thanks. When do you think you'll update?




Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Wait For Keys
« Reply #49 on: September 26, 2010, 09:05:13 pm »
Well, 8 clock cycles times 15MHz/6MHz is 20 clock cycles... 13 still might not be enough...
Good luck making it work!
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Wait For Keys
« Reply #50 on: September 26, 2010, 09:25:12 pm »
I wonder if 20 would start being a bit slow when a game in particular checks for about 20 keys every loop? It might be nice if in 6 MHz the amount of clock cycles was kept lower in 6 MHz mode. You would have to make the parser detect which getkey commands are placed after Full and which ones are placed after Normal or something like that, though. Disregard my comment if the slow down is not noticeable when Getkey() is used in large amounts in one loop, though.

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Wait For Keys
« Reply #51 on: September 26, 2010, 09:28:32 pm »
Well, the main problem is that you can't tell whether or not you're currently in Full mode, and doing so would take more than 8 (and possibly 20) clock cycles. Maybe a getKey(#)r like I suggested could alleviate that by at least giving programmers the option?
And it shouldn't be too noticeable unless speed is very important.
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Wait For Keys
« Reply #52 on: September 26, 2010, 09:56:04 pm »
The speed is negligible.  If you checked for 80 key presses, it would be the same as an extra "Pause 1" which means each key would only add about 1/80th of a pause number.  The main reason I've been avoiding it is because it makes the code larger and having separate routines makes it even worse.  So at this point I think I'll just add an extra byte to give it a total of 20 clock cycles regardless of speed.  This should settle the matter.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Wait For Keys
« Reply #53 on: September 26, 2010, 09:58:12 pm »
Sounds good; can't wait for a release! :D
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Wait For Keys
« Reply #54 on: September 26, 2010, 10:20:05 pm »
Oh wow, disregard my comment, then. If the speed is this negligible, 20 clock cycles should be ok. Keep up the good work Quigibo :)