diff --git a/MELHORIAS.md b/MELHORIAS.md new file mode 100644 index 0000000..f4cdbe7 --- /dev/null +++ b/MELHORIAS.md @@ -0,0 +1,113 @@ +# Melhorias + +Anotações do que ainda vale arrumar, sem ordem de prioridade. O que for feito +sai daqui (ou fica marcado como feito, com a data). + +--- + +## Exportação não devia ter tamanho fixo: arrays dinâmicos/esparsos + +**Estado:** pendente +**Onde:** `libraries/tinyblocks-blueprint/src/serialize.c` (grava 60-68, lê 220-232), +`libraries/tinyblocks-blueprint/include/blueprint.h` (`TB_BP_MAX_INPUTS` 16), +`libraries/tinyblocks-editor/include/tb_editor_internal.h` (`MAX_INPUTS` 16, `MAX_MOUTHS` 3) + +Todo bloco é gravado com os arrays inteiros do modelo, mesmo quando o tipo do +bloco não usa campo nenhum: + +| campo | tamanho gravado | conteúdo | +|---|---|---| +| `sub` | 3 | bocas de bloco C (corpo / senão / finalmente) | +| `args` | 16 | id do reporter encaixado em cada campo | +| `in_text` | 16 | texto literal de cada campo | + +`-1` (e `""`) é "vazio": sem reporter, boca vazia, sem pai, sem próximo. Isso é +fiel ao modelo em memória, mas o arquivo vira enchimento: + +``` +examples/snake.json, aba Snake, 178 blocos -> 177 KB + slots de texto: 3280, preenchidos: 207 + args com reporter: 116 + ~95% do arquivo é -1 / "" +``` + +O tamanho cresce com (blocos x 16), não com o que foi usado. Fica ruim de ler, +ruim de diffar e sem motivo para ser grande. + +**Direção:** gravar só os campos usados (e, de quebra, só os que o tipo do bloco +declara — `input_desc_count`), com arrays de tamanho variável: + +1. **Curto prazo, sem trocar de formato:** cortar o enchimento do fim, gravando + só até o último campo usado. O leitor já aceita array curto: item faltando em + `sub`/`args` vira `-1` e em `in_text` fica `""` (as abas nascem zeradas — + `blueprint.c:43`). Vale nos dois sentidos: arquivo novo abre em leitor velho + e arquivo velho abre em leitor novo. +2. **Formato esparso:** `args`/`in_text` como objeto só do que existe + (`{"1": "8"}`), subindo `version` para 3 e mantendo o caminho de leitura do + v1/v2 que já existe (`serialize.c:221`). +3. **Fundo:** tirar o tamanho fixo da estrutura (`sub[3]`, `args[16]`, + `in_text[16][64]`) e guardar só quantas entradas o tipo declara. Além do + arquivo, economiza RAM: cada bloco carrega ~1,1 KB de campos (16x64 B + 16 + int + 3 int) para usar 0 a 3. + +**Cuidado:** o mesmo `serialize.c` atende JSON, XML e CSV (`TB_BP_FMT_*`), e o +`TbBpBlock` é o modelo que o editor preenche (`EdBlock` espelha os mesmos +limites). Mexer aí pede `make test-blueprint` e `make test-editor` verdes, mais +um caso novo em `tests/blueprint_test.c`: array curto/faltando ainda carrega. + +--- + +## Aba não devia ter limite de blocos (nem o projeto, de abas/variáveis) + +**Estado:** pendente +**Onde:** `libraries/tinyblocks-editor/include/tb_editor_internal.h:183` (`MAX_WS` 256), +`:568-569` (`Tab.ws[MAX_WS]`, `Tab.top[MAX_WS]`), `:812-813` (`grp_mem`, `grp_mem_pos`), +`libraries/tinyblocks-editor/src/tb_editor.c:332-344` (`blk_alloc`), +`libraries/tinyblocks-blueprint/include/blueprint.h:22-30` +(`TB_BP_MAX_WS/TABS/UBLOCKS/VARS`), `libraries/tinyblocks-blueprint/src/serialize.c:206`, +`libraries/tinyblocks-editor/src/tb_editor.c:2811` + +O espaço de trabalho de uma aba é um vetor fixo de 256 `EdBlock`. O índice na +aba **é a identidade do bloco** (`parent`, `prel`, `next`, `sub[]`, `args[]` +apontam para índices), então a aba não pode crescer realocando: `blk_alloc` +(`tb_editor.c:332`) varre 0..255 procurando `used == false` e devolve `-1` quando +não acha. Com `in_text[16][64]` + `lit_text[64]` + `type_name[64]` + `args[16]` + +`sub[3]`, cada bloco ocupa ~1,2 KB — 256 blocos por aba dão ~300 KB, quase tudo +enchimento (ver o item acima: no `examples/snake.json`, 207 de 3280 campos). + +O que acontece hoje ao estourar: + +| caminho | comportamento | +|---|---| +| arrastar da paleta | `hot_status` = "Limite de 256 blocos por aba atingido" (`tb_editor.c:6078`) | +| MCP `add_block` | erro "A aba esta cheia (256 blocos)" (`tb_editor_mcp.c:558`) | +| colar scratchblocks | aviso "a aba esta cheia (%d blocos)" (`tb_editor.c:3083`) | +| duplo-clique em parâmetro do "defina" | **nada**: não cria o `Port.In` e não avisa (`tb_editor.c:6551`) | +| abrir projeto com aba >256 blocos | **descarta os blocos em silêncio** (`serialize.c:206`: `if (i >= 0 && i < TB_BP_MAX_WS)`) | +| salvar | corta a lista de variáveis em 64 (`tb_editor.c:2811`) e abas em 8 | + +Os dois últimos são os piores: dá para (ou conseguir escrever à mão) salvar um +projeto que reabre sem parte dos blocos/variáveis, sem nenhuma mensagem. + +**Por que incomoda de verdade:** um script ou um corpo de "Meus Blocos" inteiro +precisa caber em 256 blocos. A arquitetura já é multi-aba — `define_sync` +procura os "defina" em todas as abas (`tb_editor.c:1744+`) e `define_find` +também (`:1708`), `run_flag` roda só a aba atual (`vm_start(&CT, ...)`, `:1537`) +— mas o limite é de armazenamento, não de desenho: programas grandes ficam +fatiados em procedimentos artificiais, um por aba. + +**Direção:** + +1. `Tab` com vetor dinâmico: `EdBlock* ws; int ws_cap, ws_n;` + lista de índices + livres (não compactar: todo mundo referencia índice). `top[]`, `grp_mem[]` + e `grp_mem_pos[]` idem. +2. Blueprint: `TbBpTab` com blocos dinâmicos/esparsos (o índice já vai no `i` do + JSON). No leitor, crescer até `max(i)+1` em vez de descartar; no gravador, + gravar o que existe (e não cortar variáveis em 64). +3. Nunca descartar em silêncio: se algum limite continuar, devolver erro e + mostrar no `hot_status`/toast. +4. Mesma família: `MAX_TABS` 8, `MAX_USER_BLOCKS` 16, `TB_BP_MAX_VARS` 64, + `MAX_UBLK_SLOTS` 8. Vale o mesmo tratamento, ou ao menos mensagem clara. +5. Testes: `make test-blueprint` (carregar aba com >256 blocos e arquivo + esparso/curto) e `make test-editor` (o harness monta o JSON com `fputs`: + cabe uma aba grande e um projeto com mais de 8 abas). diff --git a/examples/snake.json b/examples/snake.json new file mode 100644 index 0000000..3016d60 --- /dev/null +++ b/examples/snake.json @@ -0,0 +1,9171 @@ +{ + "format": "tinyblocks-project", + "version": 2, + "cur_tab": 0, + "tabs": [ + { + "name": "Snake", + "composite": false, + "comp_id": -1, + "color": 0, + "ws_sx": 120, + "ws_sy": 3120, + "blocks": [ + { + "i": 0, + "type": "Port.Define", + "x": 144, + "y": 584, + "parent": -1, + "prel": -1, + "next": 1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "desenhe tudo", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 1, + "type": "Stage.Clear", + "x": 40, + "y": 700, + "parent": 0, + "prel": 0, + "next": 2, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 2, + "type": "Stage.PenColor", + "x": 0, + "y": 0, + "parent": 1, + "prel": 0, + "next": 3, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "230", + "50", + "50", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 3, + "type": "Stage.Circle", + "x": 0, + "y": 0, + "parent": 2, + "prel": 0, + "next": 10, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 4, + 7, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "8", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 4, + "type": "Math.Add", + "x": 0, + "y": 0, + "parent": 3, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 5, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "10", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 5, + "type": "Math.Mul", + "x": 0, + "y": 0, + "parent": 4, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 6, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "20", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 6, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 5, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "fx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 7, + "type": "Math.Add", + "x": 0, + "y": 0, + "parent": 3, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 8, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "10", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 8, + "type": "Math.Mul", + "x": 0, + "y": 0, + "parent": 7, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 9, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "20", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 9, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 8, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "fy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 10, + "type": "Stage.PenColor", + "x": 0, + "y": 0, + "parent": 3, + "prel": 0, + "next": 11, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "60", + "180", + "75", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 11, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 10, + "prel": 0, + "next": 12, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "i", + "2", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 12, + "type": "Control.Repeat", + "x": 0, + "y": 0, + "parent": 11, + "prel": 0, + "next": 28, + "sub": [ + 16, + -1, + -1 + ], + "args": [ + 13, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 13, + "type": "Math.Sub", + "x": 0, + "y": 0, + "parent": 12, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 14, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 14, + "type": "List.Length", + "x": 0, + "y": 0, + "parent": 13, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 15, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 15, + "type": "List.Var", + "x": 0, + "y": 0, + "parent": 14, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "sx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 16, + "type": "Stage.Circle", + "x": 0, + "y": 0, + "parent": 12, + "prel": 1, + "next": 27, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 17, + 22, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "9", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 17, + "type": "Math.Add", + "x": 0, + "y": 0, + "parent": 16, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 18, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "10", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 18, + "type": "Math.Mul", + "x": 0, + "y": 0, + "parent": 17, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 19, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "20", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 19, + "type": "List.Item", + "x": 0, + "y": 0, + "parent": 18, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 21, + 20, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 20, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 19, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "i", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 21, + "type": "List.Var", + "x": 0, + "y": 0, + "parent": 19, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "sx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 22, + "type": "Math.Add", + "x": 0, + "y": 0, + "parent": 16, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 23, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "10", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 23, + "type": "Math.Mul", + "x": 0, + "y": 0, + "parent": 22, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 24, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "20", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 24, + "type": "List.Item", + "x": 0, + "y": 0, + "parent": 23, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 26, + 25, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 25, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 24, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "i", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 26, + "type": "List.Var", + "x": 0, + "y": 0, + "parent": 24, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "sy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 27, + "type": "Variables.Change", + "x": 0, + "y": 0, + "parent": 16, + "prel": 0, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "i", + "1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 28, + "type": "Stage.PenColor", + "x": 0, + "y": 0, + "parent": 12, + "prel": 0, + "next": 29, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "20", + "110", + "40", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 29, + "type": "Stage.Circle", + "x": 0, + "y": 0, + "parent": 28, + "prel": 0, + "next": 38, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 30, + 34, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "10", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 30, + "type": "Math.Add", + "x": 0, + "y": 0, + "parent": 29, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 31, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "10", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 31, + "type": "Math.Mul", + "x": 0, + "y": 0, + "parent": 30, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 32, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "20", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 32, + "type": "List.Item", + "x": 0, + "y": 0, + "parent": 31, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 33, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 33, + "type": "List.Var", + "x": 0, + "y": 0, + "parent": 32, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "sx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 34, + "type": "Math.Add", + "x": 0, + "y": 0, + "parent": 29, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 35, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "10", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 35, + "type": "Math.Mul", + "x": 0, + "y": 0, + "parent": 34, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 36, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "20", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 36, + "type": "List.Item", + "x": 0, + "y": 0, + "parent": 35, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 37, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 37, + "type": "List.Var", + "x": 0, + "y": 0, + "parent": 36, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "sy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 38, + "type": "Stage.PenColor", + "x": 0, + "y": 0, + "parent": 29, + "prel": 0, + "next": 39, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "40", + "40", + "40", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 39, + "type": "Stage.Text", + "x": 0, + "y": 0, + "parent": 38, + "prel": 0, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 40, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "-230", + "165", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 40, + "type": "Text.Concat", + "x": 0, + "y": 0, + "parent": 39, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + 41, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "pontos: ", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 41, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 40, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "pontos", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 42, + "type": "Events.WhenRun", + "x": 144, + "y": 1251, + "parent": -1, + "prel": -1, + "next": 43, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 43, + "type": "List.Clear", + "x": 0, + "y": 0, + "parent": 42, + "prel": 0, + "next": 44, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "sx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 44, + "type": "List.Clear", + "x": 0, + "y": 0, + "parent": 43, + "prel": 0, + "next": 45, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "sy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 45, + "type": "List.Clear", + "x": 0, + "y": 0, + "parent": 44, + "prel": 0, + "next": 46, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "sk", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 46, + "type": "List.Push", + "x": 0, + "y": 0, + "parent": 45, + "prel": 0, + "next": 47, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "0", + "sx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 47, + "type": "List.Push", + "x": 0, + "y": 0, + "parent": 46, + "prel": 0, + "next": 48, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "0", + "sy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 48, + "type": "List.Push", + "x": 0, + "y": 0, + "parent": 47, + "prel": 0, + "next": 49, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "0_0", + "sk", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 49, + "type": "List.Push", + "x": 0, + "y": 0, + "parent": 48, + "prel": 0, + "next": 50, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "-1", + "sx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 50, + "type": "List.Push", + "x": 0, + "y": 0, + "parent": 49, + "prel": 0, + "next": 51, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "0", + "sy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 51, + "type": "List.Push", + "x": 0, + "y": 0, + "parent": 50, + "prel": 0, + "next": 52, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "-1_0", + "sk", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 52, + "type": "List.Push", + "x": 0, + "y": 0, + "parent": 51, + "prel": 0, + "next": 53, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "-2", + "sx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 53, + "type": "List.Push", + "x": 0, + "y": 0, + "parent": 52, + "prel": 0, + "next": 54, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "0", + "sy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 54, + "type": "List.Push", + "x": 0, + "y": 0, + "parent": 53, + "prel": 0, + "next": 55, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "-2_0", + "sk", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 55, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 54, + "prel": 0, + "next": 56, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "dx", + "1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 56, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 55, + "prel": 0, + "next": 57, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "dy", + "0", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 57, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 56, + "prel": 0, + "next": 58, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "pontos", + "0", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 58, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 57, + "prel": 0, + "next": 59, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "vivo", + "1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 59, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 58, + "prel": 0, + "next": 61, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + 60, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "fx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 60, + "type": "Operators.Random", + "x": 0, + "y": 0, + "parent": 59, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "-11", + "11", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 61, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 59, + "prel": 0, + "next": 63, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + 62, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "fy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 62, + "type": "Operators.Random", + "x": 0, + "y": 0, + "parent": 61, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "-8", + "8", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 63, + "type": "Input.ResetTimer", + "x": 0, + "y": 0, + "parent": 61, + "prel": 0, + "next": 176, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 64, + "type": "Control.Forever", + "x": 0, + "y": 0, + "parent": 176, + "prel": 0, + "next": -1, + "sub": [ + 65, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 65, + "type": "Control.If", + "x": 0, + "y": 0, + "parent": 64, + "prel": 1, + "next": 73, + "sub": [ + 71, + -1, + -1 + ], + "args": [ + 66, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 66, + "type": "Operators.And", + "x": 0, + "y": 0, + "parent": 65, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 67, + 68, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 67, + "type": "Input.KeyPressed", + "x": 0, + "y": 0, + "parent": 66, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "cima", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 68, + "type": "Operators.Not", + "x": 0, + "y": 0, + "parent": 66, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 69, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 69, + "type": "Operators.Eq", + "x": 0, + "y": 0, + "parent": 68, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 70, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "-1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 70, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 69, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "dy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 71, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 65, + "prel": 1, + "next": 72, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "dx", + "0", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 72, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 71, + "prel": 0, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "dy", + "1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 73, + "type": "Control.If", + "x": 0, + "y": 0, + "parent": 65, + "prel": 0, + "next": 81, + "sub": [ + 79, + -1, + -1 + ], + "args": [ + 74, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 74, + "type": "Operators.And", + "x": 0, + "y": 0, + "parent": 73, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 75, + 76, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 75, + "type": "Input.KeyPressed", + "x": 0, + "y": 0, + "parent": 74, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "baixo", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 76, + "type": "Operators.Not", + "x": 0, + "y": 0, + "parent": 74, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 77, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 77, + "type": "Operators.Eq", + "x": 0, + "y": 0, + "parent": 76, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 78, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 78, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 77, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "dy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 79, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 73, + "prel": 1, + "next": 80, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "dx", + "0", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 80, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 79, + "prel": 0, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "dy", + "-1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 81, + "type": "Control.If", + "x": 0, + "y": 0, + "parent": 73, + "prel": 0, + "next": 89, + "sub": [ + 87, + -1, + -1 + ], + "args": [ + 82, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 82, + "type": "Operators.And", + "x": 0, + "y": 0, + "parent": 81, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 83, + 84, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 83, + "type": "Input.KeyPressed", + "x": 0, + "y": 0, + "parent": 82, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "esquerda", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 84, + "type": "Operators.Not", + "x": 0, + "y": 0, + "parent": 82, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 85, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 85, + "type": "Operators.Eq", + "x": 0, + "y": 0, + "parent": 84, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 86, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 86, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 85, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "dx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 87, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 81, + "prel": 1, + "next": 88, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "dx", + "-1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 88, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 87, + "prel": 0, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "dy", + "0", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 89, + "type": "Control.If", + "x": 0, + "y": 0, + "parent": 81, + "prel": 0, + "next": 97, + "sub": [ + 95, + -1, + -1 + ], + "args": [ + 90, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 90, + "type": "Operators.And", + "x": 0, + "y": 0, + "parent": 89, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 91, + 92, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 91, + "type": "Input.KeyPressed", + "x": 0, + "y": 0, + "parent": 90, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "direita", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 92, + "type": "Operators.Not", + "x": 0, + "y": 0, + "parent": 90, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 93, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 93, + "type": "Operators.Eq", + "x": 0, + "y": 0, + "parent": 92, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 94, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "-1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 94, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 93, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "dx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 95, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 89, + "prel": 1, + "next": 96, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "dx", + "1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 96, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 95, + "prel": 0, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "dy", + "0", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 97, + "type": "Control.If", + "x": 0, + "y": 0, + "parent": 89, + "prel": 0, + "next": -1, + "sub": [ + 103, + -1, + -1 + ], + "args": [ + 98, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 98, + "type": "Operators.And", + "x": 0, + "y": 0, + "parent": 97, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 99, + 101, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 99, + "type": "Operators.Gt", + "x": 0, + "y": 0, + "parent": 98, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 100, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "0.12", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 100, + "type": "Input.Timer", + "x": 0, + "y": 0, + "parent": 99, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 101, + "type": "Operators.Eq", + "x": 0, + "y": 0, + "parent": 98, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 102, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 102, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 101, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "vivo", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 103, + "type": "Input.ResetTimer", + "x": 0, + "y": 0, + "parent": 97, + "prel": 1, + "next": 104, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 104, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 103, + "prel": 0, + "next": 109, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + 105, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 105, + "type": "Math.Add", + "x": 0, + "y": 0, + "parent": 104, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 106, + 108, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 106, + "type": "List.Item", + "x": 0, + "y": 0, + "parent": 105, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 107, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 107, + "type": "List.Var", + "x": 0, + "y": 0, + "parent": 106, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "sx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 108, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 105, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "dx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 109, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 104, + "prel": 0, + "next": 114, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + 110, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 110, + "type": "Math.Add", + "x": 0, + "y": 0, + "parent": 109, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 111, + 113, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 111, + "type": "List.Item", + "x": 0, + "y": 0, + "parent": 110, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 112, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 112, + "type": "List.Var", + "x": 0, + "y": 0, + "parent": 111, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "sy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 113, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 110, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "dy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 114, + "type": "Control.If", + "x": 0, + "y": 0, + "parent": 109, + "prel": 0, + "next": 118, + "sub": [ + 117, + -1, + -1 + ], + "args": [ + 115, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 115, + "type": "Operators.Gt", + "x": 0, + "y": 0, + "parent": 114, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 116, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "11", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 116, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 115, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 117, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 114, + "prel": 1, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hx", + "-11", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 118, + "type": "Control.If", + "x": 0, + "y": 0, + "parent": 114, + "prel": 0, + "next": 122, + "sub": [ + 121, + -1, + -1 + ], + "args": [ + 119, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 119, + "type": "Operators.Lt", + "x": 0, + "y": 0, + "parent": 118, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 120, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "-11", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 120, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 119, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 121, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 118, + "prel": 1, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hx", + "11", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 122, + "type": "Control.If", + "x": 0, + "y": 0, + "parent": 118, + "prel": 0, + "next": 126, + "sub": [ + 125, + -1, + -1 + ], + "args": [ + 123, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 123, + "type": "Operators.Gt", + "x": 0, + "y": 0, + "parent": 122, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 124, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "8", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 124, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 123, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 125, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 122, + "prel": 1, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hy", + "-8", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 126, + "type": "Control.If", + "x": 0, + "y": 0, + "parent": 122, + "prel": 0, + "next": 130, + "sub": [ + 129, + -1, + -1 + ], + "args": [ + 127, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 127, + "type": "Operators.Lt", + "x": 0, + "y": 0, + "parent": 126, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 128, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "-8", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 128, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 127, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 129, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 126, + "prel": 1, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hy", + "8", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 130, + "type": "Control.IfElse", + "x": 0, + "y": 0, + "parent": 126, + "prel": 0, + "next": -1, + "sub": [ + 137, + 142, + -1 + ], + "args": [ + 131, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 131, + "type": "List.Contains", + "x": 0, + "y": 0, + "parent": 130, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 132, + 133, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 132, + "type": "List.Var", + "x": 0, + "y": 0, + "parent": 131, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "sk", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 133, + "type": "Text.Concat", + "x": 0, + "y": 0, + "parent": 131, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 134, + 136, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 134, + "type": "Text.Concat", + "x": 0, + "y": 0, + "parent": 133, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 135, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "_", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 135, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 134, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 136, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 133, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 137, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 130, + "prel": 1, + "next": 138, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "vivo", + "0", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 138, + "type": "Stage.Text", + "x": 0, + "y": 0, + "parent": 137, + "prel": 0, + "next": 139, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "fim de jogo! clique na bandeira", + "-120", + "0", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 139, + "type": "IO.Print", + "x": 0, + "y": 0, + "parent": 138, + "prel": 0, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 140, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 140, + "type": "Text.Concat", + "x": 0, + "y": 0, + "parent": 139, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + 141, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "fim! pontos: ", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 141, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 140, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "pontos", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 142, + "type": "List.InsertAt", + "x": 0, + "y": 0, + "parent": 130, + "prel": 2, + "next": 144, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 143, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "1", + "sx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 143, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 142, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 144, + "type": "List.InsertAt", + "x": 0, + "y": 0, + "parent": 142, + "prel": 0, + "next": 146, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 145, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "1", + "sy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 145, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 144, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 146, + "type": "List.InsertAt", + "x": 0, + "y": 0, + "parent": 144, + "prel": 0, + "next": 151, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 147, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "1", + "sk", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 147, + "type": "Text.Concat", + "x": 0, + "y": 0, + "parent": 146, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 148, + 150, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 148, + "type": "Text.Concat", + "x": 0, + "y": 0, + "parent": 147, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 149, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "_", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 149, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 148, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 150, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 147, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 151, + "type": "Control.IfElse", + "x": 0, + "y": 0, + "parent": 146, + "prel": 0, + "next": 177, + "sub": [ + 159, + 167, + -1 + ], + "args": [ + 152, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 152, + "type": "Operators.And", + "x": 0, + "y": 0, + "parent": 151, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 153, + 156, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 153, + "type": "Operators.Eq", + "x": 0, + "y": 0, + "parent": 152, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 154, + 155, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 154, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 153, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 155, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 153, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "fx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 156, + "type": "Operators.Eq", + "x": 0, + "y": 0, + "parent": 152, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 157, + 158, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 157, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 156, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "hy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 158, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 156, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "fy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 159, + "type": "Variables.Change", + "x": 0, + "y": 0, + "parent": 151, + "prel": 1, + "next": 160, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "pontos", + "1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 160, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 159, + "prel": 0, + "next": 162, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + 161, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "fx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 161, + "type": "Operators.Random", + "x": 0, + "y": 0, + "parent": 160, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "-11", + "11", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 162, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 160, + "prel": 0, + "next": 164, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + 163, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "fy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 163, + "type": "Operators.Random", + "x": 0, + "y": 0, + "parent": 162, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "-8", + "8", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 164, + "type": "IO.Print", + "x": 0, + "y": 0, + "parent": 162, + "prel": 0, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 165, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 165, + "type": "Text.Concat", + "x": 0, + "y": 0, + "parent": 164, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + 166, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "pontos: ", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 166, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 165, + "prel": 5, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "pontos", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 167, + "type": "List.DeleteAt", + "x": 0, + "y": 0, + "parent": 151, + "prel": 2, + "next": 170, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 168, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "sx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 168, + "type": "List.Length", + "x": 0, + "y": 0, + "parent": 167, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 169, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 169, + "type": "List.Var", + "x": 0, + "y": 0, + "parent": 168, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "sx", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 170, + "type": "List.DeleteAt", + "x": 0, + "y": 0, + "parent": 167, + "prel": 0, + "next": 173, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 171, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "sy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 171, + "type": "List.Length", + "x": 0, + "y": 0, + "parent": 170, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 172, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 172, + "type": "List.Var", + "x": 0, + "y": 0, + "parent": 171, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "sy", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 173, + "type": "List.DeleteAt", + "x": 0, + "y": 0, + "parent": 170, + "prel": 0, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 174, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "sk", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 174, + "type": "List.Length", + "x": 0, + "y": 0, + "parent": 173, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + 175, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 175, + "type": "List.Var", + "x": 0, + "y": 0, + "parent": 174, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "sk", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 176, + "type": "User.desenhe tudo", + "x": 0, + "y": 0, + "parent": 63, + "prel": 0, + "next": 64, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 177, + "type": "User.desenhe tudo", + "x": 0, + "y": 0, + "parent": 151, + "prel": 0, + "next": -1, + "sub": [ + -1, + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + } + ], + "top": [ + 0, + 42 + ] + } + ], + "user_blocks": [ + { + "name": "desenhe tudo", + "color": 0, + "tab": -1, + "inputs": [], + "outputs": [], + "parts": [] + } + ], + "variables": [ + { + "name": "i", + "kind": 0, + "num": 4, + "text": "" + }, + { + "name": "dx", + "kind": 0, + "num": 1, + "text": "" + }, + { + "name": "dy", + "kind": 0, + "num": 0, + "text": "" + }, + { + "name": "pontos", + "kind": 0, + "num": 0, + "text": "" + }, + { + "name": "vivo", + "kind": 0, + "num": 1, + "text": "" + }, + { + "name": "fx", + "kind": 0, + "num": 10, + "text": "" + }, + { + "name": "fy", + "kind": 0, + "num": -6, + "text": "" + }, + { + "name": "hx", + "kind": 0, + "num": -10, + "text": "" + }, + { + "name": "hy", + "kind": 0, + "num": 0, + "text": "" + }, + { + "name": "chamadas", + "kind": 0, + "num": 1304, + "text": "" + } + ] +} diff --git a/include/tinyblocks/tb_stage.h b/include/tinyblocks/tb_stage.h index ae5109e..6e78396 100644 --- a/include/tinyblocks/tb_stage.h +++ b/include/tinyblocks/tb_stage.h @@ -25,6 +25,8 @@ TB_API void tb_stage_text(const char* text, float x, float y); TB_API bool tb_stage_image(const TinyBlocks_Image* img, float x, float y); TB_API bool tb_stage_image_named(const char* name, float x, float y); TB_API bool tb_stage_image_number(int number, float x, float y); +/* Como tb_stage_image, mas com zoom (escala) da imagem; zoom <= 0 = 1. */ +TB_API bool tb_stage_image_zoom(const TinyBlocks_Image* img, float x, float y, float zoom); /* Vista: tamanho da area onde o palco sera desenhado (letterbox 4:3) */ TB_API void tb_stage_set_view(float w, float h); diff --git a/libraries/tinyblocks-blueprint/include/blueprint.h b/libraries/tinyblocks-blueprint/include/blueprint.h index 74d69e2..9cc4514 100644 --- a/libraries/tinyblocks-blueprint/include/blueprint.h +++ b/libraries/tinyblocks-blueprint/include/blueprint.h @@ -19,13 +19,13 @@ #include #include -#define TB_BP_MAX_WS 256 +#define TB_BP_MAX_WS 65536 /* teto de blocos por aba (o vetor cresce sob demanda) */ #define TB_BP_MAX_INPUTS 16 #define TB_BP_MAX_TABS 8 -#define TB_BP_MAX_UBLOCKS 16 +#define TB_BP_MAX_UBLOCKS 64 #define TB_BP_MAX_UPARTS 16 #define TB_BP_MAX_USLOTS 8 -#define TB_BP_MAX_VARS 64 +#define TB_BP_MAX_VARS 4096 #define TB_BP_LIT_CAP 512 #define TB_BP_MAX_GROUPS 32 @@ -59,8 +59,14 @@ typedef struct { } TbBpGroup; typedef struct { - TbBpBlock blocks[TB_BP_MAX_WS]; - int top[TB_BP_MAX_WS]; + /* O indice do bloco e a identidade dele: o vetor pode crescer (realloc) + sem invalidar os vinculos, mas nunca compacta. */ + TbBpBlock* blocks; + int blocks_cap; /* slots alocados */ + int blocks_n; /* maior indice usado + 1 */ + int blocks_scan; /* dica do proximo slot livre */ + int* top; + int top_cap; int top_n; float ws_sx, ws_sy; char name[48]; @@ -114,9 +120,13 @@ void tb_blueprint_clear(TbBlueprint* bp); /* Cria uma aba; devolve o indice ou -1. */ int tb_blueprint_add_tab(TbBlueprint* bp, const char* name, bool composite); TbBpTab* tb_blueprint_tab(TbBlueprint* bp, int i); +/* Solta o pool de uma TbBpTab isolada (a struct em si e de quem chamou) */ +void tb_blueprint_tab_free(TbBpTab* t); /* Aloca um bloco no pool da aba; devolve o indice ou -1. */ int tb_blueprint_alloc_block(TbBpTab* t); +/* Garante que o slot i existe (zerado); devolve o bloco ou NULL. */ +TbBpBlock* tb_blueprint_tab_slot(TbBpTab* t, int i); /* Liga child ao pai na relacao rel (child < 0 desliga). */ void tb_blueprint_link(TbBpTab* t, int parent, int rel, int child); void tb_blueprint_top_add(TbBpTab* t, int bi); diff --git a/libraries/tinyblocks-blueprint/src/blueprint.c b/libraries/tinyblocks-blueprint/src/blueprint.c index 05ffb96..4b2b600 100644 --- a/libraries/tinyblocks-blueprint/src/blueprint.c +++ b/libraries/tinyblocks-blueprint/src/blueprint.c @@ -16,26 +16,54 @@ TbBlueprint* tb_blueprint_new(void) { } void tb_blueprint_free(TbBlueprint* bp) { + if (!bp) return; + for (int i = 0; i < TB_BP_MAX_TABS; i++) { + free(bp->tabs[i].blocks); + free(bp->tabs[i].top); + } free(bp); } +/* Zera um bloco para o estado "vazio" (sem pai, sem proximo, campos -1) */ +static void bp_block_init(TbBpBlock* b) { + memset(b, 0, sizeof(*b)); + b->parent = -1; + b->prel = TB_BP_REL_NONE; + b->next = -1; + b->sub[0] = b->sub[1] = b->sub[2] = -1; + for (int s = 0; s < TB_BP_MAX_INPUTS; s++) b->args[s] = -1; +} + void tb_blueprint_clear(TbBlueprint* bp) { if (!bp) return; - memset(bp, 0, sizeof(*bp)); - for (int i = 0; i < TB_BP_MAX_TABS; i++) { - TbBpTab* t = &bp->tabs[i]; - t->comp_id = -1; - for (int b = 0; b < TB_BP_MAX_WS; b++) { - t->blocks[b].parent = -1; - t->blocks[b].prel = TB_BP_REL_NONE; - t->blocks[b].next = -1; - t->blocks[b].sub[0] = t->blocks[b].sub[1] = t->blocks[b].sub[2] = -1; - for (int s = 0; s < TB_BP_MAX_INPUTS; s++) t->blocks[b].args[s] = -1; - } + for (int i = 0; i < TB_BP_MAX_TABS; i++) { /* antes do memset: solta o pool */ + free(bp->tabs[i].blocks); + free(bp->tabs[i].top); } + memset(bp, 0, sizeof(*bp)); + for (int i = 0; i < TB_BP_MAX_TABS; i++) bp->tabs[i].comp_id = -1; for (int u = 0; u < TB_BP_MAX_UBLOCKS; u++) bp->user_blocks[u].tab_idx = -1; } +/* Garante que o slot i existe (zerado e marcado como usado) */ +TbBpBlock* tb_blueprint_tab_slot(TbBpTab* t, int i) { + if (!t || i < 0 || i >= TB_BP_MAX_WS) return NULL; + if (i >= t->blocks_cap) { + int nc = t->blocks_cap ? t->blocks_cap : 64; + while (nc <= i) nc *= 2; + TbBpBlock* p = (TbBpBlock*)realloc(t->blocks, (size_t)nc * sizeof(*p)); + if (!p) return NULL; + for (int k = t->blocks_cap; k < nc; k++) bp_block_init(&p[k]); + t->blocks = p; + t->blocks_cap = nc; + } + if (i >= t->blocks_n) t->blocks_n = i + 1; + /* slot novo (ou reaproveitado pela serializacao): nasce vazio */ + if (!t->blocks[i].used) bp_block_init(&t->blocks[i]); + for (int s = 0; s < TB_BP_MAX_INPUTS; s++) if (t->blocks[i].args[s] < 0) t->blocks[i].args[s] = -1; + return &t->blocks[i]; +} + int tb_blueprint_add_tab(TbBlueprint* bp, const char* name, bool composite) { if (!bp || bp->tab_count >= TB_BP_MAX_TABS) return -1; int idx = bp->tab_count++; @@ -45,16 +73,16 @@ int tb_blueprint_add_tab(TbBlueprint* bp, const char* name, bool composite) { t->composite = composite; if (name && name[0]) snprintf(t->name, sizeof(t->name), "%s", name); else snprintf(t->name, sizeof(t->name), "Codigo %d", idx + 1); - for (int b = 0; b < TB_BP_MAX_WS; b++) { - t->blocks[b].parent = -1; - t->blocks[b].prel = TB_BP_REL_NONE; - t->blocks[b].next = -1; - t->blocks[b].sub[0] = t->blocks[b].sub[1] = t->blocks[b].sub[2] = -1; - for (int s = 0; s < TB_BP_MAX_INPUTS; s++) t->blocks[b].args[s] = -1; - } return idx; } +/* Solta o pool de uma TbBpTab isolada (a struct em si e de quem chamou) */ +void tb_blueprint_tab_free(TbBpTab* t) { + if (!t) return; + free(t->blocks); t->blocks = NULL; t->blocks_cap = t->blocks_n = t->blocks_scan = 0; + free(t->top); t->top = NULL; t->top_cap = t->top_n = 0; +} + TbBpTab* tb_blueprint_tab(TbBlueprint* bp, int i) { if (!bp || i < 0 || i >= bp->tab_count) return NULL; return &bp->tabs[i]; @@ -62,30 +90,33 @@ TbBpTab* tb_blueprint_tab(TbBlueprint* bp, int i) { int tb_blueprint_alloc_block(TbBpTab* t) { if (!t) return -1; - for (int i = 0; i < TB_BP_MAX_WS; i++) { - if (t->blocks[i].used) continue; - TbBpBlock* b = &t->blocks[i]; - memset(b, 0, sizeof(*b)); + /* dica nao anda para tras: alocacao em serie fica O(1) amortizado */ + int i = t->blocks_scan; + while (i < t->blocks_n && t->blocks[i].used) i++; + if (i >= t->blocks_n) { + if (i >= TB_BP_MAX_WS) return -1; + TbBpBlock* b = tb_blueprint_tab_slot(t, i); + if (!b) return -1; b->used = true; - b->parent = -1; - b->prel = TB_BP_REL_NONE; - b->next = -1; - b->sub[0] = b->sub[1] = b->sub[2] = -1; - for (int s = 0; s < TB_BP_MAX_INPUTS; s++) b->args[s] = -1; + t->blocks_scan = i + 1; return i; } - return -1; + TbBpBlock* b = &t->blocks[i]; + bp_block_init(b); + b->used = true; + t->blocks_scan = i + 1; + return i; } void tb_blueprint_link(TbBpTab* t, int parent, int rel, int child) { - if (!t || parent < 0 || parent >= TB_BP_MAX_WS) return; + if (!t || parent < 0 || parent >= t->blocks_n) return; TbBpBlock* p = &t->blocks[parent]; if (rel == TB_BP_REL_NEXT) p->next = child; else if (rel < TB_BP_REL_ARG0) p->sub[rel - TB_BP_REL_SUB0] = child; else p->args[rel - TB_BP_REL_ARG0] = child; - if (child >= 0 && child < TB_BP_MAX_WS) { - t->blocks[child].parent = parent; - t->blocks[child].prel = rel; + if (child >= 0) { + TbBpBlock* c = tb_blueprint_tab_slot(t, child); + if (c) { c->parent = parent; c->prel = rel; } } } @@ -97,7 +128,14 @@ void tb_blueprint_top_add(TbBpTab* t, int bi) { t->top_n--; break; } - if (t->top_n < TB_BP_MAX_WS) t->top[t->top_n++] = bi; + if (t->top_n >= t->top_cap) { + int nc = t->top_cap ? t->top_cap * 2 : 32; + int* p = (int*)realloc(t->top, (size_t)nc * sizeof(*p)); + if (!p) return; + t->top = p; + t->top_cap = nc; + } + t->top[t->top_n++] = bi; } void tb_blueprint_var_set_text(TbBlueprint* bp, const char* name, const char* value) { diff --git a/libraries/tinyblocks-blueprint/src/serialize.c b/libraries/tinyblocks-blueprint/src/serialize.c index 432708f..bbef569 100644 --- a/libraries/tinyblocks-blueprint/src/serialize.c +++ b/libraries/tinyblocks-blueprint/src/serialize.c @@ -46,7 +46,7 @@ TinyBlocks_JsonValue* tb_blueprint_to_json(const TbBlueprint* bp) { TinyBlocks_JsonValue* jb = tb_json_array(); PUT(jt, "blocks", jb); - for (int i = 0; i < TB_BP_MAX_WS; i++) { + for (int i = 0; i < T->blocks_n; i++) { const TbBpBlock* b = &T->blocks[i]; if (!b->used) continue; TinyBlocks_JsonValue* o = tb_json_object(); @@ -210,8 +210,8 @@ TbBlueprint* tb_blueprint_from_json(const TinyBlocks_JsonValue* root) { for (uint32_t bi = 0; jb && bi < tb_json_array_length(jb); bi++) { TinyBlocks_JsonValue* o = tb_json_array_get(jb, bi); int i = (int)jget_num(o, "i", -1); - if (i >= 0 && i < TB_BP_MAX_WS) { - TbBpBlock* b = &T->blocks[i]; + TbBpBlock* b = tb_blueprint_tab_slot(T, i); /* cresce ate o indice i */ + if (b) { b->used = true; snprintf(b->type, sizeof(b->type), "%s", jget_str(o, "type", "")); b->x = (float)jget_num(o, "x", 0); @@ -241,10 +241,17 @@ TbBlueprint* tb_blueprint_from_json(const TinyBlocks_JsonValue* root) { TinyBlocks_JsonValue* top = tb_json_object_get(jt, "top"); T->top_n = 0; - for (uint32_t i = 0; top && i < tb_json_array_length(top) && T->top_n < TB_BP_MAX_WS; i++) { + for (uint32_t i = 0; top && i < tb_json_array_length(top); i++) { TinyBlocks_JsonValue* e = tb_json_array_get(top, i); - T->top[T->top_n++] = e ? (int)tb_json_as_number(e, 0) : 0; + int h = e ? (int)tb_json_as_number(e, 0) : 0; tb_json_release(e); + if (T->top_n >= T->top_cap) { + int nc = T->top_cap ? T->top_cap * 2 : 32; + int* p = (int*)realloc(T->top, (size_t)nc * sizeof(*p)); + if (!p) break; + T->top = p; T->top_cap = nc; + } + T->top[T->top_n++] = h; } tb_json_release(top); @@ -412,7 +419,7 @@ static void blueprint_xml(Buf* b, const TbBlueprint* bp) { for (int i = 0; i < T->top_n; i++) { char t[24]; snprintf(t, sizeof(t), "%d", T->top[i]); bs(b, t); } bs(b, "\n"); bindent(b, 3); bs(b, "\n"); - for (int i = 0; i < TB_BP_MAX_WS; i++) { + for (int i = 0; i < T->blocks_n; i++) { const TbBpBlock* bl = &T->blocks[i]; if (!bl->used) continue; bindent(b, 4); bs(b, "tab_count; ti++) { const TbBpTab* T = &bp->tabs[ti]; - for (int i = 0; i < TB_BP_MAX_WS; i++) { + for (int i = 0; i < T->blocks_n; i++) { const TbBpBlock* b = &T->blocks[i]; if (!b->used) continue; TinyBlocks_JsonValue* o = tb_json_object(); diff --git a/libraries/tinyblocks-editor/include/tb_editor_internal.h b/libraries/tinyblocks-editor/include/tb_editor_internal.h index 996479e..59381c0 100644 --- a/libraries/tinyblocks-editor/include/tb_editor_internal.h +++ b/libraries/tinyblocks-editor/include/tb_editor_internal.h @@ -180,7 +180,7 @@ enum { IT_SEL = 0, IT_BRUSH, IT_LINE, IT_RECT, IT_ELLIPSE, #define PREVIEW_W 168 #define SNAP_R 28.f -#define MAX_WS 256 +#define MAX_WS 65536 /* teto de blocos por aba (o vetor cresce sob demanda) */ #define MAX_INPUTS 16 #define MAX_PARTS 40 #define MAX_TABS 8 @@ -369,7 +369,7 @@ static const BlockSpec s_specs[] = { {"Stage.Line", "desenhe linha de x %1 y %2 até x %3 y %4", "-100|0|100|0"}, {"Stage.Rect", "desenhe retângulo em x %1 y %2 largura %3 altura %4", "0|0|120|80"}, {"Stage.Circle", "desenhe círculo em x %1 y %2 raio %3", "0|0|50"}, - {"Stage.Draw", "desenhe %1 em x %2 y %3", "|0|0"}, + {"Stage.Draw", "desenhe %1 em x %2 y %3 escala %4", "|0|0|1"}, {"Stage.ImageByName", "desenhe imagem nome %1 em x %2 y %3", "|0|0"}, {"Stage.ImageByNumber", "desenhe imagem número %1 em x %2 y %3", "1|0|0"}, {"Stage.Text", "escreva %1 no palco em x %2 y %3", "Olá!|-40|0"}, @@ -565,9 +565,18 @@ typedef struct { typedef struct { int line; char* text; char color[12]; } CodeTok; typedef struct Tab { - EdBlock ws[MAX_WS]; - int top[MAX_WS]; /* pilhas de topo, em ordem de desenho */ - int top_n; + /* Blocos: vetor dinamico. O indice do bloco e a identidade dele + (parent/prel/next/sub[]/args[] apontam indices), entao o vetor cresce + por realloc e nunca compacta; slot liberado volta pela lista free_ids. */ + EdBlock* ws; + int ws_cap; /* slots alocados */ + int ws_n; /* maior indice usado + 1 */ + int* free_ids; /* indices livres (LIFO) */ + int free_n, free_cap; + + int* top; /* pilhas de topo, em ordem de desenho */ + int top_cap; + int top_n; float ws_sx, ws_sy; char name[48]; bool is_composite; @@ -809,8 +818,12 @@ typedef struct Ed { /* Grupos: arrasto (1 = mover com o conteudo, 2 = redimensionar) e titulo */ int grp_drag, grp_mode; float grp_mx, grp_my, grp_ox, grp_oy, grp_ow, grp_oh; - int grp_mem[MAX_WS], grp_mem_n; /* pilhas levadas junto */ - float grp_mem_pos[MAX_WS][2]; + int* grp_mem; /* pilhas levadas junto */ + float (*grp_mem_pos)[2]; + int grp_mem_n, grp_mem_cap; + /* Culling do desenho de blocos: retangulo visivel do painel sendo desenhado */ + bool cull_on; + float cull_x, cull_y, cull_w, cull_h; int grp_sub[MAX_GROUPS], grp_sub_n; /* grupos de dentro */ float grp_sub_pos[MAX_GROUPS][2]; int grp_edit; /* titulo em edicao, ou -1 */ @@ -1034,6 +1047,10 @@ const TabClass* tab_class(const Tab* T); * Indices de bloco sao posicoes no pool da aba (T->ws); "pilha" = bloco de * topo (T->top). Mudou a aba: layout_tab(T). */ int blk_new(Tab* T, TinyBlocks_TypeBlock* type); +/* O pool de blocos cresce por demanda (ate MAX_WS = 65536 por aba) */ +bool blk_reserve(Tab* T, int i); /* garante o slot i */ +void blk_release(Tab* T, int i); /* devolve o slot p/ reuso */ +void tab_ws_clear(Tab* T); /* zera o pool (mantem RAM) */ void top_add(Tab* T, int bi); void top_remove(Tab* T, int bi); void blk_link(Tab* T, int parent, int rel, int child); diff --git a/libraries/tinyblocks-editor/src/tb_editor.c b/libraries/tinyblocks-editor/src/tb_editor.c index fb63704..9878744 100644 --- a/libraries/tinyblocks-editor/src/tb_editor.c +++ b/libraries/tinyblocks-editor/src/tb_editor.c @@ -329,18 +329,67 @@ static void blk_defaults(EdBlock* b) { } } +/* Zera um slot para o estado "vazio" (sem pai, sem proximo, campos -1) */ +static void blk_slot_clear(Tab* T, int i) { + EdBlock* b = &T->ws[i]; + memset(b, 0, sizeof(*b)); + b->used = false; + b->parent = -1; b->prel = REL_NONE; b->next = -1; + b->sub[0] = b->sub[1] = b->sub[2] = -1; + for (int s = 0; s < MAX_INPUTS; s++) b->args[s] = -1; +} + +/* Garante que o slot i existe (crescendo o vetor por dobragem) */ +bool blk_reserve(Tab* T, int i) { + if (!T || i < 0) return false; + if (i >= MAX_WS) return false; + if (i >= T->ws_cap) { + int nc = T->ws_cap ? T->ws_cap : 64; + while (nc <= i) nc *= 2; + EdBlock* p = (EdBlock*)realloc(T->ws, (size_t)nc * sizeof(*p)); + if (!p) return false; + T->ws = p; + for (int k = T->ws_cap; k < nc; k++) blk_slot_clear(T, k); + T->ws_cap = nc; + } + if (i >= T->ws_n) T->ws_n = i + 1; + return true; +} + +/* Zera o pool da aba (mantem a memoria alocada, para reuso) */ +void tab_ws_clear(Tab* T) { + if (!T) return; + for (int i = 0; i < T->ws_cap; i++) blk_slot_clear(T, i); + T->ws_n = 0; + T->free_n = 0; + T->top_n = 0; +} + +/* Devolve o slot para reuso (o bloco ja saiu da arvore) */ +void blk_release(Tab* T, int i) { + if (!T || i < 0 || i >= T->ws_cap) return; + if (T->free_n >= T->free_cap) { + int nc = T->free_cap ? T->free_cap * 2 : 64; + int* p = (int*)realloc(T->free_ids, (size_t)nc * sizeof(*p)); + if (!p) return; /* sem memoria: o slot so nao e reusado */ + T->free_ids = p; T->free_cap = nc; + } + T->free_ids[T->free_n++] = i; +} + static int blk_alloc(Tab* T) { - for (int i = 0; i < MAX_WS; i++) { - if (T->ws[i].used) continue; - EdBlock* b = &T->ws[i]; - memset(b, 0, sizeof(*b)); - b->used = true; - b->parent = -1; b->prel = REL_NONE; b->next = -1; - b->sub[0] = b->sub[1] = b->sub[2] = -1; - for (int s = 0; s < MAX_INPUTS; s++) b->args[s] = -1; + if (T->free_n > 0) { + int i = T->free_ids[--T->free_n]; + blk_slot_clear(T, i); + T->ws[i].used = true; return i; } - return -1; + if (T->ws_n >= MAX_WS) return -1; + int i = T->ws_n; + if (!blk_reserve(T, i)) return -1; + blk_slot_clear(T, i); + T->ws[i].used = true; + return i; } int blk_new(Tab* T, TinyBlocks_TypeBlock* type) { @@ -365,7 +414,13 @@ void top_remove(Tab* T, int bi) { /* Adiciona (ou traz para a frente) uma pilha de topo */ void top_add(Tab* T, int bi) { top_remove(T, bi); - if (T->top_n < MAX_WS) T->top[T->top_n++] = bi; + if (T->top_n >= T->top_cap) { + int nc = T->top_cap ? T->top_cap * 2 : 32; + int* p = (int*)realloc(T->top, (size_t)nc * sizeof(*p)); + if (!p) return; + T->top = p; T->top_cap = nc; + } + T->top[T->top_n++] = bi; } /* Liga child ao pai na relação rel (child - -1 desliga) */ @@ -491,6 +546,7 @@ void free_tree(Ed* ed, Tab* T, int bi) { } b->used = false; b->live_rt = NULL; + blk_release(T, bi); bi = nx; } } @@ -1035,8 +1091,25 @@ static void ax_chain(Ed* ed, Tab* T, int head, float ox, float oy, uint32_t acts static void render_chain(Ed* ed, TinyBlocks_RenderableBlock* rb, Tab* T, int head, float ox, float oy); +/* Retangulo visivel (coordenadas de tela) do painel que esta sendo desenhado. + * O palco e a saida sao desenhados depois da area de scripts, e os comandos de + * desenho tem um teto (TB_DRAW_CMD_CAP): sem culling, uma aba com milhares de + * blocos consome o teto e o palco some da tela. */ +void ed_cull_pane(Ed* ed, bool on, float x, float y, float w, float h) { + ed->cull_on = on; ed->cull_x = x; ed->cull_y = y; ed->cull_w = w; ed->cull_h = h; +} + +static bool culled(const Ed* ed, const EdBlock* b, float ox, float oy) { + if (!ed->cull_on) return false; + const float M = 80.f; /* folga: valores encaixados passam do corpo */ + float x = b->ax + ox, y = b->ay + oy; + return x + b->w < ed->cull_x - M || x > ed->cull_x + ed->cull_w + M || + y + b->h < ed->cull_y - M || y > ed->cull_y + ed->cull_h + M; +} + static void render_block(Ed* ed, TinyBlocks_RenderableBlock* rb, Tab* T, int bi, float ox, float oy) { EdBlock* b = &T->ws[bi]; + if (culled(ed, b, ox, oy)) return; Shape sh = shape_of(b->type); Col c, d; block_cols(ed, b, &c, &d); float x = b->ax + ox, y = b->ay + oy, w = b->w, h = b->h; @@ -1142,9 +1215,11 @@ static void render_block(Ed* ed, TinyBlocks_RenderableBlock* rb, Tab* T, int bi, /* Desenha de baixo para cima, para cada encaixe cobrir o bloco seguinte */ static void render_chain(Ed* ed, TinyBlocks_RenderableBlock* rb, Tab* T, int head, float ox, float oy) { - int ids[MAX_WS], n = 0; - for (int c = head; c >= 0 && n < MAX_WS; c = T->ws[c].next) ids[n++] = c; + int* ids = T->ws_n > 0 ? (int*)malloc((size_t)T->ws_n * sizeof(int)) : NULL; + int n = 0; + for (int c = head; ids && c >= 0 && n < T->ws_n; c = T->ws[c].next) ids[n++] = c; for (int i = n - 1; i >= 0; i--) render_block(ed, rb, T, ids[i], ox, oy); + free(ids); } /* === @@ -1169,7 +1244,7 @@ static void run_abort(Ed* ed, const char* msg) { } static void clear_live(Tab* T) { - for (int i = 0; i < MAX_WS; i++) T->ws[i].live_rt = NULL; + for (int i = 0; i < T->ws_n; i++) T->ws[i].live_rt = NULL; } /* Destrói as instâncias do runtime da execução anterior (e para os scripts) */ @@ -1523,8 +1598,9 @@ void vm_stop(Ed* ed) { void run_flag(Ed* ed) { run_begin(ed, true); tb_input_timer_reset(); /* como no Scratch: a bandeira zera o cronometro */ - int heads[MAX_WS], n = 0; - for (int i = 0; i < CT.top_n; i++) heads[n++] = CT.top[i]; + int* heads = CT.top_n > 0 ? (int*)malloc((size_t)CT.top_n * sizeof(int)) : NULL; + int n = 0; + for (int i = 0; heads && i < CT.top_n; i++) heads[n++] = CT.top[i]; for (int i = 1; i < n; i++) for (int j = i; j > 0 && CT.ws[heads[j]].y < CT.ws[heads[j-1]].y; j--) { int tmp = heads[j]; heads[j] = heads[j-1]; heads[j-1] = tmp; @@ -1538,6 +1614,7 @@ void run_flag(Ed* ed) { started++; } } + free(heads); if (!started) { run_end(ed); stage_append(ed, "Nenhum script começa com \"quando a bandeira for clicado\".\n"); @@ -1823,8 +1900,9 @@ static void eval_composite(TinyBlocks_Block* self, TinyBlocks* rt) { } /* Aba so do bloco: roda os scripts da definição de cima para baixo */ Tab* S = def->snap; - int heads[MAX_WS], n = 0; - for (int i = 0; i < S->top_n; i++) heads[n++] = S->top[i]; + int* heads = S->top_n > 0 ? (int*)malloc((size_t)S->top_n * sizeof(int)) : NULL; + int n = 0; + for (int i = 0; heads && i < S->top_n; i++) heads[n++] = S->top[i]; for (int i = 1; i < n; i++) for (int j = i; j > 0 && S->ws[heads[j]].y < S->ws[heads[j-1]].y; j--) { int tmp = heads[j]; heads[j] = heads[j-1]; heads[j-1] = tmp; @@ -1832,6 +1910,7 @@ static void eval_composite(TinyBlocks_Block* self, TinyBlocks* rt) { for (int i = 0; i < n && !ed->abort; i++) if (!shape_is_value(shape_of(blk_type(ed, &S->ws[heads[i]])))) run_chain(ed, S, heads[i]); + free(heads); done: for (int i = 0; i < def->output_count; i++) { @@ -1848,7 +1927,7 @@ done: * Tipos: invalidação/re-resolução (hot reload e redefinição de compostos) * === */ static void invalidate_tab(Tab* T) { - for (int i = 0; i < MAX_WS; i++) { T->ws[i].type = NULL; T->ws[i].live_rt = NULL; } + for (int i = 0; i < T->ws_n; i++) { T->ws[i].type = NULL; T->ws[i].live_rt = NULL; } } static void invalidate_types(Ed* ed) { @@ -1860,7 +1939,7 @@ static void invalidate_types(Ed* ed) { } static void retype_tab(Ed* ed, Tab* T) { - for (int i = 0; i < MAX_WS; i++) { + for (int i = 0; i < T->ws_n; i++) { EdBlock* b = &T->ws[i]; if (!b->used) continue; b->type = b->type_name[0] ? tb_type_block_find(ed->rt, b->type_name) : NULL; @@ -1945,7 +2024,15 @@ static void fly_add_block(Ed* ed, int cat, TinyBlocks_TypeBlock* t, const char* void palette_rebuild(Ed* ed) { cats_rebuild(ed); + /* Zera a paleta sem jogar fora o pool de blocos (ele seria realocado do + zero a cada troca de categoria) */ + EdBlock* fws = ed->fly.ws; int fcap = ed->fly.ws_cap; + int* fids = ed->fly.free_ids; int fidscap = ed->fly.free_cap; + int* ftop = ed->fly.top; int ftopcap = ed->fly.top_cap; memset(&ed->fly, 0, sizeof(ed->fly)); + ed->fly.ws = fws; ed->fly.ws_cap = fcap; + ed->fly.free_ids = fids; ed->fly.free_cap = fidscap; + ed->fly.top = ftop; ed->fly.top_cap = ftopcap; ed->fly_n = 0; float y = 8; TinyBlocks_TypeBlock* var_get = tb_type_block_find(ed->rt, "Variables.Get"); @@ -2495,6 +2582,7 @@ bool tab_new_kind(Ed* ed, const char* name, bool is_composite, int kind) { } int idx = ed->tab_n++; Tab* T = &ed->tabs[idx]; + tab_doc_free(T); /* slot reaproveitado: solta o pool */ memset(T, 0, sizeof(*T)); if (name && name[0]) strncpy(T->name, name, sizeof(T->name) - 1); else snprintf(T->name, sizeof(T->name), "Código %d", idx + 1); @@ -2535,6 +2623,10 @@ void tab_doc_free(Tab* T) { T->img_layer_n = 0; if (T->img_prev) { tb_image_release(T->img_prev); T->img_prev = NULL; } img_sel_reset(T); + /* pool de blocos e pilhas de topo (dinamicos desde o limite de 65536) */ + free(T->ws); T->ws = NULL; T->ws_cap = T->ws_n = 0; + free(T->free_ids); T->free_ids = NULL; T->free_n = T->free_cap = 0; + free(T->top); T->top = NULL; T->top_cap = T->top_n = 0; } /* Novo indice de uma aba depois de mover `from` para `to` */ @@ -2626,7 +2718,7 @@ static void open_def(Ed* ed, const char* uname) { static void collect_labels(Tab* T, const char* type_name, char names[][32], int* count, const char* fallback) { *count = 0; - for (int i = 0; i < MAX_WS && *count < MAX_UBLK_SLOTS; i++) { + for (int i = 0; i < T->ws_n && *count < MAX_UBLK_SLOTS; i++) { EdBlock* b = &T->ws[i]; if (!b->used || strcmp(b->type_name, type_name) != 0) continue; char lbl[32]; @@ -2640,8 +2732,9 @@ static void collect_labels(Tab* T, const char* type_name, char names[][32], int* /* Reconcilia os blocos Port.In do corpo com as entradas do protótipo */ static void comp_sync_inputs(Ed* ed, UserBlockDef* def, Tab* T) { - int ids[MAX_WS], n = 0; - for (int i = 0; i < MAX_WS; i++) { + int* ids = T->ws_n > 0 ? (int*)malloc((size_t)T->ws_n * sizeof(int)) : NULL; + int n = 0; + for (int i = 0; ids && i < T->ws_n; i++) { EdBlock* b = &T->ws[i]; if (b->used && strcmp(b->type_name, "Port.In") == 0) ids[n++] = i; } @@ -2657,6 +2750,7 @@ static void comp_sync_inputs(Ed* ed, UserBlockDef* def, Tab* T) { } } for (int k = def->input_count; k < n; k++) free_tree(ed, T, ids[k]); + free(ids); } /* Deriva os nomes das entradas a partir das partes do protótipo */ @@ -2750,18 +2844,19 @@ static void tab_to_bp(const Tab* T, TbBpTab* B) { B->comp_id = T->comp_id; B->color_idx = T->color_idx; B->ws_sx = T->ws_sx; B->ws_sy = T->ws_sy; - B->top_n = T->top_n; - for (int i = 0; i < T->top_n; i++) B->top[i] = T->top[i]; + B->top_n = 0; + for (int i = 0; i < T->top_n; i++) tb_blueprint_top_add(B, T->top[i]); B->group_n = T->group_n < TB_BP_MAX_GROUPS ? T->group_n : TB_BP_MAX_GROUPS; for (int g = 0; g < B->group_n; g++) { const WsGroup* G = &T->groups[g]; B->groups[g] = (TbBpGroup){ G->x, G->y, G->w, G->h, G->color, "" }; snprintf(B->groups[g].title, sizeof(B->groups[g].title), "%s", G->title); } - for (int i = 0; i < MAX_WS; i++) { + for (int i = 0; i < T->ws_n; i++) { const EdBlock* b = &T->ws[i]; if (!b->used) continue; - TbBpBlock* o = &B->blocks[i]; + TbBpBlock* o = tb_blueprint_tab_slot(B, i); + if (!o) break; o->used = true; snprintf(o->type, sizeof(o->type), "%s", b->type_name); o->x = b->x; o->y = b->y; @@ -2821,15 +2916,11 @@ static TbBlueprint* ed_to_blueprint(Ed* ed) { /* Blocos de uma aba da blueprint -> aba do editor (os mesmos indices) */ static void bp_tab_load(Ed* ed, const TbBpTab* B, Tab* T) { - for (int i = 0; i < MAX_WS; i++) { - memset(&T->ws[i], 0, sizeof(T->ws[i])); - T->ws[i].parent = -1; T->ws[i].prel = REL_NONE; T->ws[i].next = -1; - T->ws[i].sub[0] = T->ws[i].sub[1] = T->ws[i].sub[2] = -1; - for (int s = 0; s < MAX_INPUTS; s++) T->ws[i].args[s] = -1; - } - for (int i = 0; i < MAX_WS; i++) { + tab_ws_clear(T); /* zera o pool da aba */ + for (int i = 0; i < B->blocks_n; i++) { const TbBpBlock* o = &B->blocks[i]; if (!o->used) continue; + if (!blk_reserve(T, i)) break; EdBlock* b = &T->ws[i]; b->used = true; snprintf(b->type_name, sizeof(b->type_name), "%s", o->type); @@ -2843,8 +2934,8 @@ static void bp_tab_load(Ed* ed, const TbBpTab* B, Tab* T) { } snprintf(b->lit_text, sizeof(b->lit_text), "%s", o->lit); } - T->top_n = B->top_n < MAX_WS ? B->top_n : MAX_WS; - for (int i = 0; i < T->top_n; i++) T->top[i] = B->top[i]; + T->top_n = 0; + for (int i = 0; i < B->top_n; i++) top_add(T, B->top[i]); } /* Descarta tudo do editor e reconstroi a partir da blueprint. */ @@ -2885,6 +2976,7 @@ static void blueprint_apply(Ed* ed, const TbBlueprint* bp) { for (int ti = 0; ti < bp->tab_count && ed->tab_n < MAX_TABS; ti++) { const TbBpTab* B = &bp->tabs[ti]; Tab* T = &ed->tabs[ed->tab_n++]; + tab_doc_free(T); /* slot reaproveitado: solta o pool */ memset(T, 0, sizeof(*T)); snprintf(T->name, sizeof(T->name), "%s", B->name); T->is_composite = B->composite; @@ -3047,6 +3139,13 @@ static TbSbContext sb_context(Ed* ed, TbSbLabel** labels_out) { return cx; } +/* Solta uma aba de blueprint isolada (pool de blocos + struct) */ +static void bp_tab_dispose(TbBpTab* B) { + if (!B) return; + tb_blueprint_tab_free(B); + free(B); +} + /* Pilha `head` da aba T (ou a aba inteira, head < 0) em scratchblocks. malloc */ char* ed_scratchblocks_export(Ed* ed, const Tab* T, int head) { TbBpTab* B = calloc(1, sizeof(TbBpTab)); @@ -3057,7 +3156,7 @@ char* ed_scratchblocks_export(Ed* ed, const Tab* T, int head) { TbSbContext cx = sb_context(ed, &labels); char* txt = tb_scratchblocks_export(B, &cx); free(labels); - free(B); + bp_tab_dispose(B); return txt; } @@ -3072,21 +3171,23 @@ int ed_scratchblocks_import(Ed* ed, Tab* T, const char* text, float x, float y, TbSbContext cx = sb_context(ed, &labels); int n = tb_scratchblocks_import(text, B, &cx, warn, warn_cap); free(labels); - if (n <= 0) { free(B); return -1; } - int map[TB_BP_MAX_WS]; - for (int i = 0; i < TB_BP_MAX_WS; i++) { + if (n <= 0) { bp_tab_dispose(B); return -1; } + int* map = (int*)malloc((size_t)(B->blocks_n > 0 ? B->blocks_n : 1) * sizeof(int)); + if (!map) { bp_tab_dispose(B); return -1; } + for (int i = 0; i < B->blocks_n; i++) { map[i] = -1; if (!B->blocks[i].used) continue; map[i] = blk_alloc(T); - if (map[i] < 0) { /* aba cheia: desfaz */ - for (int j = 0; j < i; j++) if (map[j] >= 0) T->ws[map[j]].used = false; - if (warn && warn_cap) snprintf(warn, warn_cap, "a aba esta cheia (%d blocos)", MAX_WS); - free(B); + if (map[i] < 0) { /* limite da aba: desfaz */ + for (int j = 0; j < i; j++) if (map[j] >= 0) { T->ws[map[j]].used = false; blk_release(T, map[j]); } + if (warn && warn_cap) snprintf(warn, warn_cap, "limite de %d blocos por aba", MAX_WS); + free(map); + bp_tab_dispose(B); return -1; } } -#define MAP(i) ((i) >= 0 && (i) < TB_BP_MAX_WS ? map[i] : -1) - for (int i = 0; i < TB_BP_MAX_WS; i++) { +#define MAP(i) ((i) >= 0 && (i) < B->blocks_n ? map[i] : -1) + for (int i = 0; i < B->blocks_n; i++) { const TbBpBlock* o = &B->blocks[i]; if (!o->used) continue; EdBlock* b = &T->ws[map[i]]; @@ -3104,14 +3205,15 @@ int ed_scratchblocks_import(Ed* ed, Tab* T, const char* text, float x, float y, #undef MAP int made = 0; for (int t = 0; t < B->top_n; t++) { - int h = B->top[t] >= 0 && B->top[t] < TB_BP_MAX_WS ? map[B->top[t]] : -1; + int h = B->top[t] >= 0 && B->top[t] < B->blocks_n ? map[B->top[t]] : -1; if (h < 0) continue; T->ws[h].x = x; T->ws[h].y = y; top_add(T, h); if (made < max && heads) heads[made] = h; made++; } - free(B); + free(map); + bp_tab_dispose(B); layout_tab(T); /* empilha uma embaixo da outra */ for (int k = 1; k < made && k < max && heads; k++) { float x0, y0, x1, y1; @@ -3176,11 +3278,11 @@ static bool sb_import_text(Ed* ed, const char* text, const char* name) { if (n <= 0) snprintf(ed->hot_status, sizeof(ed->hot_status), "Nenhum script em %.200s", name); else snprintf(ed->hot_status, sizeof(ed->hot_status), "Limite de abas atingido"); ed->hot_status_ok = false; - free(B); + bp_tab_dispose(B); return false; } bp_tab_load(ed, B, &CT); - free(B); + bp_tab_dispose(B); layout_tab(&CT); cleanup_ws(ed); /* arruma as pilhas uma embaixo da outra */ palette_rebuild(ed); @@ -3488,7 +3590,7 @@ static void dlg_ok(Ed* ed) { snprintf(old_type, sizeof(old_type), "User.%s", old_name); snprintf(new_type, sizeof(new_type), "User.%s", def->name); for (int t = 0; t < ed->tab_n; t++) - for (int i = 0; i < MAX_WS; i++) { + for (int i = 0; i < ed->tabs[t].ws_n; i++) { EdBlock* b = &ed->tabs[t].ws[i]; if (b->used && strcmp(b->type_name, old_type) == 0) snprintf(b->type_name, sizeof(b->type_name), "%s", new_type); @@ -4837,7 +4939,7 @@ static void groups_render(Ed* ed, TinyBlocks_RenderableBlock* rb, float ox, floa /* Limites de uma pilha (todos os blocos dela, ja com layout) */ void stack_bounds(Tab* T, int root, float* x0, float* y0, float* x1, float* y1) { *x0 = *y0 = 1e9f; *x1 = *y1 = -1e9f; - for (int i = 0; i < MAX_WS; i++) { + for (int i = 0; i < T->ws_n; i++) { EdBlock* b = &T->ws[i]; if (!b->used || stack_root(T, i) != root) continue; if (b->ax < *x0) *x0 = b->ax; @@ -4871,6 +4973,21 @@ static void group_delete(Tab* T, int g) { T->group_n--; } +/* Garante espaco para n pilhas no arrasto de grupo */ +static bool grp_mem_reserve(Ed* ed, int n) { + if (n <= ed->grp_mem_cap) return true; + int nc = ed->grp_mem_cap ? ed->grp_mem_cap * 2 : 64; + while (nc < n) nc *= 2; + int* ids = (int*)realloc(ed->grp_mem, (size_t)nc * sizeof(*ids)); + if (!ids) return false; + ed->grp_mem = ids; + float (*pos)[2] = (float(*)[2])realloc(ed->grp_mem_pos, (size_t)nc * sizeof(*pos)); + if (!pos) return false; + ed->grp_mem_pos = pos; + ed->grp_mem_cap = nc; + return true; +} + /* Comeca a mover o grupo g: guarda as pilhas e grupos que estao dentro */ static void group_press(Ed* ed, int g, float mx, float my, int mode) { Tab* T = &CT; @@ -4883,6 +5000,7 @@ static void group_press(Ed* ed, int g, float mx, float my, int mode) { for (int i = 0; i < T->top_n; i++) { EdBlock* b = &T->ws[T->top[i]]; if (!in_rect(b->x, b->y, G->x, G->y, G->w, G->h)) continue; + if (!grp_mem_reserve(ed, ed->grp_mem_n + 1)) break; ed->grp_mem[ed->grp_mem_n] = T->top[i]; ed->grp_mem_pos[ed->grp_mem_n][0] = b->x; ed->grp_mem_pos[ed->grp_mem_n][1] = b->y; @@ -4952,10 +5070,16 @@ static void render_workspace(Ed* ed, TinyBlocks_RenderableBlock* rb) { rb_text_c(rb, WS_X + (WS_W - tw(hint, FS_UI))*0.5f, WS_Y + WS_H*0.45f, hint, COL_TEXT_DIM, FS_UI); } + ed_cull_pane(ed, true, WS_X, WS_Y, WS_W, WS_H); for (int i = 0; i < CT.top_n; i++) { if (ed->state == ES_DRAG && CT.top[i] == ed->drag_bi) continue; + /* pilha inteira fora da vista: nem comeca a desenhar */ + float x0, y0, x1, y1; + stack_bounds(&CT, CT.top[i], &x0, &y0, &x1, &y1); + if (x1 + ox < WS_X || x0 + ox > WS_X + WS_W || y1 + oy < WS_Y || y0 + oy > WS_Y + WS_H) continue; render_chain(ed, rb, &CT, CT.top[i], ox, oy); } + ed_cull_pane(ed, false, 0, 0, 0, 0); render_snap(ed, rb, ox, oy); ax_workspace(ed, ox, oy); if (ed->bubble_bi >= 0 && CT.ws[ed->bubble_bi].used) { /* balao com o valor do reporter */ @@ -5848,7 +5972,7 @@ static void compute_snap(Ed* ed) { if (shape_is_value(ds)) { /* Repórter: o lado esquerdo procura um campo de entrada */ float px = d->x, py = d->y + d->h*0.5f; - for (int i = 0; i < MAX_WS; i++) { + for (int i = 0; i < T->ws_n; i++) { EdBlock* B = &T->ws[i]; if (!B->used || B->dragging || !B->type) continue; for (int s = 0; s < input_count(B->type); s++) { @@ -5865,7 +5989,7 @@ static void compute_snap(Ed* ed) { int last = ed->drag_bi; while (T->ws[last].next >= 0) last = T->ws[last].next; bool drag_cap = is_cap(T->ws[last].type); - for (int i = 0; i < MAX_WS; i++) { + for (int i = 0; i < T->ws_n; i++) { EdBlock* B = &T->ws[i]; if (!B->used || B->dragging) continue; Shape bs = shape_of(B->type); @@ -6830,7 +6954,7 @@ static void update_tooltip(Ed* ed, bool alt) { /* mantem aberto enquanto o mouse estiver sobre o tooltip ... */ if (in_rect(ed->mouse_x, ed->mouse_y, ed->tip_x, ed->tip_y, ed->tip_w, ed->tip_h)) return; /* ... ou sobre o proprio bloco de origem (permite soltar o Alt e clicar) */ - if (tab_class(&CT)->blocks && ed->tip_bi >= 0 && ed->tip_bi < MAX_WS && CT.ws[ed->tip_bi].used) { + if (tab_class(&CT)->blocks && ed->tip_bi >= 0 && ed->tip_bi < CT.ws_n && CT.ws[ed->tip_bi].used) { int hb = hit_ws(&CT, ed->mouse_x - WS_X + CT.ws_sx, ed->mouse_y - WS_Y + CT.ws_sy); if (hb == ed->tip_bi) return; } @@ -7499,9 +7623,24 @@ static bool editor_instance_init(TinyBlocks_Block* self, TinyBlocks* rt) { palette_rebuild(ed); tb_libman_init(rt); /* liga tinyblocks-api e adota as libs embutidas */ tb_libman_scan_defaults(); /* procura library.toml em libraries/ e ~/.tinyblocks */ - for (int i = 0; i < s_preload_n; i++) hotlib_load(ed, s_preload[i]); - s_preload_n = 0; + /* Argumentos da linha de comando: .so = library; projeto (.json, .txt...) = + abre; pasta = ignora com aviso (antes ia para o dlopen) */ + const char* open_path = NULL; + for (int i = 0; i < s_preload_n; i++) { + const char* a = s_preload[i]; + struct stat st; + if (stat(a, &st) == 0 && S_ISDIR(st.st_mode)) { + snprintf(ed->hot_status, sizeof(ed->hot_status), "Ignorado: %.120s é uma pasta, não um projeto nem uma library", a); + ed->hot_status_ok = false; + } else if (has_ext(a, ".so")) { + hotlib_load(ed, a); + } else { + open_path = a; /* o ultimo projeto da linha de comando */ + } + } seed_example(ed); + if (open_path) project_load(ed, open_path); + s_preload_n = 0; /* Configuracoes iniciais (store da tinyblocks-environ) */ if (tb_environ_count() == 0) { @@ -7523,9 +7662,12 @@ static void editor_instance_deinit(TinyBlocks_Block* self, TinyBlocks* rt) { * aqui só soltamos o que é do editor. */ bubble_clear(ed); for (int i = 0; i < ed->tab_n; i++) tab_doc_free(&ed->tabs[i]); + tab_doc_free(&ed->fly); /* pool da paleta */ free(ed->fdlg.ents); free(ed->sbp_text); free(ed->run_blocks); + free(ed->grp_mem); + free(ed->grp_mem_pos); for (int u = 0; u < ed->user_block_n; u++) free(ed->user_blocks[u].snap); tb_libman_shutdown(); tb_a11y_tree_free(ed->ax_tree); diff --git a/libraries/tinyblocks-editor/src/tb_editor_mcp.c b/libraries/tinyblocks-editor/src/tb_editor_mcp.c index 12bb6f0..04311b2 100644 --- a/libraries/tinyblocks-editor/src/tb_editor_mcp.c +++ b/libraries/tinyblocks-editor/src/tb_editor_mcp.c @@ -57,7 +57,7 @@ static Tab* arg_block_tab(Ed* ed, TbMcpRequest* rq, int* idx) { return &ed->tabs[t]; } -static bool block_ok(Tab* T, int bi) { return bi >= 0 && bi < MAX_WS && T->ws[bi].used; } +static bool block_ok(Tab* T, int bi) { return bi >= 0 && bi < T->ws_n && T->ws[bi].used; } static int arg_block(TbMcpRequest* rq, Tab* T, const char* key) { if (!tb_mcp_req_has(rq, key)) { tb_mcp_req_error(rq, "Falta o argumento \"%s\"", key); return -1; } @@ -317,8 +317,8 @@ static void t_list_stacks(void* user, TbMcpRequest* rq) { Tab* T = arg_block_tab(ed, rq, &ti); if (!T) return; layout_tab(T); - int order[MAX_WS]; - int n = stacks_sorted(T, order); + int* order = T->top_n > 0 ? (int*)malloc((size_t)T->top_n * sizeof(int)) : NULL; + int n = order ? stacks_sorted(T, order) : 0; char* text = NULL; size_t len = 0, cap = 0; text_add(&text, &len, &cap, "Aba %d \"%s\": %d pilha(s)\n\n", ti, T->name, n); @@ -326,6 +326,7 @@ static void t_list_stacks(void* user, TbMcpRequest* rq) { for (int i = 0; i < n; i++) jpush(arr, stack_json(ed, T, order[i], &text, &len, &cap)); tb_mcp_req_text(rq, "%s", text ? text : ""); free(text); + free(order); TinyBlocks_JsonValue* o = tb_json_object(); jset(o, "tab", tb_json_number(ti)); jset(o, "stacks", arr); diff --git a/libraries/tinyblocks-pen/src/tb_pen.c b/libraries/tinyblocks-pen/src/tb_pen.c index 15381f2..8bee569 100644 --- a/libraries/tinyblocks-pen/src/tb_pen.c +++ b/libraries/tinyblocks-pen/src/tb_pen.c @@ -88,8 +88,9 @@ static bool point_at(const TinyBlocks_JsonValue* arr, uint32_t i, float* x, floa static void eval_draw(TinyBlocks_Block* self, TinyBlocks* rt) { TinyBlocks_Value v = tb_block_get_input(self, rt, 0); float x = (float)tb_block_input_number(self, rt, 1, 0), y = (float)tb_block_input_number(self, rt, 2, 0); + float zoom = (float)tb_block_input_number(self, rt, 3, 1); if (v.kind == TB_VALUE_IMAGE && v.as.image) { - tb_stage_image(v.as.image, x, y); + tb_stage_image_zoom(v.as.image, x, y, zoom); } else if (v.kind == TB_VALUE_JSON && v.as.json && tb_json_kind(v.as.json) == TB_JSON_ARRAY) { uint32_t n = tb_json_array_length(v.as.json); float lx = 0, ly = 0; @@ -148,7 +149,7 @@ static bool pen_init(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib) { TB_BLOCK_META("Stage.Text", "eval_text", "Escreve um texto no palco"); TB_BLOCK_META("Stage.Draw", "eval_draw", - "Desenha a imagem ou a lista de pontos que vier de outro bloco"); + "Desenha a imagem (com zoom opcional) ou a lista de pontos que vier de outro bloco"); TB_BLOCK_META("Stage.ImageByName", "eval_image_name", "Desenha no palco a imagem com esse nome"); TB_BLOCK_META("Stage.ImageByNumber", "eval_image_number", @@ -163,7 +164,7 @@ static bool pen_init(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib) { static const TinyBlocks_SlotDesc circ[] = {{"x", TB_VALUE_REAL}, {"y", TB_VALUE_REAL}, {"raio", TB_VALUE_REAL}}; static const TinyBlocks_SlotDesc text[] = {{"texto", TB_VALUE_TEXT}, {"x", TB_VALUE_REAL}, {"y", TB_VALUE_REAL}}; static const TinyBlocks_SlotDesc img_name[] = {{"nome", TB_VALUE_TEXT}, {"x", TB_VALUE_REAL}, {"y", TB_VALUE_REAL}}; - static const TinyBlocks_SlotDesc draw[] = {{"imagem", TB_VALUE_NONE}, {"x", TB_VALUE_REAL}, {"y", TB_VALUE_REAL}}; + static const TinyBlocks_SlotDesc draw[] = {{"imagem", TB_VALUE_NONE}, {"x", TB_VALUE_REAL}, {"y", TB_VALUE_REAL}, {"escala", TB_VALUE_REAL}}; static const TinyBlocks_SlotDesc img_num[] = {{"numero", TB_VALUE_INTEGER}, {"x", TB_VALUE_REAL}, {"y", TB_VALUE_REAL}}; return reg(rt, lib, "Stage.Clear", NULL, 0, eval_clear) @@ -174,7 +175,7 @@ static bool pen_init(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib) { && reg(rt, lib, "Stage.Rect", rect, 4, eval_rect) && reg(rt, lib, "Stage.Circle", circ, 3, eval_circle) && reg(rt, lib, "Stage.Text", text, 3, eval_text) - && reg(rt, lib, "Stage.Draw", draw, 3, eval_draw) + && reg(rt, lib, "Stage.Draw", draw, 4, eval_draw) && reg(rt, lib, "Stage.ImageByName", img_name, 3, eval_image_name) ; (void)img_num; } diff --git a/libraries/tinyblocks-scratchblocks/src/tb_scratchblocks.c b/libraries/tinyblocks-scratchblocks/src/tb_scratchblocks.c index a642288..56bc5ee 100644 --- a/libraries/tinyblocks-scratchblocks/src/tb_scratchblocks.c +++ b/libraries/tinyblocks-scratchblocks/src/tb_scratchblocks.c @@ -490,7 +490,7 @@ static void indent(Sb* out, int depth) { } static void render_chain(const Models* M, const TbBpTab* tab, int bi, int depth, Sb* out) { - for (int c = bi; c >= 0 && c < TB_BP_MAX_WS && tab->blocks[c].used; c = tab->blocks[c].next) { + for (int c = bi; c >= 0 && c < tab->blocks_n && tab->blocks[c].used; c = tab->blocks[c].next) { const TbBpBlock* b = &tab->blocks[c]; int sh = block_shape(M, b->type); indent(out, depth); @@ -512,10 +512,11 @@ char* tb_scratchblocks_export(const TbBpTab* tab, const TbSbContext* cx) { Models M = models_load(cx); if (!M.m) return NULL; /* pilhas de cima para baixo */ - int order[TB_BP_MAX_WS], n = 0; + int* order = tab->top_n > 0 ? (int*)malloc((size_t)tab->top_n * sizeof(int)) : NULL; + int n = 0; for (int i = 0; i < tab->top_n; i++) { int bi = tab->top[i]; - if (bi < 0 || bi >= TB_BP_MAX_WS || !tab->blocks[bi].used) continue; + if (bi < 0 || bi >= tab->blocks_n || !tab->blocks[bi].used || !order) continue; int k = n++; while (k > 0 && tab->blocks[order[k - 1]].y > tab->blocks[bi].y) { order[k] = order[k - 1]; k--; } order[k] = bi; @@ -526,6 +527,7 @@ char* tb_scratchblocks_export(const TbBpTab* tab, const TbSbContext* cx) { if (i) sb_str(&out, "\n"); render_chain(&M, tab, order[i], 0, &out); } + free(order); free(M.m); return out.p; } diff --git a/src/tb_stage.c b/src/tb_stage.c index 748720c..11121b5 100644 --- a/src/tb_stage.c +++ b/src/tb_stage.c @@ -105,14 +105,19 @@ void tb_stage_text(const char* text, float x, float y) { } } -bool tb_stage_image(const TinyBlocks_Image* img, float x, float y) { +bool tb_stage_image_zoom(const TinyBlocks_Image* img, float x, float y, float zoom) { if (!img) return false; StageCmd* c = push(SC_IMAGE); if (!c) return false; c->a = x; c->b = y; + c->d = zoom > 0.f ? zoom : 1.f; c->img = img; return true; } + +bool tb_stage_image(const TinyBlocks_Image* img, float x, float y) { + return tb_stage_image_zoom(img, x, y, 1.f); +} bool tb_stage_image_named(const char* name, float x, float y) { return tb_stage_image(tb_image_store_get(name), x, y); } @@ -178,7 +183,8 @@ bool tb_stage_render(TinyBlocks_RenderableBlock* rb) { const TinyBlocks_Image* im = c->img; int iw = tb_image_width(im), ih = tb_image_height(im); if (iw > 0 && ih > 0) { - float dw = iw * sc, dh = ih * sc; + float z = c->d > 0.f ? c->d : 1.f; + float dw = iw * sc * z, dh = ih * sc * z; tb_draw_image(rb, SX(c->a) - dw * 0.5f, SY(c->b) - dh * 0.5f, dw, dh, im); } break; diff --git a/tests/blueprint_test.c b/tests/blueprint_test.c index 8d02174..84bac5d 100644 --- a/tests/blueprint_test.c +++ b/tests/blueprint_test.c @@ -103,6 +103,81 @@ int main(void) { free(csv); tb_blueprint_free(bp); + char err2[160] = ""; + + /* -- aba grande: muito mais que o limite antigo (256 blocos) -- */ + { + const int N = 5000; + TbBlueprint* big = tb_blueprint_new(); + TbBpTab* T = tb_blueprint_tab(big, tb_blueprint_add_tab(big, "Grande", false)); + int prev = -1; + for (int i = 0; i < N; i++) { + int bi = tb_blueprint_alloc_block(T); + if (i == 0) tb_blueprint_top_add(T, bi); + snprintf(T->blocks[bi].type, sizeof(T->blocks[bi].type), "Variables.Change"); + snprintf(T->blocks[bi].in_text[0], 64, "cont"); + if (prev >= 0) tb_blueprint_link(T, prev, TB_BP_REL_NEXT, bi); + prev = bi; + } + CHECK(prev == N - 1 && T->blocks_n == N, "aba grande: 5000 blocos em sequencia"); + char* j = tb_blueprint_serialize(big, TB_BP_FMT_JSON, false); + TbBlueprint* back = j ? tb_blueprint_parse(j, TB_BP_FMT_JSON, err2, sizeof(err2)) : NULL; + CHECK(back != NULL, "aba grande: ida e volta em JSON"); + if (back) { + TbBpTab* B = &back->tabs[0]; + int n = 0; + for (int i = 0; i < B->blocks_n; i++) if (B->blocks[i].used) n++; + CHECK(n == N, "aba grande: os 5000 blocos voltam inteiros"); + CHECK(B->blocks[N-1].used && B->blocks[N-2].next == N - 1, "aba grande: vinculos do fim preservados"); + CHECK(B->top_n == 1 && B->top[0] == 0, "aba grande: topo preservado"); + tb_blueprint_free(back); + } + free(j); + tb_blueprint_free(big); + } + + /* -- indices esparsos e o teto por aba -- */ + { + TbBlueprint* sp = tb_blueprint_new(); + TbBpTab* T = tb_blueprint_tab(sp, tb_blueprint_add_tab(sp, "Esparso", false)); + TbBpBlock* far = tb_blueprint_tab_slot(T, 3000); + CHECK(far != NULL && T->blocks_n == 3001, "indice esparso (3000) cresce o vetor ate ele"); + if (far) { far->used = true; snprintf(far->type, sizeof(far->type), "Events.WhenRun"); tb_blueprint_top_add(T, 3000); } + char* j = tb_blueprint_serialize(sp, TB_BP_FMT_JSON, false); + TbBlueprint* back = j ? tb_blueprint_parse(j, TB_BP_FMT_JSON, err2, sizeof(err2)) : NULL; + CHECK(back && back->tabs[0].blocks_n == 3001 && back->tabs[0].blocks[3000].used, + "indice esparso sobrevive ao arquivo"); + if (back) tb_blueprint_free(back); + free(j); + CHECK(tb_blueprint_tab_slot(T, TB_BP_MAX_WS) == NULL, "indice no teto (65536) e recusado"); + CHECK(tb_blueprint_tab_slot(T, -1) == NULL, "indice negativo e recusado"); + tb_blueprint_free(sp); + + /* arquivo com indice fora do teto: ignora, sem estourar */ + const char* js = "{\"format\":\"tinyblocks-project\",\"version\":2,\"cur_tab\":0,\"tabs\":[{" + "\"name\":\"Fim\",\"composite\":false,\"comp_id\":-1,\"color\":0,\"blocks\":[" + "{\"i\":99999,\"type\":\"Events.WhenRun\"}],\"top\":[0]}]," + "\"user_blocks\":[],\"variables\":[]}"; + TbBlueprint* ob = tb_blueprint_parse(js, TB_BP_FMT_JSON, err2, sizeof(err2)); + CHECK(ob && ob->tab_count == 1, "bloco com indice fora do teto nao quebra a leitura"); + if (ob) tb_blueprint_free(ob); + } + + /* -- variaveis: o limite era 64 -- */ + { + TbBlueprint* vp = tb_blueprint_new(); + tb_blueprint_add_tab(vp, "Vars", false); + char nm[32]; + for (int i = 0; i < 300; i++) { snprintf(nm, sizeof(nm), "v%d", i); tb_blueprint_var_set_text(vp, nm, "1"); } + char* vj = tb_blueprint_serialize(vp, TB_BP_FMT_JSON, false); + TbBlueprint* vb = vj ? tb_blueprint_parse(vj, TB_BP_FMT_JSON, err2, sizeof(err2)) : NULL; + CHECK(vb && vb->var_n == 300, "300 variaveis sobrevivem ao arquivo (o limite era 64)"); + CHECK(vb && strcmp(vb->vars[299].name, "v299") == 0, "ultima variavel preservada"); + if (vb) tb_blueprint_free(vb); + free(vj); + tb_blueprint_free(vp); + } + printf(fails ? "\n%d FALHA(S)\n" : "\nTUDO OK\n", fails); return fails != 0; } diff --git a/tests/editor_harness.c b/tests/editor_harness.c index 9e802e0..a9ff6ed 100644 --- a/tests/editor_harness.c +++ b/tests/editor_harness.c @@ -1317,6 +1317,78 @@ int main(void) { t = mcp("ui_type", "{\"key\":\"escape\"}", &err, NULL); CHECK(!err && ax_in(0, TB_A11Y_DIALOG, "Configurações") < 0, "mcp: ui_type aperta Esc e fecha"); free(t); + + /* colar de uma vez mais blocos que o limite antigo por aba (256) */ + { + size_t cap = 400 * 40 + 64; + char* big = (char*)malloc(cap); + size_t p = 0; + p += snprintf(big + p, cap - p, "{\"code\":\"when flag clicked\\n"); + for (int i = 0; i < 300; i++) p += snprintf(big + p, cap - p, "change [colados v] by (1)\\n"); + p += snprintf(big + p, cap - p, "\",\"x\":40,\"y\":600}"); + t = mcp("add_scratchblocks", big, &err, NULL); + free(big); + CHECK(!err && ws_count("adicione (1) a (colados)") >= 300, + "mcp: cola 300 blocos numa aba (o limite antigo era 256)"); + free(t); + } + } + + /* 14. Aba grande: mais blocos que o limite antigo (256): carrega, roda e salva */ + { + const int N = 600; + const char* bigp = "/tmp/tb_harness_big.json"; + remove(bigp); + FILE* bf = fopen(bigp, "wb"); + CHECK(bf != NULL, "aba grande: projeto de teste escrito"); + if (bf) { + fputs("{\"format\":\"tinyblocks-project\",\"version\":2,\"cur_tab\":0," + "\"tabs\":[{\"name\":\"Grande\",\"composite\":false,\"comp_id\":-1,\"color\":0,\"blocks\":[", bf); + fprintf(bf, "{\"i\":0,\"type\":\"Events.WhenRun\",\"x\":40,\"y\":40,\"next\":1}"); + for (int i = 1; i <= N; i++) + fprintf(bf, ",{\"i\":%d,\"type\":\"Variables.Change\",\"parent\":%d,\"prel\":0,\"next\":%d," + "\"in_text\":[\"cont\",\"1\"]}", i, i - 1, i + 1); + fprintf(bf, ",{\"i\":%d,\"type\":\"IO.Print\",\"parent\":%d,\"prel\":0," + "\"in_text\":[\"cont\",\"\"]," + "\"args\":[-1,%d,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]}", N + 1, N, N + 2); + fprintf(bf, ",{\"i\":%d,\"type\":\"Variables.Get\",\"parent\":%d,\"prel\":5," + "\"in_text\":[\"cont\"]}", N + 2, N + 1); + fputs("],\"top\":[0]}],\"user_blocks\":[]," + "\"variables\":[{\"name\":\"cont\",\"kind\":0,\"num\":0,\"text\":\"\"}]}", bf); + fclose(bf); + } + ax_do(menu_btn("Abrir"), TB_A11Y_ACT_ACTIVATE); + type_path(bigp); + frame(0, 0, 0, 0, 0, 0, NULL); + CHECK(ax_in(ax_in(0, TB_A11Y_TAB_LIST, "Abas"), TB_A11Y_TAB, "Grande") >= 0, + "aba grande: abre o projeto de 602 blocos"); + CHECK(ws_count("adicione (1) a (cont)") >= N, + "aba grande: os 600 blocos entram na área de scripts"); + { + /* a area de scripts e desenhada antes do palco: sem culling os + * blocos fora da vista comem o teto de comandos e o palco some */ + int stage = ax_in(pane("Palco"), TB_A11Y_CANVAS, "Palco"); + CHECK(stage >= 0 && drawn_count(TB_DRAW_FILL_RECT, stage) > 0, + "aba grande: o palco continua desenhado (culling dos blocos fora da vista)"); + CHECK(pane("Saída") >= 0 && ncmd < TB_DRAW_CMD_CAP, + "aba grande: os comandos de desenho não estouram o teto"); + } + flag(); + for (int i = 0; i < 4; i++) frame(0, 0, 0, 0, 0, 0, NULL); + CHECK(console_has("cont = 600"), "aba grande: o script roda inteiro (a VM passa do bloco 256)"); + stop(); + + const char* bigp2 = "/tmp/tb_harness_big2.json"; + remove(bigp2); + ax_do(menu_btn("Salvar"), TB_A11Y_ACT_ACTIVATE); + type_path(bigp2); + CHECK(toast_has("Projeto salvo"), "aba grande: salva o projeto"); + ax_do(menu_btn("Abrir"), TB_A11Y_ACT_ACTIVATE); + type_path(bigp2); + frame(0, 0, 0, 0, 0, 0, NULL); + CHECK(ws_count("adicione (1) a (cont)") >= N, "aba grande: volta inteira do arquivo salvo"); + remove(bigp); + remove(bigp2); } tinyblocks_deinit(&rt); diff --git a/tests/scratchblocks_test.c b/tests/scratchblocks_test.c index abd0c37..340a839 100644 --- a/tests/scratchblocks_test.c +++ b/tests/scratchblocks_test.c @@ -35,6 +35,9 @@ static const TbSbContext CX = { s_labels, 2, shape, slot_kind, category, NULL }; static TbBpTab* fresh(void) { return calloc(1, sizeof(TbBpTab)); } +/* a aba tem pool dinamico desde o limite de 65536 blocos */ +static void drop(TbBpTab* t) { if (!t) return; tb_blueprint_tab_free(t); free(t); } + static const char* SCRIPT = "[scratchblocks]\n" "when flag clicked\n" @@ -116,7 +119,7 @@ int main(void) { tb_scratchblocks_import(txt ? txt : "", t2, &CX, warn, sizeof(warn)); char* txt2 = tb_scratchblocks_export(t2, &CX); CHECK(txt2 && txt && !strcmp(txt, txt2), "ida e volta (exportar(importar(texto))) é estável"); - free(txt); free(txt2); free(t2); free(t); + free(txt); free(txt2); drop(t2); drop(t); /* -- blocos só do TinyBlocks: rótulo em português + ::categoria --- */ t = fresh(); @@ -139,14 +142,14 @@ int main(void) { CHECK(txt && strstr(txt, "if <[/tmp] é pasta? :: extension> then\n"), "booleano do TinyBlocks dentro do if"); if (txt && !strstr(txt, "if <[/tmp] é pasta? :: extension> then\n")) printf("---- obtido:\n%s----\n", txt); CHECK(txt && strstr(txt, "forever\n set pen size to (4)\nend\n"), "sempre (tampa) com corpo"); - free(txt); free(t); + free(txt); drop(t); /* -- linha desconhecida: avisa e segue --- */ t = fresh(); n = tb_scratchblocks_import("when flag clicked\nvoe para a lua\nerase all\n", t, &CX, warn, sizeof(warn)); CHECK(n == 1 && strstr(warn, "linha 2"), "linha desconhecida gera aviso com o número da linha"); CHECK(!strcmp(ty(t, t->blocks[t->top[0]].next), "Stage.Clear"), "e o resto continua sendo importado"); - free(t); + drop(t); /* -- texto com colchetes é escapado --- */ t = fresh(); @@ -154,7 +157,7 @@ int main(void) { CHECK(!strcmp(t->blocks[t->top[0]].in_text[0], "a ] b"), "\\] dentro de [ ] é texto"); txt = tb_scratchblocks_export(t, &CX); CHECK(txt && !strcmp(txt, "say [a \\] b]\n"), "exporta escapando o ]"); - free(txt); free(t); + free(txt); drop(t); if (fails) printf("\n%d FALHA(S)\n", fails); else printf("\nTUDO OK\n");