Skip to content

Commit

Permalink
Merge pull request #534 from udo-munk/dev
Browse files Browse the repository at this point in the history
merge dev
  • Loading branch information
udo-munk authored Jan 29, 2025
2 parents b522adf + 57cfeca commit 8f50e92
Show file tree
Hide file tree
Showing 63 changed files with 5,568 additions and 359 deletions.
15 changes: 13 additions & 2 deletions altairsim/srcsim/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
MACHINE = altair
# emulate a machine's frontpanel
FRONTPANEL ?= YES
# show an introspection panel
INFOPANEL ?= YES
# use SDL2 instead of X11
WANT_SDL ?= NO
# machine specific system source files
Expand Down Expand Up @@ -47,11 +49,16 @@ VPATH = $(CORE_DIR) $(IO_DIR) $(FP_DIR)
include $(CORE_DIR)/Makefile.in-os

###
### SDL2/X11 PLATFORM VARIABLES
### SDL2/X11 AND INFOPANEL PLATFORM VARIABLES
###
ifeq ($(WANT_SDL),YES)
ifeq ($(INFOPANEL),YES)
PLAT_DEFS = -DINFOPANEL -DWANT_SDL
PLAT_SRCS = simpanel.c simsdl.c
else
PLAT_DEFS = -DWANT_SDL
PLAT_SRCS = simsdl.c
endif
ifeq ($(TARGET_OS),BSD)
PLAT_INCS = -I/usr/local/include/SDL2
PLAT_LDFLAGS = -L/usr/local/lib
Expand All @@ -66,6 +73,10 @@ PLAT_LDFLAGS = -Wl,-search_paths_first -Wl,-headerpad_max_install_names \
PLAT_LDLIBS = -framework SDL2
endif
else
ifeq ($(INFOPANEL),YES)
PLAT_DEFS = -DINFOPANEL
PLAT_SRCS = simpanel.c
endif
ifeq ($(TARGET_OS),BSD)
PLAT_INCS = -I/usr/local/include
PLAT_LDFLAGS = -L/usr/local/lib
Expand All @@ -79,7 +90,7 @@ PLAT_LDLIBS = -lX11
endif
endif
###
### END SDL2/X11 PLATFORM VARIABLES
### END SDL2/X11 AND INFOPANEL PLATFORM VARIABLES
###

###
Expand Down
39 changes: 23 additions & 16 deletions altairsim/srcsim/simctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
#include "log.h"
static const char *TAG = "system";

/* cpu_switch states */
#define CPUSW_STOP 0 /* stopped */
#define CPUSW_RUN 1 /* running */
#define CPUSW_STEP 2 /* single step */
#define CPUSW_STEPCYCLE 3 /* machine cycle step */

static BYTE fp_led_wait;
static int cpu_switch;
static int reset;
Expand Down Expand Up @@ -190,14 +196,14 @@ void mon(void)

/* run CPU if not idling */
switch (cpu_switch) {
case 1:
case CPUSW_RUN:
if (!reset)
run_cpu();
break;
case 2:
case CPUSW_STEP:
step_cpu();
if (cpu_switch == 2)
cpu_switch = 0;
if (cpu_switch == CPUSW_STEP)
cpu_switch = CPUSW_STOP;
break;
default:
break;
Expand Down Expand Up @@ -274,16 +280,16 @@ static void run_clicked(int state, int val)
switch (state) {
case FP_SW_DOWN:
if (cpu_state != ST_CONTIN_RUN) {
cpu_state = ST_CONTIN_RUN;
cpu_state = ST_STOPPED; /* get out of ST_SINGLE_STEP */
fp_led_wait = 0;
cpu_switch = 1;
cpu_switch = CPUSW_RUN;
}
break;
case FP_SW_UP:
if (cpu_state == ST_CONTIN_RUN) {
cpu_state = ST_STOPPED;
fp_led_wait = 1;
cpu_switch = 0;
cpu_switch = CPUSW_STOP;
}
break;
default:
Expand All @@ -306,7 +312,7 @@ static void step_clicked(int state, int val)

switch (state) {
case FP_SW_UP:
cpu_switch = 2;
cpu_switch = CPUSW_STEP;
break;
case FP_SW_DOWN:
break;
Expand All @@ -333,9 +339,9 @@ bool wait_step(void)
return ret;
}

cpu_switch = 3;
cpu_switch = CPUSW_STEPCYCLE;

while ((cpu_switch == 3) && !reset) {
while ((cpu_switch == CPUSW_STEPCYCLE) && !reset) {
/* when INP update data bus LEDs */
if (cpu_bus == (CPU_WO | CPU_INP)) {
if (port_in[fp_led_address & 0xff])
Expand All @@ -344,7 +350,7 @@ bool wait_step(void)
}
fp_clock++;
fp_sampleData();
sleep_for_ms(1);
sleep_for_ms(10);
ret = true;
}

Expand All @@ -361,9 +367,9 @@ void wait_int_step(void)
if (cpu_state != ST_SINGLE_STEP)
return;

cpu_switch = 3;
cpu_switch = CPUSW_STEPCYCLE;

while ((cpu_switch == 3) && !reset) {
while ((cpu_switch == CPUSW_STEPCYCLE) && !reset) {
fp_clock++;
fp_sampleData();
sleep_for_ms(10);
Expand Down Expand Up @@ -401,7 +407,8 @@ static void reset_clicked(int state, int val)
/* update front panel */
fp_led_address = PC;
fp_led_data = fp_read(PC);
if ((p_tab[PC] == MEM_RO) || (p_tab[PC] == MEM_WPROT))
if ((p_tab[PC >> 8] == MEM_RO) ||
(p_tab[PC >> 8] == MEM_WPROT))
mem_wp = 1;
else
mem_wp = 0;
Expand Down Expand Up @@ -572,7 +579,7 @@ static void power_clicked(int state, int val)
if (!power)
break;
power = 0;
cpu_switch = 0;
cpu_switch = CPUSW_STOP;
cpu_state = ST_STOPPED;
cpu_error = POWEROFF;
break;
Expand All @@ -587,7 +594,7 @@ static void power_clicked(int state, int val)
static void quit_callback(void)
{
power = 0;
cpu_switch = 0;
cpu_switch = CPUSW_STOP;
cpu_state = ST_STOPPED;
cpu_error = POWEROFF;
}
Expand Down
5 changes: 5 additions & 0 deletions altairsim/srcsim/simio.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ void init_io(void)
/* create local sockets */
init_unix_server_socket(&ucons[0], "altairsim.tape");
init_unix_server_socket(&ucons[1], "altairsim.sio2");

altair_sio_reset();
altair_2sio_reset();
}

/*
Expand Down Expand Up @@ -191,6 +194,8 @@ void reset_io(void)
cromemco_dazzler_off();
tarbell_reset();
altair_dsk_reset();
altair_sio_reset();
altair_2sio_reset();
}

#if 0 /* currently not used */
Expand Down
12 changes: 12 additions & 0 deletions altairsim/srcsim/simmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#endif
#ifdef FRONTPANEL
#include "simctl.h"
#include "simport.h"
#include "frontpanel.h"
#endif

Expand Down Expand Up @@ -73,6 +74,10 @@ extern void init_memory(void);
*/
static inline void memwrt(WORD addr, BYTE data)
{
#ifdef FRONTPANEL
uint64_t t;
#endif

#ifdef BUS_8080
#ifndef FRONTPANEL
cpu_bus &= ~CPU_M1;
Expand All @@ -82,11 +87,13 @@ static inline void memwrt(WORD addr, BYTE data)

#ifdef FRONTPANEL
if (F_flag) {
t = get_clock_us();
fp_clock++;
fp_led_address = addr;
fp_led_data = 0xff;
fp_sampleData();
wait_step();
cpu_tadj += get_clock_us() - t;
} else
cpu_bus &= ~CPU_M1;
#endif
Expand All @@ -105,6 +112,9 @@ static inline void memwrt(WORD addr, BYTE data)
static inline BYTE memrdr(WORD addr)
{
register BYTE data;
#ifdef FRONTPANEL
uint64_t t;
#endif

#ifdef WANT_HB
if (hb_flag && hb_addr == addr) {
Expand Down Expand Up @@ -144,11 +154,13 @@ static inline BYTE memrdr(WORD addr)

#ifdef FRONTPANEL
if (F_flag) {
t = get_clock_us();
fp_clock++;
fp_led_address = addr;
fp_led_data = data;
fp_sampleData();
wait_step();
cpu_tadj += get_clock_us() - t;
} else
cpu_bus &= ~CPU_M1;
#endif
Expand Down
54 changes: 49 additions & 5 deletions cpmsim/srcsim/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# (simple) machine name - will be suffixed with 'sim'
# and the executable saved as '../machinesim'
MACHINE = cpm
# show an introspection panel
INFOPANEL ?= NO
# use SDL2 instead of X11
WANT_SDL ?= NO
# machine specific system source files
MACHINE_SRCS = simcfg.c simio.c simmem.c simctl.c
# machine specific I/O source files
Expand Down Expand Up @@ -37,8 +41,48 @@ VPATH = $(CORE_DIR) $(IO_DIR)

include $(CORE_DIR)/Makefile.in-os

DEFS = -DCONFDIR=\"$(CONF_DIR)\" -DDISKSDIR=\"$(DISKS_DIR)\"
INCS = -I. -I$(CORE_DIR) -I$(IO_DIR)
###
### SDL2/X11 INFOPANEL PLATFORM VARIABLES
###
ifeq ($(INFOPANEL),YES)
ifeq ($(WANT_SDL),YES)
PLAT_DEFS = -DINFOPANEL -DWANT_SDL
PLAT_SRCS = simpanel.c simsdl.c
ifeq ($(TARGET_OS),BSD)
PLAT_INCS = -I/usr/local/include/SDL2
PLAT_LDFLAGS = -L/usr/local/lib
PLAT_LDLIBS = -lSDL2 -lSDL2main
else ifeq ($(TARGET_OS),LINUX)
PLAT_INCS = -I/usr/include/SDL2
PLAT_LDLIBS = -lSDL2 -lSDL2main
else ifeq ($(TARGET_OS),OSX)
PLAT_INCS = -F/Library/Frameworks -I/Library/Frameworks/SDL2.framework/Headers
PLAT_LDFLAGS = -Wl,-search_paths_first -Wl,-headerpad_max_install_names \
-Wl,-rpath,/Library/Frameworks
PLAT_LDLIBS = -framework SDL2
endif
else
PLAT_DEFS = -DINFOPANEL
PLAT_SRCS = simpanel.c
ifeq ($(TARGET_OS),BSD)
PLAT_INCS = -I/usr/local/include
PLAT_LDFLAGS = -L/usr/local/lib
PLAT_LDLIBS = -lX11 -lpthread
else ifeq ($(TARGET_OS),LINUX)
PLAT_LDLIBS = -lX11 -lpthread
else ifeq ($(TARGET_OS),OSX)
PLAT_INCS = -I/opt/X11/include -I/opt/local/include -I/usr/local/include
PLAT_LDFLAGS = -L/opt/X11/lib -L/usr/local/lib
PLAT_LDLIBS = -lX11 -lpthread
endif
endif
endif
###
### END INFOPANEL SDL2/X11 PLATFORM VARIABLES
###

DEFS = -DCONFDIR=\"$(CONF_DIR)\" -DDISKSDIR=\"$(DISKS_DIR)\" $(PLAT_DEFS)
INCS = -I. -I$(CORE_DIR) -I$(IO_DIR) $(PLAT_INCS)
CPPFLAGS = $(DEFS) $(INCS)

CSTDS = -std=c99 -D_DEFAULT_SOURCE # -D_XOPEN_SOURCE=700L
Expand All @@ -59,8 +103,8 @@ endif

CFLAGS = $(CSTDS) $(COPTS) $(CWARNS)

LDFLAGS =
LDLIBS =
LDFLAGS = $(PLAT_LDFLAGS)
LDLIBS = $(PLAT_LDLIBS)

INSTALL = install
INSTALL_PROGRAM = $(INSTALL)
Expand All @@ -70,7 +114,7 @@ INSTALL_DATA = $(INSTALL) -m 644
CORE_SRCS = sim8080.c simcore.c simdis.c simfun.c simglb.c simice.c simint.c \
simmain.c simz80.c simz80-cb.c simz80-dd.c simz80-ddcb.c simz80-ed.c \
simz80-fd.c simz80-fdcb.c
SRCS = $(CORE_SRCS) $(MACHINE_SRCS) $(IO_SRCS)
SRCS = $(CORE_SRCS) $(MACHINE_SRCS) $(IO_SRCS) $(PLAT_SRCS)
OBJS = $(SRCS:.c=.o)
DEPS = $(SRCS:.c=.d)

Expand Down
5 changes: 4 additions & 1 deletion cpmsim/srcsim/simio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2076,8 +2076,11 @@ static BYTE speedl_in(void)
static void speedh_out(BYTE data)
{
speed += data << 8;
tmax = speed * 10000;
f_value = speed;
if (f_value)
tmax = speed * 10000;
else
tmax = 100000;
}

/*
Expand Down
15 changes: 13 additions & 2 deletions cromemcosim/srcsim/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
MACHINE = cromemco
# emulate a machine's frontpanel
FRONTPANEL ?= YES
# show an introspection panel
INFOPANEL ?= YES
# use SDL2 instead of X11
WANT_SDL ?= NO
# machine specific system source files
Expand Down Expand Up @@ -54,11 +56,16 @@ VPATH = $(CORE_DIR) $(IO_DIR) $(FP_DIR) $(NET_DIR) $(CIV_DIR)
include $(CORE_DIR)/Makefile.in-os

###
### SDL2/X11 PLATFORM VARIABLES
### SDL2/X11 AND INFOPANEL PLATFORM VARIABLES
###
ifeq ($(WANT_SDL),YES)
ifeq ($(INFOPANEL),YES)
PLAT_DEFS = -DINFOPANEL -DWANT_SDL
PLAT_SRCS = simpanel.c simsdl.c
else
PLAT_DEFS = -DWANT_SDL
PLAT_SRCS = simsdl.c
endif
ifeq ($(TARGET_OS),BSD)
PLAT_INCS = -I/usr/local/include/SDL2
PLAT_LDFLAGS = -L/usr/local/lib
Expand All @@ -73,6 +80,10 @@ PLAT_LDFLAGS = -Wl,-search_paths_first -Wl,-headerpad_max_install_names \
PLAT_LDLIBS = -framework SDL2
endif
else
ifeq ($(INFOPANEL),YES)
PLAT_DEFS = -DINFOPANEL
PLAT_SRCS = simpanel.c
endif
ifeq ($(TARGET_OS),BSD)
PLAT_INCS = -I/usr/local/include
PLAT_LDFLAGS = -L/usr/local/lib
Expand All @@ -86,7 +97,7 @@ PLAT_LDLIBS = -lX11
endif
endif
###
### END SDL2/X11 PLATFORM VARIABLES
### END SDL2/X11 AND INFOPANEL PLATFORM VARIABLES
###

###
Expand Down
Loading

0 comments on commit 8f50e92

Please sign in to comment.