timing-and-frame-loop

Analyzes and retunes busy-wait frame timing in a Z80 assembly Breakout game.

Updated Nov 29, 2024
One-click install
npx skills add https://github.com/SpeedRD/Arkanoid_Z80 --skill timing-and-frame-loop-speedrd
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: timing-and-frame-loop
Source: https://github.com/SpeedRD/Arkanoid_Z80/tree/main/.claude/skills/timing-and-frame-loop
Command: npx skills add https://github.com/SpeedRD/Arkanoid_Z80 --skill timing-and-frame-loop-speedrd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Changing ball or paddle speed in this Z80 assembly game is error-prone because all pacing comes from counted busy-wait delay loops with no interrupts or vsync, so editing one constant silently changes the feel of everything else. This Skill documents the frame loop architecture, T-state delay budgets, and coupling between the two timing constants so changes are deliberate rather than guesswork. ## Core Features & Use Cases - Frame budget derivation: Provides worked T-state arithmetic for each delay loop (Esperar_pelota, esperar, teclado) so you can re-derive frame time after any change. - Coupled retuning guidance: Explains that ball speed and paddle responsiveness share one frame, and gives a table for adjusting both constants together to hit a target. - Hard constraints and traps: Enforces the one-cell-per-frame step rule, the non-zero row velocity invariant, and warns that a delay constant of 0 wraps to the longest delay. - Use Case: You want to make the ball faster without breaking collision detection. The Skill tells you to lower the $1100 delay constant in pelota.asm, never raise the step size, and to compensate the paddle by adjusting CONTADOR in pala.asm. ## Quick Start Ask the AI to explain how to safely make the ball faster in this game and which constants in pelota.asm and pala.asm to change together.

Frequently Asked Questions about timing-and-frame-loop

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I change ball speed in a Z80 assembly game loop?

Change ball speed by adjusting the delay constant in the busy-wait loop, never by enlarging the step size. A step larger than one cell per frame lets the ball skip cells and pass through bricks without colliding, since collision is a cell lookup.

How do I make a game paddle more responsive without side effects?

Shorten the frame by lowering the paddle delay constant, but note the ball speeds up proportionally because both share one loop. To retune only one thing, adjust both delay constants together against a total frame budget.

Why does the ball flicker in a busy-wait game loop?

The ball is drawn, held during the delay, then erased while the rest of the frame runs, so it is visible only about 73% of each frame. That duty cycle is a property of the busy-wait model, not a bug in the draw routine.

Why did the game freeze when holding S or G keys?

The keyboard poll loop branched back without decrementing its counter when a key on the same half-row was neither A nor D, looping forever. The fix routes those keys through the normal unsuccessful-poll path so the loop always terminates.

What happens if a delay loop constant is set to zero?

Zero is the longest delay, not the shortest, because the loops decrement before testing and wrap to 65536 iterations, roughly half a second per frame. The minimum useful value is 1.

Does game timing stay correct on faster hardware or emulators?

No. All pacing is CPU-clock-dependent at 3.5 MHz with no interrupts or frame counter, so faster machines or non-cycle-accurate emulators speed everything up proportionally. Use a cycle-accurate emulator for tuning.