1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-22 14:33:51 +00:00

convert old vcs examples/foo paths to examples/foo.a

This commit is contained in:
Steven Hugg 2019-05-08 23:10:24 -04:00
parent cd0d1416dc
commit e73388b24e
5 changed files with 62 additions and 43 deletions

View File

@ -145,6 +145,7 @@ TODO:
- un-bind from repo?
- repo/platform dichotomy
- navigate to/from repo
- import 'examples/' retains path?
WEB WORKER FORMAT

View File

@ -10,37 +10,37 @@ declare var Javatari : any;
declare var jt : any; // 6502
const VCS_PRESETS = [
{id:'examples/hello', chapter:4, name:'Hello 6502 and TIA'},
{id:'examples/vsync', chapter:5, name:'Painting on the CRT', title:'Color Bars'},
{id:'examples/playfield', chapter:6, name:'Playfield Graphics'},
{id:'examples/sprite', chapter:7, name:'Players and Sprites'},
{id:'examples/timing2', chapter:9, name:'Fine Positioning', title:'Fine Position'},
{id:'examples/missiles', chapter:10, name:'Player/Missile Graphics', title:'Player/Missile'},
{id:'examples/complexscene', chapter:15, name:'Complex Scene I'},
{id:'examples/complexscene2', chapter:16, name:'Complex Scene II'},
{id:'examples/scoreboard', chapter:18, name:'Scoreboard'},
{id:'examples/collisions', chapter:19, name:'Collisions'},
{id:'examples/bitmap', chapter:20, name:'Async Playfield: Bitmap', title:'Async PF Bitmap'},
{id:'examples/brickgame', chapter:21, name:'Async Playfield: Bricks', title:'Async PF Bricks'},
// {id:'examples/multisprite1', chapter:8, name:'Sprite Kernel'},
{id:'examples/bigsprite', chapter:22, name:'A Big 48-Pixel Sprite', title:'48-Pixel Sprite'},
{id:'examples/tinyfonts2', chapter:23, name:'Tiny Text'},
{id:'examples/score6', chapter:24, name:'6-Digit Score'},
{id:'examples/retrigger', chapter:26, name:'Sprite Formations'},
// {id:'examples/tinyfonts', chapter:23, name:'Tiny Fonts, Slow'},
{id:'examples/multisprite3', chapter:28, name:'Multisprites'},
{id:'examples/procgen1', chapter:30, name:'Procedural Generation'},
{id:'examples/lines', chapter:31, name:'Drawing Lines'},
// {id:'examples/piatable', name:'Timer Table'},
{id:'examples/musicplayer', chapter:32, name:'Music Player'},
{id:'examples/road', chapter:33, name:'Pseudo 3D Road'},
{id:'examples/bankswitching', chapter:35, name:'Bankswitching'},
{id:'examples/wavetable', chapter:36, name:'Wavetable Sound'},
{id:'examples/fracpitch', name:'Fractional Pitch'},
{id:'examples/pal', name:'PAL Video Output'},
// {id:'examples/testlibrary', name:'VCS Library Demo'},
// {id:'examples/music2', name:'Pitch-Accurate Music'},
// {id:'examples/fullgame', name:'Thru Hike: The Game', title:'Thru Hike'},
{id:'examples/hello.a', chapter:4, name:'Hello 6502 and TIA'},
{id:'examples/vsync.a', chapter:5, name:'Painting on the CRT', title:'Color Bars'},
{id:'examples/playfield.a', chapter:6, name:'Playfield Graphics'},
{id:'examples/sprite.a', chapter:7, name:'Players and Sprites'},
{id:'examples/timing2.a', chapter:9, name:'Fine Positioning', title:'Fine Position'},
{id:'examples/missiles.a', chapter:10, name:'Player/Missile Graphics', title:'Player/Missile'},
{id:'examples/complexscene.a', chapter:15, name:'Complex Scene I'},
{id:'examples/complexscene2.a', chapter:16, name:'Complex Scene II'},
{id:'examples/scoreboard.a', chapter:18, name:'Scoreboard'},
{id:'examples/collisions.a', chapter:19, name:'Collisions'},
{id:'examples/bitmap.a', chapter:20, name:'Async Playfield: Bitmap', title:'Async PF Bitmap'},
{id:'examples/brickgame.a', chapter:21, name:'Async Playfield: Bricks', title:'Async PF Bricks'},
// {id:'examples/multisprite1.a', chapter:8, name:'Sprite Kernel'},
{id:'examples/bigsprite.a', chapter:22, name:'A Big 48-Pixel Sprite', title:'48-Pixel Sprite'},
{id:'examples/tinyfonts2.a', chapter:23, name:'Tiny Text'},
{id:'examples/score6.a', chapter:24, name:'6-Digit Score'},
{id:'examples/retrigger.a', chapter:26, name:'Sprite Formations'},
// {id:'examples/tinyfonts.a', chapter:23, name:'Tiny Fonts, Slow'},
{id:'examples/multisprite3.a', chapter:28, name:'Multisprites'},
{id:'examples/procgen1.a', chapter:30, name:'Procedural Generation'},
{id:'examples/lines.a', chapter:31, name:'Drawing Lines'},
// {id:'examples/piatable.a', name:'Timer Table'},
{id:'examples/musicplayer.a', chapter:32, name:'Music Player'},
{id:'examples/road.a', chapter:33, name:'Pseudo 3D Road'},
{id:'examples/bankswitching.a', chapter:35, name:'Bankswitching'},
{id:'examples/wavetable.a', chapter:36, name:'Wavetable Sound'},
{id:'examples/fracpitch.a', name:'Fractional Pitch'},
{id:'examples/pal.a', name:'PAL Video Output'},
// {id:'examples/testlibrary.a', name:'VCS Library Demo'},
// {id:'examples/music2.a', name:'Pitch-Accurate Music'},
// {id:'examples/fullgame.a', name:'Thru Hike: The Game', title:'Thru Hike'},
{id:'bb/helloworld.bas', name:'Hello World (batariBASIC)'},
{id:'bb/draw.bas', name:'Playfield Draw (batariBASIC)'},
{id:'bb/sample.bas', name:'Sprite Test (batariBASIC)'},

View File

@ -213,8 +213,6 @@ export class CodeProject {
var preset_id = this.platform_id;
preset_id = preset_id.replace(/[.]\w+/,''); // remove .suffix from preset name
var webpath = "presets/" + preset_id + "/" + path;
if (this.platform_id.startsWith('vcs') && path.indexOf('.') <= 0)
webpath += ".a"; // legacy stuff
// try to GET file, use file ext to determine text/binary
this.callbackGetRemote( webpath, (data:FileData) => {
if (data == null) {

View File

@ -608,16 +608,10 @@ function _downloadCassetteFile(e) {
});
}
function fixFilename(fn : string) : string {
if (platform_id.startsWith('vcs') && fn.indexOf('.') <= 0)
fn += ".a"; // TODO: legacy stuff
return fn;
}
function _revertFile(e) {
var wnd = projectWindows.getActive();
if (wnd && wnd.setText) {
var fn = fixFilename(projectWindows.getActiveID());
var fn = projectWindows.getActiveID();
// TODO: .mame
$.get( "presets/"+getBasePlatform(platform_id)+"/"+fn, function(text) {
if (confirm("Reset '" + fn + "' to default?")) {
@ -726,7 +720,7 @@ function _downloadAllFilesZipFile(e) {
// TODO: handle binary files
store.getItem(path, (err, text) => {
if (text) {
zip.file(fixFilename(path), text);
zip.file(path, text);
}
if (++count == keys.length) {
zip.generateAsync({type:"blob"}).then( (content) => {
@ -1534,6 +1528,11 @@ function startPlatform() {
qs['file'] = lastid || PRESETS[0].id;
replaceURLState();
}
// legacy vcs stuff
if (platform_id == 'vcs' && qs['file'].startsWith('examples/') && !qs['file'].endsWith('.a')) {
qs['file'] += '.a';
replaceURLState();
}
// start platform and load file
platform.start();
loadBIOSFromProject();
@ -1612,7 +1611,7 @@ function loadImportedURL(url : string) {
export function startUI(loadplatform : boolean) {
installErrorHandler();
// add default platform?
platform_id = qs['platform'] || localStorage.getItem("__lastplatform");
platform_id = qs['platform'] || (hasLocalStorage && localStorage.getItem("__lastplatform"));
if (!platform_id) {
platform_id = qs['platform'] = "vcs";
}
@ -1633,6 +1632,8 @@ export function startUI(loadplatform : boolean) {
loadImportedURL(qs['importURL']);
return;
}
// is vcs? convert legacy stuff
convertLegacyVCS(store);
// load and start platform object
if (loadplatform) {
loadAndStartPlatform();
@ -1648,8 +1649,26 @@ function loadAndStartPlatform() {
console.log("loaded platform", platform_id);
startPlatform();
showWelcomeMessage();
document.title = document.title + " [" + platform_id + "] - " + (('['+repo_id+'] - ')||'') + current_project.mainPath;
document.title = document.title + " [" + platform_id + "] - " + (repo_id?('['+repo_id+'] - '):'') + current_project.mainPath;
}, () => {
alert('Platform "' + platform_id + '" not supported.');
});
}
// TODO: remove eventually
function convertLegacyVCS(store) {
if (platform_id == 'vcs' && hasLocalStorage && !localStorage.getItem("__migratevcs")) {
store.keys().then((keys:string[]) => {
keys.forEach((key) => {
if (key.startsWith('examples/') && !key.endsWith('.a')) {
store.getItem(key).then( (val) => {
if (val) {
return store.setItem(key+'.a', val);
}
});
}
});
localStorage.setItem("__migratevcs", "1");
})
}
}

View File

@ -95,6 +95,7 @@ describe('Store', function() {
it('Should bind paths to Github', function(done) {
var store = mstore.createNewPersistentStore(test_platform_id, function(store) {
var gh = newGH(store);
localStorage.removeItem('__repos');
var sess = {repopath:'foo/bar', url:'_'};
gh.bind(sess, true);
assert.deepEqual(gh.getRepos(), {'foo/bar':'_'});