Monday, September 16, 2013

Some love for ZeroBrane Studio

I’d like to say that having a fast Lua debugger and IDE (specifically ZeroBrane Studio, ZBS from now on) - has been a benefit for LuaZ80.

Up till now, I’ve used the command line and a tiny Z80 single step debugger I wrote. However, having a Lua debugger has allowed me to debug stuff that I didn’t even realise was broken - or would have taken longer to figure out in other ways. Whereas I always use a debugger in C++ and C, generally I use a lot of print statements in dynamic programming languages like Python and Lua. But I’ve realised how much help a good debugger is for Lua.

Over the weekend I came across the ZBS remote console (and I had read about it as a feature … but never used it). So, whilst you are debugging, the local console (which can be used to test bits of Lua or poke ZBS itself) becomes a remote console that’s an interactive session with your Lua program you are debugging - so you can check variables (which you can view with the watch or stack view as well), run functions in your program, define new stuff, or whatever you want.

I also want to play with the Live Coding feature

For LuaZ80, the Lua code that implements the actual Z80 microprocessor instructions is created piecemeal a line or two at a time and assembled into a table then converted (joined together) into a string with table.concat. All of the fragments are in the same file (lua_z80.lua) based on the operation of original Z80 instructions. The string we then 'compile’/‘process’ with load() to make a function to call that we can call when we reach that Z80 address to run a few Z80 instructions.

Obviously it’s a bit of a problem debugging the code fragments that implement the Z80 because they don’t live in a fixed file. Previously I was using my Z80 single step debugger to view the affects, view the Lua code and guess why the fragment was broken. However with ZBS, using editor.autoactivate = true in my preference file allows me to single step debug this code in a ‘magically created’ file in ZBS.

ZBS is written in Lua (wxLua, wxWidgets, Lua and LuaJIT libraries excluded) which seems a bonus if YOU are coding in Lua - either all Lua or as a small part of your main program (e.g. data load format or script extension language). Did I mention it integrates and debugs external projects very well?

Paul, the author, is also extremely responsive to feedback, and as an open source project it’s great!

As a side note, I’m a bit of fan of Eclipse (several other Java-based IDEs are available) and use PyDev extension for Python work, and CDT for some C++ work. And I’ve also used LDT, which is nice as well. My main problem with LDT is debugging is, for some reason, incredibly slow: running in the debugger takes forever - over five minutes to run (in the debugger) a piece of unit test code on one project that takes a fraction of a second in ZBS - both on Mac OS X and on Win7. (I could complain about the stability of Eclipse with extensions but hey, it’s free and very powerful, so I really have no right to complain). As an active user of Eclipse, Visual Studio and Xcode, ZBS is an amazing piece of work that compares very favourably with the big players.

So, yay for ZeroBrane Studio!

Sunday, September 08, 2013

LuaZ80 goes public (and Open Source)

Finally, a couple of months after my holiday (where most of it was written - although I started a couple of weeks before), I've got to the stage where I feel confident enough to publish my LuaZ80 project to the world, incomplete as it is.

Or rather I've got to the stage where I realise I need to push it out, because otherwise it will stay on my hard drive forever.

So what does it do? Well, it emulates a Z80 microprocessor (that was in the ZX80, ZX81, ZX Spectrum, Amstrad CPC 464, TRS-80 Model 1 (and several other home computers), as well as arcade games and may other things.

But rather than being a simple 'read-decode-execute' type emulator, it recompiles Z80 into Lua and executes that in Lua, a dynamic programming language.

Obviously it's been inspired (but shares no technical ideas or code from) jslinux. (Running Linux on a virtual x86 and virtual hardware all emulated in javascript is seriously cool.)

Anyway, you can get more information from here:
And the code from github:

Newer›  ‹Older