I finally beat Super Mario Bros! I only used 50 separate save states and restarted from them countless times 😅

Super Mario Bros victory screen.
“Thank you Mario! Your quest is over. We present you a new quest. Push button B to select a world” Super Mario Bros victory screen. “Thank you Mario! Your quest is over. We present you a new quest. Push button B to select a world”

NES Emulator: Existentials Crisis

In which I discover the performance downsides of Swift existentials, to the tune of hundreds of thousands of dynamically dispatched function calls per second.

sadlerjw.com/2025/08/22/nes-em

in reply to self

I made a website for my NES emulator, and there's a macOS build anyone can download and use! (There are a list of caveats on the website.)
A TestFlight build is in review for iPhone and iPad, so that will come later.
nesbit.app

in reply to self

Nesbit, my NES emulator written from scratch in Swift, is available for macOS and now there’s a TestFlight for iOS and iPadOS too! It has an on-screen controller for touch devices and supports hardware keyboards and gamepads on all platforms. (It only supports mapper 0 roms for now, though.)

You can find details, plus the TestFlight link and a direct download for macOS, on the website: nesbit.app

I feel sick. The guy came with an appropriate amount of skepticism and he was still hoodwinked by ChatGPT for nearly a month.
mastodon.social/@kashhill/1150

Ruining the Swift-iness of my code to get some huge performance wins. Instead of completely pinning the CPU at 60 FPS now I’m using 50-70% of the CPU.
Using existentials in tight loops is bad news. But existentials are so CONVEEENIENT 😩

in reply to self

More things are working! I think from the video series that inspired this project, these palette issues will go away once I implement sprites. (So far we’re just seeing backgrounds.)
🤞

An NES test ROM’s display showing a list of tests with “OK” next to each. An NES test ROM’s display showing a list of tests with “OK” next to each.
Donkey Kong’s demo mode showing correctly, albeit without any sprites. DK is visible at the top of the level but Mario and DK’s barrels are not visible. Donkey Kong’s demo mode showing correctly, albeit without any sprites. DK is visible at the top of the level but Mario and DK’s barrels are not visible.
The opening screen of Super Mario Bros, but several portions of the screen are showing the wrong colours. The opening screen of Super Mario Bros, but several portions of the screen are showing the wrong colours.
in reply to self

SPRITES!!!
I changed something that’s corrupting the palette’s background, but SPRITES ARE WORKING!

The Donkey Kong demo that shows if you don’t press any buttons at the start screen. DK now throws barrels, Mario climbs up the level and uses a hammer to explode some barrels before being hit by one. The background is grey instead of the correct colour, which is black.
in reply to self

THIS CLOSE to perfect! Looks like I have an off-by-one error with the scrolling on the scanline at the bottom of the hud area, but otherwise I’m absolutely over the moon with this!

The demo that plays at the start of Super Mario Bros. There’s a glitch where the bottom line of the hud area scrolls and snaps back when it should stay static on screen, but all the animations and colours are correct!
in reply to self

I had to dip into UIKit to make a controller that worked with multiple simultaneous touches and tracked touches when they enter a view instead of just when touches _begin_ in a view, but this thing is properly playable now! (I am bad at Mario though)

A playthrough of world 1-1 of Super Mario Bros using a very ugly on-screen controller.
in reply to self

I had to look at the Delta source code for inspiration because as far as I can tell UIControl.Event.touchDragEnter does not behave as advertised. Thanks @rileytestut!

Kershaw for the Dodgers vs Scherzer for the Jays AND Buck Martinez is back on the Jays broadcast‽ Should be one of the better games of the sEEEason!

I figured, the NES is 40+ years old, shouldn’t be too hard to emulate it fast enough.

I was wrong. With the PPU generating garbage pixels (I’m not far enough along to run real games yet) I’m only getting 30fps on my iPhone 14 Pro.

I may have to lose some of the Swiftiness of my code to make it fast enough. It needs to run at 60fps (for NTSC) because the CPU and PPU and their numbers of clock cycles per frame are directly tied together.

in reply to self

I say “garbage” pixels and not “random” pixels because generating random pixels using UInt8.random() produced single-digit frames per second. Randomness is expensive!

in reply to self

I’ve got ROMs loading into my NES emulator (mapper 0 only for now) and things are extremely not working! Found a big ol’ bug in my jump instructions. I’m sure there are many more to come.

in reply to self

