From 5ae0f154bd925c050e37b572ea30b51b09e8b569 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sun, 3 Sep 2006 22:27:04 +0000 Subject: Extra sanity checks on start-up. --- z80.h | 7 ++++--- z80_decode.c | 10 ++++++++++ z80_private.h | 1 - 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/z80.h b/z80.h index 9683e3f..af0017b 100644 --- a/z80.h +++ b/z80.h @@ -44,20 +44,21 @@ typedef struct Z80 Z80; typedef unsigned long Z80Val; -/* 8-bit type +/* 8-bit type. The emulation will exit with code 2 if this isn't 8 bits. */ typedef unsigned char Z80Byte; -/* 8-bit signed type +/* 8-bit signed type. The emulation will exit with code 2 if this isn't 8 bits. */ typedef signed char Z80Relative; -/* 16-bit type +/* 16-bit type. The emulation will exit with code 2 if this isn't 16 bits. */ typedef unsigned short Z80Word; + /* Memory */ typedef Z80Byte Z80Memory[0x10000]; diff --git a/z80_decode.c b/z80_decode.c index 4b6929c..81760ae 100644 --- a/z80_decode.c +++ b/z80_decode.c @@ -27,6 +27,7 @@ */ #include +#include #include "z80.h" #include "z80_private.h" @@ -71,6 +72,8 @@ void Z80_InitialiseInternals(void) Z80Word f; Z80Reg r; + /* Check endianness + */ r.w=0x1234; if (r.b[0] == 0x12) @@ -88,6 +91,13 @@ void Z80_InitialiseInternals(void) exit(1); } + /* Check variable sizes + */ + if (CHAR_BIT!=8 || sizeof(Z80Word)!=2) + { + exit(2); + } + /* Initialise flag tables */ for(f=0;f<256;f++) diff --git a/z80_private.h b/z80_private.h index 58b9584..2797a8a 100644 --- a/z80_private.h +++ b/z80_private.h @@ -42,7 +42,6 @@ /* ---------------------------------------- TYPES */ - typedef union { Z80Word w; -- cgit v1.2.3