├── .gitattributes ├── .github └── workflows │ └── docs.yaml ├── .gitignore ├── .gitmodules ├── .vscode ├── launch.json └── tasks.json ├── Doxyfile ├── LICENSE ├── Makefile ├── Makefile.check ├── Makefile.curses ├── Makefile.dos ├── Makefile.inc ├── Makefile.mac6 ├── Makefile.nds ├── Makefile.palm ├── Makefile.sdl ├── Makefile.wasm ├── Makefile.win16 ├── Makefile.win32 ├── Makefile.win386 ├── Makefile.xlib ├── README.md ├── Unifile ├── assets ├── 16x16x16 │ ├── c_turnip.bmp │ ├── i_apple.bmp │ ├── i_hammer.bmp │ ├── i_hoe.bmp │ ├── i_plot.bmp │ ├── i_seed.bmp │ ├── i_turnip.bmp │ ├── p_chk_b.bmp │ ├── p_chk_bl.bmp │ ├── p_chk_br.bmp │ ├── p_chk_c.bmp │ ├── p_chk_l.bmp │ ├── p_chk_r.bmp │ ├── p_chk_t.bmp │ ├── p_chk_tl.bmp │ ├── p_chk_tr.bmp │ ├── s_dog.bmp │ ├── s_fount.bmp │ ├── s_maid.bmp │ ├── s_mglass.bmp │ ├── s_pncess.bmp │ ├── s_robe.bmp │ ├── s_witch.bmp │ ├── s_world.bmp │ ├── s_yeti.bmp │ ├── t_brick.bmp │ ├── t_dirt.bmp │ ├── t_grass.bmp │ ├── t_pillar.bmp │ ├── t_pool.bmp │ ├── t_sgrass.bmp │ ├── t_spillr.bmp │ ├── t_stree.bmp │ ├── t_tile.bmp │ └── t_tree.bmp ├── 16x16x2 │ ├── c_turnip.bmp │ ├── i_apple.bmp │ ├── i_hammer.bmp │ ├── i_hoe.bmp │ ├── i_plot.bmp │ ├── i_seed.bmp │ ├── i_turnip.bmp │ ├── p_chk_b.bmp │ ├── p_chk_bl.bmp │ ├── p_chk_br.bmp │ ├── p_chk_c.bmp │ ├── p_chk_l.bmp │ ├── p_chk_r.bmp │ ├── p_chk_t.bmp │ ├── p_chk_tl.bmp │ ├── p_chk_tr.bmp │ ├── s_dog.bmp │ ├── s_fount.bmp │ ├── s_maid.bmp │ ├── s_mglass.bmp │ ├── s_pncess.bmp │ ├── s_robe.bmp │ ├── s_witch.bmp │ ├── s_world.bmp │ ├── s_yeti.bmp │ ├── t_brick.bmp │ ├── t_dirt.bmp │ ├── t_grass.bmp │ ├── t_pillar.bmp │ ├── t_pool.bmp │ ├── t_sgrass.bmp │ ├── t_spillr.bmp │ ├── t_stree.bmp │ ├── t_tile.bmp │ └── t_tree.bmp ├── 16x16x4 │ ├── c_turnip.bmp │ ├── i_apple.bmp │ ├── i_hammer.bmp │ ├── i_hoe.bmp │ ├── i_plot.bmp │ ├── i_seed.bmp │ ├── i_turnip.bmp │ ├── p_chk_b.bmp │ ├── p_chk_bl.bmp │ ├── p_chk_br.bmp │ ├── p_chk_c.bmp │ ├── p_chk_l.bmp │ ├── p_chk_r.bmp │ ├── p_chk_t.bmp │ ├── p_chk_tl.bmp │ ├── p_chk_tr.bmp │ ├── s_dog.bmp │ ├── s_fount.bmp │ ├── s_maid.bmp │ ├── s_mglass.bmp │ ├── s_pncess.bmp │ ├── s_robe.bmp │ ├── s_witch.bmp │ ├── s_world.bmp │ ├── s_yeti.bmp │ ├── t_brick.bmp │ ├── t_dirt.bmp │ ├── t_grass.bmp │ ├── t_pillar.bmp │ ├── t_pool.bmp │ ├── t_sgrass.bmp │ ├── t_spillr.bmp │ ├── t_stree.bmp │ ├── t_tile.bmp │ └── t_tree.bmp ├── cga16.gpl ├── cga4.gpl ├── dsekai.bmp ├── dsekai.ico ├── dsekai.tiled-project ├── m_field.json ├── m_field │ ├── chest.s │ ├── dog.s │ ├── fountain.s │ ├── maid.s │ ├── princess.s │ ├── tree.s │ ├── wforst.s │ └── wtempl.s ├── m_forst.json ├── m_forst │ ├── wfield.s │ └── yeti.s ├── m_templ.json ├── m_templ │ └── wfield.s ├── t2_field.json ├── t2_forst.json ├── t2_templ.json ├── t_trans.bmp ├── test_16_16_256.bmp ├── test_16_16_4.bmp ├── test_16_16_4.cga ├── test_32_32_2.bmp └── test_32_32_256.bmp ├── check ├── check.c ├── ckdataim.c ├── ckdatajs.c ├── ckdio.c ├── ckdrc.c ├── ckgfx.c ├── ckitem.c ├── ckmemory.c ├── ckmobile.c ├── cktmap.c ├── cktopdwn.c ├── ckwindow.c └── testdata.h ├── doxstyle.css ├── dsekai.rc ├── dsekai.vcp ├── dsekai.vcw ├── pkgs.sh ├── resids.h ├── screens ├── firecga.png ├── overwrld.png └── windowsp.png ├── src ├── DSEKAI.MAK ├── config.h ├── crop.c ├── crop.h ├── cropdef.h ├── dsekai.h ├── engines.c ├── engines.h ├── gid.h ├── irc.c ├── irc.h ├── item.c ├── item.h ├── itstruct.h ├── main.c ├── menu.c ├── menu.h ├── mobile.c ├── mobile.h ├── mulipalm.def ├── palmrsc.h ├── palms.rcp ├── pathfind.c ├── pathfind.h ├── pov.c ├── profiler.h ├── scparse.c ├── scparse.h ├── script.c ├── script.h ├── scstruct.h ├── serial.h ├── serial │ └── asn.c ├── strpool.c ├── strpool.h ├── tilemap.c ├── tilemap.h ├── title.c ├── tmasn.c ├── tmasn.h ├── tmjson.c ├── tmjson.h ├── tmstruct.h ├── topdown.c ├── winceres.h ├── winids.h ├── winstat.h └── winstat.rc └── tools ├── compile.c ├── lookups.c ├── map2asn.c └── mappack.c /.gitattributes: -------------------------------------------------------------------------------- 1 | *.c text eol=crlf 2 | *.h text eol=crlf 3 | -------------------------------------------------------------------------------- /.github/workflows/docs.yaml: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | on: 3 | push: 4 | branches: [master] 5 | 6 | jobs: 7 | build-documentation: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Checkout dsekai and unilayer 11 | uses: actions/checkout@v2 12 | with: 13 | submodules: recursive 14 | 15 | - name: Doxygen Action 16 | uses: mattnotmitt/doxygen-action@v1.1.0 17 | with: 18 | doxyfile-path: ./Doxyfile 19 | working-directory: . 20 | 21 | - name: Pages Deployment 22 | uses: peaceiris/actions-gh-pages@v3 23 | with: 24 | github_token: ${{ secrets.GITHUB_TOKEN }} 25 | publish_dir: ./doc/html 26 | enable_jekyll: false 27 | allow_empty_commit: false 28 | force_orphan: true 29 | publish_branch: gh-pages 30 | 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.exe 3 | *.err 4 | bin 5 | bin-* 6 | obj 7 | obj-* 8 | gen 9 | gen-* 10 | dep 11 | dep-* 12 | resext.h 13 | QC.INI 14 | .finf 15 | .rsrc 16 | doc 17 | *.vcb 18 | *.vcl 19 | *.vco 20 | *.aps 21 | tmp 22 | gmon.out 23 | assets/pattern_*.bmp 24 | assets/tile_*.bmp 25 | assets/sprite_*.bmp 26 | assets/*/*.cga 27 | assets/*.asn 28 | assets/dsekai.tiled-session 29 | build 30 | build_* 31 | log*.txt 32 | packages 33 | pkgbuild 34 | rez.output.rsrc 35 | packages.iso 36 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "unilayer"] 2 | path = unilayer 3 | url = https://github.com/indigoparadox/unilayer 4 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "(gdb) Launch", 9 | "type": "cppdbg", 10 | "request": "launch", 11 | "program": "${workspaceFolder}/bin/dsekai", 12 | "args": [], 13 | "stopAtEntry": false, 14 | "cwd": "${workspaceFolder}/bin", 15 | "environment": [{ 16 | "name": "SDL_RENDER_DRIVER", 17 | "value": "software" 18 | }], 19 | "externalConsole": false, 20 | "MIMode": "gdb", 21 | "setupCommands": [ 22 | { 23 | "description": "Enable pretty-printing for gdb", 24 | "text": "-enable-pretty-printing", 25 | "ignoreFailures": true 26 | } 27 | ] 28 | }, 29 | { 30 | "name": "(gdb) Attach (POSE)", 31 | "type": "gdb", 32 | "gdbpath": "/usr/bin/m68k-palmos-gdb", 33 | "request": "attach", 34 | "remote": true, 35 | "executable": "${workspaceFolder}/obj/palm/dsekai", 36 | "target": "palmos", 37 | } 38 | ] 39 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "command": "make", 6 | "label": "build (SDL)", 7 | "args": [ 8 | "clean", 9 | "../bin/dsekai" 10 | ], 11 | "options": { 12 | "cwd": "${workspaceFolder}/src" 13 | }, 14 | "problemMatcher": [], 15 | "group": { 16 | "kind": "build", 17 | "isDefault": true 18 | } 19 | }, 20 | { 21 | "command": "make", 22 | "label": "build (DOS)", 23 | "args": [ 24 | "clean", 25 | "../bin/dsekai.exe" 26 | ], 27 | "options": { 28 | "cwd": "${workspaceFolder}/src" 29 | }, 30 | "problemMatcher": [], 31 | "group": { 32 | "kind": "build", 33 | "isDefault": true 34 | } 35 | }, 36 | { 37 | "command": "make", 38 | "label": "build (Palm)", 39 | "args": [ 40 | "clean", 41 | "../bin/dsekai.prc" 42 | ], 43 | "options": { 44 | "cwd": "${workspaceFolder}/src" 45 | }, 46 | "problemMatcher": [], 47 | "group": { 48 | "kind": "build", 49 | "isDefault": true 50 | } 51 | } 52 | ] 53 | } -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | CALLER=MASTER 3 | # Build file resources by default, otherwise use win/palm resources. 4 | ifneq ($(RESOURCE),DEFAULT) 5 | RESOURCE=FILE 6 | ifneq ($(FMT_JSON),TRUE) 7 | FMT_ASN=TRUE 8 | endif 9 | endif 10 | 11 | # Figure out what packages we can build based on platform limitations. 12 | 13 | BUILD_PKG_ALL := pkg_sdl pkg_win16 pkg_win32 pkg_curses 14 | 15 | # Palm not included by default as it requires MONO and RESOURCE=DEFAULT. 16 | BUILD_PALM=0 17 | # DOS not included by default as it requires CGA to be set. 18 | BUILD_DOS=0 19 | # xlib not included by default as it requires CGA to be set. 20 | BUILD_XLIB=0 21 | # WASM not included as it requires RESOURCE=DEFAULT. 22 | BUILD_WASM=0 23 | 24 | ifeq ($(DEPTH),MONO) 25 | ifeq ($(RESOURCE),DEFAULT) 26 | BUILD_PALM=1 27 | BUILD_PKG_ALL += pkg_palm 28 | endif 29 | else ifeq ($(DEPTH),VGA) 30 | ifeq ($(RESOURCE),DEFAULT) 31 | BUILD_WASM=1 32 | BUILD_PKG_ALL += pkg_wasm 33 | endif 34 | else 35 | # DEPTH=VGA 36 | BUILD_DOS=1 37 | BUILD_PKG_ALL += pkg_dos 38 | BUILD_XLIB=1 39 | BUILD_PKG_ALL += pkg_xlib 40 | ifeq ($(RESOURCE),DEFAULT) 41 | BUILD_WASM=1 42 | BUILD_PKG_ALL += pkg_wasm 43 | endif 44 | endif 45 | 46 | .PHONY: clean $(BUILD_PKG_ALL) 47 | 48 | all: $(BUILD_PKG_ALL) 49 | 50 | # Include platform-specific Makefiles. 51 | 52 | include Makefile.inc 53 | 54 | include Makefile.sdl 55 | include Makefile.win16 56 | include Makefile.win32 57 | include Makefile.curses 58 | 59 | ifeq ($(BUILD_PALM),1) 60 | include Makefile.palm 61 | endif 62 | ifeq ($(BUILD_DOS),1) 63 | include Makefile.dos 64 | endif 65 | ifeq ($(BUILD_XLIB),1) 66 | include Makefile.xlib 67 | endif 68 | ifeq ($(BUILD_WASM),1) 69 | include Makefile.wasm 70 | endif 71 | 72 | # NDS makefile not currently included as it is broken on our system. 73 | 74 | # ====== Clean ====== 75 | 76 | clean: 77 | rm -rf data obj obj-* bin bin-* gen gen-* dep dep-* *.err .rsrc .finf gmon.out log*.txt packages pkgbuild dsdos prof_output* unimake test_unilayer dsekai.iso 78 | 79 | -------------------------------------------------------------------------------- /Makefile.check: -------------------------------------------------------------------------------- 1 | 2 | # vi:syntax=make 3 | 4 | include Makefile 5 | 6 | # 1. Directories 7 | 8 | OBJDIR_CHECK := $(OBJDIR)/check 9 | DEPDIR_CHECK := $(DEPDIR)/check 10 | GENDIR_CHECK := $(GENDIR)/check 11 | 12 | # 2. Files 13 | 14 | DSEKAI_C_FILES_CHECK_ONLY := \ 15 | check/check.c \ 16 | check/ckmobile.c \ 17 | check/ckitem.c \ 18 | check/cktmap.c \ 19 | check/ckwindow.c \ 20 | check/ckgfx.c \ 21 | check/cktopdwn.c \ 22 | check/ckdataim.c \ 23 | check/ckdatajs.c \ 24 | check/ckdio.c \ 25 | check/ckmemory.c \ 26 | unilayer/graphics/nullg.c \ 27 | unilayer/input/nulli.c \ 28 | tools/data/cga.c \ 29 | tools/data/bmp.c \ 30 | tools/data/icns.c 31 | 32 | DSEKAI_O_FILES_CHECK_ONLY := \ 33 | $(addprefix $(OBJDIR_CHECK)/,$(subst .c,.o,$(DSEKAI_C_FILES))) \ 34 | $(addprefix $(OBJDIR_CHECK)/,$(subst .c,.o,$(DSEKAI_C_FILES_CHECK_ONLY))) 35 | 36 | RESEXT_H := $(GENDIR_CHECK)/resext.h 37 | 38 | # 3. Programs 39 | 40 | CC_SDL := gcc 41 | LD_SDL := gcc 42 | 43 | # 4. Arguments 44 | 45 | DEFINES_CHECK := \ 46 | $(DEFINES_DSEKAI) \ 47 | $(DEFINES_DEPTH) \ 48 | $(DEFINES_RESOURCE) \ 49 | -DPLATFORM_NULL \ 50 | -DSCREEN_W=160 \ 51 | -DSCREEN_H=160 \ 52 | -DSCREEN_SCALE=$(SCREEN_SCALE) 53 | 54 | INCLUDES_CHECK := \ 55 | $(UNLAYER_INCLUDES) \ 56 | -I $(GENDIR_CHECK) 57 | 58 | CFLAGS_CHECK := $(shell pkg-config check --cflags) -g $(CFLAGS_GCC_GENERIC) $(DEFINES_CHECK) $(INCLUDES_CHECK) 59 | 60 | # ====== Check: Null ====== 61 | 62 | $(RESEXT_H): $(GENDIR_CHECK)/$(STAMPFILE) $(MKRESH) 63 | $(MKRESH) -f palm -i 5001 \ 64 | -if $(DSEKAI_ASSETS_BITMAPS) $(DSEKAI_ASSETS_MAPS_JSON) \ 65 | -oh $@ 66 | 67 | $(BIN_CHECK): $(DSEKAI_O_FILES_CHECK_ONLY) | $(BINDIR)/$(STAMPFILE) 68 | $(CC) -o $@ $^ $(LDFLAGS) 69 | 70 | #$(DEPDIR_CHECK)/%.d: %.c $(RESEXT_H) 71 | # $(MD) $(dir $@) 72 | # $(CC) $(CFLAGS_CHECK) -MM $< \ 73 | # -MT $(subst .c,.o,$(addprefix $(DEPDIR_CHECK)/,$<)) -MF $@ 74 | 75 | #include $(subst $(OBJDIR)/,$(DEPDIR)/,$(DSEKAI_O_FILES_CHECK:.o=.d)) 76 | 77 | $(OBJDIR_CHECK)/%.o: %.c check/testdata.h $(RESEXT_H) 78 | $(MD) $(dir $@) 79 | $(CC) $(CFLAGS_CHECK) -c -o $@ $(<:%.o=%) 80 | 81 | -------------------------------------------------------------------------------- /Makefile.curses: -------------------------------------------------------------------------------- 1 | 2 | # vi:syntax=make 3 | 4 | ifneq ($(CALLER),MASTER) 5 | include Makefile.inc 6 | endif 7 | 8 | # 1. Directories 9 | 10 | OBJDIR_CURSES := $(OBJDIR)/curses 11 | DEPDIR_CURSES := $(DEPDIR)/curses 12 | GENDIR_CURSES := $(GENDIR)/curses 13 | 14 | RESEXT_H_CURSES := $(GENDIR_CURSES)/resext.h 15 | 16 | # 2. Files 17 | 18 | BIN_CURSES := $(BINDIR)/$(DSEKAI)t 19 | 20 | DSEKAI_C_FILES_CURSES_ONLY := \ 21 | src/main.c \ 22 | src/scparse.c \ 23 | unilayer/src/input/cursesi.c \ 24 | unilayer/src/graphics/cursesg.c \ 25 | unilayer/src/memory/fakem.c \ 26 | unilayer/src/save/file.c 27 | 28 | DSEKAI_O_FILES_CURSES := \ 29 | $(addprefix $(OBJDIR_CURSES)/,$(subst .c,.o,$(DSEKAI_C_FILES))) \ 30 | $(addprefix $(OBJDIR_CURSES)/,$(subst .c,.o,$(DSEKAI_C_FILES_CURSES_ONLY))) \ 31 | $(addprefix $(OBJDIR_CURSES)/,$(subst .c,.o,$(DSEKAI_C_FILES_RES))) 32 | 33 | # 1a. Packaging Manifest 34 | 35 | CURSES_MANIFEST := 36 | ifeq ($(FMT_ASN),TRUE) 37 | CURSES_MANIFEST += $(subst .json,.asn,$(DSEKAI_ASSETS_MAPS_JSON)) 38 | endif 39 | 40 | ifeq ($(FMT_JSON),TRUE) 41 | CURSES_MANIFEST += \ 42 | $(DSEKAI_ASSETS_MAPS_JSON) \ 43 | $(DSEKAI_ASSETS_TILESETS_JSON) \ 44 | $(DSEKAI_ASSETS_SCRIPTS) 45 | endif 46 | 47 | # 3. Programs 48 | 49 | CC_CURSES := gcc 50 | LD_CURSES := gcc 51 | 52 | # 4. Arguments 53 | 54 | # Disable a bunch of effects we can't represent in text mode. 55 | 56 | DEFINES_CURSES := \ 57 | $(DEFINES_DSEKAI) \ 58 | $(DEFINES_DEPTH) \ 59 | $(DEFINES_RESOURCE) \ 60 | -DNO_ENGINE_POV \ 61 | -DNO_TRANSITIONS \ 62 | -DNO_ANIMATE \ 63 | -DNO_DRAW_ENGINE_BEHIND_MENU \ 64 | -DNO_GFX_CACHE \ 65 | -DNO_SMOOTH_WALK \ 66 | -DNO_DIRTY_TILES \ 67 | -DDISABLE_WEATHER_EFFECTS \ 68 | -DPLATFORM_CURSES 69 | 70 | INCLUDES_CURSES := \ 71 | $(INCLUDES_UNILAYER) \ 72 | -I $(GENDIR_CURSES) 73 | 74 | CFLAGS_CURSES := $(CFLAGS_GCC_GENERIC) $(FLAGS_GCC_SANITIZE) $(DEFINES_CURSES) $(INCLUDES_CURSES) 75 | 76 | LDFLAGS_CURSES := $(LDFLAGS_GCC_GENERIC) $(FLAGS_GCC_SANITIZE) -lncurses 77 | 78 | # 5. Targets 79 | 80 | platform := curses 81 | platform_upper := CURSES 82 | res_gfx := $(DSEKAI_ASSETS_BITMAPS) 83 | $(eval $(RESEXT_H_RULE)) 84 | 85 | pkg_bin := $(BIN_CURSES) $(CONVERT) $(MAP2ASN) 86 | pkg_strip := strip 87 | pkg_name := $(DSEKAI)-$(platform)-$(PKGOS)-$(GIT_HASH) 88 | pkg_reqs := $(CURSES_MANIFEST) 89 | $(eval $(PKG_RULE)) 90 | 91 | $(BIN_CURSES): $(DSEKAI_O_FILES_CURSES) | $(BINDIR)/$(STAMPFILE) $(RESEXT_H_CURSES) 92 | $(LD_CURSES) -o $@ $^ $(LDFLAGS_CURSES) 93 | 94 | $(OBJDIR_CURSES)/%.o: %.c $(RESEXT_H_CURSES) | $(DSEKAI_ASSETS_MAPS_JSON) 95 | $(MD) $(dir $@) 96 | $(CC_CURSES) $(CFLAGS_CURSES) -c -o $@ $(<:%.o=%) 97 | 98 | #$(DEPDIR_CURSES)/%.d: %.c $(GENDIR_CURSES)/resext.h 99 | # $(MD) $(dir $@) 100 | # $(CC_CURSES) $(CFLAGS_CURSES) -MM $< \ 101 | # -MT $(subst .c,.o,$(addprefix $(DEPDIR_CURSES)/,$<)) -MF $@ 102 | 103 | #include $(subst $(OBJDIR)/,$(DEPDIR)/,$(DSEKAI_O_FILES_CURSES:.o=.d)) 104 | 105 | 106 | -------------------------------------------------------------------------------- /Makefile.dos: -------------------------------------------------------------------------------- 1 | 2 | # vi:syntax=make 3 | 4 | ifneq ($(CALLER),MASTER) 5 | include Makefile.inc 6 | endif 7 | 8 | # 1. Directories 9 | 10 | OBJDIR_DOS := $(OBJDIR)/dos 11 | DEPDIR_DOS := $(DEPDIR)/dos 12 | GENDIR_DOS := $(GENDIR)/dos 13 | 14 | CONVERT_OBJDIR_DOS := $(OBJDIR)/convert/dos 15 | MAP2ASN_OBJDIR_DOS := $(OBJDIR)/map2asn/dos 16 | 17 | # 2. Files 18 | 19 | BIN_DOS := $(BINDIR)/$(DSEKAI).exe 20 | 21 | DSEKAI_C_FILES_DOS_ONLY := \ 22 | src/main.c \ 23 | unilayer/src/input/dosi.c \ 24 | unilayer/src/graphics/dosg.c \ 25 | unilayer/src/memory/dosm.c \ 26 | unilayer/src/save/file.c 27 | 28 | # This includes ALL object files, including engines and unilayer. 29 | # These are further subdivided in the rule to generate the .lnk script, below. 30 | DSEKAI_O_FILES_DOS := \ 31 | $(addprefix $(OBJDIR_DOS)/,$(subst .c,.o,$(DSEKAI_C_FILES))) \ 32 | $(addprefix $(OBJDIR_DOS)/,$(subst .c,.o,$(DSEKAI_C_FILES_DOS_ONLY))) \ 33 | $(addprefix $(OBJDIR_DOS)/,$(subst .c,.o,$(DSEKAI_C_FILES_RES))) 34 | 35 | DSEKAI_OVERLAYS_DOS := $(foreach f,$(DSEKAI_C_FILES_ENGINES),$(subst src/,$(BINDIR)/,$(subst .c,.ovl,$f))) 36 | 37 | # 2b. Utilities 38 | 39 | CONVERT_O_FILES_DOS := \ 40 | $(addprefix $(CONVERT_OBJDIR_DOS)/,$(subst .c,.o,$(CONVERT_C_FILES))) 41 | 42 | MAP2ASN_O_FILES_DOS := \ 43 | $(addprefix $(MAP2ASN_OBJDIR_DOS)/,$(subst .c,.o,$(MAP2ASN_C_FILES))) 44 | 45 | # 2c. Packaging Manifest 46 | 47 | DOS_MANIFEST := 48 | 49 | ifeq ($(RESOURCE),FILE) 50 | ifeq ($(DEPTH),VGA) 51 | DOS_MANIFEST += $(subst .bmp,.vga,$(DSEKAI_ASSETS_BITMAPS)) 52 | else 53 | # Assume CGA by default. 54 | DOS_MANIFEST += $(subst .bmp,.cga,$(DSEKAI_ASSETS_BITMAPS)) 55 | endif 56 | endif 57 | 58 | ifeq ($(FMT_ASN),TRUE) 59 | DOS_MANIFEST += $(subst .json,.asn,$(DSEKAI_ASSETS_MAPS_JSON)) 60 | endif 61 | 62 | ifeq ($(FMT_JSON),TRUE) 63 | DOS_MANIFEST += $(DSEKAI_ASSETS_MAPS_JSON) 64 | endif 65 | 66 | RESEXT_H_DOS := $(GENDIR_DOS)/resext.h 67 | 68 | # 3. Programs 69 | 70 | CC_DOS := wcc 71 | LD_DOS := wcl 72 | WLINK := wlink 73 | 74 | # 4. Arguments 75 | 76 | ifeq ($(BUILD),RELEASE) 77 | DEFINES_DEBUG := 78 | else 79 | # Assume debug build. 80 | DEFINES_DEBUG := -DDSEKAI_PROFILER 81 | endif 82 | 83 | DEFINES_SDL := \ 84 | $(DEFINES_DSEKAI) \ 85 | 86 | DEFINES_DOS := \ 87 | $(DEFINES_DSEKAI) \ 88 | $(DEFINES_DEPTH) \ 89 | $(DEFINES_RESOURCE) \ 90 | $(DEFINES_DEBUG) \ 91 | -DNO_ENGINE_POV \ 92 | -DNO_TRANSITIONS \ 93 | -DNO_ANIMATE \ 94 | -DNO_DRAW_ENGINE_BEHIND_MENU \ 95 | -DPLATFORM_DOS \ 96 | -DUSE_SOFTWARE_TEXT \ 97 | -DUSE_SOFTWARE_LINES \ 98 | -DDISABLE_WEATHER_EFFECTS \ 99 | -DGRAPHICS_CACHE_INITIAL_SZ=25 \ 100 | -DRESOURCE_PATH_MAX=28 \ 101 | -DNO_SCRIPT_COMPILER \ 102 | -DUSE_LOOKUPS 103 | 104 | INCLUDES_DOS := \ 105 | $(subst -I ,-i=,$(INCLUDES_UNILAYER)) \ 106 | -i=$(GENDIR_DOS) 107 | 108 | CFLAGS_DOS_BASIC := -os -hw -d0 -0 $(CFLAGS_OWC_GENERIC) -wo -we 109 | 110 | # If we don't use the large memory model, we can't load assets reliably. 111 | CFLAGS_DOS := -ml -DMEMORY_LARGE $(CFLAGS_DOS_BASIC) $(DEFINES_DOS) $(INCLUDES_DOS) 112 | 113 | ifneq ($(BUILD),RELEASE) 114 | CFLAGS_DOS += -DLOG_TO_FILE 115 | endif 116 | 117 | LDFLAGS_DOS := $(LDFLAGS_OWC_GENERIC) 118 | 119 | # 4b. Utilities 120 | 121 | CFLAGS_UTILITY_DOS := -mh $(CFLAGS_DOS_BASIC) $(DEFINES_MAP2ASN) $(INCLUDES_DOS) -DPLATFORM_DOS 122 | 123 | LDFLAGS_UTILITY_DOS := $(LDFLAGS_OWC_GENERIC) -k8192 124 | 125 | # 5. Targets 126 | 127 | platform := dos 128 | platform_upper := DOS 129 | ifeq ($(DEPTH),VGA) 130 | res_gfx := $(subst .bmp,.vga,$(subst $(ASSETDIR)/,$(GENDIR_DOS)/,$(DSEKAI_ASSETS_BITMAPS))) 131 | else 132 | # Assume CGA by default. 133 | res_gfx := $(subst .bmp,.cga,$(subst $(ASSETDIR)/,$(GENDIR_DOS)/,$(DSEKAI_ASSETS_BITMAPS))) 134 | endif 135 | $(eval $(RESEXT_H_RULE)) 136 | 137 | # DOS utilities give stack overflow right now. 138 | pkg_bin := $(BIN_DOS) $(DSEKAI_OVERLAYS_DOS) $(BINDIR)/convert.exe $(BINDIR)/map2asn.exe 139 | #pkg_bin := $(BIN_DOS) 140 | pkg_strip := echo 141 | pkg_name := $(DSEKAI)-$(platform)-$(GIT_HASH) 142 | pkg_reqs := $(DOS_MANIFEST) 143 | $(eval $(PKG_RULE)) 144 | 145 | #$(BINDIR)/doscga.drc: res_doscga_drc 146 | 147 | #res_doscga_drc: $(DRCPACK) $(DSEKAI_ASSETS_DOS_CGA) 148 | # rm $(BINDIR)/doscga.drc || true 149 | # $(DRCPACK) -c -a -af $(BINDIR)/doscga.drc -i 5001 \ 150 | # -if $(GENDIR_DOS)/*.cga $(DSEKAI_ASSETS_MAPS) -lh $(GENDIR_DOS)/resext.h 151 | 152 | # TODO: Should these ASSETDIR rules be removed? 153 | 154 | #$(ASSETDIR)/%.cga: $(ASSETDIR)/%.bmp | $(CONVERT) 155 | # $(CONVERT) -ic bmp -oc cga -ob 2 -if $< -of $@ -og 156 | # 157 | #$(ASSETDIR)/%.vga: $(ASSETDIR)/%.bmp | $(CONVERT) 158 | # $(CONVERT) -ic bmp -oc cga -ob 8 -if $< -of $@ -og 159 | 160 | $(BINDIR)/assets/%.cga: $(ASSETDIR)/%.bmp $(CONVERT) | \ 161 | $(BINDIR)/assets/$(STAMPFILE) 162 | $(MD) $(dir $@) 163 | $(CONVERT) -ic bmp -oc cga -ob 2 -if $< -of $@ -og 164 | 165 | $(BINDIR)/assets/%.vga: $(ASSETDIR)/%.bmp $(CONVERT) | \ 166 | $(BINDIR)/assets/$(STAMPFILE) 167 | $(MD) $(dir $@) 168 | $(CONVERT) -ic bmp -oc cga -ob 4 -if $< -of $@ -og 169 | 170 | $(GENDIR_DOS)/%.cga: $(ASSETDIR)/%.bmp | $(CONVERT) $(GENDIR_DOS)/$(STAMPFILE) 171 | $(MD) $(dir $@) 172 | $(CONVERT) -ic bmp -oc cga -ob 2 -if $< -of $@ -og 173 | 174 | $(GENDIR_DOS)/%.vga: $(ASSETDIR)/%.bmp | $(CONVERT) $(GENDIR_DOS)/$(STAMPFILE) 175 | $(MD) $(dir $@) 176 | $(CONVERT) -ic bmp -oc cga -ob 4 -if $< -of $@ -og 177 | 178 | $(BIN_DOS) $(DSEKAI_OVERLAYS_DOS): $(DSEKAI_O_FILES_DOS) | $(OBJDIR_DOS)/dsekai.lnk $(BINDIR)/$(STAMPFILE) 179 | #$(LD_DOS) $(LDFLAGS_DOS) -fe=$@ $^ 180 | cd $(OBJDIR_DOS) && $(WLINK) $(LDFLAGS_DOS) @dsekai && cp -v dsekai.exe *.ovl ../../$(BINDIR) 181 | 182 | # Create a linker script to handle overlays and other tricks. 183 | $(OBJDIR_DOS)/dsekai.lnk: $(DSEKAI_O_FILES_DOS) 184 | echo system dos > $@ 185 | echo option map >> $@ 186 | echo name dsekai >> $@ 187 | echo $(foreach f,$(DSEKAI_C_FILES_SUPPORT),file $(subst .c,,$f)\\n) >> $@ 188 | echo $(foreach f,$(DSEKAI_C_FILES_DOS_ONLY),file $(subst .c,,$f)\\n) >> $@ 189 | echo $(foreach f,$(DSEKAI_C_FILES_RES),file $(subst .c,,$f)\\n) >> $@ 190 | # Begin the engine overlay area. 191 | echo begin >> $@ 192 | # New engine overlays go here. e.g. if the new engine is src/topdown.c, it 193 | # should be added without extension below as src/topdown. The "into x" part 194 | # creates a new overlay "library" for it to be inserted into (e.g. ovltopdn 195 | # creates ovltopdn.ovl next to dsekai.exe that must be kept with it!) 196 | echo $(foreach f,$(DSEKAI_C_FILES_ENGINES),section into $(subst src/,,$(subst .c,,$f)) file $(subst .c,,$f)\\n) >> $@ 197 | echo end >> $@ 198 | 199 | $(OBJDIR_DOS)/%.o: %.c $(RESEXT_H_DOS) 200 | $(MD) $(dir $@) 201 | $(CC_DOS) $(CFLAGS_DOS) -fo=$@ $(<:%.c=%) 202 | 203 | #$(DEPDIR_DOS)/%.d: %.c $(RESEXT_H_DOS) 204 | # $(MD) $(dir $@) 205 | # $(HOST_CC) $(subst -i=,-I ,$(INCLUDES_DOS)) $(DEFINES_DOS) -MM $< \ 206 | # -MT $(subst .c,.o,$(addprefix $(DEPDIR_DOS)/,$<)) -MF $@ 207 | # 208 | #include $(subst $(OBJDIR)/,$(DEPDIR)/,$(DSEKAI_O_FILES_DOS:.o=.d)) 209 | 210 | # 5b. DOS Utilities 211 | 212 | $(CONVERT_OBJDIR_DOS)/%.o: %.c 213 | $(MD) $(dir $@) 214 | $(CC_DOS) $(CFLAGS_UTILITY_DOS) -fo=$@ $(<:%.c=%) 215 | 216 | $(BINDIR)/convert.exe: $(CONVERT_O_FILES_DOS) 217 | $(LD_DOS) $(LDFLAGS_DOS) -fe=$@ $^ 218 | 219 | $(MAP2ASN_OBJDIR_DOS)/%.o: %.c 220 | $(MD) $(dir $@) 221 | $(CC_DOS) $(CFLAGS_UTILITY_DOS) -fo=$@ $(<:%.c=%) 222 | 223 | $(BINDIR)/map2asn.exe: $(MAP2ASN_O_FILES_DOS) | $(BINDIR)/$(STAMPFILE) 224 | $(LD_DOS) $(LDFLAGS_DOS) -fe=$@ $^ 225 | 226 | -------------------------------------------------------------------------------- /Makefile.mac6: -------------------------------------------------------------------------------- 1 | 2 | # vi:syntax=make 3 | 4 | ifneq ($(CALLER),MASTER) 5 | include Makefile.inc 6 | endif 7 | 8 | 9 | ifneq ($(DEPTH),MONO) 10 | $(error mac6 target must be built with MONO DEPTH) 11 | endif 12 | 13 | # 1. Directories 14 | 15 | OBJDIR_MAC6 := $(OBJDIR)/mac6 16 | DEPDIR_MAC6 := $(DEPDIR)/mac6 17 | GENDIR_MAC6 := $(GENDIR)/mac6 18 | 19 | RETRO68_PREFIX := /opt/Retro68-build/toolchain 20 | 21 | # 2. Files 22 | 23 | BIN_MAC6 := $(BINDIR)/$(DSEKAI).bin $(BINDIR)/$(DSEKAI).APPL $(BINDIR)/$(DSEKAI).dsk 24 | 25 | DSEKAI_C_FILES_MAC6_ONLY := \ 26 | src/main.c \ 27 | src/scparse.c \ 28 | unilayer/src/input/mac6i.c \ 29 | unilayer/src/graphics/mac6g.c \ 30 | unilayer/src/memory/mac6m.c \ 31 | unilayer/src/save/file.c 32 | 33 | # 1a. Packaging Manifest 34 | 35 | DSEKAI_ASSETS_ICNS := \ 36 | $(subst .bmp,.icns,$(subst $(ASSETDIR)/,$(GENDIR_MAC6)/,$(DSEKAI_ASSETS_BITMAPS))) 37 | 38 | DSEKAI_ASSETS_RSRC := \ 39 | $(subst .bmp,.rsrc,$(subst $(ASSETDIR)/,$(GENDIR_MAC6)/,$(DSEKAI_ASSETS_BITMAPS))) 40 | 41 | DSEKAI_ASSETS_MAPS_MAC6 := \ 42 | $(subst .json,.h,$(subst $(ASSETDIR)/,$(GENDIR_MAC6)/,$(DSEKAI_ASSETS_MAPS_JSON))) 43 | 44 | DSEKAI_O_FILES_MAC6 := \ 45 | $(addprefix $(OBJDIR_MAC6)/,$(subst .c,.o,$(DSEKAI_C_FILES))) \ 46 | $(addprefix $(OBJDIR_MAC6)/,$(subst .c,.o,$(DSEKAI_C_FILES_MAC6_ONLY))) \ 47 | $(addprefix $(OBJDIR_MAC6)/,$(subst .c,.o,$(DSEKAI_C_FILES_RES))) 48 | 49 | RESEXT_H_MAC6 := $(GENDIR_MAC6)/resext.h 50 | 51 | # 3. Programs 52 | 53 | CC_MAC6 := m68k-apple-macos-gcc 54 | CXX_MAC6 := m68k-apple-macos-g++ 55 | REZ_MAC6 := Rez 56 | 57 | # 4. Arguments 58 | 59 | DEFINES_MAC6 := \ 60 | $(DEFINES_DSEKAI) \ 61 | $(DEFINES_DEPTH) \ 62 | $(DEFINES_RESOURCE) \ 63 | -DPLATFORM_MAC6 \ 64 | -DNO_ENGINE_POV \ 65 | -DNO_ANIMATE \ 66 | -DNO_TRANSITIONS \ 67 | -DUSE_SOFTWARE_TEXT 68 | 69 | INCLUDES_MAC6 := \ 70 | $(INCLUDES_UNILAYER) \ 71 | -I$(GENDIR_MAC6) \ 72 | -I$(RETRO68_PREFIX)/multiversal/CIncludes 73 | 74 | #CFLAGS_MAC6 := $(shell echo $(CFLAGS_GCC_GENERIC) | sed -e 's/--std=c89//g') $(DEFINES_MAC6) $(INCLUDES_MAC6) 75 | CFLAGS_MAC6 := $(DEFINES_MAC6) $(INCLUDES_MAC6) -Werror 76 | 77 | ifneq ($(BUILD),RELEASE) 78 | CFLAGS_MAC6 += -DLOG_TO_FILE 79 | endif 80 | 81 | LDFLAGS_MAC6 := -lRetroConsole $(LDFLAGS_GCC_GENERIC) 82 | 83 | # 5. Targets 84 | 85 | #$(BINDIR)/mac6.drc \ 86 | #$(GENDIR_MAC6)/resext.h: $(DSEKAI_ASSETS_PICTS) $(DRCPACK) | \ 87 | #$(GENDIR_MAC6)/$(STAMPFILE) 88 | # $(DRCPACK) -c -a -af $(BINDIR)/mac6.drc -t PICT -i 5001 \ 89 | # -if $(DSEKAI_ASSETS_PICTS) $(DSEKAI_ASSETS_MAPS) \ 90 | # -lh $(GENDIR_MAC6)/resext.h 91 | 92 | platform := mac6 93 | platform_upper := MAC6 94 | res_gfx := $(DSEKAI_ASSETS_BITMAPS) 95 | $(eval $(RESEXT_H_RULE)) 96 | 97 | pkg_bin := $(BINDIR)/$(DSEKAI).APPL 98 | pkg_strip := echo 99 | pkg_name := $(DSEKAI)-$(platform)-$(GIT_HASH) 100 | pkg_reqs := 101 | $(eval $(PKG_RULE)) 102 | 103 | #$(GENDIR_MAC6)/%.pict: $(ASSETDIR)/%.bmp | $(GENDIR_MAC6)/$(STAMPFILE) 104 | # $(IMAGEMAGICK) $< $@ 105 | 106 | #$(GENDIR_MAC6)/%.rsrc: $(GENDIR_MAC6)/%.icns 107 | # echo "read 'icns' (-16455) \"$<\";" > $@ 108 | 109 | $(GENDIR_MAC6)/%.icns: $(ASSETDIR)/%.bmp $(CONVERT) | $(GENDIR_MAC6)/$(STAMPFILE) 110 | $(MD) $(dir $@) 111 | $(CONVERT) -if $< -of $@ -ob 1 -r -ic bmp -oc icns 112 | 113 | $(OBJDIR_MAC6)/$(DSEKAI).code.bin: $(DSEKAI_O_FILES_MAC6) | $(OBJDIR_MAC6) 114 | $(CXX_MAC6) $(LDFLAGS_MAC6) -o $@ $^ # Use CXX to link for RetroConsole. 115 | 116 | $(BIN_MAC6): $(OBJDIR_MAC6)/$(DSEKAI).code.bin $(BINDIR)/$(STAMPFILE) 117 | $(REZ_MAC6) -I$(RETRO68_PREFIX)/RIncludes \ 118 | --copy $^ \ 119 | "$(RETRO68_PREFIX)/RIncludes/Retro68APPL.r" \ 120 | -t "APPL" -c "DSEK" \ 121 | -o $(BINDIR)/$(DSEKAI).bin \ 122 | --cc $(BINDIR)/$(DSEKAI).APPL \ 123 | --cc $(BINDIR)/$(DSEKAI).dsk 124 | 125 | $(OBJDIR_MAC6)/%.o: %.c $(RESEXT_H_MAC6) 126 | $(MD) $(dir $@) 127 | $(CC_MAC6) $(CFLAGS_MAC6) -c -o $@ $(<:%.o=%) 128 | 129 | -------------------------------------------------------------------------------- /Makefile.palm: -------------------------------------------------------------------------------- 1 | 2 | # vi:syntax=make 3 | 4 | ifneq ($(CALLER),MASTER) 5 | include Makefile.inc 6 | endif 7 | 8 | ifneq ($(DEPTH),MONO) 9 | $(error palm target must be built with MONO DEPTH) 10 | endif 11 | 12 | ifneq ($(RESOURCE),DEFAULT) 13 | $(error palm target must be built with DEFAULT RESOURCE) 14 | endif 15 | 16 | # 1. Directories 17 | 18 | OBJDIR_PALM := $(OBJDIR)/palm 19 | DEPDIR_PALM := $(DEPDIR)/palm 20 | GENDIR_PALM := $(GENDIR)/palm 21 | 22 | # 2. Files 23 | 24 | BIN_PALM := $(BINDIR)/$(DSEKAI).prc 25 | 26 | # Break up translation units so they can be positioned to avoid the dreaded 27 | # "relocation truncated to fit" errors by putting things that call each other 28 | # close. 29 | 30 | DSEKAI_C_FILES_PALM_ONLY_1 := \ 31 | src/main.c 32 | 33 | DSEKAI_C_FILES_PALM_ONLY_2 := \ 34 | unilayer/src/input/palmi.c \ 35 | unilayer/src/memory/palmm.c \ 36 | unilayer/src/resource/palmr.c \ 37 | unilayer/src/save/palm.c \ 38 | unilayer/src/graphics/palmg.c 39 | 40 | DSEKAI_O_FILES_PALM := \ 41 | $(addprefix $(OBJDIR_PALM)/,$(subst .c,.o,$(DSEKAI_C_FILES_PALM_ONLY_1))) \ 42 | $(addprefix $(OBJDIR_PALM)/,$(subst .c,.o,$(DSEKAI_C_FILES_ENGINES))) \ 43 | $(addprefix $(OBJDIR_PALM)/,$(subst .c,.o,$(DSEKAI_C_FILES_SUPPORT_1))) \ 44 | $(addprefix $(OBJDIR_PALM)/,$(subst .c,.o,$(DSEKAI_C_FILES_PALM_ONLY_2))) \ 45 | $(addprefix $(OBJDIR_PALM)/,$(subst .c,.o,$(DSEKAI_C_FILES_SUPPORT_2))) 46 | 47 | RESEXT_H_PALM := $(GENDIR_PALM)/resext.h 48 | 49 | MULIPALM_LD := $(GENDIR_PALM)/mulipalm.ld 50 | MULIPALM_DEF := src/mulipalm.def 51 | MULIPALM_O := $(OBJDIR_PALM)/mulipalm.o 52 | 53 | # 3. Programs 54 | 55 | CC_PALM := m68k-palmos-gcc 56 | LD_PALM := m68k-palmos-gcc 57 | AS_PALM := m68k-palmos-as 58 | PILRC := pilrc 59 | OBJRES := m68k-palmos-obj-res 60 | BUILDPRC := build-prc 61 | MULTIGEN := m68k-palmos-multigen 62 | 63 | # 4. Arguments 64 | 65 | DEFINES_PALM := \ 66 | $(DEFINES_DSEKAI) \ 67 | $(DEFINES_DEPTH) \ 68 | -DPLATFORM_PALM \ 69 | -DNO_ENGINE_POV \ 70 | -DNO_TITLE \ 71 | -DNO_ANIMATE \ 72 | -DNO_DRAW_ENGINE_BEHIND_MENU \ 73 | -DUSE_SOFTWARE_TEXT \ 74 | -DUSE_SOFTWARE_LINES \ 75 | -DNO_SCRIPT_COMPILER 76 | 77 | INCLUDES_PALM := \ 78 | $(INCLUDES_UNILAYER) \ 79 | -I $(GENDIR_PALM) \ 80 | -I /opt/palmdev/sdk-3.5/include \ 81 | -I /opt/palmdev/sdk-3.5/include/Libraries/ \ 82 | -I /opt/palmdev/sdk-3.5/include/Dynamic/ \ 83 | -I /opt/palmdev/sdk-3.5/include/Core/ \ 84 | -I /opt/palmdev/sdk-3.5/include/Core/UI/ \ 85 | -I /opt/palmdev/sdk-3.5/include/Core/System/ \ 86 | -I /opt/palmdev/sdk-3.5/include/Core/Hardware/ \ 87 | -I /opt/palmdev/sdk-3.5/include/Core/International/ 88 | 89 | CFLAGS_PALM := -Os $(DEFINES_PALM) $(INCLUDES_PALM) 90 | 91 | ifneq ($(BUILD),RELEASE) 92 | CFLAGS_PALM += -g -DLOG_TO_FILE 93 | endif 94 | 95 | LDFLAGS_PALM := $(CFLAGS_PALM) 96 | 97 | APPID := DSEK 98 | 99 | # 5. Targets 100 | 101 | platform := palm 102 | platform_upper := PALM 103 | res_gfx := $(DSEKAI_ASSETS_BITMAPS) 104 | $(eval $(RESEXT_H_RULE)) 105 | 106 | pkg_bin := $(BIN_PALM) 107 | pkg_strip := echo 108 | pkg_name := $(DSEKAI)-$(platform)-$(GIT_HASH) 109 | pkg_reqs := 110 | $(eval $(PKG_RULE)) 111 | 112 | $(OBJDIR_PALM)/$(DSEKAI): $(DSEKAI_O_FILES_PALM) $(MULIPALM_O) | $(MULIPALM_LD) 113 | $(LD_PALM) $(LDFLAGS_PALM) -o $@ $^ $(MULIPALM_LD) 114 | 115 | $(OBJDIR_PALM)/bin$(STAMPFILE): src/palms.rcp $(GENDIR_PALM)/palmd.rcp | \ 116 | $(OBJDIR_PALM)/$(STAMPFILE) 117 | $(PILRC) $(INCLUDES_PALM) $< $(OBJDIR_PALM) 118 | touch $@ 119 | 120 | $(MULIPALM_O): $(GENDIR_PALM)/mulipalm.s 121 | $(MD) $(dir $@) 122 | $(AS_PALM) -o $@ $< 123 | 124 | $(GENDIR_PALM)/mulipalm.s $(MULIPALM_LD): $(MULIPALM_DEF) | \ 125 | $(GENDIR_PALM) 126 | $(MULTIGEN) -b $(GENDIR_PALM)/mulipalm $< 127 | 128 | ifeq ($(BUILD),RELEASE) 129 | $(BIN_PALM): \ 130 | $(OBJDIR_PALM)/bin$(STAMPFILE) $(MULIPALM_DEF) $(OBJDIR_PALM)/$(DSEKAI) | \ 131 | $(BINDIR)/$(STAMPFILE) 132 | m68k-palmos-strip $(OBJDIR_PALM)/$(DSEKAI) 133 | $(BUILDPRC) -o $@ $(MULIPALM_DEF) $(OBJDIR_PALM)/$(DSEKAI) $(OBJDIR_PALM)/*.bin 134 | else 135 | $(BIN_PALM): \ 136 | $(OBJDIR_PALM)/bin$(STAMPFILE) $(MULIPALM_DEF) $(OBJDIR_PALM)/$(DSEKAI) | \ 137 | $(BINDIR)/$(STAMPFILE) 138 | $(BUILDPRC) -o $@ $(MULIPALM_DEF) $(OBJDIR_PALM)/$(DSEKAI) $(OBJDIR_PALM)/*.bin 139 | endif 140 | 141 | $(OBJDIR_PALM)/%.o: %.c $(GENDIR_PALM)/palmd.rcp $(RESEXT_H_PALM) 142 | $(MD) $(dir $@) 143 | $(CC_PALM) $(CFLAGS_PALM) -c -o $@ $(<:%.o=%) 144 | 145 | -------------------------------------------------------------------------------- /Makefile.sdl: -------------------------------------------------------------------------------- 1 | 2 | # vi:syntax=make 3 | 4 | ifneq ($(CALLER),MASTER) 5 | include Makefile.inc 6 | endif 7 | 8 | # 1. Directories 9 | 10 | OBJDIR_SDL := $(OBJDIR)/sdl 11 | DEPDIR_SDL := $(DEPDIR)/sdl 12 | GENDIR_SDL := $(GENDIR)/sdl 13 | 14 | # 2. Files 15 | 16 | BIN_SDL := $(BINDIR)/$(DSEKAI) 17 | 18 | DSEKAI_C_FILES_SDL_ONLY := \ 19 | src/main.c \ 20 | src/pov.c \ 21 | src/scparse.c \ 22 | unilayer/src/animate.c \ 23 | unilayer/src/input/sdli.c \ 24 | unilayer/src/graphics/sdlg.c \ 25 | unilayer/src/memory/fakem.c \ 26 | unilayer/src/save/file.c 27 | 28 | DSEKAI_O_FILES_SDL := \ 29 | $(addprefix $(OBJDIR_SDL)/,$(subst .c,.o,$(DSEKAI_C_FILES))) \ 30 | $(addprefix $(OBJDIR_SDL)/,$(subst .c,.o,$(DSEKAI_C_FILES_SDL_ONLY))) \ 31 | $(addprefix $(OBJDIR_SDL)/,$(subst .c,.o,$(DSEKAI_C_FILES_RES))) 32 | 33 | RESEXT_H_SDL := $(GENDIR_SDL)/resext.h 34 | 35 | # 1a. Packaging Manifest 36 | 37 | SDL_MANIFEST := 38 | 39 | ifeq ($(RESOURCE),FILE) 40 | SDL_MANIFEST += $(DSEKAI_ASSETS_BITMAPS) 41 | endif 42 | 43 | ifeq ($(FMT_ASN),TRUE) 44 | SDL_MANIFEST += $(subst .json,.asn,$(DSEKAI_ASSETS_MAPS_JSON)) 45 | endif 46 | 47 | ifeq ($(FMT_JSON),TRUE) 48 | SDL_MANIFEST += \ 49 | $(DSEKAI_ASSETS_MAPS_JSON) \ 50 | $(DSEKAI_ASSETS_TILESETS_JSON) \ 51 | $(DSEKAI_ASSETS_SCRIPTS) 52 | endif 53 | 54 | # 3. Programs 55 | 56 | CC_SDL := gcc 57 | LD_SDL := gcc 58 | 59 | # 4. Arguments 60 | 61 | ifeq ($(BUILD),RELEASE) 62 | DEFINES_DEBUG := 63 | else 64 | # Assume debug build. 65 | #DEFINES_DEBUG := -DUSE_BACKTRACE -DMEMORY_FAKE_TRACE_LOCKS -DSCRIPT_TRACE 66 | DEFINES_DEBUG := -DUSE_BACKTRACE -DMEMORY_HANDLE_SENTINAL=1234 -DDSEKAI_PROFILER 67 | endif 68 | 69 | DEFINES_SDL := \ 70 | $(DEFINES_DSEKAI) \ 71 | $(DEFINES_DEPTH) \ 72 | $(DEFINES_RESOURCE) \ 73 | $(DEFINES_DEBUG) \ 74 | -DUSE_SOFTWARE_TEXT \ 75 | -DSCREEN_SCALE=$(SCREEN_SCALE) 76 | 77 | INCLUDES_SDL := \ 78 | $(INCLUDES_UNILAYER) \ 79 | -I $(GENDIR_SDL) 80 | 81 | CFLAGS_SDL := $(CFLAGS_GCC_GENERIC) $(FLAGS_GCC_SANITIZE) $(DEFINES_SDL) $(INCLUDES_SDL) 82 | 83 | LDFLAGS_SDL := $(LDFLAGS_GCC_GENERIC) $(FLAGS_GCC_SANITIZE) -lm 84 | 85 | ifeq ($(TRACEWIN),TRUE) 86 | CFLAGS_SDL += -DWINDOW_TRACE 87 | endif 88 | 89 | ifeq ("$(SDL_VER)","1") 90 | CFLAGS_SDL += $(shell pkg-config sdl --cflags) -DPLATFORM_SDL1 91 | LDFLAGS_SDL += $(shell pkg-config sdl --libs) 92 | else 93 | CFLAGS_SDL += $(shell pkg-config sdl2 --cflags) -DPLATFORM_SDL2 94 | LDFLAGS_SDL += $(shell pkg-config sdl2 --libs) 95 | endif 96 | 97 | # 5. Targets 98 | 99 | platform := sdl 100 | platform_upper := SDL 101 | res_gfx := $(DSEKAI_ASSETS_BITMAPS) 102 | $(eval $(RESEXT_H_RULE)) 103 | 104 | pkg_bin := $(BIN_SDL) $(CONVERT) $(MAP2ASN) 105 | pkg_strip := strip 106 | pkg_name := $(DSEKAI)-$(platform)-$(PKGOS)-$(GIT_HASH) 107 | pkg_reqs := $(SDL_MANIFEST) 108 | $(eval $(PKG_RULE)) 109 | 110 | $(BIN_SDL): $(DSEKAI_O_FILES_SDL) | $(BINDIR)/$(STAMPFILE) 111 | $(LD_SDL) -o $@ $^ $(LDFLAGS_SDL) 112 | 113 | $(OBJDIR_SDL)/%.o: %.c $(RESEXT_H_SDL) | $(DSEKAI_ASSETS_MAPS_JSON) 114 | $(MD) $(dir $@) 115 | $(CC_SDL) $(CFLAGS_SDL) -c -o $@ $(<:%.o=%) 116 | 117 | $(DEPDIR_SDL)/%.d: %.c $(RESEXT_H_SDL) 118 | $(MD) $(dir $@) 119 | $(CC_SDL) $(CFLAGS_SDL) -MM $< \ 120 | -MT $(subst .c,.o,$(addprefix $(DEPDIR_SDL)/,$<)) -MF $@ 121 | 122 | #include $(subst $(OBJDIR)/,$(DEPDIR)/,$(DSEKAI_O_FILES_SDL:.o=.d)) 123 | 124 | -------------------------------------------------------------------------------- /Makefile.wasm: -------------------------------------------------------------------------------- 1 | 2 | # vi:syntax=make 3 | 4 | ifneq ($(CALLER),MASTER) 5 | include Makefile.inc 6 | endif 7 | 8 | # 1. Directories 9 | 10 | OBJDIR_WASM := $(OBJDIR)/wasm 11 | DEPDIR_WASM := $(DEPDIR)/wasm 12 | GENDIR_WASM := $(GENDIR)/wasm 13 | 14 | # 2. Files 15 | 16 | BIN_WASM := $(BINDIR)/$(DSEKAI).html 17 | 18 | ifeq ("$(RESOURCE)","DEFAULT") 19 | DEFINES_RESOURCE := -DRESOURCE_WASM 20 | DSEKAI_C_FILES_RES := unilayer/src/resource/webr.c 21 | endif 22 | 23 | DSEKAI_C_FILES_WASM_ONLY := \ 24 | src/main.c \ 25 | src/pov.c \ 26 | src/scparse.c \ 27 | unilayer/src/animate.c \ 28 | unilayer/src/input/sdli.c \ 29 | unilayer/src/graphics/sdlg.c \ 30 | unilayer/src/save/web.c \ 31 | unilayer/src/memory/fakem.c \ 32 | unilayer/src/resource/webr.c 33 | 34 | DSEKAI_O_FILES_WASM := \ 35 | $(addprefix $(OBJDIR_WASM)/,$(subst .c,.o,$(DSEKAI_C_FILES))) \ 36 | $(addprefix $(OBJDIR_WASM)/,$(subst .c,.o,$(DSEKAI_C_FILES_WASM_ONLY))) \ 37 | $(addprefix $(OBJDIR_WASM)/,$(subst .c,.o,$(DSEKAI_C_FILES_RES))) 38 | 39 | RESEXT_H_WASM := $(GENDIR_WASM)/resext.h 40 | 41 | # 3. Programs 42 | 43 | CC_WASM := emcc 44 | LD_WASM := emcc 45 | 46 | # 4. Arguments 47 | 48 | DEFINES_WASM := \ 49 | $(DEFINES_DSEKAI) \ 50 | $(DEFINES_DEPTH) \ 51 | $(DEFINES_RESOURCE) \ 52 | -DPLATFORM_SDL \ 53 | -DPLATFORM_WASM \ 54 | -DNO_QUIT \ 55 | -DUSE_SOFTWARE_TEXT \ 56 | -DSCREEN_SCALE=$(SCREEN_SCALE) 57 | 58 | INCLUDES_WASM := \ 59 | $(INCLUDES_UNILAYER) \ 60 | -I $(GENDIR_WASM) 61 | 62 | CFLAGS_WASM := $(CFLAGS_GCC_GENERIC) $(DEFINES_WASM) $(INCLUDES_WASM) -s USE_SDL=2 63 | 64 | LDFLAGS_WASM := $(LDFLAGS_GCC_GENERIC) -s USE_SDL=2 -s FETCH 65 | 66 | ifneq ($(BUILD),RELEASE) 67 | LDFLAGS_WASM += -s ASSERTIONS=1 68 | endif 69 | 70 | # 5. Targets 71 | 72 | # 5a. Packages 73 | 74 | platform := wasm 75 | platform_upper := WASM 76 | res_gfx := $(DSEKAI_ASSETS_BITMAPS) 77 | 78 | ifneq ("$(RESOURCE)", "DEFAULT") 79 | $(eval $(RESEXT_H_RULE)) 80 | else 81 | 82 | $(RESEXT_H_WASM): 83 | # TODO 84 | $(MD) $(dir $@) 85 | touch $@ 86 | 87 | endif 88 | 89 | pkg_bin := $(BIN_WASM) \ 90 | $(BINDIR)/$(DSEKAI).wasm \ 91 | $(BINDIR)/$(DSEKAI).js 92 | pkg_strip := echo 93 | pkg_name := $(DSEKAI)-$(platform)-$(GIT_HASH) 94 | pkg_reqs := 95 | $(eval $(PKG_RULE)) 96 | 97 | # 5b. Binaries 98 | 99 | $(BIN_WASM) $(BINDIR)/$(DSEKAI).wasm $(BINDIR)/$(DSEKAI).js: \ 100 | $(DSEKAI_O_FILES_WASM) | $(BINDIR)/$(STAMPFILE) 101 | $(LD_WASM) -o $(BIN_WASM) $^ $(LDFLAGS_WASM) 102 | 103 | $(OBJDIR_WASM)/%.o: %.c $(RESEXT_H_WASM) | $(DSEKAI_ASSETS_MAPS_JSON) 104 | $(MD) $(dir $@) 105 | $(CC_WASM) $(CFLAGS_WASM) -c -o $@ $(<:%.o=%) 106 | 107 | #$(DEPDIR_WASM)/%.d: %.c $(RESEXT_H_WASM) 108 | # $(MD) $(dir $@) 109 | # $(CC_WASM) $(CFLAGS_WASM) -MM $< \ 110 | # -MT $(subst .c,.o,$(addprefix $(DEPDIR_WASM)/,$<)) -MF $@ 111 | # 112 | #include $(subst $(OBJDIR)/,$(DEPDIR)/,$(DSEKAI_O_FILES_WASM:.o=.d)) 113 | 114 | -------------------------------------------------------------------------------- /Makefile.win16: -------------------------------------------------------------------------------- 1 | 2 | # vi:syntax=make 3 | 4 | ifneq ($(CALLER),MASTER) 5 | include Makefile.inc 6 | endif 7 | 8 | # 1. Directories 9 | 10 | OBJDIR_WIN16 := $(OBJDIR)/win16 11 | DEPDIR_WIN16 := $(DEPDIR)/win16 12 | GENDIR_WIN16 := $(GENDIR)/win16 13 | 14 | # 2. Files 15 | 16 | BIN_WIN16 := $(BINDIR)/$(DSEKAI)16.exe 17 | 18 | DSEKAI_C_FILES_WIN16_ONLY := \ 19 | src/main.c \ 20 | unilayer/src/input/wini.c \ 21 | unilayer/src/memory/winm.c \ 22 | unilayer/src/graphics/wing.c \ 23 | unilayer/src/save/file.c 24 | 25 | ifeq ($(RESOURCE),DEFAULT) 26 | DSEKAI_C_FILES_WIN16_ONLY += unilayer/src/resource/winr.c 27 | else 28 | DSEKAI_C_FILES_WIN16_ONLY += $(DSEKAI_C_FILES_RES) 29 | endif 30 | 31 | DSEKAI_O_FILES_WIN16 := \ 32 | $(addprefix $(OBJDIR_WIN16)/,$(subst .c,.o,$(DSEKAI_C_FILES))) \ 33 | $(addprefix $(OBJDIR_WIN16)/,$(subst .c,.o,$(DSEKAI_C_FILES_WIN16_ONLY))) 34 | 35 | WIN16_RES_FILES := src/winstat.rc 36 | ifeq ($(RESOURCE),DEFAULT) 37 | WIN16_RES_FILES += $(GENDIR_WIN16)/win.rc 38 | endif 39 | WIN16_RES_FILES += $(ASSETDIR)/$(DSEKAI).ico 40 | 41 | # 1a. Packaging Manifest 42 | 43 | WIN16_MANIFEST := 44 | 45 | ifeq ($(RESOURCE),FILE) 46 | WIN16_MANIFEST += $(DSEKAI_ASSETS_BITMAPS) 47 | endif 48 | 49 | ifeq ($(FMT_ASN),TRUE) 50 | WIN16_MANIFEST += $(subst .json,.asn,$(DSEKAI_ASSETS_MAPS_JSON)) 51 | endif 52 | 53 | ifeq ($(FMT_JSON),TRUE) 54 | WIN16_MANIFEST += \ 55 | $(DSEKAI_ASSETS_MAPS_JSON) \ 56 | $(DSEKAI_ASSETS_TILESETS_JSON) 57 | endif 58 | 59 | RESEXT_H_WIN16 := $(GENDIR_WIN16)/resext.h 60 | 61 | # 3. Programs 62 | 63 | CC_WIN16 := wcc 64 | LD_WIN16 := wcl 65 | RC_WIN16 := wrc 66 | 67 | # 4. Arguments 68 | 69 | DEFINES_WIN16 := \ 70 | $(DEFINES_DSEKAI) \ 71 | $(DEFINES_DEPTH) \ 72 | -DPLATFORM_WIN16 \ 73 | -DNO_ENGINE_POV \ 74 | -DNO_ANIMATE \ 75 | -DWINM_MOVEABLE \ 76 | -DNO_SCRIPT_COMPILER 77 | #-DWIN16_FAKE_DS 78 | 79 | INCLUDES_WIN16 := \ 80 | $(subst -I ,-i=,$(INCLUDES_UNILAYER)) \ 81 | -i=$(GENDIR_WIN16) \ 82 | -i=$(INCLUDE)/win 83 | 84 | CFLAGS_WIN16 := -bt=windows -bw -ml -DMEMORY_LARGE $(CFLAGS_OWC_GENERIC) -zp=1 $(DEFINES_WIN16) $(INCLUDES_WIN16) 85 | 86 | LDFLAGS_WIN16 := -l=windows -ml $(LDFLAGS_OWC_GENERIC) 87 | 88 | RCFLAGS_WIN16 := -r $(DEFINES_WIN16) -i=$(INCLUDE)win 89 | 90 | ifneq ($(BUILD),RELEASE) 91 | # Debug build. 92 | CFLAGS_WIN16 += -DLOG_TO_FILE 93 | LDFLAGS_WIN16 += -en -d3 94 | endif 95 | 96 | ifneq ($(RESOURCE),DEFAULT) 97 | CFLAGS_WIN16 += $(subst -I ,-I=,$(DEFINES_RESOURCE)) 98 | endif 99 | 100 | ifeq ($(RESOURCE),DEFAULT) 101 | RCFLAGS_WIN16 += -DRESOURCE_WIN 102 | endif 103 | 104 | # 5. Targets 105 | 106 | platform := win16 107 | platform_upper := WIN16 108 | res_gfx := $(DSEKAI_ASSETS_BITMAPS) 109 | $(eval $(RESEXT_H_RULE)) 110 | 111 | pkg_bin := $(BIN_WIN16) 112 | pkg_strip := echo 113 | pkg_name := $(DSEKAI)-$(platform)-$(GIT_HASH) 114 | pkg_reqs := $(WIN16_MANIFEST) 115 | $(eval $(PKG_RULE)) 116 | 117 | $(BINDIR)/$(DSEKAI)16.img: $(BIN_WIN16) 118 | $(DD) if=/dev/zero bs=512 count=2880 of="$@" 119 | $(MKFSVFAT) "$@" 120 | $(MCOPY) -i "$@" $< ::$(DSEKAI)16.exe 121 | 122 | $(BIN_WIN16): \ 123 | $(DSEKAI_O_FILES_WIN16) $(OBJDIR_WIN16)/win.res | $(BINDIR)/$(STAMPFILE) 124 | $(LD_WIN16) $(LDFLAGS_WIN16) -fe=$@ $^ 125 | 126 | $(OBJDIR_WIN16)/win.res: $(WIN16_RES_FILES) | $(OBJDIR_WIN16)/$(STAMPFILE) 127 | $(RC_WIN16) $(RCFLAGS_WIN16) $< -fo=$@ 128 | 129 | $(OBJDIR_WIN16)/%.o: %.c $(OBJDIR_WIN16)/win.res $(RESEXT_H_WIN16) 130 | $(MD) $(dir $@) 131 | $(CC_WIN16) $(CFLAGS_WIN16) -fo=$@ $(<:%.c=%) 132 | 133 | #$(DEPDIR_WIN16)/%.d: %.c $(RESEXT_H_WIN16) 134 | # $(MD) $(dir $@) 135 | # $(HOST_CC) $(subst -i=,-I ,$(INCLUDES_WIN16)) $(DEFINES_WIN16) -MM $< \ 136 | # -MT $(subst .c,.o,$(addprefix $(DEPDIR_WIN32)/,$<)) -MF $@ 137 | 138 | #include $(subst $(OBJDIR)/,$(DEPDIR)/,$(DSEKAI_O_FILES_WIN16:.o=.d)) 139 | 140 | -------------------------------------------------------------------------------- /Makefile.win32: -------------------------------------------------------------------------------- 1 | 2 | # vi:syntax=make 3 | 4 | ifneq ($(CALLER),MASTER) 5 | include Makefile.inc 6 | endif 7 | 8 | # 1. Directories 9 | 10 | OBJDIR_WIN32 := $(OBJDIR)/win32 11 | DEPDIR_WIN32 := $(DEPDIR)/win32 12 | GENDIR_WIN32 := $(GENDIR)/win32 13 | 14 | CONVERT_OBJDIR_WIN32 := $(OBJDIR)/convert/win32 15 | MAP2ASN_OBJDIR_WIN32 := $(OBJDIR)/map2asn/win32 16 | 17 | # 2. Files 18 | 19 | BIN_WIN32 := $(BINDIR)/$(DSEKAI)32.exe 20 | 21 | DSEKAI_C_FILES_WIN32_ONLY := \ 22 | src/main.c \ 23 | src/pov.c \ 24 | src/scparse.c \ 25 | unilayer/src/animate.c \ 26 | unilayer/src/input/wini.c \ 27 | unilayer/src/memory/winm.c \ 28 | unilayer/src/graphics/wing.c \ 29 | unilayer/src/save/file.c 30 | 31 | ifeq ($(RESOURCE),DEFAULT) 32 | DSEKAI_C_FILES_WIN32_ONLY += unilayer/src/resource/winr.c 33 | else 34 | DSEKAI_C_FILES_WIN32_ONLY += $(DSEKAI_C_FILES_RES) 35 | endif 36 | 37 | DSEKAI_O_FILES_WIN32 := \ 38 | $(addprefix $(OBJDIR_WIN32)/,$(subst .c,.o,$(DSEKAI_C_FILES))) \ 39 | $(addprefix $(OBJDIR_WIN32)/,$(subst .c,.o,$(DSEKAI_C_FILES_WIN32_ONLY))) 40 | 41 | WIN32_RES_FILES := src/winstat.rc 42 | ifeq ($(RESOURCE),DEFAULT) 43 | WIN32_RES_FILES += $(GENDIR_WIN32)/win.rc 44 | endif 45 | WIN32_RES_FILES += $(ASSETDIR)/$(DSEKAI).ico 46 | 47 | # 2b. Utilities 48 | 49 | # Rough hack: replace "fake" with "win" to use the correct memory module. 50 | 51 | CONVERT_O_FILES_WIN32 := \ 52 | $(addprefix $(CONVERT_OBJDIR_WIN32)/,$(subst .c,.o,$(subst fake,win,$(CONVERT_C_FILES)))) 53 | 54 | MAP2ASN_O_FILES_WIN32 := \ 55 | $(addprefix $(MAP2ASN_OBJDIR_WIN32)/,$(subst .c,.o,$(subst fake,win,$(MAP2ASN_C_FILES)))) 56 | 57 | # 1a. Packaging Manifest 58 | 59 | WIN32_MANIFEST := 60 | 61 | ifeq ($(RESOURCE),FILE) 62 | WIN32_MANIFEST += $(DSEKAI_ASSETS_BITMAPS) 63 | endif 64 | 65 | ifeq ($(FMT_ASN),TRUE) 66 | WIN32_MANIFEST += $(subst .json,.asn,$(DSEKAI_ASSETS_MAPS_JSON)) 67 | endif 68 | 69 | ifeq ($(FMT_JSON),TRUE) 70 | WIN32_MANIFEST += \ 71 | $(DSEKAI_ASSETS_MAPS_JSON) \ 72 | $(DSEKAI_ASSETS_TILESETS_JSON) 73 | endif 74 | 75 | RESEXT_H_WIN32 := $(GENDIR_WIN32)/resext.h 76 | 77 | # 3. Programs 78 | 79 | CC_WIN32 := wcc386 80 | LD_WIN32 := wcl386 81 | RC_WIN32 := wrc 82 | 83 | # 4. Arguments 84 | 85 | DEFINES_WIN32 := \ 86 | $(DEFINES_DSEKAI) \ 87 | $(DEFINES_DEPTH) \ 88 | -DPLATFORM_WIN32 89 | 90 | INCLUDES_WIN32 := \ 91 | $(subst -I ,-i=,$(INCLUDES_UNILAYER)) \ 92 | -i=$(GENDIR_WIN32) \ 93 | -i=$(INCLUDE)/nt 94 | 95 | CFLAGS_WIN32_BASIC := -bt=nt -3 -zp=1 96 | 97 | CFLAGS_WIN32 := $(CFLAGS_WIN32_BASIC) $(CFLAGS_OWC_GENERIC) $(DEFINES_WIN32) $(INCLUDES_WIN32) 98 | 99 | ifneq ($(RESOURCE),DEFAULT) 100 | CFLAGS_WIN32 += $(subst -I ,-I=,$(DEFINES_RESOURCE)) 101 | endif 102 | 103 | ifneq ($(BUILD),RELEASE) 104 | CFLAGS_WIN16 += -DLOG_TO_FILE 105 | endif 106 | 107 | LDFLAGS_WIN32 := -bcl=nt_win -zp=1 $(LDFLAGS_OWC_GENERIC) 108 | 109 | RCFLAGS_WIN32 := -r $(DEFINES_WIN32) -i=$(INCLUDE)win -bt=nt 110 | 111 | ifeq ($(RESOURCE),DEFAULT) 112 | RCFLAGS_WIN32 += -DRESOURCE_WIN 113 | endif 114 | 115 | # 4b. Utilities 116 | 117 | CFLAGS_UTILITY_WIN32 := $(CFLAGS_WIN32_BASIC) $(DEFINES_MAP2ASN) $(INCLUDES_WIN32) -DPLATFORM_WIN32 118 | 119 | # 5. Targets 120 | 121 | platform := win32 122 | platform_upper := WIN32 123 | res_gfx := $(DSEKAI_ASSETS_BITMAPS) 124 | $(eval $(RESEXT_H_RULE)) 125 | 126 | pkg_bin := $(BIN_WIN32) $(BINDIR)/conv32.exe $(BINDIR)/mapasn32.exe 127 | pkg_strip := echo 128 | pkg_name := $(DSEKAI)-$(platform)-$(GIT_HASH) 129 | pkg_reqs := $(WIN32_MANIFEST) 130 | $(eval $(PKG_RULE)) 131 | 132 | $(BIN_WIN32): \ 133 | $(DSEKAI_O_FILES_WIN32) $(OBJDIR_WIN32)/win.res | $(BINDIR)/$(STAMPFILE) 134 | $(LD_WIN32) $(LDFLAGS_WIN32) -fe=$@ $^ 135 | 136 | $(OBJDIR_WIN32)/win.res: $(WIN32_RES_FILES) | $(OBJDIR_WIN32)/$(STAMPFILE) 137 | $(RC_WIN32) $(RCFLAGS_WIN32) $< -fo=$@ 138 | 139 | $(OBJDIR_WIN32)/%.o: %.c $(OBJDIR_WIN32)/win.res $(RESEXT_H_WIN32) 140 | $(MD) $(dir $@) 141 | $(CC_WIN32) $(CFLAGS_WIN32) -fo=$@ $(<:%.c=%) 142 | 143 | #$(DEPDIR_WIN32)/%.d: %.c $(RESEXT_H_WIN32) 144 | # $(MD) $(dir $@) 145 | # $(HOST_CC) $(subst -i=,-I ,$(INCLUDES_WIN32)) $(DEFINES_WIN32) -MM $< \ 146 | # -MT $(subst .c,.o,$(addprefix $(DEPDIR_WIN32)/,$<)) -MF $@ 147 | 148 | #include $(subst $(OBJDIR)/,$(DEPDIR)/,$(DSEKAI_O_FILES_WIN32:.o=.d)) 149 | 150 | # 5b. Windows Utilities 151 | 152 | $(CONVERT_OBJDIR_WIN32)/%.o: %.c 153 | $(MD) $(dir $@) 154 | $(CC_WIN32) $(CFLAGS_UTILITY_WIN32) -fo=$@ $(<:%.c=%) 155 | 156 | $(BINDIR)/conv32.exe: $(CONVERT_O_FILES_WIN32) 157 | $(LD_WIN32) $(LDFLAGS_WIN32) -fe=$@ $^ 158 | 159 | $(MAP2ASN_OBJDIR_WIN32)/%.o: %.c 160 | $(MD) $(dir $@) 161 | $(CC_WIN32) $(CFLAGS_UTILITY_WIN32) -fo=$@ $(<:%.c=%) 162 | 163 | $(BINDIR)/mapasn32.exe: $(MAP2ASN_O_FILES_WIN32) | $(BINDIR)/$(STAMPFILE) 164 | $(LD_WIN32) $(LDFLAGS_WIN32) -fe=$@ $^ 165 | 166 | -------------------------------------------------------------------------------- /Makefile.win386: -------------------------------------------------------------------------------- 1 | 2 | # vi:syntax=make 3 | 4 | ifneq ($(CALLER),MASTER) 5 | include Makefile.inc 6 | endif 7 | 8 | # 1. Directories 9 | 10 | OBJDIR_WIN386 := $(OBJDIR)/win386 11 | DEPDIR_WIN386 := $(DEPDIR)/win386 12 | GENDIR_WIN386 := $(GENDIR)/win386 13 | 14 | # 2. Files 15 | 16 | BIN_WIN386 := $(BINDIR)/$(DSEKAI)le.exe 17 | 18 | DSEKAI_C_FILES_WIN386_ONLY := \ 19 | src/main.c \ 20 | src/pov.c \ 21 | src/scparse.c \ 22 | unilayer/src/animate.c \ 23 | unilayer/src/input/wini.c \ 24 | unilayer/src/memory/fakem.c \ 25 | unilayer/src/graphics/wing.c \ 26 | unilayer/src/save/file.c 27 | 28 | ifeq ($(RESOURCE),DEFAULT) 29 | DSEKAI_C_FILES_WIN386_ONLY += unilayer/src/resource/winr.c 30 | else 31 | DSEKAI_C_FILES_WIN386_ONLY += $(DSEKAI_C_FILES_RES) 32 | endif 33 | 34 | DSEKAI_O_FILES_WIN386 := \ 35 | $(addprefix $(OBJDIR_WIN386)/,$(subst .c,.o,$(DSEKAI_C_FILES))) \ 36 | $(addprefix $(OBJDIR_WIN386)/,$(subst .c,.o,$(DSEKAI_C_FILES_WIN386_ONLY))) 37 | 38 | WIN386_RES_FILES := src/winstat.rc 39 | ifeq ($(RESOURCE),DEFAULT) 40 | WIN386_RES_FILES += $(GENDIR_WIN386)/win.rc 41 | endif 42 | #WIN386_RES_FILES += $(ASSETDIR)/$(DSEKAI).ico 43 | 44 | # 1a. Packaging Manifest 45 | 46 | WIN386_MANIFEST := 47 | 48 | ifeq ($(RESOURCE),FILE) 49 | WIN386_MANIFEST += $(DSEKAI_ASSETS_BITMAPS) 50 | endif 51 | 52 | ifeq ($(FMT_ASN),TRUE) 53 | WIN386_MANIFEST += $(subst .json,.asn,$(DSEKAI_ASSETS_MAPS_JSON)) 54 | endif 55 | 56 | ifeq ($(FMT_JSON),TRUE) 57 | WIN386_MANIFEST += \ 58 | $(DSEKAI_ASSETS_MAPS_JSON) \ 59 | $(DSEKAI_ASSETS_TILESETS_JSON) 60 | endif 61 | 62 | RESEXT_H_WIN386 := $(GENDIR_WIN386)/resext.h 63 | 64 | # 3. Programs 65 | 66 | CC_WIN386 := wcc386 67 | LD_WIN386 := wcl386 68 | RC_WIN386 := wrc 69 | 70 | # 4. Arguments 71 | 72 | DEFINES_WIN386 := \ 73 | $(DEFINES_DSEKAI) \ 74 | $(DEFINES_DEPTH) \ 75 | -DPLATFORM_WIN16 \ 76 | -DMEMORY_FAKE 77 | 78 | INCLUDES_WIN386 := \ 79 | $(subst -I ,-i=,$(INCLUDES_UNILAYER)) \ 80 | -i=$(GENDIR_WIN386) \ 81 | -i=$(INCLUDE)/win 82 | 83 | CFLAGS_WIN386 := -bt=windows -bw $(CFLAGS_OWC_GENERIC) $(DEFINES_WIN386) $(INCLUDES_WIN386) 84 | 85 | LDFLAGS_WIN386 := -l=win386 $(LDFLAGS_OWC_GENERIC) 86 | 87 | RCFLAGS_WIN386 := $(DEFINES_WIN386) -i=$(INCLUDE)win 88 | 89 | ifneq ($(BUILD),RELEASE) 90 | # Debug build. 91 | CFLAGS_WIN386 += -DLOG_TO_FILE 92 | LDFLAGS_WIN386 += -en -d3 93 | endif 94 | 95 | ifneq ($(RESOURCE),DEFAULT) 96 | CFLAGS_WIN386 += $(subst -I ,-I=,$(DEFINES_RESOURCE)) 97 | endif 98 | 99 | ifeq ($(RESOURCE),DEFAULT) 100 | RCFLAGS_WIN386 += -DRESOURCE_WIN 101 | endif 102 | 103 | # 5. Targets 104 | 105 | platform := win386 106 | platform_upper := WIN386 107 | res_gfx := $(DSEKAI_ASSETS_BITMAPS) 108 | $(eval $(RESEXT_H_RULE)) 109 | 110 | pkg_bin := $(BIN_WIN386) 111 | pkg_strip := echo 112 | pkg_name := $(DSEKAI)-$(platform)-$(GIT_HASH) 113 | pkg_reqs := $(WIN386_MANIFEST) 114 | $(eval $(PKG_RULE)) 115 | 116 | $(BINDIR)/$(DSEKAI)le.img: $(BIN_WIN386) 117 | $(DD) if=/dev/zero bs=512 count=2880 of="$@" 118 | $(MKFSVFAT) "$@" 119 | $(MCOPY) -i "$@" $< ::$(DSEKAI)le.exe 120 | 121 | $(OBJDIR_WIN386)/$(DSEKAI)le.rex: \ 122 | $(DSEKAI_O_FILES_WIN386) | $(OBJDIR_WIN386)/$(STAMPFILE) 123 | $(LD_WIN386) $(LDFLAGS_WIN386) -fe=$@ $^ 124 | 125 | $(BIN_WIN386): $(OBJDIR_WIN386)/$(DSEKAI)le.rex | $(BINDIR)/$(STAMPFILE) 126 | wbind $< -s $(WATCOM)/binw/win386.ext -R $(WIN386_RES_FILES) $(RCFLAGS_WIN386) $(OBJDIR_WIN386)/$(DSEKAI)le.exe 127 | mv -v $(OBJDIR_WIN386)/$(DSEKAI)le.exe $(BIN_WIN386) 128 | 129 | $(OBJDIR_WIN386)/%.o: %.c $(RESEXT_H_WIN386) 130 | $(MD) $(dir $@) 131 | $(CC_WIN386) $(CFLAGS_WIN386) -fo=$@ $(<:%.c=%) 132 | 133 | #$(DEPDIR_WIN386)/%.d: %.c $(RESEXT_H_WIN386) 134 | # $(MD) $(dir $@) 135 | # $(HOST_CC) $(subst -i=,-I ,$(INCLUDES_WIN386)) $(DEFINES_WIN386) -MM $< \ 136 | # -MT $(subst .c,.o,$(addprefix $(DEPDIR_WIN32)/,$<)) -MF $@ 137 | 138 | #include $(subst $(OBJDIR)/,$(DEPDIR)/,$(DSEKAI_O_FILES_WIN386:.o=.d)) 139 | 140 | -------------------------------------------------------------------------------- /Makefile.xlib: -------------------------------------------------------------------------------- 1 | 2 | # vi:syntax=make 3 | 4 | ifneq ($(CALLER),MASTER) 5 | include Makefile.inc 6 | endif 7 | 8 | ifneq ($(DEPTH),CGA) 9 | ifneq ($(DEPTH),MONO) 10 | $(error xlib target must be built with CGA DEPTH) 11 | endif 12 | endif 13 | 14 | # 1. Directories 15 | 16 | OBJDIR_XLIB := $(OBJDIR)/xlib 17 | DEPDIR_XLIB := $(DEPDIR)/xlib 18 | GENDIR_XLIB := $(GENDIR)/xlib 19 | 20 | # 2. Files 21 | 22 | BIN_XLIB := $(BINDIR)/$(DSEKAI)x 23 | 24 | DSEKAI_C_FILES_XLIB_ONLY := \ 25 | src/main.c \ 26 | src/pov.c \ 27 | src/scparse.c \ 28 | unilayer/src/animate.c \ 29 | unilayer/src/input/xi.c \ 30 | unilayer/src/graphics/xg.c \ 31 | unilayer/src/memory/fakem.c \ 32 | unilayer/src/save/file.c 33 | 34 | DSEKAI_O_FILES_XLIB := \ 35 | $(addprefix $(OBJDIR_XLIB)/,$(subst .c,.o,$(DSEKAI_C_FILES))) \ 36 | $(addprefix $(OBJDIR_XLIB)/,$(subst .c,.o,$(DSEKAI_C_FILES_XLIB_ONLY))) \ 37 | $(addprefix $(OBJDIR_XLIB)/,$(subst .c,.o,$(DSEKAI_C_FILES_RES))) 38 | 39 | # 1a. Packaging Manifest 40 | 41 | XLIB_MANIFEST := 42 | 43 | ifeq ($(RESOURCE),FILE) 44 | XLIB_MANIFEST += $(DSEKAI_ASSETS_BITMAPS) 45 | endif 46 | 47 | ifeq ($(FMT_ASN),TRUE) 48 | XLIB_MANIFEST += $(subst .json,.asn,$(DSEKAI_ASSETS_MAPS_JSON)) 49 | endif 50 | 51 | ifeq ($(FMT_JSON),TRUE) 52 | XLIB_MANIFEST += \ 53 | $(DSEKAI_ASSETS_MAPS_JSON) \ 54 | $(DSEKAI_ASSETS_TILESETS_JSON) 55 | endif 56 | 57 | RESEXT_H_XLIB := $(GENDIR_XLIB)/resext.h 58 | 59 | # 3. Programs 60 | 61 | CC_XLIB := gcc 62 | LD_XLIB := gcc 63 | 64 | # 4. Arguments 65 | 66 | DEFINES_XLIB := \ 67 | $(DEFINES_DSEKAI) \ 68 | $(DEFINES_DEPTH) \ 69 | $(DEFINES_RESOURCE) \ 70 | -DPLATFORM_XLIB \ 71 | -DUSE_SOFTWARE_TEXT \ 72 | -DUSE_SOFTWARE_LINES \ 73 | -DSCREEN_SCALE=$(SCREEN_SCALE) 74 | 75 | INCLUDES_XLIB := \ 76 | $(INCLUDES_UNILAYER) \ 77 | -I $(GENDIR_XLIB) 78 | 79 | CFLAGS_XLIB := $(CFLAGS_GCC_GENERIC) $(FLAGS_GCC_SANITIZE) $(DEFINES_XLIB) $(INCLUDES_XLIB) 80 | 81 | LDFLAGS_XLIB := -lX11 -lm $(LDFLAGS_GCC_GENERIC) $(FLAGS_GCC_SANITIZE) 82 | 83 | # 5. Targets 84 | 85 | platform := xlib 86 | platform_upper := XLIB 87 | res_gfx := $(DSEKAI_ASSETS_BITMAPS) 88 | $(eval $(RESEXT_H_RULE)) 89 | 90 | pkg_bin := $(BIN_XLIB) $(CONVERT) $(MAP2ASN) 91 | pkg_strip := strip 92 | pkg_name := $(DSEKAI)-$(platform)-$(PKGOS)-$(GIT_HASH) 93 | pkg_reqs := $(XLIB_MANIFEST) 94 | $(eval $(PKG_RULE)) 95 | 96 | $(BIN_XLIB): $(DSEKAI_O_FILES_XLIB) | $(BINDIR)/$(STAMPFILE) $(RESEXT_H_XLIB) 97 | $(LD_XLIB) -o $@ $^ $(LDFLAGS_XLIB) 98 | 99 | $(OBJDIR_XLIB)/%.o: %.c $(RESEXT_H_XLIB) 100 | $(MD) $(dir $@) 101 | $(CC_XLIB) $(CFLAGS_XLIB) -c -o $@ $(<:%.o=%) 102 | 103 | $(DEPDIR_XLIB)/%.d: %.c $(RESEXT_H_XLIB) 104 | $(MD) $(dir $@) 105 | $(CC_XLIB) $(CFLAGS_XLIB) -MM $< \ 106 | -MT $(subst .c,.o,$(addprefix $(DEPDIR_XLIB)/,$<)) -MF $@ 107 | 108 | #include $(subst $(OBJDIR)/,$(DEPDIR)/,$(DSEKAI_O_FILES_XLIB:.o=.d)) 109 | 110 | -------------------------------------------------------------------------------- /Unifile: -------------------------------------------------------------------------------- 1 | [code] 2 | src/tilemap.c 3 | src/mobile.c 4 | src/item.c 5 | src/window.c 6 | src/script.c 7 | src/engines.c 8 | src/topdown.c 9 | src/title.c 10 | src/menu.c 11 | src/crop.c 12 | src/strpool.c 13 | unilayer/src/graphics.c 14 | unilayer/src/dio.c 15 | 16 | [includes] 17 | -Iunilayer/src 18 | 19 | [code.dos] 20 | src/main.c 21 | unilayer/src/input/dosi.c 22 | unilayer/src/graphics/dosg.c 23 | unilayer/src/memory/fakem.c 24 | 25 | [defines.dos] 26 | -DNO_ENGINE_POV 27 | -DNO_TRANSITIONS 28 | -DNO_ANIMATE 29 | -DUSE_SOFTWARE_TEXT 30 | -DUSE_SOFTWARE_LINES 31 | -DDISABLE_WEATHER_EFFECTS 32 | -DGRAPHICS_CACHE_INITIAL_SZ=25 33 | -DRESOURCE_PATH_MAX=28 34 | -DUSE_LOOKUPS 35 | 36 | [code.plm] 37 | src/main.c 38 | unilayer/src/input/palmi.c 39 | unilayer/src/memory/palmm.c 40 | unilayer/src/resource/palmr.c 41 | unilayer/src/graphics/palmg.c 42 | 43 | [defines.plm] 44 | -DNO_ENGINE_POV 45 | -DNO_TITLE 46 | -DNO_ANIMATE 47 | -DUSE_SOFTWARE_TEXT 48 | -DUSE_SOFTWARE_LINES 49 | 50 | [defines.w16] 51 | -DNO_ENGINE_POV 52 | -DUSE_SOFTWARE_TEXT 53 | 54 | [defines.w32] 55 | -DUSE_SOFTWARE_TEXT 56 | -DSCREEN_SCALE=2 57 | 58 | -------------------------------------------------------------------------------- /assets/16x16x16/c_turnip.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/c_turnip.bmp -------------------------------------------------------------------------------- /assets/16x16x16/i_apple.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/i_apple.bmp -------------------------------------------------------------------------------- /assets/16x16x16/i_hammer.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/i_hammer.bmp -------------------------------------------------------------------------------- /assets/16x16x16/i_hoe.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/i_hoe.bmp -------------------------------------------------------------------------------- /assets/16x16x16/i_plot.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/i_plot.bmp -------------------------------------------------------------------------------- /assets/16x16x16/i_seed.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/i_seed.bmp -------------------------------------------------------------------------------- /assets/16x16x16/i_turnip.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/i_turnip.bmp -------------------------------------------------------------------------------- /assets/16x16x16/p_chk_b.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/p_chk_b.bmp -------------------------------------------------------------------------------- /assets/16x16x16/p_chk_bl.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/p_chk_bl.bmp -------------------------------------------------------------------------------- /assets/16x16x16/p_chk_br.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/p_chk_br.bmp -------------------------------------------------------------------------------- /assets/16x16x16/p_chk_c.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/p_chk_c.bmp -------------------------------------------------------------------------------- /assets/16x16x16/p_chk_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/p_chk_l.bmp -------------------------------------------------------------------------------- /assets/16x16x16/p_chk_r.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/p_chk_r.bmp -------------------------------------------------------------------------------- /assets/16x16x16/p_chk_t.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/p_chk_t.bmp -------------------------------------------------------------------------------- /assets/16x16x16/p_chk_tl.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/p_chk_tl.bmp -------------------------------------------------------------------------------- /assets/16x16x16/p_chk_tr.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/p_chk_tr.bmp -------------------------------------------------------------------------------- /assets/16x16x16/s_dog.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/s_dog.bmp -------------------------------------------------------------------------------- /assets/16x16x16/s_fount.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/s_fount.bmp -------------------------------------------------------------------------------- /assets/16x16x16/s_maid.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/s_maid.bmp -------------------------------------------------------------------------------- /assets/16x16x16/s_mglass.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/s_mglass.bmp -------------------------------------------------------------------------------- /assets/16x16x16/s_pncess.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/s_pncess.bmp -------------------------------------------------------------------------------- /assets/16x16x16/s_robe.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/s_robe.bmp -------------------------------------------------------------------------------- /assets/16x16x16/s_witch.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/s_witch.bmp -------------------------------------------------------------------------------- /assets/16x16x16/s_world.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/s_world.bmp -------------------------------------------------------------------------------- /assets/16x16x16/s_yeti.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/s_yeti.bmp -------------------------------------------------------------------------------- /assets/16x16x16/t_brick.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/t_brick.bmp -------------------------------------------------------------------------------- /assets/16x16x16/t_dirt.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/t_dirt.bmp -------------------------------------------------------------------------------- /assets/16x16x16/t_grass.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/t_grass.bmp -------------------------------------------------------------------------------- /assets/16x16x16/t_pillar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/t_pillar.bmp -------------------------------------------------------------------------------- /assets/16x16x16/t_pool.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/t_pool.bmp -------------------------------------------------------------------------------- /assets/16x16x16/t_sgrass.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/t_sgrass.bmp -------------------------------------------------------------------------------- /assets/16x16x16/t_spillr.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/t_spillr.bmp -------------------------------------------------------------------------------- /assets/16x16x16/t_stree.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/t_stree.bmp -------------------------------------------------------------------------------- /assets/16x16x16/t_tile.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/t_tile.bmp -------------------------------------------------------------------------------- /assets/16x16x16/t_tree.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x16/t_tree.bmp -------------------------------------------------------------------------------- /assets/16x16x2/c_turnip.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/c_turnip.bmp -------------------------------------------------------------------------------- /assets/16x16x2/i_apple.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/i_apple.bmp -------------------------------------------------------------------------------- /assets/16x16x2/i_hammer.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/i_hammer.bmp -------------------------------------------------------------------------------- /assets/16x16x2/i_hoe.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/i_hoe.bmp -------------------------------------------------------------------------------- /assets/16x16x2/i_plot.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/i_plot.bmp -------------------------------------------------------------------------------- /assets/16x16x2/i_seed.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/i_seed.bmp -------------------------------------------------------------------------------- /assets/16x16x2/i_turnip.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/i_turnip.bmp -------------------------------------------------------------------------------- /assets/16x16x2/p_chk_b.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/p_chk_b.bmp -------------------------------------------------------------------------------- /assets/16x16x2/p_chk_bl.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/p_chk_bl.bmp -------------------------------------------------------------------------------- /assets/16x16x2/p_chk_br.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/p_chk_br.bmp -------------------------------------------------------------------------------- /assets/16x16x2/p_chk_c.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/p_chk_c.bmp -------------------------------------------------------------------------------- /assets/16x16x2/p_chk_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/p_chk_l.bmp -------------------------------------------------------------------------------- /assets/16x16x2/p_chk_r.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/p_chk_r.bmp -------------------------------------------------------------------------------- /assets/16x16x2/p_chk_t.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/p_chk_t.bmp -------------------------------------------------------------------------------- /assets/16x16x2/p_chk_tl.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/p_chk_tl.bmp -------------------------------------------------------------------------------- /assets/16x16x2/p_chk_tr.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/p_chk_tr.bmp -------------------------------------------------------------------------------- /assets/16x16x2/s_dog.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/s_dog.bmp -------------------------------------------------------------------------------- /assets/16x16x2/s_fount.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/s_fount.bmp -------------------------------------------------------------------------------- /assets/16x16x2/s_maid.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/s_maid.bmp -------------------------------------------------------------------------------- /assets/16x16x2/s_mglass.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/s_mglass.bmp -------------------------------------------------------------------------------- /assets/16x16x2/s_pncess.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/s_pncess.bmp -------------------------------------------------------------------------------- /assets/16x16x2/s_robe.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/s_robe.bmp -------------------------------------------------------------------------------- /assets/16x16x2/s_witch.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/s_witch.bmp -------------------------------------------------------------------------------- /assets/16x16x2/s_world.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/s_world.bmp -------------------------------------------------------------------------------- /assets/16x16x2/s_yeti.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/s_yeti.bmp -------------------------------------------------------------------------------- /assets/16x16x2/t_brick.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/t_brick.bmp -------------------------------------------------------------------------------- /assets/16x16x2/t_dirt.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/t_dirt.bmp -------------------------------------------------------------------------------- /assets/16x16x2/t_grass.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/t_grass.bmp -------------------------------------------------------------------------------- /assets/16x16x2/t_pillar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/t_pillar.bmp -------------------------------------------------------------------------------- /assets/16x16x2/t_pool.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/t_pool.bmp -------------------------------------------------------------------------------- /assets/16x16x2/t_sgrass.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/t_sgrass.bmp -------------------------------------------------------------------------------- /assets/16x16x2/t_spillr.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/t_spillr.bmp -------------------------------------------------------------------------------- /assets/16x16x2/t_stree.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/t_stree.bmp -------------------------------------------------------------------------------- /assets/16x16x2/t_tile.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/t_tile.bmp -------------------------------------------------------------------------------- /assets/16x16x2/t_tree.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x2/t_tree.bmp -------------------------------------------------------------------------------- /assets/16x16x4/c_turnip.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/c_turnip.bmp -------------------------------------------------------------------------------- /assets/16x16x4/i_apple.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/i_apple.bmp -------------------------------------------------------------------------------- /assets/16x16x4/i_hammer.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/i_hammer.bmp -------------------------------------------------------------------------------- /assets/16x16x4/i_hoe.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/i_hoe.bmp -------------------------------------------------------------------------------- /assets/16x16x4/i_plot.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/i_plot.bmp -------------------------------------------------------------------------------- /assets/16x16x4/i_seed.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/i_seed.bmp -------------------------------------------------------------------------------- /assets/16x16x4/i_turnip.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/i_turnip.bmp -------------------------------------------------------------------------------- /assets/16x16x4/p_chk_b.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/p_chk_b.bmp -------------------------------------------------------------------------------- /assets/16x16x4/p_chk_bl.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/p_chk_bl.bmp -------------------------------------------------------------------------------- /assets/16x16x4/p_chk_br.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/p_chk_br.bmp -------------------------------------------------------------------------------- /assets/16x16x4/p_chk_c.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/p_chk_c.bmp -------------------------------------------------------------------------------- /assets/16x16x4/p_chk_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/p_chk_l.bmp -------------------------------------------------------------------------------- /assets/16x16x4/p_chk_r.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/p_chk_r.bmp -------------------------------------------------------------------------------- /assets/16x16x4/p_chk_t.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/p_chk_t.bmp -------------------------------------------------------------------------------- /assets/16x16x4/p_chk_tl.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/p_chk_tl.bmp -------------------------------------------------------------------------------- /assets/16x16x4/p_chk_tr.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/p_chk_tr.bmp -------------------------------------------------------------------------------- /assets/16x16x4/s_dog.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/s_dog.bmp -------------------------------------------------------------------------------- /assets/16x16x4/s_fount.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/s_fount.bmp -------------------------------------------------------------------------------- /assets/16x16x4/s_maid.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/s_maid.bmp -------------------------------------------------------------------------------- /assets/16x16x4/s_mglass.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/s_mglass.bmp -------------------------------------------------------------------------------- /assets/16x16x4/s_pncess.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/s_pncess.bmp -------------------------------------------------------------------------------- /assets/16x16x4/s_robe.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/s_robe.bmp -------------------------------------------------------------------------------- /assets/16x16x4/s_witch.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/s_witch.bmp -------------------------------------------------------------------------------- /assets/16x16x4/s_world.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/s_world.bmp -------------------------------------------------------------------------------- /assets/16x16x4/s_yeti.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/s_yeti.bmp -------------------------------------------------------------------------------- /assets/16x16x4/t_brick.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/t_brick.bmp -------------------------------------------------------------------------------- /assets/16x16x4/t_dirt.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/t_dirt.bmp -------------------------------------------------------------------------------- /assets/16x16x4/t_grass.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/t_grass.bmp -------------------------------------------------------------------------------- /assets/16x16x4/t_pillar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/t_pillar.bmp -------------------------------------------------------------------------------- /assets/16x16x4/t_pool.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/t_pool.bmp -------------------------------------------------------------------------------- /assets/16x16x4/t_sgrass.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/t_sgrass.bmp -------------------------------------------------------------------------------- /assets/16x16x4/t_spillr.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/t_spillr.bmp -------------------------------------------------------------------------------- /assets/16x16x4/t_stree.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/t_stree.bmp -------------------------------------------------------------------------------- /assets/16x16x4/t_tile.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/t_tile.bmp -------------------------------------------------------------------------------- /assets/16x16x4/t_tree.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/16x16x4/t_tree.bmp -------------------------------------------------------------------------------- /assets/cga16.gpl: -------------------------------------------------------------------------------- 1 | GIMP Palette 2 | Name: cga16 3 | Columns: 16 4 | # 5 | 0 0 0 Untitled 6 | 0 0 170 Untitled 7 | 0 170 0 Untitled 8 | 0 170 170 Untitled 9 | 170 0 0 Untitled 10 | 170 0 170 Untitled 11 | 170 85 0 Untitled 12 | 170 170 170 Untitled 13 | 85 85 85 Untitled 14 | 85 85 255 Untitled 15 | 85 255 85 Untitled 16 | 85 255 255 Untitled 17 | 255 85 85 Untitled 18 | 255 85 255 Untitled 19 | 255 255 85 Untitled 20 | 255 255 255 Untitled 21 | -------------------------------------------------------------------------------- /assets/cga4.gpl: -------------------------------------------------------------------------------- 1 | GIMP Palette 2 | Name: cga4 3 | Columns: 16 4 | # 5 | 0 0 0 Untitled 6 | 0 255 255 Untitled 7 | 255 0 255 Untitled 8 | 255 255 255 Untitled 9 | -------------------------------------------------------------------------------- /assets/dsekai.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/dsekai.bmp -------------------------------------------------------------------------------- /assets/dsekai.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/dsekai.ico -------------------------------------------------------------------------------- /assets/dsekai.tiled-project: -------------------------------------------------------------------------------- 1 | { 2 | "automappingRulesFile": "", 3 | "commands": [ 4 | ], 5 | "extensionsPath": "extensions", 6 | "folders": [ 7 | ], 8 | "objectTypesFile": "" 9 | } 10 | -------------------------------------------------------------------------------- /assets/m_field/chest.s: -------------------------------------------------------------------------------- 1 | 2 | start 0: 3 | face west 4 | sleep 5 5 | goto 0 6 | 7 | interact 0: 8 | speak 6 ; "Found an editor!" 9 | give 1236 ; Editor 10 | die 0 11 | return stack_i ; No RC as a buffer against dupe if there's a bug. 12 | 13 | -------------------------------------------------------------------------------- /assets/m_field/dog.s: -------------------------------------------------------------------------------- 1 | 2 | start 0: 3 | face follow 4 | push follow 5 | walk 1 6 | sleep 3 7 | goto 0 ; Infinite loop. 8 | 9 | interact 0: 10 | speak 9 ; "Woof! Woof!" 11 | disable 0 12 | return stack 13 | 14 | -------------------------------------------------------------------------------- /assets/m_field/fountain.s: -------------------------------------------------------------------------------- 1 | 2 | start 0: 3 | sleep 5 4 | goto 0 5 | 6 | interact 0: 7 | speak 2 ; "It's a fountain." 8 | disable 0 9 | return stack 10 | 11 | -------------------------------------------------------------------------------- /assets/m_field/maid.s: -------------------------------------------------------------------------------- 1 | 2 | start 0: 3 | sleep 5 4 | goto 0 5 | 6 | interact 0: 7 | speak 7 ; "You'll need this hoe to till soil." 8 | give 1237 ; Hoe 9 | disable 0 10 | return stack_i 11 | 12 | interact 1: 13 | speak 8 ; "Do your best!" 14 | disable 0 15 | return stack 16 | 17 | -------------------------------------------------------------------------------- /assets/m_field/princess.s: -------------------------------------------------------------------------------- 1 | 2 | start 0: 3 | face east 4 | push east 5 | walk 1 6 | sleep 3 7 | push east 8 | walk 1 9 | sleep 9 10 | face west 11 | push west 12 | walk 1 13 | sleep 3 14 | push west 15 | walk 1 16 | sleep 9 17 | goto 0 ; Infinite loop. 18 | 19 | interact 0: 20 | speak 0 ; "Try planting this in soil." 21 | give 1234 ; Turnip seed. 22 | pop 0 ; Items pushed. TODO: GOTO if failed. 23 | disable 0 24 | return stack_i 25 | 26 | interact 1: 27 | speak 8 ; "Do your best!" 28 | disable 0 29 | return stack 30 | 31 | -------------------------------------------------------------------------------- /assets/m_field/tree.s: -------------------------------------------------------------------------------- 1 | 2 | start 0: 3 | face north 4 | sleep 5 5 | goto 0 6 | 7 | interact 0: 8 | speak 3 ; "Found a fruit!" 9 | give 1235 ; Apple 10 | die 0 11 | return stack_i ; No RC as a buffer against dupe if there's a bug. 12 | 13 | -------------------------------------------------------------------------------- /assets/m_field/wforst.s: -------------------------------------------------------------------------------- 1 | 2 | start 0: 3 | face east 4 | sleep 5 5 | goto 0 6 | 7 | interact 0: 8 | push 5 ; x 9 | push 1 ; y 10 | warp 5 ; forst 11 | disable 0 12 | return stack 13 | 14 | -------------------------------------------------------------------------------- /assets/m_field/wtempl.s: -------------------------------------------------------------------------------- 1 | 2 | start 0: 3 | face east 4 | sleep 5 5 | goto 0 6 | 7 | interact 0: 8 | push 14 ; x 9 | push 38 ; y 10 | warp 4 ; templ 11 | disable 0 12 | return stack 13 | 14 | -------------------------------------------------------------------------------- /assets/m_forst/wfield.s: -------------------------------------------------------------------------------- 1 | 2 | start 0: 3 | face 2 4 | sleep 5 5 | goto 0 6 | 7 | interact 0: 8 | push 5 ; x 9 | push 14 ; y 10 | warp 0 ; field 11 | disable 0 12 | return stack 13 | 14 | -------------------------------------------------------------------------------- /assets/m_forst/yeti.s: -------------------------------------------------------------------------------- 1 | 2 | start 0: 3 | push random 4 | face stack_p 5 | walk stack 6 | sleep 3 7 | goto 0 ; Infinite loop. 8 | 9 | interact 0: 10 | speak 1 ; Not yeti... 11 | disable 0 12 | return stack 13 | 14 | -------------------------------------------------------------------------------- /assets/m_templ/wfield.s: -------------------------------------------------------------------------------- 1 | 2 | start 0: 3 | face 2 4 | sleep 5 5 | goto 0 6 | 7 | interact 0: 8 | push 4 ; x 9 | push 1 ; y 10 | warp 0 ; field 11 | disable 0 12 | return stack 13 | 14 | -------------------------------------------------------------------------------- /assets/t2_field.json: -------------------------------------------------------------------------------- 1 | { "columns":0, 2 | "grid": 3 | { 4 | "height":1, 5 | "orientation":"orthogonal", 6 | "width":1 7 | }, 8 | "margin":0, 9 | "name":"field_tiles", 10 | "spacing":0, 11 | "tilecount":5, 12 | "tiledversion":"1.9.2", 13 | "tileheight":16, 14 | "tiles":[ 15 | { 16 | "id":0, 17 | "image":"16x16x4\/t_grass.bmp", 18 | "imageheight":16, 19 | "imagewidth":16, 20 | "properties":[ 21 | { 22 | "name":"ascii", 23 | "type":"string", 24 | "value":"." 25 | }, 26 | { 27 | "name":"flags", 28 | "type":"int", 29 | "value":0 30 | }] 31 | }, 32 | { 33 | "id":1, 34 | "image":"16x16x4\/t_brick.bmp", 35 | "imageheight":16, 36 | "imagewidth":16, 37 | "properties":[ 38 | { 39 | "name":"ascii", 40 | "type":"string", 41 | "value":"x" 42 | }, 43 | { 44 | "name":"flags", 45 | "type":"int", 46 | "value":1 47 | }] 48 | }, 49 | { 50 | "id":2, 51 | "image":"16x16x4\/t_tree.bmp", 52 | "imageheight":16, 53 | "imagewidth":16, 54 | "probability":0.0500000007450581, 55 | "properties":[ 56 | { 57 | "name":"ascii", 58 | "type":"string", 59 | "value":"t" 60 | }, 61 | { 62 | "name":"flags", 63 | "type":"int", 64 | "value":1 65 | }] 66 | }, 67 | { 68 | "id":3, 69 | "image":"16x16x4\/t_pillar.bmp", 70 | "imageheight":16, 71 | "imagewidth":16, 72 | "probability":0.00100000004749745, 73 | "properties":[ 74 | { 75 | "name":"ascii", 76 | "type":"string", 77 | "value":"i" 78 | }, 79 | { 80 | "name":"flags", 81 | "type":"int", 82 | "value":1 83 | }] 84 | }, 85 | { 86 | "id":4, 87 | "image":"16x16x4\/t_pool.bmp", 88 | "imageheight":16, 89 | "imagewidth":16, 90 | "probability":0.00999999977648258, 91 | "properties":[ 92 | { 93 | "name":"ascii", 94 | "type":"string", 95 | "value":"o" 96 | }, 97 | { 98 | "name":"flags", 99 | "type":"int", 100 | "value":1 101 | }] 102 | }], 103 | "tilewidth":16, 104 | "type":"tileset", 105 | "version":"1.9", 106 | "wangsets":[ 107 | { 108 | "colors":[ 109 | { 110 | "color":"#ff0000", 111 | "name":"grass", 112 | "probability":1, 113 | "tile":0 114 | }, 115 | { 116 | "color":"#00ff00", 117 | "name":"brick_wall", 118 | "probability":1, 119 | "tile":1 120 | }, 121 | { 122 | "color":"#0000ff", 123 | "name":"tree", 124 | "probability":1, 125 | "tile":2 126 | }, 127 | { 128 | "color":"#ff7700", 129 | "name":"pillar", 130 | "probability":1, 131 | "tile":-1 132 | }, 133 | { 134 | "color":"#00e9ff", 135 | "name":"pool", 136 | "probability":1, 137 | "tile":-1 138 | }], 139 | "name":"Terrains", 140 | "tile":-1, 141 | "type":"corner", 142 | "wangtiles":[ 143 | { 144 | "tileid":0, 145 | "wangid":[0, 1, 0, 1, 0, 1, 0, 1] 146 | }, 147 | { 148 | "tileid":1, 149 | "wangid":[0, 2, 0, 2, 0, 2, 0, 2] 150 | }, 151 | { 152 | "tileid":2, 153 | "wangid":[0, 3, 0, 3, 0, 3, 0, 3] 154 | }] 155 | }] 156 | } -------------------------------------------------------------------------------- /assets/t2_forst.json: -------------------------------------------------------------------------------- 1 | { "columns":0, 2 | "grid": 3 | { 4 | "height":1, 5 | "orientation":"orthogonal", 6 | "width":1 7 | }, 8 | "margin":0, 9 | "name":"t2_forst", 10 | "spacing":0, 11 | "tilecount":3, 12 | "tiledversion":"1.9.2", 13 | "tileheight":16, 14 | "tiles":[ 15 | { 16 | "id":0, 17 | "image":"16x16x4\/t_sgrass.bmp", 18 | "imageheight":16, 19 | "imagewidth":16, 20 | "properties":[ 21 | { 22 | "name":"ascii", 23 | "type":"string", 24 | "value":"." 25 | }, 26 | { 27 | "name":"flags", 28 | "type":"int", 29 | "value":0 30 | }] 31 | }, 32 | { 33 | "id":1, 34 | "image":"16x16x4\/t_stree.bmp", 35 | "imageheight":16, 36 | "imagewidth":16, 37 | "properties":[ 38 | { 39 | "name":"ascii", 40 | "type":"string", 41 | "value":"t" 42 | }, 43 | { 44 | "name":"flags", 45 | "type":"int", 46 | "value":1 47 | }] 48 | }, 49 | { 50 | "id":2, 51 | "image":"16x16x4\/t_spillr.bmp", 52 | "imageheight":16, 53 | "imagewidth":16, 54 | "properties":[ 55 | { 56 | "name":"ascii", 57 | "type":"string", 58 | "value":"i" 59 | }, 60 | { 61 | "name":"flags", 62 | "type":"int", 63 | "value":1 64 | }] 65 | }], 66 | "tilewidth":16, 67 | "type":"tileset", 68 | "version":"1.9" 69 | } -------------------------------------------------------------------------------- /assets/t2_templ.json: -------------------------------------------------------------------------------- 1 | { "columns":0, 2 | "grid": 3 | { 4 | "height":1, 5 | "orientation":"orthogonal", 6 | "width":1 7 | }, 8 | "margin":0, 9 | "name":"t2_templ", 10 | "spacing":0, 11 | "tilecount":3, 12 | "tiledversion":"1.9.2", 13 | "tileheight":16, 14 | "tiles":[ 15 | { 16 | "id":0, 17 | "image":"16x16x4\/t_tile.bmp", 18 | "imageheight":16, 19 | "imagewidth":16, 20 | "properties":[ 21 | { 22 | "name":"ascii", 23 | "type":"string", 24 | "value":" " 25 | }, 26 | { 27 | "name":"flags", 28 | "type":"int", 29 | "value":0 30 | }] 31 | }, 32 | { 33 | "id":1, 34 | "image":"16x16x4\/t_pillar.bmp", 35 | "imageheight":16, 36 | "imagewidth":16, 37 | "properties":[ 38 | { 39 | "name":"ascii", 40 | "type":"string", 41 | "value":"i" 42 | }, 43 | { 44 | "name":"flags", 45 | "type":"int", 46 | "value":1 47 | }] 48 | }, 49 | { 50 | "id":2, 51 | "image":"16x16x4\/t_brick.bmp", 52 | "imageheight":16, 53 | "imagewidth":16, 54 | "properties":[ 55 | { 56 | "name":"ascii", 57 | "type":"string", 58 | "value":"x" 59 | }, 60 | { 61 | "name":"flags", 62 | "type":"int", 63 | "value":1 64 | }] 65 | }], 66 | "tilewidth":16, 67 | "type":"tileset", 68 | "version":"1.9" 69 | } -------------------------------------------------------------------------------- /assets/t_trans.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/t_trans.bmp -------------------------------------------------------------------------------- /assets/test_16_16_256.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/test_16_16_256.bmp -------------------------------------------------------------------------------- /assets/test_16_16_4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/test_16_16_4.bmp -------------------------------------------------------------------------------- /assets/test_16_16_4.cga: -------------------------------------------------------------------------------- 1 | 00000000: c3bf c3bf c3bf c3bf c3bf c3bf c3bf c3bf ................ 2 | 00000010: c3bf c3bf c3bf c3bf c3bf c3bf c3bf c3bf ................ 3 | 00000020: c3bf c3bf c3bf c3bf c3bf c3bf c3bf c3bf ................ 4 | 00000030: c3bf c3bf c3bf c3bf c3bf c3bf c3bf c3bf ................ 5 | 00000040: c3bf c3bf c3bf c3bf c3bf c3bf c3bf c3bf ................ 6 | 00000050: c3bf c3bf c3bf c3bf c3bf c3bf c3bf c3bf ................ 7 | 00000060: c3bf c3bf c3bf c3bf c3bf c3bf c3bf c3bf ................ 8 | 00000070: c3bf c3bf c3bf c3bf c3bf c3bf c3bf c3bf ................ 9 | 00000080: c3bf c3bf c3bf c3bf c3bf c3bf c3bf c3bf ................ 10 | 00000090: c3bf c3bf c3bf c3bf c3bf c3bf c3bf c3bf ................ 11 | 000000a0: c3bf c3bf c3bf c3bf c3bf c3bf c3bf c3bf ................ 12 | 000000b0: c3bf c3bf c3bf c3bf c3bf c3bf c3bf c3bf ................ 13 | 000000c0: 0a . 14 | -------------------------------------------------------------------------------- /assets/test_32_32_2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/test_32_32_2.bmp -------------------------------------------------------------------------------- /assets/test_32_32_256.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/assets/test_32_32_256.bmp -------------------------------------------------------------------------------- /check/check.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #define main_add_test_proto( suite_name ) \ 5 | Suite* suite_name ## _suite(); 6 | 7 | #define main_add_test( suite_name ) \ 8 | for( i = 0 ; argc > i ; i++ ) { \ 9 | if( \ 10 | 1 < argc && \ 11 | 0 != strncmp( #suite_name, argv[i], strlen( #suite_name ) ) \ 12 | ) { \ 13 | continue; \ 14 | } \ 15 | Suite* s_ ## suite_name = suite_name ## _suite(); \ 16 | SRunner* sr_ ## suite_name = srunner_create( s_ ## suite_name ); \ 17 | if( nofork ) { \ 18 | srunner_set_fork_status( sr_ ## suite_name, CK_NOFORK ); \ 19 | } \ 20 | srunner_run_all( sr_ ## suite_name, verbose ); \ 21 | number_failed += srunner_ntests_failed( sr_ ## suite_name ); \ 22 | srunner_free( sr_ ## suite_name ); \ 23 | break; \ 24 | } 25 | 26 | main_add_test_proto( mobile ) 27 | main_add_test_proto( tilemap ) 28 | main_add_test_proto( graphics ) 29 | main_add_test_proto( data_img ) 30 | main_add_test_proto( data_js ) 31 | main_add_test_proto( item ) 32 | main_add_test_proto( engines ) 33 | main_add_test_proto( window ) 34 | main_add_test_proto( dio ) 35 | main_add_test_proto( memory ) 36 | 37 | int main( int argc, char* argv[] ) { 38 | int number_failed = 0, 39 | i = 0, 40 | nofork = 0, 41 | verbose = CK_VERBOSE; 42 | 43 | main_add_test( mobile ); 44 | main_add_test( tilemap ); 45 | main_add_test( graphics ); 46 | main_add_test( data_img ); 47 | main_add_test( data_js ); 48 | main_add_test( item ); 49 | main_add_test( engines ); 50 | main_add_test( window ); 51 | main_add_test( dio ); 52 | main_add_test( memory ); 53 | 54 | return( number_failed == 0 ) ? 0 : 1; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /check/ckdataim.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "../src/dstypes.h" 5 | #include "../tools/convert.h" 6 | #include "../tools/data/cga.h" 7 | #include "../tools/data/bmp.h" 8 | #include "../tools/data/icns.h" 9 | 10 | #define CKDATA_IM_C 11 | #include "testdata.h" 12 | 13 | void buffer_printf( uint8_t* buffer, int start, int end, int col_break ) { 14 | int column_idx = 1, 15 | i = 0; 16 | 17 | for( i = start ; end > i ; i++ ) { 18 | if( 0 != buffer[i] ) { 19 | printf( "0x%02x, ", buffer[i] ); 20 | } else { 21 | printf( " , " ); 22 | } 23 | 24 | if( 0 == column_idx % col_break ) { 25 | printf( "\n" ); 26 | } 27 | column_idx++; 28 | } 29 | 30 | printf( "\n\n" ); 31 | } 32 | 33 | START_TEST( check_data_cga_read ) { 34 | struct CONVERT_GRID* grid = NULL; 35 | struct CONVERT_OPTIONS options; 36 | 37 | memset( &options, '\0', sizeof( struct CONVERT_OPTIONS ) ); 38 | options.cga_use_header = 1; 39 | 40 | grid = cga_read( 41 | (const uint8_t*)&gc_test_cga_16_16_4, TEST_CGA_16_16_4_SZ, &options ); 42 | 43 | ck_assert_int_eq( gc_test_grid_16_16_4.sz_x, grid->sz_x ); 44 | ck_assert_int_eq( gc_test_grid_16_16_4.sz_y, grid->sz_y ); 45 | ck_assert_int_eq( gc_test_grid_16_16_4.bpp, grid->bpp ); 46 | ck_assert_int_eq( gc_test_grid_16_16_4.data_sz, grid->data_sz ); 47 | ck_assert_int_eq( gc_test_grid_16_16_4_data[_i], grid->data[_i] ); 48 | 49 | /* dio_print_grid( grid ); */ 50 | 51 | free( grid->data ); 52 | free( grid ); 53 | } 54 | END_TEST 55 | 56 | START_TEST( check_data_cga_write ) { 57 | struct CONVERT_OPTIONS options; 58 | uint8_t buffer[TEST_CGA_16_16_4_SZ]; 59 | struct CGA_HEADER* cga_header = (struct CGA_HEADER*)buffer, 60 | * test_header = (struct CGA_HEADER*)gc_test_cga_16_16_4; 61 | 62 | memset( &buffer, '\0', TEST_CGA_16_16_4_SZ ); 63 | memset( &options, '\0', sizeof( struct CONVERT_OPTIONS ) ); 64 | options.cga_use_header = 1; 65 | options.bpp = 2; 66 | 67 | cga_write( 68 | (uint8_t*)&buffer, TEST_CGA_16_16_4_SZ, &gc_test_grid_16_16_4, &options ); 69 | 70 | ck_assert_int_eq( test_header->version, cga_header->version ); 71 | ck_assert_int_eq( test_header->width, cga_header->width ); 72 | ck_assert_int_eq( test_header->height, cga_header->height ); 73 | ck_assert_int_eq( test_header->bpp, cga_header->bpp ); 74 | ck_assert_int_eq( test_header->plane1_offset, cga_header->plane1_offset ); 75 | ck_assert_int_eq( CGA_HEADER_SZ, cga_header->plane1_offset ); 76 | ck_assert_int_eq( gc_test_cga_16_16_4[_i], buffer[_i] ); 77 | } 78 | END_TEST 79 | 80 | START_TEST( check_data_icns_read ) { 81 | struct CONVERT_GRID* grid = NULL; 82 | struct CONVERT_OPTIONS options; 83 | 84 | memset( &options, '\0', sizeof( struct CONVERT_OPTIONS ) ); 85 | 86 | grid = icns_read( 87 | (const uint8_t*)&gc_test_icns_16_16_2, TEST_CGA_16_16_4_SZ, &options ); 88 | 89 | ck_assert_int_eq( gc_test_grid_16_16_4.sz_x, grid->sz_x ); 90 | ck_assert_int_eq( gc_test_grid_16_16_4.sz_y, grid->sz_y ); 91 | ck_assert_int_eq( gc_test_grid_16_16_4.bpp, 2 ); 92 | ck_assert_int_eq( gc_test_grid_16_16_4.data_sz, grid->data_sz ); 93 | ck_assert_int_eq( (gc_test_grid_16_16_4_data[_i] & 0x01), grid->data[_i] ); 94 | 95 | /* dio_print_grid( grid ); */ 96 | 97 | free( grid->data ); 98 | free( grid ); 99 | } 100 | END_TEST 101 | 102 | START_TEST( check_data_icns_write_data ) { 103 | struct CONVERT_OPTIONS options; 104 | uint8_t buffer[TEST_ICNS_16_16_2_SZ]; 105 | struct ICNS_FILE_HEADER* file_header = (struct ICNS_FILE_HEADER*)buffer, 106 | * test_header = (struct ICNS_FILE_HEADER*)gc_test_icns_16_16_2; 107 | 108 | memset( &buffer, '\0', TEST_ICNS_16_16_2_SZ ); 109 | memset( &options, '\0', sizeof( struct CONVERT_OPTIONS ) ); 110 | options.bpp = 1; 111 | options.reverse = 0; 112 | 113 | icns_write( 114 | (uint8_t*)&buffer, TEST_ICNS_16_16_2_SZ, 115 | &gc_test_grid_16_16_4, &options ); 116 | 117 | ck_assert_int_eq( 118 | dio_reverse_endian_32( test_header->file_sz ), 119 | dio_reverse_endian_32( file_header->file_sz ) ); 120 | ck_assert_int_eq( 121 | gc_test_icns_16_16_2[ICNS_FILE_HEADER_SZ + ICNS_DATA_HEADER_SZ + _i], 122 | buffer[ICNS_FILE_HEADER_SZ + ICNS_DATA_HEADER_SZ +_i] ); 123 | } 124 | END_TEST 125 | 126 | START_TEST( check_data_bmp_write_header ) { 127 | struct CONVERT_OPTIONS options; 128 | uint8_t buffer[TEST_BMP_16_16_16_SZ]; 129 | struct BITMAP_FILE_HEADER* file_header = (struct BITMAP_FILE_HEADER*)buffer, 130 | * test_f_header = (struct BITMAP_FILE_HEADER*)gc_test_bmp_16_16_16; 131 | struct BITMAP_DATA_HEADER* data_header = (struct BITMAP_DATA_HEADER*)buffer, 132 | * test_d_header = (struct BITMAP_DATA_HEADER*)&(gc_test_bmp_16_16_16[ 133 | sizeof( struct BITMAP_FILE_HEADER )]); 134 | 135 | memset( &buffer, '\0', TEST_BMP_16_16_16_SZ ); 136 | memset( &options, '\0', sizeof( struct CONVERT_OPTIONS ) ); 137 | options.bpp = 4; 138 | 139 | bmp_write( 140 | (uint8_t*)&buffer, TEST_BMP_16_16_16_SZ, 141 | &gc_test_grid_16_16_4, &options ); 142 | 143 | } 144 | END_TEST 145 | 146 | START_TEST( check_data_bmp_write_data ) { 147 | struct CONVERT_OPTIONS options; 148 | uint8_t buffer[TEST_BMP_16_16_16_SZ]; 149 | struct BITMAP_FILE_HEADER* file_header = (struct BITMAP_FILE_HEADER*)buffer, 150 | * test_f_header = (struct BITMAP_FILE_HEADER*)gc_test_bmp_16_16_16; 151 | struct BITMAP_DATA_HEADER* data_header = (struct BITMAP_DATA_HEADER*)buffer, 152 | * test_d_header = (struct BITMAP_DATA_HEADER*)&(gc_test_bmp_16_16_16[ 153 | sizeof( struct BITMAP_FILE_HEADER )]); 154 | 155 | memset( &buffer, '\0', TEST_BMP_16_16_16_SZ ); 156 | memset( &options, '\0', sizeof( struct CONVERT_OPTIONS ) ); 157 | options.bpp = 4; 158 | 159 | bmp_write( 160 | (uint8_t*)&buffer, TEST_BMP_16_16_16_SZ, 161 | &gc_test_grid_16_16_4, &options ); 162 | 163 | /* ck_assert_int_eq( test_f_header->file_sz, file_header->file_sz ); */ 164 | ck_assert_int_eq( 165 | gc_test_bmp_16_16_16[ 166 | sizeof( struct BITMAP_FILE_HEADER ) + 167 | sizeof( struct BITMAP_DATA_HEADER ) + _i], 168 | buffer[ 169 | sizeof( struct BITMAP_FILE_HEADER ) + 170 | sizeof( struct BITMAP_DATA_HEADER ) + _i] ); 171 | } 172 | END_TEST 173 | 174 | Suite* data_img_suite( void ) { 175 | Suite* s; 176 | TCase* tc_bmp, 177 | *tc_cga, 178 | *tc_icns; 179 | 180 | s = suite_create( "data_img" ); 181 | 182 | /* CGA test case */ 183 | tc_cga = tcase_create( "CGA" ); 184 | 185 | tcase_add_loop_test( tc_cga, check_data_cga_read, 0, 256 ); 186 | tcase_add_loop_test( tc_cga, check_data_cga_write, 0, TEST_CGA_16_16_4_SZ ); 187 | 188 | suite_add_tcase( s, tc_cga ); 189 | 190 | /* ICNS test case */ 191 | tc_icns = tcase_create( "ICNS" ); 192 | 193 | tcase_add_loop_test( tc_icns, check_data_icns_read, 0, 256 ); 194 | tcase_add_loop_test( 195 | tc_icns, check_data_icns_write_data, 0, TEST_ICNS_16_16_2_DATA_SZ ); 196 | 197 | suite_add_tcase( s, tc_icns ); 198 | 199 | /* BMP test case */ 200 | tc_bmp = tcase_create( "BMP" ); 201 | 202 | tcase_add_test( tc_bmp, check_data_bmp_write_header ); 203 | tcase_add_loop_test( 204 | tc_bmp, check_data_bmp_write_data, 205 | sizeof( struct BITMAP_FILE_HEADER ) + 206 | sizeof( struct BITMAP_DATA_HEADER ), 207 | sizeof( struct BITMAP_FILE_HEADER ) + 208 | sizeof( struct BITMAP_DATA_HEADER ) + ((16 * 16) / 2) ); 209 | 210 | suite_add_tcase( s, tc_bmp ); 211 | 212 | return s; 213 | } 214 | 215 | -------------------------------------------------------------------------------- /check/ckdatajs.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "../src/dstypes.h" 5 | 6 | #define CKDATA_JS_C 7 | #include "testdata.h" 8 | 9 | #define JSON_TEST_TOKENS_MAX 50 10 | 11 | static int g_tokens_parsed = 0; 12 | static jsmn_parser g_parser; 13 | static jsmntok_t g_tokens[JSON_TEST_TOKENS_MAX]; 14 | 15 | static void data_js_setup() { 16 | memset( &g_parser, '\0', sizeof( jsmn_parser ) ); 17 | memset( &g_tokens, '\0', JSON_TEST_TOKENS_MAX * sizeof( jsmntok_t ) ); 18 | jsmn_init( &g_parser ); 19 | g_tokens_parsed = jsmn_parse( 20 | &g_parser, gc_test_json, strlen( gc_test_json ), 21 | g_tokens, JSON_TEST_TOKENS_MAX ); 22 | ck_assert_int_gt( g_tokens_parsed, 0 ); 23 | } 24 | 25 | static void data_js_teardown() { 26 | 27 | } 28 | 29 | START_TEST( check_data_json_parse_obj_first ) { 30 | int id = 0; 31 | 32 | id = json_token_id_from_path( 33 | "/objects/0/name", 15, &(g_tokens[0]), g_tokens_parsed, gc_test_json ); 34 | 35 | ck_assert_int_eq( id, 7 ); 36 | } 37 | END_TEST 38 | 39 | START_TEST( check_data_json_parse_multi_obj ) { 40 | int id = 0; 41 | 42 | id = json_token_id_from_path( 43 | "/objects_sz", 11, &(g_tokens[0]), g_tokens_parsed, gc_test_json ); 44 | 45 | ck_assert_int_eq( id, 2 ); 46 | } 47 | END_TEST 48 | 49 | START_TEST( check_data_json_parse_list ) { 50 | int id = 0, 51 | val = 0; 52 | 53 | id = json_token_id_from_path( 54 | "/items/3", 8, &(g_tokens[0]), g_tokens_parsed, gc_test_json ); 55 | 56 | ck_assert_int_eq( id, 37 ); 57 | 58 | val = dio_atoi( &(gc_test_json[g_tokens[id].start]), 10 ); 59 | ck_assert_int_eq( val, 44 ); 60 | } 61 | END_TEST 62 | 63 | START_TEST( check_data_json_parse_through_combi ) { 64 | int id = 0; 65 | 66 | id = json_token_id_from_path( 67 | "/objects/0/extra/2", 18, &(g_tokens[0]), g_tokens_parsed, gc_test_json ); 68 | 69 | ck_assert_int_eq( id, 16 ); 70 | ck_assert_int_eq( gc_test_json[g_tokens[id].start], 'z' ); 71 | } 72 | END_TEST 73 | 74 | START_TEST( check_data_json_parse_tileset_path ) { 75 | int id = 0; 76 | 77 | id = json_token_id_from_path( 78 | "/tilesets/0/source", 18, &(g_tokens[0]), g_tokens_parsed, gc_test_json ); 79 | 80 | ck_assert_int_eq( id, 46 ); 81 | ck_assert_int_eq( gc_test_json[g_tokens[id].start], 'f' ); 82 | } 83 | END_TEST 84 | 85 | START_TEST( check_data_json_parse_attribs ) { 86 | int id = 0; 87 | 88 | id = json_token_id_from_path( 89 | "/objects/[name=fii]/extra/0", 27, 90 | &(g_tokens[0]), g_tokens_parsed, gc_test_json ); 91 | 92 | ck_assert_int_eq( id, 26 ); 93 | ck_assert_int_eq( gc_test_json[g_tokens[id].start], 'h' ); 94 | ck_assert_int_eq( gc_test_json[g_tokens[id].start + 1], 'i' ); 95 | ck_assert_int_eq( gc_test_json[g_tokens[id].start + 2], 'z' ); 96 | ck_assert_int_eq( gc_test_json[g_tokens[id].start + 3], 'z' ); 97 | } 98 | END_TEST 99 | 100 | START_TEST( check_data_json_oob ) { 101 | int id = 0; 102 | 103 | id = json_token_id_from_path( 104 | "/objects/2/extra/0", 27, 105 | &(g_tokens[0]), g_tokens_parsed, gc_test_json ); 106 | 107 | ck_assert_int_eq( id, -1 ); 108 | 109 | id = json_token_id_from_path( 110 | "/objects/[name=hurl]/extra/0", 27, 111 | &(g_tokens[0]), g_tokens_parsed, gc_test_json ); 112 | 113 | ck_assert_int_eq( id, -1 ); 114 | } 115 | END_TEST 116 | 117 | Suite* data_js_suite( void ) { 118 | Suite* s; 119 | TCase* tc_core; 120 | 121 | s = suite_create( "data_js" ); 122 | 123 | /* Core test case */ 124 | tc_core = tcase_create( "Core" ); 125 | tcase_add_checked_fixture( tc_core, data_js_setup, data_js_teardown ); 126 | 127 | tcase_add_test( tc_core, check_data_json_parse_obj_first ); 128 | tcase_add_test( tc_core, check_data_json_parse_multi_obj ); 129 | tcase_add_test( tc_core, check_data_json_parse_list ); 130 | tcase_add_test( tc_core, check_data_json_parse_through_combi ); 131 | tcase_add_test( tc_core, check_data_json_parse_tileset_path ); 132 | tcase_add_test( tc_core, check_data_json_parse_attribs ); 133 | tcase_add_test( tc_core, check_data_json_oob ); 134 | 135 | suite_add_tcase( s, tc_core ); 136 | 137 | return s; 138 | } 139 | 140 | -------------------------------------------------------------------------------- /check/ckgfx.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | Suite* graphics_suite( void ) { 5 | Suite* s; 6 | TCase* tc_core; 7 | 8 | s = suite_create( "graphics" ); 9 | 10 | /* Core test case */ 11 | tc_core = tcase_create( "Core" ); 12 | 13 | suite_add_tcase( s, tc_core ); 14 | 15 | return s; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /check/ckitem.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | Suite* item_suite( void ) { 5 | Suite* s; 6 | TCase* tc_core; 7 | 8 | s = suite_create( "item" ); 9 | 10 | /* Core test case */ 11 | tc_core = tcase_create( "Core" ); 12 | 13 | suite_add_tcase( s, tc_core ); 14 | 15 | return s; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /check/ckmemory.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "../src/dstypes.h" 5 | 6 | START_TEST( check_memory_alloc ) { 7 | struct FAKE_MEMORY_HANDLE* handle = NULL; 8 | 9 | handle = memory_alloc( 1, 1024 ); 10 | 11 | ck_assert_ptr_ne( handle, NULL ); 12 | 13 | memory_free( handle ); 14 | } 15 | END_TEST 16 | 17 | START_TEST( check_memory_write ) { 18 | struct FAKE_MEMORY_HANDLE* handle = NULL; 19 | char* ptr = NULL; 20 | const char test_str[] = "The quick brown fox jumped over the lazy dog."; 21 | 22 | handle = memory_alloc( 1, 1024 ); 23 | 24 | ptr = memory_lock( handle ); 25 | memcpy( ptr, test_str, strlen( test_str ) + 1 ); 26 | memory_unlock( handle ); 27 | 28 | ck_assert_str_eq( test_str, handle->ptr ); 29 | 30 | } 31 | END_TEST 32 | 33 | START_TEST( check_memory_lock ) { 34 | struct FAKE_MEMORY_HANDLE* handle1 = NULL, 35 | * handle2 = NULL; 36 | uint8_t* buffer1 = NULL, 37 | * buffer2 = NULL; 38 | 39 | handle1 = memory_alloc( 1, 10 ); 40 | handle2 = memory_alloc( 1, 20 ); 41 | 42 | ck_assert_int_eq( 0, handle1->locks ); 43 | ck_assert_int_eq( 0, handle2->locks ); 44 | ck_assert_int_eq( 10, memory_sz( handle1 ) ); 45 | ck_assert_int_eq( 20, memory_sz( handle2 ) ); 46 | 47 | buffer1 = memory_lock( handle1 ); 48 | buffer2 = memory_lock( handle2 ); 49 | 50 | ck_assert_int_eq( 1, handle1->locks ); 51 | ck_assert_int_eq( 1, handle2->locks ); 52 | ck_assert_int_eq( 10, memory_sz( handle1 ) ); 53 | ck_assert_int_eq( 20, memory_sz( handle2 ) ); 54 | ck_assert_ptr_eq( buffer1, handle1->ptr ); 55 | ck_assert_ptr_eq( buffer2, handle2->ptr ); 56 | 57 | buffer1 = memory_unlock( handle1 ); 58 | buffer2 = memory_unlock( handle2 ); 59 | 60 | ck_assert_int_eq( 10, memory_sz( handle1 ) ); 61 | ck_assert_int_eq( 20, memory_sz( handle2 ) ); 62 | 63 | ck_assert_int_eq( 0, handle1->locks ); 64 | ck_assert_int_eq( 0, handle2->locks ); 65 | 66 | memory_free( handle1 ); 67 | memory_free( handle2 ); 68 | 69 | } 70 | END_TEST 71 | 72 | Suite* memory_suite( void ) { 73 | Suite* s; 74 | TCase* tc_core; 75 | 76 | s = suite_create( "memory" ); 77 | 78 | tc_core = tcase_create( "Core" ); 79 | 80 | tcase_add_test( tc_core, check_memory_alloc ); 81 | tcase_add_test( tc_core, check_memory_write ); 82 | tcase_add_test( tc_core, check_memory_lock ); 83 | 84 | suite_add_tcase( s, tc_core ); 85 | 86 | return s; 87 | } 88 | 89 | -------------------------------------------------------------------------------- /check/ckmobile.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | Suite* mobile_suite( void ) { 5 | Suite* s; 6 | TCase* tc_core; 7 | 8 | s = suite_create( "mobile" ); 9 | 10 | /* Core test case */ 11 | tc_core = tcase_create( "Core" ); 12 | 13 | suite_add_tcase( s, tc_core ); 14 | 15 | return s; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /check/cktmap.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | Suite* tilemap_suite( void ) { 5 | Suite* s; 6 | TCase* tc_core; 7 | 8 | s = suite_create( "tilemap" ); 9 | 10 | /* Core test case */ 11 | tc_core = tcase_create( "Core" ); 12 | 13 | suite_add_tcase( s, tc_core ); 14 | 15 | return s; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /check/cktopdwn.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | Suite* engines_suite( void ) { 5 | Suite* s; 6 | TCase* tc_core; 7 | 8 | s = suite_create( "engines" ); 9 | 10 | /* Core test case */ 11 | tc_core = tcase_create( "Core" ); 12 | 13 | suite_add_tcase( s, tc_core ); 14 | 15 | return s; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /check/ckwindow.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | Suite* window_suite( void ) { 5 | Suite* s; 6 | TCase* tc_core; 7 | 8 | s = suite_create( "window" ); 9 | 10 | /* Core test case */ 11 | tc_core = tcase_create( "Core" ); 12 | 13 | suite_add_tcase( s, tc_core ); 14 | 15 | return s; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /doxstyle.css: -------------------------------------------------------------------------------- 1 | 2 | body { 3 | background: black; 4 | color: white; 5 | } 6 | 7 | .header { 8 | background: black !important; 9 | } 10 | 11 | a, a:visited { 12 | color: cyan !important; 13 | } 14 | 15 | h2 { 16 | color: magenta !important; 17 | } 18 | 19 | .sm-dox, .sm-dox ul, .sm-dox ul a, .navpath ul { 20 | background: black !important; 21 | border: white 1px solid; 22 | } 23 | 24 | tr.even { 25 | background: transparent !important; 26 | } 27 | 28 | tr { 29 | } 30 | 31 | .doxtable th { 32 | background: cyan !important; 33 | color: black !important; 34 | } 35 | 36 | .memberdecls td { 37 | background: transparent !important; 38 | } 39 | 40 | .mdescRight, .memproto, .memdoc, .memtitle { 41 | background: black !important; 42 | } 43 | 44 | .memname { 45 | color: white !important; 46 | } 47 | 48 | .paramname { 49 | color: magenta !important; 50 | } 51 | 52 | .mdescRight { 53 | color: white !important; 54 | } 55 | 56 | .doxtable td { 57 | background: transparent !important; 58 | border: 1px solid cyan !important; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /dsekai.rc: -------------------------------------------------------------------------------- 1 | //Microsoft eMbedded Visual C++ generated resource script. 2 | // 3 | 4 | #include "resids.h" 5 | 6 | #include "gen\win16\resext.h" 7 | 8 | #define APSTUDIO_READONLY_SYMBOLS 9 | ///////////////////////////////////////////////////////////////////////////// 10 | // 11 | // Generated from the TEXTINCLUDE 2 resource. 12 | // 13 | #include "src\winceres.h" 14 | ///////////////////////////////////////////////////////////////////////////// 15 | #undef APSTUDIO_READONLY_SYMBOLS 16 | 17 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 18 | #ifdef _WIN32 19 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 20 | #pragma code_page(1252) 21 | #endif 22 | 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // Icon 26 | // 27 | 28 | // Icon with lowest ID value placed first to ensure application icon 29 | // remains consistent on all systems. 30 | IDI_DSEKAI ICON DISCARDABLE "assets/dsekai.ICO" 31 | 32 | #ifdef APSTUDIO_INVOKED 33 | ///////////////////////////////////////////////////////////////////////////// 34 | // 35 | // TEXTINCLUDE 36 | // 37 | 38 | 1 TEXTINCLUDE DISCARDABLE 39 | BEGIN 40 | "resource.h\0" 41 | END 42 | 43 | 2 TEXTINCLUDE DISCARDABLE 44 | BEGIN 45 | "#include ""src\\winceres.h""\r\n" 46 | "\0" 47 | END 48 | 49 | 3 TEXTINCLUDE DISCARDABLE 50 | BEGIN 51 | "\r\n" 52 | "\0" 53 | END 54 | 55 | #endif // APSTUDIO_INVOKED 56 | 57 | ///////////////////////////////////////////////////////////////////////////// 58 | // 59 | // Menu 60 | // 61 | 62 | IDM_MENU MENU DISCARDABLE 63 | BEGIN 64 | POPUP "&File" 65 | BEGIN 66 | MENUITEM "E&xit", IDM_FILE_EXIT 67 | END 68 | POPUP "&Help" 69 | BEGIN 70 | MENUITEM "&About", IDM_HELP_ABOUT 71 | END 72 | END 73 | 74 | 75 | ///////////////////////////////////////////////////////////////////////////// 76 | // 77 | // Dialog 78 | // 79 | IDD_ABOUTBOX DIALOGEX 0, 0, 125, 55 80 | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU 81 | EXSTYLE WS_EX_CAPTIONOKBTN 82 | CAPTION "About dsekai" 83 | FONT 8, "System" 84 | BEGIN 85 | ICON IDI_DSEKAI,IDC_STATIC,11,17,20,20 86 | LTEXT "dsekai Version 1.0",IDC_STATIC,38,10,70,8, SS_NOPREFIX 87 | LTEXT "Copyright (C) 2021",IDC_STATIC,38,25,70,8 88 | END 89 | 90 | ///////////////////////////////////////////////////////////////////////////// 91 | // 92 | // DESIGNINFO 93 | // 94 | 95 | #ifdef APSTUDIO_INVOKED 96 | GUIDELINES DESIGNINFO DISCARDABLE 97 | BEGIN 98 | IDD_ABOUTBOX, DIALOG 99 | BEGIN 100 | LEFTMARGIN, 7 101 | RIGHTMARGIN, 118 102 | TOPMARGIN, 7 103 | BOTTOMMARGIN, 48 104 | END 105 | END 106 | #endif // APSTUDIO_INVOKED 107 | 108 | 109 | ///////////////////////////////////////////////////////////////////////////// 110 | // 111 | // Accelerator 112 | // 113 | 114 | IDC_DSEKAI ACCELERATORS DISCARDABLE 115 | BEGIN 116 | "/", IDM_HELP_ABOUT, ASCII, ALT, NOINVERT 117 | VK_F4, IDM_FILE_EXIT, VIRTKEY, ALT, NOINVERT 118 | END 119 | 120 | 121 | ///////////////////////////////////////////////////////////////////////////// 122 | // 123 | // String Table 124 | // 125 | 126 | STRINGTABLE DISCARDABLE 127 | BEGIN 128 | IDC_DSEKAI "DSEKAI" 129 | IDS_APP_TITLE "dsekai" 130 | END 131 | 132 | #endif 133 | ///////////////////////////////////////////////////////////////////////////// 134 | 135 | 136 | 137 | #ifndef APSTUDIO_INVOKED 138 | ///////////////////////////////////////////////////////////////////////////// 139 | // 140 | // Generated from the TEXTINCLUDE 3 resource. 141 | // 142 | 143 | 144 | ///////////////////////////////////////////////////////////////////////////// 145 | #endif // not APSTUDIO_INVOKED 146 | 147 | sprite_looking_glass BITMAP "assets/sprite_looking_glass.bmp" 148 | sprite_princess BITMAP "assets/sprite_princess.bmp" 149 | sprite_robe BITMAP "assets/sprite_robe.bmp" 150 | tile_field_brick_wall BITMAP "assets/tile_field_brick_wall.bmp" 151 | tile_field_grass BITMAP "assets/tile_field_grass.bmp" 152 | tile_field_tree BITMAP "assets/tile_field_tree.bmp" 153 | pattern_cm_checker_bl BITMAP "assets/pattern_cm_checker_bl.bmp" 154 | pattern_cm_checker_br BITMAP "assets/pattern_cm_checker_br.bmp" 155 | pattern_cm_checker_l BITMAP "assets/pattern_cm_checker_l.bmp" 156 | pattern_cm_checker_b BITMAP "assets/pattern_cm_checker_b.bmp" 157 | pattern_cm_checker_r BITMAP "assets/pattern_cm_checker_r.bmp" 158 | pattern_cm_checker_tl BITMAP "assets/pattern_cm_checker_tl.bmp" 159 | pattern_cm_checker_t BITMAP "assets/pattern_cm_checker_t.bmp" 160 | pattern_cm_checker_tr BITMAP "assets/pattern_cm_checker_tr.bmp" 161 | pattern_cm_checker_c BITMAP "assets/pattern_cm_checker_c.bmp" 162 | 163 | -------------------------------------------------------------------------------- /dsekai.vcw: -------------------------------------------------------------------------------- 1 | Microsoft eMbedded Visual Tools Workspace File, Format Version 3.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "dsekai"=".\dsekai.vcp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /pkgs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PLATFORMS="dos win386 win16 win32 sdl xlib curses wasm mac palm nds" 4 | BUILD=DEBUG 5 | DEBUG_THRESHOLD=1 6 | ACTION=BUILD 7 | PKG_ISO=0 8 | GIT_HASH="`git rev-parse --short HEAD`" 9 | 10 | build_sdl() { 11 | make -f Makefile.sdl SDL_VER=2 DTHRESHOLD=$DEBUG_THRESHOLD DEPTH=CGA BUILD=$BUILD pkg_sdl || exit 12 | make -f Makefile.sdl SDL_VER=2 DTHRESHOLD=$DEBUG_THRESHOLD DEPTH=VGA RESOURCE=FILE FMT_ASN=TRUE BUILD=$BUILD pkg_sdl || exit 13 | } 14 | 15 | build_dos() { 16 | make -f Makefile.dos DTHRESHOLD=$DEBUG_THRESHOLD RESOURCE=FILE FMT_ASN=TRUE BUILD=$BUILD ARCFMT=ZIP pkg_dos || exit 17 | make -f Makefile.dos DTHRESHOLD=$DEBUG_THRESHOLD DEPTH=VGA RESOURCE=FILE FMT_ASN=TRUE BUILD=$BUILD ARCFMT=ZIP pkg_dos || exit 18 | } 19 | 20 | build_win386() { 21 | make -f Makefile.win386 DTHRESHOLD=$DEBUG_THRESHOLD DEPTH=VGA RESOURCE=FILE FMT_ASN=TRUE BUILD=$BUILD ARCFMT=ZIP pkg_win386 || exit 22 | } 23 | 24 | build_win16() { 25 | make -f Makefile.win16 DTHRESHOLD=$DEBUG_THRESHOLD DEPTH=VGA RESOURCE=FILE FMT_ASN=TRUE BUILD=$BUILD ARCFMT=ZIP pkg_win16 || exit 26 | } 27 | 28 | build_win32() { 29 | make -f Makefile.win32 DTHRESHOLD=$DEBUG_THRESHOLD DEPTH=VGA RESOURCE=FILE FMT_ASN=TRUE BUILD=$BUILD ARCFMT=ZIP pkg_win32 || exit 30 | } 31 | 32 | build_xlib() { 33 | make -f Makefile.xlib DTHRESHOLD=$DEBUG_THRESHOLD RESOURCE=FILE FMT_ASN=TRUE BUILD=$BUILD pkg_xlib || exit 34 | } 35 | 36 | build_curses() { 37 | make -f Makefile.curses DTHRESHOLD=$DEBUG_THRESHOLD RESOURCE=FILE FMT_ASN=TRUE BUILD=$BUILD pkg_curses || exit 38 | } 39 | 40 | build_mac6() { 41 | make -f Makefile.mac6 DTHRESHOLD=$DEBUG_THRESHOLD DEPTH=MONO FMT_ASN=TRUE RESOURCE=FILE BUILD=$BUILD pkg_mac6 || exit 42 | } 43 | 44 | build_nds() { 45 | make -f Makefile.nds DTHRESHOLD=$DEBUG_THRESHOLD DEPTH=VGA FMT_ASN=TRUE BUILD=$BUILD pkg_nds || exit 46 | } 47 | 48 | build_wasm() { 49 | make -f Makefile.wasm DTHRESHOLD=$DEBUG_THRESHOLD DEPTH=VGA BUILD=$BUILD ARCFMT=ZIP pkg_wasm || exit 50 | make -f Makefile.wasm DTHRESHOLD=$DEBUG_THRESHOLD BUILD=$BUILD ARCFMT=ZIP pkg_wasm || exit 51 | } 52 | 53 | do_run() { 54 | if [ "$PLAT_SPEC" = "sdl" ]; then 55 | if [ ! -d pkgbuild/dsekai-sdl-*-vga-*-asn ]; then 56 | build_sdl 57 | fi 58 | cd pkgbuild/dsekai-sdl-*-vga-*-asn && ./dsekai 59 | elif [ "$PLAT_SPEC" = "dos" ]; then 60 | if [ ! -d pkgbuild/dsekai-dos-*-cga-*-asn ]; then 61 | build_dos 62 | fi 63 | # This is complicated by FreeDOS for /D not finding wildcards... 64 | # Requires a symlink "dsekai" to this directory in dosemu root. 65 | if [ ! -L "dsdos" ]; then 66 | ln -s pkgbuild/dsekai-dos-*-cga-*-asn/ dsdos 67 | fi 68 | echo "cd \\dsekai\\dsdos" > dsdos/dsdos.bat 69 | echo "dsekai.exe" >> dsdos/dsdos.bat 70 | dosemu -2 "dsekai\\dsdos\\dsdos.bat" 71 | elif [ "$PLAT_SPEC" = "win32" ]; then 72 | if [ ! -d pkgbuild/dsekai-win32-*-vga-*-asn ]; then 73 | build_win32 74 | fi 75 | cd pkgbuild/dsekai-win32-*-vga-*-asn && wine ./dsekai32.exe 76 | elif [ "$PLAT_SPEC" = "win16" ]; then 77 | if [ ! -d pkgbuild/dsekai-win16-*-vga-*-asn ]; then 78 | build_win16 79 | fi 80 | cd pkgbuild/dsekai-win16-*-vga-*-asn && wine ./dsekai16.exe 81 | elif [ "$PLAT_SPEC" = "win386" ]; then 82 | if [ ! -d pkgbuild/dsekai-win386-*-vga-*-asn ]; then 83 | build_win386 84 | fi 85 | cd pkgbuild/dsekai-win386-*-vga-*-asn && wine ./dsekaile.exe 86 | elif [ "$PLAT_SPEC" = "xlib" ]; then 87 | if [ ! -d pkgbuild/dsekai-xlib-*-cga-*-asn ]; then 88 | build_xlib 89 | fi 90 | cd pkgbuild/dsekai-xlib-*-cga-*-asn && ./dsekaix 91 | elif [ "$PLAT_SPEC" = "curses" ]; then 92 | if [ ! -d pkgbuild/dsekai-curses-* ]; then 93 | build_curses 94 | fi 95 | cd pkgbuild/dsekai-curses-* && ./dsekait 96 | elif [ "$PLAT_SPEC" = "nds" ]; then 97 | if [ ! -d pkgbuild/dsekai-nds-* ]; then 98 | build_nds 99 | fi 100 | desmume pkgbuild/dsekai-nds-*/dsekai.nds 101 | elif [ "$PLAT_SPEC" = "wasm" ]; then 102 | cd pkgbuild/dsekai-wasm-*-vga-* && python -m http.server 103 | fi 104 | } 105 | 106 | do_build() { 107 | if [ "$PLAT_SPEC" = "sdl" ] || [ -z "$PLAT_SPEC" ]; then 108 | build_sdl 109 | fi 110 | 111 | if [ "$PLAT_SPEC" = "palm" ] || [ -z "$PLAT_SPEC" ]; then 112 | make -f Makefile.palm DTHRESHOLD=$DEBUG_THRESHOLD BUILD=$BUILD DEPTH=MONO pkg_palm || exit 113 | fi 114 | 115 | if [ "$PLAT_SPEC" = "xlib" ] || [ -z "$PLAT_SPEC" ]; then 116 | build_xlib 117 | fi 118 | 119 | if [ "$PLAT_SPEC" = "curses" ] || [ -z "$PLAT_SPEC" ]; then 120 | build_curses 121 | fi 122 | 123 | if [ "$PLAT_SPEC" = "dos" ] || [ -z "$PLAT_SPEC" ]; then 124 | build_dos 125 | fi 126 | 127 | if [ "$PLAT_SPEC" = "win386" ] || [ -z "$PLAT_SPEC" ]; then 128 | build_win386 129 | fi 130 | 131 | if [ "$PLAT_SPEC" = "win16" ] || [ -z "$PLAT_SPEC" ]; then 132 | build_win16 133 | fi 134 | 135 | if [ "$PLAT_SPEC" = "win32" ] || [ -z "$PLAT_SPEC" ]; then 136 | build_win32 137 | fi 138 | 139 | if [ "$PLAT_SPEC" = "wasm" ] || [ -z "$PLAT_SPEC" ]; then 140 | build_wasm 141 | fi 142 | 143 | if [ "$PLAT_SPEC" = "mac" ] || [ -z "$PLAT_SPEC" ]; then 144 | build_mac6 145 | fi 146 | 147 | if [ "$PLAT_SPEC" = "nds" ] || [ -z "$PLAT_SPEC" ]; then 148 | build_nds 149 | fi 150 | 151 | echo "All packages built OK!" 152 | } 153 | 154 | while [ "$1" ]; do 155 | case "$1" in 156 | "-h"|"--help") 157 | echo "usage: $0 [-r] [prof|run] [platspec]" 158 | echo 159 | echo "-r - Build RELEASE-mode binaries." 160 | echo "run - Command: Run build binary for platspec." 161 | echo "prof - Command: Build profile data from run." 162 | echo "platspec - Platform specifier." 163 | echo 164 | echo "Current platforms: $PLATFORMS" 165 | echo 166 | exit 1 167 | ;; 168 | 169 | "-r"|"--release") 170 | BUILD=RELEASE 171 | DEBUG_THRESHOLD= 172 | ;; 173 | 174 | "-d"|"--debug-threshold") 175 | shift 176 | DEBUG_THRESHOLD=$1 177 | ;; 178 | 179 | "-i"|"--iso") 180 | PKG_ISO=1 181 | ;; 182 | 183 | *) 184 | if [ "prof" = "$1" ]; then 185 | ACTION=PROFILE 186 | elif [ "run" = "$1" ]; then 187 | ACTION=RUN 188 | elif [[ "$PLATFORMS" == *"$1"* ]]; then 189 | PLAT_SPEC="$1" 190 | fi 191 | ;; 192 | esac 193 | shift 194 | done 195 | 196 | if [ -z "$PLAT_SPEC" ]; then 197 | echo "No platform specified for ${ACTION}..." 198 | else 199 | echo "${ACTION}ing for $PLAT_SPEC..." 200 | fi 201 | 202 | if [ "$ACTION" = "PROFILE" ]; then 203 | 204 | if [ "$PLAT_SPEC" = "sdl" ]; then 205 | echo "Profiling to: prof_output_sdl" 206 | gprof pkgbuild/dsekai-sdl-*-vga-*-asn/{dsekai,gmon.out} > prof_output_sdl 207 | else 208 | echo "Unknown profile target!" 209 | fi 210 | 211 | exit 212 | 213 | elif [ "$ACTION" = "BUILD" ]; then 214 | do_build 215 | 216 | if [ $PKG_ISO -eq 1 ]; then 217 | mkisofs -r -J -V "DSEKAI_$GIT_HASH" -o dsekai.iso packages 218 | fi 219 | 220 | elif [ "$ACTION" = "RUN" ]; then 221 | do_run 222 | 223 | fi 224 | 225 | 226 | -------------------------------------------------------------------------------- /resids.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft eMbedded Visual C++ generated include file. 3 | // Used by DSEKAI.RC 4 | // 5 | #define IDS_APP_TITLE 1 6 | #define IDC_DSEKAI 3 7 | #define IDI_DSEKAI 101 8 | #define IDM_MENU 102 9 | #define IDD_ABOUTBOX 103 10 | #define IDM_FILE_EXIT 40002 11 | #define IDM_HELP_ABOUT 40003 12 | 13 | // Next default values for new objects 14 | // 15 | #ifdef APSTUDIO_INVOKED 16 | #ifndef APSTUDIO_READONLY_SYMBOLS 17 | #define _APS_NEXT_RESOURCE_VALUE 104 18 | #define _APS_NEXT_COMMAND_VALUE 40004 19 | #define _APS_NEXT_CONTROL_VALUE 1001 20 | #define _APS_NEXT_SYMED_VALUE 101 21 | #endif 22 | #endif 23 | -------------------------------------------------------------------------------- /screens/firecga.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/screens/firecga.png -------------------------------------------------------------------------------- /screens/overwrld.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/screens/overwrld.png -------------------------------------------------------------------------------- /screens/windowsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indigoparadox/dsekai/316efb9ba8bf0ee6178335f8755c241b7564898b/screens/windowsp.png -------------------------------------------------------------------------------- /src/DSEKAI.MAK: -------------------------------------------------------------------------------- 1 | # 2 | # Program: Dsekai 3 | # 4 | 5 | .c.obj: 6 | qcl -c -Ic:\msc5\include -DPLATFORM_DOS -DANCIENT_C -W1 -Ze -Zid -AM $*.c 7 | 8 | graphics.obj : graphics.c 9 | 10 | item.obj : item.c 11 | 12 | main.obj : main.c 13 | 14 | mobile.obj : mobile.c 15 | 16 | tilemap.obj : tilemap.c 17 | 18 | topdown.obj : topdown.c 19 | 20 | window.obj : window.c 21 | 22 | dio.obj : 23 | qcl -c -Ic:\msc5\include -DPLATFORM_DOS -DANCIENT_C -W1 -Ze -Zid -AM data\dio.c 24 | 25 | drc.obj : 26 | qcl -c -Ic:\msc5\include -DPLATFORM_DOS -DANCIENT_C -W1 -Ze -Zid -AM data\drc.c 27 | 28 | dosg.obj : 29 | qcl -c -Ic:\msc5\include -DPLATFORM_DOS -DANCIENT_C -W1 -Ze -Zid -AM graphics\dosg.c 30 | 31 | dosi.obj : input\dosi.c 32 | qcl -c -Ic:\msc5\include -DPLATFORM_DOS -DANCIENT_C -W1 -Ze -Zid -AM input\dosi.c 33 | 34 | Dsekai.exe : graphics.obj item.obj main.obj mobile.obj tilemap.obj \ 35 | topdown.obj window.obj dio.obj drc.obj dosg.obj dosi.obj 36 | del Dsekai.lnk 37 | echo graphics.obj+ >>Dsekai.lnk 38 | echo item.obj+ >>Dsekai.lnk 39 | echo main.obj+ >>Dsekai.lnk 40 | echo mobile.obj+ >>Dsekai.lnk 41 | echo tilemap.obj+ >>Dsekai.lnk 42 | echo topdown.obj+ >>Dsekai.lnk 43 | echo window.obj+ >>Dsekai.lnk 44 | echo dio.obj+ >>Dsekai.lnk 45 | echo drc.obj+ >>Dsekai.lnk 46 | echo dosg.obj+ >>Dsekai.lnk 47 | echo dosi.obj >>Dsekai.lnk 48 | echo Dsekai.exe >>Dsekai.lnk 49 | echo Dsekai.map >>Dsekai.lnk 50 | link @Dsekai.lnk /NOI $(LDFLAGS); 51 | -------------------------------------------------------------------------------- /src/crop.c: -------------------------------------------------------------------------------- 1 | 2 | #define CROPS_C 3 | #include "dsekai.h" 4 | 5 | void crop_grow( struct CROP_PLOT* plot ) { 6 | uint8_t crop_stage = (plot->flags & CROP_FLAG_STAGE_MASK); 7 | 8 | /* TODO: Implement a rolling timer that counts down and compensates for 9 | * rollover. 10 | */ 11 | if( plot->next_at_ticks <= graphics_get_ms() ) { 12 | /* TODO: Growth modifiers based on terrain, powerups, etc. */ 13 | crop_stage++; 14 | plot->flags &= ~CROP_FLAG_STAGE_MASK; 15 | plot->flags |= crop_stage; 16 | plot->next_at_ticks = graphics_get_ms() + plot->cycle; 17 | debug_printf( 1, "crop gid: %d grew to stage: %d, next stage at: %d", 18 | plot->crop_gid, crop_stage, plot->next_at_ticks ); 19 | } 20 | } 21 | 22 | void crop_grow_all( struct DSEKAI_STATE* state ) { 23 | int16_t i = 0; 24 | 25 | if( !engines_state_lock( state ) ) { 26 | goto cleanup; 27 | } 28 | 29 | for( i = 0 ; state->crops_sz > i ; i++ ) { 30 | if( 31 | CROP_FLAG_ACTIVE != (CROP_FLAG_ACTIVE & state->crops[i].flags) || 32 | 0 == state->crops[i].crop_gid || 33 | CROP_STAGE_MAX == (CROP_FLAG_STAGE_MASK & state->crops[i].flags) 34 | ) { 35 | continue; 36 | } 37 | 38 | crop_grow( &(state->crops[i]) ); 39 | } 40 | 41 | cleanup: 42 | return; 43 | } 44 | 45 | struct CROP_PLOT* crop_find_plot( 46 | uint8_t x, uint8_t y, struct DSEKAI_STATE* state 47 | ) { 48 | int8_t i = 0; 49 | struct CROP_PLOT* plot = NULL; 50 | 51 | if( !engines_state_lock( state ) ) { 52 | goto cleanup; 53 | } 54 | 55 | /* Find a plot in front of the user. */ 56 | for( i = 0 ; state->crops_sz > i ; i++ ) { 57 | if( 58 | CROP_FLAG_ACTIVE != (CROP_FLAG_ACTIVE & state->crops[i].flags) || 59 | state->crops[i].map_gid != state->tilemap->gid || 60 | x != state->crops[i].coords.x || y != state->crops[i].coords.y 61 | ) { 62 | continue; 63 | } 64 | 65 | plot = (struct CROP_PLOT*)&(state->crops[i]); 66 | break; 67 | } 68 | 69 | cleanup: 70 | 71 | return plot; 72 | } 73 | 74 | int8_t crop_plant( 75 | uint8_t crop_gid, struct CROP_PLOT* plot, struct DSEKAI_STATE* state 76 | ) { 77 | int8_t retval = 1, 78 | i = 0; 79 | 80 | if( !engines_state_lock( state ) ) { 81 | goto cleanup; 82 | } 83 | 84 | /* Find the crop definition. */ 85 | i = crop_get_def_idx( crop_gid, state ); 86 | if( 0 > i ) { 87 | retval = CROP_ERROR_DEF_NOT_FOUND; 88 | error_printf( "could not find crop def for: %d", crop_gid ); 89 | goto cleanup; 90 | } 91 | 92 | /* TODO: Make sure another crop isn't already growing here! */ 93 | 94 | /* Plant the crop. */ 95 | plot->crop_gid = crop_gid; 96 | plot->next_at_ticks = graphics_get_ms() + state->tilemap->crop_defs[i].cycle; 97 | plot->cycle = state->tilemap->crop_defs[i].cycle; 98 | 99 | debug_printf( 1, "planted crop: %d at: %d, %d on map %d, next stage at: %d", 100 | plot->crop_gid, plot->coords.x, plot->coords.y, 101 | plot->map_gid, plot->next_at_ticks ); 102 | 103 | cleanup: 104 | 105 | return retval; 106 | } 107 | 108 | int8_t crop_harvest( 109 | MOBILE_GID harvester_gid, struct CROP_PLOT* plot, struct DSEKAI_STATE* state 110 | ) { 111 | int8_t i = 0, 112 | retval = 1; 113 | 114 | if( !engines_state_lock( state ) ) { 115 | goto cleanup; 116 | } 117 | 118 | assert( 0 < plot->crop_gid ); 119 | assert( CROP_STAGE_MAX == (CROP_FLAG_STAGE_MASK & plot->flags) ); 120 | 121 | /* Find the crop definition. */ 122 | i = crop_get_def_idx( plot->crop_gid, state ); 123 | if( 0 > i ) { 124 | retval = CROP_ERROR_DEF_NOT_FOUND; 125 | error_printf( "could not find crop def for: %d", plot->crop_gid ); 126 | goto cleanup; 127 | } 128 | 129 | debug_printf( 1, "harvesting plot at: %d, %d on map: %d", 130 | plot->coords.x, plot->coords.y, plot->map_gid ); 131 | 132 | /* Give the harvested crop to the harvester. */ 133 | item_stack_or_add( 134 | state->tilemap->crop_defs[i].produce_gid, harvester_gid, state ); 135 | 136 | /* Update the plot status to reflect harvest. */ 137 | plot->flags &= ~CROP_FLAG_STAGE_MASK; 138 | if( 139 | CROP_DEF_FLAG_REGROWS != 140 | (state->tilemap->crop_defs[i].flags & CROP_DEF_FLAG_REGROWS) 141 | ) { 142 | plot->crop_gid = 0; 143 | plot->next_at_ticks = 0; 144 | plot->cycle = 0; 145 | } else { 146 | /* Crop does regrow. */ 147 | plot->next_at_ticks = graphics_get_ms() + plot->cycle; 148 | plot->flags |= (CROP_FLAG_STAGE_MASK & 2); 149 | } 150 | 151 | cleanup: 152 | 153 | return retval; 154 | } 155 | 156 | int8_t crop_get_def_idx( uint8_t gid, struct DSEKAI_STATE* state ) { 157 | int8_t i = 0, 158 | retval = -1; 159 | 160 | if( !engines_state_lock( state ) ) { 161 | goto cleanup; 162 | } 163 | 164 | /* Check TILEMAP::crop_defs for ::CROP_DEF with same GID. */ 165 | for( i = 0 ; TILEMAP_CROP_DEFS_MAX > i ; i++ ) { 166 | if( state->tilemap->crop_defs[i].gid == gid ) { 167 | retval = i; 168 | break; 169 | } 170 | } 171 | 172 | if( 0 > retval ) { 173 | error_printf( "could not find crop def for: %d", gid ); 174 | } 175 | 176 | cleanup: 177 | return retval; 178 | 179 | } 180 | 181 | -------------------------------------------------------------------------------- /src/crop.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CROP_H 3 | #define CROP_H 4 | 5 | /** 6 | * \addtogroup dsekai_crops Crops 7 | * 8 | * \{ 9 | */ 10 | 11 | /*! \file crops.h 12 | * \brief Structs, functions, and macros pertaining to crops. 13 | */ 14 | 15 | /** 16 | * \addtogroup dsekai_crops_flags Crop Flags 17 | * 18 | * \brief Flags which affect an individual ::CROP_PLOT. 19 | * 20 | * \{ 21 | */ 22 | 23 | /** 24 | * \brief CROP_PLOT::flags indicating plot is active (tilled). 25 | */ 26 | #define CROP_FLAG_ACTIVE 0x04 27 | 28 | /** 29 | * \brief CROP_PLOT::flags mask of current crop growth stage. 30 | * 31 | * Stages are as follows: 32 | * 33 | * 0. Seed (if CROP_PLOT::crop_name[0] != 0) 34 | * 1. Bud 35 | * 2. Intermediate 36 | * 3. Mature / Ready for Harvest 37 | */ 38 | #define CROP_FLAG_STAGE_MASK 0x03 39 | 40 | /*! \} */ 41 | 42 | /** 43 | * \brief Maximum potential crop growth stage, corresponds to 44 | * ::CROP_FLAG_STAGE_MASK. 45 | */ 46 | #define CROP_STAGE_MAX 3 47 | 48 | /*! \brief Return value indicating ::CROP_DEF was not found for provided GID. */ 49 | #define CROP_ERROR_DEF_NOT_FOUND -1 50 | /** 51 | * \brief Return value indicating ::CROP_PLOT was not found for provided 52 | * ::TILEMAP::name and ::TILEMAP_COORDS. 53 | */ 54 | #define CROP_ERROR_PLOT_NOT_FOUND -2 55 | 56 | #define CROP_ERROR_PRODUCE_NOT_FOUND -3 57 | 58 | struct CROP_PLOT { 59 | /** 60 | * \brief TILEMAP::gid of the tilemap on which this crop is growing. 61 | */ 62 | uint16_t map_gid; 63 | /** 64 | * \brief Compared to GIDs in TILEMAP::crop_defs to find crop details. 65 | */ 66 | uint8_t crop_gid; 67 | /*! \brief See \ref dsekai_crops_flags for more information. */ 68 | uint8_t flags; 69 | /** 70 | * \brief Nominal number of ms until crop reaches next growth stage. 71 | * 72 | * Intentionally duplicated from ::CROP_DEF::cycle so that crops are able 73 | * to continue growing even when the ::TILEMAP they exist on is not loaded. 74 | */ 75 | uint16_t cycle; 76 | /** 77 | * \brief Next absolute ms at which this crop may advance to next growth 78 | * stage. 79 | */ 80 | uint32_t next_at_ticks; 81 | struct TILEMAP_COORDS coords; 82 | }; 83 | 84 | 85 | /** 86 | * \brief Check the crop's current cycle/flags and grow to the next stage if 87 | * able to. 88 | */ 89 | void crop_grow( struct CROP_PLOT* plot ); 90 | 91 | /** 92 | * \brief Call crop_grow() on all crops active in the engine state. 93 | */ 94 | void crop_grow_all( struct DSEKAI_STATE* state ); 95 | 96 | struct CROP_PLOT* crop_find_plot( 97 | uint8_t x, uint8_t y, struct DSEKAI_STATE* state ); 98 | 99 | /** 100 | * \brief Given a ::CROP_DEF::gid, plant on a plot at the given coordinates on 101 | * the currently loaded ::TILEMAP. 102 | */ 103 | int8_t crop_plant( 104 | uint8_t crop_gid, struct CROP_PLOT* plot, struct DSEKAI_STATE* state 105 | ) SECTION_CROP; 106 | 107 | /** 108 | * \brief Harvest the given ::CROP_PLOT, giving the produce to the specified 109 | * \ref dsekai_items_owners. 110 | * \param harvester_gid ::MOBILE_GID of the ::MOBILE to give the harvest to. 111 | */ 112 | int8_t crop_harvest( 113 | MOBILE_GID harvester_gid, struct CROP_PLOT* plot, struct DSEKAI_STATE* state 114 | ) SECTION_CROP; 115 | 116 | /** 117 | * \brief Given a ::CROP_DEF::gid, find the index in ::TILEMAP::crop_defs. 118 | */ 119 | int8_t crop_get_def_idx( uint8_t gid, struct DSEKAI_STATE* state ); 120 | 121 | /*! \} */ 122 | 123 | #endif /* !CROP_H */ 124 | 125 | -------------------------------------------------------------------------------- /src/cropdef.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CROPDEF_H 3 | #define CROPDEF_H 4 | 5 | /** 6 | * \addtogroup dsekai_crops 7 | * 8 | * \{ 9 | */ 10 | 11 | /*! \file crops.h 12 | * \brief Crop definition struct to be included in a ::TILEMAP. 13 | */ 14 | 15 | /** 16 | * \addtogroup dsekai_crops_def_flags Crop Definition Flags 17 | * 18 | * \brief Flags which affect all crops that share a ::CROP_DEF universally. 19 | * 20 | * \{ 21 | */ 22 | 23 | /** 24 | * \brief CROP_DEF::flags indicating crop definition is populated. 25 | */ 26 | #define CROP_DEF_FLAG_ACTIVE 0x01 27 | 28 | /** 29 | * \brief CROP_DEF::flags indicating crop regrows when harvested. 30 | */ 31 | #define CROP_DEF_FLAG_REGROWS 0x02 32 | 33 | /*! \} */ 34 | 35 | /** 36 | * \brief Definition of a crop to be stored with the ::TILEMAP on which the 37 | * crop may be grown. 38 | */ 39 | struct CROP_DEF { 40 | /*! \brief Sprite sheet for this crop as it's growing. */ 41 | RESOURCE_NAME sprite_name; 42 | int16_t sprite_cache_id; 43 | char name[CROP_NAME_MAX]; 44 | /*! \brief System identifier for this crop. Unique among all ::CROP_DEF. */ 45 | uint8_t gid; 46 | /*! \brief See \ref dsekai_crops_def_flags for more information. */ 47 | uint8_t flags; 48 | /*! \brief Nominal number of ms until crop reaches next growth stage. */ 49 | uint16_t cycle; 50 | /** 51 | * \brief ::ITEM::gid of the item to be given when this crop is harvested. 52 | */ 53 | int16_t produce_gid; 54 | }; 55 | 56 | #endif /* !CROPDEF_H */ 57 | 58 | -------------------------------------------------------------------------------- /src/dsekai.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef DSEKAI_H 3 | #define DSEKAI_H 4 | 5 | /*! \file dsekai.h 6 | * \brief Engine state data and main header, used in every engine file. 7 | * 8 | * This file should be used to call all other engine headers, to ensure 9 | * dependencies are kept and in order. 10 | * 11 | * Data types and constants that are used in multiple engine headers should 12 | * be placed in this file. 13 | */ 14 | 15 | #define DSEKAI_ERROR_ALLOCATE -128 16 | 17 | /** 18 | * \relates ANIMATION 19 | * \brief Indicates that an animation is behind tiles. 20 | */ 21 | #define ANIMATE_FLAG_BG 0x0400 22 | /** 23 | * \relates ANIMATION 24 | * \brief Indicates that an animation is in front of tiles. 25 | */ 26 | #define ANIMATE_FLAG_FG 0x0800 27 | /** 28 | * \relates ANIMATION 29 | * \brief Indicates that an animation is being used for TILEMAP::weather. 30 | */ 31 | #define ANIMATE_FLAG_WEATHER 0x0200 32 | /** 33 | * \relates ANIMATION 34 | * \brief Indicates that an animation was created by a ::SCRIPT. 35 | */ 36 | #define ANIMATE_FLAG_SCRIPT 0x0100 37 | 38 | #ifdef PLATFORM_PALM 39 | #define SECTION_CROP __attribute__ ((section( "cropfns" ))) 40 | #define SECTION_ITEM __attribute__ ((section( "itemfns" ))) 41 | #define SECTION_MOBILE __attribute__ ((section( "mobfns" ))) 42 | #define SECTION_SCRIPT __attribute__ ((section( "scrfns" ))) 43 | #define SECTION_TILEMAP __attribute__ ((section( "tmapfns" ))) 44 | #else 45 | #define SECTION_CROP 46 | #define SECTION_ITEM 47 | #define SECTION_MOBILE 48 | #define SECTION_SCRIPT 49 | #define SECTION_TILEMAP 50 | #endif /* PLATFORM_PALM */ 51 | 52 | /* === Includes === */ 53 | 54 | #include 55 | #include "gid.h" 56 | #include "config.h" 57 | 58 | /** 59 | * \brief Convenience macro for creating a dialog ::WINDOW with a sprite and 60 | * text string specified from TILEMAP::strpool. 61 | * \image html windowsp.png 62 | * \param dialog Index of the string to display from TILEMAP::strpool. 63 | * \param sprite RESOURCE_NAME of the GRAPHICS_BITMAP to display in this window. 64 | */ 65 | #define window_prefab_dialog( dialog, sprite, dir_flag, fg, bg ) window_push( WINDOW_ID_SCRIPT_SPEAK, 0, WINDOW_TYPE_WINDOW, WINDOW_FLAG_MODAL, SCREEN_MAP_X, WINDOW_PLACEMENT_CENTER, SCREEN_MAP_W, WINDOW_SIZE_AUTO, fg, bg, 0, 0, NULL ); window_push( WINDOW_ID_SCRIPT_SPEAK + 1, WINDOW_ID_SCRIPT_SPEAK, WINDOW_TYPE_LABEL, 0, WINDOW_PLACEMENT_CENTER, 30, WINDOW_PLACEMENT_CENTER, WINDOW_PLACEMENT_CENTER, fg, bg, GRAPHICS_STRING_FLAG_FONT_SCRIPT, 0, dialog ); window_push( WINDOW_ID_SCRIPT_SPEAK + 2, WINDOW_ID_SCRIPT_SPEAK, WINDOW_TYPE_SPRITE, dir_flag | WINDOW_FLAG_SPRITE_BORDER_SINGLE, WINDOW_PLACEMENT_CENTER, 6, WINDOW_SIZE_AUTO, WINDOW_SIZE_AUTO, fg, bg, 0, sprite, NULL ); 66 | 67 | #define window_prefab_system_dialog( dialog, fg, bg ) window_push( WINDOW_ID_SCRIPT_SPEAK, 0, WINDOW_TYPE_WINDOW, WINDOW_FLAG_MODAL, SCREEN_MAP_X, WINDOW_PLACEMENT_CENTER, SCREEN_MAP_W, WINDOW_SIZE_AUTO, fg, bg, 0, 0, NULL ); window_push( WINDOW_ID_SCRIPT_SPEAK + 1, WINDOW_ID_SCRIPT_SPEAK, WINDOW_TYPE_LABEL, 0, WINDOW_PLACEMENT_CENTER, 30, WINDOW_PLACEMENT_CENTER, WINDOW_PLACEMENT_CENTER, fg, bg, 0, 0, dialog ); window_push( WINDOW_ID_SCRIPT_SPEAK + 2, WINDOW_ID_SCRIPT_SPEAK, WINDOW_TYPE_SPRITE, MOBILE_DIR_SOUTH | WINDOW_FLAG_SPRITE_BORDER_SINGLE, WINDOW_PLACEMENT_CENTER, 6, WINDOW_SIZE_AUTO, WINDOW_SIZE_AUTO, fg, bg, 0, state->player.sprite_cache_id, NULL ); 68 | 69 | struct DSEKAI_STATE; 70 | 71 | #include "winids.h" 72 | 73 | #include "itstruct.h" 74 | #include "cropdef.h" 75 | #include "tmstruct.h" 76 | 77 | #include "strpool.h" 78 | 79 | #include "script.h" 80 | 81 | #ifndef NO_SCRIPT_COMPILER 82 | #include "scparse.h" 83 | #endif /* !NO_SCRIPT_COMPILER */ 84 | 85 | #include "tilemap.h" 86 | #include "mobile.h" 87 | #include "item.h" 88 | #ifdef NETWORK_IRC 89 | #include "irc.h" 90 | #endif /* NETWORK_IRC */ 91 | #include "menu.h" 92 | #include "crop.h" 93 | #include "pathfind.h" 94 | 95 | #ifdef TILEMAP_FMT_JSON 96 | #include "tmjson.h" 97 | #endif /* TILEMAP_FMT_JSON */ 98 | 99 | #include "tmasn.h" 100 | 101 | #ifdef TILEMAP_FMT_BIN 102 | #include "tmbin.h" 103 | #endif /* TILEMAP_FMT_BIN */ 104 | 105 | #include "serial.h" 106 | 107 | #include "engines.h" 108 | 109 | #endif /* !DSEKAI_H */ 110 | 111 | -------------------------------------------------------------------------------- /src/gid.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef GID_H 3 | #define GID_H 4 | 5 | /** 6 | * \addtogroup dsekai_gid Globally Unique Identifiers 7 | * \brief Identifiers for objects that are unique among ALL ::TILEMAP objects 8 | * and persistant between \ref dsekai_engines_locking cycles. 9 | * 10 | * These should be used in cases longer than one unilayer_loop_iter(), as a 11 | * ::MEMORY_PTR may be relocated in memory when unlocked and array indexes 12 | * may change if the array is compacted. 13 | * \{ 14 | */ 15 | 16 | /** 17 | * \file gid.h 18 | * \brief Contains macros and typedefs for globally unique identifiers. 19 | */ 20 | 21 | /*! \brief Globally unique identifier for ::MOBILE objects. */ 22 | typedef uint32_t MOBILE_GID; 23 | /*! \brief Globally unique identifier for ::TILEMAP_SPAWN objects. */ 24 | typedef uint16_t SPAWN_GID; 25 | /*! \brief Globally unique identifier for ::TILEMAP objects. */ 26 | typedef uint16_t TILEMAP_GID; 27 | 28 | /** 29 | * \brief Special case unique identifier for the spawner of the 30 | * player-controlled ::MOBILE. 31 | * 32 | * This should exist only on one tilemap (the first tilemap loaded in a new 33 | * world). 34 | */ 35 | #define SPAWN_GID_PLAYER 0xffff 36 | 37 | #define MOBILE_GID_NONE 0 38 | 39 | /*! \brief Special case unique identifier for the player-controlled ::MOBILE. */ 40 | #define MOBILE_GID_PLAYER 0xffffffff 41 | 42 | /** 43 | * \relates MOBILE 44 | * \brief MOBILE::map_gid value indicating mobile is present on all tilemaps. 45 | * 46 | * This is generally only used for the player. 47 | */ 48 | #define MOBILE_MAP_GID_ALL 0xffff 49 | 50 | /** 51 | * \relates MOBILE 52 | * \brief Insert into logging format strings when a mobile's 53 | * \ref dsekai_gid is needed. 54 | */ 55 | #define MOBILE_GID_FMT "%04d:%04d" 56 | 57 | /** 58 | * \relates MOBILE 59 | * \brief Insert into the args provided to a format string using 60 | * ::MOBILE_GID_FMT. 61 | * \param m Locked ::MEMORY_PTR to the mobile to examine. 62 | */ 63 | #define mobile_get_gid_fmt( m ) (m)->map_gid, (m)->spawner_gid 64 | 65 | /*! \} */ 66 | 67 | #endif /* !GID_H */ 68 | 69 | -------------------------------------------------------------------------------- /src/irc.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | /** 4 | * \brief Add a script instruction to the given mobile. If the mobile's 5 | * script queue is full, request resync and update the mobile with 6 | * received full state. 7 | */ 8 | void irc_mobile_queue( struct MOBILE* m, struct SCRIPT_STEP* s ) { 9 | 10 | } 11 | 12 | int16_t irc_connect() { 13 | 14 | } 15 | 16 | -------------------------------------------------------------------------------- /src/irc.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/itstruct.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef ITSTRUCT_H 3 | #define ITSTRUCT_H 4 | 5 | /** 6 | * \addtogroup dsekai_items Items 7 | * 8 | * \{ 9 | */ 10 | 11 | /*! \file itstruct.h 12 | * \brief Structs pertaining to inventory objects. 13 | */ 14 | 15 | /** 16 | * \addtogroup dsekai_items_flags Item Flags 17 | * \brief Flags which affect an individual ::ITEM. 18 | * \{ 19 | */ 20 | 21 | /** 22 | * \brief ITEM::flags bit indicating item exists in the world (and is not 23 | * just a free slot in DSEKAI_STATE::items. 24 | */ 25 | #define ITEM_FLAG_ACTIVE 0x1000 26 | #define ITEM_FLAG_CRAFTABLE 0x2000 27 | 28 | /** 29 | * \brief ITEM::flags indicating this item is not the last used item slot. 30 | * 31 | * This is an optimization measure: The allocation always sets this bit, 32 | * dying doesn't unset it, reallocation can use item slots with this bit set, 33 | * and iteration loops can break early when they no longer see it. 34 | */ 35 | #define ITEM_FLAG_NOT_LAST 0x4000 36 | 37 | /** 38 | * \brief Bitmask for ITEM::flags indicating that item's 39 | * \ref dsekai_items_use. 40 | */ 41 | #define ITEM_TYPE_MASK 0x0f00 42 | 43 | /** 44 | * \brief Bitmask for ITEM::flags indicating the number of copies of this 45 | * item as a stack. 46 | */ 47 | #define ITEM_COUNT_MASK 0x00ff 48 | 49 | /*! \} */ /* dsekai_items_flags */ 50 | 51 | /** 52 | * \relates ITEM 53 | * \brief Get the \ref dsekai_items_use for ::ITEM e, e.g. to index in 54 | * ::gc_items_max. 55 | */ 56 | #define item_get_type_flag( e ) (((e)->flags & ITEM_TYPE_MASK) >> 8) 57 | 58 | /** 59 | * \relates ITEM 60 | * \brief Set the \ref dsekai_items_use for ::ITEM e. 61 | */ 62 | #define item_set_type_flag( e, v ) (e)->flags = (((e)->flags & ~ITEM_TYPE_MASK) | (((v) << 8) & ITEM_TYPE_MASK)) 63 | 64 | /** 65 | * \relates ITEM 66 | * \brief Return the number of copies of ::ITEM e as a stack. 67 | */ 68 | #define item_get_count_flag( e ) ((e)->flags & ITEM_COUNT_MASK) 69 | 70 | /** 71 | * \relates ITEM 72 | * \brief Increment the number of copies of ::ITEM e as a stack. 73 | */ 74 | #define item_incr_count( e, v ) (e)->flags = (((e)->flags & ~ITEM_COUNT_MASK) | ((item_get_count_flag( e ) + (((v) & ITEM_COUNT_MASK))) & ITEM_COUNT_MASK)) 75 | 76 | /** 77 | * \relates ITEM_NAME 78 | * \brief The maximum characters in an ITEM::name. 79 | */ 80 | #define ITEM_NAME_SZ 8 81 | 82 | /** 83 | * \brief An instance of an item in the world. 84 | * 85 | * All extant items are stored in DSEKAI_STATE::items_handle after being 86 | * created in-world, typically through a ::SCRIPT attached to a ::TILEMAP. 87 | * 88 | * Example copies of items available to create on a given ::TILEMAP are stored 89 | * in that's tilemap's TILEMAP::item_defs. 90 | */ 91 | struct ITEM { 92 | RESOURCE_NAME sprite_name; 93 | /** 94 | * \brief Index of the item's sprite loaded in the 95 | * \ref unilayer_graphics_cache. 96 | */ 97 | int16_t sprite_cache_id; 98 | /*! \brief Meaningful name of this item displayed in menus, etc. */ 99 | char name[ITEM_NAME_SZ + 1]; /* +1 for NULL. */ 100 | /** 101 | * \brief \ref dsekai_items_owners for this particular item. 102 | */ 103 | int16_t owner; 104 | /** 105 | * \brief Arbitrary portion of the GID of the item. 106 | */ 107 | int16_t gid; 108 | /** 109 | * \brief Qualitative value specific to each ::ITEM_TYPE_MASK. 110 | * 111 | * | Item | Data | 112 | * |------|-------------| 113 | * | Seed | Crop GID | 114 | * | Food | HP+ | 115 | * 116 | */ 117 | uint8_t data; 118 | /*! \brief \ref dsekai_items_flags pertaining to this item. */ 119 | uint16_t flags; 120 | /** 121 | * \brief If ITEM::owner is ::ITEM_OWNER_NONE, the X coord (in tiles) of 122 | * this item on the ::TILEMAP referred to by ITEM::map_gid. 123 | */ 124 | uint8_t x; 125 | /** 126 | * \brief If ITEM::owner is ::ITEM_OWNER_NONE, the Y coord (in tiles) of 127 | * this item on the ::TILEMAP referred to by ITEM::map_gid. 128 | */ 129 | uint8_t y; 130 | /** 131 | * \brief TILEMAP::gid of the tilemap on which this item is sitting. Only 132 | * has meaning when ITEM::owner is set to ::ITEM_OWNER_NONE. 133 | */ 134 | TILEMAP_GID map_gid; 135 | }; 136 | 137 | /*! \} */ /* dsekai_items */ 138 | 139 | #endif /* !ITSTRUCT_H */ 140 | 141 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | 2 | #define MAIN_C 3 | 4 | #include "dsekai.h" 5 | 6 | MEMORY_HANDLE g_state_handle = (MEMORY_HANDLE)NULL; 7 | 8 | #ifdef PLATFORM_WIN 9 | #include "winstat.h" 10 | #endif /* PLATFORM_WIN */ 11 | 12 | /* === Main Class Definition === */ 13 | 14 | int unilayer_main( int argc, char* argv[] ) { 15 | 16 | /* === Main Preamble === */ 17 | 18 | struct DSEKAI_STATE* state = NULL; 19 | int16_t retval = 0; 20 | 21 | platform_init( icon_dsekai ); 22 | 23 | assert( 0 == TILEMAP_TW % 4 ); 24 | assert( 0 == TILEMAP_TH % 4 ); 25 | 26 | /* Setup logging and log some debug items about this build. */ 27 | 28 | logging_init(); 29 | 30 | debug_printf( 3, "dsekai compiled " __DATE__ __TIME__ ); 31 | debug_printf( 3, "git hash: " DSEKAI_GIT_HASH ); 32 | debug_printf( 3, "using " RESOURCES " resources" ); 33 | 34 | error_printf( "error test" ); 35 | 36 | size_printf( 3, "state", sizeof( struct DSEKAI_STATE ) ); 37 | assert( sizeof( struct DSEKAI_STATE ) < 16384 ); 38 | size_printf( 3, "tilemap", sizeof( struct TILEMAP ) ); 39 | assert( sizeof( struct TILEMAP ) < 16384 ); 40 | 41 | size_multi_printf( 42 | 3, "mobile", sizeof( struct MOBILE ), DSEKAI_MOBILES_MAX ); 43 | size_multi_printf( 3, "item", sizeof( struct ITEM ), DSEKAI_ITEMS_MAX ); 44 | size_multi_printf( 45 | 3, "crop", sizeof( struct CROP_PLOT ), DSEKAI_CROPS_MAX ); 46 | assert( sizeof( struct TILEMAP ) < 16384 ); 47 | 48 | #ifndef NO_ANIMATE 49 | size_printf( 3, "animations cache", 50 | sizeof( struct ANIMATION ) * ANIMATE_ANIMATIONS_MAX ); 51 | assert( sizeof( struct ANIMATION ) * ANIMATE_ANIMATIONS_MAX < 16384 ); 52 | #endif /* !NO_ANIMATE */ 53 | 54 | /* Initialize subsystems. */ 55 | 56 | if( !memory_init() ) { 57 | error_printf( "unable to initialize memory" ); 58 | retval = 1; 59 | goto exit; 60 | } 61 | 62 | if( !graphics_init() ) { 63 | error_printf( "unable to initialize graphics" ); 64 | retval = 1; 65 | goto exit; 66 | } 67 | 68 | engines_draw_loading_screen(); 69 | 70 | if( !input_init() ) { 71 | retval = 1; 72 | error_printf( "unable to initialize input" ); 73 | goto exit; 74 | } 75 | 76 | if( !window_init( 77 | SCREEN_MAP_X, SCREEN_MAP_Y, SCREEN_MAP_W, SCREEN_MAP_H ) 78 | ) { 79 | retval = 1; 80 | error_printf( "unable to initialize GUI" ); 81 | goto exit; 82 | } 83 | 84 | if( !script_init() ) { 85 | error_printf( "unable to initialize scripts" ); 86 | retval = 1; 87 | goto exit; 88 | } 89 | 90 | /* Setup the engine state. */ 91 | 92 | debug_printf( 1, "allocating state..." ); 93 | g_state_handle = memory_alloc( sizeof( struct DSEKAI_STATE ), 1 ); 94 | if( (MEMORY_HANDLE)NULL == g_state_handle ) { 95 | error_printf( "unable to allocate state!" ); 96 | retval = 1; 97 | goto exit; 98 | } 99 | 100 | state = (struct DSEKAI_STATE*)memory_lock( g_state_handle ); 101 | state->version = 1; 102 | state->engine_state = ENGINE_STATE_OPENING; 103 | state->menu.menu_id = -1; 104 | state->menu.highlight_id = -1; 105 | 106 | state->map_handle = memory_alloc( 1, sizeof( struct TILEMAP ) ); 107 | if( (MEMORY_HANDLE)NULL == state->map_handle ) { 108 | error_printf( "unable to allocate tilemap!" ); 109 | retval = 1; 110 | goto exit; 111 | } 112 | 113 | /* TODO: Start small and resize later. */ 114 | state->items_sz = DSEKAI_ITEMS_MAX; 115 | state->items_handle = 116 | memory_alloc( DSEKAI_ITEMS_MAX, sizeof( struct ITEM ) ); 117 | if( (MEMORY_HANDLE)NULL == state->items_handle ) { 118 | error_printf( "unable to allocate items!" ); 119 | retval = 1; 120 | goto exit; 121 | } 122 | 123 | /* TODO: Start small and resize later. */ 124 | state->mobiles_sz = DSEKAI_MOBILES_MAX; 125 | state->mobiles_handle = 126 | memory_alloc( DSEKAI_MOBILES_MAX, sizeof( struct MOBILE ) ); 127 | if( (MEMORY_HANDLE)NULL == state->mobiles_handle ) { 128 | error_printf( "unable to allocate mobiles!" ); 129 | retval = 1; 130 | goto exit; 131 | } 132 | 133 | /* TODO: Start small and resize later. */ 134 | state->crops_sz = DSEKAI_CROPS_MAX; 135 | state->crops_handle = 136 | memory_alloc( DSEKAI_CROPS_MAX, sizeof( struct CROP_PLOT ) ); 137 | if( (MEMORY_HANDLE)NULL == state->crops_handle ) { 138 | error_printf( "unable to allocate crops!" ); 139 | retval = 1; 140 | goto exit; 141 | } 142 | 143 | unilayer_loop_set( engines_loop_iter, g_state_handle ); 144 | 145 | state = (struct DSEKAI_STATE*)memory_unlock( g_state_handle ); 146 | 147 | /* === Main Loop === */ 148 | 149 | #ifndef PLATFORM_WASM 150 | 151 | while( 0 < g_running ) { 152 | unilayer_loop_iter(); 153 | /* 154 | assert( NULL == state->tilemap ); 155 | assert( NULL == state->mobiles ); 156 | assert( NULL == state->items ); 157 | assert( NULL == state->crops ); 158 | */ 159 | 160 | #ifdef USE_SOFT_ASSERT 161 | if( 0 < g_assert_failed_len ) { 162 | while( g_running ) { 163 | if( g_input_key_quit == input_poll( NULL, NULL ) ) { 164 | g_running = 0; 165 | } 166 | WinDrawChars( g_assert_failed, g_assert_failed_len, 10, 20 ); 167 | } 168 | } 169 | #endif /* USE_SOFT_ASSERT */ 170 | } 171 | 172 | /* === Shutdown === */ 173 | 174 | state = (struct DSEKAI_STATE*)memory_lock( g_state_handle ); 175 | if( NULL == state ) { 176 | error_printf( "unable to lock state" ); 177 | retval = 1; 178 | goto exit; 179 | } 180 | if( (MEMORY_HANDLE)NULL != state->map_handle ) { 181 | memory_free( state->map_handle ); 182 | } 183 | state = (struct DSEKAI_STATE*)memory_unlock( g_state_handle ); 184 | 185 | memory_free( g_state_handle ); 186 | 187 | window_shutdown(); 188 | script_shutdown(); 189 | input_shutdown(); 190 | graphics_shutdown(); 191 | 192 | logging_shutdown(); 193 | 194 | platform_shutdown(); 195 | 196 | #endif /* !PLATFORM_WASM */ 197 | 198 | exit: 199 | 200 | return retval; 201 | } 202 | 203 | after_unilayer_main() 204 | 205 | -------------------------------------------------------------------------------- /src/menu.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef MENU_H 3 | #define MENU_H 4 | 5 | /** 6 | * \addtogroup dsekai_menus Menus 7 | * \brief On-screen menu handling world-specific functions. 8 | * 9 | * \{ 10 | */ 11 | 12 | /** 13 | * \brief Defines the top-level menu items and callbacks used to handle each 14 | * submenu. 15 | */ 16 | #define MENU_TABLE( f ) f( 0, main ) f( 1, items ) f( 2, craft ) f( 3, save ) f( 4, quit ) 17 | 18 | /** 19 | * \brief Maximum length of a menu item's display text. 20 | */ 21 | #define MENU_TEXT_SZ 20 22 | 23 | /** 24 | * \brief Open the on-screen menu, pausing the current engine. 25 | */ 26 | void menu_open( struct DSEKAI_STATE* state ); 27 | 28 | /** 29 | * \brief Close the on-screen menu, resuming the current engine. 30 | */ 31 | void menu_close( struct DSEKAI_STATE* state ); 32 | 33 | /** 34 | * \brief Render a currently active menu on-screen. 35 | */ 36 | typedef void (*MENU_RENDERER)( struct DSEKAI_STATE* state ); 37 | 38 | /** 39 | * \brief Handle input for a currently active menu. 40 | */ 41 | typedef int16_t (*MENU_HANDLER)( 42 | INPUT_VAL in_char, int16_t click_x, int16_t click_y, 43 | struct DSEKAI_STATE* state ); 44 | 45 | #define MENU_RENDERER_PROTOTYPES( idx, name ) void menu_renderer_ ## name( struct DSEKAI_STATE* state ); 46 | 47 | MENU_TABLE( MENU_RENDERER_PROTOTYPES ) 48 | 49 | #define MENU_HANDLER_PROTOTYPES( idx, name ) int16_t menu_handler_ ## name( INPUT_VAL in_char, int16_t click_x, int16_t click_y, struct DSEKAI_STATE* state ); 50 | 51 | MENU_TABLE( MENU_HANDLER_PROTOTYPES ) 52 | 53 | /** 54 | * \relates MENU_STATE 55 | * \brief MENU_STATE::flags indicating menu draw callback should be called 56 | * again. 57 | */ 58 | #define MENU_FLAG_DIRTY 0x80 59 | 60 | /** 61 | * \relates MENU_STATE 62 | * \brief MENU_STATE::flags indicating item menu should only show craftable 63 | * items and return to craft menu when item is selected. 64 | */ 65 | #define MENU_FLAG_ITEM_CRAFTABLE 0x40 66 | 67 | #define MENU_FLAG_ITEM_OPEN_SEL_USE 0x01 68 | #define MENU_FLAG_ITEM_OPEN_SEL_CRAFT 0x02 69 | #define MENU_FLAG_ITEM_OPEN_SEL_DROP 0x03 70 | 71 | #define MENU_FLAG_ITEM_OPEN_SEL_MASK 0x03 72 | 73 | struct MENU_STATE { 74 | /*! \brief Currently open menu as an index in the MENU_TABLE. */ 75 | int8_t menu_id; 76 | /*! \brief Currently selected item. Managed by the callback of the menu 77 | * indicated by MENU_STATE::menu_id. 78 | */ 79 | int8_t highlight_id; 80 | /*! \brief Bitfield used to manage menu behavior. */ 81 | uint8_t flags; 82 | /*! \brief graphics_get_ms() at which menu was last opened. */ 83 | uint32_t open_ms; 84 | int8_t craft_item_ids[3]; 85 | int8_t craft_mod_idx; 86 | }; 87 | 88 | #ifdef MENU_C 89 | 90 | #define MENU_TABLE_RENDERERS( idx, name ) menu_renderer_ ## name, 91 | 92 | RES_CONST MENU_RENDERER gc_menu_renderers[] = { 93 | MENU_TABLE( MENU_TABLE_RENDERERS ) 94 | }; 95 | 96 | #define MENU_TABLE_HANDLERS( idx, name ) menu_handler_ ## name, 97 | 98 | RES_CONST MENU_HANDLER gc_menu_handlers[] = { 99 | MENU_TABLE( MENU_TABLE_HANDLERS ) 100 | }; 101 | 102 | #define MENU_TABLE_TOKENS( idx, name ) #name, 103 | 104 | RES_CONST char gc_menu_tokens[][MENU_TEXT_SZ] = { 105 | MENU_TABLE( MENU_TABLE_TOKENS ) 106 | "" 107 | }; 108 | 109 | #define MENU_TABLE_CONSTS( idx, name ) RES_CONST uint8_t gc_menu_idx_ ## name = idx; 110 | 111 | MENU_TABLE( MENU_TABLE_CONSTS ) 112 | 113 | #else 114 | 115 | /** 116 | * \brief Table of callbacks used to draw menus. 117 | * 118 | * These are called once when the menu is opened, and should create a ::WINDOW. 119 | */ 120 | extern RES_CONST MENU_RENDERER gc_menu_renderers[]; 121 | 122 | /** 123 | * \brief Table of callacks used to handle menu input. 124 | * 125 | * These should close the menu's ::WINDOW and set MENU_FLAG_DIRTY on global 126 | * MENU_STATE. 127 | */ 128 | extern RES_CONST MENU_HANDLER gc_menu_handlers[]; 129 | 130 | /** 131 | * \brief Table of menu item names as strings. 132 | */ 133 | extern RES_CONST char gc_menu_tokens[][MENU_TEXT_SZ]; 134 | 135 | #define MENU_TABLE_CONSTS( idx, name ) extern RES_CONST uint8_t gc_menu_idx_ ## name; 136 | 137 | MENU_TABLE( MENU_TABLE_CONSTS ) 138 | 139 | #endif /* MENU_C */ 140 | 141 | /*! \} */ 142 | 143 | #endif /* !MENU_H */ 144 | 145 | -------------------------------------------------------------------------------- /src/mulipalm.def: -------------------------------------------------------------------------------- 1 | application { "dsekai" DSEK } 2 | multiple code { cropfns itemfns mobfns scrfns tmapfns setfns winfns asnfns } 3 | 4 | -------------------------------------------------------------------------------- /src/palmrsc.h: -------------------------------------------------------------------------------- 1 | 2 | #define AboutAlert 2000 3 | #define TheError 3000 4 | 5 | -------------------------------------------------------------------------------- /src/palms.rcp: -------------------------------------------------------------------------------- 1 | 2 | #include "src/palmrsc.h" 3 | #include "residx.h" 4 | 5 | VERSION 1 "1.0" 6 | 7 | ALERT ID AboutAlert 8 | INFORMATION 9 | BEGIN 10 | TITLE "About Colors" 11 | MESSAGE "The Palm Color Converter lets you convert the Red-, Green-and Blue values of a color into it's hexadecimal value and vice versa." 12 | BUTTONS "OK" 13 | END 14 | 15 | ALERT ID TheError 16 | INFORMATION 17 | BEGIN 18 | TITLE "Error" 19 | MESSAGE "^1" 20 | BUTTONS "OK" 21 | END 22 | 23 | #include "palmd.rcp" 24 | 25 | -------------------------------------------------------------------------------- /src/pathfind.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef PATHFIND_H 3 | #define PATHFIND_H 4 | 5 | /** 6 | * \addtogroup dsekai_pathfind Pathfinding 7 | * \{ 8 | */ 9 | 10 | /** 11 | * \file pathfind.h 12 | */ 13 | 14 | struct PATHFIND_NODE { 15 | struct TILEMAP_COORDS coords; 16 | /*! \brief Total node cost. */ 17 | uint8_t f; 18 | /*! \brief Distance from node to pathfinding start. */ 19 | uint8_t g; 20 | /*! \brief Estimated distance from node to pathfinding target. */ 21 | uint8_t h; 22 | /*! \brief Direction of this node from its parent. */ 23 | int8_t dir; 24 | }; 25 | 26 | #define PATHFIND_ERROR_FARTHER -2 27 | 28 | #define PATHFIND_ERROR_CLOSED -3 29 | 30 | /** 31 | * \brief Flag for pathfind_start() indicating the target tile is occupied 32 | * (e.g. we're following another mobile), so don't try to land on it. 33 | */ 34 | #define PATHFIND_FLAGS_TGT_OCCUPIED 0x01 35 | 36 | #ifdef PATHFIND_TRACE 37 | # define pathfind_trace_printf( lvl, ... ) debug_printf( lvl, __VA_ARGS__ ) 38 | #else 39 | /** 40 | * \brief Alias for debug_printf() enabled when PATHFIND_TRACE is defined. 41 | * 42 | * This was made its own alias since pathfinding can get rather chatty when it's 43 | * enabled! 44 | */ 45 | # define pathfind_trace_printf( ... ) 46 | #endif /* PATHFIND_TRACE */ 47 | 48 | #define pathfind_cmp_eq( a, b ) (((a)->coords.x == (b)->coords.x) && (((a)->coords.y == (b)->coords.y))) 49 | 50 | int8_t pathfind_start( 51 | struct MOBILE* mover, uint8_t tgt_x, uint8_t tgt_y, uint8_t steps, 52 | uint8_t flags, struct DSEKAI_STATE* state ); 53 | 54 | /** 55 | * \brief Check for blocking terrain or other ::MOBILE objects preventing 56 | * movement in dir_move. 57 | * \param mover Locked ::MEMORY_PTR to ::MOBILE performing the movement. 58 | * \param dir_move \ref dsekai_mobiles_directions to attempt to move in. 59 | * \param state Locked ::MEMORY_PTR for current ::DSEKAI_STATE. 60 | * \param force 0 if movement should not be attempted if input is blocked 61 | * globally, or 1 if it should. 62 | * \param t Locked ::MEMORY_PTR for DSEKAI_STATE::map_handle. 63 | * \return 1 if successful, 64 | * or ::MOBILE_ERROR_BLOCKED if movement is blocked. 65 | * \todo TODO: Determine terrain movement speed. 66 | */ 67 | #define pathfind_test_dir( x, y, dir_move, state, t ) (TILEMAP_ERROR_BLOCKED != tilemap_collide( x, y, dir_move, t ) && (NULL == mobile_get_facing( x, y, dir_move, state )) ? 1 : MOBILE_ERROR_BLOCKED) 68 | 69 | /*! \} */ /* dsekai_pathfind */ 70 | 71 | #endif /* !PATHFIND_H */ 72 | 73 | -------------------------------------------------------------------------------- /src/profiler.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef PROFILER_H 3 | #define PROFILER_H 4 | 5 | /*! \file profiler.h 6 | * \brief Header containing lightweight in-module profiling tools. 7 | */ 8 | 9 | #ifdef DSEKAI_PROFILER 10 | 11 | #define PROFILE_FIELDS_STRUCT( field ) int32_t field; 12 | 13 | struct DSEKAI_PROFILE { 14 | PROFILE_FIELDS( PROFILE_FIELDS_STRUCT ); 15 | }; 16 | 17 | static struct DSEKAI_PROFILE profile; 18 | static int32_t profile_diff = 0; 19 | 20 | # define profiler_init() memory_zero_ptr( &profile, sizeof( struct DSEKAI_PROFILE ) ) 21 | # define profiler_set() profile_diff = graphics_get_ms(); if( 0 > profile_diff ) { error_printf( "error setting profiler!" ); } 22 | # define profiler_incr( field ) if( 0 <= profile_diff ) { profile.field += (graphics_get_ms() - profile_diff); } 23 | 24 | #define PROFILE_FIELDS_PRINTF( field ) debug_printf( 3, #field ": %d", profile.field ); 25 | 26 | # define profiler_print( profiler_module ) debug_printf( 3, "=== " profiler_module " PROFILER RESULTS ===" ); PROFILE_FIELDS( PROFILE_FIELDS_PRINTF ); debug_printf( 3, "=== END " profiler_module " PROFILER RESULTS ===" ); 27 | 28 | #else 29 | 30 | # define profiler_print( profiler_module ) 31 | # define profiler_init() 32 | # define profiler_set() 33 | # define profiler_incr( field ) 34 | 35 | #endif /* DSEKAI_PROFILER */ 36 | 37 | #endif /* !PROFILER_H */ 38 | 39 | -------------------------------------------------------------------------------- /src/scparse.c: -------------------------------------------------------------------------------- 1 | 2 | #define SCPARSE_C 3 | #include "dsekai.h" 4 | 5 | /* For atoi. */ 6 | #include 7 | 8 | void script_cmp_case( char* token, size_t token_sz ) { 9 | uint16_t i = 0; 10 | 11 | /* Change token case for compare. */ 12 | for( i = 0 ; token_sz > i ; i++ ) { 13 | if( script_char_alpha( token[i] ) ) { 14 | token[i] -= 32; 15 | } 16 | } 17 | } 18 | 19 | void script_cmp_action( char* token, size_t token_sz, struct SCRIPT_STEP* s ) { 20 | uint16_t i = 0; 21 | 22 | script_cmp_case( token, token_sz ); 23 | 24 | /* Compare to token table. */ 25 | i = 0; 26 | while( NULL != gc_sc_tokens[i] ) { 27 | if( 0 == memory_strncmp_ptr( token, gc_sc_tokens[i], token_sz ) ) { 28 | s->action = i; 29 | script_trace_printf( 1, " action: %s\n", gc_sc_tokens[i] ); 30 | return; 31 | } 32 | i++; 33 | } 34 | 35 | s->action = 0; 36 | } 37 | 38 | int16_t script_arg_special( char* token, size_t token_sz ) { 39 | 40 | script_cmp_case( token, token_sz ); 41 | 42 | if( 0 == memory_strncmp_ptr( "SOUTH", token, 5 ) ) { 43 | return 0; 44 | } else if( 0 == memory_strncmp_ptr( "NORTH", token, 5 ) ) { 45 | return 1; 46 | } else if( 0 == memory_strncmp_ptr( "EAST", token, 4 ) ) { 47 | return 2; 48 | } else if( 0 == memory_strncmp_ptr( "WEST", token, 4 ) ) { 49 | return 3; 50 | } else if( 0 == memory_strncmp_ptr( "STACK_I", token, 7 ) ) { 51 | return SCRIPT_ARG_STACK_I; 52 | } else if( 0 == memory_strncmp_ptr( "STACK_P", token, 7 ) ) { 53 | return SCRIPT_ARG_STACK_P; 54 | } else if( 0 == memory_strncmp_ptr( "STACK", token, 5 ) ) { 55 | return SCRIPT_ARG_STACK; 56 | } else if( 0 == memory_strncmp_ptr( "RANDOM", token, 6 ) ) { 57 | return SCRIPT_ARG_RANDOM; 58 | } else if( 0 == memory_strncmp_ptr( "FOLLOW", token, 6 ) ) { 59 | return SCRIPT_ARG_FOLLOW; 60 | } 61 | 62 | return -1; 63 | } 64 | 65 | void script_reset_token( struct SCRIPT_COMPILE_STATE* s ) { 66 | s->token_iter_sz = 0; 67 | s->token_iter[s->token_iter_sz] = '\0'; 68 | } 69 | 70 | void script_parse_src( char c, struct SCRIPT_COMPILE_STATE* s ) { 71 | int16_t arg_tmp = 0; 72 | 73 | switch( c ) { 74 | 75 | case ':': 76 | if( SCRIPT_CS_COMMENT == (SCRIPT_CS_COMMENT & s->flags) ) { 77 | /* Colons happen in comments sometimes. */ 78 | break; 79 | } 80 | s->steps[s->steps_sz].arg = atoi( s->token_iter ); 81 | 82 | script_trace_printf( 1, " action: %d, l: %d\n", 83 | s->steps[s->steps_sz].action, s->steps[s->steps_sz].arg ); 84 | 85 | /* Make sure this is an instruction that can be a label. */ 86 | assert( 87 | SCRIPT_ACTION_START == s->steps[s->steps_sz].action || 88 | SCRIPT_ACTION_INTERACT == s->steps[s->steps_sz].action ); 89 | 90 | if( 7 == s->steps[s->steps_sz].action ) { 91 | /* Only increment start count if this is a START. */ 92 | /* (Multiple INTERACTs don't make sense. */ 93 | s->steps[s->steps_sz].arg = s->last_start++; 94 | } 95 | 96 | s->steps_sz++; 97 | script_reset_token( s ); 98 | break; 99 | 100 | case '#': 101 | case ';': 102 | s->flags |= SCRIPT_CS_COMMENT; 103 | break; 104 | 105 | case '\r': 106 | case '\n': 107 | if( SCRIPT_CS_COMMENT == (SCRIPT_CS_COMMENT & s->flags) ) { 108 | /* Get out of comment in new line. */ 109 | s->flags &= ~SCRIPT_CS_COMMENT; 110 | script_reset_token( s ); 111 | break; 112 | } 113 | 114 | case ' ': 115 | if( SCRIPT_CS_COMMENT == (SCRIPT_CS_COMMENT & s->flags) ) { 116 | script_reset_token( s ); 117 | break; 118 | } 119 | 120 | /* Do nothing if token buffer empty. */ 121 | if( 0 == s->token_iter_sz ) { 122 | break; 123 | } 124 | 125 | /* Process token. */ 126 | script_trace_printf( 1, "token #%d: %s\n", s->steps_sz, s->token_iter ); 127 | if( 0 < s->steps[s->steps_sz].action ) { 128 | /* Set arg and advance instruction. */ 129 | 130 | arg_tmp = script_arg_special( s->token_iter, s->token_iter_sz ); 131 | 132 | /* All special args are positive, so negative means failure. */ 133 | if( 0 > arg_tmp ) { 134 | arg_tmp = atoi( s->token_iter ); 135 | } 136 | s->steps[s->steps_sz].arg = arg_tmp; 137 | script_trace_printf( 1, " arg: %d\n", s->steps[s->steps_sz].arg ); 138 | s->steps_sz++; 139 | 140 | } else { 141 | /* Read instruction. */ 142 | script_cmp_action( 143 | s->token_iter, s->token_iter_sz, &(s->steps[s->steps_sz]) ); 144 | } 145 | script_reset_token( s ); 146 | break; 147 | 148 | default: 149 | if( SCRIPT_CS_COMMENT == (SCRIPT_CS_COMMENT & s->flags) ) { 150 | break; 151 | } 152 | /* Reset token buffer. */ 153 | s->token_iter[s->token_iter_sz++] = c; 154 | s->token_iter[s->token_iter_sz] = '\0'; 155 | break; 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /src/scparse.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef SCPARSE_H 3 | #define SCPARSE_H 4 | 5 | /* TODO: Rename functions/macros with scparse. */ 6 | 7 | #define SCRIPT_CS_NONE 0 8 | #define SCRIPT_CS_COMMENT 1 9 | 10 | #define script_char_alpha( c ) (96 < c && 123 > c) 11 | 12 | void script_cmp_case( char* token, size_t token_sz ); 13 | void script_cmp_action( char* token, size_t token_sz, struct SCRIPT_STEP* s ); 14 | int16_t script_arg_special( char* token, size_t token_sz ); 15 | void script_reset_token( struct SCRIPT_COMPILE_STATE* s ); 16 | void script_parse_src( char c, struct SCRIPT_COMPILE_STATE* s ); 17 | 18 | #ifdef SCPARSE_C 19 | 20 | #define SCRIPT_CB_TABLE_TOKEN( idx, name, c ) #name, 21 | 22 | /*! \brief List of valid script action tokens. */ 23 | const char* gc_sc_tokens[] = { 24 | SCRIPT_CB_TABLE( SCRIPT_CB_TABLE_TOKEN ) 25 | NULL 26 | }; 27 | 28 | #define SCRIPT_CB_TABLE_BYTE( idx, name, c ) c, 29 | 30 | const char gc_sc_bytes[] = { 31 | SCRIPT_CB_TABLE( SCRIPT_CB_TABLE_BYTE ) 32 | '\0' 33 | }; 34 | 35 | #else 36 | 37 | extern const char* gc_sc_tokens[]; 38 | extern const char gc_sc_bytes[]; 39 | 40 | #endif /* SCPARSE_C */ 41 | 42 | #endif /* !SCPARSE_H */ 43 | 44 | -------------------------------------------------------------------------------- /src/scstruct.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef SCSTRUCT_H 3 | #define SCSTRUCT_H 4 | 5 | /** 6 | * \addtogroup scripting 7 | * 8 | * \{ 9 | */ 10 | 11 | /*! \file scstruct.h 12 | * \brief Structs representing behavior scripts. 13 | */ 14 | 15 | /** 16 | * \brief Contains a single instruction in a script, in SCRIPT::steps. 17 | * 18 | * Modifications to this struct should also be reflected in 19 | * tools/map2h.c (map2h.h). 20 | */ 21 | struct SCRIPT_STEP { 22 | /*! \brief Opcode of the action as defined by ::SCRIPT_CB_TABLE. */ 23 | uint16_t action; 24 | /*! \brief Argument that will be passed to this action on execution. */ 25 | int16_t arg; 26 | }; 27 | 28 | /** 29 | * \brief Contains immutable state for scripts attached to a TILEMAP. 30 | * 31 | * Modifications to this struct should also be reflected in 32 | * tools/map2h.c (map2h.h). 33 | */ 34 | struct SCRIPT { 35 | /*! \brief Indexed list of script steps in order. */ 36 | struct SCRIPT_STEP steps[SCRIPT_STEPS_MAX]; 37 | /*! \brief Number of SCRIPT::steps attached to this script. */ 38 | uint16_t steps_count; 39 | }; 40 | 41 | #ifndef NO_SCRIPT_COMPILER 42 | 43 | /** 44 | * \addtogroup scripting_compiler Script Compiler 45 | */ 46 | 47 | #define SCRIPT_TOKEN_ITER_SZ_MAX 255 48 | 49 | struct SCRIPT_COMPILE_STATE { 50 | uint8_t flags; 51 | char token_iter[SCRIPT_TOKEN_ITER_SZ_MAX + 1]; 52 | uint16_t token_iter_sz; 53 | struct SCRIPT_STEP* steps; 54 | uint16_t steps_sz; 55 | int16_t last_start; 56 | }; 57 | 58 | #endif /* !NO_SCRIPT_COMPILER */ 59 | 60 | /*! \} */ 61 | 62 | #endif /* !SCSTRUCT_H */ 63 | 64 | -------------------------------------------------------------------------------- /src/serial.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef SERIAL_H 3 | #define SERIAL_H 4 | 5 | /** 6 | * \addtogroup dsekai_engines 7 | * \{ 8 | */ 9 | 10 | /** 11 | * \file serial.h 12 | * \brief Functions for (de)serializing engine structs to save states. 13 | */ 14 | 15 | #define SERIAL_ERROR -1 16 | 17 | #define serial_asn_write_seq_start( p_asn_buffer_h, p_mark, desc, idx, cleanup ) debug_printf( 2, "(offset 0x%02x) writing %s seq start", idx, desc ); idx = asn_write_seq_start( p_asn_buffer_h, idx, p_mark ); if( 0 > idx ) { error_printf( "error writing %s seq start", desc ); idx = SERIAL_ERROR; goto cleanup; } 18 | 19 | #define serial_asn_write_seq_end( p_asn_buffer_h, p_mark, desc, idx, cleanup ) debug_printf( 2, "(offset 0x%02x) writing %s seq end", idx, desc ); idx = asn_write_seq_end( p_asn_buffer_h, idx, p_mark ); if( 0 > idx ) { error_printf( "error writing %s seq end", desc ); idx = SERIAL_ERROR; goto cleanup; } 20 | 21 | #define serial_asn_write_int( p_asn_buffer_h, val, x_val_sz, desc, idx, cleanup ) debug_printf( 2, "(offset 0x%02x) writing %s: %d", idx, desc, val ); idx = asn_write_int( p_asn_buffer_h, idx, val ); if( 0 > idx ) { error_printf( "error writing %s: %d", desc, idx ); goto cleanup; } 22 | 23 | #define serial_asn_write_string( p_asn_buffer_h, str, str_sz, desc, idx, cleanup ) debug_printf( 2, "(offset 0x%02x) writing %s: %s", idx, desc, str ); idx = asn_write_string( p_asn_buffer_h, idx, str, str_sz ); if( 0 > idx ) { error_printf( "error writing %s: %d", desc, idx ); goto cleanup; } 24 | 25 | #define serial_asn_read_seq( asn_buffer, p_type, p_sz, desc, idx, read_sz, cleanup ) read_sz = asn_read_meta_ptr( asn_buffer, idx, p_type, p_sz ); if( ASN_SEQUENCE != *(p_type) ) { error_printf( "invalid %s sequence type: 0x%02x", desc, *(p_type) ); idx = SERIAL_ERROR; goto cleanup; } debug_printf( 2, "(offset 0x%02x) read %s seq start (%d bytes)", idx, desc, *(p_sz) ); idx += read_sz; 26 | 27 | #define serial_asn_read_int( asn_buffer, p_val, val_sz, flags, desc, idx, read_sz, cleanup ) read_sz = asn_read_int( (uint8_t*)(p_val), val_sz, flags, asn_buffer, idx ); if( 0 >= read_sz ) { error_printf( "error reading %s", desc ); idx = SERIAL_ERROR; goto cleanup; } debug_printf( 2, "(offset 0x%02x) read %s (%d bytes): %d", idx, desc, read_sz, *(p_val) ); idx += read_sz; 28 | 29 | #define serial_asn_read_string( asn_buffer, str_buffer, str_buffer_sz, desc, idx, read_sz, cleanup ) read_sz = asn_read_string( str_buffer, str_buffer_sz, asn_buffer, idx ); if( 0 >= read_sz ) { error_printf( "error reading %s", desc ); idx = SERIAL_ERROR; goto cleanup; } debug_printf( 2, "(offset 0x%02x) read %s (%d bytes): %s", idx, desc, read_sz, str_buffer ); idx += read_sz; 30 | 31 | /* int16_t engines_asn_load( RESOURCE_ID id, struct DSEKAI_STATE* state ); */ 32 | 33 | /** 34 | * \brief Serialize the engine struct to a save state and call the 35 | * \ref unilayer_save to write that save state to storage. 36 | * \return Number of bytes written or error code. 37 | */ 38 | int32_t serial_save( const char* save_name, struct DSEKAI_STATE* state 39 | ) SECTION_ASN; /* Stuff it in ASN section even if it's a different fmt. */ 40 | 41 | /** 42 | * \brief Call the \ref unilayer_save to provide the save state with the 43 | * given name and deserialize it into the given engine struct. 44 | * \return Number of bytes read or error code. 45 | */ 46 | int32_t serial_load( const char* save_name, struct DSEKAI_STATE* state 47 | ) SECTION_ASN; /* Stuff it in ASN section even if it's a different fmt. */ 48 | 49 | /*! \} */ /* dsekai_engines */ 50 | 51 | #endif /* !SERIAL_H */ 52 | 53 | -------------------------------------------------------------------------------- /src/strpool.c: -------------------------------------------------------------------------------- 1 | 2 | #include "dsekai.h" 3 | 4 | int16_t strpool_get_sz( const char* str_in ) { 5 | int16_t int_out = 0; 6 | 7 | int_out |= (str_in[1] & 0xff); 8 | int_out <<= 8; 9 | int_out |= (str_in[0] & 0xff); 10 | 11 | return int_out; 12 | } 13 | 14 | void strpool_init( char* strpool, int16_t strpool_sz ) { 15 | 16 | memory_zero_ptr( strpool, strpool_sz ); 17 | strpool[0] = ((strpool_sz - 2) & 0xff); 18 | strpool[1] = (((strpool_sz - 2) >> 8) & 0xff); 19 | debug_printf( 3, "strpool initialized as %d bytes", strpool_sz ); 20 | 21 | assert( strpool_sz - 2 == strpool_get_sz( strpool ) ); 22 | } 23 | 24 | int16_t strpool_add_string( char* strpool, char* string, int16_t string_sz ) { 25 | int16_t i = 0, 26 | str_len = 0, 27 | strpool_sz = 0; 28 | 29 | strpool_sz = strpool_get_sz( strpool ); 30 | i += 2; /* Move past strpool size. */ 31 | 32 | while( '\0' != strpool[i] ) { 33 | str_len = strpool_get_sz( &(strpool[i]) ); 34 | i += 2; /* Move past length. */ 35 | i += str_len; /* Move past string. */ 36 | } 37 | 38 | if( string_sz + 1 + i + 2 >= strpool_sz ) { 39 | error_printf( "strpool size exceeded (%d out of %d)!", 40 | string_sz + 1 + i + 2, strpool_sz ); 41 | return -1; 42 | } 43 | 44 | /* Store LSB first so zeros are easier to detect. */ 45 | strpool[i] = ((string_sz + 1) & 0xff); 46 | strpool[i + 1] = (((string_sz + 1) >> 8) & 0xff); 47 | memory_copy_ptr( &(strpool[i + 2]), string, string_sz ); 48 | 49 | return i; 50 | } 51 | 52 | const char* strpool_get( const char* strpool, int16_t idx, int16_t* sz_out ) { 53 | int16_t i = 0, 54 | str_len = 0, 55 | idx_iter = 0, 56 | strpool_sz = 0; 57 | 58 | strpool_sz = strpool_get_sz( strpool ); 59 | i += 2; /* Move past strpool size. */ 60 | 61 | while( idx_iter < idx && i < strpool_sz ) { 62 | str_len = strpool_get_sz( &(strpool[i]) ); 63 | i += 2; /* Move past length. */ 64 | i += str_len; /* Move past string. */ 65 | idx_iter++; 66 | } 67 | 68 | if( idx_iter != idx ) { 69 | return NULL; 70 | } 71 | 72 | if( NULL != sz_out ) { 73 | *sz_out = strpool_get_sz( &(strpool[i]) ); 74 | } 75 | 76 | i += 2; /* Move past string size. */ 77 | 78 | return &(strpool[i]); 79 | } 80 | 81 | -------------------------------------------------------------------------------- /src/strpool.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef STRPOOL_H 3 | #define STRPOOL_H 4 | 5 | /** 6 | * \addtogroup dsekai_strpool String Pool 7 | * \brief Flexible storage for strings in small spaces. 8 | * 9 | * String pools are used so that all of the strings that may be used by the UI 10 | * are kept in a spot that can be easily referenced even when the OS moves 11 | * memory around. Their flexible nature conserves precious memory. 12 | * 13 | * | 0x0 | 0x2 | 0x4 | ... 14 | * |--------------|-------------------|-----------------------|----- 15 | * | strpool size | first string size | first string contents | ... 16 | * 17 | * All size values are stored LSB first, so that non-zero values are more 18 | * immediately apparent. 19 | * 20 | * There is an initial 16-bit value denoting the size of the entire pool. This 21 | * can be considered the pool header and does not repeat. 22 | * 23 | * This is followed by a 16-bit value denoting the size of the first string, 24 | * followed by the string, itself (NULL-terminated; the sizes do not include 25 | * this termination). This size-contents-terminator pattern repeats for the 26 | * rest of the pool. 27 | * 28 | * \{ 29 | */ 30 | 31 | /*! \file strpool.h 32 | * \brief Flexible storage for strings in small spaces. 33 | */ 34 | 35 | /** 36 | * \brief Get the size of a string pool or contained string. 37 | * \param str_in String pool or character offset of string size to read. 38 | * \return Size of pool or string. 39 | */ 40 | int16_t strpool_get_sz( const char* str_in ); 41 | 42 | /** 43 | * \brief Prepare a string pool for use. 44 | * \param strpool String pool to initialize (zero out and imprint size). 45 | * \param strpool_sz Size allocated to the string pool (including all headers). 46 | */ 47 | void strpool_init( char* strpool, int16_t strpool_sz ); 48 | 49 | int16_t strpool_add_string( char* strpool, char* string, int16_t string_sz ); 50 | 51 | const char* strpool_get( const char* strpool, int16_t idx, int16_t* sz_out ); 52 | 53 | /* \} */ 54 | 55 | #endif /* !STRPOOL_H */ 56 | 57 | -------------------------------------------------------------------------------- /src/tilemap.c: -------------------------------------------------------------------------------- 1 | 2 | #define TILEMAP_C 3 | #include "dsekai.h" 4 | 5 | #ifndef RESOURCE_FILE 6 | 7 | extern RES_CONST char gc_map_names[][TILEMAP_NAME_MAX]; 8 | extern RES_CONST struct TILEMAP* gc_map_structs[]; 9 | extern RES_CONST uint8_t gc_map_count; 10 | 11 | #endif /* !RESOURCE_FILE */ 12 | 13 | int16_t tilemap_load( const char* map_name, struct TILEMAP* t ) { 14 | int16_t map_retval = 0, 15 | i = 0; 16 | #ifdef RESOURCE_FILE 17 | char map_load_path[RESOURCE_PATH_MAX]; 18 | #else 19 | int8_t map_name_sz = 0; 20 | #endif /* RESOURCE_FILE */ 21 | RESOURCE_ID ts_id; 22 | 23 | /* TODO: Work this into resource API in a modular fashion. */ 24 | #if defined( RESOURCE_FILE ) || defined( RESOURCE_WASM ) 25 | # ifdef TILEMAP_FMT_JSON 26 | memory_zero_ptr( (MEMORY_PTR)map_load_path, TILEMAP_NAME_MAX ); 27 | dio_snprintf( 28 | map_load_path, 29 | RESOURCE_PATH_MAX, 30 | ASSETS_PATH "m_%s.json", map_name ); 31 | map_retval = tilemap_json_load( map_load_path, t ); 32 | # elif defined TILEMAP_FMT_ASN 33 | dio_snprintf( 34 | map_load_path, 35 | RESOURCE_PATH_MAX, 36 | ASSETS_PATH "m_%s.asn", map_name ); 37 | map_retval = tilemap_asn_load_res( map_load_path, t ); 38 | # else 39 | /* Can't load a map for the engine; we're probably in map2asn. */ 40 | map_retval = 0; 41 | # endif 42 | 43 | #else 44 | map_name_sz = memory_strnlen_ptr( map_name, TILEMAP_NAME_MAX ); 45 | debug_printf( 2, "attempting to open tilemap: %s (%d chars)", 46 | map_name, map_name_sz ); 47 | debug_printf( 1, "looping through %d tilemaps...", gc_map_count ); 48 | for( i = 0 ; gc_map_count > i ; i++ ) { 49 | if( 0 == memory_strncmp_ptr( gc_map_names[i], map_name, map_name_sz ) ) { 50 | debug_printf( 1, "gc_map_%s vs %s", gc_map_names[i], map_name ); 51 | memory_copy_ptr( (MEMORY_PTR)t, (MEMORY_PTR)gc_map_structs[i], 52 | sizeof( struct TILEMAP ) ); 53 | map_retval = 1; 54 | break; 55 | } 56 | } 57 | 58 | #endif /* RESOURCE_FILE */ 59 | 60 | if( 0 >= map_retval ) { 61 | goto cleanup; 62 | } 63 | 64 | /* Preload tilemap tileset tiles into graphics cache. */ 65 | for( i = 0 ; TILEMAP_TILESETS_MAX > i ; i++ ) { 66 | /* Skip inactive tiles. */ 67 | if( 68 | TILESET_FLAG_ACTIVE != (t->tileset[i].flags & TILESET_FLAG_ACTIVE) 69 | ) { 70 | continue; 71 | } 72 | 73 | debug_printf( 2, "preloading tile %d image...", i ); 74 | resource_id_from_name( &ts_id, t->tileset[i].image_name, 75 | RESOURCE_EXT_GRAPHICS ); 76 | t->tileset[i].image_cache_id = graphics_cache_load_bitmap( 77 | ts_id, GRAPHICS_BMP_FLAG_TYPE_TILE ); 78 | } 79 | 80 | cleanup: 81 | 82 | return map_retval; 83 | } 84 | 85 | void tilemap_refresh_tiles( struct TILEMAP* t ) { 86 | int8_t x = 0, y = 0; 87 | 88 | for( y = 0 ; TILEMAP_TH > y ; y++ ) { 89 | for( x = 0 ; TILEMAP_TW > x ; x++ ) { 90 | t->tiles_flags[(y * TILEMAP_TW) + x] |= TILEMAP_TILE_FLAG_DIRTY; 91 | } 92 | } 93 | } 94 | 95 | void tilemap_set_weather( uint8_t weather, struct TILEMAP* t ) { 96 | 97 | if( 98 | TILEMAP_FLAG_WEATHER_SNOW == 99 | (TILEMAP_FLAG_WEATHER_MASK & weather) 100 | ) { 101 | debug_printf( 2, "current weather is snowy" ); 102 | #ifndef DISABLE_WEATHER_EFFECTS 103 | animate_create( 104 | ANIMATE_TYPE_SNOW, ANIMATE_FLAG_WEATHER | ANIMATE_FLAG_FG, 105 | SCREEN_MAP_X, SCREEN_MAP_Y, SCREEN_MAP_W, SCREEN_MAP_H ); 106 | #endif /* !DISABLE_WEATHER_EFFECTS */ 107 | } else { 108 | debug_printf( 2, "current weather is clear" ); 109 | } 110 | 111 | t->flags |= (TILEMAP_FLAG_WEATHER_MASK & weather); 112 | } 113 | 114 | int8_t tilemap_collide( 115 | uint8_t x, uint8_t y, uint8_t dir, struct TILEMAP* t 116 | ) { 117 | uint8_t tile_id = 0; 118 | int16_t x_test = 0, y_test = 0; 119 | int8_t retval = 0; 120 | 121 | assert( dir < 4 ); 122 | 123 | x_test = x + gc_mobile_x_offsets[dir]; 124 | y_test = y + gc_mobile_y_offsets[dir]; 125 | 126 | tile_id = tilemap_get_tile_id( t, x_test, y_test ); 127 | if( t->tileset[tile_id].flags & (uint8_t)TILESET_FLAG_BLOCK ) { 128 | retval = TILEMAP_ERROR_BLOCKED; 129 | } 130 | return retval; 131 | } 132 | 133 | void tilemap_advance_tile_id( struct TILEMAP* t, uint16_t x, uint16_t y ) { 134 | int8_t tile_id = 0; 135 | 136 | if( x >= TILEMAP_TW || y >= TILEMAP_TH ) { 137 | error_printf( "attempted to advance tile out of range!" ); 138 | return; 139 | } 140 | 141 | tile_id = tilemap_get_tile_id( t, x, y ); 142 | 143 | /* Find the next highest loaded tile, wrapping around to 0 if needed. */ 144 | do { 145 | tile_id++; 146 | 147 | if( TILEMAP_TILESETS_MAX <= tile_id ) { 148 | tile_id = 0; 149 | } 150 | } while( 151 | TILESET_FLAG_ACTIVE != 152 | (TILESET_FLAG_ACTIVE & t->tileset[tile_id].flags) 153 | ); 154 | 155 | debug_printf( 0, "tile_id: %d", tile_id ); 156 | 157 | /* Merge the tile ID back into the tilemap. */ 158 | if( 0 == x % 2 ) { 159 | t->tiles[((y * TILEMAP_TW) + x) / 2] &= ~0xf0; 160 | tile_id <<= 4; 161 | } else { 162 | t->tiles[((y * TILEMAP_TW) + x) / 2] &= ~0x0f; 163 | } 164 | t->tiles[((y * TILEMAP_TW) + x) / 2] |= tile_id; 165 | } 166 | 167 | void tilemap_deinit( struct TILEMAP* t ) { 168 | if( NULL == t ) { 169 | return; 170 | } 171 | } 172 | 173 | -------------------------------------------------------------------------------- /src/tilemap.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef TILEMAP_H 3 | #define TILEMAP_H 4 | 5 | /** 6 | * \addtogroup dsekai_tilemaps Tilemaps 7 | * 8 | * \{ 9 | */ 10 | 11 | /*! \file tilemap.h 12 | * \brief Functions and macros pertaining to tilemaps. 13 | */ 14 | 15 | /** 16 | * \addtogroup dsekai_tilemaps_flags Tilemap Flags 17 | * 18 | * \{ 19 | */ 20 | 21 | /** 22 | * \brief Bitmask indicating flags that determine ::TILEMAP weather. 23 | */ 24 | #define TILEMAP_FLAG_WEATHER_MASK 0x0f 25 | 26 | #define TILEMAP_FLAG_WEATHER_SNOW 0x01 27 | #define TILEMAP_FLAG_WEATHER_RAIN 0x02 28 | 29 | #define TILEMAP_FLAG_EDITABLE 0x10 30 | 31 | /*! \} */ 32 | 33 | /** 34 | * \brief Return value indicating movement is blocked by terrain. 35 | * \warning This should not overlap with ::MOBILE_ERROR_BLOCKED! 36 | */ 37 | #define TILEMAP_ERROR_BLOCKED -40 38 | 39 | /** 40 | * \relates ::TILESET_TILE 41 | * \brief TILESET_TILE::flags bit flag indicating tile will block movement. 42 | */ 43 | #define TILESET_FLAG_BLOCK 0x01 44 | 45 | /** 46 | * \relates ::TILESET_TILE 47 | * \brief TILESET_TILE::flags bit flag indicating player is allowed to grow a 48 | * ::CROP_PLOT on this tile. 49 | */ 50 | #define TILESET_FLAG_FARMABLE 0x02 51 | 52 | /** 53 | * \relates ::TILESET_TILE 54 | * \brief TILESET_TILE::flags bit flag indicating tile is not empty. 55 | */ 56 | #define TILESET_FLAG_ACTIVE 0x80 57 | 58 | /** 59 | * \relates ::TILEMAP 60 | * \brief TILEMAP::tiles_flags bit flag indicating tile must be redrawn. 61 | */ 62 | #define TILEMAP_TILE_FLAG_DIRTY 0x01 63 | 64 | /** 65 | * \brief Get the TILEMAP::tileset index for the tile at the given coords. 66 | * \param t ::MEMORY_PTR to TILEMAP from which to get the tile. 67 | * \param x Tile X coordinate in tiles. 68 | * \param y Tile Y coordinate in tiles. 69 | */ 70 | #define tilemap_get_tile_id( t, x, y ) (((t)->tiles[((y * TILEMAP_TW) + x) / 2] >> (0 == x % 2 ? 4 : 0)) & 0x0f) 71 | 72 | #ifdef PLATFORM_CURSES 73 | # define tilemap_tile_get_image( tt ) ((tt)->ascii) 74 | #else 75 | /** 76 | * \relates TILEMAP_TILE 77 | * \brief Get the pointer to the sprite graphic to use for a ::TILEMAP_TILE. 78 | */ 79 | # define tilemap_tile_get_image( tt ) ((tt)->image_cache_id) 80 | #endif /* PLATFORM_CURSES */ 81 | 82 | /* 83 | #define mobile_break_if_last( mobiles, i ) if( MOBILE_FLAG_NOT_LAST != (MOBILE_FLAG_NOT_LAST & mobiles[i].flags) ) { debug_printf( 0, "breaking early on mobile %d!", i ); break; } 84 | */ 85 | 86 | #ifndef IGNORE_DIRTY 87 | 88 | #define tilemap_is_dirty( x, y, map ) (((map)->tiles_flags[((y) * TILEMAP_TW) + (x)] & TILEMAP_TILE_FLAG_DIRTY)) 89 | 90 | #define tilemap_set_dirty( x, y, map ) (map)->tiles_flags[(y * TILEMAP_TW) + x] |= TILEMAP_TILE_FLAG_DIRTY; 91 | 92 | #define tilemap_unset_dirty( x, y, map ) (map)->tiles_flags[(y * TILEMAP_TW) + x] &= ~TILEMAP_TILE_FLAG_DIRTY; 93 | 94 | #endif /* !IGNORE_DIRTY */ 95 | 96 | #ifdef RESOURCE_FILE 97 | 98 | uint16_t tilemap_fix_asset_path( 99 | char* path_in, uint16_t path_in_sz, const char* map_path ); 100 | 101 | #endif /* RESOURCE_FILE */ 102 | 103 | /** 104 | * \brief Load tilemap with map_name into the given ::TILEMAP and prepare it 105 | * for running in the engine. 106 | */ 107 | int16_t tilemap_load( const char* map_name, struct TILEMAP* t ); 108 | 109 | /** 110 | * \relates TILEMAP 111 | * \brief Force a redraw of all tiles on a TILEMAP by marking them dirty. 112 | * \param t ::MEMORY_PTR to a TILEMAP to redraw. 113 | */ 114 | void tilemap_refresh_tiles( struct TILEMAP* t ); 115 | 116 | /** 117 | * \relates TILEMAP 118 | * \brief Set the \ref dsekai_tilemaps_weather of the given ::TILEMAP, 119 | * including starting any related animation effects. 120 | * \param t ::MEMORY_PTR to a TILEMAP to set the weather of. 121 | * \param weather Weather-related \ref dsekai_tilemaps_flags. 122 | * 123 | * This will start the relevant animation if necessary. 124 | */ 125 | void tilemap_set_weather( uint8_t weather, struct TILEMAP* t ) SECTION_TILEMAP; 126 | 127 | /** 128 | * \brief Detect potential collision between a MOBILE and TILEMAP tile with 129 | * blocking flags. 130 | * \param dir MOBILE::dir in which the MOBILE is moving. 131 | * \param t ::MEMORY_PTR to the TILEMAP on which the MOBILE is moving. 132 | * \return 1 if a collision will occur and 0 otherwise. 133 | */ 134 | int8_t tilemap_collide( 135 | uint8_t x, uint8_t y, uint8_t dir, struct TILEMAP* t ); 136 | 137 | /** 138 | * \brief Increment the tile_id on the specified tile coordinates. Useful for 139 | * editing ::TILEMAP. 140 | */ 141 | void tilemap_advance_tile_id( struct TILEMAP* t, uint16_t x, uint16_t y ) 142 | SECTION_TILEMAP; 143 | 144 | /** 145 | * \relates TILEMAP 146 | * \brief Prepare a TILEMAP for deallocation. 147 | * \param t ::MEMORY_PTR to a TILEMAP to deinitialize. 148 | */ 149 | void tilemap_deinit( struct TILEMAP* ) SECTION_TILEMAP; 150 | 151 | /*! \} */ 152 | 153 | # ifdef TILEMAP_C 154 | 155 | # ifdef RESOURCE_FILE 156 | 157 | # include "tmjson.h" 158 | # include "tmasn.h" 159 | 160 | /* Get the real path to the tileset (it's JSON so assume file paths). */ 161 | /* Resource IDs would be using pre-parsed maps. */ 162 | 163 | uint16_t tilemap_fix_asset_path( 164 | char* path_in, uint16_t path_in_sz, const char* map_path 165 | ) { 166 | uint16_t path_sz_out = 0, 167 | map_path_sz = 0; 168 | 169 | map_path_sz = memory_strnlen_ptr( map_path, RESOURCE_PATH_MAX ); 170 | path_sz_out = dio_char_idx_r( map_path, map_path_sz, PLATFORM_DIR_SEP ); 171 | if( 172 | /* Found a map path. */ 173 | 0 < path_sz_out && 174 | /* Map path fits in buffer with filename, separator, and NULL. */ 175 | path_in_sz > path_sz_out + 2 176 | ) { 177 | /* Prepend map directory to tileset name. */ 178 | memory_strncpy_ptr( path_in, map_path, path_sz_out ); 179 | 180 | /* Append path separator. */ 181 | path_in[path_sz_out++] = PLATFORM_DIR_SEP; 182 | 183 | /* Add (temporary) NULL terminator. */ 184 | path_in[path_sz_out] = '\0'; 185 | 186 | debug_printf( 2, "map directory: %s", path_in ); 187 | 188 | } else { 189 | error_printf( "unable to fit map path into buffer!" ); 190 | path_sz_out = 0; 191 | } 192 | 193 | return path_sz_out; 194 | } 195 | 196 | # endif /* RESOURCE_FILE */ 197 | 198 | # endif /* TILEMAP_C */ 199 | 200 | #endif /* TILEMAP_H */ 201 | 202 | -------------------------------------------------------------------------------- /src/tmasn.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef TMASN_H 3 | #define TMASN_H 4 | 5 | /** 6 | * \addtogroup dsekai_tilemaps 7 | * 8 | * \{ 9 | */ 10 | 11 | /** 12 | * \addtogroup asn_tilemaps ASN.1 Tilemaps 13 | * \brief Extremely specific dialect of ASN.1 used to store tilemaps in a 14 | * compact and simple binary format. 15 | * 16 | * \{ 17 | */ 18 | 19 | /*! \file tmasn.h 20 | * \brief Definitions and functions for reading an ASN.1-formatted ::TILEMAP. 21 | */ 22 | 23 | /*! \brief Read size returned when there was a parsing error. */ 24 | #define TILEMAP_ASN_ERROR_READ -1 25 | 26 | #define TILEMAP_ASN_ERROR_WRITE -1 27 | 28 | #define TILEMAP_ASN_SAVE_BUFFER_INITIAL_SZ 2048 29 | 30 | /* Public */ 31 | 32 | int32_t tilemap_asn_load_res( RESOURCE_ID id, struct TILEMAP* t ) SECTION_ASN; 33 | int32_t tilemap_asn_load( 34 | const uint8_t* asn_buffer, int32_t asn_buffer_sz, struct TILEMAP* t 35 | ) SECTION_ASN; 36 | int32_t tilemap_asn_save( 37 | MEMORY_HANDLE h_buffer, int32_t idx, struct TILEMAP* t ) SECTION_ASN; 38 | 39 | /*! \} */ 40 | 41 | /*! \} */ 42 | 43 | #endif /* !TMASN_H */ 44 | 45 | -------------------------------------------------------------------------------- /src/tmjson.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef TMJSON_H 3 | #define TMJSON_H 4 | 5 | /** 6 | * \addtogroup dsekai_tilemaps 7 | * 8 | * \{ 9 | */ 10 | 11 | /*! \file tmjson.h 12 | * \brief Constants and functions for populating a TILEMAP from \ref json. 13 | */ 14 | 15 | #include "dsekai.h" 16 | 17 | /** 18 | * \addtogroup dsekai_tilemaps_json_format_sect Tilemaps JSON Format 19 | * 20 | * \{ 21 | * \page dsekai_tilemaps_json_format 22 | * 23 | * \} 24 | */ 25 | 26 | /*! \brief Maximum possible length of an individual dialog string. */ 27 | #define TILEMAP_JSON_STRBUF_SZ 128 28 | 29 | /** 30 | * \addtogroup dsekai_tilemaps_json_paths Tilemaps JSON Paths 31 | * \brief Paths to map properties in a Tiled \ref json file. 32 | * 33 | * All paths here use \ref json_paths syntax. 34 | * 35 | * Some paths use %%d conversion specifiers as placeholders for the index of a 36 | * discrete value being iterated over. 37 | * 38 | * \{ 39 | */ 40 | 41 | /** 42 | * \brief JSON path to script definition. 43 | * 44 | * Scripts are stored in map properties as "script_n", where n represents the 45 | * index of the script as referred to by MOBILE::script_id. 46 | * 47 | * Scripts are stored as sequences of a single character (shorthand for a 48 | * statement) followed by a number (an argument). They must be parsed by 49 | * ::script_parse_str. 50 | */ 51 | #define TILEMAP_JPATH_SCRIPT "/properties/[name=script_%d]/value" 52 | /*! \brief JSON path to string definition. */ 53 | #define TILEMAP_JPATH_STRING "/properties/[name=string_%d]/value" 54 | /*! \brief JSON path to TILEMAP::gid. */ 55 | #define TILEMAP_JPATH_GID "/properties/[name=gid]/value" 56 | /*! \brief JSON path to tileset source in map data. */ 57 | #define TILEMAP_JPATH_TS_SRC "/tilesets/0/source" 58 | /*! \brief JSON path to terrain tile TILEMAP::tileset index in map data. */ 59 | #define TILEMAP_JPATH_TILE "/layers/[name=terrain]/data/%d" 60 | /*! \brief JSON path to map name. */ 61 | #define TILEMAP_JPATH_PROP_NAME "/properties/[name=name]/value" 62 | /*! \brief JSON path to map engine type. */ 63 | #define TILEMAP_JPATH_PROP_ENGINE "/properties/[name=engine]/value" 64 | /*! \brief JSON path to weather property. */ 65 | #define TILEMAP_JPATH_PROP_WEATHER "/properties/[name=weather]/value" 66 | /*! \brief JSON path to editable property. */ 67 | #define TILEMAP_JPATH_PROP_EDITABLE "/properties/[name=editable]/value" 68 | /*! \brief JSON path to mobile tile X. */ 69 | #define TILEMAP_JPATH_MOB_X "/layers/[name=mobiles]/objects/%d/x" 70 | /*! \brief JSON path to mobile tile Y. */ 71 | #define TILEMAP_JPATH_MOB_Y "/layers/[name=mobiles]/objects/%d/y" 72 | /*! \brief JSON path to mobile name. */ 73 | #define TILEMAP_JPATH_MOB_NAME "/layers/[name=mobiles]/objects/%d/name" 74 | /*! \brief JSON path to TILEMAP_SPAWN::type. */ 75 | #define TILEMAP_JPATH_MOB_SPRITE "/layers/[name=mobiles]/objects/%d/class" 76 | /*! \brief JSON path to TILEMAP_SPAWN::gid. */ 77 | #define TILEMAP_JPATH_MOB_GID "/layers/[name=mobiles]/objects/%d/properties/[name=gid]/value" 78 | /*! \brief JSON path to mobile script index. */ 79 | #define TILEMAP_JPATH_MOB_SCRIPT "/layers/[name=mobiles]/objects/%d/properties/[name=script]/value" 80 | /*! \brief JSON path to mobile type. */ 81 | #define TILEMAP_JPATH_MOB_TYPE_FLAG "/layers/[name=mobiles]/objects/%d/properties/[name=type]/value" 82 | #define TILEMAP_JPATH_MOB_PLAYER_FLAG "/layers/[name=mobiles]/objects/%d/properties/[name=player]/value" 83 | #define TILEMAP_JPATH_MOB_ASCII "/layers/[name=mobiles]/objects/%d/properties/[name=ascii]/value" 84 | /*! \brief JSON path to TILESET_TILE::image. */ 85 | #define TILEMAP_JPATH_TS_TILE "/tiles/%d/image" 86 | /*! \brief JSON path to TILESET_TILE::flags. */ 87 | #define TILEMAP_JPATH_TS_FLAGS "/tiles/%d/properties/[name=flags]/value" 88 | #define TILEMAP_JPATH_TS_ASCII "/tiles/%d/properties/[name=ascii]/value" 89 | #define TILEMAP_JPATH_ITEM_GID "/layers/[name=items]/objects/%d/properties/[name=gid]/value" 90 | #define TILEMAP_JPATH_ITEM_NAME "/layers/[name=items]/objects/%d/name" 91 | #define TILEMAP_JPATH_ITEM_TYPE "/layers/[name=items]/objects/%d/class" 92 | #define TILEMAP_JPATH_ITEM_SPRITE "/layers/[name=items]/objects/%d/properties/[name=sprite]/value" 93 | #define TILEMAP_JPATH_ITEM_DATA "/layers/[name=items]/objects/%d/properties/[name=data]/value" 94 | #define TILEMAP_JPATH_ITEM_CRAFTABLE "/layers/[name=items]/objects/%d/properties/[name=craftable]/value" 95 | #define TILEMAP_JPATH_CROP_DEF_NAME "/layers/[name=crops]/objects/%d/name" 96 | #define TILEMAP_JPATH_CROP_DEF_GID "/layers/[name=crops]/objects/%d/properties/[name=gid]/value" 97 | #define TILEMAP_JPATH_CROP_DEF_CYCLE "/layers/[name=crops]/objects/%d/properties/[name=cycle]/value" 98 | #define TILEMAP_JPATH_CROP_DEF_REGROWS "/layers/[name=crops]/objects/%d/properties/[name=regrows]/value" 99 | #define TILEMAP_JPATH_CROP_DEF_SPRITE "/layers/[name=crops]/objects/%d/properties/[name=sprite]/value" 100 | #define TILEMAP_JPATH_CROP_DEF_PRODUCE_GID "/layers/[name=crops]/objects/%d/properties/[name=produce]/value" 101 | 102 | /*! \} */ 103 | 104 | /** 105 | * \brief Load tilemap specified by id into TILEMAP struct t. 106 | * \param id A RESOURCE_ID indicating the tilemap to load from disk. 107 | * \param t ::MEMORY_PTR to an empty TILEMAP struct to be loaded into. 108 | * \return 109 | */ 110 | int16_t tilemap_json_load( const RESOURCE_ID id, struct TILEMAP* t ); 111 | 112 | /*! \} */ 113 | 114 | #endif /* !TMJSON_H */ 115 | 116 | -------------------------------------------------------------------------------- /src/tmstruct.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef TMSTRUCTS_H 3 | #define TMSTRUCTS_H 4 | 5 | /** 6 | * \addtogroup dsekai_tilemaps 7 | * 8 | * \{ 9 | */ 10 | 11 | /*! \file tmstruct.h 12 | * \brief Structs representing tilemaps and related objects. 13 | */ 14 | 15 | #include "scstruct.h" 16 | 17 | /*! \brief Maximum number of SCRIPT structs attached to a tilemap. */ 18 | #define TILEMAP_SCRIPTS_MAX 8 19 | /*! \brief Maximum TILEMAP width in tiles. */ 20 | #define TILEMAP_TW 40 21 | /*! \brief Maximum TILEMAP height in tiles. */ 22 | #define TILEMAP_TH 40 23 | /*! \brief TILEMAP::tileset maximum length. */ 24 | #define TILEMAP_TILESETS_MAX 12 25 | #define TILEMAP_SPAWN_NAME_SZ 12 26 | /*! \brief Screen width in tiles. */ 27 | #define SCREEN_TW (SCREEN_MAP_W / TILE_W) 28 | /*! \brief Screen height in tiles. */ 29 | #define SCREEN_TH (SCREEN_MAP_H / TILE_H) 30 | #define TILEMAP_TS ((TILEMAP_TH * TILEMAP_TW) / 2) 31 | 32 | /*! \brief X/Y coordinates of a tile on the current map. */ 33 | struct TILEMAP_COORDS { 34 | /*! \brief Horizontal coordinate in tiles. */ 35 | uint8_t x; 36 | /*! \brief Vertical coordinate in tiles. */ 37 | uint8_t y; 38 | }; 39 | 40 | /*! \brief Tile prototype stored in TILEMAP::tileset. */ 41 | struct TILESET_TILE { 42 | /*! \brief Indentifier for graphical asset representing this tile. */ 43 | RESOURCE_NAME image_name; 44 | unsigned char ascii; 45 | /*! \brief Flags indicating behavior for this tile. */ 46 | uint8_t flags; 47 | /** 48 | * \brief Index of the tile image loaded in the 49 | * \ref unilayer_graphics_cache. 50 | */ 51 | uint16_t image_cache_id; 52 | }; 53 | 54 | /* TODO: Move spawner to mostruct.h for consistency. */ 55 | /*! \brief Defines a spawner to create mobiles in the world. 56 | * 57 | * Modifications to this struct should also be reflected in tools/map2h.c. 58 | */ 59 | struct TILEMAP_SPAWN { 60 | /*! \brief Internal name of a spawned MOBILE. */ 61 | char name[TILEMAP_SPAWN_NAME_SZ]; 62 | /* TODO: Allow a range of coordinates in which to spawn. */ 63 | /* TODO: Allow multiple spawns from single spawner. */ 64 | /*! \brief Tile-based coordinates at which to spawn. */ 65 | struct TILEMAP_COORDS coords; 66 | /** 67 | * \brief RESOURCE_NAME for the MOBILE::sprite on a spawned MOBILE. 68 | */ 69 | RESOURCE_NAME sprite_name; 70 | unsigned char ascii; 71 | /*! \brief \ref dsekai_mobile_flags to pass to spawned MOBILE::flags. */ 72 | uint16_t flags; 73 | /** 74 | * \brief Unique identifying number for this spawner loaded from tilemap. 75 | * 76 | * Passed to MOBILE::spawner_gid on spawned ::MOBILE objects. 77 | */ 78 | SPAWN_GID gid; 79 | /*! \brief Index of TILEMAP::scripts attached to mobiles spawned. */ 80 | int16_t script_id; 81 | }; 82 | 83 | /*! \brief Information pertaining to in-game world currently loaded. 84 | * 85 | * Modifications to this struct should also be reflected in tools/map2h.c. 86 | */ 87 | struct TILEMAP { 88 | /*! \brief Tilemap name. */ 89 | char name[TILEMAP_NAME_MAX]; 90 | /*! \brief Current \ref dsekai_tilemaps_flags. */ 91 | uint8_t flags; 92 | /** 93 | * \brief Globally unique ID for this tilemap. 94 | * 95 | * \attention This should not be set to ::MOBILE_MAP_GID_ALL, or weird 96 | * things will happen! 97 | */ 98 | TILEMAP_GID gid; 99 | /*! \brief Array of prototype tiles all map tiles are based on. */ 100 | struct TILESET_TILE tileset[TILEMAP_TILESETS_MAX]; 101 | /*! \brief Array of 4-bit numbers representing tiles composing the map. */ 102 | uint8_t tiles[(TILEMAP_TH * TILEMAP_TW) / 2]; 103 | /*! \brief Special flag bitfields indicating each tile's behavior. */ 104 | uint8_t tiles_flags[TILEMAP_TH * TILEMAP_TW]; 105 | /*! \brief Mobile spawns on this map. */ 106 | struct TILEMAP_SPAWN spawns[TILEMAP_SPAWNS_MAX]; 107 | /*! \brief Strings used in dialog/signs on this map. */ 108 | char strpool[TILEMAP_STRPOOL_SZ]; 109 | /* \brief Scripts available to attach to any MOBILE. */ 110 | struct SCRIPT scripts[TILEMAP_SCRIPTS_MAX]; 111 | /*! \brief Items able to be collected on this map. */ 112 | struct ITEM item_defs[TILEMAP_ITEMS_MAX]; 113 | /*! \brief Crops able to be grown on this map. */ 114 | struct CROP_DEF crop_defs[TILEMAP_CROP_DEFS_MAX]; 115 | /* struct WARP warps[TILEMAP_WARPS_MAX]; */ 116 | }; 117 | 118 | /*! \} */ 119 | 120 | #endif /* !TMSTRUCTS_H */ 121 | 122 | -------------------------------------------------------------------------------- /src/winceres.h: -------------------------------------------------------------------------------- 1 | #ifndef __NEWRES_H__ 2 | #define __NEWRES_H__ 3 | 4 | #if !defined(UNDER_CE) 5 | #define UNDER_CE _WIN32_WCE 6 | #endif 7 | 8 | #if defined(_WIN32_WCE) 9 | #if !defined(WCEOLE_ENABLE_DIALOGEX) 10 | #define DIALOGEX DIALOG DISCARDABLE 11 | #endif 12 | #include 13 | #define SHMENUBAR RCDATA 14 | #if defined(WIN32_PLATFORM_PSPC) && (_WIN32_WCE >= 300) 15 | #include 16 | #else 17 | #define I_IMAGENONE (-2) 18 | #define NOMENU 0xFFFF 19 | #define IDS_SHNEW 1 20 | 21 | #define IDM_SHAREDNEW 10 22 | #define IDM_SHAREDNEWDEFAULT 11 23 | #endif 24 | #endif // _WIN32_WCE 25 | 26 | 27 | #ifdef RC_INVOKED 28 | #ifndef _INC_WINDOWS 29 | #define _INC_WINDOWS 30 | #include "winuser.h" // extract from windows header 31 | #endif 32 | #endif 33 | 34 | #ifdef IDC_STATIC 35 | #undef IDC_STATIC 36 | #endif 37 | #define IDC_STATIC (-1) 38 | 39 | #endif //__NEWRES_H__ 40 | -------------------------------------------------------------------------------- /src/winids.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef WINIDS_H 3 | #define WINIDS_H 4 | 5 | /*! \brief Recommended WINDOW::id for the status window. */ 6 | #define WINDOW_ID_STATUS 111 7 | /*! \brief Recommended WINDOW::id for a script speech window. */ 8 | #define WINDOW_ID_SCRIPT_SPEAK 897 9 | /*! \brief WINDOW::id that can safely be used by on-screen menus. */ 10 | #define MENU_WINDOW_ID 786 11 | #define MENU_WINDOW_INFO_ID 787 12 | #define MENU_WINDOW_CRAFT_ID 789 13 | #define MENU_WINDOW_ITEM_SEL_ID 790 14 | #define MENU_WINDOW_ITEM_ICON 791 15 | #define WINDOW_ID_MENU_LABEL_ITEM 300 16 | #define WINDOW_ID_TITLE_MENU 687 17 | #define WINDOW_ID_MENU_LABEL_ITEM_SEL_USE 500 18 | 19 | #endif /* WINIDS_H */ 20 | 21 | -------------------------------------------------------------------------------- /src/winstat.h: -------------------------------------------------------------------------------- 1 | 2 | #define icon_dsekai 4001 3 | 4 | -------------------------------------------------------------------------------- /src/winstat.rc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #ifdef RESOURCE_WIN 5 | #ifdef PLATFORM_WIN32 6 | #include "../gen/win32/residx.h" 7 | #include "../gen/win32/win.rc" 8 | #elif defined( PLATFORM_WIN16 ) 9 | #include "../gen/win16/residx.h" 10 | #include "../gen/win16/win.rc" 11 | #endif /* PLATFORM_WIN16, PLATFORM_WIN32 */ 12 | #endif /* RESOURCE_WIN */ 13 | 14 | #include "winstat.h" 15 | 16 | icon_dsekai ICON "assets/dsekai.ico" 17 | 18 | -------------------------------------------------------------------------------- /tools/compile.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../src/dsekai.h" 9 | 10 | uint8_t g_flags = 0; 11 | 12 | #define CS_FLAG_VERBOSE 1 13 | 14 | int main( int argc, char** argv ) { 15 | int retval = 0; 16 | FILE* in_file = NULL; 17 | size_t in_sz = 0, 18 | in_read = 0, 19 | i = 0; 20 | uint8_t* in_bytes = NULL; 21 | struct SCRIPT_COMPILE_STATE s; 22 | struct SCRIPT_STEP steps[SCRIPT_STEPS_MAX]; 23 | char* filename = NULL; 24 | 25 | /* TODO: Use unilayer functions! */ 26 | 27 | debug_printf( 3, "compile compiled " __DATE__ __TIME__ ); 28 | debug_printf( 3, "git hash: " GIT_HASH ); 29 | 30 | for( i = 1 ; argc > i ; i++ ) { 31 | if( 0 == strncmp( "-v", argv[i], 2 ) ) { 32 | g_flags |= CS_FLAG_VERBOSE; 33 | } else { 34 | assert( NULL == filename ); 35 | filename = argv[i]; 36 | } 37 | } 38 | 39 | if( NULL == filename ) { 40 | error_printf( "usage:" ); 41 | error_printf( "%s ", argv[0] ); 42 | goto cleanup; 43 | } 44 | 45 | /* Open file. */ 46 | in_file = fopen( filename, "r" ); 47 | assert( NULL != in_file ); 48 | 49 | /* Get size. */ 50 | fseek( in_file, 0, SEEK_END ); 51 | in_sz = ftell( in_file ); 52 | fseek( in_file, 0, SEEK_SET ); 53 | 54 | /* Allocate, read. */ 55 | in_bytes = calloc( in_sz, 1 ); 56 | assert( NULL != in_bytes ); 57 | 58 | in_read = fread( in_bytes, 1, in_sz, in_file ); 59 | assert( in_read == in_sz ); 60 | 61 | /* Parse. */ 62 | memset( &s, '\0', sizeof( struct SCRIPT_COMPILE_STATE ) ); 63 | memset( &steps, '\0', sizeof( struct SCRIPT_STEP ) * SCRIPT_STEPS_MAX ); 64 | s.steps = steps; 65 | 66 | for( i = 0 ; in_sz > i ; i++ ) { 67 | script_parse_src( in_bytes[i], &s ); 68 | } 69 | 70 | /* Display bytes. */ 71 | printf( "\n" ); 72 | for( i = 0 ; s.steps_sz > i ; i++ ) { 73 | printf( "%c%d", gc_sc_bytes[s.steps[i].action], s.steps[i].arg ); 74 | } 75 | printf( "\n" ); 76 | 77 | cleanup: 78 | 79 | if( NULL != in_file ) { 80 | fclose( in_file ); 81 | } 82 | 83 | if( NULL != in_bytes ) { 84 | free( in_bytes ); 85 | } 86 | 87 | return retval; 88 | } 89 | 90 | -------------------------------------------------------------------------------- /tools/lookups.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define GRAPHICS_90DEG_RADS 1.5708 8 | #define GRAPHICS_RAY_ROTATE_INC (3 * GRAPHICS_90DEG_RADS) 9 | #define GRAPHICS_RAY_FOV 0.66 10 | 11 | void print_table_cga_bytes( 12 | FILE* hout, const char* type, const char* name, int my, int mx, int modulus, 13 | int offset 14 | ) { 15 | int y = 0, 16 | x = 0; 17 | 18 | fprintf( hout, "static const %s huge %s[%d][%d] = {\n", 19 | type, name, my, mx ); 20 | for( y = 0 ; my > y ; y++ ) { 21 | fprintf( hout, " {" ); 22 | for( x = 0 ; mx > x ; x++ ) { 23 | fprintf( hout, "0x%x", 24 | modulus ? 6 - (((((y / 2) * mx) + x) % 4) * 2) : 25 | (((y / 2) * mx) + x) / 4 ) + offset; 26 | if( x + 1 < mx ) { 27 | fprintf( hout, ", " ); 28 | } 29 | } 30 | fprintf( hout, "}" ); 31 | if( y + 1 < my ) { 32 | fprintf( hout, ",\n" ); 33 | } else { 34 | fprintf( hout, "\n" ); 35 | } 36 | } 37 | fprintf( hout, "};\n\n" ); 38 | } 39 | 40 | int main( int argc, char* argv[] ) { 41 | int x = 0, y = 0; 42 | double dir_x_right, 43 | dir_y_right, 44 | plane_x_right, 45 | plane_y_right, 46 | delta_dist_x, 47 | delta_dist_y, 48 | dir_x, 49 | dir_y, 50 | camera_x; 51 | FILE* hout = NULL; 52 | 53 | assert( argc == 3 ); 54 | 55 | hout = fopen( argv[2], "w" ); 56 | 57 | if( 0 == strncmp( "cga", argv[1], 3 ) ) { 58 | print_table_cga_bytes( 59 | hout, "uint16_t", "gc_offsets_cga_bytes_p1", 200, 320, 0, 0 ); 60 | print_table_cga_bytes( 61 | hout, "uint16_t", "gc_offsets_cga_bytes_p2", 200, 320, 0, 0 ); 62 | print_table_cga_bytes( 63 | hout, "uint8_t", "gc_offsets_cga_bits_p1", 200, 320, 1, 0 ); 64 | 65 | } else if( 0 == strncmp( "pov", argv[1], 3 ) ) { 66 | /* left */ 67 | fprintf( hout, "\n/* left */\n\n" ); 68 | 69 | fprintf( hout, "/* facing_x */\n%f,\n", 70 | 0 * cos( GRAPHICS_RAY_ROTATE_INC ) - 71 | -1 * sin( GRAPHICS_RAY_ROTATE_INC ) ); 72 | fprintf( hout, "/* facing_y */\n%f,\n", 73 | 0 * sin( GRAPHICS_RAY_ROTATE_INC ) + 74 | -1 * cos( GRAPHICS_RAY_ROTATE_INC ) ); 75 | fprintf( hout, "/* plane_x */\n%f,\n", 76 | GRAPHICS_RAY_FOV * cos( GRAPHICS_RAY_ROTATE_INC ) - 77 | 0 * sin( GRAPHICS_RAY_ROTATE_INC ) ); 78 | fprintf( hout, "/* plane_y */\n%f,\n", 79 | GRAPHICS_RAY_FOV * sin( GRAPHICS_RAY_ROTATE_INC ) + 80 | 0 * cos( GRAPHICS_RAY_ROTATE_INC ) ); 81 | 82 | /* right */ 83 | fprintf( hout, "\n/* right */\n\n" ); 84 | 85 | dir_x_right = 0 * cos( -GRAPHICS_RAY_ROTATE_INC ) - 86 | -1 * sin( -GRAPHICS_RAY_ROTATE_INC ); 87 | dir_y_right = 0 * sin( -GRAPHICS_RAY_ROTATE_INC ) + 88 | -1 * cos( -GRAPHICS_RAY_ROTATE_INC ); 89 | plane_x_right = GRAPHICS_RAY_FOV * cos(-GRAPHICS_RAY_ROTATE_INC ) - 90 | 0 * sin( -GRAPHICS_RAY_ROTATE_INC ); 91 | plane_y_right = GRAPHICS_RAY_FOV * sin( -GRAPHICS_RAY_ROTATE_INC ) + 92 | 0 * cos( -GRAPHICS_RAY_ROTATE_INC ); 93 | 94 | fprintf( hout, "/* facing_x */\n%f,\n", dir_x_right ); 95 | fprintf( hout, "/* facing_y */\n%f,\n", dir_y_right ); 96 | fprintf( hout, "/* plane_x */\n%f,\n", plane_x_right ); 97 | fprintf( hout, "/* plane_y */\n%f,\n", plane_y_right ); 98 | 99 | fprintf( hout, "\n/* fabs */\n\n" ); 100 | 101 | for( x = 0 ; 160 > x ; x++ ) { 102 | /* Setup ray direction and position. */ 103 | camera_x = 2 * x / (double)160 - 1; 104 | dir_x = dir_x_right + plane_x_right * camera_x; 105 | dir_y = dir_y_right + plane_y_right * camera_x; 106 | 107 | /* Set ray distance to next tile side. */ 108 | delta_dist_x = (0 == dir_x) ? 1e30 : fabs( 1 / dir_x ); 109 | delta_dist_y = (0 == dir_y) ? 1e30 : fabs( 1 / dir_y ); 110 | fprintf( hout, "/* dir_x */\n%f\n", dir_x_right ); 111 | fprintf( hout, "/* dir_y */\n%f\n", dir_y_right ); 112 | fprintf( hout, "/* delta_dist_x */\n%f\n", delta_dist_x ); 113 | fprintf( hout, "/* delta_dist_y */\n%f\n", delta_dist_y ); 114 | fprintf( hout, "\n" ); 115 | } 116 | 117 | 118 | } else { 119 | printf( "usage: lookups [cga|pov] " ); 120 | } 121 | 122 | fclose( hout ); 123 | 124 | return 0; 125 | } 126 | 127 | -------------------------------------------------------------------------------- /tools/map2asn.c: -------------------------------------------------------------------------------- 1 | 2 | #define ENGINES_TOKENS_ONLY 3 | #define ENGINES_C 4 | #define ITEM_C 5 | #define CROP_C 6 | #define MOBILE_C 7 | #define TILEMAP_C 8 | #include "../src/dsekai.h" 9 | 10 | #include "../src/tmjson.h" 11 | #include "../src/tmasn.h" 12 | 13 | void buffer_assign_short( uint8_t* buffer, uint16_t n ) { 14 | buffer[0] = ((n & 0xff00) >> 8); 15 | buffer[1] = (n & 0x00ff); 16 | } 17 | 18 | int main( int argc, char* argv[] ) { 19 | FILE* map_file = NULL, 20 | * asn_file = NULL; 21 | struct TILEMAP* t = NULL; 22 | int retval = 0, 23 | idx = 0; 24 | MEMORY_HANDLE h_buffer = (MEMORY_HANDLE)NULL, 25 | h_t = (MEMORY_HANDLE)NULL; 26 | uint8_t* buffer = NULL; 27 | 28 | debug_printf( 3, "map2asn compiled " __DATE__ __TIME__ ); 29 | debug_printf( 3, "git hash: " GIT_HASH ); 30 | 31 | if( 3 > argc ) { 32 | error_printf( "usage:" ); 33 | error_printf( "%s ", argv[0] ); 34 | error_printf( "in_json - JSON tilemap file to convert to ASN.1." ); 35 | error_printf( "out_asn - ASN.1 filename to create." ); 36 | retval = 1; 37 | goto cleanup; 38 | } 39 | 40 | h_t = memory_alloc( sizeof( struct TILEMAP ), 1 ); 41 | if( (MEMORY_HANDLE)NULL == h_t ) { 42 | error_printf( "could not allocate tilemap!" ); 43 | retval = 1; 44 | goto cleanup; 45 | } 46 | 47 | t = memory_lock( h_t ); 48 | assert( NULL != t ); 49 | 50 | retval = tilemap_json_load( argv[1], t ); 51 | if( !retval ) { 52 | retval = 1; 53 | goto cleanup; 54 | } 55 | retval = 0; 56 | 57 | h_buffer = memory_alloc( TILEMAP_ASN_SAVE_BUFFER_INITIAL_SZ, 1 ); 58 | 59 | idx = tilemap_asn_save( h_buffer, 0, t ); 60 | if( 0 > idx ) { 61 | error_printf( "could not write tilemap!" ); 62 | goto cleanup; 63 | } 64 | 65 | /* Write the ASN map file to disk. */ 66 | save_write( argv[2], h_buffer, idx ); 67 | 68 | debug_printf( 3, "%d bytes written", idx ); 69 | 70 | cleanup: 71 | 72 | if( NULL != t ) { 73 | t = memory_unlock( h_t ); 74 | } 75 | 76 | if( (MEMORY_HANDLE)NULL != h_t ) { 77 | memory_free( h_t ); 78 | } 79 | 80 | if( NULL != buffer ) { 81 | buffer = memory_unlock( h_buffer ); 82 | } 83 | 84 | if( (MEMORY_HANDLE)NULL != h_buffer ) { 85 | memory_free( h_buffer ); 86 | } 87 | 88 | return retval; 89 | } 90 | 91 | --------------------------------------------------------------------------------