Skip to content

Commit ca94692

Browse files
committed
1 parent b6e5e0c commit ca94692

4 files changed

Lines changed: 49 additions & 26 deletions

File tree

src/bytecode.go

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12396,15 +12396,19 @@ func (sc text) Run(c *Char, _ []int32) bool {
1239612396
case "m":
1239712397
fntList = sys.motif.Fnt
1239812398
}
12399-
if fnt >= 0 && fnt < len(fntList) && fntList[fnt] != nil {
12400-
ts.fnt = fntList[fnt]
12401-
switch fflg {
12402-
case "f":
12403-
ts.SetLocalcoord(float32(sys.lifebar.localcoord[0]), float32(sys.lifebar.localcoord[1]))
12404-
case "m":
12405-
ts.SetLocalcoord(float32(sys.motif.Info.Localcoord[0]), float32(sys.motif.Info.Localcoord[1]))
12406-
default:
12407-
//ts.SetLocalcoord(c.stOgi().localcoord[0], c.stOgi().localcoord[1])
12399+
if fnt >= 0 {
12400+
if f := fntList[fnt]; f != nil {
12401+
ts.fnt = f
12402+
switch fflg {
12403+
case "f":
12404+
ts.SetLocalcoord(float32(sys.lifebar.localcoord[0]), float32(sys.lifebar.localcoord[1]))
12405+
case "m":
12406+
ts.SetLocalcoord(float32(sys.motif.Info.Localcoord[0]), float32(sys.motif.Info.Localcoord[1]))
12407+
default:
12408+
//ts.SetLocalcoord(c.stOgi().localcoord[0], c.stOgi().localcoord[1])
12409+
}
12410+
} else {
12411+
fnt = -1
1240812412
}
1240912413
} else {
1241012414
fnt = -1
@@ -12661,18 +12665,28 @@ func (sc modifyText) Run(c *Char, _ []int32) bool {
1266112665
}
1266212666
case text_font:
1266312667
fnt := int(exp[1].evalI(c))
12664-
fflg := exp[0].evalB(c)
12668+
fflg := string(*(*[]byte)(unsafe.Pointer(&exp[0])))
1266512669
fntList := crun.gi().fnt
12666-
if fflg {
12670+
switch fflg {
12671+
case "f":
1266712672
fntList = sys.lifebar.fnt
12668-
}
12669-
if fnt >= 0 && fnt < len(fntList) && fntList[fnt] != nil {
12670-
eachText(func(ts *TextSprite) {
12671-
ts.fnt = fntList[fnt]
12672-
if fflg {
12673-
ts.SetLocalcoord(float32(sys.lifebar.localcoord[0]), float32(sys.lifebar.localcoord[1]))
12674-
}
12675-
})
12673+
case "m":
12674+
fntList = sys.motif.Fnt
12675+
}
12676+
if fnt >= 0 {
12677+
if f := fntList[fnt]; f != nil {
12678+
eachText(func(ts *TextSprite) {
12679+
ts.fnt = f
12680+
switch fflg {
12681+
case "f":
12682+
ts.SetLocalcoord(float32(sys.lifebar.localcoord[0]), float32(sys.lifebar.localcoord[1]))
12683+
case "m":
12684+
ts.SetLocalcoord(float32(sys.motif.Info.Localcoord[0]), float32(sys.motif.Info.Localcoord[1]))
12685+
default:
12686+
//ts.SetLocalcoord(c.stOgi().localcoord[0], c.stOgi().localcoord[1])
12687+
}
12688+
})
12689+
}
1267612690
}
1267712691
case text_localcoord:
1267812692
var x, y float32

src/compiler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5696,13 +5696,16 @@ func (c *Compiler) getDataPrefix(data *string, ffxDefault bool) (prefix string)
56965696
// Find the longest matching valid prefix at the start of the string
56975697
// The length check allows "FFF" to be used even though "F" is reserved
56985698
longestMatch := ""
5699-
// Check "F" and "S" reserved prefixes
5699+
// Check "F", "S", "M" reserved prefixes
57005700
if strings.HasPrefix(str, "f") {
57015701
longestMatch = "f"
57025702
}
57035703
if strings.HasPrefix(str, "s") {
57045704
longestMatch = "s"
57055705
}
5706+
if strings.HasPrefix(str, "m") {
5707+
longestMatch = "m"
5708+
}
57065709
// Check common FX prefixes currently in use
57075710
for p := range sys.ffx {
57085711
if strings.HasPrefix(str, p) && len(p) > len(longestMatch) {

src/compiler_functions.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5508,9 +5508,12 @@ func (c *Compiler) text(is IniSection, sc *StateControllerBase, _ int8) (StateCo
55085508
}
55095509
if err := c.stateParam(is, "font", false, func(data string) error {
55105510
prefix := c.getDataPrefix(&data, false)
5511-
fflg := prefix == "f"
5511+
// Only "f" (lifebar) or "m" (motif) are meaningful for Text/ModifyText.
5512+
if prefix != "f" && prefix != "m" {
5513+
prefix = ""
5514+
}
55125515
return c.scAdd(sc, text_font, data, VT_Int, 1,
5513-
sc.iToExp(Btoi(fflg))...)
5516+
sc.beToExp(BytecodeExp(prefix))...)
55145517
}); err != nil {
55155518
return err
55165519
}
@@ -5631,9 +5634,12 @@ func (c *Compiler) modifyText(is IniSection, sc *StateControllerBase, _ int8) (S
56315634
}
56325635
if err := c.stateParam(is, "font", false, func(data string) error {
56335636
prefix := c.getDataPrefix(&data, false)
5634-
fflg := prefix == "f"
5637+
// Only "f" (lifebar) or "m" (motif) are meaningful for Text/ModifyText.
5638+
if prefix != "f" && prefix != "m" {
5639+
prefix = ""
5640+
}
56355641
return c.scAdd(sc, text_font, data, VT_Int, 1,
5636-
sc.iToExp(Btoi(fflg))...)
5642+
sc.beToExp(BytecodeExp(prefix))...)
56375643
}); err != nil {
56385644
return err
56395645
}

src/music.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,12 @@ func (m Music) tryPlay(key, def string) bool {
320320
return false
321321
}
322322
hasDefined := false
323-
for i, v := range lst {
323+
for _, v := range lst {
324324
if v != nil && strings.TrimSpace(v.bgmusic) != "" {
325325
hasDefined = true
326326
break
327327
}
328-
fmt.Printf("[music] tryPlay: prefix '%s' candidate[%d] has empty bgmusic\n", key, i)
328+
//fmt.Printf("[music] tryPlay: prefix '%s' candidate[%d] has empty bgmusic\n", key, i)
329329
}
330330
if !hasDefined {
331331
//fmt.Printf("[music] tryPlay: prefix '%s' has no defined bgmusic entries\n", key)

0 commit comments

Comments
 (0)