{"id":17703273,"url":"https://github.com/visrealm/vremutms9918","last_synced_at":"2025-04-13T00:11:36.523Z","repository":{"id":41745961,"uuid":"402684306","full_name":"visrealm/vrEmuTms9918","owner":"visrealm","description":"TMS9918A emulator library (C99)","archived":false,"fork":false,"pushed_at":"2024-05-22T02:11:58.000Z","size":3353,"stargazers_count":40,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-23T02:44:34.673Z","etag":null,"topics":["assembly","c","colecovision","creativision","emulator","graphics","hardware","msx","sprites","ti-99","ti99","tms9918","tms9918-emulation","tms9918a","tms9928","tms9929a","video"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/visrealm.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":"2021-09-03T07:28:19.000Z","updated_at":"2024-06-08T06:31:13.671Z","dependencies_parsed_at":"2023-11-18T23:23:52.418Z","dependency_job_id":"647bd848-4112-4ec6-a31a-495e8e449414","html_url":"https://github.com/visrealm/vrEmuTms9918","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/visrealm%2FvrEmuTms9918","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/visrealm%2FvrEmuTms9918/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/visrealm%2FvrEmuTms9918/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/visrealm%2FvrEmuTms9918/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/visrealm","download_url":"https://codeload.github.com/visrealm/vrEmuTms9918/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647287,"owners_count":21139086,"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":["assembly","c","colecovision","creativision","emulator","graphics","hardware","msx","sprites","ti-99","ti99","tms9918","tms9918-emulation","tms9918a","tms9928","tms9929a","video"],"created_at":"2024-10-24T20:22:21.414Z","updated_at":"2025-04-13T00:11:36.516Z","avatar_url":"https://github.com/visrealm.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vrEmuTms9918 - TMS9918 / TMS9918A / TMS9929A VDP Emulator\n\n\u003ca href=\"https://github.com/visrealm/vrEmuTms9918/actions/workflows/cmake-multi-platform.yml\"\u003e\u003cimg src=\"https://github.com/visrealm/vrEmuTms9918/actions/workflows/cmake-multi-platform.yml/badge.svg\"/\u003e\u003c/a\u003e\n\nTMS9918 emulator. Core engine written in C99. Zero dependencies.\n\nThe goal is to emulate all documented modes listed in the [TMS9918A/TMS9928A/TMS9929A datasheet](http://www1.cs.columbia.edu/~sedwards/papers/TMS9918.pdf)\n\n## Supported Modes\n\n* Graphics I (including sprites)\n* Graphics II (including sprites)\n* Multicolor mode (including sprites)\n* Text\n\n## Other features\n\n* 5th sprite\n* Sprite collisions\n* VSYNC interrupt\n* Individual scanline rendering\n\n## PICO9918\n\nThis library is also being used in the [PICO9918](https://github.com/visrealm/pico9918) project. A drop-in replacement for a physical TMS9918A powered by a Raspberry Pi Pico.\n\n\u003cimg src=\"https://github.com/visrealm/pico9918/raw/main/img/pico9918_v1_0_sm.png\" width=\"640px\"\u003e\n\nThe PICO9918 running in an original TI-99/4A:\n\n### Don't mess with Texas!\n[![PICO9918 Prototype - Don't mess with Texas](https://img.visualrealmsoftware.com/youtube/thumb/ljNRFKbOGJs)](https://youtu.be/ljNRFKbOGJs)\n\nSee [github.com/visrealm/pico9918](https://github.com/visrealm/pico9918)\n\n## Demos:\n\n#### Graphics Mode I Demo\n\u003cimg src=\"res/mode1demo.gif\" alt=\"Graphics Mode I Demo\" width=\"1279px\"\u003e\n\n#### Graphics Mode II Demo\n\u003cimg src=\"res/mode2demo.gif\" alt=\"Graphics Mode II Demo\" width=\"1279px\"\u003e\n\n#### Text Mode Demo\n\u003cimg src=\"res/textdemo.gif\" alt=\"Text Mode Demo\" width=\"1279px\"\u003e\n\n#### Multicolor Mode Demo\n\u003cimg src=\"res/mcdemo.gif\" alt=\"Multicolor Mode Demo\" width=\"1279px\"\u003e\n\n## Building\n\nvrEmuTms9918 uses the CMake build system\n\n#### Checkout repository\n\n```\ngit clone https://github.com/visrealm/vrEmuTms9918.git\ncd vrEmuTms9918\n```\n\n#### Setup build\n\n```\nmkdir build\ncd build\ncmake ..\n```\n\n#### Build\n\n```\ncmake --build .\n```\nWindows: Optionally, open the generated solution file\n\n#### Run tests\n```\nctest\n```\nWindows: Optionally, build the ALL_TESTS project in the generated solution file\n\n## Quick start\n\n```c\n#include \"vrEmuTms9918.h\"\n#include \"vrEmuTms9918Util.h\"\n\n#define TMS_VRAM_NAME_ADDRESS          0x3800\n#define TMS_VRAM_COLOR_ADDRESS         0x0000\n#define TMS_VRAM_PATT_ADDRESS          0x2000\n#define TMS_VRAM_SPRITE_ATTR_ADDRESS   0x3B00\n#define TMS_VRAM_SPRITE_PATT_ADDRESS   0x1800\n\n// program entry point\nint main()\n{\n  // create a new tms9918\n  VrEmuTms9918 *tms9918 = vrEmuTms9918New();\n  \n  // Here, we're using the helper functions provided by vrEmuTms9918Util.h\n  //\n  // In a full system emulator, the only functions required (connected to the system bus) would be:\n  //\n  //  * vrEmuTms9918WriteAddr()\n  //  * vrEmuTms9918WriteData()\n  //  * vrEmuTms9918ReadStatus()\n  //  * vrEmuTms9918ReadData()\n  //\n  // The helper functions below wrap the above functions and are not required.\n  // vrEmuTms9918Util.h/c can be omitted if you're not using them.\n  //\n  // For a full example, see https://github.com/visrealm/hbc-56/blob/master/emulator/src/devices/tms9918_device.c\n  \n  // set up the VDP write-only registers\n  vrEmuTms9918WriteRegisterValue(tms9918, TMS_REG_0, TMS_R0_MODE_GRAPHICS_I);\n  vrEmuTms9918WriteRegisterValue(tms9918, TMS_REG_1, TMS_R1_MODE_GRAPHICS_I | TMS_R1_RAM_16K);\n  vrEmuTms9918SetNameTableAddr(tms9918, TMS_VRAM_NAME_ADDRESS);\n  vrEmuTms9918SetColorTableAddr(tms9918, TMS_VRAM_COLOR_ADDRESS);\n  vrEmuTms9918SetPatternTableAddr(tms9918, TMS_VRAM_PATT_ADDRESS);\n  vrEmuTms9918SetSpriteAttrTableAddr(tms9918, TMS_VRAM_SPRITE_ATTR_ADDRESS);\n  vrEmuTms9918SetSpritePattTableAddr(tms9918, TMS_VRAM_SPRITE_PATT_ADDRESS);\n  vrEmuTms9918SetFgBgColor(tms9918, TMS_BLACK, TMS_CYAN);\n  \n  // send it some data (a pattern)\n  vrEmuTms9918SetAddressWrite(tms9918, TMS_VRAM_PATT_ADDRESS);\n\n  // update pattern #0\n  char smile[] = {0b00111100,\n                  0b01000010,\n                  0b10000001,\n                  0b10100101,\n                  0b10000001,\n                  0b10011001,\n                  0b01000010,\n                  0b00111100};\n  vrEmuTms9918WriteBytes(tms9918, smile, sizeof(smile));\n  \n  // update fg/bg color for first 8 characters\n  vrEmuTms9918SetAddressWrite(tms9918, TMS_VRAM_COLOR_ADDRESS)\n  vrEmuTms9918WriteData(tms9918, vrEmuTms9918FgBgColor(TMS_BLACK, TMS_LT_YELLOW));\n \n  // output smile pattern to screen\n  vrEmuTms9918SetAddressWrite(tms9918, TMS_VRAM_NAME_ADDRESS);\n\n  // a few smiles\n  vrEmuTms9918WriteData(tms9918, 0x00);\n  vrEmuTms9918WriteData(tms9918, 0x00);\n  vrEmuTms9918WriteData(tms9918, 0x00);\n  \n  // render the display\n  char scanline[TMS9918A_PIXELS_X]; // scanline buffer\n\n  // an example output (a framebuffer for an SDL texture)\n  uint32_t frameBuffer[TMS9918A_PIXELS_X * TMS9918A_PIXELS_Y];\n\n  // generate all scanlines and render to framebuffer\n  uint32_t *pixPtr = frameBuffer;\n  for (int y = 0; y \u003c TMS9918A_PIXELS_Y; ++y)\n  {\n    // get the scanline pixels\n    vrEmuTms9918ScanLine(tms9918, y, scanline);\n    \n    for (int x = 0; x \u003c TMS9918A_PIXELS_X; ++x)\n    {\n      // values returned from vrEmuTms9918ScanLine() are palette indexes\n      // use the vrEmuTms9918Palette array to convert to an RGBA value      \n      *pixPtr++ = vrEmuTms9918Palette[scanline[x]];\n    }    \n  }\n  \n  // output the buffer...\n  \n  ...\n  \n  \n  // clean up\n  \n  vrEmuTms9918Destroy(tms9918);\n  tms9918 = NULL;\n  \n  return 0;\n}\n```\n\n## Real example\n\nThis library is used in the [HBC-56](https://github.com/visrealm/hbc-56) emulator.\n\nThe HBC-56 uses this library to support:\n\n* Rendering to an SDL texture.\n* TMS9918 VSYNC Interrupts.\n* Time-based rendering. Supports beam-time.\n\nFull source: [hbc-56/emulator/src/devices/tms9918_device.c](https://github.com/visrealm/hbc-56/blob/master/emulator/src/devices/tms9918_device.c)\n\n## License\nThis code is licensed under the [MIT](https://opensource.org/licenses/MIT \"MIT\") license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvisrealm%2Fvremutms9918","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvisrealm%2Fvremutms9918","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvisrealm%2Fvremutms9918/lists"}