Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: WMEPico - now you can build WME games in DOSBox  (Read 4697 times)

0 Members and 5 Guests are viewing this topic.

cccatch

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 3
    • View Profile
WMEPico - now you can build WME games in DOSBox
« on: June 15, 2025, 02:44:56 PM »

Code: [Select]
#include <std_disclaimer.h>
"I do not accept responsibility for any effects, adverse or otherwise, that this code may have on you, your computer, your sanity, your dog, and anything else that you can think of. Use it at your own risk."

New in version 3.1.6.3:
  • Improved saving speed by 33%
  • Logs are more verbose now
  • Fixed build from real DOS
  • Added ScummVM support

FAQ:
Q: I copied my data files from the Wintermute official IDE, but they aren't working!
A: They must be converted first. Please build your project normally using official tools, and then, you'll need to decompress data.dcp file.
Get Python 3, Numpy and that script: https://drive.google.com/file/d/1Ot06g-nn7rnvEzppUKF4gK_vG0FMcGqL/view?usp=sharing

Q: My OS tells wmepico.exe is not compatible with my version of Windows.
A: You'll need an emulator then. If you pick DOSBox, configure it like this:

Code: [Select]
...
[autoexec]
rem Directory C:\wmepico must exist on host system
mount c C:\wmepico
c:
wmepico
pause

Thank you Slimer and yolklore for all your support and extensive testing.

Download: https://drive.google.com/file/d/1ZQca7Em8TM1YktAn6ooJOCxxwiw6Ysv1/view?usp=sharing

Comments are always welcome, of course.
Logged

cccatch

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 3
    • View Profile
Re: WMEPico - now you can build WME games in DOSBox
« Reply #1 on: June 18, 2025, 06:09:04 AM »

Code: [Select]
/*wmepico (Power C 2.0, run "pc /e wmepico.c")*/
#include <malloc.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <direct.h>
typedef struct{
char magic[8];
char packageVersion[12];
char desc[104];
char numDirs[8];
}hdr;
FILE*arc;
char far*heap;
long heapsz=0;
long filecnt=0;
char origdir[256];
void fail(char const*s){
puts(s);
fclose(arc);
chdir(origdir);
exit(0);
}
void put_header(){
hdr h;
memset(&h,0,sizeof(h));
strcpy(h.magic,"\xde\xad\xc0\xdeJUNK");
h.packageVersion[1]=2;
strcpy(h.desc,"MINhMain data    (Wintermute Engine \xa9 DEAD:CODE 2010)");
h.numDirs[0]=1;
if(fwrite(&h,sizeof(h),1,arc)!=1){
fail("disk is not writeable");
}
}
char full_path[4096];
char iobuf[4096];
int subdirs[8];
char const*known_exts[]={
"act\0or",
"but\0ton",
"fon\0t",
"gam\0e",
"ima\0ge",
"ite\0ms",
"sce\0ne",
"scr\0ipt",
"set\0tings",
"spr\0ite",
"win\0dow",
NULL
};
int walk(char const*d,int depth){
struct ffblk e;
char*p=&e.ff_name;
char*o;
char*m;
int h;
char**s;
char*at=full_path;
char*ext;
int t;
FILE*f;
long off;
if(depth>=8||chdir(d))goto err;
if(depth)at+=subdirs[depth-1];
h=findfirst("*.*",&e,22);
while(h!=-1){
if(!(*p=='.'&&(p[1]==0||(p[1]=='.'&&p[2]==0)))){
o=at;
ext=p;
while(*ext&&*ext!='.'){
t=*ext;
if(t>='A'&&t<='Z')t+='a'-'A';
*o++=t;
++ext;
}
if(*ext=='.'&&ext[1]){
*o++='.';
++ext;
m=o;
while(*ext){
t=*ext;
if(t>='A'&&t<='Z')t+='a'-'A';
*o++=t;
++ext;
}
*o=0;
s=known_exts;
while(*s){
if(!strcmp(*s,m)){
ext=(*s)+(strlen(*s)+1);
t=strlen(ext);
memcpy(o,ext,t);
o+=t;
break;
}
++s;
}
}
if(o==at)fail("empty file name");
*o++='\\';
subdirs[depth]=o-full_path;
if(e.ff_attrib&16){
fwrite(full_path,1,subdirs[depth],stdout);
puts("");
walk(p,depth+1);
}else{
printf("File ");
fwrite(full_path,1,subdirs[depth]-1,stdout);
puts("");
if(subdirs[depth]>255)fail("filename is too long");
f=fopen(p,"rb");
if(!f)fail("can't open file");
if(heapsz+(8+subdirs[depth])>(1L<<19))fail("out of memory");
farmemcpy(heap+heapsz,full_path,subdirs[depth]);
heap[heapsz+subdirs[depth]-1]=0;
heapsz+=subdirs[depth];
off=ftell(arc);
farmemcpy(heap+heapsz,&off,4);
for(;;){
t=fread(iobuf,1,4096,f);
if(t<0){
fclose(f);
fail("read error");
}
if(!t)break;
if(fwrite(iobuf,t,1,arc)!=1){
fclose(f);
fail("write error");
}
}
off=ftell(arc)-off;
farmemcpy(heap+heapsz+4,&off,4);
heapsz+=8;
filecnt+=1;
fclose(f);
}
o=at;
while(*o!='\\'){
if(*o=='~')fail("long name error");
++o;
}
}
h=findnext(&e);
}
if(chdir("..")){
err:
fail("disk error");
}
return 0;
}
int main(){
size_t sz;
size_t z;
char far*s;
long p;
long i;
if(!(s=heap=farmalloc(1L<<19))){
puts("can't allocate");
return 0;
}
if(!getcwd(origdir,255))return 0;
arc=fopen("data.dcp","wb");
if(!arc)return 0;
put_header();
walk("data",0);
p=ftell(arc);
if(fwrite("\5data\0\0",7,1,arc)!=1)fail("can't write footer");
if(fwrite(&filecnt,4,1,arc)!=1)fail("can't write file count");
for(i=0;i<filecnt;++i){
sz=farstrlen(s)+1;
if(fputc(sz,arc)!=sz)fail("can't write filename length");
farmemcpy(iobuf,s,sz+8);
s+=sz+8;
for(z=0;z<sz;++z)iobuf[z]^='D';
if(fwrite(iobuf,sz+8,1,arc)!=1)fail("can't write filename");
if(fwrite("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",16,1,arc)!=1)
 fail("can't write garbage");
}
fseek(arc,128,SEEK_SET);
if(fwrite(&p,4,1,arc)!=1)fail("Why? It was almost done!");
fail("OK");
return 0;
}
Logged

