Modules Nestopia V1.40

Ici se règle les problèmes concernant la configuration des différents émulateurs.

Modérateurs : Porko, Modérateurs

Répondre
Avatar de l’utilisateur
tetsuo001
noob
noob
Messages : 7
Inscription : 16 avr. 2015 - 10:36

Modules Nestopia V1.40

Message par tetsuo001 » 16 avr. 2015 - 22:26

bonjour à tous

je teste un peu hyperspin voir si je le rentre dans ma borne, j'avoue c'est juste super beau comparer a un temps jadis :p

j'essaie de mettre nestopia mais a chaque fois un soucis que j'arrive a paré grâce aux forum mais j'en suis actuellement a un soucis de modules

je suis avec une version 1.40 de nestopia, et dans la section modules du freecloud c'est la V1.39 du ahk pour nestopia, j’ai tout de même tenté, mais cela ne fonctionne pas en tous cas une erreur sur le modules me met hyperlaunch ( que je n'ai pas un module pour hyperlaunch2)
j’ai chercher d'autre ahk et ceux de la version 1.42 sur google ou encore une V1.39 de nestopia pour tester mais pour l'instant bredouille ... je continue a chercher
je suis aller sur pas mal de site et de forum mais sans succès

alors j'ai peut être omis quelque chose

j'ai tester la rom pas de soucis en direct, j’ai suivie les tutos ( d'ailleurs superbe merci a ceux qui ont pris le temps sur le forum) et tous c'est dérouler correctement, dans hyperspin pas de soucis je vais jusque la rom dans la wheel mais lorsque je la lance soucis de module ...


merci d'avance a tous
Dernière modification par tetsuo001 le 17 avr. 2015 - 21:43, modifié 1 fois.

Avatar de l’utilisateur
moustic
Administrateur
Administrateur
Messages : 6941
Inscription : 23 juil. 2014 - 01:00
Localisation : Saint Jean Rohrbach
A remercié : 331 fois
A été remercié : 677 fois

Re: modules Nestopia V1.40

Message par moustic » 16 avr. 2015 - 22:34

Re,

