Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
File renamed without changes.
21 changes: 21 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM --platform=amd64 debian:11.6-slim@sha256:f7d141c1ec6af549958a7a2543365a7829c2cdc4476308ec2e182f8a7c59b519

LABEL description="Development environment for bemanitools"

# mingw-w64-gcc has 32-bit and 64-bit toolchains
RUN apt-get update && apt-get install -y --no-install-recommends \
mingw-w64 \
mingw-w64-common \
make \
zip \
git \
clang-format \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

RUN pip3 install mdformat

RUN mkdir /bemanitools
WORKDIR /bemanitools

ENV SHELL /bin/bash
38 changes: 29 additions & 9 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ BUILDDIR ?= build

builddir_docker := $(BUILDDIR)/docker

docker_container_name := "bemanitools-build"
docker_image_name := "bemanitools-build:latest"
docker_build_container_name := "bemanitools-build"
docker_build_image_name := "bemanitools-build:latest"
docker_dev_container_name := "bemanitools-dev"
docker_dev_image_name := "bemanitools-dev:latest"

depdir := $(BUILDDIR)/dep
objdir := $(BUILDDIR)/obj
Expand All @@ -41,6 +43,7 @@ FORCE:

.PHONY: \
build-docker \
dev-docker \
clean \
code-format \
doc-format \
Expand Down Expand Up @@ -89,21 +92,38 @@ version:
$(V)echo "$(gitrev)" > version

build-docker:
$(V)docker rm -f $(docker_container_name) 2> /dev/null || true
$(V)docker rm -f $(docker_build_container_name) 2> /dev/null || true
$(V)docker \
build \
-t $(docker_image_name) \
-f Dockerfile \
-t $(docker_build_image_name) \
-f Dockerfile.build \
.
$(V)docker \
run \
--volume $(shell pwd):/bemanitools \
--name $(docker_container_name) \
$(docker_image_name)
--name $(docker_build_container_name) \
$(docker_build_image_name)

dev-docker:
$(V)docker rm -f $(docker_dev_container_name) 2> /dev/null || true
$(V)docker \
build \
-t $(docker_dev_image_name) \
-f Dockerfile.dev \
.
$(V)docker \
run \
--interactive \
--tty \
--volume $(shell pwd):/bemanitools \
--name $(docker_dev_container_name) \
$(docker_dev_image_name)

clean-docker:
$(V)docker rm -f $(docker_container_name) || true
$(V)docker image rm -f $(docker_image_name) || true
$(V)docker rm -f $(docker_dev_container_name) || true
$(V)docker image rm -f $(docker_dev_image_name) || true
$(V)docker rm -f $(docker_build_container_name) || true
$(V)docker image rm -f $(docker_build_image_name) || true
$(V)rm -rf $(BUILDDIR)

#
Expand Down
5 changes: 5 additions & 0 deletions Module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ include src/main/bstio/Module.mk
include src/main/camhook/Module.mk
include src/main/cconfig/Module.mk
include src/main/config/Module.mk
include src/main/core/Module.mk
include src/main/d3d9-util/Module.mk
include src/main/d3d9exhook/Module.mk
include src/main/ddrhook-util/Module.mk
Expand Down Expand Up @@ -710,6 +711,8 @@ $(zipdir)/ddr-14-to-18.zip: \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/geninput.dll \
dist/ddr/config.bat \
dist/ddr/gamestart-17.bat \
dist/ddr/gamestart-18.bat \
dist/ddr/gamestart-14.bat \
dist/ddr/gamestart-15.bat \
dist/ddr/gamestart-16.bat \
Expand All @@ -728,6 +731,8 @@ $(zipdir)/ddr-16-to-18-x64.zip: \
build/bin/indep-64/eamio.dll \
build/bin/indep-64/geninput.dll \
dist/ddr/config.bat \
dist/ddr/gamestart-17.bat \
dist/ddr/gamestart-18.bat \
dist/ddr/gamestart-16.bat \
dist/ddr/gamestart-17.bat \
dist/ddr/gamestart-18.bat \
Expand Down
31 changes: 31 additions & 0 deletions src/api/log.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef BEMANITOOLS_API_THREAD_H
#define BEMANITOOLS_API_THREAD_H

