• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Go で書き直した Ikemen


Commit MetaInfo

Révision91713c1dc67da570da5aeb04c457b85ec405a34f (tree)
l'heure2016-12-23 00:00:47
AuteurSUEHIRO <supersuehiro@user...>
CommiterSUEHIRO

Message de Log

リダイレクトやエクスプロードのところを書いた

Change Summary

Modification

--- a/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
1-/chars
2-/data
3-/go
4-/sound
5-/stages
--- a/build.sh
+++ b/build.sh
@@ -1,5 +1,3 @@
11 #!/bin/sh
2-GOPATH=$PWD/go
3-export GOPATH
2+export GOPATH=$PWD/go
43 GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build -o ikemen ./src
5-go clean ./src
--- a/get.sh
+++ b/get.sh
@@ -1,6 +1,5 @@
11 #!/bin/sh
2-GOPATH=$PWD/go
3-export GOPATH
2+export GOPATH=$PWD/go
43 go get -u github.com/yuin/gopher-lua
54 go get -u github.com/go-gl/glfw/v3.2/glfw
65 go get -u github.com/go-gl/gl/v2.1/gl
--- a/run.sh
+++ b/run.sh
@@ -1,6 +1,4 @@
11 #!/bin/sh
2-GOPATH=$PWD/go
3-export GOPATH
2+export GOPATH=$PWD/go
43 go fmt ./src/*.go
5-# godoc -src ./src .* > godoc.txt
64 go run ./src/*.go
--- a/src/bytecode.go
+++ b/src/bytecode.go
@@ -634,7 +634,6 @@ func (_ BytecodeExp) blor(v1 *BytecodeValue, v2 BytecodeValue) {
634634 v1.SetB(v1.ToB() || v2.ToB())
635635 }
636636 func (be BytecodeExp) run(c *Char, scpn int) BytecodeValue {
637- sys.bcStack.Clear()
638637 orgc := c
639638 for i := 1; i <= len(be); i++ {
640639 switch be[i-1] {
@@ -668,6 +667,69 @@ func (be BytecodeExp) run(c *Char, scpn int) BytecodeValue {
668667 fallthrough
669668 case OC_jmp:
670669 i += int(*(*int32)(unsafe.Pointer(&be[i]))) + 4
670+ case OC_parent:
671+ if c = c.parent(); c != nil {
672+ i += 4
673+ continue
674+ }
675+ sys.bcStack.Push(BytecodeSF())
676+ i += int(*(*int32)(unsafe.Pointer(&be[i]))) + 4
677+ case OC_root:
678+ if c = c.root(); c != nil {
679+ i += 4
680+ continue
681+ }
682+ sys.bcStack.Push(BytecodeSF())
683+ i += int(*(*int32)(unsafe.Pointer(&be[i]))) + 4
684+ case OC_helper:
685+ if c = c.helper(sys.bcStack.Pop().ToI()); c != nil {
686+ i += 4
687+ continue
688+ }
689+ sys.bcStack.Push(BytecodeSF())
690+ i += int(*(*int32)(unsafe.Pointer(&be[i]))) + 4
691+ case OC_target:
692+ if c = c.target(sys.bcStack.Pop().ToI()); c != nil {
693+ i += 4
694+ continue
695+ }
696+ sys.bcStack.Push(BytecodeSF())
697+ i += int(*(*int32)(unsafe.Pointer(&be[i]))) + 4
698+ case OC_partner:
699+ if c = c.partner(sys.bcStack.Pop().ToI()); c != nil {
700+ i += 4
701+ continue
702+ }
703+ sys.bcStack.Push(BytecodeSF())
704+ i += int(*(*int32)(unsafe.Pointer(&be[i]))) + 4
705+ case OC_enemy:
706+ if c = c.enemy(sys.bcStack.Pop().ToI()); c != nil {
707+ i += 4
708+ continue
709+ }
710+ sys.bcStack.Push(BytecodeSF())
711+ i += int(*(*int32)(unsafe.Pointer(&be[i]))) + 4
712+ case OC_enemynear:
713+ if c = c.enemynear(sys.bcStack.Pop().ToI()); c != nil {
714+ i += 4
715+ continue
716+ }
717+ sys.bcStack.Push(BytecodeSF())
718+ i += int(*(*int32)(unsafe.Pointer(&be[i]))) + 4
719+ case OC_playerid:
720+ if c = c.playerid(sys.bcStack.Pop().ToI()); c != nil {
721+ i += 4
722+ continue
723+ }
724+ sys.bcStack.Push(BytecodeSF())
725+ i += int(*(*int32)(unsafe.Pointer(&be[i]))) + 4
726+ case OC_p2:
727+ if c = c.p2(); c != nil {
728+ i += 4
729+ continue
730+ }
731+ sys.bcStack.Push(BytecodeSF())
732+ i += int(*(*int32)(unsafe.Pointer(&be[i]))) + 4
671733 case OC_int8:
672734 sys.bcStack.Push(BytecodeInt(int32(int8(be[i]))))
673735 i++
@@ -768,10 +830,13 @@ func (be BytecodeExp) run(c *Char, scpn int) BytecodeValue {
768830 case OC_animtime:
769831 sys.bcStack.Push(BytecodeInt(c.animTime()))
770832 case OC_animelemtime:
771- sys.bcStack.Push(BytecodeInt(c.animElemTime(sys.bcStack.Pop().ToI())))
833+ *sys.bcStack.Top() = BytecodeInt(c.animElemTime(sys.bcStack.Top().ToI()))
834+ case OC_stateno:
835+ sys.bcStack.Push(BytecodeInt(c.stateNo()))
772836 case OC_ex_:
773837 be.run_ex(c, scpn, &i)
774838 default:
839+ println(be[i-1])
775840 unimplemented()
776841 }
777842 c = orgc
@@ -783,6 +848,9 @@ func (be BytecodeExp) run_ex(c *Char, scpn int, i *int) {
783848 switch be[*i-1] {
784849 case OC_ex_matchover:
785850 sys.bcStack.Push(BytecodeBool(sys.matchOver()))
851+ default:
852+ println(be[*i-1])
853+ unimplemented()
786854 }
787855 }
788856 func (be BytecodeExp) evalF(c *Char, scpn int) float32 {
@@ -865,6 +933,9 @@ func (scb StateControllerBase) run(c *Char, ps *int32,
865933 }
866934 }
867935 *ps = scb.persistent
936+ if len(sys.bcStack) != 0 {
937+ unimplemented()
938+ }
868939 return true
869940 }
870941
@@ -1341,6 +1412,399 @@ func (sc ctrlSet) Run(c *Char, ps *int32) bool {
13411412 return false
13421413 }
13431414
1415+type explod StateControllerBase
1416+
1417+const (
1418+ explod_ownpal byte = iota
1419+ explod_remappal
1420+ explod_id
1421+ explod_facing
1422+ explod_vfacing
1423+ explod_pos
1424+ explod_random
1425+ explod_postype
1426+ explod_velocity
1427+ explod_accel
1428+ explod_scale
1429+ explod_bindtime
1430+ explod_removetime
1431+ explod_supermove
1432+ explod_supermovetime
1433+ explod_pausemovetime
1434+ explod_sprpriority
1435+ explod_ontop
1436+ explod_shadow
1437+ explod_removeongethit
1438+ explod_trans
1439+ explod_anim
1440+ explod_angle
1441+ explod_yangle
1442+ explod_xangle
1443+ explod_ignorehitpause
1444+)
1445+
1446+func (sc explod) Run(c *Char, ps *int32) bool {
1447+ var e *Explod
1448+ var i int
1449+ rp := [2]int32{-1, 0}
1450+ StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool {
1451+ if e == nil {
1452+ e, i = c.newExplod()
1453+ if e == nil {
1454+ return false
1455+ }
1456+ }
1457+ switch id {
1458+ case explod_ownpal:
1459+ e.ownpal = exp[0].evalB(c, sc.playerNo)
1460+ case explod_remappal:
1461+ rp[0] = exp[0].evalI(c, sc.playerNo)
1462+ if len(exp) > 1 {
1463+ rp[1] = exp[1].evalI(c, sc.playerNo)
1464+ }
1465+ case explod_id:
1466+ e.id = Max(0, exp[0].evalI(c, sc.playerNo))
1467+ case explod_facing:
1468+ if exp[0].evalI(c, sc.playerNo) < 0 {
1469+ e.relativef = -1
1470+ } else {
1471+ e.relativef = 1
1472+ }
1473+ case explod_vfacing:
1474+ if exp[0].evalI(c, sc.playerNo) < 0 {
1475+ e.vfacing = -1
1476+ } else {
1477+ e.vfacing = 1
1478+ }
1479+ case explod_pos:
1480+ e.offset[0] = exp[0].evalF(c, sc.playerNo)
1481+ if len(exp) > 1 {
1482+ e.offset[1] = exp[1].evalF(c, sc.playerNo)
1483+ }
1484+ case explod_random:
1485+ rndx := exp[0].evalF(c, sc.playerNo)
1486+ e.offset[0] += RandF(-rndx, rndx)
1487+ if len(exp) > 1 {
1488+ rndy := exp[1].evalF(c, sc.playerNo)
1489+ e.offset[1] += RandF(-rndy, rndy)
1490+ }
1491+ case explod_postype:
1492+ e.postype = PosType(exp[0].evalI(c, sc.playerNo))
1493+ e.setPos(c)
1494+ case explod_velocity:
1495+ e.velocity[0] = exp[0].evalF(c, sc.playerNo)
1496+ if len(exp) > 1 {
1497+ e.velocity[1] = exp[1].evalF(c, sc.playerNo)
1498+ }
1499+ case explod_accel:
1500+ e.accel[0] = exp[0].evalF(c, sc.playerNo)
1501+ if len(exp) > 1 {
1502+ e.accel[1] = exp[1].evalF(c, sc.playerNo)
1503+ }
1504+ case explod_scale:
1505+ e.scale[0] = exp[0].evalF(c, sc.playerNo)
1506+ if len(exp) > 1 {
1507+ e.scale[1] = exp[1].evalF(c, sc.playerNo)
1508+ }
1509+ case explod_bindtime:
1510+ e.bindtime = exp[0].evalI(c, sc.playerNo)
1511+ case explod_removetime:
1512+ e.removetime = exp[0].evalI(c, sc.playerNo)
1513+ case explod_supermove:
1514+ if exp[0].evalB(c, sc.playerNo) {
1515+ e.supermovetime = -1
1516+ } else {
1517+ e.supermovetime = 0
1518+ }
1519+ case explod_supermovetime:
1520+ e.supermovetime = exp[0].evalI(c, sc.playerNo)
1521+ case explod_pausemovetime:
1522+ e.pausemovetime = exp[0].evalI(c, sc.playerNo)
1523+ case explod_sprpriority:
1524+ e.sprpriority = exp[0].evalI(c, sc.playerNo)
1525+ case explod_ontop:
1526+ e.ontop = exp[0].evalB(c, sc.playerNo)
1527+ if e.ontop {
1528+ e.sprpriority = 0
1529+ }
1530+ case explod_shadow:
1531+ e.shadow[0] = exp[0].evalI(c, sc.playerNo)
1532+ if len(exp) > 1 {
1533+ e.shadow[1] = exp[1].evalI(c, sc.playerNo)
1534+ if len(exp) > 2 {
1535+ e.shadow[2] = exp[2].evalI(c, sc.playerNo)
1536+ }
1537+ }
1538+ case explod_removeongethit:
1539+ e.removeongethit = exp[0].evalB(c, sc.playerNo)
1540+ case explod_trans:
1541+ e.alpha = [2]int32{exp[0].evalI(c, sc.playerNo),
1542+ exp[1].evalI(c, sc.playerNo)}
1543+ if len(exp) > 2 {
1544+ e.alpha[0] = Max(0, Min(255, e.alpha[0]))
1545+ e.alpha[1] = Max(0, Min(255, e.alpha[1]))
1546+ }
1547+ case explod_anim:
1548+ e.anim = c.getAnim(exp[1].evalI(c, sc.playerNo),
1549+ exp[0].evalB(c, sc.playerNo))
1550+ case explod_angle:
1551+ e.angle = exp[0].evalF(c, sc.playerNo)
1552+ case explod_yangle:
1553+ exp[0].run(c, sc.playerNo)
1554+ case explod_xangle:
1555+ exp[0].run(c, sc.playerNo)
1556+ case explod_ignorehitpause:
1557+ e.ignorehitpause = exp[0].evalB(c, sc.playerNo)
1558+ }
1559+ return true
1560+ })
1561+ c.insertExplodEx(i, rp[0], rp[1])
1562+ return false
1563+}
1564+
1565+type modifyExplod explod
1566+
1567+func (sc modifyExplod) Run(c *Char, ps *int32) bool {
1568+ eid := int32(-1)
1569+ var expls []*Explod
1570+ rp := [2]int32{-1, 0}
1571+ eachExpl := func(f func(e *Explod)) {
1572+ for _, e := range expls {
1573+ f(e)
1574+ }
1575+ }
1576+ StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool {
1577+ switch id {
1578+ case explod_remappal:
1579+ rp[0] = exp[0].evalI(c, sc.playerNo)
1580+ if len(exp) > 1 {
1581+ rp[1] = exp[1].evalI(c, sc.playerNo)
1582+ }
1583+ case explod_id:
1584+ eid = exp[0].evalI(c, sc.playerNo)
1585+ default:
1586+ if len(expls) == 0 {
1587+ expls = c.getExplods(eid)
1588+ if len(expls) == 0 {
1589+ return false
1590+ }
1591+ eachExpl(func(e *Explod) {
1592+ if e.ownpal {
1593+ c.remapPalSub(e.palfx, 1, 1, rp[0], rp[1])
1594+ }
1595+ })
1596+ }
1597+ switch id {
1598+ case explod_facing:
1599+ if exp[0].evalI(c, sc.playerNo) < 0 {
1600+ eachExpl(func(e *Explod) { e.relativef = -1 })
1601+ } else {
1602+ eachExpl(func(e *Explod) { e.relativef = 1 })
1603+ }
1604+ case explod_vfacing:
1605+ if exp[0].evalI(c, sc.playerNo) < 0 {
1606+ eachExpl(func(e *Explod) { e.vfacing = -1 })
1607+ } else {
1608+ eachExpl(func(e *Explod) { e.vfacing = 1 })
1609+ }
1610+ case explod_pos:
1611+ x := exp[0].evalF(c, sc.playerNo)
1612+ eachExpl(func(e *Explod) { e.offset[0] = x })
1613+ if len(exp) > 1 {
1614+ y := exp[1].evalF(c, sc.playerNo)
1615+ eachExpl(func(e *Explod) { e.offset[1] = y })
1616+ }
1617+ case explod_random:
1618+ rndx := exp[0].evalF(c, sc.playerNo)
1619+ rndx = RandF(-rndx, rndx)
1620+ eachExpl(func(e *Explod) { e.offset[0] += rndx })
1621+ if len(exp) > 1 {
1622+ rndy := exp[1].evalF(c, sc.playerNo)
1623+ rndy = RandF(-rndy, rndy)
1624+ eachExpl(func(e *Explod) { e.offset[1] += rndy })
1625+ }
1626+ case explod_postype:
1627+ pt := PosType(exp[0].evalI(c, sc.playerNo))
1628+ eachExpl(func(e *Explod) {
1629+ e.postype = pt
1630+ e.setPos(c)
1631+ })
1632+ case explod_velocity:
1633+ x := exp[0].evalF(c, sc.playerNo)
1634+ eachExpl(func(e *Explod) { e.velocity[0] = x })
1635+ if len(exp) > 1 {
1636+ y := exp[1].evalF(c, sc.playerNo)
1637+ eachExpl(func(e *Explod) { e.velocity[1] = y })
1638+ }
1639+ case explod_accel:
1640+ x := exp[0].evalF(c, sc.playerNo)
1641+ eachExpl(func(e *Explod) { e.accel[0] = x })
1642+ if len(exp) > 1 {
1643+ y := exp[1].evalF(c, sc.playerNo)
1644+ eachExpl(func(e *Explod) { e.accel[1] = y })
1645+ }
1646+ case explod_scale:
1647+ x := exp[0].evalF(c, sc.playerNo)
1648+ eachExpl(func(e *Explod) { e.scale[0] = x })
1649+ if len(exp) > 1 {
1650+ y := exp[1].evalF(c, sc.playerNo)
1651+ eachExpl(func(e *Explod) { e.scale[1] = y })
1652+ }
1653+ case explod_bindtime:
1654+ t := exp[0].evalI(c, sc.playerNo)
1655+ eachExpl(func(e *Explod) { e.bindtime = t })
1656+ case explod_removetime:
1657+ t := exp[0].evalI(c, sc.playerNo)
1658+ eachExpl(func(e *Explod) { e.removetime = t })
1659+ case explod_supermove:
1660+ if exp[0].evalB(c, sc.playerNo) {
1661+ eachExpl(func(e *Explod) { e.supermovetime = -1 })
1662+ } else {
1663+ eachExpl(func(e *Explod) { e.supermovetime = 0 })
1664+ }
1665+ case explod_supermovetime:
1666+ t := exp[0].evalI(c, sc.playerNo)
1667+ eachExpl(func(e *Explod) { e.supermovetime = t })
1668+ case explod_pausemovetime:
1669+ t := exp[0].evalI(c, sc.playerNo)
1670+ eachExpl(func(e *Explod) { e.pausemovetime = t })
1671+ case explod_sprpriority:
1672+ t := exp[0].evalI(c, sc.playerNo)
1673+ eachExpl(func(e *Explod) { e.sprpriority = t })
1674+ case explod_ontop:
1675+ t := exp[0].evalB(c, sc.playerNo)
1676+ eachExpl(func(e *Explod) {
1677+ e.ontop = t
1678+ if e.ontop {
1679+ e.sprpriority = 0
1680+ }
1681+ })
1682+ case explod_shadow:
1683+ r := exp[0].evalI(c, sc.playerNo)
1684+ eachExpl(func(e *Explod) { e.shadow[0] = r })
1685+ if len(exp) > 1 {
1686+ g := exp[1].evalI(c, sc.playerNo)
1687+ eachExpl(func(e *Explod) { e.shadow[1] = g })
1688+ if len(exp) > 2 {
1689+ b := exp[2].evalI(c, sc.playerNo)
1690+ eachExpl(func(e *Explod) { e.shadow[2] = b })
1691+ }
1692+ }
1693+ case explod_removeongethit:
1694+ t := exp[0].evalB(c, sc.playerNo)
1695+ eachExpl(func(e *Explod) { e.removeongethit = t })
1696+ case explod_trans:
1697+ s, d := exp[0].evalI(c, sc.playerNo), exp[1].evalI(c, sc.playerNo)
1698+ if len(exp) > 2 {
1699+ s = Max(0, Min(255, s))
1700+ d = Max(0, Min(255, d))
1701+ }
1702+ eachExpl(func(e *Explod) { e.alpha = [2]int32{s, d} })
1703+ case explod_angle:
1704+ a := exp[0].evalF(c, sc.playerNo)
1705+ eachExpl(func(e *Explod) { e.angle = a })
1706+ case explod_yangle:
1707+ exp[0].run(c, sc.playerNo)
1708+ case explod_xangle:
1709+ exp[0].run(c, sc.playerNo)
1710+ }
1711+ }
1712+ return true
1713+ })
1714+ return false
1715+}
1716+
1717+type posSet StateControllerBase
1718+
1719+const (
1720+ posSet_x byte = iota
1721+ posSet_y
1722+ posSet_z
1723+)
1724+
1725+func (sc posSet) Run(c *Char, ps *int32) bool {
1726+ StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool {
1727+ switch id {
1728+ case posSet_x:
1729+ c.setX(exp[0].evalF(c, sc.playerNo))
1730+ case posSet_y:
1731+ c.setY(exp[0].evalF(c, sc.playerNo))
1732+ case posSet_z:
1733+ exp[0].run(c, sc.playerNo)
1734+ }
1735+ return true
1736+ })
1737+ return false
1738+}
1739+
1740+type posAdd posSet
1741+
1742+func (sc posAdd) Run(c *Char, ps *int32) bool {
1743+ StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool {
1744+ switch id {
1745+ case posSet_x:
1746+ c.addX(exp[0].evalF(c, sc.playerNo))
1747+ case posSet_y:
1748+ c.addY(exp[0].evalF(c, sc.playerNo))
1749+ case posSet_z:
1750+ exp[0].run(c, sc.playerNo)
1751+ }
1752+ return true
1753+ })
1754+ return false
1755+}
1756+
1757+type velSet posSet
1758+
1759+func (sc velSet) Run(c *Char, ps *int32) bool {
1760+ StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool {
1761+ switch id {
1762+ case posSet_x:
1763+ c.setXV(exp[0].evalF(c, sc.playerNo))
1764+ case posSet_y:
1765+ c.setYV(exp[0].evalF(c, sc.playerNo))
1766+ case posSet_z:
1767+ exp[0].run(c, sc.playerNo)
1768+ }
1769+ return true
1770+ })
1771+ return false
1772+}
1773+
1774+type velAdd posSet
1775+
1776+func (sc velAdd) Run(c *Char, ps *int32) bool {
1777+ StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool {
1778+ switch id {
1779+ case posSet_x:
1780+ c.addXV(exp[0].evalF(c, sc.playerNo))
1781+ case posSet_y:
1782+ c.addYV(exp[0].evalF(c, sc.playerNo))
1783+ case posSet_z:
1784+ exp[0].run(c, sc.playerNo)
1785+ }
1786+ return true
1787+ })
1788+ return false
1789+}
1790+
1791+type velMul posSet
1792+
1793+func (sc velMul) Run(c *Char, ps *int32) bool {
1794+ StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool {
1795+ switch id {
1796+ case posSet_x:
1797+ c.mulXV(exp[0].evalF(c, sc.playerNo))
1798+ case posSet_y:
1799+ c.mulYV(exp[0].evalF(c, sc.playerNo))
1800+ case posSet_z:
1801+ exp[0].run(c, sc.playerNo)
1802+ }
1803+ return true
1804+ })
1805+ return false
1806+}
1807+
13441808 type hitDef StateControllerBase
13451809
13461810 const (
@@ -1352,9 +1816,9 @@ func (sc hitDef) Run(c *Char, ps *int32) bool {
13521816 switch id {
13531817 case hitDef_:
13541818 }
1355- unimplemented()
13561819 return true
13571820 })
1821+ unimplemented()
13581822 return false
13591823 }
13601824
--- a/src/char.go
+++ b/src/char.go
@@ -663,6 +663,47 @@ func (ai *AfterImage) setupPalFX() {
663663 }
664664 }
665665
666+type Explod struct {
667+ id int32
668+ bindtime int32
669+ scale [2]float32
670+ time int32
671+ removeongethit bool
672+ removetime int32
673+ velocity [2]float32
674+ accel [2]float32
675+ sprpriority int32
676+ postype PosType
677+ offset [2]float32
678+ relativef int32
679+ pos [2]float32
680+ facing int32
681+ vfacing int32
682+ shadow [3]int32
683+ supermovetime int32
684+ pausemovetime int32
685+ anim *Animation
686+ ontop bool
687+ alpha [2]int32
688+ ownpal bool
689+ playerId int32
690+ bindId int32
691+ ignorehitpause bool
692+ angle float32
693+ oldPos [2]float32
694+ newPos [2]float32
695+ palfx *PalFX
696+}
697+
698+func (e *Explod) clear() {
699+ *e = Explod{id: IErr, scale: [2]float32{1, 1}, removetime: -2,
700+ postype: PT_P1, relativef: 1, facing: 1, vfacing: 1,
701+ alpha: [2]int32{-1, 0}, playerId: -1, bindId: -1, ignorehitpause: true}
702+}
703+func (e *Explod) setPos(c *Char) {
704+ unimplemented()
705+}
706+
666707 type Projectile struct {
667708 hitdef HitDef
668709 id int32
@@ -738,6 +779,8 @@ type Char struct {
738779 size CharSize
739780 hitdef HitDef
740781 pos [2]float32
782+ drawPos [2]float32
783+ oldPos [2]float32
741784 vel [2]float32
742785 standby bool
743786 pauseMovetime int32
@@ -1105,3 +1148,92 @@ func (c *Char) animElemTime(e int32) int32 {
11051148 unimplemented()
11061149 return 0
11071150 }
1151+func (c *Char) newExplod() (*Explod, int) {
1152+ unimplemented()
1153+ return nil, 0
1154+}
1155+func (c *Char) getExplods(id int32) []*Explod {
1156+ unimplemented()
1157+ return nil
1158+}
1159+func (c *Char) remapPalSub(pfx *PalFX, sg, sn, dg, dn int32) {
1160+ unimplemented()
1161+}
1162+func (c *Char) insertExplodEx(i int, rpg, rpn int32) {
1163+ unimplemented()
1164+}
1165+func (c *Char) getAnim(n int32, ffx bool) *Animation {
1166+ unimplemented()
1167+ return nil
1168+}
1169+func (c *Char) setPosX(x float32) {
1170+ if c.pos[0] != x {
1171+ c.pos[0] = x
1172+ unimplemented()
1173+ }
1174+}
1175+func (c *Char) setPosY(y float32) {
1176+ c.pos[1] = y
1177+}
1178+func (c *Char) setX(x float32) {
1179+ c.oldPos[0], c.drawPos[0] = x, x
1180+ c.setPosX(x)
1181+}
1182+func (c *Char) setY(y float32) {
1183+ c.oldPos[1], c.drawPos[1] = y, y
1184+ c.setPosY(y)
1185+}
1186+func (c *Char) addX(x float32) {
1187+ c.setX(c.pos[0] + x)
1188+}
1189+func (c *Char) addY(y float32) {
1190+ c.setY(c.pos[1] + y)
1191+}
1192+func (c *Char) addXV(xv float32) {
1193+ c.vel[0] += xv
1194+}
1195+func (c *Char) addYV(yv float32) {
1196+ c.vel[1] += yv
1197+}
1198+func (c *Char) mulXV(xv float32) {
1199+ c.vel[0] *= xv
1200+}
1201+func (c *Char) mulYV(yv float32) {
1202+ c.vel[1] *= yv
1203+}
1204+func (c *Char) parent() *Char {
1205+ unimplemented()
1206+ return nil
1207+}
1208+func (c *Char) root() *Char {
1209+ unimplemented()
1210+ return nil
1211+}
1212+func (c *Char) helper(id int32) *Char {
1213+ unimplemented()
1214+ return nil
1215+}
1216+func (c *Char) target(id int32) *Char {
1217+ unimplemented()
1218+ return nil
1219+}
1220+func (c *Char) enemy(n int32) *Char {
1221+ unimplemented()
1222+ return nil
1223+}
1224+func (c *Char) enemynear(n int32) *Char {
1225+ unimplemented()
1226+ return nil
1227+}
1228+func (c *Char) playerid(id int32) *Char {
1229+ unimplemented()
1230+ return nil
1231+}
1232+func (c *Char) p2() *Char {
1233+ unimplemented()
1234+ return nil
1235+}
1236+func (c *Char) stateNo() int32 {
1237+ unimplemented()
1238+ return 0
1239+}
--- a/src/compiler.go
+++ b/src/compiler.go
@@ -505,8 +505,75 @@ func (c *Compiler) expValue(out *BytecodeExp, in *string) (BytecodeValue,
505505 var bv1, bv2, bv3 BytecodeValue
506506 var n int32
507507 var be BytecodeExp
508+ var opc OpCode
508509 var err error
509510 switch c.token {
511+ case "root", "parent", "helper", "target", "partner",
512+ "enemy", "enemynear", "playerid":
513+ switch c.token {
514+ case "parent":
515+ opc = OC_parent
516+ c.token = c.tokenizer(in)
517+ case "root":
518+ opc = OC_root
519+ c.token = c.tokenizer(in)
520+ default:
521+ switch c.token {
522+ case "helper":
523+ opc = OC_helper
524+ case "target":
525+ opc = OC_target
526+ case "partner":
527+ opc = OC_partner
528+ case "enemy":
529+ opc = OC_enemy
530+ case "enemynear":
531+ opc = OC_enemynear
532+ case "playerid":
533+ opc = OC_playerid
534+ }
535+ c.token = c.tokenizer(in)
536+ if c.token == "(" {
537+ c.token = c.tokenizer(in)
538+ if bv1, err = c.expBoolOr(out, in); err != nil {
539+ return BytecodeSF(), err
540+ }
541+ if err := c.kakkotojiru(in); err != nil {
542+ return BytecodeSF(), err
543+ }
544+ c.token = c.tokenizer(in)
545+ out.appendValue(bv1)
546+ } else {
547+ switch opc {
548+ case OC_helper, OC_target:
549+ out.appendValue(BytecodeInt(-1))
550+ case OC_partner, OC_enemy, OC_enemynear:
551+ out.appendValue(BytecodeInt(0))
552+ case OC_playerid:
553+ return BytecodeSF(), Error("playeridの次に'('がありません")
554+ }
555+ }
556+ }
557+ if c.token != "," {
558+ return BytecodeSF(), Error(",がありません")
559+ }
560+ c.token = c.tokenizer(in)
561+ bv1, err = c.expValue(&be1, in)
562+ if err != nil {
563+ return BytecodeSF(), err
564+ }
565+ be1.appendValue(bv1)
566+ out.appendJmp(opc, int32(len(be1)))
567+ out.append(be1...)
568+ return BytecodeSF(), nil
569+ case "(":
570+ c.token = c.tokenizer(in)
571+ if bv, err = c.expBoolOr(&be1, in); err != nil {
572+ return BytecodeSF(), err
573+ }
574+ if err := c.kakkotojiru(in); err != nil {
575+ return BytecodeSF(), err
576+ }
510577 case "-":
511578 if len(*in) > 0 && (((*in)[0] >= '0' && (*in)[0] <= '9') || (*in)[0] == '.') {
512579 c.token += c.tokenizer(in)
@@ -613,6 +680,21 @@ func (c *Compiler) expValue(out *BytecodeExp, in *string) (BytecodeValue,
613680 }
614681 out.append(OC_jsf8, OpCode(len(be)))
615682 out.append(be...)
683+ case "animelemtime":
684+ if c.tokenizer(in) != "(" {
685+ return BytecodeSF(), Error(c.token + "の次に'('がありません")
686+ }
687+ c.token = c.tokenizer(in)
688+ if bv1, err = c.expBoolOr(out, in); err != nil {
689+ return BytecodeSF(), err
690+ }
691+ if err := c.kakkotojiru(in); err != nil {
692+ return BytecodeSF(), err
693+ }
694+ out.appendValue(bv1)
695+ out.append(OC_animelemtime)
696+ case "stateno":
697+ out.append(OC_stateno)
616698 default:
617699 println(c.token)
618700 unimplemented()
@@ -1040,7 +1122,7 @@ func (c *Compiler) fullExpression(in *string, vt ValueType) (BytecodeExp,
10401122 return be, nil
10411123 }
10421124 func (c *Compiler) parseSection(lines []string, i *int,
1043- sctrl func(name, data string) error) (IniSection, error) {
1125+ sctrl func(name, data string) error) (IniSection, bool, error) {
10441126 is := NewIniSection()
10451127 _type, persistent, ignorehitpause := true, true, true
10461128 for ; *i < len(lines); (*i)++ {
@@ -1075,7 +1157,7 @@ func (c *Compiler) parseSection(lines []string, i *int,
10751157 if sys.ignoreMostErrors {
10761158 continue
10771159 }
1078- return nil, Error(name + "が重複しています")
1160+ return nil, false, Error(name + "が重複しています")
10791161 }
10801162 if sctrl != nil {
10811163 switch name {
@@ -1101,14 +1183,14 @@ func (c *Compiler) parseSection(lines []string, i *int,
11011183 }
11021184 }
11031185 if err := sctrl(name, data); err != nil {
1104- return nil, err
1186+ return nil, false, err
11051187 }
11061188 } else {
11071189 is[name] = data
11081190 }
11091191 }
11101192 }
1111- return is, nil
1193+ return is, !ignorehitpause, nil
11121194 }
11131195 func (c *Compiler) stateSec(is IniSection, f func() error) error {
11141196 if err := f(); err != nil {
@@ -1139,8 +1221,8 @@ func (c *Compiler) stateParam(is IniSection, name string,
11391221 }
11401222 return nil
11411223 }
1142-func (c *Compiler) scAdd(sc *StateControllerBase, id byte,
1143- data string, vt ValueType, numArg int, topbe ...BytecodeExp) error {
1224+func (c *Compiler) exprs(data string, vt ValueType,
1225+ numArg int) ([]BytecodeExp, error) {
11441226 bes := []BytecodeExp{}
11451227 for n := 1; n <= numArg; n++ {
11461228 var be BytecodeExp
@@ -1151,13 +1233,21 @@ func (c *Compiler) scAdd(sc *StateControllerBase, id byte,
11511233 be, err = c.fullExpression(&data, vt)
11521234 }
11531235 if err != nil {
1154- return err
1236+ return nil, err
11551237 }
11561238 bes = append(bes, be)
11571239 if c.token != "," {
11581240 break
11591241 }
11601242 }
1243+ return bes, nil
1244+}
1245+func (c *Compiler) scAdd(sc *StateControllerBase, id byte,
1246+ data string, vt ValueType, numArg int, topbe ...BytecodeExp) error {
1247+ bes, err := c.exprs(data, vt, numArg)
1248+ if err != nil {
1249+ return err
1250+ }
11611251 sc.add(id, append(topbe, bes...))
11621252 return nil
11631253 }
@@ -1175,6 +1265,125 @@ func (c *Compiler) paramValue(is IniSection, sc *StateControllerBase,
11751265 }
11761266 return nil
11771267 }
1268+func (c *Compiler) paramPostye(is IniSection, sc *StateControllerBase,
1269+ id byte) error {
1270+ return c.stateParam(is, "postype", func(data string) error {
1271+ if len(data) == 0 {
1272+ return Error("値が指定されていません")
1273+ }
1274+ var pt PosType
1275+ if len(data) >= 2 && strings.ToLower(data[:2]) == "p2" {
1276+ pt = PT_P2
1277+ } else {
1278+ switch strings.ToLower(data)[0] {
1279+ case 'p':
1280+ pt = PT_P1
1281+ case 'f':
1282+ pt = PT_F
1283+ case 'b':
1284+ pt = PT_B
1285+ case 'l':
1286+ pt = PT_L
1287+ case 'r':
1288+ pt = PT_R
1289+ case 'n':
1290+ pt = PT_N
1291+ default:
1292+ return Error(data + "が無効な値です")
1293+ }
1294+ }
1295+ sc.add(id, sc.iToExp(int32(pt)))
1296+ return nil
1297+ })
1298+}
1299+func (c *Compiler) paramTrans(is IniSection, sc *StateControllerBase,
1300+ prefix string, id byte, afterImage bool) error {
1301+ return c.stateParam(is, prefix+"trans", func(data string) error {
1302+ if len(data) == 0 {
1303+ return Error("値が指定されていません")
1304+ }
1305+ tt := TT_default
1306+ data = strings.ToLower(data)
1307+ switch data {
1308+ case "none":
1309+ tt = TT_none
1310+ case "add1":
1311+ tt = TT_add1
1312+ case "sub":
1313+ tt = TT_sub
1314+ default:
1315+ _error := false
1316+ if afterImage {
1317+ if len(data) >= 3 && data[:3] == "add" {
1318+ tt = TT_add
1319+ } else {
1320+ _error = true
1321+ }
1322+ } else {
1323+ switch data {
1324+ case "default":
1325+ tt = TT_default
1326+ case "add":
1327+ tt = TT_add
1328+ case "addalpha", "alpha":
1329+ tt = TT_alpha
1330+ default:
1331+ _error = true
1332+ }
1333+ }
1334+ if _error && (!afterImage || !sys.ignoreMostErrors) {
1335+ return Error(data + "が無効な値です")
1336+ }
1337+ }
1338+ var exp []BytecodeExp
1339+ if !afterImage && (tt == TT_alpha || tt == TT_add1) {
1340+ b := false
1341+ if err := c.stateParam(is, prefix+"alpha", func(data string) error {
1342+ b = true
1343+ bes, err := c.exprs(data, VT_Int, 2)
1344+ if err != nil {
1345+ return err
1346+ }
1347+ exp = make([]BytecodeExp, 3) // 長さ3にする
1348+ exp[0] = bes[0]
1349+ if len(bes) < 2 {
1350+ if tt == TT_add1 {
1351+ exp[1].appendValue(BytecodeInt(128))
1352+ } else {
1353+ exp[1].appendValue(BytecodeInt(255))
1354+ }
1355+ } else {
1356+ exp[1] = bes[1]
1357+ }
1358+ return nil
1359+ }); err != nil {
1360+ return err
1361+ }
1362+ if !b {
1363+ if tt == TT_add1 {
1364+ exp = sc.iToExp(255, 128)
1365+ } else {
1366+ exp = sc.iToExp(-1, 0)
1367+ }
1368+ }
1369+ } else {
1370+ switch tt {
1371+ case TT_none:
1372+ exp = sc.iToExp(255, 0)
1373+ case TT_add:
1374+ exp = sc.iToExp(255, 255)
1375+ case TT_add1:
1376+ exp = sc.iToExp(255, 128)
1377+ case TT_sub:
1378+ exp = sc.iToExp(1, 255)
1379+ default:
1380+ exp = sc.iToExp(-1, 0)
1381+ }
1382+ }
1383+ sc.add(id, exp)
1384+ return nil
1385+ })
1386+}
11781387 func (c *Compiler) stateDef(is IniSection, sbc *StateBytecode) error {
11791388 return c.stateSec(is, func() error {
11801389 sc := newStateControllerBase(c.playerNo)
@@ -1343,19 +1552,19 @@ func (c *Compiler) hitBySub(is IniSection, sc *StateControllerBase) error {
13431552 return nil
13441553 }
13451554 func (c *Compiler) hitBy(is IniSection, sbc *StateBytecode,
1346- sc *StateControllerBase) (StateController, error) {
1555+ sc *StateControllerBase, _ bool) (StateController, error) {
13471556 return hitBy(*sc), c.stateSec(is, func() error {
13481557 return c.hitBySub(is, sc)
13491558 })
13501559 }
13511560 func (c *Compiler) notHitBy(is IniSection, sbc *StateBytecode,
1352- sc *StateControllerBase) (StateController, error) {
1561+ sc *StateControllerBase, _ bool) (StateController, error) {
13531562 return notHitBy(*sc), c.stateSec(is, func() error {
13541563 return c.hitBySub(is, sc)
13551564 })
13561565 }
13571566 func (c *Compiler) assertSpecial(is IniSection, sbc *StateBytecode,
1358- sc *StateControllerBase) (StateController, error) {
1567+ sc *StateControllerBase, _ bool) (StateController, error) {
13591568 return assertSpecial(*sc), c.stateSec(is, func() error {
13601569 foo := func(data string) error {
13611570 switch data {
@@ -1428,7 +1637,7 @@ func (c *Compiler) assertSpecial(is IniSection, sbc *StateBytecode,
14281637 })
14291638 }
14301639 func (c *Compiler) playSnd(is IniSection, sbc *StateBytecode,
1431- sc *StateControllerBase) (StateController, error) {
1640+ sc *StateControllerBase, _ bool) (StateController, error) {
14321641 return playSnd(*sc), c.stateSec(is, func() error {
14331642 f := false
14341643 if err := c.stateParam(is, "value", func(data string) error {
@@ -1505,19 +1714,19 @@ func (c *Compiler) changeStateSub(is IniSection,
15051714 return nil
15061715 }
15071716 func (c *Compiler) changeState(is IniSection, sbc *StateBytecode,
1508- sc *StateControllerBase) (StateController, error) {
1717+ sc *StateControllerBase, _ bool) (StateController, error) {
15091718 return changeState(*sc), c.stateSec(is, func() error {
15101719 return c.changeStateSub(is, sc)
15111720 })
15121721 }
15131722 func (c *Compiler) selfState(is IniSection, sbc *StateBytecode,
1514- sc *StateControllerBase) (StateController, error) {
1723+ sc *StateControllerBase, _ bool) (StateController, error) {
15151724 return selfState(*sc), c.stateSec(is, func() error {
15161725 return c.changeStateSub(is, sc)
15171726 })
15181727 }
15191728 func (c *Compiler) tagIn(is IniSection, sbc *StateBytecode,
1520- sc *StateControllerBase) (StateController, error) {
1729+ sc *StateControllerBase, _ bool) (StateController, error) {
15211730 return tagIn(*sc), c.stateSec(is, func() error {
15221731 if err := c.paramValue(is, sc, "stateno",
15231732 tagIn_stateno, VT_Int, 1, true); err != nil {
@@ -1537,14 +1746,14 @@ func (c *Compiler) tagIn(is IniSection, sbc *StateBytecode,
15371746 })
15381747 }
15391748 func (c *Compiler) tagOut(is IniSection, sbc *StateBytecode,
1540- sc *StateControllerBase) (StateController, error) {
1749+ sc *StateControllerBase, _ bool) (StateController, error) {
15411750 return tagOut(*sc), c.stateSec(is, func() error {
15421751 sc.add(tagOut_, nil)
15431752 return nil
15441753 })
15451754 }
15461755 func (c *Compiler) destroySelf(is IniSection, sbc *StateBytecode,
1547- sc *StateControllerBase) (StateController, error) {
1756+ sc *StateControllerBase, _ bool) (StateController, error) {
15481757 return destroySelf(*sc), c.stateSec(is, func() error {
15491758 if err := c.paramValue(is, sc, "recursive",
15501759 destroySelf_recursive, VT_Bool, 1, false); err != nil {
@@ -1570,19 +1779,19 @@ func (c *Compiler) changeAnimSub(is IniSection,
15701779 return nil
15711780 }
15721781 func (c *Compiler) changeAnim(is IniSection, sbc *StateBytecode,
1573- sc *StateControllerBase) (StateController, error) {
1782+ sc *StateControllerBase, _ bool) (StateController, error) {
15741783 return changeAnim(*sc), c.stateSec(is, func() error {
15751784 return c.changeAnimSub(is, sc)
15761785 })
15771786 }
15781787 func (c *Compiler) changeAnim2(is IniSection, sbc *StateBytecode,
1579- sc *StateControllerBase) (StateController, error) {
1788+ sc *StateControllerBase, _ bool) (StateController, error) {
15801789 return changeAnim2(*sc), c.stateSec(is, func() error {
15811790 return c.changeAnimSub(is, sc)
15821791 })
15831792 }
15841793 func (c *Compiler) helper(is IniSection, sbc *StateBytecode,
1585- sc *StateControllerBase) (StateController, error) {
1794+ sc *StateControllerBase, _ bool) (StateController, error) {
15861795 return helper(*sc), c.stateSec(is, func() error {
15871796 if err := c.stateParam(is, "helpertype", func(data string) error {
15881797 if len(data) == 0 {
@@ -1608,34 +1817,7 @@ func (c *Compiler) helper(is IniSection, sbc *StateBytecode,
16081817 }); err != nil {
16091818 return err
16101819 }
1611- if err := c.stateParam(is, "postype", func(data string) error {
1612- if len(data) == 0 {
1613- return Error("値が指定されていません")
1614- }
1615- var pt PosType
1616- if len(data) >= 2 && strings.ToLower(data[:2]) == "p2" {
1617- pt = PT_P2
1618- } else {
1619- switch strings.ToLower(data)[0] {
1620- case 'p':
1621- pt = PT_P1
1622- case 'f':
1623- pt = PT_F
1624- case 'b':
1625- pt = PT_B
1626- case 'l':
1627- pt = PT_L
1628- case 'r':
1629- pt = PT_R
1630- case 'n':
1631- pt = PT_N
1632- default:
1633- return Error(data + "が無効な値です")
1634- }
1635- }
1636- sc.add(helper_postype, sc.iToExp(int32(pt)))
1637- return nil
1638- }); err != nil {
1820+ if err := c.paramPostye(is, sc, helper_postype); err != nil {
16391821 return err
16401822 }
16411823 if err := c.paramValue(is, sc, "ownpal",
@@ -1718,24 +1900,221 @@ func (c *Compiler) helper(is IniSection, sbc *StateBytecode,
17181900 })
17191901 }
17201902 func (c *Compiler) powerAdd(is IniSection, sbc *StateBytecode,
1721- sc *StateControllerBase) (StateController, error) {
1903+ sc *StateControllerBase, _ bool) (StateController, error) {
17221904 return powerAdd(*sc), c.stateSec(is, func() error {
17231905 return c.paramValue(is, sc, "value", powerAdd_value, VT_Int, 1, true)
17241906 })
17251907 }
17261908 func (c *Compiler) ctrlSet(is IniSection, sbc *StateBytecode,
1727- sc *StateControllerBase) (StateController, error) {
1909+ sc *StateControllerBase, _ bool) (StateController, error) {
17281910 return ctrlSet(*sc), c.stateSec(is, func() error {
17291911 return c.paramValue(is, sc, "value", ctrlSet_value, VT_Bool, 1, true)
17301912 })
17311913 }
1914+func (c *Compiler) explodSub(is IniSection,
1915+ sc *StateControllerBase) error {
1916+ if err := c.paramValue(is, sc, "remappal",
1917+ explod_remappal, VT_Int, 2, false); err != nil {
1918+ return err
1919+ }
1920+ if err := c.paramValue(is, sc, "id",
1921+ explod_id, VT_Int, 1, false); err != nil {
1922+ return err
1923+ }
1924+ if err := c.paramPostye(is, sc, explod_postype); err != nil {
1925+ return err
1926+ }
1927+ if err := c.paramValue(is, sc, "facing",
1928+ explod_facing, VT_Int, 1, false); err != nil {
1929+ return err
1930+ }
1931+ if err := c.paramValue(is, sc, "vfacing",
1932+ explod_vfacing, VT_Int, 1, false); err != nil {
1933+ return err
1934+ }
1935+ if err := c.paramValue(is, sc, "pos",
1936+ explod_pos, VT_Float, 2, false); err != nil {
1937+ return err
1938+ }
1939+ if err := c.paramValue(is, sc, "random",
1940+ explod_random, VT_Float, 2, false); err != nil {
1941+ return err
1942+ }
1943+ f := false
1944+ if err := c.stateParam(is, "vel", func(data string) error {
1945+ f = true
1946+ return c.scAdd(sc, explod_velocity, data, VT_Float, 2)
1947+ }); err != nil {
1948+ return err
1949+ }
1950+ if !f {
1951+ if err := c.paramValue(is, sc, "velocity",
1952+ explod_velocity, VT_Float, 2, false); err != nil {
1953+ return err
1954+ }
1955+ }
1956+ if err := c.paramValue(is, sc, "accel",
1957+ explod_accel, VT_Float, 2, false); err != nil {
1958+ return err
1959+ }
1960+ if err := c.paramValue(is, sc, "scale",
1961+ explod_scale, VT_Float, 2, false); err != nil {
1962+ return err
1963+ }
1964+ if err := c.paramValue(is, sc, "bindtime",
1965+ explod_bindtime, VT_Int, 1, false); err != nil {
1966+ return err
1967+ }
1968+ if err := c.paramValue(is, sc, "removetime",
1969+ explod_removetime, VT_Int, 1, false); err != nil {
1970+ return err
1971+ }
1972+ if err := c.paramValue(is, sc, "supermove",
1973+ explod_supermove, VT_Bool, 1, false); err != nil {
1974+ return err
1975+ }
1976+ if err := c.paramValue(is, sc, "supermovetime",
1977+ explod_supermovetime, VT_Int, 1, false); err != nil {
1978+ return err
1979+ }
1980+ if err := c.paramValue(is, sc, "pausemovetime",
1981+ explod_pausemovetime, VT_Int, 1, false); err != nil {
1982+ return err
1983+ }
1984+ if err := c.paramValue(is, sc, "sprpriority",
1985+ explod_sprpriority, VT_Int, 1, false); err != nil {
1986+ return err
1987+ }
1988+ if err := c.paramValue(is, sc, "ontop",
1989+ explod_ontop, VT_Bool, 1, false); err != nil {
1990+ return err
1991+ }
1992+ if err := c.paramValue(is, sc, "shadow",
1993+ explod_shadow, VT_Int, 3, false); err != nil {
1994+ return err
1995+ }
1996+ if err := c.paramValue(is, sc, "removeongethit",
1997+ explod_removeongethit, VT_Bool, 1, false); err != nil {
1998+ return err
1999+ }
2000+ if err := c.paramTrans(is, sc, "", explod_trans, false); err != nil {
2001+ return err
2002+ }
2003+ return nil
2004+}
2005+func (c *Compiler) explod(is IniSection, sbc *StateBytecode,
2006+ sc *StateControllerBase, ihp bool) (StateController, error) {
2007+ return explod(*sc), c.stateSec(is, func() error {
2008+ if err := c.paramValue(is, sc, "ownpal",
2009+ explod_ownpal, VT_Bool, 1, false); err != nil {
2010+ return err
2011+ }
2012+ if err := c.explodSub(is, sc); err != nil {
2013+ return err
2014+ }
2015+ if err := c.stateParam(is, "anim", func(data string) error {
2016+ fflg := false
2017+ if len(data) > 0 && strings.ToLower(data)[0] == 'f' {
2018+ fflg = true
2019+ data = data[1:]
2020+ }
2021+ return c.scAdd(sc, explod_anim, data, VT_Int, 1,
2022+ sc.iToExp(Btoi(fflg))...)
2023+ }); err != nil {
2024+ return err
2025+ }
2026+ if err := c.paramValue(is, sc, "angle",
2027+ explod_angle, VT_Float, 1, false); err != nil {
2028+ return err
2029+ }
2030+ if err := c.paramValue(is, sc, "yangle",
2031+ explod_yangle, VT_Float, 1, false); err != nil {
2032+ return err
2033+ }
2034+ if err := c.paramValue(is, sc, "xangle",
2035+ explod_xangle, VT_Float, 1, false); err != nil {
2036+ return err
2037+ }
2038+ if ihp && !sc.ignorehitpause {
2039+ sc.add(explod_ignorehitpause, sc.iToExp(0))
2040+ }
2041+ return nil
2042+ })
2043+}
2044+func (c *Compiler) modifyExplod(is IniSection, sbc *StateBytecode,
2045+ sc *StateControllerBase, _ bool) (StateController, error) {
2046+ return modifyExplod(*sc), c.stateSec(is, func() error {
2047+ if err := c.explodSub(is, sc); err != nil {
2048+ return err
2049+ }
2050+ if err := c.paramValue(is, sc, "angle",
2051+ explod_angle, VT_Float, 1, false); err != nil {
2052+ return err
2053+ }
2054+ if err := c.paramValue(is, sc, "yangle",
2055+ explod_yangle, VT_Float, 1, false); err != nil {
2056+ return err
2057+ }
2058+ if err := c.paramValue(is, sc, "xangle",
2059+ explod_xangle, VT_Float, 1, false); err != nil {
2060+ return err
2061+ }
2062+ return nil
2063+ })
2064+}
2065+func (c *Compiler) posSetSub(is IniSection,
2066+ sc *StateControllerBase) error {
2067+ if err := c.paramValue(is, sc, "x",
2068+ posSet_x, VT_Float, 1, false); err != nil {
2069+ return err
2070+ }
2071+ if err := c.paramValue(is, sc, "y",
2072+ posSet_y, VT_Float, 1, false); err != nil {
2073+ return err
2074+ }
2075+ if err := c.paramValue(is, sc, "z",
2076+ posSet_z, VT_Float, 1, false); err != nil {
2077+ return err
2078+ }
2079+ return nil
2080+}
2081+func (c *Compiler) posSet(is IniSection, sbc *StateBytecode,
2082+ sc *StateControllerBase, _ bool) (StateController, error) {
2083+ return posSet(*sc), c.stateSec(is, func() error {
2084+ return c.posSetSub(is, sc)
2085+ })
2086+}
2087+func (c *Compiler) posAdd(is IniSection, sbc *StateBytecode,
2088+ sc *StateControllerBase, _ bool) (StateController, error) {
2089+ return posAdd(*sc), c.stateSec(is, func() error {
2090+ return c.posSetSub(is, sc)
2091+ })
2092+}
2093+func (c *Compiler) velSet(is IniSection, sbc *StateBytecode,
2094+ sc *StateControllerBase, _ bool) (StateController, error) {
2095+ return velSet(*sc), c.stateSec(is, func() error {
2096+ return c.posSetSub(is, sc)
2097+ })
2098+}
2099+func (c *Compiler) velAdd(is IniSection, sbc *StateBytecode,
2100+ sc *StateControllerBase, _ bool) (StateController, error) {
2101+ return velAdd(*sc), c.stateSec(is, func() error {
2102+ return c.posSetSub(is, sc)
2103+ })
2104+}
2105+func (c *Compiler) velMul(is IniSection, sbc *StateBytecode,
2106+ sc *StateControllerBase, _ bool) (StateController, error) {
2107+ return velMul(*sc), c.stateSec(is, func() error {
2108+ return c.posSetSub(is, sc)
2109+ })
2110+}
17322111 func (c *Compiler) hitDefSub(is IniSection,
17332112 sc *StateControllerBase) error {
17342113 unimplemented()
17352114 return nil
17362115 }
17372116 func (c *Compiler) hitDef(is IniSection, sbc *StateBytecode,
1738- sc *StateControllerBase) (StateController, error) {
2117+ sc *StateControllerBase, _ bool) (StateController, error) {
17392118 return hitDef(*sc), c.stateSec(is, func() error {
17402119 return c.hitDefSub(is, sc)
17412120 })
@@ -1770,7 +2149,7 @@ func (c *Compiler) stateCompile(bc *Bytecode, filename, def string) error {
17702149 }
17712150 existInThisFile[n] = true
17722151 i++
1773- is, err := c.parseSection(lines, &i, nil)
2152+ is, _, err := c.parseSection(lines, &i, nil)
17742153 if err != nil {
17752154 return errmes(err)
17762155 }
@@ -1789,12 +2168,12 @@ func (c *Compiler) stateCompile(bc *Bytecode, filename, def string) error {
17892168 i++
17902169 sc := newStateControllerBase(c.playerNo)
17912170 var scf func(is IniSection, sbc *StateBytecode,
1792- sc *StateControllerBase) (StateController, error)
2171+ sc *StateControllerBase, ihp bool) (StateController, error)
17932172 var triggerall []BytecodeExp
17942173 allUtikiri := false
17952174 var trigger [][]BytecodeExp
17962175 var trexist []int8
1797- is, err := c.parseSection(lines, &i, func(name, data string) error {
2176+ is, ihp, err := c.parseSection(lines, &i, func(name, data string) error {
17982177 switch name {
17992178 case "type":
18002179 switch data {
@@ -1826,6 +2205,20 @@ func (c *Compiler) stateCompile(bc *Bytecode, filename, def string) error {
18262205 scf = c.powerAdd
18272206 case "ctrlset":
18282207 scf = c.ctrlSet
2208+ case "explod":
2209+ scf = c.explod
2210+ case "modifyexplod":
2211+ scf = c.modifyExplod
2212+ case "posset":
2213+ scf = c.posSet
2214+ case "posadd":
2215+ scf = c.posAdd
2216+ case "velset":
2217+ scf = c.velSet
2218+ case "veladd":
2219+ scf = c.velAdd
2220+ case "velmul":
2221+ scf = c.velMul
18292222 case "hitdef":
18302223 scf = c.hitDef
18312224 default:
@@ -1961,7 +2354,7 @@ func (c *Compiler) stateCompile(bc *Bytecode, filename, def string) error {
19612354 if len(texp) > 0 {
19622355 sc.add(SCID_trigger, sc.beToExp(texp))
19632356 }
1964- sctrl, err := scf(is, sbc, sc)
2357+ sctrl, err := scf(is, sbc, sc, ihp)
19652358 if err != nil {
19662359 return errmes(err)
19672360 }
--- a/src/image.go
+++ b/src/image.go
@@ -13,6 +13,17 @@ import (
1313 "unsafe"
1414 )
1515
16+type TransType int32
17+
18+const (
19+ TT_default TransType = iota
20+ TT_none
21+ TT_add
22+ TT_alpha
23+ TT_add1
24+ TT_sub
25+)
26+
1627 type Texture uint32
1728
1829 func textureFinalizer(t *Texture) {