Added lmarbles game

This commit is contained in:
Jerome Marty
2010-12-21 11:57:14 +01:00
committed by pelya
parent a2eaebb9ff
commit 11bc49d017
124 changed files with 23620 additions and 0 deletions

View File

@@ -0,0 +1,113 @@
DEFS = @DEFS@ @arch_flag@ @inst_flag@ @prf_flag@ @sound_flag@ @ascii_flag@
marblesres.o: win32.ico
@echo "1 VERSIONINFO" > $(PACKAGE).rc
@echo "FILEVERSION `echo $(VERSION) | $(AWK) '{ gsub(/\./,","); print }'`,0" >> $(PACKAGE).rc
@echo "PRODUCTVERSION `echo $(VERSION) | $(AWK) '{ gsub(/\./,","); print }'`,0" >> $(PACKAGE).rc
@echo "FILEFLAGSMASK 0" >> $(PACKAGE).rc
@echo "FILEOS 0x40000" >> $(PACKAGE).rc
@echo "FILETYPE 1" >> $(PACKAGE).rc
@echo "{" >> $(PACKAGE).rc
@echo " BLOCK \"StringFileInfo\"" >> $(PACKAGE).rc
@echo " {" >> $(PACKAGE).rc
@echo " BLOCK \"040904E4\"" >> $(PACKAGE).rc
@echo " {" >> $(PACKAGE).rc
@echo " VALUE \"CompanyName\", \"LGames - Michael Speck\"" >> $(PACKAGE).rc
@echo " VALUE \"FileDescription\", \"@appname@\"" >> $(PACKAGE).rc
@echo " VALUE \"FileVersion\", \"$(VERSION)\"" >> $(PACKAGE).rc
@echo " VALUE \"InternalName\", \"$(PACKAGE)\"" >> $(PACKAGE).rc
@echo " VALUE \"LegalCopyright\", \"GNU Public License\"" >> $(PACKAGE).rc
@echo " VALUE \"OriginalFilename\", \"$(PACKAGE)$(EXEEXT)\"" >> $(PACKAGE).rc
@echo " VALUE \"ProductName\", \"@appname@\"" >> $(PACKAGE).rc
@echo " VALUE \"ProductVersion\", \"$(VERSION)\"" >> $(PACKAGE).rc
@echo " }" >> $(PACKAGE).rc
@echo " }" >> $(PACKAGE).rc
@echo "}" >> $(PACKAGE).rc
@echo "0 ICON win32.ico" >> $(PACKAGE).rc
@windres -o $@ -i $(PACKAGE).rc
bin_PROGRAMS = lmarbles
lmarbles_SOURCES = audio.c cfg.c dynlist.c file.c game.c levels.c main.c menu.c \
profile.c sdl.c timer.c audio.h cfg.h dynlist.h file.h game.h levels.h \
menu.h profile.h sdl.h timer.h win32.ico lmarbles.6
lmarbles_DEPENDENCIES = @win32_deps@
lmarbles_LDADD = @win32_deps@ @mixer_flag@
man_MANS = lmarbles.6
DATA_FILES = \
gfx/board.bmp gfx/f_red.bmp gfx/f_small.bmp gfx/f_white.bmp \
gfx/f_yellow.bmp gfx/figure.bmp gfx/lights.bmp gfx/logo.bmp \
gfx/m_frame.bmp gfx/m_sframe.bmp gfx/marbles.bmp gfx/tiny.sdlfnt \
gfx/title.bmp gfx/win_icon.bmp \
\
sounds/alarm.wav sounds/arrow.wav sounds/click.wav sounds/explode.wav \
sounds/select.wav sounds/stop.wav sounds/teleport.wav sounds/score.wav \
\
levels/Original \
\
gfx/stone/arrow_d.bmp gfx/stone/arrow_l.bmp gfx/stone/arrow_r.bmp \
gfx/stone/arrow_u.bmp gfx/stone/background.bmp gfx/stone/barrier_lr.bmp \
gfx/stone/barrier_ud.bmp gfx/stone/floor.bmp gfx/stone/teleport0.bmp \
gfx/stone/teleport1.bmp gfx/stone/teleport2.bmp \
gfx/stone/teleport3.bmp gfx/stone/wall.bmp \
gfx/stone/wall_crumble.bmp \
\
gfx/metal/arrow_d.bmp gfx/metal/arrow_l.bmp gfx/metal/arrow_r.bmp \
gfx/metal/arrow_u.bmp gfx/metal/background.bmp gfx/metal/barrier_lr.bmp \
gfx/metal/barrier_ud.bmp gfx/metal/floor.bmp gfx/metal/teleport0.bmp \
gfx/metal/teleport1.bmp gfx/metal/teleport2.bmp \
gfx/metal/teleport3.bmp gfx/metal/wall.bmp \
gfx/metal/wall_crumble.bmp \
\
gfx/wood/arrow_d.bmp gfx/wood/arrow_l.bmp gfx/wood/arrow_r.bmp \
gfx/wood/arrow_u.bmp gfx/wood/background.bmp gfx/wood/barrier_lr.bmp \
gfx/wood/barrier_ud.bmp gfx/wood/floor.bmp gfx/wood/teleport0.bmp \
gfx/wood/teleport1.bmp gfx/wood/teleport2.bmp \
gfx/wood/teleport3.bmp gfx/wood/wall.bmp \
gfx/wood/wall_crumble.bmp
DOC_FILES = manual/manual.html manual/arrow.jpg manual/arrow2.jpg \
manual/crumble.jpg manual/teleport.jpg manual/marbles.jpg
EXTRA_DIST= empty.prfs $(DATA_FILES) $(DOC_FILES)
install-data-local:
#directories
$(mkinstalldirs) $(DESTDIR)$(inst_dir)
$(mkinstalldirs) $(DESTDIR)$(inst_dir)/gfx
$(mkinstalldirs) $(DESTDIR)$(inst_dir)/gfx/stone
$(mkinstalldirs) $(DESTDIR)$(inst_dir)/gfx/metal
$(mkinstalldirs) $(DESTDIR)$(inst_dir)/gfx/wood
$(mkinstalldirs) $(DESTDIR)$(inst_dir)/sounds
$(mkinstalldirs) $(DESTDIR)$(inst_dir)/levels
#data files
for file in $(DATA_FILES); do\
$(INSTALL_DATA) $$file $(DESTDIR)$(inst_dir)/$$file;\
done
#profiles
$(mkinstalldirs) $(DESTDIR)$(prf_dir)
if ! test -f $(DESTDIR)$(prf_dir)/lmarbles.prfs; then \
$(INSTALL_DATA) -m 666 empty.prfs $(DESTDIR)$(prf_dir)/lmarbles.prfs; \
fi;
uninstall-local:
rm -rf $(DESTDIR)$(inst_dir)
rm -f $(DESTDIR)$(prf_dir)/lmarbles.prfs
win32rootdir=`pwd -W | awk '{ gsub("/","\\\\"); print}'`
win32-install-script:
@$(STRIP) $(PACKAGE)$(EXEEXT)
@echo "Source: \"$(win32rootdir)\\$(PACKAGE)$(EXEEXT)\"; DestDir: \"{app}\"; CopyMode: alwaysoverwrite" >> @win32_inst_script@
@for file in $(DATA_FILES) $(DOC_FILES); do \
win32src=$(win32rootdir)\\`echo $$file | awk '{ gsub("/","\\\\"); print }'`; \
win32dest=`dirname $$file | awk '{ gsub("/","\\\\"); print }'`; \
echo "Source: \"$$win32src\"; DestDir: \"{app}\\$$win32dest\"; CopyMode: alwaysoverwrite" >> @win32_inst_script@; \
done
@list='$(SUBDIRS)'; for subdir in $$list; do \
(cd $$subdir \
&& $(MAKE) $(AM_MAKEFLAGS) win32-install-script); \
done

View File

@@ -0,0 +1,596 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
bin_PROGRAMS = lmarbles$(EXEEXT)
subdir = src
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man6dir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_lmarbles_OBJECTS = audio.$(OBJEXT) cfg.$(OBJEXT) dynlist.$(OBJEXT) \
file.$(OBJEXT) game.$(OBJEXT) levels.$(OBJEXT) main.$(OBJEXT) \
menu.$(OBJEXT) profile.$(OBJEXT) sdl.$(OBJEXT) timer.$(OBJEXT)
lmarbles_OBJECTS = $(am_lmarbles_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(lmarbles_SOURCES)
DIST_SOURCES = $(lmarbles_SOURCES)
man6dir = $(mandir)/man6
NROFF = nroff
MANS = $(man_MANS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@ @arch_flag@ @inst_flag@ @prf_flag@ @sound_flag@ @ascii_flag@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SDL_CFLAGS = @SDL_CFLAGS@
SDL_CONFIG = @SDL_CONFIG@
SDL_LIBS = @SDL_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_CC = @ac_ct_CC@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
appname = @appname@
arch_flag = @arch_flag@
ascii_flag = @ascii_flag@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
inst_dir = @inst_dir@
inst_flag = @inst_flag@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mixer_flag = @mixer_flag@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
prf_dir = @prf_dir@
prf_flag = @prf_flag@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sound_flag = @sound_flag@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
win32_deps = @win32_deps@
win32_inst_script = @win32_inst_script@
lmarbles_SOURCES = audio.c cfg.c dynlist.c file.c game.c levels.c main.c menu.c \
profile.c sdl.c timer.c audio.h cfg.h dynlist.h file.h game.h levels.h \
menu.h profile.h sdl.h timer.h win32.ico lmarbles.6
lmarbles_DEPENDENCIES = @win32_deps@
lmarbles_LDADD = @win32_deps@ @mixer_flag@
man_MANS = lmarbles.6
DATA_FILES = \
gfx/board.bmp gfx/f_red.bmp gfx/f_small.bmp gfx/f_white.bmp \
gfx/f_yellow.bmp gfx/figure.bmp gfx/lights.bmp gfx/logo.bmp \
gfx/m_frame.bmp gfx/m_sframe.bmp gfx/marbles.bmp gfx/tiny.sdlfnt \
gfx/title.bmp gfx/win_icon.bmp \
\
sounds/alarm.wav sounds/arrow.wav sounds/click.wav sounds/explode.wav \
sounds/select.wav sounds/stop.wav sounds/teleport.wav sounds/score.wav \
\
levels/Original \
\
gfx/stone/arrow_d.bmp gfx/stone/arrow_l.bmp gfx/stone/arrow_r.bmp \
gfx/stone/arrow_u.bmp gfx/stone/background.bmp gfx/stone/barrier_lr.bmp \
gfx/stone/barrier_ud.bmp gfx/stone/floor.bmp gfx/stone/teleport0.bmp \
gfx/stone/teleport1.bmp gfx/stone/teleport2.bmp \
gfx/stone/teleport3.bmp gfx/stone/wall.bmp \
gfx/stone/wall_crumble.bmp \
\
gfx/metal/arrow_d.bmp gfx/metal/arrow_l.bmp gfx/metal/arrow_r.bmp \
gfx/metal/arrow_u.bmp gfx/metal/background.bmp gfx/metal/barrier_lr.bmp \
gfx/metal/barrier_ud.bmp gfx/metal/floor.bmp gfx/metal/teleport0.bmp \
gfx/metal/teleport1.bmp gfx/metal/teleport2.bmp \
gfx/metal/teleport3.bmp gfx/metal/wall.bmp \
gfx/metal/wall_crumble.bmp \
\
gfx/wood/arrow_d.bmp gfx/wood/arrow_l.bmp gfx/wood/arrow_r.bmp \
gfx/wood/arrow_u.bmp gfx/wood/background.bmp gfx/wood/barrier_lr.bmp \
gfx/wood/barrier_ud.bmp gfx/wood/floor.bmp gfx/wood/teleport0.bmp \
gfx/wood/teleport1.bmp gfx/wood/teleport2.bmp \
gfx/wood/teleport3.bmp gfx/wood/wall.bmp \
gfx/wood/wall_crumble.bmp
DOC_FILES = manual/manual.html manual/arrow.jpg manual/arrow2.jpg \
manual/crumble.jpg manual/teleport.jpg manual/marbles.jpg
EXTRA_DIST = empty.prfs $(DATA_FILES) $(DOC_FILES)
win32rootdir = `pwd -W | awk '{ gsub("/","\\\\"); print}'`
all: all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign src/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
@list='$(bin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
; then \
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
$(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
rm -f "$(DESTDIR)$(bindir)/$$f"; \
done
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
lmarbles$(EXEEXT): $(lmarbles_OBJECTS) $(lmarbles_DEPENDENCIES)
@rm -f lmarbles$(EXEEXT)
$(LINK) $(lmarbles_LDFLAGS) $(lmarbles_OBJECTS) $(lmarbles_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfg.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlist.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/game.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/levels.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/menu.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/profile.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
uninstall-info-am:
install-man6: $(man6_MANS) $(man_MANS)
@$(NORMAL_INSTALL)
test -z "$(man6dir)" || $(mkdir_p) "$(DESTDIR)$(man6dir)"
@list='$(man6_MANS) $(dist_man6_MANS) $(nodist_man6_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.6*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
6*) ;; \
*) ext='6' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man6dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man6dir)/$$inst"; \
done
uninstall-man6:
@$(NORMAL_UNINSTALL)
@list='$(man6_MANS) $(dist_man6_MANS) $(nodist_man6_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.6*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
6*) ;; \
*) ext='6' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f '$(DESTDIR)$(man6dir)/$$inst'"; \
rm -f "$(DESTDIR)$(man6dir)/$$inst"; \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
$(mkdir_p) $(distdir)/gfx $(distdir)/gfx/metal $(distdir)/gfx/stone $(distdir)/gfx/wood $(distdir)/levels $(distdir)/manual $(distdir)/sounds
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS) $(MANS)
installdirs:
for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man6dir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-data-local install-man
install-exec-am: install-binPROGRAMS
install-info: install-info-am
install-man: install-man6
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-local \
uninstall-man
uninstall-man: uninstall-man6
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
clean-generic ctags distclean distclean-compile \
distclean-generic distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-binPROGRAMS \
install-data install-data-am install-data-local install-exec \
install-exec-am install-info install-info-am install-man \
install-man6 install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \
ps ps-am tags uninstall uninstall-am uninstall-binPROGRAMS \
uninstall-info-am uninstall-local uninstall-man uninstall-man6
marblesres.o: win32.ico
@echo "1 VERSIONINFO" > $(PACKAGE).rc
@echo "FILEVERSION `echo $(VERSION) | $(AWK) '{ gsub(/\./,","); print }'`,0" >> $(PACKAGE).rc
@echo "PRODUCTVERSION `echo $(VERSION) | $(AWK) '{ gsub(/\./,","); print }'`,0" >> $(PACKAGE).rc
@echo "FILEFLAGSMASK 0" >> $(PACKAGE).rc
@echo "FILEOS 0x40000" >> $(PACKAGE).rc
@echo "FILETYPE 1" >> $(PACKAGE).rc
@echo "{" >> $(PACKAGE).rc
@echo " BLOCK \"StringFileInfo\"" >> $(PACKAGE).rc
@echo " {" >> $(PACKAGE).rc
@echo " BLOCK \"040904E4\"" >> $(PACKAGE).rc
@echo " {" >> $(PACKAGE).rc
@echo " VALUE \"CompanyName\", \"LGames - Michael Speck\"" >> $(PACKAGE).rc
@echo " VALUE \"FileDescription\", \"@appname@\"" >> $(PACKAGE).rc
@echo " VALUE \"FileVersion\", \"$(VERSION)\"" >> $(PACKAGE).rc
@echo " VALUE \"InternalName\", \"$(PACKAGE)\"" >> $(PACKAGE).rc
@echo " VALUE \"LegalCopyright\", \"GNU Public License\"" >> $(PACKAGE).rc
@echo " VALUE \"OriginalFilename\", \"$(PACKAGE)$(EXEEXT)\"" >> $(PACKAGE).rc
@echo " VALUE \"ProductName\", \"@appname@\"" >> $(PACKAGE).rc
@echo " VALUE \"ProductVersion\", \"$(VERSION)\"" >> $(PACKAGE).rc
@echo " }" >> $(PACKAGE).rc
@echo " }" >> $(PACKAGE).rc
@echo "}" >> $(PACKAGE).rc
@echo "0 ICON win32.ico" >> $(PACKAGE).rc
@windres -o $@ -i $(PACKAGE).rc
install-data-local:
#directories
$(mkinstalldirs) $(DESTDIR)$(inst_dir)
$(mkinstalldirs) $(DESTDIR)$(inst_dir)/gfx
$(mkinstalldirs) $(DESTDIR)$(inst_dir)/gfx/stone
$(mkinstalldirs) $(DESTDIR)$(inst_dir)/gfx/metal
$(mkinstalldirs) $(DESTDIR)$(inst_dir)/gfx/wood
$(mkinstalldirs) $(DESTDIR)$(inst_dir)/sounds
$(mkinstalldirs) $(DESTDIR)$(inst_dir)/levels
#data files
for file in $(DATA_FILES); do\
$(INSTALL_DATA) $$file $(DESTDIR)$(inst_dir)/$$file;\
done
#profiles
$(mkinstalldirs) $(DESTDIR)$(prf_dir)
if ! test -f $(DESTDIR)$(prf_dir)/lmarbles.prfs; then \
$(INSTALL_DATA) -m 666 empty.prfs $(DESTDIR)$(prf_dir)/lmarbles.prfs; \
fi;
uninstall-local:
rm -rf $(DESTDIR)$(inst_dir)
rm -f $(DESTDIR)$(prf_dir)/lmarbles.prfs
win32-install-script:
@$(STRIP) $(PACKAGE)$(EXEEXT)
@echo "Source: \"$(win32rootdir)\\$(PACKAGE)$(EXEEXT)\"; DestDir: \"{app}\"; CopyMode: alwaysoverwrite" >> @win32_inst_script@
@for file in $(DATA_FILES) $(DOC_FILES); do \
win32src=$(win32rootdir)\\`echo $$file | awk '{ gsub("/","\\\\"); print }'`; \
win32dest=`dirname $$file | awk '{ gsub("/","\\\\"); print }'`; \
echo "Source: \"$$win32src\"; DestDir: \"{app}\\$$win32dest\"; CopyMode: alwaysoverwrite" >> @win32_inst_script@; \
done
@list='$(SUBDIRS)'; for subdir in $$list; do \
(cd $$subdir \
&& $(MAKE) $(AM_MAKEFLAGS) win32-install-script); \
done
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -0,0 +1,151 @@
/***************************************************************************
sound.c - description
-------------------
begin : Sun Jul 29 2001
copyright : (C) 2001 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifdef SOUND
#include <SDL_mixer.h>
#include "audio.h"
/*
====================================================================
If audio device was properly initiated this flag is set.
If this flag is not set; no action will be taken for audio.
====================================================================
*/
int audio_ok = 0;
/*
====================================================================
If this flag is not set no sound is played.
====================================================================
*/
int sound_enabled = 1;
/*
====================================================================
Initiate/close audio
====================================================================
*/
int audio_open()
{
if ( Mix_OpenAudio( MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 256 ) < 0 ) {
fprintf( stderr, "audio_open: can't open audio device: %s\n", SDL_GetError() );
audio_ok = 0;
return 0;
}
audio_ok = 1;
return 1;
}
void audio_close()
{
if ( !audio_ok ) return;
Mix_CloseAudio();
}
/*
====================================================================
Sound chunk
====================================================================
*/
Sound_Chunk* sound_chunk_load( char *file_name )
{
char path[512];
Mix_Chunk *chunk = 0;
if ( !audio_ok ) {
fprintf( stderr,
"sound_chunk_load: cannot load WAV '%s' as audio device isn't initated properly\n",
file_name );
return 0;
}
/* use SRCDIR/sounds as source directory */
sprintf( path, "%s/sounds/%s", SRC_DIR, file_name );
chunk = Mix_LoadWAV( path );
if ( chunk == 0 )
{
fprintf( stderr, "chunk_load: couldn't load WAV '%s': %s\n", path, SDL_GetError() );
}
return (Sound_Chunk*)chunk;
}
void sound_chunk_free( Sound_Chunk **chunk )
{
if ( !audio_ok ) return;
Mix_FreeChunk( (Mix_Chunk*)(*chunk) );
*chunk = 0;
}
/*
====================================================================
Sound stuff
====================================================================
*/
/*
====================================================================
Enable/disable sound
====================================================================
*/
void sound_enable( int enable )
{
if ( !audio_ok ) return;
sound_enabled = enable;
if ( !enable )
Mix_Pause( -1 ); /* stop all sound channels */
}
/*
====================================================================
Set general volume of sounds. 0 - 127
====================================================================
*/
void sound_volume( int level )
{
if ( !audio_ok ) return;
if ( level < 0 ) level = 0;
if ( level > 127 ) level = 127;
Mix_Volume( -1, level ); /* all sound channels */
}
/*
====================================================================
Play a chunk.
====================================================================
*/
void sound_play( Sound_Chunk *chunk )
{
if ( !audio_ok ) return;
if ( !sound_enabled ) return;
/* use first free sound channel and play sound one time */
Mix_PlayChannel( -1, (Mix_Chunk*)chunk, 0 );
}
/*
====================================================================
Music stuff
====================================================================
*/
/*
====================================================================
Set general volume of sounds. 0 - 127
====================================================================
*/
void music_volume( int level )
{
/* not implemented */
}
#endif

View File

@@ -0,0 +1,64 @@
/***************************************************************************
sound.h - description
-------------------
begin : Sun Jul 29 2001
copyright : (C) 2001 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef __AUDIO_H
#define __AUDIO_H
#ifdef SOUND
/*
====================================================================
Wrapper for the SDL_mixer functions.
====================================================================
*/
/*
====================================================================
Initiate/close audio
====================================================================
*/
int audio_open();
void audio_close();
/*
====================================================================
Sound chunk
====================================================================
*/
typedef Mix_Chunk Sound_Chunk;
Sound_Chunk* sound_chunk_load( char *file_name );
void sound_chunk_free( Sound_Chunk **chunk );
/*
====================================================================
Sound stuff
====================================================================
*/
void sound_enable( int enable );
void sound_volume( int level /*0 - 127*/ );
void sound_play( Sound_Chunk *chunk );
/*
====================================================================
Music stuff
====================================================================
*/
void music_volume( int level );
#endif
#endif

View File

@@ -0,0 +1,190 @@
/***************************************************************************
cfg.c - description
-------------------
begin : Sat Aug 5 2000
copyright : (C) 2000 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "cfg.h"
#include "sdl.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "file.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#ifdef _WIN32
#define MKDIR(d, p) mkdir(d)
#else
#define MKDIR mkdir
#endif
char c_pth[512];
Cfg cfg;
/*
get the full path of the cfg file
*/
void C_StPth()
{
DIR *dir;
#ifdef _WIN32
snprintf( c_pth, sizeof(c_pth)-1, "%s/lgames", (getenv( "HOME" )?getenv( "HOME" ):".") );
#else
snprintf( c_pth, sizeof(c_pth)-1, "%s/.lgames", getenv( "HOME" ) );
#endif
/* create .lgames directory if not found */
if ( (dir = opendir( c_pth )) == 0 ) {
fprintf( stderr, "Config directory ~/.lgames not found. Creating it.\n" );
MKDIR( c_pth, S_IRWXU );
}
else
{
closedir(dir);
}
/* get full path of config file */
strcat( c_pth, "/lmarbles.conf" );
}
/*
load it
*/
void C_Ld()
{
char str[256];
FILE *f;
struct stat dir_stat;
printf("loading configuration...\n");
// load init //
if ((f = fopen(c_pth, "r")) == 0) {
printf("cfg file '%s' not found; using defaults\n", c_pth);
C_Def();
}
else {
stat( c_pth, &dir_stat );
if ( dir_stat.st_size != sizeof( Cfg ) ) {
fprintf( stderr, "config file '%s' corrupted... using defaults\n", c_pth );
C_Def();
}
else
{
#ifdef ASCII
F_GetE(f, str, F_VAL);
if (strncmp(str,"ascii",5)) {
printf("cfg file '%s' not in ascii; using defaults\n", c_pth);
C_Def();
}
else {
F_GetE(f, cfg.prf_nm, F_VAL); cfg.prf_nm[strlen(cfg.prf_nm) - 1] = 0;
F_GetE(f, str, F_VAL); F_ValToInt(str, &cfg.prf);
F_GetE(f, str, F_VAL); F_ValToInt(str, &cfg.s_vol);
F_GetE(f, str, F_VAL); F_ValToInt(str, &cfg.s_on);
F_GetE(f, str, F_VAL); F_ValToInt(str, &cfg.ani);
F_GetE(f, str, F_VAL); F_ValToInt(str, &cfg.trp);
F_GetE(f, str, F_VAL); F_ValToInt(str, &cfg.fscr);
F_GetE(f, str, F_VAL); F_ValToInt(str, &cfg.dim);
F_GetE(f, str, F_VAL); F_ValToInt(str, &cfg.diff);
F_GetE(f, str, F_VAL); F_ValToInt(str, &cfg.k_up);
F_GetE(f, str, F_VAL); F_ValToInt(str, &cfg.k_down);
F_GetE(f, str, F_VAL); F_ValToInt(str, &cfg.k_left);
F_GetE(f, str, F_VAL); F_ValToInt(str, &cfg.k_right);
F_GetE(f, str, F_VAL); F_ValToInt(str, &cfg.k_undo);
}
#else
fread(str, 5, 1, f);
if (!strncmp(str,"ascii",5)) {
printf("cfg file '%s' in ascii but raw binary data expected; using defaults\n", c_pth);
C_Def();
}
else {
fseek(f,SEEK_SET,0);
fread(&cfg, sizeof(Cfg), 1, f);
}
#endif
}
fclose(f);
}
}
/*
save it
*/
void C_Sv()
{
//save init //
FILE *f = fopen(c_pth, "w");
#ifdef ASCII
char str[256];
F_WrtE(f, "ascii");
F_WrtE(f, cfg.prf_nm);
F_IntToStr(str, cfg.prf); F_WrtE(f, str);
F_IntToStr(str, cfg.s_vol); F_WrtE(f, str);
F_IntToStr(str, cfg.s_on); F_WrtE(f, str);
F_IntToStr(str, cfg.ani); F_WrtE(f, str);
F_IntToStr(str, cfg.trp); F_WrtE(f, str);
F_IntToStr(str, cfg.fscr); F_WrtE(f, str);
F_IntToStr(str, cfg.dim); F_WrtE(f, str);
F_IntToStr(str, cfg.diff); F_WrtE(f, str);
F_IntToStr(str, cfg.k_up); F_WrtE(f, str);
F_IntToStr(str, cfg.k_down); F_WrtE(f, str);
F_IntToStr(str, cfg.k_left); F_WrtE(f, str);
F_IntToStr(str, cfg.k_right); F_WrtE(f, str);
F_IntToStr(str, cfg.k_undo); F_WrtE(f, str);
#else
fwrite(&cfg, sizeof(Cfg), 1, f);
#endif
fclose(f);
}
/*
default values
*/
void C_Def()
{
strcpy(cfg.prf_nm, "Michael");
cfg.prf = 0;
// sound //
cfg.s_vol = 6;
cfg.s_on = 1;
// gfx //
cfg.ani = 1;
cfg.trp = 1;
cfg.fscr = 0;
cfg.dim = 1;
cfg.diff = DIFF_NORMAL;
// controls
cfg.k_up = SDLK_UP;
cfg.k_down = SDLK_DOWN;
cfg.k_left = SDLK_LEFT;
cfg.k_right = SDLK_RIGHT;
cfg.k_undo = SDLK_SPACE;
}

View File

@@ -0,0 +1,56 @@
/***************************************************************************
cfg.h - description
-------------------
begin : Sat Aug 5 2000
copyright : (C) 2000 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef CFG_H
#define CFG_H
enum {
DIFF_EASY = 0,
DIFF_NORMAL,
DIFF_HARD,
DIFF_BRAINSTORM
};
// config file //
typedef struct {
// profile
char prf_nm[12];
int prf;
// level set //
int ls;
// sound
int s_on;
int s_vol;
// gfx //
int ani;
int trp;
int fscr; // fullscreen
int dim; // dim effect on?
int diff; // difficulty
int k_up; // controls
int k_down;
int k_left;
int k_right;
int k_undo;
} Cfg;
void C_StPth();
void C_Ld();
void C_Sv();
void C_Def();
#endif

View File

@@ -0,0 +1,271 @@
/***************************************************************************
dynlist.c - description
-------------------
begin : Sat Apr 8 2000
copyright : (C) 2000 by
email :
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "dynlist.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/*
initialize list
*/
void DL_Ini(DLst *dlst)
{
dlst->cntr = 0;
dlst->hd.p = dlst->tl.n = 0;
dlst->hd.n = &dlst->tl;
dlst->tl.p = &dlst->hd;
dlst->hd.d = dlst->tl.d = 0;
dlst->flgs = DL_NONE;
dlst->cb = 0;
}
/*
insert an item at index
*/
int DL_Ins(DLst *dlst, unsigned int index, void *item)
{
int i;
DL_E *cur = &dlst->hd;
DL_E *new_entry;
if (index > dlst->cntr) {
fprintf(stderr, "ERR: dl_insert: index %i out of range...\n", index);
return 1;
}
if (item == 0) {
fprintf(stderr, "ERR: dl_insert: item is NULL...\n");
return 1;
}
for (i = 0; i < index; i++)
cur = cur->n;
new_entry = (DL_E*)malloc(sizeof(DL_E));
new_entry->d = item;
new_entry->n = cur->n;
new_entry->p = cur;
cur->n->p = new_entry;
cur->n = new_entry;
dlst->cntr++;
return 0;
}
/*
insert at the end of the list
*/
int DL_Add(DLst *dlst, void *item)
{
return DL_Ins(dlst, dlst->cntr, item);
}
/*
delete an entry
*/
int DL_DelE(DLst *dlst, DL_E *e)
{
if (e == 0) {
fprintf(stderr, "ERR: dl_delete: entry is NULL...\n");
return 1;
}
if (dlst->cntr == 0) {
fprintf(stderr, "ERR: dl_delete: list is empty...\n");
return 1;
}
if (e == &dlst->hd || e == &dlst->tl) {
fprintf(stderr, "ERR: dl_delete: trying to delete hd or tl..\n");
return 1;
}
e->p->n = e->n;
e->n->p = e->p;
dlst->cntr--;
if (dlst->flgs & DL_AUTODEL) {
if (dlst->flgs & DL_NOCB)
free(e->d);
else {
if (dlst->cb == 0) {
fprintf(stderr, "ERR: dl_delete: no destroy callback installed...\n");
free(e);
return 1;
}
(dlst->cb)(e->d);
}
}
free(e);
return 0;
}
/*
delete entry containing this item
*/
int DL_DelP(DLst *dlst, void *item)
{
int i;
DL_E *cur = &dlst->hd;
if (item == 0) {
fprintf(stderr, "ERR: dl_delete: item is NULL...\n");
return 1;
}
if (dlst->cntr == 0) {
fprintf(stderr, "ERR: dl_delete: list is empty...\n");
return 1;
}
for (i = 0; i <= dlst->cntr; i++)
if (cur->n != &dlst->tl) {
cur = cur->n;
if (cur->d == item)
break;
}
else {
fprintf(stderr, "ERR: dl_delete: list does not contain item 0x%x...\n", (int)item);
return 1;
}
cur->n->p = cur->p;
cur->p->n = cur->n;
dlst->cntr--;
cur->n = cur->p = 0;
if (dlst->flgs & DL_AUTODEL) {
if (dlst->flgs & DL_NOCB)
free(cur->d);
else {
if (dlst->cb == 0) {
fprintf(stderr, "ERR: dl_delete: no destroy callback installed...\n");
free(cur);
return 1;
}
(dlst->cb)(cur->d);
}
}
free(cur);
return 0;
}
/*
delete item at index
*/
int DL_Del(DLst *dlst, unsigned int index)
{
int i;
DL_E *cur = &dlst->hd;
if (index >= dlst->cntr) {
fprintf(stderr, "ERR: dl_delete: index %i out of range...\n", index);
return 1;
}
if (dlst->cntr == 0) {
fprintf(stderr, "ERR: dl_delete: list is empty...\n");
return 1;
}
for (i = 0; i <= index; i++)
cur = cur->n;
cur->n->p = cur->p;
cur->p->n = cur->n;
dlst->cntr--;
cur->n = cur->p = 0;
if (dlst->flgs & DL_AUTODEL) {
if (dlst->flgs & DL_NOCB)
free(cur->d);
else {
if (dlst->cb == 0) {
fprintf(stderr, "ERR: dl_delete: no destroy callback installed...\n");
free(cur);
return 1;
}
(dlst->cb)(cur->d);
}
}
free(cur);
return 0;
}
/*
get the item with index 'index'
*/
void* DL_Get(DLst *dlst, int index)
{
unsigned int i;
DL_E *cur = &dlst->hd;
if (index >= dlst->cntr) {
fprintf(stderr, "ERR: dl_get: index %i out of range...\n", index);
return 0;
}
for (i = 0; i <= (unsigned)index; i++)
cur = cur->n;
return cur->d;
}
/*
get the current entry from a pointer
*/
DL_E *DL_GetE(DLst *dlst, void *item)
{
int i;
DL_E *cur = &dlst->hd;
if (item == 0) {
fprintf(stderr, "ERR: DL_GetE: item is NULL...\n");
return 0;
}
if (dlst->cntr == 0) {
fprintf(stderr, "ERR: DL_GetE: list is empty...\n");
return 0;
}
for (i = 0; i <= dlst->cntr; i++)
if (cur->n != &dlst->tl) {
cur = cur->n;
if (cur->d == item)
break;
}
else {
fprintf(stderr, "ERR: DL_GetE: list does not contain item 0x%x...\n", (int)item);
return 0;
}
return cur;
}
/*
clear all entries of list
*/
void DL_Clr(DLst *dlst)
{
DL_E *cur = dlst->hd.n;
DL_E *n;
while (cur != &dlst->tl) {
n = cur->n;
DL_DelE(dlst, cur);
cur = n;
}
}

View File

@@ -0,0 +1,58 @@
/***************************************************************************
dynlist.h - description
-------------------
begin : Sat Apr 8 2000
copyright : (C) 2000 by
email :
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef DYNLIST_H
#define DYNLIST_H
#ifdef __cplusplus
extern "C" {
#endif
//dl flags
#define DL_NONE (0)
#define DL_AUTODEL (1L<<0)
#define DL_NOCB (1L<<1)
typedef struct _DL_E {
struct _DL_E *n;
struct _DL_E *p;
void *d;
} DL_E;
typedef struct {
unsigned int flgs;
unsigned int cntr; //don't edit
DL_E hd; //don't edit
DL_E tl; //don't edit
void (*cb)(void*);
} DLst;
void DL_Ini(DLst *dlst);
int DL_Ins(DLst *dlst, unsigned int i, void *item); //insert item
int DL_Add(DLst *dlst, void *item); //insert at the end
int DL_DelE(DLst *dlst, DL_E *e);
int DL_DelP(DLst *dlst, void *item);
int DL_Del(DLst *dlst, unsigned int i);
void* DL_Get(DLst *dlst, int i);
DL_E *DL_GetE(DLst *dlst, void *item);
void DL_Clr(DLst *dlst); //clear full list
#ifdef __cplusplus
};
#endif
#endif

Binary file not shown.

View File

@@ -0,0 +1,168 @@
/***************************************************************************
file.c - description
-------------------
begin : Tue Sep 26 2000
copyright : (C) 2000 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "file.h"
#include <stdlib.h>
#include <string.h>
int f_ln = 0;
/*
read an entry and return if the correct flag is set else read next entry
*/
void F_GetE(FILE *f, char *str, int flgs)
{
int i = 0;
char c;
str[0] = 0;
while (!feof(f)) {
fread(&c, 1/*sizeof(char)*/, 1, f); /* MUST BE exactly on byte */
if (c == 10) {
f_ln++; // increase line counter //
continue; // ignore returns //
}
str[i++] = c; str[i] = 0;
if ( (c == ';' && flgs & F_VAL) || (c == '>' && flgs & F_SUB) || (c == ')' && flgs & F_COM) )
break;
if (c == ';' || c == '>' || c == ')')
i = 0;
}
if (i == 1)
str[0] = 0;
}
/*
returns the first character bigger than 32
*/
char F_FstC(char *str, char **n)
{
int i = 0;
while (str[i] <= 32) {
i++;
if (i >= strlen(str)) return 0;
}
*n = str + i;
return str[i];
}
/*
returns the last character bigger than 32
*/
char F_LstC(char *str)
{
int i = strlen(str) - 1;
while (str[i] <= 32) {
i--;
if (i <= 0) return 0;
}
return str[i];
}
/*
read value to v
*/
int F_GetV(char *str, char *v)
{
int i;
char *n;
for (i = 0; i < strlen(str); i++)
if (str[i] == '=') {
F_FstC(str + i + 1, &n);
strcpy(v, n);
v[strlen(v) - 1] = 0; // mask semicolon
return 1;
}
return 0;
}
/*
check entry for type and target name and assign p the value
*/
int F_CkE(char *str, int t, char *nm, char *v)
{
char *n;
if (strlen(str) == 0) return 0;
if (t & F_VAL) {
F_FstC(str, &n);
if (strncmp(nm, n, strlen(nm)))
return 0;
if (v != 0 )
return F_GetV(str, v);
else
return 0;
}
else
if (t & F_SUB) {
F_FstC(str, &n);
if (!strncmp(nm, n, strlen(nm)))
return 1;
}
else
if (t & F_COM && F_FstC(str, 0) == '(' && F_LstC(str) == ')')
return 1;
return 0;
}
/*
write an entry with a semicolon at its end
*/
void F_WrtE(FILE *f, char *str)
{
char f_str[strlen(str) + 2];
sprintf(f_str, "%s;", str);
fwrite(f_str, strlen(f_str), 1, f);
}
/*
convert an integer to string
*/
void F_IntToStr(char *str, int i)
{
sprintf(str,"%i", i);
}
/*
convert an float to string
*/
void F_FloatToStr(char *str, float f)
{
sprintf(str,"%2.2f",f);
}
/* convert a value only containing one integer */
void F_ValToInt(char *str, int *i)
{
str[strlen(str) - 1] = 0;
*i = atoi(str);
}
/* convert a value only containing one float */
void F_ValToFloat(char *str, float *f)
{
str[strlen(str) - 1] = 0;
*f = (float)strtod(str, 0);
}
/* convert a value only containing one character */
void F_ValToChar(char *str, char *c)
{
str[strlen(str) - 1] = 0;
*c = (char)atoi(str);
}

View File

