Work in Progress

This commit is contained in:
Stefan Arentz 2016-11-22 16:01:29 -05:00
parent 15be191d05
commit cd04241e39
3 changed files with 143 additions and 5 deletions

26
ewm.c
View File

@ -28,7 +28,9 @@
#include <string.h>
#include "cpu.h"
#include "dsk.h"
#include "mem.h"
#include "mmu.h"
#include "pia.h"
// Apple 1 / 8K RAM / WOZ Monitor
@ -61,6 +63,19 @@ static int setup_apple2plus(struct cpu_t *cpu) {
return 0;
}
// Apple IIe / 128K RAM / Original ROMs
static int setup_apple2e(struct cpu_t *cpu) {
struct ewm_mmu_t *mmu = malloc(sizeof(struct ewm_mmu_t));
mmu_init(mmu, cpu);
struct ewm_dsk_t *dsk = malloc(sizeof(struct ewm_dsk_t));
dsk_init(dsk);
dsk_set_disk_file(dsk, 1, "disks/DOS33-SystemMaster.dsk");
dsk_set_disk_file(dsk, 2, "disks/DOS33-SamplePrograms.dsk");
mmu_insert_card(mmu, 6, &dsk->card);
return 0;
}
// Machine Setup
typedef int (*ewm_machine_setup_f)(struct cpu_t *cpu);
@ -72,10 +87,11 @@ struct ewm_machine_t {
};
static struct ewm_machine_t machines[] = {
{ "apple1", "Apple 1", setup_apple1 },
{ "replica1", "Replica 1", setup_replica1 },
{ "apple2plus", "Apple ][+", setup_apple2plus },
{ NULL, NULL, NULL }
{ "apple1", "Apple 1", setup_apple1 },
{ "replica1", "Replica 1", setup_replica1 },
{ "apple2plus", "Apple ][+", setup_apple2plus },
{ "apple2e", "Apple IIe", setup_apple2e },
{ NULL, NULL, NULL }
};
static struct option options[] = {
@ -118,7 +134,7 @@ int main(int argc, char **argv) {
argv += optind;
if (machine == NULL) {
fprintf(stderr, "Usage: ewm --machine apple1|replica1|apple2plus\n");
fprintf(stderr, "Usage: ewm --machine apple1|replica1|apple2plus|apple2e\n");
exit(1);
}

78
mmu.c Normal file
View File

@ -0,0 +1,78 @@
// The MIT License (MIT)
//
// Copyright (c) 2015 Stefan Arentz - http://github.com/st3fan/ewm
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <stdint.h>
#include "cpu.h"
#include "mem.h"
#include "mmu.h"
//
// This file implements the Apple IIe MMU. The MMU replaces most
// memory related logic on older models. It is an integrated chip that
// can do bank switching, manage memory access, etc. It is really the
// central hub.
//
// It manages all system RAM and ROM by taking ownership of the
// complete address space. It also provides hooks to manage the
// extension slots.
//
// The MMU implements an Apple IIe Extended 80-Column Card. There is
// no way to turn this off.
//
// We implement a modern Apple IIe memory map as follows:
//
//
// $C100 - $C2FF (49408 - 49919): Extensions to System Monitor
// $C300 - $C3FF (49920 - 50175): 80-Column Display Routines
// $C400 - $C7FF (50176 - 51199): Self-Test Routines
// $C800 - $CFFF (51200 - 53247): More 80-Column Display Routines
// $D000 - $F7FF (53248 - 63487): Applesoft Interpreter
// $F800 - $FFFF (63488 - 65535): System Monitor
// $D000 - $DFFF (53248 - 57343): Bank-Switched RAM (2 Banks RAM, 1 Bank ROM)
// $E000 - $FFFF (57344 - 65535): Bank-Switched RAM (1 Bank RAM, 1 Bank ROM)
//
static uint8_t mmu_read(struct cpu_t *cpu, struct mem_t *mem, uint16_t addr);
static void mmu_write(struct cpu_t *cpu, struct mem_t *mem, uint16_t addr, uint8_t b);
// Public API
void mmu_init(struct ewm_mmu_t *mmu, struct cpu_t *cpu) {
cpu_add_iom(cpu, 0x0000, 0xffff, mmu, mmu_read, mmu_write);
}
void mmu_insert_card(struct ewm_mmu_t *mmu, uint8_t index, struct ewm_crd_t *card) {
}
void mmu_remove_card(struct ewm_mmu_t *mmu, uint8_t index) {
}
// Private API
static uint8_t mmu_read(struct cpu_t *cpu, struct mem_t *mem, uint16_t addr) {
return 0;
}
static void mmu_write(struct cpu_t *cpu, struct mem_t *mem, uint16_t addr, uint8_t b) {
}

44
mmu.h Normal file
View File

@ -0,0 +1,44 @@
// The MIT License (MIT)
//
// Copyright (c) 2015 Stefan Arentz - http://github.com/st3fan/ewm
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef EWM_MMU_H
#define EWM_MMU_H
#include <stdint.h>
struct cpu_t;
struct mem_t;
struct ewm_crd_t {
int x;
};
struct ewm_mmu_t {
int x;
};
void mmu_init(struct ewm_mmu_t *mmu, struct cpu_t *cpu);
void mmu_insert_card(struct ewm_mmu_t *mmu, uint8_t index, struct ewm_crd_t *card);
void mmu_remove_card(struct ewm_mmu_t *mmu, uint8_t index);
#endif // EWM_MMU_H