English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 28 November 2017, 13:20   #81
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
Quote:
Originally Posted by xboxown View Post
Hope you can map the Amiga keys into soon!!! - bites shirt -
me too

#1)
Code:
typedef unsigned short u16;
...
SDL_EnableUNICODE(1);
....
u16 system_alt_map[] = {30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 
				49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44};
....
	else if ((keysym->mod & KMOD_ALT) != 0) 
	{
		if ( (keysym->sym >= SDLK_a) && (keysym->sym <= SDLK_z)  )
		return system_alt_map[keysym->sym - SDLK_a] << 8;	// alt a-z
what does the array do with the return value. can anyone explain this?

do they use u16 because above they enable unicode and in the return value they shift
8 bit of the result,to get ascii values?

#2) I triggered some debug values - using printf ... %d ... :
Code:
event.c: keysym->sym: 13  - SDLK_a: 97          ---> return key
event.c: return value: 4222720
event.c: keysym->sym: 97  - SDLK_a: 97         ----> a
event.c: return value: 7680
event.c: keysym->sym: 115  - SDLK_a: 97         ----> s
event.c: return value: 7936
event.c: keysym->sym: 100  - SDLK_a: 97         ----> d
event.c: return value: 8192
event.c: keysym->sym: 102  - SDLK_a: 97         ----> f
event.c: return value: 8448
event.c: keysym->sym: 103  - SDLK_a: 97         ----> g
event.c: return value: 8704
event.c: keysym->sym: 104  - SDLK_a: 97         ----> j
event.c: return value: 8960
event.c: keysym->sym: 271  - SDLK_a: 97         ---->  enter
event.c: return value: 1735680
the return value of a-z are constant, while the return value of "enter" and "return" do change,
with each new start of nagi.
Code:
printf("event.c: return value: %d\n", (system_alt_map[keysym->sym - SDLK_a] << 8));
#3) strange thing, another function uses system_keymap function.
if I push return-key the result is 13, keys between a-z gives 0.
I still cannot find out where the math goes wrong here :/

anyone any idea?

Last edited by emufan; 28 November 2017 at 20:00.
emufan is offline  
Old 28 November 2017, 16:07   #82
xboxown
Registered User
 
Join Date: Dec 2012
Location: Vancouver/Canada
Posts: 678
Look here:

https://www.alt-codes.net/

System_alt_map array is coming from that.

My suggestion is replace the system_alt_map values to the map of the Amiga keys and replace all the SDLK_a through SDL_z with your own constant values for AmiSDLK_a through AmiSDLK_z with the Amiga key code at the link below:

http://whdload.de/docs/en/rawkey.html

For example look here

u16 system_alt_map[] = {30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50,
49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44};
...

Do you see 30? That is the up key right? For the Amiga equivalent would be 4C so in this code you would replace 30 with 4C it would be like this


u16 system_alt_map[] = {4C, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50,
49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44};

I am thinking the reason why they specified these certain characters in system_alt_map is that those are the characters you are not allowed to enter in the game. So all the system characters are to be ignored and only the values from a to z allowed entry. But what do I know.
xboxown is offline  
Old 28 November 2017, 16:24   #83
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
thanks, thats interesting. but I think the array includes chars a to z only.
so 30 (decimal) equals a
here I found IBM keyboard key code info,which lists:
30 (dec) --> 1E (hex) --> a
48 (dec) --> 30 (hex) --> b
46 (dec) --> 2E (hex) --> c
with the whdload website, i can try to make that array amiga-compatible

Last edited by emufan; 28 November 2017 at 16:40.
emufan is offline  
Old 28 November 2017, 16:36   #84
xboxown
Registered User
 
Join Date: Dec 2012
Location: Vancouver/Canada
Posts: 678
If what you say is true then use this website http://www.unit-conversion.info/texttools/hexadecimal/

Take each value and convert it to char then replace that with Amiga's equivalent.
xboxown is offline  
Old 28 November 2017, 16:38   #85
xboxown
Registered User
 
Join Date: Dec 2012
Location: Vancouver/Canada
Posts: 678
There ya go
xboxown is offline  
Old 28 November 2017, 16:40   #86
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
#1) thats cool, seems working this way:
Code:
u16 system_alt_map[] = {32, 53, 51, 34,  ....
Attached Thumbnails
Click image for larger version

Name:	nagi68k.png
Views:	86
Size:	3.6 KB
ID:	55641  
emufan is offline  
Old 28 November 2017, 16:42   #87
xboxown
Registered User
 
Join Date: Dec 2012
Location: Vancouver/Canada
Posts: 678
aaaaaaaaaaaaaaaaaaah!!!!!!!!!!!!! I WANT IT!! GIVE ME! GIVE ME! GIIIIIIIIIIIIVEEE ME!!!!!!!!!!!!!!!!!
xboxown is offline  
Old 28 November 2017, 16:44   #88
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
Quote:
Originally Posted by xboxown View Post
aaaaaaaaaaaaaaaaaaah!!!!!!!!!!!!! I WANT IT!! GIVE ME! GIVE ME! GIIIIIIIIIIIIVEEE ME!!!!!!!!!!!!!!!!!
only 5 chars done, need cigarette, then I'll finish it

#1) hmm, starting with the 6th char "f" - it did not work anymore.

right before you posted your findings, I made an attempt on another location in the code,
and these 5 lines were still active.

rewrote the array with amiga codes --> nothing

back to the 5 lines i wrote earlier, and voila - we have chars again.
i did insert in a loop those case things for all chars - using the original chars from the array.
this time i have to convert from dec to hex:
Code:
                return 0x0D;
            case SDLK_a:
                return 0x1E;
            case SDLK_b:
                return 0x30;
...
I dont get it, now I get wrong chars: a is "space" b is "0"
on some keys nagi quits, due to wrong chars, not in the font files

#2) I have no clue what I messed up. did reverse changes, old new array and so on. I can type some chars,
but the wrong ones, m ==1 n ==2 and some more.

#3) there is something wrong - with the working one in the image above,
one of the functions return "97" - now I get "30"
this does explain why I get 1,2,0, "space",$ and some more - we are too low in the ascii table, but why?
dec <-> hex conversation failure - no clue atm.

Last edited by emufan; 28 November 2017 at 19:46.
emufan is offline  
Old 28 November 2017, 18:51   #89
xboxown
Registered User
 
Join Date: Dec 2012
Location: Vancouver/Canada
Posts: 678
Unfortunately I am not at home as I am at work right now. It is now 9:46 AM when I posted it and the time you read it. I will not be back at home until 6:40 PM. Long way to go for me to try it out.

But here is my suggestion on this. Do a severe debug system. Here is how the debug system works. Return the code back to it's original, original, original form. Then underneath the

u16 system_alt_map[] = {30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50,
49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44};

put a print out string and wait for user input before moving on to the loop.

Then put an output string for key character. Write down in piece of paper the value for character a and the value for system_alt_map[] . Write down or print out the code of the if system on a paper and with your finger pretend your on that line as it loops one line at a time. Keep entering the values of a,b, c, d,e, f, g,h, i, j, k and so on.

With this information you should be able to have a proper conversion sheet of PC keys vs Amiga keys. You have the Amiga keys on whdload.de so you don't need to print it out but if you feel having it physical will be easy to read and understand, print that out.


Say the PC key for a is value as 32 and the Amiga key for a is value as 4F you replace the 32 with 4F and so on.

Also while you are at it, print out the string value SDLK_a, SDLK_b, etc and see if they are linked to PC or Amiga key values.

If these are constant values and they are correct then forget them but if those are the culprit then you may need to have your own SDLK_a constant value that match that of the Amiga's value.
xboxown is offline  
Old 28 November 2017, 19:44   #90
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
I did replace the PC keys with amiga values, switched back and forth, but nothing changed.

but as mentioned above, the "97" in the image above for letter "a",
this made me looking into the ascii table.

in a good mood again, i changed all the values in the "switch -> case" construct,
from the hex pc/amiga values to the decimal ascii values, starting with 97.

take a look at the image attached. commands like "look" do work, are recognized

#1) test the one attached and report back
I left the debug lines active, they report any key press. will remove them later.

#2) one strange thing, Nagi is a bit slow in winuae , fastest possible and JIT enabled.
but after some restarts of nagi it is blazing fast, out of a sudden. loading of the game is maybe 10x faster.
I have no clue why it's so slow initially. rather strange.
Attached Thumbnails
Click image for larger version

Name:	nagi68k-2.png
Views:	93
Size:	6.3 KB
ID:	55644  

Last edited by emufan; 28 November 2017 at 21:21.
emufan is offline  
Old 28 November 2017, 20:06   #91
xboxown
Registered User
 
Join Date: Dec 2012
Location: Vancouver/Canada
Posts: 678
Quote:
Originally Posted by emufan View Post
i did replace the pc keys with amiga values, switched back and forth, but nothing changed.

But as mentioned above, the "97" in the image above for letter "a",
this made me looking into the ascii table.

In a good mood again, i changed all the values in the "switch -> case" construct,
from the hex pc/amiga values to the decimal ascii values, starting with 97.

Take a look at the image attached. Commands like "look" do work, are recognized

#1) test the one attached and report back
i left the debug lines active, they report any key press. Will remove them later.

I love you!!

I promise to test it when I come home! PROMISE!

Last edited by xboxown; 28 November 2017 at 20:24.
xboxown is offline  
Old 28 November 2017, 20:40   #92
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
Quote:
Originally Posted by xboxown View Post
I promise to test it when I come home! PROMISE!
allright

#1) before u start a lengthy game, just test, if there are all letters available

#2) the "space" key was missing, I added it with ascii 144 , which is wrong, see image,
changed to (dec) 32 and it's working - try "open stove" in the Voodoo Girl game - in her house - 1st scene

Last edited by emufan; 29 November 2017 at 09:19.
emufan is offline  
Old 29 November 2017, 06:56   #93
xboxown
Registered User
 
Join Date: Dec 2012
Location: Vancouver/Canada
Posts: 678
Quote:
Originally Posted by emufan View Post
allright

#1) before u start a lengthy game, just test, if there are all letters available

#2) the "space" key was missing, I added it with ascii 144 , which is wrong, see image,
changed to (dec) 32 and it's working - try "open stove" in the Voodoo Girl game - in her house - 1st scene

AAAAAAAAAAAAAAAA!!!!!!!!!! IT IS BEAUTIFUL! IT WORKS! IT WORKS IT WORKS!!!!!!!!!!!!!!
xboxown is offline  
Old 29 November 2017, 09:06   #94
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
Quote:
Originally Posted by xboxown View Post
AAAAAAAAAAAAAAAA!!!!!!!!!! IT IS BEAUTIFUL! IT WORKS! IT WORKS IT WORKS!!!!!!!!!!!!!!
that's cool. so i will update the aminet version
emufan is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 21:19.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09465 seconds with 16 queries