mappum / DCPU-16

:floppy_disk: A javascript emulator for DCPU-16 (the computer system in Mojang's new game, 0x10c). Works in browsers and Node.
http://mappum.github.com/DCPU-16/
94 stars 18 forks source link

JSLint of CPU source (and a small bug fix) #24

Closed stevegeek closed 12 years ago

stevegeek commented 12 years ago

Hey if you are interested here is a JSLint of the DCPU source. It significantly changes the code so if you are interested then I recommend you pull as soon as you can be bothered as otherwise you will have a merge nightmare on your hands.

JSLint is slightly annoying and draconian but it enforces some good practices, helps find numerous bugs, and helps ensure a common code style throughout the project.

There is also a fix to the end() method which was referencing and old property name.

Later I might do some optimisation and introduce the underscore library to simplify the code a bit, but depends on time of course!

mappum commented 12 years ago

It has changed since you linted it, so I'll just lint it myself. Thanks for the suggestion, I do trust Douglas Crockford's JS better than my own.

mappum commented 12 years ago

Nevermind, I thought it auto-fixed the problems. I'll just fix the conflicts from yours (they aren't big).

stevegeek commented 12 years ago

Ok well if you decide not to use this in the end, then note that JSLint will warn about calling parseInt without a base parameter. Since I suppose values in the DCPU ASM can be in hex, octal or decimal I wrote a little function called parseLiteral() to appropriately call parseInt() depending on the input string.

Edit: It is basically untested. Time for qunit :)

mappum commented 12 years ago

Pulled, thanks.

stevegeek commented 12 years ago

Ah ok cool