ALT-N change it to some other keys (How)

Second part of the best game ever made.
Thenasty
Sheikh
Sheikh
Posts: 34
Joined: February 27th, 2020, 10:19 pm

Re: ALT-N change it to some other keys (How)

Post by Thenasty »

it seems I am stuck at changing this


b into down arrow (i tried 50) cause 80 into hex is 50 not responding
crtrl-q into esc can't find 0x11 value on the same line so i can change to 0x1B
spacebar into Enter 0x20 change it to Enter (0x0D) not responding
Thenasty
Sheikh
Sheikh
Posts: 34
Joined: February 27th, 2020, 10:19 pm

Re: ALT-N change it to some other keys (How)

Post by Thenasty »

stumbled upon 2 other keys

J & K

assuming J = Joystick (this acting like SPACEBAR but in automatically it keeps moving back to fighting mode) until you press K I guess back to Keyboard mode.

Need to disable this also. Did no find 0x6A or 0x6B in the same line for J & K so I can change it.
Thenasty
Sheikh
Sheikh
Posts: 34
Joined: February 27th, 2020, 10:19 pm

Re: ALT-N change it to some other keys (How)

Post by Thenasty »

Thanks David, I figure out the Pop2 stopping at the last level

Thanks for the codes you have given me without those I would not have figured this out

80 3E 98 09 03

I change 03 to 0D






NOW only Karateka
CTRL-Q into ESC (never figured it out).
SPACEBAR to ENTER not responding but response to other regular keys
B into DOWN/ARROW not responding but response to other regular keys
Disable J & K

Thanks
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: ALT-N change it to some other keys (How)

Post by David »

Thenasty wrote: August 9th, 2020, 9:50 pm NOW only Karateka
CTRL-Q into ESC (never figured it out).
Search: 74 04 3C 11 74 01
Change: 11 to 1B
(The offset of the byte to change is 0x18AC.)

Details:

Code: Select all

code:16A3                      check_ctrl_q    proc near
code:16A3 B2 FF                                mov     dl, 0FFh
code:16A5 B4 06                                mov     ah, 6
code:16A7 CD 21                                int     21h             ; DOS - DIRECT CONSOLE I/O CHARACTER OUTPUT
code:16A7                                                              ; DL = character <> FFh ; but if DL=FFh then it's INPUT!
code:16A7                                                              ;  Return: ZF set = no character
code:16A7                                                              ;   ZF clear = character recieved, AL = character
code:16A9 74 04                                jz      locret_16AF
code:16AB 3C 11                                cmp     al, 11h         ; ctrl-q ; <-- Change to 1Bh (Esc)
code:16AD 74 01                                jz      loc_16B0
Thenasty wrote: August 9th, 2020, 9:50 pm SPACEBAR to ENTER not responding but response to other regular keys
Karateka handles keys in two separate branches: codes below 0x20 in one branch, and other codes in another branch.
The second branch checks those keys which control the player.
This means that if any of the player-control keys is changed to a key with code below 0x20 (such as Enter), then it won't work.

To remove this separation:

Search: 8B 46 0A 3D 20 00 7C 03 E9 88 00
Change: 90 90 90 90 90 90 90 90 90 90 90
(Offset: 0x2025)

At offset 0x20B0 write: 90 90 90 90 90 90 90 90

Details:

Code: Select all

We overwrite the following code with NOPs:

code:1E25 8B 46 0A                             mov     ax, [bp+key]
code:1E28 3D 20 00                             cmp     ax, ' '
code:1E2B 7C 03                                jl      then_less20h
code:1E2D E9 88 00                             jmp     else_less20h
code:1E30                      ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
code:1E30
code:1E30                      then_less20h:

code:1EB0 B8 FF FF                             mov     ax, 0FFFFh
code:1EB3 83 C4 06                             add     sp, 6
code:1EB6 5D                                   pop     bp
code:1EB7 C3                                   retn
code:1EB8                      ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
code:1EB8
code:1EB8                      else_less20h:
Thenasty wrote: August 9th, 2020, 9:50 pm Disable J & K
Search: 83 7E 0A 6A 75 11
Change 75 to EB.
(The offset of the byte to change is 0x1FFB.)

Search: 83 7E 0A 6B 75 11
Change 75 to EB.
(The offset of the byte to change is 0x2012.)

Details:

Code: Select all

code:1DF7 83 7E 0A 6A                          cmp     [bp+key], 'j'
code:1DFB 75 11                                jnz     loc_1E0E ; <-- change to JMP
code:1DFD E8 41 24                             call    play_sound_5
code:1E00 C7 06 46 DF 00 00                    mov     keyboard_mode, 0

