Ara pilla el .BAS de la linea de comandos. Arreglada release version de Windows
This commit is contained in:
12
main.cpp
12
main.cpp
@@ -39,20 +39,30 @@ unsigned char input_data_out() {
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
vm_init("test.bas");
|
||||
// Inicialitzar la m<>quina virtual (li arriba el arxiu amb el programa per linea de comandos)
|
||||
vm_init(argc < 2 ? nullptr : argv[1]); // "test.bas"
|
||||
|
||||
// Inicialitzar el procesador gr<67>fic
|
||||
vdp_init();
|
||||
|
||||
// Registrar els ports d'entrada i eixida del procesador gr<67>fic
|
||||
vm_register_out_port(10, vdp_data_out);
|
||||
vm_register_out_port(11, vdp_cmd_out);
|
||||
vm_register_in_port(12, vdp_in);
|
||||
|
||||
// Registrar els ports d'entrada i eixida del dispositiu d'entrada (teclat, en cas del emu)
|
||||
vm_register_out_port(20, input_data_in);
|
||||
vm_register_in_port(21, input_data_out);
|
||||
|
||||
// Inicialitzar el procesador de s<>
|
||||
sound_init();
|
||||
|
||||
// Registrar els ports d'entrada i eixida del procesador de s<>
|
||||
vm_register_out_port(30, sound_data_out);
|
||||
vm_register_out_port(31, sound_cmd_out);
|
||||
vm_register_in_port(32, sound_in);
|
||||
|
||||
// Inicialitzem el depurador del emulador
|
||||
debug_init(vm_get_memory());
|
||||
const bool* breakpoints = debug_get_breakpoints();
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>C:\dev\lib\sdl2\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\dev\lib\sdl2\lib\x86;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -76,6 +78,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
||||
35
vm.cpp
35
vm.cpp
@@ -48,28 +48,33 @@ static void load_rom() {
|
||||
}
|
||||
|
||||
static void load_program(const char* filename) {
|
||||
FILE *f = fopen(filename, "rb");
|
||||
fseek(f, 0, SEEK_END);
|
||||
long fsize = ftell(f);
|
||||
fseek(f, 0, SEEK_SET); //same as rewind(f);
|
||||
char *program = (char*)malloc(fsize + 1);
|
||||
fread(program, fsize, 1, f);
|
||||
fclose(f);
|
||||
program[fsize] = 0;
|
||||
if (filename == nullptr) {
|
||||
error_raise("No file specified");
|
||||
} else {
|
||||
FILE *f = fopen(filename, "rb");
|
||||
if (f == nullptr) {
|
||||
error_raise("File not found");
|
||||
} else {
|
||||
fseek(f, 0, SEEK_END);
|
||||
long fsize = ftell(f);
|
||||
fseek(f, 0, SEEK_SET); //same as rewind(f);
|
||||
char *program = (char*)malloc(fsize + 1);
|
||||
fread(program, fsize, 1, f);
|
||||
fclose(f);
|
||||
program[fsize] = 0;
|
||||
|
||||
register_constants();
|
||||
register_constants();
|
||||
|
||||
parser_parse(program, mem);
|
||||
free(program);
|
||||
parser_parse(program, mem);
|
||||
free(program);
|
||||
}
|
||||
}
|
||||
|
||||
if (error_raised()) {
|
||||
vm_pc = 0xA000;
|
||||
//error_print(&mem[0xA000]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
printf("Compilation complete!\nProgram size: %d bytes\nMemory usage: %d bytes\n", parser_get_codesize(), parser_get_memory_usage());
|
||||
/*FILE *f = fopen("test.bin", "wb");
|
||||
if (f == nullptr) perror("Error");// printf("Error: %d (%s)\n", errno, strerror(errno));
|
||||
fwrite(rawCode, parser_get_codesize(), 1, f);
|
||||
fclose(f);*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user