{"id":17930436,"url":"https://github.com/remy/txt2bas","last_synced_at":"2025-03-24T04:31:16.382Z","repository":{"id":57383073,"uuid":"256716368","full_name":"remy/txt2bas","owner":"remy","description":"ZX Spectrum BASIC conversion tooling (specific support for NextBASIC)","archived":false,"fork":false,"pushed_at":"2024-07-09T18:51:42.000Z","size":597,"stargazers_count":20,"open_issues_count":4,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-19T01:59:32.828Z","etag":null,"topics":["nextbasic","spectrum-next"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/remy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"remy"}},"created_at":"2020-04-18T09:39:01.000Z","updated_at":"2024-12-19T23:40:15.000Z","dependencies_parsed_at":"2024-06-12T23:54:43.568Z","dependency_job_id":"fe9dca57-f083-4f46-972a-9dbf68d42994","html_url":"https://github.com/remy/txt2bas","commit_stats":{"total_commits":162,"total_committers":1,"mean_commits":162.0,"dds":0.0,"last_synced_commit":"a9f57c34d442e0b0da3b30690f7c83bbc6d1bc69"},"previous_names":[],"tags_count":85,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remy%2Ftxt2bas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remy%2Ftxt2bas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remy%2Ftxt2bas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remy%2Ftxt2bas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remy","download_url":"https://codeload.github.com/remy/txt2bas/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245211059,"owners_count":20578335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nextbasic","spectrum-next"],"created_at":"2024-10-28T21:13:25.348Z","updated_at":"2025-03-24T04:31:15.968Z","avatar_url":"https://github.com/remy.png","language":"JavaScript","readme":"# txt2bas and bas2txt - tooling for ZX Spectrum NextBASIC\n\nThis code is inspired by the [.txt2bas](https://gitlab.com/thesmog358/tbblue/-/blob/ef6dc4fd0f684349d16354d67d4f756db2994fdb/src/asm/dot_commands/txt2bas.asm) dot command on the ZX Spectrum Next (not that I could read the asm code!).\n\nThis project provides:\n\n- `txt2bas` command line tool\n- `bas2txt` command line tool\n- NextBASIC validation\n- library for BASIC and text manipulation, validation and renumbering\n\n## Installation\n\n[Node](https://nodejs.org/en/) and npm (included with node) are required to install and run the code.\n\nFor the command line tooling - this installs _both_ tools:\n\n```\nnpm install --global txt2bas\n```\n\n## Command line usage\n\nCommand line arguments are the same for both `txt2bas` and `bas2txt`:\n\n```\ntxt2bas -i source.txt -o result.bas # generate a 3dos basic file\nbas2txt -i source.bas -o result.txt # generates plain text\n```\n\nOmitting `-o` will print to `stdout`.\n\nBy default the generated file is a +3DOS format unless the output or input filename ends in `.tap` or using the format option `-f tap`:\n\n```\ntxt2bas -i source.txt -o result.tap # generates a tap file\n```\n\nThe command line can also read from `stdin` though this works best on `txt2bas` and not recommended for `bas2txt`.\n\nNote that `#autostart` directive is also supported.\n\n### Command line options\n\n- `-i FILENAME` - input filename\n- `-o FILENAME` - output filename\n- `-t` - (txt2bas only) test and validate the NextBASIC source\n- `-C` - (txt2bas only) strip comments (to reduce final size)\n- `-bank` - (txt2bas only) generate a BANK loadable result\n- `-A #n` - (txt2bas only) set autostart line to `#n`\n- `-f 3dos|tap` - set the output format\n- `-H`- omit the file header (either in output or in parsing input)\n- `-udg` - UDGs are used so encode with binary not utf8\n- `-tokens` - (txt2bas only) show parser tokens (for debugging)\n- `-h` - Show help options\n- `-v` - Show current version\n\n## Library API\n\nProblematically using the library exposes a number of paired functions:\n\n- `line2bas(String: line): Object\u003cUint8Array: basic, Number: lineNumber, Array: tokens, Number: length\u003e` - the byte data is contained in `result.basic`\n- `bas2line(Uint8Array: data): String` - expects to include the line number, line length and the line itself as bytes\n- `file2bas(String: source, Object\u003cString=3dos: format, filename=UNTITLED: String, validate=false: Boolean\u003e): Uint8Array` - results full byte array with correct format header, if `validate` is true, will throw on token errors\n- `bas2file(Uint8Array: source, String=3dos: format): String` - formatted BASIC text\n- `formatText(String: line): String` - processes the line through `line2bas` then `bas2line` to result the formatted line\n- `validateTxt(String: source): Array[String]` - parses each line collecting and returning any token errors\n- `plus3DOSHeader` and `tapHeader` - file headers for the appropriate data formats\n- `codes` an object lookup from NextBASIC numerical value to text value, ie. `0xf5 = 'PRINT'`\n- `statements(String: source): Array[Statement]` - returns the parsed statement which include `lineNumber` and `tokens` for each line.\n- `renumber(String: source, Object\u003cstart: Number, end: Number, step=10: Number, base=start: Number\u003e)` - renumbers source lines and `GO TO` line number targets.\n\n## Development\n\n- Currently the latest code uses node@21 (due to specific use of syntax)\n- To test with another project: `npm link`\n- For new features of language or validation changes, ensure a test is provided\n- txt2bas also support different NextOS versions, specified through `parser-version`\n\n## Licence\n\n- [MIT](https://rem.mit-license.org/)\n","funding_links":["https://github.com/sponsors/remy"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremy%2Ftxt2bas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremy%2Ftxt2bas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremy%2Ftxt2bas/lists"}