Skip to content

Instantly share code, notes, and snippets.

@Cyanne
Last active December 24, 2024 14:06
Show Gist options
  • Select an option

  • Save Cyanne/c7a97b4be30ad515ddbd5cdeb1c81055 to your computer and use it in GitHub Desktop.

Select an option

Save Cyanne/c7a97b4be30ad515ddbd5cdeb1c81055 to your computer and use it in GitHub Desktop.

Revisions

  1. Cyanne revised this gist Dec 24, 2024. No changes.
  2. Cyanne created this gist Jan 13, 2023.
    199 changes: 199 additions & 0 deletions easy6502_beams-generated.asm
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,199 @@
    StoreGun:
    ; Line order data starting at $20
    LDA #$00 ; Gun 1 Blue Laser Upper Row
    STA $20
    LDA #$60 ; 2 red
    STA $21
    LDA #$68 ; 3 green
    STA $22
    LDA #$00 ; 4 blue
    STA $23
    LDA #$00 ; Gun 1 Blue Laser Upper Row
    STA $24
    LDA #$60 ; 2 red
    STA $25
    LDA #$68 ; 3 green
    STA $26
    LDA #$68 ; 4 green
    STA $27
    LDA #$00 ; Gun 1 Blue Laser Upper Row
    STA $28
    LDA #$60 ; 2 red
    STA $29
    LDA #$68 ; 3 green
    STA $2a
    LDA #$00 ; 4 blue
    STA $2b
    LDA #$00 ; Gun 1 Blue Laser Upper Row
    STA $2c
    LDA #$60 ; 2 red
    STA $2d
    LDA #$68 ; 3 green
    STA $2e
    LDA #$60 ; 4 red
    STA $2f
    LDA #$08 ; Gun 1 Blue Laser Bottom Row
    STA $30
    LDA #$18 ; 2 red bottom
    STA $31
    LDA #$70 ; 3 green bottom
    STA $32
    LDA #$18 ; 4 red bottom
    STA $33
    LDA #$10 ; Gun 1-4 Body Rows
    STA $34
    STA $35
    STA $36
    STA $37
    LDA #$10 ; Gun 1-4 Body Rows
    STA $38
    STA $39
    STA $3a
    STA $3b
    LDA #$10 ; Gun 1-4 Body Rows
    STA $3c
    STA $3d
    STA $3e
    STA $3f
    LDA #$ff ; Done
    STA $40

    ; Blue Laser Upper Rows ($00-$07)
    LDA #$06
    STA $01
    LDA #$0e
    STA $02
    LDA #$03
    STA $03
    LDA #$01
    STA $04
    LDA #$03
    STA $05
    LDA #$0e
    STA $06
    LDA #$06
    STA $07

    ; Blue Laser Bottom Row ($08-$10)
    LDA #$06
    STA $0a
    LDA #$0e
    STA $0b
    LDA #$01
    STA $0c
    LDA #$0e
    STA $0d
    LDA #$06
    STA $0e

    ; Red Laser Upper Rows ($60-$67)
    LDA #$02
    STA $61
    LDA #$08
    STA $62
    LDA #$07
    STA $63
    LDA #$01
    STA $64
    LDA #$07
    STA $65
    LDA #$08
    STA $66
    LDA #$02
    STA $67

    ; Red Laser Bottom Row ($18-$1f)
    LDA #$02
    STA $1a
    LDA #$08
    STA $1b
    LDA #$01
    STA $1c
    LDA #$08
    STA $1d
    LDA #$02
    STA $1e

    ; Green Laser Upper Rows ($68-$6f)
    LDA #$09
    STA $69
    LDA #$05
    STA $6a
    LDA #$0d
    STA $6b
    LDA #$01
    STA $6c
    LDA #$0d
    STA $6d
    LDA #$05
    STA $6e
    LDA #$09
    STA $6f

    ; Green Laser Upper Rows ($70-$77)
    LDA #$09
    STA $72
    LDA #$05
    STA $73
    LDA #$01
    STA $74
    LDA #$05
    STA $75
    LDA #$09
    STA $76

    ; Gun Body Row ($11-$17)
    LDA #$0b
    STA $11
    LDA #$0b
    STA $12
    LDA #$0c
    STA $13
    LDA #$0c
    STA $14
    LDA #$0f
    STA $15
    LDA #$0f
    STA $16
    LDA #$0c
    STA $17

    DrawGun:
    ; A: Color
    LDX #$00 ; X: Init memory pos reader counter.
    LDY #$00 ; Y: Init screen pos writer counter.
    LDA #$01 ; | Init address $50: Line order counter.
    STA $50 ; |
    ; Address $51: Backup space for Y
    ; | Init address $52: Line progress counter
    DrawGunLoop:
    LDA $00,X ; Read color from address $00+X
    STA $0200,Y ; Store this color to address $0200+Y
    INX
    INC $52
    LDA $52
    CMP #$09 ; Check if line is done
    BEQ AddLine
    INY
    JMP DrawGunLoop

    AddLine:
    LDA #$00 ; \ Reset line progress counter
    STA $52 ; /
    TYA ; \ Backup Y (screen pos counter) into $51
    STA $51 ; /
    LDY $50 ; Load into Y Line Order Counter ($50)
    ; Re-set memory read position X by reading the line order data starting at $20
    LDA $0020,Y ; Y now being the line order count
    CMP #$ff
    BEQ Exit
    TAX ; Give the resulting reset point to X
    INY ; Increment line order counter
    STY $50 ; Store it back into $50
    LDY $51 ; Recover backup of Y to Y (screen pos counter)
    JMP DrawGunLoop

    Exit:
    BRK