cc65: fixed errors in include files; minor fixes, preset updates

This commit is contained in:
Steven Hugg 2019-03-22 20:26:47 -04:00
parent f49ce33f97
commit cc767eafd0
10 changed files with 139 additions and 23 deletions

View File

@ -101,6 +101,8 @@ TODO:
- editor: select palette for chr, select charmap for map (dependencies?)
- global undo/redo at checkpoints (when rom changes)
- asset editor still refreshes twice
- pulldown shows wrong file if preset not present
- landscape mode for arcade ports
WEB WORKER FORMAT

View File

@ -22,7 +22,7 @@ unsigned int nt2attraddr(unsigned int a) {
((a >> 4) & 0x38) | ((a >> 2) & 0x07);
}
#define ATTRADR_A(x,y) (NAMETABLE_A|0x3c0|((((y)>>2)<<3)|((x)>>2)))
#define ATTRADR_A(x,y) (NAMETABLE_A|0x3c0|((((y)>>2)<<3)|((x)>>2)))
void put_pixel(unsigned char px, unsigned char py, char color) {
int ntaddr, attraddr;

View File

@ -1,6 +1,6 @@
.segment "CHARS"
;;{w:8,h:8,bpp:1,count:256,brev:1,np:2,pofs:8,remap:[0,1,2,4,5,6,7,8,9,10,11,12]}*/
.segment "CHARS"
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00

105
presets/nes/monobitmap.c Normal file
View File

@ -0,0 +1,105 @@
#include "neslib.h"
#include "nes.h"
#define NES_MAPPER 2 // UxROM mapper
#define NES_CHR_BANKS 0 // CHR RAM
void set_pixel(byte x, byte y, byte color) {
// compute pattern table address
word a = (x/8)*16 + ((y&63)/8)*(16*32) + (y&7);
byte b;
if (y & 64) a |= 8;
if (y & 128) a |= 0x1000;
// read old byte
vram_adr(a);
vram_read(&b, 1);
if (color) {
b |= 128 >> (x&7); // set pixel
} else {
b &= ~(128 >> (x&7)); // clear pixel
}
// write new byte
vram_adr(a);
vram_put(b);
}
// write values 0..255
void vram_put_256inc() {
word i;
for (i=0; i<256; i++)
vram_put(i);
}
void vram_put_attrib() {
vram_fill(0x00, 0x10); // first palette
vram_fill(0x55, 0x10); // second palette
}
void setup_monobitmap() {
// clear pattern table
vram_adr(0x0);
vram_fill(0x0, 0x2000);
// setup nametable A and B
vram_adr(NAMETABLE_A);
vram_put_256inc();
vram_put_256inc();
vram_put_256inc();
vram_put_256inc();
vram_adr(NAMETABLE_B);
vram_put_256inc();
vram_put_256inc();
vram_put_256inc();
vram_put_256inc();
vram_adr(NAMETABLE_A + 0x3c0);
vram_put_attrib();
vram_put_attrib();
vram_adr(NAMETABLE_B + 0x3c0);
vram_put_attrib();
vram_put_attrib();
bank_bg(0);
// setup sprite 0
oam_clear();
oam_size(0);
oam_spr(255, 125, 255, 0, 0);
bank_spr(1);
// make sprite 255 = white square
vram_adr(0x1ff0);
vram_fill(0xff, 0x10);
}
/*{pal:"nes"}*/
const byte MONOBMP_PALETTE[16] = {
0x03,
0x30, 0x03, 0x30, 0x00,
0x03, 0x30, 0x30, 0x00,
0x30, 0x03, 0x30, 0x00,
0x03, 0x30, 0x30
};
void demo() {
byte i;
for (i=16; i<220; i++) {
set_pixel(i,16,1);
set_pixel(16,i,1);
set_pixel(i,220,1);
set_pixel(220,i,1);
set_pixel(i,i,1);
}
}
void main(void)
{
byte ctrl;
setup_monobitmap();
pal_bg(MONOBMP_PALETTE);
demo();
ppu_on_all();//enable rendering
while(1) {
ppu_wait_nmi();
// split screen at line 128
ctrl = PPU.control;
split(0,0);
PPU.control = ctrl ^ 0x10; // bg bank 1
}
}

View File

@ -38,6 +38,7 @@ export type PixelEditorImageFormat = {
brev?:boolean
destfmt?:PixelEditorImageFormat
xform?:string
skip?:number
};
export type PixelEditorPaletteFormat = {
@ -352,6 +353,7 @@ function convertWordsToImages(words:UintArray, fmt:PixelEditorImageFormat) : Uin
var wordsperline = fmt.sl || Math.ceil(width * bpp / bitsperword);
var mask = (1 << bpp)-1;
var pofs = fmt.pofs || wordsperline*height*count;
var skip = fmt.skip || 0;
var images = [];
for (var n=0; n<count; n++) {
var imgdata = [];
@ -362,7 +364,7 @@ function convertWordsToImages(words:UintArray, fmt:PixelEditorImageFormat) : Uin
var color = 0;
var ofs = remapBits(ofs0, fmt.remap);
for (var p=0; p<nplanes; p++) {
var byte = words[ofs + p*pofs];
var byte = words[ofs + p*pofs + skip];
color |= ((fmt.brev ? byte>>(bitsperword-shift-bpp) : byte>>shift) & mask) << (p*bpp);
}
imgdata.push(color);
@ -389,6 +391,7 @@ function convertImagesToWords(images:Uint8Array[], fmt:PixelEditorImageFormat) :
var wordsperline = fmt.sl || Math.ceil(fmt.w * bpp / bitsperword);
var mask = (1 << bpp)-1;
var pofs = fmt.pofs || wordsperline*height*count;
var skip = fmt.skip || 0;
var words;
if (bitsperword <= 8)
words = new Uint8Array(wordsperline*height*count*nplanes);
@ -405,7 +408,7 @@ function convertImagesToWords(images:Uint8Array[], fmt:PixelEditorImageFormat) :
var ofs = remapBits(ofs0, fmt.remap);
for (var p=0; p<nplanes; p++) {
var c = (color >> (p*bpp)) & mask;
words[ofs + p*pofs] |= (fmt.brev ? (c << (bitsperword-shift-bpp)) : (c << shift));
words[ofs + p*pofs + skip] |= (fmt.brev ? (c << (bitsperword-shift-bpp)) : (c << shift));
}
shift += bpp;
if (shift >= bitsperword) {
@ -622,20 +625,24 @@ var PREDEF_PALETTES = {
0xC4D5E7, 0xFF4000, 0xDC0E22, 0xFF476B, 0xD7009F, 0x680AD7, 0x0019BC, 0x0054B1, 0x006A5B, 0x008C03, 0x00AB00, 0x2C8800, 0xA47200, 0x000000, 0x000000, 0x000000,
0xF8F8F8, 0xFFAB3C, 0xFF7981, 0xFF5BC5, 0xFF48F2, 0xDF49FF, 0x476DFF, 0x00B4F7, 0x00E0FF, 0x00E375, 0x03F42B, 0x78B82E, 0xE5E218, 0x787878, 0x000000, 0x000000,
0xFFFFFF, 0xFFF2BE, 0xF8B8B8, 0xF8B8D8, 0xFFB6FF, 0xFFC3FF, 0xC7D1FF, 0x9ADAFF, 0x88EDF8, 0x83FFDD, 0xB8F8B8, 0xF5F8AC, 0xFFFFB0, 0xF8D8F8, 0x000000, 0x000000
]
],
'ap2lores':[
(0x000000), (0xff00ff), (0x00007f), (0x7f007f), (0x007f00), (0x7f7f7f), (0x0000bf), (0x0000ff),
(0xbf7f00), (0xffbf00), (0xbfbfbf), (0xff7f7f), (0x00ff00), (0xffff00), (0x00bf7f), (0xffffff),
],
};
var PREDEF_LAYOUTS : {[id:string]:PixelEditorPaletteLayout} = {
'nes':[
['Screen Color', 0x00, 1],
['Background 1', 0x01, 3],
['Background 2', 0x05, 3],
['Background 3', 0x09, 3],
['Background 4', 0x0d, 3],
['Sprite 1', 0x11, 3],
['Sprite 2', 0x15, 3],
['Sprite 3', 0x19, 3],
['Sprite 4', 0x1d, 3]
['Background 0', 0x01, 3],
['Background 1', 0x05, 3],
['Background 2', 0x09, 3],
['Background 3', 0x0d, 3],
['Sprite 0', 0x11, 3],
['Sprite 1', 0x15, 3],
['Sprite 2', 0x19, 3],
['Sprite 3', 0x1d, 3]
],
};

View File

@ -26,6 +26,7 @@ const JSNES_PRESETS = [
{id:'statusbar.c', name:'Split Status Bar'},
{id:'horizmask.c', name:'Offscreen Scrolling'},
{id:'attributes.c', name:'Attribute Table + Pixels'},
{id:'monobitmap.c', name:'Monochrome Bitmap'},
{id:'aputest.c', name:'Sound Tester'},
{id:'music.c', name:'Music Player'},
{id:'siegegame.c', name:'Siege Game'},

View File

@ -1122,7 +1122,7 @@ export class AssetEditorView implements ProjectView, pixed.EditorContext {
aeditor.appendTo(adual);
// make default layout if not exists
if (!layout) {
var imgsperline = palette.length > 32 ? 8 : 4;
var imgsperline = palette.length > 32 ? 8 : 4; // TODO: use 'n'?
var len = allcolors.length;
layout = [];
for (var i=0; i<len; i+=imgsperline) {

View File

@ -561,9 +561,9 @@ function makeErrorMatcher(errors:WorkerError[], regex, iline:number, imsg:number
}
}
function extractErrors(regex, strings:string[], path:string) {
function extractErrors(regex, strings:string[], path:string, iline, imsg, ifilename) {
var errors = [];
var matcher = makeErrorMatcher(errors, regex, 1, 2, path);
var matcher = makeErrorMatcher(errors, regex, iline, imsg, path, ifilename);
for (var i=0; i<strings.length; i++) {
matcher(strings[i]);
}
@ -1025,17 +1025,18 @@ function compileCC65(step:BuildStep) {
loadNative("cc65");
var params = step.params;
// stderr
var re_err1 = /.*?[(](\d+)[)].*?: (.+)/;
var errors = [];
var re_err1 = /(.*?)[(](\d+)[)].*?: (.+)/;
var errors : WorkerError[] = [];
var errline = 0;
function match_fn(s) {
console.log(s);
var matches = re_err1.exec(s);
if (matches) {
errline = parseInt(matches[1]);
errline = parseInt(matches[2]);
errors.push({
line:errline,
msg:matches[2]
msg:matches[3],
path:matches[1]
});
}
}
@ -1386,7 +1387,7 @@ function preprocessMCPP(step:BuildStep) {
var errout = FS.readFile("mcpp.err", {encoding:'utf8'});
if (errout.length) {
// //main.c:2: error: Can't open include file "stdiosd.h"
var errors = extractErrors(/[^:]+:(\d+): (.+)/, errout.split("\n"), step.path);
var errors = extractErrors(/([^:]+):(\d+): (.+)/, errout.split("\n"), step.path, 2, 3, 1);
if (errors.length == 0) {
errors = [{line:0, msg:errout}];
}

View File

@ -10,7 +10,7 @@ describe('Pixel editor', function() {
it('Should decode', function() {
var paldatastr = " 0x00, 0x03, 0x19, 0x50, 0x52, 0x07, 0x1f, 0x37, 0xe0, 0xa4, 0xfd, 0xff, 0x38, 0x70, 0x7f, 0xf8, ";
var fmt = {w:14,h:16,bpp:4,brev:1};
var datastr = "0x00,0x00,0xef,0xef,0xe0,0x00,0x00, 0x00,0xee,0xee,0xfe,0xee,0xe0,0x00, 0x0e,0xed,0xef,0xef,0xed,0xee,0x00, 0x0e,0xee,0xdd,0xdd,0xde,0xee,0x00, 0x0e,0xee,0xed,0xde,0xee,0xee,0x00, 0x00,0xee,0xee,0xde,0xee,0xe0,0x00, 0x00,0xee,0xee,0xde,0xee,0xe0,0x00, 0x00,0x00,0xed,0xdd,0xe0,0x00,0x0d, 0xdd,0xdd,0xee,0xee,0xed,0xdd,0xd0, 0x0d,0xee,0xee,0xee,0xee,0xee,0x00, 0x0e,0xe0,0xee,0xee,0xe0,0xee,0x00, 0x0e,0xe0,0xee,0xee,0xe0,0xee,0x00, 0x0e,0xe0,0xdd,0xdd,0xd0,0xde,0x00, 0x0d,0x00,0xee,0x0e,0xe0,0x0d,0x00, 0x00,0x00,0xed,0x0e,0xe0,0x00,0x00, 0x00,0x0d,0xdd,0x0d,0xdd,0x00,0x18,";
var datastr = "1,2, 0x00,0x00,0xef,0xef,0xe0,0x00,0x00, 0x00,0xee,0xee,0xfe,0xee,0xe0,0x00, 0x0e,0xed,0xef,0xef,0xed,0xee,0x00, 0x0e,0xee,0xdd,0xdd,0xde,0xee,0x00, 0x0e,0xee,0xed,0xde,0xee,0xee,0x00, 0x00,0xee,0xee,0xde,0xee,0xe0,0x00, 0x00,0xee,0xee,0xde,0xee,0xe0,0x00, 0x00,0x00,0xed,0xdd,0xe0,0x00,0x0d, 0xdd,0xdd,0xee,0xee,0xed,0xdd,0xd0, 0x0d,0xee,0xee,0xee,0xee,0xee,0x00, 0x0e,0xe0,0xee,0xee,0xe0,0xee,0x00, 0x0e,0xe0,0xee,0xee,0xe0,0xee,0x00, 0x0e,0xe0,0xdd,0xdd,0xd0,0xde,0x00, 0x0d,0x00,0xee,0x0e,0xe0,0x0d,0x00, 0x00,0x00,0xed,0x0e,0xe0,0x00,0x00, 0x00,0x0d,0xdd,0x0d,0xdd,0x00,0x18,";
pixed.pixelEditorDecodeMessage({data:{fmt:fmt,bytestr:datastr,palfmt:{pal:332,n:16},palstr:paldatastr}});
assert.deepEqual(pixed.palette, [0xff000000,
0xff000060,

2
tss

@ -1 +1 @@
Subproject commit 61a1691a1de05dca3b694bf603db49ffbaf572cf
Subproject commit 5b5ee67fc06956bc7dce51726e98812d2d897eaa