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

ファミコンエミュレータで ゲームプログラミング

ファミコンエミュレータで ゲームプログラミング

Presentation about how to paint a background on the famikon at Open Source UN conference 2018, KAWAGOE. It was a 5 minutes lightning talk. 2018/04/14

Daniel Sangorrin

April 14, 2018
Tweet

More Decks by Daniel Sangorrin

Other Decks in Technology

Transcript

  1. 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
  2. cc65 • Install the cc65 compiler $ git clone https://github.com/cc65/cc65.git

    $ cd cc65 $ make $ sudo porg -lp cc65 make install PREFIX=/usr $ porg -f cc65 /usr/bin/*65 /usr/share/cc65/* $ which cc65 /usr/bin/cc65 <- C compiler $ which ca65 /usr/bin/ca65 <- ASM compiler
  3. 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
  4. UnRLE void Draw_Background(void) { PPU_ADDRESS = 0x20; // nametable 0

    address (0x2000) PPU_ADDRESS = 0x00; UnRLE(N2); // uncompress }
  5. main void main (void) { PPU_CTRL = 0; PPU_MASK =

    0; Draw_Background(); PPU_ADDRESS = 0x3f; PPU_ADDRESS = 0x00; for( index = 0; index < sizeof(PALETTE); ++index ){ PPU_DATA = PALETTE[index]; } PPU_ADDRESS = 0; PPU_ADDRESS = 0; SCROLL = 0; SCROLL = 0; Wait_Vblank(); PPU_CTRL = 0x90; PPU_MASK = 0x1e; while (1); } _Wait_Vblank: lda $2002 bpl _Wait_Vblank rts