From 05bfcbae9cbe9db4797ef2703c4d37f511608fe6 Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Mon, 10 May 2021 19:38:02 +0800 Subject: replace get_local_time function --- asm/Makefile | 10 ++++++++-- asm/rich4.asm | 33 +++++---------------------------- asm/rich4_time.c | 17 +++++++++++++++++ asm/rich4_time.h | 16 ++++++++++++++++ csrc/rich4_time.c | 17 ----------------- csrc/rich4_time.h | 16 ---------------- 6 files changed, 46 insertions(+), 63 deletions(-) create mode 100644 asm/rich4_time.c create mode 100644 asm/rich4_time.h delete mode 100644 csrc/rich4_time.c delete mode 100644 csrc/rich4_time.h diff --git a/asm/Makefile b/asm/Makefile index 17df9dc..410fa8f 100644 --- a/asm/Makefile +++ b/asm/Makefile @@ -1,11 +1,17 @@ CROSS=i686-w64-mingw32- +CC=$(CROSS)gcc LD=$(CROSS)ld LDFLAGS=-e fcn_0045709c LIBS=-lgdi32 -luser32 -lkernel32 -lwinmm -ldsound -lddraw LIBS+=-lmsvcrt -%.exe: %.obj - $(LD) -o $@ $< $(LDFLAGS) $(LIBS) +OBJS = rich4.obj rich4_time.obj + +rich4.exe: $(OBJS) + $(LD) -o $@ $(OBJS) $(LDFLAGS) $(LIBS) %.obj: %.asm nasm -f win32 $< + +%.obj: %.c + $(CC) $(CFLAGS) -c -o $@ $< diff --git a/asm/rich4.asm b/asm/rich4.asm index 209004d..8594823 100644 --- a/asm/rich4.asm +++ b/asm/rich4.asm @@ -130,6 +130,8 @@ extern _memcpy extern _strlen extern _memcmp +extern _get_local_time + section .text db 0xcc db 0xeb @@ -22525,7 +22527,7 @@ cmp ebx, 3 jl short loc_00411a01 ; jl 0x411a01 mov eax, esp push eax -call fcn_00458331 ; call 0x458331 +call _get_local_time ; call 0x458331 add esp, 4 xor eax, eax mov ax, word [esp + 2] @@ -22573,7 +22575,7 @@ fcn_00411aa3: sub esp, 8 mov eax, esp push eax -call fcn_00458331 ; call 0x458331 +call _get_local_time ; call 0x458331 add esp, 4 xor eax, eax mov ax, word [esp + 2] @@ -22970,7 +22972,7 @@ add esp, 0xc loc_00411f1e: mov eax, esp push eax -call fcn_00458331 ; call 0x458331 +call _get_local_time ; call 0x458331 add esp, 4 mov edx, dword [esp + 2] cmp dx, 0x7ce @@ -118700,31 +118702,6 @@ pop edi pop esi ret -fcn_00458331: -push ebx -sub esp, 0x10 -mov ebx, dword [esp + 0x18] -mov eax, esp -push eax -call dword [cs:__imp__GetLocalTime@4] ; ucall: call dword cs:[0x4623b0] -mov al, byte [esp + 6] -mov byte [ebx], al -mov al, byte [esp + 2] -mov byte [ebx + 1], al -mov eax, dword [esp] -mov word [ebx + 2], ax -mov al, byte [esp + 4] -mov byte [ebx + 4], al -add esp, 0x10 -pop ebx -ret - -endloc_00458363: -db 0x00 -dd 0x00000000 -dd 0x00000000 -dd 0x00000000 - fcn_00458370: push edx mov eax, dword [esp + 8] diff --git a/asm/rich4_time.c b/asm/rich4_time.c new file mode 100644 index 0000000..fafac33 --- /dev/null +++ b/asm/rich4_time.c @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2018 Iru Cai + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include +#include "rich4_time.h" + +void get_local_time(rich4_time *t) +{ + SYSTEMTIME st; + GetLocalTime(&st); + t->day = st.wDay; + t->month = st.wMonth; + t->year = st.wYear; + t->dayofweek = st.wDayOfWeek; +} diff --git a/asm/rich4_time.h b/asm/rich4_time.h new file mode 100644 index 0000000..0f88d28 --- /dev/null +++ b/asm/rich4_time.h @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2018 Iru Cai + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include + +typedef struct +{ + uint8_t day; + uint8_t month; + uint16_t year; + uint16_t dayofweek; +} rich4_time; + +void get_local_time(rich4_time *t); diff --git a/csrc/rich4_time.c b/csrc/rich4_time.c deleted file mode 100644 index fafac33..0000000 --- a/csrc/rich4_time.c +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (C) 2018 Iru Cai - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -#include -#include "rich4_time.h" - -void get_local_time(rich4_time *t) -{ - SYSTEMTIME st; - GetLocalTime(&st); - t->day = st.wDay; - t->month = st.wMonth; - t->year = st.wYear; - t->dayofweek = st.wDayOfWeek; -} diff --git a/csrc/rich4_time.h b/csrc/rich4_time.h deleted file mode 100644 index 0f88d28..0000000 --- a/csrc/rich4_time.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (C) 2018 Iru Cai - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -#include - -typedef struct -{ - uint8_t day; - uint8_t month; - uint16_t year; - uint16_t dayofweek; -} rich4_time; - -void get_local_time(rich4_time *t); -- cgit v1.2.3