@@ -0,0 +1,37 @@
/***************************************************************************
file.h - description
-------------------
begin : Tue Sep 26 2000
copyright : (C) 2000 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef FILE_H
#define FILE_H
#include <stdio.h>
#define F_SUB 0x0001
#define F_COM 0x0002
#define F_VAL 0x0004
void F_GetE(FILE *f, char *str, int flgs);
int F_CkE(char *str, int t, char *nm, char *v);
void F_WrtE(FILE *f, char *str);
void F_IntToStr(char *str, int i);
void F_FloatToStr(char *str, float f);
void F_ValToInt(char *str, int *i);
void F_ValToFloat(char *str, float *f);
void F_ValToChar(char *str, char *c);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,279 @@
/***************************************************************************
game.h - description
-------------------
begin : Mon Aug 14 2000
copyright : (C) 2000 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef GAME_H
#define GAME_H
#include <sys/stat.h>
#include <dirent.h>
#include "levels.h"
#include "dynlist.h"
#include "profile.h"
#include "sdl.h"
#include "audio.h"
// gfx set //
typedef struct {
char nm[16]; // name
int ok; // can be used
SDL_Surface
*s_bkgd, // background
*s_wl, // walls
*s_flr, // floor
*s_r_arw, *s_l_arw, *s_u_arw, *s_d_arw, // arrows
*s_ud_bar, *s_lr_bar, // barriers
*s_tlp_0, *s_tlp_1, *s_tlp_2, *s_tlp_3, // teleporters
*s_crmbl; // crumbling wall
} GSet;
// animation information //
typedef struct {
int f; // frame limit //
float c; // change per millisecond //
float p; // current position //
int w, h; // size of one sprite //
} AInf;
// map animation //
typedef struct {
int x, y; // position in map
int t; // type
AInf *a; // animation info
} MAni;
// position
typedef struct {
int x, y;
} Pos;
// vector
typedef struct {
float x,y;
} Vec;
// shrapnell
typedef struct {
SDL_Surface *s_shr; // picture;
Vec d; //direction
float x,y; //position
int w, h; // size
float a; // alpha
} Shr;
// cursor states //
#define C_NONE 0
#define C_SEL 1
#define C_U 2
#define C_R 3
#define C_D 4
#define C_L 5
// valid marble directions //
#define MD_L (1<<0)
#define MD_R (1<<1)
#define MD_U (1<<2)
#define MD_D (1<<3)
#define L_GREEN 0
#define L_ORANGE 1
#define L_RED 2
#define L_WHITE 3
#define L_SIZE 12
typedef struct {
// gfx sets //
DLst g_sts; // gfx sets //
// mouse button state //
int bttn[4];
// graphics //
SDL_Surface *s_lghts; // lamps displaying level progress //
SDL_Surface *s_brd; // side board //
SDL_Surface *s_mrb; // marbles //
SDL_Surface *s_fig; // figure //
SDL_Surface *s_bkgd; // background //
SDL_Surface *s_mf; // marble frame //
SDL_Surface *s_msf; // marble select frame //
// fonts //
SFnt *f_sml; // info //
SFnt *f_wht; // time //
SFnt *f_rd; // time2 - not much time left //
// references //
Prf *c_prf; // current profile //
SInf *c_s_inf; // current profile level set info //
LSet *c_l_st; // current level set //
GSet *c_g_st; // current gfx set //
Lvl *c_lvl; // current level //
// player //
int hi_scr; // last hiscore //
int c_l_id; // current level //
int c_ch; // current chapter //
int o_ch; // old chapter //
int l_done; // level finished //
// marble //
float m_v; // marble velocity per millisecond //
int m_sel; // selected a marble ? //
int m_mx, m_my; // position in map //
int m_o_x, m_o_y; // old position //
int m_o_move_count; // old move count //
float m_x, m_y; // position in screen //
int m_mv; // moving ? //
int m_d; // direction of moving //
int m_vd; // valid directions //
int m_tx, m_ty; // target position in screen //
int m_id; // current type of marble //
AInf m_a; // animation information //
int m_act; // action type //
int m_warp; // warp marble to destination //
// marble frame and marble select frame
AInf mf_a; // animation info
AInf msf_a; // animation info
// layout //
int l_x, l_y; // offset of level relative to 0,0 -- in L_Ini()
int f_x, f_y; // figure offset relative to b_x, 0
int b_x; // board x
int i_x, i_y; // info position relative to b_x,0
int t_x, t_y; // timer position relative to b_x,0
int s_x, s_y; // set info position relative to b_x,0
int c_x, c_y; // position of first chapter info relative to b_x,0 -- in L_Ini()
// geometry //
int t_w, t_h; // tile size //
int f_w, f_h; // figure marble size //
int f_fw, f_fh; // figure frame size //
int scr_w, scr_h; // screen size //
int brd_w; // board width
int s_w, s_h; // size of set info
int c_off; // offset between chapter infos //
// cursors //
int c_stat; // cursor state //
SDL_Cursor *c_u, *c_d, *c_l, *c_r, *c_s, *c_n, *c_w; // cursors
// old mouse pos //
int o_mx, o_my;
// level warp //
char inf_str[64]; // warp info string
int w_c, w_l; // warp level and chapter
// map animations //
MAni *m_ani; // animations
int ma_num; // animation number
AInf ma_ow_a; // oneway info
AInf ma_tlp_a; // teleport info
int tlp_a; // telporter alpha
// sounds
#ifdef SOUND
Sound_Chunk *wv_tlp; // teleport
Sound_Chunk *wv_sel; // select
Sound_Chunk *wv_stp; // stop
Sound_Chunk *wv_clk; // click
Sound_Chunk *wv_exp; // explode
Sound_Chunk *wv_alm; // alarm
Sound_Chunk *wv_arw; // arrow
Sound_Chunk *wv_scr; // score
#endif
DLst shr; // shrapnells
float shr_a_c; // alpha change per second
// credits
float cr_a_c; // alpha change per msecond
float cr_a; // current alpha
int cr_tm; // shown how long ?
int cr_c_tm; // current time
char cr_str[256]; // what is shown...
int cr_x, cr_y, cr_w, cr_h; // shown where ?
int cr_st; // state: 0 undim, 1 shown, 2 dim
// snapshot
int snap;
// blink time //
int blink_time;
} Game;
void G_Ini();
void G_Trm();
int G_Opn();
void G_Cls();
void G_Run();
void G_LdGSts();
void G_DelGSt(void *p);
void G_Ps();
void G_CkFgr();
int G_CfmWrp();
int G_CfmQut();
int G_CfmRst();
int G_CkLSt();
// marble //
void Mr_Hd();
void Mr_Shw();
int Mr_Upd(int ms);
void Mr_Sel(int x, int y);
void Mr_Rel(int x, int y);
void Mr_IniMv();
void Mr_Stp();
void Mr_Ins();
void Mr_CkVDir(int mx, int my);
void Mr_Act();
void Mr_ResPos();
// timer //
void Tm_Hd();
void Tm_Shw();
int Tm_Upd(int ms);
// level info //
void Inf_Hd();
int Inf_Upd();
void Inf_Shw();
// cursor //
void Cr_Ld(char *src, char *d, char*m);
void Cr_Cng(int x, int y);
// frame //
void MF_Hd();
void MF_Upd(int ms);
void MF_Shw();
// map animations //
void MA_Ini();
void MA_Upd(int ms);
void MA_Shw();
// shrapnells //
void Shr_Add(int x, int y, int w, int h, Vec d, SDL_Surface *s_shr);
void Shr_Del(void *p);
void Shr_Hd();
void Shr_Upd(int ms);
void Shr_Shw();
// wall //
void Wl_Exp(int x, int y, int v);
// figure animation //
void FA_Run();
void FA_Add(int mx, int my, int m);
// credits //
void Cr_Ini();
void Cr_Hd();
void Cr_Upd(int ms);
void Cr_Shw();
// bonus summary //
void BS_Run(float b_lvl, float b_tm);
void BS_Hd(int x, int y, int w, int h);
void BS_Shw(int x, int y, int v);
// shnapshot //
void SnapShot();
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 880 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@@ -0,0 +1,837 @@
/***************************************************************************
levels.c - description
-------------------
begin : Mon Aug 14 2000
copyright : (C) 2000 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include "levels.h"
#include "dynlist.h"
#include "game.h"
#include "file.h"
#include "sdl.h"
#include "timer.h"
#include "cfg.h"
/* game struct -- game.c */
extern Game gm;
/* line counter -- file.c */
extern int f_ln;
/* Sdl -- sdl.c */
extern Sdl sdl;
/* profiles -- profile.c */
extern DLst prfs;
/* config -- cfg.c */
extern Cfg cfg;
char **ls_lst = 0;
int ls_n = 0;
DLst l_sts;
/*
count and create a list with all loadable filenames found in SRC_DIR/levels
*/
void L_CrtLst()
{
int i;
char d_nm[256];
char path[256+64];
DIR *dir = 0;
struct dirent *e;
struct stat s;
ls_n = 0;
// create directory string //
sprintf(d_nm, "%s/levels", SRC_DIR);
// find and open directory //
if ((dir = opendir(d_nm)) == 0) {
fprintf(stderr, "ERROR: can't find directory '%s'\n", d_nm);
exit(1);
}
printf("searching for level sets...\n");
// well, let's check the count the entries //
while ((e = readdir(dir)) != 0) {
sprintf(path, "%s/%s", d_nm, e->d_name);
stat(path, &s);
if (S_ISREG(s.st_mode)) {
(ls_n)++;
printf("'%s'\n", e->d_name);
}
}
if (ls_n == 0) {
fprintf(stderr, "ERROR: '%s' seems to be empty\n", d_nm);
closedir(dir);
exit(1);
}
else
printf("...total of %i\n", ls_n);
// now we'll create the list //
rewinddir(dir);
ls_lst = malloc(sizeof(char*) * (ls_n));
for (i = 0; i < ls_n; i++) {
do {
e = readdir(dir);
if (e == 0) continue;
sprintf(path, "%s/%s", d_nm, e->d_name);
stat(path, &s);
} while (!S_ISREG(s.st_mode));
ls_lst[i] = malloc(strlen(e->d_name) + 1);
strcpy(ls_lst[i], e->d_name);
}
// close dir //
closedir(dir);
}
/*
free list memory
*/
void L_DelLst()
{
int i;
if (!ls_lst) return;
for (i = 0; i < ls_n; i++)
free(ls_lst[i]);
free(ls_lst);
}
/*
callback for dynlist l_sts to delete a level set
*/
void L_DelSt(void *p)
{
int i;
LSet *st = (LSet*)p;
if (st->ch) {
for (i = 0; i < st->c_num; i++)
free(st->ch[i].lvls);
free(st->ch);
}
free(p);
}
/*
add an empty and invalid entry
*/
void L_AddInvSt(char *nm)
{
LSet *st = malloc(sizeof(LSet));
st->c_num = 0;
st->ch = 0;
st->ok = 0;
strcpy(st->nm, nm);
DL_Add(&l_sts, st);
}
/*
set marble, type and id of a map tile
*/
void L_StMpT(MapT *tl, int m, int t, int id)
{
tl->m = m;
tl->t = t;
tl->id = id;
}
/*
parse and add a new lset from file f
*/
int L_LdSt(FILE *f)
{
int i, j, k, l;
char val[64];
char str[512];
LSet *st = malloc(sizeof(LSet));
// info section //
F_GetE(f, str, F_SUB | F_VAL);
if (!F_CkE(str, F_SUB, "<info>", 0)) {
printf("ERROR: line %i: '<info>' expected\n", f_ln);
free(st);
return 0;
}
// levels per chapter //
F_GetE(f, str, F_VAL);
if (!F_CkE(str, F_VAL, "levels", val)) {
printf("ERROR: line %i: 'levels' expected\n", f_ln);
free(st);
return 0;
}
st->l_num = atoi(val);
// chapters //
F_GetE(f, str, F_VAL);
if (!F_CkE(str, F_VAL, "chapters", val)) {
printf("ERROR: line %i: 'chapters' expected\n", f_ln);
free(st);
return 0;
}
st->c_num = atoi(val);
// limit type //
F_GetE(f, str, F_VAL);
if (!F_CkE(str, F_VAL, "limit", val)) {
printf("ERROR: line %i: 'limit' expected\n", f_ln);
free(st);
return 0;
}
if ( !strncmp( "time", val, 4 ) )
st->limit_type = TIME;
else
st->limit_type = MOVES;
// info section //
F_GetE(f, str, F_SUB | F_VAL);
if (!F_CkE(str, F_SUB, "</info>", 0)) {
printf("ERROR: line %i: '</info>' expected\n", f_ln);
free(st);
return 0;
}
// get memory
st->ch = malloc( sizeof(Chptr) * st->c_num );
for (i = 0; i < st->c_num; i++)
st->ch[i].lvls = malloc( sizeof(Lvl) * st->l_num );
// chapters
for (i = 0; i < st->c_num; i++) {
// chapter start //
F_GetE(f, str, F_SUB | F_VAL);
if (!F_CkE(str, F_SUB, "<chapter>", 0)) {
printf("ERROR: line %i: '<chapter>' expected\n", f_ln);
goto failure;
}
// name //
F_GetE(f, str, F_VAL);
if (!F_CkE(str, F_VAL, "name", st->ch[i].nm)) {
printf("ERROR: line %i: 'name' expected\n", f_ln);
goto failure;
}
// author //
F_GetE(f, str, F_VAL);
if (!F_CkE(str, F_VAL, "author", st->ch[i].authr)) {
printf("ERROR: line %i: 'author' expected\n", f_ln);
goto failure;
}
// gset //
F_GetE(f, str, F_VAL);
if (!F_CkE(str, F_VAL, "gfx_set", st->ch[i].g_st)) {
printf("ERROR: line %i: 'gfx_set' expected\n", f_ln);
goto failure;
}
// open for play ? //
F_GetE(f, str, F_VAL);
if (!F_CkE(str, F_VAL, "open", val)) {
printf("ERROR: line %i: 'open' expected\n", f_ln);
goto failure;
}
st->ch[i].opn = atoi(val);
// levels //
for (j = 0; j < st->l_num; j++) {
// level start //
F_GetE(f, str, F_SUB | F_VAL);
if (!F_CkE(str, F_SUB, "<level>", 0)) {
printf("ERROR: line %i: '<level>' expected\n", f_ln);
goto failure;
}
// time //
F_GetE(f, str, F_VAL);
if (!F_CkE(str, F_VAL, "limit", val)) {
printf("ERROR: line %i: 'limit' expected\n", f_ln);
goto failure;
}
st->ch[i].lvls[j].tm = atoi(val);
// map width //
F_GetE(f, str, F_VAL);
if (!F_CkE(str, F_VAL, "map_w", val)) {
printf("ERROR: line %i: 'map_w' expected\n", f_ln);
goto failure;
}
if ((st->ch[i].lvls[j].m_w = atoi(val)) > L_MAX_W || atoi(val) < L_MIN_W) {
printf("ERROR: line %i: 'map_w' out of range (%i-%i): %i\n", f_ln, L_MIN_W, L_MAX_W, atoi(val));
goto failure;
}
// map height //
F_GetE(f, str, F_VAL);
if (!F_CkE(str, F_VAL, "map_h", val)) {
printf("ERROR: line %i: 'map_h' expected\n", f_ln);
goto failure;
}
if ((st->ch[i].lvls[j].m_h = atoi(val)) > L_MAX_H || atoi(val) < L_MIN_H) {
printf("ERROR: line %i: 'map_w' out of range (%i-%i): %i\n", f_ln, L_MIN_H, L_MAX_H, atoi(val));
goto failure;
}
// figure width //
F_GetE(f, str, F_VAL);
if (!F_CkE(str, F_VAL, "fig_w", val)) {
printf("ERROR: line %i: 'fig_w' expected\n", f_ln);
goto failure;
}
st->ch[i].lvls[j].f_w = atoi(val);
if ((st->ch[i].lvls[j].f_w = atoi(val)) > F_MAX_W || atoi(val) < F_MIN_W) {
printf("ERROR: line %i: 'fig_w' out of range (%i-%i): %i\n", f_ln, F_MIN_W, F_MAX_W, atoi(val));
goto failure;
}
// figure height //
F_GetE(f, str, F_VAL);
if (!F_CkE(str, F_VAL, "fig_h", val)) {
printf("ERROR: line %i: 'fig_h' expected\n", f_ln);
goto failure;
}
if ((st->ch[i].lvls[j].f_h = atoi(val)) > F_MAX_H || atoi(val) < F_MIN_H) {
printf("ERROR: line %i: 'fig_h' out of range (%i-%i): %i\n", f_ln, F_MIN_H, F_MAX_H, atoi(val));
goto failure;
}
// figure start //
F_GetE(f, str, F_SUB | F_VAL);
if (!F_CkE(str, F_SUB, "<figure>", 0)) {
printf("ERROR: line %i: '<figure>' expected\n", f_ln);
goto failure;
}
// figure //
for (k = 0; k < st->ch[i].lvls[j].f_h; k++) {
F_GetE(f, str, F_VAL);
for (l = 0; l < st->ch[i].lvls[j].f_w; l++) {
if (str[l] >= '0' && str[l] <= '9')
st->ch[i].lvls[j].fgr[l][k] = str[l] - 48;
else
if (str[l] != 32)
printf("WARNING: line %i: bad figure marble '%c'\n", f_ln, str[l]);
else
st->ch[i].lvls[j].fgr[l][k] = -1;
}
}
// figure end //
F_GetE(f, str, F_SUB | F_VAL);
if (!F_CkE(str, F_SUB, "</figure>", 0)) {
printf("ERROR: line %i: '</figure>' expected\n", f_ln);
goto failure;
}
// map start //
F_GetE(f, str, F_SUB | F_VAL);
if (!F_CkE(str, F_SUB, "<map>", 0)) {
printf("ERROR: line %i: '<map>' expected\n", f_ln);
goto failure;
}
// map
for (k = 0; k < st->ch[i].lvls[j].m_h; k++) {
memset(str, 0, 256);
F_GetE(f, str, F_VAL);
for (l = 0; l < st->ch[i].lvls[j].m_w; l++) {
if (str[l] >= '0' && str[l] <= '9')
L_StMpT(&st->ch[i].lvls[j].map[l][k], str[l] - 48, M_FLOOR, 0);
else
switch (str[l]) {
case 'a':
case 'b':
case 'c':
L_StMpT(&st->ch[i].lvls[j].map[l][k], -1, M_WALL, str[l] - 97);
break;
case ' ':
L_StMpT(&st->ch[i].lvls[j].map[l][k], -1, M_FLOOR, 0);
break;
case 'u':
L_StMpT(&st->ch[i].lvls[j].map[l][k], -1, M_OW_U, 0);
break;
case 'd':
L_StMpT(&st->ch[i].lvls[j].map[l][k], -1, M_OW_D, 0);
break;
case 'r':
L_StMpT(&st->ch[i].lvls[j].map[l][k], -1, M_OW_R, 0);
break;
case 'l':
L_StMpT(&st->ch[i].lvls[j].map[l][k], -1, M_OW_L, 0);
break;
case 'U':
L_StMpT(&st->ch[i].lvls[j].map[l][k], -1, M_OW_U_C, 0);
break;
case 'D':
L_StMpT(&st->ch[i].lvls[j].map[l][k], -1, M_OW_D_C, 0);
break;
case 'R':
L_StMpT(&st->ch[i].lvls[j].map[l][k], -1, M_OW_R_C, 0);
break;
case 'L':
L_StMpT(&st->ch[i].lvls[j].map[l][k], -1, M_OW_L_C, 0);
break;
case 'w':
L_StMpT(&st->ch[i].lvls[j].map[l][k], -1, M_TLP_0, 0);
break;
case 'x':
L_StMpT(&st->ch[i].lvls[j].map[l][k], -1, M_TLP_1, 0);
break;
case 'y':
L_StMpT(&st->ch[i].lvls[j].map[l][k], -1, M_TLP_2, 0);
break;
case 'z':
L_StMpT(&st->ch[i].lvls[j].map[l][k], -1, M_TLP_3, 0);
break;
case 'A':
case 'B':
case 'C':
L_StMpT(&st->ch[i].lvls[j].map[l][k], -1, M_CRUMBLE, str[l] - 65);
break;
default:
L_StMpT(&st->ch[i].lvls[j].map[l][k], -1, M_EMPTY, 0);
break;
}
}
}
// map end //
F_GetE(f, str, F_SUB | F_VAL);
if (!F_CkE(str, F_SUB, "</map>", 0)) {
printf("ERROR: line %i: '</map>' expected\n", f_ln);
goto failure;
}
// level end //
F_GetE(f, str, F_SUB | F_VAL);
if (!F_CkE(str, F_SUB, "</level>", 0)) {
printf("ERROR: line %i: '</level>' expected\n", f_ln);
goto failure;
}
}
// chapter end //
F_GetE(f, str, F_SUB);
if (!F_CkE(str, F_SUB, "</chapter>", 0)) {
printf("ERROR: line %i: '</chapter>' expected\n", f_ln);
goto failure;
}
}
// return 1 in any case cuz 0 assumes that an empty set must be added
printf("ok\n");
DL_Add(&l_sts, st);
st->ok = 1;
return 1;
failure:
DL_Add(&l_sts, st);
// L_DelSt(st);
st->ok = 0;
return 1;
}
/*
initialize level l
*/
void L_Ini(int c, int l)
{
char *nm;
DL_E *e;
int gst_ok = 0;
int px, py, i, j, k;
Lvl *lp;
char str[64];
int off;
char *str_num[] = {"1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10."};
float mv_mod;
// show credit when new chapter
if ( gm.o_ch == -1 || gm.o_ch != c )
Cr_Ini();
// set level & chapter index
gm.o_ch = c;
gm.c_ch = c;
gm.c_l_id = l;
gm.l_done = 0;
// set open flag
gm.c_s_inf->c_opn[gm.c_ch] = 1;
// copy current level
if (gm.c_lvl) free(gm.c_lvl);
gm.c_lvl = malloc(sizeof(Lvl));
memcpy(gm.c_lvl, &gm.c_l_st->ch[gm.c_ch].lvls[gm.c_l_id], sizeof(Lvl));
// load gfx set
nm = gm.c_l_st->ch[gm.c_ch].g_st;
e = gm.g_sts.hd.n;
while (e != &gm.g_sts.tl) {
if (!strncmp(nm, ((GSet*)e->d)->nm, strlen(nm)) && ((GSet*)e->d)->ok) {
gm.c_g_st = (GSet*)e->d;
gst_ok = 1;
break;
}
e = e->n;
}
if (!gst_ok) {
printf("WARNING: unknown or unuseable gfx set '%s';\nsearching for a good one...\n", nm);
// find first useable set
e = gm.g_sts.hd.n;
while (e != &gm.g_sts.tl) {
if (((GSet*)e->d)->ok) {
gm.c_g_st = (GSet*)e->d;
printf("'%s' used instead\n", gm.c_g_st->nm);
gst_ok = 1;
break;
}
e = e->n;
}
if (!gst_ok) {
printf("ERROR: no good gfx set found...\n");
exit(1);
}
}
// set bkgd picture
if (gm.c_g_st->s_bkgd) {
for (j = 0; j < gm.scr_w - gm.brd_w; j += gm.c_g_st->s_bkgd->w)
for (k = 0; k < gm.scr_h; k += gm.c_g_st->s_bkgd->h) {
D_DST(gm.s_bkgd, j, k, gm.c_g_st->s_bkgd->w, gm.c_g_st->s_bkgd->h);
D_SRC(gm.c_g_st->s_bkgd, 0, 0);
SS_Blt();
}
}
else {
D_DST(gm.s_bkgd, 0, 0, gm.scr_w - gm.brd_w, gm.scr_h);
SS_Fill(0x0);
}
// add board
D_DST(gm.s_bkgd, gm.s_bkgd->w - gm.s_brd->w, 0, gm.s_brd->w, gm.s_brd->h);
D_SRC(gm.s_brd, 0, 0);
SS_Blt();
// add static level gfx
lp = &gm.c_l_st->ch[gm.c_ch].lvls[gm.c_l_id];
gm.l_x = (gm.scr_w - gm.brd_w - lp->m_w * gm.t_w) / 2;
gm.l_y = (gm.scr_h - lp->m_h * gm.t_h) / 2;
for (i = 0; i < lp->m_w; i++)
for (j = 0; j < lp->m_h; j++)
L_DrwMpTl(i, j);
// add marbles
for (i = 0; i < lp->m_w; i++)
for (j = 0; j < lp->m_h; j++)
if (lp->map[i][j].m != - 1) {
D_DST(gm.s_bkgd, gm.l_x + i * gm.t_w, gm.l_y + j * gm.t_h, gm.t_w, gm.t_h);
D_SRC(gm.s_mrb, 0, lp->map[i][j].m * gm.t_h);
SS_Blt();
}
// add figure
px = gm.b_x + gm.f_x + (gm.f_fw - lp->f_w * gm.f_h) / 2;
py = gm.f_y + (gm.f_fh - lp->f_h * gm.f_h)/ 2;
for (i = 0; i < lp->f_w; i++)
for (j = 0; j < lp->f_h; j++)
if (lp->fgr[i][j] != -1) {
D_DST(gm.s_bkgd, px + i * gm.f_w, py + j * gm.f_h, gm.f_w, gm.f_h);
D_SRC(gm.s_fig, 0, lp->fgr[i][j] * gm.f_h);
SS_Blt();
}
// add player info
off = gm.f_sml->h + 2;
gm.f_sml->algn = TA_X_L | TA_Y_T;
SF_Wrt(gm.f_sml, gm.s_bkgd, gm.i_x + gm.b_x, gm.i_y, "Player:", 0);
gm.f_sml->algn = TA_X_R | TA_Y_T;
SF_Wrt(gm.f_sml, gm.s_bkgd, gm.scr_w - gm.i_x, gm.i_y, gm.c_prf->nm, 0);
gm.f_sml->algn = TA_X_L | TA_Y_T;
SF_Wrt(gm.f_sml, gm.s_bkgd, gm.i_x + gm.b_x, gm.i_y + off, "Score:", 0);
gm.f_sml->algn = TA_X_R | TA_Y_T;
sprintf(str, "%i", gm.c_prf->scr);
SF_Wrt(gm.f_sml, gm.s_bkgd, gm.scr_w - gm.i_x, gm.i_y + off, str, 0);
gm.f_sml->algn = TA_X_L | TA_Y_T;
SF_Wrt(gm.f_sml, gm.s_bkgd, gm.i_x + gm.b_x, gm.i_y + off*2 + 5, "HighScore:", 0);
gm.f_sml->algn = TA_X_R | TA_Y_T;
sprintf(str, "%i", gm.hi_scr);
SF_Wrt(gm.f_sml, gm.s_bkgd, gm.scr_w - gm.i_x, gm.i_y + off*2 + 5, str, 0);
// add name of levelset above set info
gm.f_sml->algn = TA_X_C | TA_Y_T;
SF_Wrt(gm.f_sml, gm.s_bkgd, gm.b_x + gm.brd_w / 2, gm.s_y + 5, gm.c_l_st->nm, 0);
// compute position of first chapter
gm.c_x = 50; // changed
gm.c_y = gm.s_y + (gm.s_h - gm.c_l_st->c_num * L_SIZE) / 2;
// add chapter numbers
gm.f_sml->algn = TA_X_L | TA_Y_T;
for (i = 0; i < gm.c_l_st->c_num; i++) {
SF_Wrt(gm.f_sml, gm.s_bkgd, gm.b_x + gm.c_x - 30, gm.c_y + i * L_SIZE, str_num[i], 0);
}
// draw chapter lights
for (j = 0; j < gm.c_l_st->c_num; j++)
for (i = 0; i < gm.c_l_st->l_num; i++) {
D_DST(gm.s_bkgd, gm.b_x + gm.c_x + i * L_SIZE, gm.c_y + j * L_SIZE, L_SIZE, L_SIZE);
if (!gm.c_s_inf->c_opn[j]) {
D_SRC(gm.s_lghts, L_RED * L_SIZE, 0);
}
else
if ( gm.c_s_inf->cmp[j * gm.c_l_st->l_num + i] ) {
D_SRC(gm.s_lghts, L_GREEN * L_SIZE, 0);
}
else {
D_SRC(gm.s_lghts, L_ORANGE * L_SIZE, 0);
}
SS_Blt();
}
// current level is white
D_DST(gm.s_bkgd, gm.b_x + gm.c_x + l * L_SIZE, gm.c_y + c * L_SIZE, L_SIZE, L_SIZE);
D_SRC(gm.s_lghts, L_WHITE * L_SIZE, 0);
SS_Blt();
// initiate animations
MA_Ini();
// undim
D_FDST(sdl.scr);
D_FSRC(gm.s_bkgd);
SS_Blt();
if (cfg.dim)
SDL_UNDIM();
else
Sdl_FUpd();
// reset timer
T_Rst();
// reset marble and frame
gm.m_mv = 0;
gm.m_sel = 0;
gm.mf_a.p = 0;
gm.msf_a.p = 0;
gm.m_act = M_EMPTY;
gm.m_mx = gm.m_my = -1;
if ( gm.c_l_st->limit_type == TIME ) {
/* set time from seconds to milliseconds if time used */
gm.c_lvl->tm *= 1000;
gm.c_lvl->tm+=1000;
}
else {
/* gm.c_lvl->tm containts the move limit. this is modified according
to the difficulty levels */
switch ( cfg.diff ) {
case DIFF_EASY:
mv_mod = (int)ceil((float)gm.c_lvl->tm * 0.2 * ( 5 - gm.c_ch ) );
gm.c_lvl->tm += mv_mod;
if ( gm.c_lvl->tm % 2 ) gm.c_lvl->tm++;
break;
case DIFF_NORMAL:
mv_mod = (int)ceil((float)gm.c_lvl->tm * 0.1 * ( 5 - gm.c_ch ) );
gm.c_lvl->tm += mv_mod;
if ( gm.c_lvl->tm % 2 ) gm.c_lvl->tm++;
break;
case DIFF_HARD:
mv_mod = (int)ceil((float)gm.c_lvl->tm * 0.05 * ( 5 - gm.c_ch ) );
gm.c_lvl->tm += mv_mod;
if ( gm.c_lvl->tm % 2 ) gm.c_lvl->tm++;
break;
case DIFF_BRAINSTORM:
break;
}
}
// init blink time //
gm.blink_time = 0;
// cursor state
gm.c_stat = C_NONE;
SDL_SetCursor(gm.c_n);
// reset shrapnells
DL_Clr(&gm.shr);
}
/*
draw a map tile to gm.s_bkgd with x,y position in the map using current map
*/
void L_DrwMpTl(int i, int j)
{
switch (gm.c_lvl->map[i][j].t) {
case M_WALL:
// add wall shadow on right side ? //
if ( i + 1 >= gm.c_lvl->m_w || gm.c_lvl->map[i + 1][j].t == M_EMPTY ) {
D_DST(gm.s_bkgd, gm.l_x + (i + 1) * gm.t_w, gm.l_y + j * gm.t_h, 1, gm.t_h + 1);
SS_Fill(0x0);
}
// add wall shadow on bottom ? //
if ( j + 1 >= gm.c_lvl->m_h || gm.c_lvl->map[i][j + 1].t == M_EMPTY ) {
D_DST(gm.s_bkgd, gm.l_x + i * gm.t_w, gm.l_y + (j + 1) * gm.t_h, gm.t_w + 1, 1);
SS_Fill(0x0);
}
// add wall shadow on left side ? //
if ( (i == 0)
|| ((i - 1 >= gm.c_lvl->m_w) || gm.c_lvl->map[i - 1][j].t == M_EMPTY )) {
D_DST(gm.s_bkgd, gm.l_x + i * gm.t_w - 1, gm.l_y + j * gm.t_h, 1, gm.t_h + 1);
SS_Fill(0x0);
}
// add wall shadow on top ? //
if ( (j == 0)
|| ((j - 1 >= gm.c_lvl->m_h) || gm.c_lvl->map[i][j - 1].t == M_EMPTY )) {
D_DST(gm.s_bkgd, gm.l_x + i * gm.t_w, gm.l_y + j * gm.t_h - 1, gm.t_w + 1, 1);
SS_Fill(0x0);
}
D_DST(gm.s_bkgd, gm.l_x + i * gm.t_w, gm.l_y + j * gm.t_h, gm.t_w, gm.t_h);
D_SRC(gm.c_g_st->s_wl, gm.c_lvl->map[i][j].id * gm.t_w, 0);
SS_Blt();
break;
case M_CRUMBLE:
D_DST(gm.s_bkgd, gm.l_x + i * gm.t_w, gm.l_y + j * gm.t_h, gm.t_w, gm.t_h);
D_SRC(gm.c_g_st->s_flr, 0, 0);
SS_Blt();
D_DST(gm.s_bkgd, gm.l_x + i * gm.t_w, gm.l_y + j * gm.t_h, gm.t_w, gm.t_h);
D_SRC(gm.c_g_st->s_crmbl, gm.c_lvl->map[i][j].id * gm.t_w, 0);
SS_Blt();
gm.f_sml->algn = TA_X_R | TA_Y_B;
switch (gm.c_lvl->map[i][j].id) {
case 0:
SF_Wrt(gm.f_sml, gm.s_bkgd, gm.l_x + (i + 1) * gm.t_w - 1, gm.l_y + (j + 1) * gm.t_h - 1, "1", 0);
break;
case 1:
SF_Wrt(gm.f_sml, gm.s_bkgd, gm.l_x + (i + 1) * gm.t_w - 1, gm.l_y + (j + 1) * gm.t_h - 1, "2", 0);
break;
case 2:
SF_Wrt(gm.f_sml, gm.s_bkgd, gm.l_x + (i + 1) * gm.t_w - 1, gm.l_y + (j + 1) * gm.t_h - 1, "3", 0);
break;
}
break;
case M_EMPTY:
break;
default:
D_DST(gm.s_bkgd, gm.l_x + i * gm.t_w, gm.l_y + j * gm.t_h, gm.t_w, gm.t_h);
D_SRC(gm.c_g_st->s_flr, 0, 0);
SS_Blt();
break;
}
// static animations ? //
if (!cfg.ani) {
D_DST(gm.s_bkgd, gm.l_x + i * gm.t_w, gm.l_y + j * gm.t_h, gm.t_w, gm.t_h);
switch (gm.c_lvl->map[i][j].t) {
case M_OW_U:
case M_OW_U_C:
D_SRC(gm.c_g_st->s_u_arw, 0, 0);
SS_Blt();
break;
case M_OW_D:
case M_OW_D_C:
D_SRC(gm.c_g_st->s_d_arw, 0, 0);
SS_Blt();
break;
case M_OW_L:
case M_OW_L_C:
D_SRC(gm.c_g_st->s_l_arw, 0, 0);
SS_Blt();
break;
case M_OW_R:
case M_OW_R_C:
D_SRC(gm.c_g_st->s_r_arw, 0, 0);
SS_Blt();
break;
}
D_DST(gm.s_bkgd, gm.l_x + i * gm.t_w, gm.l_y + j * gm.t_h, gm.t_w, gm.t_h);
switch (gm.c_lvl->map[i][j].t) {
case M_OW_U_C:
case M_OW_D_C:
D_SRC(gm.c_g_st->s_lr_bar, 0, 0);
SS_Blt();
break;
case M_OW_L_C:
case M_OW_R_C:
D_SRC(gm.c_g_st->s_ud_bar, 0, 0);
SS_Blt();
break;
}
D_DST(gm.s_bkgd, gm.l_x + i * gm.t_w, gm.l_y + j * gm.t_h, gm.t_w, gm.t_h);
switch (gm.c_lvl->map[i][j].t) {
case M_TLP_0:
D_SRC(gm.c_g_st->s_tlp_0, 0, 0);
SS_ABlt(gm.tlp_a);
break;
case M_TLP_1:
D_SRC(gm.c_g_st->s_tlp_1, 0, 0);
SS_ABlt(gm.tlp_a);
break;
case M_TLP_2:
D_SRC(gm.c_g_st->s_tlp_2, 0, 0);
SS_ABlt(gm.tlp_a);
break;
case M_TLP_3:
D_SRC(gm.c_g_st->s_tlp_3, 0, 0);
SS_ABlt(gm.tlp_a);
break;
}
}
}
/*
proceed to next valid level
*/
int L_FndNxt()
{
int i, j;
// proceed to next level
gm.c_l_id++;
if (gm.c_l_id >= gm.c_l_st->l_num) {
gm.c_l_id = 0;
gm.c_ch++;
// check if this chapter can be entered or if this was the last chapter if not take first unsolved level found
if (gm.c_ch >= gm.c_l_st->c_num || !gm.c_l_st->ch[gm.c_ch].opn) {
for (i = 0; i < gm.c_ch; i++)
for (j = 0; j < gm.c_l_st->l_num; j++)
if (!gm.c_s_inf->cmp[i * gm.c_l_st->l_num + j]) {
// not all levels completed jump back to first unsolved level
gm.c_ch = i;
gm.c_l_id = j;
return 1;
}
if (gm.c_ch >= gm.c_l_st->c_num)
return 0;
else
return 1;
}
}
else {
// check if all levels of this chapter has been solved
for (i = 0; i <= gm.c_ch; i++)
for (j = 0; j < gm.c_l_st->l_num; j++)
if (!gm.c_s_inf->cmp[i * gm.c_l_st->l_num + j]) {
return 1;
}
// yes! open next chapter
if ( gm.c_ch < gm.c_l_st->c_num - 1 )
gm.c_s_inf->c_opn[gm.c_ch + 1] = 1;
}
return 1;
}

