Understanding 'KeyXlate' from graphic item 561

Discuss Chaos Strikes Back for Windows and Linux, an unofficial port of Chaos Strikes Back to PC by Paul Stevens, as well as CSBuild, an associated dungeon editor.

Moderator: Zyx

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
ChristopheF
Encyclopedist
Posts: 1544
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Understanding 'KeyXlate' from graphic item 561

Post by ChristopheF »

As you know, I have started to document the content of the 5 binary items (558 to 562) found in the graphics.dat file of DM and CSB.
I am currently working on item 561 and in the comments from the CSBwin source code, there are "KeyXlate" entries that I don't understand (see here http://dmweb.free.fr/?q=node/1397):

Code: Select all

  i8  Byte18448[8];     // KeyXlate swapped when read        ...
  i8  Byte18440[12];    //  KeyXlate swapped when read        ...
  KeyXlate Byte18428[7];//  KeyXlate swapped when read        ...
  i8  Byte18400[28];    //  KeyXlate swapped when read
Here are the actual 76 bytes of data in the tables described above:

Code: Select all

00 94 00 1B
00 00 00 00

00 92 00 0D
00 93 00 1B
00 00 00 00

00 01 52 00     52: scan code of the 'Insert' key (Turn left)
00 03 48 00     48: scan code of the 'Up arrow' key (Move forward)
00 02 47 00     47: scan code of the 'Clr/Home' key (Turn right)
00 06 4B 00     4B: scan code of the 'Left arrow' key (Strafe left)
00 05 50 00     50: scan code of the 'Down arrow' key (Move backward)
00 04 4D 00     4D: scan code of the 'Right arrow' key (Strafe right)
00 00 00 00

00 07 3B 00     3B: scan code of the 'F1' key (Select champion 1)
00 08 3C 00     3C: scan code of the 'F2' key (Select champion 2)
00 09 3D 00     3D: scan code of the 'F3' key (Select champion 3)
00 0A 3E 00     3E: scan code of the 'F4' key (Select champion 4)
00 8C 00 13
00 93 00 1B
00 00 00 00
By examining the CSBwin code, I understand there is some translation occuring from keyboard scan codes to something related to the mouse and a Mouse Queue, but I don't understand exactly what is going on. What is the mouse queue and its purpose? What is exactly translated? What are the scan codes for which there is no comment in the data above?

Any help would be welcome!
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Gotta run right now.....but:

When the mouse button is clicked, the
location on the screen is turned into
a mouse-click-type. See HandleMouseEvents.
D6W, I think, has the type much of the time.

When the mouse is clicked, the 'event' is added
to the mouse event queue to be processed in
a first-in/first-out basis.

Some keyboard keys are translated to e
equivalent mouse-event-types. The up
arrow key is translated to a mouse click on
the up arrow. The event is added to the
mouse queue.

I will be back later to answer more detailed
questions.
User avatar
ChristopheF
Encyclopedist
Posts: 1544
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Post by ChristopheF »

Thank you for your reply. I had a look at HandleMouseEvents and identified the following mouse event types that are used in the KeyXlate from my previous post:

Code: Select all

0001 Turn left
0002 Turn right
0003 Move forward
0004 Move right
0005 Move backward
0006 Move left
0007 Select champion 1
0008 Select champion 2
0009 Select champion 3
000A Select champion 4

008C 140 Display disk menu
0092 147 Freeze game
0093 148 Unfreeze game
0094 149 ?
I cannot find mouse event type 149 (94h). What is it?


Also, what are the other scan codes? The ones I identified have their second byte set to 00.
The others have their first byte set to 00h. What does that mean? I found some documentation about the Atari keyboard controller and it only tells about scan codes that are 1 byte long, not 2 bytes.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

I cannot find mouse event type 149 (94h). What is it?
You must be using a base other than 10 or 16.
In fact, you must be using an odd (not a multiple
of 2) base. In fact, you must be using a non-
integral base. Sixteen and one-ninth to be
exact. :wink:

As I recall, the keyboard sends scan codes. The
operating system converts these to ASCII when
possible. Some keys a(or key combinations) did
not have ASCII equivalents. The keyboard reported
ASCII codes in the lower 8 bits and scan codes
in the upper 8 bits. Now don't yell at me if this
is wrong.....it is just what I recall from decades
ago. I still have the Atari Internals manual if
we need to dig into this in depth.
User avatar
ChristopheF
Encyclopedist
Posts: 1544
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Post by ChristopheF »

Thanks a lot, now I think it is all clear (with 94h = 148 it is better :) )

Code: Select all

00 94 00 1B     1B: ASCII code of 'Escape'              translated to mouse event type 0094 (148): Unfreeze game
00 00 00 00

00 92 00 0D     0D: ASCII code of 'Carriage return'     translated to mouse event type 0092 (146): Wake up
00 93 00 1B     1B: ASCII code of 'Escape'              translated to mouse event type 0093 (147): Freeze game
00 00 00 00

00 01 52 00     52: scan code of the 'Insert' key       translated to mouse event type 0001: Turn left
00 03 48 00     48: scan code of the 'Up arrow' key     translated to mouse event type 0003: Move forward
00 02 47 00     47: scan code of the 'Clr/Home' key     translated to mouse event type 0002: Turn right
00 06 4B 00     4B: scan code of the 'Left arrow' key   translated to mouse event type 0006: Move left
00 05 50 00     50: scan code of the 'Down arrow' key   translated to mouse event type 0005: Move backward
00 04 4D 00     4D: scan code of the 'Right arrow' key  translated to mouse event type 0004: Move right
00 00 00 00

00 07 3B 00     3B: scan code of the 'F1' key           translated to mouse event type 0007: Select champion 1
00 08 3C 00     3C: scan code of the 'F2' key           translated to mouse event type 0008: Select champion 2
00 09 3D 00     3D: scan code of the 'F3' key           translated to mouse event type 0009: Select champion 3
00 0A 3E 00     3E: scan code of the 'F4' key           translated to mouse event type 000A: Select champion 4
00 8C 00 13     13: ASCII code of 'CTRL-S'              translated to mouse event type 008C (140): Display disk menu
00 93 00 1B     1B: ASCII code of 'Escape'              translated to mouse event type 0093 (147): Freeze game
00 00 00 00
Post Reply

Return to “Chaos Strikes Back for Windows & Linux (CSBWin) / CSBuild”