Skip to content

Commit

Permalink
Merge pull request #508 from sneakywumpus/addsdl2
Browse files Browse the repository at this point in the history
Add support for SDL2
  • Loading branch information
udo-munk authored Jan 8, 2025
2 parents 7422a69 + a073ef2 commit caa8f40
Show file tree
Hide file tree
Showing 65 changed files with 9,439 additions and 8,551 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,7 @@ distclean:
$(MAKE) -C $$subdir/srcsim distclean; \
done

.NOTPARALLEL: all

.PHONY: all tools libs bioses misc machines reassemble FORCE \
install uninstall clean distclean
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ Full documentation is at https://www.icl1900.co.uk/unix4fun/z80pack
## Ubuntu

### Building
First install the needed dependencies:
First install the needed dependencies for X11:

sudo apt install build-essential libglu1-mesa-dev libjpeg9-dev

Then run
or for SDL2:

sudo apt install build-essential libsdl2-dev libsdl2-image-dev

Then for X11 run

make

or for SDL2 run

WANT_SDL=YES make

to build all the MACHINES mentioned in the Makefile.

## Release vs Development
Expand All @@ -42,7 +50,8 @@ finished release.

### Running CP/M 2.2

CP/M 2.2 is the ancestor of MS-DOS. Use this command to invoke CP/M 2.2 with two disks containing some sample programs and sources.
CP/M 2.2 is the ancestor of MS-DOS. Use this command to invoke CP/M 2.2 with
two disks containing some sample programs and sources.


(cd cpmsim; ./cpm22)
Expand Down Expand Up @@ -92,7 +101,8 @@ Clock frequency 630.22 MHz

### Running CP/M 3

CP/M 3 was the next generation of CP/M with features from MP/M to notably be able to use more RAM along with a lot of other nice features.
CP/M 3 was the next generation of CP/M with features from MP/M to notably
be able to use more RAM along with a lot of other nice features.

Run with:

Expand Down Expand Up @@ -173,10 +183,11 @@ A>dir a:
A: CPM3 SYS : VT100DYN COM : TRACE UTL : HIST UTL : PROFILE SUB
SYSTEM FILE(S) EXIST
A>dir b:
B: BNKBDOS3 SPR : CPM3 SYS : LDRBIOS3 MAC : SCB MAC : RESBDOS3 SPR : BIOS3 MAC : PATCH COM
B: GENCPM COM : BDOS3 SPR : GENCPM DAT : BOOT Z80 : M80 COM : LINK COM : L80 COM
B: WM COM : MAC COM : WM HLP : BNKBIOS3 SPR : LDR SUB : INITDIR COM : CPMLDR COM
B: COPYSYS COM : CPMLDR REL : RMAC COM : SYSGEN SUB
B: BNKBDOS3 SPR : CPM3 SYS : LDRBIOS3 MAC : SCB MAC : RESBDOS3 SPR
B: BIOS3 MAC : PATCH COM : GENCPM COM : BDOS3 SPR : GENCPM DAT
B: BOOT Z80 : M80 COM : LINK COM : L80 COM : WM COM
B: MAC COM : WM HLP : BNKBIOS3 SPR : LDR SUB : INITDIR COM
B: CPMLDR COM : COPYSYS COM : CPMLDR REL : RMAC COM : SYSGEN SUB
A>bye
System halted
Expand Down
14 changes: 7 additions & 7 deletions altairsim/conf/system.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ fp_size 800
# front panel port value for machine without fp in hex (00 - FF)
fp_port 0

# VDM background and foreground colors in hex RGB format
# VDM background and foreground colors in RGB format
# white Monitor
vdm_bg 303030
vdm_fg FFFFFF
vdm_bg 48,48,48
vdm_fg 255,255,255
# green Monitor
#vdm_bg 002000
#vdm_fg 00BF00
#vdm_bg 0,32,0
#vdm_fg 0,191,0
# amber Monitor
#vdm_bg 202000
#vdm_fg FFBF00
#vdm_bg 32,32,0
#vdm_fg 255,191,0
# Add scanlines to VDM monitor, 0 = no scanlines
vdm_scanlines 1

