Cite as
sonicretro/s1disasm
Original
https://github.com/sonicretro/s1disasm
Pinned
sonicretro/s1disasm @ 15dfa3a6ee4c53aeb482233e493755c84b4f3479
Accessed
2026-10-20
Licence
none stated; the README disclaimer says the content is "for informational and educational purposes only" and "Commercial usage is expressly prohibited"
Credit
Sonic Retro community disassembly project; see the repository's contributor graph (the pinned commit is by Selbi182).
Notes
Builds REV01 by default (sonic.asm: Revision = 1, FixBugs = 0). The jump code cited here has no revision conditionals; claims describe the FixBugs = 0 (original) paths.

Cited on

Claims (123)

Built with Revision = 0, s1disasm is Sonic The Hedgehog (USA, Europe) byte for byte; its default build, Revision = 1, is the later REV01.build_tools/chkbitperfect.lua L23–24build_tools/chkbitperfect.lua L25–26sonic.asm L14–16Verified
In the running game, on flat ground out of water, a jump's press frame sets Sonic's Y speed to −$680 (6.5 px/frame), whether he stands, runs, or rolls._incObj/01 Sonic.asm L8_incObj/01 Sonic.asm L1218Verified
In the running game, a jump pressed on a 45° ramp built from Green Hill's $E0 ramp block adds the jump speed along the ground normal (the sine and cosine of his angle − $40) to both his X and Y speeds, and he doesn't move that frame: standing on the ramp, both went from 0 to −1177; running up it, from 395 and −396 to −782 and −1573._incObj/01 Sonic.asm L1224–1233_incObj/sub CalcSine.asm L53Verified
In the running game, the object fall routine adds a gravity of $38 (0.21875 px/frame²) to Sonic's Y speed on every airborne frame, rising or falling, after a jump or off a ledge, button held or not._incObj/sub ObjectFall & SpeedToPos.asm L5_incObj/01 Sonic.asm L363Verified
In the running game, on flat ground out of water, letting go of the button while a jump still rises faster than 4 px/frame sets Sonic's Y speed to exactly −$400: the release check runs before the move and gravity, so a release on any of airborne updates 1 to 12 moves him up exactly 4 px that frame and leaves −$3C8 after gravity (−$400 + $38, computed)._incObj/01 Sonic.asm L1273–1288_incObj/sub ObjectFall & SpeedToPos.asm L16–20Verified
In the running game, out of water, gravity slows a held jump's 6.5 px/frame take-off below the 4 px/frame release cap on its 12th airborne update, to −$3E0 (computed, −$680 + 12 × $38; the press frame itself runs no airborne update)._incObj/01 Sonic.asm L8_incObj/sub ObjectFall & SpeedToPos.asm L5_incObj/01 Sonic.asm L1276–1284_incObj/sub ObjectFall & SpeedToPos.asm L16–17Verified
In the running game, Sonic's airborne-mode routine runs the release check before the object fall routine moves Sonic and adds gravity, so a release frame moves him by the capped speed, exactly 4 px up, and gravity adds to the cap._incObj/01 Sonic.asm L359–363Verified
In the running game, on flat ground, Sonic doesn't move on a jump's press frame, even at top speed: X stays put and Y changes only by the curl (roll-shift), because the jump routine drops its return address, skipping the rest of the grounded routine, the speed-to-position move included._incObj/01 Sonic.asm L1236_incObj/01 Sonic.asm L317–323Verified
In the running game, on flat ground, a standing or running jump curls Sonic up on the press frame, shrinking his height radius by 5 px, from 19 to 14, and adding 5 px to Y, so his feet stay put._incObj/01 Sonic.asm L1250–1254_Constants.asm L312–314Verified
In the running game, the object fall routine and the speed-to-position routine move Sonic's 32-bit position each frame by his speed shifted left 8 bits, X by this frame's X speed and Y, in the air, by the Y speed before gravity, so positions are 16.16 and speeds 8.8 fixed point._incObj/sub ObjectFall & SpeedToPos.asm L16–20Verified
In the running game, a Y speed written into a jump, −$1100 rising or $FC0 falling, is neither capped nor clamped: gravity keeps adding $38, to −$10C8 a frame later and to $1068 before he lands, because the jump-height routine skips its −$FC0 cap after jumps (with the disassembly's bug fixes off, as in the original game)._incObj/01 Sonic.asm L1291–1302Verified
In the running game, on flat ground, when Sonic walks off a ledge a jump press on any of the next 5 frames gives him no upward speed, because only the grounded modes, the normal and rolling mode routines, call the jump routine._incObj/01 Sonic.asm L113–116_incObj/01 Sonic.asm L318_incObj/01 Sonic.asm L348Verified
In the running game (flat ground, out of water), a standing jump peaks 39 px up tapped (the button held on the press frame only) and 100 px held (not let go before the peak), landing on frames 39 and 62._incObj/01 Sonic.asm L8_incObj/01 Sonic.asm L1273–1288_incObj/sub ObjectFall & SpeedToPos.asm L16–20Verified
In the running game, on flat ground, Sonic's top running speed is $600 (6 px/frame): holding the d-pad his ground speed stops there, and in the air the d-pad caps his X speed there too._incObj/01 Sonic.asm L5_incObj/01 Sonic.asm L45_incObj/01 Sonic.asm L940Verified
In the running game, on flat ground, holding the d-pad the way Sonic runs, or from a standstill, adds his acceleration, $C, to his ground speed each frame, up to the top speed._incObj/01 Sonic.asm L6_incObj/01 Sonic.asm L706–723Verified
In the running game, on flat ground, holding forward above the top speed pulls Sonic's speed down to it in one frame, on the ground and in the air, because the ground move-right routine and the air steering cap after adding without first checking whether he is already faster._incObj/01 Sonic.asm L716–719_incObj/01 Sonic.asm L963–966Verified
In the running game, on flat ground, out of water and without speed shoes, with neither Left nor Right held, Sonic's ground speed loses the acceleration, $C, each frame toward zero, stopping at exactly 0. Water halves the acceleration and speed shoes double it, and the friction with it._incObj/01 Sonic.asm L499–524_incObj/01 Sonic.asm L6_incObj/01 Sonic.asm L45–46_incObj/01 Sonic.asm L381–383_incObj/01 Sonic.asm L252–259_incObj/26, 2E Monitors and Power-Ups.asm L285–293Verified
In the running game, on flat ground, holding the d-pad against Sonic's motion subtracts his deceleration, $80, a frame, and a step that would cross zero sets the speed to $80 the other way: from $40 written in by the probe, Left gives −$80, and from −$40, Right gives $80._incObj/01 Sonic.asm L7_incObj/01 Sonic.asm L665–668_incObj/01 Sonic.asm L729–732Verified
In the running game, on flat ground, reversing from top speed, Sonic running right reaches exactly 0 on the 12th frame and −$C on the 13th, but running left he jumps from −$80 to +$80 on the 12th._incObj/01 Sonic.asm L665–668_incObj/01 Sonic.asm L729–732Verified
In the running game, on flat ground, out of water and without speed shoes, turning around from top speed takes 140 frames to reach top speed the other way when Sonic runs right, and 130 when he runs left._incObj/01 Sonic.asm L636–672_incObj/01 Sonic.asm L706–736Verified
In the running game, on flat ground, out of water and without speed shoes, Sonic reaches top speed from a standstill in 128 frames, and from top speed he coasts to a stop in 128 frames with the d-pad released ($600 / $C = 128, computed)._incObj/01 Sonic.asm L5–6Verified
In the running game, on flat ground, a reversal skids (stopping animation, and facing his motion) when the slowed speed is at least $400 moving right but only $301 moving left, because the angle read overwrites the speed's low byte._incObj/01 Sonic.asm L677–694_incObj/01 Sonic.asm L748–752Verified
In the running game, on flat ground, the d-pad turns Sonic only when his ground speed is 0 or already that way, so reversing from top speed out of water and without speed shoes, he keeps facing his motion until the 13th frame, the one after his speed reaches 0 from the right or crosses it from the left._incObj/01 Sonic.asm L636–643_incObj/01 Sonic.asm L706–709_incObj/01 Sonic.asm L948–950Verified
In the running game, on flat ground, Down without Left or Right curls Sonic into a roll when his ground speed, after this frame's friction, is at least $80 either way: out of water and without speed shoes the friction is $C, so from $8C written in by the probe he rolls, from $8B he doesn't._incObj/01 Sonic.asm L1150–1161_incObj/01 Sonic.asm L1176–1187_incObj/01 Sonic.asm L320–321Verified
In the running game, on flat ground, a roll never speeds up: friction takes $6 a frame whatever is held, holding against the roll takes another $20, and a ground speed past $1000 written in by the probe gives an X speed of exactly ±$1000 (16 px/frame)._incObj/01 Sonic.asm L767–773_incObj/01 Sonic.asm L791–797_incObj/01 Sonic.asm L912–917_incObj/01 Sonic.asm L863–873Verified
In the running game, on flat ground, out of water and without speed shoes, with the slow ground speed written in by the probe, holding against a roll turns it around only below $20 moving right but up to $20 moving left, then friction leaves $7A; other slow speeds stop and stand Sonic up. In a roll the deceleration is a quarter of the $80, $20, and the friction half of the $C acceleration, $6, so a turn's $80 drops to $7A (computed)._incObj/01 Sonic.asm L896–899_incObj/01 Sonic.asm L921–924_incObj/01 Sonic.asm L767–773_incObj/01 Sonic.asm L791–825Verified
In the running game, out of water and without speed shoes, a roll started at top speed on flat ground stops on its 255th frame whether forward is held or not, and Sonic stands up on that frame. The starting frame's walking friction leaves $600 − $C = $5F4, which the roll's $6 friction takes in 254 more frames (computed)._incObj/01 Sonic.asm L767–825Verified
In the running game, on flat ground, the jump adds nothing to Sonic's X speed, and because the press frame skips the ground-move routine, he leaves the ground with the previous frame's speed, whatever the d-pad holds on that frame._incObj/01 Sonic.asm L1224–1230_incObj/sub CalcSine.asm L53_incObj/01 Sonic.asm L317–320Verified
In the running game, on flat ground, after a jump from a roll the d-pad does nothing in the air, neither steering Sonic nor turning him, and air drag still runs._incObj/01 Sonic.asm L1248–1249_incObj/01 Sonic.asm L1262–1263_incObj/01 Sonic.asm L944–945_incObj/01 Sonic.asm L974–986Verified
In the running game, on flat ground (with the disassembly's bug fixes off, as in the original game), a jump from a roll gives Sonic his standing height radius, 5 px more than the ball's, without moving him, so he lands 5 px early and uncurls with his feet 5 px above the floor._incObj/01 Sonic.asm L1241–1249_incObj/01 Sonic.asm L1830–1838_incObj/Sonic AnglePos.asm L86–91Verified
In the running game (with the disassembly's bug fixes off, as in the original game), on flat ground, a roll jump's landing frame leaves Sonic's feet 5 px above the floor, and the next frame puts them back on it._incObj/01 Sonic.asm L1241–1263_incObj/01 Sonic.asm L1558–1561_incObj/01 Sonic.asm L1813–1845_incObj/01 Sonic.asm L317–324_incObj/Sonic AnglePos.asm L99–105Verified
In the running game, out of water and without speed shoes, in the air the d-pad adds $18, twice the ground acceleration $C, to Sonic's X speed each frame either way, with no separate deceleration, up to the top speed; after a jump from a roll it does nothing._incObj/01 Sonic.asm L939–970Verified
In the running game, while Sonic rises no faster than 4 px/frame (Y speed −$400 to −1 before that frame's gravity), each frame subtracts his X speed shifted right 5 bits, about 1/32: an X speed of $400 written in by the probe was dragged at Y speeds −$400 and −1, and not at −$401 or 0._incObj/01 Sonic.asm L986–1013Verified
In the running game, on flat ground out of water, a held jump from top speed with the d-pad released is dragged on 18 frames and lands at $369 (3.41 px/frame) to the right but −$35E to the left. The drag runs while the Y speed is −$400 to −1 before gravity, which a take-off of −$680 gaining $38 a frame passes through in 18 updates (computed)._incObj/01 Sonic.asm L8_incObj/sub ObjectFall & SpeedToPos.asm L5Verified
In the running game, landing on flat ground keeps Sonic's horizontal speed: on the landing frame his ground speed is that frame's X speed, after its air steering, drag, and move, his Y speed is 0, and he stands uncurled._incObj/01 Sonic.asm L1594–1596_incObj/01 Sonic.asm L1798–1799_incObj/01 Sonic.asm L359–371_incObj/01 Sonic.asm L1830–1834Verified
A frame-by-frame model of Sonic's normal, rolling, and airborne mode routines on flat ground matches Sonic the Hedgehog itself, run in MAME on a floor built of Green Hill Act 1's blocks, on every frame of the movement lab's flat-ground presets and stress scripts and of 100 random input scripts._incObj/01 Sonic.asm L317–371_incObj/01 Sonic.asm L381–536_incObj/01 Sonic.asm L636–929_incObj/01 Sonic.asm L939–1013_incObj/01 Sonic.asm L1146–1288_incObj/01 Sonic.asm L1484–1617_incObj/01 Sonic.asm L1813–1845sonic.asm L1117–1122Verified
Standing, Sonic's floor and ceiling sensors sit 19 px above and below his center and 9 px to each side, a 19 × 39 px box; curled up, 14 and 7, 15 × 29 px._Constants.asm L311–318_incObj/Sonic Collision.asm L113–123Code
A hit throws Sonic up at -$400 and away from the object at $200 (-$200 and $100 underwater), and the hurt routine's gravity is $30, 8 less than the usual $38._incObj/Sonic ReactToItem.asm L394–405_incObj/01 Sonic.asm L1868–1869Code
A hit sets the flash timer to 120 frames and landing sets it to 120 again; it counts down only in the control routine, so Sonic blinks and can't be hurt for 120 frames after he lands._incObj/Sonic ReactToItem.asm L410_incObj/01 Sonic.asm L1916–1925_incObj/01 Sonic.asm L142–147_incObj/Sonic ReactToItem.asm L356–357Code
Hit without a shield, Sonic drops his rings, at most 32 of them as bouncing rings, and the count goes to 0; if no object slot is free for the bouncing rings, he is knocked back and keeps them all. With no rings he dies, unless the debug cheat is on, when he is knocked back instead._incObj/Sonic ReactToItem.asm L376–383_incObj/Sonic ReactToItem.asm L437–459_incObj/25, 37 Rings.asm L237–241_incObj/25, 37 Rings.asm L298Code
Sonic 1's shield takes one hit in place of the rings; the hurt routine skips the ring drop, clears the shield, and knocks Sonic back as usual._incObj/Sonic ReactToItem.asm L376–389Code
Against objects Sonic is a 16 px wide box whose half-height is his height radius minus 3: 32 px tall standing, 22 px curled in a roll or a jump from standing or running, 20 px on the ducking frame. With the disassembly's bug fixes off, as in the original game, a jump from a roll keeps the standing height radius, so that ball is 32 px tall. The level sees separate sensors (collision-box)._incObj/Sonic ReactToItem.asm L15–41_Constants.asm L316–317_Constants.asm L312–314_incObj/01 Sonic.asm L1241–1250_incObj/01 Sonic.asm L1176–1178Code
Sonic 1 has no spin dash; standing on the ground, the normal-mode routine checks only for a jump, the slope, the d-pad, and a roll._incObj/01 Sonic.asm L316–325Code
In the running game, on a 45° ramp built from Green Hill's $E0 ramp block, every ground frame's ground speed matched the flat-ground rules after a slope term of the sine of his angle times $20 while he ran, $50 while he rolled downhill and a quarter of that uphill; standing still on the ramp for 60 frames, he didn't move._incObj/01 Sonic.asm L1329–1339_incObj/01 Sonic.asm L1369–1376Verified
Sonic 1's level collision is 16 × 16 px blocks; a floor sensor reads the solid height of its pixel column in a block, a wall sensor the solid width of its pixel row, and each search looks in the sensor's block and at most one more._incObj/sub FindNearestTile & FindFloor & FindWall.asm L111–125_incObj/sub FindNearestTile & FindFloor & FindWall.asm L150–153_incObj/sub FindNearestTile & FindFloor & FindWall.asm L180–185_incObj/sub FindNearestTile & FindFloor & FindWall.asm L336–337Code
In the running game, on a 45° ramp built from Green Hill's $E0 ramp block that meets its flat $FF blocks, each ground frame's angle was the nearer floor sensor's block angle, or, when that byte has bit 0 set, his last angle snapped to the nearest quarter turn: $E0 became 0 stepping onto the flat blocks, and angles $1F, $20, $E0, $E1 written on flat ground became 0, $40, 0, 0 a frame later. Placed in the air by RAM writes, landing on the flat blocks with $F0 written gave angle 0; landing on the ramp gave $E0._incObj/Sonic AnglePos.asm L190–211_incObj/Sonic Collision.asm L166–168_incObj/Sonic Collision.asm L151_incObj/01 Sonic.asm L1558–1560_incObj/sub FindNearestTile & FindFloor & FindWall.asm L133–134Verified
On a flat floor, after each ground move, the floor-angle routine reads two floor sensors, at his center's X ± his width radius and his center's Y + his height radius (9 and 19 px standing, 7 and 14 curled); the nearer floor counts, and within 14 px either way he snaps to it._incObj/Sonic AnglePos.asm L45–51_Constants.asm L311–314_incObj/Sonic AnglePos.asm L53–61_incObj/Sonic AnglePos.asm L74–78_incObj/Sonic AnglePos.asm L84–105_incObj/Sonic AnglePos.asm L192–195_incObj/01 Sonic.asm L320–324Code
In the running game, walking and rolling off steps down built from Green Hill's 9, 10, and 11 px blocks, Sonic stayed on the ground over a 14 px step, his feet dropping 14 px on the frame his trailing floor sensor passed its edge; over a 15 px step he was in the air on that frame, with a Y speed of 0, no jump flag, and still curled if rolling, and the next frame's gravity made his Y speed $38._incObj/Sonic AnglePos.asm L99–113_incObj/01 Sonic.asm L74–76_incObj/01 Sonic.asm L114–116_incObj/01 Sonic.asm L534–536_incObj/01 Sonic.asm L1274–1275_incObj/01 Sonic.asm L1237_incObj/01 Sonic.asm L1842_incObj/01 Sonic.asm L330–334Verified
In the running game, at the end of the probe's flat runway, Sonic first counts as airborne on the frame whose move takes his trailing floor sensor past the ledge. Holding Right from a standstill 48 px before it, that is frame 49, his center 9 px past it; rolling toward it from 160 px, frame 95, his center 8 px past. A press on frame 49 still jumps, and one on any of the next 5 frames doesn't._incObj/Sonic AnglePos.asm L84–116_incObj/01 Sonic.asm L317–372_incObj/01 Sonic.asm L330–343_incObj/01 Sonic.asm L359–372_incObj/Sonic AnglePos.asm L59–78_Constants.asm L311–313Verified
In the running game, on flat ground Sonic's wall sensor sat 10 px ahead of where the frame's X speed would put his center and 8 px below it: standing on Green Hill's 14 px blocks (feet on row 961), its 10 px block ahead (top row 950) stopped him and its 9 px block (top row 951) didn't, and curled on its 9 px blocks (feet on row 966), a full block (top row 960) stopped him and a 14 px one (top row 962) didn't. In the air, after the move, his side sensors sat 10 px to either side of his center._incObj/Sonic Collision.asm L13–23_incObj/Sonic Collision.asm L57–59_Constants.asm L318_incObj/Sonic Collision.asm L298–299_incObj/Sonic Collision.asm L553–555_incObj/Sonic Collision.asm L293–295_incObj/Sonic Collision.asm L548–550_incObj/01 Sonic.asm L330–342_incObj/01 Sonic.asm L359–371_incObj/01 Sonic.asm L554–565Verified
In the running game, walking and rolling into walls of Green Hill's full blocks on flat ground, in 44 runs at speeds up to $A00 (10 of them coasting from $A00 written into his ground speed), a wall at the sensor ahead cut Sonic's X speed by the sensor's depth in whole pixels, 1 to 10 px, so that frame's move stopped the sensor 1 px short of the wall, his center 11 px from its face, and it set his ground speed to 0._incObj/01 Sonic.asm L567–579_incObj/01 Sonic.asm L591–593_incObj/01 Sonic.asm L605–606_incObj/01 Sonic.asm L875Verified
In the running game, Sonic in the air counted as moving mostly down or up by his speeds after gravity: falling rightward or rising leftward once his Y speed was at least 250/256 of his X speed, and falling leftward or rising rightward only once his X speed was under 250/256 of his Y speed. Placed beside a wall of Green Hill's full blocks on the side away from his X motion, which only the down and up checks reach, he was pushed at those Y speeds and not at 1 less, all four ways._incObj/01 Sonic.asm L1485–1504_incObj/01 Sonic.asm L1493–1495_incObj/sub CalcAngle.asm L31–46_incObj/sub CalcAngle.asm L92–93_incObj/01 Sonic.asm L330–342_incObj/01 Sonic.asm L359–371Verified
In the running game, with Sonic's position, speeds, and size written into RAM in the air beside walls of Green Hill's full blocks and one frame played, a wall at a side sensor pushed Sonic out by whole pixels, his center 11 px from its face, and set his X speed to 0; moving mostly down or up he was pushed by a wall on either side, moving mostly left or right only by one on that side, and that push ended the frame's checks: with his feet 3 px into the floor he stayed in the air beside the wall and landed away from it._incObj/01 Sonic.asm L1511–1524_incObj/01 Sonic.asm L1625–1632_incObj/01 Sonic.asm L1747–1753Verified
In the running game, written into the air above Green Hill's blocks, Sonic falling mostly down landed when a floor sensor was inside the ground unless both were deeper than his Y speed in whole pixels plus 8, and moved up by the deeper one's depth: at Y speed $100 he landed 9 px deep and not 10, at $500 13 and not 14, and with one sensor over a pit, or on a block 5 px lower, 12 px deep. Moving mostly sideways and not rising, he landed 19 px deep, and not 20, where his center's row is in the floor; rising, he didn't land._incObj/01 Sonic.asm L1528–1559_incObj/01 Sonic.asm L1652–1679_incObj/01 Sonic.asm L1773–1794Verified
In the running game, under Green Hill's full blocks, in one standing jump and in one-frame cases whose position and speeds the probe wrote into RAM, Sonic's head sensors met a ceiling only while he moved mostly up or mostly sideways: inside one, he moved down by the depth, his head sensors to the row below it. Moving mostly up, his Y speed became 0 under a flat block, and under its full $A0 block he landed on the ceiling, taking its angle and a ground speed from his Y speed. Moving sideways, his Y speed became 0 if he was rising and stayed if he was falling, and with his feet in the floor he didn't land that frame. Moving mostly down with his head in a block, he wasn't moved._incObj/01 Sonic.asm L1714–1722_incObj/01 Sonic.asm L1727–1733_incObj/01 Sonic.asm L1637–1643_incObj/Sonic Collision.asm L400–401_incObj/01 Sonic.asm L1511–1534Verified
In the running game, walking and rolling under rows of Green Hill's full blocks 16 and 32 px above the floor, Sonic stayed on the ground with his feet on row 959 and part of himself inside the blocks, and every frame's ground speed matched the flat-ground model._incObj/01 Sonic.asm L317–325_incObj/01 Sonic.asm L347–354_incObj/Sonic Collision.asm L94_incObj/01 Sonic.asm L1637_incObj/Sonic Collision.asm L57–59_Constants.asm L312–314_incObj/01 Sonic.asm L1031–1038Verified
Standing on flat ground, not on an object, with ground speed 0 after the left and right steps (before friction) and the floor under his center 12 px or more below his feet, Sonic turns to face right if last frame's right floor sensor met no block, or else left if the left one met none, and plays his balancing animation._incObj/01 Sonic.asm L402–412_incObj/01 Sonic.asm L437–457_incObj/Sonic AnglePos.asm L17–19_incObj/01 Sonic.asm L83–84Code
In the running game, a jump press went through only when Sonic's head sensors had 6 or more clear pixel rows above them, under Green Hill's full blocks and its 4 px slab on floors of its 9 to 16 px blocks: gaps of 6, 7, and 9 rows jumped, and 5, 3, and less didn't, standing and curled. A block 48 px above his floor left him 9 standing; one 32 px up refused him standing (his head 7 px inside it) and curled (3 px above his head). A refused press ran the rest of the ground frame._incObj/01 Sonic.asm L1211–1216_incObj/Sonic Collision.asm L359–366_Constants.asm L311–314_incObj/sub FindNearestTile & FindFloor & FindWall.asm L120–124_incObj/sub FindNearestTile & FindFloor & FindWall.asm L180–184_incObj/sub FindNearestTile & FindFloor & FindWall.asm L205–209_incObj/sub FindNearestTile & FindFloor & FindWall.asm L152–178_incObj/01 Sonic.asm L1256–1258_incObj/01 Sonic.asm L317–324Verified
Sonic dies once his Y position is more than 224 px below the level's bottom boundary, except past X $2000 in Scrap Brain Zone act 2, where it ends the act and loads act 3. In Green Hill Act 1, run in MAME, every one of 18 falls into a pit killed him on the first frame after his center passed the boundary plus 224 px; the Scrap Brain exception is read in the code only._incObj/01 Sonic.asm L1083–1097_incObj/01 Sonic.asm L1110–1113_incObj/01 Sonic.asm L1116–1119_incObj/Sonic ReactToItem.asm L454–459Verified
On stages built in Green Hill Act 1 from the act's full flat 16 × 16 block, the movement lab's Sonic model matches Sonic the Hedgehog itself, run in MAME, on every frame of 100 random stages with random input scripts, three in four with floating blocks, and of the lab's stage presets, until a fall into a pit kills him at the bottom boundary or he nears the end of the built floor._incObj/sub FindNearestTile & FindFloor & FindWall.asm L111–457_incObj/Sonic AnglePos.asm L6–211_incObj/Sonic Collision.asm L13–563_incObj/01 Sonic.asm L381–629_incObj/01 Sonic.asm L1484–1845_incObj/sub CalcAngle.asm L13–93Verified
In the running game, with the camera's left edge written 1 px right of Sonic as he stands in Green Hill Act 1, the camera scrolls right 16 px a frame, away from him, for 510 frames, until the act's end locks the left boundary past him and the boundary moves him 16 px inside it; with the edge on his own x, it moves 144 px left in one frame (the distance 0 less 144, computed)._inc/ScrollHoriz & ScrollVertical.asm L35–51_inc/ScrollHoriz & ScrollVertical.asm L59–62_inc/ScrollHoriz & ScrollVertical.asm L83–85_inc/ScrollHoriz & ScrollVertical.asm L93–94sonic.asm L3204–3214_incObj/01 Sonic.asm L1066–1069_incObj/01 Sonic.asm L1124–1125Verified
The title screen's cheats start with a d-pad code, read from each frame's new presses: Up, Down, Left, Right on every console in REV00 (Sonic The Hedgehog (USA, Europe)) and on non-Japanese consoles in REV01, while a Japanese console in REV01 takes Up, Down, Down, Down, Left, Right. The code is complete on the first frame after its last direction with no new d-pad press, and a wrong direction starts it over; s1disasm's bug-fix build, unlike the original, counts a wrong press that matches the code's first direction as that first press.sonic.asm L2353–2361sonic.asm L2096–2118sonic.asm L2142–2158Code
When the title screen's d-pad code completes on a Japanese console, the cheat it turns on depends on how many times C has been pressed since the title screen began: the count halved, keeping its low two bits, picks level select (0 or 1 presses), slow motion (2 or 3), debug mode (4 or 5), or the hidden-credits flag (6 or 7; the pattern repeats every 8 presses). On any other console 2 to 7 presses (again repeating every 8 presses) turn on slow motion and debug mode instead, and 0 or 1 level select, so the hidden-credits flag can't be set there from the title screen.sonic.asm L2064–2065sonic.asm L2125–2138sonic.asm L2160–2164_Variables.asm L459–462Code
With the hidden-credits flag set, holding exactly A, B, C, and Down ($72; any other button added fails) as the screen before the title loads hides its SONIC TEAM PRESENTS text and puts white ($EEE) and cyan ($880) in the first two colors of the third palette line of the palette the screen fades in to. The text is an object that makes this test once, when it first runs, which the title screen's setup does once before the screen fades in; if the test fails, it shows the text. The ending's credits load the same object, which there shows the current credits page and skips the test._incObj/8A Credits and Sonic Team Presents.asm L16–42sonic.asm L3839–3867sonic.asm L1945–1948_Constants.asm L188Code
The title screen's setup, before SONIC TEAM PRESENTS fades in, decompresses the art s1disasm calls the hidden Japanese credits into VRAM and its 40 by 28 cell map into the foreground plane, so the names are on that screen with or without a cheat. In the original game (s1disasm with its bug fixes off, either revision) the map's tiles use the first palette line; s1disasm's bug-fix build gives them the third, the line the cheat colors.sonic.asm L1922–1924sonic.asm L1930–1940_Constants.asm L486–488Code
On the SONIC TEAM PRESENTS screen the backdrop is color 0 of the third palette line, and the fade-in buffer is cleared to black before Sonic's palette is loaded into its first line, so without the cheat the backdrop fades in black. The cheat's white goes into that backdrop color, and its cyan into color 1 of the third line. In the original game (bug fixes off) the hidden names are on the first line and don't use that cyan; in s1disasm's bug-fix build they are on the third line, where their color 1 is the cheat's cyan.sonic.asm L1917sonic.asm L1942–1944_inc/Palette Index.asm L19_Variables.asm L325–328_incObj/8A Credits and Sonic Team Presents.asm L36–37Code
In MAME 0.289 from power-on, Sonic The Hedgehog (USA, Europe) on a Japanese console (MAME's Genesis, with a read tap that clears the overseas bit, bit 7, of the version register at $A10001), with C pressed six times on the title screen and then Up, Down, Left, Right, turned on the hidden-credits flag and no other cheat; on MAME's Genesis (USA), the same input turned on slow motion and debug mode.sonic.asm L2354–2355sonic.asm L2125–2136_Variables.asm L459–462sonic.asm L2160–2164Verified
Without the cheat, the hidden names are on the SONIC TEAM PRESENTS screen but black on black. In MAME 0.289 from power-on, on its Genesis with a read tap that clears the version register's overseas bit (a Japanese console), the first SONIC TEAM PRESENTS screen had the hidden names in 245 cells of the foreground plane, all in color 1 of the first palette line (line 0), which the VDP's color RAM held as $000, black, and the backdrop was $000 too. Every name pixel outside the SONIC TEAM PRESENTS text was drawn black.sonic.asm L1917sonic.asm L1937sonic.asm L1942–1944_inc/Palette Index.asm L19_Variables.asm L325–328Verified
With the cheat, the SONIC TEAM PRESENTS screen shows the hidden names in black on white, without the SONIC TEAM PRESENTS text. In MAME 0.289 on its Genesis with a read tap that clears the version register's overseas bit (a Japanese console), after the cheat input, a demo, and the Sega screen, with A, B, C, and Down held from the Sega screen on, the next SONIC TEAM PRESENTS screen had no SONIC TEAM PRESENTS text, and the third palette line began with $EEE and $880. The backdrop was white, $EEE, and the names stayed in color 1 of the first line, $000: 2,862 black pixels and every other pixel white._incObj/8A Credits and Sonic Team Presents.asm L32–38sonic.asm L1917sonic.asm L1937Verified
The end-of-act signpost counts Sonic as passing on the first frame his x position is at or right of the signpost's and less than 32 px past it; it then plays its sound, stops the act's timer, and locks the screen's left edge._incObj/0D Signpost.asm L43–55Code
Each loop in Green Hill and Star Light is one 256 × 256 px chunk of level with two versions, and a loop flag on Sonic picks which one is solid under him. The zone's table names the loop chunks, Green Hill's $B5 and Star Light's $AA and $B4, their high bit marking them special in the layout; for a special chunk, with Sonic's loop flag set, the block lookup that the wall and floor searches call reads the chunk after it instead._inc/LevelSizeLoad & BgScrollSpeed.asm L224–228_incObj/sub FindNearestTile & FindFloor & FindWall.asm L67–74_incObj/sub FindNearestTile & FindFloor & FindWall.asm L24–26_incObj/sub FindNearestTile & FindFloor & FindWall.asm L295–296Code
Sonic's loop flag switches at the loop's top: on a loop chunk it clears in the chunk's first 44 px and sets from 224 px on; between them, a clear flag sets once his angle is $01 to $80 ($80 upside down), and a set flag clears once his angle passes $80. On Star Light's second loop chunk, $B4, it clears while he is in the air. Off a loop chunk it clears, except on Green Hill's two roll-tunnel chunks, which force a roll and leave it as it is. Only Green Hill and Star Light run the check._incObj/01 Sonic.asm L2058–2062_incObj/01 Sonic.asm L2075–2085_incObj/01 Sonic.asm L2090–2094_incObj/01 Sonic.asm L2099–2135Code
Sonic's jump takes off at $680 subpixels per frame (6.5 px/frame), $800 as Super Sonic, and $380 underwater, the same take-off as Sonic 1._incObj/01 Sonic.asm L8Code
With no jump button held, the jump-height check cuts a rise faster than 4 px/frame to exactly -$400 (-$200 underwater), as in Sonic 1._incObj/01 Sonic.asm L1276–1288Code
Sonic's object setup sets his top speed to $600, his acceleration to $C, and his deceleration to $80 subpixels, Sonic 1's values; speed shoes and Super Sonic swap in others._incObj/01 Sonic.asm L5–7Code
Holding forward no longer pulls a faster Sonic down to the top speed on the ground; the move-right routine undoes the frame's acceleration and keeps the speed he had._incObj/01 Sonic.asm L716–719Code
In the air the air-control routine adds twice the acceleration, $18, either way and still caps at the top speed even when Sonic was already faster, as Sonic 1 does._incObj/01 Sonic.asm L940–966Code
Sonic 2 keeps Sonic 1's air drag; Sonic 2's air-drag routine is instruction for instruction Sonic 1's, taking X speed shifted right 5 bits while Y speed is from −$400 to −1._incObj/01 Sonic.asm L986–1013Code
On a slope Sonic's ground speed gains the sine of the angle times $20 a frame while he runs and $50 while he rolls downhill (a quarter of that uphill), with nothing while he stands; the code matches Sonic 1's._incObj/01 Sonic.asm L1323–1392Code
On a wall or ceiling below $280 (2.5 px/frame) ground speed, the slope-repel check zeroes the speed, drops Sonic off, and locks the d-pad for 30 frames, as in Sonic 1._incObj/01 Sonic.asm L1412–1427Code
Rolling, Sonic slows by half his acceleration ($6) a frame, by $20 more against the d-pad, and his X speed is clamped to $1000 (16 px/frame)._incObj/01 Sonic.asm L770–773_incObj/01 Sonic.asm L863–865Code
Sonic curls into a roll when Down is held without Left or Right and his ground speed is at least $80 either way, unless a sliding flag is set, as in Sonic 1._incObj/01 Sonic.asm L1146–1161Code
A hit throws Sonic up at -$400 and away from the object at $200 (half both underwater), and the hurt routine's gravity is $30, $10 underwater._incObj/Sonic ReactToItem.asm L394–395_incObj/01 Sonic.asm L1869–1872Code
For touching objects such as enemies and monitors, Sonic is a 16 px wide box whose half-height is his height radius minus 3: 32 px tall standing (radius $13), 22 px curled up (radius $E)._incObj/Sonic ReactToItem.asm L17–41Code
Sonic dies once his Y position is more than 224 px below the camera's bottom boundary, checked by the level-bounds routine before each move, as in Sonic 1, but with the disassembly's bug fixes off (as in the original game) Sonic 2 checks the boundary where it is and Sonic 1 the target it's moving to. In Emerald Hill Act 1, run in MAME, each of 18 falls into a pit killed him on the first frame after his center passed row 1024._incObj/01 Sonic.asm L1083–1097Verified
With neither Left nor Right held and the sliding status clear, a standing Sonic's ground speed moves 12 ($C, his acceleration) toward 0 each frame and stops at 0, as in Sonic 1; while sliding, the ground-move routine goes straight to its traction step, with no d-pad and no friction._incObj/01 Sonic.asm L499–508Code
Turning against his motion on flat ground, Sonic skids (the stopping animation, still facing his old direction of motion) when his ground speed before the turning step is at least $480 going right or $381 going left, as in Sonic 1: the angle check overwrites the low byte of the speed it then compares._incObj/01 Sonic.asm L684–692Code
Sonic's level collision radii are 9 × 19 px standing and 7 × 14 curled, set by his object setup, the jump, the roll, and the spin dash, and his wall sensors sit 10 px from his center: Sonic 1's sizes._Constants.asm L311–318Code
Sonic 2's level collision is 16 × 16 px blocks whose layout words carry solidity bits. Sonic starts testing bit $C for floors and $D for walls and ceilings; with the floor bit at $C the collision routines read the first of two collision tables, and otherwise the second. As in Sonic 1, each floor or wall search looks in the sensor's block and at most one more._incObj/sub FindNearestTile & FindFloor & FindWall.asm L111–125Code
When both floor sensors are above the floor after a ground move, the angle-and-position routine moves Sonic down onto it if it's within his X speed's whole pixels plus 4, at most 14; any farther and he's in the air. Sonic 1 reaches down 14 px at every speed._incObj/Sonic AnglePos.asm L99–101Code
On the ground, the wall check looks from where this frame's X speed will put him, 10 px ahead of his center and 8 px below it on flat ground, as in Sonic 1._incObj/Sonic Collision.asm L13–23_incObj/Sonic Collision.asm L55–59_Constants.asm L318_incObj/Sonic Collision.asm L298–299Code
On the ground with nonzero ground speed, a wall found ahead (his wall sensor, ahead of where this frame's X speed puts him, inside a block) cuts this frame's X speed so he stops beside it, and sets his ground speed to 0, as in Sonic 1._incObj/01 Sonic.asm L555–579Code
In the air the level-collision routine picks one of four checks by the direction of his speed: the angle of X and Y speed less $20, to a quarter, as in Sonic 1, with the same angle table._incObj/01 Sonic.asm L1485–1504Code
In the air, a wall sensor 10 px from his center inside a block pushes Sonic out by whole pixels and sets his X speed to 0; moving mostly sideways, that ends the frame's checks, as in Sonic 1._incObj/01 Sonic.asm L1511–1524_incObj/01 Sonic.asm L1625–1632Code
Falling mostly down, Sonic lands only if one floor sensor is no deeper in the floor than his Y speed's whole pixels plus 8, as in Sonic 1; moving mostly sideways he lands at any depth while not rising, with the disassembly's bug fixes off (as in the original game)._incObj/01 Sonic.asm L1549–1555_incObj/01 Sonic.asm L1651–1656Code
Moving mostly up, a head sensor inside a block moves Sonic down out of it and sets his Y speed to 0 on a flat ceiling; moving mostly sideways it moves him down and stops a rise, and skips the floor check that frame, as in Sonic 1._incObj/01 Sonic.asm L1714–1722_incObj/01 Sonic.asm L1636–1647Code
On the ground nothing checks above Sonic except a jump press; standing or rolling into a block's underside leaves him inside it, as in Sonic 1._incObj/01 Sonic.asm L317–325Code
A jump press jumps only if both head sensors find 6 px or more of room above his head, as in Sonic 1; the check first writes his angle plus $80 ($80 on flat ground) to both angle buffers._incObj/01 Sonic.asm L1211–1216Code
Standing on flat ground, not on an object, not sliding, and with d-pad control (its lock timer 0), with ground speed 0 after the left and right steps and the floor under his center 12 px or more below his feet, Sonic balances on the side whose floor sensor met no block last frame (the right first). He turns to face that side only when he faces away from it and the floor 6 px back from his center is also 12 px or more below; Sonic 1 turns him at any such edge._incObj/01 Sonic.asm L437–457Code
On the frame Sonic jumps, the rest of that frame's mode (the move and the floor snap) doesn't run, as in Sonic 1._incObj/01 Sonic.asm L1224–1236Code
A jump from a roll sets the roll-jump flag, and while it's set the air-control routine skips the d-pad, as in Sonic 1; the drag near the top of the jump still applies._incObj/01 Sonic.asm L944–945Code
With the disassembly's bug fixes off (as in the original game), a jump sets the standing collision radii before checking for a roll, so a roll jump keeps them while curled, and lands 5 px early; landing then lifts his center 5 px more, as in Sonic 1._incObj/01 Sonic.asm L1241–1249_incObj/01 Sonic.asm L1830–1838Code
Landing on flat ground sets his ground speed to his X speed and his Y speed to 0, and clears the jump, roll-jump, and in-air flags, as in Sonic 1; out of pinball mode it also uncurls him (the standing radii, his center 5 px up), as Sonic 1 always does._incObj/01 Sonic.asm L1594–1596_incObj/01 Sonic.asm L1822–1842Code
Sonic 2's movement on flat ground is Sonic 1's with five changes: the spin dash, a ground speed above the top kept while forward is held, a blink after standing that skips up to five frames of input, balancing that turns him only when he's far over the edge, and a floor snap that reaches down his X speed's whole pixels plus 4 rather than 14 px._incObj/01 Sonic.asm L317–325_incObj/01 Sonic.asm L437–457_incObj/01 Sonic.asm L716–719_incObj/Sonic AnglePos.asm L99–101Code
The sprite-move routine adds $38 subpixels/frame to a falling player's speed, Sonic 1's and Sonic 2's gravity, and underwater the air modes take $28 back._incObj/sub ObjectFall & SpeedToPos.asm L5Code
Sonic's setup routine sets the top speed to $600, the acceleration to $C, and the deceleration to $80 subpixels, the values of Sonic 1 and Sonic 2._incObj/01 Sonic.asm L5–7Code
In the air the air-steering routine still adds $18 a frame, but a Sonic already faster than the top speed keeps his speed; Sonic 1 and Sonic 2 pulled him down to it._incObj/01 Sonic.asm L951–956Code
Sonic 3 & Knuckles keeps Sonic 1's air drag, X speed less X speed shifted right 5 bits while Y speed is from −$400 to −1._incObj/01 Sonic.asm L986–995Code
Unlike Sonic 1 and Sonic 2, a standing player slides on a slope whose push, sine × $20, is at least $D; the walking and rolling factors are $20 and $50._incObj/01 Sonic.asm L1334–1335Code
Below $280 ground speed on a steep slope the player now slips, with a $80 push along the slope, and falls off only near walls and ceilings; Sonic 1 and 2 dropped him from any slope past 45°. As in Sonic 2, the slip also ignores Left and Right for 30 frames._incObj/01 Sonic.asm L1412–1427Code
Against objects the player is still a 16 px wide box whose half-height is his height radius minus 3 (while the insta-shield attacks, a 48 × 48 px box instead), and ducking no longer shrinks it as it did in Sonic 2._incObj/Sonic ReactToItem.asm L17–41Code
A hit throws the player up at -$400 and away from the object at $200 (half both underwater), the speeds of Sonic 1 and Sonic 2._incObj/Sonic ReactToItem.asm L394–395Code
The invulnerability count is now a byte but still 120, set by the hit and again on landing, and still blinks the sprite._incObj/Sonic ReactToItem.asm L410Code
With room overhead (jump-headroom), a jump press adds the jump speed along the ground's normal, -$680 straight up on flat ground with normal gravity (jump-speed gives the underwater and Super speeds), keeps the X speed, and ends the frame: the jump frame moves nothing. Standing, the jump curls Sonic and moves his center 5 px down (up with reverse gravity); from a roll he keeps the standing size (roll-jump-size)._incObj/01 Sonic.asm L1224–1236Code
On flat ground, not on an object, when both floor sensors find the floor more than |X speed's high byte| + 4 px below, at most 14, Sonic leaves the ground with his speeds as they are, unless a flag is set; closer than that, he moves down to it. Sonic 2 has the same rule; Sonic 1 used a flat 14 px._incObj/Sonic AnglePos.asm L100–101Code
In Sonic Advance 2 the ground acceleration rises with the ring count. At the start of each frame a bracket routine picks a bracket from the rings and the boost physics routine sets the acceleration from a table: 8 subpixels (1/256 px/frame) a frame with 10 rings or fewer, 12 with 11 to 49, 14 with 50 to 99, 16 with 100 to 149, and 18 with 150 or more. The deceleration, taken when the d-pad is held against the motion, is 64 in every bracket, and the speed-up item doubles both. With neither Left nor Right held, or while a timer counts down (30 frames, half a second, which an update function sets when the player's rotation is 32 to 223 of 256 (tilted an eighth of a turn or more) and his ground speed is under 1.875 px/frame, as it zeroes that speed and puts him in the air), the ground movement routine takes a fixed 8 a frame off the speed toward 0. Sonic 1's rates are $C (12) to accelerate, the same $C for the friction, and $80 (128) against the motion._incObj/01 Sonic.asm L5–7_incObj/01 Sonic.asm L499–506Code
Outside boost mode the boost physics routine sets the top speed, the speed holding forward builds to in the ground movement routine, to 6 px/frame (Q(6.0)), Sonic 1's top speed ($600). A faster speed, from a slope, is cut only at the ground cap, by the routine at 0x08023260, which the ground state calls after adding the slope term: 9 px/frame, or 15 while a spin-attack flag is set, as a spin dash sets it._incObj/01 Sonic.asm L5Code
Boost mode starts from a run held at the top speed. Holding forward on the ground at 6 px/frame or faster, the ground movement routine leaves the speed as it is and adds the frame's acceleration to a boost counter, in the branch where Sonic 2's move-right routine keeps a speed above the top and Sonic 1's cuts it back to the top. At the start of each frame the boost state routine turns boost mode on once the counter reaches the ring bracket's entry in a threshold table: Q(8) (2048) with 10 rings or fewer, 2040 with 11 to 49, 1680 with 50 to 99, 1440 with 100 to 149, and 1080 with 150 or more. In the air or below the top speed it sets the counter back to 0. With each bracket's acceleration that is 256, 170, 120, 90, and 60 frames of holding forward at the top speed, and half as many with the speed-up item (computed)._incObj/01 Sonic.asm L716–719Code
In boost mode the boost physics routine raises the top speed, the speed holding forward builds to, from 6 to 12 px/frame, twice Sonic 1's single top speed ($600; computed), and the ground cap to 15; the acceleration still follows the ring count. The boost state routine looks for the end of boost mode only on the ground, where a ground speed below 4.5 px/frame ends it. Among the other ends are a hit, the start of Tails's or Cream's flight, a multiplayer finish, the special stage transition, and the player's setup._incObj/01 Sonic.asm L5Code
The jump start routine, which doesn't test the character, adds 4.875 px/frame (2.625 in water) to the speed along the ground's normal (his rotation less a quarter turn). Sonic 1's jump routine adds $680 (6.5 px/frame) along the normal the same way, so Sonic Advance 2's take-off is three quarters of it (computed)._incObj/01 Sonic.asm L8_incObj/01 Sonic.asm L1218_incObj/01 Sonic.asm L1224–1233Code
Each frame of a jump, button held or not, the jumping state's routine adds 42/256 px/frame² (12/256 in water) to the vertical speed through a fall-speed update, except on a frame where Sonic's forward thrust or a mid-air move starts: the routine returns before the gravity then. That is three quarters of the gravity Sonic 1's airborne-rolling mode adds through its object fall routine, $38 (56/256) a frame (computed)._incObj/sub ObjectFall & SpeedToPos.asm L5_incObj/01 Sonic.asm L359–363Code
In a jump (a move-state flag the jump start routine sets), on any frame the jump button isn't held, the jumping state's routine cuts a rise faster than 3 px/frame to exactly −3 (−1.5 in water). Outside the Collect Rings multiplayer mode it first tries Sonic's forward thrust and the mid-air moves, and a frame on which one starts skips the cap. Sonic 1's release cap cuts to 4 px/frame (-$400), so this cap too is three quarters of Sonic 1's (computed)._incObj/01 Sonic.asm L1273–1288Code
The ending credits, under "Sonic Team Staff", give game plan to Carol Yas, program to Yu 2, character design to BigIsland, design to Jinya and Phenix Rie, sound production to Masato Nakamura, and sound programming to Jimita and Macky._maps/Credits.asm L17_maps/Credits.asm L36_maps/Credits.asm L58_maps/Credits.asm L72_maps/Credits.asm L101_maps/Credits.asm L127_maps/Credits.asm L159Wiki