Next Generation Emulation banner

Chip16 Official thread (Development/Suggestions)

127K 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
Image
Image

Image
Image

Image
Image
Image


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
 
#452 ·
Hey all,
I am having some trouble with my Chip16 emulator :(

The BC_TestRom.c16 passes all tests, but at least 2 ROMS don't work correctly, or at all..

1. The Starfield ROM shows absolutely nothing on the screen of my emulator
2. The Alien game just posted works ok until I hit an alien. Then I hear multiple firing noises like I am holding down the fire button (but no shots on the screen), and after a few seconds it goes to the next level automatically.

I am at bit of a loss as all other ROMS seem to work ok and the test rom passes just fine.

cheers,
Paul
 
#457 ·
hmm, dont know what would be wrong... The only thing the bestcoder test doesnt check is Random numbers i think, but i presume Maze works?
 
#459 · (Edited)
yeh starfield doesnt do any sprite flipping, infact the only one that does is the spinning arrows as far as i know..

palette flipping one doesnt use randoms in any way, so yeh, wierd ;p

Edit: Only other possible, it does a check at the start

:program_loop
subi r2, 1
jc program

possibly your carry check isnt working? or that might be the now not part of the spec jump which you need to emulate anyway (opcode 0x11), could be worth checking

heres a snippet of the old spec

Code:
10 00 LL HH	JMP HHLL		Jump to the specified address.
11 00 LL HH	JMC HHLL		(obsolete) Jump to the specified address if carry flag is raised.
12 00 LL HH	JMZ HHLL		(obsolete) Jump to the specified address if zero flag is raised.
 
#461 ·
This is how I am doing my conditions:

Code:
function  TChip16_Emulator.ConditionTrue(c: Byte): Boolean;
begin
  Result := False;

  case (c and $F) of
    $0 : if FFlags.z = 1                             then Result := True; //Z   = 0x0 // [z==1]         Equal (Zero)
    $1 : if FFlags.z = 0                             then Result := True; //NZ  = 0x1 // [z==0]         Not Equal (Non-Zero)
    $2 : if FFlags.n = 1                             then Result := True; //N   = 0x2 // [n==1]         Negative
    $3 : if FFlags.n = 0                             then Result := True; //NN  = 0x3 // [n==0]         Not-Negative (Positive or Zero)
    $4 : if (FFlags.n = 0) and (FFlags.z = 0)        then Result := True; //P   = 0x4 // [n==0 && z==0] Positive
    $5 : if FFlags.o = 1                             then Result := True; //O   = 0x5 // [o==1]         Overflow
    $6 : if FFlags.o = 0                             then Result := True; //NO  = 0x6 // [o==0]         No Overflow
    $7 : if (FFlags.c = 0) and (FFlags.z = 0)        then Result := True; //A   = 0x7 // [c==0 && z==0] Above       (Unsigned Greater Than)
    $8 : if FFlags.c = 0                             then Result := True; //AE  = 0x8 // [c==0]         Above Equal (Unsigned Greater Than or Equal)
    $9 : if FFlags.c = 1                             then Result := True; //B   = 0x9 // [c==1]         Below       (Unsigned Less Than)
    $A : if (FFlags.c = 1) or (FFlags.z = 1)         then Result := True; //BE  = 0xA // [c==1 || z==1] Below Equal (Unsigned Less Than or Equal)
    $B : if (FFlags.o = FFlags.n) and (FFlags.z = 0) then Result := True; //G   = 0xB // [o==n && z==0] Signed Greater Than
    $C : if FFlags.o =  FFlags.n                     then Result := True; //GE  = 0xC // [o==n]         Signed Greater Than or Equal
    $D : if FFlags.o <> FFlags.n                     then Result := True; //L   = 0xD // [o!=n]         Signed Less Than
    $E : if (FFlags.o <> FFlags.n) or (FFlags.z = 1) then Result := True; //LE  = 0xE // [o!=n || z==1] Signed Less Than or Equal
  else
    Result := False;//RES = 0xF // Reserved for future use
  end;
end;
Code:
procedure TChip16_Emulator.OpCode_Jx;
begin
  if ConditionTrue(FInst.X) then FPC := FInst.HHLL;
end;
Code:
procedure TChip16_Emulator.OpCode_Cx;
begin
  if ConditionTrue(FInst.X) then
  begin
    Stack_PushWord(FPC);
    FPC := FInst.HHLL;
  end;
end;
Anyway I have attached my Lazarus (freepascal) project. It includes the .exe + a bunch of 1c16 programs in the executable folder.

Keys Used so far
Code:
    if      (aEvent.key.keysym.sym = SDLK_UP)    then FController1.Up     := 1
    else if (aEvent.key.keysym.sym = SDLK_DOWN)  then FController1.Down   := 1
    else if (aEvent.key.keysym.sym = SDLK_LEFT)  then FController1.Left   := 1
    else if (aEvent.key.keysym.sym = SDLK_RIGHT) then FController1.Right  := 1
    else if (aEvent.key.keysym.sym = SDLK_Z)     then FController1.A      := 1
    else if (aEvent.key.keysym.sym = SDLK_X)     then FController1.B      := 1
    else if (aEvent.key.keysym.sym = SDLK_C)     then FController1.Select := 1
    else if (aEvent.key.keysym.sym = SDLK_V)     then FController1.Start  := 1

    else if (aEvent.key.keysym.sym = SDLK_KP8)   then FController2.Up     := 1
    else if (aEvent.key.keysym.sym = SDLK_KP2)   then FController2.Down   := 1
    else if (aEvent.key.keysym.sym = SDLK_KP4)   then FController2.Left   := 1
    else if (aEvent.key.keysym.sym = SDLK_KP6)   then FController2.Right  := 1
If someone can help, that would be great! I just want it to work completely :)
 
