Go で書き直した Ikemen
Revision | bf71913ba3881dad1e6a10babde2ba0f12084d88 (tree) |
---|---|
Zeit | 2016-12-21 01:45:39 |
Autor | SUEHIRO <supersuehiro@user...> |
Commiter | SUEHIRO |
旧式トリガーのところを書くのが大変だった
@@ -5,7 +5,7 @@ import ( | ||
5 | 5 | "unsafe" |
6 | 6 | ) |
7 | 7 | |
8 | -type StateType uint32 | |
8 | +type StateType int32 | |
9 | 9 | |
10 | 10 | const ( |
11 | 11 | ST_S StateType = 1 << iota |
@@ -19,7 +19,7 @@ const ( | ||
19 | 19 | ST_P = ST_U |
20 | 20 | ) |
21 | 21 | |
22 | -type AttackType uint32 | |
22 | +type AttackType int32 | |
23 | 23 | |
24 | 24 | const ( |
25 | 25 | AT_NA AttackType = 1 << (iota + 6) |
@@ -33,7 +33,7 @@ const ( | ||
33 | 33 | AT_HP |
34 | 34 | ) |
35 | 35 | |
36 | -type MoveType uint32 | |
36 | +type MoveType int32 | |
37 | 37 | |
38 | 38 | const ( |
39 | 39 | MT_I MoveType = 1 << (iota + 15) |
@@ -67,6 +67,7 @@ const ( | ||
67 | 67 | OC_dup |
68 | 68 | OC_swap |
69 | 69 | OC_run |
70 | + OC_jsf8 | |
70 | 71 | OC_jmp8 |
71 | 72 | OC_jz8 |
72 | 73 | OC_jnz8 |
@@ -187,7 +188,6 @@ const ( | ||
187 | 188 | OC_hitfall |
188 | 189 | OC_hitvel_x |
189 | 190 | OC_hitvel_y |
190 | - OC_roundno | |
191 | 191 | OC_roundsexisted |
192 | 192 | OC_parent |
193 | 193 | OC_root |
@@ -361,8 +361,10 @@ const ( | ||
361 | 361 | OC_ex_drawgame |
362 | 362 | OC_ex_matchover |
363 | 363 | OC_ex_matchno |
364 | + OC_ex_roundno | |
364 | 365 | OC_ex_ishometeam |
365 | 366 | OC_ex_tickspersecond |
367 | + OC_ex_timemod | |
366 | 368 | ) |
367 | 369 | |
368 | 370 | type StringPool struct { |
@@ -636,6 +638,16 @@ func (be BytecodeExp) run(c *Char, scpn int) BytecodeValue { | ||
636 | 638 | orgc := c |
637 | 639 | for i := 1; i <= len(be); i++ { |
638 | 640 | switch be[i-1] { |
641 | + case OC_jsf8: | |
642 | + if sys.bcStack.Top().IsSF() { | |
643 | + if be[i] == 0 { | |
644 | + i = len(be) | |
645 | + } else { | |
646 | + i += int(uint8(be[i])) + 1 | |
647 | + } | |
648 | + } else { | |
649 | + i++ | |
650 | + } | |
639 | 651 | case OC_jz8, OC_jnz8: |
640 | 652 | if sys.bcStack.Top().ToB() == (be[i-1] == OC_jz8) { |
641 | 653 | i++ |
@@ -749,10 +761,16 @@ func (be BytecodeExp) run(c *Char, scpn int) BytecodeValue { | ||
749 | 761 | sys.bcStack.Push(BytecodeBool(c.alive())) |
750 | 762 | case OC_random: |
751 | 763 | sys.bcStack.Push(BytecodeInt(Rand(0, 999))) |
764 | + case OC_roundstate: | |
765 | + sys.bcStack.Push(BytecodeInt(c.roundState())) | |
752 | 766 | case OC_anim: |
753 | 767 | sys.bcStack.Push(BytecodeInt(c.animNo())) |
754 | 768 | case OC_animtime: |
755 | 769 | sys.bcStack.Push(BytecodeInt(c.animTime())) |
770 | + case OC_animelemtime: | |
771 | + sys.bcStack.Push(BytecodeInt(c.animElemTime(sys.bcStack.Pop().ToI()))) | |
772 | + case OC_ex_: | |
773 | + be.run_ex(c, scpn, &i) | |
756 | 774 | default: |
757 | 775 | unimplemented() |
758 | 776 | } |
@@ -760,6 +778,13 @@ func (be BytecodeExp) run(c *Char, scpn int) BytecodeValue { | ||
760 | 778 | } |
761 | 779 | return sys.bcStack.Pop() |
762 | 780 | } |
781 | +func (be BytecodeExp) run_ex(c *Char, scpn int, i *int) { | |
782 | + (*i)++ | |
783 | + switch be[*i-1] { | |
784 | + case OC_ex_matchover: | |
785 | + sys.bcStack.Push(BytecodeBool(sys.matchOver())) | |
786 | + } | |
787 | +} | |
763 | 788 | func (be BytecodeExp) evalF(c *Char, scpn int) float32 { |
764 | 789 | return be.run(c, scpn).ToF() |
765 | 790 | } |
@@ -1316,6 +1341,23 @@ func (sc ctrlSet) Run(c *Char, ps *int32) bool { | ||
1316 | 1341 | return false |
1317 | 1342 | } |
1318 | 1343 | |
1344 | +type hitDef StateControllerBase | |
1345 | + | |
1346 | +const ( | |
1347 | + hitDef_ byte = iota | |
1348 | +) | |
1349 | + | |
1350 | +func (sc hitDef) Run(c *Char, ps *int32) bool { | |
1351 | + StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool { | |
1352 | + switch id { | |
1353 | + case hitDef_: | |
1354 | + } | |
1355 | + unimplemented() | |
1356 | + return true | |
1357 | + }) | |
1358 | + return false | |
1359 | +} | |
1360 | + | |
1319 | 1361 | type StateBytecode struct { |
1320 | 1362 | stateType StateType |
1321 | 1363 | moveType MoveType |
@@ -296,26 +296,26 @@ func (cm *CharMovement) init() { | ||
296 | 296 | cm.down.friction_threshold = 0.05 |
297 | 297 | } |
298 | 298 | |
299 | -type Reaction1 int32 | |
299 | +type Reaction int32 | |
300 | 300 | |
301 | 301 | const ( |
302 | - AT_Light Reaction1 = iota | |
303 | - AT_Medium | |
304 | - AT_Hard | |
305 | - AT_Back | |
306 | - AT_Up | |
307 | - AT_Diagup | |
308 | - AT_Unknown | |
302 | + RA_Light Reaction = iota | |
303 | + RA_Medium | |
304 | + RA_Hard | |
305 | + RA_Back | |
306 | + RA_Up | |
307 | + RA_Diagup | |
308 | + RA_Unknown | |
309 | 309 | ) |
310 | 310 | |
311 | -type Reaction2 int32 | |
311 | +type HitType int32 | |
312 | 312 | |
313 | 313 | const ( |
314 | - R2_None Reaction2 = iota | |
315 | - R2_High | |
316 | - R2_Low | |
317 | - R2_Trip | |
318 | - R2_Unknown | |
314 | + HT_None HitType = iota | |
315 | + HT_High | |
316 | + HT_Low | |
317 | + HT_Trip | |
318 | + HT_Unknown | |
319 | 319 | ) |
320 | 320 | |
321 | 321 | type AiuchiType int32 |
@@ -327,7 +327,7 @@ const ( | ||
327 | 327 | ) |
328 | 328 | |
329 | 329 | type Fall struct { |
330 | - animtype Reaction1 | |
330 | + animtype Reaction | |
331 | 331 | xvelocity float32 |
332 | 332 | yvelocity float32 |
333 | 333 | recover int32 |
@@ -341,23 +341,23 @@ type Fall struct { | ||
341 | 341 | } |
342 | 342 | |
343 | 343 | func (f *Fall) clear() { |
344 | - *f = Fall{animtype: AT_Unknown, xvelocity: float32(math.NaN()), | |
344 | + *f = Fall{animtype: RA_Unknown, xvelocity: float32(math.NaN()), | |
345 | 345 | yvelocity: -4.5} |
346 | 346 | } |
347 | 347 | func (f *Fall) setDefault() { |
348 | - *f = Fall{animtype: AT_Unknown, xvelocity: float32(math.NaN()), | |
348 | + *f = Fall{animtype: RA_Unknown, xvelocity: float32(math.NaN()), | |
349 | 349 | yvelocity: -4.5, recover: 1, recovertime: 4, kill: 1, envshake_freq: 60, |
350 | 350 | envshake_ampl: -4, envshake_phase: float32(math.NaN())} |
351 | 351 | } |
352 | 352 | |
353 | 353 | type HitDef struct { |
354 | - attr uint32 | |
355 | - reversal_attr uint32 | |
356 | - hitflag uint32 | |
357 | - guardflag uint32 | |
354 | + attr int32 | |
355 | + reversal_attr int32 | |
356 | + hitflag int32 | |
357 | + guardflag int32 | |
358 | 358 | affectteam int32 |
359 | - animtype Reaction1 | |
360 | - air_animtype Reaction1 | |
359 | + animtype Reaction | |
360 | + air_animtype Reaction | |
361 | 361 | priority int32 |
362 | 362 | bothhittype AiuchiType |
363 | 363 | hitdamage int32 |
@@ -371,8 +371,8 @@ type HitDef struct { | ||
371 | 371 | sparkxy [2]float32 |
372 | 372 | hitsound [2]int32 |
373 | 373 | guardsound [2]int32 |
374 | - ground_type Reaction2 | |
375 | - air_type Reaction2 | |
374 | + ground_type HitType | |
375 | + air_type HitType | |
376 | 376 | ground_slidetime int32 |
377 | 377 | guard_slidetime int32 |
378 | 378 | ground_hittime int32 |
@@ -432,19 +432,19 @@ type HitDef struct { | ||
432 | 432 | snap [2]float32 |
433 | 433 | snapt int32 |
434 | 434 | fall Fall |
435 | + playerNo int | |
435 | 436 | kill bool |
436 | 437 | guard_kill bool |
437 | 438 | forcenofall bool |
438 | 439 | lhit bool |
439 | - playerNo int | |
440 | 440 | } |
441 | 441 | |
442 | 442 | func (hd *HitDef) clear() { |
443 | - *hd = HitDef{hitflag: uint32(ST_S | ST_C | ST_A | ST_F), affectteam: 1, | |
444 | - animtype: AT_Light, air_animtype: AT_Unknown, priority: 4, | |
443 | + *hd = HitDef{hitflag: int32(ST_S | ST_C | ST_A | ST_F), affectteam: 1, | |
444 | + animtype: RA_Light, air_animtype: RA_Unknown, priority: 4, | |
445 | 445 | bothhittype: AT_Hit, sparkno: IErr, guard_sparkno: IErr, |
446 | 446 | hitsound: [2]int32{IErr, -1}, guardsound: [2]int32{IErr, -1}, |
447 | - ground_type: R2_High, air_type: R2_Unknown, air_hittime: 20, | |
447 | + ground_type: HT_High, air_type: HT_Unknown, air_hittime: 20, | |
448 | 448 | yaccel: float32(math.NaN()), guard_velocity: float32(math.NaN()), |
449 | 449 | airguard_velocity: [2]float32{float32(math.NaN()), |
450 | 450 | float32(math.NaN())}, |
@@ -466,11 +466,249 @@ func (hd *HitDef) clear() { | ||
466 | 466 | hd.fall.setDefault() |
467 | 467 | } |
468 | 468 | func (hd *HitDef) invalidate(stateType StateType) { |
469 | - hd.attr = hd.attr&^(uint32(AT_NA)-1) | uint32(stateType) | 0x80000000 | |
470 | - hd.reversal_attr |= 0x80000000 | |
469 | + hd.attr = hd.attr&^(int32(AT_NA)-1) | int32(stateType) | -1<<31 | |
470 | + hd.reversal_attr |= -1 << 31 | |
471 | 471 | hd.lhit = false |
472 | 472 | } |
473 | 473 | |
474 | +type GetHitVar struct { | |
475 | + hitBy [][2]int32 | |
476 | + hit1 [2]int32 | |
477 | + hit2 [2]int32 | |
478 | + attr int32 | |
479 | + _type HitType | |
480 | + airanimtype Reaction | |
481 | + groundanimtype Reaction | |
482 | + airtype HitType | |
483 | + groundtype HitType | |
484 | + damage int32 | |
485 | + hitcount int32 | |
486 | + fallcount int32 | |
487 | + hitshaketime int32 | |
488 | + hittime int32 | |
489 | + slidetime int32 | |
490 | + ctrltime int32 | |
491 | + xvel float32 | |
492 | + yvel float32 | |
493 | + yaccel float32 | |
494 | + hitid int32 | |
495 | + xoff float32 | |
496 | + yoff float32 | |
497 | + fall Fall | |
498 | + playerNo int | |
499 | + fallf bool | |
500 | + guarded bool | |
501 | + p2getp1state bool | |
502 | + forcestand bool | |
503 | +} | |
504 | + | |
505 | +func (ghv *GetHitVar) clear() { | |
506 | + *ghv = GetHitVar{_type: -1, hittime: -1, yaccel: float32(math.NaN()), | |
507 | + xoff: ghv.xoff, yoff: ghv.yoff, hitid: -1, playerNo: -1} | |
508 | + ghv.fall.clear() | |
509 | +} | |
510 | +func (ghv *GetHitVar) clearOff() { | |
511 | + ghv.xoff, ghv.yoff = 0, 0 | |
512 | +} | |
513 | +func (ghv GetHitVar) getYaccel() float32 { | |
514 | + if math.IsNaN(float64(ghv.yaccel)) { | |
515 | + return 0.35 | |
516 | + } | |
517 | + return ghv.yaccel | |
518 | +} | |
519 | +func (ghv GetHitVar) idMatch(id int32) bool { | |
520 | + for _, v := range ghv.hitBy { | |
521 | + if v[0] == id { | |
522 | + return true | |
523 | + } | |
524 | + } | |
525 | + return false | |
526 | +} | |
527 | +func (ghv GetHitVar) getJuggle(id, defaultJuggle int32) int32 { | |
528 | + for _, v := range ghv.hitBy { | |
529 | + if v[0] == id { | |
530 | + return v[1] | |
531 | + } | |
532 | + } | |
533 | + return defaultJuggle | |
534 | +} | |
535 | +func (ghv *GetHitVar) dropId(id int32) { | |
536 | + for i, v := range ghv.hitBy { | |
537 | + if v[0] == id { | |
538 | + ghv.hitBy = append(ghv.hitBy[:i], ghv.hitBy[i+1:]...) | |
539 | + break | |
540 | + } | |
541 | + } | |
542 | +} | |
543 | +func (ghv *GetHitVar) addId(id, juggle int32) { | |
544 | + ghv.dropId(id) | |
545 | + ghv.hitBy = append(ghv.hitBy, [2]int32{id, juggle}) | |
546 | +} | |
547 | + | |
548 | +type HitOverride struct { | |
549 | + attr int32 | |
550 | + stateno int32 | |
551 | + time int32 | |
552 | + playerNo int | |
553 | + forceair bool | |
554 | +} | |
555 | + | |
556 | +func (ho *HitOverride) clear() { | |
557 | + *ho = HitOverride{stateno: -1, playerNo: -1} | |
558 | +} | |
559 | + | |
560 | +type aimgImage struct { | |
561 | + anim Animation | |
562 | + pos, scl, ascl [2]float32 | |
563 | + angle float32 | |
564 | + angleset, old bool | |
565 | +} | |
566 | + | |
567 | +type AfterImage struct { | |
568 | + time int32 | |
569 | + length int32 | |
570 | + postbright [3]int32 | |
571 | + add [3]int32 | |
572 | + mul [3]float32 | |
573 | + timegap int32 | |
574 | + framegap int32 | |
575 | + alpha [2]int32 | |
576 | + palfx []PalFX | |
577 | + imgs [64]aimgImage | |
578 | + imgidx int | |
579 | + restgap int32 | |
580 | + reccount int32 | |
581 | +} | |
582 | + | |
583 | +func newAfterImage() *AfterImage { | |
584 | + ai := &AfterImage{palfx: make([]PalFX, sys.afterImageMax)} | |
585 | + for i := range ai.palfx { | |
586 | + ai.palfx[i].enable, ai.palfx[i].negType = true, true | |
587 | + } | |
588 | + ai.clear() | |
589 | + ai.timegap = 0 | |
590 | + return ai | |
591 | +} | |
592 | +func (ai *AfterImage) clear() { | |
593 | + ai.time = 0 | |
594 | + ai.length = 20 | |
595 | + if len(ai.palfx) > 0 { | |
596 | + ai.palfx[0].eColor = 1 | |
597 | + ai.palfx[0].eInvertall = false | |
598 | + ai.palfx[0].eAdd = [3]int32{30, 30, 30} | |
599 | + ai.palfx[0].eMul = [3]int32{120, 120, 220} | |
600 | + } | |
601 | + ai.postbright = [3]int32{0, 0, 0} | |
602 | + ai.add = [3]int32{10, 10, 25} | |
603 | + ai.mul = [3]float32{0.65, 0.65, 0.75} | |
604 | + ai.timegap = 1 | |
605 | + ai.framegap = 6 | |
606 | + ai.alpha = [2]int32{-1, 0} | |
607 | + ai.imgidx = 0 | |
608 | + ai.restgap = 0 | |
609 | + ai.reccount = 0 | |
610 | +} | |
611 | +func (ai *AfterImage) setPalColor(color int32) { | |
612 | + if len(ai.palfx) > 0 { | |
613 | + ai.palfx[0].eColor = float32(Max(0, Min(256, color))) / 256 | |
614 | + } | |
615 | +} | |
616 | +func (ai *AfterImage) setPalInvertall(invertall bool) { | |
617 | + if len(ai.palfx) > 0 { | |
618 | + ai.palfx[0].eInvertall = invertall | |
619 | + } | |
620 | +} | |
621 | +func (ai *AfterImage) setPalBrightR(addr int32) { | |
622 | + if len(ai.palfx) > 0 { | |
623 | + ai.palfx[0].eAdd[0] = addr | |
624 | + } | |
625 | +} | |
626 | +func (ai *AfterImage) setPalBrightG(addg int32) { | |
627 | + if len(ai.palfx) > 0 { | |
628 | + ai.palfx[0].eAdd[1] = addg | |
629 | + } | |
630 | +} | |
631 | +func (ai *AfterImage) setPalBrightB(addb int32) { | |
632 | + if len(ai.palfx) > 0 { | |
633 | + ai.palfx[0].eAdd[2] = addb | |
634 | + } | |
635 | +} | |
636 | +func (ai *AfterImage) setPalContrastR(mulr int32) { | |
637 | + if len(ai.palfx) > 0 { | |
638 | + ai.palfx[0].eMul[0] = mulr | |
639 | + } | |
640 | +} | |
641 | +func (ai *AfterImage) setPalContrastG(mulg int32) { | |
642 | + if len(ai.palfx) > 0 { | |
643 | + ai.palfx[0].eMul[1] = mulg | |
644 | + } | |
645 | +} | |
646 | +func (ai *AfterImage) setPalContrastB(mulb int32) { | |
647 | + if len(ai.palfx) > 0 { | |
648 | + ai.palfx[0].eMul[2] = mulb | |
649 | + } | |
650 | +} | |
651 | +func (ai *AfterImage) setupPalFX() { | |
652 | + pb := ai.postbright | |
653 | + for i := 1; i < len(ai.palfx); i++ { | |
654 | + ai.palfx[i].eColor = ai.palfx[i-1].eColor | |
655 | + ai.palfx[i].eInvertall = ai.palfx[i-1].eInvertall | |
656 | + ai.palfx[i].eAdd[0] = ai.palfx[i-1].eAdd[0] + pb[0] | |
657 | + ai.palfx[i].eAdd[1] = ai.palfx[i-1].eAdd[1] + pb[1] | |
658 | + ai.palfx[i].eAdd[2] = ai.palfx[i-1].eAdd[2] + pb[2] | |
659 | + pb = [3]int32{0, 0, 0} | |
660 | + ai.palfx[i].eMul[0] = int32(float32(ai.palfx[i-1].eMul[0]) * ai.mul[0]) | |
661 | + ai.palfx[i].eMul[1] = int32(float32(ai.palfx[i-1].eMul[1]) * ai.mul[1]) | |
662 | + ai.palfx[i].eMul[2] = int32(float32(ai.palfx[i-1].eMul[2]) * ai.mul[2]) | |
663 | + } | |
664 | +} | |
665 | + | |
666 | +type Projectile struct { | |
667 | + hitdef HitDef | |
668 | + id int32 | |
669 | + anim int32 | |
670 | + hitanim int32 | |
671 | + remanim int32 | |
672 | + cancelanim int32 | |
673 | + scale [2]float32 | |
674 | + clsnscale [2]float32 | |
675 | + remove bool | |
676 | + removetime int32 | |
677 | + velocity [2]float32 | |
678 | + remvelocity [2]float32 | |
679 | + accel [2]float32 | |
680 | + velmul [2]float32 | |
681 | + hits int32 | |
682 | + misstime int32 | |
683 | + priority int32 | |
684 | + prioritypoint int32 | |
685 | + sprpriority int32 | |
686 | + edgebound int32 | |
687 | + stagebound int32 | |
688 | + heightbound [2]int32 | |
689 | + pos [2]float32 | |
690 | + facing int32 | |
691 | + shadow [3]int32 | |
692 | + supermovetime int32 | |
693 | + pausemovetime int32 | |
694 | + ani *Animation | |
695 | + timemiss int32 | |
696 | + hitpause int32 | |
697 | + oldPos [2]float32 | |
698 | + newPos [2]float32 | |
699 | + aimg AfterImage | |
700 | + palfx *PalFX | |
701 | +} | |
702 | + | |
703 | +func (p *Projectile) clear() { | |
704 | + *p = Projectile{id: IErr, hitanim: -1, remanim: IErr, cancelanim: IErr, | |
705 | + scale: [2]float32{1, 1}, clsnscale: [2]float32{1, 1}, remove: true, | |
706 | + removetime: -1, velmul: [2]float32{1, 1}, hits: 1, priority: 1, | |
707 | + prioritypoint: 1, sprpriority: 3, edgebound: 40, stagebound: 40, | |
708 | + heightbound: [2]int32{-240, 1}, facing: 1} | |
709 | + p.hitdef.clear() | |
710 | +} | |
711 | + | |
474 | 712 | type CharGlobalInfo struct { |
475 | 713 | def string |
476 | 714 | displayname string |
@@ -851,6 +1089,10 @@ func (c *Char) helperInit(h *Char, st int32, pt PosType, x, y float32, | ||
851 | 1089 | facing int32, ownpal bool) { |
852 | 1090 | unimplemented() |
853 | 1091 | } |
1092 | +func (c *Char) roundState() int32 { | |
1093 | + unimplemented() | |
1094 | + return 0 | |
1095 | +} | |
854 | 1096 | func (c *Char) animNo() int32 { |
855 | 1097 | unimplemented() |
856 | 1098 | return 0 |
@@ -859,3 +1101,7 @@ func (c *Char) animTime() int32 { | ||
859 | 1101 | unimplemented() |
860 | 1102 | return 0 |
861 | 1103 | } |
1104 | +func (c *Char) animElemTime(e int32) int32 { | |
1105 | + unimplemented() | |
1106 | + return 0 | |
1107 | +} |
@@ -79,7 +79,7 @@ func IsFinite(f float32) bool { | ||
79 | 79 | func Atoi(str string) int32 { |
80 | 80 | n := int32(0) |
81 | 81 | str = strings.TrimSpace(str) |
82 | - if len(str) >= 0 { | |
82 | + if len(str) > 0 { | |
83 | 83 | var a string |
84 | 84 | if str[0] == '-' || str[0] == '+' { |
85 | 85 | a = str[1:] |
@@ -196,6 +196,25 @@ func (c *Compiler) operator(in *string) error { | ||
196 | 196 | } |
197 | 197 | return nil |
198 | 198 | } |
199 | +func (c *Compiler) integer2(in *string) (int32, error) { | |
200 | + istr := c.token | |
201 | + c.token = c.tokenizer(in) | |
202 | + minus := istr == "-" | |
203 | + if minus { | |
204 | + istr = c.token | |
205 | + c.token = c.tokenizer(in) | |
206 | + } | |
207 | + for _, c := range istr { | |
208 | + if c < '0' || c > '9' { | |
209 | + return 0, Error(istr + "が整数でありません") | |
210 | + } | |
211 | + } | |
212 | + i := Atoi(istr) | |
213 | + if minus { | |
214 | + i *= -1 | |
215 | + } | |
216 | + return i, nil | |
217 | +} | |
199 | 218 | func (c *Compiler) number(token string) BytecodeValue { |
200 | 219 | f, err := strconv.ParseFloat(token, 64) |
201 | 220 | if err != nil && f == 0 { |
@@ -312,6 +331,165 @@ func (c *Compiler) kakkotojiru(in *string) error { | ||
312 | 331 | } |
313 | 332 | return nil |
314 | 333 | } |
334 | +func (c *Compiler) kyuushiki(in *string) (not bool, err error) { | |
335 | + for { | |
336 | + if c.token == "!=" { | |
337 | + not = true | |
338 | + break | |
339 | + } else if len(c.token) > 0 { | |
340 | + if c.token[len(c.token)-1] == '=' { | |
341 | + break | |
342 | + } | |
343 | + } else { | |
344 | + return false, Error("'='か'!='がありません") | |
345 | + } | |
346 | + c.token = c.tokenizer(in) | |
347 | + } | |
348 | + c.token = c.tokenizer(in) | |
349 | + return | |
350 | +} | |
351 | +func (c *Compiler) intRange(in *string) (minop OpCode, maxop OpCode, | |
352 | + min, max int32, err error) { | |
353 | + switch c.token { | |
354 | + case "(": | |
355 | + minop = OC_gt | |
356 | + case "[": | |
357 | + minop = OC_ge | |
358 | + default: | |
359 | + err = Error("'['か'('がありません") | |
360 | + return | |
361 | + } | |
362 | + integer := func() (int32, error) { | |
363 | + c.token = c.tokenizer(in) | |
364 | + minus := false | |
365 | + for c.token == "-" || c.token == "+" { | |
366 | + minus = minus || c.token == "-" | |
367 | + c.token = c.tokenizer(in) | |
368 | + } | |
369 | + if len(c.token) == 0 || c.token[0] < '0' || c.token[0] > '9' { | |
370 | + return 0, Error("数字の読み込みエラーです") | |
371 | + } | |
372 | + i := Atoi(c.token) | |
373 | + if minus { | |
374 | + i *= -1 | |
375 | + } | |
376 | + return i, nil | |
377 | + } | |
378 | + if min, err = integer(); err != nil { | |
379 | + return | |
380 | + } | |
381 | + i := strings.Index(*in, ",") | |
382 | + if i < 0 { | |
383 | + err = Error("','がありません") | |
384 | + return | |
385 | + } | |
386 | + *in = (*in)[i+1:] | |
387 | + if max, err = integer(); err != nil { | |
388 | + return | |
389 | + } | |
390 | + i = strings.IndexAny(*in, "])") | |
391 | + if i < 0 { | |
392 | + err = Error("']'か')'がありません") | |
393 | + return | |
394 | + } | |
395 | + if (*in)[i] == ')' { | |
396 | + maxop = OC_lt | |
397 | + } else { | |
398 | + maxop = OC_le | |
399 | + } | |
400 | + *in = (*in)[i+1:] | |
401 | + c.token = c.tokenizer(in) | |
402 | + return | |
403 | +} | |
404 | +func (c *Compiler) kyuushikiThroughNeo(_range bool, in *string) { | |
405 | + i := 0 | |
406 | + for ; i < len(*in); i++ { | |
407 | + if (*in)[i] >= '0' && (*in)[i] <= '9' || (*in)[i] == '-' || | |
408 | + _range && ((*in)[i] == '[' || (*in)[i] == '(') { | |
409 | + break | |
410 | + } | |
411 | + } | |
412 | + *in = (*in)[i:] | |
413 | + c.token = c.tokenizer(in) | |
414 | +} | |
415 | +func (c *Compiler) kyuushikiSuperDX(out *BytecodeExp, in *string, | |
416 | + hissu bool) error { | |
417 | + comma := c.token == "," | |
418 | + if comma { | |
419 | + c.token = c.tokenizer(in) | |
420 | + } | |
421 | + var opc OpCode | |
422 | + switch c.token { | |
423 | + case "<": | |
424 | + opc = OC_lt | |
425 | + c.kyuushikiThroughNeo(false, in) | |
426 | + case ">": | |
427 | + opc = OC_gt | |
428 | + c.kyuushikiThroughNeo(false, in) | |
429 | + case "<=": | |
430 | + opc = OC_le | |
431 | + c.kyuushikiThroughNeo(false, in) | |
432 | + case ">=": | |
433 | + opc = OC_ge | |
434 | + c.kyuushikiThroughNeo(false, in) | |
435 | + default: | |
436 | + opc = OC_eq | |
437 | + hikaku := false | |
438 | + switch c.token { | |
439 | + case "!=": | |
440 | + opc = OC_ne | |
441 | + hikaku = true | |
442 | + case "=": | |
443 | + hikaku = true | |
444 | + default: | |
445 | + if hissu && !comma { | |
446 | + return Error("比較演算子がありません") | |
447 | + } | |
448 | + } | |
449 | + if hikaku { | |
450 | + c.kyuushikiThroughNeo(true, in) | |
451 | + } | |
452 | + if c.token == "[" || c.token == "(" { | |
453 | + minop, maxop, min, max, err := c.intRange(in) | |
454 | + if err != nil { | |
455 | + return err | |
456 | + } | |
457 | + if opc == OC_ne { | |
458 | + if minop == OC_gt { | |
459 | + minop = OC_le | |
460 | + } else { | |
461 | + minop = OC_lt | |
462 | + } | |
463 | + if maxop == OC_lt { | |
464 | + minop = OC_ge | |
465 | + } else { | |
466 | + minop = OC_gt | |
467 | + } | |
468 | + } | |
469 | + out.append(OC_dup) | |
470 | + out.appendValue(BytecodeInt(min)) | |
471 | + out.append(minop) | |
472 | + out.append(OC_swap) | |
473 | + out.appendValue(BytecodeInt(max)) | |
474 | + out.append(maxop) | |
475 | + if opc == OC_ne { | |
476 | + out.append(OC_blor) | |
477 | + } else { | |
478 | + out.append(OC_bland) | |
479 | + } | |
480 | + c.usiroOp = comma || hikaku | |
481 | + return nil | |
482 | + } | |
483 | + } | |
484 | + n, err := c.integer2(in) | |
485 | + if err != nil { | |
486 | + return err | |
487 | + } | |
488 | + out.appendValue(BytecodeInt(n)) | |
489 | + out.append(opc) | |
490 | + c.usiroOp = true | |
491 | + return nil | |
492 | +} | |
315 | 493 | func (c *Compiler) expValue(out *BytecodeExp, in *string) (BytecodeValue, |
316 | 494 | error) { |
317 | 495 | c.usiroOp, c.norange = true, false |
@@ -325,6 +503,8 @@ func (c *Compiler) expValue(out *BytecodeExp, in *string) (BytecodeValue, | ||
325 | 503 | } |
326 | 504 | var be1, be2, be3 BytecodeExp |
327 | 505 | var bv1, bv2, bv3 BytecodeValue |
506 | + var n int32 | |
507 | + var be BytecodeExp | |
328 | 508 | var err error |
329 | 509 | switch c.token { |
330 | 510 | case "-": |
@@ -405,10 +585,34 @@ func (c *Compiler) expValue(out *BytecodeExp, in *string) (BytecodeValue, | ||
405 | 585 | } |
406 | 586 | case "random": |
407 | 587 | out.append(OC_random) |
588 | + case "roundstate": | |
589 | + out.append(OC_roundstate) | |
590 | + case "matchover": | |
591 | + out.append(OC_ex_, OC_ex_matchover) | |
408 | 592 | case "anim": |
409 | 593 | out.append(OC_anim) |
410 | 594 | case "animtime": |
411 | 595 | out.append(OC_animtime) |
596 | + case "animelem": | |
597 | + if _, err = c.kyuushiki(in); err != nil { | |
598 | + return BytecodeSF(), err | |
599 | + } | |
600 | + if c.token == "-" { | |
601 | + return BytecodeSF(), Error("マイナスが付くとエラーです") | |
602 | + } | |
603 | + if n, err = c.integer2(in); err != nil { | |
604 | + return BytecodeSF(), err | |
605 | + } | |
606 | + if n <= 0 { | |
607 | + return BytecodeSF(), Error("animelemのは0より大きくなければいけません") | |
608 | + } | |
609 | + out.appendValue(BytecodeInt(n)) | |
610 | + out.append(OC_animelemtime) | |
611 | + if err = c.kyuushikiSuperDX(&be, in, false); err != nil { | |
612 | + return BytecodeSF(), err | |
613 | + } | |
614 | + out.append(OC_jsf8, OpCode(len(be))) | |
615 | + out.append(be...) | |
412 | 616 | default: |
413 | 617 | println(c.token) |
414 | 618 | unimplemented() |
@@ -1525,6 +1729,17 @@ func (c *Compiler) ctrlSet(is IniSection, sbc *StateBytecode, | ||
1525 | 1729 | return c.paramValue(is, sc, "value", ctrlSet_value, VT_Bool, 1, true) |
1526 | 1730 | }) |
1527 | 1731 | } |
1732 | +func (c *Compiler) hitDefSub(is IniSection, | |
1733 | + sc *StateControllerBase) error { | |
1734 | + unimplemented() | |
1735 | + return nil | |
1736 | +} | |
1737 | +func (c *Compiler) hitDef(is IniSection, sbc *StateBytecode, | |
1738 | + sc *StateControllerBase) (StateController, error) { | |
1739 | + return hitDef(*sc), c.stateSec(is, func() error { | |
1740 | + return c.hitDefSub(is, sc) | |
1741 | + }) | |
1742 | +} | |
1528 | 1743 | func (c *Compiler) stateCompile(bc *Bytecode, filename, def string) error { |
1529 | 1744 | var lines []string |
1530 | 1745 | if err := LoadFile(&filename, def, func(filename string) error { |
@@ -1568,6 +1783,7 @@ func (c *Compiler) stateCompile(bc *Bytecode, filename, def string) error { | ||
1568 | 1783 | strings.SplitN(lines[i], ";", 2)[0])) |
1569 | 1784 | if len(line) < 7 || line[0] != '[' || line[len(line)-1] != ']' || |
1570 | 1785 | line[1:7] != "state " { |
1786 | + i-- | |
1571 | 1787 | break |
1572 | 1788 | } |
1573 | 1789 | i++ |
@@ -1610,6 +1826,8 @@ func (c *Compiler) stateCompile(bc *Bytecode, filename, def string) error { | ||
1610 | 1826 | scf = c.powerAdd |
1611 | 1827 | case "ctrlset": |
1612 | 1828 | scf = c.ctrlSet |
1829 | + case "hitdef": | |
1830 | + scf = c.hitDef | |
1613 | 1831 | default: |
1614 | 1832 | println(data) |
1615 | 1833 | unimplemented() |
@@ -28,8 +28,16 @@ func NewTexture() (t *Texture) { | ||
28 | 28 | } |
29 | 29 | |
30 | 30 | type PalFX struct { |
31 | - Time int32 | |
32 | - Remap []int | |
31 | + Time int32 | |
32 | + Remap []int | |
33 | + Invertall bool | |
34 | + negType bool | |
35 | + enable bool | |
36 | + eInvertall bool | |
37 | + enegType bool | |
38 | + eAdd [3]int32 | |
39 | + eMul [3]int32 | |
40 | + eColor float32 | |
33 | 41 | } |
34 | 42 | |
35 | 43 | func NewPalFX() *PalFX { return &PalFX{} } |
@@ -33,7 +33,8 @@ var sys = System{ | ||
33 | 33 | listenPort: "7500", |
34 | 34 | loader: *newLoader(), |
35 | 35 | numSimul: [2]int{2, 2}, |
36 | - numTurns: [2]int{2, 2}} | |
36 | + numTurns: [2]int{2, 2}, | |
37 | + afterImageMax: 8} | |
37 | 38 | |
38 | 39 | type TeamMode int32 |
39 | 40 |
@@ -80,6 +81,7 @@ type System struct { | ||
80 | 81 | inputRemap [MaxSimul * 2]int |
81 | 82 | listenPort string |
82 | 83 | round int32 |
84 | + matchWins [2]int32 | |
83 | 85 | wins [2]int32 |
84 | 86 | rexisted [2]int32 |
85 | 87 | draws int32 |
@@ -95,6 +97,7 @@ type System struct { | ||
95 | 97 | stringPool [MaxSimul * 2]StringPool |
96 | 98 | bcStack BytecodeStack |
97 | 99 | specialFlag GlobalSpecialFlag |
100 | + afterImageMax int | |
98 | 101 | } |
99 | 102 | |
100 | 103 | func (s *System) init(w, h int32) *lua.LState { |
@@ -190,6 +193,9 @@ func (s *System) synchronize() error { | ||
190 | 193 | } |
191 | 194 | return nil |
192 | 195 | } |
196 | +func (s *System) matchOver() bool { | |
197 | + return s.wins[0] >= s.matchWins[0] || s.wins[1] >= s.matchWins[1] | |
198 | +} | |
193 | 199 | |
194 | 200 | type SelectChar struct { |
195 | 201 | def, name string |