Alors voila mon module pour nestopia (j'ai la version 1.40) et le module version 1.39 marche au poil chez moi:
module
----------------------------------------------------------------------------
; Nintendo Entertainment System
; Nestopia 1.39
; by djvj & BBB
; 1.3
;
; Notes:
; Since the exit emulator key does nothing you should setup an escape key within the emulator using the input options, the default is alt+x, so change
; to esc. But since esc is the default key to bring up the fullscreen menu then you should change that to something else such as Alt+M. The exit emulator menu
; key is disabled to allow for game saving etc...
; <exit>Esc</exit>
; <toggle-menu>Alt+M</toggle-menu>

; Set these keys below
;----------------------------------------------------------------------------
Fullscreen = true
BlackMenu = true ; Make Nestopia's menu black so it looks better fullscreen
ExitKey = Esc ; Set Nestopia's Exit key here
ToggleMenuKey = Alt+M ; Set Nestopia's Toggle Menu key here. Make sure this is not the same as your exit key
;----------------------------------------------------------------------------

settingsFile := CheckFile(emuPath . "nestopia.xml")

FadeInStart()

xpath_load(emuXML, settingsFile ) ; need to read the existing xml otherwise xpath deletes all existing nodes
xpath(emuXML, "/configuration/preferences/application/confirm-exit/text()", "no") ; turning off confirmation on exit
xpath(emuXML, "/configuration/input/keys/file/exit/text()", ExitKey) ; setting exit key
xpath(emuXML, "/configuration/input/keys/view/ToggleMenuKey/text()", ToggleMenuKey) ; setting toggle menu key

; Black Menu
If ( BlackMenu = "true" ) {
xpath(emuXML, "/configuration/preferences/appearance/menu-fullscreen/custom-color/text()", "0x00000000") ; black
xpath(emuXML, "/configuration/preferences/appearance/menu-fullscreen/use-custom-color/text()", "yes") ; turning on custom colors
} Else
xpath(emuXML, "/configuration/preferences/appearance/menu-fullscreen/use-custom-color/text()", "no") ; turning off custom colors

; Enable Fullscreen
If ( Fullscreen = "true" )
xpath(emuXML, "/configuration/preferences/application/start-fullscreen/text()", "yes")
Else
xpath(emuXML, "/configuration/preferences/application/start-fullscreen/text()", "no")

xpath_save(emuXML, settingsFile) ; write new XML

7z(romPath, romName, romExtension, 7zExtractDir)

Run, %executable% "%romPath%%romName%%romExtension%", %emuPath%

WinActivate, ahk_class Nestopia
WinWaitActive, ahk_class Nestopia

FadeInExit()

Process, WaitClose, %executable%

7zCleanUp()

FadeOutExit()

WinActivate, Hyperspin

ExitApp

CloseProcess:
FadeOutStart()
WinClose, ahk_class Nestopia
Return


xpath(ByRef doc, step, set = "") {
static sc, scb = "" ; use EOT (\x04) as delimiter

If step contains %scb% ; i.e. illegal character
Return
sid := scb . &doc . ":" ; should be unique identifier for current XML object
If (InStr(step, "select:") == 1) { ; for quick selection
stsl = 1
StringTrimLeft, step, step, 7
}
If (InStr(step, "/") == 1)
str = 1 ; root selected
Else {
StringGetPos, p, sc, %sid% ; retrieve previous path
If ErrorLevel = 1
t = /
Else StringMid, t, sc, p += StrLen(sid) + 1, InStr(sc, scb, "", p + 2) - p
step = %t%/%step%
}

; normalize path e.g. /root/node/../child/. becomes /root/child:
step := RegExReplace(step, "(?<=^|/)(?:[^\[/@]+/\.{2}|\.)(?:/|$)|^.+(?=//)")

If (str == 1 or stsl == 1) { ; if not relative path and no select:
; remove last node and trailing attributes and functions:
xpr := RegExReplace(step, (str == 1 and stsl != 1 ? "/(?:\w+:)?\w+(?:\[[^\]]*])?" : "")
. "(?:/@.*?|/\w+\(\))*$")
StringReplace, xpr, xpr, [-1], [1], All ; -1 become just 1
StringReplace, xpr, xpr, [+1], [last()], All ; +1 becomes last()
StringGetPos, p, sc, %sid%
If ErrorLevel = 1
sc = %sc%%sid%%xpr%%scb% ; add record or update as necessary:
Else sc := SubStr(sc, 1, p += StrLen(sid)) . xpr . SubStr(sc, InStr(sc, scb, "", p))
}

; for unions call each operand seperately and join results:
If (InStr(step, "|")) {
StringSplit, s, step, |, `n`t  `r
Loop, %s0%
res .= xpath(doc, s%A_Index%, set) . ","
Return, SubStr(res, 1, -1)
}
Else If (InStr(step, "//") == 1) { ; for wildcard selectors use regex searching mode:
StringTrimLeft, step, step, 2
re = 1
rew = 1
xp = /(?:(?:\w+:)?\w+)*/
}

NumPut(160, doc, 0, "UChar") ; unmask variable

; resolve xpath components to: absolute node path, attributes and predicates (if any)
Loop, Parse, step, /
{
Image

Avatar de l’utilisateur
tetsuo001
noob
noob
Messages : 7
Inscription : 16 avr. 2015 - 10:36

Re: Modules Nestopia V1.40

Message par tetsuo001 » 17 avr. 2015 - 09:21

Merci beaucoup, j'essaie cela cette aprés midi !!!

Avatar de l’utilisateur
tetsuo001
noob
noob
Messages : 7
Inscription : 16 avr. 2015 - 10:36

Re: Modules Nestopia V1.40

Message par tetsuo001 » 17 avr. 2015 - 18:09

bonjour

alors après test, il me reconnait une erreur a la ligne 61 ...

Error at line 187
line text: hideDesktop()
Etrror: functions cannot contain functions

the programm will exit ...


je continue les tests un peux étrange si cela fonctionne chez toi ( d'autre)

Avatar de l’utilisateur
jegious
Apprenti
Apprenti
Messages : 19
Inscription : 02 déc. 2012 - 00:00
A été remercié : 1 fois

Re: Modules Nestopia V1.40

Message par jegious » 17 avr. 2015 - 20:38

Il est pas entier ce AHK,
je viens de tester celui ci sur Nestopia 1.46 prevu pour 1.39 et tout fonctionne correctement
il faut bien penser a modifier les touches Esc et la mise en Full Screen dans l'emulateur,reglage manette (option/imput)

module
;----------------------------------------------------------------------------
; Nintendo Entertainment System
; Nestopia
;
; Notes:
; Since the exit emulator key does nothing you should setup an escape key within the emulator using the input options, the default is alt+x, so change
; to esc. But since esc is the default key to bring up the fullscreen menu then you should change that to something else such as Alt+M. The exit emulator menu
; key is disabled to allow for game saving etc...
; <exit>Esc</exit>
; <toggle-menu>Alt+M</toggle-menu>

; Set these keys below
;----------------------------------------------------------------------------
Fullscreen = true
BlackMenu = true ; Make Nestopia's menu black so it looks better fullscreen
ExitKey = Esc ; Set Nestopia's Exit key here
ToggleMenuKey = Alt+M ; Set Nestopia's Toggle Menu key here. Make sure this is not the same as your exit key
;----------------------------------------------------------------------------

settingsFile := CheckFile(emuPath . "nestopia.xml")

FadeInStart()

xpath_load(emuXML, settingsFile ) ; need to read the existing xml otherwise xpath deletes all existing nodes
xpath(emuXML, "/configuration/preferences/application/confirm-exit/text()", "no") ; turning off confirmation on exit
xpath(emuXML, "/configuration/input/keys/file/exit/text()", ExitKey) ; setting exit key
xpath(emuXML, "/configuration/input/keys/view/ToggleMenuKey/text()", ToggleMenuKey) ; setting toggle menu key

; Black Menu
If ( BlackMenu = "true" ) {
xpath(emuXML, "/configuration/preferences/appearance/menu-fullscreen/custom-color/text()", "0x00000000") ; black
xpath(emuXML, "/configuration/preferences/appearance/menu-fullscreen/use-custom-color/text()", "yes") ; turning on custom colors
} Else
xpath(emuXML, "/configuration/preferences/appearance/menu-fullscreen/use-custom-color/text()", "no") ; turning off custom colors

; Enable Fullscreen
If ( Fullscreen = "true" )
xpath(emuXML, "/configuration/preferences/application/start-fullscreen/text()", "yes")
Else
xpath(emuXML, "/configuration/preferences/application/start-fullscreen/text()", "no")

xpath_save(emuXML, settingsFile) ; write new XML

7z(romPath, romName, romExtension, 7zExtractDir)

Run, %executable% "%romPath%%romName%%romExtension%", %emuPath%

WinActivate, ahk_class Nestopia
WinWaitActive, ahk_class Nestopia

FadeInExit()

Process, WaitClose, %executable%

7zCleanUp()

FadeOutExit()

WinActivate, Hyperspin

ExitApp

CloseProcess:
FadeOutStart()
WinClose, ahk_class Nestopia
Return


xpath(ByRef doc, step, set = "") {
static sc, scb = "" ; use EOT (\x04) as delimiter

If step contains %scb% ; i.e. illegal character
Return
sid := scb . &doc . ":" ; should be unique identifier for current XML object
If (InStr(step, "select:") == 1) { ; for quick selection
stsl = 1
StringTrimLeft, step, step, 7
}
If (InStr(step, "/") == 1)
str = 1 ; root selected
Else {
StringGetPos, p, sc, %sid% ; retrieve previous path
If ErrorLevel = 1
t = /
Else StringMid, t, sc, p += StrLen(sid) + 1, InStr(sc, scb, "", p + 2) - p
step = %t%/%step%
}

; normalize path e.g. /root/node/../child/. becomes /root/child:
step := RegExReplace(step, "(?<=^|/)(?:[^\[/@]+/\.{2}|\.)(?:/|$)|^.+(?=//)")

If (str == 1 or stsl == 1) { ; if not relative path and no select:
; remove last node and trailing attributes and functions:
xpr := RegExReplace(step, (str == 1 and stsl != 1 ? "/(?:\w+:)?\w+(?:\[[^\]]*])?" : "")
. "(?:/@.*?|/\w+\(\))*$")
StringReplace, xpr, xpr, [-1], [1], All ; -1 become just 1
StringReplace, xpr, xpr, [+1], [last()], All ; +1 becomes last()
StringGetPos, p, sc, %sid%
If ErrorLevel = 1
sc = %sc%%sid%%xpr%%scb% ; add record or update as necessary:
Else sc := SubStr(sc, 1, p += StrLen(sid)) . xpr . SubStr(sc, InStr(sc, scb, "", p))
}

; for unions call each operand seperately and join results:
If (InStr(step, "|")) {
StringSplit, s, step, |, `n`t  `r
Loop, %s0%
res .= xpath(doc, s%A_Index%, set) . ","
Return, SubStr(res, 1, -1)
}
Else If (InStr(step, "//") == 1) { ; for wildcard selectors use regex searching mode:
StringTrimLeft, step, step, 2
re = 1
rew = 1
xp = /(?:(?:\w+:)?\w+)*/
}

NumPut(160, doc, 0, "UChar") ; unmask variable

; resolve xpath components to: absolute node path, attributes and predicates (if any)
Loop, Parse, step, /
{
s = %A_LoopField%
If (InStr(s, "*") == 1) ; regex mode for wildcards
{
re = 1
s := "(?:\w+:)?\w+" . SubStr(s, 2)
}
Else If (InStr(s, "@") == 1) { ; if current step is attribute:
StringTrimLeft, atr, s, 1
Continue
}
StringGetPos, p, s, [ ; look for predicate opening [...]
If ErrorLevel = 0
{
If s contains [+1],[-1] ; for child nodes record creation instructions in a list
{
If A_Index = 2 ; root node creation
{
StringLeft, t, s, p
t = <%t%/:: ></%t%/>
If (InStr(s, "+1")) {
If doc =
doc = .
doc = %doc%%t%
}
Else doc = .%t%%doc%
StringLeft, s, s, InStr(s, "[") - 1
}
Else {
nw = %nw%%s%
Continue
}
}
Else { ; i.e. for conditional predicates

If (InStr(s, "last()")) { ; finding last node
StringLeft, t, s, p
t := "<" . SubStr(xp, 2) . t . "/:: "
If re ; with regex:
{
os = 0
Loop
If (!os := RegExMatch(doc, t, "", 1 + os)) {
t = %A_Index%
Break
}
t--
}
Else { ; otherwise using StringReplace
StringReplace, doc, doc, %t%, %t%, UseErrorLevel
t = %ErrorLevel%
}
If (RegExMatch(s, "i)last\(\)\s*\-\s*(\d+)", a)) ; i.e. [last() - 2]
StringReplace, s, s, %a%, % t - a1
Else StringReplace, s, s, last(), %t%
}

; concat. the predicate to the list against the current absolute path:
ax = %ax%%xp%%s%
StringLeft, s, s, p
}
}
Else If (InStr(s, "()")) { ; if step is function, add to list
fn = %fn%+%s% ; use + prefix to prevent overlapping naming conflicts
Continue
}
; finally, if step is not any of the above, assume it's the name of a child node
xp = %xp%%s%/ ; ... and add to list, forming the absolute path
}

If (xp == "" or xp == "/") ; i.e. error cases
Return

; remove initial root selector (/) as this is how the parser works by default:
StringTrimLeft, xp, xp, 1
StringTrimRight, ax, ax, 1

StringTrimRight, nw, nw, 1

ct = 0 ; counter
os = 0 ; offset for main loop starts at zero
Loop {
; find offset of next element, and its closing tag offset:
If re
os := RegExMatch(doc, "<" . xp . ":: ", "", 1 + os)
, osx := RegExMatch(doc, "</" . xp . ">", rem, os) + StrLen(rem)
Else {
StringGetPos, osx, doc, </%xp%>, , os := InStr(doc, "<" . xp . ":: ", true, 1 + os)
osx += 4 + StrLen(xp)
}
If os = 0 ; stop looping when no more tags are found
Break

; predicate parser:
If ax !=
{
sk = 0
Loop, Parse, ax, ] ; for each predicate
{
; split components to: (1) path, (2) selector, (3) operator, (4) quotation char, (5) operand
If (!RegExMatch(A_LoopField, "/?(.*?)\[(.+?)(?:\s*([<>!=]{1,2})\s*(['""])?(.+)(?(4)\4))?\s*$", a))
Continue
a1 = %a1%/
If re
RegExMatch(rem, "(?<=^</)" . a1, a1)

If a2 is integer ; i.e. match only certain index
{
StringGetPos, t, a1, /, R2
StringMid, t, a1, 1, t + 1
t := InStr(SubStr(doc, 1, os), "<" . t . ":: ", true, 0)
; extract parent node:
StringMid, sub, doc, t, InStr(doc, ">", "", os) - t
xpf := "<" . a1 . ":: "
; get index of current element within parent node:
StringReplace, sub, sub, %xpf%, %xpf%, UseErrorLevel
If a2 != %ErrorLevel%
sk = 1
Continue
}

StringReplace, xp, xp, /, /, UseErrorLevel
t = %ErrorLevel%
StringReplace, a1, a1, /, /, UseErrorLevel

; extract result for deep analysis
If t = %ErrorLevel% ; i.e. /root/node[child='test']
StringMid, sub, doc, os, osx - os
Else StringMid, sub, doc
, t := InStr(SubStr(doc, 1, os), "<" . a1 . ":: ", true, 0)
, InStr(doc, "</" . a1 . ">", true, t) + 1

If a2 = position()
sub = %i%
Else If (InStr(a2, "@") == 1) ; when selector is an attribute:
RegExMatch(SubStr(sub, 1, InStr(sub, ">"))
, a3 == "" ? "\b" . SubStr(a2, 2) . "=([""'])[^\1]*?\1"
: "\b(?<=" . SubStr(a2, 2) . "=([""']))[^\1]+?(?=\1)", sub)
Else ; otherwise child node:
{
If a2 = . ; if selector is current node don't append to path:
a2 = /
Else a2 = %a2%/
StringMid, sub, sub
, t := InStr(sub, ">", "", InStr(sub, "<" . a1 . a2 . ":: ", true) + 1) + 1
, InStr(sub, "</" . a1 . a2 . ">", true) - t
}

; dynamic mini expression evaluator:
sk += !(a3 == "" ? (sub != "")
: a3 == "=" ? sub == a5
: a3 == "!=" ? sub != a5
: a3 == ">" ? sub > a5
: a3 == ">=" ? sub >= a5
: a3 == "<" ? sub < a5
: a3 == "<=" ? sub <= a5)
}
If sk != 0 ; if conditions were not met for this result, skip it
Continue
}

If nw != ; for node creation
{
If re
nwp := SubStr(rem, 3, -1)
Else nwp = %xp%
Loop, Parse, nw, ]
{
StringLeft, nwn, A_LoopField, InStr(A_LoopField, "[") - 1
nwn = %nwn%/
nwt = <%nwp%%nwn%:: ></%nwp%%nwn%>
If (t := InStr(A_LoopField, "-1")
? InStr(doc, ">", "", InStr(doc, "<" . nwp . ":: ", true, os) + 1) + 1
: InStr(doc, "</" . nwp . ">", true, os))
os := t
StringLen, osx, nwt
osx += os
doc := SubStr(doc, 1, os - 1) . nwt . SubStr(doc, os)
nwp = %nwp%%nwn%
}
StringLen, t, nwp
If (InStr(fn, "+text()") and atr == "")
os += t + 5, osx -= t + 3
}

If atr !=
{
; extract attribute offsets, with surrounding declaration if text() is not used:
If (t := RegExMatch(SubStr(doc, os, InStr(doc, ">", "", os) - os), InStr(fn, "+text()")
? "(?<=\b" . atr . "=([""']))[^\1]*?(?=\1)"
: "\b" . atr . "=([""'])[^\1]*?\1", rem))
os += t - 1, osx := os + StrLen(rem)
Else { ; create attribute
os := InStr(doc, ">", "", os + 1)
, doc := SubStr(doc, 1, os - 1) . " " . atr . "=""""" . SubStr(doc, os)
, osx := ++os + StrLen(atr) + 3
If (InStr(fn, "+text()"))
osx := os += StrLen(atr) + 2
}
}
Else If (InStr(fn, "+text()") and nw == "") ; for text content:
os := InStr(doc, ">", "", os) + 1, osx := InStr(doc, re ? rem : "</" . xp . ">", true, os)

If InStr(fn, "+index-of()") ; get index rather than content
sub = %A_Index%
Else StringMid, sub, doc, os, osx - os ; extract result

If (InStr(fn, "+count()")) ; increment counter if count() function is used
ct++
Else res = %res%%sub%, ; ... and concat to list

If (set != "" or InStr(fn, "+remove()")) ; modify or remove...
setb = %setb%%os%.%osx%| ; mark for modification
}

If setb !=
{
If (InStr(set, "node:") == 1) {
set := SubStr(xpath(doc, SubStr(set, 6) . "/rawsrc()"), 2)
StringReplace, set, set, <, <%xp%, All
StringReplace, set, set, <%xp%/, </%xp%, All
NumPut(160, doc, 0, "UChar")
}
StringTrimRight, setb, setb, 1
Loop, Parse, setb, |
{
StringSplit, setp, A_LoopField, .
StringLen, t, xp
If (InStr(fn, "+append()"))
setp2 := setp1 := setp2 - t - 3
Else If (InStr(fn, "+prepend()"))
setp2 := setp1 := InStr(doc, ">", "", setp1) + 2
doc := SubStr(doc, 1, setp1 - 1) . set . SubStr(doc, setp2) ; dissect then insert new value
}
}

If (InStr(fn, "+count()"))
res = %ct%, ; trailing char since SubStr is used below

nsid := scb . &doc . ":" ; update sid as necessary
If nsid != %sid%
StringReplace, sc, sc, %sid%, %nsid%

NumPut(0, doc, 0, "UChar") ; remask variable to prevent external editing
StringTrimRight, res, res, 1
If (InStr(fn, "+rawsrc()")) {
StringTrimLeft, t, xpr, 1
StringReplace, res, res, <%t%/, <, All
StringReplace, res, res, </%t%, <, All
StringReplace, res, res, `,, `,%scb%, All
Return, scb . res
}
; remove trailing comma and absolute paths from result before returning:
Return, RegExReplace(res, "S)(?<=<)(\/)?(?:(\w+)\/)+(?(1)|:: )", "$1$2")
}

xpath_save(ByRef doc, src = "") {
xml := RegExReplace(SubStr(doc, 2), "S)(?<=<)(\/)?(?:(\w+)\/)+(?(1)|:: )", "$1$2") ; remove metadata
xml := RegExReplace(xml, "<([\w:]+)([^>]*)><\/\1>", "<$1$2 />") ; fuse empty nodes
;xml := RegExReplace(xml, " (?=(?:\w+:)?\w+=['""])") ; remove prepending whitespace on attributes
xml := RegExReplace(xml, "^\s+|\s+$") ; remove start and leading whitespace
If InStr(xml, "<?xml") != 1 ; add processor instruction if there isn't any:
xml = <?xml version="1.0" encoding="iso-8859-1"?>`n%xml%
StringReplace, xml, xml, `r, , All ; normalize linefeeds:
StringReplace, xml, xml, `n, `r`n, All
sp := " "
StringLen, sl, sp
s =
VarSetCapacity(sxml, StrLen(xml) * 1.1)
Loop, Parse, xml, <, `n`t  `r
{
If A_LoopField =
Continue
If (sb := InStr(A_LoopField, "/") == 1)
StringTrimRight, s, s, sl
sxml = %sxml%`n%s%<%A_LoopField%
If sb
StringTrimRight, s, s, sl
If (InStr(A_LoopField, "?") != 1 and InStr(A_LoopField, "!") != 1
and !InStr(A_LoopField, "/>"))
s .= sp
}
StringTrimLeft, sxml, sxml, 1
sxml := RegExReplace(sxml, "(\n(?:" . sp . ")*<((?:\w+:)?\w+\b)[^<]+?)\n(?:"
. sp . ")*</\2>", "$1</$2>")
If src = ; if save path not specified return the XML document:
Return, sxml
FileDelete, %src% ; delete existing file
FileAppend, %sxml%, %src% ; create new one
Return, ErrorLevel ; return errors, if any
}

xpath_load(ByRef doc, src = "") {
If src = ; if source is empty assume the out variable is the one to be loaded
src = %doc%
Else If FileExist(src) ; otherwise read from file (if it exists)
FileRead, src, %src%
If src not contains <,>
Return, false
; combined expressions slightly improve performance:
src := RegExReplace(src, "<((?:\w+:)?\w+\b)([^>]*)\/\s*>", "<$1$2></$1>") ; defuse nodes
, VarSetCapacity(doc, VarSetCapacity(xml, StrLen(src) * 1.5) * 1.1) ; pre-allocate enough space
Loop, Parse, src, < ; for each opening tag:
{
If (A_Index == 2 and InStr(A_LoopField, "?xml") == 1)
Continue
Else If (InStr(A_LoopField, "?") == 1) ; ignore all other processor instructions
xml = %xml%<%A_LoopField%
Else If (InStr(A_LoopField, "![CDATA[") == 1) { ; escape entities in CDATA sections
cdata := SubStr(A_LoopField, 9, -3)
StringReplace, cdata, cdata, ", ", All
StringReplace, cdata, cdata, &, &, All
StringReplace, cdata, cdata, ', &apos;, All
StringReplace, cdata, cdata, <, <, All
StringReplace, cdata, cdata, >, >, All
xml = %xml%%cdata%
}
Else If (!pos := RegExMatch(A_LoopField, "^\/?(?:\w+:)?\w+", tag)) ; if this isn't a valid tag:
{
If A_LoopField is not space
xml = %xml%<%A_LoopField% ; convert to escaped entity value
}
Else {
StringMid, ex, A_LoopField, pos + StrLen(tag) ; get tag name
If InStr(tag, "/") = 1 { ; if this is a closing tag:
xml = %xml%</%pre%%ex% ; close tag
StringGetPos, pos, pre, /, R2
StringLeft, pre, pre, pos + 1
}
Else {
pre = %pre%%tag%/
xml = %xml%<%pre%:: %ex%
}
}
}
StringReplace, doc, xml, `,, &#44;, All ; entity escape commas (which are used as array delimiters)
NumPut(0, doc := " " . doc, 0, "UChar") ; mask variable from text display with nullbyte
Return, true ; assume sucessful load by this point
}

Avatar de l’utilisateur
tetsuo001
noob
noob
Messages : 7
Inscription : 16 avr. 2015 - 10:36

Re: Modules Nestopia V1.40

Message par tetsuo001 » 17 avr. 2015 - 21:42

jégious a écrit :Il est pas entier ce AHK,
je viens de tester celui ci sur Nestopia 1.46 prevu pour 1.39 et tout fonctionne correctement
il faut bien penser a modifier les touches Esc et la mise en Full Screen dans l'emulateur,reglage manette (option/imput)

module
;----------------------------------------------------------------------------
; Nintendo Entertainment System
; Nestopia
;
; Notes:
; Since the exit emulator key does nothing you should setup an escape key within the emulator using the input options, the default is alt+x, so change
; to esc. But since esc is the default key to bring up the fullscreen menu then you should change that to something else such as Alt+M. The exit emulator menu
; key is disabled to allow for game saving etc...
; <exit>Esc</exit>
; <toggle-menu>Alt+M</toggle-menu>

; Set these keys below
;----------------------------------------------------------------------------
Fullscreen = true
BlackMenu = true ; Make Nestopia's menu black so it looks better fullscreen
ExitKey = Esc ; Set Nestopia's Exit key here
ToggleMenuKey = Alt+M ; Set Nestopia's Toggle Menu key here. Make sure this is not the same as your exit key
;----------------------------------------------------------------------------

settingsFile := CheckFile(emuPath . "nestopia.xml")

FadeInStart()

xpath_load(emuXML, settingsFile ) ; need to read the existing xml otherwise xpath deletes all existing nodes
xpath(emuXML, "/configuration/preferences/application/confirm-exit/text()", "no") ; turning off confirmation on exit
xpath(emuXML, "/configuration/input/keys/file/exit/text()", ExitKey) ; setting exit key
xpath(emuXML, "/configuration/input/keys/view/ToggleMenuKey/text()", ToggleMenuKey) ; setting toggle menu key

; Black Menu
If ( BlackMenu = "true" ) {
xpath(emuXML, "/configuration/preferences/appearance/menu-fullscreen/custom-color/text()", "0x00000000") ; black
xpath(emuXML, "/configuration/preferences/appearance/menu-fullscreen/use-custom-color/text()", "yes") ; turning on custom colors
} Else
xpath(emuXML, "/configuration/preferences/appearance/menu-fullscreen/use-custom-color/text()", "no") ; turning off custom colors

; Enable Fullscreen
If ( Fullscreen = "true" )
xpath(emuXML, "/configuration/preferences/application/start-fullscreen/text()", "yes")
Else
xpath(emuXML, "/configuration/preferences/application/start-fullscreen/text()", "no")

xpath_save(emuXML, settingsFile) ; write new XML

7z(romPath, romName, romExtension, 7zExtractDir)

Run, %executable% "%romPath%%romName%%romExtension%", %emuPath%

WinActivate, ahk_class Nestopia
WinWaitActive, ahk_class Nestopia

FadeInExit()

Process, WaitClose, %executable%

7zCleanUp()

FadeOutExit()

WinActivate, Hyperspin

ExitApp

CloseProcess:
FadeOutStart()
WinClose, ahk_class Nestopia
Return


xpath(ByRef doc, step, set = "") {
static sc, scb = "" ; use EOT (\x04) as delimiter

If step contains %scb% ; i.e. illegal character
Return
sid := scb . &doc . ":" ; should be unique identifier for current XML object
If (InStr(step, "select:") == 1) { ; for quick selection
stsl = 1
StringTrimLeft, step, step, 7
}
If (InStr(step, "/") == 1)
str = 1 ; root selected
Else {
StringGetPos, p, sc, %sid% ; retrieve previous path
If ErrorLevel = 1
t = /
Else StringMid, t, sc, p += StrLen(sid) + 1, InStr(sc, scb, "", p + 2) - p
step = %t%/%step%
}

; normalize path e.g. /root/node/../child/. becomes /root/child:
step := RegExReplace(step, "(?<=^|/)(?:[^\[/@]+/\.{2}|\.)(?:/|$)|^.+(?=//)")

If (str == 1 or stsl == 1) { ; if not relative path and no select:
; remove last node and trailing attributes and functions:
xpr := RegExReplace(step, (str == 1 and stsl != 1 ? "/(?:\w+:)?\w+(?:\[[^\]]*])?" : "")
. "(?:/@.*?|/\w+\(\))*$")
StringReplace, xpr, xpr, [-1], [1], All ; -1 become just 1
StringReplace, xpr, xpr, [+1], [last()], All ; +1 becomes last()
StringGetPos, p, sc, %sid%
If ErrorLevel = 1
sc = %sc%%sid%%xpr%%scb% ; add record or update as necessary:
Else sc := SubStr(sc, 1, p += StrLen(sid)) . xpr . SubStr(sc, InStr(sc, scb, "", p))
}

; for unions call each operand seperately and join results:
If (InStr(step, "|")) {
StringSplit, s, step, |, `n`t  `r
Loop, %s0%
res .= xpath(doc, s%A_Index%, set) . ","
Return, SubStr(res, 1, -1)
}
Else If (InStr(step, "//") == 1) { ; for wildcard selectors use regex searching mode:
StringTrimLeft, step, step, 2
re = 1
rew = 1
xp = /(?:(?:\w+:)?\w+)*/
}

NumPut(160, doc, 0, "UChar") ; unmask variable

; resolve xpath components to: absolute node path, attributes and predicates (if any)
Loop, Parse, step, /
{
s = %A_LoopField%
If (InStr(s, "*") == 1) ; regex mode for wildcards
{
re = 1
s := "(?:\w+:)?\w+" . SubStr(s, 2)
}
Else If (InStr(s, "@") == 1) { ; if current step is attribute:
StringTrimLeft, atr, s, 1
Continue
}
StringGetPos, p, s, [ ; look for predicate opening [...]
If ErrorLevel = 0
{
If s contains [+1],[-1] ; for child nodes record creation instructions in a list
{
If A_Index = 2 ; root node creation
{
StringLeft, t, s, p
t = <%t%/:: ></%t%/>
If (InStr(s, "+1")) {
If doc =
doc = .
doc = %doc%%t%
}
Else doc = .%t%%doc%
StringLeft, s, s, InStr(s, "[") - 1
}
Else {
nw = %nw%%s%
Continue
}
}
Else { ; i.e. for conditional predicates

If (InStr(s, "last()")) { ; finding last node
StringLeft, t, s, p
t := "<" . SubStr(xp, 2) . t . "/:: "
If re ; with regex:
{
os = 0
Loop
If (!os := RegExMatch(doc, t, "", 1 + os)) {
t = %A_Index%
Break
}
t--
}
Else { ; otherwise using StringReplace
StringReplace, doc, doc, %t%, %t%, UseErrorLevel
t = %ErrorLevel%
}
If (RegExMatch(s, "i)last\(\)\s*\-\s*(\d+)", a)) ; i.e. [last() - 2]
StringReplace, s, s, %a%, % t - a1
Else StringReplace, s, s, last(), %t%
}

; concat. the predicate to the list against the current absolute path:
ax = %ax%%xp%%s%
StringLeft, s, s, p
}
}
Else If (InStr(s, "()")) { ; if step is function, add to list
fn = %fn%+%s% ; use + prefix to prevent overlapping naming conflicts
Continue
}
; finally, if step is not any of the above, assume it's the name of a child node
xp = %xp%%s%/ ; ... and add to list, forming the absolute path
}

If (xp == "" or xp == "/") ; i.e. error cases
Return

; remove initial root selector (/) as this is how the parser works by default:
StringTrimLeft, xp, xp, 1
StringTrimRight, ax, ax, 1

StringTrimRight, nw, nw, 1

ct = 0 ; counter
os = 0 ; offset for main loop starts at zero
Loop {
; find offset of next element, and its closing tag offset:
If re
os := RegExMatch(doc, "<" . xp . ":: ", "", 1 + os)
, osx := RegExMatch(doc, "</" . xp . ">", rem, os) + StrLen(rem)
Else {
StringGetPos, osx, doc, </%xp%>, , os := InStr(doc, "<" . xp . ":: ", true, 1 + os)
osx += 4 + StrLen(xp)
}
If os = 0 ; stop looping when no more tags are found
Break

; predicate parser:
If ax !=
{
sk = 0
Loop, Parse, ax, ] ; for each predicate
{
; split components to: (1) path, (2) selector, (3) operator, (4) quotation char, (5) operand
If (!RegExMatch(A_LoopField, "/?(.*?)\[(.+?)(?:\s*([<>!=]{1,2})\s*(['""])?(.+)(?(4)\4))?\s*$", a))
Continue
a1 = %a1%/
If re
RegExMatch(rem, "(?<=^</)" . a1, a1)

If a2 is integer ; i.e. match only certain index
{
StringGetPos, t, a1, /, R2
StringMid, t, a1, 1, t + 1
t := InStr(SubStr(doc, 1, os), "<" . t . ":: ", true, 0)
; extract parent node:
StringMid, sub, doc, t, InStr(doc, ">", "", os) - t
xpf := "<" . a1 . ":: "
; get index of current element within parent node:
StringReplace, sub, sub, %xpf%, %xpf%, UseErrorLevel
If a2 != %ErrorLevel%
sk = 1
Continue
}

StringReplace, xp, xp, /, /, UseErrorLevel
t = %ErrorLevel%
StringReplace, a1, a1, /, /, UseErrorLevel

; extract result for deep analysis
If t = %ErrorLevel% ; i.e. /root/node[child='test']
StringMid, sub, doc, os, osx - os
Else StringMid, sub, doc
, t := InStr(SubStr(doc, 1, os), "<" . a1 . ":: ", true, 0)
, InStr(doc, "</" . a1 . ">", true, t) + 1

If a2 = position()
sub = %i%
Else If (InStr(a2, "@") == 1) ; when selector is an attribute:
RegExMatch(SubStr(sub, 1, InStr(sub, ">"))
, a3 == "" ? "\b" . SubStr(a2, 2) . "=([""'])[^\1]*?\1"
: "\b(?<=" . SubStr(a2, 2) . "=([""']))[^\1]+?(?=\1)", sub)
Else ; otherwise child node:
{
If a2 = . ; if selector is current node don't append to path:
a2 = /
Else a2 = %a2%/
StringMid, sub, sub
, t := InStr(sub, ">", "", InStr(sub, "<" . a1 . a2 . ":: ", true) + 1) + 1
, InStr(sub, "</" . a1 . a2 . ">", true) - t
}

; dynamic mini expression evaluator:
sk += !(a3 == "" ? (sub != "")
: a3 == "=" ? sub == a5
: a3 == "!=" ? sub != a5
: a3 == ">" ? sub > a5
: a3 == ">=" ? sub >= a5
: a3 == "<" ? sub < a5
: a3 == "<=" ? sub <= a5)
}
If sk != 0 ; if conditions were not met for this result, skip it
Continue
}

If nw != ; for node creation
{
If re
nwp := SubStr(rem, 3, -1)
Else nwp = %xp%
Loop, Parse, nw, ]
{
StringLeft, nwn, A_LoopField, InStr(A_LoopField, "[") - 1
nwn = %nwn%/
nwt = <%nwp%%nwn%:: ></%nwp%%nwn%>
If (t := InStr(A_LoopField, "-1")
? InStr(doc, ">", "", InStr(doc, "<" . nwp . ":: ", true, os) + 1) + 1
: InStr(doc, "</" . nwp . ">", true, os))
os := t
StringLen, osx, nwt
osx += os
doc := SubStr(doc, 1, os - 1) . nwt . SubStr(doc, os)
nwp = %nwp%%nwn%
}
StringLen, t, nwp
If (InStr(fn, "+text()") and atr == "")
os += t + 5, osx -= t + 3
}

If atr !=
{
; extract attribute offsets, with surrounding declaration if text() is not used:
If (t := RegExMatch(SubStr(doc, os, InStr(doc, ">", "", os) - os), InStr(fn, "+text()")
? "(?<=\b" . atr . "=([""']))[^\1]*?(?=\1)"
: "\b" . atr . "=([""'])[^\1]*?\1", rem))
os += t - 1, osx := os + StrLen(rem)
Else { ; create attribute
os := InStr(doc, ">", "", os + 1)
, doc := SubStr(doc, 1, os - 1) . " " . atr . "=""""" . SubStr(doc, os)
, osx := ++os + StrLen(atr) + 3
If (InStr(fn, "+text()"))
osx := os += StrLen(atr) + 2
}
}
Else If (InStr(fn, "+text()") and nw == "") ; for text content:
os := InStr(doc, ">", "", os) + 1, osx := InStr(doc, re ? rem : "</" . xp . ">", true, os)

If InStr(fn, "+index-of()") ; get index rather than content
sub = %A_Index%
Else StringMid, sub, doc, os, osx - os ; extract result

If (InStr(fn, "+count()")) ; increment counter if count() function is used
ct++
Else res = %res%%sub%, ; ... and concat to list

If (set != "" or InStr(fn, "+remove()")) ; modify or remove...
setb = %setb%%os%.%osx%| ; mark for modification
}

If setb !=
{
If (InStr(set, "node:") == 1) {
set := SubStr(xpath(doc, SubStr(set, 6) . "/rawsrc()"), 2)
StringReplace, set, set, <, <%xp%, All
StringReplace, set, set, <%xp%/, </%xp%, All
NumPut(160, doc, 0, "UChar")
}
StringTrimRight, setb, setb, 1
Loop, Parse, setb, |
{
StringSplit, setp, A_LoopField, .
StringLen, t, xp
If (InStr(fn, "+append()"))
setp2 := setp1 := setp2 - t - 3
Else If (InStr(fn, "+prepend()"))
setp2 := setp1 := InStr(doc, ">", "", setp1) + 2
doc := SubStr(doc, 1, setp1 - 1) . set . SubStr(doc, setp2) ; dissect then insert new value
}
}

If (InStr(fn, "+count()"))
res = %ct%, ; trailing char since SubStr is used below

nsid := scb . &doc . ":" ; update sid as necessary
If nsid != %sid%
StringReplace, sc, sc, %sid%, %nsid%

NumPut(0, doc, 0, "UChar") ; remask variable to prevent external editing
StringTrimRight, res, res, 1
If (InStr(fn, "+rawsrc()")) {
StringTrimLeft, t, xpr, 1
StringReplace, res, res, <%t%/, <, All
StringReplace, res, res, </%t%, <, All
StringReplace, res, res, `,, `,%scb%, All
Return, scb . res
}
; remove trailing comma and absolute paths from result before returning:
Return, RegExReplace(res, "S)(?<=<)(\/)?(?:(\w+)\/)+(?(1)|:: )", "$1$2")
}

