This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| lazy_static! { | |
| pub static ref MAP: HashMap<u8, Opecode> = { | |
| let mut m = HashMap::new(); | |
| m.insert(0xA9, Opecode { name: Instruction::LDA, mode: Addressing::Immediate, cycle: cycles[0xA9] }); | |
| m.insert(0xA5, Opecode { name: Instruction::LDA, mode: Addressing::ZeroPage, cycle: cycles[0xA5] }); | |
| m.insert(0xB5, Opecode { name: Instruction::LDA, mode: Addressing::ZeroPageX, cycle: cycles[0xB5] }); | |
| m.insert(0xAD, Opecode { name: Instruction::LDA, mode: Addressing::Absolute, cycle: cycles[0xAD] }); | |
| // ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub fn run<T: CpuRegisters + Debug, U: CpuBus>(registers: &mut T, bus: &mut U) -> Data { | |
| let _code = fetch(registers, bus); | |
| let ref map = opecode::MAP; | |
| let code = &*map.get(&_code).unwrap(); | |
| let opeland = fetch_opeland(&code, registers, bus); | |
| match code.name { | |
| Instruction::LDA if code.mode == Addressing::Immediate => lda_imm(opeland, registers), | |
| Instruction::LDA => lda(opeland, registers, bus), | |
| Instruction::LDX if code.mode == Addressing::Immediate => ldx_imm(opeland, registers), | |
| Instruction::LDX => ldx(opeland, registers, bus), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[derive(Debug)] | |
| struct Status { | |
| negative: bool, | |
| overflow: bool, | |
| reserved: bool, | |
| break_mode: bool, | |
| decimal_mode: bool, | |
| interrupt: bool, | |
| zero: bool, | |
| carry: bool, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| build: | |
| cargo rustc — release \ | |
| — target=wasm32-unknown-emscripten — \ | |
| -C opt-level=3 \ | |
| -C link-args=”-O3 -s NO_EXIT_RUNTIME=1 -s EXPORTED_FUNCTIONS=[‘_run’]” |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mergeInto(LibraryManager.library, { | |
| canvas_render: function (ptr, len) { | |
| Module.NES.buf = new Uint8Array(Module.HEAPU8.buffer, ptr, len); | |
| Module.NES.image.data.set(Module.NES.buf); | |
| Module.NES.ctx.putImageData(Module.NES.image, 0, 0); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mod color; | |
| use super::{BackgroundField, BackgroundCtx}; | |
| use super::PaletteList; | |
| use super::{Sprite, SpritesWithCtx, SpritePosition}; | |
| use self::color::COLORS; | |
| extern "C" { | |
| fn canvas_render(ptr: *const u8, len: usize); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Address | Size | Device | |
|---|---|---|---|
| 0x0000~0x07FF | 0x0800 | WRAM | |
| 0x0800~0x1FFF | - | WRAM(mirror) | |
| 0x2000~0x2007 | 0x0008 | PPU Registers | |
| 0x2008~0x3FFF | - | PPU Registers(mirror) | |
| 0x4000~0x401F | 0x0020 | APU I/O、PAD | |
| 0x4020~0x5FFF | 0x1FE0 | exROM | |
| 0x6000~0x7FFF | 0x2000 | exRAM | |
| 0x8000~0xBFFF | 0x4000 | ProgramROM | |
| 0xC000~0xFFFF | 0x4000 | ProgramROM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Name | Size | Description | |
|---|---|---|---|
| A | 8bit | Accumrator | |
| X | 8bit | Index | |
| Y | 8bit | Index | |
| S | 8bit | Stack Pointer(SP) | |
| P | 8bit | Status | |
| PC | 16bit | Program Counter(PC) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="./gpu.js" type="text/javascript"></script> | |
| <script> | |
| const gpu = new GPU(); | |
| const n = 512; | |
| const matMul = gpu.createKernel(function (a, b) { | |
| var sum = 0; | |
| for (var i = 0; i < this.constants.size; i++) { | |
| if (false) { | |
| sum += a[i] + b[i] * 2; | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <emscripten.h> | |
| void onLoadCallback(const char *filename) { | |
| FILE *fp; | |
| char s[256]; | |
| if((fp = fopen(filename, "r")) == NULL) { | |
| printf("file open error!!\n"); |