It is currently Mon Jul 22, 2019 10:39 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Sun Dec 23, 2018 10:08 am 
Offline
User avatar

Joined: Thu May 31, 2018 11:12 am
Posts: 167
Location: Bristol, England
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 3889 times ]
File comment: Just in case the Dropbox link stops working
NES.xml [38.39 KiB]
Downloaded 70 times
Top
 Profile  
 
PostPosted: Sun Dec 23, 2018 11:12 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11376
Location: Rio de Janeiro - Brazil
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.


Top
 Profile  
 
PostPosted: Sun Dec 23, 2018 11:25 am 
Offline
User avatar

Joined: Thu May 31, 2018 11:12 am
Posts: 167
Location: Bristol, England
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 3870 times ]
Top
 Profile  
 
PostPosted: Sun Dec 23, 2018 12:46 pm 
Offline
User avatar

Joined: Thu May 31, 2018 11:12 am
Posts: 167
Location: Bristol, England
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 3847 times ]
Top
 Profile  
 
PostPosted: Sun Dec 23, 2018 2:34 pm 
Offline
User avatar

Joined: Thu Aug 13, 2015 4:40 pm
Posts: 411
Location: Rio de Janeiro - Brazil
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!


Top
 Profile  
 
PostPosted: Sun Dec 23, 2018 2:36 pm 
Offline
User avatar

Joined: Thu May 31, 2018 11:12 am
Posts: 167
Location: Bristol, England
Is ASM6 a good choice for the assembler?


Top
 Profile  
 
PostPosted: Sun Dec 23, 2018 2:37 pm 
Offline
User avatar

Joined: Thu May 31, 2018 11:12 am
Posts: 167
Location: Bristol, England
By the way, the labels don't need to wrap around the script but it's easier to organise things that way.


Top
 Profile  
 
PostPosted: Sun Dec 23, 2018 2:40 pm 
Offline
User avatar

Joined: Thu May 31, 2018 11:12 am
Posts: 167
Location: Bristol, England
tokumaru wrote:
The event system is pretty handy too.

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


Top
 Profile  
 
PostPosted: Sun Dec 23, 2018 3:27 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11376
Location: Rio de Janeiro - Brazil
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.


Top
 Profile  
 
PostPosted: Sun Dec 23, 2018 3:35 pm 
Offline
User avatar

Joined: Thu May 31, 2018 11:12 am
Posts: 167
Location: Bristol, England
An interpreter would be too slow


Top
 Profile  
 
PostPosted: Sun Dec 23, 2018 3:36 pm 
Offline
User avatar

Joined: Thu May 31, 2018 11:12 am
Posts: 167
Location: Bristol, England
The problem is that is isn't written from scratch (get it?) so I don't have much control over how it works


Top
 Profile  
 
PostPosted: Sun Dec 23, 2018 4:27 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11376
Location: Rio de Janeiro - Brazil
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.


Top
 Profile  
 
PostPosted: Mon Dec 24, 2018 1:59 am 
Offline
User avatar

Joined: Thu May 31, 2018 11:12 am
Posts: 167
Location: Bristol, England
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.


Top
 Profile  
 
PostPosted: Mon Dec 24, 2018 2:12 am 
Offline
User avatar

Joined: Thu May 31, 2018 11:12 am
Posts: 167
Location: Bristol, England
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.


Top
 Profile  
 
PostPosted: Mon Dec 24, 2018 7:00 am 
Offline
User avatar

Joined: Thu May 31, 2018 11:12 am
Posts: 167
Location: Bristol, England
Multithreading could work like this


Attachments:
multi.PNG
multi.PNG [ 55.48 KiB | Viewed 3663 times ]
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group