Expand Down
106 changes: 56 additions & 50 deletions altairsim/srcsim/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
# and the executable saved as '../machinesim'
MACHINE = altair
# emulate a machine's frontpanel
FRONTPANEL = YES
FRONTPANEL ?= YES
# 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 @@ -34,28 +36,6 @@ ROMS_DIR = $(DATADIR)/roms
### END MACHINE DEPENDENT VARIABLES
###

###
### FRONTPANEL VARIABLES
###
ifeq ($(FRONTPANEL),YES)
FP_SRCS = fpmain.cpp
FP_DEFS = -DFRONTPANEL
FP_LIB = $(FP_DIR)/libfrontpanel.a
FP_LDLIBS = -lfrontpanel -ljpeg -lGL -lGLU
LINK = $(CXX)
LINKFLAGS = $(CXXFLAGS)
else
FP_SRCS =
FP_DEFS =
FP_LIB =
FP_LDLIBS =
LINK = $(CC)
LINKFLAGS = $(CFLAGS)
endif
###
### END FRONTPANEL VARIABLES
###

SIM = ../$(MACHINE)sim

CORE_DIR = ../../z80core
Expand All @@ -64,85 +44,111 @@ FP_DIR = ../../frontpanel

VPATH = $(CORE_DIR) $(IO_DIR) $(FP_DIR)

###
### START O/S PLATFORM DEPENDENT VARIABLES
###
include $(CORE_DIR)/Makefile.in-os

###
### SDL2/X11 PLATFORM VARIABLES
###
ifeq ($(WANT_SDL),YES)
PLAT_DEFS = -DWANT_SDL
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
ifeq ($(TARGET_OS),BSD)
PLAT_INCS = -I/usr/local/include
PLAT_LDFLAGS = -L/usr/local/lib
PLAT_LDLIBS = -lthr
PLAT_LDLIBS = -lX11
else ifeq ($(TARGET_OS),LINUX)
PLAT_LDLIBS = -lX11
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
endif
ifeq ($(TARGET_OS),LINUX)
PLAT_LDLIBS = -lm -lpthread
endif
###
### END SDL2/X11 PLATFORM VARIABLES
###

###
### FRONTPANEL VARIABLES
###
ifeq ($(FRONTPANEL),YES)
FP_DEFS = -DFRONTPANEL
FP_LIB = $(FP_DIR)/libfrontpanel.a
ifeq ($(WANT_SDL),YES)
ifeq ($(TARGET_OS),OSX)
PLAT_INCS = -I/opt/X11/include
PLAT_LDFLAGS = -L/usr/local/lib -L/opt/X11/lib
FP_LDLIBS = -lfrontpanel -framework SDL2_image -framework OpenGL
else
FP_LDLIBS = -lfrontpanel -lSDL2_image -lGL
endif
else
FP_LDLIBS = -lfrontpanel -ljpeg -lGL
endif
endif
###
### END O/S DEPENDENT VARIABLES
### END FRONTPANEL VARIABLES
###

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

CSTDS = -std=c99 -D_DEFAULT_SOURCE # -D_XOPEN_SOURCE=700L
CWARNS = -Wall -Wextra -Wwrite-strings
CXXSTDS = -std=c++03 -D_DEFAULT_SOURCE # -D_XOPEN_SOURCE=700L
CXXWARNS = -Wall -Wextra

# Production - the default
COPTS = -O3 -U_FORTIFY_SOURCE
CXXOPTS = -O3 -U_FORTIFY_SOURCE

# Development - use `MODE=DEV make build`
ifeq ($(MODE),DEV)
COPTS = -O3 -fstack-protector-all -D_FORTIFY_SOURCE=2
CXXOPTS = -O3 -fstack-protector-all -D_FORTIFY_SOURCE=2
endif

# Debug - use `DEBUG=1 make build`
ifneq ($(DEBUG),)
COPTS = -O -g
CXXOPTS = -O -g
endif

CFLAGS = $(CSTDS) $(COPTS) $(CWARNS) $(PLAT_CFLAGS)
CXXFLAGS = $(CXXSTDS) $(CXXOPTS) $(CXXWARNS) $(PLAT_CXXFLAGS)
CFLAGS = $(CSTDS) $(COPTS) $(CWARNS)

