diff --git a/.gitignore b/.gitignore index b0162ad..0821eb7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /tmp *.bin *.nes +*.nes.deb *.sym *.mlb *.nl diff --git a/README.md b/README.md index aac04eb..33e7787 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Table of Contents * [searcher(name)](#searchername) * [load, loadfile, dofile ; installhooks(), uninstallhooks()](#load-loadfile-dofile--installhooks-uninstallhooks) * [image(filename)](#imagefilename) - * [VCS Module](#vcs-module) + * [Platform Modules](#platform-modules) * [Building](#building) * [Windows](#windows) * [Linux](#linux) @@ -107,6 +107,8 @@ Have a look at these files in the `samples` folder to get started with l65: * `vcs_music.l65`: imports and plays back a TIATracker .ttt file directly. * `vcs_mcart.l65`: imports all TIATracker .ttt files in the folder supplied as arg, or current directory, and builds a music cart. + * `nes_hello.l65`: a NES 'Hello World' using BG tiles, and automatic positioned font within a 4kB CHR rom page. + There's also `vcspal.act`, a palette file for authoring software for VCS. Use this palette or a similar one to create 8b PNG for `l65.image` and helper loaders depending on it. You can generate such a palette, or a GPL one for GIMP using [vcsconv](https://github.com/g012/vcsconv) `authpalette` command. ## API @@ -598,10 +600,12 @@ Return `nil` and an error message on failure, or a table with the following fiel * `height`: image height, in pixels * [1..width\*height]: the pixels, as palette indices (all bytes) -### VCS Module +### Platform Modules `vcs.l65` is a helper file for developing on Atari 2600 VCS. It's embedded into the l65 executable. It sets the 6502.lua module as metatable of the current `_ENV`, defines all TIA and PIA symbols, some helper constants and functions, as well as mapper helpers and automatic cross bank call functions. See the samples directory for usage examples, and browse vcs.l65 directly for the list of self-explanatory helpers. +`nes.l65` is for NES/Famicom. It provides templates for some mappers, including 0-NROM, 1-MMC1, 2-UxROM, 3-CNROM, 4-MMC3, 5-MMC5, and 66-GxROM. + ## Building Use CMake to build a standalone executable. Following are basic instructions if you've never used CMake. diff --git a/nes.l65 b/nes.l65 index 4c52d5b..d88f3c5 100644 --- a/nes.l65 +++ b/nes.l65 @@ -82,9 +82,12 @@ cpu.getsym_as.fceux = function(filename) -- .nl, multiple files if a < 0x8000 then ins(ram, s) elseif a < 0x10000 then local a_org = symbolsorg[l] or a - local bank = math.floor((a_org - 0x8000) / 0x4000) - if not rom[bank] then rom[bank] = {} end - ins(rom[bank], s) + local romstart = locations[2].start -- header location should always be defined first, skip it + if a_org >= romstart then + local bank = math.floor((a_org - romstart) / 0x4000) + if not rom[bank] then rom[bank] = {} end + ins(rom[bank], s) + end end end) local fn = filename