View File

@@ -0,0 +1,104 @@
/***************************************************************************
levels.h - description
-------------------
begin : Mon Aug 14 2000
copyright : (C) 2000 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef LEVELS_H
#define LEVELS_H
#include <stdio.h>
#define MAX_LVLS 10
#define MAX_CHPTRS 10
#define L_MAX_W 13
#define L_MIN_W 4
#define L_MAX_H 14
#define L_MIN_H 4
#define F_MAX_W 10
#define F_MIN_W 2
#define F_MAX_H 10
#define F_MIN_H 1
// level bonuses //
#define LB_COMPLETED 1000
#define LB_PER_MOVE 50
// limit type //
#define TIME 0
#define MOVES 1
// tile types //
enum {
M_EMPTY = 0, // background //
M_FLOOR, // simple floor //
M_OW_U_C, // oneway directed to north (up) closed to the left and right side //
M_OW_D_C, // analog //
M_OW_L_C, // analog //
M_OW_R_C, // analog //
M_OW_U, // oneway to north not closed at the sides //
M_OW_D, // analog //
M_OW_L, // analog //
M_OW_R, // analog //
M_WALL, // impassible wall //
M_TLP_0, // teleporter //
M_TLP_1, // analog //
M_TLP_2, // analog //
M_TLP_3, // analog //
M_CRUMBLE, // crumbling wall //
M_NUM
};
typedef struct {
int m; // marble //
int t; // type //
int id;
} MapT;
typedef struct {
int tm; // time //
int m_w, m_h; // map size //
int f_w, f_h; // figure size //
int fgr[F_MAX_W][F_MAX_H]; // figure //
MapT map[L_MAX_W][L_MAX_H]; // map //
} Lvl;
typedef struct {
char nm[64];
char authr[32];
char g_st[32];
int bkgd;
int opn; // levels from this chapter can be played
Lvl *lvls;
} Chptr;
typedef struct {
char nm[64];
int c_num;
int l_num;
Chptr *ch;
int ok;
int limit_type; /* which type of limit? */
} LSet;
void L_CrtLst();
void L_DelLst();
void L_DelSt(void *p);
void L_AddInvSt(char *nm);
int L_LdSt(FILE *f);
void L_Ini(int c, int l);
void L_DrwMpTl(int x, int y);
int L_FndNxt();
#endif

View File

@@ -0,0 +1,768 @@
<info>
levels = 8; (per chapter)
chapters = 4;
limit = moves; (either moves or limit)
</info>
<chapter>
name = Tutorial;
author = Michael Speck;
gfx_set = stone;
open = 1;
<level>
limit = 11;
map_w = 8; map_h = 8;
fig_w = 2; fig_h = 2;
<figure>
56;
65;
</figure>
<map>
cccccccc;
c 5 b c;
cbb c;
c 6 b6c;
cccc b c;
...c b c;
...c 5 c;
...ccccc;
</map>
</level>
<level>
limit = 18;
map_w = 10; map_h = 9;
fig_w = 4; fig_h = 2;
<figure>
1 ;
1898;
</figure>
<map>
aaaaaaaaaa;
a 1 8 a;
a bb bb a;
a b b a;
a 8 a;
a aaaa a;
a a..a a;
a9 a..a 1a;
aaaa..aaaa;
</map>
</level>
<level>
limit = 22;
map_w = 11; map_h = 9;
fig_w = 3; fig_h = 3;
<figure>
4 ;
6 6;
4 ;
</figure>
<map>
.aaaaaaaaa.;
.a 4a.;
.a cc caa;
.a 4c a;
aac cc c a;
a c a;
a6 cc a;
aaaaaaaa6 a;
.......aaaa;
</map>
</level>
<level>
limit = 22;
map_w = 10; map_h = 10;
fig_w = 3; fig_h = 1;
<figure>
313;
</figure>
<map>
bbbbbbbbbb;
b 1b;
b aab;
ba a aa3b;
b a a b;
b 3a b;
b a b;
b a aa b;
b a a b;
bbbbbbbbbb;
</map>
</level>
<level>
limit = 25;
map_w = 9; map_h = 9;
fig_w = 3; fig_h = 3;
<figure>
2 ;
787;
2 ;
</figure>
<map>
aaaaaaaaa;
a2c c7 a;
a cc a;
acc c ca;
a a;
a8c c cca;
acc c2a;
a7 a;
aaaaaaaaa;
</map>
</level>
<level>
limit = 21;
map_w = 10; map_h = 12;
fig_w = 3; fig_h = 3;
<figure>
7 9;
8 ;
9 7;
</figure>
<map>
bbbbb;
b 8 b;
b b b;
b b b;
b b b;
b bbbbbb;
bbb b;
b9 bbbb7b;
bbb b;
b bbb;
b7b 9b;
bbbbbbbbbb;
</map>
</level>
<level>
limit = 31; (seconds or moves)
map_w = 10; map_h = 10;
fig_w = 4; fig_h = 3;
<figure>
5 ;
2343;
5 ;
</figure>
<map>
aaaaaaaaaa;
a5 2a;
abb b4b a;
a3b b b a;
a a;
a b b b a;
a b5 b a;
a bbb b a;
a 3 a;
aaaaaaaaaa;
</map>
</level>
<level>
limit = 63;
map_w = 13; map_h = 12;
fig_w = 5; fig_h = 3;
<figure>
55 5;
5000 ;
5 5;
</figure>
<map>
...ccccccccc.;
...c a 5c.;
...c0a c.;
...ca aac.;
cccc aa 5c.;
c0a 5 ccc.;
c c..;
c a5a aaaaccc;
c a 5 c;
c5 aa 0aadc;
cc l c;
.cccccccccccc;
</map>
</level>
</chapter>
<chapter>
name = A few problems;
author = Michael Speck;
gfx_set = wood;
open = 0;
<level>
limit = 16;
map_w = 8; map_h = 7;
fig_w = 3; fig_h = 3;
<figure>
1 1;
232;
1 1;
</figure>
<map>
bbbbbbbb;
b1 c 2b;
b R cb;
bc2 1 3b;
b L cb;
b1 c 1b;
bbbbbbbb;
</map>
</level>
<level>
limit = 35;
map_w = 12; map_h = 9;
fig_w = 5; fig_h = 3;
<figure>
55 ;
50015;
5 ;
</figure>
<map>
bbbbbbbbbbbb;
b 5 c 5b;
b y ccc b;
b5 0l y b;
ccc cc c b;
.c 5 c b;
.c 0cc c1l b;
.c 5 cbbbb;
.ccccccc....;
</map>
</level>
<level>
limit = 19;
map_w = 8; map_h = 8;
fig_w = 3; fig_h = 3;
<figure>
1;
2 ;
1 ;
</figure>
<map>
cccccccc;
c 1 c;
c ccc cc;
c 2 c;
c ccc cc;
c 1 c;
c c c;
cccccccc;
</map>
</level>
<level>
limit = 22;
map_w = 11; map_h = 10;
fig_w = 3; fig_h = 4;
<figure>
9 ;
8 ;
8 ;
393;
</figure>
<map>
....bbb....;
....b3b....;
....b b....;
bbbbb bbbbb;
b b;
b8bbbbbbb8b;
b b.....b b;
b9bbbbbbb9b;
b 3 b;
bbbbbbbbbbb;
</map>
</level>
<level>
limit = 54;
map_w = 12; map_h = 7;
fig_w = 4; fig_h = 3;
<figure>
8 ;
7997;
1 ;
</figure>
<map>
bbbbbbbbbbbb;
b7 c 9b;
b c c1 c cb;
b c b;
b c c cb;
b9 7c 8b;
bbbbbbbbbbbb;
</map>
</level>
<level>
limit = 30; (!)
map_w = 13; map_h = 13;
fig_w = 6; fig_h = 3;
<figure>
99 ;
77 77;
88 ;
</figure>
<map>
....ccccccccc;
....c 9 c;
....c bbbbb7c;
....c c;
ccc.c b b c;
c7ccc 7b b c;
c b b c;
c 8c;
c bbbb8cccccc;
c b..b c.....;
c7bbbb c.....;
c 9 c.....;
cccccccc.....;
</map>
</level>
<level>
limit = 64;
map_w = 13; map_h = 13;
fig_w = 5; fig_h = 5;
<figure>
5 5 ;
5 1 5;
1 1 ;
5 1 5;
5 5 ;
</figure>
<map>
bbbbbb.......;
b5 b.......;
b aa5b.......;
b 1a bbbbbbbb;
b a a 1b;
b 5 a5 ab;
b aa a b;
b 1a a b;
b 5a5 a5b;
bbbbbbbb 1a b;
.......b aa b;
.......b 5 b;
.......bbbbbb;
</map>
</level>
<level>
limit = 16;
map_w = 11; map_h = 9;
fig_w = 5; fig_h = 3;
<figure>
4 ;
8 8 ;
1 1 1;
</figure>
<map>
bbbbbbbbbbb;
b8b b b b8b;
b AAA b;
bbA 1 1 Abb;
b b;
bb 4 bb;
b AA AA b;
b b b1b b b;
bbbbbbbbbbb;
</map>
</level>
</chapter>
<chapter>
name = Sometimes Tricky;
author = Michael Speck;
gfx_set = metal;
open = 0;
<level>
limit = 24;
map_w = 13; map_h = 12;
fig_w = 4; fig_h = 3;
<figure>
5 5;
77 ;
5 5;
</figure>
<map>
..aaaaaaaaaaa;
..a7 5a;
aaa b bb b a;
a b a;
a b a;
a bb5b bb a;
a b b a;
a b 5b aa;
aa bb bb a.;
.a b a.;
.aaa5 7a.;
...aaaaaaaaa.;
</map>
</level>
<level>
limit = 42;
map_w = 12; map_h = 8;
fig_w = 4; fig_h = 4;
<figure>
2 ;
21 ;
89;
9 ;
</figure>
<map>
aaaaa.......;
a a aaaaaaa.;
a 9a x a.;
a 98aa aaa;
aaa aa12 a;
.a x a2 a;
.aaaaaaa a a;
.......aaaaa;
</map>
</level>
<level>
limit = 98;
map_w = 11; map_h = 11;
fig_w = 5; fig_h = 4;
<figure>
555 ;
10701;
232 ;
9 ;
</figure>
<map>
cccccccccc.;
c0 5c2 cc;
c c0 c;
c ccucccc c;
c 3c 9c c;
c l l lc1c;
c 5cu c c;
c ccc c;
c2 c cc 5c;
cc 1c 7 cc;
.ccccccccc.;
</map>
</level>
<level>
limit = 28;
map_w = 11; map_h = 10;
fig_w = 3; fig_h = 4;
<figure>
1 ;
32 ;
23;
1 ;
</figure>
<map>
bbbbbbbbbbb;
bx 1c c 3b;
b c c b;
bccc c c b;
b xc2 b;
b 2cy b;
b c c cccb;
b c c b;
b3 c c1 yb;
bbbbbbbbbbb;
</map>
</level>
<level>
limit = 38;
map_w = 9; map_h = 11;
fig_w = 3; fig_h = 3;
<figure>
7;
98 ;
7;
</figure>
<map>
ccccccc..;
cz 7 c..;
cb bb ccc;
c9 c;
c b bbbuc;
c b z c;
c dc;
c bbbbb c;
c b 8c;
c7 ccccc;
ccccc....;
</map>
</level>
<level>
limit = 20; (!)
map_w = 12; map_h = 9;
fig_w = 3; fig_h = 2;
<figure>
5 ;
4 4;
</figure>
<map>
......aaaaaa;
......a A 4a;
aaaaaaa a;
a a a;
ay wauwdaa;
a 5a a.;
aaaaaaadyuaa;
.....a4 a;
.....aaaaaaa;
</map>
</level>
<level>
limit = 42;
map_w = 12; map_h = 9;
fig_w = 4; fig_h = 3;
<figure>
99 ;
7887;
9 ;
</figure>
<map>
bbbbb..bbbb;
b 9 bbbb xb;
b a 9 d b;
b wa a7 b;
b a w a8b;
b7l a8x b;
bbb a bb;
..bbbb r9b.;
.....bbbbb.;
</map>
</level>
<level>
limit = 22;
map_w = 9; map_h = 7;
fig_w = 4; fig_h = 2;
<figure>
1289;
3 ;
</figure>
<map>
...aaa...;
.aaa3aaa.;
aa a a aa;
a9 2 1a;
aa a a aa;
.a a8a a.;
.aaaaaaa.;
</map>
</level>
</chapter>
<chapter>
name = Hardcore;
author = Michael Speck;
gfx_set = metal;
open = 0;
<level>
limit = 44;
map_w = 12; map_h = 12;
fig_w = 5; fig_h = 3;
<figure>
8 ;
97 79;
8 ;
</figure>
<map>
.....aaaaaaa;
.aaaaa a;
.a 9aaa a;
.a aaa a a;
.a a u a a;
aa a 8R 9 a;
a 7 L8 a aa;
a a d a a.;
a a aaa a.;
a aaa7 a.;
a aaaaa.;
aaaaaaa.....;
</map>
</level>
<level>
limit = 37;
map_w = 11; map_h = 11;
fig_w = 3; fig_h = 5;
<figure>
7 ;
7 ;
3 ;
9 9;
3 ;
</figure>
<map>
aaaaaaaaaa.;
a7 a 9a.;
a a aa;
a aaa ya 3a;
a az aaa a;
a3 xa a;
aa zax a;
.a aaa 7aa;
.a ya aaa.;
.a9 a...;
.aaaaaaa...;
</map>
</level>
<level>
limit = 14;
map_w = 8; map_h = 8;
fig_w = 3; fig_h = 2;
<figure>
131;
2 ;
</figure>
<map>
cccccccc;
c1 w 1c;
c c;
cx y xc;
cccc 3c;
...cy wc;
...c2 c;
...ccccc;
</map>
</level>
<level>
limit = 44;
map_w = 13; map_h = 9;
fig_w = 3; fig_h = 3;
<figure>
232;
7 7;
232;
</figure>
<map>
..aaaaaaaaa..;
..a2aa7aa2a..;
cca a y a acc;
c2 y z 2c;
ccc z ccc;
..cc3 a 3cc..;
...ccU7Dcc...;
....c c....;
....ccccc....;
</map>
</level>
<level>
limit = 35;
map_w = 10; map_h = 12;
fig_w = 3; fig_h = 4;
<figure>
6 ;
656;
6 ;
4 ;
</figure>
<map>
......aaaa;
......a 4a;
....aaa a;
....a6 uwa;
..aaa l a;
..a6 ryaaa;
aaawl 6a..;
a r aaa..;
ayd 6a....;
a aaa....;
a5 a......;
aaaa......;
</map>
</level>
<level>
limit = 47;
map_w = 9; map_h = 9;
fig_w = 3; fig_h = 4;
<figure>
4 4;
5 ;
6 ;
5 ;
</figure>
<map>
ccccccccc;
c4 d r 5c;
c a a a c;
cr r d lc;
c a6a a c;
cu d l dc;
c a a a c;
c5 l u 4c;
ccccccccc;
</map>
</level>
<level>
limit = 43;
map_w = 11; map_h = 11;
fig_w = 5; fig_h = 3;
<figure>
1 1 ;
59395;
191 ;
</figure>
<map>
....bbb....;
.bbbbybbbb.;
.b 5 5 b.;
.b1aa3aa1b.;
bb ax za bb;
bz wb;
bb w y bb;
.b1 a9a 1b.;
.b 9 9 b.;
.bbbbxbbbb.;
....bbb....;
</map>
</level>
<level>
limit = 23;
map_w = 10; map_h = 9;
fig_w = 3; fig_h = 3;
<figure>
2 ;
1 1;
2 ;
</figure>
<map>
..aaaaaaaa;
..ax A a;
aaa aaa;
a2a a1a;
ar xw la;
a1a a2a;
aaa aaa;
a A wa..;
aaaaaaaa..;
</map>
</level>
</chapter>

