TwMS v155.1_ICS_人物座標左右走

不知道耶,都沒看到有人發左右走,我很無聊就發囉

//TwMS v155.1_ICS_人物座標左右走
//Author: Onion
//好處是不會有偏移問題(需開起小地圖)
//這個版本支援CEAutoAssembler了,也就是說可以加到打勾掛裡了這樣XD
[Enable]
Alloc(AutoLRICS, 512)
Alloc(ChrX, 04)
Alloc(MyLR, 04)
Alloc(Step, 04)
Label(AutoLR)
Label(GetWall)
Label(GetChrX)
Label(GoRight)
Label(GoLeft)
Label(SetX)

Step:
DD 1 //0為停止

MyLR:
DD 1 //開啟後向右走

AutoLRICS:
Cmp [Step],0
Je  GetFocus
Cmp [Step],1
Je  SetX

Cmp [Esp],00A56C56
Jne GetFocus
Mov [Esp],AutoLR
Jmp GetFocus

SetX:
Call GetChrX
Mov [ChrX],Eax
Inc [Step]
Jmp GetFocus

AutoLR:
Call GetWall
Mov  [Ebp-04],Eax
Jmp  00A56F9A

GetWall:
Call GetChrX
Mov  Ecx,[ChrX]
Sub  Eax,Ecx
Cmp  Eax,0
Jle  GoRight
Call GetChrX
Mov  Ecx,[ChrX]
sub  Ecx,Eax
cmp  Ecx,0
Jle  GoLeft
Mov  Eax,[MyLR]
Ret

GetChrX:
Mov Eax,[00FE35AC]
Mov Eax,[Eax+0FA0]
Ret

GoRight:
Mov [MyLR],1
Mov Eax,1
Ret

GoLeft:
Mov [MyLR],FFFFFFFF
Mov Eax,FFFFFFFF
Ret

00FEB8C0:
DD AutoLRICS

[Disable]
00FEB8C0:
DD GetFocus
DeAlloc(MyLR)
DeAlloc(SetX)
DeAlloc(AutoLRICS)

以下是kkmomo大大修改的精簡版本:
//TwMS v155.1_ICS_人物座標左右走
//Author: Onion
//Modify: kkmomo
//好處是不會有偏移問題(需開起小地圖)
//這個版本支援CEAutoAssembler了,也就是說可以加到打勾掛裡了這樣XD

[Enable]
Alloc(AutoLRICS, 512)
Alloc(ChrX, 04)
Alloc(Step, 04)
Label(GetWall)
Label(GetChrX)
Label(AutoLR)
Label(Return)

Step:
DD 1 //0為停止

AutoLRICS:
Cmp [Step],1
Jl Return
Jg AutoLR
Call GetChrX
Mov [ChrX],Eax
Inc [Step]

AutoLR:
Mov Eax,[Esp]
Cmp [Eax],850FC63B
Jne Return
Call GetWall
Mov [Ebp-04],Eax
Mov Eax,[Esp]
Add Eax,4
Mov Eax,[Eax]
Add [Esp],Eax
Add [Esp],8

Return:
Push 00
Jmp GetFocus+2

GetWall:
Call GetChrX
Sub Eax,[ChrX]
And Eax,80000000
Rol Eax,2
Dec Eax
Ret

GetChrX:
Mov Eax,[00FE35AC]
Mov Eax,[Eax+0FA0]
Ret

GetFocus-5:
Jmp AutoLRICS
DB EB F9

[Disable]
GetFocus:
DB 6A 00

DeAlloc(Step)
DeAlloc(ChrX)
DeAlloc(AutoLRICS)

