npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fcdev

v0.9.2

Published

6502 兼容机(NES、学习机等)的开发工具:用 cc65 构建 C 与汇编程序

Readme

fcdev

6502 兼容机(NES、小霸王学习机等)的开发工具:用 cc65 把 C 或 ca65 汇编构建成机型对应的程序,可在模拟器里运行与调试,并能把已有程序反汇编回 ca65 源码。首批支持 NES 与小霸王学习机 SB2000,更多机型按“目标”扩展。

通常不需要手动安装:用 npm create fcdev@latest 创建项目时会自动装好。

安装

npm install --save-dev fcdev

要求 Node.js 22.12 及以上。cc65 编译器在依赖包 fcdev-cc65 里,npm 会自动安装;也可以用环境变量 FCDEV_CC65_HOME 指向自备的 cc65 目录。模拟器 Ember 随包安装(Windows 64 位,在依赖包 fcdev-ember 里),run 与 debug 不用另外下载:第一次用到时 fcdev 把它复制到 %LOCALAPPDATA%\fcdev\ember,全机共用,Ember 自带升级;要用自备的 Ember 时,用环境变量 FCDEV_EMULATOR 或 fcdev.json 的 emulator 指向它的可执行文件。调试 SDK 随 fcdev 一起安装。

使用

fcdev 装在项目的 node_modules 里,没有加入系统的 PATH,在终端里直接输入 fcdev 会提示找不到命令,要写成 npx fcdev …。package.json 的 scripts 里可以直接写 fcdev …,用 npm run <脚本> 运行。想直接输入 fcdev,可以全局安装:npm install -g fcdev。

npx fcdev build            # 构建当前目录;目录里的全部 .c、.s、.asm 链接成一个程序
npx fcdev build src        # 构建目录 src
npx fcdev build src/a.c    # 只构建这个文件,它自己是一个程序
npx fcdev run src          # 构建后在 Ember 里运行
npx fcdev disk src         # 构建后把程序放进磁盘镜像(只有声明了磁盘能力的目标)
npx fcdev disasm game.nes  # 反汇编成 ca65 工程,并回读校验
npx fcdev sync             # 生成 IDE 的 C/C++ 配置
npx fcdev info --json      # 显示目标、工具链与头文件目录
npx fcdev api sb_file_open # 查询目标的 C 接口文档(函数名、模块名、$功能号或关键词;不带词列出全部模块)
npx fcdev docs syscall     # 查使用文档的本机路径(主题名或关键词;不带词列出全部主题)

入口是 main(汇编程序写 .export _main)。产物放在项目根的 build/<目标>/,中间文件在 build/obj/。

调试

npx fcdev run --debug --port 5688 src   # 以调试模式启动 Ember,程序载入后停在开机状态
FCDEV_DEBUG_PORT=5688 npx fcdev debug call runtime.run frames=60 wait=true
FCDEV_DEBUG_PORT=5688 npx fcdev debug screenshot screen.png

debug 把参数原样交给 Ember 调试 SDK 的终端客户端,npx fcdev debug --help 查看命令,npx fcdev debug methods 列出全部请求。调试端口默认 5699。学习机目标需要在 fcdev.json 里用 firmware 指定 BIOS 文件,run 会把程序放进软盘镜像、开机并在 SB-DOS 里输入程序名运行(加 --debug 停在开机状态)。

反汇编

npx fcdev disasm game.nes                                   # NES,入口取自中断向量
npx fcdev disasm prog.bin --base 8000 --entry 8008          # 平铺二进制:加载地址与入口
npx fcdev disasm game.nes --cdl game.cdl --symbols sym.txt  # 加 CDL 与符号文件

用 ca65、ld65 把生成的源码重新汇编链接,与原映像逐字节比较,不一致就报错。输出目录是一个工程:disasm.json、src/main.s、include/、link.cfg。只追得到的代码才会按指令输出,其余按数据输出;用 --cdl(FCEUX、Mesen 格式)或 --trace(Ember 记录的指令轨迹)补充运行时才执行到的代码。

