home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fun CD 26
/
OTACD26.ISO
/
etc
/
nawkk
/
yane0310
/
ygs2k156.lzh
/
source
/
TScript.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2000-03-11
|
56KB
|
1,538 lines
// TScript.cpp
#include "TScript.h"
//////////////////////////////////////////////////////////////////////////////
#ifdef StartUp // スタートアップルーチンは必要なのか?
//////////////////////////////////////////////////////////////////////////////
// スクリプトコンパイラーのシーン描画関数
//////////////////////////////////////////////////////////////////////////////
SCENE_DEFINE(GameStart) {
SCENE_STATIC(TScript,cmp){
if (cmp->m_nDebugMode!=0) {
cmp->SetDebugMode(((cmp->m_nDebugMode-1) & 2)!=0); // デバッグ用スクリプトのアセンブルファイル出力
ErrorlogOutputEnable(((cmp->m_nDebugMode-1) & 1)!=0); // デバッグ用内部エラー出力
}
cmp->SetInstructionAreaSize(TInstructionArea);
LRESULT hr;
hr = cmp->Load("script/gamestart.c",false);
if (hr<0){
// ファイルが存在しなければダイアログを開いて、実行するファイルを問い合わせる
CYFileDialog file;
char buf[256];
file.SetFileExt("c");
if (file.GetOpenFileName(buf)!=0 || cmp->Load(buf,false)!=0) {
ysFrame.ReturnScene(); // それだけなのよん
ysFrame.SetGameExit(NULL); // 終了したときに呼び出される関数
return ;
}
} else if (hr>0) { // コンパイルエラー
ysFrame.ReturnScene(); // それだけなのよん
ysFrame.SetGameExit(NULL); // 終了したときに呼び出される関数
return ;
}
}
SCENE_INITIALIZER;
LRESULT hr = cmp->ReExecute();
if (hr==0) {
ysFrame.ReturnScene(); // 実行終了
ysFrame.SetGameExit(NULL); // 終了したときに呼び出される関数
// 正常終了なのだから、確認は不要
return ;
}
}
//////////////////////////////////////////////////////////////////////////////
LRESULT Goodbye(void){
bool b = ysFrame.YesNo("確認","本当に終了するのですか?");
if (b) return 0; else return 1;
}
//////////////////////////////////////////////////////////////////////////////
// フレームワークからウィンドゥの生成前に呼び出される。
//////////////////////////////////////////////////////////////////////////////
void GameMain(void) {
ErrorlogOutputEnable(false); // デバッグ用エラー出力
ysFrame.SetAppName("YaneGameScript2000Platform");
ysFrame.SetNextScene(GameStart); // 次に表示するシーンの設定
ysWindow.SetWindowStyle(WS_VISIBLE|WS_SYSMENU|WS_CAPTION|WS_MINIMIZEBOX); // 最大化ボタンは付けない
ysFrame.SetGameExit(Goodbye); // 終了したときに呼び出される関数
ysDraw.SetDisplayMode(WindowMode,640,480,8);
ysFrame.SetMultiApp(false);
// イニシャライザを起動
LRESULT hr;
TScript cmp;
cmp.SetInstructionAreaSize(TInstructionArea);
hr = cmp.Load("script/gameinit.c",false);
if (hr==0) {
cmp.ReExecute();
} else if (hr>0) { // コンパイルエラー(ファイルが存在しないのはOK)
ysFrame.SetGameExit(NULL); // 終了したときに呼び出される関数
ysFrame.Quit(); // それだけなのよん
return ;
}
}
#endif
//////////////////////////////////////////////////////////////////////////////
// ディフォルトイニシャライザの用意
//////////////////////////////////////////////////////////////////////////////
#ifdef DefaultTScript // ディフォルトイニシャライザが必要なのか?
void TScript::Initialize(void) { }
void TScript::Terminate(void) { }
#endif
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// スクリプト関数の定義
//////////////////////////////////////////////////////////////////////////////
TScript* TScript::m_this = NULL;
TScript::TScript(void){
m_this = this; // 掟破り:p
// staticなCSoundは不可。(デストラクタで処理が利かないため)
m_sound = new CSound [m_nSoundMax];
m_plane = new CPlane [m_nPlaneMax];
m_gametime = new CGameTime [m_nGameTimeMax];
m_fpslayer = new CFPSLayer;
m_textlayer = new CTextLayer [m_nTextLayerMax];
m_alpString = new LPSTR [m_nStringMax];
for(int i=0;i<m_nStringMax;i++) {
m_alpString[i] = new char[m_nStringLength];
}
m_lpszSenarioString = new char[m_nStringLength];
// Randomize
srand((unsigned)CTimeBase::timeGetTime()); // これで十分でしょう
/////////////////////////////////////////////////////////////////
// ユーザー公開関数の登録
/////////////////////////////////////////////////////////////////
// デバッグ用
RegistUserFunction("InnerLog",InnerLog);
RegistUserFunction("InnerLogMes",InnerLogMes);
// Wave
RegistUserFunction("LoadWave",LoadWave);
RegistUserFunction("PlayWave",PlayWave);
RegistUserFunction("StopWave",StopWave);
RegistUserFunction("PauseWave",PauseWave);
RegistUserFunction("ReplayWave",ReplayWave);
RegistUserFunction("IsPlayWave",IsPlayWave);
RegistUserFunction("ReleaseWave",ReleaseWave);
RegistUserFunction("ReleaseWaveAll",ReleaseWaveAll);
RegistUserFunction("SetLoopModeWave",SetLoopModeWave);
RegistUserFunction("SetVolumeWave",SetVolumeWave);
RegistUserFunction("SetVolumeWaveAll",SetVolumeWaveAll);
RegistUserFunction("SetWaveFormat",SetWaveFormat);
// CD関連
RegistUserFunction("OpenCD",OpenCD);
RegistUserFunction("CloseCD",CloseCD);
RegistUserFunction("StopCD",StopCD);
RegistUserFunction("PauseCD",PauseCD);
RegistUserFunction("ReplayCD",ReplayCD);
RegistUserFunction("PlayCDFromStart",PlayCDFromStart);
RegistUserFunction("PlayCD",PlayCD);
RegistUserFunction("PlayCDFromTo",PlayCDFromTo);
RegistUserFunction("PlayCDPos",PlayCDPos);
RegistUserFunction("IsPlayCD",IsPlayCD);
RegistUserFunction("SetLoopModeCD",SetLoopModeCD);
RegistUserFunction("GetSongMaxCD",GetSongMaxCD);
RegistUserFunction("GetCurrentPosCD",GetCurrentPosCD);
RegistUserFunction("EjectCD",EjectCD);
RegistUserVariable("SongLengthCD",(LONG&)ysCD.m_dwSongLength);
RegistUserVariable("SongStartCD",(LONG&)ysCD.m_dwSongStart);
// MIDI関連
RegistUserFunction("LoadMIDI",LoadMIDI);
RegistUserFunction("PlayMIDI",PlayMIDI);
RegistUserFunction("StopMIDI",StopMIDI);
RegistUserFunction("PauseMIDI",PauseMIDI);
RegistUserFunction("ReplayMIDI",ReplayMIDI);
RegistUserFunction("ReleaseMIDI",ReleaseMIDI);
RegistUserFunction("IsPlayMIDI",IsPlayMIDI);
RegistUserFunction("SetLoopModeMIDI",SetLoopModeMIDI);
// Bitmap関連
RegistUserFunction("GetBpp",GetBpp);
RegistUserFunction("LoadBitmap",LoadBitmapFile);
RegistUserFunction("LoadBitmapW",LoadBitmapFileW);
RegistUserFunction("SaveBitmap",SaveBitmapFile);
RegistUserFunction("ReleaseBitmap",ReleaseBitmap);
RegistUserFunction("GetPlaneSize",GetPlaneSize);
RegistUserFunction("SetColorKeyRGB",SetColorKeyRGB);
RegistUserFunction("SetColorKeyPos",SetColorKeyPos);
RegistUserFunction("ClearSecondary",ClearSecondary);
RegistUserFunction("ClearSecondaryRect",ClearSecondaryRect);
RegistUserFunction("SetFillColor",SetFillColor);
RegistUserFunction("SetFillColorRGB",SetFillColorRGB);
RegistUserFunction("Blt",Blt);
RegistUserFunction("BltRect",BltRect);
RegistUserFunction("BltFast",BltFast);
RegistUserFunction("BltFastRect",BltFastRect);
RegistUserFunction("BlendBlt",BlendBlt);
RegistUserFunction("BlendBltRect",BlendBltRect);
RegistUserFunction("ClipBlt",ClipBlt);
RegistUserFunction("ClipBltRect",ClipBltRect);
RegistUserFunction("ClipBltFast",ClipBltFast);
RegistUserFunction("ClipBltFastRect",ClipBltFastRect);
RegistUserFunction("ClipBlendBlt",ClipBlendBlt);
RegistUserFunction("ClipBlendBltRect",ClipBlendBltRect);
RegistUserFunction("BltR",BltR);
RegistUserFunction("BltRectR",BltRectR);
RegistUserFunction("BltFastR",BltFastR);
RegistUserFunction("BltFastRectR",BltFastRectR);
RegistUserFunction("BlendBltR",BlendBltR);
RegistUserFunction("BlendBltRectR",BlendBltRectR);
RegistUserFunction("ClipBltR",ClipBltR);
RegistUserFunction("ClipBltRectR",ClipBltRectR);
RegistUserFunction("ClipBltFastR",ClipBltFastR);
RegistUserFunction("ClipBltFastRectR",ClipBltFastRectR);
RegistUserFunction("ClipBlendBltR",ClipBlendBltR);
RegistUserFunction("ClipBlendBltRectR",ClipBlendBltRectR);
RegistUserFunction("EnableBlendColorKey",EnableBlendColorKey);
RegistUserFunction("FlushBlt",FlushBlt);
RegistUserFunction("MosaicBlt",MosaicBlt);
RegistUserFunction("CreateSurface",CreateSurface);
RegistUserFunction("SwapToSecondary",SwapToSecondary);
RegistUserFunction("SetSecondaryOffset",SetSecondaryOffset);
// FPS関連
RegistUserFunction("SetFPS",SetFPS);
RegistUserFunction("GetFPS",GetFPS);
RegistUserFunction("GetRealFPS",GetRealFPS);
RegistUserFunction("ResetTime",ResetTime);
RegistUserFunction("GetTime",GetTime);
RegistUserFunction("PauseTime",PauseTime);
RegistUserFunction("RestartTime",RestartTime);
RegistUserFunction("PauseTimeAll",PauseTimeAll);
RegistUserFunction("RestartTimeAll",RestartTimeAll);
// FPS表示関連
RegistUserFunction("FPSLayerOn",FPSLayerOn);
RegistUserFunction("FPSLayerOff",FPSLayerOff);
// 画面効果関連
RegistUserFunction("SetBrightness",SetBrightness);
RegistUserFunction("RealizePalette",RealizePalette);
RegistUserFunction("FlushPalette",FlushPalette);
RegistUserFunction("SetSystemMemoryUse",SetSystemMemoryUse);
// 文字表示関連
RegistUserFunction("TextLayerOn",TextLayerOn);
RegistUserFunction("TextLayerOff",TextLayerOff);
RegistUserFunction("TextMove",TextMove);
RegistUserFunction("TextOut",TextOut);
RegistUserFunction("TextSize",TextSize);
RegistUserFunction("TextHeight",TextHeight);
RegistUserFunction("TextColor",TextColor);
RegistUserFunction("TextBackColor",TextBackColor);
RegistUserFunction("TextBackColorDisable",TextBackColorDisable);
RegistUserFunction("TextFont",TextFont);
RegistUserFunction("TextBlend",TextBlend);
RegistUserFunction("TextBlt",TextBlt);
RegistUserFunction("TextGetSize",TextGetSize);
// 文字列操作関数
RegistUserFunction("strcpy",strcpy);
RegistUserFunction("strncpy",strncpy);
RegistUserFunction("strcat",strcat);
RegistUserFunction("sprintf",sprintf);
RegistUserFunction("sprintf0",sprintf0); // 互換性のため残す
RegistUserFunction("sprintf1",sprintf1);
RegistUserFunction("sprintf2",sprintf2);
RegistUserFunction("sprintf3",sprintf3);
// キー入力関数
RegistUserFunction("KeyInput",KeyInput);
RegistUserFunction("IsPressUpKey",IsPressUpKey);
RegistUserFunction("IsPressDownKey",IsPressDownKey);
RegistUserFunction("IsPressLeftKey",IsPressLeftKey);
RegistUserFunction("IsPressRightKey",IsPressRightKey);
RegistUserFunction("IsPressReturnKey",IsPressReturnKey);
RegistUserFunction("IsPressSpaceKey",IsPressSpaceKey);
RegistUserFunction("IsPressEscKey",IsPressEscKey);
RegistUserFunction("IsPushUpKey",IsPushUpKey);
RegistUserFunction("IsPushDownKey",IsPushDownKey);
RegistUserFunction("IsPushLeftKey",IsPushLeftKey);
RegistUserFunction("IsPushRightKey",IsPushRightKey);
RegistUserFunction("IsPushReturnKey",IsPushReturnKey);
RegistUserFunction("IsPushSpaceKey",IsPushSpaceKey);
RegistUserFunction("IsPushEscKey",IsPushEscKey);
RegistUserFunction("IsPushKey",IsPushKey); // 汎用Key
RegistUserFunction("IsPressKey",IsPressKey);
RegistUserFunction("IsPushJoyKey",IsPushJoyKey); // 汎用JoyStick
RegistUserFunction("IsPressJoyKey",IsPressJoyKey);
RegistUserFunction("SetJoyButtonMax",SetJoyButtonMax);
RegistUserFunction("IsPushMIDIKey",IsPushMIDIKey); // 汎用MIDI
RegistUserFunction("IsPressMIDIKey",IsPressMIDIKey);
RegistUserFunction("GetVelocityMIDIKey",GetVelocityMIDIKey);
RegistUserFunction("MouseLayerOn",MouseLayerOn); // Mouse入力
RegistUserFunction("MouseLayerOff",MouseLayerOff);
RegistUserFunction("GetMouseInfo",GetMouseInfo);
RegistUserFunction("SetMouseInfo",SetMouseInfo);
// バックアッププレーン
RegistUserFunction("EnableBackupPlane",EnableBackupPlane);
RegistUserFunction("DisableBackupPlane",DisableBackupPlane);
RegistUserFunction("SnapToBackupPlane",SnapToBackupPlane);
RegistUserFunction("BltFromBackupPlane",BltFromBackupPlane);
RegistUserFunction("SaveBackupPlane",SaveBackupPlane);
// シナリオ機能
RegistUserFunction("OpenSenario",OpenSenario);
RegistUserFunction("ReadSenario",ReadSenario);
RegistUserFunction("OpenSenario2",OpenSenario2);
RegistUserFunction("ReadSenarioToString",ReadSenarioToString);
RegistUserFunction("ReadLineToString",ReadLineToString);
// ディスプレイモードの変更
RegistUserFunction("SetDisplayMode",SetDisplayMode);
RegistUserFunction("ChangeDisplayMode",ChangeDisplayMode);
// ファイル入出力
RegistUserFunction("LoadFile",LoadFile);
RegistUserFunction("SaveFile",SaveFile);
// new,delete
TMemory.clear();
RegistUserFunction("new",NewMemory);
RegistUserFunction("delete",DeleteMemory);
// LoadLibrary,FreeLibrary
TLibrary.clear();
RegistUserFunction("LoadLibrary",LoadLibrary);
RegistUserFunction("FreeLibrary",FreeLibrary);
RegistUserFunction("GetFunction",GetFunction);
// その他
RegistUserFunction("Rand",Rand);
RegistUserFunction("GetCurrentDirectory",GetCurrentDirectory);
RegistUserFunction("SetCurrentDirectory",SetCurrentDirectory);
RegistUserFunction("SetConstParam",SetConstParam);
RegistUserFunction("GetConstParam",GetConstParam);
// ゲームフラグ管理
RegistUserFunction("LoadGameFlag",LoadGameFlag);
RegistUserFunction("SaveGameFlag",SaveGameFlag);
RegistUserFunction("LoadGameFlag2",LoadGameFlag2);
RegistUserFunction("SaveGameFlag2",SaveGameFlag2);
RegistUserFunction("ResetGameFlag",ResetGameFlag);
RegistUserFunction("ResetGameFlag2",ResetGameFlag2);
// User変数
RegistUserVariable("gameflag",m_GameFlag[0]);
RegistUserVariable("gameflag2",m_GameFlag2[0]);
RegistUserVariable("string",(LONG&)m_alpString[0]);
// イニシャライザでのみ呼び出される
RegistUserFunction("SetWindow",SetWindow);
RegistUserFunction("SetDebugMode",TSetDebugMode);
Initialize(); // 各ゲーム専用初期化
}
/////////////////////////////////////////////////////////////////
TScript::~TScript(){
DELETEPTR_SAFE(m_sound);
DELETEPTR_SAFE(m_plane);
DELETEPTR_SAFE(m_gametime);
DELETE_SAFE(m_fpslayer);
DELETEPTR_SAFE(m_textlayer);
for(int i=0;i<m_nStringMax;i++) {
DELETE_SAFE(m_alpString[i]);
}
DELETE_SAFE(m_alpString);
DELETE_SAFE(m_lpszSenarioString);
DELETE_SAFE(m_yfpSenario);
{
set<BYTE*>::iterator it = TMemory.begin();
while (it!=TMemory.end()) { // delete忘れをすべてdelete
delete *it;
it ++;
}
TMemory.clear(); // 一応クリア
}
{
multiset<HINSTANCE>::iterator it = TLibrary.begin();
while (it!=TLibrary.end()) { // FreeLibrary忘れをすべてFreeLibrary
::FreeLibrary(*it);
it ++;
}
TLibrary.clear(); // 一応クリア
}
// mouse入力の解放
DELETE_SAFE(m_mouselayer);
DELETE_SAFE(m_mouseinput);
Terminate(); // 各ゲーム専用終了コード
ysDraw.EnableBackupPlane(false); // バックアッププレーンつぶしておく:p
ysDraw.SetFillColor(0); // 余計なお世話か?
ysDraw.SetBrightness(256);
ysCD.Close();
}
/////////////////////////////////////////////////////////////////////
// スクリプトでユーザーに一般公開している関数
/////////////////////////////////////////////////////////////////////
// デバッグ用
TUserFunc(TScript::InnerLog) {
char buf[256];
wsprintf(buf,"スクリプトから %d が出力されました",*p);
::InnerLog(buf);
return 0;
}
TUserFunc(TScript::InnerLogMes){
char buf[256];
wsprintf(buf,"スクリプトから %s が出力されました",*p);
::InnerLog(buf);
return 0;
}
/////////////////////////////////////////////////////////////////////
// Wave関連
// CSoundクラスを呼び出すだけだから、苦労はゼロ:p
CSound* TScript::m_sound = NULL; // コンストラクタで確保しようね:p
TUserFunc(TScript::LoadWave) { return m_sound[*(p+1)].LoadWaveFile((LPSTR)*p);}
TUserFunc(TScript::PlayWave) { return m_sound[*p].Play(); }
TUserFunc(TScript::StopWave) { return m_sound[*p].Stop(); }
TUserFunc(TScript::PauseWave) { return m_sound[*p].Pause(); }
TUserFunc(TScript::ReplayWave) { return m_sound[*p].Replay(); }
TUserFunc(TScript::IsPlayWave) { return m_sound[*p].IsPlay();}
TUserFunc(TScript::SetLoopModeWave) { m_sound[*p].SetLoopMode(*(p+1)!=0); return 0; }
TUserFunc(TScript::ReleaseWave) { return m_sound[*p].ReleaseWave();}
TUserFunc(TScript::ReleaseWaveAll) {
for(int i=0;i<m_nSoundMax;i++){
m_sound[i].ReleaseWave();
}
return 0;
}
TUserFunc(TScript::SetVolumeWave) { return m_sound[*p].SetVolume(*(p+1));}
TUserFunc(TScript::SetVolumeWaveAll){
for(int i=0;i<m_nSoundMax;i++){
m_sound[i].SetVolume(*p);
}
return 0;
}
TUserFunc(TScript::SetWaveFormat) { return ysSound.SetFormat((int)*p); }
/////////////////////////////////////////////////////////////////////
// MIDI関連
// MIDIクラスを呼び出すだけだから、苦労はゼロ:p
TUserFunc(TScript::LoadMIDI) { return ysMIDIOut.Open((LPSTR)*p); }
TUserFunc(TScript::PlayMIDI) { return ysMIDIOut.Play(); }
TUserFunc(TScript::StopMIDI) { return ysMIDIOut.Stop(); }
TUserFunc(TScript::PauseMIDI) { return ysMIDIOut.Pause(); }
TUserFunc(TScript::ReplayMIDI) { return ysMIDIOut.Replay(); }
TUserFunc(TScript::ReleaseMIDI) { return ysMIDIOut.Close(); }
TUserFunc(TScript::IsPlayMIDI) { return ysMIDIOut.IsPlay(); }
TUserFunc(TScript::SetLoopModeMIDI) { return ysMIDIOut.SetLoopMode(*p!=0); }
/////////////////////////////////////////////////////////////////////
// CDDA関連
// CDDAクラスを呼び出すだけだから、苦労はゼロ:p
TUserFunc(TScript::OpenCD) { return ysCD.Open(); }
TUserFunc(TScript::CloseCD) { return ysCD.Close(); }
TUserFunc(TScript::StopCD) { return ysCD.Stop(); }
TUserFunc(TScript::PauseCD) { return ysCD.Pause(); }
TUserFunc(TScript::ReplayCD){ return ysCD.Replay(); }
TUserFunc(TScript::IsPlayCD){
if (ysCD.IsPlay()) return 1; else return 0;
}
TUserFunc(TScript::PlayCDFromStart) { return ysCD.Play(); }
TUserFunc(TScript::PlayCD) { return ysCD.Play(*p); }
TUserFunc(TScript::PlayCDFromTo) { return ysCD.Play(*p,*(p+1)); }
TUserFunc(TScript::PlayCDPos) { return ysCD.PlayDW(*p,*(p+1)); }
TUserFunc(TScript::SetLoopModeCD) { ysCD.SetLoopMode(*p!=0); return 0;}
TUserFunc(TScript::GetSongMaxCD) { return ysCD.GetSongMax();}
TUserFunc(TScript::GetCurrentPosCD) { DWORD dw; ysCD.GetCurrentPos(dw); return dw; }
TUserFunc(TScript::EjectCD) { return ysCD.Eject(*p!=0); }
/////////////////////////////////////////////////////////////////////
// Bitmap関連
// CPlaneクラスを呼び出すだけだから、苦労はゼロ:p
CPlane* TScript::m_plane = NULL; // コンストラクタで確保しようね:p
TUserFunc(TScript::GetBpp) { return CPlane::GetBpp(); }
TUserFunc(TScript::LoadBitmapFile) { return m_plane[*(p+1)].LoadBitmapFile((LPSTR)*p,*(p+2)!=0); }
TUserFunc(TScript::LoadBitmapFileW) { return m_plane[*(p+2)].LoadBitmapFileW((LPSTR)*p,(LPSTR)*(p+1),*(p+3)!=0); }
TUserFunc(TScript::SaveBitmapFile) {
RECT rc;
SetRect(&rc,*(p+2),*(p+3),*(p+2) + *(p+4),*(p+3) + *(p+5));
return m_plane[*(p+1)].SaveBitmapFile((LPSTR)*p,rc);
}
TUserFunc(TScript::ReleaseBitmap) { return m_plane[*p].ReleaseBitmap(); }
TUserFunc(TScript::GetPlaneSize) { m_plane[*p].GetSize((int&)*(long*)*(p+1),(int&)*(long*)*(p+2)); return 0; }
TUserFunc(TScript::SetColorKeyRGB) { return m_plane[*p].SetColorKey(RGB(*(p+1),*(p+2),*(p+3))); }
TUserFunc(TScript::SetColorKeyPos) { return m_plane[*p].SetColorKey(*(p+1),*(p+2)); }
TUserFunc(TScript::ClearSecondary) { return ysDraw.ClearSecondary(); }
TUserFunc(TScript::ClearSecondaryRect) {
RECT r;
SetRect(&r,*p,*(p+1),*p + *(p+2),*(p+1) + *(p+3));
return ysDraw.ClearSecondary(r);
}
TUserFunc(TScript::SetFillColor) { ysDraw.SetFillColor(*p); return 0; }
TUserFunc(TScript::SetFillColorRGB) { ysDraw.SetFillColorRGB(RGB(*p,*(p+1),*(p+2))); return 0; }
TUserFunc(TScript::Blt) { m_plane[*p].Blt(*(p+1),*(p+2)); return 0; }
TUserFunc(TScript::BltRect) {
RECT sr;
SetRect(&sr,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6));
m_plane[*p].Blt(*(p+1),*(p+2),sr);
return 0;
}
TUserFunc(TScript::BltFast) { m_plane[*p].BltFast(*(p+1),*(p+2)); return 0; }
TUserFunc(TScript::BltFastRect) {
RECT sr;
SetRect(&sr,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6));
m_plane[*p].BltFast(*(p+1),*(p+2),sr);
return 0;
}
TUserFunc(TScript::BlendBlt) {
return m_plane[*p].BlendBlt(*(p+1),*(p+2),*(p+3),*(p+4),*(p+5),*(p+6),*(p+7),*(p+8));
}
TUserFunc(TScript::BlendBltRect) {
RECT sr;
SetRect(&sr,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6));
return m_plane[*p].BlendBlt(*(p+1),*(p+2),sr,*(p+7),*(p+8),*(p+9),*(p+10),*(p+11),*(p+12));
}
// 転送先Clip系
TUserFunc(TScript::ClipBlt) {
RECT sr;
SetRect(&sr,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6));
m_plane[*p].ClipBlt(*(p+1),*(p+2),sr);
return 0;
}
TUserFunc(TScript::ClipBltRect) {
RECT sr;
SetRect(&sr,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6));
RECT clip;
SetRect(&clip,*(p+7),*(p+8),*(p+7)+*(p+9),*(p+8)+*(p+10));
m_plane[*p].ClipBlt(*(p+1),*(p+2),sr,clip);
return 0;
}
TUserFunc(TScript::ClipBltFast) {
RECT sr;
SetRect(&sr,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6));
m_plane[*p].ClipBltFast(*(p+1),*(p+2),sr);
return 0;
}
TUserFunc(TScript::ClipBltFastRect) {
RECT sr;
SetRect(&sr,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6));
RECT clip;
SetRect(&clip,*(p+7),*(p+8),*(p+7)+*(p+9),*(p+8)+*(p+10));
m_plane[*p].ClipBltFast(*(p+1),*(p+2),sr,clip);
return 0;
}
TUserFunc(TScript::ClipBlendBlt) {
RECT clip;
SetRect(&clip,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6)); // 転送先矩形
return m_plane[*p].ClipBlendBlt(*(p+1),*(p+2),*(p+7),*(p+8),*(p+9),*(p+10),*(p+11),*(p+12),clip);
}
TUserFunc(TScript::ClipBlendBltRect) {
RECT sr;
SetRect(&sr,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6)); // 転送元矩形
RECT clip;
SetRect(&clip,*(p+7),*(p+8),*(p+7)+*(p+9),*(p+8)+*(p+10)); // 転送先クリッピング
return m_plane[*p].ClipBlendBlt(*(p+1),*(p+2),sr,*(p+11),*(p+12),*(p+13),*(p+14),*(p+15),*(p+16),clip);
}
// 拡大縮小機能付
TUserFunc(TScript::BltR) { m_plane[*p].Blt(*(p+1),*(p+2),(double)*(p+3)/65536,(double)*(p+4)/65536); return 0; }
TUserFunc(TScript::BltRectR) {
RECT sr;
SetRect(&sr,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6));
m_plane[*p].Blt(*(p+1),*(p+2),sr,(double)*(p+7)/65536,(double)*(p+8)/65536);
return 0;
}
TUserFunc(TScript::BltFastR) { m_plane[*p].BltFast(*(p+1),*(p+2),(double)*(p+3)/65536,(double)*(p+4)/65536); return 0; }
TUserFunc(TScript::BltFastRectR) {
RECT sr;
SetRect(&sr,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6));
m_plane[*p].BltFast(*(p+1),*(p+2),sr,(double)*(p+7)/65536,(double)*(p+8)/65536);
return 0;
}
TUserFunc(TScript::BlendBltR) {
return m_plane[*p].BlendBlt(*(p+1),*(p+2),*(p+3),*(p+4),*(p+5),*(p+6),*(p+7),*(p+8),(double)*(p+9)/65536,(double)*(p+10)/65536);
}
TUserFunc(TScript::BlendBltRectR) {
RECT sr;
SetRect(&sr,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6));
return m_plane[*p].BlendBlt(*(p+1),*(p+2),sr,*(p+7),*(p+8),*(p+9),*(p+10),*(p+11),*(p+12),(double)*(p+13)/65536,(double)*(p+14)/65536);
}
TUserFunc(TScript::ClipBltR) {
RECT sr;
SetRect(&sr,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6));
m_plane[*p].ClipBlt(*(p+1),*(p+2),sr,(double)*(p+7)/65536,(double)*(p+8)/65536);
return 0;
}
TUserFunc(TScript::ClipBltRectR) {
RECT sr;
SetRect(&sr,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6));
RECT clip;
SetRect(&clip,*(p+7),*(p+8),*(p+7)+*(p+9),*(p+8)+*(p+10));
m_plane[*p].ClipBlt(*(p+1),*(p+2),sr,clip,(double)*(p+11)/65536,(double)*(p+12)/65536);
return 0;
}
TUserFunc(TScript::ClipBltFastR) {
RECT sr;
SetRect(&sr,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6));
m_plane[*p].ClipBltFast(*(p+1),*(p+2),sr,(double)*(p+7)/65536,(double)*(p+8)/65536);
return 0;
}
TUserFunc(TScript::ClipBltFastRectR){
RECT sr;
SetRect(&sr,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6));
RECT clip;
SetRect(&clip,*(p+7),*(p+8),*(p+7)+*(p+9),*(p+8)+*(p+10));
m_plane[*p].ClipBltFast(*(p+1),*(p+2),sr,clip,(double)*(p+11)/65536,(double)*(p+12)/65536);
return 0;
}
TUserFunc(TScript::ClipBlendBltR) {
RECT clip;
SetRect(&clip,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6)); // 転送先矩形
return m_plane[*p].ClipBlendBlt(*(p+1),*(p+2),*(p+7),*(p+8),*(p+9),*(p+10),*(p+11),*(p+12),clip,(double)*(p+13)/65536,(double)*(p+14)/65536);
}
TUserFunc(TScript::ClipBlendBltRectR){
RECT sr;
SetRect(&sr,*(p+3),*(p+4),*(p+3)+*(p+5),*(p+4)+*(p+6)); // 転送元矩形
RECT clip;
SetRect(&clip,*(p+7),*(p+8),*(p+7)+*(p+9),*(p+8)+*(p+10)); // 転送先クリッピング
return m_plane[*p].ClipBlendBlt(*(p+1),*(p+2),sr,*(p+11),*(p+12),*(p+13),*(p+14),*(p+15),*(p+16),clip,(double)*(p+17)/65536,(double)*(p+18)/65536);
}
TUserFunc(TScript::EnableBlendColorKey){
m_plane[*p].EnableBlendColorKey(*(p+1)!=0);
return 0;
}
TUserFunc(TScript::FlushBlt) { // added '99/12/1
RECT sr;
SetRect(&sr,*(p+1),*(p+2),*(p+1)+*(p+3),*(p+2)+*(p+4));
return m_plane[*p].FlushBlt(sr);
}
TUserFunc(TScript::MosaicBlt) { // added '99/12/1
RECT sr;
SetRect(&sr,*(p+1),*(p+2),*(p+1)+*(p+3),*(p+2)+*(p+4));
return m_plane[*p].MosaicBlt(sr,*(p+5));
}
TUserFunc(TScript::CreateSurface){
return m_plane[*p].CreateSurface(*(p+1),*(p+2));
}
TUserFunc(TScript::SwapToSecondary){
return m_plane[*p].SwapToSecondary();
}
TUserFunc(TScript::SetSecondaryOffset){
return ysDraw.SetSecondaryOffset(*p,*(p+1));
}
/////////////////////////////////////////////////////////////////////
// タイマー関連
CGameTime* TScript::m_gametime = NULL;
TUserFunc(TScript::SetFPS) { ysTime.SetFPS(*p); return 0; }
TUserFunc(TScript::GetFPS) { return ysTime.GetFPS(); }
TUserFunc(TScript::GetRealFPS) { return ysTime.GetRealFPS(); }
TUserFunc(TScript::ResetTime) { m_gametime[*p].ResetTime(); return 0; }
TUserFunc(TScript::GetTime) { return m_gametime[*p].GetTime(); }
TUserFunc(TScript::PauseTime) { m_gametime[*p].PauseTime(); return 0; }
TUserFunc(TScript::RestartTime) { m_gametime[*p].RestartTime(); return 0; }
TUserFunc(TScript::PauseTimeAll) { return m_gametime[*p].PauseTimeAll(); }
TUserFunc(TScript::RestartTimeAll) { return m_gametime[*p].RestartTimeAll(); }
/////////////////////////////////////////////////////////////////////
// FPS表示関連
CFPSLayer* TScript::m_fpslayer = NULL;
TUserFunc(TScript::FPSLayerOn) { LayerScreen += m_fpslayer; m_fpslayer->Move(*p,*(p+1)); return 0; }
TUserFunc(TScript::FPSLayerOff) { LayerScreen -= m_fpslayer; return 0; }
/////////////////////////////////////////////////////////////////////
// 画面効果関連
TUserFunc(TScript::SetBrightness) { ysDraw.SetBrightness(*p); return 0; }
TUserFunc(TScript::RealizePalette) { ysDraw.RealizePalette(m_plane[*p]); return 0; }
TUserFunc(TScript::FlushPalette) { ysDraw.FlushPalette(); return 0; }
TUserFunc(TScript::SetSystemMemoryUse) { ysDraw.SetSystemMemoryUse(*p!=0); return 0; }
/////////////////////////////////////////////////////////////////////
// 文字列表示関連
CTextLayer* TScript::m_textlayer = NULL;
TUserFunc(TScript::TextLayerOn) { LayerScreen += m_textlayer[*p]; m_textlayer[*p].Move(*(p+1),*(p+2)); return 0; }
TUserFunc(TScript::TextLayerOff) { LayerScreen -= m_textlayer[*p]; return 0; }
TUserFunc(TScript::TextMove) { m_textlayer[*p].Move(*(p+1),*(p+2)); return 0; }
TUserFunc(TScript::TextOut) { m_textlayer[*p].SetText((LPSTR)*(p+1)); return 0; }
TUserFunc(TScript::TextSize) { m_textlayer[*p].SetFontSize(*(p+1)); return 0; }
TUserFunc(TScript::TextHeight) { m_textlayer[*p].SetHeight(*(p+1)); return 0; }
TUserFunc(TScript::TextColor) { m_textlayer[*p].SetColor(RGB(*(p+1),*(p+2),*(p+3))); return 0; }
TUserFunc(TScript::TextBackColor) { m_textlayer[*p].SetBackColor(RGB(*(p+1),*(p+2),*(p+3))); return 0; }
TUserFunc(TScript::TextBackColorDisable){ m_textlayer[*p].SetBackColor(CLR_INVALID); return 0; }
TUserFunc(TScript::TextFont) {
if (0<=*(p+1) && *(p+1)<=4) {
m_textlayer[*p].SetFont(*(p+1)); // 0から4か
} else {
m_textlayer[*p].SetFont((LPSTR)*(p+1)); // さもなくば文字列ポインタ
}
return 0;
}
TUserFunc(TScript::TextBlend) { m_textlayer[*p].SetBlend(*(p+1)); return 0; }
TUserFunc(TScript::TextBlt) {
m_textlayer[*p].OnPaint();
// textlayerの直接描画には、hdcも必要。
HDC hdc;
if (ysDraw.BeginPaintSecondary(hdc)==0){
m_textlayer[*p].OnPaint(hdc);
ysDraw.EndPaintSecondary();
return 0;
} else {
return 1;
}
}
TUserFunc(TScript::TextGetSize) { return m_textlayer[*p].GetSize((int&)*(int*)*(p+1),(int&)*(int*)*(p+2)); }
/////////////////////////////////////////////////////////////////////
// 文字列操作関数
LPSTR* TScript::m_alpString;
TUserFunc(TScript::strcpy) { return (LONG)::strcpy((LPSTR)*p,(LPSTR)*(p+1)); }
TUserFunc(TScript::strncpy) { // 漢字コードを考慮したn文字コピー
LPSTR p1 = (LPSTR)*p;
LPSTR p2 = (LPSTR)*(p+1);
int n = *(p+2);
for(;*p2!='\0' && n;n--,p1++){
*p1 = *(p2++);
// 漢字なのか?
if ((((BYTE)*p1)>=0x80 && ((BYTE)*p1)<=0xa0)||(((BYTE)*p1)>=0xe0 && ((BYTE)*p1)<=0xff)) *(++p1) = *(p2++);
}
*p1 = '\0'; // 終端文字だけ入れとかなくっちゃ!
return n;
}
TUserFunc(TScript::strcat) { return (LONG)::strcat((LPSTR)*p,(LPSTR)*(p+1)); }
TUserFunc(TScript::sprintf) { ::wvsprintf((LPSTR)*p,(LPSTR)*(p+1),(va_list)(p+2)); return 0; }
TUserFunc(TScript::sprintf0) { ::wsprintf((LPSTR)*p,(LPSTR)*(p+1)); return 0; }
TUserFunc(TScript::sprintf1) { ::wsprintf((LPSTR)*p,(LPSTR)*(p+1),*(p+2)); return 0; }
TUserFunc(TScript::sprintf2) { ::wsprintf((LPSTR)*p,(LPSTR)*(p+1),*(p+2),*(p+3)); return 0; }
TUserFunc(TScript::sprintf3) { ::wsprintf((LPSTR)*p,(LPSTR)*(p+1),*(p+2),*(p+3),*(p+4)); return 0; }
/////////////////////////////////////////////////////////////////////
// キー入力関数
TUserFunc(TScript::KeyInput) { KEY_INPUT; ysMIDIIn.GetKeyState(); return 0; }
TUserFunc(TScript::IsPressUpKey) { return RKEY_8; }
TUserFunc(TScript::IsPressDownKey) { return RKEY_2; }
TUserFunc(TScript::IsPressLeftKey) { return RKEY_4; }
TUserFunc(TScript::IsPressRightKey) { return RKEY_6; }
TUserFunc(TScript::IsPressSpaceKey) {
if (TUSE_XZ_FOR_BUTTON) return RKEY_SPACE || KEYPRESS(DIK_Z);
return RKEY_SPACE;
}
TUserFunc(TScript::IsPressReturnKey) {
if (TUSE_XZ_FOR_BUTTON) return RKEY_RETURN || KEYPRESS(DIK_X);
return RKEY_RETURN;
}
TUserFunc(TScript::IsPressEscKey) { return RKEY_ESC; }
TUserFunc(TScript::IsPushUpKey) { return KEY_8; }
TUserFunc(TScript::IsPushDownKey) { return KEY_2; }
TUserFunc(TScript::IsPushLeftKey) { return KEY_4; }
TUserFunc(TScript::IsPushRightKey) { return KEY_6; }
TUserFunc(TScript::IsPushSpaceKey) {
if (TUSE_XZ_FOR_BUTTON) return KEY_SPACE || KEYPUSH(DIK_Z);
return KEY_SPACE;
}
TUserFunc(TScript::IsPushReturnKey) {
if (TUSE_XZ_FOR_BUTTON) return KEY_RETURN || KEYPUSH(DIK_X);
return KEY_RETURN;
}
TUserFunc(TScript::IsPushEscKey) { return KEY_ESC; }
TUserFunc(TScript::IsPushKey) { return ysInput.IsKeyPushDown(*p); }
TUserFunc(TScript::IsPressKey) { return ysInput.IsKeyPress(*p); }
TUserFunc(TScript::IsPushJoyKey) { return ysJoy.IsKeyPushDown(*p); }
TUserFunc(TScript::IsPressJoyKey) { return ysJoy.IsKeyPress(*p); }
TUserFunc(TScript::SetJoyButtonMax) { ysJoy.SetButtonMax(*p); return 0;}
TUserFunc(TScript::IsPushMIDIKey) { return ysMIDIIn.IsKeyPushDown(*p); }
TUserFunc(TScript::IsPressMIDIKey) { return ysMIDIIn.IsKeyPress(*p); }
TUserFunc(TScript::GetVelocityMIDIKey) { return ysMIDIIn.GetVelocity(*p); }
CMouseLayer* TScript::m_mouselayer = NULL;
CMouseInput* TScript::m_mouseinput = NULL;
TUserFunc(TScript::MouseLayerOn) {
if (m_mouselayer!=NULL) {
m_mouselayer->SetPlane(&m_plane[*p],*(p+1),*(p+2));
} else {
m_mouselayer = new CMouseLayer(&m_plane[*p],*(p+1),*(p+2));
}
if (m_mouseinput==NULL) {
m_mouseinput = new CMouseInput;
}
return 0;
}
TUserFunc(TScript::MouseLayerOff) {
DELETE_SAFE(m_mouselayer);
DELETE_SAFE(m_mouseinput);
return 0;
}
TUserFunc(TScript::GetMouseInfo) {
if (m_mouseinput==NULL) return 1; // error
m_mouseinput->GetInfo((int&)*(int*)*p,(int&)*(int*)*(p+1),(int&)*(int*)*(p+2));
return 0;
}
TUserFunc(TScript::SetMouseInfo) {
if (m_mouseinput==NULL) return 1; // error
m_mouseinput->SetXY((int)*p,(int)*(p+1));
return 0;
}
/////////////////////////////////////////////////////////////////////
// バックアッププレーン
TUserFunc(TScript::EnableBackupPlane) { ysDraw.EnableBackupPlane(true); return 0; }
TUserFunc(TScript::DisableBackupPlane) { ysDraw.EnableBackupPlane(false); return 0; }
TUserFunc(TScript::SnapToBackupPlane) { ysDraw.SnapToBackupPlane(); return 0; }
TUserFunc(TScript::BltFromBackupPlane) { if (ysDraw.BltFromBackupPlane()) { ysDraw.ClearSecondary(); return 1; } else return 0; }
TUserFunc(TScript::SaveBackupPlane) { return ysDraw.GetBackupPlane()->SaveBitmapFile((LPSTR)*p); }
/////////////////////////////////////////////////////////////////////
// シナリオ機能(要は、メッセージ表示機能)
CYFile* TScript::m_yfpSenario = NULL;
int TScript::m_nSenarioTextLayerNo = 0;
LPSTR TScript::m_lpszSenarioString = NULL;
TUserFunc(TScript::OpenSenario) {
DELETE_SAFE(m_yfpSenario);
m_yfpSenario = new CYFile;
// ReadFile!!
if (m_yfpSenario->ReadFile((LPSTR)*p)!=0) {
DELETE_SAFE(m_yfpSenario);
return 2; // OpenError!!
}
m_nSenarioTextLayerNo = *(p+1);
return ReadSenario2();
}
TUserFunc(TScript::ReadSenario) {
KeyInput(NULL);
if (IsPushSpaceKey(NULL)) {
return ReadSenario2();
} else {
return 0;
}
}
TUserFunc(TScript::OpenSenario2) {
DELETE_SAFE(m_yfpSenario);
m_yfpSenario = new CYFile;
// ReadFile!!
if (m_yfpSenario->ReadFile((LPSTR)*p)!=0) {
DELETE_SAFE(m_yfpSenario);
return 2; // OpenError!!
}
return 0;
}
TUserFunc(TScript::ReadSenarioToString) {
if (m_yfpSenario==NULL) return 3; // 呼ぶなっちゅーに!
if (m_yfpSenario->ReadLine2((LPSTR)*p)!=0) {
DELETE_SAFE(m_yfpSenario);
return 1;
}
return 0;
}
TUserFunc(TScript::ReadLineToString) {
if (m_yfpSenario==NULL) return 3; // 呼ぶなっちゅーに!
if (m_yfpSenario->ReadLine((LPSTR)*p)!=0) {
DELETE_SAFE(m_yfpSenario);
return 1;
}
return 0;
}
/////////////////////////////////////////////////////////////////
long TScript::ReadSenario2(void){
if (m_yfpSenario==NULL) return 3; // 呼ぶなっちゅーに!
if (m_yfpSenario->ReadLine2(m_lpszSenarioString)!=0) {
DELETE_SAFE(m_yfpSenario);
return 1;
}
m_textlayer[m_nSenarioTextLayerNo].SetText(m_lpszSenarioString);
return 0;
}
/////////////////////////////////////////////////////////////////////
// ディスプレイモードの変更
int TScript::m_nDisplayMode1 = 0;
int TScript::m_nDisplayMode2 = 1;
TUserFunc(TScript::SetDisplayMode) { m_nDisplayMode1 = *p; m_nDisplayMode2 = *(p+1); return 0; }
TUserFunc(TScript::ChangeDisplayMode) {
int DisplayMode = 0;
switch (*p) {
case 1: DisplayMode = m_nDisplayMode1; break;
case 2: DisplayMode = m_nDisplayMode2; break;
default: return 1; // Error!!
}
// DisplayMode 0:ScreenMode,1:FullScreen256,2:FullScreen64K,3:FullScreen16M,4:TrueColor
if (DisplayMode==0) {
return ysDraw.SetDisplayMode(WindowMode);
}
ysDraw.BeginChangeDisplay();
switch(DisplayMode){
case 1: break;
case 2: goto Disp16;
case 3: goto Disp24;
case 4: goto Disp32;
}
// FullScreenModeのときは、希望するモードにならなければ、その次の解像度にする。
ysDraw.TestDisplayMode(FullScreenMode,640,480,8);
Disp16:
ysDraw.TestDisplayMode(FullScreenMode,640,480,16);
Disp24:
ysDraw.TestDisplayMode(FullScreenMode,640,480,24);
Disp32:
ysDraw.TestDisplayMode(FullScreenMode,640,480,32);
ysDraw.TestDisplayMode(WindowMode,640,480,0); // Windowモードならなんでも良い
return ysDraw.EndChangeDisplay();
}
/////////////////////////////////////////////////////////////////////
// ファイル入出力
TUserFunc(TScript::LoadFile) {
CYFile file;
if (file.ReadFile((LPSTR)*p)==0) {
CopyMemory((LPBYTE)*(p+1),file.GetFileMemory(),*(p+2));
return 0;
}
return 1;
}
TUserFunc(TScript::SaveFile) {
CYFile file;
return file.WriteFile((LPSTR)*p,(LPBYTE)*(p+1),*(p+2));
}
/////////////////////////////////////////////////////////////////////
// その他
TUserFunc(TScript::Rand) { return rand() % *p; }
TUserFunc(TScript::GetCurrentDirectory) {
string dir;
dir = CYFile::GetCurrentDirectory();
::strcpy((LPSTR)*p,dir.c_str());
return 0;
}
TUserFunc(TScript::SetCurrentDirectory) {
CYFile::SetCurrentDirectory((LPSTR)*p);
return 0;
}
/////////////////////////////////////////////////////////////////////
// ユーザー変数関連
LONG TScript::m_GameFlag[TGameFlagMax];
LONG TScript::m_GameFlag2[TGameFlagMax2];
TUserFunc(TScript::LoadGameFlag) {
CYFile file;
if (file.ReadFile((LPSTR)*p)==0) {
CopyMemory(TScript::m_GameFlag,file.GetFileMemory(),(sizeof(LONG))* TGameFlagMax);
return 0;
}
return 1;
}
TUserFunc(TScript::SaveGameFlag) {
CYFile file;
return file.WriteFile((LPSTR)*p,TScript::m_GameFlag,(sizeof(LONG)) * TGameFlagMax);
}
TUserFunc(TScript::LoadGameFlag2) {
CYFile file;
if (file.ReadFile((LPSTR)*p)==0) {
CopyMemory(TScript::m_GameFlag2,file.GetFileMemory(),(sizeof(LONG))* TGameFlagMax2);
return 0;
}
return 1;
}
TUserFunc(TScript::SaveGameFlag2) {
CYFile file;
return file.WriteFile((LPSTR)*p,TScript::m_GameFlag2,(sizeof(LONG)) * TGameFlagMax2);
}
TUserFunc(TScript::ResetGameFlag){
for (int i=0;i<TGameFlagMax;i++){
m_GameFlag[i] = 0;
}
return 0;
}
TUserFunc(TScript::ResetGameFlag2){
for (int i=0;i<TGameFlagMax2;i++){
m_GameFlag2[i] = 0;
}
return 0;
}
/////////////////////////////////////////////////////////////////////
CBytePtrArray TScript::TMemory;
TUserFunc(TScript::NewMemory){
BYTE *pb = new BYTE[*p];
TMemory.insert(pb);
return (LONG)pb;
}
TUserFunc(TScript::DeleteMemory){
int n;
n = TMemory.erase((BYTE*)*p); // 削除
if (n==0) return 1; // そんなんnewして無いやん?
delete (BYTE*)*p;
return 0;
}
/////////////////////////////////////////////////////////////////////
// LoadLibrary,FreeLibrary
CLibraryArray TScript::TLibrary;
TUserFunc(TScript::LoadLibrary) {
HINSTANCE h = ::LoadLibrary(CYFile::MakeFullName((LPSTR)*p).c_str());
if (h==NULL) return 0;
TLibrary.insert(h);
return (LONG)h;
}
TUserFunc(TScript::FreeLibrary) {
multiset<HINSTANCE>::iterator it;
it = TLibrary.find((HINSTANCE)*p);
if (it==TLibrary.end()) return 1; // そんなんLoadLibraryして無いやん?
TLibrary.erase(it); // 削除
return ::FreeLibrary((HINSTANCE)*p)?0:1;
}
TUserFunc(TScript::GetFunction) {
FARPROC proc = GetProcAddress((HMODULE)*p,(LPCSTR)*(p+1));
return (LONG)proc;
}
/////////////////////////////////////////////////////////////////////
TUserFunc(TScript::SetWindow){
ysDraw.SetDisplayMode((EScreenMode)*p,*(p+1),*(p+2),*(p+3));
return 0;
}
int TScript::m_nDebugMode = 0;
TUserFunc(TScript::TSetDebugMode){
m_nDebugMode = *p + 1; // 1加算しておく
return 0;
}
/////////////////////////////////////////////////////////////////////
// 各種定数設定
// 各種定数初期化
int TScript::m_nSoundMax = TSoundMax; // 総Soundチャンネル数
int TScript::m_nPlaneMax = TPlaneMax; // 総プレーン数
int TScript::m_nGameTimeMax = TGameTimeMax; // 総GameTime数
int TScript::m_nTextLayerMax = TTextLayerMax; // 総テキストレイヤー数
int TScript::m_nStringMax = TStringMax; // string配列の数
int TScript::m_nStringLength = TStringLength; // string配列の大きさ
bool TScript::m_bUSE_XZ_FOR_BUTTON = TUSE_XZ_FOR_BUTTON; // XとZキーをスペース、リターンに割り当てる
DWORD TScript::m_dwInstructionArea = TInstructionArea; // 命令エリアサイズ非制限
// ScriptSDKに関数をエクスポートするためのクラス (C)yaneurao '00/01/04
// クラスは、前方参照すると、レイアウトが狂うので…
#pragma pointers_to_members(full_generality,multiple_inheritance)
// 詳しくは、
// http://www.sun-inet.or.jp/~yaneurao/rsp/
// スーパープログラマーへの道 第90回~94回を参照のこと。
class CScriptSDK {
protected:
// CPlane関連
LPDIRECTDRAWSURFACE (CPlane::*GetSurface)(void);
LPDIRECTDRAWPALETTE (CPlane::*GetPalette)(void);
LRESULT (CPlane::*LoadBitmapFile)(string BitmapFileName,bool bLoadPalette=true);
LRESULT (CPlane::*LoadBitmapFileW)(string BitmapFileName256,string BitmapFileNameElse
,bool bLoadPalette=true);
LRESULT (CPlane::*ReleaseBitmap)(void);
LRESULT (CPlane::*GetSize)(int &x,int &y);
LRESULT (CPlane::*SetColorKey)(COLORREF rgb);
LRESULT (CPlane::*SetColorKeyPos)(int x,int y);
LRESULT (CPlane::*Blt)(int x,int y);
LRESULT (CPlane::*BltRect)(int x,int y,RECT r);
LRESULT (CPlane::*BltFast)(int x,int y);
LRESULT (CPlane::*BltFastRect)(int x,int y,RECT r);
LRESULT (CPlane::*BlendBlt)(int x,int y,int ar,int ag,int ab,int br,int bg,int bb);
LRESULT (CPlane::*BlendBltRect)(int x,int y,RECT &rc,int ar,int ag,int ab,int br,int bg,int bb);
LRESULT (CPlane::*ClipBlt)(int x,int y,RECT &clip);
LRESULT (CPlane::*ClipBltRect)(int x,int y,RECT r,RECT &clip);
LRESULT (CPlane::*ClipBltFast)(int x,int y,RECT &clip);
LRESULT (CPlane::*ClipBltFastRect)(int x,int y,RECT r,RECT &clip);
LRESULT (CPlane::*ClipBlendBlt)(int x,int y,int ar,int ag,int ab,int br,int bg,int bb,RECT &clip);
LRESULT (CPlane::*ClipBlendBltRect)(int x,int y,RECT rc,int ar,int ag,int ab,int br,int bg,int bb,RECT &clip);
LRESULT (CPlane::*BltR)(int x,int y,double rx,double ry=-1);
LRESULT (CPlane::*BltRectR)(int x,int y,RECT &sr,double rx,double ry=-1);
LRESULT (CPlane::*BltFastR)(int x,int y,double rx,double ry=-1);
LRESULT (CPlane::*BltFastRectR)(int x,int y,RECT &sr,double rx,double ry=-1);
LRESULT (CPlane::*ClipBltR)(int x,int y,RECT &clip,double rx,double ry=-1);
LRESULT (CPlane::*ClipBltRectR)(int x,int y,RECT &sr,RECT &clip,double rx,double ry=-1);
LRESULT (CPlane::*ClipBltFastR)(int x,int y,RECT &clip,double rx,double ry=-1);
LRESULT (CPlane::*ClipBltFastRectR)(int x,int y,RECT &sr,RECT &clip,double rx,double ry=-1);
LRESULT (CPlane::*BlendBltR)(int x,int y,int ar,int ag,int ab,int br,int bg,int bb,double rx,double ry=-1);
LRESULT (CPlane::*BlendBltRectR)(int x,int y,RECT &rc,int ar,int ag,int ab,int br,int bg,int bb,double rx,double ry=-1);
LRESULT (CPlane::*ClipBlendBltR)(int x,int y,int ar,int ag,int ab,int br,int bg,int bb,RECT &clip,double rx,double ry=-1);
LRESULT (CPlane::*ClipBlendBltRectR)(int x,int y,RECT rc,int ar,int ag,int ab,int br,int bg,int bb,RECT &clip,double rx,double ry=-1);
LRESULT (CPlane::*EnableBlendColorKey)(bool b);
LRESULT (CPlane::*FlushBlt)(RECT &r);
LRESULT (CPlane::*MosaicBlt)(RECT &r,int d);
LRESULT (CPlane::*CreateSurface)(int x,int y);
LRESULT (CPlane::*BeginPaint)(HDC &hdc);
LRESULT (CPlane::*EndPaint)(void);
LRESULT (CPlane::*SwapToSecondary)(void);
CPlane* (*CreateCPlaneInstance)(void);
void (*DeleteCPlaneInstance)(CPlane*);
// Draw関連
void (CDirectDraw::*SetFillColor)(DWORD dwFillColor);
void (CDirectDraw::*SetFillColorRGB)(COLORREF rgb);
int (CDirectDraw::*GetBpp)(void);
LRESULT (CDirectDraw::*ClearSecondary)(void);
LRESULT (CDirectDraw::*ClearSecondaryRect)(RECT &r);
LRESULT (CDirectDraw::*SetSecondaryOffset)(int ox,int oy);
LRESULT (CDirectDraw::*BeginPaintSecondary)(HDC& hdc);
LRESULT (CDirectDraw::*EndPaintSecondary)(void);
LRESULT (CDirectDraw::*RealizePalette)(CPlane &plane);
void (CDirectDraw::*SetBrightness)(int bright);
void (CDirectDraw::*FlushPalette)(void);
LPDIRECTDRAWPALETTE (CDirectDraw::*GetMainPalette)(void);
LPDIRECTDRAWSURFACE (CDirectDraw::*GetSecondary)(void);
// CSound関連
LRESULT (CSound::*LoadWaveFile)(const string& filename);
LRESULT (CSound::*ReleaseWave)(void);
LRESULT (CSound::*Play)(void);
LRESULT (CSound::*Stop)(void);
bool (CSound::*IsPlay)(void);
LRESULT (CSound::*Pause)(void);
LRESULT (CSound::*Replay)(void);
LRESULT (CSound::*SetVolume)(long volume);
long (CSound::*GetVolume)(void);
void (CSound::*SetLoopMode)(bool bLoop);
CSound* (*CreateCSoundInstance)(void);
void (*DeleteCSoundInstance)(CSound*);
// File関連
LRESULT (CYFile::*ReadFile)(string filename);
LPVOID (CYFile::*GetFileMemory)(void);
DWORD (CYFile::*GetFileSize)(void);
void (CYFile::*ReleaseFileBuffer)(void);
LRESULT (CYFile::*WriteFile)(string filename,LPVOID mem,DWORD size);
LRESULT (CYFile::*ReadLine)(LPSTR buf);
LRESULT (CYFile::*ReadLine2)(LPSTR buf);
LRESULT (CYFile::*ReadData)(BYTE*p,DWORD size);
CYFile* (*CreateCYFileInstance)(void);
void (*DeleteCYFileInstance)(CYFile*);
// MIDI関連
LRESULT (CMIDIOutput::*MIDIOpen)(LPCTSTR pFileName,LPCTSTR pType=NULL);
LRESULT (CMIDIOutput::*MIDIClose)(void);
LRESULT (CMIDIOutput::*MIDIPlay)(void);
LRESULT (CMIDIOutput::*MIDIReplay)(void);
LRESULT (CMIDIOutput::*MIDIStop)(void);
LRESULT (CMIDIOutput::*MIDIPause)(void);
BOOL (CMIDIOutput::*MIDIIsPlay)()const;
LRESULT (CMIDIOutput::*MIDISetLoopMode)(BOOL bLoop);
// CD関連
LRESULT (CCDDA::*CDOpen)(void);
LRESULT (CCDDA::*CDClose)(void);
LRESULT (CCDDA::*CDStop)(void);
LRESULT (CCDDA::*CDPause)(void);
LRESULT (CCDDA::*CDReplay)(void);
LRESULT (CCDDA::*CDPlay)(void);
LRESULT (CCDDA::*CDPlay2)(int);
bool (CCDDA::*CDIsPlay)(void);
void (CCDDA::*CDSetLoopMode)(bool bLoop);
int (CCDDA::*CDGetSongMax)(void);
LRESULT (CCDDA::*CDEject)(bool bEject);
// キー入力関連
void (CVirtualKey::*ClearKeyDevice)(void);
void (CVirtualKey::*AddDevice)(CKeyBase*);
void (CVirtualKey::*RemoveDevice)(CKeyBase*);
void (CVirtualKey::*KeyInput)(void);
void (CVirtualKey::*ClearKeyList)(void);
void (CVirtualKey::*AddKey)(int vkey,CKeyBase*,int key);
void (CVirtualKey::*RemoveKey)(int vkey,CKeyBase*,int key);
bool (CVirtualKey::*IsVKeyPress)(int vkey);
bool (CVirtualKey::*IsVKeyPushDown)(int vkey);
CVirtualKey* (*CreateCVirtualKeyInstance)(void);
void (*DeleteCVirtualKeyInstance)(CVirtualKey*);
// CGameTime
void (CGameTime::*ResetTime)(void);
DWORD (CGameTime::*GetTime)(void);
void (CGameTime::*PauseTime)(void);
void (CGameTime::*RestartTime)(void);
CGameTime* (*CreateCGameTimeInstance)(void);
void (*DeleteCGameTimeInstance)(CGameTime*);
// その他
// エクスポートする関数を追加する場合は、ここに追加すること。決して途中に挿入しないこと。
LRESULT (CPlane::*SaveBitmapFile)(LPSTR filename,RECT &rc);
// Factory
private:
static CPlane* _CreateCPlaneInstance(void) { return new CPlane; }
static void _DeleteCPlaneInstance(CPlane* p) { delete p; }
static CSound* _CreateCSoundInstance(void) { return new CSound; }
static void _DeleteCSoundInstance(CSound* p) { delete p; }
static CYFile* _CreateCYFileInstance(void) { return new CYFile; }
static void _DeleteCYFileInstance(CYFile* p) { delete p; }
static CVirtualKey* _CreateCVirtualKeyInstance(void) { return new CVirtualKey; }
static void _DeleteCVirtualKeyInstance(CVirtualKey* p) { delete p; }
static CGameTime* _CreateCGameTimeInstance(void) { return new CGameTime; }
static void _DeleteCGameTimeInstance(CGameTime* p) { delete p; }
// Initialize
public:
CScriptSDK(void) {
GetSurface = CPlane::GetSurface;
GetPalette = CPlane::GetPalette;
LoadBitmapFile = CPlane::LoadBitmapFile;
LoadBitmapFileW = CPlane::LoadBitmapFileW;
SaveBitmapFile = CPlane::SaveBitmapFile; // added on ver1.01
ReleaseBitmap = CPlane::ReleaseBitmap;
GetSize = CPlane::GetSize;
SetColorKey = CPlane::SetColorKey;
SetColorKeyPos = CPlane::SetColorKey;
Blt = CPlane::Blt;
BltRect = CPlane::Blt;
BltFast = CPlane::BltFast;
BltFastRect = CPlane::BltFast;
BlendBlt = CPlane::BlendBlt;
BlendBltRect = CPlane::BlendBlt;
ClipBlt = CPlane::ClipBlt;
ClipBltRect = CPlane::ClipBlt;
ClipBltFast = CPlane::ClipBltFast;
ClipBltFastRect = CPlane::ClipBltFast;
ClipBlendBlt = CPlane::ClipBlendBlt;
ClipBlendBltRect= CPlane::ClipBlendBlt;
BltR = CPlane::Blt;
BltRectR = CPlane::Blt;
BltFastR = CPlane::BltFast;
BltFastRectR = CPlane::BltFast;
BlendBltR = CPlane::BlendBlt;
BlendBltRectR = CPlane::BlendBlt;
ClipBltR = CPlane::ClipBlt;
ClipBltRectR = CPlane::ClipBlt;
ClipBltFastR = CPlane::ClipBltFast;
ClipBltFastRectR= CPlane::ClipBltFast;
ClipBlendBltR = CPlane::ClipBlendBlt;
ClipBlendBltRectR=CPlane::ClipBlendBlt;
EnableBlendColorKey=CPlane::EnableBlendColorKey;
FlushBlt =CPlane::FlushBlt;
MosaicBlt =CPlane::MosaicBlt;
CreateSurface =CPlane::CreateSurface;
BeginPaint =CPlane::BeginPaint;
EndPaint =CPlane::EndPaint;
SwapToSecondary =CPlane::SwapToSecondary;
CreateCPlaneInstance = _CreateCPlaneInstance;
DeleteCPlaneInstance = _DeleteCPlaneInstance;
SetFillColor = CDirectDraw::SetFillColor;
SetFillColorRGB = CDirectDraw::SetFillColorRGB;
GetBpp = CDirectDraw::GetBpp;
ClearSecondary = CDirectDraw::ClearSecondary;
ClearSecondaryRect = CDirectDraw::ClearSecondary;
SetSecondaryOffset = CDirectDraw::SetSecondaryOffset;
BeginPaintSecondary = CDirectDraw::BeginPaintSecondary;
EndPaintSecondary = CDirectDraw::EndPaintSecondary;
RealizePalette = CDirectDraw::RealizePalette;
SetBrightness = CDirectDraw::SetBrightness;
FlushPalette = CDirectDraw::FlushPalette;
GetMainPalette = CDirectDraw::GetMainPalette;
GetSecondary = CDirectDraw::GetSecondary;
LoadWaveFile = CSound::LoadWaveFile;
ReleaseWave = CSound::ReleaseWave;
Play = CSound::Play;
Stop = CSound::Stop;
IsPlay = CSound::IsPlay;
Pause = CSound::Pause;
Replay = CSound::Replay;
SetVolume = CSound::SetVolume;
GetVolume = CSound::GetVolume;
SetLoopMode = CSound::SetLoopMode;
CreateCSoundInstance = _CreateCSoundInstance;
DeleteCSoundInstance = _DeleteCSoundInstance;
ReadFile = CYFile::ReadFile;
GetFileMemory = CYFile::GetFileMemory;
GetFileSize = CYFile::GetFileSize;
ReleaseFileBuffer = CYFile::ReleaseFileBuffer;
WriteFile = CYFile::WriteFile;
ReadLine = CYFile::ReadLine;
ReadLine2 = CYFile::ReadLine2;
ReadData = CYFile::ReadData;
CreateCYFileInstance= _CreateCYFileInstance;
DeleteCYFileInstance= _DeleteCYFileInstance;
MIDIOpen = CMIDIOutput::Open;
MIDIClose = CMIDIOutput::Close;
MIDIPlay = CMIDIOutput::Play;
MIDIReplay = CMIDIOutput::Replay;
MIDIStop = CMIDIOutput::Stop;
MIDIPause = CMIDIOutput::Pause;
MIDIIsPlay = CMIDIOutput::IsPlay;
MIDISetLoopMode = CMIDIOutput::SetLoopMode;
CDOpen = CCDDA::Open;
CDClose = CCDDA::Close;
CDStop = CCDDA::Stop;
CDPause = CCDDA::Pause;
CDReplay = CCDDA::Replay;
CDPlay = CCDDA::Play;
CDPlay2 = CCDDA::Play;
CDIsPlay = CCDDA::IsPlay;
CDSetLoopMode=CCDDA::SetLoopMode;
CDGetSongMax= CCDDA::GetSongMax;
CDEject = CCDDA::Eject;
ClearKeyDevice = CVirtualKey::ClearKeyDevice;
AddDevice = CVirtualKey::AddDevice;
RemoveDevice = CVirtualKey::RemoveDevice;
KeyInput = CVirtualKey::KeyInput;
ClearKeyList = CVirtualKey::ClearKeyList;
AddKey = CVirtualKey::AddKey;
RemoveKey = CVirtualKey::RemoveKey;
IsVKeyPress = CVirtualKey::IsVKeyPress;
IsVKeyPushDown = CVirtualKey::IsVKeyPushDown;
CreateCVirtualKeyInstance = _CreateCVirtualKeyInstance;
DeleteCVirtualKeyInstance = _DeleteCVirtualKeyInstance;
ResetTime = CGameTime::ResetTime;
GetTime = CGameTime::GetTime;
PauseTime = CGameTime::PauseTime;
RestartTime = CGameTime::RestartTime;
CreateCGameTimeInstance = _CreateCGameTimeInstance;
DeleteCGameTimeInstance = _DeleteCGameTimeInstance;
}
};
TUserFunc(TScript::SetConstParam){ // 各種定数の途中変更機能
// パラメータをあらかじめいれておく
int n = *(p+1);
bool b = *(p+1)!=0;
LPSTR r = (LPSTR)*(p+1);
// 小文字をすべて大文字に変換してチェックする必要あり
char menu[_MAX_PATH];
ToUpperStr(menu,(LPCSTR)*p);
if (!strcmp(menu,"ENABLEPAUSE")){
ysFrame.SetPauseUse(b);
} else if (!strcmp(menu,"ENABLEMULTIAPP")){
ysFrame.SetMultiApp(b);
} else if (!strcmp(menu,"CAPTION")){
return ysFrame.SetAppName(r);
// あとは、各種定数
} else if (!strcmp(menu,"SOUNDMAX")){
DELETEPTR_SAFE(m_sound);
m_nSoundMax = n;
m_sound = new CSound [m_nSoundMax];
} else if (!strcmp(menu,"PLANEMAX")){
DELETEPTR_SAFE(m_plane);
m_nPlaneMax = n;
m_plane = new CPlane [m_nPlaneMax];
} else if (!strcmp(menu,"GAMETIMEMAX")){
DELETEPTR_SAFE(m_gametime);
m_nGameTimeMax = n;
m_gametime = new CGameTime [m_nGameTimeMax];
} else if (!strcmp(menu,"TEXTLAYERMAX")){
DELETEPTR_SAFE(m_textlayer);
m_nTextLayerMax = n;
m_textlayer = new CTextLayer [m_nTextLayerMax];
} else if (!strcmp(menu,"STRINGMAX")){
// いったん解放
for(int i=0;i<m_nStringMax;i++) {
DELETE_SAFE(m_alpString[i]);
}
DELETE_SAFE(m_alpString);
DELETE_SAFE(m_lpszSenarioString);
m_nStringMax = n;
// 再確保
m_alpString = new LPSTR [m_nStringMax];
for(i=0;i<m_nStringMax;i++) {
m_alpString[i] = new char[m_nStringLength];
}
m_lpszSenarioString = new char[m_nStringLength];
// 再登録
m_this -> RegistUserVariable("string",(LONG&)m_alpString[0]);
} else if (!strcmp(menu,"STRINGLENGTH")){
// いったん解放
for(int i=0;i<m_nStringMax;i++) {
DELETE_SAFE(m_alpString[i]);
}
DELETE_SAFE(m_alpString);
DELETE_SAFE(m_lpszSenarioString);
m_nStringLength = n;
// 再確保
m_alpString = new LPSTR [m_nStringMax];
for(i=0;i<m_nStringMax;i++) {
m_alpString[i] = new char[m_nStringLength];
}
m_lpszSenarioString = new char[m_nStringLength];
// 再登録
m_this -> RegistUserVariable("string",(LONG&)m_alpString[0]);
} else if (!strcmp(menu,"USE_XZ_FOR_BUTTON")){
m_bUSE_XZ_FOR_BUTTON = b;
} else if (!strcmp(menu,"INSTRUCTIONAREA")){
m_dwInstructionArea = n;
// メッセージボックス
} else if (!strcmp(menu,"MESSAGEBOX")){
ysFrame.MessageOut((LPCSTR)*(p+1),(LPCSTR)*(p+2));
} else if (!strcmp(menu,"YESNO")){
return ysFrame.YesNo((LPCSTR)*(p+1),(LPCSTR)*(p+2))?1:0; // これは返し値必要
// フリップ描画
} else if (!strcmp(menu,"USEFLIP")){
ysDraw.SetDirectDrawFlipUse(b);
// ウィンドゥ位置の設定
} else if (!strcmp(menu,"WINDOWPOS")){
ysWindow.SetWindowPos(*(p+1),*(p+2));
} else {
// 未知の命令
return 1;
}
return 0;
}
TUserFunc(TScript::GetConstParam){ // 各種定数の取得機能
// 小文字をすべて大文字に変換してチェックする必要あり
char menu[_MAX_PATH];
ToUpperStr(menu,(LPCSTR)*p);
if (!strcmp(menu,"ENCODEKEY")){
LONG q = (LONG)m_loadfile.c_str();
for(int i=3;i<13;i++){
q ^= 0x53521abf;
q += 0x16234613 >> i;
}
*(p+1) = q;
// ウィンドゥのサイズ取得
} else if (!strcmp(menu,"SCREENSIZE")){
ysWindow.GetScreenSize((int&)*(int*)*(p+1),(int&)*(int*)*(p+2));
// yaneuraoGameScriptSDK用エクスポート
} else if (!strcmp(menu,"SCRIPTSDK")){
static void* pointz[13]; // まあテキトーでええわ
static CScriptSDK scriptsdk;
pointz[0] = &scriptsdk;
pointz[1] = m_plane;
pointz[2] = (void*)m_nPlaneMax; // 最大数を格納
pointz[3] = (void*)sizeof(CPlane); // sizeを格納
pointz[4] = m_sound;
pointz[5] = (void*)m_nSoundMax; // 最大数を格納
pointz[6] = (void*)sizeof(CSound); // sizeを格納
pointz[7] = (void*)&ysDraw;
pointz[8] = (void*)&ysMIDIOut;
pointz[9] = (void*)&ysCD;
pointz[10] = (void*)&ysInput;
pointz[11] = (void*)&ysJoy;
pointz[12] = (void*)&ysMIDIIn;
return (LONG)pointz;
} else {
// 未知の命令
return 1;
}
return 0;
}
void TScript::ToUpperStr(LPSTR q2,LPCSTR q){
// 一応、漢字コードを避けるためのルーチンも入れとこか…
bool kanji=false;
do {
if (kanji) {
kanji = false;
} else if (((BYTE)*q>=0x80 && (BYTE)*q<=0xa0) || ((BYTE)*q>=0xe0 && (BYTE)*q<=0xff)) {
kanji = true; // 2バイトコードの1バイト目であった
} else {
kanji = false; // 2バイトコードの1バイト目ではなかった
}
if (!kanji && (BYTE)*q >='a' && (BYTE)*q <= 'z') {
*q2 = (BYTE)*q - 'a' + 'A';
} else {
*q2 = *q;
}
q2++;
} while (*(q++));
// これで変換完了
}