What's new

Lend me your fingers

glVertex3f

Crap Cracker
I need a good "point in the right direction". I was wondering what the next step up from Chip8 would be. Also I need a site with some docs/tutorials on things like what CPU cycles are and why they put $ in front of hex op-codes...

but basically, what is a good next step?
 

zenogais

New member
Well, you had alot of troubles with Chip8, and I think alot of it stemmed from not understanding the core components of the language you were using. So I would say get yourself a good book or ebook (like this one), and try to learn C++ a little better. I pesonally have read probably 30-40 books on programming and various programming languages, and each one has helped me grasp the language better in some way, one of those books being Thinking in C++ (First and Second Editions) Also, I would try looking at and working on some larger projects, as your code seemed to show a lack of any organizational strategy, which helps immensely during debugging. The end result did have an organizational pattern, but it seems very familiar after look at the sources of other Chip8 emulators. Anyway, Once you've done that, I'd say try rewriting your Chip8 emulator with what you've learned and see if you can't make it even better. Then move on to something like Gameboy. I hope that this will help you and the best of luck to you.
 
Last edited:
OP
glVertex3f

glVertex3f

Crap Cracker
Yeah after I thought about it a while, I decided dig out my "C++ Black Book". After reading several chapters I realized several basic concepts that I had missed. I have been programming for a few years but ive never been "serious" about it. It was always just something I would do when I was bored. But now between this book (also a "Teach yourself C" book) and the emulator, my knowledge has doubled if not trippled.

I owe a great thanks to many of you here for putting up with my misunderstandings and helping me with the Chip8. I am currently rewriting it with SDL and it is amazing what happens when you actually understand whats going on. I think all the :experience: that I HAVE had with programming, helps me be a quick learner. lol, i got a pen and paper and scribbled out binary code unti I completely understood converting hex/dec to binary and bit shifting and all things binary ;)

The only thing that I have trouble with now is learning class inheritance. I cant find any really good explanations.

Thanks again for all your help!

PS: I think I will use jump tables instead of switch/case.. :)
 

smcd

Active member
If you need help with classes, inheritance, polymorphism, etc. just ask (not saying I'm a genius) but I can help, as many others on the board probably can/would as well.
 
OP
glVertex3f

glVertex3f

Crap Cracker
Well my main concern is the way I am currently doing it.

Seperate classes for each aspect (CPU, Video, Memory) and then just doing a

Code:
Video   cVideo
Memory  cMemory

and using it in my CPU code. It seems that this might be a little messy and that these classes should be accessed differently?
 

smcd

Active member
This isn't real code, but it would be somewhat logical...
Code:
class Machine{
    class CPU;
    class Input;
    class Interrupts;
    class Memory;
    class Sound;
    class Video;
    ...
    ...
}
Something like that (once again, this isn't real code here...) might be a general way to do it, saying that the entire system is an object, and inside the system there are several objects.
 

zenogais

New member
Well, theres standard meanings for inheritance and polymorphism. Inheriting an object from another object is commonly said to give the object inheriting an "is a" relationship with the base class, like the classic example:

Code:
class Shape {
public:
        virtual std::string   getName() = 0;
        virtual unsigned int getLength() = 0;
};

// Sqaure

class Square : public Shape
{
public:
        std::string getName() { return "Square"; }
        unsigned int getLength() { return 100; }
};

As for having to do it the way you mentioned, no one ever said that. I'm currently using private inheritance in my Gameboy emulator as an alternative to creating an instance of every object inside the CPU class. Private inheritance is used to dictate an "is implemented in terms of" relationship. Just experiment and find a method you like really, theres a bazillion different ways to write an emulator.
 
OP
glVertex3f

glVertex3f

Crap Cracker
Im having some SDL trouble. How can I use cout with sdl?

Ive tried many things but it always outputs the text into a stdout.txt file.
 

refraction

PCSX2 Coder
glVertex3f said:
Im having some SDL trouble. How can I use cout with sdl?

Ive tried many things but it always outputs the text into a stdout.txt file.

have you chosen Console as a subsystem?
 
OP
glVertex3f

glVertex3f

Crap Cracker
Yes, if I use std::cout it simply doesnt show the text in the console, but it puts it into the stdout.txt file.

At first I was going to use std::cin to get the rom name, when I typed in the rom name it did not "echo" the text to the screen but when I hit enter it still loaded. It is very odd.

I am now using command line arguments but it will not let me cout errors to the console.
 
OP
glVertex3f

glVertex3f

Crap Cracker
Here, I made a simple program to test cout..

When it runs, an empty console box appears with the little flashing cursor at the top left

When I hit enter the window appears

Code:
#include <iostream>
#include <sdl.h>

SDL_Surface *screen;
SDL_Event    event;

int CreateSDLWindow() 
{
  if(SDL_Init(SDL_INIT_VIDEO) == -1) return -1;
	
  screen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE);
	
  if(screen == NULL) return -1;
	
  return 0;
}

void CheckEvent()
{
  if(SDL_PollEvent(&event)) {
    if(event.type == SDL_QUIT) {
      SDL_Quit();
      exit(0);
    }
  }
}

int main(int argc, char *argv[])
{
  std::cout << "Press enter to lauch SDL window";
  std::cin.get();
	
  CreateSDLWindow();
	
  for(;;) {
    CheckEvent();
  }
	
  SDL_Quit();
  return 0;
}
 

Top