diff --git a/Makefile.am b/Makefile.am index 48f3d0b1..f68a78f9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,9 +28,8 @@ noinst_PROGRAMS = genfont bin_PROGRAMS = apple2ix -VM_SRC = \ - src/asm386/glue.S src/asm386/cpu.S src/asm386/display.S \ - src/asm386/memory.S +ASM_SRC = \ + src/asm386/glue.S src/asm386/cpu.S src/asm386/display.S INTERFACE_CLASSIC_SRC = \ src/interface.c @@ -48,7 +47,7 @@ META_SRC = \ # NOTE : selectively enabled through configuration process ... EXTRA_apple2ix_SOURCES = \ - $(VM_SRC) \ + $(ASM_SRC) \ \ $(INTERFACE_CLASSIC_SRC) \ \ @@ -64,8 +63,8 @@ apple2ix_SOURCES = src/font.c src/misc.c src/display.c src/vm.c \ apple2ix_CFLAGS = @AM_CFLAGS@ @X_CFLAGS@ apple2ix_LDFLAGS = @ARCHOS_HACK_LDFLAGS@ -apple2ix_LDADD = @VM_O@ @INTERFACE_O@ @VIDEO_O@ @AUDIO_O@ @META_O@ @X_LIBS@ -apple2ix_DEPENDENCIES = @VM_O@ @INTERFACE_O@ @VIDEO_O@ @AUDIO_O@ @META_O@ +apple2ix_LDADD = @ASM_O@ @INTERFACE_O@ @VIDEO_O@ @AUDIO_O@ @META_O@ @X_LIBS@ +apple2ix_DEPENDENCIES = @ASM_O@ @INTERFACE_O@ @VIDEO_O@ @AUDIO_O@ @META_O@ genfont_SOURCES = src/genfont.c @@ -86,22 +85,22 @@ A2_TEST_CFLAGS = -DTESTING=1 -Isrc/greatest TESTS = testcpu testdisplay testvm check_PROGRAMS = testcpu testdisplay testvm -testcpu_SOURCES = src/test/testcpu.c $(A2_TEST_SOURCES) $(VM_SRC) $(META_SRC) $(VIDEO_SRC) +testcpu_SOURCES = src/test/testcpu.c $(A2_TEST_SOURCES) $(ASM_SRC) $(META_SRC) $(VIDEO_SRC) testcpu_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -UAUDIO_ENABLED -UINTERFACE_CLASSIC -DHEADLESS=1 testcpu_LDFLAGS = $(apple2ix_LDFLAGS) -testcpu_DEPENDENCIES = @VM_O@ @META_O@ +testcpu_DEPENDENCIES = @ASM_O@ @META_O@ -testdisplay_SOURCES = src/test/testdisplay.c $(A2_TEST_SOURCES) $(VM_SRC) $(META_SRC) $(VIDEO_SRC) +testdisplay_SOURCES = src/test/testdisplay.c $(A2_TEST_SOURCES) $(ASM_SRC) $(META_SRC) $(VIDEO_SRC) # HACK FIXME TODO NOTE: why don't these CFLAGS here pass down to the .S and .c files in the subdirectories? testdisplay_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -UAUDIO_ENABLED -UINTERFACE_CLASSIC -DHEADLESS=0 testdisplay_LDFLAGS = $(apple2ix_LDFLAGS) -testdisplay_DEPENDENCIES = @VM_O@ @META_O@ @VIDEO_O@ +testdisplay_DEPENDENCIES = @ASM_O@ @META_O@ @VIDEO_O@ -testvm_SOURCES = src/test/testvm.c $(A2_TEST_SOURCES) $(VM_SRC) $(META_SRC) $(VIDEO_SRC) +testvm_SOURCES = src/test/testvm.c $(A2_TEST_SOURCES) $(ASM_SRC) $(META_SRC) $(VIDEO_SRC) # HACK FIXME TODO NOTE: why don't these CFLAGS here pass down to the .S and .c files in the subdirectories? testvm_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -UAUDIO_ENABLED -UINTERFACE_CLASSIC -DHEADLESS=0 testvm_LDFLAGS = $(apple2ix_LDFLAGS) -testvm_DEPENDENCIES = @VM_O@ @META_O@ @VIDEO_O@ +testvm_DEPENDENCIES = @ASM_O@ @META_O@ @VIDEO_O@ ############################################################################### # Misc diff --git a/configure.ac b/configure.ac index b0eb7bf7..78236b1d 100644 --- a/configure.ac +++ b/configure.ac @@ -76,8 +76,8 @@ dnl at this point we believe arch/os is good ... ARCHOS_HACK_LDFLAGS="-L/usr/lib/i386-linux-gnu -L/lib/i386-linux-gnu" AC_SUBST(ARCHOS_HACK_LDFLAGS) -VM_O="src/asm386/glue.o src/asm386/cpu.o src/asm386/display.o src/asm386/memory.o" -AC_SUBST(VM_O) +ASM_O="src/asm386/glue.o src/asm386/cpu.o src/asm386/display.o" +AC_SUBST(ASM_O) dnl --------------------------------------------------------------------------- diff --git a/src/asm386/cpu.S b/src/asm386/cpu.S index eca9e3f3..36ad4fd1 100644 --- a/src/asm386/cpu.S +++ b/src/asm386/cpu.S @@ -138,7 +138,7 @@ movb SN(cpu65_current)+5, Y_Reg; \ movb SN(cpu65_current)+6, SP_Reg_L; \ movl SN(base_stackzp), %eax; \ - subl $SN(apple_ii_64k), %eax; \ + subl $SN(apple_ii_64k), %eax; /* $ for pointer addr */ \ orl %eax, SP_Reg; \ xorl %eax, %eax; diff --git a/src/asm386/memory.S b/src/asm386/memory.S deleted file mode 100644 index 73950e1c..00000000 --- a/src/asm386/memory.S +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Apple // emulator for Linux: - * Functions for memory-access indirection table. - * - * 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 "apple2.h" -#include "cpu.h" -#include "misc.h" - - /* -------------------------------------------------------------------- - .................................................................... - Apple ][+ Memory documentation (//e differs mostly in softswitches) - - I use two jump tables; one for get_memory and one for set_memory - respectively. The jump tables contain exactly 64k entries to - avoid unnecessary range checking. Furthermore, special access - or to serve memory mapped I/O services are easily obtained by - patching the jump table with various routines. - - Apple 64k address space: - - (Two byte addresses are represented with least significant - byte first, e.g. address FA59 is represented as 59 FA) - - Address Description - - 0000 - 00FF Zero page RAM - 0100 - 01FF Stack - 0200 - 03EF RAM - 03F0 - 03F1 Address for BRK instruction - (normally 59 FA = FA59) - 03F2 - 03F3 Soft entry vector (normally BF 9D = 9DBF) - 03F4 Power-up byte - 03F5 - 03F7 Jump instruction to the subroutine which - handles Applesoft II &-commands - (normally 4C 58 FF = JMP FF58) - 03F8 - 03FA Jump instruction to the subroutine which - handles User CTRL-Y commands - (normally 4C 65 FF = JMP FF65) - 03FB - 03FD Jump instruction to the subroutine which - handles Non-Maskable Interrupts (NMI) - (normally 4C 65 FF = JMP FF65) - 03FE - 03FF Address of the subroutine which handles - Interrupt ReQuests (IRQ) - (normally 65 FF = FF65) - 0400 - 07FF Basically primary video text page - 0478 - 047F I/O Scratchpad RAM Addresses for Slot 0 - 7 - 04F8 - 04FF - " " - - 0578 - 057F - " " - - 05F8 - 05FF - " " - - 0678 - 067F - " " - - 06F8 - 06FF - " " - - 0778 - 077F - " " - - 07F8 - 07FF - " " - - ----- These two addresses are pretty strange; the values - provided were inconsistent at least on my Apple II - 05F8 Holds the slot number of the disk - controller card from which DOS was - booted. - 07F8 Holds the slot number (CX, X = Slot #) - of the slot that is currently active. - - 0800 - 0BFF Basically secondary video text page - - 0C00 - 1FFF Plain RAM - 2000 - 3FFF Primary video hires page (RAM) - 4000 - 5FFF Secondary video Hi-Res page (RAM) - 6000 - BFFF Plain RAM - (Normally the operating system is - loaded into ~= 9C00 - BFFF) - C000 - C00F Keyboard data - (C00X contains the character ASCII - code of the pressed key. The - value is available at any C00X - address) - C010 - C01F Clear Keyboard strobe - C020 - C02F Cassette output toggle - C030 - C03F Speaker toggle - C040 - C04F Utility strobe - C050 Set graphics mode - C051 Set text mode - C052 Set all text or graphics - C053 Mix text and graphics - C054 Display primary page - C055 Display secondary page - C056 Display low-res graphics - C057 Display hi-res graphics - C058 - C05F Annunciator outputs - C060 Cassette input - C061 - C063 Pushbutton inputs (button 1, 2 and 3) - C064 - C067 Game controller inputs - C068 - C06F Same as C060 - C067 - C070 - C07F Game controller strobe - C080 - C08F Slot 0 I/O space (usually a language card) - --- If language card - C080 Reset language card - Read mode enabled - Write mode disabled - Read from language card - Write to ROM (impossible of course) - C081 --- First access - Read mode disabled - Read from ROM - --- On second access - Write mode enabled - Write to language card - C082 --- (Disable language card) - Read mode disabled - Write mode disabled - Read from ROM - Write to ROM - C083 --- First access - Read mode enabled - Read from language card - --- On second access - Write mode enabled - Write to language card - C088 - C08B Same as C080 - C083, but - switch to second bank, i.e. - map addresses D000-DFFF to - other 4k area. - C100 - C1FF Slot 1 PROM - C200 - C2FF Slot 2 PROM - C300 - C3FF Slot 3 PROM - C400 - C4FF Slot 4 PROM - C500 - C5FF Slot 5 PROM - C600 - C6FF Slot 6 PROM - C700 - C7FF Slot 7 PROM - C800 - CFFF Expansion ROM (for peripheral cards) - CFFF Disable access to expansion ROM for - ALL peripheral cards. - D000 - DFFF ROM or 4k RAM if language card is - enabled. However, there are TWO 4k - banks that can be mapped onto addresses - D000 - DFFF. See C088 - C08B. - E000 - FFFF ROM or 8k RAM if language card is - enabled. - ----------------------------------------------------------------- */ - -return80: movb $0x80,%al - ret - -/* HACK!!!!! - how does the expansion slot get referenced? need to handle other roms requesting to use this area!!!! */ -E(iie_read_slot_expansion) -#if 0 -/* HACK FIXME TODO NOTE: why is this a problematic pattern? - Shouldn't it be the same result as the original? The mov (%eax), %eax appears suspicious ... -*/ - movl $SN(apple_ii_64k), %eax - addl $c8rom_offset, %eax - addl EffectiveAddr_E, %eax - movzbl (%eax), %eax - ret -#endif - orl SN(c8rom_offset), EffectiveAddr_E - movb SN(apple_ii_64k)(,EffectiveAddr_E,1), %al - andl $0xFFFF, EffectiveAddr_E - ret - -/* HACK!!!!! - how does the expansion slot get referenced? */ -E(iie_disable_slot_expansion) - ret - diff --git a/src/misc.c b/src/misc.c index 7651c688..9c4e5257 100644 --- a/src/misc.c +++ b/src/misc.c @@ -555,7 +555,6 @@ void c_initialize_iie_switches() { base_c3rom = apple_ii_64k[1]; /* c3rom internal */ base_c4rom = apple_ii_64k[1]; /* c4rom internal */ base_c5rom = apple_ii_64k[1]; /* c5rom internal */ - c8rom_offset = 0x10000; /* c8rom internal */ base_cxrom = apple_ii_64k[0]; /* cxrom peripheral */ } diff --git a/src/misc.h b/src/misc.h index dac80432..5febc7c5 100644 --- a/src/misc.h +++ b/src/misc.h @@ -53,9 +53,6 @@ int argc; #define TEMPSIZE 4096 char temp[ TEMPSIZE ]; /* should be >=4096 (stuff depends on this) */ -/* memory offsets from softswitches */ -int c8rom_offset; - extern uint8_t *base_ramrd; extern uint8_t *base_ramwrt; extern uint8_t *base_textrd; @@ -121,6 +118,8 @@ extern uint32_t softswitches; void c_initialize_firsttime(); void c_initialize_sound_hooks(); void c_disable_sound_hooks(); +void c_set_primary_char(); +void c_set_altchar(); void c_initialize_font(); void c_initialize_vm(); void reinitialize(); diff --git a/src/vm.c b/src/vm.c index 3048addf..c66bc219 100644 --- a/src/vm.c +++ b/src/vm.c @@ -9,10 +9,107 @@ * */ -/* - * Apple //e VM Routines - * - */ +/* ---------------------------------------------------------------------------- + Apple //e 64K VM + + (Two byte addresses are represented with least significant + byte first, e.g. address FA59 is represented as 59 FA) + + This is not meant to be definitive. + Verify against _Understanding the Apple IIe_ by Jim Sather + + Address Description + ----------- ----------- + 0000 - 00FF Zero page RAM + 0100 - 01FF Stack + 0200 - 03EF RAM + 03F0 - 03F1 Address for BRK instruction (normally 59 FA = FA59) + 03F2 - 03F3 Soft entry vector (normally BF 9D = 9DBF) + 03F4 Power-up byte + 03F5 - 03F7 Jump instruction to the subroutine which handles + Applesoft II &-commands (normally 4C 58 FF = JMP FF58) + 03F8 - 03FA Jump instruction to the subroutine which handles User + CTRL-Y commands (normally 4C 65 FF = JMP FF65) + 03FB - 03FD Jump instruction to the subroutine which handles + Non-Maskable Interrupts (NMI) (normally 4C 65 FF = JMP FF65) + 03FE - 03FF Address of the subroutine which handles Interrupt + ReQuests (IRQ) (normally 65 FF = FF65) + 0400 - 07FF Basically primary video text page + 0478 - 047F I/O Scratchpad RAM Addresses for Slot 0 - 7 + 04F8 - 04FF - " " - + 0578 - 057F - " " - + 05F8 - 05FF - " " - + 0678 - 067F - " " - + 06F8 - 06FF - " " - + 0778 - 077F - " " - + 07F8 - 07FF - " " - + 05F8 Holds the slot number of the disk controller card from + which DOS was booted. ??? VERIFY... + 07F8 Holds the slot number (CX, X = Slot #) of the slot that + is currently active. ??? VERIFY... + 0800 - 0BFF Secondary video text page + 0C00 - 1FFF Plain RAM + 2000 - 3FFF Primary video hires page (RAM) + 4000 - 5FFF Secondary video hires page (RAM) + 6000 - BFFF Plain RAM (Normally the OS is loaded into ~9C00 - BFFF) + C000 - C00F Keyboard data (C00X contains the character ASCII code of + the pressed key. The value is available at any C00X address) + C010 - C01F Clear Keyboard strobe + C020 - C02F Cassette output toggle + C030 - C03F Speaker toggle + C040 - C04F Utility strobe + C050 Set graphics mode + C051 Set text mode + C052 Set all text or graphics + C053 Mix text and graphics + C054 Display primary page + C055 Display secondary page + C056 Display low-res graphics + C057 Display hi-res graphics + C058 - C05F Annunciator outputs + C060 Cassette input + C061 - C063 Pushbutton inputs (button 1, 2 and 3) + C064 - C067 Game controller inputs + C068 - C06F Same as C060 - C067 + C070 - C07F Game controller strobe + C080 - C08F Slot 0 I/O space (usually a language card) + C080 Reset language card + * Read enabled + * Write disabled + * Read from language card + C081 --- First access + * Read mode disabled + * Read from ROM + --- On second+ access + * Write mode enabled + * Write to language card + C082 --- (Disable language card) + * Read mode disabled + * Write mode disabled + * Read from ROM + C083 --- First access + * Read mode enabled + * Read from language card + --- On second+ access + * Write mode enabled + * Write to language card + C088 - C08B Same as C080 - C083, but switch to second bank, i.e. + map addresses D000-DFFF to other 4K area. + C100 - C1FF Slot 1 PROM + C200 - C2FF Slot 2 PROM + C300 - C3FF Slot 3 PROM + C400 - C4FF Slot 4 PROM + C500 - C5FF Slot 5 PROM + C600 - C6FF Slot 6 PROM + C700 - C7FF Slot 7 PROM + C800 - CFFF Expansion ROM (for peripheral cards) + CFFF Disable access to expansion ROM for + ALL peripheral cards. + D000 - DFFF ROM or 4K RAM if language card is enabled. However, + there are TWO 4K banks that can be mapped onto addresses + D000 - DFFF. See C088 - C08B. + E000 - FFFF ROM or 8K RAM if language card is enabled. +---------------------------------------------------------------------------- */ #include "common.h" @@ -832,3 +929,17 @@ GLUE_C_READ(iie_check_cxrom) return (softswitches & SS_CXROM) ? 0x80 : 0x00; } +GLUE_C_READ(iie_read_slot_expansion) +{ + // HACK TODO FIXME : how does the expansion slot get referenced? Need to handle other ROMs that might use this area + // ... Also Need moar tests ... + return apple_ii_64k[1][ea]; +} + +GLUE_C_READ(iie_disable_slot_expansion) +{ + // HACK TODO FIXME : how does the expansion slot get referenced? Need to handle other ROMs that might use this area + // ... Also Need moar tests ... + return 0x0; +} +