Project set up - Falmouth-Games-Academy/comp310-wiki GitHub Wiki

Project Set Up

What you will need

In order to start, you'll need to get a couple of different pieces of software, which have been linked below.

Assembler

Emulator

Sprite Editor

Any text editor of your choice.

Once you have downloaded and unpacked these files, you are almost ready to begin. Please note on the emulator if you have 2 or more monitors it may only work on the primary screen.

Things to know to get you going

The first lines of the default code, are used to inform the assembler of the structure of your program.

    .inesprg 1 ; Assign one bank to be program code (16kb)
    .ineschr 1 ; Assign one bank to be sprite data or up to (16kb)
    .inesmap 0 ;
    .inesmir 1 ;

Following from that there is the information from the NESdev wiki which does a brief explanation of what your program should do when the NES is powered on or switched off.

Unlike modern-day programming languages 6502 Assembly code has different instructions and syntax. A list of the instructions can be found here along with their Opcodes.

Starting Template

This shows the basic code structure of an assembly program for a NES game. Courtesy of the Nerdy Nights tutorials, the compressed .zip file including a the mario.chr character sprite sheet can be found here.

  .inesprg 1   ; 1x 16KB PRG code
  .ineschr 1   ; 1x  8KB CHR data
  .inesmap 0   ; mapper 0 = NROM, no bank swapping
  .inesmir 1   ; background mirroring
  

;;;;;;;;;;;;;;;

    
  .bank 0
  .org $C000 
RESET:
  SEI          ; disable IRQs
  CLD          ; disable decimal mode
  LDX #$40
  STX $4017    ; disable APU frame IRQ
  LDX #$FF
  TXS          ; Set up stack
  INX          ; now X = 0
  STX $2000    ; disable NMI
  STX $2001    ; disable rendering
  STX $4010    ; disable DMC IRQs

vblankwait1:       ; First wait for vblank to make sure PPU is ready
  BIT $2002
  BPL vblankwait1

clrmem:
  LDA #$00
  STA $0000, x
  STA $0100, x
  STA $0200, x
  STA $0400, x
  STA $0500, x
  STA $0600, x
  STA $0700, x
  LDA #$FE
  STA $0300, x
  INX
  BNE clrmem
   
vblankwait2:      ; Second wait for vblank, PPU is ready after this
  BIT $2002
  BPL vblankwait2


  LDA #%10000000   ;intensify blues
  STA $2001

Forever:
  JMP Forever     ;jump back to Forever, infinite loop
  
 

NMI:
  RTI
 
;;;;;;;;;;;;;;  
  
  
  
  .bank 1
  .org $FFFA     ;first of the three vectors starts here
  .dw NMI        ;when an NMI happens (once per frame if enabled) the 
                   ;processor will jump to the label NMI:
  .dw RESET      ;when the processor first turns on or is reset, it will jump
                   ;to the label RESET:
  .dw 0          ;external interrupt IRQ is not used in this tutorial
  
  
;;;;;;;;;;;;;;  
  
  
  .bank 2
  .org $0000
  .incbin "mario.chr"   ;includes 8KB graphics file from SMB1

[1]


Discussion

Heres .waw to .dmc conversion for sound
Heres a database with NES game music(.nsf format)
An .nsf player
62 Tutorials on NES Programming to get you started

[1] Nerdy Nights tutorial series on NES development