summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2012-08-12 04:35:56 (GMT)
committerH. Peter Anvin <hpa@linux.intel.com>2012-08-12 04:35:56 (GMT)
commit65cb695173f7707a8b776d11d7c4e915b31b0ab2 (patch)
tree82dda5e07fa5da8bd3aa0ab6368fcc62c8416664
parentad4333d9763f709227cbbd20ccd995cac4a1986e (diff)
downloadabc80sim-65cb695173f7707a8b776d11d7c4e915b31b0ab2.zip
abc80sim-65cb695173f7707a8b776d11d7c4e915b31b0ab2.tar.gz
abc80sim-65cb695173f7707a8b776d11d7c4e915b31b0ab2.tar.bz2
abc80sim-65cb695173f7707a8b776d11d7c4e915b31b0ab2.tar.xz
Handle BASIC switching when changing 40/80 columns
-rw-r--r--Makefile10
-rw-r--r--abc80.c30
-rw-r--r--abcrom40.bin (renamed from abcprom)bin16384 -> 16384 bytes
-rw-r--r--abcrom80.binbin0 -> 16384 bytes
-rw-r--r--sdlscrn.c7
-rw-r--r--z80.h1
6 files changed, 25 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index c29acce..4e76c11 100644
--- a/Makefile
+++ b/Makefile
@@ -34,8 +34,10 @@ CC = gcc
CFLAGS = -W -Wall -g -O2 $(DEFINES) -I/usr/X11R6/include -I/usr/include/SDL -DABCDIR=\"$(ABCDIR)\"
LDFLAGS = -g -L/usr/X11R6/lib
-OBJS = abc80.o clock.o sdlscrn.o z80.o abc80_mem.o io.o abcfont.o disk.o z80dis.o
-SRCS = abc80.c clock.c sdlscrn.c z80.c abc80_mem.c io.c abcfont.c disk.c z80dis.c
+PERL = perl
+
+OBJS = abc80.o clock.o sdlscrn.o z80.o abc80_mem.o io.o abcfont.o disk.o z80dis.o abcrom40.o abcrom80.o
+SRCS = abc80.c clock.c sdlscrn.c z80.c abc80_mem.c io.c abcfont.c disk.c z80dis.c abcrom40.c abcrom80.c
HDRS = clock.h screen.h z80.h patchlevel.h
all: abc80
@@ -51,6 +53,10 @@ install: abc80
abc80: $(OBJS)
$(CC) $(LDFLAGS) -o abc80 $(OBJS) -lSDL -lX11 -lpthread
+abcrom40.c: abcrom40.bin bin2c.pl
+ $(PERL) bin2c.pl abcrom40 < $< > $@ || ( rm -f $@ ; false )
+abcrom80.c: abcrom80.bin bin2c.pl
+ $(PERL) bin2c.pl abcrom80 < $< > $@ || ( rm -f $@ ; false )
abc80.o: clock.h screen.h z80.h patchlevel.h
clock.o: clock.h z80.h
diff --git a/abc80.c b/abc80.c
index f5b47a8..8d53d42 100644
--- a/abc80.c
+++ b/abc80.c
@@ -65,15 +65,21 @@ load_sysfile(FILE *sysfile)
* Load the BASIC interpretor into memory
* This is stored as a raw byte-dump.
*/
-static void
-load_basic(FILE *sysfile)
+static int no_basic = 0;
+
+extern const unsigned char abcrom40[16384];
+extern const unsigned char abcrom80[16384];
+
+void load_basic(int mode40)
{
uchar *memory;
+ const unsigned char *rom = mode40 ? abcrom40 : abcrom80;
memory = mem_rom_address();
- fread(memory, sizeof(unsigned char), 0x4000, sysfile);
-}
+ if (!no_basic)
+ memcpy(memory, rom, 16384);
+}
/*
* Print usage message
@@ -93,7 +99,6 @@ int main(int argc, char **argv)
{
char sysfile_name[256];
FILE *sysfile;
- int no_basic = 0;
int no_device = 0;
int c;
@@ -126,21 +131,6 @@ int main(int argc, char **argv)
io_init();
/*
- * Load the BASIC interpretor unless
- * we are asked not to.
- */
- if (!no_basic) {
- sprintf(sysfile_name, "%s/abcprom", ABCDIR);
- if ((sysfile = fopen(sysfile_name, "r")) == NULL) {
- fprintf(stderr, "ABC80: Can't open BAISC file: %s\n",
- sysfile_name);
- exit(1);
- }
- load_basic(sysfile);
- fclose(sysfile);
- }
-
- /*
* Load the device driver code unless
* we are asked not to.
*/
diff --git a/abcprom b/abcrom40.bin
index d7c2203..d7c2203 100644
--- a/abcprom
+++ b/abcrom40.bin
Binary files differ
diff --git a/abcrom80.bin b/abcrom80.bin
new file mode 100644
index 0000000..8d205ab
--- /dev/null
+++ b/abcrom80.bin
Binary files differ
diff --git a/sdlscrn.c b/sdlscrn.c
index bc9293f..1e3e129 100644
--- a/sdlscrn.c
+++ b/sdlscrn.c
@@ -229,6 +229,8 @@ void setmode40(int m)
put_screen(x, y);
update_screen(0,0,width-1,23);
+
+ load_basic(m);
}
}
@@ -280,7 +282,7 @@ void screen_init(void)
}
}
- mode40 = 1;
+ mode40 = 0;
/* Blink timer */
SDL_AddTimer(400, post_periodic, (void *)toggle_blink);
@@ -288,6 +290,9 @@ void screen_init(void)
/* Enable keyboard decoding */
SDL_EnableUNICODE(1);
+ /* Load the appropriate BASIC */
+ load_basic(mode40);
+
return;
}
diff --git a/z80.h b/z80.h
index 4900a61..8fd294b 100644
--- a/z80.h
+++ b/z80.h
@@ -174,6 +174,7 @@ extern int z80_in(int);
extern void io_init(void);
extern int disassemble(int);
extern int DAsm(ushort pc, char *T, int *target);
+extern void load_basic(int);
/*
extern void debug_init();