code:1E0E 83 7E 0A 6B                          cmp     [bp+key], 'k'
code:1E12 75 11                                jnz     loc_1E25 ; <-- change to JMP
code:1E14 E8 2A 24                             call    play_sound_5
code:1E17 C7 06 46 DF 01 00                    mov     keyboard_mode, 1

Thenasty wrote: August 9th, 2020, 9:50 pm B into DOWN/ARROW not responding but response to other regular keys
The down arrow has a two-byte code, but the area at offset 0x71C2 can only have one byte per key.

I haven't found a solution to this yet.
Thenasty
Sheikh
Sheikh
Posts: 34
Joined: February 27th, 2020, 10:19 pm

Re: ALT-N change it to some other keys (How)

Post by Thenasty »

Thanks a lot David.

How I wish I could do what you do.

I would never have come up with all those 90 90 90 90 . . . .

Disabling the J & K and changing the SPACE (20) to ENTER (0D) all works.

Something about the CTRL-Q

Search: 74 04 3C 11 74 01
Change: 11 to 1B
(The offset of the byte to change is 0x18AC.)

The controls become unresponsive when you enter the Temple to the fight the First Samurai (from the beginning this would the 5th Samurai) .

It has nothing to do with the disabling the J & K and changing the SPACE to ENTER ( I tested this separately one by one).



Anyway thanks again.

PS: I am learning and challenged myself with a simple DOS game and manage to find where to change the controls (only 4 controls) for it.
I am just stuck on the ESC. This will take a while for me. I am guessing it would be some sort of JMP to skip the second ESC to be pressed.
Just need to press it one time to exit but I have to do it twice.

This game http://www.retrogames.cz/dos/bbabies.zip runs fast on the system but found a TSR program to slow it down to a playable speed.


This is what I found from this game.

Controls 1 2 3 Space (manage to change it to anything)
offset 6836 (31h)
offset 6842 (32h)
offset 684E (33h)
offset 689E (20)

bonus, I also found this 2 and just disabled those.
offset 685A (34h)
offset 6866 (36h)


Crossing fingers about the ESC (exit game on one press) to skip on screen
===============================================================


Anyway a big Thanks goes to you, stay safe... (just lost some family members and Friends from Covid-19). The Virus is Real and it Kills.



Thanks David
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: ALT-N change it to some other keys (How)

Post by Norbert »

Thenasty wrote: August 16th, 2020, 7:21 pm(just lost some family members and Friends from Covid-19)
Ouch. Sorry for your loss.
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: ALT-N change it to some other keys (How)

Post by David »

Thenasty wrote: August 16th, 2020, 7:21 pm Something about the CTRL-Q

Search: 74 04 3C 11 74 01
Change: 11 to 1B
(The offset of the byte to change is 0x18AC.)

The controls become unresponsive when you enter the Temple to the fight the First Samurai (from the beginning this would the 5th Samurai) .

It has nothing to do with the disabling the J & K and changing the SPACE to ENTER ( I tested this separately one by one).
Whoops, it seems this hack triggers the tamper protection built into Karateka!

Fortunately it can be fixed with this:
Search: 83 7E 08 02 75 03 E8 8A 25
Change: E8 8A 25 to 90 90 90
(offset: 0x1D14)

Details:

Code: Select all

code:1B0E 83 7E 08 02                          cmp     [bp+which_bal], 2
code:1B12 75 03                                jnz     loc_1B17
code:1B14 E8 8A 25                             call    tamper_check? ; <-- change to NOPs
code:1B17                      loc_1B17:

More about this tamper protection:

When you enter the castle (level 2), the game calculates the checksums of some parts of itself. (It just adds the bytes together.)
If they don't match the expected values then the game zeroes some variables related to the player's animation.
This means he can't move anymore unless you restart the game.

There are two checked parts.
One of them probably used to contain some disk-based copy protection, but now it contains the code which checks Ctrl+Q.
The previous hack changes this part.

I am going to post the disassembly of Karateka so those interested can see what I'm talking about.
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: ALT-N change it to some other keys (How)

Post by David »

Here is the disassembly of Karateka.
It's a separate post in case I move it into a new thread.
Attachments
Karateka_disasm_2020-08-20.zip
(420.27 KiB) Downloaded 71 times
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: ALT-N change it to some other keys (How)

Post by David »

Thenasty wrote: August 16th, 2020, 7:21 pm The controls become unresponsive when you enter the Temple to the fight the First Samurai (from the beginning this would the 5th Samurai) .
By the way, I found some people running into this:

1.
https://www.dosgames.com/forum/viewtopic.php?t=6886 wrote:
GameMaster.EXE wrote: When I enter level 2, the game crashes.
The_Sinister_Mastermind wrote: Do you get an error message of any sort?
GameMaster.EXE wrote: No, everything on the screen freezes except for the enemy, who moves around freely kicking and punching at the frozen main character, whose lives aren't affected by the blows for some reason, probably because the game is "frozen"
In the version I have, the player can die, though.

2.
https://www.dosbox.com/comp_list.php?showID=379&letter=K wrote: The 1994 version is useless. For example, the keyboard halts in the second level.

But the 1987 version works fine and there's neither a need for those files nor to mount a floppy.

All you need is to take the files PRNGAL and TITLE.BCG from the 1994 version and put them in the 1987 version's folder. That's it!
I wonder what is this "1994 version" of Karateka...
Thenasty
Sheikh
Sheikh
Posts: 34
Joined: February 27th, 2020, 10:19 pm

Re: ALT-N change it to some other keys (How)

Post by Thenasty »

Hi David, thanks for the update.

I have the 86/87 version of the game. Applied the changes you provided and works.

Tamper protection never came across my mind. Probably it's the same with the B = Bow, hence giving you the run-around (maybe a headache).

Anyway, I manage to grab the '94 version and tried it and don't see any difference. This version I grab had to be installed in a floppy but you can just SUBST the folder to A: and it ran.

Thanks for the disassembly of the program. I'm gonna poke my eyes in it and see what I can learn (looking forward some notes in there that you made).

Thanks again.
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: ALT-N change it to some other keys (How)

Post by David »

Thenasty wrote: August 20th, 2020, 5:03 pm Tamper protection never came across my mind. Probably it's the same with the B = Bow, hence giving you the run-around (maybe a headache).
Nah, it's simpler.
Bow can be changed into any key whose code is a single byte.
Only two-byte key codes can't be used there.

It's a limitation of the code which checks for the keys which control the player.
It can't even check for the left and right arrows directly.
So instead it checks for 4 and 6, and another part of the code turns the left and right arrows into 4 and 6 before the aforementioned code sees it.
Thenasty wrote: August 20th, 2020, 5:03 pm Anyway, I manage to grab the '94 version and tried it and don't see any difference.
Where did you find it?
Thenasty
Sheikh
Sheikh
Posts: 34
Joined: February 27th, 2020, 10:19 pm

Re: ALT-N change it to some other keys (How)

Post by Thenasty »

This site has it

https://www.myabandonware.com/game/karateka-8b

it say 86 on the web page, but the KARATEKA.EXE inside the zip file is dated 1994.

All the rest of the file looks like it's all the same from the 86.
Thenasty
Sheikh
Sheikh
Posts: 34
Joined: February 27th, 2020, 10:19 pm

Re: ALT-N change it to some other keys (How)

Post by Thenasty »

It looks like this game has 3 version floating around.
your included EXE in the disassembly has a CRC C7A533CF
I see another one here with this CRC 5D2C0AAF
and the 1994 Version CRC 127CB4B8


Let me know if you want any of this.

I can dump it in MS-OneDrive.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: ALT-N change it to some other keys (How)

Post by Norbert »

Thenasty wrote: August 20th, 2020, 11:50 pmIt looks like this game has 3 version floating around.
your included EXE in the disassembly has a CRC C7A533CF
I see another one here with this CRC 5D2C0AAF
and the 1994 Version CRC 127CB4B8
Attached is what I could find in various packages.
1x 3cbc4f4b
7x c7a533cf
1x 127cb4b8
2x 1c0b68a8

I could not find the 5d2c0aaf version.
(Or maybe your CRC is not crc32.)
Attachments
c7a533cf.zip
(581.56 KiB) Downloaded 71 times
127cb4b8.zip
(84.35 KiB) Downloaded 64 times
3cbc4f4b.zip
(83.06 KiB) Downloaded 69 times
1c0b68a8.zip
(1.64 MiB) Downloaded 92 times
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: ALT-N change it to some other keys (How)

Post by David »

Thenasty wrote: August 20th, 2020, 11:10 pm This site has it

https://www.myabandonware.com/game/karateka-8b

it say 86 on the web page, but the KARATEKA.EXE inside the zip file is dated 1994.

All the rest of the file looks like it's all the same from the 86.
On that page, someone complained about the "bug" caused by the tamper protection:
Xcalibre wrote: I lose Keyboard function after entering the house and hitting space bar to go to fight mode. Right after the cutscene... any ideas?

Thenasty wrote: August 20th, 2020, 11:50 pm It looks like this game has 3 version floating around.
your included EXE in the disassembly has a CRC C7A533CF
I see another one here with this CRC 5D2C0AAF
and the 1994 Version CRC 127CB4B8


Let me know if you want any of this.

I can dump it in MS-OneDrive.
Yes, please upload them.
Especially the 5D2C0AAF version is interesting, because Norbert didn't find it anywhere.
Post Reply