在 VS Code 里还可以用扩展“fcdev 6502 开发”:它给 Copilot 提供反汇编与模拟器工具和智能体“6502 反汇编工程师”,多轮完成命名、注释、区域标注、分层与回读,也能连接 Ember 记录运行情况再导入工程。

配置

项目根的 fcdev.json,未知的配置项会报错:

| 项 | 默认值 | 说明 | | --- | --- | --- | | target | 无,必填 | 目标名:nes 或 sb2000 | | name | 目录名 | 目录构建时的程序名;SB2000 要符合 DOS 8.3 规则 | | out | build | 输出目录 | | optimize | true | 给 cc65 加优化选项 | | define | 空 | 预定义宏,值为字符串或数字 | | include | 空 | 额外的头文件目录 | | toolchain | 空 | 自备 cc65 的根目录,优先于工具链包 | | firmware | 无 | 固件(BIOS)文件;SB2000 运行时必填,fcdev 不提供任何 BIOS 或 ROM | | emulator | 空 | 自备 Ember 的路径,不设时读环境变量 FCDEV_EMULATOR,再没有时用随包的 Ember | | targetOptions | 空 | 目标专用选项,如 NES 的 font(是否链接 ASCII 字库,默认 true)、SB2000 的 banks(大程序的库页个数,默认 0) |

目标

| 目标 | 产物 | 头文件 | 说明 | | --- | --- | --- | --- | | nes | .nes | nes.h(cc65)、fcnes.h | NROM,16K PRG 加 8K CHR;fcnes.h 提供调色板、文字显示与等待垂直消隐 | | sb2000 | .EXE | sb2000.h | 程序从 $8000 起装入,默认最大 16K,设 targetOptions.banks 后可换页做到约 468K;C 栈在窗口顶端;运行库把 DOS 的系统调用和硬件寄存器封装成 200 多个 C 函数(文字、键盘手柄鼠标、文件目录、软驱、显示、声音、数学、打印机、输入法,以及 DMA、图形端口、定时器等硬件操作),用 fcdev api 查询,整本文档见 targets/sb2000/api-reference.md |

文档

完整的使用文档随本包发布,装好后在 node_modules/fcdev/docs/。终端里运行 npx fcdev docs 列出全部主题,npx fcdev docs <主题> 给出该文档的本机路径。更新记录在本包的 CHANGELOG.md。

| 想做什么 | 主题 | 文档 | | --- | --- | --- | | 查命令、fcdev.json 配置与构建流程 | build | docs/01-命令行与构建.md | | 开发 NES 程序 | nes | docs/nes/01-开发指南.md | | 开发 SB2000(SB-DOS)程序 | sb2000 | docs/sb2000/01-开发指南.md | | 查 SB-DOS 系统调用与出错码 | syscall | docs/sb2000/02-系统调用手册.md | | 查 SB2000 的硬件行为 | hardware | docs/sb2000/03-硬件说明.md | | 查 SB2000 运行库的 C 函数 | api | targets/sb2000/api-reference.md(也可以用 npx fcdev api 查询) | | 查 SB2000 的功能号、地址、出错码与寄存器符号(汇编名与 C 名) | symbols | targets/sb2000/symbols-reference.md | | 看 SB2000 示例程序的完整源码 | examples | targets/sb2000/examples-source.md | | 在模拟器里运行与调试,查调试命令 | emulator | docs/02-模拟器与调试.md | | 反汇编已有程序 | disasm | docs/03-反汇编.md | | 创建项目与模板 | create | docs/04-创建包与模板.md |

限制

  • 反汇编支持 NES 映射器 0、1、2、3、4、7、SB-DOS 程序与平铺二进制;静态追踪只追到经地址表分发的间接跳转,其他间接调用的代码按数据输出,回读仍然一致。
  • SB2000 程序的退出码被忽略,main 返回后总是回到 DOS。
  • run 在非调试模式下沿用模拟器的单实例规则:已有普通的模拟器窗口时,会把程序交给它打开。

许可证

Apache-2.0。cc65 部分为 zlib 许可,随工具链包附带许可文件。