Searching for text, comparing, searching for more
#1
Posted 04 June 2012 - 10:10 PM
1. Search for "0008 ble".
2. When found, check the line below it for "st".
3. If that is the next line after it, copy the line that had the "0008 ble". If not, continue searching for "0008 ble" and the "st" line below it.
I'm doing this to find limits to modify by canceling or forcing branches to always go if there is a store operation after it. It's the #2 part I don't know how to do. How do I get it to check if the line below it has the store operation, and then do things based on that? I'd know how to write PPC code that can do that, but not a clue for AHK.
#2
Posted 05 June 2012 - 01:14 AM
Data =
(
1 random line
2 some words, 0008 ble and some other words
3 random line
4 some words, 0008 ble and some other words <--
5 line contains st and some other words
6 random line
)
pos = 1
while !InStr(NextLine, "st")
{
pos := RegExMatch(Data, "`am)^.*0008\sble.*$", Result, Pos+StrLen(Result))
RegExMatch(Data, "`am)^.*$", NextLine, Pos + StrLen(Result))
}
MsgBox % Result
#3
Posted 08 June 2012 - 07:24 PM
#4
Posted 08 June 2012 - 10:39 PM
please see if this one meets your needs, this should be a little more comprehensive.
Data =
(
1 random line
2 some words, 0008 ble and some other words
3 random line
4 some words, 0008 ble and some other words <--
5 line contains st and some other words
6 random line
)
loop, parse, data, `n`r
{
thisLine:= A_LoopField
IfInString , thisLine, st
IfInString , PrevLine, 0008 ble
break
PrevLine := thisLine
}
MsgBox, % PrevLine
#5
Posted 11 June 2012 - 12:03 AM
#InstallKeybdHook
#z::
Loop 128
{
Loop 256
{
WinWait, Prototype.txt - WordPad
WinActivate,
SendInput, {HOME}{SHIFTDOWN}{CTRLDOWN}{RIGHT}{SHIFTUP}c{CTRLUP}
WinWait, HxD - [C]
WinActivate,
SendInput, {CTRLDOWN}gv{CTRLUP}{ENTER}60000000
WinWait, Prototype.txt - WordPad
WinActivate,
SendInput, {UP}{HOME}
}
WinWait, Prototype.txt - WordPad
WinActivate,
SendInput, {DOWN}{ENTER 3}{UP 4}
WinWait, HxD - [C]
WinActivate,
SendInput, {ALTDOWN}{F4}{ALTUP}y
WinWaitClose, HxD - [C],
RunWait, Prototype.bat, C:\CMPAutoTools\
WinWaitClose, Prototype.bat
WinWait, C:\CMP Auto Tools
WinActivate,
FileRecycle, C:\CMP Auto Tools\EBOOT.Elf
FileRecycleEmpty, C:\
WinWait, C:\CMP Auto Tools
WinActivate,
FileCopy, C:\CMP Auto Tools\EBOOT - Copy.Elf, C:\CMP Auto Tools\EBOOT.Elf
Run, EBOOT.Elf, C:\CMP Auto Tools\
WinWait, HxD - [C]
WinActivate,
WinWait, C:\CMP Auto Tools\GamesOutput\Katamari Forever\NTSC\3.41,
WinActivate,
SendInput, up0001{F2}{CTRLDOWN}v{CTRLUP}{ENTER}
}
return
#a::
Loop 4096
{
WinWait, Programmer's Notepad - [Prototype-NTSC.txt],
WinActivate,
SendInput, {F3}{HOME}{SHIFTDOWN}{END}{SHIFTUP}{CTRLDOWN}c{CTRLUP}
WinWait, Prototype.txt - WordPad,
WinWaitActive,
SendInput, {CTRLDOWN}v{CTRLUP}{ENTER}
}
return
#q::
Loop 8192
{
SendInput, {F3}{END}{SHIFTDOWN}{HOME}{SHIFTUP}{BACKSPACE 2}
}
return
#w::
Loop 120
{
WinWait, Prototype.txt - WordPad
WinActivate,
SendInput, {RIGHT}{SHIFTDOWN}{UP 3}{LEFT}{SHIFTUP}{DELETE}{PGUP 8}
}
return
#o::
Data =
(
1 random line
2 some words, 0008 ble and some other words
3 random line
4 some words, 0008 ble and some other words <--
5 line contains st and some other words
6 random line
)
loop, parse, data, `n`r
{
thisLine:= A_LoopField
IfInString , thisLine, st
IfInString , PrevLine, 0008 ble
break
PrevLine := thisLine
}
MsgBox, % PrevLine
I have programmer's notepad 2 open with the game's big text file, and within it I search for "0008*tabspace*ble". It doesn't have *tabspace* in it, I mean the character. That way when it I press windows key + A it starts copying all lines with that to the Prototype text file.
I have 2 windows open, c:\cmp auto tools\ and c:\cmp auto tools\gamesoutput\prototype\ntsc\3.41\. I have the program HxD.exe open with the game's EBOOT.Elf file open.
I press windows key + Z at the address of the first line in the Prototype text file. It goes to HxD.exe, opens the go to address box, copies the address and pressed Enter to go to it. It then types 60000000 to nop the line. It repeats that process many times until done.
I want to change my barbaric script for windows key + A.
I want it to do 2 different things. It pressed F3 and finds the next instance of "0008 ble", then I want 2 different things from there.
1. Go down one line and check if the next line has "st" in it. If it does, copy that line above it that has the "0008 ble" and copy it to the text file.
2. If the line below it doesn't have "st", then press F3 and go to the next instance of "0008 ble".
These are 2 example instances from the game's text file.
0003BB28: 409D0008 ble- cr7,0x3bb30
0003BB2C: D1BF00D4 stfs f13,212(r31)
001356F8: 409D0008 ble- cr7,0x135700
001356FC: FFA00090 fmr f29,f0
What it should do is copy "0003BB28: 409D0008 ble- cr7,0x3bb30" to the text file, and skip past "001356F8: 409D0008 ble- cr7,0x135700" because the line after it doesn't have "st".
#6
Posted 11 June 2012 - 12:14 AM
and you have a missing return at the end.
#o::
data =
(
0003BB28: 409D0008 ble- cr7,0x3bb30
0003BB2C: D1BF00D4 stfs f13,212(r31)
001356F8: 409D0008 ble- cr7,0x135700
001356FC: FFA00090 fmr f29,f0
)
loop, parse, data, `n`r
{
thisLine:= A_LoopField
IfInString , thisLine, st
IfInString , PrevLine, 0008[color=#FF0000]`t[/color]ble
break
PrevLine := thisLine
}
MsgBox, % PrevLine
[color=#FF0000]return[/color]
#7
Posted 11 June 2012 - 02:28 AM
The outputted text file for me lists each line with 4 things in the same order that never changes. Address, hex code, ASM operation, and registers involved. The ASM for the branch operation I care about is the last 4 digits of the hex code since that tells me how far the branch is jumping, and the ASM operation since the "ble" is branch if less than or equal. For the store operations, all I care about is the ASM operation.
#8
Posted 11 June 2012 - 06:37 AM
it is because I have provided you with the general idea, I don't know at which part of your code you're going to insert those lines. I had no idea you want it to be a hotkeyI was wondering about the return part. I wondered why you didn't have it there.
Actually I didn't this was a copy and paste from your post above, maybe my editor changed the "tab" size according to my settings but it's still a "tab"And now I'm baffled as to why you changed the data to what you did
The following tested just fine, replace "data" with your own lines and let me know.
#o::
data =
(
0003BB28: 409D0008 ble- cr7,0x3bb30
0003BB2C: D1BF00D4 stfs f13,212(r31)
001356F8: 409D0008 ble- cr7,0x135700
001356FC: FFA00090 fmr f29,f0
)
loop, parse, data, `n,`r
{
if InStr(A_LoopField,"st")
if RegExMatch(PrevLine,".*0008\W*ble")
{
Result := PrevLine
break
}
PrevLine := A_LoopField
}
if Result
MsgBox % Result
else
MsgBox, not found
return
#9
Posted 14 June 2012 - 05:49 PM
#10
Posted 14 June 2012 - 05:51 PM




