1
0
mirror of https://github.com/jborza/emu6502.git synced 2024-11-25 03:34:40 +00:00
emu6502/emu6502.c

70 lines
1.6 KiB
C
Raw Normal View History

2019-04-13 20:00:37 +00:00
// emu6502.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <stdio.h>
2019-04-14 08:57:25 +00:00
#include <stdlib.h>
2019-04-14 10:39:56 +00:00
#include <memory.h>
2019-04-13 20:00:37 +00:00
#include "state.h"
#include "cpu.h"
2019-04-13 23:51:50 +00:00
#include "disassembler.h"
2019-04-14 08:57:25 +00:00
#include "opcodes.h"
2019-04-14 10:39:56 +00:00
#include "test6502.h"
2019-04-13 23:51:50 +00:00
byte* read_game() {
FILE* file = fopen("..\\bins\\tetris.bin", "r");
2019-04-19 09:38:52 +00:00
//byte* buffer = malloc(0x800);
byte buffer[32];
int read = fread(&buffer, sizeof(byte), 32, file);
2019-04-13 23:51:50 +00:00
fclose(file);
return buffer;
}
2019-04-19 09:38:52 +00:00
void emulate_game() {
State6502 state;
//FILE* file = fopen("..\\bins\\tetris.bin", "r");
clear_state(&state);
state.memory = read_game();
for (int i = 0; i < 100; i++) {
disassemble_6502(state.memory, i);
}
}
2019-04-13 20:00:37 +00:00
int main()
2019-04-19 09:38:52 +00:00
{
//emulate_game();
2019-04-14 10:39:56 +00:00
run_tests();
2019-04-14 11:24:02 +00:00
printf("All tests succeeded.\n");
return 0;
2019-04-14 10:39:56 +00:00
}
//void emulate() {
// State6502 state;
// memset(&state.memory, 0, sizeof(State6502));
// print_state(&state);
// clear_state(&state);
// byte* memory = read_game();
// //state.memory = read_game();
// state.memory = malloc(4096);
// memset(state.memory, 0, sizeof(byte) * 4096);
// state.memory[0] = 0xEA;
// state.memory[1] = 0x05; //ORA $a0
// state.memory[2] = 0xA0;
// state.memory[3] = 0xEA; //NOP
// state.memory[4] = 0x09; //ORA #$ff
// state.memory[5] = 0xff;
// state.memory[6] = 0xA9; //LDA
// state.memory[7] = 0x00; //0
// state.memory[8] = 0x0D; //ORA $1234
// state.memory[9] = 0x34;
// state.memory[10] = 0x02;
// state.memory[0xA0] = 0x13;
// state.memory[0x0234] = 0xAA;
//
// for (int i = 0; i < 10; i++) {
// print_all(&state);
// disassemble_6502(state.memory, state.pc);
// emulate_6502_op(&state);
// }
//}