Author Topic: Prizm Getkey  (Read 11839 times)

0 Members and 1 Guest are viewing this topic.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Prizm Getkey
« Reply #15 on: March 27, 2011, 09:57:55 pm »
That would indeed be possible. It could probably be done very efficiently if you used the barrel shifter in the CPU to rotate the proper bit in the register into the T bit.

EDIT: Looking it over with the keyboard matrix from Insight, you can actually optimize GetKey at run-time if some information can be computed beforehand (presumably at compile-time):

Code: [Select]
Returns 1 in T bit if the current key is being pressed. Returns 0 in T bit otherwise.
R1= -1*Number of shifts (two's complement notation)
R2= Specific longword of keyboard matrix (A44B0000, A44B0004, or A44B0008)
MOV.L @R2,R3
SHLD R1,R3
« Last Edit: March 28, 2011, 02:04:17 am by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: Prizm Getkey
« Reply #16 on: August 19, 2011, 01:26:47 am »
I've been working a making a getkey library that is OS independent for my contest entry and this is what I have so far. Currently it supports reading the key matrix then converting it into a short length identifier. Multi key support is not added yet but is coming soon. Here is the library along with an example program. To use just send a 12 byte array pointer to CustomKey() which will fill the array with the key buffer. Then use BufferConvert() to convert the buffer into a usable identifier. The key identifiers can be found in the #define section of CustomKey.h. Standby for full documentation

Code: (CustomKey.h) [Select]
#define KEY_EXE 0x0004
#define KEY_RETURN 0x0004
#define KEY_NEGATIVE 0x0008
#define KEY_ANS 0x0008
#define KEY_EXP 0x0010
#define KEY_PI 0x0010
#define KEY_QUOTE 0x0010
#define KEY_POINT 0x0020
#define KEY_EQUAL 0x0020
#define KEY_SPACE 0x0020
#define KEY_NUM_ZERO 0x0040
#define KEY_IMAGINARY 0x0040
#define KEY_ALPHA_Z 0x0040
#define KEY_AC_ON 0x0101
#define KEY_OFF 0x0101
#define KEY_DIV 0x0204
#define KEY_CURLY_RIGHT 0x0204
#define KEY_ALPHA_T 0x0204
#define KEY_MULT 0x0208
#define KEY_CURLY_LEFT 0x0208
#define KEY_ALPHA_S 0x0208
#define KEY_NUM_SIX 0x0210
#define KEY_ALPHA_R 0x0210
#define KEY_NUM_FIVE 0x0220
#define KEY_FORMAT 0x0220
#define KEY_ALPHA_Q 0x0220
#define KEY_NUM_FOUR 0x0240
#define KEY_CATALOG 0x0240
#define KEY_ALPHA_P 0x0240
#define KEY_MINUS 0x0304
#define KEY_BRACKET_RIGHT 0x0304
#define KEY_ALPHA_Y 0x0304
#define KEY_PLUS 0x0308
#define KEY_BRACKET_LEFT 0x0308
#define KEY_ALPHA_X 0x0308
#define KEY_NUM_THREE 0x0310
#define KEY_ALPHA_W 0x0310
#define KEY_NUM_TWO 0x0320
#define KEY_MAT 0x0320
#define KEY_ALPHA_V 0x0320
#define KEY_NUM_ONE 0x0340
#define KEY_LIST 0x0340
#define KEY_ALPHA_U 0x0340
#define KEY_ARROW 0x0402
#define KEY_SWAP 0x0402
#define KEY_ALPHA_L 0x0402
#define KEY_COMMA 0x0404
#define KEY_MOVE 0x0404
#define KEY_ALPHA_K 0x0404
#define KEY_PARA_RIGHT 0x0408
#define KEY_RECIPROCAL 0x0408
#define KEY_ALPHA_J 0x0408
#define KEY_PARA_LEFT 0x0410
#define KEY_CUBIC_ROOT 0x0410
#define KEY_ALPHA_I 0x0410
#define KEY_FRAC_DEC 0x0420
#define KEY_MIXED_IMPROPER 0x0420
#define KEY_ALPHA_H 0x0420
#define KEY_FRAC 0x0440
#define KEY_MIXED 0x0440
#define KEY_ALPHA_G 0x0440
#define KEY_DEL 0x0508
#define KEY_INS 0x0508
#define KEY_UNDO 0x0508
#define KEY_NUM_NINE 0x0510
#define KEY_PASTE 0x0510
#define KEY_ALPHA_O 0x0510
#define KEY_NUM_EIGHT 0x0520
#define KEY_CLIP 0x0520
#define KEY_ALPHA_N 0x0520
#define KEY_NUM_SEVEN 0x0540
#define KEY_CAPTURE 0x0540
#define KEY_ALPHA_M 0x0540
#define KEY_RIGHT 0x0602
#define KEY_DOWN 0x0604
#define KEY_EXIT 0x0608
#define KEY_QUIT 0x0608
#define KEY_RAISE 0x0610
#define KEY_X_ROOT 0x0610
#define KEY_THETA 0x0610
#define KEY_SQUARE 0x0620
#define KEY_SQUARE_ROOT 0x0620
#define KEY_RADIAN 0x0620
#define KEY_ALPHA 0x0640
#define KEY_ALPHA_LOCK 0x0640
#define KEY_TAN 0x0702
#define KEY_REVERSE_TAN 0x0702
#define KEY_ALPHA_F 0x0702
#define KEY_COS 0x0704
#define KEY_REVERSE_COS 0x0704
#define KEY_ALPHA_E 0x0704
#define KEY_SIN 0x0708
#define KEY_REVERSE_SIN 0x0708
#define KEY_ALPHA_D 0x0708
#define KEY_LN 0x0710
#define KEY_E_X 0x0710
#define KEY_ALPHA_C 0x0710
#define KEY_LOG 0x0720
#define KEY_TEN_X 0x0720
#define KEY_ALPHA_B 0x0720
#define KEY_X 0x0740
#define KEY_ANGLE 0x0740
#define KEY_ALPHA_A 0x0740
#define KEY_F_SIX 0x0802
#define KEY_G_T 0x0802
#define KEY_F_FIVE 0x0804
#define KEY_G_SOLVE 0x0804
#define KEY_F_FOUR 0x0808
#define KEY_SKETCH 0x0808
#define KEY_F_THREE 0x0810
#define KEY_V_WINDOW 0x0810
#define KEY_F_TWO 0x0820
#define KEY_ZOOM 0x0820
#define KEY_F_ONE 0x0840
#define KEY_TRACE 0x0840
#define KEY_UP 0x0902
#define KEY_LEFT 0x0904
#define KEY_MENU 0x0908
#define KEY_SETUP 0x0908
#define KEY_VARS 0x0910
#define KEY_PRGM 0x0910
#define KEY_OPTN 0x0920
#define KEY_SHIFT 0x0940



void CustomKey( char * buffer);
short BufferConvert( char * buffer);

void CustomKey( char * buffer)
{
const char * keyaddress = 0xa44b0000;

for (int index = 0; index < 12; index++)
{
buffer[index] = keyaddress[index];
}
}

short BufferConvert( char * buffer)
{
short KeyResult;
for(short index = 0; index < 12; index++)
{
if(buffer[index] != 0)
KeyResult = (index << 8) | ((short) buffer[index]);
}
return KeyResult;
}
Code: (example) [Select]
#include <display.h>
#include <SYSTEM_syscalls.h>
#include <CustomKey.h>
#include <keyboard.h>

//
void main(void) {
int x = 1;
int y = 1;
int color = 0;
int mode = 0;
char keybuffer[12];
short key;
int iContinue = 1;

char* heart = "    ";
heart[2] = 0xE5;
heart[3] = 0xE2;
Bdisp_AllCr_VRAM();

while (iContinue) {
key = 0;
Bdisp_AllCr_VRAM();
PrintXY(x, y, heart, mode, color);
Bdisp_PutDisp_DD();
while (key == 0)
{
CustomKey( keybuffer );
key = BufferConvert(keybuffer);
}
switch (key) {
case KEY_EXIT:
iContinue = 0;
break;
case KEY_UP:
y = y == 1 ? 8 : y-1;
break;
case KEY_DOWN:
y = y == 8 ? 1 : y+1;
break;
case KEY_LEFT:
x = x == 0 ? 21 : x-1;
break;
case KEY_RIGHT:
x = x == 21 ? x=1 : x+1;
break;
case KEY_PLUS:
color = color == 7 ? 0 : color+1;
break;
case KEY_MINUS:
color = color == 0 ? 7 : color-1;
break;
case KEY_MULT:
mode = !mode;
break;
case KEY_DIV:
mode = !mode;
break;
}
}

return;
}





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 DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Prizm Getkey
« Reply #17 on: September 05, 2011, 04:07:00 pm »
I wonder if adding multi key support will be easy? Does the Prizm allows direct input like on TI calcs? (where instead of returning the keycode, it checks if a specific key was pressed or not)
« Last Edit: September 05, 2011, 04:07:26 pm by DJ_O »

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: Prizm Getkey
« Reply #18 on: September 05, 2011, 08:43:35 pm »
I wonder if adding multi key support will be easy? Does the Prizm allows direct input like on TI calcs? (where instead of returning the keycode, it checks if a specific key was pressed or not)
Yes the entire keyboard is hardware memory mapped so you can if any key is currently up or down without any difficulty. On the matter of multi key support that is easily done but I'm still working on the best way to implement the function in C that would be very simple for another Prizm coder to use.

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 JosJuice

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1344
  • Rating: +66/-14
    • View Profile
Re: Prizm Getkey
« Reply #19 on: September 06, 2011, 10:14:45 am »
I wonder if adding multi key support will be easy? Does the Prizm allows direct input like on TI calcs? (where instead of returning the keycode, it checks if a specific key was pressed or not)
Yep. Insight has an example of it (the "keyboard ports" option).

Ashbad

  • Guest
Re: Prizm Getkey
« Reply #20 on: September 06, 2011, 08:28:17 pm »
I wonder if adding multi key support will be easy? Does the Prizm allows direct input like on TI calcs? (where instead of returning the keycode, it checks if a specific key was pressed or not)
Yes the entire keyboard is hardware memory mapped so you can if any key is currently up or down without any difficulty. On the matter of multi key support that is easily done but I'm still working on the best way to implement the function in C that would be very simple for another Prizm coder to use.

Personally, passing and returning a key[] matrix by reference and checking like key[KEY_PRGM_F1] I think would be my favorite way.
« Last Edit: September 06, 2011, 08:28:44 pm by Ashbad »

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Prizm Getkey
« Reply #21 on: September 07, 2011, 12:44:08 pm »
It would be pretty easy to make an isKeyPressed macro like the Ndless library has.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Prizm Getkey
« Reply #22 on: September 07, 2011, 04:49:22 pm »
Does the prizm have a grid for the keys or can all keys be detected independent of each other?

Offline PierrotLL

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 19
  • Rating: +2/-0
    • View Profile
Re: Prizm Getkey
« Reply #23 on: November 28, 2011, 08:01:30 pm »
Old topic but it's done : keydown function