Corewar documentation 1.0.0
|
The header of the corewar project. More...
Go to the source code of this file.
Data Structures | |
struct | cell_s |
The cell structure. More... | |
struct | champion_s |
The champion structure. More... | |
struct | corewar_s |
The corewar structure. More... | |
Macros | |
#define | COREWAR_H_ |
#define | CHAMPION ((champion_t *)tmp->data) |
#define | ARENA_LINE_NUMBER 96 |
Typedefs | |
typedef struct cell_s | cell_t |
The cell structure. | |
typedef struct champion_s | champion_t |
The champion structure. | |
typedef struct corewar_s | corewar_t |
The corewar structure. | |
Functions | |
corewar_t * | get_corewar (void) |
Get the corewar structure. | |
void | free_corewar (void) |
Free the corewar structure and all the memory allocated. | |
int | corewar (void) |
The virtual machine of the corewar. | |
int | parse_args (int argc, char **argv) |
Parse the arguments. | |
int | get_next_champion_number (void) |
Get the next champion number disponible. | |
int | champion_number_exist (int number) |
Check if a champion number exist. | |
int | analyse_champions (void) |
Analyse each champion files and complete the champion structure. | |
champion_t * | get_champion_by_number (int number) |
Get a champion by its number. | |
void | update_program_counter (champion_t *champion, int value) |
Update the program counter of a champion. | |
void | update_carry (champion_t *champion, int value) |
Update the carry of a champion. | |
char * | read_file (char *filepath, int size, int start) |
Read a file and return the content. | |
int | get_prog_size (char *header) |
Get the program size. | |
int | is_valid_magic (char *header) |
Check if the magic number is valid. | |
int | build_arena (void) |
Build the arena. | |
void | display_arena (void) |
Display the arena. | |
node_t * | get_arena_node (int address) |
Get the arena node from an address. | |
void | check_alive_champions (void) |
Check if the champions are alive. | |
void | display_winner (node_t *champions) |
Display the winner. | |
int | check_champions_number (node_t *champions) |
Check the number of champions. | |
void | execute_instructions (champion_t *champion) |
Execute the instructions. | |
int | get_int_from_address (node_t *address, int size) |
Get int from address. | |
void | write_int_in_address (champion_t *champion, node_t *address, int value) |
Write int in address. | |
int | read_int_in_address (node_t *address, int size) |
Read int in address. | |
char | get_code_byte_index (char coding_byte, int index) |
Get the type of byte with the coding byte at the index. | |
char | get_size_from_type (char type, bool max_size) |
Get the size of the type. | |
char | get_size_of_coding_byte (char coding_byte, bool max_size) |
Get the size of the coding byte. | |
void | exec_add (champion_t *champion, node_t *address) |
The add function. | |
void | exec_aff (champion_t *champion, node_t *address) |
The aff function. | |
void | exec_and (champion_t *champion, node_t *address) |
The and function. | |
void | exec_fork (champion_t *champion, node_t *address) |
The fork function. | |
void | exec_ld (champion_t *champion, node_t *address) |
The ld function. | |
void | exec_ldi (champion_t *champion, node_t *address) |
The ldi function. | |
void | exec_lfork (champion_t *champion, node_t *address) |
The lfork function. | |
void | exec_live (champion_t *champion, node_t *address) |
The live function. | |
void | exec_lld (champion_t *champion, node_t *address) |
The lld function. | |
void | exec_lldi (champion_t *champion, node_t *address) |
The lldi function. | |
void | exec_or (champion_t *champion, node_t *address) |
The or function. | |
void | exec_st (champion_t *champion, node_t *address) |
The st function. | |
void | exec_sti (champion_t *champion, node_t *address) |
The sti function. | |
void | exec_sub (champion_t *champion, node_t *address) |
The sub function. | |
void | exec_xor (champion_t *champion, node_t *address) |
The xor function. | |
void | exec_zjmp (champion_t *champion, node_t *address) |
The zjmp function. | |
void | update_max_visual_index (corewar_t *corewar) |
Update the max visual index. | |
int | check_touch (corewar_t *corewar) |
Check the touch. | |
void | init_display (corewar_t *corewar) |
Initialize the display. | |
void | set_color (int address, char *owner) |
Set the color of the texte. | |
void | display_corewar (corewar_t *corewar) |
Display the corewar. | |
The header of the corewar project.
int analyse_champions | ( | void | ) |
Analyse each champion files and complete the champion structure.
int build_arena | ( | void | ) |
Build the arena.
int champion_number_exist | ( | int | number | ) |
Check if a champion number exist.
number | The champion number |
void check_alive_champions | ( | void | ) |
Check if the champions are alive.
int check_champions_number | ( | node_t * | champions | ) |
Check the number of champions.
champions | The champions list |
int check_touch | ( | corewar_t * | corewar | ) |
Check the touch.
corewar | The corewar structure |
int corewar | ( | void | ) |
The virtual machine of the corewar.
void display_arena | ( | void | ) |
Display the arena.
void display_corewar | ( | corewar_t * | corewar | ) |
Display the corewar.
corewar | The corewar structure |
void display_winner | ( | node_t * | champions | ) |
Display the winner.
champions | The champions list |
void exec_add | ( | champion_t * | champion, |
node_t * | address ) |
The add function.
champion | The champion to execute the add function |
address | The address of the add function |
void exec_aff | ( | champion_t * | champion, |
node_t * | address ) |
The aff function.
champion | The champion to execute the aff function |
address | The address of the aff function |
void exec_and | ( | champion_t * | champion, |
node_t * | address ) |
The and function.
champion | The champion to execute the and function |
address | The address of the and function |
void exec_fork | ( | champion_t * | champion, |
node_t * | address ) |
The fork function.
champion | The champion to execute the fork function |
address | The address of the fork function |
void exec_ld | ( | champion_t * | champion, |
node_t * | address ) |
The ld function.
champion | The champion to execute the ld function |
address | The address of the ld function |
void exec_ldi | ( | champion_t * | champion, |
node_t * | address ) |
The ldi function.
champion | The champion to execute the ldi function |
address | The address of the ldi function |
void exec_lfork | ( | champion_t * | champion, |
node_t * | address ) |
The lfork function.
champion | The champion to execute the lfork function |
address | The address of the lfork function |
void exec_live | ( | champion_t * | champion, |
node_t * | address ) |
The live function.
champion | The champion to execute the live function |
address | The address of the live function |
void exec_lld | ( | champion_t * | champion, |
node_t * | address ) |
The lld function.
champion | The champion to execute the lld function |
address | The address of the lld function |
void exec_lldi | ( | champion_t * | champion, |
node_t * | address ) |
The lldi function.
champion | The champion to execute the lldi function |
address | The address of the lldi function |
void exec_or | ( | champion_t * | champion, |
node_t * | address ) |
The or function.
champion | The champion to execute the or function |
address | The address of the or function |
void exec_st | ( | champion_t * | champion, |
node_t * | address ) |
The st function.
champion | The champion to execute the st function |
address | The address of the st function |
void exec_sti | ( | champion_t * | champion, |
node_t * | address ) |
The sti function.
champion | The champion to execute the sti function |
address | The address of the sti function |
void exec_sub | ( | champion_t * | champion, |
node_t * | address ) |
The sub function.
champion | The champion to execute the sub function |
address | The address of the sub function |
void exec_xor | ( | champion_t * | champion, |
node_t * | address ) |
The xor function.
champion | The champion to execute the xor function |
address | The address of the xor function |
void exec_zjmp | ( | champion_t * | champion, |
node_t * | address ) |
The zjmp function.
champion | The champion to execute the zjmp function |
address | The address of the zjmp function |
void execute_instructions | ( | champion_t * | champion | ) |
Execute the instructions.
champion | The champion to execute the instructions |
void free_corewar | ( | void | ) |
Free the corewar structure and all the memory allocated.
node_t * get_arena_node | ( | int | address | ) |
Get the arena node from an address.
address | The address of the node |
champion_t * get_champion_by_number | ( | int | number | ) |
Get a champion by its number.
number | The champion number |
char get_code_byte_index | ( | char | coding_byte, |
int | index ) |
Get the type of byte with the coding byte at the index.
coding_byte | The coding byte to get the index |
index | The index of the coding byte value |
corewar_t * get_corewar | ( | void | ) |
Get the corewar structure.
int get_int_from_address | ( | node_t * | address, |
int | size ) |
Get int from address.
address | The address to get the int |
size | The size of the int |
int get_next_champion_number | ( | void | ) |
Get the next champion number disponible.
int get_prog_size | ( | char * | header | ) |
Get the program size.
header | The header of the program |
char get_size_from_type | ( | char | type, |
bool | max_size ) |
Get the size of the type.
type | The type to get the size |
max_size | The max size of the type |
char get_size_of_coding_byte | ( | char | coding_byte, |
bool | max_size ) |
Get the size of the coding byte.
coding_byte | The coding byte to get the size |
max_size | The max size of the coding byte |
void init_display | ( | corewar_t * | corewar | ) |
Initialize the display.
corewar | The corewar structure |
int is_valid_magic | ( | char * | header | ) |
Check if the magic number is valid.
header | The header of the program |
int parse_args | ( | int | argc, |
char ** | argv ) |
Parse the arguments.
argc | The number of arguments |
argv | The arguments |
char * read_file | ( | char * | filepath, |
int | size, | ||
int | start ) |
Read a file and return the content.
filepath | The file path |
size | The size of the bytes to read |
start | The start of the reading |
int read_int_in_address | ( | node_t * | address, |
int | size ) |
Read int in address.
address | The address to read the int |
size | The size of the int |
void set_color | ( | int | address, |
char * | owner ) |
Set the color of the texte.
address | The address of the cell |
owner | The owner of the cell |
void update_carry | ( | champion_t * | champion, |
int | value ) |
Update the carry of a champion.
champion | The champion to update |
value | The value to check |
void update_max_visual_index | ( | corewar_t * | corewar | ) |
Update the max visual index.
corewar | The corewar structure |
void update_program_counter | ( | champion_t * | champion, |
int | value ) |
Update the program counter of a champion.
champion | The champion to update |
value | The value to add to the program counter |
void write_int_in_address | ( | champion_t * | champion, |
node_t * | address, | ||
int | value ) |
Write int in address.
champion | The champion to write the int |
address | The address to write the int |
value | The value to write |