Author Topic: [SDK] IsKey too slow...  (Read 5225 times)

0 Members and 1 Guest are viewing this topic.

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
[SDK] IsKey too slow...
« on: August 19, 2011, 05:30:37 pm »
Hello everyone!
I want to find anything to avoid using IsKeyXX functions, there are really too slow. I don't want to use RFX, because there are bugs on G35+ (Press Left and the calc will understand Up and Left...)...

I can use the syscalls, or the adresses, if I have all the adresses (I Have functions to determine model)...
So, if anyone may light me to pointing a function that is faster than IsKey and non buggy, please?

Offline SimonLothar

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 129
  • Rating: +35/-1
    • View Profile
Re: [SDK] IsKey too slow...
« Reply #1 on: August 20, 2011, 06:38:00 am »
I want to find anything to avoid using IsKeyXX functions, there are really too slow.
If you inspect the syscall documentation included in my Prizm mini SDK, you will find the legacy syscall
0x06C4 int Keyboard_PRGM_GetKey( TBCDvalue*result );
Perhaps it is fast enough.

If not:

I used the following code as fast non-blocking keyboard read a long time ago (before I decided to use Keyboard_PRGM_GetKey)
It demonstrates the register-based keyboard read on the legacy systems.

Code: [Select]
void delay( void ){
int i;
  for (i=0;i<5;i++){};
}

//
int CheckKeyRow( int row ){
int result=0;
short*PORTB_CTRL=(void*)0xA4000102;
short*PORTM_CTRL=(void*)0xA4000118;
char*PORTB=(void*)0xA4000122;
char*PORTM=(void*)0xA4000138;
char*PORTA=(void*)0xA4000120;
short smask;
char cmask;

  smask = 0x0003 << ((row%8)*2);
  cmask = ~( 1 << (row%8) );
  if (row<8){
// configure port B as input, except for the "row to check"-bit, which has to be an output.
    *PORTB_CTRL = 0xAAAA ^ smask;
// configure port M as input; port M is inactive with row < 8                                                        
    *PORTM_CTRL = (*PORTM_CTRL & 0xFF00 ) | 0x00AA;
    delay();
    *PORTB = cmask;    // set the "row to check"-bit to 0 on port B
    *PORTM = (*PORTM & 0xF0 ) | 0x0F;    // port M is inactive with row < 8
  }else{
    *PORTB_CTRL = 0xAAAA;  // configure port B as input; port B is inactive with row >= 8
// configure port M as input, except for the "row to check"-bit, which has to be an output.
    *PORTM_CTRL = ((*PORTM_CTRL & 0xFF00 ) | 0x00AA)  ^ smask;
    delay();
    *PORTB = 0xFF;    // port B is inactive with row >= 8 (all to 1)
    *PORTM = (*PORTM & 0xF0 ) | cmask;  // set the "row to check"-bit to 0
  };
  delay();
  result = ~(*PORTA);   // a pressed key in the row-to-check draws the corresponding bit to 0
  delay();
  *PORTB_CTRL = 0xAAAA;
  *PORTM_CTRL = (*PORTM_CTRL & 0xFF00 ) | 0x00AA;
  delay();
  *PORTB_CTRL = 0x5555;
  *PORTM_CTRL = (*PORTM_CTRL & 0xFF00 ) | 0x0055;
  delay();

  return result;
}

I'll be back.

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: [SDK] IsKey too slow...
« Reply #2 on: August 24, 2011, 09:23:28 am »
Hello! I will test it in the near future, i will tell you, if it's compatible fot the others Graphs other than Fx9860 SD, but thanks!

EDIT: How does it works? How get I the key i want? I saw you're function is multi-key.

EDIT: YAARG! PRGM Getkey is as slow as BASIC mode! SHIT!

EDIT: YES! YES! YES! THAT WORKS, and I know How to use it! A row is a line of keys, and a bit is a key:
for the first row 000000 are F1-F2-F3-F4-F5-F6
and with (key & (1<<num))!=0, we get 0 or 1!
:3
« Last Edit: August 25, 2011, 06:18:13 pm by Eiyeron »

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: [SDK] IsKey too slow...
« Reply #3 on: August 31, 2011, 12:06:28 am »
Do you mean Prizm key detection in ASM/C is as slow as in BASIC? O.O

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: [SDK] IsKey too slow...
« Reply #4 on: August 31, 2011, 02:28:30 am »
Do you mean Prizm key detection in ASM/C is as slow as in BASIC? O.O
That particular system call is as slow as its Basic counterpart because that's what the interpreter calls when its running a Basic program. There are other much faster system calls available such as one that will return a buffer full of the keyboard data or even a non system call based one that I developed that works directly with the hardware and is extremely fast.

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: [SDK] IsKey too slow...
« Reply #5 on: August 31, 2011, 06:26:24 am »
No said about the Prgm Syscall! With a friend we could use your function to make  function like FastKeyDOwn. But why sometimes the calculator show me an reboot? (On sdk, error FFFFFF8)
« Last Edit: August 31, 2011, 06:27:38 am by Eiyeron »

Offline SimonLothar

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 129
  • Rating: +35/-1
    • View Profile
Re: [SDK] IsKey too slow...
« Reply #6 on: August 31, 2011, 10:55:47 am »
No said about the Prgm Syscall! With a friend we could use your function to make  function like FastKeyDOwn. But why sometimes the calculator show me an reboot? (On sdk, error FFFFFF8)
Post the source, please.
I'll be back.

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: [SDK] IsKey too slow...
« Reply #7 on: August 31, 2011, 12:38:39 pm »
Hum...
Here!

(And what about the particle system?)

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: [SDK] IsKey too slow...
« Reply #8 on: August 31, 2011, 02:35:15 pm »
Do you mean Prizm key detection in ASM/C is as slow as in BASIC? O.O
That particular system call is as slow as its Basic counterpart because that's what the interpreter calls when its running a Basic program. There are other much faster system calls available such as one that will return a buffer full of the keyboard data or even a non system call based one that I developed that works directly with the hardware and is extremely fast.
Ok phew. I was worried here. It would severely limit ASM/C development otherwise X.x

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: [SDK] IsKey too slow...
« Reply #9 on: September 07, 2011, 12:50:14 pm »
I saw changing the delay makes  the function buggy, also, trying ths funtion on certains programs is buggy...
Here the soure of the buggy program. (need to replace IsKeyDown by KeyDown)...