What's new

My PotatoChipAte

OP
glVertex3f

glVertex3f

Crap Cracker
EDIT:

lol never mind... you were right refraction

Code:
memset(Display, 0, CHIP8_DISPLAY_SIZE);

EDIT2:

wow.. memset seems to be fixing alot of my problems...
Thank you refraction...

And people not to harsh on my code please, lol. I know not what I do.
 
Last edited:

refraction

PCSX2 Coder
glVertex3f said:
EDIT:

lol never mind... you were right refraction

Code:
memset(Display, 0, CHIP8_DISPLAY_SIZE);

EDIT2:

wow.. memset seems to be fixing alot of my problems...
Thank you refraction...

And people not to harsh on my code please, lol. I know not what I do.

yes the mem commands are very handy, as they can be handled much more efficently than erasing and making new arrays and copying arrays like i said with scrolling, after the dodgy for loop to shift the pixels 4 places left or whatever (if you find a better way of doing that let me know!) you can use memcpy to bring it back nice and fast like so

memcpy(Display, TempDisp, CHIP8_DISPLAY_SIZE);

much faster code is generated than for loops :)
 
OP
glVertex3f

glVertex3f

Crap Cracker
Am i doing this right?

Code:
void CPU::sprite()
{
  int x = cMemory.V[(opCode&0x0F00) >> 8];
  int y = cMemory.V[(opCode&0x00F0) >> 4];
  
  int height    = cVideo.superChip ? 16 : (opCode&0x000F);
  int width     = cVideo.superChip ? 16 : 8;
  int dataCheck = cVideo.superChip ? 0x8000 : 0x80;
	
  cMemory.V[0xF] = 0;
	
  for(int ly = 0; ly < height; ly++) {
    unsigned char data = cMemory.memory[cMemory.I + ly];

    for(int lx = 0; lx < width; lx++) {

      if((data&(dataCheck >> lx)) != 0) {
        if(cVideo.display[(x + lx) + ((y + ly) * cVideo.screenW)] == 1) cMemory.V[0xF] = 1;
        cVideo.display[(x + lx) + ((y + ly) * cVideo.screenW)] ^= 1;
      }
    }
  }

  cVideo.draw();
}
 

refraction

PCSX2 Coder
as far as i can tell it looks like it should work as long as cVideo.SuperChip does return a boolean value and cVideoScreenWidth is being set to the correct width of the screen.

just one thing to remember (if you havent done it already) when you output it to the screen times the values by the size of the pixels your using, else itll just be a big pile of mush and a very small screen ;p
 
OP
glVertex3f

glVertex3f

Crap Cracker
Im begining to think that opengl is just way to much for this project. What graphics library should I use... (I dont have MSVC++ so i dont think I could use DirectX)
 

smcd

Active member
You could try SDL (which uses OpenGL I believe), then you might can even make a portable emulator. :p Otherwise there are packages to use DirectX with gcc/g++ in Windows, or you could use the Windows API, poke around google, Windows GDI Programming. Or, try Borland's compiler, it should be able to do DirectX stuff too I think, but not sure because I don't like it/use it.
 

refraction

PCSX2 Coder
yeh i used SDL, its an OpenGL wrapper (you were right :p) and is very simple to use especially for this! and comes in handy for later emulators :)
 
OP
glVertex3f

glVertex3f

Crap Cracker
I think i'll probably see if I can get the emulation stable before I change the graphics.

Anyhow, a few problems...

Alien.jpg


Thats not supposed to be like that im sure...

heres the updated code.

EDIT: I just realized that SDL creates its own window... can you still do menus and the like?
 
Last edited:

refraction

PCSX2 Coder
umm that picture doesnt work.

yes SDL does create its own window, a lot of emulators do the same, i wouldnt worry about there being 2 windows really, just make sure the SDL window is created when you click run instead of when the program starts, so you dont have 2 windows right at the beginning :)
 
OP
glVertex3f

glVertex3f

Crap Cracker
so SDL has no commands for menus? I would like to have it set up like it is now, where you have the main window with the menus on it and thats it.
 

zenogais

New member
glVertex3f said:
so SDL has no commands for menus? I would like to have it set up like it is now, where you have the main window with the menus on it and thats it.

You can still keep the window, its just that a seperate window will pop up when the game starts running.
 
OP
glVertex3f

glVertex3f

Crap Cracker
hmm, i guess I could figure out a way to make the main window display all the roms that are in a certain directory... Anyone know how that would work?
 

smcd

Active member
In windows you can use FindFirstFile/FindNextFile and if you want, filter the results by using a file extension (dunno what you'd use for chip8 there are several extensions I've seen).
 
OP
glVertex3f

glVertex3f

Crap Cracker
I finally got SDL working.. now I need to learn it... hmmm... could take a while.. :blush: oh well :party:
 
Last edited:
OP
glVertex3f

glVertex3f

Crap Cracker
hmmm debugger caught something

Code:
Program has received a signal-name="SIGSEGV",signal-meaning="Segmentation fault" at Video::update()({name="this",value="0x439000"}), file C:\MWProj\SDLChip\Display.cpp:47

Heres that piece of code.

Code:
unsigned int clrBlack = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);

SDL is probably the trickiest library ive ever tried to learn. Maybe im just tired. Was it hard to learn for you all here? Did you go by any tutorials or just the included docs?
 
Last edited:
OP
glVertex3f

glVertex3f

Crap Cracker
See, my problem is Ive only learned two. Allegro was first, then OpenGL.... so yeah...

Since im not as tired, I think i'll look at it again.
 
Last edited:
OP
glVertex3f

glVertex3f

Crap Cracker
AHHH. I have been working on my emulator, and now every Chip8 rom runs almost flawlessly. A few roms have a few tiny glitches and Super chip 8 isnt done.. but still... wow... :)

Sorry im on a happy trip.

EDIT: Question, whats a HP48 flag?

also, I am afraid i am dong this wrong.
Code:
void CPU::setChip8()
{
  cVideo.superChip = FALSE;	

  cVideo.pixelWidth = 10;
	
  cVideo.screenW = 64;
  cVideo.screenH = 32;
	
  delete [] cVideo.display;
  cVideo.display = new unsigned char [CHIP8_DISPLAY_SIZE];
}

void CPU::setSuperChip8()
{
  cVideo.superChip = TRUE;
	
  cVideo.pixelWidth = 5;
	
  cVideo.screenW = 128;
  cVideo.screenH = 64;
	
  delete [] cVideo.display;
  cVideo.display = new unsigned char [SCHIP8_DISPLAY_SIZE];
}
???
 
Last edited:

smcd

Active member
HP48 has to do with a chip8 emulator that runs on an HP48 calculator, from what I understand, nothing really related to chip8?
 
OP
glVertex3f

glVertex3f

Crap Cracker
thats what I thought... interesting...

I just noticed in some docs (doomulations I believe) on the str and ldr instructions for SChip8 it said to save to HP48 flags...
 
Last edited:

Top