<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>TinyComputers.io (Posts about tony cruise)</title><link>https://tinycomputers.io/</link><description></description><atom:link href="https://tinycomputers.io/categories/tony-cruise.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Original site content © 2022–2026 Tiny Machines Workshop, LLC, except where otherwise noted. Some rights reserved.</copyright><lastBuildDate>Mon, 16 Nov 2026 20:51:25 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Review of "Classic Game Programming on the NES: Make Your Own Retro Video Game" by Tony Cruise</title><link>https://tinycomputers.io/posts/review-of-classic-game-programming-on-the-nes-by-tony-cruise.html?utm_source=feed&amp;utm_medium=rss&amp;utm_campaign=rss</link><dc:creator>A.C. Jokela</dc:creator><description>&lt;div class="audio-widget"&gt;
&lt;div class="audio-widget-header"&gt;
&lt;span class="audio-widget-icon"&gt;🎧&lt;/span&gt;
&lt;span class="audio-widget-label"&gt;Listen to this article&lt;/span&gt;
&lt;/div&gt;
&lt;audio controls preload="metadata"&gt;
&lt;source src="https://tinycomputers.io/review-of-classic-game-programming-on-the-nes-by-tony-cruise_tts.mp3" type="audio/mpeg"&gt;
&lt;/source&gt;&lt;/audio&gt;
&lt;div class="audio-widget-footer"&gt;39 min · AI-generated narration&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Disclosure:&lt;/strong&gt; I have been a technical reviewer for Manning on several projects.&lt;/p&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;&lt;img src="https://tinycomputers.io/images/classic-game-programming-on-the-nes/cover-001.png" alt="Cover of Classic Game Programming on the NES by Tony Cruise, foreword by Philip and Andrew Oliver, published by Manning. The subtitle, Make your own retro video game, sits at the top right. The title is set in large orange type that runs from a navy band onto the white page, beside Manning's usual historical costume engraving: a woman in a blue gown and gold headdress, redrawn holding a gray NES console and controller." style="float: right; max-width: 250px; margin: 0 0 1em 1.5em;"&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://go.tinymachines.io/classic-game-programming-nes"&gt;&lt;em&gt;Classic Game Programming on the NES: Make Your Own Retro Video Game&lt;/em&gt;&lt;/a&gt; is Tony Cruise's first book for Manning, published in June 2024 with a foreword by the Oliver Twins. Cruise has been programming 8-bit machines since the early 1980s, and his previous book, the self-published &lt;a href="https://go.tinymachines.io/programming-games-colecovision-adam"&gt;&lt;em&gt;Programming Games for the ColecoVision and Adam in Assembler&lt;/em&gt;&lt;/a&gt;, teaches Z80 assembly. This one moves to the Ricoh 2A03, the 6502 variant inside the Nintendo Entertainment System.&lt;/p&gt;
&lt;p&gt;I have spent much of the past year on the Z80, from &lt;a href="https://tinycomputers.io/posts/cpm-on-physical-retroshield-z80.html"&gt;CP/M on a RetroShield&lt;/a&gt; to a &lt;a href="https://tinycomputers.io/posts/clean-room-z80-emulator.html"&gt;clean-room emulator&lt;/a&gt; to reviews of &lt;a href="https://tinycomputers.io/posts/build-your-own-z80-computer-steve-ciarcia.html"&gt;Ciarcia&lt;/a&gt; and &lt;a href="https://tinycomputers.io/posts/the-z80-microcomputer-handbook-william-barden.html"&gt;Barden&lt;/a&gt;. I wanted a 6502 book to set beside them, and the NES is the natural machine. It sold more than 60 million consoles, and its video chip, the picture processing unit or PPU, punishes sloppy timing.&lt;/p&gt;
&lt;p&gt;Chapters 1 and 2 cover the console and the tools, and chapters 3 and 4 are a 6502 primer built around an online simulator. Chapter 5 is a small demo with a bat and a ball. Chapters 6 through 16 build one game, Mega Blast, a vertical shooter modeled on the Intellivision's Astrosmash, adding a feature per chapter: sprites, enemies, collisions, scoring, lives, animation, sound effects, and music. In its front matter, on page xv, the book names its reader: "For anyone interested in building their own retro games! No programming experience required."&lt;/p&gt;
&lt;p&gt;I tested the book the way I would test code. I built every chapter folder in the &lt;a href="https://go.tinymachines.io/tony-cruise-nes-repo"&gt;companion repository&lt;/a&gt; with cc65 2.19, the book's toolchain, booted each ROM in an emulator, and ran suspect routines on a 6502 simulator. I checked every error below against a primary source: the book itself, a tool's source code, or the &lt;a href="https://go.tinymachines.io/nesdev-wiki"&gt;NESdev wiki&lt;/a&gt;, the NES homebrew community's hardware reference. The game holds up. The explanations of the machine underneath it often don't.&lt;/p&gt;
&lt;h3&gt;A Z80 Programmer Crosses Over&lt;/h3&gt;
&lt;p&gt;In the preface, Cruise traces his path: a secondhand Texas Instruments TI-99/4, then two Spectravideo computers, the second fitted with a ColecoVision adapter, and later MSX home computers. Apart from the TI-99/4, every one of them runs a Z80 at about 3.58 MHz. He came to the NES decades later, with an &lt;a href="https://go.tinymachines.io/nintendo-world-championships-cartridge"&gt;NES Championships cartridge&lt;/a&gt; for the first Game On Expo in Arizona. On page xiii, he writes: "I developed this in three months, learning both 6502 Assembler and the NES hardware at the same time."&lt;/p&gt;
&lt;p&gt;He says his interest in the NES comes from "its Japanese origin and part of its graphics chip design inherited from the TMS graphics chips found in the Spectravideo and MSX computers." The chips he means are Texas Instruments' TMS9918 family, the video chips in his Spectravideo and MSX machines and in the ColecoVision. That lineage is debated: some veterans of the NESdev forums see the TMS9918 in the PPU, and others call the PPU completely custom.&lt;/p&gt;
&lt;p&gt;Two slips in chapter 1 read like TMS9918 habits. Page 10 correctly warns that changing video memory, or VRAM, at the wrong time corrupts the screen. It then adds that "the time to both read and write VRAM is longer while the screen is being drawn (as the PPU is busy)." That is true of the TMS9918, which needs slower CPU access during active display. The NES never makes the CPU wait for video memory. A write during rendering is no slower; it lands at the wrong address instead.&lt;/p&gt;
&lt;p&gt;Page 7 hedges in one bullet, then states flatly that tile patterns "need to be loaded from the game ROM into the NES's video memory before they can be used," which is how a TMS9918 machine works. Every ROM in this book keeps its tile graphics in a ROM chip on the cartridge, which the PPU reads directly, as page 81 itself says. I can't prove where the slips came from, but both describe a chip Cruise has programmed since the early 1980s.&lt;/p&gt;
&lt;h3&gt;What Works&lt;/h3&gt;
&lt;p&gt;Figure 1.5 on page 6 is the most useful diagram in the book. It splits a game into two parts. A main loop reads input, spawns and moves enemies, checks collisions, animates, and advances the level. A separate routine runs during vblank, the short gap between frames when the PPU isn't drawing, and updates sprites, writes to video memory, and plays music. The PPU starts that routine through the CPU's non-maskable interrupt, so NES programmers call it the NMI. That split is the central discipline of NES programming, and the book establishes it before any code.&lt;/p&gt;
&lt;figure style="margin: 2rem 0; text-align: center;"&gt;
&lt;a href="https://tinycomputers.io/images/classic-game-programming-on-the-nes/page-6-figure-1-5.png"&gt;&lt;img src="https://tinycomputers.io/images/classic-game-programming-on-the-nes/page-6-figure-1-5.png" alt="Page 6 of Classic Game Programming on the NES, cropped to section 1.5, The structure of a game, with Figure 1.5. A flowchart starts at Initialize console and leads to an Intro screens box holding Title screen, Options, High scores, and Game information. Start game leads into The game loop: Get player input and move player, Initialize or spawn enemies, Move enemies, Detect collisions, Animate objects, and Level progression or increase difficulty, looping back. Game over leads to Ending a game, which returns to the intro screens. A separate Video processor box shows PPU draws screen feeding a vBlank NMI routine with three steps: Update sprite data (OAM), Write changes to VRAM, and Play music and sound effects." width="1475" height="1200" loading="lazy" style="display: block; width: 560px; max-width: 100%; height: auto; margin: 0 auto; border: 1px solid #ccc; border-radius: 4px;"&gt;&lt;/a&gt;
&lt;figcaption&gt;&lt;em&gt;Page 6 of the book, with Figure 1.5. I cropped it to section 1.5 and removed the licensing line at the foot of the page, which carries my email address.&lt;/em&gt;&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Chapter 5 starts with the linker instead of the code. It explains the linker's configuration file one memory area at a time. The result is a ROM image of exactly 40,976 bytes: a 16-byte header that tells emulators what cartridge to expect, 32 KB of program ROM, and 8 KB of tile graphics. All 12 chapter folders build to that size with zero warnings, and each one is a complete snapshot, so diffing two shows what a chapter adds.&lt;/p&gt;
&lt;p&gt;The game code has habits worth copying:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The finished NMI works in the right order.&lt;/strong&gt; The sprite table goes to the PPU first, by a hardware block copy, then the video memory updates, then the scroll and control registers, then music.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;During play, game logic never touches video memory.&lt;/strong&gt; It sets bits in an &lt;code&gt;update&lt;/code&gt; byte, and the NMI redraws only what changed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The random number generator is good.&lt;/strong&gt; Two linear-feedback shift registers with periods of 65,535 and 32,767 give a combined period of about 2.1 billion, seeded from the frame on which the player presses a button.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Collision detection is derived, not handed over.&lt;/strong&gt; Three diagrams in chapter 9 build the overlap test, and the code exits on the first failed comparison.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Enemies are data.&lt;/strong&gt; Chapter 12 defines each enemy type as a nine-byte record, so a new enemy is mostly a new row in a table.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Chapter 13 is a catalog of cheap effects.&lt;/strong&gt; Palette cycling, a backdrop flash, and a screen shake take under 40 bytes each, and twinkling stars made by swapping tiles take about 200.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Chapter 16 also has a section on publishing, rare in a programming book, that names suppliers of cartridge boards and shells and lists homebrew publishers.&lt;/p&gt;
&lt;figure style="margin: 2rem 0; text-align: center;"&gt;
&lt;a href="https://tinycomputers.io/images/classic-game-programming-on-the-nes/ch16-gameplay.png"&gt;&lt;img src="https://tinycomputers.io/images/classic-game-programming-on-the-nes/ch16-gameplay.png" alt="Mega Blast built from the book's chapter 16 code, running in an emulator. A blue fighter at the bottom of the screen has fired a yellow shot that is passing just left of a large olive meteor. A lavender smart bomb falls through a black sky dotted with pink stars, and a small meteor has dropped through a tan zigzag mountain ridge toward a red ground line. The bottom row reads SCORE 0000690, followed by five reserve ships." width="768" height="672" loading="lazy" style="display: block; width: 512px; max-width: 100%; height: auto; margin: 0 auto; border: 1px solid #ccc; border-radius: 4px; image-rendering: pixelated;"&gt;&lt;/a&gt;
&lt;figcaption&gt;&lt;em&gt;The chapter 16 ROM, built from the companion repository and run in the cynes emulator, with the top and bottom eight lines cropped as an NTSC television would hide them.&lt;/em&gt;&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h3&gt;Test the Exercises Like Code&lt;/h3&gt;
&lt;p&gt;Chapters 3 and 4 teach the 6502 with an online simulator built from Nick Morgan's 6502js. Each of the 28 exercises ends in a box showing the register dump the reader should see: paste a few lines, assemble, run, and compare. It is a good design, and it only works if the listings and the boxes are right. Eight of the 28 go wrong.&lt;/p&gt;
&lt;p&gt;In chapter 3, five of the 13 exercises go wrong. Two boxes print the wrong final program counter. In three more, the listing itself is wrong. Exercise 3.9 stores the accumulator where the text says X, and Exercises 3.12 and 3.13, which cover indirect stores, the hardest idea in the chapter, leave out the code that sets up the pointer. Their boxes faithfully show the result: a byte landing in zero page, the first 256 bytes of RAM, instead of at the addresses 0x0306 and 0x0300 that the text promises. The sentence that splits the pointer's address into two bytes gives the high byte as 30, not 03, word for word, on four different pages, though the table beside it gets it right.&lt;/p&gt;
&lt;p&gt;In chapter 4, three of the 15 boxes are wrong, two of them with an accumulator value the code can't produce, though the prose just above those two gives the right answer. Pages 62 and 63 add four faulty increment and decrement examples, three of them with broken code.&lt;/p&gt;
&lt;p&gt;The reference material has the same problems:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Addressing modes that don't exist.&lt;/strong&gt; Page 37 says the zero-page indexed load "can use either the X or Y registers for the index value." The 6502's load instruction, LDA, has no such Y form, and the book's own simulator rejects it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Carry after subtraction.&lt;/strong&gt; Table 4.1 says carry is set "if an overflow occurred during addition or subtraction." That is the Z80's rule, where subtraction sets carry on a borrow. On the 6502, subtraction clears carry on a borrow, as Table 3.6 correctly said.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Rotation.&lt;/strong&gt; Page 74 says of the rotate instructions, "If this instruction is repeated eight times, the value will be back to where we started." The 6502 rotates through the carry, a nine-bit ring, so it takes nine. Eight is right for the Z80's circular rotates, which copy the outgoing bit straight back in, though not for its rotates through carry.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Interrupts.&lt;/strong&gt; Page 89 says SEI, the instruction that switches off interrupts, "clears the interrupt flag." It sets the flag, which the book's tables say is what disables interrupts.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Label case.&lt;/strong&gt; Page 69 says "It doesn't matter whether you use upper or lower case for the label," which a beginner will likely read as "labels ignore case." They don't: the book's assembler, ca65, as the book runs it, and the book's own simulator both treat case as significant. Listing 6.10 spells &lt;code&gt;INES_MAPPER&lt;/code&gt; as &lt;code&gt;INES_mapper&lt;/code&gt; once, and as printed it fails to assemble. The repository's copy is correct.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Manning's errata lists two corrections, both from later chapters, and the repository starts at chapter 5, so neither the errata nor the repository corrects these exercises. My copy of the PDF, dated May 2025, already includes both errata corrections, so every error above survived Manning's correction pass. A beginner whose screen, box, and explanation disagree has no way to know which to trust.&lt;/p&gt;
&lt;h3&gt;Bugs the Prose Calls Correct&lt;/h3&gt;
&lt;p&gt;The game chapters are more accurate, but where they go wrong, the prose usually describes the broken code as working.&lt;/p&gt;
&lt;p&gt;The first NES program in the book has a visible bug. Chapter 5's NMI points the PPU's address register at the palette and never resets the scroll afterward. The two share an internal latch, so the background is drawn about 45 lines too low. Whatever sits in the unused second nametable, the tile map for a second screen, fills the top of the screen. The book's own Figure 5.4 shows the demo's WELCOME message at the same wrong height. One write to the PPU's control register and two to its scroll register fix it. Chapter 6 adds those writes without saying they fix anything. It introduces the routine as "The next function we can keep like the example in the last chapter."&lt;/p&gt;
&lt;p&gt;A reader reported the problem as &lt;a href="https://go.tinymachines.io/tony-cruise-nes-issue-4"&gt;issue 4&lt;/a&gt; in March 2026, and it is still open. The chapter 5 template closely follows Brad Smith's public &lt;a href="https://go.tinymachines.io/nes-ca65-example"&gt;NES-ca65-example&lt;/a&gt;, which resets the scroll. Its license doesn't require credit, but a pointer to it would have helped readers find that fix.&lt;/p&gt;
&lt;figure style="margin: 2rem 0; text-align: center;"&gt;
&lt;a href="https://tinycomputers.io/images/classic-game-programming-on-the-nes/ch05-scroll-bug.png"&gt;&lt;img src="https://tinycomputers.io/images/classic-game-programming-on-the-nes/ch05-scroll-bug.png" alt="Three versions of the chapter 5 example screen side by side. Left: the book's Figure 5.4 from page 105, printed on white, with WELCOME about a third of the way down. Middle: the companion repository's chapter 5 ROM in an emulator, with WELCOME at the same height and a band of magenta and green garbage tiles across the top. Right: the same code with one control-register write and two scroll-register writes added after the palette upload, which puts WELCOME near the top, at tile row 4 where the code places it, and clears the garbage. The bat sits at the same spot in all three panels, while the bouncing ball was caught in a different place in the book's figure." width="1602" height="546" loading="lazy" style="display: block; width: 720px; max-width: 100%; height: auto; margin: 0 auto; border: 1px solid #ccc; border-radius: 4px;"&gt;&lt;/a&gt;
&lt;figcaption&gt;&lt;em&gt;Left, the book's Figure 5.4, cropped from page 105. Middle, the repository's chapter 5 ROM in the cynes emulator. Right, the same ROM with the scroll reset added. The fix leaves the sprites in place because they ignore the scroll; the ball bounces, so the book caught it elsewhere.&lt;/em&gt;&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Mega Blast keeps its score in three bytes that each hold 0 to 99, and the code that carries between them has two flag bugs. I confirmed both by running the routines:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Listing 10.3&lt;/strong&gt; compares each byte with 99 and branches if the carry flag is clear, which page 162 describes as "less than or equal to 99." The 6502's compare sets carry when the value is at least 99, the reverse of the Z80's, so the branch is taken only below 99. A byte that reaches 99 is treated as an overflow and becomes 255. The same page promises the score will roll over "but won't cause any strange display problems or make our game crash." A reader's &lt;a href="https://go.tinymachines.io/tony-cruise-nes-pr-2"&gt;pull request&lt;/a&gt; fixed the repository in June 2024, but the book still prints the bug, even after Manning's spring 2025 corrections.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Score subtraction&lt;/strong&gt; on page 164 decrements the middle byte and then branches on carry: "If decrementing the value of the second byte does not set the carry flag (i.e., does not go past zero), then we can jump to our @skip label." Decrementing never touches the carry, on the 6502 or the Z80. The branch tests the carry left by the addition before it, which is always set, so a borrow never reaches the top byte. Each meteor that reaches the ground costs 10 points, and at exactly 100,000 points one should leave 99,990; the routine leaves the middle byte at 255. Few players will get there, but the lesson that decrementing sets the carry is wrong on both chips.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is the repository's code, with my comments in place of the book's:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;clc&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;adc&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="c1"&gt;; fix up the low byte&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;sta&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;dec&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="c1"&gt;; DEC sets N and Z, never C&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;bcs&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;@skip&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="c1"&gt;; always taken: C is still set by the ADC&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Two promised features never arrive. Chapter 12 draws tiles for an enemy explosion that is never spawned, so shot meteors simply vanish, and the ship's final explosion freezes on its first frame instead of playing out as page 178 plans.&lt;/p&gt;
&lt;p&gt;The book never puts a number on the vblank budget, though page 209 says NMI code must be "as fast as possible." Page 93 even says the hardware copy of the sprite table runs "without tying up the CPU." It halts the CPU for 513 or 514 cycles, about 23% of the roughly 2,273 cycles of vblank on a North American console.&lt;/p&gt;
&lt;p&gt;The worst bug is in the lives display, and it blows far past that budget. Listing 11.13 loads the number of lives into the X register, then masks the accumulator down to its low three bits, a step annotated "Limits to a max of 8." The count is in X, not the accumulator, so nothing is limited. The loop that follows, which blanks the unused ship icons, counts eight minus the number of lives. At eight lives that count is zero, and a countdown loop that starts at zero wraps around and runs 256 times, as a Z80 DJNZ loop does when B starts at zero. The NMI writes 1,056 bytes to video memory, which takes about 7,000 cycles, three times all of vblank, and the writes that land after vblank wreck the screen.&lt;/p&gt;
&lt;p&gt;Chapters 11 through 15 never let the count pass five, but chapter 16 adds an extra life every 5,000 points with no cap. A player who reaches 15,000 points without losing a ship triggers the bug. The repository's code awards lives at 1,000, 6,000, and 11,000 points, so it fails at 11,000.&lt;/p&gt;
&lt;figure style="margin: 2rem 0; text-align: center;"&gt;
&lt;a href="https://tinycomputers.io/images/classic-game-programming-on-the-nes/ch16-lives-overflow.png"&gt;&lt;img src="https://tinycomputers.io/images/classic-game-programming-on-the-nes/ch16-lives-overflow.png" alt="Four emulator screenshots of the chapter 16 ROM in a two-by-two grid. Top left, five lives as the game starts: a clean screen with the LEVEL 01 banner, stars, the mountain ridge, the ship, SCORE 0000000, and five reserve ships. Top right, the frame after the lives counter becomes eight: the background turns gray, streaks and stray letters cover the top and bottom of the screen, and the score label is split apart. Bottom left, two seconds later: stray letters and fragments of text remain scattered across the playfield, and the lives row is broken. Bottom right, the control with seven lives two seconds later: a clean screen with seven reserve ships." width="1068" height="1088" loading="lazy" style="display: block; width: 560px; max-width: 100%; height: auto; margin: 0 auto; border: 1px solid #ccc; border-radius: 4px; image-rendering: pixelated;"&gt;&lt;/a&gt;
&lt;figcaption&gt;&lt;em&gt;The chapter 16 ROM in the cynes emulator. I set the lives counter in RAM rather than earning the lives in play. Eight lives wrecks the screen; seven, the control, draws cleanly.&lt;/em&gt;&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h3&gt;Sound by Screenshot&lt;/h3&gt;
&lt;p&gt;Chapters 14 and 15 add sound with FamiStudio, a free music editor that ships a playback engine for ca65. Wiring it in takes short, working code: a configuration block, includes, two init calls, and one call at the end of the NMI. Sound takes 4,327 of the 7,391 bytes of code and data in the finished game's program ROM, 2,767 of them for the engine; everything else takes 3,064.&lt;/p&gt;
&lt;p&gt;The reader learns FamiStudio, not the audio processing unit, or APU, the 2A03's built-in sound hardware. Of the 25 figures in the two chapters, 22 come from FamiStudio's interface or website. Neither chapter gives an APU register address, though appendix C has a table of them, and no listing writes to the APU. That is a stated choice. Page 238 says "it is much easier to use one of the sound and music creation tools and the playback engines they provide." But Listing 14.1 prints the exported sound-effect data without explaining it, and the format is simple. A byte of 0x80 or more names an APU register, and the byte after it is the value to write. A byte from 1 to 127 is a number of frames to wait, and zero ends the effect. Decoding it is the hardware lesson the chapter skips.&lt;/p&gt;
&lt;p&gt;The little hardware prose here is loose. Pages 225 and 243 say "Apple Music commonly uses 128-bit samples." Its lossless streams use 16- or 24-bit samples; 128 kbps is a common MP3 bit rate. And the in-game music plays drums on the APU's sample channel, called DPCM, though the book's own controller routine warns that DPCM samples "can conflict with gamepad reading" and then reads the pad only once per frame.&lt;/p&gt;
&lt;h3&gt;Aged Tools and Thin Appendices&lt;/h3&gt;
&lt;p&gt;Some of the setup advice has aged, and some of the build scripts never worked:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Chapter 2 says Mac users must run Mesen in a virtual machine. That was true of the original Mesen the book links to, but Mesen 2 already offered experimental macOS builds before the book shipped, and it has had official macOS releases since version 2.1.0 in May 2025.&lt;/li&gt;
&lt;li&gt;Page 232 says to copy famistudio_ca65.s from famistudio.org. Since FamiStudio 4.3.0, released in December 2024, six months after the book, that file pulls in separate note-table binaries and no longer assembles alone. Copy the NoteTables folder too, or use the 4.1.0 engine bundled in the repository.&lt;/li&gt;
&lt;li&gt;On Linux and macOS, the book's &lt;code&gt;.\compile.sh&lt;/code&gt; fails, and the scripts are committed without the execute bit, so &lt;code&gt;./compile.sh&lt;/code&gt; fails too. &lt;code&gt;bash compile.sh&lt;/code&gt; works.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After Listing 16.1 adds extra lives, chapter 16 turns into a survey, and the appendices are reference tables. The section on mappers, the bank-switching chips on bigger cartridges, explains bank switching in diagrams but never shows a bank switch. The list of expansion sound chips doesn't mention that an unmodified NES can't play them, because only the Famicom's cartridge slot carries audio.&lt;/p&gt;
&lt;h3&gt;The 6502 Through Z80 Eyes&lt;/h3&gt;
&lt;p&gt;The book names the Z80 only once, on page 160, but a Z80 programmer reads every page as a comparison.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Registers.&lt;/strong&gt; Page 28 says the 6502 "has a particularly small number of registers compared to other 8-bit processors." The headline problem in the &lt;a href="https://tinycomputers.io/posts/rust-on-z80-an-llvm-backend-odyssey.html"&gt;Rust-on-Z80 backend&lt;/a&gt; was register poverty: seven 8-bit registers where the LLVM compiler framework expects many more. The 6502 has three, and it treats zero page as a register file reached with two-byte, three-cycle instructions. The llvm-mos compiler makes this formal with 16 two-byte "imaginary registers" in zero page, and its &lt;a href="https://go.tinymachines.io/llvm-mos-sdk"&gt;development kit&lt;/a&gt; targets the NES directly.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I/O.&lt;/strong&gt; "The 6502 processor does not have specific instructions to access external ports," says Appendix C. Every PPU, APU, and controller register is a memory address. The Z80 has a separate port space with its own IN and OUT instructions, so the clean-room emulator talks to the outside world through four callbacks: memory read, memory write, port in, and port out. A 2A03 core needs only the first two.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Interrupts.&lt;/strong&gt; The NES and the ColecoVision both wire vblank to the CPU's non-maskable interrupt. The book's handler saves its three registers to the stack by hand, where a Z80 handler can swap in a whole alternate register set with two exchange instructions.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Emulators.&lt;/strong&gt; Page 15 recommends the iNES emulator by Marat Fayzullin, whose ROM header format opens every ROM in the book. He also wrote fMSX and ColEm, emulators of the MSX and the ColecoVision. Mesen, the first emulator chapter 2 recommends, added ColecoVision support in version 2.1.0, so one emulator now runs both machines.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Decimal.&lt;/strong&gt; Page 160 says "On a Z80 or normal 6502 processor, there are commands to help with this type of approach to storing numbers, called binary-coded decimal (BCD)." Nintendo, it says, removed them "to either save space or make the processor different enough so it didn't have to pay a license." No instructions were removed. The instructions that set and clear the decimal flag still work, and the book's own reset code uses one. The 2A03 ignores the decimal flag because Ricoh removed five transistors from the decimal adjust circuit, which saved no space. The licensing motive is plausible but unconfirmed.&lt;/p&gt;
&lt;p&gt;Cruise's workaround is base 100, not BCD. &lt;code&gt;dec99_to_bytes&lt;/code&gt; splits each score byte into digits by subtracting 50 once, 20 as often as it fits, and then 10, and the caller adds 48 to get a tile number. The prime sieve that &lt;a href="https://tinycomputers.io/posts/sectorz-a-c-compiler-in-733-bytes-of-z80-assembly.html"&gt;SectorZ&lt;/a&gt; compiles prints numbers the same way, with repeated subtraction and &lt;code&gt;c = d + 48&lt;/code&gt;. On the Z80, the decimal-adjust instruction, DAA, does the work in hardware, as it does in the &lt;a href="https://tinycomputers.io/posts/building-z80-roms-with-rust-a-modern-approach-to-retro-computing.html"&gt;kz80_calc&lt;/a&gt; spreadsheet's packed BCD:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="c1"&gt;; add A (two packed BCD digits) to a little-endian BCD score&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nf"&gt;ld&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="no"&gt;hl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="no"&gt;score&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="no"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,(&lt;/span&gt;&lt;span class="no"&gt;hl&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nf"&gt;daa&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nf"&gt;ld&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;hl&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="no"&gt;a&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nf"&gt;inc&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="no"&gt;hl&lt;/span&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="c1"&gt;; INC HL doesn't touch the carry&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nf"&gt;ld&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="no"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,(&lt;/span&gt;&lt;span class="no"&gt;hl&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nf"&gt;adc&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="no"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nf"&gt;daa&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nf"&gt;ld&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;hl&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="no"&gt;a&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="c1"&gt;; repeat the last five lines for each further byte&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Reading list.&lt;/strong&gt; Page 26 recommends &lt;a href="https://go.tinymachines.io/programming-the-6502-zaks"&gt;&lt;em&gt;Programming the 6502&lt;/em&gt;&lt;/a&gt; by "Rodney Zaks." His name is Rodnay, and I recommended his &lt;a href="https://go.tinymachines.io/nxeFwX"&gt;&lt;em&gt;Programming the Z80&lt;/em&gt;&lt;/a&gt; in the Ciarcia and Barden reviews. The two make a good pair for a Z80 programmer learning the 6502.&lt;/p&gt;
&lt;h3&gt;Who Should Read It&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;Classic Game Programming on the NES&lt;/em&gt; suits a reader who already programs, wants a complete NES game with a clean structure, and will keep the NESdev wiki open beside it. Despite the promise on page xv, a reader with no programming experience is the one least able to catch the primer's errors. Readers who know the 6502 can skip chapters 3 and 4, as page xvi suggests. Readers coming from the Z80 should read them slowly. Table 4.1's carry rule is the Z80's, and eight rotations do bring a byte back on the Z80's circular rotates, so both errors will look right to them.&lt;/p&gt;
&lt;p&gt;Buy it for the project: a complete, well-structured game that fits the simplest NES cartridge and builds anywhere cc65 runs. Build from the repository rather than the printed listings. It assembles where Listing 6.10 doesn't, and a reader's pull requests fixed its copy of Listing 10.3 and a chapter 10 branch that kept enemies from advancing. Manning's spring 2025 corrections fixed that branch in the book but not Listing 10.3. Don't buy it to learn the 6502 or the PPU. For that, other resources are better:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;a href="https://go.tinymachines.io/nesdev-wiki"&gt;NESdev wiki&lt;/a&gt; is the reference the book leans on, and its pages on the PPU, APU, and init code are more accurate.&lt;/li&gt;
&lt;li&gt;Kevin Zurawel's free &lt;a href="https://go.tinymachines.io/famicom-party"&gt;&lt;em&gt;Famicom Party&lt;/em&gt;&lt;/a&gt; also uses ca65, though it is unfinished at 17 chapters.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For Manning's errata page, the repository, and any second edition, the fixes are clear:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Run every exercise.&lt;/strong&gt; Check each printed dump against the simulator and publish errata for chapters 3 and 4.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fix the game bugs in the repository.&lt;/strong&gt; Start with the lives display, the score subtraction, and chapter 5's scroll reset.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Put a number on vblank.&lt;/strong&gt; State the 2,273-cycle budget and count every NMI against it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Write one APU register by hand before opening FamiStudio.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Cruise has been programming for more than 40 years, and Mega Blast shows it: the NMI order, the update flags, and the data-driven enemies are the work of someone who has shipped games. One reader's pull requests have already fixed two bugs in the repository, and Cruise merged both within a day. The explanations deserve the same pass.&lt;/p&gt;</description><category>8-bit</category><category>6502</category><category>assembly</category><category>book review</category><category>ca65</category><category>cc65</category><category>emulation</category><category>game development</category><category>manning</category><category>nes</category><category>retrocomputing</category><category>tony cruise</category><category>z80</category><guid>https://tinycomputers.io/posts/review-of-classic-game-programming-on-the-nes-by-tony-cruise.html</guid><pubDate>Mon, 16 Nov 2026 14:00:00 GMT</pubDate></item></channel></rss>