View File

@@ -0,0 +1,40 @@
.\" Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.TH MARBLES 6 "February 14, 2001"
.SH NAME
marbles \- build figures out of colored marbles
.SH SYNOPSIS
.B marbles
.SH DESCRIPTION
This manual page was written for the Debian GNU/Linux distribution
because the original program does not have a manual page.
.PP
You goal in the puzzle game
.B marbles
is to create a more or less complex figure out of single marbles within
a time limit to reach the next level. Sounds easy? Well, there is a
problem: If a marble starts to move, it will not stop until it hits
a wall or another marble.
.SH OPTIONS
None.
.SH FILES
.TP
.IP "~/.marbles.cfg"
Automatically generated configfile. This is not meant for human editing.
.TP
.IP "/var/lib/games/lmarbles.prfs"
Global preferences and score file. Not for human editing.
.SH BUGS
Please report any bugs you find to Michael Speck <kulkanie@gmx.net>
.SH LICENCE
.B marbles
is covered by the GNU General Public License(GPL).
.SH SEE ALSO
.BR lbreakout (1)
.PP
/usr/share/doc/marbles/*
.SH AUTHOR
Michael Speck <kulkanie@gmx.net>
.PP
This manual page was written by Uwe Hermann <uh1763@hermann-uwe.de>,
for the Debian GNU/Linux system (but may be used by others).

View File

@@ -0,0 +1,539 @@
/***************************************************************************
main.c - description
-------------------
begin : Sam Aug 5 12:36:32 MEST 2000
copyright : (C) 2000 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
#ifdef _WIN32
#include <fcntl.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "menu.h"
#include "cfg.h"
#include "levels.h"
#include "timer.h"
#include "sdl.h"
#include "audio.h"
#include "profile.h"
#include "game.h"
// timer -- timer.c //
extern struct timeb t_c, t_lc;
// quit game quickly ? //
int trm_gm = 0;
// menu config -- cfg.c //
extern Cfg cfg;
// menu manager -- menu.c //
extern MMng mm;
// sdl struct //
extern Sdl sdl;
// levelset list and number of entries -- levels.c //
extern char **ls_lst;
extern int ls_n;
// profiles //
extern DLst prfs;
// string list for the menu -- profile.c //
extern char **prf_lst;
extern int prf_n;
// menu entry containing the profile list //
MEnt *me_prf, *me_del, *me_clr;
// menu actions MUST BE GREATER THAN 0 //
#define MA_NONE 0
#define MA_QUT 1
#define MA_PLY 2
#define MA_HSC 3
/*
====================================================================
Clear the SDL event key (keydown events)
====================================================================
*/
int all_filter( const SDL_Event *event )
{
return 0;
}
void event_clear_sdl_queue()
{
SDL_Event event;
SDL_SetEventFilter( all_filter );
while ( SDL_PollEvent( &event ) );
SDL_SetEventFilter( 0 );
}
/*
previously defined hiscore.h but this file no longer needed
*/
typedef struct {
char nm[12];
int lvl;
int lvs;
int scr;
int pct;
} H_E;
/*
show hiscore and highlight rank r
*/
void H_Shw()
{
int i, j;
SDL_Surface *buf = 0;
SFnt *ft;
Prf *p;
int e_h = mm.ft_nml->h + 2;
int off = 50;
int a_y = 100;
char str[12];
int e_num = prfs.cntr > 10 ? 10 : prfs.cntr;
H_E hscr[e_num];
DL_E *e;
// save screen //
buf = SS_Crt(sdl.scr->w, sdl.scr->h, SDL_SWSURFACE);
D_FDST(buf);
D_FSRC(sdl.scr);
SS_Blt();
// darken screen //
if (cfg.dim)
SDL_DIM();
// draw background //
D_FDST(sdl.scr);
D_FSRC(mm.ss_bkgd);
SS_Blt();
// brighten screen //
if (cfg.dim)
SDL_UNDIM();
else
Sdl_FUpd();
// create highscore list //
memset(hscr, 0, sizeof(hscr));
e = prfs.hd.n;
while (e != &prfs.tl) {
p = (Prf*)e->d;
for (i = 0; i < e_num; i++)
if (p->scr >= hscr[i].scr) {
for (j = e_num - 1; j > i; j--)
hscr[j] = hscr[j - 1];
hscr[i].scr = p->scr;
hscr[i].pct = p->pct;
hscr[i].lvl = p->lvls;
strcpy(hscr[i].nm, p->nm);
break;
}
e = e->n;
}
// write hiscores //
SF_Wrt(mm.ft_nml, sdl.scr, sdl.scr->w / 2, 50, "Best Profiles", 0);
mm.ft_nml->algn = mm.ft_sel->algn = TA_X_L | TA_Y_T;
for (i = 0; i < e_num; i++) {
if (0) // changed later
ft = mm.ft_sel;
else
ft = mm.ft_nml;
ft->algn = TA_X_L | TA_Y_T;
SF_Wrt(ft, sdl.scr, off, a_y + i * e_h, hscr[i].nm, 0);
ft->algn = TA_X_C | TA_Y_T;
sprintf(str, "%i", hscr[i].lvl);
SF_Wrt(ft, sdl.scr, sdl.scr->w / 2, a_y + i * e_h, str, 0);
sprintf(str, "%i", hscr[i].scr);
// sprintf(str, "%i (%i.%i%%)", hscr[i].scr, hscr[i].pct / 10, hscr[i].pct % 10);
ft->algn = TA_X_R | TA_Y_T;
SF_Wrt(ft, sdl.scr, sdl.scr->w - off, a_y + i * e_h, str, 0);
}
mm.ft_nml->algn = mm.ft_sel->algn = TA_X_C | TA_Y_C;
Sdl_FUpd();
// wait for a click //
Sdl_WtFrClk();
//darken screen //
if (cfg.dim)
SDL_DIM();
// restore screen //
D_FDST(sdl.scr);
D_FSRC(buf);
SS_Blt();
// brighten screen //
if (cfg.dim)
SDL_UNDIM();
else
Sdl_FUpd();
// reset timer //
T_Rst();
}
// menu callbacks //
/*
activate / deactivate sound
*/
void CB_Snd()
{
#ifdef SOUND
sound_enable(cfg.s_on);
#endif
}
/*
set sound volume
*/
void CB_StV()
{
#ifdef SOUND
sound_volume(cfg.s_vol * 16);
#endif
}
/*
create a profile
*/
void CB_CrtP()
{
Prf_Crt(cfg.prf_nm);
Prf_CrtLst();
// update menu entries //
ME_CngSwX(me_prf, &cfg.prf, prf_lst, prf_n);
ME_CngSwX(me_del, &cfg.prf, prf_lst, prf_n);
ME_CngSwX(me_clr, &cfg.prf, prf_lst, prf_n);
}
/*
clear a profile
*/
void CB_ClrP()
{
Prf *p = DL_Get(&prfs, cfg.prf);
DL_Clr(&p->sts);
p->lvls = 0;
p->scr = 0;
p->pct = 0;
}
/*
delete a profile
*/
void CB_DelP()
{
if (prfs.cntr < 2) {
printf("WARNING: last profile cannot be deleted\n");
return;
}
// delete from list //
DL_Del(&prfs, cfg.prf);
Prf_CrtLst();
// update menu entries //
ME_CngSwX(me_prf, &cfg.prf, prf_lst, prf_n);
ME_CngSwX(me_del, &cfg.prf, prf_lst, prf_n);
ME_CngSwX(me_clr, &cfg.prf, prf_lst, prf_n);
}
void CB_SrtP()
{
// Prf_Srt();
}
/*
init menu
add all entries
check them
*/
void MM_CrtE()
{
SDL_Surface *ss_bk, *ss_lg;
SFnt *ft_y, *ft_w, *ft_t;
Menu *_main, *opts, *snd, *new, *edit, *del, *clr, *crt, *c_del, *c_clr, *c_crt, *gfx, *ctrl;
MEnt *e;
char *str_diff[] = {"Easy", "Normal", "Hard", "Brainstorm"};
// load and assign gfx //
ss_bk = SS_Ld("gfx/title.bmp", SDL_SWSURFACE);
ss_lg = SS_Ld("gfx/logo.bmp", SDL_SWSURFACE);
ft_y = SF_LdFxd("gfx/f_yellow.bmp", 32, 96, 10);
ft_w = SF_LdFxd("gfx/f_white.bmp", 32, 96, 10);
MM_Ini(ss_bk->w / 2, ss_bk->h - 100, 50, ss_bk, ss_lg, ft_y, ft_w);
// add copyright //
ft_t = SF_Ld("gfx/tiny.sdlfnt");
ft_t->algn = TA_X_R | TA_Y_B;
SF_Wrt(ft_t, ss_bk, ss_bk->w-3, ss_bk->h-1, "(C) 2000 Michael Speck", 0);
ft_t->algn = TA_X_L | TA_Y_B;
SF_Wrt(ft_t, ss_bk, 0, ss_bk->h-1, "http://lgames.sourceforge.net", 0);
SF_Fr(ft_t);
// create and add entrys //
_main = M_Crt(); MM_Add(_main);
opts = M_Crt(); MM_Add(opts);
snd = M_Crt(); MM_Add(snd);
new = M_Crt(); MM_Add(new);
edit = M_Crt(); MM_Add(edit);
del = M_Crt(); MM_Add(del);
clr = M_Crt(); MM_Add(clr);
crt = M_Crt(); MM_Add(crt);
c_del = M_Crt(); MM_Add(c_del);
c_clr = M_Crt(); MM_Add(c_clr);
c_crt = M_Crt(); MM_Add(c_crt);
gfx = M_Crt(); MM_Add(gfx);
ctrl = M_Crt(); MM_Add(ctrl);
// main //
M_Add(_main, ME_CrtSub("New Game", new));
M_Add(_main, ME_CrtAct("Best Profiles", MA_HSC));
M_Add(_main, ME_CrtSub("Options", opts));
M_Add(_main, ME_CrtAct("Quit", MA_QUT));
// options //
M_Add(opts, ME_CrtSub("Controls", ctrl));
M_Add(opts, ME_CrtSub("Graphics", gfx));
#ifdef SOUND
M_Add(opts, ME_CrtSub("Audio", snd));
#else
M_Add(opts, ME_CrtSep("Audio"));
#endif
M_Add(opts, ME_CrtSep(""));
M_Add(opts, ME_CrtSub("Back", _main));
// sound //
e = ME_CrtSw2("Sound: ", &cfg.s_on, "Off", "On");
e->cb = CB_Snd;
M_Add(snd, e);
e = ME_CrtRng("Volume: ", &cfg.s_vol, 1, 8, 1);
e->cb = CB_StV;
M_Add(snd, e);
M_Add(snd, ME_CrtSep(""));
M_Add(snd, ME_CrtSub("Back", opts));
// new game //
M_Add(new, ME_CrtAct("Start", MA_PLY));
M_Add(new, ME_CrtSep(""));
M_Add(new, ME_CrtSwX("Difficulty:", &cfg.diff, str_diff, 4));
if (cfg.ls >= ls_n) cfg.ls = 0; // maybe someone deleted some level sets //
M_Add(new, ME_CrtSwX("Levelset:", &cfg.ls, ls_lst, ls_n));
me_prf = ME_CrtSwX("Profile:", &cfg.prf, prf_lst, prf_n);
M_Add(new, me_prf);
M_Add(new, ME_CrtSep(""));
M_Add(new, ME_CrtSub("Edit Profiles", edit));
M_Add(new, ME_CrtSep(""));
M_Add(new, ME_CrtSub("Back", _main));
// edit //
M_Add(edit, ME_CrtSub("Create Profile", crt));
M_Add(edit, ME_CrtSub("Clear Profile", clr));
M_Add(edit, ME_CrtSub("Delete Profile", del));
M_Add(edit, ME_CrtSep(""));
e = ME_CrtSub("Back", new);
e->cb = CB_SrtP;
M_Add(edit, e);
// create //
M_Add(crt, ME_CrtStr("Profile Name", cfg.prf_nm, 11));
M_Add(crt, ME_CrtSub("Create Profile", c_crt));
M_Add(crt, ME_CrtSep(""));
M_Add(crt, ME_CrtSub("Back", edit));
// confirm create //
e = ME_CrtSub("Yes", crt);
e->cb = CB_CrtP;
M_Add(c_crt, e);
M_Add(c_crt, ME_CrtSub("No", crt));
// clear //
me_clr = ME_CrtSwX("Profile:", &cfg.prf, prf_lst, prf_n);
M_Add(clr, me_clr);
M_Add(clr, ME_CrtSub("Clear Profile", c_clr));
M_Add(clr, ME_CrtSep(""));
M_Add(clr, ME_CrtSub("Back", edit));
// confirm clear //
e = ME_CrtSub("Yes", clr);
e->cb = CB_ClrP;
M_Add(c_clr, e);
M_Add(c_clr, ME_CrtSub("No", clr));
// delete //
me_del = ME_CrtSwX("Profile:", &cfg.prf, prf_lst, prf_n);
M_Add(del, me_del);
M_Add(del, ME_CrtSub("Delete Profile", c_del));
M_Add(del, ME_CrtSep(""));
M_Add(del, ME_CrtSub("Back", edit));
// confirm clear //
e = ME_CrtSub("Yes", del);
e->cb = CB_DelP;
M_Add(c_del, e);
M_Add(c_del, ME_CrtSub("No", del));
// graphics //
M_Add(gfx, ME_CrtSw2("Animations:", &cfg.ani, "Off", "On"));
// M_Add(gfx, ME_CrtSw2("Transparency:", &cfg.trp, "Off", "On"));
M_Add(gfx, ME_CrtSw2("Fullscreen:", &cfg.fscr, "Off", "On"));
M_Add(gfx, ME_CrtSw2("Dim Effect:", &cfg.dim, "Off", "On"));
M_Add(gfx, ME_CrtSep(""));
M_Add(gfx, ME_CrtSub("Back", opts));
// controls
M_Add(ctrl, ME_CrtKey("Up", &cfg.k_up));
M_Add(ctrl, ME_CrtKey("Down", &cfg.k_down));
M_Add(ctrl, ME_CrtKey("Left", &cfg.k_left));
M_Add(ctrl, ME_CrtKey("Right", &cfg.k_right));
M_Add(ctrl, ME_CrtKey("Undo", &cfg.k_undo));
M_Add(ctrl, ME_CrtSep(""));
M_Add(ctrl, ME_CrtSub("Back", opts));
// default valid keys
MM_DfVKys();
// adjust position of all entries in all menus //
MM_AdjP();
// call all callbacks //
MM_CB();
// check for errors
MM_Ck();
}
/*
init sound, menu, profiles, game
main loop for the menu
*/
int main(int argc, char *argv[])
{
SDL_Event e;
int go_on = 1;
int ms;
char aux[64];
#ifdef _WIN32
/* Get Windows to open files in binary mode instead of default text mode */
_fmode = _O_BINARY;
#endif
// just query version? //
if ( argc > 1 && !strncmp( "--version", argv[1], 9 ) ) {
printf( "%s\n", VERSION );
return 0;
}
// random init
srand(time(NULL));
// sdl init //
#ifdef SOUND
Sdl_Ini(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER);
#else
Sdl_Ini(SDL_INIT_VIDEO | SDL_INIT_TIMER);
#endif
sprintf( aux, "LMarbles %s", VERSION );
SDL_WM_SetCaption(aux, 0);
// show logo //
Sdl_StVdMd(512, 384, 16, SDL_SWSURFACE);
// show hardware capabilities //
Sdl_HwCps();
// load config //
C_StPth();
C_Ld();
// load profiles //
Prf_Ini();
if (!Prf_Ld())
cfg.prf = 0;
// create levelset list and reset config's levelset index if nescessary //
L_CrtLst();
if (cfg.ls >= ls_n)
cfg.ls = 0;
#ifdef SOUND
audio_open();
sound_enable( cfg.s_on );
sound_volume( cfg.s_vol * 16 );
#endif
// game init //
G_Ini();
// init and show menu//
MM_CrtE();
MM_Shw(MM_RSZ);
event_clear_sdl_queue();
//menu loop
T_Rst(); // reset time //
while (go_on && !trm_gm) {
M_Hd(mm.c_mn);
if (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT)
trm_gm = 1;
if (e.type == SDL_KEYUP && e.key.keysym.sym == SDLK_ESCAPE)
go_on = 0;
switch (MM_Evt(&e)) {
case MA_QUT:
go_on = 0;
break;
case MA_PLY:
if (G_Opn()) {
G_Run();
G_Cls();
}
break;
case MA_HSC:
M_Shw(mm.c_mn);
Sdl_UpdR();
H_Shw(); // defined in main.c //
break;
}
}
ms = T_Gt();
M_CmA(mm.c_mn, ms);
M_Shw(mm.c_mn);
Sdl_UpdR();
SDL_Delay( 5 );
}
// terminate menu //
MM_Trm();
// terminate game //
G_Trm();
// close soundserver //
#ifdef SOUND
audio_close();
#endif
// save config //
C_Sv();
// free levelset list //
L_DelLst();
// save profiles //
Prf_Sv();
Prf_Trm();
// free screen //
Sdl_Qut();
printf("Bye, bye!\n");
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 908 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 808 B

View File

