nesdev.com
http://forums.nesdev.com/

Proof of concept: Programming the NES with blocks
http://forums.nesdev.com/viewtopic.php?f=2&t=18173
Page 1 of 1

Author:  orlaisadog [ Sun Dec 23, 2018 10:08 am ]
Post subject:  Proof of concept: Programming the NES with blocks

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:
File comment: Hello World script
nes.png
nes.png [ 44.12 KiB | Viewed 4322 times ]
File comment: Just in case the Dropbox link stops working
NES.xml [38.39 KiB]
Downloaded 85 times

Author:  tokumaru [ Sun Dec 23, 2018 11:12 am ]
Post subject:  Re: Proof of concept: Programming the NES with blocks

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.

Author:  orlaisadog [ Sun Dec 23, 2018 11:25 am ]
Post subject:  Re: Proof of concept: Programming the NES with blocks

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 4303 times ]

Author:  orlaisadog [ Sun Dec 23, 2018 12:46 pm ]
Post subject:  Re: Proof of concept: Programming the NES with blocks

I'm making progress with the assembly version

Attachments:
File comment: This compiles through ASM6 to the Nerdy Nights Week 3 program
anothersnip.PNG
anothersnip.PNG [ 66.54 KiB | Viewed 4280 times ]

Author:  nesrocks [ Sun Dec 23, 2018 2:34 pm ]
Post subject:  Re: Proof of concept: Programming the NES with blocks

This seems like a great way to make sure your program is structurally sound. Very interesting.

Author:  orlaisadog [ Sun Dec 23, 2018 2:36 pm ]
Post subject:  Re: Proof of concept: Programming the NES with blocks

Is ASM6 a good choice for the assembler?

Author:  orlaisadog [ Sun Dec 23, 2018 2:37 pm ]
Post subject:  Re: Proof of concept: Programming the NES with blocks

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

Author:  orlaisadog [ Sun Dec 23, 2018 2:40 pm ]
Post subject:  Re: Proof of concept: Programming the NES with blocks

tokumaru wrote:
The event system is pretty handy too.

Do you mean the hat blocks? They would be hard because it's single threaded

Author:  tokumaru [ Sun Dec 23, 2018 3:27 pm ]
Post subject:  Re: Proof of concept: Programming the NES with blocks

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.

Author:  orlaisadog [ Sun Dec 23, 2018 3:35 pm ]
Post subject:  Re: Proof of concept: Programming the NES with blocks

An interpreter would be too slow

Author:  orlaisadog [ Sun Dec 23, 2018 3:36 pm ]
Post subject:  Re: Proof of concept: Programming the NES with blocks

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

Author:  tokumaru [ Sun Dec 23, 2018 4:27 pm ]
Post subject:  Re: Proof of concept: Programming the NES with blocks

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.

Author:  orlaisadog [ Mon Dec 24, 2018 1:59 am ]
Post subject:  Re: Proof of concept: Programming the NES with blocks

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.

Author:  orlaisadog [ Mon Dec 24, 2018 2:12 am ]
Post subject:  Re: Proof of concept: Programming the NES with blocks

Maybe I could get more control if I use Blockly
Edit: It might be too hard though:
Quote:
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.

Author:  orlaisadog [ Mon Dec 24, 2018 7:00 am ]
Post subject:  Re: Proof of concept: Programming the NES with blocks

Multithreading could work like this

Attachments:
multi.PNG
multi.PNG [ 55.48 KiB | Viewed 4096 times ]

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/