cccatch

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 3
    • View Profile
Re: WMEPico - now you can build WME games in DOSBox
« Reply #2 on: June 18, 2025, 06:10:03 AM »

Code: [Select]
import zlib,numpy as np,os,sys
f=open('data.dcp','rb')
f.seek(128)
f.seek(np.frombuffer(f.read(4),dtype=np.uint32)[0])
f.read(7)
cnt=np.frombuffer(f.read(4),dtype=np.uint32)[0]
tok=f.read()
for i in range(cnt):
 c=tok[0]
 tok=tok[1:]
 fname=(np.frombuffer(tok[:c],dtype=np.uint8)^ord('D')).tobytes().rstrip(b'\0').replace(b'\\',b'/')
 tok=tok[c:]
 d,n=os.path.split(fname)
 d=b'datan/'+d
 if b'.' in n:
  n,e=n.split(b'.',1)
  n=n+b'.'+(e[:3])
 os.makedirs(d,exist_ok=True)
 info=np.frombuffer(tok[:24],dtype=np.uint32)
 tok=tok[24:]
 f.seek(info[0])
 if info[2]:
  z=zlib.decompress(f.read(info[2]))
  if len(z)!=info[1]:
   raise RuntimeError
 else:
  z=f.read(info[1])
 of=open(d+b'/'+n,'wb')
 of.write(z)
 of.close()
Logged

Mot

  • Occasional poster
  • **
  • Karma: 3
  • Offline Offline
  • Posts: 60
    • View Profile
Re: WMEPico - now you can build WME games in DOSBox
« Reply #3 on: June 19, 2025, 07:33:02 PM »

Hey cccatch :)

Kudos to you on your project. It looks interesting and useful.
« Last Edit: June 20, 2025, 12:12:37 AM by Mot »
Logged
 

Page created in 0.234 seconds with 20 queries.