Next Generation Emulation banner
461 - 480 of 872 Posts
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 :)
 
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
 
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
 
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:
 
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 >
 
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
 
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. :)
 
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
 
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;
 
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
 
I added OpCode JMC ($11) support, and old starfield now works - yay!
Awesome!
Glad to head that's solved :) to be honest I'm suprised not more of the old roms used jmc
 
You're not the first to get caught out! Think ill looking at starfield today and fix it before shendo makes an new pack

Edit: Here we go, fixed rom and sources. the rnd was doing 0-2 o_O that wasn ever going to work for 4 directions.. lol

Tykel: Theres a bug in tchip16 assembler, it doesnt take immediate numbers for ldi sp, tried to compile ninja and it fails on that.
 
oh and for those interested, ive made a start on a fighting game.

here is a mockup using the art i created from the sprites. i might however do a different body for the cpu player so there is some distinction, but the player will always be on the left anyway ;p

Don't go off the colours, that's the colours i used in Photoshop, they are slightly different using the Chip 16 palette, dont know if i can be fussed to change the palette for the game ;p You can tell im no artist.. lol, i think this is what you refer to as "developer graphics" :p
 
461 - 480 of 872 Posts