mirror of
https://github.com/isledecomp/isle.git
synced 2024-11-24 08:38:29 -05:00
Bootstrap MxSmack (#343)
* Bootstrap MxSmack * Add comment about incorrect structure * Fix naming * Fix name * Add a comment about SDK * Add names from Smacker SDK * Use SMACK.LIB and interface * Use RAD.H defined types * Use different commets * Fix member offset * Update mxsmack.cpp
This commit is contained in:
parent
994d17a85e
commit
db60467ba3
9 changed files with 914 additions and 110 deletions
401
3rdparty/smack/RAD.H
vendored
Normal file
401
3rdparty/smack/RAD.H
vendored
Normal file
|
@ -0,0 +1,401 @@
|
|||
#ifndef __RAD__
|
||||
#define __RAD__
|
||||
|
||||
#define RADCOPYRIGHT "Copyright (c) RAD Software, 1994-95."
|
||||
|
||||
|
||||
// __RADDOS__ means DOS code (16 or 32 bit)
|
||||
// __RAD16__ means 16 bit code (Win16)
|
||||
// __RAD32__ means 32 bit code (DOS, Win386, Win32s, Mac)
|
||||
// __RADWIN__ means Windows code (Win16, Win386, Win32s)
|
||||
// __RADWINEXT__ means Windows 386 extender (Win386)
|
||||
// __RADNT__ means Win32s code
|
||||
// __RADMAC__ means Macintosh
|
||||
// __RAD68K__ means 68K Macintosh
|
||||
// __RADPPC__ means PowerMac
|
||||
|
||||
|
||||
#if defined(__MWERKS__) || defined(THINK_C) || defined(powerc) || defined(macintosh) || defined(__powerc)
|
||||
|
||||
#define __RADMAC__
|
||||
#if defined(powerc) || defined(__powerc)
|
||||
#define __RADPPC__
|
||||
#else
|
||||
#define __RAD68K__
|
||||
#endif
|
||||
|
||||
#define __RAD32__
|
||||
|
||||
#else
|
||||
|
||||
#ifdef __DOS__
|
||||
#define __RADDOS__
|
||||
#endif
|
||||
|
||||
#ifdef __386__
|
||||
#define __RAD32__
|
||||
#endif
|
||||
|
||||
#ifdef _Windows //For Borland
|
||||
#ifdef __WIN32__
|
||||
#define WIN32
|
||||
#else
|
||||
#define __WINDOWS__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS //For MS
|
||||
#ifndef _WIN32
|
||||
#define __WINDOWS__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define __RADWIN__
|
||||
#define __RADNT__
|
||||
#define __RAD32__
|
||||
#else
|
||||
#ifdef __NT__
|
||||
#define __RADNT__
|
||||
#define __RAD32__
|
||||
#define __RADWIN__
|
||||
#else
|
||||
#ifdef __WINDOWS_386__
|
||||
#define __RADWIN__
|
||||
#define __RADWINEXT__
|
||||
#define __RAD32__
|
||||
#else
|
||||
#ifdef __WINDOWS__
|
||||
#define __RADWIN__
|
||||
#define __RAD16__
|
||||
#else
|
||||
#ifdef WIN32
|
||||
#define __RADWIN__
|
||||
#define __RADNT__
|
||||
#define __RAD32__
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(__RADDOS__) && !defined(__RADWIN__) && !defined(__RADMAC__)
|
||||
#error RAD.H didn'y detect your platform. Define __DOS__, __WINDOWS__, WIN32, macintosh, or powerc.
|
||||
#endif
|
||||
|
||||
#ifdef __RADMAC__
|
||||
#define RADLINK
|
||||
#define RADEXPLINK
|
||||
#define RADASMLINK
|
||||
#else
|
||||
|
||||
#ifdef __RADNT__
|
||||
#ifndef _WIN32
|
||||
#define _WIN32
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define RADDLLIMP
|
||||
|
||||
#ifdef __RADWIN__
|
||||
#ifdef __RAD32__
|
||||
#ifdef __RADNT__
|
||||
#define RADEXPLINK __cdecl
|
||||
#ifndef __RADINDLL_
|
||||
#undef RADDLLIMP
|
||||
#define RADDLLIMP __declspec(dllimport)
|
||||
#endif
|
||||
#ifdef __WATCOMC__
|
||||
#define RADLINK __pascal
|
||||
#else
|
||||
#define RADLINK
|
||||
#endif
|
||||
#else
|
||||
#define RADLINK __pascal
|
||||
#define RADEXPLINK __far __pascal
|
||||
#endif
|
||||
#else
|
||||
#define RADLINK __far __pascal
|
||||
#define RADEXPLINK __export __far __pascal
|
||||
#endif
|
||||
#else
|
||||
#define RADLINK __pascal
|
||||
#define RADEXPLINK __pascal
|
||||
#endif
|
||||
|
||||
#define RADASMLINK __cdecl
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define RCFUNC extern "C"
|
||||
#define RCSTART extern "C" {
|
||||
#define RCEND }
|
||||
#else
|
||||
#define RCFUNC
|
||||
#define RCSTART
|
||||
#define RCEND
|
||||
#endif
|
||||
|
||||
|
||||
RCSTART
|
||||
|
||||
#define s8 signed char
|
||||
#define u8 unsigned char
|
||||
#define u32 unsigned long
|
||||
#define s32 signed long
|
||||
|
||||
#ifdef __RAD32__
|
||||
#define PTR4
|
||||
|
||||
#define u16 unsigned short
|
||||
#define s16 signed short
|
||||
|
||||
#ifdef __RADMAC__
|
||||
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
#include <OSUtils.h>
|
||||
|
||||
#define radstrlen strlen
|
||||
|
||||
#define radmemset memset
|
||||
|
||||
#define radmemcpy(dest,source,size) BlockMoveData((Ptr)(source),(Ptr)(dest),size)
|
||||
|
||||
#define radmemcpydb(dest,source,size) BlockMoveData((Ptr)(source),(Ptr)(dest),size)
|
||||
|
||||
#define radstrcpy strcpy
|
||||
|
||||
#ifdef __RAD68K__
|
||||
|
||||
#pragma parameter __D0 mult64anddiv(__D0,__D1,__D2)
|
||||
u32 mult64anddiv(u32 m1,u32 m2,u32 d) FOURWORDINLINE(0x4C01,0x0C01,0x4C42,0x0C01);
|
||||
// muls.l d1,d1:d0 divs.l d2,d1:d0
|
||||
|
||||
#pragma parameter radconv32a(__A0,__D0)
|
||||
void radconv32a(void* p,u32 n) NINEWORDINLINE(0x4A80,0x600C,0x2210,0xE059,0x4841,0xE059,0x20C1,0x5380,0x6EF2);
|
||||
// tst.l d0 bra.s @loope @loop: move.l (a0),d1 ror.w #8,d1 swap d1 ror.w #8,d1 move.l d1,(a0)+ sub.l #1,d0 bgt.s @loop @loope:
|
||||
|
||||
#else
|
||||
|
||||
u32 mult64anddiv(u32 m1,u32 m2,u32 d);
|
||||
|
||||
void radconv32a(void* p,u32 n);
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
|
||||
u32 mult64anddiv(u32 m1,u32 m2,u32 d);
|
||||
#pragma aux mult64anddiv = "mul ecx" "div ebx" parm [eax] [ecx] [ebx] modify [EDX eax];
|
||||
|
||||
s32 radabs(s32 ab);
|
||||
#pragma aux radabs = "test eax,eax" "jge skip" "neg eax" "skip:" parm [eax];
|
||||
|
||||
#define radabs32 radabs
|
||||
|
||||
u32 DOSOut(char* str);
|
||||
#pragma aux DOSOut = "cld" "mov ecx,0xffffffff" "xor eax,eax" "mov edx,edi" "repne scasb" "not ecx" "dec ecx" "mov ebx,1" "mov ah,0x40" "int 0x21" parm [EDI] modify [EAX EBX ECX EDX EDI] value [ecx];
|
||||
|
||||
void DOSOutNum(char* str,u32 len);
|
||||
#pragma aux DOSOutNum = "mov ah,0x40" "mov ebx,1" "int 0x21" parm [edx] [ecx] modify [eax ebx];
|
||||
|
||||
u32 ErrOut(char* str);
|
||||
#pragma aux ErrOut = "cld" "mov ecx,0xffffffff" "xor eax,eax" "mov edx,edi" "repne scasb" "not ecx" "dec ecx" "xor ebx,ebx" "mov ah,0x40" "int 0x21" parm [EDI] modify [EAX EBX ECX EDX EDI] value [ecx];
|
||||
|
||||
void ErrOutNum(char* str,u32 len);
|
||||
#pragma aux ErrOutNum = "mov ah,0x40" "xor ebx,ebx" "int 0x21" parm [edx] [ecx] modify [eax ebx];
|
||||
|
||||
void radmemset16(void* dest,u16 value,u32 size);
|
||||
#pragma aux radmemset16 = "cld" "mov bx,ax" "shl eax,16" "mov ax,bx" "mov bl,cl" "shr ecx,1" "rep stosd" "mov cl,bl" "and cl,1" "rep stosb" parm [EDI] [EAX] [ECX] modify [EAX EDX EBX ECX EDI];
|
||||
|
||||
void radmemset(void* dest,u8 value,u32 size);
|
||||
#pragma aux radmemset = "cld" "mov ah,al" "mov bx,ax" "shl eax,16" "mov ax,bx" "mov bl,cl" "shr ecx,2" "rep stosd" "mov cl,bl" "and cl,3" "rep stosb" parm [EDI] [AL] [ECX] modify [EAX EDX EBX ECX EDI];
|
||||
|
||||
void radmemcpy(void* dest,void* source,u32 size);
|
||||
#pragma aux radmemcpy = "cld" "mov bl,cl" "shr ecx,2" "rep movsd" "mov cl,bl" "and cl,3" "rep movsb" parm [EDI] [ESI] [ECX] modify [EBX ECX EDI ESI];
|
||||
|
||||
void __far *radfmemcpy(void __far* dest,void __far* source,u32 size);
|
||||
#pragma aux radfmemcpy = "cld" "push es" "push ds" "mov es,cx" "mov ds,dx" "mov ecx,eax" "shr ecx,2" "rep movsd" "mov cl,al" "and cl,3" "rep movsb" "pop ds" "pop es" parm [CX EDI] [DX ESI] [EAX] modify [ECX EDI ESI] value [CX EDI];
|
||||
|
||||
void radmemcpydb(void* dest,void* source,u32 size); //Destination bigger
|
||||
#pragma aux radmemcpydb = "std" "mov bl,cl" "lea esi,[esi+ecx-4]" "lea edi,[edi+ecx-4]" "shr ecx,2" "rep movsd" "and bl,3" "jz dne" "add esi,3" "add edi,3" "mov cl,bl" "rep movsb" "dne:" "cld" parm [EDI] [ESI] [ECX] modify [EBX ECX EDI ESI];
|
||||
|
||||
char* radstrcpy(void* dest,void* source);
|
||||
#pragma aux radstrcpy = "cld" "mov edx,edi" "lp:" "mov al,[esi]" "inc esi" "mov [edi],al" "inc edi" "cmp al,0" "jne lp" parm [EDI] [ESI] modify [EAX EDX EDI ESI] value [EDX];
|
||||
|
||||
char __far* radfstrcpy(void __far* dest,void __far* source);
|
||||
#pragma aux radfstrcpy = "cld" "push es" "push ds" "mov es,cx" "mov ds,dx" "mov edx,edi" "lp:" "lodsb" "stosb" "test al,0xff" "jnz lp" "pop ds" "pop es" parm [CX EDI] [DX ESI] modify [EAX EDX EDI ESI] value [CX EDX];
|
||||
|
||||
char* radstpcpy(void* dest,void* source);
|
||||
#pragma aux radstpcpy = "cld" "lp:" "mov al,[esi]" "inc esi" "mov [edi],al" "inc edi" "cmp al,0" "jne lp" "dec edi" parm [EDI] [ESI] modify [EAX EDI ESI] value [EDI];
|
||||
|
||||
char* radstpcpyrs(void* dest,void* source);
|
||||
#pragma aux radstpcpyrs = "cld" "lp:" "lodsb" "stosb" "test al,0xff" "jnz lp" "dec edi" parm [EDI] [ESI] modify [EAX EDI ESI] value [ESI];
|
||||
|
||||
u32 radstrlen(void* dest);
|
||||
#pragma aux radstrlen = "cld" "mov ecx,0xffffffff" "xor eax,eax" "repne scasb" "not ecx" "dec ecx" parm [EDI] modify [EAX ECX EDI] value [ECX];
|
||||
|
||||
char* radstrcat(void* dest,void* source);
|
||||
#pragma aux radstrcat = "cld" "mov ecx,0xffffffff" "mov edx,edi" "xor eax,eax" "repne scasb" "dec edi" "lp:" "lodsb" "stosb" "test al,0xff" "jnz lp" \
|
||||
parm [EDI] [ESI] modify [EAX ECX EDI ESI] value [EDX];
|
||||
|
||||
char* radstrchr(void* dest,char chr);
|
||||
#pragma aux radstrchr = "cld" "lp:" "lodsb" "cmp al,dl" "je fnd" "cmp al,0" "jnz lp" "mov esi,1" "fnd:" "dec esi" parm [ESI] [DL] modify [EAX ESI] value [esi];
|
||||
|
||||
s8 radmemcmp(void* s1,void* s2,u32 len);
|
||||
#pragma aux radmemcmp = "cld" "rep cmpsb" "setne al" "jbe end" "neg al" "end:" parm [EDI] [ESI] [ECX] modify [ECX EDI ESI];
|
||||
|
||||
s8 radstrcmp(void* s1,void* s2);
|
||||
#pragma aux radstrcmp = "lp:" "mov al,[esi]" "mov ah,[edi]" "cmp al,ah" "jne set" "cmp al,0" "je set" "inc esi" "inc edi" "jmp lp" "set:" "setne al" "jbe end" "neg al" "end:" \
|
||||
parm [EDI] [ESI] modify [EAX EDI ESI];
|
||||
|
||||
s8 radstricmp(void* s1,void* s2);
|
||||
#pragma aux radstricmp = "lp:" "mov al,[esi]" "mov ah,[edi]" "cmp al,'a'" "jb c1" "cmp al,'z'" "ja c1" "sub al,32" "c1:" "cmp ah,'a'" "jb c2" "cmp ah,'z'" "ja c2" "sub ah,32" "c2:" "cmp al,ah" "jne set" "cmp al,0" "je set" \
|
||||
"inc esi" "inc edi" "jmp lp" "set:" "setne al" "jbe end" "neg al" "end:" \
|
||||
parm [EDI] [ESI] modify [EAX EDI ESI];
|
||||
|
||||
s8 radstrnicmp(void* s1,void* s2,u32 len);
|
||||
#pragma aux radstrnicmp = "lp:" "mov al,[esi]" "mov ah,[edi]" "cmp al,'a'" "jb c1" "cmp al,'z'" "ja c1" "sub al,32" "c1:" "cmp ah,'a'" "jb c2" "cmp ah,'z'" "ja c2" "sub ah,32" "c2:" "cmp al,ah" "jne set" "cmp al,0" "je set" \
|
||||
"dec ecx" "jz set" "inc esi" "inc edi" "jmp lp" "set:" "setne al" "jbe end" "neg al" "end:" \
|
||||
parm [EDI] [ESI] [ECX] modify [EAX ECX EDI ESI];
|
||||
|
||||
char* radstrupr(void* s1);
|
||||
#pragma aux radstrupr = "mov ecx,edi" "lp:" "mov al,[edi]" "cmp al,'a'" "jb c1" "cmp al,'z'" "ja c1" "sub [edi],32" "c1:" "inc edi" "cmp al,0" "jne lp" parm [EDI] modify [EAX EDI] value [ecx];
|
||||
|
||||
char* radstrlwr(void* s1);
|
||||
#pragma aux radstrlwr = "mov ecx,edi" "lp:" "mov al,[edi]" "cmp al,'A'" "jb c1" "cmp al,'Z'" "ja c1" "add [edi],32" "c1:" "inc edi" "cmp al,0" "jne lp" parm [EDI] modify [EAX EDI] value [ecx];
|
||||
|
||||
u32 radstru32(void* dest);
|
||||
#pragma aux radstru32 = "cld" "xor ecx,ecx" "xor ebx,ebx" "xor edi,edi" "lodsb" "cmp al,45" "jne skip2" "mov edi,1" "jmp skip" "lp:" "mov eax,10" "mul ecx" "lea ecx,[eax+ebx]" \
|
||||
"skip:" "lodsb" "skip2:" "cmp al,0x39" "ja dne" "cmp al,0x30" "jb dne" "mov bl,al" "sub bl,0x30" "jmp lp" "dne:" "test edi,1" "jz pos" "neg ecx" "pos:" \
|
||||
parm [ESI] modify [EAX EBX EDX EDI ESI] value [ecx];
|
||||
|
||||
u16 GetDS();
|
||||
#pragma aux GetDS = "mov ax,ds" value [ax];
|
||||
|
||||
#ifdef __RADWINEXT__
|
||||
|
||||
u32 GetBase(u16 sel);
|
||||
#pragma aux GetBase = "mov bx,ax" "mov ax,6" "int 0x31" "shrd eax,ecx,16" "mov ax,dx" parm [ax] modify [ax bx cx dx] value [eax];
|
||||
|
||||
#define _16To32(ptr16) ((void*)(((GetBase((u16)(((u32)(ptr16))>>16))+((u16)(u32)(ptr16)))-GetBase(GetDS()))))
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef __RADWIN__
|
||||
#define int86 int386
|
||||
#define int86x int386x
|
||||
#endif
|
||||
|
||||
#define u32regs x
|
||||
#define u16regs w
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define PTR4 __far
|
||||
|
||||
#define u16 unsigned int
|
||||
#define s16 signed int
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
|
||||
s16 radabs(s16 ab);
|
||||
#pragma aux radabs = "test ax,ax" "jge skip" "neg ax" "skip:" parm [ax] value [ax];
|
||||
|
||||
s32 radabs32(s32 ab);
|
||||
#pragma aux radabs32 = "test dx,dx" "jge skip" "neg dx" "neg ax" "sbb dx,0" "skip:" parm [dx ax] value [dx ax];
|
||||
|
||||
u32 DOSOut(char far* dest);
|
||||
#pragma aux DOSOut = "cld" "and edi,0xffff" "mov dx,di" "mov ecx,0xffffffff" "xor eax,eax" 0x67 "repne scasb" "not ecx" "dec ecx" "mov bx,1" "push ds" "push es" "pop ds" "mov ah,0x40" "int 0x21" "pop ds" "movzx eax,cx" "shr ecx,16" \
|
||||
parm [ES DI] modify [AX BX CX DX DI ES] value [CX AX];
|
||||
|
||||
void DOSOutNum(char far* str,u16 len);
|
||||
#pragma aux DOSOutNum = "push ds" "mov ds,cx" "mov cx,bx" "mov ah,0x40" "mov bx,1" "int 0x21" "pop ds" parm [cx dx] [bx] modify [ax bx cx];
|
||||
|
||||
u32 ErrOut(char far* dest);
|
||||
#pragma aux ErrOut = "cld" "and edi,0xffff" "mov dx,di" "mov ecx,0xffffffff" "xor eax,eax" 0x67 "repne scasb" "not ecx" "dec ecx" "xor bx,bx" "push ds" "push es" "pop ds" "mov ah,0x40" "int 0x21" "pop ds" "movzx eax,cx" "shr ecx,16" \
|
||||
parm [ES DI] modify [AX BX CX DX DI ES] value [CX AX];
|
||||
|
||||
void ErrOutNum(char far* str,u16 len);
|
||||
#pragma aux ErrOutNum = "push ds" "mov ds,cx" "mov cx,bx" "mov ah,0x40" "xor bx,bx" "int 0x21" "pop ds" parm [cx dx] [bx] modify [ax bx cx];
|
||||
|
||||
void radmemset(void far *dest,u8 value,u32 size);
|
||||
#pragma aux radmemset = "cld" "and edi,0ffffh" "shl ecx,16" "mov cx,bx" "mov ah,al" "mov bx,ax" "shl eax,16" "mov ax,bx" "mov bl,cl" "shr ecx,2" 0x67 "rep stosd" "mov cl,bl" "and cl,3" "rep stosb" parm [ES DI] [AL] [CX BX];
|
||||
|
||||
void radmemcpy(void far* dest,void far* source,u32 size);
|
||||
#pragma aux radmemcpy = "cld" "push ds" "mov ds,dx" "and esi,0ffffh" "and edi,0ffffh" "shl ecx,16" "mov cx,bx" "shr ecx,2" 0x67 "rep movsd" "mov cl,bl" "and cl,3" "rep movsb" "pop ds" parm [ES DI] [DX SI] [CX BX] modify [CX SI DI ES];
|
||||
|
||||
char far* radstrcpy(void far* dest,void far* source);
|
||||
#pragma aux radstrcpy = "cld" "push ds" "mov ds,dx" "and esi,0xffff" "and edi,0xffff" "mov dx,di" "lp:" "lodsb" "stosb" "test al,0xff" "jnz lp" "pop ds" parm [ES DI] [DX SI] modify [AX DX DI SI ES] value [es dx];
|
||||
|
||||
char far* radstpcpy(void far* dest,void far* source);
|
||||
#pragma aux radstpcpy = "cld" "push ds" "mov ds,dx" "and esi,0xffff" "and edi,0xffff" "lp:" "lodsb" "stosb" "test al,0xff" "jnz lp" "dec di" "pop ds" parm [ES DI] [DX SI] modify [DI SI ES] value [es di];
|
||||
|
||||
u32 radstrlen(void far* dest);
|
||||
#pragma aux radstrlen = "cld" "and edi,0xffff" "mov ecx,0xffffffff" "xor eax,eax" 0x67 "repne scasb" "not ecx" "dec ecx" "movzx eax,cx" "shr ecx,16" parm [ES DI] modify [AX CX DI ES] value [CX AX];
|
||||
|
||||
char far* radstrcat(void far* dest,void far* source);
|
||||
#pragma aux radstrcat = "cld" "and edi,0xffff" "mov ecx,0xffffffff" "and esi,0xffff" "push ds" "mov ds,dx" "mov dx,di" "xor eax,eax" 0x67 "repne scasb" "dec edi" "lp:" "lodsb" "stosb" "test al,0xff" "jnz lp" "pop ds" \
|
||||
parm [ES DI] [DX SI] modify [AX CX DI SI ES] value [es dx];
|
||||
|
||||
char far* radstrchr(void far* dest,char chr);
|
||||
#pragma aux radstrchr = "cld" "lp:" 0x26 "lodsb" "cmp al,dl" "je fnd" "cmp al,0" "jnz lp" "xor ax,ax" "mov es,ax" "mov si,1" "fnd:" "dec si" parm [ES SI] [DL] modify [AX SI ES] value [es si];
|
||||
|
||||
s8 radstricmp(void far* s1,void far* s2);
|
||||
#pragma aux radstricmp = "and edi,0xffff" "push ds" "mov ds,dx" "and esi,0xffff" "lp:" "mov al,[esi]" "mov ah,[edi]" "cmp al,'a'" "jb c1" "cmp al,'z'" "ja c1" "sub al,32" "c1:" \
|
||||
"cmp ah,'a'" "jb c2" "cmp ah,'z'" "ja c2" "sub ah,32" "c2:" "cmp al,ah" "jne set" "cmp al,0" "je set" \
|
||||
"inc esi" "inc edi" "jmp lp" "set:" "setne al" "jbe end" "neg al" "end:" "pop ds" \
|
||||
parm [ES DI] [DX SI] modify [AX DI SI];
|
||||
|
||||
u32 radstru32(void far* dest);
|
||||
#pragma aux radstru32 = "cld" "xor ecx,ecx" "xor ebx,ebx" "xor edi,edi" "lodsb" "cmp al,45" "jne skip2" "mov edi,1" "jmp skip" "lp:" "mov eax,10" "mul ecx" "lea ecx,[eax+ebx]" \
|
||||
"skip:" 0x26 "lodsb" "skip2:" "cmp al,0x39" "ja dne" "cmp al,0x30" "jb dne" "mov bl,al" "sub bl,0x30" "jmp lp" "dne:" "test edi,1" "jz pos" "neg ecx" "pos:" \
|
||||
"movzx eax,cx" "shr ecx,16" parm [ES SI] modify [AX BX DX DI SI] value [cx ax];
|
||||
|
||||
u32 mult64anddiv(u32 m1,u32 m2,u32 d);
|
||||
#pragma aux mult64anddiv = "shl ecx,16" "mov cx,ax" "shrd eax,edx,16" "mov ax,si" "mul ecx" "shl edi,16" "mov di,bx" "div edi" "shld edx,eax,16" "and edx,0xffff" "and eax,0xffff" parm [cx ax] [dx si] [di bx] \
|
||||
modify [ax bx cx dx si di] value [dx ax];
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
RCEND
|
||||
|
||||
RCFUNC void PTR4* RADLINK radmalloc(u32 numbytes);
|
||||
RCFUNC void RADLINK radfree(void PTR4* ptr);
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
|
||||
char bkbhit();
|
||||
#pragma aux bkbhit = "mov ah,1" "int 0x16" "lahf" "shr eax,14" "and eax,1" "xor al,1" ;
|
||||
|
||||
char bgetch();
|
||||
#pragma aux bgetch = "xor ah,ah" "int 0x16" "test al,0xff" "jnz done" "mov al,ah" "or al,0x80" "done:" modify [AX];
|
||||
|
||||
void BreakPoint();
|
||||
#pragma aux BreakPoint = "int 3";
|
||||
|
||||
u8 radinp(u16 p);
|
||||
#pragma aux radinp = "in al,dx" parm [DX];
|
||||
|
||||
u8 radtoupper(u8 p);
|
||||
#pragma aux radtoupper = "cmp al,'a'" "jb c1" "cmp al,'z'" "ja c1" "sub al,32" "c1:" parm [al] value [al];
|
||||
|
||||
void radoutp(u16 p,u8 v);
|
||||
#pragma aux radoutp = "out dx,al" parm [DX] [AL];
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
307
3rdparty/smack/SMACK.H
vendored
Normal file
307
3rdparty/smack/SMACK.H
vendored
Normal file
|
@ -0,0 +1,307 @@
|
|||
#ifndef SMACKH
|
||||
#define SMACKH
|
||||
|
||||
#include "rad.h"
|
||||
|
||||
RCSTART
|
||||
|
||||
#define SMACKVERSION "2.0y"
|
||||
|
||||
typedef struct SmackSumTag {
|
||||
u32 TotalTime; // total time
|
||||
u32 MS100PerFrame; // MS*100 per frame (100000/MS100PerFrame=Frames/Sec)
|
||||
u32 TotalOpenTime; // Time to open and prepare for decompression
|
||||
u32 TotalFrames; // Total Frames displayed
|
||||
u32 SkippedFrames; // Total number of skipped frames
|
||||
u32 TotalBlitTime; // Total time spent blitting
|
||||
u32 TotalReadTime; // Total time spent reading
|
||||
u32 TotalDecompTime; // Total time spent decompressing
|
||||
u32 TotalBackReadTime; // Total time spent reading in background
|
||||
u32 TotalReadSpeed; // Total io speed (bytes/second)
|
||||
u32 SlowestFrameTime; // Slowest single frame time
|
||||
u32 Slowest2FrameTime; // Second slowest single frame time
|
||||
u32 SlowestFrameNum; // Slowest single frame number
|
||||
u32 Slowest2FrameNum; // Second slowest single frame number
|
||||
u32 AverageFrameSize; // Average size of the frame
|
||||
u32 Highest1SecRate; // Highest 1 sec data rate
|
||||
u32 Highest1SecFrame; // Highest 1 sec data rate starting frame
|
||||
u32 HighestMemAmount; // Highest amount of memory allocated
|
||||
u32 TotalExtraMemory; // Total extra memory allocated
|
||||
u32 HighestExtraUsed; // Highest extra memory actually used
|
||||
} SmackSum;
|
||||
|
||||
typedef struct SmackTag {
|
||||
u32 Version; // SMK2 only right now
|
||||
u32 Width; // Width (1 based, 640 for example)
|
||||
u32 Height; // Height (1 based, 480 for example)
|
||||
u32 Frames; // Number of frames (1 based, 100 = 100 frames)
|
||||
u32 MSPerFrame; // Frame Rate
|
||||
u32 SmackerType; // bit 0 set=ring frame
|
||||
u32 LargestInTrack[7]; // Largest single size for each track
|
||||
u32 tablesize; // Size of the init tables
|
||||
u32 codesize; // Compression info
|
||||
u32 absize; // ditto
|
||||
u32 detailsize; // ditto
|
||||
u32 typesize; // ditto
|
||||
u32 TrackType[7]; // high byte=0x80-Comp,0x40-PCM data,0x20-16 bit,0x10-stereo
|
||||
u32 extra; // extra value (should be zero)
|
||||
u32 NewPalette; // set to one if the palette changed
|
||||
u8 Palette[772]; // palette data
|
||||
u32 FrameNum; // Frame Number to be displayed
|
||||
u32 LastRectx; // Rect set in from SmackToBufferRect (X coord)
|
||||
u32 LastRecty; // Rect set in from SmackToBufferRect (Y coord)
|
||||
u32 LastRectw; // Rect set in from SmackToBufferRect (Width)
|
||||
u32 LastRecth; // Rect set in from SmackToBufferRect (Height)
|
||||
u32 OpenFlags; // flags used on open
|
||||
u32 LeftOfs; // Left Offset used in SmackTo
|
||||
u32 TopOfs; // Top Offset used in SmackTo
|
||||
} Smack;
|
||||
|
||||
#define SmackHeaderSize(smk) ((((u8*)&((smk)->extra))-((u8*)(smk)))+4)
|
||||
|
||||
//=======================================================================
|
||||
#define SMACKNEEDPAN 0x00020L // Will be setting the pan
|
||||
#define SMACKNEEDVOLUME 0x00040L // Will be setting the volume
|
||||
#define SMACKFRAMERATE 0x00080L // Override fr (call SmackFrameRate first)
|
||||
#define SMACKLOADEXTRA 0x00100L // Load the extra buffer during SmackOpen
|
||||
#define SMACKPRELOADALL 0x00200L // Preload the entire animation
|
||||
#define SMACKNOSKIP 0x00400L // Don't skip frames if falling behind
|
||||
#define SMACKSIMULATE 0x00800L // Simulate the speed (call SmackSim first)
|
||||
#define SMACKFILEHANDLE 0x01000L // Use when passing in a file handle
|
||||
#define SMACKTRACK1 0x02000L // Play audio track 1
|
||||
#define SMACKTRACK2 0x04000L // Play audio track 2
|
||||
#define SMACKTRACK3 0x08000L // Play audio track 3
|
||||
#define SMACKTRACK4 0x10000L // Play audio track 4
|
||||
#define SMACKTRACK5 0x20000L // Play audio track 5
|
||||
#define SMACKTRACK6 0x40000L // Play audio track 6
|
||||
#define SMACKTRACK7 0x80000L // Play audio track 7
|
||||
#define SMACKTRACKS (SMACKTRACK1|SMACKTRACK2|SMACKTRACK3|SMACKTRACK4|SMACKTRACK5|SMACKTRACK6|SMACKTRACK7)
|
||||
|
||||
#define SMACKAUTOEXTRA 0xffffffffL // NOT A FLAG! - Use as extrabuf param
|
||||
//=======================================================================
|
||||
|
||||
#define SMACKSURFACEFAST 0
|
||||
#define SMACKSURFACESLOW 1
|
||||
#define SMACKSURFACEDIRECT 2
|
||||
|
||||
|
||||
Smack PTR4* RADEXPLINK SmackOpen(char PTR4* name,u32 flags,u32 extrabuf);
|
||||
|
||||
#ifdef __RADMAC__
|
||||
#include <files.h>
|
||||
|
||||
Smack PTR4* RADEXPLINK SmackMacOpen(FSSpec* fsp,u32 flags,u32 extrabuf);
|
||||
#endif
|
||||
|
||||
u32 RADEXPLINK SmackDoFrame(Smack PTR4* smk);
|
||||
void RADEXPLINK SmackNextFrame(Smack PTR4* smk);
|
||||
u32 RADEXPLINK SmackWait(Smack PTR4* smk);
|
||||
void RADEXPLINK SmackClose(Smack PTR4* smk);
|
||||
|
||||
void RADEXPLINK SmackVolumePan(Smack PTR4* smk, u32 trackflag,u32 volume,u32 pan);
|
||||
|
||||
void RADEXPLINK SmackSummary(Smack PTR4* smk,SmackSum PTR4* sum);
|
||||
|
||||
u32 RADEXPLINK SmackSoundInTrack(Smack PTR4* smk,u32 trackflags);
|
||||
u32 RADEXPLINK SmackSoundOnOff(Smack PTR4* smk,u32 on);
|
||||
|
||||
#ifdef __RADMAC__
|
||||
void RADEXPLINK SmackToScreen(Smack PTR4* smk,u32 left,u32 top);
|
||||
#else
|
||||
void RADEXPLINK SmackToScreen(Smack PTR4* smk,u32 left,u32 top,u32 BytesPS,u16 PTR4* WinTbl,u32 SetBank);
|
||||
#endif
|
||||
|
||||
void RADEXPLINK SmackToBuffer(Smack PTR4* smk,u32 left,u32 top,u32 Pitch,u32 destheight,void PTR4* buf,u32 Reversed);
|
||||
u32 RADEXPLINK SmackToBufferRect(Smack PTR4* smk, u32 SmackSurface);
|
||||
|
||||
void RADEXPLINK SmackGoto(Smack PTR4* smk,u32 frame);
|
||||
void RADEXPLINK SmackColorRemap(Smack PTR4* smk,void PTR4* remappal,u32 numcolors,u32 paltype);
|
||||
void RADEXPLINK SmackColorTrans(Smack PTR4* smk,void PTR4* trans);
|
||||
void RADEXPLINK SmackFrameRate(u32 forcerate);
|
||||
void RADEXPLINK SmackSimulate(u32 sim);
|
||||
|
||||
u32 RADEXPLINK SmackGetTrackData(Smack PTR4* smk,void PTR4* dest,u32 trackflag);
|
||||
|
||||
void RADEXPLINK SmackSoundCheck();
|
||||
|
||||
//======================================================================
|
||||
#ifdef __RADDOS__
|
||||
|
||||
#define SMACKSOUNDNONE -1
|
||||
|
||||
extern void* cdecl SmackTimerSetupAddr;
|
||||
extern void* cdecl SmackTimerReadAddr;
|
||||
extern void* cdecl SmackTimerDoneAddr;
|
||||
|
||||
typedef void RADLINK (*SmackTimerSetupType)();
|
||||
typedef u32 RADLINK (*SmackTimerReadType)();
|
||||
typedef void RADLINK (*SmackTimerDoneType)();
|
||||
|
||||
#define SmackTimerSetup() ((SmackTimerSetupType)(SmackTimerSetupAddr))()
|
||||
#define SmackTimerRead() ((SmackTimerReadType)(SmackTimerReadAddr))()
|
||||
#define SmackTimerDone() ((SmackTimerDoneType)(SmackTimerDoneAddr))()
|
||||
|
||||
u8 RADEXPLINK SmackSoundUseMSS(void* DigDriver,u32 MaxTimerSpeed);
|
||||
void RADEXPLINK SmackSoundMSSLiteInit();
|
||||
void RADEXPLINK SmackSoundMSSLiteDone();
|
||||
|
||||
u8 RADEXPLINK SmackSoundUseSOS3r(u32 SOSDriver,u32 MaxTimerSpeed);
|
||||
u8 RADEXPLINK SmackSoundUseSOS3s(u32 SOSDriver,u32 MaxTimerSpeed);
|
||||
u8 RADEXPLINK SmackSoundUseSOS4r(u32 SOSDriver,u32 MaxTimerSpeed);
|
||||
u8 RADEXPLINK SmackSoundUseSOS4s(u32 SOSDriver,u32 MaxTimerSpeed);
|
||||
|
||||
#ifdef __SW_3R
|
||||
#define SmackSoundUseSOS3 SmackSoundUseSOS3r
|
||||
#define SmackSoundUseSOS4 SmackSoundUseSOS4r
|
||||
#else
|
||||
#define SmackSoundUseSOS3 SmackSoundUseSOS3s
|
||||
#define SmackSoundUseSOS4 SmackSoundUseSOS4s
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define SMACKRESRESET 0
|
||||
#define SMACKRES640X400 1
|
||||
#define SMACKRES640X480 2
|
||||
#define SMACKRES800X600 3
|
||||
#define SMACKRES1024X768 4
|
||||
|
||||
u32 RADEXPLINK SmackSetSystemRes(u32 mode); // use SMACKRES* values
|
||||
|
||||
#ifdef __RADMAC__
|
||||
|
||||
#include <windows.h>
|
||||
#include <palettes.h>
|
||||
#include <qdoffscreen.h>
|
||||
#include <timer.h>
|
||||
|
||||
typedef struct SmkTMInfoTag {
|
||||
TMTask smTask;
|
||||
u32 milli;
|
||||
} SmkTMInfo;
|
||||
|
||||
extern SmkTMInfo __SmackTimeInfo;
|
||||
|
||||
void RADEXPLINK SmackTimerSetup();
|
||||
void RADEXPLINK SmackTimerDone();
|
||||
#define SmackTimerRead() (__SmackTimeInfo.milli)
|
||||
|
||||
#define SMACKAUTOBLIT 0
|
||||
#define SMACKDIRECTBLIT 1
|
||||
#define SMACKGWORLDBLIT 2
|
||||
|
||||
typedef struct SmackBufTag {
|
||||
u32 Reversed;
|
||||
u32 SurfaceType; // SMACKSURFACExxxxxx
|
||||
u32 BlitType; // SMACKxxxxxBLIT
|
||||
u32 Width;
|
||||
u32 Height;
|
||||
u32 Pitch;
|
||||
u32 Zoomed;
|
||||
u32 ZWidth;
|
||||
u32 ZHeight;
|
||||
u32 DispColors; // colors on screen
|
||||
u32 MaxPalColors;
|
||||
u32 PalColorsInUse;
|
||||
u32 StartPalColor;
|
||||
u32 EndPalColor;
|
||||
void* Buffer;
|
||||
void* Palette;
|
||||
u32 PalType;
|
||||
|
||||
WindowPtr wp;
|
||||
GWorldPtr gwp;
|
||||
CTabHandle cth;
|
||||
PaletteHandle palh;
|
||||
} SmackBuf;
|
||||
|
||||
#else
|
||||
|
||||
#ifdef __RADWIN__
|
||||
|
||||
#define INCLUDE_MMSYSTEM_H
|
||||
#include "windows.h"
|
||||
#include "windowsx.h"
|
||||
|
||||
#define SMACKAUTOBLIT 0
|
||||
#define SMACKFULL320X240BLIT 1
|
||||
#define SMACKFULL320X200BLIT 2
|
||||
#define SMACKSTANDARDBLIT 3
|
||||
#define SMACKWINGBLIT 4
|
||||
|
||||
#define WM_SMACKACTIVATE WM_USER+0x5678
|
||||
|
||||
typedef struct SmackBufTag {
|
||||
u32 Reversed; // 1 if the buffer is upside down
|
||||
u32 SurfaceType; // SMACKSURFACExxxx defines
|
||||
u32 BlitType; // SMACKxxxxBLIT defines
|
||||
u32 FullScreen; // 1 if full-screen
|
||||
u32 Width;
|
||||
u32 Height;
|
||||
u32 Zoomed;
|
||||
u32 ZWidth;
|
||||
u32 ZHeight;
|
||||
u32 DispColors; // colors on the screen
|
||||
u32 MaxPalColors; // total possible colors in palette (usually 256)
|
||||
u32 PalColorsInUse; // Used colors in palette (usually 236)
|
||||
u32 StartPalColor; // first usable color index (usually 10)
|
||||
u32 EndPalColor; // last usable color index (usually 246)
|
||||
RGBQUAD Palette[256];
|
||||
u32 PalType;
|
||||
|
||||
void PTR4* Buffer;
|
||||
void PTR4* DIBRestore;
|
||||
u32 OurBitmap;
|
||||
u32 OrigBitmap;
|
||||
u32 OurPalette;
|
||||
u32 WinGDC;
|
||||
u32 FullFocused;
|
||||
u32 ParentHwnd;
|
||||
u32 OldParWndProc;
|
||||
u32 OldDispWndProc;
|
||||
u32 DispHwnd;
|
||||
u32 WinGBufHandle;
|
||||
} SmackBuf;
|
||||
|
||||
void RADEXPLINK SmackGet(Smack PTR4* smk,void PTR4* dest);
|
||||
void RADEXPLINK SmackBufferGet( SmackBuf PTR4* sbuf, void PTR4* dest);
|
||||
|
||||
u8 RADEXPLINK SmackSoundUseMSS(void PTR4* dd);
|
||||
u8 RADEXPLINK SmackSoundUseDirectSound(HWND hw);
|
||||
|
||||
#define SmackTimerSetup()
|
||||
#define SmackTimerDone()
|
||||
#define SmackTimerRead timeGetTime
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __RADMAC__
|
||||
SmackBuf PTR4* RADEXPLINK SmackBufferOpen( WindowPtr wp, u16 BlitType, u16 width, u16 height, u16 ZoomW, u16 ZoomH );
|
||||
u16 RADEXPLINK SmackBufferBlit( SmackBuf PTR4* sbuf, u16 hwndx, u16 hwndy, u16 subx, u16 suby, u16 subw, u16 subh );
|
||||
void RADEXPLINK SmackBufferFromScreen( SmackBuf PTR4* destbuf, u16 x, u16 y);
|
||||
#else
|
||||
SmackBuf PTR4* RADEXPLINK SmackBufferOpen( HWND wnd, u16 BlitType, u16 width, u16 height, u16 ZoomW, u16 ZoomH );
|
||||
u16 RADEXPLINK SmackBufferBlit( SmackBuf PTR4* sbuf, HDC dc, u16 hwndx, u16 hwndy, u16 subx, u16 suby, u16 subw, u16 subh );
|
||||
void RADEXPLINK SmackBufferFromScreen( SmackBuf PTR4* destbuf, HWND hw, u16 x, u16 y);
|
||||
#endif
|
||||
|
||||
char PTR4* RADEXPLINK SmackBufferString(char PTR4* dest,u16 BlitType);
|
||||
|
||||
void RADEXPLINK SmackBufferNewPalette( SmackBuf PTR4* sbuf, void PTR4* pal, u16 paltype );
|
||||
u16 RADEXPLINK SmackBufferSetPalette( SmackBuf PTR4* sbuf );
|
||||
void RADEXPLINK SmackBufferClose( SmackBuf PTR4* sbuf );
|
||||
|
||||
void RADEXPLINK SmackBufferClear( SmackBuf PTR4* destbuf, u16 color);
|
||||
void RADEXPLINK SmackBufferToBuffer( SmackBuf PTR4* destbuf, u16 destx, u16 desty, SmackBuf PTR4* sourcebuf,u16 sourcex,u16 sourcey,u16 sourcew,u16 sourceh);
|
||||
void RADEXPLINK SmackBufferToBufferTrans( SmackBuf PTR4* destbuf, u16 destx, u16 desty, SmackBuf PTR4* sourcebuf,u16 sourcex,u16 sourcey,u16 sourcew,u16 sourceh,u16 TransColor);
|
||||
void RADEXPLINK SmackBufferCopyPalette( SmackBuf PTR4* destbuf, SmackBuf PTR4* sourcebuf, u16 remap);
|
||||
|
||||
u16 RADEXPLINK SmackBufferFocused( SmackBuf PTR4* sbuf);
|
||||
|
||||
#endif
|
||||
|
||||
RCEND
|
||||
|
||||
#endif
|
BIN
3rdparty/smack/SMACK.LIB
vendored
Normal file
BIN
3rdparty/smack/SMACK.LIB
vendored
Normal file
Binary file not shown.
54
3rdparty/smk/smk.h
vendored
54
3rdparty/smk/smk.h
vendored
|
@ -1,54 +0,0 @@
|
|||
#ifndef SMK_H
|
||||
#define SMK_H
|
||||
|
||||
struct SmackSum {
|
||||
unsigned long m_totalTime;
|
||||
unsigned long m_ms100PerFrame;
|
||||
unsigned long m_totalOpenTime;
|
||||
unsigned long m_totalFrames;
|
||||
unsigned long m_skippedFrames;
|
||||
unsigned long m_totalBlitTime;
|
||||
unsigned long m_totalReadTime;
|
||||
unsigned long m_totalDecompressTime;
|
||||
unsigned long m_totalBackReadTime;
|
||||
unsigned long m_totalReadSpeed;
|
||||
unsigned long m_slowestFrameTime;
|
||||
unsigned long m_slowestTwoFrameTime;
|
||||
unsigned long m_slowestFrameNum;
|
||||
unsigned long m_slowestTwoFrameNum;
|
||||
unsigned long m_averageFrameSize;
|
||||
unsigned long m_highestOneSecRate;
|
||||
unsigned long m_highestOneSecFrame;
|
||||
unsigned long m_highestMemAmount;
|
||||
unsigned long m_totalExtraMemory;
|
||||
unsigned long m_highestExtraUsed;
|
||||
};
|
||||
|
||||
struct Smack {
|
||||
unsigned long m_version;
|
||||
unsigned long m_width;
|
||||
unsigned long m_height;
|
||||
unsigned long m_frames;
|
||||
unsigned long m_msInAFrame;
|
||||
unsigned long m_smkType;
|
||||
unsigned long m_audioTrackSize[7];
|
||||
unsigned long m_treeSize;
|
||||
unsigned long m_codeSize;
|
||||
unsigned long m_abSize;
|
||||
unsigned long m_detailSize;
|
||||
unsigned long m_typeSize;
|
||||
unsigned long m_trackType[7];
|
||||
unsigned long m_extra;
|
||||
unsigned long m_newPalette;
|
||||
unsigned char m_palette[772];
|
||||
unsigned long m_frameNum;
|
||||
unsigned long m_lastRectX;
|
||||
unsigned long m_lastRectY;
|
||||
unsigned long m_lastRectW;
|
||||
unsigned long m_lastRectH;
|
||||
unsigned long m_openFlags;
|
||||
unsigned long m_leftOfs;
|
||||
unsigned long m_topOfs;
|
||||
};
|
||||
|
||||
#endif // SMK_H
|
|
@ -168,6 +168,7 @@ add_library(lego1 SHARED
|
|||
LEGO1/mxregionlist.cpp
|
||||
LEGO1/mxscheduler.cpp
|
||||
LEGO1/mxsemaphore.cpp
|
||||
LEGO1/mxsmack.cpp
|
||||
LEGO1/mxsmkpresenter.cpp
|
||||
LEGO1/mxsoundmanager.cpp
|
||||
LEGO1/mxsoundpresenter.cpp
|
||||
|
@ -232,11 +233,10 @@ if (MINGW)
|
|||
endif()
|
||||
|
||||
# Additional include directories
|
||||
|
||||
target_include_directories(lego1 PRIVATE "${CMAKE_SOURCE_DIR}/util")
|
||||
target_include_directories(lego1 PUBLIC "${CMAKE_SOURCE_DIR}/3rdparty/vec")
|
||||
target_include_directories(lego1 PRIVATE "${CMAKE_SOURCE_DIR}/3rdparty/flic")
|
||||
target_include_directories(lego1 PRIVATE "${CMAKE_SOURCE_DIR}/3rdparty/smk")
|
||||
target_include_directories(lego1 PRIVATE "${CMAKE_SOURCE_DIR}/3rdparty/smack")
|
||||
|
||||
if (ISLE_USE_SMARTHEAP)
|
||||
add_library(SmartHeap::SmartHeap STATIC IMPORTED)
|
||||
|
@ -254,8 +254,10 @@ if (ISLE_USE_DX5)
|
|||
target_link_directories(lego1 PRIVATE "${CMAKE_SOURCE_DIR}/3rdparty/dx5/lib")
|
||||
endif()
|
||||
|
||||
target_link_directories(lego1 PRIVATE "${CMAKE_SOURCE_DIR}/3rdparty/smack")
|
||||
|
||||
# Link libraries
|
||||
target_link_libraries(lego1 PRIVATE ddraw dsound dxguid dinput winmm d3drm)
|
||||
target_link_libraries(lego1 PRIVATE ddraw dsound dxguid dinput winmm d3drm smack)
|
||||
|
||||
# Make sure filenames are ALL CAPS
|
||||
set_property(TARGET lego1 PROPERTY OUTPUT_NAME LEGO1)
|
||||
|
|
141
LEGO1/mxsmack.cpp
Normal file
141
LEGO1/mxsmack.cpp
Normal file
|
@ -0,0 +1,141 @@
|
|||
#include "mxsmack.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
DECOMP_SIZE_ASSERT(SmackTag, 0x390);
|
||||
DECOMP_SIZE_ASSERT(MxSmack, 0x6b8);
|
||||
|
||||
// FUNCTION: LEGO1 0x100c5a90
|
||||
MxResult MxSmack::LoadHeaderAndTrees(MxU8* p_data, MxSmack* p_mxSmack)
|
||||
{
|
||||
// Macros for readability
|
||||
#define FRAME_COUNT(mxSmack) (p_mxSmack->m_smackTag.Frames + (p_mxSmack->m_smackTag.SmackerType & 1))
|
||||
|
||||
MxResult result = SUCCESS;
|
||||
MxU8* frameTypes = NULL;
|
||||
MxU8* huffmanTrees = NULL;
|
||||
|
||||
if (!p_data || !p_mxSmack) {
|
||||
result = FAILURE;
|
||||
}
|
||||
else {
|
||||
p_mxSmack->m_frameTypes = NULL;
|
||||
p_mxSmack->m_frameSizes = NULL;
|
||||
p_mxSmack->m_huffmanTrees = NULL;
|
||||
p_mxSmack->m_huffmanTables = NULL;
|
||||
|
||||
memcpy(&p_mxSmack->m_smackTag, p_data, SmackHeaderSize(&p_mxSmack->m_smackTag));
|
||||
p_data += SmackHeaderSize(&p_mxSmack->m_smackTag);
|
||||
|
||||
MxU32* frameSizes = new MxU32[FRAME_COUNT(p_mxSmack)];
|
||||
|
||||
if (!frameSizes) {
|
||||
result = FAILURE;
|
||||
}
|
||||
else {
|
||||
memcpy(frameSizes, p_data, FRAME_COUNT(p_mxSmack) * sizeof(MxU32));
|
||||
|
||||
p_data += FRAME_COUNT(p_mxSmack) * sizeof(MxU32);
|
||||
p_mxSmack->m_maxFrameSize = 0;
|
||||
|
||||
// TODO
|
||||
for (MxU32 i = 0; i < FRAME_COUNT(p_mxSmack); i++) {
|
||||
if (p_mxSmack->m_maxFrameSize < frameSizes[i])
|
||||
p_mxSmack->m_maxFrameSize = frameSizes[i];
|
||||
}
|
||||
|
||||
frameTypes = new MxU8[FRAME_COUNT(p_mxSmack)];
|
||||
|
||||
if (!frameTypes) {
|
||||
result = FAILURE;
|
||||
}
|
||||
else {
|
||||
memcpy(frameTypes, p_data, FRAME_COUNT(p_mxSmack));
|
||||
p_data += FRAME_COUNT(p_mxSmack);
|
||||
|
||||
MxU32 treeSize = p_mxSmack->m_smackTag.tablesize + 0x1000;
|
||||
if (treeSize <= 0x2000)
|
||||
treeSize = 0x2000;
|
||||
|
||||
huffmanTrees = new MxU8[treeSize];
|
||||
|
||||
if (!huffmanTrees) {
|
||||
result = FAILURE;
|
||||
}
|
||||
else {
|
||||
memcpy(huffmanTrees + 0x1000, p_data, p_mxSmack->m_smackTag.tablesize);
|
||||
|
||||
p_mxSmack->m_huffmanTables = new MxU8
|
||||
[p_mxSmack->m_smackTag.codesize + p_mxSmack->m_smackTag.absize +
|
||||
p_mxSmack->m_smackTag.detailsize + p_mxSmack->m_smackTag.typesize + SmackGetSizeTables()];
|
||||
|
||||
if (!p_mxSmack->m_huffmanTables) {
|
||||
result = FAILURE;
|
||||
}
|
||||
else {
|
||||
SmackDoTables(
|
||||
huffmanTrees,
|
||||
p_mxSmack->m_huffmanTables,
|
||||
p_mxSmack->m_smackTag.codesize,
|
||||
p_mxSmack->m_smackTag.absize,
|
||||
p_mxSmack->m_smackTag.detailsize,
|
||||
p_mxSmack->m_smackTag.typesize
|
||||
);
|
||||
|
||||
MxU32 size =
|
||||
::SmackGetSizeDeltas(p_mxSmack->m_smackTag.Width, p_mxSmack->m_smackTag.Height) + 32;
|
||||
p_mxSmack->m_unk0x6b4 = new MxU8[size];
|
||||
memset(p_mxSmack->m_unk0x6b4, 0, size);
|
||||
|
||||
MxS32 width = p_mxSmack->m_smackTag.Width;
|
||||
MxU32* data = (MxU32*) p_mxSmack->m_unk0x6b4;
|
||||
|
||||
*data = 1;
|
||||
data++;
|
||||
*data = 0;
|
||||
data++;
|
||||
*data = p_mxSmack->m_smackTag.Width / 4;
|
||||
data++;
|
||||
*data = p_mxSmack->m_smackTag.Height / 4;
|
||||
data++;
|
||||
*data = width - 4;
|
||||
data++;
|
||||
*data = width * 3;
|
||||
data++;
|
||||
*data = width;
|
||||
data++;
|
||||
*data = width * 4 - p_mxSmack->m_smackTag.Width;
|
||||
data++;
|
||||
data++;
|
||||
*data = p_mxSmack->m_smackTag.Width;
|
||||
data++;
|
||||
*data = p_mxSmack->m_smackTag.Height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
p_mxSmack->m_frameTypes = frameTypes;
|
||||
p_mxSmack->m_frameSizes = frameSizes;
|
||||
p_mxSmack->m_huffmanTrees = huffmanTrees;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
#undef FRAME_COUNT
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100c5d40
|
||||
void MxSmack::Destroy(MxSmack* p_mxSmack)
|
||||
{
|
||||
if (p_mxSmack->m_frameSizes)
|
||||
delete[] p_mxSmack->m_frameSizes;
|
||||
if (p_mxSmack->m_frameTypes)
|
||||
delete[] p_mxSmack->m_frameTypes;
|
||||
if (p_mxSmack->m_huffmanTrees)
|
||||
delete[] p_mxSmack->m_huffmanTrees;
|
||||
if (p_mxSmack->m_huffmanTables)
|
||||
delete[] p_mxSmack->m_huffmanTables;
|
||||
if (p_mxSmack->m_unk0x6b4)
|
||||
delete[] p_mxSmack->m_unk0x6b4;
|
||||
}
|
45
LEGO1/mxsmack.h
Normal file
45
LEGO1/mxsmack.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
#ifndef MXSMACK_H
|
||||
#define MXSMACK_H
|
||||
|
||||
#include "decomp.h"
|
||||
#include "mxtypes.h"
|
||||
|
||||
#include <smack.h>
|
||||
|
||||
// These functions are not part of the public interface,
|
||||
// but present in SMACK.LIB and used directly by Mindscape.
|
||||
extern "C"
|
||||
{
|
||||
// (SMACK.LIB) FUNCTION: LEGO1 0x100cd782
|
||||
u32 SmackGetSizeTables();
|
||||
|
||||
// (SMACK.LIB) FUNCTION: LEGO1 0x100cd7e8
|
||||
void SmackDoTables(
|
||||
u8* p_huffmanTrees,
|
||||
u8* p_huffmanTables,
|
||||
u32 p_codeSize,
|
||||
u32 p_abSize,
|
||||
u32 p_detailSize,
|
||||
u32 p_typeSize
|
||||
);
|
||||
|
||||
// (SMACK.LIB) FUNCTION: LEGO1 0x100d052c
|
||||
u32 SmackGetSizeDeltas(u32 p_width, u32 p_height);
|
||||
}
|
||||
|
||||
// SIZE 0x6b8
|
||||
struct MxSmack {
|
||||
SmackTag m_smackTag; // 0x00
|
||||
undefined m_unk0x390[784]; // 0x390
|
||||
MxU32* m_frameSizes; // 0x6a0
|
||||
MxU8* m_frameTypes; // 0x6a4
|
||||
MxU8* m_huffmanTrees; // 0x6a8
|
||||
MxU8* m_huffmanTables; // 0x6ac
|
||||
MxU32 m_maxFrameSize; // 0x6b0
|
||||
MxU8* m_unk0x6b4; // 0x6b4
|
||||
|
||||
static MxResult LoadHeaderAndTrees(MxU8* p_data, MxSmack* p_mxSmack);
|
||||
static void Destroy(MxSmack* p_mxSmack);
|
||||
};
|
||||
|
||||
#endif // MXSMACK_H
|
|
@ -31,7 +31,7 @@ void MxSmkPresenter::Destroy(MxBool p_fromDestructor)
|
|||
{
|
||||
m_criticalSection.Enter();
|
||||
|
||||
FUN_100c5d40(&m_mxSmack);
|
||||
MxSmack::Destroy(&m_mxSmack);
|
||||
Init();
|
||||
|
||||
m_criticalSection.Leave();
|
||||
|
@ -41,10 +41,10 @@ void MxSmkPresenter::Destroy(MxBool p_fromDestructor)
|
|||
}
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x100b3940
|
||||
// FUNCTION: LEGO1 0x100b3940
|
||||
void MxSmkPresenter::LoadHeader(MxStreamChunk* p_chunk)
|
||||
{
|
||||
// TODO
|
||||
MxSmack::LoadHeaderAndTrees(p_chunk->GetData(), &m_mxSmack);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b3960
|
||||
|
@ -54,7 +54,7 @@ void MxSmkPresenter::CreateBitmap()
|
|||
delete m_bitmap;
|
||||
|
||||
m_bitmap = new MxBitmap;
|
||||
m_bitmap->SetSize(m_mxSmack.m_smack.m_width, m_mxSmack.m_smack.m_height, NULL, FALSE);
|
||||
m_bitmap->SetSize(m_mxSmack.m_smackTag.Width, m_mxSmack.m_smackTag.Height, NULL, FALSE);
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x100b3a00
|
||||
|
@ -64,23 +64,19 @@ void MxSmkPresenter::LoadFrame(MxStreamChunk* p_chunk)
|
|||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b4260
|
||||
MxU32 MxSmkPresenter::VTable0x88()
|
||||
void MxSmkPresenter::VTable0x88()
|
||||
{
|
||||
MxU32 result = m_unk0x71c;
|
||||
if ((m_mxSmack.m_smack.m_smkType & 1) != 0) {
|
||||
result = m_unk0x71c / m_mxSmack.m_smack.m_frames;
|
||||
if (1 < m_unk0x71c && (m_unk0x71c % m_mxSmack.m_smack.m_frames) == 1) {
|
||||
if ((m_mxSmack.m_smackTag.SmackerType & 1) != 0) {
|
||||
MxU32 und = (m_unk0x71c % m_mxSmack.m_smackTag.Frames);
|
||||
if (1 < m_unk0x71c && und == 1)
|
||||
m_unk0x71c = 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
if (m_mxSmack.m_smack.m_frames == result) {
|
||||
if (m_mxSmack.m_smackTag.Frames == m_unk0x71c) {
|
||||
m_unk0x71c = 0;
|
||||
result = 0;
|
||||
memset(m_mxSmack.m_smack.m_palette, 0, sizeof(m_mxSmack.m_smack.m_palette));
|
||||
// TODO: struct incorrect, Palette at wrong offset?
|
||||
memset(m_mxSmack.m_smackTag.Palette, 0, sizeof(m_mxSmack.m_smackTag.Palette));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,18 +93,3 @@ void MxSmkPresenter::Destroy()
|
|||
{
|
||||
Destroy(FALSE);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100c5d40
|
||||
void MxSmkPresenter::FUN_100c5d40(MxSmack* p_mxSmack)
|
||||
{
|
||||
if (p_mxSmack->m_unk0x6a0)
|
||||
delete p_mxSmack->m_unk0x6a0;
|
||||
if (p_mxSmack->m_unk0x6a4)
|
||||
delete p_mxSmack->m_unk0x6a4;
|
||||
if (p_mxSmack->m_unk0x6a8)
|
||||
delete p_mxSmack->m_unk0x6a8;
|
||||
if (p_mxSmack->m_unk0x6ac)
|
||||
delete p_mxSmack->m_unk0x6ac;
|
||||
if (p_mxSmack->m_unk0x6b4)
|
||||
delete p_mxSmack->m_unk0x6b4;
|
||||
}
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
#define MXSMKPRESENTER_H
|
||||
|
||||
#include "decomp.h"
|
||||
#include "mxsmack.h"
|
||||
#include "mxvideopresenter.h"
|
||||
|
||||
#include <smk.h>
|
||||
|
||||
// VTABLE: LEGO1 0x100dc348
|
||||
// SIZE 0x720
|
||||
class MxSmkPresenter : public MxVideoPresenter {
|
||||
|
@ -31,32 +30,14 @@ class MxSmkPresenter : public MxVideoPresenter {
|
|||
virtual void CreateBitmap() override; // vtable+0x60
|
||||
virtual void LoadFrame(MxStreamChunk* p_chunk) override; // vtable+0x68
|
||||
virtual void RealizePalette() override; // vtable+0x70
|
||||
virtual MxU32 VTable0x88(); // vtable+0x88
|
||||
|
||||
struct MxSmack {
|
||||
Smack m_smack;
|
||||
|
||||
// Unknown for the time being. Not an immediately
|
||||
// recognizable part of the SMK standard...
|
||||
|
||||
undefined m_unk0x3f4[784];
|
||||
undefined4* m_unk0x6a0;
|
||||
undefined4* m_unk0x6a4;
|
||||
undefined4* m_unk0x6a8;
|
||||
undefined4* m_unk0x6ac;
|
||||
undefined4* m_unk0x6b0;
|
||||
undefined4* m_unk0x6b4;
|
||||
};
|
||||
|
||||
MxSmack m_mxSmack;
|
||||
undefined4 m_unk0x71c;
|
||||
virtual void VTable0x88(); // vtable+0x88
|
||||
|
||||
private:
|
||||
void Init();
|
||||
void Destroy(MxBool p_fromDestructor);
|
||||
|
||||
// This should most likely be in a separate translation unit
|
||||
static void FUN_100c5d40(MxSmack* p_mxSmack);
|
||||
MxSmack m_mxSmack; // 0x64
|
||||
undefined4 m_unk0x71c; // 0x71c
|
||||
};
|
||||
|
||||
#endif // MXSMKPRESENTER_H
|
||||
|
|
Loading…
Reference in a new issue