铁血丹心

 找回密码
 我要成为铁血侠客
搜索
查看: 2095|回复: 2

[DOS] 50指令翻译

[复制链接]
 楼主| 发表于 2025-6-15 18:27 | 显示全部楼层 |阅读模式

马上注册,结交更多侠友!

您需要 登录 才可以下载或查看,没有账号?我要成为铁血侠客

x
需配合KA以前编写的“kdef转lua脚本的工具”。该工具可以将原版的指令转为lua脚本,一般来说可以有利于阅读理解,如果框架中有完整指令脚本支持,也能直接执行。但其中的50指令部分只是简单转换了,仍旧难以理解。

新增加的工具可以将这部分50指令转为正常的程序格式,制作者也可以自己修改源码和配置,应该能转成可以直接执行的格式。

源码在:https://github.com/scarsty/kys-t ... %99%A8/abcd/trans50

一个转换范例:

转换前的指令:
  1. if CheckRoleSexual(256) == true then goto label0 end;
  2. ::label2::
  3.     instruct_50e(8, 0, 7236, 400, 0, 0, 0);
  4.     instruct_50e(34, 0, 15, 60, 285, 25, 0);
  5.     instruct_50e(33, 0, 400, 20, 65, 26211, 0);
  6.     instruct_50e(0, 1, 7237, 0, 0, 0, 0);
  7. ::label1::
  8.     instruct_50e(3, 0, 2, 1005, 1002, 100, 0);
  9.     instruct_50e(3, 0, 0, 1005, 1005, 2000, 0);
  10.     instruct_50e(32, 0, 1005, 4, 0, 0, 0);
  11.     instruct_50e(8, 1, 1, 400, 0, 0, 0);
  12.     instruct_50e(3, 0, 0, 1, 1, 1, 0);
  13.     instruct_50e(3, 0, 0, 1002, 1002, 1, 0);
  14.     instruct_50e(4, 0, 0, 1002, 4, 0, 0);
  15.     if CheckRoleSexual(256) == true then goto label1 end;
  16.         instruct_50e(34, 0, 80, 95, 150, 83, 0);
  17.         instruct_50e(39, 0, 4, 1100, 100, 85, 100);
  18.         instruct_50e(4, 0, 2, 100, 0, 0, 0);
  19.         if CheckRoleSexual(256) == true then goto label2 end;
复制代码



