{"id":16528374,"url":"https://github.com/danvk/gwbasic-decoder","last_synced_at":"2025-09-12T19:31:37.990Z","repository":{"id":66069038,"uuid":"131444079","full_name":"danvk/gwbasic-decoder","owner":"danvk","description":"Convert binary GW-BASIC programs back to text","archived":false,"fork":false,"pushed_at":"2019-09-20T22:22:38.000Z","size":26,"stargazers_count":37,"open_issues_count":0,"forks_count":4,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-12-29T23:03:55.651Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danvk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2018-04-28T21:05:38.000Z","updated_at":"2024-11-12T06:34:59.000Z","dependencies_parsed_at":"2023-05-19T09:00:14.446Z","dependency_job_id":null,"html_url":"https://github.com/danvk/gwbasic-decoder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danvk%2Fgwbasic-decoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danvk%2Fgwbasic-decoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danvk%2Fgwbasic-decoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danvk%2Fgwbasic-decoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danvk","download_url":"https://codeload.github.com/danvk/gwbasic-decoder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232780145,"owners_count":18575474,"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":[],"created_at":"2024-10-11T17:40:07.266Z","updated_at":"2025-01-06T20:00:10.063Z","avatar_url":"https://github.com/danvk.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gwbasic-decoder\n\n[GW-BASIC] (aka GWBASIC or Gee-Whiz Basic) was a BASIC interpreter developed by Microsoft and bundled with MS-DOS until the advent of [QBASIC] with MS-DOS 5.0. GW-BASIC stored programs in memory at a time when memory was very scarce. Hence it used a compact, binary representation of code. It used this same binary format for code saved on disk, which makes it hard to read GW-BASIC programs nowadays.\n\nOr at least it used to. Thanks to [this site][tokens], I was able to write a decoder in Python. Run your `.BAS` file through the script (see below) and you'll get a human-readable version of the program back out. Enjoy!\n\n## Example\n\n    $ python convert.py GAME.BAS\n     10 CLS\n     20 SCREEN 8\n     30 Y=320: X=100\n     40 A$=\"\": WHILE+ A$=\"\":A$=INKEY$:WEND\n     50 CIRCLE (Y,X),19,0\n     55 IF M\u003c\u003e1 AND RND\u003e.8 THEN GOSUB 160\n     60 IF A$=\"2\" THEN X=X+1\n     70 IF A$=\"8\" THEN X=X-1\n     80 IF A$=\"4\" THEN Y=Y-2\n     90 IF A$=\"6\" THEN Y=Y+2\n    100 IF A$=\"7\" THEN X=X-1: Y=Y-2\n    110 IF A$=\"9\" THEN X=X-1: Y=Y+2\n    120 IF A$=\"3\" THEN X=X+1: Y=Y+2\n    130 IF A$=\"1\" THEN X=X+1: Y=Y-2\n    140 CIRCLE (Y,X),19\n    143 FOR I=-18 TO 18\n    145 IF POINT(Y,X+I)=-1 THEN END\n    147 NEXT\n    150 GOTO 40\n    160 ON TIMER(1) GOSUB 200\n    170 TIMER ON\n    175 M=1: H=INT(1+RND*240)\n    180 RETURN\n    200 IF F=0 THEN R=12\n    210 LINE(G,H)-(R,H),10\n    220 F=1\n    230 R=R+622\n    240 IF R\u003e640 THEN F=0: M=0: TIMER OFF\n    250 RETURN\n\n## Complete type support\n\nThe output is exactly the same as in the original GW-Basic.\n\n    $ python convert.py TYPEDEMO.BAS\n    10 ' Single precision floats (32 bit)\n    20 A = 46.8: B = -1.09E-06: C = 3489!: D = 22.4822\n    30 ' Double precision floats (64 bit)\n    40 E# = 3.569D-39: F# = -.0001094327263526#: G# = 35#: H# = 78987654321.1234#\n    50 ' String, Integer, Octal, Hexadecimal\n    60 I$ = \"Hello World!\": J% = 1234: K = \u0026O347: L = \u0026H32F\n    70 REM Tokenized types, one-byte type, more octal and hex\n    80 PRINT 0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 63\n    90 PRINT \u0026O7234; \u0026O1702; \u0026O177777; \u0026O0; \u0026H3FB9; \u0026HFFFF; \u0026H0\n\n## Custom code page for the extended ASCII characters\n\nYou can specify an encoding in an argument:\n\n    $ python convert.py --encoding cp437 CODEPAGE.BAS\n    10 ' IBM Code Page 437\n    20 REM Årvíztürö tükörfúrógép\n    30 PRINT \"sin(α + ß) = sin(α)*cos(ß) + cos(α)*sin(ß)\"\n\nThe most common code pages of the DOS era:\n- cp437: The code page of the original IBM PC\n- cp850: Latin-1 (Some symbols and Greek characters in the cp437 got replaced with more latin letters.)\n- cp1252: Windows 1.0 -\u003e Windows 98\n- iso-8859-1: Western European encoding, early web standard\n\n[gw-basic]: http://en.wikipedia.org/wiki/GW-BASIC\n[qbasic]: http://en.wikipedia.org/wiki/QBASIC\n[tokens]: http://www.chebucto.ns.ca/~af380/GW-BASIC-tokens.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanvk%2Fgwbasic-decoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanvk%2Fgwbasic-decoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanvk%2Fgwbasic-decoder/lists"}