aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2012-05-09 00:03:40 +0000
committerDimitri Sokolyuk <demon@dim13.org>2012-05-09 00:03:40 +0000
commit11129399de73cd03a914ee7ddc2dd641feb83f21 (patch)
treea2e051cf27f4d4156613d48e6e791c983dac90a0
parent625200d796e6652e084ad44563234868a87b697e (diff)
devices stub
-rw-r--r--Makefile3
-rw-r--r--clock.c50
-rw-r--r--dcpu16.h15
3 files changed, 58 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 7040e7b..bdf821e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,8 @@
# $Id$
PROG= dcpu
-SRCS= gramar.y lexer.l emu.c main.c tui.c gui.c y.tab.h
+SRCS= gramar.y lexer.l emu.c main.c tui.c gui.c y.tab.h \
+ lem1802.c keyboard.c clock.c
NOMAN=
CFLAGS+=`sdl-config --cflags`
LDADD+= `sdl-config --libs` -lcurses -lSDL_image
diff --git a/clock.c b/clock.c
new file mode 100644
index 0000000..15ae242
--- /dev/null
+++ b/clock.c
@@ -0,0 +1,50 @@
+/* $Id$ */
+/*
+ * Copyright (c) 2012 Dimitri Sokolyuk <demon@dim13.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, dATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include "dcpu16.h"
+
+enum { CLK_ON,
+ CLK_STORE,
+ CLK_INTR,
+};
+
+void
+clk(struct context *c)
+{
+ switch (c->reg[A]) {
+ case CLK_ON:
+ break;
+ case CLK_STORE:
+ break;
+ case CLK_INTR:
+ break;
+ default:
+ break;
+ }
+}
+
+void
+register_clk(struct context *c)
+{
+ struct device *d = &c->dev[++c->ndev];
+
+ d->id = 0x12d0b402;
+ d->version = 0x1;
+ d->manu = 0;
+ d->cb = clk;
+}
diff --git a/dcpu16.h b/dcpu16.h
index 084ca22..9a47624 100644
--- a/dcpu16.h
+++ b/dcpu16.h
@@ -47,18 +47,15 @@ enum { NOP, JSR, BRK,
struct context {
unsigned short mem[MEMSZ];
unsigned short reg[nReg];
- struct device *dev;
+ struct device {
+ unsigned int id;
+ unsigned int version;
+ unsigned int manu;
+ void (*cb)(struct context *);
+ } dev[256];
int ndev;
};
-struct device {
- unsigned int id;
- unsigned int version;
- unsigned int manufacturer;
- void (*cb)(struct context *);
- struct device *next;
-};
-
/* display: 32x12 (128x96) + 16 pixel boarder, font 8x4 */
int compile(FILE *, unsigned short *, size_t);