From 11129399de73cd03a914ee7ddc2dd641feb83f21 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 9 May 2012 00:03:40 +0000 Subject: devices stub --- Makefile | 3 ++- clock.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ dcpu16.h | 15 ++++++--------- 3 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 clock.c 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 + * + * 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 +#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); -- cgit v1.2.3