Skip to main content

News

Topic: Sphere 5.5.1 (miniSphere) (Read 412536 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • Rhuan
  • [*][*][*][*]
Re: minisphere 4.3.8
Reply #1455
You can get a second hand mac mini or macbook for fairly cheap if you just want any device that will run osx. If you're looking for a high spec machine to last for a long time then the price gets high fast though.

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • miniSphere Developer
Re: minisphere 4.3.8
Reply #1456
I just had an idea.  If I end up getting a Mac, I could compile minisphere for iOS.  Then maybe we could get Sphere into the App Store somehow.  I don't know what the process for that is, or if Apple would allow it, but it's worth looking into at least.

There shouldn't be any technical issue here anyway, Allegro supports iOS and I know several people have compiled Duktape for iOS too.
Sphere 5.5.1 - miniSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: minisphere 4.3.8
Reply #1457

I just had an idea.  If I end up getting a Mac, I could compile minisphere for iOS.  Then maybe we could get Sphere into the App Store somehow.  I don't know what the process for that is, or if Apple would allow it, but it's worth looking into at least.

There shouldn't be any technical issue here anyway, Allegro supports iOS and I know several people have compiled Duktape for iOS too.

That sounds pretty cool. I could try compiling minisphere for Android, though I have no idea what the process is like.

Also,  I noticed that if a function throws an exception that isn't caught in a try/catch,  it aborts with "script not found `scripts/main.js`" despite the fact that scripts/main.js is the main script, and said function is in a library imported via require()

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • miniSphere Developer
Re: minisphere 4.3.8
Reply #1458

Also,  I noticed that if a function throws an exception that isn't caught in a try/catch,  it aborts with "script not found `scripts/main.js`" despite the fact that scripts/main.js is the main script, and said function is in a library imported via require()


I see, it only happens in the following case (all of these must be true):

  • An error is thrown from a module which is first required, either directly or indirectly, at the top of the main script

  • The module throws an error before its corresponding require() has returned

  • There is no try-catch active to catch the error so that it crashes the game



I'll look into what causes that when I get a chance.  It is a bit odd but not really pressing to fix since it doesn't affect functionality (the game would have crashed in that case anyway).
Sphere 5.5.1 - miniSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: minisphere 4.3.8
Reply #1459
Quote
An error is thrown from a module which is first required, either directly or indirectly, at the top of the main script

I always do my requires and script imports at the beginning, in the same way that you would do (most) #includes at the beginning of a main C source file.

Quote
The module throws an error before its corresponding require() has returned

I know that if there's a try/catch block, it doesn't have any issue. That was the idea. But the problem isn't that it throws an error but that said exception causes it to think that the main script doesn't exist, rather than giving information about where the exception was thrown.
Does a module have to return true (or false on failure) at the very end of the script?


Also also, is it possible to force a script/module to run synchronously? In my Chip's Challenge engine, it's having issues with skipping numbers, and it seems to be caused by that.

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • miniSphere Developer
Re: minisphere 4.3.8
Reply #1460
I know, I wasn't criticizing your methods, just summarizing the exact conditions that cause the bug for posterity.  I fully intend to fix it at some point. :)

Modules don't have to return anything.  The return value of require() is whatever the module assigns to module.exportsreturn statements are valid (because CommonJS modules are secretly self-executing functions), but will be ignored.

Not sure what you mean by running synchronously - require() is synchronous by definition; it only returns once the module has run to completion.  So you'll have to clarify here.
Sphere 5.5.1 - miniSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • miniSphere Developer
Re: minisphere 4.3.8
Reply #1461
Seeing as quite a few bugs have been found now in minisphere 4.3.8, and 5.0 is still a ways off, I think what I'll do is get Cell back in working order without the TypeScript, etc. support yet, and release a 4.4.0 version with the bug fixes along with some recent enhancements (I have to review the commit history to figure out what these are...), this way there won't be a broken release up for months.

edit: Here's the full changelog so far for 4.4.0:
Code: (text) [Select]
* Adds `FS.readFile()` and `FS.writeFile()` which allow reading and writing
  an entire file in a single operation.

* Improves Sphere v1 compatibility by adding several missing APIs.

* Dispatch API functions will no longer accept a JavaScript source code string
  as a callback, the callback must now always be a function.

* Improves miniRT documentation.

* Fixes a bug where the miniRT terminal can be rendered before other threads.

* Fixes a bug where `random.sample()` sometimes returns `undefined`.

* Fixes a bug where error attribution doesn't work properly if `Duktape.act()`
  is not available at the time of the error.

* Fixes a bug where `CreatePerson()` won't accept a Spriteset object.
  • Last Edit: January 09, 2017, 03:02:19 pm by Fat Cerberus
Sphere 5.5.1 - miniSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • miniSphere Developer
Re: minisphere 4.3.8
Reply #1462
Just finished implementing TypeScript support in Cell, so maybe minisphere 4.4.0 will get it after all :D

Code: [Select]

D:\src\spectacles-i>cell -bd dist
Cell X.X.X Sphere packaging compiler (x64)
the JavaScript-powered compiler for Sphere v2
(c) 2015-2017 Fat Cerberus

evaluating Cellscript.js...
processing 125 targets...
    transpile @/scripts/AIContext.js
    transpile @/scripts/Battle.js
    transpile @/scripts/BattleActor.js
    transpile @/scripts/battleAI/HeadlessHorseAI.js
    transpile @/scripts/battleAI/LumisquirrelAI.js
    transpile @/scripts/battleAI/Robert1AI.js
    transpile @/scripts/battleAI/Robert2AI.js
    transpile @/scripts/battleAI/ScottStarcrossAI.js
    transpile @/scripts/battleAI/ScottTempleAI.js
    transpile @/scripts/battleAI/VictorAI.js
    transpile @/scripts/BattleHUD.js
    transpile @/scripts/BattleScreen.js
    transpile @/scripts/BattleUnit.js
    transpile @/scripts/ConditionContext.js
    transpile @/scripts/Cutscenes.js
    transpile @/scripts/FieldMenu.js
    transpile @/scripts/gamedef/animations.js
    transpile @/scripts/gamedef/battles.js
    transpile @/scripts/gamedef/characters.js
    transpile @/scripts/gamedef/conditions.js
    transpile @/scripts/gamedef/game.js
    transpile @/scripts/gamedef/items.js
    transpile @/scripts/gamedef/maps.js
    transpile @/scripts/gamedef/math.js
    transpile @/scripts/gamedef/moveEffects.js
    transpile @/scripts/gamedef/scenes.js
    transpile @/scripts/gamedef/skills.js
    transpile @/scripts/gamedef/stats.js
    transpile @/scripts/gamedef/statuses.js
    transpile @/scripts/gamedef/text.js
    transpile @/scripts/gamedef/weapons.js
    transpile @/scripts/GameOverScreen.js
    transpile @/scripts/GrowthPopup.js
    transpile @/scripts/ItemUsable.js
    transpile @/scripts/LucidaClock.js
    transpile @/scripts/main.js
    transpile @/scripts/MapContext.js
    transpile @/scripts/maps/main.js
    transpile @/scripts/maps/Portentia.js
    transpile @/scripts/maps/Testville.js
    transpile @/scripts/MenuStrip.js
    transpile @/scripts/MoveMenu.js
    transpile @/scripts/MPGauge.js
    transpile @/scripts/MPPool.js
    transpile @/scripts/Party.js
    transpile @/scripts/PartyMember.js
    transpile @/scripts/Scrambler.js
    transpile @/scripts/Session.js
    transpile @/scripts/SkillUsable.js
    transpile @/scripts/SpecsClient.js
    transpile @/scripts/SpecsServer.js
    transpile @/scripts/SpriteImage.js
    transpile @/scripts/Stat.js
    transpile @/scripts/StatusContext.js
    transpile @/scripts/StoryManager.js
    transpile @/scripts/TargetMenu.js
    transpile @/scripts/testcases/brucesStory.js
    transpile @/scripts/testcases/lastLucidan.js
    transpile @/scripts/TestHarness.js
    transpile @/scripts/TitleScreen.js
    transpile @/scripts/TurnPreview.js
    transpile @/scripts/WeaponUsable.js
    install @/lib/kh2bar.js
    install @/lib/map/Atlas.js
    install @/lib/map/index.js
    install @/lib/map/Map.js
    install @/lib/map/ObstructionMap.js
    install @/lib/map/Person.js
    install @/lib/map/Tileset.js
    install @/images/GameOverScreen.png
    install @/images/Logos/GameLogo.png
    install @/images/Logos/TitleCard.png
    install @/images/ScottSucks.png
    install @/images/TestBattle.png
    install @/images/TitleScreen.png
    install @/maps/main.rmp
    install @/maps/Portentia.rmp
    install @/maps/Testville.rmp
    install @/maps/Portentia.rts
    install @/maps/TestvilleTiles.rts
    install @/music/Animals.ogg
    install @/music/BasicInstinct.ogg
    install @/music/BattleForLucida.ogg
    install @/music/BruceTellsHisStory.ogg
    install @/music/CreepFight.ogg
    install @/music/DeathComeNearMe.ogg
    install @/music/EndOfInnocence.ogg
    install @/music/GameOver.ogg
    install @/music/HymnOfLiberty.ogg
    install @/music/LamentForBruce.ogg
    install @/music/LucidaByNight.ogg
    install @/music/MalmagmaManor.ogg
    install @/music/ManorBoss.ogg
    install @/music/MyDreamsButADropOfFuel.ogg
    install @/music/MyDreamsButADropOfFuel2.ogg
    install @/music/OneWorldIsNotEnough.ogg
    install @/music/OurWorldCanStillBeSaved.ogg
    install @/music/Portentia.ogg
    install @/music/RiseOfThePrimus.ogg
    install @/music/RunawayTrain.ogg
    install @/music/ScottsHomecoming.ogg
    install @/music/SeasonsEnd.ogg
    install @/music/SpectaclesTheme.ogg
    install @/music/SubfloorManor.ogg
    install @/music/ThePromise.ogg
    install @/music/TheQuantumEnigma.ogg
    install @/music/TimeToLetGo.ogg
    install @/spritesets/battlers/Amanda.rss
    install @/spritesets/battlers/Bruce.rss
    install @/spritesets/battlers/Elysia.rss
    install @/spritesets/battlers/H. Horse.rss
    install @/spritesets/battlers/Justin.rss
    install @/spritesets/battlers/Katelyn.rss
    install @/spritesets/battlers/Lauren.rss
    install @/spritesets/battlers/Lumisquirrel.rss
    install @/spritesets/battlers/maggie.rss
    install @/spritesets/battlers/maggie_hippo.rss
    install @/spritesets/battlers/Robert.rss
    install @/spritesets/battlers/Scott T.rss
    install @/spritesets/battlers/Scott.rss
    install @/spritesets/battlers/Victor.rss
    install @/spritesets/battlers/Xemnas.rss
    install @/spritesets/invisible.rss
    install @/sounds/Munch.wav
    install @/icon.png
writing game.json... OK.
Sphere 5.5.1 - miniSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • miniSphere Developer
Re: minisphere 4.3.8
Reply #1463

Also,  I noticed that if a function throws an exception that isn't caught in a try/catch, it aborts with "script not found `scripts/main.js`" despite the fact that scripts/main.js is the main script, and said function is in a library imported via require()


So I just looked into this bug.  By any chance do you happen to be throwing something which is not an instance of the JS Error class (or a subtype)?  If so I think I found the cause of the bug.  It's here:
https://github.com/fatcerberus/minisphere/blob/master/src/engine/script.c#L75-L76

When a script crashes, the script executor checks to see if there's an error on top of the Duktape stack, and if there isn't it pushes a generic "script not found" one (because it assumes that the script didn't run at all).  Trouble is, in JS, you can throw things that aren't Errors (for example, strings--something Sphere v1 code does a lot).  So the check is incorrect.  I'll need to refactor the script executor a bit to fix it, but it shouldn't be overly difficult.
Sphere 5.5.1 - miniSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • miniSphere Developer
Re: minisphere 4.3.8
Reply #1464
I switched out TypeScript for Babel.  It turns out that, when run under Duktape with type checking turned on and a default type definition file (lib.d.ts), TypeScript compilation is SLOW.  That wouldn't be so bad by itself--Cell will only rebuild changed files--however with TypeScript all scripts have to be passed to the compiler simultaneously for types to work properly across files.  This means that even changing one file causes your entire game to be recompiled.  For a large game such as my own Spectacles, that comes out to several minutes worth of compilation.  Not nice.

I suspect that most people using the transpile() function in Cell would only be looking for ES6 syntax support anyway, and Babel works well for that.  It's also much less painful; scripts are parsed as ES6 modules, so the transpiler doesn't need to see the complete program upfront.  Each script is recompiled only when it changes.

Next order of business: Source map support.  When using a transpile step, the line numbers sometimes end up being way off under SSJ Blue (command-line SSJ is not an issue since it pulls the already transpiled source directly from the engine).
Sphere 5.5.1 - miniSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • miniSphere Developer
Re: minisphere 4.3.8
Reply #1465
I went the extra mile and added a Babel polyfill to the latest build of minisphere.  This allows game code to use new stuff like Map and Set.  So now, in combination with a Cellscript using the transpile module, minisphere can be a full ES6 environment :))
Sphere 5.5.1 - miniSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: minisphere 4.3.8
Reply #1466
In regards to the synchonous issue, I'm trying to figure out why it seems to be skipping numbers. If I replace system.sleep with GetKey, it only responds after 6 keypresses but still processes the n++ after every keypresse (so it displays 6,12,18,etc)
Code: [Select]

