It is currently Wed Oct 18, 2017 4:28 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: NES Multithreading Demo
PostPosted: Tue Mar 28, 2006 10:48 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
I wrote a simple demo of how to support multiple threads on the NES, both cooperative and pre-emptive. The latter are implemented using the APU's 60 Hz interrupt, and another version using the DMC interrupt running at 4000 times per second for finer switching granularity. Source is generously commented and assembles with NESASM. It has been tested on my NES.

nes_threads.zip

The cooperative version could be implemented on modern architectures without much difficulty. Using it an emulator could simplify things a lot.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 29, 2006 1:59 am 
Offline
User avatar

Joined: Sun Mar 19, 2006 3:06 am
Posts: 583
Location: Gothenburg/Sweden
Multithreading on a NES? This is cool stuff. What's next? A multi-threaded operating system? :)
(Hm well, that'd be cool for developing.. :))


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 29, 2006 2:41 am 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
The people over on the 6502.org forum discuss operating system implementation on the 65xxx series. Some are pretty hard-core about it. I think Solomon's Key might use some kind of multithreading, or at least a prioritization scheme for giving time to enemy objects. On some rooms the enemies go slower when there are lots of them, but the game speed never changes.

One thing to remember is that the main benefit of multithreading is the ability to write some kinds of code in a clearer way. It's all about which execution structure is most straightforward. The message-based scheme has objects responding to inputs via subroutine calls, while a multithreaded scheme gives each object its own thread from which it actively checks for things and responds to them.

It generally doesn't work very well to give every on-screen object its own thread, but it can help to have two or three threads in a program, each performing specific tasks. An interesting example would be a thread doing some lengthy calculation over the span of multiple frames during whatever free time there was. Using a pre-emptive thread would allow it to be written without constant checks for "is it time to go to sleep yet".


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: FrankenGraphics, Google Adsense [Bot] and 11 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