/* main.c
This file is part of the "First" CPU simulator project.
Copyright (c) 2024 Efthymios Kritikos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
#include
#include
#include "gui.h"
#include "simdata.h"
#include "stdint.h"
int main(){
if(start_gui()){
printf("Failed on start_gui()\n");
return 1;
}
uint8_t *RAM=malloc(16777216); //Maximum addressable memory
if(!RAM){
gui_error("failed to allocate 16MiB of memory for the system ram");
return 1;
}
struct simdata_t *simdata = init_simdata();
if(!simdata){
gui_error("failed to initialise simdata");
return 1;
}
gui_error("failed to initialise simdata");
if(gui_continue_request()){
end_gui();
printf("Failed on gui_continue_request()\n");
free_simdata(simdata);
return 1;
}
if(end_gui()){
printf("Failed on end_gui()\n");
free_simdata(simdata);
return 1;
}
free_simdata(simdata);
free(RAM);
return 0;
}