Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ファミコンアセンブリ入門

 ファミコンアセンブリ入門

Here I gave a small introduction to programming in assembly for the NES emulator fceux.

Daniel Sangorrin

March 28, 2018
Tweet

More Decks by Daniel Sangorrin

Other Decks in Programming

Transcript

  1. ファミコンアセンブリ入門
    Daniel Sangorrin ( ダニエル )
    @daromart
    @daromart
    東海道らぐ横浜の集い 2018 桜舞う巻
    2018/03/24

    View Slide

  2. View Slide

  3. Architecture Reference

    http://nesdev.com/

    http://hp.vector.co.jp/authors/VA042397/inde
    x.html

    View Slide

  4. 6502 アセンブリ
    https://skilldrick.github.io/easy6502/
    LDX #0 ; X will be the pixel index
    LDA #3 ; A will contain the color
    FIRST:
    STA $0200,X
    INX
    CPX #255
    BCC FIRST
    STA $02FF
    LDX #0
    LDA #4
    SECOND:
    STA $0300,X
    INX
    CPX #255
    BCC SECOND
    STA $03FF
    LDX #0
    LDA #5
    THIRD:
    STA $0400,X
    INX
    CPX #255
    BCC THIRD
    STA $04FF
    LDX #0
    LDA #6
    FOURTH:
    STA $0500,X
    INX
    CPX #255
    BCC FOURTH
    STA $05FF

    View Slide

  5. Assembly Reference

    https://nesdoug.com/

    https://en.wikibooks.org/wiki/6502_Assembl
    y

    https://timcheeseman.com/nesdev

    View Slide

  6. WINE + FCEUX

    Fceux available in Linux

    But no debug functionality

    WINE to run the Win32 version
    $ sudo dpkg --add-architecture i386
    $ wget -nc https://dl.winehq.org/wine-builds/Release.key
    $ sudo apt-key add Release.key
    $ sudo apt-add-repository https://dl.winehq.org/wine-
    builds/ubuntu/
    $ sudo apt-get update
    $ sudo apt-get install --install-recommends winehq-stable
    [Alt] sudo apt-get install --install-recommends winehq-devel
    $ wine fceux xxx.nes

    View Slide

  7. cc65

    Install the cc65 compiler
    $ git clone https://github.com/cc65/cc65.git
    $ cd cc65
    $ make
    $ sudo make install PREFIX=/usr
    $ which cc65
    /usr/bin/cc65 $ which ca65
    /usr/bin/ca65

    View Slide

  8. Hello World
    $ git clone https://github.com/cirla/nesdev.git
    $ cd nesdev
    $ git checkout hello_world
    $ ls
    reset.s: initialization of the NES
    hello_world.c: contains main called from reset.s
    hello_world.cfg: linker script (describes the CPU memory map used)
    sprites.chr: file with sprites (Bitmap ROM)
    $ make
    -> hello_world.nes
    $ wine fceux.exe hello_world.nes
    -> shows a hello world

    View Slide