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

Started by
4 comments, last by tom_mai78101 12 years ago
DhmFp.png

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.
Advertisement
This is madness!
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.

throw table_exception("(? ???)? ? ???");

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).
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.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.


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.

This topic is closed to new replies.

Advertisement