@@ -0,0 +1,359 @@
<!doctype html public "-//w3c//dtd html 4.0//en">
<html>
<head>
<title>LMarbles Manual Page</title>
</head>
<body bgcolor=#cccccc text=#000000 link=#0000ff vlink=#9632aa alink=#ffffff>
<!-- title -->
<h1 align=center>LMarbles</h1>
<p align=center>
Copyright 2000 Michael Speck<br>
Released under GPL<br><br>
<hr>
</p>
<!-- contents -->
<p>
<h2><a name="toc"> Table of Contents</a></h2>
<ol type=I>
<li><a href="#options">Menu</a></li>
<li><a href="#game">How To Play</a></li>
<li><a href="#controls">Controls</a></li>
<li><a href="#levels">Creating Your Own Levels</a></li>
</ol>
<hr>
</p>
<!-- menu -->
<h3><a name="options">Menu</a></h3>
<p>
<ul type=circle>
<li><i>[New Game]</i> (submenu)
<ul>
<li><i>[Start]</i><br>
Starts a game.</li>
<li><i>[Difficulty]</i><br>
<UL>
<LI><I>Brainstorm:</I>You play against my solution made after some time passed.
I had to play the levels for real so this is a fair move limit.</LI>
<LI><I>Easy:</I> You play against my solution +100% (-20% per chapter).</LI>
<LI><I>Normal:</I> You play against my solution +50%moves (-10%per chapter).</LI>
<LI><I>Hard:</I>You play against my solution +25% moves (-5% per chapter).</LI>
</UL>
<I>Hard</I> gives you twice the score and <I>Brainstorm</I> five times
the score of a <I>Normal</I> game. <I>Easy</I> cuts your score in half.
</li>
<li><i>[Levelset]</i><br>
Set of levels you want to play (e.g. 'Original').</li>
<li><i>[Profile]</i><br>
Profile you want to play with (e.g. 'Michael'). Any progress and score will be written to this profile.</li>
<li><i>[Edit Profiles]</i> (submenu)
<ul>
<li><i>[Create Profile]</i> (submenu)<br>
Enter a profile name (eg your own name) and simply create it. Now choose this new profile at <i>[New Game]/[Profile]</i>
and start the game.
</li>
<li><i>[Clear Profile]</i> (submenu)<br>
This will clear score and any level progress of the choosen profile.
</li>
<li><i>[Delete Profile]</i> (submenu)<br>
This will remove a profile. Of course, a new one using the same name can be recreated (which would be same
like simply clear it).
</li>
</ul>
</li>
</li>
</ul>
</li>
<li><i>[Best Profiles]</i><br>
A list of the ten best players with the following information: name (left side), number of levels finished (middle),
score (right side), average time needed in percent (in brackets; 100%-not even one second needed(impossible); 0%-every single second has been used).
</li>
<li><i>[Options]</i> (submenu)
<ul type=circle>
<li><i>[Graphics]</i> (submenu) </li>
<ul>
<li><i>[Animations]</i><br> Enables/Disables animations.</li>
<li><i>[Fullscreen]</i><br> Switches between windowed and fullscreen mode.</li>
<li><i>[Dim Effect]</i><br> Enables/Disables dim effect. ('Disabled' is recommended when using SDL older than version 1.1.4.)</li>
</ul>
<li><i>[Audio]</i> (submenu) </li>
<ul>
<li><i>[Sound]</i><br> Enables/Disables sound.</li>
<li><i>[Volume]</i><br> Sets volume of sound.</li>
</ul>
</ul>
</li>
<li><i>[Quit]</i><br>
Quits the game!
</li>
</ul>
</p>
<a href="#toc">ToC</a><br><br>
<hr>
<!-- how to play -->
<h3><a name="game">How To Play</a></h3>
<p>
<p>
Marbles is very similiar to Atomix and was heavily inspired by it. Goal is to create a more or less
complex figure out of single marbles within a time limit to reach the next level.<br>
Sounds easy? Well, there is a problem: If a marble starts to move it will not stop until it hits a
wall or marble.
</p>
<p>
There are also some obstacles:<br>
<img src="arrow.jpg" alt="arrow" width=32 height=32><br>
If a marble moves on such an arrow it will change its direction to the direction the arrow points at.
If a marble comes from the direction the arrow points at it will stop before the arrow.<br>
<img src="arrow2.jpg" alt="arrow2" width=32 height=32><br>
These yellow and black stripes mean this tile can neither be accessed from these sides nor from the side the
arrow points at. So there is only one way to get past this obstacle.<br>
<img src="teleport.jpg" alt="teleport" width=32 height=32><br>
If a marble encounters such a teleport it will teleport to the second one of the same color and keep on moving
in the same direction.<br>
<img src="crumble.jpg" alt="crumble" width=32 height=32><br>
Such a crumbling wall takes one, two or three hits before it vanishes completely. The number of hits left is
displayed by a small digit in the lower right corner of the crumbling wall.
</p>
<P>
You play against a move limit and you'll gain the following score when you finished
a level:
<TABLE border=2 cellpadding=10 cellspacing=0>
<TR><TD>Difficulty</TD><TD>Level Bonus</TD><TD>Bonus per remaining move</TD><TR>
<TR><TD>Easy</TD><TD>500</TD><TD>25</TD></TR>
<TR><TD>Normal</TD><TD>1000</TD><TD>50</TD></TR>
<TR><TD>Hard</TD><TD>2000</TD><TD>100</TD></TR>
<TR><TD>Brainstorm</TD><TD>5000</TD><TD>250</TD></TR>
</TABLE>
<i>You will <strong>not</strong> gain points twice for the same level!</i></P>
</P>
<p>
If you run Marbles the very first time only one profile (named 'Michael') exists. You probably want to play with
a profile named like you. How to create and use a new profile is described in <a href="#options">Menu</a>.<br>
Levels are grouped in chapters and chapters are grouped in levelsets. Right now, Marbles comes with just one
levelset called 'Original' containing three chapters with ten levels each. Of course, you can <a href="#levels">create your own levelsets</a>.<br>
<i>You have unlimited tries to solve a level! The order in which you solve levels of one chapter does not matter! There are small lights in the right lower
corner of the screen of one of the following colors: red(cannot be accessed), orange(can be accessed, not solved yet) and
green (already solved, you will not gain any score for solving it again). Just click on a light and confirm
to change the level. To enter a new chapter ALL previous levels have to be solved.</i>
</p>
Although the interface is quite intuitive you should take a look at the <a href="#controls">controls</a>.
</p>
<a href="#toc">ToC</a><br><br>
<hr>
<!-- controls -->
<h3><a name="controls">Controls</a></h3>
<p>
Use your mouse to:<br>
<i>Select a marble:</i> Left-click on it. (You can simply change selection by clicking on another marble)<br>
<i>Release a marble:</i> Right-click anywhere.<br>
<i>Move a marble:</i> When you selected a marble move the mouse pointer into the wanted direction. If movement is
possible the mouse pointer will change into a big arrow pointing into the direction. Then simply left-click.<br>
<i>Change the level:</i> As written in <a href="#game">'How To Play'</a> these lights in the right lower corner
represent the levels. Simply left-click on a green or orange one and confirm the change. (If you choose the
current level (white frame) this will be the same as restarting this level.)<br>
<i>Confirm:</i> When you quit, restart or change the level you will be asked to confirm first by pressing 'y' or
'n'. You can do this with left-click(yes) or right-click(no) as well.
</p>
<p>
Important keys:<br>
[Escape]: Quits the game after confirmation.<br>
[r]: Restarts level after confirmation.<br>
[p]: Pauses game.<br>
[Space]: If you think your last movement was wrong you can restore the old position by pressing Space as
long as the marble did not hit a crumbling wall (can be redefined in options/controls).<br>
<br>
You can use the cursor keys to move a marble (can also be redefined)!<br>
<br>
<i>
If your difficulty is 'Training' press a movement key or left mouse button while a marble is moving to 'warp' it to its destination!
</i>
</p>
<a href="#toc">ToC</a><br><br>
<hr>
<!-- own levels -->
<h3><a name="levels">Creating Your Own Levels</a></h3>
<p>
As described in <a href="#game">'How To Play'</a> levels are grouped in chapters and chapters are grouped in
levelsets. A levelset is a file in Marbles' subdirectory 'levels' without any extension. When finished with the
creation you must become root and copy it to the install directory usually
/usr/local/share/games/marbles/levels (if you installed marbles). That's it. Of course, you must test and change
a lot while developing so you should extract Marbles' source somewhere temporary, run configure with the option
--disable-install which allows you to work in Marbles' temporary 'levels' directory where you can simply edit and test
your levelset. (the 'levels' directory should already contain a file called 'Original').
</p>
<p>
Once again step by step:
<ul>
<li>temporarily extract the source somewhere (e.g. /tmp)</li>
<li>change to this source directory</li>
<li>run './configure --disable-install'; 'make' (do not type 'make install'!!!)</li>
<li>change to ./marbles/levels</li>
<li>create an empty file without any extension (e.g. 'Brainstorm')</li>
<li><b>edit this file properly</b> (as described below)</li>
<li>test it by running Marbles (binary can be found in the parent directory of 'levels')</li>
<li>when everything works fine, become root and install it to Marbles' install directory (usually
/usr/local/share/games/marbles/levels - <i>of course, you must have installed Marbles before doing this</i>)
</ul>
</p>
<p>
When testing your levelsets you should use a separate profile (e.g. called 'Testing').<br>
If you start creating a new levelset with, say, ten levels per chapter but you have made only one level so
far Marbles will stop parsing the file and ask for confirmation if you try to start this levelset (press 'y' or
left-click). All levels before the error can be played without problems but because Marbles stopped parsing
further levels does not exist. Changing to such a non-existing level might result in an infinite loop. But when
you are finished with creating your levelset no errors or warnings should occur! (If you run Marbles in an xterm
errors and warnings will be displayed.)
</p>
<p>
<i>If you have problems writing the file, take a look at 'Original'.</i>
</p>
<p>
<b>How to write the file:</b>
</p>
<p>
<u>Syntax:</u><br>
<i>&lt;subsection&gt;</i><br> starts a subsection (e.g. &lt;level&gt;)<br>
<i>&lt;/subsection&gt;</i><br> ends a subsection (e.g. &lt;/level&gt;)<br>
<i>(comment)</i><br> such a comment <strong>must not</strong> contain any '&lt;' or '&gt;' or ';'<br>
<i>normal entry;</i><br> (e.g. in subsection map of a level: ...a 1 aa...;)<br>
<i>variable = value;</i><br> (e.g. author = Michael Speck;)<br>
</p>
<p><i>
Normal entries and initializations <strong>have to</strong> end with a semicolon! Subsections and comments <strong>must not</strong> end with a semicolon!
</i></p>
<p>
Each levelset starts with a subsection called 'info' containing information about the number of levels per
chapter and the number of chapters.<br>
<b>
&lt;info&gt;<br>
levels = levels_per_chapter; </b>(maximum is 10)<b><br>
chapters = chapter_number; </b>(maximum is 10)<b><br>
&lt;/info&gt;<br>
</b>
</p>
<p>
It follows the definition of each chapter containing information about name, author, used graphics set, whether this
chapter is open from the very beginning and definition of each level (number of levels as you defined in
&lt;info&gt;). Usually only the first chapter is open for playing from the very beginning.<br>
<b>
&lt;chapter&gt;<br>
name = Name Of The Chapter;<br>
author = Your Name;<br>
gfx_set = GfxSet; </b>(either 'stone' or 'metal' or 'wood'; e.g. gfx_set = stone)<b><br>
open = Open?; </b>(1 = open; 0 = all previous levels have to be completed first)<b><br>
<br>
...levels<br>
<br>
&lt;/chapter&gt;<br>
</b>
</p>
<p>
A level is defined as follows. It contains information about the time (in seconds), size of the map, size of
the figure and two subsections with the figure and the map.<br>
<b>
&lt;level&gt;<br>
time = time_in_seconds; </b>(e.g. time = 90;)<b><br>
map_w = map_width; </b>(ranges between 4 and 13)<b><br>
map_h = map_height; </b>(ranges between 4 and 14)<b><br>
fig_w = figure_width; </b>(ranges between 2 and 10)<b><br>
fig_h = figure_height; </b>(ranges between 1 and 10)<b><br>
&lt;figure&gt;<br>
...<br>
&lt;/figure&gt;<br>
&lt;map&gt;<br>
...<br>
&lt;/map&gt;<br>
&lt;/level&gt;<br>
</b>
</p>
<p>
A figure tile is either a marble ID from 0 to 9 or [Space] for no marble.<br>
<img src="marbles.jpg" alt="marbles" width=320 height=32><br>
<pre>
Example:
&lt;figure&gt;
1 2 ;
23454;
1 2 ;
&lt;/figure&gt;
</pre>
</p>
<p>
Valid map tiles are:<br>
'a', 'b', 'c' - different walls<br>
'A', 'B', 'C' - crumbling walls ('C' three, 'B' two, 'A' one hit)<br>
[Space] - floor<br>
'.' - background<br>
'u','d','r','l' - arrows without barriers (up, down, right, left)<br>
'U','D','R','L' - arrows with barriers (up, down, right, left)<br>
'w','x','y','z' - teleports of different colors<br>
'0'..'9' - marbles<br>
<pre>
Example:
&lt;map&gt;
....aaaa;
..aaa 2a;
.aa1 xa;
aa u aa;
a 2 xa.;
aaaaaaa.;
&lt;/map&gt;
</pre>
</p>
<p>
So this is the structure of a levelset:<br>
<b>
&lt;info&gt;<br>
...<br>
&lt;/info&gt;<br>
<br>
&lt;chapter&gt;<br>
...<br>
<br>
&lt;level&gt;<br>
...<br>
&lt;figure&gt;<br>
...<br>
&lt;/figure&gt;<br>
&lt;map&gt;<br>
...<br>
&lt;/map&gt;<br>
&lt;/level&gt;<br>
<br>
...(more levels)<br>
<br>
&lt;/chapter&gt;<br>
<br>
...(more chapters)<br>
</b>
</p>
<p>
Once again: Taking a look at 'Original' might help you a lot...
</p>
<a href="#toc">ToC</a><br><br>
<hr>
<!-- credits -->
<p>
<center><br><a href="mailto:kulkanie@gmx.net">Contact</a></center>
<br>
<font size=-1>
<div align=right>Last Update: December 9th 2000<br></div>
</font>
</p>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B

View File

@@ -0,0 +1,763 @@
/***************************************************************************
menu.c - description
-------------------
begin : Sat Aug 5 2000
copyright : (C) 2000 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "menu.h"
#include <stdlib.h>
#include <string.h>
#include "cfg.h"
extern Sdl sdl;
MMng mm;
extern Cfg cfg;
// menu entry //
/*
free entry
*/
void ME_Fr(void *e)
{
DL_Clr(&((MEnt*)e)->sw);
free(e);
}
/*
all entries have these init steps in common
*/
void ME_Ini(MEnt *e, int t, char *n)
{
DL_Ini(&e->sw);
e->sw.flgs = DL_NOCB | DL_AUTODEL;
e->a = 255;
strcpy(e->nm, n);
e->t = t;
e->dx = e->dy = e->dw = e->dh = 0;
e->x = e->y = 0;
e->cb = 0;
}
/*
set range
*/
void ME_StRng(MEnt* e, int *p, int min, int max, int stp)
{
e->p = p;
e->min = min;
e->max = max;
e->stp = stp;
}
/*
create an empty entry
*/
MEnt* ME_Crt()
{
MEnt *e;
e = malloc(sizeof(MEnt));
if (e == 0) {
printf("ME_Crt: Ups... not enough memory to create menu entry...\n");
exit(1);
}
return e;
}
/*
create separator
*/
MEnt* ME_CrtSep(char *s)
{
MEnt *e = ME_Crt();
ME_Ini(e, ME_SEP, s);
return e;
}
/*
create two switches group
*/
MEnt* ME_CrtSw2(char *n, int *p, char *cap1, char *cap2)
{
char *sw;
MEnt *e = ME_Crt();
ME_Ini(e, ME_SWT, n);
ME_StRng(e, p, 0, 1, 1);
sw = malloc(32);
strcpy(sw, cap1);
DL_Add(&e->sw, sw);
sw = malloc(32);
strcpy(sw, cap2);
DL_Add(&e->sw, sw);
return e;
}
/*
create multi switches group
*/
MEnt* ME_CrtSwX(char *n, int *p, char **caps, int num)
{
int i;
char *sw;
MEnt *e = ME_Crt();
ME_Ini(e, ME_SWT, n);
ME_StRng(e, p, 0, num - 1, 1);
for (i = 0; i < num; i++) {
sw = malloc(32);
strcpy(sw, caps[i]);
DL_Add(&e->sw, sw);
}
return e;
}
/*
create range
*/
MEnt* ME_CrtRng(char *n, int *p, int min, int max, int stp)
{
MEnt *e = ME_Crt();
ME_Ini(e, ME_RNG, n);
ME_StRng(e, p, min, max, stp);
return e;
}
/*
create action
*/
MEnt* ME_CrtAct(char *n, int a_id)
{
MEnt *e = ME_Crt();
ME_Ini(e, ME_ACT, n);
e->act = a_id;
return e;
}
/*
create an edit
min is the current length
max the max length
and p the char pointer
*/
MEnt* ME_CrtStr(char *n, char *p, int m)
{
MEnt *e = ME_Crt();
ME_Ini(e, ME_STR, n);
e->max = m;
e->min = strlen(p);
e->p = (int*)p;
return e;
}
/*
create a submenu
*/
MEnt* ME_CrtSub(char *n, void *m)
{
MEnt *e = ME_Crt();
ME_Ini(e, ME_SUB, n);
e->smn = m;
return e;
}
/*
create a key
*/
MEnt* ME_CrtKey(char *n, int *p)
{
MEnt *e = ME_Crt();
ME_Ini(e, ME_KEY, n);
e->p = p;
return e;
}
/*
update the string and compute size
*/
void ME_SUpd(MEnt* e)
{
char c;
switch (e->t) {
case ME_STR:
sprintf(e->str, "%s: %s", e->nm, (char*)e->p);
break;
case ME_SWT:
sprintf(e->str, "%s %s", e->nm, (char*)DL_Get(&e->sw, *e->p));
break;
case ME_RNG:
sprintf(e->str, "%s %i", e->nm, *e->p);
break;
case ME_KEY:
c = *((char*)e->p);
if (c > 32 && c < 127)
sprintf(e->str, "%s: '%c'", e->nm, c);
else
if (*e->p == 0)
sprintf(e->str, "%s: ???", e->nm);
else
switch (*e->p){
case SDLK_UP:
sprintf(e->str, "%s: Up", e->nm);
break;
case SDLK_DOWN:
sprintf(e->str, "%s: Down", e->nm);
break;
case SDLK_LEFT:
sprintf(e->str, "%s: Left", e->nm);
break;
case SDLK_RIGHT:
sprintf(e->str, "%s: Right", e->nm);
break;
case SDLK_SPACE:
sprintf(e->str, "%s: Space", e->nm);
break;
default:
sprintf(e->str, "%s: %i", e->nm, c);
}
break;
default:
strcpy(e->str, e->nm);
break;
}
e->dw = SF_TxtW(mm.ft_nml, e->str);
e->dh = mm.ft_nml->h;
e->dx = e->x - (e->dw >> 1);
e->dy = e->y - (e->dh >> 1);
}
/*
edit string
*/
void ME_Edt(MEnt *e, int c, int u)
{
if (e->t != ME_STR) return;
if (c == SDLK_BACKSPACE && e->min > 0) {
//clear last char
((char*)e->p)[--e->min] = 0;
}
else
if (c >= 32 && c < 128 && e->min < e->max) {
//letter
((char*)e->p)[e->min++] = u;
}
}
/*
change multi switches group
*/
void ME_CngSwX(MEnt *e, int *p, char **caps, int num)
{
int i;
char *sw;
DL_Clr(&e->sw);
ME_StRng(e, p, 0, num - 1, 1);
for (i = 0; i < num; i++) {
sw = malloc(32);
strcpy(sw, caps[i]);
DL_Add(&e->sw, sw);
}
*e->p = 0;
}
// menu //
/*
create an empty menu
*/
Menu* M_Crt()
{
Menu *m;
m = malloc(sizeof(Menu));
if (m == 0) {
printf("M_Crt(): Ups... not enough memory to create a menu\n");
exit(1);
}
m->c_e = 0;
DL_Ini(&m->ent);
m->ent.flgs = DL_AUTODEL;
m->ent.cb = ME_Fr;
return m;
}
/*
clear a menu
*/
void M_Fr(void *m)
{
DL_Clr(&((Menu*)m)->ent);
free(m);
}
/*
add an entry and select first entry as current
*/
void M_Add(Menu *m, MEnt *e)
{
DL_Add(&m->ent, e);
if (m->c_e == 0 && e->t != ME_SEP) {
m->c_e = e;
m->c_e->a = 0;
}
}
/*
hide a menu
*/
void M_Hd(Menu *m)
{
DL_E *e = m->ent.hd.n;
MEnt *me;
while (e != &m->ent.tl) {
me = (MEnt*)e->d;
D_DST(sdl.scr, me->dx, me->dy, me->dw, me->dh);
D_SRC(mm.ss_bkgd, me->dx, me->dy);
SS_Blt();
Sdl_AddR(me->dx, me->dy, me->dw, me->dh);
e = e->n;
}
}
/*
show a menu by drawing each entry
*/
void M_Shw(Menu *m)
{
DL_E *e = m->ent.hd.n;
MEnt *me;
M_SUpd(m);
while (e != &m->ent.tl) {
me = (MEnt*)e->d;
if (me == m->c_e) {
if (me->a > 0) {
SF_Wrt(mm.ft_nml, sdl.scr, me->x, me->y, me->str, 0);
SF_Wrt(mm.ft_sel, sdl.scr, me->x, me->y, me->str, (int)me->a);
}
else
SF_Wrt(mm.ft_sel, sdl.scr, me->x, me->y, me->str, 0);
}
else {
SF_Wrt(mm.ft_nml, sdl.scr, me->x, me->y, me->str, 0);
if (me->a < 255)
SF_Wrt(mm.ft_sel, sdl.scr, me->x, me->y, me->str, (int)me->a);
}
Sdl_AddR(me->dx, me->dy, me->dw, me->dh);
e = e->n;
}
}
/*
do an ME_SUpd() for all entries
*/
void M_SUpd(Menu *m)
{
DL_E *e = m->ent.hd.n;
while (e != &m->ent.tl) {
ME_SUpd((MEnt*)e->d);
e = e->n;
}
}
/*
compute new alpha value for all entries
*/
void M_CmA(Menu *m, int ms)
{
DL_E *e = m->ent.hd.n;
MEnt *me;
while (e != &m->ent.tl) {
me = (MEnt*)e->d;
if (me->a < 255 && me != m->c_e) {
me->a += mm.a_c * ms;
if (me->a > 255)
me->a = 255;
}
e = e->n;
}
}
// menu manager //
/*
initialize graphics, menu and positions of menu and logo
*/
void MM_Ini(int x, int y, int ly, SDL_Surface *ss_bk, SDL_Surface *ss_lg, SFnt *fn, SFnt *fs)
{
mm.ss_bkgd = ss_bk;
mm.ss_logo = ss_lg;
mm.ft_nml = fn;
mm.ft_sel = fs;
mm.ft_nml->algn = mm.ft_sel->algn = TA_X_C | TA_Y_C;
mm.x = x;
mm.y = y;
mm.ly = ly;
mm.lx = (ss_bk->w - ss_lg->w) / 2;
DL_Ini(&mm.mn);
mm.mn.flgs = DL_AUTODEL;
mm.mn.cb = M_Fr;
mm.c_mn = 0;
mm.a_c = 0.28;
#ifdef SOUND
mm.s_clk = sound_chunk_load("click.wav");
#endif
}
/*
show the menu
sets a new video mode if wanted
*/
void MM_Shw(int rsz)
{
if (rsz)
Sdl_StVdMd(mm.ss_bkgd->w, mm.ss_bkgd->h, 16, SDL_SWSURFACE);
D_FDST(sdl.scr);
D_FSRC(mm.ss_bkgd);
SS_Blt();
D_DST(sdl.scr, mm.lx, mm.ly, mm.ss_logo->w, mm.ss_logo->h);
D_SRC(mm.ss_logo, 0, 0);
SS_Blt();
if (cfg.dim)
SDL_UNDIM();
else
Sdl_FUpd();
if (mm.c_mn == 0 || mm.c_mn->ent.cntr == 0) {
fprintf(stderr, "MM_Shw(): Ups... no current or empty menu defined!\n");
exit(1);
}
mm.c_mn->c_e->a = 0;
M_Shw(mm.c_mn);
Sdl_UpdR();
}
/*
free memory used
*/
void MM_Trm()
{
if (mm.ss_bkgd) SDL_FreeSurface(mm.ss_bkgd);
if (mm.ss_logo) SDL_FreeSurface(mm.ss_logo);
if (mm.ft_nml) SF_Fr(mm.ft_nml);
if (mm.ft_sel) SF_Fr(mm.ft_sel);
DL_Clr(&mm.mn);
#ifdef SOUND
if (mm.s_clk) sound_chunk_free(&mm.s_clk);
#endif
}
/*
add a menu
*/
void MM_Add(Menu *m)
{
DL_Add(&mm.mn, m);
if (mm.mn.cntr == 1)
mm.c_mn = m;
}
/*
adjust position of all entries in all menus relative to mm.x | mm.y as centre
*/
void MM_AdjP()
{
DL_E *m = mm.mn.hd.n;
DL_E *e;
MEnt *me;
int i;
while (m != &mm.mn.tl) {
e = ((Menu*)m->d)->ent.hd.n;
i = 0;
while (e != &((Menu*)m->d)->ent.tl) {
me = (MEnt*)e->d;
me->x = mm.x;
me->y = (mm.y - (((Menu*)m->d)->ent.cntr * mm.ft_nml->h) / 2) + i * mm.ft_nml->h + mm.ft_nml->h / 2;
i++;
e = e->n;
}
m = m->n;
}
}
/*
allow default keys: alphanumerical and arrows
*/
void MM_DfVKys()
{
int i;
memset(mm.vkys, 0, sizeof(mm.vkys));
for (i = 32; i < 128; i++)
mm.vkys[i] = 1;
mm.vkys[SDLK_UP] = 1;
mm.vkys[SDLK_DOWN] = 1;
mm.vkys[SDLK_RIGHT] = 1;
mm.vkys[SDLK_LEFT] = 1;
mm.vkys[SDLK_p] = 0;
mm.vkys[SDLK_f] = 0;
mm.vkys[SDLK_r] = 0;
}
/*
checks if all menus contain at least one entry
and if every menu has an current entry selected
stuff like submenu in an entry is not checked
*/
void MM_Ck()
{
#ifdef DEBUG
DL_E *e = mm.mn.hd.n;
Menu *m;
printf("checking menu... ");
// no menu at all? //
if (mm.mn.cntr == 0) {
printf("NOT ONE MENU FOUND!\n");
exit(1);
}
if (mm.c_mn == 0) {
printf("NO CURRENT MENU SELECTED!\n");
exit(1);
}
while (e != &mm.mn.tl) {
m = (Menu*)e->d;
if (m->ent.cntr == 0) {
printf("YOU'VE ADDED AN EMPTY MENU!\n");
exit(1);
}
if (m->c_e == 0) {
printf("NO CURRENT ENTRY SELECTED!\n");
exit(1);
}
e = e->n;
}
printf("OK\n");
#endif
}
/*
process incoming events
*/
int MM_Evt(SDL_Event *e)
{
DL_E *m, *le;
MEnt *me;
int ex = 0;
// waiting for a key ? //
if (mm.c_mn->c_e->t == ME_KEY && *mm.c_mn->c_e->p == 0) {
if (e->type == SDL_KEYUP && mm.vkys[e->key.keysym.sym]) {
// check other key entries for their value //
m = mm.mn.hd.n;
while (!ex && m != &mm.mn.tl) {
le = ((Menu*)m->d)->ent.hd.n;
while (!ex && le != &((Menu*)m->d)->ent.tl) {
me = (MEnt*)le->d;
if (me->t == ME_KEY && *me->p == e->key.keysym.sym)
ex = 1;
le = le->n;
}
m = m->n;
}
// set key
if (!ex) {
*mm.c_mn->c_e->p = e->key.keysym.sym;
if (mm.c_mn->c_e->cb != 0)
mm.c_mn->c_e->cb();
}
}
return MM_NONE;
}
// normal event
switch (e->type) {
case SDL_MOUSEMOTION:
return MM_SelE(e->motion.x, e->motion.y);
case SDL_MOUSEBUTTONUP:
if (e->button.button == 1)
return MM_UseE(MM_INC);
else
return MM_UseE(MM_DEC);
case SDL_KEYDOWN:
switch (e->key.keysym.sym) {
case SDLK_RETURN:
return MM_UseE(MM_NONE);
case SDLK_UP:
return MM_PrvE();
case SDLK_DOWN:
return MM_NxtE();
case SDLK_LEFT:
return MM_UseE(MM_DEC);
case SDLK_RIGHT:
return MM_UseE(MM_INC);
default:
if (mm.c_mn->c_e->t == ME_STR)
ME_Edt(mm.c_mn->c_e, e->key.keysym.sym, e->key.keysym.unicode);
return MM_NONE;
}
return MM_NONE;
}
return MM_NONE;
}
/*
use an entry
submenu: set submenu
action: return action
range: change pos due to c (inc or dec)
str: add or delete char
*/
int MM_UseE(int c)
{
MEnt *me = mm.c_mn->c_e;
switch (me->t) {
case ME_SUB:
#ifdef SOUND
sound_play(mm.s_clk);
#endif
if (mm.c_mn->c_e->cb != 0)
mm.c_mn->c_e->cb();
mm.c_mn = (Menu*)me->smn;
break;
case ME_ACT:
#ifdef SOUND
sound_play(mm.s_clk);
#endif
if (mm.c_mn->c_e->cb != 0)
mm.c_mn->c_e->cb();
return me->act;
case ME_SWT:
case ME_RNG:
#ifdef SOUND
sound_play(mm.s_clk);
#endif
if (c == MM_DEC) {
*me->p -= me->stp;
if (*me->p < me->min)
*me->p = me->max - ((me->max - me->min) % me->stp);
}
else
if (c == MM_INC) {
*me->p += me->stp;
if (*me->p > me->max)
*me->p = me->min;
}
if (mm.c_mn->c_e->cb != 0)
mm.c_mn->c_e->cb();
break;
case ME_KEY:
*me->p = 0;
if (mm.c_mn->c_e->cb != 0)
mm.c_mn->c_e->cb();
break;
}
return MM_NONE;
}
/*
select prev entry
*/
int MM_PrvE()
{
DL_E *e = DL_GetE(&mm.c_mn->ent, mm.c_mn->c_e)->p;
while (e != &mm.c_mn->ent.hd && ((MEnt*)e->d)->t == ME_SEP) e = e->p;
if (e != &mm.c_mn->ent.hd) {
mm.c_mn->c_e = (MEnt*)e->d;
mm.c_mn->c_e->a = 0;
}
#ifdef SOUND
sound_play(mm.s_clk);
#endif
return MM_NONE;
}
/*
select next entry
*/
int MM_NxtE()
{
DL_E *e = DL_GetE(&mm.c_mn->ent, mm.c_mn->c_e)->n;
while (e != &mm.c_mn->ent.tl && ((MEnt*)e->d)->t == ME_SEP) e = e->n;
if (e != &mm.c_mn->ent.tl) {
mm.c_mn->c_e = (MEnt*)e->d;
mm.c_mn->c_e->a = 0;
}
#ifdef SOUND
sound_play(mm.s_clk);
#endif
return MM_NONE;
}
/*
select an entry at pos x,y if valid
*/
int MM_SelE(int x, int y)
{
DL_E *e = mm.c_mn->ent.hd.n;
MEnt *me, *old = mm.c_mn->c_e;
while (e != &mm.c_mn->ent.tl) {
me = (MEnt*)e->d;
if (me->t != ME_SEP && x >= me->dx && x < me->dx + me->dw && y >= me->dy && y < me->dy + me->dh) {
mm.c_mn->c_e = me;
mm.c_mn->c_e->a = 0;
#ifdef SOUND
if (mm.c_mn->c_e != old)
sound_play(mm.s_clk);
#endif
return MM_NONE;
}
e = e->n;
}
return MM_NONE;
}
void MM_CB()
{
DL_E *e = mm.c_mn->ent.hd.n;
MEnt *me;
while (e != &mm.c_mn->ent.tl) {
me = (MEnt*)e->d;
if (me->cb != 0)
me->cb();
e = e->n;
}
}

View File

@@ -0,0 +1,120 @@
/***************************************************************************
menu.h - description
-------------------
begin : Sat Aug 5 2000
copyright : (C) 2000 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef MENU_H
#define MENU_H
#include "sdl.h"
#include "dynlist.h"
#include "audio.h"
// menu entry //
// entry types //
#define ME_SEP 0
#define ME_SUB 1
#define ME_SWT 2
#define ME_RNG 3
#define ME_ACT 4
#define ME_KEY 5
#define ME_STR 6
typedef struct {
char nm[32];
char str[64];
DLst sw;
int t;
int *p;
int min;
int max;
int stp;
int act;
void *smn;
int x, y;
int dx;
int dy;
int dw;
int dh;
float a;
void (*cb)(void);
} MEnt;
void ME_Fr(void *e);
void ME_Ini(MEnt *e, int t, char *n);
MEnt* ME_CrtSep(char *s);
MEnt* ME_CrtSw2(char *n, int *p, char *cap1, char *cap2);
MEnt* ME_CrtSwX(char *n, int *p, char **caps, int num);
MEnt* ME_CrtRng(char *n, int *p, int min, int max, int stp);
MEnt* ME_CrtAct(char *n, int a_id);
MEnt* ME_CrtStr(char *n, char *p, int m);
MEnt* ME_CrtSub(char *n, void *m);
MEnt* ME_CrtKey(char *n, int *p);
void ME_SUpd(MEnt *e);
void ME_Edt(MEnt *e, int c, int u);
void ME_CngSwX(MEnt *e, int *p, char **caps, int num);
// menu //
typedef struct {
DLst ent;
MEnt *c_e;
} Menu;
Menu* M_Crt();
void M_Fr(void *m);
void M_Add(Menu *m, MEnt *e);
void M_Hd(Menu *m);
void M_Shw(Menu *m);
void M_SUpd(Menu *m);
void M_CmA(Menu *m, int ms);
// menu manager //
// resize or keep resolution ? //
#define MM_KP 0
#define MM_RSZ 1
// return values for MM_Evt(..) //
#define MM_TRMGM -1
#define MM_NONE 0
// increase or decrease a value when use entry ? //
#define MM_INC 0
#define MM_DEC 1
typedef struct {
SDL_Surface *ss_bkgd;
SDL_Surface *ss_logo;
SFnt *ft_nml;
SFnt *ft_sel;
int x, y; // centre of menu in ss_bkgnd //
int lx, ly; // position of logo //
float a_c; // alpha change per ms used for enlightning //
int d; // delay per loop //
DLst mn;
Menu *c_mn;
char vkys[SDLK_LAST];
#ifdef SOUND
Sound_Chunk *s_clk;
#endif
} MMng;
void MM_Ini(int x, int y, int ly, SDL_Surface *ss_bk, SDL_Surface *ss_lg, SFnt *fn, SFnt *fs);
void MM_Shw(int rsz);
void MM_Trm();
void MM_Add(Menu *m);
void MM_AdjP();
void MM_DfVKys();
void MM_Ck();
int MM_Evt(SDL_Event *e);
int MM_UseE(int c);
int MM_PrvE();
int MM_NxtE();
int MM_SelE(int x, int y);
void MM_CB();
#endif

View File

@@ -0,0 +1,422 @@
/***************************************************************************
profile.c - description
-------------------
begin : Sun Sep 17 2000
copyright : (C) 2000 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "profile.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cfg.h"
#include "file.h"
// profiles //
DLst prfs;
// string list for the menu //
char **prf_lst = 0;
int prf_n = 0;
// profile source path //
char prf_pth[256];
// configuration //
extern Cfg cfg;
/* initialize dyn list and source path */
void Prf_Ini()
{
DL_Ini(&prfs);
prfs.flgs = DL_AUTODEL;
prfs.cb = Prf_Del;
sprintf(prf_pth, "%s/lmarbles.prfs", PRF_DIR);
}
/* terminate profiles; must be saved first */
void Prf_Trm()
{
Prf_DelLst();
DL_Clr(&prfs);
}
/* load profiles */
int Prf_Ld()
{
Prf *p;
SInf *st;
int s_num = 0, p_num = 0;
FILE *f = 0;
int not_f = 0;
char str[256];
#ifdef ASCII
int i;
#endif
printf("loading profiles... ");
// read access ? //
if ((f = fopen(prf_pth, "r")) == 0) {
printf("\nWARNING: file %s does not exist; cannot read profiles\n", prf_pth);
Prf_Crt("Michael");
not_f = 1;
}
else {
/* load ascii identification */
#ifdef ASCII
F_GetE(f, str, F_VAL); str[strlen(str) - 1] = 0;
if (strncmp(str,"ascii",5)) {
printf("\nWARNING: trying to load raw binary data in ascii; cannot read profiles\n", prf_pth);
Prf_Crt("Michael");
not_f = 1;
}
else {
#else
fread(str, 5, 1, f);
if (!strncmp(str,"ascii",5)) {
printf("\nWARNING: trying to load in ascii instead of raw binary format; cannot read profiles\n");
Prf_Crt("Michael");
not_f = 1;
}
else {
fseek(f, SEEK_SET, 0);
#endif
/* load numbers of profiles */
#ifdef ASCII
F_GetE(f, str, F_VAL); F_ValToInt(str, &p_num);
#else
fread((void*)&p_num, sizeof(int), 1, f);
#endif
if (p_num <= 0) {
printf("WARNING: bad profile counter: %i\n", p_num);
Prf_Crt("Michael");
not_f = 1;
}
else {
while (p_num--) {
p = malloc(sizeof(Prf));
#ifdef ASCII
/* name */
F_GetE(f, p->nm, F_VAL); p->nm[strlen(p->nm) - 1] = 0;
/* levels played */
F_GetE(f, str, F_VAL); F_ValToInt(str, &p->lvls);
/* score */
F_GetE(f, str, F_VAL); F_ValToInt(str, &p->scr);
/* percentage */
F_GetE(f, str, F_VAL); F_ValToFloat(str, &p->pct);
/* number of levelsets */
F_GetE(f, str, F_VAL); F_ValToInt(str, &s_num);
#else
/* name */
fread(p->nm, sizeof(p->nm), 1, f);
/* levels played */
fread(&p->lvls, sizeof(p->lvls), 1, f);
/* score */
fread(&p->scr, sizeof(p->scr), 1, f);
/* percentage */
fread(&p->pct, sizeof(p->pct), 1, f);
/* number of levelsets */
fread(&s_num, sizeof(int), 1, f);
#endif
DL_Ini(&p->sts);
p->sts.flgs = DL_AUTODEL | DL_NOCB;
if (s_num >= 0)
while (s_num--) {
/* level sets */
st = malloc(sizeof(SInf));
#ifdef ASCII
F_GetE(f, st->nm, F_VAL); st->nm[strlen(st->nm) - 1] = 0;
F_GetE(f, str, F_VAL); F_ValToInt(str, &st->num);
F_GetE(f, str, F_VAL); F_ValToInt(str, &st->l_num);
F_GetE(f, str, F_VAL); F_ValToInt(str, &st->c_num);
for ( i = 0; i < st->c_num; i++) {
F_GetE(f, str, F_VAL); F_ValToChar(str, &st->c_opn[i]);
}
for ( i = 0; i < st->num; i++) {
F_GetE(f, str, F_VAL); F_ValToChar(str, &st->cmp[i]);
}
#else
fread(st->nm, sizeof(st->nm), 1, f);
fread(&st->num, sizeof(int), 1, f);
fread(&st->l_num, sizeof(int), 1, f);
fread(&st->c_num, sizeof(int), 1, f);
fread(st->c_opn, sizeof(char), st->c_num, f);
fread(st->cmp, sizeof(char), st->num, f);
#endif
DL_Add(&p->sts, st);
}
DL_Add(&prfs, p);
}
}
printf("ok\n");
#ifdef ASCII
}
#else
}
#endif
fclose(f);
}
Prf_CrtLst();
return !not_f;
}
/* save profiles */
void Prf_Sv()
{
DL_E *e = prfs.hd.n, *le = 0;
Prf *p;
SInf *st;
FILE *f;
#ifdef ASCII
int i;
char str[256];
#endif
printf("saving profiles... ");
if ((f = fopen(prf_pth, "w")) == 0) {
printf("WARNING: no write access to %s\n", prf_pth);
}
else {
/* save ascii identification */
#ifdef ASCII
F_WrtE(f, "ascii");
#endif
/* save numbers of profiles */
#ifdef ASCII
F_IntToStr(str, prfs.cntr); F_WrtE(f, str);
#else
fwrite((void*)&prfs.cntr, sizeof(int), 1, f);
#endif
while (e != &prfs.tl) {
p = (Prf*)e->d;
#ifdef ASCII
/* save name -- 12 chars */
F_WrtE(f, p->nm);
/* levels played */
F_IntToStr(str, p->lvls); F_WrtE(f, str);
/* score */
F_IntToStr(str, p->scr); F_WrtE(f, str);
/* percentage */
F_FloatToStr(str, p->pct); F_WrtE(f, str);
/* save number of levelsets */
F_IntToStr(str, p->sts.cntr); F_WrtE(f, str);
#else
/* save name -- 12 chars */
fwrite(p->nm, sizeof(p->nm), 1, f);
/* levels played */
fwrite(&p->lvls, sizeof(p->lvls), 1, f);
/* score */
fwrite(&p->scr, sizeof(p->scr), 1, f);
/* percentage */
fwrite(&p->pct, sizeof(p->pct), 1, f);
/* save number of levelsets */
fwrite(&p->sts.cntr, sizeof(int), 1, f);
#endif
/* save all levelsets */
le = p->sts.hd.n;
while (le != &p->sts.tl) {
st = (SInf*)le->d;
#ifdef ASCII
/* save name -- 32 chars */
F_WrtE(f, st->nm);
/* save number of flags */
F_IntToStr(str, st->num); F_WrtE(f, str);
/* save level peer chapter number */
F_IntToStr(str, st->l_num); F_WrtE(f, str);
/* save chapter number */
F_IntToStr(str, st->c_num); F_WrtE(f, str);
/* save chapter open flags */
for ( i = 0; i < st->c_num; i++ ) {
F_IntToStr(str, st->c_opn[i]); F_WrtE(f, str);
}
/* save flags */
for ( i = 0; i < st->num; i++ ) {
F_IntToStr(str, st->cmp[i]); F_WrtE(f, str);
}
#else
/* save name -- 32 chars */
fwrite(st->nm, sizeof(st->nm), 1, f);
/* save number of flags */
fwrite(&st->num, sizeof(int), 1, f);
/* save level peer chapter number */
fwrite(&st->l_num, sizeof(int), 1, f);
/* save chapter number */
fwrite(&st->c_num, sizeof(int), 1, f);
/* save chapter open flags */
fwrite(st->c_opn, sizeof(char), st->c_num, f);
/* save flags */
fwrite(st->cmp, sizeof(char), st->num, f);
#endif
le = le->n;
}
e = e->n;
}
printf("ok\n");
fclose(f);
}
}
/* create a new profile */
void Prf_Crt(char *nm)
{
Prf *p;
DL_E *e = prfs.hd.n;
// if the name already exists the profile is not created //
while (e != &prfs.tl) {
if (!strcmp(((Prf*)e->d)->nm, nm)) {
printf("WARNING: profile '%s' already exists\n", nm);
return;
}
e = e->n;
}
p = malloc(sizeof(Prf));
strcpy(p->nm, nm);
p->scr = 0;
p->pct = 0;
p->lvls = 0;
DL_Ini(&p->sts);
p->sts.flgs = DL_AUTODEL | DL_NOCB;
DL_Add(&prfs, p);
}
/* delete an existing profile by pointer */
void Prf_Del(void *p)
{
DL_Clr(&((Prf*)p)->sts);
free(p);
}
/* register or find a levelset with name nm */
SInf* Prf_RegLS(Prf *p, LSet *l_st)
{
int i;
DL_E *e = p->sts.hd.n;
SInf *s;
/* maybe it already exists */
while (e != &p->sts.tl) {
s = (SInf*)e->d;
if (!strcmp(s->nm, l_st->nm)) {
if (l_st->c_num != s->c_num || l_st->l_num != s->l_num) {
// seems to be changed; clear it //
s->num = l_st->c_num * l_st->l_num;
s->l_num = l_st->l_num;
s->c_num = l_st->c_num;
for (i = 0; i < s->c_num; i++)
s->c_opn[i] = l_st->ch[i].opn;
memset(s->cmp, 0, sizeof(s->cmp));
printf("WARNING: profile '%s': set info '%s' seems to be out of date\n", p->nm, l_st->nm);
}
return s;
}
e = e->n;
}
/* must be registered */
s = malloc(sizeof(SInf));
strcpy(s->nm, l_st->nm);
s->num = l_st->c_num * l_st->l_num;
s->l_num = l_st->l_num;
s->c_num = l_st->c_num;
for (i = 0; i < s->c_num; i++)
s->c_opn[i] = l_st->ch[i].opn;
memset(s->cmp, 0, sizeof(s->cmp));
DL_Add(&p->sts, s);
return s;
}
/* create profile name list */
void Prf_CrtLst()
{
int i = 0;
DL_E *e = prfs.hd.n;
Prf *p;
Prf_DelLst();
prf_lst = malloc(sizeof(char*) * prfs.cntr);
while (e != &prfs.tl) {
p = (Prf*)e->d;
prf_lst[i] = malloc(sizeof(p->nm) + 1);
strcpy(prf_lst[i], p->nm);
i++;
e = e->n;
}
prf_n = i;
}
/* delete profile name list */
void Prf_DelLst()
{
int i;
if (prf_lst == 0) return;
for (i = 0; i < prf_n; i++)
free(prf_lst[i]);
free(prf_lst);
}
/*
sort all profiles best profile comes first
*/
void Prf_Srt()
{
void *p;
DL_E *e = prfs.hd.n, *e2;
if (prfs.cntr == 0) return;
while (e != prfs.tl.p) {
e2 = e->n;
while (e2 != &prfs.tl) {
if (((Prf*)e2->d)->scr > ((Prf*)e->d)->scr) {
p = e2->d;
e2->d = e->d;
e->d = p;
}
e2 = e2->n;
}
e = e->n;
}
}
/*
update Profile p's score and info
s is rem_time / max_time of that level
*/
void Prf_Upd(Prf *p, SInf *inf, int l_id, float pct, int scr)
{
float new_p;
#ifdef DEBUG
float old_p = p->pct;
printf("level %i...", l_id);
#endif
if (!inf->cmp[l_id]) {
/* mark as completed */
inf->cmp[l_id] = 1;
/* update percentage */
if (p->lvls == 0)
p->pct = pct;
else {
new_p = (p->pct * p->lvls + pct) / (p->lvls + 1);
p->pct = new_p;
}
p->lvls++;
p->scr += scr;
#ifdef DEBUG
printf("marked as completed\n");
printf("added %4.2f: percentage changed from %4.2f to %4.2f\n", pct, old_p, p->pct);
printf("score added: %i\n", scr);
#endif
}
#ifdef DEBUG
else
printf("already finished\n");
#endif
}

View File