#include <stdint.h>

#ifdef __GNUC__
/* Bemanitools is compiled with GCC (MinGW, specifically) as of version 5 */
#define LOG_CHECK_FMT __attribute__((format(printf, 2, 3)))
#else
/* Compile it out for MSVC plebs */
#define LOG_CHECK_FMT
#endif

/* An AVS-style logger function. Comes in four flavors: misc, info, warning,
and fatal, with increasing severity. Fatal loggers do not return, they
abort the running process after writing their message to the log.

"module" is an arbitrary short string identifying the source of the log
message. The name of the calling DLL is a good default choice for this
string, although you might want to identify a module within your DLL here
instead.

"fmt" is a printf-style format string. Depending on the context in which
your DLL is running you might end up calling a logger function exported
from libavs, which has its own printf implementation (including a number of
proprietary extensions), so don't use any overly exotic formats. */

typedef void (*btapi_log_formatter_t)(const char *module, const char *fmt, ...)
LOG_CHECK_FMT;

#endif
20 changes: 20 additions & 0 deletions src/api/thread.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef BEMANITOOLS_API_THREAD_H
#define BEMANITOOLS_API_THREAD_H

#include <stdint.h>

/* An API for spawning threads. This API is defined by libavs, although
Bemanitools itself may supply compatible implementations of these functions
to your DLL, depending on the context in which it runs.

NOTE: You may only use the logging functions from a thread where Bemanitools
calls you, or a thread that you create using this API. Failure to observe
this restriction will cause the process to crash. This is a limitation of
libavs itself, not Bemanitools. */

typedef int (*btapi_thread_create_t)(
int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority);
typedef void (*btapi_thread_join_t)(int thread_id, int *result);
typedef void (*btapi_thread_destroy_t)(int thread_id);

#endif
3 changes: 3 additions & 0 deletions src/imports/avs.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ void property_file_write(struct property *prop, const char *path);
int property_set_flag(struct property *prop, int flags, int mask);
void property_destroy(struct property *prop);

avs_error property_get_error(struct property *prop);
void property_clear_error(struct property *prop);

int property_psmap_import(
struct property *prop,
struct property_node *root,
Expand Down
2 changes: 2 additions & 0 deletions src/imports/import_32_0_avs.def
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ EXPORTS
property_destroy
property_file_write
property_insert_read
property_clear_error
property_get_error
property_mem_write
property_read_query_memsize
property_search
Expand Down
2 changes: 2 additions & 0 deletions src/imports/import_32_1002_avs.def
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ EXPORTS
property_destroy
property_file_write
property_insert_read
property_clear_error
property_get_error
property_mem_write
property_read_query_memsize
property_search
Expand Down
2 changes: 2 additions & 0 deletions src/imports/import_32_1101_avs.def
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ EXPORTS
property_desc_to_buffer @246 NONAME
property_destroy @247 NONAME
property_insert_read @255 NONAME
property_clear_error @573 NONAME
property_get_error @573 NONAME
property_node_create @266 NONAME
property_node_datasize @267 NONAME
property_node_name @274 NONAME
Expand Down
2 changes: 2 additions & 0 deletions src/imports/import_32_1304_avs.def
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ EXPORTS
property_desc_to_buffer @201 NONAME
property_destroy @264 NONAME
property_insert_read @23 NONAME
property_clear_error @573 NONAME
property_get_error @573 NONAME
property_node_create @316 NONAME
property_node_datasize @249 NONAME
property_node_name @255 NONAME
Expand Down
2 changes: 2 additions & 0 deletions src/imports/import_32_1306_avs.def
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ EXPORTS
property_desc_to_buffer @201 NONAME == XC058ba50000cd
property_destroy @264 NONAME == XC058ba500010f
property_insert_read @23 NONAME == XC058ba5000016
property_clear_error @573 NONAME
property_get_error @573 NONAME
property_node_create @316 NONAME == XC058ba5000143
property_node_datasize @249 NONAME == XC058ba5000100
property_node_name @255 NONAME == XC058ba5000106
Expand Down
2 changes: 2 additions & 0 deletions src/imports/import_32_1403_avs.def
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ EXPORTS
property_desc_to_buffer @131 NONAME
property_destroy @130 NONAME
property_insert_read @133 NONAME
property_clear_error @573 NONAME
property_get_error @573 NONAME
property_node_name @573 NONAME ==
property_node_read @573 NONAME ==
property_node_remove @148 NONAME
Expand Down
2 changes: 2 additions & 0 deletions src/imports/import_32_1508_avs.def
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ EXPORTS
property_desc_to_buffer @129 NONAME
property_destroy @128 NONAME
property_insert_read @131 NONAME
property_clear_error @573 NONAME
property_get_error @573 NONAME
property_node_create @145 NONAME
property_node_name @150 NONAME
property_node_read @154 NONAME == XCd229cc0000f3
Expand Down
2 changes: 2 additions & 0 deletions src/imports/import_32_1601_avs.def
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ EXPORTS
property_destroy @125 NONAME
property_desc_to_buffer @126 NONAME
property_insert_read @128 NONAME
property_clear_error @573 NONAME
property_get_error @573 NONAME
property_search @141 NONAME
property_node_create @142 NONAME
property_node_name @147 NONAME == XCnbrep7000092
Expand Down
2 changes: 2 additions & 0 deletions src/imports/import_32_1603_avs.def
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ EXPORTS
property_destroy @146 NONAME
property_desc_to_buffer @147 NONAME
property_insert_read @149 NONAME
property_clear_error @158 NONAME == XCnbrep700009d
property_get_error @159 NONAME == XCnbrep700009e
property_search @162 NONAME
property_node_create @163 NONAME
property_node_name @168 NONAME == XCnbrep70000a7
Expand Down
2 changes: 2 additions & 0 deletions src/imports/import_32_1700_avs.def
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ EXPORTS
property_destroy @146 NONAME
property_desc_to_buffer @147 NONAME
property_insert_read @149 NONAME
property_clear_error @158 NONAME == XCgsqzn000009d
property_get_error @159 NONAME == XCgsqzn000009e
property_search @162 NONAME
property_node_create @163 NONAME
property_node_name @168 NONAME == XCgsqzn00000a7
Expand Down
2 changes: 2 additions & 0 deletions src/imports/import_32_803_avs.def
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ EXPORTS
property_destroy
property_file_write
property_insert_read
property_clear_error
property_get_error
property_mem_write
property_read_query_memsize
property_search
Expand Down
2 changes: 2 additions & 0 deletions src/imports/import_64_1508_avs.def
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ EXPORTS
property_desc_to_buffer @129 NONAME
property_destroy @128 NONAME
property_insert_read @131 NONAME
property_clear_error @573 NONAME
property_get_error @573 NONAME
property_node_create @145 NONAME
property_node_name @150 NONAME
property_node_read @154 NONAME == XCd229cc0000f3
Expand Down
2 changes: 2 additions & 0 deletions src/imports/import_64_1509_avs.def
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ EXPORTS
property_desc_to_buffer @129 NONAME
property_destroy @128 NONAME
property_insert_read @131 NONAME
property_clear_error @573 NONAME
property_get_error @573 NONAME
property_node_create @145 NONAME
property_node_name @573 NONAME ==
property_node_read @573 NONAME ==
Expand Down
2 changes: 2 additions & 0 deletions src/imports/import_64_1601_avs.def
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ EXPORTS
property_destroy @125 NONAME
property_desc_to_buffer @126 NONAME
property_insert_read @128 NONAME
property_clear_error @573 NONAME
property_get_error @573 NONAME
property_search @141 NONAME
property_node_create @142 NONAME
property_node_name @147 NONAME == XCnbrep7000092
Expand Down
4 changes: 3 additions & 1 deletion src/imports/import_64_1603_avs.def
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ EXPORTS
property_destroy @146 NONAME
property_desc_to_buffer @147 NONAME
property_insert_read @149 NONAME
property_clear_error @158 NONAME == XCnbrep700009d
property_get_error @159 NONAME == XCnbrep700009e
property_search @162 NONAME
property_node_create @163 NONAME
property_node_name @168 NONAME == XCnbrep70000a7
property_node_remove @164 NONAME
property_node_type @169 NONAME == XCnbrep70000a8
property_node_clone @165 NONAME
property_node_clone @165 NONAME == XCnbrep70000a4
property_node_traversal @167 NONAME
property_node_refdata @166 NONAME == XCnbrep70000a5
property_node_datasize @171 NONAME == XCnbrep70000aa
Expand Down
2 changes: 2 additions & 0 deletions src/imports/import_64_1700_avs.def
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ EXPORTS
property_destroy @146 NONAME
property_desc_to_buffer @147 NONAME
property_insert_read @149 NONAME
property_clear_error @158 NONAME == XCgsqzn000009d
property_get_error @159 NONAME == XCgsqzn000009e
property_search @162 NONAME
property_node_create @163 NONAME
property_node_name @168 NONAME == XCgsqzn00000a7
Expand Down
1 change: 1 addition & 0 deletions src/main/aciodrv-proc/Module.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
libs += aciodrv-proc

libs_aciodrv-proc := \
core \

src_aciodrv-proc := \
panb.c \
Expand Down
11 changes: 6 additions & 5 deletions src/main/aciodrv-proc/panb.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#include "aciodrv/device.h"
#include "aciodrv/panb.h"

#include "util/log.h"
#include "util/thread.h"
#include "core/thread.h"

#include "core/log.h"

static int auto_poll_proc(void *auto_poll_param);
static int auto_poll_threadid;
Expand Down Expand Up @@ -50,7 +51,7 @@ bool aciodrv_proc_panb_init(struct aciodrv_device_ctx *device)
InitializeCriticalSection(&keypair_lock);
InitializeCriticalSection(&auto_poll_stop_lock);
auto_poll_threadid =
thread_create(auto_poll_proc, (void *) device, 0x4000, 0);
core_thread_create(auto_poll_proc, (void *) device, 0x4000, 0);

return true;
}
Expand Down Expand Up @@ -80,8 +81,8 @@ void aciodrv_proc_panb_fini(struct aciodrv_device_ctx *device)
auto_poll_stop = true;
LeaveCriticalSection(&auto_poll_stop_lock);

thread_join(auto_poll_threadid, NULL);
thread_destroy(auto_poll_threadid);
core_thread_join(auto_poll_threadid, NULL);
core_thread_destroy(auto_poll_threadid);

DeleteCriticalSection(&keypair_lock);
DeleteCriticalSection(&auto_poll_stop_lock);
Expand Down
3 changes: 2 additions & 1 deletion src/main/aciodrv/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

#include "aciodrv/port.h"

#include "core/log.h"

#include "util/hex.h"
#include "util/log.h"
#include "util/mem.h"

/* Enable to dump all data to the logger */
Expand Down
2 changes: 1 addition & 1 deletion src/main/aciodrv/h44b.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "aciodrv/device.h"

#include "util/log.h"
#include "core/log.h"

bool aciodrv_h44b_init(struct aciodrv_device_ctx *device, uint8_t node_id)
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/aciodrv/icca.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "aciodrv/device.h"
#include "aciodrv/icca.h"

#include "util/log.h"
#include "core/log.h"

static bool aciodrv_icca_queue_loop_start(
struct aciodrv_device_ctx *device, uint8_t node_id)
Expand Down
Loading