├── .gitignore ├── README.md ├── music.sid ├── sprite1.spr ├── Makefile ├── flash.asm ├── sprite.asm ├── bookmarks.md ├── bars.asm ├── text.asm ├── multint.asm ├── LICENSE └── music.asm /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.prg 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | C64 Code 2 | ======== 3 | 4 | Commodore 64 code samples 5 | -------------------------------------------------------------------------------- /music.sid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ennorehling/c64/HEAD/music.sid -------------------------------------------------------------------------------- /sprite1.spr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ennorehling/c64/HEAD/sprite1.spr -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: flash.prg multint.prg 2 | 3 | clean: 4 | @rm *.prg 5 | 6 | %.prg: %.asm 7 | dasm $< -o$@ 8 | -------------------------------------------------------------------------------- /flash.asm: -------------------------------------------------------------------------------- 1 | ; dasm source 2 | processor 6502 3 | 4 | org $0801 ; sys2061 5 | sysline: 6 | .byte $0b,$08,$01,$00,$9e,$32,$30,$36,$31,$00,$00,$00 7 | 8 | org $080d ; sys2061 9 | 10 | loop: inc $d020 11 | inc $d021 12 | jmp loop 13 | 14 | -------------------------------------------------------------------------------- /sprite.asm: -------------------------------------------------------------------------------- 1 | processor 6502 2 | 3 | org $0801 ; sys2061 4 | sysline: 5 | .byte $0b,$08,$01,$00,$9e,$32,$30,$36,$31,$00,$00,$00 6 | 7 | org $080d ; sys2061 8 | lda #$80 9 | sta $07f8 10 | lda #$01 11 | sta $d015 12 | lda #$80 13 | sta $d000 14 | sta $d001 15 | rts 16 | 17 | org $2000 18 | INCBIN "sprite1.spr" 19 | -------------------------------------------------------------------------------- /bookmarks.md: -------------------------------------------------------------------------------- 1 | Tutorials: 2 | 3 | * Stable Raster interrupt -- [antimon](http://www.antimon.org/dl/c64/code/stable.txt) 4 | * An Introduction to C64 demo coding -- [antimon](http://www.antimon.org/code/Linus/) 5 | * Assemble It! -- [unikat](http://tnd64.unikat.sk/assemble_it1.html) 6 | * Behind the scenes -- [ninja](https://www.youtube.com/watch?v=So-m4NUzKLw) 7 | * C64 Tutorials -- [digitalerr0r](https://digitalerr0r.wordpress.com/tutorials/) 8 | -------------------------------------------------------------------------------- /bars.asm: -------------------------------------------------------------------------------- 1 | processor 6502 2 | org $0801 ; sys2061 3 | sysline: 4 | .byte $0b,$08,$01,$00,$9e,$32,$30,$36,$31,$00,$00,$00 5 | 6 | org $080d ; sys2061 7 | 8 | lda #$00 9 | sta $02 10 | 11 | incloop: 12 | lda $02 13 | cmp $d012 14 | bne incloop 15 | inc $d021 16 | adc #$10 17 | sta $02 18 | decloop: 19 | lda $02 20 | cmp $d012 21 | bne decloop 22 | dec $d021 23 | sbc #$10 24 | sta $02 25 | jmp incloop 26 | -------------------------------------------------------------------------------- /text.asm: -------------------------------------------------------------------------------- 1 | ; draw some text 2 | processor 6502 3 | 4 | org $0801 ; sys2061 5 | sysline: 6 | .byte $0b,$08,$01,$00,$9e,$32,$30,$36,$31,$00,$00,$00 7 | 8 | org $080d ; sys2061 9 | 10 | jsr $e544 ; clear screen 11 | 12 | ldx #$00 13 | write: lda msg,x 14 | jsr $ffd2 15 | inx 16 | cpx #54 17 | bne write 18 | 19 | ldx #$00 20 | setcol: lda #$07 21 | sta $d800,x 22 | inx 23 | cpx #54 24 | bne setcol 25 | 26 | rts 27 | 28 | ; org $1ffe 29 | ; incbin "scrap_writer_iii_17.64c" 30 | 31 | msg .byte "C64 PROGRAMMING TUTORIAL BY DIGITALERR0R OF DARK CODEX" 32 | -------------------------------------------------------------------------------- /multint.asm: -------------------------------------------------------------------------------- 1 | processor 6502 2 | org $0801 ; sys2061 3 | sysline: 4 | .byte $0b,$08,$01,$00,$9e,$32,$30,$36,$31,$00,$00,$00 5 | 6 | org $080d ; sys2061 7 | 8 | ;clear screen 9 | jsr $e544 10 | 11 | ; disable interrupts 12 | sei 13 | lda #$7f 14 | sta $dc0d 15 | sta $dd0d 16 | lda #$01 17 | sta $d01a 18 | 19 | ; set text mode 20 | lda #$1b 21 | ldx #$08 22 | ldy #$14 23 | sta $d011 24 | stx $d016 25 | sty $d014 26 | 27 | ; init irq 28 | lda #irq 30 | sta $0314 31 | stx $0315 32 | 33 | ; create raster interrupt at line 0 34 | ldy #$00 35 | sty $d012 36 | 37 | ; clear interrupts and ACK irq 38 | lda $dc0d 39 | lda $dd0d 40 | asl $d019 41 | cli 42 | 43 | halt: jmp halt 44 | 45 | irq: 46 | inc $d020 47 | inc $d021 48 | 49 | ; Create new raster interrupt after 16 lines 50 | lda #$10 51 | adc $d012 52 | sta $d012 53 | 54 | asl $d019 ; ack interrupt 55 | jmp $ea81 ; restore stack 56 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Enno Rehling 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /music.asm: -------------------------------------------------------------------------------- 1 | ; play music, do some shit 2 | processor 6502 3 | 4 | org $0801 ; sys2061 5 | sysline: 6 | .byte $0b,$08,$01,$00,$9e,$32,$30,$36,$31,$00,$00,$00 7 | 8 | org $080d ; sys2061 9 | jsr $e544 ; clear screen 10 | lda #$00 11 | sta $d020 12 | sta $d021 13 | tax 14 | tay 15 | jsr $1000 ; init sid 16 | 17 | ; interrupt init 18 | sei 19 | 20 | ; disable cia1, ci2, vic intr 21 | lda #$7f 22 | sta $dc0d 23 | sta $dd0d 24 | 25 | ; enable raster intr 26 | lda #$01 27 | sta $d01a 28 | 29 | ; enter single-color mode 30 | lda #$1b 31 | ldx #$08 32 | ldy #$14 33 | sta $d011 ; text mode 34 | stx $d016 ; single color 35 | sty $d018 ; default charset 36 | 37 | lda #irq1 39 | sta $0314 40 | stx $0315 41 | 42 | ldy #$7e ; raster interrupt at line 7e 43 | sty $d012 44 | 45 | ; clear pending intr. 46 | lda $dc0d 47 | lda $dd0d 48 | asl $d019 49 | 50 | cli 51 | 52 | ; hello world 53 | ldx #$00 54 | write: lda msg,x 55 | jsr $ffd2 56 | inx 57 | cpx #26 58 | bne write 59 | 60 | ldx #$00 61 | ldy #$07 62 | setcol: tya 63 | sta $d800,x 64 | iny 65 | inx 66 | cpx #26 67 | bne setcol 68 | 69 | loop: jmp loop 70 | 71 | irq1: lda #$06 72 | sta $d020 73 | sta $d021 74 | lda #irq2 76 | sta $0314 77 | stx $0315 78 | ldy #$a0 79 | sty $d012 80 | 81 | asl $d019 ; ack intr 82 | jmp $ea81 83 | 84 | 85 | irq2: lda #$05 86 | sta $d020 87 | sta $d021 88 | jsr $1006 ; play music 89 | lda #irq1 91 | sta $0314 92 | stx $0315 93 | ldy #$00 94 | sty $d012 95 | asl $d019 ; ack intr 96 | jmp $ea81 97 | 98 | org $1000-$7e 99 | incbin "music.sid" 100 | 101 | msg .byte "LOREM IPSUM DOLOR SIT AMET" 102 | --------------------------------------------------------------------------------