Z80 Assembly 28: Basic Sound Generation (The Beeper Port)

The Basics of Beeper Sound Many simple Z80 systems (like the ZX Spectrum) lack a dedicated sound chip and rely on a simple speaker connected to an I/O port. This speaker is known as the beeper. How Tones are Made: A tone is generated by rapidly toggling a single bit in the output port (switching the speaker ON and OFF) at a specific frequency. Frequency & Pitch: The speed of the toggling loop determines the tone’s frequency (pitch). ...

September 27, 2025

Z80 Assembly 27: Horizontal and Vertical Scrolling (Fast Block Moves)

The Challenge of Scrolling Creating the illusion of movement across a large background map (scrolling) is a major performance challenge for 8-bit CPUs. You must shift thousands of bytes of screen memory every single frame. Slow code will cause a noticeable flicker or lag. The Solution: LDIR The Z80’s LDIR (Load, Increment, Repeat) instruction is the fastest tool for this job. It executes much faster than any software loop built with LD, INC, DEC, and JP. ...

September 27, 2025

Z80 Assembly 26: Collision Detection (Bounding Boxes and Bitwise Checks)

Bounding Box Collision (The Quick Check) Collision detection is computationally expensive. The fastest method is the Bounding Box check. This method checks if the rectangular area occupied by two objects (their boxes) overlap on the X and Y axes. If the boxes don’t overlap, the objects cannot be touching. The Principle: An overlap exists if: Object A’s right edge (A.X + A.Width) is > Object B’s left edge (B.X), AND Object A’s left edge (A.X) is < Object B’s right edge (B.X + B.Width), AND The same two conditions are met for the Y-axis. Z80 Implementation (X-Axis Check): ...

September 27, 2025

Z80 Assembly 25: Timing the Frame Rate (VSync) for Smooth Animation

The Problem: Screen Tearing If your Z80 code draws objects to the screen while the video hardware is actively reading and displaying that part of memory, you get a visual artifact called screen tearing (a horizontal break in the image). The Solution: VSync (Vertical Synchronization) Vertical Synchronization, or VSync, is the process of waiting until the video beam has finished drawing the current frame and is resetting to the top of the screen (the Vertical Blanking Interval, or VBI). By drawing only during the VBI, you ensure the user never sees partially rendered frames. ...

September 27, 2025