added werror, slider doesn't freeze the game

This commit is contained in:
Hay1tsme 2022-01-05 05:07:29 -05:00 committed by Hay1tsme
parent f4e151c4ef
commit 2e7c7c1fe0
3 changed files with 52 additions and 51 deletions

View File

@ -35,6 +35,7 @@ static const struct hook_symbol win32_hooks[] = {
HRESULT elisabeth_hook_init() HRESULT elisabeth_hook_init()
{ {
dll_hook_insert_hooks(NULL); dll_hook_insert_hooks(NULL);
return S_OK;
} }
static void dll_hook_insert_hooks(HMODULE target) static void dll_hook_insert_hooks(HMODULE target)
@ -55,7 +56,7 @@ FARPROC WINAPI my_GetProcAddress(HMODULE hModule, const char *name)
if (ordinal > 0xFFFF) { if (ordinal > 0xFFFF) {
/* Import by name */ /* Import by name */
if (strcmp(name, "USBIntLED_Init") == 0) { if (strcmp(name, "USBIntLED_Init") == 0) {
result = my_USBIntLED_Init; result = (FARPROC) my_USBIntLED_Init;
} }
} }

View File

@ -21,16 +21,16 @@
#include "util/dprintf.h" #include "util/dprintf.h"
#include "util/dump.h" #include "util/dump.h"
static HRESULT touch0_handle_irp(struct irp *irp); static HRESULT touch_handle_irp(struct irp *irp);
static HRESULT touch0_handle_irp_locked(struct irp *irp); static HRESULT touch0_handle_irp_locked(struct irp *irp);
static HRESULT touch1_handle_irp(struct irp *irp);
static HRESULT touch1_handle_irp_locked(struct irp *irp); static HRESULT touch1_handle_irp_locked(struct irp *irp);
static HRESULT touch_req_dispatch(const struct touch_req *req); static HRESULT touch_req_dispatch(const struct touch_req *req);
static HRESULT touch_frame_decode(struct touch_req *dest, const struct iobuf *iobuf, int side); static HRESULT touch_frame_decode(struct touch_req *dest, struct iobuf *iobuf, int side);
static HRESULT touch_handle_get_rev_date(const struct touch_req *req); static HRESULT touch_handle_get_rev_date(const struct touch_req *req);
static HRESULT touch_handle_startup(const struct touch_req *req);
static CRITICAL_SECTION touch0_lock; static CRITICAL_SECTION touch0_lock;
static struct uart touch0_uart; static struct uart touch0_uart;
@ -68,25 +68,29 @@ HRESULT touch_hook_init(const struct touch_config *cfg)
touch1_uart.readable.bytes = touch1_readable_bytes; touch1_uart.readable.bytes = touch1_readable_bytes;
touch1_uart.readable.nbytes = sizeof(touch1_readable_bytes); touch1_uart.readable.nbytes = sizeof(touch1_readable_bytes);
iohook_push_handler(touch0_handle_irp); return iohook_push_handler(touch_handle_irp);
iohook_push_handler(touch1_handle_irp);
return S_OK;
} }
static HRESULT touch0_handle_irp(struct irp *irp) static HRESULT touch_handle_irp(struct irp *irp)
{ {
HRESULT hr; HRESULT hr;
assert(irp != NULL); assert(irp != NULL);
if (!uart_match_irp(&touch0_uart, irp)) { if (uart_match_irp(&touch0_uart, irp)) {
EnterCriticalSection(&touch0_lock);
hr = touch0_handle_irp_locked(irp);
LeaveCriticalSection(&touch0_lock);
}
else if (uart_match_irp(&touch1_uart, irp)) {
EnterCriticalSection(&touch1_lock);
hr = touch1_handle_irp_locked(irp);
LeaveCriticalSection(&touch1_lock);
}
else {
return iohook_invoke_next(irp); return iohook_invoke_next(irp);
} }
EnterCriticalSection(&touch0_lock);
hr = touch0_handle_irp_locked(irp);
LeaveCriticalSection(&touch0_lock);
return hr; return hr;
} }
@ -132,26 +136,11 @@ static HRESULT touch0_handle_irp_locked(struct irp *irp)
if (FAILED(hr)) { if (FAILED(hr)) {
dprintf("Wacca touch: Processing error: %x\n", (int) hr); dprintf("Wacca touch: Processing error: %x\n", (int) hr);
} }
return hr;
} }
} }
static HRESULT touch1_handle_irp(struct irp *irp)
{
HRESULT hr;
assert(irp != NULL);
if (!uart_match_irp(&touch1_uart, irp)) {
return iohook_invoke_next(irp);
}
EnterCriticalSection(&touch1_lock);
hr = touch1_handle_irp_locked(irp);
LeaveCriticalSection(&touch1_lock);
return hr;
}
static HRESULT touch1_handle_irp_locked(struct irp *irp) static HRESULT touch1_handle_irp_locked(struct irp *irp)
{ {
struct touch_req req; struct touch_req req;
@ -180,7 +169,7 @@ static HRESULT touch1_handle_irp_locked(struct irp *irp)
dump_iobuf(&touch1_uart.written); dump_iobuf(&touch1_uart.written);
#endif #endif
hr = touch_frame_decode(&req, &touch0_uart.written, 1); hr = touch_frame_decode(&req, &touch1_uart.written, 1);
if (hr != S_OK) { if (hr != S_OK) {
if (FAILED(hr)) { if (FAILED(hr)) {
@ -195,6 +184,8 @@ static HRESULT touch1_handle_irp_locked(struct irp *irp)
if (FAILED(hr)) { if (FAILED(hr)) {
dprintf("Wacca touch: Processing error: %x\n", (int) hr); dprintf("Wacca touch: Processing error: %x\n", (int) hr);
} }
return hr;
} }
} }
@ -203,6 +194,8 @@ static HRESULT touch_req_dispatch(const struct touch_req *req)
switch (req->cmd) { switch (req->cmd) {
case CMD_GET_REV_DATE: case CMD_GET_REV_DATE:
return touch_handle_get_rev_date(req); return touch_handle_get_rev_date(req);
case CMD_STARTUP:
return touch_handle_startup(req);
default: default:
dprintf("Wacca touch: Unhandled command %02x\n", req->cmd); dprintf("Wacca touch: Unhandled command %02x\n", req->cmd);
@ -213,40 +206,40 @@ static HRESULT touch_req_dispatch(const struct touch_req *req)
static HRESULT touch_handle_get_rev_date(const struct touch_req *req) static HRESULT touch_handle_get_rev_date(const struct touch_req *req)
{ {
dprintf("Wacca Touch%d: Get board rev date\n", req->side); dprintf("Wacca Touch%d: Get board rev date\n", req->side);
if (req->side) { if (req->side == 0) {
touch0_uart.readable.bytes[0] = 0xa0; // TODO: a0 31 39 30 35 32 33 2c
touch0_uart.readable.bytes[1] = 0x31;
touch0_uart.readable.bytes[2] = 0x39;
touch0_uart.readable.bytes[3] = 0x30;
touch0_uart.readable.bytes[4] = 0x35;
touch0_uart.readable.bytes[5] = 0x32;
touch0_uart.readable.bytes[6] = 0x33;
touch0_uart.readable.bytes[7] = 0x2c;
} }
else { else {
touch1_uart.readable.bytes[0] = 0xa0; // TODO: see above
touch1_uart.readable.bytes[1] = 0x31;
touch1_uart.readable.bytes[2] = 0x39;
touch1_uart.readable.bytes[3] = 0x30;
touch1_uart.readable.bytes[4] = 0x35;
touch1_uart.readable.bytes[5] = 0x32;
touch1_uart.readable.bytes[6] = 0x33;
touch1_uart.readable.bytes[7] = 0x2c;
} }
return S_OK; return S_OK;
} }
static HRESULT touch_frame_decode(struct touch_req *dest, const struct iobuf *iobuf, int side) static HRESULT touch_handle_startup(const struct touch_req *req)
{
dprintf("Wacca Touch%d: Startup\n", req->side);
if (req->side == 0) {
// TODO: 20 20 20 20 30 20 20 20 20 30 20 20 20 20 31 20 20 20 20 32 20 20 20 20 33 20 20 20 20 34 20 20 20 20 35 20 20 20 31 35 20 20 20 31 35 20 20 20 31 35 20 20 20 31 35 20 20 20 31 35 20 20 20 31 35 20 20 20 31 31 20 20 20 31 31 20 20 20 31 31 0d
}
else {
// TODO: see above
}
return S_OK;
}
static HRESULT touch_frame_decode(struct touch_req *dest, struct iobuf *iobuf, int side)
{ {
dest->side = side; dest->side = side;
dest->cmd = iobuf->bytes[0]; dest->cmd = iobuf->bytes[0];
dest->data_length = _countof(iobuf->bytes) - 1; iobuf->pos--;
dest->data_length = iobuf->pos;
if (dest->data_length > 0) { if (dest->data_length > 0) {
for (int i = 1; i < dest->data_length; i++) { for (int i = 1; i < dest->data_length; i++) {
dest->data[i-1] = iobuf->bytes[i]; dest->data[i-1] = iobuf->bytes[i];
} }
} }
iobuf->pos -= dest->data_length;
return S_OK; return S_OK;
} }

View File

@ -1,4 +1,11 @@
project('segatools', 'c', version: '0.1.0') project(
'segatools',
'c',
version: '0.1.0',
default_options: [
'werror=true',
],
)
add_project_arguments( add_project_arguments(
'-DCOBJMACROS', '-DCOBJMACROS',