(fn, size)
| 644 | }; |
| 645 | |
| 646 | const byteToObject = (fn, size) => { |
| 647 | let keysMap = { |
| 648 | 0: ["fg"], // FILLSCREEN |
| 649 | 1: ["x", "y", "w", "h", "fg"], // DRAWRECT |
| 650 | 2: ["x", "y", "w", "h", "fg"], // FILLRECT |
| 651 | 3: ["x", "y", "w", "h", "r", "fg"], // DRAWROUNDRECT |
| 652 | 4: ["x", "y", "w", "h", "r", "fg"], // FILLROUNDRECT |
| 653 | 5: ["x", "y", "r", "fg"], // DRAWCIRCLE |
| 654 | 6: ["x", "y", "r", "fg"], // FILLCIRCLE |
| 655 | 7: ["x", "y", "x2", "y2", "x3", "y3", "fg"], // DRAWTRIANGLE |
| 656 | 8: ["x", "y", "x2", "y2", "x3", "y3", "fg"], // FILLTRIANGLE |
| 657 | 9: ["x", "y", "rx", "ry", "fg"], // DRAWELLIPSE |
| 658 | 10: ["x", "y", "rx", "ry", "fg"], // FILLELLIPSE |
| 659 | 11: ["x", "y", "x1", "y1", "fg"], // DRAWLINE |
| 660 | 12: ["x", "y", "r", "ir", "startAngle", "endAngle", "fg", "bg"], // DRAWARC |
| 661 | 13: ["x", "y", "bx", "by", "wd", "fg", "bg"], // DRAWWIDELINE |
| 662 | 14: ["x", "y", "size", "fg", "bg", "txt"], // DRAWCENTRESTRING |
| 663 | 15: ["x", "y", "size", "fg", "bg", "txt"], // DRAWRIGHTSTRING |
| 664 | 16: ["x", "y", "size", "fg", "bg", "txt"], // DRAWSTRING |
| 665 | 17: ["x", "y", "size", "fg", "bg", "txt"], // PRINT |
| 666 | 18: ["x", "y", "center", "ms", "fs", "file"], // DRAWIMAGE |
| 667 | 20: ["x", "y", "h", "fg"], // DRAWFASTVLINE |
| 668 | 21: ["x", "y", "w", "fg"], // DRAWFASTHLINE |
| 669 | 99: ["w", "h", "rotation"], // SCREEN_INFO |
| 670 | }; |
| 671 | |
| 672 | let r = {}; |
| 673 | let lengthLeft = size - 3; |
| 674 | for (let key of keysMap[fn]) { |
| 675 | if (["txt", "file"].includes(key)) { |
| 676 | r[key] = getByteValue(`s${lengthLeft}`); |
| 677 | } else if (["rotation", "fs"].includes(key)) { |
| 678 | lengthLeft -= 1; |
| 679 | r[key] = getByteValue("int8"); |
| 680 | if (key === "fs") { |
| 681 | r[key] = r[key] === 0 ? "SD" : "FS"; // 0 for SD, 1 for FS |
| 682 | } |
| 683 | } else { |
| 684 | lengthLeft -= 2; |
| 685 | r[key] = getByteValue("int16"); |
| 686 | } |
| 687 | } |
| 688 | return r; |
| 689 | }; |
| 690 | |
| 691 | let offset = 0; |
| 692 | ctx.clearRect(0, 0, canvas.width, canvas.height); |
no test coverage detected