Skip to content

Commit

Permalink
added command line options for speed and video scale
Browse files Browse the repository at this point in the history
./program speed scale rom
  • Loading branch information
daniel-Jones committed Aug 22, 2020
1 parent 9fa7c26 commit f23b667
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
9 changes: 0 additions & 9 deletions chip8.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,6 @@ chip8_init()
{
memory[0x0 + i] = chip8_fontset[i];
}

/*
uint8_t sinv[] = {0xBA, 0x7C, 0xD6, 0xFE, 0x54, 0xAA};
// temp
for (uint8_t i = 0; i <= FONT_WIDTH; i++)
{
memory[PROGRAM_START+i] = sinv[i];
}
*/
}

void
Expand Down
13 changes: 8 additions & 5 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* https://slack-files.com/T3CH37TNX-F3RKEUKL4-b05ab4930d?nojsmode=1
*/

#define VIDEO_SCALE 5
//#define VIDEO_SCALE 5
#define STEPPING 0 // set to 1 to step manually through program

SDL_Window *window;
Expand All @@ -46,6 +46,7 @@ void handle_key_up(int keycode);
uint8_t get_chip8_key(int keycode);
void print_registers();

int VIDEO_SCALE = 5;
int step_cycle = 0;

extern uint32_t video[WIDTH*HEIGHT];
Expand All @@ -62,7 +63,7 @@ extern uint16_t stack[STACK_SIZE];
void
usage(char *program)
{
printf("usage: %s [romfile]\n", program);
printf("usage: %s [speed] [scale] [romfile]\nspeed - how many cycles per second should be run (60-1000 or so, depends on the game)\nscale - pixel scaling (~5 recommended)", program);
}

void
Expand Down Expand Up @@ -204,23 +205,25 @@ handle_sdl_events()

int main(int argc, char *argv[])
{
if (argc < 2)
if (argc < 4)
{
usage(argv[0]);
exit(EXIT_FAILURE);
}


VIDEO_SCALE = atoi(argv[1]);
chip8_init();

if (!load_rom(argv[1]))
if (!load_rom(argv[3]))
{
fprintf(stderr, "cannot start interpreter\n");
exit(EXIT_FAILURE);
}

init_video();

const int fps = 300;
const int fps = atoi(argv[2]);
const int frame_delay = 1000/fps;
uint32_t frame_start;
uint32_t frame_time;
Expand Down

0 comments on commit f23b667

Please sign in to comment.