xpath_save(ByRef doc, src = "") {
xml := RegExReplace(SubStr(doc, 2), "S)(?<=<)(\/)?(?:(\w+)\/)+(?(1)|:: )", "$1$2") ; remove metadata
xml := RegExReplace(xml, "<([\w:]+)([^>]*)><\/\1>", "<$1$2 />") ; fuse empty nodes
;xml := RegExReplace(xml, " (?=(?:\w+:)?\w+=['""])") ; remove prepending whitespace on attributes
xml := RegExReplace(xml, "^\s+|\s+$") ; remove start and leading whitespace
If InStr(xml, "<?xml") != 1 ; add processor instruction if there isn't any:
xml = <?xml version="1.0" encoding="iso-8859-1"?>`n%xml%
StringReplace, xml, xml, `r, , All ; normalize linefeeds:
StringReplace, xml, xml, `n, `r`n, All
sp := " "
StringLen, sl, sp
s =
VarSetCapacity(sxml, StrLen(xml) * 1.1)
Loop, Parse, xml, <, `n`t  `r
{
If A_LoopField =
Continue
If (sb := InStr(A_LoopField, "/") == 1)
StringTrimRight, s, s, sl
sxml = %sxml%`n%s%<%A_LoopField%
If sb
StringTrimRight, s, s, sl
If (InStr(A_LoopField, "?") != 1 and InStr(A_LoopField, "!") != 1
and !InStr(A_LoopField, "/>"))
s .= sp
}
StringTrimLeft, sxml, sxml, 1
sxml := RegExReplace(sxml, "(\n(?:" . sp . ")*<((?:\w+:)?\w+\b)[^<]+?)\n(?:"
. sp . ")*</\2>", "$1</$2>")
If src = ; if save path not specified return the XML document:
Return, sxml
FileDelete, %src% ; delete existing file
FileAppend, %sxml%, %src% ; create new one
Return, ErrorLevel ; return errors, if any
}

xpath_load(ByRef doc, src = "") {
If src = ; if source is empty assume the out variable is the one to be loaded
src = %doc%
Else If FileExist(src) ; otherwise read from file (if it exists)
FileRead, src, %src%
If src not contains <,>
Return, false
; combined expressions slightly improve performance:
src := RegExReplace(src, "<((?:\w+:)?\w+\b)([^>]*)\/\s*>", "<$1$2></$1>") ; defuse nodes
, VarSetCapacity(doc, VarSetCapacity(xml, StrLen(src) * 1.5) * 1.1) ; pre-allocate enough space
Loop, Parse, src, < ; for each opening tag:
{
If (A_Index == 2 and InStr(A_LoopField, "?xml") == 1)
Continue
Else If (InStr(A_LoopField, "?") == 1) ; ignore all other processor instructions
xml = %xml%<%A_LoopField%
Else If (InStr(A_LoopField, "![CDATA[") == 1) { ; escape entities in CDATA sections
cdata := SubStr(A_LoopField, 9, -3)
StringReplace, cdata, cdata, ", ", All
StringReplace, cdata, cdata, &, &, All
StringReplace, cdata, cdata, ', &apos;, All
StringReplace, cdata, cdata, <, <, All
StringReplace, cdata, cdata, >, >, All
xml = %xml%%cdata%
}
Else If (!pos := RegExMatch(A_LoopField, "^\/?(?:\w+:)?\w+", tag)) ; if this isn't a valid tag:
{
If A_LoopField is not space
xml = %xml%<%A_LoopField% ; convert to escaped entity value
}
Else {
StringMid, ex, A_LoopField, pos + StrLen(tag) ; get tag name
If InStr(tag, "/") = 1 { ; if this is a closing tag:
xml = %xml%</%pre%%ex% ; close tag
StringGetPos, pos, pre, /, R2
StringLeft, pre, pre, pos + 1
}
Else {
pre = %pre%%tag%/
xml = %xml%<%pre%:: %ex%
}
}
}
StringReplace, doc, xml, `,, &#44;, All ; entity escape commas (which are used as array delimiters)
NumPut(0, doc := " " . doc, 0, "UChar") ; mask variable from text display with nullbyte
Return, true ; assume sucessful load by this point
}

Ha super cela fonctionne nickel
apparemment je doit créer certain dossier je vais voir cela save etc ...
mais au final cela fonctionne

merci beaucoup pour le coup de main !!!

Avatar de l’utilisateur
jegious
Apprenti
Apprenti
Messages : 19
Inscription : 02 déc. 2012 - 00:00
A été remercié : 1 fois

Re: Modules Nestopia V1.40

Message par jegious » 18 avr. 2015 - 13:04

Voila le contenu de mon dossier Nestopia,
si ça peut aider.

Image

Avatar de l’utilisateur
roxaslove
noob
noob
Messages : 5
Inscription : 25 déc. 2014 - 12:23

Re: Modules Nestopia V1.40

Message par roxaslove » 07 mai 2015 - 21:09

Salut tout le monde,

J'ai un petit soucis avec Nestopia...
Quand je lance mon jeu a partir de hyperspin nestopia souvre a part dans une fenetre du coup quand je quitte le jeu il me fait apparaitre la fenetre de l'emulateur que je doit fermer a la souris pour ensuite retourner sur HyperSpin aidez moi svp

Avatar de l’utilisateur
jegious
Apprenti
Apprenti
Messages : 19
Inscription : 02 déc. 2012 - 00:00
A été remercié : 1 fois

Re: Modules Nestopia V1.40

Message par jegious » 07 mai 2015 - 21:15

jégious a écrit :Il est pas entier ce AHK,
je viens de tester celui ci sur Nestopia 1.46 prevu pour 1.39 et tout fonctionne correctement
il faut bien penser a modifier les touches Esc et la mise en Full Screen dans l'emulateur,reglage manette (option/imput)

module
;----------------------------------------------------------------------------
; Nintendo Entertainment System
; Nestopia
;
; Notes:
; Since the exit emulator key does nothing you should setup an escape key within the emulator using the input options, the default is alt+x, so change
; to esc. But since esc is the default key to bring up the fullscreen menu then you should change that to something else such as Alt+M. The exit emulator menu
; key is disabled to allow for game saving etc...
; <exit>Esc</exit>
; <toggle-menu>Alt+M</toggle-menu>

; Set these keys below
;----------------------------------------------------------------------------
Fullscreen = true
BlackMenu = true ; Make Nestopia's menu black so it looks better fullscreen
ExitKey = Esc ; Set Nestopia's Exit key here
ToggleMenuKey = Alt+M ; Set Nestopia's Toggle Menu key here. Make sure this is not the same as your exit key
;----------------------------------------------------------------------------

settingsFile := CheckFile(emuPath . "nestopia.xml")

FadeInStart()

xpath_load(emuXML, settingsFile ) ; need to read the existing xml otherwise xpath deletes all existing nodes
xpath(emuXML, "/configuration/preferences/application/confirm-exit/text()", "no") ; turning off confirmation on exit
xpath(emuXML, "/configuration/input/keys/file/exit/text()", ExitKey) ; setting exit key
xpath(emuXML, "/configuration/input/keys/view/ToggleMenuKey/text()", ToggleMenuKey) ; setting toggle menu key

; Black Menu
If ( BlackMenu = "true" ) {
xpath(emuXML, "/configuration/preferences/appearance/menu-fullscreen/custom-color/text()", "0x00000000") ; black
xpath(emuXML, "/configuration/preferences/appearance/menu-fullscreen/use-custom-color/text()", "yes") ; turning on custom colors
} Else
xpath(emuXML, "/configuration/preferences/appearance/menu-fullscreen/use-custom-color/text()", "no") ; turning off custom colors

; Enable Fullscreen
If ( Fullscreen = "true" )
xpath(emuXML, "/configuration/preferences/application/start-fullscreen/text()", "yes")
Else
xpath(emuXML, "/configuration/preferences/application/start-fullscreen/text()", "no")

xpath_save(emuXML, settingsFile) ; write new XML

7z(romPath, romName, romExtension, 7zExtractDir)

Run, %executable% "%romPath%%romName%%romExtension%", %emuPath%

WinActivate, ahk_class Nestopia
WinWaitActive, ahk_class Nestopia

FadeInExit()

Process, WaitClose, %executable%

7zCleanUp()

FadeOutExit()

WinActivate, Hyperspin

ExitApp

CloseProcess:
FadeOutStart()
WinClose, ahk_class Nestopia
Return


xpath(ByRef doc, step, set = "") {
static sc, scb = "" ; use EOT (\x04) as delimiter

If step contains %scb% ; i.e. illegal character
Return
sid := scb . &doc . ":" ; should be unique identifier for current XML object
If (InStr(step, "select:") == 1) { ; for quick selection
stsl = 1
StringTrimLeft, step, step, 7
}
If (InStr(step, "/") == 1)
str = 1 ; root selected
Else {
StringGetPos, p, sc, %sid% ; retrieve previous path
If ErrorLevel = 1
t = /
Else StringMid, t, sc, p += StrLen(sid) + 1, InStr(sc, scb, "", p + 2) - p
step = %t%/%step%
}

; normalize path e.g. /root/node/../child/. becomes /root/child:
step := RegExReplace(step, "(?<=^|/)(?:[^\[/@]+/\.{2}|\.)(?:/|$)|^.+(?=//)")

If (str == 1 or stsl == 1) { ; if not relative path and no select:
; remove last node and trailing attributes and functions:
xpr := RegExReplace(step, (str == 1 and stsl != 1 ? "/(?:\w+:)?\w+(?:\[[^\]]*])?" : "")
. "(?:/@.*?|/\w+\(\))*$")
StringReplace, xpr, xpr, [-1], [1], All ; -1 become just 1
StringReplace, xpr, xpr, [+1], [last()], All ; +1 becomes last()
StringGetPos, p, sc, %sid%
If ErrorLevel = 1
sc = %sc%%sid%%xpr%%scb% ; add record or update as necessary:
Else sc := SubStr(sc, 1, p += StrLen(sid)) . xpr . SubStr(sc, InStr(sc, scb, "", p))
}

; for unions call each operand seperately and join results:
If (InStr(step, "|")) {
StringSplit, s, step, |, `n`t  `r
Loop, %s0%
res .= xpath(doc, s%A_Index%, set) . ","
Return, SubStr(res, 1, -1)
}
Else If (InStr(step, "//") == 1) { ; for wildcard selectors use regex searching mode:
StringTrimLeft, step, step, 2
re = 1
rew = 1
xp = /(?:(?:\w+:)?\w+)*/
}

NumPut(160, doc, 0, "UChar") ; unmask variable

; resolve xpath components to: absolute node path, attributes and predicates (if any)
Loop, Parse, step, /
{
s = %A_LoopField%
If (InStr(s, "*") == 1) ; regex mode for wildcards
{
re = 1
s := "(?:\w+:)?\w+" . SubStr(s, 2)
}
Else If (InStr(s, "@") == 1) { ; if current step is attribute:
StringTrimLeft, atr, s, 1
Continue
}
StringGetPos, p, s, [ ; look for predicate opening [...]
If ErrorLevel = 0
{
If s contains [+1],[-1] ; for child nodes record creation instructions in a list
{
If A_Index = 2 ; root node creation
{
StringLeft, t, s, p
t = <%t%/:: ></%t%/>
If (InStr(s, "+1")) {
If doc =
doc = .
doc = %doc%%t%
}
Else doc = .%t%%doc%
StringLeft, s, s, InStr(s, "[") - 1
}
Else {
nw = %nw%%s%
Continue
}
}
Else { ; i.e. for conditional predicates

If (InStr(s, "last()")) { ; finding last node
StringLeft, t, s, p
t := "<" . SubStr(xp, 2) . t . "/:: "
If re ; with regex:
{
os = 0
Loop
If (!os := RegExMatch(doc, t, "", 1 + os)) {
t = %A_Index%
Break
}
t--
}
Else { ; otherwise using StringReplace
StringReplace, doc, doc, %t%, %t%, UseErrorLevel
t = %ErrorLevel%
}
If (RegExMatch(s, "i)last\(\)\s*\-\s*(\d+)", a)) ; i.e. [last() - 2]
StringReplace, s, s, %a%, % t - a1
Else StringReplace, s, s, last(), %t%
}

; concat. the predicate to the list against the current absolute path:
ax = %ax%%xp%%s%
StringLeft, s, s, p
}
}
Else If (InStr(s, "()")) { ; if step is function, add to list
fn = %fn%+%s% ; use + prefix to prevent overlapping naming conflicts
Continue
}
; finally, if step is not any of the above, assume it's the name of a child node
xp = %xp%%s%/ ; ... and add to list, forming the absolute path
}

If (xp == "" or xp == "/") ; i.e. error cases
Return

; remove initial root selector (/) as this is how the parser works by default:
StringTrimLeft, xp, xp, 1
StringTrimRight, ax, ax, 1

StringTrimRight, nw, nw, 1

ct = 0 ; counter
os = 0 ; offset for main loop starts at zero
Loop {
; find offset of next element, and its closing tag offset:
If re
os := RegExMatch(doc, "<" . xp . ":: ", "", 1 + os)
, osx := RegExMatch(doc, "</" . xp . ">", rem, os) + StrLen(rem)
Else {
StringGetPos, osx, doc, </%xp%>, , os := InStr(doc, "<" . xp . ":: ", true, 1 + os)
osx += 4 + StrLen(xp)
}
If os = 0 ; stop looping when no more tags are found
Break

; predicate parser:
If ax !=
{
sk = 0
Loop, Parse, ax, ] ; for each predicate
{
; split components to: (1) path, (2) selector, (3) operator, (4) quotation char, (5) operand
If (!RegExMatch(A_LoopField, "/?(.*?)\[(.+?)(?:\s*([<>!=]{1,2})\s*(['""])?(.+)(?(4)\4))?\s*$", a))
Continue
a1 = %a1%/
If re
RegExMatch(rem, "(?<=^</)" . a1, a1)

If a2 is integer ; i.e. match only certain index
{
StringGetPos, t, a1, /, R2
StringMid, t, a1, 1, t + 1
t := InStr(SubStr(doc, 1, os), "<" . t . ":: ", true, 0)
; extract parent node:
StringMid, sub, doc, t, InStr(doc, ">", "", os) - t
xpf := "<" . a1 . ":: "
; get index of current element within parent node:
StringReplace, sub, sub, %xpf%, %xpf%, UseErrorLevel
If a2 != %ErrorLevel%
sk = 1
Continue
}

StringReplace, xp, xp, /, /, UseErrorLevel
t = %ErrorLevel%
StringReplace, a1, a1, /, /, UseErrorLevel

; extract result for deep analysis
If t = %ErrorLevel% ; i.e. /root/node[child='test']
StringMid, sub, doc, os, osx - os
Else StringMid, sub, doc
, t := InStr(SubStr(doc, 1, os), "<" . a1 . ":: ", true, 0)
, InStr(doc, "</" . a1 . ">", true, t) + 1

If a2 = position()
sub = %i%
Else If (InStr(a2, "@") == 1) ; when selector is an attribute:
RegExMatch(SubStr(sub, 1, InStr(sub, ">"))
, a3 == "" ? "\b" . SubStr(a2, 2) . "=([""'])[^\1]*?\1"
: "\b(?<=" . SubStr(a2, 2) . "=([""']))[^\1]+?(?=\1)", sub)
Else ; otherwise child node:
{
If a2 = . ; if selector is current node don't append to path:
a2 = /
Else a2 = %a2%/
StringMid, sub, sub
, t := InStr(sub, ">", "", InStr(sub, "<" . a1 . a2 . ":: ", true) + 1) + 1
, InStr(sub, "</" . a1 . a2 . ">", true) - t
}

; dynamic mini expression evaluator:
sk += !(a3 == "" ? (sub != "")
: a3 == "=" ? sub == a5
: a3 == "!=" ? sub != a5
: a3 == ">" ? sub > a5
: a3 == ">=" ? sub >= a5
: a3 == "<" ? sub < a5
: a3 == "<=" ? sub <= a5)
}
If sk != 0 ; if conditions were not met for this result, skip it
Continue
}

If nw != ; for node creation
{
If re
nwp := SubStr(rem, 3, -1)
Else nwp = %xp%
Loop, Parse, nw, ]
{
StringLeft, nwn, A_LoopField, InStr(A_LoopField, "[") - 1
nwn = %nwn%/
nwt = <%nwp%%nwn%:: ></%nwp%%nwn%>
If (t := InStr(A_LoopField, "-1")
? InStr(doc, ">", "", InStr(doc, "<" . nwp . ":: ", true, os) + 1) + 1
: InStr(doc, "</" . nwp . ">", true, os))
os := t
StringLen, osx, nwt
osx += os
doc := SubStr(doc, 1, os - 1) . nwt . SubStr(doc, os)
nwp = %nwp%%nwn%
}
StringLen, t, nwp
If (InStr(fn, "+text()") and atr == "")
os += t + 5, osx -= t + 3
}

If atr !=
{
; extract attribute offsets, with surrounding declaration if text() is not used:
If (t := RegExMatch(SubStr(doc, os, InStr(doc, ">", "", os) - os), InStr(fn, "+text()")
? "(?<=\b" . atr . "=([""']))[^\1]*?(?=\1)"
: "\b" . atr . "=([""'])[^\1]*?\1", rem))
os += t - 1, osx := os + StrLen(rem)
Else { ; create attribute
os := InStr(doc, ">", "", os + 1)
, doc := SubStr(doc, 1, os - 1) . " " . atr . "=""""" . SubStr(doc, os)
, osx := ++os + StrLen(atr) + 3
If (InStr(fn, "+text()"))
osx := os += StrLen(atr) + 2
}
}
Else If (InStr(fn, "+text()") and nw == "") ; for text content:
os := InStr(doc, ">", "", os) + 1, osx := InStr(doc, re ? rem : "</" . xp . ">", true, os)

If InStr(fn, "+index-of()") ; get index rather than content
sub = %A_Index%
Else StringMid, sub, doc, os, osx - os ; extract result

If (InStr(fn, "+count()")) ; increment counter if count() function is used
ct++
Else res = %res%%sub%, ; ... and concat to list

If (set != "" or InStr(fn, "+remove()")) ; modify or remove...
setb = %setb%%os%.%osx%| ; mark for modification
}

If setb !=
{
If (InStr(set, "node:") == 1) {
set := SubStr(xpath(doc, SubStr(set, 6) . "/rawsrc()"), 2)
StringReplace, set, set, <, <%xp%, All
StringReplace, set, set, <%xp%/, </%xp%, All
NumPut(160, doc, 0, "UChar")
}
StringTrimRight, setb, setb, 1
Loop, Parse, setb, |
{
StringSplit, setp, A_LoopField, .
StringLen, t, xp
If (InStr(fn, "+append()"))
setp2 := setp1 := setp2 - t - 3
Else If (InStr(fn, "+prepend()"))
setp2 := setp1 := InStr(doc, ">", "", setp1) + 2
doc := SubStr(doc, 1, setp1 - 1) . set . SubStr(doc, setp2) ; dissect then insert new value
}
}

If (InStr(fn, "+count()"))
res = %ct%, ; trailing char since SubStr is used below

nsid := scb . &doc . ":" ; update sid as necessary
If nsid != %sid%
StringReplace, sc, sc, %sid%, %nsid%

NumPut(0, doc, 0, "UChar") ; remask variable to prevent external editing
StringTrimRight, res, res, 1
If (InStr(fn, "+rawsrc()")) {
StringTrimLeft, t, xpr, 1
StringReplace, res, res, <%t%/, <, All
StringReplace, res, res, </%t%, <, All
StringReplace, res, res, `,, `,%scb%, All
Return, scb . res
}
; remove trailing comma and absolute paths from result before returning:
Return, RegExReplace(res, "S)(?<=<)(\/)?(?:(\w+)\/)+(?(1)|:: )", "$1$2")
}

xpath_save(ByRef doc, src = "") {
xml := RegExReplace(SubStr(doc, 2), "S)(?<=<)(\/)?(?:(\w+)\/)+(?(1)|:: )", "$1$2") ; remove metadata
xml := RegExReplace(xml, "<([\w:]+)([^>]*)><\/\1>", "<$1$2 />") ; fuse empty nodes
;xml := RegExReplace(xml, " (?=(?:\w+:)?\w+=['""])") ; remove prepending whitespace on attributes
xml := RegExReplace(xml, "^\s+|\s+$") ; remove start and leading whitespace
If InStr(xml, "<?xml") != 1 ; add processor instruction if there isn't any:
xml = <?xml version="1.0" encoding="iso-8859-1"?>`n%xml%
StringReplace, xml, xml, `r, , All ; normalize linefeeds:
StringReplace, xml, xml, `n, `r`n, All
sp := " "
StringLen, sl, sp
s =
VarSetCapacity(sxml, StrLen(xml) * 1.1)
Loop, Parse, xml, <, `n`t  `r
{
If A_LoopField =
Continue
If (sb := InStr(A_LoopField, "/") == 1)
StringTrimRight, s, s, sl
sxml = %sxml%`n%s%<%A_LoopField%
If sb
StringTrimRight, s, s, sl
If (InStr(A_LoopField, "?") != 1 and InStr(A_LoopField, "!") != 1
and !InStr(A_LoopField, "/>"))
s .= sp
}
StringTrimLeft, sxml, sxml, 1
sxml := RegExReplace(sxml, "(\n(?:" . sp . ")*<((?:\w+:)?\w+\b)[^<]+?)\n(?:"
. sp . ")*</\2>", "$1</$2>")
If src = ; if save path not specified return the XML document:
Return, sxml
FileDelete, %src% ; delete existing file
FileAppend, %sxml%, %src% ; create new one
Return, ErrorLevel ; return errors, if any
}

xpath_load(ByRef doc, src = "") {
If src = ; if source is empty assume the out variable is the one to be loaded
src = %doc%
Else If FileExist(src) ; otherwise read from file (if it exists)
FileRead, src, %src%
If src not contains <,>
Return, false
; combined expressions slightly improve performance:
src := RegExReplace(src, "<((?:\w+:)?\w+\b)([^>]*)\/\s*>", "<$1$2></$1>") ; defuse nodes
, VarSetCapacity(doc, VarSetCapacity(xml, StrLen(src) * 1.5) * 1.1) ; pre-allocate enough space
Loop, Parse, src, < ; for each opening tag:
{
If (A_Index == 2 and InStr(A_LoopField, "?xml") == 1)
Continue
Else If (InStr(A_LoopField, "?") == 1) ; ignore all other processor instructions
xml = %xml%<%A_LoopField%
Else If (InStr(A_LoopField, "![CDATA[") == 1) { ; escape entities in CDATA sections
cdata := SubStr(A_LoopField, 9, -3)
StringReplace, cdata, cdata, ", ", All
StringReplace, cdata, cdata, &, &, All
StringReplace, cdata, cdata, ', &apos;, All
StringReplace, cdata, cdata, <, <, All
StringReplace, cdata, cdata, >, >, All
xml = %xml%%cdata%
}
Else If (!pos := RegExMatch(A_LoopField, "^\/?(?:\w+:)?\w+", tag)) ; if this isn't a valid tag:
{
If A_LoopField is not space
xml = %xml%<%A_LoopField% ; convert to escaped entity value
}
Else {
StringMid, ex, A_LoopField, pos + StrLen(tag) ; get tag name
If InStr(tag, "/") = 1 { ; if this is a closing tag:
xml = %xml%</%pre%%ex% ; close tag
StringGetPos, pos, pre, /, R2
StringLeft, pre, pre, pos + 1
}
Else {
pre = %pre%%tag%/
xml = %xml%<%pre%:: %ex%
}
}
}
StringReplace, doc, xml, `,, &#44;, All ; entity escape commas (which are used as array delimiters)
NumPut(0, doc := " " . doc, 0, "UChar") ; mask variable from text display with nullbyte
Return, true ; assume sucessful load by this point
}

Avatar de l’utilisateur
roxaslove
noob
noob
Messages : 5
Inscription : 25 déc. 2014 - 12:23

Re: Modules Nestopia V1.40

Message par roxaslove » 07 mai 2015 - 21:46

Donc je recopier le AHK ? (chose que j'ai fait logiquement et modifier la touche ESC et la mise full screen (il est déja mis en full screen)attend je vais tester

Avatar de l’utilisateur
roxaslove
noob
noob
Messages : 5
Inscription : 25 déc. 2014 - 12:23

Re: Modules Nestopia V1.40

Message par roxaslove » 07 mai 2015 - 21:49

J'ai mis en fullscreen au lancement et tout y a pas de soucis mais pour quitter lemul direct ca se passe comment car il me remet toujours la barre en haut quoi

Avatar de l’utilisateur
jegious
Apprenti
Apprenti
Messages : 19
Inscription : 02 déc. 2012 - 00:00
A été remercié : 1 fois

Re: Modules Nestopia V1.40

Message par jegious » 08 mai 2015 - 14:58

Tu ouvres Nestopia,
en haut,tu as 'options',puis 'imput'
une fenêtre s'ouvre,
dans la colonne de gauche,'Type',tu choisis 'View',
colonne de droite 'Mapping',tu choisis la combinaison de touche qui correspond a 'Fullscreen'
tu modifies cette combinaison par ce que tu veux.
Ensuite,colonne de gauche,tu choisis 'File',
colonne de droite tout en bas,en face de 'Exit',tu mets en surbrillance la touche affectée et
tu cliques sur 'Clear' au dessous,puis OK
si Nestopia est en Fullscreen,tu fais Alt+F4,sinon
tu appuies sur la touche ou combinaison de touche que tu a choisis pour basculer en fullscreen et Alt+F4.
Voilà,j’espère que ça a résolu ton souci.

Avatar de l’utilisateur
roxaslove
noob
noob
Messages : 5
Inscription : 25 déc. 2014 - 12:23

Re: Modules Nestopia V1.40

Message par roxaslove » 08 mai 2015 - 17:48

ok merci beaucoup j'avais trouver en attendant j'ai pas lacher l'affaire !
Dit une petite question tu sais ou trouver des Theme NES car j'aimerais me faire une petite playlist NES

Désolé de re déranger pour nestopia mais j'ai beau assimiler une touche au bouton EXIT mais des que 'lemulateur ferme je doit reconfigurer ma touche elle ne veut pas rester enregistrer pk ?

edit : aprés plusieurs essai la toutes les attribution de touches fonctionnent exepter la touche EXIT qui a chaque foi que je demarre lemulateur via HyperSpin refuse de fonctionner ....

Avatar de l’utilisateur
jegious
Apprenti
Apprenti
Messages : 19
Inscription : 02 déc. 2012 - 00:00
A été remercié : 1 fois

Re: Modules Nestopia V1.40

Message par jegious » 08 mai 2015 - 21:04

La meilleure solution,
c'est d'utiliser JoyToKey,tu affectes ce que tu veux comme touche Esc.
Puis,dans JoyToKey,tu associes le profil créé pour ta config touche NES à l’application Nestopia
comme ça dés que tu lances Nestopia via Hyperspin,ta config de touche JoyToKey/Nestopia prendra le dessus et
tu pourras quitter sans problème.
Perso,j’utilise JoyToKey pour tout les émulateurs,
a chaque fois que quelqu'un vient avec un joystick ou une manettes différentes,
j'ajoute un joystick dans JoyToKey et je modifie les profils pour chaque config afin d'avoir un maximum de compatibilité avec tout les controls

Pour les thèmes,il y en a plein sur le forum ou sinon dans la rubrique: viewforum.php?f=48" onclick="window.open(this.href);return false;
ou comme moi,tu te les fais a ta convenance grâce a Hypertheme inclue avec les packs HFS du forum.

Avatar de l’utilisateur
roxaslove
noob
noob
Messages : 5
Inscription : 25 déc. 2014 - 12:23

Re: Modules Nestopia V1.40

Message par roxaslove » 08 mai 2015 - 21:14

merci encore pour tout tes renseignement par contre pour les thémes super nes je veut bien les faire moi même mais trouver les images et tout pour des jeux NES c'est un peu complex mais merci encore

peut etre un petit tuto pour m'aider a associer joytokey ainsi que les touches a nestopia ?

jgious je t'explique mon soucis une foi tout configurer sur nestopia l'emulateur et JoyToKey tout marche a merveille par contre une foi que je passe par notre ami HyperSpin et que je lance mon jeu la bizarrement mes touches ne sont plus du tout reconnu et je suis obliger de retourner dans l'emulateur en lui meme car mes touches on rechanger...
D'ou cela peut t'il provenir car si je passe par l'emul direct ca fonctionne mais quand je lance lemul a partir d'hyperspin plus rien

Avatar de l’utilisateur
jegious
Apprenti
Apprenti
Messages : 19
Inscription : 02 déc. 2012 - 00:00
A été remercié : 1 fois

Re: Modules Nestopia V1.40

Message par jegious » 09 mai 2015 - 13:25

Un tuto JoytoKey,il y en a déjà un sur le forum:
viewtopic.php?f=28&t=402" onclick="window.open(this.href);return false;

Pour le soucis,j'vois pas du tout,
maybe,ré-installe un nestopia propre et reconfigure les touches+affecter JoyToKey avec nestopia.exe
une fois cela fait,tu lances nestopia,tu mets en Fullscreen,lances un jeu pour tester la manette et tu quittes avec Alt+F4

Répondre

Revenir à « Aide Configuration d'Emulateurs »