转换后的指令:
  1. ::label2::
  2. x[400] = "你為什么會選擇進入這個世界?";        --instruct_50e(8, 0, 7236, 400, 0, 0, 0);
  3. DrawRect(15, 60, 285, 25);        --instruct_50e(34, 0, 15, 60, 285, 25, 0);
  4. DrawString(x[400], 20, 65, 26211);        --instruct_50e(33, 0, 400, 20, 65, 26211, 0);
  5. x[1] = 7237;        --instruct_50e(0, 1, 7237, 0, 0, 0, 0);
  6. ::label1::
  7. x[1005] = x[1002] * 100;        --instruct_50e(3, 0, 2, 1005, 1002, 100, 0);
  8. x[1005] = x[1005] + 2000;        --instruct_50e(3, 0, 0, 1005, 1005, 2000, 0);
  9. temp = x[1005];        --instruct_50e(32, 0, 1005, 4, 0, 0, 0);
  10. x[temp] = talk(x[1]);        --instruct_50e(8, 1, 1, 400, 0, 0, 0);
  11. x[1] = x[1] + 1;        --instruct_50e(3, 0, 0, 1, 1, 1, 0);
  12. x[1002] = x[1002] + 1;        --instruct_50e(3, 0, 0, 1002, 1002, 1, 0);
  13. if x[1002] < 4 then jump_flag = false; else jump_flag = true; end;        --instruct_50e(4, 0, 0, 1002, 4, 0, 0);
  14. if jump_flag == true then goto label1 end;
  15. DrawRect(80, 95, 150, 83);        --instruct_50e(34, 0, 80, 95, 150, 83, 0);
  16. strs = {};
  17. for i=1, 4 do
  18. strs[i] = x[x[1100] + i - 1];
  19. end
  20. x[100] = menu(strs, #strs, 85, 100);        --instruct_50e(39, 0, 4, 1100, 100, 85, 100);
  21. if x[100] == 0 then jump_flag = false; else jump_flag = true; end;        --instruct_50e(4, 0, 2, 100, 0, 0, 0);
  22. if jump_flag == true then goto label2 end;
复制代码


可以看出是执行了一个选菜单。

再进一步的转换可以得到:
  1. repeat
  2. x[400] = "你為什么會選擇進入這個世界?";        --instruct_50e(8, 0, 7236, 400, 0, 0, 0);
  3. DrawRect(15, 60, 285, 25);        --instruct_50e(34, 0, 15, 60, 285, 25, 0);
  4. DrawString(x[400], 20, 65, 26211);        --instruct_50e(33, 0, 400, 20, 65, 26211, 0);
  5. x[1] = 7237;        --instruct_50e(0, 1, 7237, 0, 0, 0, 0);
  6. repeat
  7. x[1005] = x[1002] * 100;        --instruct_50e(3, 0, 2, 1005, 1002, 100, 0);
  8. x[1005] = x[1005] + 2000;        --instruct_50e(3, 0, 0, 1005, 1005, 2000, 0);
  9. x[x[1005]] = GetTalk(x[1]);        --instruct_50e(8, 1, 1, 400, 0, 0, 0);
  10. x[1] = x[1] + 1;        --instruct_50e(3, 0, 0, 1, 1, 1, 0);
  11. x[1002] = x[1002] + 1;        --instruct_50e(3, 0, 0, 1002, 1002, 1, 0);
  12. until x[1002] >= 4
  13. DrawRect(80, 95, 150, 83);        --instruct_50e(34, 0, 80, 95, 150, 83, 0);
  14. strs = {};
  15. for i=1, 4 do
  16. strs[i] = x[x[1100 + i - 1]];
  17. end
  18. x[100] = menu(85, 100, strs, #strs);        --instruct_50e(39, 0, 4, 1100, 100, 85, 100);
  19. until x[100] ~= 0
复制代码

可以看出此时逻辑已经比较清楚了。

需注意转换结果中没有考虑x的变量空间连续。本垃圾分析这个连续的条件很少被用到,如遇到也可以手动修改。



【武侠.中国】铁血丹心论坛(大武侠):致力于推广和发展武侠文化,让我们一起努力,做全球最大的武侠社区。
可能是目前为止最好的金庸群侠传MOD游戏交流论坛,各种经典武侠游戏等你来玩,各种开源制作工具等你来实现你的游戏开发之梦。
发表于 2025-6-28 21:09 | 显示全部楼层
代码可读性 += 1e-5
【武侠.中国】铁血丹心论坛(大武侠):致力于推广和发展武侠文化,让我们一起努力,做全球最大的武侠社区。
可能是目前为止最好的金庸群侠传MOD游戏交流论坛,各种经典武侠游戏等你来玩,各种开源制作工具等你来实现你的游戏开发之梦。
 楼主| 发表于 2026-8-3 10:36 | 显示全部楼层
目前进一步的分析可以将代码更简化一些,例如以下跳转场景的例子,看起来似乎好了一些。

同时,也尝试用cifa取代lua。

  1. instruct_50(26, 0, 0, 10590, 29, 200, 0);
  2. instruct_50(26, 0, 0, 10588, 29, 201, 0);
  3. instruct_50(26, 0, 0, 10586, 29, 202, 0);
  4. instruct_50(24, 13, 200, 3, 201, 202, 203);
  5. instruct_50(22, 3, 200, 203, 7, 204, 0);
  6. instruct_50(3, 0, 2, 204, 204, -1, 0);
  7. instruct_50(16, 5, 2, 200, 16, 204, 0);
  8. instruct_50(16, 5, 2, 200, 44, 201, 0);
  9. instruct_50(16, 5, 2, 200, 46, 202, 0);
  10. instruct_50(22, 3, 200, 203, 8, 205, 0);
  11. instruct_50(3, 0, 3, 206, 205, 100, 0);
  12. instruct_50(3, 0, 4, 207, 205, 100, 0);
  13. instruct_50(17, 1, 2, 200, 20, 208, 0);
  14. instruct_50(17, 1, 2, 200, 22, 209, 0);
  15. instruct_50(4, 0, 5, 208, 0, 0, 0);
  16. if CheckJumpFlag() == true then goto label0 end;
  17.     instruct_50(4, 0, 5, 209, 0, 0, 0);
  18.     if CheckJumpFlag() == true then goto label1 end;
  19.         instruct_50(16, 5, 2, 204, 48, 206, 0);
  20.         instruct_50(16, 5, 2, 204, 50, 207, 0);
  21. exit();
  22. ::label0::
  23. ::label1::
  24.         instruct_50(16, 5, 2, 204, 28, 206, 0);
  25.         instruct_50(16, 5, 2, 204, 30, 207, 0);
  26. exit();
复制代码
  1. SetX50(200, getcurrentscene());
  2. SetX50(201, getsceney());
  3. SetX50(202, getscenex());
  4. SetX50(203, GetS(GetX50(200), 3, GetX50(201), GetX50(202)));
  5. SetX50(204, GetD(GetX50(200), GetX50(203), 7));
  6. SetX50(204, GetX50(204) * -1);
  7. SetSubmapInfo(GetX50(200), 16 / 2, GetX50(204));
  8. SetSubmapInfo(GetX50(200), 44 / 2, GetX50(201));
  9. SetSubmapInfo(GetX50(200), 46 / 2, GetX50(202));
  10. SetX50(205, GetD(GetX50(200), GetX50(203), 8));
  11. SetX50(206, GetX50(205) / 100);
  12. SetX50(207, GetX50(205) % 100);
  13. SetX50(208, GetSubmapInfo(GetX50(200), 20 / 2));
  14. SetX50(209, GetSubmapInfo(GetX50(200), 22 / 2));
  15. if (GetX50(208) <= 0 && GetX50(209) <= 0) {
  16.     SetSubmapInfo(GetX50(204), 48 / 2, GetX50(206));
  17.     SetSubmapInfo(GetX50(204), 50 / 2, GetX50(207));
  18.     exit();
  19. }
  20. SetSubmapInfo(GetX50(204), 28 / 2, GetX50(206));
  21. SetSubmapInfo(GetX50(204), 30 / 2, GetX50(207));
复制代码


【武侠.中国】铁血丹心论坛(大武侠):致力于推广和发展武侠文化,让我们一起努力,做全球最大的武侠社区。
可能是目前为止最好的金庸群侠传MOD游戏交流论坛,各种经典武侠游戏等你来玩,各种开源制作工具等你来实现你的游戏开发之梦。

本版积分规则

小黑屋|手机版|铁血丹心

GMT+8, 2026-8-4 05:00

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表