summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile4
-rw-r--r--src/snap.c17
-rw-r--r--src/snap.h9
-rw-r--r--src/spec.c27
4 files changed, 40 insertions, 17 deletions
diff --git a/src/Makefile b/src/Makefile
index addc749..003f717 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -18,7 +18,7 @@
#
# -------------------------------------------------------------------------
#
-# $Id: Makefile,v 1.9 2004-01-24 01:47:55 ianc Exp $
+# $Id: Makefile,v 1.10 2004-01-24 02:17:57 ianc Exp $
#
@@ -96,7 +96,7 @@ main.o: /usr/local/include/SDL/SDL_keysym.h
main.o: /usr/local/include/SDL/SDL_mouse.h /usr/local/include/SDL/SDL_video.h
main.o: /usr/local/include/SDL/SDL_mutex.h /usr/local/include/SDL/SDL_quit.h
main.o: /usr/local/include/SDL/SDL_version.h z80/z80.h spec.h gfx.h gui.h
-main.o: memmenu.h config.h exit.h util.h
+main.o: memmenu.h config.h kbbmp.h exit.h util.h
spec.o: /usr/include/stdlib.h /usr/include/sys/cdefs.h
spec.o: /usr/include/sys/_types.h /usr/include/machine/_types.h
spec.o: /usr/include/stdio.h /usr/include/string.h /usr/include/strings.h
diff --git a/src/snap.c b/src/snap.c
index c67c0bf..bbc074b 100644
--- a/src/snap.c
+++ b/src/snap.c
@@ -26,6 +26,7 @@
static const char ident[]="$Id$";
#include "snap.h"
+#include "util.h"
static const char ident_h[]=ESPEC_SNAP_H;
@@ -94,7 +95,7 @@ static void PutByte(FILE *fp, Z80Byte b)
/* ---------------------------------------- INTERFACES
*/
-int TAPLoad(FILE *fp, Z80Byte id, Z80Word *addr, Z80Word *len, Z80Byte *mem)
+int TAPLoad(FILE *fp, Z80Byte id, Z80Word *addr, Z80Word *len, SNAP_Poke poke)
{
Z80Word blen;
Z80Byte type,b,csum,tape_csum;
@@ -128,8 +129,7 @@ int TAPLoad(FILE *fp, Z80Byte id, Z80Word *addr, Z80Word *len, Z80Byte *mem)
b=GetByte(fp);
csum^=b;
- if (*addr>=ROMLEN)
- mem[*addr]=b;
+ poke(*addr,b);
(*addr)++;
(*len)--;
@@ -153,6 +153,7 @@ int TAPLoad(FILE *fp, Z80Byte id, Z80Word *addr, Z80Word *len, Z80Byte *mem)
/* Check the checksum
*/
+ Debug("csum = %d, tape csum = %d\n",csum,tape_csum);
return csum==tape_csum;
}
else
@@ -167,7 +168,7 @@ int TAPLoad(FILE *fp, Z80Byte id, Z80Word *addr, Z80Word *len, Z80Byte *mem)
}
-int TAPSave(FILE *fp, Z80Byte id, Z80Word *addr, Z80Word *len, Z80Byte *mem)
+int TAPSave(FILE *fp, Z80Byte id, Z80Word *addr, Z80Word *len, SNAP_Peek peek)
{
Z80Byte csum;
@@ -185,8 +186,12 @@ int TAPSave(FILE *fp, Z80Byte id, Z80Word *addr, Z80Word *len, Z80Byte *mem)
while(*len)
{
- PutByte(fp,mem[*addr]);
- csum^=mem[*addr];
+ Z80Byte b;
+
+ b=peek(*addr);
+
+ PutByte(fp,b);
+ csum^=b;
(*addr)++;
(*len)--;
}
diff --git a/src/snap.h b/src/snap.h
index 04d771a..d1978b6 100644
--- a/src/snap.h
+++ b/src/snap.h
@@ -35,18 +35,21 @@
/* ---------------------------------------- INTERFACES
*/
+typedef Z80Byte (*SNAP_Peek)(Z80Word address);
+typedef void (*SNAP_Poke)(Z80Word address, Z80Byte val);
+
+
/* Loads a block from a TAP file. Returns FALSE for failure.
- Won't write below location 0x4000 in mem.
*/
int TAPLoad(FILE *fp, Z80Byte id, Z80Word *addr,
- Z80Word *len, Z80Byte *mem);
+ Z80Word *len, SNAP_Poke poke);
/* Saves a block to a TAP file. Returns FALSE for failure
(which it never does as long as fp is not NULL).
*/
int TAPSave(FILE *fp, Z80Byte id, Z80Word *addr,
- Z80Word *len, Z80Byte *mem);
+ Z80Word *len, SNAP_Peek peek);
/* Copies a string. The result must be freed.
diff --git a/src/spec.c b/src/spec.c
index 7f0bd7f..1fba973 100644
--- a/src/spec.c
+++ b/src/spec.c
@@ -244,6 +244,19 @@ static void DumpZ80(Z80 *z80)
/* ---------------------------------------- PRIVATE FUNCTIONS
*/
+static Z80Byte Peek(Z80Word addr)
+{
+ return mem[addr];
+}
+
+
+static void Poke(Z80Word addr, Z80Byte val)
+{
+ if (addr>=ROMLEN)
+ mem[addr]=val;
+}
+
+
void DrawScanlineAt(int y, int sline)
{
int aline;
@@ -339,13 +352,13 @@ static int EDCallback(Z80 *z80, Z80Val data)
}
else
{
- if (TAPSave(tape_out,HIBYTE(state.AF),&state.IX,&state.DE,mem))
+ if (TAPSave(tape_out,HIBYTE(state.AF),&state.IX,&state.DE,Peek))
{
- state.AF&=~eZ80_Carry;
+ state.AF|=eZ80_Carry;
}
else
{
- state.AF|=eZ80_Carry;
+ state.AF&=~eZ80_Carry;
}
}
break;
@@ -357,13 +370,13 @@ static int EDCallback(Z80 *z80, Z80Val data)
}
else
{
- if (TAPLoad(tape_in,HIBYTE(state.AF),&state.IX,&state.DE,mem))
+ if (TAPLoad(tape_in,HIBYTE(state.AF),&state.IX,&state.DE,Poke))
{
- state.AF&=~eZ80_Carry;
+ state.AF|=eZ80_Carry;
}
else
{
- state.AF|=eZ80_Carry;
+ state.AF&=~eZ80_Carry;
}
}
break;
@@ -595,6 +608,8 @@ const Z80Label *SPECGetLabel(void)
{
static const Z80Label label[]=
{
+ {0x04c6, "SAVE"},
+ {0x0562, "LOAD"},
{0x5c00, "KSTATE"},
{0x5c01, "KSTATE+1"},
{0x5c02, "KSTATE+2"},