Update: there were bugs in like 8 of my instructions 🫣
The test ROM I’m using is insisting that I implement the illegal instructions, and I’m not interested in that right now, so on to trying to make graphics render. I’m even less sure what’s going wrong here.

in reply to self

Some things are working! (Other things are not (not pictured).)

A test ROM is running in my NES emulator. A checkerboard pattern and a rainbow pattern scroll as I hold the start button. A frames per second counter shows 49 FPS.

Glad I never got around to buying one. Yikes.
social.lol/@adam/1149595540435

Writing an NES emulator in Swift dev diary: CPU instructions!
sadlerjw.com/2025/08/02/nes-em

On an absolute lark, I’m writing an NES emulator in Swift that I’ll probably never finish…

sadlerjw.com/2025/07/31/writin

in reply to self

I haven’t been this engaged by a project in years. Except Factorio. Does Factorio count?

theguardian.com/world/2025/jul

@thomasfuchs unless I’m misunderstanding you, this is how it works on iPadOS 18 too. When I scroll down a page (whether on portrait or landscape), the address bar and tabs collapse.

(I’m on 18.5 but I don’t have 26 installed anywhere to compare.)

@thomasfuchs why can’t either of these dudes reliably spell “Replit,” the name of the thing they’re talking about 🤨

This is an absolutely _stunning_ performance of Rachmaninov’s 3rd Piano Concerto. I’ve heard many versions, and Argerich’s is my favourite, but Yunchan makes so many interesting choices, and he’s just 18 years old here. Marin Alsop conducting.
Well worth the 45 minutes.
youtube.com/watch?v=DPJL488cfRw

in reply to self

If you know the piece well, watch the concert first. Then watch this video and see how much you noticed of the bits that make it special.
I was pleased that I noticed a few, but I learned a lot: youtu.be/DhUFLepewgA?si=Xale4m

Software development is a field brimming with table saws. Compilers, high level languages, IDEs...
Quitting programming because of AI is like quitting carpentry because IKEA came along and changed the game, vastly reducing most people's need for carpenters.
I'm not saying it's the end of our industry, but it's hugely demoralizing to many of us, and companies are salivating over how many of us they can get rid of.
(Of course, the better analogy is textiles in the 1800s)
manton.org/2025/07/03/simon-wi

Spectacular.
social.ericwbailey.website/@er

@marioguzman I’m always taken by the clarity of hierarchy in these old screenshots between the chrome, source list, and what Apple would call “content” today.
Even more so now that the first stated design principle of Liquid Glass is hierarchy, which is barely noticeable in their new designs in comparison!

New iOS “Liquid Glass” design: looks super cool, technically impressive, major contrast issues and visually distracting during scrolling.
The first betas for iOS 7 had similar readability issues. Hopefully this gets adjusted before release like it was then.
mastodon.blaede.family/@cassid

“I Think I’m Done Thinking About genAI For Now”
blog.glyph.im/2025/06/i-think-

The iOS text editing system added a “finish my sentence” type of autocomplete in I think iOS 18. (I know Gmail’s had that for years and years, but I don’t use Gmail.)

Does anyone else find themselves taking a suggested sentence completion as a cue like “I’d better find a different way to finish this sentence, even if it was pretty much what I already had in mind?”

I know it’s irrational, but I definitely do that. Not even on purpose - it just happens.

A genuine question: when people talk about AI they talk about non-deterministic computing. Is that really true? Do LLMs and such not produce the same output given identical input? Or do they mean “unpredictable to humans,” as in, we have no idea what will happen if we haven’t tried this exact input before?
(I am aware of context windows, I consider them part of the input in the context of this question.)

in reply to self

Apparently it really does mean non-deterministic. From @cocoaphony’s article cocoaphony.micro.blog/2025/06/
(cc @mattiem since you were also wondering)

AI is nondeterministic. Just because a prompt worked once does not mean it will work the same way a second time. Even with the same prompt, context and model, an LLM will generally produce different results. This is intentional. How random the results will be is a tunable property called temperature, so for activities that should have consistent behaviors, it can be helpful to reduce the temperature. Reducing the temperature prevents the model from straying as far from its training data, so setting it too low can make it unable to adapt to novel inputs. AI is nondeterministic. Just because a prompt worked once does not mean it will work the same way a second time. Even with the same prompt, context and model, an LLM will generally produce different results. This is intentional. How random the results will be is a tunable property called temperature, so for activities that should have consistent behaviors, it can be helpful to reduce the temperature. Reducing the temperature prevents the model from straying as far from its training data, so setting it too low can make it unable to adapt to novel inputs.