for(n = 0; n <999; n++) {
font.drawText(0,0,n);
//drawNumber(n,numbers_pos[0].x, numbers_pos[0].y);
screen.flip();
system.sleep(60);
}

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • miniSphere Developer
Re: minisphere 4.3.8
Reply #1467
system.sleep() behavior changed in minisphere 4.3 - it now runs an update-render loop (because otherwise the frame count is meaningless).  Therefore if you have no render jobs set up using the Dispatch API, the screen will go blank (this is implied in the API documentation, but should be made clearer).  If you change it to Delay(1000); it works as expected.  Generally Sphere v2 code should use the Dispatch API (or the threads module, which wraps it).  Synchronous code should stick to the Sphere v1 API.

The bug of only updating every 6 numbers isn't with GetKey() by the way.  Changing to Delay() shows the same behavior: it goes 0, 6, 12, 18, etc.  It works properly if you change screen.flip() to FlipScreen().  So that's kind of weird and I'll have to look into it.
Sphere 5.5.1 - miniSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: minisphere 4.3.8
Reply #1468
Yeah, there are some discrepancies between functions in the new API and the equivalent function from the old API.
And I didn't know about Delay()

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • miniSphere Developer
Re: minisphere 4.3.8
Reply #1469
I think the problem might be that screen.frameRate is set to 60 by default.  So minisphere tries to maintain 60fps but skips a bunch of frames because you stuck a 1s delay in there.  It's hardcoded not to skip more than 5 frames though, hence the 0->6->12 pattern.  FlipScreen is unthrottled by default (for compatibility reasons), so no frames get skipped.

You'd probably see the same behavior with Sphere 1.5 if you call SetFrameRate(60) first and do the delay manually.  In fact it might even be worse because Sphere 1.5 is programmed to skip up to 20 frames (!).

tl;dr: Your for loop works properly, but not all the frames are rendered.
Sphere 5.5.1 - miniSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub