ERROR!!!
Slow-mo delay (ms):
program counter (PC):
instruction register (I):
accumulator (AC):
memory address register (M):
data register (Z):
sound channels:
registers:
rom space ( to ):
choose rom file or enter code to start...
What Is NesNoise?
NesNoise is a 16-bit bytecode-based (meaning it is not an accurate emulator of anything) music machine, designed to sound somewhat like the Nintendo Entertainment System.
You enter instructions in binary, and the instructions play a part in making different sounds.
It is internally based on HTML5/JS. Nothing you enter is stored anywhere, as the whole project runs entirely in the browser.
The computer-like interface has no RAM, but it has 16 registers, and a memory adress register intended to read values from ROM.
It has 4 sound channels - Square A (SQA), Square B (SQB), Triangle (TRI), and White Noise (FUZ), which has a variable sample rate.
All values in the uploaded ROMs are little-endian, but are converted to a normal JavaScript integer, and the textbox input is big-endian, to conform with JavaScript integers.
What are these instructions you speak of?
These instructions are 8-bit, meaning the upper byte is completely ignored.
Here is the official table of instructions, ommitting the upper byte:
0x | 1x | 2x | 3x | 4x | 5x | 6x | 7x | 8x | 9x | Ax | Bx | Cx | Dx | Ex | Fx | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x0 | NOP | ACSET REG0 | REGSET 0, Z | REGSET 0, AC | ACSET MEM | JMPEQ AC, Z, MEM | ADD AC, Z | ADD AC, MEM | SQAFREQ AC | |||||||
x1 | ACSET REG1 | REGSET 1, Z | REGSET 1, AC | JMPNEQ AC, Z, MEM | SUB AC, Z | SUB AC, MEM | SQAVOL AC | |||||||||
x2 | ACSET REG2 | REGSET 2, Z | REGSET 2, AC | JMPLT AC, Z, MEM | ||||||||||||
x3 | ACSET REG3 | REGSET 3, Z | REGSET 3, AC | JMPLTE AC, Z, MEM | ||||||||||||
x4 | ACSET REG4 | REGSET 4, Z | REGSET 4, AC | JMPGT AC, Z, MEM | RSHIFT AC, Z | RSHIFT AC, MEM | SQBFREQ AC | |||||||||
x5 | ACSET REG5 | REGSET 5, Z | REGSET 5, AC | JMPGTE AC, Z, MEM | LSHIFT AC, Z | LSHIFT AC, MEM | SQBVOL AC | |||||||||
x6 | ACSET REG6 | REGSET 6, Z | REGSET 6, AC | |||||||||||||
x7 | ACSET REG7 | REGSET 7, Z | REGSET 7, AC | |||||||||||||
x8 | UNJMP | ACSET REG8 | REGSET 8, Z | REGSET 8, AC | REGSET M, AC | AND AC, Z | AND AC, MEM | TRIFREQ AC | ||||||||
x9 | ACSET REG9 | REGSET 9, Z | REGSET 9, AC | OR AC, Z | OR AC, MEM | TRIVOL AC | ||||||||||
xA | ACSET REGA | REGSET A, Z | REGSET A, AC | XOR AC, Z | XOR AC, MEM | |||||||||||
xB | ACSET REGB | REGSET B, Z | REGSET B, AC | |||||||||||||
xC | ACSET REGC | REGSET C, Z | REGSET C, AC | NOT AC | FUZFREQ AC | |||||||||||
xD | ACSET REGD | REGSET D, Z | REGSET D, AC | FUZVOL AC | ||||||||||||
xE | ACSET REGE | REGSET E, Z | REGSET E, AC | |||||||||||||
xF | JMP MEM | ACSET REGF | REGSET F, Z | REGSET F, AC |
What is that weird text box?
The text box is designed for input that doesn't require a hex editor. It enables comments, and parses values as JavaScript integers.
This does NOT mean you can enter other JavaScript syntaxes; you can only enter numbers (decimal, '0x' hex values, '0b' binary values, '0o' octal values...).
To add a comment, use a semicolon. This is used like a JavaScript or C++ comment (i.e. '//').
The comma is used to separate values, and extra whitespace and comments are ignored. A comment ends at the end of a line.
For example, you can write "0x0000, ; Update the sound outputs".
Things that may need explaining...
To see things work, the browser needs to breathe.
The NOP instruction does not simply do nothing, as you may think. It updates all of the sound outputs if they have changed, and only then does it wait for 1 frame.
It should run at 60fps, but your mileage may vary.
RAM? Where we're going, we don't need RAM.
There are 16 registers general-purpose registers. Each register can be set to AC (the accumulator) or Z (the data register). You can also set AC to one of the registers.
They have hexadecimal names, 0-9 and A-F, for convenience.
When any instruction requests a Z value, that value comes from the word after the current instruction. When this Z value is required, the program counter jumps 2 steps to accommodate the double-word instruction.
These registers are the only way to store data, as the machine probably does not need much storage for its sole purpose, and registers are often reused anyway.
Other registers
There are other registers in the system. These are the accumulator (AC), the program counter (PC), the memory adress register (M), and the data register (Z), and the instruction register (I).
The accumulator is the first value for any calculations. It is also the register that is compared to data for conditional jumps.
The program counter by default increases by 1 when an instruction is executed. However, if the instruction has a data value, it jumps by 2, and if the instruction itself is a jump, the program counter jumps there and does not jump ahead so it can execute the instruction at the new adress.
The memory adress register does not have anything to do with RAM. Instead, its sole purpose is interacting with ROM. It enables jumping, as well as performing calculations on values in the ROM.
The data register is the Z register because there is already a general-purpose D register. This is only used when an instruction requires it, and in this case, it is overwritten, and is completely ignored otherwise.
The instruction register is the register that holds the current instruction. It is not accessible by the instructions themselves.
More help on its way (maybe)...