LDFLAGS = -L$(FP_DIR) $(PLAT_LDFLAGS)
LDLIBS = $(FP_LDLIBS) -lX11 $(PLAT_LDLIBS)
LDLIBS = $(FP_LDLIBS) $(PLAT_LDLIBS) -lm -lpthread

INSTALL = install
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 644

# core system source files for the CPU simulation
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
simmain.c simsdl.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)
XXSRCS = $(FP_SRCS)
OBJS = $(SRCS:.c=.o) $(XXSRCS:.cpp=.o)
DEPS = $(SRCS:.c=.d) $(XXSRCS:.cpp=.d)
OBJS = $(SRCS:.c=.o)
DEPS = $(SRCS:.c=.d)

all: $(SIM)

$(SIM): $(OBJS) $(FP_LIB)
$(LINK) $(LINKFLAGS) $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $@
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $@

$(DEPS): sim.h

%.d: %.c
@$(CC) -MM $(CFLAGS) $(CPPFLAGS) $< > $@

%.d: %.cpp
@$(CXX) -MM $(CXXFLAGS) $(CPPFLAGS) $< > $@

-include $(DEPS)

$(FP_LIB): FORCE
Expand Down
52 changes: 49 additions & 3 deletions altairsim/srcsim/simcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* Copyright (C) 2008-2021 Udo Munk
* Copyright (C) 2021 David McNaughton
* Copyright (C) 2025 by Thomas Eberhardt
*
* This module reads the system configuration file and sets
* global variables, so that the system can be configured.
Expand All @@ -29,6 +30,7 @@
* 22-JAN-2021 added option for config file
* 31-JUL-2021 allow building machine without frontpanel
* 29-AUG-2021 new memory configuration sections
* 03-JAN-2025 changed colors configuration to RGB-triple
*/

#include <stddef.h>
Expand Down Expand Up @@ -59,7 +61,7 @@ void config(void)
FILE *fp;
char buf[BUFSIZE];
char *s, *t1, *t2, *t3, *t4;
int v1, v2;
int v1, v2, v3;
char fn[MAX_LFN - 1];

int num_segs = 0;
Expand Down Expand Up @@ -224,9 +226,53 @@ void config(void)
fp_size = atoi(t2);
#endif
} else if (!strcmp(t1, "vdm_bg")) {
strncpy(&bg_color[1], t2, 6);
if ((t3 = strtok(NULL, " \t,")) == NULL ||
(t4 = strtok(NULL, " \t,")) == NULL) {
LOGW(TAG, "missing parameter for %s", t1);
continue;
}
v1 = strtol(t2, NULL, 0);
if (v1 < 0 || v1 > 255) {
LOGW(TAG, "invalid red component %d", v1);
continue;
}
v2 = strtol(t3, NULL, 0);
if (v2 < 0 || v2 > 255) {
LOGW(TAG, "invalid green component %d", v2);
continue;
}
v3 = strtol(t4, NULL, 0);
if (v3 < 0 || v3 > 255) {
LOGW(TAG, "invalid blue component %d", v3);
continue;
}
bg_color[0] = v1;
bg_color[1] = v2;
bg_color[2] = v3;
} else if (!strcmp(t1, "vdm_fg")) {
strncpy(&fg_color[1], t2, 6);
if ((t3 = strtok(NULL, " \t,")) == NULL ||
(t4 = strtok(NULL, " \t,")) == NULL) {
LOGW(TAG, "missing parameter for %s", t1);
continue;
}
v1 = strtol(t2, NULL, 0);
if (v1 < 0 || v1 > 255) {
LOGW(TAG, "invalid red component %d", v1);
continue;
}
v2 = strtol(t3, NULL, 0);
if (v2 < 0 || v2 > 255) {
LOGW(TAG, "invalid green component %d", v2);
continue;
}
v3 = strtol(t4, NULL, 0);
if (v3 < 0 || v3 > 255) {
LOGW(TAG, "invalid blue component %d", v3);
continue;
}
fg_color[0] = v1;
fg_color[1] = v2;
fg_color[2] = v3;
} else if (!strcmp(t1, "vdm_scanlines")) {
if (*t2 != '0')
slf = 2;
Expand Down
Loading

0 comments on commit caa8f40

Please sign in to comment.