{"id":16252976,"url":"https://github.com/digitsensitive/chip8","last_synced_at":"2025-04-08T12:43:13.336Z","repository":{"id":85849603,"uuid":"287890809","full_name":"digitsensitive/chip8","owner":"digitsensitive","description":null,"archived":false,"fork":false,"pushed_at":"2020-08-23T12:34:47.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T08:47:10.495Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","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/digitsensitive.png","metadata":{"files":{"readme":"README.md","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":"2020-08-16T06:53:59.000Z","updated_at":"2020-08-23T12:34:49.000Z","dependencies_parsed_at":"2023-03-06T20:45:42.424Z","dependency_job_id":null,"html_url":"https://github.com/digitsensitive/chip8","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/digitsensitive%2Fchip8","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitsensitive%2Fchip8/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitsensitive%2Fchip8/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitsensitive%2Fchip8/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitsensitive","download_url":"https://codeload.github.com/digitsensitive/chip8/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247846170,"owners_count":21005973,"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-10T15:15:33.905Z","updated_at":"2025-04-08T12:43:13.306Z","avatar_url":"https://github.com/digitsensitive.png","language":"C++","readme":"# CHIP-8\n\n## Systems memory map\n\n- 0x000 - 0x1FF: CHIP-8 interpreter (contains font set in emu)\n- 0x200 - 0xFFF: Program ROM and work RAM\n\nDetails:\n- 0x050 - 0x0A0: Used for the built in 4x5 pixel font set (0-F)\n- 0xEA0 - 0xEFF: Reserved for the call stack, internal use, and other variables\n- 0xF00 - 0xFFF: Reserved for display refresh\n\n## Memory\n\n- Most commonly implemented on 4K systems (f.e. Cosmac VIP, Telmac 1800)\n- These machines had 4096 (0x1000) memory locations\n- Each location with 8 bits (a byte)\n  --\u003e 4096 * 8 = 32768 bits = 4096 byte = \n- The CHIP-8 interpreter itself occupies the first 512 bytes of the memory space\n- Most programs written for the original system begin at memory location 512 (0x200)\n- The uppermost 256 bytes (0xF00-0xFFF) are reserved for display refresh\n- The 96 bytes below that (0xEA0-0xEFF) were reserved for the call stack, internal use, and other variables.\n- In modern CHIP-8 implementations, where the interpreter is running natively \noutside the 4K memory space, there is no need to avoid the lower 512 bytes \nof memory (0x000-0x200), and it is common to store font data there.\n\n## Registers\n\n- 16 * 8-bit data registers named V0 to VF.\n- The VF register doubles as a flag for some instructions; thus, it should be avoided.\n- In an addition operation, VF is the carry flag, while in subtraction, it is \n  the \"no borrow\" flag. In the draw instruction VF is set upon pixel collision.\n- The address register, which is named I, is 16 bits wide and is used with \n  several opcodes that involve memory operations.\n\n## Stack\n\n- The stack is only used to store return addresses when subroutines are called\n- The original RCA 1802 version allocated 48 bytes for up to 12 levels of nesting\n- Modern implementations usually have more\n\n## Timers\n\n- Two timers\n- They both count down at 60 hertz, until they reach 0.\n- Delay timer: This timer is intended to be used for timing the events of games. \n  Its value can be set and read.\n- Sound timer: This timer is used for sound effects. When its value is nonzero, \n  a beeping sound is made.\n\n## Input\n\n- Input is done with a hex keyboard that has 16 keys ranging 0 to F\n- The '8', '4', '6', and '2' keys are typically used for directional input\n- Three opcodes are used to detect input\n  - One skips an instruction if a specific key is pressed, \n  - while another does the same if a specific key is not pressed\n  - The third waits for a key press, and then stores it in one of the data registers.\n\n## Graphics and sound\n\n- Original CHIP-8 Display resolution is 64×32 pixels (= 2048) \n  and color is monochrome (= black and white)\n- Graphics are drawn to the screen solely by drawing sprites,\n  which are 8 pixels wide and may be from 1 to 15 pixels in height\n- Sprite pixels are XOR'd with corresponding screen pixels. In other words, \n  sprite pixels that are set flip the color of the corresponding screen pixel,\n  while unset sprite pixels do nothing\n- The carry flag (VF) is set to 1 if any screen pixels are flipped from set to \n  unset when a sprite is drawn and set to 0 otherwise.\n  This is used for collision detection.\n\nAs previously described, a beeping sound is played when the value of the sound timer is nonzero.\n\n## Opcode table\n\n- 35 / each two bytes long and stored big-endian\n- Big-endian is an order in which the \"big end\" \n  (most significant value in the sequence) is stored first \n  (at the lowest storage address).\n- Use on of these types:\n    unsigned short\n    unsigned short int\n    uint16_t\n    u_int16_t\n  --\u003e\t0 to 65,535\n\n- NNN: address\n- NN: 8-bit constant\n- N: 4-bit constant\n- X and Y: 4-bit register identifier\n- PC : Program Counter\n- I : 16bit register (For memory address) (Similar to void pointer)\n- VN: One of the 16 available variables. N may be 0 to F (hexadecimal)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitsensitive%2Fchip8","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitsensitive%2Fchip8","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitsensitive%2Fchip8/lists"}