Jump to content

  • Log In with Google      Sign In   
  • Create Account

Do you suppose this is an efficient way of writing assembly only in Java?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 tom_mai78101   Members   -  Reputation: 572

Like
2Likes
Like

Posted 19 March 2012 - 11:32 AM

Posted Image

EDIT: Added a mirror in case Imgur is down.

This is an image posted by the one and only famous "notch" of the Minecraft game.

It's interesting that he's implementing a new variant of 6502 CPU in Java. Suppose you are writing a game that requires a complex CPU as a core gameplay, when you write something like this, do you consider it to be efficient, given that it has to be implemented in a high level programming language?

To me, I haven't seen a method to create a programmable CPU assembly instructions in pure Java sense, until now. This brings up a whole new, and most direct, approach to this.

And other than being efficient or not, what is your point of view in regards to implementing a small complex CPU (like redstone circuitry in Minecraft) in a game?

Thanks in advance.

Sponsor:

#2 Madhed   Crossbones+   -  Reputation: 2994

Like
2Likes
Like

Posted 19 March 2012 - 11:37 AM

This is madness!

#3 Ravyne   GDNet+   -  Reputation: 7498

Like
0Likes
Like

Posted 19 March 2012 - 12:11 PM

This is basically the classic approach to emulators -- a huge switch statement full of op-codes, so nothing new there.

Programming games with simplified processors are neat, but the audience is inherently more limited the more complex the CPU is -- RoboRally is a good example of a simple "processor" with a very limited and application-specific command set, almost anyone can approach it. On the other hand, there are games that use more-complex, free-form programming which only programmers can really approach -- I recall one where you were basically programming a little robot tank to battle other tanks. In the tank game, you had a fairly general-purpose CPU, and you could move, turn the turret, control the radar's sweep and distance, etc by writing bytes into the right registers/memory locations. There was also a simple serial communication channels so that multiple robots could communicate.

Programming games appeal to a limited set of people and most of those quickly find "real programming" more interesting, so the appeal is usually fleeting. Other than that, I can't think of much use for a full-blown CPU simulator.

That said, I've often thought about creating a soft-console that provided a set of capabilities and a programming model similar to early (8 and 16-bit) consoles, which would certainly employ a general-purpose CPU of some kind.

#4 Net Gnome   Members   -  Reputation: 769

Like
0Likes
Like

Posted 19 March 2012 - 12:11 PM

It depends what you're trying to accomplish. Are you trying to make an Exact emulator or a Good Enough emulator? Good Enoughs are usually "simple" compared to the Exact implementations, which usually require several magnitudes of processing power to replicate in logic, peculularities, and sometimes flaws (see BSnes [i think] as an example, it requires at least a 3.2 Ghz CPU to emulate the SNES hardware exactly despite the original HW was in low Mhz range). So essentially, no emulator is effecient, its just how fast do you need it to run, and what compromises are you going to make?

Otherwise, most emulators are kinda what notch is showing, a method to interpret and execute assembly or microcode in a form like the original. But that is just the "easy" part. When it comes to core-timing, unique features, etc. it gets alot more messy, especially if you're trying for complete emulation, where you MUST implement it logically correct, not via a short cut.

Ultimately, in a game, it comes down to: what do you want the player to do, then limit them to that. Giving them basic logic building blocks that can be combined together appears to work the best (ala Minecraft and Dwarf Fortress).

#5 mhagain   Crossbones+   -  Reputation: 8005

Like
0Likes
Like

Posted 19 March 2012 - 12:13 PM

Writing assembly in Java is like - oh, I dunno - making pizza out of bricks or something.

I'm sure that the Minecraft guys had a valid reason for doing what they did here, but seriously - this is one of those "do NOT do it unless you absolutely know that you need it and unless you absolutely know EXACTLY what you are doing" things.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#6 tom_mai78101   Members   -  Reputation: 572

Like
0Likes
Like

Posted 24 March 2012 - 02:04 AM

I'm sure that the Minecraft guys had a valid reason for doing what they did here, but seriously - this is one of those "do NOT do it unless you absolutely know that you need it and unless you absolutely know EXACTLY what you are doing" things.


This is exactly what creators of emulators have in mind.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS