# Space Harrier 2 (slightly faster edition)

**URL:** <https://forum.cpcwiki.eu/t/space-harrier-2-slightly-faster-edition/737>\
**Category:** Vibe-coded games\
**Tags:** ai\
**Created:** [October 8, 2026, 3:41am UTC](https://forum.cpcwiki.eu/t/space-harrier-2-slightly-faster-edition/737 "2026-10-08T03:41:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ervin](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/ervin/32/87_2.png) [@ervin](https://forum.cpcwiki.eu/u/ervin)\
**Post date:** [October 8, 2026, 3:41am UTC](https://forum.cpcwiki.eu/t/space-harrier-2-slightly-faster-edition/737/1 "2026-10-08T03:41:32Z")

</div>

### Code & Logic Involvement

Debugging / Optimization only (Human wrote, AI analyzed/fixed)

### Assets & Pipeline Involvement

None (Code-only or pure human assets)

### Project Notes & Prompts

Space Harrier 2.  
Claude has made it faster, but still not great unfortunately.

[space\_harrier\_2\_fast.dsk](https://forum.cpcwiki.eu/uploads/short-url/sv9DBjr7tcKWQNVKjK1vxScpx0q.dsk) (195 KB)

---

<div class="post-metadata">

**Author:** ![Jean-Marie](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/jean-marie/32/424_2.png) [@Jean-Marie](https://forum.cpcwiki.eu/u/Jean-Marie)\
**Post date:** [October 8, 2026, 4:17am UTC](https://forum.cpcwiki.eu/t/space-harrier-2-slightly-faster-edition/737/2 "2026-10-08T04:17:45Z")

</div>

Nice, thank you! It must mean the code was already optimized, altough I had a quick look and spotted a few misses.  
At offset 2981, there is a _call &0836:ret_ which could be replaced with a _jp &0836_.  
A few lines below, at offset 2992 we see : _ld de ,&9C00:add hl,de._ There is obviously no point at adding 0 to the register L ! So better use : _ld a,h:add &9C:ld h,a_ which avoids 16 bit overheads. Unless it’s self-modifying code of course, but it doesn’t seem to be the case here.  
I wonder if your models are correctly trained for optimization, but I confess i’m ignorant with all this.

---

<div class="post-metadata">

**Author:** ![ervin](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/ervin/32/87_2.png) [@ervin](https://forum.cpcwiki.eu/u/ervin)\
**Post date:** [October 8, 2026, 4:38am UTC](https://forum.cpcwiki.eu/t/space-harrier-2-slightly-faster-edition/737/3 "2026-10-08T04:38:07Z")

</div>

Thanks!

I will pass that info to Claude and see what it says.

[EDIT] Yes it agrees, but said the following:

Both are right; they would just save about 7 µs per game loop at most, which is too small to see.

- **`#2981`, `call #0836 : ret` → `jp #0836`:** saves 5 µs (`call` 5 + `ret` 3 against `jp` 3). This tail only runs for the original copy, which during play is now only the occasional full copy; menus, title and transitions still use it. My game-loop copy already ends with `jp music`.
- **`#2992`, `ld de,#9C00 : add hl,de` → `ld a,h : add a,#9C : ld h,a`:** saves 2 µs (6 against 4). It’s safe: the low byte added is 0, so there’s never a carry out of L. A is free at that point, because the next instructions reload it with `ld a,(#316B)`, and it isn’t self-modified. This is the original clear’s address calculation, which only runs on non-game-loop clears; my game-loop clear gets the address from the `#E600` line table instead.

Against a game loop of about 80–95 ms, that’s under 0.01%. The game is full of patterns like these; they mostly sit outside the routines that cost frames.

---

<div class="post-metadata">

**Author:** ![Jean-Marie](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/jean-marie/32/424_2.png) [@Jean-Marie](https://forum.cpcwiki.eu/u/Jean-Marie)\
**Post date:** [October 8, 2026, 4:56am UTC](https://forum.cpcwiki.eu/t/space-harrier-2-slightly-faster-edition/737/4 "2026-10-08T04:56:29Z")

</div>

Yeah, I had put a breakpoint at 2981, and it’s called only when the player is hit, but it’s called many times, and it is code from the game loop. Tell this Claude guy he must do better 😜

---

<div class="post-metadata">

**Author:** ![ervin](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/ervin/32/87_2.png) [@ervin](https://forum.cpcwiki.eu/u/ervin)\
**Post date:** [October 8, 2026, 4:58am UTC](https://forum.cpcwiki.eu/t/space-harrier-2-slightly-faster-edition/737/5 "2026-10-08T04:58:38Z")

</div>

LOL yes, but in my opinion Claude is getting too good at this.

The game I’m working on is being written the old-fashioned way, but optimising old games is beyond my skill level, and it’s a bit of fun using Claude to do it. 🙂

---

<div class="post-metadata">

**Author:** ![Gryzor](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/gryzor/32/7_2.png) [@Gryzor](https://forum.cpcwiki.eu/u/Gryzor)\
**Post date:** [October 8, 2026, 6:58am UTC](https://forum.cpcwiki.eu/t/space-harrier-2-slightly-faster-edition/737/6 "2026-10-08T06:58:42Z")

</div>

> [@ervin](#):
>
> Claude has made it faster, but still not great unfortunately.

Haha loved that 😃
