about summary refs log blame commit diff
path: root/main.c
blob: 94e4a95b0ad859df8bcba4b3aa3760f3f5b08471 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                  





                                


                               







                      

                                   

                                                  


                               
                                                      
     
                                            

     
                    
 
                              




                                                  

             




                                                     
#include <stdio.h>
#include <unistd.h>
#include <config.h>
#include <emulator.h>

int main(int argc, char** argv);
void show_help();

int main(int argc, char** argv)
{
    if(argc < 2)
    {
        show_help();
        return 1;
    }

    Emulator emulator;

    emulator_initialise(&emulator);

    if(emulator_load_rom(&emulator, argv[1]) != 0)
        return 2;

    printf("Hello brother!\n");

    /*for(int i = 0; i < sizeof(emulator.memory); ++i)
    {
        printf("0x%x ", emulator.memory[i]);
    }

    putchar('\n');*/

    while(emulator.is_on == 1)
    {
        emulator_tick(&emulator);
        usleep(1000000 / INSTRUCTIONS_PER_SECOND);
    }

    return 0;
}

void show_help()
{
    printf("BAD USAGE! -> ./chip8_emulator [ROM]\n");
}