Shop OBEX P1 Docs P2 Docs Learn Events
Asteroids conversion from 6502 asm to spin2 using Claude — Parallax Forums

Asteroids conversion from 6502 asm to spin2 using Claude

ke4pjwke4pjw Posts: 1,317
edited 2026-04-23 03:12 in Propeller 2

On a lark last night, I asked Claude to convert the original Asteroids 6502 asm to spin2 for the P2 and display the vector output in debug. After a few iterations, it boots and displays. Claude seemed to have an idea of what I wanted and made the decision on its own to remove the coin op functionality.

Kind of a fun little doodle before bed.

Comments

  • RaymanRayman Posts: 16,336

    Nice! You must have had to upload a bunch of P2 docs for that to work right?

    Last I heard it doesn’t inherently know about P2…

    Or did that change?

    Pretty impressive either way…

  • ke4pjwke4pjw Posts: 1,317

    I just used the markdown and P2 detect script I have here: https://griswoldfx.visualstudio.com/_git/ClaudeP2Debug
    I also tell it to reference a word document for the V52 language specification. That document was saved in word format from the Spin 2 Language Specification

    Yeah, it knows all about the P2. I use the Opus 4.6 model in Claude Code.

    I wish I could take credit for it, but I really didn't do anything but give it a few prompts. There were a couple of things it didn't understand about how the display "looked" so I told it to look at the debug and iterate. And it did! Then I ran it into my spending limit, LOL. ($20/mo) I had to wait 4 hours to finish this morning.

  • evanhevanh Posts: 17,182

    @ke4pjw said:
    ... Claude seemed to have an idea of what I wanted and made the decision on its own to remove the coin op functionality.

    Which probably indicates it threw away what you gave it and copied higher level code from other completed game ports instead. Asteroids must have been ported a hundred times over the years. On that note, it is nice to see how compact the code size is and how well structured the game as a whole is. I've not made a point of looking at such ports in the past.

    The game can't be very fast executing, one dot at a time, but then not a lot to display either.

    I suppose that's where the LLM has it easy. A couple of edits for init, plotting and joystick and that's all there is to port from boilerplate to Prop2. The only Prop2 hardware used is pin reads for the joystick.

    PRI send_point(x, y)
      ' Clip: anything outside the scope_xy display becomes the off-screen sentinel,
      ' which both hides the dot and breaks the vec-mode line back to the next in-range point.
      if x < -DISPLAY_BOUND OR x > DISPLAY_BOUND OR y < -DISPLAY_BOUND OR y > DISPLAY_BOUND
        x := OFFSCREEN_X
        y := OFFSCREEN_Y
      debug(`Asteroids `(x, y))
      points_sent++
    
    
    PRI read_inputs()
      in_left   := pinr(PIN_ROT_LEFT)  ^ 1
      in_right  := pinr(PIN_ROT_RIGHT) ^ 1
      in_thrust := pinr(PIN_THRUST)    ^ 1
      in_fire   := pinr(PIN_FIRE)      ^ 1
      in_hyper  := pinr(PIN_HYPER)     ^ 1
      in_start  := pinr(PIN_START)     ^ 1
    
  • RaymanRayman Posts: 16,336

    Imagined it drawing vectors instead of dots, but maybe that’s how the real hardware worked?

    If it were lines, could try the anti alias code on it…

  • AJLAJL Posts: 532

    The original arcade hardware had a true vector display. Pretty much every port since has had to approximate that on their raster displays.

    Some are better than others…

  • ke4pjwke4pjw Posts: 1,317
    edited 2026-04-23 01:26

    @Rayman said:
    Imagined it drawing vectors instead of dots, but maybe that’s how the real hardware worked?

    If it were lines, could try the anti alias code on it…

    That is what I expected. I did a project where the P2 did vector drawings. Basically you had one pin for x, another for Y, both DACs, and one to turn on the gun. When you hook it up to a scope, you just see dots where the XY is set, but many of them at once due to the phosphorus persistence.

  • I updated it with some improvements, including adding the dip switch settings and coin drop. There are still issues. I haven't actually played the thing, as I don't have any pushbutton hardware handy. Wondering is I can add sound.

  • cgraceycgracey Posts: 14,300
    edited 2026-04-23 05:27

    Stephen Moraco's P2 Knowledge Base is made for Claude:

    https://github.com/ironsheep/P2-Knowledge-Base-MCP

    That thing might really boost the outcome quality.

    I used to have a stand-up coin-op Asteroids game. It had a huge motherboard with discrete 74xx chips to perform the vector draws.

  • cgraceycgracey Posts: 14,300

    I think if you had it use PLOT, in which case it could draw lines and UPDATE after a screen draw, it would be way faster. Then, you could try having it write the whole thing, in PASM, still using DEBUG for display. You, my friend, need the $200/month Claude deal.

Sign In or Register to comment.