#462 ·
PS. The lazarus project automatically runs one of the projects as a test (Starfield I think), but normally you just use it like so:

Code:
Chip16_Emu.exe -s2x alien.c16
you can use:
-s2x for 2x size
-s3x for 3x size

Defaults to 1x size.
You can use one of the supplied batch files to run ROMS in 2x or 3x size like this:

Code:
Chip16_Emu_s2x.bat alien.c16
 
#463 ·
paul_nicholls: Your emulator does not handle opcode 0x11 from old spec version.

[...skip...]
or that might be the now not part of the spec jump which you need to emulate anyway (opcode 0x11), could be worth checking

heres a snippet of the old spec

Code:
10 00 LL HH	JMP HHLL		Jump to the specified address.
11 00 LL HH	JMC HHLL		(obsolete) Jump to the specified address if carry flag is raised.
12 00 LL HH	JMZ HHLL		(obsolete) Jump to the specified address if zero flag is raised.
Two ways to solve this problem:
1) Processes older 0x11 opcode in emulator or
2) Re-compile maze from sources with new version of thchip16 by tykel
 
#464 · (Edited)
paul_nicholls: Your emulator does not handle opcode 0x11 from old spec version.
Ahhh! Ok, thanks mate :) It didn't occur to me that some of the programs might have been still using the older spec opcodes :)

Two ways to solve this problem:
1) Processes older 0x11 opcode in emulator or
2) Re-compile maze from sources with new version of thchip16 by tykel
Now I can look into it...thanks for finding the problem, it was driving me nuts! :thumb:
 
#465 · (Edited)
I obviously didn't look at my own dissassembly text of starfield.c16 after running the ROM!! I would have noticed this:

Code:
$0000:   $20060100 LDI     R6, #$0001
$0004:   $20070200 LDI     R7, #$0002
$0008:   $200F0000 LDI     RF, #$0000
$000C:   $2008A000 LDI     R8, #$00A0
$0010:   $20097800 LDI     R9, #$0078
$0014:   $04000101 SPR     $0101
$0018:   $2002FF00 LDI     R2, #$00FF
$001C:   $50020100 SUBI    R2, #$0001
$0020:   $1100A400 Unknown Instruction!!
$0024:   $200E0010 LDI     RE, #$1000
$0028:   $20030000 LDI     R3, #$0000
$002C:   $14005800 CALL    $0058
$0030:   $200E0020 LDI     RE, #$2000
$0034:   $20030000 LDI     R3, #$0000
......
< FACEPALM >
 
#468 · (Edited)
Ref, I think you forgot to seed the rand in your emulator. :p

I did! Though in my defense its never needed to be seeded random till my alien game :p
 
#469 ·
Ok guys, I have new compiler demo to show you all (not again, :p but wait, this time it's good). It's called 'Mega Man X 16'. You control Mega Man X and fight against Storm Eagle. Press Direction buttons to move and A button to shoot. Enjoy!

Oh and source code for this game and beta version of the compiler (version 0.01) will be released tomorrow. :)
 
#470 · (Edited)
interesting! however i dont seem to be able to kill him lol

but thanks, you just made me notice a bug in my constant propegation ;p

edit: fixed in v1.45, along with my RAND seed ;p
 
#473 ·
Nice work Prads! I will try out the game later on :)

I recompiled starfield so it uses the new spec opcodes, but I still have a problem. There are no stars in the lower right corner of the screen. I know this has been talked about before but I can't recall what the cure was...

This is my random routine in my emulator:
Code:
procedure TChip16_Emulator.OpCode_RND;
begin
  FReg[FInst.X] := Random(FInst.HHLL + 1) and $FFFF; // 07 0X LL HH	RND RX, HHLL		Generate a random number and store it in register X. Maximum value is HHLL.
end;
 
#474 ·
Nice work Prads! I will try out the game later on :)

I recompiled starfield so it uses the new spec opcodes, but I still have a problem. There are no stars in the lower right corner of the screen. I know this has been talked about before but I can't recall what the cure was...

This is my random routine in my emulator:
Code:
procedure TChip16_Emulator.OpCode_RND;
begin
  FReg[FInst.X] := Random(FInst.HHLL + 1) and $FFFF; // 07 0X LL HH	RND RX, HHLL		Generate a random number and store it in register X. Maximum value is HHLL.
end;
Sounds like your starfield bugged like shendo's one (it was perma cornerless :p). implement the 0x11 then use this version
http://forums.ngemu.com/showpost.php?p=2032785&postcount=291