Beginning to refactor memory.S -> vm.c

This commit is contained in:
Aaron Culliney 2014-05-10 11:25:35 -07:00
parent 25cd542a2c
commit 9ff453be23
6 changed files with 75 additions and 65 deletions

View File

@ -58,7 +58,7 @@ EXTRA_apple2ix_SOURCES = \
\
$(META_SRC)
apple2ix_SOURCES = src/font.c src/misc.c src/display.c \
apple2ix_SOURCES = src/font.c src/misc.c src/display.c src/vm.c \
src/timing.c src/zlib-helpers.c src/joystick.c src/keys.c src/prefs.c \
src/disk.c src/cpu-supp.c
@ -72,7 +72,7 @@ genfont_SOURCES = src/genfont.c
src/font.c: src/font.txt genfont
./genfont < $< > $@
src/asm386/glue.S: src/disk.c src/misc.c src/display.c @AUDIO_GLUE_C@
src/asm386/glue.S: src/disk.c src/misc.c src/display.c src/vm.c @AUDIO_GLUE_C@
./src/asm386/genglue $^ > $@
###############################################################################

View File

@ -149,43 +149,6 @@
enabled.
----------------------------------------------------------------- */
/* ram_nop, read_ram_default, write_ram_default: default ram/rom
read/write functions. */
E(ram_nop)
ret
E(read_unmapped_softswitch)
movb SN(apple_ii_64k)(,EffectiveAddr_E,1), %al
ret
E(write_unmapped_softswitch)
ret
E(read_keyboard)
movb SN(apple_ii_64k)+0xC000, %al
ret
E(read_keyboard_strobe)
andb $0x7f, SN(apple_ii_64k)+0xC000
andb $0x7f, SN(apple_ii_64k)+0x1C000
movb SN(apple_ii_64k)+0xC000, %al /* HACK: necessary? */
ret
E(read_random)
pushal
call SN(c_read_random)
popal
movb SN(random_value), %al
ret
E(read_speaker_toggle_pc)
#ifdef AUDIO_ENABLED
pushal
call SN(SpkrToggle)
popal // FIXME, do we need to set %al to something here?
#endif
ret
/* PAGE2 off. if 80STORE on then we use main text page1, and if HIRES
on we also use main hires page1, regardless of RAMRD and
RAMWRT. */

View File

@ -1712,14 +1712,12 @@ WORD VideoGetScannerAddress(bool* pbVblBar_OUT, const DWORD uExecutedCycles)
}
*/
extern void c_read_random();
extern uint8_t random_value;
extern uint8_t c_read_random(uint16_t);
static uint8_t MemReadFloatingBus(const unsigned long uExecutedCycles)
{
//return*(LPBYTE)(mem + VideoGetScannerAddress(NULL, uExecutedCycles));
// HUGE HACK FIXME TODO
c_read_random();
return random_value;
return c_read_random(0x0);
}
#define nCyclesLeft cpu65_cycle_count

View File

@ -64,8 +64,8 @@ uint8_t *base_d000_wrt;
uint8_t *base_e000_wrt;
uint8_t *base_c3rom;
void *base_c4rom;
void *base_c5rom;
uint8_t *base_c4rom;
uint8_t *base_c5rom;
uint8_t *base_cxrom;
@ -554,7 +554,7 @@ void c_initialize_sound_hooks()
{
cpu65_vmem[i].r = cpu65_vmem[i].w =
#ifdef AUDIO_ENABLED
(sound_volume > 0) ? read_speaker_toggle_pc :
(sound_volume > 0) ? speaker_toggle :
#endif
ram_nop;
}
@ -698,16 +698,6 @@ GLUE_C_READ(read_gc1)
return 0xFF;
}
// HACK FIXME TODO : candidate for GLUE_C_READ(...)
void c_read_random() {
static time_t seed=0;
if (!seed) {
seed = time(NULL);
srandom(seed);
}
random_value = (unsigned char)random();
}
#if !defined(TESTING)
static void main_thread(void *dummyptr) {
struct timespec sleeptime = { .tv_sec=0, .tv_nsec=8333333 }; // 120Hz

View File

@ -40,13 +40,10 @@ extern const unsigned char lcase_glyphs[0x100];
extern const unsigned char mousetext_glyphs[0x100];
extern const unsigned char interface_glyphs[88];
unsigned char apple_ii_64k[2][65536]; /* 128k memory */
uint8_t apple_ii_64k[2][65536]; /* 128k memory */
/* language card memory and settings */
unsigned char language_card[2][8192], language_banks[2][8192];
/* misc stuff */
uint8_t random_value;
uint8_t language_card[2][8192], language_banks[2][8192];
/* global ref to commandline args */
char **argv;
@ -73,8 +70,8 @@ extern uint8_t *base_d000_wrt;
extern uint8_t *base_e000_wrt;
extern uint8_t *base_c3rom;
extern void *base_c4rom; // points to function or memory vector
extern void *base_c5rom; // points to function or memory vector
extern uint8_t *base_c4rom; // points to function or memory vector
extern uint8_t *base_c5rom; // points to function or memory vector
extern uint8_t *base_cxrom;
/* softswitches */
@ -126,7 +123,6 @@ void c_initialize_sound_hooks();
void c_disable_sound_hooks();
void c_initialize_font();
void c_initialize_vm();
void c_read_random();
void reinitialize();
/* virtual memory compacter */
@ -144,7 +140,7 @@ read_random(),
read_unmapped_softswitch(),
read_keyboard(),
read_keyboard_strobe(),
read_speaker_toggle_pc(),
speaker_toggle(),
read_switch_graphics(),
read_switch_text(),
read_switch_no_mixed(),

63
src/vm.c Normal file
View File

@ -0,0 +1,63 @@
/*
* Apple // emulator for *nix
*
* 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.
*
*/
/*
* Apple //e VM Routines
*
*/
#include "common.h"
GLUE_C_READ(ram_nop)
{
return 0x0;
}
GLUE_C_READ(read_unmapped_softswitch)
{
return apple_ii_64k[0][ea];
}
GLUE_C_WRITE(write_unmapped_softswitch)
{
// ...
}
GLUE_C_READ(read_keyboard)
{
return apple_ii_64k[0][0xC000];
}
GLUE_C_READ(read_keyboard_strobe)
{
apple_ii_64k[0][0xC000] &= 0x7F;
apple_ii_64k[1][0xC000] &= 0x7F;
return apple_ii_64k[0][0xC000];
}
GLUE_C_READ(read_random)
{
static time_t seed=0;
if (!seed) {
seed = time(NULL);
srandom(seed);
}
return (random() % UINT_MAX);
}
GLUE_C_READ(speaker_toggle)
{
#ifdef AUDIO_ENABLED
SpkrToggle();
#endif
return 0;
}