@@ -0,0 +1,53 @@
/***************************************************************************
profile.h - description
-------------------
begin : Sun Sep 17 2000
copyright : (C) 2000 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef PROFILE_H
#define PROFILE_H
#include "levels.h"
#include "dynlist.h"
typedef struct {
char nm[32];
int num;
int l_num; // levels per chapter //
int c_num;
char c_opn[MAX_CHPTRS];
char cmp[MAX_LVLS * MAX_CHPTRS];
} SInf;
typedef struct {
char nm[12];
int lvls;
int scr; // total score gained
float pct; // percentage of time needed to complete a level
DLst sts;
} Prf;
void Prf_Ini();
void Prf_Trm();
int Prf_Ld();
void Prf_Sv();
void Prf_Crt(char *nm);
void Prf_Del(void *p);
SInf* Prf_RegLS(Prf *p, LSet *l_st);
void Prf_CrtLst();
void Prf_DelLst();
void Prf_Srt();
void Prf_Upd(Prf *p, SInf *inf, int l_id, float pct, int scr);
#endif

View File

@@ -0,0 +1,628 @@
/***************************************************************************
sdl.c - description
-------------------
begin : Thu Apr 20 2000
copyright : (C) 2000 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "sdl.h"
#include <stdlib.h>
#include <string.h>
extern int trm_gm;
Sdl sdl;
// sdl surface //
/*
load a surface from file putting it in soft or hardware mem
*/
SDL_Surface* SS_Ld(char *fname, int f)
{
SDL_Surface *buf;
SDL_Surface *new_sur;
char path[strlen(SRC_DIR)+ strlen(fname) + 2];
sprintf(path, "%s/%s", SRC_DIR, fname);
buf = SDL_LoadBMP(path);
if (buf == 0) {
fprintf(stderr, "ERR: ssur_load: file '%s' not found or not enough memory\n", path);
if (f & SDL_NONFATAL)
return 0;
else
exit(1);
}
new_sur = SS_Crt(buf->w, buf->h, f);
SDL_BlitSurface(buf, 0, new_sur, 0);
SDL_FreeSurface(buf);
return new_sur;
}
/*
create an surface
MUST NOT BE USED IF NO SDLSCREEN IS SET
*/
SDL_Surface* SS_Crt(int w, int h, int f)
{
SDL_Surface *sur;
SDL_PixelFormat *spf = SDL_GetVideoSurface()->format;
if ((sur = SDL_CreateRGBSurface(f, w, h, spf->BitsPerPixel, spf->Rmask, spf->Gmask, spf->Bmask, spf->Amask)) == 0) {
fprintf(stderr, "ERR: ssur_create: not enough memory to create surface...\n");
exit(1);
}
SDL_SetColorKey(sur, SDL_SRCCOLORKEY, SDL_MapRGB(sur->format,0,0,0));
SDL_SetAlpha(sur, 0, 0); // no alpha //
return sur;
}
/*
return display format
*/
int SS_DpyFmt(SDL_Surface *sur)
{
if ((sur = SDL_DisplayFormat(sur)) == 0) {
fprintf(stderr, "ERR: ssur_displayformat: convertion failed\n");
return 1;
}
return 0;
}
/*
lock surface
*/
void SS_Bgn(SDL_Surface *sur)
{
if (SDL_MUSTLOCK(sur))
SDL_LockSurface(sur);
}
/*
unlock surface
*/
void SS_End(SDL_Surface *sur)
{
if (SDL_MUSTLOCK(sur))
SDL_UnlockSurface(sur);
}
/*
blit surface with destination D_DST and source D_SRC using it's actual alpha and color key settings
*/
void SS_Blt(void)
{
#ifdef SDL_1_1_5
if (sdl.s.s->flags & SDL_SRCALPHA)
SDL_SetAlpha(sdl.s.s, SDL_SRCALPHA, 255 - sdl.s.s->format->alpha);
#endif
SDL_BlitSurface(sdl.s.s, &sdl.s.r, sdl.d.s, &sdl.d.r);
#ifdef SDL_1_1_5
if (sdl.s.s->flags & SDL_SRCALPHA)
SDL_SetAlpha(sdl.s.s, SDL_SRCALPHA, 255 - sdl.s.s->format->alpha);
#endif
}
/*
do an alpha blit
*/
void SS_ABlt(int alpha)
{
#ifdef SDL_1_1_5
SDL_SetAlpha(sdl.s.s, SDL_SRCALPHA, 255 - alpha);
#else
SDL_SetAlpha(sdl.s.s, SDL_SRCALPHA, alpha);
#endif
SDL_BlitSurface(sdl.s.s, &sdl.s.r, sdl.d.s, &sdl.d.r);
SDL_SetAlpha(sdl.s.s, 0, 0);
}
/*
fill surface with color c
*/
void SS_Fill(int c)
{
SDL_FillRect(sdl.d.s, &sdl.d.r, SDL_MapRGB(sdl.d.s->format, c >> 16, (c >> 8) & 0xFF, c & 0xFF));
}
/* get pixel */
Uint32 get_pixel( SDL_Surface *surf, int x, int y )
{
int pos = 0;
Uint32 pixel = 0;
pos = y * surf->pitch + x * surf->format->BytesPerPixel;
memcpy( &pixel, surf->pixels + pos, surf->format->BytesPerPixel );
return pixel;
}
// sdl font //
/*
load a font using the width values in the file
*/
SFnt* SF_Ld(char *fname)
{
SFnt *fnt = 0;
FILE *file = 0;
char path[strlen(SRC_DIR)+ strlen(fname) + 2];
int i;
sprintf(path, "%s/%s", SRC_DIR, fname);
fnt = malloc(sizeof(SFnt));
if (fnt == 0) {
fprintf(stderr, "ERR: sfnt_load: not enough memory\n");
exit(1);
}
if ((fnt->ss = SS_Ld(fname, SDL_SWSURFACE)) == 0)
exit(1);
fnt->algn = TA_X_L | TA_Y_T;
fnt->clr = 0x00FFFFFF;
fnt->h = fnt->ss->h;
//table
file = fopen(path, "r");
fseek(file, -1, SEEK_END);
fread(&fnt->off, 1, 1, file);
#ifdef DEBUG
printf("offset: %i\n", fnt->off);
#endif
fseek(file, -2, SEEK_END);
fread(&fnt->len, 1, 1, file);
#ifdef DEBUG
printf("number: %i\n", fnt->len);
#endif
fseek(file, -2 - fnt->len, SEEK_END);
fread(fnt->lw, 1, fnt->len, file);
#ifdef DEBUG
printf("letter width: %i\n", fnt->len);
for (i = 0; i < fnt->len; i++)
printf("%i ", fnt->lw[i]);
printf("\n");
#endif
fclose(file);
//letter offsets
fnt->loff[0] = 0;
for (i = 1; i < fnt->len; i++)
fnt->loff[i] = fnt->loff[i - 1] + fnt->lw[i - 1];
//allowed keys
memset(fnt->keys, 0, 256);
for (i = 0; i < fnt->len; i++) {
fnt->keys[i + fnt->off] = 1;
}
fnt->lX = fnt->lY = fnt->lW = fnt->lH = 0;
return fnt;
}
/*
load a font with fixed size
*/
SFnt* SF_LdFxd(char *f, int off, int len, int w)
{
int i;
SFnt *fnt;
char path[strlen(SRC_DIR)+ strlen(f) + 2];
sprintf(path, "%s/%s", SRC_DIR, f);
fnt = malloc(sizeof(SFnt));
if (fnt == 0) {
fprintf(stderr, "ERR: sfnt_load: not enough memory\n");
exit(1);
}
if ((fnt->ss = SS_Ld(f, SDL_SWSURFACE)) == 0)
exit(1);
fnt->algn = TA_X_L | TA_Y_T;
fnt->clr = 0x00FFFFFF;
fnt->h = fnt->ss->h;
fnt->off = off;
fnt->len = len;
for (i = 0; i < len; i++)
fnt->lw[i] = w;
//letter offsets
fnt->loff[0] = 0;
for (i = 1; i < fnt->len; i++)
fnt->loff[i] = fnt->loff[i - 1] + w;
//allowed keys
memset(fnt->keys, 0, 256);
for (i = 0; i < fnt->len; i++) {
fnt->keys[i + fnt->off] = 1;
}
fnt->lX = fnt->lY = fnt->lW = fnt->lH = 0;
return fnt;
}
/*
free memory
*/
void SF_Fr(SFnt *fnt)
{
if (fnt->ss) SDL_FreeSurface(fnt->ss);
free(fnt);
}
/*
write something with transparency
*/
int SF_Wrt(SFnt *fnt, SDL_Surface *dest, int x, int y, char *str, int alpha)
{
int c_abs;
int len = strlen(str);
int pix_len = 0;
int px = x, py = y;
int i;
SDL_Surface *spf = SDL_GetVideoSurface();
pix_len = SF_TxtW(fnt, str);
for (i = 0; i < len; i++)
if (!fnt->keys[(int)str[i]])
str[i] = ' ';
//alignment
if (fnt->algn & TA_X_C)
px -= pix_len >> 1;
else
if (fnt->algn & TA_X_R)
px -= pix_len;
if (fnt->algn & TA_Y_C)
py -= fnt->h >> 1;
else
if (fnt->algn & TA_Y_B)
py -= fnt->h;
fnt->lX = px; if (fnt->lX < 0) fnt->lX = 0;
fnt->lY = py; if (fnt->lY < 0) fnt->lY = 0;
fnt->lW = pix_len; if (fnt->lX + fnt->lW >= spf->w) fnt->lW = spf->w - fnt->lX;
fnt->lH = fnt->h; if (fnt->lY + fnt->lH >= spf->h) fnt->lH = spf->h - fnt->lY;
if (alpha != 0)
SDL_SetAlpha(fnt->ss, SDL_SRCALPHA, alpha);
else
SDL_SetAlpha(fnt->ss, 0, 0);
for (i = 0; i < len; i++) {
c_abs = str[i] - fnt->off;
D_DST(dest, px, py, fnt->lw[c_abs], fnt->h);
D_SRC(fnt->ss, fnt->loff[c_abs], 0);
SS_Blt();
px += fnt->lw[c_abs];
}
return 0;
}
/*
lock font surface
*/
void SF_Bgn(SFnt *fnt)
{
SS_Bgn(fnt->ss);
}
/*
unlock font surface
*/
void SF_End(SFnt *fnt)
{
SS_End(fnt->ss);
}
/*
return last update region
*/
SDL_Rect SF_LstR(SFnt *fnt)
{
SDL_Rect rect={fnt->lX, fnt->lY, fnt->lW, fnt->lH};
return rect;
}
/*
return the text width in pixels
*/
int SF_TxtW(SFnt *fnt, char *str)
{
unsigned int i;
int pix_len = 0;
for (i = 0; i < strlen(str); i++)
pix_len += fnt->lw[str[i] - fnt->off];
return pix_len;
}
// sdl //
/*
initialize sdl
*/
void Sdl_Ini(int f)
{
sdl.scr = 0;
if (SDL_Init(f) < 0) {
fprintf(stderr, "ERR: sdl_init: %s", SDL_GetError());
exit(1);
}
SDL_EnableUNICODE(1);
atexit(SDL_Quit);
}
/*
free screen
*/
void Sdl_Qut()
{
if (sdl.scr) SDL_FreeSurface(sdl.scr);
}
/*
set video mode and give information about hardware capabilities
*/
int Sdl_StVdMd(int w, int h, int d, int f)
{
int depth;
#ifdef DEBUG
SDL_PixelFormat *fmt;
#endif
if (sdl.scr) {
SDL_FreeSurface(sdl.scr);
}
else { /* load window icon on first time setup */
SDL_Surface *icon;
if ((icon = SDL_LoadBMP(SRC_DIR "/gfx/win_icon.bmp")) != NULL) {
SDL_SetColorKey(icon, SDL_SRCCOLORKEY, SDL_MapRGB(icon->format,255,255,255));
SDL_WM_SetIcon(icon, NULL);
}
}
// is this mode is supported
depth = SDL_VideoModeOK(w, h, d, f);
if ( depth == 0 ) {
fprintf(stderr, "ERR: SDL_VideoModeOK says mode %ix%ix%i is invalid...\ntrying to emulate with 16 bits depth\n", w, h, d);
depth = 16;
}
// set video mode
if ((sdl.scr = SDL_SetVideoMode(w, h, depth, f)) == 0) {
fprintf(stderr, "ERR: sdl_setvideomode: %s", SDL_GetError());
return 1;
}
#ifdef DEBUG
if (f & SDL_HWSURFACE && !(sdl.scr->flags & SDL_HWSURFACE))
fprintf(stderr, "unable to create screen in hardware memory...\n");
if (f & SDL_DOUBLEBUF && !(sdl.scr->flags & SDL_DOUBLEBUF))
fprintf(stderr, "unable to create double buffered screen...\n");
if (f & SDL_FULLSCREEN && !(sdl.scr->flags & SDL_FULLSCREEN))
fprintf(stderr, "unable to switch to fullscreen...\n");
fmt = sdl.scr->format;
printf("video mode format:\n");
printf("Masks: R=%i, G=%i, B=%i\n", fmt->Rmask, fmt->Gmask, fmt->Bmask);
printf("LShft: R=%i, G=%i, B=%i\n", fmt->Rshift, fmt->Gshift, fmt->Bshift);
printf("RShft: R=%i, G=%i, B=%i\n", fmt->Rloss, fmt->Gloss, fmt->Bloss);
printf("BBP: %i\n", fmt->BitsPerPixel);
printf("-----\n");
#endif
return 0;
}
/*
show hardware capabilities
*/
void Sdl_HwCps()
{
const SDL_VideoInfo *vi = SDL_GetVideoInfo();
char *ny[2] = {"No", "Yes"};
printf("video hardware capabilities:\n");
printf("Hardware Surfaces: %s\n", ny[vi->hw_available]);
printf("HW_Blit (CC, A): %s (%s, %s)\n", ny[vi->blit_hw], ny[vi->blit_hw_CC], ny[vi->blit_hw_A]);
printf("SW_Blit (CC, A): %s (%s, %s)\n", ny[vi->blit_sw], ny[vi->blit_sw_CC], ny[vi->blit_sw_A]);
printf("HW_Fill: %s\n", ny[vi->blit_fill]);
printf("Video Memory: %i\n", vi->video_mem);
printf("------\n");
}
/*
update just one rect
*/
void Sdl_Upd(int x, int y, int w, int h)
{
SDL_UpdateRect(sdl.scr, x, y, w, h);
}
/*
do a full update
*/
void Sdl_FUpd()
{
SDL_UpdateRect(sdl.scr, 0, 0, 0 ,0);
}
/*
draw all update regions
*/
void Sdl_UpdR()
{
if (sdl.rnum == SDL_MAX_RGNS)
SDL_UpdateRect(sdl.scr, 0, 0, sdl.scr->w, sdl.scr->h);
else
SDL_UpdateRects(sdl.scr, sdl.rnum, sdl.rgns);
sdl.rnum = 0;
}
/*
add update region
*/
void Sdl_AddR(int x, int y, int w, int h)
{
if (sdl.rnum == SDL_MAX_RGNS) return;
if (x < 0) {
w += x;
x = 0;
}
if (y < 0) {
h += y;
y = 0;
}
if (x + w > sdl.scr->w)
w = sdl.scr->w - x;
if (y + h > sdl.scr->h)
h = sdl.scr->h - y;
if (w <= 0 || h <= 0)
return;
sdl.rgns[sdl.rnum].x = x;
sdl.rgns[sdl.rnum].y = y;
sdl.rgns[sdl.rnum].w = w;
sdl.rgns[sdl.rnum].h = h;
sdl.rnum++;
}
/*
fade screen to black
*/
void Sdl_Dim(int steps, int delay, int trp)
{
#ifndef NODIM
SDL_Surface *buffer;
int per_step = trp / steps;
int i;
if (trm_gm) return;
buffer = SS_Crt(sdl.scr->w, sdl.scr->h, SDL_SWSURFACE);
SDL_SetColorKey(buffer, 0, 0);
D_FDST(buffer);
D_FSRC(sdl.scr);
SS_Blt();
for (i = 0; i <= trp; i += per_step) {
D_FDST(sdl.scr);
SS_Fill(0x0);
D_FSRC(buffer);
SS_ABlt(i);
Sdl_FUpd();
SDL_Delay(delay);
}
if (trp == 255) {
D_FDST(sdl.scr);
SS_Fill(0x0);
Sdl_FUpd();
}
SDL_FreeSurface(buffer);
#else
Sdl_FUpd();
#endif
}
/*
undim screen
*/
void Sdl_UnDim(int steps, int delay, int trp)
{
#ifndef NODIM
SDL_Surface *buffer;
int per_step = trp / steps;
int i;
if (trm_gm) return;
buffer = SS_Crt(sdl.scr->w, sdl.scr->h, SDL_SWSURFACE);
SDL_SetColorKey(buffer, 0, 0);
D_FDST(buffer);
D_FSRC(sdl.scr);
SS_Blt();
for (i = trp; i >= 0; i -= per_step) {
D_FDST(sdl.scr);
SS_Fill(0x0);
D_FSRC(buffer);
SS_ABlt(i);
Sdl_FUpd();
SDL_Delay(delay);
}
D_FDST(sdl.scr);
D_FSRC(buffer);
SS_Blt();
Sdl_FUpd();
SDL_FreeSurface(buffer);
#else
Sdl_FUpd();
#endif
}
/*
wait for a key
*/
int Sdl_WtFrKy()
{
//wait for key
SDL_Event event;
while (1) {
SDL_WaitEvent(&event);
if (event.type == SDL_QUIT) {
trm_gm = 1;
return 0;
}
if (event.type == SDL_KEYUP)
return event.key.keysym.sym;
}
}
/*
wait for a key or mouse click
*/
void Sdl_WtFrClk()
{
//wait for key or button
SDL_Event event;
while (1) {
SDL_WaitEvent(&event);
if (event.type == SDL_QUIT) {
trm_gm = 1;
return;
}
if (event.type == SDL_KEYUP || event.type == SDL_MOUSEBUTTONUP)
return;
}
}
/*
lock surface
*/
void Sdl_Bgn()
{
if (SDL_MUSTLOCK(sdl.scr))
SDL_LockSurface(sdl.scr);
}
/*
unlock surface
*/
void Sdl_End()
{
if (SDL_MUSTLOCK(sdl.scr))
SDL_UnlockSurface(sdl.scr);
}
/*
flip hardware screens (double buffer)
*/
void Sdl_Flp()
{
SDL_Flip(sdl.scr);
}

View File

@@ -0,0 +1,115 @@
/***************************************************************************
sdl.h - description
-------------------
begin : Thu Apr 20 2000
copyright : (C) 2000 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef SDL_H
#define SDL_H
#include <SDL/SDL.h>
#include <SDL_mixer.h>
#ifdef __cplusplus
extern "C" {
#endif
// draw region //
#define D_SRC(p, i, j) {sdl.s.s = p; sdl.s.r.x = i; sdl.s.r.y = j; sdl.s.r.w = sdl.d.r.w; sdl.s.r.h = sdl.d.r.h;}
#define D_DST(p, i, j, k, l) {sdl.d.s = p; sdl.d.r.x = i; sdl.d.r.y = j; sdl.d.r.w = k; sdl.d.r.h = l;}
#define D_FSRC(p) {sdl.s.s = p; sdl.s.r.x = 0; sdl.s.r.y = 0; sdl.s.r.w = sdl.d.r.w; sdl.s.r.h = sdl.d.r.h;}
#define D_FDST(p) {sdl.d.s = p; sdl.d.r.x = 0; sdl.d.r.y = 0; sdl.d.r.w = (p)->w; sdl.d.r.h = (p)->h;}
typedef struct {
SDL_Surface *s;
SDL_Rect r;
} DrawRgn;
// Sdl Surface //
#define SDL_NONFATAL 0x10000000
SDL_Surface* SS_Ld(char *fname, int f);
SDL_Surface* SS_Crt(int w, int h, int f);
int SS_DpyFmt(SDL_Surface *sur);
void SS_Bgn(SDL_Surface *sur);
void SS_End(SDL_Surface *sur);
void SS_Blt(void);
void SS_ABlt(int alpha);
void SS_Fill(int c);
Uint32 get_pixel( SDL_Surface *surf, int x, int y );
// Sdl Font //
#define TA_X_L (1L<<1)
#define TA_X_C (1L<<2)
#define TA_X_R (1L<<3)
#define TA_Y_T (1L<<4)
#define TA_Y_C (1L<<5)
#define TA_Y_B (1L<<6)
typedef struct {
SDL_Surface *ss;
int algn;
int clr;
int h;
char lw[256];
int loff[256];
char keys[256];
char off;
char len;
//last written rect
int lX;
int lY;
int lW;
int lH;
} SFnt;
SFnt* SF_Ld(char *fname);
SFnt* SF_LdFxd(char *fname, int off, int len, int w);
void SF_Fr(SFnt *sfnt);
int SF_Wrt(SFnt *sfnt, SDL_Surface *dest, int x, int y, char *str, int alpha);
void SF_Bgn(SFnt *sfnt);
void SF_End(SFnt *sfnt);
SDL_Rect SF_LstR(SFnt *fnt);
int SF_TxtW(SFnt *fnt, char *str);
// Sdl //
#define SDL_MAX_RGNS 200
#define SDL_DIM_STEPS 8
#define SDL_DIM_DELAY 20
#define SDL_DIM() Sdl_Dim(SDL_DIM_STEPS, SDL_DIM_DELAY, 255)
#define SDL_UNDIM() Sdl_UnDim(SDL_DIM_STEPS, SDL_DIM_DELAY, 255)
typedef struct {
SDL_Surface *scr;
DrawRgn d, s;
int rnum;
SDL_Rect rgns[SDL_MAX_RGNS];
} Sdl;
void Sdl_Ini(int f);
void Sdl_Qut();
int Sdl_StVdMd(int w, int h, int d, int f);
void Sdl_HwCps();
void Sdl_Upd(int x, int y, int w, int h);
void Sdl_FUpd();
void Sdl_UpdR();
void Sdl_AddR(int x, int y, int w, int h);
void Sdl_Dim(int steps, int delay, int trp);
void Sdl_UnDim(int steps, int delay, int trp);
int Sdl_WtFrKy();
void Sdl_WtFrClk();
// hardware funcs //
void Sdl_Bgn();
void Sdl_End();
void Sdl_Flp();
#ifdef __cplusplus
};
#endif
#endif

View File

@@ -0,0 +1,47 @@
/***************************************************************************
timer.c - description
-------------------
begin : Mon Aug 14 2000
copyright : (C) 2000 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <sys/time.h>
#include <time.h>
#include "timer.h"
#include "sdl.h"
int t_c, t_lc;
/*
get milliseconds since last call
*/
int T_Gt()
{
int ms;
t_c = SDL_GetTicks();
ms = t_c - t_lc;
t_lc = t_c;
if (ms == 0) {
ms = 1;
SDL_Delay(1);
}
return ms;
}
/*
reset timer
*/
void T_Rst()
{
t_lc = SDL_GetTicks();
}

View File

@@ -0,0 +1,24 @@
/***************************************************************************
timer.h - description
-------------------
begin : Mon Aug 14 2000
copyright : (C) 2000 by Michael Speck
email : kulkanie@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef TIMER_H
#define TIMER_H
int T_Gt();
void T_Rst();
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB