Next Generation Emulation banner

Chip16 Official thread (Development/Suggestions)

117K views 871 replies 39 participants last post by  acetone-man-thecoder 
#1 · (Edited)
Read all earlier developments from the first thread from Shendo HERE:
http://forums.ngemu.com/showthread.php?t=138170


-----------------------

Description:
ShendoXT said:
What is Chip16?

Chip16 is intended as a fairly easy to implement, well documented and community supported system which would aid beginners when writing their emulator.
This would solve many CHIP8 inconsistencies as well as undocumented features sometimes (possibly) added by interpreter authors themselves.
CHIP16 has a regular D-PAD controller with 4 buttons in contrast to CHIP8's somewhat messy 16 keys keyboard.
Chip16 is also more interesting than Chip8, thanks to a higher resolution, colour display and expanded memory.

Full specification (latest):
http://github.com/tykel/chip16/wiki/Instructions

If you have a suggestion to improve the Chip16 specification, please post it here so it can be discussed. Provide as much detail as you can.

If you have made an emulator, game, or other software regarding Chip16, please post it here with a link. Source code preferred ;)

In the case of Chip16 games/demos: please post a ROM with a header.

Screenshots:
-----------
View attachment 216991 View attachment 216992 View attachment 216993 View attachment 216994 View attachment 216995 View attachment 216996 View attachment 216997 View attachment 216998 View attachment 216999 View attachment 217000 View attachment 217001 View attachment 217002 View attachment 217003




Links:
-----

Program pack (07/16/2012): link
Program pack (03/14/2012): link

Assembler: link

Reference emulator #1 (by refraction): RefChip16
Reference emulator #2 (by me): mash16
Online emulator: Js16
Other emulators (outdated, will not work): cottonCx

Command line image converter: img16
GUI image converter: link

Command line ROM reader/patcher (linux build, source included): View attachment 217495
GUI ROM reader/patcher (windows build): link
 
See less See more
7
#2 ·
Wow that was unexpected! Big shame he doesn't want to continue :( thanks for all your work shendo, hopefully those of us who contribute will make you proud :)

Congrats on your new position tykel :)
 
#3 ·
The big thing this project needs is a serious sound spec. I dont see why we cant have something close to the level of gameboy or something...
 
#4 ·
Was wondering why there were now 2 chip16 threads :p
I support the decision, congrats tykel.

As for sound, I'm too busy to help out with that atm, so I'm going to sit that discussion out.
 
#5 ·
As this is supposed to be somebodies first emulator (a bit more in depth than chip8 anyway) so we dont want anything too complex for sound. A simple tone with pitch/length control is more than enough imo.
 
#7 ·
As this is supposed to be somebodies first emulator (a bit more in depth than chip8 anyway) so we dont want anything too complex for sound. A simple tone with pitch/length control is more than enough imo.
So are we sticking with these, or making some changes?

Code:
09 00 00 00     SND0			Stop playing sounds.
0A 00 LL HH	SND1 HHLL		Play 500Hz tone for HHLL miliseconds.
0B 00 LL HH	SND2 HHLL		Play 1000Hz tone for HHLL miliseconds.
0C 00 LL HH	SND3 HHLL		Play 1500Hz tone for HHLL miliseconds.
If someone can already make an emulator that can play 3 different tones (the three existing instructions), why couldn't we change it so there is only one sound instruction instead of 3 with variable tone as presented in the other thread by refraction?

Code:
0D 0X LL HH SNP Play PCM Sound for HHLL miliseconds at the tone specified in 
                address pointed to by Register X
This wouldn't make the emulator any harder to build would it? A tone is a tone....in this case it would be variable instead of fixed.

cheers,
Paul
 
#8 · (Edited)
So are we sticking with these, or making some changes?

Code:
09 00 00 00     SND0			Stop playing sounds.
0A 00 LL HH	SND1 HHLL		Play 500Hz tone for HHLL miliseconds.
0B 00 LL HH	SND2 HHLL		Play 1000Hz tone for HHLL miliseconds.
0C 00 LL HH	SND3 HHLL		Play 1500Hz tone for HHLL miliseconds.
If someone can already make an emulator that can play 3 different tones (the three existing instructions), why couldn't we change it so there is only one sound instruction instead of 3 with variable tone as presented in the other thread by refraction?

Code:
0D 0X LL HH SNP Play PCM Sound for HHLL miliseconds at the tone specified in 
                address pointed to by Register X
This wouldn't make the emulator any harder to build would it? A tone is a tone....in this case it would be variable instead of fixed.

cheers,
Paul
I think this is the way to go. Simple but flexible enough to do something interesting.
The real issue is whether we keep ops SND1..3 :/
 
#9 ·
The biggest issue is all existing ops will need rewriting if we don't keep the existing ones.

how many roms use SND0? If none, we can just replace that one, keep the others for compatibility
 
#10 ·
The biggest issue is all existing ops will need rewriting if we don't keep the existing ones.
True, this would be a pain to change...but surly a bit of pain now would make for a better 'machine' later?

how many roms use SND0? If none, we can just replace that one, keep the others for compatibility
It would be cleaner if we can just get rid of the SND1...SND3 commands, but I don't know how many roms use sound...maybe there are not many?

cheers,
Paul
 
#13 ·
I had a look on my hd quickly, I reckon there are about 6-7 ROMs that use sound, and only one or two I don't have source code to. So recompiling with a new instruction would be easy, and hex-editing is a possibility for the remaining one or two.
 
#14 ·
Code:
09 00 00 00     SND0			Stop playing sounds.
0A 00 LL HH	SND1 HHLL		Play 500Hz tone for HHLL miliseconds.
0B 00 LL HH	SND2 HHLL		Play 1000Hz tone for HHLL miliseconds.
0C 00 LL HH	SND3 HHLL		Play 1500Hz tone for HHLL miliseconds.
...
Code:
0D 0X LL HH SNP Play PCM Sound for HHLL miliseconds at the tone specified in 
                address pointed to by Register X
these instructions don't make much sense, since they don't talk about what type of wave the sound is.

we can either keep sound generation really primitive, or we can make it a more simplified version of what consoles have.
if we want good sounding games, we obviously don't want primitive sound. but at the same time, how many of us are going to code a chip16 game with cool music?

someone should read up on how the old-gen systems do their sound, and propose a simplified version (they tended to over-complicate things due to hw restrictions).
 
#15 ·
#16 ·
The intention was so you have more choice of tones for movement, death noses or maybe a short ditty. Not expecting any maestros here. And sound wave tone is fine imo :)
 
#21 ·
I only just noticed this, but aren't some of these op codes a problem?

Code:
B0 0X 0N 00	SHL RX, N		Logical    Shift value in register X left N times.  Affects [z,n]
B1 0X 0N 00	SHR RX, N		Logical    Shift value in register X right N times. Affects [z,n]
B0 0X 0N 00	SAL RX, N		Arithmetic Shift value in register X left N times.  Affects [z,n] (same as SHL)
B2 0X 0N 00	SAR RX, N		Arithmetic Shift value in register X right N times. Affects [z,n]
B3 YX 00 00	SHL RX, RY		Logical    Shift value in register X left by the value in (RY & 0xf).  Affects [z,n]
B4 YX 00 00	SHR RX, RY		Logical    Shift value in register X right by the value in (RY & 0xf). Affects [z,n]
B3 YX 00 00	SAL RX, RY		Arithmetic Shift value in register X left by the value in (RY & 0xf).  Affects [z,n] (same as SHL)
B5 YX 00 00	SAR RX, RY		Arithmetic Shift value in register X right by the value in (RY & 0xf). Affects [z,n]
Unless it has changed and not been updated I can see these duplicates:

Code:
B0 0X 0N 00	SHL RX, N		Logical    Shift value in register X left N times.  Affects [z,n]
B0 0X 0N 00	SAL RX, N		Arithmetic Shift value in register X left N times.  Affects [z,n] (same as SHL)
and these ones:
Code:
B3 YX 00 00	SHL RX, RY		Logical    Shift value in register X left by the value in (RY & 0xf).  Affects [z,n]
B3 YX 00 00	SAL RX, RY		Arithmetic Shift value in register X left by the value in (RY & 0xf).  Affects [z,n] (same as SHL)
 
#22 ·
I only just noticed this, but aren't some of these op codes a problem?

Code:
B0 0X 0N 00	SHL RX, N		Logical    Shift value in register X left N times.  Affects [z,n]
B1 0X 0N 00	SHR RX, N		Logical    Shift value in register X right N times. Affects [z,n]
B0 0X 0N 00	SAL RX, N		Arithmetic Shift value in register X left N times.  Affects [z,n] (same as SHL)
B2 0X 0N 00	SAR RX, N		Arithmetic Shift value in register X right N times. Affects [z,n]
B3 YX 00 00	SHL RX, RY		Logical    Shift value in register X left by the value in (RY & 0xf).  Affects [z,n]
B4 YX 00 00	SHR RX, RY		Logical    Shift value in register X right by the value in (RY & 0xf). Affects [z,n]
B3 YX 00 00	SAL RX, RY		Arithmetic Shift value in register X left by the value in (RY & 0xf).  Affects [z,n] (same as SHL)
B5 YX 00 00	SAR RX, RY		Arithmetic Shift value in register X right by the value in (RY & 0xf). Affects [z,n]
Unless it has changed and not been updated I can see these duplicates:

Code:
B0 0X 0N 00	SHL RX, N		Logical    Shift value in register X left N times.  Affects [z,n]
B0 0X 0N 00	SAL RX, N		Arithmetic Shift value in register X left N times.  Affects [z,n] (same as SHL)
and these ones:
Code:
B3 YX 00 00	SHL RX, RY		Logical    Shift value in register X left by the value in (RY & 0xf).  Affects [z,n]
B3 YX 00 00	SAL RX, RY		Arithmetic Shift value in register X left by the value in (RY & 0xf).  Affects [z,n] (same as SHL)
I thought the same at first.
In fact, they are just equivalent operations, and the mnemonics translate to the same opcodes.
The reason for this is that right-shifting can extend the sign bit (SAR) or not (SHR); however left-shifting can not extend the sign bit, SAL and SHL are there for consistency in the instruction set. (In the same way some condition codes in the Sign Flag have multiple aliases)

Chris2Balls: Keep us posted!
 
#24 · (Edited)
Hi,

I wanted to point out an issue with the RND instruction emulated in C or C++ with the rand() function.
The problem appears in cottonvibes's emulator playing starfield and probably in other emulators written in C.

This seems to come from the rand() function which generate random integers between 0 and RAND_MAX (which is generally 32767) and starfield asks for full 16-bits range.
That results in a no fullscreen starfield.

Moreover, if you do :
Code:
R[x] = rand()%(HHLL + 1)
the bottom right hand corner isn't drawn.
Doing
Code:
R[x] = rand()&(HHLL + 1)
solve this issue.

As a beginner maybe i'm mistaking though.
 
#25 · (Edited)
Maze is best to show this, I did something like

V =(rand()%HHLL+1)-1

If you don't do the minus 1 it can go out of range requested

Update:

This is what i do exactly

randval = rand() % ((unsigned short)IMMEDIATE+1); //Apparently if IMMEDIATE is 1, it always generates 0 o_O
//Need to make sure result isnt 0 and is in range.
if(randval > IMMEDIATE) randval -= 1;
REG_X = randval;
 
#26 · (Edited)
Hey all,
I am thinking of trying to make my own emulator, and I am unsure as how to do 'correct' timing in the CPU. The spec says that the CPU is 1MHz, which is 1uS per CPU update.

First, this seems much quicker than I might get a software timer to give me a time between updates, so I am unsure how I am going to get an 'accurate' count (ignoring Windows not being a true multi-tasking OS).

Is QueryPerformanceCounter going to have enough resolution for this? GetTickCount only supplies around 1mS of resolution...

If I can get ok timing, then I see I can do the CPU updates one of two ways:

1) Decode and execute one instruction per CPU tick, and keep track of when to do the next instruction update (global time variable)

2) Decode and execute N instructions per update, and then wait the remainder of the time left in a N * 1uS update chunk before doing the next bunch of updates.

Any ideas?

Am I being too worried about this part of the machine? :)

cheers,
Paul
 
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top