留言

  1. 作者已經移除這則留言。

    回覆刪除
  2. 作者已經移除這則留言。

    回覆刪除
  3. 初步簡化一些,雖然沒差多少XD
    再改一個地方應該就可以AllVersion

    //TwMS v155.1_ICS_人物座標左右走
    //Author: Onion
    //好處是不會有偏移問題(需開起小地圖)
    //這個版本支援CEAutoAssembler了,也就是說可以加到打勾掛裡了這樣XD

    [Enable]
    Alloc(AutoLRICS, 512)
    Alloc(ChrX, 04)
    Alloc(Step, 04)
    Label(GetWall)
    Label(GetChrX)
    Label(AutoLR)
    Label(Return)

    Step:
    DD 1 //0為停止

    AutoLRICS:
    Cmp [Step],1
    Jl Return
    Jg AutoLR
    Call GetChrX
    Mov [ChrX],Eax
    Inc [Step]

    AutoLR:
    Mov Eax,[Esp]
    Cmp [Eax],850FC63B
    Jne Return
    Call GetWall
    Mov [Ebp-04],Eax
    Mov Eax,[Esp]
    Add Eax,4
    Mov Eax,[Eax]
    Add [Esp],Eax
    Add [Esp],8

    Return:
    Push 00
    Jmp GetFocus+2

    GetWall:
    Call GetChrX
    Sub Eax,[ChrX]
    And Eax,80000000
    Neg Eax
    Sbb Eax,Eax
    And Eax,2
    Sub Eax,1
    Ret

    GetChrX:
    Mov Eax,[00FE35AC]
    Mov Eax,[Eax+0FA0]
    Ret

    GetFocus-5:
    Jmp AutoLRICS
    DB EB F9

    [Disable]
    GetFocus:
    DB 6A 00

    DeAlloc(Step)
    DeAlloc(ChrX)
    DeAlloc(AutoLRICS)

    回覆刪除
    回覆
    1. 不過這個版本需要人物的POINTER比較難搞成自動更新
      普通的左右走倒是OK

      刪除
    2. 我比較不是很懂得是數值運算這邊,Sbb Eax,Eax指令設Eax為0或者-1,那Rol是怎麼算的@@?
      And Eax,80000000
      Rol Eax,2
      Dec Eax
      這樣是怎麼算的呢?

      刪除
    3. pointer再用另一個api就可以做成自動更新,雖然有找到可是懶得改寫,興緻缺缺
      從008875E0往下大概10多行去trace就可以找到

      一開始想法是用
      Eax = (Eax-[ChrX]<0) ? 1 : -1
      //斷判正負等價於判斷MSB值
      Eax = ( (Eax-[ChrX]<0) & 80000000 ) ? 1 : -1

      ==================================
      r = r ? v1 : v2
      ---------------
      neg r
      sbb r,r
      and r,(v1-v2)
      add r,v2
      ---------------
      case : r=0
      neg r r = 0 , CF=0
      sbb r,r r = 0-0-CF = 0
      and r,(v1-v2) r = 0&(v1-v2) = 0
      add r,v2 r = 0+v2 = v2

      case : r=R≠0
      neg r r = -R , CF=1
      sbb r,r r = (-R)-(-R)-CF = -1
      and r,(v1-v2) r = (-1)&(v1-v2) = v1-v2
      add r,v2 r = (v1-v2)+v2 = v1
      ==================================
      後來想說這是特殊情況,就看看有沒有特別的方法
      MSB=1 時 希望得到 1
      MSB=0 時 希望得到 -1

      找共同點,就先想到共同加或減某數,很容易想到先用1試試
      2-1 = 1
      0-1 = -1

      看到0,2就會想到位移,然後就想到用rol
      00000010 = (rol 10000000,2)
      00000000 = (rol 00000000,2)

      刪除
    4. soga,我瞭了,謝謝大大精闢的ASM講解XD

      刪除
  4. 這裡可以再少幾行
    GetWall:
    Call GetChrX
    Sub Eax,[ChrX]
    And Eax,80000000
    Rol Eax,2
    Dec Eax
    Ret

    回覆刪除

張貼留言

本月最夯

楓之谷洋蔥4.1.2 - 最後更新日期04/03

偷用電腦,怎知?事件檢視器全記錄!(開機時間、啟動項時間...)