Proof of concept: Programming the NES with blocks

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Proof of concept: Programming the NES with blocks

Post by orlaisadog » Sun Dec 23, 2018 10:08 am

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.
Attachments
Hello World script
Hello World script
nes.png (44.12 KiB) Viewed 4792 times
NES.xml
Just in case the Dropbox link stops working
(38.39 KiB) Downloaded 100 times

User avatar
tokumaru
Posts: 11469
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Proof of concept: Programming the NES with blocks

Post by tokumaru » Sun Dec 23, 2018 11:12 am

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.

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: Proof of concept: Programming the NES with blocks

Post by orlaisadog » Sun Dec 23, 2018 11:25 am

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?
Attachments
snip3.PNG
snip3.PNG (11.63 KiB) Viewed 4773 times

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: Proof of concept: Programming the NES with blocks

Post by orlaisadog » Sun Dec 23, 2018 12:46 pm

I'm making progress with the assembly version
Attachments
This compiles through ASM6 to the Nerdy Nights Week 3 program
This compiles through ASM6 to the Nerdy Nights Week 3 program

User avatar
nesrocks
Posts: 437
Joined: Thu Aug 13, 2015 4:40 pm
Location: Rio de Janeiro - Brazil
Contact:

Re: Proof of concept: Programming the NES with blocks

Post by nesrocks » Sun Dec 23, 2018 2:34 pm

This seems like a great way to make sure your program is structurally sound. Very interesting.
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: Proof of concept: Programming the NES with blocks

Post by orlaisadog » Sun Dec 23, 2018 2:36 pm

Is ASM6 a good choice for the assembler?

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: Proof of concept: Programming the NES with blocks

Post by orlaisadog » Sun Dec 23, 2018 2:37 pm

By the way, the labels don't need to wrap around the script but it's easier to organise things that way.

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: Proof of concept: Programming the NES with blocks

Post by orlaisadog » Sun Dec 23, 2018 2:40 pm

tokumaru wrote:The event system is pretty handy too.
Do you mean the hat blocks? They would be hard because it's single threaded

User avatar
tokumaru
Posts: 11469
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Proof of concept: Programming the NES with blocks

Post by tokumaru » Sun Dec 23, 2018 3:27 pm

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.

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: Proof of concept: Programming the NES with blocks

Post by orlaisadog » Sun Dec 23, 2018 3:35 pm

An interpreter would be too slow

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: Proof of concept: Programming the NES with blocks

Post by orlaisadog » Sun Dec 23, 2018 3:36 pm

The problem is that is isn't written from scratch (get it?) so I don't have much control over how it works

User avatar
tokumaru
Posts: 11469
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Proof of concept: Programming the NES with blocks

Post by tokumaru » Sun Dec 23, 2018 4:27 pm

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.

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: Proof of concept: Programming the NES with blocks

Post by orlaisadog » Mon Dec 24, 2018 1:59 am

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.

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: Proof of concept: Programming the NES with blocks

Post by orlaisadog » Mon Dec 24, 2018 2:12 am

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.

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: Proof of concept: Programming the NES with blocks

Post by orlaisadog » Mon Dec 24, 2018 7:00 am

Multithreading could work like this
Attachments
multi.PNG

Post Reply