{"id":16134416,"url":"https://github.com/mrspeaker/ebas2bas","last_synced_at":"2025-10-06T00:18:15.043Z","repository":{"id":137019214,"uuid":"415234135","full_name":"mrspeaker/ebas2bas","owner":"mrspeaker","description":"Convert \"ebas\" files to standard C64 BASIC","archived":false,"fork":false,"pushed_at":"2021-10-17T02:42:05.000Z","size":63,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T15:51:40.734Z","etag":null,"topics":["basic","basic-programming","c64","commodore-64"],"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/mrspeaker.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2021-10-09T07:18:42.000Z","updated_at":"2021-10-17T02:42:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"09fcf6cd-59ac-40ed-9ec7-e5385dd856f7","html_url":"https://github.com/mrspeaker/ebas2bas","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mrspeaker/ebas2bas","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrspeaker%2Febas2bas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrspeaker%2Febas2bas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrspeaker%2Febas2bas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrspeaker%2Febas2bas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrspeaker","download_url":"https://codeload.github.com/mrspeaker/ebas2bas/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrspeaker%2Febas2bas/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278538931,"owners_count":26003476,"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","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["basic","basic-programming","c64","commodore-64"],"created_at":"2024-10-09T22:48:54.381Z","updated_at":"2025-10-06T00:18:15.005Z","avatar_url":"https://github.com/mrspeaker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"* EBAS2BAS\nC64 BASIC, with some lil' conveniences: no line numbers required, and some other helpful transformations. This tool converts /.ebas/ files to standard C64 BASIC as a /.bas/ file.\n\nWhat is an /.ebas/ file? It's a thing I made up, 'cause I am making a game which requires me to write /a lot/ of C64 BASIC, and I got annoyed at re-numbering things. Then I got carried away adding more features. *Unless you are me, you likely will have no use for this script*.\n\n[[https://user-images.githubusercontent.com/129330/136657907-99987639-f516-42a7-b2aa-4905a4704705.gif]]\n\nHere's an example of some \"eBASIC\":\n\n#+BEGIN_SRC basic\n  # Position sprites\n  for n=4 to 9:\n    poke v+n,n*0x14:\n  next\n\n  # Print some text\n  print \"{clear}\"\n  ~top\n   poke 0x286,n:\n   n=n+1\n   print \"coding is basic ...  \";\n   goto ~top\n#+END_SRC\n\nRunning ebas2bas generates BASIC:\n#+BEGIN_SRC basic\n  10 for n=4 to 9:poke v+n, n*20:next\n  20 print \"{clear}\"\n  30 poke 646,n:n=n+1\n  40 print \"coding is basic ...  \";\n  50 goto 30\n#+END_SRC\n\n** Usage\n\n#+BEGIN_SRC bash\nnode ebas2bas.js \u003cfilename\u003e\n#+END_SRC\n\nYou can omit the ~.ebas~ extension. The output will be the the same name, but with a ~.bas~ extension.\n\n** Transformations\n\n*** Line numbers \u0026 labels\n#+BEGIN_SRC basic\n   ~top\n   print \"i am the best \";\n   goto ~top\n#+END_SRC\n\n compiles to:\n\n#+BEGIN_SRC basic\n   10 print \"i am the best \";\n   20 goto 10\n#+END_SRC\n\n*** Support for hex and binary numbers\n\n Converts hex and binary numbers to decimal\n\n#+BEGIN_SRC\n   0x1f -\u003e 31\n   0b111 -\u003e 7\n   0b1000_0001 -\u003e 129\n#+END_SRC\n\n*** Comments\n\nComments with \"#\" are removed from the source code (You can still use REM comments if you want them to stay).\n\n#+BEGIN_SRC\n   poke 0xD020,1 # Make border white -\u003e poke 53280,1\n#+END_SRC\n\n*** Multi line source\n\nMost BASIC programs jam many statements onto a single line. To keep the source readable, you can use multiple lines - then any ending with \":\" will be concatenated.\n\n#+BEGIN_SRC basic\n   for n=0 to 62 :\n     read q :\n     poke 0x340+n,q :\n   next\n#+END_SRC\n\n compiles to:\n\n#+BEGIN_SRC basic\n   10 for n=0 to 62 :read q :poke 832+n,q :next\n#+END_SRC\n\n*** Include files\nExternal files can be included into the current source with ~{{ \"./path/to/file\" }}~. The contents of the file will be dumped in the first pass, so all further transformations (hex, macros, etc) will be applied to the included contents. Include files can also contain other includes (with no circular dependency testing, so becareful!).\n\nAs the include file is dumped directly, it can also be assembly code, or macros. If it's assembly, remember to wrap the include tag in an inline-assembler tag (see section ~inline assembler~) if needed. Eg: ~{{! {{ \"./test.asm\" }} !}}~.\n\n*** Macros\nMacros are javascript functions that return BASIC source code that is injected in the final listing. If the return value is an array, multiple lines will be injected. To define a macro, wrap a javascript function in ~{!~ and ~!}~ tags:\n#+BEGIN_SRC js\n{! rainbow = (str) =\u003e {\n  const cols = COLS.slice(1); // COLS = Magic array of color tokens\n  return str\n    .split(\"\")\n    .map((ch,i) =\u003e \"{\" + cols[i % cols.length] + \"}\" + ch)\n    .join(\"\");\n} !}\n#+END_SRC\nThis defines a macro called ~rainbow~ that splits an input string into characters, then changes the color of each character using the standard basic color codes (eg ~{wht},{red}~). To call a macro, wrap a function call in ~{{~ and ~}}~ tags:\n#+BEGIN_SRC basic\nprint \"hello, {{ rainbow(\"world\") }}!\"\nREM compiles to:\n10 print \"hello, {wht}w{red}o{cyn}r{pur}l{grn}d!\"\n#+END_SRC\n*** Inline assembler\nInline assembler can be compiled with [[http://www.theweb.dk/KickAssembler/Main.html][KickAssembler]], and the bytes are then injected into the BASIC listing via POKES and run with a SYS call.\n\n#+BEGIN_SRC asm\n{{!\"set screen colors via asm\"\n  *=$c000\n  lda #0\n  sta $d020\n  sta $d021\n  rts\n!}}\n#+END_SRC\n\nCompiles to:\n#+BEGIN_SRC basic\n10 rem set screen colors via asm\n20 for za = 0 to 8:read zb:poke 49152+za,zb:next za\n30 sys 49152\n40 data 169,0,141,32,208,141,33,208,96\n#+END_SRC\n\nThe title string is optional, and will be included in a REM statement if present. If you don't specify a base memory location (with the KickAssembler definition (eg, ~*=$c000~) it will use the default (I think it's ~$801~? Which is not good for BASIC!). But if you specify the base in your first inline asm block, subsequent blocks can continue on from the last address by putting a ~*~ after the opening tag.\n\nFor example, the above asm is located from ~$c000~ to ~$c008~ (49152-49160 decimal). If you start the next asm block with ~{{!*~, it will POKE the bytes into location ~$c009~ (49161 decimal).\n\n** Options\nSorry, no CLI options yet. Settings are defined in [[https://github.com/mrspeaker/ebas2bas/blob/main/ebas_config.json][ebas_config.json]]:\n\n#+BEGIN_SRC json\n{\n  \"LINE_SPACING\": 10,\n  \"OUTFILE_PATH\": \"./\",\n  \"KICKASSEMBLER_PATH\": \"/usr/lib/KickAssembler/\",\n}\n#+END_SRC\n\n- *LINE_SPACING* is how to sequentially number your source code. Default is 10, but you might just want 1 (or 5, or whatever).\n- *OUTFILE_PATH* indicates where to dump the output file. Default is in the current directory.\n- *KICKASSEMBLER_PATH* is the path to the KickAssembler compiler jar file if you want to do inline assembler.\n\n** Running .bas files on a C64\nMy use case is to convert the .ebas file to plain C64 BASIC, then compile /that/ into an optimised C64 ~.prg~ file with Egon Olsen's fantastic [[https://github.com/EgonOlsen71/basicv2][BASICv2]] ~mospeed~ java command line tool:\n\n#+BEGIN_SRC bash\n./mospeed.sh -target=test.prg test.bas\n#+END_SRC\n\nThe ~.prg~ file can then be loaded into Vice or another emulator (or, you know, run on a real Commodore 64!).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrspeaker%2Febas2bas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrspeaker%2Febas2bas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrspeaker%2Febas2bas/lists"}