1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-12-21 08:30:55 +00:00

Add struct, initial create function for apple2

This commit is contained in:
Peter Evans 2017-12-06 14:36:14 -06:00
parent 89ddd20658
commit 0e02fb8a1a
4 changed files with 48 additions and 0 deletions

15
include/apple2.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef _APPLE2_H_
#define _APPLE2_H_
#include "mos6502.h"
typedef struct {
/*
* The apple 2 hardware used an MOS-6502 processor.
*/
mos6502 *cpu;
} apple2;
extern apple2 *apple2_create();
#endif

View File

@ -1,4 +1,5 @@
set(emp_sources
apple2.c
log.c
mos6502.c
mos6502.addr.c

20
src/apple2.c Normal file
View File

@ -0,0 +1,20 @@
/*
* apple2.c
*/
#include "apple2.h"
apple2 *
apple2_create()
{
apple2 *mach;
mach = malloc(sizeof(apple2));
if (mach == NULL) {
return NULL;
}
mach->cpu = mos6502_create();
return mach;
}

12
tests/apple2.c Normal file
View File

@ -0,0 +1,12 @@
#include <criterion/criterion.h>
#include "apple2.h"
Test(apple2, create)
{
apple2 *mach;
mach = apple2_create();
cr_assert_neq(mach, NULL);
cr_assert_neq(mach->cpu, NULL);
}