|
sl543001
中级用户
  
积分 499
发帖 225
注册 2008-12-30
状态 离线
|
    『楼 主』:
[源码解释][10-1-25更新]全彩迷宫 真正彩色的批处理游戏
使用 LLM 解释/回答一下
一个基于微型外部命令的彩色批处理脚本,基础部分已经基本完成!全部代码,控制在10KB以内.
当前为基础测试版,日后会添加更多有创意的游戏模式,欢迎大家提供意见和建议!
新动向:正在开发新的外部命令,以提高开发速度!
以使用新的外部命令SYBN dll 完成对个演示文件
http://www.cn-dos.net/forum/viewthread.php?tid=50188&fpage=1
-------------------------------------------------------------------------------------
咱这是技术贴,自然要有货才行,俺会不定期添加和修改代码解释!
『第 3 楼』: 解释:sybc命令的彩色输出
『第 4 楼』: 解释:sybc的键盘输入与DEBUG调用2进制程序
『第 5 楼』: 解释:地图压缩
『第 6 楼』: 解释:地图验证
『第 7 楼』: 解释:随机地图生成
『第 11 楼』: 解释:不兼容2K3的原因
『第 12 楼』: 解释:关于DEBUD
......等待日后,添加更多解释......
后面会慢慢附上其他代码解释,有疑问请回帖!
近期动向:近期忙着期末考试,正准备把基础功能单独分离出来搞成一个类库的样子,以后写其他脚本时一口气插进去就能用.
另外的心情:俺发现写解释比写代码轻松得多,头疼几个小时也不见得能憋出几行代码,最后一优化可能更没几行了- -!写代码解释就轻松得多,几分钟就出来了!
当然,俺的代码第一优先减小体积,并没有考虑可读性,所以不包含任何注释,看起来可能比较费劲,有问题就回帖,没问题也请回帖顶一下,嘻嘻!
Last edited by sl543001 on 2010-2-5 at 16:29 ]
A color batch script based on a micro external command , the basic part has been basically completed! The entire code is controlled within 10KB.
This is the basic test version. More creative game modes will be added in the future. Everyone is welcome to provide opinions and suggestions!
New development: Developing a new external command to improve the development speed!
Complete a demo file using the new external command SYBN dll
http://www.cn-dos.net/forum/viewthread.php?tid=50188&fpage=1
-------------------------------------------------------------------------------------
This is a technical post, so there must be content. I will add and modify code explanations from time to time!
『Building 3』: Explanation: Color output of the sybc command
『Building 4』: Explanation: Keyboard input of sybc and DEBUG calling binary program
『Building 5』: Explanation: Map compression
『Building 6』: Explanation: Map verification
『Building 7』: Explanation: Random map generation
『Building 11』: Explanation: Reasons for incompatibility with 2K3
『Building 12』: Explanation: About DEBUD
......Wait for the future, add more explanations......
Other code explanations will be attached later. If you have any questions, please reply!
Recent development: Recently busy with final exams, and am preparing to separate the basic functions and make them into a library-like form. Then when writing other scripts, I can just insert it all at once and use it.
Another mood: I find that writing explanations is much easier than writing code. It may not be possible to squeeze out a few lines of code after thinking hard for hours. In the end, an optimization may make it even fewer lines - -! Writing code explanations is much easier, and it comes out in a few minutes!
Of course, my code first prioritizes reducing the size , and does not consider readability, so there are no comments at all. It may be more difficult to read. If you have questions, please reply. If there are no questions, please also reply to support, hehehe!
Last edited by sl543001 on 2010-2-5 at 16:29 ]
此帖被 +70 点积分 点击查看详情 评分人:【 moniuming 】 | 分数: +15 | 时间:2010-1-16 21:42 | 评分人:【 netbenton 】 | 分数: +15 | 时间:2010-1-18 23:09 | 评分人:【 ccwan 】 | 分数: +20 | 时间:2010-1-21 18:10 | 评分人:【 zh159 】 | 分数: +20 | 时间:2010-1-29 15:58 |
|
附件
1: mgtm.rar (2010-1-15 22:53, 4.01 KiB,下载次数: 88)
附件
2: mg.GIF (2010-1-15 22:54, 13.51 KiB,下载次数: 19)
附件
3: mgsy.GIF (2010-1-15 22:54, 25.02 KiB,下载次数: 3)
附件
4: mgtm.GIF (2010-1-15 22:54, 23.05 KiB,下载次数: 2)
附件
5: yzsb.GIF (2010-1-15 22:54, 26.25 KiB,下载次数: 2)
|
|
2010-1-15 22:53 |
|
|
clamber
初级用户
 
积分 46
发帖 39
注册 2008-11-2
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
不错!看起来很复杂啊,高级命令。
Not bad! It looks complicated, advanced commands.
|
|
2010-1-16 13:49 |
|
|
sl543001
中级用户
  
积分 499
发帖 225
注册 2008-12-30
状态 离线
|
『第 3 楼』:
解释:sybc的彩色输出
使用 LLM 解释/回答一下
sybc.com大小仅240B,集成在脚本中,随脚本执行时生成,它源于修改过的tit.com输出彩色字符,依赖于16位子系统"command"
和基于相同命令的:bk子程序结合,可以使用较少的代码实现漂亮的效果:
只需要以下代码既可以实现顶楼的"图1",的选关画面.
::":bk"用于画出彩色的的矩形或直线,以及通过自定义样式画出一些有意思的形状
::画一条竖线 起始位置10008 25行 1列 颜色f1 样式2
call :bk 10008 25 1 f1 2
::画一条横线 起始位置12000 1行 40列 颜色f1 样式2
call :bk 12000 1 40 f1 2
::在两条线的交点,画出图形
sybc 11908f1╬
sybc 12006f1╬╬╬
sybc 12108f1╬
sybc 12108f1╬
::在屏幕上显示选关信息
sybc 10322f1%JBM% {20100115A 测试版}
sybc 10622f2按上键 $f0上 一 关 $f8
sybc 10722f2按下键 $f0下 一 关 $f8
sybc 10822f2按左键 $f0同步地图 $f8
sybc 10922f2按右键 $f0修改验证 $f8
sybc 11022f2按回车 $f0打开回显 $f8
sybc 11222f2空格键 $f0随机地图游戏
sybc 11322f2字母键 $f0自带地图游戏
==========================================
SYBC的参数格式如下
sybc ...
5个数字,第一个是占位数字,大小无所谓,,因为脚本对0开头数字可能出错,所以加上个数字凑成5位数,避过0开头,节约脚本的代码
和color的参数一样
要显示的文字,不能含有符号"$",因为后边要用
使用符号"$"结束一个彩色字符串的输出,这样就可以继续写下一个彩色字符串,从而连续输出多种颜色的字符而无需多次调用sybc,节约代码,提高速度.最后一个结束符可以省略
注意:以后版本的sybc参数格式可能有改变!
Last edited by sl543001 on 2010-1-18 at 20:53 ]
sybc.com is only 240B in size, integrated in the script, generated when the script is executed. It originates from modifying the output of tit.com to produce colorful characters, relying on the 16-bit subsystem "command" and combining with the :bk subroutine based on the same command. It can achieve beautiful effects with less code:
Only the following code can achieve the "Figure 1" in the top post, the level selection screen.
::":bk" is used to draw colorful rectangles or lines, and draw some interesting shapes through custom styles
::Draw a vertical line, starting position 10008 , 25 lines, 1 column, color f1 , style 2
call :bk 10008 25 1 f1 2
::Draw a horizontal line, starting position 12000 , 1 line, 40 columns, color f1 , style 2
call :bk 12000 1 40 f1 2
::Draw graphics at the intersection of the two lines
sybc 11908f1╬
sybc 12006f1╬╬╬
sybc 12108f1╬
sybc 12108f1╬
::Display level selection information on the screen
sybc 10322f1%JBM% {20100115A Test Version}
sybc 10622f2Press up key $f0Previous level $f8
sybc 10722f2Press down key $f0Next level $f8
sybc 10822f2Press left key $f0Synchronize map $f8
sybc 10922f2Press right key $f0Modify verification $f8
sybc 11022f2Press enter key $f0Enable echo $f8
sybc 11222f2Spacebar $f0Random map game
sybc 11322f2Letter key $f0Built-in map game
==========================================
The parameter format of SYBC is as follows
sybc ...
5 digits, the first one is a placeholder digit, the size doesn't matter, , because the script may have errors with numbers starting with 0, so add a digit to make it a 5-digit number, avoid numbers starting with 0, and save the code of the script
the same as the parameter of color
the text to display, cannot contain the symbol "$", because it will be used later
use the symbol "$" to end the output of a colorful string, so that you can continue to write the next colorful string, so as to continuously output characters of multiple colors without calling sybc multiple times, save code and improve speed. The last end symbol can be omitted
Note: The parameter format of sybc in future versions may change!
Last edited by sl543001 on 2010-1-18 at 20:53 ]
|
|
2010-1-17 16:03 |
|
|
sl543001
中级用户
  
积分 499
发帖 225
注册 2008-12-30
状态 离线
|
『第 4 楼』:
解释:sybc的键盘输入与DEBUG调用2进制程序
使用 LLM 解释/回答一下
sybc命令还集成了类似choice的截取键盘输入功能,但是它不支持延时.
它支持2种返回值
使用"sybc"命令不加参数可以获取键盘码
使用"sybn a"命令可以获取可以获取字符内码
附上sybc的debug代码:
set a=A100;E8A 80 CD89 C581 81 F980 7F06 CD09 8016 1F9 687F 64EB 83BE E800 65 5AE3 73E8;3C00 7F18 8853 E8C6 57 4CE3 65E8 3C00 7F4F 8845 B0C2 F602 50E2 A0B0 E6F6 15F;E8C7 3D 32E3 C387 393C 27E 904 FB80 7E39 8003 9C3 F24 E380 C00F 4E0 D808;B850 B800 750 295A 89F5 EBE9 AC46 ACAC ACAC F7E2 4CB4 21CD FAEB E088 4CB4;21CD ACAC 203C 475 F9E2 9EB C388 3CAC 7520 E202 C3F9 C387 302C EB80 B430;F60A E4 C3D8 5953 4E42 DED0 C4B8 3032 3930 3231 3631 AC24 243C A74 88AA AAD0;F5E2 B4EB B2EB E349 49AF ACE3 B6E8 E3FF 87A7 3CC3 7E39 402 8009 39FB 37E;C380 2409 800F FE3 10B2 E2F6 D800 C288 C7E2 86EB
set b=;RCX;F0;N SYBC.COM;W;Q;
(ECHO.%a:;=&ECHO.DW %&ECHO.%b:;=&ECHO.%)|DEBUG
使用debug可以吧2进制程序添加的脚本中,但要付出超过2.5倍的文件体积为代价
以下的代码经过了专门的优化,暂时还没有找到更省代码的方式,这使得我们不能方便的在脚本中集成较大的2进制程序
另外这里使用的是额外生成后再调用的方式使用2进制程序.
对于不常用或不方便额外生成文件等情况可以改用"set b=;RCX;F0;G;Q;"直接运行而无需生成文件.
而这样不能添加参数,不过还可以改用"set b=A80;DB 03 00 54 30 01;RCX;F0;G;Q;"
=============================================
注意:SYBC.com是基于tit.com通过反汇编后修改合成的16位程序,它继承了原tit.com的一些BUG和不足.
虽然俺很努力要消除这些BUG和不足,但至今效果有限,只得暂时绕过,但不排除日后这些BUG和不足再次作怪!
已知的BUG的和不足体现如下:
1.乱码,部分情况下中文字符发生局部乱码,无太大影响.
2.无显示,部分情况下该被覆盖显示的内容未被覆盖,无太大影响.
3.不支持windows 2003,由于兼容性问题sybc不支持等部分操作系统,体现为啥也不显示,影响较大,暂未找到解决办法!
Last edited by sl543001 on 2010-1-20 at 21:31 ]
The sybc command also integrates a keyboard input interception function similar to choice, but it does not support delay.
It supports 2 types of return values
Using the "sybc" command without parameters can obtain the keycode
Using the "sybn a" command can obtain the character internal code
Attach the debug code of sybc:
set a=A100;E8A 80 CD89 C581 81 F980 7F06 CD09 8016 1F9 687F 64EB 83BE E800 65 5AE3 73E8;3C00 7F18 8853 E8C6 57 4CE3 65E8 3C00 7F4F 8845 B0C2 F602 50E2 A0B0 E6F6 15F;E8C7 3D 32E3 C387 393C 27E 904 FB80 7E39 8003 9C3 F24 E380 C00F 4E0 D808;B850 B800 750 295A 89F5 EBE9 AC46 ACAC ACAC F7E2 4CB4 21CD FAEB E088 4CB4;21CD ACAC 203C 475 F9E2 9EB C388 3CAC 7520 E202 C3F9 C387 302C EB80 B430;F60A E4 C3D8 5953 4E42 DED0 C4B8 3032 3930 3231 3631 AC24 243C A74 88AA AAD0;F5E2 B4EB B2EB E349 49AF ACE3 B6E8 E3FF 87A7 3CC3 7E39 402 8009 39FB 37E;C380 2409 800F FE3 10B2 E2F6 D800 C288 C7E2 86EB
set b=;RCX;F0;N SYBC.COM;W;Q;
(ECHO.%a:;=&ECHO.DW %&ECHO.%b:;=&ECHO.%)|DEBUG
Using debug can add the binary program to the script, but at the cost of more than 2.5 times the file size
The following code has been specially optimized, and no more code-saving method has been found for the time being, which makes it inconvenient to integrate large binary programs in the script
In addition, the method of generating and then calling the binary program is used here.
For situations where it is not commonly used or it is inconvenient to generate files, etc., you can directly run "set b=;RCX;F0;G;Q;" without generating the file.
And this cannot add parameters, but you can also use "set b=A80;DB 03 00 54 30 01;RCX;F0;G;Q;"
=============================================
Note: SYBC.com is a 16-bit program synthesized by disassembling and modifying tit.com. It inherits some bugs and deficiencies of the original tit.com.
Although I have tried very hard to eliminate these bugs and deficiencies, the effect is limited so far, and I have to bypass them for the time being, but there is no exclusion that these bugs and deficiencies will act up again in the future!
The known bugs and deficiencies are reflected as follows:
1. Garbled code, in some cases, Chinese characters are partially garbled, which has no major impact.
2. No display, in some cases, the content that should be overwritten is not overwritten, which has no major impact.
3. Does not support Windows 2003. Due to compatibility issues, sybc does not support some operating systems, which is reflected as nothing is displayed, which has a greater impact, and no solution has been found for the time being!
Last edited by sl543001 on 2010-1-20 at 21:31 ]
|
|
2010-1-17 16:15 |
|
|
sl543001
中级用户
  
积分 499
发帖 225
注册 2008-12-30
状态 离线
|
『第 5 楼』:
解释:地图压缩
使用 LLM 解释/回答一下
一张完整的地图要包含21*40个方格的信息,每个方格格式大体为"f1■$",由此可以算出地图大小=21*40*5=4200B大约为4KB
对于脚本来说执行效率与文件大小成反比,大于10kb的脚本如果有很多跳转的话,可能慢如蜗牛.
很不巧,游戏类的脚本基本上大多含有大量的跳转,所以控制文件大小就必需了!
解决办法有两方面,一,优化压缩代码;二,拆分为多个文件;两手都要抓,两手都要硬!
由于当前只有一张地图,勉强还不用拆分文件,所以我们先对地图代码进行压缩!
压缩算法如下:
===============================================
1.把每个地图格子用一个字母代替 如"f1■$"用字母D代替,为了区分,我们使用变量DKD来代替f1■$",而在地图中则直接使用字母D
变量DK*在脚本的开头定义:DKA=F2∷$;DKB=F4·$;DKD=F1■$;DKE=F0¤$;DKQ=F0■$;DKV=F5∷$;DKW=F5:D$;DKX=F2☆$
另外,在游戏的地图模块或地图文件中还可以添加或是修改以上定义
===============================================
2.利用脚本推箱子的方法 http://www.cn-dos.net/forum/viewthread.php?tid=48603&fpage=1
把重复地块用数字替换,如把"AAAAAAA"替换为""A7,这样可以立刻再节约很多地图代码
===============================================
3.由于以上2步后地图文件减小了10倍但仍然大于400B,单张地图自然无所谓,但考虑到将来可能有很多张的图,所以需要进一步压缩代码.
为了进一步减小代码,继续使用地图中未使用的字母替代在不同位置重复的部分,将替代列表保存到额外的变量中
===============================================
最后单张地图大小控制在300B以内,完全可以在当前脚本中添加几张地图而不太大的增加文件体积.
当然这并不是最优的方法,也许以后能找到更好的方法替代它!
最终的地图格式如下:
SET DTM1=AMHE8AHHMK8O5QEME5ADKOEN2PO2DE6MQON9PN3QN2QEJONHAOEN2O2N3PEJONO7A2PNON2QOEJONHAP2NDE8AEJ3N9PQNKEMOE4DKP3ONHEMOK4NOE5ANQO4EMHE4AN9IO2OEMK4ODE8AIE4AEME3AHAN3QOI6AM3P9IPIE4AEJODKOE3AOIOAOEJOKAQQPP4EJHE6AE5APE6JK6O7PE$
SET DTS1=DTBH=7;DTBL=29;DTMY=-AMDANEAOOOPO3QE9HNPIMPJ9AK
当前版本的地图解压代码如下:
SET TC=ABCDEFGHIJKLMNOPQRSTUVWXYZ
SET DTMY=
SET /A TN=123456789,N=1,M=1,DTMYC=10,WZH=1,WZL=1
::::::::::::::::::::::::::::::::::::::::::::
::再此加入或读取地图信息存储到相应的变量中,例如把上面的代码插入到这里
::::::::::::::::::::::::::::::::::::::::::::
SET A=!DTS%GS%:;=$!
SET %A:$=&SET %
FOR /L %%A IN (1,1,%DTMYC%) DO SET /A LSBL1=%%A*3-3 &&SET /A LSBL2=%%A*3-1 &&(FOR /F "TOKENS=1,2" %%B IN ("!LSBL1! !LSBL2!") DO IF NOT "%%C" == "" SET dtJ%%A=!DTMY:~%%B,2! && SET DTY%%A=!DTMY:~%%C,1!)
for /l %%A in (%DTMYC%,-1,1) do for /f "tokens=1,2" %%B in ("!DTY%%A! !DTJ%%A!") DO SET DTM%GS%=!DTM%GS%:%%B=%%C!
ECHO %DTM1% >DTM1.TXT
FOR /L %%A IN (0,1,999) DO (SET /A T=%%A+1
FOR %%B IN (!T!) DO (FOR /F "TOKENS=1-3 DELIMS=/" %%1 IN ("!DTM%GS%:~%%A,1!/!DTM%GS%:~%%B,1!/!N!") DO (
IF "!TC:%%1=!" NEQ "!TC!" (IF "!TN:%%2=!" NEQ "!TN!" (SET K=%%2) ELSE (SET K=1)
FOR /L %%K IN (1,1,!K!) DO SET DT!N!.!M!=!DK%%1!&&SET /A M+=1
) ELSE (IF "%%1" EQU "-" SET /A N+=1,M=1)&&IF "!TN:%%2=!" == "$" GOTO ZRDTW)))
: ZRDTW
SET DT%DTBH%.%DTBL%=%DKX%
Last edited by sl543001 on 2010-1-20 at 21:06 ]
A complete map needs to contain information for 21*40 grids. The format of each grid is roughly "f1■$", so the map size can be calculated as 21*40*5=4200B, approximately 4KB.
For scripts, execution efficiency is inversely proportional to file size. A script larger than 10kb with many jumps may be as slow as a snail.
Unfortunately, most game - related scripts basically contain a large number of jumps, so it is necessary to control the file size!
There are two aspects of solutions: first, optimize and compress the code; second, split into multiple files; both hands need to be抓, both hands need to be hard!
Since there is currently only one map, it is barely not necessary to split files, so we first compress the map code!
The compression algorithm is as follows:
===============================================
1. Replace each map grid with a letter. For example, "f1■$" is replaced with the letter D. To distinguish, we use the variable DKD to represent "f1■$", and directly use the letter D in the map.
Variables D K* are defined at the beginning of the script: DKA = F2∷$; DKB = F4·$; DKD = F1■$; DKE = F0¤$; DKQ = F0■$; DKV = F5∷$; DKW = F5:D$; DKX = F2☆$
In addition, in the game's map module or map file, the above definitions can be added or modified.
===============================================
2. Use the method of the script push - box http://www.cn-dos.net/forum/viewthread.php?tid=48603&fpage=1
Replace repeated plots with numbers. For example, replace "AAAAAAA" with "A7", which can immediately save a lot of map code.
===============================================
3. After the above two steps, the map file is reduced by 10 times but is still larger than 400B. A single map is naturally no problem, but considering that there may be many maps in the future, further code compression is needed.
To further reduce the code, continue to use unused letters in the map to replace repeated parts in different positions, and save the replacement list to an extra variable .
===============================================
Finally, the size of a single map is controlled within 300B, and it is completely possible to add several maps in the current script without greatly increasing the file size.
Of course, this is not the optimal method. Maybe a better method can be found to replace it in the future!
The final map format is as follows:
SET DTM1=AMHE8AHHMK8O5QEME5ADKOEN2PO2DE6MQON9PN3QN2QEJONHAOEN2O2N3PEJONO7A2PNON2QOEJONHAP2NDE8AEJ3N9PQNKEMOE4DKP3ONHEMOK4NOE5ANQO4EMHE4AN9IO2OEMK4ODE8AIE4AEME3AHAN3QOI6AM3P9IPIE4AEJODKOE3AOIOAOEJOKAQQPP4EJHE6AE5APE6JK6O7PE$
SET DTS1=DTBH=7;DTBL=29;DTMY=-AMDANEAOOOPO3QE9HNPIMPJ9AK
The map decompression code of the current version is as follows:
SET TC=ABCDEFGHIJKLMNOPQRSTUVWXYZ
SET DTMY=
SET /A TN=123456789,N=1,M=1,DTMYC=10,WZH=1,WZL=1
::::::::::::::::::::::::::::::::::::::::::::
::Insert or read map information into corresponding variables here, for example, insert the above code here
::::::::::::::::::::::::::::::::::::::::::::
SET A=!DTS%GS%:;=$!
SET %A:$=&SET %
FOR /L %%A IN (1,1,%DTMYC%) DO SET /A LSBL1=%%A*3-3 &&SET /A LSBL2=%%A*3-1 &&(FOR /F "TOKENS=1,2" %%B IN ("!LSBL1! !LSBL2!") DO IF NOT "%%C" == "" SET dtJ%%A=!DTMY:~%%B,2! && SET DTY%%A=!DTMY:~%%C,1!)
for /l %%A in (%DTMYC%,-1,1) do for /f "tokens=1,2" %%B in ("!DTY%%A! !DTJ%%A!") DO SET DTM%GS%=!DTM%GS%:%%B=%%C!
ECHO %DTM1% >DTM1.TXT
FOR /L %%A IN (0,1,999) DO (SET /A T=%%A+1
FOR %%B IN (!T!) DO (FOR /F "TOKENS=1-3 DELIMS=/" %%1 IN ("!DTM%GS%:~%%A,1!/!DTM%GS%:~%%B,1!/!N!") DO (
IF "!TC:%%1=!" NEQ "!TC!" (IF "!TN:%%2=!" NEQ "!TN!" (SET K=%%2) ELSE (SET K=1)
FOR /L %%K IN (1,1,!K!) DO SET DT!N!.!M!=!DK%%1!&&SET /A M+=1
) ELSE (IF "%%1" EQU "-" SET /A N+=1,M=1)&&IF "!TN:%%2=!" == "$" GOTO ZRDTW)))
: ZRDTW
SET DT%DTBH%.%DTBL%=%DKX%
Last edited by sl543001 on 2010-1-20 at 21:06 ]
|
|
2010-1-18 19:55 |
|
|
sl543001
中级用户
  
积分 499
发帖 225
注册 2008-12-30
状态 离线
|
『第 6 楼』:
解释:地图验证
使用 LLM 解释/回答一下
在截图4中,我们看到了验证失败的提示框,它使用的自认也是sybc+:BK组合,代码如下:
call :BK 10824 15 4 81 3
SYBC 10926CF×$85 验证失败!$87
SYBC 1102680地图不可用,正在重制地图!
他是脚本对随机的图可用性验证失败后的提示,也就是出现永远也走不通时才出现.
其算法比较简陋,遇到如下左边情况时,将把地图替换为右边情况,循环重复直至无法改变或遇到地图出口为止.
■■■■■■■■■ ■■■■■■■■■ ■■■■■■■■■
■○∷∷∷∷∷∷■ ■○○∷∷∷∷∷■ ■○○○∷∷∷∷■
■∷■■■■■∷■ ■○■■■■■∷■ ■○■■■■■∷■
■∷■∷∷∷■∷■ ■∷■∷∷∷■∷■ ■○■∷∷∷■∷■
■∷■∷■■■∷■ ■∷■∷■■■∷■ ■∷■∷■■■∷■
■∷■∷∷∷∷∷■ ■∷■∷∷∷∷∷■ ■∷■∷∷∷∷∷■
■■■■■■■■■ ■■■■■■■■■ ■■■■■■■■■
由图可知检查○周围是否有∷,有则替换为○
从左上第一个格子开始,一行一行检查直至右下方最终结果会是下图
■■■■■■■■■
■○○○○○○○■
■○■■■■■○■
■○■∷∷∷■○■
■○■∷■■■○■
■○■∷∷∷○○■
■■■■■■■■■
由图可知,执行一遍后会漏掉好多方块,于是需要再检查一遍
为了防止出现极端情况例如类似如下左图,我们不能一直由左上至右下检查,而需要不断改变方向,脚本中就是使用4个方向轮流检查.
■■■■■■■■■ ■■■■■■■■■ ■■■■■■■■■
■○■∷∷∷■∷■ ■○■∷∷∷■∷■ ■○■∷∷∷■∷■
■○■∷■∷■∷■ ■○■∷■∷■∷■ ■○■∷■∷■∷■
■○■∷■∷■∷■ ■○■∷■∷■∷■ ■○■○■∷■∷■
■○■∷■∷■∷■ ■○■○■∷■∷■ ■○■○■∷■∷■
■○○○■∷∷∷■ ■○○○■∷∷∷■ ■○○○■∷∷∷■
■■■■■■■■■ ■■■■■■■■■ ■■■■■■■■■
===================================
附:验证部分代码:
: YZDT
IF %YZMS% == %YzM2% GOTO OK
IF %YZMS% == %YzM1% IF %SJDT% == 0 GOTO OK
TITLE %JBM% 验证地图
IF "%LSBLL%" == "180" GOTO NN
SET YZTG=NO
SET A=DT1.1=%DKB%;LSBLN=%LSBLM%;YZA5=^^^!YZA4^^^!;YZA4=^^^!YZA3^^^!;YZA3=^^^!YZA2^^^!;YZA2=^^^!YZA1^^^!;YZA1=^^^!YZA5^^^!;YZB5=^^^!YZB4^^^!;YZB4=^^^!YZB3^^^!;YZB3=^^^!YZB2^^^!;YZB2=^^^!YZB1^^^!;YZB1=^^^!YZB5^^^!
SET %A:;=&SET %
FOR /L %%A IN (%YZA2%) DO FOR /L %%B IN (%YZB2%) DO IF !DT%%A.%%B! == %DKB% (
SET /A YZH=%%A-1,YZL=%%B
FOR /F %%C IN ("^!DT!YZH!.!YZL!^!") DO SET B=%%C
IF !B! == %DKA% SET DT!YZH!.!YZL!=%DKB%&SET /A LSBLM+=1
IF !B! == %DKX% GOTO OK
SET /A YZH=%%A,YZL=%%B-1
FOR /F %%C IN ("^!DT!YZH!.!YZL!^!") DO SET B=%%C
IF !B! == %DKA% SET DT!YZH!.!YZL!=%DKB%&SET /A LSBLM+=1
IF !B! == %DKX% GOTO OK
SET /A YZL=%%B+1
FOR /F %%C IN ("^!DT!YZH!.!YZL!^!") DO SET B=%%C
IF !B! == %DKA% SET DT!YZH!.!YZL!=%DKB%&SET /A LSBLM+=1
IF !B! == %DKX% GOTO OK
SET /A YZH=%%A+1,YZL=%%B
FOR /F %%C IN ("^!DT!YZH!.!YZL!^!") DO SET B=%%C
IF !B! == %DKA% SET DT!YZH!.!YZL!=%DKB%&SET /A LSBLM+=1
IF !B! == %DKX% GOTO OK
)
SET /A LSBLL=LSBLL+1
IF "%LSBLM%" == "%LSBLN%" GOTO NN
GOTO YZDT
: OK
TITLE %JBM% 迷宫探秘
SET /A WZH=1,WZL=1,YZTG=0
FOR /L %%A IN (1,1,20) DO FOR /L %%B IN (1,1,39) DO IF !DT%%A.%%B! == %DKB% SET DT%%A.%%B=%DKA%
goto :eof
: NN
CALL :XS
call :BK 10824 15 4 81 3
SYBC 10926CF×$85 验证失败!$87
SYBC 1102680地图不可用,正在重制地图!
SET /A NANDU-=10,YZTG=1
IF %NANDU% LSS 10 SET NANDU=20
goto :eof
Last edited by sl543001 on 2010-1-19 at 23:41 ]
In Screenshot 4, we see a verification failure prompt box, which also uses the self - recognized sybc+:BK combination. The code is as follows :
call :BK 10824 15 4 81 3
SYBC 10926CF×$85 Verification failed! $87
SYBC 1102680 Map unavailable, remaking map!
It is the prompt after the script fails the verification of the random map's availability, that is, it appears when there is no way to go forever.
Its algorithm is relatively crude. When encountering the situation on the left below, it will replace the map with the situation on the right, and repeat the cycle until it cannot be changed or the map exit is encountered.
■■■■■■■■■ ■■■■■■■■■ ■■■■■■■■■
■○∷∷∷∷∷∷■ ■○○∷∷∷∷∷■ ■○○○∷∷∷∷■
■∷■■■■■∷■ ■○■■■■■∷■ ■○■■■■■∷■
■∷■∷∷∷■∷■ ■∷■∷∷∷■∷■ ■○■∷∷∷■∷■
■∷■∷■■■∷■ ■∷■∷■■■∷■ ■∷■∷■■■∷■
■∷■∷∷∷∷∷■ ■∷■∷∷∷∷∷■ ■∷■∷∷∷∷∷■
■■■■■■■■■ ■■■■■■■■■ ■■■■■■■■■
It can be seen from the figure that we check whether there is ∷ around ○. If there is, we replace it with ○ (in the actual script, a dot · is used. For the sake of beauty, a circle ○ is used instead because of the forum font).
Starting from the first grid in the upper left, we check row by row until the final result in the lower right will be the following figure
■■■■■■■■■
■○○○○○○○■
■○■■■■■○■
■○■∷∷∷■○■
■○■∷■■■○■
■○■∷∷∷○○■
■■■■■■■■■
It can be seen from the figure that many squares will be omitted after one execution, so we need to check again.
In order to prevent extreme situations such as the left figure below, we cannot always check from the upper left to the lower right. Instead, we need to change directions continuously. In the script, 4 directions are used to check in turn.
■■■■■■■■■ ■■■■■■■■■ ■■■■■■■■■
■○■∷∷∷■∷■ ■○■∷∷∷■∷■ ■○■∷∷∷■∷■
■○■∷■∷■∷■ ■○■∷■∷■∷■ ■○■∷■∷■∷■
■○■∷■∷■∷■ ■○■∷■∷■∷■ ■○■○■∷■∷■
■○■∷■∷■∷■ ■○■○■∷■∷■ ■○■○■∷■∷■
■○○○■∷∷∷■ ■○○○■∷∷∷■ ■○○○■∷∷∷■
■■■■■■■■■ ■■■■■■■■■ ■■■■■■■■■
===================================
Attachment: Verification part of the code:
: YZDT
IF %YZMS% == %YzM2% GOTO OK
IF %YZMS% == %YzM1% IF %SJDT% == 0 GOTO OK
TITLE %JBM% Verification map
IF "%LSBLL%" == "180" GOTO NN
SET YZTG=NO
SET A=DT1.1=%DKB%;LSBLN=%LSBLM%;YZA5=^^^!YZA4^^^!;YZA4=^^^!YZA3^^^!;YZA3=^^^!YZA2^^^!;YZA2=^^^!YZA1^^^!;YZA1=^^^!YZA5^^^!;YZB5=^^^!YZB4^^^!;YZB4=^^^!YZB3^^^!;YZB3=^^^!YZB2^^^!;YZB2=^^^!YZB1^^^!;YZB1=^^^!YZB5^^^!
SET %A:;=&SET %
FOR /L %%A IN (%YZA2%) DO FOR /L %%B IN (%YZB2%) DO IF !DT%%A.%%B! == %DKB% (
SET /A YZH=%%A-1,YZL=%%B
FOR /F %%C IN ("^!DT!YZH!.!YZL!^!") DO SET B=%%C
IF !B! == %DKA% SET DT!YZH!.!YZL!=%DKB%&SET /A LSBLM+=1
IF !B! == %DKX% GOTO OK
SET /A YZH=%%A,YZL=%%B-1
FOR /F %%C IN ("^!DT!YZH!.!YZL!^!") DO SET B=%%C
IF !B! == %DKA% SET DT!YZH!.!YZL!=%DKB%&SET /A LSBLM+=1
IF !B! == %DKX% GOTO OK
SET /A YZL=%%B+1
FOR /F %%C IN ("^!DT!YZH!.!YZL!^!") DO SET B=%%C
IF !B! == %DKA% SET DT!YZH!.!YZL!=%DKB%&SET /A LSBLM+=1
IF !B! == %DKX% GOTO OK
SET /A YZH=%%A+1,YZL=%%B
FOR /F %%C IN ("^!DT!YZH!.!YZL!^!") DO SET B=%%C
IF !B! == %DKA% SET DT!YZH!.!YZL!=%DKB%&SET /A LSBLM+=1
IF !B! == %DKX% GOTO OK
)
SET /A LSBLL=LSBLL+1
IF "%LSBLM%" == "%LSBLN%" GOTO NN
GOTO YZDT
: OK
TITLE %JBM% Maze Exploration
SET /A WZH=1,WZL=1,YZTG=0
FOR /L %%A IN (1,1,20) DO FOR /L %%B IN (1,1,39) DO IF !DT%%A.%%B! == %DKB% SET DT%%A.%%B=%DKA%
goto :eof
: NN
CALL :XS
call :BK 10824 15 4 81 3
SYBC 10926CF×$85 Verification failed! $87
SYBC 1102680 Map unavailable, remaking map!
SET /A NANDU-=10,YZTG=1
IF %NANDU% LSS 10 SET NANDU=20
goto :eof
Last edited by sl543001 on 2010 - 1 - 19 at 23:41 ]
|
|
2010-1-19 22:56 |
|
|
sl543001
中级用户
  
积分 499
发帖 225
注册 2008-12-30
状态 离线
|
『第 7 楼』:
解释:随机地图生成
使用 LLM 解释/回答一下
在没有大量自带地图的情况下,使用随机地图是唯一的出路!
最初使用的随机地图是完全无规律的随机布点,最终地图很难看.
后来在同学HEXIN.的建议下改用1/4永久墙,1/4永久空,1/2随机的方式生成出看起来比较整齐的随机地图.
==============================================
当前的随机地图生成算法一样很简陋,分为3个步骤:
1.制作地图边框,生成类似如下的图:
■■■■■■■■■■■
■∷∷∷∷∷∷∷∷∷■
■∷∷∷∷∷∷∷∷∷■
■∷∷∷∷∷∷∷∷∷■
■∷∷∷∷∷∷∷∷∷■
■∷∷∷∷∷∷∷∷∷■
■∷∷∷∷∷∷∷∷∷■
■∷∷∷∷∷∷∷∷∷■
■■■■■■■■■■■
2.在偶数行偶数列添加■,生成类似如下的图:
■■■■■■■■■■■
■∷∷∷∷∷∷∷∷∷■
■∷■∷■∷■∷■∷■
■∷∷∷∷∷∷∷∷∷■
■∷■∷■∷■∷■∷■
■∷∷∷∷∷∷∷∷∷■
■∷■∷■∷■∷■∷■
■∷∷∷∷∷∷∷∷∷■
■■■■■■■■■■■
3.如果是奇数行在偶数列随机生成,如果是偶数行在奇数列随机生成■
■■■■■■■■■■■
■∷○∷○∷○∷○∷■ ○为奇数行的偶数列的位置
■◎■◎■◎■◎■◎■ ◎为偶数行的奇数列的位置
■∷○∷○∷○∷○∷■
■◎■◎■◎■◎■◎■ 反复随机在以上位置生成■
■∷○∷○∷○∷○∷■ 随机的数量有变量NANDU控制
■◎■◎■◎■◎■◎■
■∷○∷○∷○∷○∷■
■■■■■■■■■■■
加上随机生成的出口,最终生成的地图类似下图:
■■■■■■■■■■■
■∷∷∷■∷■∷∷∷■
■∷■■■∷■■■∷■
■∷∷∷■∷∷∷∷∷■
■■■∷■∷■∷■■■
■∷■∷∷∷■∷■∷■
■■■■■☆■∷■■■
■∷■∷∷∷■∷∷∷■
■■■■■■■■■■■
然后就交给楼上的地图验证模块验证了!
=========================
附地图生成部分代码:
:SJ
SET /A SJDT=1,LSBL=1
FOR /L %%A IN (2,2,19) DO FOR /L %%B IN (2,2,38) DO SET DT%%A.%%B=%DKE%
: SJ1
SET /A LSBL+=1,sjh=%random%%%19+1,sjl=%random%%%19*2+2,sjhj=sjh/2,sjho=(sjh+1)/2
if %sjhj% == %sjho% set /a sjl-=1
SET DT%SJH%.%SJL%=%DKE%
IF %LSBL% LSS %NANDU% GOTO SJ1
: SJ2
SET /A sjh=%random%%%19+1,sjl=%random%%%19*2+2,A=(SJL+4)*(SJH+4)
IF %A% LSS 100 GOTO SJ2
SET A=DT1.2=%DKA%;DT2.1=%DKA%;DT2.3=%DKA%;DT3.2=%DKA%;DT4.3=%DKA%;DT3.4=%DKA%;DT%SJH%.%SJL%=%DKX%
SET %A:;=&SET %
GOTO :EOF
Last edited by sl543001 on 2010-1-20 at 21:16 ]
Without a large number of built-in maps, using random maps is the only way out!
The initially used random maps were completely irregular random layouts, and the final maps were very ugly.
Later, under the suggestion of classmate HEXIN., we switched to using a method of 1/4 permanent walls, 1/4 permanent spaces, and 1/2 random to generate relatively neat random maps.
==============================================
The current random map generation algorithm is still very crude, divided into 3 steps:
1. Make the map border, generate a graph similar to the following:
■■■■■■■■■■■
■∷∷∷∷∷∷∷∷∷■
■∷∷∷∷∷∷∷∷∷■
■∷∷∷∷∷∷∷∷∷■
■∷∷∷∷∷∷∷∷∷■
■∷∷∷∷∷∷∷∷∷■
■∷∷∷∷∷∷∷∷∷■
■∷∷∷∷∷∷∷∷∷■
■■■■■■■■■■■
2. Add ■ in even rows and even columns, generate a graph similar to the following:
■■■■■■■■■■■
■∷∷∷∷∷∷∷∷∷■
■∷■∷■∷■∷■∷■
■∷∷∷∷∷∷∷∷∷■
■∷■∷■∷■∷■∷■
■∷∷∷∷∷∷∷∷∷■
■∷■∷■∷■∷■∷■
■∷∷∷∷∷∷∷∷∷■
■■■■■■■■■■■
3. If it is an odd row, randomly generate ■ in even columns; if it is an even row, randomly generate ■ in odd columns
■■■■■■■■■■■
■∷○∷○∷○∷○∷■ ○ is the position of even columns in odd rows
■◎■◎■◎■◎■◎■ ◎ is the position of odd columns in even rows
■∷○∷○∷○∷○∷■
■◎■◎■◎■◎■◎■ Randomly generate ■ in the above positions repeatedly
■∷○∷○∷○∷○∷■ The number of randomness is controlled by variable NANDU
■◎■◎■◎■◎■◎■
■∷○∷○∷○∷○∷■
■■■■■■■■■■■
Add the randomly generated exit, and the finally generated map is similar to the following:
■■■■■■■■■■■
■∷∷∷■∷■∷∷∷■
■∷■■■∷■■■∷■
■∷∷∷■∷∷∷∷∷■
■■■∷■∷■∷■■■
■∷■∷∷∷■∷■∷■
■■■■■☆■∷■■■
■∷■∷∷∷■∷∷∷■
■■■■■■■■■■■
Then it is handed over to the map verification module upstairs for verification!
=========================
Attached is the part of the map generation code:
:SJ
SET /A SJDT=1,LSBL=1
FOR /L %%A IN (2,2,19) DO FOR /L %%B IN (2,2,38) DO SET DT%%A.%%B=%DKE%
: SJ1
SET /A LSBL+=1,sjh=%random%%%19+1,sjl=%random%%%19*2+2,sjhj=sjh/2,sjho=(sjh+1)/2
if %sjhj% == %sjho% set /a sjl-=1
SET DT%SJH%.%SJL%=%DKE%
IF %LSBL% LSS %NANDU% GOTO SJ1
: SJ2
SET /A sjh=%random%%%19+1,sjl=%random%%%19*2+2,A=(SJL+4)*(SJH+4)
IF %A% LSS 100 GOTO SJ2
SET A=DT1.2=%DKA%;DT2.1=%DKA%;DT2.3=%DKA%;DT3.2=%DKA%;DT4.3=%DKA%;DT3.4=%DKA%;DT%SJH%.%SJL%=%DKX%
SET %A:;=&SET %
GOTO :EOF
Last edited by sl543001 on 2010-1-20 at 21:16 ]
|
|
2010-1-20 20:41 |
|
|
cxchcq
新手上路

积分 16
发帖 12
注册 2010-1-19
状态 离线
|
|
2010-1-21 17:33 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
|
2010-1-21 18:09 |
|
|
Jays
新手上路

积分 10
发帖 7
注册 2006-10-31
状态 离线
|
|
2010-1-22 10:31 |
|
|
sl543001
中级用户
  
积分 499
发帖 225
注册 2008-12-30
状态 离线
|
『第 11 楼』:
解释:不兼容2K3的原因[未证实]
使用 LLM 解释/回答一下
脚本彩色输出使用的com程序是16位DOS程序,
要在非DOS系统下运行,需要模拟系统.
windows 98/2000/XP/2003......等系统使用command.exe运行16位DOS程序.
从windows 2000起默认shell改用基于32位的cmd.exe,从此脚本的扩展名也从bat改为cmd.
在windows 2000/XP中,一旦使用16位DOS程序.系统将自动从cmd.exe切换到command.exe,并不在自动切回.
而windows 2003中使用16位DOS程序.系统将自动从cmd.exe切换到command.exe,完成后自动切回cmd.exe.
==========================================
为啥呢?因为command.exe默认不支持中文哦,要不然咱干嘛在脚本开头加上chcp 437 graftabl 936 强制改为中文显示.
微软正在有计划的淘汰16位程序,这只是第一步!
当然微软有他的理由,他可能会说:"你瞧!你的cmd窗口宽度最多80,但是脱离16位dos程序后,你的cmd窗口可以拉长哦!"
当然,暗地里的原因他是不会告诉你的!推荐大家了解一下"WINter"联盟.
Last edited by sl543001 on 2010-1-23 at 18:17 ]
The COM program used for colorful output of scripts is a 16-bit DOS program. To run it under a non-DOS system, a simulation system is needed. Systems like Windows 98/2000/XP/2003... use command.exe to run 16-bit DOS programs. Starting from Windows 2000, the default shell is changed to the 32-bit cmd.exe, and from then on, the extension of the script is changed from bat to cmd. In Windows 2000/XP, once a 16-bit DOS program is used, the system will automatically switch from cmd.exe to command.exe and will not switch back automatically. While in Windows 2003, when a 16-bit DOS program is used, the system will automatically switch from cmd.exe to command.exe and then automatically switch back to cmd.exe.
==========================================
Why is that? Because command.exe does not support Chinese by default. Otherwise, why would we add chcp 437 graftabl 936 at the beginning of the script to force it to display in Chinese. Microsoft is phasing out 16-bit programs on purpose, and this is just the first step!
Of course, Microsoft has its reasons. It might say, "You see! The maximum width of your cmd window is at most 80, but after getting rid of 16-bit DOS programs, your cmd window can be stretched!"
Of course, the real reason behind it won't be told to you! It is recommended that everyone learn about the "WINter" alliance.
Last edited by sl543001 on 2010-1-23 at 18:17 ]
|
|
2010-1-23 18:10 |
|
|
sl543001
中级用户
  
积分 499
发帖 225
注册 2008-12-30
状态 离线
|
『第 12 楼』:
解释:关于DEBUD
使用 LLM 解释/回答一下
windows系列中DEBUG是16位子系统的调试工具,也就是说它只针对16位子系统有效.貌似不同cmd窗口运行同时DEBUG相互之间没有关联.这样的话,DEBUG这个在DOS时代超级牛X的大神在2000以后的系统中用途就有限了.不过我们仍然可以利用它发挥余热,为本们贡献力量.
===============================================
DUGUG在脚本中目前比较常用的功能就是输出com程序.
我们使用a+db或a+dw或e等指令吧汇编源代码或16进制代码输入到DEBUG.然后使用W指令输出的文件,然后运行文件.这个过程可以制造出"假单文件"的脚本,当然,把W改为G可以跳过生成文件的步骤,制造出"真单文件"的脚本.另外DEBUG还可以用来进行简单的16进制编辑和文本修改.
当然,还有很多方式有待我们去发掘!
===============================================
首先解释一下a dw db e等DEBUG指令
:a指令可以让我们在制定位置向内存写汇编指令
-----------------------------------------------
a 100
mov ah,4c
int 21
-----------------------------------------------
:a+db指令单字节写16进制数据到内存
-----------------------------------------------
a 100
db b4 4c cd 21
-----------------------------------------------
:a+dw指令双字节写16进制数据到内存
-----------------------------------------------
a 100
dw 4cb4 21cd
-----------------------------------------------
:e指令单字节写16进制数据到内存
-----------------------------------------------
e 100 b4 4c cd 21
-----------------------------------------------
注意1:以上四个例子最终效果是一样的哦!
注意2:前3个例子最后有一个空行,不能省哦!
发现:貌似e指令最省代码,然后是a+dw.不过如果代码比较多的话,貌似有变化.dw每4个16进制数一个空格,而db和e是2个16进制数一个空格.稍微多一点的代码db就会超过e哦!所以代码较少e好用一些较多时dw更省代码.
===============================================
上面介绍了输入到内存,再解释一下输出到文件的N W R
N是指定最后输出的文件名,例如:sybc.com,注意使用8.3规则,部分情况下可能大小写敏感.
R CX用于制定文件大小,很重要,注意使用16进制在后一行写
W 就是保存了,不需要参数
:保存示例
-----------------------------------------------
a 100
db b4 4c cd 21
r cx
4
n sybc.com
w
-----------------------------------------------
另外,不想输出文件直接运行要使用G指令
:G运行
-----------------------------------------------
a 100
db b4 4c cd 21
r cx
4
g
-----------------------------------------------
===============================================
其他常用的DEBUG指令
F 批量写入重复内容
L 读取文件到内存
这些东西大家自己去看帮助文档或去百度了解吧,就不详细介绍了
===============================================
最后这么多行东西怎么搞到cmd里去呢?只要全部echo然后搞到括号里最后使用管道符搞进DEBUG就行.
:插入到cmd
-----------------------------------------------
(echo a 100&echo db b4 4c cd 21&echo.&echo r cx&echo 4&echo g&echo.)|DEBUG
-----------------------------------------------
另外还有不在成熟的半成品方案,效果也不错,就是必须放在开头.
:插入到cmd的半成品方案
-----------------------------------------------
@echo off&color f2&title ...&goto begain
a 100
db b4 4c cd 21
r cx
4
g
:begain
debug <%0 >nul
-----------------------------------------------
===============================================
最终的优化:一些小技巧可以进一步优化代码
a 100可以用a100
e 100可以用e100
r cx可以用rcx
也就是可以省aer等指令后的空格,但也仅限于此
db,dw之类的空格是不可以省的.
利用预处理吧重复的代码简化
例如:
(echo a 100&echo db b4 4c cd 21&echo.&echo r cx&echo 4&echo g&echo.)|DEBUG
可以简化为
set a=a 100;db b4 4c cd 21;;rcx;4; g;
(ECHO.%a:;=&ECHO. %)|debug
当然相信大家可以找到更多更好的办法继续优化.
Last edited by sl543001 on 2010-1-25 at 19:32 ]
In the Windows series, DEBUG is a debugging tool for 16-bit subsystems, that is to say, it is only effective for the 16-bit subsystem . It seems that there is no connection between different cmd windows running DEBUG simultaneously. In this way, the great god DEBUG in the DOS era has limited uses in systems after 2000. However, we can still use it to make contributions.
===============================================
DUGUG's currently relatively commonly used function in scripts is to output com programs.
We use instructions such as a+db or a+dw or e to input assembly source code or hexadecimal code into DEBUG. Then use the W instruction to output the file, and then run the file. This process can create a "pseudo-single-file" script. Of course, changing W to G can skip the step of generating the file and create a "true single-file" script. In addition, DEBUG can also be used for simple hexadecimal editing and text modification.
Of course, there are still many ways waiting for us to explore!
===============================================
First, explain the DEBUG instructions such as a, dw, db, e
: The a instruction allows us to write assembly instructions to memory at a specified position
-----------------------------------------------
a 100
mov ah,4c
int 21
-----------------------------------------------
: a+db instruction to write single-byte hexadecimal data to memory
-----------------------------------------------
a 100
db b4 4c cd 21
-----------------------------------------------
: a+dw instruction to write double-byte hexadecimal data to memory
-----------------------------------------------
a 100
dw 4cb4 21cd
-----------------------------------------------
: e instruction to write single-byte hexadecimal data to memory
-----------------------------------------------
e 100 b4 4c cd 21
-----------------------------------------------
Note 1: The final effects of the above four examples are the same!
Note 2: There is an empty line at the end of the first three examples, which cannot be omitted.
Discovery: It seems that the e instruction is the most code-saving, and then a+dw. But if the code is relatively long, there seems to be a change. dw has a space every 4 hexadecimal numbers, while db and e have a space every 2 hexadecimal numbers. A little more code and db will exceed e! So the e is easy to use for less code and dw is more code-saving for more code.
===============================================
The above introduced input to memory, and then explain output to file N W R
N is to specify the final output file name, for example: sybc.com, note that the 8.3 rule is used, and in some cases it may be case-sensitive.
R CX is used to specify the file size, which is very important, note that write in hexadecimal in the next line
W is to save, no parameters are needed
: Save example
-----------------------------------------------
a 100
db b4 4c cd 21
r cx
4
n sybc.com
w
-----------------------------------------------
In addition, if you don't want to output the file and directly run, you need to use the G instruction
: G run
-----------------------------------------------
a 100
db b4 4c cd 21
r cx
4
g
-----------------------------------------------
===============================================
Other commonly used DEBUG instructions
F batch write repeated content
L read file to memory
You can go to the help document or Baidu to understand these things by yourself, and I won't introduce them in detail.
===============================================
Finally, how to get so many lines into the cmd? Just echo all and put them in parentheses and finally use the pipe symbol to get into DEBUG.
: Insert into cmd
-----------------------------------------------
(echo a 100&echo db b4 4c cd 21&echo.&echo r cx&echo 4&echo g&echo.)|DEBUG
-----------------------------------------------
In addition, there is an immature semi-finished product plan, which also has a good effect, that is, it must be placed at the beginning.
: Semi-finished product plan inserted into cmd
-----------------------------------------------
@echo off&color f2&title ...&goto begain
a 100
db b4 4c cd 21
r cx
4
g
:begain
debug <%0 >nul
-----------------------------------------------
===============================================
Final optimization: Some small tricks can further optimize the code
a 100 can be a100
e 100 can be e100
r cx can be rcx
That is, the space after instructions such as a, e, r can be saved, but only this
Spaces like db, dw cannot be saved.
Use preprocessing to simplify repeated code
For example:
(echo a 100&echo db b4 4c cd 21&echo.&echo r cx&echo 4&echo g&echo.)|DEBUG
Can be simplified to
set a=a 100;db b4 4c cd 21;;rcx;4; g;
(ECHO.%a:;=&ECHO. %)|debug
Of course, I believe everyone can find more and better ways to continue to optimize.
Last edited by sl543001 on 2010-1-25 at 19:32 ]
|
|
2010-1-25 19:30 |
|
|
ldr2zjj
初级用户
 
积分 167
发帖 95
注册 2007-5-6
状态 离线
|
|
2010-1-28 14:29 |
|
|
ldr2zjj
初级用户
 
积分 167
发帖 95
注册 2007-5-6
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
先试试~~~看起来非常牛,我的WIN7系统玩不了~~~
Let's give it a try~~~It looks really amazing, but my Windows 7 system can't play it~~~
|
|
2010-1-29 13:05 |
|
|
sysplay
初级用户
 
积分 23
发帖 19
注册 2009-7-10
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
终于见识到什么是高手。
Finally, I've seen what a master is.
|
|
2010-2-1 17:55 |
|
|