Skip to main content

News

Topic: Cellscript for Sphere 1.x games (Read 5149 times) previous topic - next topic

0 Members and 2 Guests are viewing this topic.
  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Cellscript for Sphere 1.x games
Here's a Cellscript that will compile most Sphere 1.x games and allow use of ES6 syntax.  Save the code below as Cellscript.mjs in the root of the game directory and enter cell from the command line.  That's it!

Code: (javascript) [Select]
/**
 *  Cellscript for Sphere v1 Migration
 *  (c) 2017 Fat Cerberus
 *
 *  save this as `Cellscript.mjs` in the root of your Sphere project, and you're
 *  ready to start taking advantage of everything the Sphere v2 toolchain has to
 *  offer!
 *
**/

import { transpile } from 'cell-runtime';

// any metadata defined here is written to game.json and is available to game
// code through `Sphere.Game`.
Object.assign(Sphere.Game,
{
name: "Game Title",
version: 1,  // Sphere v1 compatibility
author: "Some Guy",
summary: "This game probably sucks.",
resolution: '320x240',
main: 'scripts/main.js',
});

// Duktape doesn't support ES2015 syntax yet so we need to transpile if we want
// access to those features.
transpile('@/scripts', files('scripts/*.js', true));

// this should cover everything needed to run the majority of Sphere v1 games.
install('@/animations',   files('animations/*.mng', true));
install('@/fonts',        files('fonts/*.rfn', true));
install('@/images',       files('images/*.bmp', true));
install('@/images',       files('images/*.jpg', true));
install('@/images',       files('images/*.png', true));
install('@/maps',         files('maps/*.rmp', true));
install('@/maps',         files('maps/*.rts', true));
install('@/sounds',       files('sounds/*.wav', true));
install('@/sounds',       files('sounds/*.ogg', true));
install('@/sounds',       files('sounds/*.mp3', true));
install('@/sounds',       files('sounds/*.flac', true));
install('@/sounds',       files('sounds/*.it', true));
install('@/sounds',       files('sounds/*.xm', true));
install('@/sounds',       files('sounds/*.s3m', true));
install('@/spritesets',   files('spritesets/*.rss', true));
install('@/windowstyles', files('windowstyles/*.rws', true));
install('@/',             files('icon.png'));
  • Last Edit: August 10, 2017, 02:33:24 am by Fat Cerberus
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Cellscript for Sphere 1.x games
Reply #1
Also: cell -p gamepak.spk to make an SPK.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Cellscript for Sphere 1.x games
Reply #2
The above Cellscript even works to compile frigging Kefka's Revenge and the compiled SPK package runs perfectly* afterwards.  Sometimes my level of commitment to backwards compatibility amazes even me.  Yep, just going to stand here and keep being awesome.  8)

* "Perfectly" must be understood to be a relative term in this context, this being Kefka's Revenge and all... :P
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
Re: Cellscript for Sphere 1.x games
Reply #3
Nice stuff! Will you include this with a template project in miniSphere? Seems like a good idea to get people started, even without an editor. :)

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Cellscript for Sphere 1.x games
Reply #4
The ideal state I'd like to get to would be where it's possible to develop Sphere games entirely from the command line.  Cell and SSJ get us most of the way there already; using JavaScript to control Cell builds was the best thing I ever did because it allows the compiler to be easily extended to do pretty much anything you want.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
Re: Cellscript for Sphere 1.x games
Reply #5
I suppose this could also mean conversion of eg. sprite sheets + a JSON file to rts files and the likes, as long as the work is put into that?
That sounds like an excellent way to go forward to me, as one doesn't necessarily have to rely on just one IDE.

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Cellscript for Sphere 1.x games
Reply #6

I suppose this could also mean conversion of eg. sprite sheets + a JSON file to rts files and the likes, as long as the work is put into that?
That sounds like an excellent way to go forward to me, as one doesn't necessarily have to rely on just one IDE.


Yep, that was pretty much the exact kind of thing I had in mind when I first came up with the idea of a Sphere compiler.  I felt it was more important for the miniSphere 4.4 release, though, to implement ES6 support so that we can start using classes and stuff as soon as possible, as it makes for much more readable code.  I find it a lot easier to read a properly indented class definition, for example, compared to the typical Class.prototype.method = function() {} shenanigans required pre-ES6.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Cellscript for Sphere 1.x games
Reply #7
Hm, this could actually be a niche for that majin tool that I stopped developing after it got marginalized by the Cell rewrite: Upgrading Sphere v1 games. :) How that would work is you run majin in a directory containing a game.sgm file and it does everything needed to prepare that directory for a Sphere v2 workflow, including generating a Cellscript, etc.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub