Page 1 of 1
Proof of concept: Programming the NES with blocks
Posted: Sun Dec 23, 2018 10:08 am
by orlaisadog
I haven't posted on here in ages, but I made a proof of concept for programming the NES in a Scratch-like language. I ported the "hello world" project from
this tutorial to it. I noticed that
this Scratch clone has something called "Codification" so it can compile the script into any language, including C, so I made it compile to cc65-compatible code. It really is any language because it's completely customisable, and it could be tweaked to compile into assembly language, but for now, I made it use C.
To try it you need to
download this file, then go to
this link and press the button that looks like a piece of paper, then "Import" and then import the .xml file. You can change the script if you want then click the script to compile it to C, which is shown in the variable on the right. You can right click it and press "export" to save it. Download
this template and replace the contents of "hello.c" with the generated program, and compile it.
This might be a good way to introduce people to NES programming or even quickly test out concepts if you're used to languages like Scratch.
Re: Proof of concept: Programming the NES with blocks
Posted: Sun Dec 23, 2018 11:12 am
by tokumaru
This is pretty cool. I recently started using Scratch for coding games with the kids I teach and was very impressed at how quickly it's possible to put a game together. I immediately wondered if something like that would work on the NES.
I feel like what makes Scratch good for games is the way it's able to move objects around. Programming movement is incredibly simple, and I think that's an important aspect to carry over to the NES for this to work well. The event system is pretty handy too.
Re: Proof of concept: Programming the NES with blocks
Posted: Sun Dec 23, 2018 11:25 am
by orlaisadog
I use Scratch, and I really need to move on, but I'm really good at it now. I can do basic 3D.
Also, I'm working on an assembly language version of this now.
Edit: Wait, are you a teacher?
Re: Proof of concept: Programming the NES with blocks
Posted: Sun Dec 23, 2018 12:46 pm
by orlaisadog
I'm making progress with the assembly version
Re: Proof of concept: Programming the NES with blocks
Posted: Sun Dec 23, 2018 2:34 pm
by nesrocks
This seems like a great way to make sure your program is structurally sound. Very interesting.
Re: Proof of concept: Programming the NES with blocks
Posted: Sun Dec 23, 2018 2:36 pm
by orlaisadog
Is ASM6 a good choice for the assembler?
Re: Proof of concept: Programming the NES with blocks
Posted: Sun Dec 23, 2018 2:37 pm
by orlaisadog
By the way, the labels don't need to wrap around the script but it's easier to organise things that way.
Re: Proof of concept: Programming the NES with blocks
Posted: Sun Dec 23, 2018 2:40 pm
by orlaisadog
tokumaru wrote:The event system is pretty handy too.
Do you mean the hat blocks? They would be hard because it's single threaded
Re: Proof of concept: Programming the NES with blocks
Posted: Sun Dec 23, 2018 3:27 pm
by tokumaru
orlaisadog wrote:Wait, are you a teacher?
Currently, yeah.
orlaisadog wrote:Is ASM6 a good choice for the assembler?
If you're editing everything with blocks I don't think that the underlying assembler matters much... As long as the complete toolchain allows you to go from blocks to binary, everything should be fine.
orlaisadog wrote:Do you mean the hat blocks? They would be hard because it's single threaded
Well, so is Scratch... "Threads" in Scratch are run sequentially, with the interpreter controlling when each script starts and stops. I think that a proper NES version of scratch also needs to be able to manage threads, otherwise most of the benefits are lost.
As I see it, the biggest benefit of using Scratch is not that it replaces typing with draggable blocks, but that it manages objects mostly automatically, so you don't have to bother with every little detail. You just describe the behavior of each object, very linearly, and the interpreter takes care of updating everything in parallel.
Re: Proof of concept: Programming the NES with blocks
Posted: Sun Dec 23, 2018 3:35 pm
by orlaisadog
An interpreter would be too slow
Re: Proof of concept: Programming the NES with blocks
Posted: Sun Dec 23, 2018 3:36 pm
by orlaisadog
The problem is that is isn't written from scratch (get it?) so I don't have much control over how it works
Re: Proof of concept: Programming the NES with blocks
Posted: Sun Dec 23, 2018 4:27 pm
by tokumaru
I get that this is just a proof of concept, but for something like this to be really useful for NES programming it has to do more than just create linear programs with blocks, otherwise it's just more annoying than simply typing.
I don't think an interpreter would be to slow if only a handful of scripts are running at any given time, but I guess it should be possible to compile to pseudo-threads too, if the points where the scripts yield was hardcoded.
Re: Proof of concept: Programming the NES with blocks
Posted: Mon Dec 24, 2018 1:59 am
by orlaisadog
I'll try to add psuedo-threading if you think it would be useful, but I originally thought of it being an easier way to use an assembler so I wouldn't have type so much or to remember opcodes.
Re: Proof of concept: Programming the NES with blocks
Posted: Mon Dec 24, 2018 2:12 am
by orlaisadog
Maybe I could get more control if I use Blockly
Edit: It might be too hard though:
Creating a new language generator for Blockly is a fairly large undertaking, and with that in mind the documentation doesn't seem to offer much in terms of help with creating one.
Re: Proof of concept: Programming the NES with blocks
Posted: Mon Dec 24, 2018 7:00 am
by orlaisadog
Multithreading could work like this