├── README.md ├── .gitignore ├── demo.code-workspace ├── cl65config.json └── demo.s /README.md: -------------------------------------------------------------------------------- 1 | # DevEnvironmentDemo 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.nes 3 | *.nes* 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /demo.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /cl65config.json: -------------------------------------------------------------------------------- 1 | { 2 | "executable": "C:\\cc65\\bin\\cl65", 3 | "input": "demo.s", 4 | "params": "--verbose --target nes -o demo.nes" 5 | } 6 | -------------------------------------------------------------------------------- /demo.s: -------------------------------------------------------------------------------- 1 | .segment "HEADER" 2 | ; .byte "NES", $1A ; iNES header identifier 3 | .byte $4E, $45, $53, $1A 4 | .byte 2 ; 2x 16KB PRG code 5 | .byte 1 ; 1x 8KB CHR data 6 | .byte $01, $00 ; mapper 0, vertical mirroring 7 | 8 | .segment "VECTORS" 9 | ;; When an NMI happens (once per frame if enabled) the label nmi: 10 | .addr nmi 11 | ;; When the processor first turns on or is reset, it will jump to the label reset: 12 | .addr reset 13 | ;; External interrupt IRQ (unused) 14 | .addr 0 15 | 16 | ; "nes" linker config requires a STARTUP section, even if it's empty 17 | .segment "STARTUP" 18 | 19 | ; Main code segment for the program 20 | .segment "CODE" 21 | 22 | reset: 23 | sei ; disable IRQs 24 | cld ; disable decimal mode 25 | ldx #$40 26 | stx $4017 ; disable APU frame IRQ 27 | ldx #$ff ; Set up stack 28 | txs ; . 29 | inx ; now X = 0 30 | stx $2000 ; disable NMI 31 | stx $2001 ; disable rendering 32 | stx $4010 ; disable DMC IRQs 33 | 34 | ;; first wait for vblank to make sure PPU is ready 35 | vblankwait1: 36 | bit $2002 37 | bpl vblankwait1 38 | 39 | clear_memory: 40 | lda #$00 41 | sta $0000, x 42 | sta $0100, x 43 | sta $0200, x 44 | sta $0300, x 45 | sta $0400, x 46 | sta $0500, x 47 | sta $0600, x 48 | sta $0700, x 49 | inx 50 | bne clear_memory 51 | 52 | ;; second wait for vblank, PPU is ready after this 53 | vblankwait2: 54 | bit $2002 55 | bpl vblankwait2 56 | 57 | main: 58 | load_palettes: 59 | lda $2002 60 | lda #$3f 61 | sta $2006 62 | lda #$00 63 | sta $2006 64 | ldx #$00 65 | @loop: 66 | lda palettes, x 67 | sta $2007 68 | inx 69 | cpx #$20 70 | bne @loop 71 | 72 | enable_rendering: 73 | lda #%10000000 ; Enable NMI 74 | sta $2000 75 | lda #%00010000 ; Enable Sprites 76 | sta $2001 77 | 78 | forever: 79 | jmp forever 80 | 81 | nmi: 82 | ldx #$00 ; Set SPR-RAM address to 0 83 | stx $2003 84 | @loop: lda hello, x ; Load the hello message into SPR-RAM 85 | sta $2004 86 | inx 87 | cpx #$1c 88 | bne @loop 89 | rti 90 | 91 | hello: 92 | .byte $00, $00, $00, $00 ; Why do I need these here? 93 | .byte $00, $00, $00, $00 94 | .byte $6c, $00, $00, $6c 95 | .byte $6c, $01, $00, $76 96 | .byte $6c, $02, $00, $80 97 | .byte $6c, $02, $00, $8A 98 | .byte $6c, $03, $00, $94 99 | 100 | palettes: 101 | ; Background Palette 102 | .byte $0f, $00, $00, $00 103 | .byte $0f, $00, $00, $00 104 | .byte $0f, $00, $00, $00 105 | .byte $0f, $00, $00, $00 106 | 107 | ; Sprite Palette 108 | .byte $0f, $20, $00, $00 109 | .byte $0f, $00, $00, $00 110 | .byte $0f, $00, $00, $00 111 | .byte $0f, $00, $00, $00 112 | 113 | ; Character memory 114 | .segment "CHARS" 115 | .byte %11000011 ; H (00) 116 | .byte %11000011 117 | .byte %11000011 118 | .byte %11111111 119 | .byte %11111111 120 | .byte %11000011 121 | .byte %11000011 122 | .byte %11000011 123 | .byte $00, $00, $00, $00, $00, $00, $00, $00 124 | 125 | .byte %11111111 ; E (01) 126 | .byte %11111111 127 | .byte %11000000 128 | .byte %11111100 129 | .byte %11111100 130 | .byte %11000000 131 | .byte %11111111 132 | .byte %11111111 133 | .byte $00, $00, $00, $00, $00, $00, $00, $00 134 | 135 | .byte %11000000 ; L (02) 136 | .byte %11000000 137 | .byte %11000000 138 | .byte %11000000 139 | .byte %11000000 140 | .byte %11000000 141 | .byte %11111111 142 | .byte %11111111 143 | .byte $00, $00, $00, $00, $00, $00, $00, $00 144 | 145 | .byte %01111110 ; O (03) 146 | .byte %11100111 147 | .byte %11000011 148 | .byte %11000011 149 | .byte %11000011 150 | .byte %11000011 151 | .byte %11100111 152 | .byte %01111110 153 | .byte $00, $00, $00, $00, $00, $00, $00, $00 154 | --------------------------------------------------------------------------------