Next Generation Emulation banner
1 - 20 of 486 Posts
Not totally sure how to do that, but I'll read up on it. :D;
Well it doesn't have to be anything special.
If you take a look at my thread you will see that my debugger is simply 2 listboxes, one showing values of registers and other disassembled code.
When you have that you are able to check if each opcode you execute gives desired result.

Edit: I see cottonvibes beat me to it :p
 
If you are asking how to know what instruction should be executed when you fetch an opcode you should AND it with 0xF000 and shift it to the right by 12.

You can also use higher part of the opcode (RAM[PC]) to get the same result:
Code:
switch ((RAM[PC] & 0xF0)>>4)
            {
                case 0x00:
                    break;

                case 0x01:
                    break;

                case 0x02:
                    break;

                ...
            }
Some people split opcodes into nibbles so you may also take that approach.
 
Cool emu dreampeppers99.

runawayprisoner said:
Anyway, the screen "scrolls" itself when something is out of bounds. Namely... x128 would become x0. x-1 would become x127. x129 would become x2, and so on... you get the idea.
AFAIK chip8 does not loop the image so implementation of that would be a hack.
 
You will also see this in Pong when you move your paddle past the top and bottom of the screen..
Actually pong is programmed to wrap paddles around (though it needs to completly disappear from the screen to appear on the other side).
Also among the undocumented features is that for subtraction, when the result is zero or lower, the flag is set. It's not a carry flag there, it's a carry and zero flag. Cowgod didn't state it so in his document, and neither did David Winter.
Nice find. Explains why Ant doesn't work properly on my emu.
 
Ohh Sokoban in colour! :)

Does it work well in your emu? I've seen it messing up on later levels on some emulators due to a bug with carry,
like this: V[F]=carry; V[x]=calculation;
while it should be: int temp=carry; V[x]=calculation; V[F]=carry;
The 1st implementation would cause a problem with eg. "add V[0],v[F]".
I believe mine has that problem. Hm, maybe this is the right time to fix that.
 
I have made a clone of the Intellivision game called "SNAFU".

This is my first game in the assembler so getting the AI to work right was a pain in the a**.

During development the game was tested in Hap's "Fish and Chips" emulator (and mine too, hehe)
I tested other emus as well and saw that some of them have problems with Fx0A opcode (LD Vx, K).
So fix that folks, otherwise the game will start immediately and not wait for any key to be pressed like it's supposed to.


You can download the binary as well as source which can be compiled with chipper.
If you want to add or change something be my guest ;)
 
Thanks Runawayprisoner.
Well the AI is not that bright but it gets the job done I guess.

Hehe, I just ran the game in your emu and I see what you mean with "color mod methods won't play nice"
Maybe you can check if the sprites were drawn on same x and y coordinate without raising the collision flag
and then apply the same color used by the first sprite at that location.

And, your anti flicker filter killed my flashing arrow :p

---

I gave a quick look at this thread and saw that some people actually write to the
surface directly and read it pixel by pixel to see if the collision happened.

Personally I did a 2D boolean array and manipulated that.
After the draw opcode was completed I would clear the surface and draw the content of that array.
 
Dax said:
...perhaps using an external RAM chip. :p
Hehe, bank switching for CHIP8 :p

runawayprisoner said:
And I'm actually using the same color for the same sprite read from the same ROM address so perhaps it's not that kind of problem, but I'll make sure to debug it thoroughly as I'm certain there must be a universal method that works for all games... Well, we'll see.
Well, I meant for different sprites placed on the same X,Y coordinates without raising collision flag.
 
Very, very nice test Tronix286. It motivated me to fix my emu after almost 2 years of not touching it.
That was the idea anyway. After I saw my messy code I decided to rewrite the emu.

This is the old one:
View attachment 211885

After two days of coding I made a new one which works much better then the old one:
View attachment 211896
I still have to implement half-pixel scrolling and few minor stuff.

Anyway here are some screenshots I made during development: (Note the build numbers)
 
In the trend of Chip8 emu tests I decided to make one too.
This one tests the implementation of the Fx0A opcode.

============================
Fx0A opcode test for Chip8.
============================
Author: Shendo

About:
-------
This test rom will do a few simple checks to ensure that
Fx0A opcode is properly executed.

Usage:
-------
When you see "GO" printed on the screen press any key (0 to F) to start the test.
If testing went as expected "OK" should be displayed. If you get an error code read further.

Error codes:
-------------
Error 1: Register did not get updated with a value of the pressed key.
Error 2: Stored value is higher then 0xF.
Error 3: Currently pressed key does not equal to stored key.
 
Here is my draw opcode:
Code:
        /// <summary>
        /// Draw a sprite on the specified coordinates.
        /// </summary>
        /// <param name="X">X coordinate.</param>
        /// <param name="Y">Y coordinate.</param>
        /// <param name="Height">Height of the sprite. 0 for 16x16 sprite</param>
        private void DRWOpcode(byte X, byte Y, byte Height)
        {
            int SpriteWidth = 8;        //Chip-8 sprites are 8 pixels wide
            ushort GraphicData = 0;     //Graphic data will be stored here
            ushort MemoryOffset = 0;    //RAM offset to fetch graphic data from
            int CurX = 0;               //Current X
            int CurY = 0;               //Current Y

            //Check if this is a 16x16 draw instruction
            if (Height == 0)
            {
                if(VideoMode == 1) SpriteWidth = 16;       //SCHIP sprites are 16 pixels wide
                Height = 16;            //SCHIP sprites are 16 pixels high
            }

            //Reset colision flag
            VREGS[0xF] = 0;

            //Draw graphics line by line
            for (int i = 0; i < Height; i++)
            {
                GraphicData = (ushort)((RAM[IREG + MemoryOffset]<<8) | RAM[IREG + MemoryOffset + 1]);

                //Check each bit from the graphic data
                for (int j = 0; j < SpriteWidth; j++)
                {
                    //Check if pixel should be drawn
                    if (((GraphicData >> (15 - j)) & 1) == 1)
                    {
                        //Wrap the screen
                        if (VideoMode == 1)
                        {
                            //SCHIP
                            CurX = (X + j) % 128;
                            CurY = (Y + i) % 64;
                        }
                        else
                        {
                            //Chip-8
                            CurX = (X + j) % 64;
                            CurY = (Y + i) % 32;
                        }

                        //Check if there already is a raised pixel in the VRAM
                        if (VRAM[CurX, CurY] == 1)
                        {
                            //Set the colision flag
                            VREGS[0xF] = 1;

                            //Lower the pixel
                            VRAM[CurX, CurY] = 0;
                        }
                        else
                        {
                            //Raise the pixel
                            VRAM[CurX, CurY] = 1;
                        }
                    }
                }

                //Go to next location of graphic data
                if (Height == 16 && VideoMode == 1) MemoryOffset += 2; else MemoryOffset++;
            }
        }
This code draws 8xn and 8x16 sprites in chip8 mode and 16x16 sprites in schip mode which makes hap's emutest display graphics properly.
 
1 - 20 of 486 Posts