銀星工作室 CWMAP 97 地圖編輯器 Falesss.c
最近整理舊光碟準備拿去回收,翻到很久已前約國中時,燒的光碟,嚇到,以前想學寫game蒐集的一些資料,現在的google已經找不到的資料了,就讓他回歸google吧!
程式碼下載:http://pompom.new.googlepages.com/Falesss.c
/*
銀星工作室 CWMAP 97 地圖編輯器-使用範例 ( C語言 )
-------------------------------------------------------------
以下全部函數都是最基本的寫法(較易懂),但相對的速度也較慢,
因只是秀出如何撰寫使用 .SMP/.SMC 檔,不要求速度所叫H已夠了,
特別加上【中文註解】,應該連初學者都看的懂了.
------- 遊戲創作夢想已不再是夢 --------
日期: 1997.06.21 (看完株羅紀公園-失落的世界後)
作者: 謝明宏 (Alan Hsieh)
語言: Turbo C/C++ 3.0 ( Borland C/C++ 也可用 )
說明: 本範例程式免費使用,另徵求好心【QB高手】將之翻為 .BAS ...
*/
//#include"music.c"
#include <io.h>
#include <dos.h>
#include <mem.h>
#include <stdio.h>
#include <conio.h>
#include <alloc.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
////////////////////////////////////////////////////////////////////////
//sound blaster set driver function.........
////////////////////////////////////////////////////////////////////////
typedef char strings[255];
strings scmf,save_cmf;
unsigned char *cmf;
unsigned char *music_status;
int read_value(int addr)
{
return( *(cmf+addr)|(*(cmf+addr+1)<<8) );
}
/*-------- play *. cmf --------------------*/
void PlayCmf(unsigned char * buffer)
{
unsigned offset,ins_offset,ins_cnt,author,title,freq,pertick,tempo,rem,divisor;
union REGS regs;
cmf=buffer;
offset=read_value(0x8);
ins_offset=read_value(0x6);
author=read_value(0x10);
title=read_value(0x0e);
rem=read_value(0x12);
freq=read_value(0x0c);
pertick=read_value(0x0a);
ins_cnt=read_value(0x24);
tempo=read_value(0x26);
divisor=1193180/freq;
regs.x.bx = 2;
regs.x.cx=ins_cnt;
regs.x.dx=FP_SEG(cmf);
regs.x.ax=FP_OFF(cmf)+ins_offset;
int86(0x80,®s, ®s);
regs.x.bx=4;
regs.x.ax=divisor;
int86(0x80,®s, ®s);
regs.x.bx=6;
regs.x.dx=FP_SEG(cmf);
regs.x.ax=FP_OFF(cmf)+offset;
int86(0x80,®s, ®s);
}
/*--- stop music output--------*/
void StopMusic(void)
{
union REGS regs;
regs.x.bx=7;
int86(0x80,®s, ®s);
}
void PauseMusic(void)
{
union REGS regs;
regs.x.bx=9;
int86(0x80,®s, ®s);
}
void ResumeMusic(void)
{
union REGS regs;
regs.x.bx=10;
int86(0x80,®s, ®s);
}
void ResetFMDriver(void)
{
union REGS regs;
regs.x.bx=1;
regs.x.dx=FP_SEG(music_status);
regs.x.ax=FP_OFF(music_status);
int86(0x80,®s, ®s);
regs.x.bx=8;
int86(0x80,®s, ®s);
}
int GetFMDriverVersion(void)
{
union REGS regs;
regs.x.bx=0;
return(regs.x.ax);
}
void ContinuePlay(void)
{
if(*music_status) return;
else PlayCmf(cmf);
}
int Check_SB_driver()
{
union REGS regs;
int i,ess;
regs.x.ax=0x3580;
int86(0x21,®s, ®s);
asm{
mov i,es;
}
if(i || regs.x.bx) return 1;
else return 0;
}
/*----- main program here------------*/
unsigned char *buf;
void musics( char * stringss)
{
FILE *fp;
unsigned length;
char c;
if(!Check_SB_driver())
{
puts("sb driver sbfmdrv.com not load yet..");
exit(0);
}
if((fp=fopen(stringss,"rb"))==NULL)
{
puts("file can't found..");
exit(1);
}
length=filelength(fileno(fp));
buf=(unsigned char *)malloc(length);
fread(buf,1,length,fp);
fclose(fp);
ResetFMDriver();
PlayCmf(buf);
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
typedef struct { // .SMP FILE BODY
signed int cell[3];
signed char state;
signed char other;
} mapcell;
typedef struct {
char header[18]; // .SMC FILE HEADER
char version[5];
char mask;
int mx,my; //picture size
int mapno; //all picture number
int maxcol; // max color
unsigned char mappal[768];
unsigned char reserv[6];
} mapcellhead;
typedef struct { // .SMP FILE HEADER
char header[12];
char version[5];
char mask; //0x1a
int resx;
int resy;
int mapx; // picture max x
int mapy; // picture max y
int picx; //=mx
int picy; //=my
int mapno;
long maxcol;
unsigned char mappal[768];
unsigned char reserv[6];
} maphead;
#define max_picx 11
#define max_picy 7
int maxx= 70;
int maxy= 70;
maphead map_head;
mapcellhead map_cell_head;
mapcell map_cell[70*70]; // 最大 50x50 (試用版)
unsigned char pal[768]; // 調色盤
unsigned char * pics[1000]; // 最多1000個元件
void initmode(char Mode) // 初始化繪圖模式
{
union REGS r;
r.h.ah = 0;
r.x.ax = Mode;
int86(0x10,&r,&r);
}
void putdot(int x,int y,char c)
{
unsigned char far *screen;
screen=(unsigned char*)MK_FP(0xa000,0);
screen[x+y*320]=c;
}
void mem_putdot(int x,int y,char c,unsigned char *pic_datas)
{
unsigned char far *screen;
screen=(unsigned char*)MK_FP(FP_SEG(pic_datas),FP_OFF(pic_datas));
screen[x+y*320]=c;
}
void put_mem(int xx,int yy,int max_x,int max_y,unsigned char *pic)
{
int x,y,wx=28,wy=28;
wx=max_x;
wy=max_y;
for(y=0;y<wy;y++)
{
for(x=0;x<wx;x++)
{
if (pic[(y*wx+x+4)] !=255)
{
// putpixel(xx+x,yy+y,pic[y*wx+x]);
putdot(xx+x,yy+y,pic[y*wx+x+4]);
}
}
}
}
void put_other_mem(int xx,int yy,int max_x,int max_y,unsigned char *pic,unsigned char *other_mem)
{
int x,y,wx=28,wy=28;
wy=max_x;
wx=max_y;
for(y=0;y<wy;y++)
{
for(x=0;x<wx;x++)
{
if (pic[(y*wx+x+4)] !=255)
{
mem_putdot(xx+x,yy+y,pic[y*wx+x+4],other_mem);
}
}
}
}
void set_mem_full( unsigned char *mem_full,int how_many,unsigned char colors)
{
int i;
for (i=0;i<how_many;i++);
mem_full[i]=colors;
};
void putpixel(int x,int y,char color) // 繪點
{
poke(0xA000,x+(y << 8)+(y << 6),color);
}
void putimage(int x,int y,unsigned char * pic) // 放圖函數
{
int wx,wy,j;
wx=*(pic)+1;
wy=*(pic+2)+1;
for (j=0;j<wy;j++)
movedata(FP_SEG(pic),FP_OFF(pic)+4+j*wx,0xA000,x+((y+j)*320),wx);
}
void put_in_mem(int x,int y,unsigned char * pic,unsigned char *topic) // 放圖函數
{
// the picture write in fales memory
int wx,wy,j;
wx=*(pic)+1;
wy=*(pic+2)+1;
for (j=0;j<wy;j++)
movedata(FP_SEG(pic),FP_OFF(pic)+4+j*wx,FP_SEG(topic),FP_OFF(x+((y+j)*320)),wx);
}
void change_bank(unsigned char *pic_data)
{
movedata(FP_SEG(pic_data),FP_OFF(pic_data),0xa000,0x0000,64000);
}
void bar(int x,int y,int x2,int y2,unsigned char color)
{ // 區塊 (最簡單的方法但不快 !)
int a,b;
for (a=x;a<=x2;a++)
for (b=y;b<=y2;b++)
putpixel(a,b,color);
}
void set_right(char * pal) // 設定調色盤
{
unsigned int vseg,vofs;
int i,ii;
for (ii=0;ii<256;ii++)
{
for (i=0;i<768;i++)
{
*(pal+i)= *pal+1;
}
}
vseg=FP_SEG(pal);
vofs=FP_OFF(pal);
asm {
mov ax,0x1012 /* 1012h 功能 設定調色盤 */
mov bx,0 /* 第 0 色開始 */
mov cx,256 /* 設定 256 色 */
mov es,vseg /* Segment */
mov dx,vofs /* Offset */
int 0x10 /* 10H 視訊中斷 */
}
}
void setpalette(char * pal) // 設定調色盤
{
unsigned int vseg,vofs;
vseg=FP_SEG(pal);
vofs=FP_OFF(pal);
asm {
mov ax,0x1012 /* 1012h 功能 設定調色盤 */
mov bx,0 /* 第 0 色開始 */
mov cx,256 /* 設定 256 色 */
mov es,vseg /* Segment */
mov dx,vofs /* Offset */
int 0x10 /* 10H 視訊中斷 */
}
}
void loadsmp(char *fname) // 讀取 .SMP 檔
{
FILE *fp;
int i;
fp=fopen(fname,"rb");
fread((char *)&map_head,sizeof(map_head),1,fp); //讀檔頭
for (i=0;i<map_head.mapx*map_head.mapy;i++) // i=0 To 50x50
{
fread((char*)&map_cell[i],sizeof(mapcell),1,fp); //讀地圖
}
fclose(fp);
}
void loadsmc(char *fname) // 讀取 .SMC 檔
{
FILE *fp;
char temp[12];
int i;
fp=fopen(fname,"rb");
fread((char *)&map_cell_head,sizeof(mapcellhead),1,fp); // 讀檔頭
setpalette(map_cell_head.mappal); // 設調色盤
for (i=0;i<map_head.mapno;i++) // 讀元件(圖形)
{
fread(temp,12,1,fp); // 元件名
pics[i]=(unsigned char *) malloc(map_cell_head.mx*map_cell_head.my+4);
fread((unsigned char * )pics[i],map_cell_head.mx*map_cell_head.my+4,1,fp);
}
fclose(fp);
}
void freesmc(void)
{
int i;
for (i=0;i<map_head.mapno;i++) // 讀元件(圖形)
{
free(pics[i]);
}
}
void drawscreen(int x,int y) // 繪出整個畫面
{
int i,j,no;
for(j=0;j<8;j++) // 10*20(元件大小)=200
for(i=0;i<13;i++) // 16*20(元件大小)=320
{
no=map_cell[x+i+(y+j)*map_head.mapx].cell[0]; // >=0 才放,不然填黑
if (no >=0) putimage(i*map_head.picx,j*map_head.picy,pics[no]); else
bar(i*map_head.picx,j*map_head.picy,i*map_head.picx+23,j*map_head.picy+23,0);
}
}
int ret_state(int xxxx,int yyyy)
{
return map_cell[xxxx+(yyyy*map_head.mapx)].state; // >=0 才放,不然填黑
}
void write_state(int xxxx,int yyyy,int numberss)
{
map_cell[xxxx+(yyyy*map_head.mapx)].state=numberss; // >=0 才放,不然填黑
}
int ret_other(int xxxx,int yyyy)
{
return map_cell[xxxx+(yyyy*map_head.mapx)].other; // >=0 才放,不然填黑
}
void write_other(int xxxx,int yyyy,int inputss)
{
map_cell[xxxx+(yyyy*map_head.mapx)].other=inputss; // >=0 才放,不然填黑
}
void drawscreen1(int x,int y,unsigned char *fale_mem) // 繪出整個畫面
{
int i,j,no;
for(j=0;j<max_picy;j++) // 10*20(元件大小)=200
for(i=0;i<max_picx;i++) // 16*20(元件大小)=320
{
no=map_cell[x+i+(y+j)*map_head.mapx].cell[0]; // >=0 才放,不然填黑
if (no >=0) put_other_mem(i*map_head.picx,j*map_head.picy,28,28,pics[no],fale_mem);
else
{
bar(i*map_head.picx,j*map_head.picy,i*map_head.picx+27,j*map_head.picy+27,0);
}
}
}
void drawscreen2(int x,int y,unsigned char *fale_mem) // 繪出整個畫面
{
int i,j,no;
for(j=0;j<max_picy;j++) // 10*20(元件大小)=200
for(i=0;i<max_picx;i++) // 16*20(元件大小)=320
{
no=map_cell[x+i+(y+j)*map_head.mapx].cell[1]; // >=0 才放,不然填黑
if (no >=0) put_other_mem(i*map_head.picx,j*map_head.picy,28,28,pics[no],fale_mem);
// if (no >=0) putimage(i*map_head.picx,j*map_head.picy,pics[no]); else
// bar(i*map_head.picx,j*map_head.picy,i*map_head.picx+27,j*map_head.picy+27,0);
}
}
// 程式開始
void drawscreen3(int x,int y,unsigned char *fale_mem) // 繪出整個畫面
{
int i,j,no;
for(j=0;j<max_picy;j++) // 10*20(元件大小)=200
for(i=0;i<max_picx;i++) // 16*20(元件大小)=320
{
no=map_cell[x+i+(y+j)*map_head.mapx].cell[2]; // >=0 才放,不然填黑
if (no >=0) put_other_mem(i*map_head.picx,j*map_head.picy,28,28,pics[no],fale_mem);
// if (no >=0) putimage(i*map_head.picx,j*map_head.picy,pics[no]); else
// bar(i*map_head.picx,j*map_head.picy,i*map_head.picx+27,j*map_head.picy+27,0);
}
}
unsigned char *get_fales; // 程式開始
void read_mem(char *strs,unsigned char *pics,int sizes)
{
FILE *cap;
int i;
cap = fopen(strs,"rb");
if (cap==NULL)
{
initmode(0x3); // 回到文字模式
printf("no find any pct file (read_mem)");
getch();
exit(0);
}
fread(pics,sizes,1,cap);
fclose(cap);
}
char *people[8];
char *magic[8];
///////////////////////////////////////////////////////
// PUT WORD MAIN PART //
////////////////////////////////////////////////////
typedef struct {
char header[22]; //{檔頭 無用}
char name[16]; //{名稱 無用}
char ver[4]; //{1.0}
char mask; //{#1A}
char mode; //{0:BitFont,1:VectFont,2:bitcolor 一定為0 目前}
char extend; //{0:BitPut ,1:BitPut 設定以!=0或!=1判斷}
char size; //{12/15/16/20/24/40/48 無用}
char sizex; //{Default = Size 寬度}
char sizey; //{Default = Size 高度}
char block; //{12=2,20=3,40=5,48=6 }
int sizeof1; //{15=30,16=32 一個字多少BYTE}
long total; //{Total Font Max=65535 全部多少中文字}
long fontoffs; //{Font Offset 字形起始位置 (seek to here) }
long paloffs; //{Palette Offset 無用 }
long fsize; //{File Size Max = 640K 檔案大小}
char reserve [5]; // {無用}
}VCF; //{VCF HEADER SIZE = 72 }
VCF font; //結構宣告一陣列
FILE *V_fp; //檔案指標
void putvcf(unsigned char *string,int lx,int ly,int color)
{ //^^^^^^字串 //X //Y //顏色
static char mask[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01}; //遮罩
unsigned char word[30]/*假設為15字型 */,ascii_buf[2];/*ASCII 對印陣列 */
unsigned long place;//移動位置變數
unsigned int i,j,x,y,pixel,block,column,cstrlen;
cstrlen=strlen(string);//字串長度
for(i=0;i<cstrlen;i++)
{
if(string[i]!=32) //不是空白
{
fseek(V_fp,72,0);//跳過檔頭資訊
for(j=0;j<font.total;j++) //在所有字型總數做判斷
{
fread(ascii_buf,2,1,V_fp);//讀2個ascii
if(string[i]==ascii_buf[0]&&string[i+1]==ascii_buf[1])
{//假如兩個都一樣
place=j;//移動位置變數
break;
}
} //字形起始位置+place*字的大小
fseek(V_fp,font.fontoffs+place*font.sizeof1,0);
fread(word,font.sizeof1,1,V_fp);//讀字的size到陣列
for(column=0;column<font.sizey;column++) //放字的原理
for(block=0;block<font.block;block++) //不懂CALL ME !
for(pixel=0;pixel<8;pixel++)
if((word[column*font.block+block]&mask[pixel])!=0)
{
x=(block<<3)+pixel+lx;
y=column+ly;
putpixel(x,y,color+column);
}
lx=lx+font.sizex; //加字的寬度
i++;
}
else lx=lx+font.sizex/2;//空白的話 加字的寬度的一半;中文是2個ascii
}
}
void mainss(void)
{
// driver=installuserdriver("SVGA256",NULL);
V_fp=fopen("test1.VCF","rb");if(V_fp==NULL)exit(1);
fread(&font,72,1,V_fp);
putvcf(" 武男傳奇 ",12,85,215);
getch();
fclose(V_fp);
}
//銀星工作室站長 : E Chen 陳怡孝
// nx ny
int startx=9,starty=9; // for run_people power function
int next_x=0,next_y=0; // for run_people power function
int run_people (int stx,int sty, int *randd)
{
int ii,auto_con=0,copyx,copyy;
int rands;
/* unsigned char *run_peo[8];
for (ii=0;ii<8;ii++)
run_peo[ii]=(unsigned char *)malloc(788);
read_mem("old1.pct",run_peo[0],788);
read_mem("old2.pct",run_peo[1],788);
read_mem("old3.pct",run_peo[2],788);
read_mem("old4.pct",run_peo[3],788);
read_mem("old5.pct",run_peo[4],788);
read_mem("old6.pct",run_peo[5],788);
read_mem("a7.pct",run_peo[6],788);
read_mem("a8.pct",run_peo[7],788); */
copyx=startx;
copyy=starty;
// write_other(copyx,copyy,10);
// randomize();
rands=random(4);
// printf("...%d",rands);
if (rands==0)
{
if ((ret_state(startx,starty+1)==0) && (starty+1<map_head.mapy))
{
if ((ret_other(startx,starty+1)==0))
{
write_state(next_x,next_y,0);
write_state(startx,starty+1,20);
starty++;
}
}
}
if (rands==1)
{
if ((ret_state(startx-1,starty)==0) && (startx+-1>0))
{
if ((ret_other(startx-1,starty)==0))
{
write_state(next_x,next_y,0);
write_state(startx-1,starty,20);
startx--;
}
}
}
if (rands==2)
{
if ((ret_state(startx+1,starty)==0) && (startx+1<map_head.mapx))
{
if ((ret_other(startx+1,starty)==0))
{
write_state(next_x,next_y,0);
write_state(startx+1,starty,20);
startx++;
}
}
}
if (rands==3)
{
if ((ret_state(startx,starty-1)==0) && (starty-1>0))
{
if ((ret_other(startx,starty-1)==0))
{
write_state(next_x,next_y,0);
write_state(startx,starty-1,20);
starty--;
}
}
}
next_x=startx;
next_y=starty;
if ((abs(startx-(stx+5)) <=5) && (abs(starty-(sty+3)) <=3 ))
{
*randd=rands;
return 1;
// printf(" %d %d ",startx,starty);
// delay(30);
}
if (auto_con==1) auto_con=0; else;auto_con=1;
}
///////////////////////////////////////////////////////
// MAIN PROGRAM STAR //
////////////////////////////////////////////////////
void main(void)
{
int envirment,ranx,rany,randz,figures=0,add_x=0,add_y=0;
int iii,ii=1;
int run=0,chg_run=0;
int ture_y=84,ture_x=140;
int next_nx=0,next_ny=0;
int first_x,first_y,first_nx,first_ny;
int number1,chg=0;
int nx=10;
int ny=7;
int save_maxx,save_maxy;
strings smp,smc,save_smc,save_smp;
int save_run,save_chg_run,save_ture_y,save_ture_x,save_nx,save_ny;
char key;
char *peoples;
get_fales =(unsigned char*)malloc(64000); //
for (ii=0;ii<8;ii++)
people[ii]=(unsigned char *)malloc(788);
peoples=(unsigned char *)malloc(788);
read_mem("a1.pct",people[0],788);
read_mem("a2.pct",people[1],788);
read_mem("a3.pct",people[2],788);
read_mem("a4.pct",people[3],788);
read_mem("a5.pct",people[4],788);
read_mem("a6.pct",people[5],788);
read_mem("a7.pct",people[6],788);
read_mem("a8.pct",people[7],788);
read_mem("old1.pct",peoples,788);
initmode(0x13); // 進入 320x200x256
strcpy(smp,"games1.smp");
strcpy(smc,"games1.smc");
strcpy(scmf,"b.cmf"); //start music
loadsmp(smp); // 讀 .smp
loadsmc(smc); // 讀 .smc
musics(scmf);
bar(0,0,319,199,0); // 清除螢幕 */
for (iii=0;iii<200;iii++)
for (ii=0;ii<320;ii++)
mem_putdot(ii,iii,0,get_fales);
change_bank(get_fales);
drawscreen1(0,0,get_fales); // 畫出一個畫面
drawscreen2(0,0,get_fales); // 畫出一個畫面
drawscreen3(0,0,get_fales); // 畫出一個畫面
V_fp=fopen("a.VCF","rb");if(V_fp==NULL)exit(1);
fread(&font,72,1,V_fp);
putvcf("楓の谷",120,85,216);
fclose(V_fp);
getch();
strcpy(scmf,"b.cmf");
musics(scmf);
while (key!=27)
{
randomize();
while(!kbhit())
{
ContinuePlay();
figures++;
if ((envirment==1) && (figures==200)) /// the inkey make active
{
if (run_people(nx,ny,&randz)==1)
{
drawscreen1(nx,ny,get_fales);
put_other_mem(ture_x,ture_y,28,28,people[run],get_fales);
drawscreen2(nx,ny,get_fales);
drawscreen3(nx,ny,get_fales);
put_other_mem((startx-nx)*28,(starty-ny)*28,28,28,people[randz*2+chg],get_fales);
change_bank(get_fales);
}
}
if (figures>=1600) figures=0;
// if (chg==0) chg++; else chg--;
}
key=getch(); // 等待按鍵
if (kbhit())
while (kbhit())
{
key=getch();
ContinuePlay();
figures++;
if ((envirment==1) && (figures==200))
{
if (run_people(nx,ny,&randz)==1)
{
drawscreen1(nx,ny,get_fales);
put_other_mem(ture_x,ture_y,28,28,people[run],get_fales);
drawscreen2(nx,ny,get_fales);
put_other_mem((startx-nx)*28,(starty-ny)*28,28,28,people[randz*2+chg_run],get_fales);
change_bank(get_fales);
}
}
if (figures>=1600) figures=0;
}
switch(key)
{
case 72:{
if ((ny==0) && (ture_y>=28)) ture_y=ture_y-28;
if (ture_y>84)
{
ture_y=ture_y-28;
if (chg_run==0) run=6; else run=7;
}
else
{
if (ny>0) ny--;
{
if (chg_run==0) run=6; else run=7;
}
}
break;
} // 上
case 13:{
// printf("x = %d, y = %d ",nx+(ture_x/28),ny+(ture_y/28));
/* printf(" save_cmf %s\n",save_cmf);
printf(" scmf %s\n",scmf);
printf(" smp %s\n",smp);
printf(" save_smp %s\n",save_smp);
printf(" smc %s\n",smc);
printf(" save_smc %s\n",save_smc);
printf("nx = %d, ny = %d \n",nx,ny);
printf("ture_x = %d, ture_y = %d \n",ture_x,ture_y);
printf("first_x = %d, firsty = %d \n",first_x,first_y);*/
V_fp=fopen("a.VCF","rb");if(V_fp==NULL)exit(1);
fread(&font,72,1,V_fp);
putvcf("楓の谷",120,85,216);
fclose(V_fp);
getch();
break;
}
case 80:{
if ((ny==map_head.mapy-max_picy) && (ture_y<=28*(max_picy-2))) ture_y=ture_y+28;
if (ture_y<84)
{
ture_y=ture_y+28;
if (chg_run==0) run=0; else run=1;
}
else
{
if (ny<map_head.mapy-max_picy) ny++;
{
if (chg_run==0) run=0; else run=1;
}
}
break;
} // 下
case 75:{
if ((nx==0) && (ture_x>=28)) ture_x=ture_x-28;
if (ture_x>140)
{
ture_x=ture_x-28;
if (chg_run==0) run=2; else run=3;
}
else
{
if (nx>0) nx--;
{
if (chg_run==0) run=2; else run=3;
}
}
break;
} // 左
case 77:{
if ((nx==map_head.mapx-max_picx) && (ture_x<=28*(max_picx-2))) ture_x=ture_x+28;
if (ture_x<140)
{
ture_x=ture_x+28;
if (chg_run==0) run=4; else run=5;
}
else
{
if (nx<map_head.mapx-max_picx) nx++;
{
if (chg_run==0) run=4; else run=5;
}
}
break;
} // 右
case 96:{
printf(" 96 \n");
if ((run==0) || (run==1)) add_y++;
if ((run==2) || (run==3)) add_x--;
if ((run==4) || (run==5)) add_x++;
if ((run==6) || (run==7)) add_y--;
printf(" The state is %d \n",ret_state(add_x+(nx+ture_x/28),add_y+(ny+ture_y/28)));
getch();
// if (ret_state(add_x+nx+ture_x/28,add_y+ny+ture_y/28)==20)
add_y=0;
add_x=0;
break;
}
case 9:{
printf(" 9 \n");
if ((run==0) || (run==1)) add_y++;
if ((run==2) || (run==3)) add_x--;
if ((run==4) || (run==5)) add_x++;
if ((run==6) || (run==7)) add_y--;
printf(" The other is %d \n",ret_other(add_x+(nx+ture_x/28),add_y+(ny+ture_y/28)));
getch();
// if (ret_state(add_x+nx+ture_x/28,add_y+ny+ture_y/28)==20)
add_y=0;
add_x=0;
break;
}
}
if (ret_other(nx+(ture_x/28),ny+(ture_y/28))==1)
{
freesmc();
StopMusic();
free(buf);
strcpy(save_smp,smp);
strcpy(save_smc,smc);
strcpy(save_cmf,scmf);
save_run = run;
save_chg_run = chg_run;
save_ture_y = ture_y;
save_ture_x = ture_x;
save_nx = nx;
save_ny = ny;
printf("save_cmf %s\n",save_cmf);
printf("scmf %s\n",cmf);
printf("smp %s\n",smp);
printf("smc %s\n",smc);
printf("save_smp %s\n",save_smp);
printf("save_smc %s\n",save_smc);
getch();
if ((nx==5) && (ny==1))
{
envirment=1;
set_right(map_cell_head.mappal); // 設調色盤
getch();
strcpy(smp ,"rooms1.smp") ;
strcpy(smc ,"rooms1.smc") ;
strcpy(scmf,"1000.cmf" ) ;
loadsmp(smp); // 讀 .smp
loadsmc(smc); // 讀 .smc
musics(scmf);
run=0;
chg_run=0;
ture_y=84;
ture_x=140;
nx=4;
ny=10;
}
if ((nx==19) && (ny==0))
{
set_right(map_cell_head.mappal); // 設調色盤
strcpy(smp ,"map1.smp");
strcpy(smc , "map1.smc");
strcpy(scmf,"axel-f.cmf" ) ;
loadsmp(smp); // 讀 .smp
loadsmc(smc); // 讀 .smc
musics(scmf);
run=0;
chg_run=0;
ture_y=84;
ture_x=140;
nx=5;
ny=10;
}
if ((nx==19) && (ny==2))
{
set_right(map_cell_head.mappal); // 設調色盤
strcpy(smp ,"house1.smp");
strcpy(smc , "house1.smc");
strcpy(scmf,"letter.cmf" ) ;
loadsmp(smp); // 讀 .smp
loadsmc(smc); // 讀 .smc
musics(scmf);
run=0;
chg_run=0;
ture_y=84;
ture_x=140;
nx=5;
ny=10;
}
}
if (ret_other(nx+(ture_x/28),ny+(ture_y/28))==-1)
{
StopMusic();
free(buf);
freesmc();
strcpy(smp , save_smp);
strcpy(smc , save_smc);
strcpy(scmf, save_cmf);
loadsmp(save_smp); // 讀 .smp
loadsmc(save_smc); // 讀 .smc
musics(scmf);
run = save_run ;
chg_run = save_chg_run;
ture_y = save_ture_y ;
ture_x = save_ture_x ;
nx = save_nx ;
ny = save_ny ;
}
if (ret_state(nx+(ture_x/28),ny+(ture_y/28))==0)
{
write_state(next_nx,next_ny,0);
write_state(nx+(ture_x/28),ny+(ture_y/28),10);
drawscreen1(nx,ny,get_fales);
put_other_mem(ture_x,ture_y,28,28,people[run],get_fales);
if (run_people(nx,ny,&randz)==1)
{
put_other_mem((startx-nx)*28,(starty-ny)*28,28,28,people[randz*2+chg_run],get_fales);
}
next_nx=nx+ture_x/28;
next_ny=ny+ture_y/28;
first_x=ture_x;
first_y=ture_y;
first_nx=nx;
first_ny=ny;
drawscreen2(nx,ny,get_fales);
drawscreen3(nx,ny,get_fales);
}
else
{
number1=map_cell[first_nx+(first_x/28)+(first_ny+first_y/28)*map_head.mapx].cell[0]; // >=0 才放,不然填黑
put_other_mem(first_x,first_y,28,28,pics[number1],get_fales);
put_other_mem(first_x,first_y,28,28,people[run],get_fales);
drawscreen2(first_nx,first_ny,get_fales);
drawscreen3(first_nx,first_ny,get_fales);
ture_x=first_x;
ture_y=first_y;
nx=first_nx;
ny=first_ny;
}
if (chg_run==0) chg_run++; else chg_run--;
change_bank(get_fales);
// 更新畫面
}
freesmc();
free(buf);
free(get_fales);
free(pics);
free(people);
initmode(0x3); // 回到文字模式
StopMusic();
}


0 Responses to "銀星工作室 CWMAP 97 地圖編輯器 Falesss.c"
留下您的意見: