📄 go.asm
字号:
cld
mov esi, MMradio.mem
mov edi, esi
add edi, MemQiPanStep
mov ecx, MemQiPanStep/4
rep movsd
pop esi
add esi, 4
inc dword ptr dwMoveNum
.if dword ptr dwMoveNum <= 361
jmp @B
.else
jmp @EndThisFunc
.endif
.endif
;
;比较大小
@EndThisFunc:
; MessageHex @di
; MessageHex @ying
; MessageHex @diV
; MessageHex @yingV
mov eax, @MaxMoveNum
add eax, 19
mov dl, 19
div dl
movzx ecx, ah
inc ecx
movzx ebx, al
mov MMrnd.x, ecx
mov MMrnd.y, ebx
;invoke _CheckRule, ecx, ebx, _Color
;返回最大
ret
_MakeOneRadioMove endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_MakeCanPutList proc _X, _Y
;维护CanPutList
;这个列表的维护现在非常简单
;“凡是下过子的都不合法”
;还没有不入的概念及打劫等复杂的概念;
;要进一步升级
mov eax, _Y
mov ecx, 19 * 4
mul cl
mov ebx, _X
shl ebx, 2
add ebx, eax
sub ebx, 20*4
mov esi, lpCanPutList
add esi, ebx
mov eax, 0FFFFFFFFh
mov [esi], eax
sub dword ptr dwCPLCount, 1
ret
_MakeCanPutList endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_MakeRadioMove proc _Cmd, _X, _Y, _Color
;在具体的着法生成模块中,现在只响应二种命令;
;mov esi, lpRSPoint
;mov ax, [esi-8]
mov eax, _Cmd
.if eax == MMC_GETONEMOVE
;如果xycolor为0则表示是第一手;
mov eax, MMmakeOneMove.x
.if eax == 0
ret
.elseif
;将棋子落在棋盘上且做相应计算;
invoke _MRMPutOneStone, \
MMmakeOneMove.x ,MMmakeOneMove.y ,MMmakeOneMove.color
.endif
.elseif eax == MMC_MAKEONEMOVE
invoke _MakeOneRadioMove, _Color
mov eax, MMrnd.x
mov MMradio.x, eax
mov eax, MMrnd.y
mov MMradio.y, eax
mov eax, _Color
mov MMradio.color, eax
.endif
;
ret
_MakeRadioMove endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;_MakeRadioMove
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_SendCmd2All proc _Cmd, _X, _Y, _Color
;简单地将命令转发给所有着子生成模块(还是必要的?)
;
.if _Cmd == MMC_GETONEMOVE
;维护CanPutList
invoke _MakeCanPutList, _X, _Y
.endif
invoke _MakeRadioMove, _Cmd, _X, _Y, _Color
ret
_SendCmd2All endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_MakeOneMove proc ;_PreX, _PreY, _PreColor
;
local @TempColor
;===============在这里加入总的着子生成(选择)模块================〖
;
mov eax, MMmakeOneMove.cmd
.if eax == MMC_MAKEONEMOVE
invoke _SendCmd2All, MMC_MAKEONEMOVE, NULL, NULL, MMmakeOneMove.color
.elseif eax == MMC_GETANDMAKE
mov esi, MMmakeOneMove.x
mov edi, MMmakeOneMove.y
mov ebx, MMmakeOneMove.color
.if ebx == 1
mov @TempColor, 2
.elseif ebx == 2
mov @TempColor, 1
.endif
invoke _SendCmd2All, MMC_GETONEMOVE, esi, edi, ebx
invoke _SendCmd2All, MMC_MAKEONEMOVE, NULL, NULL, @TempColor
.endif
;在这里从所有生成着点中选择;
mov eax, MMradio.x
mov iQiziX, eax
mov MMmakeOneMove.x, eax
mov eax, MMradio.y
mov iQiziY, eax
mov MMmakeOneMove.y, eax
mov ebx, MMradio.color
mov MMmakeOneMove.color, ebx
invoke _CheckRule, iQiziX, iQiziY, ebx
;还要设状态
;维护CanPutList
invoke _MakeCanPutList, MMradio.x, MMradio.y
;===============在这里加入总的着子生成(选择)模块=================〗
;通知所有应知者_MakeOneMove刚生成的着点;
invoke _SendCmd2All, MMC_GETONEMOVE, \
MMmakeOneMove.x, MMmakeOneMove.y, MMmakeOneMove.color
;MessageHex MMmakeOneMove.color
invoke ResetEvent, hMoveEvent
.if iMoveThreadExit != dword ptr 100h
.if iWillPutColor == BlackStone
invoke PostMessage, hWinMain,WM_PP_BLACK, iQiziX, iQiziY
.elseif iWillPutColor == WhiteStone
invoke PostMessage, hWinMain,WM_PP_WHITE, iQiziX, iQiziY
.endif
.endif
ret
_MakeOneMove endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_MakeOneMoveT proc uses ebx esi edi, _lParam
;这是线程子程序,
;如果想要线程退出,就将iMoveThreadExit的值设为100h
;===============在这里加上具体着子生成模块的初始化部分=============〖
;Add U Init code @ here
invoke _InitAllCanPutList
invoke _InitMakeRadioMove
;===============在这里加上着子生成模块的初始化部分================= 〗
@@:
invoke WaitForSingleObject, hMoveEvent, INFINITE
invoke _MakeOneMove
;如果iMoveThreadExit不等于100h,则表示主控程序还不想关闭线程;
;则线程_MakeOneMove,再来等待下一个事件;
.if iMoveThreadExit != dword ptr 100h
;invoke _MakeOneMove
jmp @B
.endif
;===============在这里加上具体着子生成模块的卸载部分=============〖
;
invoke _UnloadAllCanPutList
;
invoke _UnloadMakeRadioMove
;===============在这里加上具体着子生成模块的卸载部分============= 〗
mov dwThreadIsRunning, 0
invoke CloseHandle, hMoveEvent
;mov eax, hMoveThread
;mov hOldThread, eax
invoke CloseHandle, hMoveThread
;线程退出后,可能立即创建一新线程;
;线程退出较慢(?),可能会产生问题;
;取线程退出码又出错。?。只有等一会了。
;invoke ExitThread, 0
ret
_MakeOneMoveT endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_CreateRndFile proc
;生成一随机数文件,可删除。
;按键50下,得到人工的随机数。
invoke CreateFile, offset szFileName, GENERIC_READ OR GENERIC_WRITE,\
0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL
mov hFile, eax
;
mov ecx, 500
mov esi, offset fileoff
xor ebx, ebx
@@:
rdtsc
mov [esi+ebx], eax
mov edx, eax
MessageHex edx
add ebx, 4
sub ecx, 1
jnz @B
invoke SetFilePointer, hFile, 2000, NULL, FILE_BEGIN
invoke SetEndOfFile, hFile
invoke SetFilePointer, hFile, 0, NULL, FILE_BEGIN
invoke WriteFile, hFile, offset fileoff, 2000, offset lpWriten, NULL
invoke FlushFileBuffers, hFile
invoke CloseHandle, hFile
ret
_CreateRndFile endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ShowRnd proc
;可删除
pushad
rdtsc
mov ebx, eax
rdtsc
mov esi, eax
MessageHex ebx
MessageHex esi
popad
ret
_ShowRnd endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_PreMakeOneMove proc
;在生成棋着的模块前,做些准备工夫
;创建一个事件对象,让着法生成程序先等在那里。
;
invoke CreateEvent, NULL, TRUE, FALSE, NULL
mov hMoveEvent, eax
invoke CreateThread, NULL, 0, offset _MakeOneMoveT, 0, 0, offset lpMoveThreadId
mov hMoveThread, eax
mov dwThreadIsRunning, 1 ;这一句也是没用的;delit
.if dword ptr iMode == MODE_PC2MAN
invoke SetEvent, hMoveEvent
;跑吧
.endif
ret
_PreMakeOneMove endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_PrePlay proc
;在选择了人人对弈或人机对弈之后,
;在真正对弈开始之前,
;进行黑白方、棋规、让子数、贴目、对局时间等等的选择与设定。
;
.if dword ptr iMode == MODE_MAN2PC
mov iPlayedByPc, TRUE
mov dword ptr PcPlay, WhiteStone
.elseif dword ptr iMode == MODE_PC2MAN
mov iPlayedByPc, FALSE
mov dword ptr PcPlay, BlackStone
.endif
;mov hMoveEvent, 0
mov dword ptr iModeGoing, 1
mov dword ptr iWillPutColor, BlackStone
mov iMoveThreadExit, 0
ret
_PrePlay endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_MakeDingShiKu1 proc
;dothis
;
local @lpMem
local @OrgPoint, @lpOrg
local @NewPoint, @lpNew
local @hOrgFile, @hNewFile
local @dwOrgLength, @Length
local @Stone
local @StoneColor
local @Level, @Flag, @Top
local @Father, @BBrather, @LBrather, @Sun
local @Temp
;申请内存
invoke GlobalAlloc, GPTR, 1500000
.if eax == NULL
Message "定式库申请内存失败!"
ret
.endif
mov @lpMem, eax
;生成二个指针
mov @OrgPoint,eax
mov @lpOrg, eax
mov @Top, eax
add eax, 750000
mov @NewPoint, eax
mov @lpNew, eax
;
;打开原始文件
invoke CreateFile, offset szOrgDSK, GENERIC_READ, FILE_SHARE_READ, NULL, \
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL
.if eax == INVALID_HANDLE_VALUE
Message "打开定式库原数据库文件错!"
ret
.endif
mov @hOrgFile, eax
;读入原文件
mov esi, @lpOrg ;为什么非要这样啊?!Tell me WHY...
invoke ReadFile, @hOrgFile, esi , 750000, addr @dwOrgLength, NULL
.if eax == 0
Message "读定式库原始文件出错!"
ret
.endif
;@dwOrgLength中有文件长度
mov eax, @dwOrgLength
add @Top, eax
;创建新文件
invoke CreateFile, offset szNewDSK, GENERIC_READ or GENERIC_WRITE, 0, NULL, \
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL
.if eax == INVALID_HANDLE_VALUE
Message "创建定式库新文件错!如果新文件已存在,请更名。"
.endif
mov @hNewFile, eax
;开始处理文件
;
invoke SetFilePointer, @hOrgFile, 0, NULL, FILE_BEGIN
.if eax == -1
Message "移动定式库原文件指针失败!"
.endif
;
mov esi, @OrgPoint
mov edi, @NewPoint
add edi, 200h
mov @NewPoint, edi
mov eax, @dwOrgLength
mov @Length, eax
mov @Level, 0
cld
;设初值
mov @Flag, 0
mov @Level, 0
mov @Stone, bTuoXian
mov @StoneColor, WhiteStone
;设根值
;mov @Father, 0
;mov @BBrather, 0
;mov @LBrather, 0
;mov @Sun, 32
;mov self, bTuoxian
; add edi, 12
; mov eax, 32
; stosd
; mov al, bTuoXian
; stosb
; ;edi指向下一个数据点
; add edi, 15
;
;设状态
mov @Father, 0
mov @BBrather, 0
mov @LBrather, 0
mov @Sun, 0
push @Stone
push @StoneColor
push @Sun
push @LBrather
push @BBrather
push @Father
;push @Falg
.repeat
lodsb
;
.if al == '('
lodsb
.if al == ';'
inc @Level
;mov @Flag, dsLevel
.elseif
dec esi
.continue
.endif
.elseif al == 0Dh
.continue
.elseif al == 0Ah
.continue
.elseif al == 'B' || al == 'W'
;movzx @Temp, al
lodsb
.if al == '['
lodsb
sub al, 'a'
inc al
mov bl, al
;
lodsb
sub al, 'a'
mov bh, 19
mul bh
add bl, al
;bl中为一维坐标值
mov [edi+16], bl
pop @Father
.if @Father == 1
;
.endif
.elseif
dec esi
.continue
.endif
.elseif al == ')'
;dothis
dec @Level
.if @Level == 0
;Save new file and Exit
.endif
.elseif al == 'L'
lodsb
.if al == 'B'
@@:
lodsb
.if al == '['
;push @Flag == 1表示有分支
pushd 1
.elseif
dec esi
.continue
.endif
jmp @B
;
.elseif
dec esi
.continue
.endif
; .elseif al == 'C'
; lodsb
; .if al == '['
; mov ecx, 1000h
; mov al, ']'
; repne scasb
; ;未存注释;dothis
; .endif
; ;
;
; .elseif al == 'A'
; lodsb
; .if al == 'P'
; lodsb
; .if al == '['
; mov ecx, 1000h
; mov al, ']'
; repne scasb
; .elseif
; dec esi
; .continue
; .endif
; .endif
;
; .elseif al == 'S'
; mov ecx, 1000h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -