[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-108053":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":16,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":18,"compositeScore":19,"rankGlobal":9,"rankLanguage":9,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":21,"topics":24,"createdAt":9,"pushedAt":25,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":15,"starSnapshotCount":15,"syncStatus":29,"lastSyncTime":30,"discoverSource":31},108053,"outrunners-port","cheviman\u002Foutrunners-port","cheviman","Native port of OutRunners (Sega arcade, 1992) for PC and consoles, built on the verified C decompilation cheviman\u002Foutrunners-decomp. Bring your own ROM.",null,"C",147,15,3,20,0,18,95,10,62.03,"BSD 3-Clause \"New\" or \"Revised\" License",false,"main",true,[],"2026-11-19 23:52:27","2026-11-22 08:55:45","# OutRunners — port\n\nSega's 1992 arcade game *OutRunners* (Sega System Multi 32) as a native game for computers, the Nintendo\nSwitch, Android and Anbernic's handhelds, built on its decompilation,\n[outrunners-decomp](https:\u002F\u002Fgithub.com\u002Fcheviman\u002Foutrunners-decomp): the game's program decompiled into C and\nchecked frame by frame against MAME in picture and sound. Two games come out of the same C:\n\n- **OutRunners Arcade**: the arcade game as it is, both cabinet screens side by side, the same frame by frame\n  as the reference.\n- **OutRunners**: the console version, the arcade game made for playing at home. The game's functions that\n  `console\u002Freplaced.txt` lists have the console's own versions (`console\u002F`); the rest is the game's.\n\nThis repository contains no game data. As with [n64decomp\u002Fsm64](https:\u002F\u002Fgithub.com\u002Fn64decomp\u002Fsm64), you bring\nyour own ROM set (MAME's `orunners`, World), and the game takes its assets out of it.\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"docs\u002Fscreenshots\u002Ftitle_menu.png\" width=\"32%\" alt=\"The title and its menu, in 16:9: ARCADE, 2 PLAYERS, NETWORK, & KNUCKLES, OPTIONS, EXIT\">\n  \u003Cimg src=\"docs\u002Fscreenshots\u002Frace_fork.png\" width=\"32%\" alt=\"A race at the pre-stage's fork: WEST or EAST, in 16:9\">\n  \u003Cimg src=\"docs\u002Fscreenshots\u002Fnetwork_room.png\" width=\"32%\" alt=\"NETWORK: a room with two devices, SEBAS and NICO, and the host's START\">\n  \u003Cimg src=\"docs\u002Fscreenshots\u002Freverse_map.png\" width=\"32%\" alt=\"& KNUCKLES > REVERSE: the goal picked on the route map\">\n  \u003Cimg src=\"docs\u002Fscreenshots\u002Foptions.png\" width=\"32%\" alt=\"OPTIONS over the title's opening\">\n  \u003Cbr>\n  \u003Cimg src=\"docs\u002Fscreenshots\u002Ftwo_players.png\" width=\"65%\" alt=\"2 PLAYERS: both seats in one race, side by side\">\n\u003C\u002Fp>\n\n## Playing it\n\nThe [releases](https:\u002F\u002Fgithub.com\u002Fcheviman\u002Foutrunners-port\u002Freleases) hold a package for Windows, Linux and\nmacOS (an .app for Apple silicon and Intel), with both games and the tools that make the devices' games.\nKeep `orunners.zip` beside the game, or drop it on its window when it asks: the first time it starts, it\ntakes the assets out of it (a few seconds) and keeps them. `README.txt` in the package says what each tool\nneeds.\n\n- **Nintendo Switch**: OutRunners NSP makes `OutRunners.nsp` with your ROM set and your console's keys, for\n  a console with Atmosphere (`ports\u002Fswitch\u002FREADME.md`).\n- **Android**: OutRunners APK makes `OutRunners.apk` with your ROM set, signed with a key of yours\n  (`ports\u002Fandroid\u002FREADME.md`).\n- **Anbernic's H700 handhelds** (RG35XX, RG40XX and their kin): OutRunners Anbernic makes the folder for\n  PORTS (`ports\u002Fanbernic\u002FREADME.md`).\n\nWhat any tool makes is yours alone, with the game's data in it: never share it.\n\n## OutRunners, the console version\n\n- **One screen**, the left seat's, and one sound; free play, no coins. The SEGA presentation (the title's\n  SEGA, dark, until three cars race across it), then the title with PRESS START.\n- **The title's menu**:\n  - ARCADE: the arcade's game, one player.\n  - 2 PLAYERS: both seats in one race, their screens side by side or one over the other; on a tablet or an\n    open Fold, the two screens facing each other, each player with their own touch controls.\n  - NETWORK: rooms of up to four devices on the local network (below).\n  - & KNUCKLES: CLASSIC (the arcade's game, 5 seconds more in every part, the right seat's START joins\n    it), TIME ATTACK (no time limit, the fastest run raced again as a see-through ghost), FULL (all 31\n    courses in one race), REVERSE (from a goal picked on the route map back to the start).\n  - OPTIONS: CONTROLS (keys and game controller buttons for each player), DIFFICULTY, TIME (by stage),\n    VIDEO (the window's size, full screen, PIXELS sharp, smooth, bilinear or CRT, WIDE off, 16:9 or 20:9,\n    2 PLAYERS' layout), VOLUME, SOUND TEST, STEERING (the sticks' dead zone and sensitivity, a racing wheel's\n    rotation, the keys' and pads' speed, SET UP WHEEL and an INPUT TEST of the wheel and the pedals), FPS\n    (the frames a second on the picture and in the window's title); the version at its bottom right.\n- **The pause** in a race (Escape, Enter or a game controller's Start): CONTINUE, RESTART (the same game\n  again, the same cars and transmissions chosen on the car select by themselves; not in NETWORK), QUIT GAME.\n- **The keys**: the arrows steer, accelerate and brake; Q and A shift up and down; space is the radio,\n  `[` and `]` its songs; Enter starts and pauses. A game controller: the d-pad or the left stick steers,\n  the right trigger or A accelerates, the left trigger or B brakes (a trigger as far as it is pressed), the\n  shoulders shift. OPTIONS > CONTROLS changes them, the triggers and the sticks' buttons too.\n- **A racing wheel**: the game reads it as a game controller, the wheel its left stick and the pedals its\n  triggers. One SDL (which reads the controllers) knows, a Logitech G29 for one, works as it is plugged in;\n  one it has no layout for, a Thrustmaster T300RS on Windows for one, is set up once in OPTIONS > STEERING:\n  - **SET UP WHEEL** asks for its controls one by one: turn the wheel left, press the gas and let go, the\n    brake, then the buttons for shift up, shift down and start (Escape cancels). The wheel is then player 1's\n    game controller. Its pedals may be separate or combined in one axis; its other buttons are the\n    controller's A, B, X, Y and the rest (A accelerates and B brakes, as on a pad, until OPTIONS > CONTROLS\n    changes them), its hat the d-pad. The layout is kept in `gamecontrollerdb.txt`, beside `controls.ini` in\n    the folder where the game keeps its files: SDL's own format, a line a device, so a layout made elsewhere\n    (SDL's community's `gamecontrollerdb.txt`, a tool's) can go there too, and both games read it as they\n    start.\n  - **WHEEL ROTATION** is the wheel's own turn from end to end, 270 to 1080 (900 on a G29): the game's wheel\n    turns all the way at 135 each way, the arcade's 270, and stays at its end past them; the DEAD ZONE counts\n    within those 135 (on a wheel, 0%).\n  - **INPUT TEST** shows the wheel, the gas and the brake as the game sees them, to see where the wheel\n    reaches its ends and the pedals their floor (it comes next after SET UP WHEEL).\n- **Android's touch controls**: the wheel, GAS and BRAKE, the gears' buttons with the manual transmission,\n  START and the radio. On a tall screen (an open Fold, a tablet) the picture goes to the top and the controls\n  under it, over the game's own route map following the car.\n\n## NETWORK\n\nUp to four devices race together, each one of the arcade's linked cabinets (two seats each: NETWORK > PLAYERS\n2 where the device has a second player), on the same local network: a house's Wi-Fi, or a phone's hotspot.\nComputers, phones and the Switch play together.\n\n1. NETWORK > NAME: your name, as the rooms show it.\n2. One device picks HOST: its room waits for the others, showing each one that joins with its name.\n3. The others pick JOIN: the rooms found on the network, and the one to join.\n4. The host's START (two devices or more) starts an ARCADE race of all of them: each one picks a car, and the\n   race is the game's own, its entries, checkpoints, forks and times as the arcade's linked cabinets have\n   them. After the race, back to the room.\n\nA device that stops being heard holds the race for a moment (WAIT); after 3 seconds it is out of it, as a car\nout of time, and the race goes on without it. If the one gone hosted the race or the room, the next device\nhosts it on, from where it was. The game uses UDP: the rooms' beacons on port 27720, and a port of the\nsystem's choosing for the race; a firewall that asks about the game should let it reach the private network.\n\nHow it works: each device sends its two race records to every other one each frame, as the cabinets' link\nboard would, and the game reads them as it reads the board's (`console\u002Fnetwork.c`, with the sockets in\n`console\u002Fnet_udp.c`). `orunners_console_headless --real-time` runs two games on one computer for the checks\n(`tests\u002Fconsole\u002Fnetwork_*.txt`).\n\n## What comes next\n\n- **4 PLAYERS on the Switch**: up to four players in one race on one console, the screen in four.\n- **iOS and the New Nintendo 3DS**: their ports, by [yoshisuga](https:\u002F\u002Fgithub.com\u002Fyoshisuga), in\n  [pull request 14](https:\u002F\u002Fgithub.com\u002Fcheviman\u002Foutrunners-port\u002Fpull\u002F14).\n\n## Supporting it\n\nIf you enjoy the game, you can support it on [GitHub Sponsors](https:\u002F\u002Fgithub.com\u002Fsponsors\u002Fcheviman): it buys\nthe time for what comes next. Thank you!\n\n## Building the port\n\nThe window games build as the rest of this repository does (\"Getting started\" below): `cmake --build` makes\n`OutRunners Arcade` (target `orunners`) and `OutRunners` (target `outrunners`) beside the tools in\n`build\u002Fbin\u002F`. `orunners_console_headless` runs the console version without a window, from scripts of its\nmenu's actions (`--actions`, `tests\u002Fconsole\u002F`). The devices' builds and their tools are in `ports\u002Fswitch\u002F`,\n`ports\u002Fandroid\u002F` and `ports\u002Fanbernic\u002F`, each with its README; `console\u002FPLAN.md` holds the console version's\nplan and what is done.\n\nThe rest of this README is the decompilation's, which this repository carries\n([outrunners-decomp](https:\u002F\u002Fgithub.com\u002Fcheviman\u002Foutrunners-decomp)).\n\n## Status\n\nHow much of the C reads as C written by hand, measured on every run of `python tools\u002Fnoise_report.py`\n(`clean`): 602 of the 762 functions (79.0%) and 26,144 of their 26,759 lines of code (97.7%) hold nothing\nof what the table under \"What is left, and why\" counts. Some of that the C has to keep to do what the\noriginal does: R12 and R14 where a value goes from one object's handler to the next through them, several fields\nmoved in one access as the original's one instruction moves them, a byte or halfword of a value changed\nwith the rest of it kept, as the original's byte and halfword instructions change it, and the memory the\nmemory test, the checksum and the copy reach by its address, whatever is there (`MEMORY_ROUTINES` in\n`tools\u002Fgame_profile.py`, each with why). Without counting those (`faithful`), all 762 functions and all\n26,759 lines of code are clean, the goal before the ports.\n\nApart from all that, the C keeps the game's state where the original had it, laid out as the board's work RAM (one structure, `struct game`, which the code reaches through `game`): structures reached by casting an address, addresses of the work RAM, of code and of tables used as values, links within a 64 KB page, memory moved and filled through its address (the memory model's row of the table under \"What is left, and why\"). 252 of the game's 696 functions (36.2%) and 20,271 of their 22,869 lines of code (88.6%) touch none of it; taking the rest out is the next phase.\n\n- [x] ROM set verification (MAME set `orunners`, World), by CRC32 and SHA-1 of every file\n- [x] Multi 32 board model in C (`runtime\u002F`): memory map, interrupt controller and timers, the two I\u002FO\n      chips, EEPROM, the A\u002FD converter of the wheels and pedals, and the link board with no other cabinet\n      on the line\n- [x] Reference run of the original program on MAME's V70 core against that model (`s32ref`), with MAME's\n      Multi 32 video drawing both screens: it boots, runs the attract mode and plays a scripted game, the\n      same frame by frame from one run to the next\n- [x] The sound board in the reference: the sound program on MAME's Z80, with ymfm's YM3438 (which the\n      program uses only for its timer) and MAME's MultiPCM, which plays the music and the effects\n      (`s32ref --sound-wav`), the same sample for sample from one run to the next\n- [x] Scenarios (`tests\u002Fcontrols\u002F`): the attract mode; a game until GAME OVER; races to all ten goals of the\n      map, the race time held by a poke (`race_*`, `two_players`, and the `route_*` that\n      `tools\u002Fmake_routes.py` writes, turning the wheel before the forks a route takes); a name typed into\n      the entry; every page of the test mode and its 122 sounds. Between them they execute 16,103 addresses\n      (`python tools\u002Fcheck_scenarios.py --reference-only`); the game has no continue\n- [x] Recursive disassembly without traces (`tools\u002Fdisassemble.py`, from `symbols.txt`): the vectors, the\n      tables of code addresses next to the jumps that read them, the object handlers (stored in field 4,\n      from lists, tables of lists and the streams of objects along each stage's road, which fork with the\n      route) and a timeline: 19,708 instructions in 640 functions, no invalid or overlapping paths, and all\n      16,103 addresses the scenarios execute among them\n- [x] Coverage (`tools\u002Fcoverage.py`): every byte of the code chips is code, data that the code or the\n      tables `symbols.txt` describes point at, or fill; none is unknown. To find the last of it,\n      `s32ref --rom-reads FILE` lists what a run reads of the ROM as data, by instruction. The code and the\n      tables nothing uses are in `symbols.txt` too (its last section): 52 functions nothing calls are\n      decompiled with the rest; 1,039 bytes of code are left out of the C, the reset vector's jump and 14\n      places of dead code that jump or call into the middle of functions the game runs, whose C would cut\n      those functions in two\n- [x] Translation scaffold (`tools\u002Frecompile.py`): the program translated into C one instruction at a time,\n      615 functions that the V60 runtime (`runtime\u002Fsrc\u002Fv60.c`) runs a frame at a time. `orunners_headless`\n      matches the reference frame by frame in all 16 scenarios. The game runs two tasks, each on a stack\n      of its own, and its VBLANK handler swaps them; their C runs on native stacks of their own\n      (`runtime\u002Fsrc\u002Ftasks.c`)\n- [x] Decompiler, first pass (`tools\u002Fdecompile.py`): the program decompiled into C, in `src\u002F`: 671 functions\n      with no goto, which the game's runtime (`runtime\u002Fsrc\u002Fgame.c`) runs a frame at a time.\n      `orunners_game_headless` matches the reference frame by frame in all 16 scenarios, and\n      `tools\u002Fcheck_structure.py` finds the C's ifs, loops and switches doing what the program's jumps do in\n      every function, the ones no scenario runs included (and in the sound program's 60, with `--sound`). The VBLANK handler\n      asks the runtime to swap the tasks (`swap_tasks`), and a function that returns for its caller too\n      says so (`left_caller`). The registers the whole program shares are globals, a copy for each task:\n      `current_object`, `player_car` and `screen` (named by `symbols.txt`), and R12 and R14, scratch\n      registers whose last value the next function may read: globals named after them only where a value\n      goes into or out of a function, and locals with names of their own elsewhere (716 uses of the\n      globals, which `tools\u002Fnoise_report.py` counts, 932 before; R27 and R28 are locals: 1,495 uses with\n      them). The game's structures are typed (`tools\u002Fcore\u002Fdecompiler\u002Fpointers.py`, with `tools\u002Fgame_profile.py`'s structures):\n      the objects (0x100 bytes, 124 in the page of each screen's block), the screen's car (0x200 bytes at\n      1000 of the block), the course's ring of segments (128 of 0x20 bytes from 2000 of the block) and the\n      block of the screen a task runs (`SCREEN_1`, `SCREEN_2`), read as `OBJECT(p)->field`,\n      `CAR(p)->field`, `ROAD_SEGMENT(p)->field` and `SCREEN(p)->field`, each player's race record\n      (`RACE(p)`, which `symbols.txt` declares with the fields that point at it) and the objects' area\n      below each screen's block (`OBJECT_AREA(screen - 0x8000u)`: the lists of the objects, their slots);\n      what the code reaches by its own address in the screens' blocks and the race records reads as their\n      fields (`SCREEN(SCREEN_1)->game_mode`, `RACE(RACE_COPY_1)->entry_frames`), an object whose handler\n      is set to a family's function as that family's, and the variables' arrays by element\n      (`time_difficulty[1]`, `video_registers[16]`). The objects' code is\n      named and commented, family by family (the scenery and traffic along the road, the player's car and\n      the race display, the radio and its DJ, the title, attract and select screens, the route map, the\n      name entry), with each family's own fields, and so is the rest of the game's code: the boot and the\n      two tasks' frame loops, the game's modes and steps, the race's logic and the link between cabinets,\n      the sprite lists and the board's services (sound requests, palettes, text, the EEPROM, coins and\n      bookkeeping), the test mode and the interrupt hooks, with the work RAM variables and screen fields\n      they use; the code nothing that runs reaches is named and commented as well (\"Unused:\"). The sound\n      program is named in `sound_symbols.txt`: one driver for both screens, each with its page of commands,\n      eight sequence players and a queue of MIDI messages, played on 24 MultiPCM voices and the YM3438's\n      six channels, and the engine and tyre noise the game drives through the page (the game's side of the\n      shared RAM has the same names). Every parameter, result and local variable is named by what it holds\n      (`symbols.txt`'s param, result and local lines: 2,100 were named after a register and 565 values the\n      decompiler works out once were numbered), and so are the values a string move fills with; where a\n      partial write chains two values of a register into one variable, its name says both\n      (`model_then_animation`). Every variable has a name, and every field but 11 uses of fields still\n      named after their offset (`tools\u002Fnoise_report.py`, unk_fields; 79 before): the bytes of two\n      families' arrays, which their start clears as a word, a halfword and two bytes (the car radio's\n      `car_models`, the checkpoint board's `row_steps`: a family's field cannot be an array yet), and\n      fields of objects of two families (the choice flags `car_select_entries_run` starts) or of any\n      (`start_object_list`'s number in its list)\n- [x] The memory the code reaches through pointers, typed: a record of the work RAM, of the program ROM\n      or of the board's plain memories (the video RAM, the sprite RAM, the RAM the sound program shares) a\n      local, a parameter or a field points at is a structure, so `mem_read16(projected_segment + 4u)` reads\n      `PROJECTED_SEGMENT(projected_segment)->x` (each screen's ring of views and the road as it projects it,\n      the sprites' depth lists and the sprite lists' entries, the text layer's cells, the cars' hit boxes,\n      riders and sprays, the crash tables, the courses' starts, the coin chutes, the seats' credits and\n      inputs, the lamps, the settings' copies, the bookkeeping and the course records the sound program's RAM\n      keeps, the palettes' and the packed tiles' lists, the text records); a pointer that walks values of one\n      width reads `NAME(p)[i]` (`OBJECT_WORDS(object_bytes)[1] = 0u`), an array inside a record by a number\n      the code works out reads `SCREEN(screen)->places[player]`, and an unrolled copy or clear is the loop\n      it does. The board's registers have names: a variable in its plain memories (`MACHINE_ID_TEXT_CELL`,\n      `NBG0_SCROLL_X[layer]`), a device's register read and written by name or by the address the code\n      works out, through the bus (`io_read8(IO_1_CNT)`, `io_write16(board_records, ...)`: 371,\n      `board_registers`, not noise). 150 reads and writes still go through a computed address\n      (`tools\u002Fnoise_report.py`, mem_access; 2,877 before this was typed): see \"What is left, and why\".\n      `tools\u002Fmemory_census.py` says what each one reaches over the scenarios, with the game built with\n      `ORUNNERS_MEMORY_CENSUS`\n- [x] The game's own video and sound: `runtime\u002Fsrc\u002Fvideo.c` draws both screens; the sound program,\n      decompiled into C (`src\u002Fsound\u002F`, `tools\u002Fdecompile_sound.py` from `sound_symbols.txt`), runs on the\n      board's time with the YM3438 (`runtime\u002Fsrc\u002Fym3438.c`) and the MultiPCM (`runtime\u002Fsrc\u002Fmultipcm.c`,\n      the same as MAME's sample for sample). `orunners_game_headless` matches the reference frame by frame\n      in state, picture and sound in all 16 scenarios (`python tools\u002Fcheck_scenarios.py --video --sound`).\n      Left out of the comparisons: the V70's and the Z80's stacks, which the C keeps in no memory, and the\n      copies the test mode's RAM tests leave of them in the sprite RAM (`runtime\u002Finclude\u002Fs32\u002Fmachine.h`)\n- [x] A window port (`orunners`, `ports\u002Fsdl2\u002F`): both screens, the sound, the keyboard and game controllers;\n      a control script played in the window gives the reference's frames (`coin_start`: state, picture\n      and sound)\n- [x] The assets (`extract_assets.py`, driven by `assets.json`, which holds positions only), each with a\n      name, in formats the usual tools open: the tiles as 37 tilesets by subject (the road, each course's\n      backgrounds, the route map, the title...: `tilesets.txt`), the sprites as 264 sheets by subject\n      (`cars\u002F\u003Ccar>\u002F`, `scenery\u002F\u003Ccourse>\u002F`, `hud\u002F`, `traffic\u002F`...: `sprite_sheets.txt`), the MultiPCM's\n      samples as 219 WAV files by what plays them (`pcm_samples.txt`) with the 512 sample headers as text,\n      the music and the sound effects as 324 MIDI files, and the program's and the sound program's tables\n      as text records with their fields' names and addresses written as the names of what they reach.\n      `python extract_assets.py --check` builds the 17 chips back from them, byte for byte (the code from\n      the set)\n- [x] The game is not anchored to the ROM: it loads those files themselves when it starts\n      (`runtime\u002Fsrc\u002Fassets.c`, `assets_media.c`, `assets_midi.c`), every piece in a block of memory of its\n      own, with no image of the ROM, no region the size of a chip, no mirrors, banks or interleaving. The C\n      reads a table by its name (`game_mode_jumps[mode]`: a pointer the loader sets, `src\u002Ftable.c`'s\n      `game_tables`); an address the game keeps in its variables reaches its data through the assets'\n      index (`data_at`); the video draws tiles from the tilesets by their numbers and sprites from the sheets\n      by their places, the MultiPCM plays the WAV files, the sound program reads its tables and rebuilds its\n      sequences from the MIDI files. What the loader reads is the ROM's data byte for byte (the program's\n      818 pieces and the sound program's 396), and the 16 scenarios are identical in state, picture and\n      sound. The reference and the translation scaffold read the ROM set when they start, as MAME does, and\n      the memory test's ROM part is the board's (`runtime\u002Freplaced.txt`: the decompiled game has no ROM chips\n      to sum)\n- [x] The C reads the program's data by name: the records of the program ROM are structures\n      (`ROAD_ROW_RECORD(road_row_record)->animation`, `SPRITE_SIZE_STEP(size_step)->source_size`, the\n      car's `car_handlings[model]`), the lists they lead to are typed\n      (`FLASHING_SCENERY_PALETTES(palettes)[0]`), and every table has a name: none\n      is named after its address any more (`tools\u002Fnoise_report.py`, rom_names: 709 uses before), and 26\n      reads still go through a ROM address (rom_reads, 598 before). Those are the course's stream, whose\n      commands have operands of different widths behind one pointer (16, `player_car_extend_course` and\n      `player_car_build_segment`); the input test's list, which one pointer walks through two layouts in a\n      row (9); and the road objects' stream after a fork, read through the object's field in one operand\n      (1). Every ROM address the code uses as a value has a name (a data or table line, or a constant\n      line for a number that only looks like one: 101 before) but two (raw_rom_addresses): the switches\n      that go on through the original's own jump target in `car_radio_update` and `song_title_show`,\n      where the code's address stands for \"go on here\", as the cases do. The data's text files go by\n      subject, as the C does: a table goes with the C file that reads it the most\n      (`assets\u002Fdata\u002Frace\u002Fcourse.txt` holds the courses `src\u002Frace\u002Fcourse.c` builds the road from)\n- [x] The C by subject, as the original's modules lay it out (`symbols.txt`'s file lines, a file a subject,\n      some taking several stretches of the program): `src\u002Fsystem\u002F` (the main program, the settings, the\n      inputs, coins and bookkeeping, sound requests, the LCD, the interrupts, the test mode), `src\u002Fvideo\u002F`\n      (the chips, unpacking, palettes, text), `src\u002Fengine\u002F` (the objects and their sprites), `src\u002Frace\u002F`\n      (the player's car, its physics, the course, the other cars, the hits, the race's display, the link\n      between cabinets), `src\u002Fobjects\u002F` (the scenery, the traffic, the race's people, the road's surface,\n      the backgrounds, the car radio), `src\u002Fscenes\u002F` (the game modes, the attract mode, the title, the coin\n      prompts, the car select, the ranking, the name entry, the route map) and `src\u002Fsound\u002F` (the sound\n      program: its main loop, the MIDI messages, the FM voices, the engine noise, the sequences), each\n      file with its header and what it holds\n- [x] Linux and macOS: the game builds with GCC and Clang as well as MSVC, and GitHub Actions builds it on\n      every push for Linux, macOS (an .app for Apple silicon and Intel) and Windows, with no ROM set and SDL2\n      inside the window port (`.github\u002Fworkflows\u002Fbuild.yml`: a package each, the window port with its\n      licenses). On Linux (Ubuntu 24.04 on WSL, GCC 13 and Clang 18) the 16 scenarios were identical to the\n      reference in state, picture and sound (with the game on its earlier assets pack; not run again on\n      Linux since it loads the asset files). The macOS build has not been run on a Mac yet\n- [x] Toward the 99%: a jump through a table of code is a switch with the cases the table holds and no\n      `default:`, as the original checks no index (`--checks` writes a build that stops on an index past\n      the table, where the 16 scenarios run as well); R12 and R14 are locals wherever their value stays\n      within a function; what every call passes and every way back hands back is followed bit by bit\n      across functions (`knownbits.across`), so a byte every caller passes as a byte is a byte's sum; a\n      function returns no more of its result than its callers read, and a register a function only hands\n      back as it was is no argument its caller has to work out where it drops what comes back; the sound\n      program puts no byte back into the pair it was taken from unchanged, and a pointer moved within its\n      256-byte page reads `IN_PAGE(queue_pointer, write_index)`. Partial writes 439 -> 245, casts 2,856 ->\n      2,796; `tools\u002Fcheck_structure.py` finds every function's control flow as the program's jumps\n- [x] Toward the 99%, the second round: what a function reads to work out R12 and R14 is followed as what\n      it hands back is, so a call that writes them no longer reads all its callee may read (`draw_object`'s\n      R0); the bits known zero across functions start from all of them and are taken back until nothing\n      changes, which finds a value that goes round between calls (`insert_coin`'s credits); a bit tested by\n      a constant number reads that bit alone; what a function hands back through pointers is worked out\n      only as wide as its callers read it; stack slots are followed a part at a time, as registers are (a\n      register pushed whole and popped for its low byte). Memory by a number the code works out reads as the\n      arrays it is: in the screen's block and the objects' area (`route_branches[forks_reached - 1]`,\n      where the code counts from 1; `checkpoint_orders[checkpoint_offset * 4u + pass_player]`), the race\n      records' copies by player (`RACE(RACE_COPY_1)[player].segment`), the road's ring of segments by a\n      byte offset (`ROAD_SEGMENT(screen + 0x2000u + offset)->half_width`), the record after the one a\n      pointer is in, and a field an `inc.b` reaches through an index (`row_steps[row_player]`). Partial\n      writes 245 -> 180, memory reached by address 149 -> 82, casts 2,796 -> 2,749; the 16 scenarios\n      identical in state, picture and sound, and `tools\u002Fcheck_structure.py` 0 problems\n- [x] Toward the 99%, the third round: the data the code walks through one pointer at several widths reads\n      as the bytes of a named table (`COURSE_BYTES(course_place)[0]`, `AS16(INPUT_TEST_BYTES(item)[0])`,\n      the test mode's texts), and a fork's table of the road objects' streams as its own elements: no data\n      is read through its ROM address any more (26 before). The objects' fields every family numbers\n      alike have names of their own (`number`, `car`, `car_colour`: no field is named after its offset, 5\n      before). What a search or a string move leaves in a register points where `symbols.txt` says\n      (`OBJECT_SLOT_FLAGS(free_flag)[0]`, `LCD_CHARACTERS(text_end)[0]`); a register can point at a\n      variable (the test mode's R20 at its settings: `time_difficulty[stage_item - 1u]`); the screens'\n      pages of the sound RAM by the screen's index; a word written at an element of an array of halfwords\n      is `AS32` of it (`AS32(video_registers[32 + index * 2u])`, not an address). A case of a switch that\n      goes on to the start of another goes just before it and falls through into it, as C cases do\n      (`lap_timer_update`, no control flag left). Memory reached by address 82 -> 53\n- [x] Toward the 99%, the fourth round: a state machine's cases that go on into another case are written as\n      C cases that fall through into it, stop where another case starts, leave by break and copy a small\n      case they jump to (`song_title_show` has no control flag left, `player_car_move_view` 2 of 3,\n      `car_radio_update` 5 of 7); the bits known zero go through what a function pushes and pops (the\n      sound test's codes and the name entry's letters read as their tables, `sound_test_codes[sound_number]`).\n      Memory reached by address 53 -> 48, partial writes 180 -> 174, casts 2,747 -> 2,732\n- [x] Toward the 99%, the fifth round, the control flags: a state machine's cases inside a loop are written\n      the same way, and a case that falls through into the next ones takes their code where it is copied\n      (`checkpoint_board_update`); a jump into a state's case right after storing its number is the switch\n      running again, `state = 0xFu; continue;`, where that writes the C shorter (`route_map_update`, the\n      car select's attendant); a switch in a loop whose cases go round again or leave it ends with a\n      break (`init_screen`'s course walk); where flags are still left, the head of a loop around another\n      one, a small block several jump to and a larger piece of a loop entered at two places are copied\n      (`player_car_move_view`; `palette_fade_step` 3 of 9); the station's DJ, which four states of the\n      radio jump to, is a function of its own (`car_radio_talk`, a `func` line, out of `car_radio_update`).\n      The functions named have no flag left but `palette_fade_step`. Control flags 15 functions and 59\n      flags -> 10 and 38, ROM addresses printed as numbers 4 -> 0\n- [x] Toward the 99%, the sixth round, the results written back: a function that hands results back\n      through pointers is also written with one way out at its end where the short ways to it meet the\n      others there, which the C keeps when it writes results back before fewer returns, or as few in\n      fewer lines (`playlist_command`'s commands are cases that break, `vector_angles` an if and an else);\n      a call whose result is the function's own as it ends (the original's jump on into the callee) gets\n      the caller's pointer, `*p_leftover = x; draw_object_at_scale(..., p_leftover, ...);` (the seven\n      `draw_object_*` routines); a copy of a function's code keeps the variables of the base a field\n      access adds up (`ROAD_SEGMENT(screen + 0x2000u + (ring_offset & 0xFFFu))`), which kept the copies\n      with one way out from being taken. Results written back before an early return 64 -> 13\n- [x] Toward the 99%, the seventh round, control flags and memory by address: the ways of a case that goes\n      on into the next one meet where that one starts (`race_background_update`, no flag left:\n      `if (stage_background_change == 0u) { if (new_branch == 0u) break; new_branch = 0u; }`); the switch\n      runs again for a state's case also where its block does something before it switches (split off), where\n      the state is stored with the fields after it in one word and where other fields of the record are stored\n      after it (`player_car_update`, 1 flag of 3). A pointer the code keeps on the stack keeps its type\n      (`CAR_SELECT_TILEMAP_SETUP(setup_bits - 0x1Cu)->video_register_bits`, the road surface's line scroll,\n      the sound program's voices and sequence players); a typed local stays a variable where its one use is\n      a memory access (`ROAD_SEGMENT(car_segment_record)->half_width`, `TEXT_LAYER_CELLS(cursor_cell)[0]`);\n      the road rows' last sprites are `SPRITE_WORDS` (the board's memories read the work RAM or the\n      program's chips where the game points there, as the bus does); a device's place moved by a constant,\n      or with its low byte replaced, is still the device (the link board's flag, the input test's ports).\n      Control flags 10 functions and 38 flags -> 9 and 35, memory reached by address 48 -> 27\n- [x] Toward the 99%, the eighth round, a part of one value put into another: a part a write keeps of a\n      register that holds the same constant on every way into the block is that constant (`unpack`'s offset\n      back, `0xFFFF0000u | AS16(PACKED_BYTES(source)[0])`; the test mode's minus sign, `0x642Du`); a\n      parameter `symbols.txt` says points at a structure is a pointer where the function only puts an\n      address together from it (`sequence_player = IN_PAGE(player, 0x1Bu)`); a pointer moved to another\n      place of its 256-byte page says so with `IN_PAGE` (the input test's ports of an I\u002FO chip,\n      `r12 = IN_PAGE(port_a, 0xAu)`; the test mode's settings walked by their places). A small tail written\n      again where it is jumped to does not take the one way back with it (`player_car_drive` writes its\n      results once, at its end), and the objects' lists are cleared through a pointer to blocks of eight\n      bytes (`OBJECT_LIST_BLOCK(list_block)->low`). The crash of the screen's car, state 5 of\n      `player_car_update`, which a hit also runs into the frame it starts, is a function of its own\n      (`player_car_crash_step`, a `func` line: `player_car_update` has no flag left). Mixed partial writes\n      37 -> 28 lines, in 22 -> 16 functions; results written back before an early return 13 -> 9; memory\n      reached by address 27 -> 25; control flags 9 functions and 35 flags -> 8 and 34\n- [x] Toward all of it, the ninth round, the control flags: none is left. The values a register can hold\n      where the code reads it are followed from the constants the functions and their callers set and from\n      the program ROM's tables (`ranges.py`), so a bit tested by a register's number reads only the bits\n      those numbers reach (the link board's self-test, 4 or 5 chips; the staff credits code's controls; the\n      coin chutes' switches); a loop the code enters at more than two places gets a copy of the rest of the\n      round those ways start (`palette_fade_step`: the scan for the first colour still fading goes on into\n      the loop of steps at its red, green or blue); a loop whose ways out run through code of their own\n      goes on where they meet; a test made again with nothing changed between goes straight to its side\n      (`race_car_draw` tests the rival flag twice); a short way out several blocks of a loop lead to, a\n      small loop of its own too, is written where each is (`road_surface_lines`' step to the next segment and\n      its copy of the points left, so that the ways meet where it draws the line); and a function can go\n      back to its caller at an exit (`exit` lines: `second_task_frames`, both screens' frames, returns when\n      the test mode starts, as C cannot break out of two loops). Large pieces several ways run into are\n      functions of their own (`func` lines): `player_car_engine_wheelspin`, `_grip`, `_standing`, `_revs`;\n      `race_car_draw_behind`, `race_car_draw_link`; `name_entry_read_wheel`, `name_entry_choose`,\n      `name_entry_finish`, `name_entry_store_record`, `name_entry_draw_time`; and in the sound program,\n      `cut_open_hi_hat`, `take_voice` and `release_note` for each screen. Control flags 8 functions and 34\n      flags -> 0; results written back before an early return 9 -> 0; mixed partial writes 28 -> 23 lines, in\n      16 -> 12 functions\n- [x] Toward all of it, the tenth round, the mixed partial writes: none is left. A partial write whose kept\n      part something reads afterwards changes a part of the one value the register holds, so the C writes it\n      in place, on one variable: `random_number`'s state and the number it hands back, the turntable's\n      leftover with the flags in its low byte, the riders' gestures `race_car_draw` puts in R12's low byte,\n      the memory test's results in the low byte of its ROM check, `road_surface_halfway_lines`' stripe count\n      with the last frame's segment in its low half, the sound program's register pairs (a count in B, a\n      register in C). Not where the code reads memory through one of them: a pointer moved within its page is\n      a pointer of its own (`IN_PAGE`, the input test's ports). A value goes into the rest a partial write\n      keeps, or a partial write into what reads that rest too, only where the part written or the rest is\n      zero, so each of the original's steps where both carry something is a line of its own (the A\u002FD\n      converter's bits shifted in one at a time, `read_switches_and_analog`; the EEPROM's, `eeprom_read_word`;\n      a pair of x turned round, then its low half written, `road_row_pair_draw`). And a call passes only the\n      parts of a register its callee reads: `multiply_bytes` clears the low byte of its value first thing, so\n      its callers put the level in the high byte alone (`level_product = (uint32_t)note_level \u003C\u003C 8`). Mixed\n      partial writes 23 -> 0 lines, in 12 -> 0 functions; partial writes 150 -> 148; R12 and R14's uses\n      717 -> 720 (the riders' gestures, in R12 as the original keeps them)\n- [x] All of it, the eleventh round, the last memory reached by address outside the memory routines: an\n      index the code counts (a register whose every value is a byte or a halfword, or itself counted on by a\n      constant) reads its table by name, `car_numbers[players_left - 1u]` as the car select counts the\n      players down to 1 (and the sound program's channel controls, by the channel's offset); an array of a\n      structure read from so many of its elements before its start as one term of the index counts in is\n      that term counted from more than 0, `page_table[(page_set - 3u) * 5u + (near_scroll >> 9)]` (the road's\n      page table, in `symbols.txt` the 15 words it is: five for each of page sets 3 to 5); and a table read\n      from its middle by a signed number is that table from its real start, `steer_frames_by_steering[64 +\n      steering]` (129 bytes from 00927C, a table's count in `symbols.txt` as a variable's: `table\n      NAME[COUNT]`), which the assets cut there too: assets taken out before it are cut another way, and the\n      game stops when it loads them (`the assets have no table steer_frames_by_steering`; `python\n      extract_assets.py --only program_data --force` takes the data out again). The program's data in\n      `assets\u002Fdata` take the file of the C that reads them, the loaders' lists (`src\u002Ftable.c`,\n      `src\u002Fsound\u002Ftables.c`) left out: they name every table once, and had put 24 of them in a `table.txt` of\n      their own. Memory reached by address 25 ->\n      21, the memory routines' alone; faithful 759 -> 762 functions and 26,879 -> 26,883 lines: all of it\n- [x] After it, the small things: the names the decompiler made up for memory that its accesses turned out\n      to be something else (44 variables `unk_` in the screens' blocks, the tables `rom_000001` and\n      `rom_000002`) are no longer declared, nor loaded; a function that returns a value and ends in a switch\n      whose every case returns says that nothing goes on past it (`unreachable()`), so no compiler warns;\n      and a place so many bytes on from a pointer in its 64 KB page, added in 16 bits as the original does, is\n      `PAGE_ADD` (the ring of the road's segments: partial writes 148 -> 140)\n- [x] The twelfth round, R12 and R14 as global variables only where they have to be. What a function leaves\n      in them is live where it ends as far as its callers read it, and where a boundary function ends (an\n      object's handler, an interrupt, a task: the code that runs next reads what it leaves); a part of the\n      global a function only takes through stays as it was. In the functions that neither call through a\n      memory slot, nor wait for an interrupt, nor only take a value through to the next handler, nor call\n      one of those, they are registers like the rest: parameters and results named in `symbols.txt` (61\n      `param` lines: the drawing's `last_piece` and `last_size_step`, the road's `select_place` and\n      `stripe`, the EEPROM's `eeprom_port`...), and locals (`first_segment`, `handling`, `next_segment`).\n      R12 and R14's uses 720 -> 347, in 104 -> 74 functions; partial writes 140 -> 132; clean 592 -> 601\n      functions\n- [x] The board's memory model counted (`python tools\u002Fnoise_report.py`): the structures the code reaches by\n      casting an address of the work RAM, the variables at fixed addresses, the addresses of the work RAM,\n      of code and of tables used as values, the places worked out within a page, and the memory moved,\n      filled or searched through its address, which nothing counted before (106: `move_halfwords`,\n      `move_string`, `set_bytes`...), with how much of the game's C touches none of it. No name made up of an\n      address or an offset is left: 17 functions' comments gave fields by their offset, from before the\n      fields had names (`the car object's unk_10`, its `timer`), `struct object`'s view of every object\n      declared 64 such fields that no code reads (now padding), and one place of screen 2's block went by a\n      name made up of its address that the meter did not see (`made_up_names` 86 -> 0)\n- [x] The game's state as one structure, the first step out of the board's memory model: `struct game`\n      (`src\u002Fram.h`) is the work RAM laid out as the original had it, its blocks by name (`object_area_1`,\n      `screen_1`, `races`, `race_copies`, `object_area_2`, `screen_2`, `isdn_races`, `stacks`) and its\n      variables at their places, the names that share bytes in a union (`checkpoint_lamp[8]` and the names\n      of its bytes: each screen's lamp a record of four). The code reaches it through `game`\n      (`game->game_frame_count++`); the runtime keeps one world's (`runtime\u002Fsrc\u002Fgame.c`) and the board\n      reads the same bytes, so each frame's state still compares byte for byte with the original's. The\n      arrays the code indexes have their counts in `symbols.txt` (`course_records[60]`, the ten records of\n      six bytes), so that no index runs past one, and a screen's block is the 0x6000 bytes its fields take\n      (the game's variables follow screen 1's). Variables at fixed addresses (`ram_variables`) 139 -> 0\n- [x] The state's blocks by name where the code reaches them at their fixed addresses: a field of a\n      screen's block, of a player's race record or of a copy of one is the block's field\n      (`game->screen_1.unpack_state`, `game->races[0].car_number`), and a record the code counts from the\n      first copy by a player's number its element (`game->race_copies[player].model`): the copies are\n      eight, every player's with the link (`link_receive_records` brings in the other cabinets'). Structures\n      reached by casting an address (`ram_structures`) 9,034 -> 8,920, addresses of the work RAM used as\n      values 296 -> 182\n- [x] Pointers, first part: the registers the whole program shares that point at a structure are C\n      pointers (`struct object *current_object`, `struct car *player_car`, `struct screen *screen`), read\n      as such (`current_object->state++`), set from a block of the state or a structure inside one by name\n      (`screen = &game->screen_1`, `player_car = &screen->car`), and the runtime keeps a copy of them for\n      each task. The structures inside a screen's block and an objects' area are members of theirs\n      (`symbols.txt`'s `member` lines: the screen's ring of eight `views`, its `car`, the course's ring of\n      128 `road_segments`, the `projected_segments`, the 416 `depth_layers`; the area's `spare_object`,\n      `object_lists` and 124 `objects`). Where the C still needs the address the original holds there\n      (a field that keeps one, a link in the page, a block copy), `address_of(screen)` gives it, and\n      `pointer_to(address)` the pointer for one, into any memory the original's register points into: the\n      test mode's R20 walks the bookkeeping in the sound board's RAM, and the text drawing's walks the ROM's\n      texts, through copies `ram_outside` keeps the addresses of (`pointer_conversions`: 413). Structures\n      reached by casting an address 8,920 -> 2,121; out of the memory model 145 -> 235 functions\n- [x] Pointers, second part: a function's own variables, its parameters and what it hands back are C\n      pointers where they point at the start of one structure of the state wherever the code reaches a\n      field through them (`struct object *object = NULL; ... object->flags`, `struct object\n      *start_object(void)`, `draw_object_at_scale(..., struct projected_segment *projected_segment, ...)`),\n      the signatures decided from each function's own code before any call to it is written; a caller\n      that holds an address passes `pointer_to(address)`, and a pointer compared with 0 is `NULL`\n      (`object != NULL`). Structures reached by casting an address 2,121 -> 1,173; the conversions 413 ->\n      706, where each new pointer meets what is still an address: the fields that keep one, the links\n      in the page, the parameters of a function whose code reaches no field through them\n- [x] Pointers into the program ROM's records the same way, read in place in the piece of the program's\n      data (`const struct sprite_animation *sprite_animation = NULL; ... sprite_animation->frames`):\n      `rom_pointer(address)` gives the one for an address the code holds, and `address_of` finds the\n      address back from the piece. Tables reached through an address (`table_addresses`) 1,283 -> 1,163;\n      the conversions 706 -> 822 (`rom_pointer` counted with them), most of them a field or a table that\n      keeps a ROM address (`rom_pointer(player_car->surface_entry_1)`, `rom_pointer(stage_courses[i])`)\n- [x] A variable that walks its record (it reads a field and moves on to the next, as the V60's `[R10+]`\n      does) as a pointer to the record it is in: `size_step->height`, not\n      `SPRITE_SIZE_STEP(size_step - 0x4u)->height`; its steps within the record go, and one onto another\n      record moves it by records (`sprite_place++`, `race--`). Structures reached by casting an address\n      1,173 -> 935, tables reached through an address 1,163 -> 779; the conversions 822 -> 900, one where\n      such a pointer gets its value (`size_step = rom_pointer(...)`) in place of a cast at each field;\n      326 lines of C less\n\n## What is left, and why\n\nWhat the C still says the way the original's instructions do, rather than in the game's own terms. Each of\nthese does exactly what the original does; the counts come from `python tools\u002Fnoise_report.py` (its line\nnames in brackets) or, for the ones it does not count, from the C as it is now.\n\n| What | Count | Why |\n|---|---|---|\n| R12 and R14 named after the register (`context_registers`) | 347 uses | Scratch registers whose last value the next handler reads: `race_cars_start` puts the car's address together from R12's high half, which the handler before it left (the screen's page), and the road rows' and the scenery's drawing keep the height of the last size step in R14 and skip reloading it when the object's step is the same. The C keeps them as globals, a copy for each task, only in the functions where they have to be (74, 104 before the twelfth round): the boundary functions (an object's handler, an interrupt, a task), the two that call through a memory slot (`run_objects`, `test_mode_frame`), `wait_for_frame` (the vertical blank's interrupt writes R12), the ones a value only goes through on its way to the next handler, and their callers. In the others they are registers like the rest: parameters and results with names of their own (`race_car_put_sprite(..., &last_piece, ..., &last_size_step)`, `eeprom_read_word(command, eeprom_port, ...)`), and locals; a value stays a local where nothing reads it after the function (the hit boxes' `first_segment`), and the C keeps the parts of the global a function only takes through (a halfword it writes keeps the page above it). 932 uses before the eighth round, 720 before the twelfth. R27 and R28 are locals: the one function that would read them before setting them, `player_car_project_road`, does so only if its projection pattern skipped every segment, and it starts with a 1 (`symbols.txt`'s `unread` lines) |\n| Memory reached through a computed address (`mem_access`) | 21 | The routines that work on memory by its address, whatever is there (`MEMORY_ROUTINES` in `tools\u002Fgame_profile.py`, faithful): the memory test (6), `unrolled_copy`, a copy from any address to any other (8), what boot writes where the board maps nothing (E00000, E80000: 6), the checksum of the settings (1). Nothing else: the last 4 went in the eleventh round (the car numbers one before the array by a count that goes down, the road's page table by page sets counted from 3, the body's frame by the steering from the middle of its table); 149 before the second round, 48 before the seventh |\n| Several fields read or written at once, `AS16`\u002F`AS32` (`wide_access`) | 206 | The original moves them in one instruction: the sprite lists' halfwords two at a time (54: a list's jump, and its copy in the other half of the list 0x3000 bytes on, `SPRITE_WORDS(p)[6144]`), the screen's block (69: the LCD's 16 characters four at a time, `AS32(SCREEN(SCREEN_1)->lcd_text[4])`; the game mode with its steps, the memory test's results two at a time...), palette colours 64 bits at a time (16), a halfword or a word of the data the code walks a byte at a time (the input test's list, the course's records, the test mode's texts: 13), two text cells at once (7), objects' fields (5), the projected segments copied whole (4), the car's brake lights (4), and 34 more (two halfword video registers at once, the unpacker's halfwords, a course record's model and name, the seats' bookkeeping bytes...) |\n| Jumps through a table with an index it does not have (`invalid_jump`) | 0 | The original jumps through its tables of code without checking the index, and so does the C: its switch has the cases the table holds and no `default:` (191 before). `python tools\u002Fdecompile.py --checks` (and `decompile_sound.py --checks`) writes the C for a build where an index the table does not hold stops the game with the address the original would have jumped to (`invalid_jump`, 192 places); the 16 scenarios are identical in that build too. Three functions end in such a switch whose every case returns: the C says nothing goes on past it (`unreachable()`, C23's), as nothing does in the original |\n| Results written back before an early return (`copy_backs`) | 0 | A function hands back what it leaves in registers through pointers (`p_leftover`): kept in a local, it is written back as the function ends, once where the ways out meet at the end (`vector_angles`), straight through the pointer where the function only passes it on, and before the call that hands it on (`*p_leftover = x; draw_object_at_scale(..., p_leftover, ...);`). None left: `road_surface_lines`' 9, at three returns out of the loops its control flags left, went with them in the ninth round (64 before the sixth round) |\n| Functions with `bool` control flags (`control_variables`) | 0 | Where the original's jumps join paths that no nesting of ifs and loops can, a flag would say which way to go instead of a goto (59 functions had them before the sixth round). None is left: the decompiler writes what C can say: a small block several jump to written for each, a jump into a state's case right after storing its number written as the switch running again (`state = 3u; continue;`), a larger piece of a loop entered at two places copied for the second way in, a large piece several states jump to is a function of its own (`car_radio_talk`, `player_car_crash_step` and the ninth round's: `func` lines), a loop entered at more than two places gets a copy of the rest of the round those ways start (`palette_fade_step`), a test made again with nothing changed between goes straight to its side (`race_car_draw`), a short way out several blocks of a loop lead to is written where each is (`road_surface_lines`), and code two nested loops both leave to is where a function of their own goes back to its caller (`second_task_frames`, an `exit` line) |\n| Partial writes of a variable, `(x & ~0xFFFFu) \\| ...` (`partial_writes`) | 130 | Each changes a part of a value and keeps the rest of the same value, as the original's byte and halfword instructions do (`colour_count`'s `inc.b`, `palette = (palette & ~0xFFu) \\| (uint8_t)(palette + 1u)`; a pointer moved within its 64 KB page), which the faithful measure takes as the original's. None puts a part of one value into another (`mixed_partial_writes`: 23 lines, in 12 functions, before the tenth round): where something reads the rest a write keeps, the write changes a part of the one value the register holds, and the C writes it on that one variable, a step a line where the part written and the rest both carry something: two halves the code keeps in one register and turns round (the random numbers' state, `random_number`; a pair of x in `road_row_pair_draw`), bits shifted in one at a time (the A\u002FD converter's, `read_switches_and_analog`; the EEPROM's, `eeprom_read_word`), a cell's attribute and character (`test_mode_bookkeeping_draw_histogram`), the Z80's register pair BC with a count in B and a register in C (`set_voice_modulation_screen_1` and `_2`), a result the code puts in the low byte of what a call left (the turntable's leftover and the item's flags, the memory test's results), the riders' gestures in R12 (`race_car_draw`), the last frame's segment in the low half of `road_surface_halfway_lines`' stripe count. A call passes only the parts of a register its callee reads, so what a caller would put in a part the callee clears first goes (`multiply_bytes`' callers: `level_product = (uint32_t)note_level \u003C\u003C 8`). A bit tested by a register's number reads only the bits the numbers that register can hold reach (`ranges.py`: the link board's self-test, the staff credits code's controls, the coin chutes' switches from their table in the ROM), so a byte read into the register before such a test keeps nothing of what was there. The V70 writes the low byte or halfword of a 32-bit register and keeps the rest; the C does the same where the rest is read later: a pair packed in one register (`draw_text_at`'s position, x in the low halfword and y in the high one), halfword sums on a register whose high half goes on into a product or a store, a result the callers' variables take whole through a pointer. What every call passes and every way back hands back is followed bit by bit across functions, a function returns only what its callers read of its result, and a register a function only hands back is worked out only where its caller reads it afterwards, so those need none (439 before). A pointer moved within its 64 KB page (the next entry of a list, a link the code reads: `chain_tail = LINKED(chain_tail, DEPTH_LIST(depth_list)->tail)`) says so with `LINKED`, as the objects' links do (77), and a place so many bytes on from a pointer in its page, added in 16 bits as the original does, with `PAGE_ADD` (the ring of the road's segments, `PAGE_ADD(address_of(screen) + 0x2000u, player_car->segment_offset)`: 10), and one within its 256-byte page with `IN_PAGE` (the sound program's MIDI queue's next byte, a sequence player's field; the game's ports of an I\u002FO chip) |\n| Data read through its ROM address (`rom_reads`) | 0 | The course's stream, the input test's list and the test mode's texts read as the bytes of their tables, a halfword or a word of them with `AS16`\u002F`AS32`; a fork's table of the road objects' streams as its own elements (26 before) |\n| Tables read by their address (`rom_table_reads`) | 0 | Both programs read their tables by name: a pointer each that the loader sets (`src\u002Ftable.c`'s `game_tables`, `src\u002Fsound\u002Ftables.c`'s `sound_tables`); 847 before |\n| ROM addresses printed as numbers (`raw_rom_addresses`) | 0 | Every ROM address the code uses as a value has a name; the last four were `car_radio_update`'s switch going on at its own jump targets, which now runs the switch again or calls `car_radio_talk` |\n| Fields named after their offset (`unk_fields`) | 0 | The objects' fields 09, 0A and 0B that the code that starts an object sets alike for any family: `number` (its place in its start list, a choice flag's player), `car`, `car_colour` (5 before) |\n| A function the board puts its own in place of (`board_replaced`) | 1 | The memory test's sums of the ROM chips (`runtime\u002Freplaced.txt`): the game has no ROM chips to sum, so the board hands back the sums the program keeps for them (at 03FFF8 and 03FFFC), as good chips give |\n| Work RAM addresses printed as numbers | 25 uses | The tasks' stacks and frames (`0x21F800u`, `0x21FF84u`), places in the screens' blocks (the sprite places `0x20C000u`, one past screen 2's LCD text `0x218F20u`, where `test_mode_start` leaves R12) and the coin meters after the first: the decompiler names a constant only when it is a variable's own address. The memory model's `ram_addresses` counts them |\n| Names made up of an address or an offset (`unk_names`, `made_up_names`) | 0 | None in the code, none in a comment, none declared for nothing: 17 functions' comments gave fields by their offset, written before the fields had names (`the car object's unk_10`, its `timer`), `struct object`'s view of every object declared 64 fields named after their offset that no code reads, as the families' views name those bytes (86 before, now padding), and `test_mode_start` gave a place of screen 2's block by a name made up of its address (`unk_218F20_ADDRESS`), now its number |\n| The game's state in the board's memory model (`ram_structures`, `ram_variables`, `ram_addresses`, `code_addresses`, `table_addresses`, `page_links`, `ram_blocks`, `pointer_conversions`) | 935, 0, 162, 206, 779, 96, 106 and 900 | The game's state is one structure, `struct game`, laid out as the board's work RAM (128 KB at 200000), at the places the original had it, so that each frame's state compares byte for byte with the original's; the code reaches its variables as its fields (`game->game_frame_count`; 139 macros over fixed addresses before), and its blocks where the code reaches them at their fixed addresses (`game->screen_1.unpack_state`); the registers the whole program shares, and a function's own variables, parameters and results, that point at a structure are C pointers (`current_object->state`, `object->flags`). A field that holds an address is still read by casting it (`RACE(screen->race_copy)->stage_count`), the other pointers are 32-bit addresses, the C turns a pointer back into the address the original holds where it still needs it (`address_of(screen)`) and makes one from an address it holds (`pointer_to`, `rom_pointer`), an object's handler is a code address that `call_code` runs, the tables are reached through the addresses they hold (`data_at`), a link is an address's low halfword in its 64 KB page (`LINKED`), and memory is moved, filled and searched through its address as the V60's string instructions do (`move_halfwords(object, zero_block_ADDRESS, 0x80u)` clears an object; the others clear lists, race records and tables, copy the settings, the LCD's texts, the sprite entries and the video and mixer registers' values, and the memory test keeps the work RAM in the sprite RAM while it tests it). Taking the game's state out of that model, with real pointers and plain C variables, is the next phase; the board's own memories (the video and sprite RAM, the palettes, the sound and link boards' RAM) stay, being how the game talks to the board |\n| Data without a name of its own | 186 pieces, 1 to 6 bytes | The `data_XXXXXX` sections of `assets\u002Fdata\u002F`: the alignment between the code and the tables (zeros), the V60's `nop`s at 000000-000005, and dead code bytes in two places (00E8D9, after `halt`s) that the code reaches by no way. Every table has a name, and every piece with a structure a format of its own |\n| Board registers without a name | 6 uses | The interrupt controller's register 5 (`IRQ_D00005`, which MAME does not know either) and the bytes boot writes to E00000 and E80000-E80003, where the board maps nothing |\n| Calls through a slot that holds a function's address | 11 wrappers | `src\u002Ftable.c`: how `call_code()` runs a function from a code address it reads (`call_0006B0` runs `second_task`), named after that address |\n\n## Getting started\n\nRequirements: Python 3.10 or newer, CMake 3.20 or newer and a C11 \u002F C++17 compiler (Visual Studio Build\nTools on Windows, GCC or Clang on Linux, Xcode's command line tools on macOS). The window port needs SDL2\n2.30 or newer: on Windows its development package for Visual C++ (`SDL2-devel-2.32.10-VC.zip`) unpacked in\n`build\u002Fdownloads\u002Fsdl2\u002F`, elsewhere the system's (`libsdl2-dev` on Debian and Ubuntu); or, with\n`-DORUNNERS_STATIC_SDL2=ON`, SDL2 2.32.10 built from its source into the executable (CMake fetches it from\nGitHub), as the packages are. On Linux and macOS the commands below run with `python3`.\n\nThe decompiler, the analysis tools and the asset formats are a project of their own,\n[arcade-decomp](https:\u002F\u002Fgithub.com\u002Fcheviman\u002Farcade-decomp), which this repository keeps in `tools\u002Fcore\u002F` as\na git submodule: clone it with the submodule (`git submodule update --init` in a clone made without it).\nThe build needs it to take the assets out of your ROM set:\n\n```bash\ngit clone --recursive https:\u002F\u002Fgithub.com\u002Fcheviman\u002Foutrunners-decomp\n```\n\n1. Put your MAME `orunners.zip`, or the files inside it, in `rom\u002F`, and check it:\n\n   ```bash\n   python tools\u002Fverify_rom.py\n   ```\n\n2. Build the tools into `build\u002Fbin\u002F` (the build takes the assets out of the ROM set into `assets\u002F`, which\n   the game loads from the repository's folder or from beside its executable; no executable holds the\n   ROM):\n\n   ```bash\n   cmake -S . -B build\u002Fcmake\n   ```\n\n   ```bash\n   cmake --build build\u002Fcmake --config Release\n   ```\n\n3. Run the original program on the reference, here the attract mode for a minute, with a frame of both\n   screens every ten seconds as BMP:\n\n   ```bash\n   build\u002Fbin\u002Fs32ref --script tests\u002Fcontrols\u002Fattract.txt --video-dump 600 --video-dump 1200 --video-dir build\u002Fframes\n   ```\n\n   `tests\u002Fcontrols\u002F` holds the control scripts (format in `runtime\u002Finclude\u002Fs32\u002Fscript.h`). With\n   `--sound-wav FILE` the sound board runs too and what it plays is written as a WAV file. The attract\n   mode, with the settings a new EEPROM gets, plays no note; a game does (`tests\u002Fcontrols\u002Fcoin_start.txt`).\n\n4. Run every scenario on the reference, translate the program into C from what they execute, build that\n   translation (`orunners_headless`) and compare it with the reference, frame by frame:\n\n   ```bash\n   python tools\u002Fcheck_scenarios.py --reference-only\n   ```\n\n   ```bash\n   python tools\u002Frecompile.py --trace build\u002Fscenarios\u002F*\u002Fexecuted.txt --calls build\u002Fscenarios\u002F*\u002Fcalled.txt\n   ```\n\n   ```bash\n   cmake -S . -B build\u002Fcmake -DORUNNERS_SCAFFOLD=ON\n   ```\n\n   ```bash\n   cmake --build build\u002Fcmake --config Release\n   ```\n\n   ```bash\n   python tools\u002Fcheck_scenarios.py --translated --native-only\n   ```\n\n   The translation goes to `build\u002Fgenerated\u002F` and stays out of the repository: it is the game's code.\n\n5. The decompiled program is in `src\u002F`, and the build makes `orunners_game_headless` from it. Compare it\n   with the reference (the first command of step 4 writes the reference's results):\n\n   ```bash\n   python tools\u002Fcheck_scenarios.py --native-only\n   ```\n\n   `python tools\u002Fdecompile.py` writes `src\u002F` again, from the ROM and `symbols.txt`, and\n   `python tools\u002Fdecompile_sound.py` the sound program's C (`src\u002Fsound\u002F`), from the ROM and\n   `sound_symbols.txt`, with the timing model the reference runs the sound program on\n   (`build\u002Fsound\u002Ftiming.txt`). With the picture and the sound:\n\n   ```bash\n   python tools\u002Fcheck_scenarios.py --video --sound\n   ```\n\n   (this runs the reference again: with `--sound` its Z80 keeps the game's time, block by block).\n\n6. Play it in a window:\n\n   ```bash\n   build\u002Fbin\u002Forunners\n   ```\n\n   The two screens side by side, the ca","这是一个基于C语言反编译成果的《OutRunners》（世嘉1992年街机游戏）原生跨平台移植项目，支持PC（Windows\u002FLinux\u002FmacOS）、Nintendo Switch、Android及Anbernic手持设备。项目核心是经MAME逐帧验证的可信C反编译代码，提供街机版（双屏同步）与家用机版（单屏适配）两种运行模式，不包含任何游戏资源，需用户自行提供合法ROM（MAME格式orunners.zip）。适用于复古游戏爱好者、街机模拟研究者及嵌入式平台怀旧游戏开发者在合规前提下进行本地化运行与二次分发构建。",2,"2026-11-24 04:33:26","CREATED_QUERY"]