mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-26 10:49:17 +00:00
trying to fix asset editor nametables
This commit is contained in:
parent
de0ede9e81
commit
e3a3016f9d
@ -94,12 +94,14 @@ TODO:
|
|||||||
- persist palette/tilemap selections
|
- persist palette/tilemap selections
|
||||||
- more tools for editing
|
- more tools for editing
|
||||||
- map editor
|
- map editor
|
||||||
|
- arbitrary nametable editing
|
||||||
- metasprites
|
- metasprites
|
||||||
- throw errors when bad/no refs
|
- throw errors when bad/no refs
|
||||||
- per-View keyboard shortcuts
|
- per-View keyboard shortcuts
|
||||||
- parse labels
|
- parse labels
|
||||||
- parse .incbin directives?
|
- parse .incbin directives?
|
||||||
- can't replace in hex directives
|
- can't replace in hex directives
|
||||||
|
- should maybe use same single-canvas editor for map + char editor
|
||||||
- crt0.s compiled each time?
|
- crt0.s compiled each time?
|
||||||
- debug highlight doesn't go away when debugging -> running
|
- debug highlight doesn't go away when debugging -> running
|
||||||
- show breakpoint of PC or highest address on stack
|
- show breakpoint of PC or highest address on stack
|
||||||
@ -149,7 +151,6 @@ TODO:
|
|||||||
- can published files retain path?
|
- can published files retain path?
|
||||||
- what if import interrupted and partial files?
|
- what if import interrupted and partial files?
|
||||||
- CORS for some blobs?
|
- CORS for some blobs?
|
||||||
- confusing when examples load if file not found
|
|
||||||
- don't import useless files
|
- don't import useless files
|
||||||
- support projects with subdirectories, file list?
|
- support projects with subdirectories, file list?
|
||||||
- emulator needs reset shortcut for nes
|
- emulator needs reset shortcut for nes
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/*{w:32,h:30,bpp:8,comp:"rletag",map:"nesnt"}*/
|
||||||
const unsigned char gameover_nam[81]={
|
const unsigned char gameover_nam[81]={
|
||||||
0x01,0x00,0x01,0xfe,0x00,0x01,0x86,0x60,0x61,0x60,0x62,0x63,0x64,0x65,0x66,0x00,
|
0x01,0x00,0x01,0xfe,0x00,0x01,0x86,0x60,0x61,0x60,0x62,0x63,0x64,0x65,0x66,0x00,
|
||||||
0x60,0x62,0x67,0x68,0x65,0x66,0x65,0x62,0x00,0x97,0x00,0x01,0x0c,0x67,0x6a,0x67,
|
0x60,0x62,0x67,0x68,0x65,0x66,0x65,0x62,0x00,0x97,0x00,0x01,0x0c,0x67,0x6a,0x67,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/*{w:32,h:30,bpp:8,comp:"rletag",map:"nesnt"}*/
|
||||||
const unsigned char level2_nam[459]={
|
const unsigned char level2_nam[459]={
|
||||||
0x01,0x00,0x01,0xc5,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,
|
0x01,0x00,0x01,0xc5,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,
|
||||||
0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x00,0x01,0x0b,0x42,0x43,0x42,0x43,0x42,
|
0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x00,0x01,0x0b,0x42,0x43,0x42,0x43,0x42,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/*{w:32,h:30,bpp:8,comp:"rletag",map:"nesnt"}*/
|
||||||
const unsigned char level3_nam[540]={
|
const unsigned char level3_nam[540]={
|
||||||
0x01,0x00,0x01,0xc5,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,
|
0x01,0x00,0x01,0xc5,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,
|
||||||
0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x00,0x01,0x0b,0x42,0x43,0x42,0x43,0x42,
|
0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x00,0x01,0x0b,0x42,0x43,0x42,0x43,0x42,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/*{w:32,h:30,bpp:8,comp:"rletag",map:"nesnt"}*/
|
||||||
const unsigned char level4_nam[640]={
|
const unsigned char level4_nam[640]={
|
||||||
0x02,0x00,0x02,0x85,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,
|
0x02,0x00,0x02,0x85,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,
|
||||||
0x00,0x02,0x13,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x00,
|
0x00,0x02,0x13,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x00,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/*{w:32,h:30,bpp:8,comp:"rletag",map:"nesnt"}*/
|
||||||
const unsigned char level5_nam[851]={
|
const unsigned char level5_nam[851]={
|
||||||
0x01,0x00,0x01,0x83,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,
|
0x01,0x00,0x01,0x83,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,
|
||||||
0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x00,0x01,0x07,0x42,
|
0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x00,0x01,0x07,0x42,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/*{w:32,h:30,bpp:8,comp:"rletag",map:"nesnt"}*/
|
||||||
const unsigned char level_nam[52]={
|
const unsigned char level_nam[52]={
|
||||||
0x01,0x00,0x01,0xfe,0x00,0x01,0x89,0x67,0x00,0x65,0x66,0x67,0x68,0x65,0x66,0x67,
|
0x01,0x00,0x01,0xfe,0x00,0x01,0x89,0x67,0x00,0x65,0x66,0x67,0x68,0x65,0x66,0x67,
|
||||||
0x00,0x01,0x16,0x67,0x00,0x65,0x6d,0x67,0x68,0x65,0x6d,0x67,0x00,0x01,0x16,0x72,
|
0x00,0x01,0x16,0x67,0x00,0x65,0x6d,0x67,0x68,0x65,0x6d,0x67,0x00,0x01,0x16,0x72,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/*{w:32,h:30,bpp:8,comp:"rletag",map:"nesnt"}*/
|
||||||
const unsigned char title_nam[380]={
|
const unsigned char title_nam[380]={
|
||||||
0x01,0x00,0x01,0x85,0x40,0x41,0x00,0x00,0x40,0x41,0x00,0x01,0x05,0x40,0x41,0x40,
|
0x01,0x00,0x01,0x85,0x40,0x41,0x00,0x00,0x40,0x41,0x00,0x01,0x05,0x40,0x41,0x40,
|
||||||
0x41,0x40,0x41,0x00,0x01,0x07,0x40,0x41,0x40,0x41,0x40,0x41,0x42,0x43,0x00,0x00,
|
0x41,0x40,0x41,0x00,0x01,0x07,0x40,0x41,0x40,0x41,0x40,0x41,0x42,0x43,0x00,0x00,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/*{w:32,h:30,bpp:8,comp:"rletag",map:"nesnt"}*/
|
||||||
const unsigned char welldone_nam[106]={
|
const unsigned char welldone_nam[106]={
|
||||||
0x02,0x00,0x02,0xfe,0x00,0x02,0x86,0x67,0x68,0x65,0x66,0x67,0x00,0x67,0x00,0x00,
|
0x02,0x00,0x02,0xfe,0x00,0x02,0x86,0x67,0x68,0x65,0x66,0x67,0x00,0x67,0x00,0x00,
|
||||||
0x65,0x62,0x60,0x62,0x63,0x79,0x65,0x66,0x00,0x97,0x00,0x02,0x0c,0x82,0x83,0x65,
|
0x65,0x62,0x60,0x62,0x63,0x79,0x65,0x66,0x00,0x97,0x00,0x02,0x0c,0x82,0x83,0x65,
|
||||||
|
@ -704,7 +704,9 @@ export class NESNametableConverter extends Compositor {
|
|||||||
for (var row=0; row<this.rows; row++) {
|
for (var row=0; row<this.rows; row++) {
|
||||||
for (var col=0; col<this.cols; col++) {
|
for (var col=0; col<this.cols; col++) {
|
||||||
var name = this.words[this.baseofs + a];
|
var name = this.words[this.baseofs + a];
|
||||||
|
if (typeof name === 'undefined') throw "No name for address " + this.baseofs + " + " + a;
|
||||||
var t = this.tilemap[name];
|
var t = this.tilemap[name];
|
||||||
|
if (!t) throw "No tilemap found for tile index " + name;
|
||||||
attraddr = (a & 0x2c00) | 0x3c0 | (a & 0x0C00) | ((a >> 4) & 0x38) | ((a >> 2) & 0x07);
|
attraddr = (a & 0x2c00) | 0x3c0 | (a & 0x0C00) | ((a >> 4) & 0x38) | ((a >> 2) & 0x07);
|
||||||
var attr = this.words[attraddr];
|
var attr = this.words[attraddr];
|
||||||
var tag = name ^ (attr<<9) ^ 0x80000000;
|
var tag = name ^ (attr<<9) ^ 0x80000000;
|
||||||
@ -840,6 +842,40 @@ export class CharmapEditor extends PixNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class MapEditor extends PixNode {
|
||||||
|
|
||||||
|
context;
|
||||||
|
parentdiv;
|
||||||
|
fmt;
|
||||||
|
|
||||||
|
constructor(context:EditorContext, parentdiv:JQuery, fmt:PixelEditorImageFormat) {
|
||||||
|
super();
|
||||||
|
this.context = context;
|
||||||
|
this.parentdiv = parentdiv;
|
||||||
|
this.fmt = fmt;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateLeft() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateRight() {
|
||||||
|
if (equalNestedArrays(this.rgbimgs, this.left.rgbimgs)) return false;
|
||||||
|
this.rgbimgs = this.left.rgbimgs;
|
||||||
|
var adual = newDiv(this.parentdiv.empty(), "asset_dual"); // contains grid and editor
|
||||||
|
var agrid = newDiv(adual);
|
||||||
|
var aeditor = newDiv(adual, "asset_editor").hide(); // contains editor, when selected
|
||||||
|
// add image chooser grid
|
||||||
|
var viewer = new Viewer();
|
||||||
|
viewer.width = this.fmt.w;
|
||||||
|
viewer.height = this.fmt.h;
|
||||||
|
viewer.recreate();
|
||||||
|
viewer.updateImage(this.rgbimgs[0]);
|
||||||
|
agrid.append(viewer.canvas);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class Viewer {
|
export class Viewer {
|
||||||
|
|
||||||
width : number;
|
width : number;
|
||||||
|
40
src/views.ts
40
src/views.ts
@ -924,10 +924,13 @@ export class AssetEditorView implements ProjectView, pixed.EditorContext {
|
|||||||
this.deferrednodes = [];
|
this.deferrednodes = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
registerAsset(type:string, node:pixed.PixNode, deferred:boolean) {
|
registerAsset(type:string, node:pixed.PixNode, deferred:number) {
|
||||||
this.rootnodes.push(node);
|
this.rootnodes.push(node);
|
||||||
if (deferred) {
|
if (deferred) {
|
||||||
|
if (deferred > 1)
|
||||||
this.deferrednodes.push(node);
|
this.deferrednodes.push(node);
|
||||||
|
else
|
||||||
|
this.deferrednodes.unshift(node);
|
||||||
} else {
|
} else {
|
||||||
node.refreshRight();
|
node.refreshRight();
|
||||||
}
|
}
|
||||||
@ -973,8 +976,7 @@ export class AssetEditorView implements ProjectView, pixed.EditorContext {
|
|||||||
this.rootnodes.forEach((node) => {
|
this.rootnodes.forEach((node) => {
|
||||||
while (node != null) {
|
while (node != null) {
|
||||||
if (node instanceof pixed.Palettizer) {
|
if (node instanceof pixed.Palettizer) {
|
||||||
// TODO: move to node class?
|
var rgbimgs = node.rgbimgs;
|
||||||
var rgbimgs = node.rgbimgs; // TODO: why is null?
|
|
||||||
if (rgbimgs && rgbimgs.length >= matchlen) {
|
if (rgbimgs && rgbimgs.length >= matchlen) {
|
||||||
result.push({node:node, name:"Tilemap", images:node.images, rgbimgs:rgbimgs}); // TODO
|
result.push({node:node, name:"Tilemap", images:node.images, rgbimgs:rgbimgs}); // TODO
|
||||||
}
|
}
|
||||||
@ -1178,14 +1180,14 @@ export class AssetEditorView implements ProjectView, pixed.EditorContext {
|
|||||||
let node = new pixed.FileDataNode(projectWindows, fileid);
|
let node = new pixed.FileDataNode(projectWindows, fileid);
|
||||||
const neschrfmt = {w:8,h:8,bpp:1,count:(data.length>>4),brev:true,np:2,pofs:8,remap:[0,1,2,4,5,6,7,8,9,10,11,12]}; // TODO
|
const neschrfmt = {w:8,h:8,bpp:1,count:(data.length>>4),brev:true,np:2,pofs:8,remap:[0,1,2,4,5,6,7,8,9,10,11,12]}; // TODO
|
||||||
this.addPixelEditor(this.ensureFileDiv(fileid), node, neschrfmt);
|
this.addPixelEditor(this.ensureFileDiv(fileid), node, neschrfmt);
|
||||||
this.registerAsset("charmap", node, true);
|
this.registerAsset("charmap", node, 1);
|
||||||
nassets++;
|
nassets++;
|
||||||
} else if (platform_id.startsWith('nes') && fileid.endsWith('.pal') && data instanceof Uint8Array) {
|
} else if (platform_id.startsWith('nes') && fileid.endsWith('.pal') && data instanceof Uint8Array) {
|
||||||
// is this a NES PAL?
|
// is this a NES PAL?
|
||||||
let node = new pixed.FileDataNode(projectWindows, fileid);
|
let node = new pixed.FileDataNode(projectWindows, fileid);
|
||||||
const nespalfmt = {pal:"nes",layout:"nes"};
|
const nespalfmt = {pal:"nes",layout:"nes"};
|
||||||
this.addPaletteEditor(this.ensureFileDiv(fileid), node, nespalfmt);
|
this.addPaletteEditor(this.ensureFileDiv(fileid), node, nespalfmt);
|
||||||
this.registerAsset("palette", node, false);
|
this.registerAsset("palette", node, 0);
|
||||||
nassets++;
|
nassets++;
|
||||||
} else if (typeof data === 'string') {
|
} else if (typeof data === 'string') {
|
||||||
let textfrags = this.scanFileTextForAssets(fileid, data);
|
let textfrags = this.scanFileTextForAssets(fileid, data);
|
||||||
@ -1194,30 +1196,29 @@ export class AssetEditorView implements ProjectView, pixed.EditorContext {
|
|||||||
let label = fileid; // TODO: label
|
let label = fileid; // TODO: label
|
||||||
let node : pixed.PixNode = new pixed.TextDataNode(projectWindows, fileid, label, frag.start, frag.end);
|
let node : pixed.PixNode = new pixed.TextDataNode(projectWindows, fileid, label, frag.start, frag.end);
|
||||||
let first = node;
|
let first = node;
|
||||||
// rle-compressed? TODO
|
// rle-compressed? TODO: how to edit?
|
||||||
if (frag.fmt.comp == 'rletag') {
|
if (frag.fmt.comp == 'rletag') {
|
||||||
//node = node.addRight(new pixed.Compressor());
|
node = node.addRight(new pixed.Compressor());
|
||||||
continue; // TODO
|
|
||||||
}
|
}
|
||||||
// is this a nes nametable?
|
// is this a nes nametable?
|
||||||
if (frag.fmt.map == 'nesnt') {
|
if (frag.fmt.map == 'nesnt') {
|
||||||
node = node.addRight(new pixed.NESNametableConverter(this)); // TODO?
|
node = node.addRight(new pixed.NESNametableConverter(this));
|
||||||
node = node.addRight(new pixed.Palettizer(this, {w:8,h:8,bpp:4})); // TODO?
|
node = node.addRight(new pixed.Palettizer(this, {w:8,h:8,bpp:4}));
|
||||||
const fmt = {w:8*32,h:8*30,count:1}; // TODO
|
const fmt = {w:8*(frag.fmt.w||32),h:8*(frag.fmt.h||30),count:1}; // TODO: can't do custom sizes
|
||||||
node = node.addRight(new pixed.CharmapEditor(this, newDiv(this.ensureFileDiv(fileid)), fmt));
|
node = node.addRight(new pixed.MapEditor(this, newDiv(this.ensureFileDiv(fileid)), fmt));
|
||||||
this.registerAsset("nametable", first, true);
|
this.registerAsset("nametable", first, 2);
|
||||||
nassets++;
|
nassets++;
|
||||||
}
|
}
|
||||||
// is this a bitmap?
|
// is this a bitmap?
|
||||||
else if (frag.fmt.w > 0 && frag.fmt.h > 0) {
|
else if (frag.fmt.w > 0 && frag.fmt.h > 0) {
|
||||||
this.addPixelEditor(this.ensureFileDiv(fileid), node, frag.fmt);
|
this.addPixelEditor(this.ensureFileDiv(fileid), node, frag.fmt);
|
||||||
this.registerAsset("charmap", first, true);
|
this.registerAsset("charmap", first, 1);
|
||||||
nassets++;
|
nassets++;
|
||||||
}
|
}
|
||||||
// is this a palette?
|
// is this a palette?
|
||||||
else if (frag.fmt.pal) {
|
else if (frag.fmt.pal) {
|
||||||
this.addPaletteEditor(this.ensureFileDiv(fileid), node, frag.fmt);
|
this.addPaletteEditor(this.ensureFileDiv(fileid), node, frag.fmt);
|
||||||
this.registerAsset("palette", first, false);
|
this.registerAsset("palette", first, 0);
|
||||||
nassets++;
|
nassets++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1249,7 +1250,14 @@ export class AssetEditorView implements ProjectView, pixed.EditorContext {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log("Found " + this.rootnodes.length + " assets");
|
console.log("Found " + this.rootnodes.length + " assets");
|
||||||
this.deferrednodes.forEach((node) => { node.refreshRight(); });
|
this.deferrednodes.forEach((node) => {
|
||||||
|
try {
|
||||||
|
node.refreshRight();
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
alert(e+"");
|
||||||
|
}
|
||||||
|
});
|
||||||
this.deferrednodes = [];
|
this.deferrednodes = [];
|
||||||
} else {
|
} else {
|
||||||
// only refresh nodes if not actively editing
|
// only refresh nodes if not actively editing
|
||||||
|
Loading…
Reference in New Issue
Block a user