Skip to content

Instantly share code, notes, and snippets.

@worldofchris
Created July 14, 2024 21:20
Show Gist options
  • Save worldofchris/2336cc9e8d2a818159078b1212b982da to your computer and use it in GitHub Desktop.
Save worldofchris/2336cc9e8d2a818159078b1212b982da to your computer and use it in GitHub Desktop.
PETSCII Coffee
.pc = $0801 "C64File" // Set the program counter to the start of BASIC memory
.word coffee // Link to the start of the program
.word 2021 // Link to the next line (dummy)
.byte $9E // BASIC token for SYS
.text "2061" // Address to call (2061 decimal = $080D)
.byte 0 // End of BASIC program
.pc = $080D // Continue program at $080D
coffee: lda #$00
sta $d020
sta $d021
chars: lda #<screen_data
sta copy_mem_source_lo
lda #>screen_data
sta copy_mem_source_hi
lda #$00
sta copy_mem_dest_lo
lda #$04
sta copy_mem_dest_hi
lda #$00
sta copy_mem_dest_length_lo
lda #$04
sta copy_mem_dest_length_hi
jsr copy_mem
color: lda #<color_data
sta copy_mem_source_lo
lda #>color_data
sta copy_mem_source_hi
lda #$00
sta copy_mem_dest_lo
lda #$D8
sta copy_mem_dest_hi
lda #$00
sta copy_mem_dest_length_lo
lda #$04
sta copy_mem_dest_length_hi
jsr copy_mem
rts
// http://www.6502.org/source/general/memory_move.html
copy_delay: .byte $ff
copy_mem: ldy #$0
ldx copy_mem_dest_length_hi
beq !next+
!loop:
txa
pha
ldx copy_delay
!loop_i: beq !next+
dex
jmp !loop_i-
!next: pla
tax
lda copy_mem_source_lo
sta $02
lda copy_mem_source_hi
sta $03
lda ($02),y
pha
lda copy_mem_dest_lo
sta $02
lda copy_mem_dest_hi
sta $03
pla
sta ($02),y
iny
bne !loop-
inc copy_mem_source_hi
inc copy_mem_dest_hi
dex
bne !loop-
!next: ldx copy_mem_dest_length_lo
beq !next+
!loop: lda copy_mem_source_lo
sta $02
lda copy_mem_source_hi
sta $03
lda ($02),y
pha
lda copy_mem_dest_lo
sta $02
lda copy_mem_dest_hi
sta $03
pla
sta ($02),y
iny
dex
bne !loop-
!next: rts
copy_mem_dest_lo: .byte 0
copy_mem_dest_hi: .byte 0
copy_mem_dest_length_lo: .byte 0
copy_mem_dest_length_hi: .byte 0
copy_mem_source_lo: .byte 0
copy_mem_source_hi: .byte 0
screen_data:
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$52,$52,$52,$52,$52,$52,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$4F,$77,$77,$77,$77,$50,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$74,$21,$3D,$3D,$1E,$67,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$74,$20,$4F,$50,$20,$67,$20,$28,$28,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$74,$20,$74,$67,$20,$67,$20,$29,$29,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$3D,$3D,$3D,$3D,$3D,$3D,$20,$4F,$50,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$4C,$6F,$6F,$6F,$6F,$7A,$20,$54,$59,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$45,$45,$45,$45,$45,$45,$45,$45,$45,$45,$45,$45,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20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