{"id":42147838,"url":"https://github.com/peter-mount/teletextc64","last_synced_at":"2026-01-26T18:00:38.568Z","repository":{"id":48090496,"uuid":"354890923","full_name":"peter-mount/teletextc64","owner":"peter-mount","description":"Emulator for the BBC Micro's Mode 7 for the Commodore C64","archived":false,"fork":false,"pushed_at":"2021-04-06T19:28:07.000Z","size":89,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-06T21:38:41.322Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Assembly","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/peter-mount.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}},"created_at":"2021-04-05T16:02:23.000Z","updated_at":"2022-07-21T20:55:57.000Z","dependencies_parsed_at":"2022-08-12T18:20:54.708Z","dependency_job_id":null,"html_url":"https://github.com/peter-mount/teletextc64","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/peter-mount/teletextc64","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-mount%2Fteletextc64","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-mount%2Fteletextc64/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-mount%2Fteletextc64/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-mount%2Fteletextc64/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peter-mount","download_url":"https://codeload.github.com/peter-mount/teletextc64/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-mount%2Fteletextc64/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28784093,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T13:55:28.044Z","status":"ssl_error","status_checked_at":"2026-01-26T13:55:26.068Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2026-01-26T18:00:21.446Z","updated_at":"2026-01-26T18:00:38.555Z","avatar_url":"https://github.com/peter-mount.png","language":"Assembly","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Teletext Emulator for the C64\nThis directory contains an emulator of the BBC Micro's Mode 7 teletext display mode for the Commodore C64.\n\n![Teletext Test Card on Vice](testcard.png)\n\nThe emulator consists of a small \u003c3K driver file loaded at \u0026C000 in the C64 address map.\nIt exposes a set of routines at that address from which a user program can then use to\ninteract with the teletext screen.\n\nThe driver is not compatible with Commodore Basic due to Zero page requirements.\n\nTo use the driver you need to first call teletextInit (\u0026C000) then one of the provided\nroutines, usually oswrch \u0026 writeString.\n\n## API\nThe following are the public entry points into the driver\n\n### C000 Initialisation\n\nTo initialise the screen you need to call the routine at \u0026C000.\nThis will configure the C64's screen to show a blank black screen ready for use.\n\n### C003 osascii\nNamed after the BBC MOS equivalent routine, this will pass the character in A to oswrch\nunless it's a CR (\u00260D/13) in which case it calls osnewl to move the cursor to the start\nof the next line.\n### C007 osnewl\nNamed after the BBC MOS equivalent routine, this moves the cursor to the start of the next\nline. This routine actually just sends the 2 byte LF,CR sequence (\u00260A,\u00260D) to oswrch.\n\n### C00E oswrch\n\nNamed after the BBC MOS equivalent routine, this takes a character in the Accumulator\nand displays it on the screen.\n\nThis routine accepts the same VDU control characters that the BBC does, although only a few\nof them are actually implemented, all of the multiple character sequence codes require the\nsame number so remain compatible with the BBC Micro.\n\nThe ones implemented are:\n\n| Char  | Name | Action |\n| ----- | ---- | ------ |\n| 00  0 | NOP | Does nothing |\n| 08  8 | BS | Backspace cursor one character |\n| 09  9 | HT | Advance cursor one character |\n| 0A 10 | LF | Move cursor down one line |\n| 0B 11 | VT | Move cursor up one line |\n| 0C 12 | FF | Clear screen |\n| 0D 13 | CR | Move cursot to start of current line |\n| 1E 30 | RS | Move cursor to home at top left of the screen |\n| 1F 31 | US | Move text cursor to X, Y where coordinates are provided by the next 2 bytes submitted to oswrch |\nAll other codes that require multiple bytes are only supported to the point that oswrch will\nconsume those extra bytes. This has been done to allow code to be ported from the BBC to the C64 with minimal changes.\n\n### C011 writeString\n\nThis routine will write a null (\u002600) terminated string to oswrch. Unlike most implementations this routine knows\nthe internal state of oswrch so that it only terminates on a null if there are no more pending bytes required by oswrch.\n\nFor example: the sequence 31,0,10 will position the cursor at column 0 of row 10 but will not terminate the string.\n\nHere's an example from the [departures8bit](https://github.com/peter-mount/departures8bit) project:\n\n    .writeTeletextBanner\n        LDX #\u003cbanner\n        LDY #\u003ebanner\n        JMP writeString\n    .banner\n        EQUS 30, 134, \"departureboards.mobi\", 13, 10\n        EQUS 132, 157, 135, 141, 31, 9, 1, \"Live UK Departure Boards\"\n        EQUS 132, 157, 135, 141, 31, 9, 2, \"Live UK Departure Boards\"\n        EQUS 10, 130, \"Please wait whilst loading completes...\", 0\n\n### C014 refreshScreen\n\nThis routine will refresh the screen with the contents of the framebuffer. It's useful if the framebuffer was updated\noutside of the driver - for example by loading a screen directly from disk. In that instance refreshScreen needs to be\ncalled, so the actual screen is displayed.\n\n### C017 clearStatus\n\nThe status area is the right half of the top line. Usually used in viewdata style applications\nto show a status, clock or the page identity of what's visible.\n\nThis routine clears just that half of the line.\n\n### C01A showStatus\n\nThe status area is the right half of the top line. Usually used in viewdata style applications\nto show a status, clock or the page identity of what's visible.\n\nThis routine writes the null terminated string pointed to by XY into the status area.\nThe string is limited to just that area so will be truncated if too long but if it's short\nthen the line will be padded with spaces.\nThe string will be left justified.\n\n## Memory Map\nThe driver requires a total of 13K of memory + 16 bytes of zero page:\n\n| Address range | Contents |\n| ------------- | -------- | \n| 0080 - 008F | Zero page workspace |\n| 0400 - 07E7 | Teletext screen buffer |\n| 07E8 - 07FF | Workspace |\n| C000 - CBFF | Teletext driver code |\n| CC00 - CFFF | VIC-II Colour ram |\n| E000 - FFFF | VIC-II Bitmap |\n\nDue to requiring zero page, the driver is incompatible with Basic.\n\n## Implementation\n\nThe following features are implemented:\n\n### Text colour controls\nWriting characters 129 to 135 will cause subsequent characters to change to the defined\ncolour - up to the next colour control character.\n\n| Char   | Action |\n| ------ | ------ |\n| 80 128 | Alphanumeric black* |\n| 81 129 | Alphanumeric red |\n| 82 130 | Alphanumeric green |\n| 83 131 | Alphanumeric yellow |\n| 84 132 | Alphanumeric blue |\n| 85 133 | Alphanumeric magenta |\n| 86 134 | Alphanumeric cyan |\n| 87 135 | Alphanumeric white |\n| 9C 156 | Black background |\n| 9D 157 | New background |\n\nNote: \u002680 (128) is not supported on the BBC Micro but is defined in latter Teletext standards.\nIt's implemented here as it required no coding to implement.\nNot implementing it would have increased the size of the driver.\n\n### Background colour\n\n| Char   | Action |\n| ------ | ------ |\n| 9C 156 | Black background |\n| 9D 157 | New background |\n\nCharacter 157 will make the background colour that of the current text colour.\ne.g. the sequence 132, 157, 135 will set the following text to White with a Blue background.\n\nNote: One of the unusual ways Teletext works is that if you change the character before the 157 to another\nvalue then the background changes automatically to the new colour without needing to send the 157 again.\nIf the new character is not a colour one, then the colour will be that of the preceding character.\nThis will flow back to the beginning of that line.\n\nAll lines begin with White text \u0026 a Black background.\n\nCharacter 156 turns the background off - so to black.\n\n### Graphics controls\n\nWriting characters 145 to 151 will cause subsequent characters to change to the defined\ncolour - up to the next colour control character. The characters would also be shown as\nsixel (6 pixel) graphics characters.\n\n| Char   | Action |\n| ------ | ------ |\n| 90 144 | Graphics black* |\n| 91 145 | Graphics red |\n| 92 146 | Graphics green |\n| 93 147 | Graphics yellow |\n| 94 148 | Graphics blue |\n| 95 149 | Graphics magenta |\n| 96 150 | Graphics cyan |\n| 97 151 | Graphics white |\n| 99 153 | Contiguous graphics |\n| 9A 154 | Separated graphics |\n\nNote: \u002690 (144) is not supported on the BBC Micro but is defined in latter Teletext standards.\nIt's implemented here as it required no coding to implement.\nNot implementing it would have increased the size of the driver.\n\n### Unimplemented codes\nThe following codes are not implemented.\n\n| Char   | Action |\n| ------ | ------ |\n| 88 136 | Flash |\n| 89 137 | Steady |\n| 98 152 | Conceal |\n| 9B 155 | Toggle between character sets* |\n| 9E 158 | Hold graphics |\n| 9F 159 | Release graphics |\n\nNote: Flash (136) \u0026 Steady (137) are unlikely to be implemented due to no support for changing colours in VIC-II chip.\n\n155 is not implemented on the BBC micro but supported in BBC Basic (Windows 6.14a) and BBCSDL.\nAs we only have 1 character set available so that code will do nothing.\n\n### Implementation Quirks\nThese items apply due to our implementation:\n* Double height text presumes the top half will be on ODD rows and the bottom half on EVEN rows.\n* Graphics are not supported in Double height mode. They will appear at normal height.\n* As stated before the black Alpha (128) and Graphics (144) colours are implemented even though they are not supported on the BBC Micro.\n* Scrolling is not supported. When the bottom of the screen is reached the cursor will wrap to the top.\n* Text windows are not supported.\n* Writing direct to screen ram (\u00267C00 on BBC B, \u00260400 on the C64) will not cause the character to appear immediately. You need to call refreshScreen for it to appear.\n\n## Building\n\nTo build you will need gnumake, beebasm and vice installed - the latter for the c1541 tool to create a d64 disk image.\n\nRun make and it will assemble several files:\n\n| local filename | filename in disk image | contents |\n| -------- | ---------------------- | -------- |\n| testcard.d64 | | d64 disk image containing the other files |\n| teletext.prg | teletext | teletext emulator |\n| testcard.prg | testcard | Example test card as seen above |\n| splash.prg | splash | Graphics example of a train in teletext |\n\nTo use it in your own application, simply copy the teletext file from the disk image to your own image.\nLoad it using `LOAD \"teletext\",8,1` or the equivalent in assembly, see below.\n\nThen, in your own code then initialise it with `JSR \u0026C000` then use oswrch or writeString routines in your own code.\n\nTo view the test cards, simply load them in memory followed by a call to refreshScreen:\nRemember the initialise routine at \u0026C000 must have been called first.\n\n                LDA #8                      ; Logical file number\n                LDX #8                      ; Device 8 disk\n                LDY #1                      ; Load with address in file\n                JSR SETLFS\n            \n                JSR strLen                  ; Get filename length\n                LDA #8                      ; Filename length\n                LDX #\u003cfileName              ; SETNAM on filename\n                LDY #\u003efileName\n                JSR SETNAM\n            \n                LDA #0                      ; Flag LOAD\n                JSR LOAD                    ; Load into memory\n                JMP \u0026C014                   ; Refresh screen\n    .fileName   EQUS \"testcard\", 0\n\nEach of the provided examples are in PRG format so they will load at address \u00260400.\nThe call to refreshScreen simply refreshes the C64's actual screen with the correct representation\nfrom those files.\n\n## Character sets\n\nThere's now 3 character sets available which currently require a build to switch between:\n\n| source | Contents |\n| ------ | -------- |\n| charset1 | The default character set based on the original Mullard SAA5050 chip used in the BBC Micro |\n| charset2 | The default BBC character set used in Mode's 0..6 |\n| charset3 | charset2 with the teletext characters for 1/2, 1/4, 3/4 etc replacing the ASCII glyphs |\n\nTo change the character set in use just change the include at the end of teletext.asm.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-mount%2Fteletextc64","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeter-mount%2Fteletextc64","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-mount%2Fteletextc64/lists"}