mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-06-17 12:29:31 +00:00
remove compact.c for simplicity
This commit is contained in:
parent
e919718b73
commit
f462f79708
12
src/Makefile
12
src/Makefile
|
@ -75,7 +75,7 @@ EXTRA_PROGRAMS = apple2 xapple2 xapple2-80col
|
|||
bin_PROGRAMS = xapple2 xapple2-80col
|
||||
|
||||
EXTRA_apple2_SOURCES = debugger.c opcodes.c debug.c joystick.c
|
||||
apple2_SOURCES = cpu.S memory.S display.S glue.S keys.c prefs.c disk.c interface.c misc.c font.c svideo.c compact.c cpu-supp.c vidsup.c timing.c
|
||||
apple2_SOURCES = cpu.S memory.S display.S glue.S keys.c prefs.c disk.c interface.c misc.c font.c svideo.c cpu-supp.c vidsup.c timing.c
|
||||
|
||||
|
||||
apple2_LDADD = joystick.o -lvga
|
||||
|
@ -83,7 +83,7 @@ apple2_DEPENDENCIES = joystick.o
|
|||
|
||||
EXTRA_xapple2_SOURCES = debugger.c opcodes.c debug.c joystick.c
|
||||
|
||||
xapple2_SOURCES = cpu.S memory.S display.S glue.S keys.c prefs.c disk.c interface.c misc.c font.c xvideo.c compact.c cpu-supp.c vidsup.c timing.c
|
||||
xapple2_SOURCES = cpu.S memory.S display.S glue.S keys.c prefs.c disk.c interface.c misc.c font.c xvideo.c cpu-supp.c vidsup.c timing.c
|
||||
|
||||
|
||||
xapple2_LDADD = joystick.o -L/usr/lib/i386-linux-gnu -lX11 -lXext -lrt
|
||||
|
@ -91,7 +91,7 @@ xapple2_DEPENDENCIES = joystick.o
|
|||
|
||||
EXTRA_xapple2_80col_SOURCES = debugger.c opcodes.c debug.c joystick.c
|
||||
|
||||
xapple2_80col_SOURCES = cpu.S memory.S glue.S keys.c prefs.c disk.c font.c compact.c cpu-supp.c misc.c interface.c timing.c
|
||||
xapple2_80col_SOURCES = cpu.S memory.S glue.S keys.c prefs.c disk.c font.c cpu-supp.c misc.c interface.c timing.c
|
||||
|
||||
|
||||
xapple2_80col_LDADD = joystick.o vidsup-80.o xvideo-80.o display-80.o -L/usr/lib/i386-linux-gnu -lX11 -lXext -lrt
|
||||
|
@ -119,11 +119,11 @@ X_CFLAGS =
|
|||
X_LIBS =
|
||||
X_EXTRA_LIBS =
|
||||
X_PRE_LIBS = -lSM -lICE
|
||||
apple2_OBJECTS = cpu.o memory.o display.o glue.o keys.o prefs.o disk.o debugger.o opcodes.o debug.o interface.o misc.o font.o svideo.o compact.o cpu-supp.o vidsup.o timing.o
|
||||
apple2_OBJECTS = cpu.o memory.o display.o glue.o keys.o prefs.o disk.o debugger.o opcodes.o debug.o interface.o misc.o font.o svideo.o cpu-supp.o vidsup.o timing.o
|
||||
apple2_LDFLAGS =
|
||||
xapple2_OBJECTS = cpu.o memory.o display.o glue.o keys.o prefs.o disk.o debugger.o opcodes.o debug.o interface.o misc.o font.o xvideo.o compact.o cpu-supp.o vidsup.o timing.o
|
||||
xapple2_OBJECTS = cpu.o memory.o display.o glue.o keys.o prefs.o disk.o debugger.o opcodes.o debug.o interface.o misc.o font.o xvideo.o cpu-supp.o vidsup.o timing.o
|
||||
xapple2_LDFLAGS =
|
||||
xapple2_80col_OBJECTS = cpu.o memory.o glue.o keys.o prefs.o disk.o debugger.o opcodes.o debug.o font.o compact.o cpu-supp.o misc.o interface.o timing.o
|
||||
xapple2_80col_OBJECTS = cpu.o memory.o glue.o keys.o prefs.o disk.o debugger.o opcodes.o debug.o font.o cpu-supp.o misc.o interface.o timing.o
|
||||
xapple2_80col_LDFLAGS =
|
||||
genfont_SOURCES = genfont.c
|
||||
genfont_OBJECTS = genfont.o
|
||||
|
|
179
src/compact.c
179
src/compact.c
|
@ -1,179 +0,0 @@
|
|||
/*
|
||||
* Apple // emulator for Linux: Memory optimizer
|
||||
*
|
||||
* Copyright 1994 Alexander Jean-Claude Bottema
|
||||
* Copyright 1995 Stephen Lee
|
||||
* Copyright 1997, 1998 Aaron Culliney
|
||||
* Copyright 1998, 1999, 2000 Michael Deutschmann
|
||||
*
|
||||
* This software package is subject to the GNU General Public License
|
||||
* version 2 or later (your choice) as published by the Free Software
|
||||
* Foundation.
|
||||
*
|
||||
* THERE ARE NO WARRANTIES WHATSOEVER.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "misc.h"
|
||||
#include "cpu.h"
|
||||
|
||||
/* This code is not essential to emulator operation. It (ab)uses the
|
||||
* virtual-memory system so that repetitive parts of the memory-access
|
||||
* indirection table are compressed. This should hopefully relieve load
|
||||
* on the processor's cache and boost speed.
|
||||
*
|
||||
* This file is far more complicated than it needs to be. For the present
|
||||
* purpose --- emulating an Apple // series machine on an 386 box --- I
|
||||
* could have hard-wired the compaction specifically for the Apple layout and
|
||||
* i386 page size.
|
||||
*
|
||||
* But it's more flexible - it needs no change to be used in an emulator
|
||||
* for Nintendo, C64, etc. Support for host processors with different
|
||||
* page sizes will just be matter of changing the PSIZE and TPAGES macros.
|
||||
*
|
||||
*/
|
||||
|
||||
#define TSIZE 524288 /* Size of the entire table */
|
||||
#define PSIZE 4096 /* Size of a page */
|
||||
#define TPAGES 128 /* pages in table */
|
||||
|
||||
#ifndef HAVE_MMAP
|
||||
|
||||
void precompact(void){}
|
||||
void compact(void){}
|
||||
|
||||
#else /* HAVE_MMAP */
|
||||
|
||||
static int compaction_file = -1;
|
||||
|
||||
void pre_compact(void)
|
||||
{
|
||||
const char *tmpdir;
|
||||
char *filename;
|
||||
char *x;
|
||||
|
||||
/* Destroy any old mapping file */
|
||||
close(compaction_file);
|
||||
|
||||
/* Reset the mapping on the table to normal, in case compaction has
|
||||
* been done before. This also tests if the kernel is advanced enough
|
||||
* to support this stunt.
|
||||
*/
|
||||
x = mmap((void *) cpu65_vmem,
|
||||
TSIZE,
|
||||
PROT_READ|PROT_WRITE,
|
||||
MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE,
|
||||
0,
|
||||
0);
|
||||
|
||||
if (x == MAP_FAILED)
|
||||
{
|
||||
/* mmap failed.
|
||||
* For now we assume this is because we are running on a system
|
||||
* which doesn't support cookie-cutter mmap operations.
|
||||
*
|
||||
* We set compaction_file to -1 and return. This tells compact to
|
||||
* do nothing. (The emu still works.)
|
||||
*/
|
||||
printf("System does not appear to support fancy mmap\n"
|
||||
"(error: %m)\n");
|
||||
|
||||
compaction_file = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create a fresh new mapping file */
|
||||
tmpdir = getenv("TMPDIR");
|
||||
if (!tmpdir) tmpdir = "/tmp";
|
||||
filename = alloca(strlen(tmpdir) + 9);
|
||||
strcpy(filename,tmpdir);
|
||||
strcat(filename,"/a2-XXXXXX");
|
||||
compaction_file = mkstemp(filename);
|
||||
|
||||
if (!compaction_file)
|
||||
{
|
||||
fprintf(stderr,"cannot open temporary file (%m)\n");
|
||||
exit(EXIT_FAILURE);
|
||||
};
|
||||
|
||||
unlink(filename);
|
||||
if (ftruncate(compaction_file,TSIZE) == -1) { /* might not be 100% portable */
|
||||
// ERROR ...
|
||||
}
|
||||
|
||||
/* If the ftruncate doesn't work (Single Unix does not require it
|
||||
* to work for the extending case), try this instead:
|
||||
*
|
||||
* lseek(compaction_file,TSIZE-1,SEEK_SET);
|
||||
* write(compaction_file,"",1);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void compact(void)
|
||||
{
|
||||
int i,j,n;
|
||||
char *work;
|
||||
char *x;
|
||||
|
||||
/* Give up if the first mmap didn't work out */
|
||||
if (compaction_file == -1) return;
|
||||
|
||||
work = mmap(0,
|
||||
TSIZE,
|
||||
PROT_READ|PROT_WRITE,
|
||||
MAP_FILE|MAP_SHARED,
|
||||
compaction_file,
|
||||
0);
|
||||
|
||||
if (work == MAP_FAILED)
|
||||
{
|
||||
fprintf(stderr,"mmap failure (%m)");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
n = 0;
|
||||
i = TPAGES;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
j = n;
|
||||
while (j-- && memcmp(work+j*PSIZE,
|
||||
((void *) cpu65_vmem)+i*PSIZE,
|
||||
PSIZE));
|
||||
if (j == -1)
|
||||
{
|
||||
memcpy(work+n*PSIZE,
|
||||
((void *) cpu65_vmem)+i*PSIZE,
|
||||
PSIZE);
|
||||
j = n++;
|
||||
}
|
||||
|
||||
x = mmap(((void *) cpu65_vmem)+i*PSIZE,
|
||||
PSIZE,
|
||||
PROT_READ|PROT_WRITE,
|
||||
MAP_FIXED|MAP_FILE|MAP_SHARED,
|
||||
compaction_file,
|
||||
j*PSIZE);
|
||||
if (x == MAP_FAILED) {
|
||||
// ERROR
|
||||
}
|
||||
|
||||
if (work == MAP_FAILED)
|
||||
{
|
||||
fprintf(stderr,"mmap failure (%m)");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
munmap(work,TSIZE);
|
||||
|
||||
}
|
||||
|
||||
#endif /* HAVE_MMAP */
|
|
@ -125,8 +125,6 @@ void c_initialize_tables() {
|
|||
|
||||
int i;
|
||||
|
||||
pre_compact(); /* Prepare for VM compression */
|
||||
|
||||
/* reset everything */
|
||||
for (i = 0; i < 0x10000; i++)
|
||||
{
|
||||
|
@ -547,12 +545,9 @@ void c_initialize_tables() {
|
|||
iie_disable_slot_expansion;
|
||||
#endif
|
||||
|
||||
video_set(0); /* must be done here, between pre_compact & compact */
|
||||
video_set(0);
|
||||
|
||||
disk_install(6); /* Put a Disk ][ Controller in slot 6 */
|
||||
|
||||
compact(); /* Compress memory so that identical pages share storage */
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user