Next Generation Emulation banner
301 - 320 of 872 Posts
Discussion starter · #301 · (Edited)
Oops, sorry about the Starfield. I added the latest ROM now.

There seems to be an issue in the new tchip16 with the importbin directive. It seems like it omits some bytes from the files.
The issue can be recreated with the Reflection game (source available in the program pack).
Ah yes, I see, the font is messed up. I'll fix that asap!

EDIT: It seems the decimal string-to-int was messed up (?), but only on Windows (??).
That bug is fixed now, and my build of Reflection is now identical to the one from the pack you last posted.
Get the latest from the Google Code page. I also made error output more GNUtools-like.
Give a shout if a problem persists!
 
Sorry ref, you are right. It's because of the wrong version of directx 9.0. I installed June 2010 version of dx and it works perfectly now.
Phew! I'm glad about that, I was starting to think my cost was really bad lol
 
Discussion starter · #305 ·
Hi Refraction,

I'm not sure but I think your random number generator doesn't give you an uniform distribution :
If you want to compare the PRNG results, you can also look at the Static and Herdle roms.
 
Hey all, I have a question about Chip16 Sprites...

I am making a Pascal class that will represent a sprite so I can create one, set/get it's pixels, and save to a file, or draw the sprite at a memory location (for the emulator).

I am not quite sure how I can access indvidual pixels if the data is in a 1D array.

I figure that I can use an array of this size?:
SetLength(FSpriteData,(aWidth * aHeight) div 2);

It says this in the Spec:

Sprites are byte coded color indexes. 1 Byte represents a block of 2 pixels.
For example, if the sprite height and width are set to 2 the sprite is 4 pixels wide and 2 pixels tall.
Higher nibble is the left pixel and lower nibble is the right pixel.
So looking at LSB to MSB:
0...7
RRLL is two pixels of a sprite?

How would I calculate a pixel's byte and nibble, and retrieve the correct pixel nibble?
Like this??
Code:
PixelOffset := aY * FWidth + aX;
PixelByte   := PixelOffset div 2;
PixelNibble := PixelOffset mod 2;

Pixel       := (FSpriteData[PixelByte] shr (PixelNibble * 4)) and $F;  // get low or high nibble depending on PixelNibble (shifts right 0 or 4 bits)
or do I have to swap around the nibble I am retrieving?

Cheers,
Paul
 
Discussion starter · #308 ·
I think since width is necessarily a multiple of 2, you should always read pixels in groups of 2 (hence, a byte at a time).
The high nibble (>> 4) is the left pixel, and the low nibble (& 0xF) is the right pixel.
Then translate/write these pixel values into your graphics buffer.
Does that help?
 
Discussion starter · #310 ·
You can find my command line utility at the tchip16 link in my sig, in the downloads section.
Tronix's GUI utility with filters can be found here.
Links added to OP.
 
yay! I have gotten my chip16 sprite working, at least when accessing the pixels...I can load a chip16 image .bin file, and print out it's nibbles as a debugging tool:



This is my final code for accessing the sprite's pixels:
Code:
function  TChip16Sprite.GetPixel(aX,aY: Integer): Byte;
const
  cNibbleShift: array[0..1] of Byte = (4,0);     //0 = left pixel, 1 = right pixel
  cNibbleMask : array[0..1] of Byte = ($F0,$0F); //0 = left pixel, 1 = right pixel

var
  PixelIndex  : LongInt;
  NibbleIndex : Byte;
begin
  Result := 0;

  PixelIndex   := aY * (FWidth shr 1) + (aX shr 1);
  if PixelIndex > High(FSpriteData) then Exit;
  NibbleIndex := (aX and 1); // even pixels = 0 (left pixel nibble), odd pixels = 1 (right pixel nibble)
  Result      := (FSpriteData[PixelIndex] and cNibbleMask[NibbleIndex]) shr cNibbleShift[NibbleIndex];
end;
EDIT: and my SetPixel code works too!! Nice :)
Code:
procedure TChip16Sprite.SetPixel(aX,aY: Integer; aCol: Byte);
const
  cNibbleShift: array[0..1] of Byte = (4,0);     //0 = left pixel, 1 = right pixel
  cNibbleMask : array[0..1] of Byte = ($F0,$0F); //0 = left pixel, 1 = right pixel

var
  PixelIndex  : LongInt;
  NibbleIndex : Byte;
begin
  aCol := aCol and $F; //only allow color in lower nibble ($0-$F)
  PixelIndex   := aY * (FWidth shr 1) + (aX shr 1);
  if PixelIndex > High(FSpriteData) then Exit;
  NibbleIndex := (aX and 1); // even pixels = 0 (left pixel nibble), odd pixels = 1 (right pixel nibble)
  FSpriteData[PixelIndex] := FSpriteData[PixelIndex] and ((cNibbleMask[NibbleIndex xor 1]) or (aCol shl cNibbleMask[NibbleIndex]));
end;
cheers,
Paul
 
Discussion starter · #316 · (Edited)
@refraction & tykel: Thanks guys! :)
Oh, for fun...I am seeing if I can code up my own Chip16 demo while I am doing my emulator (haven't done much yet LOL).
HINT: It will include a very, very famous ball bouncing, and use palette cycling... :D
Nice, looking forward to it! How about some music to go along? :D
 
301 - 320 of 872 Posts