PPU: start implementing internal behaviour properly
run valgrind/kcachegrind and do some optimisations
huge refactor + cleanup
A NES emulator written in C++, imgui and SFML.
ImGui to SFML bindings are from https://github.com/eliasdaler/imgui-sfml.
processor 6502
SEG
ORG $4020 ; Cartridge address
; 8-bit Fibonacci sequence generator
; TODO: Add 16-bit support :D
Reset
LDA #$01 ; Load the value VAL_A into the accumulator
LoopForever
STA $01 ; Store A in zero page address 0
STA $4018 ; Print A
ADC $00 ; Add value in address $00
STA $02 ; Store result in address $02
STA $4018 ; 4018 is unused(?) on the NES, so here I'm using it to print a byte
ADC $01 ; Add value in addres $01
STA $00 ; Store result in $00
STA $4018 ; Print A
ADC $02 ; Add value in $02
JMP LoopForever ; Jump back to the LoopForever label
ORG $FFFA ; Address of section
; Store the 16-bit address of the Reset label
; to be jumped to when any of these vectors occur
; This address is usually mapped to cartridge ROM in the NES
.word Reset ; in the NMI vector
.word Reset ; The Reset Vector
.word Reset ; And the IRQ/BRK vector
END
Can be compiled with dasm
:
dasm docs/fib.asm -f3 -v5 -0test.bin
You can inspect the file test.bin
with a hex editor and you should see the following:
; xxd test.bin | head -n 1
00000000: a901 8501 6500 8502 8d18 4065 0185 008d ....e.....@e....
The file is padded by 0x0FFA bytes up until the address of the reset vectors.
Tests can be run by invoking cnes
with the -t
flag.
Some unit tests depend on pre-compiled 6502 binaries, these are installed to /usr/share/cnes/tests/
, for local builds set the TESTS_PATH
build flag to a relative path, e.g.
meson compile -C build -DTESTS_PATH=tests