diff --git a/AdvMan/AdvMan.cpp b/AdvMan/AdvMan.cpp deleted file mode 100644 index 88670a8..0000000 --- a/AdvMan/AdvMan.cpp +++ /dev/null @@ -1,187 +0,0 @@ -// AdvMan.cpp : Defines the class behaviors for the application. -// - -#include "stdafx.h" -#include "AdvMan.h" - -#include "MainFrm.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CAdvManApp - -BEGIN_MESSAGE_MAP(CAdvManApp, CWinApp) - //{{AFX_MSG_MAP(CAdvManApp) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CAdvManApp construction - -CAdvManApp::CAdvManApp() -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CAdvManApp object - -CAdvManApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CAdvManApp initialization - -extern "C" -{ -#include "..\crashdump.h" - -int GetExeVersion(); -} - -int GetExeVersion() -{ - return 1; -} - -BOOL CAdvManApp::InitInstance() -{ -InitCrashDump(); - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - -#ifdef _AFXDLL - Enable3dControls(); // Call this when using MFC in a shared DLL -#else - Enable3dControlsStatic(); // Call this when linking to MFC statically -#endif - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("Bredysoft")); - - - // To create the main window, this code creates a new frame window - // object and then sets it as the application's main window object. - - CMainFrame* pFrame = new CMainFrame; - m_pMainWnd = pFrame; - - // create and load the frame with its resources - - pFrame->LoadFrame(IDR_MAINFRAME, - WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, - NULL); - - - - - // The one and only window has been initialized, so show and update it. - pFrame->ShowWindow(SW_SHOW); - pFrame->UpdateWindow(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CAdvManApp message handlers - - - - - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CAdvManApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// CAdvManApp message handlers - -struct TestDlgInfo -{ - MSG *msg; - BOOL found; - HWND exclude; -}; - -static BOOL WINAPI TestDlgWindows(HWND hWnd, LPARAM lParam) -{ - TestDlgInfo *nfo=(TestDlgInfo *)lParam; - if (hWnd==nfo->exclude) return TRUE; - if (SendMessage(hWnd,WM_APP+9998,0,(LPARAM)nfo->msg) || IsDialogMessage(hWnd,nfo->msg)) - { - nfo->found=TRUE; - return FALSE; - } - return TRUE; -} - -BOOL CAdvManApp::PreTranslateMessage(MSG *pMsg) -{ - TestDlgInfo nfo; - nfo.msg=pMsg; - nfo.found=FALSE; - nfo.exclude=*m_pMainWnd; - - EnumThreadWindows(GetCurrentThreadId(),TestDlgWindows,(LPARAM)&nfo); - return nfo.found; -} diff --git a/AdvMan/AdvMan.h b/AdvMan/AdvMan.h deleted file mode 100644 index f08f54b..0000000 --- a/AdvMan/AdvMan.h +++ /dev/null @@ -1,55 +0,0 @@ -// AdvMan.h : main header file for the ADVMAN application -// - -#if !defined(AFX_ADVMAN_H__A43CD3B3_508C_4DDB_B89C_50FE1291B8B9__INCLUDED_) -#define AFX_ADVMAN_H__A43CD3B3_508C_4DDB_B89C_50FE1291B8B9__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CAdvManApp: -// See AdvMan.cpp for the implementation of this class -// - -class CAdvManApp : public CWinApp -{ -public: - CAdvManApp(); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAdvManApp) - public: - virtual BOOL InitInstance(); - //}}AFX_VIRTUAL - -// Implementation - -public: - //{{AFX_MSG(CAdvManApp) - afx_msg void OnAppAbout(); - // NOTE - the ClassWizard will add and remove member functions here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - - virtual BOOL PreTranslateMessage(MSG *pMsg); -}; - - -///////////////////////////////////////////////////////////////////////////// - -extern CAdvManApp theApp; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_ADVMAN_H__A43CD3B3_508C_4DDB_B89C_50FE1291B8B9__INCLUDED_) diff --git a/AdvMan/AdvMan.rc b/AdvMan/AdvMan.rc deleted file mode 100644 index 1d9b914..0000000 --- a/AdvMan/AdvMan.rc +++ /dev/null @@ -1,569 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Czech resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CSY) -#ifdef _WIN32 -LANGUAGE LANG_CZECH, SUBLANG_DEFAULT -#pragma code_page(1250) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_SPLITTER_RESOURCES\r\n" - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\AdvMan.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP "res\\Toolbar.bmp" -IDR_TOOLEDITORY BITMAP "res\\editory.bmp" -IDR_PREKLADACE BITMAP "res\\prekladace.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR 16, 16 -BEGIN - BUTTON ID_FILE_NOVDOBRODRUST - BUTTON ID_FILE_NATIDOBRODRUSTV - SEPARATOR - BUTTON ID_NSTROJE_MAPEDIT - BUTTON ID_NSTROJE_TESTUJDOBRODRUSTV - SEPARATOR - BUTTON ID_APP_EXIT - SEPARATOR - BUTTON ID_APP_ABOUT -END - -IDR_TOOLEDITORY TOOLBAR 16, 15 -BEGIN - BUTTON ID_EDITORY_KOUZLATAB - BUTTON ID_EDITORY_POSTAVYTAB - BUTTON ID_EDITORY_DIALOGY - BUTTON ID_EDITORY_WEAPONSSCR - BUTTON ID_EDITORY_ITEMSPIC - BUTTON ID_EDITORY_ITEMSSCR -END - -IDR_PREKLADACE TOOLBAR 16, 15 -BEGIN - BUTTON ID_PEKLADAE_PELOKOUZLA - BUTTON ID_PEKLADAE_PELODIALOGY - BUTTON ID_PEKLADAE_PELOPOSTAVYTAB -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "Nové dobrodružstí", ID_FILE_NOVDOBRODRUST - MENUITEM SEPARATOR - MENUITEM "Načti dobrodružství", ID_FILE_NATIDOBRODRUSTV - MENUITEM "Znovu načíst", ID_FILE_ZNOVUNAST - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "Editory" - BEGIN - MENUITEM "KOUZLA.TAB", ID_EDITORY_KOUZLATAB - MENUITEM "POSTAVY.TAB", ID_EDITORY_POSTAVYTAB - MENUITEM "Dialogy", ID_EDITORY_DIALOGY - MENUITEM "ITEMS.SCR", ID_EDITORY_ITEMSSCR - MENUITEM "ITEMS.PIC", ID_EDITORY_ITEMSPIC - MENUITEM "WEAPONS.SCR", ID_EDITORY_WEAPONSSCR - MENUITEM "Soubor ADV", ID_EDITORY_SOUBORADV - END - POPUP "Překladače" - BEGIN - MENUITEM "Přelož kouzla", ID_PEKLADAE_PELOKOUZLA - MENUITEM "Přelož dialogy", ID_PEKLADAE_PELODIALOGY - MENUITEM "Přelož POSTAVY.TAB", ID_PEKLADAE_PELOPOSTAVYTAB - END - POPUP "Nástroje" - BEGIN - MENUITEM "MapEdit", ID_NSTROJE_MAPEDIT - MENUITEM "Testuj dobrodružství", ID_NSTROJE_TESTUJDOBRODRUSTV - MENUITEM SEPARATOR - MENUITEM "Tvůrce podlah", ID_NSTROJE_TVRCEPODLAH - MENUITEM "Tvůrce palet pro nestvůry", ID_NSTROJE_TVRCEPALETPRONESTVRY - - MENUITEM "Tvůrce ikon pro předměty", ID_NSTROJE_TVRCEIKONPROPEDMTY - - MENUITEM "Čtečka DDL souborů", ID_NSTROJE_TEKADDLSOUBOR - MENUITEM SEPARATOR - MENUITEM "Exportuj dobrodružství", ID_NSTROJE_EXPORTUJDOBRODRUSTV - - END - POPUP "&View" - BEGIN - MENUITEM "Hlavní toolbar", ID_VIEW_TOOLBAR - MENUITEM "Překladače", ID_VIEW_PREKLADACE - MENUITEM "Editory", 32810 - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - END - POPUP "&Help" - BEGIN - MENUITEM "&About AdvMan...", ID_APP_ABOUT - END -END - -IDR_EDITORMENU MENU -BEGIN - POPUP "Soubor" - BEGIN - MENUITEM "Uložit", IDOK - MENUITEM SEPARATOR - MENUITEM "Konec", IDCANCEL - END - POPUP "Úpravy" - BEGIN - MENUITEM "Zpět", ID_PRAVY_UNDO - MENUITEM SEPARATOR - MENUITEM "Kopírovat", ID_UPRAVY_COPY - MENUITEM "Vyjmout", ID_UPRAVY_VYJMOUT - MENUITEM "Vložit", ID_UPRAVY_VLOZIT - MENUITEM "Vymazat", ID_UPRAVY_VYMAZAT - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_NOVEDOBR DIALOGEX 0, 0, 234, 297 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Založit nové dobrodružství" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - LTEXT "Jméno nového dobrodružství",IDC_STATIC,7,7,92,8 - EDITTEXT IDC_JMENO,7,18,159,12,ES_AUTOHSCROLL | WS_GROUP - GROUPBOX "Vyber organizaci projektu",IDC_STATIC,7,36,162,60, - WS_GROUP - CONTROL "Nová organizace (doporučeno)",IDC_ORGANIZACE,"Button", - BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,15,55,114,10 - CONTROL "Původní DOSová organizace (kompatibilní)",IDC_RADIO2, - "Button",BS_AUTORADIOBUTTON,15,66,152,10 - CONTROL "Vše v jedné složce (malé projeky)",IDC_RADIO3,"Button", - BS_AUTORADIOBUTTON,15,77,121,10 - GROUPBOX "Do nového projektu vložit",IDC_STATIC,7,98,162,82, - WS_GROUP - CONTROL "Také soubory pro editaci kouzel",IDC_KOUZLA,"Button", - BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,15,111,117,10 - CONTROL "Také soubory pro editaci dialogů",IDC_DIALOGY,"Button", - BS_AUTOCHECKBOX,15,123,119,10 - CONTROL "Také definice grafiky originální hry",IDC_DEFINICE, - "Button",BS_AUTOCHECKBOX,15,135,123,10 - CONTROL "Také všechny mapy z originální hry",IDC_MAPY,"Button", - BS_AUTOCHECKBOX,15,147,127,10 - GROUPBOX "Startovní mapa",IDC_STATIC,7,183,161,29,WS_GROUP - EDITTEXT IDC_STARTMAP,16,193,145,12,ES_AUTOHSCROLL | WS_GROUP - GROUPBOX "Počet členů družiny",IDC_STATIC,7,214,161,42,WS_GROUP - LTEXT "Nejméně",IDC_STATIC,15,228,29,8 - LTEXT "Nejvíce",IDC_STATIC,15,242,26,8 - EDITTEXT IDC_MINPOSTAV,53,226,16,12,ES_MULTILINE | WS_GROUP - EDITTEXT IDC_MAXPOSTAV,53,240,16,12,ES_MULTILINE | WS_GROUP - DEFPUSHBUTTON "OK",IDOK,177,7,50,14,WS_GROUP - PUSHBUTTON "Storno",IDCANCEL,177,24,50,14,NOT WS_TABSTOP - CONTROL "Také originální dialogy",IDC_ORIGDLGS,"Button", - BS_AUTOCHECKBOX,15,159,87,10 -END - -IDD_TEXTEDITOR DIALOGEX 0, 0, 599, 412 -STYLE DS_SETFONT | DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | - WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -CAPTION "Textový editor" -MENU IDR_EDITORMENU -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Uložit (Ctrl+S)",IDOK,540,397,58,14 - EDITTEXT IDC_EDIT,44,0,553,395,ES_MULTILINE | ES_AUTOVSCROLL | - ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_BORDER | - WS_VSCROLL | WS_HSCROLL,WS_EX_STATICEDGE -END - -IDD_DIALOGY DIALOGEX 0, 0, 334, 202 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Dialogy" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - PUSHBUTTON "Zavřít",IDCANCEL,267,24,60,14 - PUSHBUTTON "Upravit dialog",IDC_EDIT,267,68,60,14 - PUSHBUTTON "Přidat dialog",IDC_ADD,267,52,60,14 - PUSHBUTTON "Vymazat dialog",IDC_DELETE,267,85,60,14 - CONTROL "List1",IDC_DLGLIST,"SysListView32",LVS_REPORT | - LVS_SHOWSELALWAYS | LVS_EDITLABELS | WS_BORDER | - WS_TABSTOP,7,7,256,188 - PUSHBUTTON "Obnovit",IDC_RESCAN,267,181,60,14 - DEFPUSHBUTTON "OK",IDOK,267,7,60,14 -END - -IDD_NOVYDIALOG DIALOG 0, 0, 214, 105 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Nový dialog" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,157,67,50,14 - PUSHBUTTON "Cancel",IDCANCEL,157,84,50,14 - LTEXT "Popis dialogu:",IDC_STATIC,7,7,45,8 - EDITTEXT IDC_POPIS,7,18,200,12,ES_AUTOHSCROLL - LTEXT "Jméno souboru dialogu bez přípony (.dlg) - 8 znaků", - IDC_STATIC,7,32,162,8 - COMBOBOX IDC_JMENO,7,43,73,61,CBS_DROPDOWN | CBS_SORT | - WS_VSCROLL | WS_TABSTOP - LTEXT "Čislo dialogu:",IDC_STATIC,7,60,42,8 - LTEXT "Uplatní se pouze pro nově založený dialog",IDC_STATIC,7, - 89,134,8 - COMBOBOX IDC_CISLO,7,72,33,105,CBS_DROPDOWN | CBS_SORT | - WS_VSCROLL | WS_TABSTOP -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_NOVEDOBR, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 227 - TOPMARGIN, 7 - BOTTOMMARGIN, 290 - END - - IDD_TEXTEDITOR, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 592 - TOPMARGIN, 7 - BOTTOMMARGIN, 405 - END - - IDD_DIALOGY, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 327 - TOPMARGIN, 7 - BOTTOMMARGIN, 195 - END - - IDD_NOVYDIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 207 - TOPMARGIN, 7 - BOTTOMMARGIN, 98 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_NOTEPADICON ICON "idc_note.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDR_MAINFRAME "Adventure Manager" - IDS_NOVEDOBRODRUZSTVIDOKONCENO - "Průvodce novým dobrodružstvím dokončil všechny úkoly.\r\n\r\nPokud se zobrazila nějaká chyba, bude nutné po opravě chyby příkaz opakovat, jinak nebude dobrodružství hratelné." - IDS_ADVFILTER "Dobrodružství Skeldalu|*.adv|Všechny soubory|*.*||" - IDS_CHYBAPRICTENI "Chyba při čtení souboru dobrodružství" - IDS_MAINFRAMETITLE "%s - Adventure Manager " - IDS_UNTITLED "Nepojmenované.ADV" - IDS_CANNOTEXECUTE "Nemohu spustit aplikaci '%1'" - IDS_NEMOHUNAJITNICOD "Pozor! Nemohu najít následující soubor(y):\r\n\r\n%1\r\n\r\nChybějící soubory mohou způsobit, že dobrodružství nebude možné hrát." - IDS_EDITADVWARN "Pozor! Změny v souboru ADV se neprojeví ihned. Po uložení nechte znovu načíst dobrodružství pomocí funkce Soubor -> Znovu načíst." - IDS_DLGNAME "Jméno" - IDS_DLGDESC "Popis" - IDS_DLGID "ID" - IDS_UNABLETOSAVEDIALOGYDLG - "Nemohu uložit soubor DIALOGY.DLG. Nastala nějaká chyba." - IDS_NODESC "" -END - -STRINGTABLE -BEGIN - AFX_IDS_APP_TITLE "AdvMan" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompts to save documents\nExit" -END - -STRINGTABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE -BEGIN - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" -END - -#endif // Czech resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOG 0, 0, 235, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About AdvMan" -FONT 8, "MS Sans Serif" -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "AdvMan Version 1.0",IDC_STATIC,40,10,119,8,SS_NOPREFIX - LTEXT "Copyright (C) 2005",IDC_STATIC,40,25,119,8 - DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_ABOUTBOX, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 228 - TOPMARGIN, 7 - BOTTOMMARGIN, 48 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\AdvMan.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS -BEGIN - "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT - VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT - "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "FileDescription", "AdvMan MFC Application" - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "AdvMan" - VALUE "LegalCopyright", "Copyright (C) 2005" - VALUE "OriginalFilename", "AdvMan.EXE" - VALUE "ProductName", "AdvMan Application" - VALUE "ProductVersion", "1, 0, 0, 1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\AdvMan.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/AdvMan/AdvMan.sln b/AdvMan/AdvMan.sln deleted file mode 100644 index d4e56d1..0000000 --- a/AdvMan/AdvMan.sln +++ /dev/null @@ -1,21 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AdvMan", "AdvMan.vcproj", "{D38E31E6-CC5E-4C25-B966-85BF48E8C53E}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {D38E31E6-CC5E-4C25-B966-85BF48E8C53E}.Debug.ActiveCfg = Debug|Win32 - {D38E31E6-CC5E-4C25-B966-85BF48E8C53E}.Debug.Build.0 = Debug|Win32 - {D38E31E6-CC5E-4C25-B966-85BF48E8C53E}.Release.ActiveCfg = Release|Win32 - {D38E31E6-CC5E-4C25-B966-85BF48E8C53E}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/AdvMan/AdvMan.vcproj b/AdvMan/AdvMan.vcproj deleted file mode 100644 index b3f0061..0000000 --- a/AdvMan/AdvMan.vcproj +++ /dev/null @@ -1,525 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/AdvMan/ChildView.cpp b/AdvMan/ChildView.cpp deleted file mode 100644 index d4dc2da..0000000 --- a/AdvMan/ChildView.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// ChildView.cpp : implementation of the CChildView class -// - -#include "stdafx.h" -#include "AdvMan.h" -#include "ChildView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CChildView - -CChildView::CChildView() -{ -} - -CChildView::~CChildView() -{ -} - - -BEGIN_MESSAGE_MAP(CChildView,CWnd ) - //{{AFX_MSG_MAP(CChildView) - ON_WM_PAINT() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CChildView message handlers - -BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs) -{ - if (!CWnd::PreCreateWindow(cs)) - return FALSE; - - cs.dwExStyle |= WS_EX_CLIENTEDGE; - cs.style &= ~WS_BORDER; - cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, - ::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL); - - return TRUE; -} - -void CChildView::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - // TODO: Add your message handler code here - - // Do not call CWnd::OnPaint() for painting messages -} - diff --git a/AdvMan/ChildView.h b/AdvMan/ChildView.h deleted file mode 100644 index 1a31b1d..0000000 --- a/AdvMan/ChildView.h +++ /dev/null @@ -1,51 +0,0 @@ -// ChildView.h : interface of the CChildView class -// -///////////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_CHILDVIEW_H__C7E216F0_6DED_46F2_9E4F_0F71719D08CA__INCLUDED_) -#define AFX_CHILDVIEW_H__C7E216F0_6DED_46F2_9E4F_0F71719D08CA__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -///////////////////////////////////////////////////////////////////////////// -// CChildView window - -class CChildView : public CWnd -{ -// Construction -public: - CChildView(); - -// Attributes -public: - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CChildView) - protected: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CChildView(); - - // Generated message map functions -protected: - //{{AFX_MSG(CChildView) - afx_msg void OnPaint(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_CHILDVIEW_H__C7E216F0_6DED_46F2_9E4F_0F71719D08CA__INCLUDED_) diff --git a/AdvMan/DlgDialogy.cpp b/AdvMan/DlgDialogy.cpp deleted file mode 100644 index e226f8e..0000000 --- a/AdvMan/DlgDialogy.cpp +++ /dev/null @@ -1,264 +0,0 @@ -// DlgDialogy.cpp : implementation file -// - -#include "stdafx.h" -#include "AdvMan.h" -#include "DlgDialogy.h" -#include "../cztable.h" -#include "MainFrm.h" -#include "DlgNovyDialog.h" -#include -#include ".\dlgdialogy.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// DlgDialogy dialog - - -DlgDialogy::DlgDialogy(CWnd* pParent /*=NULL*/) - : CDialog(DlgDialogy::IDD, pParent) -{ - //{{AFX_DATA_INIT(DlgDialogy) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void DlgDialogy::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(DlgDialogy) - DDX_Control(pDX, IDC_DLGLIST, wList); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(DlgDialogy, CDialog) - //{{AFX_MSG_MAP(DlgDialogy) - ON_BN_CLICKED(IDC_RESCAN, OnRescan) - ON_BN_CLICKED(IDC_DELETE, OnDelete) - ON_BN_CLICKED(IDC_EDIT, OnEdit) - ON_NOTIFY(LVN_COLUMNCLICK, IDC_DLGLIST, OnColumnclickDlglist) - ON_BN_CLICKED(IDC_ADD, OnAdd) - ON_NOTIFY(NM_DBLCLK, IDC_DLGLIST, OnNMDblclkDlglist) - //}}AFX_MSG_MAP - ON_NOTIFY(LVN_ENDLABELEDIT, IDC_DLGLIST, OnLvnEndlabeleditDlglist) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// DlgDialogy message handlers - -BOOL DlgDialogy::OnInitDialog() -{ - CDialog::OnInitDialog(); - - wList.InsertColumn(0,CString(MAKEINTRESOURCE(IDS_DLGDESC)),LVCFMT_LEFT,200,0); - wList.InsertColumn(1,CString(MAKEINTRESOURCE(IDS_DLGNAME)),LVCFMT_LEFT,100,1); - wList.InsertColumn(2,CString(MAKEINTRESOURCE(IDS_DLGID)),LVCFMT_CENTER,30,2); - ListView_SetExtendedListViewStyleEx(wList,LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES,LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES); - OnRescan(); - - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -int DlgDialogy::GetDialogID(const char *name) -{ - Pathname dialogPath=_dlgpath; - dialogPath.SetFilename(name); - FILE *f=fopen_icase(dialogPath,"r"); - if (f==0) return -1; - int id; - char dialog[40]; - if (fscanf(f," %40[^\r\n\t (] ( %d )",dialog,&id)==2) - { - if (istrcmp(dialog,"DIALOG")==0) - { - fclose(f); - return id; - } - } - fclose(f); - return -1; -} - -void DlgDialogy::LoadDialogyDlg() -{ - FILE *f=fopen_icase(_dlgpath,"r"); - if (f==0) return; - - int p=0; - - while (!feof(f)) - { - char name[80]; - char desc[256]; - name[0]=0; - desc[0]=0; - fscanf(f,"%80s",name); - fscanf(f," %250[^\r\n]",desc); - kamenik2windows(name,strlen(name),name); - kamenik2windows(desc,strlen(desc),desc); - int row; - - if (name[0]!=0 || desc[0]!=0) - { - row=wList.InsertItem(p,desc,0); - wList.SetItemText(row,1,name); - int dlgId=GetDialogID(name); - wList.SetItemText(row,2,itoa(dlgId,desc,10)); - p++; - } - } - fclose(f); -} - -void DlgDialogy::OnRescan() -{ - wList.DeleteAllItems(); - LoadDialogyDlg(); -} - -void DlgDialogy::OnDelete() -{ - int w; - while ((w=wList.GetNextItem(-1,LVNI_SELECTED))!=-1) - { - wList.DeleteItem(w); - } -} - -void DlgDialogy::OnEdit() -{ - CString name; - int w=-1; - while ((w=wList.GetNextItem(w,LVNI_SELECTED))!=-1) - { - name=wList.GetItemText(w,1); - Pathname editName=_dlgpath; - editName.SetFilename(name); - _mainFrame->OpenEditor(editName); - } -} - -void DlgDialogy::OnOK() -{ - FILE *f=fopen_icase(_dlgpath,"w"); - if (f==0) - { - AfxMessageBox(IDS_UNABLETOSAVEDIALOGYDLG,MB_ICONEXCLAMATION); - return; - } - - for (int i=0,cnt=wList.GetItemCount();iiSubItem; - wList.SortItems(CompareFunc,(DWORD)this); - - *pResult = 0; -} - - -int DlgDialogy::CompareItems(int item1, int item2) -{ - switch (_sortItem) - { - case 0: - { - CString a=wList.GetItemText(item1,0); - CString b=wList.GetItemText(item2,0); - return istrcmp(a,b); - } - case 1: - { - CString a=wList.GetItemText(item1,1); - CString b=wList.GetItemText(item2,1); - return istrcmp(a,b); - } - case 2: - { - char buff[20]; - int a,b; - wList.GetItemText(item1,2,buff,20);a=atoi(buff); - wList.GetItemText(item2,2,buff,20);b=atoi(buff); - return (a>b)-(a_dlgpath; - nw.sourceLst=&wList; - if (nw.DoModal()==IDOK) - { - int p=wList.InsertItem(wList.GetItemCount(),nw.vPopis); - Pathname dlgName=_dlgpath; - dlgName.SetFiletitle(nw.vJmeno); - dlgName.SetExtension(".dlg"); - wList.SetItemText(p,1,dlgName.GetFilename()); - if (_check_file_exists(dlgName)!=0) - { - FILE *f=fopen_icase(dlgName,"w"); - fprintf(f,"DIALOG(%d)\n",nw.vCislo); - fprintf(f,"{\nPICTURE (\"SCREEN\")\nDESC (\"Popis\")\nSTANDARD (1)\n}\n\nSENTENCE (1,0)\n{\n\n}"); - fclose(f); - } - int num=GetDialogID(dlgName.GetFilename()); - char buff[20]; - wList.SetItemText(p,2,itoa(num,buff,10)); - } -} - - -void DlgDialogy::OnNMDblclkDlglist(NMHDR *pNMHDR, LRESULT *pResult) -{ - OnEdit(); - *pResult = 0; -} - -void DlgDialogy::OnLvnEndlabeleditDlglist(NMHDR *pNMHDR, LRESULT *pResult) -{ - NMLVDISPINFO *pDispInfo = reinterpret_cast(pNMHDR); - // TODO: Add your control notification handler code here - *pResult = 1; -} diff --git a/AdvMan/DlgDialogy.h b/AdvMan/DlgDialogy.h deleted file mode 100644 index 10efb2d..0000000 --- a/AdvMan/DlgDialogy.h +++ /dev/null @@ -1,76 +0,0 @@ -#if !defined(AFX_DLGDIALOGY_H__E47269D5_6849_42F5_AF6F_32EEEE32104D__INCLUDED_) -#define AFX_DLGDIALOGY_H__E47269D5_6849_42F5_AF6F_32EEEE32104D__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// DlgDialogy.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// DlgDialogy dialog - -#define MAXDIALOGY 240 - -class CMainFrame; - -class DlgDialogy : public CDialog -{ -// Construction -public: - void LoadDialogyDlg(); - DlgDialogy(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(DlgDialogy) - enum { IDD = IDD_DIALOGY }; - CListCtrl wList; - //}}AFX_DATA - - Pathname _dlgpath; - CMainFrame *_mainFrame; - int _sortItem; - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(DlgDialogy) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(DlgDialogy) - virtual BOOL OnInitDialog(); - afx_msg void OnRescan(); - afx_msg void OnDelete(); - afx_msg void OnEdit(); - virtual void OnOK(); - virtual void OnCancel(); - afx_msg void OnColumnclickDlglist(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnAdd(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - - int GetDialogID(const char *name); - static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) - { - DlgDialogy *self=(DlgDialogy *)lParamSort; - return self->CompareItems(lParam1,lParam2); - } - - int CompareItems(int item1, int item2); - - -public: - afx_msg void OnNMDblclkDlglist(NMHDR *pNMHDR, LRESULT *pResult); - afx_msg void OnLvnEndlabeleditDlglist(NMHDR *pNMHDR, LRESULT *pResult); -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DLGDIALOGY_H__E47269D5_6849_42F5_AF6F_32EEEE32104D__INCLUDED_) diff --git a/AdvMan/DlgNoveDobr.cpp b/AdvMan/DlgNoveDobr.cpp deleted file mode 100644 index 9c30222..0000000 --- a/AdvMan/DlgNoveDobr.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// DlgNoveDobr.cpp : implementation file -// - -#include "stdafx.h" -#include "AdvMan.h" -#include "DlgNoveDobr.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// DlgNoveDobr dialog - - -DlgNoveDobr::DlgNoveDobr(CWnd* pParent /*=NULL*/) - : CDialog(DlgNoveDobr::IDD, pParent) -{ - //{{AFX_DATA_INIT(DlgNoveDobr) - vJmeno = _T(""); - vKouzla = TRUE; - vMapy = FALSE; - vDialogy = TRUE; - vDefinice = FALSE; - vOrganizace = 0; - vStartMap = _T("start.map"); - vMaxPostav = 3; - vMinPostav = 3; - //}}AFX_DATA_INIT -} - - -void DlgNoveDobr::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(DlgNoveDobr) - DDX_Text(pDX, IDC_JMENO, vJmeno); - DDX_Check(pDX, IDC_KOUZLA, vKouzla); - DDX_Check(pDX, IDC_MAPY, vMapy); - DDX_Check(pDX, IDC_DIALOGY, vDialogy); - DDX_Check(pDX, IDC_DEFINICE, vDefinice); - DDX_Radio(pDX, IDC_ORGANIZACE, vOrganizace); - DDX_Text(pDX, IDC_STARTMAP, vStartMap); - DDX_Check(pDX, IDC_ORIGDLGS, vDialogyDlg); - DDV_MaxChars(pDX, vStartMap, 12); - //}}AFX_DATA_MAP - DDX_Text(pDX, IDC_MINPOSTAV, vMinPostav); - DDV_MinMaxUInt(pDX, vMinPostav, 1, 6); - DDX_Text(pDX, IDC_MAXPOSTAV, vMaxPostav); - DDV_MinMaxUInt(pDX, vMaxPostav, vMinPostav, 6); -} - - -BEGIN_MESSAGE_MAP(DlgNoveDobr, CDialog) - //{{AFX_MSG_MAP(DlgNoveDobr) - ON_EN_CHANGE(IDC_JMENO, OnChangeJmeno) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// DlgNoveDobr message handlers - -void DlgNoveDobr::DialogRules() -{ - GetDlgItem(IDOK)->EnableWindow(GetDlgItem(IDC_JMENO)->GetWindowTextLength()); -} - -BOOL DlgNoveDobr::OnInitDialog() -{ - CDialog::OnInitDialog(); - - DialogRules(); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void DlgNoveDobr::OnChangeJmeno() -{ - DialogRules(); -} diff --git a/AdvMan/DlgNoveDobr.h b/AdvMan/DlgNoveDobr.h deleted file mode 100644 index a3db1f4..0000000 --- a/AdvMan/DlgNoveDobr.h +++ /dev/null @@ -1,57 +0,0 @@ -#if !defined(AFX_DLGNOVEDOBR_H__410472E5_5BCF_4CE8_8FE3_10693C0F05F7__INCLUDED_) -#define AFX_DLGNOVEDOBR_H__410472E5_5BCF_4CE8_8FE3_10693C0F05F7__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// DlgNoveDobr.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// DlgNoveDobr dialog - -class DlgNoveDobr : public CDialog -{ -// Construction -public: - void DialogRules(); - DlgNoveDobr(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(DlgNoveDobr) - enum { IDD = IDD_NOVEDOBR }; - CString vJmeno; - BOOL vKouzla; - BOOL vMapy; - BOOL vDialogy; - BOOL vDefinice; - BOOL vDialogyDlg; - int vOrganizace; - CString vStartMap; - UINT vMaxPostav; - UINT vMinPostav; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(DlgNoveDobr) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(DlgNoveDobr) - virtual BOOL OnInitDialog(); - afx_msg void OnChangeJmeno(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DLGNOVEDOBR_H__410472E5_5BCF_4CE8_8FE3_10693C0F05F7__INCLUDED_) diff --git a/AdvMan/DlgNovyDialog.cpp b/AdvMan/DlgNovyDialog.cpp deleted file mode 100644 index a5d119e..0000000 --- a/AdvMan/DlgNovyDialog.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// DlgNovyDialog.cpp : implementation file -// - -#include "stdafx.h" -#include "AdvMan.h" -#include "DlgNovyDialog.h" -#include - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// DlgNovyDialog dialog - - -DlgNovyDialog::DlgNovyDialog(CWnd* pParent /*=NULL*/) - : CDialog(DlgNovyDialog::IDD, pParent) -{ - //{{AFX_DATA_INIT(DlgNovyDialog) - vCislo = 0; - vJmeno = _T(""); - vPopis = _T(""); - //}}AFX_DATA_INIT -} - - -void DlgNovyDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(DlgNovyDialog) - DDX_Control(pDX, IDC_CISLO, wCislo); - DDX_Control(pDX, IDC_JMENO, wJmeno); - DDX_Text(pDX, IDC_CISLO, vCislo); - DDV_MinMaxInt(pDX, vCislo, 1, 254); - DDX_CBString(pDX, IDC_JMENO, vJmeno); - DDV_MaxChars(pDX, vJmeno, 8); - DDX_Text(pDX, IDC_POPIS, vPopis); - DDV_MaxChars(pDX, vPopis, 50); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(DlgNovyDialog, CDialog) - //{{AFX_MSG_MAP(DlgNovyDialog) - ON_CBN_EDITCHANGE(IDC_JMENO, OnEditchangeJmeno) - ON_CBN_SELENDOK(IDC_JMENO, OnSelendokJmeno) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// DlgNovyDialog message handlers - -BOOL DlgNovyDialog::OnInitDialog() -{ - CDialog::OnInitDialog(); - - bool idlist[256]; - memset(idlist,0,sizeof(idlist)); - - dlgSource.SetFilename("*.dlg"); - CFileFind fnd; - BOOL next; - if (fnd.FindFile(dlgSource)) do - { - next=fnd.FindNextFile(); - CString name=fnd.GetFileTitle(); - name.MakeLower(); - wJmeno.AddString(name); - }while (next); - - int i,cnt; - for (i=0,cnt=sourceLst->GetItemCount();iGetItemText(i,1); - dlgSource.SetFilename(name); - name=dlgSource.GetTitle(); - name.MakeLower(); - int p=wJmeno.FindStringExact(-1,name); - if (p!=-1) wJmeno.DeleteString(p); - - name=sourceLst->GetItemText(i,2); - p=atoi(name); - if (p>=0 && p<256) idlist[p]=true; - } - bool x=true; - for (i=1;i<254;i++) if (!idlist[i]) - { - char buff[50]; - sprintf(buff,"%3d",i); - wCislo.AddString(buff); - if (x) - { - wCislo.SetWindowText(buff); - x=false; - } - } - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void DlgNovyDialog::DialogRules() -{ - BOOL ok=wJmeno.GetWindowTextLength() && wCislo.GetWindowTextLength(); - GetDlgItem(IDOK)->EnableWindow(ok); - CString name; - wJmeno.GetWindowText(name); - dlgSource.SetFiletitle(name); - wCislo.EnableWindow(check_file_exists(dlgSource)==-1); -} - -void DlgNovyDialog::OnEditchangeJmeno() -{ - DialogRules(); -} - -void DlgNovyDialog::OnSelendokJmeno() -{ - int p=wJmeno.GetCurSel(); - CString z; - wJmeno.GetLBText(p,z); - wJmeno.SetWindowText(z); - DialogRules(); -} diff --git a/AdvMan/DlgNovyDialog.h b/AdvMan/DlgNovyDialog.h deleted file mode 100644 index 526175a..0000000 --- a/AdvMan/DlgNovyDialog.h +++ /dev/null @@ -1,57 +0,0 @@ -#if !defined(AFX_DLGNOVYDIALOG_H__00136ADF_E2C6_4081_83AB_D5110EE43612__INCLUDED_) -#define AFX_DLGNOVYDIALOG_H__00136ADF_E2C6_4081_83AB_D5110EE43612__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// DlgNovyDialog.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// DlgNovyDialog dialog - -class DlgDialogy; - -class DlgNovyDialog : public CDialog -{ -// Construction -public: - void DialogRules(); - DlgNovyDialog(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(DlgNovyDialog) - enum { IDD = IDD_NOVYDIALOG }; - CComboBox wCislo; - CComboBox wJmeno; - int vCislo; - CString vJmeno; - CString vPopis; - //}}AFX_DATA - - CListCtrl *sourceLst; - Pathname dlgSource; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(DlgNovyDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(DlgNovyDialog) - virtual BOOL OnInitDialog(); - afx_msg void OnEditchangeJmeno(); - afx_msg void OnSelendokJmeno(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DLGNOVYDIALOG_H__00136ADF_E2C6_4081_83AB_D5110EE43612__INCLUDED_) diff --git a/AdvMan/FS_tasker.h b/AdvMan/FS_tasker.h deleted file mode 100644 index e69de29..0000000 diff --git a/AdvMan/MainFrm.cpp b/AdvMan/MainFrm.cpp deleted file mode 100644 index b0743b6..0000000 --- a/AdvMan/MainFrm.cpp +++ /dev/null @@ -1,677 +0,0 @@ -// MainFrm.cpp : implementation of the CMainFrame class -// - -#include "stdafx.h" -#include "AdvMan.h" -#include "..\cztable.h" - -#include "MainFrm.h" -#include "DlgDialogy.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd) - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) - //{{AFX_MSG_MAP(CMainFrame) - ON_WM_CREATE() - ON_WM_SETFOCUS() - ON_WM_INITMENUPOPUP() - ON_COMMAND(ID_FILE_NOVDOBRODRUST, OnFileNovdobrodrust) - ON_COMMAND(ID_FILE_NATIDOBRODRUSTV, OnFileNatidobrodrustv) - ON_COMMAND(ID_EDITORY_KOUZLATAB, OnEditoryKouzlatab) - ON_COMMAND(ID_EDITORY_POSTAVYTAB, OnEditoryPostavytab) - ON_COMMAND(ID_EDITORY_ITEMSSCR, OnEditoryItemsscr) - ON_COMMAND(ID_EDITORY_ITEMSPIC, OnEditoryItemspic) - ON_COMMAND(ID_EDITORY_WEAPONSSCR, OnEditoryWeaponsscr) - ON_WM_DESTROY() - ON_COMMAND(ID_PEKLADAE_PELOKOUZLA, OnPekladaePelokouzla) - ON_COMMAND(ID_PEKLADAE_PELODIALOGY, OnPekladaePelodialogy) - ON_COMMAND(ID_PEKLADAE_PELOPOSTAVYTAB, OnPekladaePelopostavytab) - ON_COMMAND(ID_NSTROJE_MAPEDIT, OnNstrojeMapedit) - ON_COMMAND(ID_NSTROJE_TESTUJDOBRODRUSTV, OnNstrojeTestujdobrodrustv) - ON_COMMAND(ID_NSTROJE_TVRCEPODLAH, OnNstrojeTvrcepodlah) - ON_COMMAND(ID_NSTROJE_TVRCEPALETPRONESTVRY, OnNstrojeTvrcepaletpronestvry) - ON_COMMAND(ID_NSTROJE_TVRCEIKONPROPEDMTY, OnNstrojeTvrceikonpropedmty) - ON_COMMAND(ID_EDITORY_SOUBORADV, OnEditorySouboradv) - ON_COMMAND(ID_FILE_ZNOVUNAST, OnFileZnovunast) - ON_UPDATE_COMMAND_UI(ID_FILE_ZNOVUNAST, OnUpdateFileZnovunast) - ON_COMMAND(ID_EDITORY_DIALOGY, OnEditoryDialogy) - ON_COMMAND_EX(ID_VIEW_EDITORY,OnBarCheck) - ON_COMMAND_EX(ID_VIEW_PREKLADACE,OnBarCheck) - ON_UPDATE_COMMAND_UI(ID_VIEW_EDITORY,OnUpdateControlBarMenu) - ON_UPDATE_COMMAND_UI(ID_VIEW_PREKLADACE,OnUpdateControlBarMenu) - ON_UPDATE_COMMAND_UI_RANGE(ID_EDITORY_KOUZLATAB,ID_EDITORY_WEAPONSSCR,OnUpdateEditory) - ON_UPDATE_COMMAND_UI_RANGE(ID_PEKLADAE_PELOKOUZLA,ID_PEKLADAE_PELOPOSTAVYTAB,OnUpdateEditory) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - // TODO: add member initialization code here - -} - -CMainFrame::~CMainFrame() -{ - -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - // create a view to occupy the client area of the frame - if (!m_wndView.Create(ES_READONLY|WS_VISIBLE|WS_CHILD|ES_MULTILINE|ES_AUTOVSCROLL|ES_AUTOHSCROLL|WS_VSCROLL|WS_HSCROLL,CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST)) - { - TRACE0("Failed to create view window\n"); - return -1; - } - - if (!m_wndToolBar.CreateEx(this, TBSTYLE_BUTTON, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_TOOLTIPS | CBRS_FLYBY |BTNS_AUTOSIZE | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - - if (!m_wndEditoryBar.CreateEx(this, TBSTYLE_BUTTON, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_TOOLTIPS | CBRS_FLYBY |BTNS_AUTOSIZE | CBRS_SIZE_DYNAMIC,CRect(0,0,0,0),ID_VIEW_EDITORY) || - !m_wndEditoryBar.LoadToolBar(IDR_TOOLEDITORY)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - - if (!m_wndPrekladaceBar.CreateEx(this, TBSTYLE_BUTTON, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_TOOLTIPS | CBRS_FLYBY |BTNS_AUTOSIZE | CBRS_SIZE_DYNAMIC,CRect(0,0,0,0),ID_VIEW_PREKLADACE) || - !m_wndPrekladaceBar.LoadToolBar(IDR_PREKLADACE)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - // TODO: Delete these three lines if you don't want the toolbar to - // be dockable - ShowWindow(SW_SHOW); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndEditoryBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndPrekladaceBar.EnableDocking(CBRS_ALIGN_ANY); - EnableDocking(CBRS_ALIGN_ANY); - DockControlBar(&m_wndToolBar); - DockControlBar(&m_wndEditoryBar); - DockControlBar(&m_wndPrekladaceBar); - UpdateWindow(); - CRect rc; - GetClientRect(&rc); - ClientToScreen(&rc); - DockControlBar(&m_wndEditoryBar,(UINT)0,CRect(rc.left+180,rc.top+5,rc.left+180,rc.top+5)); - DockControlBar(&m_wndPrekladaceBar,(UINT)0,CRect(rc.left+350,rc.top+5,rc.left+350,rc.top+5)); - - _adv=0; - CString untitled; - untitled.LoadString(IDS_UNTITLED); - SetTitle(untitled); - - SetClassLong(*this,GCL_HICON,(LONG)(theApp.LoadIcon(IDR_MAINFRAME))); - - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CFrameWnd::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - cs.dwExStyle &= ~WS_EX_CLIENTEDGE; - cs.lpszClass = AfxRegisterWndClass(0); - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers -void CMainFrame::OnSetFocus(CWnd* pOldWnd) -{ - // forward focus to the view window - m_wndView.SetFocus(); -} - -BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) -{ - // let the view have first crack at the command - if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) - return TRUE; - - // otherwise, do default handling - return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); -} - - -void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu) -{ - if (_adv==0) - { - for (int i=0,cnt=pPopupMenu->GetMenuItemCount();iGetMenuItemID(i); - if (id!=ID_FILE_NOVDOBRODRUST && id!=ID_FILE_NATIDOBRODRUSTV && id!=ID_APP_EXIT && - id!=ID_VIEW_TOOLBAR && id!=ID_VIEW_STATUS_BAR && id!=ID_APP_ABOUT && id!=ID_VIEW_EDITORY) - pPopupMenu->EnableMenuItem(i,MF_GRAYED|MF_BYPOSITION); - } - } - else - CFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu); -} - -#include "DlgNoveDobr.h" - -static str_add_wildcard(TSTR_LIST *lst, const char *mask) -{ - CFileFind fnd; - BOOL nxt=fnd.FindFile(mask); - if (nxt==FALSE) - { - CString msg; - AfxFormatString1(msg,IDS_NEMOHUNAJITNICOD,mask); - AfxMessageBox(msg,MB_ICONEXCLAMATION); - } - while (nxt) - { - nxt=fnd.FindNextFile(); - str_add(lst,fnd.GetFilePath()); - } -} - -void CMainFrame::OnFileNovdobrodrust() -{ - DlgNoveDobr dlg; - int id=dlg.DoModal(); - if (id==IDOK) - { - release_list(_adv); - _adv=create_list(10); - CString baseMap=_T("adv\\")+dlg.vJmeno+_T("\\"); - add_field_txt(&_adv,_T("CESTA_MAPY"),baseMap); - CString cestaGrafika; - CString cestaDialogy; - CString cestaEnemy; - CString cestaItemy; - CString cestaPozice; - CString cestaZvuky; - CString cestaBasicGr; - switch (dlg.vOrganizace) - { - case 0: - cestaGrafika=baseMap+_T("GRFSTENY" PATH_SEPARATOR); - cestaDialogy=baseMap+_T("GRFDIALG" PATH_SEPARATOR); - cestaEnemy=baseMap+_T("GRFENEMY" PATH_SEPARATOR); - cestaItemy=baseMap+_T("GRFITEMS" PATH_SEPARATOR); - cestaPozice=baseMap+_T("SAVEGAME" PATH_SEPARATOR); - cestaZvuky=baseMap+_T("SOUNDS" PATH_SEPARATOR); - cestaBasicGr=baseMap+_T("GRFBASIC" PATH_SEPARATOR); - break; - case 1: - cestaGrafika=baseMap+_T("graphics" PATH_SEPARATOR); - cestaDialogy=baseMap+_T("graphics" PATH_SEPARATOR "dialogs" PATH_SEPARATOR); - cestaEnemy=baseMap+_T("graphics" PATH_SEPARATOR "enemies" PATH_SEPARATOR); - cestaItemy=baseMap+_T("graphics" PATH_SEPARATOR "items"); - cestaPozice=baseMap+_T("SAVEGAME" PATH_SEPARATOR ); - cestaZvuky=baseMap+_T("SAMPLES" PATH_SEPARATOR); - cestaBasicGr=baseMap+_T("graphics" PATH_SEPARATOR "basic" PATH_SEPARATOR); - break; - case 2: - cestaGrafika=baseMap; - cestaDialogy=baseMap; - cestaEnemy=baseMap; - cestaItemy=baseMap; - cestaPozice=baseMap+_T("SAVEGAME" PATH_SEPARATOR); - cestaZvuky=baseMap; - cestaBasicGr=baseMap; - break; - } - - add_field_txt(&_adv,_T("CESTA_GRAFIKA"),cestaGrafika); - add_field_txt(&_adv,_T("CESTA_DIALOGY"),cestaDialogy); - add_field_txt(&_adv,_T("CESTA_ENEMY"),cestaEnemy); - add_field_txt(&_adv,_T("CESTA_ITEMY"),cestaItemy); - add_field_txt(&_adv,_T("CESTA_POZICE"),cestaPozice); - add_field_txt(&_adv,_T("CESTA_ZVUKY"),cestaZvuky); - add_field_txt(&_adv,_T("CESTA_BGRAFIKA"),cestaBasicGr); - - add_field_txt(&_adv,_T("DEFAULT_MAP"),dlg.vStartMap); - add_field_num(&_adv,_T("CHAR_MIN"),dlg.vMinPostav); - add_field_num(&_adv,_T("CHAR_MAX"),dlg.vMaxPostav); - add_field_num(&_adv,_T("PATCH"),1); - - Pathname pth=Pathname::GetExePath(); - pth.SetFiletitle(dlg.vJmeno); - pth.SetExtension(_T(".adv")); - - save_config(_adv,pth); - - _advName=pth; - _advPath=pth.GetDirectoryWithDrive(); - - SetTitle(pth); - - - Pathname exePath=Pathname::GetExePath(); - - pth.CreateFolder(exePath.GetDirectoryWithDrive()+baseMap); - pth.CreateFolder(exePath.GetDirectoryWithDrive()+cestaGrafika); - pth.CreateFolder(exePath.GetDirectoryWithDrive()+cestaDialogy); - pth.CreateFolder(exePath.GetDirectoryWithDrive()+cestaItemy); - pth.CreateFolder(exePath.GetDirectoryWithDrive()+cestaEnemy); - pth.CreateFolder(exePath.GetDirectoryWithDrive()+cestaPozice); - pth.CreateFolder(exePath.GetDirectoryWithDrive()+cestaZvuky); - pth.CreateFolder(exePath.GetDirectoryWithDrive()+cestaBasicGr); - - CString basePath=pth.GetDirectoryWithDrive(); - - TSTR_LIST fileList=create_list(10); - str_add_wildcard(&fileList,basePath+_T("maps\\*.dat")); - if (!dlg.vDefinice) str_add_wildcard(&fileList,basePath+_T("AdvManData\\weapons.scr")); - if (!dlg.vDefinice) str_add_wildcard(&fileList,basePath+_T("AdvManData\\items.scr")); - str_add_wildcard(&fileList,basePath+_T("AdvManData\\items.pic")); - str_add_wildcard(&fileList,basePath+_T("AdvManData\\*.lst")); - str_add_wildcard(&fileList,basePath+_T("AdvManData\\postavy.def")); - str_add_wildcard(&fileList,basePath+_T("AdvManData\\postavy.tab")); - str_add_wildcard(&fileList,basePath+_T("AdvManData\\predmety.tab")); - if (dlg.vKouzla) - { - str_add_wildcard(&fileList,basePath+_T("AdvManData\\kouzla.def")); - str_add_wildcard(&fileList,basePath+_T("AdvManData\\kouzla.tab")); - } - if (dlg.vDialogy) - { - str_add_wildcard(&fileList,basePath+_T("AdvManData\\dialogy.def")); - str_add_wildcard(&fileList,basePath+_T("AdvManData\\dlgsecrt.def")); - } - if (dlg.vDefinice) - { - str_add_wildcard(&fileList,basePath+_T("AdvManData\\*.scr")); - str_add_wildcard(&fileList,basePath+_T("AdvManData\\*.txt")); - } - if (dlg.vMapy) - { - str_add_wildcard(&fileList,basePath+_T("maps\\*.map")); - } - if (dlg.vDialogyDlg) - { - str_add_wildcard(&fileList,basePath+_T("AdvManData\\*.dlg")); - } - int totalszneed=0; - int i,cnt; - for (i=0,cnt=str_count(fileList);imessage,pMsg->wParam,pMsg->lParam); - pMsg->time=res; - return res==0; -} - - -LRESULT CMainFrame::BroadcastMessage(UINT msg, WPARAM wParam, LPARAM lParam) -{ - MSG Msg; - Msg.message=msg; - Msg.wParam=wParam; - Msg.lParam=lParam; - Msg.time=0; - EnumThreadWindows(GetCurrentThreadId(),BroadcastMsgCallback,(LPARAM)&Msg); - return Msg.time; -} - -void CMainFrame::SaveAll() -{ - BroadcastMessage(MSG_FORCESAVE,0,0); -} - -void CMainFrame::OpenEditor(const char *name) -{ - if (BroadcastMessage(MSG_FINDANDPOPUP,0,(LPARAM)name)==0) - { - EditSkeldalFile(name); - } -} - -void CMainFrame::OnDestroy() -{ - SaveBarState("MainFrame"); - CFrameWnd::OnDestroy(); - - BroadcastMessage(MSG_CLOSEEDITOR,0,0); - release_list(_adv); - _adv=0; - - -} - -void CMainFrame::StartApp(const char *appname, CString cmdline, bool wait, const char *folder) -{ - SaveAll(); - STARTUPINFO nfo; - memset(&nfo,0,sizeof(nfo)); - nfo.cb=sizeof(nfo); - HANDLE pipe; - if (wait) - { - HANDLE output; - CreatePipe(&pipe,&output,0,0); - DuplicateHandle(GetCurrentProcess(),output,GetCurrentProcess(),&output,0,TRUE,DUPLICATE_SAME_ACCESS|DUPLICATE_CLOSE_SOURCE); - nfo.hStdOutput=output; - nfo.hStdError=output; - nfo.dwFlags|=STARTF_USESTDHANDLES; - m_wndView.SetWindowText(""); - } - Pathname app=appname; - cmdline=_T("\"")+CString(appname)+_T("\" ")+cmdline; - CString startdir; - PROCESS_INFORMATION pi; - if (folder==0) - startdir=app.GetDirectoryWithDrive(); - else - startdir=folder; - if (startdir[startdir.GetLength()-1]=='\\') startdir.Delete(startdir.GetLength()-1); - BOOL res=CreateProcess(appname,cmdline.LockBuffer(),0,0,TRUE,NORMAL_PRIORITY_CLASS|DETACHED_PROCESS,0,startdir,&nfo,&pi); - cmdline.UnlockBuffer(); - if (res==FALSE) - { - CString ss; - AfxFormatString1(ss,IDS_CANNOTEXECUTE,cmdline); - AfxMessageBox(ss,MB_ICONSTOP); - } - else - { - CloseHandle(pi.hThread); - if (wait) - { - int rep=10; - bool end; - do - { - DWORD datalen; - PeekNamedPipe(pipe,0,0,0,&datalen,0); - while (datalen) - { - DWORD readed=0; - char buff[256]; - if (ReadFile(pipe,&buff,255,&readed,0)==FALSE) break; - if (readed==0) break; - int cnt=m_wndView.GetWindowTextLength(); - if (cnt>20000) - { - m_wndView.SetSel(0,10000); - m_wndView.ReplaceSel(""); - cnt=m_wndView.GetWindowTextLength(); - } - buff[readed]=0; - kamenik2windows(buff,readed,buff); - m_wndView.SetSel(cnt,cnt); - m_wndView.ReplaceSel(buff); - PeekNamedPipe(pipe,0,0,0,&datalen,0); - rep=10; - } - UpdateWindow(); - end=WaitForSingleObject(pi.hProcess,200)==WAIT_TIMEOUT; - rep--; - } - while (rep>0 || end); - } - CloseHandle(pi.hProcess); - } - if (wait) - { - CloseHandle(pipe); - CloseHandle(nfo.hStdOutput); - } - SetForegroundWindow(); -} - -void CMainFrame::OnPekladaePelokouzla() -{ - CString cmdline=_T("\"")+_baseMapPath+_T("KOUZLA.TAB")+_T("\""); - Pathname apppath=Pathname::GetExePath(); - CString appname=apppath.GetDirectoryWithDrive()+CString(_T("AdvManData\\CSPELLS.EXE")); - StartApp(appname,cmdline,true,_baseMapPath); -} - -void CMainFrame::OnPekladaePelodialogy() -{ - CString cmdline=_T("\"")+_baseMapPath+_T("DIALOGY.DLG")+_T("\""); - Pathname apppath=Pathname::GetExePath(); - CString appname=apppath.GetDirectoryWithDrive()+CString(_T("AdvManData\\CDIALOGY.EXE")); - StartApp(appname,cmdline,true,_baseMapPath); - -} - -void CMainFrame::OnPekladaePelopostavytab() -{ - CString cmdline=_T("\"")+_baseMapPath+_T("POSTAVY.TAB\" \"")+_baseMapPath+_T("POSTAVY.DAT")+_T("\""); - Pathname apppath=Pathname::GetExePath(); - CString appname=apppath.GetDirectoryWithDrive()+CString(_T("AdvManData\\Lex_Lib.exe")); - StartApp(appname,cmdline,true,_baseMapPath); - -} - -void CMainFrame::OnNstrojeMapedit() -{ - Pathname apppath=Pathname::GetExePath(); - apppath.SetFilename(_T("MapEdit.exe")); - StartApp(apppath,CString(_T("\""))+_advName+_T("\""),false); -} - -void CMainFrame::OnNstrojeTestujdobrodrustv() -{ - Pathname apppath=Pathname::GetExePath(); - apppath.SetFilename(_T("Skeldal.exe")); - StartApp(apppath,CString(_T("\""))+_advName+_T("\""),false); -} - -void CMainFrame::OnNstrojeTvrcepodlah() -{ - Pathname apppath=Pathname::GetExePath(); - apppath.SetFilename(_T("AdvManData\\Podlahar.exe")); - StartApp(apppath,"",false,_advPath+get_text_field(_adv,"CESTA_GRAFIKA")); - -} - -void CMainFrame::OnNstrojeTvrcepaletpronestvry() -{ - Pathname apppath=Pathname::GetExePath(); - apppath.SetFilename(_T("AdvManData\\ColEdit.exe")); - StartApp(apppath,"",false,_advPath+get_text_field(_adv,"CESTA_ENEMY")); -} - - -void CMainFrame::OnNstrojeTvrceikonpropedmty() -{ - Pathname apppath=Pathname::GetExePath(); - apppath.SetFilename(_T("AdvManData\\ItemIcons.exe")); - StartApp(apppath,"",false,_advPath+get_text_field(_adv,"CESTA_ITEMY")); -} - -void CMainFrame::OnEditorySouboradv() -{ - AfxMessageBox(IDS_EDITADVWARN,MB_ICONEXCLAMATION); - OpenEditor(_advName); -} - -void CMainFrame::OnFileZnovunast() -{ - release_list(_adv); - _adv=read_config(_advName); - _baseMapPath=_advPath+get_text_field(_adv,"CESTA_MAPY"); -} - -void CMainFrame::OnUpdateFileZnovunast(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(_adv!=0); -} - -void CMainFrame::OnEditoryDialogy() -{ - DlgDialogy dlg; - dlg._dlgpath.SetDirectory(_baseMapPath); - dlg._dlgpath.SetFilename(_T("Dialogy.dlg")); - dlg.DoModal(); -} - -void CMainFrame::OnUpdateEditory(CCmdUI *pCmdUI) -{ - pCmdUI->Enable(_adv!=0); -} diff --git a/AdvMan/MainFrm.h b/AdvMan/MainFrm.h deleted file mode 100644 index 5a31502..0000000 --- a/AdvMan/MainFrm.h +++ /dev/null @@ -1,95 +0,0 @@ -// MainFrm.h : interface of the CMainFrame class -// -///////////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_MAINFRM_H__0420AD88_2B58_4379_BD0D_069A821C039D__INCLUDED_) -#define AFX_MAINFRM_H__0420AD88_2B58_4379_BD0D_069A821C039D__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "ChildView.h" - - -class CMainFrame : public CFrameWnd -{ - -public: - CMainFrame(); -protected: - DECLARE_DYNAMIC(CMainFrame) - -// Attributes -public: - TSTR_LIST _adv; - CString _baseMapPath; - CString _advPath; - CString _advName; -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CMainFrame) - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo); - //}}AFX_VIRTUAL - -// Implementation -public: - void StartApp(const char *appname, CString cmdline, bool wait, const char *folder=0); - void OpenEditor(const char *name); - void SaveAll(); - static LRESULT BroadcastMessage(UINT msg, WPARAM wParam, LPARAM lParam); - void SetTitle(const _TCHAR *name); - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CStatusBar m_wndStatusBar; - CToolBar m_wndToolBar; - CToolBar m_wndEditoryBar; - CToolBar m_wndPrekladaceBar; - CEdit m_wndView; - -// Generated message map functions -protected: - //{{AFX_MSG(CMainFrame) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSetFocus(CWnd *pOldWnd); - afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu); - afx_msg void OnFileNovdobrodrust(); - afx_msg void OnFileNatidobrodrustv(); - afx_msg void OnEditoryKouzlatab(); - afx_msg void OnEditoryPostavytab(); - afx_msg void OnEditoryItemsscr(); - afx_msg void OnEditoryItemspic(); - afx_msg void OnEditoryWeaponsscr(); - afx_msg void OnDestroy(); - afx_msg void OnPekladaePelokouzla(); - afx_msg void OnPekladaePelodialogy(); - afx_msg void OnPekladaePelopostavytab(); - afx_msg void OnNstrojeMapedit(); - afx_msg void OnNstrojeTestujdobrodrustv(); - afx_msg void OnNstrojeTvrcepodlah(); - afx_msg void OnNstrojeTvrcepaletpronestvry(); - afx_msg void OnNstrojeTvrceikonpropedmty(); - afx_msg void OnEditorySouboradv(); - afx_msg void OnFileZnovunast(); - afx_msg void OnUpdateFileZnovunast(CCmdUI* pCmdUI); - afx_msg void OnEditoryDialogy(); - afx_msg void OnUpdateEditory(CCmdUI *pCmdUI); -//}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_MAINFRM_H__0420AD88_2B58_4379_BD0D_069A821C039D__INCLUDED_) diff --git a/AdvMan/Pathname.cpp b/AdvMan/Pathname.cpp deleted file mode 100644 index 681b90c..0000000 --- a/AdvMan/Pathname.cpp +++ /dev/null @@ -1,621 +0,0 @@ -// Pathname.cpp: implementation of the Pathname class. -// -////////////////////////////////////////////////////////////////////// - -#include "Pathname.h" -#include -#include -#include -#include -#include - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -#pragma comment(lib,"User32") -#pragma comment(lib,"shell32") - -Pathname::Pathname(const char *name) -{ - _fullpath=NULL; - _path=_filetitle=_extension=_end=""; - - if (name==NULL) SetPathName("*.*"); - else SetPathName(name); -} - -Pathname::Pathname(PathNameNullEnum null) -{ - _fullpath=NULL; - _path=_filetitle=_extension=_end=""; -} - - -Pathname::Pathname(const char *relpath, const Pathname &abspath) -{ - _path=_filetitle=_extension=_end=""; - _fullpath=NULL; - - char *part; - char *pth=strcpy((char *)alloca(sizeof(*relpath)+strlen(relpath)+1),relpath); - part=strrchr(pth,'\\'); - if (part) part++;else part=NULL; - if (part) - { - SetFilename(part); - *part=0; - SetDirectory(pth); - } - else - SetFilename(pth); - if (RelativeToFull(abspath)==false) SetNull(); -} - - -Pathname::~Pathname() -{ - delete [] _fullpath; -} - -const char *Pathname::GetNameFromPath(const char *path) -{ - char *c=strrchr(path,'\\'); - if (c!=NULL) c++;else return path; - return c; -} - -const char *Pathname::GetExtensionFromPath(const char *path) -{ - const char *fname=GetNameFromPath(path); - char *c=strrchr(fname,'.'); - if (c==NULL) c=strrchr(path,0); - return c; -} - -void Pathname::RebuildData(const char *path, const char *filetitle, const char *extension, int pathlen, int titlelen, int extlen) -{ - int totalsize=(pathlen+titlelen+extlen)*2+10; - char *olddata=_fullpath; - _fullpath=new char[totalsize]; - _path=_fullpath+pathlen+titlelen+extlen+1; - memcpy(_path,path,pathlen+1); - _filetitle=_path+pathlen+1; - memcpy(_filetitle,filetitle,titlelen+1); - _extension=_filetitle+titlelen+1; - memcpy(_extension,extension,extlen+1); - _end=_extension+extlen+1; - RebuildPath(); - delete [] olddata; -} - -void Pathname::RebuildPath() -{ - sprintf(_fullpath,"%s%s%s",_path,_filetitle,_extension); -} - -void Pathname::SetDrive(const char dr) -{ - if (HasDrive()) - { - if (dr==0) - { - strcpy(_path,_path+2); - strcpy(_fullpath,_fullpath+2); - } - else - { - _path[0]=dr; - _fullpath[0]=dr; - } - } - else if (dr!=0) - { - int np=IsNetworkPath(); - if (np) - { - _path[0]=dr; - _path[1]=':'; - strcpy(_path+2,_path+np); - RebuildPath(); - } - else - { - char *c=(char *)alloca((strlen(_path)+4)*sizeof(*c)); - sprintf(c,"%c:%s",dr,_path); - SetDirectory(c); - } - } -} - -void Pathname::SetDirectory(const char *dir) -{ - bool copydrv; //directory doesn't contain drive, need copy from original - bool addslash; //directory doesn't ending by backslash, need add it - - int len=strlen(dir); - copydrv=HasDrive() && !HasDrive(dir); //copy original drive, if exists and directory doesn't contaion drive - if (strncmp(dir,"\\\\",2)==0) copydrv=false; //network path, don't copy drive - addslash=len && dir[len-1]!='\\'; //add slash - if (addslash || copydrv) - { - char *c=(char *)alloca((len+4)*sizeof(dir[0])); //allocate some space for string - if (addslash && copydrv) - sprintf(c,"%c%c%s\\",_path[0],_path[1],dir); //add drive and add slash - else if (addslash) - sprintf(c,"%s\\",dir); //add slash only - else - sprintf(c,"%c%c%s",_path[0],_path[1],dir); //add drive only - dir=c; //this is new path for now - len=strlen(dir); - } - if (len<_filetitle-_path) //there is space for store path - {strcpy(_path,dir); RebuildPath();} //store it and rebuild result - else - RebuildData(dir,_filetitle,_extension,len,strlen(_filetitle),strlen(_extension)); - //rebuild internal data complettly -} - -void Pathname::SetFilename(const char *filename) -{ - char *dot=strrchr(filename,'.'); - if (dot==NULL) - { - SetFiletitle(filename); - SetExtension(""); - return; - } - int tllen=dot-filename; - int exlen=strlen(dot); - char *c=(char *)alloca((tllen+1)*sizeof(*c)); - memcpy(c,filename,tllen); - c[tllen]=0; - if (exlen+tllen+1<_end-_filetitle) - { - memcpy(_filetitle,c,tllen+1); - _extension=_filetitle+tllen+1; - memcpy(_extension,dot,exlen+1); - RebuildPath(); - } - else - RebuildData(_path,c,dot,strlen(_path),tllen,exlen); -} - -void Pathname::SetExtension(const char *ext) -{ - int len=strlen(ext); - if (ext[0] && ext[0]!='.') - { - char *s=(char *)alloca((len+2)*sizeof(*s)); - sprintf(s,".%s",ext); - ext=s; - len++; - } - if (len<_end-_extension) - { - memcpy(_extension,ext,len+1); - RebuildPath(); - } - else - { - RebuildData(_path,_filetitle,ext,strlen(_path),strlen(_filetitle),len); - } -} - -void Pathname::SetFiletitle(const char *title) -{ - int len=strlen(title); - if (len<_extension-_filetitle) - { - memcpy(_filetitle,title,len+1); - RebuildPath(); - } - else - { - RebuildData(_path,title,_extension,strlen(_path),len,strlen(_extension)); - } -} - -void Pathname::SetPathName(const char *pathname) -{ - if (pathname==NULL || pathname[0]==0) - { - SetNull(); - return; - } - char *part; - DWORD needsz=GetFullPathName(pathname,0,NULL,&part); - char *fpth=(char *)alloca(needsz*sizeof(*fpth)); - GetFullPathName(pathname,needsz,fpth,&part); - part=strrchr(fpth,'\\'); - if (part) part++;else part=NULL; - if (part) - { - SetFilename(part); - *part=0; - } - else - SetFilename(""); - SetDirectory(fpth); -} - -Pathname& Pathname::operator=(const Pathname& other) -{ - if (other.IsNull()) SetNull(); - else RebuildData(other._path,other._filetitle,other._extension,strlen(other._path),strlen(other._filetitle),strlen(other._extension)); - return *this; -} - -Pathname::Pathname(const Pathname &other) -{ - _fullpath=NULL; - if (other.IsNull()) SetNull(); - else RebuildData(other._path,other._filetitle,other._extension,strlen(other._path),strlen(other._filetitle),strlen(other._extension)); -} - -bool Pathname::FullToRelative(const Pathname &relativeto) -{ - if (relativeto.IsNull() || IsNull()) return false; - bool h1=HasDrive(); - bool h2=relativeto.HasDrive(); - if (h1!=h2) return false; //rozdilny zpusob adresace - nelze vytvorit relatvni cestu - if (h1==true && h2==true && toupper(GetDrive())!=toupper(relativeto.GetDrive())) - return false; //ruzne disky, nelze vytvorit relativni cestu - if (strncmp(_path,"\\\\",2)==0) //sitova cesta - { - int slsh=0; //citac lomitek - const char *a=_path; - const char *b=relativeto._path; - while (toupper(*a)==toupper(*b) && *a && slsh<3) //zacatek sitove cesty musi byt stejny - { - if (*a=='\\') slsh++; - a++;b++; - } - if (slsh!=3) return false; //pokud neni stejny, nelze vytvorit relativni cestu - } - int sublevel=0; - const char *ps1=_path; - const char *ps2=relativeto._path; - if (h1) - {ps1+=2;ps2+=2;} - const char *sls=ps2; - while (toupper(*ps1)==toupper(*ps2) && *ps1) - { - if (*ps2=='\\') sls=ps2+1; - ps1++;ps2++; - } - ps1-=ps2-sls; - if (sls) - { - while (sls=strchr(sls,'\\')) - { - sls++; - sublevel++; - } - } - char *buff=(char *)alloca((sublevel*3+strlen(ps1)+1)*sizeof(*buff)); - char *pos=buff; - for (int i=0;iref._path) - { - end--; - while (end>ref._path && end[-1]!='\\') end--; - } - beg+=3; - } - else - beg+=2; - } - int partln=end-ref._path; - char *buff=(char *)alloca((partln+strlen(beg)+1)*sizeof(*buff)); - memcpy(buff,ref._path,partln); - strcpy(buff+partln,beg); - SetDrive(0); - SetDirectory(buff); - return true; -} - -int Pathname::IsNetworkPath() const -{ - if (strncmp(_path,"\\\\",2)==0) //sitova cesta - { - const char *p=_path+2; - char *c=strchr(p,'\\'); - if (c) return c-_path; - } - return 0; -} - -void Pathname::SetServerName(const char *server) -{ - if (HasDrive()) SetDrive(0); - else - { - int np=IsNetworkPath(); - if (np) strcpy(_path,_path+np); //str - } - char *buff=(char *)alloca((strlen(server)+strlen(_path)+5)*sizeof(*buff)); - if (_path[0]!='\\') - sprintf(buff,"\\\\%s\\%s",server,_path); - else - sprintf(buff,"\\\\%s%s",server,_path); - SetDirectory(buff); -} - -void Pathname::SetNull() -{ - delete [] _fullpath; - _fullpath=NULL; - _path=_filetitle=_extension=_end=""; -} - -bool Pathname::GetPartFromPath(const char *path, int partnum, char *buff, int bufsize, int mode) -{ - const char *scan=path; - while (*scan=='\\') scan++; - while (partnum && *scan) - { - while (*scan!='\\' && *scan) scan++; - while (*scan=='\\') scan++; - partnum--; - } - if (*scan==0) - { - buff[0]=0; - return false; - } - int pt=0; - if (mode==-1) - { - pt=scan-path; - if (pt>bufsize) - { - buff[0]=0; - return true; - } - else - memcpy(buff,path,pt); - } - bool nlast=false; - while (*scan && (mode==1 || !nlast) && ptsize) return false; - if (psize==0) {buff[0]=0;return true;} - strncpy(buff,GetDirectoryWithDrive(),psize-1); - buff[psize-1]=0; - return true; -} - -bool Pathname::IsPathValid() const -{ - if (IsNull()) return false; - char *invalidChars="/*?\"<>|"; - const char *path=GetFullPath(); - if (*path==0) return false; - while (*path) - { - if (strchr(invalidChars,*path)!=NULL) return false; - path++; - } - return true; -} - - - -bool Pathname::SetTempDirectory() -{ - char buff[1]; - DWORD size=GetTempPath(1,buff); - if (size==0) return false; - size++; - char *p=(char *)alloca(size); - if (GetTempPath(size,p)==0) return false; - SetDirectory(p); - return true; -} - -bool Pathname::SetDirectorySpecial(int nSpecCode) -{ - char buff[MAX_PATH]; - if (SHGetSpecialFolderPath(GetForegroundWindow(),buff,nSpecCode,FALSE)!=NOERROR) return false; - SetDirectory(buff); - return true; -} - -bool Pathname::SetTempFile(const char *prefix, unsigned int unique) -{ - char tempname[MAX_PATH]; - if (GetTempFileName(GetDirectoryWithDrive(),prefix,unique,tempname)==0) return false; - this->SetPathName(tempname); - return true; -} - -Pathname Pathname::GetExePath() -{ - char buff[MAX_PATH*4]; - GetModuleFileName(NULL,buff,sizeof(buff)); - return Pathname(buff); -} - -const char *Pathname::FullToRelativeProjectRoot(const char *full, const char *projectRoot) -{ - const char *a=full,*b=projectRoot; - while (*a && tolower(*a)==tolower(*b)) {a++;b++;}; - if (*b) return full; - return a; -} - -bool Pathname::CreateFolder(void *security_descriptor) -{ - int begpart=-1; - int len=strlen(_fullpath)+1; - char *buff=(char *)alloca(len); - for (int i=1;GetPart(i,buff,len,-1);i++) - { - if (begpart==-1 && _check_file_exists(buff)!=0) begpart=i; - if (begpart!=-1) - { - if (begpart==-1) begpart=i; - BOOL res=CreateDirectory(buff,(LPSECURITY_ATTRIBUTES)security_descriptor); - if (res==FALSE) - { - for (int j=i;i>=begpart;i--) - { - GetPart(i,buff,len,-1); - RemoveDirectory(buff); - } - return false; - } - } - } - return true; -} - -bool Pathname::CreateFolder(const char *path, void *security_descriptor) -{ - Pathname pth; - pth.SetDirectory(path); - return pth.CreateFolder(security_descriptor); -} - -static bool RemoveDirectoryFull(const Pathname &p, int part, char *buff, int bufsize) -{ - if (p.GetPart(part+1,buff,bufsize,-1)) - if (RemoveDirectoryFull(p,part+1,buff,bufsize)==false) return false; - p.GetPart(part,buff,bufsize, -1); - return RemoveDirectory(buff)!=FALSE; -} - -static bool RemoveDirRecursive(const char *dir, const char *mask) -{ - if (dir==0 || dir[0]==0) return false; - if (strcmp(dir,"\\")==0) return false; - bool res=true; - Pathname newp; - newp.SetDirectory(dir); - if (mask) - { - WIN32_FIND_DATAA fnd; - HANDLE h; - newp.SetFilename(mask); - h=FindFirstFileA(newp,&fnd); - if (h) - { - do - { - if (!(fnd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - { - newp.SetFilename(fnd.cFileName); - if (DeleteFile(newp)==FALSE) res=false; - } - }while (FindNextFileA(h,&fnd)); - CloseHandle(h); - } - } - { - WIN32_FIND_DATAA fnd; - HANDLE h; - newp.SetFilename("*.*"); - h=FindFirstFileA(newp,&fnd); - if (h) - { - do - { - if ((fnd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && strcmp(fnd.cFileName,".")!=0 && strcmp(fnd.cFileName,"..")!=0) - { - newp.SetFilename(fnd.cFileName); - if (RemoveDirRecursive(newp,mask)==false) res=false; - else DeleteFile(newp); - } - }while (FindNextFileA(h,&fnd)); - CloseHandle(h); - } - } - return res; - -} - -bool Pathname::DeleteFolder(int dfFlags) -{ - int bufflen=strlen(_fullpath)+1; - char *buff=(char *)alloca(bufflen); -/* if (dfFlags & DFRecycleBin) - { - GetDirectoryWithDriveWLBS(buff,bufflen); - SHFILEOPSTRUCT delinfo; - delinfo.hwnd=NULL; - delinfo.wFunc=FO_DELETE; - delinfo.pFrom=GetFullPath(); - delinfo.pTo=NULL; - delinfo.fFlags=FOF_ALLOWUNDO|FOF_NOCONFIRMATION|FOF_NOERRORUI|((dfFlags & DFRecursive)?0:FOF_NORECURSION)| - ((dfFlags & DFShowProgress)?0:FOF_SILENT); - delinfo.fAnyOperationsAborted=0; - delinfo.hNameMappings=0; - delinfo.lpszProgressTitle=0; - - } - else*/ - { - if (dfFlags & DFRecursive) - { - bool res=RemoveDirRecursive(GetDirectoryWithDrive(),dfFlags & DFFile?GetFilename():0); - if (res==false) return false; - } - if (dfFlags & DFPath) - { - if (GetPart(1,buff,bufflen,-1)==false) return false; - return RemoveDirectoryFull(*this, 1,buff,bufflen); - } - else - { - GetDirectoryWithDriveWLBS(buff,bufflen); - return RemoveDirectory(buff)!=FALSE; - } - - } - return false; -} \ No newline at end of file diff --git a/AdvMan/Pathname.h b/AdvMan/Pathname.h deleted file mode 100644 index da57e63..0000000 --- a/AdvMan/Pathname.h +++ /dev/null @@ -1,451 +0,0 @@ -// Pathname.h: interface for the Pathname class. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_Pathname_H__40F41C23_3AA2_486C_B9E5_33AEE67FB313__INCLUDED_) -#define AFX_Pathname_H__40F41C23_3AA2_486C_B9E5_33AEE67FB313__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include -#include -#include - -#ifndef ASSERT -#ifdef _DEBUG -#define ASSERT(x) assert(x) -#else -#define ASSERT(x) -#endif -#endif - -enum PathNameNullEnum {PathNull}; - -#define PathNameCompare(op) bool operator op (const Pathname &other) const \ -{if (IsNull() || other.IsNull()) return false;else return istrcmp(_fullpath,other._fullpath) op 0;}\ - bool operator op (const char *other) const \ -{ASSERT(other[0]!=0);\ - if (IsNull() || other==NULL) return false;else return istrcmp(_fullpath,other) op 0;} - -#ifndef _UNICODE - -/** class Pathname simplifying manipulation with pathnames, filenames, general paths, and -also supports convert from absolute path to relative respectively */ - - - -class Pathname -{ - ///object value and data - /**The implementation of Pathname creates only one buffer for all variables. It can - increase speed by effective memory use. Strings are stored one after another separated - by zero byte. Evry time any string changed, implementation recalculate buffer usage, and - decide, whether it should resize buffer or not. - - _fullpath also points to string contain full path with filename, - it is dominant value of the class - */ - char *_fullpath; - char *_path; /// - If name is provided, Pathname will expand it into full name with drive and folder name. - @param name optional argument to inicialize object - */ - Pathname(const char *name=NULL); - - ///Construct Pathname class - /** Using this constructor Pathname(PathNull) will create Pathname class with null content is set. - If null content is set, all string-query function returns NULL. IsNull function returns true. This state - is sets until new path is assigned. There is a set of functions invalid called in null state. - */ - - Pathname(PathNameNullEnum null); - - ///Construct Pathname class - /** - @param relpath Relative path or uncomplette path or single filename with extension. - Pathname will expand this pathname into full using absolute path provided by the second - argument. - @param abspath Absolute path used as reference to folder - the origin of relative path - provided in the first argument. - */ - Pathname(const char *relpath, const Pathname &abspath); - - ///Construct Pathname as copy of another pathname - Pathname(const Pathname &other); - - ///Destruct Pathname - virtual ~Pathname(); - - ///Function returns the current drive letter. - /** Before usage, ensure, that current pathname contain drive. - In network path drive letter is missing. - In this case, result is undefined. To ensure, use HasDrive function - @return the drive letter of current path. - */ - char GetDrive() const - { - if (IsNull()) return 0; - return _path[0]; - } - - ///Static function determines, if argument contain a drive information. - /** - @param dir directory to inspect - @return true, if directory contain drive.

- This function is independed, it don't need any Pathname variable declared. - */ - static bool HasDrive(const char *dir) - {return (isalpha(dir[0]) && dir[1]==':');} - - ///Function determines, if current pathname contain a drive information - /** - @return true, if current pathname contain a drive information - */ - bool HasDrive() const - { - if (IsNull()) return false; - return HasDrive(_path); - } - - - ///Function returns current folder name - /** - if current folder name contain drive, only folder name is returned (without drive). - In other cases (relative or network drives) returns full path. - @return folder name or full path. Pointer is valid until any first change in object. - Do not invoke release function at pointer! - */ - const char *GetDirectory() const - { - if (HasDrive()) return _path+3; - else return _path; - } - - const char *GetDirectoryWithDrive() const - { - return _path; - } - - ///Function returns current filename with extension - /** - @return current filename with extension. Pointer is valid until any first change in object. - Do not invoke release function at pointer! - */ - const char *GetFilename() const - { - if (IsNull()) return NULL; - const char *blk=strrchr(_fullpath,'\\'); - if (blk) blk=blk+1;else blk=_fullpath; - return blk; - } - - ///Function returns current extension (with starting dot) - /** - @return current extension. Pointer is valid until any first change in object. - Do not invoke release function at pointer! - */ - const char *GetExtension() const - {return _extension;} - - ///Function returns current filename without extension (without dot) - /** - @return current filename without extension (without dot). Pointer is valid until any first change in object. - Do not invoke release function at pointer! - */ - const char *GetTitle() const - {return _filetitle;} - - ///Function changes current drive. - /**If object contain pathname with drive, then current drive is changed and function returns. - If object contain network path, then computer name is changed to the drive name. - If object contain relative path, then whole path is replaced by path on root on drive. - @param dr new drive letter. This parameter can be set to zero. It means, that current - driver is deleted, and path is converted to relative path from root. Note: Zero c - cannot be used with network paths and relative paths, and finnaly has no effect to the object - */ - - void SetDrive(const char dr); - - ///Sets new directory for object - /** if object contain a drive letter and argument dir doesn't, then current drive is remain - and only directory part is replaced. If current path is network path or relative path, - then whole path is replaced by new one. - If argument dir contain drive letter, then whole path is replaced too. - @param dir contain new pathname. Backslash should be the last character in string - */ - void SetDirectory(const char *dir); - - ///Sets new filename for object. - /** - If filename contain dot, function assumes, that filename is provided with extension. - Otherwise, current extension remains untouched. - @param filename new filename for object - */ - - void SetFilename(const char *filename); - - ///Sets new extension for object. - /** - If ext doesn't starting with dot, function adds it. - @param ext new extension for object - */ - void SetExtension(const char *ext); - - ///Sets new file title - /** Function changes file title, extension remains untouched. - if title contains extension (dot inside its name), this extension doesn't change - current extension. For example, if current extension is ".cpp" and filetitle contain - "source.h", then result is "source.h.cpp" - @param title a new title for object. - */ - - void SetFiletitle(const char *title); - - ///Function returns full pathname. - /** - @return current pathname. Pointer is valid until any first change in object. - Do not invoke release function at pointer! - */ - - const char *GetFullPath() const - {return _fullpath;} - - ///Sets pathname - /** Function has same effect as constructor. But it can be used - anytime during object lifetime. It simply replaces current pathname with newer. Pathname - in argument is expanded to full pathname, current directory is used as reference. - @param pathname new pathname - */ - void SetPathName(const char *pathname); - - Pathname& operator=(const char *other) - {SetPathName(other);return *this;} - Pathname& operator=(const Pathname& other); - - ///converts object to string - operator const char *() const - {return GetFullPath();} - - ///Static function to help getting filename from pathname - /** Function finds last backslash / and return pointer to first character after it. - Pointer stays valid until original path is destroyed or until original path is changed - @param path pathname to inspect as string - @return pointer to filename - */ - static const char *GetNameFromPath(const char *path); - - ///Static function to help getting extension from pathname - /** Function finds last dot '.' in filename return pointer to it (extension with dot). - Pointer stays valid until original path is destroyed or until original path is changed - @param path pathname to inspect as string - @return pointer to extension - */ - static const char *GetExtensionFromPath(const char *path); - - ///Function sets server name for network path - /** If current path is network path, then changes server name to newer. Otherwise - it remove drive letter, and insert server name before remain path - @param server server name without slashes - */ - void SetServerName(const char *server); - - ///Function inspects current path and returns, whether contain server name - /**@return zero, if current path is not valid network path. Nonzero if path contain - server name. Then value returned count characters containing server name with precedent - slashes. - */ - int IsNetworkPath() const; - - ///Function converts current relative path into absolute path - /** - If current path is not relative, function do nothing. - @param ref reference to path, against which path is relative. - @return true if path has been converted, or false, if conversion is impossible - */ - bool RelativeToFull(const Pathname &ref); - - ///Function converts current absolute path into relative path - /** - If current path is not relative, function do nothing. Both paths must be on the same - drive or network computer. - - @param ref reference to path, against which path should be relative. - @return true if path has been converted, or false, if conversion is impossible - */ - bool FullToRelative(const Pathname &relativeto); - - Pathname& operator+=(const char *relativePath) - {*this=Pathname(relativePath,*this);return *this;} - - Pathname operator+(const char *relativePath) - {Pathname out(relativePath,*this);return out;} - - bool IsNull() const {return _fullpath==NULL;} - - void SetNull(); - - PathNameCompare(<) - PathNameCompare(>) - PathNameCompare(==) - PathNameCompare(>=) - PathNameCompare(<=) - PathNameCompare(!=) - - - ///Function gets part of pathname - /** - @param path subject of examine - @param partnum zero-base index of part of pathname. Index 0 mostly contain drive or server, in case of - relative path, there is the name of the first folder or dots. - @param buff buffer for store result - @param bufsize count characters in buffer; - @param mode mode=0, gets only name of part. - mode=1, get current part and remain parts of path. - mode=-1, gets all parts till current - @return Function returns true, if it was succesful, and it was not last part. Function returns - false, if it was succesful, and it was last part. Function returns false and sets buffer empty, - if an error occured. Function returns true and sets buffer empty, if buffer is too small to hold data - */ - static bool GetPartFromPath(const char *path, int partnum, char *buff, int bufsize, int mode=0); - - ///Function gets part of object - /** - @param partnum zero-base index of part of pathname. Index 0 mostly contain drive or server, in case of - relative path, there is the name of the first folder or dots. - @param buff buffer for store result - @param bufsize count characters in buffer; - @param mode mode=0, gets only name of part. - mode=1, get current part and remain parts of path. - mode=-1, gets all parts till current - @return Function returns true, if it was succesful, and it was not last part. Function returns - false, if it was succesful, and it was last part. Function returns false and sets buffer empty, - if an error occured. Function returns true and sets buffer empty, if buffer is too small to hold data - */ - bool GetPart(int partnum, char *buff, int bufsize,int mode=0) const - { - return GetPartFromPath(this->_fullpath,partnum,buff,bufsize,mode); - } - - /// Get Directory With Drive Without Last Back Slash - /** Retrieves into buffer directory with drive and removes last backslash - @param buff buffer that retrieves path - @param size size of buffer - @return true, if success, failed if buffer is too small*/ - - - bool GetDirectoryWithDriveWLBS(char *buff, size_t size) const; - - - /// function checks, if path is valid and returns true, if does. - bool IsPathValid() const; - - /// Sets special directory. - /** - @param bSpecCode this value may be operation-system - depend. Windows implementation using CSIDL_XXXX constants, which is described in SHGetSpecialFolderLocation function - description - @return true, if function were successful - */ - bool SetDirectorySpecial(int nSpecCode); - - ///Sets temporaly directory. - bool SetTempDirectory(); - - ///Guess temporaly file name - /** - @param prefix prefix string for name - @param unique if unique is non-zero, it is used for new temporaly file. If unique is zero, function guess own unique - value. - @return true if function were successful - */ - bool SetTempFile(const char *prefix="tmp", unsigned int unique=NULL); - - ///Returns path of current executable. - /**It useful, when accessing folder, from when current module has been executed */ - static Pathname GetExePath(); - - ///Solves most used conversion from fullpath to path relative to project root - /** - @param full full pathname with drive - @param projectRoot project root path - @return function returns pointer to full path, where starts relative part. If - fullpath doesn't contain project root path, it returns pointer to full. - @example FullToProjectRoot("x:\\project\\data\\example.txt","x:\\project"); //result is "data\\example.txt" - */ - - static const char *FullToRelativeProjectRoot(const char *full, const char *projectRoot); - - ///Creates folder from path - static bool CreateFolder(const char *path, void *security_descriptor=0); - - ///Creates all folders from path stored in object - /** - Function creates path stored in object. Function creates whole path, when it doesn't - exists. - @param security_descriptor pointer for additional information about security on new folder - if this parameter is NULL, default descriptor is used. This parameter is platform - depended. - @return if path has been created, returns true. In case of error, returns false - and no changes are made on disk (Function rollbacks any changes) - */ - bool CreateFolder(void *security_descriptor=0); - - - enum DeleteFolderFlags { - DFSimple=0, //only deletes latest folder - DFPath=1, //deletes whole path, if there are no files - DFFile=2, //deletes file specified in object. You can use wildcards - DFRecursive=4, //also deletes all folders inside the path -/* DFRecycleBin=8, //move all deleted files or folders into recycle bin - DFShowProgress=16, //enables progress bar during deleting*/ - }; - - ///Deletes folder stored in object - /** - @param dfFlags combination of flags. - @return function returns true, when no error occured. Function return false, - when error occured. - */ - bool DeleteFolder(int dfFlags); - - -protected: - ///Function rebuild buffer with new values - /** This protected function recalculates space for buffer, allocated it, and rebuild its - content with data supplied by arguments. Function doesn't assumes, that all strings are - terminated by zero by default. "pathlen, titlelen and extlen" must contain correct values. - Terminating zero is not included, but function excepting it. - Valid using is: RebuildData(a,b,c,strlen(a),strlen(b),strlen(c)); - All pointers returned by Get functions can be used and stays valid, until this function returns. - */ - void RebuildData(const char *path, const char *filetitle, const char *extension, int pathlen, int titlelen, int extlen); - ///Function only rebuild _fullpath string. - /** It doesn't check space for string! This function is used, when length of path is excepted - the same or smaller, then current. - */ - void RebuildPath(); - - -}; - - -#else - -#error unicode version of Pathname is not currently supported - -#endif - -#undef PathNameCompare - -#endif // !defined(AFX_Pathname_H__40F41C23_3AA2_486C_B9E5_33AEE67FB313__INCLUDED_) diff --git a/AdvMan/StdAfx.cpp b/AdvMan/StdAfx.cpp deleted file mode 100644 index 46c628d..0000000 --- a/AdvMan/StdAfx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// AdvMan.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/AdvMan/StdAfx.h b/AdvMan/StdAfx.h deleted file mode 100644 index 3541103..0000000 --- a/AdvMan/StdAfx.h +++ /dev/null @@ -1,33 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__978B5377_B3F7_4A88_A4CA_02390EC070E2__INCLUDED_) -#define AFX_STDAFX_H__978B5377_B3F7_4A88_A4CA_02390EC070E2__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers - -#include // MFC core and standard components -#include // MFC extensions -#include // MFC support for Internet Explorer 4 Common Controls -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -extern "C" -{ -#include -#include -} -#include "Pathname.h" -#include -#include "..\mapedit\editor.h" -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__978B5377_B3F7_4A88_A4CA_02390EC070E2__INCLUDED_) diff --git a/AdvMan/bgraph2dx.h b/AdvMan/bgraph2dx.h deleted file mode 100644 index e69de29..0000000 diff --git a/AdvMan/debug.h b/AdvMan/debug.h deleted file mode 100644 index e69de29..0000000 diff --git a/AdvMan/idc_note.ico b/AdvMan/idc_note.ico deleted file mode 100644 index c6dc4fe..0000000 Binary files a/AdvMan/idc_note.ico and /dev/null differ diff --git a/AdvMan/mem.h b/AdvMan/mem.h deleted file mode 100644 index b0216b8..0000000 --- a/AdvMan/mem.h +++ /dev/null @@ -1,4 +0,0 @@ -__inline void *getmem(int32_t sz) -{ - return malloc(sz); -} \ No newline at end of file diff --git a/AdvMan/res/AdvMan.ico b/AdvMan/res/AdvMan.ico deleted file mode 100644 index 5311fc7..0000000 Binary files a/AdvMan/res/AdvMan.ico and /dev/null differ diff --git a/AdvMan/res/AdvMan.rc2 b/AdvMan/res/AdvMan.rc2 deleted file mode 100644 index cb2e42e..0000000 --- a/AdvMan/res/AdvMan.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// ADVMAN.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/AdvMan/res/Toolbar.bmp b/AdvMan/res/Toolbar.bmp deleted file mode 100644 index 90aadbe..0000000 Binary files a/AdvMan/res/Toolbar.bmp and /dev/null differ diff --git a/AdvMan/res/editory.bmp b/AdvMan/res/editory.bmp deleted file mode 100644 index c4aeb87..0000000 Binary files a/AdvMan/res/editory.bmp and /dev/null differ diff --git a/AdvMan/res/prekladace.bmp b/AdvMan/res/prekladace.bmp deleted file mode 100644 index 5493fd2..0000000 Binary files a/AdvMan/res/prekladace.bmp and /dev/null differ diff --git a/AdvMan/resource.h b/AdvMan/resource.h deleted file mode 100644 index 009d8cc..0000000 --- a/AdvMan/resource.h +++ /dev/null @@ -1,88 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by AdvMan.rc -// -#define IDC_ADD 4 -#define IDC_DELETE 5 -#define IDC_RESCAN 6 -#define IDD_ABOUTBOX 101 -#define IDD_TEXTEDITOR 105 -#define IDR_EDITORMENU 107 -#define IDI_MAINICON 117 -#define IDI_NOTEPADICON 118 -#define IDR_MAINFRAME 128 -#define IDR_ADVMANTYPE 129 -#define IDS_NOVEDOBRODRUZSTVIDOKONCENO 129 -#define IDD_NOVEDOBR 130 -#define IDS_ADVFILTER 130 -#define IDS_CHYBAPRICTENI 131 -#define IDS_MAINFRAMETITLE 132 -#define IDS_UNTITLED 133 -#define IDS_CANNOTEXECUTE 134 -#define IDD_DIALOGY 134 -#define IDS_NEMOHUNAJITNICOD 135 -#define IDD_NOVYDIALOG 135 -#define IDS_EDITADVWARN 136 -#define IDR_TOOLEDITORY 136 -#define IDS_DLGNAME 137 -#define IDS_DLGDESC 138 -#define IDR_PREKLADACE 138 -#define IDS_DLGID 139 -#define IDS_UNABLETOSAVEDIALOGYDLG 140 -#define IDS_NODESC 141 -#define IDC_JMENO 1000 -#define IDC_EDIT 1000 -#define IDC_ORGANIZACE 1001 -#define IDC_RADIO2 1002 -#define IDC_RADIO3 1003 -#define IDC_KOUZLA 1004 -#define IDC_DIALOGY 1005 -#define IDC_DEFINICE 1006 -#define IDC_MAPY 1007 -#define IDC_MAPY2 1008 -#define IDC_ORIGDLGS 1008 -#define IDC_STARTMAP 1009 -#define IDC_MINPOSTAV 1010 -#define IDC_MAXPOSTAV 1011 -#define IDC_DLGLIST 1012 -#define IDC_POPIS 1013 -#define IDC_CISLO 1016 -#define ID_FILE_NOVDOBRODRUST 32771 -#define ID_FILE_NATIDOBRODRUSTV 32773 -#define ID_EDITORY_KOUZLATAB 32774 -#define ID_EDITORY_POSTAVYTAB 32775 -#define ID_EDITORY_DIALOGY 32776 -#define ID_EDITORY_ITEMSSCR 32777 -#define ID_EDITORY_ITEMSPIC 32778 -#define ID_EDITORY_WEAPONSSCR 32779 -#define ID_NSTROJE_TVRCEPODLAH 32780 -#define ID_NSTROJE_TVRCEPALETPRONESTVRY 32781 -#define ID_NSTROJE_TVRCEIKONPROPEDMTY 32782 -#define ID_PEKLADAE_PELOKOUZLA 32783 -#define ID_PEKLADAE_PELODIALOGY 32784 -#define ID_PEKLADAE_PELOPOSTAVYTAB 32785 -#define ID_NSTROJE_EXPORTUJDOBRODRUSTV 32786 -#define ID_NSTROJE_TEKADDLSOUBOR 32787 -#define ID_NSTROJE_MAPEDIT 32788 -#define ID_NSTROJE_TESTUJDOBRODRUSTV 32789 -#define ID_EDITORY_SOUBORADV 32790 -#define ID_FILE_ZNOVUNAST 32791 -#define ID_VIEW_PREKLADACE 32802 -#define ID_VIEW_EDITORY 32810 -#define ID_PRAVY_UNDO 40001 -#define ID_UPRAVY_COPY 40002 -#define ID_UPRAVY_VYJMOUT 40003 -#define ID_UPRAVY_VLOZIT 40004 -#define ID_UPRAVY_VYMAZAT 40005 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 140 -#define _APS_NEXT_COMMAND_VALUE 32815 -#define _APS_NEXT_CONTROL_VALUE 1018 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/AdvMan/skeldal_win.h b/AdvMan/skeldal_win.h deleted file mode 100644 index 4fa48b5..0000000 --- a/AdvMan/skeldal_win.h +++ /dev/null @@ -1,4 +0,0 @@ -#include -#include -#include -#include \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index ad8266b..f937be8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ if (MSVC) add_compile_options(/W4 /EHsc /DNOMINMAX /J) set(STANDARD_LIBRARIES "") else() - add_compile_options(-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-value -Wno-extern-c-compat -funsigned-char) + add_compile_options(-Wall -Wextra -Werror -Wno-unused-result -Wno-unused-parameter -Wno-unused-value -Wno-extern-c-compat -funsigned-char) set(STANDARD_LIBRARIES "pthread") endif() diff --git a/DDLReader/DDLFile.cpp b/DDLReader/DDLFile.cpp deleted file mode 100644 index e0cc247..0000000 --- a/DDLReader/DDLFile.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "stdafx.h" -#include ".\ddlfile.h" - -DDLFile::DDLFile(void) -{ - _hFile=0; -} - -DDLFile::~DDLFile(void) -{ - if (_hFile!=0) CloseHandle(_hFile); -} - - - - -bool DDLFile::OpenDDLFile(WString filename) -{ - _hFile=CreateFile(filename,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL, - OPEN_EXISTING,FILE_FLAG_RANDOM_ACCESS,NULL); - if (_hFile==INVALID_HANDLE_VALUE) - { - _hFile=0; - return false; - } - return true; -} - -bool DDLFile::ReadFile(void *data, size_t sz) -{ - DWORD readed=0; - if (::ReadFile(_hFile,data,sz,&readed,NULL)==FALSE) return false; - if (readed!=sz) return false; - return true; -} - -bool DDLFile::EnumFiles(IDDLFileEnumerator &enmClass) -{ - uint32_t firstGroup; - uint32_t groupEndOffset; - uint32_t endGroups; - int i; - int ngroups; - SetFilePointer(_hFile,0,0,FILE_BEGIN); - if (ReadFile(&firstGroup,sizeof(firstGroup))==false) return false; - if (ReadFile(&groupEndOffset,sizeof(firstGroup))==false) return false; - uint32_t *group=(uint32_t *)alloca(groupEndOffset); - group[0]=firstGroup; - group[1]=groupEndOffset; - ngroups=groupEndOffset/8; - if (groupEndOffset!=8 && ReadFile(group+2,groupEndOffset-8)==false) return false; - SetFilePointer(_hFile,12,0,FILE_CURRENT); - if (ReadFile(&endGroups,sizeof(endGroups))==false) return false; - for (i=0;i(other); - dother.data=0;dother.sz=0; - } - DDLData& operator =(const DDLData &other) - { - DDLData &dother=const_cast(other); - data=other.data;sz=other.sz; - dother.data=0;dother.sz=0; - return *this; - } -}; - -class DDLFile -{ - HANDLE _hFile; - - bool ReadFile(void *data, size_t sz); -public: - DDLFile(void); - ~DDLFile(void); - - bool OpenDDLFile(WString filename); - bool EnumFiles(IDDLFileEnumerator &enmClass); - DDLData ExtractFile(uint32_t offset); - uint32_t GetFileSize(uint32_t offset); -}; diff --git a/DDLReader/DDLReader.cpp b/DDLReader/DDLReader.cpp deleted file mode 100644 index 2042ba3..0000000 --- a/DDLReader/DDLReader.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// DDLReader.cpp : Defines the class behaviors for the application. -// - -#include "stdafx.h" -#include "DDLReader.h" -#include "DDLReaderDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CDDLReaderApp - -BEGIN_MESSAGE_MAP(CDDLReaderApp, CWinApp) - //{{AFX_MSG_MAP(CDDLReaderApp) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - //}}AFX_MSG - ON_COMMAND(ID_HELP, CWinApp::OnHelp) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDDLReaderApp construction - -CDDLReaderApp::CDDLReaderApp() -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CDDLReaderApp object - -CDDLReaderApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CDDLReaderApp initialization - -BOOL CDDLReaderApp::InitInstance() -{ - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - - CDDLReaderDlg dlg; - m_pMainWnd = &dlg; - int nResponse = dlg.DoModal(); - if (nResponse == IDOK) - { - // TODO: Place code here to handle when the dialog is - // dismissed with OK - } - else if (nResponse == IDCANCEL) - { - // TODO: Place code here to handle when the dialog is - // dismissed with Cancel - } - - // Since the dialog has been closed, return FALSE so that we exit the - // application, rather than start the application's message pump. - return FALSE; -} diff --git a/DDLReader/DDLReader.h b/DDLReader/DDLReader.h deleted file mode 100644 index 08dbe48..0000000 --- a/DDLReader/DDLReader.h +++ /dev/null @@ -1,49 +0,0 @@ -// DDLReader.h : main header file for the DDLREADER application -// - -#if !defined(AFX_DDLREADER_H__9FE8F7F8_112D_4735_A4BA_5141A991D609__INCLUDED_) -#define AFX_DDLREADER_H__9FE8F7F8_112D_4735_A4BA_5141A991D609__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CDDLReaderApp: -// See DDLReader.cpp for the implementation of this class -// - -class CDDLReaderApp : public CWinApp -{ -public: - CDDLReaderApp(); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDDLReaderApp) - public: - virtual BOOL InitInstance(); - //}}AFX_VIRTUAL - -// Implementation - - //{{AFX_MSG(CDDLReaderApp) - // NOTE - the ClassWizard will add and remove member functions here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DDLREADER_H__9FE8F7F8_112D_4735_A4BA_5141A991D609__INCLUDED_) diff --git a/DDLReader/DDLReader.rc b/DDLReader/DDLReader.rc deleted file mode 100644 index f1fcb4b..0000000 --- a/DDLReader/DDLReader.rc +++ /dev/null @@ -1,278 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Czech resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CSY) -#ifdef _WIN32 -LANGUAGE LANG_CZECH, SUBLANG_DEFAULT -#pragma code_page(1250) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_SPLITTER_RESOURCES\r\n" - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\DDLReader.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\DDLReader.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_EXPORTING DIALOGEX 0, 0, 186, 82 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | - WS_CAPTION | WS_SYSMENU -CAPTION "Exporting" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER | 0x1,7,39, - 172,14 - CTEXT "Exporting",IDC_STATIC,7,7,172,8 - CTEXT "Static",IDC_NAME,7,23,172,8 - PUSHBUTTON "Stop",IDC_BUTTON1,68,61,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_EXPORTING, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 179 - TOPMARGIN, 7 - BOTTOMMARGIN, 75 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDS_ABOUTBOX "&About DDLReader..." - IDS_FILEOPENFAILED "Failed to open DDL" - IDC_HEADGROUP "Group" - IDC_HEADFNAME "Filename" - IDC_HEADSIZE "Size" - IDC_HEADOFFSET "Offset" - IDS_DDLFILTER "DDLFiles|*.ddl|All Files|*.*||" - IDC_GROUP_GRAPHICS "Graphics" - IDC_GROUP_SOUNDS "Sounds" - IDC_GROUP_FONTS "Fonts" - IDC_GROUP_BASIC "Basic graphics" -END - -STRINGTABLE -BEGIN - IDC_GROUP_ITEMS "Item graphics" - IDC_GROUP_MONSTERS "Monster graphics" - IDC_GROUP_DIALOGS "Dialog graphics" - IDC_GROUP_UNSPECIFIED "Unspecified" - IDC_GROUP_UNKNOWN "Unknown (%d)" - IDS_UNABLETOCREATEFILE "Unable to create target file: \r\n%1" - IDS_UNABLETOEXTACTDATA "Unable to extract data. General reading error" -END - -#endif // Czech resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOG 0, 0, 235, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About DDLReader" -FONT 8, "MS Sans Serif" -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "DDLReader Version 1.0",IDC_STATIC,40,10,119,8, - SS_NOPREFIX - LTEXT "Copyright (C) 2005",IDC_STATIC,40,25,119,8 - DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP -END - -IDD_DDLREADER_DIALOG DIALOGEX 0, 0, 364, 262 -STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE | WS_CAPTION | - WS_SYSMENU | WS_THICKFRAME -EXSTYLE WS_EX_APPWINDOW -CAPTION "DDLReader" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - CONTROL "List2",IDC_FILELIST,"SysListView32",LVS_REPORT | - LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,0,14,363,219 - LTEXT "Export to folder:",IDC_POPISEK,0,235,50,8 - EDITTEXT IDC_FOLDER,0,248,263,14,ES_AUTOHSCROLL - PUSHBUTTON "Browse",IDC_BROWSE,268,248,34,14 - PUSHBUTTON "Export",IDC_EXPORT,306,248,58,14 - EDITTEXT IDC_DDLFILE,0,0,313,12,ES_AUTOHSCROLL - PUSHBUTTON "Browse DDL",IDC_DDLBROWSE,314,0,50,12 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "FileDescription", "DDLReader MFC Application" - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "DDLReader" - VALUE "LegalCopyright", "Copyright (C) 2005" - VALUE "OriginalFilename", "DDLReader.EXE" - VALUE "ProductName", "DDLReader Application" - VALUE "ProductVersion", "1, 0, 0, 1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_ABOUTBOX, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 228 - TOPMARGIN, 7 - BOTTOMMARGIN, 48 - END - - IDD_DDLREADER_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 357 - TOPMARGIN, 7 - BOTTOMMARGIN, 255 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\DDLReader.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/DDLReader/DDLReader.sln b/DDLReader/DDLReader.sln deleted file mode 100644 index cc4c08b..0000000 --- a/DDLReader/DDLReader.sln +++ /dev/null @@ -1,34 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DDLReader", "DDLReader.vcproj", "{A5326507-3420-4D03-B9EB-5583790B412B}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SourceCodeControl) = preSolution - SccNumberOfProjects = 2 - SccProjectName0 = \u0022$/Skeldal/DDLReader\u0022,\u0020NJEAAAAA - SccLocalPath0 = ..\\..\\.. - SccProvider0 = MSSCCI:Microsoft\u0020Visual\u0020SourceSafe - CanCheckoutShared = false - SccProjectFilePathRelativizedFromConnection0 = Projects\\Skeldal\\DDLReader\\ - SolutionUniqueID = {A1A5598F-1F71-475C-8CAA-699B487DC20F} - SccProjectUniqueName1 = DDLReader.vcproj - SccLocalPath1 = ..\\..\\.. - CanCheckoutShared = false - SccProjectFilePathRelativizedFromConnection1 = Projects\\Skeldal\\DDLReader\\ - EndGlobalSection - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {A5326507-3420-4D03-B9EB-5583790B412B}.Debug.ActiveCfg = Debug|Win32 - {A5326507-3420-4D03-B9EB-5583790B412B}.Debug.Build.0 = Debug|Win32 - {A5326507-3420-4D03-B9EB-5583790B412B}.Release.ActiveCfg = Release|Win32 - {A5326507-3420-4D03-B9EB-5583790B412B}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/DDLReader/DDLReader.vcproj b/DDLReader/DDLReader.vcproj deleted file mode 100644 index f50a9a4..0000000 --- a/DDLReader/DDLReader.vcproj +++ /dev/null @@ -1,291 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/DDLReader/DDLReaderDlg.cpp b/DDLReader/DDLReaderDlg.cpp deleted file mode 100644 index 7e7a1f7..0000000 --- a/DDLReader/DDLReaderDlg.cpp +++ /dev/null @@ -1,533 +0,0 @@ -// DDLReaderDlg.cpp : implementation file -// - -#include "stdafx.h" -#include "DDLReader.h" -#include "DDLReaderDlg.h" -#include ".\ddlreaderdlg.h" -#include "WPathname.h" -#include "DlgProgress.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDDLReaderDlg dialog - -CDDLReaderDlg::CDDLReaderDlg(CWnd* pParent /*=NULL*/) - : CDialog(CDDLReaderDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CDDLReaderDlg) - vFolder = _T(""); - //}}AFX_DATA_INIT - // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 - m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); -} - -CDDLReaderDlg::~CDDLReaderDlg() -{ - if (!_lastTemp.IsNull()) DeleteFile(_lastTemp); -} - -void CDDLReaderDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CDDLReaderDlg) - DDX_Control(pDX, IDC_FOLDER, wFolder); - DDX_Control(pDX, IDC_FILELIST, wFileList); - DDX_Control(pDX, IDC_BROWSE, wBrowse); - DDX_Control(pDX, IDC_EXPORT, wExport); - DDX_Text(pDX, IDC_FOLDER, vFolder); - DDX_Control(pDX, IDC_POPISEK, wPopisek); - //}}AFX_DATA_MAP - DDX_Control(pDX, IDC_DDLFILE, wDDLFile); - DDX_Control(pDX, IDC_DDLBROWSE, wDDLBrowse); -} - -BEGIN_MESSAGE_MAP(CDDLReaderDlg, CDialog) - //{{AFX_MSG_MAP(CDDLReaderDlg) - ON_WM_SYSCOMMAND() - ON_WM_PAINT() - ON_WM_QUERYDRAGICON() - //}}AFX_MSG_MAP - ON_WM_SIZE() - ON_WM_GETMINMAXINFO() - ON_EN_KILLFOCUS(IDC_DDLFILE, OnEnKillfocusDdlfile) - ON_BN_CLICKED(IDC_DDLBROWSE, OnBnClickedDdlbrowse) - ON_NOTIFY(LVN_COLUMNCLICK, IDC_FILELIST, OnLvnColumnclickFilelist) - ON_BN_CLICKED(IDC_BROWSE, OnBnClickedBrowse) - ON_BN_CLICKED(IDC_EXPORT, OnBnClickedExport) - ON_NOTIFY(NM_DBLCLK, IDC_FILELIST, OnNMDblclkFilelist) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDDLReaderDlg message handlers - -BOOL CDDLReaderDlg::OnInitDialog() -{ - CRect rc; - GetClientRect(&rc); - _dlgSize=rc.Size(); - CDialog::OnInitDialog(); - - // Add "About..." menu item to system menu. - - // IDM_ABOUTBOX must be in the system command range. - ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); - ASSERT(IDM_ABOUTBOX < 0xF000); - - CMenu* pSysMenu = GetSystemMenu(FALSE); - if (pSysMenu != NULL) - { - CString strAboutMenu; - strAboutMenu.LoadString(IDS_ABOUTBOX); - if (!strAboutMenu.IsEmpty()) - { - pSysMenu->AppendMenu(MF_SEPARATOR); - pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); - } - } - - // Set the icon for this dialog. The framework does this automatically - // when the application's main window is not a dialog - SetIcon(m_hIcon, TRUE); // Set big icon - SetIcon(m_hIcon, FALSE); // Set small icon - - CString header; - header.LoadString(IDC_HEADGROUP); - wFileList.InsertColumn(0,header,LVCFMT_CENTER,100,0); - header.LoadString(IDC_HEADFNAME); - wFileList.InsertColumn(1,header,LVCFMT_LEFT,140,1); - header.LoadString(IDC_HEADSIZE); - wFileList.InsertColumn(2,header,LVCFMT_RIGHT,80,2); - header.LoadString(IDC_HEADOFFSET); - wFileList.InsertColumn(3,header,LVCFMT_RIGHT,80,3); - ListView_SetExtendedListViewStyleEx(wFileList,LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP,LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP); - - // TODO: Add extra initialization here - - return TRUE; // return TRUE unless you set the focus to a control -} - -void CDDLReaderDlg::OnSysCommand(UINT nID, LPARAM lParam) -{ - if ((nID & 0xFFF0) == IDM_ABOUTBOX) - { - CAboutDlg dlgAbout; - dlgAbout.DoModal(); - } - else - { - CDialog::OnSysCommand(nID, lParam); - } -} - -// If you add a minimize button to your dialog, you will need the code below -// to draw the icon. For MFC applications using the document/view model, -// this is automatically done for you by the framework. - -void CDDLReaderDlg::OnPaint() -{ - if (IsIconic()) - { - CPaintDC dc(this); // device context for painting - - SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); - - // Center icon in client rectangle - int cxIcon = GetSystemMetrics(SM_CXICON); - int cyIcon = GetSystemMetrics(SM_CYICON); - CRect rect; - GetClientRect(&rect); - int x = (rect.Width() - cxIcon + 1) / 2; - int y = (rect.Height() - cyIcon + 1) / 2; - - // Draw the icon - dc.DrawIcon(x, y, m_hIcon); - } - else - { - CDialog::OnPaint(); - } -} - -// The system calls this to obtain the cursor to display while the user drags -// the minimized window. -HCURSOR CDDLReaderDlg::OnQueryDragIcon() -{ - return (HCURSOR) m_hIcon; -} - -void MoveWindowRel(HDWP &hdwp, CWnd &wnd, int xr,int yr, int xs, int ys) -{ - CRect rc; - wnd.GetWindowRect(&rc); - wnd.GetParent()->ScreenToClient(&rc); - rc.left+=xr; - rc.top+=yr; - rc.bottom+=yr+ys; - rc.right+=xr+xs; - hdwp=DeferWindowPos(hdwp,wnd,NULL,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,SWP_NOZORDER); -} - -void CDDLReaderDlg::OnSize(UINT nType, int cx, int cy) -{ - CDialog::OnSize(nType, cx, cy); - if (nType!=SIZE_MINIMIZED) - { - if (wFileList.GetSafeHwnd()!=0) - { - HDWP dwp=BeginDeferWindowPos(10); - int difx=cx-_dlgSize.cx; - int dify=cy-_dlgSize.cy; - MoveWindowRel(dwp,wFileList,0,0,difx,dify); - MoveWindowRel(dwp,wPopisek,0,dify,0,0); - MoveWindowRel(dwp,wFolder,0,dify,difx,0); - MoveWindowRel(dwp,wExport,difx,dify,0,0); - MoveWindowRel(dwp,wBrowse,difx,dify,0,0); - MoveWindowRel(dwp,wDDLFile,0,0,difx,0); - MoveWindowRel(dwp,wDDLBrowse,difx,0,0,0); - EndDeferWindowPos(dwp); - - } - _dlgSize.cx=cx; - _dlgSize.cy=cy; - } -} - - -void CDDLReaderDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI) -{ - CDialog::OnGetMinMaxInfo(lpMMI); - lpMMI->ptMinTrackSize.x=200; - lpMMI->ptMinTrackSize.y=150; - -} - -void CDDLReaderDlg::OnEnKillfocusDdlfile() -{ - CString name; - wDDLFile.GetWindowText(name); - if (_ddlfile.OpenDDLFile(WString(name.GetString()))==false) - AfxMessageBox(IDS_FILEOPENFAILED); - UpdateList(); -} - -static CString GetGroupName(int group) -{ - int id; - switch (group) - { - case 1: id= IDC_GROUP_GRAPHICS;break; - case 2: id= IDC_GROUP_SOUNDS;break; - case 3: id= IDC_GROUP_FONTS;break; - case 7: id= IDC_GROUP_BASIC;break; - case 8: id= IDC_GROUP_ITEMS;break; - case 9: id= IDC_GROUP_MONSTERS;break; - case 11: id= IDC_GROUP_DIALOGS;break; - case 0: id=IDC_GROUP_UNSPECIFIED;break; - default: id=IDC_GROUP_UNKNOWN;break; - } - CString res; - res.Format(id,group); - return res; -} - -bool CDDLReaderDlg::File(WString name, int group, uint32_t offset) -{ - LVITEM item; - CString grpname=GetGroupName(group); - wchar_t buff[40]; - item.iItem=wFileList.GetItemCount(); - item.iSubItem=0; - item.mask=LVIF_GROUPID|LVIF_TEXT; - item.iGroupId=group; - item.pszText=grpname.LockBuffer(); - int ipos=wFileList.InsertItem(&item); - wFileList.SetItemText(ipos,1,name); - wFileList.SetItemText(ipos,3,_ui64tow(offset,buff,10)); - grpname.UnlockBuffer(); - return true; -} - -void CDDLReaderDlg::UpdateList(void) -{ - CString tmp; - wFileList.DeleteAllItems(); - _ddlfile.EnumFiles(*this); - for (int i=0,cnt=wFileList.GetItemCount();iGetItemText(lParam1,sinfo.index); - sinfo.right=sinfo.list->GetItemText(lParam2,sinfo.index); - switch (sinfo.index) - { - case 0: - case 1: res=wcsicmp(sinfo.left,sinfo.right);break; - case 3: { - int l=_wtoi(sinfo.left); - int r=_wtoi(sinfo.right); - res=(l>r)-(lGetItemText(lParam1,3); - sinfo.right=sinfo.list->GetItemText(lParam2,3); - uint32_t l=_wtoi(sinfo.left); - uint32_t r=_wtoi(sinfo.right); - l=sinfo._ddlfile->GetFileSize(l); - r=sinfo._ddlfile->GetFileSize(r); - res=(l>r)-(llParam2)-(lParam1(pNMHDR); - for (int i=0,cnt=wFileList.GetItemCount();iiSubItem; - sinfo.list=&wFileList; - sinfo._ddlfile=&_ddlfile; - wFileList.SortItems(SortItemsInFileList,(LPARAM)&sinfo); - *pResult = 0; -} - -static int WINAPI PosBrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lParam,LPARAM lpData) - { - const wchar_t *curpath=(const wchar_t *)lpData; - if (uMsg == BFFM_INITIALIZED) - { - if (curpath && curpath[0]) - { - ::SendMessage(hwnd,BFFM_SETSELECTION,TRUE,(LPARAM)((LPCSTR)curpath)); - ::SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)((LPCSTR)curpath)); - } - } - else if (uMsg == BFFM_SELCHANGED) - { - wchar_t buff[_MAX_PATH]; - if (SHGetPathFromIDList((LPITEMIDLIST)lParam,buff)) - { - ::SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)buff); - } - } - return 0; - }; - -static bool PathBrowser(HWND hWnd, wchar_t *path /* MAX_PATH size */) -{ - BROWSEINFO brw; - memset(&brw,0,sizeof(brw)); - brw.hwndOwner=hWnd; - brw.pidlRoot=NULL; - brw.pszDisplayName=path; - brw.lParam=(LPARAM)path; - brw.ulFlags= BIF_RETURNONLYFSDIRS |BIF_STATUSTEXT|BIF_USENEWUI ; - brw.lpfn = (BFFCALLBACK)(PosBrowseCallbackProc); - LPITEMIDLIST il=SHBrowseForFolder( &brw ); - if (il==NULL) return false; - SHGetPathFromIDList(il,path); - IMalloc *shmalloc; - SHGetMalloc(&shmalloc); - shmalloc->Free(il); - if (path[0]==0) return false; - return true; -} - - -void CDDLReaderDlg::OnBnClickedBrowse() -{ - wchar_t path[MAX_PATH]; - wFolder.GetWindowText(path,MAX_PATH); - if (PathBrowser(*this,path)) - { - wFolder.SetWindowText(path); - } -} - -void CDDLReaderDlg::OnBnClickedExport() -{ - wchar_t path[MAX_PATH]; - wFolder.GetWindowText(path,MAX_PATH); - if (path[0]==0) OnBnClickedBrowse(); - wFolder.GetWindowText(path,MAX_PATH); - if (path[0]==0) return; - WPathname fpath; - fpath.SetDirectory(path); - POSITION pos=wFileList.GetFirstSelectedItemPosition(); - int max=wFileList.GetSelectedCount(); - int cur=0; - DlgProgress pb; - if (max) {pb.Create(IDD_EXPORTING);pb.CenterWindow(this);EnableWindow(FALSE);} - while (pos) - { - MSG msg; - pb.wProgress.SetRange(0,max); - pb.wProgress.SetPos(++cur); - int i=wFileList.GetNextSelectedItem(pos); - CString fname; - uint32_t offset; - fname=wFileList.GetItemText(i,1); - offset=(uint32_t)_wtoi64(wFileList.GetItemText(i,3)); - pb.wDesc.SetWindowText(fname); - if (PeekMessage(&msg,0,0,0,PM_NOREMOVE)==TRUE) AfxPumpMessage(); - if (pb.stop) break; - DDLData data=_ddlfile.ExtractFile(offset); - if (data.data!=NULL) - { - fpath.SetFilename(fname); - HANDLE hFile=CreateFile(fpath,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL); - while (hFile==INVALID_HANDLE_VALUE) - { - CString msg; - AfxFormatString1(msg,IDS_UNABLETOCREATEFILE,fpath); - int retry=AfxMessageBox(msg,MB_ABORTRETRYIGNORE); - if (retry==IDABORT) {EnableWindow(TRUE);return;} - if (retry==IDIGNORE) break; - hFile=CreateFile(fpath,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL); - } - if (hFile!=INVALID_HANDLE_VALUE) - { - DWORD written; - WriteFile(hFile,data.data,data.sz,&written,NULL); - CloseHandle(hFile); - } - } - else - { - CString msg; - AfxFormatString1(msg,IDS_UNABLETOEXTACTDATA,fpath); - AfxMessageBox(msg,MB_OK|MB_ICONSTOP); - } - } - EnableWindow(TRUE); - - -} - -WPathname CDDLReaderDlg::CreateTemp(int index) -{ - if (!_lastTemp.IsNull()) DeleteFile(_lastTemp); - CString fname; - uint32_t offset; - fname=wFileList.GetItemText(index,1); - offset=(uint32_t)_wtoi64(wFileList.GetItemText(index,3)); - _lastTemp.SetTempDirectory(); - _lastTemp.SetFileTitle(WSC("SkeldalDDLReader")); - _lastTemp.SetExtension(WSC(".")+WString(fname)); - DDLData data=_ddlfile.ExtractFile(offset); - if (data.data) - { - HANDLE hFile=CreateFile(_lastTemp,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL); - DWORD written; - WriteFile(hFile,data.data,data.sz,&written,NULL); - CloseHandle(hFile); - } - return _lastTemp; -} - -void CDDLReaderDlg::OnNMDblclkFilelist(NMHDR *pNMHDR, LRESULT *pResult) -{ - // TODO: Add your control notification handler code here - *pResult = 0; - int index=wFileList.GetNextItem(-1,LVNI_FOCUSED); - WPathname pth=CreateTemp(index); - ShellExecute(*this,0,pth,0,0,SW_NORMAL); -} diff --git a/DDLReader/DDLReaderDlg.h b/DDLReader/DDLReaderDlg.h deleted file mode 100644 index 7faf316..0000000 --- a/DDLReader/DDLReaderDlg.h +++ /dev/null @@ -1,76 +0,0 @@ -// DDLReaderDlg.h : header file -// - -#include "t:\h\atlmfc\include\afxwin.h" -#include "ddlfile.h" -#include "WPathname.h" -#if !defined(AFX_DDLREADERDLG_H__E765355F_0112_4B3E_90CE_111E28FE8EC6__INCLUDED_) -#define AFX_DDLREADERDLG_H__E765355F_0112_4B3E_90CE_111E28FE8EC6__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -///////////////////////////////////////////////////////////////////////////// -// CDDLReaderDlg dialog - -class CDDLReaderDlg : public CDialog, public IDDLFileEnumerator -{ -// Construction - CSize _dlgSize; - WPathname _lastTemp; -public: - CDDLReaderDlg(CWnd* pParent = NULL); // standard constructor - ~CDDLReaderDlg(); - -// Dialog Data - //{{AFX_DATA(CDDLReaderDlg) - enum { IDD = IDD_DDLREADER_DIALOG }; - CEdit wFolder; - CListCtrl wFileList; - CButton wBrowse; - CButton wExport; - CString vFolder; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDDLReaderDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - HICON m_hIcon; - - // Generated message map functions - //{{AFX_MSG(CDDLReaderDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnSysCommand(UINT nID, LPARAM lParam); - afx_msg void OnPaint(); - afx_msg HCURSOR OnQueryDragIcon(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -public: - afx_msg void OnSize(UINT nType, int cx, int cy); - CStatic wPopisek; - CEdit wDDLFile; - CButton wDDLBrowse; - afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI); - DDLFile _ddlfile; - afx_msg void OnEnKillfocusDdlfile(); - void UpdateList(void); - virtual bool File(WString name, int group, uint32_t offset); - afx_msg void OnBnClickedDdlbrowse(); - afx_msg void OnLvnColumnclickFilelist(NMHDR *pNMHDR, LRESULT *pResult); - afx_msg void OnBnClickedBrowse(); - afx_msg void OnBnClickedExport(); - afx_msg void OnNMDblclkFilelist(NMHDR *pNMHDR, LRESULT *pResult); - - WPathname CreateTemp(int index); -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DDLREADERDLG_H__E765355F_0112_4B3E_90CE_111E28FE8EC6__INCLUDED_) diff --git a/DDLReader/DlgProgress.cpp b/DDLReader/DlgProgress.cpp deleted file mode 100644 index cccfd60..0000000 --- a/DDLReader/DlgProgress.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// DlgProgress.cpp : implementation file -// - -#include "stdafx.h" -#include "DDLReader.h" -#include "DlgProgress.h" -#include ".\dlgprogress.h" - - -// DlgProgress dialog - -IMPLEMENT_DYNAMIC(DlgProgress, CDialog) -DlgProgress::DlgProgress(CWnd* pParent /*=NULL*/) - : CDialog(DlgProgress::IDD, pParent) -{ - stop=false; -} - -DlgProgress::~DlgProgress() -{ -} - -void DlgProgress::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - DDX_Control(pDX, IDC_PROGRESS, wProgress); - DDX_Control(pDX, IDC_NAME, wDesc); -} - - -BEGIN_MESSAGE_MAP(DlgProgress, CDialog) - ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1) -END_MESSAGE_MAP() - - -// DlgProgress message handlers - -void DlgProgress::OnBnClickedButton1() -{ - stop=true; -} diff --git a/DDLReader/DlgProgress.h b/DDLReader/DlgProgress.h deleted file mode 100644 index 8e6e3fb..0000000 --- a/DDLReader/DlgProgress.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include "t:\h\atlmfc\include\afxcmn.h" -#include "t:\h\atlmfc\include\afxwin.h" - - -// DlgProgress dialog - -class DlgProgress : public CDialog -{ - DECLARE_DYNAMIC(DlgProgress) - -public: - DlgProgress(CWnd* pParent = NULL); // standard constructor - virtual ~DlgProgress(); - -// Dialog Data - enum { IDD = IDD_EXPORTING }; - -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - - DECLARE_MESSAGE_MAP() -public: - CProgressCtrl wProgress; - CStatic wDesc; - afx_msg void OnBnClickedButton1(); - bool stop; -}; diff --git a/DDLReader/IWStringEffect.h b/DDLReader/IWStringEffect.h deleted file mode 100644 index 084f813..0000000 --- a/DDLReader/IWStringEffect.h +++ /dev/null @@ -1,36 +0,0 @@ -#if !defined(AFX_IWSTRINGEFFECT_H__863ADE82_7789_4E54_BE7D_B8F0740FD81B__INCLUDED_) -#define AFX_IWSTRINGEFFECT_H__863ADE82_7789_4E54_BE7D_B8F0740FD81B__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include - -class IWStringEffect -{ -public: - ///function returns extra size that effect needs - /** - @param curSize size of string that enters to the effect - @return count of extra characters needs to effects; - */ - virtual uint32_t GetEffectExtraSize(uint32_t curSize) {return 0;} - - ///function renders begin of string. - /** Function returns number of characters rendered, and must be <= then size returned by GetEffectExtraSize() - @param renderPtr pointer to render buffer - @param curSize size of string that enters to the effect - @return number of characters rendered. Entered string will be rendered behind. - */ - virtual uint32_t PreRenderString(wchar_t *renderPtr,uint32_t curSize) {return 0;} - - ///function renders effect. - /** - @param renderPtr pointer to begin of render buffer. - @param rendered number of characters rendered by previous effect. Value doesn't point to the end - of buffer, function must add result of PreRenderString */ - virtual void RenderString(wchar_t *renderPtr, uint32_t rendered)=0; -}; - -#endif diff --git a/DDLReader/Projects/Skeldal/DDLReader/DDLFile.cpp b/DDLReader/Projects/Skeldal/DDLReader/DDLFile.cpp deleted file mode 100644 index e0cc247..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/DDLFile.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "stdafx.h" -#include ".\ddlfile.h" - -DDLFile::DDLFile(void) -{ - _hFile=0; -} - -DDLFile::~DDLFile(void) -{ - if (_hFile!=0) CloseHandle(_hFile); -} - - - - -bool DDLFile::OpenDDLFile(WString filename) -{ - _hFile=CreateFile(filename,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL, - OPEN_EXISTING,FILE_FLAG_RANDOM_ACCESS,NULL); - if (_hFile==INVALID_HANDLE_VALUE) - { - _hFile=0; - return false; - } - return true; -} - -bool DDLFile::ReadFile(void *data, size_t sz) -{ - DWORD readed=0; - if (::ReadFile(_hFile,data,sz,&readed,NULL)==FALSE) return false; - if (readed!=sz) return false; - return true; -} - -bool DDLFile::EnumFiles(IDDLFileEnumerator &enmClass) -{ - uint32_t firstGroup; - uint32_t groupEndOffset; - uint32_t endGroups; - int i; - int ngroups; - SetFilePointer(_hFile,0,0,FILE_BEGIN); - if (ReadFile(&firstGroup,sizeof(firstGroup))==false) return false; - if (ReadFile(&groupEndOffset,sizeof(firstGroup))==false) return false; - uint32_t *group=(uint32_t *)alloca(groupEndOffset); - group[0]=firstGroup; - group[1]=groupEndOffset; - ngroups=groupEndOffset/8; - if (groupEndOffset!=8 && ReadFile(group+2,groupEndOffset-8)==false) return false; - SetFilePointer(_hFile,12,0,FILE_CURRENT); - if (ReadFile(&endGroups,sizeof(endGroups))==false) return false; - for (i=0;i(other); - dother.data=0;dother.sz=0; - } - DDLData& operator =(const DDLData &other) - { - DDLData &dother=const_cast(other); - data=other.data;sz=other.sz; - dother.data=0;dother.sz=0; - return *this; - } -}; - -class DDLFile -{ - HANDLE _hFile; - - bool ReadFile(void *data, size_t sz); -public: - DDLFile(void); - ~DDLFile(void); - - bool OpenDDLFile(WString filename); - bool EnumFiles(IDDLFileEnumerator &enmClass); - DDLData ExtractFile(uint32_t offset); - uint32_t GetFileSize(uint32_t offset); -}; diff --git a/DDLReader/Projects/Skeldal/DDLReader/DDLReader.cpp b/DDLReader/Projects/Skeldal/DDLReader/DDLReader.cpp deleted file mode 100644 index 2042ba3..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/DDLReader.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// DDLReader.cpp : Defines the class behaviors for the application. -// - -#include "stdafx.h" -#include "DDLReader.h" -#include "DDLReaderDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CDDLReaderApp - -BEGIN_MESSAGE_MAP(CDDLReaderApp, CWinApp) - //{{AFX_MSG_MAP(CDDLReaderApp) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - //}}AFX_MSG - ON_COMMAND(ID_HELP, CWinApp::OnHelp) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDDLReaderApp construction - -CDDLReaderApp::CDDLReaderApp() -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CDDLReaderApp object - -CDDLReaderApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CDDLReaderApp initialization - -BOOL CDDLReaderApp::InitInstance() -{ - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - - CDDLReaderDlg dlg; - m_pMainWnd = &dlg; - int nResponse = dlg.DoModal(); - if (nResponse == IDOK) - { - // TODO: Place code here to handle when the dialog is - // dismissed with OK - } - else if (nResponse == IDCANCEL) - { - // TODO: Place code here to handle when the dialog is - // dismissed with Cancel - } - - // Since the dialog has been closed, return FALSE so that we exit the - // application, rather than start the application's message pump. - return FALSE; -} diff --git a/DDLReader/Projects/Skeldal/DDLReader/DDLReader.h b/DDLReader/Projects/Skeldal/DDLReader/DDLReader.h deleted file mode 100644 index 08dbe48..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/DDLReader.h +++ /dev/null @@ -1,49 +0,0 @@ -// DDLReader.h : main header file for the DDLREADER application -// - -#if !defined(AFX_DDLREADER_H__9FE8F7F8_112D_4735_A4BA_5141A991D609__INCLUDED_) -#define AFX_DDLREADER_H__9FE8F7F8_112D_4735_A4BA_5141A991D609__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CDDLReaderApp: -// See DDLReader.cpp for the implementation of this class -// - -class CDDLReaderApp : public CWinApp -{ -public: - CDDLReaderApp(); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDDLReaderApp) - public: - virtual BOOL InitInstance(); - //}}AFX_VIRTUAL - -// Implementation - - //{{AFX_MSG(CDDLReaderApp) - // NOTE - the ClassWizard will add and remove member functions here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DDLREADER_H__9FE8F7F8_112D_4735_A4BA_5141A991D609__INCLUDED_) diff --git a/DDLReader/Projects/Skeldal/DDLReader/DDLReader.rc b/DDLReader/Projects/Skeldal/DDLReader/DDLReader.rc deleted file mode 100644 index f1fcb4b..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/DDLReader.rc +++ /dev/null @@ -1,278 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Czech resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CSY) -#ifdef _WIN32 -LANGUAGE LANG_CZECH, SUBLANG_DEFAULT -#pragma code_page(1250) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_SPLITTER_RESOURCES\r\n" - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\DDLReader.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\DDLReader.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_EXPORTING DIALOGEX 0, 0, 186, 82 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | - WS_CAPTION | WS_SYSMENU -CAPTION "Exporting" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER | 0x1,7,39, - 172,14 - CTEXT "Exporting",IDC_STATIC,7,7,172,8 - CTEXT "Static",IDC_NAME,7,23,172,8 - PUSHBUTTON "Stop",IDC_BUTTON1,68,61,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_EXPORTING, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 179 - TOPMARGIN, 7 - BOTTOMMARGIN, 75 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDS_ABOUTBOX "&About DDLReader..." - IDS_FILEOPENFAILED "Failed to open DDL" - IDC_HEADGROUP "Group" - IDC_HEADFNAME "Filename" - IDC_HEADSIZE "Size" - IDC_HEADOFFSET "Offset" - IDS_DDLFILTER "DDLFiles|*.ddl|All Files|*.*||" - IDC_GROUP_GRAPHICS "Graphics" - IDC_GROUP_SOUNDS "Sounds" - IDC_GROUP_FONTS "Fonts" - IDC_GROUP_BASIC "Basic graphics" -END - -STRINGTABLE -BEGIN - IDC_GROUP_ITEMS "Item graphics" - IDC_GROUP_MONSTERS "Monster graphics" - IDC_GROUP_DIALOGS "Dialog graphics" - IDC_GROUP_UNSPECIFIED "Unspecified" - IDC_GROUP_UNKNOWN "Unknown (%d)" - IDS_UNABLETOCREATEFILE "Unable to create target file: \r\n%1" - IDS_UNABLETOEXTACTDATA "Unable to extract data. General reading error" -END - -#endif // Czech resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOG 0, 0, 235, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About DDLReader" -FONT 8, "MS Sans Serif" -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "DDLReader Version 1.0",IDC_STATIC,40,10,119,8, - SS_NOPREFIX - LTEXT "Copyright (C) 2005",IDC_STATIC,40,25,119,8 - DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP -END - -IDD_DDLREADER_DIALOG DIALOGEX 0, 0, 364, 262 -STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE | WS_CAPTION | - WS_SYSMENU | WS_THICKFRAME -EXSTYLE WS_EX_APPWINDOW -CAPTION "DDLReader" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - CONTROL "List2",IDC_FILELIST,"SysListView32",LVS_REPORT | - LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,0,14,363,219 - LTEXT "Export to folder:",IDC_POPISEK,0,235,50,8 - EDITTEXT IDC_FOLDER,0,248,263,14,ES_AUTOHSCROLL - PUSHBUTTON "Browse",IDC_BROWSE,268,248,34,14 - PUSHBUTTON "Export",IDC_EXPORT,306,248,58,14 - EDITTEXT IDC_DDLFILE,0,0,313,12,ES_AUTOHSCROLL - PUSHBUTTON "Browse DDL",IDC_DDLBROWSE,314,0,50,12 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "FileDescription", "DDLReader MFC Application" - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "DDLReader" - VALUE "LegalCopyright", "Copyright (C) 2005" - VALUE "OriginalFilename", "DDLReader.EXE" - VALUE "ProductName", "DDLReader Application" - VALUE "ProductVersion", "1, 0, 0, 1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_ABOUTBOX, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 228 - TOPMARGIN, 7 - BOTTOMMARGIN, 48 - END - - IDD_DDLREADER_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 357 - TOPMARGIN, 7 - BOTTOMMARGIN, 255 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\DDLReader.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/DDLReader/Projects/Skeldal/DDLReader/DDLReader.sln b/DDLReader/Projects/Skeldal/DDLReader/DDLReader.sln deleted file mode 100644 index cc4c08b..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/DDLReader.sln +++ /dev/null @@ -1,34 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DDLReader", "DDLReader.vcproj", "{A5326507-3420-4D03-B9EB-5583790B412B}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SourceCodeControl) = preSolution - SccNumberOfProjects = 2 - SccProjectName0 = \u0022$/Skeldal/DDLReader\u0022,\u0020NJEAAAAA - SccLocalPath0 = ..\\..\\.. - SccProvider0 = MSSCCI:Microsoft\u0020Visual\u0020SourceSafe - CanCheckoutShared = false - SccProjectFilePathRelativizedFromConnection0 = Projects\\Skeldal\\DDLReader\\ - SolutionUniqueID = {A1A5598F-1F71-475C-8CAA-699B487DC20F} - SccProjectUniqueName1 = DDLReader.vcproj - SccLocalPath1 = ..\\..\\.. - CanCheckoutShared = false - SccProjectFilePathRelativizedFromConnection1 = Projects\\Skeldal\\DDLReader\\ - EndGlobalSection - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {A5326507-3420-4D03-B9EB-5583790B412B}.Debug.ActiveCfg = Debug|Win32 - {A5326507-3420-4D03-B9EB-5583790B412B}.Debug.Build.0 = Debug|Win32 - {A5326507-3420-4D03-B9EB-5583790B412B}.Release.ActiveCfg = Release|Win32 - {A5326507-3420-4D03-B9EB-5583790B412B}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/DDLReader/Projects/Skeldal/DDLReader/DDLReader.vcproj b/DDLReader/Projects/Skeldal/DDLReader/DDLReader.vcproj deleted file mode 100644 index f50a9a4..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/DDLReader.vcproj +++ /dev/null @@ -1,291 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/DDLReader/Projects/Skeldal/DDLReader/DDLReaderDlg.cpp b/DDLReader/Projects/Skeldal/DDLReader/DDLReaderDlg.cpp deleted file mode 100644 index 7e7a1f7..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/DDLReaderDlg.cpp +++ /dev/null @@ -1,533 +0,0 @@ -// DDLReaderDlg.cpp : implementation file -// - -#include "stdafx.h" -#include "DDLReader.h" -#include "DDLReaderDlg.h" -#include ".\ddlreaderdlg.h" -#include "WPathname.h" -#include "DlgProgress.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDDLReaderDlg dialog - -CDDLReaderDlg::CDDLReaderDlg(CWnd* pParent /*=NULL*/) - : CDialog(CDDLReaderDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CDDLReaderDlg) - vFolder = _T(""); - //}}AFX_DATA_INIT - // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 - m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); -} - -CDDLReaderDlg::~CDDLReaderDlg() -{ - if (!_lastTemp.IsNull()) DeleteFile(_lastTemp); -} - -void CDDLReaderDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CDDLReaderDlg) - DDX_Control(pDX, IDC_FOLDER, wFolder); - DDX_Control(pDX, IDC_FILELIST, wFileList); - DDX_Control(pDX, IDC_BROWSE, wBrowse); - DDX_Control(pDX, IDC_EXPORT, wExport); - DDX_Text(pDX, IDC_FOLDER, vFolder); - DDX_Control(pDX, IDC_POPISEK, wPopisek); - //}}AFX_DATA_MAP - DDX_Control(pDX, IDC_DDLFILE, wDDLFile); - DDX_Control(pDX, IDC_DDLBROWSE, wDDLBrowse); -} - -BEGIN_MESSAGE_MAP(CDDLReaderDlg, CDialog) - //{{AFX_MSG_MAP(CDDLReaderDlg) - ON_WM_SYSCOMMAND() - ON_WM_PAINT() - ON_WM_QUERYDRAGICON() - //}}AFX_MSG_MAP - ON_WM_SIZE() - ON_WM_GETMINMAXINFO() - ON_EN_KILLFOCUS(IDC_DDLFILE, OnEnKillfocusDdlfile) - ON_BN_CLICKED(IDC_DDLBROWSE, OnBnClickedDdlbrowse) - ON_NOTIFY(LVN_COLUMNCLICK, IDC_FILELIST, OnLvnColumnclickFilelist) - ON_BN_CLICKED(IDC_BROWSE, OnBnClickedBrowse) - ON_BN_CLICKED(IDC_EXPORT, OnBnClickedExport) - ON_NOTIFY(NM_DBLCLK, IDC_FILELIST, OnNMDblclkFilelist) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDDLReaderDlg message handlers - -BOOL CDDLReaderDlg::OnInitDialog() -{ - CRect rc; - GetClientRect(&rc); - _dlgSize=rc.Size(); - CDialog::OnInitDialog(); - - // Add "About..." menu item to system menu. - - // IDM_ABOUTBOX must be in the system command range. - ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); - ASSERT(IDM_ABOUTBOX < 0xF000); - - CMenu* pSysMenu = GetSystemMenu(FALSE); - if (pSysMenu != NULL) - { - CString strAboutMenu; - strAboutMenu.LoadString(IDS_ABOUTBOX); - if (!strAboutMenu.IsEmpty()) - { - pSysMenu->AppendMenu(MF_SEPARATOR); - pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); - } - } - - // Set the icon for this dialog. The framework does this automatically - // when the application's main window is not a dialog - SetIcon(m_hIcon, TRUE); // Set big icon - SetIcon(m_hIcon, FALSE); // Set small icon - - CString header; - header.LoadString(IDC_HEADGROUP); - wFileList.InsertColumn(0,header,LVCFMT_CENTER,100,0); - header.LoadString(IDC_HEADFNAME); - wFileList.InsertColumn(1,header,LVCFMT_LEFT,140,1); - header.LoadString(IDC_HEADSIZE); - wFileList.InsertColumn(2,header,LVCFMT_RIGHT,80,2); - header.LoadString(IDC_HEADOFFSET); - wFileList.InsertColumn(3,header,LVCFMT_RIGHT,80,3); - ListView_SetExtendedListViewStyleEx(wFileList,LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP,LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP); - - // TODO: Add extra initialization here - - return TRUE; // return TRUE unless you set the focus to a control -} - -void CDDLReaderDlg::OnSysCommand(UINT nID, LPARAM lParam) -{ - if ((nID & 0xFFF0) == IDM_ABOUTBOX) - { - CAboutDlg dlgAbout; - dlgAbout.DoModal(); - } - else - { - CDialog::OnSysCommand(nID, lParam); - } -} - -// If you add a minimize button to your dialog, you will need the code below -// to draw the icon. For MFC applications using the document/view model, -// this is automatically done for you by the framework. - -void CDDLReaderDlg::OnPaint() -{ - if (IsIconic()) - { - CPaintDC dc(this); // device context for painting - - SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); - - // Center icon in client rectangle - int cxIcon = GetSystemMetrics(SM_CXICON); - int cyIcon = GetSystemMetrics(SM_CYICON); - CRect rect; - GetClientRect(&rect); - int x = (rect.Width() - cxIcon + 1) / 2; - int y = (rect.Height() - cyIcon + 1) / 2; - - // Draw the icon - dc.DrawIcon(x, y, m_hIcon); - } - else - { - CDialog::OnPaint(); - } -} - -// The system calls this to obtain the cursor to display while the user drags -// the minimized window. -HCURSOR CDDLReaderDlg::OnQueryDragIcon() -{ - return (HCURSOR) m_hIcon; -} - -void MoveWindowRel(HDWP &hdwp, CWnd &wnd, int xr,int yr, int xs, int ys) -{ - CRect rc; - wnd.GetWindowRect(&rc); - wnd.GetParent()->ScreenToClient(&rc); - rc.left+=xr; - rc.top+=yr; - rc.bottom+=yr+ys; - rc.right+=xr+xs; - hdwp=DeferWindowPos(hdwp,wnd,NULL,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,SWP_NOZORDER); -} - -void CDDLReaderDlg::OnSize(UINT nType, int cx, int cy) -{ - CDialog::OnSize(nType, cx, cy); - if (nType!=SIZE_MINIMIZED) - { - if (wFileList.GetSafeHwnd()!=0) - { - HDWP dwp=BeginDeferWindowPos(10); - int difx=cx-_dlgSize.cx; - int dify=cy-_dlgSize.cy; - MoveWindowRel(dwp,wFileList,0,0,difx,dify); - MoveWindowRel(dwp,wPopisek,0,dify,0,0); - MoveWindowRel(dwp,wFolder,0,dify,difx,0); - MoveWindowRel(dwp,wExport,difx,dify,0,0); - MoveWindowRel(dwp,wBrowse,difx,dify,0,0); - MoveWindowRel(dwp,wDDLFile,0,0,difx,0); - MoveWindowRel(dwp,wDDLBrowse,difx,0,0,0); - EndDeferWindowPos(dwp); - - } - _dlgSize.cx=cx; - _dlgSize.cy=cy; - } -} - - -void CDDLReaderDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI) -{ - CDialog::OnGetMinMaxInfo(lpMMI); - lpMMI->ptMinTrackSize.x=200; - lpMMI->ptMinTrackSize.y=150; - -} - -void CDDLReaderDlg::OnEnKillfocusDdlfile() -{ - CString name; - wDDLFile.GetWindowText(name); - if (_ddlfile.OpenDDLFile(WString(name.GetString()))==false) - AfxMessageBox(IDS_FILEOPENFAILED); - UpdateList(); -} - -static CString GetGroupName(int group) -{ - int id; - switch (group) - { - case 1: id= IDC_GROUP_GRAPHICS;break; - case 2: id= IDC_GROUP_SOUNDS;break; - case 3: id= IDC_GROUP_FONTS;break; - case 7: id= IDC_GROUP_BASIC;break; - case 8: id= IDC_GROUP_ITEMS;break; - case 9: id= IDC_GROUP_MONSTERS;break; - case 11: id= IDC_GROUP_DIALOGS;break; - case 0: id=IDC_GROUP_UNSPECIFIED;break; - default: id=IDC_GROUP_UNKNOWN;break; - } - CString res; - res.Format(id,group); - return res; -} - -bool CDDLReaderDlg::File(WString name, int group, uint32_t offset) -{ - LVITEM item; - CString grpname=GetGroupName(group); - wchar_t buff[40]; - item.iItem=wFileList.GetItemCount(); - item.iSubItem=0; - item.mask=LVIF_GROUPID|LVIF_TEXT; - item.iGroupId=group; - item.pszText=grpname.LockBuffer(); - int ipos=wFileList.InsertItem(&item); - wFileList.SetItemText(ipos,1,name); - wFileList.SetItemText(ipos,3,_ui64tow(offset,buff,10)); - grpname.UnlockBuffer(); - return true; -} - -void CDDLReaderDlg::UpdateList(void) -{ - CString tmp; - wFileList.DeleteAllItems(); - _ddlfile.EnumFiles(*this); - for (int i=0,cnt=wFileList.GetItemCount();iGetItemText(lParam1,sinfo.index); - sinfo.right=sinfo.list->GetItemText(lParam2,sinfo.index); - switch (sinfo.index) - { - case 0: - case 1: res=wcsicmp(sinfo.left,sinfo.right);break; - case 3: { - int l=_wtoi(sinfo.left); - int r=_wtoi(sinfo.right); - res=(l>r)-(lGetItemText(lParam1,3); - sinfo.right=sinfo.list->GetItemText(lParam2,3); - uint32_t l=_wtoi(sinfo.left); - uint32_t r=_wtoi(sinfo.right); - l=sinfo._ddlfile->GetFileSize(l); - r=sinfo._ddlfile->GetFileSize(r); - res=(l>r)-(llParam2)-(lParam1(pNMHDR); - for (int i=0,cnt=wFileList.GetItemCount();iiSubItem; - sinfo.list=&wFileList; - sinfo._ddlfile=&_ddlfile; - wFileList.SortItems(SortItemsInFileList,(LPARAM)&sinfo); - *pResult = 0; -} - -static int WINAPI PosBrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lParam,LPARAM lpData) - { - const wchar_t *curpath=(const wchar_t *)lpData; - if (uMsg == BFFM_INITIALIZED) - { - if (curpath && curpath[0]) - { - ::SendMessage(hwnd,BFFM_SETSELECTION,TRUE,(LPARAM)((LPCSTR)curpath)); - ::SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)((LPCSTR)curpath)); - } - } - else if (uMsg == BFFM_SELCHANGED) - { - wchar_t buff[_MAX_PATH]; - if (SHGetPathFromIDList((LPITEMIDLIST)lParam,buff)) - { - ::SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)buff); - } - } - return 0; - }; - -static bool PathBrowser(HWND hWnd, wchar_t *path /* MAX_PATH size */) -{ - BROWSEINFO brw; - memset(&brw,0,sizeof(brw)); - brw.hwndOwner=hWnd; - brw.pidlRoot=NULL; - brw.pszDisplayName=path; - brw.lParam=(LPARAM)path; - brw.ulFlags= BIF_RETURNONLYFSDIRS |BIF_STATUSTEXT|BIF_USENEWUI ; - brw.lpfn = (BFFCALLBACK)(PosBrowseCallbackProc); - LPITEMIDLIST il=SHBrowseForFolder( &brw ); - if (il==NULL) return false; - SHGetPathFromIDList(il,path); - IMalloc *shmalloc; - SHGetMalloc(&shmalloc); - shmalloc->Free(il); - if (path[0]==0) return false; - return true; -} - - -void CDDLReaderDlg::OnBnClickedBrowse() -{ - wchar_t path[MAX_PATH]; - wFolder.GetWindowText(path,MAX_PATH); - if (PathBrowser(*this,path)) - { - wFolder.SetWindowText(path); - } -} - -void CDDLReaderDlg::OnBnClickedExport() -{ - wchar_t path[MAX_PATH]; - wFolder.GetWindowText(path,MAX_PATH); - if (path[0]==0) OnBnClickedBrowse(); - wFolder.GetWindowText(path,MAX_PATH); - if (path[0]==0) return; - WPathname fpath; - fpath.SetDirectory(path); - POSITION pos=wFileList.GetFirstSelectedItemPosition(); - int max=wFileList.GetSelectedCount(); - int cur=0; - DlgProgress pb; - if (max) {pb.Create(IDD_EXPORTING);pb.CenterWindow(this);EnableWindow(FALSE);} - while (pos) - { - MSG msg; - pb.wProgress.SetRange(0,max); - pb.wProgress.SetPos(++cur); - int i=wFileList.GetNextSelectedItem(pos); - CString fname; - uint32_t offset; - fname=wFileList.GetItemText(i,1); - offset=(uint32_t)_wtoi64(wFileList.GetItemText(i,3)); - pb.wDesc.SetWindowText(fname); - if (PeekMessage(&msg,0,0,0,PM_NOREMOVE)==TRUE) AfxPumpMessage(); - if (pb.stop) break; - DDLData data=_ddlfile.ExtractFile(offset); - if (data.data!=NULL) - { - fpath.SetFilename(fname); - HANDLE hFile=CreateFile(fpath,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL); - while (hFile==INVALID_HANDLE_VALUE) - { - CString msg; - AfxFormatString1(msg,IDS_UNABLETOCREATEFILE,fpath); - int retry=AfxMessageBox(msg,MB_ABORTRETRYIGNORE); - if (retry==IDABORT) {EnableWindow(TRUE);return;} - if (retry==IDIGNORE) break; - hFile=CreateFile(fpath,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL); - } - if (hFile!=INVALID_HANDLE_VALUE) - { - DWORD written; - WriteFile(hFile,data.data,data.sz,&written,NULL); - CloseHandle(hFile); - } - } - else - { - CString msg; - AfxFormatString1(msg,IDS_UNABLETOEXTACTDATA,fpath); - AfxMessageBox(msg,MB_OK|MB_ICONSTOP); - } - } - EnableWindow(TRUE); - - -} - -WPathname CDDLReaderDlg::CreateTemp(int index) -{ - if (!_lastTemp.IsNull()) DeleteFile(_lastTemp); - CString fname; - uint32_t offset; - fname=wFileList.GetItemText(index,1); - offset=(uint32_t)_wtoi64(wFileList.GetItemText(index,3)); - _lastTemp.SetTempDirectory(); - _lastTemp.SetFileTitle(WSC("SkeldalDDLReader")); - _lastTemp.SetExtension(WSC(".")+WString(fname)); - DDLData data=_ddlfile.ExtractFile(offset); - if (data.data) - { - HANDLE hFile=CreateFile(_lastTemp,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL); - DWORD written; - WriteFile(hFile,data.data,data.sz,&written,NULL); - CloseHandle(hFile); - } - return _lastTemp; -} - -void CDDLReaderDlg::OnNMDblclkFilelist(NMHDR *pNMHDR, LRESULT *pResult) -{ - // TODO: Add your control notification handler code here - *pResult = 0; - int index=wFileList.GetNextItem(-1,LVNI_FOCUSED); - WPathname pth=CreateTemp(index); - ShellExecute(*this,0,pth,0,0,SW_NORMAL); -} diff --git a/DDLReader/Projects/Skeldal/DDLReader/DDLReaderDlg.h b/DDLReader/Projects/Skeldal/DDLReader/DDLReaderDlg.h deleted file mode 100644 index 7faf316..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/DDLReaderDlg.h +++ /dev/null @@ -1,76 +0,0 @@ -// DDLReaderDlg.h : header file -// - -#include "t:\h\atlmfc\include\afxwin.h" -#include "ddlfile.h" -#include "WPathname.h" -#if !defined(AFX_DDLREADERDLG_H__E765355F_0112_4B3E_90CE_111E28FE8EC6__INCLUDED_) -#define AFX_DDLREADERDLG_H__E765355F_0112_4B3E_90CE_111E28FE8EC6__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -///////////////////////////////////////////////////////////////////////////// -// CDDLReaderDlg dialog - -class CDDLReaderDlg : public CDialog, public IDDLFileEnumerator -{ -// Construction - CSize _dlgSize; - WPathname _lastTemp; -public: - CDDLReaderDlg(CWnd* pParent = NULL); // standard constructor - ~CDDLReaderDlg(); - -// Dialog Data - //{{AFX_DATA(CDDLReaderDlg) - enum { IDD = IDD_DDLREADER_DIALOG }; - CEdit wFolder; - CListCtrl wFileList; - CButton wBrowse; - CButton wExport; - CString vFolder; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDDLReaderDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - HICON m_hIcon; - - // Generated message map functions - //{{AFX_MSG(CDDLReaderDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnSysCommand(UINT nID, LPARAM lParam); - afx_msg void OnPaint(); - afx_msg HCURSOR OnQueryDragIcon(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -public: - afx_msg void OnSize(UINT nType, int cx, int cy); - CStatic wPopisek; - CEdit wDDLFile; - CButton wDDLBrowse; - afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI); - DDLFile _ddlfile; - afx_msg void OnEnKillfocusDdlfile(); - void UpdateList(void); - virtual bool File(WString name, int group, uint32_t offset); - afx_msg void OnBnClickedDdlbrowse(); - afx_msg void OnLvnColumnclickFilelist(NMHDR *pNMHDR, LRESULT *pResult); - afx_msg void OnBnClickedBrowse(); - afx_msg void OnBnClickedExport(); - afx_msg void OnNMDblclkFilelist(NMHDR *pNMHDR, LRESULT *pResult); - - WPathname CreateTemp(int index); -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DDLREADERDLG_H__E765355F_0112_4B3E_90CE_111E28FE8EC6__INCLUDED_) diff --git a/DDLReader/Projects/Skeldal/DDLReader/DlgProgress.cpp b/DDLReader/Projects/Skeldal/DDLReader/DlgProgress.cpp deleted file mode 100644 index cccfd60..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/DlgProgress.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// DlgProgress.cpp : implementation file -// - -#include "stdafx.h" -#include "DDLReader.h" -#include "DlgProgress.h" -#include ".\dlgprogress.h" - - -// DlgProgress dialog - -IMPLEMENT_DYNAMIC(DlgProgress, CDialog) -DlgProgress::DlgProgress(CWnd* pParent /*=NULL*/) - : CDialog(DlgProgress::IDD, pParent) -{ - stop=false; -} - -DlgProgress::~DlgProgress() -{ -} - -void DlgProgress::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - DDX_Control(pDX, IDC_PROGRESS, wProgress); - DDX_Control(pDX, IDC_NAME, wDesc); -} - - -BEGIN_MESSAGE_MAP(DlgProgress, CDialog) - ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1) -END_MESSAGE_MAP() - - -// DlgProgress message handlers - -void DlgProgress::OnBnClickedButton1() -{ - stop=true; -} diff --git a/DDLReader/Projects/Skeldal/DDLReader/DlgProgress.h b/DDLReader/Projects/Skeldal/DDLReader/DlgProgress.h deleted file mode 100644 index 8e6e3fb..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/DlgProgress.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include "t:\h\atlmfc\include\afxcmn.h" -#include "t:\h\atlmfc\include\afxwin.h" - - -// DlgProgress dialog - -class DlgProgress : public CDialog -{ - DECLARE_DYNAMIC(DlgProgress) - -public: - DlgProgress(CWnd* pParent = NULL); // standard constructor - virtual ~DlgProgress(); - -// Dialog Data - enum { IDD = IDD_EXPORTING }; - -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - - DECLARE_MESSAGE_MAP() -public: - CProgressCtrl wProgress; - CStatic wDesc; - afx_msg void OnBnClickedButton1(); - bool stop; -}; diff --git a/DDLReader/Projects/Skeldal/DDLReader/IWStringEffect.h b/DDLReader/Projects/Skeldal/DDLReader/IWStringEffect.h deleted file mode 100644 index 084f813..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/IWStringEffect.h +++ /dev/null @@ -1,36 +0,0 @@ -#if !defined(AFX_IWSTRINGEFFECT_H__863ADE82_7789_4E54_BE7D_B8F0740FD81B__INCLUDED_) -#define AFX_IWSTRINGEFFECT_H__863ADE82_7789_4E54_BE7D_B8F0740FD81B__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include - -class IWStringEffect -{ -public: - ///function returns extra size that effect needs - /** - @param curSize size of string that enters to the effect - @return count of extra characters needs to effects; - */ - virtual uint32_t GetEffectExtraSize(uint32_t curSize) {return 0;} - - ///function renders begin of string. - /** Function returns number of characters rendered, and must be <= then size returned by GetEffectExtraSize() - @param renderPtr pointer to render buffer - @param curSize size of string that enters to the effect - @return number of characters rendered. Entered string will be rendered behind. - */ - virtual uint32_t PreRenderString(wchar_t *renderPtr,uint32_t curSize) {return 0;} - - ///function renders effect. - /** - @param renderPtr pointer to begin of render buffer. - @param rendered number of characters rendered by previous effect. Value doesn't point to the end - of buffer, function must add result of PreRenderString */ - virtual void RenderString(wchar_t *renderPtr, uint32_t rendered)=0; -}; - -#endif diff --git a/DDLReader/Projects/Skeldal/DDLReader/StdAfx.cpp b/DDLReader/Projects/Skeldal/DDLReader/StdAfx.cpp deleted file mode 100644 index 1a90873..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/StdAfx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// DDLReader.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/DDLReader/Projects/Skeldal/DDLReader/StdAfx.h b/DDLReader/Projects/Skeldal/DDLReader/StdAfx.h deleted file mode 100644 index 666c5f5..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/StdAfx.h +++ /dev/null @@ -1,27 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__C5BDACC6_729E_4CA2_B27E_A1F209FB32A7__INCLUDED_) -#define AFX_STDAFX_H__C5BDACC6_729E_4CA2_B27E_A1F209FB32A7__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers - -#include // MFC core and standard components -#include // MFC extensions -#include // MFC support for Internet Explorer 4 Common Controls -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include "wstring.h" - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__C5BDACC6_729E_4CA2_B27E_A1F209FB32A7__INCLUDED_) diff --git a/DDLReader/Projects/Skeldal/DDLReader/WPathname.cpp b/DDLReader/Projects/Skeldal/DDLReader/WPathname.cpp deleted file mode 100644 index fab2f57..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/WPathname.cpp +++ /dev/null @@ -1,408 +0,0 @@ -// WPathname.cpp: implementation of the WPathname class. -// -////////////////////////////////////////////////////////////////////// - -#include "WPathname.h" -#include -#include - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -WPathname::WPathname(const wchar_t *name /*=NULL*/) -{ - if (name) SetPathname(name); -} - -WPathname::WPathname(const WString &name) -{ - SetPathname(name); -} - -WPathname::WPathname(const wchar_t *relpath, const WPathname &abspath) -{ - _fullpath=WString(relpath); - int chr=_fullpath.FindLast('\\'); - if (chr!=-1) - { - _path=_fullpath.Left(chr+1); - _filetitle=_fullpath.Right(chr+1); - } - else - { - _filetitle=_fullpath; - } - chr=_filetitle.FindLast('.'); - if (chr!=-1) - { - _extension=_filetitle.Right(chr); - _filetitle=_filetitle.Left(chr); - } - - RelativeToFull(abspath); -} - - -WPathname::WPathname(const WPathname &other) -{ - _fullpath=other._fullpath; - _path=other._path; - _filetitle=other._filetitle; - _extension=other._extension; -} - -void WPathname::SetDrive(wchar_t dr) -{ - if (HasDrive()) - { - if (dr==0) _path=_path.Right(2); - else _path[0]=dr; - } - else if (dr!=0) - { - int np=IsNetworkPath(); - wchar_t buff[2]; - buff[0]=dr; - buff[1]=':'; - buff[2]=0; - if (np) - _path=WString(buff)+_path.Right(np); - else - _path=WString(buff)+_path; - - } - RebuildPath(); -} - -void WPathname::SetDirectory(const wchar_t *dir) -{ - bool copydrv; //directory doesn't contain drive, need copy from original - bool addslash; //directory doesn't ending by backslash, need add it - - int len=wcslen(dir); - copydrv=HasDrive(dir) || !HasDrive(); //copy original drive, if exists and directory doesn't contaion drive - if (wcsncmp(dir,L"\\\\",2)==0) copydrv=true; //network path, don't copy drive - addslash=len && dir[len-1]!='\\'; //add slash - if (copydrv) - _path=WString(dir); - else - _path=_path.Left(2)+WString(dir); - if (addslash) - _path+=WSC("\\"); - - RebuildPath(); -} - -void WPathname::SetFilename(const wchar_t *filename) -{ - WString wfilename=WString(filename); - int dot=wfilename.FindLast('.'); - if (dot==-1) - { - _filetitle=wfilename; - _extension=0; - } - else - { - _filetitle=wfilename.Left(dot); - _extension=wfilename.Right(dot); - } - - RebuildPath(); -} - -void WPathname::SetExtension(const wchar_t *ext) -{ - _extension=WString(ext); - RebuildPath(); -} - -void WPathname::SetFileTitle(const wchar_t *title) -{ - _filetitle=WString(title); - RebuildPath(); -} - -void WPathname::SetPathname(const wchar_t *pathname) -{ - SetPathname(WString(pathname)); -} - -void WPathname::SetPathname(const WString &pathname) -{ - if (pathname.GetLength()==0) SetNull(); - else - { - wchar_t *part; - DWORD needsz=GetFullPathNameW(pathname,0,NULL,&part); - wchar_t *fpth=(wchar_t *)alloca(needsz*sizeof(*fpth)); - GetFullPathNameW(pathname,needsz,fpth,&part); - part=wcsrchr(fpth,'\\'); - if (part) part++;else part=NULL; - if (part) - { - SetFilename(part); - *part=0; - } - else - SetFilename(WString()); - SetDirectory(fpth); - } -} - -const wchar_t *WPathname::GetNameFromPath(const wchar_t *path) -{ - const wchar_t *c=wcsrchr(path,'\\'); - if (c!=NULL) c++;else return path; - return c; -} - -const wchar_t *WPathname::GetExtensionFromPath(const wchar_t *path) -{ - const wchar_t *fname=GetNameFromPath(path); - const wchar_t *c=wcsrchr(fname,'.'); - if (c==NULL) c=wcsrchr(path,0); - return c; -} - -void WPathname::RebuildPath() -{ - _fullpath=_path+_filetitle+_extension; -} - -bool WPathname::GetDirectoryWithDriveWLBS(wchar_t *buff, size_t size) const -{ - size_t psize=wcslen(GetDirectoryWithDrive()); - if (psize>size) return false; - if (psize==0) {buff[0]=0;return true;} - wcsncpy(buff,GetDirectoryWithDrive(),psize-1); - buff[psize-1]=0; - return true; -} - -WString WPathname::GetDirectoryWithDriveWLBS() const -{ - if (_path.GetLength()) return _path.Left(_path.GetLength()-1); - return WString(); -} - -bool WPathname::IsPathValid() const -{ - if (IsNull()) return false; - wchar_t *invalidChars=L"/*?\"<>|"; - const wchar_t *path=GetFullPath(); - if (*path==0) return false; - while (*path) - { - if (wcschr(invalidChars,*path)!=NULL) return false; - path++; - } - return true; -} - -bool WPathname::SetTempDirectory() -{ - wchar_t buff[1]; - DWORD size=GetTempPathW(1,buff); - if (size==0) return false; - WString pth; - wchar_t *p=pth.CreateBuffer(size); - if (GetTempPathW(size,p)==0) return false; - pth.UnlockBuffer(); - _path=pth; - return true; -} - -bool WPathname::SetDirectorySpecial(int nSpecCode) -{ - wchar_t buff[MAX_PATH]; - if (SHGetSpecialFolderPathW(GetForegroundWindow(),buff,nSpecCode,FALSE)!=NOERROR) return false; - SetDirectory(buff); - return true; -} - -bool WPathname::SetTempFile(const wchar_t *prefix, unsigned int unique) -{ - wchar_t tempname[MAX_PATH]; - if (GetTempFileNameW(GetDirectoryWithDrive(),prefix,unique,tempname)==0) return false; - this->SetPathname(tempname); - return true; -} - -WPathname WPathname::GetExePath() -{ - wchar_t buff[MAX_PATH*4]; - GetModuleFileNameW(NULL,buff,sizeof(buff)); - return WPathname(buff); -} - -const wchar_t *WPathname::FullToRelativeProjectRoot(const wchar_t *full, const wchar_t *projectRoot) -{ - const wchar_t *a=full,*b=projectRoot; - while (*a && towlower(*a)==towlower(*b)) {a++;b++;}; - if (*b) return full; - return a; -} - -bool WPathname::FullToRelative(const WPathname &relativeto) -{ - if (relativeto.IsNull() || IsNull()) return false; - bool h1=HasDrive(); - bool h2=relativeto.HasDrive(); - if (h1!=h2) return false; //rozdilny zpusob adresace - nelze vytvorit relatvni cestu - if (h1==true && h2==true && towupper(GetDrive())!=towupper(relativeto.GetDrive())) - return false; //ruzne disky, nelze vytvorit relativni cestu - if (wcsncmp(_path,L"\\\\",2)==0) //sitova cesta - { - int slsh=0; //citac lomitek - const wchar_t *a=_path; - const wchar_t *b=relativeto._path; - while (towupper(*a)==towupper(*b) && *a && slsh<3) //zacatek sitove cesty musi byt stejny - { - if (*a=='\\') slsh++; - a++;b++; - } - if (slsh!=3) return false; //pokud neni stejny, nelze vytvorit relativni cestu - } - int sublevel=0; - const wchar_t *ps1=_path; - const wchar_t *ps2=relativeto._path; - if (h1) {ps1+=2;ps2+=2;} - const wchar_t *sls=ps2; - while (towupper(*ps1)==towupper(*ps2) && *ps1) - { - if (*ps2=='\\') sls=ps2+1; - ps1++;ps2++; - } - ps1-=ps2-sls; - if (sls) - { - while (sls=wcschr(sls,'\\')) - { - sls++; - sublevel++; - } - } - wchar_t *buff=(wchar_t *)alloca((sublevel*3+wcslen(ps1)+1)*sizeof(*buff)); - wchar_t *pos=buff; - for (int i=0;iref._path.GetString()) - { - end--; - while (end>ref._path.GetString() && end[-1]!='\\') end--; - } - beg+=3; - } - else - beg+=2; - } - int partln=end-ref._path; - wchar_t *buff=(wchar_t *)alloca((partln+wcslen(beg)+1)*sizeof(*buff)); - wcsncpy(buff,ref._path,partln); - wcscpy(buff+partln,beg); - SetDrive(0); - SetDirectory(buff); - return true; -} - -int WPathname::IsNetworkPath() const -{ - if (wcsncmp(_path,L"\\\\",2)==0) //sitova cesta - { - const wchar_t *p=_path+2; - const wchar_t *c=wcschr(p,'\\'); - if (c) return c-_path; - } - return 0; -} - -void WPathname::SetServerName(const wchar_t *server) -{ - if (HasDrive()) SetDrive(0); - else - { - int np=IsNetworkPath(); - _path=_path.Right(np); - } - - _path=WSC("\\\\")+WString(server)+WSC("\\"); - RebuildPath(); -} - -void WPathname::SetNull() -{ - _fullpath=_path=_filetitle=_extension=0; -} - -bool WPathname::GetPartFromPath(const wchar_t *path, int partnum, wchar_t *buff, int bufsize, int mode) -{ - const wchar_t *scan=path; - while (*scan=='\\') scan++; - while (partnum && *scan) - { - while (*scan!='\\' && *scan) scan++; - while (*scan=='\\') scan++; - partnum--; - } - if (*scan==0) - { - buff[0]=0; - return false; - } - int pt=0; - if (mode==-1) - { - pt=scan-path; - if (pt>bufsize) - { - buff[0]=0; - return true; - } - else - memcpy(buff,path,pt); - } - bool nlast=false; - while (*scan && (mode==1 || !nlast) && pt 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "WString.h" - -#ifndef ASSERT -#ifdef _DEBUG -#define ASSERT(x) assert(x) -#else -#define ASSERT(x) -#endif -#endif - -#define WPathnameCompare(op) bool operator op (const WPathname &other) const \ -{if (IsNull() || other.IsNull()) return false;else return wcsicmp(_fullpath,other._fullpath) op 0;}\ - bool operator op (const wchar_t *other) const \ -{ASSERT(!other || other[0]!=0);\ - if (IsNull() || other==NULL) return false;else return wcsicmp(_fullpath,other) op 0;} - -/** class WPathname simplifying manipulation with WPathnames, filenames, general paths, and -also supports convert from absolute path to relative respectively */ - - - -class WPathname -{ - ///object value and data - /**The implementation of WPathname creates only one buffer for all variables. It can - increase speed by effective memory use. Strings are stored one after another separated - by zero byte. Evry time any string changed, implementation recalculate buffer usage, and - decide, whether it should resize buffer or not. - - _fullpath also points to string contain full path with filename, - it is dominant value of the class - */ - WString _fullpath; - WString _path; /// - If name is provided, WPathname will expand it into full name with drive and folder name. - @param name optional argument to inicialize object - */ - WPathname(const wchar_t *name=NULL); - WPathname(const WString &name); - - ///Construct WPathname class - /** - @param relpath Relative path or uncomplette path or single filename with extension. - WPathname will expand this WPathname into full using absolute path provided by the second - argument. - @param abspath Absolute path used as reference to folder - the origin of relative path - provided in the first argument. - */ - WPathname(const wchar_t *relpath, const WPathname &abspath); - - ///Construct WPathname as copy of another WPathname - WPathname(const WPathname &other); - - - ///Function returns the current drive letter. - /** Before usage, ensure, that current WPathname contain drive. - In network path drive letter is missing. - In this case, result is undefined. To ensure, use HasDrive function - @return the drive letter of current path. - */ - wchar_t GetDrive() const - { - if (IsNull()) return 0; - return _path[0]; - } - - ///Static function determines, if argument contain a drive information. - /** - @param dir directory to inspect - @return true, if directory contain drive.

- This function is independed, it don't need any WPathname variable declared. - */ - static bool HasDrive(const wchar_t *dir) - {return (dir[0]>='A' && dir[0]<='Z' || dir[0]>='a' && dir[0]<='z') && dir[1]==':';} - - ///Function determines, if current WPathname contain a drive information - /** - @return true, if current WPathname contain a drive information - */ - bool HasDrive() const - { - if (IsNull()) return false; - return HasDrive(_path); - } - - - ///Function returns current folder name - /** - if current folder name contain drive, only folder name is returned (without drive). - In other cases (relative or network drives) returns full path. - @return folder name or full path. Pointer is valid until any first change in object. - Do not invoke release function at pointer! - */ - const wchar_t *GetDirectory() const - { - if (HasDrive()) return _path.GetString()+3; - else return _path.GetString()+IsNetworkPath(); - } - - const wchar_t *GetDirectoryWithDrive() const - { - return _path; - } - - ///Function returns current filename with extension - /** - @return current filename with extension. Pointer is valid until any first change in object. - Do not invoke release function at pointer! - */ - const wchar_t *GetFilename() const - { - if (IsNull()) return NULL; - const wchar_t *blk=wcsrchr(_fullpath,'\\'); - if (blk) blk=blk+1;else blk=_fullpath; - return blk; - } - - ///Function returns current extension (with starting dot) - /** - @return current extension. Pointer is valid until any first change in object. - Do not invoke release function at pointer! - */ - const wchar_t *GetExtension() const - {return _extension;} - - ///Function returns current filename without extension (without dot) - /** - @return current filename without extension (without dot). Pointer is valid until any first change in object. - Do not invoke release function at pointer! - */ - const wchar_t *GetTitle() const - {return _filetitle;} - - ///Function changes current drive. - /**If object contain WPathname with drive, then current drive is changed and function returns. - If object contain network path, then computer name is changed to the drive name. - If object contain relative path, then whole path is replaced by path on root on drive. - @param dr new drive letter. This parameter can be set to zero. It means, that current - driver is deleted, and path is converted to relative path from root. Note: Zero c - cannot be used with network paths and relative paths, and finnaly has no effect to the object - */ - - void SetDrive(wchar_t dr); - - ///Sets new directory for object - /** if object contain a drive letter and argument dir doesn't, then current drive is remain - and only directory part is replaced. If current path is network path or relative path, - then whole path is replaced by new one. - If argument dir contain drive letter, then whole path is replaced too. - @param dir contain new WPathname. Backslash should be the last wchar_tacter in string - */ - void SetDirectory(const wchar_t *dir); - - ///Sets new filename for object. - /** - If filename contain dot, function assumes, that filename is provided with extension. - Otherwise, current extension remains untouched. - @param filename new filename for object - */ - - void SetFilename(const wchar_t *filename); - - ///Sets new extension for object. - /** - If ext doesn't starting with dot, function adds it. - @param ext new extension for object - */ - void SetExtension(const wchar_t *ext); - - ///Sets new file title - /** Function changes file title, extension remains untouched. - if title contains extension (dot inside its name), this extension doesn't change - current extension. For example, if current extension is ".cpp" and filetitle contain - "source.h", then result is "source.h.cpp" - @param title a new title for object. - */ - - void SetFileTitle(const wchar_t *title); - - ///Function returns full WPathname. - /** - @return current WPathname. Pointer is valid until any first change in object. - Do not invoke release function at pointer! - */ - - const wchar_t *GetFullPath() const - {return _fullpath;} - - ///Sets WPathname - /** Function has same effect as constructor. But it can be used - anytime during object lifetime. It simply replaces current WPathname with newer. WPathname - in argument is expanded to full WPathname, current directory is used as reference. - @param WPathname new WPathname - */ - void SetPathname(const wchar_t *pathname); - void SetPathname(const WString &pathname); - - WPathname& operator=(const wchar_t *other) - {SetPathname(other);return *this;} - - WPathname& operator=(const WString &other) - {SetPathname(other);return *this;} - - WPathname& operator=(const WPathname& other) - { - _fullpath=other._fullpath; - _path=other._path; - _filetitle=other._filetitle; - _extension=other._extension; - return *this; - } - - ///converts object to string - operator const wchar_t *() const - {return GetFullPath();} - - ///Static function to help getting filename from WPathname - /** Function finds last backslash / and return pointer to first wchar_tacter after it. - Pointer stays valid until original path is destroyed or until original path is changed - @param path WPathname to inspect as string - @return pointer to filename - */ - static const wchar_t *GetNameFromPath(const wchar_t *path); - - ///Static function to help getting extension from WPathname - /** Function finds last dot '.' in filename return pointer to it (extension with dot). - Pointer stays valid until original path is destroyed or until original path is changed - @param path WPathname to inspect as string - @return pointer to extension - */ - static const wchar_t *GetExtensionFromPath(const wchar_t *path); - - ///Function sets server name for network path - /** If current path is network path, then changes server name to newer. Otherwise - it remove drive letter, and insert server name before remain path - @param server server name without slashes - */ - void SetServerName(const wchar_t *server); - - ///Function inspects current path and returns, whether contain server name - /**@return zero, if current path is not valid network path. Nonzero if path contain - server name. Then value returned count wchar_tacters containing server name with precedent - slashes. - */ - int IsNetworkPath() const; - - ///Function converts current relative path into absolute path - /** - If current path is not relative, function do nothing. - @param ref reference to path, against which path is relative. - @return true if path has been converted, or false, if conversion is impossible - */ - bool RelativeToFull(const WPathname &ref); - - ///Function converts current absolute path into relative path - /** - If current path is not relative, function do nothing. Both paths must be on the same - drive or network computer. - - @param ref reference to path, against which path should be relative. - @return true if path has been converted, or false, if conversion is impossible - */ - bool FullToRelative(const WPathname &relativeto); - - WPathname& operator+=(const wchar_t *relativePath) - {*this=WPathname(relativePath,*this);return *this;} - - WPathname operator+(const wchar_t *relativePath) - {WPathname out(relativePath,*this);return out;} - - bool IsNull() const {return _fullpath.GetLength()==0;} - - void SetNull(); - - WPathnameCompare(<) - WPathnameCompare(>) - WPathnameCompare(==) - WPathnameCompare(>=) - WPathnameCompare(<=) - WPathnameCompare(!=) - - - ///Function gets part of WPathname - /** - @param path subject of examine - @param partnum zero-base index of part of WPathname. Index 0 mostly contain drive or server, in case of - relative path, there is the name of the first folder or dots. - @param buff buffer for store result - @param bufsize count wchar_tacters in buffer; - @param mode mode=0, gets only name of part. - mode=1, get current part and remain parts of path. - mode=-1, gets all parts till current - @return Function returns true, if it was succesful, and it was not last part. Function returns - false, if it was succesful, and it was last part. Function returns false and sets buffer empty, - if an error occured. Function returns true and sets buffer empty, if buffer is too small to hold data - */ - static bool GetPartFromPath(const wchar_t *path, int partnum, wchar_t *buff, int bufsize, int mode=0); - - ///Function gets part of object - /** - @param partnum zero-base index of part of WPathname. Index 0 mostly contain drive or server, in case of - relative path, there is the name of the first folder or dots. - @param buff buffer for store result - @param bufsize count wchar_tacters in buffer; - @param mode mode=0, gets only name of part. - mode=1, get current part and remain parts of path. - mode=-1, gets all parts till current - @return Function returns true, if it was succesful, and it was not last part. Function returns - false, if it was succesful, and it was last part. Function returns false and sets buffer empty, - if an error occured. Function returns true and sets buffer empty, if buffer is too small to hold data - */ - bool GetPart(int partnum, wchar_t *buff, int bufsize,int mode=0) const - { - return GetPartFromPath(this->_fullpath,partnum,buff,bufsize,mode); - } - - /// Get Directory With Drive Without Last Back Slash - /** Retrieves into buffer directory with drive and removes last backslash - @param buff buffer that retrieves path - @param size size of buffer - @return true, if success, failed if buffer is too small*/ - - - bool GetDirectoryWithDriveWLBS(wchar_t *buff, size_t size) const; - - WString GetDirectoryWithDriveWLBS() const; - - - /// function checks, if path is valid and returns true, if does. - bool IsPathValid() const; - - /// Sets special directory. - /** - @param bSpecCode this value may be operation-system - depend. Windows implementation using CSIDL_XXXX constants, which is described in SHGetSpecialFolderLocation function - description - @return true, if function were successful - */ - bool SetDirectorySpecial(int nSpecCode); - - ///Sets temporaly directory. - bool SetTempDirectory(); - - ///Guess temporaly file name - /** - @param prefix prefix string for name - @param unique if unique is non-zero, it is used for new temporaly file. If unique is zero, function guess own unique - value. - @return true if function were successful - */ - bool SetTempFile(const wchar_t *prefix=L"tmp", unsigned int unique=NULL); - - ///Returns path of current executable. - /**It useful, when accessing folder, from when current module has been executed */ - static WPathname GetExePath(); - - ///Solves most used conversion from fullpath to path relative to project root - /** - @param full full WPathname with drive - @param projectRoot project root path - @return function returns pointer to full path, where starts relative part. If - fullpath doesn't contain project root path, it returns pointer to full. - @example FullToProjectRoot("x:\\project\\data\\example.txt","x:\\project"); //result is "data\\example.txt" - */ - - static const wchar_t *FullToRelativeProjectRoot(const wchar_t *full, const wchar_t *projectRoot); - - -protected: - ///Function only rebuild _fullpath string. - /** It doesn't check space for string! This function is used, when length of path is excepted - the same or smaller, then current. - */ - void RebuildPath(); - - -}; - - - -#endif // !defined(AFX_WPathname_H__158F59D5_B422_4FA6_86AC_10B5EC48C81B__INCLUDED_) diff --git a/DDLReader/Projects/Skeldal/DDLReader/WString.cpp b/DDLReader/Projects/Skeldal/DDLReader/WString.cpp deleted file mode 100644 index a485574..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/WString.cpp +++ /dev/null @@ -1,193 +0,0 @@ -// WString.cpp: implementation of the WString class. -// -////////////////////////////////////////////////////////////////////// - -#include "WString.h" -#include -#include - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -WString::WString(const char *sbstring, unsigned int codePage) -{ - if (sbstring==NULL || *sbstring==0) - { - _ref=NULL; - } - else - { - size_t reqBuff=MultiByteToWideChar(codePage,0,sbstring,-1,NULL,0); - - _ref=WStringMemory::AllocString(NULL,reqBuff); - _ref->AddRef(); - wchar_t *str=const_cast(_ref->GetStringFromMemBlock()); - - MultiByteToWideChar(codePage,0,sbstring,-1,str,reqBuff); - } -} - -int WString::FormatV(wchar_t *format, va_list lst) -{ - size_t curSize=4096; - int written; - do - { - _ref=WStringMemory::AllocString(NULL,curSize); - wchar_t *str=const_cast(_ref->GetStringFromMemBlock()); - written=_vsnwprintf(str,curSize,format,lst); - if (written<0) - { - curSize*=2; - WStringMemory::FreeProxy(_ref); - } - } - while (written<-1); - _ref->RecalcLength(); - _ref->AddRef(); - return written; -} - -int WString::Format(wchar_t *format, ...) -{ - va_list valst; - va_start(valst,format); - return FormatV(format,valst); -} - - -int WString::ScanStringV(const wchar_t *format, va_list lst) const -{ - uint32_t *ptr=(uint32_t *)lst; - return swscanf(GetString(),format,ptr[0],ptr[1],ptr[2],ptr[3],ptr[4],ptr[5],ptr[6],ptr[7],ptr[8],ptr[9], - ptr[10],ptr[11],ptr[12],ptr[13],ptr[14],ptr[15],ptr[16],ptr[17],ptr[18],ptr[19]); - -} - -int WString::ScanString(const wchar_t *format, ...) const -{ - va_list valst; - va_start(valst,format); - return ScanStringV(format,valst); -} - -bool WString::ReplaceOnce(const WString &findWhat,const WString &replaceWith) -{ - int pos=Find(findWhat); - if (pos==-1) return false; - (*this)=Left(pos)+replaceWith+Right(pos+replaceWith.GetLength()); - return true; -} - -bool WString::ReplaceAll(const WString &findWhat,const WString &replaceWith) -{ - WString process=*this; - WString result; - int pos; - bool processed=false; - while ((pos=process.Find(findWhat))!=-1) - { - result=result+process.Left(pos)+replaceWith; - process=process.Right(pos+findWhat.GetLength()); - processed=true; - } - *this=result+process; - return processed; -} - -WString WString::TrimLeft() const -{ - return TrimLeft(L" \r\n\t"); -} - -WString WString::TrimRight() const -{ - return TrimRight(L" \r\n\t"); -} - -WString WString::TrimLeft(wchar_t *trimChars) const -{ - const wchar_t *proStr=GetString(); - int p=0; - while (proStr[p] && wcschr(trimChars,proStr[p]!=NULL)) p++; - return Right(p); -} - -WString WString::TrimRight(wchar_t *trimChars) const -{ - const wchar_t *proStr=GetString(); - int p=GetLength()-1; - while (p>=0 && wcschr(trimChars,proStr[p]!=NULL)) p--; - return Left(p+1); -} - -WString WString::Upper() const -{ - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,WStringProxy::EfUpper))); -} - -WString WString::Lower() const -{ - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,WStringProxy::EfLower))); -} - -WString WString::Reverse() const -{ - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,WStringProxy::EfReverse))); -} - -WString WString::Effect(IWStringEffect *effect) const -{ - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,effect))); -} - -void WString::SetUTF7(const char *utf7) -{ - *this=WString(utf7,CP_UTF7); -} - -void WString::SetUTF8(const char *utf8) -{ - *this=WString(utf8,CP_UTF8); -} - -const char *WString::AsSBString(unsigned int codePage, WString &holder) -{ - const wchar_t *str=GetString(); - size_t reqsize=WideCharToMultiByte(codePage,0,str,-1,NULL,0,NULL,NULL); - WStringProxy *holderProxy=WStringMemory::AllocString(NULL,reqsize/2); //reqsize/2+(2 bytes) - char *mbstr=reinterpret_cast(const_cast(holderProxy->GetStringFromMemBlock())); - WideCharToMultiByte(codePage,0,str,-1,mbstr,reqsize,NULL,NULL); - holder=WString(holderProxy); - return mbstr; -} - -const char *WString::AsUTF7(WString &holder) -{ - return AsSBString(CP_UTF7,holder); -} - -const char *WString::AsUTF8(WString &holder) -{ - return AsSBString(CP_UTF8,holder); -} - -void WString::ReadFromStream(size_t (*streamReader)(wchar_t *buffer, size_t bufferLen, void *context),void *context) -{ - _ref->Release(); - _ref=NULL; - wchar_t buff[256]; - size_t rd; - while ((rd=streamReader(buff,sizeof(buff)/sizeof(wchar_t),context))!=0) - { - *this=*this+WString(buff,rd); - } -} - -const WString WStringConst(const wchar_t *text) -{ - return WString(WStringMemory::AllocProxy(WStringProxy(text))); -} - diff --git a/DDLReader/Projects/Skeldal/DDLReader/WString.h b/DDLReader/Projects/Skeldal/DDLReader/WString.h deleted file mode 100644 index a244adb..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/WString.h +++ /dev/null @@ -1,496 +0,0 @@ -// WString.h: interface for the WString class. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_WSTRING_H__481164FB_3BB7_4824_B0E3_8B371F0AAF3A__INCLUDED_) -#define AFX_WSTRING_H__481164FB_3BB7_4824_B0E3_8B371F0AAF3A__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "WStringProxy.h" -#include - -class WString -{ - mutable WStringProxy *_ref; - - - -public: - ///constructs empty string - WString():_ref(0) {} - - ///constructs string. - explicit WString(const wchar_t *string):_ref(string==NULL?NULL:WStringMemory::AllocString(string,0)) {_ref->AddRef();}; - - ///constructs string from wide-char array with specified length - WString(const wchar_t *string, size_t sz):_ref(WStringMemory::AllocString(string,sz)) {_ref->AddRef();}; - - ///copy constructor - /**constructor doesn't copy the string, only reference. - String is shared until it is changed - */ - WString(const WString &other):_ref(other._ref) {_ref->AddRef();} - - ///constructs string from multi-byte string. codePage specified code page of string - WString(const char *sbstring, unsigned int codePage); - - ///constructs string from string-proxy. Used internally with WStringMemory::AllocXXX functions - WString(WStringProxy *proxy):_ref(proxy) {_ref->AddRef();} - - ///assignment operator - /** assignment operator doesn't copy the string only reference. - String is shared until it is changed */ - WString &operator=(const WString &other) - {other._ref->AddRef();_ref->Release();_ref=other._ref;return *this;} - - ///Destructor - releases reference - ~WString() {_ref->Release();} - - ///function converts instance of WString to wchar_t pointer - /** - Function will perform RenderString, if it is needed. - */ - const wchar_t *GetString() const - { - if (_ref==NULL) return L""; - WStringProxy *str=_ref->RenderString(); - if (_ref!=str) - { - str->AddRef();_ref->Release();_ref=str; - } - return _ref->GetStringFromMemBlock(); - } - - ///operator can convert WString to wchar_t pointer anytime - operator const wchar_t *() const {return GetString();} - - ///function returns count of characters in string - /** function doesn't need to render string, so it can be called anytime - without loosing the benefit of "pseudo-strings" boosting */ - size_t GetLength() const - { - if (_ref) return _ref->GetLength(); - else return 0; - } - - ///function creates string as sum of this and another string - /** function creates "pseudo-string" that represents sum of two string. - pseudo-string is rendered to "real-string" automatically, when it is needed */ - WString operator+(const WString other) const - { - if (_ref==NULL) return other; - if (other._ref==NULL) return *this; - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,other._ref))); - } - - WString &operator+=(const WString other) - { - *this=*this+other; - return *this; - } - - ///function creates string as substring of another string - /** function creates "pseudo-string" that represents substring of anothers string. - Pseudo-string is rendered to "real-string" automatically, when it is needed */ - WString Mid(size_t begin, size_t len) const - { - if (begin==0) return Left(len); - if (_ref==NULL || begin>GetLength()) return WString(); - if (begin+len>GetLength()) return Right(begin); - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,begin,len))); - } - - WString Left(size_t len) const - { - if (_ref==NULL) return WString(); - if (len>=GetLength()) return *this; - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,0,len))); - } - - WString Right(size_t begin) const - { - if (_ref==NULL || begin>GetLength()) return WString(); - if (begin==0) return *this; - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,begin,GetLength()-begin))); - } - - WString RightR(size_t count) const - { - if (_ref==NULL || count==0) return WString(); - if (count>=GetLength()) return *this; - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,GetLength()-count,count))); - } - - WString Delete(size_t begin, size_t count) const - { - if (_ref==NULL) return WString(); - if (begin==0) return Right(count); - if (begin+count>=GetLength()) return Left(begin); - return WString(WStringMemory::AllocProxy(WStringProxy(Left(begin)._ref,Right(begin+count)._ref))); - } - - WString Insert(const WString &what, size_t index) const - { - if (_ref==NULL) return what; - if (index==0) return what+*this; - if (index>=GetLength()) return *this+what; - return Left(index)+what+Right(index); - } - - /// function allows to access any char in string - wchar_t operator[](int index) const - { - assert(index<=(int)GetLength() && index>=0); - return GetString()[index]; - } - - /// functions allows lock string for accesing it directly. - /** Function returns pointer to buffer which holds string. - Buffer size is equal to string length plus terminating zero. - Application can modify content of buffer. - If string is shared with another WString object, LockBuffer - creates copy of string - Do not forger to call UnlockBuffer, when you finish modifiing the content - */ - wchar_t *LockBuffer() - { - if (_ref==NULL) return NULL; - GetString(); - WStringMemory::LockProxy(_ref); - if (_ref->IsShared()) - { - WStringMemory::UnlockProxy(_ref); - _ref->Release(); - _ref=WStringMemory::AllocString(_ref->GetStringFromMemBlock(),0); - _ref->AddRef(); - WStringMemory::LockProxy(_ref); - } - return const_cast(_ref->GetStringFromMemBlock()); - } - - /// Function creates buffer for string and returns its address - /** Application can use buffer in functions, that cannot work with - WString objects. Size of buffer is specified by sz value, and it is in characters. - Application must call UnlockBuffer after writes all data into buffer. - - NOTE: Prevoius content of string is lost. - NOTE: sz specifies buffer size without terminating zero character - */ - wchar_t *CreateBuffer(size_t sz) - { - _ref->Release(); - _ref=WStringMemory::AllocString(NULL,sz); - _ref->AddRef(); - WStringMemory::LockProxy(_ref); - return const_cast(_ref->GetStringFromMemBlock()); - } - - /// Function creates buffer, and copies string into it. - /** Parameter sz specifies size of new buffer in characters - When sz is smaller then size of string, string is truncated - When sz is larger then size of string, string is copied unchanged, - but extra characters can be appended. - - NOTE: sz specifies buffer size without terminating zero character - */ - wchar_t *CreateBufferCopy(size_t sz) - { - WString save=*this; - wchar_t *wbuff=CreateBuffer(sz); - int minsz=__min(sz,save.GetLength()); - wcsncpy(wbuff,save.GetString(),minsz); - return wbuff; - } - - /// Function unlocks internal buffer - /** parameter sz specifies final lenght of string in buffer. Default - value -1 forces function calc size by own - */ - void UnlockBuffer(int sz=-1) - { - if (_ref==NULL) return; - wchar_t *wbuff=const_cast(_ref->GetStringFromMemBlock()); - if (sz<0) sz=wcslen(wbuff); - else wbuff[sz]=0; - if (sz!=(signed)_ref->GetLength()) - { - _ref->RecalcLength(); - WStringMemory::UnlockProxy(_ref); - } - } - - class WStringAtCharHelper - { - WString &_str; - size_t _index; - public: - WStringAtCharHelper(WString &str,size_t index):_str(str),_index(index) {} - WString &operator=(wchar_t z) - { - wchar_t *buff=_str.LockBuffer(); - assert(buff && _index<_str.GetLength()); - buff[_index]=z; - _str.UnlockBuffer(); - return _str; - } - operator wchar_t() - { - assert(_index<_str.GetLength()); - return ((const wchar_t *)_str)[_index]; - } - }; - - /// Function will return helper object, which can access single character in string - /** - Using array operator is slower than accessing characters by LockBuffer function - */ - WStringAtCharHelper operator[](int index) - { - return WStringAtCharHelper(*this,index); - } - - int Find(wchar_t z,size_t from=0) const - { - if (from>=GetLength()) return -1; - const wchar_t *res=wcschr(GetString()+from,z); - if (res) return res-GetString(); - else return -1; - } - - int FindLast(wchar_t z) const - { - const wchar_t *res=wcsrchr(GetString(),z); - if (res) return res-GetString(); - else return -1; - } - - int Find(const wchar_t *z,size_t from=0) const - { - if (z==NULL) return -1; - if (from>=GetLength()) return -1; - const wchar_t *res=wcsstr(GetString()+from,z); - if (res) return res-GetString(); - else return -1; - } - - int FormatV(wchar_t *format, va_list lst); - - int Format(wchar_t *format, ...); - - ///Scans string for format - /** function is limited, item count is limited up to 20 items */ - int ScanStringV(const wchar_t *format, va_list lst) const; - - ///Scans string for format - /** function is limited, item count is limited up to 20 items */ - int ScanString(const wchar_t *format, ...) const; - - bool ReplaceOnce(const WString &findWhat,const WString &replaceWith); - - bool ReplaceAll(const WString &findWhat,const WString &replaceWith); - - WString TrimLeft() const; - - WString TrimRight() const; - - WString TrimLeft(wchar_t *trimChars) const; - - WString TrimRight(wchar_t *trimChars) const; - - ///Function splits string into two - /** Left part of string is returned. - Right part of string is leaved in object - @param splitPos split position. - @return if splitPos==0, function returns empty string. if splitPos>=length, function - moves string from object to result*/ - WString Split(size_t splitPos) - { - WString result=Left(splitPos); - *this=Right(splitPos); - return result; - } - - bool IsEmpty() const {return _ref==NULL;} - - void Empty() const {_ref->Release();_ref=NULL;} - - int Compare(const wchar_t *other) const - { - return wcscmp(*this,other); - } - - bool operator>(const WString &other) const {return Compare(other)>0;} - bool operator<(const WString &other) const {return Compare(other)<0;} - bool operator>=(const WString &other) const {return Compare(other)>=0;} - bool operator<=(const WString &other) const {return Compare(other)<=0;} - bool operator!=(const WString &other) const {return Compare(other)<=0;} - bool operator==(const WString &other) const {return Compare(other)<=0;} - - WString Upper() const; - WString Lower() const; - WString Reverse() const; - - ///Applies user effect on string - /** pointer should be static allocated object, or must be valid during lifetime of resulting string */ - WString Effect(IWStringEffect *effect) const; - - void SetUTF7(const char *utf7); - void SetUTF8(const char *utf8); - - ///Function converts string to SingleByte string - /** - @param codePage Platform depends code page of result - @param holder Object that holds result. Result pointer is valid during lifetime of holder. Once holder - released, pointer is invalidated. You can get resulting pointer anytime from holder reintepreting - wchar_t to char - @result pointer to string - */ - const char *AsSBString(unsigned int codePage, WString &holder); - - ///Returns multibyte string in UTF7 codepage - /**See AsSBString description*/ - const char *AsUTF7(WString &holder); - - ///Returns multibyte string in UTF7 codepage - /**See AsSBString description*/ - const char *AsUTF8(WString &holder); - - - ///Function reads string from stream - /** - Function calls streamReader repeatly until function returns zero. In each call, streamReader returns - number of characters, that has been readed. - @param sreamReader pointer to function which provides reading from a stream - @param context user defined context pointer (most in cases, pointer to stream is passed) - @param buffer space allocated for data readed from stream - @param bufferLen maximum count of characters can be written to buffer - @return streamReader returns number of characters, that has been written to buffer. Function must return zero - to stop reading - */ - void ReadFromStream(size_t (*streamReader)(wchar_t *buffer, size_t bufferLen, void *context),void *context); - - WString operator() (int from) const {return from<0?RightR(-from):Right(from);} - WString operator() (int from, int to) const - { - if (from>=0) - return to<0?Mid(from,-to):Mid(from,to-from); - else - return to<0?Mid(GetLength()+from,-to):Mid(GetLength()+from,GetLength()-from-to); - } - - ///Enables global string sharing. - /** Function Share allows share strings that contains same text. It can reduce memory - usage. Function is useful when there is many objects that contains string with same text. - - Basically, two strings is shared, if one string is created as copy of another string. Strings - is sharing they content, until one of them is modified. - - Calling Share function, string is registered for global sharing. If string with same content is already - registered, then content of current string is released, and string is shared. - - To successfully share two strings, both strings must call Share() function. Sharing is provided until one - of strings is modified. After modifications are done, Share function of modified string must be called again. - - Remember: Global sharing can reduce amount of memory, if there are multiple strings that containging - the same content. But sharing of each unique string takes small piece of memory to store sharing - informations. - - To share string automatically, use WSharedString class - WSC strings cannot be shared! - */ - void Share() const - { - WStringProxy *curref=_ref; - GetString(); - _ref=WStringMemory::ShareString(curref); - _ref->AddRef(); - curref->Release(); - } - - ///Disables global string sharing - /** Function unregisters string from global sharing database. If string is shared, function doesn't break - it. But all strings that currently sharing content will not be shared with newly created strings. - */ - void Unshare() - { - WStringMemory::UnshareString(_ref); - } -}; - -///Function will create constant WString -/** function will not copy content of string. Only creates reference to string - Using WStringConst is faster for strings in code -@exmple result=a+WStringConst(L"text")+b; -*/ -const WString WStringConst(const wchar_t *text); - -///Macro to easy convert incode string to WString -/** -function also marks text wide. -@example WString text=WSC("Hello world"); -*/ -#define WSC(x) WStringConst(L##x) -///Macro to easy convert any wchar_t buffer to constant WString -/** -IMPORTANT NOTE!: Buffer must exists until string is rendered. -If you are using WSCB in function, don't forget call GetString before function exits -If you are excepting additional string operations outside function, using standard -WString conversion can be more effecient. -*/ -#define WSCB(x) WStringConst(x) - - - -class WSharedString: public WString -{ -public: - WSharedString() {} - - ///constructs string. - explicit WSharedString(const wchar_t *string):WString(string) {Share();} - - ///constructs string from wide-char array with specified length - WSharedString(const wchar_t *string, size_t sz):WString(string,sz) {Share();}; - - ///copy constructor - /**constructor doesn't copy the string, only reference. - String is shared until it is changed - */ - WSharedString(const WSharedString &other):WString(other) {} - WSharedString(const WString &other):WString(other) {Share();} - - ///constructs string from multi-byte string. codePage specified code page of string - WSharedString(const char *sbstring, unsigned int codePage):WString(sbstring,codePage) {Share();} - - ///assignment operator - /** assignment operator doesn't copy the string only reference. - String is shared until it is changed */ - WSharedString &operator=(const WString &other) - {WString::operator =(other);Share();return *this;} - - const wchar_t *GetString() const - { - const wchar_t *res=WString::GetString(); - Share(); - return res; - } - operator const wchar_t *() const {return GetString();} - wchar_t operator[](int index) const - { - assert(index<=(int)GetLength() && index>=0); - return GetString()[index]; - } - - void UnlockBuffer(int sz=-1) - { - WString::UnlockBuffer(sz); - Share(); - } - -}; - - -#endif // !defined(AFX_WSTRING_H__481164FB_3BB7_4824_B0E3_8B371F0AAF3A__INCLUDED_) diff --git a/DDLReader/Projects/Skeldal/DDLReader/WStringMemory.cpp b/DDLReader/Projects/Skeldal/DDLReader/WStringMemory.cpp deleted file mode 100644 index 947ed02..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/WStringMemory.cpp +++ /dev/null @@ -1,397 +0,0 @@ -// WStringMemorySingleThread.cpp: implementation of the WStringMemory class. -// -////////////////////////////////////////////////////////////////////// - -#include -#include -#include "WStringMemory.h" -#include "WStringProxy.h" -#include -#include -#include - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -#ifdef _MT //multithreading -#define WSTRING_MT -#endif - -#ifdef WSTRING_MT //multithreading - - -struct WStringMTLock -{ - WStringProxy *_lockProxy; - LONG _recursionCount; - DWORD _owner; - HANDLE _event; - WStringMTLock(WStringProxy *x):_lockProxy(x) {} - WStringMTLock():_lockProxy(NULL) {} - - bool operator==(const WStringMTLock &other) const {return _lockProxy==other._lockProxy;} - bool operator!=(const WStringMTLock &other) const {return _lockProxy!=other._lockProxy;} - bool operator>=(const WStringMTLock &other) const {return _lockProxy>=other._lockProxy;} - bool operator<=(const WStringMTLock &other) const {return _lockProxy<=other._lockProxy;} - bool operator>(const WStringMTLock &other) const {return _lockProxy>other._lockProxy;} - bool operator<(const WStringMTLock &other) const {return _lockProxy *GLockDB=NULL; //Lock proxy database - -static void exitMT() -{ - DeleteCriticalSection(&GLocker); -} - - -static void OnStartup() -{ - InitializeCriticalSection(&GLocker); - atexit(exitMT); -} - -#define ON_STARTUP_PRIORITY_NORMAL OnStartup -#include - -#endif - - - -#define WS_MAXFREELISTS 32 -#define WS_FREELISTSTEP 32 -#define WS_TOTALMAXFREEKBYTES 256 - -#define WS_MAXIMUMFASTALLOC (WS_MAXFREELISTS*WS_FREELISTSTEP) - -#define WS_MAXFREEBYTES PerSlotMaxAlloc - - -static size_t PerSlotMaxAlloc=(WS_TOTALMAXFREEKBYTES*1024/WS_MAXFREELISTS); -static WStringProxy *FreeList=NULL; -static void **StringFreeList[WS_MAXFREELISTS]; -static size_t StringFreeBytes[WS_MAXFREELISTS]; -static bool InitManager=true; - - -static void InitManagerPointers() -{ - memset(StringFreeList,0,sizeof(StringFreeList)); - memset(StringFreeBytes,0,sizeof(StringFreeBytes)); - InitManager=false; -} - -static void *AllocStringBlock(size_t sz) -{ - if (InitManager) InitManagerPointers(); - if (sz>WS_MAXIMUMFASTALLOC) return malloc(sz); - int pos=(sz+WS_FREELISTSTEP-1)/WS_FREELISTSTEP; - void **nxt=StringFreeList[pos]; - if (nxt==0) - { - printf("malloc %d\n",pos*WS_FREELISTSTEP); - return malloc(pos*WS_FREELISTSTEP); - } - printf("fast_alloc %d\n",pos*WS_FREELISTSTEP); - StringFreeList[pos]=(void **)(*nxt); - StringFreeBytes[pos]-=_msize(nxt); - return nxt; -} - -static void DeallocStringBlock(void *ptr) -{ - size_t sz=_msize(ptr); - if (sz>WS_MAXIMUMFASTALLOC) {free(ptr);return;} - int pos=(sz+WS_FREELISTSTEP-1)/WS_FREELISTSTEP; - if (sz+StringFreeBytes[pos]>WS_MAXFREEBYTES) - { - printf("free %d\n",sz); - free(ptr);return; - } - void **proxy=(void **)ptr; - *proxy=(void *)StringFreeList[pos]; - StringFreeList[pos]=proxy; - StringFreeBytes[pos]+=sz; - printf("fast_free %d\n",sz); -} - - -static inline void *operator new(size_t alloc,size_t sz) -{ - return AllocStringBlock(sz+alloc); -} - -static inline void operator delete(void *p,size_t alloc) -{ - DeallocStringBlock(p); -} - -static inline void *operator new(size_t sz,void *ptr) -{ - return ptr; -} - -static inline void operator delete(void *ptr,void *p) -{ -} - -WStringProxy * WStringMemory::AllocString(const wchar_t *text, size_t size) -{ -#ifdef WSTRING_MT - EnterCriticalSection(&GLocker); -#endif - assert(size!=0 || text!=0); - if (size==0) size=wcslen(text); - WStringProxy *proxy=new((size+1)*sizeof(wchar_t)) WStringProxy(size,0,0); - wchar_t *alloctext=const_cast(proxy->GetStringFromMemBlock()); - if (text) wcsncpy(alloctext,text,size); - alloctext[size]=0; - if (proxy->_redirect==0) - { - proxy->_redirect=alloctext; - proxy->_blockData2=1; - } -#ifdef WSTRING_MT - LeaveCriticalSection(&GLocker); -#endif - return proxy; -} - -WStringProxy * WStringMemory::AllocProxy(const WStringProxy &templateProxy) -{ - WStringProxy * res; -#ifdef WSTRING_MT - EnterCriticalSection(&GLocker); -#endif - if (FreeList==NULL) res=new WStringProxy(templateProxy); - else - { - WStringProxy *alloc=FreeList; - FreeList=alloc->_baseString; - res=new((void *)alloc) WStringProxy(templateProxy); - } -#ifdef WSTRING_MT - LeaveCriticalSection(&GLocker); -#endif - return res; -} - -void WStringMemory::FreeProxy(WStringProxy *proxy) -{ -#ifdef WSTRING_MT - EnterCriticalSection(&GLocker); -#endif - if (proxy->_operation==proxy->OpMemBlck && !(proxy->_blockData2==0 && proxy->_redirect!=NULL)) - { - if (proxy->_blockData2==2) UnshareString(proxy); - DeallocStringBlock(proxy); - } - else - { - proxy->~WStringProxy(); - proxy->_baseString=FreeList; - FreeList=proxy; - } -#ifdef WSTRING_MT - LeaveCriticalSection(&GLocker); -#endif -} - -#ifdef WSTRING_MT - -void WStringMemory::LockProxy( WStringProxy *proxy) -{ -nextTry: - EnterCriticalSection(&GLocker); - WStringMTLock srch(proxy),*found; - if (GLockDB==NULL) GLockDB=new BTree(16); - found=GLockDB->Find(srch); - if (found==NULL) - { - srch._event=NULL; - srch._owner=GetCurrentThreadId(); - srch._recursionCount=1; - GLockDB->Add(srch); - } - else - { - if (found->_owner!=GetCurrentThreadId()) - { - HANDLE w=found->_event; - if (w==0) {w=found->_event=CreateEvent(NULL,TRUE,FALSE,NULL);} - LeaveCriticalSection(&GLocker); //leave section - WaitForSingleObject(w,INFINITE); - goto nextTry; - } - else - { - found->_recursionCount++; - } - } - LeaveCriticalSection(&GLocker); //leave section -} - -void WStringMemory::UnlockProxy( WStringProxy *proxy) -{ - EnterCriticalSection(&GLocker); - WStringMTLock srch(proxy),*found; - found=GLockDB->Find(srch); - if (found) - { - if (--found->_recursionCount==0) - { - if (found->_event!=NULL) - { - SetEvent(found->_event); - CloseHandle(found->_event); - } - GLockDB->Remove(*found); - } - } - LeaveCriticalSection(&GLocker); -} - - -void WStringMemory::AddRefProxy(WStringProxy *proxy) -{ - InterlockedIncrement(reinterpret_cast(&proxy->_refCount)); -} - -bool WStringMemory::ReleaseRefProxy(WStringProxy *proxy) -{ - LONG res=InterlockedDecrement(reinterpret_cast(&proxy->_refCount)); - if (res<0) res=InterlockedIncrement(reinterpret_cast(&proxy->_refCount)); - return res==0; -} - -#else -void WStringMemory::LockProxy( WStringProxy *proxy) -{ - //not needed in single thread environment -} - -void WStringMemory::UnlockProxy( WStringProxy *proxy) -{ - //not needed in single thread environment -} - - -void WStringMemory::AddRefProxy(WStringProxy *proxy) -{ - //no special handling in single thread environment - ++proxy->_refCount; -} - -bool WStringMemory::ReleaseRefProxy(WStringProxy *proxy) -{ - //no special handling in single thread environment - if (proxy->_refCount) --proxy->_refCount; - return proxy->_refCount==0; -} - -#endif -void WStringMemory::FreeExtra() -{ -#ifdef WSTRING_MT - EnterCriticalSection(&GLocker); -#endif - while (FreeList) - { - void *proxy=FreeList; - FreeList=FreeList->_baseString; - free(proxy); - } - for (int i=0;i_redirect,other._str->_redirect); - } - - bool operator==(const ShareDBItem& other) const {return Compare(other)==0;} - bool operator>=(const ShareDBItem& other) const {return Compare(other)>=0;} - bool operator<=(const ShareDBItem& other) const {return Compare(other)<=0;} - bool operator!=(const ShareDBItem& other) const {return Compare(other)!=0;} - bool operator>(const ShareDBItem& other) const {return Compare(other)>0;} - bool operator<(const ShareDBItem& other) const {return Compare(other)<0;} -}; - -static BTree *GDB=NULL; - -WStringProxy *WStringMemory::ShareString(WStringProxy *proxy) -{ - if (proxy->_operation!=WStringProxy::OpMemBlck || proxy->_blockData2==0 || proxy->_blockData2==2) return proxy; - -#ifdef WSTRING_MT - EnterCriticalSection(&GLocker); -#endif - - if (GDB==NULL) GDB=new BTree; - - proxy->_blockData2=2; //block is subject of sharing - proxy->_redirect=proxy->GetStringFromMemBlock(); //setup pointer to string - ShareDBItem *found=GDB->Find(ShareDBItem(proxy)); - if (found) {proxy->_blockData2=1;proxy=found->_str;} - else GDB->Add(ShareDBItem(proxy)); -#ifdef WSTRING_MT - LeaveCriticalSection(&GLocker); -#endif - return proxy; -} - -void WStringMemory::UnshareString(WStringProxy *proxy) -{ - if (proxy->_operation!=WStringProxy::OpMemBlck || proxy->_blockData2!=2) return; - if (GDB==NULL) return; -#ifdef WSTRING_MT - EnterCriticalSection(&GLocker); -#endif - GDB->Remove(ShareDBItem(proxy)); - proxy->_blockData2=1; -#ifdef WSTRING_MT - LeaveCriticalSection(&GLocker); -#endif -} \ No newline at end of file diff --git a/DDLReader/Projects/Skeldal/DDLReader/WStringMemory.h b/DDLReader/Projects/Skeldal/DDLReader/WStringMemory.h deleted file mode 100644 index a81b08e..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/WStringMemory.h +++ /dev/null @@ -1,61 +0,0 @@ -// WStringMemory.h: interface for the WStringMemory class. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_WSTRINGMEMORY_H__79693029_4788_4099_9A97_92AF310A7AD5__INCLUDED_) -#define AFX_WSTRINGMEMORY_H__79693029_4788_4099_9A97_92AF310A7AD5__INCLUDED_ - -#include - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -class WStringProxy; - -class WStringMemory -{ -public: - - static WStringProxy * AllocString(const wchar_t *text, size_t size); - static WStringProxy * AllocProxy(const WStringProxy &templateProxy); - static void FreeProxy(WStringProxy *proxy); - static void LockProxy(WStringProxy *proxy); - static void UnlockProxy(WStringProxy *proxy); - - //Releases extra memory leaved for future fast allocations - static void FreeExtra(); - - //Support addref for proxy - Single- or Multi- thread support - static void AddRefProxy(WStringProxy *proxy); - - //Support addref for proxy - Single- or Multi- thread support - //returns true, when counter reached zero - static bool ReleaseRefProxy(WStringProxy *proxy); - - ///Gets statistics about memory manager - /** - @param details optional pointer to 32 size_t items. Array will be filled - with sizes of each string fastalloc group. - @return function returns total bytes allocated for string fast allocation. - (This number should be below 256KB) - */ - static size_t GetStatistics(size_t *details=NULL); - - ///Function allows sharing the strings - /** This function is called by WString::Share function - Function mark proxy shared. If string is same as shared, - it returns pointer to proxy with proxy of string that contains - the same text. - Read description of WString::Share for more informations - */ - static WStringProxy *ShareString(WStringProxy *proxy); - - ///Function disables sharing of the string - static void UnshareString(WStringProxy *proxy); - -}; - - - -#endif // !defined(AFX_WSTRINGMEMORY_H__79693029_4788_4099_9A97_92AF310A7AD5__INCLUDED_) diff --git a/DDLReader/Projects/Skeldal/DDLReader/WStringProxy.cpp b/DDLReader/Projects/Skeldal/DDLReader/WStringProxy.cpp deleted file mode 100644 index e98b577..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/WStringProxy.cpp +++ /dev/null @@ -1,185 +0,0 @@ -// WStringProxy.cpp: implementation of the WStringProxy class. -// -////////////////////////////////////////////////////////////////////// - - -#include "WStringProxy.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -/** Funkce vytvo�� transitivn� uz�v�r. -to znamen�, �e zru�� v�echny z�et�zen� redirecty. -*/ -WStringProxy *WStringProxy::TransitivniUzaver() -{ - if (_operation==OpSubstr && _offset==0 && _stringSize==_baseString->GetLength()) - { - WStringProxy *next=_baseString->TransitivniUzaver(); - if (next==NULL) return this; - next->AddRef(); - _baseString->Release(); - _baseString=next; - return next; - } - return NULL; -} - -/** Main render procedure -It creates allocates buffer proxy and renders tree into it -Then turns self into redirect proxy a redirect self into newly created string -Rerurns pointer to newly created proxy -*/ -WStringProxy *WStringProxy::RenderString() -{ - if (_operation==OpMemBlck) return this; - - WStringProxy *pp=TransitivniUzaver(); - if (pp!=NULL) return pp->_baseString->RenderString(); - - WStringProxy *newProxy=WStringMemory::AllocString(NULL,_stringSize); - wchar_t *renderPtr=const_cast(newProxy->GetStringFromMemBlock()); - - RenderStringToBuffer(renderPtr); - - newProxy->AddRef(); - this->~WStringProxy(); - _operation=OpSubstr; - _offset=0; - _baseString=newProxy; - - return newProxy; -} - -/** Function renders simple effect into buffer -Function needs buffer with nul terminated string -*/ -void WStringProxy::RenderSimpleEffect(wchar_t *renderPtr) -{ - assert(_operation==OpEffect); - switch (_effect) - { - case EfLower: wcslwr(renderPtr);break; - case EfUpper: wcsupr(renderPtr);break; - case EfReverse: wcsrev(renderPtr);break; - } - -} - -/** Light phase of rendering. Used to render string that is not -created from substring. This part is optimized for concat and user effects -When substring must be rendered, function call RenderStringToBufferSubstr to -render substring. -*/ -void WStringProxy::RenderStringToBuffer(wchar_t *renderPtr) -{ - WStringMemory::LockProxy(this); - switch (_operation) - { - case OpConcat: - _baseString->RenderStringToBuffer(renderPtr); - _secondString->RenderStringToBuffer(renderPtr+_baseString->GetLength()); - break; - case OpSubstr: - { - _baseString->RenderStringToBufferSubstr(renderPtr,_offset,GetLength()); - } - break; - case OpMemBlck: - { - const wchar_t *str=GetStringFromMemBlock(); - wcsncpy(renderPtr,str,_stringSize); - } - break; - case OpEffect: - { - uint32_t offset=0; - renderPtr[_stringSize]=0; //we can append zero, because right side of string is not yet rendered - //if this is end of string, one extra character for zero is also allocated. - //efect functions can rely on it. - if (_blockData2>=256) offset=_userEffect->PreRenderString(renderPtr,_baseString->GetLength()); //call prerender to prepare begin of buffer - _baseString->RenderStringToBuffer(renderPtr+offset); //render string to rest of buffer - if (_blockData2>=256) _userEffect->RenderString(renderPtr,_baseString->GetLength()); //apply effect to buffer - else RenderSimpleEffect(renderPtr); - } - break; - }; - WStringMemory::UnlockProxy(this); -} - -/** -Deep phase of rendering. Function can render substrings, or render substring of two -concated strings. Function can also perform partial effect on string. Function cannot -handle partial user effect, so this effects are converted to things strings. -*/ -void WStringProxy::RenderStringToBufferSubstr(wchar_t *renderPtr, size_t offset, size_t size) -{ - WStringMemory::LockProxy(this); - switch (_operation) - { - case OpConcat: - { - //process substring of concat - //count characters in buffer - size_t rendered; - //when string starts in left string - if (_baseString->GetLength()>offset) - { - //calculate total characters that may be rendered - rendered=_baseString->GetLength()-offset; - //but limit it to request size - if (rendered>size) rendered=size; - //render substring into buffer - _baseString->RenderStringToBufferSubstr(renderPtr,offset,rendered); - } - else - //no character has been rendered - rendered=0; - - //there is still characters remained to render. We will take it from second string - if (size-rendered>0) - { - if (offset>_baseString->GetLength()) offset-=_baseString->GetLength(); - else offset=0; - _secondString->RenderStringToBufferSubstr(renderPtr+rendered,offset,size-rendered); - } - } - break; - case OpSubstr: - { //rendering substrings is very easy - offset+=_offset; //add offset of substring - assert(offset+size<=GetLength()); //check length - //render substring - this->RenderStringToBufferSubstr(renderPtr,offset,size); - } - break; - case OpMemBlck: - { - //rendering from memory, final stop in recursion - //Get pointer string - const wchar_t *str=GetStringFromMemBlock(); - //copy substring from string into render buffer - wcsncpy(renderPtr,str+offset,size); - } - break; - case OpEffect: - if (_blockData2>=256) //interface cannot handle partial rendering - { - RenderString(); //convert proxy to simple redirect and render it - RenderStringToBufferSubstr(renderPtr,offset,size); //now we are able to cut out part - } - else - { - //all standard effects maps string 1:1 - //first get content of substring into buffer - _baseString->RenderStringToBufferSubstr(renderPtr,offset,size); - //we can append zero, because right side of string is not yet rendered - renderPtr[size]=0; - //process effect on target - RenderSimpleEffect(renderPtr); - } - break; - }; - WStringMemory::UnlockProxy(this); -} \ No newline at end of file diff --git a/DDLReader/Projects/Skeldal/DDLReader/WStringProxy.h b/DDLReader/Projects/Skeldal/DDLReader/WStringProxy.h deleted file mode 100644 index 0bf63ed..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/WStringProxy.h +++ /dev/null @@ -1,232 +0,0 @@ -// WStringProxy.h: interface for the WStringProxy class. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_WSTRINGPROXY_H__863ADE82_7789_4E54_BE7D_B8F0740FD81B__INCLUDED_) -#define AFX_WSTRINGPROXY_H__863ADE82_7789_4E54_BE7D_B8F0740FD81B__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "WStringMemory.h" -#include "IWStringEffect.h" -#include -#include -#include -#include - -/* -List of proxy types - -Memory_Proxy _operation=OpMemBlck - _blockData==0 and _blockData2==0 - or - _blockData!=0 and _blockData2!=0 - (_redirect - debug pointer) - (_blockData - 1) - -Proxy_Const _operation=OpMemBlck - _redirect - pointer to string - _blockData2=0 - -Proxy_Shared _operation=OpMemBlck - _redirect - pointer to string - _blockData2=2; - -Proxy_Immediate _operation=OpMemBlck - _blockData>0xFFFF - _blockData2>0xFFFF - both parameters are used by immediate memory manager - -Proxy_Concat _operation=OpConcat - _baseString and _secondString is valid - -Proxy_Link _operation=OpSubstr - _baseString is valid - _stringSize==_baseString->_stringSize - _offset==0; - NOTE: Can be used without rendering - -Proxy_RightSub _operation=OpSubstr - _baseString is valid - _offset<=_baseString->_stringSize - _stringSize==_baseString->_stringSize-_offset - NOTE: Can be used without rendering - -Proxy_SubString _operation=OpSubstr - _baseString is valid - _offset<=_baseString->_stringSize - _stringSize<=_baseString->_stringSize-_offset - -Proxy_Effect _operation=OpEffect - _baseString is valid - _stringSize=_baseString->_stringSize - _effect defining effect code < 0xFFFF - -Proxy_UserEffect _operation=OpEffect - _baseString is valid - _stringSize=_baseString->_stringSize - _effect>0xFFFF - _userEffect defining pointer to effect interface - -*/ -class WStringProxy -{ -public: - enum Operation - { - OpConcat=0, //proxy contains two links to concat it - OpSubstr=1, //proxy contains link to another proxy and specified substring - OpMemBlck=-2, //proxy contains informations about following string - OpEffect=-1, //proxy describing some efect with string - }; - - enum Effect - { - EfLower, //effect lower case - EfUpper, //effect upper case - EfReverse, //effect reverse string - }; -public: - - uint32_t _refCount; //reference count - uint32_t _stringSize:30; //string size in characters (maximum size 1073741823 characters ~ 2147483646 bytes) - Operation _operation:2; //operation with string or proxy type - - union - { - WStringProxy *_baseString; //pointer to next proxy referenced by this proxy - uint32_t _blockData; //user defined block data for OpMemBlock proxy type - const wchar_t *_redirect; //used for OpMemBlock, when _blockData2 is zero. - }; - - union - { - WStringProxy *_secondString; //pointer to second string for OpConcat - uint32_t _offset; //offset of substring for OpSubstr - Effect _effect; //effect selector for OpEffect - IWStringEffect *_userEffect; //user effect defined by IWStringEffect interface (valid when _effect is invalid) - uint32_t _blockData2; //user defined block data for OpMemBlock proxy type - exception: if this value is zero, member _redirect is valid - - }; - - - void RenderStringToBuffer(wchar_t *renderPtr); - void RenderStringToBufferSubstr(wchar_t *renderPtr, size_t offset, size_t size); - WStringProxy *TransitivniUzaver(); - void RenderSimpleEffect(wchar_t *renderPtr); - -public: - WStringProxy():_refCount(0),_operation(OpSubstr),_stringSize(0),_baseString(0),_secondString(0) {} //inicializes empty string proxy - - WStringProxy(WStringProxy *other): - _refCount(0), - _stringSize(other->GetLength()), - _baseString(other), - _operation(OpSubstr), - _offset(0) - {_baseString->AddRef();} - - WStringProxy(WStringProxy *other, uint32_t offset, uint32_t size): - _refCount(0), - _stringSize(size), - _baseString(other), - _operation(OpSubstr), - _offset(offset) - {_baseString->AddRef();} - - WStringProxy(WStringProxy *a, WStringProxy *b): - _refCount(0), - _stringSize(a->GetLength()+b->GetLength()), - _baseString(a), - _operation(OpConcat), - _secondString(b) - {_baseString->AddRef();_secondString->AddRef();} - - WStringProxy(WStringProxy *a, Effect effect): - _refCount(0), - _stringSize(a->GetLength()), - _baseString(a), - _operation(OpEffect), - _effect(effect) - {_baseString->AddRef();} - - WStringProxy(WStringProxy *a, IWStringEffect *userEffect): - _refCount(0), - _stringSize(a->GetLength()+userEffect->GetEffectExtraSize(a->GetLength())), - _baseString(a), - _operation(OpEffect), - _userEffect(userEffect) - {_baseString->AddRef();} - - WStringProxy(uint32_t size, uint32_t user1, uint32_t user2): - _refCount(0), - _stringSize(size), - _operation(OpMemBlck), - _blockData(user1), - _blockData2(user2) - {} - - WStringProxy(const wchar_t *imText): - _refCount(0), - _stringSize(wcslen(imText)), - _redirect(imText), - _blockData2(0), - _operation(OpMemBlck) - {} - - WStringProxy(const WStringProxy &other) - { - memcpy(this,&other,sizeof(*this)); - if (_operation!=OpMemBlck) _baseString->AddRef(); - if (_operation==OpConcat) _secondString->AddRef(); - } - - WStringProxy& operator=(const WStringProxy &other) - { - WStringProxy::~WStringProxy(); //call destructor to destruct current proxy - memcpy(this,&other,sizeof(*this)); //construct new proxy from template - if (_operation!=OpMemBlck) _baseString->AddRef(); - if (_operation==OpConcat) _secondString->AddRef(); - } - - WStringProxy *RenderString(); - - ~WStringProxy() - { - if (_operation!=OpMemBlck) _baseString->Release(); - if (_operation==OpConcat) _secondString->Release(); - } - - - uint32_t GetLength() {return _stringSize;} - void AddRef() {if (this) WStringMemory::AddRefProxy(this);} - void Release() {if (this) if (WStringMemory::ReleaseRefProxy(this)) WStringMemory::FreeProxy(this);} - - const wchar_t *GetString() - { - if (_operation==OpMemBlck) return (const wchar_t *)(this+1); - WStringProxy *p=RenderString(); - (*this)=*p; - return (const wchar_t *)(p+1); - } - - const wchar_t *GetStringFromMemBlock() - { - assert(_operation==OpMemBlck); - if (_blockData2==0 && _redirect!=NULL) return _redirect; - else return (const wchar_t *)(this+1); - } - - bool IsShared() {return _refCount>1;} - - void RecalcLength() - { - const wchar_t *str=GetStringFromMemBlock(); - _stringSize=wcslen(str); - } - -}; - -#endif // !defined(AFX_WSTRINGPROXY_H__863ADE82_7789_4E54_BE7D_B8F0740FD81B__INCLUDED_) diff --git a/DDLReader/Projects/Skeldal/DDLReader/res/DDLReader.ico b/DDLReader/Projects/Skeldal/DDLReader/res/DDLReader.ico deleted file mode 100644 index 7eef0bc..0000000 Binary files a/DDLReader/Projects/Skeldal/DDLReader/res/DDLReader.ico and /dev/null differ diff --git a/DDLReader/Projects/Skeldal/DDLReader/resource.h b/DDLReader/Projects/Skeldal/DDLReader/resource.h deleted file mode 100644 index 2625141..0000000 --- a/DDLReader/Projects/Skeldal/DDLReader/resource.h +++ /dev/null @@ -1,49 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by DDLReader.rc -// -#define IDM_ABOUTBOX 0x0010 -#define IDD_ABOUTBOX 100 -#define IDS_ABOUTBOX 101 -#define IDD_DDLREADER_DIALOG 102 -#define IDS_FILEOPENFAILED 102 -#define IDC_HEADGROUP 103 -#define IDC_HEADFNAME 104 -#define IDC_HEADSIZE 105 -#define IDC_HEADOFFSET 106 -#define IDS_DDLFILTER 107 -#define IDC_GROUP_GRAPHICS 108 -#define IDC_GROUP_SOUNDS 109 -#define IDC_GROUP_FONTS 110 -#define IDC_GROUP_BASIC 111 -#define IDC_GROUP_ITEMS 112 -#define IDC_GROUP_MONSTERS 113 -#define IDC_GROUP_DIALOGS 114 -#define IDC_GROUP_UNSPECIFIED 115 -#define IDC_GROUP_UNKNOWN 116 -#define IDS_UNABLETOCREATEFILE 117 -#define IDS_UNABLETOEXTACTDATA 118 -#define IDR_MAINFRAME 128 -#define IDD_PROGRESS 129 -#define IDD_EXPORTING 129 -#define IDC_FILELIST 1001 -#define IDC_FOLDER 1002 -#define IDC_BROWSE 1003 -#define IDC_EXPORT 1004 -#define IDC_POPISEK 1005 -#define IDC_DDLFILE 1006 -#define IDC_DDLBROWSE 1007 -#define IDC_PROGRESS 1008 -#define IDC_NAME 1009 -#define IDC_BUTTON1 1010 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 130 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1011 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/DDLReader/StdAfx.cpp b/DDLReader/StdAfx.cpp deleted file mode 100644 index 1a90873..0000000 --- a/DDLReader/StdAfx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// DDLReader.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/DDLReader/StdAfx.h b/DDLReader/StdAfx.h deleted file mode 100644 index 666c5f5..0000000 --- a/DDLReader/StdAfx.h +++ /dev/null @@ -1,27 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__C5BDACC6_729E_4CA2_B27E_A1F209FB32A7__INCLUDED_) -#define AFX_STDAFX_H__C5BDACC6_729E_4CA2_B27E_A1F209FB32A7__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers - -#include // MFC core and standard components -#include // MFC extensions -#include // MFC support for Internet Explorer 4 Common Controls -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include "wstring.h" - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__C5BDACC6_729E_4CA2_B27E_A1F209FB32A7__INCLUDED_) diff --git a/DDLReader/WPathname.cpp b/DDLReader/WPathname.cpp deleted file mode 100644 index fab2f57..0000000 --- a/DDLReader/WPathname.cpp +++ /dev/null @@ -1,408 +0,0 @@ -// WPathname.cpp: implementation of the WPathname class. -// -////////////////////////////////////////////////////////////////////// - -#include "WPathname.h" -#include -#include - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -WPathname::WPathname(const wchar_t *name /*=NULL*/) -{ - if (name) SetPathname(name); -} - -WPathname::WPathname(const WString &name) -{ - SetPathname(name); -} - -WPathname::WPathname(const wchar_t *relpath, const WPathname &abspath) -{ - _fullpath=WString(relpath); - int chr=_fullpath.FindLast('\\'); - if (chr!=-1) - { - _path=_fullpath.Left(chr+1); - _filetitle=_fullpath.Right(chr+1); - } - else - { - _filetitle=_fullpath; - } - chr=_filetitle.FindLast('.'); - if (chr!=-1) - { - _extension=_filetitle.Right(chr); - _filetitle=_filetitle.Left(chr); - } - - RelativeToFull(abspath); -} - - -WPathname::WPathname(const WPathname &other) -{ - _fullpath=other._fullpath; - _path=other._path; - _filetitle=other._filetitle; - _extension=other._extension; -} - -void WPathname::SetDrive(wchar_t dr) -{ - if (HasDrive()) - { - if (dr==0) _path=_path.Right(2); - else _path[0]=dr; - } - else if (dr!=0) - { - int np=IsNetworkPath(); - wchar_t buff[2]; - buff[0]=dr; - buff[1]=':'; - buff[2]=0; - if (np) - _path=WString(buff)+_path.Right(np); - else - _path=WString(buff)+_path; - - } - RebuildPath(); -} - -void WPathname::SetDirectory(const wchar_t *dir) -{ - bool copydrv; //directory doesn't contain drive, need copy from original - bool addslash; //directory doesn't ending by backslash, need add it - - int len=wcslen(dir); - copydrv=HasDrive(dir) || !HasDrive(); //copy original drive, if exists and directory doesn't contaion drive - if (wcsncmp(dir,L"\\\\",2)==0) copydrv=true; //network path, don't copy drive - addslash=len && dir[len-1]!='\\'; //add slash - if (copydrv) - _path=WString(dir); - else - _path=_path.Left(2)+WString(dir); - if (addslash) - _path+=WSC("\\"); - - RebuildPath(); -} - -void WPathname::SetFilename(const wchar_t *filename) -{ - WString wfilename=WString(filename); - int dot=wfilename.FindLast('.'); - if (dot==-1) - { - _filetitle=wfilename; - _extension=0; - } - else - { - _filetitle=wfilename.Left(dot); - _extension=wfilename.Right(dot); - } - - RebuildPath(); -} - -void WPathname::SetExtension(const wchar_t *ext) -{ - _extension=WString(ext); - RebuildPath(); -} - -void WPathname::SetFileTitle(const wchar_t *title) -{ - _filetitle=WString(title); - RebuildPath(); -} - -void WPathname::SetPathname(const wchar_t *pathname) -{ - SetPathname(WString(pathname)); -} - -void WPathname::SetPathname(const WString &pathname) -{ - if (pathname.GetLength()==0) SetNull(); - else - { - wchar_t *part; - DWORD needsz=GetFullPathNameW(pathname,0,NULL,&part); - wchar_t *fpth=(wchar_t *)alloca(needsz*sizeof(*fpth)); - GetFullPathNameW(pathname,needsz,fpth,&part); - part=wcsrchr(fpth,'\\'); - if (part) part++;else part=NULL; - if (part) - { - SetFilename(part); - *part=0; - } - else - SetFilename(WString()); - SetDirectory(fpth); - } -} - -const wchar_t *WPathname::GetNameFromPath(const wchar_t *path) -{ - const wchar_t *c=wcsrchr(path,'\\'); - if (c!=NULL) c++;else return path; - return c; -} - -const wchar_t *WPathname::GetExtensionFromPath(const wchar_t *path) -{ - const wchar_t *fname=GetNameFromPath(path); - const wchar_t *c=wcsrchr(fname,'.'); - if (c==NULL) c=wcsrchr(path,0); - return c; -} - -void WPathname::RebuildPath() -{ - _fullpath=_path+_filetitle+_extension; -} - -bool WPathname::GetDirectoryWithDriveWLBS(wchar_t *buff, size_t size) const -{ - size_t psize=wcslen(GetDirectoryWithDrive()); - if (psize>size) return false; - if (psize==0) {buff[0]=0;return true;} - wcsncpy(buff,GetDirectoryWithDrive(),psize-1); - buff[psize-1]=0; - return true; -} - -WString WPathname::GetDirectoryWithDriveWLBS() const -{ - if (_path.GetLength()) return _path.Left(_path.GetLength()-1); - return WString(); -} - -bool WPathname::IsPathValid() const -{ - if (IsNull()) return false; - wchar_t *invalidChars=L"/*?\"<>|"; - const wchar_t *path=GetFullPath(); - if (*path==0) return false; - while (*path) - { - if (wcschr(invalidChars,*path)!=NULL) return false; - path++; - } - return true; -} - -bool WPathname::SetTempDirectory() -{ - wchar_t buff[1]; - DWORD size=GetTempPathW(1,buff); - if (size==0) return false; - WString pth; - wchar_t *p=pth.CreateBuffer(size); - if (GetTempPathW(size,p)==0) return false; - pth.UnlockBuffer(); - _path=pth; - return true; -} - -bool WPathname::SetDirectorySpecial(int nSpecCode) -{ - wchar_t buff[MAX_PATH]; - if (SHGetSpecialFolderPathW(GetForegroundWindow(),buff,nSpecCode,FALSE)!=NOERROR) return false; - SetDirectory(buff); - return true; -} - -bool WPathname::SetTempFile(const wchar_t *prefix, unsigned int unique) -{ - wchar_t tempname[MAX_PATH]; - if (GetTempFileNameW(GetDirectoryWithDrive(),prefix,unique,tempname)==0) return false; - this->SetPathname(tempname); - return true; -} - -WPathname WPathname::GetExePath() -{ - wchar_t buff[MAX_PATH*4]; - GetModuleFileNameW(NULL,buff,sizeof(buff)); - return WPathname(buff); -} - -const wchar_t *WPathname::FullToRelativeProjectRoot(const wchar_t *full, const wchar_t *projectRoot) -{ - const wchar_t *a=full,*b=projectRoot; - while (*a && towlower(*a)==towlower(*b)) {a++;b++;}; - if (*b) return full; - return a; -} - -bool WPathname::FullToRelative(const WPathname &relativeto) -{ - if (relativeto.IsNull() || IsNull()) return false; - bool h1=HasDrive(); - bool h2=relativeto.HasDrive(); - if (h1!=h2) return false; //rozdilny zpusob adresace - nelze vytvorit relatvni cestu - if (h1==true && h2==true && towupper(GetDrive())!=towupper(relativeto.GetDrive())) - return false; //ruzne disky, nelze vytvorit relativni cestu - if (wcsncmp(_path,L"\\\\",2)==0) //sitova cesta - { - int slsh=0; //citac lomitek - const wchar_t *a=_path; - const wchar_t *b=relativeto._path; - while (towupper(*a)==towupper(*b) && *a && slsh<3) //zacatek sitove cesty musi byt stejny - { - if (*a=='\\') slsh++; - a++;b++; - } - if (slsh!=3) return false; //pokud neni stejny, nelze vytvorit relativni cestu - } - int sublevel=0; - const wchar_t *ps1=_path; - const wchar_t *ps2=relativeto._path; - if (h1) {ps1+=2;ps2+=2;} - const wchar_t *sls=ps2; - while (towupper(*ps1)==towupper(*ps2) && *ps1) - { - if (*ps2=='\\') sls=ps2+1; - ps1++;ps2++; - } - ps1-=ps2-sls; - if (sls) - { - while (sls=wcschr(sls,'\\')) - { - sls++; - sublevel++; - } - } - wchar_t *buff=(wchar_t *)alloca((sublevel*3+wcslen(ps1)+1)*sizeof(*buff)); - wchar_t *pos=buff; - for (int i=0;iref._path.GetString()) - { - end--; - while (end>ref._path.GetString() && end[-1]!='\\') end--; - } - beg+=3; - } - else - beg+=2; - } - int partln=end-ref._path; - wchar_t *buff=(wchar_t *)alloca((partln+wcslen(beg)+1)*sizeof(*buff)); - wcsncpy(buff,ref._path,partln); - wcscpy(buff+partln,beg); - SetDrive(0); - SetDirectory(buff); - return true; -} - -int WPathname::IsNetworkPath() const -{ - if (wcsncmp(_path,L"\\\\",2)==0) //sitova cesta - { - const wchar_t *p=_path+2; - const wchar_t *c=wcschr(p,'\\'); - if (c) return c-_path; - } - return 0; -} - -void WPathname::SetServerName(const wchar_t *server) -{ - if (HasDrive()) SetDrive(0); - else - { - int np=IsNetworkPath(); - _path=_path.Right(np); - } - - _path=WSC("\\\\")+WString(server)+WSC("\\"); - RebuildPath(); -} - -void WPathname::SetNull() -{ - _fullpath=_path=_filetitle=_extension=0; -} - -bool WPathname::GetPartFromPath(const wchar_t *path, int partnum, wchar_t *buff, int bufsize, int mode) -{ - const wchar_t *scan=path; - while (*scan=='\\') scan++; - while (partnum && *scan) - { - while (*scan!='\\' && *scan) scan++; - while (*scan=='\\') scan++; - partnum--; - } - if (*scan==0) - { - buff[0]=0; - return false; - } - int pt=0; - if (mode==-1) - { - pt=scan-path; - if (pt>bufsize) - { - buff[0]=0; - return true; - } - else - memcpy(buff,path,pt); - } - bool nlast=false; - while (*scan && (mode==1 || !nlast) && pt 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "WString.h" - -#ifndef ASSERT -#ifdef _DEBUG -#define ASSERT(x) assert(x) -#else -#define ASSERT(x) -#endif -#endif - -#define WPathnameCompare(op) bool operator op (const WPathname &other) const \ -{if (IsNull() || other.IsNull()) return false;else return wcsicmp(_fullpath,other._fullpath) op 0;}\ - bool operator op (const wchar_t *other) const \ -{ASSERT(!other || other[0]!=0);\ - if (IsNull() || other==NULL) return false;else return wcsicmp(_fullpath,other) op 0;} - -/** class WPathname simplifying manipulation with WPathnames, filenames, general paths, and -also supports convert from absolute path to relative respectively */ - - - -class WPathname -{ - ///object value and data - /**The implementation of WPathname creates only one buffer for all variables. It can - increase speed by effective memory use. Strings are stored one after another separated - by zero byte. Evry time any string changed, implementation recalculate buffer usage, and - decide, whether it should resize buffer or not. - - _fullpath also points to string contain full path with filename, - it is dominant value of the class - */ - WString _fullpath; - WString _path; /// - If name is provided, WPathname will expand it into full name with drive and folder name. - @param name optional argument to inicialize object - */ - WPathname(const wchar_t *name=NULL); - WPathname(const WString &name); - - ///Construct WPathname class - /** - @param relpath Relative path or uncomplette path or single filename with extension. - WPathname will expand this WPathname into full using absolute path provided by the second - argument. - @param abspath Absolute path used as reference to folder - the origin of relative path - provided in the first argument. - */ - WPathname(const wchar_t *relpath, const WPathname &abspath); - - ///Construct WPathname as copy of another WPathname - WPathname(const WPathname &other); - - - ///Function returns the current drive letter. - /** Before usage, ensure, that current WPathname contain drive. - In network path drive letter is missing. - In this case, result is undefined. To ensure, use HasDrive function - @return the drive letter of current path. - */ - wchar_t GetDrive() const - { - if (IsNull()) return 0; - return _path[0]; - } - - ///Static function determines, if argument contain a drive information. - /** - @param dir directory to inspect - @return true, if directory contain drive.

- This function is independed, it don't need any WPathname variable declared. - */ - static bool HasDrive(const wchar_t *dir) - {return (dir[0]>='A' && dir[0]<='Z' || dir[0]>='a' && dir[0]<='z') && dir[1]==':';} - - ///Function determines, if current WPathname contain a drive information - /** - @return true, if current WPathname contain a drive information - */ - bool HasDrive() const - { - if (IsNull()) return false; - return HasDrive(_path); - } - - - ///Function returns current folder name - /** - if current folder name contain drive, only folder name is returned (without drive). - In other cases (relative or network drives) returns full path. - @return folder name or full path. Pointer is valid until any first change in object. - Do not invoke release function at pointer! - */ - const wchar_t *GetDirectory() const - { - if (HasDrive()) return _path.GetString()+3; - else return _path.GetString()+IsNetworkPath(); - } - - const wchar_t *GetDirectoryWithDrive() const - { - return _path; - } - - ///Function returns current filename with extension - /** - @return current filename with extension. Pointer is valid until any first change in object. - Do not invoke release function at pointer! - */ - const wchar_t *GetFilename() const - { - if (IsNull()) return NULL; - const wchar_t *blk=wcsrchr(_fullpath,'\\'); - if (blk) blk=blk+1;else blk=_fullpath; - return blk; - } - - ///Function returns current extension (with starting dot) - /** - @return current extension. Pointer is valid until any first change in object. - Do not invoke release function at pointer! - */ - const wchar_t *GetExtension() const - {return _extension;} - - ///Function returns current filename without extension (without dot) - /** - @return current filename without extension (without dot). Pointer is valid until any first change in object. - Do not invoke release function at pointer! - */ - const wchar_t *GetTitle() const - {return _filetitle;} - - ///Function changes current drive. - /**If object contain WPathname with drive, then current drive is changed and function returns. - If object contain network path, then computer name is changed to the drive name. - If object contain relative path, then whole path is replaced by path on root on drive. - @param dr new drive letter. This parameter can be set to zero. It means, that current - driver is deleted, and path is converted to relative path from root. Note: Zero c - cannot be used with network paths and relative paths, and finnaly has no effect to the object - */ - - void SetDrive(wchar_t dr); - - ///Sets new directory for object - /** if object contain a drive letter and argument dir doesn't, then current drive is remain - and only directory part is replaced. If current path is network path or relative path, - then whole path is replaced by new one. - If argument dir contain drive letter, then whole path is replaced too. - @param dir contain new WPathname. Backslash should be the last wchar_tacter in string - */ - void SetDirectory(const wchar_t *dir); - - ///Sets new filename for object. - /** - If filename contain dot, function assumes, that filename is provided with extension. - Otherwise, current extension remains untouched. - @param filename new filename for object - */ - - void SetFilename(const wchar_t *filename); - - ///Sets new extension for object. - /** - If ext doesn't starting with dot, function adds it. - @param ext new extension for object - */ - void SetExtension(const wchar_t *ext); - - ///Sets new file title - /** Function changes file title, extension remains untouched. - if title contains extension (dot inside its name), this extension doesn't change - current extension. For example, if current extension is ".cpp" and filetitle contain - "source.h", then result is "source.h.cpp" - @param title a new title for object. - */ - - void SetFileTitle(const wchar_t *title); - - ///Function returns full WPathname. - /** - @return current WPathname. Pointer is valid until any first change in object. - Do not invoke release function at pointer! - */ - - const wchar_t *GetFullPath() const - {return _fullpath;} - - ///Sets WPathname - /** Function has same effect as constructor. But it can be used - anytime during object lifetime. It simply replaces current WPathname with newer. WPathname - in argument is expanded to full WPathname, current directory is used as reference. - @param WPathname new WPathname - */ - void SetPathname(const wchar_t *pathname); - void SetPathname(const WString &pathname); - - WPathname& operator=(const wchar_t *other) - {SetPathname(other);return *this;} - - WPathname& operator=(const WString &other) - {SetPathname(other);return *this;} - - WPathname& operator=(const WPathname& other) - { - _fullpath=other._fullpath; - _path=other._path; - _filetitle=other._filetitle; - _extension=other._extension; - return *this; - } - - ///converts object to string - operator const wchar_t *() const - {return GetFullPath();} - - ///Static function to help getting filename from WPathname - /** Function finds last backslash / and return pointer to first wchar_tacter after it. - Pointer stays valid until original path is destroyed or until original path is changed - @param path WPathname to inspect as string - @return pointer to filename - */ - static const wchar_t *GetNameFromPath(const wchar_t *path); - - ///Static function to help getting extension from WPathname - /** Function finds last dot '.' in filename return pointer to it (extension with dot). - Pointer stays valid until original path is destroyed or until original path is changed - @param path WPathname to inspect as string - @return pointer to extension - */ - static const wchar_t *GetExtensionFromPath(const wchar_t *path); - - ///Function sets server name for network path - /** If current path is network path, then changes server name to newer. Otherwise - it remove drive letter, and insert server name before remain path - @param server server name without slashes - */ - void SetServerName(const wchar_t *server); - - ///Function inspects current path and returns, whether contain server name - /**@return zero, if current path is not valid network path. Nonzero if path contain - server name. Then value returned count wchar_tacters containing server name with precedent - slashes. - */ - int IsNetworkPath() const; - - ///Function converts current relative path into absolute path - /** - If current path is not relative, function do nothing. - @param ref reference to path, against which path is relative. - @return true if path has been converted, or false, if conversion is impossible - */ - bool RelativeToFull(const WPathname &ref); - - ///Function converts current absolute path into relative path - /** - If current path is not relative, function do nothing. Both paths must be on the same - drive or network computer. - - @param ref reference to path, against which path should be relative. - @return true if path has been converted, or false, if conversion is impossible - */ - bool FullToRelative(const WPathname &relativeto); - - WPathname& operator+=(const wchar_t *relativePath) - {*this=WPathname(relativePath,*this);return *this;} - - WPathname operator+(const wchar_t *relativePath) - {WPathname out(relativePath,*this);return out;} - - bool IsNull() const {return _fullpath.GetLength()==0;} - - void SetNull(); - - WPathnameCompare(<) - WPathnameCompare(>) - WPathnameCompare(==) - WPathnameCompare(>=) - WPathnameCompare(<=) - WPathnameCompare(!=) - - - ///Function gets part of WPathname - /** - @param path subject of examine - @param partnum zero-base index of part of WPathname. Index 0 mostly contain drive or server, in case of - relative path, there is the name of the first folder or dots. - @param buff buffer for store result - @param bufsize count wchar_tacters in buffer; - @param mode mode=0, gets only name of part. - mode=1, get current part and remain parts of path. - mode=-1, gets all parts till current - @return Function returns true, if it was succesful, and it was not last part. Function returns - false, if it was succesful, and it was last part. Function returns false and sets buffer empty, - if an error occured. Function returns true and sets buffer empty, if buffer is too small to hold data - */ - static bool GetPartFromPath(const wchar_t *path, int partnum, wchar_t *buff, int bufsize, int mode=0); - - ///Function gets part of object - /** - @param partnum zero-base index of part of WPathname. Index 0 mostly contain drive or server, in case of - relative path, there is the name of the first folder or dots. - @param buff buffer for store result - @param bufsize count wchar_tacters in buffer; - @param mode mode=0, gets only name of part. - mode=1, get current part and remain parts of path. - mode=-1, gets all parts till current - @return Function returns true, if it was succesful, and it was not last part. Function returns - false, if it was succesful, and it was last part. Function returns false and sets buffer empty, - if an error occured. Function returns true and sets buffer empty, if buffer is too small to hold data - */ - bool GetPart(int partnum, wchar_t *buff, int bufsize,int mode=0) const - { - return GetPartFromPath(this->_fullpath,partnum,buff,bufsize,mode); - } - - /// Get Directory With Drive Without Last Back Slash - /** Retrieves into buffer directory with drive and removes last backslash - @param buff buffer that retrieves path - @param size size of buffer - @return true, if success, failed if buffer is too small*/ - - - bool GetDirectoryWithDriveWLBS(wchar_t *buff, size_t size) const; - - WString GetDirectoryWithDriveWLBS() const; - - - /// function checks, if path is valid and returns true, if does. - bool IsPathValid() const; - - /// Sets special directory. - /** - @param bSpecCode this value may be operation-system - depend. Windows implementation using CSIDL_XXXX constants, which is described in SHGetSpecialFolderLocation function - description - @return true, if function were successful - */ - bool SetDirectorySpecial(int nSpecCode); - - ///Sets temporaly directory. - bool SetTempDirectory(); - - ///Guess temporaly file name - /** - @param prefix prefix string for name - @param unique if unique is non-zero, it is used for new temporaly file. If unique is zero, function guess own unique - value. - @return true if function were successful - */ - bool SetTempFile(const wchar_t *prefix=L"tmp", unsigned int unique=NULL); - - ///Returns path of current executable. - /**It useful, when accessing folder, from when current module has been executed */ - static WPathname GetExePath(); - - ///Solves most used conversion from fullpath to path relative to project root - /** - @param full full WPathname with drive - @param projectRoot project root path - @return function returns pointer to full path, where starts relative part. If - fullpath doesn't contain project root path, it returns pointer to full. - @example FullToProjectRoot("x:\\project\\data\\example.txt","x:\\project"); //result is "data\\example.txt" - */ - - static const wchar_t *FullToRelativeProjectRoot(const wchar_t *full, const wchar_t *projectRoot); - - -protected: - ///Function only rebuild _fullpath string. - /** It doesn't check space for string! This function is used, when length of path is excepted - the same or smaller, then current. - */ - void RebuildPath(); - - -}; - - - -#endif // !defined(AFX_WPathname_H__158F59D5_B422_4FA6_86AC_10B5EC48C81B__INCLUDED_) diff --git a/DDLReader/WString.cpp b/DDLReader/WString.cpp deleted file mode 100644 index ea60b4e..0000000 --- a/DDLReader/WString.cpp +++ /dev/null @@ -1,194 +0,0 @@ -// WString.cpp: implementation of the WString class. -// -////////////////////////////////////////////////////////////////////// - -#include "WString.h" -#include -#include - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -WString::WString(const char *sbstring, unsigned int codePage) -{ - if (sbstring==NULL || *sbstring==0) - { - _ref=NULL; - } - else - { - size_t reqBuff=MultiByteToWideChar(codePage,0,sbstring,-1,NULL,0); - - _ref=WStringMemory::AllocString(NULL,reqBuff); - _ref->AddRef(); - wchar_t *str=const_cast(_ref->GetStringFromMemBlock()); - - MultiByteToWideChar(codePage,0,sbstring,-1,str,reqBuff); - } -} - -int WString::FormatV(wchar_t *format, va_list lst) -{ - size_t curSize=4096; - int written; - do - { - _ref=WStringMemory::AllocString(NULL,curSize); - wchar_t *str=const_cast(_ref->GetStringFromMemBlock()); - written=_vsnwprintf(str,curSize,format,lst); - if (written<0) - { - curSize*=2; - WStringMemory::FreeProxy(_ref); - } - } - while (written<-1); - _ref->RecalcLength(); - _ref->AddRef(); - return written; -} - -int WString::Format(wchar_t *format, ...) -{ - va_list valst; - va_start(valst,format); - return FormatV(format,valst); -} - - -int WString::ScanStringV(const wchar_t *format, va_list lst) const -{ - uint32_t *ptr=(uint32_t *)lst; - return swscanf(GetString(),format,ptr[0],ptr[1],ptr[2],ptr[3],ptr[4],ptr[5],ptr[6],ptr[7],ptr[8],ptr[9], - ptr[10],ptr[11],ptr[12],ptr[13],ptr[14],ptr[15],ptr[16],ptr[17],ptr[18],ptr[19]); - -} - -int WString::ScanString(const wchar_t *format, ...) const -{ - va_list valst; - va_start(valst,format); - return ScanStringV(format,valst); -} - -bool WString::ReplaceOnce(const WString &findWhat,const WString &replaceWith) -{ - int pos=Find(findWhat); - if (pos==-1) return false; - (*this)=Left(pos)+replaceWith+Right(pos+replaceWith.GetLength()); - return true; -} - -bool WString::ReplaceAll(const WString &findWhat,const WString &replaceWith) -{ - WString process=*this; - WString result; - int pos; - bool processed=false; - while ((pos=process.Find(findWhat))!=-1) - { - result=result+process.Left(pos)+replaceWith; - process=process.Right(pos+findWhat.GetLength()); - processed=true; - } - *this=result+process; - return processed; -} - -WString WString::TrimLeft() const -{ - return TrimLeft(L" \r\n\t"); -} - -WString WString::TrimRight() const -{ - return TrimRight(L" \r\n\t"); -} - -WString WString::TrimLeft(wchar_t *trimChars) const -{ - const wchar_t *proStr=GetString(); - int p=0; - while (proStr[p] && wcschr(trimChars,proStr[p]!=NULL)) p++; - return Right(p); -} - -WString WString::TrimRight(wchar_t *trimChars) const -{ - const wchar_t *proStr=GetString(); - int p=GetLength()-1; - while (p>=0 && wcschr(trimChars,proStr[p]!=NULL)) p--; - return Left(p+1); -} - -WString WString::Upper() const -{ - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,WStringProxy::EfUpper))); -} - -WString WString::Lower() const -{ - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,WStringProxy::EfLower))); -} - -WString WString::Reverse() const -{ - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,WStringProxy::EfReverse))); -} - -WString WString::Effect(IWStringEffect *effect) const -{ - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,effect))); -} - -void WString::SetUTF7(const char *utf7) -{ - *this=WString(utf7,CP_UTF7); -} - -void WString::SetUTF8(const char *utf8) -{ - *this=WString(utf8,CP_UTF8); -} - -const char *WString::AsSBString(unsigned int codePage, WString &holder) -{ - const wchar_t *str=GetString(); - if (str[0]==0) return ""; - size_t reqsize=WideCharToMultiByte(codePage,0,str,-1,NULL,0,NULL,NULL); - WStringProxy *holderProxy=WStringMemory::AllocString(NULL,reqsize/2); //reqsize/2+(2 bytes) - char *mbstr=reinterpret_cast(const_cast(holderProxy->GetStringFromMemBlock())); - WideCharToMultiByte(codePage,0,str,-1,mbstr,reqsize,NULL,NULL); - holder=WString(holderProxy); - return mbstr; -} - -const char *WString::AsUTF7(WString &holder) -{ - return AsSBString(CP_UTF7,holder); -} - -const char *WString::AsUTF8(WString &holder) -{ - return AsSBString(CP_UTF8,holder); -} - -void WString::ReadFromStream(size_t (*streamReader)(wchar_t *buffer, size_t bufferLen, void *context),void *context) -{ - _ref->Release(); - _ref=NULL; - wchar_t buff[256]; - size_t rd; - while ((rd=streamReader(buff,sizeof(buff)/sizeof(wchar_t),context))!=0) - { - *this=*this+WString(buff,rd); - } -} - -const WString WStringConst(const wchar_t *text) -{ - return WString(WStringMemory::AllocProxy(WStringProxy(text))); -} - diff --git a/DDLReader/WString.h b/DDLReader/WString.h deleted file mode 100644 index a244adb..0000000 --- a/DDLReader/WString.h +++ /dev/null @@ -1,496 +0,0 @@ -// WString.h: interface for the WString class. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_WSTRING_H__481164FB_3BB7_4824_B0E3_8B371F0AAF3A__INCLUDED_) -#define AFX_WSTRING_H__481164FB_3BB7_4824_B0E3_8B371F0AAF3A__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "WStringProxy.h" -#include - -class WString -{ - mutable WStringProxy *_ref; - - - -public: - ///constructs empty string - WString():_ref(0) {} - - ///constructs string. - explicit WString(const wchar_t *string):_ref(string==NULL?NULL:WStringMemory::AllocString(string,0)) {_ref->AddRef();}; - - ///constructs string from wide-char array with specified length - WString(const wchar_t *string, size_t sz):_ref(WStringMemory::AllocString(string,sz)) {_ref->AddRef();}; - - ///copy constructor - /**constructor doesn't copy the string, only reference. - String is shared until it is changed - */ - WString(const WString &other):_ref(other._ref) {_ref->AddRef();} - - ///constructs string from multi-byte string. codePage specified code page of string - WString(const char *sbstring, unsigned int codePage); - - ///constructs string from string-proxy. Used internally with WStringMemory::AllocXXX functions - WString(WStringProxy *proxy):_ref(proxy) {_ref->AddRef();} - - ///assignment operator - /** assignment operator doesn't copy the string only reference. - String is shared until it is changed */ - WString &operator=(const WString &other) - {other._ref->AddRef();_ref->Release();_ref=other._ref;return *this;} - - ///Destructor - releases reference - ~WString() {_ref->Release();} - - ///function converts instance of WString to wchar_t pointer - /** - Function will perform RenderString, if it is needed. - */ - const wchar_t *GetString() const - { - if (_ref==NULL) return L""; - WStringProxy *str=_ref->RenderString(); - if (_ref!=str) - { - str->AddRef();_ref->Release();_ref=str; - } - return _ref->GetStringFromMemBlock(); - } - - ///operator can convert WString to wchar_t pointer anytime - operator const wchar_t *() const {return GetString();} - - ///function returns count of characters in string - /** function doesn't need to render string, so it can be called anytime - without loosing the benefit of "pseudo-strings" boosting */ - size_t GetLength() const - { - if (_ref) return _ref->GetLength(); - else return 0; - } - - ///function creates string as sum of this and another string - /** function creates "pseudo-string" that represents sum of two string. - pseudo-string is rendered to "real-string" automatically, when it is needed */ - WString operator+(const WString other) const - { - if (_ref==NULL) return other; - if (other._ref==NULL) return *this; - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,other._ref))); - } - - WString &operator+=(const WString other) - { - *this=*this+other; - return *this; - } - - ///function creates string as substring of another string - /** function creates "pseudo-string" that represents substring of anothers string. - Pseudo-string is rendered to "real-string" automatically, when it is needed */ - WString Mid(size_t begin, size_t len) const - { - if (begin==0) return Left(len); - if (_ref==NULL || begin>GetLength()) return WString(); - if (begin+len>GetLength()) return Right(begin); - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,begin,len))); - } - - WString Left(size_t len) const - { - if (_ref==NULL) return WString(); - if (len>=GetLength()) return *this; - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,0,len))); - } - - WString Right(size_t begin) const - { - if (_ref==NULL || begin>GetLength()) return WString(); - if (begin==0) return *this; - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,begin,GetLength()-begin))); - } - - WString RightR(size_t count) const - { - if (_ref==NULL || count==0) return WString(); - if (count>=GetLength()) return *this; - return WString(WStringMemory::AllocProxy(WStringProxy(_ref,GetLength()-count,count))); - } - - WString Delete(size_t begin, size_t count) const - { - if (_ref==NULL) return WString(); - if (begin==0) return Right(count); - if (begin+count>=GetLength()) return Left(begin); - return WString(WStringMemory::AllocProxy(WStringProxy(Left(begin)._ref,Right(begin+count)._ref))); - } - - WString Insert(const WString &what, size_t index) const - { - if (_ref==NULL) return what; - if (index==0) return what+*this; - if (index>=GetLength()) return *this+what; - return Left(index)+what+Right(index); - } - - /// function allows to access any char in string - wchar_t operator[](int index) const - { - assert(index<=(int)GetLength() && index>=0); - return GetString()[index]; - } - - /// functions allows lock string for accesing it directly. - /** Function returns pointer to buffer which holds string. - Buffer size is equal to string length plus terminating zero. - Application can modify content of buffer. - If string is shared with another WString object, LockBuffer - creates copy of string - Do not forger to call UnlockBuffer, when you finish modifiing the content - */ - wchar_t *LockBuffer() - { - if (_ref==NULL) return NULL; - GetString(); - WStringMemory::LockProxy(_ref); - if (_ref->IsShared()) - { - WStringMemory::UnlockProxy(_ref); - _ref->Release(); - _ref=WStringMemory::AllocString(_ref->GetStringFromMemBlock(),0); - _ref->AddRef(); - WStringMemory::LockProxy(_ref); - } - return const_cast(_ref->GetStringFromMemBlock()); - } - - /// Function creates buffer for string and returns its address - /** Application can use buffer in functions, that cannot work with - WString objects. Size of buffer is specified by sz value, and it is in characters. - Application must call UnlockBuffer after writes all data into buffer. - - NOTE: Prevoius content of string is lost. - NOTE: sz specifies buffer size without terminating zero character - */ - wchar_t *CreateBuffer(size_t sz) - { - _ref->Release(); - _ref=WStringMemory::AllocString(NULL,sz); - _ref->AddRef(); - WStringMemory::LockProxy(_ref); - return const_cast(_ref->GetStringFromMemBlock()); - } - - /// Function creates buffer, and copies string into it. - /** Parameter sz specifies size of new buffer in characters - When sz is smaller then size of string, string is truncated - When sz is larger then size of string, string is copied unchanged, - but extra characters can be appended. - - NOTE: sz specifies buffer size without terminating zero character - */ - wchar_t *CreateBufferCopy(size_t sz) - { - WString save=*this; - wchar_t *wbuff=CreateBuffer(sz); - int minsz=__min(sz,save.GetLength()); - wcsncpy(wbuff,save.GetString(),minsz); - return wbuff; - } - - /// Function unlocks internal buffer - /** parameter sz specifies final lenght of string in buffer. Default - value -1 forces function calc size by own - */ - void UnlockBuffer(int sz=-1) - { - if (_ref==NULL) return; - wchar_t *wbuff=const_cast(_ref->GetStringFromMemBlock()); - if (sz<0) sz=wcslen(wbuff); - else wbuff[sz]=0; - if (sz!=(signed)_ref->GetLength()) - { - _ref->RecalcLength(); - WStringMemory::UnlockProxy(_ref); - } - } - - class WStringAtCharHelper - { - WString &_str; - size_t _index; - public: - WStringAtCharHelper(WString &str,size_t index):_str(str),_index(index) {} - WString &operator=(wchar_t z) - { - wchar_t *buff=_str.LockBuffer(); - assert(buff && _index<_str.GetLength()); - buff[_index]=z; - _str.UnlockBuffer(); - return _str; - } - operator wchar_t() - { - assert(_index<_str.GetLength()); - return ((const wchar_t *)_str)[_index]; - } - }; - - /// Function will return helper object, which can access single character in string - /** - Using array operator is slower than accessing characters by LockBuffer function - */ - WStringAtCharHelper operator[](int index) - { - return WStringAtCharHelper(*this,index); - } - - int Find(wchar_t z,size_t from=0) const - { - if (from>=GetLength()) return -1; - const wchar_t *res=wcschr(GetString()+from,z); - if (res) return res-GetString(); - else return -1; - } - - int FindLast(wchar_t z) const - { - const wchar_t *res=wcsrchr(GetString(),z); - if (res) return res-GetString(); - else return -1; - } - - int Find(const wchar_t *z,size_t from=0) const - { - if (z==NULL) return -1; - if (from>=GetLength()) return -1; - const wchar_t *res=wcsstr(GetString()+from,z); - if (res) return res-GetString(); - else return -1; - } - - int FormatV(wchar_t *format, va_list lst); - - int Format(wchar_t *format, ...); - - ///Scans string for format - /** function is limited, item count is limited up to 20 items */ - int ScanStringV(const wchar_t *format, va_list lst) const; - - ///Scans string for format - /** function is limited, item count is limited up to 20 items */ - int ScanString(const wchar_t *format, ...) const; - - bool ReplaceOnce(const WString &findWhat,const WString &replaceWith); - - bool ReplaceAll(const WString &findWhat,const WString &replaceWith); - - WString TrimLeft() const; - - WString TrimRight() const; - - WString TrimLeft(wchar_t *trimChars) const; - - WString TrimRight(wchar_t *trimChars) const; - - ///Function splits string into two - /** Left part of string is returned. - Right part of string is leaved in object - @param splitPos split position. - @return if splitPos==0, function returns empty string. if splitPos>=length, function - moves string from object to result*/ - WString Split(size_t splitPos) - { - WString result=Left(splitPos); - *this=Right(splitPos); - return result; - } - - bool IsEmpty() const {return _ref==NULL;} - - void Empty() const {_ref->Release();_ref=NULL;} - - int Compare(const wchar_t *other) const - { - return wcscmp(*this,other); - } - - bool operator>(const WString &other) const {return Compare(other)>0;} - bool operator<(const WString &other) const {return Compare(other)<0;} - bool operator>=(const WString &other) const {return Compare(other)>=0;} - bool operator<=(const WString &other) const {return Compare(other)<=0;} - bool operator!=(const WString &other) const {return Compare(other)<=0;} - bool operator==(const WString &other) const {return Compare(other)<=0;} - - WString Upper() const; - WString Lower() const; - WString Reverse() const; - - ///Applies user effect on string - /** pointer should be static allocated object, or must be valid during lifetime of resulting string */ - WString Effect(IWStringEffect *effect) const; - - void SetUTF7(const char *utf7); - void SetUTF8(const char *utf8); - - ///Function converts string to SingleByte string - /** - @param codePage Platform depends code page of result - @param holder Object that holds result. Result pointer is valid during lifetime of holder. Once holder - released, pointer is invalidated. You can get resulting pointer anytime from holder reintepreting - wchar_t to char - @result pointer to string - */ - const char *AsSBString(unsigned int codePage, WString &holder); - - ///Returns multibyte string in UTF7 codepage - /**See AsSBString description*/ - const char *AsUTF7(WString &holder); - - ///Returns multibyte string in UTF7 codepage - /**See AsSBString description*/ - const char *AsUTF8(WString &holder); - - - ///Function reads string from stream - /** - Function calls streamReader repeatly until function returns zero. In each call, streamReader returns - number of characters, that has been readed. - @param sreamReader pointer to function which provides reading from a stream - @param context user defined context pointer (most in cases, pointer to stream is passed) - @param buffer space allocated for data readed from stream - @param bufferLen maximum count of characters can be written to buffer - @return streamReader returns number of characters, that has been written to buffer. Function must return zero - to stop reading - */ - void ReadFromStream(size_t (*streamReader)(wchar_t *buffer, size_t bufferLen, void *context),void *context); - - WString operator() (int from) const {return from<0?RightR(-from):Right(from);} - WString operator() (int from, int to) const - { - if (from>=0) - return to<0?Mid(from,-to):Mid(from,to-from); - else - return to<0?Mid(GetLength()+from,-to):Mid(GetLength()+from,GetLength()-from-to); - } - - ///Enables global string sharing. - /** Function Share allows share strings that contains same text. It can reduce memory - usage. Function is useful when there is many objects that contains string with same text. - - Basically, two strings is shared, if one string is created as copy of another string. Strings - is sharing they content, until one of them is modified. - - Calling Share function, string is registered for global sharing. If string with same content is already - registered, then content of current string is released, and string is shared. - - To successfully share two strings, both strings must call Share() function. Sharing is provided until one - of strings is modified. After modifications are done, Share function of modified string must be called again. - - Remember: Global sharing can reduce amount of memory, if there are multiple strings that containging - the same content. But sharing of each unique string takes small piece of memory to store sharing - informations. - - To share string automatically, use WSharedString class - WSC strings cannot be shared! - */ - void Share() const - { - WStringProxy *curref=_ref; - GetString(); - _ref=WStringMemory::ShareString(curref); - _ref->AddRef(); - curref->Release(); - } - - ///Disables global string sharing - /** Function unregisters string from global sharing database. If string is shared, function doesn't break - it. But all strings that currently sharing content will not be shared with newly created strings. - */ - void Unshare() - { - WStringMemory::UnshareString(_ref); - } -}; - -///Function will create constant WString -/** function will not copy content of string. Only creates reference to string - Using WStringConst is faster for strings in code -@exmple result=a+WStringConst(L"text")+b; -*/ -const WString WStringConst(const wchar_t *text); - -///Macro to easy convert incode string to WString -/** -function also marks text wide. -@example WString text=WSC("Hello world"); -*/ -#define WSC(x) WStringConst(L##x) -///Macro to easy convert any wchar_t buffer to constant WString -/** -IMPORTANT NOTE!: Buffer must exists until string is rendered. -If you are using WSCB in function, don't forget call GetString before function exits -If you are excepting additional string operations outside function, using standard -WString conversion can be more effecient. -*/ -#define WSCB(x) WStringConst(x) - - - -class WSharedString: public WString -{ -public: - WSharedString() {} - - ///constructs string. - explicit WSharedString(const wchar_t *string):WString(string) {Share();} - - ///constructs string from wide-char array with specified length - WSharedString(const wchar_t *string, size_t sz):WString(string,sz) {Share();}; - - ///copy constructor - /**constructor doesn't copy the string, only reference. - String is shared until it is changed - */ - WSharedString(const WSharedString &other):WString(other) {} - WSharedString(const WString &other):WString(other) {Share();} - - ///constructs string from multi-byte string. codePage specified code page of string - WSharedString(const char *sbstring, unsigned int codePage):WString(sbstring,codePage) {Share();} - - ///assignment operator - /** assignment operator doesn't copy the string only reference. - String is shared until it is changed */ - WSharedString &operator=(const WString &other) - {WString::operator =(other);Share();return *this;} - - const wchar_t *GetString() const - { - const wchar_t *res=WString::GetString(); - Share(); - return res; - } - operator const wchar_t *() const {return GetString();} - wchar_t operator[](int index) const - { - assert(index<=(int)GetLength() && index>=0); - return GetString()[index]; - } - - void UnlockBuffer(int sz=-1) - { - WString::UnlockBuffer(sz); - Share(); - } - -}; - - -#endif // !defined(AFX_WSTRING_H__481164FB_3BB7_4824_B0E3_8B371F0AAF3A__INCLUDED_) diff --git a/DDLReader/WStringMemory.cpp b/DDLReader/WStringMemory.cpp deleted file mode 100644 index 947ed02..0000000 --- a/DDLReader/WStringMemory.cpp +++ /dev/null @@ -1,397 +0,0 @@ -// WStringMemorySingleThread.cpp: implementation of the WStringMemory class. -// -////////////////////////////////////////////////////////////////////// - -#include -#include -#include "WStringMemory.h" -#include "WStringProxy.h" -#include -#include -#include - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -#ifdef _MT //multithreading -#define WSTRING_MT -#endif - -#ifdef WSTRING_MT //multithreading - - -struct WStringMTLock -{ - WStringProxy *_lockProxy; - LONG _recursionCount; - DWORD _owner; - HANDLE _event; - WStringMTLock(WStringProxy *x):_lockProxy(x) {} - WStringMTLock():_lockProxy(NULL) {} - - bool operator==(const WStringMTLock &other) const {return _lockProxy==other._lockProxy;} - bool operator!=(const WStringMTLock &other) const {return _lockProxy!=other._lockProxy;} - bool operator>=(const WStringMTLock &other) const {return _lockProxy>=other._lockProxy;} - bool operator<=(const WStringMTLock &other) const {return _lockProxy<=other._lockProxy;} - bool operator>(const WStringMTLock &other) const {return _lockProxy>other._lockProxy;} - bool operator<(const WStringMTLock &other) const {return _lockProxy *GLockDB=NULL; //Lock proxy database - -static void exitMT() -{ - DeleteCriticalSection(&GLocker); -} - - -static void OnStartup() -{ - InitializeCriticalSection(&GLocker); - atexit(exitMT); -} - -#define ON_STARTUP_PRIORITY_NORMAL OnStartup -#include - -#endif - - - -#define WS_MAXFREELISTS 32 -#define WS_FREELISTSTEP 32 -#define WS_TOTALMAXFREEKBYTES 256 - -#define WS_MAXIMUMFASTALLOC (WS_MAXFREELISTS*WS_FREELISTSTEP) - -#define WS_MAXFREEBYTES PerSlotMaxAlloc - - -static size_t PerSlotMaxAlloc=(WS_TOTALMAXFREEKBYTES*1024/WS_MAXFREELISTS); -static WStringProxy *FreeList=NULL; -static void **StringFreeList[WS_MAXFREELISTS]; -static size_t StringFreeBytes[WS_MAXFREELISTS]; -static bool InitManager=true; - - -static void InitManagerPointers() -{ - memset(StringFreeList,0,sizeof(StringFreeList)); - memset(StringFreeBytes,0,sizeof(StringFreeBytes)); - InitManager=false; -} - -static void *AllocStringBlock(size_t sz) -{ - if (InitManager) InitManagerPointers(); - if (sz>WS_MAXIMUMFASTALLOC) return malloc(sz); - int pos=(sz+WS_FREELISTSTEP-1)/WS_FREELISTSTEP; - void **nxt=StringFreeList[pos]; - if (nxt==0) - { - printf("malloc %d\n",pos*WS_FREELISTSTEP); - return malloc(pos*WS_FREELISTSTEP); - } - printf("fast_alloc %d\n",pos*WS_FREELISTSTEP); - StringFreeList[pos]=(void **)(*nxt); - StringFreeBytes[pos]-=_msize(nxt); - return nxt; -} - -static void DeallocStringBlock(void *ptr) -{ - size_t sz=_msize(ptr); - if (sz>WS_MAXIMUMFASTALLOC) {free(ptr);return;} - int pos=(sz+WS_FREELISTSTEP-1)/WS_FREELISTSTEP; - if (sz+StringFreeBytes[pos]>WS_MAXFREEBYTES) - { - printf("free %d\n",sz); - free(ptr);return; - } - void **proxy=(void **)ptr; - *proxy=(void *)StringFreeList[pos]; - StringFreeList[pos]=proxy; - StringFreeBytes[pos]+=sz; - printf("fast_free %d\n",sz); -} - - -static inline void *operator new(size_t alloc,size_t sz) -{ - return AllocStringBlock(sz+alloc); -} - -static inline void operator delete(void *p,size_t alloc) -{ - DeallocStringBlock(p); -} - -static inline void *operator new(size_t sz,void *ptr) -{ - return ptr; -} - -static inline void operator delete(void *ptr,void *p) -{ -} - -WStringProxy * WStringMemory::AllocString(const wchar_t *text, size_t size) -{ -#ifdef WSTRING_MT - EnterCriticalSection(&GLocker); -#endif - assert(size!=0 || text!=0); - if (size==0) size=wcslen(text); - WStringProxy *proxy=new((size+1)*sizeof(wchar_t)) WStringProxy(size,0,0); - wchar_t *alloctext=const_cast(proxy->GetStringFromMemBlock()); - if (text) wcsncpy(alloctext,text,size); - alloctext[size]=0; - if (proxy->_redirect==0) - { - proxy->_redirect=alloctext; - proxy->_blockData2=1; - } -#ifdef WSTRING_MT - LeaveCriticalSection(&GLocker); -#endif - return proxy; -} - -WStringProxy * WStringMemory::AllocProxy(const WStringProxy &templateProxy) -{ - WStringProxy * res; -#ifdef WSTRING_MT - EnterCriticalSection(&GLocker); -#endif - if (FreeList==NULL) res=new WStringProxy(templateProxy); - else - { - WStringProxy *alloc=FreeList; - FreeList=alloc->_baseString; - res=new((void *)alloc) WStringProxy(templateProxy); - } -#ifdef WSTRING_MT - LeaveCriticalSection(&GLocker); -#endif - return res; -} - -void WStringMemory::FreeProxy(WStringProxy *proxy) -{ -#ifdef WSTRING_MT - EnterCriticalSection(&GLocker); -#endif - if (proxy->_operation==proxy->OpMemBlck && !(proxy->_blockData2==0 && proxy->_redirect!=NULL)) - { - if (proxy->_blockData2==2) UnshareString(proxy); - DeallocStringBlock(proxy); - } - else - { - proxy->~WStringProxy(); - proxy->_baseString=FreeList; - FreeList=proxy; - } -#ifdef WSTRING_MT - LeaveCriticalSection(&GLocker); -#endif -} - -#ifdef WSTRING_MT - -void WStringMemory::LockProxy( WStringProxy *proxy) -{ -nextTry: - EnterCriticalSection(&GLocker); - WStringMTLock srch(proxy),*found; - if (GLockDB==NULL) GLockDB=new BTree(16); - found=GLockDB->Find(srch); - if (found==NULL) - { - srch._event=NULL; - srch._owner=GetCurrentThreadId(); - srch._recursionCount=1; - GLockDB->Add(srch); - } - else - { - if (found->_owner!=GetCurrentThreadId()) - { - HANDLE w=found->_event; - if (w==0) {w=found->_event=CreateEvent(NULL,TRUE,FALSE,NULL);} - LeaveCriticalSection(&GLocker); //leave section - WaitForSingleObject(w,INFINITE); - goto nextTry; - } - else - { - found->_recursionCount++; - } - } - LeaveCriticalSection(&GLocker); //leave section -} - -void WStringMemory::UnlockProxy( WStringProxy *proxy) -{ - EnterCriticalSection(&GLocker); - WStringMTLock srch(proxy),*found; - found=GLockDB->Find(srch); - if (found) - { - if (--found->_recursionCount==0) - { - if (found->_event!=NULL) - { - SetEvent(found->_event); - CloseHandle(found->_event); - } - GLockDB->Remove(*found); - } - } - LeaveCriticalSection(&GLocker); -} - - -void WStringMemory::AddRefProxy(WStringProxy *proxy) -{ - InterlockedIncrement(reinterpret_cast(&proxy->_refCount)); -} - -bool WStringMemory::ReleaseRefProxy(WStringProxy *proxy) -{ - LONG res=InterlockedDecrement(reinterpret_cast(&proxy->_refCount)); - if (res<0) res=InterlockedIncrement(reinterpret_cast(&proxy->_refCount)); - return res==0; -} - -#else -void WStringMemory::LockProxy( WStringProxy *proxy) -{ - //not needed in single thread environment -} - -void WStringMemory::UnlockProxy( WStringProxy *proxy) -{ - //not needed in single thread environment -} - - -void WStringMemory::AddRefProxy(WStringProxy *proxy) -{ - //no special handling in single thread environment - ++proxy->_refCount; -} - -bool WStringMemory::ReleaseRefProxy(WStringProxy *proxy) -{ - //no special handling in single thread environment - if (proxy->_refCount) --proxy->_refCount; - return proxy->_refCount==0; -} - -#endif -void WStringMemory::FreeExtra() -{ -#ifdef WSTRING_MT - EnterCriticalSection(&GLocker); -#endif - while (FreeList) - { - void *proxy=FreeList; - FreeList=FreeList->_baseString; - free(proxy); - } - for (int i=0;i_redirect,other._str->_redirect); - } - - bool operator==(const ShareDBItem& other) const {return Compare(other)==0;} - bool operator>=(const ShareDBItem& other) const {return Compare(other)>=0;} - bool operator<=(const ShareDBItem& other) const {return Compare(other)<=0;} - bool operator!=(const ShareDBItem& other) const {return Compare(other)!=0;} - bool operator>(const ShareDBItem& other) const {return Compare(other)>0;} - bool operator<(const ShareDBItem& other) const {return Compare(other)<0;} -}; - -static BTree *GDB=NULL; - -WStringProxy *WStringMemory::ShareString(WStringProxy *proxy) -{ - if (proxy->_operation!=WStringProxy::OpMemBlck || proxy->_blockData2==0 || proxy->_blockData2==2) return proxy; - -#ifdef WSTRING_MT - EnterCriticalSection(&GLocker); -#endif - - if (GDB==NULL) GDB=new BTree; - - proxy->_blockData2=2; //block is subject of sharing - proxy->_redirect=proxy->GetStringFromMemBlock(); //setup pointer to string - ShareDBItem *found=GDB->Find(ShareDBItem(proxy)); - if (found) {proxy->_blockData2=1;proxy=found->_str;} - else GDB->Add(ShareDBItem(proxy)); -#ifdef WSTRING_MT - LeaveCriticalSection(&GLocker); -#endif - return proxy; -} - -void WStringMemory::UnshareString(WStringProxy *proxy) -{ - if (proxy->_operation!=WStringProxy::OpMemBlck || proxy->_blockData2!=2) return; - if (GDB==NULL) return; -#ifdef WSTRING_MT - EnterCriticalSection(&GLocker); -#endif - GDB->Remove(ShareDBItem(proxy)); - proxy->_blockData2=1; -#ifdef WSTRING_MT - LeaveCriticalSection(&GLocker); -#endif -} \ No newline at end of file diff --git a/DDLReader/WStringMemory.h b/DDLReader/WStringMemory.h deleted file mode 100644 index a81b08e..0000000 --- a/DDLReader/WStringMemory.h +++ /dev/null @@ -1,61 +0,0 @@ -// WStringMemory.h: interface for the WStringMemory class. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_WSTRINGMEMORY_H__79693029_4788_4099_9A97_92AF310A7AD5__INCLUDED_) -#define AFX_WSTRINGMEMORY_H__79693029_4788_4099_9A97_92AF310A7AD5__INCLUDED_ - -#include - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -class WStringProxy; - -class WStringMemory -{ -public: - - static WStringProxy * AllocString(const wchar_t *text, size_t size); - static WStringProxy * AllocProxy(const WStringProxy &templateProxy); - static void FreeProxy(WStringProxy *proxy); - static void LockProxy(WStringProxy *proxy); - static void UnlockProxy(WStringProxy *proxy); - - //Releases extra memory leaved for future fast allocations - static void FreeExtra(); - - //Support addref for proxy - Single- or Multi- thread support - static void AddRefProxy(WStringProxy *proxy); - - //Support addref for proxy - Single- or Multi- thread support - //returns true, when counter reached zero - static bool ReleaseRefProxy(WStringProxy *proxy); - - ///Gets statistics about memory manager - /** - @param details optional pointer to 32 size_t items. Array will be filled - with sizes of each string fastalloc group. - @return function returns total bytes allocated for string fast allocation. - (This number should be below 256KB) - */ - static size_t GetStatistics(size_t *details=NULL); - - ///Function allows sharing the strings - /** This function is called by WString::Share function - Function mark proxy shared. If string is same as shared, - it returns pointer to proxy with proxy of string that contains - the same text. - Read description of WString::Share for more informations - */ - static WStringProxy *ShareString(WStringProxy *proxy); - - ///Function disables sharing of the string - static void UnshareString(WStringProxy *proxy); - -}; - - - -#endif // !defined(AFX_WSTRINGMEMORY_H__79693029_4788_4099_9A97_92AF310A7AD5__INCLUDED_) diff --git a/DDLReader/WStringProxy.cpp b/DDLReader/WStringProxy.cpp deleted file mode 100644 index e98b577..0000000 --- a/DDLReader/WStringProxy.cpp +++ /dev/null @@ -1,185 +0,0 @@ -// WStringProxy.cpp: implementation of the WStringProxy class. -// -////////////////////////////////////////////////////////////////////// - - -#include "WStringProxy.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -/** Funkce vytvo�� transitivnďż˝ uzďż˝vďż˝r. -to znamenďż˝, ďż˝e zru�� vďż˝echny zďż˝etďż˝zenďż˝ redirecty. -*/ -WStringProxy *WStringProxy::TransitivniUzaver() -{ - if (_operation==OpSubstr && _offset==0 && _stringSize==_baseString->GetLength()) - { - WStringProxy *next=_baseString->TransitivniUzaver(); - if (next==NULL) return this; - next->AddRef(); - _baseString->Release(); - _baseString=next; - return next; - } - return NULL; -} - -/** Main render procedure -It creates allocates buffer proxy and renders tree into it -Then turns self into redirect proxy a redirect self into newly created string -Rerurns pointer to newly created proxy -*/ -WStringProxy *WStringProxy::RenderString() -{ - if (_operation==OpMemBlck) return this; - - WStringProxy *pp=TransitivniUzaver(); - if (pp!=NULL) return pp->_baseString->RenderString(); - - WStringProxy *newProxy=WStringMemory::AllocString(NULL,_stringSize); - wchar_t *renderPtr=const_cast(newProxy->GetStringFromMemBlock()); - - RenderStringToBuffer(renderPtr); - - newProxy->AddRef(); - this->~WStringProxy(); - _operation=OpSubstr; - _offset=0; - _baseString=newProxy; - - return newProxy; -} - -/** Function renders simple effect into buffer -Function needs buffer with nul terminated string -*/ -void WStringProxy::RenderSimpleEffect(wchar_t *renderPtr) -{ - assert(_operation==OpEffect); - switch (_effect) - { - case EfLower: wcslwr(renderPtr);break; - case EfUpper: wcsupr(renderPtr);break; - case EfReverse: wcsrev(renderPtr);break; - } - -} - -/** Light phase of rendering. Used to render string that is not -created from substring. This part is optimized for concat and user effects -When substring must be rendered, function call RenderStringToBufferSubstr to -render substring. -*/ -void WStringProxy::RenderStringToBuffer(wchar_t *renderPtr) -{ - WStringMemory::LockProxy(this); - switch (_operation) - { - case OpConcat: - _baseString->RenderStringToBuffer(renderPtr); - _secondString->RenderStringToBuffer(renderPtr+_baseString->GetLength()); - break; - case OpSubstr: - { - _baseString->RenderStringToBufferSubstr(renderPtr,_offset,GetLength()); - } - break; - case OpMemBlck: - { - const wchar_t *str=GetStringFromMemBlock(); - wcsncpy(renderPtr,str,_stringSize); - } - break; - case OpEffect: - { - uint32_t offset=0; - renderPtr[_stringSize]=0; //we can append zero, because right side of string is not yet rendered - //if this is end of string, one extra character for zero is also allocated. - //efect functions can rely on it. - if (_blockData2>=256) offset=_userEffect->PreRenderString(renderPtr,_baseString->GetLength()); //call prerender to prepare begin of buffer - _baseString->RenderStringToBuffer(renderPtr+offset); //render string to rest of buffer - if (_blockData2>=256) _userEffect->RenderString(renderPtr,_baseString->GetLength()); //apply effect to buffer - else RenderSimpleEffect(renderPtr); - } - break; - }; - WStringMemory::UnlockProxy(this); -} - -/** -Deep phase of rendering. Function can render substrings, or render substring of two -concated strings. Function can also perform partial effect on string. Function cannot -handle partial user effect, so this effects are converted to things strings. -*/ -void WStringProxy::RenderStringToBufferSubstr(wchar_t *renderPtr, size_t offset, size_t size) -{ - WStringMemory::LockProxy(this); - switch (_operation) - { - case OpConcat: - { - //process substring of concat - //count characters in buffer - size_t rendered; - //when string starts in left string - if (_baseString->GetLength()>offset) - { - //calculate total characters that may be rendered - rendered=_baseString->GetLength()-offset; - //but limit it to request size - if (rendered>size) rendered=size; - //render substring into buffer - _baseString->RenderStringToBufferSubstr(renderPtr,offset,rendered); - } - else - //no character has been rendered - rendered=0; - - //there is still characters remained to render. We will take it from second string - if (size-rendered>0) - { - if (offset>_baseString->GetLength()) offset-=_baseString->GetLength(); - else offset=0; - _secondString->RenderStringToBufferSubstr(renderPtr+rendered,offset,size-rendered); - } - } - break; - case OpSubstr: - { //rendering substrings is very easy - offset+=_offset; //add offset of substring - assert(offset+size<=GetLength()); //check length - //render substring - this->RenderStringToBufferSubstr(renderPtr,offset,size); - } - break; - case OpMemBlck: - { - //rendering from memory, final stop in recursion - //Get pointer string - const wchar_t *str=GetStringFromMemBlock(); - //copy substring from string into render buffer - wcsncpy(renderPtr,str+offset,size); - } - break; - case OpEffect: - if (_blockData2>=256) //interface cannot handle partial rendering - { - RenderString(); //convert proxy to simple redirect and render it - RenderStringToBufferSubstr(renderPtr,offset,size); //now we are able to cut out part - } - else - { - //all standard effects maps string 1:1 - //first get content of substring into buffer - _baseString->RenderStringToBufferSubstr(renderPtr,offset,size); - //we can append zero, because right side of string is not yet rendered - renderPtr[size]=0; - //process effect on target - RenderSimpleEffect(renderPtr); - } - break; - }; - WStringMemory::UnlockProxy(this); -} \ No newline at end of file diff --git a/DDLReader/WStringProxy.h b/DDLReader/WStringProxy.h deleted file mode 100644 index 0bf63ed..0000000 --- a/DDLReader/WStringProxy.h +++ /dev/null @@ -1,232 +0,0 @@ -// WStringProxy.h: interface for the WStringProxy class. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_WSTRINGPROXY_H__863ADE82_7789_4E54_BE7D_B8F0740FD81B__INCLUDED_) -#define AFX_WSTRINGPROXY_H__863ADE82_7789_4E54_BE7D_B8F0740FD81B__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "WStringMemory.h" -#include "IWStringEffect.h" -#include -#include -#include -#include - -/* -List of proxy types - -Memory_Proxy _operation=OpMemBlck - _blockData==0 and _blockData2==0 - or - _blockData!=0 and _blockData2!=0 - (_redirect - debug pointer) - (_blockData - 1) - -Proxy_Const _operation=OpMemBlck - _redirect - pointer to string - _blockData2=0 - -Proxy_Shared _operation=OpMemBlck - _redirect - pointer to string - _blockData2=2; - -Proxy_Immediate _operation=OpMemBlck - _blockData>0xFFFF - _blockData2>0xFFFF - both parameters are used by immediate memory manager - -Proxy_Concat _operation=OpConcat - _baseString and _secondString is valid - -Proxy_Link _operation=OpSubstr - _baseString is valid - _stringSize==_baseString->_stringSize - _offset==0; - NOTE: Can be used without rendering - -Proxy_RightSub _operation=OpSubstr - _baseString is valid - _offset<=_baseString->_stringSize - _stringSize==_baseString->_stringSize-_offset - NOTE: Can be used without rendering - -Proxy_SubString _operation=OpSubstr - _baseString is valid - _offset<=_baseString->_stringSize - _stringSize<=_baseString->_stringSize-_offset - -Proxy_Effect _operation=OpEffect - _baseString is valid - _stringSize=_baseString->_stringSize - _effect defining effect code < 0xFFFF - -Proxy_UserEffect _operation=OpEffect - _baseString is valid - _stringSize=_baseString->_stringSize - _effect>0xFFFF - _userEffect defining pointer to effect interface - -*/ -class WStringProxy -{ -public: - enum Operation - { - OpConcat=0, //proxy contains two links to concat it - OpSubstr=1, //proxy contains link to another proxy and specified substring - OpMemBlck=-2, //proxy contains informations about following string - OpEffect=-1, //proxy describing some efect with string - }; - - enum Effect - { - EfLower, //effect lower case - EfUpper, //effect upper case - EfReverse, //effect reverse string - }; -public: - - uint32_t _refCount; //reference count - uint32_t _stringSize:30; //string size in characters (maximum size 1073741823 characters ~ 2147483646 bytes) - Operation _operation:2; //operation with string or proxy type - - union - { - WStringProxy *_baseString; //pointer to next proxy referenced by this proxy - uint32_t _blockData; //user defined block data for OpMemBlock proxy type - const wchar_t *_redirect; //used for OpMemBlock, when _blockData2 is zero. - }; - - union - { - WStringProxy *_secondString; //pointer to second string for OpConcat - uint32_t _offset; //offset of substring for OpSubstr - Effect _effect; //effect selector for OpEffect - IWStringEffect *_userEffect; //user effect defined by IWStringEffect interface (valid when _effect is invalid) - uint32_t _blockData2; //user defined block data for OpMemBlock proxy type - exception: if this value is zero, member _redirect is valid - - }; - - - void RenderStringToBuffer(wchar_t *renderPtr); - void RenderStringToBufferSubstr(wchar_t *renderPtr, size_t offset, size_t size); - WStringProxy *TransitivniUzaver(); - void RenderSimpleEffect(wchar_t *renderPtr); - -public: - WStringProxy():_refCount(0),_operation(OpSubstr),_stringSize(0),_baseString(0),_secondString(0) {} //inicializes empty string proxy - - WStringProxy(WStringProxy *other): - _refCount(0), - _stringSize(other->GetLength()), - _baseString(other), - _operation(OpSubstr), - _offset(0) - {_baseString->AddRef();} - - WStringProxy(WStringProxy *other, uint32_t offset, uint32_t size): - _refCount(0), - _stringSize(size), - _baseString(other), - _operation(OpSubstr), - _offset(offset) - {_baseString->AddRef();} - - WStringProxy(WStringProxy *a, WStringProxy *b): - _refCount(0), - _stringSize(a->GetLength()+b->GetLength()), - _baseString(a), - _operation(OpConcat), - _secondString(b) - {_baseString->AddRef();_secondString->AddRef();} - - WStringProxy(WStringProxy *a, Effect effect): - _refCount(0), - _stringSize(a->GetLength()), - _baseString(a), - _operation(OpEffect), - _effect(effect) - {_baseString->AddRef();} - - WStringProxy(WStringProxy *a, IWStringEffect *userEffect): - _refCount(0), - _stringSize(a->GetLength()+userEffect->GetEffectExtraSize(a->GetLength())), - _baseString(a), - _operation(OpEffect), - _userEffect(userEffect) - {_baseString->AddRef();} - - WStringProxy(uint32_t size, uint32_t user1, uint32_t user2): - _refCount(0), - _stringSize(size), - _operation(OpMemBlck), - _blockData(user1), - _blockData2(user2) - {} - - WStringProxy(const wchar_t *imText): - _refCount(0), - _stringSize(wcslen(imText)), - _redirect(imText), - _blockData2(0), - _operation(OpMemBlck) - {} - - WStringProxy(const WStringProxy &other) - { - memcpy(this,&other,sizeof(*this)); - if (_operation!=OpMemBlck) _baseString->AddRef(); - if (_operation==OpConcat) _secondString->AddRef(); - } - - WStringProxy& operator=(const WStringProxy &other) - { - WStringProxy::~WStringProxy(); //call destructor to destruct current proxy - memcpy(this,&other,sizeof(*this)); //construct new proxy from template - if (_operation!=OpMemBlck) _baseString->AddRef(); - if (_operation==OpConcat) _secondString->AddRef(); - } - - WStringProxy *RenderString(); - - ~WStringProxy() - { - if (_operation!=OpMemBlck) _baseString->Release(); - if (_operation==OpConcat) _secondString->Release(); - } - - - uint32_t GetLength() {return _stringSize;} - void AddRef() {if (this) WStringMemory::AddRefProxy(this);} - void Release() {if (this) if (WStringMemory::ReleaseRefProxy(this)) WStringMemory::FreeProxy(this);} - - const wchar_t *GetString() - { - if (_operation==OpMemBlck) return (const wchar_t *)(this+1); - WStringProxy *p=RenderString(); - (*this)=*p; - return (const wchar_t *)(p+1); - } - - const wchar_t *GetStringFromMemBlock() - { - assert(_operation==OpMemBlck); - if (_blockData2==0 && _redirect!=NULL) return _redirect; - else return (const wchar_t *)(this+1); - } - - bool IsShared() {return _refCount>1;} - - void RecalcLength() - { - const wchar_t *str=GetStringFromMemBlock(); - _stringSize=wcslen(str); - } - -}; - -#endif // !defined(AFX_WSTRINGPROXY_H__863ADE82_7789_4E54_BE7D_B8F0740FD81B__INCLUDED_) diff --git a/DDLReader/res/DDLReader.ico b/DDLReader/res/DDLReader.ico deleted file mode 100644 index 7eef0bc..0000000 Binary files a/DDLReader/res/DDLReader.ico and /dev/null differ diff --git a/DDLReader/res/DDLReader.rc2 b/DDLReader/res/DDLReader.rc2 deleted file mode 100644 index 35693f0..0000000 --- a/DDLReader/res/DDLReader.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// DDLREADER.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/DDLReader/resource.h b/DDLReader/resource.h deleted file mode 100644 index 2625141..0000000 --- a/DDLReader/resource.h +++ /dev/null @@ -1,49 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by DDLReader.rc -// -#define IDM_ABOUTBOX 0x0010 -#define IDD_ABOUTBOX 100 -#define IDS_ABOUTBOX 101 -#define IDD_DDLREADER_DIALOG 102 -#define IDS_FILEOPENFAILED 102 -#define IDC_HEADGROUP 103 -#define IDC_HEADFNAME 104 -#define IDC_HEADSIZE 105 -#define IDC_HEADOFFSET 106 -#define IDS_DDLFILTER 107 -#define IDC_GROUP_GRAPHICS 108 -#define IDC_GROUP_SOUNDS 109 -#define IDC_GROUP_FONTS 110 -#define IDC_GROUP_BASIC 111 -#define IDC_GROUP_ITEMS 112 -#define IDC_GROUP_MONSTERS 113 -#define IDC_GROUP_DIALOGS 114 -#define IDC_GROUP_UNSPECIFIED 115 -#define IDC_GROUP_UNKNOWN 116 -#define IDS_UNABLETOCREATEFILE 117 -#define IDS_UNABLETOEXTACTDATA 118 -#define IDR_MAINFRAME 128 -#define IDD_PROGRESS 129 -#define IDD_EXPORTING 129 -#define IDC_FILELIST 1001 -#define IDC_FOLDER 1002 -#define IDC_BROWSE 1003 -#define IDC_EXPORT 1004 -#define IDC_POPISEK 1005 -#define IDC_DDLFILE 1006 -#define IDC_DDLBROWSE 1007 -#define IDC_PROGRESS 1008 -#define IDC_NAME 1009 -#define IDC_BUTTON1 1010 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 130 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1011 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/FONT/BIG.FON b/FONT/BIG.FON deleted file mode 100644 index 8034176..0000000 Binary files a/FONT/BIG.FON and /dev/null differ diff --git a/FONT/BIG2.FON b/FONT/BIG2.FON deleted file mode 100644 index 65524ae..0000000 Binary files a/FONT/BIG2.FON and /dev/null differ diff --git a/FONT/BOLDCZ.FON b/FONT/BOLDCZ.FON deleted file mode 100644 index be5e16c..0000000 Binary files a/FONT/BOLDCZ.FON and /dev/null differ diff --git a/FONT/BROOKLIN.FON b/FONT/BROOKLIN.FON deleted file mode 100644 index 733c5e5..0000000 Binary files a/FONT/BROOKLIN.FON and /dev/null differ diff --git a/FONT/EUROMODE.FON b/FONT/EUROMODE.FON deleted file mode 100644 index 398e4db..0000000 Binary files a/FONT/EUROMODE.FON and /dev/null differ diff --git a/FONT/FONT4X8.FON b/FONT/FONT4X8.FON deleted file mode 100644 index f918236..0000000 Binary files a/FONT/FONT4X8.FON and /dev/null differ diff --git a/FONT/FONT5X8.FON b/FONT/FONT5X8.FON deleted file mode 100644 index d39b3e2..0000000 Binary files a/FONT/FONT5X8.FON and /dev/null differ diff --git a/FONT/FONT6X9.FON b/FONT/FONT6X9.FON deleted file mode 100644 index ddc1006..0000000 Binary files a/FONT/FONT6X9.FON and /dev/null differ diff --git a/FONT/IKONES.FON b/FONT/IKONES.FON deleted file mode 100644 index 36a9495..0000000 Binary files a/FONT/IKONES.FON and /dev/null differ diff --git a/FONT/KNIHA.FON b/FONT/KNIHA.FON deleted file mode 100644 index 371eba4..0000000 Binary files a/FONT/KNIHA.FON and /dev/null differ diff --git a/FONT/SADA16.FON b/FONT/SADA16.FON deleted file mode 100644 index 4ff2637..0000000 Binary files a/FONT/SADA16.FON and /dev/null differ diff --git a/FONT/SADA7.FON b/FONT/SADA7.FON deleted file mode 100644 index f548b55..0000000 Binary files a/FONT/SADA7.FON and /dev/null differ diff --git a/FONT/TIMESBIG.FON b/FONT/TIMESBIG.FON deleted file mode 100644 index 0b1a6bd..0000000 Binary files a/FONT/TIMESBIG.FON and /dev/null differ diff --git a/FONT/TIMESBIT.FON b/FONT/TIMESBIT.FON deleted file mode 100644 index 4d7f635..0000000 Binary files a/FONT/TIMESBIT.FON and /dev/null differ diff --git a/FONT/TIMESE.FON b/FONT/TIMESE.FON deleted file mode 100644 index 460b558..0000000 Binary files a/FONT/TIMESE.FON and /dev/null differ diff --git a/FONT/TINY.FON b/FONT/TINY.FON deleted file mode 100644 index 371eba4..0000000 Binary files a/FONT/TINY.FON and /dev/null differ diff --git a/FONT/ikony.fon b/FONT/ikony.fon deleted file mode 100644 index 12f8f96..0000000 Binary files a/FONT/ikony.fon and /dev/null differ diff --git a/INST/SETUP.C b/INST/SETUP.C deleted file mode 100644 index d27dfc8..0000000 --- a/INST/SETUP.C +++ /dev/null @@ -1,1427 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "setup.h" -#include "setvideo.h" -#include "setuplib.h" -#include "setupcpy.h" - -#define TEST_MUSIC "\\SNDTEST.MUS" -#define SETUP_BATCH "SETUP.BAT" -#define _SOURCE_ copy_source_path -#define ER_NAME "c:\\skeldal.!!!" -#define VEL_RAMECEK 8 - -#define VMODE "VMODE" -#define SOUND_DEVICE "SOUND_DEVICE" - -#define SETUP_NAME "SETUP.EXE" - -word *ramecky[VEL_RAMECEK]; - -#define SKELDAL "SKELDAL" -#define SKELDAL_INI SKELDAL".INI" -#define CONCAT(t,s1,s2) strcat(strcpy(t=alloca(strlen(s1)+strlen(s2)+1),s1),s2) -void *bbutt; - -char *copy_source_path; -char *test_sound_name; -char *program_data_path=NULL; -char setup_mode=0; - -char *pgm_name; - -TSTR_LIST setup_ini; - -typedef struct tsound - { - int device,port,irq,dma; - }TSOUND; - - -FILE *ini; -word *vga_font; -word *icones; -word icone_color[7]={0x2108,0x7fff,0x000f,0x4210,0x6f7b}; -//static char target_path[256]="E:\HRY\SKELDAL\"; -char *source_path; -char target_path[2049]; -static TSOUND sound_info={0,0,0,0}; -static int vmode=0; -static char mixer_running=0; -static char back=0; -static char install_type; -static long install_sizes[3]; -static long maxcopy=1; -TSTR_LIST handbook=NULL; -TSTR_LIST dirlist=NULL; -TSTR_LIST disklist=NULL; -int win_handbook=-1; -char rescue_mode=0; -char *inifile=NULL; - -#pragma off (stack_checking) - -static char home_path(char *source_path) - { - unsigned x,z; - _dos_setdrive(source_path[0]-'@',&x); - _dos_getdrive(&z); - if (z!=source_path[0]-'@') return 1; - chdir("\\"); - chdir(source_path); - return 0; - } -char error_device(word a,char b,char c) - { - a,b,c; - - errno=-1; - return _ERR_FAIL; - } - -int create_er_file() - { - FILE *f; - if (!access(ER_NAME,F_OK)) return 0; - - f=fopen(ER_NAME,"w"); - fprintf(f,"7925536\n"); - fprintf(f,"Toto je zachranny soubor pro instalacni program ke hre BRANY SKELDALU. Pokud se posledni instalace nezdarila, nemazte tento soubor!"); - fclose(f); - return 1; - } - -void remove_er_file() - { - FILE *f; - - f=fopen(ER_NAME,"r"); - if (f!=NULL) - { - long l=0; - fscanf(f,"%d",&l); - fclose(f); - if (l==7925536) remove(ER_NAME); - } - } - - -static conv_ramecek(word *ram) - { - int i; - word xs,ys; - char *ptr; - word *targ; - - xs=ram[0]; - ys=ram[1]/VEL_RAMECEK; - ptr=(char *)(ram+3+256); - for(i=0;i"); - } - for(i=0;i"); - set_value(0,20,""); - } - else - { - sprintf(s,"VESA %d.%02d",si.version/256,si.version%256); - set_value(0,10,s); - set_value(0,20,si.oemstr); - } - set_value(0,30,gr_mody[vmode]);do_events(); - sound_detect(&sound_info.device,&sound_info.port,&sound_info.dma,&sound_info.irq); - set_value(0,40,device_name(sound_info.device)); - if (sound_info.device==DEV_WSS || sound_info.device==DEV_ULTRA) - sprintf(s,"Port %X Dma %X",sound_info.port,sound_info.dma); - else sprintf(s,"Port %X Dma %X Irq %X",sound_info.port,sound_info.dma,sound_info.irq); - set_value(0,50,s); - set_value(0,60,get_cdrom()); - set_enable(0,6,1); - set_enable(0,5,1); - } - -static EVENT_PROC(esc_mode2) - { - GET_USER_PTR(); - WHEN_MSG(E_KEYBOARD) - { - if (GET_DATA(char)==27) - { - donegr(); - if (vmode==0)initgr_low();else initgr_spec(vmode); - zobraz_mysku(); - redraw_desktop(); - goto_control(0); - terminate_gui(); - } - } - } - -static char test_mode() - { - char i,j,c; - - if (msg_box("Test grafiky",'\x1', - "Instalďż˝tor nynďż˝ vyzkou�� zvolenďż˝ grafickďż˝ reďż˝im. " - "Pokud obrazovka zďż˝stane ďż˝ernďż˝, nebo zobrazďż˝ nesmysly, stisknďż˝te " - "ESC a instalďż˝tor obnovďż˝ pďż˝vodnďż˝ reďż˝im.","Start","Zruďż˝it",NULL)==2) return 0; - send_message(E_ADD,E_KEYBOARD,esc_mode2); - donegr(); - i=initgr_spec(f_get_value(0,9)); - if (!i) - { - zobraz_mysku(); - redraw_desktop(); - } - if (!i && (j=msg_box("Test grafiky",'\x2',"Vidiďż˝ prostďż˝edďż˝ instalďż˝toru sprďż˝vnďż˝?","Ano","Ne",NULL))==1) - { - vmode=f_get_value(0,9); - if (vmode==0) initgr_low(); - zobraz_mysku(); - c=1; - } - else - { - c_set_value(0,9,vmode); - if (j!=0) - { - donegr(); - if (vmode==0) initgr_low();else initgr_spec(vmode); - zobraz_mysku(); - redraw_desktop(); - } - c=0; - } - send_message(E_DONE,E_KEYBOARD,esc_mode2); - return c; - } - -static TSTR_LIST video_ls=NULL; - -static void create_video_ls() - { - int i; - if (video_ls==NULL) - { - video_ls=create_list(3); - for(i=0;i<3;i++) str_add(&video_ls,gr_mody[i]); - } - } - -static void select_vga() - { - default_font=&font6x9; - def_dialoge(20,300,156,156,"Kvalita grafiky",2); - define(9,0,20,156,80,0,listbox,video_ls,0x03ff,0);c_default(vmode); - property(NULL,vga_font,NULL,WINCOLOR); - define(20,38,5,80,20,3,button,"Zmďż˝nit teďż˝");on_control_change(test_mode); - property(bbutt,NULL,NULL,BUTTONCOLOR); - redraw_window(); - } - - -static void change_dma() - { - int i,j; - - i=f_get_value(0,30); - j=f_get_value(0,35)+3; - if (o_aktual->id==30) - { - c_set_value(0,30,i); - c_set_value(0,35,i-3); - } - else - { - c_set_value(0,30,j); - c_set_value(0,35,j-3); - } - } - -static void select_mode_win() - { - def_dialoge(224,270,192,156,"Instalovat",2); - default_font=&font6x9; - define(10,30,40,132,30,0,button,"Automaticky");property(bbutt,NULL,NULL,BUTTONCOLOR);on_control_change(terminate_gui); - define(30,30,80,132,30,0,button,"Podle p��nďż˝");property(bbutt,NULL,NULL,BUTTONCOLOR);on_control_change(terminate_gui); - define(40,50,15,92,20,3,button,"Konec");property(bbutt,NULL,NULL,BUTTONCOLOR);on_control_change(stop_copy); - redraw_window(); - } - -static void select_mode_win_setup() - { - def_dialoge(224,270,192,156,"Moďż˝nosti:",2); - default_font=&font6x9; - define(10,30,40,132,30,0,button,"Nastavenďż˝");property(bbutt,NULL,NULL,BUTTONCOLOR);on_control_change(terminate_gui); - define(30,30,80,132,30,0,button,"Odinstalovďż˝nďż˝");property(bbutt,NULL,NULL,BUTTONCOLOR);on_control_change(terminate_gui); - define(40,50,15,92,20,3,button,"Konec");property(bbutt,NULL,NULL,BUTTONCOLOR);on_control_change(stop_setup); - redraw_window(); - } - - - -static void device_select() - { - int i,p; - i=f_get_value(0,9); - set_enable(0,40,i!=DEV_ULTRA && i!=DEV_WSS && i!=DEV_NOSOUND && i!=DEV_DAC); - p=i==DEV_SB16 || i==DEV_ULTRA; - set_enable(0,35,p); - if (p==0) - { - c_set_value(0,30,1); - c_set_value(0,35,1-3); - } - set_enable(0,20,i!=DEV_NOSOUND); - set_enable(0,30,i!=DEV_NOSOUND && i!=DEV_DAC); - set_enable(0,50,i!=DEV_NOSOUND); - } - -static void device_select2() - { - int i; - - device_select(); - i=f_get_value(0,9); - if (i==DEV_DAC) - { - char c; - def_dialoge(270,240,100,100,device_name(i),3); - define(10,10,25,60,40,0,radio_butts,3,"LPT 1","LPT 2","PC Speaker");c_default(0); - define(20,10,5,80,20,2,button,"Ok");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(terminate_gui); - redraw_window(); - escape(); - c=f_get_value(0,10); - close_current(); - if (c==0) set_value(0,20,"378");else - if (c==1)set_value(0,20,"278"); - else set_value(0,20,"042"); - } - if (i==DEV_SB16 || i==DEV_ULTRA || i==DEV_SBPRO || i==DEV_SB20 || i==DEV_SB10) - set_value(0,20,"220"); - if (i==DEV_WSS) set_value(0,20,"530"); - } - -static void select_sound(); -static void detect_sound() - { - if (msg_box("Rozpoznďż˝nďż˝ zvukovďż˝ karty",'\x2',"Opravdu chceďż˝ nechat rozpoznat zvukovou kartu? Na nďż˝kterďż˝ch po��ta��ch m��e automatickďż˝ rozpoznďż˝vďż˝nďż˝ zpďż˝sobit zatuhnutďż˝ po��taďż˝e.","Ano","Ne",NULL)==2) return; - if (mixer_running) stop_mixing(); - mixer_running=0; - set_enable(0,70,mixer_running); - sound_detect(&sound_info.device,&sound_info.port,&sound_info.dma,&sound_info.irq); - close_current(); - select_sound(); - } - -static int sound_win=-1; - -static char sound_scan() - { - char buffer[20]; - char dmas[]={0,1,3,5,6,7}; - char irqs[]={2,3,5,7}; - - sound_info.device=f_get_value(sound_win,9); - if (sound_info.device!=DEV_NOSOUND) - { - if (sound_info.device==DEV_DAC) - if (msg_box("Varovďż˝nďż˝!",'\x1',"Vybranďż˝ zvukovďż˝ za��zenďż˝ pou��vďż˝ nestandardnďż˝ p��stupy a vyu��vďż˝ " - "nďż˝kterďż˝ch skrytďż˝ch trikďż˝ systďż˝mu. Na nďż˝kterďż˝ch po��ta��ch nemusďż˝ pracovat sprďż˝vnďż˝. " - "Toto za��zenďż˝ nedok��e pracovat pod WINDOWS95 nebo jinďż˝m OS vďż˝jma DOSu. " - "Pro zrychlenďż˝ prďż˝ce odinstalujte ze systďż˝mu jakďż˝koliv EMM manager (EMM386, QEMM, apod.) " - "Chcete pokraďż˝ovat?","Ano","Ne",NULL)==2) return 1; - get_value(sound_win,20,buffer); - if (sscanf(buffer,"%x",&sound_info.port)!=1) - { - msg_box("Pozor!",'\x1',"Mus�� vyplnit sprďż˝vnďż˝ Port","Ok",NULL); - return 1; - } - } - sound_info.dma=dmas[f_get_value(sound_win,30)]; - sound_info.irq=irqs[f_get_value(sound_win,40)]; - return 0; - } - - -static void test_sound() - { - if (mixer_running) stop_mixing(); - if (sound_scan()) return; - set_mixing_device(sound_info.device,22050,sound_info.port,sound_info.dma,sound_info.irq); - start_mixing(); - change_music(test_sound_name); - mix_back_sound(2); - mix_back_sound(0); - mixer_running=1; - set_enable(0,70,mixer_running); - } - -static void stop_sound() - { - if (mixer_running) - { - stop_mixing(); - mixer_running=0; - set_enable(sound_win,70,mixer_running); - } - } - -void select_sound() - { - TSTR_LIST ls; - int i; - char buff[30]; - - ls=create_list(8); - default_font=&font6x9; - for(i=0;i<8;i++) str_add(&ls,device_name(i)); - str_replace(&ls,0,""); - sound_win=def_dialoge(200,300,300,156,"Zvukovďż˝ karta",2); - define(9,2,20,170,85,0,listbox,ls,0x03ff,0);c_default(sound_info.device);on_control_change(device_select2); - property(def_border(0,0x4210),vga_font,NULL,WINCOLOR); - define(-1,180,20,1,1,0,label,"Port:"); - define(20,10,20,30,12,1,input_line,3);property(def_border(0,0x4210),vga_font,NULL,WINCOLOR); - set_default(itoa(sound_info.port,buff,16)); - define(-1,180,40,1,1,0,label,"DMA:"); - i=sound_info.dma;i-=(i>2)+(i>4); - define(30,40,40,30,30,1,radio_butts,3,"0","1","3");c_default(i);on_control_change(change_dma); - define(35,10,40,30,30,1,radio_butts,3,"5","6","7");c_default(i-3);on_control_change(change_dma); - define(-1,180,80,1,1,0,label,"IRQ:"); - i=sound_info.irq;i-=2*(i>1)+(i>4)+(i>6); - define(40,40,80,30,40,1,radio_butts,4,"2","3","5","7");c_default(i); - define(50,10,5,80,20,2,button,"Test");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(test_sound); - define(60,100,5,80,20,2,button,"Rozpoznat");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(detect_sound); - define(70,190,5,80,20,2,button,"Stop");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(stop_sound); - redraw_window(); - set_enable(0,70,mixer_running); - device_select(); - } - -static void back_start() - { - back=1; - stop_sound(); - sound_scan(); - while (waktual!=NULL) close_current(); - terminate_gui(); - } - -static void control_window(void *forward,void *back,void *help); -static void control_next1(); - -static void control_back1() - { - close_current(); - get_value(0,60,target_path); - while (waktual!=NULL) close_current(); - exit_wait=0; - select_vga(); - select_sound(); - control_window(control_next1,back_start,open_help); - } - -static trace_chdir(char *what) - { - char *c; - char *d; - - c=alloca(strlen(what)+1); - strcpy(c,what); - d=strrchr(c,'\\'); - while (d!=NULL) - { - if (chdir(c)==0) - { - home_path(c); - return; - } - *d=0; - d=strrchr(c,'\\'); - } - strcat(c,"\\"); - home_path(c); - } - - -void static show_space(char device) - { - char buff[100]; - static long lastvalue; - static char lastdevice; - - device=toupper(device); - if (device>='A' && device<='Z') - { - if (device!=lastdevice) lastvalue=get_disk_free(device-'@')/1024; - sprintf(buff,"Na disku %c: je volnďż˝ch %d Kb",device,lastvalue); - lastdevice=device; - set_value(0,80,buff); - } - } - -static open_load_window() - { - char c; - get_value(0,60,target_path); - trace_chdir(target_path); - getcwd(target_path,2047); - load_window(); - escape(); - home_path(source_path); - c=o_aktual->id==150; - if (c) - { - get_value(0,10,target_path); - } - close_current(); - if (c) - set_value(0,60,target_path); - else - get_value(0,60,target_path); - show_space(target_path[0]); - } - -static char create_ini(char *path,char *name) - { - - if (inifile!=NULL) - { - fclose(ini); - remove(inifile); - free(inifile); - } - inifile=NewArr(char,strlen(path)+strlen(name)+2); - sprintf(inifile,"%s\\%s",path,name); - ini=fopen(inifile,"w"); - if (ini==NULL) return 1; - add_to_list(inifile); - fprintf(ini,"vmode %d\n", vmode); - fprintf(ini,"sound_device %d %x %d %d\n",sound_info.device,sound_info.port,sound_info.dma,sound_info.irq); - fprintf(ini,"sound_mixfreq 22049\n"); - fprintf(ini,"default_map lespred.map\n"); - fprintf(ini,"preload 1\n"); - fprintf(ini,"game_speed 5\n"); - return 0; - } - /* -static char create_setup_batch(char *path,char *name) - { - char *st; - FILE *batch; - - st=alloca(strlen(path)+strlen(name)+2); - sprintf(st,"%s\\%s",path,name); - batch=fopen(st,"w"); - if (batch==NULL) return 1; - fputs( - "@Echo off\n" - ":skok\n" - "Echo Vloz CD \"Brany Skeldalu\" do mechaniky\n" - "Echo a stiskni jakoukoliv klavesu. \n" - "Echo.\n" - "Echo Kombinace CNTR+C prerusi program....\n" - "Pause > NUL\n",batch); - fprintf(batch,"if not exist %s goto skok\n",pgm_name); - fprintf(batch,"%s -s \n",pgm_name); - fclose(batch); - return 0; - } - */ -static void close_ini() - { - if (ini!=NULL) fclose(ini); - } - -static void copy_self(char alloc) - { - static char *t; - - if (alloc) - { - t=NewArr(char,strlen(target_path)+strlen(SETUP_NAME)+2); - sprintf(t,"%s\\%s",target_path,SETUP_NAME); - cpy_file(pgm_name,t); - } - else free(t); - } - -static long self_size() - { - struct find_t f; - - _dos_findfirst(pgm_name,_A_NORMAL,&f); - return f.size; - } - -static void start_install() - { - long diskfree; - char error=0,autostart; - get_value(0,60,target_path); - if (find_object(waktual,70)!=NULL) autostart=f_get_value(0,70); else autostart=1; - strupper(target_path); - if (validate_path(target_path)==0) - { - msg_box("Cesta je ďż˝patnďż˝",'\x1',"Cesta s cďż˝lovďż˝m adres��em je chybnďż˝ zadďż˝na. Nepou��vejte dlouhďż˝ nďż˝zvy z WINDOWS 95!","OK",NULL); - return; - } - get_script(_SOURCE_,target_path); - switch (o_aktual->id) - { - case 10:install_type=INST_MIN;break; - case 20:install_type=INST_MED;break; - case 30:install_type=INST_MAX;break; - } - maxcopy=install_sizes[install_type]; - diskfree=get_disk_free(target_path[0]-'@'); - if (maxcopy>diskfree) - { - if (msg_box("Nedostatek mďż˝sta!",'\x1',"Instalďż˝tor vypo��tal, ďż˝e BS zaberou vďż˝ce mďż˝sta neďż˝ mďż˝te na svďż˝m disku. " - "Pokud vďż˝ak pou��vate komprimaďż˝nďż˝ program jako je tďż˝eba DRVSPACE, pak mohou bďż˝t ďż˝daje o " - "volnďż˝m mďż˝stu nepďż˝esne. I pďż˝es to, ďż˝e nenďż˝ volnďż˝ mďż˝sto chcete pokraďż˝ovat?","Ano","Ne",NULL)==2) return; - } - else if (maxcopy+1024*1024>diskfree) - { - if (msg_box("Mďż˝lo mďż˝sta",'\x2',"Po nainstalovďż˝nďż˝ by mďż˝lo zbďż˝t alespoďż˝ 1MB pro bďż˝h. Souďż˝asnďż˝ prostor" - "umo��uje hru nainstalovat, avďż˝ak hru nebude moďż˝nďż˝ spustit. Pokraďż˝ovat?","Ano","Ne",NULL)==2) return; - } - maxcopy=maxcopy<<1; - while (waktual!=NULL) close_current(); - cascade_mkdir(target_path); - if (create_ini(target_path,SKELDAL_INI)) - { - msg_box(PRG_HEADER,'\x1',"Nemohu vytvoďż˝it konfiguraďż˝nďż˝ soubor. Zkontroluj spravnost zďż˝pisu cesty","Ok",NULL); - clean_up(); - return; - } -// create_setup_batch(target_path,SETUP_BATCH); - display_progress(); - stop_sound(); - switch (install_type) - { - case INST_MIN:if (do_script(0) || do_script(-1) || do_script(-2) || do_script(-3)) error=1;break; - case INST_MED:if (do_script(0) || do_script(1) || do_script(-2) || do_script(-3)) error=1;break; - case INST_MAX:if (do_script(0) || do_script(1) || do_script(2) || do_script(3)) error=1; - break; - } - copy_self(1); - cpy_flush(); - copy_self(0); - close_ini(); - if (error) shutdown(),exit(1); - close_current(); - do_events(); - if (!autostart) msg_box("Hotovo",' ',"Hra 'Brďż˝ny Skeldalu' je ďż˝sp��nďż˝ nainstalovďż˝na. Spuďż˝tďż˝nďż˝ proveďż˝te z p��kazovďż˝ ��dky napsďż˝nďż˝m 'SKELDAL'","Konec",NULL); - purge_file_list(); - shutdown(); - home_path(target_path); - if (autostart) - { - puts("Chvilicku strpeni..."); - exit(254); - } - else exit(0); - } - -static EVENT_PROC (show_space_event) - { - OBJREC *o; - - o=(OBJREC *)user_ptr; - if (msg->msg==E_KEYBOARD || msg->msg==E_CURSOR_TICK) - { - char *c; - - c=o->data; - if (c[1]==':') - show_space(c[0]); - if (msg->msg==E_KEYBOARD) - *(char *)msg->data=toupper(*(char *)msg->data); - } - } - -static show_space_exit() - { - EVENT_MSG msg; - - msg.msg=E_KEYBOARD; - show_space_event(&msg,(void **)o_aktual); - } - - - -static void rozsah_window() - { - char buff[100]; - char *text="Velikost na HD zhruba %d KB"; - - exit_wait=0; - default_font=&font6x9; - def_dialoge(146,160,348,264,"Rozsah instalace",2); - define(10,10,30,70,30,0,button,"Minimďż˝lnďż˝");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(start_install); - define(-1,90,30,1,1,0,label,"Instaluje jen nejdďż˝leďż˝itďż˝j�� soubory na HD"); - define(-1,90,40,1,1,0,label,"Vďż˝e ostatnďż˝ se pak na��tďż˝ p��mo z CD"); - sprintf(buff,text,install_sizes[0]/1024); - define(-1,90,50,1,1,0,label,buff); - define(20,10,80,70,30,0,button,"Stďż˝ednďż˝");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(start_install); - define(-1,90,80,1,1,0,label,"Instaluje vďż˝echny datovďż˝ soubory na HD"); - define(-1,90,90,1,1,0,label,"Hudba a video se ďż˝tou p��mo z CD"); - sprintf(buff,text,install_sizes[1]/1024); - define(-1,90,100,1,1,0,label,buff); - define(30,10,130,70,30,0,button,"Maximďż˝lnďż˝");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(start_install); - define(-1,90,130,1,1,0,label,"Instaluje vďż˝e na v�� HD vďż˝etnďż˝ hudby"); - define(-1,90,140,1,1,0,label,"a videa. Z CD se nena��tďż˝ vďż˝bec nic."); - sprintf(buff,text,install_sizes[2]/1024); - define(-1,90,150,1,1,0,label,buff); - define(40,10,180,70,20,0,button,"Sloďż˝ka");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(open_load_window); - define(60,90,185,250,11,0,input_line,2048);property(def_border(1,0x4210),&font6x9,NULL,0x7fff); - set_default(target_path); - on_event(show_space_event);on_exit(show_space_exit); - define(70,40,220,200,10,0,check_box,"Po nainstalovďż˝nďż˝ hru automaticky spustit.");c_default(1); - define(80,10,10,250,11,2,view_line,100);set_default(""); - show_space(target_path[0]); - } - -static void automatic_window() - { - char buff[100]; - char *text="Hra zabere zhruba %d KB mďż˝sta"; - - exit_wait=0; - default_font=&font6x9; - def_dialoge(110,200,420,80,"Instalovat kam?",2); - define(40,10,33,70,15,0,button,"Najďż˝t");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(open_load_window); - define(60,90,35,310,11,0,input_line,2048);property(def_border(1,0x4210),&font6x9,NULL,0x7fff); - set_default(target_path); - on_event(show_space_event);on_exit(show_space_exit); - define(10,10,10,70,20,2,button,"Start");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(start_install); - define(20,90,10,70,20,2,button,"<< Zpďż˝t");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(back_start); - sprintf(buff,text,install_sizes[0]/1024); - define(90,180,20,200,10,2,view_line,100);set_default(buff); - define(80,180,10,200,10,2,view_line,100);set_default(""); - show_space(target_path[0]); - redraw_window(); - } - - - -static void control_next1() - { - sound_scan(); - while (waktual!=NULL) close_current(); - rozsah_window(); - control_window(NULL,control_back1,open_help); - } - -static void control_window(void *forward,void *back,void *help) - { - def_dialoge(524,300,96,156,"Moďż˝nosti",2); - define(10,8,30,80,20,0,button,"Dal�� >>");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(forward); - define(20,8,60,80,20,0,button,"<< Zpďż˝t");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(back); - define(30,8,90,80,20,0,button,"? Pomoc");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(help); - define(40,8,10,80,20,3,button,"Konec");property(bbutt,&font6x9,NULL,BUTTONCOLOR); - if (setup_mode) on_control_change(stop_setup);else on_control_change(stop_copy); - set_enable(0,10,forward!=NULL); - set_enable(0,20,back!=NULL); - set_enable(0,30,help!=NULL); - redraw_window(); - } - -static void run_setup() - { - int id; - - while (waktual!=NULL) close_current(); - get_script(_SOURCE_,""); - { - int minus[3]; - minus[1]=check_size(-2)+check_size(-3); - minus[0]=minus[1]+check_size(-1); - install_sizes[0]=check_size(0)+self_size(); - install_sizes[1]=install_sizes[0]+check_size(1); - install_sizes[2]=install_sizes[1]+check_size(2)+check_size(3); - install_sizes[0]+=minus[0]; - install_sizes[1]+=minus[1]; - id; - } - if (all_finder()) - { - char *c; - getcwd(&target_path,2047); - c=strchr(target_path,0); - c--; - if (*c=='\\') *c=0; - strcat(target_path,"\\"SKELDAL); - } - else - { - target_path[0]=select_disk()+'@'; - target_path[1]=':'; - target_path[2]='\\'; - strcpy(target_path+3,SKELDAL); - } - do - { - home_path(source_path); - back=0; - select_mode_win(); - about_window(); - id=o_aktual->id; - close_current(); - close_current(); - exit_wait=0; - if (id==10) - { - autodetect(); - automatic_window(); - } - if (id==30) - { - if (msg_box("Autodetekce?",'\x1',"Chcete nejprve provest autodetekci hardware?","Ano","Ne",NULL)==1) autodetect(); - select_vga(); - select_sound(); - control_window(control_next1,back_start,open_help); - } - if (id!=40) escape(); - } - while (back); - } - -static void save_ini() - { - char c[50]; - char d; - char err=1; - - if (sound_scan()) return; - d=msg_box("Potvrzenďż˝?",'\x2',"Chceďż˝ zapsat zmďż˝ny do konfiguraďż˝nďż˝ho souboru hry?","Ano","Ne","Zruďż˝it",NULL); - if (d==3) return; - if (d==1) - { - sprintf(c,"%d %x %d %d",sound_info.device, - sound_info.port, - sound_info.dma, - sound_info.irq); - add_field_txt(&setup_ini,SOUND_DEVICE,c); - add_field_num(&setup_ini,VMODE,vmode); - home_path(target_path); - err=save_config(setup_ini,SKELDAL_INI); - } - shutdown(); - home_path(target_path); - switch (err) - { - case -1:puts("Pri ukladani se objevila neocekavana chyba. Soubor "SKELDAL_INI" nebyl ulozen");break; - case 0:puts("Nastaveni bylo ulozeno..."); break; - case 1:puts("Nastaveni nebylo zmeneno..."); break; - } - exit(0); - } - -static void deinstall() - { - char ig; - int x,y; - def_dialoge(200,200,250,156,"Odinstalovat?",2); - define(-1,10,30,200,100,0,label,"Tato volba odstranďż˝ hru z vaďż˝eho disku."); - define(-1,10,40,200,100,0,label,"Potďż˝ jiďż˝ nebude moďż˝ne hru spustit"); - define(-1,10,50,200,100,0,label,"do novďż˝ho nainstalovďż˝nďż˝ z CD."); - define(10,30,80,150,10,0,check_box,"Zachovat uloďż˝enďż˝ pozice");c_default(1); - define(20,10,10,80,30,3,button,"Ano");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(terminate_gui); - define(30,10,10,80,30,2,button,"Proboha NE");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(terminate_gui); - redraw_window(); - escape(); - if (o_aktual->id==30) - { - close_current(); - return; - } - ig=f_get_value(0,10); - set_enable(0,30,0); - set_enable(0,20,0); - set_enable(0,10,0); - do_events(); - home_path(target_path); - cascade_delete(ig); - chdir(".."); - rmdir(target_path); - home_path(source_path); - curcolor=0; - for(x=319;x>-1;x-=2) - { - y=x*240/320;bar(x,y,639-x,479-y);showview(0,0,0,0); - } - shutdown(); - exit(0); - } - -static void run_resetup() - { - int id; - - while (waktual!=NULL) close_current(); - do - { - home_path(source_path); - back=0; - select_mode_win_setup(); - about_window(); - id=o_aktual->id; - close_current(); - close_current(); - exit_wait=0; - if (id==30) - { - deinstall(); - back=1; - } - if (id==10) - { - select_vga(); - select_sound(); - control_window(save_ini,back_start,NULL); - } - if (id!=40) escape(); - } - while (back); - } - - -#define REPEAT(i,cnt) for(i=0;i=2 && argv[1][0]=='-' && toupper(argv[1][1])=='S') || access(SKELDAL_INI,F_OK)==0) - { - char *c; - char *d; - setup_mode=1; - getcwd(target_path,PATH_MAX+1); - setup_ini=read_config(SKELDAL_INI); - if (setup_ini==NULL) - { - printf("The file %s has not been found. You must reinstall the game\n" - "Insert the CD into driver and run INSTALL.EXE\n",SKELDAL_INI); - printf("Nemohu najit soubor %s. Budes muset hru znovu nainstalovat\n" - "Z CD \"Brany Skeldalu\" spust program INSTALL.EXE\n",SKELDAL_INI); - exit(0); - } - get_num_field(setup_ini,VMODE,&vmode); - c=get_text_field(setup_ini,"CESTA_CD"); - program_data_path=NewArr(char,strlen(c)+1);strcpy(program_data_path,c); - c=strchr(program_data_path,0); - if (c>program_data_path && c[-1]=='\n') c[-1]=0,c--; - if (c>program_data_path && c[-1]=='\\') c[-1]=0; - c=get_text_field(setup_ini,SOUND_DEVICE); - sscanf(c,"%d %x %d %d",&sound_info.device, - &sound_info.port, - &sound_info.dma, - &sound_info.irq); - c=alloca(strlen(argv[0])+1); - strcpy(c,argv[0]); - d=strrchr(c,'\\'); - if (d!=NULL) - { - d[d-c<=2]=0; - home_path(c); - } - } - } - -main(int argc,char **argv) - { - char s; - char *c; - - pgm_name=argv[0]; - check_setup_mode(argc,argv); - if (argc==2 && !setup_mode) copy_source_path=argv[1];else copy_source_path=NULL; - if (!setup_mode) - { - _setvideomode(_TEXTC80); - rescue_mode=!(s=create_er_file()); - if (s && !setup_mode) warning(),getche(); - } - else - s=0; - init_setup(s); - create_video_ls(); - set_mixing_device(0,22050,0,0,0); - c=test_sound_name=NewArr(char, strlen(program_data_path)+strlen(TEST_MUSIC)+1); - sprintf(c,"%s%s",program_data_path,TEST_MUSIC); - if (access(c,F_OK)!=0) - { - shutdown(); - printf("Vloz CD \"Brany Skeldalu\" do jednotky CD-ROM a spust znova instalaci\n" - "Insert CD \"The Gates of the Skeldal\" into CD-ROM and try to run INSTALL again.\n"); - abort(); - } - konec_skladby=skladba_konec; - change_music(c); - mix_back_sound(2); - if (setup_mode) run_resetup(); - else - { - if (!rescue_mode) run_setup(); - if (rescue_mode) - { - ask_video(); - escape(); - } - } - shutdown(); - } diff --git a/INST/SETUP.H b/INST/SETUP.H deleted file mode 100644 index 14263b1..0000000 --- a/INST/SETUP.H +++ /dev/null @@ -1,18 +0,0 @@ -extern word ikones; -extern word boldcz; -extern word sipka; -extern word font6x9; -extern void *bbutt; -extern word *vga_font; -extern word *icones; -extern word icone_color[]; -extern word ramecek; -extern word *ramecky[]; - -//#define WINCOLOR 0x6318 -#define WINCOLOR (31*1024+31*32+26) -#define LABELCOLOR (11*1024+11*32+06) -#define BUTTONCOLOR (28*1024+24*32+3) -#define PRG_HEADER "Br ny Skeldalu Setup v1."VERSION - -extern FILE *ini; diff --git a/INST/SETUPCPY.C b/INST/SETUPCPY.C deleted file mode 100644 index 993be65..0000000 --- a/INST/SETUPCPY.C +++ /dev/null @@ -1,165 +0,0 @@ -#include -#include -#include -#include -#include "setupcpy.h" - -#define DATASIZE 32768 -#define INFOBLOCK 1 -#define DATABLOCK 2 -#define ERRORBLOCK 3 - -typedef struct tdatablock - { - void *next; - char block_type; - unsigned short load_size; - char data[DATASIZE]; - }TDATABLOCK; - -typedef struct tinfoblock - { - void *next; - char block_type; - char pathname[2]; - }TINFOBLOCK; - -static void *start=NULL; -static void *end=NULL; -static FILE *cpyout=NULL; -static long progress=0; - -void (*cpy_error)(int,char *); -void (*mem_error_next)(long); - -void (*cpy_progress)(long); - - -static void *alloc_file(char *target_name) - { - TINFOBLOCK *p; - - p=(TINFOBLOCK *)getmem(sizeof(TINFOBLOCK)+strlen(target_name)); - strcpy(p->pathname,target_name); - p->next=NULL; - p->block_type=INFOBLOCK; - return p; - } - -static void *alloc_data() - { - TDATABLOCK *p; - - p=New(TDATABLOCK); - p->next=NULL; - p->load_size=0; - p->block_type=DATABLOCK; - return p; - } - - -static void *load_data(FILE *f) - { - TDATABLOCK *p; - int rc; - int retry=0; - void *end_line; - - p=end_line=alloc_data(); - again: - errno=0; - rc=fread(p->data,1,sizeof(p->data),f); - p->load_size=rc; - if (ferror(f) || rc!=sizeof(p->data) && errno!=0) - { - if (retry) retry--; - else cpy_error(CPERR_READ,NULL); - fseek(f,-rc,SEEK_CUR); - errno=0; - goto again; - } - progress+=p->load_size; - cpy_progress(progress); - return end_line; - } - -static error_mem(long size) - { - TDATABLOCK *p; - TINFOBLOCK *q; - int rc; - - size; - if (start==NULL) mem_error_next(size); - while (start!=NULL) - { - p=start; - q=start; - if (q->block_type==INFOBLOCK) - { - if (cpyout!=NULL) fclose(cpyout); - again: - cpyout=fopen(q->pathname,"wb"); - if (cpyout==NULL) - { - cpy_error(CPERR_OPEN,q->pathname); - goto again; - } - start=q->next; - free(q); - } - else if (p->block_type==DATABLOCK) - { - again2: - rc=fwrite(p->data,1,p->load_size,cpyout); - if (rc!=p->load_size) - { - cpy_error(CPERR_WRITE,q->pathname); - fseek(cpyout,-rc,SEEK_CUR); - goto again2; - } - progress+=p->load_size; - cpy_progress(progress); - start=p->next; - free(p); - } - } - end=NULL; - } - -void cpy_file(char *source,char *target) - { - FILE *f; - TDATABLOCK *p; - TINFOBLOCK *q; - - again: - errno=0; - f=fopen(source,"rb"); - if (f==NULL) - { - cpy_error(CPERR_OPEN,source); - goto again; - } - q=alloc_file(target); - if (start==NULL) start=end=q;else end=(((TDATABLOCK *)end)->next=q); - while (!feof(f)) - { - p=load_data(f); - if (start==NULL) start=end=p;else end=(((TDATABLOCK *)end)->next=p); - } - fclose(f); - } - -void cpy_flush() - { - if (start!=NULL)error_mem(0); - if (cpyout!=NULL)fclose(cpyout); - cpyout=NULL; - } - -void install_cpy() - { - mem_error_next=mem_error; - mem_error=error_mem; - } diff --git a/INST/SETUPCPY.H b/INST/SETUPCPY.H deleted file mode 100644 index e46a382..0000000 --- a/INST/SETUPCPY.H +++ /dev/null @@ -1,9 +0,0 @@ -#define CPERR_OPEN 1 -#define CPERR_WRITE 2 -#define CPERR_READ 3 - -extern void (*cpy_error)(int,char *); -extern void (*cpy_progress)(long); -void cpy_file(char *source,char *target); -void cpy_flush(); -void install_cpy(); diff --git a/INST/SETUPLIB.C b/INST/SETUPLIB.C deleted file mode 100644 index 658a586..0000000 --- a/INST/SETUPLIB.C +++ /dev/null @@ -1,505 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "setuplib.h" -#include "setupcpy.h" -#include "setup.h" - -#define COPY "COPY" -#define MKDIR "MKDIR" -#define INI "INI" - -#define DIR_NAMES 6 -char *dirnames[]= - { - "GAMES.*", - "GAME*.*", - "HRY.*", - "ZABAVA.*", - "SKELDAL", - "NAPOLEON", - }; - -TSTR_LIST file_list=NULL; - -static void done_bar_init(OBJREC *o,long *params) - { - o->userptr=New(long); - *(long *)o->userptr=*params; - } - -static void done_bar_draw(int x1,int y1,int x2,int y2,OBJREC *o) - { - long value,max,x3; - - value=*(long *)o->data; - max=*(long *)o->userptr; - x3=x1+(x2-x1)*value/max; - if (x3<=x1) x3=x1; - if (x3>=x2) x3=x2; - bar(x3,y1,x2,y2); - curcolor=o->f_color[1]; - bar(x1,y1,x3,y2); - } - -void done_bar(OBJREC *o) //define(...done_bar,max); - { - o->call_init=done_bar_init; - o->call_draw=done_bar_draw; - o->datasize=4; - } - - - -char select_disk() - { - char last=3; - struct diskfree_t ds; - int max=0,i; - long now; - - for(i=('C'-'@');i<('Z'-'@');i++) - { - if (_dos_getdiskfree(i,&ds)==0) - { - now=ds.avail_clusters*ds.sectors_per_cluster*ds.bytes_per_sector; - if (now>max) - { - max=now; - last=i; - } - } - } - return last; - } - -char dir_finder() - { - struct find_t ft; - int i; - int rc; - - for(i=0;imax && sz[j]datasize=(*len)+1; - } - -static void view_line_draw(int x1,int y1, int x2, int y2, OBJREC *o) - { - char *c; - - bar(x1,y1,x2,y2); - c=(char *)o->data; - if (!*c) return; - set_aligned_position(x2,y1,2,0,c); - outtext(c); - } - - -void view_line(OBJREC *o) - { - o->call_init=view_line_init; - o->call_draw=view_line_draw; - } - - -char get_max_res() - { - if (vesasupport(0x110)) return 2; - if (vesasupport(0x100)) return 1; - return 0; - } - -void add_to_list(char *name) - { - if (file_list==NULL) file_list=create_list(256); - str_add(&file_list,name); - } - -static void copy_1_file(char *init_mask,char *filename,char *target) - { - char *c,*d; - - c=alloca(strlen(init_mask)+strlen(filename)+1); - strcpy(c,init_mask); - d=strrchr(c,'\\'); - d++; - strcpy(d,filename); - d=alloca(strlen(target)+strlen(filename)+10); - strcpy(d,target); - if (d[0]==0 || d[strlen(d)-1]!='\\') strcat(d,"\\"); - strcat(d,filename); - set_value(0,20,filename); - add_to_list(d); - cpy_file(c,d); - } - -static void copy_files(char *param) - { - struct find_t ft; - char *source_mask; - char *target; - int rc; - - target=strchr(param,' '); - if (target==NULL) return; - source_mask=alloca(target-param); - source_mask[target-param]=0; - strncpy(source_mask,param,target-param); - target++; - rc=_dos_findfirst(source_mask,_A_NORMAL,&ft); - while (rc==0) - { - copy_1_file(source_mask,ft.name,target); - rc=_dos_findnext(&ft); - } - _dos_findclose(&ft); - } - -char cascade_mkdir(char *path) - { - char *c; - char d; - - if (path[0]==0||path[1]==':' && path[2]==0) return 0; - if (!access(path,F_OK)) return 0; - c=strrchr(path,'\\'); - if (c==NULL) return 0; - *c=0; - d=cascade_mkdir(path); - *c='\\'; - if (d==1) return 1; - if (mkdir(path)!=0) return 1; - add_to_list(path); - return 0; - } - - -static char add_to_ini(char *params) - { - return fprintf(ini,"%s\n",params)<0; - } - -static char *commands[]= - { - COPY, - MKDIR, - INI, - }; - -static char (*calls[])(char *params)= - { - copy_files, - cascade_mkdir, - add_to_ini, - }; - - - -static char command_match(char *cmd,char *test,char **params) - { - while (*test) if (toupper(*cmd++)!=toupper(*test++)) return 0; - if (*cmd!=' ') return 0; - *params=cmd+1; - return 1; - } - - -char do_script(int section) - { - int pos; - int num; - int str_siz=str_count(script); - char *command; - - for(pos=0;pos"); - } - return s; - } - -char validate_path(char *path) - { - unsigned disk; - unsigned cdisk,lastdrv; - char *c,ll=0,tt=0,d; - - static char valid[]="$%'_@{}~`#()&-"; - - if (path==NULL || path[0]==0 || path[1]!=':' || path[2]!='\\') return 0; - disk=toupper(path[0]); - if (disk<'A' || disk>'Z') return 0; - _dos_getdrive(&cdisk); - disk-='@';_dos_setdrive(disk,&lastdrv); - _dos_getdrive(&lastdrv); - disk=(disk==lastdrv); - _dos_setdrive(cdisk,&lastdrv); - if (!disk) return 0; - c=path+2;ll=0; - while (*c) - { - d=toupper(*c); - if (d=='\\') - if (ll) return 0;else ll=1,tt=0; - else - if (d>='A' && d<='Z' || d>='0' && d<='9' || strchr(valid,d)!=NULL || d>127) ll=0; - else if (d=='.') if (tt) return 0;else tt=1; - else return 0; - c++; - } - if (ll) return 0; - return 1; - } - -void clean_up() - { - int i,cnt; - if (file_list==NULL) return; - cnt=str_count(file_list); - for(i=cnt-1;i>=0;i--) if (file_list[i]!=NULL) - { - if (remove(file_list[i])) rmdir(file_list[i]); - } - release_list(file_list); - file_list=NULL; - } - -void purge_file_list() - { - if (file_list==NULL) return; - release_list(file_list); - file_list=NULL; - } - -char cascade_delete(char ignore_sav) - { - struct find_t f; - int rc; - - rc=_dos_findfirst("*.*",_A_SUBDIR,&f); - while (rc==0) - { - if (f.attrib & _A_SUBDIR) - { - if (f.name[0]!='.') - { - chdir(f.name); - cascade_delete(ignore_sav); - chdir(".."); - rmdir(f.name); - } - } - else - { - char *c=strchr(f.name,'.'); - - if (c!=NULL) - { - strupper(c); - if (!ignore_sav || strncmp(c,".SAV",4)) remove(f.name); - } - else remove(f.name); - } - rc=_dos_findnext(&f); - } - return 0; - } diff --git a/INST/SETUPLIB.H b/INST/SETUPLIB.H deleted file mode 100644 index 7928d30..0000000 --- a/INST/SETUPLIB.H +++ /dev/null @@ -1,22 +0,0 @@ -char all_finder(); -char select_disk(); -char read_script(char *filename,char *source_path,char *target_path); -long check_size(int gr); -long get_disk_free(char disk); -void view_line(OBJREC *o); -char *get_cdrom(); -char get_max_res(); -char do_script(int); -void done_bar(); //define(...done_bar,max); -char cascade_mkdir(char *path); -char validate_path(char *path); -char cascade_delete(char ignore_sav); //maze soubory a podadresare. Pripadne ignoruje soubory SAV - -void clean_up(); //maze zkopirovane soubory a adresare -void purge_file_list(); -void add_to_list(char *name); - - -#define INST_MIN 0 -#define INST_MED 1 -#define INST_MAX 2 diff --git a/INST/SETVIDEO.C b/INST/SETVIDEO.C deleted file mode 100644 index 3898652..0000000 --- a/INST/SETVIDEO.C +++ /dev/null @@ -1,197 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "setup.h" - -static void *xlat256=NULL; -static void *xlat16=NULL; - -static void create_xlats() - { - if (xlat256==NULL) xlat256=create_special_palette(); - if (xlat16==NULL) xlat16=create_blw_palette16(); - } - - -static void initgr_common() - { - register_ms_cursor(&sipka); - init_mysky(); - hranice_mysky(0,0,639,479); - update_mysky(); - schovej_mysku(); - bar(0,0,639,479); - showview(0,0,0,0); - } - -int initgr_auto() - { - int vmode; - create_xlats(); - vmode=2; - if (initmode32()) - { - vmode=1; - if (initmode256(xlat256)) - { - vmode=0; - initmode16(xlat16); - } - } - initgr_common(); - return vmode; - } - -int initgr_spec(int vmode) - { - int i=-1; - create_xlats(); - switch (vmode) - { - case 0:i=initmode_lo(xlat256);break; - case 1:i=initmode256(xlat256);break; - case 2:i=initmode32();break; - } - initgr_common(); - return i; - } - -void initgr_low() - { - create_xlats(); - initmode16(xlat16); - initgr_common(); - } - -void donegr() - { - closemode(); - done_mysky(); - } - -void kresli_okno(WINDOW *w) - { - int x,y; - int xs,ys,xsr,ysr; - int x1,y1,xs1,ys1; - int i,j; - - xsr=ramecky[0][0]; - ysr=ramecky[0][1]; - x1=w->x-12; - y1=w->y-12; - xs1=w->xs+24; - ys1=w->ys+24; - xs=xs1/xsr; - ys=ys1/ysr; - curcolor=w->color; - bar(w->x,w->y,w->x+w->xs,w->y+w->ys); - for(j=0,y=y1;jx; - y=waktual->y; - } - name; - highlight(&ctl,WINCOLOR); - ctl.bsize=2;ctl.ctldef=0; - x+=20;y+=20; - memcpy(fc,flat_color(0x7fe0),sizeof(FC_TABLE)); - fc[0]=0x0000; - if (x+xs>MAX_X-2) x=MAX_X-2-xs; - if (y+ys>MAX_Y-2) y=MAX_Y-2-ys; - p=create_window(x,y,xs,ys,WINCOLOR,&ctl); - q=desktop_add_window(p); - define(0,2,2,xs-5-20*(xs>=70),14,0,win_label,name); - ctl.bsize=1;ctl.ctldef=1; - o_end->autoresizex=1; - property(&ctl,vga_font,&fc,LABELCOLOR); - if (xs>=70) - { - define(1,1,1,19,16,1,button,"\x0f"); - property(NULL,icones,&icone_color,WINCOLOR);on_control_change(close_current); - } - return q; - } - -int def_dialoge(word x,word y,word xs, word ys, char *name,char modal) - { - CTL3D ctl; - FC_TABLE fc; - WINDOW *p; - int i; - - memcpy(fc,flat_color(0x7fe0),sizeof(FC_TABLE)); - if (modal & 0x2) - { - ctl.bsize=12; - xs=((xs+6)/12)*12; - ys=((ys+6)/12)*12; - } - else - memcpy(&ctl,def_border(2,WINCOLOR),sizeof(CTL3D)); - p=create_window(x,y,xs,ys,WINCOLOR,&ctl); - i=desktop_add_window(p); - if (modal & 1) set_window_modal(); - memcpy(&ctl,def_border(5,WINCOLOR),sizeof(CTL3D)); - if (name!=NULL) - { - define(0,2,2,xs-4,14,0,win_label,name); - o_end->autoresizex=1; - property(&ctl,vga_font,&fc,LABELCOLOR); - } - if (modal & 0x2) p->draw_event=kresli_okno; - return i; - } - -void def_listbox(int id,word x,word y,word xs,word ys,TSTR_LIST ls,int ofs,int color) - { - CTL3D b1,b2; - word black[]={0,0,0,0,0,0}; - - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D)); - define(id+1,x+xs+4,y+18,15,ys-35,0,scroll_bar_v,0,10,1,0x0200); - property(&b2,NULL,NULL,WINCOLOR); - define(id+2,x+xs+4,y,14,14,0,scroll_button,-1,0,"\x4"); - property(&b1,icones,black,WINCOLOR);on_control_change(scroll_support); - define(id+3,x+xs+4,y+ys-14,14,14,0,scroll_button,1,10,"\6"); - property(&b1,icones,black,WINCOLOR);on_control_change(scroll_support); - define(id,x,y,xs,ys,0,listbox,ls,color,ofs); - property(&b2,NULL,NULL,WINCOLOR); - } - diff --git a/INST/SETVIDEO.H b/INST/SETVIDEO.H deleted file mode 100644 index dce03e5..0000000 --- a/INST/SETVIDEO.H +++ /dev/null @@ -1,6 +0,0 @@ -int initgr_auto(); -void initgr_low(); -int initgr_spec(int vmode); -void donegr(); -int def_dialoge(word x,word y,word xs, word ys, char *name,char modal); -void def_listbox(int id,word x,word y,word xs,word ys,TSTR_LIST ls,int ofs,int color); diff --git a/INST/STUB.C b/INST/STUB.C deleted file mode 100644 index c059d9b..0000000 --- a/INST/STUB.C +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include -#include -#include -#include -#define QUIET x - -/* Add environment strings to be searched here */ -char *paths_to_check[] = { - "DOS4GPATH", - "PATH"}; - -char *dos4g_path() -{ - static char fullpath[80]; - int i; - - for( i = 0; - i < sizeof( paths_to_check ) / sizeof( paths_to_check[0] ); i++ ) { - _searchenv( "dos4gw.exe", paths_to_check[i], fullpath ); - if( fullpath[0] ) return( &fullpath ); - } - for( i = 0; - i < sizeof( paths_to_check ) / sizeof( paths_to_check[0] ); i++ ) { - _searchenv( "dos4g.exe", paths_to_check[i], fullpath ); - if( fullpath[0] ) return( &fullpath ); - } - return( "dos4gw.exe" ); -} - -main( int argc, char *argv[] ) -{ - char *av[4]; - auto char cmdline[128]; - int i; - av[0] = dos4g_path(); /* Locate the DOS/4G loader */ - av[1] = argv[0]; /* name of executable to run */ - av[2] = getcmd( cmdline ); /* command line */ - av[3] = NULL; /* end of list */ -#ifdef QUIET - putenv( "DOS4G=QUIET" ); /* disables DOS/4G Copyright banner */ -#endif - printf("Instalator Br ny Skeldalu (C)1997 Napoleon gameS Nahr v m... \n"); - i=spawnvp(P_WAIT, av[0], av ); - if (i==254) - execl(av[0],av[0],"SKELDAL.EXE",NULL);else exit(0); - puts( "Chyba pri nacitani extenderu:" ); - puts( av[0] ); - puts( "\nZkontrolujte zda-li je k dosazeni na aktualnim adresari\n" - "popripade specifikujte jeho v cestu v systemove promenne:\n" - "SET DOS4GPATH=disk:\\cesta\n"); - exit( 1 ); /* indicate error */ -} diff --git a/INST/TEXTLIB.ASM b/INST/TEXTLIB.ASM deleted file mode 100644 index 3ec6511..0000000 --- a/INST/TEXTLIB.ASM +++ /dev/null @@ -1,101 +0,0 @@ -.model small -.386 - -SEGB800 equ 0b8000h - -_TEXT segment byte public 'CODE' use32 - assume CS:_TEXT - assume DS:DGROUP - -public load_font_ -load_font_: ;esi font - mov esi,offset fonttable - mov edx,3c4h - mov eax,0402h - out dx,ax - mov eax,0704h - out dx,ax - Mov edx,3ceh - mov eax,0204h - out dx,ax - mov eax,0005h - out dx,ax - mov eax,0406h - out dx,ax - mov edi,0xA0000h - mov edx,256 -lfOpk: mov ecx,16 - rep movsb - add edi,16 - dec edx - jne lfopk - mov edx,3c4h - mov eax,0302h - out dx,ax - mov eax,0304h - out dx,ax - Mov edx,3ceh - mov eax,0004h - out dx,ax - mov eax,1005h - out dx,ax - mov eax,0E06h - out dx,ax - ret - -public set_font_8x8_ -set_font_8x8_: - cli - mov edx,3d4h - mov eax,0100h - out dx,ax - mov edx,3c4h - mov al,1 - out dx,al - inc edx - in al,dx - or al,1 - out dx,al - mov edx,03dah - in al,dx - mov edx,03c0h - mov al,13h - out dx,al - mov al,0 - out dx,ax - mov al,32 - out dx,al - mov edx,3d4h - mov eax,0300h - out dx,ax - sti - ret - -public turn_flashing_ ;ebx - ON/OFF -turn_flashing_: - mov eax,1003h - int 10h - ret - - -public get_window_size_ ;eax,edx-velikost -get_window_size_: - imul eax,edx - shl eax,1 - add eax,4 - ret - -public save_window_ ;eax,edx-pozice - ;ecx,ebx-velikost - ;edi - buffer -save_window_ - stosb - imul eax,160 - lea eax,[eax+edx*2] - lea esi,[eax+SEGB800] - mov al,dl - stosb - mov al,bl - mov ah,cl - stosw - mov edx,ebx diff --git a/INST/TEXTLIB.C b/INST/TEXTLIB.C deleted file mode 100644 index fd40910..0000000 --- a/INST/TEXTLIB.C +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/MAPS/CDIALOGY.C b/MAPS/CDIALOGY.C deleted file mode 100644 index c20c909..0000000 --- a/MAPS/CDIALOGY.C +++ /dev/null @@ -1,585 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#define P_STRING 1 -#define P_SHORT 2 -#define P_VAR 3 -#define TEMP_NAME1 "cdialogy.$$$" -#define SCRIPT "dialogy.scr" - -typedef struct t_paragraph - { - unsigned num:15; - unsigned alt:15; - unsigned visited:1; - unsigned first:1; - long position; - }T_PARAGRAPH; - - -char *pgf_name=NULL; - -T_PARAGRAPH *pgf_list=NULL; -int pgf_count=0; -char *program; -int prog_size=0; -int prog_pos=0; -int last_pgf; -int sentencs=0; -int libs=0; - -FILE *f; -FILE *mlist; - -#define newline(f) {int c;while ((c=fgetc(f))!='\n' && c!=EOF);} -#define get_cislo(f,cislo) fscanf(f,"%d",cislo);newline(f) -#define get_command(f,cislo) fscanf(f,"%c%d",cislo,cislo);newline(f) - -static int basic_num; -static int abs_num; -static int last_dialoge; -static int standard_jump; -static char sentence; -static char sub_mode,b_closed=1; - -static int open_level=0; -static int iff_mode=0; -static char was_sub=0; -#define IF_JUMP 1 -#define IF_NOT_JUMP 2 -#define IF_ELSE 3 - -typedef struct if_record - { - int level; - int pointer; - }IF_RECORD; - -int if_ptr=0; - -#define IF_LEN 32 - -static IF_RECORD if_data[IF_LEN]; - -int init(char *c) - { - prog_size=163840; - prog_pos=0; - program=malloc(prog_size); - f=fopen(c,"rt"); - if (f==NULL) return 1; - return 0; - } - -void error(char *c) - { - printf("%s v odstavci %d (Dialog %d Sentence %d).",c,last_pgf,basic_num/128,last_pgf); - exit(1); - } - -void resize(void **p,int newsize) - { - void *q; - - if (*p==NULL) q=malloc(newsize);else - { - q=malloc(newsize); - if (q!=NULL) - { - memcpy(q,*p,_msize(*p)); - free(*p); - } - } - if (q==NULL) - { - puts("Nedostatek pamŘti"); - exit(1); - } - *p=q; - } - -void check_prog_space(int num) - { - if (prog_pos+num>prog_size-16) - { - prog_size+=163840; - resize(&program,prog_size); - } - } - -void add_byte(char byte) - { - check_prog_space(1); - program[prog_pos++]=byte; - } - -void add_short(short i) - { - add_byte(P_SHORT); - check_prog_space(2); - *(short*)(program+prog_pos++)=i; - prog_pos++; - } - -void add_var(short i) - { - add_byte(P_VAR); - check_prog_space(2); - *(short*)(program+prog_pos++)=i; - prog_pos++; - } - -void copy_short(FILE *f) - { - int c; - int i; - c=fgetc(f); - if (c=='&') - { - get_cislo(f,&i); - add_var(i); - } - else - { - if (isdigit(c)) ungetc(c,f); - get_cislo(f,&i); - add_short(i); - } - } - -void add_string(char *c) - { - add_byte(P_STRING); - check_prog_space(strlen(c)+1); - while (*c && *c!='\n') program[prog_pos++]=*c++; - program[prog_pos++]=0; - } - -void add_pgf(T_PARAGRAPH *p) - { - resize(&pgf_list,sizeof(*p)*(pgf_count+1)); - memcpy(pgf_list+pgf_count,p,sizeof(*p)); - pgf_list[pgf_count].position=prog_pos; - pgf_list[pgf_count].visited=0; - pgf_list[pgf_count].first=0; - if (pgf_name!=NULL) - { - fprintf(mlist,"%6d %s\n",pgf_list[pgf_count].num,pgf_name); - free(pgf_name); - pgf_name=NULL; - } - pgf_count++; - } - -void decode_pgf1(char *c) //c je text bez vykricniku - { - int pn,an,i; - T_PARAGRAPH p; - char relative=0; - if (*c=='!') - { - relative=1; - c++; - } - i=sscanf(c,"%d",&pn); - if (relative) pn+=abs_num;else abs_num=pn; - if (i!=1) error("Chybn‚ pou§itˇ znaku \"!\""); - last_pgf=pn; - c=strchr(c,','); - if (c==NULL) an=pn; - else - { - c++; - i=sscanf(c,"%d",&an); - if (i!=1) error("Oźek v  se źˇslo alternativnˇho odstavce"); - } - p.num=pn; - p.alt=an; - add_pgf(&p); - } - -void js_dialoge(FILE *f) - { - int parm1; - T_PARAGRAPH pgf; - - if (!b_closed) error("Ocekava se '}' (close_block)"); - get_cislo(f,&parm1); - abs_num=basic_num=parm1*128; - pgf.num=basic_num; - pgf.alt=basic_num; - last_dialoge=pgf_count; - last_pgf=0; - add_pgf(&pgf); - get_command(f,&parm1); - if (parm1!=-2) error ("Ocekava se '{' (open_block)"); - sentence=0; - b_closed=0; - add_short(167); - add_short(basic_num); - } - -void js_first(FILE *f) - { - int parm1; - - - add_short(166); - add_short(last_pgf); - add_short(140); - get_cislo(f,&parm1); - add_short(parm1); - } - -void js_standard(FILE *f) - { - int parm1; - - get_cislo(f,&parm1); - if (parm1>0) standard_jump=parm1;else standard_jump=32767+parm1-basic_num; - } - -void js_close_block() - { - if (open_level) - { - if (was_sub) - if (sub_mode) - add_short(165); - else - { - add_short(139); - add_short(standard_jump); - } - sub_mode=0; - open_level--; - return; - } - if (b_closed) error("Neocekavany znak '}' (close_block)"); - if (sentence && sub_mode) add_short(165);else - { - add_short(139); - add_short(standard_jump); - } - b_closed=1; - } - -void js_sentence(FILE *f) - { - int par1,par2; - T_PARAGRAPH pgf; - - if (!b_closed || open_level) error("Ocekava se '}' (close_block)"); - b_closed=0; - get_cislo(f,&par1); - get_cislo(f,&par2); - sub_mode=par2; - pgf.num=par1+basic_num; - pgf.alt=par1+basic_num; - add_pgf(&pgf); - sentence=1; - last_pgf=par1; - get_command(f,&par1); - if (par1!=-2) error ("Ocekava se '{' (open_block)"); - sentencs++; - was_sub=0; - } - - -void js_sub(FILE *f) - { - int par1; - char *c; - int d; - - c=malloc(65536); - d=getc(f);while (d!=EOF && d!='$') d=getc(f); - fgets(c,65536,f); - if (sub_mode) - { - add_short(142); - get_cislo(f,&par1); - if (par1>0) add_short(par1);else add_short(32767+par1-basic_num); - add_string(c); - } - else - { - add_short(148); - add_string(c); - get_cislo(f,&par1); - if (par1>0) standard_jump=par1;else standard_jump=32767+par1-basic_num; - } - free(c); - } - -void js_close_sub() - { - was_sub=1; - if (sub_mode)add_short(164); else add_short(144); - } - -void save_pgf_name(FILE *f) - { - long l; - int i,s; - l=ftell(f); - for(s=0;(i=fgetc(f))!=EOF && i!='\n';s++); - if (pgf_name!=NULL) free(pgf_name); - pgf_name=(char *)malloc(s+2); - fseek(f,l,SEEK_SET); - fgets(pgf_name,s+1,f); - fgetc(f); - } - -void push_level(int level,int pos) - { - if (if_ptr==IF_LEN) error("Priliz dlouha struktura if & else"); - if_data[if_ptr].level=level; - if_data[if_ptr].pointer=pos; - if_ptr++; - } - -void pop_and_fill(int pos,int level) - { - int i; - int prog_sav; - prog_sav=prog_pos; - while (if_ptr && if_data[if_ptr-1].level==level) - { - if_ptr--; - prog_pos=if_data[if_ptr].pointer; - i=pos-if_data[if_ptr].pointer-3; - if (i>32767 || i<-32767) error("Blok if/else je priliz dlouhy (delsi nez 32767 bytu)"); - add_short(i); - } - prog_pos=prog_sav; - } - -int get_last_level() - { - if (if_ptr) return if_data[if_ptr-1].level; - else return -1; - } - -void add_if_jump() - { - char c=1; - switch(iff_mode) - { - case IF_NOT_JUMP:add_short(169);break; - case IF_JUMP:add_short(170);break; - case IF_ELSE:c=0;break; - } - if (c) - { - push_level(open_level,prog_pos); - add_short(0); - } - iff_mode=0; - was_sub=0; - } - -void add_else() - { - int psave,c; - get_command(f,&c); - if (c!=-2) error("Chybn  syntaxe pýˇkazu else. Oźek v  se '{'"); - was_sub=0; - if (get_last_level()!=open_level) error("Else bez if"); - add_short(171); - psave=prog_pos; - add_short(0); - pop_and_fill(prog_pos,open_level); - push_level(open_level,psave); - open_level++; - } - -void set_alternative(FILE *f) - { - int cislo; - - get_cislo(f,&cislo); - pgf_list[pgf_count-1].alt=cislo+basic_num; - } - -void decode_program(FILE *f) - { - int c; - char next_sub=0; - char *d; - - d=(char *)calloc(sizeof(char),16384); - open_level=0; - c=fgetc(f); - while (c!=EOF) - { - if (c=='!') - { - char d[256]; - - fgets(&d,256,f); - decode_pgf1(d); - } - else if (isdigit(c) || c=='-') - { - int cislo; - ungetc(c,f); - get_cislo(f,&cislo); - add_short(cislo); - } - else if (c=='*') - { - int cislo; - get_cislo(f,&cislo); - if (cislo!=517 && next_sub) - { - js_close_sub(); - next_sub=0; - } - if (cislo!=171 && !iff_mode) pop_and_fill(prog_pos,open_level); - switch (cislo) - { - case 512:js_dialoge(f);break; //Sekce DIALOG - case 513:js_first(f);break; //Prikaz FIRST - case 514:add_short(152); //Prikaz WHEN_ITEM - copy_short(f); - add_short(140); - get_cislo(f,&cislo); - if (cislo>0)add_short(cislo);else add_short(cislo+32767-basic_num); - break; - case 515:add_short(163); //prikaz WHEN_FLAG - copy_short(f); - add_short(140); - get_cislo(f,&cislo); - if (cislo>0)add_short(cislo);else add_short(cislo+32767-basic_num); - break; - case 516:js_standard(f);break; //prikaz STANDARD - case 517:js_sub(f);next_sub=1;break; //prikaz SUB - case 520:js_sentence(f);break; //Sekce SENTENCE - case -1:js_close_block();break; //znak }// - case -2: if (iff_mode) add_if_jump();else error("Neocekavany znak '{' (open_block)"); - open_level++; - break; //znak {// - case 999:save_pgf_name(f);break; - case 169:if (iff_mode) add_if_jump(); //prikaz if - iff_mode=IF_NOT_JUMP;break; - case 170:if (iff_mode!=IF_NOT_JUMP) error("NOT bez IF"); //modifikator not - iff_mode=IF_JUMP;break; - case 171:if (iff_mode) error("Chybn‚ pou§itˇ pýˇkazu ELSE"); //prikaz else - add_else();break; - case 173:set_alternative(f);break; - default: add_short(cislo);break; - } - } - else if (c=='$') - { - fgets(d,16384,f); - add_string(d); - } - else if (c=='&') - { - int cislo; - get_cislo(f,&cislo); - add_var(cislo); - } - c=fgetc(f); - } - free(d); - } - -void save_program() - { - FILE *tg; - int pgstart; - - tg=fopen("dialogy.dat","wb"); - pgstart=pgf_count*sizeof(*pgf_list); - fwrite(&pgf_count,1,sizeof(pgf_count),tg); - fwrite(&prog_pos,1,sizeof(prog_pos),tg); - fwrite(pgf_list,1,pgstart,tg); - fwrite(program,1,prog_pos,tg); - fclose(tg); - } - -void create_include_list(char *filename) - { - FILE *f,*g; - int i; - char s[15]; - - f=fopen(filename,"r"); - if (f==NULL) - { - printf("Soubor nenalezen: %s\n",filename); - exit(0); - } - g=fopen(TEMP_NAME1,"w"); - fputs("#include dialogy.def\n",g); - fputs("#command pgf_name *999 1\n",g); - do - { - i=fscanf(f,"%14s",s); - if (i==1) - { - fprintf(g,"pgf_name '"); - while((i=fgetc(f))!='\n' && i!=EOF) fputc(i,g);fputs("'\n",g); - fprintf(g,"#include %s\n",s); - libs++; - i=1; - } - } - while(i==1); - fclose(f); - fclose(g); - } - -const char *GetLexLibPath() -{ - static char c[MAX_PATH]; - char *z; - GetModuleFileName(0,c,MAX_PATH); - z=strrchr(c,'\\')+1; - strcpy(z,"lex_lib.exe"); - return c; -} - -main(int argc,char *argv[]) - { - if (argc<2) - { - puts("Tento program vyzaduje jmeno souboru, ve kterem se naleza\n" - "script pro popis dialogu pro hru BRANY SKELDALU v 1.0"); - exit(0); - } - puts(""); - puts("Probˇh  kompilace:"); - puts(" Spouçtˇm program LEX_LIB.EXE\n"); - putenv("DOS4G=QUIET"); - create_include_list(argv[1]); - if (spawnlp(P_WAIT,GetLexLibPath(),"lex_lib.exe",TEMP_NAME1,"temp.$$$",NULL)) - exit(1); - if (errno || init("temp.$$$")) - { - puts("Nemohu spustit program lex_lib.exe"); - exit(1); - } - mlist=fopen(SCRIPT,"w"); - if (mlist==NULL) - { - printf("Nemohu otevrit soubor %s pro zapis.\n",SCRIPT); - exit(0); - } - decode_program(f); - fclose(f); - remove("temp.$$$"); - remove(TEMP_NAME1); - puts("Kompilace ŁspŘçn ..."); - printf("Vytvoreno odstavcu: %d\nCelkem knihoven: %d\nCelkem Sentenci: %d\nD‚lka k˘du: %d\n",pgf_count,libs,sentencs,prog_pos); - save_program(); - fclose(mlist); - } - diff --git a/MAPS/DLGPRINT.C b/MAPS/DLGPRINT.C deleted file mode 100644 index 6519372..0000000 --- a/MAPS/DLGPRINT.C +++ /dev/null @@ -1,188 +0,0 @@ -#include - -#include -#include -#include - -#define DIALOGY "DIALOGY.DAT" -void *dialog; -int count; -char *pc; -char *ending; -char all_print,print_it; -char print2; - -#define SAVE_POSTS 20 -static char sn_nums[SAVE_POSTS]; -static char sn_nams[SAVE_POSTS][32]; -static char sn_rods[SAVE_POSTS]; - -static void error(char *text) - { - fputs(text,stderr); - exit(1); - } - - -typedef struct t_paragraph - { - unsigned num:15; - unsigned alt:15; - unsigned visited:1; - unsigned first:1; - long position; - }T_PARAGRAPH; - - - -void Load_dialogs() - { - FILE *f; - int size; - - f=fopen(DIALOGY,"rb"); - if (f==NULL) - { - fprintf(stderr,"Nemohu otevrit soubor %s",DIALOGY); - exit(1); - } - fseek(f,0,SEEK_END); - size=ftell(f); - fseek(f,0,SEEK_SET); - dialog=malloc(size); - fread(dialog,1,size,f); - fclose(f); - memcpy(&count,dialog,4); - ending=pc=dialog; - pc+=sizeof(T_PARAGRAPH)*count+8; - ending+=size; - } - -static char buff[65535]; - -static char *transfer_text(char *source,char *target) - { - char *orgn=source,*ot=target,c; - int num; - print2=print_it=0; - while (*source) - { - if (*source=='%') - { - source++; - switch(*source) - { - case '[':*target++='[';break; - case ']':*target++=']';break; - case 'a':*target++='\'';break; - case 'p': - case '%':*target++='%';break; - case 'n':strcpy(target,sn_nams[0]);target+=strlen(sn_nams[0]);print2=print_it=1;break; - default: num=0;while (isdigit(*source)) num=10*num+*source++-'0'; - if (*source=='l') - { - sn_nums[0]=sn_nums[num]; - strcpy(sn_nams[0],sn_nams[num]); - sn_rods[0]=sn_rods[num]; - } - break; - } - source++; - } - else if (*source=='[') - { - source++;print2=print_it=1; - num=sn_rods[0]; - while(num>0) - { - source=strchr(source,','); - num--; - if (source==NULL) - { - puts(orgn); - error("Chybnďż˝ rod nebo malďż˝ poďż˝et tvarďż˝ od jednoho slova"); - } - source++; - } - while (*source!=',' && *source!=']' && *source!=0) *target++=*source++; - if (*source!=']') - { - source=strchr(source,']'); - if (source==NULL) - { - puts(orgn); - error("Oďż˝ekďż˝vďż˝ se ']'"); - } - } - source++; - } - else c=*target++=*source++; - } - *target=0; - //if (code_page==2) - // prekodovat(ot); - return target; - } - -void read_program() - { - while(pc"); - } - pc=strchr(pc,0)+1; - } - } - } - -void read_names() - { - char fm; - int i,j,k; - - do - { - fprintf(stderr,"Budes zadďż˝vat muďż˝skďż˝ jmďż˝na, nebo ďż˝enskďż˝: (M/Z)");gets(buff); - fm=toupper(buff[0]); - } - while (fm!='M'&& fm!='Z') ; - fprintf(stderr,"Nynďż˝ je tďż˝eba zadat nďż˝kolik jmen, poslednďż˝ odklepni ENTREM\n"); - i=0; - do - { - fprintf(stderr,"%d.jmďż˝no:",i+1);gets(buff); - if (buff[0]) strncpy(sn_nams[i],buff,31); - i++; - } - while(i -#include -#include -#include -#include - -static int latest_version(char *wild,int numpos) - { - struct find_t ff; - int rc; - int i=0,j=-1; - char *p; - - rc=_dos_findfirst(wild,_A_NORMAL,&ff); - while (rc==0) - { - p=ff.name+numpos; - sscanf(p,"%d",&i); - if (i>j) j=i; - rc=_dos_findnext(&ff); - } - _dos_findclose(&ff); - return j; - } - -void save_dump() - { - static dump_counter=-1; - FILE *f; - int i,r,g,b,x,y; - word *a; - char c[20]; - - if (dump_counter==-1) - { - dump_counter=latest_version("DUMP*.BMP",4); - SEND_LOG("(DUMP) Dump counter sets to %d",dump_counter,0); - } - sprintf(c,"DUMP%04d.BMP",++dump_counter); - SEND_LOG("(DUMP) Saving screen shot named '%s'",c,0); - f=fopen(c,"wb"); - fputc('B',f);fputc('M',f); - i=640*480*3+0x36; - fwrite(&i,1,4,f);i=0; - fwrite(&i,1,4,f); - i=0x36; - fwrite(&i,1,4,f); - i=0x28; - fwrite(&i,1,4,f); - i=640; - fwrite(&i,1,4,f); - i=480; - fwrite(&i,1,4,f); - i=1; - fwrite(&i,1,2,f); - i=24; - fwrite(&i,1,2,f); - i=0; - fwrite(&i,1,4,f); - i=640*480*3; - fwrite(&i,1,4,f); - for(i=4,r=0;i>0;i--) fwrite(&r,1,4,f); - for(y=480;y>0;y--) - { - a=&screen[(y-1)*640]; - for(x=0;x<640;x++) - { - i=a[x]; - b=(i & 0x1f)<<3; - g=(i & 0x3e0)>>2; - r=(i & 0x7f00)>>7; - i=((r*256)+g)*256+b; - fwrite(&i,1,3,f); - } - } - fclose(f); - } - diff --git a/MAPS/DUMP.H b/MAPS/DUMP.H deleted file mode 100644 index 737ecb6..0000000 --- a/MAPS/DUMP.H +++ /dev/null @@ -1 +0,0 @@ -void save_dump(); diff --git a/MAPS/EDIT_MAP.C b/MAPS/EDIT_MAP.C deleted file mode 100644 index 83ad37e..0000000 --- a/MAPS/EDIT_MAP.C +++ /dev/null @@ -1,1179 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "mapy.h" -#include -#include -#include "globals.h" -#include "edit_map.h" -#include "steny.h" -#include "save_map.h" -#include "wiz_tool.h" -#include "resource.h" - -int temp_source; -int sektor_info=-1; -int sektor_win=-1; -int draw_win=-1; -int change_map; -char datapath[]=""; -char last_directions=0; - -char *strs(int num) - { - static char s[200]; - char **format; - int *p; - - p=(int *)(o_end->userptr); - format=(char **)p+4; - sprintf(s,*format,num); - return s; - } - -long vals(int num) - { - char s[200]; - long i; - - get_value(0,num,s); - sscanf (s,"%d", &i); - return i; - } - - -void test_int(void) - { - int *p; - char s[200]; - char **t; - int i; - - p=(int *)(o_aktual->userptr); - get_value(0,o_aktual->id,s); - sscanf (s,"%d", &i); - p=p+2; - if (i<*p || i>*(p+1)) cancel_event(); - t=(char **)p+2; - sprintf(s,*t,i); - set_value(0,o_aktual->id,s); - } - -void fill_bit_fields(int win,int id_start,int source,int count) - { - while (count) - { - c_set_value(win,id_start,source & 1); - id_start+=10; - source>>=1; - count--; - } - } - -long get_bit_fields(int win,int id_start,int count) - { - long l; - int mask; - - mask=0;l=0; - while (count) - { - l|=f_get_value(win,id_start)<id; - p=o_aktual; - v=f_get_value(0,id); - v=string_list(*(char **)(o_aktual->userptr),v); - if (v+1) c_set_value(0,id,v); - o_aktual=p; - p->on_change(); - o_aktual=o_start; - } - -void string_list_sup() - { - run_background(string_list_sup_call); - } - -void str_line_init(OBJREC *o,void **x) //source_list - { - o->userptr=(void *)getmem(16); - memcpy(o->userptr,x,sizeof(*x)); - } - -void str_line_draw(int x1,int y1,int x2,int y2,OBJREC *o) - { - char c[200]; - char **s; - int *d; - - - d=(int *)o->data; - bar(x1,y1,x2,y2); - s=*(char ***)(o->userptr); - if (*d<0 || *d>=str_count(s) || s[*d]==0) strcpy(c,"???");else strcpy(c,s[*d]); - while (text_width(c)>(x2-x1)) - { - char *t; - - t=strchr(c,'\0'); - *(--t)='\0'; - } - position(x1,y1); - outtext(c); - } - -void str_line_event(EVENT_MSG *msg,OBJREC *o) - { - if (msg->msg==E_CONTROL) - { - memcpy(o->userptr,msg->data,4); - } - } - -void str_line(OBJREC *o) - { - o->call_init=str_line_init; - o->call_draw=str_line_draw; - o->call_event=str_line_event; - o->datasize=4; - } - -static void refresh_vyk_map() - { - int i,j,s,d; - - for(i=1;i1) - selmode=msg_box("Editor stďż˝n",'\x2',"Je oznaďż˝eno vďż˝ce sektorďż˝. Chceďż˝ upravit pouze ...","Aktuďż˝lnďż˝","Vďż˝echny","Zmďż˝ny","Zpďż˝t",NULL); - else selmode=(apl!=1 && apl!=2 && apl!=4 && apl!=8 && target!=0)?3:1; - else - smer=0,apl=0xf,selmode=1; - if (selmode==4) return 0; - p->flags=get_bit_fields(0,120,20); - p->flags|=f_get_value(0,350); - p->prim_anim=vals(50)-1; - p->sec_anim=vals(60)-1; - p->xsec=vals(70)>>1; - p->ysec=vals(80)>>1; - p->lclip=vals(440); - p->sector_tag=vals(90); - p->side_tag=f_get_value(0,100); - p->action=f_get_value(0,110); - p->prim=f_get_value(0,20); - p->sec=f_get_value(0,30); - p->oblouk=f_get_value(0,40)+(f_get_value(0,450)<<5)+(f_get_value(0,470)<<7); - p->side_tag|=(f_get_value(0,480)<<7); - o=&mapa.sidedef[target][smer]; - if (selmode==3) - { - memset(&chs,0,sizeof(chs)); - if (p->flags!=o->flags) chs.flags=o->flags ^ p->flags; - if (p->prim_anim!=o->prim_anim) chs.prim_anim=0xFF; - if (p->sec_anim!=o->sec_anim) chs.sec_anim=0xFF; - if (p->xsec!=o->xsec) chs.xsec=0xFF; - if (p->ysec!=o->ysec) chs.ysec=0xFF; - if (p->lclip!=o->lclip) chs.lclip=0xFF; - if (p->sector_tag!=o->sector_tag) chs.lclip=0xFF; - if ((p->side_tag & 0x7F)!=(o->side_tag & 0x7F)) chs.side_tag|=0x7F; - if ((p->side_tag & 0x80)!=(o->side_tag & 0x80)) chs.side_tag|=0x80; - if (p->action!=o->action) chs.action=0xFF; - if (p->prim!=o->prim) chs.prim=0xFF; - if (p->sec!=o->sec) chs.sec=0xFF; - if ((p->oblouk & 0x1F)!=(o->oblouk & 0x1F)) chs.sec|=0x1F; - if ((p->oblouk & 0x60)!=(o->oblouk & 0x60)) chs.sec|=0x60; - if ((p->oblouk & 0x80)!=(o->oblouk & 0x80)) chs.sec|=0x80; - } - else - { - memset(&chs,0xff,sizeof(chs)); - } - for (i=0;i<4;(apl>>=1),i++) if (apl & 1) - { - o=&mapa.sidedef[target][i]; - move_changes(p,o,&chs,sizeof(TSTENA)); - if (selmode!=1) - for(j=1;jmsg==E_INIT) return &edit_side_predvolba_0; - if (msg->msg==E_DONE) return NULL; - c=(char *)msg->data; - strcpy(c,"Vlastnosti nastaveny jako pďż˝edvolba..."); - c=strchr(c,'\0'); - msg->data=(void *)c; - msg->msg=-1; - return NULL; - } - -void edit_side_predvolba_1(void) - { - edit_side_save(0,-1); - send_message(E_STATUS_LINE,E_DONE,E_IDLE,edit_side_predvolba_0); - send_message(E_STATUS_LINE,E_ADD,E_IDLE,edit_side_predvolba_0); - } - -void edit_side_predvolba_2(void) - { - send_message(E_STATUS_LINE,E_DONE,E_IDLE,edit_side_predvolba_0); - } - -void value_store_init(OBJREC *o,int *bytes) - { - o->datasize=*bytes; - } - -void value_store(OBJREC *o) - { - o->call_init=value_store_init; - } - -void action_flags() - { - CTL3D b1; - long flags; - - flags=f_get_value(0,350); - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - def_dialoge(300,220,300,210,"Vďż˝ce vlajek"); - define(CANCEL_BUTT,11,5,80,20,2,button,"Zruďż˝it");property(&b1,NULL,NULL,WINCOLOR); - on_control_change(terminate_gui); - define(OK_BUTT,100,5,80,20,2,button,"Ok");property(&b1,NULL,NULL,WINCOLOR); - on_control_change(terminate_gui); - define(10,10,20,250,10,0,check_box,side_flgs[24]); - define(20,10,32,250,10,0,check_box,side_flgs[25]); - define(30,10,44,250,10,0,check_box,side_flgs[26]); - define(40,10,56,250,10,0,check_box,side_flgs[27]); - define(50,10,68,250,10,0,check_box,side_flgs[28]); - define(60,10,88,250,10,0,check_box,side_flgs[29]); - define(70,10,100,250,10,0,check_box,side_flgs[30]); - define(80,10,112,250,10,0,check_box,side_flgs[31]); - define(90,10,124,250,10,0,check_box,side_flgs[20]); - define(100,10,136,250,10,0,check_box,side_flgs[21]); - define(110,10,148,250,10,0,check_box,side_flgs[22]); - define(120,10,160,250,10,0,check_box,side_flgs[23]); - fill_bit_fields(0,10,flags>>24,8); - fill_bit_fields(0,90,flags>>20,4); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - flags=get_bit_fields(0,10,8)<<24; - flags|=get_bit_fields(0,90,4)<<20; - - } - close_window(waktual); - c_set_value(0,350,flags); - } - -int find_vyklenek_id(int sector,int dir) - { - int i; - for(i=0;i<256;i++) if (vyklenky[i].sector==sector && vyklenky[i].dir==dir) return i; - return -1; - } - -int find_free_vyklenek() - { - int i; - for(i=0;i<256;i++) if (vyklenky[i].sector==0) return i; - return -1; - } - - -static void edit_vyklenek_start() - { - int smer,sector; - int id; - - smer=f_get_value(0,370); - sector=f_get_value(0,360); - id=find_vyklenek_id(sector,smer); - if (id==-1) - { - TVYKLENEK *v; - id=find_free_vyklenek(); - if (id==-1) - { - msg_box("Omezeni!",'\x1',"V mapďż˝ je pouďż˝ito jiďż˝ mnoho vďż˝klenkďż˝ ve zdi. Maximďż˝lnďż˝ poďż˝et je 256","Ok",NULL); - return; - } - v=vyklenky+id; - v->xpos=250; - v->ypos=160; - v->xs=80; - v->ys=60; - v->sector=sector; - v->dir=smer; - v->items[0]=0; - } - edit_vyklenek(id); - refresh_vyk_map(); - } - -void edit_side(int source,int smer) - { - TSTENA *p; - CTL3D b1,b2,b3; - char s[200]; - - p=&mapa.sidedef[source][smer]; - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D)); - memcpy(&b3,def_border(6,WINCOLOR),sizeof(CTL3D)); - default_font=vga_font; - memcpy(f_default,flat_color(0x0000),sizeof(charcolors)); - sprintf(s,"Vlastnosti stďż˝n, sektor %d stďż˝na %d",source,smer); - def_window(400,324,s); - waktual->x=125; - waktual->y=60; - waktual->modal=1; - define(CANCEL_BUTT,10,5,80,20,2,button,"Zruďż˝it");property(&b1,NULL,NULL,WINCOLOR); - on_control_change(close_current); - define(OK_BUTT,190,5,80,20,2,button,"Ok");property(&b1,NULL,NULL,WINCOLOR); - on_control_change(edit_side_ok); - define(3400,100,5,80,20,2,button,"Pďż˝edvolba");property(&b1,NULL,NULL,WINCOLOR); - on_control_change(edit_side_predvolba_1);on_control_exit(edit_side_predvolba_2); - define(10,5,20,300,35,0,label,"Primďż˝rnďż˝: Sekundarnďż˝: Oblouk:");property(&b3,NULL,NULL,WINCOLOR); - define(20,10,35,90,12,0,str_line,side_names);property(&b2,NULL,NULL,WINCOLOR);c_default(p->prim); - on_control_enter(string_list_sup); - define(30,110,35,90,12,0,str_line,side_names);property(&b2,NULL,NULL,WINCOLOR);c_default(p->sec); - on_control_enter(string_list_sup); - define(40,210,35,90,12,0,str_line,oblouky);property(&b2,NULL,NULL,WINCOLOR);c_default(p->oblouk & 0x0f); - on_control_enter(string_list_sup); - define(-1,5,60,250,12,0,label,"Animace primarnďż˝:"); - define(-1,5,75,250,12,0,label,"Animace sekundarnďż˝:"); - define(-1,5,90,250,12,0,label,"X pozice sek. stďż˝ny:"); - define(-1,5,105,250,12,0,label,"Y pozice sek. stďż˝ny:"); - define(-1,5,120,250,12,0,label,"Cďż˝lovďż˝ sektor udďż˝losti:"); - define(-1,5,135,250,12,0,label,"Cďż˝lovďż˝ stďż˝na udďż˝losti:"); - define(-1,5,150,250,12,0,label,"Popis akce:"); - define(-1,260,60,100,12,0,label,"Aplikuj na stďż˝nu:"); - define(50,200,60,50,10,0,input_line,10,1,16,"%6d");property(&b2,NULL,NULL,WINCOLOR); - set_default(strs((p->prim_anim & 0xf)+1));on_control_exit(test_int); - define(60,200,75,50,10,0,input_line,10,1,16,"%6d");property(&b2,NULL,NULL,WINCOLOR); - set_default(strs((p->sec_anim & 0xf)+1));on_control_exit(test_int); - define(70,200,90,50,10,0,input_line,10,0,499,"%6d");property(&b2,NULL,NULL,WINCOLOR); - set_default(strs(p->xsec<<1));on_control_exit(test_int); - define(80,200,105,50,10,0,input_line,10,0,511,"%6d");property(&b2,NULL,NULL,WINCOLOR); - set_default(strs(p->ysec<<1));on_control_exit(test_int); - define(90,200,120,50,10,0,input_line,10,0,65535,"%6d");property(&b2,NULL,NULL,WINCOLOR); - set_default(strs(p->sector_tag));on_control_exit(test_int); - define(100,200,135,50,10,0,str_line,steny2);property(&b2,NULL,NULL,WINCOLOR); - c_default(p->side_tag & 0x3);on_control_enter(string_list_sup); - define(110,100,150,150,10,0,str_line,actions);property(&b2,NULL,NULL,WINCOLOR); - on_control_enter(string_list_sup); c_default(p->action); - define(120,10,175,150,10,0,check_box,side_flgs[0]); - define(130,10,187,150,10,0,check_box,side_flgs[1]); - define(140,10,199,150,10,0,check_box,side_flgs[2]); - define(150,10,211,150,10,0,check_box,side_flgs[3]); - define(160,10,223,150,10,0,check_box,side_flgs[4]); - define(170,10,235,150,10,0,check_box,side_flgs[5]); - define(180,10,247,150,10,0,check_box,side_flgs[6]); - define(190,10,259,150,10,0,check_box,side_flgs[7]); - define(200,190,175,100,10,0,check_box,side_flgs[8]); - define(210,190,187,100,10,0,check_box,side_flgs[9]); - define(220,190,199,100,10,0,check_box,side_flgs[10]); - define(230,190,211,150,10,0,check_box,side_flgs[11]); - define(240,190,223,150,10,0,check_box,side_flgs[12]); - define(250,190,235,150,10,0,check_box,side_flgs[13]); - define(260,190,247,150,10,0,check_box,side_flgs[14]); - define(270,190,259,150,10,0,check_box,side_flgs[15]); - define(280,10,271,75,10,0,check_box,side_flgs[16]); - define(290,10,283,75,10,0,check_box,side_flgs[17]); - define(300,190,271,150,10,0,check_box,side_flgs[18]); - define(310,10,295,75,11,0,check_box,side_flgs[19]); - define(400,290,80,100,10,0,check_box,"Severnďż˝"); - define(410,290,95,100,10,0,check_box,"Vďż˝chodnďż˝"); - define(420,290,110,100,10,0,check_box,"Jiďż˝nďż˝"); - define(430,290,125,100,10,0,check_box,"Zďż˝padnďż˝"); - define(340,290,150,100,15,0,button2,"Vďż˝ce >>");on_control_change(action_flags); - define(350,290,150,100,15,0,value_store,4);c_default(p->flags & 0xfff00000); - define(360,290,150,100,15,0,value_store,4);c_default(source); - define(370,290,150,100,15,0,value_store,4);c_default(smer); - define(-1,5,20,60,10,1,label,"Lclip:"); - define(440,30,35,30,12,1,input_line,3,0,255,"%3d"); - property(&b2,NULL,NULL,WINCOLOR); - set_default(strs(p->lclip));on_control_exit(test_int); - define(450,10,220,30,30,1,radio_butts,3,"-","\x4","\x6");c_default((p->oblouk>>5) & 0x3); - property(NULL,icones,NULL,WINCOLOR); - define(460,10,175,80,12,1,button,"Vďż˝klenek");on_control_change(edit_vyklenek_start); - define(470,190,283,150,10,0,check_box,"Lze poloďż˝it za");c_default(p->oblouk>>7); - define(480,10,307,75,10,0,check_box,"Pďż˝edsunout s.");c_default(p->side_tag>>7); - fill_bit_fields(0,120,p->flags,20); if (source) - fill_bit_fields(0,400,1<id/10-5); - } - -void edit_sector(int source) - { - TSECTOR *p; - TSTR_LIST l; - CTL3D b1,b2,b3; - - l=read_directory("c:\\windows\\system\\*.*",DIR_FULL,_A_NORMAL); - p=&mapa.sectordef[source]; - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D)); - memcpy(&b3,def_border(3,WINCOLOR),sizeof(CTL3D)); - default_font=vga_font; - memcpy(f_default,flat_color(0x0000),sizeof(charcolors)); - def_dialoge(100,100,300,200,"String list - test only"); - define(9,10,20,240,170,0,listbox,l,0x1f);c_default(0); - o_end->autoresizex=1; - o_end->autoresizey=1; - define(10,3,42,17,110,1,scroll_bar_v,0,10,1,SCROLLBARCOL); - property(NULL,NULL,NULL,WINCOLOR); - o_end->autoresizey=1; - define(11,1,20,21,17,1,scroll_button,-1,0,"\x1e"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(12,1,22,21,17,2,scroll_button,1,10,"\x1f"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(20,1,1,10,10,2,resizer); -/* define(OK_BUTT,100,5,80,20,2,button,"Ok");property(&b1,NULL,NULL,WINCOLOR); - on_change(terminate); - define(CANCEL_BUTT,10,5,80,20,2,button,"Zruďż˝it");property(&b1,NULL,NULL,WINCOLOR); - on_change(terminate); - define(-1,5,20,100,12,0,label,"Pďż˝ipojenďż˝:"); - define(10,10,35,50,12,0,input_line,20,0,MAPSIZE-1,"%6d");property(&b2,NULL,NULL,WINCOLOR); - set_default(strs(p->step_next[0]));on_exit(test_int); - define(20,10,50,50,12,0,input_line,20,0,MAPSIZE-1,"%6d");property(&b2,NULL,NULL,WINCOLOR); - set_default(strs(p->step_next[1]));on_exit(test_int); - define(30,10,65,50,12,0,input_line,20,0,MAPSIZE-1,"%6d");property(&b2,NULL,NULL,WINCOLOR); - set_default(strs(p->step_next[2]));on_exit(test_int); - define(40,10,80,50,12,0,input_line,20,0,MAPSIZE-1,"%6d");property(&b2,NULL,NULL,WINCOLOR); - set_default(strs(p->step_next[3]));on_exit(test_int); - define(50,70,35,80,12,0,button,"Sever");property(&b1,NULL,NULL,WINCOLOR);on_change(edit_side_sup); - define(60,70,50,80,12,0,button,"Vďż˝chod");property(&b1,NULL,NULL,WINCOLOR);on_change(edit_side_sup); - define(70,70,65,80,12,0,button,"Jih");property(&b1,NULL,NULL,WINCOLOR);on_change(edit_side_sup); - define(80,70,80,80,12,0,button,"Zďż˝pad");property(&b1,NULL,NULL,WINCOLOR);on_change(edit_side_sup); - temp_source=source; - */redraw_window(); - escape(); - close_window(waktual); - release_list(l); - } - -void run_edit_side(void) - { - char s[100]; - int i; - OBJREC *o; - - get_value(0,5,s); - if (strcmp(s,"?")) - { - sscanf(s,"%d",&i); - o=o_aktual; - edit_side(i,o_aktual->id/10-10); - } - - } - - -void Apply(void) - { - int sec,i; - char s[100]; - - get_value(0,5,s); - if (!strcmp(s,"?")) return; - sscanf(s,"%d",&sec); - { - TSECTOR *p;int j; - - p=&mapa.sectordef[sec]; - for (j=0;j<4;j++) p->step_next[j]=(word)vals((j+1)*10); - } - for (i=1;imsg==E_MOUSE) - { - ms=get_mouse(msg); - if (ms->event_type & 0x8) - { - int s; - s=vals(o_aktual->id); - jdi_na_sektor(s); - } - } - } - -void chozeni2(EVENT_MSG *msg,OBJREC *o) - { - word s2,s1; - char ok=1; - - if (msg->msg==E_INIT) return ; - if (msg->msg==E_DONE) return ; - if (msg->msg==E_KEYBOARD) - { - if (o_aktual==NULL || o_aktual->on_change!=chozeni2) return; - if (waktual->id==map_win || waktual->id==tool_bar) - select_window(sektor_win); - if (waktual->id!=sektor_win) return; - s2=vals(5);s1=s2; - if (s2>maplen) return; - if (!(*(char *)msg->data)) - switch (*(int *)msg->data>>8) - { - case 'H':s1=mapa.sectordef[s2].step_next[0];break; - case 'P':s1=mapa.sectordef[s2].step_next[2];break; - case 'M':s1=mapa.sectordef[s2].step_next[1];break; - case 'K':s1=mapa.sectordef[s2].step_next[3];break; - default:ok=0; - } - else if (*(char *)msg->data!=13) ok=0; - if (ok) - { - if (s1>maplen) return; - jdi_na_sektor(s1); - while (_bios_keybrd(_KEYBRD_READY)) _bios_keybrd(_KEYBRD_READ); - msg->msg=-1; - } - } - if (msg->msg==E_GET_FOCUS) - { - memcpy(&o->f_color,flat_color(0x3e0),sizeof(FC_TABLE)); - redraw_object(o); - } - if (msg->msg==E_LOST_FOCUS) - { - memcpy(&o->f_color,flat_color(0),sizeof(FC_TABLE)); - redraw_object(o); - } - - return ; - } - -void sector_details_call(int sect_num) - { - TSECTOR *p; - CTL3D b1,b2,b3; - int start,end,i; - char s[200]; - - p=&mapa.sectordef[sect_num]; - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D)); - memcpy(&b3,def_border(3,WINCOLOR),sizeof(CTL3D)); - default_font=vga_font; - memcpy(f_default,flat_color(0x0000),sizeof(charcolors)); - sprintf(s,"Detaily sektoru %d",sect_num); - def_dialoge(100,50,440,340,s); - define(-1,30,30,100,12,0,label,"Strop:"); - define(-1,30,50,100,12,0,label,"Podlaha:"); - define(-1,30,70,100,12,0,label,"Sektor:"); - define(-1,30,90,100,12,0,label,"Cďż˝l akce:"); - define(-1,30,110,100,12,0,label,"Stďż˝na akce:"); - define(-1,30,130,100,12,0,label,"Popis akce:"); - define(10,30,28,100,13,1,str_line,ceils);property(&b2,NULL,NULL,WINCOLOR); - c_default(p->ceil); on_control_enter(string_list_sup); - define(20,30,48,100,13,1,str_line,floors);property(&b2,NULL,NULL,WINCOLOR); - c_default(p->floor); on_control_enter(string_list_sup); - define(30,30,68,100,13,1,str_line,sector_types);property(&b2,NULL,NULL,WINCOLOR); - c_default(p->sector_type); on_control_enter(string_list_sup); - define(40,30,88,50,13,1,input_line,10,0,MAPSIZE,"%6d");property(&b2,NULL,NULL,WINCOLOR); - set_default(strs(p->sector_tag));on_control_exit(test_int); - define(50,30,108,100,13,1,str_line,steny2);property(&b2,NULL,NULL,WINCOLOR); - c_default(p->side_tag & 3); on_control_enter(string_list_sup); - define(60,30,128,150,13,1,str_line,actions);property(&b2,NULL,NULL,WINCOLOR); - c_default(p->action); on_control_enter(string_list_sup); - define(70,5,150,214,80,0,radio_butts,7, - "(1) Normďż˝lnďż˝ podlaha", - "(2) Dva druhy podlah", - "(3) Dva smďż˝ry", - "(4) Dva smďż˝ry a druhy", - "(5) ďż˝tyďż˝i smďż˝ry", - "(6) ďż˝tyďż˝i smďż˝ry a dva druhy", - "(7) ďż˝achovnice");c_default(p->flags & 0x7); - define(80,5,150,214,80,1,radio_butts,7, - "(1) Normďż˝lnďż˝ strop", - "(2) Dva druhy strop", - "(3) Dva smďż˝ry", - "(4) Dva smďż˝ry a druhy", - "(5) ďż˝tyďż˝i smďż˝ry", - "(6) ďż˝tyďż˝i smďż˝ry a dva druhy", - "(7) ďż˝achovnice");c_default(p->flags >> 4 & 0x7); - define(90,5,240,214,10,0,check_box,"(?)Animace podlahy");c_default((p->flags & 0x8)!=0); - define(95,5,240,214,10,1,check_box,"(?)Animace stropu");c_default((p->flags & 0x80)!=0); - define(65,5,252,214,10,0,check_box,"Sekundarni shading");c_default((minfo[sect_num].flags & 0x100)>>8); - define(75,5,258,214,40,1,radio_butts,4,"*default*","ďż˝ipka","Schody","Bez symbolu");c_default((minfo[sect_num].flags & 0x600)>>9); - define(83,5,264,214,10,0,check_box,"!Automap (kouzlem)");c_default((minfo[sect_num].flags & 0x800)>>11); - define(85,5,276,214,10,0,check_box,"!Summon");c_default((minfo[sect_num].flags & 0x1000)>>12); - define(87,5,288,214,10,0,check_box,"Neprojde hledanďż˝m cesty");c_default((minfo[sect_num].flags & 0x2000)>>13); - define(100,10,10,80,20,3,button,"Ok");property(&b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(110,10,10,80,20,2,button,"Zruďż˝it");property(&b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(120,100,10,80,20,2,button,"Pďż˝edvolba");property(&b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - set_enable(0,120,sect_num!=0); - redraw_window(); - do - { - sem: - escape(); - if (o_aktual->id-110) - { - i=0; - if (o_aktual->id==120) - { - start=0;end=0;minfo[0].flags|=1; - } - else - { - if (count_of_sel()<2 || (i=msg_box("Co teďż˝?",'\x2',"Mďż˝m vlastnosti aplikovat na jeden sektor nebo na vybranou oblast?", - "Na sektor","Na oblast","Zruďż˝it",NULL))==1) - { - start=sect_num; - end=sect_num; - minfo[sect_num].flags |=1; - } - else - { - start=1; - end=maplen-1; - } - } - if (i==3) goto sem; - else - for (i=start;i<=end;i++) if (minfo[i].flags & 1) - { - p=&mapa.sectordef[i]; - p->ceil=f_get_value(0,10); - p->floor=f_get_value(0,20); - p->sector_type=f_get_value(0,30); - p->sector_tag=vals(40); - p->side_tag=f_get_value(0,50); - p->action=f_get_value(0,60); - p->flags=f_get_value(0,70)+16*f_get_value(0,80)+8*f_get_value(0,90)+0x80*f_get_value(0,95);; - minfo[i].flags&=~0x1f00; - minfo[i].flags|=(f_get_value(0,65)<<8)|(f_get_value(0,75)<<9)|(f_get_value(0,83)<<11)|(f_get_value(0,85)<<12)|(f_get_value(0,87)<<13); - } - } - } - while (o_aktual && o_aktual->id==120); - close_window(waktual); - minfo[0].flags &= ~1; - } - -void set_change_map(void) - { - int i; - - i=o_aktual->id / 10-5; - if (i>14) i-=11; - change_map|=1<10) break; - } - *c=0; - if (c!=err) - { - do - c--; - while (c!=err && *c==32); - if (*c!=32) c++; - *c=0; - }*/ - } - -void call_testmap(int pos) - { - char tt[250]; - HWND hWnd; - - if (save_all_map()) return; - save_items(); - - LoadString(GetModuleHandle(NULL),3,tt,250); - hWnd=FindWindow(NULL,tt); - if (hWnd==NULL) - { - msg_box("Testovani mapy",'\x1',"Pro testovani mapy, spust hru Skeldal.exe v okne s tvym dobrodruzstvim " - "Vytvor novou skupinu, popripade nahraj pozici." - "Po nahrati urovne muzes zacit hru testovat. MapEdit se propoji s hrou.","Ok",NULL); - } - else - { - const char *fname=strrchr(filename,'\\'); - ATOM atm; - LRESULT res; - - if (fname==NULL) fname=filename;else fname++; - atm=GlobalAddAtom(fname); - SendMessageTimeout(hWnd,WM_RELOADMAP,pos,(LPARAM)atm,SMTO_NORMAL,2000,&res); - GlobalDeleteAtom(atm); - BringWindowToTop(hWnd); - } - } - -void testmap(void) - { - call_testmap(vals(5)); - } - -void close_sector_win(void) - { - close_window(waktual); - send_message(E_DONE,E_KEYBOARD,chozeni2); - } - -void open_sector_win(void) - { - if (find_window(sektor_win)==NULL) - { - CTL3D b1,b2; - FC_TABLE f_sel; - - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D)); - default_font=vga_font; - memcpy(f_default,flat_color(0x0000),sizeof(charcolors)); - memcpy(&f_sel,flat_color(0x0017),sizeof(charcolors)); - sektor_win=def_window(120,325,"Vlastnosti"); - waktual->y=2;waktual->x=SCR_WIDTH_X-120-3; - on_control_change(close_sector_win); - define(100,4,19,59,14,0,button2,"Sever:");on_control_change(run_edit_side); - define(110,4,49,59,14,0,button2,"Vďż˝chod:");on_control_change(run_edit_side); - define(120,4,79,59,14,0,button2,"Jih:");on_control_change(run_edit_side); - define(130,4,109,59,14,0,button2,"Zďż˝pad:");on_control_change(run_edit_side); - define(-1,5,140,59,10,0,label,"Strop:"); - define(-1,5,170,59,10,0,label,"Podlaha:"); - define(-1,5,200,59,10,0,label,"Typ sektoru:"); - define(10,65,20,50,12,0,input_line,20,0,MAPSIZE-1,"%5d");property(&b2,NULL,&f_sel,WINCOLOR); - set_default("0");on_control_exit(test_int);on_event(chozeni); - define(20,65,50,50,12,0,input_line,20,0,MAPSIZE-1,"%5d");property(&b2,NULL,&f_sel,WINCOLOR); - set_default("0");on_control_exit(test_int);on_event(chozeni); - define(30,65,80,50,12,0,input_line,20,0,MAPSIZE-1,"%5d");property(&b2,NULL,&f_sel,WINCOLOR); - set_default("0");on_control_exit(test_int);on_event(chozeni); - define(40,65,110,50,12,0,input_line,20,0,MAPSIZE-1,"%5d");property(&b2,NULL,&f_sel,WINCOLOR); - set_default("0");on_control_exit(test_int);on_event(chozeni); - define(50,5,35,95,12,0,str_line,side_names);property(&b2,NULL,&f_sel,WINCOLOR); - c_default(0); on_control_enter(string_list_sup);on_control_change(set_change_map); - define(60,5,65,95,12,0,str_line,side_names);property(&b2,NULL,&f_sel,WINCOLOR); - c_default(0); on_control_enter(string_list_sup);on_control_change(set_change_map); - define(70,5,95,95,12,0,str_line,side_names);property(&b2,NULL,&f_sel,WINCOLOR); - c_default(0); on_control_enter(string_list_sup);on_control_change(set_change_map); - define(80,5,125,95,12,0,str_line,side_names);property(&b2,NULL,&f_sel,WINCOLOR); - c_default(0); on_control_enter(string_list_sup);on_control_change(set_change_map); - define(140,103,35,12,12,0,check_box,"");o_end->call_event=o_end->on_change; - define(150,103,65,12,12,0,check_box,"");o_end->call_event=o_end->on_change; - define(160,103,95,12,12,0,check_box,"");o_end->call_event=o_end->on_change; - define(170,103,125,12,12,0,check_box,"");o_end->call_event=o_end->on_change; - define(200,5,155,110,12,0,str_line,ceils);property(&b2,NULL,&f_sel,WINCOLOR); - c_default(0); on_control_enter(string_list_sup);on_control_change(set_change_map); - define(210,5,185,110,12,0,str_line,floors);property(&b2,NULL,&f_sel,WINCOLOR); - c_default(0); on_control_enter(string_list_sup);on_control_change(set_change_map); - define(220,5,215,110,12,0,str_line,sector_types);property(&b2,NULL,&f_sel,WINCOLOR); - c_default(0); on_control_enter(string_list_sup);on_control_change(set_change_map); - define(-1,1,30,60,10,3,label,"Sektor:"); - define(OK_BUTT,60,67,55,17,3,button2,"Aplikuj");on_control_change(Apply); - define(300,4,67,55,17,3,button2,"Detaily");on_control_change(sector_details); - define(5,60,30,55,12,3,input_line,20,0,MAPSIZE-1,"%5d");property(&b2,NULL,NULL,WINCOLOR); - set_default("?");on_control_change(chozeni2); - define(310,4,3,112,20,3,button,"Testovat mapu");on_control_change(testmap); - define(320,4,47,55,17,2,button2,"Zoom+");on_control_change(zoomin); - define(330,4,47,55,17,3,button2,"Zoom-");on_control_change(zoomout); - send_message(E_ADD,E_KEYBOARD,chozeni2); - waktual->popup=1; - } - else - { - select_window(sektor_win); - } - redraw_window(); - } - - -void info_sector(int sector) - { - char c[100]; - WINDOW *w; - int i; - - if (!sector) return; - w=waktual; - if (waktual->id!=sektor_win) open_sector_win(); - sprintf(c,"%5d",sector); - set_value(0,5,c); - for(i=0;i<4;i++) - { - sprintf(c,"%5d",mapa.sectordef[sector].step_next[i]); - set_value(0,(i+1)*10,c); - } - c_set_value(0,50,mapa.sidedef[sector][0].prim); - c_set_value(0,60,mapa.sidedef[sector][1].prim); - c_set_value(0,70,mapa.sidedef[sector][2].prim); - c_set_value(0,80,mapa.sidedef[sector][3].prim); - c_set_value(0,140,(mapa.sidedef[sector][0].flags & 0x200)!=0); - c_set_value(0,150,(mapa.sidedef[sector][1].flags & 0x200)!=0); - c_set_value(0,160,(mapa.sidedef[sector][2].flags & 0x200)!=0); - c_set_value(0,170,(mapa.sidedef[sector][3].flags & 0x200)!=0); - c_set_value(0,200,mapa.sectordef[sector].ceil); - c_set_value(0,210,mapa.sectordef[sector].floor); - c_set_value(0,220,mapa.sectordef[sector].sector_type); - select_window(w->id); - change_map=0; - } - -void draw_win_1(void) - { - int i; - - for (i=20;i<70;i++) c_set_value(draw_win,i,0); - c_set_value(draw_win,10,1); - } - -void draw_win_2(void) - { - c_set_value(draw_win,10,get_bit_fields(draw_win,10,6)==0);; - } - - -void open_draw_win(void) - { - if (find_window(draw_win)==NULL) - { - FC_TABLE f_sel; - - default_font=vga_font; - memcpy(f_default,flat_color(0x0000),sizeof(charcolors)); - memcpy(&f_sel,flat_color(0x0017),sizeof(charcolors)); - draw_win=def_window(120,165,"Vlajky"); - waktual->y=2;waktual->x=SCR_WIDTH_X-120-3; - define(10,5,30,100,10,0,check_box,"Rozdďż˝lit");c_default(1); - on_control_change(draw_win_1); - define(20,5,45,100,10,0,check_box,"!Hraďż˝");c_default(0); - on_control_change(draw_win_2); - define(30,5,60,100,10,0,check_box,"!Nestvďż˝ra");c_default(0); - on_control_change(draw_win_2); - define(40,5,75,100,10,0,check_box,"!Vďż˝c");c_default(0); - on_control_change(draw_win_2); - define(50,5,90,100,10,0,check_box,"!Zvuk");c_default(0); - on_control_change(draw_win_2); - define(60,5,105,100,10,0,check_box,"PrimVis");c_default(0); - on_control_change(draw_win_2); - define(70,5,18,110,17,3,button2,"Zoom in");on_control_change(zoomin); - define(80,5,1,110,17,3,button2,"Zoom out");on_control_change(zoomout); - waktual->popup=1; - - } - else - { - select_window(sektor_win); - } - redraw_window(); - } - -long get_draw_flags(void) - { - long l; - if (find_window(draw_win)!=NULL) - { - l=get_bit_fields(draw_win,10,6); - if (l & 1)l=0; else - if (l & 0x20) l=(l & 0x1f)|SD_PRIM_VIS; - } - else - l=0xff91; - return l; - } - - -static void veci_ve_vyklenku(TSTR_LIST *ls,short *list) - { - int i; - if (*ls!=NULL) release_list(*ls); - *ls=create_list(8); - for(i=0;list[i]!=0;i++) - { - int it=list[i]-1; - if (it>=max_items) str_add(ls,"");else str_add(ls,item_list[it].jmeno); - } - } - -static void add_to_vyk() - { - int i,p; - TSTR_LIST ls; - TSTR_LIST ls2; - TVYKLENEK *v; - int id; - - i=f_get_value(0,9); - p=f_get_value(0,29); - id=f_get_value(0,20); - send_message(E_GUI,29,E_CONTROL,0,&ls); - send_message(E_GUI,9,E_CONTROL,0,&ls2); - if (ls2[i]==NULL) return; - sscanf(ls2[i],"%d",&i); - if (i==-1) return; - v=vyklenky+id; - if (p!=7)memmove(v->items+p+1,v->items+p,(7-p)*2); - v->items[8]=0; - v->items[p]=i+1; - veci_ve_vyklenku(&ls,&v->items); - send_message(E_GUI,29,E_CONTROL,1,ls); - } - -static void remove_from_vyk() - { - int i; - TVYKLENEK *v; - TSTR_LIST ls; - int id; - - i=f_get_value(0,29); - if (i>=8) return; - id=f_get_value(0,20); - v=vyklenky+id; - memmove(&v->items[i],&v->items[i+1],(8-i)*2); - send_message(E_GUI,29,E_CONTROL,0,&ls); - veci_ve_vyklenku(&ls,&v->items); - send_message(E_GUI,29,E_CONTROL,1,ls); - } - -static change_grep() - { - TSTR_LIST ls; - char grep_en; - int grep_type; - int grep_num; - - c_set_value(0,9,0); - send_message(E_GUI,9,E_CONTROL,2); - grep_en=f_get_value(0,90); - grep_type=f_get_value(0,80); - if (grep_en) grep_num=grep_type;else grep_num=-1; - send_message(E_GUI,9,E_CONTROL,0,&ls); - create_isort_list(&ls,grep_num); - send_message(E_GUI,9,E_CONTROL,1,ls); - redraw_desktop(); - } - -void edit_vyklenek(int idnum) - { - TVYKLENEK *v=vyklenky+idnum; - TSTR_LIST vyklist=NULL; - TSTR_LIST ls_sorts=NULL; - CTL3D b1,b2,b3; - TVYKLENEK old; - - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D)); - memcpy(&b3,def_border(6,WINCOLOR),sizeof(CTL3D)); - memcpy(&old,v,sizeof(TVYKLENEK)); - veci_ve_vyklenku(&vyklist,&v->items); - create_isort_list(&ls_sorts,-1); - def_dialoge(70,100,500,200,"Oprava vďż˝klenkďż˝"); - define(9,10,20,200,126,0,listbox,ls_sorts,RGB555(31,31,31),0); - property(&b3,NULL,NULL,WINCOLOR);c_default(0); - define(10,216,40,21,87,0,scroll_bar_v,0,10,1,SCROLLBARCOL); - property(&b2,NULL,NULL,WINCOLOR); - define(11,216,20,21,17,0,scroll_button,-1,0,"\x1e"); - property(&b1,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(12,216,130,21,17,0,scroll_button,1,10,"\x1f"); - property(&b1,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(20,0,0,0,0,0,value_store,4);c_default(idnum); - define(29,10,20,200,120,1,listbox,vyklist,RGB555(31,31,31),0); - property(&b3,NULL,NULL,WINCOLOR);c_default(0); - define(40,242,40,40,15,0,button,">>");on_control_change(add_to_vyk); - define(50,242,60,40,15,0,button,"<<");on_control_change(remove_from_vyk); - define(80,30,150,120,12,1,str_line,typy_veci);c_default(0); - property(&b2,NULL,NULL,WINCOLOR);on_control_enter(string_list_sup);on_control_change(change_grep); - define(-1,150,150,50,10,1,label,"Filtr:"); - define(90,10,150,10,10,1,check_box,"");c_default(0);on_control_change(change_grep); - define(-1,10,30,1,10,3,label,"Xpos Ypos Xsiz Ysiz Sector Pos"); - define(100,8,12,40,12,3,input_line,10,0,500,"%4d");set_default(strs(v->xpos)); - property(&b2,NULL,NULL,WINCOLOR);on_control_exit(test_int); - define(110,53,12,40,12,3,input_line,10,0,500,"%4d");set_default(strs(v->ypos)); - property(&b2,NULL,NULL,WINCOLOR);on_control_exit(test_int); - define(120,98,12,40,12,3,input_line,10,0,500,"%4d");set_default(strs(v->xs)); - property(&b2,NULL,NULL,WINCOLOR);on_control_exit(test_int); - define(130,143,12,40,12,3,input_line,10,0,500,"%4d");set_default(strs(v->ys)); - property(&b2,NULL,NULL,WINCOLOR);on_control_exit(test_int); - define(140,188,12,40,12,3,input_line,10,0,maplen,"%4d");set_default(strs(v->sector)); - property(&b2,NULL,NULL,WINCOLOR);on_control_exit(test_int); - define(150,233,12,40,12,3,input_line,10,0,3,"%4d");set_default(strs(v->dir)); - property(&b2,NULL,NULL,WINCOLOR);on_control_exit(test_int); - define(200,5,5,60,20,2,button,"Ok");on_control_change(terminate_gui);property(&b1,NULL,NULL,WINCOLOR); - define(210,70,5,60,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(&b1,NULL,NULL,WINCOLOR); - define(220,135,5,60,20,2,button,"Vymazat");on_control_change(terminate_gui);property(&b1,NULL,NULL,WINCOLOR); - redraw_window(); - opp: - escape(); - if (o_aktual->id==200) - { - v->xpos=vals(100); - v->ypos=vals(110); - v->xs=vals(120); - v->ys=vals(130); - v->sector=vals(140); - v->dir=vals(150); - } - else if (o_aktual->id==220) - if (msg_box("Mapedit",'\x2',"Chceďż˝ opravdu vďż˝klenek zbourat?","Ano","Ne",NULL)==1) - { - v->sector=0; - } - else goto opp; - else if (o_aktual->id==210) - { - memcpy(v,&old,sizeof(old)); - } - send_message(E_GUI,9,E_CONTROL,0,&ls_sorts); - release_list(vyklist); - release_list(ls_sorts); - close_current(); - } diff --git a/MAPS/EDIT_MAP.H b/MAPS/EDIT_MAP.H deleted file mode 100644 index 04ce908..0000000 --- a/MAPS/EDIT_MAP.H +++ /dev/null @@ -1,21 +0,0 @@ -void edit_sector(int source); -void open_sector_win(void); -void info_sector(int sector); -void open_draw_win(void); -long get_draw_flags(void); -void edit_side(int source,int smer); -void sector_details_call(int sect_num); -void chozeni2(EVENT_MSG *msg,OBJREC *o); -void jdi_na_sektor(int s); - - -void string_list_sup(); -void str_line(OBJREC *o); -char *strs(int num); -long vals(int num); -void test_int(void); -void fill_bit_fields(int win,int id_start,int source,int count); -long get_bit_fields(int win,int id_start,int count); -void value_store(OBJREC *o); - - diff --git a/MAPS/GLOBALS.H b/MAPS/GLOBALS.H deleted file mode 100644 index 0ca6ffb..0000000 --- a/MAPS/GLOBALS.H +++ /dev/null @@ -1,133 +0,0 @@ -#define WINCOLOR RGB555(24,24,24) -#define LABELCOLOR RGB555(0,0,15) - -#define OK_BUTT 10000 -#define CANCEL_BUTT 10001 -#define YES_BUTT 10002 -#define NO_BUTT 10003 - -#define SID ".SID" -#define CEI ".CEI" -#define FLR ".FLR" -#define OBL ".OBL" -#define TXT ".TXT" -#define TEXT_FILE "..\\popisy.txt" -#define XITEM_FILE "ITEMS.DAT" -#define XDLG_SCRIPT "dialogy.scr" -#define XWEAPONS_SCRIPT "weapons.scr" - -#define SAMPLE_PATH sample_path -#define XMUSIC_PATH "..\\music\\" - -#define XSHOP_NAME "shops.dat" -#define ITEMS_DAT ITEM_FILE -#define XMOB_FILE "enemy.dat" -#define XMOB_SOUND "SOUND.DAT" - -#define ITEM_FILE mapFiles.items_dat -#define DLG_SCRIPT mapFiles.dialogy_scr -#define WEAPONS_SCRIPT mapFiles.weapons_scr - - -#define SHOP_NAME mapFiles.shops_dat -#define MOB_FILE mapFiles.enemy -#define MOB_SOUND mapFiles.enemy_sound - -typedef struct _MapFilesTag -{ - char *items_script; - char *items_pics; - char *items_dat; - char *dialogy_scr; - char *weapons_scr; - char *shops_dat; - char *enemy; - char *enemy_sound; -}SMapFiles; - -extern SMapFiles mapFiles; - -#define concat(c,a,b) strcpy((c=alloca(strlen(a)+strlen(b)+1)),a),strcat(c,b) - -extern char *sample_path; -extern word *icones,*vga_font; -extern word icone_color[7]; -extern char **actions; -extern char **steny2; -extern char **zivly; -extern char **sector_types; -extern char **act_types; -extern char **typy_zbrani; -extern char **typy_veci; -extern char **umisteni_veci; -extern char **side_flgs; -extern word menu_win; -extern int sektor_win; -extern draw_win; -extern m_zoom; -extern long xmap_offs,ymap_offs,cur_layer; -extern char sekceid[8]; -extern char filename[MAX_PATH]; -extern int test_mode; -extern int multiaction_win; -extern int enemy_win; -extern long wiz_tool_numb; -extern int item_win; -extern int vzor_win; -extern int selected_place; -extern char **config_file; -extern char *script_name; - -#define MSB_OK "Ok",NULL -#define MSB_ANONE "Ano","Ne",NULL -#define MSB_ANONEZRUSIT "Ano","Ne","Zru¨it",NULL -#define MSB_OKZRUSIT "Ok","Zru¨it",NULL -#define SCROLLBARCOL RGB(0,20,0) - -void graph_init(char windowed); -long def_window(word xs,word ys,char *name); -void def_dialoge(word x,word y,word xs, word ys, char *name); -void zoomin(); -void zoomout(); -char *pripona(char *fname,char *prip); -void browser(const char *pathname,char *filename); -void call_testmap(int); -void editor_veci(); -void pcxviewer(); - -void shop_train_edit(); -void save_items(); -void load_items(); -void save_all_shops(); -void load_all_shops(); -void re_build_shop_list(void *,void *, int); -void mapy_init(void); -void init_multiactions(); -void update_multiactions(); -void *save_macros(); -void load_macros(void *data); -void play_wav(va_list args); -void save_sound_map(); -void load_sound_map(); -void load_background(); -void mob_test_sound(); -void check_unused_sounds(); -int add_mob_sound(char *wav); -void mob_sound_copy(); -extern TSTR_LIST enemy_sound; -void edit_vyklenek(int idnum); -void create_isort_list(TSTR_LIST *ls_sorts,int filter); -void item_sound_call(void *it); - - -void remove_items_from_sector(int sector); -void remove_mobs_from_sector(int sector); - -char ask_password(char *pass,char text); -char check_data_password(void); -char *set_data_password(char *); - -char **read_ddl_dir(char *filter); -void read_ddl_list_wav(char ***list); - - diff --git a/MAPS/ITEMS.C b/MAPS/ITEMS.C deleted file mode 100644 index d80a771..0000000 --- a/MAPS/ITEMS.C +++ /dev/null @@ -1,1012 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mapy.h" -#include "globals.h" -#include "edit_map.h" - -#define ITEM_IKON "..\\grafika\\items\\" - -//------------------------MAP EDIT ITEM SYSTEM----------------------- - -#define MARK_INSIDE 0x8101 -#define MARK_NEXT 0x8102 -#define MARK_END_GROUP 0x8100 - -TITEM *item_tree=NULL; - -TITEM *clean_item(TITEM *it) - { - memset(it,0,sizeof(*it)); - return it; - } - -TITEM *create_new_item() - { - if (item_tree==NULL) - { - item_tree=(TITEM *)getmem(sizeof(TITEM)); - item_tree->next=NULL; - item_tree->inside=NULL; - item_tree->parent=NULL; - } - else - { - TITEM *p; - - p=(TITEM *)getmem(sizeof(TITEM)); - p[0].next=item_tree; - p[0].inside=NULL; - p[0].parent=NULL; - item_tree->parent=p; - item_tree=p; - } - return item_tree; - } - -TITEM *isolate_item(TITEM *it) - { - TITEM *p; - - p=it->parent; - if (it==item_tree) - { - item_tree=it->next; - item_tree->parent=NULL; - it->next=NULL; - it->parent=NULL; - } - else - if (p!=NULL) - if (p->inside==it) - { - p->inside=it->next; - it->parent=NULL; - it->next=NULL; - if (p->inside!=NULL)(p->inside)->parent=p; - } - else - { - p->next=it->next; - it->parent=NULL; - it->next=NULL; - if (p->next!=NULL)(p->next)->parent=p; - } - return it; - } - -TITEM *isolate_item_group(TITEM *it) - { - TITEM *p; - - p=it->parent; - if (p!=NULL) - if (p->inside==it) - { - p->inside=NULL; - it->parent=NULL; - } - else - { - p->next=NULL; - it->parent=NULL; - } - return it; - } - - -TITEM *insert_inside(TITEM *it1,TITEM *it2) - { - TITEM *p; - - if (it1->parent!=NULL) return NULL; //chyba: predmet je uz nekde vlozen - je nutne ho izolovat - p=it2; - while (p!=it1 && p!=NULL) p=p->parent; - if (p==it1) return NULL; //chyba v integrite : nelze vlozit predmet do sebe; - p=it1; - while (p->next!=NULL) p=p->next; - p->next=it2->inside; - it2->inside=it1; - it1->parent=it2; - if (p->next!=NULL) (p->next)->parent=p; - return it2; - } - -TITEM *insert_isolated(TITEM *it1) //vlozi izolovany predmet na zakladni uroven - { - if (it1->parent==NULL && it1->next==NULL) - { - if ((it1->next=item_tree)!=NULL) item_tree->parent=it1; - item_tree=it1; - return item_tree; - } - else - return NULL; //predmet neni izolovan; - } - -TITEM *create_location(TITEM *it,int druh,int sector,int posit,char *level) - { - it->jmeno[0]='~'; - it->jmeno[1]=0; - switch (druh) - { - case IT_MAPLOC:sprintf(it->popis,"MAPA: %s SECT: %d POS: %d",level,sector,posit);break; - case IT_MONSTER:sprintf(it->popis,"MAPA: %s OBLUDA: %d UMISTENI %d",level,sector,posit); - } - it->druh=druh; - it->hmotnost=sector; - it->nosnost=posit; - return it; - } - -void generate_item_list(TITEM *start,TSTR_LIST *list, char first) - { - static char c[80]; - static int start_list; - - if (first) start_list=0; - while (start!=NULL) - if (start->jmeno[0]!='~') - { - sprintf(c,"%08X %s",(int)start,start->jmeno); - if (str_replace(list,start_list,c)==NULL) return; - start_list++; - if (start->inside!=NULL) generate_item_list(start->inside,list,0); - start=start->next; - } - } -void generate_item_tree(TITEM *start,TSTR_LIST *list, char first) - { - static char tree[80]; - static char c[80]; - static int start_list; - - if (first) - { - start_list=0; - tree[0]='\0'; - } - strcat(tree," "); - while (start!=NULL) - { - if (start->next==NULL) - { - char *d; - - d=strchr(tree,'\0')-3; - strcpy(d,"�� "); - } - else - { - char *d; - - d=strchr(tree,'\0')-3; - strcpy(d,"�� "); - } - if (start->jmeno[0]=='~') - sprintf(c,"%08X %s%s",(int)start,tree,start->popis); - else - sprintf(c,"%08X %s%s",(int)start,tree,start->jmeno); - if (str_replace(list,start_list,c)==NULL) return; - start_list++; - if (start->inside!=NULL) - { - if (start->next==NULL) - { - char *d; - - d=strchr(tree,'\0')-3; - strcpy(d,"\xdb\xdb "); - } - else - { - char *d; - - d=strchr(tree,'\0')-3; - strcpy(d,"ďż˝\xdb "); - } - generate_item_tree(start->inside,list,0); - } - start=start->next; - } - tree[strlen(tree)-3]='\0'; - } - -void save_item_group(TITEM *it,FILE *f); - -void save_item(TITEM *it,FILE *f) - { - fwrite(it,1,sizeof(*it),f); - if (it->inside!=NULL) - { - { - unsigned short i=MARK_INSIDE; - - fwrite(&i,1,sizeof(i),f); - } - save_item_group(it->inside,f); - } - if (it->next!=NULL) - { - unsigned short i=MARK_NEXT; - - fwrite(&i,1,sizeof(i),f); - } - else - { - unsigned short i=MARK_END_GROUP; - - fwrite(&i,1,sizeof(i),f); - } - } - -void save_item_group(TITEM *it,FILE *f) - { - while (it!=NULL) - { - save_item(it,f); - it=it->next; - } - } - -TITEM *load_group(TITEM *parent,FILE *f) - { - TITEM *p,*q=NULL; - unsigned short mark=MARK_NEXT; - - - while (mark==MARK_NEXT) - { - p=(TITEM *)getmem(sizeof(TITEM)); - fread(p,1,sizeof(*p),f); - p->next=q; - p->parent=parent; - p->inside=NULL; - if (q!=NULL) q->parent=p; - q=p; - fread(&mark,1,sizeof(mark),f); - if (mark==MARK_INSIDE) - { - p->inside=load_group(p,f); - fread(&mark,1,sizeof(mark),f); - } - } - return q; - } - -int delete_item(TITEM *it) - { - TITEM *p; - - if (it->parent!=NULL || it->next!=NULL) return -1; - p=it->inside; - while (p!=NULL) - { - TITEM *q; - - q=p->next; - insert_isolated(isolate_item(p)); - p=q; - } - free(it); - return 0; - } -TITEM *clone_item(TITEM *it,char inside) - { - TITEM *i2,*i3,*i4,*i5,*i6; - - i2=create_new_item(); - memcpy(i2,it,sizeof(TITEM)-12); - if (it->inside!=NULL) - if (inside) - { - i4=it->inside;i5=NULL;i6=NULL; - while (i4!=NULL) - { - i3=clone_item(i4,inside); - i3=isolate_item(i3); - if (i5==NULL) - { - i5=i3; - i6=i3; - i5->parent=i2; - } - else - { - i6->next=i3; - i3->parent=i6; - i6=i6->next; - } - i4=i4->next; - } - i2->inside=i5; - } - return i2; - } - -//-------------------------------------------------------------- -void workspace_draw(int x1,int y1,int x2, int y2,OBJREC *o); - -TITEM *selected_item; -int lastpos_sec; -int lastpos_sid; - - -void workspace_items(int x1,int y1,int x2, int y2, OBJREC *o) - { - int xc,yc,x,y,s,p; - int xb1,yb1,xb2,yb2; - char *c; - char cn[20],dn[20]; - int mapx,mapy; - TITEM *pt; - - workspace_draw(x1,y1,x2,y2,o); - xc=(o->xs % M_ZOOM)>>1; - yc=(o->ys % M_ZOOM)>>1; - *(long *)o->data=1; - mapx=(x2-x1)>>m_zoom; - mapy=(y2-y1)>>m_zoom; - pt=item_tree; - while (pt!=NULL) - { - if (pt->druh==IT_MAPLOC) - { - c=&pt->popis; - sscanf(c,"%s%s",dn,cn); - s=pt->hmotnost; - p=pt->nosnost; - if (minfo[s].layer==cur_layer && !strcmp(cn,filename)) - { - x=minfo[s].x;y=minfo[s].y; - x-=xmap_offs; - y-=ymap_offs; - if (x>=0 && y>=0 && xlocx+x*M_ZOOM+(M_ZOOM/2)*((p & 1)!=((p & 2)>>1)); - yb1=yc+o->locy+y*M_ZOOM+(M_ZOOM/2)*((p & 2)!=0); - xb2=xb1+M_ZOOM/2-1; - yb2=yb1+M_ZOOM/2-1; - curcolor=RGB555(31,0,31); - line(xb1,yb1,xb2,yb2); - line(xb2,yb1,xb1,yb2); - } - } - } - pt=pt->next; - } - } - -void workspace_select_item(EVENT_MSG *msg,OBJREC *o) - { - MS_EVENT *ms; - int xn,yn,xc,yc; - int x1,y1,xp,yp; - int s,l,i; - char *c; - TITEM *it; - - xc=(o->xs % M_ZOOM)>>1; - yc=(o->ys % M_ZOOM)>>1; - xn=o->locx+xc; - yn=o->locy+yc; - if (msg->msg==E_MOUSE) - if ((ms=get_mouse(msg))->event_type==0x2) - { - x1=(ms->x-xn)/(M_ZOOM/2); - y1=(ms->y-yn)/(M_ZOOM/2); - xp=x1 & 0x1;x1>>=1; - yp=y1 & 0x1;y1>>=1; - x1+=xmap_offs; - y1+=ymap_offs; - l=2*(yp!=0)+(xp!=yp); - for (i=0;idruh==IT_MAPLOC) - { - char cn[20],dn[20]; - int lc; - - c=&it->popis; - sscanf(c,"%s%s%s%d%s%d",dn,cn,dn,&s,dn,&lc); - if (s==i && lc==l && !strcmp(cn,filename)) - { - selected_item=it; - return; - } - } - it=it->next; - } - } - selected_item=NULL; - } - } - -TITEM *items_on_map() - { - OBJREC *o; - - waktual->modal=0; - create_map_win(-1); - select_window(tool_bar); - if (waktual->id==tool_bar) close_current(); - select_window(map_win); - o=find_object(waktual,10); - o->call_draw=workspace_items; - o->call_event=workspace_select_item; - set_window_modal(); - selected_item=NULL; - while (selected_item==NULL && waktual->id==map_win) do_events(); - if (waktual->id==map_win) close_current(); - waktual->modal=1; - return selected_item; - } - -void item_umisti_v_mape(TITEM *it) - { - OBJREC *o; - - waktual->modal=0; - create_map_win(-1); - select_window(tool_bar); - if (waktual->id==tool_bar) close_current(); - select_window(map_win); - o=find_object(waktual,10); - o->call_draw=workspace_items; - o->call_event=workspace_select_item; - set_window_modal(); - lastpos_sec=-1; - while (waktual->id==map_win) - { - do_events(); - if (lastpos_sec!=-1) - { - if (selected_item!=NULL) insert_inside(isolate_item(clone_item(it,0)),selected_item); - else insert_inside(isolate_item(clone_item(it,1)),create_location(create_new_item(),IT_MAPLOC,lastpos_sec,lastpos_sid,filename)); - lastpos_sec=-1; - redraw_desktop(); - } - } - waktual->modal=1; - return; - } - -void ikona_display(int x1,int y1,int x2,int y2,OBJREC *o) - { - static char *ikonlib=NULL; - static int lastikolib=-1; - int nowlib; - int ikn; - char s[200]; - - ikn=*(int *)o->data; - nowlib=ikn/18; - if (lastikolib!=nowlib) - { - FILE *f;int i; - sprintf(s,ITEM_IKON"ikony%02d.lib",nowlib); - f=fopen(s,"rb"); - if (f==NULL) - for(i=0;i<18;i++) - { - memset(&ikonlib[2+2+2+512+2475*i],0,2993); - } - else - { - if (ikonlib==NULL) ikonlib=(char *)getmem(18*2993); - fread(ikonlib,1,18*2993,f); - fclose(f); - } - lastikolib=nowlib; - } - ikn%=18; - bar(x1,y1,x2,y2); - put_picture(x1,y1,ikonlib+ikn*2993); - } - -void ikona_click(EVENT_MSG *msg,OBJREC *o) - { - MS_EVENT *ms; - - o; - if (msg->msg==E_MOUSE) - { - ms=get_mouse(msg); - if (ms->event_type==0x4) - set_change(); - } - } - -void ikona(OBJREC *o) - { - o->call_draw=ikona_display; - o->call_event=ikona_click; - o->datasize=4; - } - -int select_ikon_lib(int last) - { - int x,y,i,s; - - s=last; - def_dialoge(50,200,500,264,"Knihovna ikon - vyber jednu ikonu"); - x=5;y=20; - for (i=0;i<30;i++) - { - define(i+10,x,y,45,55,0,ikona);c_default(last+i); - property(def_border(5,WINCOLOR),NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - x+=48;if (x+48>490) {y+=58;x=5;} - } - define(300,10,10,80,20,3,button,"<<"); - property(def_border(1,0),NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(310,10,10,80,20,2,button,">>"); - property(def_border(1,0),NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(320,175-40,10,80,20,3,button,"Zruďż˝it"); - property(def_border(1,0),NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - redraw_window(); - do - { - escape(); - if (o_aktual->id==300) - { - last-=30;if (last<0) last=0; - for(i=0;i<30;i++) c_set_value(0,10+i,last+i); - } - if (o_aktual->id==310) - { - last+=30; - for(i=0;i<30;i++) c_set_value(0,10+i,last+i); - } - } - while (o_aktual->id==310 || o_aktual->id==300); - i=o_aktual->id; - close_current(); - if (i==320) i=s; else i=i-10+last; - return i; - } - -void change_item_ikone() - { - c_set_value(0,130,select_ikon_lib(f_get_value(0,130))); - } - -char nvlast[][16]= - {"cSďż˝la","Schopnost magie","Pohyblivost","Obratnost","Max zranďż˝nďż˝", - "Kondice","Max mana","Obrana(dolnďż˝)","Obrana(Hornďż˝)","ďż˝tok(Dolnďż˝)", - "ďż˝tok(Hornďż˝)","Oheďż˝","Voda","Zemďż˝","Vzduch","Mysl","Magickďż˝ sďż˝la(D)", - "Magickďż˝ sďż˝la(H)","\0"}; - -void ukaz_vlastnosti(int pocet,int x,int y,int id,short *it) - { - word i,ts; - - i=0; - curfont=vga_font; - default_font=curfont; - while (nvlast[i][0] && i200) - { - x+=200; - y=20; - } - define(-1,x,y,ts,10,0,label,nvlast[i]); - define(id++,x+130,y,60,12,0,input_line,7,-32767,+32767,"%6d"); - property(def_border(5,WINCOLOR),NULL,NULL,WINCOLOR); - set_default(strs(*it));it++; - on_exit(test_int); - y+=15; - i++; - } - } - -void oprav_vlastnosti(TITEM *it) - { - int i; - def_dialoge(120,80,410,300,"Vlastnosti"); - ukaz_vlastnosti(4,5,20,70,&it->podminky); - define(-1,5,93,190,0,0,label,"");property(def_border(2,WINCOLOR),NULL,NULL,WINCOLOR); - ukaz_vlastnosti(99,5,105,80,&it->zmeny); - define(130,5,200,100,10,0,check_box,"Na hlavu"); - define(140,5,212,100,10,0,check_box,"Na krk"); - define(150,5,224,100,10,0,check_box,"Na telo"); - define(160,5,236,100,10,0,check_box,"Na ruce"); - define(170,5,248,100,10,0,check_box,"Na lokte"); - define(180,5,260,100,10,0,check_box,"Kolem pasu"); - define(190,5,272,100,10,0,check_box,"Na nohy"); - define(200,105,200,100,10,0,check_box,"Na chodidla"); - define(210,105,212,100,10,0,check_box,"Na ramena"); - define(220,105,224,100,10,0,check_box,"Na zďż˝da"); - define(300,10,10,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui); - property(def_border(1,0),NULL,NULL,WINCOLOR); - define(310,10,40,80,20,2,button,"Ok");on_control_change(terminate_gui); - property(def_border(1,0),NULL,NULL,WINCOLOR); - define(-1,225,206,70,10,0,label,"Magickďż˝ ďż˝tok"); - define(250,225,218,70,70,0,radio_butts,5,"Oheďż˝","Voda","Zemďż˝","Vzduch","Mysl"); - c_default(it->zmeny[VLS_MGZIVEL]); - fill_bit_fields(0,130,it->place_map,11); - redraw_window(); - escape(); - if (o_aktual->id==310) - { - for(i=0;i<4;i++) it->podminky[i]=vals(i+70); - for(i=0;i<18;i++) it->zmeny[i]=vals(i+80); - it->place_map=get_bit_fields(0,130,10); - it->zmeny[VLS_MGZIVEL]=f_get_value(0,250); - } - close_current(); - } - -void otevri_vlastnosti() - { - TITEM *it; - - get_value(0,5,&it); - oprav_vlastnosti(it); - } - -void save_edited_item() - { - TITEM *it; - - get_value(0,5,&it); - get_value(0,15,it->jmeno); - get_value(0,20,it->popis); - it->hmotnost=vals(40); - it->nosnost=vals(50); - it->keynum=vals(60); - it->user_value=vals(70); - it->use_event=vals(80); - it->druh=f_get_value(0,90); - it->spell=vals(100); - it->magie=vals(110); - it->silaspell=vals(120); - it->ikona=f_get_value(0,130); - terminate_gui(); - } - -TITEM *select_item(TITEM *it); - -void e_item_insert_inside() - { - TITEM *it,*is; - - save_edited_item(); - get_value(0,5,&it); - is=select_item(item_tree); - if (is==NULL) return; - it=isolate_item(it); - if (insert_inside(it,is)==NULL) - { - msg_box("Chyba integrity:",'\x1',"Nelze vloďż˝it tento pďż˝edmďż˝t do zvolenďż˝ho " - "Patrnďż˝ se pokou��� vloďż˝it tut�� vďż˝c samu do sebe. Nebo vďż˝c nenďż˝ " - "izolovďż˝na, nebo ji nelze izolovat. Je moďż˝nďż˝ ďż˝e se sna��� vloďż˝it " - "vďż˝c do vďż˝ci, kterďż˝ je uvnitďż˝ tďż˝to vďż˝ci, nebo v uvnitďż˝ vďż˝ci, kterďż˝ " - "je uvnitďż˝ vďż˝ci, do kterďż˝ chceďż˝ vďż˝c umďż˝stit atd. Mohlo by dojit k " - "zacyklenďż˝ a to nelze dopustit. Program bude vďż˝c izolovat, jelikoďż˝ " - "jiďż˝ nelze rekonstruovat pďż˝vodnďż˝ stav","Budu si pamatovat",NULL); - insert_isolated(it); - return; - } - terminate_gui(); - } - -void e_item_insert_map() - { - TITEM *it; - - save_edited_item(); - get_value(0,5,&it); - item_umisti_v_mape(it); - } -void item_edit(TITEM *it) - { - CTL3D *c; - - c=def_border(5,WINCOLOR); - def_dialoge(120,80,410,300,"Oprava ďż˝dajďż˝ o pďż˝edmďż˝tu"); - curfont=vga_font; - default_font=curfont; - define(-1,5,20,50,10,0,label,"Jmďż˝no (31 znakďż˝)"); - define(15,10,35,288,12,0,input_line,31);set_default(it->jmeno); - property(def_border(2,WINCOLOR),NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - define(-1,5,50,50,10,0,label,"Popis (63 znakďż˝)"); - define(20,10,65,380,12,0,input_line,63);set_default(it->popis); - property(def_border(2,WINCOLOR),NULL,flat_color(0xF),WINCOLOR); - define(5,0,0,0,0,0,value_store,4);set_default(&it); - define(30,10,30,80,20,1,button,"Vlastnosti"); - property(def_border(1,0),NULL,NULL,WINCOLOR);on_control_change(otevri_vlastnosti); - define(-1,5,80,100,10,0,label,"Hmotnost"); - define(-1,5,95,100,10,0,label,"Nosnost"); - define(-1,5,110,100,10,0,label,"ID Kl��e"); - define(-1,5,125,100,10,0,label,"?Hodnota"); - define(-1,5,140,100,10,0,label,"ďż˝.Udďż˝losti"); - define(-1,5,155,100,10,0,label,"Druh"); - def_border(5,WINCOLOR); - define(40,105,80,60,12,0,input_line,7,-32767,+32767,"%6d"); - property(c,NULL,NULL,WINCOLOR);on_exit(test_int);set_default(strs(it->hmotnost)); - define(50,105,95,60,12,0,input_line,7,-32767,+32767,"%6d"); - property(c,NULL,NULL,WINCOLOR);on_exit(test_int);set_default(strs(it->nosnost)); - define(60,105,110,60,12,0,input_line,7,-32767,+32767,"%6d"); - property(c,NULL,NULL,WINCOLOR);on_exit(test_int);set_default(strs(it->keynum)); - define(70,105,125,60,12,0,input_line,7,-32767,+32767,"%6d"); - property(c,NULL,NULL,WINCOLOR);on_exit(test_int);set_default(strs(it->user_value)); - define(80,105,140,60,12,0,input_line,7,-32767,+32767,"%6d"); - property(c,NULL,NULL,WINCOLOR);on_exit(test_int);set_default(strs(it->use_event)); - define(90,80,155,120,108,0,radio_butts,10, - "Nespecif.", - "Brnďż˝nďż˝", - "Ruďż˝nďż˝ zbraďż˝", - "Svitek/Hulka", - "Stďż˝elnďż˝ zbr.", - "Vrhacďż˝", - "Lektvar/Mďż˝ch", - "Jďż˝dlo", - "Batoh/Truhla", - "Specialnďż˝");c_default(it->druh); - define(-1,105,80,100,10,1,label,"Kouzlo:"); - define(-1,105,95,100,10,1,label,"Mana celk:"); - define(-1,105,110,100,10,1,label,"Sďż˝la kouzla"); - define(100,55,80,60,12,1,input_line,7,-32767,32767,"%6d");on_exit(test_int); - property(c,NULL,NULL,WINCOLOR);set_default(strs(it->spell)); - define(110,55,95,60,12,1,input_line,7,-32767,32767,"%6d");on_exit(test_int); - property(c,NULL,NULL,WINCOLOR);set_default(strs(it->magie)); - define(120,55,110,60,12,1,input_line,7,-32767,32767,"%6d");on_exit(test_int); - property(c,NULL,NULL,WINCOLOR);set_default(strs(it->silaspell)); - define(130,10,180,45,55,0,ikona);c_default(it->ikona); - property(c,NULL,NULL,WINCOLOR);on_control_change(change_item_ikone); - define(300,10,10,80,20,3,button,"Uloďż˝");property(def_border(1,0),NULL,NULL,RGB(0,24,0));on_control_change(save_edited_item); - define(310,100,10,80,20,3,button,"Vloďż˝it do");property(def_border(1,0),NULL,NULL,WINCOLOR);on_control_change(e_item_insert_inside); - define(320,100,10,80,20,2,button,"Umďż˝stit");property(def_border(1,0),NULL,NULL,WINCOLOR);on_control_change(e_item_insert_map); - define(330,10,10,80,20,2,button,"Zruďż˝it");property(def_border(1,0),NULL,flat_color(RGB555(31,31,31)),RGB555(16,0,0);on_control_change(terminate_gui); - redraw_window(); - escape(); - close_current(); - } - - -void select_item_edit() - { - TITEM *it; - TSTR_LIST ls; - int i; - - send_message(E_GUI,9,E_CONTROL,0,&ls); - i=f_get_value(0,9); - if (ls[i]==NULL) return; - sscanf(ls[i],"%X",&it); - if ((unsigned short)it->druh>=256) - { - msg_box("Nelze!",'\x1',"Nelze upravovat tento druh vďż˝ci","Beru na vďż˝domďż˝",NULL); - return; - } - item_edit(it); - generate_item_tree(item_tree,&ls,1); - str_delfreelines(&ls); - send_message(E_GUI,9,E_CONTROL,1,ls); - } - -void select_item_klon() - { - TITEM *it; - TSTR_LIST ls; - int i; - - send_message(E_GUI,9,E_CONTROL,0,&ls); - i=f_get_value(0,9); - if (ls[i]==NULL) return; - sscanf(ls[i],"%X",&it); - if ((unsigned short)it->druh>=256) - { - msg_box("Nelze!",'\x1',"Nelze klonovat tento druh vďż˝ci","Beru na vďż˝domďż˝",NULL); - return; - } - if (it->inside!=NULL) - { - i=msg_box("Klonovat",'\x2',"Klonovat i vďż˝ci uvnitďż˝?","Ano","Ne",NULL); - } - it=clone_item(it,i==1); - generate_item_tree(item_tree,&ls,1); - str_delfreelines(&ls); - send_message(E_GUI,9,E_CONTROL,1,ls); - } - -void select_item_isolate() - { - TITEM *it; - TSTR_LIST ls; - int i; - - send_message(E_GUI,9,E_CONTROL,0,&ls); - i=f_get_value(0,9); - if (ls[i]==NULL) return; - sscanf(ls[i],"%X",&it); - isolate_item(it); - insert_isolated(it); - generate_item_tree(item_tree,&ls,1); - str_delfreelines(&ls); - send_message(E_GUI,9,E_CONTROL,1,ls); - } - -void check_for_empty_loc() - { - TITEM *it1,*it2; - - it1=item_tree; - while (it1!=NULL) - { - if ((it1->druh==IT_MAPLOC || it1->druh==IT_MONSTER) && it1->inside==NULL) - { - it2=it1;it1=it2->next; - isolate_item(it2); - delete_item(it2); - } - else - it1=it1->next; - } - } - -void select_item_delete() - { - TITEM *it; - TSTR_LIST ls; - int i; - - send_message(E_GUI,9,E_CONTROL,0,&ls); - i=f_get_value(0,9); - if (ls[i]==NULL) return; - sscanf(ls[i],"%X",&it); - if (item_tree==it && it->next==NULL) - { - msg_box("Nelze!",'\x1',"Jeden pďż˝edmďż˝t musďż˝ zďż˝stat","Ok",NULL); - return; - } - if (msg_box("Pďż˝edmďż˝ty",'\x2',"Vymazat vybranou vďż˝c","Souhlas","Ne",NULL)==2) return; - isolate_item(it); - delete_item(it); - check_for_empty_loc(); - release_list(ls); - ls=create_list(16); - generate_item_tree(item_tree,&ls,1); - str_delfreelines(&ls); - send_message(E_GUI,9,E_CONTROL,1,ls); - set_value(0,5,item_tree); - } - -void items_on_map_show() - { - TITEM *it; - TSTR_LIST il; - int ls; - int i; - - send_message(E_GUI,9,E_CONTROL,0,&il); - i=f_get_value(0,9); - if (il[i]==NULL) return; - sscanf(il[i],"%X",&it); - unselect_map(); - if (it->druh==IT_MAPLOC) - { - char c[20],d[20]; - sscanf(it->popis,"%s%s",c,d); - if (!strcmp(d,filename)) minfo[it->hmotnost].flags|=0x1; - } - it=items_on_map(); - if (it==NULL) return; - ls=str_count(il); - for(i=0;iid==60) - { - cis=f_get_value(0,9); - send_message(E_GUI,9,E_CONTROL,0,&il); - c=il[cis]; - if (c!=NULL) sscanf(c,"%x",&it); - } - close_current(); - return it; - } - -void editor_veci() - { - if (item_tree==NULL) item_edit(clean_item(create_new_item())); - select_item(item_tree); - } - -void save_items() - { - FILE *f; - - if (item_tree==NULL) return; - f=fopen(ITEM_FILE,"wb"); - save_item_group(item_tree,f); - fclose(f); - } - -void load_items() - { - FILE *f; - - f=fopen(ITEM_FILE,"rb"); - if (f==NULL) return; - item_tree=load_group(NULL,f); - fclose(f); - } diff --git a/MAPS/ITEMS2.C b/MAPS/ITEMS2.C deleted file mode 100644 index 2cdc66e..0000000 --- a/MAPS/ITEMS2.C +++ /dev/null @@ -1,1707 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mapy.h" -#include "globals.h" -#include "edit_map.h" -#include "steny.h" -#include "save_map.h" -#include "mob_edit.h" - - -#define ITEM_BUFFER 256 -#define SV_ITLIST 0x8001 -#define SV_SNDLIST 0x8002 -#define SV_END 0x8000 -#define SV_PASSW 0x1000 - -#define ITEM_IKON "..\\graphics\\items\\" -#define ITEM_MALE "..\\graphics\\basic\\char00.pcx" - -#define DIALOG_MASK "..\\graphics\\dialogs\\*.hi" - - -#define IT_INSIDE 0x1 -#define IT_IDENTF 0x2 -#define IT_UNIKAT 0x4 -#define IT_MAGIC 0x8 - -TITEM item_list[ITEM_SORTS]; -short *item_place[MAPSIZE*4]; -short item_buffer[ITEM_BUFFER]; -short max_items; -int item_win=-1; -int vzor_win=-1; -int selected_place=-1; -int preview_win=-1; -int grep_num=-1; - -static int shop_window=-1; - -TSTR_LIST vzhled_veci; -TSTR_LIST pohledy_veci; - -TSTR_LIST ls_buffer=NULL,ls_sorts=NULL; -TSTR_LIST itm_sounds=NULL; - -TSHOP *shop_list=NULL;int max_shops=0; -TSTR_LIST shop_items=NULL;short shop_max_id=1; -TTRAINING *train_list=NULL;int max_trains=0; - -void clear_it_buffer(); - -void init_item_system(void) - { - static char again=0; - int i; - - if (again) for(i=0;idata; - nowlib=ikn/18; - if (lastikolib!=nowlib) - { - FILE *f;int i;void *z;long size; - char *c=get_text_field(config_file,"CESTA_ITEMY"); - if (c==NULL) c=""; - sprintf(n,"ikony%02d.lib",nowlib); - sprintf(s,"%s%s",c,n); - if (ikonlib==NULL) ikonlib=(char *)getmem(18*2993); - f=fopen(s,"rb"); - if (f==NULL) - if ((z=afile(n,read_group(0),&size))==NULL) - for(i=0;i<18;i++) - { - memset(ikonlib+i*2993,0,2993); - } - else - { - memcpy(ikonlib,z,18*2993); - free(z); - } - else - { - fread(ikonlib,1,18*2993,f); - fclose(f); - } - lastikolib=nowlib; - for(i=0;i<18;i++) - { - int j; - word *z=(word *)(ikonlib+i*2993+6); - for (j=0;j<256;j++) z[j]=z[j]+(z[j] & 0x7FE0); - } - - } - ikn%=18; - bar(x1,y1,x2,y2); - put_picture(x1,y1,ikonlib+ikn*2993); - } - -void ikona_click(EVENT_MSG *msg,OBJREC *o) - { - MS_EVENT *ms; - - o; - if (msg->msg==E_MOUSE) - { - ms=get_mouse(msg); - if (ms->event_type==0x4) - set_change(); - } - } - -void ikona(OBJREC *o) - { - o->call_draw=ikona_display; - o->call_event=ikona_click; - o->datasize=4; - } - -int select_ikon_lib(int last) - { - int x,y,i,s; - - s=last; - def_dialoge(50,200,500,264,"Knihovna ikon - vyber jednu ikonu"); - x=5;y=20; - for (i=0;i<30;i++) - { - define(i+10,x,y,45,55,0,ikona);c_default(last+i); - property(def_border(5,WINCOLOR),NULL,NULL,0);on_control_change(terminate_gui); - x+=48;if (x+48>490) {y+=58;x=5;} - } - define(300,10,10,80,20,3,button,"<<"); - property(def_border(1,0),NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(310,10,10,80,20,2,button,">>"); - property(def_border(1,0),NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(320,175-40,10,80,20,3,button,"Zruďż˝it"); - property(def_border(1,0),NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - redraw_window(); - do - { - escape(); - if (o_aktual->id==300) - { - last-=30;if (last<0) last=0; - for(i=0;i<30;i++) c_set_value(0,10+i,last+i); - } - if (o_aktual->id==310) - { - last+=30; - for(i=0;i<30;i++) c_set_value(0,10+i,last+i); - } - } - while (o_aktual->id==310 || o_aktual->id==300); - i=o_aktual->id; - close_current(); - if (i==320) i=s; else i=i-10+last; - return i; - } - -void change_item_ikone() - { - c_set_value(0,130,select_ikon_lib(f_get_value(0,130))); - } - -char nvlast[][16]= - {"Sďż˝la","Schopnost magie","Pohyblivost","Obratnost","Max zranďż˝nďż˝", - "Kondice","Max mana","Obrana(dolnďż˝)","Obrana(Hornďż˝)","ďż˝tok(Dolnďż˝)", - "ďż˝tok(Hornďż˝)","Oheďż˝","Voda","Zemďż˝","Vzduch","Mysl","ďż˝ivoty Regen", - "Mana Regen","Kondice Regen","Magickďż˝ sďż˝la(D)", "Magickďż˝ sďż˝la(H)","","��innek zďż˝sahu","*"}; - -void ukaz_vlastnosti(int pocet,int x,int y,int id,short *it) - { - word i,ts; - - i=0; - curfont=vga_font; - default_font=curfont; - while (nvlast[i][0]!='*' && i250) - { - x+=200; - y=20; - } - if (nvlast[i][0]) - { - define(-1,x,y,ts,10,0,label,nvlast[i]); - define(id++,x+130,y,60,12,0,input_line,7,-32767,+32767,"%6d"); - property(def_border(5,WINCOLOR),NULL,NULL,WINCOLOR); - set_default(strs(*it)); - on_exit(test_int); - y+=15; - } - it++; - i++; - } - } - -void oprav_vlastnosti(TITEM *it) - { - int i; - def_dialoge(120,80,410,310,"Vlastnosti"); - ukaz_vlastnosti(4,5,20,70,it->podminky); - define(-1,5,93,190,0,0,label,"");property(def_border(2,WINCOLOR),NULL,NULL,WINCOLOR); - ukaz_vlastnosti(99,5,105,80,it->zmeny); - /*define(130,5,200,100,10,0,check_box,"Na hlavu"); - define(140,5,212,100,10,0,check_box,"Na krk"); - define(150,5,224,100,10,0,check_box,"Na telo"); - define(160,5,236,100,10,0,check_box,"Na ruce"); - define(170,5,248,100,10,0,check_box,"Na lokte"); - define(180,5,260,100,10,0,check_box,"Kolem pasu"); - define(190,5,272,100,10,0,check_box,"Na nohy"); - define(200,105,200,100,10,0,check_box,"Na chodidla"); - define(210,105,212,100,10,0,check_box,"Na ramena"); - define(220,105,224,100,10,0,check_box,"Na zďż˝da"); */ - define(300,10,10,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui); - property(def_border(1,0),NULL,NULL,WINCOLOR); - define(310,10,40,80,20,2,button,"Ok");on_control_change(terminate_gui); - property(def_border(1,0),NULL,NULL,WINCOLOR); - define(-1,225,216,70,10,0,label,"Magickďż˝ ďż˝tok"); - define(250,225,228,70,70,0,radio_butts,5,"Oheďż˝","Voda","Zemďż˝","Vzduch","Mysl"); - c_default(it->zmeny[VLS_MGZIVEL]); -// fill_bit_fields(0,130,it->place_map,11); - redraw_window(); - escape(); - if (o_aktual->id==310) - { - for(i=0;i<4;i++) it->podminky[i]=vals(i+70); - for(i=0;i<23;i++) it->zmeny[i]=vals(i+80); -// it->place_map=get_bit_fields(0,130,10); - it->zmeny[VLS_MGZIVEL]=f_get_value(0,250); - } - close_current(); - } - -void otevri_vlastnosti() - { - TITEM *it; - - get_value(0,5,&it); - oprav_vlastnosti(it); - } - -void item_special(TITEM *it) - { - int i,y; - CTL3D *c; - - def_dialoge(140,100,410,320,"Special - obrďż˝zky v letu"); - y=20;c=def_border(5,WINCOLOR); - for(i=0;i<16;i++) - { - define((i+1)*10,100,y,300,12,0,str_line,pohledy_veci);property(c,NULL,NULL,WINCOLOR); - c_default(it->v_letu[i]); on_enter(string_list_sup); - y+=15; if ((i & 3)==3) y+=5; - } - define(-1,5,20,1,1,0,label,"Zezadu"); - define(-1,5,85,1,1,0,label,"Ze strany"); - define(-1,5,150,1,1,0,label,"Zepďż˝edu"); - define(-1,5,215,1,1,0,label,"Vďż˝buch"); - define(300,10,10,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui); - define(310,100,10,80,20,2,button,"Ok");on_control_change(terminate_gui); - redraw_window(); - escape(); - if (o_aktual->id==310) - for(i=0;i<16;i++) it->v_letu[i]=f_get_value(0,i*10+10); - close_current(); - } - -void otevri_special() - { - TITEM *it; - - get_value(0,5,&it); - item_special(it); - } - -void items_adjusting() - { - int num; - TSTR_LIST pcxs=NULL; - char *filename; - int x1,y1,x2,y2,yy1,yy2; - word *vec = 0; - WINDOW *w; - char *c,*d; - word *male,malexs,maleys; - - w=find_window(preview_win); - c=get_text_field(config_file,"CESTA_BGRAFIKA"); if (c==NULL) c=""; - concat(d,c,"CHAR00.PCX"); - if (w!=NULL) close_window(w); - if (open_pcx(d,A_8BIT,(void *)&male)) - { - void *z;long s; - char *ss=strrchr(d,'\\'); - if (ss==NULL) ss=d;else ss=ss+1; - - if ((z=afile(ss,read_group(0),&s))==NULL) return; - load_pcx(z,s,A_8BIT,(void *)&male);free(z); - } - malexs=male[0]; - maleys=male[1]; - free(male); - read_side_list(ITEMS_SCRIPT,&pcxs,2,4); - num=f_get_value(0,190); - if (num >= str_count(pcxs)) - num = 0; - concat(c,"",pcxs[num]); - d=get_text_field(config_file,"CESTA_ITEMY");if (d==NULL) d=""; - concat(filename,d,c); - release_list(pcxs); - if (open_pcx(filename,A_8BIT,(void *)&vec)) - { - void *z;long s; - - if ((z=afile(c,read_group(0),&s))==NULL) - { - msg_box("Soubor nenalezen!",'\x1',filename,"Ok",NULL); - return; - } - load_pcx(z,s,A_8BIT,(void *)&vec);free(z); - } - x1=vals(140); - y1=vals(150); - x2=vals(160); - y2=vals(170); - yy1=350-y1-vec[1]; - yy2=350-y2-vec[1]; - if (yy1<0 || yy2<0) - { - msg_box("Chyba!",'\x1',"Nelze zobrazit, protoďż˝e nďż˝hled je z��sti mimo obrazovku!","Ok",NULL); - return; - } - preview_win=def_window(300,400,"View"); - define(10,150-malexs/2,350-maleys,malexs,maleys,0,pcx_view);set_default(ITEM_MALE); - define(20,150+x1-vec[0]/2,yy1,1,1,0,pcx_view);set_default(filename); - define(30,150+x2-vec[0]/2,yy2,1,1,0,pcx_view);set_default(filename); - define(40,5,5,80,20,2,button,"Ok");on_control_change(close_current); - movesize_win(waktual,0,0,300,400); - redraw_window(); - free(vec); - } - - -static add_sound_to_table(char *s) - { - int cnt; - int i; - - cnt=str_count(itm_sounds); - for(i=1;isound; y=160+15; - if (z==0) s=NULL;else s=itm_sounds[z]; - if (s==NULL) s=""; - define(-1,5,y,1,1,0,label,"Zvuk:"); - define(20,120,y,120,12,0,input_line,13);property(&b2,NULL,NULL,WINCOLOR); - set_default(s); - define(40,245,y,20,12,0,button,"<"); - property(&b1,NULL,NULL,WINCOLOR);on_control_change(mob_sound_copy); - } - define(100,5,5,80,20,2,button,"Ok");on_control_change(terminate_gui); property(&b1,NULL,NULL,WINCOLOR); - define(110,90,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui); property(&b1,NULL,NULL,WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==100) - { - char s[200]; - int z; - get_value(0,20,s); - strupper(s); - z=it->sound; - if (s[0])it->sound=add_sound_to_table(s);else it->sound=0; - delete_unused_sound(z); - } - close_current(); - check_unused_sounds(); - } - - -static void item_sound() - { - TITEM *it; - - get_value(0,5,&it); - item_sound_call(it); - } - -void save_edited_item() - { - TITEM *it; - WINDOW *w; - - get_value(0,5,&it); - get_value(0,15,it->jmeno); - get_value(0,20,it->popis); - it->hmotnost=vals(40); - it->nosnost=vals(50); - it->keynum=vals(60); - it->user_value=vals(70); - it->use_event=vals(80); - it->druh=f_get_value(0,90); - it->spell=vals(100); - it->magie=vals(110); - it->cena=vals(120); - it->ikona=f_get_value(0,130); - it->polohy[0][0]=vals(140); - it->polohy[0][1]=vals(150); - it->polohy[1][0]=vals(160); - it->polohy[1][1]=vals(170); - it->umisteni=f_get_value(0,180); - it->vzhled=f_get_value(0,190); - it->flags=get_bit_fields(0,210,2); - it->typ_zbrane=f_get_value(0,200); - it->zmeny[VLS_KOUZLA]=f_get_value(0,700); - it->animace=f_get_value(0,400); - it->hitpos=vals(410); - it->shiftup=0xff; - w=find_window(preview_win); - if (w!=NULL) close_window(w); - terminate_gui(); - } - - -void spell_affections(); - -static update_hitpos() - { - int i; - - i=f_get_value(0,400); - if (i==0) set_value(0,410,"0"); - else - if (weapons_pos[i]!=NULL) - { - set_value(0,410,weapons_pos[i]); - } - } - - - - - -void adjust_enter(EVENT_MSG *msg,OBJREC *o) - { - char update=0; - - if (msg->msg==E_KEYBOARD) - { - int s; - - char save=0; - - s=vals(o_aktual->id); - switch (*(int *)msg->data>>8) - { - case 'Q':s++;save=1;break; - case 'I':s--;save=1;break; - } - if (save) - { - char buff[256]; - set_value(0,o_aktual->id,itoa(s,buff,10)); - update=1; - } - } - - if (msg->msg==E_KEYBOARD && *(char *)(msg->data)==13) update=1; - if (update) - { - if (find_window(preview_win)!=NULL) - { - WINDOW *w; - int c; - w=waktual;c=o->id; - items_adjusting(); - select_window(w->id); - goto_control(c); - } - } - } - -void item_edit(TITEM *it) - { - CTL3D *c; - WINDOW *w; - int anm=it->animace; - - if (anm>=str_count(weapons)) anm=0; - c=def_border(5,WINCOLOR); - def_dialoge(220,80,410,350,"Oprava ďż˝dajďż˝ o pďż˝edmďż˝tu"); - curfont=vga_font; - default_font=curfont; - define(-1,5,20,50,10,0,label,"Jmďż˝no (31 znakďż˝)"); - define(15,10,35,288,12,0,input_line,31);set_default(it->jmeno); - property(def_border(2,WINCOLOR),NULL,flat_color(RGB555(16,0,0)),WINCOLOR); - define(-1,5,50,50,10,0,label,"Popis (31 znakďż˝)"); - define(20,10,65,380,12,0,input_line,31);set_default(it->popis); - property(def_border(2,WINCOLOR),NULL,flat_color(0xF),WINCOLOR); - define(5,0,0,0,0,0,value_store,4);set_default(&it); - define(30,10,30,80,20,1,button,"Vlastnosti"); - property(def_border(1,0),NULL,NULL,WINCOLOR);on_control_change(otevri_vlastnosti); - define(-1,5,80,100,10,0,label,"Hmotnost"); - define(-1,5,95,100,10,0,label,"Nosnost"); - define(-1,5,110,100,10,0,label,"ID Kl��e"); - define(-1,5,125,100,10,0,label,"?Hodnota"); - define(-1,5,140,100,10,0,label,"ďż˝.Udďż˝losti"); - define(-1,5,155,100,10,0,label,"Druh"); - def_border(5,WINCOLOR); - define(40,105,80,60,12,0,input_line,7,-32767,+32767,"%6d"); - property(c,NULL,NULL,WINCOLOR);on_exit(test_int);set_default(strs(it->hmotnost)); - define(50,105,95,60,12,0,input_line,7,-32767,+32767,"%6d"); - property(c,NULL,NULL,WINCOLOR);on_exit(test_int);set_default(strs(it->nosnost)); - define(60,105,110,60,12,0,input_line,7,-32767,+32767,"%6d"); - property(c,NULL,NULL,WINCOLOR);on_exit(test_int);set_default(strs(it->keynum)); - define(70,105,125,60,12,0,input_line,7,-32767,+32767,"%6d"); - property(c,NULL,NULL,WINCOLOR);on_exit(test_int);set_default(strs(it->user_value)); - define(80,105,140,60,12,0,input_line,7,-32767,+32767,"%6d"); - property(c,NULL,NULL,WINCOLOR);on_exit(test_int);set_default(strs(it->use_event)); - define(90,80,160,220,12,0,str_line,typy_veci);property(c,NULL,NULL,WINCOLOR); - on_enter(string_list_sup);c_default(it->druh); - define(-1,105,80,100,10,1,label,"Kouzlo:"); - define(-1,105,95,100,10,1,label,"Mana celk:"); - define(-1,105,110,100,10,1,label,"Cena vďż˝ci"); - define(-1,105,125,100,10,1,label,"Poloha1(XY)"); - define(-1,105,140,100,10,1,label,"Poloha2(XY)"); - define(100,55,80,50,12,1,input_line,7,-32767,32767,"%6d");on_exit(test_int); - property(c,NULL,NULL,WINCOLOR);set_default(strs(it->spell)); - define(110,55,95,50,12,1,input_line,7,-32767,32767,"%6d");on_exit(test_int); - property(c,NULL,NULL,WINCOLOR);set_default(strs(it->magie)); - define(120,5,110,100,12,1,input_line,10,0,999999,"%10d");on_exit(test_int); - property(c,NULL,NULL,WINCOLOR);set_default(strs(it->cena)); - define(140,55,125,50,12,1,input_line,7,-32767,32767,"%5d");on_exit(test_int); - property(c,NULL,NULL,WINCOLOR);set_default(strs(it->polohy[0][0]));on_event(adjust_enter); - define(150,5,125,45,12,1,input_line,7,-32767,32767,"%5d");on_exit(test_int); - property(c,NULL,NULL,WINCOLOR);set_default(strs(it->polohy[0][1]));on_event(adjust_enter); - define(160,55,140,50,12,1,input_line,7,-32767,32767,"%5d");on_exit(test_int); - property(c,NULL,NULL,WINCOLOR);set_default(strs(it->polohy[1][0]));on_event(adjust_enter); - define(170,5,140,45,12,1,input_line,7,-32767,32767,"%5d");on_exit(test_int); - property(c,NULL,NULL,WINCOLOR);set_default(strs(it->polohy[1][1]));on_event(adjust_enter); - define(175,5,155,60,20,1,button,"Zobraz");on_control_change(items_adjusting); - define(180,80,175,220,12,0,str_line,umisteni_veci);property(c,NULL,NULL,WINCOLOR); - on_enter(string_list_sup);c_default(it->umisteni); - define(200,80,190,220,12,0,str_line,typy_zbrani);property(c,NULL,NULL,WINCOLOR); - on_enter(string_list_sup);c_default(it->typ_zbrane); - define(210,80,205,220,10,0,check_box,"Pďż˝i dopadu se zni��"); - define(220,80,217,220,10,0,check_box,"Existuje dokud je pou��vďż˝n"); - define(130,10,180,45,55,0,ikona);c_default(it->ikona); - property(c,NULL,NULL,0);on_control_change(change_item_ikone); - define(-1,150,25,120,12,2,label,"Obrďż˝zkovďż˝ script"); - define(190,150,10,120,12,2,str_line,vzhled_veci);property(c,NULL,NULL,WINCOLOR); - c_default(it->vzhled); on_enter(string_list_sup); - define(-1,150,60,120,12,2,label,"Animace zbranďż˝"); - define(400,150,45,120,12,2,str_line,weapons);property(c,NULL,NULL,WINCOLOR); - c_default(anm); on_enter(string_list_sup);on_control_change(update_hitpos); - define(-1,10,45,1,12,3,label,"Hit Pos:"); - define(410,90,45,40,12,3,input_line,7,0,255,"%4d");on_exit(test_int); - property(c,NULL,NULL,WINCOLOR);set_default(strs(it->hitpos)); - define(300,10,35,80,20,2,button,"Uloďż˝");property(def_border(1,0),NULL,NULL,RGB555(0,20,0));on_control_change(save_edited_item); - define(320,10,70,80,20,2,button,"Zvuk");property(def_border(1,0),NULL,NULL,WINCOLOR);on_control_change(item_sound); - define(330,10,10,80,20,2,button,"Zruďż˝it");property(def_border(1,0),NULL,flat_color(RGB555(31,31,31)),RGB555(20,0,0));on_control_change(terminate_gui); - define(310,10,10,80,20,3,button,"Special");property(def_border(1,0),NULL,NULL,WINCOLOR);on_control_change(otevri_special); - define(340,10,95,80,20,2,button,"Aff");property(def_border(1,0),NULL,NULL,WINCOLOR);on_control_change(spell_affections); - define(700,0,0,0,0,0,value_store,4);c_default(it->zmeny[VLS_KOUZLA]); - redraw_window(); - fill_bit_fields(0,210,it->flags,2); - escape(); - w=find_window(preview_win); - if (w!=NULL) close_window(w); - close_current(); - } - -void clear_it_buffer() - { - memset(item_buffer,0,sizeof(item_buffer)); - } - -void create_ibuffer_list() - { - int i; - if (ls_buffer!=NULL) release_list(ls_buffer); - ls_buffer=create_list(32); - for (i=0;item_buffer[i];i++) - { - char c[80];TITEM *q; - int p; - p=abs(item_buffer[i])-1; - q=&item_list[p]; - if (item_buffer[i]<0) sprintf(c,"%3d ... %s",i,q->jmeno); - else sprintf(c,"%3d %s",i,q->jmeno); - if (str_replace(&ls_buffer,i,c)==NULL) return; - } - if (i==0) str_replace(&ls_buffer,0," -1 <ďż˝adnďż˝ pďż˝edmďż˝ty>"); - str_delfreelines(&ls_buffer); - } - -void create_isort_list(TSTR_LIST *ls_sorts,int filter) - { - int i; - char cc=0; - if (*ls_sorts!=NULL) release_list(*ls_sorts); - *ls_sorts=create_list(32); - for (i=0;ijmeno[0]!='?' && (filter==-1 || q->druh==filter)) - { - sprintf(c,"%4d %s",i,q->jmeno); - if (str_replace(ls_sorts,i,c)==NULL) return; - cc=1; - } - } - if (!cc) str_replace(ls_sorts,0," -1 <ďż˝adnďż˝ vzory>"); - str_delfreelines(ls_sorts); - } - -void save_items() - { - FILE *f;int i; - TSTR_LIST names=NULL; - char passw[50]; - - for(i=0;i"); - } - else if (sect==SV_PASSW) - { - encrypt(p); - set_data_password(p); - } - else if (sect==SV_SNDLIST) - { - int i; - char *c,*s; - - c=s=p;i=1; - while(c-s=max_items) - memset(&item_list[j],0,sizeof(TITEM)); - else - memcpy(&item_list[j],&item_list[i],sizeof(TITEM)); - item_edit(&item_list[j]); - create_isort_list(&ls_sorts,grep_num); - send_message(E_GUI,9,E_CONTROL,1,ls_sorts); - } - -void edit_selected_item() - { - int i; - - if (check_data_password()==0) return; - i=f_get_value(0,9); - sscanf(ls_sorts[i],"%d",&i); - if (i<0 || i>=max_items) clone_item(); - else - item_edit(&item_list[i]); - create_isort_list(&ls_sorts,grep_num); - send_message(E_GUI,9,E_CONTROL,1,ls_sorts); - } - -void delete_item_sort() - { - int i; - - if (check_data_password()==0) return; - i=f_get_value(0,9); - sscanf(ls_sorts[i],"%d",&i); - if (i<0 || i>=max_items) return; - if (msg_box("Dotaz?",'\x02',"Opravdu m�� v ďż˝myslu vymazat tento vzor? Je moďż˝nďż˝," - " ďż˝e na tento vzor se odvolďż˝vďż˝jďż˝ pďż˝edmďż˝ty v jinďż˝ mapďż˝. MAPEDIT je " - "nem��e vymazat, a mohou se dal�� prďż˝cďż˝ zmďż˝nit v pďż˝edmďż˝t jinďż˝!", - "Pďż˝esto vymazat","Zruďż˝it",NULL)==2) return; - strcpy(item_list[i].jmeno,"??? Vymazďż˝n"); - while (max_items && item_list[max_items-1].jmeno[0]=='?') max_items--; - create_isort_list(&ls_sorts,grep_num); - send_message(E_GUI,9,E_CONTROL,1,ls_sorts); - } - -void refresh_itm() - { - create_ibuffer_list(); - send_message(E_GUI,9,E_CONTROL,1,ls_buffer); - } - -void it_kos() - { - int i; - - i=f_get_value(0,9); - sscanf(ls_buffer[i],"%d",&i); - if (i<0 || i>=ITEM_BUFFER) return; - if (i==ITEM_BUFFER-1) - { - item_buffer[i]=-1; - return; - } - memcpy(&item_buffer[i],&item_buffer[i+1],(ITEM_BUFFER-i-1)*2); - create_ibuffer_list(); - send_message(E_GUI,9,E_CONTROL,1,ls_buffer); - } - -void open_item_win() - { - create_ibuffer_list(); - if (find_window(item_win)==NULL) - { - CTL3D b1,b2; - FC_TABLE f_sel; - - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D)); - default_font=vga_font; - memcpy(f_default,flat_color(0x0000),sizeof(charcolors)); - memcpy(&f_sel,flat_color(RGB555(0,0,24)),sizeof(charcolors)); - item_win=def_window(200,300,"Pďż˝edmďż˝ty"); - waktual->y=2;waktual->x=SCR_WIDTH_X-20-160-3; - waktual->minsizx=120; - waktual->minsizy=100; - on_control_change(close_current); - define(9,5,20,170,240,0,listbox,ls_buffer,RGB555(31,31,0),0);c_default(0); - property(&b2,NULL,&f_sel,WINCOLOR); - o_end->autoresizex=1; - o_end->autoresizey=1; - define(10,3,41,19,198,1,scroll_bar_v,0,10,1,SCROLLBARCOL); - property(&b2,NULL,NULL,WINCOLOR);on_control_change(scroll_support); - o_end->autoresizey=1; - define(11,3,20,19,19,1,scroll_button,-1,0,"\x1e"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(12,3,40,19,19,2,scroll_button,1,10,"\x1f"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(20,3,1,10,10,2,resizer); - define(30,5,10,50,20,3,button,"Pďż˝ekr."); - property(&b1,NULL,NULL,WINCOLOR);on_control_change(refresh_itm); - define(30,60,10,50,20,3,button,"Vymaďż˝"); - property(&b1,NULL,NULL,WINCOLOR);on_control_change(it_kos); - movesize_win(waktual,waktual->x,waktual->y,waktual->xs,150); - redraw_window(); - - } - else - select_window(item_win); - } - -void umisti_item() - { - int i,j; - - if (selected_place==-1) - { - msg_box("Nic nenďż˝ vybrďż˝no",'\x01',"Nejd��ve klikni my�� na mapďż˝, na mďż˝sto kam chceďż˝ pďż˝edmďż˝t umďż˝stit","Ok",NULL); - return; - } - i=f_get_value(0,9); - sscanf(ls_sorts[i],"%d",&i); - for(j=0;jins;item_buffer[i]=item_buffer[i-1],i--); - item_buffer[ins+1]=-wht-1; - open_item_win(); - send_message(E_GUI,9,E_CONTROL,1,ls_buffer); - } - -void inv_testmap() - { - if (selected_place<0) - msg_box("Nic nenďż˝ vybrďż˝no",'\x01',"Nejd��ve klikni my�� na mapďż˝, na mďż˝sto kde chceďż˝ za��t","Ok",NULL); - else - call_testmap(selected_place/4); - } - -static void change_grep() - { - char grep_en; - int grep_type; - - grep_en=f_get_value(0,100); - grep_type=f_get_value(0,90); - if (grep_en) grep_num=grep_type;else grep_num=-1; - send_message(E_GUI,9,E_CONTROL,0,&ls_sorts); - create_isort_list(&ls_sorts,grep_num); - send_message(E_GUI,9,E_CONTROL,1,ls_sorts); - c_set_value(0,9,0); - send_message(E_GUI,9,E_CONTROL,2); - - } - -void editor_vzoru() - { - if (find_window(vzor_win)==NULL) - { - CTL3D b1,b2; - FC_TABLE f_sel; - - create_isort_list(&ls_sorts,grep_num); - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D)); - default_font=vga_font; - memcpy(f_default,flat_color(0x0000),sizeof(charcolors)); - memcpy(&f_sel,flat_color(RGB555(0,0,20)),sizeof(charcolors)); - vzor_win=def_window(200,370,"Vzory"); - waktual->minsizx=130; - waktual->minsizy=170; - on_control_change(close_current); - define(9,5,20,170,240,0,listbox,ls_sorts,RGB555(31,31,0),0);c_default(0); - property(&b2,NULL,&f_sel,WINCOLOR); - o_end->autoresizex=1; - o_end->autoresizey=1; - define(10,3,41,19,198,1,scroll_bar_v,0,10,1,SCROLLBARCOL); - property(&b2,NULL,NULL,WINCOLOR);on_control_change(scroll_support); - o_end->autoresizey=1; - define(11,3,20,19,19,1,scroll_button,-1,0,"\x1e"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(12,3,110,19,19,2,scroll_button,1,10,"\x1f"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(20,3,1,10,10,2,resizer); - define(30,5,35,50,20,3,button,"Vymaďż˝");on_control_change(delete_item_sort); - property(&b1,NULL,NULL,WINCOLOR); - define(40,5,60,50,20,3,button,"Klonuj");on_control_change(clone_item); - property(&b1,NULL,NULL,WINCOLOR); - define(50,5,85,50,20,3,button,"Oprav");on_control_change(edit_selected_item); - property(&b1,NULL,NULL,WINCOLOR); - define(60,10,35,60,20,2,button,"Umďż˝stit");on_control_change(umisti_item); - property(&b1,NULL,NULL,WINCOLOR); - define(70,10,60,60,20,2,button,"Vloďż˝ do");on_control_change(vloz_do_item); - property(&b1,NULL,NULL,WINCOLOR); - define(80,10,85,60,20,2,button,"Test");on_control_change(inv_testmap); - property(&b1,NULL,NULL,WINCOLOR); - define(90,5,10,170,12,3,str_line,typy_veci);c_default(grep_num>-1?grep_num:0); - property(&b2,NULL,&f_sel,WINCOLOR);on_enter(string_list_sup);on_control_change(change_grep); - o_end->autoresizex=1; - define(100,10,10,10,10,2,check_box,"");c_default(grep_num>-1);on_control_change(change_grep); - movesize_win(waktual,waktual->x,160,waktual->xs,SCR_WIDTH_Y-20-160); - redraw_window(); - } - else - select_window(vzor_win); - } - -void select_item(int itpos) - { - if (selected_place!=-1) - { - int ps; - for(ps=0;item_buffer[ps];ps++); - if (item_place[selected_place]!=NULL) free(item_place[selected_place]); - if (ps) - { - item_place[selected_place]=getmem((ps+1)*sizeof(**item_place)); - memcpy(item_place[selected_place],item_buffer,_msize(item_place[selected_place])); - item_place[selected_place][ps]=0; - } - else item_place[selected_place]=NULL; - } - clear_it_buffer(); - if (itpos!=-1 && item_place[itpos]!=NULL) - memcpy(item_buffer,item_place[itpos],_msize(item_place[itpos])); - selected_place=itpos; - if (itpos!=-1) - { - open_item_win(); - send_message(E_GUI,9,E_CONTROL,1,ls_buffer); - } - } - -char save_item_map(FILE *f,int id) - { - int totalmem=0,i,j; - short *c,*d; - long r; - - select_item(-1); - for(i=0;i> 16; - for(j=0;j=count[0]) return; - c3=c1=*ptr; - c1+=record*sizef; - c2=c1+sizef; - siz=*count*sizef; - c3+=siz; - if (c3!=c2)memmove(c1,c2,(c3-c2)); - p=realloc(*ptr,siz-sizef); - if (siz-sizef<=0) {*ptr=NULL;p=NULL;} - if (p!=NULL) *ptr=p; - count[0]--; - } - - -void re_build_shop_list(TSTR_LIST *ls,TSHOP *p, int count) - { - if (*ls!=NULL) release_list(*ls); - *ls=create_list(count+1); - while(count--) - { - char s[100]; - - sprintf(s,"%s (%d)",p->keeper,p->products); - str_add(ls,s); - p++; - } - str_add(ls,""); - } - - -static void refresh_shop_list() - { - TSTR_LIST ls; - - send_message(E_GUI,9,E_CONTROL,0,&ls); - re_build_shop_list(&ls,shop_list,max_shops); - send_message(E_GUI,9,E_CONTROL,1,ls); - } - -void re_build_item_list(TSTR_LIST *ls,TPRODUCT *p,int count) - { - - if (*ls!=NULL) release_list(*ls); - *ls=create_list(16); - if (!count || p==NULL) - { - str_add(ls,"<��dnďż˝ pďż˝edmďż˝t>"); - return; - } - while (count--) - { - char s[200]; - short d; - - d=p->item; - if (p->trade_flags & SHP_TYPE) - sprintf(s,"typ: <%s>",typy_veci[d]); - else if (d>=max_items) strcpy(s,""); - else - sprintf(s,"%c%c%c%c %s (%d)",(p->trade_flags & SHP_SELL?'P':219), - (p->trade_flags & SHP_BUY?'N':219), - (p->trade_flags & SHP_AUTOADD?'Z':219), - (p->trade_flags & SHP_SPECIAL?'S':219), - item_list[d].jmeno,p->pocet - ); - p++; - str_add(ls,s); - } - } - -TSHOP *create_shop() - { - TSHOP *p; - add_record(&shop_list,&max_shops,sizeof(TSHOP)); - p=shop_list+max_shops-1; - memset(p,0,sizeof(*p)); - p->koef=10; - p->shop_id=shop_max_id++; - return p; - } - -static char *shopstate=NULL; - -static void close_edit_shop() - { - TSHOP *p; - TSTR_LIST ls; - char s[20]; - int i; - - p=shop_list+f_get_value(0,500); - get_value(0,200,s); - get_value(0,210,p->picture); - i=f_get_value(0,500); - p->koef=vals(220); - p->spec_max=vals(230); - if (s[0]==0) - { - msg_box("Editor obchodďż˝",'\x1',"Obchod musďż˝ mďż˝t svďż˝ho prodavaďż˝e (shopkeeppera). Obchod bude oznaďż˝en jako smazanďż˝.","Ok",NULL); - strcpy(s,"*vymazďż˝n*"); - } - if (s[0]=='<') - { - msg_box("Editor obchodďż˝",'\x1',"Obchodnďż˝k mďż˝ neplatnďż˝ jmďż˝no","Ok",NULL); - return; - } - strcpy(p->keeper,s); - if (!p->products && s[0]!='*') - msg_box("Editor obchodďż˝",'\x1',"S ni��m se neobchoduje. Nejsou definovďż˝ny ��dnďż˝ produkty. Tato situace m��e vďż˝st ke krachu hry!","Beru na vďż˝domďż˝",NULL); - send_message(E_GUI,9,E_CONTROL,0,&ls); - release_list(ls); - close_current(); - select_window(shop_window); - refresh_shop_list(); - shopstate[i]=0; - } - -static void add_item() - { - TSHOP *p; - TSTR_LIST ls; - TPRODUCT *pr; - int i; - - p=shop_list+f_get_value(0,500); - i=f_get_value(0,9); - send_message(E_GUI,9,E_CONTROL,0,&ls); - insert_record(&p->list,&p->products,sizeof(*pr),i); - pr=p->list+i; - pr->trade_flags=get_bit_fields(0,130,4); - pr->cena=vals(110); - pr->max_pocet=pr->pocet=vals(120); - pr->item=f_get_value(0,100); - sscanf(shop_items[pr->item],"%hd",&pr->item); - re_build_item_list(&ls,p->list,p->products); - send_message(E_GUI,9,E_CONTROL,1,ls); - redraw_window(); - } - -static void rewrite_item() - { - TSHOP *p; - TSTR_LIST ls; - TPRODUCT *pr; - int i; - - p=shop_list+f_get_value(0,500); - i=f_get_value(0,9); - send_message(E_GUI,9,E_CONTROL,0,&ls); - if (i>=p->products) return; - pr=p->list+i; - if (i>=pr->max_pocet) return; - pr->trade_flags=get_bit_fields(0,130,4); - pr->cena=vals(110); - pr->max_pocet=pr->pocet=vals(120); - pr->item=f_get_value(0,100); - sscanf(shop_items[pr->item],"%hd",&pr->item); - re_build_item_list(&ls,p->list,p->products); - send_message(E_GUI,9,E_CONTROL,1,ls); - redraw_window(); - } - -static void show_selected() - { - TSHOP *p; - TPRODUCT *pr; - int i; - char c[30]; - - p=shop_list+f_get_value(0,500); - i=f_get_value(0,9); - if (i>=p->products) return; - pr=p->list+i; - if (pr->trade_flags & SHP_TYPE) return; - sprintf(c,"%7d",pr->cena); - set_value(0,110,c); - sprintf(c,"%7d",pr->max_pocet); - set_value(0,120,c); - c_set_value(0,100,pr->item); - fill_bit_fields(0,130,pr->trade_flags,4); - } - -static void add_type() - { - TSHOP *p; - TSTR_LIST ls; - TPRODUCT *pr; - - p=shop_list+f_get_value(0,500); - send_message(E_GUI,9,E_CONTROL,0,&ls); - add_record(&p->list,&p->products,sizeof(*pr)); - pr=p->list+p->products-1; - pr->trade_flags=SHP_BUY|SHP_TYPE; - pr->cena=-1; - pr->max_pocet=pr->pocet=-1; - pr->item=item_list[f_get_value(0,100)].druh; - re_build_item_list(&ls,p->list,p->products); - send_message(E_GUI,9,E_CONTROL,1,ls); - redraw_window(); - } - -static void remove_item() - { - TSTR_LIST ls; - int i; - - TSHOP *p; - p=shop_list+f_get_value(0,500); - i=f_get_value(0,9); - send_message(E_GUI,9,E_CONTROL,0,&ls); - delete_record(&p->list,&p->products,sizeof(TPRODUCT),i); - re_build_item_list(&ls,p->list,p->products); - send_message(E_GUI,9,E_CONTROL,1,ls); - redraw_window(); - } - -static void zjisti_cenu() - { - int i=f_get_value(0,100); - int j=9999999; - - sscanf(shop_items[i],"%d",&j); - if (jlist,shp->products); - memcpy(&ctl1,def_border(1,0),sizeof(ctl1)); - memcpy(&ctl2,def_border(2,WINCOLOR),sizeof(ctl2)); - def_window(400,300,"Editor obchodďż˝"); - on_control_change(close_edit_shop); - define(500,0,0,0,0,0,value_store,4);c_default(i); - define(9,10,20,200,166,0,listbox,ls,RGB555(31,31,31),0); - property(&ctl1,NULL,NULL,WINCOLOR);c_default(0);on_control_change(show_selected); - define(10,217,40,19,127,0,scroll_bar_v,0,10,1,SCROLLBARCOL); - property(&ctl1,NULL,NULL,WINCOLOR); - define(11,216,20,21,17,0,scroll_button,-1,0,"\x1e"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(12,216,170,21,17,0,scroll_button,1,10,"\x1f"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(20,75,30,60,20,1,button,"Voďż˝it");property(&ctl1,NULL,NULL,WINCOLOR);on_control_change(add_item); - define(60,75,55,60,20,1,button,"Pďż˝epsat");property(&ctl1,NULL,NULL,WINCOLOR);on_control_change(rewrite_item); - define(30,10,30,60,20,1,button,"Typ");property(&ctl1,NULL,NULL,WINCOLOR);on_control_change(add_type); - define(40,10,55,60,20,1,button,"Odebrat");property(&ctl1,NULL,NULL,WINCOLOR);on_control_change(remove_item); - define(50,10,10,80,20,2,button,"Zav��t");property(&ctl1,NULL,NULL,WINCOLOR);on_control_change(close_edit_shop); - define(100,10,80,150,12,1,str_line,shop_items);property(&ctl2,NULL,NULL,WINCOLOR); - c_default(0); on_enter(string_list_sup);on_control_change(zjisti_cenu); - define(-1,155,100,1,1,1,label,"Cena:"); - define(110,10,100,90,12,1,input_line,10,0,9999999,"%7d");property(&ctl2,NULL,NULL,WINCOLOR); - set_default(strs(item_list[0].cena));on_exit(test_int); - define(-1,155,120,1,1,1,label,"Poďż˝et:"); - define(120,10,120,90,12,1,input_line,10,-1,9999999,"%7d");property(&ctl2,NULL,NULL,WINCOLOR); - set_default(strs(1));on_exit(test_int); - define(130,10,135,150,10,1,check_box,"Prodďż˝vat");c_default(1); - define(140,10,147,150,10,1,check_box,"Nakupovat");c_default(0); - define(150,10,159,150,10,1,check_box,"Zbo�� pďż˝ibďż˝vďż˝");c_default(0); - define(160,10,171,150,10,1,check_box,"Nenďż˝ vďż˝dy na skladďż˝");c_default(0); - define(-1,10,200,1,1,0,label,"Shopkeeper:"); - define(200,100,200,200,12,0,input_line,15);set_default(shp->keeper);property(&ctl2,NULL,NULL,WINCOLOR); - define(-1,10,220,1,1,0,label,"Obrďż˝zek:"); - define(210,100,220,100,12,0,input_line,12);set_default(shp->picture);property(&ctl2,NULL,NULL,WINCOLOR); - define(215,220,218,80,14,0,button,"Nalistuj");property(&ctl1,NULL,NULL,WINCOLOR);on_control_change(browse_dialogs); - define(-1,10,240,1,1,0,label,"Rozptyl cen +/- [%]"); - define(220,150,240,60,12,0,input_line,6,0,100,"%5d");set_default(strs(shp->koef));on_exit(test_int);property(&ctl2,NULL,NULL,WINCOLOR); - define(-1,220,240,1,1,0,label,"Poďż˝et spec:"); - define(230,320,240,60,12,0,input_line,6,0,100,"%5d");set_default(strs(shp->spec_max));on_exit(test_int);property(&ctl2,NULL,NULL,WINCOLOR); - { - char s[50]; - sprintf(s,"Shop ID: %d",shp->shop_id); - define(-1,10,260,1,1,0,label,s); - } - - redraw_window(); - } - -static void close_shop_list() - { - TSTR_LIST ls; - int i; - - send_message(E_GUI,9,E_CONTROL,0,&ls); - for(i=0;i=max_shops) return; - if (ls[i]==NULL) return; - if (shopstate[i]==1) - { - msg_box("Seznam obchodďż˝",'\x1',"Tento obchod je jiďż˝ opravovďż˝n v jinďż˝m oknďż˝. Nelze jej znovu otev��t","Ok",NULL); - return; - } - shopstate[i]=1; - send_message(E_GUI,9,E_CONTROL,1,ls); - edit_shop(i); - } - } - -static void erase_shop() - { - int i; - TSTR_LIST ls; - TSHOP *p; - - if (check_data_password()==0) return; - i=f_get_value(0,9); - send_message(E_GUI,9,E_CONTROL,0,&ls); - if (i>=max_shops) return; - if (ls[i]==NULL) return; - if (ls[i][0]=='<') - { - msg_box("Seznam obchodďż˝",'\x1',"Tento obchod je opravovďż˝n v jinďż˝m oknďż˝. Nelze jej vymazat","Ok",NULL); - return; - } - if (msg_box("Vymazat obchod?",'\x2',"Opravdu chceďż˝ vymazat obchod?","Ano","Ne",NULL)==2) return; - p=shop_list+i; - strcpy(p->keeper,"*vymazďż˝n*"); - re_build_shop_list(&ls,shop_list,max_shops); - send_message(E_GUI,9,E_CONTROL,1,ls); - } - - -void open_shop_list() - { - TSTR_LIST ls=NULL; - CTL3D ctl1; - - - if (find_window(shop_window)==NULL) - { - create_isort_list(&ls_sorts,grep_num); - shopstate=NewArr(char,max_shops);memset(shopstate,0,max_shops); - shop_items=ls_sorts; - ls_sorts=NULL; - re_build_shop_list(&ls,shop_list,max_shops); - memcpy(&ctl1,def_border(1,0),sizeof(ctl1)); - shop_window=def_window(250,220,"Seznam obchodďż˝"); - on_control_change(close_shop_list); - define(9,10,20,200,166,0,listbox,ls,RGB555(31,31,31),0); - property(&ctl1,NULL,NULL,WINCOLOR);c_default(0);//on_change(edit_shop_item); - define(10,217,40,19,127,0,scroll_bar_v,0,10,1,SCROLLBARCOL); - property(&ctl1,NULL,NULL,WINCOLOR); - define(11,216,20,21,17,0,scroll_button,-1,0,"\x1e"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(12,216,170,21,17,0,scroll_button,1,10,"\x1f"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(200,5,5,70,20,3,button,"Oprava");on_control_change(open_shop_editor);property(&ctl1,NULL,NULL,WINCOLOR); - define(210,80,5,70,20,3,button,"Vymazat");on_control_change(erase_shop);property(&ctl1,NULL,NULL,WINCOLOR); - movesize_win(waktual,10,10,250,220); - } - else select_window(shop_window); - redraw_window(); - } - -void shop_train_edit() - { - open_shop_list(); - } - - -void save_shop(TSHOP *p,FILE *f) - { - char *itm; - int i,j,typs=0,lss; - TPRODUCT *pstr,*pr,*nls,*npr; - TSHOP *shp; - - shp=p;p=New(TSHOP); - memcpy(p,shp,sizeof(*p)); - itm=getmem(max_items); - memset(itm,0,max_items); - pstr=p->list;pr=pstr; - for(i=0;iproducts;i++,pr++) - { - if (pr->trade_flags & SHP_TYPE) - { - typs++; - for(j=0;jitem) itm[j]|=1; - } - else - if (itm[pr->item]) - { - char s[300]; - - sprintf(s,"Duplicitnďż˝ pďż˝edmďż˝t v definici v obchodu '%s'. Soubor obchodu bude uloďż˝en, ale vlastnďż˝ hra m��e na tomto pďż˝edmďż˝tu zkrachovat!",p->keeper); - msg_box("Shop edit",'\x1',s,"Ok",NULL); - typs++; - } - else - itm[pr->item]|=2; - } - lss=0; - for(i=0;iproducts;i++,pr++) - if (!(pr->trade_flags & SHP_TYPE)) memcpy(npr++,pr,sizeof(TPRODUCT)); - for(i=0;iitem=i; - npr->cena=item_list[i].cena; - npr->trade_flags=SHP_BUY | SHP_NOEDIT | SHP_SELL; - npr->pocet=npr->max_pocet=0; - npr++; - } - pr=pstr; - for(i=0;iproducts;i++,pr++) - if (pr->trade_flags & SHP_TYPE) memcpy(npr++,pr,sizeof(TPRODUCT)); - p->products=typs+lss; - p->list_size=lss; - fwrite(p,1,sizeof(TSHOP),f); - fwrite(nls,p->products,sizeof(TPRODUCT),f); - free(nls); - free(itm); - free(p); - } - -void save_all_shops() - { - FILE *f; - int i; - int pocet=max_shops; - - f=fopen(SHOP_NAME,"wb"); - fwrite(&pocet,1,4,f); - for(i=0;ishop_id>=shop_max_id) shop_max_id=p->shop_id+1; - lss=p->products; - ols=NewArr(TPRODUCT,lss); - fread(ols,lss,sizeof(TPRODUCT),f); - el=0; - for(i=0;itrade_flags & SHP_NOEDIT)) memcpy(pr++,tr,sizeof(TPRODUCT)); - free(ols); - p->list=nls; - p->products=el; - } - - -void load_all_shops() - { - FILE *f; - int i; - int pocet=0; - - f=fopen(SHOP_NAME,"rb"); - if (f==NULL) return; - fread(&pocet,1,4,f); - if (!pocet) - { - fclose(f); - return; - } - shop_list=NewArr(TSHOP,pocet); - for(i=0;i -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "dump.h" -#include "mapy.h" -#include "edit_map.h" -#include "globals.h" -#include "steny.h" -#include "save_map.h" -#include "wiz_tool.h" -#include "mob_edit.h" -#include "../crashdump.h" -#include "../mapedit/version.h" -#include "../mapedit/editor.h" - -//#define FONTPATH "d:\\tp\\vga\\" -#define FONTPATH "..\\font\\" -extern T_EVENT_ROOT *ev_tree; - -static char newmap=0; -static char nosound=0; -TSTR_LIST config_file; - -word *icones,*vga_font; -char *sample_path; -char *script_name; -extern word ikones; -extern word boldcz; -extern word font8x5; -word icone_color[7]={RGB555(8,8,8),RGB555(31,31,31),RGB555(0,0,15),RGB555(16,16,16),RGB555(0x1b,0x1b,0x1b)}; -extern word sipka; -static char *error_texts[]= - { - "Progamovďż˝ chyba", - "Prďż˝vďż˝ b���cďż˝ udďż˝lost zpďż˝sobila neplatnou referenci pam��i!", - "Prďż˝vďż˝ b���cďż˝ udďż˝lost zpďż˝sobila zpracovďż˝nďż˝ neplatnďż˝ instrukce!", - "Systďż˝m zachytil neoďż˝ekďż˝vanou chybu programu!" - }; - -static char ask_exit_status; - -word menu_win=-1; -char hicolor=1; -char sekceid[8]=""; -long pc_counter=0; -long pc_max=1; -long pc_result=0; -long pc_tick=0; -int test_mode=4; -char *background_file=NULL; -int editor_win=-1; -char color16=0; - -void close_test() - { - close_window(waktual); - } - -void logo(void) - { - CTL3D ctl; - word *p; - - ctl.light=RGB555(31,31,31); - ctl.shadow=RGB555(16,16,16); - ctl.bsize=2; - ctl.ctldef=0; - draw_border(120,120,0x18f,0x6a,&ctl); - p=(word *)LoadResourceFont("MAPEDIT.HI"); - put_picture(120,120,p); -// free(p); - showview(0,0,0,0); - } - -void about(); - -void movesize_test() - { - WINDOW *w; - - w=find_window(map_win); - if (w==NULL) return; - movesize_win(w,0,0,100,100); - redraw_desktop(); - } - -void forced_map_test() - { - int i; - - for(i=0;i>8)=='D') terminate_gui(); - if ((c & 0xff)==0 && (c>>8)==';') about(); - if ((c & 0xff)==0 && (c>>8)=='?') save_dump(); - if ((c & 0xff)==0 && (c>>8)=='<') movesize_test(); - if ((c & 0xff)=='t' || (c & 0xff)=='T' || (c & 0xff)==' ' ) forced_map_test(); - } - } - -EVENT_PROC(wait_ms_key) - { - MS_EVENT *ms; - - GET_USER_PTR(); - WHEN_MSG(E_INIT) - return; - WHEN_MSG(E_MOUSE) - { - ms=get_mouse(GET_MSG_VAR()); - if (ms->event_type & 4) terminate_gui(); - } - } - -EVENT_PROC(main_menu) - { - MS_EVENT *ms; - - GET_USER_PTR(); - WHEN_MSG(E_INIT) - return; - WHEN_MSG(E_MOUSE) - { - ms=get_mouse(GET_MSG_VAR()); - if (ms->event_type & 32) select_window(menu_win),redraw_window(); - } - } - - -void wait_mouse(void) - { - send_message(E_ADD,E_MOUSE,wait_ms_key); - escape(); - send_message(E_DONE,E_MOUSE,wait_ms_key); - } - -EVENT_PROC(all_status) - { - char *c; - char *fn; - char **p; - - GET_USER_PTR(); - WHEN_MSG(E_INIT) return; - WHEN_MSG(E_DONE) return; - c=GET_DATA_PTR(char); - c=(char *)msg->data; - fn=strrchr(filename,'\\'); - if (fn) fn++;else fn=filename; - sprintf(c,"CH:%d, N:%d, P:%d, file: %s ",maplen,0,max_items,fn); - c=strchr(c,'\0'); - if (pc_result<0) sprintf(c,"(wait)");else sprintf(c,"CPU %03d%%",pc_result); - c=strchr(c,'\0'); - p=&GET_DATA_PTR(char) - *p=c; - pc_counter++; - } - -void *pc_metter(EVENT_MSG *msg) - { - static int last1,last2; - if (msg->msg==E_INIT) return &pc_metter; - if (msg->msg==E_DONE) return NULL; - pc_tick++; - if (pc_tick>10) - { - if (pc_counter>pc_max) - if (last1>pc_max && last2>pc_max) pc_max=pc_counter; - else last2=last1;last1=pc_counter; - pc_result=100-pc_counter*100/pc_max; - pc_counter=0; - pc_tick=0; - } - return NULL; - } - -void graph_init(char windowed) -{ -/* -int c; -static word *p=NULL; - if (color16) - { - if (p==NULL)p=create_blw_palette16(); - initmode16(p); - } - else - { - if (hicolor) c=initmode32() ;else c=-1; - if (c) - { - - if (p==NULL)p=create_special_palette(); - if (initmode256(p)) - initmode_lo(p); - } - } - */ -// report_mode(1); - - const char *c=get_text_field(config_file,"MAPEDIT_WINDOW"); - int scale = 1; - if (c != 0) - { - int x,y; - if (sscanf(c,"%dx%d",&x,&y) == 2 && x>=640 && y>=480) - DxSetInitResolution(x,y); - } - ; - c=get_text_field(config_file,"MAPEDIT_SCALE"); - if (c != 0) - { - sscanf(c,"%d",&scale); - } -initmode_dx(windowed,scale,0,0); - -} - -void init_sound() - { - int a,b,c,d; - if (nosound) - { - a=DEV_NOSOUND; - } - else if (sound_detect(&a,&b,&c,&d)) - { - puts("No sound device found"); - a=DEV_NOSOUND; - } - set_mixing_device(a,22000,b,c,d); - } - -void prg_error(EVENT_MSG *msg,void **unused) - { - int *err; - char *c; - - unused; - if (msg->msg==E_PRGERROR) - { - err=(int *)(*(int **)msg->data); - switch (*err) - { - case ERR_MEMREF:c=error_texts[1];break; - case ERR_ILLEGI:c=error_texts[2];break; - default: c=error_texts[3];break; - } - zobraz_mysku(); - showview(0,0,0,0); - *err=2-msg_box(error_texts[0],' ',c,"Ignoruj","Konec","Uloďż˝ mapu",NULL); - if (*err==-1) save_all_map(); - } - } - -void raise_error_conv(int i) - { -/* if (i==SIGILL) raise_error(ERR_ILLEGI); - else - if (i==SIGSEGV) raise_error(ERR_MEMREF); - else - raise_error(ERR_MEMREF); -*/ - } - -static void key_test(va_list args) - { - word c; - do - { - EVENT_MSG *msg = task_wait_event(E_KEYBOARD); - c=va_arg(msg->data,unsigned int); - } - while ((c & 0xff)!='!'); - puts("\x7"); - } - -void ddl_init() - { - char *c; - char *path,*temp; - - c=get_text_field(config_file,"CESTA_DATA"); - concat(path,c,"SKELDAL.DDL"); - c=get_text_field(config_file,"CESTA_TEMP"); - if (c!=NULL)concat(temp,c,"~MAPEDIT.TMP");else temp=c; - printf("Hledam soubor %s\n",path); - init_manager(path,temp); - } - -void init(void) - { - mapy_init(); - ddl_init(); - vga_font=LoadResourceFont("BOLDCZ"); - default_font=vga_font; - icones=LoadResourceFont("IKONY"); - graph_init(1); - curcolor=RGB555(24,24,24);memcpy(charcolors,flat_color(0x0000),sizeof(charcolors)); - init_events(100); - curfont=default_font; - register_ms_cursor(LoadResourceFont("SIPKA.HI")); - init_mysky(); -// hranice_mysky(0,0,639,479); - add_task(1024,key_test); - send_message(E_ADD,E_STATUS_LINE,status_line); - send_message(E_STATUS_LINE,E_ADD,E_IDLE,all_status); - send_message(E_STATUS_LINE,E_ADD,E_IDLE,status_mem_info); - send_message(E_STATUS_LINE,E_ADD,E_IDLE,show_time); - send_message(E_ADD,E_TIMER,pc_metter); - send_message(E_ADD,E_KEYBOARD,exit_key); - send_message(E_ADD,E_PRGERROR,prg_error); - signal(SIGILL,raise_error_conv); - signal(SIGSEGV,raise_error_conv); - install_gui(); - redraw_desktop();do_events(); - send_message(E_ADD,E_MOUSE,main_menu); - msg_box_font=vga_font; - msg_icn_font=icones; - ukaz_mysku(); - update_mysky(); - } -/* - w=create_window(100,100,400,200,0x6318,&x); - id=desktop_add_window(w); - define(10,20,50,30,0,sample,"Test"); - property(&x,NULL,flat_color(0x7000),0xffff); - define(10,20,70,30,3,button,"Tlacitko"); - property(NULL,NULL,flat_color(0x000f),0x01c0);on_change(close_test); - w=create_window(5,5,200,200,0x6318,&x); - id=desktop_add_window(w); - define(50,50,70,30,3,button,"Tlacitko"); - property(NULL,NULL,flat_color(0x7fff),0x000f);on_change(close_test); - w=create_window(300,150,300,200,0x6318,&x); - id=desktop_add_window(w); - define(50,50,70,30,3,button,"Tlacitko"); - property(NULL,NULL,flat_color(0x7fff),0x000f);on_change(close_test); - */ - -long def_window(word xs,word ys,char *name) - { - word x=0,y=0; - WINDOW *p; - CTL3D ctl; - FC_TABLE fc; - long q; - - if (waktual!=NULL) - { - x=waktual->x; - y=waktual->y; - } - - highlight(&ctl,WINCOLOR); - ctl.bsize=2;ctl.ctldef=0; - x+=20;y+=20; - memcpy(fc,flat_color(RGB555(31,31,0)),sizeof(FC_TABLE)); - fc[0]=0x0000; - if (x+xs>SCR_WIDTH_X-2) x=SCR_WIDTH_X-2-xs; - if (y+ys>SCR_WIDTH_Y-2) y=SCR_WIDTH_Y-2-ys; - p=create_window(x,y,xs,ys,WINCOLOR,&ctl); - q=desktop_add_window(p); - define(0,2,2,xs-5-20*(xs>=70),14,0,win_label,name); - ctl.bsize=1;ctl.ctldef=1; - o_end->autoresizex=1; - property(&ctl,vga_font,&fc,LABELCOLOR); - if (xs>=70) - { - define(1,1,1,19,16,1,button,"\x0f"); - property(NULL,icones,&icone_color,WINCOLOR);on_control_change(close_test); - } - return q; - } - -void def_dialoge(word x,word y,word xs, word ys, char *name) - { - CTL3D ctl; - FC_TABLE fc; - WINDOW *p; - - - memcpy(fc,flat_color(RGB555(31,31,0)),sizeof(FC_TABLE)); - memcpy(&ctl,def_border(2,WINCOLOR),sizeof(CTL3D)); - p=create_window(x,y,xs,ys,WINCOLOR,&ctl); - desktop_add_window(p); - set_window_modal(); - ctl.bsize=1;ctl.ctldef=1; - define(0,1,1,xs-2,14,0,win_label,name); - o_end->autoresizex=1; - property(&ctl,vga_font,&fc,LABELCOLOR); - } - -void dtext_init(OBJREC *o,char *title) - { - title=get_title(title); - o->userptr=(void *)getmem(strlen(title)+1); - strcpy((char *)o->userptr,title); - } - - -void dtext_draw(int x1,int y1,int x2, int y2,OBJREC *o) - { - x2;y2; - fontdsize=1; - position(x1,y1); - outtext((char *)o->userptr); - fontdsize=0; - } - -void dtext(OBJREC *o) - { - o->call_init=dtext_init; - o->call_draw=dtext_draw; - //o->call_event=sample_event; - //o->call_done=sample_done; - } - -void about() - { - FC_TABLE c={0,RGB555(31,31,0),RGB555(28,28,28),RGB555(24,24,24),RGB555(20,20,20)}; - FC_TABLE c2={0,RGB555(31,16,0),RGB555(28,16,0),RGB555(24,16,0),RGB555(20,16,0)}; - FC_TABLE c3={0,RGB555(0,24,0),RGB555(0,20,0),RGB555(0,16,0),RGB555(0,10,0)}; - static about_win=-1; - - if (find_window(about_win)==NULL) - { - about_win=def_window(300,200,"About"); - waktual->x=320-150; - waktual->y=140; - memcpy(f_default,flat_color(0x0),sizeof(FC_TABLE)); - waktual->modal=1; - default_font=vga_font; - define(-1,5,25,29,29,0,dtext,"\x8");property(NULL,icones,&c,WINCOLOR); - define(-1,75,25,100,29,0,dtext,"MAPEDIT");property(NULL,NULL,&c2,WINCOLOR); - define(-1,200,35,60,29,0,label,"verze 2.0");property(NULL,NULL,&c3,WINCOLOR); - define(-1,20,80,200,10,0,label,"Napsďż˝no pro hru \"Brďż˝ny Skeldalu\""); - define(-1,20,92,200,10,0,label,"(C) 1997 Napoleon gameS "); - define(-1,20,104,200,10,0,label,"Naprogamoval: Ondďż˝ej Novďż˝k "); - define(-1,20,116,200,10,0,label,"Tento software smďż˝ bďż˝t pouďż˝it jen"); - define(-1,20,128,200,10,0,label,"ve spojenďż˝ s vďż˝vojem hry \"Brďż˝ny"); - define(-1,20,140,200,10,0,label,"Skeldalu\" (a p��padnďż˝ dal�� verze)"); - define(-1,20,152,200,10,0,label,"a to pouze ďż˝leny vďż˝vojovďż˝ho tďż˝mu."); - define(10,110,170,80,20,0,button,"Ok");on_control_change(close_test); - } - else select_window(about_win); - redraw_window(); - } - -void fog_bar_draw(int x1,int y1,int x2,int y2,OBJREC *o) - { - disable_bar(x1,y1,x2-x1,y2-y1,o->color); - } - -void fog_bar(OBJREC *o) - { - o->call_draw=fog_bar_draw; - } - -void close_app(void) - { - WINDOW *w; - CTL3D x={0,0,0,0}; - - int mx = DxGetResX() - 1; - int my = DxGetResY() - 1; - - w=create_window(0,0,1,1,0,&x); - desktop_add_window(w); - define(-1,0,0,mx,my,0,fog_bar);property(NULL,NULL,NULL,RGB555(16,0,0)); - redraw_desktop(); - if ((ask_exit_status=msg_box("Dotaz?",'\x2',"Chceďż˝ program ukonďż˝it, nebo nahrďż˝t jinou mapu?","Jinou mapu","Ukonďż˝it","Ne",NULL))!=3) terminate_gui(); - close_window(w); - do_events(); - } - -void edit_basic_maze() - { - if (tool_sel>40) tool_sel=30; - create_map_win(-1); - if (newmap) - { - edit_side(0,0); - sector_details_call(0); - if (str_count(side_names)>2 || side_names[1]!=NULL) newmap=0; - } - } - -void spawn_editor(char *dosline) - { -// deinstall_mouse_handler(); - closemode(); - system(dosline); - graph_init(1); -// install_mouse_handler(); -// hranice_mysky(0,0,639,479); - redraw_desktop(); - } - -void edit_script_file() - { - char s[255]=""; - char *pr;WINDOW *w; - - - w=find_window(sektor_win); - if (w!=NULL) close_window(w); - switch (o_aktual->id) - { - case 10:strcat(s,pripona(filename,SCR));break; - case 20:strcat(s,pripona(filename,".TXT"));break; - case 30:strcat(s,ITEMS_SCRIPT);break; - case 40:strcat(s,ITEMS_PICS);break; - } - EditSkeldalFile(s); - pr=pripona(filename,SCR); - read_full_side_script(pr); - read_side_list(ITEMS_SCRIPT,&vzhled_veci,0,4); - read_side_list(ITEMS_PICS,&pohledy_veci,0,2); - read_side_list(WEAPONS_SCRIPT,&weapons,0,3); - read_side_list(WEAPONS_SCRIPT,&weapons_pos,2,3); - } - -void call_animator() - { - spawn_editor("ani"); - } - - -void open_editor_win() - { - if (find_window(editor_win)==NULL) - { - editor_win=def_window(100,150,"Editory"); - define(10,10,25,80,20,0,button,"map script");on_control_change(edit_script_file); - define(20,10,50,80,20,0,button,"map texty");on_control_change(edit_script_file); - define(30,10,75,80,20,0,button,"items.scr");on_control_change(edit_script_file); - define(40,10,100,80,20,0,button,"items.pic");on_control_change(edit_script_file); - define(50,10,125,80,20,0,button,"animator");on_control_change(call_animator); - redraw_window(); - } - else - { - select_window(editor_win); - redraw_window(); - } - } - -void create_menu(void) - { - FC_TABLE c={0,RGB555(31,31,31),RGB555(24,24,24),RGB555(16,16,16),RGB555(4,4,4)}; - menu_win=def_window(400,150,"Map Edit v2.0 for Windows - " MAPEDIT_VERSION ); - waktual->x=120; - waktual->y=250; - on_control_change(close_app); - curcolor=WINCOLOR; - default_font=icones; - define(10,5,25,29,29,0,button,"\x8");property(NULL,NULL,&c,WINCOLOR);on_control_change(edit_basic_maze); - define(20,5,55,29,29,0,button,"\x9");property(NULL,NULL,&c,WINCOLOR);on_control_change(editor_veci); - define(30,5,85,29,29,0,button,"\xA");property(NULL,NULL,&c,WINCOLOR);on_control_change(enemy_window); - c[1]=RGB555(20,0,0);c[2]=RGB555(0,0,16); - define(40,200,25,29,29,0,button,"e");property(NULL,NULL,&c,WINCOLOR);on_control_change(shop_train_edit); - c[1]=RGB555(31,31,31);c[2]=RGB555(24,24,24); - c[3]=RGB555(20,0,0);c[4]=RGB555(0,0,16); - define(50,200,55,29,29,0,button,"E");property(NULL,NULL,&c,WINCOLOR);on_control_change(open_editor_win); - define(60,200,85,29,29,0,button,"S");property(NULL,NULL,&c,WINCOLOR);on_control_change(save_all_map); - define(70,5,115,29,29,0,button,"P");property(NULL,NULL,&c,WINCOLOR);on_control_change(pcxviewer); - memcpy(c,flat_color(RGB555(0,0,15)),sizeof(FC_TABLE)); - define(-1,45,35,90,20,0,label,"Kreslenďż˝ mapy");property(NULL,vga_font,&c,WINCOLOR); - define(-1,45,65,90,20,0,label,"Poklďż˝dďż˝nďż˝ pďż˝edmďż˝tďż˝");property(NULL,vga_font,&c,WINCOLOR); - define(-1,45,95,90,20,0,label,"Umďż˝sďż˝ovďż˝nďż˝ nestvďż˝r");property(NULL,vga_font,&c,WINCOLOR); - define(-1,240,35,90,20,0,label,"Obchody");property(NULL,vga_font,&c,WINCOLOR); - define(-1,240,65,90,20,0,label,"Editor scriptďż˝");property(NULL,vga_font,&c,WINCOLOR); - define(-1,240,95,90,20,0,label,"Uloďż˝enďż˝ mapy");property(NULL,vga_font,&c,WINCOLOR); - define(-1,45,125,90,20,0,label,"Prohl��eďż˝ PCX");property(NULL,vga_font,&c,WINCOLOR); - default_font=vga_font; - memcpy(f_default,flat_color(0x0000),sizeof(charcolors)); - //set_enable(0,20,0); - //set_enable(0,30,0); - } - -void help(void) - { - printf("Parametry:\n\n"); - printf("mapedit filename [/4] [/2] [/c|t|v|m] [/?] \n" - "\n" - "/2 Prosadi 256 barev\n" - "/1 Prosadi 16 barev\n" - "/c Inicializace mysi se simulaci CGA karty (default)\n" - "/t Inicializace mysi se simulaci textoveho rezimu (standard)\n" - "/v Inicializace mysi se simulaci VGA\n" - "/m Inicializace mysi se simulaci MCGA\n" - "/? Tento help\n" - "/s Bez zvuku (dobre pro WIN95)\n" - ); - exit(0); - } - -void args_support(char count, char *sw[]) - { - int i; - char c; - - for(i=1;i<=count;i++) - if (sw[i][0]=='/') - { - c=sw[i][1]; - switch (c) - { - case '?': help();break; -/* case '4': line480=1;break; - case '2': hicolor=0;break; - case '1': color16=1;break; - case 'c': - case 'C': ms_fake_mode=0x6;break; - case 't': - case 'T': ms_fake_mode=0x3;break; - case 'v': - case 'V': ms_fake_mode=0x12;break; - case 'm': - case 'M': ms_fake_mode=0x13;break; - case 'r': - case 'R': test_mode=sw[i][2]-48;if (test_mode<0 || test_mode>4) test_mode=0;break;*/ - case 's': nosound=1;break; - } - } - else - strcpy(filename,sw[i]); - } - -char *pripona(char *fname,char *prip) - { - static char name[128],*s,*t; - - strncpy(name,fname,128); - name[127]='\0'; - t=strchr(name,'.'); - s=t; - while (s!=NULL) - { - t=s; - s=strchr(t+1,'.'); - } - if (t==NULL) - { - t=strchr(name,'\0'); - } - strcpy(t,prip); - return name; - } - - -void load_background() - { - FILE *f; - long siz; - - if (gui_background!=NULL) - { - free(gui_background); - gui_background=NULL; - } - f=fopen(background_file,"rb"); - if (f==NULL) return; - fseek(f,0,SEEK_END);siz=ftell(f); - fseek(f,0,SEEK_SET); - gui_background=getmem(siz); - fread(gui_background,1,siz,f); - redraw_desktop(); - fclose(f); - } - -static void shut_down() - { -// deinstall_mouse_handler(); - closemode(); - } - -void init_maps(void); - -static ask_password_event(EVENT_MSG *msg,OBJREC *obj) - { - obj; - WHEN_MSG(E_KEYBOARD) - { - char c=GET_DATA(char); - if (c==13) {goto_control(20);terminate_gui();} - if (c==27) {goto_control(30);terminate_gui();} - } - } - -char ask_password(char *pass,char text) - { - char *c; - - switch (text) - { - case 0:c="Prov��enďż˝";break; - case 1:c="Zmďż˝na hesla";break; - case 2:c="Kontrola";break; - } - def_dialoge(320-100,240-50,200,90,c); - define(-1,10,20,1,1,0,label,"Vloďż˝ heslo:"); - define(10,10,40,180,12,0,input_line,49); - property(def_border(3,WINCOLOR),NULL,flat_color(RGB555(31,31,31)),RGB555(8,8,8)); - if (text==1)set_default(pass);else set_default("");on_event(ask_password_event); - define(20,5,5,50,20,2,button,"OK"); - property(def_border(1,0),NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(30,5,5,50,20,3,button,"Zruďż˝it"); - property(def_border(1,0),NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - redraw_window(); - goto_control(10); - escape(); - if (o_aktual->id==30) text=0;else - { - text=1; - get_value(0,10,pass); - } - close_current(); - return text; - } - -static int data_edit_enabled=0; -static char data_password[50]=""; - -char check_data_password(void) - { - char text[50]; - - if (data_password[0]==0) data_edit_enabled=1; - if (data_edit_enabled) return 1; - if (ask_password(text,0)==0) return 0; - if (strcmp(data_password,text)) - { - msg_box("Chyba!",1,"Chybnďż˝ heslo! P��stup zamďż˝tnut!","OK",NULL); - return 0; - } - else - { - data_edit_enabled=1; - return 1; - } - } - -char *set_data_password(char *text) - { - if (text!=NULL) - { - strncpy(data_password,text,sizeof(data_password)); - data_password[sizeof(data_password)-1]=0; - } - return data_password; - } - -/*TSTR_LIST read_ddl_dir(char *filter) - { - TSTR_LIST ls; - int i=0; - char *s; - - ls=create_list(256); - s=read_next_entry(MMR_FIRST); - while (s!=NULL) - { - char *d; - char c[13]; - - strncpy(c,s,12); - c[12]=0; - if (filter!=NULL) - { - d=strrchr(c,'.'); - if (d!=NULL && !strncmp(d+1,filter,3)) str_replace(&ls,i++,c); - } - else - str_replace(&ls,i++,c); - s=read_next_entry(MMR_NEXT); - } - if (i==0) str_add(&ls,""); - ls=sort_list(ls,-1); - return ls; - } -*/ - -SMapFiles mapFiles; - -static char *strdup2(const char *a, const char *b) -{ - char *res=malloc(strlen(a)+strlen(b)+1); - strcpy(res,a); - strcat(res,b); - return res; -} - -static void InitMapFiles(const char *path) -{ - mapFiles.items_script=strdup2(path,XITEMS_SCRIPT); - mapFiles.items_pics=strdup2(path,XITEMS_PICS); - mapFiles.items_dat=strdup2(path,XITEM_FILE); - mapFiles.dialogy_scr=strdup2(path,XDLG_SCRIPT); - mapFiles.weapons_scr=strdup2(path,XWEAPONS_SCRIPT); - mapFiles.shops_dat=strdup2(path,XSHOP_NAME); - mapFiles.enemy=strdup2(path,XMOB_FILE); - mapFiles.enemy_sound=strdup2(path,XMOB_SOUND); -} -static void ClearMapFiles() -{ - free(mapFiles.items_script); - free(mapFiles.items_pics); - free(mapFiles.items_dat); - free(mapFiles.dialogy_scr); - free(mapFiles.weapons_scr); - free(mapFiles.shops_dat); - free(mapFiles.enemy); - free(mapFiles.enemy_sound); - -} - - -static BOOL WINAPI HandlerRoutine( - DWORD dwCtrlType // control signal type -) -{ - return TRUE; -} - -int main(int argc,char *argv[]) - { - char *s; - char *pr; - char test[50]; - char *mask; - InitCrashDump(); - SetConsoleCtrlHandler(HandlerRoutine,TRUE); - filename[0]='\0'; - // strcpy(filename,"TEST.MAP"); - args_support(argc-1,argv); - printf("Hledam konfiguracni soubor\n"); - config_file=read_config("WSKELDAL.INI"); - if (config_file==NULL) - { - puts("...nemohu najit WSKELDAL.INI\n"); - return 1; - } - if (strlen(filename)>3 && istrcmp(filename+strlen(filename)-3,"adv")==0) - { - TSTR_LIST adv_cfg=read_config(filename); - config_file=merge_configs(config_file,adv_cfg); - filename[0]=0; - } - sample_path=get_text_field(config_file,"CESTA_ZVUKY"); - if (sample_path==NULL) sample_path=""; - mob_dir=get_text_field(config_file,"CESTA_ENEMY"); - if (mob_dir==NULL) mob_dir=""; - init_sound(); - init(); - - concat(mask,get_text_field(config_file,"CESTA_MAPY"),"*.map"); - atexit(shut_down); -// signal(SIGABRT,shut_down); - init_mob_list(); - InitMapFiles(get_text_field(config_file,"CESTA_MAPY")); - do - { - ask_exit_status=2; - if (filename[0]=='\0') browser(mask,filename); - if (filename[0]!='\0') - { - char *mapy=get_text_field(config_file,"CESTA_MAPY"); - memmove(filename+strlen(mapy),filename,strlen(filename)+1); - memcpy(filename,mapy,strlen(mapy)); - s=pripona(filename,".HI"); - background_file=(char *)getmem(strlen(s)+1);strcpy(background_file,s); - load_background(); - } - do_events(); - logo(); - pr=pripona(filename,SCR); - script_name=NewArr(char,strlen(pr)+1); - strcpy(script_name,pr); - read_full_side_script(pr); - read_spec_procs(); - read_side_list(ITEMS_SCRIPT,&vzhled_veci,0,4); - read_side_list(ITEMS_PICS,&pohledy_veci,0,2); - read_dlg_list(DLG_SCRIPT,&dlg_names,&dlg_pgfs); - read_side_list(WEAPONS_SCRIPT,&weapons,0,3); - read_side_list(WEAPONS_SCRIPT,&weapons_pos,2,3); - set_defaults(); - init_multiactions(); - memset(vyklenky,0,sizeof(vyklenky)); - init_item_system(); - if (filename[0]!='\0' ) - { - int sel=1; - - init_maps(); - set_defaults(); - if (load_map(filename)) - msg_box(filename,'\01',"Tento soubor je buďż˝ neďż˝itelnďż˝, nebo poďż˝kozenďż˝","Pokraďż˝ovat",NULL); - if (check_password(NULL)==0) - if (ask_password(test,0)==0 || check_password(test)==0) - { - filename[0]=0; - ask_exit_status=1; - goto preskoc; - } - if (maplen<2) - { - sel=msg_box(filename,' ',"Soubor neexistuje, bude vytvoďż˝en novďż˝. Nynďż˝ je nutnďż˝ nastavit zďż˝kladnďż˝ stďż˝ny" - " a jinďż˝ dal�� parametry pro tuto mapu","Pokraďż˝ujem","Zavďż˝it",NULL); - if (sel==1) - { - newmap=1; - } - - } - if (sel==1) - { - create_menu(); - redraw_window(); - escape(); - filename[0]=0; - close_current(); - } - } - preskoc: - free(background_file); - } - while (ask_exit_status==1); - ClearMapFiles(); - redraw_desktop(); - close_manager(); - return 0; - } - -int __stdcall WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) -{ - return main(__argc,__argv); -} - - - int GetExeVersion() - { - return MAPEDIT_NVERSION; - } diff --git a/MAPS/MAPY.C b/MAPS/MAPY.C deleted file mode 100644 index 5724500..0000000 --- a/MAPS/MAPY.C +++ /dev/null @@ -1,1108 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mapy.h" -#include -#include "steny.h" -#include "globals.h" -#include "edit_map.h" -#include "wiz_tool.h" -#include "mob_edit.h" - -TMAP mapa; -TMAP_EDIT minfo; -TVYKLENEK vyklenky[256]; -long map_win=-1; -long tool_bar=-1; -char tool_sel=30; -long xmap_offs=0,ymap_offs=0,cur_layer=0; -int maplen=1; -int m_zoom=3; -static char nocenter=0; - -#define ZELENA RGB555(0,31,0) -#define CERVENA RGB555(31,0,0) -#define MODRA RGB555(0,0,31) - -char _actions []= - "<��dnďż˝>\0" - "Otevďż˝i dveďż˝e\0" - "Zavďż˝i dveďż˝e\0" - "Otevďż˝i nebo zavďż˝i\0" - "Spusďż˝ animaci prim\0" - "Ukaďż˝ prim. stďż˝nu\0" - "Schovej prim.stďż˝nu\0" - "Uk/schov.pri.stďż˝nu\0" - "Spusďż˝ animaci sek.\0" - "Ukaďż˝ sek. stďż˝nu\0" - "Schovej sek. stďż˝nu\0" - "Uk/schov.sek.stďż˝nu\0" - "Schovej prim.&sek.\0" - "Zobraz text\0" - "Kod.zďż˝mek (starďż˝-Nepou��vat!)\0" - "Otevďż˝i teleport\0" - "Uzavďż˝i teleport\0" - "Kodovďż˝ zďż˝mek (log)\0" - "Konec hry\0" - "\\\0"; - -char chka[]={0,1,1,1,1,1,1,1,1,1,1,1,0}; -char _steny2 []="Severnďż˝\0Vďż˝chodnďż˝\0Jiďż˝nďż˝\0Zďż˝padnďż˝\0\\\0"; -char _zivly []="Oheďż˝\0Voda\0Zemďż˝\0Vzduch\0Mysl\0\\\0"; - -char _sector_types[]= - "!Volnďż˝!\0""Normalnďż˝\0""Schody\0""Loďż˝ka na vodďż˝\0""Lďż˝va\0" - "Smďż˝r sever\0""Smďż˝r vďż˝chod\0""Smďż˝r jih\0""Smďż˝r zďż˝pad\0""Voda\0""Sloup\0""Dira\0""Teleport\0" - "Tla��tko(norm)\0""Tla��tko(zmaďż˝k)\0" - "Flďż˝tna (Sever)\0""Flďż˝tna (Vďż˝chod)\0""Flďż˝tna (Jih)\0""Flďż˝tna (Zďż˝pad)\0" - "Opuďż˝tďż˝nďż˝ mapy\0""Vďż˝r\0""Sloup&Smrt\0""Ubďż˝ra ďż˝ivoty\0" - "\\\0"; - -char _type_multi_actions[]= - "Nop\0""Sound effekt\0""Text global\0""Text local\0""Send action\0""Fireball\0""Destroy Item\0" - "Load Level\0""Drop Item\0""Start dialog\0""Start Shop\0""Code Lock\0""Cancel Action\0" - "Lock\0""Swap Sectors\0""HIT Player\0""If Jump\0""Call SpecProc\0" - "If have item\0""Story (local)\0""If test action\0""Experience\0""Teleport_group\0""Play Anim\0" - "Create Item\0""If flag Jump\0""Change Flag\0""Drop Unique Item\0" - "Drop Money\0""Give Unique Item\0" - "If Item Holded\0""Write Book\0" - "Random Jump\0""The End\0""Send Monter To\0""Share Multiaction\0""Change Music\0""Global Event\0" - "If Sector Num\0""If Sector Type\0" - "\\\0"; - -char _typy_zbrani[]= - "Meďż˝ (t��kďż˝ ostrďż˝ rovnďż˝)\0" - "Sekera (t��kďż˝ ostrďż˝ ost.)\0" - "Kladivo (tupďż˝)\0" - "Hďż˝l\0" - "Dďż˝ka (Lehkďż˝ ostrďż˝)\0" - "��p (stďż˝elnďż˝)\0" - "Ostatnďż˝ / Spec\0" - "\\\0"; - -char _typy_veci[]= - "Nespecifikovďż˝no\0" - "Zbraďż˝ tv��� v tv��\0" - "Vrhacďż˝ zbraďż˝\0" - "Stďż˝elnďż˝ zbraďż˝\0" - "Zbroj\0" - "Svitek / Hďż˝lka\0" - "Lektvar\0" - "Voda\0" - "Jďż˝dlo\0" - "Speciďż˝lnďż˝\0" - "Runa\0" - "Penďż˝ze\0" - "Svitek s textem\0" - "Prach\0" - "Ostatnďż˝\0" - "\\\0"; - -char _umisteni_veci[]= - "Nikam\0" - "Zavazadlo\0" - "Na tďż˝lo (nahoďż˝e)\0" - "Na tďż˝lo (dole)\0" - "Na hlavu\0" - "Na nohy\0" - "Kutna (na tďż˝lo/nahoďż˝e/dole/helma)\0" - "Na krk\0" - "Do ruky\0" - "Obouruďż˝\0" - "Prsten\0" - "��p\0" - "\\0"; - -char _side_flgs[]= - "Automap\0" - "Neprďż˝chozďż˝(hrďż˝c)\0" - "Neprďż˝chozďż˝(nestvďż˝ra)\0" - "Neprďż˝chozďż˝(vďż˝c)\0" - "Neprďż˝chozďż˝(zvuk)\0" - "Poplach\0" - "Prďż˝chozďż˝ akce\0" - "Prďż˝chlednďż˝ stďż˝na\0" - "Prim:Animace\0" - "Prim:Viditelnďż˝\0" - "Prim:Tam a zpďż˝t\0" - "Prim:Smďż˝r\0" - "Sek:Animace\0" - "Sek:Viditelnďż˝\0" - "Sek:Tam a zpďż˝t\0" - "Sek:Smďż˝r\0" - "Levďż˝ oblouk\0" - "Pravďż˝ oblouk\0" - "Dva druhy stďż˝n\0" - "Spec. mapovat\0" - "Kopďż˝ruj p��chozďż˝ udďż˝lost\0" - "Poďż˝li jinou udďż˝lost\0" - "Aplikuj i z druhďż˝ strany\0" - "Autoanimace pďż˝epďż˝na��\0" - "Zmďż˝na automapingu\0" - "Zmďż˝na prďż˝chodnosti(hr��)\0" - "Zmďż˝na prďż˝chodnosti(nestvďż˝ra)\0" - "Zmďż˝na prďż˝chodnosti(vďż˝c)\0" - "Zmďż˝na prďż˝chodnosti(zvuk)\0" - "Tajnďż˝ stďż˝na\0" - "TRUESEE (iluze)\0" - "Neviditelnďż˝ na mapďż˝\0" - "Potvora je ve hďż˝e\0" - "Potvora je v oblasti\0" - "\\\0"; - -char **side_flgs; -char **actions; -char **steny2; -char **zivly; -char **sector_types; -char **act_types; -char **typy_zbrani; -char **typy_veci; -char **umisteni_veci; -char **mob_procs=NULL; -char **wall_procs=NULL; - -char side_chscr[]= - {8,8,4,1,2,1,4,1,1,1,1,16,8,8, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 4,4,4,4,8,8,0}; - -word fgc[32]= - {0,RGB555(0,27,31),RGB555(4,27,16),RGB555(0,15,31),RGB555(16,16,16),RGB555(0,31,31),RGB555(4,23,15),RGB555(0,31,31), - RGB555(20,0,0),RGB555(20,31,31),RGB555(24,15,15),RGB555(20,15,18),RGB555(28,0,0),RGB555(28,31,31),RGB555(28,23,0),0 - ,WINCOLOR,RGB555(0,27,31),RGB555(4,27,16),RGB555(0,15,31),RGB555(16,16,16),RGB555(0,31,31),RGB555(4,23,15),RGB555(0,31,31), - RGB555(20,0,0),RGB555(20,31,31),RGB555(24,15,15),RGB555(20,15,18),RGB555(28,0,0),RGB555(28,31,31),RGB555(28,23,0),0}; - -void init_maps(void) - { - memset(&mapa,0,sizeof(mapa)); - } - -int find_free_sector(void) - { - int i=1; - - while (i=MAPSIZE) return -1; - return i; - } - -int find_sector(int x,int y,int layer) - { - int i=0; - char p; - - do - { - i++; - while (iflags|=0x80; - st->flags&=~0x021e; - mapa.sectordef[sector1].step_next[smer]=sector2; - smer=(smer+2)& 3; - st=&mapa.sidedef[sector2][smer]; - st->flags|=0x80; - st->flags&=~0x021e; - mapa.sectordef[sector2].step_next[smer]=sector1; - } - - -void wire_sector(int sector) - { - int x,y,l,s; - - x=minfo[sector].x; - y=minfo[sector].y; - l=minfo[sector].layer; - s=find_sector(x,y-1,l); - if (s+1) wire_2_sectors(sector,s,0); - s=find_sector(x+1,y,l); - if (s+1) wire_2_sectors(sector,s,1); - s=find_sector(x,y+1,l); - if (s+1) wire_2_sectors(sector,s,2); - s=find_sector(x-1,y,l); - if (s+1) wire_2_sectors(sector,s,3); - } - -int add_sector(int x,int y,int layer,int source_num) - { - int w; - - w=find_sector(x,y,layer); - if (!(w+1)) - { - TSTENA *st,*sc; - int i; - - w=find_free_sector(); - if (w>=maplen) maplen=w+1; - if (w==-1) return -1; - for (i=0;i<4;i++) - { - st=&mapa.sidedef[w][i]; - sc=&mapa.sidedef[source_num][i]; - memcpy(st,sc,sizeof(TSTENA)); - st->flags&=~0xfe; - st->flags|=0x021e; - } - memcpy(&mapa.sectordef[w],&mapa.sectordef[source_num],sizeof(TSECTOR)); - memset(&mapa.sectordef[w].step_next,0,sizeof(mapa.sectordef[w].step_next)); - if (!mapa.sectordef[w].sector_type) mapa.sectordef[w].sector_type=1; - minfo[w].x=x; - minfo[w].y=y; - minfo[w].layer=layer; - minfo[w].flags=0; - } - wire_sector(w); - return w; - } - -void unwire_2_sectors(int sector1,int sector2,int smer) - { - TSTENA *st; - - st=&mapa.sidedef[sector1][smer]; - mapa.sectordef[sector1].step_next[smer]=0; - st->flags&=~0xfe; - st->flags|=0x021e; - smer=(smer+2)& 3; - st=&mapa.sidedef[sector2][smer]; - st->flags&=~0xfe; - st->flags|=0x021e; - mapa.sectordef[sector2].step_next[smer]=0; - } - -void flags_2_sectors(int sector1,int sector2,int smer,long flags) - { - TSTENA *st; - - st=&mapa.sidedef[sector1][smer]; - st->flags|=flags; - smer=(smer+2)& 3; - st=&mapa.sidedef[sector2][smer]; - st->flags|=flags; - } - - -void tenka_stena(int x,int y,int layer,int smer,int flags) - { - int s1,s2; - - s1=find_sector(x,y,layer); - if (s1+1) - { - if (mapa.sectordef[s1].step_next[smer]) - { - s2=mapa.sectordef[s1].step_next[smer]; - if (s2>=0 && s2>1),y,x,y+(M_ZOOM>>1)); - line(x+(M_ZOOM>>1),y,x+M_ZOOM,y+(M_ZOOM>>1)); - line(x+(M_ZOOM>>1),y,x+(M_ZOOM>>1),y+M_ZOOM); - } - -void sipka_dolu(int x,int y) - { -line(x+(M_ZOOM>>1),y+M_ZOOM,x,y+(M_ZOOM>>1)); -line(x+(M_ZOOM>>1),y+M_ZOOM,x+M_ZOOM,y+(M_ZOOM>>1)); -line(x+(M_ZOOM>>1),y,x+(M_ZOOM>>1),y+M_ZOOM); - } - -void sipka(int x,int y,int q,int color) - { - char c[2]=" \0"; - - if (m_zoom<3) return; - c[0]=q; - charcolors[0]=RGB555(16,9,0); - charcolors[1]=color; - curfont=icones; - if (m_zoom>3) fontdsize=1; - set_aligned_position(x+(M_ZOOM>>1),y+(M_ZOOM>>1),1,1,c); - outtext(c); - fontdsize=0; - } - -void prepinac(int x,int y,int q,TSTENA *p,char tma) - { - curcolor=0; - if (p->sector_tag) curcolor=RGB555(31,16,0); - if (tma) curcolor|=RGB555(0,0,31); - if (p->oblouk & 0x10) curcolor|=RGB555(0,31,0); - if (curcolor) - { - if (curcolor==RGB555(31,31,31)) curcolor=0; - switch (q) - { - case 0: bar(x+(M_ZOOM>>1)-1,y,x+(M_ZOOM>>1)+1,y+2);break; - case 2: bar(x+(M_ZOOM>>1)-1,y+M_ZOOM,x+(M_ZOOM>>1)+1,y+M_ZOOM-2);break; - case 1: bar(x+M_ZOOM,y+(M_ZOOM>>1)-1,x+M_ZOOM-2,y+(M_ZOOM>>1)+1);break; - case 3: bar(x,y+(M_ZOOM>>1)-1,x+2,y+(M_ZOOM>>1)+1);break; - } - } - } - -void norm_rectangle(int x1,int y1,int x2,int y2) - { - ver_line(x1,y1,y2); - ver_line(x2,y1,y2); - hor_line(x1,y1,x2); - hor_line(x1,y2,x2); -} - -void autocenter_map() - { - int i; - int xmax; - int xmin; - int ymax; - int ymin; - char sett=0; - char chnged=0; - - if (nocenter) - { - nocenter=0; - return; - } - for(i=1;ixmax) xmax=x; - if (yymax) ymax=y; - } - else - { - xmin=xmax=x;ymin=ymax=y;sett=1; - } - } - if (chnged) - { - xmap_offs=(xmax+xmin)>>1; - ymap_offs=(ymax+ymin)>>1; - c_set_value(map_win,20,xmap_offs); - c_set_value(map_win,30,ymap_offs); - } - } - -void workspace_draw(int x1,int y1,int x2, int y2,OBJREC *o) - { - int x,y,i,j,xc,yc; - int mapx,mapy; - int mmz=M_ZOOM; - int mmz1=mmz/4; - int mmz3=mmz*3/4; - int yoff,xoff; - char q; - - mmz=M_ZOOM; - xc=(o->xs % M_ZOOM)>>1; - yc=(o->ys % M_ZOOM)>>1; - *(long *)o->data=1; - bar(x1,y1,x2,y2); - if (m_zoom>1) - for (y=y1+yc;y>m_zoom; - mapy=(y2-y1)>>m_zoom; - xoff=xmap_offs-mapx/2; - yoff=ymap_offs-mapy/2; - for (j=0;j<2;j++) - for (i=1;i=0 && x=0 && ylocx+xc; - y=(y<locy+yc; - - switch (q) - { - case 1:curcolor=RGB555(31,31,31);break; - case 4:curcolor=RGB555(31,15,0);break; - case 3: - case 20: - case 9:curcolor=RGB555(0,15,31);break; - case 22:curcolor=RGB555(0,31,0);break; - default: curcolor=RGB555(31,31,31); - } - - if (minfo[i].flags & 1) curcolor=RGB555(31,31,0); - if (!j) bar(x,y,x+M_ZOOM-1,y+M_ZOOM-1); - else - { - TSTENA *p; - long flg; - char sd; - - //if (tool_sel==50) - { - int p; - p=i*4; - ikris(p,x,y,x+(M_ZOOM>>1),y+(M_ZOOM>>1)); - ikris(p+1,x+(M_ZOOM>>1),y,x+M_ZOOM,y+(M_ZOOM>>1)); - ikris(p+2,x+(M_ZOOM>>1),y+(M_ZOOM>>1),x+M_ZOOM,y+M_ZOOM); - ikris(p+3,x,y+(M_ZOOM>>1),x+(M_ZOOM>>1),y+M_ZOOM); - } - p=&(mapa.sidedef[i][0]); - curcolor=RGB555(31,31,31); - flg=p->flags; - sd=p->side_tag; - if (flg & 0x21e) - {curcolor=fgc[((flg>>1)&0xf) | ((flg>>5)&0x10)];hor_line(x,y,x+mmz);} - if (flg & 0x10000) {curcolor=0x1f;hor_line(x,y,x+mmz1);} - if (flg & 0x20000) {curcolor=0x1f;hor_line(x+mmz3,y,x+mmz);} - if (sd & 0x80) {curcolor=RGB555(19,0,0);hor_line(x,y+mmz-1,x+mmz);} - p++;flg=p->flags; - sd=p->side_tag; - if (flg & 0x21e) - {curcolor=fgc[((flg>>1)&0xf) | ((flg>>5)&0x10)];ver_line(x+M_ZOOM,y,y+M_ZOOM);} - if (flg & 0x10000) {curcolor=0x1f;ver_line(x+mmz,y,y+mmz1);} - if (flg & 0x20000) {curcolor=0x1f;ver_line(x+mmz,y+mmz3,y+mmz);} - if (sd & 0x80) {curcolor=RGB555(19,0,0);ver_line(x+1,y,y+mmz);} - - p++;flg=p->flags; - sd=p->side_tag; - if (flg & 0x21e) - {curcolor=fgc[((flg>>1)&0xf) | ((flg>>5)&0x10)];hor_line(x,y+M_ZOOM,x+M_ZOOM);} - if (flg & 0x10000) {curcolor=0x1f;hor_line(x+mmz3,y+mmz,x+mmz);} - if (flg & 0x20000) {curcolor=0x1f;hor_line(x,y+mmz,x+mmz1);} - if (sd & 0x80) {curcolor=RGB555(19,0,0);hor_line(x,y+1,x+mmz);} - p++;flg=p->flags; - sd=p->side_tag; - if (flg & 0x21e) - {curcolor=fgc[((flg>>1)&0xf) | ((flg>>3)&0x10)];ver_line(x,y,y+M_ZOOM);} - if (flg & 0x10000) {curcolor=0x1f;ver_line(x,y+mmz3,y+mmz);} - if (flg & 0x20000) {curcolor=0x1f;ver_line(x,y,y+mmz1);} - if (sd & 0x80) {curcolor=RGB555(19,0,0);ver_line(x+mmz-1,y,y+mmz);} - curcolor=0; - switch (q) - { - case 1:break; - case 2:sipka(x,y,'s',ZELENA);break; - case 3:sipka(x,y,'l',ZELENA);break; - //case 4:curcolor=0x0;norm_rectangle(x+(M_ZOOM>>2),y+(M_ZOOM>>2),x+M_ZOOM-(M_ZOOM>>2)-1,y+M_ZOOM-(M_ZOOM>>2)-1);break; - case 5: - case 6: - case 7: - case 8:sipka(x,y,q-1,ZELENA);break; - case 10:if (M_ZOOM>=4) curcolor=0x1f;bar(x+(M_ZOOM>>1)-2,y+(M_ZOOM>>1)-2,x+(M_ZOOM>>1)+1,y+(M_ZOOM>>1)+1);break; - case 11:curcolor=0x0;bar(x+(M_ZOOM>>2),y+(M_ZOOM>>2),x+M_ZOOM-(M_ZOOM>>2)-1,y+M_ZOOM-(M_ZOOM>>2)-1);break; - case 12:sipka(x,y,'T',ZELENA);break; - case 13:curcolor=0x0;norm_rectangle(x+(M_ZOOM>>2),y+(M_ZOOM>>2),x+M_ZOOM-(M_ZOOM>>2)-1,y+M_ZOOM-(M_ZOOM>>2)-1);break; - case 14:curcolor=RGB555(31,0,0);bar(x+(M_ZOOM>>2),y+(M_ZOOM>>2),x+M_ZOOM-(M_ZOOM>>2)-1,y+M_ZOOM-(M_ZOOM>>2)-1); - case 15: - case 16: - case 17: - case 18:sipka(x,y,q-15+4,MODRA);break; - case 19:sipka(x,y,'.',RGB555(31,31,0));break; - case 20:sipka(x,y,'!',ZELENA);break; - case 21:sipka(x,y,'M',0x8000);break; - } - if (mob_map[i]!=-1) sipka(x,y,((mob_map[i]>>14) & 3)+4,CERVENA); - for (q=0;q<4;q++) prepinac(x,y,q,&(mapa.sidedef[i][q]),(multi_actions[(i<<2)+q]!=NULL)); - } - } - } - } - -void swaps(int *x1,int *y1,int *x2,int *y2) - { - if (*x1>*x2) - { - *x1+=*x2; - *x2=*x1-*x2; - *x1=*x1-*x2; - } - if (*y1>*y2) - { - *y1+=*y2; - *y2=*y1-*y2; - *y1=*y1-*y2; - } - } - - -void draw_rectangle(int x1,int y1,int x2,int y2) - { - swaps(&x1,&y1,&x2,&y2); - xor_rectangle(x1,y1,x2-x1,y2-y1); - } - -void *working(EVENT_MSG *msg) - { - static work_counter=0; - int i; - char *c; - - if (msg->msg==E_INIT) return &working; - if (msg->msg==E_DONE) return NULL; - c=(char *)msg->data; - strcpy(c," Pracuji "); - c=strchr(c,'\0'); - for (i=0;idata=(void *)c; - work_counter=(work_counter+1) & 7; - return NULL; - } - -void *print_layer(EVENT_MSG *msg) - { - char *c; - - if (msg->msg==E_INIT) return &print_layer; - if (msg->msg==E_DONE) return NULL; - c=(char *)msg->data; - sprintf(c,"%d. patro",cur_layer); - c=strchr(c,'\0'); - msg->data=(void *)c; - msg->msg=-1; - return NULL; - } - - -void add_map_bar(va_list args) - { - int x,y; - long f; - int x1=va_arg(args,int); - int y1=va_arg(args,int); - int x2=va_arg(args,int); - int y2=va_arg(args,int); - - f=get_draw_flags(); - swaps(&x1,&y1,&x2,&y2); - if (y1==y2) - for(x=x1;xflags|=(mf->x>=x1 && mf->xy>=y1 && mf->ylayer==cur_layer && mapa.sectordef[y].sector_type!=0); - } - if (tool_sel==40 && c==0) close_wiz_tool(); - } - - -void workspace_event(EVENT_MSG *msg,OBJREC *o) - { - static char draw=0; - static int xf,yf,xo,yo; - int xn,yn,xc,yc; - int mapx,mapy,xoff,yoff; - int msx,msy; - - xc=(o->xs % M_ZOOM)>>1; - yc=(o->ys % M_ZOOM)>>1; - xn=o->locx+xc; - yn=o->locy+yc; - mapx=(o->xs)>>m_zoom; - mapy=(o->ys)>>m_zoom; - xoff=xmap_offs-mapx/2; - yoff=ymap_offs-mapy/2; - switch (msg->msg) - { - case E_MOUSE: - { - MS_EVENT *ms; - - ms=get_mouse(msg); - msx=ms->x-xn; - msy=ms->y-yn; - if (tool_sel==50) - { - if (ms->event_type & 0xA) - { - int i,j; - xo=(msx>>m_zoom)+xoff; - yo=(msy>>m_zoom)+yoff; - for(i=0;i(M_ZOOM>>1)) j++; - if (yo>(M_ZOOM>>1)) j=3-j; - select_item(i*4+j); - return; - } - return; - } - if (ms->event_type & 0xA) - { - xf=(msx+(M_ZOOM>>1)) & ~(M_ZOOM-1); - yf=(msy+(M_ZOOM>>1)) & ~(M_ZOOM-1); - xo=xf;yo=yf; - draw=ms->event_type & 0xA; - return; - } - if (draw && (ms->tl1 || ms->tl2)) - { - draw_rectangle(xn+xf,yn+yf,xn+xo,yn+yo); - xo=(msx+(M_ZOOM>>1)) & ~(M_ZOOM-1); - yo=(msy+(M_ZOOM>>1)) & ~(M_ZOOM-1); - draw_rectangle(xn+xf,yn+yf,xn+xo,yn+yo); - return; - } - if (ms->event_type & 0x14 && draw) - { - int i; - - i=tool_sel; - if (tool_sel==10 && !(draw & 2)) i=20; - if (tool_sel==20 && !(draw & 2)) i=10; - draw=0; - xf=(xf>>m_zoom)+xoff; - xo=(xo>>m_zoom)+xoff; - yf=(yf>>m_zoom)+yoff; - yo=(yo>>m_zoom)+yoff; - switch (i) - { - case 10:add_task(8196,add_map_bar,xf,yf,xo,yo);break; - case 20:add_task(8196,del_map_bar,xf,yf,xo,yo);break; - case 30: - case 40: - if (xf==xo) xo=1+(xf=msx/M_ZOOM+xoff); - if (yf==yo) yo=1+(yf=msy/M_ZOOM+yoff); - edit_map_bar(xf,yf,xo,yo); - redraw_object(o); - break; - } - - } - } - break; - case E_GET_FOCUS: break; - case E_LOST_FOCUS: if (draw) redraw_object(o);draw=0;break; - } - } -void workspace(OBJREC *o) - { -//o->call_init=workspace_init; - o->call_draw=workspace_draw; - o->call_event=workspace_event; - o->datasize=4; - } - -void close_with_tool(void) - { - WINDOW *w; - close_window(waktual); - if ((w=find_window(tool_bar))!=NULL) close_window(w); - if ((w=find_window(multiaction_win))!=NULL) close_window(w); - if ((w=find_window(enemy_win))!=NULL) close_window(w); - if ((w=find_window(wiz_tool_numb))!=NULL) close_window(w); - if ((w=find_window(sektor_win))!=NULL) close_window(w); - if ((w=find_window(item_win))!=NULL) close_window(w); - if ((w=find_window(vzor_win))!=NULL) close_window(w); - } - -void change_tools() - { - int i; - WINDOW *w; - - if (find_window(tool_bar)==NULL) return; - for (i=10;i<50;i+=10)c_set_value(tool_bar,i,i==tool_sel); - if (tool_sel!=30) if (find_window(sektor_win)!=NULL) - { - close_window(find_window(sektor_win)); - if (tool_sel!=40) unselect_map(); else open_wiz_tool(); - send_message(E_DONE,E_KEYBOARD,chozeni2); - } - if (tool_sel!=40) - { - if ((w=find_window(wiz_tool_numb))!=NULL) close_window(w); - if ((w=find_window(multiaction_win))!=NULL) close_window(w); - if (tool_sel!=30) unselect_map(); - else - for(i=0;iid; - change_tools(); - } - - -void scroll_workspace() - { - ymap_offs=f_get_value(0,20); - xmap_offs=f_get_value(0,30); - c_set_value(0,10,0); - } - - -void layer_show() - { - send_message(E_STATUS_LINE,E_ADD,E_IDLE,print_layer); - } -void layer_hide() - { - send_message(E_STATUS_LINE,E_DONE,E_IDLE,print_layer); - } - -void layer_plus() - { - cur_layer++; - if (cur_layer>MAX_DEPTH) cur_layer=MAX_DEPTH; - autocenter_map(); - c_set_value(0,10,0); - } - -void layer_minus() - { - cur_layer--; - if (cur_layerx=7;waktual->y=2; - on_control_change(close_with_tool); - define(10,2,20,473,408,0,workspace); - property(def_border(1,0),NULL,NULL,WINCOLOR); - o_end->autoresizex=1;o_end->autoresizey=1; - ctl=def_border(3,WINCOLOR); - waktual->minsizx=140; - waktual->minsizy=90; - define(20,3,42,17,365,1,scroll_bar_v,-100,100,(59*8)/M_ZOOM,SCROLLBARCOL); - property(ctl,NULL,NULL,WINCOLOR);c_default(ymap_offs);on_control_change(scroll_workspace); - o_end->autoresizey=1; - define(21,1,20,21,17,1,scroll_button,-2,-100,"\x1e"); - property(NULL,icones,&cl,WINCOLOR);on_control_change(scroll_support); - define(22,1,22,21,17,2,scroll_button,2,100,"\x1f"); - property(NULL,icones,&cl,WINCOLOR);on_control_change(scroll_support); - define(30,26,3,352,15,3,scroll_bar_h,-100,100,(59*8)/M_ZOOM,SCROLLBARCOL); - property(ctl,NULL,NULL,WINCOLOR);c_default(xmap_offs);on_control_change(scroll_workspace); - o_end->autoresizex=1; - define(31,96,1,21,19,2,scroll_button,2,100,"\x1c"); - property(NULL,icones,&cl,WINCOLOR);on_control_change(scroll_support); - define(32,1,1,21,19,3,scroll_button,-2,-100,"\x1d"); - property(NULL,icones,&cl,WINCOLOR);on_control_change(scroll_support); - define(40,60,1,30,19,2,button,"/");property(NULL,icones,&cl,WINCOLOR); - on_control_enter(layer_show);on_control_exit(layer_hide);on_control_change(layer_plus); - define(50,28,1,30,19,2,button,"\\");property(NULL,icones,&cl,WINCOLOR); - on_control_enter(layer_show);on_control_exit(layer_hide);on_control_change(layer_minus); - define(60,1,1,19,19,2,resizer); - xpp=&xp; - xpp++; - if (xp>=0) movesize_win(waktual,xp,*xpp,*(xpp+1),*(xpp+2)); - else movesize_win(waktual,3,3,SCR_WIDTH_X-130,SCR_WIDTH_Y-10); - } - else - { - select_window(map_win); - } - if (find_window(tool_bar)==NULL) - { - redraw_window(); - tool_bar=def_window(90,90,"Tools"); - waktual->x=SCR_WIDTH_X-1-94;waktual->y=desktop_y_size-90-3; - define(20,1,55,40,34,0,toggle_button,"\xC");property(NULL,icones,&icone_color,WINCOLOR); - on_control_change(tool_select);c_default(tool_sel==20); - define(30,42,20,40,34,0,toggle_button,"\xD");property(NULL,icones,&icone_color,WINCOLOR); - on_control_change(tool_select);c_default(tool_sel==30); - define(40,42,55,40,34,0,toggle_button,"\xE");property(NULL,icones,&icone_color,WINCOLOR); - on_control_change(tool_select);c_default(tool_sel==40); - define(10,1,20,40,34,0,toggle_button,"\xB");property(NULL,icones,&icone_color,WINCOLOR); - on_control_change(tool_select);c_default(tool_sel==10); - } -if (tool_sel==10)open_draw_win(); -if (tool_sel==40)open_wiz_tool(); -redraw_desktop(); - } - -void zoomin() - { - WINDOW *w,s; - if (m_zoom<5) - { - m_zoom++; - w=find_window(map_win); - if (w!=NULL) - { - s=*w; - nocenter=1; - close_window(w); - create_map_win(s.x,s.y,s.xs,s.ys); - } - - } - } -void zoomout() - { - WINDOW *w,s; - if (m_zoom>0) - { - m_zoom--; - w=find_window(map_win); - if (w!=NULL) - { - s=*w; - nocenter=1; - close_window(w); - create_map_win(s.x,s.y,s.xs,s.ys); - } - } - } -void set_defaults(void) - { - mapa.sidedef[0][0].flags=0x1fc42201; - mapa.sidedef[0][0].xsec=250/2; - mapa.sidedef[0][0].ysec=160/2; - mapa.sectordef[0].flags=0x11; - } - -void mapy_init(void) - { - actions=(char **)build_static_list(_actions); - steny2=(char **)build_static_list(_steny2); - zivly=(char **)build_static_list(_zivly); - sector_types=(char **)build_static_list(_sector_types); - act_types=(char **)build_static_list(_type_multi_actions); - typy_veci=(char **)build_static_list(_typy_veci); - typy_zbrani=(char **)build_static_list(_typy_zbrani); - umisteni_veci=(char **)build_static_list(_umisteni_veci); - side_flgs=(char **)build_static_list(_side_flgs); - } - -static __inline long output_code(void *target,long bitepos,int bitsize,int data) - { - *((long *)target+bitepos/8)|=data<<(bitepos & 0x7); - return bitepos+bitsize; - } - -static __inline long input_code(void *source,long *bitepos,int bitsize,int mask) - { - long res=*((long *)source+(*bitepos>>8)); - res>>=(*bitepos & 0x7); - bitepos[0]+=bitsize; - return res; - } - -/*long output_code(void *target,long bitepos,int bitsize,int data); -#pragma aux output_code parm [edi][edx][ebx][eax]=\ - "mov ecx,edx"\ - "shr ecx,3"\ - "add edi,ecx"\ - "mov ecx,edx"\ - "and cl,7h"\ - "shl eax,cl"\ - "or [edi],eax"\ - "add edx,ebx"\ - value[edx] modify [ecx]; - - -int input_code(void *source,long *bitepos,int bitsize,int mask); -#pragma aux input_code parm [esi][edi][ebx][edx]=\ - "mov ecx,[edi]"\ - "mov eax,ecx"\ - "shr eax,3"\ - "mov eax,[esi+eax]"\ - "and cl,7"\ - "shr eax,cl"\ - "and eax,edx"\ - "add [edi],ebx"\ - value[eax] modify [ecx]; -*/ - - - -void calc_changes_mem(void *orgn,void *new, void *maskreg, char *scr) - { - long bitepos1=0; - long bitepos2=0; - long bitepos3=0; - int mask; - int v1,v2; - - while (*scr) - { - mask=(1< -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mapy.h" -#include -#include "globals.h" -#include "edit_map.h" -#include "save_map.h" -#include "steny.h" -#include "mob_edit.h" -#include - - - -char *mob_dir; -TSTR_LIST enemy_list=NULL; -TSTR_LIST enemy_sound=NULL; -TMOB moblist[TOTAL_MOBS]; -short mob_map[MAPSIZE]; -int enemy_win=-1; - -void edit_mob(int i); - -static void mirror_pcx(word *pcx) - { - int xs; - int ys; - int i,j,k,l; - char *c,*d,*e; - - xs=pcx[0]; - ys=pcx[1]; - pcx+=3+256; - l=xs/2; - c=(char *)pcx; - for(i=0;iuserptr=getmem(129+4); - memset(o->userptr,0,129+4); - } - -void pcx_view_draw(int x1,int y1,int x2,int y2,OBJREC *o) - { - char *oldname; - char *newname; - void *picture; - char mirror=0; - - - picture=*(void **)(oldname=o->userptr); - oldname+=4; - newname=o->data; - if (newname[0]=='*') - newname++,mirror=1; - if (strcmp(oldname,newname)) - { - free(picture); - picture=NULL; - } - if (picture==NULL) - { - open_pcx(newname,A_8BIT,&picture); - if (mirror && picture!=NULL) mirror_pcx(picture); - } - if (picture==NULL) - { - char *d=strrchr(newname,'\\'); - void *z;long s; - if (d!=NULL) d++;else d=newname; - z=afile(d,read_group(0),&s); - if (z!=NULL) load_pcx(z,s,A_8BIT,&picture);free(z); - if (mirror) mirror_pcx(picture); - } - bar(x1,y1,x2,y2); - if (picture!=NULL) put_picture(x1,y1,picture); - *(void **)(o->userptr)=picture; - strcpy(oldname,newname); - } - -void pcx_view_done(OBJREC *o) - { - void *picture; - picture=*(void **)(o->userptr); - free(picture); - } - -void pcx_view(OBJREC *o) - { - o->call_init=pcx_view_init; - o->call_draw=pcx_view_draw; - o->call_done=pcx_view_done; - o->datasize=129; - } - -void symetry_draw(int x1,int y1,int x2,int y2,OBJREC *o) - { - x2; - curcolor=RGB555(31,31,31); - x1+=*(int *)o->data; - ver_line_xor(x1,y1,y2); - } - -void symetry_event(EVENT_MSG *msg,OBJREC *o) - { - MS_EVENT *ms; - - if (msg->msg==E_MOUSE) - { - int x1,x2; - ms=get_mouse(msg); - if (ms->tl1) - { - x1=*(int *)o->data+o->locx; - curcolor=RGB555(31,31,31); - schovej_mysku(); - ver_line_xor(x1,o->locy,o->locy+o->ys); - x2=ms->x; - ver_line_xor(x2,o->locy,o->locy+o->ys); - ukaz_mysku(); - if (x1locy,x2+1,o->locy+o->ys); - else showview(x2,o->locy,x1+1,o->locy+o->ys); - *(int *)o->data=x2-o->locx; - } - } - } - -void symetry(OBJREC *o) - { - o->call_draw=symetry_draw; - o->call_event=symetry_event; - o->datasize=4; - } - -#define delete_mob(i) memset(&moblist[i],0,sizeof(TMOB);moblist[i].cislo_vzoru=-1;create_enemy_list() -#define clear_mob_map() memset(mob_map,0xff,sizeof(mob_map)) -#define clear_map_place(i) (mob_map[i]=-1) -#define place_mob(i,j) (mob_map[i]=(j)) - -void purge_mob_map() - { - clear_mob_map(); - } - - -int add_mob_sound(char *wav) - { - int i,c; - if (enemy_sound==NULL) - { - enemy_sound=create_list(4); - return str_add(&enemy_sound,wav); - } - else - { - c=str_count(enemy_sound); - for(i=0;i"); - } - - -void new_mob() - { - int i,j; - char c; - - - if (!mglob.local_monsters && check_data_password()==0) return; - i=f_get_value(0,29); - c=enemy_list[i]!=NULL && moblist[i].cislo_vzoru!=-1; - j=create_mob(); - if (c) - { - sscanf(enemy_list[i],"%d",&i); - if (i!=-1) moblist[j]=moblist[i]; - } - else - { - memset(moblist+i,0,sizeof(TMOB)); - moblist[i].cislo_vzoru=-1; - } - edit_mob(j); - create_enemy_list(); - send_message(E_GUI,29,E_CONTROL,1,enemy_list); - } - -static char nvlast[][16]= - {"Sďż˝la","UM(%kouzlenďż˝)","Pohyblivost","Obratnost","Max zranďż˝nďż˝", - "","","Obrana(dolnďż˝)","Obrana(Hornďż˝)","ďż˝tok(Dolnďż˝)", - "ďż˝tok(Hornďż˝)","Oheďż˝","Voda","Zemďż˝","Vzduch","Mysl","ďż˝ivoty Regen", - "","","Magickďż˝ sďż˝la(D)", "Magickďż˝ sďż˝la(H)","","��innek zďż˝sahu","*"}; - - -char smery_anim[][7]= - {"Vpďż˝ed","Vlevo","Vzad","Vpravo","ďż˝tok","Zďż˝sah"}; -char smery_znaky[]="FLBRCH"; - -char sekvence[]="0123456789ABCDEF"; - -char load_ddl_seq(char *name,char otoceni) - { - char *z,*c; - long size; - - c=z=afile(name,9,&size); - if (z!=NULL) - { - while (otoceni--) if (z!=NULL) z=strchr(z+1,'\n'); - if (z==NULL) - { - free(c); - return 0; - } - while (*z<32) z++; - memcpy(sekvence,z,sizeof(sekvence)); - } - free(c); - return 1; - } - -char load_sequence(char *mobname,int otoceni) - { - char s[128]; - char st[13]; - FILE *f; - int i,c; - - sprintf(s,"%s%s.SEQ",MOB_DIR,mobname); - sprintf(st,"%s.SEQ",mobname); - f=fopen(s,"r"); - if (f==NULL) - { - char text[256]; - - if (load_ddl_seq(st,otoceni)) return 0; - sprintf(text,"Nemohu nalezt soubor %s jenďż˝ ma obsahovat sekvence animacďż˝ pro tuto potvoru...",s); - msg_box("Upozornďż˝nďż˝!",'\x1',text,"Beru na vďż˝domďż˝",NULL); - return 1; - } - while(otoceni--) - while (fgetc(f)!='\n'); - c=fgetc(f); i=0; - while (c!=EOF && c!='\n' && imsg) - { - case E_INIT:phase=-1; - turn=f_get_value(0,185); - break; - case E_TIMER:if (delay) delay--; - else - { - char name[129],c[10]; - word *picture; - int x,y,xs,ys; - - delay=2; - get_value(0,100,c); - sprintf(name,"%s%s%c%c.PCX",MOB_DIR,c,smery_znaky[turn]=='R'?'L':smery_znaky[turn],sekvence[phase+1]); - x=320;y=0;xs=1;ys=1; - ch=open_pcx(name,A_8BIT,(void **)&picture); - if (ch) - { - void *z;long s;char *c; - c=strrchr(name,'\\');if (c==NULL) c=name;else c++; - z=afile(c,9,&s); - if (z!=NULL) load_pcx(z,s,A_8BIT,(void **)&picture),free(z),ch=0;else ch=1,picture=NULL; - } - if (!ch) - { - if (turn==3) - mirror_pcx(picture); - x-=f_get_value(0,300+turn*16+phase+1); - xs=picture[0]; - ys=picture[1]; - y=460-ys; - if (x<0) x=0; - put_picture(x,y,picture); - free(picture); - } - phase=(phase+1)%vals(120+turn); - showview(0,0,0,0); - curcolor=0; - bar(x,y,x+xs,y+ys); - } - break; - case E_KEYBOARD:exit_wait=1;break; - case E_MOUSE: - { - MS_EVENT *ms; - - ms=get_mouse(msg); - if (ms->event_type & 0x4) exit_wait=1; - msg->msg=-1; - } - } - } - -void play_mob() - { - int i; - char s[12]; - - int mx = DxGetResX() - 1; - int my = DxGetResY() - 1; - - get_value(0,100,s); - i=f_get_value(0,185); - if (load_sequence(s,i)) return; - update_mysky(); - schovej_mysku(); - curcolor=0; - bar(0,0,mx,my); - send_message(E_ADD,E_TIMER,pohyb_moba); - send_message(E_ADD,E_KEYBOARD,pohyb_moba); - send_message(E_ADD,E_MOUSE,pohyb_moba); - escape(); - send_message(E_DONE,E_TIMER,pohyb_moba); - send_message(E_DONE,E_KEYBOARD,pohyb_moba); - send_message(E_DONE,E_MOUSE,pohyb_moba); - redraw_desktop(); - ukaz_mysku(); - } - - -void build_mobs_name() - { - int i,j,k; - char c,path[129],name[10]; - char *d; - char m; - - i=f_get_value(0,180); - j=f_get_value(0,185); - get_value(0,100,name); - c=smery_znaky[j]; - if (c=='R') c='L',m=1;else m=0; - sprintf(path,"%s%s%s%c%c.PCX",m?"*":"",MOB_DIR,name,c,sekvence[i]); - k=f_get_value(0,205); - c_set_value(0,205,300); - c_set_value(0,205,k); - c_set_value(0,205,300); - set_value(0,200,path); - c_set_value(0,205,f_get_value(0,300+i+16*j)); - d=strrchr(path,'\\');if (d!=NULL) d++;else d=path; - set_value(0,207,d); - } - -void check_mobs_name() - { - char s[10]; - int i; - - get_value(0,100,s); - for(i=0;i<6 && s[i];i++) if (s[i]==32) s[i]='_'; - for(;i<6;i++) s[i]='_'; - s[i]=0; - strupper(s); - set_value(0,100,s); - c_set_value(0,180,0); - c_set_value(0,185,0); - build_mobs_name(); - } - -void mob_next() - { - int i,j,max; - char s[12]; - i=f_get_value(0,180); - j=f_get_value(0,185); - get_value(0,100,s); - load_sequence(s,j); - c_set_value(0,300+i+16*j,f_get_value(0,205)); - max=vals(120+j); - i=(i+1)%(max+1); - c_set_value(0,180,i); - build_mobs_name(); - redraw_desktop(); - } - -void mob_turn() - { - int i,j; - char s[12]; - i=f_get_value(0,180); - j=f_get_value(0,185); - c_set_value(0,300+i+16*j,f_get_value(0,205)); - do - j=(j+1)%+6; - while (!vals(120+j)); - c_set_value(0,185,j); - c_set_value(0,180,0); - get_value(0,100,s); - load_sequence(s,j); - build_mobs_name(); - redraw_desktop(); - } - -void mob_ask_delete() - { - - if (msg_box("Dotaz?",'\x2',"Opravdu chceďż˝ potovoru vymazat ze seznamďż˝ vzorďż˝? Ujisti se, ďż˝e tuto potvoru nepou��v�� v ��dnďż˝ jinďż˝ mapďż˝","Ano","Ne",NULL)==1) - terminate_gui(); - o_aktual=find_object(waktual,260); - } - -char *sound_ev[]= - {"Pďż˝i chďż˝zi","ďż˝tok","Zďż˝sah","Reserved"}; - -void mob_test_sound() - { - char *c; - TSTR_LIST ls; - int d; - - send_message(E_GUI,9,E_CONTROL,0,&ls); - d=f_get_value(0,9); - if (ls[d]==NULL) return; - concat(c,"",ls[d]); - name_conv(c); - add_task(16384,play_wav,c,0); - do_events(); - do_events(); - } - -void mob_sound_copy() - { - int id=o_aktual->id; - TSTR_LIST ls; - int d; - char c[20]; - - send_message(E_GUI,9,E_CONTROL,0,&ls); - d=f_get_value(0,9); - if (ls[d]==NULL) return; - strncpy(c,ls[d],20);name_conv(c); - id-=20; - set_value(0,id,c); - } - - -void mob_inv() - { - int m,i; - CTL3D b1; - TSTR_LIST ls_sorts=NULL; - - create_isort_list(&ls_sorts,-1); - m=f_get_value(0,190); - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - default_font=vga_font; - memcpy(f_default,flat_color(0x0000),sizeof(charcolors)); - def_dialoge(100,50,400,390,"Invent�� potvory"); - str_insline(&ls_sorts,0,""); - for(i=0;iid==300) - for(i=0;i", - "< volno >", - "< volno >", - "Vyhrazeno pro dďż˝mona" - }; - -void spell_affections() - { - int m,i; - CTL3D b1; - - - m=f_get_value(0,700); - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - default_font=vga_font; - memcpy(f_default,flat_color(0x0000),sizeof(charcolors)); - def_dialoge(100,50,400,390,"Affections"); - for(i=0;i<16;i++) - { - define(i+10,10,20+i*12,250,10,0,check_box,aff_list[i]);c_default((m & (1<id==300) - { - for(i=0,m=0;i<16;i++) m|=f_get_value(0,i+10)<id==100) - { - char s[20]; - for(j=0;jid)) - { - moblist[i].dialog=-1; - return; - } - j=moblist[i].dialog; - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D)); - memcpy(&b3,def_border(6,WINCOLOR),sizeof(CTL3D)); - default_font=vga_font; - memcpy(f_default,flat_color(0x0000),sizeof(charcolors)); - def_dialoge(100,250,250,180,"Pďż˝iďż˝aďż˝ dialog"); - define(9,10,20,200,126,0,listbox,dlg_names,RGB555(31,31,31),0); - property(&b3,NULL,NULL,WINCOLOR);c_default(pgf2name(j)); - define(10,217,40,19,87,0,scroll_bar_v,0,10,1,SCROLLBARCOL); - property(&b2,NULL,NULL,WINCOLOR); - define(11,216,20,21,17,0,scroll_button,-1,0,"\x1e"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(12,216,130,21,17,0,scroll_button,1,10,"\x1f"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(100,5,5,80,20,2,button,"Ok");on_control_change(terminate_gui); property(&b1,NULL,NULL,WINCOLOR); - define(110,90,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui); property(&b1,NULL,NULL,WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==100) - { - moblist[i].dialog=dlg_pgfs[f_get_value(0,9)]; - } - close_current(); - c_set_value(0,k,moblist[i].dialog>=0); - } - -/*static void ask_dialog(EVENT_MSG *msg,OBJREC *obj) - { - if (msg->msg==E_MOUSE) - { - MS_EVENT *ms; - - ms=get_mouse(msg); - if ((ms->event_type & 0xA && *(char *)obj->data)) - open_dialog_edit_box(); - } - }*/ - -void edit_mob(int i) - { - int y,z; - CTL3D *b1; - - if (!mglob.local_monsters && check_data_password()==0) return; - i; - if (!moblist[i].anim_counts[0]) moblist[i].anim_counts[0]=1; - def_dialoge(50,20,550,415,"Definice potvory"); - define(200,310,35,290,1,0,pcx_view);set_default("_"); - define(205,310,35,290,370,0,symetry);c_default(moblist[i].adjusting[0]); - define(207,5,20,120,20,1,input_line,20);set_default(""); - define(-1,190,20,100,12,0,label,"Jmďż˝no potvory"); - define(10,300,20,200,12,0,input_line,31);set_default(moblist[i].name);property(def_border(2,WINCOLOR),NULL,NULL,WINCOLOR); - z=0;b1=def_border(5,WINCOLOR); - for(y=20;y<380;) - { - if (nvlast[z][0]) - { - define(-1,5,y,140,12,0,label,nvlast[z]); - define(z+20,120,y,60,12,0,input_line,8,-32767,32767,"%6d");set_default(strs(moblist[i].vlastnosti[z]));on_control_exit(test_int); - property(b1,NULL,NULL,WINCOLOR); - y+=15; - } - z+=1; - if (nvlast[z][0]=='*') break; - } - y+=15; - define(-1,5,y,140,12,0,label,"ďż˝ivel:"); - define(102,120,y,60,12,0,str_line,zivly);c_default(moblist[i].vlastnosti[VLS_MGZIVEL]);on_enter(string_list_sup);property(b1,NULL,NULL,WINCOLOR);y+=15; - define(-1,5,y,140,12,0,label,"Jmďż˝no grafiky"); - define(100,120,y,60,12,0,input_line,6);set_default(moblist[i].mobs_name);property(b1,NULL,NULL,WINCOLOR);on_control_exit(check_mobs_name);y+=15; - define(-1,5,y,140,12,0,label,"Rychlost"); - define(101,130,y,30,12,0,input_line,3,0,128,"%3d");set_default(strs(moblist[i].speed));on_control_exit(test_int);property(b1,NULL,NULL,WINCOLOR);y+=15; - define(-1,5,y,140,12,0,label,"ďż˝ance ďż˝tďż˝ku"); - define(103,130,y,30,12,0,input_line,3,0,255,"%3d");set_default(strs(moblist[i].flee_num));on_control_exit(test_int);property(b1,NULL,NULL,WINCOLOR);y+=15; - define(-1,5,y,140,12,0,label,"Kouzlo"); - define(104,130,y,30,12,0,input_line,3,0,255,"%3d");set_default(strs(moblist[i].casting));on_control_exit(test_int);property(b1,NULL,NULL,WINCOLOR);y+=15; - define(-1,5,y,140,12,0,label,"Specproc"); - define(105,120,y,60,12,0,str_line,mob_procs);c_default(moblist[i].specproc);on_enter(string_list_sup);property(b1,NULL,NULL,WINCOLOR);y+=15; - y=260;define(-1,220,248,140,12,0,label,"Poďż˝et anim."); - for(z=0;z<6;z++) - { - define(-1,190,y,50,12,0,label,smery_anim[z]); - define(z+120,260,y,20,12,0,input_line,2,!z*2,15,"%2d");set_default(strs(moblist[i].anim_counts[z]));on_control_exit(test_int); - property(b1,NULL,NULL,WINCOLOR); - y+=15; - } - define(127,285,320,20,12,0,input_line,2,1,15,"%2d");set_default(strs(moblist[i].hit_pos));on_control_exit(test_int); - property(b1,NULL,NULL,WINCOLOR); - define(430,190,350,50,10,0,check_box,"Chodďż˝"); - define(440,190,362,50,10,0,check_box,"ďż˝to��"); - define(450,190,374,50,10,0,check_box,"Sly��"); - define(460,250,350,100,10,0,check_box,"Jeden na pol��ku"); - define(470,250,362,60,10,0,check_box,"Str��ce"); - define(480,250,374,40,10,0,check_box,"Sebere"); - define(490,250,386,40,10,0,check_box,"Sbďż˝rďż˝"); - define(500,190,386,50,10,0,check_box,"St��lďż˝"); - define(510,20,438,50,10,0,check_box,"Dialog.");c_default(moblist[i].dialog>=0);on_control_change(open_dialog_edit_box); - define(-1,190,50,50,12,0,label,"Dohled"); - define(-1,190,65,50,12,0,label,"Dosah"); - define(-1,190,80,50,12,0,label,"Expy:"); - define(-1,190,95,50,12,0,label,"Bonus:"); - define(-1,190,110,50,12,0,label,"Penďż˝ze:"); - define(160,260,50,30,12,0,input_line,3,0,255,"%3d");set_default(strs(moblist[i].dohled));on_control_exit(test_int);property(b1,NULL,NULL,WINCOLOR); - define(170,260,65,30,12,0,input_line,3,0,255,"%3d");set_default(strs(moblist[i].dosah));on_control_exit(test_int);property(b1,NULL,NULL,WINCOLOR); - define(175,250,80,55,12,0,input_line,6,0,999999,"%6d");set_default(strs(moblist[i].experience));on_control_exit(test_int);property(b1,NULL,NULL,WINCOLOR); - define(176,250,95,55,12,0,input_line,6,0,65535,"%6d");set_default(strs(moblist[i].bonus));on_control_exit(test_int);property(b1,NULL,NULL,WINCOLOR); - define(177,255,110,50,12,0,input_line,6,0,65535,"%5d");set_default(strs(moblist[i].money));on_control_exit(test_int);property(b1,NULL,NULL,WINCOLOR); - define(180,0,0,0,0,0,value_store,4);c_default(0);//cislo_animace - define(185,0,0,0,0,0,value_store,4);c_default(0);//cislo_pozice - define(190,0,0,0,0,0,value_store,4);c_default(i);//cislo_i - b1=def_border(1,0); - define(210,190,144,80,20,0,button,"Dal�� >>");property(b1,NULL,NULL,WINCOLOR);on_control_change(mob_next); - define(220,190,166,80,20,0,button,"Otoďż˝it");property(b1,NULL,NULL,WINCOLOR);on_control_change(mob_turn); - define(230,190,188,80,20,0,button,"Test");property(b1,NULL,NULL,WINCOLOR);on_control_change(play_mob); - define(240,84,2,80,20,2,button,"Zruďż˝it");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(250,2,2,80,20,2,button,"Ok");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(260,166,2,80,20,2,button,"Vymazat");property(b1,NULL,NULL,WINCOLOR);on_control_change(mob_ask_delete); - define(270,2,24,80,20,2,button,"Zvuky");property(b1,NULL,NULL,WINCOLOR);on_control_change(mob_sound); - define(280,84,24,80,20,2,button,"Invent��");property(b1,NULL,NULL,WINCOLOR);on_control_change(mob_inv); - define(290,166,24,80,20,2,button,"Aff");property(b1,NULL,NULL,WINCOLOR);on_control_change(spell_affections); - define(-1,190,220,1,1,0,label,"Pals:"); - define(520,230,220,30,12,0,input_line,3,-127,127,"%3d");set_default(strs(moblist[i].paletts_count));on_control_exit(test_int);property(b1,NULL,NULL,WINCOLOR); - for(y=0;y<6*16;y++) {define(300+y,0,0,0,0,0,value_store,4);c_default(moblist[i].adjusting[y]);} - define(630,0,0,0,0,0,value_store,1);c_default(0);//IN_BATTLE; - define(640,190,400,50,10,0,check_box,"Prďż˝chozďż˝"); - define(650,190,412,50,10,0,check_box,"Cďż˝tďż˝"); - define(660,190,424,100,10,0,check_box,"Astral (wind)"); - define(670,300,400,100,10,0,check_box,"Reload mob"); - define(680,300,412,100,10,0,check_box,"Kouzlďż˝"); - define(700,0,0,0,0,0,value_store,4);c_default(moblist[i].vlastnosti[VLS_KOUZLA]); - movesize_win(waktual,0,0,DxGetResX(),DxGetResY()); - check_mobs_name(); - fill_bit_fields(0,430,moblist[i].stay_strategy,8); - fill_bit_fields(0,630,moblist[i].vlajky,6); - redraw_desktop(); - escape(); - if (o_aktual->id==250) - { - TMOB *p; - p=&moblist[i]; - get_value(0,10,p->name); - for(z=0;z<24;z++) - if (nvlast[z][0]) p->vlastnosti[z]=vals(20+z);else p->vlastnosti[z]=0; - get_value(0,100,p->mobs_name); - p->speed=vals(101); - p->vlastnosti[VLS_MGZIVEL]=f_get_value(0,102); - p->flee_num=vals(103); - p->casting=vals(104); - p->specproc=f_get_value(0,105); - for(z=0;z<6;z++) p->anim_counts[z]=vals(120+z); - p->hit_pos=vals(127); - p->stay_strategy=get_bit_fields(0,430,8); - p->vlajky=get_bit_fields(0,630,6) | (p->vlajky & 0x40); - p->dohled=vals(160); - p->dosah=vals(170); - p->experience=vals(175); - p->bonus=vals(176); - p->money=vals(177); - p->vlastnosti[VLS_KOUZLA]=f_get_value(0,700); - for(z=0;z<6*16;z++) p->adjusting[z]=f_get_value(0,300+z); - if (p->name[0]=='\0') - { - msg_box("Doporuďż˝enďż˝",' ',"Bylo by dobrďż˝ potvoru nazvat, kvuli snadnďż˝ manipulaci","Ok",NULL); - strcpy(p->name,p->mobs_name); - } - p->lives=p->vlastnosti[VLS_MAXHIT]; - p->cislo_vzoru=i; - p->locx=128; - p->headx=128; - p->locy=128; - p->heady=128; - for(y=0;y<6;y++) - for(z=0;z<16;z++) - if (moblist[i].anim_counts[y]==0) moblist[i].adjusting[z+y*16]=moblist[i].adjusting[z]; - p->paletts_count=vals(520); - } - z=o_aktual->id; - close_current(); - if (z==260) - { - int j; - char redraw=0; - for(j=0;j=0 && iminsizx=140; - waktual->minsizy=150; - define(-1,3,1,10,10,2,resizer); - define(29,5,20,170,190,0,listbox,enemy_list,RGB555(31,31,0),4);c_default(0); - o_end->autoresizex=1; - o_end->autoresizey=1; - b1=def_border(3,WINCOLOR); - define(30,5,38,15,156,1,scroll_bar_v,0,10,1,SCROLLBARCOL); - property(b1,NULL,NULL,WINCOLOR); - o_end->autoresizey=1; - define(31,3,20,19,15,1,scroll_button,-1,0,"\x1e"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(32,3,68,19,15,2,scroll_button,1,10,"\x1f"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(40,5,5,60,20,3,button,"Vymazat");property(b1,NULL,NULL,WINCOLOR);on_control_change(vymazat_moba); - define(50,5,30,60,20,3,button,"Umďż˝stit");property(b1,NULL,NULL,WINCOLOR);on_control_change(umistit_moba); - define(60,70,5,60,20,3,button,"Novou");property(b1,NULL,NULL,WINCOLOR);on_control_change(new_mob); - define(70,70,30,60,20,3,button,"Opravit");property(b1,NULL,NULL,WINCOLOR);on_control_change(edit_mob_event); - movesize_win(waktual,SCR_WIDTH_X,0,170,SCR_WIDTH_Y-20); - redraw_window(); - } - else - select_window(enemy_win); - } - -void select_enemy(int at_sector) - { - int i,num,pos; - - num=mob_map[at_sector]; - if (num==-1) return; - num&=0x3fff; - pos=0; - for(i=0;icislo_vzoru]=*x; - free(x); - fclose(f); - } - -void *save_mobs_to_map(long *size) - { - int i,cnt; - TMOB *m,*c; - - for(i=0,cnt=0;icislo_vzoru]=*m; - } - -void *save_mob_map(long *size) - { - int i,c; - short *data,*p; - - for(i=0,c=0;i255) msg_box("Omezenďż˝",'\x1',"Nelze mďż˝t v jednďż˝ mapďż˝ vďż˝c potvor neďż˝ 255. MAPEDIT nďż˝kterďż˝ nenahraje.","Ok",NULL); - p=data=getmem(*size=c*4); - for(i=0;ic || enemy_sound[z-1]==NULL)) - { - moblist[i].sounds[j]=0; - err=1; - } - } - if (err) - { - char text[200]; - sprintf(text,"Nestvďż˝ra \"%s\" mďż˝ ďż˝patnou referenci zvuku! Poloďż˝ka bude vynulovďż˝na!",moblist[i].name); - if (msg_box("Chybnďż˝ reference",'\x1',text,"Pokraďż˝ovat","Opravit",NULL)==2) mob_sound_call(i); - } - } - } - -void save_sound_map() - { - FILE *f; - int i,c; - - if (enemy_sound==NULL) - { - remove(MOB_SOUND); - return; - } - check_correct_sounds(); - f=fopen(MOB_SOUND,"wb"); - c=str_count(enemy_sound); - while (c>0 && enemy_sound[c-1]==NULL) c--; - fwrite(&c,1,4,f); - for(i=0;i -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mapy.h" -#include "globals.h" -#include "edit_map.h" -#include "steny.h" -#include "save_map.h" -#include "mob_edit.h" - -int pcxview_win=-1; -static char swap=1; -static char in_ddl=0; - -static void *last_pcx=NULL; -static char *basic_path; - -#define BASIC_PATH "..\\graphics\\" - - -TSTR_LIST read_ddl_dir(char *filter) - { - TSTR_LIST ls; - int i=0; - char *s; - - ls=create_list(256); - s=read_next_entry(MMR_FIRST); - while (s!=NULL) - { - char *d; - char c[13]; - - strncpy(c,s,12); - c[12]=0; - if (filter!=NULL) - { - d=strrchr(c,'.'); - if (d!=NULL && !strncmp(d+1,filter,3)) str_replace(&ls,i++,c); - } - else - str_replace(&ls,i++,c); - s=read_next_entry(MMR_NEXT); - } - if (i==0) str_add(&ls,""); - ls=sort_list(ls,-1); - return ls; - } - -static void get_directory() - { - TSTR_LIST ls; - char pathname[256]; - char file=0; - - c_set_value(0,9,0); - send_message(E_GUI,9,E_CONTROL,2); - get_value(0,20,pathname); - file=f_get_value(0,45); - if (pathname[0]==0) strcpy(pathname,".\\"); - else - if (pathname[strlen(pathname)-1]!='\\') strcat(pathname,"\\"); - set_value(0,20,pathname); - send_message(E_GUI,9,E_CONTROL,0,&ls); - if (ls!=NULL) release_list(ls); - if (file) - ls=read_ddl_dir("PCX"); - else - { - strcat(pathname,"*.pcx"); - ls=read_directory(pathname,DIR_BREIF,_A_NORMAL); - } - if (ls==NULL) - { - ls=create_list(2); - str_add(&ls,""); - } - send_message(E_GUI,9,E_CONTROL,1,ls); - in_ddl=file; - redraw_desktop(); - } - -static void close_pcx_window() - { - TSTR_LIST ls; - send_message(E_GUI,9,E_CONTROL,0,&ls); - if (ls!=NULL) release_list(ls); - if (last_pcx!=NULL)free(last_pcx);last_pcx=NULL; - close_current(); - } - -static void picture2_display(int x1,int y1,int x2,int y2,OBJREC *o) - { - word *paleta; - word *data; - int xs,ys,xo; - word *w; - char *d,*e; - - data=*(void **)o->data;x2,y2; - if (data==NULL) return; - paleta=data+3; - xs=data[0]; - ys=data[1]; - if (swap) y1=y1+ys/2; - data=paleta+256; - e=(char *)data; - do - { - w=GetScreenAdr()+x1+scr_linelen2*y1; - xo=xs/2; - d=e; - do - { - word col=paleta[*d]; - *w++=col/*+(col & ~0x1F)*/;d+=2; - } - while (--xo); - e+=xs*2; - if (swap) y1--;else y1++; - ys-=2; - } - while(ys>0 && y1<460); - } - -static void picture2(OBJREC *o) - { - o->call_draw=picture2_display; - o->datasize=4; - } - -static char *get_pcx(char *filename) - { - char *c; - if (in_ddl) - { - long s; - void *z; - char *name; - - name=strrchr(filename,'\\');if(name!=NULL) name++;else name=filename; - if (test_file_exist(read_group(0),name)) - { - z=afile(name,read_group(0),&s); - load_pcx(z,s,A_8BIT,&c); - free(z); - } - else - c=NULL; - } - else - if (open_pcx(filename,A_8BIT,&c)) - { - in_ddl=!in_ddl;c=get_pcx(filename);in_ddl=!in_ddl; - return c; - } - return c; - } - -static void read_pcx() - { - char pathname[256]; - char name[30]; - TSTR_LIST ls; - int i; - - send_message(E_GUI,9,E_CONTROL,0,&ls); - get_value(0,20,pathname); - if (last_pcx!=NULL) free(last_pcx); - i=f_get_value(0,9); - strcpy(name,ls[i]);name_conv(name); - strcat(pathname,name); - last_pcx=get_pcx(pathname); - c_set_value(0,30,(int)last_pcx); - redraw_window(); - } - -static void change_swap() - { - swap=f_get_value(0,40); - redraw_window(); - } - -static char clr_sw=1; - -static void refresh_scrs() - { - WINDOW *w; - int i; - set_value(0,100,""); - set_value(0,110," 1"); - switch(i=f_get_value(0,130)) - { - case 0:send_message(E_GUI,140,E_CONTROL,side_names);break; - case 1:send_message(E_GUI,140,E_CONTROL,floors);break; - case 2:send_message(E_GUI,140,E_CONTROL,ceils);break; - case 3:send_message(E_GUI,140,E_CONTROL,oblouky);break; - } - if (o_aktual && o_aktual->id==130) - { - if (i==3) fill_bit_fields(0,160,2+4,3);else fill_bit_fields(0,160,1,3); - set_enable(0,160,i!=3); - set_enable(0,170,i!=2 && i!=1); - set_enable(0,180,i!=2 && i!=1); - } - c_set_value(0,140,0); - set_value(0,150," 1"); - Beep(1000,10); - w=find_window(sektor_win); - if (w!=NULL) close_window(w); - clr_sw=1; - } - -static void clear_switchs() - { - if (clr_sw) - { - c_set_value(0,160,0); - c_set_value(0,170,0); - c_set_value(0,180,0); - c_set_value(0,o_aktual->id,1); - clr_sw=0; - } - } - - -#define ZMENIT "Zmďż˝nit grafiku" -static void zmenit() - { - int i,c,f; - char *name; - TSTR_LIST ls; - - i=f_get_value(0,9); - send_message(E_GUI,9,E_CONTROL,0,&ls); - if (i>=str_count(ls))return; - if (ls[i]==NULL) return; - name=alloca(strlen(ls[i])+1);strcpy(name,ls[i]); - name_conv(name); - c=f_get_value(0,140); - if (c==0) - { - msg_box(ZMENIT,1,"Mus�� vybrat nďż˝jakou grafiku. Klepni tam, jak je napsďż˝no ",MSB_OK); - return; - } - load_side_script(script_name); - f=vals(150); - i=change_side(f_get_value(0,130),c-1,get_bit_fields(0,160,3),f-1,name); - if (i<-1) - { - msg_box(ZMENIT,1,"Program odmďż˝tl (z nďż˝jakďż˝ch dďż˝vodďż˝) akci provďż˝st. Zkontrolujte vďż˝echny ďż˝daje",MSB_OK); - discharge_side_script(); - return; - } - if (i==-1) - { - msg_box(ZMENIT,1,"Nepovolenďż˝ kombinace polďż˝ \"Hlavnďż˝\", \"Levďż˝\" a \"Pravďż˝\"",MSB_OK); - discharge_side_script(); - return; - } - save_side_script(script_name); - refresh_scrs(); - c_set_value(0,140,c); - if (i>0) - { - char c[20]; - - set_value(0,150,itoa(f+1,c,10)); - } - } - -#define VYMAZAT "Vymazat" -static void vymazat() - { - int pos=f_get_value(0,140); - - if (pos==0) - { - msg_box(VYMAZAT,1,"Mus�� vybrat nďż˝jakou grafiku. Klepni tam, jak je napsďż˝no ",MSB_OK); - return; - } - if (msg_box(VYMAZAT,1,"Vymazat grafiku vďż˝etnďż˝ p��padnďż˝ch animacďż˝?",MSB_ANONE)==2) return; - load_side_script(script_name); - if (delete_side(f_get_value(0,130),pos-1)) - { - msg_box(VYMAZAT,1,"Program odmďż˝tl vymazat grafiky ze scriptu, nastala nďż˝jakďż˝ chyba.",MSB_OK); - discharge_side_script(); - return; - } - save_side_script(script_name); - refresh_scrs(); - } - -#define ZALOZIT "Zaloďż˝it grafiku" -static void add_graphics() - { - char name[200]; - int c,d; - - get_value(0,100,name); - if (name[0]==0) {msg_box(ZALOZIT,1,"Mus�� vepsat nďż˝jakďż˝ jmďż˝no!",MSB_OK);return;} - load_side_script(script_name); - if ((c=add_side(f_get_value(0,130),name,vals(110)))==-1) - { - msg_box(ZALOZIT,1,"Nelze zaloďż˝it novou grafiku! P��liďż˝ mnoho grafik, nebo nastala jinďż˝ chyba.",MSB_OK); - discharge_side_script(); - } - else save_side_script(script_name); - d=vals(110); - refresh_scrs(); - c_set_value(0,140,c+1-d+1); - } - -static char *def_nahled(int id,int x,int y,char *name) - { - char *fpath,*p; - char ind=in_ddl; - - if (name==NULL) return NULL; - concat(fpath,basic_path,name); - in_ddl=0; - p=get_pcx(fpath); - in_ddl=ind; - define(id,x,y,10,10,0,picture2);c_default((int)p); - return p; - } - -static void nahled() - { - int list; - int pos,i; - char *p1=NULL,*p2=NULL,*p3=NULL,*p4; - char swps=swap; - - list=f_get_value(0,130);pos=f_get_value(0,140)-1+vals(150)-1; - if (pos<0) - { - msg_box("Nďż˝hled",1,"Nenďż˝ co zobrazit!",MSB_OK); - return; - } - load_side_script(script_name); - tady: - def_dialoge(2,2,630,440,"Nďż˝hled grafiky"); - switch (list) - { - case 0: p1=def_nahled(10,5,25,get_side_name(list,pos,1)); - p2=def_nahled(10,255,25,get_side_name(list,pos,2)); - p3=def_nahled(10,380,25,get_side_name(list,pos,3)); - swap=1; - break; - case 1: - case 2: p1=def_nahled(10,5,25,get_side_name(list,pos,1)); - swap=0; - break; - case 3: p1=def_nahled(10,5,25,get_side_name(list,pos,1)); - p2=def_nahled(10,255,25,get_side_name(list,pos,2)); - swap=1; - break; - } - define(-1,5,5,80,20,2,button,"Ok");on_control_change(terminate_gui); - define(110,100,5,80,20,2,button,">>");on_control_change(terminate_gui); - define(120,190,5,80,20,2,button,"<<");on_control_change(terminate_gui); - redraw_window(); - p4=get_side_name(list,pos,0); - if (p4!=NULL) set_enable(0,120,p4[0]=='*' && pos>0); - p4=get_side_name(list,pos+1,0); - set_enable(0,110,p4!=NULL && p4[0]=='*'); - escape(); - i=o_aktual->id; - close_current(); - free(p1);free(p2);free(p3); - if (i==110){pos++;goto tady;} - if (i==120){pos--;goto tady;} - discharge_side_script(); - swap=swps; - } - -void pcxviewer() - { - TSTR_LIST ls; - - basic_path=get_text_field(config_file,"CESTA_GRAFIKA"); - if (basic_path==NULL)basic_path=""; - if (find_window(pcxview_win)==NULL) - { - CTL3D b1,b2,b3; - - ls=create_list(2);str_add(&ls,""); - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D)); - memcpy(&b3,def_border(6,WINCOLOR),sizeof(CTL3D)); - pcxview_win=def_window(635,440,"Prohl��eďż˝ obrazkďż˝ PCX"); - default_font=vga_font; - memcpy(f_default,flat_color(0x0000),sizeof(charcolors)); - on_control_change(close_pcx_window); - - define(9,10,20,110,376,0,listbox,ls,0x7fff,0);on_control_change(read_pcx); - property(&b3,NULL,NULL,WINCOLOR);c_default(0); - define(10,126,40,21,337,0,scroll_bar_v,0,10,1,0x0200); - property(&b2,NULL,NULL,WINCOLOR); - define(11,126,20,21,17,0,scroll_button,-1,0,"\x1e"); - property(&b1,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(12,126,380,21,17,0,scroll_button,1,10,"\x1f"); - property(&b1,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(-1,175,20,1,1,0,label,"Cesta:"); - define(20,175,32,320,12,0,input_line,240);set_default(basic_path); - property(&b3,NULL,NULL,WINCOLOR);on_control_exit(get_directory); - define(30,175,50,2,2,0,picture2);c_default(0); - define(40,10,10,80,10,3,check_box,"Otoďż˝it");c_default(swap);on_control_change(change_swap); - define(45,10,25,160,10,3,check_box,"Grafika Skeldalu");c_default(0);on_control_change(get_directory); - define(-1,5,80,110,75,1,label,"");property(&b2,NULL,NULL,WINCOLOR); - define(-1,10,80,100,70,1,label,"Novďż˝ grafika"); - define(100,10,100,100,10,1,input_line,50);set_default("");property(&b3,NULL,NULL,WINCOLOR); - define(-1,10,115,100,12,1,label,"Snďż˝mkďż˝"); - define(110,10,115,30,10,1,input_line,20,1,15,"%2d");set_default(strs(1));property(&b3,NULL,NULL,WINCOLOR); - on_control_exit(test_int); - define(120,10,130,60,20,1,button,"Zaloďż˝it");property(&b1,NULL,NULL,WINCOLOR); - on_control_change(add_graphics); - define(130,10,160,110,50,1,radio_butts,4,"Stďż˝na","Podlaha","Strop","Oblouk");c_default(0);on_control_change(refresh_scrs); - - define(-1,5,230,110,110,1,label,"");property(&b2,NULL,NULL,WINCOLOR); - define(-1,10,230,100,10,1,label,"Vyber grafiku:"); - define(140,10,255,100,10,1,str_line,side_names);on_enter(string_list_sup);c_default(0);property(&b2,NULL,NULL,WINCOLOR); - define(-1,10,270,100,12,1,label,"Snďż˝mek"); - define(150,10,270,30,12,1,input_line,20,1,15,"%2d");set_default(strs(1));property(&b3,NULL,NULL,WINCOLOR); - on_control_exit(test_int); - define(160,10,300,100,10,1,check_box,"Hlavnďż˝");c_default(0);on_control_change(clear_switchs); - define(170,10,312,100,10,1,check_box,"Levďż˝");c_default(0);on_control_change(clear_switchs); - define(180,10,324,100,10,1,check_box,"Pravďż˝");c_default(0);on_control_change(clear_switchs); - define(190,20,345,80,20,1,button,"Pďż˝iďż˝adit");property(&b1,NULL,NULL,WINCOLOR);on_control_change(zmenit); - define(200,20,370,80,20,1,button,"Vymazat");property(&b1,NULL,NULL,WINCOLOR);on_control_change(vymazat); - define(200,20,395,80,20,1,button,"Nďż˝hled");property(&b1,NULL,NULL,WINCOLOR);on_control_change(nahled); - define(-1,130,20,1,400,1,label,"");property(def_border(4,WINCOLOR),NULL,NULL,WINCOLOR); - define(-1,100,30,1,1,1,label,"Tvďż˝rce"); - define(-1,100,45,1,1,1,label,"grafickďż˝ch"); - define(-1,100,60,1,1,1,label,"scriptďż˝"); - } - else - { - select_window(pcxview_win); - } - redraw_window(); - get_directory(); - } diff --git a/MAPS/SAVE_MAP.C b/MAPS/SAVE_MAP.C deleted file mode 100644 index da54ee3..0000000 --- a/MAPS/SAVE_MAP.C +++ /dev/null @@ -1,694 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mapy.h" -#include "edit_map.h" -#include "globals.h" -#include "steny.h" -#include "mob_edit.h" -#include "save_map.h" -#include - -#define A_SIDEMAP 0x8001 -#define A_SECTMAP 0x8002 -#define A_STRTAB1 0x8003 //stena main -#define A_STRTAB2 0x8004 //stena leva -#define A_STRTAB3 0x8005 //stena prava -#define A_STRTAB4 0x8006 //strop -#define A_STRTAB5 0x8007 //podlaha -#define A_STRTAB6 0x8008 //oblouk levy -#define A_MAPINFO 0x8009 -#define A_MAPGLOB 0x800A -#define A_STRTAB7 0x800B //oblouk pravy -#define A_MAPITEM 0x800C //itemy -#define A_MAPMACR 0x800D //Makra multiakce -#define A_MAPFLY 0x800E //Letajici predmety -#define A_MAPMOBS 0x800F //Potvory v bludiďż˝ti -#define A_MAPVYK 0x8010 //Vyklenky -#define A_MOBS 0x8011 //Potvory definice -#define A_MOBSND 0x8012 //Potvory zvuky -#define A_PASSW 0x8013 //Heslo 1 -#define A_PASSW2 0x8014 //Heslo 2 -#define A_MAPEND 0x8000 - -#define BACKUP_ADR "backup" - -char filename[MAX_PATH]; - static char backup=0; - -static char password[50]; -static char passpass; - -void encrypt(char *password) - { - char *p=password; - - p=password; - while(*p) *p=~*p,p++; - } - -void encrypt2(char *in,char *out,int size) - { - int c=clock(),i; - char z; - for(i=0;inext; - *size=i*sizeof(TSMP_STAMP); - z=(TSMP_STAMP *)getmem(*size); - i=0; - q=smplist; - while(q!=NULL) - memcpy(&z[i++],q->data,sizeof(TSMP_STAMP)),q=q->next; - return z; - } - -void build_sample_tree(TSMP_STAMP *z,long size) - { - int i; - - smplist=NULL; - for (i=0;isizeof(mglob)) size=sizeof(mglob); - memcpy(&mglob,temp,size); -/* if (size>sizeof(mglob)-sizeof(mglob.mappassw)) - { - decrypt2(mglob.mappassw,password); - passpass=2; - if (password[0]) newcode=1; - }*/ - break; - case A_MAPINFO: - memcpy(&minfo,temp,size); - maplen=size / sizeof(TMAP_EDIT_INFO); - sect=0; - for (i=0;i20) Shift_map_sectors_down(); - break; - case A_MAPMACR: - load_macros(temp); - break; - case A_MAPEND: - nmapend=0; - break; - case A_MAPITEM: - load_item_map(temp,size); - break; - case A_MAPMOBS: - load_mob_map(temp,size); - break; - case A_MOBS: - load_mobs_to_map(temp,size); - mglob.local_monsters=1; - break; - case A_MOBSND: - load_sound_dat(temp,size); - break; - case A_MAPVYK: - memcpy(vyklenky,temp,size); - break; - case A_PASSW: -/* if (passpass<2) - { - memcpy(password,temp,size); - encrypt(password); - passpass=2; - }*/ - break; - } - else - { - if (temp!=NULL)free(temp); - fclose(f); - return -1; - } - free(temp); - } - while (nmapend); - fclose(f); - for(r=1;r0 && names[cn-1]==NULL) cn--; - while (jmsg==E_INIT) return ; - if (msg->msg==E_DONE) return ; - if (msg->msg==E_MOUSE) - { - MS_EVENT *ms; - - ms=get_mouse(msg); - if (ms->tl1) - { - send_message(E_STATUS_LINE,E_DONE,E_IDLE,backup_info); - send_message(E_DONE,E_MOUSE,backup_info); - return; - } - return; - } - c=(char *)msg->data; - strcpy(c,"Starďż˝ soubor byl uloďż˝en v adres��i backup\\..."); - c=strchr(c,'\0'); - msg->data=(void *)c; - msg->msg=-1; - return; - } - - -void create_backup(char *old_filename) - { - char *c; - FILE *fl; - void *d; - long siz; - - mkdir(BACKUP_ADR); - c=alloca(strlen(BACKUP_ADR)+1+strlen(old_filename)+1); - sprintf(c,"%s\\%s",BACKUP_ADR,old_filename); - fl=fopen(old_filename,"rb");if (fl==NULL) return; - fseek(fl,0,SEEK_END);siz=ftell(fl); - fseek(fl,0,SEEK_SET); - d=getmem(siz); - fread(d,1,siz,fl); - fclose(fl); - fl=fopen(c,"wb"); - if (fl!=NULL) - { - fwrite(d,1,siz,fl); - fclose(fl); - send_message(E_STATUS_LINE,E_ADD,E_IDLE,backup_info); - send_message(E_ADD,E_MOUSE,backup_info); - } - free(d); - } - - - - -int save_map(char *filename) - { - long bytesize; - FILE *f; - char nerr=1;char *pr; - int i,j; - TSTR_LIST names=NULL; - void *temp; - char enpass[58]; - - f=fopen(filename,"wb"); - if (f==NULL) return -1; - - for (i=1;iflags & 0x40000) - if ((minfo[i].x+minfo[i].y+j)& 1) - w->prim+=(w->prim_anim & 0xf)+1; - } - - bytesize=sizeof(mglob); - encrypt2(password,mglob.mappassw,sizeof(mglob.mappassw)); - if (nerr) - nerr&=(bytesize==save_section(f,&mglob,A_MAPGLOB,bytesize)); - - bytesize=maplen*sizeof(TSTENA)*4; - if (nerr) - nerr&=(bytesize==save_section(f,&mapa.sidedef,A_SIDEMAP,bytesize)); - - bytesize=maplen*sizeof(TSECTOR); - if (nerr) - nerr&=(bytesize==save_section(f,&mapa.sectordef,A_SECTMAP,bytesize)); - - if (password[0]) Shift_map_sectors_up(); - bytesize=maplen*sizeof(TMAP_EDIT_INFO); - if (nerr) - nerr&=(bytesize==save_section(f,&minfo,A_MAPINFO,bytesize)); - if (password[0]) Shift_map_sectors_down(); - pr=pripona(filename,SCR); - for (i=1;i<8;i++) - { - - switch (i) - { - case 1: - case 2: - case 3:read_side_script_one(pr,NSID,&names,i,4);break; - case 4:read_side_script_one(pr,NCEI,&names,1,2);break; - case 5:read_side_script_one(pr,NFLR,&names,1,2);break; - case 6:read_side_script_one(pr,NOBL,&names,1,3);break; - case 7:read_side_script_one(pr,NOBL,&names,2,3);break; - } - if (nerr) - nerr&=save_scr_list(f,names,i==7?A_STRTAB7:A_STRTAB1+i-1); - } - - strcpy(enpass,"Heslo \x8 je heslo"); - bytesize=strlen(enpass)+1; - if (nerr && bytesize>1) - { - encrypt(enpass); - memcpy(enpass+bytesize,"\0\x13\x80",12);bytesize+=24; - nerr&=(bytesize==save_section(f,enpass,A_PASSW,bytesize)); - } - temp=save_macros(&bytesize); - if (temp!=NULL) - { - if (nerr) - nerr&=(bytesize==save_section(f,temp,A_MAPMACR,bytesize)); - free(temp); - } - - if (nerr) - nerr&=save_item_map(f,A_MAPITEM); - - if (mglob.local_monsters) - { - temp=save_mobs_to_map(&bytesize); - if (nerr && temp!=NULL) - nerr&=(bytesize==save_section(f,temp,A_MOBS,bytesize)); - free(temp); - nerr&=save_sound_dat(f,A_MOBSND); - } - - temp=save_mob_map(&bytesize); - if (temp!=NULL) - { - if (nerr) - nerr&=(bytesize==save_section(f,temp,A_MAPMOBS,bytesize)); - free(temp); - } - for(i=255;i>1;i--) if (vyklenky[i].sector!=0) break; - bytesize=sizeof(TVYKLENEK)*(i+1); - if (nerr) - nerr&=(bytesize==save_section(f,vyklenky,A_MAPVYK,bytesize)); - strcpy(enpass,"To bys \x8 chtel vedet co? \x8 "); - bytesize=strlen(enpass)+1; - if (nerr && bytesize>1) - { - encrypt(enpass); - memcpy(enpass+bytesize,"\0\x13\x80",12);bytesize+=12; - nerr&=(bytesize==save_section(f,enpass,A_PASSW,bytesize)); - } - bytesize=sizeof(bytesize); - if (nerr) - nerr&=(bytesize==save_section(f,&bytesize,A_MAPEND,bytesize)); - strcpy(enpass,"Ty si \x8 ale nedas pokoj! \x8"); - bytesize=strlen(enpass)+1; - if (nerr && bytesize>1) - { - encrypt(enpass); - memcpy(enpass+bytesize,"\0\x13\x80",12);bytesize+=12; - nerr&=(bytesize==save_section(f,enpass,A_PASSW,bytesize)); - } - bytesize=sizeof(bytesize); - if (nerr) - nerr&=(bytesize==save_section(f,&bytesize,A_MAPEND,bytesize)); - fclose(f); - if (names!=NULL) release_list(names); - { - int x,y; - for(x=1;xprim_anim&=0xf; - w->sec_anim&=0xf; - if (!s->step_next[j]) - { - w->flags|=0x1e; - w->flags&=~0x080; - } - if (!w->sector_tag) - { - w->action=0; - w->side_tag&=~3; - } - if (w->flags & 0x100) - { - w->prim_anim|=(rand()*(w->prim_anim)/32768)<<4; - } - if (w->prim>=maxp) w->prim=1; -/* if (!(w->flags & 0x80) && w->prim==0) - { - *objnumber=i; - *objsub=j; - return -1; // Wall definition missing - } */ - if (s->step_next[j] && !(mapa.sectordef[s->step_next[j]].sector_type)) - { - *objnumber=i; - *objsub=j; - return -2; // Wall leades to unexisting sector - } -/* if (s->sector_type==3) - if (w->flags & 1) - if (mapa.sidedef[i][(j+1)&3].flags & 1 || mapa.sidedef[i][(j-1)&3].flags & 1 || - (!(mapa.sidedef[i][(j^2)].flags & 1))) - { - *objnumber=i; - *objsub=-1; - return -3; // Stairs wire error. - } */ - if (chka[w->action] && !(mapa.sectordef[w->sector_tag].sector_type)) - { - *objnumber=i; - *objsub=j; - return -4; // Event leades to unexisting sector. - } - } - return 0; - } - -static char set_date_time(char *filename, unsigned long date, unsigned long time) - { - HANDLE h=CreateFile(filename,0,0,NULL,OPEN_EXISTING,0,NULL); - FILETIME WriteTime; - char err=0; - if (h==NULL) return 1; - WriteTime.dwHighDateTime=date; - WriteTime.dwLowDateTime=time; - err=SetFileTime(h,NULL,NULL,&WriteTime)==1; - CloseHandle(h); - return err; - } - -static char get_date_time(char *filename, unsigned long *date, unsigned long *time) - { - HANDLE h=CreateFile(filename,0,0,NULL,OPEN_EXISTING,0,NULL); - FILETIME WriteTime; - char err=0; - if (h==NULL) return 1; - err=GetFileTime(h,NULL,NULL,&WriteTime)!=1; - *date=WriteTime.dwHighDateTime; - *time=WriteTime.dwLowDateTime; - CloseHandle(h); - return err; - } - -void validate_sound_map() - { - unsigned short date,time; - - if (get_date_time(MOB_SOUND,&date,&time)) return; - set_date_time(MOB_FILE,date,time); - set_date_time(ITEM_FILE,date,time); - } - -char check_sound_map() - { - unsigned long date,time; - unsigned long cdate,ctime; - - if (get_date_time(MOB_SOUND,&date,&time)) return 0; - get_date_time(MOB_FILE,&cdate,&ctime); - if (date!=cdate || time!=ctime) return 1; - get_date_time(ITEM_FILE,&cdate,&ctime); - if (date!=cdate || time!=ctime) return 1; - return 0; - } - - -int save_all_map(void) - { - int x,y,z; - char info[160]; - char *txt; - if ((z=check_map(&x,&y))!=0) - { - WINDOW *w; - unselect_map(); - if ((w=find_window(tool_bar))!=NULL) close_window(w); - tool_sel=30; - create_map_win(-1); - open_sector_win(); - jdi_na_sektor(x); - } - sprintf(info,"Chyba %02d na pozici %d:%d",-z,x,y); - switch (z) - { - case -1:msg_box(info,'\01',"Chybďż˝ definice stďż˝ny!","OK",NULL);break; - case -2:msg_box(info,'\01',"Chodba vede do neexistujďż˝cďż˝ho sektoru!","OK",NULL);break; - case -3:msg_box(info,'\01',"Schody jsou ďż˝patnďż˝ spojenďż˝ se sousednďż˝mďż˝ sektory!","OK",NULL);break; - case -4:msg_box(info,'\01',"Udďż˝lost v neexistujďż˝cďż˝m sektoru!","OK",NULL);break; - } - if (!backup) - { - create_backup(filename); - create_backup(SHOP_NAME); - create_backup(ITEMS_DAT); - create_backup(MOB_FILE); - create_backup(MOB_SOUND); - backup=1; - } - if (save_map(filename)) - { - sprintf(info,"Nedok��u uloďż˝it soubor %s.",filename); - msg_box("Chyba I/O",'\01',info,"!Panika!",NULL); - } - else txt=pripona(filename,TXT); - save_items(); - if (_access(txt,0)!=0) - { - FILE *f; - - f=fopen(txt,"w"); - if (f) { - fputs("-1\n",f); - fclose(f); - } - } - if (!mglob.local_monsters) - { - save_mobs(); - save_sound_map(); - } - save_all_shops(); - validate_sound_map(); - return z; - } - -char *set_password(char *text) - { - if (text!=NULL) - { - strncpy(password,text,sizeof(password)); - password[sizeof(password)-1]=0; - } - return password; - } - -char check_password(char *text) - { - if (password[0]==0) return 1; - if (text==NULL) return 0; - return !strcmp(text,password); - } - - diff --git a/MAPS/SAVE_MAP.H b/MAPS/SAVE_MAP.H deleted file mode 100644 index 313bd45..0000000 --- a/MAPS/SAVE_MAP.H +++ /dev/null @@ -1,14 +0,0 @@ -extern char filename[MAX_PATH]; - -int load_map(char *filename); -int save_map(char *filename); -int save_all_map(void); - -long save_section(FILE *f,void *section, int sct_type,long sect_size); -long load_section(FILE *f,void **section, int *sct_type,long *sect_size); -int save_scr_list(FILE *f,TSTR_LIST names,int scr_id); -char check_sound_map(); -char *set_password(char *text); -char check_password(char *text); -void encrypt(char *password); - diff --git a/MAPS/STENY.C b/MAPS/STENY.C deleted file mode 100644 index 429cefe..0000000 --- a/MAPS/STENY.C +++ /dev/null @@ -1,542 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "steny.h" -#include "globals.h" - -#define WLISTX 200 -#define WLISTY 200 - -#define DELETED "*(deleted)" -#define EMPTY "EMPTY.PCX" -#define ANIM "*frame" - -TSTR_LIST side_names=NULL; -TSTR_LIST floors=NULL; -TSTR_LIST ceils=NULL; -TSTR_LIST oblouky=NULL; -TSTR_LIST dlg_names=NULL; -TSTR_LIST weapons=NULL; -TSTR_LIST weapons_pos=NULL; - -int *dlg_pgfs=NULL; - -void read_side_list(char *filename,TSTR_LIST *outpt,int relative,int structlen) - { - char i,j; - FILE *f; - char s[200]; - - - if (*outpt!=NULL) release_list(*outpt); - *outpt=create_list(1); - str_replace(outpt,0,""); - f=fopen(filename,"r"); - if (f==NULL) return; - i=1;j=0; - while (relative) - { - fscanf(f,"%s",&s);relative--; - } - do - { - if (fscanf(f,"%s",&s)==1 && (!j)) str_replace(outpt,i++,s); - j++; - if (j==structlen) j=0; - } - while (!feof(f)); - fclose(f); - str_delfreelines(outpt); - j=str_count(*outpt); - for(i=0;iuserptr=(void *)getmem(16); - memcpy(o->userptr,strtable,4); - } - - -void read_dlg_list(char *filename,TSTR_LIST *outpt,int **nums) - { - FILE *f; - char s[200]; - int i,j,k; - - f=fopen(filename,"r"); - i=0; - if (*outpt!=NULL) release_list(*outpt); - *outpt=create_list(1); - str_replace(outpt,0," "); - if (f==NULL) return; - do - { - if (fgets(s,199,f)==NULL) break; - str_replace(outpt,i++,s); - } - while (!feof(f)); - fclose(f); - if (*nums!=NULL) free(*nums); - k=str_count(*outpt); - *nums=(int *)getmem(sizeof(int)*k); - for(j=0;jdata; - t=(t_side_names **)o->userptr; - table=*t; - bar(x1,y1,x2,y2); - for (i=0;i<*d;i++) - if (!strcmp((*table)[i],"\\")) return; - i=*d; - while (y1+text_height((*table)[i])o->xs) - { - char *t; - - t=strchr(s,'\0'); - *(--t)='\0'; - } - position(x1,y1); - outtext(s); - y1+=text_height(*table); - i++; - } - } -void strlist_event(EVENT_MSG *msg,OBJREC *o) - { - t_side_names *table,**t; - int *d,i; - - d=(int *)o->data; - t=(t_side_names **)o->userptr; - table=*t; - if (msg->msg==E_MOUSE) - { - MS_EVENT *ms; - - ms=get_mouse(msg); - if (ms->event_type & 4) - { - int y1=0; - - i=*d; - while (y1+text_height((*table)[i])<(ms->y-o->locy)) - { - if (!strcmp((*table)[i],"\\")) return; - y1+=text_height(*table); - i++; - } - *d=i; - terminate_gui(); - } - } - if (msg->msg==E_CONTROL) - { - memcpy(o->userptr,msg->data,4); - redraw_object(o); - } - } - - -void strlist(OBJREC *o) - { - o->call_init=strlist_init; - o->call_draw=strlist_draw; - o->call_event=strlist_event; - o->datasize=4; - - } - -void strlist_scroll() - { - c_set_value(0,10,f_get_value(0,20)); - } - -int strlist_count(char *s) - { - int i; - - i=0; - while (strcmp(s,"\\")) i++,s+=T_LIST_SIZE; - return i; - } - -TSTR_LIST build_static_list(char *c) - { - TSTR_LIST e; - int i=0; - - e=create_list(10); - while (c[0]!='\\') - { - str_replace(&e,i,c); - c=strchr(c,0); - c++;i++; - } - str_delfreelines(&e); - return e; - } - - -int string_list(char *c,int akt) - { - int oldid; - int x1,y1; - CTL3D *ctl; - FC_TABLE cl; - int vysl; - - cl[0]=0;cl[1]=0x610; - ctl=def_border(3,WINCOLOR); - oldid=o_aktual->id; - x1=o_aktual->locx; - y1=o_aktual->locy+o_aktual->ys; - if (y1+WLISTY>desktop_y_size) y1=desktop_y_size-WLISTY; - if (x1+WLISTX+4>SCR_WIDTH_X) x1=SCR_WIDTH_X-WLISTX-4; - def_window(WLISTX,WLISTY,"Vyber"); - waktual->x=x1; - waktual->y=y1; - on_control_change(terminate_gui); - set_window_modal(); - define(19,5,20,WLISTX-30,WLISTY-20,0,listbox,c,RGB555(31,31,31),0);c_default(akt); - on_control_change(terminate_gui); - define(20,3,42,17,WLISTY-64,1,scroll_bar_v,0,1,18,SCROLLBARCOL); - property(ctl,NULL,NULL,WINCOLOR);c_default(0); - define(21,1,20,21,17,1,scroll_button,-1,0,"\x1e"); - property(NULL,icones,&cl,WINCOLOR);on_control_change(scroll_support); - define(22,1,1,21,17,2,scroll_button,1,1,"\x1f"); - property(NULL,icones,&cl,WINCOLOR);on_control_change(scroll_support); - redraw_window(); - send_message(E_GUI,19,E_CONTROL,2); - redraw_window(); - goto_control(19); - escape(); - if (o_aktual->id==19) vysl=f_get_value(0,19); else vysl=-1; - close_window(waktual); - return vysl; - } - -char find_nick(FILE *f,char *nick) - { - char rn[5]; - int i; - - do - { - i=fscanf(f,"%3s",rn); - if (i==EOF) return 1; - while (i!=EOF && i!='{') i=fgetc(f); - if (!strcmp(rn,nick)) return 0; - do - { - while (i!=EOF && i>=' ') i=fgetc(f); - while (i!=EOF && i<=' ') i=fgetc(f); - } - while (i!=EOF && i!='}'); - } - while (i!=EOF); - return 1; - } - -void read_side_script_one(char *filename,char *nick,TSTR_LIST *outpt,int relative,int structlen) - { - char i,j; - FILE *f; - char s[200],end=0; - - if (*outpt!=NULL) release_list(*outpt); - *outpt=create_list(1); - str_replace(outpt,0,""); - f=fopen(filename,"r"); - if (f==NULL) return; - if (find_nick(f,nick)) - { - fclose(f); - return; - } - i=1;j=0; - while (relative && !end) - { - fscanf(f,"%s",s);relative--; - if (s[0]=='}') end=1; - } - if (!end) - do - { - if (fscanf(f,"%s",s)==1 && (!j) && s[0]!='}') str_replace(outpt,i++,s); - if (s[0]=='}') end=1; - j++; - if (j==structlen) j=0; - } - while (!feof(f) && !end); - fclose(f); - str_delfreelines(outpt); - j=str_count(*outpt); - for(i=0;i=count) i=0,j++; - } - while(1); - } - - -void load_side_script(char *filename) - { - FILE *f; - int i; - - if (sid[0]!=NULL) for(i=0;i<4;i++) release_list(sid[i]); - if (flr[0]!=NULL) for(i=0;i<2;i++) release_list(flr[i]); - if (cei[0]!=NULL) for(i=0;i<2;i++) release_list(cei[i]); - if (obl[0]!=NULL) for(i=0;i<3;i++) release_list(obl[i]); - f=script_name==NULL?NULL:fopen(filename,"r"); - if (f!=NULL) - { - fseek(f,0,SEEK_SET);if (!find_nick(f,NSID)) scan_section_script(f,4,sid); - fseek(f,0,SEEK_SET);if (!find_nick(f,NFLR)) scan_section_script(f,2,flr); - fseek(f,0,SEEK_SET);if (!find_nick(f,NCEI)) scan_section_script(f,2,cei); - fseek(f,0,SEEK_SET);if (!find_nick(f,NOBL)) scan_section_script(f,3,obl); - fclose(f); - } - } - -static int add_to_script(TSTR_LIST *ls,char *name,int frames,int count,int max) - { - int cnt; - int i,a,f,j; - char *c,*d; - - if (ls[0]==NULL) - { - for(i=0;i=cnt || ls[0][i]==NULL || !strcmp(ls[0][i],DELETED)) a++,f=i; - else a=0; - i++; - } - } - if (f+frames>max) return -1; - c=alloca(strlen(name)+20); - if (frames>1) sprintf(c,"%s(%d)",name,frames);else strcpy(c,name); - for (d=c;*d;d++) if (*d<=' ') *d='_'; - str_replace(ls,f,c);for(i=1;i=str_count(ls) || ls[side]==NULL || strcmp(ls[side],ANIM)) return 0; - return 1; - } - -static int delete_side_st(TSTR_LIST *ls,int pos,int count) - { - int cnt,i; - - if (ls[0]==NULL) return -1; - cnt=str_count(ls[0]); - do - { - for(i=0;i0 && (ls[0][cnt-1]==NULL || !strcmp(ls[0][cnt-1],DELETED))) - { - cnt--; - str_replace(ls,cnt,NULL); - } - return 0; - } - -int delete_side(int list,int pos) - { - switch (list) - { - case 0: return delete_side_st(sid,pos,4);break; - case 1: return delete_side_st(flr,pos,2);break; - case 2: return delete_side_st(cei,pos,2);break; - case 3: return delete_side_st(obl,pos,3);break; - default: return -1; - } - } - -int add_side(int list,char *name,int frames) - { - switch (list) - { - case 0: return add_to_script(sid,name,frames,4,256);break; - case 1: return add_to_script(flr,name,frames,2,256);break; - case 2: return add_to_script(cei,name,frames,2,256);break; - case 3: return add_to_script(obl,name,frames,3,16);break; - default: return -1; - } - } - -char *get_side_name(int list,int pos,int field) - { - char **res=NULL; - switch (list) - { - case 0: res=sid[field];break; - case 1: res=flr[field];break; - case 2: res=cei[field];break; - case 3: res=obl[field];break; - default: return NULL; - } - if (res==NULL) return NULL; - return res[pos]; - } - - - -void save_section_script(FILE *f,TSTR_LIST *ls,int count) - { - int i,j,cnt; - - cnt=str_count(ls[0]); - for (j=0;j -#include -#include -#include "..\types.h" -#include "..\memman.h" -#include "..\devices.h" -#include "..\event.h" -#include "..\bmouse.h" -#include "..\bgraph.h" -#include "..\gui.h" -#include "..\basicobj.h" -#define WINCOLOR RGB555(24,24,24) -#define LABELCOLOR RGB555(0,0,15) -word *icones; -word icone_color[7]={0x2108,0x7fff,0x000f,0x4210,0x6f7b}; - -void close_test() - { - close_window(waktual); - } - -void logo(void) - { - CTL3D ctl; - word *p; - - ctl.light=0x7fff; - ctl.shadow=0x4210; - ctl.bsize=2; - ctl.ctldef=0; - draw_border(120,90,0x18f,0x6a,&ctl); - p=(word *)load_file("..\\konvert\\mapedit.hi"); - put_picture(120,90,p); - free(p); - showview(0,0,0,0); - } - -void *wait_ms_key(EVENT_MSG *msg) - { - MS_EVENT *ms; - if (msg->msg==E_INIT) return &wait_ms_key; - if (msg->msg==E_MOUSE) - { - ms=get_mouse(msg); - if (ms->event_type & 4) terminate(); - } - return NULL; - } - - -void wait_mouse(void) - { - send_message(E_ADD,E_MOUSE,wait_ms_key); - escape(); - send_message(E_DONE,E_MOUSE,wait_ms_key); - } - - -void init(void) - { - default_font=load_file("d:\\tp\\vga\\boldcz.fon"); - icones=load_file("d:\\tp\\vga\\ikones.fon"); - if (initmode32()) - { - word *p; - - p=load_file("..\\xlat256.pal"); - if (initmode256(p)) - initmode_lo(p); - } - curcolor=0x6318;memcpy(charcolors,flat_color(0x0000),sizeof(charcolors)); - init_events(100); - curfont=default_font; - register_ms_cursor(load_file("..\\konvert\\sipka.HI")); - init_mysky(); - send_message(E_ADD,E_STATUS_LINE,status_line,16); - send_message(E_STATUS_LINE,E_ADD,E_IDLE,show_time); - send_message(E_STATUS_LINE,E_ADD,E_IDLE,status_mem_info); - send_message(E_STATUS_LINE,E_ADD,E_IDLE,mouse_xy); - ukaz_mysku(); - redraw_desktop();logo();wait_mouse(); - install_gui(); - } -/* - w=create_window(100,100,400,200,0x6318,&x); - id=desktop_add_window(w); - define(10,20,50,30,0,sample,"Test"); - property(&x,NULL,flat_color(0x7000),0xffff); - define(10,20,70,30,3,button,"Tlacitko"); - property(NULL,NULL,flat_color(0x000f),0x01c0);on_change(close_test); - w=create_window(5,5,200,200,0x6318,&x); - id=desktop_add_window(w); - define(50,50,70,30,3,button,"Tlacitko"); - property(NULL,NULL,flat_color(0x7fff),0x000f);on_change(close_test); - w=create_window(300,150,300,200,0x6318,&x); - id=desktop_add_window(w); - define(50,50,70,30,3,button,"Tlacitko"); - property(NULL,NULL,flat_color(0x7fff),0x000f);on_change(close_test); - */ - -void def_window(word xs,word ys,char *name) - { - word x=0,y=0; - WINDOW *p; - CTL3D ctl; - - if (waktual!=NULL) - { - x=waktual->x; - y=waktual->y; - } - - highlight(&ctl,WINCOLOR); - ctl.bsize=2;ctl.ctldef=0; - x+=20;y+=20; - if (x+xs>MAX_X-2) x=MAX_X-2-xs; - if (y+ys>MAX_Y-2) y=MAX_Y-2-ys; - p=create_window(x,y,xs,ys,WINCOLOR,&ctl); - desktop_add_window(p); - define(0,2,2,xs-25,14,0,win_label,name); - ctl.bsize=1;ctl.ctldef=1; - property(&ctl,default_font,flat_color(0x7fe0),LABELCOLOR); - define(1,xs-20,1,19,16,0,button,"\x1f"); - property(NULL,icones,&icone_color,WINCOLOR);on_change(close_test); - - } - -void Simple_window(void); - -void open_next(void) - { - def_window(300,200,"Dal¨ˇ okno"); - Simple_window(); - redraw_window(); - } - -void Simple_window(void) - { - CTL3D ctl; - highlight(&ctl,WINCOLOR); - ctl.bsize=2;ctl.ctldef=0; - - define(10,30,30,80,20,0,button,"Nov‚ okno"); - property(NULL,default_font,flat_color(0000),WINCOLOR); - on_change(open_next); - define(20,120,30,80,20,0,button,"Konec"); - property(NULL,default_font,flat_color(0000),WINCOLOR); - on_change(terminate); - define(30,60,60,90,12,0,check_box,"Check box"); - property(NULL,default_font,flat_color(0),WINCOLOR);c_default(0); - define(40,60,80,4*15,4*15,0,radio_butts,4,"Test 1","Test 2","Test 3","Test 4"); - property(NULL,default_font,flat_color(0),WINCOLOR);c_default(1); - define(50,170,80,80,20,0,toggle_button,"Toggle");c_default(1); - property(NULL,default_font,flat_color(0),WINCOLOR); - define(60,20,25,180,10,3,input_line,255); - property(&ctl,default_font,flat_color(0),WINCOLOR);set_default("Vstupnˇ linka"); - - - } - - -void main() - { - init(); - def_window(300,200,"Prvnˇ okno"); - Simple_window(); - redraw_desktop(); - escape(); -// deinstall_mouse_handler(); - closemode(); - } - - - - diff --git a/MAPS/WIZ_TOOL.C b/MAPS/WIZ_TOOL.C deleted file mode 100644 index d3b0646..0000000 --- a/MAPS/WIZ_TOOL.C +++ /dev/null @@ -1,3010 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mapy.h" -#include -#include -#include "globals.h" -#include "edit_map.h" -#include "steny.h" -#include "mob_edit.h" -#include "save_map.h" - -long wiz_tool_numb=-1; -MAPGLOBAL mglob={"","","","",0,0,0,1}; - -PTRMAP *smplist=NULL; - -TMULTI_ACTION **multi_actions[MAPSIZE*4]; -int multiaction_win=-1; -void open_multiaction_window(); -static TSTR_LIST mul_list=NULL; - -void create_isort_list(); - - -int action_sizes[MAX_ACTIONS]= - {sizeof(TMA_GEN),sizeof(TMA_SOUND),sizeof(TMA_TEXT),sizeof(TMA_TEXT), - sizeof(TMA_SEND_ACTION),sizeof(TMA_FIREBALL),sizeof(TMA_GEN),sizeof(TMA_LOADLEV), - sizeof(TMA_DROPITM),sizeof(TMA_TEXT),sizeof(TMA_TEXT),sizeof(TMA_CODELOCK), - sizeof(TMA_CACTN),sizeof(TMA_LOCK),sizeof(TMA_SWAPSC),sizeof(TMA_WOUND), - sizeof(TMA_TWOP),sizeof(TMA_TWOP),sizeof(TMA_TWOP),sizeof(TMA_TEXT),sizeof(TMA_TWOP), - sizeof(TMA_TWOP),sizeof(TMA_TWOP),sizeof(TMA_LOADLEV),sizeof(TMA_DROPITM), - sizeof(TMA_TWOP),sizeof(TMA_TWOP),sizeof(TMA_UNIQ),sizeof(TMA_TWOP),sizeof(TMA_UNIQ), - sizeof(TMA_TWOP),sizeof(TMA_LOADLEV),sizeof(TMA_TWOP),sizeof(TMA_LOADLEV), - sizeof(TMA_TWOP),sizeof(TMA_TWOP),sizeof(TMA_TEXT),sizeof(TMA_GLOBE),sizeof(TMA_IFSEC),sizeof(TMA_TWOP)}; - -void close_wiz_tool(void) - { - WINDOW *p; - p=find_window(wiz_tool_numb); - if (p!=NULL) close_window(p); - } - -int count_of_sel(void) - { - int i=0,j=1; - - for(;jflags &=~(0x40F1F | SD_LEFT_ARC | SD_RIGHT_ARC); - sd2->flags &=~(0x40F1F | SD_LEFT_ARC | SD_RIGHT_ARC); - sd1->lclip=lclip; - sd2->lclip=lclip; - if (swp) - { - sd1->flags|=flags2 | 0x800; - sd2->flags|=flags2 | 0x800; - if (anim1!=0) - { - sd1->flags|=0x0200; - sd2->flags|=0x0200; - } - } - else - { - sd1->flags|=flags1; - sd2->flags|=flags1; - sd1->flags|=0x0200; - sd2->flags|=0x0200; - } - sd1->prim=side1;sd2->prim=side2; - sd1->prim_anim=anim1;sd2->prim_anim=anim2; - if (!remote) - { - sd1->flags&=~0xfff00000; - sd1->flags|=((flags1^flags2)<<24)| 0x00400000; - sd1->action=1+mode+4*(anim1==0); - sd1->sector_tag=sector1; - sd1->side_tag=dir; - sd2->flags&=~0xfff00000; - sd2->flags|=((flags1^flags2)<<24)| 0x00400000; - sd2->action=1+mode+4*(anim1==0); - sd2->sector_tag=sector1; - sd2->side_tag=dir; - } - } - else - { - word *w,i,k,d; - TSTENA *sd; - - w=mapa.sectordef[sector1].step_next; - if (!w[0] && !w[1] && !w[2] && !w[3]) - { - msg_box("Nejsou ��dnďż˝ vďż˝chody:",'\x1',"Zde nelze vytvoďż˝it tento druh stďż˝ny","Ok",NULL); - return; - } - d=65535; - for(i=0;i<4;i++) - if (w[i]) - { - sd=&mapa.sidedef[sector1][i]; - sd->flags&=~0xFFF00f1f; - if (d!=65535) sd->flags|=0x00100000; - sd->flags|=flags1|(((flags1^flags2)<<24))|0x00400800; - sd->prim=side1; - sd->action=0; - if (d!=65535) - { - sd->side_tag=d; - sd->sector_tag=sector1; - } - d=i; - } - for(k=0;k<4;k++) - if (w[k]) - { - sd=&mapa.sidedef[w[k]][(k+2)&3]; - sd->flags&=~0xFFF00f1f; - sd->flags|=flags1|(((flags1^flags2)<<24)|0x200); - sd->prim=side1; - sd->action=mode+5; - sd->side_tag=d; - sd->sector_tag=sector1; - } - } - terminate_gui(); - } - -void create_door(void) - { - int i; - CTL3D b1,b2,b3; - if (count_of_sel()!=1) - { - msg_box("Door Wizard:",'\x1',"Mus�� oznaďż˝it pouze jeden sektor!","Ok",NULL); - return; - } - for (i=0;iid==30) - { - int obl,i,j; - - obl=f_get_value(0,10); - v_rozich=f_get_value(0,20); - for(i=1;i>");on_control_change(zabezpecit); - define(100,10,10,200,11,3,input_line,29);set_default(mglob.mapname); - property(&b3,NULL,NULL,WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - char c; - for(i=0;i<4;i++) - get_value(0,i*10+10,mglob.back_fnames[i]); - mglob.fade_r=vals(50); - mglob.fade_g=vals(60); - mglob.fade_b=vals(70); - mglob.start_sector=vals(80); - mglob.direction=f_get_value(0,90); - mglob.map_effector=f_get_value(0,95); - c=mglob.local_monsters; - mglob.local_monsters=f_get_value(0,96); - mglob.map_autofadefc=f_get_value(0,97); - if (c!=mglob.local_monsters && c==1) - { - load_mobs(); - load_sound_map(); - } - get_value(0,100,mglob.mapname); - mglob.map_effector=f_get_value(0,95); - } - close_window(waktual); - } - -void set_side_flag(int sector,int side,int what,int set) - { - int value=1; - - value<<=what; - if (set) mapa.sidedef[sector][side].flags|=value; - else mapa.sidedef[sector][side].flags&=~value; - } - -void set_side_flags(int sector,int side,int on_flags,int off_flags,int depth) - { - if (on_flags & 1) set_side_flag(sector,side,7,1); - if (on_flags & 2) set_side_flag(sector,side,18,1); - if (on_flags & 4) set_side_flag(sector,side,29,1); - if (on_flags & 8) set_side_flag(sector,side,9,1); - if (on_flags & 0x10) set_side_flag(sector,side,8,1); - if (off_flags & 1) set_side_flag(sector,side,7,0); - if (off_flags & 2) set_side_flag(sector,side,18,0); - if (off_flags & 4) set_side_flag(sector,side,29,0); - if (off_flags & 8) set_side_flag(sector,side,9,0); - if (off_flags & 0x10) set_side_flag(sector,side,8,0); - if (on_flags & 0x20) - { - mapa.sidedef[sector][side].oblouk&=0x1f; - mapa.sidedef[sector][side].oblouk|=depth<<5; - } - } - -void set_flags_inside(int on_flags,int off_flags,int depth,int where) - { - int x1=+30000,y1=+30000,x2=-30000,y2=-30000; - int i; - - for(i=0;ix2) x2=minfo[i].x; - if (minfo[i].y>y2) y2=minfo[i].y; - } - for(i=0;ix2) x2=minfo[i].x; - if (minfo[i].y>y2) y2=minfo[i].y; - } - for(i=0;i0) - { - txtp2=target; - if (!(txtp2=mapa.sectordef[target].step_next[dir1])) - if ((txtp2=add_sector(x+smery[dir1][0],y+smery[dir1][1],tlayer,0))<1) error="Nenďż˝ mďż˝sto pro sektor!"; - else wire_sector(txtp2); - wire_sector(target); - mapa.sectordef[sect].sector_tag=txtp2; - mapa.sectordef[sect].sector_type=2; - mapa.sectordef[target].sector_tag=txtp1; - mapa.sectordef[target].sector_type=2; - } - else error="Nenďż˝ mďż˝sto pro sektor!"; - } - else error="V cďż˝lovďż˝m patďż˝e nenďż˝ mďż˝sto pro sektor"; - } - else error="Z toho sektoru nelze tďż˝mto smďż˝rem vytvoďż˝it schody"; - else - if ((txtp1=mapa.sectordef[sect].step_next[dir2])) - if ((txtp2=mapa.sectordef[target].step_next[dir1])) - { - mapa.sectordef[sect].sector_tag=txtp2; - mapa.sectordef[sect].sector_type=2; - mapa.sectordef[target].sector_tag=txtp1; - mapa.sectordef[target].sector_type=2; - } - else error="Cilovďż˝ sektor mďż˝ chybnďż˝ orientovanďż˝ vďż˝chody"; - else error="Nelze vytvoďż˝it schody poďż˝adovanďż˝m smďż˝rem"; - if (error!=NULL) - { - msg_box("Stairs Wizard:",'\x1',error,"Ok",NULL); - return; - } - if (!mode) - { - int i; - for(i=0;i<4;i++) - { - mapa.sidedef[sect][i].flags=(i==dir2?SD_INVIS:0); - mapa.sidedef[target][i].flags=(i==dir1?SD_INVIS:0); - } - mapa.sectordef[sect].floor=0; - mapa.sectordef[sect].ceil=0; - } - mapa.sidedef[txtp1][dir1].prim=prim1; - mapa.sidedef[txtp2][dir2].prim=prim2; - mapa.sidedef[txtp1][dir1].prim_anim=anim1-1; - mapa.sidedef[txtp2][dir2].prim_anim=anim2-1; - mapa.sidedef[txtp1][dir1].flags|=0x280 | SD_INVIS; - mapa.sidedef[txtp2][dir2].flags|=0x280 | SD_INVIS; - mapa.sidedef[txtp1][dir1].flags&=~SD_DOUBLE_SIDE; - mapa.sidedef[txtp2][dir2].flags&=~SD_DOUBLE_SIDE; - if (anim1) mapa.sidedef[txtp1][dir1].flags|=0x100; - if (anim2) mapa.sidedef[txtp2][dir2].flags|=0x100; - terminate_gui(); - } - -static void schody(void) - { - int i; - CTL3D b1,b2,b3; - if (count_of_sel()!=1) - { - msg_box("Stairs Wizard:",'\x1',"Mus�� oznaďż˝it pouze jeden sektor!","Ok",NULL); - return; - } - for (i=0;iid==OK_BUTT) - { - long smer=get_bit_fields(0,400,4); - int prim_side=f_get_value(0,20); - int sec_side=f_get_value(0,30); - long pro_prim=get_bit_fields(0,440,1); - long pro_sec=get_bit_fields(0,450,1); - int i; - for(i=1;iy=2;waktual->x=SCR_WIDTH_X-120-3; - on_control_change(close_wiz_tool); - define(10,10,25,100,19,0,button2,"Dveďż˝e");on_control_change(create_door); - define(10,10,45,100,19,0,button2,"Oblouky");on_control_change(crt_oblouky); - define(10,10,65,100,19,0,button2,"Schody");on_control_change(schody); - define(10,10,85,100,19,0,button2,"Globalnďż˝");on_control_change(preference); - define(10,10,105,100,19,0,button2,"Bloky");on_control_change(open_blok_window); - define(10,10,125,100,19,0,button2,"Multiakce");on_control_change(open_multiaction_window); - define(10,10,145,100,19,0,button2,"Pďż˝edvolba");on_control_change(predvolba); - define(10,10,165,100,19,0,button2,"Vďż˝bďż˝r");on_control_change(vyber); - } - else - { - select_window(wiz_tool_numb); - } - redraw_window(); - select_window(w->id); - } - -static BOOL WINAPI SetCurrentAppWindow(HWND hWnd, LPARAM lParam) -{ - HWND *hPtr=(HWND *)lParam; - *hPtr=hWnd; - return FALSE; -} - -typedef struct __BrowserDlgDesc -{ - char *path; - char *filename; - int baselen; - int level; -} BrowserDlgDesc; - -#include "../mapedit/resource.h" -#include - -static void DirListbox(const char *mask, HWND listBox, int dots) -{ - WIN32_FIND_DATA w32fnd; - HANDLE h; - - if (strrchr(mask,'\\') == 0) - { - char *dirmask=(char *)alloca(strlen(mask)+5); - strcpy(dirmask,".\\"); - strcat(dirmask,mask); - DirListbox(dirmask,listBox,dots); - return; - } - h=FindFirstFile(mask,&w32fnd); - ComboBox_ResetContent(listBox); - if (h!=INVALID_HANDLE_VALUE) do - { - char *name=w32fnd.cFileName; - if (~w32fnd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - { - int p=ComboBox_AddString(listBox,name); - ComboBox_SetItemData(listBox,p,0); - } - } while (FindNextFile(h,&w32fnd)); - FindClose(h); - { - char *dirmask=(char *)alloca(strlen(mask)+5); - char *c=strrchr(mask,'\\'); - HANDLE h; - if (c==0) c=dirmask;else c++; - strcpy(dirmask,mask); - strcpy(dirmask+(c-mask),"*.*"); - h=FindFirstFile(dirmask,&w32fnd); - if (h!=INVALID_HANDLE_VALUE) do - { - char *name=w32fnd.cFileName; - if (w32fnd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - { - if (strcmp(name,".")) - { - if (dots||strcmp(name,"..")) - { - int p; - name=(char *)alloca(strlen(name)+3); - sprintf(name,"[%s]",w32fnd.cFileName); - p=ComboBox_AddString(listBox,name); - ComboBox_SetItemData(listBox,p,1); - } - } - } - } while (FindNextFile(h,&w32fnd)); - FindClose(h); - } - } - - -LRESULT WINAPI BrowserDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - BrowserDlgDesc *dlgnfo=(BrowserDlgDesc *)GetWindowLong(hDlg,DWL_USER); - switch (msg) - { - case WM_INITDIALOG: - dlgnfo=(BrowserDlgDesc *)lParam; - DirListbox(dlgnfo->path,GetDlgItem(hDlg,IDC_LIST),0); - SetWindowLong(hDlg,DWL_USER,lParam); - dlgnfo->baselen=strrchr(dlgnfo->path,'\\')-dlgnfo->path+1; - dlgnfo->level=0; - { - HWND parent=GetParent(hDlg); - RECT rc1,rc2; - GetWindowRect(parent,&rc1); - GetWindowRect(hDlg,&rc2); - rc2.left=((rc1.right+rc1.left)>>1)-((rc2.right-rc2.left)>>1); - rc2.top=((rc1.top+rc1.bottom)>>1)-((rc2.bottom-rc2.top)>>1); - SetWindowPos(hDlg,0,rc2.left,rc2.top,0,0,SWP_NOZORDER|SWP_NOSIZE); - SetDlgItemText(hDlg,IDC_PATH,dlgnfo->path); - } - break; - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDOK: - { - HWND list=GetDlgItem(hDlg,IDC_LIST); - int len=GetWindowTextLength(list)+1; - char *name=(char *)alloca(len+10); - int sel; - int mode=0; - char *c; - - GetWindowText(list,name,len); - if (name[0]==0) break; - sel=ComboBox_FindStringExact(list,-1,name); - if (sel!=-1) mode=ComboBox_GetItemData(list,sel); - if (mode==0) - { - if (strlen(name)<5 || istrcmp(name+strlen(name)-4,".map")!=0) strcat(name,".map"); - if (strlen(name)>12) - { - MessageBox(hDlg,"Jmeno mapy je prilis dlouhe (max 8 znaku bez pripony nebo 12 znaku s priponou)",0,MB_OK|MB_ICONEXCLAMATION); - break; - } - strcpy(dlgnfo->filename,dlgnfo->path+dlgnfo->baselen); - c=strrchr(dlgnfo->filename,'\\'); - if (strlen(name)+strlen(dlgnfo->filename)>=MAX_PATH) break; - if (c==0) c=dlgnfo->filename;else c++; - strcpy(c,name); - EndDialog(hDlg, IDOK); - } - else - { - strcpy(name,name+1); - name[strlen(name)-1]=0; - if (strcmp(name,"..")==0) - { - char *a=strrchr(dlgnfo->path,'\\'); - char *b; - if (a==0) break; - *a=0; - b=strrchr(dlgnfo->path,'\\'); - if (b==0) b=dlgnfo->path;else b++; - strcpy(b,a+1); - dlgnfo->level--; - } - else - { - char *c=(char *)malloc(strlen(dlgnfo->path)+strlen(name)+5); - char *a; - char *b; - strcpy(c,dlgnfo->path); - a=strrchr(c,'\\'); - if (a == 0) a = c; else a++; - b=a+strlen(name)+1; - memmove(b,a,strlen(a)+1); - a[strlen(name)] = '\\'; - memcpy(a,name,strlen(name)); - dlgnfo->level++; - free(dlgnfo->path); - dlgnfo->path=c; - } - DirListbox(dlgnfo->path,list,dlgnfo->level); - SetDlgItemText(hDlg,IDC_PATH,dlgnfo->path); - } - } - break; - case IDCANCEL: - EndDialog(hDlg,IDCANCEL); - break; - case IDC_LIST: if (HIWORD(wParam)==LBN_DBLCLK) - PostMessage(hDlg,WM_COMMAND,IDOK,0); - break; - default: return 0; - } - } - break; - default: return 0; - } - return 1; -} - -void browser(const char *path, char *filename) -{ - BrowserDlgDesc dlg; - HWND hWnd; - dlg.path=strdup(path); - dlg.filename=filename; - EnumThreadWindows(GetCurrentThreadId(),SetCurrentAppWindow,(LPARAM)&hWnd); - if (DialogBoxParam(GetModuleHandle(0),MAKEINTRESOURCE(IDD_OPENDIALOG),hWnd,BrowserDlgProc,(LPARAM)&dlg)==IDCANCEL) - filename[0]=0; - free(dlg.path); -} -/* -void browser(char *pathname,char *filename) - { - OPENFILENAME ofn; - char *mask=(char *)alloca(strlen(pathname)*2+10); - char *c; - char tempfile[MAX_PATH]; - char *cwd=getcwd(NULL,0); - char *basePath=strcat(strcat(strcpy((char *)alloca(strlen(cwd)+strlen(pathname)+3),cwd),"\\"),pathname); - char *z=strrchr(basePath,'\\'); - z[0]=0; - - c=strrchr(pathname,'\\'); - if (c!=0) c++;else c=pathname; - - ZeroMemory(&ofn,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - sprintf(mask,"%s%c%s%c",c,0,c,0); - - EnumThreadWindows(GetCurrentThreadId(),SetCurrentAppWindow,(LPARAM)&(ofn.hwndOwner)); - ofn.Flags=OFN_PATHMUSTEXIST|OFN_HIDEREADONLY|OFN_NOCHANGEDIR; - ofn.lpstrDefExt=strrchr(pathname,'.')+1; - ofn.lpstrFile=tempfile; - ofn.lpstrFilter=mask; - ofn.nMaxFile=MAX_PATH; - ofn.lpstrInitialDir=basePath; -opakuj: - tempfile[0]=0; - if (GetOpenFileName(&ofn)) - { - - if (strnicmp(basePath,tempfile,strlen(basePath))!=0) - { - msg_box("Browser",'\x1',"Nelze vybirat soubory nad aktualni slozkou.","Ok",NULL); - goto opakuj; - } - strcpy(filename,tempfile+strlen(basePath)+1); - } - else - filename[0]=0; - free(cwd); -} - /* - TSTR_LIST l; - - filename; - l=read_directory(pathname,DIR_BREIF,_A_NORMAL); - if (l==NULL && default_ext) - { - msg_box("Browser",'\x1',"Funkce read_directory() vratila chybu. Adres�� je prďż˝zdnďż˝ nebo je nedostatek pamďż˝ti","Ok",NULL); - return; - } - default_font=vga_font; - memcpy(f_default,flat_color(0x0000),sizeof(charcolors)); - def_window(160,450,"Nalistovat"); - set_window_modal(); - on_change(terminate); - define(9,10,20,120,420,0,listbox,l,RGB555(31,31,0),0);c_default(0); - on_change(terminate); - o_end->autoresizex=1; - o_end->autoresizey=1; - define(10,3,42,21,360,1,scroll_bar_v,0,10,1,SCROLLBARCOL); - property(NULL,NULL,NULL,WINCOLOR); - o_end->autoresizey=1; - define(11,3,20,21,17,1,scroll_button,-1,0,"\x1e"); - property(NULL,icones,NULL,WINCOLOR);on_change(scroll_support); - define(12,3,22,21,17,2,scroll_button,1,10,"\x1f"); - property(NULL,icones,NULL,WINCOLOR);on_change(scroll_support); - define(20,3,1,10,10,2,resizer); - redraw_window(); - escape(); - if (o_aktual->id==9) - { - char *a,*b; - strcpy(filename,l[f_get_value(0,9)]); - a=filename;b=a; - while (*b || b-filename>12) - { - *a=*b++; - if (*a!=32) a++; - } - *a='\0'; - } - - close_window(waktual); - release_list(l); - */ - -void add_ma_flags(int start,int x,int y,TMULTI_ACTION *p) - { - define(-1,x,y,1,1,0,label,"Podmďż˝nky"); - define(start+0,x+25,y+15,140,10,0,check_box,"Cancel program");c_default(p->general.cancel); - define(start+1,x+25,y+27,140,10,0,check_box,"Jedenkrďż˝t");c_default(p->general.once); - define(start+2,x+25,y+39,140,10,0,check_box,"ďż˝sp��nďż˝ prďż˝chod");c_default(p->general.ps); - define(start+3,x+25,y+51,140,10,0,check_box,"Neďż˝sp��nďż˝ prďż˝chod");c_default(p->general.pf); - define(start+4,x+25,y+63,140,10,0,check_box,"ďż˝sp��nďż˝ dotyk");c_default(p->general.ts); - define(start+5,x+25,y+75,140,10,0,check_box,"Neďż˝sp��nďż˝ dotyk");c_default(p->general.tf); - define(start+6,x+25,y+87,140,10,0,check_box,"Informace o zďż˝mku");c_default(p->general.li); - define(start+7,x+25,y+99,140,10,0,check_box,"Pďż˝ed odchodem");c_default(p->general.ul); - define(start+8,x+25,y+111,140,10,0,check_box,"Pďż˝i p��chodu akce");c_default(p->general.ia); - define(start+9,x+25,y+123,140,10,0,check_box,"Pďż˝i startu levelu");c_default(p->general.sp); - define(start+10,x+25,y+135,140,10,0,check_box,"Pďż˝i uzavďż˝enďż˝ dve��");c_default(p->general.as); - define(start+11,x+25,y+147,140,10,0,check_box,"Kaďż˝de anim.pol��ko");c_default(p->general.am); - define(start+12,x+25,y+159,140,10,0,check_box,"Kaďż˝de druhďż˝ a.p.");c_default(p->general.a2); - define(start+13,x+25,y+171,140,10,0,check_box,"Pďż˝i provedenďż˝ akce");c_default(p->general.pa); - define(start+14,x+25,y+183,140,10,0,check_box,"ďż˝sp��nďż˝ SpecProc");c_default(p->general.us); - define(start+15,x+25,y+195,140,10,0,check_box,"Pďż˝i otevďż˝enďż˝ dve��");c_default(p->general.od); - define(start+16,x+25,y+207,140,10,0,check_box,"Udďż˝lost vďż˝klenku");c_default(p->general.vy); - } - -void read_ma_flags(int start,TMULTI_ACTION *p) - { - p->general.cancel=f_get_value(0,start+0); - p->general.once=f_get_value(0,start+1); - p->general.ps=f_get_value(0,start+2); - p->general.pf=f_get_value(0,start+3); - p->general.ts=f_get_value(0,start+4); - p->general.tf=f_get_value(0,start+5); - p->general.li=f_get_value(0,start+6); - p->general.ul=f_get_value(0,start+7); - p->general.ia=f_get_value(0,start+8); - p->general.sp=f_get_value(0,start+9); - p->general.as=f_get_value(0,start+10); - p->general.am=f_get_value(0,start+11); - p->general.a2=f_get_value(0,start+12); - p->general.pa=f_get_value(0,start+13); - p->general.us=f_get_value(0,start+14); - p->general.od=f_get_value(0,start+15); - p->general.vy=f_get_value(0,start+16); - } - - -void *load_wav_sample(char *filename,long *size) - { - FILE *f; - char *c; - void *d; - - concat(c,sample_path,filename); - f=fopen(c,"rb"); - if (f==NULL) - { - return afile(filename,read_group(0),size); - } - fseek(f,0,SEEK_END); - d=malloc(*size=ftell(f)); - fseek(f,0,SEEK_SET); - fread(d,1,*size,f); - fclose(f); - return d; - } - - -void tma_sound_update() - { - int select; - TSTR_LIST ls; - char *riff,*rff,*rff2; - char fmt_buff[256]; - T_WAVE fmt; - long size; - char *c; - - send_message(E_GUI,9,E_CONTROL,0,&ls); - select=f_get_value(0,9); - concat(c,"",ls[select]); - if (c==NULL) return; - name_conv(c); - riff=load_wav_sample(c,&size); - if (riff==NULL) return; - if ((rff=find_chunk(riff,WAV_FMT))!=NULL && (rff2=find_chunk(riff,WAV_DATA))!=NULL) - { - read_chunk(rff,&fmt_buff); - size=get_chunk_size(rff2); - memcpy(&fmt,fmt_buff,sizeof(fmt)); - if (fmt.wav_mode==1 && fmt.chans==1) - { - strcpy(c,ls[select]); - name_conv(c); - set_value(0,20,c); - sprintf(c,"%6d",fmt.freq);set_value(0,30,c); - sprintf(c,"%6d",size);set_value(0,40,c); - sprintf(c,"%6d",size);set_value(0,50,c); - sprintf(c,"%6d",0);set_value(0,60,c); - c_set_value(0,100,fmt.freq!=fmt.bps); - } - else msg_box("Nesprďż˝vnďż˝ WAV",'\x1',"Do hry lze vloďż˝it jen WAV ve formatu PCM mono!","Ok",NULL); - } - else msg_box("Chybnďż˝ soubor WAV",'\x1',"Tento soubor neobsahuje platnďż˝ format pro WAV","Ok",NULL); - free(riff); - } - - - -void play_wav(va_list args) - { - char *filename=va_arg(args,char *); - int ffreq=va_arg(args,int); - char fmt_buff[256]; - T_WAVE fmt; - char *riff,*rff; - static load_another=2; - static char *sample=NULL; - int freq,mode,samplesize; - int startloop,endloop,ofs; - long size; - char argsSave[16]; - memcpy(argsSave,args,16); - - riff=load_wav_sample(filename,&size); - if (riff==NULL) return; - if ((rff=find_chunk(riff,WAV_FMT))==NULL) return; - { - read_chunk(rff,&fmt_buff); - memcpy(&fmt,fmt_buff,sizeof(fmt)); - if (fmt.wav_mode==1 && fmt.chans==1) - { - freq=fmt.freq; - mode=fmt.bps/freq; - if (load_another==2) start_mixing(); - load_another=1; - task_sleep(NULL); - task_sleep(NULL); - load_another=0; - if ((rff=find_chunk(riff,WAV_DATA))!=NULL) - { - samplesize=get_chunk_size(rff); - if (sample!=NULL) free(sample); - sample=(char *)getmem(samplesize); - read_chunk(rff,sample); - { - int *z; - set_channel_volume(0,32767,32767); -/* if (mode==1) - for(i=0;i0) - { - freq=ffreq; - startloop=z[0]; - endloop=z[1]; - ofs=z[2]; - if (endloop>samplesize) - { - msg_box("Pozor",'\x1',"Konec opakovďż˝nďż˝ le�� za koncem souboru!","Ok",NULL); - endloop=samplesize; - } - if (startloop>endloop) - { - msg_box("Pozor",'\x1',"Za��tek opakovďż˝nďż˝ le�� ZA jeho koncem!","Ok",NULL); - startloop=endloop; - } - } - else - { - startloop=samplesize; - endloop=samplesize; - ofs=0; - } - play_sample(0,sample+ofs,endloop-ofs,startloop-ofs,freq,mode); - while (!load_another && get_channel_state(0)) task_sleep(NULL); - mute_channel(0); - } - free(sample);sample=NULL; - } - } - } - free(riff); - if (load_another==0) - { - stop_mixing(); - load_another=2; - } - } - -void tma_sound_preview() - { - char ok; - char au; - int select; - TSTR_LIST ls; - char *c; - - ok=f_get_value(0,290); - au=f_get_value(0,295); - if (au) tma_sound_update(); - if (!ok) return; - send_message(E_GUI,9,E_CONTROL,0,&ls); - select=f_get_value(0,9); - if (ls[select]==NULL) return; - concat(c,"",ls[select]); - name_conv(c); - add_task(16384,play_wav,c,-1); - do_events(); - do_events(); - } - -void tma_sound_autoupdate() - { - char c; - - c=f_get_value(0,295); - set_enable(0,320,!c); - } - -void tma_sound_test() - { - char *c; - char d[15]; - - get_value(0,20,d); - concat(c,"",d); - name_conv(c); - add_task(16384,play_wav,c,vals(30),vals(40),vals(50),vals(60)); - do_events(); - do_events(); - } - -void read_ddl_list_wav(char ***list) - { - TSTR_LIST ddld; - int i,c; - - ddld=read_ddl_dir("WAV"); - if (ddld==NULL) return; - if (*list==NULL) - { - *list=ddld; - return; - } - c=str_count(ddld); - str_add(list,"--- SKELDAL ---"); - for(i=0;isound.freq==0) - { - q->sound.freq=11025; - q->sound.volume=100; - } - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D)); - memcpy(&b3,def_border(6,WINCOLOR),sizeof(CTL3D)); - default_font=vga_font; - memcpy(f_default,flat_color(0x0000),sizeof(charcolors)); - def_dialoge(100,50,350,390,"Editor zvukovďż˝ch efektďż˝"); - concat(c,sample_path,"*.wav"); - list=read_directory(c,DIR_BREIF,_A_NORMAL); - read_ddl_list_wav(&list); - define(9,10,20,200,126,0,listbox,list,RGB555(31,31,31),0); - property(&b3,NULL,NULL,WINCOLOR);c_default(0);on_control_change(tma_sound_preview); - define(10,217,40,19,87,0,scroll_bar_v,0,10,1,SCROLLBARCOL); - property(&b2,NULL,NULL,WINCOLOR); - define(11,216,20,21,17,0,scroll_button,-1,0,"\x1e"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(12,216,130,21,17,0,scroll_button,1,10,"\x1f"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(-1,10,160,100,11,0,label,"Jmďż˝no:"); - define(-1,10,175,100,11,0,label,"freq[Hz]:"); - define(-1,10,190,100,11,0,label,"StartLoop:"); - define(-1,10,205,100,11,0,label,"EndLoop:"); - define(-1,10,220,100,11,0,label,"SmpOffset:"); - define(-1,10,235,100,11,0,label,"Hlasitost:"); - define(-1,10,250,100,11,0,label,"Stopa:"); - define(20,90,160,110,11,0,input_line,12); - property(&b3,NULL,NULL,WINCOLOR);set_default(q->sound.filename); - define(30,90,175,70,11,0,input_line,7,4000,88000,"%6d");on_exit(test_int); - property(&b2,NULL,NULL,WINCOLOR);set_default(strs(q->sound.freq)); - define(40,90,190,70,11,0,input_line,7,0,0x7fffffff,"%6d");on_exit(test_int); - property(&b2,NULL,NULL,WINCOLOR);set_default(strs(q->sound.start_loop)); - define(50,90,205,70,11,0,input_line,7,0,0x7fffffff,"%6d");on_exit(test_int); - property(&b2,NULL,NULL,WINCOLOR);set_default(strs(q->sound.end_loop)); - define(60,90,220,70,11,0,input_line,7,0,0x7fffffff,"%6d");on_exit(test_int); - property(&b2,NULL,NULL,WINCOLOR);set_default(strs(q->sound.offset)); - define(70,90,235,70,11,0,input_line,7,0,100,"%6d");on_exit(test_int); - property(&b2,NULL,NULL,WINCOLOR);set_default(strs(q->sound.volume)); - define(80,90,250,70,11,0,input_line,7,0,100,"%6d");on_exit(test_int); - property(&b2,NULL,NULL,WINCOLOR);set_default(strs(q->sound.soundid)); - define(100,20,265,100,11,0,check_box,"16Bit");c_default(q->sound.bit16 & 1); - define(110,20,277,100,11,0,check_box,"Zakaďż˝ pďż˝i otevďż˝rďż˝nďż˝");c_default((q->sound.bit16 & 2)>>1); - define(120,20,290,100,11,0,check_box,"Zakaďż˝ pďż˝i zavďż˝rďż˝nďż˝");c_default((q->sound.bit16 & 4)>>2); - define(130,20,302,100,11,0,check_box,"Nďż˝hodnďż˝ stereo");c_default((q->sound.bit16 & 8)>>3); - define(290,5,80,100,11,1,check_box,"Preview");c_default(preview); - define(295,5,92,100,11,1,check_box,"AutoUpdate");c_default(autoupdate);on_control_change(tma_sound_autoupdate); - define(300,5,20,100,20,1,button,"Ok");property(&b1,NULL,NULL,WINCOLOR); - on_control_change(terminate_gui); - define(310,5,45,100,20,1,button,"Zrusit");property(&b1,NULL,NULL,WINCOLOR); - on_control_change(terminate_gui); - define(320,5,160,100,20,1,button,"<< Update");property(&b1,NULL,NULL,WINCOLOR); - on_control_change(tma_sound_update); - define(330,5,135,45,20,1,button,"");property(&b1,NULL,NULL,WINCOLOR); - on_control_change(tma_sound_test); - define(340,60,135,45,20,1,button,"");property(&b1,NULL,NULL,WINCOLOR); - on_control_change(tma_sound_stop); - add_ma_flags(400,165,175,q); - redraw_desktop(); - set_enable(0,320,!autoupdate); - escape(); - preview=f_get_value(0,290); - autoupdate=f_get_value(0,295); - if (o_aktual->id==300) - { - char c[15]; - read_ma_flags(400,q); - q->sound.volume=vals(70); - q->sound.start_loop=vals(40); - q->sound.end_loop=vals(50); - q->sound.freq=vals(30); - q->sound.offset=vals(60); - q->sound.soundid=vals(80); - q->sound.bit16=get_bit_fields(0,100,4); - get_value(0,20,c); - strncpy(q->sound.filename,c,12); - } - close_current(); - mute_channel(0); - } - -//----------------------- WIZARD MULTIACTIONS ------------------------- - -TMULTI_ACTION *add_multiaction(int sector,int side,int before, TMULTI_ACTION *typa) - { - TMULTI_ACTION **p; - int type; - - type=typa->general.action; - p=multi_actions[sector*4+side]; - if (p==NULL) - { - p=(TMULTI_ACTION **)getmem(sizeof(TMULTI_ACTION *)); - memset(p,0,_msize(p)); - *p=(TMULTI_ACTION *)getmem(action_sizes[type]); - memset(*p,0,action_sizes[type]); - multi_actions[sector*4+side]=p; - memcpy(*p,typa,action_sizes[type]); - return *p; - } - else - { - TSTR_LIST z; - char *zs; - TMULTI_ACTION *c; - - z=(TSTR_LIST)p; - zs=(char *)getmem(action_sizes[type]); - memset(zs,1,action_sizes[type]); - zs[action_sizes[type]-1]=0; - c=(TMULTI_ACTION *)str_insline(&z,before,zs); - multi_actions[sector*4+side]=(TMULTI_ACTION **)z; - memset(c,0,action_sizes[type]); - memcpy(c,typa,action_sizes[type]); - free(zs); - return c; - } - } - -void delete_multiaction(int sector,int side,int pos) - { - TSTR_LIST p; - - p=(TSTR_LIST)multi_actions[sector*4+side]; - if (p==NULL) return; - str_remove(&p,pos); - str_delfreelines(&p); - if (*p==NULL) - { - release_list(p); - p=NULL; - } - multi_actions[sector*4+side]=(TMULTI_ACTION **)p; - - } - -void prefer_multiaction(int sector,int side,int pos) - { - TSTR_LIST p; - int i; - char *c; - - p=(TSTR_LIST)multi_actions[sector*4+side]; - if (p==NULL) return; - i=pos; - while (i>1) - { - c=p[i]; - p[i]=p[i-1]; - p[i+1]=c; - i--; - } - } - -void create_multiaction_list(TSTR_LIST *list,int sector,int side) - { - TMULTI_ACTION **p; - int count,i,j; - int list_count; - char s[200]; - - p=multi_actions[sector*4+side]; - if (*list==NULL) *list=create_list(10); - list_count=str_count(*list); - for(i=0;igeneral.cancel?'X':'_',p[i]->general.once?'1':'_',act_types[p[i]->general.action],p[i]->sound.flags+p[i]->sound.eflags*256); - str_add(list,s); - } - sprintf(s,""); - str_add(list,s); - str_delfreelines(list); - } - -void init_multiactions() - { - static char again=0; - int i,s,j; - TMULTI_ACTION **p; - - if (again) for(i=0;icall_draw=show_3dbox_draw; - } - -void tma_fireball(TMULTI_ACTION *p) - { - CTL3D *b1; - static int item=1,xpos=-32,ypos=250,zpos=160,speed=16; - char new; - TSTR_LIST ls_sorts=NULL; - - create_isort_list(&ls_sorts,-1); - def_dialoge(220,60,400,300,"Macro: Fireball"); - b1=def_border(5,WINCOLOR); - new=0; - if (p->fireball.item==0) - { - p->fireball.item=item; - p->fireball.xpos=xpos; - p->fireball.ypos=ypos; - p->fireball.zpos=zpos; - p->fireball.speed=speed; - new=1; - } - define(-1,5,20,1,1,0,label,"Vystďż˝elenďż˝ vďż˝c:"); - define(-1,5,35,1,1,0,label,"Xpoz <-63,63>:"); - define(-1,5,50,1,1,0,label,"Ypoz <0,499>:"); - define(-1,5,65,1,1,0,label,"Zpoz <0,319>:"); - define(-1,5,80,1,1,0,label,"Rychlost:<1,128>"); - define(-1,5,100,120,120,1,show_3dbox); - add_ma_flags(100,5,100,p); - define(10,150,20,200,12,0,str_line,ls_sorts);property(b1,NULL,NULL,WINCOLOR); - c_default (p->fireball.item-1);on_enter(string_list_sup); - define(20,150,35,60,12,0,input_line,3,-63,63,"%3d");property(b1,NULL,NULL,WINCOLOR); - set_default(strs(p->fireball.xpos));on_exit(test_int); - define(30,150,50,60,12,0,input_line,3,0,499,"%3d");property(b1,NULL,NULL,WINCOLOR); - set_default(strs(p->fireball.ypos));on_exit(test_int); - define(40,150,65,60,12,0,input_line,3,0,319,"%3d");property(b1,NULL,NULL,WINCOLOR); - set_default(strs(p->fireball.zpos));on_exit(test_int); - define(50,150,80,60,12,0,input_line,3,0,319,"%3d");property(b1,NULL,NULL,WINCOLOR); - set_default(strs(p->fireball.speed));on_exit(test_int); - b1=def_border(1,0); - define(60,10,10,80,20,2,button,"Zruďż˝it");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(70,10,35,80,20,2,button,"Ok");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - redraw_window(); - escape(); - if (o_aktual->id==70) - { - p->fireball.xpos=vals(20); - p->fireball.ypos=vals(30); - p->fireball.zpos=vals(40); - p->fireball.speed=vals(50); - p->fireball.item=f_get_value(0,10)+1; - if (new) - { - xpos=vals(20); - ypos=vals(30); - zpos=vals(40); - speed=vals(50); - item=f_get_value(0,10)+1; - } - read_ma_flags(100,p); - } - close_current(); - release_list(ls_sorts); - } - -void tma_send(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: Send Action"); - define(-1,5,22,1,1,0,label,"Sektor:"); - b1=def_border(5,WINCOLOR); - define(10,80,20,60,12,0,input_line,5,0,maplen,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->send_a.sector)); - define(-1,5,37,1,1,0,label,"Stďż˝na:"); - define(20,80,35,100,12,0,str_line,steny2);on_enter(string_list_sup); - property(b1,NULL,NULL,WINCOLOR);c_default(q->send_a.side); - define(-1,5,52,1,1,0,label,"Akce:"); - define(30,80,50,150,12,0,str_line,actions);on_enter(string_list_sup); - property(b1,NULL,NULL,WINCOLOR);c_default(q->send_a.s_action); - define(-1,5,67,1,1,0,label,"Zpoďż˝dďż˝nďż˝:"); - define(40,80,65,60,12,0,input_line,5,0,255,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->send_a.delay)); - define(110,10,90,200,10,0,check_box,"Zmďż˝na automapingu"); - define(120,10,102,200,10,0,check_box,"Zmďż˝na prďż˝chodnosti(hr��)"); - define(130,10,114,200,10,0,check_box,"Zmďż˝na prďż˝chodnosti(nestvďż˝ra)"); - define(140,10,126,200,10,0,check_box,"Zmďż˝na prďż˝chodnosti(vďż˝c)"); - define(150,10,138,200,10,0,check_box,"Zmďż˝na prďż˝chodnosti(zvuk)"); - add_ma_flags(200,220,20,q); - fill_bit_fields(0,110,q->send_a.change_bits,5); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->send_a.sector=vals(10); - q->send_a.side=f_get_value(0,20); - q->send_a.s_action=f_get_value(0,30); - q->send_a.delay=vals(40); - q->send_a.change_bits=get_bit_fields(0,110,5); - read_ma_flags(200,q); - } - close_current(); - } - -void tma_loadlev(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: Load Level"); - b1=def_border(5,WINCOLOR); - define(-1,5,22,1,1,0,label,"Sektor:"); - define(20,80,20,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->loadlev.start_pos)); - define(-1,5,37,1,1,0,label,"Smďż˝r:"); - define(30,80,35,100,12,0,str_line,steny2);on_enter(string_list_sup); - property(b1,NULL,NULL,WINCOLOR);c_default(q->loadlev.dir); - define(-1,5,52,1,1,0,label,"Jmďż˝no:"); - define(10,80,50,100,12,0,input_line,12);property(b1,NULL,NULL,WINCOLOR);set_default(q->loadlev.name); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->loadlev.start_pos=vals(20); - q->loadlev.dir=f_get_value(0,30); - get_value(0,10,q->loadlev.name); - read_ma_flags(200,q); - } - close_current(); - } - -void tma_play_anim(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: Play animation"); - b1=def_border(5,WINCOLOR); - define(-1,5,20,1,1,0,label,"Jmďż˝no:"); - define(10,80,22,100,12,0,input_line,12);property(b1,NULL,NULL,WINCOLOR);set_default(q->loadlev.name); - define(20,20,40,100,10,0,check_box,"cls");c_default(q->loadlev.dir); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->loadlev.dir=f_get_value(0,20); - get_value(0,10,q->loadlev.name); - read_ma_flags(200,q); - } - close_current(); - } - -void tma_write_book(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - - if (q->loadlev.name[0]==0) strcpy(q->loadlev.name,"KNIHA.TXT"); - def_dialoge(220,60,410,300,"Macro: Write to book"); - b1=def_border(5,WINCOLOR); - define(-1,5,20,1,1,0,label,"Kniha:"); - define(10,80,35,100,12,0,input_line,12);property(b1,NULL,NULL,WINCOLOR);set_default(q->loadlev.name); - define(-1,5,50,1,1,0,label,"��slo odstavce:"); - define(20,80,65,65,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->loadlev.start_pos)); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->loadlev.start_pos=vals(20); - get_value(0,10,q->loadlev.name); - read_ma_flags(200,q); - } - close_current(); - } - - -void tma_swapsectors(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: Swap Sectors"); - b1=def_border(5,WINCOLOR); - define(-1,5,22,1,1,0,label,"Sektor1:"); - define(20,80,20,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->swaps.sector1)); - define(-1,5,37,1,1,0,label,"Sektor2:"); - define(30,80,35,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->swaps.sector2)); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->swaps.sector1=vals(20); - q->swaps.sector2=vals(30); - read_ma_flags(200,q); - } - close_current(); - } - -void tma_experience(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: Send Experience"); - b1=def_border(5,WINCOLOR); - define(-1,5,22,1,1,0,label,"Zkuďż˝enost:"); - define(20,100,20,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->twop.parm1)); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->twop.parm1=vals(20); - read_ma_flags(200,q); - } - close_current(); - } - - - -void tma_cancel_action(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: Cancel Action"); - b1=def_border(5,WINCOLOR); - define(-1,5,22,1,1,0,label,"Sektor:"); - define(20,80,20,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->cactn.sector)); - define(-1,5,37,1,1,0,label,"Smďż˝r:"); - define(30,80,35,100,12,0,str_line,steny2);on_enter(string_list_sup); - property(b1,NULL,NULL,WINCOLOR);c_default(q->cactn.dir); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->cactn.sector=vals(20); - q->cactn.dir=f_get_value(0,30); - read_ma_flags(200,q); - } - close_current(); - } - -void tma_sharema(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: Share Multiaction"); - b1=def_border(5,WINCOLOR); - define(-1,5,22,1,1,0,label,"Sektor:"); - define(20,80,20,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->twop.parm1)); - define(-1,5,37,1,1,0,label,"Smďż˝r:"); - define(30,80,35,100,12,0,str_line,steny2);on_enter(string_list_sup); - property(b1,NULL,NULL,WINCOLOR);c_default(q->twop.parm2); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - define(-1,5,100,10,10,0,label,"Spustďż˝ MA program na jinďż˝m"); - define(-1,5,110,10,10,0,label,"mďż˝stďż˝, tak jako by byl"); - define(-1,5,120,10,10,0,label,"definovďż˝n zde."); - define(-1,5,140,10,10,0,label,"Vyuďż˝itďż˝:"); - define(-1,5,150,10,10,0,label,"Sdďż˝lenďż˝ jednoho program"); - define(-1,5,160,10,10,0,label,"Zmďż˝na v mďż˝stďż˝ sdďż˝leni se pak"); - define(-1,5,170,10,10,0,label,"projevďż˝ na vďż˝ech mďż˝stech, kterďż˝"); - define(-1,5,180,10,10,0,label,"program sdďż˝lejďż˝."); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->twop.parm1=vals(20); - q->twop.parm2=f_get_value(0,30); - read_ma_flags(200,q); - } - close_current(); - } - - -void tma_teleport_group(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: Teleport Group"); - b1=def_border(5,WINCOLOR); - define(-1,5,22,1,1,0,label,"Sektor:"); - define(20,80,20,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->twop.parm1)); - define(-1,5,37,1,1,0,label,"Smďż˝r:"); - define(30,80,35,100,12,0,str_line,steny2);on_enter(string_list_sup); - property(b1,NULL,NULL,WINCOLOR);c_default(q->twop.parm2 & 3); - define(40,80,59,100,10,0,check_box,"Povol efekt");c_default(q->twop.parm2>>7); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->twop.parm1=vals(20); - q->twop.parm2=f_get_value(0,30)+(f_get_value(0,40)<<7); - read_ma_flags(200,q); - } - close_current(); - } - - -void tma_lock(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: Lock"); - b1=def_border(5,WINCOLOR); - define(-1,5,22,1,1,0,label,"��slo kl��e:"); - define(10,120,20,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->lock.key_id)); - define(-1,5,37,1,1,0,label,"Uroveďż˝:"); - define(20,120,35,60,12,0,input_line,5,-1,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->lock.thieflevel)); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->lock.key_id=vals(10); - q->lock.thieflevel=vals(20); - read_ma_flags(200,q); - } - close_current(); - } - -void tma_specproc(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: Call Specproc"); - b1=def_border(5,WINCOLOR); - define(-1,5,22,1,1,0,label,"Jmďż˝no spec:"); - define(10,120,20,95,12,0,str_line,wall_procs);on_enter(string_list_sup); - property(b1,NULL,NULL,WINCOLOR);c_default(q->lock.key_id); - define(-1,5,37,1,1,0,label,"Parametr:"); - define(20,120,35,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->lock.thieflevel)); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->twop.parm1=f_get_value(0,10); - q->twop.parm2=vals(20); - read_ma_flags(200,q); - } - close_current(); - } - -void tma_ifjump(TMULTI_ACTION *q,int linenum,TSTR_LIST ls) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: If Jump"); - b1=def_border(5,WINCOLOR); - define(-1,5,22,1,1,0,label,"Podmďż˝nka:"); - define(10,10,35,200,12,0,str_line,ls);on_enter(string_list_sup); - property(b1,NULL,NULL,WINCOLOR);c_default(abs(q->twop.parm1)-1); - define(-1,5,52,1,1,0,label,"��slo ��dku:"); - define(20,120,50,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->twop.parm2+linenum)); - define(30,5,75,100,30,0,radio_butts,2,"Skok kdyďż˝ podmďż˝nka platďż˝","Skok kdyďż˝ podmďż˝nka neplatďż˝"); - c_default(q->twop.parm1<0); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->twop.parm1=f_get_value(0,10)+1; - q->twop.parm2=vals(20)-linenum; - if (f_get_value(0,30)) q->twop.parm1=-q->twop.parm1; - read_ma_flags(200,q); - } - close_current(); - } - -void tma_randjmp(TMULTI_ACTION *q,int linenum) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: If Jump"); - b1=def_border(5,WINCOLOR); - define(-1,5,22,1,1,0,label,"Pravdďż˝podobnost: [%]"); - define(10,120,35,60,12,0,input_line,5,0,100,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->twop.parm1)); - define(-1,5,52,1,1,0,label,"��slo ��dku:"); - define(20,120,50,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->twop.parm2+linenum)); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->twop.parm1=vals(10); - q->twop.parm2=vals(20)-linenum; - read_ma_flags(200,q); - } - close_current(); - } - - -void tma_ifflagjump(TMULTI_ACTION *q,int linenum) - { - CTL3D *b1=NULL; - - if (q->twop.parm1==0) q->twop.parm1=1; - def_dialoge(220,60,410,300,"Macro: If flag Jump"); - b1=def_border(5,WINCOLOR); - define(-1,5,22,1,1,0,label,"��slo vlajky:"); - define(10,120,20,60,12,0,input_line,5,0,255,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(abs(q->twop.parm1)-1)); - define(-1,5,52,1,1,0,label,"��slo ��dku:"); - define(20,120,50,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->twop.parm2+linenum)); - define(30,5,75,100,30,0,radio_butts,2,"Skok kdyďż˝ vlajka nastavena","Skok kdyďż˝ vlajka vynulovďż˝na"); - c_default(q->twop.parm1<0); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->twop.parm1=vals(10)+1; - q->twop.parm2=vals(20)-linenum; - if (f_get_value(0,30)) q->twop.parm1=-q->twop.parm1; - read_ma_flags(200,q); - } - close_current(); - } - -void tma_setflag(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: Change Flag"); - b1=def_border(5,WINCOLOR); - define(-1,5,22,1,1,0,label,"��slo vlajky:"); - define(10,120,20,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->twop.parm1)); - define(-1,5,37,1,1,0,label,"Akce:"); - define(20,60,37,80,40,0,radio_butts,3,"Nulovat","Nastavit","Negovat");c_default(q->twop.parm2); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->twop.parm1=vals(10); - q->twop.parm2=f_get_value(0,20); - read_ma_flags(200,q); - } - close_current(); - } - - -void tma_wound(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: HIT Player"); - b1=def_border(5,WINCOLOR); - define(-1,5,22,1,1,0,label,"Min:"); - define(10,120,20,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->wound.minor)); - define(-1,5,37,1,1,0,label,"Max:"); - define(20,120,35,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->wound.major)); - define(30,120,50,100,10,0,check_box,"Ohrozďż˝ skupinu");c_default(q->wound.pflags & 1); - define(40,120,70,60,80,0,radio_butts,7,"P��mďż˝ zranďż˝nďż˝","Hod na obranu","Oheďż˝","Voda","Zemďż˝","Vzduch","Mysl"); - c_default(q->wound.pflags>>1); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->wound.minor=vals(10); - q->wound.major=vals(20); - q->wound.pflags=f_get_value(0,30)+(f_get_value(0,40)<<1); - read_ma_flags(200,q); - } - close_current(); - } - -void tma_cmoney(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: Create Money"); - b1=def_border(5,WINCOLOR); - define(-1,5,22,1,1,0,label,"Min:"); - define(10,120,20,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->twop.parm1)); - define(-1,5,37,1,1,0,label,"Max:"); - define(20,120,35,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->twop.parm2)); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - tady: - escape(); - if (o_aktual->id==OK_BUTT) - { - int a=vals(10),b=vals(20); - if (a>b) - { msg_box("Create Money",1,"Min musďż˝ bďż˝t men�� neďż˝ Max","OK",NULL);goto tady;} - q->twop.parm1=a; - q->twop.parm2=b; - read_ma_flags(200,q); - } - close_current(); - } - -static void tma_gomonster(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: Send Monster To"); - b1=def_border(5,WINCOLOR); - define(-1,5,22,1,1,0,label,"Odkud:"); - define(10,120,20,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->twop.parm1)); - define(-1,5,37,1,1,0,label,"Kam:"); - define(20,120,35,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->twop.parm2)); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - tady: - escape(); - if (o_aktual->id==OK_BUTT) - { - int a=vals(10),b=vals(20); - if (a==b) - { msg_box("Send Monster To",1,"Ale tohle nesmysl!","OK",NULL);goto tady;} - q->twop.parm1=a; - q->twop.parm2=b; - read_ma_flags(200,q); - } - close_current(); - } - - -void tma_clock(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - char s[20]; - - def_dialoge(220,60,410,300,"Macro: Code Lock"); - b1=def_border(5,WINCOLOR); - define(-1,5,22,1,1,0,label,"Character:"); - define(10,100,20,10,12,0,input_line,2); - property(b1,NULL,NULL,WINCOLOR);s[0]=q->clock.znak;s[1]=0;set_default(s); - define(-1,5,37,1,1,0,label,"String:"); - define(20,80,35,100,12,0,input_line,8);strncpy(s,q->clock.string,8);s[8]=0;set_default(s); - property(b1,NULL,NULL,WINCOLOR); - define(-1,5,52,1,1,0,label,"��slo:"); - define(30,80,50,30,12,0,input_line,8,0,15," %02d");set_default(strs(q->clock.codenum)); - on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - get_value(0,10,s);q->clock.znak=s[0]; - get_value(0,20,s);strncpy(q->clock.string,s,8); - q->clock.codenum=vals(30); - read_ma_flags(200,q); - } - close_current(); - } - - - - -void tma_text(TMULTI_ACTION *q,char *filename) - { - CTL3D *b1; - int id; - TSTR_LIST ls; - int lcount; - - - ls=create_list(10); - if (id=load_string_list(&ls,filename)) - { - char s[300]; - if (id<0) sprintf(s,"Soubour %s chybďż˝ nebo je poďż˝kozen. Nelze editovat texty",filename); - else sprintf(s,"Chyba v souboru %s na ��dce %d",filename,id); - msg_box("Chyba!",'\x1',s,"Ok",NULL); - return; - } - lcount=str_count(ls); - if (q->text.textindex>=lcount) q->text.textindex=0; - while (q->text.textindextext.textindex]==NULL) - (q->text.textindex)++; - if (q->text.textindex>=lcount) - { - msg_box("Oznďż˝menďż˝",'\x1',"��dnďż˝ texty nejsou k dispozici","Ok",NULL); - return; - } - b1=def_border(5,WINCOLOR); - def_dialoge(420,120,250,290,"Oprav akci"); - define(-1,5,20,1,1,0,label,"Text:"); - define(10,5,19,170,12,1,str_line,ls); - c_default(q->text.textindex); - on_enter(string_list_sup); - property(b1,NULL,flat_color(0x1f),WINCOLOR); - add_ma_flags(20,5,35,q); - b1=def_border(1,0); - define(OK_BUTT,5,5,60,20,3,button,"Ok");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(CANCEL_BUTT,5,5,60,20,2,button,"Zruďż˝it");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - redraw_window(); - escape(); - id=o_aktual->id; - if (id==CANCEL_BUTT) - { - release_list(ls); - close_current(); - return; - } - read_ma_flags(20,q); - q->text.textindex=f_get_value(0,10); - release_list(ls); - close_current(); - } - -void tma_dialog(TMULTI_ACTION *q) - { - CTL3D *b1; - int id; - int i; - - - i=pgf2name(q->text.textindex); - b1=def_border(5,WINCOLOR); - def_dialoge(420,120,250,290,"Oprav akci"); - define(-1,5,20,1,1,0,label,"Dialog:"); - define(10,5,19,170,12,1,str_line,dlg_names); - c_default(i); - on_enter(string_list_sup); - property(b1,NULL,flat_color(0x1f),WINCOLOR); - add_ma_flags(20,5,35,q); - b1=def_border(1,0); - define(OK_BUTT,5,5,60,20,3,button,"Ok");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(CANCEL_BUTT,5,5,60,20,2,button,"Zruďż˝it");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - redraw_window(); - escape(); - id=o_aktual->id; - if (id==CANCEL_BUTT) - { - close_current(); - return; - } - read_ma_flags(20,q); - q->text.textindex=dlg_pgfs[f_get_value(0,10)]; - close_current(); - } - -void tma_shop(TMULTI_ACTION *q) - { - CTL3D *b1; - int id; - int i; - TSTR_LIST ls=NULL; - - - re_build_shop_list(&ls,shop_list,max_shops); - for(i=0;itext.textindex) break; - b1=def_border(5,WINCOLOR); - def_dialoge(420,120,250,290,"Oprav akci"); - define(-1,5,20,1,1,0,label,"Obchod:"); - define(10,5,19,170,12,1,str_line,ls); - c_default(i); - on_enter(string_list_sup); - property(b1,NULL,flat_color(0x1f),WINCOLOR); - add_ma_flags(20,5,35,q); - b1=def_border(1,0); - define(OK_BUTT,5,5,60,20,3,button,"Ok");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(CANCEL_BUTT,5,5,60,20,2,button,"Zruďż˝it");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - redraw_window(); - escape(); - release_list(ls); - id=o_aktual->id; - if (id==CANCEL_BUTT) - { - close_current(); - return; - } - read_ma_flags(20,q); - q->text.textindex=shop_list[f_get_value(0,10)].shop_id; - close_current(); - } - - -void tma_create_dropi(TMULTI_ACTION *q,char *name) - { - CTL3D *b1; - int id; - TSTR_LIST ls=NULL; - int lcount; - int it; - - - create_isort_list(&ls,-1); - lcount=str_count(ls); - it=q->dropi.item; - if (it>=lcount) it=0; - b1=def_border(5,WINCOLOR); - def_dialoge(420,120,250,290,name); - define(-1,5,20,1,1,0,label,"Vďż˝c:"); - define(10,5,19,170,12,1,str_line,ls); - c_default(it); - on_enter(string_list_sup); - property(b1,NULL,flat_color(0x1f),WINCOLOR); - add_ma_flags(20,5,35,q); - b1=def_border(1,0); - define(OK_BUTT,5,5,60,20,3,button,"Ok");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(CANCEL_BUTT,5,5,60,20,2,button,"Zruďż˝it");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - redraw_window(); - escape(); - id=o_aktual->id; - release_list(ls); - if (id==CANCEL_BUTT) - { - close_current(); - return; - } - read_ma_flags(20,q); - q->dropi.item=f_get_value(0,10); - close_current(); - } - - -void tma_gen(TMULTI_ACTION *q,char *name) - { - CTL3D *b1; - int id; - - - b1=def_border(5,WINCOLOR); - def_dialoge(420,120,250,290,name); - add_ma_flags(20,5,35,q); - b1=def_border(1,0); - define(OK_BUTT,5,5,60,20,3,button,"Ok");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(CANCEL_BUTT,5,5,60,20,2,button,"Zruďż˝it");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - redraw_window(); - escape(); - id=o_aktual->id; - if (id==CANCEL_BUTT) - { - close_current(); - return; - } - read_ma_flags(20,q); - close_current(); - } - - -static void tma_unique_edit() - { - TITEM *it; - - it=(TITEM *)f_get_value(0,20); - item_edit(it); - } - -void tma_unique(TMULTI_ACTION *q,char edit) - { - CTL3D *b1; - - - if (!edit) - { - int i; - tma_create_dropi(q,"Zvol pďż˝edlohu"); - i=q->dropi.item; - memcpy(&q->uniq.item,item_list+i,sizeof(q->uniq.item)); - } - def_dialoge(420,120,250,290,"Create Unique"); - b1=def_border(1,0); - define(10,10,19,230,15,1,button,"Oprav vlastnosti predmetu"); - on_control_change(tma_unique_edit); - property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(20,0,0,0,0,0,value_store,4);c_default((int)&q->uniq.item); - add_ma_flags(30,5,40,q); - define(OK_BUTT,5,5,60,20,3,button,"Zav��t");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - redraw_window(); - if (edit)escape();else tma_unique_edit(); - read_ma_flags(30,q); - close_current(); - } - -static char *global_events[MAGLOB_NEXTID]= -{ - "Pred opustenim mapy", - "Pred usnutim", - "Po probuzeni", - "Pred ulozenim", - "Po ulozeni", - "Pred carovanim", - "Po carovani", - "Otevreni mapy", - "Uzavreni mapy", - "Pred bitvou", - "Po bitve", - "Otevreni knihy", - "Zavreni knihy", - "Kazde kolo", - "Smrt postavy muze", - "Smrt postavy zeny", - "Smrt vsech postav", - "Zraneni muze", - "Zraneni zeny", - "Sebrani runy", - "Sebrani predmetu", - "Krok", - "Otoceni", - "Alarm", - "Magie ohne", - "Magie vody", - "Magie zeme", - "Magie vzduchu", - "Magie mysli", - "Pri kouzle 1 ", - "Pri kouzle 2 ", - "Pri kouzle 3 ", - "Pri kouzle 4 ", - "Pri kouzle 5 ", - "Pri kouzle 6 ", - "Pri kouzle 7 ", - "Pri kouzle 8 ", - "Pri kouzle 9 ", - "Casovac 1 ", - "Casovac 2 ", - "Casovac 3 ", - "Casovac 4 ", - "Melodie fletny 1 ", - "Melodie fletny 2 ", - "Melodie fletny 3 ", - "Melodie fletny 4 ", - "Melodie fletny 5 ", - "Melodie fletny 6 ", - "Melodie fletny 7 ", - "Melodie fletny 8 ", -}; - -void tma_globe(TMULTI_ACTION *q) - { - CTL3D *b1=NULL; - - int i,cnt=sizeof(global_events)/sizeof(global_events[0]); - TSTR_LIST lst=create_list(cnt); - for (i=0;iglobe.event); - define(6,290,20,60,12,0,input_line,10,-0x7FFFFFFF,0x7FFFFFFF,"%d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->globe.param)); - define(-1,5,52,1,1,0,label,"Sektor:"); - define(10,80,50,60,12,0,input_line,10,0,maplen,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->globe.sector)); - define(-1,5,37,1,1,0,label,"Pri vzniku udalosti poslat akci na:"); - define(-1,5,67,1,1,0,label,"Stďż˝na:"); - define(20,80,65,100,12,0,str_line,steny2);on_enter(string_list_sup); - property(b1,NULL,NULL,WINCOLOR);c_default(q->globe.side); - define(-1,5,80,100,10,0,label,"Pďż˝i volbe sektor 0 severni"); - define(-1,5,90,100,10,0,label,"se akce neposila"); - define(30,20,110,100,10,0,check_box,"Zakaz puvodni chovani");c_default(q->globe.cancel); - add_ma_flags(200,200,50,q); - fill_bit_fields(0,110,q->send_a.change_bits,5); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->globe.event=f_get_value(0,5); - q->globe.param=vals(6); - q->globe.sector=vals(10); - q->globe.side=f_get_value(0,20); - q->globe.cancel=get_bit_fields(0,30,1); - read_ma_flags(200,q); - } - close_current(); - release_list(lst); - } - -static char create_mode=0; - -void tma_sectnumjmp(TMULTI_ACTION *q,int linenum) - { - CTL3D *b1=NULL; - - def_dialoge(220,60,410,300,"Macro: If Jump"); - b1=def_border(5,WINCOLOR); - define(-1,5,52,1,1,0,label,"Sektor:"); - define(10,80,50,60,12,0,input_line,6,0,maplen,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->ifsec.sector)); - define(-1,5,67,1,1,0,label,"Stďż˝na:"); - define(20,80,65,100,12,0,str_line,steny2);on_enter(string_list_sup); - property(b1,NULL,NULL,WINCOLOR);c_default(q->ifsec.side); - define(-1,5,82,1,1,0,label,"��slo ��dku:"); - define(30,120,80,60,12,0,input_line,5,0,32767,"%5d");on_exit(test_int); - property(b1,NULL,NULL,WINCOLOR);set_default(strs(q->ifsec.line+linenum)); - define(40,5,120,120,30,0,radio_butts,2,"Skok kdyďż˝ podmďż˝nka platďż˝","Skok kdyďż˝ podmďż˝nka neplatďż˝"); - c_default(q->ifsec.invert); - add_ma_flags(200,220,20,q); - b1=def_border(1,0); - define(OK_BUTT,5,30,80,20,2,button,"Ok");on_control_change(terminate_gui);property(b1,NULL,flat_color(0x1f),WINCOLOR); - define(CANCEL_BUTT,5,5,80,20,2,button,"Zruďż˝it");on_control_change(terminate_gui);property(b1,NULL,flat_color(RGB555(15,0,0)),WINCOLOR); - redraw_window(); - escape(); - if (o_aktual->id==OK_BUTT) - { - q->ifsec.sector=vals(10); - q->ifsec.side=f_get_value(0,20); - q->ifsec.line=vals(30)-linenum; - q->ifsec.invert=f_get_value(0,40); - read_ma_flags(200,q); - } - close_current(); - } - -void edit_multiaction() - { - int sect,side,num; - TMULTI_ACTION *q; - TMULTI_ACTION **z; - TSTR_LIST ls=NULL; - - sect=vals(10); - side=f_get_value(0,20); - num=f_get_value(0,29); - z=multi_actions[sect*4+side];if (z==NULL) return; - if (num>=str_count((TSTR_LIST)(z))) return; - q=z[num];if (q==NULL) return; - switch (q->general.action) - { - case MA_GEN:return; - case MA_SOUND:tma_sound(q);break; - case MA_TEXTG:tma_text(q,TEXT_FILE);break; - case MA_TEXTL:tma_text(q,pripona(filename,TXT));break; - case MA_SENDA:tma_send(q);break; - case MA_FIREB:tma_fireball(q);break; - case MA_LOADL:tma_loadlev(q);break; - case MA_DROPI:tma_create_dropi(q,"Macro: Drop item");break; - case MA_DIALG:tma_dialog(q);break; - case MA_SSHOP:tma_shop(q);break; - case MA_CLOCK:tma_clock(q);break; - case MA_CACTN:tma_cancel_action(q);break; - case MA_LOCK:tma_lock(q);break; - case MA_SWAPS:tma_swapsectors(q);break; - case MA_WOUND:tma_wound(q);break; - case MA_IFJMP:tma_ifjump(q,num,side_flgs);break; - case MA_CALLS:tma_specproc(q);break; - case MA_PICKI: - case MA_HAVIT:create_isort_list(&ls,-1);tma_ifjump(q,num,ls);release_list(ls);break; - case MA_STORY:tma_text(q,pripona(filename,TXT));break; - case MA_IFACT:tma_ifjump(q,num,actions);break; - case MA_SNDEX:tma_experience(q);break; - case MA_TELEP:tma_teleport_group(q);break; - case MA_PLAYA:tma_play_anim(q);break; - case MA_CREAT:tma_create_dropi(q,"Macro: Create item");break; - case MA_ISFLG:tma_ifflagjump(q,num);break; - case MA_CHFLG:tma_setflag(q);break; - case MA_GUNIQ: - case MA_CUNIQ:tma_unique(q,q->uniq.item.jmeno[0]!=0);break; - case MA_MONEY:tma_cmoney(q);break; - case MA_WBOOK:tma_write_book(q);break; - case MA_RANDJ:tma_randjmp(q,num);break; - case MA_GOMOB:tma_gomonster(q);break; - case MA_SHRMA:if (create_mode) q->sound.flags=q->sound.eflags=0xFF;tma_sharema(q);break; - case MA_MUSIC:tma_text(q,pripona(filename,TXT));break; - case MA_GLOBE:tma_globe(q);break; - case MA_IFSEC:tma_sectnumjmp(q,num);break; - case MA_IFSTP:tma_ifjump(q,num,sector_types);break; - default:if (!create_mode) tma_gen(q,act_types[q->general.action]);break; - } - create_multiaction_list(&mul_list,sect,side); - send_message(E_GUI,29,E_CONTROL,1,mul_list); - create_mode=0; - } -void create_multiaction_invalid() - { - int i; - - i=f_get_value(0,10); - set_enable(0,OK_BUTT,i<(sizeof(action_sizes)/sizeof(int))); - } - - - -void create_multiaction_dialoge() - { - CTL3D *b1; - int id,i; - static TMULTI_ACTION x={0,0,0,0}; - int sect,side,before; - char s[30]; - static int act_default=1; - TSTR_LIST ls;char *c; - - sect=vals(10); - ls=(TSTR_LIST)getmem(_msize(act_types)); - memcpy(ls,act_types,_msize(act_types)); - sort_list(ls,-1); - c=act_types[act_default];id=str_count(act_types); - for(i=0;iid; - if (id==CANCEL_BUTT) - { - close_current(); - return; - } - read_ma_flags(20,&x); - c=ls[f_get_value(0,9)];id=str_count(act_types); - for(i=0;i0) c_set_value(0,29,num-1); - create_multiaction_list(&mul_list,sect,side); - send_message(E_GUI,29,E_CONTROL,1,mul_list); - } - -void mult_change_dir() - { - int i,s; - - - i=vals(10); - s=f_get_value(0,20); - create_multiaction_list(&mul_list,i,s); - send_message(E_GUI,29,E_CONTROL,1,mul_list); - } - -static TMULTI_ACTION **pamet=0; - -static void copy_and_paste() -{ - CTL3D *b1=NULL; - int id; - - int sect=vals(10); - int side=f_get_value(0,20); - - def_dialoge(400,100,200,320,"Prďż˝ce s pamďż˝tďż˝"); - b1=def_border(5,WINCOLOR); - define(10,10,20,180,20,0,button,"Kopďż˝rovat do pamďż˝ti");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(400,10,70,100,10,0,check_box,"Severnďż˝");c_default(side==0); - define(410,10,85,100,10,0,check_box,"Vďż˝chodnďż˝");c_default(side==1); - define(420,10,100,100,10,0,check_box,"Jiďż˝nďż˝");c_default(side==2); - define(430,10,115,100,10,0,check_box,"Zďż˝padnďż˝");c_default(side==3); - define(440,10,130,180,10,0,check_box,"Tam kde je prim. stďż˝na");c_default(0); - define(445,10,150,180,12,0,str_line,side_names);property(b1,NULL,NULL,WINCOLOR);c_default(0); - on_enter(string_list_sup); - define(450,10,170,180,10,0,check_box,"Tam kde je sec. stďż˝na");c_default(0); - define(455,10,190,180,12,0,str_line,side_names);property(b1,NULL,NULL,WINCOLOR);c_default(0); - on_enter(string_list_sup); - define(-1,10,210,180,12,0,label,"Jak vloďż˝it?"); - define(460,10,225,180,30,0,radio_butts,3, - "Pďż˝epsat vďż˝e", - "Pďż˝epsat pouďż˝itďż˝ udďż˝l.", - "Pďż˝idat na konec");c_default(1); - define(20,10,260,180,20,0,button,"Vloďż˝it");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - define(30,10,285,180,20,0,button,"Zruďż˝it");property(b1,NULL,NULL,WINCOLOR);on_control_change(terminate_gui); - redraw_window(); - escape(); - id=o_aktual->id; - if (id==10) - { - TMULTI_ACTION **z=multi_actions[sect*4+side]; - int cnt=str_count((TSTR_LIST)z); - int i; - - if (pamet) release_list((TSTR_LIST) pamet); - pamet=(TMULTI_ACTION **)malloc(sizeof(*pamet)*cnt); - memset(pamet,0,sizeof(*pamet)*cnt); - for (i=0;isound.flags; - eflags|=pamet[i]->sound.eflags; - } - for (i=0;isound.flags&=~flags; - m->sound.eflags&=~eflags; - if (m->sound.flags==0 && m->sound.eflags==0) - { - free(m); - memcpy(z+i,z+i+1,sizeof(m)*(str_count((TSTR_LIST)z)-i-1)); - z[str_count((TSTR_LIST)z)-1]=0; - --i; - } - } - } - } - } - { - int sect=i; - TMULTI_ACTION **z=multi_actions[sect*4+j]; - int i,k=0; - int cnt=str_count((TSTR_LIST) z); - for (i=0;iminsizx=120; - waktual->minsizy=150; - define(-1,5,20,1,1,0,label,"Sektor"); - define(-1,5,32,1,1,0,label,"Stďż˝na"); - define(-1,5,44,1,1,0,label,"Program:"); - define(-1,3,1,10,10,2,resizer); - define(10,5,20,60,10,1,input_line,5,0,maplen-1,"%5d");set_default(strs(i));on_exit(test_int); - property(NULL,NULL,flat_color(0x1f),WINCOLOR); - define(20,5,32,60,10,1,str_line,steny2);c_default(0);on_enter(string_list_sup); - property(NULL,NULL,flat_color(0x1f),WINCOLOR);on_control_change(mult_change_dir); - create_multiaction_list(&mul_list,i,0); - define(29,5,55,95,180,0,listbox,mul_list,RGB555(31,31,0),0);c_default(0); - o_end->autoresizex=1; - o_end->autoresizey=1; - define(30,3,66,15,157,1,scroll_bar_v,0,10,1,SCROLLBARCOL); - property(NULL,NULL,NULL,WINCOLOR); - o_end->autoresizey=1; - define(31,3,50,15,15,1,scroll_button,-1,0,"\x1e"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(32,3,60,15,15,2,scroll_button,1,10,"\x1f"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(40,5,5,50,20,3,button,"Vymaďż˝");property(b1,NULL,NULL,WINCOLOR);on_control_change(delete_multiaction_ask); - define(50,60,5,50,20,3,button,"Edit");property(b1,NULL,NULL,WINCOLOR);on_control_change(edit_multiaction); - define(60,5,30,50,20,3,button,"Vloďż˝");property(b1,NULL,NULL,WINCOLOR);on_control_change(create_multiaction_dialoge); - define(70,60,30,50,20,3,button,"Pamďż˝t");property(b1,NULL,NULL,WINCOLOR);on_control_change(copy_and_paste); - //define(70,60,30,50,20,3,button,"Poďż˝adďż˝");property(b1,NULL,NULL,WINCOLOR); - redraw_window(); - } - select_window(wiz_tool_numb);close_current(); - } - -void update_multiactions() - { - void *wsave; - WINDOW *f; - char c[20]; - int i,s; - - wsave=waktual; - f=find_window(multiaction_win); - if (f==NULL) - { - open_multiaction_window(); - return; - } - for (i=1;igeneral.action]; - maxsize+=4; - } - } - maxsize+=4; - c=data=(char *)getmem(maxsize); - for(i=1;igeneral.action]; - memcpy(c,&siz,4);c+=4; - memcpy(c,*q,siz);c+=siz; - } - m=0; - memcpy(c,&m,4);c+=4; - } - } - memcpy(c,&m,4); - *blocksize=maxsize; - return (void *)data; - - } - -void load_macros(void *data) - { - long *c; - int sect,sid; - - c=data; - while (*c) - { - int i,siz,csiz; - TMULTI_ACTION a; - sect=*c>>2; - sid=*c & 3; - c++;i=0; - while (*c) - { - siz=*c++; - if (siz>sizeof(a)) csiz=sizeof(a);else csiz=siz; - memcpy(&a,c,csiz); - c=(long *)((char *)c+siz); - add_multiaction(sect,sid,i++,&a); - } - c++; - } - } diff --git a/MAPS/WIZ_TOOL.H b/MAPS/WIZ_TOOL.H deleted file mode 100644 index afeb736..0000000 --- a/MAPS/WIZ_TOOL.H +++ /dev/null @@ -1,5 +0,0 @@ -void open_wiz_tool(void); -void close_wiz_tool(void); -extern long wiz_tool_numb; -int count_of_sel(void); -void sample_editor(int sector,int side); diff --git a/PCX/3DMAN.C b/PCX/3DMAN.C deleted file mode 100644 index c7d0c84..0000000 --- a/PCX/3DMAN.C +++ /dev/null @@ -1,102 +0,0 @@ -#include "..\types.h" -#include "..\bgraph.h"; -#include "pcx.h" -#include -#include -#include -typedef char bitmap[640*480+512+6+16]; - -#define DATASTART (512+6) -#define DATASIZE (640*480) - -bitmap out; -bitmap in1; - -void clear_bm(bitmap *c) -{ -memset(((char *)c+DATASTART),0,DATASIZE); -} - -void adjust_point(int *x,int *y) - { - while (*x>=640) (*x)-=640; - while (*x<0) (*x)+=640; - while (*y>=480) (*y)-=480; - while (*y<0) (*y)+=480; - } - -void set_point(int x,int y,int c) - { - adjust_point(&x,&y); - out[DATASTART+x+y*640]=c; - } - -int get_point(int x,int y) - { - x=x*640/500;y=y*480/2000; - adjust_point(&x,&y); - return in1[DATASTART+x+y*640]; - } - -#define TXT_Y 480 -#define TXT_X 640 -#define OKO_Y 103 -#define OKO_X 250 -#define OKO_Z (-1100) -#define OSA_Y 1000 -#define OSA_X 500 - -int vypocet_z(int y) - { - return(OSA_Y-y)*(-OKO_Z)/(y-OKO_Y); - } - -int vypocet_x(int x,int z) - { - return(x-OKO_X)*z/(-OKO_Z)+x; - } - -void smycka() - { - int x1,y1,z1; - int x2; - - for(y1=351;y1>178;y1--) - { - z1=vypocet_z(y1); - for(x1=0;x1<639;x1++) - { - x2=vypocet_x(x1-70,z1); - set_point(x1,y1+9+16,get_point(x2,z1+350)); - } - /*if (!(y1 & 7))*/{put_picture(0,0,out);showview(0,0,0,0);} - - } - } - -initmode32b(); - - -void init() - { - initmode32b(); - memcpy(&out,&in1,sizeof(in1)); - clear_bm(out); - } - -main() - { - void *buffer; - - open_pcx("TEXTURA.PCX",A_8BIT,&buffer); - memcpy(&in1,buffer,sizeof(in1)); - free(buffer); - open_pcx("sit.PCX",A_8BIT,&buffer); - init(); - memcpy(&out,buffer,sizeof(out)); - put_picture(0,0,&out); - showview(0,0,0,0); - smycka(); - getchar(); - return 0; - } diff --git a/PCX/BOLDCZ.FON b/PCX/BOLDCZ.FON deleted file mode 100644 index 7a767fa..0000000 Binary files a/PCX/BOLDCZ.FON and /dev/null differ diff --git a/PCX/PCX.C b/PCX/PCX.C deleted file mode 100644 index 13c38b0..0000000 --- a/PCX/PCX.C +++ /dev/null @@ -1,180 +0,0 @@ -#include -#include -#include -#include -/*#include "..\types.h"*/ -#include "pcx.h" -#include -/*#include "..\bgraph.h"*/ - - -void decomprimate_line_256(char *src,char *trg,int linelen,int *srcstep) - { - char *srcsave; - - srcsave=src; - while (linelen--) - { - if (*src>=0xc0) - { - int i; - i=*src++ & 0x3f;memset(trg,*src++,i); - trg+=i;linelen-=i-1; - } - else - *trg++=*src++; - } - *srcstep=src-srcsave; - } -void decomprimate_line_hi(char *src,unsigned short *trg,unsigned short *paleta,int linelen,int *srcstep) - { - char *srcsave; - - srcsave=src; - while (linelen--) - { - if (*src>=0xc0) - { - int i,j; - i=(*src++) & 0x3f; - for (j=0;j>3; - g=(tg+(*(bt++)-tg)*(5-j)/5)>>3; - b=(tb+(*(bt++)-tb)*(5-j)/5)>>3; - hi=(r<<10)+(g<<5)+b; - pal2[j][i]=hi; - } - while (++i & 0xff); - } - } - - -int load_pcx(char *pcx,long fsize,int conv_type,char **buffer, ... ) - //dale nasleduji int hodnoty poctu prechodu a R,G,B barvy - { - char *paleta1; - unsigned short paleta2[256]; - char *ptr1;unsigned short *ptr2; - char *ptr3; - int i; - PCXHEADER pcxdata; - int xsize,ysize; - - - paleta1=pcx+fsize-768; - ptr1=paleta1;ptr2=paleta2; - for (i=0;i<256;i++) - { - *ptr2=*(ptr1++)>>3; - *ptr2=(*ptr2<<5)+(*(ptr1++)>>3); - *ptr2=(*ptr2<<6)+(*(ptr1++)>>3); - ptr2++; - } - - memcpy(&pcxdata,pcx,sizeof(pcxdata)); - xsize=pcxdata.xmax-pcxdata.xmin+1; - ysize=pcxdata.ymax-pcxdata.ymin+1; - switch (conv_type) - { - case A_8BIT: *buffer=(char *)getmem(xsize*ysize+512+6+16);break; - case A_15BIT: *buffer=(char *)getmem(xsize*ysize*2+6+16);break; - case A_FADE_PAL: *buffer=(char *)getmem(xsize*ysize+512*5+6+16);break; - default: return -2; //invalid type specificied - } - ptr1=*buffer; - *(unsigned short *)ptr1++=xsize;ptr1++; - *(unsigned short *)ptr1++=ysize;ptr1++; - *(unsigned short *)ptr1++=conv_type;ptr1++; - pcx+=sizeof(pcxdata);ptr3=pcx; - if (conv_type==A_8BIT) - { - memcpy(ptr1,paleta2,512); - ptr1+=512; - } - if (conv_type==A_FADE_PAL) - { - int *i,tr,tg,tb; - - i=(int *)&buffer;i++; - tr=*i++;tg=*i++;tb=*i++; - - palette_shadow(paleta1,(unsigned short *)ptr1,tr,tg,tb); - ptr1+=5*512; - } - ysize++; - while (--ysize) - { - int step; - if (conv_type==15) - { - decomprimate_line_hi(ptr3,(unsigned short *)ptr1,paleta2,pcxdata.bytesperline,&step); - ptr1+=2*xsize; - } - else - { - decomprimate_line_256(ptr3,ptr1,pcxdata.bytesperline,&step); - ptr1+=xsize; - } - ptr3+=step; - } - return 0; - } - -int open_pcx(char *filename,int type,char **buffer,...) - { - FILE *pcx; - char *src; - long fsize; - - pcx=fopen(filename,"rb"); - if (pcx==NULL) return -1; - fseek(pcx,0,SEEK_END); - fsize=ftell(pcx); - fseek(pcx,0,SEEK_SET); - src=(char *)getmem(fsize); - fread(src,1,fsize,pcx); - fsize=load_pcx(src,fsize,type,buffer,*((int *)&buffer+1),*((int *)&buffer+2),*((int *)&buffer+3)); - fclose(pcx); - free(src); - return fsize; - } - -/*void initmode32b(); - -main() - { - char *buf; - - initmode32b(); - open_pcx("DESK.pcx",A_8BIT,&buf,0,0,0); - put_picture(0,480-102,buf); - showview(0,0,0,0); - getchar(); - return 0; - } - - -*/ - diff --git a/PCX/PCX.H b/PCX/PCX.H deleted file mode 100644 index 7000c99..0000000 --- a/PCX/PCX.H +++ /dev/null @@ -1,25 +0,0 @@ -#define A_8BIT 8 -#define A_15BIT 15 -#define A_FADE_PAL 256*8 - -typedef struct pcxrecord - { - unsigned short id; - char encoding; - char bitperpixel; - unsigned short xmin,ymin,xmax,ymax; - unsigned short hdpi,vdpi; - char colormap[48]; - char reserved; - char mplanes; - unsigned short bytesperline; - unsigned short paleteinfo; - unsigned short hscreen,vscreen; - char filler[54]; - }PCXHEADER; - - - -int load_pcx(char *pcx,long fsize,int conv_type,char **buffer, ... ); -int open_pcx(char *filename,int type,char **buffer,...); - diff --git a/PCX/PCXTST.C b/PCX/PCXTST.C deleted file mode 100644 index eb06b23..0000000 --- a/PCX/PCXTST.C +++ /dev/null @@ -1,173 +0,0 @@ -#include "..\types.h" -#include -#include -#include -#include "..\bgraph.h" -#define A_8BIT 8 -#define A_15BIT 15 -#define A_FADE_PAL 256*8 - -typedef struct pcxrecord - { - unsigned short id; - char encoding; - char bitperpixel; - unsigned short xmin,ymin,xmax,ymax; - unsigned short hdpi,vdpi; - char colormap[48]; - char reserved; - char mplanes; - unsigned short bytesperline; - unsigned short paleteinfo; - unsigned short hscreen,vscreen; - char filler[54]; - }PCXHEADER; - - - -void decomprimate_line_256(char *src,char *trg,int linelen,int *srcstep) - { - char *srcsave; - - srcsave=src; - while (linelen--) - { - if (*src>=0xc0) - { - int i; - i=*src++ & 0x3f;memset(trg,*src++,i); - trg+=i;linelen-=i-1; - } - else - *trg++=*src++; - } - *srcstep=src-srcsave; - } -void decomprimate_line_hi(char *src,unsigned short *trg,unsigned short *paleta,int linelen,int *srcstep) - { - char *srcsave; - - srcsave=src; - while (linelen--) - { - if (*src>=0xc0) - { - int i,j; - i=(*src++) & 0x3f; - for (j=0;j>3; - *ptr2=(*ptr2<<5)+(*(ptr1++)>>3); - *ptr2=(*ptr2<<5)+(*(ptr1++)>>3); - ptr2++; - } - - fseek(pcx,curptr,SEEK_SET); - fread(&pcxdata,sizeof(pcxdata),1,pcx); - xsize=pcxdata.xmax-pcxdata.xmin+1; - ysize=pcxdata.ymax-pcxdata.ymin+1; - switch (conv_type) - { - case A_8BIT: *buffer=(char *)malloc(xsize*ysize+512+6+16);break; - case A_15BIT: *buffer=(char *)malloc(xsize*ysize*2+6+16);break; - case A_FADE_PAL: *buffer=(char *)malloc(xsize*ysize+512*5+6+16);break; - default: return -2; //invalid type specificied - } - ptr1=*buffer; - *(word *)ptr1++=xsize;ptr1++; - *(word *)ptr1++=ysize;ptr1++; - *(word *)ptr1++=conv_type;ptr1++; - src_buff=(char *)malloc(fsize);ptr3=src_buff; - fread(src_buff,fsize-768-sizeof(pcxdata),1,pcx); - if (conv_type==A_8BIT) - { - memcpy(ptr1,paleta2,512); - ptr1+=512; - } - while (--ysize) - { - int step; - if (conv_type==15) - { - decomprimate_line_hi(ptr3,(word *)ptr1,paleta2,pcxdata.bytesperline,&step); - ptr1+=2*xsize; - } - else - { - decomprimate_line_256(ptr3,ptr1,pcxdata.bytesperline,&step); - ptr1+=xsize; - } - ptr3+=step; - } - free(src_buff); - return 0; - } - -int open_pcx(char *filename,int type,char **buffer) - { - FILE *pcx; - long fsize; - - pcx=fopen(filename,"rb"); - if (pcx==NULL) return -1; - fseek(pcx,0,SEEK_END); - fsize=ftell(pcx); - fseek(pcx,0,SEEK_SET); - fsize=load_pcx(pcx,fsize,type,buffer); - fclose(pcx); - return fsize; - } - -void initmode32b(); - -main() - { - char *buf; - - initmode32b(); - getchar(); - //open_pcx("d:\\tycoon2\\scr2.pcx",A_8BIT,&buf); - //put_picture(0,0,buf);free(buf); - open_pcx("desk.pcx",A_15BIT,&buf); - put_picture(0,480-101,buf);free(buf); - open_pcx("topbar.pcx",A_15BIT,&buf); - put_picture(0,0,buf);free(buf); - - showview(0,0,0,0); - getchar(); - return 0; - } - - - - - diff --git a/PCX/PODLAHY.C b/PCX/PODLAHY.C deleted file mode 100644 index a7321b5..0000000 --- a/PCX/PODLAHY.C +++ /dev/null @@ -1,330 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include "..\game\engine1.h" -#include "pcx.h" - -void calc_points(); -void create_tables(); - -char filename1[128]; -char filename2[128]; - -char buffer[640*480+6+512]; - -char *obr1,*obr2; - -typedef struct tbarva - { - char r,g,b; - }TBARVA; - -TBARVA shadow; -int shadow_max; - -struct tbarva palette[256]; - - -char datapath[]=""; -extern struct all_view showtabs; -extern t_points viewport_geometry; - -void do_events() - { - - } - -int get_shd_color(char src,int cur) - { - struct tbarva what; - int c,d,m,p,i,ml; - - m=256*256*256; - c=0;d=0; - what=palette[src]; - cur=shadow_max-cur; - cur=(int)(shadow_max*sqrt((float)cur/(float)shadow_max)); - what.r=(shadow.r+(what.r-shadow.r)*cur/shadow_max); - what.g=(shadow.g+(what.g-shadow.g)*cur/shadow_max); - what.b=(shadow.b+(what.b-shadow.b)*cur/shadow_max); - for(i=0;i<256;i++) - { - p=(what.r-palette[i].r)*(what.r-palette[i].r)+ - (what.g-palette[i].g)*(what.g-palette[i].g)+ - (what.b-palette[i].b)*(what.b-palette[i].b); - if (p=1000) xp-=1000; - while (xp<0) xp+=1000; - if ((xp>=500)^(swap)) srcp=srcadr2+(xp % 500); else srcp=srcadr1+(xp%500); - if (table[*srcp]==0xffff) table[*srcp]=get_shd_color(*srcp,yline); - *point=table[*srcp]&0xff; - } - return showtabs.f_table[2][yline].counter; - } - -void draw_it_all_f() - { - int i,m,y,m2,s; - - y=0;s=0; - m2=(360-MIDDLE_Y)-viewport_geometry[0][0][VIEW3D_Z].y; - shadow_max=m2; - for (i=0;i=1000) xp-=1000; - while (xp<0) xp+=1000; - if ((xp>=500)^(swap)) srcp=srcadr2+(xp % 500); else srcp=srcadr1+(xp % 500); - if (table[*srcp]==0xffff) table[*srcp]=get_shd_color(*srcp,yline); - *point=(table[*srcp]&0xff); - } - return showtabs.c_table[2][yline].counter; - } - -void draw_it_all_c() - { - int i,m,y,m2,s; - - y=0;s=0; - m2=MIDDLE_Y+viewport_geometry[0][1][VIEW3D_Z].y; - shadow_max=m2; - for (i=0;i \n" - "\n" - " \n" - " soubory s texturami ve formatu pcx. Textura musi mit velikost 500x320\n\n" - " \n" - " Cisla predstavujici slozky barvy, jenz se pouzije ke generovani mlhy,\n" - " nebo ke stmavovani. Jednotlive hodnoty jsou v rozsahu <0-255>\n" - "\n" - "Vysledne soubory se ulozi do aktualniho adresare pod jmeny:\n" - " PODLAHA.PCX - soubor s podlahou\n" - " STROP.PCX - soubor se stropem\n" - "\n" - "Pozn.: Prestoze se jedna o korektni format PCX, doporucuji oba soubory \n" - " natahnout do Autodesk Animatora a znovu v tomto formatu ulozit\n" - " Stavalo se mi, ze se muj PCX dekomprimator s timto vygenerovanym souborem\n" - " hroutil.\n" - ); - exit(0); - } - - -main(int argv,char *argc[]) - { - int r,g,b,i; - char rv[10],gv[10],bv[10]; - if (argv!=6) help(); - strass(filename1,argc[1],128); - strass(filename2,argc[2],128); - strass(rv,argc[3],10); - strass(gv,argc[4],10); - strass(bv,argc[5],10); - sscanf(rv,"%d",&r); - sscanf(gv,"%d",&g); - sscanf(bv,"%d",&b); - if (r<0 || r>255 || g<0 || g>255 || b<0 || b>255 ) - { - printf("Hodnoty by mely byt rozsahu <0-255> \n"); - abort(); - } - shadow.r=r;shadow.g=g;shadow.b=b; - calc_points(); - create_tables(); - read_palette(filename1,&palette); - shadow_max=100; - memset(buffer,get_shd_color(0,100),640*480+6+512); - *(word *)buffer=640; - *((word *)buffer+1)=480; - *((word *)buffer+2)=8; - if (open_pcx(filename1,A_8BIT,&obr1) ) - { - printf("Nemohu najit %s.\n",filename1); - abort(); - } - if (open_pcx(filename2,A_8BIT,&obr2) ) - { - printf("Nemohu najit %s.\n",filename2); - abort(); - } - memcpy(buffer+6,obr1+6,512); - draw_it_all_f(); - draw_it_all_c(); - initmode32(); - for(i=0;i>3)<<10)+((g>>3)<<5)+(b>>3); - put_picture(0,0,buffer); - showview(0,0,0,0); - getchar(); - closemode(); - save_pcx("STROP.PCX",0,0,639,92); - save_pcx("PODLAHA.PCX",0,360-198,639,360); - printf("Vytvoreny soubory STROP.PCX a PODLAHA.PCX\n"); - - } - diff --git a/UTILS/ITEMLIST.C b/UTILS/ITEMLIST.C deleted file mode 100644 index c06e6b0..0000000 --- a/UTILS/ITEMLIST.C +++ /dev/null @@ -1,328 +0,0 @@ -#include -#include -#include -#include -#include - -#define SV_ITLIST 0x8001 -#define SV_SNDLIST 0x8002 -#define SV_END 0x8000 - - -typedef struct titem - { - char jmeno[32]; //32 Jmeno predmetu - char popis[32]; //64 - short zmeny[24]; //112 Tabulka, jakych zmen ma na hracovy vlastnosti - short podminky[4];//120 Tabulka, jake vlastnosti musi mit hrac k pouziti predmetu - short hmotnost,nosnost,druh; //126 druh = Typ predmetu - short umisteni; //128 Kam se predmet umisti? - word flags; //130 ruzne vlajky - short spell,magie,sound_handle;//136 specialni kouzla / rukojet zvuku - short use_event; //140 specialni udalost - unsigned short ikona,vzhled; //144 ikony a vzhled - short user_value; //146 uzivatelska hodnota - short keynum; //148 cislo klice - short polohy[2][2]; //156 souradnice poloh pro zobrazeni v inv - char typ_zbrane; //160 Typ zbrane - char unused; - short sound; //cislo zvuku - short v_letu[16]; //192 - int cena; - char weapon_attack; //relativni handle k souboru s animaci utok - char hitpos; //pozice zasahu animace - short rezerva[13]; //224 rezervovane - }TITEM; - -#define isweapon(p) ((p)>=1 && (p)<=3) - -char sekceid[]=""; -TITEM *itlist; -int item_count; -char *sound; -char listsize; -int pagelen; - -char pr_name=0,pr_type=0,pr_sound=0,pr_umist=0,pr_zbran=0,pr_hmotn=0,pr_popis=0; -char grp_sort=0,pr_number=0,pr_cena=0; - -char _typy_zbrani[]= - "Meďż˝\0" - "Sekera\0" - "Kladivo\0" - "Hďż˝l\0" - "Dďż˝ka\0" - "Stďż˝elnďż˝\0" - "Ostatnďż˝\0"; - -char _typy_veci[]= - "Nespecifikovďż˝no\0" - "Zbraďż˝ tv��� v tv��\0" - "Vrhacďż˝ zbraďż˝\0" - "Stďż˝elnďż˝ zbraďż˝\0" - "Zbroj\0" - "Svitek / Hďż˝lka\0" - "Lektvar\0" - "Voda\0" - "Jďż˝dlo\0" - "Speciďż˝lnďż˝\0" - "Runa\0" - "Penďż˝ze\0" - "Svitek s textem\0" - "Prach\0" - "Ostatnďż˝\0"; - -char _umisteni_veci[]= - "Nikam\0" - "Zavazadlo\0" - "Na tďż˝lo (nahoďż˝e)\0" - "Na tďż˝lo (dole)\0" - "Na hlavu\0" - "Na nohy\0" - "Kutna\0" - "Na krk\0" - "Do ruky\0" - "Obouruďż˝\0" - "Prsten\0" - "��p\0"; - - -long load_section(FILE *f,void **section, int *sct_type,long *sect_size) -// - { - long s; - char c[20]; - - *section=NULL; - fread(c,1,sizeof(sekceid),f); - if (strcmp(c,sekceid)) return -1; - fread(sct_type,1,sizeof(*sct_type),f); - fread(sect_size,1,sizeof(*sect_size),f); - fread(&s,1,sizeof(s),f); - *section=malloc(*sect_size); - s=fread(*section,1,*sect_size,f); - return s; - } - -void load_items_dat(char *name) - { - FILE *f; - void *temp; - int type; - long size; - - f=fopen(name,"rb"); - if (f==NULL) - { - printf("Nemohu otevrit soubor %s\n",name); - exit(1); - } - do - { - load_section(f,&temp,&type,&size); - switch (type) - { - case SV_ITLIST:itlist=temp;item_count=size/sizeof(TITEM);break; - case SV_SNDLIST:sound=temp;listsize=size;break; - - case SV_END: - default: free(temp);break; - } - } - while (type!=SV_END); - fclose(f); - } - -char *find_str(char *sound,int number,long listsize) - { - char *c; - static char none[]=""; - static char unknown[]=""; - - c=sound; - if (!number) return none; - number--; - while (c-soundjmeno); - if (pr_type) printf("%-20sďż˝",find_str(_typy_veci,t->druh+1,sizeof(_typy_veci))); - if (pr_umist) printf("%-20sďż˝",find_str(_umisteni_veci,t->umisteni+1,sizeof(_umisteni_veci))); - if (pr_zbran) printf("%-10sďż˝",isweapon(t->druh)?find_str(_typy_zbrani,t->typ_zbrane+1,sizeof(_typy_zbrani)):" "); - if (pr_hmotn) printf("%6dďż˝",t->hmotnost); - if (pr_cena) printf("%6dďż˝",t->cena); - if (pr_sound) printf("%-12sďż˝",find_str(sound,t->sound,listsize)); - if (pr_popis) printf("%s",t->popis); - puts(""); - } - -void print_head() - { - int lines=0; - if (pr_number) printf("ID "),lines+=4; - if (pr_name) printf("%-32s ","Jmeno veci"),lines+=33; - if (pr_type) printf("%-20s ","Typ veci"),lines+=21; - if (pr_umist) printf("%-20s ","Umisteni"),lines+=21; - if (pr_zbran) printf("%-10s ","Zbran"),lines+=11; - if (pr_hmotn) printf("%-6s ","Vaha"),lines+=7; - if (pr_cena) printf("%-6s ","Cena"),lines+=7; - if (pr_sound) printf("%-12s ","Zvuk"),lines+=13; - if (pr_popis) printf("%s","Popis"),lines+=6; - puts(""); - if (lines) while (lines--) putc(196,stdout); - puts(""); - } - -void endpage(int i) - { - if (pagelen && i%pagelen==0) - { - if (i) putc(12,stdout); - print_head(); - } - } - -void counting_sort(TITEM *sr,TITEM *tg,int count,int *idnums) - { - int tridy[30][20]; - int i,j,c; - TITEM *s; - - memset(tridy,0,sizeof(tridy)); - for(i=0,s=sr;idruh][isweapon(s->druh)?s->typ_zbrane:0]++; - c=0; - for(i=0;i<30;i++) - for(j=0;j<20;j++) - { - register int d; - d=tridy[i][j]; - tridy[i][j]=c; - c+=d; - } - for(i=0,s=sr;idruh][isweapon(s->druh)?s->typ_zbrane:0]++; - tg[c]=*s; - idnums[c]=i; - } - } - -void print_list() - { - int i; - TITEM *t; - - if (!pagelen) print_head(); - if (!grp_sort) - { - for(i=0,t=itlist;i" - VALUE "FileDescription", "TODO: " - VALUE "FileVersion", "1.0.0.1" - VALUE "InternalName", "Podlahar.exe" - VALUE "LegalCopyright", "TODO: (c) . All rights reserved." - VALUE "OriginalFilename","Podlahar.exe" - VALUE "ProductName", "TODO: " - VALUE "ProductVersion", "1.0.0.1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 1252 - END -END - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_ABOUTBOX, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 228 - TOPMARGIN, 7 - BOTTOMMARGIN, 48 - END - IDD_PODLAHAR_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 313 - TOPMARGIN, 7 - BOTTOMMARGIN, 193 - END -END -#endif // APSTUDIO_INVOKED - - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDS_ABOUTBOX "&About Podlahar..." -END - - -#endif -#ifdef _UNICODE -IDR_MANIFEST RT_MANIFEST "res\\Podlahar.manifest" -#endif - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 -#pragma code_page(1252) -#include "res\\Podlahar.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#endif -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/UTILS/Podlahar/Podlahar.vcproj b/UTILS/Podlahar/Podlahar.vcproj deleted file mode 100644 index c69a540..0000000 --- a/UTILS/Podlahar/Podlahar.vcproj +++ /dev/null @@ -1,193 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/UTILS/Podlahar/PodlaharDlg.cpp b/UTILS/Podlahar/PodlaharDlg.cpp deleted file mode 100644 index 3190b1f..0000000 --- a/UTILS/Podlahar/PodlaharDlg.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// PodlaharDlg.cpp : implementation file -// - -#include "stdafx.h" -#include "Podlahar.h" -#include "PodlaharDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - enum { IDD = IDD_ABOUTBOX }; - - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) -END_MESSAGE_MAP() - - -// CPodlaharDlg dialog - -BEGIN_DHTML_EVENT_MAP(CPodlaharDlg) - DHTML_EVENT_ONCLICK(_T("ButtonOK"), OnButtonOK) - DHTML_EVENT_ONCLICK(_T("ButtonCancel"), OnButtonCancel) -END_DHTML_EVENT_MAP() - - -CPodlaharDlg::CPodlaharDlg(CWnd* pParent /*=NULL*/) - : CDHtmlDialog(CPodlaharDlg::IDD, CPodlaharDlg::IDH, pParent) -{ - m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); -} - -void CPodlaharDlg::DoDataExchange(CDataExchange* pDX) -{ - CDHtmlDialog::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(CPodlaharDlg, CDHtmlDialog) - ON_WM_SYSCOMMAND() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -// CPodlaharDlg message handlers - -BOOL CPodlaharDlg::OnInitDialog() -{ - CDHtmlDialog::OnInitDialog(); - - // Add "About..." menu item to system menu. - - // IDM_ABOUTBOX must be in the system command range. - ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); - ASSERT(IDM_ABOUTBOX < 0xF000); - - CMenu* pSysMenu = GetSystemMenu(FALSE); - if (pSysMenu != NULL) - { - CString strAboutMenu; - strAboutMenu.LoadString(IDS_ABOUTBOX); - if (!strAboutMenu.IsEmpty()) - { - pSysMenu->AppendMenu(MF_SEPARATOR); - pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); - } - } - - // Set the icon for this dialog. The framework does this automatically - // when the application's main window is not a dialog - SetIcon(m_hIcon, TRUE); // Set big icon - SetIcon(m_hIcon, FALSE); // Set small icon - - // TODO: Add extra initialization here - - return TRUE; // return TRUE unless you set the focus to a control -} - -void CPodlaharDlg::OnSysCommand(UINT nID, LPARAM lParam) -{ - if ((nID & 0xFFF0) == IDM_ABOUTBOX) - { - CAboutDlg dlgAbout; - dlgAbout.DoModal(); - } - else - { - CDHtmlDialog::OnSysCommand(nID, lParam); - } -} - -// If you add a minimize button to your dialog, you will need the code below -// to draw the icon. For MFC applications using the document/view model, -// this is automatically done for you by the framework. - -void CPodlaharDlg::OnPaint() -{ - if (IsIconic()) - { - CPaintDC dc(this); // device context for painting - - SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); - - // Center icon in client rectangle - int cxIcon = GetSystemMetrics(SM_CXICON); - int cyIcon = GetSystemMetrics(SM_CYICON); - CRect rect; - GetClientRect(&rect); - int x = (rect.Width() - cxIcon + 1) / 2; - int y = (rect.Height() - cyIcon + 1) / 2; - - // Draw the icon - dc.DrawIcon(x, y, m_hIcon); - } - else - { - CDHtmlDialog::OnPaint(); - } -} - -// The system calls this function to obtain the cursor to display while the user drags -// the minimized window. -HCURSOR CPodlaharDlg::OnQueryDragIcon() -{ - return static_cast(m_hIcon); -} -HRESULT CPodlaharDlg::OnButtonOK(IHTMLElement* /*pElement*/) -{ - OnOK(); - return S_OK; -} - -HRESULT CPodlaharDlg::OnButtonCancel(IHTMLElement* /*pElement*/) -{ - OnCancel(); - return S_OK; -} diff --git a/UTILS/Podlahar/PodlaharDlg.h b/UTILS/Podlahar/PodlaharDlg.h deleted file mode 100644 index c2dd19c..0000000 --- a/UTILS/Podlahar/PodlaharDlg.h +++ /dev/null @@ -1,34 +0,0 @@ -// PodlaharDlg.h : header file -// - -#pragma once - - -// CPodlaharDlg dialog -class CPodlaharDlg : public CDHtmlDialog -{ -// Construction -public: - CPodlaharDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - enum { IDD = IDD_PODLAHAR_DIALOG, IDH = IDR_HTML_PODLAHAR_DIALOG }; - - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - - HRESULT OnButtonOK(IHTMLElement *pElement); - HRESULT OnButtonCancel(IHTMLElement *pElement); - -// Implementation -protected: - HICON m_hIcon; - - // Generated message map functions - virtual BOOL OnInitDialog(); - afx_msg void OnSysCommand(UINT nID, LPARAM lParam); - afx_msg void OnPaint(); - afx_msg HCURSOR OnQueryDragIcon(); - DECLARE_MESSAGE_MAP() - DECLARE_DHTML_EVENT_MAP() -}; diff --git a/UTILS/Podlahar/Resource.h b/UTILS/Podlahar/Resource.h deleted file mode 100644 index fe47f49..0000000 --- a/UTILS/Podlahar/Resource.h +++ /dev/null @@ -1,23 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by Podlahar.RC -// -#define IDR_MAINFRAME 128 -#define IDM_ABOUTBOX 0x0010 -#define IDD_ABOUTBOX 100 -#define IDS_ABOUTBOX 101 -#define IDD_PODLAHAR_DIALOG 102 -#define IDR_HTML_PODLAHAR_DIALOG 104 -#define IDR_MANIFEST CREATEPROCESS_MANIFEST_RESOURCE_ID - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS - -#define _APS_NEXT_RESOURCE_VALUE 129 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 32771 -#endif -#endif diff --git a/UTILS/Podlahar/res/Podlahar.ico b/UTILS/Podlahar/res/Podlahar.ico deleted file mode 100644 index 8a84ca3..0000000 Binary files a/UTILS/Podlahar/res/Podlahar.ico and /dev/null differ diff --git a/UTILS/Podlahar/res/Podlahar.rc2 b/UTILS/Podlahar/res/Podlahar.rc2 deleted file mode 100644 index 426f164..0000000 --- a/UTILS/Podlahar/res/Podlahar.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// Podlahar.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/UTILS/Podlahar/stdafx.cpp b/UTILS/Podlahar/stdafx.cpp deleted file mode 100644 index 58f9651..0000000 --- a/UTILS/Podlahar/stdafx.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// Podlahar.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - diff --git a/UTILS/Podlahar/stdafx.h b/UTILS/Podlahar/stdafx.h deleted file mode 100644 index eabf8b7..0000000 --- a/UTILS/Podlahar/stdafx.h +++ /dev/null @@ -1,43 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. -#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. -#endif - -#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. -#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. -#endif - -#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. -#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later. -#endif - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions -#include // MFC Automation classes - -#include // MFC support for Internet Explorer 4 Common Controls -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // HTML Dialogs diff --git a/VIDEO/ANIPACK.ASM b/VIDEO/ANIPACK.ASM deleted file mode 100644 index bc41e1f..0000000 --- a/VIDEO/ANIPACK.ASM +++ /dev/null @@ -1,318 +0,0 @@ -.model small -.386 -;16 bit line (de)comprimator -; -DGROUP group _DATA - -extern _anim_line_len:dword - - -_TEXT segment byte public 'CODE' use32 - assume CS:_TEXT - assume DS:DGROUP - - - -save_line1 macro reg1,reg2 - shr reg1,8 - rcr reg2,1 - shr reg1,8 - rcr reg2,1 - shr reg1,8 - rcr reg2,1 - shr reg1,8 - rcr reg2,1 -endm - -save_linex macro reg1,reg2,rols - shrd reg2,reg1,rols - shr reg1,8 - shrd reg2,reg1,rols - shr reg1,8 - shrd reg2,reg1,rols - shr reg1,8 - shrd reg2,reg1,rols -endm - - -public save_1bit_ ;ESI source - ;EDI target - ;vraci EDI ukazatel na konce; -save_1bit_: - mov cl,8 -s1b1: lodsd - save_linex eax,ebx,1 - dec cl - jnz s1b1 - mov eax,ebx - stosd - mov cl,8 -s1b2: lodsd - save_linex eax,ebx,1 - dec cl - jnz s1b2 - mov eax,ebx - stosd - ret - -public save_2bit_ -save_2bit_: - mov ch,4 -c2b11: mov cl,4 -c2b12: lodsd - save_linex eax,ebx,2 - dec cl - jnz c2b12 - mov eax,ebx - stosd - dec ch - jnz c2b11 - ret - -public save_3bit_ -save_3bit_: - mov ch,8 -c3b11: mov cl,2 -c3b12: lodsd - save_linex eax,ebx,3 - dec cl - jnz c3b12 - mov eax,ebx - shr eax,8 - stosd - dec edi - dec ch - jnz c3b11 - ret - -public save_4bit_ -save_4bit_: - mov ch,8 -c4b11: mov cl,2 -c4b12: lodsd - save_linex eax,ebx,4 - dec cl - jnz c4b12 - mov eax,ebx - stosd - dec ch - jnz c4b11 - ret - - -public load_1bit_ ;ESI - Source - ;EDI - Target - ;EBX - Palette - ;anim_line_len - delka radky -load_1bit_ : - mov ch,8 -l1b1: mov dl,[esi] - inc esi - mov cl,8 -l1b2: movzx eax,dl - and eax,1 - mov eax,[ebx+eax*2] - test eax,8000h - jnz short l1b1s - mov [edi],ax -l1b1s: add edi,2 - shr dl,1 - dec cl - jnz l1b2 - mov eax,_anim_line_len - sub eax,16 - add edi,eax - dec ch - jnz l1b1 - ret - -public load_2bit_ ;ESI - Source - ;EDI - Target - ;EBX - Palette - ;anim_line_len - delka radky -load_2bit_: - mov ch,8 -l2b1: mov dx,[esi] - add esi,2 - mov cl,8 -l2b2: mov eax,edx - and eax,3 - mov eax,[ebx+eax*2] - test eax,8000h - jnz short l2b1s - mov [edi],ax -l2b1s: add edi,2 - shr edx,2 - dec cl - jnz l2b2 - mov eax,_anim_line_len - sub eax,16 - add edi,eax - dec ch - jnz l2b1 - ret - -public load_3bit_ ;ESI - Source - ;EDI - Target - ;EBX - Palette - ;anim_line_len - delka radky -load_3bit_: - mov ch,8 -l3b1: mov edx,[esi] - add esi,3 - mov cl,8 -l3b2: mov eax,edx - and eax,7 - mov eax,[ebx+eax*2] - test eax,8000h - jnz short l3b1s - mov [edi],ax -l3b1s: add edi,2 - shr edx,3 - dec cl - jnz l3b2 - mov eax,_anim_line_len - sub eax,16 - add edi,eax - dec ch - jnz l3b1 - ret - -public load_4bit_ ;ESI - Source - ;EDI - Target - ;EBX - Palette - ;anim_line_len - delka radky -load_4bit_: - mov ch,8 -l4b1: mov edx,[esi] - add esi,4 - mov cl,8 -l4b2: mov eax,edx - and eax,15 - mov eax,[ebx+eax*2] - test eax,8000h - jnz short l4b1s - mov [edi],ax -l4b1s: add edi,2 - shr edx,4 - dec cl - jnz l4b2 - mov eax,_anim_line_len - sub eax,16 - add edi,eax - dec ch - jnz l4b1 - ret - -public load_8bit_ ;ESI - Source - ;EDI - Target - ;EBX - Palette - ;anim_line_len - delka radky -load_8bit_: - mov ch,8 -l8b1: mov cl,8 -l8b2: lodsb - movzx eax,al - mov eax,[ebx+eax*2] - test eax,8000h - jnz short l8b1s - mov [edi],ax -l8b1s: add edi,2 - dec cl - jnz l8b2 - mov eax,_anim_line_len - sub eax,16 - add edi,eax - dec ch - jnz l8b1 - ret - -public load_0bit_ ;EDI - Target - ;EBX - Palette - ;anim_line_len - delka radky -load_0bit_: - movzx eax,word ptr[ebx] - test eax,8000h - jnz l0b1s - mov ebx,eax - shl ebx,16 - or eax,ebx - mov ch,8 -l0b1: mov cl,4 -l0b2: stosd - dec cl - jnz l0b2 - mov edx,_anim_line_len - sub edx,16 - add edi,edx - dec ch - jnz l0b1 -l0b1s: ret - - -public display_interlaced_fused_lfb_ - ;ESI buffer1 - ;EBX buffer2 - ;EDI screen - -;vezme buffer 1 a sfuzuje s bufferem 2, predtim ovsem prepise buffer2 bufferem 1 -;pracuje s lfb -display_interlaced_fused_lfb_: - mov ecx,180 -dif_lp1:push ecx - mov ecx,320 -dif_lp2:lodsd - mov edx,eax - xchg edx,[ebx] - and eax,7bde7bdeh - and edx,7bde7bdeh - add eax,edx - shr eax,1 - stosd - add ebx,4 - dec ecx - jnz dif_lp2 - pop ecx - add edi,1280 - dec ecx - jnz dif_lp1 - ret - -extern mapvesaadr_:near - -public display_interlaced_fused_bank_ - ;ESI buffer1 - ;EBX buffer2 - ;EDI screen - -;vezme buffer 1 a sfuzuje s bufferem 2, predtim ovsem prepise buffer2 bufferem 1 -;pracuje s lfb -display_interlaced_fused_bank_: - mov ecx,180 -difblp1:push ecx - push edi - call mapvesaadr_ - mov ecx,320 -difblp2:lodsd - mov edx,eax - xchg edx,[ebx] - and eax,7bde7bdeh - and edx,7bde7bdeh - add eax,edx - shr eax,1 - stosd - add ebx,4 - dec ecx - jnz difblp2 - pop edi - pop ecx - add edi,4096 - dec ecx - jnz difblp1 - ret - - - - -_TEXT ends -end diff --git a/VIDEO/ANIPACK.H b/VIDEO/ANIPACK.H deleted file mode 100644 index 5d4649c..0000000 --- a/VIDEO/ANIPACK.H +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef __ANIPACK_H - -#define __ANIPACK_H - -int anim_line_len=1280; - -void load_0bit(void *target,void *palette); -void *load_1bit(void *source,void *target,void *palette); -void *load_2bit(void *source,void *target,void *palette); -void *load_3bit(void *source,void *target,void *palette); -void *load_4bit(void *source,void *target,void *palette); -void *load_8bit(void *source,void *target,void *palette); -#pragma aux load_0bit parm [EDI][EBX] modify [EAX ECX EDX] -#pragma aux load_1bit parm [ESI][EDI][EBX] modify [EAX ECX EDX] value [esi] -#pragma aux load_2bit parm [ESI][EDI][EBX] modify [EAX ECX EDX] value [esi] -#pragma aux load_3bit parm [ESI][EDI][EBX] modify [EAX ECX EDX] value [esi] -#pragma aux load_4bit parm [ESI][EDI][EBX] modify [EAX ECX EDX] value [esi] -#pragma aux load_8bit parm [ESI][EDI][EBX] modify [EAX ECX] value [esi] - -void *save_1bit(void *source,void *target); -#pragma aux save_1bit parm[esi][edi] modify [eax ebx] value[edi]; - -void *save_2bit(void *source,void *target); -#pragma aux save_2bit parm[esi][edi] modify [eax ebx] value[edi]; - -void *save_3bit(void *source,void *target); -#pragma aux save_3bit parm[esi][edi] modify [eax ebx] value[edi]; - -void *save_4bit(void *source,void *target); -#pragma aux save_4bit parm[esi][edi] modify [eax ebx] value[edi]; - - -void display_interlaced_fused_lfb(void *buff1,void *buff2,void *lfb); -#pragma aux display_interlaced_fused_lfb parm [esi][ebx][edi]modify [ecx edx eax] - -void display_interlaced_fused_bank(void *buff1,void *buff2,void *scr); -#pragma aux display_interlaced_fused_bank parm [esi][ebx][edi]modify [ecx edx eax] - -#endif diff --git a/VIDEO/BITLINE.ASM b/VIDEO/BITLINE.ASM deleted file mode 100644 index c3dfe76..0000000 --- a/VIDEO/BITLINE.ASM +++ /dev/null @@ -1,342 +0,0 @@ -.model small -.386 -;16 bit line (de)comprimator -; -_TEXT segment byte public 'CODE' use32 - assume CS:_TEXT - assume DS:DGROUP - - - -cwrite macro REG,BIT ;zapise al do [di] pouze BIT bitu ze zadu - local cwrit2 - shl edx,BIT ;posun EDX o pripraveny pocet bitu - and REG,0ffh shr (8-BIT) ;odmaskuj pripadne bity v REG - or dl,REG ;pridej REG do dl - add ch,BIT ;pripocti pridany pocet bitu - cmp ch,8 ;jestli to preteklo - jc cwrit2 ;ne, vse je OK - sub ch,8 ;ano pak odecti 8 bitu - mov cl,8 ;cl=8-ch; - sub cl,ch ; - shl edx,cl ;tj kolik zbejva posunout. - mov [edi],dh ;zapis osmice - shr dl,cl ;vrat dl do puvodniho stavu - inc edi ;dalsi adresa -cwrit2: -endm - -cwrit8 macro REG ;zapise 8 bitu do [EDI] - shl edx,8 ;posun 8 bitu - or dl,REG ;sfuzuj - mov cl,8 ;kolik urcite preteklo - sub cl,ch ;a o kolik teda posunout - shl edx,cl ;posun na dorovnani na bajt - mov [edi],dh ;zapis bajt - shr dl,cl ;spodek vrat do puvodniho stavu. - inc edi ;dalsi adresa -endm - -write_ax: ;zapisuje AX do [edi] v komprimovanem tvaru - ;hodnoty - ; 0 ... 000 - ; 1 ... 001 - ; 2 ... 010 - ; 3 ... 011 - ; 4 ... 100 - ; 5 ... 101 - ; 6 ... 110 - ; 7 ... 11100000 - ; 8 ... 11100001 - ; 9 ... 11100010 - ;10 ... - ;... - ;37 ... 11111110 - ;38 ... 1111111100000000 - ;39 ... 1111111100000001 - ; - ;291 .. 1111111111111101 - ;292 .. 1111111111111110 - ;>293 .. 1111111111111111 Lo Hi - - cmp eax,293 ;eax>293 (7+31+255) - jnc wr_16 ;zapis 16 bitove hodnoty - cmp al,38 ;eax>38 (7+31) - jnc wr_8 ;zapis 8 bitove hodnoty - cmp al,7 ;eax>7 - jnc wr_5 ;zapis 5 bitove hodnoty - cwrite al,3 ;pro cisla eax<7 (0..6) staci 3 bity - ret ;konec -wr_16: sub eax,293 ;odecti to co je zname - mov cl,0ffh ;zapis dvou hodnot 255 jako znacka ze nasleduje - cwrit8 cl ;16 bitova hodnota - mov cl,0ffh - cwrit8 cl - cwrit8 al ;zapis nizsi - mov al,ah - cwrit8 ah ;zapis vyssi - ret -wr_5: sub al,7 ;odecti co zname - or al,0E0h ;tri bity na 1 znaci 5 bitovou hodnotu - cwrit8 al ;zapis to - ret -wr_8: sub al,38 ;odecti to co je uz zname. - mov cl,0ffh ;zapis jedne hodnoty 255 znaci 8 bitovou hodnotu - cwrit8 cl ;zapis ji - cwrit8 al ;zapis al - ret - - -;vsechny mody - -; vstup: ESI - data -; EDI - buffer -; ECX - delka dat (max 65535) -; EBX - bitova rovina (bit na pozici roviny = 1) - -flush macro - local fjmp - shr ecx,16 - or ch,ch - jz fjmp - mov eax,7 - call write_ax -fjmp: -endm - -public cmode0_ -cmode0_: ;komprimuje pro mod 11110000 (uvazuji se retezce 00001 nebo 11110 pricemz - ; 0000111110 se pocita vcetne rozdilu ( - ; \---/\---/ - ; 4 4 tj 100100 - - - push ebp - xor edx,edx - xor ebp,ebp - xor eax,eax -cmode0b: lodsw - and ax,bx - cmp ax,bp - jnz cmode0a - add eax,10000h - dec cx - jnz cmode0b - shr eax,16 - shr ecx,16 - call write_ax - flush - pop ebp - ret -cmode0a: xor ebp,ebx - shr eax,16 - rol ecx,16 - call write_ax - rol ecx,16 - dec cx - jnz cmode0b - flush - pop ebp - ret - -public cmode1_ - -cmode1_: ;komprimuje pro mod 00010001 - ;komprimuje se vcetne jednicky tj - ; - ;000100001 - ;\--/\---/ - ; 3 4 tj 011100 - xor edx,edx - xor eax,eax -cmode1b: lodsw - and ax,bx - jnz cmode1a - add eax,10000h - dec cx - jnz cmode1b - shr eax,16 - shr ecx,16 - call write_ax - flush - ret -cmode1a: shr eax,16 - rol ecx,16 - call write_ax - rol ecx,16 - dec cx - jnz cmode1b - flush - ret - -public cmode2_ - -cmode2_: ;komprimuje pro mod 11101110 - ;komprimuje se vcetne 0 tj - ; - ;111101011110111110 - ;\---/\/\---/\----/ - ; 4 1 4 4 tj 100001100100 - xor edx,edx - xor eax,eax -cmode2b: lodsw - and ax,bx - jz cmode2a - add eax,10000h - dec cx - jnz cmode2b - shr eax,16 - shr ecx,16 - call write_ax - flush - ret -cmode2a: shr eax,16 - rol ecx,16 - call write_ax - rol ecx,16 - dec cx - jnz cmode2b - flush - ret - -public cmode3_ -cmode3_: ;kopiruje rovinu - mov edx,8 ;8 bitu -cmode3b: lodsw ;cti slovo - and ax,bx ;kontroluj rovinu - cmp ax,bx ;nastav carry podle vysledku - cmc ;ale spravne - rcl dh,1 ;soupni ho do dh - dec dl ;dalsi pozice - jnz cmode3a ;kdyz to neni vse pokracuj - mov [edi],dl ;je to vse - inc edi ;dalsi bajt - mov edx,8 ;dalsich 8 bitu -cmode3a: dec ecx ;dalsi slovo - jnz cmode3b ;dokud to neni vse. - cmp dl,8 - jz cmode3c - mov cl,dl - shl dh,cl - mov [edi],dh - inc edi -cmode3c: ret - - -; DEKOMPRIMACE - -cread macro REG,BIT - local crd1 - mov cl,BIT - cmp ch,cl ;zjisti zda pocet zbylych bitu - jnc crd1 ;neni nahodou min nez potrebnych - mov cl,ch ;ano, tj posun ty zbyle do dh - shl edx,cl - mov dl,[esi] ;do dl vloz dalsi bajt - inc esi ;a zvys adresu - sub cl,BIT ;odecti pocet pozadovanych bitu - mov ch,8 ;to je aktualizovana hodnota noveho ch - neg cl ;v cl je nyni mnozstvi chybejicich bitu -crd1: shl edx,cl ;prisun je do dh - sub ch,cl - mov REG,dh ;vem je do REG - and REG,0xff shr (8-BIT) ;odmaskuj horejsek -endm - -;vsechny mody - -; vstup: ESI - data -; EDI - vysledek -; ECX - delka dat (max 65535) -; EBX - bitova rovina (bit na pozici roviny = 1) - -cread_ax macro - local crd_ok - rol ecx,16 ;nejdriv schovej cx v horni pulce - xor eax,eax ;vynuluj eax - cread al,3 ;nacti 3 bity - cmp al,7 ;pokud to da hodnotu 7 pak pokracuj - jnz crd_ok ;jinak jsem hotov - cread al,5 ;nacti dalsi 5 bitu - add al,7 ;pricti ztracenych 7 - cmp al,38 ;pokracuj kdyz to da dohromady 38 - jnz crd_ok - cread al,8 ;nacti 8 bitu - add eax,38 ;a pricti 38 - cmp eax,293 ;pokracuj kdyz to da 293 - jnz crd_ok - cread al,8 ;precti dalsi 8 bitu - cread ah,8 ;Nejdriv dolni a pak horni - add eax,293 -crd_ok: rol ecx,16 ;obnov cx - -endm - -public cread0_ -cread0_: and ecx,0ffffh ;vynuluj horni pulku ecx - xor edx,edx ;vynuluj pamet bitu - cread_ax ;precti prvni zaznam - or eax,eax ;je li 0 zaciname jednickami - jnz cread0a -cread0c: cread_ax ;precti zaznam - inc eax ;+1 -cread0b: xor [edi],bx ;invertuj rovinu - add edi,2 - dec ecx ;odecitej ecx - dec eax ;odecti citac - jnz cread0b ;dokud neni ax=0 - or cx,cx ;kontrola zda nejsme na konci - jz cread0e ;kdyz ne - cread_ax ;precti dalsi zaznam - inc eax ;+1 -cread0a: sub cx,ax ;ted se jenom preskoci - jz cread0e ;ale kdyz jsme na konci tak nic nedelej - shl eax,1 ;preskoci 2*eax bajtu - add edi,eax ;skok! - jmp cread0c ;a jedem znova. -cread0e: ret - -public cread1_ -cread1_: and ecx,0ffffh - xor edx,edx -cread1a: cread_ax ;cti zaznam - add edi,eax ;preskoc EAX bajtu a zapis 1 - xor [edi],ebx - add edi,2 - dec ecx ;jedna za jeden bod - sub cx,ax ;a jeste ax bajtu - jnz cread1a ;jeste to neni vse? - ret - -public cread2_ -cread2_: and ecx,0ffffh - xor edx,edx -cread2a: cread_ax ;cti zaznam - add edi,eax ;zapis EAX bajtu a preskoc 1 -cread2b: xor [edi],ebx - add edi,2 - dec ecx ;jedna za jeden bod - dec eax - jnz cread2b - add edi,2 - dec ecx - jnz cread2a - ret - -public cread3_ -cread3_: mov dh,8 ;dh - citac bitu - mov dl,[esi] ;vezmi prvni osmici - inc esi ;zvys adresu -cread3b: shl dl,1 ;nacti bit do cf - sbb eax,eax ;je-li nastaven je vysledek 0xffffffff - and eax,ebx ;nastav prislusnou rovinu - xor [edi],ax ;proved XOR - add edi,2 ;dalsi bod - dec ecx ;odecti si ho - jz cread3a ;kdyz uz jsme na konci skok na cread3a - dec dh ;odecti citac bitu - jz cread3_ ;jakmile klesne na nulu zacni od zacatku - jmp cread3b ;jinak opakuj. -cread3a: ret - -_TEXT ends - -END diff --git a/VIDEO/BITLINE.H b/VIDEO/BITLINE.H deleted file mode 100644 index c0b8c4b..0000000 --- a/VIDEO/BITLINE.H +++ /dev/null @@ -1,16 +0,0 @@ -void *cmode0(void *source,void *target,int count,int rovina); -#pragma aux cmode0 parm [ESI][EDI][ECX][EBX] modify [EAX EDX] value [EDI]; -void *cmode1(void *source,void *target,int count,int rovina); -#pragma aux cmode1 parm [ESI][EDI][ECX][EBX] modify [EAX EDX] value [EDI]; -void *cmode2(void *source,void *target,int count,int rovina); -#pragma aux cmode2 parm [ESI][EDI][ECX][EBX] modify [EAX EDX] value [EDI]; -void *cmode3(void *source,void *target,int count,int rovina); -#pragma aux cmode3 parm [ESI][EDI][ECX][EBX] modify [EAX EDX] value [EDI]; -void *cread0(void *source,void *target,int count,int rovina); -#pragma aux cread0 parm [ESI][EDI][ECX][EBX] modify [EAX EDX] value [EDI]; -void *cread1(void *source,void *target,int count,int rovina); -#pragma aux cread1 parm [ESI][EDI][ECX][EBX] modify [EAX EDX] value [EDI]; -void *cread2(void *source,void *target,int count,int rovina); -#pragma aux cread2 parm [ESI][EDI][ECX][EBX] modify [EAX EDX] value [EDI]; -void *cread3(void *source,void *target,int count,int rovina); -#pragma aux cread3 parm [ESI][EDI][ECX][EBX] modify [EAX EDX] value [EDI]; diff --git a/VIDEO/BOLDCZ.FON b/VIDEO/BOLDCZ.FON deleted file mode 100644 index be5e16c..0000000 Binary files a/VIDEO/BOLDCZ.FON and /dev/null differ diff --git a/VIDEO/CINEMA.H b/VIDEO/CINEMA.H deleted file mode 100644 index 2cfa2de..0000000 --- a/VIDEO/CINEMA.H +++ /dev/null @@ -1,8 +0,0 @@ -#define TRACK_VIDEO 1 -#define TRACK_PALETTE 2 -#define TRACK_MUSIC 3 -#define TRACK_DELAY 4 -#define TRACK_CLEAR 5 -#define TRACK_END 0xff - - diff --git a/VIDEO/CNMBUILD.C b/VIDEO/CNMBUILD.C deleted file mode 100644 index 2cee36b..0000000 --- a/VIDEO/CNMBUILD.C +++ /dev/null @@ -1,667 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include "flc.h" -#include "anipack.h" -#include -#include "cinema.h" - -#define BOX_X 8 -#define BOX_Y 8 - -typedef int T_BOX[BOX_X*BOX_Y]; - -typedef char PALETA[256][3]; - -PALETA cur_pal; -int box_end; -T_BOX cur_box; -T_BOX sort_box; -char box_data[BOX_X*BOX_Y],conv_data[BOX_X*BOX_Y]; -char last_boxes[80][23][BOX_X*BOX_Y]; -char preview=1; -char pack_repeat=0; - -char *flc_name; - -char vystup[120000]; -char differs[120000]; -char *ip; -char bit_mode; -char same; -FILE *anim; -char *anim_name; - -word new_paleta[256],old_paleta[256]; -word play_screen[240000]; - -int per_frame=60000; -int old_per_box; -char rastry=1; -int rastry_rozliseni=100; -int per_box; -int now_calc_size; -int hranice_velikosti[][2]={ - {2,0}, - {11,1}, - {20,2}, - {21,2}, - {30,3}, - {31,3}, - {32,3}, - {33,3}, - {42,4}, - {43,4}, - {44,4}, - {45,4}, - {46,4}, - {47,4}, - {48,4}, - {49,4}, - }; - - -char compress_table[]={0,0,1,2,2,3,3,3,3,4,4,4,4,4,4,4}; -//char compress_table[]={0,0,1,2,2,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,}; -//char compress_table[]={0,0,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,}; -int hranice=0; - - -int get_distance(int col1,int col2) - { - return abs(cur_pal[col1][0]-cur_pal[col2][0])+ - abs(cur_pal[col1][1]-cur_pal[col2][1])+ - abs(cur_pal[col1][2]-cur_pal[col2][2]); - } - - - -void create_differs() - { - word *c; - char *d,*e; - int i; - int j,k,x; - - j=0;k=0x7fffffff; - for(i=1;i<256;i++) - if ((x=get_distance(0,i))<= - k) - { - k=x;j=i; - } - c=play_screen; - d=frame_buffer; - e=differs; - for(i=0;i<120000;i++,c++,d++,e++) - { - if (!*d) *d=j; - if (*c!=new_paleta[*d]) - *e=*d; - else - *e=0; - } - } - -void box_read(int xbox,int ybox) - { - int x,y,k; - char *a,*bd; - - same=1; - box_end=0; - bd=box_data; - a=differs; - memset(cur_box,0xff,sizeof(cur_box)); - xbox=BOX_X*xbox; - ybox=BOX_Y*ybox; - a+=640*ybox+xbox; - for(y=ybox;y>3); - g=(flc_paleta[i][1]>>3); - b=(flc_paleta[i][2]>>3); - new_paleta[i]=(r<<10)+(g<<5)+b; - } - memcpy(cur_pal,flc_paleta,sizeof(flc_paleta)); - new_paleta[0]=0x8000; - } - -/* -void set_vga_palette() - { - int x; - char *c; - - c=cur_pal; - outp (0x3c8 - , 0); - for (x=0; x<768; x++,c++) - { - while (inp(0x3da) & 1); - while (!(inp(0x3da) & 1)); - outp (0x3c9,*c); - } - } - - -void get_vga_palette() - { - int x; - char *c; - - c=cur_pal; - outp (0x3c7, 0); - for (x=0; x<768; x++,c++) - { - while (inp(0x3da) & 1); - while (!(inp(0x3da) & 1)); - *c=inp (0x3c9); - } - cur_pal[0][0]=0; - cur_pal[0][1]=0; - cur_pal[0][2]=0;} - */ - - - - -/*void box_analize() - { - int i,c; - int r,g,b; - - for(i=0;i=0 && (ds=get_distance(c,cur_box[i]))>max) - { - j=i;max=ds; - } - } - if (j>=0) - { - c=cur_box[j]; - sort_box[d++]=c; - cur_box[j]=-1; - a=j; - } - if (max>hranice) - { - z=d; - } - } - while (j!=-1); - if (box_end>1) box_end=z; - } - -int zvol_metodu() - { - int i=0; - - for(;hranice_velikosti[i][0]>1) & 1) ^ ((i>>3) & 1)) && indx2!=-1) indx=subst[c]; - if (sort_box[0]==0 && c && last_boxes[x][y][i]!=0 && get_distance(c,last_boxes[x][y][i])=sizeof(compress_table)) - { - int i; - - *ip++=64; - memcpy(ip,box_data,sizeof(box_data)); - memcpy(conv_data,box_data,sizeof(box_data)); - for(i=0;i(i=zvol_metodu())) box_end=i; - save_box(x,y); - } - -void conv_pict() - { - int i,j,count=0; - - pack_repeat=0; - now_calc_size=0; - conv_pal_hicolor(); - create_differs(); - ip=vystup; - old_per_box=-1; - for(i=0;i<23;i++) - for(j=0;j<80;j++) - { - per_box=(per_frame-(ip-vystup))/(80*23-count); - if (old_per_box==-1) old_per_box=per_box;else if (per_box>old_per_box)per_box+=(per_box-old_per_box); - count++; - conv_complette(j,i); - } - } - - -/* -void decompr_box(word *adr) - { - char mode; - word palxlat[16]; - int i; - - mode=*ip++; - if (mode==255) return; - if (mode<64) - { - for(i=0;i>1; - c+=2; - d+=2; - } - c+=640; - } - - } - -void save_palette() - { - int i,il,ip,ps; - for(i=0;i<256 && old_paleta[i]==new_paleta[i];i++); - il=i; - if (il==256) ip=il; - else - { - for(i=255;i>0 && old_paleta[i]==new_paleta[i];i--); - ip=i+1; - } - ps=ip-il; - if (ps) - { - i=TRACK_PALETTE; - fwrite(&i,1,1,anim); - fwrite(&il,1,2,anim); - fwrite(&ps,1,2,anim); - fwrite(&new_paleta[il],sizeof(word),ps,anim); - } - } - -void save_frame(int size) - { - int i; - - i=TRACK_VIDEO; - fwrite(&i,1,1,anim); - fwrite(&size,1,sizeof(size),anim); - fwrite(vystup,1,size,anim); - } - -void save_mark(int i) - { - fwrite(&i,1,1,anim); - } - -void int10_3(); -#pragma aux int10_3=\ - "mov eax,3"\ - "int 10h"\ - modify [eax]; - -void int10_13(); -#pragma aux int10_13=\ - "mov eax,13h"\ - "int 10h"\ - modify [eax]; - -void pack_anim() - { - int x;int size; - - Open_FLC(flc_name); - Get_first_frame(); - Decompress_frame(); - conv_pict(); - adjust_pict(); - if (preview) show_play_screen(); - size=ip-vystup;printf("Frame 1: %d \n",size); - save_palette(); - save_frame(size); - for (x=2; x<=h_flc.frames+10; x++) - { - if (x<=h_flc.frames) - { - Get_next_frame (); - Decompress_frame (); - if (preview) show_play_screen(); - } - conv_pict(); - adjust_pict(); - size=ip-vystup;printf("Frame %d: %d \n",x,size); - save_palette(); - save_frame(size); - save_mark(TRACK_DELAY); - } - save_mark(TRACK_END); - } - /* - decompr_pict(); - show_play_screen(); - getch(); - decompr_pict(); - show_play_screen(); - */ - -void load_frame() - { - int size; - fread(&size,1,sizeof(size),anim); - fread(vystup,1,size,anim); - } - -void load_palette() - { - word i; - word size; - fread(&i,1,2,anim); - fread(&size,1,2,anim); - fread(&new_paleta[i],2,size,anim); - } -/* -char play_track(FILE *anim) - { - char i; - - fread(&i,1,1,anim); - switch (i) - { - case TRACK_VIDEO: - load_frame(); - decompr_pict(); - break; - case TRACK_PALETTE: - load_palette(); - break; - case TRACK_MUSIC:break; - case TRACK_END:return 0; - case TRACK_DELAY: - show_play_screen(); - // delay(7); - break; - } - return 1; - } - - -void play_anim(FILE *anim) - { - while(play_track(anim)); - } -*/ -main(int argc,char *argv[]) - { - if (argc<3) - { - puts(""); - puts("Poziti: cnmbuild filename.flc filename.cnm [perframe] [rastry]"); - puts(""); - puts("perframe - omezeni velikosti na jeden frame"); - puts("rastry - cislo udavajici hranici pro rastrovani (0 - bez rastru)"); - return 1; - } - memset(play_screen,0xff,sizeof(play_screen)); - memset(frame_buffer,0xff,sizeof(frame_buffer)); - memset(new_paleta,0xff,sizeof(new_paleta)); - memset(last_boxes,0,sizeof(last_boxes)); - - flc_name=argv[1]; - anim_name=argv[2]; - if (argc>=4) sscanf(argv[3],"%d",&per_frame); - if (argc>=5) sscanf(argv[4],"%d",&rastry_rozliseni); - if (initmode32(NULL)) preview=0; - if (banking) - { - closemode();preview=0; - } - anim=fopen(anim_name,"wb"); - pack_anim(); - fclose(anim); - closemode(); - return 0; - } diff --git a/VIDEO/CNMCONTR.C b/VIDEO/CNMCONTR.C deleted file mode 100644 index 479fac1..0000000 --- a/VIDEO/CNMCONTR.C +++ /dev/null @@ -1,74 +0,0 @@ -#include -#include -#include -#include - -#define ERR_PARM 1 -#define ERR_STR 2 -#define ERR_NUMB 3 - - -typedef struct command_table - { - char command[20]; - void (*proc)(int frame); - }COMMAND_TABLE - -int total_commands=0; - -char paramstr[200]; -int cur_line; -char command[50]; -char errors[]="Ok.,Nespravny pocet parametru.,Chybi konec retezce.,Chybna hodnota."; - - -void extract_text(char *what,int num,char *s) - { - char *c; - char ii=0; - - c=what; - while (num && *c) - { - if (!*c) call_error(ERR_PARM); - if (*c=='\"') ii=!ii; - else if (*c==',' && !ii) num--; - c++ - } - while((*c!=',' && *c) || ii) - { - if (!*c) call_error(ERR_STR); - if (*c=='\"') ii=!ii; - *s++=*c++ - } - } - -void odstran_uvozovky(char *s) - { - char *c; - char iif=0; - - c=s; - while (*s) - { - if (*s!='\"' || iif) - { - *c++=*s; - iif=0; - } - else - iif=1; - } - } - - -int conv_to_int(char *s) - { - int i; - - if (sscanf(s,"%d",&i)!=1) return i; - call_error(ERR_NUMB) - } - - - diff --git a/VIDEO/FLC.C b/VIDEO/FLC.C deleted file mode 100644 index 420c54e..0000000 --- a/VIDEO/FLC.C +++ /dev/null @@ -1,202 +0,0 @@ -// -// Knihovna pro dekompresi FLC souboru -// - -#include -#include -#include -#include -#include -#include "flc.h" - -FILE *flc; -flcheader h_flc; -frameheader h_frame; -actionheader h_action; -char flc_paleta[256][3]; -char frame_buffer [307205]; -char *flc_buffer; -char test=1; - -void Open_FLC (char *filename) -{ - flc = fopen (filename, "rb"); - fread (&h_flc, sizeof(flcheader), 1, flc); -} - -void Close_FLC (void) -{ - fclose (flc); - free (flc_buffer); -} - -void Get_first_frame (void) -{ - fseek (flc, h_flc.offset1, SEEK_SET); - fread (&h_frame, sizeof(frameheader), 1, flc); - flc_buffer = (char*)malloc((h_frame.size-sizeof(frameheader))); - fread (flc_buffer, (h_frame.size-sizeof(frameheader)), 1, flc); -} - -void Get_next_frame (void) -{ - free (flc_buffer); - fread (&h_frame, sizeof(frameheader), 1, flc); - flc_buffer = (char*)malloc((h_frame.size-sizeof(frameheader))); - fread (flc_buffer, (h_frame.size-sizeof(frameheader)), 1, flc); -} - -void Decompress_frame (void) -{ - unsigned short x,y,z,w; - unsigned short changes, nfo_word, packets, offset, row; - int frame_pos=0,tst; - unsigned int scr_pos; - char c1, c2, c3, a; - char hi, lo; - - packets=0; - for (z=1; z<=h_frame.actions; z++) - { - memmove ( &h_action, (flc_buffer+frame_pos), sizeof(actionheader) ); - switch (h_action.code) - { - case 16: - frame_pos+=6; - memcpy(frame_buffer,flc_buffer+ - frame_pos,h_flc.width*h_flc.height); - frame_pos+=h_flc.width*h_flc.height; - break; - case 4: - { - short bc; - int barv,poc; - int fp; - - fp=frame_pos+6; - bc=*(short *)(flc_buffer+fp);fp+=2; - barv=0; - while(bc--) - { - barv+=(flc_buffer[fp++]); - poc=(char)(flc_buffer[fp++]-1)+1; - memcpy(&flc_paleta[barv][0],flc_buffer+fp,poc*3); - fp+=poc*3;barv+=poc; - } - frame_pos+=h_action.size; - } - break; - case 7: - case 12: - frame_pos+=6; - lo=flc_buffer[frame_pos]; frame_pos++; - hi=flc_buffer[frame_pos++]; - changes=hi*256+lo; - row=0;tst=frame_pos+h_action.size; - - for (y=0; frame_pos=0x8000) // preskakovane radky - { - nfo_word=(short)(-nfo_word); //0xFFFF-nfo_word+1; - row+=nfo_word; - } - - else - { - for (z=0; z=tst) break; - if (c1>128) - { - c1=0xFF-c1+1; - c2=flc_buffer[frame_pos]; - frame_pos++; - c3=flc_buffer[frame_pos]; - frame_pos++; - - for (w=1; w<=c1; w++) - { frame_buffer[scr_pos]=c2; - scr_pos++; - frame_buffer[scr_pos]=c3; - scr_pos++; } - } - else - { -// c3=0xFF-c3+1; - for (w=1; w<=c1; w++) - { frame_buffer[scr_pos]=flc_buffer[frame_pos]; - frame_pos++; - scr_pos++; - frame_buffer[scr_pos]=flc_buffer[frame_pos]; - frame_pos++; - scr_pos++; } - } - -// if (x>=640) a=1; -// } - - } - row++; - } - } - -// frame_pos+=h_action.size; - break; - case 15: - frame_pos+=6; - for (y=0; y<=(h_flc.height-1); y++) - { - frame_pos++; x=1; //a=0; - scr_pos=y*h_flc.width; - - while (x<=h_flc.width) - { - c1 = flc_buffer[frame_pos]; - frame_pos++; - - if (c1<128) - { - c2=flc_buffer[frame_pos]; - frame_pos++; - for (w=1; w<=c1; w++) - { frame_buffer[scr_pos]=c2; - scr_pos++; - x++; } - } - else - { - c1=0xFF-c1+1; - for (w=1; w<=c1; w++) - { frame_buffer[scr_pos]=flc_buffer[frame_pos]; - scr_pos++; - frame_pos++; - x++; } - } - } - } - break; - default: frame_pos+=h_action.size; - break; - }; - - } - -} diff --git a/VIDEO/FLC.H b/VIDEO/FLC.H deleted file mode 100644 index 8eb1d16..0000000 --- a/VIDEO/FLC.H +++ /dev/null @@ -1,62 +0,0 @@ -// -// Hlavickovy soubor ke knihovne FLC.C slouzici k dekompresi FLC -// - -#ifndef _FLC_H -#define _FLC_H - -typedef struct FLCHEADER { - unsigned int size; // delka souboru vcetne hlavicky - unsigned short idflc; // ID FLC=0AF12h - unsigned short frames; // pocet frejmu - unsigned short width; // sirka vsech obrazku - unsigned short height; // vyska vsech obrazku - unsigned short color; // hloubka barvy (bpp) - unsigned short flag1; - unsigned int speed; // rychlost prehravani (v 1/1000 s) - unsigned short reserv1; // rezervovany - unsigned int date1; // datum a cas vytvoreni - unsigned int serial; // seriove cislo programu - unsigned int date2; // datum a cas posledni zmeny - unsigned short XA; - unsigned short YA; - char reserv2 [42]; // rezervovano - unsigned int offset1; // offset prvniho frame - unsigned int offset2; // offset druheho frame - char reserv3 [40]; // rezervovano - } flcheader; - -typedef struct FRAMEHEADER { - unsigned int size; // velikost frame v bytech - unsigned short sign; // znacka frame OFAF1h - unsigned short actions; // pocet akci v tomto frame - char reserv [8]; // rezervovano - } frameheader; - -typedef struct ACTIONHEADER { - unsigned int size; // velikost akce v bytech - unsigned short code; // kod akce - // 04h - predani casti nebo cele palety - // 07h - predavani zmenenych casti obrazu - // 0Dh - vymaze obrazovku - // 0Fh - cela obrazovka v RLE - // 10h - nekomprimovana kopie cele obrazovky - // nasleduji data akce - } actionheader; - -extern FILE *flc; -extern flcheader h_flc; -extern frameheader h_frame; -extern actionheader h_action; -extern char frame_buffer [307205]; -extern char *flc_buffer; -extern char flc_paleta[256][3]; -//unsigned int ladici; - -void Open_FLC (char *filename); -void Close_FLC (void); -void Get_first_frame (void); -void Get_next_frame (void); -void Decompress_frame (void); - -#endif diff --git a/VIDEO/FLC/ANALYSE/DOSMEM.C b/VIDEO/FLC/ANALYSE/DOSMEM.C deleted file mode 100644 index 752670a..0000000 --- a/VIDEO/FLC/ANALYSE/DOSMEM.C +++ /dev/null @@ -1,71 +0,0 @@ -/*********************************************/ -/*** DOS memory allocation - DOSMEM.C ***/ -/*** vykostena verze chlumakova memalloc.c ***/ -/*********************************************/ - -#include -#include -#include -#include -#include "dosmem.h" - - -/*** Alokace pole v dolni pameti ***/ - -void *mem_alloc(int size) -{ - static union REGS r; - MEMREC memrec; - - r.x.eax=0x0100; - r.x.ebx=(size>>4)+1; - size=r.x.ebx<<4; - int386(0x31,&r,&r); - if (r.x.cflag) - { - printf ("No fucking DOS memory left!!!"); - exit(1); - } - memrec.ptr=(void *)((r.x.eax&0xFFFF)<<4); - Selector=memrec.selector=(short int)r.x.edx; - - return memrec.ptr; -} - - -/*** Uvolneni dolni pameti ***/ - -void mem_free(void *ptr) -{ - union REGS r; - - if(ptr!=NULL) - { - r.x.eax=0x0101; - r.x.edx=Selector; - int386(0x31,&r,&r); - if(r.x.cflag) - printf("Cannot free DOS memory!!!!"); - } - -} - - -/*** Vyvolani preruseni pomoci protected modu ***/ - -void WtNs386(int IntNum, DPMIREGS *dpmiregs) -{ - union REGS r; - struct SREGS sr; - - r.w.ax=0x300; - r.h.bl=(char)IntNum; - r.h.bh=0; - r.w.cx=0; - segread(&sr); - sr.es=FP_SEG(dpmiregs); - r.x.edi=FP_OFF(dpmiregs); - - int386x(0x31,&r,&r,&sr); -} - diff --git a/VIDEO/FLC/ANALYSE/DOSMEM.H b/VIDEO/FLC/ANALYSE/DOSMEM.H deleted file mode 100644 index b33588d..0000000 --- a/VIDEO/FLC/ANALYSE/DOSMEM.H +++ /dev/null @@ -1,46 +0,0 @@ -/************************************/ -/*** Hlavickovt soubor k DOSMEM.H ***/ -/************************************/ - - -typedef enum -{ DOS_MEMORY, - NEW, -} MEMORY_ITEMS; - -typedef struct -{ int EDI; - int ESI; - int EBP; - int reserved; - int EBX; - int EDX; - int ECX; - int EAX; - short int Flags; - short int ES; - short int DS; - short int GS; - short int IP; - short int CS; - short int SP; - short int SS; - } DPMIREGS; - -typedef struct -{ void *ptr; - int size; - int selector; //smysl jen u DOS_MEMORY - } MEMREC; - -#define D32RealSeg(P) ((((unsigned int)(P))>>4)&0xFFFF) -#define D32RealOff(P) (((unsigned int)(P))&0xF) - -int Selector; -DPMIREGS dpmiregs; - -void *mem_alloc(int size); -void mem_free(void *ptr); -void WtNs386(int IntNum, DPMIREGS *dpmiregs); - - diff --git a/VIDEO/FLC/ANALYSE/FLC.C b/VIDEO/FLC/ANALYSE/FLC.C deleted file mode 100644 index 5994eb7..0000000 --- a/VIDEO/FLC/ANALYSE/FLC.C +++ /dev/null @@ -1,5 +0,0 @@ -// -// Knihovna pro dekompresi FLC souboru -// - -#include "flc.h" diff --git a/VIDEO/FLC/ANALYSE/FLC.H b/VIDEO/FLC/ANALYSE/FLC.H deleted file mode 100644 index 15f903a..0000000 --- a/VIDEO/FLC/ANALYSE/FLC.H +++ /dev/null @@ -1,54 +0,0 @@ -// -// Hlavickovy soubor ke knihovne FLC.C slouzici k dekompresi FLC -// - -#ifndef _FLC_H -#define _FLC_H - -typedef struct FLCHEADER { - unsigned int size; // delka souboru vcetne hlavicky - unsigned short idflc; // ID FLC=0AF12h - unsigned short frames; // pocet frejmu - unsigned short width; // sirka vsech obrazku - unsigned short height; // vyska vsech obrazku - unsigned short color; // hloubka barvy (bpp) - unsigned short flag1; - unsigned int speed; // rychlost prehravani (v 1/1000 s) - unsigned short reserv1; // rezervovany - unsigned int date1; // datum a cas vytvoreni - unsigned int serial; // seriove cislo programu - unsigned int date2; // datum a cas posledni zmeny - unsigned short XA; - unsigned short YA; - char reserv2 [42]; // rezervovano - unsigned int offset1; // offset prvniho frame - unsigned int offset2; // offset druheho frame - char reserv3 [40]; // rezervovano - } flcheader; - -typedef struct FRAMEHEADER { - unsigned int size; // velikost frame v bytech - unsigned short sign; // znacka frame OFAF1h - unsigned short actions; // pocet akci v tomto frame - char reserv [8]; // rezervovano - } frameheader; - -typedef struct ACTIONHEADER { - unsigned int size; // velikost akce v bytech - unsigned short code; // kod akce - // 04h - predani casti nebo cele palety - // 07h - predavani zmenenych casti obrazu - // 0Dh - vymaze obrazovku - // 0Fh - cela obrazovka v RLE - // 10h - nekomprimovana kopie cele obrazovky - // nasleduji data akce - } actionheader; - -char frame_buffer [307200]; -char *flc_buffer; - -void Get_first_frame (void); -void Get_next_frame (void); -void Decompress_frame (void); - -#endif diff --git a/VIDEO/FLC/ANALYSE/PLAY.C b/VIDEO/FLC/ANALYSE/PLAY.C deleted file mode 100644 index d5aaca9..0000000 --- a/VIDEO/FLC/ANALYSE/PLAY.C +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include "flc.h" - -flcheader h_flc; -frameheader h_frame; -actionheader h_action; - - -void main (int argc, char *argv[]) -{ - FILE *flc; - long pozice; - int frames, actions, x, y; - - flc = fopen (argv[1], "rb"); - fread (&h_flc, sizeof(flcheader), 1, flc); - frames=h_flc.frames; - - printf ("\nHlavicka FLC souboru %s:\n", argv[1]); - printf ("Delka celeho souboru: %d\n", h_flc.size); - printf ("Pocet frame: %d\n", h_flc.frames); - printf ("Velikost filmu: %dx%d\n", h_flc.width, h_flc.height); - printf ("Hloubka barvy: %d\n", h_flc.color); - printf ("Rychlost prehravani: %d fps\n", 1000/h_flc.speed); - printf ("Offset prvniho frame: %d\n", h_flc.offset1); - - fseek (flc, h_flc.offset1, SEEK_SET); - for (x=0; x<=(frames-1); x++) - { - fread (&h_frame, sizeof(frameheader), 1, flc); - actions=h_frame.actions; - printf ("\nHlavicka %d framu:\n", x+1); - printf ("Velikost framu: %d\n", h_frame.size); - printf ("Pocet akci ve framu: %d\n", h_frame.actions); - - for (y=0; y<=(actions-1); y++) - { - pozice = ftell (flc); - fread (&h_action, sizeof(actionheader), 1, flc); - fseek (flc, (pozice+h_action.size), SEEK_SET); - printf ("\nHlavicka %d akce:\n", y+1); - printf ("Velikost dat pro tuto akci: %d\n", h_action.size); - printf ("Kod akce: %x\n", h_action.code); - } - getch (); - _clearscreen (_GCLEARSCREEN); - } - - fclose (flc); -} - - diff --git a/VIDEO/FLC/ANALYSE/VESA.C b/VIDEO/FLC/ANALYSE/VESA.C deleted file mode 100644 index a59e4d4..0000000 --- a/VIDEO/FLC/ANALYSE/VESA.C +++ /dev/null @@ -1,296 +0,0 @@ -/********************************/ -/* Prace se SVGA VESA adapterem */ -/********************************/ - -#include -#include -#include -#include -#include "vesa.h" -#include "dosmem.h" - - extern void wm_ChangeBank_(int bank); - #pragma aux (ASM) wm_ChangeBank_; - - -void Set_VESA_mode (int mode) -{ - union REGS r; - - r.w.ax=0x4f02; - r.w.bx=mode; - int386 (0x10, &r, &r); -} - - -void Show_screen (char *display) -{ - wm_ChangeBank_ (0); - memmove (0xa0000, display, 65536); - wm_ChangeBank_ (1); - memmove (0xa0000, (display+65536), 65536); - wm_ChangeBank_ (2); - memmove (0xa0000, (display+131072), 65536); - wm_ChangeBank_ (3); - memmove (0xa0000, (display+196608), 65536); - wm_ChangeBank_ (4); - memmove (0xa0000, (display+262144), 45056); -} - -void Put_image (int x, int y, int xlen, int ylen, char *image) -{ - int a,b,c,d; - long int posunuti=0; - int banka; - - if (y<103) {wm_ChangeBank_ (0); banka=0;} - if (y>103 && y<205) {wm_ChangeBank_ (1); banka=1;} - if (y>205 && y<308) {wm_ChangeBank_ (2); banka=2;} - if (y>308 && y<410) {wm_ChangeBank_ (3); banka=3;} - if (y>410) {wm_ChangeBank_ (4); banka=4;} - - for (a=0; a<=ylen; a++) - { - - d=y+a; - switch (d) - { - case 102: - if ((x+xlen)<256){ - posunuti=(y+a)*640+x; - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - wm_ChangeBank_ (1); banka=1;} - if (x>=256){ - wm_ChangeBank_ (1); banka=1; - posunuti=(((y+a)*640+x)-65536); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - } - if (x<256 && (x+xlen)>256){ - posunuti=(y+a)*640+x; b=x; c=0; - while (b!=256) - {memmove ((0xa0000+posunuti), (image+a*(xlen+1)+c), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (1); banka=1; - posunuti=(((y+a)*640+x)-65536); - memmove ((0xa0000+posunuti+c), (image+a*(xlen+1)+c), (xlen-c));} - break; - case 204: - if ((x+xlen)<512){ - posunuti=(((y+a)*640+x)-65536); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - wm_ChangeBank_ (2); banka=2;} - if (x>=512){ - wm_ChangeBank_ (2); banka=2; - posunuti=(((y+a)*640+x)-131072); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen);} - if (x<512 && (x+xlen)>512){ - posunuti=(((y+a)*640+x)-65536); b=x; c=0; - while (b!=512) - {memmove ((0xa0000+posunuti), (image+a*(xlen+1)+c), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (2); banka=2; - posunuti=(((y+a)*640+x)-131072); - memmove ((0xa0000+posunuti+c), (image+a*(xlen+1)+c), (xlen-c));} - break; - - case 307: - if ((x+xlen)<128){ - posunuti=(((y+a)*640+x)-131072); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - wm_ChangeBank_ (3); banka=3;} - if (x>=128){ - wm_ChangeBank_ (3); banka=3; - posunuti=(((y+a)*640+x)-196608); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen);} - if (x<128 && (x+xlen)>128){ - posunuti=(((y+a)*640+x)-131072); b=x; c=0; - while (b!=128) - {memmove ((0xa0000+posunuti), (image+a*(xlen+1)+c), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (3); banka=3; - posunuti=(((y+a)*640+x)-196608); - memmove ((0xa0000+posunuti+c), (image+a*(xlen+1)+c), (xlen-c));} - break; - - case 409: - if ((x+xlen)<384){ - posunuti=(((y+a)*640+x)-196608); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - wm_ChangeBank_ (4); banka=4;} - if (x>=384){ - wm_ChangeBank_ (4); banka=4; - posunuti=(((y+a)*640+x)-262144); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen);} - if (x<384 && (x+xlen)>384){ - posunuti=(((y+a)*640+x)-196608); b=x; c=0; - while (b!=384) - {memmove ((0xa0000+posunuti), (image+a*(xlen+1)+c), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (4); banka=4; - posunuti=(((y+a)*640+x)-262144); - memmove ((0xa0000+posunuti+c), (image+a*(xlen+1)+c), (xlen-c));} - break; - - default: - posunuti=(y+a)*640+x-banka*65536; - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - break; - }; - } -} - -void Get_image (int x, int y, int xlen, int ylen, char *image) -{ - int a,b,c,d; - long int posunuti=0; - int banka; - - if (y<103) {wm_ChangeBank_ (0); banka=0;} - if (y>103 && y<205) {wm_ChangeBank_ (1); banka=1;} - if (y>205 && y<308) {wm_ChangeBank_ (2); banka=2;} - if (y>308 && y<410) {wm_ChangeBank_ (3); banka=3;} - if (y>410) {wm_ChangeBank_ (4); banka=4;} - - for (a=0; a<=ylen; a++) - { - - d=y+a; - switch (d) - { - case 102: - if ((x+xlen)<256){ - posunuti=(y+a)*640+x; - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - wm_ChangeBank_ (1); banka=1;} - if (x>=256){ - wm_ChangeBank_ (1); banka=1; - posunuti=(((y+a)*640+x)-65536); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - } - if (x<256 && (x+xlen)>256){ - posunuti=(y+a)*640+x; b=x; c=0; - while (b!=256) - {memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (1); banka=1; - posunuti=(((y+a)*640+x)-65536); - memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti+c), (xlen-c));} - break; - case 204: - if ((x+xlen)<512){ - posunuti=(((y+a)*640+x)-65536); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - wm_ChangeBank_ (2); banka=2;} - if (x>=512){ - wm_ChangeBank_ (2); banka=2; - posunuti=(((y+a)*640+x)-131072); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen);} - if (x<512 && (x+xlen)>512){ - posunuti=(((y+a)*640+x)-65536); b=x; c=0; - while (b!=512) - {memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (2); banka=2; - posunuti=(((y+a)*640+x)-131072); - memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti+c), (xlen-c));} - break; - - case 307: - if ((x+xlen)<128){ - posunuti=(((y+a)*640+x)-131072); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - wm_ChangeBank_ (3); banka=3;} - if (x>=128){ - wm_ChangeBank_ (3); banka=3; - posunuti=(((y+a)*640+x)-196608); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen);} - if (x<128 && (x+xlen)>128){ - posunuti=(((y+a)*640+x)-131072); b=x; c=0; - while (b!=128) - {memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (3); banka=3; - posunuti=(((y+a)*640+x)-196608); - memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti+c), (xlen-c));} - break; - - case 409: - if ((x+xlen)<384){ - posunuti=(((y+a)*640+x)-196608); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - wm_ChangeBank_ (4); banka=4;} - if (x>=384){ - wm_ChangeBank_ (4); banka=4; - posunuti=(((y+a)*640+x)-262144); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen);} - if (x<384 && (x+xlen)>384){ - posunuti=(((y+a)*640+x)-196608); b=x; c=0; - while (b!=384) - {memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (4); banka=4; - posunuti=(((y+a)*640+x)-262144); - memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti+c), (xlen-c));} - break; - - default: - posunuti=(y+a)*640+x-banka*65536; - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - break; - }; - } - -} - - -void Get_VESA_info (void) -{ - char far *str; - VESA_INFO_BLOCK *p; - - p=(VESA_INFO_BLOCK *)mem_alloc(sizeof(VESA_INFO_BLOCK)); - - memset(&dpmiregs,0,sizeof(DPMIREGS)); - dpmiregs.EAX=0x00004f00; - dpmiregs.DS=D32RealSeg(p); - dpmiregs.ES=D32RealSeg(p); - dpmiregs.EDI=D32RealOff(p); - - WtNs386(0x10,&dpmiregs); - - str=(char far *)MK_FP(Selector,0); - _fmemcpy(&VesaInfoBlock,str,sizeof(VESA_INFO_BLOCK)); - - mem_free(p); - if(dpmiregs.EAX!=0x4f) - { - printf ("VESA Bios extension not found!!!!"); - exit (1); - } -} - - -void Get_mode_info (int mode) -{ - char far *str; - VESA_MODE_INFO_BLOCK *p; - - p=(VESA_MODE_INFO_BLOCK *)mem_alloc(sizeof(VESA_MODE_INFO_BLOCK)); - - memset(&dpmiregs,0,sizeof(DPMIREGS)); //nuluje registry - dpmiregs.EAX=0x00004f01; - dpmiregs.DS=D32RealSeg(p); - dpmiregs.ES=D32RealSeg(p); - dpmiregs.EDI=D32RealOff(p); - dpmiregs.ECX=mode; - - WtNs386(0x10,&dpmiregs); - - str=(char far *)MK_FP(Selector,0); - _fmemcpy(&VesaModeInfoBlock,str,sizeof(VESA_INFO_BLOCK)); - - _VGAGran=VesaModeInfoBlock.WinGranularity; - - mem_free(p); -} - diff --git a/VIDEO/FLC/ANALYSE/VESA.H b/VIDEO/FLC/ANALYSE/VESA.H deleted file mode 100644 index a0f12a2..0000000 --- a/VIDEO/FLC/ANALYSE/VESA.H +++ /dev/null @@ -1,70 +0,0 @@ -/********************************/ -/* Prace se SVGA VESA adapterem */ -/********************************/ - -#ifndef __VESA_H -#define __VESA_H - - -typedef struct -{ char VESASignature[4]; - short VESAversion; - unsigned OEMStringPtr; - char capabilities[4]; - short int *videomodeptr; - short int TotalMemory; - char dummy[236]; - } VESA_INFO_BLOCK; - -typedef struct -{ short unsigned ModeAttributes; - char WinAAttributes; - char WinBAttributes; - short unsigned WinGranularity; - short unsigned WinSize; - short unsigned WinASegment; - short unsigned WinBSegment; - short unsigned WinFuncPtroff; - short unsigned WinFuncPtrseg; - short unsigned BytesPerScanLine; - - short unsigned XResolution; - short unsigned YResolution; - char Xcharsize; - char Ycharsize; - char NumberOfPlanes; - char BitsPerPixel; - char NumberOfBanks; - char MemoryModel; - char BankSize; - char NumberOfImagePages; - char Reserved; - - char RedMaskSize; - char RedFieldPosition; - char GreenMaskSize; - char GreenFieldPosition; - char BlueMaskSize; - char BlueFieldPosition; - char RsvdMaskSize; - char DirectColorModeInfo; - char Dummy[216]; - } VESA_MODE_INFO_BLOCK; - - -VESA_MODE_INFO_BLOCK VesaModeInfoBlock; -VESA_INFO_BLOCK VesaInfoBlock; - -extern unsigned char _VGAPage=0; -extern unsigned char _VGAGran=0; - -void Set_VESA_mode (int mode); -void Show_screen (char *display); -void Get_VESA_info (void); -void Get_mode_info (int mode); - -void Put_image (int x, int y, int xlen, int ylen, char *image); -void Get_image (int x, int y, int xlen, int ylen, char *image); - -#endif - diff --git a/VIDEO/FLC/ANALYSE/VESA_.ASM b/VIDEO/FLC/ANALYSE/VESA_.ASM deleted file mode 100644 index d11920c..0000000 --- a/VIDEO/FLC/ANALYSE/VESA_.ASM +++ /dev/null @@ -1,63 +0,0 @@ -;EAX EDX EBX ECX -.386p -jumps -;############################################################################ -; Constanty -;############################################################################ - -dlt_x equ 640 -dlt_y equ 480 - -;############################################################################ -; Datovy segment -;############################################################################ -_DATA SEGMENT PARA PUBLIC USE32 'DATA' -align 4 - - -EXTRN __VGAPage:BYTE -EXTRN __VGAGran:BYTE - - -_DATA ENDS - -DGROUP GROUP _DATA - -;############################################################################ -; Kodovy segment -;############################################################################ -_TEXT SEGMENT PARA PUBLIC USE32 'CODE' - ASSUME cs:_TEXT, ds:_DATA - - - -public wm_ChangeBank__ -wm_ChangeBank__ PROC - - push es - pushad - - push eax - mov edx, eax - mov ebx, 0000h - mov eax, 4f05h - int 10h - - pop eax - mov edx, eax - mov ebx, 0001h - mov eax, 4f05h - int 10h - - popad - pop es - ret - -wm_ChangeBank__ endp -;---------------------------------------------------------------------------- - -_TEXT ENDS - -END - - diff --git a/VIDEO/FLC/DOSMEM.C b/VIDEO/FLC/DOSMEM.C deleted file mode 100644 index 752670a..0000000 --- a/VIDEO/FLC/DOSMEM.C +++ /dev/null @@ -1,71 +0,0 @@ -/*********************************************/ -/*** DOS memory allocation - DOSMEM.C ***/ -/*** vykostena verze chlumakova memalloc.c ***/ -/*********************************************/ - -#include -#include -#include -#include -#include "dosmem.h" - - -/*** Alokace pole v dolni pameti ***/ - -void *mem_alloc(int size) -{ - static union REGS r; - MEMREC memrec; - - r.x.eax=0x0100; - r.x.ebx=(size>>4)+1; - size=r.x.ebx<<4; - int386(0x31,&r,&r); - if (r.x.cflag) - { - printf ("No fucking DOS memory left!!!"); - exit(1); - } - memrec.ptr=(void *)((r.x.eax&0xFFFF)<<4); - Selector=memrec.selector=(short int)r.x.edx; - - return memrec.ptr; -} - - -/*** Uvolneni dolni pameti ***/ - -void mem_free(void *ptr) -{ - union REGS r; - - if(ptr!=NULL) - { - r.x.eax=0x0101; - r.x.edx=Selector; - int386(0x31,&r,&r); - if(r.x.cflag) - printf("Cannot free DOS memory!!!!"); - } - -} - - -/*** Vyvolani preruseni pomoci protected modu ***/ - -void WtNs386(int IntNum, DPMIREGS *dpmiregs) -{ - union REGS r; - struct SREGS sr; - - r.w.ax=0x300; - r.h.bl=(char)IntNum; - r.h.bh=0; - r.w.cx=0; - segread(&sr); - sr.es=FP_SEG(dpmiregs); - r.x.edi=FP_OFF(dpmiregs); - - int386x(0x31,&r,&r,&sr); -} - diff --git a/VIDEO/FLC/DOSMEM.H b/VIDEO/FLC/DOSMEM.H deleted file mode 100644 index b33588d..0000000 --- a/VIDEO/FLC/DOSMEM.H +++ /dev/null @@ -1,46 +0,0 @@ -/************************************/ -/*** Hlavickovt soubor k DOSMEM.H ***/ -/************************************/ - - -typedef enum -{ DOS_MEMORY, - NEW, -} MEMORY_ITEMS; - -typedef struct -{ int EDI; - int ESI; - int EBP; - int reserved; - int EBX; - int EDX; - int ECX; - int EAX; - short int Flags; - short int ES; - short int DS; - short int GS; - short int IP; - short int CS; - short int SP; - short int SS; - } DPMIREGS; - -typedef struct -{ void *ptr; - int size; - int selector; //smysl jen u DOS_MEMORY - } MEMREC; - -#define D32RealSeg(P) ((((unsigned int)(P))>>4)&0xFFFF) -#define D32RealOff(P) (((unsigned int)(P))&0xF) - -int Selector; -DPMIREGS dpmiregs; - -void *mem_alloc(int size); -void mem_free(void *ptr); -void WtNs386(int IntNum, DPMIREGS *dpmiregs); - - diff --git a/VIDEO/FLC/FLC.C b/VIDEO/FLC/FLC.C deleted file mode 100644 index 62e38b3..0000000 --- a/VIDEO/FLC/FLC.C +++ /dev/null @@ -1,176 +0,0 @@ -// -// Knihovna pro dekompresi FLC souboru -// - -#include -#include -#include -#include -#include -#include "flc.h" - - -void Open_FLC (char *filename) -{ - flc = fopen (filename, "rb"); - fread (&h_flc, sizeof(flcheader), 1, flc); -} - -void Close_FLC (void) -{ - fclose (flc); - free (flc_buffer); -} - -void Get_first_frame (void) -{ - fseek (flc, h_flc.offset1, SEEK_SET); - fread (&h_frame, sizeof(frameheader), 1, flc); - flc_buffer = (char*)malloc((h_frame.size-sizeof(frameheader))); - fread (flc_buffer, (h_frame.size-sizeof(frameheader)), 1, flc); -} - -void Get_next_frame (void) -{ - free (flc_buffer); - fread (&h_frame, sizeof(frameheader), 1, flc); - flc_buffer = (char*)malloc((h_frame.size-sizeof(frameheader))); - fread (flc_buffer, (h_frame.size-sizeof(frameheader)), 1, flc); -} - -void Decompress_frame (void) -{ - unsigned short x,y,z,w; - unsigned short changes, nfo_word, packets, offset, row; - int frame_pos=0; - unsigned int scr_pos; - char c1, c2, c3, a; - char hi, lo; - - for (z=1; z<=h_frame.actions; z++) - { - memmove ( &h_action, (flc_buffer+frame_pos), sizeof(actionheader) ); - switch (h_action.code) - { - case 4: - a=1;//fcl_buffer[frame_pos]; -// b=0;//flc_buffer[frame_pos]; -// c=256; //0=256 - - frame_pos+=10; - outp (0x3c8, 0); - for (x=0; x<=768; x++) outp (0x3c9, (flc_buffer[(x+frame_pos)]/=4) ); - frame_pos+=768; - break; - case 7: - frame_pos+=6; - lo=flc_buffer[frame_pos]; frame_pos++; - hi=flc_buffer[frame_pos]; frame_pos++; - changes=hi*256+lo; - row=0; - - for (y=0; y<=(changes-1); y++) // pocet menenych radek - { - lo=flc_buffer[frame_pos]; frame_pos++; - hi=flc_buffer[frame_pos]; frame_pos++; - nfo_word=hi*256+lo; - - scr_pos=row*h_flc.width; - - if (nfo_word>=0xC000) // preskakovane radky - { - nfo_word=0xFFFF-nfo_word+1; - row+=nfo_word; - } - - else - { - for (z=1; z<=nfo_word; z++) // pocet menenych bloku - { - x=1; a=0; - - offset = flc_buffer[frame_pos]; // rel. offset bloku - frame_pos++; - scr_pos+=offset; - -// while (!a) // zmena bloku -// { - c1 = flc_buffer[frame_pos]; - frame_pos++; - - if (c1>128) - { - c1=0xFF-c1+1; - c2=flc_buffer[frame_pos]; - frame_pos++; - c3=flc_buffer[frame_pos]; - frame_pos++; - - for (w=1; w<=c1; w++) - { frame_buffer[scr_pos]=c2; - scr_pos++; - frame_buffer[scr_pos]=c3; - scr_pos++; } - } - else - { -// c3=0xFF-c3+1; - for (w=1; w<=c1; w++) - { frame_buffer[scr_pos]=flc_buffer[frame_pos]; - frame_pos++; - scr_pos++; - frame_buffer[scr_pos]=flc_buffer[frame_pos]; - frame_pos++; - scr_pos++; } - } - -// if (x>=640) a=1; -// } - - } - row++; - } - } - -// frame_pos+=h_action.size; - break; - case 15: - frame_pos+=6; - for (y=0; y<=(h_flc.height-1); y++) - { - frame_pos++; x=1; //a=0; - scr_pos=y*h_flc.width; - - while (x<=h_flc.width) - { - c1 = flc_buffer[frame_pos]; - frame_pos++; - - if (c1<128) - { - c2=flc_buffer[frame_pos]; - frame_pos++; - for (w=1; w<=c1; w++) - { frame_buffer[scr_pos]=c2; - scr_pos++; - x++; } - } - else - { - c1=0xFF-c1+1; - for (w=1; w<=c1; w++) - { frame_buffer[scr_pos]=flc_buffer[frame_pos]; - scr_pos++; - frame_pos++; - x++; } - } - } - } - break; - default: frame_pos+=h_action.size; - break; - }; - - } - -} diff --git a/VIDEO/FLC/FLC.H b/VIDEO/FLC/FLC.H deleted file mode 100644 index 012a222..0000000 --- a/VIDEO/FLC/FLC.H +++ /dev/null @@ -1,61 +0,0 @@ -// -// Hlavickovy soubor ke knihovne FLC.C slouzici k dekompresi FLC -// - -#ifndef _FLC_H -#define _FLC_H - -typedef struct FLCHEADER { - unsigned int size; // delka souboru vcetne hlavicky - unsigned short idflc; // ID FLC=0AF12h - unsigned short frames; // pocet frejmu - unsigned short width; // sirka vsech obrazku - unsigned short height; // vyska vsech obrazku - unsigned short color; // hloubka barvy (bpp) - unsigned short flag1; - unsigned int speed; // rychlost prehravani (v 1/1000 s) - unsigned short reserv1; // rezervovany - unsigned int date1; // datum a cas vytvoreni - unsigned int serial; // seriove cislo programu - unsigned int date2; // datum a cas posledni zmeny - unsigned short XA; - unsigned short YA; - char reserv2 [42]; // rezervovano - unsigned int offset1; // offset prvniho frame - unsigned int offset2; // offset druheho frame - char reserv3 [40]; // rezervovano - } flcheader; - -typedef struct FRAMEHEADER { - unsigned int size; // velikost frame v bytech - unsigned short sign; // znacka frame OFAF1h - unsigned short actions; // pocet akci v tomto frame - char reserv [8]; // rezervovano - } frameheader; - -typedef struct ACTIONHEADER { - unsigned int size; // velikost akce v bytech - unsigned short code; // kod akce - // 04h - predani casti nebo cele palety - // 07h - predavani zmenenych casti obrazu - // 0Dh - vymaze obrazovku - // 0Fh - cela obrazovka v RLE - // 10h - nekomprimovana kopie cele obrazovky - // nasleduji data akce - } actionheader; - -FILE *flc; -flcheader h_flc; -frameheader h_frame; -actionheader h_action; -char frame_buffer [307205]; -char *flc_buffer; -//unsigned int ladici; - -void Open_FLC (char *filename); -void Close_FLC (void); -void Get_first_frame (void); -void Get_next_frame (void); -void Decompress_frame (void); - -#endif diff --git a/VIDEO/FLC/PLAY.C b/VIDEO/FLC/PLAY.C deleted file mode 100644 index 3138bf2..0000000 --- a/VIDEO/FLC/PLAY.C +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include -#include "flc.h" -#include "vesa.h" - -void Set_TEXT_mode (void); - -void main (int argc, char *argv[]) -{ - int x; - - Open_FLC (argv[1]); - - printf ("\nHlavicka FLC souboru %s:\n", argv[1]); - printf ("Delka celeho souboru: %d\n", h_flc.size); - printf ("Pocet frame: %d\n", h_flc.frames); - printf ("Velikost filmu: %dx%d\n", h_flc.width, h_flc.height); - printf ("Hloubka barvy: %d\n", h_flc.color); -// printf ("Rychlost prehravani: %d fps\n", 1000/h_flc.speed); - printf ("Offset prvniho frame: %d\n", h_flc.offset1); - getch (); - - Set_VESA_mode (0x101); - delay (1000); - - Get_first_frame (); - Decompress_frame (); - Show_screen (frame_buffer); - - for (x=2; x<=h_flc.frames; x++) - { - Get_next_frame (); - Decompress_frame (); - Show_screen (frame_buffer); - delay (7); - } - getch (); - - Set_TEXT_mode (); - Close_FLC (); -} - -void Set_TEXT_mode (void) -{ - union REGS inr, outr; - - inr.h.ah = 0x00; - inr.h.al = 03; - int386 (0x10, &inr, &outr); -} - - diff --git a/VIDEO/FLC/VESA.C b/VIDEO/FLC/VESA.C deleted file mode 100644 index a59e4d4..0000000 --- a/VIDEO/FLC/VESA.C +++ /dev/null @@ -1,296 +0,0 @@ -/********************************/ -/* Prace se SVGA VESA adapterem */ -/********************************/ - -#include -#include -#include -#include -#include "vesa.h" -#include "dosmem.h" - - extern void wm_ChangeBank_(int bank); - #pragma aux (ASM) wm_ChangeBank_; - - -void Set_VESA_mode (int mode) -{ - union REGS r; - - r.w.ax=0x4f02; - r.w.bx=mode; - int386 (0x10, &r, &r); -} - - -void Show_screen (char *display) -{ - wm_ChangeBank_ (0); - memmove (0xa0000, display, 65536); - wm_ChangeBank_ (1); - memmove (0xa0000, (display+65536), 65536); - wm_ChangeBank_ (2); - memmove (0xa0000, (display+131072), 65536); - wm_ChangeBank_ (3); - memmove (0xa0000, (display+196608), 65536); - wm_ChangeBank_ (4); - memmove (0xa0000, (display+262144), 45056); -} - -void Put_image (int x, int y, int xlen, int ylen, char *image) -{ - int a,b,c,d; - long int posunuti=0; - int banka; - - if (y<103) {wm_ChangeBank_ (0); banka=0;} - if (y>103 && y<205) {wm_ChangeBank_ (1); banka=1;} - if (y>205 && y<308) {wm_ChangeBank_ (2); banka=2;} - if (y>308 && y<410) {wm_ChangeBank_ (3); banka=3;} - if (y>410) {wm_ChangeBank_ (4); banka=4;} - - for (a=0; a<=ylen; a++) - { - - d=y+a; - switch (d) - { - case 102: - if ((x+xlen)<256){ - posunuti=(y+a)*640+x; - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - wm_ChangeBank_ (1); banka=1;} - if (x>=256){ - wm_ChangeBank_ (1); banka=1; - posunuti=(((y+a)*640+x)-65536); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - } - if (x<256 && (x+xlen)>256){ - posunuti=(y+a)*640+x; b=x; c=0; - while (b!=256) - {memmove ((0xa0000+posunuti), (image+a*(xlen+1)+c), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (1); banka=1; - posunuti=(((y+a)*640+x)-65536); - memmove ((0xa0000+posunuti+c), (image+a*(xlen+1)+c), (xlen-c));} - break; - case 204: - if ((x+xlen)<512){ - posunuti=(((y+a)*640+x)-65536); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - wm_ChangeBank_ (2); banka=2;} - if (x>=512){ - wm_ChangeBank_ (2); banka=2; - posunuti=(((y+a)*640+x)-131072); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen);} - if (x<512 && (x+xlen)>512){ - posunuti=(((y+a)*640+x)-65536); b=x; c=0; - while (b!=512) - {memmove ((0xa0000+posunuti), (image+a*(xlen+1)+c), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (2); banka=2; - posunuti=(((y+a)*640+x)-131072); - memmove ((0xa0000+posunuti+c), (image+a*(xlen+1)+c), (xlen-c));} - break; - - case 307: - if ((x+xlen)<128){ - posunuti=(((y+a)*640+x)-131072); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - wm_ChangeBank_ (3); banka=3;} - if (x>=128){ - wm_ChangeBank_ (3); banka=3; - posunuti=(((y+a)*640+x)-196608); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen);} - if (x<128 && (x+xlen)>128){ - posunuti=(((y+a)*640+x)-131072); b=x; c=0; - while (b!=128) - {memmove ((0xa0000+posunuti), (image+a*(xlen+1)+c), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (3); banka=3; - posunuti=(((y+a)*640+x)-196608); - memmove ((0xa0000+posunuti+c), (image+a*(xlen+1)+c), (xlen-c));} - break; - - case 409: - if ((x+xlen)<384){ - posunuti=(((y+a)*640+x)-196608); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - wm_ChangeBank_ (4); banka=4;} - if (x>=384){ - wm_ChangeBank_ (4); banka=4; - posunuti=(((y+a)*640+x)-262144); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen);} - if (x<384 && (x+xlen)>384){ - posunuti=(((y+a)*640+x)-196608); b=x; c=0; - while (b!=384) - {memmove ((0xa0000+posunuti), (image+a*(xlen+1)+c), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (4); banka=4; - posunuti=(((y+a)*640+x)-262144); - memmove ((0xa0000+posunuti+c), (image+a*(xlen+1)+c), (xlen-c));} - break; - - default: - posunuti=(y+a)*640+x-banka*65536; - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - break; - }; - } -} - -void Get_image (int x, int y, int xlen, int ylen, char *image) -{ - int a,b,c,d; - long int posunuti=0; - int banka; - - if (y<103) {wm_ChangeBank_ (0); banka=0;} - if (y>103 && y<205) {wm_ChangeBank_ (1); banka=1;} - if (y>205 && y<308) {wm_ChangeBank_ (2); banka=2;} - if (y>308 && y<410) {wm_ChangeBank_ (3); banka=3;} - if (y>410) {wm_ChangeBank_ (4); banka=4;} - - for (a=0; a<=ylen; a++) - { - - d=y+a; - switch (d) - { - case 102: - if ((x+xlen)<256){ - posunuti=(y+a)*640+x; - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - wm_ChangeBank_ (1); banka=1;} - if (x>=256){ - wm_ChangeBank_ (1); banka=1; - posunuti=(((y+a)*640+x)-65536); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - } - if (x<256 && (x+xlen)>256){ - posunuti=(y+a)*640+x; b=x; c=0; - while (b!=256) - {memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (1); banka=1; - posunuti=(((y+a)*640+x)-65536); - memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti+c), (xlen-c));} - break; - case 204: - if ((x+xlen)<512){ - posunuti=(((y+a)*640+x)-65536); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - wm_ChangeBank_ (2); banka=2;} - if (x>=512){ - wm_ChangeBank_ (2); banka=2; - posunuti=(((y+a)*640+x)-131072); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen);} - if (x<512 && (x+xlen)>512){ - posunuti=(((y+a)*640+x)-65536); b=x; c=0; - while (b!=512) - {memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (2); banka=2; - posunuti=(((y+a)*640+x)-131072); - memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti+c), (xlen-c));} - break; - - case 307: - if ((x+xlen)<128){ - posunuti=(((y+a)*640+x)-131072); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - wm_ChangeBank_ (3); banka=3;} - if (x>=128){ - wm_ChangeBank_ (3); banka=3; - posunuti=(((y+a)*640+x)-196608); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen);} - if (x<128 && (x+xlen)>128){ - posunuti=(((y+a)*640+x)-131072); b=x; c=0; - while (b!=128) - {memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (3); banka=3; - posunuti=(((y+a)*640+x)-196608); - memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti+c), (xlen-c));} - break; - - case 409: - if ((x+xlen)<384){ - posunuti=(((y+a)*640+x)-196608); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - wm_ChangeBank_ (4); banka=4;} - if (x>=384){ - wm_ChangeBank_ (4); banka=4; - posunuti=(((y+a)*640+x)-262144); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen);} - if (x<384 && (x+xlen)>384){ - posunuti=(((y+a)*640+x)-196608); b=x; c=0; - while (b!=384) - {memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (4); banka=4; - posunuti=(((y+a)*640+x)-262144); - memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti+c), (xlen-c));} - break; - - default: - posunuti=(y+a)*640+x-banka*65536; - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - break; - }; - } - -} - - -void Get_VESA_info (void) -{ - char far *str; - VESA_INFO_BLOCK *p; - - p=(VESA_INFO_BLOCK *)mem_alloc(sizeof(VESA_INFO_BLOCK)); - - memset(&dpmiregs,0,sizeof(DPMIREGS)); - dpmiregs.EAX=0x00004f00; - dpmiregs.DS=D32RealSeg(p); - dpmiregs.ES=D32RealSeg(p); - dpmiregs.EDI=D32RealOff(p); - - WtNs386(0x10,&dpmiregs); - - str=(char far *)MK_FP(Selector,0); - _fmemcpy(&VesaInfoBlock,str,sizeof(VESA_INFO_BLOCK)); - - mem_free(p); - if(dpmiregs.EAX!=0x4f) - { - printf ("VESA Bios extension not found!!!!"); - exit (1); - } -} - - -void Get_mode_info (int mode) -{ - char far *str; - VESA_MODE_INFO_BLOCK *p; - - p=(VESA_MODE_INFO_BLOCK *)mem_alloc(sizeof(VESA_MODE_INFO_BLOCK)); - - memset(&dpmiregs,0,sizeof(DPMIREGS)); //nuluje registry - dpmiregs.EAX=0x00004f01; - dpmiregs.DS=D32RealSeg(p); - dpmiregs.ES=D32RealSeg(p); - dpmiregs.EDI=D32RealOff(p); - dpmiregs.ECX=mode; - - WtNs386(0x10,&dpmiregs); - - str=(char far *)MK_FP(Selector,0); - _fmemcpy(&VesaModeInfoBlock,str,sizeof(VESA_INFO_BLOCK)); - - _VGAGran=VesaModeInfoBlock.WinGranularity; - - mem_free(p); -} - diff --git a/VIDEO/FLC/VESA.H b/VIDEO/FLC/VESA.H deleted file mode 100644 index a0f12a2..0000000 --- a/VIDEO/FLC/VESA.H +++ /dev/null @@ -1,70 +0,0 @@ -/********************************/ -/* Prace se SVGA VESA adapterem */ -/********************************/ - -#ifndef __VESA_H -#define __VESA_H - - -typedef struct -{ char VESASignature[4]; - short VESAversion; - unsigned OEMStringPtr; - char capabilities[4]; - short int *videomodeptr; - short int TotalMemory; - char dummy[236]; - } VESA_INFO_BLOCK; - -typedef struct -{ short unsigned ModeAttributes; - char WinAAttributes; - char WinBAttributes; - short unsigned WinGranularity; - short unsigned WinSize; - short unsigned WinASegment; - short unsigned WinBSegment; - short unsigned WinFuncPtroff; - short unsigned WinFuncPtrseg; - short unsigned BytesPerScanLine; - - short unsigned XResolution; - short unsigned YResolution; - char Xcharsize; - char Ycharsize; - char NumberOfPlanes; - char BitsPerPixel; - char NumberOfBanks; - char MemoryModel; - char BankSize; - char NumberOfImagePages; - char Reserved; - - char RedMaskSize; - char RedFieldPosition; - char GreenMaskSize; - char GreenFieldPosition; - char BlueMaskSize; - char BlueFieldPosition; - char RsvdMaskSize; - char DirectColorModeInfo; - char Dummy[216]; - } VESA_MODE_INFO_BLOCK; - - -VESA_MODE_INFO_BLOCK VesaModeInfoBlock; -VESA_INFO_BLOCK VesaInfoBlock; - -extern unsigned char _VGAPage=0; -extern unsigned char _VGAGran=0; - -void Set_VESA_mode (int mode); -void Show_screen (char *display); -void Get_VESA_info (void); -void Get_mode_info (int mode); - -void Put_image (int x, int y, int xlen, int ylen, char *image); -void Get_image (int x, int y, int xlen, int ylen, char *image); - -#endif - diff --git a/VIDEO/FLC/VESA_.ASM b/VIDEO/FLC/VESA_.ASM deleted file mode 100644 index d11920c..0000000 --- a/VIDEO/FLC/VESA_.ASM +++ /dev/null @@ -1,63 +0,0 @@ -;EAX EDX EBX ECX -.386p -jumps -;############################################################################ -; Constanty -;############################################################################ - -dlt_x equ 640 -dlt_y equ 480 - -;############################################################################ -; Datovy segment -;############################################################################ -_DATA SEGMENT PARA PUBLIC USE32 'DATA' -align 4 - - -EXTRN __VGAPage:BYTE -EXTRN __VGAGran:BYTE - - -_DATA ENDS - -DGROUP GROUP _DATA - -;############################################################################ -; Kodovy segment -;############################################################################ -_TEXT SEGMENT PARA PUBLIC USE32 'CODE' - ASSUME cs:_TEXT, ds:_DATA - - - -public wm_ChangeBank__ -wm_ChangeBank__ PROC - - push es - pushad - - push eax - mov edx, eax - mov ebx, 0000h - mov eax, 4f05h - int 10h - - pop eax - mov edx, eax - mov ebx, 0001h - mov eax, 4f05h - int 10h - - popad - pop es - ret - -wm_ChangeBank__ endp -;---------------------------------------------------------------------------- - -_TEXT ENDS - -END - - diff --git a/VIDEO/FLC2MGIF.C b/VIDEO/FLC2MGIF.C deleted file mode 100644 index 1bdc571..0000000 --- a/VIDEO/FLC2MGIF.C +++ /dev/null @@ -1,620 +0,0 @@ -// MOTION GIF - LZW komprimovana animace v rozliseni 320x180 256 barev avsak -// upravena pro prehravani v HICOLOR pro konkretni rezim (32768 barev) - - -// Format - /* - - [ FRAME ] - [CHUNK] !pozor delka je 3 bajtova (tj 16MB) - 0 - PRADNY CHUNK - 1 - LZW FULL SCREEN - 2 - MGIF DELTA - 3 - HICOLOR PALETE - 4 - SOUND TRACK - 5 - TEXT TRACK - 6 - MGIF COPY - 7 - SOUND INIT - - Popis Chunku: - PRAZDNY_CHUNK - muze obsahovat soukrome informace - - LZW_FULL_SCREEN - - ihned za hlavickou nasleduje LZW komprimovany obrazek - v rozliseni 320x180 256 barev - - MGIF_DELTA - - cely blok je LZW komprimovany. Po dekomprimace blok obsahuje - dva druhy informaci. Prvni DWORD je ofset od pocatku dat - ktery ukazuje na zacatek graficke informace. Po tomto - DWORDU jsou ulozeny data o umisteni grafickych bodu v obrazu - Prvni byte znaci, kolik je nutne preskocit slov. (tj *2 byte) - Dalsi byte znaci, kolik je nutne zapsat slov (tj *2 byte) - Po tomto bytu je nutne prenest presne tolik slov z - grafickeho bloku na obrazovku. Dvojice bajtu se opakuji - dokud ani jeden z nich nema nejvyssi 2 bity nastavene. - Pak tento byte znaci ze uz na radce nic vic neni. Dolni cast - byte (tj 6 bitu) pak udava pocet radku, ktere je treba pre- - skocit. (nula=zadny). - - HICOLOR PALETTE - - Prvni byte znamena pocet aktivnich barev. Pak nasleduje - paleta ve formatu xRRRRRGGGGGBBBBB. Rozdil oproti vsem - beznym paletam je v tom ze neni treba v palete udrzovat - barvy, ktere uz na obrazovce jsou, protoze zmena palety - se neprojevi na jiz zobrazenem obrazku. - - SOUND_TRACK - - Kazdy frame obsahuje zvukovou stopu. Je to RAW format. - Pro verzi MGIF97 zde je zvukova informace ulozena ve - zvukove kvalite 16-bit stereo 22000Khz, ovsem komprimovana - na 50% jako MUS. - TEXT_TRACK - - Navic je ve mozne ve frame umistit textovou zpravu (titulek) - Prvni WORD udava dobu zobrazeni (pocet frame). - Pote nasleduje text zakoncen znakem 0; - - MGIF_COPY - Za timto CHUNKEM je ulozen blok dat v nezakomprimovanem - tvaru(tj 57600byte); - - - - */ - -#include -#include -#include -#include -#include -#include -#include "flc.h" -#include "lzw.h" -#include - -#define MGIF "MGIF" -#define MGIF_Y "97" -#define VER 0x100 - -#define MGIF_EMPTY 0 -#define MGIF_LZW 1 -#define MGIF_DELTA 2 -#define MGIF_PAL 3 -#define MGIF_SOUND 4 -#define MGIF_TEXT 5 -#define MGIF_COPY 6 -#define MGIF_SINIT 7 - -#define FRAME_X 320 -#define FRAME_Y 180 -#define FRAME_LEN (FRAME_X*FRAME_Y) -#define DELTA_LEN (3*FRAME_LEN) -#define LZW_LEN (2*FRAME_LEN) - -#define SOUND_SPEED 44100 -#define PRE_SOUND ((256*1024)/2) - -#define ZTRATA lowq -#define BZTRATA colorq -#define MAX_FRAME max_fr -#define MIN_FRAME min_fr - -short mult_table[64]; -short square_table[4096]; - -typedef struct mgif_header - { - char sign[4]; - char year[2]; - char eof; - word ver; - long frames; - word snd_chans; - int snd_freq; - short ampl_table[256]; - short reserved[32]; - }; - -word last_frame[FRAME_Y][FRAME_X]; -char frame_delta[FRAME_LEN]; -char delta_data[DELTA_LEN]; -word color_state[32*32+32*32+32*32]; -char calc_data[FRAME_LEN]; -int delta_data_size; -int frame_delta_size; -int speed=20; - -int last_frame_size; -int total_frames; - -int lowq=0; -int colorq=0; -int max_fr=999999; -int min_fr=0; - -int hranice; -int hdiff=0; - -struct mgif_header gh; - -char lzw_buffer[LZW_LEN]; - -char pal_use[256],color_map[256]; -word hipal[256],max_colors; - - -FILE *mgf; - -long of_pos; -int of_chunks; - -void open_frame() - { - of_chunks=0; - of_pos=ftell(mgf); - fwrite(&of_pos,1,4,mgf); - } - -void close_frame() - { - long fsize,p; - - last_frame_size=fsize=(p=ftell(mgf))-of_pos-4; - fseek(mgf,of_pos,SEEK_SET); - fwrite(&of_chunks,1,1,mgf); - fwrite(&fsize,1,3,mgf); - fseek(mgf,p,SEEK_SET); - total_frames++; - } - - -void write_chunk(char action,long size,void *data) - { - fwrite(&action,1,1,mgf); - fwrite(&size,1,3,mgf); - fwrite(data,1,size,mgf); - of_chunks++; - } - - -void conv_2_hicolor() - { - int i,r,g,b; - for(i=0;i<256;i++) - { - r=(flc_paleta[i][0]>>3); - g=(flc_paleta[i][1]>>3); - b=(flc_paleta[i][2]>>3); - hipal[i]=((r<<10)+(g<<5)+b); - } - } - -char find_color(word c); //najde barvu v palete a vraci byte -#pragma aux find_color parm [eax]=\ - "mov edi,offset hipal"\ - "mov ecx,256"\ - "repne scasw"\ - "mov eax,edi"\ - "sub eax,offset hipal"\ - "shr eax,1"\ - "dec eax"\ - value [al] modify[edi ecx]; - - -void init_palmap() - { - int i; - memset(pal_use,0,sizeof(pal_use)); // nuluj pristupy k barvam - for(i=0;i<256;i++) color_map[i]=find_color(hipal[i]); //redukuj paletu; - max_colors=256; // pocet barev zatim 256; - } - -char test_transp(char c,word w) - { - int r1,g1,b1; - int r2,g2,b2; - int diff; - - r1=flc_paleta[c][0]>>3; - g1=flc_paleta[c][1]>>3; - b1=flc_paleta[c][2]>>3; - w&=0x7fff; - b2=w;g2=b2>>5;r2=g2>>5;b2&=0x1f;g2&=0x1f; - r1-=r2;g1-=g2;b1-=b2; - diff=abs(r1)+abs(g1<<1)+abs(b1); - return diff<=hranice; - } - -void create_delta(char *frame_buffer) - { - char *delta; - char *data; - long colors2; - int x,y; - word *p; - char skip,skc,cpc; - char c1,c2,*a,d; - - delta=delta_data; - data=frame_delta; - a=frame_buffer; - for(y=0;y<180;y++) - { - p=&last_frame[y]; - skip=1; - skc=0; - cpc=0; - for(x=0;x<160;x++) - { - c1=*a++;c2=*a++; - c1=color_map[c1]; - c2=color_map[c2]; - d=test_transp(c1,p[0]) && test_transp(c2,p[1]); - if (d!=skip) - { - if (skip) *delta++=skc;else *delta++=cpc; - skip=!skip;skc=0;cpc=0; - } - if (!skip) - { - *data++=c1; - *data++=c2; - colors2=hipal[c1]+(hipal[c2]<<16); - *(long *)p=colors2; - cpc++; - } - else skc++; - p+=2; - pal_use[c1]=1; - pal_use[c2]=1; - } - if (!skip) *delta++=cpc; - if (skc==160 && *(delta-1)!=0xff && delta!=delta_data) delta[-1]++; //preskoc n radek - else *delta++=0xc0; //oznac konec radky - } - delta_data_size=delta-delta_data; - frame_delta_size=data-frame_delta; - } - - -void reduce_palette() //redukuje paletu na nejmensi nutny pocet barev - { - int i,j; - for(i=0,j=0;i<256;i++) - { - if (pal_use[i]) - { - hipal[j]=hipal[i]; - color_map[i]=j++; - } - } - max_colors=j; - } - -void filter_colors(void *block,int size,void *colormap); //prefiltruje blok dat podle color_map -#pragma aux filter_colors parm [edi][ecx][ebx]=\ - "lp1: mov al,[edi]"\ - " xlatb"\ - " stosb"\ - " loop lp1"\ - modify [eax]; - - -void *join_two_blocks(void *d1,void *d2,int siz1,int siz2,long *celk) - { - long siz; - char *d; - void *x; - - siz=siz1+siz2+4; - d=(char *)getmem(siz); - x=d; - memcpy(d,&siz1,4);d+=4; - memcpy(d,d1,siz1);d+=siz1; - memcpy(d,d2,siz2); - *celk=siz; - return x; - } - -void create_last_frame(void *source,void *target,void *pal,int size); -#pragma aux create_last_frame parm [esi][edi][ebx][ecx]=\ - "lp1: lodsb"\ - " movzx eax,al"\ - " mov eax,[eax*2+ebx]"\ - " stosw"\ - " loop lp1"\ - modify[eax] - - -void create_mgif_pal() - { - write_chunk(MGIF_PAL,max_colors*2,hipal); - } - - -void create_mgif_lzw() - { - int siz; - - conv_2_hicolor(); - init_palmap(); - create_mgif_pal(); - filter_colors(frame_buffer,FRAME_LEN,color_map); - create_last_frame(frame_buffer,last_frame,hipal,FRAME_LEN); - init_lzw_compressor(8); - memset(lzw_buffer,0,sizeof(lzw_buffer)); - siz=lzw_encode(frame_buffer,lzw_buffer,FRAME_LEN); - if (siz>FRAME_LEN) write_chunk(MGIF_COPY,FRAME_LEN,frame_buffer); - else write_chunk(MGIF_LZW,siz,lzw_buffer); - done_lzw_compressor(8); - } - - -void create_color_state() - { - int i; - int r1,g1,b1; - int r2,g2,b2; - int diff; - char *c; - word *w; - - memset(color_state,0,sizeof(color_state)); - c=frame_buffer; - w=last_frame; - for(i=0;i>3; - g1=flc_paleta[*c][1]>>3; - b1=flc_paleta[*c][2]>>3; - b2=*w;g2=b2>>5;r2=g2>>5;b2&=0x1f;g2&=0x1f; - r1-=r2;g1-=g2;b1-=b2; - diff=abs(r1)+abs(g1<<1)+abs(b1); - color_state[diff]++; - c++;w++; - } - } - -void set_max_color_change(int cchange) - { - int i,s; - - s=0;cchange=57600-cchange; - for(i=sizeof(color_state)/sizeof(word)-1;s0;i--) s+=color_state[i]; - if (s>=cchange) i++; - hranice=i+hdiff;if (hranice<0) hranice=0; - } - -int rozptyl(int v1,int v2) - { - int c1,c2,x,s; - x=v1+v2>>1; - c1=(x-v1); - c2=(x-v2); - s=c1*c1+c2*c2; - return s; - } - -void create_low_quality() - { - void *snd;int l; - char *sn,*sr,c1,c2; - int rs,bs,gs; - - l=FRAME_LEN; - sr=frame_buffer; - snd=calc_data; - sn=(char *)snd; - l--; - while (l--) - { - c1=*sr++; - c2=*sr; - rs=rozptyl(flc_paleta[c1][0],flc_paleta[c2][0]); - gs=rozptyl(flc_paleta[c1][1],flc_paleta[c2][1]); - bs=rozptyl(flc_paleta[c1][2],flc_paleta[c2][2]); - if (rs+gs+bsFRAME_LEN) - { - create_mgif_lzw(); - return; - } - if (!frame_delta_size) return; - reduce_palette(); - filter_colors(frame_delta,frame_delta_size,color_map); - d=join_two_blocks(delta_data,frame_delta,delta_data_size,frame_delta_size,&siz); - init_lzw_compressor(8); - memset(lzw_buffer,0,sizeof(lzw_buffer)); - siz=lzw_encode(d,lzw_buffer,siz); - done_lzw_compressor(); - free(d); - if (siz>FRAME_LEN) - { - create_mgif_lzw(); - return; - } - create_mgif_pal(); - write_chunk(MGIF_DELTA,siz,lzw_buffer); - } - -void create_sound_track(int size) - { - void *p; - - p=getmem(size); - memset(p,0,size); - write_chunk(MGIF_SOUND,size,p); - free(p); - } - -void reserve_track() - { - int size; - - size=SOUND_SPEED/speed; - size&=~1; - create_sound_track(size); - } - -void prereserve_tracks() - { - int size; - int celk; - - size=SOUND_SPEED/speed; - size&=~1; - celk=PRE_SOUND; - while (celk-size>0) - { - open_frame(); - create_sound_track(size); - close_frame(); - celk-=size; - } - if (celk) - { - open_frame(); - create_sound_track(celk); - close_frame(); - } - } - -void fill_header(int frames) - { - memset(&gh,0,sizeof(gh)); - strncpy(gh.sign,MGIF,4); - strncpy(gh.year,MGIF_Y,2); - gh.eof=26; - gh.ver=VER; - gh.frames=frames; - } - - - -void show_screen() - { - word *c; - int i,j; - word *w; - - c=last_frame; - w=screen; - for(i=0;i<180;i++) - { - for(j=0;j<320;j++) - { - *w++=*c; - *w++=*c; - c++; - } - w+=640; - } - showview(0,0,640,360); - showview(0,400,200,20); - } - - -void write_frame_size(int i,int col) - { - char s[20]; - curcolor=0;bar(0,400,200,420); - sprintf(s,"%d %d %d",i,col,hranice);position(0,400);outtext(s); - } - -compress_flc(char *name) - { - int x; - - Open_FLC (name); - charcolors[0]=0; - charcolors[1]=0x7fff; - Get_first_frame (); - Decompress_frame (); - curcolor=0;bar(0,0,639,479); - open_frame(); - create_mgif_lzw(); - close_frame();write_frame_size(last_frame_size,max_colors); - show_screen(); - for (x=2; x<=h_flc.frames; x++) - { - Get_next_frame (); - Decompress_frame (); - open_frame(); - create_mgif_delta(); - close_frame(); - write_frame_size(last_frame_size,max_colors); - if (last_frame_size>MAX_FRAME) hdiff++; - else if (last_frame_size0) hdiff--; - else if (hdiff>0) hdiff--;else if(hdiff<0) hdiff++; - show_screen (); - } - Close_FLC(); - } - -void create_mgf_file(char *name) - { - mgf=fopen(name,"wb+"); - fwrite(&gh,1,sizeof(gh),mgf); - total_frames=0; - } - - -void close_mgf_file() - { - fseek(mgf,0,SEEK_SET); - fill_header(total_frames); - fwrite(&gh,1,sizeof(gh),mgf); - fclose(mgf); - } - - -void create_mult_and_square() - { - int i; - - puts("Creating tables..."); - for(i=0;i<64;i++) mult_table[i]=(short)((i-32)*(i-32)); - for(i=0;i<4096;i++) square_table[i]=(short)sqrt(i); - } - -extern int sada7; - - -main(int argc,char *argv[]) - { - puts("\n(C)1997 Komprimator Motion GIF v0.9 by Ondrej Novak"); - if (argc<3) - { - puts("Pouziti:");putchar('\n');; - puts("FLCMGIF source.flc target.mgf");putchar('\n'); - puts("Tento program generuje soubor MGF z originalniho FLC bez vkladani\n" - "prazdne zvukove stopy a bez ztratove kompresse (pouze convertor)"); - exit(0); - } - create_mgf_file(argv[2]); - initmode32(); - curfont=(void *)&sada7; - compress_flc(argv[1]); - closemode(); - puts("Zaviram Motion GIF..."); - close_mgf_file(); - } diff --git a/VIDEO/JPEGMGFA.ASM b/VIDEO/JPEGMGFA.ASM deleted file mode 100644 index 3982494..0000000 --- a/VIDEO/JPEGMGFA.ASM +++ /dev/null @@ -1,119 +0,0 @@ -.model small -.386 -;16 bit line (de)comprimator -; -DGROUP group _DATA - -extrn _cos_tab:word; - -extrn _line_skip:dword -extrn _xlat_table:dword - -_TEXT segment byte public 'CODE' use32 - assume CS:_TEXT - assume DS:DGROUP - -ADDC macro REG1,REG2,CLIP - local addc1 - add REG1,REG2 - jno addc1 - shl REG2,1 - Mov REG2,CLIP - adc REG2,0 - mov REG1,REG2 -addc1: - endm - -;cos_tab maji format: - -; adresa = pqii (hex) -; p=pozice bodu (0-15 rozdeleno na yyxx) -; q=pozice harmonicke (0-15 je rozdeleno podle code_tabs) -; i=amplituda harmonicke(0-255); -; -; hodnoty jsou FIXED real (reprezentovane v short) -; vysledek je nutne podelit 32; - - -unpack_quant macro - local upqlp1 - ;ah - point - ;vraci dh - bod - ;cl - block_size - ;esi - quant_list - lea ebx,_cos_tab;vem adresu _cos_tab - shl ah,4 ;presun pozici bodu do mista p - and eax,0xf000h ;odmaskuj zbytek - xor ebp,ebp ;vynuluj akumulator (ebp) -upqlp1: lodsb ;vem hodnotu harmonicke na pozici ii - add ebp,[ebx+eax*4];pricti k bp obsah v cos_tab - add eax,0100h ;zvys q - dec cl ;kontrola konce retezce - jnz upqlp1 - sar ebp,9 ;vysledek podel 128 (32*4) - mov eax,ebp ;vysledek je v al -endm - -public unpack_block_ -unpack_block_: ;esi - data - ;edi - out - ;ecx - size - push ebp ;uchovej ebp - mov ch,cl ;uchovej velikost retezce v ch - mov dl,0 ;dl je pozice bodu - mov dh,16 ;dh je pocet bodu -upblck1:push esi ;uchovej esi - mov ah,dl ;napln ah pozici bodu - mov cl,ch ;napln cl delko - unpack_quant ;volej makro pro vypocet bodu - pop esi ;obnov esi - add [edi],al;zapis vysledny bod (vysetruj jako rozdil od predchoziho) - inc edi - inc dl ;presun se na dalsi pozici - dec dh ;sniz citac - jnz upblck1 ;opakuj - pop ebp ;obnov ebp - ret - -public konv_iyg_hicolor_ ;esi - block i - ;edx - block r+b - ;ebx - block g+b - ;edi - out(screen) (hicolor xRRRRRGGGGGBBBBB -konv_iyg_hicolor_: - push ebp - mov ebp,ebx - lea ebx,_xlat_table - mov cl,16 ;celkem ctverec 4x4 -kiyglp1:mov ch,[esi] ;ch obsahuje intenzitu - mov al,ch ;zkopiruj ch do registru pro R G (ch je B) - mov ah,ch - sub ah,[edx] ;vypocet R (I-(R+B)) R+B=[ebp] - sub ch,[ds:ebp] ;vypocet G - sub al,ah ;vypocet B (I-R-G) - sub al,ch - xlatb - xchg ch,al - xlatb - xchg al,ah - xlatb - xchg al,ah - shl al,3 ;al<<3 000RRRRRGGGGG000 eax - shl eax,2 ;ax<<2 0RRRRRGGGGG00000 eax - or al,ch ;or ch 0RRRRRGGGGGBBBBB eax - stosw ;zapis dva body - stosw - inc esi ;zvys indexy do bufferu - inc edx - inc ebp - dec cl ;sniz citac - test cl,3 ;test na dolni 2 bity, pri 0 jdeme na dalsi radek - jnz kiyglp1 - mov eax,_line_skip ;delka obrazovky - sub eax,16 ;odecti celkem 4*2*2=16 byte - add edi,eax ;pricti k ukazateli na obrazovku - or cl,cl ;test na cl==0 - jnz kiyglp1 ;kdyz je pozitivni tak konec - pop ebp - ret -_TEXT ends -end diff --git a/VIDEO/JPEGMGIF.C b/VIDEO/JPEGMGIF.C deleted file mode 100644 index dc2590e..0000000 --- a/VIDEO/JPEGMGIF.C +++ /dev/null @@ -1,172 +0,0 @@ -#include -#include -#include -#include "jpegmgif.h" - -typedef short C_MATICE[4][4]; -typedef float R_MATICE[4][4]; -/* -C_MATICE quant= - { - {16,10,24,51}, - {14,16,40,69}, - {18,37,68,103}, - {49,78,103,120}, - }; -*/ -C_MATICE quant= - { - {2,2,4,24}, - {2,4,8,26}, - {4,8,50,80}, - {8,30,80,88}, - }; - -char xlat_table[256]; - -char code_tab[][2]= - { - {0,0},{1,0},{0,1},{0,2},{1,1},{2,0},{3,0},{2,1},{1,2},{0,3},{1,3},{2,2},{3,1}, - {3,2},{2,3},{3,3} - }; - -int cos_tab[16][16][256]; -short cuv_tab[16]; - -TBOX *rbbox; -TBOX *gbbox; -TBOX *ibox; - -#define CUV (1/1.414) -#define PI 3.14159265 -#define C(u) (u==0?CUV:1) -#define FIXED 512 -#define SCAN_LINE 640 - -int line_skip=4*640; - -void unpack_block(void *source,void *target,int size); -#pragma aux unpack_block parm [esi][edi][ecx] modify [ebx edx eax] -void konv_iyg_hicolor(void *ii,void *rb,void *gb,void *screen); -#pragma aux konv_iyg_hicolor parm[esi][edx][ebx][edi] modify [eax ecx] - -void create_cos_tab() - { - char u,v,i,k,x,y; - int j,tst; - signed char cc,*c; - - for(j=0;j<256;j++) - for(i=0;i<16;i++) - for(k=0;k<16;k++) - { - u=code_tab[i][0]; - v=code_tab[i][1]; - x=k & 3; - y=k >> 2; - cc=j & 0xff; - tst=cos_tab[k][i][j]=(int)(quant[u][v]*cc*C(u)*C(v)*cos((2*x+1)*u*PI/8.0)*cos((2*y+1)*v*PI/8.0)*FIXED); - } - for(i=0;i<16;i++) - { - u=code_tab[i][0]; - v=code_tab[i][1]; - cuv_tab[i]=(u==0)+(v==0); - } - c=xlat_table; - for(j=0;j<256;j++) if (j>127) *c++=0;else if(j>31) *c++=31;else *c++=j; - } - -short zaokrouhlit(float f) - { - if (f>0) return (short)(f+0.5); - if (f<0) return (short)(f-0.5); - return 0; - } - -void Dopredna_transformace(C_MATICE data,C_MATICE koef) - { - char u,v,x,y; - float msum; - - for(u=0;u<4;u++) - for(v=0;v<4;v++) - { - msum=0; - for(x=0;x<4;x++) - for(y=0;y<4;y++) - msum+=data[x][y]*cos((2*x+1)*u*PI/8.0)*cos((2*y+1)*v*PI/8.0); - msum*=C(u)*C(v)/4.0; - koef[u][v]=zaokrouhlit(msum/quant[u][v]); - } - } - -void Kodovani(C_MATICE data,char *out) - { - int i; - for(i=0;i<16;i++) - { - *out++=(char)(data[code_tab[i][0]][code_tab[i][1]]); - } - } - -int string_size(char *data) - { - int i; - i=16; - do - i--; - while (i && !data[i]); - return i+1; - } - -int transformace(void *screen_data,signed char *trans_data,int nextline,int box_place) - { - C_MATICE icm,rbcm,gbcm; - C_MATICE irm,rbrm,gbrm; - short i,r,g,a=0; - signed char *p; - signed char *ii,*rb,*gb; - int x,y; - char *tr=trans_data; - - ii=ibox[box_place]; - rb=rbbox[box_place]; - gb=gbbox[box_place]; - - for(y=0;y<4;y++) - { - p=(char *)screen_data+nextline*3*y; - for(x=0;x<4;x++,a++) - { - i=(p[2]+p[1]+p[0]); - r=(i-p[0]); - g=(i-p[1]); - icm[x][y]=i-ii[a]; - rbcm[x][y]=r-rb[a]; - gbcm[x][y]=g-gb[a]; - p+=3; - } - } - Dopredna_transformace(icm,irm); - Dopredna_transformace(rbcm,rbrm); - Dopredna_transformace(gbcm,gbrm); - Kodovani(irm,trans_data+1);trans_data+=1+(*trans_data=string_size(trans_data+1)); - Kodovani(rbrm,trans_data+1);trans_data+=1+(*trans_data=string_size(trans_data+1)); - Kodovani(gbrm,trans_data+1);trans_data+=1+(*trans_data=string_size(trans_data+1)); - return trans_data-tr; - } - -void zpetna_transformace(char **data,void *screen,int box_place) - { - TBOX *ii,*rb,*gb; - char *dd=*data; - unpack_block(dd+1,ii=ibox+box_place,*dd);dd+=dd[0]+1; - unpack_block(dd+1,rb=gbbox+box_place,*dd);dd+=dd[0]+1; - unpack_block(dd+1,gb=rbbox+box_place,*dd);dd+=dd[0]+1; - *data=dd; - konv_iyg_hicolor(ii,rb,gb,screen); - } - - - diff --git a/VIDEO/JPEGMGIF.H b/VIDEO/JPEGMGIF.H deleted file mode 100644 index 6e9c98c..0000000 --- a/VIDEO/JPEGMGIF.H +++ /dev/null @@ -1,10 +0,0 @@ -void create_cos_tab(); -int transformace(void *screen_data,char *trans_data,int nextline,int box_place0); -void zpetna_transformace(char **data,void *screen,int box_place); - -typedef signed char TBOX[4][4]; - -extern TBOX *rbbox; -extern TBOX *gbbox; -extern TBOX *ibox; - diff --git a/VIDEO/JPEG_SIM.C b/VIDEO/JPEG_SIM.C deleted file mode 100644 index ecf4178..0000000 --- a/VIDEO/JPEG_SIM.C +++ /dev/null @@ -1,252 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "flc.h" - -typedef short C_MATICE[8][8]; -typedef float R_MATICE[8][8]; - -C_MATICE quant= - { - {16,11,10,16,24,40,51,61}, - {12,12,14,19,26,58,60,55}, - {14,13,16,24,40,57,69,56}, - {14,17,22,29,51,87,80,61}, - {18,22,37,56,68,109,103,77}, - {24,35,55,64,81,104,113,92}, - {49,64,78,87,103,121,120,101}, - {72,92,95,98,112,100,103,99} - }; - -/*C_MATICE test= - { - {139,144,149,153,155,155,155,155}, - {144,151,153,156,159,156,156,156}, - {150,155,160,163,158,156,156,156}, - {159,161,162,160,160,159,159,159}, - {159,160,161,162,162,155,155,155}, - {161,161,161,161,160,157,157,157}, - {162,162,161,163,162,157,157,157}, - {162,162,161,161,163,158,158,158} - }; - -*/ -char code_tab[][2]= - { - {0,0},{1,0},{0,1},{0,2},{1,1},{2,0},{3,0},{2,1},{1,2},{0,3},{0,4},{1,3},{2,2}, - {3,1},{4,0},{5,0},{4,1},{3,2},{2,3},{1,4},{0,5},{0,6},{1,5},{2,4},{3,3},{4,2}, - {5,1},{6,0},{7,0},{6,1},{5,2},{4,3},{3,4},{2,5},{1,6},{0,7},{1,7},{2,6},{3,5}, - {4,4},{5,3},{6,2},{7,1},{7,2},{6,3},{5,4},{4,5},{3,6},{2,7},{3,7},{4,6},{5,5}, - {6,4},{7,3},{7,4},{6,5},{5,6},{4,7},{5,7},{6,6},{7,5},{7,6},{6,7},{7,7} - }; - - -short cos_tab[64][64][256]; -short cuv_tab[64]; - -#define CUV (1/1.414) -#define PI 3.14159265 -#define C(u) (u==0?CUV:1) -#define FIXED 128 -#define SCAN_LINE 640 - -char vystup[120000]; -char frame[120000]; -char *ip; - -void create_cos_tab() - { - char u,v,i,k,x,y; - int j; - - for(j=0;j<256;j++) - for(i=0;i<64;i++) - for(k=0;k<64;k++) - { - u=code_tab[i][0]; - v=code_tab[i][1]; - x=k & 0x7; - y=k>>3; - cos_tab[k][i][j]=(short)(quant[u][v]/2*(j-128)*cos((2*x+1)*u*PI/16)*cos((2*y+1)*v*PI/16)*FIXED/4); - } - for(i=0;i<64;i++) - { - u=code_tab[i][0]; - v=code_tab[i][1]; - cuv_tab[i]=(u==0)+(v==0); - } - } - -void Dopredna_transformace(C_MATICE data,R_MATICE koef) - { - char u,v,x,y; - float msum; - - for(u=0;u<8;u++) - for(v=0;v<8;v++) - { - msum=0; - for(x=0;x<8;x++) - for(y=0;y<8;y++) - msum+=data[x][y]*cos((2*x+1)*u*PI/16)*cos((2*y+1)*v*PI/16); - msum*=0.25*C(u)*C(v); - koef[u][v]=msum; - } - } - -short zaokrouhlit(float f) - { - if (f>0) return (short)(f+0.5); - if (f<0) return (short)(f-0.5); - return 0; - } - -void Kvantifikace(R_MATICE data,C_MATICE out) - { - char u,v; - - for(u=0;u<8;u++) - for(v=0;v<8;v++) - out[u][v]=zaokrouhlit(data[u][v]*2/quant[u][v]); - } - -void Kodovani(C_MATICE data,char *out) - { - int i; - for(i=0;i<64;i++) - { - *out++=(char)(data[code_tab[i][0]][code_tab[i][1]]); - } - } - -void Zpetna_rychla_transformace(char *data,int delka,char *vystup) - { - char *hodn; - char *p; - char i,j; - int s; - - p=vystup; - for(j=0;j<64;j++) - { - s=0;hodn=data; - for(i=0;i>1;break; - } - } - *p++=(char)(s/FIXED); - } - } - -void read_bar_8x8(char *data,C_MATICE vystup) - { - int i,j; - for(i=0;i<8;i++) - { - for(j=0;j<8;j++) - vystup[j][i]=*data++; - data+=SCAN_LINE-j; - } - } - -void write_jpg_info(char *block,char *vystup,int *size) - { - for(*size=64;*size>0;(*size)--) - if (block[*size-1]!=0) break; - memcpy(vystup,size,1); - memcpy(vystup+1,block,*size); - } - - - -void konvert_color_Y() - { - int i; - char *c,*d; - c=frame_buffer; - d=frame; - for(i=0;i>2; - } - -void compress_layer(char *from,char *to) - { - R_MATICE r; - C_MATICE c; - char out[64]; - int s,x,y; - - for(y=0;y<24;y++) - for(x=0;x<80;x++) - { - read_bar_8x8(&from[(y*SCAN_LINE+x)*8],c); - Dopredna_transformace(c,r); - Kvantifikace(r,c); - Kodovani(c,out); - write_jpg_info(out,to,&s); - to+=s+1; - } - } - -void decompress_layer(char *from,char *to) - { - char size; - int x,y,z; - char out[64]; - char *a; - - for(y=0;y<24;y++) - for(x=0;x<80;x++) - { - a=to+((SCAN_LINE*y+x)*8); - size=*from++; - Zpetna_rychla_transformace(from,size,out); - from+=size; - for(z=0;z<8;z++) memcpy(a+=640,out+z*8,8); - } - } - -void display() - { - word *c; - char *z; - char d; - int i; - - c=lbuffer; - z=frame; - for(i=0;i<640*180;i++) - { - d=*z++;d>>=3; - *c++=d+(d<<5)+(d<<10); - } - } - -void main() - { - - printf("creating %d Kb table\n",sizeof(cos_tab)/1024); - create_cos_tab(); - Open_FLC("trava.flc"); - Get_first_frame(); - Decompress_frame(); - Close_FLC(); - konvert_color_Y(); - puts("compress"); - compress_layer(frame,vystup); - puts("decompress"); - decompress_layer(vystup,frame); - initmode32(NULL); - display(); - getche(); - closemode(); - } - - diff --git a/VIDEO/LZW.C b/VIDEO/LZW.C deleted file mode 100644 index 05fe405..0000000 --- a/VIDEO/LZW.C +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include -#include -#include - - -#define LZW_MAX_CODES 4096 - -typedef struct double_s - { - short group,chr,first,next; - }DOUBLE_S; - -typedef DOUBLE_S CODE_TABLE[LZW_MAX_CODES]; - -DOUBLE_S *compress_dic; -int clear_code; -int end_code; -int free_code; -int nextgroup; -int bitsize,init_bitsize; -char old_value=0; - -void do_clear_code() - { - int i; - - old_value=0; - nextgroup=free_code; - bitsize=init_bitsize; - for(i=0;igroup=i;p->chr=-1;p->next=-1;p->first=-1; - } - } - -void reinit_lzw() - { - do_clear_code(); - } - -void init_lzw_compressor(int dic_size) - { - compress_dic=(CODE_TABLE *)getmem(sizeof(CODE_TABLE)); - clear_code=1<group; - ps=compress_dic[ps].first; - while (ps!=-1) - { - if (compress_dic[ps].chr==p->chr) return ps; - ps=compress_dic[ps].next; - } - return -1; - } - - -void add_code(DOUBLE_S *p) - { - p->first=-1;p->next=compress_dic[p->group].first; - memcpy(&compress_dic[nextgroup],p,sizeof(DOUBLE_S)); - compress_dic[p->group].first=nextgroup; - nextgroup++; - } - - -long lzw_encode(char *source,void *target,int size) - { - long bitpos=0; - DOUBLE_S p; - int f; - - clear: - old_value=p.group=*source++;size--; - while (size-->0) - { - p.chr=(int)((char)(*source++-old_value));old_value+=p.chr; - f=find_code(&p); - if (f<0) - { - bitpos=output_code(target,bitpos,bitsize,p.group); - add_code(&p); - if (nextgroup==(1<=LZW_MAX_CODES) - { - bitpos=output_code(target,bitpos,bitsize,p.group); - bitpos=output_code(target,bitpos,bitsize,clear_code); - do_clear_code(); - goto clear; - } - } - else - p.group=f; - } - bitpos=output_code(target,bitpos,bitsize,p.group); - bitpos=output_code(target,bitpos,bitsize,end_code); - return (bitpos+8)>>3; - } - - -void de_add_code(DOUBLE_S *p,int *mask) - { - DOUBLE_S *q; - - q=&compress_dic[nextgroup];q->group=p->group;q->chr=p->chr;q->first=compress_dic[p->group].first+1; - nextgroup++; - if (nextgroup==*mask) - { - *mask=(*mask<<1)+1; - bitsize++; - } - } - - - -int expand_code(int code,char **target) - { - static int first; - - if (code>end_code) - { - expand_code(compress_dic[code].group,target); - **target=old_value=compress_dic[code].chr+old_value; - (*target)++; - } - else - { - **target=old_value=code+old_value; - (*target)++; - first=code; - } - return first; - } - -char fast_expand_code(int code,char **target); -#pragma aux fast_expand_code parm[eax][edi] modify [esi ecx] value [bl] - -void lzw_decode(void *source,char *target) - { - long bitpos=0; - int code,old,i; - DOUBLE_S p; - int old_first; - int mask=0xff; - - - for(i=0;i -#include -#include -#include - -#define getmem(s) malloc(s) -#define New(typ) (typ *)getmem(sizeof(typ)) -#define NewArr(typ,pocet) (typ *)getmem(sizeof(typ)*pocet); -#define ClrArr(p,typ,pocet) memset(p,0,sizeof(typ)*pocet); - -#define LZW_MAX_CODES 4096 - -typedef struct double_s - { - short group,chr,first,next; - }DOUBLE_S; - -typedef DOUBLE_S CODE_TABLE[LZW_MAX_CODES]; - -DOUBLE_S *compress_dic; -int clear_code; -int end_code; -int free_code; -int nextgroup; -int bitsize,init_bitsize; -char old_value=0; - -void do_clear_code() //funkce maze slovni (clear code) - { - int i; - - old_value=0; - nextgroup=free_code; - bitsize=init_bitsize; - for(i=0;igroup=i;p->chr=-1;p->next=-1;p->first=-1; - } - } - -void reinit_lzw() - { - do_clear_code(); - } - -void init_lzw_compressor(int dic_size) - //dic size je velikost slovniku(bitova) - //pro 8 bitove hodnoty zde vloz 8. - { - compress_dic=(CODE_TABLE *)getmem(sizeof(CODE_TABLE)); - clear_code=1<>3; - data<<=bitepos & 7; - c[0]|=data; - c[1]=data>>8; - c[2]=data>>16; - return bitepos+bitesize; - } - -int input_code(void *source,long *bitepos,int bitsize,int mask); -#pragma aux input_code parm [esi][edi][ebx][edx]=\ - "mov ecx,[edi]"\ - "mov eax,ecx"\ - "shr eax,3"\ - "mov eax,[esi+eax]"\ - "and cl,7"\ - "shr eax,cl"\ - "and eax,edx"\ - "add [edi],ebx"\ - value[eax] modify [ecx]; - -int input_code_c(unsigned char *source,long *bitepos,int bitsize,int mask) - { - unsigned char *c;int x; - c=source; - c+=*bitepos>>3; - x=c[0]+(c[1]<<8)+(c[2]<<16); - x>>=*bitepos & 7; - x &= mask; - *bitepos=*bitepos+bitsize; - return x; - } - - -int find_code(DOUBLE_S *p) - //hleda skupinu ve slovniku. Pokud neexistuje vraci -1; - { - int ps; - - ps=p->group; - ps=compress_dic[ps].first; - while (ps!=-1) - { - if (compress_dic[ps].chr==p->chr) return ps; - ps=compress_dic[ps].next; - } - return -1; - } - - -void add_code(DOUBLE_S *p) - //vklada novou dvojici - { - p->first=-1;p->next=compress_dic[p->group].first; - memcpy(&compress_dic[nextgroup],p,sizeof(DOUBLE_S)); - compress_dic[p->group].first=nextgroup; - nextgroup++; - } - - -long lzw_encode(unsigned char *source,void *target,int size) - //Encode LZW. zdroj, cil a velikost dat. Vraci velikost komprimovano. - { - long bitpos=0; - DOUBLE_S p; - int f; - - clear: - old_value=p.group=*source++;size--; - while (size-->0) - { - p.chr=(int)((unsigned char)(*source++));old_value+=p.chr; - f=find_code(&p); - if (f<0) - { - bitpos=output_code_c(target,bitpos,bitsize,p.group); - add_code(&p); - if (nextgroup==(1<=LZW_MAX_CODES) - { - bitpos=output_code_c(target,bitpos,bitsize,p.group); - bitpos=output_code_c(target,bitpos,bitsize,clear_code); - do_clear_code(); - goto clear; - } - } - else - p.group=f; - } - bitpos=output_code_c(target,bitpos,bitsize,p.group); - bitpos=output_code_c(target,bitpos,bitsize,end_code); - return (bitpos+8)>>3; - } - - -void de_add_code(DOUBLE_S *p,int *mask) - { - DOUBLE_S *q; - - q=&compress_dic[nextgroup];q->group=p->group;q->chr=p->chr;q->first=compress_dic[p->group].first+1; - nextgroup++; - if (nextgroup==*mask) - { - *mask=(*mask<<1)+1; - bitsize++; - } - } - - - -int expand_code(int code,unsigned char **target) - { - static int first; - - if (code>end_code) - { - assert(compress_dic[code].group - -#define MAX_BUFF 65536 - -#define INPUT "testx" -#define OUTPUT "testx.l" -#define ARCH "e:\\SYSLOG.LZW" - -char input_buffer[MAX_BUFF*2]; -char output_buffer[MAX_BUFF*2]; - -FILE *in,*out; - -int datasize; -int compsize; - -void open_files(char *sr,char *tg) - { - in=fopen(sr,"rb"); - out=fopen(tg,"wb"); - if (in==NULL || out==NULL) abort(); - } - -void close_files() - { - fclose(in); - fclose(out); - } - - -void read_normal() - { - - datasize=fread(input_buffer,1,MAX_BUFF,in); - } - -void save_normal() - { - - fwrite(output_buffer,1,datasize,out); - } - - -int read_comp() - { - fread(&datasize,1,sizeof(datasize),in); - fread(&compsize,1,sizeof(datasize),in); - return fread(input_buffer,1,compsize,in); - } - -void save_comp() - { - fwrite(&datasize,1,sizeof(datasize),out); - fwrite(&compsize,1,sizeof(datasize),out); - fwrite(output_buffer,1,compsize,out); - } - - -main() - { - puts(""); - - init_lzw_compressor(8); - open_files(INPUT,ARCH); - read_normal(); - while (datasize!=0) - { - memset(output_buffer,0,sizeof(output_buffer)); - compsize=lzw_encode(input_buffer,output_buffer,datasize); - printf("Origin: %d Packed: %d Ratio %d%%\n",datasize,compsize,compsize*100/datasize); - save_comp(); - read_normal(); - reinit_lzw(); - } - close_files(); - done_lzw_compressor(); - init_lzw_compressor(8); - open_files(ARCH,OUTPUT); - while (read_comp()) - { - lzw_decode(input_buffer,output_buffer); - save_normal(); - reinit_lzw(); - } - done_lzw_compressor(); - printf("Compressed file has been extracted back\n"); - close_files(); - printf("and saved as %s.\n",OUTPUT); - } - diff --git a/VIDEO/MGFPLAYA.ASM b/VIDEO/MGFPLAYA.ASM deleted file mode 100644 index a1406b0..0000000 --- a/VIDEO/MGFPLAYA.ASM +++ /dev/null @@ -1,500 +0,0 @@ -.model small -.386 -;16 bit line (de)comprimator -; -DGROUP group _DATA - -extrn _lbuffer:dword -extrn _backsndbuff:word -extrn _vals_save:dword -extrn _backsnd:dword -extrn _lastbank:dword -extrn _gr_page_end:word -extrn _gr_end_screen:dword - - -_TEXT segment byte public 'CODE' use32 - assume CS:_TEXT - assume DS:DGROUP - -extrn mapvesaadr_:proc -extrn switchmap_:proc -extrn switchvesabank_:proc - - - -public show_full_interl_lfb_ - -show_full_interl_lfb_: - ;edi - target - ;esi - source - ;ebx - palette - push ebp - mov dl,180 -shfif2: mov ecx,320 -shfif1: lodsb - movzx eax,al - movzx eax,word ptr [eax*2+ebx] - mov ebp,eax - shl eax,16 - or eax,ebp - stosd - dec ecx - jnz shfif1 - add edi,1280 - dec dl - jnz shfif2 - pop ebp - ret - - -public show_delta_interl_lfb_ -show_delta_interl_lfb_: - ;edi - target - ;esi - source - ;ebx - palette - push ebp ;uchovej ebp - mov cl,180 ;cl pocet zbyvajicich radek - add esi,4 ;preskoc ukazatel - mov edx,esi ;edx - zacatek delta mapy - add esi,[esi-4] ;esi - zacatek dat -shdif6: push edi ;uloz adresu radku -shdif2: mov ch,[edx] ;cti _skip_ hodnotu - mov al,ch - inc edx - or al,03fh ;test zda jsou 2 nejvyssi bity nastaveny - inc al - jz shdif3 ;ano - preskakovani radku - movzx eax,ch ;expanduj _skip_ hodnotu do eax - lea edi,[eax*8+edi] ;vypocti novou pozici na obrazovce - mov ch,[edx] ;cti _copy_ hodnotu - inc edx -shdif1: lodsb ;vem bajt z datove oblasti - movzx eax,al ;expanduj do eax - movzx eax,word ptr[eax*2+ebx] ;expanduj hicolor barvu - mov ebp,eax ;rozdvoj barvy - shl ebp,16 - or eax,ebp - stosd ;zapis dva body - lodsb ;opakuj pro dalsi bod jeste jednou - movzx eax,al - movzx eax,word ptr[eax*2+ebx] - mov ebp,eax - shl ebp,16 - or eax,ebp - stosd - dec ch ;odecti _copy_ hodnotu - jnz shdif1 ;dokud neni 0 - jmp shdif2 ;pokracuj _skip_ hodnotou -shdif3: and ch,3fh ;odmaskuj hodni 2 bity - pop edi ;obnov edi - jnz shdif4 ;pokud je ch=0 preskoc jen jeden radek; - add edi,1280*2 ;preskoc radek - dec cl ;odecti citac radku - jnz shdif6 ;skok pokud neni konec - pop ebp - ret ;navrat -shdif4: inc ch ;pocet radek je ch+1 - sub cl,ch ;odecti ch od zbyvajicich radek - jz shdif5 ;je-li nula tak konec -shdif7: add edi,1280*2 ;preskoc radek - dec ch ;odecti ch - jnz shdif7 ;preskakuj dokud neni 0 - jmp shdif6 ;cti dalsi _skip_ -shdif5: pop ebp - ret ;konec - - -public show_full_interl_lfb130_ - -show_full_interl_lfb130_: - ;edi - target - ;esi - source - ;ebx - palette - push ebp - mov dl,180 -shfil2: mov ecx,160 -shfil1: lodsw - movzx ebp,al - movzx ebp,word ptr ds:[ebp*2+ebx] - movzx eax,ah - movzx eax,word ptr ds:[eax*2+ebx] - shl eax,16 - or eax,ebp - stosd - dec ecx - jnz shfil1 - add edi,640 - dec dl - jnz shfil2 - pop ebp - ret - - -public show_delta_interl_lfb130_ -show_delta_interl_lfb130_: - ;edi - target - ;esi - source - ;ebx - palette - push ebp ;uchovej ebp - mov cl,180 ;cl pocet zbyvajicich radek - add esi,4 ;preskoc ukazatel - mov edx,esi ;edx - zacatek delta mapy - add esi,[esi-4] ;esi - zacatek dat -shdil6: push edi ;uloz adresu radku -shdil2: mov ch,[edx] ;cti _skip_ hodnotu - mov al,ch - inc edx - or al,03fh ;test zda jsou 2 nejvyssi bity nastaveny - inc al - jz shdil3 ;ano - preskakovani radku - movzx eax,ch ;expanduj _skip_ hodnotu do eax - lea edi,[eax*4+edi] ;vypocti novou pozici na obrazovce - mov ch,[edx] ;cti _copy_ hodnotu - inc edx -shdil1: lodsw - movzx ebp,al - movzx ebp,word ptr ds:[ebp*2+ebx] - movzx eax,ah - movzx eax,word ptr ds:[eax*2+ebx] - shl eax,16 - or eax,ebp - stosd - dec ch ;odecti _copy_ hodnotu - jnz shdil1 ;dokud neni 0 - jmp shdil2 ;pokracuj _skip_ hodnotou -shdil3: and ch,3fh ;odmaskuj hodni 2 bity - pop edi ;obnov edi - jnz shdil4 ;pokud je ch=0 preskoc jen jeden radek; - add edi,1280 ;preskoc radek - dec cl ;odecti citac radku - jnz shdil6 ;skok pokud neni konec - pop ebp - ret ;navrat -shdil4: inc ch ;pocet radek je ch+1 - sub cl,ch ;odecti ch od zbyvajicich radek - jz shdil5 ;je-li nula tak konec -shdil7: add edi,1280 ;preskoc radek - dec ch ;odecti ch - jnz shdil7 ;preskakuj dokud neni 0 - jmp shdil6 ;cti dalsi _skip_ -shdil5: pop ebp - ret ;konec - - -public show_full_lfb12e_ - -show_full_lfb12e_: - ;edi - target - ;esi - source - ;ebx - palette - push ebp - mov dl,180 -shfl2: mov ecx,160 -shfl1: lodsw - movzx ebp,al - movzx ebp,word ptr ds:[ebp*2+ebx] - movzx eax,ah - movzx eax,word ptr ds:[eax*2+ebx] - shl eax,16 - or eax,ebp - stosd - dec ecx - jnz shfl1 - dec dl - jnz shfl2 - pop ebp - ret - - -public show_delta_lfb12e_ -show_delta_lfb12e_: - ;edi - target - ;esi - source - ;ebx - palette - push ebp ;uchovej ebp - mov cl,180 ;cl pocet zbyvajicich radek - add esi,4 ;preskoc ukazatel - mov edx,esi ;edx - zacatek delta mapy - add esi,[esi-4] ;esi - zacatek dat -shdl6: push edi ;uloz adresu radku -shdl2: mov ch,[edx] ;cti _skip_ hodnotu - mov al,ch - inc edx - or al,03fh ;test zda jsou 2 nejvyssi bity nastaveny - inc al - jz shdl3 ;ano - preskakovani radku - movzx eax,ch ;expanduj _skip_ hodnotu do eax - lea edi,[eax*4+edi] ;vypocti novou pozici na obrazovce - mov ch,[edx] ;cti _copy_ hodnotu - inc edx -shdl1: lodsw - movzx ebp,al - movzx ebp,word ptr ds:[ebp*2+ebx] - movzx eax,ah - movzx eax,word ptr ds:[eax*2+ebx] - shl eax,16 - or eax,ebp - stosd - dec ch ;odecti _copy_ hodnotu - jnz shdl1 ;dokud neni 0 - jmp shdl2 ;pokracuj _skip_ hodnotou -shdl3: and ch,3fh ;odmaskuj hodni 2 bity - pop edi ;obnov edi - jnz shdl4 ;pokud je ch=0 preskoc jen jeden radek; - add edi,640 ;preskoc radek - dec cl ;odecti citac radku - jnz shdl6 ;skok pokud neni konec - pop ebp - ret ;navrat -shdl4: inc ch ;pocet radek je ch+1 - sub cl,ch ;odecti ch od zbyvajicich radek - jz shdl5 ;je-li nula tak konec -shdl7: add edi,640 ;preskoc radek - dec ch ;odecti ch - jnz shdl7 ;preskakuj dokud neni 0 - jmp shdl6 ;cti dalsi _skip_ -shdl5: pop ebp - ret ;konec - - - -nextbank macro - mov eax,_lastbank ;ano, pak vem cislo banky - inc eax ;pricti 1 - mov _lastbank,eax ;zapis jako nove cislo banky - pushad ;uchovej vse - call switchvesabank_ ;prepni banku - popad ;obnov vse - movzx edi,di - add edi,0a0000h ;vynuluj dolni cast di -endm - -skipm macro reg - local skp1 - - mov ax,_gr_page_end - movzx edi,di - dec ax - add edi,reg - inc eax - cmp edi,eax - jc skp1 - mov eax,_lastbank ;ano, pak vem cislo banky - inc eax ;pricti 1 - mov _lastbank,eax ;zapis jako nove cislo banky - pushad ;uchovej vse - call switchvesabank_ ;prepni banku - popad ;obnov vse - movzx edi,di -skp1: or edi,0a0000h -endm - - - -public show_full_interl_bank_ -show_full_interl_bank_: - ;edi - target - ;esi - source - ;ebx - palette - call mapvesaadr_ - mov dl,180 -shfib2: mov ecx,320 - push ebp -shfib1: cmp edi,_gr_end_screen - jc shfib3 - nextbank -shfib3: lodsb - movzx eax,al - movzx eax,word ptr [eax*2+ebx] - mov ebp,eax - shl eax,16 - or eax,ebp - stosd - dec ecx - jnz shfib1 - pop ebp - add edi,1280 - dec dl - jnz shfib2 - ret - - -public show_delta_interl_bank_ -show_delta_interl_bank_: - ;edi - target - ;esi - source - ;ebx - palette - mov cl,180 ;cl pocet zbyvajicich radek - add esi,4 ;preskoc ukazatel - mov edx,esi ;edx - zacatek delta mapy - add esi,[esi-4] ;esi - zacatek dat -shdib6: push ebp ;uchovej ebp - push edi - call mapvesaadr_ -shdib2: mov ch,[edx] ;cti _skip_ hodnotu - mov al,ch - inc edx - or al,03fh ;test zda jsou 2 nejvyssi bity nastaveny - inc al - jz shdib3 ;ano - preskakovani radku - movzx eax,ch ;expanduj _skip_ hodnotu do eax - lea edi,[eax*8+edi] ;vypocti novou pozici na obrazovce - mov ch,[edx] ;cti _copy_ hodnotu - inc edx - cmp edi,_gr_end_screen - jc shdib1 - nextbank -shdib1: lodsb ;vem bajt z datove oblasti - movzx eax,al ;expanduj do eax - movzx eax,word ptr[eax*2+ebx] ;expanduj hicolor barvu - mov ebp,eax ;rozdvoj barvy - shl ebp,16 - or eax,ebp - stosd ;zapis dva body - cmp edi,_gr_end_screen - jc shdib8 - nextbank -shdib8: lodsb ;opakuj pro dalsi bod jeste jednou - movzx eax,al - movzx eax,word ptr[eax*2+ebx] - mov ebp,eax - shl ebp,16 - or eax,ebp - stosd - dec ch ;odecti _copy_ hodnotu - jnz shdib1 ;dokud neni 0 - jmp shdib2 ;pokracuj _skip_ hodnotou -shdib3: pop edi - pop ebp - and ch,3fh ;odmaskuj hodni 2 bity - jnz shdib4 ;pokud je ch=0 preskoc jen jeden radek; - add edi,2*1280 - dec cl ;odecti citac radku - jnz shdib6 ;skok pokud neni konec - ret ;navrat -shdib4: inc ch ;pocet radek je ch+1 - sub cl,ch ;odecti ch od zbyvajicich radek - jz shdib5 ;je-li nula tak konec -shdib7: add edi,2*1280 ;preskoc radek - dec ch ;odecti ch - jnz shdib7 ;preskakuj dokud neni 0 - jmp shdib6 ;cti dalsi _skip_ -shdib5: ret ;konec - - - -public sound_decompress_ ;dekompresuje hudbu - -sound_decompress_: ;esi - source - ;edi - target pos in backsndbuff - ;ecx - datasize - ;ebx - ampl_table - ;(vraci edi - pozici v backsndbuff) - mov edx,_vals_save -snddec1:lodsb - movzx eax,al - movzx eax,word ptr [eax*2+ebx] - add dx,ax - mov _backsndbuff[edi],dx - add edi,2 - and edi,3ffffh - rol edx,16 - dec ecx - jnz snddec1 - mov _vals_save,edx - ret - -public test_next_frame_ ;testuje zda je volno pro dalsi zvukovy blok - -test_next_frame_: ;edi - pozice - ;ecx - delka bloku - mov ebx,_backsnd - shl ecx,1 - shl ebx,2 - xor ecx,3ffffh - sub edi,ebx - jnc tnf1 - add edi,40000h -tnf1: cmp ecx,edi - rcl al,1 - and al,1 - ret - - - -public show_full_interl_lfb_256_ - -show_full_interl_lfb_256_: - ;edi - target - ;esi - source - ;ebx - palette - mov dl,180 -s2fif2: mov ecx,320 -s2fif1: lodsb - movzx eax,al - movzx eax,word ptr [eax*2+ebx] - stosw - dec ecx - jnz s2fif1 - add edi,640 - dec dl - jnz s2fif2 - ret - - -public show_delta_interl_lfb_256_ -show_delta_interl_lfb_256_: - ;edi - target - ;esi - source - ;ebx - palette - push ebp ;uchovej ebp - mov cl,180 ;cl pocet zbyvajicich radek - add esi,4 ;preskoc ukazatel - mov edx,esi ;edx - zacatek delta mapy - add esi,[esi-4] ;esi - zacatek dat -s2dif6: push edi ;uloz adresu radku -s2dif2: mov ch,[edx] ;cti _skip_ hodnotu - mov al,ch - inc edx - or al,03fh ;test zda jsou 2 nejvyssi bity nastaveny - inc al - jz s2dif3 ;ano - preskakovani radku - movzx eax,ch ;expanduj _skip_ hodnotu do eax - lea edi,[eax*4+edi] ;vypocti novou pozici na obrazovce - mov ch,[edx] ;cti _copy_ hodnotu - inc edx -s2dif1: lodsb ;vem bajt z datove oblasti - movzx eax,al ;expanduj do eax - movzx eax,word ptr[eax*2+ebx] ;expanduj hicolor barvu - mov ebp,eax ;rozdvoj barvy - lodsb ;opakuj pro dalsi bod jeste jednou - movzx eax,al - movzx eax,word ptr[eax*2+ebx] - shl eax,16 - or eax,ebp - stosd ;zapis 4 body - dec ch ;odecti _copy_ hodnotu - jnz s2dif1 ;dokud neni 0 - jmp s2dif2 ;pokracuj _skip_ hodnotou -s2dif3: and ch,3fh ;odmaskuj hodni 2 bity - pop edi ;obnov edi - jnz s2dif4 ;pokud je ch=0 preskoc jen jeden radek; - add edi,640*2 ;preskoc radek - dec cl ;odecti citac radku - jnz s2dif6 ;skok pokud neni konec - pop ebp - ret ;navrat -s2dif4: inc ch ;pocet radek je ch+1 - sub cl,ch ;odecti ch od zbyvajicich radek - jz s2dif5 ;je-li nula tak konec -s2dif7: add edi,640*2 ;preskoc radek - dec ch ;odecti ch - jnz s2dif7 ;preskakuj dokud neni 0 - jmp s2dif6 ;cti dalsi _skip_ -s2dif5: pop ebp - ret ;konec - -_TEXT ends - -end diff --git a/VIDEO/MGFSOUND.C b/VIDEO/MGFSOUND.C deleted file mode 100644 index 851b3be..0000000 --- a/VIDEO/MGFSOUND.C +++ /dev/null @@ -1,558 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define BLK_SIZE 100000 -#define CHANNELS 256 -#define SND_NAME ".SNF" - -typedef struct volstruc - { - int volslow,volsmax; - int volume; - int volume_end; - int vls; - - }TVOLSTRUC; - -typedef struct tchaninfo - { - FILE *snd; - char chans; - char bit8; - long repstart; - long id ; - long size; - TVOLSTRUC left,right; - }TCHANINFO; - -TCHANINFO chaninfo[CHANNELS]; - -typedef struct mgif_header - { - char sign[4]; - char year[2]; - char eof; - word ver; - long frames; - word snd_chans; - int snd_freq; - short ampl_table[256]; - short reserved[32]; - }; - -struct mgif_header gh; - -short ampl_table[256]; -signed short source[BLK_SIZE]; -char target[BLK_SIZE]; -int glob_volume=256; - -long sfreq; -unsigned short chans; -FILE *sf; -int tf; - -char *nsource; -char *ntarget; -long ssize; -long rsize,blck; -char difftype=4; - -int last_channel; - -long next_frame; - -int find_free_channel() - { - int i; - for(i=0;i<256;i++) if (chaninfo[i].snd==NULL) return i; - printf("Nemohu pridat zvuk. Jiz je zaplneno vsech %d kanalďż˝\n",CHANNELS); - return -1; - } - -void Create_table_16() - { - int a,c,d,e; - float b; - - d=-1;e=0; - for(a=0;a<128;a++) - { - b=(a/128.0); - switch (difftype) - { - case 1:b=(b*32768.0);break; - case 2:b=(b*b*32768.0);break; - case 3:b=(b*b*b*32768.0);break; - case 4:b=(b*b*b*b*32768.0);break; - case 5:b=(b*b*b*b*b*32768.0);break; - } - c=(int)b; - if (c==d) e++; - d=c;c+=e; - ampl_table[128+a]=c; - ampl_table[128-a]=-c; - } - } - -int find_index(int value) - { - int i; - - if (value==0) return 128; - if (value>0) - { - for(i=128;i<256;i++) - if (ampl_table[i]>value) return i-1; - return 255; - } - else - { - for(i=128;i>=0;i--) - if (ampl_table[i]32768 || last1<-32768) abort(); - target[i]=indx; - } - else - { - val=source[i]; - indx=find_index(val-last2); - last2+=ampl_table[indx]; - if (last2>32768 || last2<-32768) abort(); - target[i]=indx; - } - } - } - -void find_data() - { - char w[5]="data"; - int i,d; - - i=0; - do - { - d=fgetc(sf); - if (d==w[i]) i++;else i=0; - if (d==EOF) abort(); - } - while (i<4); - } - -void open_wav(char *wav) - { - TCHANINFO *inf; - int i; - struct t_wave *wavinf; - FILE *snd; - - i=find_free_channel(); - if (i==-1) return; - last_channel=i; - inf=chaninfo+i; - snd=fopen(wav,"rb"); - if (snd==NULL) - { - printf("Soubor %s neexistuje.\n",wav); - return; - } - if (find_chunk(snd,WAV_FMT)==-1) - { - printf("Soubor %s ma poskozenou hlavicku\n",wav); - fclose(snd); - return; - } - wavinf=(struct t_wave *)malloc(get_chunk_size(snd)); - if (wavinf==NULL) - { - puts("Nedostatek pamďż˝ti."); - return; - } - read_chunk(snd,wavinf); - if (wavinf->wav_mode!=1) - { - printf("Tento program podporuje pouze WAVy typu 1 (%s)\n",wav); - free(wavinf); - fclose(snd); - return; - } - inf->chans=wavinf->chans; - inf->bit8=wavinf->freq*wavinf->chans==wavinf->bps; - inf->repstart=-1; - inf->id=-1; - inf->left.volume=32768; - inf->right.volume=32768; - inf->left.vls=0; - inf->right.vls=0; - free(wavinf); - if (find_chunk(snd,WAV_DATA)==0) - { - printf("Soubor %s je poskozen\n",wav); - fclose(snd); - return; - } - inf->size=get_chunk_size(snd); - fseek(snd,4,SEEK_CUR); - inf->snd=snd; - } - -void calc_vls(TVOLSTRUC *vls) - { - vls->volslow--; - if (vls->volslow<=0) - { - vls->volslow+=vls->volsmax; - vls->volume+=vls->vls; - if ((vls->vls>0 && vls->volume>=vls->volume_end)|| - (vls->vls<0 && vls->volume<=vls->volume_end)) - { - vls->volume=vls->volume_end; - vls->vls=0; - } - } - } - -void mix_buffer(int size) - { - int chan,i; - memset(source,0,size*2); - for(chan=0;chanbit8) - { - fread(&left,1,1,inf->snd);left=(short)(left*256); - left^=0xffff8000; - inf->size--; - } - else - { - fread(&left,1,2,inf->snd);left=(short)left; - inf->size-=2; - } - if (inf->chans==1) right=left; - else - if (inf->bit8) - { - fread(&right,1,1,inf->snd);right=(short)(right*256); - right^=0xffff8000; - inf->size--; - } - else - { - fread(&right,1,2,inf->snd);right=(short)right; - inf->size-=2; - } - left=(int)left*inf->left.volume/(32768); - right=(int)right*inf->right.volume/(32768); - left=left*glob_volume/256; - right=right*glob_volume/256; - calc_vls(&inf->left); - calc_vls(&inf->right); - left+=source[i]; - right+=source[i+1]; - if (left>32767) left=32767; - if (left<-32767) left=-32767; - if (right>32767) right=32767; - if (right<-32767) right=-32767; - source[i]=left; - source[i+1]=right; - if (inf->size<=0) - { - if (inf->repstart!=-1) - { - fseek(inf->snd,0,SEEK_SET); - find_chunk(inf->snd,WAV_DATA); - inf->size=get_chunk_size(inf->snd); - fseek(inf->snd,4,SEEK_CUR); - fseek(inf->snd,inf->repstart,SEEK_CUR); - inf->size-=inf->repstart; - } - else - { - fclose(inf->snd); - inf->snd=NULL; - break; - } - } - } - } - } - } - - -void open_files(char *ntarget) - { - tf=open(ntarget,O_BINARY | O_RDWR); - if (!tf) abort(); - lseek(tf,0,SEEK_SET); - read(tf,&gh,sizeof(gh)); - memcpy(gh.ampl_table,ampl_table,sizeof(ampl_table)); - gh.snd_freq=22050; - } - - -void read_frame() - { - long x; - read(tf,&x,4); - x>>=8; - next_frame=tell(tf)+x; - } - -long find_sound_action() - { - long x;char c; - - do - { - read(tf,&x,4); - c=x;x>>=8; - if (c==4) return x; - lseek(tf,x,SEEK_CUR); - } - while (1); - } - - -void press_sound_chunk() - { - int siz; - - - siz=find_sound_action(); - mix_buffer(siz); - compress_buffer_stereo(siz); - write(tf,&target,siz); - } - -void close_files() - { - int i; - lseek(tf,0,SEEK_SET); - write(tf,&gh,sizeof(gh)); - fclose(sf); - close(tf); - for(i=0;ileft; - else if (!strcmp(command,"L")) v=&inf->right; - else if (!strcmp(command,"VOL")) - { - get_num(c,num); - v->volume=num*128; - } - else if (!strcmp(command,"VOLEND")) - { - get_num(c,num); - v->volume_end=num*128; - v->vls=0; - } - else if (!strcmp(command,"SPEED")) - { - get_num(c,v->vls);v->volsmax=1;v->volslow=1; - if (v->volume>v->volume_end) v->vls=-v->vls; - } - else if (!strcmp(command,"SLOW")) - { - get_num(c,v->volsmax);v->vls=1;v->volslow=1; - if (v->volume>v->volume_end) v->vls=-v->vls; - } - else if (!strcmp(command,"REPSTART")){ get_num(c,inf->repstart);} - else if (!strcmp(command,"GLOBVOL")) {get_num(c,glob_volume);} - } - else - { - char filename[128]; - sscanf(c,"%127s",filename); - c=strchr(c,32); - open_wav(filename); - inf=chaninfo+last_channel; - fcid=1; - } - } - } - -void call_script(char *script_name) - { - FILE *scr,*snf; - char name[256]; - char snd_name[256],*c; - int i,fr,lfr=0,wfr=-1; - - scr=fopen(script_name,"r"); - strcpy(snd_name,script_name); - c=strrchr(snd_name,'.'); - if (c==NULL) strcat(snd_name,SND_NAME); - else strcpy(c,SND_NAME); - if (scr==NULL) - { - printf("Nemohu otev��t script: %s\n",script_name); - exit(1); - } - snf=fopen(snd_name,"r"); - i=fscanf(scr,"%255s",name); - open_files(name); - if (i!=1) - { - printf("Chyba ve script souboru: %s. Prvni musďż˝ bďż˝t jmďż˝no cďż˝lovďż˝ho souboru.\n",scr); - exit(1); - } - while ((i=fgetc(scr))!=EOF && i!='\n'); - for(fr=1;fr3) - { - sscanf(argv[3],"%d",&difftype); - } - Create_table_16(); - if (argc==2) - call_script(argv[1]); - else - { - open_wav(argv[2]); - open_files(argv[1]); - ozvuceni(); - } - close_files(); - } - diff --git a/VIDEO/MGIF.C b/VIDEO/MGIF.C deleted file mode 100644 index 4ffa318..0000000 --- a/VIDEO/MGIF.C +++ /dev/null @@ -1,646 +0,0 @@ -// MOTION GIF - LZW komprimovana animace v rozliseni 320x180 256 barev avsak -// upravena pro prehravani v HICOLOR pro konkretni rezim (32768 barev) - - -// Format - /* - - [ FRAME ] - [CHUNK] !pozor delka je 3 bajtova (tj 16MB) - 0 - PRADNY CHUNK - 1 - LZW FULL SCREEN - 2 - MGIF DELTA - 3 - HICOLOR PALETE - 4 - SOUND TRACK - 5 - TEXT TRACK - 6 - MGIF COPY - 7 - SOUND INIT - - Popis Chunku: - PRAZDNY_CHUNK - muze obsahovat soukrome informace - - LZW_FULL_SCREEN - - ihned za hlavickou nasleduje LZW komprimovany obrazek - v rozliseni 320x180 256 barev - - MGIF_DELTA - - cely blok je LZW komprimovany. Po dekomprimace blok obsahuje - dva druhy informaci. Prvni DWORD je ofset od pocatku dat - ktery ukazuje na zacatek graficke informace. Po tomto - DWORDU jsou ulozeny data o umisteni grafickych bodu v obrazu - Prvni byte znaci, kolik je nutne preskocit slov. (tj *2 byte) - Dalsi byte znaci, kolik je nutne zapsat slov (tj *2 byte) - Po tomto bytu je nutne prenest presne tolik slov z - grafickeho bloku na obrazovku. Dvojice bajtu se opakuji - dokud ani jeden z nich nema nejvyssi 2 bity nastavene. - Pak tento byte znaci ze uz na radce nic vic neni. Dolni cast - byte (tj 6 bitu) pak udava pocet radku, ktere je treba pre- - skocit. (nula=zadny). - - HICOLOR PALETTE - - Prvni byte znamena pocet aktivnich barev. Pak nasleduje - paleta ve formatu xRRRRRGGGGGBBBBB. Rozdil oproti vsem - beznym paletam je v tom ze neni treba v palete udrzovat - barvy, ktere uz na obrazovce jsou, protoze zmena palety - se neprojevi na jiz zobrazenem obrazku. - - SOUND_TRACK - - Kazdy frame obsahuje zvukovou stopu. Je to RAW format. - Pro verzi MGIF97 zde je zvukova informace ulozena ve - zvukove kvalite 16-bit stereo 22000Khz, ovsem komprimovana - na 50% jako MUS. - TEXT_TRACK - - Navic je ve mozne ve frame umistit textovou zpravu (titulek) - Prvni WORD udava dobu zobrazeni (pocet frame). - Pote nasleduje text zakoncen znakem 0; - - MGIF_COPY - Za timto CHUNKEM je ulozen blok dat v nezakomprimovanem - tvaru(tj 57600byte); - - - - */ - -#include -#include -#include -#include -#include -#include -#include "flc.h" -#include "lzw.h" -#include - -#define MGIF "MGIF" -#define MGIF_Y "97" -#define VER 0x100 - -#define MGIF_EMPTY 0 -#define MGIF_LZW 1 -#define MGIF_DELTA 2 -#define MGIF_PAL 3 -#define MGIF_SOUND 4 -#define MGIF_TEXT 5 -#define MGIF_COPY 6 -#define MGIF_SINIT 7 - -#define FRAME_X 320 -#define FRAME_Y 180 -#define FRAME_LEN (FRAME_X*FRAME_Y) -#define DELTA_LEN (3*FRAME_LEN) -#define LZW_LEN (2*FRAME_LEN) - -#define SOUND_SPEED 44100 -#define PRE_SOUND ((256*1024)/2) - -#define ZTRATA lowq -#define BZTRATA colorq -#define MAX_FRAME max_fr -#define MIN_FRAME min_fr - -short mult_table[64]; -short square_table[4096]; - -typedef struct mgif_header - { - char sign[4]; - char year[2]; - char eof; - word ver; - long frames; - word snd_chans; - int snd_freq; - short ampl_table[256]; - short reserved[32]; - }; - -word last_frame[FRAME_Y][FRAME_X]; -char frame_delta[FRAME_LEN]; -char delta_data[DELTA_LEN]; -word color_state[32*32+32*32+32*32]; -char calc_data[FRAME_LEN]; -int delta_data_size; -int frame_delta_size; -int speed=20; - -int last_frame_size; -int total_frames; - -int lowq=0; -int colorq=0; -int max_fr=30000; -int min_fr=0; - -int hranice; -int hdiff=0; - -struct mgif_header gh; - -char lzw_buffer[LZW_LEN]; - -char pal_use[256],color_map[256]; -word hipal[256],max_colors; - - -FILE *mgf; - -long of_pos; -int of_chunks; - -void open_frame() - { - of_chunks=0; - of_pos=ftell(mgf); - fwrite(&of_pos,1,4,mgf); - } - -void close_frame() - { - long fsize,p; - - last_frame_size=fsize=(p=ftell(mgf))-of_pos-4; - fseek(mgf,of_pos,SEEK_SET); - fwrite(&of_chunks,1,1,mgf); - fwrite(&fsize,1,3,mgf); - fseek(mgf,p,SEEK_SET); - total_frames++; - } - - -void write_chunk(char action,long size,void *data) - { - fwrite(&action,1,1,mgf); - fwrite(&size,1,3,mgf); - fwrite(data,1,size,mgf); - of_chunks++; - } - - -void conv_2_hicolor() - { - int i,r,g,b; - for(i=0;i<256;i++) - { - r=(flc_paleta[i][0]>>3); - g=(flc_paleta[i][1]>>3); - b=(flc_paleta[i][2]>>3); - hipal[i]=((r<<10)+(g<<5)+b); - } - } - -char find_color(word c); //najde barvu v palete a vraci byte -#pragma aux find_color parm [eax]=\ - "mov edi,offset hipal"\ - "mov ecx,256"\ - "repne scasw"\ - "mov eax,edi"\ - "sub eax,offset hipal"\ - "shr eax,1"\ - "dec eax"\ - value [al] modify[edi ecx]; - - -void init_palmap() - { - int i; - memset(pal_use,0,sizeof(pal_use)); // nuluj pristupy k barvam - for(i=0;i<256;i++) color_map[i]=find_color(hipal[i]); //redukuj paletu; - max_colors=256; // pocet barev zatim 256; - } - -char test_transp(char c,word w) - { - int r1,g1,b1; - int r2,g2,b2; - int diff; - - r1=flc_paleta[c][0]>>3; - g1=flc_paleta[c][1]>>3; - b1=flc_paleta[c][2]>>3; - w&=0x7fff; - b2=w;g2=b2>>5;r2=g2>>5;b2&=0x1f;g2&=0x1f; - r1-=r2;g1-=g2;b1-=b2; - diff=abs(r1)+abs(g1<<1)+abs(b1); - return diff<=hranice; - } - -void create_delta(char *frame_buffer) - { - char *delta; - char *data; - long colors2; - int x,y; - word *p; - char skip,skc,cpc; - char c1,c2,*a,d; - - delta=delta_data; - data=frame_delta; - a=frame_buffer; - for(y=0;y<180;y++) - { - p=&last_frame[y]; - skip=1; - skc=0; - cpc=0; - for(x=0;x<160;x++) - { - c1=*a++;c2=*a++; - c1=color_map[c1]; - c2=color_map[c2]; - d=test_transp(c1,p[0]) && test_transp(c2,p[1]); - if (d!=skip) - { - if (skip) *delta++=skc;else *delta++=cpc; - skip=!skip;skc=0;cpc=0; - } - if (!skip) - { - *data++=c1; - *data++=c2; - colors2=hipal[c1]+(hipal[c2]<<16); - *(long *)p=colors2; - cpc++; - } - else skc++; - p+=2; - pal_use[c1]=1; - pal_use[c2]=1; - } - if (!skip) *delta++=cpc; - if (skc==160 && *(delta-1)!=0xff && delta!=delta_data) delta[-1]++; //preskoc n radek - else *delta++=0xc0; //oznac konec radky - } - delta_data_size=delta-delta_data; - frame_delta_size=data-frame_delta; - } - - -void reduce_palette() //redukuje paletu na nejmensi nutny pocet barev - { - int i,j; - for(i=0,j=0;i<256;i++) - { - if (pal_use[i]) - { - hipal[j]=hipal[i]; - color_map[i]=j++; - } - } - max_colors=j; - } - -void filter_colors(void *block,int size,void *colormap); //prefiltruje blok dat podle color_map -#pragma aux filter_colors parm [edi][ecx][ebx]=\ - "lp1: mov al,[edi]"\ - " xlatb"\ - " stosb"\ - " loop lp1"\ - modify [eax]; - - -void *join_two_blocks(void *d1,void *d2,int siz1,int siz2,long *celk) - { - long siz; - char *d; - void *x; - - siz=siz1+siz2+4; - d=(char *)getmem(siz); - x=d; - memcpy(d,&siz1,4);d+=4; - memcpy(d,d1,siz1);d+=siz1; - memcpy(d,d2,siz2); - *celk=siz; - return x; - } - -void create_last_frame(void *source,void *target,void *pal,int size); -#pragma aux create_last_frame parm [esi][edi][ebx][ecx]=\ - "lp1: lodsb"\ - " movzx eax,al"\ - " mov eax,[eax*2+ebx]"\ - " stosw"\ - " loop lp1"\ - modify[eax] - - -void create_mgif_pal() - { - write_chunk(MGIF_PAL,max_colors*2,hipal); - } - - -void create_mgif_lzw() - { - int siz; - - conv_2_hicolor(); - init_palmap(); - create_mgif_pal(); - filter_colors(frame_buffer,FRAME_LEN,color_map); - create_last_frame(frame_buffer,last_frame,hipal,FRAME_LEN); - init_lzw_compressor(8); - memset(lzw_buffer,0,sizeof(lzw_buffer)); - siz=lzw_encode(frame_buffer,lzw_buffer,FRAME_LEN); - if (siz>FRAME_LEN) write_chunk(MGIF_COPY,FRAME_LEN,frame_buffer); - else write_chunk(MGIF_LZW,siz,lzw_buffer); - done_lzw_compressor(8); - } - - -void create_color_state() - { - int i; - int r1,g1,b1; - int r2,g2,b2; - int diff; - char *c; - word *w; - - memset(color_state,0,sizeof(color_state)); - c=frame_buffer; - w=last_frame; - for(i=0;i>3; - g1=flc_paleta[*c][1]>>3; - b1=flc_paleta[*c][2]>>3; - b2=*w;g2=b2>>5;r2=g2>>5;b2&=0x1f;g2&=0x1f; - r1-=r2;g1-=g2;b1-=b2; - diff=abs(r1)+abs(g1<<1)+abs(b1); - color_state[diff]++; - c++;w++; - } - } - -void set_max_color_change(int cchange) - { - int i,s; - - s=0;cchange=57600-cchange; - for(i=sizeof(color_state)/sizeof(word)-1;s0;i--) s+=color_state[i]; - if (s>=cchange) i++; - hranice=i+hdiff;if (hranice<0) hranice=0; - } - -int rozptyl(int v1,int v2) - { - int c1,c2,x,s; - x=v1+v2>>1; - c1=(x-v1); - c2=(x-v2); - s=c1*c1+c2*c2; - return s; - } - -void create_low_quality() - { - void *snd;int l; - char *sn,*sr,c1,c2; - int rs,bs,gs; - - l=FRAME_LEN; - sr=frame_buffer; - snd=calc_data; - sn=(char *)snd; - l--; - while (l--) - { - c1=*sr++; - c2=*sr; - rs=rozptyl(flc_paleta[c1][0],flc_paleta[c2][0]); - gs=rozptyl(flc_paleta[c1][1],flc_paleta[c2][1]); - bs=rozptyl(flc_paleta[c1][2],flc_paleta[c2][2]); - if (rs+gs+bsFRAME_LEN) - { - create_mgif_lzw(); - return; - } - if (!frame_delta_size) return; - reduce_palette(); - filter_colors(frame_delta,frame_delta_size,color_map); - d=join_two_blocks(delta_data,frame_delta,delta_data_size,frame_delta_size,&siz); - init_lzw_compressor(8); - memset(lzw_buffer,0,sizeof(lzw_buffer)); - siz=lzw_encode(d,lzw_buffer,siz); - done_lzw_compressor(); - free(d); - if (siz>FRAME_LEN) - { - create_mgif_lzw(); - return; - } - write_chunk(MGIF_DELTA,siz,lzw_buffer); - create_mgif_pal(); - } - -void create_sound_track(int size) - { - void *p; - - p=getmem(size); - memset(p,0,size); - write_chunk(MGIF_SOUND,size,p); - free(p); - } - -void reserve_track() - { - int size; - - size=SOUND_SPEED/speed; - size&=~1; - create_sound_track(size); - } - -void prereserve_tracks() - { - int size; - int celk; - - size=SOUND_SPEED/speed; - size&=~1; - celk=PRE_SOUND; - while (celk-size>0) - { - open_frame(); - create_sound_track(size); - close_frame(); - celk-=size; - } - if (celk) - { - open_frame(); - create_sound_track(celk); - close_frame(); - } - } - -void fill_header(int frames) - { - memset(&gh,0,sizeof(gh)); - strncpy(gh.sign,MGIF,4); - strncpy(gh.year,MGIF_Y,2); - gh.eof=26; - gh.ver=VER; - gh.frames=frames; - } - - - -void show_screen() - { - word *c; - int i,j; - word *w; - - c=last_frame; - w=screen; - for(i=0;i<180;i++) - { - for(j=0;j<320;j++) - { - *w++=*c; - *w++=*c; - c++; - } - w+=640; - } - showview(0,0,640,360); - showview(0,400,200,20); - } - - -void write_frame_size(int i,int col) - { - char s[20]; - curcolor=0;bar(0,400,200,420); - sprintf(s,"%d %d %d",i,col,hranice);position(0,400);outtext(s); - } - -compress_flc(char *name) - { - int x; - - Open_FLC (name); - charcolors[0]=0; - charcolors[1]=0x7fff; - Get_first_frame (); - Decompress_frame (); - curcolor=0;bar(0,0,639,479); - open_frame(); - create_mgif_lzw(); - reserve_track(); - close_frame();write_frame_size(last_frame_size,max_colors); - show_screen(); - for (x=2; x<=h_flc.frames; x++) - { - Get_next_frame (); - Decompress_frame (); - open_frame(); - create_mgif_delta(); - reserve_track(); - close_frame(); - write_frame_size(last_frame_size,max_colors); - if (last_frame_size>MAX_FRAME) hdiff++; - else if (last_frame_size0) hdiff--; - else if (hdiff>0) hdiff--;else if(hdiff<0) hdiff++; - show_screen (); - } - Close_FLC(); - } - -void create_mgf_file(char *name) - { - mgf=fopen(name,"wb+"); - fwrite(&gh,1,sizeof(gh),mgf); - total_frames=0; - prereserve_tracks(); - } - - -void close_mgf_file() - { - fseek(mgf,0,SEEK_SET); - fill_header(total_frames); - fwrite(&gh,1,sizeof(gh),mgf); - fclose(mgf); - } - - -void create_mult_and_square() - { - int i; - - puts("Creating tables..."); - for(i=0;i<64;i++) mult_table[i]=(short)((i-32)*(i-32)); - for(i=0;i<4096;i++) square_table[i]=(short)sqrt(i); - } - -extern int sada7; - - -main(int argc,char *argv[]) - { - puts("\n(C)1997 Komprimator Motion GIF v0.9 by Ondrej Novak"); - if (argc<3) - { - puts("Pouziti:");putchar('\n');; - puts("MGIF source.flc target.mgf [speed] [lowq] [min_fr] [max_fr] [colorq]");putchar('\n'); - puts("speed - Prehravaci rychlost ve snimkach za sekundu (pro 22050kHz)\n" - "lowq - Nejnizsi mozny rozptyl barev sousednich bodu (snizuje kvalitu\n" - " obrazu) (default: 0)\n" - "min_fr - Pozadavek na nejmensi velikost frame. Pod touto hranici v \n" - " nasledujicim frame snizi velikost ztraty (default: 0)\n" - "max_fr - Pozadavek na nejvetsi velikost frame. Pri prekroceni teto \n" - " hranice se zvysi ztrata o jeden bod. (default 30000)\n" - "colorq - Tato hodnota slouzi k predvidani velikosti ztraty. Udava\n" - " kolik bodu z celkoveho poctu zmen ve frame se menit nebude\n" - " Program pak vybere ty nejmensi rozdily a ty do rozdilove \n" - " mapy nezahrne. (default: 0)\n" - "Velikost nejmensiho rozdilu je zobrazen pri komprimaci jako treti cislo\n" - "Nula udava ze se nezapisuji jen ty body, ktere se nemeni.\n\n" - "Pozn: Bezne neni nutne uvadet parametr colorq protoze stupen ztraty se \n" - "voli podle vysledku predchoziho frame. Je dobre ho uvest pri velkych\n" - "vykyvech velikosti frame. Tak zhruba pri ďż˝10KB. Hodnoty parametru se \n" - "voli od 25000-35000, cim vyssi, tim vyssi stupen ztraty"); - exit(0); - } - switch (argc) - { - case 8:sscanf(argv[7],"%d",&colorq); - case 7:sscanf(argv[6],"%d",&max_fr); - case 6:sscanf(argv[5],"%d",&min_fr); - case 5:sscanf(argv[4],"%d",&lowq); - case 4:sscanf(argv[3],"%d",&speed); - } - create_mgf_file(argv[2]); - initmode32(); - curfont=(void *)&sada7; - compress_flc(argv[1]); - closemode(); - puts("Zaviram Motion GIF..."); - close_mgf_file(); - } diff --git a/VIDEO/MGIF98.C b/VIDEO/MGIF98.C deleted file mode 100644 index ee41077..0000000 --- a/VIDEO/MGIF98.C +++ /dev/null @@ -1,376 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - - -#define PIC_XS 320 -#define PIC_YS 184 -#define HICOLOR 32768 -#define PICTURE "TEST1.PCX" -#define PI 3.141592654 -#define C(x) ((x)==0?0.5:1.0) -#define QUALITY 4 - -typedef signed char t_y_buffer[PIC_YS*PIC_XS]; -typedef signed char t_cb_buffer[PIC_YS*PIC_XS/2]; -typedef signed char t_cr_buffer[PIC_YS*PIC_XS/2]; - -typedef signed char T_COLORT[HICOLOR][3]; -typedef short T_COLORIT[64][64][64]; - -t_y_buffer y_buff,y_buff_new; -t_cb_buffer cb_buff,cb_buff_new; -t_cr_buffer cr_buff,cr_buff_new; -T_COLORT colort; -T_COLORIT colorit; - -/*char y_iquant[64]= - { - 16,11,10,16,24,40,51,61, - 12,12,14,19,26,58,60,55, - 14,13,16,24,40,57,69,56, - 14,17,22,29,51,87,80,61, - 18,22,37,56,68,109,103,77, - 24,35,55,64,81,104,113,92, - 49,64,78,87,103,121,120,101, - 72,92,95,98,112,100,103,99 - }; -*/ -signed char y_iquant[64]= - { - 4, 8, 9, 10,15,20,22,30, - 8,8,9,11,16,21,24,30, - 9,9,10,12,20,25,30,36, - 9,10,11,13,25,30,35,38, - 10,12,15,20,25,35,40,45, - 11,14,20,27,41,50,55,60, - 20,30,40,45,50,61,60,50, - 32,48,49,51,50,51,50,49, - }; - - -char test[]= - { - 139,144,149,153,155,155,155,155, - 144,151,153,156,159,156,156,156, - 150,155,160,163,158,156,156,156, - 159,161,162,160,160,159,159,159, - 159,160,161,162,162,155,155,155, - 161,161,161,161,160,157,157,157, - 162,162,161,163,162,157,157,157, - 162,162,161,161,163,158,158,158 - }; - -signed char c_iquant[64]= - { - 2,4,5,5,6,10,11,15, - 4,4,5,5,8,10,12,15, - 4,4,6,6,10,12,15,18, - 4,5,5,6,12,15,17,18, - 5,6,7,10,12,16,20,22, - 6,7,10,13,20,25,26,30, - 10,15,20,22,25,30,30,25, - 16,24,25,26,25,26,25,25, - }; - - - -signed char koef_table[PIC_YS*PIC_XS]; - -short *picture; - -char code_tab[][2]= - { - {0,0},{1,0},{0,1},{0,2},{1,1},{2,0},{3,0},{2,1},{1,2},{0,3},{0,4},{1,3},{2,2}, - {3,1},{4,0},{5,0},{4,1},{3,2},{2,3},{1,4},{0,5},{0,6},{1,5},{2,4},{3,3},{4,2}, - {5,1},{6,0},{7,0},{6,1},{5,2},{4,3},{3,4},{2,5},{1,6},{0,7},{1,7},{2,6},{3,5}, - {4,4},{5,3},{6,2},{7,1},{7,2},{6,3},{5,4},{4,5},{3,6},{2,7},{3,7},{4,6},{5,5}, - {6,4},{7,3},{7,4},{6,5},{5,6},{4,7},{5,7},{6,6},{7,5},{7,6},{6,7},{7,7} - }; - -signed char dct[64][64]; //v poradi [koef;x,y] - koef dle tabulky -signed char ict[64][64]; //v poradi [x,y;koef];koef dle tabulky - -signed short mlt[256][256]; //[i,j]=i*j -signed char mlt2[256][256]; //[i,j]=i*j (s oriznutim) - - -void create_color_table(void) - { - int r,g,b; - int y,cb,cr,i; - - - puts("Creating SECAM CT table"); - for(i=0;i>10; - g=(i>>5) & 0x1f; - b=i & 0x1f; - r<<=3; - g<<=3; - b<<=3; - y=(r*299+g*587+b*114)/1000; - cb=564*(b-y)/1000; - cr=713*(r-y)/1000; - colort[i][0]=y-128; - colort[i][1]=cb; - colort[i][2]=cr; - } - for(y=0;y<64;y++) - for(cb=-32;cb<31;cb++) - for(cr=-32;cr<31;cr++) - { - int y2=y<<2,cr2=cr<<3,cb2=cb<<3; - r=y2+cr2*1402/1000; - g=y2-(cb2*344+cr2*714)/1000; - b=y2+cb2*1772/1000; - r>>=3; - g>>=3; - b>>=3; - if (r>31) r=31; - if (g>31) g=31; - if (b>31) b=31; - if (r<0) r=0; - if (g<0) g=0; - if (b<0) b=0; - i=(r<<10)+(g<<5)+b; - colorit[(y-32)&63][cb&63][cr&63]=i; - } - } - -#define NORMALIZE(i) if (i>127) i=127;else if (i<-128) i=-128;else; - -void rozklad_obrazku(void) - { - int i; - - for(i=0;i>1,k; - k=colort[picture[i+3]][0]-y_buff_new[i]; - NORMALIZE(k); - y_buff[i]=k; - if (i & 1) - { - cb_buff[j]+=colort[picture[i+3]][1]>>2; - cr_buff[j]+=colort[picture[i+3]][2]>>2; - k=cb_buff[j]-cb_buff_new[j];NORMALIZE(k); - cb_buff[j]=k; - k=cr_buff[j]-cr_buff_new[j];NORMALIZE(k); - cr_buff[j]=k; - } - else - { - cb_buff[j]=colort[picture[i+3]][1]>>2; - cr_buff[j]=colort[picture[i+3]][2]>>2; - } - } - } - -void slozeni_obrazku(void) - { - int i,x,y; - int yy,cb,cr,w; - unsigned short *ww; - - i=0; - for(y=0;y<184;y++) - for(x=0;x<320;x++) - { - yy=y_buff_new[i]>>2; - cb=(cb_buff_new[i>>1]>>2); - cr=(cr_buff_new[i>>1]>>2); - w=colorit[yy&63][cb&63][cr&63];w=w+(w<<16); - ww=screen+x*2+y*1280; - ww[0]=w;ww[1]=w; - ww[640]=w;ww[641]=w; - //screen[x+y*640]=colorit[y_buff[i]>>2][16][16]; - i++; - } - showview(0,0,0,0); - } - -void create_dct(void) - { - int j,k,u,v,x,y; - - puts("Creating DCT table:"); - for(k=0;k<64;k++) - for(j=0;j<64;j++) - { - float res; - - u=code_tab[j][0]; - v=code_tab[j][1]; - x=k & 7;y=k>>3; - res=127*cos((2*x+1)*u*PI/16)*cos((2*y+1)*v*PI/16); - dct[j][k]=(signed char)res; - } - - } - -void create_ict(void) - { - int j,k,u,v,x,y; - - - puts("Creating ICT table:"); - for(j=0;j<64;j++) - for(k=0;k<64;k++) - { - float res; - - u=code_tab[j][0]; - v=code_tab[j][1]; - x=k & 7;y=k>>3; - res=127*cos((2*x+1)*u*PI/16)*cos((2*y+1)*v*PI/16); - ict[k][j]=(signed char)res; - } - } - -void create_mult() - { - int i,j,k; - - puts("Creating MULT table:"); - for(i=-128;i<128;i++) - for(j=-128;j<128;j++) - { - mlt[i & 0xff][j & 0xff]=i*j; - k=i*j;NORMALIZE(k); - mlt2[i & 0xff][j & 0xff]=k; - } - } - -#define GET_DCT(i,k,p) (mlt[i][dct[k][p]]) -#define GET_ICT(i,k,p) (mlt[i][ict[k][p]]) - -void dct_buffer(void *buffer,int box_x,int box_y,int linelen,char *quant) - { - int nextline=7*linelen; - int row,col,kn,pp; - char *c,*p; - signed char *ktab; - quant; - - c=buffer; - ktab=koef_table; - - for(row=0;row>=2; - suma*=C(u)*C(v);NORMALIZE(suma); - //suma/=quant[kn]; - *ktab++=(signed char)(suma); - } - c+=8; - } - c+=nextline; - } - } - -void ict_buffer(void *buffer,int box_x,int box_y,int linelen,char *quant) - { - int nextline=7*linelen; - int row,col,kn,pp; - signed char *c,*p; - signed char *ktab; - char kofs[64],ko=0; - quant; - - c=buffer; - ktab=koef_table; - - for(row=0;row>=7; - suma>>=2; - suma+=p[0]; - NORMALIZE(suma); - p[0]=suma;p++; - pp++;if (!(pp & 7)) p+=linelen-8; - } - ktab+=64; - c+=8; - } - c+=nextline; - } - } - - -main() - { - char pcn[100]; - int i; - create_color_table(); - create_dct(); - create_ict(); - create_mult(); - memset(y_buff_new,0,sizeof(y_buff_new)); - memset(cr_buff_new,0,sizeof(cr_buff_new)); - memset(cb_buff_new,0,sizeof(cb_buff_new)); - //dct_buffer(test,1,1,8,y_iquant); - //ict_buffer(y_buff_new,40,23,320,y_iquant); - - initmode32(); - - for(i=0;i<100;i++) - { - sprintf(pcn,"TEST%02d.PCX",i); - open_pcx(pcn,A_15BIT,(void **)&picture); - rozklad_obrazku(); - free(picture); - dct_buffer(y_buff,40,23,320,y_iquant); - ict_buffer(y_buff_new,40,23,320,y_iquant); - dct_buffer(cr_buff,20,23,160,c_iquant); - ict_buffer(cr_buff_new,20,23,160,c_iquant); - dct_buffer(cb_buff,20,23,160,c_iquant); - ict_buffer(cb_buff_new,20,23,160,c_iquant); - - - //memcpy(y_buff_new,y_buff,sizeof(y_buff)); -// memcpy(cr_buff_new,cr_buff,sizeof(cr_buff)); -// memcpy(cb_buff_new,cb_buff,sizeof(cb_buff)); - - slozeni_obrazku(); - } - getchar(); - } diff --git a/VIDEO/MGIFCAT.C b/VIDEO/MGIFCAT.C deleted file mode 100644 index 70ac756..0000000 --- a/VIDEO/MGIFCAT.C +++ /dev/null @@ -1,216 +0,0 @@ -#include -#include -#include -#include -#include -#include - -MGIF_HEADER_T mhead; -char nohead=1; - -char turns[8]="||//--\\\\"; -char turncnt; - -void show_progress() - { - turncnt=(turncnt+1) & 0x7; - cprintf("> %c <\x8\x8\x8\x8\x8",turns[turncnt]); - } - -void *load_frame(FILE *f,long *size,char *chunks) - { - long l; - int siz; - void *c; - - if (!fread(&l,4,1,f)) return NULL; - siz=l>>8; - *chunks=l & 0xff; - *size=siz; - c=malloc(siz); - if (c==NULL) return NULL; - if (!fread(c,siz,1,f)) - { - free(c); - return NULL; - } - return c; - } - -char save_frame(FILE *f,char chunks,void *data,long size) - { - long l; - - l=(size<<8)|chunks; - if (!fwrite(&l,4,1,f)) return 1; - if (!fwrite(data,size,1,f)) return 1; - return 0; - } - -void *trans_frame(void *src,int size,char chunks,int soundtrk,long *outlen) - { - char *s,*t; - long l; - void *tg; - - tg=malloc(size+soundtrk); - t=tg;s=src; - if (tg==NULL) return NULL; - while (chunks--) - { - l=*(long *)s;s+=sizeof(l); - if ((l & 0xff) !=MGIF_SOUND) - { - int size=l>>8; - memcpy(t,&l,sizeof(l)); - t+=4; - memcpy(t,s,size); - t+=size; - s+=size; - } - else - { - long w; - w=(soundtrk<<8)|MGIF_SOUND; - *(long *)t=w;t+=4; - memset(t,0,soundtrk); - s+=l>>8;t+=soundtrk; - } - } - *outlen=t-(char *)tg; - return tg; - } - -void *create_sound(int soundtrk, long *outlen) - { - void *tg; - char *t; - - tg=malloc(soundtrk+4); - t=tg; - if (tg==NULL) return NULL; - *(long *)t=MGIF_SOUND|(soundtrk<<8); - t+=4; - memset(t,0,soundtrk);t+=soundtrk; - *outlen=t-(char *)tg; - return tg; - } - -#define PRE_SOUND ((256*1024)/2) - -int leading_track(FILE *f,int soundtrk) - { - int celk,siz; - void *p;long s; - char res; - int frames=0; - - celk=PRE_SOUND; - while (celk) - { - if (celk>soundtrk) siz=soundtrk;else siz=celk; - p=create_sound(siz,&s); - celk-=siz; - res=save_frame(f,1,p,s);frames++; - free(p); - if (res) return 0; - } - return frames; - } - -char copy_mgif(FILE *tg,FILE *src,int speed) - { - MGIF_HEADER_T sh; - int soundtrk=44100/speed; - void *p;char chunks;long size; - void *q;long qsize; - char skip_lead=0; - - if (!fread(&sh,sizeof(sh),1,src)) return 2; - if (nohead) - { - int res; - mhead=sh,nohead=0; - fwrite(&mhead,sizeof(mhead),1,tg); - res=leading_track(tg,soundtrk); - if (!res) return 1; - mhead.frames=res; - } - while(sh.frames--) - { - p=load_frame(src,&size,&chunks); - if (p==NULL)return 1; - if (chunks!=1 || skip_lead) - { - q=trans_frame(p,size,chunks,soundtrk,&qsize); - if (q==NULL) {free(p);return 1;} - if (save_frame(tg,chunks,q,qsize)) {free(p);free(q);return 1;} - mhead.frames+=1; - free(q); - show_progress(); - skip_lead=1; - } - free(p); - } - return 0; - } - -char add_mgif(FILE *tg,char *filename,int speed) - { - FILE *src; - char res; - - src=fopen(filename,"rb"); - if (src==NULL) return 255; - res=copy_mgif(tg,src,speed); - close(src); - return res; - } - -int main(int argc,char *argv[]) - { - int ac; - int speed; - FILE *f; - - if (argc<4) - { - puts("Malo parametru. Pouziti:\n" - "\n" - "MGIFCAT [zdroj2.mgf [zdroj3.mgf [...]]]\n" - "\n" - "Rychlost je ve frames za sekundu\n" - "POZOR! Cilovy soubor bude prepsan! Neprenasi zvukove stopy!"); - return 1; - } - ac=3; - if (sscanf(argv[1],"%d",&speed)!=1) - { - printf("Neplatna rychlost: %s\n",argv[1]); - return 1; - } - f=fopen(argv[2],"wb"); - if (f==NULL) - { - printf("Nemohu otevrit vystupni soubor: %s\n",argv[2]); - return 1; - } - nohead=1; - while (ac -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "lzw.h" -#include "mgifeobj.h" -#include "mgifedit.h" -#include "mgifeact.h" -#include "mgifebld.h" - - -#define PRJ ".PRJ" - -FRAME_DEFS_T *mgf_frames=NULL; -MGIF_HEADER_T mgf_header; -char *mgif_filename; - -word preview_frame[320*180+3]; -word check1; -word work_frame[320*180]; -word check2; -word frame_shift; - -TRACK_INFO_T *smp_prg=NULL; -int samples_total=0; -int last_unchanged_frame=0; - - -long total_frames=0; - -void set_mgif(char *filename) - { - mgif_filename=NewArr(char,strlen(filename)+1); - strcpy(mgif_filename,filename); - } - -#define error_exit(f,n) {fclose(f);return (n);} - -int examine_mgif_file(char (*progress)(int perc)) - { - FILE *f; - MGIF_HEADER_T head; - int r; - int frame_size=0; - char chunks; - int chunk_size=0; - char chunk_type; - int frame,chunk; - int track_size=-1; - FRAME_DEFS_T *fd; - FRAME_DEFS_T *fg; - char fgp=0; - - frame_shift=0; - f=fopen(mgif_filename,"rb"); - if (f==NULL) return EX_NOT_FOUND; - r=fread(&head,1,sizeof(head),f); - if (r!=sizeof(head)) error_exit(f,EX_READ_ERROR); - memcpy(&mgf_header,&head,sizeof(head)); - total_frames=head.frames; - mgf_frames=NewArr(FRAME_DEFS_T,total_frames); - memset(mgf_frames,0,sizeof(FRAME_DEFS_T)*total_frames); - fg=fd=mgf_frames; - for(frame=0;frameframe_start=ftell(f); - if (fread(&chunks,1,1,f)!=1) error_exit(f,EX_READ_ERROR); - if (fread(&frame_size,1,3,f)!=3) error_exit(f,EX_READ_ERROR); - for(chunk=0;chunkdisplay_start=ftell(f); - fg->displ_type=chunk_type; - fg->display_size=chunk_size; - fgp=1; - break; - case MGIF_SOUND:fd->sound_start=ftell(f); - track_size=chunk_size; - sound=1; - fd->track_size=track_size; - break; - case MGIF_PAL: fg->pal_start=ftell(f); - break; - - } - fseek(f,chunk_size,SEEK_CUR); - } - - fd->changed=1;fd->vol_save=0; - if (!sound) error_exit(f,EX_NO_SOUND); - if (progress(frame*100/total_frames)) break; - } - fclose(f); - return EX_NO_ERROR; - } - -int add_sample(char *sample) - { - char *d; - - d=NewArr(char,strlen(sample)+1); - strcpy(d,sample); - samples_total++; - smp_prg=grealloc(smp_prg,samples_total*sizeof(TRACK_INFO_T)); - smp_prg[samples_total-1].sample_name=d; - smp_prg[samples_total-1].loop_start=-1; - smp_prg[samples_total-1].loop_end=-1; - smp_prg[samples_total-1].user_name=NULL; - smp_prg[samples_total-1].levy=NULL; - smp_prg[samples_total-1].pravy=NULL; - smp_prg[samples_total-1].starts=NULL; - smp_prg[samples_total-1].starts_count=0; - return samples_total-1; - } - -void remove_sample(int id) - { - TRACK_DATA_T *p,*q; - if (id>=samples_total) return; - p=smp_prg[id].levy; - while(p!=NULL) - { - q=p->next;free(p);p=q; - } - p=smp_prg[id].pravy; - while(p!=NULL) - { - q=p->next;free(p);p=q; - } - free(smp_prg[id].starts); - free(smp_prg[id].sample_name); - free(smp_prg[id].user_name); - samples_total--; - if (id!=samples_total)memcpy(smp_prg+id,smp_prg+id+1,(samples_total-id)*sizeof(TRACK_INFO_T)); - smp_prg=grealloc(smp_prg,samples_total*sizeof(TRACK_INFO_T)); - } - -void build_sample_list(void *list) - { - TSTR_LIST ls; - int id; - - memcpy(&ls,list,sizeof(void **)); - if (ls!=NULL) release_list(ls); - ls=create_list(samples_total+1); - for(id=0;id"); - memcpy(list,&ls,sizeof(void **)); - } - - -char get_vpoint(TRACK_DATA_T *track,int frame,TRACK_DATA_T *vp) - { - int fr; - TRACK_DATA_T *p,*q; - if (track==NULL) - { - vp->vpoint1=0; - vp->vpoint2=0; - vp->time=total_frames-frame; - vp->next=NULL; - return 1; - } - fr=0; - q=p=track; - while (p!=NULL && p->time+fr<=frame) - { - fr+=p->time; - q=p; - p=p->next; - } - if (p!=NULL) - if (fr==frame) - { - memcpy(vp,p,sizeof(*vp)); - return 0; - } - else - { - int dif; - int half; - - fr=frame-fr; - half=p->time/2; - dif=(p->vpoint2-p->vpoint1); - vp->vpoint1=p->vpoint1+(dif*fr+half)/p->time; - vp->vpoint2=p->vpoint2; - vp->time=p->time-fr; - vp->next=p->next; - } - else - { - vp->vpoint1=vp->vpoint2=q->vpoint2; - vp->time=total_frames-frame; - vp->next=NULL; - } - return 1; - } - -void add_vpoint(TRACK_DATA_T **track,int frame) - { - TRACK_DATA_T *p,*z; - int fr,alltime; - - p=*track; - if (p==NULL) - { - z=New(TRACK_DATA_T); - get_vpoint(p,0,z); - *track=z; - z->next=NULL; - add_vpoint(track,frame); - return; - } - fr=0; - while (p!=NULL && fr+p->time<=frame) - { - fr+=p->time; - p=p->next; - } - if (p==NULL) crash("Frame out of range!"); - if (fr==frame) return; - alltime=p->time; - p->time=frame-fr; - z=New(TRACK_DATA_T); - z->vpoint1=p->vpoint1+((p->vpoint2-p->vpoint1)*p->time+alltime/2)/alltime; - z->vpoint2=p->vpoint2; - z->changed=1;p->changed=1; - p->vpoint2=z->vpoint1; - z->next=p->next; - p->next=z; - z->time=alltime-p->time; - } - -void change_vpoint_spacing(TRACK_DATA_T *track,int frame,int value) - { - TRACK_DATA_T *p,*q; - int fr; - - p=track; - if (track==NULL) return; - while (p->next!=NULL) p=p->next; - if (p->time<=value) value=p->time-1; - if (!value) return; - q=track;fr=0; - while (q!=NULL && q->time+fr<=frame) - { - fr+=q->time; - q=q->next; - } - if (q==NULL) return; - if (fr+q->time+value<=frame) return; - if (q->time+value<1) return; - if (frtime+=value; - p->time-=value; - } - -void set_vpoint(TRACK_DATA_T **track,int frame,int vp1,int vp2) - { - int fr=0; - TRACK_DATA_T *p,*q; - - add_vpoint(track,frame); - p=*track;q=NULL; - while (p!=NULL && fr!=frame) - { - fr+=p->time; - q=p; - p=p->next; - } - p->changed=1; - p->vpoint1=vp2; - if (q!=NULL) - { - q->vpoint2=vp1; - q->changed=1; - } - } - -void add_restart(TRACK_INFO_T *ti,int frame) - { - int *p=ti->starts; - int sc=ti->starts_count; - int i; - - for(i=0;iframe) break; - p=grealloc(p,sizeof(int)*(sc+1)); - p[sc]=frame; - for(i=sc-1;i>=0;i--) - { - if (p[i]>p[i+1]) - { - p[i]^=p[i+1]; - p[i+1]^=p[i]; - p[i]^=p[i+1]; - } - } - ti->starts=p; - ti->starts_count++; - } - -void delete_restart(TRACK_INFO_T *ti,int frame) - { - int i; - int *p=ti->starts; - int sc=ti->starts_count; - - for(i=0;iframe) return;else if (p[i]==frame) break; - if (i==sc) return; - memcpy(p+i,p+i+1,sizeof(int)*(sc-i-1)); - p=grealloc(p,sizeof(int)*(sc-1)); - ti->starts=p; - ti->starts_count--; - } - -void delete_vpoint(TRACK_DATA_T **track,int frame) - { - int fr; - TRACK_DATA_T *p,*q; - - fr=0; - p=*track; - if (p==NULL) return; - q=NULL; - while (p!=NULL && fr!=frame) - { - fr+=p->time; - q=p;p=p->next; - } - if (p==NULL) return; - if (q==NULL) - { - if (p->next!=NULL) - { - *track=p->next; - p->next->vpoint1=p->vpoint1; - p->next->time+=p->time; - } - else - { - *track=NULL; - } - free(p); - } - else - { - q->next=p->next; - q->vpoint2=p->vpoint2; - q->time+=p->time; - free(p); - } - return; - } - - -char join_two_frames(void *source,void *target); -#pragma aux join_two_frames parm[esi][edi]=\ - "mov ecx,57600"\ - "xor bl,bl"\ -"lp1: lodsw"\ -" test [edi],0x8000"\ -" jz sk1"\ -" mov [edi],ax"\ -" or bl,ah"\ -"sk1: add edi,2"\ -" dec ecx"\ -" jnz lp1"\ -modify[ecx eax] value[bl]; - -void build_frame(int frame_num,int *exit) - { - void *data_buff; - void *delta_buff; - void *p; - word palette[256]; - FILE *f; - FRAME_DEFS_T *fd=mgf_frames+frame_num; - char full=0; - int counter=0; - static last_frame=-1; - char fast,flash; - static zavora=0; - - if (last_frame==frame_num) - { - *exit=0; - return; - } - if (frame_num>=total_frames) crash("frame_num>=total_frames"); - if (frame_num-last_frame!=1) - { - memset(preview_frame,0x80,sizeof(preview_frame)); - memset(work_frame,0x80,sizeof(work_frame)); - p=work_frame;fast=0; - } - else - { - p=preview_frame+3; - last_frame=frame_num; - fast=1; - } - preview_frame[0]=320; - preview_frame[1]=180; - preview_frame[2]=15; - while (zavora==1) task_sleep(NULL); - zavora=1; - f=fopen(mgif_filename,"rb"); - data_buff=getmem(100000); - delta_buff=getmem(100000); - init_lzw_compressor(8); - do - { - reinit_lzw(); - if (fd->pal_start) - { - fseek(f,fd->pal_start,SEEK_SET); - fread(palette,1,sizeof(palette),f); - } - if (fd->display_start) - { - fseek(f,fd->display_start,SEEK_SET); - fread(data_buff,1,fd->display_size,f); - switch (fd->displ_type) - { - case MGIF_LZW:lzw_decode(data_buff,delta_buff); - show_full_lfb12e(delta_buff,p,palette); - break; - case MGIF_DELTA:lzw_decode(data_buff,delta_buff); - show_delta_lfb12e(delta_buff,p,palette); - break; - case MGIF_COPY:show_full_lfb12e(data_buff,p,palette); - break; - } - if (!fast) full=!(join_two_frames(work_frame,preview_frame+3) & 0x80); - if (!((counter++) & 0xf) || full) - { - c_set_value(win_preview,10,0); - c_set_value(win_preview,10,(int)&preview_frame); - c_set_value(win_preview,5,(full||fast)?LABELCOLOR:(flash?0x7c00:0x3e0)); - flash=!flash; - if (waktual->id!=win_preview)redraw_desktop(); - } - if (!fast) task_sleep(NULL); - if (task_info[curtask]) break; - } - fd--; - } - while (fd>=mgf_frames && !full && !fast); - done_lzw_compressor(); - free(data_buff); - free(delta_buff); - fclose(f); - if (full) last_frame=frame_num; - zavora=0; - *exit=0; - } - -extern char backsndbuff[BACK_BUFF_SIZE]; -extern volatile long backsnd; -extern volatile long backstep; -extern volatile int backfine; -extern long vals_save; - -static stop_preview_flag=0; -static void *bufpos; - - -void preview_block(int start_frame,int x, int y) - { - word *scr; - void *data_buff; - char *dt; - void *delta_buff; - word *palette; - FILE *f; - FRAME_DEFS_T *fd=mgf_frames+start_frame; - int i; - char chunks; - int fsize,shift; - char chunk_type; - int chunk_size; - - schovej_mysku(); - zobraz_mysku(); - stop_preview_flag=0; - if (banking)scr=screen+640*y+x;else scr=(word *)lbuffer+640*y+x; - memset(backsndbuff,0,sizeof(backsndbuff)); - i=total_frames-start_frame; - bufpos=NULL; - if (!i) return; - start_mixing(); - f=fopen(mgif_filename,"rb"); - data_buff=getmem(100000); - delta_buff=getmem(100000); - shift=frame_shift; - fseek(f,fd->frame_start,SEEK_SET); - init_lzw_compressor(8); - backsnd=0;backstep=0x10000;vals_save=fd->vol_save; - do - { - char *gr,*s;char grtype; - long ssize; - fread(&fsize,1,4,f);chunks=fsize & 0xff;fsize>>=8; - fread(data_buff,1,fsize,f); - dt=data_buff; - grtype=0xff; - while (chunks--) - { - chunk_size=*(int *)dt;dt+=4; - chunk_type=chunk_size&0xff;chunk_size>>=8; - switch(chunk_type) - { - case MGIF_PAL:palette=(word *)dt;break; - case MGIF_LZW: - case MGIF_DELTA:reinit_lzw();lzw_decode(dt,delta_buff);grtype=chunk_type;break; - case MGIF_COPY:gr=dt;grtype=chunk_type;break; - case MGIF_SOUND:s=dt;ssize=chunk_size;break; - } - dt+=chunk_size; - } - do_events(); - while (test_next_frame(bufpos,ssize)) do_events(); - bufpos=sound_decompress(s,bufpos,ssize,&mgf_header.ampl_table); - if (!shift) - { - switch(grtype) - { - case MGIF_LZW: show_full_interl_lfb130(delta_buff,scr,palette);break; - case MGIF_DELTA:show_delta_interl_lfb130(delta_buff,scr,palette);break; - case MGIF_COPY:show_full_interl_lfb130(gr,scr,palette);break; - } - if (banking) showview(x,y,320,180); - } - else shift--; - fd++; - } - while (--i && !stop_preview_flag && !exit_wait); - done_lzw_compressor(); - free(data_buff); - free(delta_buff); - fclose(f); - stop_mixing(); - exit_wait=0; - } - -void stop_preview() - { - stop_preview_flag=1; - } - - -void save_track(FILE *f,TRACK_DATA_T *t,char *id) - { - fprintf(f,"%s ",id); - while (t!=NULL) - { - fprintf(f,"%d %d %d ",t->vpoint1,t->vpoint2,t->time); - t=t->next; - } - fprintf(f,"\n"); - } - -void save_starts(FILE *f,int *p,int pocet) - { - int i; - - fprintf(f,"%s %d ","START",pocet); - for(i=0;isample_name,ti->user_name==NULL?"":ti->user_name, - ti->loop_start,ti->loop_end,ti->starts_count); - save_track(f,smp_prg[i].levy,"LEFT"); - save_track(f,smp_prg[i].pravy,"RIGHT"); - save_starts(f,smp_prg[i].starts,smp_prg[i].starts_count); - if (smp_prg[i].muted) fputs("MUTED\n",f); - } - fclose(f); - } - -void *get_project_name(char *name) - { - char *c,*d; - - c=NewArr(char,strlen(name)+7); - strcpy(c,name); - d=strrchr(c,'\\');if (d==NULL) d=c; - d=strchr(d,'.');if (d!=NULL) *d=0; - strcat(c,PRJ); - return c; - } - -static void skip_space(FILE *f) - { - int c; - while ((c=getc(f))==32); - ungetc(c,f); - } - -static void skip_nline(FILE *f) - { - int c; - while ((c=getc(f))!='\n' && c!=EOF); - } - -static void *load_track(FILE *f) - { - TRACK_DATA_T *p,*st; - int vp1,vp2,tim,i; - - st=NULL; - i=fscanf(f,"%d %d %d",&vp1,&vp2,&tim); - while (i==3) - { - if (st==NULL) p=st=New(TRACK_DATA_T); - else p=(p->next=New(TRACK_DATA_T)); - p->next=NULL; - p->vpoint1=vp1; - p->vpoint2=vp2; - p->time=tim; - p->changed=0; - i=fscanf(f,"%d %d %d",&vp1,&vp2,&tim); - } - return st; - } - -static void load_starts(FILE *f,int **pole,int *pocet) - { - int i; - fscanf(f,"%d",pocet); - *pole=NewArr(int,*pocet); - for(i=0;i<*pocet;i++) fscanf(f,"%d",*pole+i); - } - - -int load_project(char *prj_name) - { - FILE *f; - int p,i,j; - TRACK_INFO_T *ti; - - f=fopen(prj_name,"r"); - if (f==NULL) return 0; - fscanf(f,"%d %d",&p,&lifikace);skip_nline(f); - smp_prg=NewArr(TRACK_INFO_T,p); - for(i=0;ilevy=NULL;ti->pravy=NULL;ti->starts=NULL; - do - { - skip_space(f); - j=getc(f);ungetc(j,f); - if (j=='#') break; - if (j=='\n') - { - skip_nline(f); - continue; - } - if (j==EOF) break; - fscanf(f,"%s",s);skip_space(f); - if (!strcmp(s,"TRACK")) - { - char s[256]; - ti->muted=0; - fscanf(f,"%[^]",s); - ti->sample_name=NewArr(char,strlen(s)+1);strcpy(ti->sample_name,s); - getc(f);s[0]=0; - fscanf(f,"%[^]",s); - if (s[0]) - { - ti->user_name=NewArr(char,strlen(s)+1);strcpy(ti->user_name,s); - } - else - ti->user_name=NULL; - getc(f); - fscanf(f,"%d %d %d",&ti->loop_start,&ti->loop_end,&ti->starts_count); - } - else if (!strcmp(s,"LEFT")) ti->levy=load_track(f); - else if (!strcmp(s,"RIGHT")) ti->pravy=load_track(f); - else if (!strcmp(s,"START")) load_starts(f,&ti->starts,&ti->starts_count); - else if (!strcmp(s,"MUTED")) ti->muted=1; - else {fclose(f);return -1;} - if (feof(f)) - { - fclose(f);return -2; - } - skip_nline(f); - } - while (1); - } - samples_total=p; - return 0; - } - -void set_changed_full_track(TRACK_INFO_T *tr) - { - set_changed_range(last_unchanged_frame,total_frames-1); - set_changed_track(tr->levy); - set_changed_track(tr->pravy); - last_unchanged_frame=total_frames; - } - -static void do_vol_table_track(TRACK_DATA_T *tr,int indx,char action) - { - int i; - int fr; - int p; - TRACK_DATA_T v; - FRAME_DEFS_T *d; - - for(i=0,fr=0,d=mgf_frames;ichanged|=(d->last_vol[indx]!=p); - d->last_vol[indx]=p; - if (v.time==1) - { - fr+=tr->time; - tr=tr->next; - } - } - } - -void read_vol_table(TRACK_INFO_T *tr) - { - do_vol_table_track(tr->levy,0,0); - do_vol_table_track(tr->pravy,1,0); - } - -void compare_vol_table(TRACK_INFO_T *tr) - { - do_vol_table_track(tr->levy,0,1); - do_vol_table_track(tr->pravy,1,1); - } - -void set_vol_table_nul(void) - { - int i; - FRAME_DEFS_T *d; - - for(i=0,d=mgf_frames;ilast_vol[0]=0; - d->last_vol[1]=0; - } - } - -static long get_track_size(TRACK_INFO_T *tr) - { - long size1=0,size2=0; - TRACK_DATA_T *l,*r; - - l=tr->levy; - r=tr->pravy; - while (l!=NULL) size1+=l->time,l=l->next; - while (r!=NULL) size2+=r->time,r=r->next; - if (size2>size1) return size2;else return size1; - } - -static void track_dopln_na_konci(TRACK_INFO_T *tr) - { - long size1=0,size2=0; - TRACK_DATA_T *l,*r; - - l=tr->levy; - r=tr->pravy; - while (l->next!=NULL) size1+=l->time,l=l->next; - while (r->next!=NULL) size2+=r->time,r=r->next; - l->time=total_frames-size1; - r->time=total_frames-size2; - } - -void warn_size_mistmach(void) - { - int size=total_frames; - int sizeh=size; - int i; - - for(i=0;isizeh) sizeh=s; - } - if (sizetotal_frames) - { - msg_box(PRG_HEADER,'\x1',"MGIFEDIT zjistil,ďż˝e film je krat��, neďż˝ stopy " - "uloďż˝enďż˝ v souboru PRJ. Ke sprďż˝vnďż˝mu umďż˝stďż˝nďż˝ pouďż˝ij funkci GDelete","Ok",NULL); - } - } - - -int get_inserted_frames(int frame) - { - int s; - - frame+=1; - s=1; - while (framesizeh) sizeh=s; - } - return sizeh-total_frames; - } - -void insert_global(int frame,int count) - { - int i; - for(i=0;i0) - { - delete_vpoint(&smp_prg[i].levy,frame+j); - delete_vpoint(&smp_prg[i].pravy,frame+j); - } - change_vpoint_spacing(smp_prg[i].levy,frame,-count); - change_vpoint_spacing(smp_prg[i].pravy,frame,-count); - track_dopln_na_konci(smp_prg+i); - set_vpoint(&smp_prg[i].levy,frame,vl.vpoint1,vl.vpoint1); - set_vpoint(&smp_prg[i].pravy,frame,vp.vpoint1,vp.vpoint1); - } - } diff --git a/VIDEO/MGIFEACT.H b/VIDEO/MGIFEACT.H deleted file mode 100644 index 05bd62e..0000000 --- a/VIDEO/MGIFEACT.H +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef _MGIFEACT_H -#include - -#define _MGIFEACT_H - -#define EX_NO_ERROR 0 -#define EX_NOT_FOUND -1 -#define EX_NO_SOUND -2 -#define EX_READ_ERROR -3 -#define EX_SOUND_ERROR -4 - -typedef struct frame_defs - { - long frame_start; - long display_start; - long pal_start; - long sound_start; - word displ_type; - long display_size; - long track_size; - char changed; - char last_vol[2]; - long vol_save; - }FRAME_DEFS_T; - -extern FRAME_DEFS_T *mgf_frames; -extern MGIF_HEADER_T mgf_header; -extern char *mgif_filename; -extern long total_frames; -extern int samples_total; -extern word frame_shift; - -int examine_mgif_file(char (*progress)(int perc)); -void set_mgif(char *filename); - -typedef struct track_data_t - { - char vpoint1; - char vpoint2; - char changed; - int time; //0 odpovida restartu. Pak vpointy neplati - struct track_data_t *next; - }TRACK_DATA_T; - -typedef struct track_info_t - { - char *sample_name; - char *user_name; - int loop_start; - int loop_end; - TRACK_DATA_T *levy,*pravy; - int *starts; - int starts_count; - char muted; - }TRACK_INFO_T; - -extern TRACK_INFO_T *smp_prg; - -int add_sample(char *sample_name); -void remove_sample(int id); -void build_sample_list(void *list); -char get_vpoint(TRACK_DATA_T *track,int frame,TRACK_DATA_T *vp); //neexistuje-li spocita se (return 1) -void set_vpoint(TRACK_DATA_T **track,int frame,int vp1,int vp2); //pokud neexistuje tak se vytvori -void add_vpoint(TRACK_DATA_T **track,int frame); -void add_restart(TRACK_INFO_T *ti,int frame); -void delete_restart(TRACK_INFO_T *ti,int frame); -void delete_vpoint(TRACK_DATA_T **track,int frame); -void change_vpoint_spacing(TRACK_DATA_T *track,int frame,int value); - -void lzw_decode(void *source,char *target); -void init_lzw_compressor(int dic_size); -void reinit_lzw(); -void done_lzw_compressor(); - -void preview_block(int start_frame,int x, int y); -void stop_preview(); -void build_frame(int frame_num,int *exit);//TASK! -#pragma aux build_frame parm[] - -void save_project(char *project_name); -int load_project(char *prj_name); -void *get_project_name(char *name); - -void read_vol_table(TRACK_INFO_T *tr); -void compare_vol_table(TRACK_INFO_T *tr); -void set_vol_table_nul(void); - -void set_changed_full_track(TRACK_INFO_T *tr); -void warn_size_mistmach(void); - -int get_inserted_frames(int frame); //tracuje film a odhaduje kolik framu bylo pridano -int get_deleted_frames(void); -void insert_global(int frame,int count); //prida count framu od framu frame. -void delete_global(int frame,int count); //prida count framu od framu frame. - - - -#endif diff --git a/VIDEO/MGIFEBLD.C b/VIDEO/MGIFEBLD.C deleted file mode 100644 index ddfafba..0000000 --- a/VIDEO/MGIFEBLD.C +++ /dev/null @@ -1,426 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "lzw.h" -#include "mgifeobj.h" -#include "mgifedit.h" -#include "mgifeact.h" -#include "mgifebld.h" -#include -#include - - -static short **frame_table; -static char work_buff[100000]; -static int last1=0; -static int last2=0; -static int last_time=0; - -int frames_build=0; -int amplifikace=0; - -typedef struct tsample - { - FILE *fs; - int start_data; - int length; - int pos; - long loop_start; - long loop_end; - char running; - char bit16; - char stereo; - }TSAMPLE; - -static TSAMPLE sample; - -static void Create_table_16(short *ampl_table,int difftype) - { - int a,c,d,e; - float b; - - d=-1;e=0; - for(a=0;a<128;a++) - { - b=(a/128.0); - switch (difftype) - { - case 1:b=(b*32768.0);break; - case 2:b=(b*b*32768.0);break; - case 3:b=(b*b*b*32768.0);break; - case 4:b=(b*b*b*b*32768.0);break; - case 5:b=(b*b*b*b*b*32768.0);break; - } - c=(int)b; - if (c==d) e++; - d=c;c+=e; - ampl_table[128+a]=c; - ampl_table[128-a]=-c; - } - } - -static int find_index(short *ampl_table,int value) - { - int i; - - if (value==0) return 128; - if (value>0) - { - for(i=128;i<256;i++) - if (ampl_table[i]>value) return i-1; - return 255; - } - else - { - for(i=128;i>=0;i--) - if (ampl_table[i]32768 || l1<-32768) crash("Building error (owerflow)"); - work_buff[i]=indx; - } - else - { - val=source[i]; - indx=find_index(ampl_table,val-l2); - l2+=ampl_table[indx]; - if (l2>32768 || l2<-32768) crash("Building error (owerflow)"); - work_buff[i]=indx; - } - } - last1=l1;last2=l2; - } - -static char save_buffer(FILE *f,int seekp,short *buffer,int size) - { - compress_buffer_stereo(mgf_header.ampl_table,buffer,size); - fseek(f,seekp,SEEK_SET); - return fwrite(work_buff,1,size,f)!=size; - } - -static char save_all() - { - int i,c=0; - FRAME_DEFS_T *fd; - FILE *f; - - f=fopen(mgif_filename,"rb+"); - if (f==NULL) return 1; - fwrite(&mgf_header,1,sizeof(mgf_header),f); - for(i=0,fd=mgf_frames;ivol_save & 0xffff); - last2=(short)(fd->vol_save>>16); - if (save_buffer(f,fd->sound_start,frame_table[i],fd->track_size)) - { - fclose(f); - return 1; - } - c_set_value(0,10,(c++)*100/frames_build); - do_events();if (exit_wait) break; - fd->changed=0; - free(frame_table[i]);frame_table[i]=NULL; - if (ibps/head->freq)/head->chans)==2; - sample.stereo=(head->chans==2); - sample.pos=0; - if (loop_start==-1) loop_start=loop_end=sample.length; - sample.loop_start=loop_start; - sample.loop_end=loop_end; - free(head); - return 0; - } - free(head); - } - fclose(f); - return 1; - } - - -static void skip_frame(int frm_len) //v puvodni velikosti (16-bit stereo) - { - if (!sample.bit16) frm_len/=2; - if (!sample.stereo) frm_len/=2; - sample.pos+=frm_len; - if (sample.loop_start=sample.loop_end) sample.pos-=sample.loop_end-sample.loop_start; - if (sample.pos>=sample.length) sample.running=0; - } - - -static char build_sound(int frm_len,short *buffer,word vol1,word vol2) - { - short val1,val2; - int rozsah,pos; - char vol1l,vol2l,vol1r,vol2r; - int ipos=ftell(sample.fs)-sample.start_data; - - vol1l=vol1 & 0xff;vol2l=vol2 & 0xff; - vol1r=vol1>>8;vol2r=vol2>>8; - rozsah=frm_len/4; - pos=0; - fseek(sample.fs,sample.pos+sample.start_data,SEEK_SET); - while (frm_len>0) - { - short i,*j=&val1; - - if (ipos>sample.pos) fseek(sample.fs,sample.pos+sample.start_data,SEEK_SET); - ipos=sample.pos; - for(i=0;i<2;i++) - { - if (sample.bit16) fread(j,1,2,sample.fs); - else - { - fread(j,1,1,sample.fs);*j<<=8; - *j^=0x8000; - } - if (!sample.stereo) - { - val2=val1;break; - } - else - j=&val2; - } - if (ferror(sample.fs)) return 1; - val1=val1*(vol1l+(vol2l-vol1l)*pos/rozsah)/256; - val1>>=amplifikace; - val2=val2*(vol1r+(vol2r-vol1r)*pos/rozsah)/256; - val2>>=amplifikace; - skip_frame(4); - if (*buffer+val1>32767) *buffer++=32767; - else if (*buffer+val1<-32768) *buffer++=-32768; - else *buffer+++=val1; - if (*buffer+val2>32767) *buffer++=32767; - else if (*buffer+val2<-32768) *buffer++=-32768; - else *buffer+++=val2; - pos++; - frm_len-=4; - if (!sample.running) break; - } - return 0; - } - - -static char build_frame_sound(int frame,int sample) - { - TRACK_DATA_T z1l,z1r,z2l,z2r; - - if (frame_table[frame]==NULL) - { - skip_frame(mgf_frames[frame].track_size*2); - } - else - { - get_vpoint(smp_prg[sample].levy,frame,&z1l); - get_vpoint(smp_prg[sample].pravy,frame,&z1r); - get_vpoint(smp_prg[sample].levy,frame+1,&z2l); - get_vpoint(smp_prg[sample].pravy,frame+1,&z2r); - if (z1l.vpoint1 || z2l.vpoint1 || z1r.vpoint1 || z2r.vpoint1) - return build_sound(mgf_frames[frame].track_size*2, - frame_table[frame], - (z1r.vpoint1<<8)+z1l.vpoint1, - (z2r.vpoint1<<8)+z2l.vpoint1); - else - skip_frame(mgf_frames[frame].track_size*2); - } - return 0; - } - -char build_one_sample(int smp) - { - int d=0; - int i; - int p,c,*pl; - - if (smp_prg[smp].muted) return 0; - if (register_sample(smp_prg[smp].sample_name, - smp_prg[smp].loop_start, - smp_prg[smp].loop_end)) return 1; - pl=smp_prg[smp].starts; - c=smp_prg[smp].starts_count; - for(i=0;ii) break; - - if (sample.running) - { - build_frame_sound(i,smp); - do_events(); - } - } - fclose(sample.fs); - return 0; - } - - -static void destroy_all() - { - int i; - - for(i=0;i=total_frames) fr2=total_frames-1; - for(;fr1<=fr2;fr1++) mgf_frames[fr1].changed=1; - } - -void set_changed_track(TRACK_DATA_T *ti) - { - int fr=0; - while (ti!=NULL) - { - if (ti->changed) set_changed_range(fr,fr+ti->time); - fr+=ti->time; - ti->changed=0; - ti=ti->next; - } - } - -int get_building_time() - { - return last_time; - } diff --git a/VIDEO/MGIFEBLD.H b/VIDEO/MGIFEBLD.H deleted file mode 100644 index 892e382..0000000 --- a/VIDEO/MGIFEBLD.H +++ /dev/null @@ -1,9 +0,0 @@ -extern int amplifikace; -extern int frames_build; - -char build_solo(int smp); -char build_all_samples(); -void set_changed_range(int fr1,int fr2); -void set_changed_track(TRACK_DATA_T *ti); -int get_building_time(); - diff --git a/VIDEO/MGIFEDIT.C b/VIDEO/MGIFEDIT.C deleted file mode 100644 index 9314a74..0000000 --- a/VIDEO/MGIFEDIT.C +++ /dev/null @@ -1,905 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "lzw.h" -#include "mgifeobj.h" -#include "mgifeact.h" -#include "mgifedit.h" -#include "mgifebld.h" -#include -#include -#include -#include -#include - -void *vga_font=&boldcz; -void *icones=&ikones; -void *ms_cur=&sipka; -word icone_color[7]={0x2108,0x7fff,0x000f,0x4210,0x6f7b}; -int win_preview; -int win_program=-1; -int cur_track=-1; -int win_control; -TSTR_LIST smp_list; -char last_path[256]=""; -char *prj_name; - -static void grinit(void) - { - initmode32(); - register_ms_cursor(ms_cur); - init_mysky(); -// hranice_mysky(0,0,639,479); - update_mysky(); - schovej_mysku(); - bar(0,0,639,479); - showview(0,0,0,0); - } - - -void init_sound() - { - int a,b,c,d; - if (sound_detect(&a,&b,&c,&d)) - { - puts("No sound device found"); - a=DEV_NOSOUND; - } - set_mixing_device(a,22000,b,c,d); - } - -static void f10exit() - { - int c; - do - { - c=*(int*)task_wait_event(E_KEYBOARD); - if ((c & 0xff)==0 && (c>>8)=='D') terminate_gui(); - if ((c & 0xff)==0 && (c>>8)=='C') - { - done_mysky(); - closemode(); - grinit(); - redraw_desktop(); - schovej_mysku(); - zobraz_mysku(); - } - } - while (1); - } - -void initialization(void) - { - init_sound(); - grinit(); - init_events(); - install_gui(); - zobraz_mysku(); - update_mysky(); - add_task(1024,f10exit); - redraw_desktop();do_events(); - msg_box_font=vga_font; - msg_icn_font=icones; - getcwd(last_path,255); - } - -long def_window(word xs,word ys,char *name) - { - word x=0,y=0; - WINDOW *p; - CTL3D ctl; - FC_TABLE fc; - long q; - - if (waktual!=NULL) - { - x=waktual->x; - y=waktual->y; - } - - highlight(&ctl,WINCOLOR); - ctl.bsize=2;ctl.ctldef=0; - x+=20;y+=20; - memcpy(fc,flat_color(0x7fe0),sizeof(FC_TABLE)); - fc[0]=0x0000; - if (x+xs>MAX_X-2) x=MAX_X-2-xs; - if (y+ys>MAX_Y-2) y=MAX_Y-2-ys; - p=create_window(x,y,xs,ys,WINCOLOR,&ctl); - q=desktop_add_window(p); - define(0,2,2,xs-5-20*(xs>=70),14,0,win_label,name); - ctl.bsize=1;ctl.ctldef=1; - o_end->autoresizex=1; - property(&ctl,vga_font,&fc,LABELCOLOR); - if (xs>=70) - { - define(1,1,1,19,16,1,button,"\x0f"); - property(NULL,icones,&icone_color,WINCOLOR);on_control_change(close_current); - } - return q; - } - -int def_dialoge(word x,word y,word xs, word ys, char *name,char modal) - { - CTL3D ctl; - FC_TABLE fc; - WINDOW *p; - int i; - - memcpy(fc,flat_color(0x7fe0),sizeof(FC_TABLE)); - memcpy(&ctl,def_border(2,WINCOLOR),sizeof(CTL3D)); - p=create_window(x,y,xs,ys,WINCOLOR,&ctl); - i=desktop_add_window(p); - if (modal) set_window_modal(); - ctl.bsize=1;ctl.ctldef=1; - define(0,1,1,xs-2,14,0,win_label,name); - o_end->autoresizex=1; - property(&ctl,vga_font,&fc,LABELCOLOR); - return i; - } - - -static void display_progress(void) - { - def_dialoge(10,300,620,80,"Na��tďż˝m informace o filmu...",1); - define(10,10,20,600,30,0,done_bar,100); - property(def_border(3,WINCOLOR),NULL,flat_color(0x2e0),WINCOLOR); - define(30,5,5,80,20,2,button,"Konec");on_control_change(terminate_gui); - property(def_border(1,0),vga_font,flat_color(0),BUTTONCOLOR); - c_default(0); - redraw_window(); - exit_wait=0; - } - -static char show_progress(int perc) - { - c_set_value(0,10,perc); - do_events(); - return exit_wait; - } - -static void done_progress(void) - { - if (exit_wait) - { - shutdown(); - puts("Program aborted by user..."); - exit(0); - } - exit_wait=0; - close_current(); - redraw_desktop(); - } - -void show_frame(int frame) - { - static int last_task=0; - - if (last_task) term_task(last_task); - while (last_task!=0) task_sleep(NULL); - if (frame>=0) last_task=add_task(32768,build_frame,frame,&last_task); - } - -int delay_task=0; -int delay_task_counter=0; - -void delayed_redraw() //task! - { - for(delay_task_counter=0;delay_task_counter<5;delay_task_counter++) task_wait_event(E_TIMER); - delay_task=0; - redraw_desktop(); - } - -static void change_frame_pos() - { - int frame; - frame=f_get_value(win_preview,20); - if (find_window(win_program)!=NULL) - { - set_value(win_program,10,&frame); - set_value(win_program,20,&frame); - set_value(win_program,30,&frame); - if (!delay_task) delay_task=add_task(1024,delayed_redraw); - else delay_task_counter=0; - } - show_frame(frame); - } - -void init_desktop(void) - { - FC_TABLE cl; - - cl[0]=0;cl[1]=0x610; - win_preview=def_dialoge(10,10,324,228,"Preview",0); - define(5,1,1,14,14,1,color_box);c_default(LABELCOLOR); - define(10,2,20,320,180,0,pic_viewer);c_default(0); - define(20,26,4,271,17,3,scroll_bar_h,0,total_frames-1,total_frames/16,0x0200); - property(def_border(3,WINCOLOR),NULL,NULL,WINCOLOR);c_default(0);on_control_change(change_frame_pos); - define(21,2,4,21,19,2,scroll_button,1,100,"\x1c"); - property(NULL,icones,&cl,WINCOLOR);on_control_change(scroll_support); - define(22,2,4,21,19,3,scroll_button,-1,-100,"\x1d"); - property(NULL,icones,&cl,WINCOLOR);on_control_change(scroll_support); - redraw_desktop(); - show_frame(0); - } - - -void shutdown() - { - done_mysky(); - closemode(); - } - - -static void init_editor() - { - char *chyba; - display_progress(); - switch(examine_mgif_file(show_progress)) - { - case EX_NOT_FOUND:chyba="MGIF soubor nenalezen!";break; - case EX_NO_SOUND:chyba="Film nemďż˝ zvukovou stopu. Sestav jej se zvukem.";break; - case EX_READ_ERROR:chyba="Chyba pďż˝i ďż˝tenďż˝. Film je moďż˝nďż˝ poďż˝kozen";break; - case EX_SOUND_ERROR:chyba="Nekonzistentnďż˝ zvukovďż˝ stopa!";break; - default:chyba=NULL; - } - if (chyba!=NULL) - { - msg_box(PRG_HEADER,'\x1',chyba,"Stop",NULL); - shutdown(); - abort(); - } - done_progress(); - } - -static int step_vpoint=1; - -static void change_vpoint() - { - TRACK_DATA_T **p,z; - int id=o_aktual->id; - int frame; - int m; - - if (id>100) - { - p=&smp_prg[cur_track].pravy; - id-=100; - } - else - p=&smp_prg[cur_track].levy; - frame=f_get_value(win_preview,20); - get_vpoint(*p,frame,&z); - m=z.vpoint1; - switch(id) - { - case 50:m-=step_vpoint>>3;if (m<0) m=0; set_vpoint(p,frame,m,m);step_vpoint++;break; - case 40:m+=step_vpoint>>3;if (m>255) m=255; set_vpoint(p,frame,m,m);step_vpoint++;break; - case 60:delete_vpoint(p,frame);break; - case 70:if (z.next!=NULL) set_vpoint(p,frame,z.next->vpoint1,z.next->vpoint1);break; - case 80:change_vpoint_spacing(*p,frame,step_vpoint>>3);step_vpoint++;break; - case 90:change_vpoint_spacing(*p,frame,-(step_vpoint>>3));step_vpoint++;break; - } - redraw_window(); - } - -static void step_clear(EVENT_MSG *msg) - { - if (msg->msg==E_LOST_FOCUS) - { - step_vpoint=8; - return; - } - if (msg->msg==E_MOUSE) - { - MS_EVENT *ms; - - ms=get_mouse(msg); - if (ms->event_type & (0x4|0x8)) step_vpoint=8; - } - } - -static void toggle_restart() - { - int *p; - int i,c; - int frame; - - frame=f_get_value(win_preview,20); - c=smp_prg[cur_track].starts_count; - p=smp_prg[cur_track].starts; - for(i=0;iid) - { - case 210:vol=max(vol1,vol2);break; - case 220:vol=min(vol1,vol2);break; - case 230:vol=(vol1+vol2)/2;break; - case 240:vol=vol2;break; - case 250:vol=vol1;break; - } - set_vpoint(p1,frame,vol,vol); - set_vpoint(p2,frame,vol,vol); - redraw_window(); - } - -static void change_frame_clk1() - { - int fr; - - fr=f_get_value(0,o_aktual->id); - c_set_value(win_preview,20,fr); - c_set_value(win_program,10,fr); - c_set_value(win_program,20,fr); - c_set_value(win_program,30,fr); - show_frame(fr); - } - - -static void mute_channel() - { - char c; - int i; - - c=f_get_value(0,260); - for(i=10;i<260;i++)set_enable(0,i,!c); - if (smp_prg[cur_track].muted!=c) - { - compare_vol_table(smp_prg+cur_track); - set_vol_table_nul(); - compare_vol_table(smp_prg+cur_track); - smp_prg[cur_track].muted=c; - } - } - -void open_program_window(int track) - { - FC_TABLE cl1,cl2; - CTL3D *cl; - int i; - int frame; - - frame=f_get_value(win_preview,20); - if (track>=samples_total) track=-1; - if (cur_track!=track) - { - WINDOW *w; - w=find_window(win_program);if (w!=NULL) close_window(w); - if (cur_track>=0 && cur_track=0 && cur_track"); - } - send_message(E_GUI,9,E_CONTROL,1,ls); - } - -static void dopln_jmeno_samplu() - { - char *name,*c; - TSTR_LIST ls; - int i; - FILE *f; - - send_message(E_GUI,9,E_CONTROL,0,&ls); - i=f_get_value(0,9); - if (ls[i]==NULL) return; - c=ls[i]; - if (!strcmp(c,"")) return; - concat(name,last_path,c); - set_value(0,30,name); - f=fopen(name,"rb"); - if (f!=NULL) - { - if (find_chunk(f,WAV_DATA)!=-1) - { - char d[50]; - - set_value(0,60,itoa(get_chunk_size(f),d,10)); - } - fclose(f); - } - } - -void new_edit_sample(int track) - { - TSTR_LIST dir; - CTL3D b1,b2,b3; - char *c,empty[]=""; - char num[200]; - - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D)); - memcpy(&b3,def_border(6,WINCOLOR),sizeof(CTL3D)); - def_dialoge(20,140,600,200,"Vloďż˝ novďż˝ zvuk",1); - dir=create_list(2);str_add(&dir,""); - define(9,10,20,120,166,0,listbox,dir,0x7fff,0);on_control_change(dopln_jmeno_samplu); - property(&b3,NULL,NULL,WINCOLOR);c_default(0); - define(10,137,40,19,127,0,scroll_bar_v,0,10,1,0x0200); - property(&b2,NULL,NULL,WINCOLOR); - define(11,136,20,21,17,0,scroll_button,-1,0,"\x1e"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(12,136,170,21,17,0,scroll_button,1,10,"\x1f"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(20,170,20,420,12,0,input_line,255);set_default(last_path);on_control_exit(change_dir); - property(&b3,vga_font,NULL,WINCOLOR); - define(-1,170,35,1,1,0,label,"Cesta a jmďż˝no zvuku"); - define(-1,170,65,1,1,0,label,"Jmďż˝no stopy (volitelnďż˝)"); - define(-1,170,95,1,1,0,label,"Za��tek opakovďż˝nďż˝ (-1 vyp)"); - define(-1,170,125,1,1,0,label,"Konec opakovďż˝nďż˝"); - c=(smp_prg[track].sample_name);if (c==NULL) c=empty; - define(30,170,50,420,12,0,input_line,255);set_default(c); - property(&b3,vga_font,NULL,WINCOLOR); - c=(smp_prg[track].user_name);if (c==NULL) c=empty; - define(40,170,80,220,12,0,input_line,255);set_default(c); - property(&b3,vga_font,NULL,WINCOLOR); - define(50,290,110,100,12,0,input_line,199);set_default(itoa(smp_prg[track].loop_start,num,10)); - property(&b3,vga_font,NULL,WINCOLOR); - define(60,290,140,100,12,0,input_line,199);set_default(itoa(smp_prg[track].loop_end,num,10)); - property(&b3,vga_font,NULL,WINCOLOR); - define(100,10,10,80,20,2,button,"Storno");property(&b1,vga_font,NULL,BUTTONCOLOR);on_control_change(terminate_gui); - define(110,10,35,80,20,2,button,"Ok");property(&b1,vga_font,NULL,BUTTONCOLOR);on_control_change(terminate_gui); - define(120,10,70,38,20,2,button,"");property(&b1,vga_font,NULL,BUTTONCOLOR); - define(130,52,70,38,20,2,button,"");property(&b1,vga_font,NULL,BUTTONCOLOR); - redraw_window(); - change_dir(); - escape(); - if (o_aktual->id==110) - { - char s[256]; - TRACK_INFO_T *t=smp_prg+track; - - get_value(0,30,s);free(t->sample_name);t->sample_name=NewArr(char,strlen(s)+1); - strcpy(t->sample_name,s); - get_value(0,40,s);free(t->user_name); - if (s[0]!=0) - { - t->user_name=NewArr(char,strlen(s)+1); - strcpy(t->user_name,s); - } - else t->user_name=NULL; - get_value(0,50,s);t->loop_start=atoi(s); - get_value(0,60,s);t->loop_end=atoi(s); - } - close_current(); - } - -static void select_sample() - { - int i; - i=f_get_value(0,9); - open_program_window(i); - } - -static void update_sample_list() - { - TSTR_LIST ls; - int i; - char p; - - send_message(E_GUI,9,E_CONTROL,0,&ls); - build_sample_list(&ls); - send_message(E_GUI,9,E_CONTROL,1,ls); - i=f_get_value(0,9); - if (i>=samples_total) i=samples_total-1; - if (i<0) i=0; - c_set_value(0,9,i); - p=samples_total!=0; - set_enable(0,30,p);set_enable(0,40,p);set_enable(0,50,p); - run_background(select_sample); - } - - -static void new_sample() - { - int track; - track=add_sample(""); - open_program_window(-1); - select_sample(); - new_edit_sample(track); - select_window(win_control); - if (smp_prg[track].sample_name[0]==0) remove_sample(track); - else - { - c_set_value(0,9,track); - set_vol_table_nul(); - compare_vol_table(smp_prg+track); - } - update_sample_list(); - } - -static void edit_sample() - { - int i; - i=f_get_value(0,9); - if (i>=samples_total || i<0) return; - new_edit_sample(i); - compare_vol_table(smp_prg+cur_track); - set_vol_table_nul(); - compare_vol_table(smp_prg+cur_track); - open_program_window(-1); - update_sample_list(); - } - -static void delete_sample() - { - int i; - i=f_get_value(0,9); - if (i>=samples_total || i<0) return; - if (msg_box("Otďż˝zka?",'\x2',"Odstranit zvuk?","Ano","Ne",NULL)==2) return; - open_program_window(-1); - remove_sample(i); - update_sample_list(); - } - -static void duplic_sample() - { - int track; - int i; - TRACK_INFO_T *t1,*t2; - i=f_get_value(0,9); - if (i>=samples_total || i<0) return; - t1=smp_prg+i; - track=add_sample(t1->sample_name); - open_program_window(-1); - t1=smp_prg+i; - t2=smp_prg+track; - if (t1->user_name!=NULL) - { - t2->user_name=NewArr(char,strlen(t1->user_name)+1); - strcpy(t2->user_name,t1->user_name); - } - else t2->user_name=NULL; - t1->loop_start=t2->loop_start; - t1->loop_end=t2->loop_end; - c_set_value(0,9,track); - send_message(E_GUI,9,E_CONTROL,2); - update_sample_list(); - } - -static void prehrat_cele() - { - show_frame(-1); - def_dialoge(2,42,635,378,"Pďż˝ehrďż˝t celďż˝",1); - redraw_window(); - curcolor=0; - start_mixing(); - play_animation(mgif_filename,SMD_HICOLOR,60,1); - stop_mixing(); - close_current(); - } - -static void stop_preview_clk() - { - stop_preview(); - } - -static void prehrat_preview() - { - OBJREC *o; - WINDOW *w; - int x,y; - - w=find_window(win_preview); - o=find_object(w,10); - show_frame(-1); - x=o->locx+320+4; - y=o->locy+180+4; - if (x>500) x=2;if (y>400) y=2; - def_dialoge(x,y,100,80,"Nďż˝hled",1); - define(10,10,25,80,30,0,button,"STOP"); - property(def_border(1,0),vga_font,NULL,BUTTONCOLOR);on_control_change(stop_preview_clk); - redraw_window(); - preview_block(f_get_value(win_preview,20),o->locx,o->locy); - close_current(); - } - -static void make() - { - if (cur_track>=0 && cur_trackid==30) - { - get_value(0,20,buffer); - if (sscanf(buffer,"%d",value)!=1) - { - msg_box(PRG_HEADER,'\x1',"To musďż˝ bďż˝t ��slo!","Ok",NULL); - goto chyba; - } - close_current(); - return 1; - } - close_current(); - return 0; - } - -static void ginsert() - { - int v; - int frame; - - frame=f_get_value(win_preview,20); - v=get_inserted_frames(frame); - if (how_frames("Kolik bylo vloďż˝eno?",&v)==0) return; - insert_global(frame,v); - redraw_desktop(); - } - -static void gdelete() - { - int v; - int frame; - - frame=f_get_value(win_preview,20); - v=get_deleted_frames(); - if (how_frames("Kolik bylo vymazďż˝no?",&v)==0) return; - delete_global(frame,v); - redraw_desktop(); - } - - - -void control_window() - { - CTL3D b1,b2,b3; - char p; - - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D)); - memcpy(&b3,def_border(6,WINCOLOR),sizeof(CTL3D)); - default_font=vga_font; - memcpy(f_default,flat_color(0x0000),sizeof(charcolors)); - win_control=def_dialoge(350,10,280,228,PRG_HEADER,0); - build_sample_list(&smp_list); - define(9,10,20,100,196,0,listbox,smp_list,0x7fff,0);on_control_change(select_sample); - property(&b3,NULL,NULL,WINCOLOR);c_default(-1); - define(10,117,40,19,157,0,scroll_bar_v,0,10,1,0x0200); - property(&b2,NULL,NULL,WINCOLOR); - define(11,116,20,21,17,0,scroll_button,-1,0,"\x1e"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(12,116,200,21,17,0,scroll_button,1,10,"\x1f"); - property(NULL,icones,NULL,WINCOLOR);on_control_change(scroll_support); - define(20,140,20,65,20,0,button,"Novďż˝");property(&b1,vga_font,NULL,BUTTONCOLOR);on_control_change(new_sample); - define(30,210,20,65,20,0,button,"Odstraďż˝");property(&b1,vga_font,NULL,BUTTONCOLOR);on_control_change(delete_sample); - define(40,140,45,65,20,0,button,"Oprav");property(&b1,vga_font,NULL,BUTTONCOLOR);on_control_change(edit_sample); - define(50,210,45,65,20,0,button,"Duplikuj");property(&b1,vga_font,NULL,BUTTONCOLOR);on_control_change(duplic_sample); - define(60,140,120,65,20,0,button,"Pďż˝ehrďż˝t");property(&b1,vga_font,NULL,BUTTONCOLOR);on_control_change(prehrat_cele); - define(70,210,120,65,20,0,button,"Nďż˝hled");property(&b1,vga_font,NULL,BUTTONCOLOR);on_control_change(prehrat_preview); - define(80,140,145,65,20,0,button,"Make");property(&b1,vga_font,NULL,BUTTONCOLOR);on_control_change(make); - define(90,210,145,65,20,0,button,"Build");property(&b1,vga_font,NULL,BUTTONCOLOR);on_control_change(build); - define(100,210,10,65,20,3,button,"Exit");property(&b1,vga_font,NULL,BUTTONCOLOR);on_control_change(exit_prog); - define(110,140,10,65,20,3,button,"Info");property(&b1,vga_font,NULL,BUTTONCOLOR);on_control_change(info); - define(120,140,170,65,20,0,button,"GInsert");property(&b1,vga_font,NULL,BUTTONCOLOR);on_control_change(ginsert); - define(130,210,170,65,20,0,button,"GDelete");property(&b1,vga_font,NULL,BUTTONCOLOR);on_control_change(gdelete); - p=samples_total!=0; - set_enable(0,30,p);set_enable(0,40,p);set_enable(0,50,p); - redraw_window(); - } - -void main(int argc,char **argv) - { - - if (argc!=2) - { - puts("MGF SoundTrack Editor ... (C) 1998 Ondďż˝ej Novďż˝k\n"); - puts("Usage: MGIFEDIT "); - exit(1); - } - initialization(); - set_mgif(argv[1]); - prj_name=get_project_name(mgif_filename); - switch (load_project(prj_name)) - { - case -1:msg_box(PRG_HEADER,'\x1',"Chyba formďż˝tu v projektu!","Zav��t",NULL);shutdown();exit(1); - case -2:msg_box(PRG_HEADER,'\x1',"Neoďż˝ekďż˝vanďż˝ eof souboru!","Zav��t",NULL);shutdown();exit(1); - } - init_editor(); - warn_size_mistmach(); - init_desktop(); - control_window(); - escape(); - shutdown(); - } diff --git a/VIDEO/MGIFEDIT.H b/VIDEO/MGIFEDIT.H deleted file mode 100644 index 462890d..0000000 --- a/VIDEO/MGIFEDIT.H +++ /dev/null @@ -1,40 +0,0 @@ -#define concat(c,s1,s2) \ - c=alloca(strlen(s1)+strlen(s2)+1);\ - strcpy(c,s1);\ - strcat(c,s2) - -extern word boldcz; -extern word ikones; -extern void *icones; -extern void *vga_font; -extern word sipka; - -extern int win_preview; - -void shutdown(); - -#define crash(msg) \ - {\ - shutdown();\ - printf("Module: %s\nLine: %d\nMessage: %s\n",__FILE__,__LINE__,msg);\ - abort();\ - }\ - -#define WINCOLOR 0x631f -#define LABELCOLOR 0x0f -#define BUTTONCOLOR (28*1024+24*32+3) -#define PRG_HEADER "MGIF Sound editor v1."VERSION - - -void show_full_lfb12e(void *source,void *target,void *palette); -#pragma aux show_full_lfb12e parm[esi][edi][ebx] modify [eax ecx edx] -void show_delta_lfb12e(void *source,void *target,void *palette); -#pragma aux show_delta_lfb12e parm[esi][edi][ebx] modify [eax ecx edx] -void show_full_interl_lfb130(void *source,void *target,void *palette); -#pragma aux show_full_interl_lfb130 parm[esi][edi][ebx] modify [eax ecx edx] -void show_delta_interl_lfb130(void *source,void *target,void *palette); -#pragma aux show_delta_interl_lfb130 parm[esi][edi][ebx] modify [eax ecx edx] -char test_next_frame(void *bufpos,int size); -#pragma aux test_next_frame parm [edi][ecx] modify [ebx] value [al] -void *sound_decompress(void *source,void *bufpos,int size,void *ampl_tab); -#pragma aux sound_decompress parm [esi][edi][ecx][ebx] modify [eax edx] value [edi] diff --git a/VIDEO/MGIFEOBJ.C b/VIDEO/MGIFEOBJ.C deleted file mode 100644 index 90de54f..0000000 --- a/VIDEO/MGIFEOBJ.C +++ /dev/null @@ -1,275 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mgifeobj.h" -#include "mgifedit.h" -#include "mgifeact.h" - - -static void done_bar_init(OBJREC *o,long *params) - { - o->userptr=New(long); - *(long *)o->userptr=*params; - } - -static void done_bar_draw(int x1,int y1,int x2,int y2,OBJREC *o) - { - long value,max,x3; - - value=*(long *)o->data; - max=*(long *)o->userptr; - x3=x1+(x2-x1)*value/max; - if (x3<=x1) x3=x1; - if (x3>=x2) x3=x2; - bar(x3,y1,x2,y2); - curcolor=o->f_color[1]; - bar(x1,y1,x3,y2); - } - -void done_bar(OBJREC *o) //define(...done_bar,max); - { - o->call_init=done_bar_init; - o->call_draw=done_bar_draw; - o->datasize=4; - } - - -static void pic_view_draw(int x1,int y1,int x2,int y2,OBJREC *o) - { - void *pic; - - x2,y2; - pic=*(void **)o->data; - if (pic!=NULL) - put_picture(x1,y1,pic); - } - -void pic_viewer(OBJREC *o) //define(...pic_view);set_value(ptr) - { - o->call_draw=pic_view_draw; - o->datasize=4; - } - -//---------------------------------------- - -#define FRAME_SIZE 2 - -static void track_view_init(OBJREC *o,void **params) - { - o->userptr=New(void *); - memcpy(o->userptr,params,sizeof(void *)); - } - -static void track_view_draw(int x1,int y1,int x2,int y2,OBJREC *o) - { - int start; - int fstart; - int pos; - int midl=x1+x2>>1; - TRACK_DATA_T z,u,*p; - - pos=*(int *)o->data; - start=(midl-pos*FRAME_SIZE); - if (startuserptr,fstart,&z); - curcolor=0; - while(p!=NULL && start+p->time*FRAME_SIZE<=x2) - { - int ys1,ys2; - - ys1=y2-(y2-y1)*p->vpoint1/256; - ys2=y2-(y2-y1)*p->vpoint2/256; - curcolor=0; - bar(start-1,ys1-1,start+1,ys1+1); - curcolor=p->vpoint1==p->vpoint2?0:0x7c00; - line(start,ys1,start+p->time*FRAME_SIZE,ys2); - start+=p->time*FRAME_SIZE; - fstart+=p->time; - p=p->next; - } - if (p!=NULL) - { - int ys1,ys2; - - get_vpoint(**(TRACK_DATA_T ***)o->userptr,fstart+(x2-start)/FRAME_SIZE,&u); - ys1=y2-(y2-y1)*p->vpoint1/256; - ys2=y2-(y2-y1)*u.vpoint1/256; - curcolor=0; - bar(start-1,ys1-1,start+1,ys1+1); - curcolor=p->vpoint1==p->vpoint2?0:0x7c00; - line(start,ys1,x2,ys2); - } - } - -static int find_near_vpoint(TRACK_DATA_T *t,int frame,int yy,int nrf,int nrs) - { - int fr=0; - int nfr=frame,rz=nrf; - int p,q; - while (t!=NULL) - { - p=abs(fr-frame); - q=abs(t->vpoint1-yy); - if (ptime; - t=t->next; - } - return nfr; - } - -static void track_view_click(EVENT_MSG *msg,OBJREC *o) - { - MS_EVENT *ms; - static int last_fr=-1; - - if (msg->msg==E_MOUSE) - { - int x,y,*data; - int frel; - int frst; - int fr,nr; - int yy; - - data=(int *)o->data; - ms=get_mouse(msg); - x=ms->x-o->locx; - y=ms->y-o->locy; - frel=x/2; - frst=o->xs/4-*data; - fr=frel-frst; - if (fr<0) fr=0; - if (fr>=total_frames) fr=total_frames-1; - yy=255-(y*256/o->ys); - if (yy<0) yy=0; - nr=find_near_vpoint(**(TRACK_DATA_T ***)o->userptr,fr,yy,5,10*256/o->ys); - if (ms->event_type & 0x8 && !ms->tl1) - { - *data=nr; - redraw_object(o); - set_change(); - } - if (ms->event_type & 0x2) last_fr=nr; - else - if (ms->event_type & 0x4) last_fr=-1; - else - if (ms->tl1 && last_fr!=-1) - if (ms->event_type & 0x8) - { - delete_vpoint(*(TRACK_DATA_T ***)o->userptr,last_fr); - redraw_object(o); - last_fr=-1; - } - else - { - set_vpoint(*(TRACK_DATA_T ***)o->userptr,last_fr,yy,yy); - redraw_object(o); - } - } - if (msg->msg==E_LOST_FOCUS) last_fr=-1; - } - -void track_view(OBJREC *o) //track_view(void *track);set_value(pos); - { - o->call_init=track_view_init; - o->call_draw=track_view_draw; - o->call_event=track_view_click; - o->datasize=4; - } - - -#define FRAME_SIZE 2 - -static void starts_view_init(OBJREC *o,void **params) - { - o->userptr=New(void *); - memcpy(o->userptr,params,sizeof(void *)); - } - -static void starts_view_draw(int x1,int y1,int x2,int y2,OBJREC *o) - { - int start; - int fstart; - int pos; - int midl=x1+x2>>1; - int count; - TRACK_INFO_T *d; - int *list; - int i; - - d=*(TRACK_INFO_T **)o->userptr; - list=d->starts;count=d->starts_count; - pos=*(int *)o->data; - start=(midl-pos*FRAME_SIZE); - if (start=0 && y<(x2-x1)/FRAME_SIZE) - { - y*=FRAME_SIZE; - y+=start; - curcolor=0; - bar(y,y1,y+1,y2); - } - } - } - -void starts_view(OBJREC *o) //track_view(void *track);set_value(pos); - { - o->call_init=starts_view_init; - o->call_draw=starts_view_draw; - o->datasize=4; - } - -static void color_box_draw(int x1,int y1,int x2,int y2,OBJREC *o) - { - curcolor=*(int *)o->data; - bar(x1,y1,x2,y2); - } - -void color_box(OBJREC *o) - { - o->call_draw=color_box_draw; - o->datasize=4; - } - diff --git a/VIDEO/MGIFEOBJ.H b/VIDEO/MGIFEOBJ.H deleted file mode 100644 index fd5be3e..0000000 --- a/VIDEO/MGIFEOBJ.H +++ /dev/null @@ -1,6 +0,0 @@ - -void done_bar(); -void pic_viewer(); -void track_view(); //track_view(void *track);set_value(pos); -void starts_view(); //track_view(TRACK_INFO_T *x);set_value(pos); -void color_box(OBJREC *o); //color_box();set_value(color) diff --git a/VIDEO/MGIFPLAY.C b/VIDEO/MGIFPLAY.C deleted file mode 100644 index f10f3d9..0000000 --- a/VIDEO/MGIFPLAY.C +++ /dev/null @@ -1,331 +0,0 @@ -// MOTION GIF - LZW komprimovana animace v rozliseni 320x180 256 barev avsak -// upravena pro prehravani v HICOLOR pro konkretni rezim (32768 barev) - - -// Format - /* - - [ FRAME ] - [CHUNK] !pozor delka je 3 bajtova (tj 16MB) - 0 - PRADNY CHUNK - 1 - LZW FULL SCREEN - 2 - MGIF DELTA - 3 - HICOLOR PALETE - 4 - SOUND TRACK - 5 - TEXT TRACK - 6 - MGIF COPY - 7 - SOUND INIT - - Popis Chunku: - PRAZDNY_CHUNK - muze obsahovat soukrome informace - - LZW_FULL_SCREEN - - ihned za hlavickou nasleduje LZW komprimovany obrazek - v rozliseni 320x180 256 barev - - MGIF_DELTA - - cely blok je LZW komprimovany. Po dekomprimace blok obsahuje - dva druhy informaci. Prvni DWORD je ofset od pocatku dat - ktery ukazuje na zacatek graficke informace. Po tomto - DWORDU jsou ulozeny data o umisteni grafickych bodu v obrazu - Prvni byte znaci, kolik je nutne preskocit slov. (tj *2 byte) - Dalsi byte znaci, kolik je nutne zapsat slov (tj *2 byte) - Po tomto bytu je nutne prenest presne tolik slov z - grafickeho bloku na obrazovku. Dvojice bajtu se opakuji - dokud ani jeden z nich nema nejvyssi 2 bity nastavene. - Pak tento byte znaci ze uz na radce nic vic neni. Dolni cast - byte (tj 6 bitu) pak udava pocet radku, ktere je treba pre- - skocit. (nula=zadny). - - HICOLOR PALETTE - - Prvni byte znamena pocet aktivnich barev. Pak nasleduje - paleta ve formatu xRRRRRGGGGGBBBBB. Rozdil oproti vsem - beznym paletam je v tom ze neni treba v palete udrzovat - barvy, ktere uz na obrazovce jsou, protoze zmena palety - se neprojevi na jiz zobrazenem obrazku. - - SOUND_TRACK - - Kazdy frame obsahuje zvukovou stopu. Je to RAW format. - Pro verzi MGIF97 zde je zvukova informace ulozena ve - zvukove kvalite 16-bit stereo 22000Khz, ovsem komprimovana - na 50% jako MUS. - TEXT_TRACK - - Navic je ve mozne ve frame umistit textovou zpravu (titulek) - Prvni WORD udava dobu zobrazeni (pocet frame). - Pote nasleduje text zakoncen znakem 0; - - MGIF_COPY - Za timto CHUNKEM je ulozen blok dat v nezakomprimovanem - tvaru(tj 57600byte); - - - - */ - - -#include -#include -#include -#include -#include -#include -#include "lzw.h" -#include - -#include -#include -#include -//#include -//#include -#include - -#define MGIF "MGIF" -#define MGIF_Y "97" -#define VER 0x100 -#define MGIF_EMPTY 0 -#define MGIF_LZW 1 -#define MGIF_DELTA 2 -#define MGIF_PAL 3 -#define MGIF_SOUND 4 -#define MGIF_TEXT 5 -#define MGIF_COPY 6 -#define MGIF_SINIT 7 - -char konec=0; - -void *bufpos; -long vals_save=0x80008000; - - -typedef struct mgif_header - { - char sign[4]; - char year[2]; - char eof; - word ver; - long frames; - word snd_chans; - int snd_freq; - short ampl_table[256]; - short reserved[32]; - }; - -struct mgif_header gh; - -int mgf; - -int chunks; -word hipal[256]; - -char open_mgf_file(char *filename) - { - mgf=open(filename,O_BINARY | O_RDONLY); - if (mgf==-1) return 1; - read(mgf,&gh,sizeof(gh)); - vals_save=0; - bufpos=NULL; - return 0; - } - -void close_mgf_file() - { - close(mgf); - } - -void load_frame(void *f) - { - long frame_head; - long frame_size; - - read(mgf,&frame_head,4); - chunks=frame_head & 0xff; - frame_size=frame_head>>8; - read(mgf,f,frame_size); - } - - -void load_lzw_frame(void *p,void *temp) - { - reinit_lzw(); - lzw_decode(p,temp); - } - -void display_copy(char *temp) - { - char *c; - int i,j; - word *w,ww; - - c=temp; - w=lbuffer+60*640; - for(i=0;i<180;i++) - { - for(j=0;j<320;j++) - { - ww=hipal[*c]; -// w[640]=ww; - *w++=ww; -// w[640]=ww; - *w++=ww; - c++; - } - w+=640; - } - //showview(0,0,640,360); - } - -void display_delta(char *temp) - { - char *graph,*contr,sk; - int i,j,k; - word *w,ww; - - contr=temp; - graph=contr+*(long *)contr; - contr+=4;graph+=4; - for(i=0;i<180;i++) - { - w=lbuffer+1280*(i+30);sk=1; - while ((*contr & 0xc0)!=0xc0) - if (sk) - { - w+=(*contr++)*4;sk=!sk; - } - else - { - k=*contr++*2; - for(j=0;j>8;p+=4; - switch(a) - { - case MGIF_LZW: - case MGIF_DELTA:load_lzw_frame(p,temp);frmode=a;break; - case MGIF_PAL:memcpy(hipal,p,siz);break; - case MGIF_COPY:temp=p;frmode=a;break; - case MGIF_SOUND:sound=p;ssize=siz;break; - } - p+=siz; - } - if (sound!=NULL) - { - while (test_next_frame(bufpos,ssize)); - bufpos=sound_decompress(sound,bufpos,ssize,&gh.ampl_table); - } - else delay(50); - if (banking) - switch (frmode) - { - case MGIF_LZW: - case MGIF_COPY:show_full_interl_bank(temp,(word *)(60*2048),hipal);break; - case MGIF_DELTA:show_delta_interl_bank(temp,(word *)(60*2048),hipal);break; - } - else - switch (frmode) - { - case MGIF_LZW: - case MGIF_COPY:show_full_interl_lfb(temp,lbuffer+60*640,hipal);break; - case MGIF_DELTA:show_delta_interl_lfb(temp,lbuffer+(60)*640,hipal);break; - } - } - -extern int test_counter; - - -void play_frames() - { - int x; - void *f,*temp; - f=getmem(65536); - temp=getmem(65536); - for(x=0;x2) - { - sscanf(argv[2],"%d",&a); - sscanf(argv[3],"%x",&b); - sscanf(argv[4],"%d",&c); - sscanf(argv[5],"%d",&d); - } - else sound_detect(&a,&b,&c,&d); - set_mixing_device(a,22050,b,c,d); - start_mixing();delay(10); - init_lzw_compressor(8); - curcolor=0x0; - bar(0,0,639,479);showview(0,0,0,0); - do - if (open_mgf_file(argv[1])) konec=1; - else - { - play_frames(); - close_mgf_file(); - } - while (!konec); - done_lzw_compressor(); - stop_mixing(); - closemode(); - } - diff --git a/VIDEO/OLD/MGIFMEM.C b/VIDEO/OLD/MGIFMEM.C deleted file mode 100644 index 919c974..0000000 --- a/VIDEO/OLD/MGIFMEM.C +++ /dev/null @@ -1,209 +0,0 @@ -#include -#include -#include - -#define MGIF "MGIF" -#define LZW_MAX_CODES 4096 -#define LZW_BUFFER 64000 - - -MGIF_PROC show_proc; -int mgif_frames;int cur_frame; - -typedef struct mgif_header - { - char sign[4]; - char year[2]; - char eof; - word ver; - long frames; - word snd_chans; - int snd_freq; - short ampl_table[256]; - short reserved[32]; - }; - - -typedef struct double_s - { - short group,chr,first,next; - }DOUBLE_S; - -typedef DOUBLE_S CODE_TABLE[LZW_MAX_CODES]; - -DOUBLE_S *compress_dic=NULL; -void *lzw_buffer=NULL; -int clear_code; -int end_code; -int free_code; -int nextgroup; -int bitsize,init_bitsize; -char old_value=0; - -void do_clear_code() - { - int i; - - old_value=0; - nextgroup=free_code; - bitsize=init_bitsize; - for(i=0;igroup=i;p->chr=-1;p->next=-1;p->first=-1; - } - } - -void reinit_lzw() - { - do_clear_code(); - } - -void init_lzw_compressor(int dic_size) - { - - if (compress_dic!=NULL)compress_dic=(CODE_TABLE *)getmem(sizeof(CODE_TABLE)); - clear_code=1<frames; - cur_frame=0; - c+=sizeof(*mgh); - init_lzw_compressor(8); - if (lzw_buffer==NULL) lzw_buffer=getmem(LZW_BUFFER); - return c; - } - -void close_mgif() //dealokuje buffery pro prehravani - { - done_lzw_compressor(); - free(lzw_buffer); - lzw_buffer=NULL; - } - - -int input_code(void *source,long *bitepos,int bitsize,int mask); -#pragma aux input_code parm [esi][edi][ebx][edx]=\ - "mov ecx,[edi]"\ - "mov eax,ecx"\ - "shr eax,3"\ - "mov eax,[esi+eax]"\ - "and cl,7"\ - "shr eax,cl"\ - "and eax,edx"\ - "add [edi],ebx"\ - value[eax] modify [ecx]; - - -void de_add_code(DOUBLE_S *p,int *mask) - { - DOUBLE_S *q; - - q=&compress_dic[nextgroup];q->group=p->group;q->chr=p->chr;q->first=compress_dic[p->group].first+1; - nextgroup++; - if (nextgroup==*mask) - { - *mask=(*mask<<1)+1; - bitsize++; - } - } - - -char fast_expand_code(int code,char **target); -#pragma aux fast_expand_code parm[eax][edi] modify [esi ecx] value [bl] - -void lzw_decode(void *source,char *target) - { - long bitpos=0; - int code,old,i; - DOUBLE_S p; - int old_first; - int mask=0xff; - - - for(i=0;i - [CHUNK] !pozor delka je 3 bajtova (tj 16MB) - 0 - PRADNY CHUNK - 1 - LZW FULL SCREEN - 2 - MGIF DELTA - 3 - HICOLOR PALETE - 4 - SOUND TRACK - 5 - TEXT TRACK - 6 - MGIF COPY - 7 - SOUND INIT - - Popis Chunku: - PRAZDNY_CHUNK - muze obsahovat soukrome informace - - LZW_FULL_SCREEN - - ihned za hlavickou nasleduje LZW komprimovany obrazek - v rozliseni 320x180 256 barev - - MGIF_DELTA - - cely blok je LZW komprimovany. Po dekomprimace blok obsahuje - dva druhy informaci. Prvni DWORD je ofset od pocatku dat - ktery ukazuje na zacatek graficke informace. Po tomto - DWORDU jsou ulozeny data o umisteni grafickych bodu v obrazu - Prvni byte znaci, kolik je nutne preskocit slov. (tj *2 byte) - Dalsi byte znaci, kolik je nutne zapsat slov (tj *2 byte) - Po tomto bytu je nutne prenest presne tolik slov z - grafickeho bloku na obrazovku. Dvojice bajtu se opakuji - dokud ani jeden z nich nema nejvyssi 2 bity nastavene. - Pak tento byte znaci ze uz na radce nic vic neni. Dolni cast - byte (tj 6 bitu) pak udava pocet radku, ktere je treba pre- - skocit. (nula=zadny). - - HICOLOR PALETTE - - Prvni byte znamena pocet aktivnich barev. Pak nasleduje - paleta ve formatu xRRRRRGGGGGBBBBB. Rozdil oproti vsem - beznym paletam je v tom ze neni treba v palete udrzovat - barvy, ktere uz na obrazovce jsou, protoze zmena palety - se neprojevi na jiz zobrazenem obrazku. - - SOUND_TRACK - - Kazdy frame obsahuje zvukovou stopu. Je to RAW format. - Pro verzi MGIF97 zde je zvukova informace ulozena ve - zvukove kvalite 16-bit stereo 22000Khz, ovsem komprimovana - na 50% jako MUS. - TEXT_TRACK - - Navic je ve mozne ve frame umistit textovou zpravu (titulek) - Prvni WORD udava dobu zobrazeni (pocet frame). - Pote nasleduje text zakoncen znakem 0; - - MGIF_COPY - Za timto CHUNKEM je ulozen blok dat v nezakomprimovanem - tvaru(tj 57600byte); - - - - */ - -#include -#include -#include -#include -#include -#include -#include -#include "lzw.h" -#include -#include -#include "jpegmgif.h" - -#define MGIF "MGIF" -#define MGIF_Y "97" -#define VER 0x100 - -#define MGIF_EMPTY 0 -#define MGIF_LZW 1 -#define MGIF_DELTA 2 -#define MGIF_PAL 3 -#define MGIF_SOUND 4 -#define MGIF_TEXT 5 -#define MGIF_COPY 6 -#define MGIF_SINIT 7 - -#define FRAME_X 320 -#define FRAME_Y 180 -#define FRAME_LEN (FRAME_X*FRAME_Y) -#define DELTA_LEN (3*FRAME_LEN) -#define LZW_LEN (2*FRAME_LEN) - -#define SOUND_SPEED 44100 -#define PRE_SOUND ((256*1024)/2) - -#define ZTRATA lowq -#define BZTRATA colorq -#define MAX_FRAME max_fr -#define MIN_FRAME min_fr - -#define BOXES_X 80 -#define BOXES_Y 45 -#define BOXES_ALL (BOXES_X*BOXES_Y) - -#define SND_NAME ".SNF" - -short mult_table[64]; -short square_table[4096]; -int statpic=0; - -typedef struct mgif_header - { - char sign[4]; - char year[2]; - char eof; - word ver; - long frames; - word snd_chans; - int snd_freq; - short ampl_table[256]; - short reserved[32]; - }; - -word last_frame[FRAME_Y][FRAME_X]; -char frame_delta[FRAME_LEN]; -char delta_data[DELTA_LEN]; -char frame_buffer[FRAME_LEN]; -word color_state[32*32+32*32+32*32]; -char calc_data[FRAME_LEN]; -char flc_paleta[256][3]; -int delta_data_size; -int frame_delta_size; -int speed=0; -int global_frame_counter=0; -int last_frame_size; -int total_frames; - -int lowq=0; -int colorq=0; -int max_fr=99999; -int min_fr=0; - -int hranice; -int hdiff=0; -int difdif=0; - -TBOX *iib; -TBOX *rbb; -TBOX *gbb; -char *rgb_mem; -char frame_step=1; - -struct mgif_header gh; - -char lzw_buffer[LZW_LEN]; - -char pal_use[256],color_map[256]; -word hipal[256],max_colors; - - -FILE *mgf; - -long of_pos; -int of_chunks; - -void open_frame() - { - of_chunks=0; - of_pos=ftell(mgf); - fwrite(&of_pos,1,4,mgf); - } - -void close_frame() - { - long fsize,p; - - last_frame_size=fsize=(p=ftell(mgf))-of_pos-4; - fseek(mgf,of_pos,SEEK_SET); - fwrite(&of_chunks,1,1,mgf); - fwrite(&fsize,1,3,mgf); - fseek(mgf,p,SEEK_SET); - total_frames++; - } - - -void write_chunk(char action,long size,void *data) - { - fwrite(&action,1,1,mgf); - fwrite(&size,1,3,mgf); - fwrite(data,1,size,mgf); - of_chunks++; - } - -/* -void conv_2_hicolor() - { - int i,r,g,b; - for(i=0;i<256;i++) - { - r=(flc_paleta[i][0]>>3); - g=(flc_paleta[i][1]>>3); - b=(flc_paleta[i][2]>>3); - hipal[i]=((r<<10)+(g<<5)+b); - } - } - */ - -void conv_2_rgb() - { - int i; - for(i=0;i<256;i++) - { - flc_paleta[i][0]=(hipal[i]>>10) & 0x1f; - flc_paleta[i][1]=(hipal[i]>>5)& 0x1f; - flc_paleta[i][2]=hipal[i]& 0x1f; - } - } - -char find_color(word c); //najde barvu v palete a vraci byte -#pragma aux find_color parm [eax]=\ - "mov edi,offset hipal"\ - "mov ecx,256"\ - "repne scasw"\ - "mov eax,edi"\ - "sub eax,offset hipal"\ - "shr eax,1"\ - "dec eax"\ - value [al] modify[edi ecx]; - - -void init_palmap() - { - int i; - memset(pal_use,0,sizeof(pal_use)); // nuluj pristupy k barvam - for(i=0;i<256;i++) color_map[i]=find_color(hipal[i]); //redukuj paletu; - max_colors=256; // pocet barev zatim 256; - } - -int test_transp(char c,word w) - { - int r1,g1,b1; - int r2,g2,b2; - int diff; - - r1=flc_paleta[c][0]>>3; - g1=flc_paleta[c][1]>>3; - b1=flc_paleta[c][2]>>3; - w&=0x7fff; - b2=w;g2=b2>>5;r2=g2>>5;b2&=0x1f;g2&=0x1f; - r1-=r2;g1-=g2;b1-=b2; - diff=r1*r1+g1*g1+b1*b1; - return diff<=hranice?diff:-1; - } - -int change_color(char c1,char c2,int diff1) - { - int r1,g1,b1; - int r3,g3,b3; - int r4,g4,b4; - int diff2; - - if (!diff1) return -1; - r1=flc_paleta[c1][0]>>3; - g1=flc_paleta[c1][1]>>3; - b1=flc_paleta[c1][2]>>3; - r3=flc_paleta[c2][0]>>3; - g3=flc_paleta[c2][1]>>3; - b3=flc_paleta[c2][2]>>3; - r4=r3-r1;g4=g3-g1;b4=b3-b1; - diff2=r4*r4+g4*g4+b4*b4; - if (diff2*2=0) - {/*if ((i=change_color(c1,c2old,d2))>=0) c1=i,d=0;else */d=1;} - else d=0; - c2old=c1; - if (d && (d2=test_transp(c2,p[1]))>=0) - {/*if (!d && (i=change_color(c2,c2old,d2))>=0) c2=i,d=0;else */d=1;} - else d=0; - c2old=c2; - if (d!=skip) - { - if (skip) *delta++=skc;else *delta++=cpc; - skip=!skip;skc=0;cpc=0; - } - if (!skip) - { - *data++=c1; - *data++=c2; - colors2=hipal[c1]+(hipal[c2]<<16); - *(long *)p=colors2; - cpc++; - } - else skc++; - p+=2; - pal_use[c1]=1; - pal_use[c2]=1; - } - if (!skip) *delta++=cpc; - if (skc==160 && *(delta-1)!=0xff && delta!=delta_data) delta[-1]++; //preskoc n radek - else *delta++=0xc0; //oznac konec radky - } - delta_data_size=delta-delta_data; - frame_delta_size=data-frame_delta; - } - - -void reduce_palette() //redukuje paletu na nejmensi nutny pocet barev - { - int i,j; - - if (!speed) pal_use[0]=1; - for(i=0,j=0;i<256;i++) - { - if (pal_use[i]) - { - hipal[j]=hipal[i]; - color_map[i]=j++; - } - } - max_colors=j; - } - -void filter_colors(void *block,int size,void *colormap); //prefiltruje blok dat podle color_map -#pragma aux filter_colors parm [edi][ecx][ebx]=\ - "lp1: mov al,[edi]"\ - " xlatb"\ - " stosb"\ - " loop lp1"\ - modify [eax]; - - -void *join_two_blocks(void *d1,void *d2,int siz1,int siz2,long *celk) - { - long siz; - char *d; - void *x; - - siz=siz1+siz2+4; - d=(char *)getmem(siz); - x=d; - memcpy(d,&siz1,4);d+=4; - memcpy(d,d1,siz1);d+=siz1; - memcpy(d,d2,siz2); - *celk=siz; - return x; - } - -void create_last_frame(void *source,void *target,void *pal,int size); -#pragma aux create_last_frame parm [esi][edi][ebx][ecx]=\ - "lp1: lodsb"\ - " movzx eax,al"\ - " mov eax,[eax*2+ebx]"\ - " stosw"\ - " loop lp1"\ - modify[eax] - - -void create_mgif_pal() - { - write_chunk(MGIF_PAL,max_colors*2,hipal); - } - - -void create_mgif_lzw() - { - int siz; - - //conv_2_rgb(); - init_palmap(); - create_mgif_pal(); - filter_colors(frame_buffer,FRAME_LEN,color_map); - create_last_frame(frame_buffer,last_frame,hipal,FRAME_LEN); - init_lzw_compressor(8); - memset(lzw_buffer,0,sizeof(lzw_buffer)); - siz=lzw_encode(frame_buffer,lzw_buffer,FRAME_LEN); - if (siz>FRAME_LEN) write_chunk(MGIF_COPY,FRAME_LEN,frame_buffer); - else write_chunk(MGIF_LZW,siz,lzw_buffer); - done_lzw_compressor(8); - } - - -void create_color_state() - { - int i; - int r1,g1,b1; - int r2,g2,b2; - int diff; - char *c; - word *w; - - memset(color_state,0,sizeof(color_state)); - c=frame_buffer; - w=last_frame; - for(i=0;i>3; - g1=flc_paleta[*c][1]>>3; - b1=flc_paleta[*c][2]>>3; - b2=*w;g2=b2>>5;r2=g2>>5;b2&=0x1f;g2&=0x1f; - r1-=r2;g1-=g2;b1-=b2; - diff=abs(r1)+abs(g1<<1)+abs(b1); - color_state[diff]++; - c++;w++; - } - } - -void set_max_color_change(int cchange) - { - int i,s; - - s=0;cchange=57600-cchange; - for(i=sizeof(color_state)/sizeof(word)-1;s0;i--) s+=color_state[i]; - if (s>=cchange) i++; - hranice=i+hdiff;if (hranice<0) hranice=0; - } - -int rozptyl(int v1,int v2) - { - int c1,c2,x,s; - x=v1+v2>>1; - c1=(x-v1); - c2=(x-v2); - s=c1*c1+c2*c2; - return s; - } - -void create_low_quality() - { - void *snd;int l; - char *sn,*sr,c1,c2; - int rs,bs,gs; - - l=FRAME_LEN; - sr=frame_buffer; - snd=calc_data; - sn=(char *)snd; - l--; - while (l--) - { - c1=*sr++; - c2=*sr; - rs=rozptyl(flc_paleta[c1][0],flc_paleta[c2][0]); - gs=rozptyl(flc_paleta[c1][1],flc_paleta[c2][1]); - bs=rozptyl(flc_paleta[c1][2],flc_paleta[c2][2]); - if (rs+gs+bsFRAME_LEN) - { - create_mgif_lzw(); - return; - } - if (!frame_delta_size) return; - reduce_palette(); - filter_colors(frame_delta,frame_delta_size,color_map); - d=join_two_blocks(delta_data,frame_delta,delta_data_size,frame_delta_size,&siz); - init_lzw_compressor(8); - memset(lzw_buffer,0,sizeof(lzw_buffer)); - siz=lzw_encode(d,lzw_buffer,siz); - done_lzw_compressor(); - free(d); - if (siz>FRAME_LEN) - { - create_mgif_lzw(); - return; - } - write_chunk(MGIF_DELTA,siz,lzw_buffer); - create_mgif_pal(); - } - -void prepare_for_mjpg() - { - iib=getmem(sizeof(TBOX)*BOXES_ALL); - rbb=getmem(sizeof(TBOX)*BOXES_ALL); - gbb=getmem(sizeof(TBOX)*BOXES_ALL); - memset(iib,0,sizeof(TBOX)*BOXES_ALL); - memset(rbb,0,sizeof(TBOX)*BOXES_ALL); - memset(gbb,0,sizeof(TBOX)*BOXES_ALL); - ibox=iib; - rbbox=rbb; - gbbox=gbb; - rgb_mem=getmem(FRAME_LEN*3); - create_cos_tab(); - } - -void create_jpg_frame() - { - int i,x,y,a; - char *dl=delta_data; - char *r=rgb_mem; - char *p=frame_buffer; - - conv_2_rgb(); - for(i=0;i0) - { - open_frame(); - create_sound_track(size); - close_frame(); - celk-=size; - } - if (celk) - { - open_frame(); - create_sound_track(celk); - close_frame(); - } - } - -void fill_header(int frames) - { - memset(&gh,0,sizeof(gh)); - strncpy(gh.sign,MGIF,4); - strncpy(gh.year,MGIF_Y,2); - gh.eof=26; - gh.ver=VER; - gh.frames=frames; - } - - - -void show_screen() - { - word *c; - int i,j; - word *w; - - c=last_frame; - w=screen; - for(i=0;i<180;i++) - { - for(j=0;j<320;j++) - { - *w++=*c; - *w++=*c; - c++; - } - w+=640; - } - showview(0,0,640,360); - showview(0,400,639,30); - } - - -void write_frame_size(int i,int col) - { - char s[200]; - sprintf(s,"SIZE: %05d COLORS: %03d COMP.LEVEL %03d",i,col,hranice);position(0,400);outtext(s); - } - -char *get_pcx_name(char *name,int x) - { - static char s[256]; - char c[10],e[20],*z; - int d; - - z=strchr(name,'#'); - if (z==NULL) - { - memset(s,0,sizeof(s)); - strncpy(s,name,240); - d=strlen(s); - if (x>9999) - { - s[d-1]=0; - sprintf(s,"%s%05d.pcx",s,x); - } - else sprintf(s,"%s%04d.pcx",s,x); - strupper(s); - } - else - { - int pocet,i; - pocet=0; - while(*z) if (*z++=='#') pocet++; - sprintf(c,"%%0%dd",pocet); - sprintf(e,c,x); - strcpy(s,name); - z=strchr(s,'#'); - for(i=0;iMAX_FRAME) {difdif=difdif<=0?1:difdif+1;hdiff+=difdif;} - else if (last_frame_size0) {difdif=difdif>=0?-1:difdif-1;hdiff+=difdif;} - else if (hdiff>0) {difdif=difdif>=0?-1:difdif-1;hdiff+=difdif;}else if(hdiff<0) hdiff=0; - show_screen (); - if (statpic) statpic--;else x+=frame_step; - global_frame_counter++; - } - } - - -void create_mgf_file(char *name) - { - mgf=fopen(name,"wb+"); - fwrite(&gh,1,sizeof(gh),mgf); - total_frames=0; - prereserve_tracks(); - } - - -void close_mgf_file() - { - fseek(mgf,0,SEEK_SET); - fill_header(total_frames); - fwrite(&gh,1,sizeof(gh),mgf); - fclose(mgf); - } - - -void create_mult_and_square() - { - int i; - - puts("Creating tables..."); - for(i=0;i<64;i++) mult_table[i]=(short)((i-32)*(i-32)); - for(i=0;i<4096;i++) square_table[i]=(short)sqrt(i); - } - -extern int boldcz; - - -void script_compress(char *script_name) - { - FILE *scr,*snf; - char s[256],name[256]; - char snd_name[256],*c; - int i; - - scr=fopen(script_name,"r"); - strcpy(snd_name,script_name); - c=strrchr(snd_name,'.'); - if (c==NULL) strcat(snd_name,SND_NAME); - else strcpy(c,SND_NAME); - if (scr==NULL) - { - printf("Nemohu otev��t script: %s\n",script_name); - exit(1); - } - snf=fopen(snd_name,"w"); - i=fscanf(scr,"%255s",name); - if (i!=1) - { - printf("Chyba ve script souboru: %s. Prvni musďż˝ bďż˝t jmďż˝no cďż˝lovďż˝ho souboru.\n",scr); - exit(1); - } - i=fscanf(scr,"%d",&speed); - create_mgf_file(name); - while ((i=fgetc(scr))!=EOF && i!='\n'); - i=fgetc(scr); - initmode32(); - while (i!=EOF) - { - while (i<33 && i!=EOF) i=fgetc(scr); - if (i!='#') - { - int j=lowq; - ungetc(i,scr); - i=fscanf(scr,"%s %d %d %d %d",s,&j,&min_fr,&max_fr,&colorq); - strupper(s); - if (!strcmp(s,"FRAMESTEP")) frame_step=j; - else - if (!strcmp(s,"STATIC")) statpic=j; - else - if (i>=1) - { - lowq=j; - if (snf!=NULL) fprintf(snf,"%d ",global_frame_counter); - compress_pcx(s); - } - } - else - while ((i=fgetc(scr))!=EOF && i!='\n'); - i=fgetc(scr); - } - closemode(); - fclose(scr); - if (snf!=NULL) fclose(snf); - close_mgf_file(); - } - -main(int argc,char *argv[]) - { - puts("\n(C)1997 Komprimator Motion GIF v0.9 by Ondrej Novak"); - if (argc<2) - { - puts("Pouziti:");putchar('\n');; - puts("PCX2MGIF [d:\\path\\]source target.mgf [speed] [lowq] [min_fr] [max_fr] [colorq]");putchar('\n'); - puts("source - Jsou 4 znaky kterymi zacina jmeno kazdeho frame (prvni 0). Takto je\n" - " mozne vytvorit animaci az o 9999 frames. Pokud je potreba delsi,pak\n" - " je ctvrty znak zmenen na cislo a je mozne vytvorit animaci dlouhou\n" - " az 99999 frames. Priklad:\n\n" - " PCX2MGIF logo logo.mgf \n\n" - " Tento zapis vytvori animaci logo.mgf, jenz bude slozena z mnoha\n" - " obrazku ve formatu PCX, jejichz jmena budou znit LOGO0000.PCX az\n" - " LOGO9999.PCX a dale bude pokracovat LOG10000.PCX az LOG99999.PCX\n\n" - "speed - Prehravaci rychlost ve snimkach za sekundu (pro 22050kHz)\n" - " Pokud je dosazeno 0 pak neni do animace vkladana zvukova stopa\n" - " (Default: 0)\n" - "lowq - Nejnizsi mozny rozptyl barev sousednich bodu (snizuje kvalitu\n" - " obrazu) (default: 0)\n" - "min_fr - Pozadavek na nejmensi velikost frame. Pod touto hranici v \n" - " nasledujicim frame snizi velikost ztraty (default: 0)"); - cprintf("--- klavesu ---\r");getche(); - puts("max_fr - Pozadavek na nejvetsi velikost frame. Pri prekroceni teto \n" - " hranice se zvysi ztrata o jeden bod. (default 99999)\n" - "colorq - Tato hodnota slouzi k predvidani velikosti ztraty. Udava\n" - " kolik bodu z celkoveho poctu zmen ve frame se menit nebude\n" - " Program pak vybere ty nejmensi rozdily a ty do rozdilove \n" - " mapy nezahrne. (default: 0)\n\n" - "Velikost nejmensiho rozdilu je zobrazen pri komprimaci jako treti cislo\n" - "Nula udava ze se nezapisuji jen ty body, ktere se nemeni.\n\n" - "Pozn1: Bezne neni nutne uvadet parametr colorq protoze stupen ztraty se \n" - "voli podle vysledku predchoziho frame. Je dobre ho uvest pri velkych\n" - "vykyvech velikosti frame. Tak zhruba pri ďż˝10KB. Hodnoty parametru se \n" - "voli od 25000-35000, cim vyssi, tim vyssi stupen ztraty\n\n" - "Pozn2: Pokud nektere parametry vynechas (treba znakem '-', nebo je na konci\n" - "neuvedes, dosadi se default hodnoty. Ty jsou zvoleny tak, aby program\n" - "nevypocitaval ztratu.\n"); - exit(0); - } - curfont=(void *)&boldcz; - if (argc>2) - { - switch (argc) - { - case 8:sscanf(argv[7],"%d",&colorq); - case 7:sscanf(argv[6],"%d",&max_fr); - case 6:sscanf(argv[5],"%d",&min_fr); - case 5:sscanf(argv[4],"%d",&lowq); - case 4:sscanf(argv[3],"%d",&speed); - } - create_mgf_file(argv[2]); - initmode32(); - compress_pcx(argv[1]); - closemode(); - } - else - { - script_compress(argv[1]); - } - puts("Zaviram Motion GIF..."); - close_mgf_file(); - } diff --git a/VIDEO/PLAY.C b/VIDEO/PLAY.C deleted file mode 100644 index 3138bf2..0000000 --- a/VIDEO/PLAY.C +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include -#include "flc.h" -#include "vesa.h" - -void Set_TEXT_mode (void); - -void main (int argc, char *argv[]) -{ - int x; - - Open_FLC (argv[1]); - - printf ("\nHlavicka FLC souboru %s:\n", argv[1]); - printf ("Delka celeho souboru: %d\n", h_flc.size); - printf ("Pocet frame: %d\n", h_flc.frames); - printf ("Velikost filmu: %dx%d\n", h_flc.width, h_flc.height); - printf ("Hloubka barvy: %d\n", h_flc.color); -// printf ("Rychlost prehravani: %d fps\n", 1000/h_flc.speed); - printf ("Offset prvniho frame: %d\n", h_flc.offset1); - getch (); - - Set_VESA_mode (0x101); - delay (1000); - - Get_first_frame (); - Decompress_frame (); - Show_screen (frame_buffer); - - for (x=2; x<=h_flc.frames; x++) - { - Get_next_frame (); - Decompress_frame (); - Show_screen (frame_buffer); - delay (7); - } - getch (); - - Set_TEXT_mode (); - Close_FLC (); -} - -void Set_TEXT_mode (void) -{ - union REGS inr, outr; - - inr.h.ah = 0x00; - inr.h.al = 03; - int386 (0x10, &inr, &outr); -} - - diff --git a/VIDEO/PLAYCNM.C b/VIDEO/PLAYCNM.C deleted file mode 100644 index 591be36..0000000 --- a/VIDEO/PLAYCNM.C +++ /dev/null @@ -1,356 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "anipack.h" -#include "cinema.h" -#include - - -#define CINEMA ".cnm" -#define PLATNO_X 640 -#define PLATNO_Y 184 - -#define PLATNO_S (PLATNO_X*PLATNO_Y) -#define POZICE (60) - -#define DECOMP_BUFF 150000 - -FILE *anim; -word *playscreen; -word *playscreen2; -word *paleta; -word *show_place; -char *decomp_buff; -char *ip; -word direct_line_len=640*8; -char direct=0; -char fusing=1; -char ifuse=0; -char interlaced=0; -char sdiff=0; - -char test_frame[120000]; - -void priponu(char *source,char *target,int n) - { - char *c,*d; - - c=strrchr(source,'.'); - d=strrchr(source,'\\'); - strncpy(target,source,n); - if (c==NULL || c16 && mode<64) || mode>64) exit(0); - if (mode<64) - { - for(i=0;i>1; - q++;p++;i--; - } - while (i); - } - -void copy_frames() - { - memcpy(playscreen2,playscreen,PLATNO_S*2); - } - -void display_interlaced(word *playscreen2,int ofs) - { - word *p,*q; - int i=180; - p=show_place+ofs; - q=playscreen2; - do - { - if (banking) memcpy(mapvesaadr1(p),q,1280);else memcpy(p,q,1280); - q+=640; - p+=banking?2048:1280;i--; - } - while (i); - } - -void display_full_lfb(word *playscreen2) - { - word *p,*q; - int i=180; - p=show_place; - q=playscreen2; - do - { - int j=320; - memcpy(p,q,1280); - p+=640; - do - { - *(long *)p=(*(long *)q & 0x7bde7bde)+(*(long *)(q+640) & 0x7bde7bde)>>1;q+=2;p+=2;j--; - } - while(j); - i--; - } - while (i); - } - -void display_full_bank(word *playscreen2) - { - word *p,*q; - long *z; - int i=180; - p=show_place; - q=playscreen2; - do - { - int j=320; - memcpy(mapvesaadr1(p),q,1280); - p+=1024; - z=(long *)mapvesaadr1(p); - do - { - *z=(*(long *)q & 0x7bde7bde)+(*(long *)(q+640) & 0x7bde7bde)>>1;q+=2;z++;j--; - } - while(j); - p+=1024; - i--; - } - while (i); - } - - -void show_play_screen() - { - if (interlaced) - { - if (fusing) - { - if (ifuse) display_interlaced(playscreen,(banking?1024:640)); - else - { - if (!banking) display_interlaced_fused_lfb(playscreen,playscreen2,show_place); - else display_interlaced_fused_bank(playscreen,playscreen2,show_place); - } - delay(30); - } - display_interlaced(playscreen,0); - } - else - { - if (fusing) - { - fuse_frames(); - if (banking) display_full_bank(playscreen2);else display_full_lfb(playscreen2); - delay(30); - copy_frames(); - } - if (banking) display_full_bank(playscreen);else display_full_lfb(playscreen); - } - } - -void set_direct_mode() - { - fusing=0; - if (!banking) - { - direct=1; - playscreen=show_place; - anim_line_len=1280*2; - direct_line_len=640*16; - } - - } - -void play_cinema(FILE *anim) - { - char i; - - do - { - fread(&i,1,1,anim); - switch (i) - { - case TRACK_VIDEO: - load_frame(anim); - decompr_pict(); - break; - case TRACK_PALETTE: - load_palette(anim); - break; - case TRACK_MUSIC:break; - case TRACK_END:return; - case TRACK_DELAY: - if (!direct) - show_play_screen(); - break; - default: return; - } - if (_bios_keybrd(_KEYBRD_READY)) return; - } - while (1); - } - -void analyze_params(char *c) - { - while (*c) - switch (*c++) - { - case 'i': - case 'I':interlaced=1;break; - case 's': - case 'S':fusing=0;break; - case 'd': - case 'D':direct=1;break; - case 'v': - case 'V':sdiff=1;break; - case 'f': - case 'F':ifuse=1;interlaced=1;fusing=1;break; - } - - } - -void main(int argc,char **argv) - { - char filename[129]; - - if (argc<2) - { - puts("Pouziti: PLAYCNM film[.cnm] [I][D][S]"); - puts(" I - Interlaced, prokladane"); - puts(" S -Skip,vypina dvojnasobny pocet Framu"); - puts(" D - Direct, prima dekomprese do LFB (totez jako IS, ale rychle)"); - puts(" V - View differences, zobrazuje pouze rozdily (jen ty dulezite)"); - puts(" F - Zapina specialni prokladaci rezim + I, ignoruje pri D"); - return; - } - if (argc>=3) analyze_params(argv[2]); - priponu(argv[1],filename,124); - anim=fopen(filename,"rb"); - if (anim==NULL) - { - printf("Nemohu otevrit soubor %s.\n",filename); - return; - } - if (initmode32(NULL)) - { - puts("Tento program vyzaduje grafickou kartu, ktera podporuje HICOLOR 32768 barev") ; - return; - } - delay(1000); - init_cinema(); - if (direct) set_direct_mode(); - do - { - play_cinema(anim); - fseek(anim,0,SEEK_SET); - } - while (!_bios_keybrd(_KEYBRD_READY)); - done_cinema(); - closemode(); - fclose(anim); - } diff --git a/VIDEO/SADA7.FON b/VIDEO/SADA7.FON deleted file mode 100644 index cbc9f80..0000000 Binary files a/VIDEO/SADA7.FON and /dev/null differ diff --git a/VIDEO/VIDEO.C b/VIDEO/VIDEO.C deleted file mode 100644 index d74a6a4..0000000 --- a/VIDEO/VIDEO.C +++ /dev/null @@ -1,102 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "bitline.h" - -int komprimuj_rovinu(void *vstup, int velikost,int rovina,void *buffer,int *vysledek) - { - int i; - int m[4]={0,0,0,0},min,j; - char c[4][1930]; - char *d; - - buffer;vysledek; - rovina=1<=m[1] && m[1]<=m[2]) j=1; - else j=2; - if (m[j]>=m[3]) j=3; - min=m[j]; - printf("%5d %5d %5d %5d - %5d\n",m[0],m[1],m[2],m[3],min); - *vysledek=min; - memcpy(buffer,c[j],min); - return j; - } - - -void *decomprimuj_rovinu(void *vstup,void *vystup,int velikost,int rovina,int mode) - { - char *d; - mode>>=rovina*2; - mode&=0x3; - rovina=1<>3)]|=m<<((j & 0x7)*2); - suma+=vel; - d=(char *)d+vel; - } - suma+=6; - c+=160*2; - } - printf("%d / %d / %d \n",180*20*15*4, suma, suma*100/(180*20*15*4)); - c=pcx+2+2+2; - memset(c,0,640*480*2); - d=compr; - for (i=0;i<180*4;i++) - { - blckdata=d; - d=(char *)d+6; - for(j=0;j<15;j++) - d=decomprimuj_rovinu(d,&c[160*2*blckdata[0]],160,j,(int)blckdata[1]); - } - } - -main() - { - test(); - } - - - diff --git a/Windows/BGraph2Dx.cpp b/Windows/BGraph2Dx.cpp deleted file mode 100644 index 4a45726..0000000 --- a/Windows/BGraph2Dx.cpp +++ /dev/null @@ -1,684 +0,0 @@ -#include -#define DWORD_PTR DWORD * -#include -#include -#include "Skeldal_win.h" -#include "resource.h" - -#define SKELDALCLASSNAME "BranySkeldalDXWindow" - -#define INWINDOW runinwindow - -static int dxWindowZoom=1; - -static HWND hMainWnd; -static IDirect3D9 *DxHandle; -static IDirect3DDevice9 *DxDevice; -static IDirect3DSurface9 *DxBackBuffer; -static D3DPRESENT_PARAMETERS pparm; - -static int initSizeX = 640; -static int initSizeY = 480; - -static unsigned short *mainBuffer=NULL; -static unsigned short *secondBuffer=NULL; -static unsigned short *curBuffer=NULL; -static uint32_t main_linelen; - -#ifdef _DX_REF -#define DXDEVICE_TYPE D3DDEVTYPE_REF -#else -#define DXDEVICE_TYPE D3DDEVTYPE_HAL -#endif - -static bool dialogs=false; -static bool runinwindow=false; -static int shiftscrx=0,shiftscry=0; - -void DXMouseTransform(unsigned short *x, unsigned short *y) -{ - *x=*x*2/dxWindowZoom; - *y=*y*2/dxWindowZoom; -} - -static const char *GetDXResult(HRESULT res) -{ - const char *text; - switch (res) - { - case D3DOK_NOAUTOGEN:text="D3DOK_NOAUTOGEN\r\n\r\nThis is a success code. However, the autogeneration of mipmaps is not supported for this format. This means that resource creation will succeed but the mipmap levels will not be automatically generated.";break; - case D3DERR_CONFLICTINGRENDERSTATE:text="D3DERR_CONFLICTINGRENDERSTATE\r\n\r\nThe currently set render states cannot be used together.";break; - case D3DERR_CONFLICTINGTEXTUREFILTER:text="D3DERR_CONFLICTINGTEXTUREFILTER\r\n\r\nThe current texture filters cannot be used together.";break; - case D3DERR_CONFLICTINGTEXTUREPALETTE:text="D3DERR_CONFLICTINGTEXTUREPALETTE\r\n\r\nThe current textures cannot be used simultaneously.";break; - case D3DERR_DEVICELOST:text="D3DERR_DEVICELOST\r\n\r\nThe device has been lost but cannot be reset at this time. Therefore, rendering is not possible.";break; - case D3DERR_DEVICENOTRESET:text="D3DERR_DEVICENOTRESET\r\n\r\nThe device has been lost but can be reset at this time.";break; - case D3DERR_DRIVERINTERNALERROR:text="D3DERR_DRIVERINTERNALERROR\r\n\r\nInternal driver error. Applications should destroy and recreate the device when receiving this error. For hints on debugging this error, see Driver Internal Errors.";break; - case D3DERR_DRIVERINVALIDCALL:text="D3DERR_DRIVERINVALIDCALL\r\n\r\nNot used.";break; - case D3DERR_INVALIDCALL:text="D3DERR_INVALIDCALL\r\n\r\nThe method call is invalid. For example, a method's parameter may not be a valid pointer.";break; - case D3DERR_INVALIDDEVICE:text="D3DERR_INVALIDDEVICE\r\n\r\nThe requested device type is not valid.";break; - case D3DERR_MOREDATA:text="D3DERR_MOREDATA\r\n\r\nThere is more data available than the specified buffer size can hold.";break; - case D3DERR_NOTAVAILABLE:text="D3DERR_NOTAVAILABLE\r\n\r\nZarizeni neni podporovano. Tato chyba vetsinou vznika pri problemu graficke karty a ovladacu. Prosim preinstalujte ovladace ke graficke karte. (\"This device does not support the queried technique.\")";break; - case D3DERR_NOTFOUND:text="D3DERR_NOTFOUND\r\n\r\nThe requested item was not found.";break; - case D3DERR_OUTOFVIDEOMEMORY:text="D3DERR_OUTOFVIDEOMEMORY\r\n\r\nDirect3D does not have enough display memory to perform the operation.";break; - case D3DERR_TOOMANYOPERATIONS:text="D3DERR_TOOMANYOPERATIONS\r\n\r\nThe application is requesting more texture-filtering operations than the device supports.";break; - case D3DERR_UNSUPPORTEDALPHAARG:text="D3DERR_UNSUPPORTEDALPHAARG\r\n\r\nThe device does not support a specified texture-blending argument for the alpha channel.";break; - case D3DERR_UNSUPPORTEDALPHAOPERATION:text="D3DERR_UNSUPPORTEDALPHAOPERATION\r\n\r\nThe device does not support a specified texture-blending operation for the alpha channel.";break; - case D3DERR_UNSUPPORTEDCOLORARG:text="D3DERR_UNSUPPORTEDCOLORARG\r\n\r\nThe device does not support a specified texture-blending argument for color values.";break; - case D3DERR_UNSUPPORTEDCOLOROPERATION:text="D3DERR_UNSUPPORTEDCOLOROPERATION\r\n\r\nThe device does not support a specified texture-blending operation for color values.";break; - case D3DERR_UNSUPPORTEDFACTORVALUE:text="D3DERR_UNSUPPORTEDFACTORVALUE\r\n\r\nThe device does not support the specified texture factor value. Not used; provided only to support older drivers.";break; - case D3DERR_UNSUPPORTEDTEXTUREFILTER:text="D3DERR_UNSUPPORTEDTEXTUREFILTER\r\n\r\nThe device does not support the specified texture filter.";break; - case D3DERR_WASSTILLDRAWING:text="D3DERR_WASSTILLDRAWING\r\n\r\nThe previous blit operation that is transferring information to or from this surface is incomplete.";break; - case D3DERR_WRONGTEXTUREFORMAT:text="D3DERR_WRONGTEXTUREFORMAT\r\n\r\nThe pixel format of the texture surface is not valid.";break; - case E_FAIL:text="E_FAIL\r\n\r\nAn undetermined error occurred inside the Direct3D subsystem.";break; - case E_INVALIDARG:text="E_INVALIDARG\r\n\r\nAn invalid parameter was passed to the returning function.";break; -// case E_INVALIDCALL:text="E_INVALIDCALL\r\n\r\nThe method call is invalid. For example, a method's parameter may have an invalid value.";break; - case E_NOINTERFACE:text="E_NOINTERFACE\r\n\r\nNo object interface is available.";break; - case E_NOTIMPL:text="E_NOTIMPL\r\n\r\nNot implemented.";break; - case E_OUTOFMEMORY:text="E_OUTOFMEMORY\r\n\r\nDirect3D could not allocate sufficient memory to complete the call.";break; - default: text="Neznama chyba DX";break; - } - return text; -} - -static inline void CheckResult(HRESULT res) - { - if (res==0) return; - char buff[512]; - sprintf(buff,"Chyba pri praci s DirectX: %s\r\nDxResult failed %8X (%d)",GetDXResult(res),res,res&0xFFFF); - MessageBox(NULL,buff,NULL,MB_OK); - ExitProcess(res); - } - -extern "C" - { - -void setvesa_displaystart(int x,int y) - { - WINDOWPLACEMENT wp; - wp.length=sizeof(wp); - GetWindowPlacement(hMainWnd,&wp); - wp.ptMaxPosition.x+=x-shiftscrx; - wp.ptMaxPosition.y+=y-shiftscry; - wp.rcNormalPosition.left+=x-shiftscrx; - wp.rcNormalPosition.top+=y-shiftscry; - wp.rcNormalPosition.right+=x-shiftscrx; - wp.rcNormalPosition.bottom+=y-shiftscry; - shiftscrx=x; - shiftscry=y; - SetWindowPlacement(hMainWnd,&wp); - } - - -#ifndef WINDOWCLASSFLAGS -#define WINDOWCLASSFLAGS 0 -#endif - -static void RegisterWindowClass() - { - WNDCLASSEX cls; - cls.cbSize=sizeof(cls); - cls.style=CS_HREDRAW|CS_VREDRAW|CS_OWNDC|WINDOWCLASSFLAGS ; - cls.lpfnWndProc=(WNDPROC)GameMainWindowWindowProc; - cls.cbClsExtra=0; - cls.cbWndExtra=0; - cls.hInstance=GetModuleHandle(NULL); - cls.hIcon=LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_MAINICON));; - cls.hCursor=NULL; - cls.hbrBackground=NULL; - cls.lpszMenuName=NULL; - cls.lpszClassName=SKELDALCLASSNAME; - cls.hIconSm=NULL; - if (RegisterClassEx(&cls)==NULL) - { - MessageBox(NULL,"RegisterClassFailed",NULL,MB_OK); - exit(0); - } - } - -static void ColCalc() - { - do - { - int32_t val; - printf("number:"); - scanf("%X",&val); - printf("RGB555(%d,%d,%d)\n",(val>>10),(val>>5) & 0x1F, val & 0x1F); - } - while (1); - } - -static void CreateSkeldalWindow() - { - //ColCalc(); - char buff[256]; - - LoadString(GetModuleHandle(NULL),IDS_WINTITLE,buff,sizeof(buff)); - - - RECT rc={0,0,initSizeX*dxWindowZoom/2,initSizeY*dxWindowZoom/2}; - DWORD flags=(INWINDOW?(WS_OVERLAPPED|WS_SYSMENU|WS_MINIMIZEBOX|WS_CAPTION|WS_BORDER):(WS_POPUP|WS_SYSMENU))|WS_VISIBLE; - AdjustWindowRect(&rc,flags,FALSE); - hMainWnd=CreateWindow(SKELDALCLASSNAME,buff,flags,100,100,rc.right-rc.left,rc.bottom-rc.top,NULL,NULL,GetModuleHandle(NULL),NULL); - if (hMainWnd==NULL) - { - MessageBox(NULL,"WindowCreationFailed",NULL,MB_OK); - exit(0); - } - UpdateWindow(hMainWnd); - } - - -static void DisplayMode(char init) - { - DEVMODE mode; - int res; - - if (init) - { - EnumDisplaySettings(NULL,ENUM_REGISTRY_SETTINGS,&mode); - - mode.dmSize=sizeof(mode); - mode.dmBitsPerPel=16; - mode.dmFields=DM_BITSPERPEL|DM_DISPLAYFREQUENCY|DM_DISPLAYFLAGS|DM_PELSWIDTH|DM_PELSHEIGHT; - - res=ChangeDisplaySettings(&mode,0); - } - else - res=ChangeDisplaySettings(NULL,0); - } - -static bool ShowLogo() - { - HBITMAP logo=(HBITMAP)LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_INITLOGO),IMAGE_BITMAP,0,0,0); - if (logo==NULL) return false; - HDC hDC; - CheckResult(DxBackBuffer->GetDC(&hDC)); - HDC hBitmap=CreateCompatibleDC(hDC); - HBITMAP old=(HBITMAP)SelectObject(hBitmap,logo); - BitBlt(hDC,0,0,initSizeX,initSizeY,hBitmap,0,0,SRCCOPY); - SelectObject(hBitmap,old); - DeleteDC(hBitmap); - DxBackBuffer->ReleaseDC(hDC); - DeleteObject(logo); - return true; - } - -void CheckMessageQueue(); - -char DXInit64(char inwindow, int zoom, int monitor, int refresh) - { - runinwindow=inwindow!=0; - dxWindowZoom=inwindow?zoom+1:2; - - RegisterWindowClass(); - CreateSkeldalWindow(); - - DxHandle=Direct3DCreate9(D3D_SDK_VERSION); - if (DxHandle==NULL) - { - MessageBox(hMainWnd,"Nepodarilo se inicializovat DirectX. " - "Preinstalujte prosim DirectX ze stranek www.microsoft.com/directx. " - "Ke spusteni je potreba mit aspon verzi DirectX 9.0c",NULL,MB_OK|MB_ICONEXCLAMATION); - return 0; - } - - HMONITOR mon=DxHandle->GetAdapterMonitor(monitor); - if (mon!=NULL) - { - MONITORINFO moninfo; - moninfo.cbSize=sizeof(moninfo); - GetMonitorInfo(mon,&moninfo); - SetWindowPos(hMainWnd,NULL,moninfo.rcWork.left,moninfo.rcWork.top,0,0,SWP_NOZORDER|SWP_NOSIZE); - } - - pparm.BackBufferWidth=initSizeX; - pparm. BackBufferHeight=initSizeY; - pparm.BackBufferFormat=D3DFMT_R5G6B5; - pparm.BackBufferCount=1; - pparm.MultiSampleType=D3DMULTISAMPLE_NONE; - pparm.SwapEffect=D3DSWAPEFFECT_COPY; - pparm.hDeviceWindow=hMainWnd; - pparm.Windowed=INWINDOW; - pparm.EnableAutoDepthStencil=FALSE; - pparm.Flags=D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; - pparm.FullScreen_RefreshRateInHz=INWINDOW?0:refresh; - pparm.PresentationInterval=D3DPRESENT_INTERVAL_IMMEDIATE ; - pparm.MultiSampleQuality=0; - - HRESULT res; - - res=DxHandle->CreateDevice(monitor,DXDEVICE_TYPE,hMainWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&pparm,&DxDevice); - if (res!=0 && inwindow) - { - DisplayMode(1); - res=DxHandle->CreateDevice(monitor,DXDEVICE_TYPE,hMainWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&pparm,&DxDevice); - } - if (res!=0) - { - res=DxHandle->CreateDevice(monitor,D3DDEVTYPE_REF,hMainWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&pparm,&DxDevice); - } - if (res!=0) - { - CheckResult(res); - return 0; - } - - res=DxDevice->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&DxBackBuffer); - CheckResult(res); - - bool logo; - logo=ShowLogo(); - - D3DLOCKED_RECT lrc; - - res=DxBackBuffer->LockRect(&lrc,NULL,0); - CheckResult(res); - - main_linelen=dx_linelen=scr_linelen=lrc.Pitch; - scr_linelen2=scr_linelen/2; - curBuffer=mainBuffer=(unsigned short *)lrc.pBits; - - secondBuffer=(unsigned short *)malloc(lrc.Pitch*initSizeY); - - if (logo) - { - InvalidateRect(hMainWnd,NULL,TRUE); - DWORD tm=GetTickCount()+5000; - while (tm>GetTickCount()) {Sleep(100);CheckMessageQueue();} - } - - return 1; - } - -void DXCloseMode() - { - if (DxDevice) - { - if (DxBackBuffer) DxBackBuffer->Release(); - DxDevice->Release(); - DxHandle->Release(); - DestroyWindow(hMainWnd); - UnregisterClass(SKELDALCLASSNAME,GetModuleHandle(NULL)); - free(secondBuffer); - if (runinwindow) DisplayMode(0); - DxDevice=NULL; - DxBackBuffer = NULL; - } - } - - -static void HandleDeviceLost() - { - HRESULT res=D3DERR_DEVICELOST; - DxBackBuffer->Release(); - DxBackBuffer=NULL; - while (res==D3DERR_DEVICELOST) - { - while (DxDevice->TestCooperativeLevel()!=D3DERR_DEVICENOTRESET) - { - MSG msg; - GetMessage(&msg,0,0,0); - DispatchMessage(&msg); - } - res=DxDevice->Reset(&pparm); - } - res=DxDevice->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&DxBackBuffer); - CheckResult(res); - res=DxDevice->Present(NULL,NULL,hMainWnd,NULL); - } - -static void GlobalPresent(RECT *prc) -{ - RECT rc=*prc; - RECT winrc=rc; - int z=dxWindowZoom/2; - if (dxWindowZoom!=2) - { - rc.left-=z; - rc.top-=z; - rc.right+=z; - rc.bottom+=z; - if (rc.left<0) rc.left=0; - if (rc.top<0) rc.top=0; - if (rc.right>=winrc.right) rc.right=winrc.right; - if (rc.bottom>=winrc.bottom) rc.bottom=winrc.bottom; - rc.left&=~1; - rc.top&=~1; - rc.right&=~1; - rc.bottom&=~1; - winrc=rc; - winrc.left=winrc.left*dxWindowZoom/2; - winrc.top=winrc.top*dxWindowZoom/2; - winrc.right=winrc.right*dxWindowZoom/2; - winrc.bottom=winrc.bottom*dxWindowZoom/2; - } - if (!dialogs) - { - LRESULT res=DxDevice->Present(&rc,&winrc,hMainWnd,NULL); - if (res==D3DERR_DEVICELOST) HandleDeviceLost(); - } -} - - -static bool UnLockBuffers() - { - if (DxBackBuffer==NULL) return false; - HRESULT res; - res=DxBackBuffer->UnlockRect(); - CheckResult(res); - return true; - } - -static void LockBuffers() - { - D3DLOCKED_RECT lrc; - HRESULT res; - res=DxBackBuffer->LockRect(&lrc,NULL,0); - CheckResult(res); - - curBuffer=mainBuffer=(unsigned short *)lrc.pBits; - if (dx_linelen!=lrc.Pitch) - { - free(secondBuffer); - main_linelen=dx_linelen=scr_linelen=lrc.Pitch; - scr_linelen2=scr_linelen/2; - curBuffer=mainBuffer=(unsigned short *)lrc.pBits; - secondBuffer=(unsigned short *)malloc(lrc.Pitch*initSizeY); - } - } - -void DXCopyRects64(unsigned short x,unsigned short y,unsigned short xs,unsigned short ys) - { - if (UnLockBuffers()==false) return; - - RECT rc; - rc.left=x; - rc.top=y; - rc.right=x+xs; - rc.bottom=y+ys; - GlobalPresent(&rc); - LockBuffers(); - - } - -unsigned short *GetScreenAdr() - { - return curBuffer; - } - -unsigned short *GetBuffer2nd() - { - return secondBuffer; - } - -void RedirectScreen(unsigned short *newaddr) - { - curBuffer=newaddr; - } - -void RestoreScreen() - { - curBuffer=mainBuffer; - scr_linelen=main_linelen; - scr_linelen2=main_linelen>>1; - - } - - -void RedirectScreenBufferSecond() - { - curBuffer=secondBuffer; - } - - -void DXCopyRects64zoom2(unsigned short x,unsigned short y,unsigned short xs,unsigned short ys) - { - HRESULT res; - if (UnLockBuffers()==false) return; - - - RECT rc; - rc.left=x; - rc.top=y; - rc.right=x+xs; - rc.bottom=y+ys; - RECT zoom; - zoom.left=x; - zoom.top=y; - zoom.right=x+2*xs; - zoom.bottom=y+2*ys; - - res=DxDevice->Present(&rc,&zoom,hMainWnd,NULL); - if (res==D3DERR_DEVICELOST) HandleDeviceLost(); - - - LockBuffers(); - } - - -void *DxPrepareWalk(int ypos) - { - HRESULT res; - - - IDirect3DSurface9 *tempbuff; - res=DxDevice->CreateRenderTarget(640,360,D3DFMT_R5G6B5,D3DMULTISAMPLE_NONE,0,TRUE,&tempbuff,NULL); - CheckResult(res); - UnLockBuffers(); - RECT src;src.left=0;src.top=ypos;src.right=640;src.bottom=ypos+360; - RECT trg;trg.left=0;trg.top=0;trg.right=640;trg.bottom=360; - res=DxDevice->StretchRect(DxBackBuffer,&src,tempbuff,&trg,D3DTEXF_NONE); - CheckResult(res); - LockBuffers(); - - return (void *)tempbuff; - } - -void DxZoomWalk(void *handle, int ypos, int *points,float phase, void *lodka) - { - if (phase>1.0) phase=1.0f; - if (phase<0.0) phase=0.0f; - UnLockBuffers(); - IDirect3DSurface9 *surf=(IDirect3DSurface9 *)handle; - RECT rc1;rc1.left=0;rc1.top=0;rc1.right=640;rc1.bottom=360; - RECT rc2;rc2.left=points[0];rc2.top=points[1];rc2.right=points[2];rc2.bottom=points[3]; - RECT rcx; - rcx.left=(int)(rc1.left+(rc2.left-rc1.left)*phase); - rcx.top=(int)(rc1.top+(rc2.top-rc1.top)*phase); - rcx.right=(int)(rc1.right+(rc2.right-rc1.right)*phase); - rcx.bottom=(int)(rc1.bottom+(rc2.bottom-rc1.bottom)*phase); - rc1.top+=ypos; - rc1.bottom+=ypos; - -/* HDC srcdc; - HDC trgdc; - HRESULT res; - res=surf->GetDC(&srcdc);CheckResult(res); - res=DxBackBuffer->GetDC(&trgdc);CheckResult(res); - StretchBlt( - trgdc,rc1.left,rc1.top,rc1.right-rc1.left,rc1.bottom-rc1.top, - srcdc,rcx.left,rcx.top,rcx.right-rcx.left,rcx.bottom-rcx.top,SRCCOPY); - surf->ReleaseDC(srcdc); - DxBackBuffer->ReleaseDC(trgdc); -*/ - - - HRESULT res; - res=DxDevice->StretchRect(surf,&rcx,DxBackBuffer,&rc1,D3DTEXF_NONE); - CheckResult(res); - - GlobalPresent(&rc1); - LockBuffers(); - } - -void DxDoneWalk(void *handle) - { - IDirect3DSurface9 *surf=(IDirect3DSurface9 *)handle; - if (surf) surf->Release(); - } - - - -void DxTurnLeftRight(char right, float phase, int border, int ypos, int *last) - { - if (phase>1.0) phase=1.0f; - if (phase<0.0) phase=0.0f; - if (phase<0.05f) return; - int space=640-2*border; - - unsigned short *scr=GetScreenAdr()+scr_linelen2*ypos; - unsigned short *buf=GetBuffer2nd()+scr_linelen2*ypos; - - int turnout=(float)(space*phase)+border; - int difto=turnout-*last; - if (!right) - { - buf+=border; - for (int y=0;y<360;y++) - { - memcpy(scr,scr+difto,(640-turnout)*2); - memcpy(scr+(640-turnout),buf,(turnout)*2); - scr+=scr_linelen2; - buf+=scr_linelen2; - } - *last=turnout; - } - else - { - for (int y=0;y<360;y++) - { - memmove(scr+*last+difto-border,scr+*last-border,(640-turnout+border)*2); - memcpy(scr,buf+(640-turnout)-border,turnout*2); - scr+=scr_linelen2; - buf+=scr_linelen2; - } - *last=turnout; - } - DXCopyRects64(0,ypos,640,360+ypos); - } - -void *DxPrepareTurn(int ypos) - { - IDirect3DSurface9 **handle=new IDirect3DSurface9 *[2]; - HRESULT res; - - - res=DxDevice->CreateRenderTarget(640,360,D3DFMT_R5G6B5,D3DMULTISAMPLE_NONE,0,TRUE,handle,NULL); - CheckResult(res); - UnLockBuffers(); - RECT src;src.left=0;src.top=ypos;src.right=640;src.bottom=ypos+360; - RECT trg;trg.left=0;trg.top=0;trg.right=640;trg.bottom=360; - res=DxDevice->StretchRect(DxBackBuffer,&src,handle[0],&trg,D3DTEXF_NONE); - CheckResult(res); - - res=DxDevice->CreateRenderTarget(640,360,D3DFMT_R5G6B5,D3DMULTISAMPLE_NONE,0,TRUE,handle+1,NULL); - CheckResult(res); - D3DLOCKED_RECT lrect; - res=handle[1]->LockRect(&lrect,NULL,0); - CheckResult(res); - - unsigned short *trgptr=(unsigned short *)lrect.pBits; - unsigned short *srcptr=secondBuffer+scr_linelen2*ypos; - for (int i=0;i<360;i++,trgptr=(unsigned short *)((char *)trgptr+lrect.Pitch),srcptr+=scr_linelen2) - memcpy(trgptr,srcptr,640*2); - handle[1]->UnlockRect(); - - LockBuffers(); - - return (void *)handle; - } - - -static inline void CopySurfaceAtPos(IDirect3DSurface9 *src, int width, int height, int xpos,int ypos, int border) - { - RECT trc; - trc.left=xpos; - trc.top=ypos; - trc.right=xpos+width; - trc.bottom=ypos+height; - RECT s_rc; - s_rc.left=0; - s_rc.top=0; - s_rc.right=width; - s_rc.bottom=height; - if (border<0) - { - trc.left-=border; - s_rc.left-=border; - } - else - { - trc.right-=border; - s_rc.right-=border; - } - if (trc.left<0) {s_rc.left-=trc.left*0.7;trc.left=0;} - if (trc.right>=640) {s_rc.right-=(trc.right-640)*0.7;trc.right=640;} - CheckResult(DxDevice->StretchRect(src,&s_rc,DxBackBuffer,&trc,D3DTEXF_NONE)); - } - -void DxTurn(void *handle, char right, int ypos,int border, float phase, void *lodka) - { - right=!right; - if (phase>1.0) phase=1.0f; - if (phase<0.0) phase=0.0f; - UnLockBuffers(); - IDirect3DSurface9 **ihandle=(IDirect3DSurface9 **)handle; - IDirect3DSurface9 *sleft=ihandle[right?0:1]; - IDirect3DSurface9 *sright=ihandle[right?1:0]; - int width=640-border*2; - int xpos=(int)border+width*phase; - if (right) xpos=640-xpos; - CopySurfaceAtPos(sleft,640,360,xpos-640+border,ypos,border); - CopySurfaceAtPos(sright,640,360,xpos-border,ypos,-border); - - - RECT rc={0,ypos,640,ypos+360}; - - GlobalPresent(&rc); - LockBuffers(); - } - - -void DxDoneTurn(void *handle) - { - IDirect3DSurface9 **ihandle=(IDirect3DSurface9 **)handle; - ihandle[0]->Release(); - ihandle[1]->Release(); - delete [] ihandle; - } - -void DxDialogs(char enable) - { - dialogs=enable!=0; - } - -} -HWND GetGameWindow() - {return hMainWnd;} - -void DxLockBuffers(BOOL lock) -{ - if (lock) LockBuffers(); - else UnLockBuffers(); -} - -void StripBlt(void *data, unsigned int startline, uint32_t width) -{ - unsigned short *start=startline*scr_linelen2+GetScreenAdr(); - while (width--) - { - memcpy(start,data,640*2); - data=(void *)((char *)data+scr_linelen); - start=start+scr_linelen2; - } -} - -void DxSetInitResolution(int x, int y) -{ - initSizeX = x; - initSizeY = y; - -} - -int DxGetResX() {return initSizeX;} -int DxGetResY() {return initSizeY;} diff --git a/Windows/BGraph2Dx.h b/Windows/BGraph2Dx.h deleted file mode 100644 index eedf6dd..0000000 --- a/Windows/BGraph2Dx.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef __BGRAPH_DX_WRAPPER_ -#define __BGRAPH_DX_WRAPPER_ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int32_t scr_linelen; -extern int32_t scr_linelen2; -extern int32_t dx_linelen; - - -//inicializuje a otevira rezim 640x480x16b v DX - otevre okno, pripravi vse pro beh hry -//Vraci 1 pri uspechu -char DXInit64(char inwindow,int zoom,int monitor, int refresh); - -//uzavre rezim grafiky -void DXCloseMode(); - -//void DXCopyRects32(unsigned short x,unsigned short y,unsigned short xs,unsigned short ys); -void DXCopyRects64(unsigned short x,unsigned short y,unsigned short xs,unsigned short ys); -void DXCopyRects64zoom2(unsigned short x,unsigned short y,unsigned short xs,unsigned short ys); - -void *DxPrepareWalk(int ypos); -void DxZoomWalk(void *handle, int ypos, int *points,float phase, void *lodka); -void DxDoneWalk(void *handle); - -void *DxPrepareTurn(int ypos); -void DxTurn(void *handle, char right, int ypos,int border, float phase, void *lodka); -void DxDoneTurn(void *handle); -void DxTurnLeftRight(char right, float phase, int border, int ypos, int *last); - - -void DxDialogs(char enable); - -void setvesa_displaystart(int x,int y); - -extern int32_t scr_linelen; -extern int32_t scr_linelen2; - -void DxSetInitResolution(int x, int y); -int DxGetResX(); -int DxGetResY(); - -void DXMouseTransform(unsigned short *x, unsigned short *y); - -HWND GetGameWindow(); -void DxLockBuffers(BOOL lock); - -void StripBlt(void *data, unsigned int startline, uint32_t width); - - -#ifdef __cplusplus - } -#endif - - -#endif \ No newline at end of file diff --git a/Windows/BOLDCZ.FON b/Windows/BOLDCZ.FON deleted file mode 100644 index be5e16c..0000000 Binary files a/Windows/BOLDCZ.FON and /dev/null differ diff --git a/Windows/FCS_Tasker.c b/Windows/FCS_Tasker.c deleted file mode 100644 index fb163f4..0000000 --- a/Windows/FCS_Tasker.c +++ /dev/null @@ -1,209 +0,0 @@ -#include -#include -#include "types.h" -#include "event.h" -#include -#include "FCS_Tasker.h" -#include - - -#define MAX_FIBERS 32 - -typedef struct _fcs_taskerstruct - { - void *fiberHandle; - int wait_event; - char waiting:1; - char exitFiber:1; - char usedSlot:1; - } FCS_TASKERSTRUCT; - -#define THREADDECL __declspec (thread) - -static THREADDECL FCS_TASKERSTRUCT fiberList[MAX_FIBERS]; -static THREADDECL int fiberNextSlot=-1; -static THREADDECL void *mainFiber=NULL; -static THREADDECL void *cleaningFiber=NULL; -static THREADDECL int currentFiber=-1; -static THREADDECL int lastTask=-1; -static THREADDECL void *switchData=NULL; -static THREADDECL int task_count=0; - -static void CALLBACK CleaningFiber(void *lpParameter) - { - do - { - SEND_LOG("(TASKER) Cleaning task %d",currentFiber,0); - assert(currentFiber>=0); - DeleteFiber(fiberList[currentFiber].fiberHandle); - fiberList[currentFiber].usedSlot=0; - currentFiber=-1; - switchData=NULL; - task_count--; - SwitchToFiber(mainFiber); - } - while (1); - } - -static void InitFibers() - { - mainFiber=ConvertThreadToFiber(NULL); - cleaningFiber=CreateFiber(0,CleaningFiber,NULL); - currentFiber=-1; - fiberNextSlot=0; - memset(fiberList,0,sizeof(fiberList)); - SEND_LOG("(TASKER) Fibers inicialized",0,0); - } - -static int GetFreeFiberSlot() - { - int save=fiberNextSlot; - do - { - if (fiberNextSlot<0) fiberNextSlot+=MAX_FIBERS; - if (fiberList[fiberNextSlot].usedSlot==0) return fiberNextSlot--; - fiberNextSlot--; - } - while (fiberNextSlot!=save); - STOP(); - return 0; - } - -static void CALLBACK RunUserFiber(void *params) - { - va_list p=(va_list)switchData; - TaskerFunctionName fcname=(TaskerFunctionName)params; - fcname(p); - SwitchToFiber(cleaningFiber); - } - -int add_task(int stack,TaskerFunctionName fcname,...) - { - if (mainFiber==NULL) InitFibers(); - { - int fib=GetFreeFiberSlot(); - va_list args; - - fiberList[fib].usedSlot=1; - fiberList[fib].waiting=0; - fiberList[fib].exitFiber=0; - fiberList[fib].fiberHandle=CreateFiber(0,RunUserFiber,fcname); - va_start(args,fcname); - switchData=args; - currentFiber=fib; - task_count++; - SEND_LOG("(TASKER) Adding task %d",fib,0); - SwitchToFiber(fiberList[fib].fiberHandle); - return fib; - } - } - -void term_task(int id_num) - { - fiberList[id_num].exitFiber=1; - } - -char is_running(int id_num) - { - return fiberList[id_num].usedSlot; - } - -void suspend_task(int id_num,int msg) - { - fiberList[id_num].waiting=1; - fiberList[id_num].wait_event=msg; - } - -void shut_down_task(int id_num) - { - if (fiberList[id_num].usedSlot) - { - SEND_LOG("(TASKER) Killing task %d",id_num,0); - DeleteFiber(fiberList[id_num].fiberHandle); - task_count--; - fiberList[id_num].usedSlot=0; - } - } - -static void *FCSTaskSleep(void *data,int fiber) - { - if (mainFiber==NULL) return data; - if (fiber==-1) - { - currentFiber=fiber; - if (GetCurrentFiber()==mainFiber) return data; - switchData=data; - SwitchToFiber(mainFiber); - return switchData; - } - if (fiberList[fiber].usedSlot) - { - currentFiber=fiber; - if (GetCurrentFiber()==fiberList[fiber].fiberHandle) return data; - switchData=data; - SwitchToFiber(fiberList[fiber].fiberHandle); - return switchData; - } - return data; - } - - -void unsuspend_task(EVENT_MSG *msg) - { - int id_num; - for (id_num=0;id_nummsg) - { - FCSTaskSleep(msg,id_num); - } - } - -void *task_sleep(void *data) - { - int i,p=lastTask+1; - if (currentFiber!=-1) return FCSTaskSleep(data,-1); - for (i=0;i=MAX_FIBERS) p-=MAX_FIBERS; - if (fiberList[p].usedSlot && !fiberList[p].waiting) - { - lastTask=p; - return FCSTaskSleep(data,p); - } - } - return data; - } - -void *task_wait_event(int32_t event_number) - { - void *p; - suspend_task(currentFiber,event_number); - p=task_sleep((void *)event_number); - fiberList[currentFiber].waiting=0; - if (p==NULL) return NULL; - return ((EVENT_MSG *)p)->data; - } - -int q_any_task() - { - return task_count; - } - -char task_quitmsg() - { - return task_quitmsg_by_id(currentFiber); - } - -char task_quitmsg_by_id(int id) - { - return fiberList[id].exitFiber; - } - -char q_is_mastertask() - { - return currentFiber==-1; - } - -int q_current_task() - { - return currentFiber; - } diff --git a/Windows/FCS_Tasker.h b/Windows/FCS_Tasker.h deleted file mode 100644 index a6e15ca..0000000 --- a/Windows/FCS_Tasker.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _FCS_TASKER_H_ -#define _FCS_TASKER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef void (*TaskerFunctionName)(va_list); - -void tasker(EVENT_MSG *msg,void **data); -int create_task(); -int add_task(int stack,TaskerFunctionName fcname,...); -void term_task(int id_num); -char is_running(int id_num); -void suspend_task(int id_num,int msg); -void shut_down_task(int id_num); -void unsuspend_task(EVENT_MSG *msg); -void *task_sleep(void *data); -void *task_wait_event(int32_t event_number); -int q_any_task(); -char task_quitmsg(); -char task_quitmsg_by_id(int id); -char q_is_mastertask(); -int q_current_task(); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Windows/Music.cpp b/Windows/Music.cpp deleted file mode 100644 index b144364..0000000 --- a/Windows/Music.cpp +++ /dev/null @@ -1,507 +0,0 @@ -#include "skeldal_win.h" -#include -#include -#include -#define DWORD_PTR DWORD * -#include -#include "types.h" -#include "zvuk.h" -#include -#include -extern "C" { -#include - } -#include "Music.h" - - -#define BUFFER_SIZE (512*1024) -#define LOCK_GRANUALITY 16384 - -MusicPlayer::MusicPlayer() -{ - _ds8Buffer=0; - _volume=255; - InitializeCriticalSection(&_lock); -} - -MusicPlayer::~MusicPlayer() -{ - Done(); - DeleteCriticalSection(&_lock); -} - -HRESULT MusicPlayer::InitBuffer(IDirectSound8 *ds8, int *linvoltable) -{ - HRESULT hres; - - WAVEFORMATEX wfex; - wfex.cbSize=sizeof(wfex); - wfex.wBitsPerSample=16; - wfex.nBlockAlign=4; - wfex.nSamplesPerSec=44100; - wfex.nAvgBytesPerSec=wfex.nSamplesPerSec*wfex.nBlockAlign; - wfex.wFormatTag=WAVE_FORMAT_PCM; - wfex.nChannels=2; - - DSBUFFERDESC desc; - desc.dwSize=sizeof(desc); - desc.dwBufferBytes=BUFFER_SIZE; - desc.dwReserved=0; - desc.dwFlags=DSBCAPS_CTRLVOLUME ; - desc.lpwfxFormat=&wfex; - - IDirectSoundBuffer *dsbf; - - hres=ds8->CreateSoundBuffer(&desc,&dsbf,NULL); - hres=dsbf->QueryInterface(IID_IDirectSoundBuffer8,(void **)&_ds8Buffer); - dsbf->Release(); - - _linvoltable=linvoltable; - return hres; -} - -HRESULT MusicPlayer::Play() -{ - _lastWritePos=0; - DWORD size; - void *ptr; - - _ds8Buffer->Lock(0,0,&ptr,&size,NULL,NULL,DSBLOCK_ENTIREBUFFER); - memset(ptr,0,size); - _ds8Buffer->Unlock(ptr,size,NULL,NULL); - _ds8Buffer->SetVolume(_linvoltable[_volume]); - HRESULT res=_ds8Buffer->Play(0,0,DSBPLAY_LOOPING); - _crossfadebytes=0; - _minorpos=0; - return res; -} - -class AutoCloseCriticalSection -{ - LPCRITICAL_SECTION lcrit; -public: - AutoCloseCriticalSection(LPCRITICAL_SECTION l):lcrit(l) - { - EnterCriticalSection(lcrit); - } - ~AutoCloseCriticalSection() - { - LeaveCriticalSection(lcrit); - } -}; - -int MusicPlayer::Open(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms) -{ - AutoCloseCriticalSection lsect(&_lock); - if (numchannels<1 || numchannels>2) return -1; - if (bitspersamp!=8 && bitspersamp!=16) return -1; - _stereo=numchannels==2; - _bit16=bitspersamp==16; - _speed=samplerate*1024/44100; - if (_speed<128) return -1; - _opened=true; - return 0; -} - -HRESULT MusicPlayer::Done() -{ - if (_ds8Buffer) _ds8Buffer->Release(); - _ds8Buffer=0; - return 0; - -} - -DWORD MusicPlayer::GetSafeXFadePos() -{ - DWORD curPos; - _ds8Buffer->GetCurrentPosition(0,&curPos); - int curpos=curPos; - if (curpos>(int)_lastWritePos) curpos-=BUFFER_SIZE; - curpos+=BUFFER_SIZE/4; - if (curpos>(int)_lastWritePos) curpos=_lastWritePos; - if (curpos<0) curpos+=BUFFER_SIZE; - if (curpos>=BUFFER_SIZE) curpos-=BUFFER_SIZE; - return curpos; -} - -static const float Inv2=0.5; -static const float Snapper=3<<22; - -static inline short toInt( float fval ) -{ - fval += Snapper; - return (short)( (*(int *)&fval)&0x007fffff ) - 0x00400000; -} - -void MusicPlayer::Close() -{ - if (TryEnterCriticalSection(&_lock)==FALSE) - { - DWORD status; - _ds8Buffer->GetStatus(&status); - _ds8Buffer->Play(0,0,DSBPLAY_LOOPING); - EnterCriticalSection(&_lock); - if ((status & DSBSTATUS_PLAYING)==0) - _ds8Buffer->Stop(); - } - - if (_crossfadebytes==0) - { - DWORD xfadepos=GetSafeXFadePos(); - DWORD xfadesz=xfadepos>_lastWritePos?(_lastWritePos+BUFFER_SIZE-xfadepos):(_lastWritePos-xfadepos); - void *ptr[2]; - DWORD sz[2]; - float ffadesz=(float)xfadesz*0.5f; - float ffadecnt=0; - if (xfadesz && _ds8Buffer->Lock(xfadepos,xfadesz,ptr+0,sz+0,ptr+1,sz+1,0)==0) - { - for (int i=0;i<2;i++) if (ptr[i]) - { - for (DWORD j=0;jffadesz) ffadecnt=ffadesz; - } - } - _ds8Buffer->Unlock(ptr[0],sz[0],ptr[1],sz[1]); - } - _crossfadebytes=xfadesz; - _lastWritePos=xfadepos; - } - _opened=false; - LeaveCriticalSection(&_lock); -} - -int MusicPlayer::Write(const char *buf, int len) -{ - EnterCriticalSection(&_lock); - if (!_opened) - { - LeaveCriticalSection(&_lock); - return 1; - } - DWORD step=(_stereo?2:1) * (_bit16?2:1); - void *lockptr[2]={0,0}; - DWORD locksz[2]={0,0}; - void *wrtptr=0; - DWORD remainspace=0; - int stage=0; - - while (len>0) - { - short sample[2]; - - if (_bit16) - if (_stereo) - { - sample[0]=*((short *)buf); - sample[1]=*((short *)buf+1); - } - else - { - sample[0]=*((short *)buf); - sample[1]=*((short *)buf); - } - else - if (_stereo) - { - sample[0]=(*buf)*256; - sample[1]=(*(buf+1))*256; - } - else - { - sample[0]=(*buf)*256; - sample[1]=(*buf)*256; - } - while (remainspace<4) - { - if (stage<1) - { - stage++; - remainspace=locksz[stage]; - wrtptr=lockptr[stage]; - } - else - { - if (lockptr[0]) - { - _ds8Buffer->Unlock(lockptr[0],locksz[0],lockptr[1],locksz[1]); - _lastWritePos+=LOCK_GRANUALITY; - while (_lastWritePos>=BUFFER_SIZE) _lastWritePos-=BUFFER_SIZE; - } - DWORD playCursor; - _ds8Buffer->GetCurrentPosition(&playCursor,0); - if (playCursor<_lastWritePos) playCursor+=BUFFER_SIZE; - while (playCursor-_lastWritePosGetCurrentPosition(&playCursor,0); - if (playCursor<_lastWritePos) playCursor+=BUFFER_SIZE; - } - HRESULT res=_ds8Buffer->Lock(_lastWritePos,LOCK_GRANUALITY,lockptr+0,locksz+0,lockptr+1,locksz+1,0); - assert(res==0); - stage=0; - remainspace=locksz[stage]; - wrtptr=lockptr[stage]; - } - } - if (_crossfadebytes) - { - short *data=(short *)wrtptr; - int32_t a=data[0]+sample[0]; - if (a<-32767) a=-32767; - if (a>32767) a=32767; - data[0]=(short)a; - a=data[1]+sample[1]; - if (a<-32767) a=-32767; - if (a>32767) a=32767; - data[1]=(short)a; - if (_crossfadebytes<4) _crossfadebytes=0;else _crossfadebytes-=4; - } - else - wrtptr = sample; - wrtptr=(void *)((char *)wrtptr+4); - remainspace-=4; - _minorpos+=_speed; - while (_minorpos>=1024) - { - buf+=step; - len-=step; - _minorpos-=1024; - } - } - if (stage==0) {locksz[1]=0;locksz[0]-=remainspace;} - else {locksz[1]-=remainspace;} - _ds8Buffer->Unlock(lockptr[0],locksz[0],lockptr[1],locksz[1]); - _lastWritePos+=locksz[0]+locksz[1]; - while (_lastWritePos>=BUFFER_SIZE) _lastWritePos-=BUFFER_SIZE; - LeaveCriticalSection(&_lock); - return 0; -} - -int MusicPlayer::CanWrite() -{ - return LOCK_GRANUALITY; -} -int MusicPlayer::IsPlaying() -{ - return 0; -} - -int MusicPlayer::Pause(int pause) -{ - int lastState=_paused?1:0; - if (pause) - {if (!_paused) {_ds8Buffer->Stop();_paused=true;}} - else - {if (_paused) {_ds8Buffer->Play(0,0,DSBPLAY_LOOPING);_paused=false;}} - return lastState; -} - - -void MusicPlayer::SetVolume(int volume) -{ - if (volume<0) return; - _ds8Buffer->SetVolume(_linvoltable[volume]); - if (volume==0) - Pause(1); - else - Pause(0); -} - -MusDecoder::MusDecoder() -{ - _playing=false; - _thread=0; - _stop=0; -} - -MusDecoder::~MusDecoder() -{ - Stop(); -} - -void MusDecoder::AttachOutput(IWAOutput *o) -{ - if (o) o->AddRef(); - if (_output) _output->Release(); - _output=o; -} - -bool MusDecoder::Play(const char *filename) -{ - DWORD res=0; - if (filename[0]=='?') - { - if (_output->Open(44100,1,8,-1,-1)<0) - { - return false; - } - _stop=false; - _playing=true; - _thread=CreateThread(0,0,MusDecoder::StartSilentWritter,this,0,&res); - return true; - } - _file=CreateFile(filename,GENERIC_READ,0,0,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0); - if (_file==0) return false; - ReadFile(_file,&_header,sizeof(_header),&res,0); - if (res!=sizeof(_header)) {CloseHandle(_file);return false;} - if (_output->Open(_header.freq,_header.channels,16,-1,-1)<0) - { - CloseHandle(_file);return false; - } - _stop=false; - _playing=true; - _thread=CreateThread(0,0,MusDecoder::StartMusDecoder,this,0,&res); - return true; -} - -void MusDecoder::Stop() -{ - if (_thread) - { - _stop=true; - _output->Pause(0); - WaitForSingleObject(_thread,INFINITE); - CloseHandle(_thread); - CloseHandle(_file); - _output->Close(); - _file=0; - _thread=0; - } -} - -DWORD WINAPI MusDecoder::StartMusDecoder(LPVOID data) -{ - MusDecoder *self=reinterpret_cast(data); - return self->MusDecodingThread(); -} - - - -UINT MusDecoder::MusDecodingThread() -{ - int32_t blocksRemain=_header.blocks; - char *packbuf=0; - short *unpackbuf=0; - int32_t packbufsz=0; - int32_t unpackbufsz=0; - for (int i=0;i=_header.channels) channel=0; - unpackbuf[i]=val; - } - _output->Write(reinterpret_cast(unpackbuf),unpackedSize); - } - _playing=false; - return 0; -} - -DWORD WINAPI MusDecoder::StartSilentWritter(LPVOID data) -{ - MusDecoder *self=reinterpret_cast(data); - return self->SilentWritterThread(); -} - -UINT MusDecoder::SilentWritterThread() -{ - char empty[1024]; - memset(empty,0,sizeof(empty)); - for (int i=0;i<1024;i++) - { - if (_stop) break; - _output->Write(empty,1024); - } - _playing=false; - return 0; - -} - -WinAmpDecoder::WinAmpDecoder() -{ - _currPlugin=0; -} - -WinAmpDecoder::~WinAmpDecoder() -{ - Stop(); -} - -void WinAmpDecoder::AttachOutput(IWAOutput *o) -{ - if (o) o->AddRef(); - if (_output) _output->Release(); - _output=o; -} - -bool WinAmpDecoder::Play(const char *filename) -{ - Stop(); - _currPlugin=SelectBestPlugin(filename); - if (_currPlugin==0) return false; - _currPlugin->AttachOutput(_output); - if (_currPlugin->Play(filename)!=_currPlugin->errOk) - { - _currPlugin=0; - return false; - } - int playtm=_currPlugin->GetOutputTime(); - int nexttm=playtm; - int c=0; - MusicPlayer *q=static_cast(_output); - while (!q->IsOpenned() && playtm==nexttm && c<2000) {Sleep(1);c++;nexttm=_currPlugin->GetOutputTime();} - _nooutput=!q->IsOpenned(); - return true; -} - -void WinAmpDecoder::Stop() -{ - if (_currPlugin==0) return; - _currPlugin->Stop(); - _currPlugin->AttachOutput(0); - _currPlugin=0; -} - -bool WinAmpDecoder::IsPlaying() -{ - if (_currPlugin==0) return false; - return !_currPlugin->IsFinished(); -} - -void WinAmpDecoder::SetVolume(int volume, int main) -{ - _currPlugin->SetVolume(volume); -} diff --git a/Windows/Music.h b/Windows/Music.h deleted file mode 100644 index 6b84d09..0000000 --- a/Windows/Music.h +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef __SKELDAL_MUSIC_ -#define __SKELDAL_MUSIC_ - -#include "WAPlayer.h" - -#define DWORD_PTR DWORD * -#include - - -class MusicPlayer: public IWAOutput -{ - DWORD _speed; //speed relative to sampling frequence; - bool _stereo; //true, if stereo - bool _bit16; //true, if 16 bits - bool _opened; - IDirectSoundBuffer8 *_ds8Buffer; - DWORD _lastWritePos; //last write pos; - DWORD _minorpos; - int *_linvoltable; - DWORD _crossfadebytes; - unsigned char _volume; - CRITICAL_SECTION _lock; - bool _paused; - - DWORD GetSafeXFadePos(); - -public: - MusicPlayer(); - ~MusicPlayer(); - - HRESULT InitBuffer(IDirectSound8 *ds8, int *linvoltable); - HRESULT Play(); - HRESULT Done(); - int Open(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms); - void Close(); - int Write(const char *buf, int len); - int CanWrite(); - int IsPlaying(); - void SetVolume(int volume); - void SetPan(int pan) {} - void Flush(int t) {} - int GetOutputTime() {return 1;} - int GetWrittenTime() {return 1;} - uint32_t AddRef() {return 1;} - uint32_t Release() {return 1;} - int Pause(int pause); - bool IsOpenned() {return _opened;} -}; - -#pragma pack (1) -struct MusFileHeader - { - short channels; - int32_t freq; - int32_t ssize; - int32_t blocks; - int32_t reserved1; - int32_t reserved2; - short ampltable[256]; - }; - #pragma pack() - - -class IDecoder -{ -public: - virtual void AttachOutput(IWAOutput *o)=0; - virtual bool Play(const char *filename)=0; - virtual bool IsPlaying()=0; - virtual void Stop()=0; - virtual void SetVolume(int volume, int main)=0; - virtual bool NotUsingOutput()=0; - virtual ~IDecoder() {} -}; - -class MusDecoder: public IDecoder -{ - MusFileHeader _header; - bool _playing; - HANDLE _thread; - IWAOutput *_output; - HANDLE _file; - bool _stop; - - - static DWORD WINAPI StartMusDecoder(LPVOID data); - static DWORD WINAPI StartSilentWritter(LPVOID data); - UINT MusDecodingThread(); - UINT SilentWritterThread(); -public: - MusDecoder(); - ~MusDecoder(); - - void AttachOutput(IWAOutput *o); - - bool Play(const char *filename); - void Stop(); - bool IsPlaying() {return _playing;} - void SetVolume(int volume, int main) {if (_output) _output->SetVolume(volume);} - bool NotUsingOutput() {return false;} -}; - -class WinAmpDecoder: public IDecoder, public WAPlayer -{ - IWAOutput *_output; - WAInputPlugin *_currPlugin; - bool _nooutput; -public: - WinAmpDecoder(); - ~WinAmpDecoder(); - - void AttachOutput(IWAOutput *o); - bool Play(const char *filename); - void Stop(); - bool IsPlaying(); - void SetVolume(int volume, int main); - bool NotUsingOutput() {return _nooutput;} -}; - - -#endif \ No newline at end of file diff --git a/Windows/Skeldal.rc b/Windows/Skeldal.rc deleted file mode 100644 index 3a2908c..0000000 --- a/Windows/Skeldal.rc +++ /dev/null @@ -1,499 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" -#include -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Czech resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CSY) -#ifdef _WIN32 -LANGUAGE LANG_CZECH, SUBLANG_DEFAULT -#pragma code_page(1250) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "#include \0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// SKELDAL_FONT -// - -IDR_BOLDCZ SKELDAL_FONT "..\\font\\BOLDCZ.FON" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_LADICIOKNO DIALOG 0, 0, 387, 221 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Ladicí okno" -FONT 8, "MS Sans Serif" -BEGIN - EDITTEXT IDC_OUTPUT,52,0,335,219,ES_MULTILINE | ES_AUTOVSCROLL | - ES_AUTOHSCROLL | WS_VSCROLL | WS_HSCROLL - PUSHBUTTON "&Nesmrtelnost",IDC_IMMORTAL,0,0,50,12 - PUSHBUTTON "Ne&tečnost",IDC_NETECNOST,0,13,50,12 - PUSHBUTTON "Jít na &sektor",IDC_GOTO,0,26,50,12 - PUSHBUTTON "Jiná &mapa",IDC_LOADMAP,0,39,50,12 - PUSHBUTTON "&Předmět",IDC_LOADITEM,0,52,50,12 - PUSHBUTTON "&Dej Peníze",IDC_TAKEMONEY,0,65,50,12 - PUSHBUTTON "Post&up",IDC_ADVENCE,0,78,50,12 - PUSHBUTTON "&Bonus zbraní",IDC_WEAPONSKILL,0,91,50,12 - PUSHBUTTON "Oži&vit nestv.",IDC_RAISEMONSTER,0,104,50,12 - PUSHBUTTON "Ož&ivit postavu",IDC_RAISEDEATH,0,117,50,12 - PUSHBUTTON "Léčit postavu",IDC_HEAL,0,130,50,12 - PUSHBUTTON "&Otevřít dveře",IDC_OPENDOOR,0,143,50,12 - PUSHBUTTON "Čistit m&apu",IDC_CLEARMAP,0,156,50,12 - PUSHBUTTON "&Zruš magii",IDC_UNAFFECT,0,169,50,12 - PUSHBUTTON "Načti n&estv.",IDC_RELOADMOBILES,0,182,50,12 - PUSHBUTTON "Pur&ge",IDC_PURGE,0,195,50,12 - PUSHBUTTON "&Refresh",IDC_REFRESH,0,208,50,12 -END - -IDD_INPUTWINDOW DIALOG 0, 0, 264, 30 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Vztupní okno" -FONT 7, "Small Fonts" -BEGIN - LTEXT "Prompt",IDC_PROMPT,0,0,211,15 - EDITTEXT IDC_VALUE,0,16,213,14,ES_AUTOHSCROLL - PUSHBUTTON "OK",IDOK,214,0,50,14 - PUSHBUTTON "Storno",IDCANCEL,214,16,50,14 -END - -IDD_CFGTABDIALOG DIALOG 0, 0, 243, 255 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | - WS_SYSMENU -CAPTION "Nastavení" -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "Tab1",IDC_TAB,"SysTabControl32",WS_TABSTOP,7,7,229,224 - LTEXT "Tomuto zobrazení\nodpovídá žádná položka", - IDC_CLIENTDESK,14,26,213,195 - DEFPUSHBUTTON "OK",IDOK,122,234,50,14 - PUSHBUTTON "Cancel",IDCANCEL,179,234,50,14 -END - -IDD_CFGGENERAL DIALOGEX 0, 0, 200, 190 -STYLE DS_SETFONT | DS_CONTROL | WS_CHILD -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - CONTROL "Spouštět hru v okně",IDC_WINDOWED,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,25,13,80,10 - CONTROL "640x480",IDC_ZOOM1,"Button",BS_AUTORADIOBUTTON | - WS_GROUP | WS_TABSTOP,41,25,43,10 - CONTROL "960x720",IDC_ZOOM2,"Button",BS_AUTORADIOBUTTON,41,36,43, - 10 - CONTROL "1280x960",IDC_ZOOM3,"Button",BS_AUTORADIOBUTTON,41,47, - 47,10 - CONTROL "Výchozí monitor",IDC_MON1,"Button",BS_AUTORADIOBUTTON | - WS_GROUP | WS_TABSTOP,119,25,66,10 - CONTROL "Druhý monitor",IDC_MON2,"Button",BS_AUTORADIOBUTTON,119, - 36,59,10 - CONTROL "Třetí monitor",IDC_MON3,"Button",BS_AUTORADIOBUTTON,119, - 47,56,10 - CONTROL "Vždy načíst celou úroveň do paměti",IDC_PRELOAD,"Button", - BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,26,62,129,10 - CONTROL "Povolit automatické ukládání na poslední pozici", - IDC_AUTOSAVE,"Button",BS_AUTOCHECKBOX | WS_GROUP | - WS_TABSTOP,25,74,166,10 - LTEXT "Rychlost hry:",IDC_STATIC,21,102,42,8 - CTEXT "??",IDC_GAMESPEEDINFO,67,102,40,8 - CONTROL "Slider1",IDC_GAMESPEED,"msctls_trackbar32", - TBS_AUTOTICKS | WS_TABSTOP,20,115,159,18 - LTEXT "Pomalu",IDC_STATIC,18,133,24,8 - LTEXT "Rychle",IDC_STATIC,162,133,23,8 - LTEXT "Urychlit bitvy:",IDC_STATIC,20,146,43,18,SS_CENTERIMAGE - CONTROL "Slider1",IDC_BATTLEACC,"msctls_trackbar32", - TBS_AUTOTICKS | WS_TABSTOP,70,146,109,18 - PUSHBUTTON "Výchozí",IDC_GAMESPEEDDEFAULT,143,168,50,14 -END - -IDD_CFGSOUND DIALOGEX 0, 0, 214, 195 -STYLE DS_SETFONT | DS_CONTROL | WS_CHILD -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - LTEXT "&Mixovací frekvence:",IDC_STATIC,20,15,66,12, - SS_CENTERIMAGE - EDITTEXT IDC_MIXFREQ,88,15,51,12,ES_CENTER | ES_AUTOHSCROLL | - ES_NUMBER - LTEXT "Hz",IDC_STATIC,140,15,10,12,SS_CENTERIMAGE - GROUPBOX "",IDC_STATIC,7,30,200,72 - LTEXT "Pozor: Nastavení hlasitostí se ukládá do herních pozic. Nastavení může být změněno, při načtení hry z pozice. Změnu nastavení pro pozici proveďte ve hře:", - IDC_STATIC,19,38,173,27 - LTEXT "&Hudba:",IDC_STATIC,19,67,29,15,SS_CENTERIMAGE - CONTROL "Slider1",IDC_SNDMUSIC,"msctls_trackbar32",TBS_BOTH | - TBS_NOTICKS | WS_TABSTOP,55,67,130,15 - LTEXT "&Skřeky",IDC_STATIC,19,83,29,15,SS_CENTERIMAGE - CONTROL "Slider1",IDC_SNDFX,"msctls_trackbar32",TBS_BOTH | - TBS_NOTICKS | WS_TABSTOP,55,83,130,15 - LTEXT "Pluginy",IDC_STATIC,7,111,24,12,SS_CENTERIMAGE - PUSHBUTTON "Cesta na pluginy",IDC_CESTANAPLUGINY,36,111,171,12, - BS_FLAT - LISTBOX IDC_PLUGLIST,7,130,200,45,LBS_SORT | - LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Vlastnosti",IDC_PLUGVLASTNOSTI,168,177,39,11 -/* PUSHBUTTON "Nápověda",IDC_PLUGINYNAPOVEDA,168,177,39,11*/ - LTEXT "Pozor: Vyžaduje pluginy z WinAmp 2.95 !!!\r\nLze získat na http://skeldal.jinak.cz", - IDC_STATIC,7,176,158,16 -END - -IDD_CFGVIDEO DIALOG 0, 0, 152, 76 -STYLE DS_SETFONT | DS_CONTROL | WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "Nepřehrávej intro při startu",IDC_SKIPINTRO,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,23,25,100,10 - CONTROL "Nezobrazuj video prokládaně",IDC_FULLRESVIDEO,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,23,44,108,10 -END - -IDD_CFGEXTRAS DIALOG 0, 0, 203, 198 -STYLE DS_SETFONT | DS_CONTROL | WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "Náhodný backfire (při kouzlení)",IDC_EXRANDOMBACKFIRES, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,115,10 - CONTROL "Recykluj nestvůry (zabité nestvůry se časem obnoví)", - IDC_EXRESPAWNMONSTERS,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,7,20,189,10 - CONTROL "Alternativni bojový systém",IDC_EXALTERNATEFIGHT,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,33,97,10 - CONTROL "Vracej do hry zničené nebo utopené předměty", - IDC_EXRECORVERITEMS,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,7,46,161,10 - CONTROL "Vloží předměty ze země do batohu pomocí CTRL", - IDC_EXBAGEXTENDED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, - 7,59,189,10 - CONTROL "Lepší výhody štítů při soubojích",IDC_EXSHIELDBLOCKING, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,72,116,10 - CONTROL "Rychlejší obchodování při použití CTRL",IDC_EXFASTTRADE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,85,142,10 - CONTROL "Zobrazuj minimapu i mimo boj",IDC_EXALWAYSMINIMAP, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,98,107,10 - CONTROL "Hromadný útěk z boje",IDC_EXGROUPFLEE,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,111,85,10 - CONTROL "Vždy otevři knihu při jejího změně obsahu", - IDC_EXAUTOOPENBOOK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, - 7,124,147,10 - CONTROL "Vždy zobraz sebranou runu",IDC_EXAUTOSHOWRUNE,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,137,101,10 - PUSHBUTTON "Nápověda",IDC_EXTRASHELP,129,177,67,14 - CONTROL "Malé nestvůry chodí také diagonálně",IDC_EXMOBDIAGONAL, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,150,133,10 -END - -IDD_CFGCHEATS DIALOG 0, 0, 169, 139 -STYLE DS_SETFONT | DS_CONTROL | WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "Vypni hladovění a žízeň",IDC_NOHUNGRY,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,43,22,91,10 - CONTROL "Povol ladící okno",IDC_DEBUGCONSOLE,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,43,43,71,10 - CTEXT "Ladící okno funguje jen u map, které nejsou zabezpečené heslem\n\nToto omezení lze zrušit zadáním univerzálního cheatovacího hesla", - IDC_STATIC,7,70,155,43 - EDITTEXT IDC_CHEATPASSWORD,7,118,155,14,ES_CENTER | ES_PASSWORD | - ES_AUTOHSCROLL | ES_NUMBER -END - -IDD_RTFVIEWER DIALOG 0, 0, 311, 313 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Brány Skeldalu " -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,254,292,50,14 - CONTROL "",IDC_RICHEDIT,"RichEdit20A",ES_MULTILINE | - ES_AUTOVSCROLL | ES_NOHIDESEL | ES_READONLY | WS_BORDER | - WS_VSCROLL | WS_TABSTOP,7,7,297,276 -END - -IDD_SELADV DIALOG 0, 0, 106, 149 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | - WS_SYSMENU -CAPTION "SKELDAL - Vyber dobrodružství" -FONT 10, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "START!",IDOK,3,120,47,14 - PUSHBUTTON "Storno",IDCANCEL,56,120,47,14 - LISTBOX IDC_LIST,3,69,100,49,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | - LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - CONTROL "Vytvořit zástupce na ploše",IDC_CREATELINK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,3,136,100,10 - CONTROL 130,IDC_STATIC,"Static",SS_BITMAP,3,3,100,60 -END - -IDD_LISTDIALOG DIALOGEX 0, 0, 208, 191 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Vyber" -FONT 8, "Courier", 400, 0, 0xEE -BEGIN - DEFPUSHBUTTON "OK",IDOK,7,170,194,14 - LISTBOX IDC_LIST,7,7,194,146,LBS_NOINTEGRALHEIGHT | - LBS_EXTENDEDSEL | WS_VSCROLL | WS_TABSTOP - LTEXT "Hodnota",IDC_STATIC,7,154,31,12,SS_CENTERIMAGE - EDITTEXT IDC_HODNOTA,41,154,160,12,ES_AUTOHSCROLL | WS_DISABLED -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_LADICIOKNO, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 380 - TOPMARGIN, 7 - BOTTOMMARGIN, 214 - END - - IDD_CFGTABDIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 236 - TOPMARGIN, 7 - BOTTOMMARGIN, 248 - END - - IDD_CFGGENERAL, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 193 - TOPMARGIN, 7 - BOTTOMMARGIN, 183 - END - - IDD_CFGSOUND, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 207 - TOPMARGIN, 7 - BOTTOMMARGIN, 188 - END - - IDD_CFGVIDEO, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 145 - TOPMARGIN, 7 - BOTTOMMARGIN, 69 - END - - IDD_CFGEXTRAS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 196 - TOPMARGIN, 7 - BOTTOMMARGIN, 191 - END - - IDD_CFGCHEATS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 162 - TOPMARGIN, 7 - BOTTOMMARGIN, 132 - END - - IDD_RTFVIEWER, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 304 - TOPMARGIN, 7 - BOTTOMMARGIN, 306 - END - - IDD_SELADV, DIALOG - BEGIN - LEFTMARGIN, 3 - RIGHTMARGIN, 103 - TOPMARGIN, 3 - BOTTOMMARGIN, 146 - END - - IDD_LISTDIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 201 - TOPMARGIN, 7 - BOTTOMMARGIN, 184 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_INITLOGO BITMAP "logo.bmp" -IDB_UVODNIPOZADI BITMAP "uvodni.bmp" -IDB_UVODNISELECT BITMAP "uvodni_sel.bmp" -IDB_SELADVDLG BITMAP "seladv_male.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_MAINICON ICON "icon.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// RTF -// - -IDR_EXTRAS RTF "extras.rtf" -IDR_WINAMPPLUGS RTF "plugins.rtf" - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -#include "..\game\version.h" - -VS_VERSION_INFO VERSIONINFO - VERSIONWINRES(FILEVERSION) - VERSIONWINRES(PRODUCTVERSION) - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040504b0" - BEGIN - VALUE "Comments", "Brány Skeldalu pro Windows" - VALUE "CompanyName", "Bredysoft" - VALUE "FileDescription", "Brány Skeldalu pro Windows" - VALUE "FileVersion", "1" - VALUE "InternalName", "Skeldal" - VALUE "LegalCopyright", "Copyright Bredysoft (C) 2005" - VALUE "LegalTrademarks", "Bredysoft" - VALUE "OriginalFilename", "Skeldal.exe" - VALUE "ProductName", " Skeldal" - VALUE "ProductVersion", "1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x405, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDS_CFGGENERAL "Obecné" - IDS_CFGSOUND "Zvuk" - IDS_CFGVIDEO "Video" - IDS_CFGEXTRAS "Rozšíření" - IDS_CFGCHEATS "Cheaty" - IDS_NICVYBRANO "Musíš něco vybrat v seznamu." -END - -STRINGTABLE -BEGIN - IDS_WINTITLE "Brány Skeldalu Windows verze" -END - -STRINGTABLE -BEGIN - IDS_CHEATWARNING1 "Upozornění: Zapínání cheatů může zkazit celkový dojem hry, a může způsobit, že hra nebude bez použití cheatů dohratelná. Chcete opravdu povolit cheaty?" - IDS_CHEATWARNING2 "Bylo vám oznámeno, že cheaty vám opravdu mohou při hraní zkazit zábavu. Berete-li toto na vědomí, stiskněte OK" - IDS_CHEATWARNING3 "Předchozí zprávu jste nevzal na vědomí. Přesto si prosím uvědomte, že zapínání cheatu vede ke snížení hratelnosti a tím pádem zábavy ze hraní. Rozhodně toto provádíte na vlastní riziko. Chcete přesto opakovat své stanovisko?" - IDS_CHEATWARNING4 "Zcela evidentně ignorujete varování, že cheaty mohou velice snížit zábavu z hraní. Budete v tom pokračovat i nadále?" - IDS_CHEATWARNING5 "Byl jste varován!" - IDS_RICHEDMISSING "Chybí propojovací knihovna RICHED20.DLL. Selhalo zobrazení okna" - IDS_MIXFREQINVALID "Mixovaci frekvence je mimo povoleny rozsah (8000-44100). Hodnota nebude uložena." - IDS_SCREENBPPWARNING "Plocha nepracuje v režimu 16bpp (65536 barev). Pro spuštění hry je nutné pracovní plochu přepnout do tohoto režimu. Přepnutí se provede automaticky a po ukončení hry se provede obnova nastavení plochy. Pokud by spuštění hry v okně způsobovalo obtíže, například by obrazovka zčernala, nebo by se obraz rozpadl, zkuste stisknou Alt+F4. Pak bude nutné před spuštěním hry v okně provést změnu nastavení plochy ručně, nebo hru spouštět na celou obrazovku." -END - -STRINGTABLE -BEGIN - IDS_INSTALLFILTER "Složky|vyberslozky.$$$slozky$$$||" - IDS_INSTALLTITLE "Vyber lokaci, kam chceš hru nainstalovat" - IDS_INSTALLPRENAME "Brány Skeldalu" - IDS_INSTALLCDFILE "INSTALL.INF" - IDS_INSTALLCDTITLE "Kde se nachází instalační CD?" - IDS_INSTALLCDFILTER "Instalační CD Brány Skeldalu|install.inf||" - IDS_CREATEDIR "Složka %s neexistuje. Chcete jí vytvořit?" - IDS_NELZEVYTVORITSLOZKU "Nelze vytvořit složku %s" - IDS_INSTALLEDGAME "Hra je nainstalovaná. Byl vytvořen zástupce na ploše. Nyní můžeš hru spustit." - IDS_INSTALLHDD "Přeješ si instalovat hru na pevný disk?\r\n\r\n* Odpověď ANO zkopíruje všechny potřebné soubory na pevný disk (asi 300MB)\r\n* Odpověď NE umožní hrát hru z CD (šetří místo na pevném disku)" - IDS_INSTALLCHYBISOUBOR "Chybi soubor(y): %s" - IDS_INSTALLTEXT1 "Instalace hry Brány Skeldalu krok 1.\r\n\r\nPřed započetím instalace vložte do jednotky originální CD hry a v okně, jenž se objeví po odklepnutí tlačítka OK,vyhledejte vyjmenovaný soubor, který se na CD nalézá." - IDS_INSTALLTEXT2 "Instalace hry Brány Skeldalu krok 2.\r\n\r\nNyní je třeba určit lokaci, kam se hra nainstaluje. V následujícím okně vyberte nejvhodnější umístění. Jméno složky můžete pozměnit v dolní části okna" - IDS_DEFAULTADV "Rovenland - Brány Skeldalu" -END - -#endif // Czech resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/Windows/StdAfx.cpp b/Windows/StdAfx.cpp deleted file mode 100644 index 64a584f..0000000 --- a/Windows/StdAfx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// WinAmpInterface.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/Windows/StdAfx.h b/Windows/StdAfx.h deleted file mode 100644 index 91aa19f..0000000 --- a/Windows/StdAfx.h +++ /dev/null @@ -1,26 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__C6160DCF_A5D8_42D0_8EAB_F594D354BFCB__INCLUDED_) -#define AFX_STDAFX_H__C6160DCF_A5D8_42D0_8EAB_F594D354BFCB__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -#include -#define WIN32_LEAN_AND_MEAN -#include -#include -#include - -// TODO: reference additional headers your program requires here - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__C6160DCF_A5D8_42D0_8EAB_F594D354BFCB__INCLUDED_) diff --git a/Windows/WAInputPlugin.cpp b/Windows/WAInputPlugin.cpp deleted file mode 100644 index fc12224..0000000 --- a/Windows/WAInputPlugin.cpp +++ /dev/null @@ -1,632 +0,0 @@ -// WAInputPlugin.cpp: implementation of the WAInputPlugin class. -// -////////////////////////////////////////////////////////////////////// - -#include "stdafx.h" -#include "WAInputPlugin.h" -#include -#include -#include "wa_ipc.h" - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -#define MAX_PLUGINS_AT_TIME 16 - -#define DECLARE_TEMPLATES(x) \ - x(0)\ - x(1)\ - x(2)\ - x(3)\ - x(4)\ - x(5)\ - x(6)\ - x(7)\ - x(8)\ - x(9)\ - x(10)\ - x(11)\ - x(12)\ - x(13)\ - x(14)\ - x(15)\ -/* x(16)\ - x(17)\ - x(18)\ - x(19)\ - x(20)\ - x(21)\ - x(22)\ - x(23)\ - x(24)\ - x(25)\ - x(26)\ - x(27)\ - x(28)\ - x(29)\ - x(30)\ - x(31)\*/ - - -#define JOIN(x,y) &x##y - -#define DECLARE_TEMPLATE_ARRAYS(x) \ -static void *p_##x[]={JOIN(x,_0),JOIN(x,_1),JOIN(x,_2),JOIN(x,_3),JOIN(x,_4),JOIN(x,_5),JOIN(x,_6),JOIN(x,_7),\ -JOIN(x,_8),JOIN(x,_9),JOIN(x,_10),JOIN(x,_11),JOIN(x,_12),JOIN(x,_13),JOIN(x,_14),JOIN(x,_15)/*,\ -JOIN(x,_16),JOIN(x,_17),JOIN(x,_18),JOIN(x,_19),JOIN(x,_20),JOIN(x,_21),JOIN(x,_22),JOIN(x,_23),\ -JOIN(x,_24),JOIN(x,_25),JOIN(x,_26),JOIN(x,_27),JOIN(x,_28),JOIN(x,_29),JOIN(x,_30),JOIN(x,_31)*/\ -}; - - -WAInputPlugin::WAInputPlugin() -{ -_inPlugin=0; -_mod=0; -_ioutput=0; -_finished=false; -_hNotify=0; -} - -WAInputPlugin::~WAInputPlugin() -{ -UnloadPlugin(); -} - -typedef In_Module * (*type_winampGetInModule2)(); - -static void empty_SAVSAInit(int maxlatency_in_ms, int srate) -{ - -} - -static void empty_SAVSADeInit() -{ - -} - -static void empty_SAAddPCMData(void *PCMData, int nch, int bps, int timestamp) -{ - -} - -static int empty_SAGetMode() -{ -return 1; -} - -static void empty_SAAdd(void *data, int timestamp, int csa) -{ - -} - -static void empty_VSAAddPCMData(void *PCMData, int nch, int bps, int timestamp) -{ - -} - -static void empty_VSAAdd(void *data, int timestamp) -{ - -} - -static int empty_VSAGetMode(int *specNch, int *waveNch) -{ - return 0; -} - -static void empty_VSASetInfo(int nch, int srate) -{ - -} - -static int empty_dsp_isactive() -{ - return 0; -} - -static int empty_dsp_dosamples(short int *samples, int numsamples, int bps, int nch, int srate) -{ - return numsamples; -} - -static void empty_SetInfo(int bitrate, int srate, int stereo, int synched) -{ - -} - -static void empty_About(HWND hWnd) -{ - -} - -static void empty_Config(HWND hWnd) -{ - -} - -static void empty_Init() -{ - -} -static void empty_Quit() -{ - -} - - -class RegistredPlugsArray -{ - WAInputPlugin *_arr[MAX_PLUGINS_AT_TIME]; -public: - RegistredPlugsArray() {memset(_arr,0,sizeof(_arr));} - int Register(WAInputPlugin *plug); - void Unregister(WAInputPlugin *plug); - WAInputPlugin *operator[] (int index) {return _arr[index];} -}; - -int RegistredPlugsArray::Register(WAInputPlugin *plug) -{ - for (int i=0;iGetAttachedOutputNoAddRef();\ - if (o) return o->Open(samplerate, numchannels, bitspersamp, bufferlenms, prebufferms);\ - return -1;\ -} - -#define m_Close(index)\ -static void output_Close_##index()\ -{\ - IWAOutput *o=GRegistredPlugsArray[index]->GetAttachedOutputNoAddRef();\ - if (o) o->Close();\ -} - -#define m_Write(index)\ -static int output_Write_##index(char *buff, int len)\ -{\ - IWAOutput *o=GRegistredPlugsArray[index]->GetAttachedOutputNoAddRef();\ - if (o) return o->Write(buff,len);\ - return 1;\ -} - -#define m_CanWrite(index)\ -static int output_CanWrite_##index()\ -{\ - IWAOutput *o=GRegistredPlugsArray[index]->GetAttachedOutputNoAddRef();\ - if (o) return o->CanWrite();\ - return 0;\ -} - -#define m_IsPlaying(index)\ -static int output_IsPlaying_##index()\ -{\ - IWAOutput *o=GRegistredPlugsArray[index]->GetAttachedOutputNoAddRef();\ - int p=o->IsPlaying();\ - return p;\ -} - -#define m_Pause(index)\ -static int output_Pause_##index(int pause)\ -{\ - IWAOutput *o=GRegistredPlugsArray[index]->GetAttachedOutputNoAddRef();\ - if (o) return o->Pause(pause);\ - return 0;\ -} - -#define m_SetVolume(index)\ -static void output_SetVolume_##index(int volume)\ -{\ - IWAOutput *o=GRegistredPlugsArray[index]->GetAttachedOutputNoAddRef();\ - if (o) o->SetVolume(volume);\ -} - -#define m_SetPan(index)\ -static void output_SetPan_##index(int pan)\ -{\ - IWAOutput *o=GRegistredPlugsArray[index]->GetAttachedOutputNoAddRef();\ - if (o) o->SetPan(pan);\ -} - -#define m_Flush(index)\ -static void output_Flush_##index(int t)\ -{\ - IWAOutput *o=GRegistredPlugsArray[index]->GetAttachedOutputNoAddRef();\ - if (o) o->Flush(t);\ -} - -#define m_GetOutputTime(index)\ -static int output_GetOutputTime_##index()\ -{\ - IWAOutput *o=GRegistredPlugsArray[index]->GetAttachedOutputNoAddRef();\ - if (o) return o->GetOutputTime();\ - return 0;\ -} - -#define m_GetWrittenTime(index)\ -static int output_GetWrittenTime_##index()\ -{\ - IWAOutput *o=GRegistredPlugsArray[index]->GetAttachedOutputNoAddRef();\ - if (o) return o->GetWrittenTime();\ - return 0;\ -} - -DECLARE_TEMPLATES(m_Open); -DECLARE_TEMPLATES(m_Close); -DECLARE_TEMPLATES(m_Write); -DECLARE_TEMPLATES(m_CanWrite); -DECLARE_TEMPLATES(m_IsPlaying); -DECLARE_TEMPLATES(m_Pause); -DECLARE_TEMPLATES(m_SetVolume); -DECLARE_TEMPLATES(m_SetPan); -DECLARE_TEMPLATES(m_Flush); -DECLARE_TEMPLATES(m_GetOutputTime); -DECLARE_TEMPLATES(m_GetWrittenTime); - -DECLARE_TEMPLATE_ARRAYS(output_Open); -DECLARE_TEMPLATE_ARRAYS(output_Close); -DECLARE_TEMPLATE_ARRAYS(output_Write); -DECLARE_TEMPLATE_ARRAYS(output_CanWrite); -DECLARE_TEMPLATE_ARRAYS(output_IsPlaying); -DECLARE_TEMPLATE_ARRAYS(output_Pause); -DECLARE_TEMPLATE_ARRAYS(output_SetVolume); -DECLARE_TEMPLATE_ARRAYS(output_SetPan); -DECLARE_TEMPLATE_ARRAYS(output_Flush); -DECLARE_TEMPLATE_ARRAYS(output_GetOutputTime); -DECLARE_TEMPLATE_ARRAYS(output_GetWrittenTime); - - -WAInputPlugin::PluginError WAInputPlugin::UIConfig(HWND parentHwnd) -{ - if (_inPlugin==0) return errNotLoaded; - _inPlugin->Config(parentHwnd); - return errOk; -} - -WAInputPlugin::PluginError WAInputPlugin::UIAbout(HWND parentHwnd) -{ - if (_inPlugin==0) return errNotLoaded; - _inPlugin->About(parentHwnd); - return errOk; -} - -WAInputPlugin::PluginError WAInputPlugin::UnloadPlugin() -{ - if (_inPlugin!=0) - { - __try - { - _inPlugin->Quit(); - } - __except(EXCEPTION_EXECUTE_HANDLER) - { - _mod=0; //prevent calling FreeLibrary.... plugin cannot be unloaded.... - } - _inPlugin=0; - } - if (_hNotify) - { - DestroyWindow(_hNotify); - _hNotify=0; - } - if (_mod) - { - FreeLibrary(_mod); - _mod=0; - } - return errOk; -} - -WAInputPlugin::PluginError WAInputPlugin::IsLoaded() -{ - if (_inPlugin==0) return errNotLoaded; - return errOk; -} - -const char *WAInputPlugin::GetDescription() -{ - if (_inPlugin==0) return 0; - return _inPlugin->description; -} - -WAInputPlugin::PluginError WAInputPlugin::GetFileInfo(const char *filename, char *title, int title_size, int *len_in_ms) -{ - if (_inPlugin==0) return errNotLoaded; - char *buff=new char[4096]; - DWORD r=GetTickCount(); - memcpy(buff+4092,&r,4); - _inPlugin->GetFileInfo(const_cast(filename),buff,len_in_ms); - if (memcmp(buff+4092,&r,4)==0) - { - return errPluginBufferOverrun; - } - int len=strlen(buff); - if (len>=title_size) - { - strncpy(title,buff,title_size); - return errBufferTooSmall; - } - else - { - strcpy(title,buff); - return errOk; - } -} - -WAInputPlugin::PluginError WAInputPlugin::UIFileInfo(const char *filename, HWND parentHwnd) -{ - if (_inPlugin==0) return errNotLoaded; - _inPlugin->InfoBox(const_cast(filename),parentHwnd); - return errOk; -} - -WAInputPlugin::PluginError WAInputPlugin::CanPlayFile(const char *filename) -{ - if (_inPlugin==0) return errNotLoaded; - if (_inPlugin->IsOurFile(const_cast(filename))) return errOk; - char *fext=_inPlugin->FileExtensions; - const char *bslash=strrchr(filename,'\\'); - if (bslash==0) bslash=filename; - const char *ext=strrchr(bslash,'.'); - if (ext==0) ext=strchr(bslash,0); - else ext++; - int extlen=strlen(ext); - while (*fext) - { - if (strnicmp(fext,ext,extlen)==0 && (fext[extlen]==';' || fext[extlen]==0)) - return errOk; - char *c=strchr(fext,';'); - if (c==0) - { - c=strchr(fext,0); - c++; - if (*c) c=strchr(c,0)+1; - fext=c; - } - else - fext=c+1; - } - return errUnknownFileFormat; -} - -WAInputPlugin::PluginError WAInputPlugin::AttachOutput(IWAOutput *o) -{ - if (_ioutput==o) return errOk; - if ((_ioutput!=0)!=(o!=0)) - { - if (o==0) GRegistredPlugsArray.Unregister(this); - else - { - int plugid=GRegistredPlugsArray.Register(this); - if (plugid==-1) return errTooManyPlugins; - - _output.About=empty_About; - _output.Config=empty_Config; - _output.Init=empty_Init; - _output.Quit=empty_Quit; - *(void **)&_output.CanWrite=p_output_CanWrite[plugid]; - *(void **)&_output.Close=p_output_Close[plugid]; - *(void **)&_output.Flush=p_output_Flush[plugid]; - *(void **)&_output.GetOutputTime=p_output_GetOutputTime[plugid]; - *(void **)&_output.GetWrittenTime=p_output_GetWrittenTime[plugid]; - *(void **)&_output.IsPlaying=p_output_IsPlaying[plugid]; - *(void **)&_output.Open=p_output_Open[plugid]; - *(void **)&_output.Pause=p_output_Pause[plugid]; - *(void **)&_output.SetPan=p_output_SetPan[plugid]; - *(void **)&_output.SetVolume=p_output_SetVolume[plugid]; - *(void **)&_output.Write=p_output_Write[plugid]; - _output.hDllInstance=GetModuleHandle(0); - _output.hMainWindow=0; - _output.description="Emulated output device"; - _output.version=0x100; - _output.id=999999999; - } - } - if (_ioutput!=0) _ioutput->Release(); - _ioutput=o; - if (o) o->AddRef(); - return errOk; -} - -#define WM_WA_MPEG_EOF WM_USER+2 -#define IPC_GET_API_SERVICE 3025 - - -static LRESULT NotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) - { - case WM_WA_MPEG_EOF: - { - WAInputPlugin *o=(WAInputPlugin *)GetWindowLong(hWnd,GWL_USERDATA); - if (o) o->MarkFinished(); - return 0; - } - case WM_USER: - { - switch (lParam) - { - case IPC_GETINIFILE: - { - return (LRESULT)("skeldalmusic.ini"); - } - case IPC_GETINIDIRECTORY: - { - return (LRESULT)(".\\"); - } - case IPC_GET_API_SERVICE: return 0; - case IPC_GET_RANDFUNC: return (LRESULT)&rand; - } - } - default: return DefWindowProc(hWnd,msg,wParam,lParam); - } -} - -static const char *RegisterWAPluginWnd() -{ - const char *name="WAPluginWnd"; - WNDCLASS cls; - if (GetClassInfo(GetModuleHandle(0),name,&cls)==FALSE) - { - memset(&cls,0,sizeof(cls)); - cls.lpszClassName=name; - cls.hInstance=GetModuleHandle(0); - cls.lpfnWndProc=(WNDPROC)NotifyWndProc; - RegisterClass(&cls); - } - return name; -} - -WAInputPlugin::PluginError WAInputPlugin::LoadPlugin(const char *name) -{ - UnloadPlugin(); - char *cwd=_getcwd(0,0); - char *setcwd=strcpy((char *)alloca(strlen(name)+1),name); - char *bs=const_cast(strrchr(setcwd,'\\')); - if (bs) - { - *bs=0; - bs=const_cast(strrchr(setcwd,'\\')); - if (bs) *bs=0; - } - _chdir(setcwd); - SetErrorMode(SEM_FAILCRITICALERRORS); - _mod=LoadLibrary(name); - _chdir(cwd); - free(cwd); - if (_mod==0) return errNotFound; - type_winampGetInModule2 winampGetInModule2=(type_winampGetInModule2)GetProcAddress(_mod,"winampGetInModule2"); - if (winampGetInModule2==0) return errNotValidPlugin; - _inPlugin=winampGetInModule2(); - if (_inPlugin==0) return errCantInit; - _hNotify=CreateWindow(RegisterWAPluginWnd(),"",0,0,0,0,0,0,0,GetModuleHandle(0),0); - SetWindowLong(_hNotify,GWL_USERDATA,(LONG)this); - _inPlugin->hMainWindow=_hNotify; - _inPlugin->hDllInstance=_mod; - _inPlugin->SAVSAInit=empty_SAVSAInit; - _inPlugin->SAVSADeInit=empty_SAVSADeInit; - _inPlugin->SAAddPCMData=empty_SAAddPCMData; - _inPlugin->SAGetMode=empty_SAGetMode; - _inPlugin->SAAdd=empty_SAAdd; - _inPlugin->VSAAddPCMData=empty_VSAAddPCMData; - _inPlugin->VSAGetMode=empty_VSAGetMode; - _inPlugin->VSAAdd=empty_VSAAdd; - _inPlugin->VSASetInfo=empty_VSASetInfo; - _inPlugin->dsp_isactive=empty_dsp_isactive; - _inPlugin->dsp_dosamples=empty_dsp_dosamples; - _inPlugin->SetInfo=empty_SetInfo; - _inPlugin->outMod=0; - __try - { - _inPlugin->Init(); - } - __except(EXCEPTION_EXECUTE_HANDLER) - { - __try - { - _inPlugin->Quit(); - } - __except(EXCEPTION_EXECUTE_HANDLER) - { - _mod=0; //Free library cannot be called, because plugin cannot be terminated... memory and resource leak - } - _inPlugin=0; - return errGPF; - } - _inPlugin->outMod=&_output; - return errOk; -} - -WAInputPlugin::PluginError WAInputPlugin::Play(const char *name) -{ - if (_inPlugin==0) return errNotLoaded; - _finished=false; - int i=_inPlugin->Play(const_cast(name)); - if (i==0) return errOk; - if (i==-1) return errFileNotFound; - return errCantPlay; -} - -WAInputPlugin::PluginError WAInputPlugin::Pause() -{ - if (_inPlugin==0) return errNotLoaded; - _inPlugin->Pause(); - return errOk; -} -WAInputPlugin::PluginError WAInputPlugin::UnPause() -{ - if (_inPlugin==0) return errNotLoaded; - _inPlugin->UnPause(); - return errOk; - -} - -WAInputPlugin::PluginError WAInputPlugin::IsPaused() -{ - if (_inPlugin==0) return errNotLoaded; - if (_inPlugin->IsPaused()) return errOk; - return errFalse; -} - -WAInputPlugin::PluginError WAInputPlugin::Stop() -{ - if (_inPlugin==0) return errNotLoaded; - _inPlugin->Pause(); - _inPlugin->UnPause(); - _inPlugin->Stop(); - return errOk; -} - -WAInputPlugin::PluginError WAInputPlugin::SetOutputTime(int t) -{ - if (_inPlugin==0) return errNotLoaded; - _inPlugin->SetOutputTime(t); - return errOk; -} - -WAInputPlugin::PluginError WAInputPlugin::SetVolume(int volume) -{ - if (_inPlugin==0) return errNotLoaded; - _inPlugin->SetVolume(volume); - return errOk; - -} -WAInputPlugin::PluginError WAInputPlugin::SetPan(int pan) -{ - if (_inPlugin==0) return errNotLoaded; - _inPlugin->SetPan(pan); - return errOk; -} - -WAInputPlugin::PluginError WAInputPlugin::EQSet(int on, char data[10], int preamp) -{ - if (_inPlugin==0) return errNotLoaded; - _inPlugin->EQSet(on,data,preamp); - return errOk; -} - -bool WAInputPlugin::IsFinished() -{ - MSG msg; - if (PeekMessage(&msg,_hNotify,WM_WA_MPEG_EOF,WM_WA_MPEG_EOF,PM_REMOVE)) - { - DispatchMessage(&msg); - } - return _finished; -} \ No newline at end of file diff --git a/Windows/WAInputPlugin.h b/Windows/WAInputPlugin.h deleted file mode 100644 index 9c7ddf2..0000000 --- a/Windows/WAInputPlugin.h +++ /dev/null @@ -1,130 +0,0 @@ -// WAInputPlugin.h: interface for the WAInputPlugin class. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_WAINPUTPLUGIN_H__C78D396A_67F6_473B_891C_D6D162312554__INCLUDED_) -#define AFX_WAINPUTPLUGIN_H__C78D396A_67F6_473B_891C_D6D162312554__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "winamp/in2.h" - -class IWAOutput -{ -public: - - // returns >=0 on success, <0 on failure - // NOTENOTENOTE: bufferlenms and prebufferms are ignored in most if not all output plug-ins. - // ... so don't expect the max latency returned to be what you asked for. - // returns max latency in ms (0 for diskwriters, etc) - // bufferlenms and prebufferms must be in ms. 0 to use defaults. - // prebufferms must be <= bufferlenms - virtual int Open(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms)=0; - - // close the ol' output device. - virtual void Close()=0; - - // 0 on success. Len == bytes to write (<= 8192 always). buf is straight audio data. - // 1 returns not able to write (yet). Non-blocking, always. - virtual int Write(const char *buf, int len)=0; - - // returns number of bytes possible to write at a given time. - // Never will decrease unless you call Write (or Close, heh) - virtual int CanWrite()=0; - - // non0 if output is still going or if data in buffers waiting to be - // written (i.e. closing while IsPlaying() returns 1 would truncate the song - virtual int IsPlaying()=0; - - // returns previous pause state - virtual int Pause(int pause)=0; - - // volume is 0-255 - virtual void SetVolume(int volume)=0; - // pan is -128 to 128 - virtual void SetPan(int pan)=0; - - // flushes buffers and restarts output at time t (in ms) - // (used for seeking) - virtual void Flush(int t)=0; - - // returns played time in MS - virtual int GetOutputTime()=0; - - // returns time written in MS (used for synching up vis stuff) - virtual int GetWrittenTime()=0; - - virtual uint32_t AddRef()=0; - - virtual uint32_t Release()=0; - -}; - - -class WAInputPlugin -{ - HMODULE _mod; - In_Module *_inPlugin; - Out_Module _output; - IWAOutput *_ioutput; - bool _finished; - HWND _hNotify; - WAInputPlugin &operator=(const WAInputPlugin &other); - WAInputPlugin(const WAInputPlugin &other); -public: - enum PluginError - { - errOk=0, - errNotFound, - errCantInit, - errNotValidPlugin, - errNotLoaded, - errBufferTooSmall, - errPluginBufferOverrun, - errUnknownFileFormat, - errTooManyPlugins, - errFileNotFound, - errCantPlay, - errFalse, - errGPF - }; -public: - WAInputPlugin(); - virtual ~WAInputPlugin(); - - PluginError LoadPlugin(const char *name); - PluginError UIConfig(HWND parentHwnd=0); - PluginError UIAbout(HWND parentHwnd=0); - PluginError UnloadPlugin(); - PluginError IsLoaded(); - const char *GetDescription(); - PluginError GetFileInfo(const char *filename, char *title, int title_size, int *len_in_ms); - PluginError UIFileInfo(const char *filename, HWND parentHwnd=0); - PluginError CanPlayFile(const char *filename); - PluginError AttachOutput(IWAOutput *o); - IWAOutput *GetAttachedOutput() {if (_ioutput) _ioutput->AddRef();return _ioutput;} - IWAOutput *GetAttachedOutputNoAddRef() {return _ioutput;} - PluginError Play(const char *name); - PluginError Pause(); - PluginError UnPause(); - PluginError IsPaused(); - PluginError Stop(); - int GetLength() - {if (_inPlugin) return _inPlugin->GetLength();return -1;} - int GetOutputTime() - {if (_inPlugin) return _inPlugin->GetOutputTime();return -1;} - PluginError SetOutputTime(int t); - PluginError SetVolume(int volume); // from 0 to 255.. usually just call outMod->SetVolume - PluginError SetPan(int pan); // from -127 to 127.. usually just call outMod->SetPan - - PluginError EQSet(int on, char data[10], int preamp); // 0-64 each, 31 is +0, 0 is +12, 63 is -12. Do nothing to ignore. - bool IsFinished(); - bool IsUsesOutput() {return _inPlugin->UsesOutputPlug!=0;} - - void MarkFinished() {_finished=true;} - -}; - -#endif // !defined(AFX_WAINPUTPLUGIN_H__C78D396A_67F6_473B_891C_D6D162312554__INCLUDED_) diff --git a/Windows/WAPlayer.cpp b/Windows/WAPlayer.cpp deleted file mode 100644 index 6251b68..0000000 --- a/Windows/WAPlayer.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "stdafx.h" -#include ".\waplayer.h" -#include - -WAPlayer::WAPlayer(void) -{ - _pluginList=0; -} - -WAPlayer::~WAPlayer(void) -{ - ClearList(); -} - - -void WAPlayer::ClearList() -{ - delete [] _pluginList; - _pluginList=0; - _nPlugins=0; -} - -void WAPlayer::LoadPlugins(const char *path) -{ - char *wildcards=(char *)alloca(strlen(path)+10); - char *pathname=(char *)alloca(strlen(path)+MAX_PATH); -// CheckPathname(pathname); - strcpy(wildcards,path); - strcpy(pathname,path); - if (wildcards[strlen(wildcards)-1]!='\\') - { - strcat(wildcards,"\\"); - strcat(pathname,"\\"); - } - char *fname=strchr(pathname,0); - strcat(wildcards,"in_*.dll"); - HANDLE h; - ClearList(); - WIN32_FIND_DATA fnd; - h=FindFirstFile(wildcards,&fnd); - if (h) do - { - _nPlugins++; - }while(FindNextFile(h,&fnd)); - FindClose(h); - - _pluginList=new WAInputPlugin[_nPlugins]; - int pos=0; - h=FindFirstFile(wildcards,&fnd); - if (h != INVALID_HANDLE_VALUE) do - { - strcpy(fname,fnd.cFileName); - if (_pluginList[pos].LoadPlugin(pathname)!=WAInputPlugin::errOk) - _pluginList[pos].UnloadPlugin(); - else - pos++; - } - while (FindNextFile(h,&fnd)); - _nPlugins=pos; - FindClose(h); -} - -WAInputPlugin *WAPlayer::SelectBestPlugin(const char *songName) -{ - for (int i=0;i<_nPlugins;i++) - if (_pluginList[i].CanPlayFile(songName)==WAInputPlugin::errOk) return _pluginList+i; - return 0; -} - -bool WAPlayer::EnumPlugins(bool (*EnumProc)(WAPlayer &player, WAInputPlugin &plugin, void *context), void *context) -{ - for (int i=0;i<_nPlugins;i++) if (EnumProc(*this,_pluginList[i],context)==false) return false; - return true; -} \ No newline at end of file diff --git a/Windows/WAPlayer.h b/Windows/WAPlayer.h deleted file mode 100644 index 1900358..0000000 --- a/Windows/WAPlayer.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include "WAInputPlugin.h" - -class WAPlayer -{ - WAInputPlugin *_pluginList; - int _nPlugins; - - WAPlayer &operator=(const WAPlayer &other); - WAPlayer(const WAPlayer &other); -public: - WAPlayer(void); - ~WAPlayer(void); - - - - void ClearList(); - void LoadPlugins(const char *path); - WAInputPlugin *SelectBestPlugin(const char *songName); - - bool EnumPlugins(bool (*EnumProc)(WAPlayer &player, WAInputPlugin &plugin, void *context), void *context); -}; diff --git a/Windows/WaveOut.cpp b/Windows/WaveOut.cpp deleted file mode 100644 index 89a3e9d..0000000 --- a/Windows/WaveOut.cpp +++ /dev/null @@ -1,157 +0,0 @@ -// WaveOut.cpp: implementation of the WaveOut class. -// -////////////////////////////////////////////////////////////////////// - -#include "stdafx.h" -#include "WaveOut.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -WaveOut::WaveOut() -{ -_device=0; -} - -WaveOut::~WaveOut() -{ -if (_device) Close(); -} - - -int WaveOut::Open(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms) -{ - MSG msg; - PeekMessage(&msg,0,0,0,0); //ensure message queue created - _paused=false; - _wrpos=0; - _pending=0; - memset(_buffers,0,sizeof(_buffers)); - _played=0; - _written=0; - - WAVEFORMATEX format; - format.cbSize=sizeof(format); - format.nChannels=numchannels; - format.nSamplesPerSec=samplerate; - format.nAvgBytesPerSec=numchannels*samplerate*(bitspersamp/8); - format.nBlockAlign=numchannels*(bitspersamp/8); - format.wBitsPerSample=bitspersamp; - format.wFormatTag=WAVE_FORMAT_PCM; - _event=CreateEvent(NULL,FALSE,FALSE,NULL); - _persec=format.nAvgBytesPerSec; - MMRESULT res=waveOutOpen(&_device,WAVE_MAPPER,&format,(DWORD)_event,(DWORD)this,CALLBACK_EVENT); - if (res==MMSYSERR_NOERROR) return 0; - return -1; -} - -void WaveOut::Close() -{ - Flush(1); - waveOutClose(_device); - _device=0; - -} - -int WaveOut::NextBuffer() -{ - int b=_wrpos; - printf("Buffers: %5d time: %d\r",_pending,GetOutputTime()/1000); - if (_buffers[_wrpos]==0 || (_buffers[_wrpos]->dwFlags & WHDR_DONE)) - { - if (_buffers[_wrpos]) - { - waveOutUnprepareHeader(_device,_buffers[_wrpos],sizeof(*_buffers[_wrpos])); - free(_buffers[_wrpos]->lpData); - _played+=_buffers[_wrpos]->dwBufferLength; - delete _buffers[_wrpos]; - _buffers[_wrpos]=0; - _pending--; - } - _wrpos++; - if (_wrpos>=MAXBUFFERS) _wrpos=0; - return b; - } - return -1; -} - - -int WaveOut::Write(const char *buf, int len) -{ - int pos=NextBuffer(); - while (pos==-1) - { - WaitForSingleObject(_event,INFINITE); - pos=NextBuffer(); - } - WAVEHDR *hdr=new WAVEHDR; - memset(hdr,0,sizeof(*hdr)); - hdr->dwBufferLength=len; - hdr->lpData=(char *)malloc(len); - memcpy(hdr->lpData,buf,len); - waveOutPrepareHeader(_device,hdr,sizeof(*hdr)); - waveOutWrite(_device,hdr,sizeof(*hdr)); - _buffers[pos]=hdr; - _pending++; - _written+=len; - return 0; -} - -int WaveOut::CanWrite() -{ - return _paused?0:16*1024*1024; -} - -int WaveOut::IsPlaying() -{ - while (_pending) - { - if (NextBuffer()==-1) return 1; - } - return 0; -} - -int WaveOut::Pause(int pause) -{ - bool waspaused=_paused; - if (pause) - { - if (!waspaused) waveOutPause(_device); - _paused=true; - } - else - { - if (waspaused) waveOutRestart(_device); - _paused=false; - } - return waspaused?1:0; -} - -void WaveOut::SetVolume(int volume) -{ - -} - -void WaveOut::SetPan(int pan) -{ - -} - - -void WaveOut::Flush(int t) -{ - waveOutReset(_device); - while (_pending) NextBuffer(); -} - - -int WaveOut::GetOutputTime() -{ - return (int)((__int64)_played*(__int64)1000/(__int64)_persec); -} - -int WaveOut::GetWrittenTime() -{ - return (int)((__int64)_played*(__int64)1000/(__int64)_persec); -} diff --git a/Windows/WaveOut.h b/Windows/WaveOut.h deleted file mode 100644 index 1f04759..0000000 --- a/Windows/WaveOut.h +++ /dev/null @@ -1,52 +0,0 @@ -// WaveOut.h: interface for the WaveOut class. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_WAVEOUT_H__1390C856_FA5C_4E84_B98D_4CC05086733D__INCLUDED_) -#define AFX_WAVEOUT_H__1390C856_FA5C_4E84_B98D_4CC05086733D__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define MAXBUFFERS 64 - -#include "WAInputPlugin.h" -#include - -class WaveOut: public IWAOutput -{ - HWAVEOUT _device; - bool _paused; - LPWAVEHDR _buffers[MAXBUFFERS]; - int _wrpos; - HANDLE _event; - DWORD _played; - DWORD _written; - DWORD _persec; - - int NextBuffer(); - int _pending; - -public: - WaveOut(); - virtual ~WaveOut(); - - virtual int Open(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms); - virtual void Close(); - virtual int Write(const char *buf, int len); - virtual int CanWrite(); - virtual int IsPlaying(); - virtual int Pause(int pause); - virtual void SetVolume(int volume); - virtual void SetPan(int pan); - virtual void Flush(int t); - virtual int GetOutputTime(); - virtual int GetWrittenTime(); - virtual uint32_t AddRef() {return 1;} - virtual uint32_t Release() {return 0;} -}; - - - -#endif // !defined(AFX_WAVEOUT_H__1390C856_FA5C_4E84_B98D_4CC05086733D__INCLUDED_) diff --git a/Windows/WinAmpInterface.cpp b/Windows/WinAmpInterface.cpp deleted file mode 100644 index 9950d46..0000000 --- a/Windows/WinAmpInterface.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// WinAmpInterface.cpp : Defines the entry point for the console application. -// - -#include "stdafx.h" -#include "WAInputPlugin.h" -#include "WaveOut.h" -#include "waplayer.h" - - -int main(int argc, char* argv[]) -{ - WAPlayer player; - player.LoadPlugins("C:\\Program Files\\Winamp\\Plugins"); - const char *name="\\\\bredy-doma\\d$\\MUSIC\\S3M\\s3m\\CTGOBLIN.S3M"; - WAInputPlugin *plug=player.SelectBestPlugin(name); - - WaveOut output; - plug->AttachOutput(&output); - plug->Play(name); - while (kbhit()==0 && !plug->IsFinished()) Sleep(500); - plug->Stop(); - plug->AttachOutput(0); - - - - return 0; -} diff --git a/Windows/WinAmpInterface.h b/Windows/WinAmpInterface.h deleted file mode 100644 index e69de29..0000000 diff --git a/Windows/bios.c b/Windows/bios.c deleted file mode 100644 index e69de29..0000000 diff --git a/Windows/bios.h b/Windows/bios.h deleted file mode 100644 index 704adbe..0000000 --- a/Windows/bios.h +++ /dev/null @@ -1,2 +0,0 @@ -#include - diff --git a/Windows/debug.h b/Windows/debug.h deleted file mode 100644 index d4c81ad..0000000 --- a/Windows/debug.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _DEBUG_H_ -#define _DEBUG_H_ - -#include - -#define STOP() StopProgram(__FILE__,__LINE__); - -static __inline void StopProgram(const char *text, int line) - { - char buff[256]; - sprintf(buff,"Stop at %s line %d",text,line); - MessageBox(NULL,buff,NULL,MB_OK|MB_SYSTEMMODAL); - __asm - { - int 3; - } - } - -#endif \ No newline at end of file diff --git a/Windows/extras.rtf b/Windows/extras.rtf deleted file mode 100644 index 9c6431e..0000000 --- a/Windows/extras.rtf +++ /dev/null @@ -1,77 +0,0 @@ -{\rtf1\ansi\deff1\adeflang1025 -{\fonttbl{\f0\froman\fprq2\fcharset238 Times New Roman;}{\f1\froman\fprq2\fcharset238 Thorndale{\*\falt Times New Roman};}{\f2\froman\fprq2\fcharset238 Times New Roman;}{\f3\froman\fprq2\fcharset238 Thorndale{\*\falt Times New Roman};}{\f4\fnil\fprq0\fcharset238 Times New Roman;}{\f5\fnil\fprq0\fcharset2 StarSymbol;}{\f6\fmodern\fprq1\fcharset238 Courier New;}{\f7\fnil\fprq2\fcharset238 Lucida Sans Unicode;}{\f8\fnil\fprq2\fcharset238 Tahoma;}{\f9\fnil\fprq0\fcharset238 Tahoma;}} -{\colortbl;\red0\green0\blue0;\red128\green128\blue128;} -{\stylesheet{\s1\cf1{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f1\fs24\lang1029\snext1 Default;} -{\s2\sa120\cf1{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f1\fs20\lang1029\sbasedon1\snext2 Text body;} -{\s3\li283\ri0\lin283\rin0\fi283\cf1\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f2\fs20\lang1029\sbasedon2\snext3 Text body indent;} -{\s4\sb240\sa120\keepn\cf1{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ql\rtlch\af8\afs28\lang255\ltrch\dbch\af7\afs28\langfe255\loch\f4\fs28\lang1029\sbasedon1\snext2 Heading;} -{\s5\cf1\uldb{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ql\rtlch\af1\afs32\lang255\ab\ltrch\dbch\af1\afs32\langfe255\ab\loch\f1\fs32\lang1029\b\sbasedon4\snext2{\*\soutlvl0} Heading 1;} -{\s6\cf1\shad\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs28\lang255\ai\ab\ltrch\dbch\af1\afs28\langfe255\ai\ab\loch\f1\fs24\lang1029\i\b\sbasedon4\snext2{\*\soutlvl1} Heading 2;} -{\s7\cf1{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ql\rtlch\af9\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f1\fs24\lang1029\sbasedon2\snext7 List;} -{\s8\sb120\sa120\cf1{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ql\rtlch\af9\afs20\lang255\ai\ltrch\dbch\af1\afs20\langfe255\ai\loch\f1\fs20\lang1029\i\sbasedon1\snext8 Caption;} -{\s9\cf1{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ql\rtlch\af9\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f1\fs24\lang1029\sbasedon1\snext9 Index;} -{\*\cs11\cf1\rtlch\af1\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f1\fs24\lang1029 Drop Caps;} -{\*\cs12\cf1\rtlch\af5\afs18\lang255\ltrch\dbch\af5\afs18\langfe255\loch\f5\fs18\lang1029 Bullets;} -{\*\cs13\cf1\horzvert0\rtlch\af1\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f1\fs24\lang1029 Vertical Numbering Symbols;} -{\*\cs14\cf1\rtlch\af6\afs24\lang255\ltrch\dbch\af6\afs24\langfe255\loch\f6\fs24\lang1029 Example;} -{\*\cs15\cf1\rtlch\af1\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f1\fs24\lang1029 Definition;} -{\*\cs16\cf1\rtlch\af1\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f1\fs24\lang1029 Numbering Symbols;} -}{\*\listtable{\list\listtemplateid1 -{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow2{\leveltext \'02\'00.;}{\levelnumbers\'01;}\fi-283\li283} -{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow2{\leveltext \'02\'01);}{\levelnumbers\'01;}\fi-283\li567}\listid1} -}{\listoverridetable{\listoverride\listid1\listoverridecount0\ls0}} - -{\info{\creatim\yr2004\mo4\dy25\hr23\min7}{\operator Ondrej Novak}{\revtim\yr2004\mo4\dy26\hr22\min53}{\printim\yr1601\mo1\dy1\hr0\min0}{\comment StarWriter}{\vern6450}}\deftab1134 -{\*\pgdsctbl -{\pgdsc0\pgdscuse195\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\pgdscnxt0 Default;}} -{\*\pgdscno0}\paperh15840\paperw12240\margl1800\margr1800\margt1440\margb1440\sectd\sbknone\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc -\pard\plain \sb240\sa120\keepn\f4\fs32\uldb\b\f7\fs32\b\f8\fs32\b \ltrpar\s5\cf1\uldb{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ql\rtlch\af1\afs32\lang255\ab\ltrch\dbch\af1\afs32\langfe255\ab\loch\f1\fs32\lang1029\b {\loch\f4\fs32\lang1029\i0\b Popis nov\'fdch roz\'9a\'ed\u345 ?en\'ed ve Skeldalu} -\par \pard\plain \ltrpar\s2\cf1{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\sa120\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f1\fs20\lang1029 {\loch\f1\fs20\lang1029\i0\b0 Oproti p\u367 ?vodn\'ed DOS verzi obsahuje verze pro Windows n\u283 ?kter\'e1 vylep\'9aen\'ed. Ka\'9ed\'e9 vylep\'9aen\'ed je v\'9aak nutn\'e9 aktivovat zatrhnut\'edm p\u345 ?\'edslu\'9an\'e9ho ok\'e9nka.} -\par \pard\plain \sb240\sa120\keepn\f4\i\shad\b\f7\fs28\i\b\f8\fs28\i\b\qj \ltrpar\s6\cf1\shad\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs28\lang255\ai\ab\ltrch\dbch\af1\afs28\langfe255\ai\ab\loch\f1\fs24\lang1029\i\b {\loch\f4\fs24\lang1029\i\b N\'e1hodn\'fd backfire (p\u345 ?i kouzlen\'ed) } -\par \pard\plain \ltrpar\s3\cf1\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li283\ri0\lin283\rin0\fi283\rtlch\af1\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f2\fs20\lang1029{\loch\f2\fs20\lang1029\i0\b{\b Backfire }}{\loch\f2\fs20\lang1029znamen\'e1 v p\u345 ?ekladu {\i "Zp\u283 ?tn\'fd n\'e1raz"}. To nast\'e1v\'e1 v situaci, kdy se \u269 ?arod\u283 ?ji kouzlo nezda\u345 ?\'ed, av\'9aak nav\'edc m\'e1 tu sm\u367 ?lu, \'9ee jeho ne\'fasp\u283 ?ch je tak fat\'e1ln\'ed, \'9ee se kouzlo obr\'e1t\'ed proti n\u283 ?mu. Pokud je za\'9akrtnuta volba {\b N\'e1hodn\'fd backfire}, m\u367 ?\'9ee \u269 ?arod\u283 ?j p\u345 ?i fat\'e1ln\'ed -m ne\'fasp\u283 ?chu necht\u283 ?n\u283 ? vyvolat n\'e1hodn\u283 ? kter\'e9koliv kouzlo z cel\'e9ho souboru kouzel Skeldalu (jde jen o kouzla z run), takto m\u367 ?\'9ee vyvolat i kouzlo, na kter\'e9 nem\'e1, ani nem\u367 ?\'9ee m\'edt \'farve\u328 ?, nebo nem\'e1 manu. Mana se p\u345 ?itom spot\u345 ?ebuje jen tolik, kolik by se spot\u345 ?eboval -o na kouzlo, jen\'9e cht\u283 ?l vyvolat. } -\par {\loch\f2\fs20\lang1029\i0\b0 Plat\'ed zde n\u283 ?kolik pravidel. Pokud je to kouzlo na postavu, automaticky se vybere \u269 ?arod\u283 ?j. Pokud m\'e1 kouzlo \'fa\u269 ?inkovat na pol\'ed\u269 ?ko, m\'e1 vliv na v\'9aechny postavy na pol\'ed\u269 ?ku, kde stoj\'ed \u269 ?arod\u283 ?j. Pokud m\'e1 kouzlo \'fa\u269 ?inkovat na pol\'ed\u269 ?ku p\u345 ?ed \u269 ?arod\u283 ?jem, m\'e1 vliv na v\'9aechn -y postavy na pol\'ed\u269 ?ku, kde stoj\'ed \u269 ?arod\u283 ?j. V p\u345 ?\'edpad\u283 ?, \'9ee se jedn\'e1 o kouzlo teleportace, je zvolen n\'e1hodn\'fd c\'edl v r\'e1mci cel\'e9ho bludi\'9at\u283 ?. } -\par {\loch\f2\fs20\lang1029\i0\b0 Za\'9akrtnut\'ed t\'e9to volby m\u367 ?\'9ee zp\u283 ?st\u345 ?it hru p\u345 ?i souboj\'edch s nep\u345 ?\'edli\'9a vy\'9akolen\'fdmi \u269 ?arod\u283 ?ji. \u268 ?asto m\u367 ?\'9ee tento necht\u283 ?n\'fd backfire p\u345 ?\'edn\'e9st i n\u283 ?jakou v\'fdhodu. } -\par \pard\plain \sb240\sa120\keepn\f4\i\shad\b\f7\fs28\i\b\f8\fs28\i\b\qj \ltrpar\s6\cf1\shad\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs28\lang255\ai\ab\ltrch\dbch\af1\afs28\langfe255\ai\ab\loch\f1\fs24\lang1029\i\b {\loch\f4\fs24\lang1029\i\b Recykluj nestv\u367 ?ry } -\par \pard\plain \ltrpar\s3\cf1\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li283\ri0\lin283\rin0\fi283\rtlch\af1\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f2\fs20\lang1029 {\loch\f2\fs20\lang1029\i0\b0 Zap\'edn\'e1 obnovov\'e1n\'ed nestv\u367 ?r. Pro hr\'e1\u269 ?e, jen\'9e maj\'ed pocit, \'9ee vybit\'e9 prostory jsou p\u345 ?\'edli\'9a nudn\'e9 je mo\'9en\'e9 tuto volbu aktivovat. Pot\'e9 se p\u345 ?esto v m\'edstech, kde byly nestvury pobity \u269 ?asem n\u283 ?jak\'e1 nestv\u367 ?ra znova objev\'ed. Nastaven\'ed neovlivn\'ed ty nestv\u367 ?ry, jen\'9e maj\'ed obn -ovov\'e1n\'ed povolen\'e9 v dobrodru\'9estv\'ed (ty se obnovuj\'ed st\'e1le) } -\par \pard\plain \sb240\sa120\keepn\f4\i\shad\b\f7\fs28\i\b\f8\fs28\i\b\qj \ltrpar\s6\cf1\shad\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs28\lang255\ai\ab\ltrch\dbch\af1\afs28\langfe255\ai\ab\loch\f1\fs24\lang1029\i\b {\loch\f4\fs24\lang1029\i\b Alternativn\'ed bojov\'fd syst\'e9m} -\par \pard\plain \ltrpar\s3\cf1\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li283\ri0\lin283\rin0\fi283\rtlch\af1\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f2\fs20\lang1029 {\loch\f2\fs20\lang1029\i0\b0 Br\'e1ny Skeldalu pro Windows p\u345 ?in\'e1\'9aej\'ed pozm\u283 ?n\u283 ?n\'fd bojov\'fd system. Jde zejm\'e9na o nov\'e9 v\'fdpo\u269 ?ty a vzorce pro z\'e1sah. P\u367 ?vodn\'ed bojov\'fd syst\'e9m pouze p\u345 ?i\u269 ?\'edt\'e1 k s\'edle \'fato\u269 ?n\'e9 \u269 ?\'edslo, obratnosti obran\'e9 \u269 ?\'edslo, porovn\'e1v\'e1 je a z toho se vypo\u269 ?\'edt\'e1 z\'e1sah. Alternativn\'ed bojov\'fd syst -\'e9m m\'e1 v\'edc n\'e1hodn\'fdch \u269 ?\'e1st\'ed, ale p\u345 ?esto d\'e1v\'e1 v\u283 ?t\'9a\'ed d\u367 ?raz i na vlastnosti postav. } -\par {\loch\f2\fs20\lang1029\i0\b0 \'dato\u269 ?n\'e1 a obrann\'e1 \u269 ?\'edsla se po\u269 ?\'edtaj\'ed 2x. Ve vzorc\'edch parametr chaos ud\'e1v\'e1 postih za p\u345 ?\'edli\'9a mnoho postav na pol\'ed\u269 ?ku a po\u269 ?\'edt\'e1 se jako chaos=(po\u269 ?et_postav+1)/2 /v\u269 ?etn\u283 ? sama sebe/.} -\par \pard\plain {\listtext\pard\plain \li850\ri0\lin850\rin0\fi-283\sa120\f2\fs20\qj 1)}\ilvl1 \ltrpar\s3\cf1\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ls0\li850\ri0\lin850\rin0\fi-283\rtlch\af1\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f2\fs20\lang1029 {\loch\f2\fs20\lang1029\i0\b0 Prvn\'ed v\'fdpo\u269 ?et spo\u269 ?\'edt\'e1 \'fato\u269 ?n\'e9 \u269 ?\'edslo (\'fa\u269 ?) a obrann\'e9 \u269 ?\'edslo (o\u269 ?) takto:} -\par \pard\plain \ltrpar\s3\cf1\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li850\ri0\lin850\rin0\fi283\rtlch\af1\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f2\fs20\lang1029{\loch\f6\fs16\lang1029\i0\b0{\fs16\f6 \'fa\u269 ?=n\'e1hoda(\'fatok_min,\'fatok_max)+\'fato\u269 ?n\'edk.obratnost/4\line o\u269 ?=n\'e1hoda(obrana_min,obrana_max)+obr\'e1nce.obratnost/(4*chaos)}}{\loch\f2\fs20\lang1029\line \line pokud o\u269 ?>\'fa\u269 ?, pak se obr\'e1nce \'fabr\'e1n\'edl \'fatoku (me\u269 ?em, \'9at\'edtem, usko\u269 ?il, nastavil bezpe\u269 ?nou \u269 ?\'e1st brn\u283 ?n\'ed) a nem\u367 ?\'9ee b\'fdt zasa\'9een b\u283 ?\'9en\'fdm \'fatokem} -\par \pard\plain {\listtext\pard\plain \li850\ri0\lin850\rin0\fi-283\sa120\f2\fs20\qj 2)}\ilvl1 \ltrpar\s3\cf1\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ls0\li850\ri0\lin850\rin0\fi-283\rtlch\af1\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f2\fs20\lang1029 {\loch\f2\fs20\lang1029\i0\b0 Druh\'fd v\'fdpo\u269 ?et spo\u269 ?\'edt\'e1 druh\'e9 \'fato\u345 ?n\'e9 \u269 ?\'edslo (\'fa\u269 ?2) a druh\'e9 obrann\'e9 \u269 ?\'edslo (o\u269 ?2)} -\par \pard\plain \ltrpar\s3\cf1\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li850\ri0\lin850\rin0\fi283\rtlch\af1\afs16\lang255\ltrch\dbch\af1\afs16\langfe255\loch\f6\fs16\lang1029 {\loch\f6\fs16\lang1029\i0\b0 \'fa\u269 ?2=n\'e1hoda(\'fatok_min,\'fatok_max)+\'fato\u269 ?n\'edk.s\'edla/5\line o\u269 ?2=n\'e1hoda(obrana_min,obrana_max)+obr\'e1nce.obratnost/(5*chaos)} -\par \pard\plain \ltrpar\s3\cf1\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li850\ri0\lin850\rin0\fi283\rtlch\af1\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f2\fs20\lang1029 {\loch\f2\fs20\lang1029\i0\b0 pokud o\u269 ?>\'fa\u269 ?, pak z\'e1sah padnul na brn\u283 ?n\'ed a nezp\u367 ?sobilo \'9e\'e1dn\'e9 po\'9akozen\'ed\line pokud \'fa\u269 ? -#include -#include "install.h" -#include "resource.h" -#include -#include -extern "C" - { -#include -#include - } -#include -#include - -static void correctfilter(char *z) - { - char *c; - while ((c=strrchr(z,'|'))!=NULL) *c=0; - } - -static void CommDlgError(HWND owner, int error) -{ - char *msg=0; - switch (error) - { - case CDERR_DIALOGFAILURE: msg="CDERR_DIALOGFAILURE: The dialog box could not be created. The common dialog box function's call to the DialogBox function failed. For example, this error occurs if the common dialog box call specifies an invalid window handle. ";break; - case CDERR_FINDRESFAILURE: msg="CDERR_FINDRESFAILURE: The common dialog box function failed to find a specified resource. ";break; - case CDERR_INITIALIZATION: msg="CDERR_INITIALIZATION: The common dialog box function failed during initialization. This error often occurs when sufficient memory is not available. ";break; - case CDERR_LOADRESFAILURE: msg="CDERR_LOADRESFAILURE: The common dialog box function failed to load a specified resource. ";break; - case CDERR_LOADSTRFAILURE: msg="CDERR_LOADSTRFAILURE: The common dialog box function failed to load a specified string. ";break; - case CDERR_LOCKRESFAILURE: msg="CDERR_LOCKRESFAILURE: The common dialog box function failed to lock a specified resource. ";break; - case CDERR_MEMALLOCFAILURE: msg="CDERR_MEMALLOCFAILURE: The common dialog box function was unable to allocate memory for internal structures. ";break; - case CDERR_MEMLOCKFAILURE: msg="CDERR_MEMLOCKFAILURE: The common dialog box function was unable to lock the memory associated with a handle. ";break; - case CDERR_NOHINSTANCE: msg="CDERR_NOHINSTANCE: The ENABLETEMPLATE flag was set in the Flags member of the initialization structure for the corresponding common dialog box, but you failed to provide a corresponding instance handle. ";break; - case CDERR_NOHOOK: msg="CDERR_NOHOOK: The ENABLEHOOK flag was set in the Flags member of the initialization structure for the corresponding common dialog box, but you failed to provide a pointer to a corresponding hook procedure. ";break; - case CDERR_NOTEMPLATE: msg="CDERR_NOTEMPLATE: The ENABLETEMPLATE flag was set in the Flags member of the initialization structure for the corresponding common dialog box, but you failed to provide a corresponding template. ";break; - case CDERR_REGISTERMSGFAIL: msg="CDERR_REGISTERMSGFAIL: The RegisterWindowMessage function returned an error code when it was called by the common dialog box function. ";break; - case CDERR_STRUCTSIZE: msg="CDERR_STRUCTSIZE: The lStructSize member of the initialization structure for the corresponding common dialog box is invalid. ";break; - case FNERR_BUFFERTOOSMALL: msg="FNERR_BUFFERTOOSMALL: The buffer pointed to by the lpstrFile member of the OPENFILENAME structure is too small for the file name specified by the user. The first two bytes of the lpstrFile buffer contain an integer value specifying the size, in TCHARs, required to receive the full name. ";break; - case FNERR_INVALIDFILENAME: msg="FNERR_INVALIDFILENAME: A file name is invalid. ";break; - case FNERR_SUBCLASSFAILURE: msg="FNERR_SUBCLASSFAILURE: An attempt to subclass a list box failed because sufficient memory was not available. ";;break; - default: msg="Unknown CommDlgError.";break; - } - char *text=(char *)alloca(strlen(msg)+200); - sprintf(text,"CommDlgError (%d / %04X)\r\n\r\nDescription:\r\n\r\n%s",error,error,msg); - MessageBox(owner,text,NULL,MB_OK|MB_ICONEXCLAMATION); -} - -static bool VyberSlozku(HWND owner, char *slozka) - { - OPENFILENAME ofn; - char filter[100]; - char title[100]; - LoadString(GetModuleHandle(NULL),IDS_INSTALLFILTER,filter,sizeof(filter)); - LoadString(GetModuleHandle(NULL),IDS_INSTALLTITLE,title,sizeof(title)); - LoadString(GetModuleHandle(NULL),IDS_INSTALLPRENAME,slozka,MAX_PATH); - correctfilter(filter); - memset(&ofn,0,sizeof(ofn)); -#ifdef OPENFILENAME_SIZE_VERSION_400 - ofn.lStructSize=OPENFILENAME_SIZE_VERSION_400; -#else - ofn.lStructSize=sizeof(ofn); -#endif - ofn.hwndOwner=owner; - ofn.lpstrFilter=filter; - ofn.lpstrFile=slozka; - ofn.nMaxFile=MAX_PATH*4; - ofn.lpstrTitle=title; - ofn.Flags=OFN_PATHMUSTEXIST|OFN_HIDEREADONLY|OFN_NOCHANGEDIR; - if (GetOpenFileName(&ofn)) return true; - else - { - int err=CommDlgExtendedError(); - if (err) CommDlgError(owner,err); - return false; - } - } - -static bool VyberCD(HWND owner, char *slozka) - { - OPENFILENAME ofn; - char filter[100]; - char title[100]; - LoadString(GetModuleHandle(NULL),IDS_INSTALLCDFILTER,filter,sizeof(filter)); - LoadString(GetModuleHandle(NULL),IDS_INSTALLCDTITLE,title,sizeof(title)); - LoadString(GetModuleHandle(NULL),IDS_INSTALLCDFILE,slozka,MAX_PATH); - correctfilter(filter); - memset(&ofn,0,sizeof(ofn)); -#ifdef OPENFILENAME_SIZE_VERSION_400 - ofn.lStructSize=OPENFILENAME_SIZE_VERSION_400; -#else - ofn.lStructSize=sizeof(ofn); -#endif - ofn.hwndOwner=owner; - ofn.lpstrFilter=filter; - ofn.lpstrFile=slozka; - ofn.nMaxFile=MAX_PATH*4; - ofn.lpstrTitle=title; - ofn.Flags=OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_NOCHANGEDIR; - if (GetOpenFileName(&ofn)) return true; - else { - int err=CommDlgExtendedError(); - if (err) CommDlgError(owner,err); - return false; - } - } - - - -static TSTR_LIST filetocopy=NULL; - -static void FileSingleCopy(const char *src, const char *trg) - { - if (filetocopy==NULL) filetocopy=create_list(100); - str_add(&filetocopy,(char *)src); - str_add(&filetocopy,(char *)trg); - } - -static void FileCopy(HWND hWnd,const char *srcmask, const char *trgmask, const char *src, const char *trg) - { - char *fsrc=(char *)alloca((strlen(srcmask)+strlen(src))*2+MAX_PATH); - char *ftrg=(char *)alloca((strlen(trgmask)+strlen(trg))*2+MAX_PATH); - sprintf(fsrc,srcmask,src); - sprintf(ftrg,trgmask,trg); - strcat(ftrg,"\\"); - char *trgplace=strchr(ftrg,0); - char *srcplace=strrchr(fsrc,'\\')+1; - WIN32_FIND_DATA fdata; - HANDLE h=FindFirstFile(fsrc,&fdata); - if (h==INVALID_HANDLE_VALUE) - { - ResMessageBox2(hWnd,IDS_INSTALLCHYBISOUBOR,MB_ICONEXCLAMATION|MB_OK,fsrc); - return; - } - if (h) do - { - if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - { - strcpy(trgplace,fdata.cFileName); - strcpy(srcplace,fdata.cFileName); - FileSingleCopy(fsrc,ftrg); - } - } - while (FindNextFile(h,&fdata)); - FindClose(h); - } - -static void DirCreate(const char *srcmask, const char *src) - { - char *fsrc=(char *)alloca((strlen(srcmask)+strlen(src))*2+MAX_PATH); - sprintf(fsrc,srcmask,src); - CreateDirectory(fsrc,NULL); - } - -static BOOL CommitCopy(HWND hWnd) - { - int size=0; - int i; - for (i=0;iSetPath(lpszPathObj); - psl->SetDescription( lpszDesc); - psl->SetWorkingDirectory(wkd); - if (args!=NULL) psl->SetArguments(args); - - // Query IShellLink for the IPersistFile interface for saving the - // shortcut in persistent storage. - hres = psl->QueryInterface(IID_IPersistFile, - (void **)&ppf); - - if (SUCCEEDED(hres)) { - wchar_t wsz[MAX_PATH]; - - // Ensure that the string is ANSI. - MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1, - wsz, MAX_PATH); - - // Save the link by calling IPersistFile::Save. - hres = ppf->Save(wsz, TRUE); - ppf->Release(); - } - psl->Release(); - } - return hres; -} - - - -static void CreateLinkSkeldal(char *buff,char *slozka) - { - CoInitialize(NULL); - GetModuleFileName(NULL,buff,MAX_PATH*4); - char *c=strrchr(buff,'\\'); - strcat(slozka,c); - SHGetSpecialFolderPath(NULL,buff,CSIDL_DESKTOPDIRECTORY,TRUE); - strcat(buff,"\\"); - c=strchr(buff,0); - LoadString(GetModuleHandle(NULL),IDS_WINTITLE,c,50); - strcat(c,".lnk"); - CreateLink(slozka,buff,"",NULL); - } - -BOOL RunInstall(HWND hWnd) - { - char slozka[MAX_PATH*4]; - char cd[MAX_PATH*4]; - char mypath[MAX_PATH*4]; - TSTR_LIST ini; - char *c; - - if (ResMessageBox(hWnd,IDS_INSTALLTEXT1,MB_OKCANCEL)==IDCANCEL) return FALSE; - if (VyberCD(hWnd,cd)==false) return FALSE; - if (ResMessageBox(hWnd,IDS_INSTALLTEXT2,MB_OKCANCEL)==IDCANCEL) return FALSE; -opakuj1: - if (VyberSlozku(hWnd,slozka)==false) return FALSE; - c=strrchr(slozka,'\\'); - if (c==NULL) goto opakuj1; - c++; - if (strstr(slozka,c) -#include -#include -#include -#include -#include -#include "resource.h" -#include "konfig.h" -#include "../game/extras.h" -#include "richview.h" -#include - -extern "C" - { -#include -#include - } - -static HWND handles[5]; -static HWND konfigHelp; - -#define CFGCHEATS 4 -#define CFGEXTRAS 3 -#define CFGSOUND 1 -#define CFGVIDEO 2 -#define CFGGENERAL 0 - -static LRESULT NullProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) - { - return 0; - } - -static HANDLE StartHelp(HWND hDlg, const char *process,const char *helppathname) - { - SHELLEXECUTEINFO nfo; - - memset(&nfo,0,sizeof(nfo)); - nfo.cbSize=sizeof(nfo); - nfo.fMask=SEE_MASK_DOENVSUBST|SEE_MASK_NOCLOSEPROCESS; - nfo.hwnd=hDlg; - nfo.lpFile=process; - nfo.lpParameters=helppathname; - nfo.nShow=SW_NORMAL; - if (ShellExecuteEx(&nfo)==0) return NULL; - return nfo.hProcess; - } - -static void ShowHelp(HWND hDlg, char *helpname) - { - SetCursor(LoadCursor(NULL,IDC_WAIT)); - HINSTANCE hInstance=GetModuleHandle(NULL); - HRSRC rscr=FindResource(hInstance,helpname,RT_HTML); - HGLOBAL hglob=LoadResource(hInstance,rscr); - void *ptr=LockResource(hglob); - DWORD sz=SizeofResource(hInstance,rscr); - DWORD wrt; - char buff[MAX_PATH*2]; - GetTempPath(sizeof(buff),buff); - strcat(buff,helpname); - HANDLE file=CreateFile(buff,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); - WriteFile(file,ptr,sz,&wrt,NULL); - CloseHandle(file); - HANDLE hlp=StartHelp(hDlg,"hh",buff); - if (hlp==NULL) hlp=StartHelp(hDlg,"iexplore",buff); - if (hlp==NULL) {hlp=StartHelp(hDlg,buff,NULL);} - for (int i=0;i<10;i++) {WaitForInputIdle(hlp,10000); Sleep(10);} - while (DeleteFile(buff)==FALSE) - {WaitForInputIdle(hlp,10000); Sleep(10);} - CloseHandle(hlp); - } - -static bool ModeWarning() - { - DEVMODE devmode; - devmode.dmSize=sizeof(DEVMODE); - EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&devmode); - return devmode.dmBitsPerPel!=16; - } - -int ResMessageBox(HWND hWnd, UINT idc, UINT flags) - { - char buff1[1024],buff2[256]; - HINSTANCE hInst=GetModuleHandle(NULL); - LoadString(hInst,idc,buff1,sizeof(buff1)); - LoadString(hInst,IDS_WINTITLE,buff2,sizeof(buff2)); - return MessageBox(hWnd,buff1,buff2,flags); - } - -int ResMessageBox2(HWND hWnd, UINT idc, UINT flags,...) - { - char buff1[1024],buff2[256],buff3[2048]; - va_list args; - va_start(args,flags); - HINSTANCE hInst=GetModuleHandle(NULL); - LoadString(hInst,idc,buff1,sizeof(buff1)); - LoadString(hInst,IDS_WINTITLE,buff2,sizeof(buff2)); - _vsnprintf(buff3,sizeof(buff3),buff1,args); - return MessageBox(hWnd,buff3,buff2,flags); - } - - - -#include "WAPlayer.h" -static WAPlayer GWinAmpPlayer; - -static bool FillListOfPlugins(WAPlayer &player, WAInputPlugin &inplug, void *context) -{ - HWND list=(HWND)context; - int i=ListBox_AddString(list,inplug.GetDescription()); - ListBox_SetItemData(list,i,(LPARAM)&inplug); - return true; -} - -static void UpdateListOfWinampPlugins(HWND okno) -{ - int len=GetWindowTextLength(GetDlgItem(okno,IDC_CESTANAPLUGINY)); - char *path=(char *)alloca(len+1); - GetWindowText(GetDlgItem(okno,IDC_CESTANAPLUGINY),path,len+1); - GWinAmpPlayer.LoadPlugins(path); - ListBox_ResetContent(GetDlgItem(okno,IDC_PLUGLIST)); - GWinAmpPlayer.EnumPlugins(FillListOfPlugins,(void *)GetDlgItem(okno,IDC_PLUGLIST)); -} - -static int WINAPI PosBrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lParam,LPARAM lpData) - { - const char *curpath=(const char *)lpData; - if (uMsg == BFFM_INITIALIZED) - { - if (curpath && curpath[0]) - { - ::SendMessage(hwnd,BFFM_SETSELECTION,TRUE,(LPARAM)((LPCSTR)curpath)); - ::SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)((LPCSTR)curpath)); - } - } - else if (uMsg == BFFM_SELCHANGED) - { - char buff[_MAX_PATH]; - if (SHGetPathFromIDList((LPITEMIDLIST)lParam,buff)) - { - ::SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)buff); - } - } - return 0; - }; - -static bool PathBrowser(HWND hWnd, char *path /* MAX_PATH size */) -{ - BROWSEINFO brw; - memset(&brw,0,sizeof(brw)); - brw.hwndOwner=hWnd; - brw.pidlRoot=NULL; - brw.pszDisplayName=path; - brw.lParam=(LPARAM)path; -#ifdef BIF_USENEWUI - brw.ulFlags= BIF_RETURNONLYFSDIRS |BIF_STATUSTEXT|BIF_USENEWUI ; -#else - brw.ulFlags= BIF_RETURNONLYFSDIRS |BIF_STATUSTEXT ; -#endif - brw.lpfn = (BFFCALLBACK)(PosBrowseCallbackProc); - LPITEMIDLIST il=SHBrowseForFolder( &brw ); - if (il==NULL) return false; - SHGetPathFromIDList(il,path); - IMalloc *shmalloc; - SHGetMalloc(&shmalloc); - shmalloc->Free(il); - if (path[0]==0) return false; - return true; -} - -static void BrowseCestaNaPluginy(HWND main, HWND control) -{ - int len=GetWindowTextLength(control); - len+=MAX_PATH; - char *path=(char *)alloca(len+1); - GetWindowText(control,path,len+1); - if (PathBrowser(main,path)) - { - SetWindowText(control,path); - UpdateListOfWinampPlugins(main); - } -} - -static void OnPlugVlastnosti(HWND hDlg) -{ - HWND list=GetDlgItem(hDlg,IDC_PLUGLIST); - int cursel=ListBox_GetCurSel(list); - if (cursel<0) - { - char buff[256]; - LoadString((HINSTANCE)GetWindowLong(hDlg,GWL_HINSTANCE),IDS_NICVYBRANO,buff,256); - MessageBox(hDlg,buff,0,MB_OK); - } - else - { - WAInputPlugin *p=(WAInputPlugin *)ListBox_GetItemData(list,cursel); - p->UIConfig(hDlg); - } - -} - -static LRESULT SubDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) - { - switch (msg) - { - case WM_NOTIFY: - { - int idCtrl = (int) wParam; - LPNMHDR pnmh = (LPNMHDR) lParam; - switch (idCtrl) - { - case IDC_GAMESPEED: - SetDlgItemInt(hDlg,IDC_GAMESPEEDINFO,SendDlgItemMessage(hDlg,IDC_GAMESPEED,TBM_GETPOS,0,0),FALSE);break; - default:return 0; - } - } - case WM_COMMAND: - { - BOOL tmp; - int idCtrl=LOWORD(wParam); - switch (idCtrl) - { - case IDC_WINDOWED: - tmp=IsDlgButtonChecked(hDlg,idCtrl)==BST_CHECKED; - if (tmp && ModeWarning()) - ResMessageBox(hDlg,IDS_SCREENBPPWARNING,MB_OK|MB_ICONINFORMATION); - EnableWindow(GetDlgItem(hDlg,IDC_ZOOM1),tmp); - EnableWindow(GetDlgItem(hDlg,IDC_ZOOM2),tmp); - EnableWindow(GetDlgItem(hDlg,IDC_ZOOM3),tmp); - break; - case IDC_GAMESPEEDDEFAULT: - SendDlgItemMessage(hDlg,IDC_GAMESPEED,TBM_SETPOS,1,20-6); - SendDlgItemMessage(hDlg,IDC_BATTLEACC,TBM_SETPOS,1,0);break; - case IDC_NOHUNGRY: - case IDC_DEBUGCONSOLE: - if (IsDlgButtonChecked(hDlg,idCtrl)==BST_CHECKED) - { - if (ResMessageBox(hDlg,IDS_CHEATWARNING1,MB_YESNO|MB_ICONQUESTION)!=IDYES || - ResMessageBox(hDlg,IDS_CHEATWARNING2,MB_OKCANCEL|MB_ICONINFORMATION)!=IDCANCEL || - ResMessageBox(hDlg,IDS_CHEATWARNING3,MB_RETRYCANCEL|MB_ICONEXCLAMATION)!=IDRETRY || - ResMessageBox(hDlg,IDS_CHEATWARNING4,MB_ABORTRETRYIGNORE|MB_ICONSTOP)!=IDIGNORE) - CheckDlgButton(hDlg,idCtrl,BST_UNCHECKED); - else - ResMessageBox(hDlg,IDS_CHEATWARNING5,MB_OK|MB_ICONEXCLAMATION); - } - - break; - - case IDC_CESTANAPLUGINY: - BrowseCestaNaPluginy(hDlg,GetDlgItem(hDlg,IDC_CESTANAPLUGINY)); - UpdateListOfWinampPlugins(hDlg); - break; - case IDC_PLUGVLASTNOSTI: - OnPlugVlastnosti(hDlg); - break; - case IDC_PLUGLIST: - if (HIWORD(wParam)==LBN_DBLCLK) OnPlugVlastnosti(hDlg); - break; - case IDC_PLUGINYNAPOVEDA: - { - if (konfigHelp) DestroyWindow(konfigHelp); - konfigHelp=(HWND)ShowRichView(hDlg,MAKEINTRESOURCE(IDR_WINAMPPLUGS),"RTF",false); - RECT rc1,rc2; - SystemParametersInfo(SPI_GETWORKAREA,0,&rc1,0); - GetWindowRect(konfigHelp,&rc2); - SetWindowPos(konfigHelp,NULL,rc1.right-rc2.right+rc2.left,0,0,0,SWP_NOSIZE|SWP_NOZORDER); - break; - } - case IDC_EXTRASHELP: - { - if (konfigHelp) DestroyWindow(konfigHelp); - konfigHelp=(HWND)ShowRichView(hDlg,MAKEINTRESOURCE(IDR_EXTRAS),"RTF",false); - RECT rc1,rc2; - SystemParametersInfo(SPI_GETWORKAREA,0,&rc1,0); - GetWindowRect(konfigHelp,&rc2); - SetWindowPos(konfigHelp,NULL,rc1.right-rc2.right+rc2.left,0,0,0,SWP_NOSIZE|SWP_NOZORDER); - break; - } - default:return 0; - } - } - case WM_MOUSEMOVE: - { - if (IsWindowVisible(handles[CFGCHEATS])) - { - EnableWindow(GetDlgItem(handles[CFGCHEATS],IDC_NOHUNGRY),FALSE); - EnableWindow(GetDlgItem(handles[CFGCHEATS],IDC_DEBUGCONSOLE),FALSE); - } - return 0; - } - default: return 0; - } - return 1; - } - - - -static void LoadSubDialog(HWND hParent, int pos, int uid, DLGPROC dlgproc) - { - RECT rc; - handles[pos]=CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(uid),hParent,dlgproc); - ShowWindow(handles[pos],SW_HIDE); - GetWindowRect(GetDlgItem(hParent,IDC_CLIENTDESK),&rc); - ScreenToClient(hParent,(POINT *)&rc.left); - ScreenToClient(hParent,(POINT *)&rc.right); - MoveWindow(handles[pos],rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,FALSE); - } - -static int GetCountOfMonitors() -{ - IDirect3D9 *dx=Direct3DCreate9(D3D_SDK_VERSION); - if (dx==NULL) return 1; - int num=dx->GetAdapterCount(); - dx->Release(); - return num; -} - -static void SetupDialog() - { - int num; - TSTR_LIST lst=read_config(SKELDALINI); - SendDlgItemMessage(handles[CFGGENERAL],IDC_GAMESPEED,TBM_SETRANGE,1,MAKELONG(1, 20)); - SendDlgItemMessage(handles[CFGGENERAL],IDC_BATTLEACC,TBM_SETRANGE,1,MAKELONG(0, 5)); - SendDlgItemMessage(handles[CFGSOUND],IDC_SNDMUSIC,TBM_SETRANGE,1,MAKELONG(0,127)); - SendDlgItemMessage(handles[CFGSOUND],IDC_SNDFX,TBM_SETRANGE,1,MAKELONG(0,255)); - CheckDlgButton(handles[CFGGENERAL],IDC_WINDOWED,(get_num_field(lst,"WINDOWED",&num)==0 && num==1)?BST_CHECKED:BST_UNCHECKED); - CheckDlgButton(handles[CFGGENERAL],IDC_PRELOAD,(get_num_field(lst,"PRELOAD",&num)==0 && num==1)?BST_CHECKED:BST_UNCHECKED); - CheckDlgButton(handles[CFGGENERAL],IDC_AUTOSAVE,(get_num_field(lst,"AUTOSAVE",&num)==0 && num==1)?BST_CHECKED:BST_UNCHECKED); - num=6;get_num_field(lst,"GAME_SPEED",&num); - num=20-num; - SendDlgItemMessage(handles[CFGGENERAL],IDC_GAMESPEED,TBM_SETPOS,1,num); - num=0;get_num_field(lst,"BATTLE_ACCEL",&num); - SendDlgItemMessage(handles[CFGGENERAL],IDC_BATTLEACC,TBM_SETPOS,1,num); - SetDlgItemInt(handles[CFGGENERAL],IDC_GAMESPEEDINFO,num,FALSE); - num=44100;get_num_field(lst,"SOUND_MIXFREQ",&num); - SetDlgItemInt(handles[CFGSOUND],IDC_MIXFREQ,num,FALSE); - num=127;get_num_field(lst,"MUSIC_VOLUME",&num); - SendDlgItemMessage(handles[CFGSOUND],IDC_SNDMUSIC,TBM_SETPOS,1,num); - num=255;get_num_field(lst,"SOUND_VOLUME",&num); - SendDlgItemMessage(handles[CFGSOUND],IDC_SNDFX,TBM_SETPOS,1,num); - CheckDlgButton(handles[CFGVIDEO],IDC_SKIPINTRO,(get_num_field(lst,"SKIP_INTRO",&num)==0 && num==1)?BST_CHECKED:BST_UNCHECKED); - CheckDlgButton(handles[CFGVIDEO],IDC_FULLRESVIDEO,(get_num_field(lst,"FULLRESVIDEO",&num)==0 && num==1)?BST_CHECKED:BST_UNCHECKED); - num=1;get_num_field(lst,"WINDOWEDZOOM",&num); - CheckRadioButton(handles[CFGGENERAL],IDC_ZOOM1,IDC_ZOOM3,IDC_ZOOM1+num-1); - num=0;get_num_field(lst,"MONITOR",&num); - CheckRadioButton(handles[CFGGENERAL],IDC_MON1,IDC_MON3,IDC_MON1+num); - const char *cestaNaPluginy=get_text_field(lst,"CESTA_PLUGINS"); - if (cestaNaPluginy==0) - { - char *cesta=AutodetectWinAmp(); - SetDlgItemText(handles[CFGSOUND],IDC_CESTANAPLUGINY,cesta); - free(cesta); - } - else - SetDlgItemText(handles[CFGSOUND],IDC_CESTANAPLUGINY,cestaNaPluginy); - UpdateListOfWinampPlugins(handles[CFGSOUND]); - int moncnt=GetCountOfMonitors(); - if (moncnt<3) EnableWindow(GetDlgItem(handles[CFGGENERAL],IDC_MON3),FALSE); - if (moncnt<2) EnableWindow(GetDlgItem(handles[CFGGENERAL],IDC_MON2),FALSE); - num=0;get_num_field(lst,"EXTRAS",&num); - for (int i=0;i<16;i++) - { - int p=1<1) SetDlgItemInt(handles[CFGCHEATS],IDC_CHEATPASSWORD,num,FALSE); - release_list(lst); - } - -static int RadioButtonChecked(HWND hWnd, int min, int max) -{ - for (int i=min;i<=max;i++) - { - if (IsDlgButtonChecked(hWnd,i)==BST_CHECKED) return i-min; - } - return -1; -} - -static void SaveKonfig(HWND hDlg) - { - TSTR_LIST lst=read_config(SKELDALINI); - add_field_num(&lst,"WINDOWED",IsDlgButtonChecked(handles[CFGGENERAL],IDC_WINDOWED)==BST_CHECKED); - add_field_num(&lst,"PRELOAD",IsDlgButtonChecked(handles[CFGGENERAL],IDC_PRELOAD)==BST_CHECKED); - add_field_num(&lst,"AUTOSAVE",IsDlgButtonChecked(handles[CFGGENERAL],IDC_AUTOSAVE)==BST_CHECKED); - add_field_num(&lst,"SKIP_INTRO",IsDlgButtonChecked(handles[CFGVIDEO],IDC_SKIPINTRO)==BST_CHECKED); - add_field_num(&lst,"FULLRESVIDEO",IsDlgButtonChecked(handles[CFGVIDEO],IDC_FULLRESVIDEO)==BST_CHECKED); - add_field_num(&lst,"DEBUG",IsDlgButtonChecked(handles[CFGCHEATS],IDC_DEBUGCONSOLE)==BST_CHECKED); - int mixfreq=GetDlgItemInt(handles[CFGSOUND],IDC_MIXFREQ,NULL,FALSE); - if (mixfreq<8000 || mixfreq>44100) - ResMessageBox(hDlg,IDS_MIXFREQINVALID,MB_OK|MB_ICONEXCLAMATION); - else - add_field_num(&lst,"SOUND_MIXFREQ",mixfreq); - add_field_num(&lst,"MUSIC_VOLUME",SendDlgItemMessage(handles[CFGSOUND],IDC_SNDMUSIC,TBM_GETPOS,0,0)); - add_field_num(&lst,"SOUND_VOLUME",SendDlgItemMessage(handles[CFGSOUND],IDC_SNDFX,TBM_GETPOS,0,0)); - add_field_num(&lst,"GAME_SPEED",20-SendDlgItemMessage(handles[CFGGENERAL],IDC_GAMESPEED,TBM_GETPOS,0,0)); - add_field_num(&lst,"BATTLE_ACCEL",SendDlgItemMessage(handles[CFGGENERAL],IDC_BATTLEACC,TBM_GETPOS,0,0)); - add_field_num(&lst,"WINDOWEDZOOM",RadioButtonChecked(handles[CFGGENERAL],IDC_ZOOM1,IDC_ZOOM3)+1); - add_field_num(&lst,"MONITOR",RadioButtonChecked(handles[CFGGENERAL],IDC_MON1,IDC_MON3)); - int acc=0; - for (int i=0;i<16;i++) - { - int p=1<1) add_field_num(&lst,"DEBUG",acc); - acc=GetWindowTextLength(GetDlgItem(handles[CFGSOUND],IDC_CESTANAPLUGINY)); - char *buff=(char *)alloca(acc+1); - GetWindowText(GetDlgItem(handles[CFGSOUND],IDC_CESTANAPLUGINY),buff,acc+1); - add_field_txt(&lst,"CESTA_PLUGINS",buff); - save_config(lst,SKELDALINI); - } - -static LRESULT KonfigProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) - { - switch (msg) - { - case WM_INITDIALOG: - LoadSubDialog(hDlg,CFGGENERAL,IDD_CFGGENERAL,(DLGPROC)SubDlgProc); - LoadSubDialog(hDlg,CFGSOUND,IDD_CFGSOUND,(DLGPROC)SubDlgProc); - LoadSubDialog(hDlg,CFGVIDEO,IDD_CFGVIDEO,(DLGPROC)NullProc); - LoadSubDialog(hDlg,CFGEXTRAS,IDD_CFGEXTRAS,(DLGPROC)SubDlgProc); - LoadSubDialog(hDlg,CFGCHEATS,IDD_CFGCHEATS,(DLGPROC)SubDlgProc); - { - for (int i=0;i<5;i++) - { - TCITEM item; - char buff[256]; - item.mask=TCIF_TEXT; - LoadString(GetModuleHandle(NULL),IDS_CFGGENERAL+i,buff,sizeof(buff)); - item.pszText=buff; - SendDlgItemMessage(hDlg,IDC_TAB,TCM_INSERTITEM,i,(LPARAM)&item); - } - ShowWindow(handles[0],SW_SHOW); - SetupDialog(); - } - konfigHelp=NULL; - break; - - case WM_NOTIFY: - { - LPNMHDR lpnmhdr = (LPNMHDR) lParam; - if (lpnmhdr->idFrom==IDC_TAB && lpnmhdr->code==TCN_SELCHANGE) - { - int cursel=TabCtrl_GetCurSel(GetDlgItem(hDlg,IDC_TAB)); - for (int i=0;i<5;i++) - ShowWindow(handles[i],i==cursel?SW_SHOW:SW_HIDE); - if (cursel==CFGCHEATS) - { - EnableWindow(GetDlgItem(handles[cursel],IDC_NOHUNGRY),TRUE); - EnableWindow(GetDlgItem(handles[cursel],IDC_DEBUGCONSOLE),TRUE); - } - } - break; - } - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDCANCEL: EndDialog(hDlg,0);break; - case IDOK: SaveKonfig(hDlg);EndDialog(hDlg,1);break; - } - return 1; - } - case WM_DESTROY: - konfigHelp=NULL; - break; - case WM_MOUSEMOVE: - { - if (IsWindowVisible(handles[CFGCHEATS])) - { - EnableWindow(GetDlgItem(handles[CFGCHEATS],IDC_NOHUNGRY),FALSE); - EnableWindow(GetDlgItem(handles[CFGCHEATS],IDC_DEBUGCONSOLE),FALSE); - } - return 0; - } - default: return 0; - } - return 1; - } - - -void OpenKonfig(HWND hParent) - { - DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_CFGTABDIALOG),hParent,(DLGPROC)KonfigProc,NULL); - GWinAmpPlayer.ClearList(); - } \ No newline at end of file diff --git a/Windows/konfig.h b/Windows/konfig.h deleted file mode 100644 index c2f620e..0000000 --- a/Windows/konfig.h +++ /dev/null @@ -1 +0,0 @@ -void OpenKonfig(HWND hParent); \ No newline at end of file diff --git a/Windows/logo.bmp b/Windows/logo.bmp deleted file mode 100644 index ac73d75..0000000 Binary files a/Windows/logo.bmp and /dev/null differ diff --git a/Windows/mem.h b/Windows/mem.h deleted file mode 100644 index d8396fe..0000000 --- a/Windows/mem.h +++ /dev/null @@ -1,2 +0,0 @@ -#include -#include \ No newline at end of file diff --git a/Windows/plugins.rtf b/Windows/plugins.rtf deleted file mode 100644 index e69de29..0000000 diff --git a/Windows/resource.h b/Windows/resource.h deleted file mode 100644 index 271db4c..0000000 --- a/Windows/resource.h +++ /dev/null @@ -1,139 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by Skeldal.rc -// -#define IDS_WINTITLE 1 -#define IDS_CFGGENERAL 100 -#define IDR_BOLDCZ 101 -#define IDS_CFGSOUND 101 -#define IDD_LADICIOKNO 102 -#define IDS_CFGVIDEO 102 -#define IDD_INPUTWINDOW 103 -#define IDS_CFGEXTRAS 103 -#define IDB_INITLOGO 104 -#define IDD_CFGSOUND 104 -#define IDS_CFGCHEATS 104 -#define IDD_CFGTABDIALOG 105 -#define IDS_NICVYBRANO 105 -#define IDD_CFGGENERAL 106 -#define IDD_CFGVIDEO 109 -#define IDD_CFGEXTRAS 111 -#define IDD_CFGCHEATS 112 -#define IDB_UVODNIPOZADI 113 -#define IDB_UVODNISELECT 114 -#define IDD_INSTALL 115 -#define IDI_MAINICON 117 -#define IDD_RTFVIEWER 122 -#define IDR_EXTRAS 124 -#define IDD_SELADV 128 -#define IDB_SELADVDLG 130 -#define IDR_WINAMPPLUGS 131 -#define IDD_DIALOG1 132 -#define IDD_LISTDIALOG 132 -#define IDS_CHEATWARNING1 200 -#define IDS_CHEATWARNING2 201 -#define IDS_CHEATWARNING3 202 -#define IDS_CHEATWARNING4 203 -#define IDS_CHEATWARNING5 204 -#define IDS_RICHEDMISSING 205 -#define IDS_MIXFREQINVALID 206 -#define IDS_SCREENBPPWARNING 207 -#define IDS_INSTALLFILTER 208 -#define IDS_INSTALLTITLE 209 -#define IDS_INSTALLPRENAME 210 -#define IDS_INSTALLCDFILE 211 -#define IDS_INSTALLCDTITLE 212 -#define IDS_INSTALLCDFILTER 213 -#define IDS_CREATEDIR 214 -#define IDS_NELZEVYTVORITSLOZKU 215 -#define IDS_INSTALLEDGAME 216 -#define IDS_INSTALLHDD 217 -#define IDS_INSTALLCHYBISOUBOR 218 -#define IDS_INSTALLTEXT1 219 -#define IDS_INSTALLTEXT2 220 -#define IDS_DEFAULTADV 221 -#define IDC_OUTPUT 1000 -#define IDC_ADVENCE 1001 -#define IDC_VALUE 1002 -#define IDC_CLEARMAP 1003 -#define IDC_RAISEDEATH 1004 -#define IDC_GOTO 1005 -#define IDC_PROMPT 1005 -#define IDC_IMMORTAL 1006 -#define IDC_TAB 1006 -#define IDC_RAISEMONSTER 1007 -#define IDC_WINDOWED 1007 -#define IDC_LOADITEM 1008 -#define IDC_PRELOAD 1008 -#define IDC_LOADMAP 1009 -#define IDC_AUTOSAVE 1009 -#define IDC_NETECNOST 1010 -#define IDC_OPENDOOR 1011 -#define IDC_GAMESPEED 1011 -#define IDC_PURGE 1012 -#define IDC_GAMESPEEDINFO 1012 -#define IDC_REFRESH 1013 -#define IDC_MIXFREQ 1013 -#define IDC_RELOADMOBILES 1014 -#define IDC_TAKEMONEY 1015 -#define IDC_UNAFFECT 1016 -#define IDC_SNDMUSIC 1016 -#define IDC_WEAPONSKILL 1017 -#define IDC_SNDFX 1017 -#define IDC_HEAL 1018 -#define IDC_SKIPINTRO 1019 -#define IDC_FULLRESVIDEO 1020 -#define IDC_DEBUGCONSOLE 1021 -#define IDC_NOHUNGRY 1022 -#define IDC_INSTALLED 1025 -#define IDC_RADIO2 1028 -#define IDC_EDIT2 1029 -#define IDC_BROWSEHDD 1030 -#define IDC_EDIT3 1031 -#define IDC_BROWSEHDD2 1032 -#define IDC_CHECK1 1033 -#define IDC_CREATELINK 1033 -#define IDC_INSTHLAVNI 1035 -#define IDC_INSTALLMUSIC 1036 -#define IDC_CLIENTDESK 1036 -#define IDC_INSTALLVIDEO 1037 -#define IDC_GAMESPEEDDEFAULT 1037 -#define IDC_EXTRASHELP 1038 -#define IDC_RICHEDIT 1040 -#define IDC_CHEATPASSWORD 1041 -#define IDC_BATTLEACC 1042 -#define IDC_LIST 1044 -#define IDC_ZOOM1 1045 -#define IDC_ZOOM2 1046 -#define IDC_ZOOM3 1047 -#define IDC_MON1 1048 -#define IDC_MON2 1049 -#define IDC_MON3 1050 -#define IDC_CESTANAPLUGINY 1050 -#define IDC_PLUGLIST 1051 -#define IDC_PLUGVLASTNOSTI 1052 -#define IDC_PLUGINYNAPOVEDA 1053 -#define IDC_HODNOTA 1054 -#define IDC_EXRANDOMBACKFIRES 2000 -#define IDC_EXRESPAWNMONSTERS 2001 -#define IDC_EXALTERNATEFIGHT 2002 -#define IDC_EXRECORVERITEMS 2003 -#define IDC_EXBAGEXTENDED 2005 -#define IDC_EXSHIELDBLOCKING 2006 -#define IDC_EXFASTTRADE 2007 -#define IDC_EXALWAYSMINIMAP 2008 -#define IDC_EXGROUPFLEE 2009 -#define IDC_EXAUTOOPENBOOK 2011 -#define IDC_EXAUTOSHOWRUNE 2012 -#define IDC_EXMOBDIAGONAL 2013 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 133 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1055 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/Windows/richview.cpp b/Windows/richview.cpp deleted file mode 100644 index 3b24e7e..0000000 --- a/Windows/richview.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include -#include -#include -#include -#include -#include - -static bool IsModal=false; - -static DWORD CALLBACK RtfViewerCallback( - DWORD dwCookie, // application-defined value - LPBYTE pbBuff, // pointer to a buffer - LONG cb, // number of bytes to read or write - LONG *pcb // pointer to number of bytes transferred -) - { - char **rdptr=(char **)dwCookie; - char *p=*rdptr; - *pcb=0; - while (*p && cb) - { - *pbBuff=*(LPBYTE)p; - pbBuff++; - p++; - cb--; - pcb[0]++; - } - *rdptr=p; - return 0; - } - - -static LRESULT RtfViewer(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) - { - switch (msg) - { - case WM_INITDIALOG: - { - HWND rtf=GetDlgItem(hWnd,IDC_RICHEDIT); - EDITSTREAM edstr; - char *rdptr=(char *)lParam; - edstr.dwCookie=(DWORD)(&rdptr); - edstr.pfnCallback=RtfViewerCallback; - SendMessage(rtf,EM_STREAMIN,SF_RTF|SFF_PLAINRTF,(LPARAM)(&edstr)); - break; - } - case WM_COMMAND: - if (LOWORD(wParam)==IDOK || LOWORD(wParam)==IDCANCEL) - { - if (IsModal) EndDialog(hWnd,LOWORD(wParam)); - else DestroyWindow(hWnd); - break; - } - return 0; - default: return 0; - } - return 1; - } - -DWORD ShowRichView(HWND hWnd, const char *resourceName, const char *resourceType, bool modal) - { - - HMODULE mod; - mod=GetModuleHandle("RICHED20.DLL"); - if (mod==NULL) mod=LoadLibrary("RICHED20.DLL"); - if (mod==NULL) - { - char buff[256]; - LoadString(GetModuleHandle(NULL),IDS_RICHEDMISSING,buff,sizeof(buff)); - MessageBox(hWnd,buff,NULL,MB_OK|MB_ICONEXCLAMATION); - return 0; - } - HRSRC rsrc=FindResource(GetModuleHandle(NULL),resourceName,resourceType); - if (rsrc==NULL) return 0; - HGLOBAL src=LoadResource(GetModuleHandle(NULL),rsrc); - const char *ptr=(const char *)LockResource(src); - DWORD res=0; - if (modal) - { - IsModal=true; - res=DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_RTFVIEWER),hWnd,(DLGPROC)RtfViewer,(LPARAM)ptr); - IsModal=false; - } - else - { - HWND hDlg=CreateDialogParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_RTFVIEWER),hWnd,(DLGPROC)RtfViewer,(LPARAM)ptr); - ShowWindow(hDlg,SW_SHOW); - res=(DWORD)hDlg; - } - return res; - } diff --git a/Windows/richview.h b/Windows/richview.h deleted file mode 100644 index 9b64dd2..0000000 --- a/Windows/richview.h +++ /dev/null @@ -1 +0,0 @@ -DWORD ShowRichView(HWND hWnd, const char *resourceName, const char *resourceType, bool modal); \ No newline at end of file diff --git a/Windows/seladv_male.bmp b/Windows/seladv_male.bmp deleted file mode 100644 index ff414cd..0000000 Binary files a/Windows/seladv_male.bmp and /dev/null differ diff --git a/Windows/skeldal_win.c b/Windows/skeldal_win.c deleted file mode 100644 index 03f41fd..0000000 --- a/Windows/skeldal_win.c +++ /dev/null @@ -1,199 +0,0 @@ -#include "skeldal_win.h" -#include "debug.h" -#include "resource.h" -#include - -void DXMouseTransform(unsigned short *x, unsigned short *y); -void DxLockBuffers(BOOL lock); - -HKL english_layout=NULL; - -#define WM_EXTRACHAR (WM_APP+100) - -#define MAX_KEYQUEUE 16 - -#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp)) -#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp)) - - -static uint32_t keyqueue[MAX_KEYQUEUE]; -static uint32_t keyqueuelen=0; -static char wheel_mapping[2]={'Q','I'}; -static BOOL noextra; -MS_EVENT win_mouseEvent; -static BOOL ActiveWindow=FALSE; -static DWORD WaitNext=0; - -void SetWheelMapping(char up, char down) -{ - wheel_mapping[0]=down; - wheel_mapping[1]=up; -} - -static void SetMouseEvent(MS_EVENT *event,UINT msg, WPARAM wParam,LPARAM lParam) - { - event->event_type=0; - switch (msg) - { - case WM_LBUTTONDOWN: event->event_type=0x2;break; - case WM_LBUTTONUP: event->event_type=0x4;break; - case WM_RBUTTONDOWN: event->event_type=0x8;break; - case WM_RBUTTONUP: event->event_type=0x10;break; - case WM_MBUTTONDOWN: event->event_type=0x20;break; - case WM_MBUTTONUP: event->event_type=0x40;break; - case WM_MOUSEMOVE: event->event_type=0x1;break; - } - event->x=GET_X_LPARAM(lParam); - event->y=GET_Y_LPARAM(lParam); - event->tl1=(wParam & MK_LBUTTON)!=0; - event->tl3=(wParam & MK_MBUTTON)!=0; - event->tl2=(wParam & MK_RBUTTON)!=0; - event->event=1; - DXMouseTransform(&event->x,&event->y); - } - -LRESULT GameMainWindowWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) - { - if (msg>=WM_MOUSEFIRST && msg<=WM_MOUSELAST && msg!=WM_MOUSEWHEEL) - { - SetMouseEvent(&win_mouseEvent,msg,wParam,lParam); - } - else switch (msg) - { - case WM_CREATE: - if (english_layout==NULL) english_layout=LoadKeyboardLayout("00000409",KLF_ACTIVATE); - DSReportWindowCreation(hWnd); - return TRUE; - case WM_ENDSESSION: - case WM_CLOSE: - DXCloseMode(); - exit(1); - break; - case WM_SETCURSOR: if (LOWORD(lParam)==HTCLIENT)SetCursor(NULL); - else return DefWindowProc(hWnd,msg,wParam,lParam);break; - return TRUE; - case WM_EXTRACHAR: if (noextra) {noextra=FALSE;break; } - case WM_CHAR: - if (keyqueuelen<16) - { - memmove(keyqueue,keyqueue+1,sizeof(*keyqueue)*keyqueuelen); - keyqueuelen++; - keyqueue[0]=MAKEWORD(wParam,HIWORD(lParam)); - } - if (msg==WM_CHAR) noextra=TRUE; - break; - case WM_MOUSEWHEEL: - { - short delta=HIWORD(wParam); - if (keyqueuelen<16) - { - memmove(keyqueue,keyqueue+1,sizeof(*keyqueue)*keyqueuelen); - keyqueuelen++; - keyqueue[0]=MAKEWORD(0,delta<0?wheel_mapping[0]:wheel_mapping[1]); - } - break; - } - case WM_ACTIVATE: - { - int fActive = LOWORD(wParam); - ActiveWindow=fActive!=WA_INACTIVE; - break; - } - case WM_PAINT: - { - PAINTSTRUCT ps; - BeginPaint(hWnd,&ps); - DXCopyRects64(0,0,DxGetResX(),DxGetResY()); - EndPaint(hWnd,&ps); - break; - } - case WM_RELOADMAP: - { - char buff[256]; - int sektor=wParam; - GlobalGetAtomName((ATOM)lParam,buff,256); - GlobalDeleteAtom((ATOM)lParam); - send_message(E_RELOADMAP,buff,sektor); - break; - } - - default: return DefWindowProc(hWnd,msg,wParam,lParam);break; - } - return 0; - } - - -void CheckMessageQueue() - { - MSG msg; - while (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) - { - TranslateMessage(&msg); - if (msg.message==WM_KEYDOWN) - { - PostMessage(msg.hwnd,WM_EXTRACHAR,0,msg.lParam); - } - DispatchMessage(&msg); - } - } - -void WaitMsgQueue() - { - WaitMessage(); - CheckMessageQueue(); - } - -uint32_t _bios_keybrd(int mode) - { -repeat: - if (keyqueuelen) - { - if (mode==_KEYBRD_READY) return 1; - if (mode==_KEYBRD_READ) {keyqueuelen--;return keyqueue[keyqueuelen];} - } - if (mode==_KEYBRD_READ) {WaitMsgQueue(); goto repeat;} - CheckMessageQueue(); - return keyqueuelen!=0; - } - -void task_terminating() - { - STOP(); - } - -void *LoadResourceFont(const char *name) - { - HINSTANCE hInst=GetModuleHandle(NULL); - HRSRC rsrc=FindResource(hInst,name,"SKELDAL_FONT"); - HGLOBAL glb=LoadResource(hInst,rsrc); - return LockResource(glb); - } - -void *LoadDefaultFont() - { - return LoadResourceFont(MAKEINTRESOURCE(IDR_BOLDCZ)); - } - - -void ShareCPU() -{ - DWORD curTime=GetTickCount(); - DWORD timeout=WaitNext - -#define BGSWITCHBIT 0x0020 - -#define SKELDALINI "WSKELDAL.INI" - -#ifdef __cplusplus -extern "C" - { -#endif - - -#define _KEYBRD_READY 0 -#define _KEYBRD_READ 1 - -#define TIMERSPEED 20; - -uint32_t _bios_keybrd(int mode); - - -LRESULT GameMainWindowWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - - -void CheckMessageQueue(); - -void DSReportWindowCreation(HWND hWindow); -char *AutodetectWinAmp(); - -#ifdef __cplusplus - } -#endif - -#define RGB888(r,g,b) ((unsigned short)((((r)<<8)&0xF800) | (((g)<<3) & 0x7C0) | ((b)>>3))) -#define RGB555(r,g,b) ((unsigned short)(((r)<<11) | (((g) & 0xF8)<<6) | (b))) -#define RGB555_ALPHA(r,g,b) ((unsigned short)(((r)<<11) | ((((g) & 0xF8) | 0x04)<<6) | (b))) - -#pragma warning (disable : 4244 4761 4133) - - -void *LoadDefaultFont(); -void *LoadResourceFont(const char *name); - -void ShareCPU(); -void SetWheelMapping(char up, char down); - - -//------------- BGRAPH DX wrapper ------------------- -#include "BGraph2Dx.h" - -#define WM_RELOADMAP (WM_APP+215) -#define E_RELOADMAP 40 - diff --git a/Windows/uvodni.bmp b/Windows/uvodni.bmp deleted file mode 100644 index da3bb77..0000000 Binary files a/Windows/uvodni.bmp and /dev/null differ diff --git a/Windows/uvodni.cpp b/Windows/uvodni.cpp deleted file mode 100644 index 5f556e7..0000000 --- a/Windows/uvodni.cpp +++ /dev/null @@ -1,322 +0,0 @@ -#include -#include -#include -#include "uvodni.h" -#include "resource.h" -#include "konfig.h" -#include "install.h" -#include -#include -#include "..\game\version.h" - - -#define UVODNIOKNOCLASS "Uvodni okno hry Brany Skeldalu@bredysoft" -#define SELPOSX 0 -#define SELPOSY 279 - -LRESULT UvodniWinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - -void RegistrujTriduOkna() - { - WNDCLASSEX cls; - memset(&cls,0,sizeof(cls)); - cls.cbSize=sizeof(cls); - cls.hCursor=LoadCursor(NULL,IDC_ARROW); - cls.hInstance=GetModuleHandle(NULL); - cls.hIcon=LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_MAINICON)); - cls.lpfnWndProc=(WNDPROC)UvodniWinProc; - cls.lpszClassName=UVODNIOKNOCLASS; - if (RegisterClassEx(&cls)==NULL) - { - MessageBox(NULL,"Nelze registrovat tridu okna",NULL,MB_OK|MB_ICONSTOP); - exit(-1); - } - } - -static HBITMAP pozadi; -static HBITMAP selpozadi; -static HDC pozadi_dc; -static HDC selpozadi_dc; -static HBITMAP pozadi_dc_old; -static HBITMAP selpozadi_dc_old; -static int exitstatus=0; - -static int GetSelection(HWND hWnd, DWORD pt,RECT *rcout) - { - POINT ptt; - BITMAP bmpi; - ptt.x=GET_X_LPARAM(pt); - ptt.y=GET_Y_LPARAM(pt); - ScreenToClient(hWnd,&ptt); - GetObject(selpozadi,sizeof(bmpi),&bmpi); - RECT rc; - rc.left=SELPOSX; - rc.top=SELPOSY; - rc.right=rc.left+bmpi.bmWidth; - rc.bottom=rc.top+bmpi.bmHeight; - for (int i=0;i<3;i++) - { - RECT rrc=rc; - rrc.top=rc.top+((rc.bottom-rc.top)*i)/3; - rrc.bottom=rc.top+((rc.bottom-rc.top)*(i+1))/3; - if (PtInRect(&rrc,ptt)) - { - if (rcout) *rcout=rrc; - return i; - } - } - return -1; - } - -static void UkazSelekci(HWND hWnd, HDC hDc, DWORD pt) - { - RECT rc; - int res=GetSelection(hWnd,pt,&rc); - if (res==-1) return; - BitBlt(hDc,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,selpozadi_dc,rc.left-SELPOSX,rc.top-SELPOSY,SRCCOPY); - } - -static HFONT vfont; - -static void ShowVersion(HDC dc) -{ - HFONT fnt=(HFONT )SelectObject(dc,vfont); - char ver[200]="Version: "VERSION; - int len=strlen(ver); - SIZE sz; - ::GetTextExtentPoint(dc,ver,len,&sz); - - SetTextColor(dc,RGB(255,255,255)); - SetBkMode(dc,TRANSPARENT); - TextOut(dc,630-sz.cx,450-sz.cy,ver,len); - SelectObject(dc,fnt); -} - -static LRESULT UvodniWinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) - { - static int lastsel; - static RECT lastselrect; - switch (msg) - { - case WM_CREATE: - { - HDC wdc=GetDC(hWnd); - pozadi=LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_UVODNIPOZADI)); - selpozadi=LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_UVODNISELECT)); - pozadi_dc=CreateCompatibleDC(wdc); - selpozadi_dc=CreateCompatibleDC(wdc); - ReleaseDC(hWnd,wdc); - pozadi_dc_old=(HBITMAP)SelectObject(pozadi_dc,pozadi); - selpozadi_dc_old=(HBITMAP)SelectObject(selpozadi_dc,selpozadi); - lastsel=-1; - if (_access(SKELDALINI,06)!=0) PostMessage(hWnd,WM_APP,0,0); - vfont=CreateFont(15,0,0,0,0,0,0,0,0,0,0,0,0,"Arial"); - return 1; - } - break; - case WM_PAINT: - { - PAINTSTRUCT ps; - HDC wdc=BeginPaint(hWnd,&ps); - BitBlt(wdc,0,0,640,480,pozadi_dc,0,0,SRCCOPY); - ShowVersion(wdc); - UkazSelekci(hWnd,wdc,GetMessagePos()); - EndPaint(hWnd,&ps); - } - break; - case WM_SETCURSOR: - if (lastsel!=-1) - SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(32649))); - else - SetCursor(LoadCursor(NULL, IDC_ARROW)); - break; - case WM_MOUSEMOVE: - { - RECT rc; - int p=GetSelection(hWnd,GetMessagePos(),&rc); - if (p!=lastsel) - { - InvalidateRect(hWnd,&rc,FALSE); - InvalidateRect(hWnd,&lastselrect,FALSE); - lastsel=p; - lastselrect=rc; - } - } - break; - case WM_CLOSE: - exitstatus=0; - DestroyWindow(hWnd); - break; - case WM_DESTROY: - SelectObject(pozadi_dc,pozadi_dc_old); - SelectObject(selpozadi_dc,selpozadi_dc_old); - DeleteObject(pozadi); - DeleteObject(selpozadi); - DeleteDC(pozadi_dc); - DeleteDC(selpozadi_dc); - PostQuitMessage(exitstatus); - DeleteObject(vfont); - break; - case WM_LBUTTONUP: - { - int p=GetSelection(hWnd,GetMessagePos(),NULL); - if (p!=-1) - { - switch (p) - { - case 2: exitstatus=0; DestroyWindow(hWnd);break; - case 0: exitstatus=1; DestroyWindow(hWnd);break; - case 1: OpenKonfig(hWnd);break; -// case 0: RunInstall(hWnd);break; - } - } - break; - } - case WM_APP: - if (RunInstall(hWnd)==FALSE) {exitstatus=0;DestroyWindow(hWnd);} - break; - default:return DefWindowProc(hWnd,msg,wParam,lParam); - } - return 1; - } - -extern "C" - { - - -char OtevriUvodniOkno() - { - RECT rc; - - char buff[256]; - - LoadString(GetModuleHandle(NULL),IDS_WINTITLE,buff,sizeof(buff)); - - InitCommonControls(); - - RegistrujTriduOkna(); - GetClientRect(GetDesktopWindow(),&rc); - rc.left=(rc.right-640)/2; - rc.top=(rc.bottom-480)/2; - - AdjustWindowRect(&rc,WS_OVERLAPPEDWINDOW,FALSE); - - HWND hOknoWnd=CreateWindow(UVODNIOKNOCLASS,buff,WS_OVERLAPPED|WS_SYSMENU|WS_VISIBLE|WS_MINIMIZEBOX|WS_BORDER,rc.left,rc.top,640,480,NULL,NULL,GetModuleHandle(NULL),NULL); - MSG msg; - while (GetMessage(&msg,0,0,0)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - UnregisterClass(UVODNIOKNOCLASS,GetModuleHandle(NULL)); - return msg.wParam==1; - } - -static void CreateAdvLink(char *advname) - { - char modname[MAX_PATH*4]; - char linkname[MAX_PATH*4]; - GetModuleFileName(NULL,modname,MAX_PATH*4); - CoInitialize(NULL); - SHGetSpecialFolderPath(NULL,linkname,CSIDL_DESKTOPDIRECTORY,TRUE); - strcat(linkname,"\\"); - strcat(linkname,advname); - strcat(linkname,".lnk"); - CreateLink(modname,linkname,"",advname); - } - - -static char selectedAdv[MAX_PATH]; -static LRESULT SelectAdventureDlg(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) - { - char temp[MAX_PATH]; - switch (msg) - { - case WM_INITDIALOG: - { - WIN32_FIND_DATA fdata; - HANDLE fnd=FindFirstFile("*.adv",&fdata); - selectedAdv[0]=0; - if (fnd!=INVALID_HANDLE_VALUE) - { - HWND lsbx=GetDlgItem(hDlg,IDC_LIST); - LoadString(GetModuleHandle(NULL),IDS_DEFAULTADV,temp,sizeof(temp)); - ListBox_AddString(lsbx,temp); - do ListBox_AddString(lsbx,fdata.cFileName); while (FindNextFile(fnd,&fdata)); - FindClose(fnd); - ListBox_SetCurSel(lsbx,0); - EnableWindow(GetDlgItem(hDlg,IDC_CREATELINK),0); - } - else - EndDialog(hDlg,IDOK); - } - break; - case WM_DRAWITEM: if (wParam==IDC_LIST) - { - LPDRAWITEMSTRUCT drawinfo=(LPDRAWITEMSTRUCT)lParam; - char *c; - if (drawinfo->itemState & ODS_SELECTED) - { - SetTextColor(drawinfo->hDC,GetSysColor(COLOR_HIGHLIGHTTEXT)); - SetBkColor(drawinfo->hDC,GetSysColor(COLOR_HIGHLIGHT)); - } - else - { - SetTextColor(drawinfo->hDC,GetSysColor(COLOR_WINDOWTEXT)); - SetBkColor(drawinfo->hDC,GetSysColor(COLOR_WINDOW)); - } - ListBox_GetText(drawinfo->hwndItem,drawinfo->itemID,temp); - c=strrchr(temp,'.'); - if (c) *c=0; - ExtTextOut(drawinfo->hDC,0,0,ETO_OPAQUE,&drawinfo->rcItem,"",0,NULL); - DrawText(drawinfo->hDC,temp,strlen(temp),&drawinfo->rcItem,DT_SINGLELINE|DT_VCENTER|DT_CENTER|DT_NOPREFIX); - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDOK: - { - HWND lsbx=GetDlgItem(hDlg,IDC_LIST); - int cursel=ListBox_GetCurSel(lsbx); - if (cursel!=0) - { - ListBox_GetText(lsbx,cursel,selectedAdv); - if (IsDlgButtonChecked(hDlg,IDC_CREATELINK) & BST_CHECKED) - CreateAdvLink(selectedAdv); - } - EndDialog(hDlg,IDOK); - } - break; - case IDCANCEL: - EndDialog(hDlg,IDCANCEL); - break; - case IDC_LIST: - if (HIWORD(wParam)==LBN_DBLCLK) - PostMessage(hDlg,WM_COMMAND,IDOK,0); - if (HIWORD(wParam)==LBN_SELCHANGE) - EnableWindow(GetDlgItem(hDlg,IDC_CREATELINK),ListBox_GetCurSel(GetDlgItem(hDlg,IDC_LIST))!=0); - break; - - default:return 0; - } - break; - default: return 0; - } - return 1; - } - -char SelectAdventure() - { - int ret=DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_SELADV), NULL, (DLGPROC)SelectAdventureDlg); - if (ret==IDCANCEL) exit(0); - if (selectedAdv[0]==0) return 0; - return 1; - } - -char *GetSelectedAdventure() - { - return selectedAdv; - } - - } diff --git a/Windows/uvodni.h b/Windows/uvodni.h deleted file mode 100644 index ccbd839..0000000 --- a/Windows/uvodni.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -char OtevriUvodniOkno(); -char SelectAdventure(); -char *GetSelectedAdventure(); - -#ifdef __cplusplus - } -#endif \ No newline at end of file diff --git a/Windows/uvodni_sel.bmp b/Windows/uvodni_sel.bmp deleted file mode 100644 index afdcfa4..0000000 Binary files a/Windows/uvodni_sel.bmp and /dev/null differ diff --git a/Windows/wa_ipc.h b/Windows/wa_ipc.h deleted file mode 100644 index 76f891b..0000000 --- a/Windows/wa_ipc.h +++ /dev/null @@ -1,1028 +0,0 @@ - /* -** Copyright (C) 2003 Nullsoft, Inc. -** -** This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held -** liable for any damages arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, including commercial applications, and to -** alter it and redistribute it freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. -** If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -** -** 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -** -** 3. This notice may not be removed or altered from any source distribution. -** -*/ - -#ifndef _WA_IPC_H_ -#define _WA_IPC_H_ - -/* -** This is the modern replacement for the classic 'frontend.h'. Most of these -** updates are designed for in-process use, i.e. from a plugin. -** -*/ - -/* message used to sent many messages to winamp's main window. -** most all of the IPC_* messages involve sending the message in the form of: -** result = SendMessage(hwnd_winamp,WM_WA_IPC,(parameter),IPC_*); -*/ -#define WM_WA_IPC WM_USER -/* but some of them use WM_COPYDATA. be afraid. -*/ - -#define IPC_GETVERSION 0 -/* int version = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETVERSION); -** -** Version will be 0x20yx for winamp 2.yx. versions previous to Winamp 2.0 -** typically (but not always) use 0x1zyx for 1.zx versions. Weird, I know. -*/ - -#define IPC_GETREGISTEREDVERSION 770 - - -typedef struct { - char *filename; - char *title; - int length; -} enqueueFileWithMetaStruct; // send this to a IPC_PLAYFILE in a non WM_COPYDATA, -// and you get the nice desired result. if title is NULL, it is treated as a "thing", -// otherwise it's assumed to be a file (for speed) - -#define IPC_PLAYFILE 100 // dont be fooled, this is really the same as enqueufile -#define IPC_ENQUEUEFILE 100 -/* sent as a WM_COPYDATA, with IPC_PLAYFILE as the dwData, and the string to play -** as the lpData. Just enqueues, does not clear the playlist or change the playback -** state. -*/ - - -#define IPC_DELETE 101 -#define IPC_DELETE_INT 1101 // don't use this, it's used internally by winamp when - // dealing with some lame explorer issues. -/* SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_DELETE); -** Use IPC_DELETE to clear Winamp's internal playlist. -*/ - - -#define IPC_STARTPLAY 102 // starts playback. almost like hitting play in Winamp. -#define IPC_STARTPLAY_INT 1102 // used internally, don't bother using it (won't be any fun) - - -#define IPC_CHDIR 103 -/* sent as a WM_COPYDATA, with IPC_CHDIR as the dwData, and the directory to change to -** as the lpData. -*/ - - -#define IPC_ISPLAYING 104 -/* int res = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_ISPLAYING); -** If it returns 1, it is playing. if it returns 3, it is paused, -** if it returns 0, it is not playing. -*/ - - -#define IPC_GETOUTPUTTIME 105 -/* int res = SendMessage(hwnd_winamp,WM_WA_IPC,mode,IPC_GETOUTPUTTIME); -** returns the position in milliseconds of the current track (mode = 0), -** or the track length, in seconds (mode = 1). Returns -1 if not playing or error. -*/ - - -#define IPC_JUMPTOTIME 106 -/* (requires Winamp 1.60+) -** SendMessage(hwnd_winamp,WM_WA_IPC,ms,IPC_JUMPTOTIME); -** IPC_JUMPTOTIME sets the position in milliseconds of the -** current song (approximately). -** Returns -1 if not playing, 1 on eof, or 0 if successful -*/ - -#define IPC_GETMODULENAME 109 -#define IPC_EX_ISRIGHTEXE 666 -/* usually shouldnt bother using these, but here goes: -** send a WM_COPYDATA with IPC_GETMODULENAME, and an internal -** flag gets set, which if you send a normal WM_WA_IPC message with -** IPC_EX_ISRIGHTEXE, it returns whether or not that filename -** matches. lame, I know. -*/ - -#define IPC_WRITEPLAYLIST 120 -/* (requires Winamp 1.666+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_WRITEPLAYLIST); -** -** IPC_WRITEPLAYLIST writes the current playlist to \\Winamp.m3u, -** and returns the current playlist position. -** Kinda obsoleted by some of the 2.x new stuff, but still good for when -** using a front-end (instead of a plug-in) -*/ - - -#define IPC_SETPLAYLISTPOS 121 -/* (requires Winamp 2.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,position,IPC_SETPLAYLISTPOS) -** IPC_SETPLAYLISTPOS sets the playlist position to 'position'. It -** does not change playback or anything, it just sets position, and -** updates the view if necessary -*/ - - -#define IPC_SETVOLUME 122 -/* (requires Winamp 2.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,volume,IPC_SETVOLUME); -** IPC_SETVOLUME sets the volume of Winamp (from 0-255). -*/ - - -#define IPC_SETPANNING 123 -/* (requires Winamp 2.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,panning,IPC_SETPANNING); -** IPC_SETPANNING sets the panning of Winamp (from 0 (left) to 255 (right)). -*/ - - -#define IPC_GETLISTLENGTH 124 -/* (requires Winamp 2.0+) -** int length = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLISTLENGTH); -** IPC_GETLISTLENGTH returns the length of the current playlist, in -** tracks. -*/ - - -#define IPC_GETLISTPOS 125 -/* (requires Winamp 2.05+) -** int pos=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLISTPOS); -** IPC_GETLISTPOS returns the playlist position. A lot like IPC_WRITEPLAYLIST -** only faster since it doesn't have to write out the list. Heh, silly me. -*/ - - -#define IPC_GETINFO 126 -/* (requires Winamp 2.05+) -** int inf=SendMessage(hwnd_winamp,WM_WA_IPC,mode,IPC_GETINFO); -** IPC_GETINFO returns info about the current playing song. The value -** it returns depends on the value of 'mode'. -** Mode Meaning -** ------------------ -** 0 Samplerate (i.e. 44100) -** 1 Bitrate (i.e. 128) -** 2 Channels (i.e. 2) -** 3 (5+) Video LOWORD=w HIWORD=h -** 4 (5+) > 65536, string (video description) -*/ - - -#define IPC_GETEQDATA 127 -/* (requires Winamp 2.05+) -** int data=SendMessage(hwnd_winamp,WM_WA_IPC,pos,IPC_GETEQDATA); -** IPC_GETEQDATA queries the status of the EQ. -** The value returned depends on what 'pos' is set to: -** Value Meaning -** ------------------ -** 0-9 The 10 bands of EQ data. 0-63 (+20db - -20db) -** 10 The preamp value. 0-63 (+20db - -20db) -** 11 Enabled. zero if disabled, nonzero if enabled. -** 12 Autoload. zero if disabled, nonzero if enabled. -*/ - - -#define IPC_SETEQDATA 128 -/* (requires Winamp 2.05+) -** SendMessage(hwnd_winamp,WM_WA_IPC,pos,IPC_GETEQDATA); -** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_SETEQDATA); -** IPC_SETEQDATA sets the value of the last position retrieved -** by IPC_GETEQDATA. This is pretty lame, and we should provide -** an extended version that lets you do a MAKELPARAM(pos,value). -** someday... - - new (2.92+): - if the high byte is set to 0xDB, then the third byte specifies - which band, and the bottom word specifies the value. -*/ - -#define IPC_ADDBOOKMARK 129 -/* (requires Winamp 2.4+) -** Sent as a WM_COPYDATA, using IPC_ADDBOOKMARK, adds the specified -** file/url to the Winamp bookmark list. -*/ -/* -In winamp 5+, we use this as a normal WM_WA_IPC and the string: - - "filename\0title\0" - - to notify the library/bookmark editor that a bookmark -was added. Note that using this message in this context does not -actually add the bookmark. -do not use :) -*/ - - -#define IPC_INSTALLPLUGIN 130 -/* not implemented, but if it was you could do a WM_COPYDATA with -** a path to a .wpz, and it would install it. -*/ - - -#define IPC_RESTARTWINAMP 135 -/* (requires Winamp 2.2+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_RESTARTWINAMP); -** IPC_RESTARTWINAMP will restart Winamp (isn't that obvious ? :) -*/ - - -#define IPC_ISFULLSTOP 400 -/* (requires winamp 2.7+ I think) -** ret=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_ISFULLSTOP); -** useful for when you're an output plugin, and you want to see -** if the stop/close is a full stop, or just between tracks. -** returns nonzero if it's full, zero if it's just a new track. -*/ - - -#define IPC_INETAVAILABLE 242 -/* (requires Winamp 2.05+) -** val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_INETAVAILABLE); -** IPC_INETAVAILABLE will return 1 if the Internet connection is available for Winamp. -*/ - - -#define IPC_UPDTITLE 243 -/* (requires Winamp 2.2+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_UPDTITLE); -** IPC_UPDTITLE will ask Winamp to update the informations about the current title. -*/ - - -#define IPC_REFRESHPLCACHE 247 -/* (requires Winamp 2.2+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_REFRESHPLCACHE); -** IPC_REFRESHPLCACHE will flush the playlist cache buffer. -** (send this if you want it to go refetch titles for tracks) -*/ - - -#define IPC_GET_SHUFFLE 250 -/* (requires Winamp 2.4+) -** val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_SHUFFLE); -** -** IPC_GET_SHUFFLE returns the status of the Shuffle option (1 if set) -*/ - - -#define IPC_GET_REPEAT 251 -/* (requires Winamp 2.4+) -** val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_REPEAT); -** -** IPC_GET_REPEAT returns the status of the Repeat option (1 if set) -*/ - - -#define IPC_SET_SHUFFLE 252 -/* (requires Winamp 2.4+) -** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_SET_SHUFFLE); -** -** IPC_SET_SHUFFLE sets the status of the Shuffle option (1 to turn it on) -*/ - - -#define IPC_SET_REPEAT 253 -/* (requires Winamp 2.4+) -** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_SET_REPEAT); -** -** IPC_SET_REPEAT sets the status of the Repeat option (1 to turn it on) -*/ - - -#define IPC_ENABLEDISABLE_ALL_WINDOWS 259 // 0xdeadbeef to disable -/* (requires Winamp 2.9+) -** SendMessage(hwnd_winamp,WM_WA_IPC,enable?0:0xdeadbeef,IPC_MBOPENREAL); -** sending with 0xdeadbeef as the param disables all winamp windows, -** any other values will enable all winamp windows. -*/ - - -#define IPC_GETWND 260 -/* (requires Winamp 2.9+) -** HWND h=SendMessage(hwnd_winamp,WM_WA_IPC,IPC_GETWND_xxx,IPC_GETWND); -** returns the HWND of the window specified. -*/ - #define IPC_GETWND_EQ 0 // use one of these for the param - #define IPC_GETWND_PE 1 - #define IPC_GETWND_MB 2 - #define IPC_GETWND_VIDEO 3 -#define IPC_ISWNDVISIBLE 261 // same param as IPC_GETWND - - - - -/************************************************************************ -***************** in-process only (WE LOVE PLUGINS) -************************************************************************/ - - -#define IPC_SETSKIN 200 -/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)"skinname",IPC_SETSKIN); -** IPC_SETSKIN sets the current skin to "skinname". Note that skinname -** can be the name of a skin, a skin .zip file, with or without path. -** If path isn't specified, the default search path is the winamp skins -** directory. -*/ - - -#define IPC_GETSKIN 201 -/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)skinname_buffer,IPC_GETSKIN); -** IPC_GETSKIN puts the directory where skin bitmaps can be found -** into skinname_buffer. -** skinname_buffer must be MAX_PATH characters in length. -** When using a .zip'd skin file, it'll return a temporary directory -** where the ZIP was decompressed. -*/ - - -#define IPC_EXECPLUG 202 -/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)"vis_file.dll",IPC_EXECPLUG); -** IPC_EXECPLUG executes a visualization plug-in pointed to by WPARAM. -** the format of this string can be: -** "vis_whatever.dll" -** "vis_whatever.dll,0" // (first mod, file in winamp plug-in dir) -** "C:\\dir\\vis_whatever.dll,1" -*/ - - -#define IPC_GETPLAYLISTFILE 211 -/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) -** char *name=SendMessage(hwnd_winamp,WM_WA_IPC,index,IPC_GETPLAYLISTFILE); -** IPC_GETPLAYLISTFILE gets the filename of the playlist entry [index]. -** returns a pointer to it. returns NULL on error. -*/ - - -#define IPC_GETPLAYLISTTITLE 212 -/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) -** char *name=SendMessage(hwnd_winamp,WM_WA_IPC,index,IPC_GETPLAYLISTTITLE); -** -** IPC_GETPLAYLISTTITLE gets the title of the playlist entry [index]. -** returns a pointer to it. returns NULL on error. -*/ - - -#define IPC_GETHTTPGETTER 240 -/* retrieves a function pointer to a HTTP retrieval function. -** if this is unsupported, returns 1 or 0. -** the function should be: -** int (*httpRetrieveFile)(HWND hwnd, char *url, char *file, char *dlgtitle); -** if you call this function, with a parent window, a URL, an output file, and a dialog title, -** it will return 0 on successful download, 1 on error. -*/ - - -#define IPC_MBOPEN 241 -/* (requires Winamp 2.05+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_MBOPEN); -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)url,IPC_MBOPEN); -** IPC_MBOPEN will open a new URL in the minibrowser. if url is NULL, it will open the Minibrowser window. -*/ - - - -#define IPC_CHANGECURRENTFILE 245 -/* (requires Winamp 2.05+) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)file,IPC_CHANGECURRENTFILE); -** IPC_CHANGECURRENTFILE will set the current playlist item. -*/ - - -#define IPC_GETMBURL 246 -/* (requires Winamp 2.2+) -** char buffer[4096]; // Urls can be VERY int32_t -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)buffer,IPC_GETMBURL); -** IPC_GETMBURL will retrieve the current Minibrowser URL into buffer. -** buffer must be at least 4096 bytes int32_t. -*/ - - -#define IPC_MBBLOCK 248 -/* (requires Winamp 2.4+) -** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_MBBLOCK); -** -** IPC_MBBLOCK will block the Minibrowser from updates if value is set to 1 -*/ - -#define IPC_MBOPENREAL 249 -/* (requires Winamp 2.4+) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)url,IPC_MBOPENREAL); -** -** IPC_MBOPENREAL works the same as IPC_MBOPEN except that it will works even if -** IPC_MBBLOCK has been set to 1 -*/ - -#define IPC_ADJUST_OPTIONSMENUPOS 280 -/* (requires Winamp 2.9+) -** int newpos=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)adjust_offset,IPC_ADJUST_OPTIONSMENUPOS); -** moves where winamp expects the Options menu in the main menu. Useful if you wish to insert a -** menu item above the options/skins/vis menus. -*/ - -#define IPC_GET_HMENU 281 -/* (requires Winamp 2.9+) -** HMENU hMenu=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)0,IPC_GET_HMENU); -** values for data: -** 0 : main popup menu -** 1 : main menubar file menu -** 2 : main menubar options menu -** 3 : main menubar windows menu -** 4 : main menubar help menu -** other values will return NULL. -*/ - -#define IPC_GET_EXTENDED_FILE_INFO 290 //pass a pointer to the following struct in wParam -#define IPC_GET_EXTENDED_FILE_INFO_HOOKABLE 296 -/* (requires Winamp 2.9+) -** to use, create an extendedFileInfoStruct, point the values filename and metadata to the -** filename and metadata field you wish to query, and ret to a buffer, with retlen to the -** length of that buffer, and then SendMessage(hwnd_winamp,WM_WA_IPC,&struct,IPC_GET_EXTENDED_FILE_INFO); -** the results should be in the buffer pointed to by ret. -** returns 1 if the decoder supports a getExtendedFileInfo method -*/ -typedef struct { - char *filename; - char *metadata; - char *ret; - int retlen; -} extendedFileInfoStruct; - -#define IPC_GET_BASIC_FILE_INFO 291 //pass a pointer to the following struct in wParam -typedef struct { - char *filename; - - int quickCheck; // set to 0 to always get, 1 for quick, 2 for default (if 2, quickCheck will be set to 0 if quick wasnot used) - - // filled in by winamp - int length; - char *title; - int titlelen; -} basicFileInfoStruct; - -#define IPC_GET_EXTLIST 292 //returns doublenull delimited. GlobalFree() it when done. if data is 0, returns raw extlist, if 1, returns something suitable for getopenfilename - -#define IPC_INFOBOX 293 -typedef struct { - HWND parent; - char *filename; -} infoBoxParam; - -#define IPC_SET_EXTENDED_FILE_INFO 294 //pass a pointer to the a extendedFileInfoStruct in wParam -/* (requires Winamp 2.9+) -** to use, create an extendedFileInfoStruct, point the values filename and metadata to the -** filename and metadata field you wish to write in ret. (retlen is not used). and then -** SendMessage(hwnd_winamp,WM_WA_IPC,&struct,IPC_SET_EXTENDED_FILE_INFO); -** returns 1 if the metadata is supported -** Call IPC_WRITE_EXTENDED_FILE_INFO once you're done setting all the metadata you want to update -*/ - -#define IPC_WRITE_EXTENDED_FILE_INFO 295 -/* (requires Winamp 2.9+) -** writes all the metadata set thru IPC_SET_EXTENDED_FILE_INFO to the file -** returns 1 if the file has been successfully updated, 0 if error -*/ - -#define IPC_FORMAT_TITLE 297 -typedef struct -{ - char *spec; // NULL=default winamp spec - void *p; - - char *out; - int out_len; - - char * (*TAGFUNC)(char * tag, void * p); //return 0 if not found - void (*TAGFREEFUNC)(char * tag,void * p); -} waFormatTitle; - -#define IPC_GETUNCOMPRESSINTERFACE 331 -/* returns a function pointer to uncompress(). -** int (*uncompress)(unsigned char *dest, uint32_t *destLen, const unsigned char *source, uint32_t sourceLen); -** right out of zlib, useful for decompressing zlibbed data. -** if you pass the parm of 0x10100000, it will return a wa_inflate_struct * to an inflate API. -*/ - -typedef struct { - int (*inflateReset)(void *strm); - int (*inflateInit_)(void *strm,const char *version, int stream_size); - int (*inflate)(void *strm, int flush); - int (*inflateEnd)(void *strm); - uint32_t (*crc32)(uint32_t crc, const unsigned char *buf, unsigned int len); -} wa_inflate_struct; - - -#define IPC_ADD_PREFS_DLG 332 -#define IPC_REMOVE_PREFS_DLG 333 -/* (requires Winamp 2.9+) -** to use, allocate a prefsDlgRec structure (either on the heap or some global -** data, but NOT on the stack), initialze the members: -** hInst to the DLL instance where the resource is located -** dlgID to the ID of the dialog, -** proc to the window procedure for the dialog -** name to the name of the prefs page in the prefs. -** where to 0 (eventually we may add more options) -** then, SendMessage(hwnd_winamp,WM_WA_IPC,&prefsRec,IPC_ADD_PREFS_DLG); -** -** you can also IPC_REMOVE_PREFS_DLG with the address of the same prefsRec, -** but you shouldn't really ever have to. -** -*/ -#define IPC_OPENPREFSTOPAGE 380 // pass an id of a builtin page, or a &prefsDlgRec of prefs page to open - -typedef struct _prefsDlgRec { - HINSTANCE hInst; - int dlgID; - void *proc; - - char *name; - int where; // 0 for options, 1 for plugins, 2 for skins, 3 for bookmarks, 4 for prefs - - - int _id; - struct _prefsDlgRec *next; -} prefsDlgRec; - - -#define IPC_GETINIFILE 334 // returns a pointer to winamp.ini -#define IPC_GETINIDIRECTORY 335 // returns a pointer to the directory to put config files in (if you dont want to use winamp.ini) - -#define IPC_SPAWNBUTTONPOPUP 361 // param = -// 0 = eject -// 1 = previous -// 2 = next -// 3 = pause -// 4 = play -// 5 = stop - -#define IPC_OPENURLBOX 360 // pass a HWND to a parent, returns a HGLOBAL that needs to be freed with GlobalFree(), if successful -#define IPC_OPENFILEBOX 362 // pass a HWND to a parent -#define IPC_OPENDIRBOX 363 // pass a HWND to a parent - -// pass an HWND to a parent. call this if you take over the whole UI so that the dialogs are not appearing on the -// bottom right of the screen since the main winamp window is at 3000x3000, call again with NULL to reset -#define IPC_SETDIALOGBOXPARENT 364 - - - -// pass 0 for a copy of the skin HBITMAP -// pass 1 for name of font to use for playlist editor likeness -// pass 2 for font charset -// pass 3 for font size -#define IPC_GET_GENSKINBITMAP 503 - - -#define IPC_GET_EMBEDIF 505 // pass an embedWindowState -// returns an HWND embedWindow(embedWindowState *); if the data is NULL, otherwise returns the HWND directly -typedef struct -{ - HWND me; //hwnd of the window - - int flags; - - RECT r; - - void *user_ptr; // for application use - - int extra_data[64]; // for internal winamp use -} embedWindowState; - -#define EMBED_FLAGS_NORESIZE 1 // set this bit in embedWindowState.flags to keep window from being resizable -#define EMBED_FLAGS_NOTRANSPARENCY 2 // set this bit in embedWindowState.flags to make gen_ff turn transparency off for this wnd - - -#define IPC_EMBED_ENUM 532 -typedef struct embedEnumStruct -{ - int (*enumProc)(embedWindowState *ws, struct embedEnumStruct *param); // return 1 to abort - int user_data; // or more :) -} embedEnumStruct; - // pass - -#define IPC_EMBED_ISVALID 533 - -#define IPC_CONVERTFILE 506 -/* (requires Winamp 2.92+) -** Converts a given file to a different format (PCM, MP3, etc...) -** To use, pass a pointer to a waFileConvertStruct struct -** This struct can be either on the heap or some global -** data, but NOT on the stack. At least, until the conversion is done. -** -** eg: SendMessage(hwnd_winamp,WM_WA_IPC,&myConvertStruct,IPC_CONVERTFILE); -** -** Return value: -** 0: Can't start the conversion. Look at myConvertStruct->error for details. -** 1: Conversion started. Status messages will be sent to the specified callbackhwnd. -** Be sure to call IPC_CONVERTFILE_END when your callback window receives the -** IPC_CB_CONVERT_DONE message. -*/ -typedef struct -{ - char *sourcefile; // "c:\\source.mp3" - char *destfile; // "c:\\dest.pcm" - int destformat[8]; // like 'PCM ',srate,nch,bps - HWND callbackhwnd; // window that will receive the IPC_CB_CONVERT notification messages - - //filled in by winamp.exe - char *error; //if IPC_CONVERTFILE returns 0, the reason will be here - - int bytes_done; //you can look at both of these values for speed statistics - int bytes_total; - int bytes_out; - - int killswitch; // don't set it manually, use IPC_CONVERTFILE_END - int extra_data[64]; // for internal winamp use -} convertFileStruct; - -#define IPC_CONVERTFILE_END 507 -/* (requires Winamp 2.92+) -** Stop/ends a convert process started from IPC_CONVERTFILE -** You need to call this when you receive the IPC_CB_CONVERTDONE message or when you -** want to abort a conversion process -** -** eg: SendMessage(hwnd_winamp,WM_WA_IPC,&myConvertStruct,IPC_CONVERTFILE_END); -** -** No return value -*/ - -typedef struct { - HWND hwndParent; - int format; - - //filled in by winamp.exe - HWND hwndConfig; - int extra_data[8]; -} convertConfigStruct; -#define IPC_CONVERT_CONFIG 508 -#define IPC_CONVERT_CONFIG_END 509 - -typedef struct -{ - void (*enumProc)(int user_data, const char *desc, int fourcc); - int user_data; -} converterEnumFmtStruct; -#define IPC_CONVERT_CONFIG_ENUMFMTS 510 -/* (requires Winamp 2.92+) -*/ - - -typedef struct -{ - char cdletter; - char *playlist_file; - HWND callback_hwnd; - - //filled in by winamp.exe - char *error; -} burnCDStruct; -#define IPC_BURN_CD 511 -/* (requires Winamp 5.0+) -*/ - -typedef struct -{ - convertFileStruct *cfs; - int priority; -} convertSetPriority; -#define IPC_CONVERT_SET_PRIORITY 512 - -typedef struct -{ - char *filename; - char *title; // 2048 bytes - int length; - int force_useformatting; // can set this to 1 if you want to force a url to use title formatting shit -} waHookTitleStruct; -// return TRUE if you hook this -#define IPC_HOOK_TITLES 850 - -#define IPC_GETSADATAFUNC 800 -// 0: returns a char *export_sa_get() that returns 150 bytes of data -// 1: returns a export_sa_setreq(int want); - -#define IPC_ISMAINWNDVISIBLE 900 - - -#define IPC_SETPLEDITCOLORS 920 -typedef struct -{ - int numElems; - int *elems; - HBITMAP bm; // set if you want to override -} waSetPlColorsStruct; - - -// the following IPC use waSpawnMenuParms as parameter -#define IPC_SPAWNEQPRESETMENU 933 -#define IPC_SPAWNFILEMENU 934 //menubar -#define IPC_SPAWNOPTIONSMENU 935 //menubar -#define IPC_SPAWNWINDOWSMENU 936 //menubar -#define IPC_SPAWNHELPMENU 937 //menubar -#define IPC_SPAWNPLAYMENU 938 //menubar -#define IPC_SPAWNPEFILEMENU 939 //menubar -#define IPC_SPAWNPEPLAYLISTMENU 940 //menubar -#define IPC_SPAWNPESORTMENU 941 //menubar -#define IPC_SPAWNPEHELPMENU 942 //menubar -#define IPC_SPAWNMLFILEMENU 943 //menubar -#define IPC_SPAWNMLVIEWMENU 944 //menubar -#define IPC_SPAWNMLHELPMENU 945 //menubar -#define IPC_SPAWNPELISTOFPLAYLISTS 946 - -typedef struct -{ - HWND wnd; - int xpos; // in screen coordinates - int ypos; -} waSpawnMenuParms; - -// waSpawnMenuParms2 is used by the menubar submenus -typedef struct -{ - HWND wnd; - int xpos; // in screen coordinates - int ypos; - int width; - int height; -} waSpawnMenuParms2; - - -// system tray sends this (you might want to simulate it) -#define WM_WA_SYSTRAY WM_USER+1 - -// input plugins send this when they are done playing back -#define WM_WA_MPEG_EOF WM_USER+2 - - - -//// video stuff - -#define IPC_IS_PLAYING_VIDEO 501 // returns >1 if playing, 0 if not, 1 if old version (so who knows):) -#define IPC_GET_IVIDEOOUTPUT 500 // see below for IVideoOutput interface -#define VIDEO_MAKETYPE(A,B,C,D) ((A) | ((B)<<8) | ((C)<<16) | ((D)<<24)) -#define VIDUSER_SET_INFOSTRING 0x1000 -#define VIDUSER_GET_VIDEOHWND 0x1001 -#define VIDUSER_SET_VFLIP 0x1002 - -#ifndef NO_IVIDEO_DECLARE -#ifdef __cplusplus - -class VideoOutput; -class SubsItem; - -typedef struct { - unsigned char* baseAddr; - int32_t rowBytes; -} YV12_PLANE; - -typedef struct { - YV12_PLANE y; - YV12_PLANE u; - YV12_PLANE v; -} YV12_PLANES; - -class IVideoOutput -{ - public: - virtual ~IVideoOutput() { } - virtual int open(int w, int h, int vflip, double aspectratio, unsigned int fmt)=0; - virtual void setcallback(LRESULT (*msgcallback)(void *token, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam), void *token) { } - virtual void close()=0; - virtual void draw(void *frame)=0; - virtual void drawSubtitle(SubsItem *item) { } - virtual void showStatusMsg(const char *text) { } - virtual int get_latency() { return 0; } - virtual void notifyBufferState(int bufferstate) { } /* 0-255*/ - - virtual int extended(int param1, int param2, int param3) { return 0; } // Dispatchable, eat this! -}; -#endif //cplusplus -#endif//NO_IVIDEO_DECLARE - -// these messages are callbacks that you can grab by subclassing the winamp window - -// wParam = -#define IPC_CB_WND_EQ 0 // use one of these for the param -#define IPC_CB_WND_PE 1 -#define IPC_CB_WND_MB 2 -#define IPC_CB_WND_VIDEO 3 -#define IPC_CB_WND_MAIN 4 - -#define IPC_CB_ONSHOWWND 600 -#define IPC_CB_ONHIDEWND 601 - -#define IPC_CB_GETTOOLTIP 602 - -#define IPC_CB_MISC 603 - #define IPC_CB_MISC_TITLE 0 - #define IPC_CB_MISC_VOLUME 1 // volume/pan - #define IPC_CB_MISC_STATUS 2 - #define IPC_CB_MISC_EQ 3 - #define IPC_CB_MISC_INFO 4 - #define IPC_CB_MISC_VIDEOINFO 5 - -#define IPC_CB_CONVERT_STATUS 604 // param value goes from 0 to 100 (percent) -#define IPC_CB_CONVERT_DONE 605 - -#define IPC_ADJUST_FFWINDOWSMENUPOS 606 -/* (requires Winamp 2.9+) -** int newpos=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)adjust_offset,IPC_ADJUST_FFWINDOWSMENUPOS); -** moves where winamp expects the freeform windows in the menubar windows main menu. Useful if you wish to insert a -** menu item above extra freeform windows. -*/ - -#define IPC_ISDOUBLESIZE 608 - -#define IPC_ADJUST_FFOPTIONSMENUPOS 609 -/* (requires Winamp 2.9+) -** int newpos=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)adjust_offset,IPC_ADJUST_FFOPTIONSMENUPOS); -** moves where winamp expects the freeform preferences item in the menubar windows main menu. Useful if you wish to insert a -** menu item above preferences item. -*/ - -#define IPC_GETTIMEDISPLAYMODE 610 // returns 0 if displaying elapsed time or 1 if displaying remaining time - -#define IPC_SETVISWND 611 // param is hwnd, setting this allows you to receive ID_VIS_NEXT/PREVOUS/RANDOM/FS wm_commands -#define ID_VIS_NEXT 40382 -#define ID_VIS_PREV 40383 -#define ID_VIS_RANDOM 40384 -#define ID_VIS_FS 40389 -#define ID_VIS_CFG 40390 -#define ID_VIS_MENU 40391 - -#define IPC_GETVISWND 612 // returns the vis cmd handler hwnd -#define IPC_ISVISRUNNING 613 -#define IPC_CB_VISRANDOM 628 // param is status of random - -#define IPC_SETIDEALVIDEOSIZE 614 // sent by winamp to winamp, trap it if you need it. width=HIWORD(param), height=LOWORD(param) - -#define IPC_GETSTOPONVIDEOCLOSE 615 -#define IPC_SETSTOPONVIDEOCLOSE 616 - -typedef struct { - HWND hwnd; - int uMsg; - int wParam; - int lParam; -} transAccelStruct; - -#define IPC_TRANSLATEACCELERATOR 617 - -typedef struct { - int cmd; - int x; - int y; - int align; -} windowCommand; // send this as param to an IPC_PLCMD, IPC_MBCMD, IPC_VIDCMD - -#define IPC_CB_ONTOGGLEAOT 618 - -#define IPC_GETPREFSWND 619 - -#define IPC_SET_PE_WIDTHHEIGHT 620 // data is a pointer to a POINT structure that holds width & height - -#define IPC_GETLANGUAGEPACKINSTANCE 621 - -#define IPC_CB_PEINFOTEXT 622 // data is a string, ie: "04:21/45:02" - -#define IPC_CB_OUTPUTCHANGED 623 // output plugin was changed in config - -#define IPC_GETOUTPUTPLUGIN 625 - -#define IPC_SETDRAWBORDERS 626 -#define IPC_DISABLESKINCURSORS 627 -#define IPC_CB_RESETFONT 629 - -#define IPC_IS_FULLSCREEN 630 // returns 1 if video or vis is in fullscreen mode -#define IPC_SET_VIS_FS_FLAG 631 // a vis should send this message with 1/as param to notify winamp that it has gone to or has come back from fullscreen mode - -#define IPC_SHOW_NOTIFICATION 632 - -#define IPC_GETSKININFO 633 - -// >>>>>>>>>>> Next is 634 - -#define IPC_PLCMD 1000 - -#define PLCMD_ADD 0 -#define PLCMD_REM 1 -#define PLCMD_SEL 2 -#define PLCMD_MISC 3 -#define PLCMD_LIST 4 - -#define IPC_MBCMD 1001 - -#define MBCMD_BACK 0 -#define MBCMD_FORWARD 1 -#define MBCMD_STOP 2 -#define MBCMD_RELOAD 3 -#define MBCMD_MISC 4 - -#define IPC_VIDCMD 1002 - -#define VIDCMD_FULLSCREEN 0 -#define VIDCMD_1X 1 -#define VIDCMD_2X 2 -#define VIDCMD_LIB 3 -#define VIDPOPUP_MISC 4 - -#define IPC_MBURL 1003 //sets the URL -#define IPC_MBGETCURURL 1004 //copies the current URL into wParam (have a 4096 buffer ready) -#define IPC_MBGETDESC 1005 //copies the current URL description into wParam (have a 4096 buffer ready) -#define IPC_MBCHECKLOCFILE 1006 //checks that the link file is up to date (otherwise updates it). wParam=parent HWND -#define IPC_MBREFRESH 1007 //refreshes the "now playing" view in the library -#define IPC_MBGETDEFURL 1008 //copies the default URL into wParam (have a 4096 buffer ready) - -#define IPC_STATS_LIBRARY_ITEMCNT 1300 // updates library count status - -// IPC 2000-3000 reserved for freeform messages, see gen_ff/ff_ipc.h -#define IPC_FF_FIRST 2000 -#define IPC_FF_LAST 3000 - -#define IPC_GETDROPTARGET 3001 - -#define IPC_PLAYLIST_MODIFIED 3002 // sent to main wnd whenever the playlist is modified - -#define IPC_PLAYING_FILE 3003 // sent to main wnd with the file as parm whenever a file is played -#define IPC_FILE_TAG_MAY_HAVE_UPDATED 3004 // sent to main wnd with the file as parm whenever a file tag might be updated - - -#define IPC_ALLOW_PLAYTRACKING 3007 -// send nonzero to allow, zero to disallow - -#define IPC_HOOK_OKTOQUIT 3010 // return 0 to abort a quit, nonzero if quit is OK - -#define IPC_WRITECONFIG 3011 // pass 2 to write all, 1 to write playlist + common, 0 to write common+less common - -// pass a string to be the name to register, and returns a value > 65536, which is a unique value you can use -// for custom WM_WA_IPC messages. -#define IPC_REGISTER_WINAMP_IPCMESSAGE 65536 - -/**************************************************************************/ - -/* -** Finally there are some WM_COMMAND messages that you can use to send -** Winamp misc commands. -** -** To send these, use: -** -** SendMessage(hwnd_winamp, WM_COMMAND,command_name,0); -*/ - -#define WINAMP_OPTIONS_EQ 40036 // toggles the EQ window -#define WINAMP_OPTIONS_PLEDIT 40040 // toggles the playlist window -#define WINAMP_VOLUMEUP 40058 // turns the volume up a little -#define WINAMP_VOLUMEDOWN 40059 // turns the volume down a little -#define WINAMP_FFWD5S 40060 // fast forwards 5 seconds -#define WINAMP_REW5S 40061 // rewinds 5 seconds - -// the following are the five main control buttons, with optionally shift -// or control pressed -// (for the exact functions of each, just try it out) -#define WINAMP_BUTTON1 40044 -#define WINAMP_BUTTON2 40045 -#define WINAMP_BUTTON3 40046 -#define WINAMP_BUTTON4 40047 -#define WINAMP_BUTTON5 40048 -#define WINAMP_BUTTON1_SHIFT 40144 -#define WINAMP_BUTTON2_SHIFT 40145 -#define WINAMP_BUTTON3_SHIFT 40146 -#define WINAMP_BUTTON4_SHIFT 40147 -#define WINAMP_BUTTON5_SHIFT 40148 -#define WINAMP_BUTTON1_CTRL 40154 -#define WINAMP_BUTTON2_CTRL 40155 -#define WINAMP_BUTTON3_CTRL 40156 -#define WINAMP_BUTTON4_CTRL 40157 -#define WINAMP_BUTTON5_CTRL 40158 - -#define WINAMP_FILE_PLAY 40029 // pops up the load file(s) box -#define WINAMP_FILE_DIR 40187 // pops up the load directory box -#define WINAMP_OPTIONS_PREFS 40012 // pops up the preferences -#define WINAMP_OPTIONS_AOT 40019 // toggles always on top -#define WINAMP_HELP_ABOUT 40041 // pops up the about box :) - -#define ID_MAIN_PLAY_AUDIOCD1 40323 // starts playing the audio CD in the first CD reader -#define ID_MAIN_PLAY_AUDIOCD2 40323 // plays the 2nd -#define ID_MAIN_PLAY_AUDIOCD3 40323 // plays the 3nd -#define ID_MAIN_PLAY_AUDIOCD4 40323 // plays the 4nd - -// IDs 42000 to 45000 are reserved for gen_ff -// IDs from 45000 to 57000 are reserved for library - - -#define IPC_GET_RANDFUNC 3015 // returns a function to get a random number -#define IPC_REGISTER_LOWORD_COMMAND 3019 // assigns you a unique ID to make your own commands (for menus, etc) -#define IPC_GET_PROXY_STRING 3023 - - -#endif//_WA_IPC_H_ - -/* -** EOF.. Enjoy. -*/ \ No newline at end of file diff --git a/Windows/winamp/In2.h b/Windows/winamp/In2.h deleted file mode 100644 index 802592f..0000000 --- a/Windows/winamp/In2.h +++ /dev/null @@ -1,103 +0,0 @@ -#include "out.h" - -// note: exported symbol is now winampGetInModule2. - -#define IN_VER 0x100 - -typedef struct -{ - int version; // module type (IN_VER) - char *description; // description of module, with version string - - HWND hMainWindow; // winamp's main window (filled in by winamp) - HINSTANCE hDllInstance; // DLL instance handle (Also filled in by winamp) - - char *FileExtensions; // "mp3\0Layer 3 MPEG\0mp2\0Layer 2 MPEG\0mpg\0Layer 1 MPEG\0" - // May be altered from Config, so the user can select what they want - - int is_seekable; // is this stream seekable? - int UsesOutputPlug; // does this plug-in use the output plug-ins? (musn't ever change, ever :) - - void (*Config)(HWND hwndParent); // configuration dialog - void (*About)(HWND hwndParent); // about dialog - - void (*Init)(); // called at program init - void (*Quit)(); // called at program quit - - void (*GetFileInfo)(char *file, char *title, int *length_in_ms); // if file == NULL, current playing is used - int (*InfoBox)(char *file, HWND hwndParent); - - int (*IsOurFile)(char *fn); // called before extension checks, to allow detection of mms://, etc - // playback stuff - int (*Play)(char *fn); // return zero on success, -1 on file-not-found, some other value on other (stopping winamp) error - void (*Pause)(); // pause stream - void (*UnPause)(); // unpause stream - int (*IsPaused)(); // ispaused? return 1 if paused, 0 if not - void (*Stop)(); // stop (unload) stream - - // time stuff - int (*GetLength)(); // get length in ms - int (*GetOutputTime)(); // returns current output time in ms. (usually returns outMod->GetOutputTime() - void (*SetOutputTime)(int time_in_ms); // seeks to point in stream (in ms). Usually you signal yoru thread to seek, which seeks and calls outMod->Flush().. - - // volume stuff - void (*SetVolume)(int volume); // from 0 to 255.. usually just call outMod->SetVolume - void (*SetPan)(int pan); // from -127 to 127.. usually just call outMod->SetPan - - // in-window builtin vis stuff - - void (*SAVSAInit)(int maxlatency_in_ms, int srate); // call once in Play(). maxlatency_in_ms should be the value returned from outMod->Open() - // call after opening audio device with max latency in ms and samplerate - void (*SAVSADeInit)(); // call in Stop() - - - // simple vis supplying mode - void (*SAAddPCMData)(void *PCMData, int nch, int bps, int timestamp); - // sets the spec data directly from PCM data - // quick and easy way to get vis working :) - // needs at least 576 samples :) - - // advanced vis supplying mode, only use if you're cool. Use SAAddPCMData for most stuff. - int (*SAGetMode)(); // gets csa (the current type (4=ws,2=osc,1=spec)) - // use when calling SAAdd() - void (*SAAdd)(void *data, int timestamp, int csa); // sets the spec data, filled in by winamp - - - // vis stuff (plug-in) - // simple vis supplying mode - void (*VSAAddPCMData)(void *PCMData, int nch, int bps, int timestamp); // sets the vis data directly from PCM data - // quick and easy way to get vis working :) - // needs at least 576 samples :) - - // advanced vis supplying mode, only use if you're cool. Use VSAAddPCMData for most stuff. - int (*VSAGetMode)(int *specNch, int *waveNch); // use to figure out what to give to VSAAdd - void (*VSAAdd)(void *data, int timestamp); // filled in by winamp, called by plug-in - - - // call this in Play() to tell the vis plug-ins the current output params. - void (*VSASetInfo)(int nch, int srate); - - - // dsp plug-in processing: - // (filled in by winamp, called by input plug) - - // returns 1 if active (which means that the number of samples returned by dsp_dosamples - // could be greater than went in.. Use it to estimate if you'll have enough room in the - // output buffer - int (*dsp_isactive)(); - - // returns number of samples to output. This can be as much as twice numsamples. - // be sure to allocate enough buffer for samples, then. - int (*dsp_dosamples)(short int *samples, int numsamples, int bps, int nch, int srate); - - - // eq stuff - void (*EQSet)(int on, char data[10], int preamp); // 0-64 each, 31 is +0, 0 is +12, 63 is -12. Do nothing to ignore. - - // info setting (filled in by winamp) - void (*SetInfo)(int bitrate, int srate, int stereo, int synched); // if -1, changes ignored? :) - - Out_Module *outMod; // filled in by winamp, optionally used :) -} In_Module; - - diff --git a/Windows/winamp/Out.h b/Windows/winamp/Out.h deleted file mode 100644 index 0dae194..0000000 --- a/Windows/winamp/Out.h +++ /dev/null @@ -1,62 +0,0 @@ - -// ids: -// waveout: 32 -// gapless: 64 -// xfade: 63 -// disk: 33 -// dsound: 38 -// NULL: 65 -// mm2: 69 - -#define OUT_VER 0x10 - -typedef struct -{ - int version; // module version (OUT_VER) - char *description; // description of module, with version string - int id; // module id. each input module gets its own. non-nullsoft modules should - // be >= 65536. - - HWND hMainWindow; // winamp's main window (filled in by winamp) - HINSTANCE hDllInstance; // DLL instance handle (filled in by winamp) - - void (*Config)(HWND hwndParent); // configuration dialog - void (*About)(HWND hwndParent); // about dialog - - void (*Init)(); // called when loaded - void (*Quit)(); // called when unloaded - - int (*Open)(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms); - // returns >=0 on success, <0 on failure - // NOTENOTENOTE: bufferlenms and prebufferms are ignored in most if not all output plug-ins. - // ... so don't expect the max latency returned to be what you asked for. - // returns max latency in ms (0 for diskwriters, etc) - // bufferlenms and prebufferms must be in ms. 0 to use defaults. - // prebufferms must be <= bufferlenms - - void (*Close)(); // close the ol' output device. - - int (*Write)(char *buf, int len); - // 0 on success. Len == bytes to write (<= 8192 always). buf is straight audio data. - // 1 returns not able to write (yet). Non-blocking, always. - - int (*CanWrite)(); // returns number of bytes possible to write at a given time. - // Never will decrease unless you call Write (or Close, heh) - - int (*IsPlaying)(); // non0 if output is still going or if data in buffers waiting to be - // written (i.e. closing while IsPlaying() returns 1 would truncate the song - - int (*Pause)(int pause); // returns previous pause state - - void (*SetVolume)(int volume); // volume is 0-255 - void (*SetPan)(int pan); // pan is -128 to 128 - - void (*Flush)(int t); // flushes buffers and restarts output at time t (in ms) - // (used for seeking) - - int (*GetOutputTime)(); // returns played time in MS - int (*GetWrittenTime)(); // returns time written in MS (used for synching up vis stuff) - -} Out_Module; - - diff --git a/Windows/zvuk_win.cpp b/Windows/zvuk_win.cpp deleted file mode 100644 index 2050cf3..0000000 --- a/Windows/zvuk_win.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include -#include - -extern "C" - { - -int mix_back_sound(int synchro) - { - - return 0; - } - -int get_timer_value() - { - return GetTickCount()/TIMERSPEED; - } - - -int get_snd_effect(int funct) - { - return 0; - } - -char set_snd_effect(int funct,int data) - { - return 0; - } - -char check_snd_effect(int funct) - { - return 0; - } - -void change_music(char *filename) - { - - } - - -void set_backsnd_freq(int freq) - { - - } - -void fade_music() - { - - } - -void set_mixing_device(int mix_dev,int mix_freq,...) - { - } -char start_mixing() - { - return 0; - } -void stop_mixing() - { - } -void play_sample(int channel,void *sample,int32_t size,int32_t lstart,int32_t sfreq,int type) - { - } -void set_channel_volume(int channel,int left,int right) - { - } -int open_backsound(char *filename) - { - return 0; - } -char *device_name(int device) - { - return ""; - } -void force_music_volume(int volume) - { - } -char get_channel_state(int channel) - { - return 0; - } -void get_channel_volume(int channel,int *left,int *right) - { - } -void mute_channel(int channel) - { - } -void chan_break_loop(int channel) - { - } -void chan_break_ext(int channel,void *org_sample,int32_t size_sample) //zrusi loop s moznosti dohrat zvuk - { - } - - } - diff --git a/ZVUK/ANALYSE/DOSMEM.C b/ZVUK/ANALYSE/DOSMEM.C deleted file mode 100644 index 752670a..0000000 --- a/ZVUK/ANALYSE/DOSMEM.C +++ /dev/null @@ -1,71 +0,0 @@ -/*********************************************/ -/*** DOS memory allocation - DOSMEM.C ***/ -/*** vykostena verze chlumakova memalloc.c ***/ -/*********************************************/ - -#include -#include -#include -#include -#include "dosmem.h" - - -/*** Alokace pole v dolni pameti ***/ - -void *mem_alloc(int size) -{ - static union REGS r; - MEMREC memrec; - - r.x.eax=0x0100; - r.x.ebx=(size>>4)+1; - size=r.x.ebx<<4; - int386(0x31,&r,&r); - if (r.x.cflag) - { - printf ("No fucking DOS memory left!!!"); - exit(1); - } - memrec.ptr=(void *)((r.x.eax&0xFFFF)<<4); - Selector=memrec.selector=(short int)r.x.edx; - - return memrec.ptr; -} - - -/*** Uvolneni dolni pameti ***/ - -void mem_free(void *ptr) -{ - union REGS r; - - if(ptr!=NULL) - { - r.x.eax=0x0101; - r.x.edx=Selector; - int386(0x31,&r,&r); - if(r.x.cflag) - printf("Cannot free DOS memory!!!!"); - } - -} - - -/*** Vyvolani preruseni pomoci protected modu ***/ - -void WtNs386(int IntNum, DPMIREGS *dpmiregs) -{ - union REGS r; - struct SREGS sr; - - r.w.ax=0x300; - r.h.bl=(char)IntNum; - r.h.bh=0; - r.w.cx=0; - segread(&sr); - sr.es=FP_SEG(dpmiregs); - r.x.edi=FP_OFF(dpmiregs); - - int386x(0x31,&r,&r,&sr); -} - diff --git a/ZVUK/ANALYSE/DOSMEM.H b/ZVUK/ANALYSE/DOSMEM.H deleted file mode 100644 index b33588d..0000000 --- a/ZVUK/ANALYSE/DOSMEM.H +++ /dev/null @@ -1,46 +0,0 @@ -/************************************/ -/*** Hlavickovt soubor k DOSMEM.H ***/ -/************************************/ - - -typedef enum -{ DOS_MEMORY, - NEW, -} MEMORY_ITEMS; - -typedef struct -{ int EDI; - int ESI; - int EBP; - int reserved; - int EBX; - int EDX; - int ECX; - int EAX; - short int Flags; - short int ES; - short int DS; - short int GS; - short int IP; - short int CS; - short int SP; - short int SS; - } DPMIREGS; - -typedef struct -{ void *ptr; - int size; - int selector; //smysl jen u DOS_MEMORY - } MEMREC; - -#define D32RealSeg(P) ((((unsigned int)(P))>>4)&0xFFFF) -#define D32RealOff(P) (((unsigned int)(P))&0xF) - -int Selector; -DPMIREGS dpmiregs; - -void *mem_alloc(int size); -void mem_free(void *ptr); -void WtNs386(int IntNum, DPMIREGS *dpmiregs); - - diff --git a/ZVUK/ANALYSE/FLC.C b/ZVUK/ANALYSE/FLC.C deleted file mode 100644 index 5994eb7..0000000 --- a/ZVUK/ANALYSE/FLC.C +++ /dev/null @@ -1,5 +0,0 @@ -// -// Knihovna pro dekompresi FLC souboru -// - -#include "flc.h" diff --git a/ZVUK/ANALYSE/FLC.H b/ZVUK/ANALYSE/FLC.H deleted file mode 100644 index 15f903a..0000000 --- a/ZVUK/ANALYSE/FLC.H +++ /dev/null @@ -1,54 +0,0 @@ -// -// Hlavickovy soubor ke knihovne FLC.C slouzici k dekompresi FLC -// - -#ifndef _FLC_H -#define _FLC_H - -typedef struct FLCHEADER { - unsigned int size; // delka souboru vcetne hlavicky - unsigned short idflc; // ID FLC=0AF12h - unsigned short frames; // pocet frejmu - unsigned short width; // sirka vsech obrazku - unsigned short height; // vyska vsech obrazku - unsigned short color; // hloubka barvy (bpp) - unsigned short flag1; - unsigned int speed; // rychlost prehravani (v 1/1000 s) - unsigned short reserv1; // rezervovany - unsigned int date1; // datum a cas vytvoreni - unsigned int serial; // seriove cislo programu - unsigned int date2; // datum a cas posledni zmeny - unsigned short XA; - unsigned short YA; - char reserv2 [42]; // rezervovano - unsigned int offset1; // offset prvniho frame - unsigned int offset2; // offset druheho frame - char reserv3 [40]; // rezervovano - } flcheader; - -typedef struct FRAMEHEADER { - unsigned int size; // velikost frame v bytech - unsigned short sign; // znacka frame OFAF1h - unsigned short actions; // pocet akci v tomto frame - char reserv [8]; // rezervovano - } frameheader; - -typedef struct ACTIONHEADER { - unsigned int size; // velikost akce v bytech - unsigned short code; // kod akce - // 04h - predani casti nebo cele palety - // 07h - predavani zmenenych casti obrazu - // 0Dh - vymaze obrazovku - // 0Fh - cela obrazovka v RLE - // 10h - nekomprimovana kopie cele obrazovky - // nasleduji data akce - } actionheader; - -char frame_buffer [307200]; -char *flc_buffer; - -void Get_first_frame (void); -void Get_next_frame (void); -void Decompress_frame (void); - -#endif diff --git a/ZVUK/ANALYSE/PLAY.C b/ZVUK/ANALYSE/PLAY.C deleted file mode 100644 index d5aaca9..0000000 --- a/ZVUK/ANALYSE/PLAY.C +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include "flc.h" - -flcheader h_flc; -frameheader h_frame; -actionheader h_action; - - -void main (int argc, char *argv[]) -{ - FILE *flc; - long pozice; - int frames, actions, x, y; - - flc = fopen (argv[1], "rb"); - fread (&h_flc, sizeof(flcheader), 1, flc); - frames=h_flc.frames; - - printf ("\nHlavicka FLC souboru %s:\n", argv[1]); - printf ("Delka celeho souboru: %d\n", h_flc.size); - printf ("Pocet frame: %d\n", h_flc.frames); - printf ("Velikost filmu: %dx%d\n", h_flc.width, h_flc.height); - printf ("Hloubka barvy: %d\n", h_flc.color); - printf ("Rychlost prehravani: %d fps\n", 1000/h_flc.speed); - printf ("Offset prvniho frame: %d\n", h_flc.offset1); - - fseek (flc, h_flc.offset1, SEEK_SET); - for (x=0; x<=(frames-1); x++) - { - fread (&h_frame, sizeof(frameheader), 1, flc); - actions=h_frame.actions; - printf ("\nHlavicka %d framu:\n", x+1); - printf ("Velikost framu: %d\n", h_frame.size); - printf ("Pocet akci ve framu: %d\n", h_frame.actions); - - for (y=0; y<=(actions-1); y++) - { - pozice = ftell (flc); - fread (&h_action, sizeof(actionheader), 1, flc); - fseek (flc, (pozice+h_action.size), SEEK_SET); - printf ("\nHlavicka %d akce:\n", y+1); - printf ("Velikost dat pro tuto akci: %d\n", h_action.size); - printf ("Kod akce: %x\n", h_action.code); - } - getch (); - _clearscreen (_GCLEARSCREEN); - } - - fclose (flc); -} - - diff --git a/ZVUK/ANALYSE/VESA.C b/ZVUK/ANALYSE/VESA.C deleted file mode 100644 index a59e4d4..0000000 --- a/ZVUK/ANALYSE/VESA.C +++ /dev/null @@ -1,296 +0,0 @@ -/********************************/ -/* Prace se SVGA VESA adapterem */ -/********************************/ - -#include -#include -#include -#include -#include "vesa.h" -#include "dosmem.h" - - extern void wm_ChangeBank_(int bank); - #pragma aux (ASM) wm_ChangeBank_; - - -void Set_VESA_mode (int mode) -{ - union REGS r; - - r.w.ax=0x4f02; - r.w.bx=mode; - int386 (0x10, &r, &r); -} - - -void Show_screen (char *display) -{ - wm_ChangeBank_ (0); - memmove (0xa0000, display, 65536); - wm_ChangeBank_ (1); - memmove (0xa0000, (display+65536), 65536); - wm_ChangeBank_ (2); - memmove (0xa0000, (display+131072), 65536); - wm_ChangeBank_ (3); - memmove (0xa0000, (display+196608), 65536); - wm_ChangeBank_ (4); - memmove (0xa0000, (display+262144), 45056); -} - -void Put_image (int x, int y, int xlen, int ylen, char *image) -{ - int a,b,c,d; - long int posunuti=0; - int banka; - - if (y<103) {wm_ChangeBank_ (0); banka=0;} - if (y>103 && y<205) {wm_ChangeBank_ (1); banka=1;} - if (y>205 && y<308) {wm_ChangeBank_ (2); banka=2;} - if (y>308 && y<410) {wm_ChangeBank_ (3); banka=3;} - if (y>410) {wm_ChangeBank_ (4); banka=4;} - - for (a=0; a<=ylen; a++) - { - - d=y+a; - switch (d) - { - case 102: - if ((x+xlen)<256){ - posunuti=(y+a)*640+x; - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - wm_ChangeBank_ (1); banka=1;} - if (x>=256){ - wm_ChangeBank_ (1); banka=1; - posunuti=(((y+a)*640+x)-65536); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - } - if (x<256 && (x+xlen)>256){ - posunuti=(y+a)*640+x; b=x; c=0; - while (b!=256) - {memmove ((0xa0000+posunuti), (image+a*(xlen+1)+c), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (1); banka=1; - posunuti=(((y+a)*640+x)-65536); - memmove ((0xa0000+posunuti+c), (image+a*(xlen+1)+c), (xlen-c));} - break; - case 204: - if ((x+xlen)<512){ - posunuti=(((y+a)*640+x)-65536); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - wm_ChangeBank_ (2); banka=2;} - if (x>=512){ - wm_ChangeBank_ (2); banka=2; - posunuti=(((y+a)*640+x)-131072); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen);} - if (x<512 && (x+xlen)>512){ - posunuti=(((y+a)*640+x)-65536); b=x; c=0; - while (b!=512) - {memmove ((0xa0000+posunuti), (image+a*(xlen+1)+c), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (2); banka=2; - posunuti=(((y+a)*640+x)-131072); - memmove ((0xa0000+posunuti+c), (image+a*(xlen+1)+c), (xlen-c));} - break; - - case 307: - if ((x+xlen)<128){ - posunuti=(((y+a)*640+x)-131072); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - wm_ChangeBank_ (3); banka=3;} - if (x>=128){ - wm_ChangeBank_ (3); banka=3; - posunuti=(((y+a)*640+x)-196608); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen);} - if (x<128 && (x+xlen)>128){ - posunuti=(((y+a)*640+x)-131072); b=x; c=0; - while (b!=128) - {memmove ((0xa0000+posunuti), (image+a*(xlen+1)+c), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (3); banka=3; - posunuti=(((y+a)*640+x)-196608); - memmove ((0xa0000+posunuti+c), (image+a*(xlen+1)+c), (xlen-c));} - break; - - case 409: - if ((x+xlen)<384){ - posunuti=(((y+a)*640+x)-196608); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - wm_ChangeBank_ (4); banka=4;} - if (x>=384){ - wm_ChangeBank_ (4); banka=4; - posunuti=(((y+a)*640+x)-262144); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen);} - if (x<384 && (x+xlen)>384){ - posunuti=(((y+a)*640+x)-196608); b=x; c=0; - while (b!=384) - {memmove ((0xa0000+posunuti), (image+a*(xlen+1)+c), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (4); banka=4; - posunuti=(((y+a)*640+x)-262144); - memmove ((0xa0000+posunuti+c), (image+a*(xlen+1)+c), (xlen-c));} - break; - - default: - posunuti=(y+a)*640+x-banka*65536; - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - break; - }; - } -} - -void Get_image (int x, int y, int xlen, int ylen, char *image) -{ - int a,b,c,d; - long int posunuti=0; - int banka; - - if (y<103) {wm_ChangeBank_ (0); banka=0;} - if (y>103 && y<205) {wm_ChangeBank_ (1); banka=1;} - if (y>205 && y<308) {wm_ChangeBank_ (2); banka=2;} - if (y>308 && y<410) {wm_ChangeBank_ (3); banka=3;} - if (y>410) {wm_ChangeBank_ (4); banka=4;} - - for (a=0; a<=ylen; a++) - { - - d=y+a; - switch (d) - { - case 102: - if ((x+xlen)<256){ - posunuti=(y+a)*640+x; - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - wm_ChangeBank_ (1); banka=1;} - if (x>=256){ - wm_ChangeBank_ (1); banka=1; - posunuti=(((y+a)*640+x)-65536); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - } - if (x<256 && (x+xlen)>256){ - posunuti=(y+a)*640+x; b=x; c=0; - while (b!=256) - {memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (1); banka=1; - posunuti=(((y+a)*640+x)-65536); - memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti+c), (xlen-c));} - break; - case 204: - if ((x+xlen)<512){ - posunuti=(((y+a)*640+x)-65536); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - wm_ChangeBank_ (2); banka=2;} - if (x>=512){ - wm_ChangeBank_ (2); banka=2; - posunuti=(((y+a)*640+x)-131072); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen);} - if (x<512 && (x+xlen)>512){ - posunuti=(((y+a)*640+x)-65536); b=x; c=0; - while (b!=512) - {memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (2); banka=2; - posunuti=(((y+a)*640+x)-131072); - memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti+c), (xlen-c));} - break; - - case 307: - if ((x+xlen)<128){ - posunuti=(((y+a)*640+x)-131072); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - wm_ChangeBank_ (3); banka=3;} - if (x>=128){ - wm_ChangeBank_ (3); banka=3; - posunuti=(((y+a)*640+x)-196608); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen);} - if (x<128 && (x+xlen)>128){ - posunuti=(((y+a)*640+x)-131072); b=x; c=0; - while (b!=128) - {memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (3); banka=3; - posunuti=(((y+a)*640+x)-196608); - memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti+c), (xlen-c));} - break; - - case 409: - if ((x+xlen)<384){ - posunuti=(((y+a)*640+x)-196608); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - wm_ChangeBank_ (4); banka=4;} - if (x>=384){ - wm_ChangeBank_ (4); banka=4; - posunuti=(((y+a)*640+x)-262144); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen);} - if (x<384 && (x+xlen)>384){ - posunuti=(((y+a)*640+x)-196608); b=x; c=0; - while (b!=384) - {memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (4); banka=4; - posunuti=(((y+a)*640+x)-262144); - memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti+c), (xlen-c));} - break; - - default: - posunuti=(y+a)*640+x-banka*65536; - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - break; - }; - } - -} - - -void Get_VESA_info (void) -{ - char far *str; - VESA_INFO_BLOCK *p; - - p=(VESA_INFO_BLOCK *)mem_alloc(sizeof(VESA_INFO_BLOCK)); - - memset(&dpmiregs,0,sizeof(DPMIREGS)); - dpmiregs.EAX=0x00004f00; - dpmiregs.DS=D32RealSeg(p); - dpmiregs.ES=D32RealSeg(p); - dpmiregs.EDI=D32RealOff(p); - - WtNs386(0x10,&dpmiregs); - - str=(char far *)MK_FP(Selector,0); - _fmemcpy(&VesaInfoBlock,str,sizeof(VESA_INFO_BLOCK)); - - mem_free(p); - if(dpmiregs.EAX!=0x4f) - { - printf ("VESA Bios extension not found!!!!"); - exit (1); - } -} - - -void Get_mode_info (int mode) -{ - char far *str; - VESA_MODE_INFO_BLOCK *p; - - p=(VESA_MODE_INFO_BLOCK *)mem_alloc(sizeof(VESA_MODE_INFO_BLOCK)); - - memset(&dpmiregs,0,sizeof(DPMIREGS)); //nuluje registry - dpmiregs.EAX=0x00004f01; - dpmiregs.DS=D32RealSeg(p); - dpmiregs.ES=D32RealSeg(p); - dpmiregs.EDI=D32RealOff(p); - dpmiregs.ECX=mode; - - WtNs386(0x10,&dpmiregs); - - str=(char far *)MK_FP(Selector,0); - _fmemcpy(&VesaModeInfoBlock,str,sizeof(VESA_INFO_BLOCK)); - - _VGAGran=VesaModeInfoBlock.WinGranularity; - - mem_free(p); -} - diff --git a/ZVUK/ANALYSE/VESA.H b/ZVUK/ANALYSE/VESA.H deleted file mode 100644 index a0f12a2..0000000 --- a/ZVUK/ANALYSE/VESA.H +++ /dev/null @@ -1,70 +0,0 @@ -/********************************/ -/* Prace se SVGA VESA adapterem */ -/********************************/ - -#ifndef __VESA_H -#define __VESA_H - - -typedef struct -{ char VESASignature[4]; - short VESAversion; - unsigned OEMStringPtr; - char capabilities[4]; - short int *videomodeptr; - short int TotalMemory; - char dummy[236]; - } VESA_INFO_BLOCK; - -typedef struct -{ short unsigned ModeAttributes; - char WinAAttributes; - char WinBAttributes; - short unsigned WinGranularity; - short unsigned WinSize; - short unsigned WinASegment; - short unsigned WinBSegment; - short unsigned WinFuncPtroff; - short unsigned WinFuncPtrseg; - short unsigned BytesPerScanLine; - - short unsigned XResolution; - short unsigned YResolution; - char Xcharsize; - char Ycharsize; - char NumberOfPlanes; - char BitsPerPixel; - char NumberOfBanks; - char MemoryModel; - char BankSize; - char NumberOfImagePages; - char Reserved; - - char RedMaskSize; - char RedFieldPosition; - char GreenMaskSize; - char GreenFieldPosition; - char BlueMaskSize; - char BlueFieldPosition; - char RsvdMaskSize; - char DirectColorModeInfo; - char Dummy[216]; - } VESA_MODE_INFO_BLOCK; - - -VESA_MODE_INFO_BLOCK VesaModeInfoBlock; -VESA_INFO_BLOCK VesaInfoBlock; - -extern unsigned char _VGAPage=0; -extern unsigned char _VGAGran=0; - -void Set_VESA_mode (int mode); -void Show_screen (char *display); -void Get_VESA_info (void); -void Get_mode_info (int mode); - -void Put_image (int x, int y, int xlen, int ylen, char *image); -void Get_image (int x, int y, int xlen, int ylen, char *image); - -#endif - diff --git a/ZVUK/ANALYSE/VESA_.ASM b/ZVUK/ANALYSE/VESA_.ASM deleted file mode 100644 index d11920c..0000000 --- a/ZVUK/ANALYSE/VESA_.ASM +++ /dev/null @@ -1,63 +0,0 @@ -;EAX EDX EBX ECX -.386p -jumps -;############################################################################ -; Constanty -;############################################################################ - -dlt_x equ 640 -dlt_y equ 480 - -;############################################################################ -; Datovy segment -;############################################################################ -_DATA SEGMENT PARA PUBLIC USE32 'DATA' -align 4 - - -EXTRN __VGAPage:BYTE -EXTRN __VGAGran:BYTE - - -_DATA ENDS - -DGROUP GROUP _DATA - -;############################################################################ -; Kodovy segment -;############################################################################ -_TEXT SEGMENT PARA PUBLIC USE32 'CODE' - ASSUME cs:_TEXT, ds:_DATA - - - -public wm_ChangeBank__ -wm_ChangeBank__ PROC - - push es - pushad - - push eax - mov edx, eax - mov ebx, 0000h - mov eax, 4f05h - int 10h - - pop eax - mov edx, eax - mov ebx, 0001h - mov eax, 4f05h - int 10h - - popad - pop es - ret - -wm_ChangeBank__ endp -;---------------------------------------------------------------------------- - -_TEXT ENDS - -END - - diff --git a/ZVUK/DOSMEM.C b/ZVUK/DOSMEM.C deleted file mode 100644 index 752670a..0000000 --- a/ZVUK/DOSMEM.C +++ /dev/null @@ -1,71 +0,0 @@ -/*********************************************/ -/*** DOS memory allocation - DOSMEM.C ***/ -/*** vykostena verze chlumakova memalloc.c ***/ -/*********************************************/ - -#include -#include -#include -#include -#include "dosmem.h" - - -/*** Alokace pole v dolni pameti ***/ - -void *mem_alloc(int size) -{ - static union REGS r; - MEMREC memrec; - - r.x.eax=0x0100; - r.x.ebx=(size>>4)+1; - size=r.x.ebx<<4; - int386(0x31,&r,&r); - if (r.x.cflag) - { - printf ("No fucking DOS memory left!!!"); - exit(1); - } - memrec.ptr=(void *)((r.x.eax&0xFFFF)<<4); - Selector=memrec.selector=(short int)r.x.edx; - - return memrec.ptr; -} - - -/*** Uvolneni dolni pameti ***/ - -void mem_free(void *ptr) -{ - union REGS r; - - if(ptr!=NULL) - { - r.x.eax=0x0101; - r.x.edx=Selector; - int386(0x31,&r,&r); - if(r.x.cflag) - printf("Cannot free DOS memory!!!!"); - } - -} - - -/*** Vyvolani preruseni pomoci protected modu ***/ - -void WtNs386(int IntNum, DPMIREGS *dpmiregs) -{ - union REGS r; - struct SREGS sr; - - r.w.ax=0x300; - r.h.bl=(char)IntNum; - r.h.bh=0; - r.w.cx=0; - segread(&sr); - sr.es=FP_SEG(dpmiregs); - r.x.edi=FP_OFF(dpmiregs); - - int386x(0x31,&r,&r,&sr); -} - diff --git a/ZVUK/DOSMEM.H b/ZVUK/DOSMEM.H deleted file mode 100644 index b33588d..0000000 --- a/ZVUK/DOSMEM.H +++ /dev/null @@ -1,46 +0,0 @@ -/************************************/ -/*** Hlavickovt soubor k DOSMEM.H ***/ -/************************************/ - - -typedef enum -{ DOS_MEMORY, - NEW, -} MEMORY_ITEMS; - -typedef struct -{ int EDI; - int ESI; - int EBP; - int reserved; - int EBX; - int EDX; - int ECX; - int EAX; - short int Flags; - short int ES; - short int DS; - short int GS; - short int IP; - short int CS; - short int SP; - short int SS; - } DPMIREGS; - -typedef struct -{ void *ptr; - int size; - int selector; //smysl jen u DOS_MEMORY - } MEMREC; - -#define D32RealSeg(P) ((((unsigned int)(P))>>4)&0xFFFF) -#define D32RealOff(P) (((unsigned int)(P))&0xF) - -int Selector; -DPMIREGS dpmiregs; - -void *mem_alloc(int size); -void mem_free(void *ptr); -void WtNs386(int IntNum, DPMIREGS *dpmiregs); - - diff --git a/ZVUK/EXAMPLE.ASM b/ZVUK/EXAMPLE.ASM deleted file mode 100644 index 9de1631..0000000 --- a/ZVUK/EXAMPLE.ASM +++ /dev/null @@ -1,67 +0,0 @@ -.model small -.386 - -DGROUP group _DATA - - -tchannel struct - PLAYPOS DD ? - STARTLOOP DD ? - ENDLOOP DD ? - SPEEDMAJ DD ? - SPEEDMIN DW ? - MINORPOS DW ? - SMPTYPE DW ?;0 - DISABLED, 1 - 8 BIT, 2 - 16 BIT - VOLUMELEFT DW ? - VOLUMERIGHT DW ? -tchannel ends - -extrn _chaninfo:dword -extrn _mixbuffer:dword -extrn _backsnd:dword ;ukazatel na buffer s hudbou na pozadi (64Kb) -extrn _backstep:dword ;krok o kolik se meni _backsnd -extrn _backsndbuff:dword ;buffer hudby na pozadi - - -extrn _jumptable:dword[3] ;[0] - skip, [1] - mix8, [2] - mix16 -extrn _getdma:dword -extrn _ido:dword - -extrn _predstih:word -extrn _lastdma:dword -extrn _lastmix:dword -extrn _surpos:dword -extrn _mixpos:dword -extrn _mixsize:dword - -extrn _dmaposadr:dword -extrn _dpmiselector:word - - - -_TEXT segment byte public 'CODE' use32 - assume CS:_TEXT - assume DS:DGROUP - - PUBLIC _MIXER -_MIXER: ;THIS IS MAIN MIXING PROCEDURE. - ;BEFORE USING, YOU MUST SET UP ALL VARIBLES TO THE CORRECT VALUES. - ;_MIXBUFFER MUST START ON PAGE OF MEMORY (EXP 0x10000 0x20000 0x30000) - ;PROCEDURE MUST BE CALLED EACH 18ms OR LITTLE. - ;IF YOU USING INTERRUPT, REMEBER, THAT YOU MUST STORE ALL REGISTERS - ;BEFORE USE. - -; CALL calcsize ;VYPOCET DELKY MIXOVANI - mov edi,_mixpos ;Nejprve se vymaze mixovaci pamet - mov ecx,_mixsize - shr ecx,2 - xor eax,eax -MIXCLR: mov [edi],eax - add di,4 - dec ecx - jnz MIXCLR - mov ebx,_chaninfo ;TED SE ZACNE MIXOVAT -MIXING: xor eax,eax - mov ax,[ebx]offset tchannel.smptype -_TEXT ends -end diff --git a/ZVUK/FLC.C b/ZVUK/FLC.C deleted file mode 100644 index 62e38b3..0000000 --- a/ZVUK/FLC.C +++ /dev/null @@ -1,176 +0,0 @@ -// -// Knihovna pro dekompresi FLC souboru -// - -#include -#include -#include -#include -#include -#include "flc.h" - - -void Open_FLC (char *filename) -{ - flc = fopen (filename, "rb"); - fread (&h_flc, sizeof(flcheader), 1, flc); -} - -void Close_FLC (void) -{ - fclose (flc); - free (flc_buffer); -} - -void Get_first_frame (void) -{ - fseek (flc, h_flc.offset1, SEEK_SET); - fread (&h_frame, sizeof(frameheader), 1, flc); - flc_buffer = (char*)malloc((h_frame.size-sizeof(frameheader))); - fread (flc_buffer, (h_frame.size-sizeof(frameheader)), 1, flc); -} - -void Get_next_frame (void) -{ - free (flc_buffer); - fread (&h_frame, sizeof(frameheader), 1, flc); - flc_buffer = (char*)malloc((h_frame.size-sizeof(frameheader))); - fread (flc_buffer, (h_frame.size-sizeof(frameheader)), 1, flc); -} - -void Decompress_frame (void) -{ - unsigned short x,y,z,w; - unsigned short changes, nfo_word, packets, offset, row; - int frame_pos=0; - unsigned int scr_pos; - char c1, c2, c3, a; - char hi, lo; - - for (z=1; z<=h_frame.actions; z++) - { - memmove ( &h_action, (flc_buffer+frame_pos), sizeof(actionheader) ); - switch (h_action.code) - { - case 4: - a=1;//fcl_buffer[frame_pos]; -// b=0;//flc_buffer[frame_pos]; -// c=256; //0=256 - - frame_pos+=10; - outp (0x3c8, 0); - for (x=0; x<=768; x++) outp (0x3c9, (flc_buffer[(x+frame_pos)]/=4) ); - frame_pos+=768; - break; - case 7: - frame_pos+=6; - lo=flc_buffer[frame_pos]; frame_pos++; - hi=flc_buffer[frame_pos]; frame_pos++; - changes=hi*256+lo; - row=0; - - for (y=0; y<=(changes-1); y++) // pocet menenych radek - { - lo=flc_buffer[frame_pos]; frame_pos++; - hi=flc_buffer[frame_pos]; frame_pos++; - nfo_word=hi*256+lo; - - scr_pos=row*h_flc.width; - - if (nfo_word>=0xC000) // preskakovane radky - { - nfo_word=0xFFFF-nfo_word+1; - row+=nfo_word; - } - - else - { - for (z=1; z<=nfo_word; z++) // pocet menenych bloku - { - x=1; a=0; - - offset = flc_buffer[frame_pos]; // rel. offset bloku - frame_pos++; - scr_pos+=offset; - -// while (!a) // zmena bloku -// { - c1 = flc_buffer[frame_pos]; - frame_pos++; - - if (c1>128) - { - c1=0xFF-c1+1; - c2=flc_buffer[frame_pos]; - frame_pos++; - c3=flc_buffer[frame_pos]; - frame_pos++; - - for (w=1; w<=c1; w++) - { frame_buffer[scr_pos]=c2; - scr_pos++; - frame_buffer[scr_pos]=c3; - scr_pos++; } - } - else - { -// c3=0xFF-c3+1; - for (w=1; w<=c1; w++) - { frame_buffer[scr_pos]=flc_buffer[frame_pos]; - frame_pos++; - scr_pos++; - frame_buffer[scr_pos]=flc_buffer[frame_pos]; - frame_pos++; - scr_pos++; } - } - -// if (x>=640) a=1; -// } - - } - row++; - } - } - -// frame_pos+=h_action.size; - break; - case 15: - frame_pos+=6; - for (y=0; y<=(h_flc.height-1); y++) - { - frame_pos++; x=1; //a=0; - scr_pos=y*h_flc.width; - - while (x<=h_flc.width) - { - c1 = flc_buffer[frame_pos]; - frame_pos++; - - if (c1<128) - { - c2=flc_buffer[frame_pos]; - frame_pos++; - for (w=1; w<=c1; w++) - { frame_buffer[scr_pos]=c2; - scr_pos++; - x++; } - } - else - { - c1=0xFF-c1+1; - for (w=1; w<=c1; w++) - { frame_buffer[scr_pos]=flc_buffer[frame_pos]; - scr_pos++; - frame_pos++; - x++; } - } - } - } - break; - default: frame_pos+=h_action.size; - break; - }; - - } - -} diff --git a/ZVUK/FLC.H b/ZVUK/FLC.H deleted file mode 100644 index 012a222..0000000 --- a/ZVUK/FLC.H +++ /dev/null @@ -1,61 +0,0 @@ -// -// Hlavickovy soubor ke knihovne FLC.C slouzici k dekompresi FLC -// - -#ifndef _FLC_H -#define _FLC_H - -typedef struct FLCHEADER { - unsigned int size; // delka souboru vcetne hlavicky - unsigned short idflc; // ID FLC=0AF12h - unsigned short frames; // pocet frejmu - unsigned short width; // sirka vsech obrazku - unsigned short height; // vyska vsech obrazku - unsigned short color; // hloubka barvy (bpp) - unsigned short flag1; - unsigned int speed; // rychlost prehravani (v 1/1000 s) - unsigned short reserv1; // rezervovany - unsigned int date1; // datum a cas vytvoreni - unsigned int serial; // seriove cislo programu - unsigned int date2; // datum a cas posledni zmeny - unsigned short XA; - unsigned short YA; - char reserv2 [42]; // rezervovano - unsigned int offset1; // offset prvniho frame - unsigned int offset2; // offset druheho frame - char reserv3 [40]; // rezervovano - } flcheader; - -typedef struct FRAMEHEADER { - unsigned int size; // velikost frame v bytech - unsigned short sign; // znacka frame OFAF1h - unsigned short actions; // pocet akci v tomto frame - char reserv [8]; // rezervovano - } frameheader; - -typedef struct ACTIONHEADER { - unsigned int size; // velikost akce v bytech - unsigned short code; // kod akce - // 04h - predani casti nebo cele palety - // 07h - predavani zmenenych casti obrazu - // 0Dh - vymaze obrazovku - // 0Fh - cela obrazovka v RLE - // 10h - nekomprimovana kopie cele obrazovky - // nasleduji data akce - } actionheader; - -FILE *flc; -flcheader h_flc; -frameheader h_frame; -actionheader h_action; -char frame_buffer [307205]; -char *flc_buffer; -//unsigned int ladici; - -void Open_FLC (char *filename); -void Close_FLC (void); -void Get_first_frame (void); -void Get_next_frame (void); -void Decompress_frame (void); - -#endif diff --git a/ZVUK/PLAY.C b/ZVUK/PLAY.C deleted file mode 100644 index 3138bf2..0000000 --- a/ZVUK/PLAY.C +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include -#include "flc.h" -#include "vesa.h" - -void Set_TEXT_mode (void); - -void main (int argc, char *argv[]) -{ - int x; - - Open_FLC (argv[1]); - - printf ("\nHlavicka FLC souboru %s:\n", argv[1]); - printf ("Delka celeho souboru: %d\n", h_flc.size); - printf ("Pocet frame: %d\n", h_flc.frames); - printf ("Velikost filmu: %dx%d\n", h_flc.width, h_flc.height); - printf ("Hloubka barvy: %d\n", h_flc.color); -// printf ("Rychlost prehravani: %d fps\n", 1000/h_flc.speed); - printf ("Offset prvniho frame: %d\n", h_flc.offset1); - getch (); - - Set_VESA_mode (0x101); - delay (1000); - - Get_first_frame (); - Decompress_frame (); - Show_screen (frame_buffer); - - for (x=2; x<=h_flc.frames; x++) - { - Get_next_frame (); - Decompress_frame (); - Show_screen (frame_buffer); - delay (7); - } - getch (); - - Set_TEXT_mode (); - Close_FLC (); -} - -void Set_TEXT_mode (void) -{ - union REGS inr, outr; - - inr.h.ah = 0x00; - inr.h.al = 03; - int386 (0x10, &inr, &outr); -} - - diff --git a/ZVUK/SNDPACK.C b/ZVUK/SNDPACK.C deleted file mode 100644 index 14384fb..0000000 --- a/ZVUK/SNDPACK.C +++ /dev/null @@ -1,254 +0,0 @@ -#include -#include -#include -#include - -#define BLK_SIZE 8192 - -short ampl_table[256]; -signed short source[BLK_SIZE]; -char target[BLK_SIZE]; - -long sfreq; -unsigned short chans; -FILE *sf,*tf; - - -char *nsource; -char *ntarget; -long ssize; -long rsize,blck; -char difftype=4; - -void Create_table_16() - { - int a,c,d,e; - float b; - - d=-1;e=0; - for(a=0;a<128;a++) - { - b=(a/128.0); - switch (difftype) - { - case 1:b=(b*32768.0);break; - case 2:b=(b*b*32768.0);break; - case 3:b=(b*b*b*32768.0);break; - case 4:b=(b*b*b*b*32768.0);break; - case 5:b=(b*b*b*b*b*32768.0);break; - } - c=(int)b; - if (c==d) e++; - d=c;c+=e; - ampl_table[128+a]=c; - ampl_table[128-a]=-c; - } - } - -int find_index(int value) - { - int i; - - if (value==0) return 128; - if (value>0) - { - for(i=128;i<256;i++) - if (ampl_table[i]>value) return i-1; - return 255; - } - else - { - for(i=128;i>=0;i--) - if (ampl_table[i]32768 || last1<-32768) abort(); - target[i]=indx; - } - else - { - val=source[i]; - indx=find_index(val-last2); - last2+=ampl_table[indx]; - if (last2>32768 || last2<-32768) abort(); - target[i]=indx; - } - } - } - -void find_data() - { - char w[5]="data"; - int i,d; - - i=0; - do - { - d=fgetc(sf); - if (d==w[i]) i++;else i=0; - if (d==EOF) abort(); - } - while (i<4); - } - - -void open_files() - { - int i=0; - sf=fopen(nsource,"rb"); - tf=fopen(ntarget,"wb"); - if (sf==NULL || tf==NULL) abort(); - fseek(sf,0x16,SEEK_SET); - fread(&chans,1,2,sf); - fread(&sfreq,1,4,sf); - find_data(); - fread(&ssize,1,4,sf); - rsize=ssize; - blck=rsize/sizeof(source); - fwrite(&chans,1,2,tf); - fwrite(&sfreq,1,4,tf); - fwrite(&ssize,1,4,tf); - fwrite(&blck,1,4,tf); - fwrite(&i,1,4,tf); - fwrite(&i,1,4,tf); - fwrite(&l_table,1,sizeof(ampl_table),tf); - } - -int read_buffer() - { - int l; - - if (rsize>sizeof(source)) l=sizeof(source); else l=rsize; - rsize-=l; - memset(source,0,sizeof(source)); - return fread(source,1,l,sf); - } - -void write_buffer() - { - int i,j; - - i=sizeof(target); - j=sizeof(source); - fwrite(&i,1,sizeof(i),tf); - fwrite(&j,1,sizeof(j),tf); - fwrite(target,1,sizeof(target),tf); - } -void timestate(int tim3,int tim4) - { - if (tim3<0) tim3=0; - tim3/=CLOCKS_PER_SEC; - tim4/=CLOCKS_PER_SEC; - cprintf("Packing time: %02d:%02d Remainig: %02d:%02d ",tim4/60,tim4%60,tim3/60,tim3%60); - } - -void pack() - { - long size; - int i,j,pt; - long tim1,tim2,tim3,tim4; - - pt=(ssize/(2*chans))/sfreq; - cprintf("\n\r" - "Packing sample : %s --> %s\n\r" - "Lenght : %10d KB\n\r" - "Total blocks : %10d blocks \n\r" - "Sample freq. : %10d Hz\n\r" - "Sample type : 16-bit %s\n\r" - "Aproximation : %10d \n\r" - "Playing time : %02d:%02d\n\r", - nsource,ntarget,ssize/1024,blck,sfreq,chans==1?"mono":"stereo",difftype,pt/60,pt%60); - timestate(88*60+88,88*60+88); - for (i=0;i<40;i++) putch('.'); - putch('\r'); - tim1=clock(); - do - { - size=read_buffer(); - if (chans==1) compress_buffer_mono(); - else compress_buffer_stereo(); - j=ftell(sf)*40/ssize; - putch('\r'); - tim2=clock(); - tim3=(tim2-tim1); - tim4=(int)((((float)ssize/ftell(sf))*tim3)); - tim3=tim4-tim3; - timestate(tim3,tim4); - for(i=0;i -#include -#include -#include - -UWORD seg; //Segment bufferu -UWORD sel; //Selector na buffer - - //Funkce pro alokaci v dolni casti pameti. - // Alloc dos memory -void dosalloc (unsigned para,unsigned short *rmseg,unsigned short *select) -{ -union REGS regs; - -regs.w.ax = 0x100; -regs.w.bx = para; -int386 (0x31,®s,®s); -*rmseg = regs.w.ax; -*select = regs.w.dx; -} - - //Funkce pro uvolneni v dolni casti pameti. - // Free dos memory -void dosfree (unsigned short select) -{ -union REGS regs; - -regs.w.ax = 0x101; -regs.w.dx = select; -int386 (0x31,®s,®s); -} - -void alloc_buffer() //nejprve se zaalokuje buffer - { - dosalloc(65536/16,&seg,&sel); - } - -void dealloc_buffer() //dealokace - { - dosfree(sel); - } - -void speaker_test() - { - puts("Init..."); - rm_proc_set(seg,sel,PORT_SPK,SPK_MODE);//Nastav rm_proc - load_rm_proc(); //nahraj rm_proc do dolni pameti - pc_speak_enable(); //PCSPEAKER do modu DAC (pokud se hraje na spk) - pc_speak_run(19000,18); //Zacni prehravat buffer (18Hz emulacni frekvence) - puts("Running..."); - getche(); //cekej na klavesu - puts("Stopping..."); - pc_speak_stop(); //Zastav prehravani - pc_speak_disable(); //PCSPEAKER vrat do normalniho rezimu - purge_rm_proc(); //vymaz rm_proc z dolni pameti - puts("Ending..."); - } - -void main() - { - alloc_buffer(); //Alokuj buffer - speaker_test(); //Test - dealloc_buffer(); //Dealokuj buffer - } diff --git a/ZVUK/TRACK.C b/ZVUK/TRACK.C deleted file mode 100644 index 1dfaab5..0000000 --- a/ZVUK/TRACK.C +++ /dev/null @@ -1,834 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#define SCRADR 0xb8000 -#define SCRSIZE (80*25*2) -#define SCRLLEN 80 -#define VOL_BLOCK (bfreq/44) -#define BVSTEP 2350 - -extern char backsndbuff[BACK_BUFF_SIZE]; -extern volatile long backsnd; -extern volatile long backstep; -extern volatile int backfine; -extern int bfreq,bblocks,bvolume; -extern FILE *bsnd; -extern unsigned short bchans; -extern long blength; -extern int bblock_size; -extern int device; -extern int devport; - -char manual_refresh=0; - -int get_playing_time(char *filename) - { - open_backsound(filename); - fclose(bsnd); - if (blength!=-1) return (bblocks*bblock_size)/(bfreq*bchans);else return 0; - } - -TSTR_LIST read_dir(char *mask,int attrs) - { - TSTR_LIST flist; - int index=0; - char c[80]; - struct find_t s; - int rc; - int doba; - - flist=create_list(256); - if (flist==NULL) return flist; - rc=_dos_findfirst(mask,attrs,&s); - while (rc==0) - { - char d[13],*p; - int i=0,j; - - if (attrs==_A_NORMAL || s.attrib & attrs) - { - - p=&d;d[12]='\0'; - while (s.name[i]!='.' && s.name[i]!='\0' ) *p++=s.name[i++]; - if (s.name[i]!='\0') j=i+1;else j=i; - while (i<8) - { - *p++=32;i++; - } - i=3; - *p++='.'; - while (s.name[j]!='\0') - { - *p++=s.name[j++]; - i--; - } - while (i>0) - { - *p++=32; - i--; - } - doba=get_playing_time(s.name); - sprintf(c,"%s %02d:%02d",d,doba/60,doba%60); - if (str_replace(&flist,index++,c)==NULL) - { - release_list(flist); - return NULL; - } - } - rc=_dos_findnext(&s); - } - sort_list(flist,-1); - str_delfreelines(&flist); - return flist; - } - -void name_conv(char *c) - { - char *a,*b,cn,cd; - - a=c;b=c; - cn=4;cd=0; - for(;*a && cn;a++,cn-=cd) - { - if (*a!=32) *b++=*a; - if (*a=='.') cd=1; - } - *b--='\0'; - if (*b=='.') *b='\0'; - } - - - -long music_size; -int block_size; -int block_max; -int vybrano=0; -int posledni=-1; -char error=0; - -typedef char TDIGIT[10]; - -TSTR_LIST adresar; - -char istr[300]; -char pause=0; - -unsigned short *screen; - -TDIGIT digits[15]= - { "���" - "ďż˝ ďż˝" - "���", - " ďż˝" - " ďż˝" - " ďż˝", - "���" - "���" - "���", - "���" - "���" - "���", - "ďż˝ ďż˝" - "���" - " ďż˝", - "���" - "���" - "���", - "���" - "���" - "���", - "���" - "ďż˝ ďż˝" - " ďż˝", - "���" - "���" - "���", - "���" - "���" - "���", - " ďż˝ " - " ďż˝ " - " ", - " " - "���" - " " - }; - - -void load_font(char *font,int start,int count); -#pragma aux load_font =\ - "cli"\ - "mov edx,3c4h"\ - "mov eax,0402h"\ - "out dx,ax"\ - "mov eax,0704h"\ - "out dx,ax"\ - "Mov edx,3ceh"\ - "mov eax,0204h"\ - "out dx,ax"\ - "mov eax,0005h"\ - "out dx,ax"\ - "mov ax,0406h"\ - "out dx,ax"\ - "shl ecx,5"\ - "mov edx,edi"\ - "mov edi,0a0000h"\ - "add edi,ecx"\ - "Opk: mov ecx,4"\ - "rep movsd"\ - "add edi,16"\ - "dec edx"\ - "jne opk"\ - "mov edx,3c4h"\ - "mov eax,0302h"\ - "out dx,ax"\ - "mov eax,0304h"\ - "out dx,ax"\ - "mov edx,3ceh"\ - "mov eax,0004h"\ - "out dx,ax"\ - "mov eax,1005h"\ - "out dx,ax"\ - "mov eax,0E06h"\ - "out dx,ax"\ - "sti"\ - parm [ESI][ECX][EDI] modify [EDX EAX]; - -void font_effekt1(); -#pragma aux font_effekt1 =\ - "mov ecx,32"\ - "mov edi,127"\ - "mov edx,3c4h"\ - "mov eax,0402h"\ - "out dx,ax"\ - "mov eax,0704h"\ - "out dx,ax"\ - "Mov edx,3ceh"\ - "mov eax,0204h"\ - "out dx,ax"\ - "mov eax,0005h"\ - "out dx,ax"\ - "mov ax,0406h"\ - "out dx,ax"\ - "shl ecx,5"\ - "mov edx,edi"\ - "mov esi,0a0000h"\ - "mov edi,0a4000h"\ - "push ecx"\ - "mov ecx,2000h"\ - "rep movsb"\ - "pop ecx"\ - "mov edi,0a4000h"\ - "add edi,ecx"\ - modify [EDX EAX ESI ECX EDI]; - -void font_effekt2(); -#pragma aux font_effekt2 =\ - "Opk: mov al,0ffh"\ - "stosb"\ - "add edi,14"\ - "stosb"\ - "add edi,16"\ - "dec edx"\ - "jne opk"\ - "mov edx,3c4h"\ - "mov eax,0302h"\ - "out dx,ax"\ - "mov eax,0304h"\ - "out dx,ax"\ - "mov edx,3ceh"\ - "mov eax,0004h"\ - "out dx,ax"\ - "mov eax,1005h"\ - "out dx,ax"\ - "mov eax,0E06h"\ - "out dx,ax"\ - modify [EDX EAX ESI ECX EDI]; -void font_effekt() - { - font_effekt1(); - font_effekt2(); - } - -#pragma aux dve_sady modify [EAX EBX EDX]=\ - "mov ebx,1"\ - "mov eax,1103h"\ - "int 10h"\ - "cli"\ - "mov edx,3d4h"\ - "mov eax,0100h"\ - "out dx,ax"\ - "mov edx,3c4h"\ - "mov al,1"\ - "out dx,al"\ - "inc edx "\ - "in al,dx "\ - "or al,1"\ - "out dx,al"\ - "mov edx,03dah"\ - "in al,dx"\ - "mov edx,03c0h"\ - "mov al,13h"\ - "out dx,al"\ - "mov al,0"\ - "out dx,ax"\ - "mov al,32"\ - "out dx,al"\ - "mov edx,3d4h"\ - "mov eax,0300h"\ - "out dx,ax"\ - "sti"\ - -void dve_sady(); - -void set_palcolor(int index,int r,int g,int b); -#pragma aux set_palcolor parm [ebx][edx][eax][ecx]=\ - "mov ch,al"\ - "mov dh,dl"\ - "mov eax,1010h"\ - "int 10h" - - -void def_fbars() - { - char f_bars[8][16]; - int i,j; - - memset(f_bars,0,sizeof(f_bars)); - for(i=0;i<8;i++) - for(j=0;j<=i;j++) - f_bars[7-i][15-j*2]=255; - load_font(f_bars,192,8); - for(i=0;i<16;i++) f_bars[0][i]=1; - for(i=0;i<16;i++) f_bars[1][i]=192; - for(i=0;i<16;i++) f_bars[2][i]=255*(i>13); - load_font(f_bars,200,3); - } - - -void disp_digit(int x,int y,char num) - { - unsigned short *adr; - char *c; - - adr=screen+y*SCRLLEN+x; - c=&digits[num]; - for(y=0;y<3;y++,adr+=SCRLLEN-3) - for(x=0;x<3;x++) *(char *)(adr++)=*c++; - } - -void clear_window(int x1,int y1,int x2,int y2,int color) - { - int x,y; - unsigned short *adr; - - color<<=8;color+=32; - for(y=y1;y<=y2;y++) - { - adr=screen+y*SCRLLEN; - for(x=x1;x<=x2;x++) - adr[x]=color; - } - } - -void disp_str(int x,int y,char *c,int color) - { - unsigned short *adr; - - adr=screen+y*SCRLLEN+x; - while (*c) *adr++=*(c++)+(color<<8); - } - -void disp_vbar_track(int x,int y,int step) - { - unsigned short *adr; - int drw=0;char cl; - - adr=screen+y*SCRLLEN+x; - while (drw<32768) - { - cl=15; - drw+=step; - adr[0]=200+(cl<<8); - adr[3]=201+(cl<<8); - adr-=SCRLLEN; - } - } - -void disp_bnum(int x,int y,int num,int dgs) - { - char sgn; - - sgn=num<0;num=abs(num); - while (dgs>0 || num>0) - { - disp_digit(x,y,num%10); - num/=10;dgs--; - x-=4; - } - if (sgn) disp_digit(x,y,11); - } - -void disp_chan(int x,int y,int value,int step) - { - unsigned short *adr; - int drw=0;char cl; - - adr=screen+y*SCRLLEN+x; - while (drw<32768) - { - if (drw>=value) cl=0; - else if (drw>24660) cl=12; - else if (drw>16384) cl=14; - else cl=10; - drw+=step; - if (drw>value && cl>0) - *adr=192+8*(drw-value)/step+(cl<<8); - else - *adr=192+(cl<<8); - adr-=SCRLLEN; - } - *adr=202+(15<<8); - } - -void init(int a,int b,int c,int d) - { - screen=(unsigned short *)SCRADR; - clear_window(0,0,79,24,15); - disp_str(0,0,"Output Device:",9); - disp_str(0,1,"Parameters:",9); - disp_str(0,3,"Track name:",9); - disp_str(0,4,"Mode:",9); - disp_str(0,5,"Blocks:",9); - disp_str(0,6,"Size:",9); - disp_str(0,7,"Playing time:",9); - if (a==-1) - if (sound_detect(&a,&b,&c,&d)) - { - disp_str(16,0,"No sound device found",14); - exit(1); - } - set_mixing_device(a,22050,b,c,d); - disp_str(16,0,device_name(a),14); - if (a>=DEV_SB10 && a<=DEV_ULTRA) - { - sprintf(istr,"port %03X dma %1d irq %1X",b,c,d); - disp_str(16,1,istr,13); - } - clear_window(50,0,79,3,30); - clear_window(50,4,79,7,4*16+15); - } - -void open_files(char *filename,char fade) - { - long total; - char spaces[50]; - - memset(spaces,32,50);spaces[30]=0; - if (bsnd!=NULL)fclose(bsnd); - if (filename!=NULL)if (fade) change_music(filename);else open_backsound(filename); - else blength=-1; - music_size=blength; - block_size=bblock_size; - disp_str(16,3,spaces,12); - error=0; - if (music_size==-1) - { - disp_str(16,3,"Track NOT found",12); - block_size=1; - bchans=1; - bfreq=1; - bblocks=0; - error=1; - } - else disp_str(16,3,filename,12); - if (bchans==1) - sprintf(istr,"16-bit mono %5d Hz ",bfreq); - else - sprintf(istr,"16-bit stereo %5d Hz",bfreq); - disp_str(16,4,istr,11); - sprintf(istr,"%05d",bblocks); - disp_str(16,5,istr,10); - sprintf(istr,"%05d KB",music_size/1024); - disp_str(16,6,istr,15); - total=(bblocks*block_size)/(bfreq*bchans); - sprintf(istr,"%02d:%02d",total/60,total%60); - disp_str(16,7,istr,14); - block_max=bblocks; - } - -void display_time(int bblocks) - { - long time,b; - - if (error) - { - disp_bnum(76,1,88,2); - disp_digit(68,1,10); - disp_bnum(64,1,88,2); - } - else - { - b=bblocks+128*1024/block_size; - if (b>block_max) b-=block_max; - time=(b*block_size)/(bfreq*bchans); - disp_bnum(76,1,time%60,2); - disp_digit(68,1,10); - disp_bnum(64,1,time/60,2); - } - } - -void display_bblocks(int bblocks) - { - long b; - - if (error) - disp_bnum(76,5,88888,5); - else - { - b=bblocks+128*1024/block_size; - if (b>block_max) b-=block_max; - disp_bnum(76,5,b,5); - } - } - -void volume_bars(int *left,int *right) - { - int i,k,l,r; - static last=0; - static sl,sr; - - r=backsnd-last; - if (r<0) r+=BACK_BUFF_SIZE/4; - if (r>VOL_BLOCK) - { - *left=sl; - *right=sr; - sr-=1000; - sl-=1000; - last=backsnd; - for(i=0;i=BACK_BUFF_SIZE/4) k-=BACK_BUFF_SIZE/4;; - l=*((short *)backsndbuff+k*2); - r=*((short *)backsndbuff+k*2+1); - if (l>sl) - sl=l; - if (r>sr) - sr=r; - } - } - } -char retrace() -//vraci stav kresliciho paprsku na obrazovce - { - return (((~inp(0x3da)) & 8)>>3); - } - -void wait_retrace() -//ceka na zpetny chod - { - while (!retrace()); - while (retrace()); - } - -void disp_volume() - { - disp_chan(77,23,bvolume*64,BVSTEP); - disp_chan(78,23,bvolume*64,BVSTEP); - disp_vbar_track(76,23,BVSTEP); - } - -void show_dir(int sel_file,int playing) - { - int cn=str_count(adresar); - int i=sel_file-5; - char spaces[32]; - int color; - - memset(spaces,32,32); - spaces[31]=0; - for(;i=cn || adresar[i]==NULL)disp_str(3,i-sel_file+17,spaces,0); - else disp_str(3,i-sel_file+17,adresar[i],color); - } - color=3+(playing==sel_file?2:0); - disp_str(1,17," ",color); - disp_str(21,17," ",color); - disp_str(0,17,"ďż˝",color); - disp_str(23,17,"ďż˝",color); - } -void play_next(char **next) - { - posledni++; - if (posledni>=str_count(adresar)) posledni=0; - if (adresar[posledni]==NULL) posledni=0; - if (adresar[posledni]==NULL) {*next=NULL;posledni=0;} - else - { - static char c[50]; - vybrano=posledni; - show_dir(vybrano,posledni); - strcpy(c,adresar[vybrano]); - name_conv(c); - open_files(c,0); - fclose(bsnd); - *next=c; - } - } - -void set_new_position() - { - static int l=0,r=0; - int i=bblocks; - long c; - int delta1=5,delta2=1; - int volsave; - char zn,oldzn; - - c=get_timer_value(); - do - { - if (_bios_keybrd(_KEYBRD_READY)) - switch (zn=_bios_keybrd(_KEYBRD_READ)>>8) - { - case 'M':i-=delta2; - if (i<0) i=0; - display_time(i); - c=get_timer_value(); - delta1--; - break; - case 'K':i+=delta2;if (i>=block_max) i=block_max-1; - display_time(i); - c=get_timer_value(); - delta1--; - break; - } - if (delta1<0) - { - delta1=5; - delta2++; - } - if (zn!=oldzn) delta2=1; - oldzn=zn; - display_bblocks(bblocks); - volume_bars(&l,&r); - mix_back_sound(0); - disp_chan(37,23,l,BVSTEP); - disp_chan(38,23,l,BVSTEP); - disp_chan(41,23,r,BVSTEP); - disp_chan(42,23,r,BVSTEP); - } - while (get_timer_value()-c<50); - if (i==bblocks) return; - volsave=get_snd_effect(SND_MUSIC); - set_snd_effect(SND_MUSIC,0); - set_snd_effect(SND_MUSIC,volsave);; - delta1=0; - if (i>bblocks && (i-bblocks)<(block_max-i)) - { - fseek(bsnd,4,SEEK_CUR); - for(;bblocksbblocks) open_backsound(NULL); - for(;bblocks!=i;bblocks--) - { - fread(&delta1,1,4,bsnd); - fseek(bsnd,4+delta1,SEEK_CUR); - display_bblocks(bblocks); - } - } - -extern int bxbass; -extern unsigned short predstih; -extern int dmatable[8][4]; -extern char intr_test; - - -static void print_dma(int dma_num) - { - int i,j,k; - - i=inp(dmatable[dma_num][0]); - j=inp(dmatable[dma_num][0]); - k=inp(dmatable[dma_num][2]); - cprintf("%04X %0X|",i+j*256,k); - } - -static void print_all_dma() - { - int i; - static char negate; - - for(i=0;i<8;i++) print_dma(i); - if (intr_test) - { - negate=!negate; - intr_test=0; - } - cprintf(" %c %d\r",negate?'*':' ',predstih); - } - -void MIXER(); -#pragma aux MIXER modify [eax ebx ecx edx esi edi]; - - -char refresh() - { - static int l=0,r=0; - char *c; - int z; - mix_back_sound(0); - if (manual_refresh) - { - MIXER(); - predstih=0x8000; - if (device==DEV_SB16) - { - int i; - i=inp(devport+0xf); - i=inp(devport+0xe); - } - } - else - { - display_bblocks(bblocks); - display_time(bblocks); - print_all_dma(); - volume_bars(&l,&r); - disp_chan(37,23,l,BVSTEP); - disp_chan(38,23,l,BVSTEP); - disp_chan(41,23,r,BVSTEP); - disp_chan(42,23,r,BVSTEP); - } - if (error && adresar[0]!=NULL) - { - play_next(&c); - open_files(c,0); - } - while (_bios_keybrd(_KEYBRD_READY)) - switch (_bios_keybrd(_KEYBRD_READ)>>8) - { - case 1:return 0; - case 'M': - case 'K': set_new_position();break; - case 0x39:if (pause) start_mixing(); else stop_mixing(); - pause=!pause; - break; - case 0x17:set_snd_effect(SND_OUTFILTER,2);break; - case 'I': if (bvolume<512) bvolume+=4; - disp_volume(); - break; - case 'Q': if (bvolume>3) bvolume-=4;else bvolume=0; - disp_volume(); - break; - case 'G': if (check_snd_effect(SND_LSWAP)) - { - z=get_snd_effect(SND_LSWAP); - z+=0xf;if (z>0xff) z=0xff; - set_snd_effect(SND_LSWAP,z); - }break; - case 'O': if (check_snd_effect(SND_LSWAP)) - { - z=get_snd_effect(SND_LSWAP); - z-=0xf;if (z<0) z=0; - set_snd_effect(SND_LSWAP,z); - } - case 'H': if (vybrano>0) - { - vybrano--;show_dir(vybrano,posledni); - }break; - break; - case 'P': if (vybrano+1256) bxbass=256;break; - case '<':bxbass-=16;if (bxbass<0) bxbass=0;break; - case 0x1c:if (adresar[vybrano]!=NULL) - { - char c[50]; - posledni=vybrano; - show_dir(vybrano,posledni); - strcpy(c,adresar[vybrano]); - name_conv(c); - open_files(c,vybrano); - break; - } - - } - return 1; - } - - -void restore_mode(); -#pragma aux restore_mode=\ - "mov eax,3"\ - "int 10h"\ - modify [eax]; - -main(int argc,char *argv[]) - { - int a,b,c,d; - - adresar=read_dir("*.mus",_A_NORMAL); - if (argc!=2 && argc!=6 && (argc!=1 || adresar[0]==NULL)) - { - int i; - printf("\n\nUsage: TRACK trackname [device] [port] [dma] [irq] \n" - " or TRACK * [device] [port] [dma] [irq] - plays current directory." - "\n\nDevice numbers:\n"); - for (i=0;i<7;i++) printf("%d. %s\n",i,device_name(i)); - puts("\nIf you use character '~' (tilda) as trackname, it will have the same\n" - "effect as '*' so you will able to play sound background in WIN95\n" - "But the volume bars will not display correct values."); - exit(0); - } - if (argc==6) - { - sscanf(argv[2],"%d",&a); - sscanf(argv[3],"%x",&b); - sscanf(argv[4],"%d",&c); - sscanf(argv[5],"%d",&d); - } - else - a=-1; - if (argv[1][0]=='~') manual_refresh=1; - def_fbars(); - //dve_sady(); - //font_effekt(); - set_palcolor(57,0,42,42); - set_palcolor(5,0,63,63); - init(a,b,c,d); - open_files(argv[1],0); - start_mixing(); - disp_vbar_track(36,23,BVSTEP); - disp_vbar_track(40,23,BVSTEP); - disp_volume(); - show_dir(0,1); - konec_skladby=play_next; - while (refresh()); - stop_mixing(); - clear_window(0,0,79,24,15); - restore_mode(); - } diff --git a/ZVUK/VESA.C b/ZVUK/VESA.C deleted file mode 100644 index a59e4d4..0000000 --- a/ZVUK/VESA.C +++ /dev/null @@ -1,296 +0,0 @@ -/********************************/ -/* Prace se SVGA VESA adapterem */ -/********************************/ - -#include -#include -#include -#include -#include "vesa.h" -#include "dosmem.h" - - extern void wm_ChangeBank_(int bank); - #pragma aux (ASM) wm_ChangeBank_; - - -void Set_VESA_mode (int mode) -{ - union REGS r; - - r.w.ax=0x4f02; - r.w.bx=mode; - int386 (0x10, &r, &r); -} - - -void Show_screen (char *display) -{ - wm_ChangeBank_ (0); - memmove (0xa0000, display, 65536); - wm_ChangeBank_ (1); - memmove (0xa0000, (display+65536), 65536); - wm_ChangeBank_ (2); - memmove (0xa0000, (display+131072), 65536); - wm_ChangeBank_ (3); - memmove (0xa0000, (display+196608), 65536); - wm_ChangeBank_ (4); - memmove (0xa0000, (display+262144), 45056); -} - -void Put_image (int x, int y, int xlen, int ylen, char *image) -{ - int a,b,c,d; - long int posunuti=0; - int banka; - - if (y<103) {wm_ChangeBank_ (0); banka=0;} - if (y>103 && y<205) {wm_ChangeBank_ (1); banka=1;} - if (y>205 && y<308) {wm_ChangeBank_ (2); banka=2;} - if (y>308 && y<410) {wm_ChangeBank_ (3); banka=3;} - if (y>410) {wm_ChangeBank_ (4); banka=4;} - - for (a=0; a<=ylen; a++) - { - - d=y+a; - switch (d) - { - case 102: - if ((x+xlen)<256){ - posunuti=(y+a)*640+x; - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - wm_ChangeBank_ (1); banka=1;} - if (x>=256){ - wm_ChangeBank_ (1); banka=1; - posunuti=(((y+a)*640+x)-65536); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - } - if (x<256 && (x+xlen)>256){ - posunuti=(y+a)*640+x; b=x; c=0; - while (b!=256) - {memmove ((0xa0000+posunuti), (image+a*(xlen+1)+c), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (1); banka=1; - posunuti=(((y+a)*640+x)-65536); - memmove ((0xa0000+posunuti+c), (image+a*(xlen+1)+c), (xlen-c));} - break; - case 204: - if ((x+xlen)<512){ - posunuti=(((y+a)*640+x)-65536); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - wm_ChangeBank_ (2); banka=2;} - if (x>=512){ - wm_ChangeBank_ (2); banka=2; - posunuti=(((y+a)*640+x)-131072); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen);} - if (x<512 && (x+xlen)>512){ - posunuti=(((y+a)*640+x)-65536); b=x; c=0; - while (b!=512) - {memmove ((0xa0000+posunuti), (image+a*(xlen+1)+c), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (2); banka=2; - posunuti=(((y+a)*640+x)-131072); - memmove ((0xa0000+posunuti+c), (image+a*(xlen+1)+c), (xlen-c));} - break; - - case 307: - if ((x+xlen)<128){ - posunuti=(((y+a)*640+x)-131072); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - wm_ChangeBank_ (3); banka=3;} - if (x>=128){ - wm_ChangeBank_ (3); banka=3; - posunuti=(((y+a)*640+x)-196608); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen);} - if (x<128 && (x+xlen)>128){ - posunuti=(((y+a)*640+x)-131072); b=x; c=0; - while (b!=128) - {memmove ((0xa0000+posunuti), (image+a*(xlen+1)+c), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (3); banka=3; - posunuti=(((y+a)*640+x)-196608); - memmove ((0xa0000+posunuti+c), (image+a*(xlen+1)+c), (xlen-c));} - break; - - case 409: - if ((x+xlen)<384){ - posunuti=(((y+a)*640+x)-196608); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - wm_ChangeBank_ (4); banka=4;} - if (x>=384){ - wm_ChangeBank_ (4); banka=4; - posunuti=(((y+a)*640+x)-262144); - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen);} - if (x<384 && (x+xlen)>384){ - posunuti=(((y+a)*640+x)-196608); b=x; c=0; - while (b!=384) - {memmove ((0xa0000+posunuti), (image+a*(xlen+1)+c), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (4); banka=4; - posunuti=(((y+a)*640+x)-262144); - memmove ((0xa0000+posunuti+c), (image+a*(xlen+1)+c), (xlen-c));} - break; - - default: - posunuti=(y+a)*640+x-banka*65536; - memmove ((0xa0000+posunuti), (image+a*(xlen+1)), xlen); - break; - }; - } -} - -void Get_image (int x, int y, int xlen, int ylen, char *image) -{ - int a,b,c,d; - long int posunuti=0; - int banka; - - if (y<103) {wm_ChangeBank_ (0); banka=0;} - if (y>103 && y<205) {wm_ChangeBank_ (1); banka=1;} - if (y>205 && y<308) {wm_ChangeBank_ (2); banka=2;} - if (y>308 && y<410) {wm_ChangeBank_ (3); banka=3;} - if (y>410) {wm_ChangeBank_ (4); banka=4;} - - for (a=0; a<=ylen; a++) - { - - d=y+a; - switch (d) - { - case 102: - if ((x+xlen)<256){ - posunuti=(y+a)*640+x; - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - wm_ChangeBank_ (1); banka=1;} - if (x>=256){ - wm_ChangeBank_ (1); banka=1; - posunuti=(((y+a)*640+x)-65536); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - } - if (x<256 && (x+xlen)>256){ - posunuti=(y+a)*640+x; b=x; c=0; - while (b!=256) - {memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (1); banka=1; - posunuti=(((y+a)*640+x)-65536); - memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti+c), (xlen-c));} - break; - case 204: - if ((x+xlen)<512){ - posunuti=(((y+a)*640+x)-65536); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - wm_ChangeBank_ (2); banka=2;} - if (x>=512){ - wm_ChangeBank_ (2); banka=2; - posunuti=(((y+a)*640+x)-131072); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen);} - if (x<512 && (x+xlen)>512){ - posunuti=(((y+a)*640+x)-65536); b=x; c=0; - while (b!=512) - {memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (2); banka=2; - posunuti=(((y+a)*640+x)-131072); - memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti+c), (xlen-c));} - break; - - case 307: - if ((x+xlen)<128){ - posunuti=(((y+a)*640+x)-131072); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - wm_ChangeBank_ (3); banka=3;} - if (x>=128){ - wm_ChangeBank_ (3); banka=3; - posunuti=(((y+a)*640+x)-196608); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen);} - if (x<128 && (x+xlen)>128){ - posunuti=(((y+a)*640+x)-131072); b=x; c=0; - while (b!=128) - {memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (3); banka=3; - posunuti=(((y+a)*640+x)-196608); - memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti+c), (xlen-c));} - break; - - case 409: - if ((x+xlen)<384){ - posunuti=(((y+a)*640+x)-196608); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - wm_ChangeBank_ (4); banka=4;} - if (x>=384){ - wm_ChangeBank_ (4); banka=4; - posunuti=(((y+a)*640+x)-262144); - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen);} - if (x<384 && (x+xlen)>384){ - posunuti=(((y+a)*640+x)-196608); b=x; c=0; - while (b!=384) - {memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti), 1); - posunuti++; b++; c++;} - wm_ChangeBank_ (4); banka=4; - posunuti=(((y+a)*640+x)-262144); - memmove ((image+a*(xlen+1)+c), (0xa0000+posunuti+c), (xlen-c));} - break; - - default: - posunuti=(y+a)*640+x-banka*65536; - memmove ((image+a*(xlen+1)), (0xa0000+posunuti), xlen); - break; - }; - } - -} - - -void Get_VESA_info (void) -{ - char far *str; - VESA_INFO_BLOCK *p; - - p=(VESA_INFO_BLOCK *)mem_alloc(sizeof(VESA_INFO_BLOCK)); - - memset(&dpmiregs,0,sizeof(DPMIREGS)); - dpmiregs.EAX=0x00004f00; - dpmiregs.DS=D32RealSeg(p); - dpmiregs.ES=D32RealSeg(p); - dpmiregs.EDI=D32RealOff(p); - - WtNs386(0x10,&dpmiregs); - - str=(char far *)MK_FP(Selector,0); - _fmemcpy(&VesaInfoBlock,str,sizeof(VESA_INFO_BLOCK)); - - mem_free(p); - if(dpmiregs.EAX!=0x4f) - { - printf ("VESA Bios extension not found!!!!"); - exit (1); - } -} - - -void Get_mode_info (int mode) -{ - char far *str; - VESA_MODE_INFO_BLOCK *p; - - p=(VESA_MODE_INFO_BLOCK *)mem_alloc(sizeof(VESA_MODE_INFO_BLOCK)); - - memset(&dpmiregs,0,sizeof(DPMIREGS)); //nuluje registry - dpmiregs.EAX=0x00004f01; - dpmiregs.DS=D32RealSeg(p); - dpmiregs.ES=D32RealSeg(p); - dpmiregs.EDI=D32RealOff(p); - dpmiregs.ECX=mode; - - WtNs386(0x10,&dpmiregs); - - str=(char far *)MK_FP(Selector,0); - _fmemcpy(&VesaModeInfoBlock,str,sizeof(VESA_INFO_BLOCK)); - - _VGAGran=VesaModeInfoBlock.WinGranularity; - - mem_free(p); -} - diff --git a/ZVUK/VESA.H b/ZVUK/VESA.H deleted file mode 100644 index a0f12a2..0000000 --- a/ZVUK/VESA.H +++ /dev/null @@ -1,70 +0,0 @@ -/********************************/ -/* Prace se SVGA VESA adapterem */ -/********************************/ - -#ifndef __VESA_H -#define __VESA_H - - -typedef struct -{ char VESASignature[4]; - short VESAversion; - unsigned OEMStringPtr; - char capabilities[4]; - short int *videomodeptr; - short int TotalMemory; - char dummy[236]; - } VESA_INFO_BLOCK; - -typedef struct -{ short unsigned ModeAttributes; - char WinAAttributes; - char WinBAttributes; - short unsigned WinGranularity; - short unsigned WinSize; - short unsigned WinASegment; - short unsigned WinBSegment; - short unsigned WinFuncPtroff; - short unsigned WinFuncPtrseg; - short unsigned BytesPerScanLine; - - short unsigned XResolution; - short unsigned YResolution; - char Xcharsize; - char Ycharsize; - char NumberOfPlanes; - char BitsPerPixel; - char NumberOfBanks; - char MemoryModel; - char BankSize; - char NumberOfImagePages; - char Reserved; - - char RedMaskSize; - char RedFieldPosition; - char GreenMaskSize; - char GreenFieldPosition; - char BlueMaskSize; - char BlueFieldPosition; - char RsvdMaskSize; - char DirectColorModeInfo; - char Dummy[216]; - } VESA_MODE_INFO_BLOCK; - - -VESA_MODE_INFO_BLOCK VesaModeInfoBlock; -VESA_INFO_BLOCK VesaInfoBlock; - -extern unsigned char _VGAPage=0; -extern unsigned char _VGAGran=0; - -void Set_VESA_mode (int mode); -void Show_screen (char *display); -void Get_VESA_info (void); -void Get_mode_info (int mode); - -void Put_image (int x, int y, int xlen, int ylen, char *image); -void Get_image (int x, int y, int xlen, int ylen, char *image); - -#endif - diff --git a/ZVUK/VESA_.ASM b/ZVUK/VESA_.ASM deleted file mode 100644 index d11920c..0000000 --- a/ZVUK/VESA_.ASM +++ /dev/null @@ -1,63 +0,0 @@ -;EAX EDX EBX ECX -.386p -jumps -;############################################################################ -; Constanty -;############################################################################ - -dlt_x equ 640 -dlt_y equ 480 - -;############################################################################ -; Datovy segment -;############################################################################ -_DATA SEGMENT PARA PUBLIC USE32 'DATA' -align 4 - - -EXTRN __VGAPage:BYTE -EXTRN __VGAGran:BYTE - - -_DATA ENDS - -DGROUP GROUP _DATA - -;############################################################################ -; Kodovy segment -;############################################################################ -_TEXT SEGMENT PARA PUBLIC USE32 'CODE' - ASSUME cs:_TEXT, ds:_DATA - - - -public wm_ChangeBank__ -wm_ChangeBank__ PROC - - push es - pushad - - push eax - mov edx, eax - mov ebx, 0000h - mov eax, 4f05h - int 10h - - pop eax - mov edx, eax - mov ebx, 0001h - mov eax, 4f05h - int 10h - - popad - pop es - ret - -wm_ChangeBank__ endp -;---------------------------------------------------------------------------- - -_TEXT ENDS - -END - - diff --git a/ZVUK/ZVUK1.C b/ZVUK/ZVUK1.C deleted file mode 100644 index d8d604c..0000000 --- a/ZVUK/ZVUK1.C +++ /dev/null @@ -1,872 +0,0 @@ -#include -#include -//#include -#include -#include -#include - -#include - - -#define MIX_MONO 8 -#define MIX_STEREO 16 -#define MIX_16STEREO 32 - -#define MUSIC1 "..\\music\\ascent.mus" -#define MUSIC2 "..\\music\\late.mus" -#define MUSIC3 "..\\music\\december.mus" -#define MUSIC4 "..\\music\\ssi.mus" -#define MUSIC5 "..\\music\\test.mus" - - -#define BACK_BUFF_SIZE 0x40000 - -#define DEV_SB10 0x0e -#define DEV_SB20 0x10 -#define DEV_SBPRO 0x12 -#define DEV_SB16 0x14 -#define DEV_WWS 0x16 -#define DEV_ULTRA 0x18 -#define DEV_DAC 0x1A -#define DEV_PCSPEAKER 0x1C - -#define MIX_REZERVA 0x50 - -#define build_dac_xlat() \ - {\ - int i;\ - for(i=0;i<256;i++) da_xlat[i]=i;\ - }\ - -#define sendsb(data) \ - while (inp(sbport+0xc) & 0x80);\ - outp(sbport+0xc,data) - -#define recivesb(data)\ - while (!(inp(sbport+0xe) & 0x80));\ - data=inp(sbport+0xa) - -char detect_enables[8]; - -#define irqdetect(irq) \ - {\ - if (detect_enables[irq]) \ - sbirq=irq;\ - detect_enables[irq]=0;\ - inp(sbport+0xE);\ - outp(0x20,0x20);\ - } - - -typedef struct tchannel - { - char *play_pos, *start_loop, *end_loop; - long speed_maj; - unsigned short speed_min, minor_pos, sample_type, vol_left, vol_right; - }TCHANNEL; - -char musiclist[5][30]={ - MUSIC1,MUSIC2,MUSIC3,MUSIC4,MUSIC5}; - -TCHANNEL chaninfo[32]; -char *mixbuffer; -char backsndbuff[BACK_BUFF_SIZE]; -volatile long backsnd=0; -volatile long backstep=1; -volatile int backfine=0; -long jumptable[3]; -long getdma; -long ido; -unsigned short predstih=0x960; -long lastdma; -long lastmix; -long mixpos; -long surpos; -long mixsize; -long dmaposadr; -long dmasizadr; -long dmapageadr; -long dmanum; -int dmamask; -int dmamode; -int device; -long samplerate=1000; -long mixfreq=100; -long idt_map[2]; -int call_back_data; -int call_back_sel; -unsigned short dpmiselector; -char mixer_zavora=0; -FILE *bsnd; -unsigned short bchans; -short btable[256]; -int bfreq,bblocks,bvolume=255; -char depack[32768]; - -char da_xlat[256]; // Xlat tabulka pro DA a PC Speaker; -int dac_port; //DAC port -int test_counter=0; - -char *sample1; -long last_load_size; - -int dmatable[8][4]= - { - {0,1,0x87,0x0A0B}, - {2,3,0x83,0x0A0B}, - {4,5,0x81,0x0A0B}, - {6,7,0x82,0x0A0B}, - {0xd0,0xd1,0x8f,0xD4D6}, - {0xd2,0xd3,0x8b,0xD4D6}, - {0xd4,0xd5,0x89,0xD4D6}, - {0xd6,0xd7,0x8a,0xD4D6} - }; - -int irqtable[16]={8,9,0xa,0xb,0xc,0xd,0xe,0xf,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77}; - -void *load_file(char *filename) - { - FILE *f; - long size,*p; - - f=fopen(filename,"rb"); - if (f==NULL) abort(); - fseek(f,0,SEEK_END); - size=ftell(f); - fseek(f,0,SEEK_SET); - p=(void *)malloc(size); - if (fread(p,1,size,f)!=size) abort; - fclose(f); - last_load_size=size; - return p; - } - -char *buff_alloc(); -#pragma aux buff_alloc modify[ebx ecx edx] value [eax] -void mixer(); -#pragma aux mixer modify [eax ebx ecx edx esi edi] -void setsbpro(); -#pragma aux setsbpro modify [eax edi] -void setsb2(); -#pragma aux setsb2 modify [eax edi] -void setsb16(); -#pragma aux setsb16 modify [eax edi] - -int sbport=0x220; -int sbirq=0; - -void init_dma(int dma) -{ -dmanum=dma; -dmaposadr=dmatable[dma][0]; -dmasizadr=dmatable[dma][1]; -dmapageadr=dmatable[dma][2]; -dmamask=dmatable[dma][3] >> 8; -dmamode=dmatable[dma][3] & 0xff; -} - -void prepare_dma(char *adr) -{ -int poz; - -outp(0x0C,0);outp(0xD8,0); -outp(dmamask,(dmanum & 3)+0x04); -outp(dmamode,(dmanum & 3)+0x58); -if (dmanum>3) poz=(long)adr >> 1; else poz=(long)adr; -outp(dmaposadr,poz & 0xff); -outp(dmaposadr,(poz>>8) & 0xff); -outp(dmapageadr,poz>>16); -outp(dmasizadr,0xff); -outp(dmasizadr,0xff); -outp(dmamask,dmanum & 3+0x04); -} - - - -void reset_blaster() -{ -int counter=100; -outp(sbport+0x6,1); -delay(10); -outp(sbport+0x6,0); -while (inp(sbport+0x0A)!=0xAA && counter--) delay(1); -} -void start_sbmono() -{ -prepare_dma(mixbuffer); -sendsb(0xd1); -sendsb(0x40); -sendsb(256 - (1000000 / samplerate)); -sendsb(0x48); -sendsb(0xff); -sendsb(0xff); -sendsb(0x1c); -} - -void stop_sbmono() -{ -sendsb(0xd3); -sendsb(0xd0); -//sendsb(0xda); -//sendsb(0xd0); -} - -void start_sb16(); - -void __interrupt __far sb16_irq() - { - int i=32767; - - i=inp(sbport+0xf); - i=inp(sbport+0xe); -// sendsb(0xb6); -// sendsb(0x30); -// sendsb(i & 0xff); -// sendsb(i >> 8); //play(16bit,signed,stereo,16384); - outp(0x20,0x20); - outp(0xA0,0x20); - } -void start_sb16() - { - int i=16383; - - outp(sbport+0x4,0x81); - outp(sbport+0x5,1 << dmanum); - outp(sbport+0x4,0x80); - switch (sbirq) - { - case 2:outp(sbport+0x5,0xf1);break; - case 5:outp(sbport+0x5,0xf2);break; - case 7:outp(sbport+0x5,0xf4);break; - } - outp(sbport+0x4,0x80); - prepare_dma(mixbuffer); - sendsb(0xd1); //speaker(enable) - sendsb(0x41); - sendsb(samplerate>>8); - sendsb(samplerate & 0xff); //Set_sample_rate(samplerate); - sendsb(0xb4); - sendsb(0x30); - sendsb(i & 0xff); - sendsb(i >> 8); //play(16bit,signed,stereo,16384); - outp(0x21,inp(0x21) & ~(1<>8); -sendsb(0x48); -sendsb(0xff); -sendsb(0xff); -sendsb(0x90); -outp(sbport+0x4,0x0e); -outp(sbport+0x5,0x13); -} - -void __interrupt __far sb10_irq() - { - int i=32767; - - i=inp(sbport+0xe); - sendsb(0x14); - sendsb(0xff); - sendsb(0xff); - outp(0x20,0x20); - outp(0xA0,0x20); - } - -void start_sb10() - { - prepare_dma(mixbuffer); - sendsb(0xd1); - sendsb(0x40); - sendsb((65536 - (256000000 / (samplerate*2)))>>8); - sendsb(0x14); - sendsb(0xff); - sendsb(0xff); - outp(0x21,inp(0x21) & ~(1<BACK_BUFF_SIZE) nextpos-=BACK_BUFF_SIZE; - return nextpos; - } - for(;;) - { - val=backsnd*4-nextpos; - if (val<0) val+=BACK_BUFF_SIZE; - if (val<32768) return nextpos; - for(count=16384;count>0;count--) - { - if (remain==0) - { - bblocks--; - if (bblocks<=0) - { - fclose(bsnd); - open_backsound(NULL); - } - load_music_block(); - last[0]=0; - last[1]=0; - remain=32768; - depos=0; - } - val=btable[depack[depos++]];remain--; - val+=last[swap]; - last[swap++]=val; - if (swap>=bchans) swap=0; - val=(val*bvolume)>>8; - if (val>32676) val=32767; - if (val<-32767) val=-32767; - *(short *)(backsndbuff+(nextpos))=val; - nextpos+=2; - if (nextpos>=BACK_BUFF_SIZE) nextpos=0; - } - } - } - - -void fade_music() - { - short *p; - int i,j,k,l,m; - - mix_back_sound(0); - k=backsnd*2; - i=k; - p=(short *)&backsndbuff; - m=mix_back_sound(1); - m=m-k*2; - if (m<0) m+=BACK_BUFF_SIZE; - m/=2; - j=m;m/=256; - do - { - l=j/256; - p[i]=p[i]*l/m; - i++;j--;if (j<0) j=0; - if (i>BACK_BUFF_SIZE/2) i=0; - } - while (i!=k); - memset(&depack,0x80,sizeof(depack)); - } - - -void stop_sbstereo() -{ -reset_blaster(); -outp(sbport+0x4,0x0e); -outp(sbport+0x5,0x11); -//sendsb(0xda); -//sendsb(0xd0); -} - -int init_blaster(int port) -{ -sbport=port; -reset_blaster(); -return(inp(sbport+0x0a)==0xaa); -} - - -void prepare_mixing(int mode) -{ -predstih=samplerate/mixfreq+MIX_REZERVA; -predstih+=MIX_REZERVA+predstih; -predstih*=(mode/MIX_MONO); -switch (mode) - { - case MIX_MONO:setsb2();break; - case MIX_STEREO:setsbpro();break; - case MIX_16STEREO:setsb16();break; - } -backsndbuff[0]=0;backstep=bfreq*0x10000/samplerate;backsnd=0; -//backsndbuff[0]=128;backstep=0;backsnd=0; -lastdma=0; -mixpos=(long)(mixbuffer+predstih); -memset(chaninfo,0,sizeof(TCHANNEL)*32); -memset(mixbuffer,0x80,65536); -} - -void play_sample(int channel,void *sample,long size,long lstart,long sfreq,int type) - { - chaninfo[channel].play_pos=sample; - chaninfo[channel].start_loop=(char *)sample+lstart; - chaninfo[channel].end_loop=(char *)sample+size; - chaninfo[channel].speed_maj=sfreq/samplerate; - chaninfo[channel].speed_min=(sfreq%samplerate)*65536/samplerate; - chaninfo[channel].sample_type=type; - } - -void set_channel_volume(int channel,int left,int right) - { - chaninfo[channel].vol_left=left; - chaninfo[channel].vol_right=right; - } - -void set_bass_treble(int x,int y) - { - outp(sbport+4,0x44);outp(sbport+5,y); - outp(sbport+4,0x45);outp(sbport+5,y); - outp(sbport+4,0x46);outp(sbport+5,x); - outp(sbport+4,0x47);outp(sbport+5,x); - } - -void mixing() -{ -int c;int smpsize; -int treble=240,bass=240; - -sample1=(char *)load_file("d:\\music\\samples\\fx\\playboy.smp"); -smpsize=last_load_size; -set_channel_volume(0,32768,0); -set_channel_volume(1,0,32768); -for (c=2;c<12;c++) - set_channel_volume(c,(c-2)*3000,27000-(c-2)*3000); -c=0; -while (c!=1) -{ -int a,b; - a=inp(dmaposadr); - a+=inp(dmaposadr)<<8; - b=(bblocks*65536)/(22050*bchans*2); - cprintf("%04X %6X %6X volume %03d block:%04d time %02d:%02d %10d\r",a,mixpos,mixsize,bvolume,bblocks,b/60,b%60,test_counter); - mix_back_sound(0); - //mixer(); - c=0; - while (_bios_keybrd(_KEYBRD_READY)) - { - c=_bios_keybrd(_KEYBRD_READ)>>8; - switch(c) - { - case 'H': if (bvolume<512) bvolume++;break; - case 'P': if (bvolume>0) bvolume--;break; - case 'I': if (treble<240) treble+=16;set_bass_treble(bass,treble);break; - case 'Q': if (treble>0) treble-=16;set_bass_treble(bass,treble);break; - case 'G': if (bass<240) bass+=16;set_bass_treble(bass,treble);break; - case 'O': if (bass>0) bass-=16;set_bass_treble(bass,treble);break; - case 'M': if (bblocks>0) - { - mixer_zavora=1; - backsnd+=8196;if (backsnd>BACK_BUFF_SIZE/4) backsnd-=BACK_BUFF_SIZE/4; - mixer_zavora=0; - } - break; - case 'K': if (ftell(bsnd)>2*(32768+8)) - { - fseek(bsnd,-2*(32768+8),SEEK_CUR); - bblocks++; - load_music_block(); - } - break; - case 0x17: - do - { - a=inp(dmaposadr); - a+=inp(dmaposadr)<<8; - } - while (!(a & 1)); - do - { - a=inp(dmaposadr); - a+=inp(dmaposadr)<<8; - } - while (a & 1); - outp(sbport+0x4,0x0e); - outp(sbport+0x5,inp(sbport+0x5) ^ 0x20); - break; - default: - if (c>=2 && c<=11) - play_sample(c-2,sample1,smpsize,smpsize,11000,1); - else - if (c>=';' && c<='@') - { - fclose(bsnd); - fade_music(); - open_backsound(musiclist[c-';']); - } - - } - } - } -} - -int int_relocation(); -#pragma aux int_relocation modify [eax ebx ecx edx esi edi] -void int_mixer_alloc(int num); -#pragma aux int_mixer_alloc parm [ebx] modify [eax ecx edx esi edi] -int int_dealloc(); -#pragma aux int_dealloc modify [eax ebx ecx edx esi edi] -void __interrupt __far int_normal(); -void high_speed_parm(void *mix,int dosdelay,char *xlattab,int port); -#pragma aux high_speed_parm parm [ebx][eax][esi][edx] modify [edi] -void int_high_alloc(int num); -#pragma aux int_high_alloc parm [ebx] modify [eax ecx edx esi edi] - - -void int_init() - { - int l; - _dos_setvect(0x1c,int_normal); - l=0x1234bc/mixfreq; - outp(0x43,0x34); - outp(0x40,l%256); - outp(0x40,l/256); - } - -void int_highspeed(int port) - { - int l; - _dos_setvect(0x1c,int_normal); - high_speed_parm(mixbuffer,samplerate/mixfreq,da_xlat,port); - int_high_alloc(0x8); - l=0x1234bc/samplerate; - outp(0x43,0x34); - outp(0x40,l%256); - outp(0x40,l/256); - } - - -void set_mixing_device(int mix_dev,int mix_freq,...) - { - int *p; - samplerate=mix_freq; - mixbuffer=buff_alloc(); - p=&mix_freq;p++; - device=mix_dev; - switch (mix_dev) - { - case DEV_SB10: - case DEV_SB20: - case DEV_SBPRO: - case DEV_SB16: - init_blaster(p[0]); - init_dma(p[1]); - sbirq=p[2]; - break; - case DEV_DAC: - dac_port=p[0]; - break; - } - } - -void start_mixing() - { - switch (device) - { - case DEV_SB10: - start_sb10(); - int_init(); - prepare_mixing(MIX_MONO); - break; - case DEV_SB20: - start_sbmono(); - int_init(); - prepare_mixing(MIX_MONO); - break; - case DEV_SBPRO: - start_sbstereo(); - int_init(); - prepare_mixing(MIX_STEREO); - break; - case DEV_SB16: - start_sb16(); - int_init(); - prepare_mixing(MIX_16STEREO); - break; - case DEV_DAC: - build_dac_xlat(); - prepare_mixing(MIX_MONO); - int_highspeed(dac_port); - break; - } - } - -void stop_mixing() - { - outp(0x43,0x34); - outp(0x40,0); - outp(0x40,0); - switch (device) - { - case DEV_SB10: - stop_sb10(); - break; - case DEV_SB20: - stop_sbmono(); - break; - case DEV_SBPRO: - stop_sbstereo(); - break; - case DEV_SB16: - stop_sb16(); - break; - case DEV_DAC: - int_dealloc(); - break; - } - } - -void __far __interrupt sb_detect_irq2() -irqdetect(2) -void __far __interrupt sb_detect_irq3() -irqdetect(3) -void __far __interrupt sb_detect_irq5() -irqdetect(5) -void __far __interrupt sb_detect_irq7() -irqdetect(7) - - -char *device_name(int device) - { - static char names[][25]= - { - "Unsupported Device", - "Sound Blaster", - "Sound Blaster 2", - "Sound Blaster Pro/2", - "Sound Blaster 16+", - "Windows Sound System", - "UltraSound", - "DAC on LPT", - "Internal Hooker", - "Pro Audio Spectrum" - }; - - switch (device) - { - case DEV_SB10:return names[1]; - case DEV_SB20:return names[2]; - case DEV_SBPRO:return names[3]; - case DEV_SB16:return names[4]; - case DEV_WWS:return names[5]; - case DEV_ULTRA:return names[6]; - case DEV_DAC:return names[7]; - case DEV_PCSPEAKER:return names[8]; - } - return names[0]; - } - -int sb_detect(int *dev,int *port,int *dma, int *irq) - { - int i,a,j; - char ver_lo; - char ver_hi; - void __far *irqsave2,__far *irqsave3,__far *irqsave5,__far *irqsave7; - int dmasaves[4]; - char dmadis[4]; - int dmatesting[4]={1,3,0,1}; - - *port=0x210; - do - { - sbport=*port; - outp(sbport+6,1);delay(1); - outp(sbport+6,0); - for(i=0;i<100 && inp(sbport+0xA)!=0xAA;i++) delay(1); - (*port)+=0x10; - } - while (i==100 && sbport<0x280); - if (i==100) return -1; //NOT DETECTED; - *port=sbport; - sendsb(0xe1); - recivesb(ver_lo); - recivesb(ver_hi); - switch (ver_hi) - { - case 1: *dev=DEV_SB10;break; - case 2: if (ver_lo) *dev=DEV_SB20;break; - case 3: *dev=DEV_SBPRO;break; - case 4: *dev=DEV_SB16;break; - default: *dev=DEV_SB10;break; - } - if (*dev==DEV_SB16) - { - outp(sbport+4,0x80); - i=inp(sbport+5); - *irq=5; - if (i & 8) *irq=7; - if (i & 4) *irq=7; - if (i & 2) *irq=5; - if (i & 1) *irq=2; - outp(sbport+4,0x81); - i=inp(sbport+5); - *dma=1; - if (i & 1) *dma=0; - if (i & 2) *dma=1; - if (i & 8) *dma=3; - return 0; - } - for(i=0;i<4;i++) - { - outp(0xc,0); - a=inp(dmatable[i][0]); - a=a+256*inp(dmatable[i][0]); - dmasaves[i]=a; - } - irqsave2=_dos_getvect(irqtable[2]); - irqsave3=_dos_getvect(irqtable[3]); - irqsave5=_dos_getvect(irqtable[5]); - irqsave7=_dos_getvect(irqtable[7]); - _dos_setvect(irqtable[2],sb_detect_irq2); - _dos_setvect(irqtable[3],sb_detect_irq3); - _dos_setvect(irqtable[5],sb_detect_irq5); - _dos_setvect(irqtable[7],sb_detect_irq7); - ver_lo=inp(0x21); - outp(0x21,0x53); - memset(detect_enables,0x1,sizeof(detect_enables)); - delay(100); - sbirq=-1; - sendsb(0xf2); - delay(1); - _dos_setvect(irqtable[2],irqsave2); - _dos_setvect(irqtable[3],irqsave3); - _dos_setvect(irqtable[5],irqsave5); - _dos_setvect(irqtable[7],irqsave7); - outp(0x21,ver_lo); - if (sbirq==-1) return -2; //DETECTION ERROR - *irq=sbirq; - for(i=0;i<4;i++) - { - outp(0xc,0); - a=inp(dmatable[i][0]); - a=a+256*inp(dmatable[i][0]); - dmadis[i]=(dmasaves[i]==a); - } - for (j=0,*dma=-1;j<4 && *dma==-1;j++) - { - i=dmatesting[j]; - init_dma(i); - prepare_dma(NULL); - sendsb(0xd3); - sendsb(0x14); - sendsb(0xff); - sendsb(0x7f); - delay(100); - outp(0xc,0); - a=inp(dmatable[i][0]); - a=a+256*inp(dmatable[i][0]); - if (dmasaves[i]!=a && dmadis[i]) *dma=i; - reset_blaster(); - } - if (*dma==-1) return -2; - return 0; - } - -main() -{ -int a,b,c,d; -printf("%d\n",sizeof(TCHANNEL)); -if (sb_detect(&a,&b,&c,&d)) - { - printf("SB not present\n"); - return; - } -//a=DEV_SBPRO; -printf("%s\n",device_name(a)); -//printf("IRQ:\n"); -//scanf("%d",&d); -set_mixing_device(a,22050,b,c,d); -printf("Port %03X dma %d irq %d freq %d.\n",b,c,d,samplerate); -open_backsound(MUSIC1); -start_mixing(); -mixing(); -stop_mixing(); -printf("\n\n\n"); -} - - - - diff --git a/ZVUK/ZVUK1A.ASM b/ZVUK/ZVUK1A.ASM deleted file mode 100644 index 2646da9..0000000 --- a/ZVUK/ZVUK1A.ASM +++ /dev/null @@ -1,271 +0,0 @@ -.model small -.386 - -DGROUP group _DATA - - -tchannel struct - PLAYPOS DD ? - STARTLOOP DD ? - ENDLOOP DD ? - SPEEDMAJ DD ? - SPEEDMIN DW ? - MINORPOS DW ? - SMPTYPE DW ?;0 - DISABLED, 1 - 8 BIT, 2 - 16 BIT - VOLUMELEFT DW ? - VOLUMERIGHT DW ? -tchannel ends - -extrn _chaninfo:dword -extrn _mixbuffer:dword -extrn _backsnd:dword ;ukazatel na buffer s hudbou na pozadi (64Kb) -extrn _backstep:dword ;krok o kolik se meni _backsnd -extrn _backsndbuff:dword ;buffer hudby na pozadi - - -extrn _jumptable:dword[3] ;[0] - skip, [1] - mix8, [2] - mix16 -extrn _getdma:dword -extrn _ido:dword - -extrn _predstih:word -extrn _lastdma:dword -extrn _lastmix:dword -extrn _surpos:dword -extrn _mixpos:dword -extrn _mixsize:dword - -extrn _dmaposadr:dword -extrn _dpmiselector:word - - - -_TEXT segment byte public 'CODE' use32 - assume CS:_TEXT - assume DS:DGROUP - - PUBLIC MIXER_ -MIXER_: ;THIS IS MAIN MIXING PROCEDURE. - ;BEFORE USING, YOU MUST SET UP ALL VARIBLES TO THE CORRECT VALUES. - ;_MIXBUFFER MUST START ON PAGE OF MEMORY (EXP 0x10000 0x20000 0x30000) - ;PROCEDURE MUST BE CALLED EACH 55ms OR LITTLE. - ;IF YOU USING INTERRUPT, REMEBER, THAT YOU MUST STORE ALL REGISTERS - ;BEFORE USE. - - CALL calcsize ;VYPOCET DELKY MIXOVANI - mov edi,_mixpos ;Nejprve se vymaze mixovaci pamet - mov ecx,_mixsize - shr ecx,2 - jnz MIXOK - ret -MIXOK: xor eax,eax -MIXCLR: mov [edi],eax - add di,4 - dec ecx - jnz MIXCLR - lea ebx,_chaninfo ;TED SE ZACNE MIXOVAT -MIXING: xor eax,eax - mov ax,smptype[ebx] - call _jumptable[eax*4] - add ebx,sizeof(tchannel) - cmp ebx,(32*sizeof(tchannel))+offset _chaninfo - jnz MIXING - call _ido - mov ecx,_mixsize - add word ptr _mixpos,cx - add word ptr _surpos,cx - ret - - -CALCSIZE:call _getdma ;eax - pozice v mixovaci pameti - mov ebx,_lastdma - mov _lastdma,eax - sub ax,bx - add ax,_predstih - add ax,word ptr _lastdma - mov bx,word ptr _mixpos - sub ax,bx - js CALCEND - and ax,not 3 - add ax,4 - and eax,0ffffh - mov _mixsize,eax - ret -CALCEND:mov _mixsize,0 - ret - -ADDC macro REG1,REG2,CLIP - local addc1 - add REG1,REG2 - jno addc1 - shl REG2,1 - Mov REG2,CLIP - adc REG2,0 - mov REG1,REG2 -addc1: - endm - - - -MIXS_ :;primixuje sampl do bufferu (8-bit stereo) - ;musi platit vsechny promenne a ebx je adresa kanalu - mov edi,_mixpos - mov ecx,_mixsize - mov esi,[ebx] - push ebp - mov bp,minorpos[ebx] -mixslp: mov al,[esi] - mov ah,al - mov edx,eax - mov al,byte ptr volumeleft[ebx+1] - imul dl - shl eax,1 - mov dl,ah - mov al,byte ptr volumeright[ebx+1] - imul dh - shl eax,1 - mov dh,ah - mov ax,[edi] - addc al,dl,7fh - addc ah,dh,7fh - mov [edi],ax ;je smixovano - add di,2 ;dalsi pozice - add bp,speedmin[ebx] - adc esi,speedmaj[ebx] - cmp esi,endloop[ebx] - jc mixsskp - mov esi,startloop[ebx] - cmp esi,endloop[ebx] - jnz mixsskp - mov smptype[ebx],0 - jmp mixsend -mixsskp:dec ecx - dec ecx - jnz mixslp -mixsend:mov minorpos[ebx],bp - mov playpos[ebx],esi - pop ebp - ret - -mixskip:ret -mixs2: ret - -m8sido: mov esi,_mixpos - mov edi,_surpos ;surpos musi byt liche - mov ecx,_mixsize - mov edx,_backsnd ;backsnd-index na hudbu v pozadi -m8sido1:mov al,[edi] ;vem surround data - sar al,1 ;sniz jejich hlasitost - mov ah,[esi] ;vem namixovana data - addc al,ah,7fh ;secti je mezi sebou - mov ah,byte ptr _backsndbuff[edx] ;ven data z hudby v pozadi - add dx,word ptr _backstep ;mezitim jdi na dalsi index - addc al,ah,7fh ;secti je mexi sebou - mov [edi],al - inc di ;dalsi pozice v mixbuff - inc si - dec ecx ;dokud to neni vsechno - jnz m8sido1 ;opakuj - mov _backsnd,edx ;zachovej index do backsoundbuff - mov esi,_surpos ;nyni pracuj jiz s prehravanymi daty - and esi,not 1 - mov edi,esi - sub si,2 ;pozice o jeden sampl za - mov ecx,_mixsize ;velikost/2 - shr ecx,1 -m8sido2:mov ax,[esi] ;vem cely sampl - xor ax,8080h - mov bx,[edi] - xor bx,8080h - ;add al,bl ;uplna prumerovaci interpolace - ;rcr al,1 - ;add ah,bh - ;rcr ah,1 - mov [esi],ax - add di,2 ;dalsi vzorek - add si,2 - dec ecx - jnz m8sido2 ;dokud neni konec - ret - -sbdma: mov edx,_dmaposadr - out 0ch,al - out 0d8h,al - xor eax,eax - in al,dx - xchg al,ah - in al,dx - xchg al,ah - add eax,offset _mixbuffer - ret - - -PUBLIC setsbpro_ -setsbpro_: - lea edi,_jumptable - mov eax,offset mixskip - stosd - mov eax,offset mixs_ - stosd - mov eax,offset mixs2 - stosd - mov _getdma,offset sbdma - mov _ido,offset m8sido - ret - - - -dpmibufalloc: - mov ax,0100h - int 31h - ret - - - -public buff_dealloc_ -buff_dealloc_: - mov dx,_dpmiselector - mov ax,0101h - int 31h - ret - -public buff_alloc_ - -buff_alloc_: - mov ebx,4200 - call dpmibufalloc - jc allcerror - test eax,0fffh - jz allc_ok - push eax - mov eax,0101h - int 31h - pop eax - mov ebx,eax - and ebx,0f000h - add ebx,1000h - sub ebx,eax - dec ebx - call dpmibufalloc - jc allcerror - push edx - call buff_alloc_ - mov ecx,edx - pop edx - push eax - mov eax,0101h - int 31h - pop eax - ret -allc_ok:mov _dpmiselector,dx - shl eax,4 - ret -allcerror: - mov word ptr _dpmiselector,0 - xor eax,eax - ret - -_TEXT ends - -end - - diff --git a/ZVUK/ZVUK2A.ASM b/ZVUK/ZVUK2A.ASM deleted file mode 100644 index 2ec022f..0000000 --- a/ZVUK/ZVUK2A.ASM +++ /dev/null @@ -1,741 +0,0 @@ -.model small -.386P - -DGROUP group _DATA - - -tchannel struct - PLAYPOS DD ? - STARTLOOP DD ? - ENDLOOP DD ? - SPEEDMAJ DD ? - SPEEDMIN DW ? - MINORPOS DW ? - SMPTYPE DW ?;0 - DISABLED, 1 - 8 BIT, 2 - 16 BIT - VOLUMELEFT DW ? - VOLUMERIGHT DW ? -tchannel ends - -rm_playdata struct - XLAT_TAB DB 256 DUP(?) - SCANOFS DW ? - SCANSEG DW ? - PORT DW ? -rm_playdata ends - -extrn _chaninfo:dword -extrn _mixbuffer:dword -extrn _backsnd:dword ;ukazatel na buffer s hudbou na pozadi (64Kb) -extrn _backstep:dword ;krok o kolik se meni _backsnd -extrn _backfine:dword ;citac udavajici kdy se zmeni _backsnd -extrn _backsndbuff:dword ;buffer hudby na pozadi -extrn _call_back_data:dword ;data_call_back_procedury -extrn _call_back_sel:word ;data_call_back_procedury - -extrn _jumptable:dword[3] ;[0] - skip, [1] - mix8, [2] - mix16 -extrn _getdma:dword -extrn _ido:dword - -extrn _predstih:word -extrn _lastdma:dword -extrn _lastmix:dword -extrn _surpos:dword -extrn _mixpos:dword -extrn _mixsize:dword - -extrn _dmaposadr:dword -extrn _dpmiselector:word - -extrn _idt_map:dword - -extrn _test_counter:dword - -extrn _mixer_zavora:byte - -_TEXT segment byte public 'CODE' use32 - assume CS:_TEXT - assume DS:DGROUP - - PUBLIC MIXER_ -MIXER_: ;THIS IS MAIN MIXING PROCEDURE. - ;BEFORE USING, YOU MUST SET UP ALL VARIBLES TO THE CORRECT VALUES. - ;_MIXBUFFER MUST START ON PAGE OF MEMORY (EXP 0x10000 0x20000 0x30000) - ;PROCEDURE MUST BE CALLED EACH 55ms OR LITTLE. - ;IF YOU USING INTERRUPT, REMEBER, THAT YOU MUST STORE ALL REGISTERS - ;BEFORE USE. - - cmp _mixer_zavora,0 - jnz mixend - inc _mixer_zavora - CALL calcsize ;VYPOCET DELKY MIXOVANI - mov edi,_mixpos ;Nejprve se vymaze mixovaci pamet - mov ecx,_mixsize - shr ecx,2 - jz MIXALL -MIXOK: xor eax,eax -MIXCLR: mov [edi],eax - add di,4 - dec ecx - jnz MIXCLR - lea ebx,_chaninfo ;TED SE ZACNE MIXOVAT -MIXING: xor eax,eax - mov ax,smptype[ebx] - call _jumptable[eax*4] - add ebx,sizeof(tchannel) - cmp ebx,(32*sizeof(tchannel))+offset _chaninfo - jnz MIXING - call _ido - mov ecx,_mixsize - add word ptr _mixpos,cx -MIXALL: mov _mixer_zavora,0 -MIXEND: ret - - -CALCSIZE:call _getdma ;eax - pozice v mixovaci pameti - mov ebx,_lastdma - mov _lastdma,eax - sub ax,bx - add ax,_predstih - add ax,word ptr _lastdma - mov bx,word ptr _mixpos - sub ax,bx - js CALCEND - and ax,not 3 - add ax,4 - and eax,0ffffh - mov _mixsize,eax - ret -CALCEND:mov _mixsize,0 - ret - -ADDC macro REG1,REG2,CLIP - local addc1 - add REG1,REG2 - jno addc1 - shl REG2,1 - Mov REG2,CLIP - adc REG2,0 - mov REG1,REG2 -addc1: - endm - - - -MIXS_ :;primixuje sampl do bufferu (8-bit stereo) - ;musi platit vsechny promenne a ebx je adresa kanalu - mov edi,_mixpos - mov ecx,_mixsize - mov esi,[ebx] - push ebp - mov bp,minorpos[ebx] -mixslp: mov dl,[esi] - mov dh,dl - mov al,byte ptr volumeleft[ebx+1] - imul dl - shl eax,1 - mov dl,ah - mov al,byte ptr volumeright[ebx+1] - imul dh - shl eax,1 - mov dh,ah - mov ax,[edi] - addc al,dl,7fh - addc ah,dh,7fh - mov [edi],ax ;je smixovano - add di,2 ;dalsi pozice - add bp,speedmin[ebx] - adc esi,speedmaj[ebx] - cmp esi,endloop[ebx] - jc mixsskp - mov esi,startloop[ebx] - cmp esi,endloop[ebx] - jnz mixsskp - mov smptype[ebx],0 - jmp mixsend -mixsskp:dec ecx - dec ecx - jnz mixslp -mixsend:mov minorpos[ebx],bp - mov playpos[ebx],esi - pop ebp - ret - -mixskip:ret -mixs2 :;primixuje sampl do bufferu (16-bit stereo) - ;musi platit vsechny promenne a ebx je adresa kanalu - mov edi,_mixpos ;vem mixovaci pozici - mov ecx,_mixsize ;vem pocet potrebnych bajtu - mov esi,[ebx] ;vyzvedni ukazatel na sample - push ebp ;zachovej bp - mov bp,minorpos[ebx] ;bp pro tuto chvili predstavuje minorpozici -mix2slp:mov dl,[esi+1] ;vem sample, ale jen vyssi bajt - mov dh,dl ;zkopiruj levy kanal do praveho - mov al,byte ptr volumeleft[ebx+1];vyzvedni hlasitost leveho kanalu - imul dl ;nasob vzorek hlasitosti - shl eax,1 ;vysledek je v ah vydelen 256x - mov dl,ah ;schovej vysledek do dl - mov al,byte ptr volumeright[ebx+1];to same pro pravy kanal - imul dh - shl eax,1 - mov dh,ah - mov ax,[edi] ;ted precti aktualni stav samplu v bufferu - addc al,dl,7fh ;pricti levy kanal s clippingem - addc ah,dh,7fh ;pricti pravy kanal s clippingem - mov [edi],ax ;je smixovano - add di,2 ;dalsi pozice - add bp,speedmin[ebx] ;skok po minor hodnotach - lahf ;uchovej priznaky v ah (hlavne cf) - adc esi,speedmaj[ebx] ;skok po major hodnotach - sahf ;obnov cf - adc esi,speedmaj[ebx] ;a jeste jednou celkem o 2xvic nez je rychlost - cmp esi,endloop[ebx] ;test na konec samplu - jc mix2sskp ;pokud jsme prekrocili konec mohou nastat dva - mov esi,startloop[ebx];pripady: - cmp esi,endloop[ebx] ; bud ma sampl opakovani pak zacina na adrese - jnz mix2sskp ; startloop nebo nema - mov smptype[ebx],0 ; pak je vypnut - jmp mix2send ;skoc na konec -mix2sskp:dec ecx ;pokracujeme v prehravani - dec ecx ;byly naplneny 2 bajty, citac o 2 dolu - jnz mix2slp ;opakuj cele mixovani dokud neni citac nule -mix2send:mov minorpos[ebx],bp ;uloz minorpozici - mov playpos[ebx],esi ;uloz majorpozici - pop ebp ;obnov BP - ret ;konec - -m8sido: mov esi,_mixpos ;vem mixovaci pozici - sub si,2 ;o jeden sampl dozadu - mov edi,_backfine ;finepozice - mov ebx,_backsnd ;pozice v bufferu - mov ecx,_mixsize ;pocet bajtu - sub ecx,2 - shl ecx,16 ;uloz do horni poloviny ecx - mov ax,[esi] ;vezmi sample - xor eax,8080h ;neznaminkova korekce -m8sido1:add si,2 ;dalsi sample - mov dx,[esi] ;nacti do dx sample - xor edx,8080h ;neznaminkova korekce - add al,dl ;secti leve kanaly - rcr al,1 ;nasleduje deleni 2x prumer - add ah,dh ;totez pro prave kanaly - rcr ah,1 - xor eax,8080h ;neznaminkova korekce - mov cl,byte ptr _backsndbuff[1+ebx*4] ;nacti back sound pro levej kanal - mov ch,byte ptr _backsndbuff[3+ebx*4];nactu back sound pro pravej kanal - addc al,cl,7fh ;secti s clippingem levy kanal - addc ah,ch,7fh ;secti s clippingem pravy kanal - add di,word ptr _backstep ;pricti fine pozici - adc bx,word ptr [_backstep+2];preteceni jde do bx plus step - and ebx,03ffffh ;celkem 16384*4 samplu - xor eax,8080h ;neznaminkova korekce - sub si,2 ;uloz na zdrojovou pozici - mov [esi],ax - add si,2 - mov eax,edx ;pouzity sampl pro prumerovani se - sub ecx,20000h ;do ax a odecti dva takty pro citac - jnc m8sido1 ;a opakuj dokud neni konec - mov _backsnd,ebx - mov _backfine,edi - ret ;navrat - - -sbdma: mov edx,_dmaposadr - out 0ch,al - out 0d8h,al - xor eax,eax - in al,dx - xchg al,ah - in al,dx - xchg al,ah - add eax,_mixbuffer - ret - - -PUBLIC setsbpro_ -setsbpro_: - lea edi,_jumptable - mov eax,offset mixskip - stosd - mov eax,offset mixs_ - stosd - mov eax,offset mixs2 - stosd - mov _getdma,offset sbdma - mov _ido,offset m8sido - ret - - -MIXM_ :;primixuje sampl do bufferu (8-bit mono) - ;musi platit vsechny promenne a ebx je adresa kanalu - mov edi,_mixpos ;vezmi mixovaci pozici - mov ecx,_mixsize ;vezmi delku mixovani - mov esi,[ebx] ;nacti ukazatel na aktualni pozici v samplu - push ebp ;uchovej docasne BP - mov bp,minorpos[ebx] ;bp ma novou ulohu, drzi minor pozici - mov al,byte ptr volumeleft[ebx+1] ;vypocti hlasitost - mov ah,byte ptr volumeright[ebx+1] - add al,ah - rcr al,1 ;jak prumer leve a prave hlasitosti - mov dh,al -mixmlp: mov al,[esi] ;vezmi sample - imul dh ;vynasob s hlasitosti - shl eax,1 ;vydel /256x (ah je vysledek) - mov al,[edi] ;vezmi momentalni obsah bufferu - addc al,ah,7fh ;secti s clippingem - mov [edi],al ;je smixovano - inc di ;dalsi pozice - add bp,speedmin[ebx] - adc esi,speedmaj[ebx] - cmp esi,endloop[ebx] - jc mixmskp - mov esi,startloop[ebx] - cmp esi,endloop[ebx] - jnz mixmskp - mov smptype[ebx],0 - jmp mixmend -mixmskp:dec ecx - jnz mixmlp -mixmend:mov minorpos[ebx],bp - mov playpos[ebx],esi - pop ebp - ret - -m8mido: mov esi,_mixpos ;vem mixovaci pozici - dec si ;o jeden sampl dozadu - lea edi,_backfine ;ukazatel na back sound buffer - mov ebx,_backsnd ;pozice v bufferu - mov ecx,_mixsize ;pocet bajtu - dec ecx - shl ecx,16 ;uloz do horni poloviny ecx - mov al,[esi] ;vezmi sample - xor eax,80h ;neznaminkova korekce -m8mido1:inc si ;dalsi sample - mov dl,[esi] ;nacti do dx - xor edx,80h ;neznaminkova korekce - add al,dl ;secti kanal - rcr al,1 ;nasleduje deleni 2x prumer - xor eax,80h ;vysledek oznamenkuj - bude se scitat - mov cl,byte ptr _backsndbuff[1+ebx*4];nacti back sound pro levej kanal - mov ch,byte ptr _backsndbuff[3+ebx*4];nactu back sound pro pravej kanal - add di,word ptr _backstep ;pricti fine pozici - adc bx,word ptr [_backstep+2];preteceni jde do bx plus step - and ebx,03ffffh ;celkem 16384*4 samplu - sar cl,1 ;del levy kanal 2ma - sar ch,1 ;del pravy kanal 2ma - add cl,ch ;secti oba kanaly - addc al,cl,7fh ;secti s clippingem kanal - xor eax,80h ;neznaminkova korekce pro SB Pro - dec si ;uloz na zdrojovou pozici - mov [esi],al - inc si - mov eax,edx ;pouzity sampl pro prumerovani se - sub ecx,10000h ;do ax a odecti jeden takt pro citac - jnc m8mido1 ;a opakuj dokud neni konec - mov _backsnd,ebx - ret ;navrat - -mixm2: ret ;navrat - - -PUBLIC setsb2_ -setsb2_: - lea edi,_jumptable - mov eax,offset mixskip - stosd - mov eax,offset mixm_ - stosd - mov eax,offset mixm2 - stosd - mov _getdma,offset sbdma - mov _ido,offset m8mido - ret - -MIX16_ :;primixuje sampl do bufferu (16-bit stereo) - ;musi platit vsechny promenne a ebx je adresa kanalu - mov edi,_mixpos ;vem mixovaci pozici - mov ecx,_mixsize ;vem mixovaci delku - mov esi,[ebx] ;vyzvedni ukazatel na sample - push ebp ;uchovej BP - mov bp,minorpos[ebx] ;bp bude drzet minor pozice -mix1lp: mov al,[esi] ;nacti sample - mov dl,al ;al a dl obsahuji levej a pravej kanal - mov ah,byte ptr volumeright[ebx+1] ;nacti pravou hlastitot - imul ah ;vynasob hlasitosti - shl eax,1 ;vse je vyreseno, deleni neni potreba - xchg edx,eax ;ted pracuj s druhym kanalem - mov ah,byte ptr volumeleft[ebx+1] ;nactu hlasitost - imul ah ;vynasob - shl eax,1 - addc [edi],dx,7fffh ;k aktualnimu vzorku pricti hodnotu - add di,2 ;dalsi pozice - addc [edi],ax,7fffh ;je smixovano - add di,2 ;dalsi pozice - add bp,speedmin[ebx] - adc esi,speedmaj[ebx] - cmp esi,endloop[ebx] - jc mix1skp - mov esi,startloop[ebx] - cmp esi,endloop[ebx] - jnz mix1skp - mov smptype[ebx],0 - jmp mix1end -mix1skp:sub ecx,4 - jnz mix1lp -mix1end:mov minorpos[ebx],bp - mov playpos[ebx],esi - pop ebp - ret - -mix162: ret - -m16ido: push ebp - mov esi,_mixpos ;vem mixovaci pozici - sub si,4 ;o jeden sampl dozadu - mov edi,_backfine ;finepozice - mov ebx,_backsnd ;pozice v bufferu - mov ecx,_mixsize ;pocet bajtu - sub ecx,4 - shl ecx,16 ;uloz do horni poloviny ecx - mov eax,[esi] ;vezmi sample - xor eax,80008000h ;neznaminkova korekce -m16ido1:add si,4 ;dalsi sample - mov ebp,eax - and ebp,0ffff0000h - mov edx,[esi] ;nacti do dx sample - xor edx,80008000h ;neznaminkova korekce - add ax,dx ;secti leve kanaly - rcr ax,1 ;nasleduje deleni 2x prumer - add ebp,edx ;totez pro prave kanaly - rcr ebp,1 - shld eax,ebp,16 - xor eax,80008000h ;neznaminkova korekce - mov cx,word ptr _backsndbuff[ebx*4] ;nacti back sound pro levej kanal - addc ax,cx,7fffh ;secti s clippingem levy kanal - mov cx,word ptr _backsndbuff[2+ebx*4];nacti back sound pro pravej kanal - rol eax,16 - addc ax,cx,7fffh ;secti s clippingem pravy kanal - add di,word ptr _backstep ;pricti fine pozici - adc bx,word ptr [_backstep+2];preteceni jde do bx plus step - and ebx,03ffffh ;celkem 16384*4 samplu - sub si,4 ;uloz na zdrojovou pozici - mov [esi],eax - add si,4 - mov eax,edx ;pouzity sampl pro prumerovani se - sub ecx,40000h ;do ax a odecti ctyri takty pro citac - jnc m16ido1 ;a opakuj dokud neni konec - pop ebp - mov _backsnd,ebx - mov _backfine,edi - ret ;navrat - - - -PUBLIC setsb16_ -setsb16_: - lea edi,_jumptable - mov eax,offset mixskip - stosd - mov eax,offset mix16_ - stosd - mov eax,offset mix162 - stosd - mov _getdma,offset sbdma - mov _ido,offset m16ido - ret - -dpmibufalloc: - mov ax,0100h - int 31h - ret - -public buff_dealloc_ -buff_dealloc_: - mov dx,_dpmiselector - mov ax,0101h - int 31h - ret - -public buff_alloc_ - -buff_alloc_: - mov ebx,4200 - call dpmibufalloc - jc allcerror - test eax,0fffh - jz allc_ok - push eax - mov eax,0101h - int 31h - pop eax - mov ebx,eax - and ebx,0f000h - add ebx,1000h - sub ebx,eax - dec ebx - call dpmibufalloc - jc allcerror - push edx - call buff_alloc_ - mov ecx,edx - pop edx - push eax - mov eax,0101h - int 31h - pop eax - ret -allc_ok:mov _dpmiselector,dx - shl eax,4 - ret -allcerror: - mov word ptr _dpmiselector,0 - xor eax,eax - ret - -public int_relocation_ -int_relocation_: - mov eax,0de0ah - int 67h - shl ebx,16 - mov bx,cx - rol ebx,16 - mov eax,ebx - ret - -public int_mixer_alloc_ -int_mixer_alloc_: - lea eax,_idt_map - sidt [eax] -; db 0fh -; db 01 -; db 08h - add eax,2 - mov eax,[eax] - shl ebx,3 - add eax,ebx - cli - mov edi,eax - push ds - pop es - mov ecx,offset int_normal_ - mov eax,ecx - stosw - mov ax,cs - stosw - mov eax,8e00h - stosw - mov eax,ecx - shr eax,16 - stosw - sti - mov ebx,1000h - call dpmibufalloc - mov esi,4*8 - mov edi,offset rm_old - mov ecx,4 - rep movsb - mov _call_back_sel,dx - mov esi,offset rm_data_ - mov edi,eax - shl edi,4 - mov _call_back_data,edi - mov ecx,1000 - rep movsb - mov edi,4*8 - mov word ptr [edi],8 - mov [edi+2],ax - ret - -public int_high_alloc_ -int_high_alloc_: - lea eax,_idt_map - sidt [eax] - add eax,2 - mov eax,[eax] - shl ebx,3 - add eax,ebx - cli - mov edi,eax - push ds - pop es - mov ecx,offset int_hspd_ - mov eax,ecx - stosw - mov ax,cs - stosw - mov eax,8e00h - stosw - mov eax,ecx - shr eax,16 - stosw - sti - mov ebx,1000h - call dpmibufalloc - mov esi,4*8 - mov edi,offset rm_old - mov ecx,4 - rep movsb - mov _call_back_sel,dx - mov esi,offset rm_data_ - mov edi,eax - shl edi,4 - mov _call_back_data,edi - mov ecx,1000 - rep movsb - mov edi,4*8 -; mov word ptr [edi],(high_speed - rm_data_) -; mov [edi+2],ax - ret - -public high_speed_parm_ - ;eax dos delay - ;edx port - ;ebx mixbuffer - ;esi xlattab -high_speed_parm_: - mov edi,offset w_max - mov [edi],ax - mov edi,offset rm_hspd - mov ecx,64 - rep movsd - xor eax,eax - stosw - mov eax,ebx - shr eax,4 - stosw - mov eax,edx - stosw - ret -public int_dealloc_ -int_dealloc_: - mov edi,4*8 - mov esi,offset rm_old - mov ecx,4 - rep movsb - mov dx,_call_back_sel - mov ax,101h - int 31h - ret - -public int_normal_: -int_normal_: - cli - pushad - push ds - push es - mov ax,seg _DATA - mov ds,ax - mov es,ax - inc _test_counter - mov al,20h - out 20h,al - sti - call mixer_ - cli - pop es - pop ds - popad - iretd - -public int_hspd_: ;high speed mode interrupt - pro D/A a PC Speaker -int_hspd_: - push ds - push esi - push ebx - push edx - push eax - mov al,20h - out 20h,al - mov ax,seg _DATA - mov ds,ax - mov ebx,_call_back_data - add ebx,(offset rm_hspd-offset rm_data_) - xor eax,eax - xor esi,esi - mov ax,[ebx+scanofs] - mov si,[ebx+scanseg] - shl esi,4 - add esi,eax - mov dx,[ebx+port] - lodsb - xlatb - out dx,al - inc word ptr [ebx+scanofs] - mov ebx,_call_back_data - dec word ptr [ebx] - jnz hs_end - mov ax,[ebx+2] - mov [ebx],ax - sti - call mixer_ - cli -hs_end: - pop eax - pop ebx - pop edx - pop esi - pop ds - iretd - -_TEXT ends - -_TEXT16 SEGMENT BYTE PUBLIC USE16 'CODE' - ASSUME cs:_TEXT16 -public rm_proc_: -rm_data_: -w_count:dw 2 ;citac preruseni -w_max dw 2 ;maximalni hodnota citace -rm_old dw ? ;stary vektor preruseni - dw ? -rm_proc_: - cli - int 1ch - cli - push si - xor si,si - dec word ptr cs:[si] - jnz w_skip - push ax - mov ax,cs:[si+2] - mov cs:[si],ax - pop ax - pushf - call dword ptr cs:[si+4] -w_skip: pop si - iret - -rm_hspd db 300 dup(?) -high_speed: - push ds - push si - push bx - push dx - push ax - mov bx,offset rm_hspd-offset rm_data_ - lds si,cs:[bx+scanofs] - mov dx,cs:[bx+port] - lodsb - xlat cs: - out dx,al - mov cs:[bx+scanofs],si - mov al,20h - out 20h,al - dec word ptr cs:[0] - jnz hspd_end - mov ax,cs:[2] - mov cs:[0],ax - pushf - call dword ptr cs:[4] - int 1ch -hspd_end: - pop ax - pop dx - pop bx - pop si - pop ds - iret - -_TEXT16 ends - -end - - diff --git a/ZVUK/zvuk.c b/ZVUK/zvuk.c deleted file mode 100644 index bd4e72b..0000000 --- a/ZVUK/zvuk.c +++ /dev/null @@ -1,1425 +0,0 @@ -#include -#include -//#include -//#include - - - -#include "zvuk.h" -//#include "pcspeak.h" - -#define MIX_REZERVA 0x50 -#define XBASS_PARM 5 -/* -#define build_dac_xlat() \ - {\ - int i;\ - for(i=0;i<256;i++) da_xlat[i]=i;\ - }\ - -#define sendsb(data) \ - *countdown=10;\ - while ((inp(devport+0xc) & 0x80) && *countdown);\ - outp(devport+0xc,data) - -#define recivesb(data)\ - *countdown=10;\ - while (!(inp(devport+0xe) & 0x80) && *countdown);\ - data=inp(devport+0xa) - -#define sendwss(reg,data)\ - *countdown=10;\ - while ((inp(devport+0x4) & 0x80) && *countdown);\ - outp(devport+0x4,reg);\ - outp(devport+0x5,data); - -#define recivewss(reg,data)\ - *countdown=10;\ - while ((inp(devport+0x4) & 0x80) && *countdown);\ - outp(devport+0x4,reg);\ - data=inp(devport+0x5); - - - -char detect_enables[8]; -#define irqdetect(irq) \ - {\ - if (detect_enables[irq]) \ - devirq=irq;\ - detect_enables[irq]=0;\ - inp(devport+0xE);\ - outp(0x20,0x20);\ - } - -*/ -typedef struct tchannel - { - char *play_pos, *start_loop, *end_loop; - int32_t speed_maj; - unsigned short speed_min, minor_pos, sample_type, vol_left, vol_right; - }TCHANNEL; - -TCHANNEL chaninfo[32]; -char *mixbuffer=NULL; -char backsndbuff[BACK_BUFF_SIZE]; -volatile int32_t backsnd=0; -volatile int32_t backstep=0x10000; -volatile int backfine=0; -int32_t ticker_save; -/*int32_t jumptable[3]; -int32_t getdma; -int32_t ido;*/ -unsigned short predstih=0x960; -int32_t lastdma; -int32_t lastmix; -int32_t mixpos; -int32_t surpos; -int32_t mixsize; -int32_t dmaposadr; -int32_t dmasizadr; -int32_t dmapageadr; -int32_t dmanum; -int dmamask; -int dmamode; -int dmamodenum=0x58;//rezim DMA (default pro SB - POZOR zmenit pro GUS na 0x48 -int device; -int32_t samplerate=22050; -int32_t mixfreq=50; -int32_t idt_map[2]; -int call_back_data; -int call_back_sel; -static char *countdown=(char *)0x440; -unsigned short dpmiselector; -char mixer_zavora=0; -static char hw_intpol=0; -FILE *bsnd; -unsigned short bchans; -short btable[256]; -int bfreq,bblocks,bblock_size,bvolume=255; -int bxbass=0; -static int gfxvol=255; -int32_t blength; -static char depack[32768]; -//void (__far __interrupt *oldvect)(); -static char swap_chans=0; - -char da_xlat[256]; // Xlat tabulka pro DA a PC Speaker; - - -int devport=0x220; //device base port -int devirq=0; //device main irq - -char gus_dma_type=0x41; //typ dma prenosu pro GUS (default 8-bit dma 16-bit samples highspeed) -char gus_last_buff=0; - - -int test_counter=0; -int timer_test_port; -int timer_value=0; -char intr_test; - -void (*konec_skladby)(char **jmeno)=NULL; - -int dmatable[8][4]= - { - {0,1,0x87,0x0A0B}, - {2,3,0x83,0x0A0B}, - {4,5,0x81,0x0A0B}, - {6,7,0x82,0x0A0B}, - {0xc0,0xc2,0x8f,0xD4D6}, - {0xc4,0xc6,0x8b,0xD4D6}, - {0xc8,0xca,0x89,0xD4D6}, - {0xcc,0xce,0x8a,0xD4D6} - }; - -static int irqtable[16]={8,9,0xa,0xb,0xc,0xd,0xe,0xf,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77}; - - static char names[][25]= - { - "Unsupported device", - "Nosound", - "Sound Blaster", - "Sound Blaster 2", - "Sound Blaster Pro", - "Sound Blaster 16+", - "Windows Sound System", - "Gravis Ultrasound", - "DAC on LPT", - "Internal Hooker", - "Pro Audio Spectrum" - }; - -char *buff_alloc(); -#pragma aux buff_alloc modify[ebx ecx edx] value [eax] -void mixer(); -#pragma aux mixer modify [eax ebx ecx edx esi edi] -void setsbpro(); -#pragma aux setsbpro modify [eax edi] -void setsb2(); -#pragma aux setsb2 modify [eax edi] -void setsb2_s(); -#pragma aux setsb2_s modify [eax edi] -void setsb16(); -#pragma aux setsb16 modify [eax edi] -void setgus(); -#pragma aux setgus modify [eax edi] -void init_gus(); -#pragma aux init_gus modify [eax ecx edx edi] -void stop_gus(); -#pragma aux stop_gus modify [eax ecx edx edi] -void gus_setchan_vol(int voice,int volume); -#pragma aux gus_setchan_vol parm [eax][ecx] modify [edx] -void gus_setchan_pan(int voice,int volume); -#pragma aux gus_setchan_pan parm [eax][ecx] modify [edx] - - -void init_dma(int dma) -{ -dmanum=dma; -dmaposadr=dmatable[dma][0]; -dmasizadr=dmatable[dma][1]; -dmapageadr=dmatable[dma][2]; -dmamask=dmatable[dma][3] >> 8; -dmamode=dmatable[dma][3] & 0xff; -} - -void prepare_dma(char *adr,int block) -{ -int poz;int page; - -outp(0x0C,0);outp(0xD8,0); -outp(dmamask,(dmanum & 3)+0x04); -outp(dmamode,(dmanum & 3)+dmamodenum); -if (dmanum>3) - { - block>>=1; - poz=(int32_t)adr>>1; - page=((int32_t)adr>>16) & ~1; - } -else - { - poz=(int32_t)adr; - page=(int32_t)adr>>16; - } -block--; -outp(dmaposadr,poz & 0xff); -outp(dmaposadr,(poz>>8) & 0xff); -outp(dmapageadr,page); -outp(dmasizadr,block & 0xff); -outp(dmasizadr,block>>8); -outp(dmamask,dmanum & 3); -/* -printf("adr: %p\n" - "block: %04X\n" - "pos: %04X\n" - "map: %04X\n" - "dmapage: %X\n" - "dmapos: %X\n" - "dmasize: %X\n" - "dmamask: %X\n", - adr,block,poz & 0xffff,page,dmapageadr,dmaposadr,dmasizadr,dmamask); -getche(); - */ -} - - - -void reset_blaster() -{ -int counter=100; -outp(devport+0x6,1); -delay(10); -outp(devport+0x6,0); -while (inp(devport+0x0A)!=0xAA && counter--) delay(1); -} -void start_sbmono() -{ -prepare_dma(mixbuffer,65536); -sendsb(0xd1); -sendsb(0x40); -sendsb(256 - (1000000 / samplerate)); -sendsb(0x48); -sendsb(0xff); -sendsb(0xff); -sendsb(0x1c); -} - -void stop_sbmono() -{ -sendsb(0xd3); -sendsb(0xd0); -//sendsb(0xda); -//sendsb(0xd0); -} - -void start_sb16(); - -void __interrupt __far sb16_irq() - { - int i=32767; - - i=inp(devport+0xf); - i=inp(devport+0xe); -// sendsb(0xb6); -// sendsb(0x30); -// sendsb(i & 0xff); -// sendsb(i >> 8); //play(16bit,signed,stereo,16384); - outp(0x20,0x20); - outp(0xA0,0x20); - intr_test=1; - } -void start_sb16() - { - int i=16383; - - outp(devport+0x4,0x81); - if (dmanum>3) - outp(devport+0x5,(1 << dmanum)| (inp(devport+0x5) & 0xf)); - else - outp(devport+0x5,1 << dmanum); - outp(devport+0x4,0x80); - switch (devirq) - { - case 2:outp(devport+0x5,0xf1);break; - case 5:outp(devport+0x5,0xf2);break; - case 7:outp(devport+0x5,0xf4);break; - } - outp(devport+0x4,0x80); - prepare_dma(mixbuffer,65536); - sendsb(0xd1); //speaker(enable) - sendsb(0x41); - sendsb(samplerate>>8); - sendsb(samplerate & 0xff); //Set_sample_rate(samplerate); - sendsb(0xb4); - sendsb(0x30); - sendsb(i & 0xff); - sendsb(i >> 8); //play(16bit,signed,stereo,16384); - outp(0x21,inp(0x21) & ~(1<>8); -sendsb(0x48); -sendsb(0xff); -sendsb(0xff); -sendsb(0x90); -outp(devport+0x4,0x0e); -outp(devport+0x5,0x23-0x20*hw_intpol); -} - -void __interrupt __far sb10_irq() - { - int i=32767; - - i=inp(devport+0xe); - sendsb(0x14); - sendsb(0xff); - sendsb(0xff); - outp(0x20,0x20); - outp(0xA0,0x20); - intr_test=1; - } - -void start_sb10() - { - prepare_dma(mixbuffer,65536); - sendsb(0xd1); - sendsb(0x40); - sendsb(256 - (1000000 / samplerate)); - sendsb(0x14); - sendsb(0xff); - sendsb(0xff); - outp(0x21,inp(0x21) & ~(1<BACK_BUFF_SIZE) nextpos-=BACK_BUFF_SIZE; - return nextpos; - } - if (synchro==3) - { - nextpos=backsnd*4-16; - if (nextpos<0) nextpos+=BACK_BUFF_SIZE; - return nextpos; - } - if (synchro>=32768) - { - predstih=synchro; - return nextpos; - } - for(;;) - { - val=backsnd*4-nextpos; - if (val<0) val+=BACK_BUFF_SIZE; - if (val0;count--) - { - if (remain<=0) - { - bblocks--; - if (bblocks<=0) - { - char *new_filename=NULL; - fclose(bsnd); - if (konec_skladby!=NULL) konec_skladby(&new_filename); - open_backsound(new_filename); - } - last[0]=0; - last[1]=0; - remain=load_music_block();; - depos=0; - } - val=btable[c=depack[depos]]; - if (bchans==2 || swap) remain--,depos++; - val+=last[swap]; - last[swap++]=val; - if (c==0) //pridano jako provizorni reseni pro korekci chyby komprimacniho programu - { - val-=31767; - } - if (swap>1)swap=0; - if (bxbass) - { - int c; - xbass[swap]+=val; - c=xbass[swap]>>XBASS_PARM; - xbass[swap]-=c; - c=(c*bxbass*4)>>8; - val+=c; - } - val=(val*bvolume)>>8; - if (val>32676) val=32767; - if (val<-32767) val=-32767; - *(short *)(backsndbuff+(nextpos))=val; - nextpos+=2; - if (nextpos>=BACK_BUFF_SIZE) nextpos=0; - } - } - } - - -void fade_music() - { - short *p; - int i,j,k,l,m; - - mix_back_sound(0); - k=backsnd*2; - i=k; - p=(short *)&backsndbuff; - m=mix_back_sound(1); - m=m-k*2; - if (m<0) m+=BACK_BUFF_SIZE; - m/=2; - j=m;m/=256; - if (m) - do - { - l=j/256; - p[i]=p[i]*l/m; - i++;j--;if (j<0) j=0; - if (i>BACK_BUFF_SIZE/2) i=0; - } - while (i!=k); - memset(&depack,0x80,sizeof(depack)); - } - - -void stop_sbstereo() -{ -reset_blaster(); -outp(devport+0x4,0x0e); -outp(devport+0x5,0x11); -//sendsb(0xda); -//sendsb(0xd0); -} - -int init_blaster(int port) -{ -devport=port; -reset_blaster(); -return(inp(devport+0x0a)==0xaa); -} - - -void prepare_mixing(int mode) -{ -predstih=samplerate/mixfreq+MIX_REZERVA; -predstih+=MIX_REZERVA+predstih; -predstih*=(mode/MIX_MONO); -switch (mode) - { - case MIX_MONO:setsb2();break; - case MIX_MONO_S:setsb2_s();break; - case MIX_STEREO:setsbpro();break; - case MIX_16STEREO:setsb16();break; - case MIX_ULTRA:setgus();break; - } -//backsndbuff[0]=128;backstep=0;backsnd=0; -lastdma=0; -mixpos=(int32_t)(mixbuffer+predstih); -memset(chaninfo,0,sizeof(TCHANNEL)*32); -memset(mixbuffer,0x80,65536); -} - -void play_sample(int channel,void *sample,int32_t size,int32_t lstart,int32_t sfreq,int type) - { - chaninfo[channel].play_pos=sample; - chaninfo[channel].start_loop=(char *)sample+lstart; - chaninfo[channel].end_loop=(char *)sample+size; - chaninfo[channel].speed_maj=sfreq/samplerate; - chaninfo[channel].speed_min=(sfreq%samplerate)*65536/samplerate; - chaninfo[channel].sample_type=type; - } - -void chan_break_ext(int channel,void *org_sample,int32_t size_sample) - { - chaninfo[channel].start_loop=chaninfo[channel].end_loop=(char *)org_sample+size_sample; - } - -void set_channel_volume(int channel,int left,int right) - { - left=(left*gfxvol)>>8; - right=(right*gfxvol)>>8; - left=max(left,0);left=min(left,32767); - right=max(right,0);right=min(right,32767); - if (swap_chans) - { - chaninfo[channel].vol_right=left; - chaninfo[channel].vol_left=right; - } - else - { - chaninfo[channel].vol_left=left; - chaninfo[channel].vol_right=right; - } - } - - -int int_relocation(); -#pragma aux int_relocation modify [eax ebx ecx edx esi edi] -void int_mixer_alloc(int num); -#pragma aux int_mixer_alloc parm [ebx] modify [eax ecx edx esi edi] -int int_dealloc(); -#pragma aux int_dealloc modify [eax ebx ecx edx esi edi] -void high_speed_parm(void *mix,int dosdelay,char *xlattab,int port); -#pragma aux high_speed_parm parm [ebx][eax][esi][edx] modify [edi] -void int_high_alloc(int num); -#pragma aux int_high_alloc parm [ebx] modify [eax ecx edx esi edi] -void write_adlib(int data); -#pragma aux write_adlib parm[eax] modify [edx] -void write_adlib_nodelay(int data); -#pragma aux write_adlib_nodelay parm[eax] modify [edx] - - -void __interrupt __far int_nosound_counter() - { - test_counter++; - _chain_intr(oldvect); - } - -void __interrupt __far int_adlib() - { - outp(0x20,0x20); - _enable(); - if (inp(timer_test_port) & 0x80) - { - test_counter++; - write_adlib_nodelay(0x8004); - } - mixer(); - _disable(); - _chain_intr(oldvect); - } - -void __interrupt __far int_normal() - { - outp(0x20,0x20); - _enable(); - test_counter++; - mixer(); - _disable(); - _chain_intr(oldvect); - } - - -void int_init() - { - int l; - - l=0x1234bc/mixfreq; - timer_test_port=0; - _disable(); - oldvect=_dos_getvect(0x8); - _dos_setvect(0x8,int_normal); - outp(0x43,0x34); - outp(0x40,l & 0xff); - outp(0x40,l>>8); - _enable(); - } - -void int_init_adlib_timer() - { - int l; - - timer_value=l=255-3125/mixfreq; - timer_test_port=0x388; - _disable(); - oldvect=_dos_getvect(0x8); - _dos_setvect(0x8,int_adlib); - write_adlib(l*256+3); - write_adlib(2*256+4); - _enable(); - } -/* -void int_ultrasnd() - { - { - int l; - - l=0x1234bc/mixfreq; - timer_test_port=0; - _disable(); - oldvect=_dos_getvect(0x8); - _dos_setvect(0x8,gus_irq); - outp(0x43,0x34); - outp(0x40,l & 0xff); - outp(0x40,l>>8); - _enable(); - } - } -*/ -void int_nosound() - { - int l; - _disable(); - oldvect=_dos_getvect(0x8); - _dos_setvect(0x8,int_nosound_counter); - l=0x1234bc/mixfreq; - outp(0x43,0x34); - outp(0x40,l%256); - outp(0x40,l/256); - _enable(); - } - -void int_highspeed(int port) - { - int l; - _dos_setvect(0x1c,int_normal); - high_speed_parm(mixbuffer,samplerate/mixfreq,da_xlat,port); - int_high_alloc(0x8); - l=0x1234bc/samplerate; - outp(0x43,0x34); - outp(0x40,l%256); - outp(0x40,l/256); - } - - -void set_mixing_device(int mix_dev,int mix_freq,...) - { - int *p; - samplerate=mix_freq; - if (mixbuffer==NULL) mixbuffer=buff_alloc(); - p=&mix_freq;p++; - device=mix_dev; - switch (mix_dev) - { - case DEV_SB10: - case DEV_SB20: - case DEV_SBPRO: - case DEV_SB16: - init_blaster(p[0]); - init_dma(p[1]); - devirq=p[2]; - break; - case DEV_DAC: - if (p[0]==0x42) set_mixing_device(DEV_PCSPEAKER,mix_freq); - else - { - rm_proc_set((int32_t)mixbuffer>>4,dpmiselector,p[0],DAC_MODE); - if (samplerate>22050) samplerate=22050; - } - break; - case DEV_PCSPEAKER: - rm_proc_set((int32_t)mixbuffer>>4,dpmiselector,0x42,SPK_MODE); - if (samplerate>19000) samplerate=19000; - break; - case DEV_ULTRA: - init_dma(p[1]); - devirq=p[2]; - dmamodenum=0x58; - if (dmanum>3) gus_dma_type=0x45;else gus_dma_type=0x41; - break; - case DEV_WSS: - devport=p[0]; - init_dma(p[1]); - break; - } - } - -int32_t pc_speak_position(void); - -void start_mixing() - { - ticker_save=*(int32_t *)0x46c; - test_counter=0; - switch (device) - { - case DEV_SB10: - prepare_mixing(MIX_MONO); - start_sb10(); - int_init(); - break; - case DEV_SB20: - prepare_mixing(MIX_MONO); - start_sbmono(); - int_init(); - break; - case DEV_SBPRO: - prepare_mixing(MIX_STEREO); - start_sbstereo(); - int_init(); - break; - case DEV_SB16: - prepare_mixing(MIX_16STEREO); - start_sb16(); - int_init(); - break; - case DEV_PCSPEAKER: - prepare_mixing(MIX_MONO_S); - pc_speak_set_proc(&getdma); - load_rm_proc(); - int_init(); - pc_speak_enable(); - pc_speak_run(samplerate,mixfreq); - break; - case DEV_DAC: - prepare_mixing(MIX_MONO_S); - pc_speak_set_proc(&getdma); - load_rm_proc(); - int_init(); - pc_speak_run(samplerate,mixfreq); - break; - case DEV_ULTRA: - prepare_mixing(MIX_ULTRA); - init_gus(); - int_init(); - delay(200); - break; - case DEV_WSS: - prepare_mixing(MIX_16STEREO); - start_wss16(); - int_init(); - break; - case DEV_NOSOUND:int_nosound();break; - } - mixer_zavora=0; - } - -void stop_mixing() - { - mixer_zavora=1; - _disable(); - *(int32_t *)0x46c=ticker_save+(int32_t)(((float)test_counter/mixfreq)*(18.2059)); - outp(0x43,0x34); - outp(0x40,0); - outp(0x40,0); - _enable(); - switch (device) - { - case DEV_SB10: - stop_sb10(); - break; - case DEV_SB20: - stop_sbmono(); - break; - case DEV_SBPRO: - stop_sbstereo(); - break; - case DEV_SB16: - stop_sb16(); - break; - case DEV_PCSPEAKER: - pc_speak_stop(); - pc_speak_disable(); - purge_rm_proc(); - break; - case DEV_DAC: - pc_speak_stop(); - purge_rm_proc(); - break; - case DEV_ULTRA: - stop_gus(); - break; - case DEV_WSS: - stop_wss16(); - break; - } - _dos_setvect(0x8,oldvect); - } - -void __far __interrupt sb_detect_irq2() -irqdetect(2) -void __far __interrupt sb_detect_irq3() -irqdetect(3) -void __far __interrupt sb_detect_irq5() -irqdetect(5) -void __far __interrupt sb_detect_irq7() -irqdetect(7) - - -char *device_name(int device) - { - - switch (device) - { - case DEV_NOSOUND:return names[1]; - case DEV_SB10:return names[2]; - case DEV_SB20:return names[3]; - case DEV_SBPRO:return names[4]; - case DEV_SB16:return names[5]; - case DEV_WSS:return names[6]; - case DEV_ULTRA:return names[7]; - case DEV_DAC:return names[8]; - case DEV_PCSPEAKER:return names[9]; - } - return names[0]; - } - -int sb_detect(int *dev,int *port,int *dma, int *irq) - { - int i,a,j; - char ver_lo; - char ver_hi; - void __far *irqsave2,__far *irqsave3,__far *irqsave5,__far *irqsave7; - int dmasaves[4]; - char dmadis[4]; - int dmatesting[4]={1,3,0,1}; - - *port=0x210; - do - { - devport=*port; - outp(devport+6,1);delay(1); - outp(devport+6,0); - for(i=0;i<100 && inp(devport+0xA)!=0xAA;i++) delay(1); - (*port)+=0x10; - } - while (i==100 && devport<0x280); - if (i==100) return -1; //NOT DETECTED; - *port=devport; - _disable();sendsb(0xe1);recivesb(ver_lo);recivesb(ver_hi);_enable(); - switch (ver_hi) - { - case 1: *dev=DEV_SB10;break; - case 2: if (ver_lo) *dev=DEV_SB20;break; - case 3: *dev=DEV_SBPRO;break; - case 4: *dev=DEV_SB16;break; - default: *dev=DEV_SB16;break; - } - if (*dev==DEV_SB16) - { - outp(devport+4,0x80); - i=inp(devport+5); - *irq=5; - if (i & 8) *irq=7; - if (i & 4) *irq=7; - if (i & 2) *irq=5; - if (i & 1) *irq=2; - outp(devport+4,0x81); - i=inp(devport+5); - *dma=1; - if (i & 0x20) *dma=5; - else if (i & 0x40) *dma=6; - else if (i & 0x80) *dma=7; - else if (i & 1) *dma=0; - else if (i & 2) *dma=1; - else if (i & 8) *dma=3; - return 0; - } - for(i=0;i<4;i++) - { - outp(0xc,0); - a=inp(dmatable[i][0]); - a=a+256*inp(dmatable[i][0]); - dmasaves[i]=a; - } - irqsave2=_dos_getvect(irqtable[2]); - irqsave3=_dos_getvect(irqtable[3]); - irqsave5=_dos_getvect(irqtable[5]); - irqsave7=_dos_getvect(irqtable[7]); - _dos_setvect(irqtable[2],sb_detect_irq2); - _dos_setvect(irqtable[3],sb_detect_irq3); - _dos_setvect(irqtable[5],sb_detect_irq5); - _dos_setvect(irqtable[7],sb_detect_irq7); - ver_lo=inp(0x21); - outp(0x21,0x53); - memset(detect_enables,0x1,sizeof(detect_enables)); - delay(100); - devirq=-1; - sendsb(0xf2); - delay(1); - _dos_setvect(irqtable[2],irqsave2); - _dos_setvect(irqtable[3],irqsave3); - _dos_setvect(irqtable[5],irqsave5); - _dos_setvect(irqtable[7],irqsave7); - outp(0x21,ver_lo); - if (devirq==-1) return -2; //DETECTION ERROR - *irq=devirq; - for(i=0;i<4;i++) - { - outp(0xc,0); - a=inp(dmatable[i][0]); - a=a+256*inp(dmatable[i][0]); - dmadis[i]=(dmasaves[i]==a); - } - for (j=0,*dma=-1;j<4 && *dma==-1;j++) - { - i=dmatesting[j]; - init_dma(i); - prepare_dma(NULL,65536); - sendsb(0xd3); - sendsb(0x14); - sendsb(0xff); - sendsb(0x7f); - delay(100); - outp(0xc,0); - a=inp(dmatable[i][0]); - a=a+256*inp(dmatable[i][0]); - if (dmasaves[i]!=a && dmadis[i]) *dma=i; - reset_blaster(); - } - if (*dma==-1) return -2; - return 0; - } - -int wss_detect(int *dev,int *port,int *dma,int *irq) - { - int wss_ports[]={0x530,0x604,0xe80,0xf40}; - int i,d; - - for(i=0;i<4;i++) - { - devport=wss_ports[i]; - if (!(inp(devport+0x4) & 0x80)) - { - sendwss(00,0xaa); - recivewss(00,d) - if (d==0xAA) break; - } - } - if (i==4) return -1; - *dev=DEV_WSS; - *port=devport; - *dma=1; - *irq=0; - return 0; - } - -int sound_detect(int *dev,int *port,int *dma, int *irq) - { - char *env; - char *f; - - *dev=0; - env=getenv("BS_SOUND"); - if (env!=NULL) - if (sscanf(env,"%d %x %d %d",dev,port,dma,irq)!=4) *dev=0; - if (*dev==0) - if (wss_detect(dev,port,dma,irq)) *dev=0; - if (*dev==0 && (env=getenv("ULTRASND"))!=NULL) - { - char c;int i; - sscanf(env,"%x%c%d%c%d%c%d",port,&c,dma,&c,&i,&c,irq); - *dev=DEV_ULTRA; - } - if (*dev==0 && (env=getenv("BLASTER"))!=NULL) - { - int i; - f=strchr(env,'T'); - if (f!=NULL) - { - sscanf(f+1,"%d",&i); - switch (i) - { - case 1:*dev=DEV_SB10;break; - case 2:*dev=DEV_SBPRO;break; - case 3:*dev=DEV_SB20;break; - case 4:*dev=DEV_SBPRO;break; - default: *dev=DEV_NOSOUND;break; - } - if (i>4) *dev=DEV_SB16; - } - f=strchr(env,'A'); - if (f!=NULL) sscanf(f+1,"%x",port);else *dev=0; - f=strchr(env,'I'); - if (f!=NULL) sscanf(f+1,"%d",irq);else *dev=0; - f=strchr(env,'D'); - if (f!=NULL) sscanf(f+1,"%d",dma);else *dev=0; - f=strchr(env,'H'); - if (f!=NULL) sscanf(f+1,"%d",dma); - } - if (*dev==0) - { - if (sb_detect(dev,port,dma,irq) && sb_detect(dev,port,dma,irq) && sb_detect(dev,port,dma,irq)) - { - *dev=0; - } - } - return -(*dev==0); - } - -/*main() -{ -printf("%d\n",sizeof(TCHANNEL)); -if (sb_detect(&a,&b,&c,&d)) - { - printf("SB not present\n"); - return; - } -//a=DEV_SBPRO; -printf("%s\n",device_name(a)); -//printf("IRQ:\n"); -//scanf("%d",&d); -set_mixing_device(a,22050,b,c,d); -printf("Port %03X dma %d irq %d freq %d.\n",b,c,d,samplerate); -open_backsound(MUSIC1); -start_mixing(); -mixing(); -stop_mixing(); -printf("\n\n\n"); -} -*/ -void change_music(char *filename) - { - mix_back_sound(0); - if (bsnd!=NULL)fclose(bsnd); - fade_music(); - open_backsound(filename); - } - -int get_timer_value() - { - return test_counter; - } - -char get_channel_state(int channel) - { - return chaninfo[channel].sample_type; - } - -void get_channel_volume(int channel,int *left,int *right) - { - *left=chaninfo[channel].vol_left; - *right=chaninfo[channel].vol_right; - } - -void mute_channel(int channel) - { - chaninfo[channel].sample_type=0; - } - -void chan_break_loop(int channel) - { - chaninfo[channel].start_loop=chaninfo[channel].end_loop; - } - -void get_bass_treble(int *x,int *y) - { - if (device==DEV_SB16) - { - outp(devport+4,0x44);*x=inp(devport+5); - outp(devport+4,0x46);*y=inp(devport+5); - } - else - { - *x=255; - *y=255; - } - } - -char sb_set_global_volume(int x) - { - if (device==DEV_SBPRO) - { - outp(devport+4,2);outp(devport+5,(x & 0xf0) | (x>>4)); - } - else if (device==DEV_SB16) - { - outp(devport+4,2);outp(devport+5,(x & 0xf0) | (x>>4)); - outp(devport+4,0x30);outp(devport+5,x); - outp(devport+4,0x31);outp(devport+5,x); - } - else return 1; - return 0; - } - - -char sb_get_global_volume() - { - if (device==DEV_SBPRO) - { - outp(devport+4,2);return inp(devport+5)&0xf0; - } - else if (device==DEV_SB16) - { - int check1,check2; - outp(devport+4,2);check1=inp(devport+5)&0xf0; - outp(devport+4,0x30);check2=inp(devport+5); - if (check1!=check2 & 0xe0) return check1;else return check2; - } - else return 1; - } - -void wss_set_global_volume(int x) - { - x>>=4; - sendwss(06,0xf-x); - sendwss(07,0xf-x); - } - -char wss_get_global_volume() - { - int x; - - recivewss(06,x); - x<<=4; - return 0xff-x; - } - -void set_music_volume(int volume) - { - if (volume==0 && bvolume!=0) - memset(backsndbuff,0,sizeof(backsndbuff)); - bvolume=volume; - } - -int get_music_volume() - { - return bvolume; - } - -void set_gfx_volume(int volume) - { - gfxvol=volume; - } - -int get_gfx_volume() - { - return gfxvol; - } - - -void snd_ping1(int data) - { - data; - } - -int snd_ping2() - { - return 0; - } - - -void set_swap_channels(int data) - { - swap_chans=data & 1; - } - -int get_swap_channels() - { - return swap_chans; - } - -void set_treble(int y) - { - outp(devport+4,0x44);outp(devport+5,y); - outp(devport+4,0x45);outp(devport+5,y); - } -void set_bass(int x) - { - outp(devport+4,0x46);outp(devport+5,x); - outp(devport+4,0x47);outp(devport+5,x); - } - -int get_treble() - { - outp(devport+4,0x44);return inp(devport+5); - } -int get_bass() - { - outp(devport+4,0x46);return inp(devport+5); - } - -char gus_swap=0; -char gus_volume=0xff; - -void set_gus_swap(int x) - { - gus_swap=x; - gus_setchan_pan(0,x>>4); - gus_setchan_pan(1,(0xff-x)>>4); - } - -void set_xbass(int x) - { - bxbass=x; - } - -int get_xbass() - { - return bxbass; - } - -int get_gus_swap() - { - return gus_swap; - } - -void gus_set_global_volume(int x) - { - gus_setchan_vol(0,x<<8); - gus_setchan_vol(1,x<<8); - gus_volume=x; - } - -int gus_get_global_volume() - { - return gus_volume; - } - -char get_outfilter() - { - return hw_intpol; - } - - -char set_outfilter(char value) - { - int a; - - if (device!=DEV_SBPRO) return 1; - if (value>1) hw_intpol=!hw_intpol; - else hw_intpol=value; - do - { - a=inp(dmaposadr); - a+=inp(dmaposadr)<<8; - } - while (a & 1); - do - { - a=inp(dmaposadr); - a+=inp(dmaposadr)<<8; - } - while (!(a & 1)); - outp(devport+0x4,0x0e); - if (hw_intpol) outp(devport+0x5,inp(devport+0x5) & ~0x20); - else outp(devport+0x5,inp(devport+0x5) | 0x20); - return 0; - } - -typedef void (*FPROC_SET)(int data); -typedef int (*FPROC_GET)(); - -FPROC_SET set_funct_table[][SND_MAXFUNCT]= - { - {snd_ping1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, - {snd_ping1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,set_gfx_volume,set_music_volume,set_xbass}, - {snd_ping1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,set_gfx_volume,set_music_volume,set_xbass}, - {snd_ping1,sb_set_global_volume,NULL,NULL,set_swap_channels,NULL,NULL,set_outfilter,set_gfx_volume,set_music_volume,set_xbass}, - {snd_ping1,sb_set_global_volume,set_bass,set_treble,set_swap_channels,NULL,NULL,NULL,set_gfx_volume,set_music_volume,set_xbass}, - {snd_ping1,wss_set_global_volume,NULL,NULL,set_swap_channels,NULL,NULL,NULL,set_gfx_volume,set_music_volume,set_xbass}, - {snd_ping1,gus_set_global_volume,NULL,NULL,NULL,set_gus_swap,NULL,NULL,set_gfx_volume,set_music_volume,set_xbass}, - {snd_ping1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,set_gfx_volume,set_music_volume,set_xbass}, - {snd_ping1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,set_gfx_volume,set_music_volume,set_xbass}, - }; - -FPROC_GET get_funct_table[][SND_MAXFUNCT]= - { - {snd_ping2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, - {snd_ping2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,get_gfx_volume,get_music_volume,get_xbass}, - {snd_ping2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,get_gfx_volume,get_music_volume,get_xbass}, - {snd_ping2,sb_get_global_volume,NULL,NULL,get_swap_channels,NULL,NULL,get_outfilter,get_gfx_volume,get_music_volume,get_xbass}, - {snd_ping2,sb_get_global_volume,get_bass,get_treble,get_swap_channels,NULL,NULL,NULL,get_gfx_volume,get_music_volume,get_xbass}, - {snd_ping2,wss_get_global_volume,NULL,NULL,get_swap_channels,NULL,NULL,NULL,get_gfx_volume,get_music_volume,get_xbass}, - {snd_ping2,gus_get_global_volume,NULL,NULL,NULL,get_gus_swap,NULL,NULL,get_gfx_volume,get_music_volume,get_xbass}, - {snd_ping2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,get_gfx_volume,get_music_volume,get_xbass}, - {snd_ping2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,get_gfx_volume,get_music_volume,get_xbass}, - }; - -char check_snd_effect(int funct) - { - return set_funct_table[device][funct]!=NULL; - } - -char set_snd_effect(int funct,int data) - { - if (set_funct_table[device][funct]!=NULL) - { - set_funct_table[device][funct](data); - return 1; - } - return 0; - } - -int get_snd_effect(int funct) - { - if (get_funct_table[device][funct]!=NULL) - { - return get_funct_table[device][funct](); - } - return 0; - } - - -void force_music_volume(int volume) - { - bvolume=volume; - } diff --git a/ZVUK/zvuk.h b/ZVUK/zvuk.h deleted file mode 100644 index a136066..0000000 --- a/ZVUK/zvuk.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef __ZVUK_H___ -#define __ZVUK_H___ - -#ifdef __cplusplus -extern "C" { -#endif - -#define BACK_BUFF_SIZE 0x40000 - -#define DEV_NOSOUND 0 -#define DEV_SB10 1 -#define DEV_SB20 2 -#define DEV_SBPRO 3 -#define DEV_SB16 4 -#define DEV_WSS 5 -#define DEV_ULTRA 6 -#define DEV_DAC 7 -#define DEV_PCSPEAKER 8 -#define DEV_DIRECTSOUND 9 //only valid device for this module - -extern int bvolume; - - -int sound_detect(int *dev,int *port,int *dma, int *irq); -void set_mixing_device(int mix_dev,int mix_freq,...); -char start_mixing(void); -void stop_mixing(void); -void play_sample(int channel,const void *sample,int32_t size,int32_t lstart,int32_t sfreq,int type); -void set_channel_volume(int channel,int left,int right); -void set_end_of_song_callback(const char * (*cb)(void *), void *ctx); - -void fade_music(void); -int mix_back_sound(int synchro); -int open_backsound(char *filename); -void change_music(const char *filename); -int get_timer_value(void); -const char *device_name(int device); -void force_music_volume(int volume); - -void set_backsnd_freq(int freq); - -char get_channel_state(int channel); -void get_channel_volume(int channel,int *left,int *right); -void mute_channel(int channel); -void chan_break_loop(int channel); -void chan_break_ext(int channel,const void *org_sample,int32_t size_sample); //zrusi loop s moznosti dohrat zvuk - -char set_snd_effect(int funct,int data); -char check_snd_effect(int funct); -int get_snd_effect(int funct); - -void *PrepareVideoSound(int mixfreq, int buffsize); -char LoadNextVideoFrame(void *buffer, const char *data, int size, const short *xlat, short *accnums, int32_t *writepos); -void DoneVideoSound(void *buffer); - - -#define SND_MAXFUNCT 11 -#define SND_PING 0 //Ping function -#define SND_GVOLUME 1 //SetGlobalVolume -#define SND_BASS 2 //SetBass -#define SND_TREBL 3 //SetTrebles -#define SND_SWAP 4 //SetSwapChannels -#define SND_LSWAP 5 //SetLinearSwapping -#define SND_SURROUND 6 //Surrourd -#define SND_OUTFILTER 7//Out Filter -#define SND_GFX 8 //setgfxvolume -#define SND_MUSIC 9 //setmusicvolume -#define SND_XBASS 10 //setxbassy - -#ifdef __cplusplus - } -#endif -#endif - diff --git a/ZVUK/zvuk_dx.cpp b/ZVUK/zvuk_dx.cpp deleted file mode 100644 index c74cab6..0000000 --- a/ZVUK/zvuk_dx.cpp +++ /dev/null @@ -1,842 +0,0 @@ -#define INITGUID -#include -#include -#include -#include -#define DWORD_PTR DWORD * -#include -#include "types.h" -#include "zvuk.h" -#include -extern "C" { -#include - } -#define MAXCHANNELS 32 -#define TIMEIDLESTOPCHANNEL 250 -#define DEFAULTBUFFERSIZE (256*1024) -#define FADELENGTH 3000 -#define MUS_ERRORWAIT 5000 -#include "Music.h" - - -static int cur_device=0; -static int cur_mixfreq=0; -static bool swap_chans=false; - -class CheckRes - { - public: - HRESULT operator=(HRESULT other) - { - if (other==0) return 0; - char buff[256]; - sprintf(buff,"DirectSound error HRESULT %08X, code %d",other,other & 0xFFFF); - int id=MessageBox(NULL,buff,NULL,MB_SYSTEMMODAL|MB_ABORTRETRYIGNORE); - if (id==IDRETRY) - { - __asm int 3; - return other; - } - if (id==IDIGNORE) return other; - exit(-1); - } - }; - - - - - -static CheckRes hres; -static HWND hWndDS8=NULL; -static IDirectSound8 *ds8=NULL; -static IDirectSoundBuffer *ds_primary; -static WAVEFORMATEX waveformat; -static int gfx_volume=255; -static int music_volume=127; -static int glob_volume=255; -static int linvoltable[256]; -static MusicPlayer GMusicPlayer; -static MusDecoder GMusDecoder; -static WinAmpDecoder GWinAmpPlayer; -static IDecoder *GCurrentDecoder=&GMusDecoder; - - -class SoundChannelInfo - { - public: - CRITICAL_SECTION sect; - char *play_pos, *start_loop, *end_loop; - IDirectSoundBuffer8 *buffer; - uint32_t chantype; - uint32_t idsPlayPos; - uint32_t idsWritePos; - uint32_t idsBuffSize; - int32_t volume; //volume for DS - int32_t pan; //pan for DS - int volleft; //left volume for skeldal - int volright; //right volume for skeldal - uint32_t preload; - uint32_t stopTime; //time, when buffer reached end. For calculating idle time - uint32_t startTime; //time, when buffer started. For calculating idle time, use 0 to sticky buffer - SoundChannelInfo() - { - buffer=NULL; - play_pos=start_loop=end_loop=NULL; - InitializeCriticalSection(§); - pan=DSBPAN_CENTER; - volume=DSBVOLUME_MAX; - } - ~SoundChannelInfo() {if (buffer) buffer->Release();DeleteCriticalSection(§);} - uint32_t CalculateLockSize(); - void ChannelMaintaince(); - bool IsPlaying() {return play_pos!=NULL;} -// bool IsFree(char type) {return play_pos==NULL || (type==chantype && play_pos==end_loop);} - void Reset(); - void InitChannel(char type, char *ppos, char *bloop,char *eloop, int freq); - void Lock() {EnterCriticalSection(§);} - void Unlock() {LeaveCriticalSection(§);} - bool TryLock() {return TryEnterCriticalSection(§)!=FALSE;} - void SetVolume(int32_t vol) - { - Lock(); - if (volume!=vol) if (buffer && play_pos ) hres=buffer->SetVolume(vol); - volume=vol; - Unlock(); - } - void SetPan(int32_t p) - { - Lock(); - if (pan!=p) if (buffer && play_pos ) hres=buffer->SetPan(p); - pan=p; - Unlock(); - } - void Mute() - { - Lock(); - Stop(); - Unlock(); - } - void Stop() - { - if (buffer) - buffer->Stop(); - play_pos=NULL; - } - - void BreakLoop() {start_loop=end_loop;} - void BreakLoopEx(char *end_sample) {start_loop=end_loop=end_sample;} - }; - -static bool shutMaintaince=false; -static SoundChannelInfo channels[MAXCHANNELS]; -static HANDLE maintainceThread; - -ULONG __stdcall MaintainceThread(void *); - -static void DSStart(int mixfreq) - { - DSBUFFERDESC desc; - - for (int i=1;i<256;i++) - { - double rang=pow(i/255.0,15); - linvoltable[i]=100*log(rang); - - } - linvoltable[0]=-10000; - - hres=DirectSoundCreate8(&DSDEVID_DefaultPlayback,&ds8,NULL); - if (hWndDS8) hres=ds8->SetCooperativeLevel(hWndDS8,DSSCL_PRIORITY); - memset(&desc,0,sizeof(desc)); - desc.dwSize=sizeof(desc); - desc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME; - hres=ds8->CreateSoundBuffer(&desc,&ds_primary,NULL); - - waveformat.cbSize=sizeof(waveformat); - waveformat.nBlockAlign=4; - waveformat.nChannels=2; - waveformat.nSamplesPerSec=mixfreq; - waveformat.nAvgBytesPerSec=mixfreq*4; - waveformat.wBitsPerSample=16; - waveformat.wFormatTag=WAVE_FORMAT_PCM; - - hres=ds_primary->SetFormat(&waveformat); - DWORD id; - - shutMaintaince=false; - maintainceThread=CreateThread(NULL,0,MaintainceThread,NULL,0,&id); - SetThreadPriority(maintainceThread,THREAD_PRIORITY_HIGHEST); - - GMusicPlayer.InitBuffer(ds8,linvoltable); - GMusicPlayer.Play(); - } - -void init_winamp_plugins(const char *path) -{ - GWinAmpPlayer.LoadPlugins(path); -} - -static void DSStop() - { - GCurrentDecoder->Stop(); - GMusDecoder.Stop(); - GMusicPlayer.Done(); - GWinAmpPlayer.ClearList(); - shutMaintaince=true; - WaitForSingleObject(maintainceThread,INFINITE); - CloseHandle(maintainceThread); - for (int i=0;iRelease();channels[i].buffer=NULL;} - if (ds_primary) ds_primary->Release(); - ds_primary=NULL; - if (ds8) ds8->Release(); - ds8=NULL; - } - -uint32_t SoundChannelInfo::CalculateLockSize() - { - if (buffer==NULL) return 0; - uint32_t playpos; - buffer->GetCurrentPosition(NULL,&playpos); - int32_t diff=(signed)playpos-(signed)idsPlayPos; - if (diff<0) diff+=idsBuffSize; - uint32_t wendpos=playpos+preload; - if (wendpos>=idsBuffSize) wendpos-=idsBuffSize; - if (wendposplaypos) return 0; - if (wendposidsBuffSize/2) sz=idsBuffSize/2; - idsPlayPos=playpos; - return sz; - } - -void SoundChannelInfo::ChannelMaintaince() - { - Lock(); - if (play_pos!=NULL) - { - if (play_pos!=end_loop) stopTime=GetTickCount(); - uint32_t lockSize=CalculateLockSize(); - if (lockSize) - { - // printf("%8d\r",lockSize); - void *audioptrs[2]; - uint32_t sizes[2]; - hres=buffer->Lock(idsWritePos,lockSize,audioptrs,sizes,audioptrs+1,sizes+1,0); - for (int i=0;i<2 && audioptrs[i];i++) - { - char *wrt=(char *)audioptrs[i]; - for (uint32_t j=0;jUnlock(audioptrs[0],sizes[0],audioptrs[1],sizes[1]); - idsWritePos+=lockSize; - if (idsWritePos>=idsBuffSize) idsWritePos-=idsBuffSize; - } - if (play_pos==end_loop && GetTickCount()-stopTime>TIMEIDLESTOPCHANNEL) - { - Stop(); - } - } - Unlock(); - } - -static void MixMaintaince() - { - for (int i=0;iRelease(); - buffer=NULL; - Unlock(); - } - -void SoundChannelInfo::InitChannel(char type, char *ppos, char *bloop,char *eloop, int freq) - { - Lock(); - uint32_t newchantype=type+freq*4; - if (chantype!=newchantype || buffer==NULL) - { - Reset(); - DSBUFFERDESC desc; - WAVEFORMATEX wfex; - wfex.cbSize=sizeof(wfex); - wfex.wFormatTag=WAVE_FORMAT_PCM; - wfex.wBitsPerSample=type==1?8:16; - wfex.nSamplesPerSec=freq; - wfex.nChannels=1; - wfex.nBlockAlign=type==1?1:2; - wfex.nAvgBytesPerSec=wfex.nBlockAlign*wfex.nSamplesPerSec; - - memset(&desc,0,sizeof(desc)); - desc.dwSize=sizeof(desc); - desc.dwFlags=DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLPAN|DSBCAPS_CTRLVOLUME|DSBCAPS_GETCURRENTPOSITION2; - desc.dwBufferBytes=DEFAULTBUFFERSIZE; - desc.lpwfxFormat=&wfex; - - preload=wfex.nAvgBytesPerSec/5; - - IDirectSoundBuffer *bufold; - - hres=ds8->CreateSoundBuffer(&desc,&bufold,NULL); - hres=bufold->QueryInterface(IID_IDirectSoundBuffer8,(void **)&buffer); - bufold->Release(); - - idsPlayPos=DEFAULTBUFFERSIZE-cur_mixfreq; - idsWritePos=0; - idsBuffSize=DEFAULTBUFFERSIZE; - - play_pos=ppos; - start_loop=bloop; - end_loop=eloop; - - chantype=newchantype; - - hres=buffer->SetVolume(volume); - hres=buffer->SetPan(pan); - - ChannelMaintaince(); - - hres=buffer->Play(0,0,DSBPLAY_LOOPING); - stopTime=startTime=GetTickCount(); - } - else - { - buffer->Stop(); - idsBuffSize=DEFAULTBUFFERSIZE; - buffer->SetCurrentPosition(0); - buffer->GetCurrentPosition(&idsPlayPos,&idsWritePos); - hres=buffer->SetVolume(volume); - hres=buffer->SetPan(pan); - play_pos=ppos; - start_loop=bloop; - end_loop=eloop; - ChannelMaintaince(); - buffer->Play(0,0,DSBPLAY_LOOPING); - stopTime=startTime=GetTickCount(); - } - Unlock(); - } - -/* -static int FindFreeChannel(char type) - { - int older=0; - DWORD m_age=0; - DWORD timval=GetTickCount(); - for (int i=0;im_age) {older=i;m_age=age;} - } - return older; - } - */ - - -extern "C" - { -int bvolume; //background volume -void (*konec_skladby)(char **jmeno)=NULL; //pointer to function to notify that end of song has been reached - -void DSReportWindowCreation(HWND hWindow) - { - hWndDS8=hWindow; - if (ds8!=NULL) hres=ds8->SetCooperativeLevel(hWndDS8,DSSCL_PRIORITY); - } - - -int sound_detect(int *dev,int *port,int *dma, int *irq) - { - *dev=DEV_DIRECTSOUND; - *port=0; - *dma=0; - *irq=0; - return 0; - } - -void set_mixing_device(int mix_dev,int mix_freq,...) - { - cur_device=mix_dev; - cur_mixfreq=mix_freq; - } - -char start_mixing() - { - if (cur_device!=DEV_DIRECTSOUND) - { - MessageBox(hWndDS8,"Invalid sound device! Check SKELDAL.INI. Only device 9 (DirectSound) can be used.",NULL,MB_SYSTEMMODAL); - exit(1); - } - if (cur_mixfreq==0) return FALSE; - DSStart(cur_mixfreq); - return TRUE; - } -void stop_mixing() - { - DSStop(); - } - -void play_sample(int channel,void *sample,int32_t size,int32_t lstart,int32_t sfreq,int type) - { - char *start=(char *)sample; - channels[channel].InitChannel(type,start,start+lstart,start+size,sfreq); - } - -void set_channel_volume(int channel,int left,int right) - { - if (left>32767) left=32767; - if (left<0) left=0; - if (right>32767) right=32767; - if (right<0) right=0; - int volleft=linvoltable[(left>>7)*gfx_volume/255]; - int volright=linvoltable[(right>>7)*gfx_volume/255]; - int volsum=__max(volleft,volright); - channels[channel].SetVolume(volsum); - channels[channel].SetPan(swap_chans?(volright-volleft):(volleft-volright)); - channels[channel].volleft=left; - channels[channel].volright=right; - } - -char get_channel_state(int channel) - { - return channels[channel].IsPlaying()==true; - } - -void get_channel_volume(int channel,int *left,int *right) - { - if (left) *left=channels[channel].volleft; - if (right) *right=channels[channel].volright; - } - -void mute_channel(int channel) - { - channels[channel].Mute(); - } - -void chan_break_loop(int channel) - { - channels[channel].BreakLoop(); - } - -void chan_break_ext(int channel,void *org_sample,int32_t size_sample) //zrusi loop s moznosti dohrat zvu - { - char *end_sample=(char *)org_sample+size_sample; - channels[channel].BreakLoopEx(end_sample); - } - -char set_snd_effect(int funct,int data) - { - switch (funct) - { - case SND_PING: return 1; - case SND_SWAP: swap_chans=(data & 1)!=0;return 1; - case SND_GFX: gfx_volume=data;return 1; - case SND_MUSIC: GCurrentDecoder->SetVolume(music_volume=data,get_snd_effect(SND_GVOLUME));return 1; - case SND_GVOLUME: hres=ds_primary->SetVolume(linvoltable[glob_volume=data]);return 1; - default: return 0; - } - } - -int get_snd_effect(int funct) - { - switch (funct) - { - case SND_PING: return 1; - case SND_SWAP: return swap_chans; - case SND_GFX: return gfx_volume; - case SND_MUSIC: return music_volume; - case SND_GVOLUME: return glob_volume; - default: return 0; - } - - } - -char check_snd_effect(int funct) - { - switch (funct) - { - case SND_PING: - case SND_SWAP: - case SND_MUSIC: - case SND_GVOLUME: - case SND_GFX: return 1; - default: return 0; - } - } - - - - -static DWORD Mus_buffSize; -/* -static HANDLE music_file=NULL; -static HANDLE next_music_file=NULL; -static bool fading=false; -static DWORD fadetime; -static DWORD Mus_lastWritePos; -static DWORD Mus_nextBlockSize; -static DWORD Mus_nextBlockRead; -static DWORD Mus_errorWait=0; -static DWORD Mus_silentPlay=0; - -#pragma pack (1) - -struct MusFile - { - short channels; - int32_t freq; - int32_t ssize; - int32_t blocks; - int32_t reserved1; - int32_t reserved2; - short ampltable[256]; - }; - -static MusFile curMus; - -#pragma pack() - - - - -static char OpenMus(HANDLE music_file) - { - DWORD bytesread; - - SetFilePointer(music_file,0,NULL,FILE_BEGIN); - - if (ReadFile(music_file,&curMus,sizeof(curMus),&bytesread,NULL)==TRUE && bytesread==sizeof(curMus)) - { - if (ReadFile(music_file,&Mus_nextBlockRead,sizeof(Mus_nextBlockRead),&bytesread,NULL)==FALSE) return 0; - if (ReadFile(music_file,&Mus_nextBlockSize,sizeof(Mus_nextBlockSize),&bytesread,NULL)==FALSE) return 0; - - - if (ds_music!=NULL) ds_music->Release(); - - WAVEFORMATEX wfex; - wfex.cbSize=sizeof(wfex); - wfex.wBitsPerSample=16; - wfex.nBlockAlign=2*curMus.channels; - wfex.nSamplesPerSec=curMus.freq; - wfex.nAvgBytesPerSec=curMus.freq*wfex.nBlockAlign; - wfex.wFormatTag=WAVE_FORMAT_PCM; - wfex.nChannels=curMus.channels; - - DSBUFFERDESC desc; - desc.dwSize=sizeof(desc); - desc.dwBufferBytes=Mus_buffSize=wfex.nAvgBytesPerSec*4; - desc.dwReserved=0; - desc.dwFlags=DSBCAPS_CTRLVOLUME ; - desc.lpwfxFormat=&wfex; - - IDirectSoundBuffer *dsbf; - - hres=ds8->CreateSoundBuffer(&desc,&dsbf,NULL); - hres=dsbf->QueryInterface(IID_IDirectSoundBuffer8,(void **)&ds_music); - dsbf->Release(); - - void *ptr; - DWORD size; - - ds_music->Lock(0,0,&ptr,&size,NULL,NULL,DSBLOCK_ENTIREBUFFER); - memset(ptr,0,size); - ds_music->Unlock(ptr,size,NULL,NULL); - ds_music->SetVolume(linvoltable[music_volume]); - ds_music->Play(0,0,DSBPLAY_LOOPING); - fadetime=0; - Mus_lastWritePos=wfex.nAvgBytesPerSec; - Mus_silentPlay=0; - - return 1; - } - return 0; - } - -static void PrepareMusFile(const char *filename) - { - CloseHandle(next_music_file); - next_music_file=CreateFile(filename,GENERIC_READ,FILE_SHARE_READ, - NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN, - NULL); - if (next_music_file==INVALID_HANDLE_VALUE) - next_music_file=NULL; - } - -static char music_decompres_block() - { - DWORD bytesread; - char *data=(char *)alloca(Mus_nextBlockRead); - short accum[2]={0,0}; - char curchan=0; - - DWORD lockSizes[2]; - void *lockPtrs[2]; - - if (ReadFile(music_file,data,Mus_nextBlockRead,&bytesread,NULL)==FALSE) return 0; - - ds_music->Lock(Mus_lastWritePos,Mus_nextBlockSize,lockPtrs,lockSizes,lockPtrs+1,lockSizes+1,0); - for (int j=0;j<2;j++) - { - short *target=(short *)lockPtrs[j]; - for (DWORD i=0;i=curMus.channels) curchan=0; - } - } - ds_music->Unlock(lockPtrs[0],lockSizes[0],lockPtrs[1],lockSizes[1]); - Mus_lastWritePos+=Mus_nextBlockSize; - if (Mus_lastWritePos>=Mus_buffSize) Mus_lastWritePos-=Mus_buffSize; - return 1; - } - -static char music_silent_play() - { - DWORD lockSizes[2]; - void *lockPtrs[2]; - - ds_music->Lock(Mus_lastWritePos,Mus_nextBlockSize,lockPtrs,lockSizes,lockPtrs+1,lockSizes+1,0); - for (int j=0;j<2;j++) - { - short *target=(short *)lockPtrs[j]; - for (DWORD i=0;iUnlock(lockPtrs[0],lockSizes[0],lockPtrs[1],lockSizes[1]); - Mus_lastWritePos+=Mus_nextBlockSize; - if (Mus_lastWritePos>=Mus_buffSize) Mus_lastWritePos-=Mus_buffSize; - return 1; - } - - -void fade_music() - { - if (fadetime==0) fadetime=music_file?GetTickCount():0; - } - - -static int mix_back_sound_worker() - { - DWORD bytesread; - if (music_file==NULL) return -2; - if (ds_music==NULL) - if (OpenMus(music_file)==0) return -2; - DWORD play; - ds_music->GetCurrentPosition(&play,NULL); - while (true) - { - if (Mus_lastWritePos<=play) - { - if (Mus_lastWritePos+Mus_nextBlockSize>=play) return 0; - } - else - { - if (Mus_lastWritePos+Mus_nextBlockSize>play+Mus_buffSize) return 0; - } - if (Mus_silentPlay) - { - if (Mus_silentPlay>GetTickCount()) - { - music_silent_play(); - return 0; - } - else - return -2; - } - - if (music_decompres_block()==0) return -2; - curMus.blocks--; - if (curMus.blocks<0) - { - Mus_silentPlay=GetTickCount()+4000; - return 0; - } - if (ReadFile(music_file,&Mus_nextBlockRead,sizeof(Mus_nextBlockRead),&bytesread,NULL)==FALSE) return -2; - if (ReadFile(music_file,&Mus_nextBlockSize,sizeof(Mus_nextBlockSize),&bytesread,NULL)==FALSE) return -2; - if (fadetime && fadetime+FADELENGTHIsPlaying()) return 0; - char *next_music; - - konec_skladby(&next_music); - change_music(next_music); - return 0; - } - -void change_music(const char *mus_filename) - { - if (GCurrentDecoder->NotUsingOutput()) GMusDecoder.Stop(); - GCurrentDecoder->Stop(); - if (mus_filename==0) - { - mus_filename="?"; - GCurrentDecoder=&GMusDecoder; - } - else - { - const char *c=strrchr(mus_filename,'.'); - if (c!=0 && istrcmp(c,".mus")==0) - GCurrentDecoder=&GMusDecoder; - else - GCurrentDecoder=&GWinAmpPlayer; - } - GCurrentDecoder->AttachOutput(&GMusicPlayer); - if (GCurrentDecoder->Play(mus_filename)==false) change_music(0); - GCurrentDecoder->SetVolume(music_volume,get_snd_effect(SND_GVOLUME)); - if (GCurrentDecoder->NotUsingOutput()) - GMusDecoder.Play("?"); - } - - -int get_timer_value() - { - return GetTickCount()/TIMERSPEED - } -char *device_name(int device) - { - if (device!=DEV_DIRECTSOUND) return "Unknown device!"; - else return "DirectSound 8"; - } -void force_music_volume(int volume) - { - } -void set_backsnd_freq(int bfreq) - { - } - -void *PrepareVideoSound(int mixfreq, int buffsize) - { - WAVEFORMATEX wfex; - wfex.cbSize=sizeof(wfex); - wfex.wBitsPerSample=16; - wfex.nBlockAlign=4; - wfex.nSamplesPerSec=mixfreq; - wfex.nAvgBytesPerSec=mixfreq*wfex.nBlockAlign; - wfex.wFormatTag=WAVE_FORMAT_PCM; - wfex.nChannels=2; - - DSBUFFERDESC desc; - desc.dwSize=sizeof(desc); - desc.dwBufferBytes=Mus_buffSize=buffsize; - desc.dwReserved=0; - desc.dwFlags=DSBCAPS_CTRLVOLUME ; - desc.lpwfxFormat=&wfex; - - IDirectSoundBuffer *dsbf; - IDirectSoundBuffer8 *ds_music; - - hres=ds8->CreateSoundBuffer(&desc,&dsbf,NULL); - hres=dsbf->QueryInterface(IID_IDirectSoundBuffer8,(void **)&ds_music); - dsbf->Release(); - - void *ptr; - DWORD size; - - ds_music->Lock(0,0,&ptr,&size,NULL,NULL,DSBLOCK_ENTIREBUFFER); - memset(ptr,0,size); - ds_music->Unlock(ptr,size,NULL,NULL); - ds_music->SetVolume(0); - ds_music->Play(0,0,DSBPLAY_LOOPING); - return (void *)ds_music; - } - -char LoadNextVideoFrame(void *buffer, char *data, int size, short *xlat,short *accnums, int32_t *writepos) - { - IDirectSoundBuffer8 *ds_music=(IDirectSoundBuffer8 *)buffer; - DSBCAPS caps; - caps.dwSize=sizeof(caps); - ds_music->GetCaps(&caps); - DWORD play; - ds_music->GetCurrentPosition(&play,NULL); - int32_t remain=play-*writepos; - if (remain<0) remain+=caps.dwBufferBytes; - if (remainLock(*writepos,size*2,lockPtrs,lockSizes,lockPtrs+1,lockSizes+1,0); - for (int j=0;j<2;j++) - { - short *target=(short *)lockPtrs[j]; - for (DWORD i=0;i32767) - {accnums[curchan]-=val-32768;val=32767;} - if (val<-32767) - {accnums[curchan]-=val+32768;val=-32767;} - accnums[curchan]=val; -/* if (data[-1]==0) //pridano jako provizorni reseni pro korekci chyby komprimacniho programu - { - val-=31767; - }*/ - *target++=val; - curchan++; - if (curchan>=2) curchan=0; - } - } - ds_music->Unlock(lockPtrs[0],lockSizes[0],lockPtrs[1],lockSizes[1]); - writepos[0]+=size*2; - if (writepos[0]>caps.dwBufferBytes) writepos[0]-=caps.dwBufferBytes; - return 1; - } - - -void DoneVideoSound(void *buffer) - { - IDirectSoundBuffer8 *ds_music=(IDirectSoundBuffer8 *)buffer; - ds_music->Stop(); - ds_music->Release(); - } - -} - diff --git a/ZVUK/zvuka.asm b/ZVUK/zvuka.asm deleted file mode 100644 index f557efa..0000000 --- a/ZVUK/zvuka.asm +++ /dev/null @@ -1,1247 +0,0 @@ -.model small -.386P - -DGROUP group _DATA - - -tchannel struct - PLAYPOS DD ? - STARTLOOP DD ? - ENDLOOP DD ? - SPEEDMAJ DD ? - SPEEDMIN DW ? - MINORPOS DW ? - SMPTYPE DW ?;0 - DISABLED, 1 - 8 BIT, 2 - 16 BIT - VOLUMELEFT DW ? - VOLUMERIGHT DW ? -tchannel ends - -rm_playdata struct - XLAT_TAB DB 256 DUP(?) - SCANOFS DW ? - SCANSEG DW ? - PORT DW ? -rm_playdata ends - -extrn _chaninfo:dword -extrn _mixbuffer:dword -extrn _backsnd:dword ;ukazatel na buffer s hudbou na pozadi (64Kb) -extrn _backstep:dword ;krok o kolik se meni _backsnd -extrn _backfine:dword ;citac udavajici kdy se zmeni _backsnd -extrn _backsndbuff:dword ;buffer hudby na pozadi -extrn _call_back_data:dword ;data_call_back_procedury -extrn _call_back_sel:word ;data_call_back_procedury - -extrn _jumptable:dword[3] ;[0] - skip, [1] - mix8, [2] - mix16 -extrn _getdma:dword -extrn _ido:dword - -extrn _predstih:word -extrn _lastdma:dword -extrn _lastmix:dword -extrn _surpos:dword -extrn _mixpos:dword -extrn _mixsize:dword -extrn _samplerate:dword - -extrn _dmaposadr:dword -extrn _dmasizadr:dword -extrn _dmanum:byte -extrn _dpmiselector:word - -extrn _idt_map:dword - -extrn _test_counter:dword - -extrn _mixer_zavora:byte -extrn _timer_test_port:word -extrn _oldvect:dword - -extrn _devport:dword -extrn _devirq:dword - -extrn _gus_dma_type:byte -extrn _gus_last_buff:byte - -_TEXT segment byte public 'CODE' use32 - assume CS:_TEXT - assume DS:DGROUP - -gus_out equ 0 -gus_irqs equ 6 -gus_timer_c equ 8 -gus_timer_d equ 9 -gus_irq_dma equ 0bh -gus_voice equ 102h -gus_reg equ 103h -gus_reg_data equ 104h -gus_pio equ 107h - -gus_block equ 2000h - - - - PUBLIC MIXER_ -MIXER_: ;THIS IS MAIN MIXING PROCEDURE. - ;BEFORE USING, YOU MUST SET UP ALL VARIBLES TO THE CORRECT VALUES. - ;_MIXBUFFER MUST START ON PAGE OF MEMORY (EX. 0x10000 0x20000 0x30000) - ;PROCEDURE MUST BE CALLED EACH 55ms OR LITTLE. - ;IF YOU USING INTERRUPT, REMEBER, THAT YOU MUST STORE ALL REGISTERS - ;BEFORE USE. - - cmp _mixer_zavora,0 - jnz mixend - inc _mixer_zavora - CALL calcsize ;VYPOCET DELKY MIXOVANI - mov edi,_mixpos ;Nejprve se vymaze mixovaci pamet - mov ecx,_mixsize - shr ecx,2 - jz MIXALL -MIXOK: xor eax,eax -MIXCLR: mov [edi],ax - add di,2 - mov [edi],ax - add di,2 - dec ecx - jnz MIXCLR - lea ebx,_chaninfo ;TED SE ZACNE MIXOVAT -MIXING: xor eax,eax - mov ax,smptype[ebx] - call _jumptable[eax*4] - add ebx,sizeof(tchannel) - cmp ebx,(32*sizeof(tchannel))+offset _chaninfo - jnz MIXING - call _ido - mov ecx,_mixsize - add word ptr _mixpos,cx -MIXALL: mov _mixer_zavora,0 -MIXEND: ret - - -CALCSIZE:call _getdma ;eax - pozice v mixovaci pameti - mov ecx,eax ;ecx - pozice dma - sub cx,word ptr _mixpos ;odecti mixpos (dma-mix_pos<0) - js CALCOK - shr cx,2 - ;add _predstih,cx - ;add _predstih,64 -CALCOK: mov ebx,_lastdma - mov _lastdma,eax - sub ax,bx - add ax,_predstih - add ax,word ptr _lastdma - mov bx,word ptr _mixpos - sub ax,bx - js CALCEND - and ax,not 3 - add ax,4 - and eax,0ffffh - mov _mixsize,eax - ret -CALCEND:mov _mixsize,0 - ret - -ADDC macro REG1,REG2,CLIP - local addc1 - add REG1,REG2 - jno addc1 - shl REG2,1 - Mov REG2,CLIP - adc REG2,0 - mov REG1,REG2 -addc1: - endm - - - -MIXS_ :;primixuje sampl do bufferu (8-bit stereo) - ;musi platit vsechny promenne a ebx je adresa kanalu - mov edi,_mixpos - mov ecx,_mixsize - mov esi,[ebx] - push ebp - mov bp,minorpos[ebx] -mixslp: mov dl,[esi] - mov dh,dl - mov al,byte ptr volumeleft[ebx+1] - imul dl - shl eax,1 - mov dl,ah - mov al,byte ptr volumeright[ebx+1] - imul dh - shl eax,1 - mov dh,ah - mov ax,[edi] - addc al,dl,7fh - addc ah,dh,7fh - mov [edi],ax ;je smixovano - add di,2 ;dalsi pozice - add bp,speedmin[ebx] - adc esi,speedmaj[ebx] - cmp esi,endloop[ebx] - jc mixsskp - mov esi,startloop[ebx] - cmp esi,endloop[ebx] - jnz mixsskp - mov smptype[ebx],0 - jmp mixsend -mixsskp:dec ecx - dec ecx - jnz mixslp -mixsend:mov minorpos[ebx],bp - mov playpos[ebx],esi - pop ebp - ret - -mixskip:ret -mixs2 :;primixuje sampl do bufferu (16-bit stereo) - ;musi platit vsechny promenne a ebx je adresa kanalu - mov edi,_mixpos ;vem mixovaci pozici - mov ecx,_mixsize ;vem pocet potrebnych bajtu - mov esi,[ebx] ;vyzvedni ukazatel na sample - push ebp ;zachovej bp - mov bp,minorpos[ebx] ;bp pro tuto chvili predstavuje minorpozici -mix2slp:mov dl,[esi+1] ;vem sample, ale jen vyssi bajt - mov dh,dl ;zkopiruj levy kanal do praveho - mov al,byte ptr volumeleft[ebx+1];vyzvedni hlasitost leveho kanalu - imul dl ;nasob vzorek hlasitosti - shl eax,1 ;vysledek je v ah vydelen 256x - mov dl,ah ;schovej vysledek do dl - mov al,byte ptr volumeright[ebx+1];to same pro pravy kanal - imul dh - shl eax,1 - mov dh,ah - mov ax,[edi] ;ted precti aktualni stav samplu v bufferu - addc al,dl,7fh ;pricti levy kanal s clippingem - addc ah,dh,7fh ;pricti pravy kanal s clippingem - mov [edi],ax ;je smixovano - add di,2 ;dalsi pozice - add bp,speedmin[ebx] ;skok po minor hodnotach - lahf ;uchovej priznaky v ah (hlavne cf) - adc esi,speedmaj[ebx] ;skok po major hodnotach - sahf ;obnov cf - adc esi,speedmaj[ebx] ;a jeste jednou celkem o 2xvic nez je rychlost - cmp esi,endloop[ebx] ;test na konec samplu - jc mix2sskp ;pokud jsme prekrocili konec mohou nastat dva - mov esi,startloop[ebx];pripady: - cmp esi,endloop[ebx] ; bud ma sampl opakovani pak zacina na adrese - jnz mix2sskp ; startloop nebo nema - mov smptype[ebx],0 ; pak je vypnut - jmp mix2send ;skoc na konec -mix2sskp:dec ecx ;pokracujeme v prehravani - dec ecx ;byly naplneny 2 bajty, citac o 2 dolu - jnz mix2slp ;opakuj cele mixovani dokud neni citac nule -mix2send:mov minorpos[ebx],bp ;uloz minorpozici - mov playpos[ebx],esi ;uloz majorpozici - pop ebp ;obnov BP - ret ;konec - -m8sido: mov esi,_mixpos ;vem mixovaci pozici - sub si,2 ;o jeden sampl dozadu - and esi,not 1 - mov edi,_backfine ;finepozice - mov ebx,_backsnd ;pozice v bufferu - mov ecx,_mixsize ;pocet bajtu - sub ecx,2 - shl ecx,16 ;uloz do horni poloviny ecx - mov ax,[esi] ;vezmi sample - xor eax,8080h ;neznaminkova korekce -m8sido1:add si,2 ;dalsi sample - mov dx,[esi] ;nacti do dx sample - xor edx,8080h ;neznaminkova korekce - add al,dl ;secti leve kanaly - rcr al,1 ;nasleduje deleni 2x prumer - add ah,dh ;totez pro prave kanaly - rcr ah,1 - xor eax,8080h ;neznaminkova korekce - mov cl,byte ptr _backsndbuff[1+ebx*4] ;nacti back sound pro levej kanal - mov ch,byte ptr _backsndbuff[3+ebx*4];nactu back sound pro pravej kanal - addc al,cl,7fh ;secti s clippingem levy kanal - addc ah,ch,7fh ;secti s clippingem pravy kanal - add di,word ptr _backstep ;pricti fine pozici - adc bx,word ptr [_backstep+2];preteceni jde do bx plus step -; and ebx,03ffffh ;celkem 16384*4 samplu - xor eax,8080h ;neznaminkova korekce - sub si,2 ;uloz na zdrojovou pozici - mov [esi],ax - add si,2 - mov eax,edx ;pouzity sampl pro prumerovani se - sub ecx,20000h ;do ax a odecti dva takty pro citac - jnc m8sido1 ;a opakuj dokud neni konec - mov _backsnd,ebx - mov _backfine,edi - ret ;navrat - - -sbdma: mov edx,_dmaposadr - out 0ch,al - out 0d8h,al - xor eax,eax - in al,dx - xchg al,ah - in al,dx - xchg al,ah - cmp _dmanum,4 - jc sbdma1 - shl eax,1 -sbdma1: add eax,_mixbuffer - ret - - -PUBLIC setsbpro_ -setsbpro_: - lea edi,_jumptable - mov eax,offset mixskip - stosd - mov eax,offset mixs_ - stosd - mov eax,offset mixs2 - stosd - mov _getdma,offset sbdma - mov _ido,offset m8sido - ret - - -MIXM_ :;primixuje sampl do bufferu (8-bit mono) - ;musi platit vsechny promenne a ebx je adresa kanalu - mov edi,_mixpos ;vezmi mixovaci pozici - mov ecx,_mixsize ;vezmi delku mixovani - mov esi,[ebx] ;nacti ukazatel na aktualni pozici v samplu - push ebp ;uchovej docasne BP - mov bp,minorpos[ebx] ;bp ma novou ulohu, drzi minor pozici - mov al,byte ptr volumeleft[ebx+1] ;vypocti hlasitost - mov ah,byte ptr volumeright[ebx+1] - add al,ah - rcr al,1 ;jak prumer leve a prave hlasitosti - mov dh,al -mixmlp: mov al,[esi] ;vezmi sample - imul dh ;vynasob s hlasitosti - shl eax,1 ;vydel /256x (ah je vysledek) - mov al,[edi] ;vezmi momentalni obsah bufferu - addc al,ah,7fh ;secti s clippingem - mov [edi],al ;je smixovano - inc di ;dalsi pozice - add bp,speedmin[ebx] - adc esi,speedmaj[ebx] - cmp esi,endloop[ebx] - jc mixmskp - mov esi,startloop[ebx] - cmp esi,endloop[ebx] - jnz mixmskp - mov smptype[ebx],0 - jmp mixmend -mixmskp:dec ecx - jnz mixmlp -mixmend:mov minorpos[ebx],bp - mov playpos[ebx],esi - pop ebp - ret - -MIXM2 :;primixuje sampl 16 do bufferu (8-bit mono) - ;musi platit vsechny promenne a ebx je adresa kanalu - mov edi,_mixpos ;vezmi mixovaci pozici - mov ecx,_mixsize ;vezmi delku mixovani - mov esi,[ebx] ;nacti ukazatel na aktualni pozici v samplu - push ebp ;uchovej docasne BP - mov bp,minorpos[ebx] ;bp ma novou ulohu, drzi minor pozici - mov al,byte ptr volumeleft[ebx+1] ;vypocti hlasitost - mov ah,byte ptr volumeright[ebx+1] - add al,ah - rcr al,1 ;jak prumer leve a prave hlasitosti - mov dh,al -mixmlp2:mov al,[esi+1] ;vezmi sample - imul dh ;vynasob s hlasitosti - shl eax,1 ;vydel /256x (ah je vysledek) - mov al,[edi] ;vezmi momentalni obsah bufferu - addc al,ah,7fh ;secti s clippingem - mov [edi],al ;je smixovano - inc di ;dalsi pozice - add bp,speedmin[ebx] - lahf ;uchovej priznaky v ah (hlavne cf) - adc esi,speedmaj[ebx] ;skok po major hodnotach - sahf ;obnov cf - adc esi,speedmaj[ebx] ;a jeste jednou celkem o 2xvic nez je rychlost - cmp esi,endloop[ebx] - jc mixmskp2 - mov esi,startloop[ebx] - cmp esi,endloop[ebx] - jnz mixmskp2 - mov smptype[ebx],0 - jmp mixmend2 -mixmskp2:dec ecx - jnz mixmlp2 -mixmend2:mov minorpos[ebx],bp - mov playpos[ebx],esi - pop ebp - ret - -m8mido: mov esi,_mixpos ;vem mixovaci pozici - dec si ;o jeden sampl dozadu - lea edi,_backfine ;ukazatel na back sound buffer - mov ebx,_backsnd ;pozice v bufferu - mov ecx,_mixsize ;pocet bajtu - dec ecx - shl ecx,16 ;uloz do horni poloviny ecx - mov al,[esi] ;vezmi sample - xor eax,80h ;neznaminkova korekce -m8mido1:inc si ;dalsi sample - mov dl,[esi] ;nacti do dx - xor edx,80h ;neznaminkova korekce - add al,dl ;secti kanal - rcr al,1 ;nasleduje deleni 2x prumer - xor eax,80h ;vysledek oznamenkuj - bude se scitat - mov cl,byte ptr _backsndbuff[1+ebx*4];nacti back sound pro levej kanal - mov ch,byte ptr _backsndbuff[3+ebx*4];nactu back sound pro pravej kanal - add di,word ptr _backstep ;pricti fine pozici - adc bx,word ptr [_backstep+2];preteceni jde do bx plus step -; and ebx,03ffffh ;celkem 16384*4 samplu - sar cl,1 ;del levy kanal 2ma - sar ch,1 ;del pravy kanal 2ma - add cl,ch ;secti oba kanaly - addc al,cl,7fh ;secti s clippingem kanal - xor eax,80h ;neznaminkova korekce pro SB Pro - dec si ;uloz na zdrojovou pozici - mov [esi],al - inc si - mov eax,edx ;pouzity sampl pro prumerovani se - sub ecx,10000h ;do ax a odecti jeden takt pro citac - jnc m8mido1 ;a opakuj dokud neni konec - mov _backsnd,ebx - ret ;navrat - -m8midos:mov esi,_mixpos ;vem mixovaci pozici - dec si ;o jeden sampl dozadu - lea edi,_backfine ;ukazatel na back sound buffer - mov ebx,_backsnd ;pozice v bufferu - mov ecx,_mixsize ;pocet bajtu - dec ecx - shl ecx,16 ;uloz do horni poloviny ecx - mov al,[esi] ;vezmi sample - xor eax,80h ;neznaminkova korekce -m8mido2:inc si ;dalsi sample - mov dl,[esi] ;nacti do dx - xor edx,80h ;neznaminkova korekce - add al,dl ;secti kanal - rcr al,1 ;nasleduje deleni 2x prumer - xor eax,80h ;vysledek oznamenkuj - bude se scitat - mov cl,byte ptr _backsndbuff[1+ebx*4];nacti back sound pro levej kanal - mov ch,byte ptr _backsndbuff[3+ebx*4];nactu back sound pro pravej kanal - add di,word ptr _backstep ;pricti fine pozici - adc bx,word ptr [_backstep+2];preteceni jde do bx plus step -; and ebx,03ffffh ;celkem 16384*4 samplu - sar cl,1 ;del levy kanal 2ma - sar ch,1 ;del pravy kanal 2ma - add cl,ch ;secti oba kanaly - addc al,cl,7fh ;secti s clippingem kanal - dec si ;uloz na zdrojovou pozici - mov [esi],al - inc si - mov eax,edx ;pouzity sampl pro prumerovani se - sub ecx,10000h ;do ax a odecti jeden takt pro citac - jnc m8mido2 ;a opakuj dokud neni konec - mov _backsnd,ebx - ret ;navrat - - - - -PUBLIC setsb2_ -setsb2_: - lea edi,_jumptable - mov eax,offset mixskip - stosd - mov eax,offset mixm_ - stosd - mov eax,offset mixm2 - stosd - mov _getdma,offset sbdma - mov _ido,offset m8mido - ret - -PUBLIC setsb2_s_ -setsb2_s_: - lea edi,_jumptable - mov eax,offset mixskip - stosd - mov eax,offset mixm_ - stosd - mov eax,offset mixm2 - stosd - mov _getdma,offset sbdma - mov _ido,offset m8midos - ret - - -MIX16_ :;primixuje sampl do bufferu (16-bit stereo) - ;musi platit vsechny promenne a ebx je adresa kanalu - mov edi,_mixpos ;vem mixovaci pozici - mov ecx,_mixsize ;vem mixovaci delku - mov esi,[ebx] ;vyzvedni ukazatel na sample - push ebp ;uchovej BP - mov bp,minorpos[ebx] ;bp bude drzet minor pozice -mix1lp: mov al,[esi] ;nacti sample - mov dl,al ;al a dl obsahuji levej a pravej kanal - mov ah,byte ptr volumeright[ebx+1] ;nacti pravou hlastitot - imul ah ;vynasob hlasitosti - shl eax,1 ;vse je vyreseno, deleni neni potreba - xchg edx,eax ;ted pracuj s druhym kanalem - mov ah,byte ptr volumeleft[ebx+1] ;nactu hlasitost - imul ah ;vynasob - shl eax,1 - addc [edi],dx,7fffh ;k aktualnimu vzorku pricti hodnotu - add di,2 ;dalsi pozice - addc [edi],ax,7fffh ;je smixovano - add di,2 ;dalsi pozice - add bp,speedmin[ebx] - adc esi,speedmaj[ebx] - cmp esi,endloop[ebx] - jc mix1skp - mov esi,startloop[ebx] - cmp esi,endloop[ebx] - jnz mix1skp - mov smptype[ebx],0 - jmp mix1end -mix1skp:sub ecx,4 - jnz mix1lp -mix1end:mov minorpos[ebx],bp - mov playpos[ebx],esi - pop ebp - ret - -mix162: ;primixuje sampl do bufferu (16-bit stereo) - ;musi platit vsechny promenne a ebx je adresa kanalu - mov edi,_mixpos ;vem mixovaci pozici - mov ecx,_mixsize ;vem mixovaci delku - mov esi,[ebx] ;vyzvedni ukazatel na sample - push ebp ;uchovej BP - mov bp,minorpos[ebx] ;bp bude drzet minor pozice -mix12lp:movsx eax,word ptr [esi] ;nacti sample - imul word ptr volumeright[ebx] ;nacti pravou hlastitot a vynasob - shl edx,1 ;vse je vyreseno, deleni neni potreba - addc [edi],dx,7fffh ;k aktualnimu vzorku pricti hodnotu - add di,2 ;dalsi pozice - movsx eax,word ptr [esi] ;nacti sample - imul word ptr volumeleft[ebx] ;nacti pravou hlastitot a vynasob - shl edx,1 ;vse je vyreseno, deleni neni potreba - addc [edi],dx,7fffh ;k aktualnimu vzorku pricti hodnotu - add di,2 ;dalsi pozice - add bp,speedmin[ebx] - lahf ;uchovej priznaky v ah (hlavne cf) - adc esi,speedmaj[ebx] ;skok po major hodnotach - sahf ;obnov cf - adc esi,speedmaj[ebx] - cmp esi,endloop[ebx] - jc mix12skp - mov esi,startloop[ebx] - cmp esi,endloop[ebx] - jnz mix12skp - mov smptype[ebx],0 - jmp mix12end -mix12skp:sub ecx,4 - jnz mix12lp -mix12end:mov minorpos[ebx],bp - mov playpos[ebx],esi - pop ebp - ret - - -m16ido: push ebp - mov esi,_mixpos ;vem mixovaci pozici - sub si,4 ;o jeden sampl dozadu - mov edi,_backfine ;finepozice - mov ebx,_backsnd ;pozice v bufferu - mov ecx,_mixsize ;pocet bajtu - sub ecx,4 - shl ecx,16 ;uloz do horni poloviny ecx - mov eax,[esi] ;vezmi sample - xor eax,80008000h ;neznaminkova korekce -m16ido1:add si,4 ;dalsi sample - mov ebp,eax - and ebp,0ffff0000h - mov edx,[esi] ;nacti do dx sample - xor edx,80008000h ;neznaminkova korekce - add ax,dx ;secti leve kanaly - rcr ax,1 ;nasleduje deleni 2x prumer - add ebp,edx ;totez pro prave kanaly - rcr ebp,1 - shld eax,ebp,16 - xor eax,80008000h ;neznaminkova korekce - mov cx,word ptr _backsndbuff[ebx*4] ;nacti back sound pro levej kanal - addc ax,cx,7fffh ;secti s clippingem levy kanal - mov cx,word ptr _backsndbuff[2+ebx*4];nacti back sound pro pravej kanal - rol eax,16 - addc ax,cx,7fffh ;secti s clippingem pravy kanal - add di,word ptr _backstep ;pricti fine pozici - adc bx,word ptr [_backstep+2];preteceni jde do bx plus step -; and ebx,03ffffh ;celkem 16384*4 samplu - sub si,4 ;uloz na zdrojovou pozici - mov [esi],eax - add si,4 - mov eax,edx ;pouzity sampl pro prumerovani se - sub ecx,40000h ;do ax a odecti ctyri takty pro citac - jnc m16ido1 ;a opakuj dokud neni konec - pop ebp - mov _backsnd,ebx - mov _backfine,edi - ret ;navrat - - - -PUBLIC setsb16_ -setsb16_: - lea edi,_jumptable - mov eax,offset mixskip - stosd - mov eax,offset mix16_ - stosd - mov eax,offset mix162 - stosd - mov _getdma,offset sbdma - mov _ido,offset m16ido - ret - - -dpmibufalloc: - mov ax,0100h - int 31h - ret - -public buff_dealloc_ -buff_dealloc_: - mov dx,_dpmiselector - mov ax,0101h - int 31h - ret - -public buff_alloc_ - -buff_alloc_: - mov ebx,4200 - call dpmibufalloc - jc allcerror - test eax,0fffh - jz allc_ok - push eax - mov eax,0101h - int 31h - pop eax - mov ebx,eax - and ebx,0f000h - add ebx,1000h - sub ebx,eax - dec ebx - call dpmibufalloc - jc allcerror - push edx - call buff_alloc_ - mov ecx,edx - pop edx - push eax - mov eax,0101h - int 31h - pop eax - ret -allc_ok:mov _dpmiselector,dx - shl eax,4 - ret -allcerror: - mov word ptr _dpmiselector,0 - xor eax,eax - ret - -public int_relocation_ -int_relocation_: - mov eax,0de0ah - int 67h - shl ebx,16 - mov bx,cx - rol ebx,16 - mov eax,ebx - ret - -public int_mixer_alloc_ -int_mixer_alloc_: - lea eax,_idt_map - sidt [eax] -; db 0fh -; db 01 -; db 08h - add eax,2 - mov eax,[eax] - shl ebx,3 - add eax,ebx - cli - mov edi,eax - push ds - pop es - mov ecx,offset int_normal_ - mov eax,ecx - stosw - mov ax,cs - stosw - mov eax,8e00h - stosw - mov eax,ecx - shr eax,16 - stosw - sti - mov ebx,1000h - call dpmibufalloc - mov esi,4*8 - mov edi,offset rm_old - mov ecx,4 - rep movsb - mov _call_back_sel,dx - mov esi,offset rm_data_ - mov edi,eax - shl edi,4 - mov _call_back_data,edi - mov ecx,1000 - rep movsb - mov edi,4*8 - mov word ptr [edi],8 - mov [edi+2],ax - ret - -public int_high_alloc_ -int_high_alloc_: - lea eax,_idt_map - sidt [eax] - add eax,2 - mov eax,[eax] - shl ebx,3 - add eax,ebx - cli - mov edi,eax - push ds - pop es - mov ecx,offset int_hspd_ - mov eax,ecx - stosw - mov ax,cs - stosw - mov eax,8e00h - stosw - mov eax,ecx - shr eax,16 - stosw - sti - mov ebx,1000h - call dpmibufalloc - mov esi,4*8 - mov edi,offset rm_old - mov ecx,4 - rep movsb - mov _call_back_sel,dx - mov esi,offset rm_data_ - mov edi,eax - shl edi,4 - mov _call_back_data,edi - mov ecx,1000 - rep movsb - mov edi,4*8 -; mov word ptr [edi],(high_speed - rm_data_) -; mov [edi+2],ax - ret - -public high_speed_parm_ - ;eax dos delay - ;edx port - ;ebx mixbuffer - ;esi xlattab -high_speed_parm_: - mov edi,offset w_max - mov [edi],ax - mov edi,offset rm_hspd - mov ecx,64 - rep movsd - xor eax,eax - stosw - mov eax,ebx - shr eax,4 - stosw - mov eax,edx - stosw - ret -public int_dealloc_ -int_dealloc_: - mov edi,4*8 - mov esi,offset rm_old - mov ecx,4 - rep movsb - mov dx,_call_back_sel - mov ax,101h - int 31h - ret - -public write_adlib_ -write_adlib_: - mov dx,_timer_test_port - out dx,al - in al,dx - in al,dx - in al,dx - in al,dx - in al,dx - in al,dx - mov al,ah - inc edx - out dx,al - mov ah,36 - dec edx -wwait: in al,dx - dec ah - jnz wwait - ret -public write_adlib_nodelay_ -write_adlib_nodelay_: - mov dx,_timer_test_port - out dx,al - in al,dx - in al,dx - in al,dx - in al,dx - in al,dx - in al,dx - mov al,ah - inc edx - out dx,al - ret - - -;public int_normal_: -int_normal_: - cli - pushad - push ds - push es - mov ax,seg _DATA - mov ds,ax - mov es,ax - mov al,20h - out 20h,al - mov dx,_timer_test_port - or dx,dx - jz intn_ok - in al,dx - test al,80h - jz intn_call_dos; - mov ax,8004h - call write_adlib_ -intn_ok:inc _test_counter - sti - call mixer_ - cli -intn_sk:pop es - pop ds - popad - iretd - -intn_call_dos:call _oldvect - jmp intn_sk - -public int_hspd_: ;high speed mode interrupt - pro D/A a PC Speaker -int_hspd_: - push ds - push esi - push ebx - push edx - push eax - mov al,20h - out 20h,al - mov ax,seg _DATA - mov ds,ax - mov ebx,_call_back_data - add ebx,(offset rm_hspd-offset rm_data_) - xor eax,eax - xor esi,esi - mov ax,[ebx+scanofs] - mov si,[ebx+scanseg] - shl esi,4 - add esi,eax - mov dx,[ebx+port] - lodsb - xlatb - out dx,al - inc word ptr [ebx+scanofs] - mov ebx,_call_back_data - dec word ptr [ebx] - jnz hs_end - mov ax,[ebx+2] - mov [ebx],ax - sti - call mixer_ - cli -hs_end: - pop eax - pop ebx - pop edx - pop esi - pop ds - iretd - -;------------------------------- ULTRASND LIB ----------------- -;Special thanx for Dalibor Straka - -gus_sv macro voice - mov edx,_devport - add edx,gus_voice - mov al,voice - out dx,al - ENDM - -gus_w macro reg,data - mov edx,_devport - mov al,reg - add edx,gus_reg - out dx,al - mov eax,data - add edx,gus_reg_data-gus_reg - out dx,ax - in ax,dx - in ax,dx - in ax,dx - in ax,dx - in ax,dx - in ax,dx - mov eax,data - out dx,ax - ENDM - -gus_wb macro reg,data - mov edx,_devport - mov al,reg - add edx,gus_reg - out dx,al - mov al,data - add edx,gus_reg_data-gus_reg+1 - out dx,al - in al,dx - in al,dx - in al,dx - in al,dx - in al,dx - in al,dx - mov al,data - out dx,al - ENDM - -gus_wbd macro reg,data - mov edx,_devport - mov al,reg - add edx,gus_reg - out dx,al - mov al,data - add edx,gus_reg_data-gus_reg+1 - out dx,al - endm - -gus_r macro reg ;vysledek v eax - mov edx,_devport - mov al,reg - add edx,gus_reg - out dx,al - add edx,gus_reg_data-gus_reg - in ax,dx - movzx eax,ax - ENDM - - -;organizace GUS RAM -;<0 - gus_block> prehravaci blok -;<32768 - +gus_block> mirror buffer (prazdny) - -extrn prepare_dma_:proc ;priprava DMA - -public stop_gus_ ;deinicializuje GUS -stop_gus_: - mov cl,31 ;ted se vyresetuji vsechny kanaly -igus_2: gus_sv cl ;vyber hlas - gus_wb 0,2 ;vypni hlas - gus_wb 1,0 ;nastav krok na 0 - gus_w 2,0003h ;nastav hlas na konec 64KB bloku - gus_w 3,0ff00h - gus_w 4,0003h - gus_w 5,0ff00h - gus_w 0Ah,0003h - gus_w 0Bh,0ff00h - gus_wb 0Dh,3fh ;vypni volume ramp - gus_wb 07h,0fh ;hlasitost 0 - gus_wb 08h,10h ;hlasitost 0 - gus_w 09h,0 ;hlasitost 0 - sub cl,1 - jnc igus_2 - ret - -gus_dma db 0,11h,11h,22h,22h,33h,44h,55h - -public init_gus_ ;inicializuje GUS do rezimu prehravani samplu - -init_gus_: - mov edx,_devport - mov al,19h ;zapni out - out dx,al - mov edx,_devport - lea edx,[edx+gus_irq_dma] - movzx eax,_dmanum - mov al,cs:gus_dma[eax] - out dx,al ;nastav DMA - gus_wbd 4ch,0 ;reset gus - mov edx,_devport - add edx,6 - mov ecx,1000 -igus_3: in al,dx - loop igus_3 ;cekani - gus_wbd 4ch,1 ;reset gus - add edx,6 - mov ecx,1000 -igus_4: in al,dx - loop igus_4 - gus_wbd 4ch,3 ;povol dac - mov edx,_devport - mov edi,_mixbuffer - mov ecx, 65536 shr 2 - xor eax,eax - rep stosd ;vynuluj dma_buffer - mov edx,_devport - add edx,gus_irqs - in al,dx - gus_r 41h - gus_wb 41h,0 - mov edx,_devport - add edx,gus_irqs - in al,dx - gus_r 41h - gus_r 41h - gus_w 42h,0 - mov eax,_mixbuffer - mov edx,65536 - call prepare_dma_ - movzx ecx,_gus_dma_type - gus_wb 41h,cl ;vynuluj prvnich 64KB GUSRAM - xor edx,edx - mov eax,617400 - mov ecx,_samplerate - div ecx - add dx,8000h - adc al,0 - cmp al,33 - jc igus_1 - mov al,32 -igus_1: dec al - or al,0c0h - mov cl,al - gus_wb 0eh,cl - call stop_gus_ - gus_sv 0 - mov ecx,0 ;nastaveni hlasu cislo 0 - gus_w 2,ecx ;zacni na 0 - gus_w 3,ecx - gus_w 0Ah,ecx - gus_w 0Bh,ecx - mov ecx,(gus_block-4) shl 8 ;konec az za gus_blockem - gus_w 5,ecx - shr ecx,16 - gus_w 4,ecx - mov ecx,(1 shl 0bh) - gus_w 1,ecx ;krok 2 - gus_w 9,0ffffh ;hlasitost max - gus_wb 0ch,0 ;panning vlevo - gus_wb 00,0ch ;spust hlas - gus_sv 1 ;nastaveni hlasu cislo 1 - mov ecx,2 shl 8 - gus_w 3,ecx ;zacni na 2 - gus_w 0Bh,ecx - shr ecx,16 - gus_w 2,ecx - gus_w 0Ah,ecx - mov ecx,(gus_block-2) shl 8 ;konec az za gus_blockem - gus_w 5,ecx - shr ecx,16 - gus_w 4,ecx - mov ecx,(1 shl 0bh) - gus_w 1,ecx ;krok 2 - gus_w 9,0ffffh ;hlasitost max - gus_wb 0ch,0fh ;panning vpravo - gus_wb 00,0ch ;spust hlas - ret - -gus_move_buff: ;presun bufferu do GUS - push eax - mov edx,_devport - add edx,gus_irqs - in al,dx - gus_r 41h - gus_wbd 41h,0 - mov edx,_devport - add edx,gus_irqs - in al,dx - gus_r 41h - gus_r 41h - mov edx,_devport - add edx,gus_irqs - in al,dx - pop eax - xor esi,esi - and ah,1fh - or ah,ah - jz gus_mb1 - mov esi,(gus_block shr 1) -gus_mb1:mov cl,4 - test _gus_dma_type,4 - jz gus_mb2 - inc cl -gus_mb2:shr esi,cl - push esi - mov eax,_mixbuffer - mov edx,ebx - call prepare_dma_ - pop esi - gus_w 42h,esi - movzx ecx,_gus_dma_type - gus_wbd 41h,cl - ret - -gus_skip:mov eax,_mixbuffer - mov _mixpos,eax - xor ecx,ecx - mov _mixsize,ecx - mov cl,_gus_last_buff - gus_sv 0 - gus_r 8Ah - shl eax,8 - cmp eax,gus_block shr 1 - rcl ch,1 - xor cl,ch - jz gus_ie - mov ah,ch - mov _gus_last_buff,ch - mov ecx,(gus_block shr 1) - mov _mixsize,ecx -gus_ie: pop eax - ret - - - -m16idog:push ebp - mov esi,_mixpos ;vem mixovaci pozici - mov edi,_backfine ;finepozice - mov ebx,_backsnd ;pozice v bufferu - mov ecx,_mixsize ;pocet bajtu - shr ecx,2 - dec ecx - shl ecx,16 -m16ido2:mov eax,[esi] - mov cx,word ptr _backsndbuff[ebx*4] ;nacti back sound pro levej kanal - addc ax,cx,7fffh ;secti s clippingem levy kanal - mov cx,word ptr _backsndbuff[2+ebx*4];nacti back sound pro pravej kanal - rol eax,16 - addc ax,cx,7fffh ;secti s clippingem pravy kanal - add di,word ptr _backstep ;pricti fine pozici - adc bx,word ptr [_backstep+2];preteceni jde do bx plus step - and ebx,03ffffh ;celkem 16384*4 samplu - mov [esi],eax - add si,4 - sub ecx,10000h ;do ax a odecti ctyri takty pro citac - jnc m16ido2 ;a opakuj dokud neni konec - pop ebp - mov _backsnd,ebx - mov _backfine,edi - mov ah,_gus_last_buff - mov ebx,_mixsize ;pocet bajtu - call gus_move_buff - ret ;navrat - - - - - -PUBLIC setGUS_ -setGUS_: - lea edi,_jumptable - mov eax,offset mixskip - stosd - mov eax,offset mix16_ - stosd - mov eax,offset mix162 - stosd - mov _getdma,offset GUS_SKIP - mov _ido,offset m16idog - ret - -public gus_setchan_vol_ -gus_setchan_vol_: ;ecx,eax - gus_sv al - gus_w 9,ecx - ret - -public gus_setchan_pan_ -gus_setchan_pan_: ;ecx,eax - gus_sv al - gus_wb 0ch,cl - ret - - -_TEXT16 SEGMENT BYTE PUBLIC USE16 'CODE' - ASSUME cs:_TEXT16 -public rm_proc_: -rm_data_: -w_count:dw 2 ;citac preruseni -w_max dw 2 ;maximalni hodnota citace -rm_old dw ? ;stary vektor preruseni - dw ? -rm_proc_: - cli - int 1ch - cli - push si - xor si,si - dec word ptr cs:[si] - jnz w_skip - push ax - mov ax,cs:[si+2] - mov cs:[si],ax - pop ax - pushf - call dword ptr cs:[si+4] -w_skip: pop si - iret - -rm_hspd db 300 dup(?) -high_speed: - push ds - push si - push bx - push dx - push ax - mov bx,offset rm_hspd-offset rm_data_ - lds si,cs:[bx+scanofs] - mov dx,cs:[bx+port] - lodsb - xlat cs: - out dx,al - mov cs:[bx+scanofs],si - mov al,20h - out 20h,al - dec word ptr cs:[0] - jnz hspd_end - mov ax,cs:[2] - mov cs:[0],ax - pushf - call dword ptr cs:[4] - int 1ch -hspd_end: - pop ax - pop dx - pop bx - pop si - pop ds - iret - -_TEXT16 ends - - -_TEXT ends - -END - diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index 56243b3..2c47152 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -1,8 +1,16 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/default_font.base64 COMMAND file_to_base64 ${CMAKE_CURRENT_LIST_DIR}/boldcz.fon > ${CMAKE_BINARY_DIR}/default_font.base64 DEPENDS ${CMAKE_CURRENT_LIST_DIR}/boldcz.fon) +add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/icon.base64 + COMMAND file_to_base64 ${CMAKE_CURRENT_LIST_DIR}/icon.bmp > ${CMAKE_BINARY_DIR}/icon.base64 + DEPENDS ${CMAKE_CURRENT_LIST_DIR}/icon.bmp) +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/resources.cpp + COMMAND ${CMAKE_COMMAND} -DOUT=${CMAKE_BINARY_DIR}/resources.cpp -DIN_FONT=${CMAKE_BINARY_DIR}/default_font.base64 -DIN_ICON=${CMAKE_BINARY_DIR}/icon.base64 -DTEMPLATE=${CMAKE_CURRENT_LIST_DIR}/resources.in.cpp -P ${CMAKE_CURRENT_LIST_DIR}/resources_to_cpp.cmake + DEPENDS ${CMAKE_BINARY_DIR}/default_font.base64 ${CMAKE_BINARY_DIR}/icon.base64 ${CMAKE_CURRENT_LIST_DIR}/resources_to_cpp.cmake ${CMAKE_CURRENT_LIST_DIR}/resources.in.cpp + ) add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/default_font.cpp COMMAND ${CMAKE_COMMAND} -DOUT=${CMAKE_BINARY_DIR}/default_font.cpp -DIN=${CMAKE_BINARY_DIR}/default_font.base64 -DTEMPLATE=${CMAKE_CURRENT_LIST_DIR}/default_font.in.cpp -P ${CMAKE_CURRENT_LIST_DIR}/default_font_to_cpp.cmake @@ -37,7 +45,7 @@ gen_stringtable.c advconfig.c temp_storage.cpp lang.c -${CMAKE_BINARY_DIR}/default_font.cpp +${CMAKE_BINARY_DIR}/resources.cpp ) add_library(skeldal_main ${files}) diff --git a/game/automap.c b/game/automap.c index 1b84221..1789eb0 100644 --- a/game/automap.c +++ b/game/automap.c @@ -143,7 +143,8 @@ void save_text_to_map(int x,int y,int depth,char *text) char c[512],*d; if (text[0]==0) return; memset(c,1,sizeof(c)); - strcpy(c+12,text); + strncpy(c+12,text,sizeof(c)-13); + c[511] = 0; if (texty_v_mape==NULL) texty_v_mape=create_list(8); d=texty_v_mape[str_add(&texty_v_mape,c)]; x=(x-320)+map_xr; diff --git a/game/builder.c b/game/builder.c index a863fa4..a969dbd 100644 --- a/game/builder.c +++ b/game/builder.c @@ -719,13 +719,7 @@ void create_minimap(int sector, int smer) } -static const float Snapper=3<<22; -static __inline int toInt( float fval ) -{ - fval += Snapper; - return ( (*(int *)&fval)&0x007fffff ) - 0x00400000; -} static const void *check_autofade(const void *image, char ceil, int dark) @@ -755,9 +749,9 @@ static const void *check_autofade(const void *image, char ceil, int dark) int r=*imgdata>>11; int g=(*imgdata>>5) & 0x3F; int b=*imgdata & 0x1F; - r=toInt(r+factor*(br-r)); - g=toInt(g+factor*(bg-g)); - b=toInt(b+factor*(bb-b)); + r=(int)(r+factor*(br-r)); + g=(int)(g+factor*(bg-g)); + b=(int)(b+factor*(bb-b)); *imgdata=(r<<11)|(g<<5)|b; imgdata++; } @@ -954,8 +948,8 @@ void draw_players(int sector,int dir,int celx,int cely) { int i; THUMAN *p; - char freep[5]; - int j,d,pp=0,f; + char freep[5]= {0,0,0,0,0}; + int j,d,pp=0,f=0; memset(freep,0,sizeof(freep)); for(i=0,pp=0;i - - -constexpr binary_data font_data ="@CONTENT@"; - -extern "C" { - -const void *LoadDefaultFont() { - return font_data.begin(); -} - -} - - diff --git a/game/default_font_to_cpp.cmake b/game/default_font_to_cpp.cmake deleted file mode 100644 index e3dfec3..0000000 --- a/game/default_font_to_cpp.cmake +++ /dev/null @@ -1,4 +0,0 @@ -file(READ ${IN} CONTENT) - -configure_file(${TEMPLATE} ${OUT} @ONLY) - diff --git a/game/dialogy.c b/game/dialogy.c index c0eb7b3..4decc3f 100644 --- a/game/dialogy.c +++ b/game/dialogy.c @@ -159,7 +159,7 @@ static void dialog_anim(va_list args) const void *anm; void *aptr; char hid; - int spdc=0,cntr=rep,tm,tm2; + int spdc=0,cntr=rep,tm = 0,tm2 = 0; int32_t scr_linelen2 = GetScreenPitch(); loc_anim_render_buffer=PIC_Y*scr_linelen2+PIC_X; @@ -216,7 +216,7 @@ static void run_anim(char *name,int speed,int rep) static void error(char *text) { char buff[256]; - sprintf(buff,"%s v odstavci %d\r\nLocal_pgf=%d / DIALOG : %d / SENTENCE : %d\r\n",text,last_pgf+local_pgf,local_pgf,local_pgf/128,last_pgf); + sprintf(buff,"%.125s v odstavci %d\r\nLocal_pgf=%d / DIALOG : %d / SENTENCE : %d\r\n",text,last_pgf+local_pgf,local_pgf,local_pgf/128,last_pgf); // MessageBox(NULL,buff,NULL,MB_OK|MB_ICONSTOP|MB_SYSTEMMODAL); SEND_LOG("(DIALOGS) Dialog error detected at %d:%d",local_pgf/128,last_pgf); SEND_LOG("(DIALOGS) Error description: %s",text); @@ -312,7 +312,7 @@ static char *transfer_text(const char *source,char *target) if (*source=='l') { sn_nums[0]=sn_nums[num]; - strcpy(sn_nams[0],sn_nams[num]); + strcopy_n(sn_nams[0],sn_nams[num],sizeof(sn_nams[0])); sn_rods[0]=sn_rods[num]; } break; @@ -554,14 +554,14 @@ static void lecho(char *c) static void save_name(int pos) { sn_nums[pos]=sn_nums[0]; - strcpy(sn_nams[pos],sn_nams[0]); + strcopy_n(sn_nams[pos],sn_nams[0],sizeof(sn_nams[pos])); sn_rods[pos]=sn_rods[0]; } static void load_name(int pos) { sn_nums[0]=sn_nums[pos]; - strcpy(sn_nams[0],sn_nams[pos]); + strcopy_n(sn_nams[0],sn_nams[pos],sizeof(sn_nams[0])); sn_rods[0]=sn_rods[pos]; } @@ -1260,7 +1260,7 @@ void do_dialog() case 134:p1=Get_short();p2=Get_short();nahodne(VLS_SMAGIE,p1,p2);break; case 135:p1=Get_short();p2=Get_short();nahodne(VLS_SILA,p1,p2);break; case 136:p1=Get_short();p2=Get_short();nahodne(VLS_OBRAT,p1,p2);break; - case 137:c=Get_string();p1=Get_short();strncpy(sn_nams[0],c,32);sn_rods[0]=p1;break; + case 137:c=Get_string();p1=Get_short();strcopy_n(sn_nams[0],c,32);sn_rods[0]=p1;break; case 138:iff=Get_short();break; case 139:goto_paragraph(Get_short());break; case 140:p1=Get_short();if (iff) goto_paragraph(p1);break; diff --git a/game/enemy.c b/game/enemy.c index 54a2de0..0f639cb 100644 --- a/game/enemy.c +++ b/game/enemy.c @@ -314,9 +314,9 @@ static char pick_item_corpse(TMOB *m,char query) static char seber_predmet(TMOB *m) { short *p=NULL,*q; - int i,j,c,z; + int i,j,c,z = 0; - for(j=0,c=0;jinv[j]==0)); + for(j=0,c=0;jinv[j]==0),++j); i=0; do { @@ -535,7 +535,7 @@ char je_mozne_videt(int sector1, int sector2, int flag) { int q_vidis_postavu(int sector,int dir,TMOB *p,int *otocit_se,char ret) { int i,z=-1; - int xs,ys,nd,d,dis=255; + int xs,ys,nd=0,d,dis=255; if (p->vlastnosti[VLS_KOUZLA] & SPL_BLIND) return -1; if (p->vlastnosti[VLS_KOUZLA] & SPL_FEAR) return -1; @@ -558,7 +558,7 @@ int q_vidis_postavu(int sector,int dir,TMOB *p,int *otocit_se,char ret) if (ok) if (je_mozne_videt(sector,postavy[i].sektor,SD_MONST_IMPS | SD_PLAY_IMPS)) { - int alt; + int alt = 0; if (ys>=abs(xs)) {nd=0;alt=xs>0?3:1;} else if (xs>=abs(ys)) {nd=3;alt=ys>0?0:2;} else if (ys<=(-abs(xs))) {nd=2;alt=xs>0?1:3;} @@ -1198,7 +1198,7 @@ static int mob_check_teleport(int sect,int num) void mob_step_next(int num,int sect,int dir,char *change) { - int c,numm,d; + int c,numm,d = 0; TMOB *p; *change+=128; @@ -1387,7 +1387,7 @@ void mob_hit(TMOB *mm,int dostal) bott_draw(0); if (mm->lives<1) { - int xpos; + int xpos = 0; switch (viewdir) { case 0:xpos=-(mm->locx-128);break; diff --git a/game/gamesave.c b/game/gamesave.c index 714dd75..d5695ef 100644 --- a/game/gamesave.c +++ b/game/gamesave.c @@ -623,7 +623,7 @@ int save_basic_info() s.out_filter=get_snd_effect(SND_OUTFILTER); s.autosave=autosave_enabled; s.game_flags=(enable_glmap!=0); - strncpy(s.level_name,level_fname,12); + strcopy_n(s.level_name,level_fname,12); for(i=0;i<5;i++) s.runes[i]=runes[i]; if (picked_item!=NULL) for(i=1,p=picked_item;*p;i++,p++);else i=0; @@ -712,7 +712,7 @@ int load_basic_info() set_snd_effect(SND_OUTFILTER,s.out_filter); if (level_fname==NULL || strncmp(s.level_name,level_fname,12)) { - strncpy(loadlevel.name,s.level_name,12); + strcopy_n(loadlevel.name,s.level_name,12); loadlevel.start_pos=viewsector; loadlevel.dir=viewdir; send_message(E_CLOSE_MAP); @@ -760,7 +760,7 @@ int save_game(int slotnum,char *gamename) ssn=alloca(strlen(sn)+3); sprintf(ssn,sn,slotnum); gn=alloca(SAVE_NAME_SIZE); - strncpy(gn,gamename,SAVE_NAME_SIZE); + strcopy_n(gn,gamename,SAVE_NAME_SIZE); if ((r=save_shops())!=0) return r; if ((r=save_basic_info())!=0) return r; save_book(); diff --git a/game/globals.h b/game/globals.h index 47676bd..332318a 100644 --- a/game/globals.h +++ b/game/globals.h @@ -1721,7 +1721,7 @@ int smlouvat_prodej(int cena,int ponuka,int posledni,int puvod,int pocet); THAGGLERESULT smlouvat_dlg(int cena,int puvod,int pocet,int posledni, int money,char mode); void disable_intro(void); -void show_jrc_logo(char *filename); +//void show_jrc_logo(char *filename); //dialogy diff --git a/game/globmap.c b/game/globmap.c index eca4396..7d4f991 100644 --- a/game/globmap.c +++ b/game/globmap.c @@ -206,7 +206,7 @@ static char test_kriterii(void) char last_op=0; char not_op=0; char text[128]; - char hodn; + char hodn = 0; char vysl=0; char symb,*c; @@ -427,7 +427,7 @@ static char flp_validate(word sector, void *ctx) { m=mobs+mob_map[sector]-1; if (m->vlajky & ~MOB_PASSABLE) return 0; - if (!m->next) + if (m->next) if (mobs[m->next-1].vlajky & ~MOB_PASSABLE) return 0; } c=map_sectors[sector].sector_type; @@ -484,7 +484,7 @@ static char load_index_map(int index) */ if (!GlobEvent(MAGLOB_LEAVEMAP,viewsector,viewdir)) return 0; viewsector=lv; - strncpy(x.name,index_tab[index].mapname,12); + strcopy_n(x.name,index_tab[index].mapname,12); x.start_pos=0; x.dir=0; macro_load_another_map(&x); diff --git a/AdvMan/FCS_tasker.h b/game/icon.base64 similarity index 100% rename from AdvMan/FCS_tasker.h rename to game/icon.base64 diff --git a/game/icon.bmp b/game/icon.bmp new file mode 100644 index 0000000..765bd50 Binary files /dev/null and b/game/icon.bmp differ diff --git a/game/interfac.c b/game/interfac.c index ef9688f..5995724 100644 --- a/game/interfac.c +++ b/game/interfac.c @@ -544,7 +544,7 @@ char labyrinth_find_path(word start,word konec,int flag,char (*proc)(word, void ok_flags[start>>3]|=1<<(start & 0x7); for(*stk_free++=start;stk_free!=stk_cur;stk_cur++) { - uint8_t i;word s,d,ss; + uint8_t i;word s=0,d=0,ss=0; s=(ss=Lo(*stk_cur))<<2; for(i=0;i<4;i++) if (!(map_sides[s+i].flags & flag)) { @@ -1181,7 +1181,7 @@ void fletna_pridej_notu(char note) { note+=65; fletna_str[pos]=note; - if (pos==13) memcpy(fletna_str,fletna_str+1,pos); + if (pos==13) memmove(fletna_str,fletna_str+1,pos-1); else pos++; } @@ -1535,6 +1535,7 @@ THAGGLERESULT smlouvat_dlg(int cena,int puvod,int pocet,int posledni, int money, return res; } +#if 0 //----------------- JRC LOGO ---------------------------------- #define SHOWDELAY 125 @@ -1611,3 +1612,4 @@ void show_jrc_logo(char *filename) showview(0,0,0,0); free(pcx); } +#endif diff --git a/game/inv.c b/game/inv.c index cdae9ac..ed19d1d 100644 --- a/game/inv.c +++ b/game/inv.c @@ -248,9 +248,9 @@ void load_items() *sep = 0; --sep; } - strncpy(glob_items[i].popis, nx, sizeof(glob_items[i].popis)-1); + strcopy_n(glob_items[i].popis, nx, sizeof(glob_items[i].popis)-1); } - strncpy(glob_items[i].jmeno, trnw, sizeof(glob_items[i].jmeno)-1); + strcopy_n(glob_items[i].jmeno, trnw, sizeof(glob_items[i].jmeno)-1); } } stringtable_free(str_table); @@ -270,7 +270,7 @@ static short expand_itemlist(void) if (item_count>32766) { - int i,j; + int i,j = 0; for(i=it_count_orgn;i=0) l=*(int32_t *)(((char *)human_selected)+parm); else switch (parm) diff --git a/game/kniha.c b/game/kniha.c index af51f86..9681a3e 100644 --- a/game/kniha.c +++ b/game/kniha.c @@ -323,7 +323,7 @@ static int get_data_handle(char *filename,void *dec) static void insert_picture(char *filename,int align,int line,int lsize) { - int x, y; + int x=0, y=0; const short *psiz; char *c=write_buff; @@ -391,7 +391,7 @@ static char read_tag(TMPFILE_RD *txt) while (c!='>') { c=read_set(txt,var,set); - if (!strcmp(var,SRC)) strncpy(pic_name,set,49); + if (!strcmp(var,SRC)) strcopy_n(pic_name,set,49); else if (!strcmp(var,ALIGN)) { if (!strcmp(set,ALEFT)) alig=1; diff --git a/game/kouzla.c b/game/kouzla.c index 808a290..fc298a6 100644 --- a/game/kouzla.c +++ b/game/kouzla.c @@ -205,14 +205,14 @@ const void *load_spells_legacy_format(const void *p, int32_t *s) { k = (np); for (int i = 0; i < count; ++i) { char *b = (char *)k; - char traceon = *(k->spellname-1); //traceon was there; + char traceon = b[offsetof(TKOUZLO, spellname)-1]; //traceon was there; size_t bofs = offsetof(TKOUZLO, traceon); size_t eofs = offsetof(TKOUZLO, spellname)-1; memmove(b+bofs+1, b+bofs, eofs-bofs);\ k->traceon = traceon; const char *new_name = stringtable_find(strtable, i, NULL); if (new_name) { - strncpy(k->spellname,new_name,sizeof(k->spellname)-1); + strcopy_n(k->spellname,new_name,sizeof(k->spellname)-1); } ++k; } @@ -435,7 +435,7 @@ static void spell_vzplanuti2(THE_TIMER *tt) static void spell_vzplanuti(int cil,int count,int hit,char mode,char zivel) { THE_TIMER *tt; - int sector,smer; + int sector = 0,smer = 0; int i,o,d; if (cil<0) { @@ -467,7 +467,7 @@ static void spell_vzplanuti(int cil,int count,int hit,char mode,char zivel) void spell_create(int cil,int what) { word sector=0; - char dir; + char dir = 0; short p[2]; if (dead_food) { @@ -508,7 +508,7 @@ void spell_create_weapon(int cil,int what) void spell_throw(int cil,int what) { word sector=0; - char dir; + char dir = 0; LETICI_VEC *fly; get_sector_dir(cil,§or,&dir); @@ -1029,7 +1029,7 @@ void spell_teleport_sector(int cil,int owner) if (cil!=owner) return; postavy_teleport_effect(0,0,0,1); - strncpy(loadlevel.name,TelepLocation.map,12); + strcopy_n(loadlevel.name,TelepLocation.map,12); loadlevel.name[12]=0; loadlevel.start_pos=TelepLocation.sector; loadlevel.dir=TelepLocation.dir; @@ -1102,7 +1102,7 @@ void spell_teleport_sector(int cil,int owner) static void spell_summon(int cil) { - short sector,i,rn,rno,slc; + short sector = 0,i,rn,rno,slc; int stdir,p; if (cil>0) sector=postavy[cil-1].sektor; @@ -1664,11 +1664,11 @@ void call_spell(int i) TelepLocation.map = 0; break; default: { - char *d = + const char *d = "Chyba v popisu kouzel: Program narazil na neznamou instrukci %d (%02X) pri zpracovani kouzla s cislem %d. Kouzlo bylo ukonďż˝eno"; - char *c = alloca(strlen(d) + 20); - sprintf(c, d, *(c - 1), *(c - 1), p->num); - bott_disp_text(c); + char *buff = alloca(strlen(d) + 20); + sprintf(buff, d, *(c - 1), *(c - 1), p->num); + bott_disp_text(buff); spell_end(i, p->cil, p->owner); return; } diff --git a/game/macros.c b/game/macros.c index 2cf93ae..80be6c2 100644 --- a/game/macros.c +++ b/game/macros.c @@ -118,7 +118,9 @@ void load_macros(int size,void *data) macro_state_block.states = (uint8_t *)(macros+count_s); macro_state_block.count = count_m; TMULTI_ACTION *m_iter = (TMULTI_ACTION *)(macro_state_block.states + count_m); +#ifndef NDEBUG TMULTI_ACTION *m_end = m_iter + count_m; +#endif first_macro = m_iter; iter = data; @@ -603,8 +605,8 @@ static void ma_move_group(int where,int turn,char effect) else { THUMAN *h=postavy; - int i; - int sctr; + int i=0; + int sctr=0; char kdo=0; for(i=0;i + + +constexpr binary_data font_data ="@FONT_CONTENT@"; +constexpr binary_data icon_data ="@ICON_CONTENT@"; + +extern "C" { + +const void *LoadDefaultFont(void) { + return font_data.begin(); +} + +const void *getWindowIcon(void) { + return icon_data.begin(); +} +size_t getWindowIconSize(void) { + return std::distance(icon_data.begin(),icon_data.end()); +} + + +} diff --git a/game/resources_to_cpp.cmake b/game/resources_to_cpp.cmake new file mode 100644 index 0000000..2735b13 --- /dev/null +++ b/game/resources_to_cpp.cmake @@ -0,0 +1,5 @@ +file(READ ${IN_FONT} FONT_CONTENT) +file(READ ${IN_ICON} ICON_CONTENT) + +configure_file(${TEMPLATE} ${OUT} @ONLY) + diff --git a/game/setup.c b/game/setup.c index 49dd0f4..b6015e1 100644 --- a/game/setup.c +++ b/game/setup.c @@ -27,7 +27,7 @@ char q_runsetup(char *parm) { char c[6]; - strncpy(c,parm,6); + strcopy_n(c,parm,6); strupper(c); return !strncmp(c,"/SETUP",6); } diff --git a/game/skeldal.c b/game/skeldal.c index 6a3c1fa..3f078b8 100644 --- a/game/skeldal.c +++ b/game/skeldal.c @@ -16,7 +16,7 @@ #include #include #include "globals.h" -#include "default_font.h" +#include "resources.h" // #include "advconfig.h" #include "skeldal.h" @@ -691,10 +691,9 @@ void *user_timer(EVENT_MSG *msg,void **usr) void do_timer(void) { EVENT_MSG msg; - char x; msg.msg=E_IDLE; - otevri_zavoru=&x; + *otevri_zavoru=1; user_timer(&msg,NULL); } @@ -865,7 +864,7 @@ void swap_error_exception(void) exit(0); } -void *boldcz; +const void *boldcz; #define ERR_WINX 320 #define ERR_WINY 100 @@ -946,6 +945,7 @@ void init_skeldal(const INI_CONFIG *cfg) exit(1); } showview = game_display_update_rect; + game_display_set_icon(getWindowIcon(), getWindowIconSize()); general_engine_init(); atexit(done_skeldal); @@ -1065,7 +1065,7 @@ extern char running_battle; ReloadMapInfo *minfo=va_arg(msg->data, ReloadMapInfo *); const char *fname=minfo->fname; int sektor=minfo->sektor; - strncpy(loadlevel.name,fname,sizeof(loadlevel.name)); + strcopy_n(loadlevel.name,fname,sizeof(loadlevel.name)); loadlevel.start_pos=sektor; for(i=0;i2) { sscanf(argv[2],"%d",§); @@ -1490,7 +1490,7 @@ static void start(va_list args) schovej_mysku(); if (!any_save()) { - show_jrc_logo("LOGO.PCX"); +// show_jrc_logo("LOGO.PCX"); play_anim(7); } skip_intro=0; @@ -1573,7 +1573,7 @@ const char *configure_pathtable(const INI_CONFIG *cfg) { static char default_subpaths[DEFAULT_SUBPATHS][DEFAULT_SUBPATHS_LEN]; for (int i = 0; i < DEFAULT_SUBPATHS; ++i) { - strncpy(default_subpaths[i], build_pathname(2, "graphics", sub_paths[i]), DEFAULT_SUBPATHS_LEN); + strcopy_n(default_subpaths[i], build_pathname(2, "graphics", sub_paths[i]), DEFAULT_SUBPATHS_LEN); } const INI_CONFIG_SECTION *paths = ini_section_open(cfg, "paths"); @@ -1603,6 +1603,7 @@ void display_error(const char *format, ...) { if (display_error_cb) { char buff[1024]; vsnprintf(buff,sizeof(buff), format, lst); + display_error_cb(buff); } else { fprintf(stderr, format, lst); } diff --git a/game/souboje.c b/game/souboje.c index d87f0e9..866df90 100644 --- a/game/souboje.c +++ b/game/souboje.c @@ -733,7 +733,7 @@ void wire_end_game() if (mname != NULL) { cur_group = postavy[i].groupnum; TMA_LOADLEV lv; - strncpy(lv.name,mname, sizeof(lv.name)-1); + strcopy_n(lv.name,mname, sizeof(lv.name)-1); lv.start_pos = -postavy[i].sektor; lv.dir = postavy[i].direction; macro_load_another_map(&lv); @@ -902,7 +902,7 @@ void utek_postavy(THUMAN *p) int trace_path(int sector,int dir) { - int mm,p,c=5; + int mm,p=0,c=5; int r=rnd(2); do { @@ -2247,7 +2247,7 @@ char zasah_veci(int sector,TFLY *fl) mob2=m1->next-MOB_START; if (mob2>=0) { - int x1,y1; + int x1=0,y1=0; m2=&mobs[mob2]; switch (fl->smer) { diff --git a/game/specproc.c b/game/specproc.c index da061c7..f744045 100644 --- a/game/specproc.c +++ b/game/specproc.c @@ -223,13 +223,6 @@ static void show_liane(THE_TIMER *t) -static const float Snapper=3<<22; - -static __inline int toInt(float fval) - { - fval += Snapper; - return ( (*(int *)&fval)&0x007fffff ) - 0x00400000; - } static void OtocObrazPodleMatice(float mx[3][2], word *picture) { @@ -243,8 +236,8 @@ static void OtocObrazPodleMatice(float mx[3][2], word *picture) { int oldx=x-320; int oldy=y-180; - int newx=toInt(oldx*mx[0][0]+oldy*mx[1][0]+320); - int newy=toInt(oldx*mx[0][1]+oldy*mx[1][1]+180); + int newx=(int)(oldx*mx[0][0]+oldy*mx[1][0]+320); + int newy=(int)(oldx*mx[0][1]+oldy*mx[1][1]+180); if (newx>=0 && newx<640 && newy>=0 && newy<360) trg[x]=picture[newx+640*newy]; else diff --git a/game/temp_storage.cpp b/game/temp_storage.cpp index 9537687..34bf203 100644 --- a/game/temp_storage.cpp +++ b/game/temp_storage.cpp @@ -43,7 +43,7 @@ void temp_storage_store(const char *name, const void *data, int32_t size) { v.resize(size+1); v[size] = 0; v.resize(size); - std::copy(b,e, v.begin()); + std::copy(b,e, v.begin()); } int32_t temp_storage_find(const char *name) { diff --git a/game/transav.c b/game/transav.c index bf8ac18..c6864c5 100644 --- a/game/transav.c +++ b/game/transav.c @@ -287,7 +287,7 @@ void unpack_save(void *in) s.items_added=0; s.glob_flags=0; s.game_time=0; - strncpy(s.level_name,mapname,12); + strcopy_n(s.level_name,mapname,12); memset(s.runes,0,sizeof(s.runes)); } @@ -583,7 +583,7 @@ void begin_program(char *sourceadv,char *targetadv) cprintf("Vystupni dobrodruzstvi %s musi obsahovat polozku DEFAULT_MAP\n\r", targetadv); exit(1); } - strncpy(mapname,c,12);mapname[12]=0; + strcopy_n(mapname,c,12);mapname[12]=0; c=get_text_field(trg,"CESTA_MAPY"); if (c==NULL) { diff --git a/game/wizard.c b/game/wizard.c index d894151..fb0be8d 100644 --- a/game/wizard.c +++ b/game/wizard.c @@ -359,7 +359,7 @@ static reload_mobs() { extern char reset_mobiles; reset_mobiles=1; - strncpy(loadlevel.name,level_fname,12); + strcopy_n(loadlevel.name,level_fname,12); loadlevel.start_pos=viewsector; loadlevel.name[12]=0; loadlevel.dir=viewdir; diff --git a/insteng/SETUP.C b/insteng/SETUP.C deleted file mode 100644 index 3249d9d..0000000 --- a/insteng/SETUP.C +++ /dev/null @@ -1,1462 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "setup.h" -#include "setvideo.h" -#include "setuplib.h" -#include "setupcpy.h" - -#define TEST_MUSIC "\\SNDTEST.MUS" -#define SETUP_BATCH "SETUP.BAT" -#define _SOURCE_ copy_source_path -#define ER_NAME "c:\\skeldal.!!!" -#define VEL_RAMECEK 8 - -#define VMODE "VMODE" -#define SOUND_DEVICE "SOUND_DEVICE" - -#define SETUP_NAME "SETUP.EXE" - -word *ramecky[VEL_RAMECEK]; - -#define SKELDAL "SKELDAL" -#define SKELDAL_INI SKELDAL".INI" -#define CONCAT(t,s1,s2) strcat(strcpy(t=alloca(strlen(s1)+strlen(s2)+1),s1),s2) -void *bbutt; - -char *copy_source_path; -char *test_sound_name; -char *program_data_path=NULL; -char setup_mode=0; -char subtitles=1; - -char *pgm_name; - -TSTR_LIST setup_ini; - -typedef struct tsound - { - int device,port,irq,dma; - }TSOUND; - - -FILE *ini; -word *vga_font; -word *icones; -word icone_color[7]={0x2108,0x7fff,0x000f,0x4210,0x6f7b}; -//static char target_path[256]="E:\HRY\SKELDAL\"; -char *source_path; -char target_path[2049]; -static TSOUND sound_info={0,0,0,0}; -static int vmode=0; -static char mixer_running=0; -static char back=0; -static char install_type; -static long install_sizes[3]; -static long maxcopy=1; -TSTR_LIST handbook=NULL; -TSTR_LIST dirlist=NULL; -TSTR_LIST disklist=NULL; -int win_handbook=-1; -char rescue_mode=0; -char *inifile=NULL; - -#pragma off (stack_checking) - -static char home_path(char *source_path) - { - unsigned x,z; - _dos_setdrive(source_path[0]-'@',&x); - _dos_getdrive(&z); - if (z!=source_path[0]-'@') return 1; - chdir("\\"); - chdir(source_path); - return 0; - } -char error_device(word a,char b,char c) - { - a,b,c; - - errno=-1; - return _ERR_FAIL; - } - -int create_er_file() - { - FILE *f; - if (!access(ER_NAME,F_OK)) return 0; - - f=fopen(ER_NAME,"w"); - fprintf(f,"7925536\n"); - fprintf(f,"This is a rescue file for Gates of Skeldal game. Don't erase the file, if INSTALL has crashed."); - fclose(f); - return 1; - } - -void remove_er_file() - { - FILE *f; - - f=fopen(ER_NAME,"r"); - if (f!=NULL) - { - long l=0; - fscanf(f,"%d",&l); - fclose(f); - if (l==7925536) remove(ER_NAME); - } - } - - -static conv_ramecek(word *ram) - { - int i; - word xs,ys; - char *ptr; - word *targ; - - xs=ram[0]; - ys=ram[1]/VEL_RAMECEK; - ptr=(char *)(ram+3+256); - for(i=0;i"); - } - for(i=0;i", - "", - "HICOLOR(64K)" - }; - -static void autodetect() - { - SVGAinfo si; - char s[80]; - - default_font=&font6x9; - def_dialoge(12,12,324,140,"Autodetection",2); - define(-1,5,22,1,1,0,label,"Graphic system:"); - define(-1,5,34,1,1,0,label,"Type of SVGA:"); - define(-1,5,46,1,1,0,label,"Resolution:"); - define(-1,5,62,1,1,0,label,"Sound card:"); - define(-1,5,74,1,1,0,label,"Parameters:"); - define(-1,5,90,1,1,0,label,"CD-ROM:"); - define(-1,5,110,1,1,0,label,"Mouse:"); - define(10,5,22,120,10,1,view_line,256);set_default(""); - define(20,5,34,160,10,1,view_line,256);set_default(""); - define(30,5,46,150,10,1,view_line,256);set_default(""); - define(40,5,62,120,10,1,view_line,256);set_default(""); - define(50,5,74,140,10,1,view_line,256);set_default(""); - define(60,5,90,150,10,1,view_line,256);set_default(""); - define(70,5,110,180,10,1,view_line,256);set_default(""); - set_enable(0,6,0); - set_enable(0,5,0); - do_events(); - if (getsvgainfo(&si)) - { - set_value(0,10,""); - set_value(0,20,""); - } - else - { - sprintf(s,"VESA %d.%02d",si.version/256,si.version%256); - set_value(0,10,s); - set_value(0,20,si.oemstr); - } - set_value(0,30,gr_mody[vmode]);do_events(); - sound_detect(&sound_info.device,&sound_info.port,&sound_info.dma,&sound_info.irq); - set_value(0,40,device_name(sound_info.device)); - if (sound_info.device==DEV_WSS || sound_info.device==DEV_ULTRA) - sprintf(s,"Port %X Dma %X",sound_info.port,sound_info.dma); - else sprintf(s,"Port %X Dma %X Irq %X",sound_info.port,sound_info.dma,sound_info.irq); - set_value(0,50,s); - set_value(0,60,get_cdrom()); - set_enable(0,6,1); - set_enable(0,5,1); - sprintf(s,"%d buttons",ms_get_keycount()); - set_value(0,70,s); - } - -static EVENT_PROC(esc_mode2) - { - GET_USER_PTR(); - WHEN_MSG(E_KEYBOARD) - { - if (GET_DATA(char)==27) - { - donegr(); - if (vmode==0)initgr_low();else initgr_spec(vmode); - zobraz_mysku(); - redraw_desktop(); - goto_control(0); - terminate_gui(); - } - } - } - -static char test_mode() - { - char i,j,c,z; - - z=f_get_value(0,9); - if (z!=5) - if (msg_box("Test",'\x1', - "Install will try to change the screen to selected video-mode. If screen stays black or display " - "nosences then immediately press ESC and install will restore previous mode. ", - "Try it","Cancel",NULL)==2) return 0; - else; - else - if (msg_box("Test grafiky",'\x1', - "Install will try to change the screen to selected video-mode. If screen stays black or display " - "nosences then immediately press ESC and install will restore previous mode. " - "Note: Game is optimized for HICOLOR(32K)!" - ,"Try it","Cancel",NULL)==2) return 0; - - send_message(E_ADD,E_KEYBOARD,esc_mode2); - donegr(); - i=initgr_spec(z); - if (!i) - { - zobraz_mysku(); - redraw_desktop(); - } - else - { - initgr_low();zobraz_mysku(); - msg_box("Not supported",2,"Graphic card don't support selected mode.","Ok",NULL); - } - if (!i && (j=msg_box("Result",'\x2',"Works it corretly?","Yes","No",NULL))==1) - { - vmode=f_get_value(0,9); - if (vmode==0) initgr_low(); - zobraz_mysku(); - c=1; - } - else - { - c_set_value(0,9,vmode); - donegr(); - if (vmode==0) initgr_low();else initgr_spec(vmode); - zobraz_mysku(); - redraw_desktop(); - c=0; - } - send_message(E_DONE,E_KEYBOARD,esc_mode2); - return c; - } - -static TSTR_LIST video_ls=NULL; - -static void create_video_ls() - { - int i; - if (video_ls==NULL) - { - video_ls=create_list(10); - for(i=0;i<6;i++) if (gr_mody[i][0]!='<')str_replace(&video_ls,i,gr_mody[i]); - } - } - -static void toggle_subtitles() - { - subtitles=f_get_value(0,30); - } - -static void select_vga() - { - default_font=&font6x9; - def_dialoge(20,300,156,156,"Graphics modes",2); - define(9,0,20,156,80,0,listbox,video_ls,0x03ff,0);c_default(vmode); - property(NULL,vga_font,NULL,WINCOLOR); - define(20,38,20,80,20,3,button,"Change now");on_control_change(test_mode); - property(bbutt,NULL,NULL,BUTTONCOLOR); - define(30,10,5,80,10,3,check_box,"Subtitles in intro.");c_default(subtitles);on_control_change(toggle_subtitles); - redraw_window(); - } - - -static void change_dma() - { - int i,j; - - i=f_get_value(0,30); - j=f_get_value(0,35)+3; - if (o_aktual->id==30) - { - c_set_value(0,30,i); - c_set_value(0,35,i-3); - } - else - { - c_set_value(0,30,j); - c_set_value(0,35,j-3); - } - } - -static void select_mode_win() - { - def_dialoge(224,270,192,156,"Install",2); - default_font=&font6x9; - define(10,30,40,132,30,0,button,"Automatic");property(bbutt,NULL,NULL,BUTTONCOLOR);on_control_change(terminate_gui); - define(30,30,80,132,30,0,button,"Custom");property(bbutt,NULL,NULL,BUTTONCOLOR);on_control_change(terminate_gui); - define(40,50,15,92,20,3,button,"Quit");property(bbutt,NULL,NULL,BUTTONCOLOR);on_control_change(stop_copy); - redraw_window(); - } - -static void select_mode_win_setup() - { - def_dialoge(224,270,192,156,"Menu",2); - default_font=&font6x9; - define(10,30,40,132,30,0,button,"Change settings");property(bbutt,NULL,NULL,BUTTONCOLOR);on_control_change(terminate_gui); - define(30,30,80,132,30,0,button,"Uninstall");property(bbutt,NULL,NULL,BUTTONCOLOR);on_control_change(terminate_gui); - define(40,50,15,92,20,3,button,"Quit");property(bbutt,NULL,NULL,BUTTONCOLOR);on_control_change(stop_setup); - redraw_window(); - } - - - -static void device_select() - { - int i,p; - i=f_get_value(0,9); - set_enable(0,40,i!=DEV_ULTRA && i!=DEV_WSS && i!=DEV_NOSOUND && i!=DEV_DAC); - p=i==DEV_SB16 || i==DEV_ULTRA; - set_enable(0,35,p); - if (p==0) - { - c_set_value(0,30,1); - c_set_value(0,35,1-3); - } - set_enable(0,20,i!=DEV_NOSOUND); - set_enable(0,30,i!=DEV_NOSOUND && i!=DEV_DAC); - set_enable(0,50,i!=DEV_NOSOUND); - } - -static void device_select2() - { - int i; - - device_select(); - i=f_get_value(0,9); - if (i==DEV_DAC) - { - char c; - def_dialoge(270,240,100,100,device_name(i),3); - define(10,10,25,60,40,0,radio_butts,3,"LPT 1","LPT 2","PC Speaker");c_default(0); - define(20,10,5,80,20,2,button,"Ok");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(terminate_gui); - redraw_window(); - escape(); - c=f_get_value(0,10); - close_current(); - if (c==0) set_value(0,20,"378");else - if (c==1)set_value(0,20,"278"); - else set_value(0,20,"042"); - } - if (i==DEV_SB16 || i==DEV_ULTRA || i==DEV_SBPRO || i==DEV_SB20 || i==DEV_SB10) - set_value(0,20,"220"); - if (i==DEV_WSS) set_value(0,20,"530"); - } - -static void select_sound(); -static void detect_sound() - { - if (msg_box("Sound card autodetect",'\x2',"This command may hangs computer. If it happened, restart the computer and configure sound card manually.","Yes","No",NULL)==2) return; - if (mixer_running) stop_mixing(); - mixer_running=0; - set_enable(0,70,mixer_running); - sound_detect(&sound_info.device,&sound_info.port,&sound_info.dma,&sound_info.irq); - close_current(); - select_sound(); - } - -static int sound_win=-1; - -static char sound_scan() - { - char buffer[20]; - char dmas[]={0,1,3,5,6,7}; - char irqs[]={2,3,5,7}; - - sound_info.device=f_get_value(sound_win,9); - if (sound_info.device!=DEV_NOSOUND) - { - if (sound_info.device==DEV_DAC) - if (msg_box("Warning!",'\x1', - "Selected sound device use non-standard accesses and routines using " - "hidden tricks on PC compatible computers. On some machines, device " - "may hangs the system. Don't use it, if not running under MS-DOS. " - "Don't use under WINDOWS! For best performance, uninstall any EMM manager, " - "such a EMM386, QEMM386 and other. Continue?", - "Yes","No",NULL)==2) return 1; - get_value(sound_win,20,buffer); - if (sscanf(buffer,"%x",&sound_info.port)!=1) - { - msg_box("Note!",'\x1',"Mistake in Port field","Ok",NULL); - return 1; - } - } - sound_info.dma=dmas[f_get_value(sound_win,30)]; - sound_info.irq=irqs[f_get_value(sound_win,40)]; - return 0; - } - - -static void test_sound() - { - if (mixer_running) stop_mixing(); - if (sound_scan()) return; - set_mixing_device(sound_info.device,22050,sound_info.port,sound_info.dma,sound_info.irq); - start_mixing(); - change_music(test_sound_name); - mix_back_sound(2); - mix_back_sound(0); - mixer_running=1; - set_enable(0,70,mixer_running); - } - -static void stop_sound() - { - if (mixer_running) - { - stop_mixing(); - mixer_running=0; - set_enable(sound_win,70,mixer_running); - } - } - -void select_sound() - { - TSTR_LIST ls; - int i; - char buff[30]; - - ls=create_list(8); - default_font=&font6x9; - for(i=0;i<8;i++) str_add(&ls,device_name(i)); - str_replace(&ls,0,""); - sound_win=def_dialoge(200,300,300,156,"Sound devices",2); - define(9,2,20,170,85,0,listbox,ls,0x03ff,0);c_default(sound_info.device);on_control_change(device_select2); - property(def_border(0,0x4210),vga_font,NULL,WINCOLOR); - define(-1,180,20,1,1,0,label,"Port:"); - define(20,10,20,30,12,1,input_line,3);property(def_border(0,0x4210),vga_font,NULL,WINCOLOR); - set_default(itoa(sound_info.port,buff,16)); - define(-1,180,40,1,1,0,label,"DMA:"); - i=sound_info.dma;i-=(i>2)+(i>4); - define(30,40,40,30,30,1,radio_butts,3,"0","1","3");c_default(i);on_control_change(change_dma); - define(35,10,40,30,30,1,radio_butts,3,"5","6","7");c_default(i-3);on_control_change(change_dma); - define(-1,180,80,1,1,0,label,"IRQ:"); - i=sound_info.irq;i-=2*(i>1)+(i>4)+(i>6); - define(40,40,80,30,40,1,radio_butts,4,"2","3","5","7");c_default(i); - define(50,10,5,80,20,2,button,"Test");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(test_sound); - define(60,100,5,80,20,2,button,"Autodetect");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(detect_sound); - define(70,190,5,80,20,2,button,"Stop");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(stop_sound); - redraw_window(); - set_enable(0,70,mixer_running); - device_select(); - } - -static void back_start() - { - back=1; - stop_sound(); - sound_scan(); - while (waktual!=NULL) close_current(); - terminate_gui(); - } - -static void control_window(void *forward,void *back,void *help); -static void control_next1(); - -static void control_back1() - { - close_current(); - get_value(0,60,target_path); - while (waktual!=NULL) close_current(); - exit_wait=0; - select_vga(); - select_sound(); - control_window(control_next1,back_start,open_help); - } - -static trace_chdir(char *what) - { - char *c; - char *d; - - c=alloca(strlen(what)+1); - strcpy(c,what); - d=strrchr(c,'\\'); - while (d!=NULL) - { - if (chdir(c)==0) - { - home_path(c); - return; - } - *d=0; - d=strrchr(c,'\\'); - } - strcat(c,"\\"); - home_path(c); - } - - -void static show_space(char device) - { - char buff[100]; - static long lastvalue; - static char lastdevice; - - device=toupper(device); - if (device>='A' && device<='Z') - { - if (device!=lastdevice) lastvalue=get_disk_free(device-'@')/1024; - sprintf(buff,"On device %c: is %d Kb free",device,lastvalue); - lastdevice=device; - set_value(0,80,buff); - } - } - -static open_load_window() - { - char c; - get_value(0,60,target_path); - trace_chdir(target_path); - getcwd(target_path,2047); - load_window(); - escape(); - home_path(source_path); - c=o_aktual->id==150; - if (c) - { - get_value(0,10,target_path); - } - close_current(); - if (c) - set_value(0,60,target_path); - else - get_value(0,60,target_path); - show_space(target_path[0]); - } - -static char create_ini(char *path,char *name) - { - - if (inifile!=NULL) - { - fclose(ini); - remove(inifile); - free(inifile); - } - inifile=NewArr(char,strlen(path)+strlen(name)+2); - sprintf(inifile,"%s\\%s",path,name); - ini=fopen(inifile,"w"); - if (ini==NULL) return 1; - add_to_list(inifile); - fprintf(ini,"vmode %d\n", vmode); - fprintf(ini,"sound_device %d %x %d %d\n",sound_info.device,sound_info.port,sound_info.dma,sound_info.irq); - fprintf(ini,"sound_mixfreq 22049\n"); - fprintf(ini,"default_map lespred.map\n"); - fprintf(ini,"preload 1\n"); - fprintf(ini,"game_speed 5\n"); - if (subtitles) fprintf(ini,"titles 1\n"); - return 0; - } - /* -static char create_setup_batch(char *path,char *name) - { - char *st; - FILE *batch; - - st=alloca(strlen(path)+strlen(name)+2); - sprintf(st,"%s\\%s",path,name); - batch=fopen(st,"w"); - if (batch==NULL) return 1; - fputs( - "@Echo off\n" - ":skok\n" - "Echo Vloz CD \"Brany Skeldalu\" do mechaniky\n" - "Echo a stiskni jakoukoliv klavesu. \n" - "Echo.\n" - "Echo Kombinace CNTR+C prerusi program....\n" - "Pause > NUL\n",batch); - fprintf(batch,"if not exist %s goto skok\n",pgm_name); - fprintf(batch,"%s -s \n",pgm_name); - fclose(batch); - return 0; - } - */ -static void close_ini() - { - if (ini!=NULL) fclose(ini); - } - -static void copy_self(char alloc) - { - static char *t; - - if (alloc) - { - t=NewArr(char,strlen(target_path)+strlen(SETUP_NAME)+2); - sprintf(t,"%s\\%s",target_path,SETUP_NAME); - cpy_file(pgm_name,t); - } - else free(t); - } - -static long self_size() - { - struct find_t f; - - _dos_findfirst(pgm_name,_A_NORMAL,&f); - return f.size; - } - -static void start_install() - { - long diskfree; - char error=0,autostart; - get_value(0,60,target_path); - if (find_object(waktual,70)!=NULL) autostart=f_get_value(0,70); else autostart=1; - strupper(target_path); - if (validate_path(target_path)==0) - { - msg_box("Incorrect path",'\x1',"The path is incorrect. Don't use long filenames!","OK",NULL); - return; - } - get_script(_SOURCE_,target_path); - switch (o_aktual->id) - { - case 10:install_type=INST_MIN;break; - case 20:install_type=INST_MED;break; - case 30:install_type=INST_MAX;break; - } - maxcopy=install_sizes[install_type]; - diskfree=get_disk_free(target_path[0]-'@'); - if (maxcopy>diskfree) - { - if (msg_box("Low disk space!",'\x1', - "Install found that selected device is running out of free space. But if " - "you using disk-compressor, such as DRVSPACE, the free space may be" - "incorrectly calculated. Continue in installation?" - ,"Yes","No",NULL)==2) return; - } - else if (maxcopy+1024*1024>diskfree) - { - if (msg_box("Low disk space!",'\x2',"Out of space on target device. Needing 1MB for temporary files. Continue?","Yes","No",NULL)==2) return; - } - maxcopy=maxcopy<<1; - while (waktual!=NULL) close_current(); - cascade_mkdir(target_path); - if (create_ini(target_path,SKELDAL_INI)) - { - msg_box(PRG_HEADER,'\x1',"Cannot create configuration file. Check target path.","Ok",NULL); - clean_up(); - return; - } -// create_setup_batch(target_path,SETUP_BATCH); - display_progress(); - stop_sound(); - switch (install_type) - { - case INST_MIN:if (do_script(0) || do_script(-1) || do_script(-2) || do_script(-3)) error=1;break; - case INST_MED:if (do_script(0) || do_script(1) || do_script(-2) || do_script(-3)) error=1;break; - case INST_MAX:if (do_script(0) || do_script(1) || do_script(2) || do_script(3)) error=1; - break; - } - copy_self(1); - cpy_flush(); - copy_self(0); - close_ini(); - if (error) shutdown(),exit(1); - close_current(); - do_events(); - if (!autostart) msg_box("Done",' ',"The Game has been succesfully installed.","Ok",NULL); - purge_file_list(); - shutdown(); - home_path(target_path); - if (autostart) - { - puts("Please wait..."); - exit(254); - } - else exit(0); - } - -static EVENT_PROC (show_space_event) - { - OBJREC *o; - - o=(OBJREC *)user_ptr; - if (msg->msg==E_KEYBOARD || msg->msg==E_CURSOR_TICK) - { - char *c; - - c=o->data; - if (c[1]==':') - show_space(c[0]); - if (msg->msg==E_KEYBOARD) - *(char *)msg->data=toupper(*(char *)msg->data); - } - } - -static show_space_exit() - { - EVENT_MSG msg; - - msg.msg=E_KEYBOARD; - show_space_event(&msg,(void **)o_aktual); - } - - - -static void rozsah_window() - { - char buff[100]; - char *text="Need on HD: %d KB"; - - exit_wait=0; - default_font=&font6x9; - def_dialoge(146,160,348,264,"Installation ragne:",2); - define(10,10,30,70,30,0,button,"Minimum");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(start_install); - define(-1,90,30,1,1,0,label,"It will copy all important files"); - define(-1,90,40,1,1,0,label,"Data are loaded from CD"); - sprintf(buff,text,install_sizes[0]/1024); - define(-1,90,50,1,1,0,label,buff); - define(20,10,80,70,30,0,button,"Normal");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(start_install); - define(-1,90,80,1,1,0,label,"It will copy all important files and data"); - define(-1,90,90,1,1,0,label,"Music and video are loaded from CD"); - sprintf(buff,text,install_sizes[1]/1024); - define(-1,90,100,1,1,0,label,buff); - define(30,10,130,70,30,0,button,"Full");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(start_install); - define(-1,90,130,1,1,0,label,"It will copy all files."); - define(-1,90,140,1,1,0,label,"You will not need CD anymore."); - sprintf(buff,text,install_sizes[2]/1024); - define(-1,90,150,1,1,0,label,buff); - define(40,10,180,70,20,0,button,"Browse");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(open_load_window); - define(60,90,185,250,11,0,input_line,2048);property(def_border(1,0x4210),&font6x9,NULL,0x7fff); - set_default(target_path); - on_event(show_space_event);on_exit(show_space_exit); - define(-1,90,173,1,1,0,label,"Target directory:"); - define(70,40,220,200,10,0,check_box,"After installation, run the game automatically.");c_default(1); - define(80,10,10,250,11,2,view_line,100);set_default(""); - show_space(target_path[0]); - } - -static void automatic_window() - { - char buff[100]; - char *text="Game need %d KB free space"; - - exit_wait=0; - default_font=&font6x9; - def_dialoge(110,200,420,80,"Target directory:",2); - define(40,10,33,70,15,0,button,"Browse");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(open_load_window); - define(60,90,35,310,11,0,input_line,2048);property(def_border(1,0x4210),&font6x9,NULL,0x7fff); - set_default(target_path); - on_event(show_space_event);on_exit(show_space_exit); - define(10,10,10,70,20,2,button,"Start");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(start_install); - define(20,90,10,70,20,2,button,"<< Back");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(back_start); - sprintf(buff,text,install_sizes[0]/1024); - define(90,180,20,200,10,2,view_line,100);set_default(buff); - define(80,180,10,200,10,2,view_line,100);set_default(""); - show_space(target_path[0]); - redraw_window(); - } - - - -static void control_next1() - { - sound_scan(); - while (waktual!=NULL) close_current(); - rozsah_window(); - control_window(NULL,control_back1,open_help); - } - -static void control_window(void *forward,void *back,void *help) - { - def_dialoge(524,300,96,156,"Options",2); - define(10,8,30,80,20,0,button,"Next >>");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(forward); - define(20,8,60,80,20,0,button,"<< Back");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(back); - define(30,8,90,80,20,0,button,"? Help");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(help); - define(40,8,10,80,20,3,button,"Quit");property(bbutt,&font6x9,NULL,BUTTONCOLOR); - if (setup_mode) on_control_change(stop_setup);else on_control_change(stop_copy); - set_enable(0,10,forward!=NULL); - set_enable(0,20,back!=NULL); - set_enable(0,30,help!=NULL); - redraw_window(); - } - -static void run_setup() - { - int id; - - while (waktual!=NULL) close_current(); - get_script(_SOURCE_,""); - { - int minus[3]; - minus[1]=check_size(-2)+check_size(-3); - minus[0]=minus[1]+check_size(-1); - install_sizes[0]=check_size(0)+self_size(); - install_sizes[1]=install_sizes[0]+check_size(1); - install_sizes[2]=install_sizes[1]+check_size(2)+check_size(3); - install_sizes[0]+=minus[0]; - install_sizes[1]+=minus[1]; - id; - } - if (all_finder()) - { - char *c; - getcwd(&target_path,2047); - c=strchr(target_path,0); - c--; - if (*c=='\\') *c=0; - strcat(target_path,"\\"SKELDAL); - } - else - { - target_path[0]=select_disk()+'@'; - target_path[1]=':'; - target_path[2]='\\'; - strcpy(target_path+3,SKELDAL); - } - do - { - home_path(source_path); - back=0; - select_mode_win(); - about_window(); - id=o_aktual->id; - close_current(); - close_current(); - exit_wait=0; - if (id==10) - { - autodetect(); - automatic_window(); - } - if (id==30) - { - if (msg_box("Autodetection",'\x1',"Do you want to start autodetection?","Yes","No",NULL)==1) autodetect(); - select_vga(); - select_sound(); - control_window(control_next1,back_start,open_help); - } - if (id!=40) escape(); - } - while (back); - } - -static void save_ini() - { - char c[50]; - char d; - char err=1; - - if (sound_scan()) return; - d=msg_box("Quit",'\x2',"Do you wish to save all changes in configuration?","Yes","No","Cancel",NULL); - if (d==3) return; - if (d==1) - { - sprintf(c,"%d %x %d %d",sound_info.device, - sound_info.port, - sound_info.dma, - sound_info.irq); - add_field_txt(&setup_ini,SOUND_DEVICE,c); - add_field_num(&setup_ini,VMODE,vmode); - add_field_num(&setup_ini,"TITLES",subtitles); - home_path(target_path); - err=save_config(setup_ini,SKELDAL_INI); - } - shutdown(); - home_path(target_path); - switch (err) - { - case -1:puts("An error occured while saving changes. File "SKELDAL_INI" hasn't been changed");break; - case 0:puts("Changes has been saved..."); break; - case 1:puts("Changes has been discarded..."); break; - } - exit(0); - } - -static void deinstall() - { - char ig; - int x,y; - def_dialoge(200,200,250,156,"Uninstall?",2); - define(-1,10,30,200,100,0,label,"This will unistall the game."); - define(-1,10,40,200,100,0,label,"After it, you won't be able to play"); - define(-1,10,50,200,100,0,label,"the game until you install it again."); - define(10,30,80,150,10,0,check_box,"Don't erase saved positions");c_default(1); - define(20,10,10,80,30,3,button,"Yes, do it!");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(terminate_gui); - define(30,10,10,80,30,2,button,"No, newer!");property(bbutt,&font6x9,NULL,BUTTONCOLOR);on_control_change(terminate_gui); - redraw_window(); - escape(); - if (o_aktual->id==30) - { - close_current(); - return; - } - ig=f_get_value(0,10); - set_enable(0,30,0); - set_enable(0,20,0); - set_enable(0,10,0); - do_events(); - home_path(target_path); - cascade_delete(ig); - chdir(".."); - rmdir(target_path); - home_path(source_path); - curcolor=0; - for(x=319;x>-1;x-=2) - { - y=x*240/320;bar(x,y,639-x,479-y);showview(0,0,0,0); - } - shutdown(); - exit(0); - } - -static void run_resetup() - { - int id; - - while (waktual!=NULL) close_current(); - do - { - home_path(source_path); - back=0; - select_mode_win_setup(); - about_window(); - id=o_aktual->id; - close_current(); - close_current(); - exit_wait=0; - if (id==30) - { - deinstall(); - back=1; - } - if (id==10) - { - select_vga(); - select_sound(); - control_window(save_ini,back_start,NULL); - } - if (id!=40) escape(); - } - while (back); - } - - -#define REPEAT(i,cnt) for(i=0;i=2 && argv[1][0]=='-' && toupper(argv[1][1])=='S') || access(SKELDAL_INI,F_OK)==0) - { - int i; - char *c; - char *d; - setup_mode=1; - getcwd(target_path,PATH_MAX+1); - setup_ini=read_config(SKELDAL_INI); - if (setup_ini==NULL) - { - printf("The file %s has not been found. You must reinstall the game\n" - "Insert the CD into driver and run INSTALL.EXE\n",SKELDAL_INI); - printf("Nemohu najit soubor %s. Budes muset hru znovu nainstalovat\n" - "Z CD \"Brany Skeldalu\" spust program INSTALL.EXE\n",SKELDAL_INI); - exit(0); - } - get_num_field(setup_ini,VMODE,&vmode); - c=get_text_field(setup_ini,"CESTA_CD"); - program_data_path=NewArr(char,strlen(c)+1);strcpy(program_data_path,c); - c=strchr(program_data_path,0); - if (c>program_data_path && c[-1]=='\n') c[-1]=0,c--; - if (c>program_data_path && c[-1]=='\\') c[-1]=0; - c=get_text_field(setup_ini,SOUND_DEVICE); - sscanf(c,"%d %x %d %d",&sound_info.device, - &sound_info.port, - &sound_info.dma, - &sound_info.irq); - c=alloca(strlen(argv[0])+1); - strcpy(c,argv[0]); - i=subtitles; - get_num_field(setup_ini,"TITLES",&i); - subtitles=i; - d=strrchr(c,'\\'); - if (d!=NULL) - { - d[d-c<=2]=0; - home_path(c); - } - } - } - -main(int argc,char **argv) - { - char s; - char *c; - - pgm_name=argv[0]; - check_setup_mode(argc,argv); - if (argc==2 && !setup_mode) copy_source_path=argv[1];else copy_source_path=NULL; - if (!setup_mode) - { - _setvideomode(_TEXTC80); - rescue_mode=!(s=create_er_file()); - if (s && !setup_mode) warning(),getche(); - } - else - s=0; - init_setup(s); - create_video_ls(); - set_mixing_device(0,22050,0,0,0); - c=test_sound_name=NewArr(char, strlen(program_data_path)+strlen(TEST_MUSIC)+1); - sprintf(c,"%s%s",program_data_path,TEST_MUSIC); - if (access(c,F_OK)!=0) - { - shutdown(); - printf("Vloz CD \"Brany Skeldalu\" do jednotky CD-ROM a spust znova instalaci\n" - "Insert CD \"The Gates of the Skeldal\" into CD-ROM and try to run INSTALL again.\n"); - abort(); - } - konec_skladby=skladba_konec; - change_music(c); - mix_back_sound(2); - if (setup_mode) run_resetup(); - else - { - if (!rescue_mode) run_setup(); - if (rescue_mode) - { - ask_video(); - escape(); - } - } - shutdown(); - } diff --git a/insteng/SETUP.H b/insteng/SETUP.H deleted file mode 100644 index 9d3f7f0..0000000 --- a/insteng/SETUP.H +++ /dev/null @@ -1,18 +0,0 @@ -extern word ikones; -extern word boldcz; -extern word sipka; -extern word font6x9; -extern void *bbutt; -extern word *vga_font; -extern word *icones; -extern word icone_color[]; -extern word ramecek; -extern word *ramecky[]; - -//#define WINCOLOR 0x6318 -#define WINCOLOR (31*1024+31*32+26) -#define LABELCOLOR (11*1024+11*32+06) -#define BUTTONCOLOR (28*1024+24*32+3) - -#define PRG_HEADER "The Gates of Skeldal Setup v1."VERSION -extern FILE *ini; diff --git a/insteng/SETUPCPY.C b/insteng/SETUPCPY.C deleted file mode 100644 index 993be65..0000000 --- a/insteng/SETUPCPY.C +++ /dev/null @@ -1,165 +0,0 @@ -#include -#include -#include -#include -#include "setupcpy.h" - -#define DATASIZE 32768 -#define INFOBLOCK 1 -#define DATABLOCK 2 -#define ERRORBLOCK 3 - -typedef struct tdatablock - { - void *next; - char block_type; - unsigned short load_size; - char data[DATASIZE]; - }TDATABLOCK; - -typedef struct tinfoblock - { - void *next; - char block_type; - char pathname[2]; - }TINFOBLOCK; - -static void *start=NULL; -static void *end=NULL; -static FILE *cpyout=NULL; -static long progress=0; - -void (*cpy_error)(int,char *); -void (*mem_error_next)(long); - -void (*cpy_progress)(long); - - -static void *alloc_file(char *target_name) - { - TINFOBLOCK *p; - - p=(TINFOBLOCK *)getmem(sizeof(TINFOBLOCK)+strlen(target_name)); - strcpy(p->pathname,target_name); - p->next=NULL; - p->block_type=INFOBLOCK; - return p; - } - -static void *alloc_data() - { - TDATABLOCK *p; - - p=New(TDATABLOCK); - p->next=NULL; - p->load_size=0; - p->block_type=DATABLOCK; - return p; - } - - -static void *load_data(FILE *f) - { - TDATABLOCK *p; - int rc; - int retry=0; - void *end_line; - - p=end_line=alloc_data(); - again: - errno=0; - rc=fread(p->data,1,sizeof(p->data),f); - p->load_size=rc; - if (ferror(f) || rc!=sizeof(p->data) && errno!=0) - { - if (retry) retry--; - else cpy_error(CPERR_READ,NULL); - fseek(f,-rc,SEEK_CUR); - errno=0; - goto again; - } - progress+=p->load_size; - cpy_progress(progress); - return end_line; - } - -static error_mem(long size) - { - TDATABLOCK *p; - TINFOBLOCK *q; - int rc; - - size; - if (start==NULL) mem_error_next(size); - while (start!=NULL) - { - p=start; - q=start; - if (q->block_type==INFOBLOCK) - { - if (cpyout!=NULL) fclose(cpyout); - again: - cpyout=fopen(q->pathname,"wb"); - if (cpyout==NULL) - { - cpy_error(CPERR_OPEN,q->pathname); - goto again; - } - start=q->next; - free(q); - } - else if (p->block_type==DATABLOCK) - { - again2: - rc=fwrite(p->data,1,p->load_size,cpyout); - if (rc!=p->load_size) - { - cpy_error(CPERR_WRITE,q->pathname); - fseek(cpyout,-rc,SEEK_CUR); - goto again2; - } - progress+=p->load_size; - cpy_progress(progress); - start=p->next; - free(p); - } - } - end=NULL; - } - -void cpy_file(char *source,char *target) - { - FILE *f; - TDATABLOCK *p; - TINFOBLOCK *q; - - again: - errno=0; - f=fopen(source,"rb"); - if (f==NULL) - { - cpy_error(CPERR_OPEN,source); - goto again; - } - q=alloc_file(target); - if (start==NULL) start=end=q;else end=(((TDATABLOCK *)end)->next=q); - while (!feof(f)) - { - p=load_data(f); - if (start==NULL) start=end=p;else end=(((TDATABLOCK *)end)->next=p); - } - fclose(f); - } - -void cpy_flush() - { - if (start!=NULL)error_mem(0); - if (cpyout!=NULL)fclose(cpyout); - cpyout=NULL; - } - -void install_cpy() - { - mem_error_next=mem_error; - mem_error=error_mem; - } diff --git a/insteng/SETUPCPY.H b/insteng/SETUPCPY.H deleted file mode 100644 index e46a382..0000000 --- a/insteng/SETUPCPY.H +++ /dev/null @@ -1,9 +0,0 @@ -#define CPERR_OPEN 1 -#define CPERR_WRITE 2 -#define CPERR_READ 3 - -extern void (*cpy_error)(int,char *); -extern void (*cpy_progress)(long); -void cpy_file(char *source,char *target); -void cpy_flush(); -void install_cpy(); diff --git a/insteng/SETUPLIB.C b/insteng/SETUPLIB.C deleted file mode 100644 index d53d4f6..0000000 --- a/insteng/SETUPLIB.C +++ /dev/null @@ -1,505 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "setuplib.h" -#include "setupcpy.h" -#include "setup.h" - -#define COPY "COPY" -#define MKDIR "MKDIR" -#define INI "INI" - -#define DIR_NAMES 6 -char *dirnames[]= - { - "GAMES.*", - "GAME*.*", - "HRY.*", - "ZABAVA.*", - "SKELDAL", - "NAPOLEON", - }; - -TSTR_LIST file_list=NULL; - -static void done_bar_init(OBJREC *o,long *params) - { - o->userptr=New(long); - *(long *)o->userptr=*params; - } - -static void done_bar_draw(int x1,int y1,int x2,int y2,OBJREC *o) - { - long value,max,x3; - - value=*(long *)o->data; - max=*(long *)o->userptr; - x3=x1+(x2-x1)*value/max; - if (x3<=x1) x3=x1; - if (x3>=x2) x3=x2; - bar(x3,y1,x2,y2); - curcolor=o->f_color[1]; - bar(x1,y1,x3,y2); - } - -void done_bar(OBJREC *o) //define(...done_bar,max); - { - o->call_init=done_bar_init; - o->call_draw=done_bar_draw; - o->datasize=4; - } - - - -char select_disk() - { - char last=3; - struct diskfree_t ds; - int max=0,i; - long now; - - for(i=('C'-'@');i<('Z'-'@');i++) - { - if (_dos_getdiskfree(i,&ds)==0) - { - now=ds.avail_clusters*ds.sectors_per_cluster*ds.bytes_per_sector; - if (now>max) - { - max=now; - last=i; - } - } - } - return last; - } - -char dir_finder() - { - struct find_t ft; - int i; - int rc; - - for(i=0;imax && sz[j]datasize=(*len)+1; - } - -static void view_line_draw(int x1,int y1, int x2, int y2, OBJREC *o) - { - char *c; - - bar(x1,y1,x2,y2); - c=(char *)o->data; - if (!*c) return; - set_aligned_position(x2,y1,2,0,c); - outtext(c); - } - - -void view_line(OBJREC *o) - { - o->call_init=view_line_init; - o->call_draw=view_line_draw; - } - - -char get_max_res() - { - if (vesasupport(0x110)) return 2; - if (vesasupport(0x100)) return 1; - return 0; - } - -void add_to_list(char *name) - { - if (file_list==NULL) file_list=create_list(256); - str_add(&file_list,name); - } - -static void copy_1_file(char *init_mask,char *filename,char *target) - { - char *c,*d; - - c=alloca(strlen(init_mask)+strlen(filename)+1); - strcpy(c,init_mask); - d=strrchr(c,'\\'); - d++; - strcpy(d,filename); - d=alloca(strlen(target)+strlen(filename)+10); - strcpy(d,target); - if (d[0]==0 || d[strlen(d)-1]!='\\') strcat(d,"\\"); - strcat(d,filename); - set_value(0,20,filename); - add_to_list(d); - cpy_file(c,d); - } - -static void copy_files(char *param) - { - struct find_t ft; - char *source_mask; - char *target; - int rc; - - target=strchr(param,' '); - if (target==NULL) return; - source_mask=alloca(target-param); - source_mask[target-param]=0; - strncpy(source_mask,param,target-param); - target++; - rc=_dos_findfirst(source_mask,_A_NORMAL,&ft); - while (rc==0) - { - copy_1_file(source_mask,ft.name,target); - rc=_dos_findnext(&ft); - } - _dos_findclose(&ft); - } - -char cascade_mkdir(char *path) - { - char *c; - char d; - - if (path[0]==0||path[1]==':' && path[2]==0) return 0; - if (!access(path,F_OK)) return 0; - c=strrchr(path,'\\'); - if (c==NULL) return 0; - *c=0; - d=cascade_mkdir(path); - *c='\\'; - if (d==1) return 1; - if (mkdir(path)!=0) return 1; - add_to_list(path); - return 0; - } - - -static char add_to_ini(char *params) - { - return fprintf(ini,"%s\n",params)<0; - } - -static char *commands[]= - { - COPY, - MKDIR, - INI, - }; - -static char (*calls[])(char *params)= - { - copy_files, - cascade_mkdir, - add_to_ini, - }; - - - -static char command_match(char *cmd,char *test,char **params) - { - while (*test) if (toupper(*cmd++)!=toupper(*test++)) return 0; - if (*cmd!=' ') return 0; - *params=cmd+1; - return 1; - } - - -char do_script(int section) - { - int pos; - int num; - int str_siz=str_count(script); - char *command; - - for(pos=0;pos"); - } - return s; - } - -char validate_path(char *path) - { - unsigned disk; - unsigned cdisk,lastdrv; - char *c,ll=0,tt=0,d; - - static char valid[]="$%'_@{}~`#()&-"; - - if (path==NULL || path[0]==0 || path[1]!=':' || path[2]!='\\') return 0; - disk=toupper(path[0]); - if (disk<'A' || disk>'Z') return 0; - _dos_getdrive(&cdisk); - disk-='@';_dos_setdrive(disk,&lastdrv); - _dos_getdrive(&lastdrv); - disk=(disk==lastdrv); - _dos_setdrive(cdisk,&lastdrv); - if (!disk) return 0; - c=path+2;ll=0; - while (*c) - { - d=toupper(*c); - if (d=='\\') - if (ll) return 0;else ll=1,tt=0; - else - if (d>='A' && d<='Z' || d>='0' && d<='9' || strchr(valid,d)!=NULL || d>127) ll=0; - else if (d=='.') if (tt) return 0;else tt=1; - else return 0; - c++; - } - if (ll) return 0; - return 1; - } - -void clean_up() - { - int i,cnt; - if (file_list==NULL) return; - cnt=str_count(file_list); - for(i=cnt-1;i>=0;i--) if (file_list[i]!=NULL) - { - if (remove(file_list[i])) rmdir(file_list[i]); - } - release_list(file_list); - file_list=NULL; - } - -void purge_file_list() - { - if (file_list==NULL) return; - release_list(file_list); - file_list=NULL; - } - -char cascade_delete(char ignore_sav) - { - struct find_t f; - int rc; - - rc=_dos_findfirst("*.*",_A_SUBDIR,&f); - while (rc==0) - { - if (f.attrib & _A_SUBDIR) - { - if (f.name[0]!='.') - { - chdir(f.name); - cascade_delete(ignore_sav); - chdir(".."); - rmdir(f.name); - } - } - else - { - char *c=strchr(f.name,'.'); - - if (c!=NULL) - { - strupper(c); - if (!ignore_sav || strncmp(c,".SAV",4)) remove(f.name); - } - else remove(f.name); - } - rc=_dos_findnext(&f); - } - return 0; - } diff --git a/insteng/SETUPLIB.H b/insteng/SETUPLIB.H deleted file mode 100644 index 7928d30..0000000 --- a/insteng/SETUPLIB.H +++ /dev/null @@ -1,22 +0,0 @@ -char all_finder(); -char select_disk(); -char read_script(char *filename,char *source_path,char *target_path); -long check_size(int gr); -long get_disk_free(char disk); -void view_line(OBJREC *o); -char *get_cdrom(); -char get_max_res(); -char do_script(int); -void done_bar(); //define(...done_bar,max); -char cascade_mkdir(char *path); -char validate_path(char *path); -char cascade_delete(char ignore_sav); //maze soubory a podadresare. Pripadne ignoruje soubory SAV - -void clean_up(); //maze zkopirovane soubory a adresare -void purge_file_list(); -void add_to_list(char *name); - - -#define INST_MIN 0 -#define INST_MED 1 -#define INST_MAX 2 diff --git a/insteng/SETVIDEO.C b/insteng/SETVIDEO.C deleted file mode 100644 index f04bf9c..0000000 --- a/insteng/SETVIDEO.C +++ /dev/null @@ -1,210 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "setup.h" - -static void *xlat256=NULL; -static void *xlat16=NULL; -static void *xlat64=NULL; - -static void create_xlats() - { - if (xlat256==NULL) xlat256=create_special_palette(); - if (xlat16==NULL) xlat16=create_blw_palette16(); - if (xlat64==NULL) xlat64=create_hixlat(); - } - - -static void initgr_common() - { - register_ms_cursor(&sipka); - if (init_mysky()!=0) - { - closemode(); - puts("Neni mys!\nMouse not found!"); - exit(0); - } -// hranice_mysky(0,0,639,479); - update_mysky(); - schovej_mysku(); - bar(0,0,639,479); - showview(0,0,0,0); - } - -int initgr_auto() - { - int vmode; - create_xlats(); - vmode=2; - if (initmode32()) - { - vmode=5; - if (initmode64(xlat64)) - { - vmode=1; - if (initmode256(xlat256)) - { - vmode=0; - initmode16(xlat16); - } - } - } - initgr_common(); - return vmode; - } - -int initgr_spec(int vmode) - { - int i=-1; - create_xlats(); - switch (vmode) - { - case 0:i=initmode_lo(xlat256);break; - case 1:i=initmode256(xlat256);break; - case 2:i=initmode32();break; - case 5:i=initmode64(xlat64);break; - } - if (!i) initgr_common(); - return i; - } - -void initgr_low() - { - create_xlats(); - initmode16(xlat16); - initgr_common(); - } - -void donegr() - { - closemode(); - done_mysky(); - } - -void kresli_okno(WINDOW *w) - { - int x,y; - int xs,ys,xsr,ysr; - int x1,y1,xs1,ys1; - int i,j; - - xsr=ramecky[0][0]; - ysr=ramecky[0][1]; - x1=w->x-12; - y1=w->y-12; - xs1=w->xs+24; - ys1=w->ys+24; - xs=xs1/xsr; - ys=ys1/ysr; - curcolor=w->color; - bar(w->x,w->y,w->x+w->xs,w->y+w->ys); - for(j=0,y=y1;jx; - y=waktual->y; - } - name; - highlight(&ctl,WINCOLOR); - ctl.bsize=2;ctl.ctldef=0; - x+=20;y+=20; - memcpy(fc,flat_color(0x7fe0),sizeof(FC_TABLE)); - fc[0]=0x0000; - if (x+xs>MAX_X-2) x=MAX_X-2-xs; - if (y+ys>MAX_Y-2) y=MAX_Y-2-ys; - p=create_window(x,y,xs,ys,WINCOLOR,&ctl); - q=desktop_add_window(p); - define(0,2,2,xs-5-20*(xs>=70),14,0,win_label,name); - ctl.bsize=1;ctl.ctldef=1; - o_end->autoresizex=1; - property(&ctl,vga_font,&fc,LABELCOLOR); - if (xs>=70) - { - define(1,1,1,19,16,1,button,"\x0f"); - property(NULL,icones,&icone_color,WINCOLOR);on_control_change(close_current); - } - return q; - } - -int def_dialoge(word x,word y,word xs, word ys, char *name,char modal) - { - CTL3D ctl; - FC_TABLE fc; - WINDOW *p; - int i; - - memcpy(fc,flat_color(0x7fe0),sizeof(FC_TABLE)); - if (modal & 0x2) - { - ctl.bsize=12; - xs=((xs+6)/12)*12; - ys=((ys+6)/12)*12; - } - else - memcpy(&ctl,def_border(2,WINCOLOR),sizeof(CTL3D)); - p=create_window(x,y,xs,ys,WINCOLOR,&ctl); - i=desktop_add_window(p); - if (modal & 1) set_window_modal(); - memcpy(&ctl,def_border(5,WINCOLOR),sizeof(CTL3D)); - if (name!=NULL) - { - define(0,2,2,xs-4,14,0,win_label,name); - o_end->autoresizex=1; - property(&ctl,vga_font,&fc,LABELCOLOR); - } - if (modal & 0x2) p->draw_event=kresli_okno; - return i; - } - -void def_listbox(int id,word x,word y,word xs,word ys,TSTR_LIST ls,int ofs,int color) - { - CTL3D b1,b2; - word black[]={0,0,0,0,0,0}; - - memcpy(&b1,def_border(1,0),sizeof(CTL3D)); - memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D)); - define(id+1,x+xs+4,y+18,15,ys-35,0,scroll_bar_v,0,10,1,0x0200); - property(&b2,NULL,NULL,WINCOLOR); - define(id+2,x+xs+4,y,14,14,0,scroll_button,-1,0,"\x4"); - property(&b1,icones,black,WINCOLOR);on_control_change(scroll_support); - define(id+3,x+xs+4,y+ys-14,14,14,0,scroll_button,1,10,"\6"); - property(&b1,icones,black,WINCOLOR);on_control_change(scroll_support); - define(id,x,y,xs,ys,0,listbox,ls,color,ofs); - property(&b2,NULL,NULL,WINCOLOR); - } - diff --git a/insteng/SETVIDEO.H b/insteng/SETVIDEO.H deleted file mode 100644 index dce03e5..0000000 --- a/insteng/SETVIDEO.H +++ /dev/null @@ -1,6 +0,0 @@ -int initgr_auto(); -void initgr_low(); -int initgr_spec(int vmode); -void donegr(); -int def_dialoge(word x,word y,word xs, word ys, char *name,char modal); -void def_listbox(int id,word x,word y,word xs,word ys,TSTR_LIST ls,int ofs,int color); diff --git a/insteng/STUB.C b/insteng/STUB.C deleted file mode 100644 index c059d9b..0000000 --- a/insteng/STUB.C +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include -#include -#include -#include -#define QUIET x - -/* Add environment strings to be searched here */ -char *paths_to_check[] = { - "DOS4GPATH", - "PATH"}; - -char *dos4g_path() -{ - static char fullpath[80]; - int i; - - for( i = 0; - i < sizeof( paths_to_check ) / sizeof( paths_to_check[0] ); i++ ) { - _searchenv( "dos4gw.exe", paths_to_check[i], fullpath ); - if( fullpath[0] ) return( &fullpath ); - } - for( i = 0; - i < sizeof( paths_to_check ) / sizeof( paths_to_check[0] ); i++ ) { - _searchenv( "dos4g.exe", paths_to_check[i], fullpath ); - if( fullpath[0] ) return( &fullpath ); - } - return( "dos4gw.exe" ); -} - -main( int argc, char *argv[] ) -{ - char *av[4]; - auto char cmdline[128]; - int i; - av[0] = dos4g_path(); /* Locate the DOS/4G loader */ - av[1] = argv[0]; /* name of executable to run */ - av[2] = getcmd( cmdline ); /* command line */ - av[3] = NULL; /* end of list */ -#ifdef QUIET - putenv( "DOS4G=QUIET" ); /* disables DOS/4G Copyright banner */ -#endif - printf("Instalator Br ny Skeldalu (C)1997 Napoleon gameS Nahr v m... \n"); - i=spawnvp(P_WAIT, av[0], av ); - if (i==254) - execl(av[0],av[0],"SKELDAL.EXE",NULL);else exit(0); - puts( "Chyba pri nacitani extenderu:" ); - puts( av[0] ); - puts( "\nZkontrolujte zda-li je k dosazeni na aktualnim adresari\n" - "popripade specifikujte jeho v cestu v systemove promenne:\n" - "SET DOS4GPATH=disk:\\cesta\n"); - exit( 1 ); /* indicate error */ -} diff --git a/insteng/TEXTLIB.ASM b/insteng/TEXTLIB.ASM deleted file mode 100644 index 3ec6511..0000000 --- a/insteng/TEXTLIB.ASM +++ /dev/null @@ -1,101 +0,0 @@ -.model small -.386 - -SEGB800 equ 0b8000h - -_TEXT segment byte public 'CODE' use32 - assume CS:_TEXT - assume DS:DGROUP - -public load_font_ -load_font_: ;esi font - mov esi,offset fonttable - mov edx,3c4h - mov eax,0402h - out dx,ax - mov eax,0704h - out dx,ax - Mov edx,3ceh - mov eax,0204h - out dx,ax - mov eax,0005h - out dx,ax - mov eax,0406h - out dx,ax - mov edi,0xA0000h - mov edx,256 -lfOpk: mov ecx,16 - rep movsb - add edi,16 - dec edx - jne lfopk - mov edx,3c4h - mov eax,0302h - out dx,ax - mov eax,0304h - out dx,ax - Mov edx,3ceh - mov eax,0004h - out dx,ax - mov eax,1005h - out dx,ax - mov eax,0E06h - out dx,ax - ret - -public set_font_8x8_ -set_font_8x8_: - cli - mov edx,3d4h - mov eax,0100h - out dx,ax - mov edx,3c4h - mov al,1 - out dx,al - inc edx - in al,dx - or al,1 - out dx,al - mov edx,03dah - in al,dx - mov edx,03c0h - mov al,13h - out dx,al - mov al,0 - out dx,ax - mov al,32 - out dx,al - mov edx,3d4h - mov eax,0300h - out dx,ax - sti - ret - -public turn_flashing_ ;ebx - ON/OFF -turn_flashing_: - mov eax,1003h - int 10h - ret - - -public get_window_size_ ;eax,edx-velikost -get_window_size_: - imul eax,edx - shl eax,1 - add eax,4 - ret - -public save_window_ ;eax,edx-pozice - ;ecx,ebx-velikost - ;edi - buffer -save_window_ - stosb - imul eax,160 - lea eax,[eax+edx*2] - lea esi,[eax+SEGB800] - mov al,dl - stosb - mov al,bl - mov ah,cl - stosw - mov edx,ebx diff --git a/insteng/TEXTLIB.C b/insteng/TEXTLIB.C deleted file mode 100644 index fd40910..0000000 --- a/insteng/TEXTLIB.C +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/libs/basicobj.c b/libs/basicobj.c index 26697b8..a9894be 100644 --- a/libs/basicobj.c +++ b/libs/basicobj.c @@ -243,7 +243,7 @@ void draw_status_line(char *c) void status_mem_info(EVENT_MSG *msg) { - + } void status_idle(EVENT_MSG *msg) @@ -530,6 +530,7 @@ void radio_butts_init(OBJREC *o,va_list params) q=(int32_t *)getmem(cnt+8); o->userptr=(void *)q; *q++=1;*q++=rcount; + z = (char *)q; va_copy(d, params); va_arg(d, int); for (i=0;i(input); - auto in_end = std::istream_iterator(); + auto in_iter = std::istreambuf_iterator(input); + auto in_end = std::istreambuf_iterator(); auto out_iter = std::ostream_iterator(std::cout); base64.encode(in_iter, in_end, out_iter); return 0; -} \ No newline at end of file +} diff --git a/libs/gui.c b/libs/gui.c index 552d88e..a390500 100644 --- a/libs/gui.c +++ b/libs/gui.c @@ -247,7 +247,7 @@ void absolute_window(WINDOW *w,OBJREC *o, int *x, int *y) void draw_object(WINDOW *w,OBJREC *o,char show) { - int x, y; + int x = 0, y = 0; int ok; // WINDOW *ws; @@ -533,7 +533,7 @@ void close_window(WINDOW *w) char mouse_in_object(MS_EVENT *ms,OBJREC *o, WINDOW *w) { - int x1, y1, x2, y2; + int x1=0, y1=0, x2=0, y2=0; absolute_window(w,o,&x1,&y1); x2=x1+o->xs; @@ -936,7 +936,7 @@ void background_runner(EVENT_MSG *msg,void **prog) { *prog_ptr=NULL; return; - } + } (*prog_ptr)(); msg->msg=-2; diff --git a/libs/inicfg.c b/libs/inicfg.c index eec88f4..21340c7 100644 --- a/libs/inicfg.c +++ b/libs/inicfg.c @@ -43,7 +43,7 @@ TSTR_LIST merge_configs(TSTR_LIST target, TSTR_LIST source) buff[255]=0; for (i=0;iseekpos=i; return h; } - strncpy(h->src_file,filename,sizeof(h->src_file)); + strcopy_n(h->src_file,filename,sizeof(h->src_file)); h->seekpos=0; strupper(h->src_file); h->loadproc=decompress; @@ -666,7 +666,7 @@ void display_status() int k; for(k=0;k<5;k++) copys[k]=h->flags & (1<src_file[0]) strncpy(nname,h->src_file,12);else strcpy(nname,""); + if (h->src_file[0]) strcopy_n(nname,h->src_file,12);else strcpy(nname,""); printf("%04Xh ... %12s %s %s %08lXh %6d %10d %6d \n",i*BK_MINOR_HANDLES+j, nname,names[h->status-1], copys,(unsigned long)(uintptr_t)h->blockdata,h->size,h->counter,h->lockcount); diff --git a/libs/pady.c b/libs/pady.c index ea601e6..9128559 100644 --- a/libs/pady.c +++ b/libs/pady.c @@ -58,36 +58,36 @@ typedef struct vzor TVZOR zena= { "hkrdtnbflmpsvz", - "a o˘uŁ–y", + "aďż˝oďż˝u��yďż˝", 1, - "-","y","","u","o","","ou" + "-","y","ďż˝","u","o","ďż˝","ou" }; //Vzor pro zena TVZOR natasa= { - "c‡j¤©¨ź‘", - "a ", + "c��j�����", + "aďż˝", 1, - "-","i","","u","o","","ou" + "-","i","ďż˝","u","o","ďż˝","ou" }; //Vzor pro zena koncici mekkou souhlaskou a a TVZOR ruze= { - "c‡j¤©¨ź‘", - "e‚iˇo˘uŁ–", + "c��j�����", + "eďż˝iďż˝oďż˝u��", 1, - "-","e","i","i","e","i","ˇ" + "-","e","i","i","e","i","ďż˝" }; //Vzor pro ruze s mekkou koncovkou TVZOR ruze2= { "dtn", - "iˇ", + "i��", 1, - "-","e","i","i","e","i","ˇ" + "-","e","i","i","e","i","ďż˝" }; //Vzor pro ruze s tvrdou koncovkou d,t,n s mekkou samohlaskou @@ -95,9 +95,9 @@ TVZOR ruze2= TVZOR pisen= { "*", - "c‡j¤©¨ź‘flmsx", + "c��j�����flmsx", 0, - "-","e","i","-","i","i","ˇ" + "-","e","i","-","i","i","ďż˝" }; //vzor pisen @@ -106,7 +106,7 @@ TVZOR kost= "*", "hkrdtnbpvz", 0, - "-","i","i","-","i","i","ˇ" + "-","i","i","-","i","i","ďż˝" }; //vzor kost @@ -142,17 +142,17 @@ TVZOR quasimodo= TVZOR pritel= { - "e‚", - "c‡j¤©¨ź‘bflmpsvz", + "eďż˝", + "c��j�����bflmpsvz", 0, "-","e","i","e","i","i","em" }; -//vzor pritel pro vzor muz pro obojetne souhlasky ze samohlaskou e, ‚ +//vzor pritel pro vzor muz pro obojetne souhlasky ze samohlaskou e, ďż˝ TVZOR muz= { "*", - "c‡j¤©¨ź‘", + "c��j�����", 0, "-","e","i","e","i","i","em" }; @@ -172,7 +172,7 @@ TVZOR fenix= TVZOR predseda= { "hkrdtnbpvz", - "a o˘uŁ–y", + "aďż˝oďż˝u��yďż˝", 1, "a","y","ovi","u","o","ovi","ou" }; @@ -181,8 +181,8 @@ TVZOR predseda= TVZOR soudce= { - "c‡j¤©¨ź‘flmsx", - "e‚iˇo˘uŁ–", + "c��j�����flmsx", + "eďż˝iďż˝oďż˝u��", 1, "e","e","i","e","e","i","em" }; @@ -192,7 +192,7 @@ TVZOR soudce= TVZOR soudce2= { "dtn", - "iˇ", + "ďż˝iďż˝", 1, "e","e","i","e","e","i","em" }; @@ -213,17 +213,17 @@ char test_vzor(TVZOR *vz,char *jmeno) return 1; } -//tato funkce se vola p©ed odejmutˇm ur‡it‚ho znaku. -//Pokud to toti‘ je zmk‡ovacˇ samohl ska, musˇ se p©ˇpadn‚ d,t,n -//zmk‡it p©ed touto samohl skou. +//tato funkce se vola pďż˝ed odejmutďż˝m urďż˝itďż˝ho znaku. +//Pokud to totiďż˝ je zmďż˝kďż˝ovacďż˝ samohlďż˝ska, musďż˝ se p��padnďż˝ d,t,n +//zmďż˝kďż˝it pďż˝ed touto samohlďż˝skou. void odejmi_znak(char *znak) { - if (znak[0]=='' || znak[0]=='ˇ' || znak[0]=='i') + if (znak[0]=='ďż˝' || znak[0]=='ďż˝' || znak[0]=='i') switch (znak[-1]) { - case 'd': znak[-1]='';break; - case 't': znak[-1]='ź';break; - case 'n': znak[-1]='¤';break; + case 'd': znak[-1]='ďż˝';break; + case 't': znak[-1]='ďż˝';break; + case 'n': znak[-1]='ďż˝';break; } } @@ -233,13 +233,13 @@ void odejmi_znak(char *znak) //Zdenek => Zdenka void uprav_e_nakonci(char *konec) { - char samohlasky[]="a e‚iˇo˘uŁy"; - char pismena[]="flmn¤r©s¨xpv"; + char samohlasky[]="aďż˝eďż˝iďż˝oďż˝uďż˝yďż˝"; + char pismena[]="flmnďż˝rďż˝sďż˝xpv"; char *c; c=konec-2; if (strchr(samohlasky,c[2])!=NULL && strchr(samohlasky,c[1])==NULL && strchr(pismena,c[-1])!=NULL) - if (c[0] =='e'|| c[0]=='‚'|| c[0] =='') + if (c[0] =='e'|| c[0]=='ďż˝'|| c[0] =='ďż˝') { odejmi_znak(c); strcpy(c,c+1); @@ -257,7 +257,7 @@ void ziskej_pad(char *buffer,char *jmeno,TVZOR *vz,char pad) end=strchr(buffer,0)-vz->chrdel; odejmi_znak(end); //odejme znak, pokud je => znak 0 neni znak cesky. strcpy(end,vz->pady[pad]); - if (pad && !vz->chrdel && end[-2]=='–') end[-2]='o'; + if (pad && !vz->chrdel && end[-2]=='ďż˝') end[-2]='o'; uprav_e_nakonci(end); return; } @@ -269,23 +269,23 @@ void uprav_dvojice(char *jmeno) { static char *dvojice[]= { - "e","d", - "źe","t", - "¤e","n", - "i","di", - "źi","ti", - "¤i","ni", - "ˇ","dˇ", - "źˇ","tˇ", - "¤ˇ","nˇ", - "r","©e", - "s","¨e", - "c","‡e", - "k","ce", - "¨","¨e", - "‘","‘e", - "‡","‡e", - "©","©e", + "ďż˝e","dďż˝", + "ďż˝e","tďż˝", + "ďż˝e","nďż˝", + "ďż˝i","di", + "ďż˝i","ti", + "ďż˝i","ni", + "��","dďż˝", + "��","tďż˝", + "��","nďż˝", + "rďż˝","ďż˝e", + "sďż˝","ďż˝e", + "cďż˝","ďż˝e", + "kďż˝","ce", + "��","ďż˝e", + "��","ďż˝e", + "��","ďż˝e", + "��","ďż˝e", }; while (*jmeno) @@ -295,7 +295,7 @@ void uprav_dvojice(char *jmeno) { if (!strncmp(jmeno,dvojice[i],2)) { - strncpy(jmeno,dvojice[i+1],2); + strcopy_n(jmeno,dvojice[i+1],2); break; } } @@ -309,8 +309,8 @@ char *jmena_padu[]= "kdo", "bez", "k", - "vidˇm", - "vol m", + "vidďż˝m", + "volďż˝m", "o", "s" }; @@ -322,7 +322,7 @@ void show_table(char *jmeno,TVZOR *vz,char tabnum) char *buff; buff=alloca(strlen(jmeno)+20); - printf("%d. mo‘nost\n\n",tabnum); + printf("%d. moďż˝nost\n\n",tabnum); for(i=0;i<7;i++) { if (i) @@ -334,15 +334,15 @@ void show_table(char *jmeno,TVZOR *vz,char tabnum) uprav_dvojice(buff); printf(" %d. %-6s %s\n",i+1,jmena_padu[i],buff); } - printf("**** Kl vesu ****\n"); + printf("**** Klďż˝vesu ****\n"); getche(); } //Tato funkce vypise celkovy vysledek. void notabs(int i) { - if (i) printf("Program na¨el %d mo‘most%s.\n",i,(i!=1?(i>1 && i<5?"i":"ˇ"):"")); - else printf("Program bohu‘el nena¨el ‘ dnou mo‘nost jak sklo¤ovat toto jm‚no.\n"); + if (i) printf("Program naďż˝el %d moďż˝most%s.\n",i,(i!=1?(i>1 && i<5?"i":"ďż˝"):"")); + else printf("Program bohuďż˝el nenaďż˝el ��dnou moďż˝nost jak skloďż˝ovat toto jmďż˝no.\n"); puts("-------------------------------------------------------------------------"); } @@ -384,20 +384,20 @@ void hlavni() char pohlavi; do { - printf("Zadej jm‚no. Vy‘aduje se min 3 znaky v ‡e¨tin kodu kamenickch \n"); - printf("Jm‚no nesmˇ mˇt vˇc ne‘ 50 znak–, a nesmˇ obsahovat mezery:\n"); - printf("Pi¨ malmi pˇsmeny, pouze prvnˇ pismeno m–‘e bt velk‚:\n"); - printf("(pouh‚ 'x' je odchod z programu)\n"); + printf("Zadej jmďż˝no. Vyďż˝aduje se min 3 znaky v ďż˝eďż˝tinďż˝ kodu kamenickďż˝ch \n"); + printf("Jmďż˝no nesmďż˝ mďż˝t vďż˝c neďż˝ 50 znakďż˝, a nesmďż˝ obsahovat mezery:\n"); + printf("Piďż˝ malďż˝mi pďż˝smeny, pouze prvnďż˝ pismeno m��e bďż˝t velkďż˝:\n"); + printf("(pouhďż˝ 'x' je odchod z programu)\n"); jmeno_chyba: gets(jmeno); if (jmeno[0]=='x' && jmeno[1]==0) return; if (strlen(jmeno)<3) { - printf("Jm‚no musˇ bt min 3 znaky dlouh‚\n"); + printf("Jmďż˝no musďż˝ bďż˝t min 3 znaky dlouhďż˝\n"); goto jmeno_chyba; } chyba: - printf("Jsi mu‘ nebo ‘ena? (M/Z nebo M/F nebo X):"); + printf("Jsi muďż˝ nebo ďż˝ena? (M/Z nebo M/F nebo X):"); pohlavi=getchar(); while (getchar()!='\n'); puts(""); @@ -414,11 +414,11 @@ main() { hlavni(); puts(""); - puts("Pokud jsi objevil p©irozen‚ jm‚no (tj re ln‚ jm‚no), kter‚ program\n" - "nedok zal vysklo¤ovat, po¨li mi jeho znnˇ na adresu:\n" + puts("Pokud jsi objevil pďż˝irozenďż˝ jmďż˝no (tj reďż˝lnďż˝ jmďż˝no), kterďż˝ program\n" + "nedokďż˝zal vyskloďż˝ovat, poďż˝li mi jeho znďż˝nďż˝ na adresu:\n" "xnovako1@cs.felk.cvut.cz\n"); - puts("Verze Latin2 se p©ipravuje...\n" - "O slovensk‚ verzi se zatˇm neuva‘uje...\n"); - puts("Napsal: Ond©ej Nov k za 2 a p–l hodiny ve WATCOM C\n" - "Zdroj ky majˇ povahu PUBLIC DOMAIN\n"); + puts("Verze Latin2 se pďż˝ipravuje...\n" + "O slovenskďż˝ verzi se zatďż˝m neuvaďż˝uje...\n"); + puts("Napsal: Ondďż˝ej Novďż˝k za 2 a pďż˝l hodiny ve WATCOM C\n" + "Zdrojďż˝ky majďż˝ povahu PUBLIC DOMAIN\n"); } diff --git a/libs/pcx.c b/libs/pcx.c index 69637c5..531765a 100644 --- a/libs/pcx.c +++ b/libs/pcx.c @@ -179,7 +179,7 @@ int load_pcx(const char *pcx,int32_t fsize,int conv_type,char **buffer, ... ) return sz; } - +/* int open_pcx(const char *filename,int type,char **buffer,...) { FILE *pcx; @@ -193,12 +193,15 @@ int open_pcx(const char *filename,int type,char **buffer,...) fseek(pcx,0,SEEK_SET); src=(char *)getmem(fsize); fread(src,1,fsize,pcx); + va_list lst; + va_start(lst, buffer); + int fsize=load_pcx(src,fsize,type,buffer,*((int *)&buffer+1),*((int *)&buffer+2),*((int *)&buffer+3)); fclose(pcx); free(src); return fsize; } - +*/ /*void initmode32b(); main() diff --git a/mapedit/CDialogy/CDialogy.vcproj b/mapedit/CDialogy/CDialogy.vcproj deleted file mode 100644 index f3ed9a4..0000000 --- a/mapedit/CDialogy/CDialogy.vcproj +++ /dev/null @@ -1,204 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mapedit/CDialogy/Debug/BuildLog.htm b/mapedit/CDialogy/Debug/BuildLog.htm deleted file mode 100644 index e3892c5..0000000 Binary files a/mapedit/CDialogy/Debug/BuildLog.htm and /dev/null differ diff --git a/mapedit/CDialogy/Debug/CDialogy.exe b/mapedit/CDialogy/Debug/CDialogy.exe deleted file mode 100644 index 8143bd9..0000000 Binary files a/mapedit/CDialogy/Debug/CDialogy.exe and /dev/null differ diff --git a/mapedit/CDialogy/Debug/CDialogy.exe.embed.manifest b/mapedit/CDialogy/Debug/CDialogy.exe.embed.manifest deleted file mode 100644 index 11bb704..0000000 --- a/mapedit/CDialogy/Debug/CDialogy.exe.embed.manifest +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/mapedit/CDialogy/Debug/CDialogy.exe.embed.manifest.res b/mapedit/CDialogy/Debug/CDialogy.exe.embed.manifest.res deleted file mode 100644 index 9c8df0e..0000000 Binary files a/mapedit/CDialogy/Debug/CDialogy.exe.embed.manifest.res and /dev/null differ diff --git a/mapedit/CDialogy/Debug/CDialogy.exe.intermediate.manifest b/mapedit/CDialogy/Debug/CDialogy.exe.intermediate.manifest deleted file mode 100644 index ecea6f7..0000000 --- a/mapedit/CDialogy/Debug/CDialogy.exe.intermediate.manifest +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/mapedit/CDialogy/Debug/mt.dep b/mapedit/CDialogy/Debug/mt.dep deleted file mode 100644 index facf237..0000000 --- a/mapedit/CDialogy/Debug/mt.dep +++ /dev/null @@ -1 +0,0 @@ -Manifest resource last updated at 21:19:30,53 on st 11.09.2013 diff --git a/mapedit/CDialogy/Debug/vc80.idb b/mapedit/CDialogy/Debug/vc80.idb deleted file mode 100644 index 548b7d2..0000000 Binary files a/mapedit/CDialogy/Debug/vc80.idb and /dev/null differ diff --git a/mapedit/CDialogy/Debug/vc90.idb b/mapedit/CDialogy/Debug/vc90.idb deleted file mode 100644 index df41d22..0000000 Binary files a/mapedit/CDialogy/Debug/vc90.idb and /dev/null differ diff --git a/mapedit/CDialogy/Release/BuildLog.htm b/mapedit/CDialogy/Release/BuildLog.htm deleted file mode 100644 index 0f03d55..0000000 Binary files a/mapedit/CDialogy/Release/BuildLog.htm and /dev/null differ diff --git a/mapedit/CDialogy/Release/CDialogy.exe b/mapedit/CDialogy/Release/CDialogy.exe deleted file mode 100644 index 3013600..0000000 Binary files a/mapedit/CDialogy/Release/CDialogy.exe and /dev/null differ diff --git a/mapedit/CDialogy/Release/CDialogy.exe.intermediate.manifest b/mapedit/CDialogy/Release/CDialogy.exe.intermediate.manifest deleted file mode 100644 index ecea6f7..0000000 --- a/mapedit/CDialogy/Release/CDialogy.exe.intermediate.manifest +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/mapedit/CDialogy/Release/mt.dep b/mapedit/CDialogy/Release/mt.dep deleted file mode 100644 index 4d51d5a..0000000 --- a/mapedit/CDialogy/Release/mt.dep +++ /dev/null @@ -1 +0,0 @@ -Manifest resource last updated at 20:26:01,30 on st 11.09.2013 diff --git a/mapedit/CDialogy/Release/vc80.idb b/mapedit/CDialogy/Release/vc80.idb deleted file mode 100644 index 95fa02d..0000000 Binary files a/mapedit/CDialogy/Release/vc80.idb and /dev/null differ diff --git a/mapedit/CDialogy/Release/vc90.idb b/mapedit/CDialogy/Release/vc90.idb deleted file mode 100644 index c63a6a3..0000000 Binary files a/mapedit/CDialogy/Release/vc90.idb and /dev/null differ diff --git a/mapedit/CSpells/CSpells.cpp b/mapedit/CSpells/CSpells.cpp deleted file mode 100644 index ae5f5e5..0000000 --- a/mapedit/CSpells/CSpells.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// CSpells.cpp : Defines the entry point for the console application. -// - -#include "stdafx.h" - -int _tmain(int argc, _TCHAR* argv[]) -{ - return 0; -} - diff --git a/mapedit/CSpells/CSpells.vcproj b/mapedit/CSpells/CSpells.vcproj deleted file mode 100644 index f8a246e..0000000 --- a/mapedit/CSpells/CSpells.vcproj +++ /dev/null @@ -1,208 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mapedit/CSpells/Debug/BuildLog.htm b/mapedit/CSpells/Debug/BuildLog.htm deleted file mode 100644 index 0d178e0..0000000 Binary files a/mapedit/CSpells/Debug/BuildLog.htm and /dev/null differ diff --git a/mapedit/CSpells/Debug/CSpells.exe b/mapedit/CSpells/Debug/CSpells.exe deleted file mode 100644 index 9862284..0000000 Binary files a/mapedit/CSpells/Debug/CSpells.exe and /dev/null differ diff --git a/mapedit/CSpells/Debug/CSpells.exe.embed.manifest b/mapedit/CSpells/Debug/CSpells.exe.embed.manifest deleted file mode 100644 index 11bb704..0000000 --- a/mapedit/CSpells/Debug/CSpells.exe.embed.manifest +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/mapedit/CSpells/Debug/CSpells.exe.embed.manifest.res b/mapedit/CSpells/Debug/CSpells.exe.embed.manifest.res deleted file mode 100644 index 9c8df0e..0000000 Binary files a/mapedit/CSpells/Debug/CSpells.exe.embed.manifest.res and /dev/null differ diff --git a/mapedit/CSpells/Debug/CSpells.exe.intermediate.manifest b/mapedit/CSpells/Debug/CSpells.exe.intermediate.manifest deleted file mode 100644 index ecea6f7..0000000 --- a/mapedit/CSpells/Debug/CSpells.exe.intermediate.manifest +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/mapedit/CSpells/Debug/mt.dep b/mapedit/CSpells/Debug/mt.dep deleted file mode 100644 index 63ead3c..0000000 --- a/mapedit/CSpells/Debug/mt.dep +++ /dev/null @@ -1 +0,0 @@ -Manifest resource last updated at 21:19:30,58 on st 11.09.2013 diff --git a/mapedit/CSpells/Debug/vc80.idb b/mapedit/CSpells/Debug/vc80.idb deleted file mode 100644 index 00088c0..0000000 Binary files a/mapedit/CSpells/Debug/vc80.idb and /dev/null differ diff --git a/mapedit/CSpells/Debug/vc90.idb b/mapedit/CSpells/Debug/vc90.idb deleted file mode 100644 index 2e8c5f5..0000000 Binary files a/mapedit/CSpells/Debug/vc90.idb and /dev/null differ diff --git a/mapedit/CSpells/Release/BuildLog.htm b/mapedit/CSpells/Release/BuildLog.htm deleted file mode 100644 index 2e4d880..0000000 Binary files a/mapedit/CSpells/Release/BuildLog.htm and /dev/null differ diff --git a/mapedit/CSpells/Release/CSpells.exe b/mapedit/CSpells/Release/CSpells.exe deleted file mode 100644 index 23822b7..0000000 Binary files a/mapedit/CSpells/Release/CSpells.exe and /dev/null differ diff --git a/mapedit/CSpells/Release/CSpells.exe.intermediate.manifest b/mapedit/CSpells/Release/CSpells.exe.intermediate.manifest deleted file mode 100644 index ecea6f7..0000000 --- a/mapedit/CSpells/Release/CSpells.exe.intermediate.manifest +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/mapedit/CSpells/Release/mt.dep b/mapedit/CSpells/Release/mt.dep deleted file mode 100644 index d15065b..0000000 --- a/mapedit/CSpells/Release/mt.dep +++ /dev/null @@ -1 +0,0 @@ -Manifest resource last updated at 20:25:58,79 on st 11.09.2013 diff --git a/mapedit/CSpells/Release/vc80.idb b/mapedit/CSpells/Release/vc80.idb deleted file mode 100644 index f844f79..0000000 Binary files a/mapedit/CSpells/Release/vc80.idb and /dev/null differ diff --git a/mapedit/CSpells/Release/vc90.idb b/mapedit/CSpells/Release/vc90.idb deleted file mode 100644 index fd9d5c5..0000000 Binary files a/mapedit/CSpells/Release/vc90.idb and /dev/null differ diff --git a/mapedit/CSpells/stdafx.cpp b/mapedit/CSpells/stdafx.cpp deleted file mode 100644 index a6021b7..0000000 --- a/mapedit/CSpells/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// CSpells.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/mapedit/CSpells/stdafx.h b/mapedit/CSpells/stdafx.h deleted file mode 100644 index f9aca9b..0000000 --- a/mapedit/CSpells/stdafx.h +++ /dev/null @@ -1,12 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - - -#include -#include - -// TODO: reference additional headers your program requires here diff --git a/mapedit/ColEdit/ColEdit.cpp b/mapedit/ColEdit/ColEdit.cpp deleted file mode 100644 index 60c947c..0000000 --- a/mapedit/ColEdit/ColEdit.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// ColEdit.cpp : Defines the class behaviors for the application. -// - -#include "stdafx.h" -#include "ColEdit.h" -#include "ColEditDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CColEditApp - -BEGIN_MESSAGE_MAP(CColEditApp, CWinApp) - //{{AFX_MSG_MAP(CColEditApp) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - //}}AFX_MSG - ON_COMMAND(ID_HELP, CWinApp::OnHelp) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CColEditApp construction - -CColEditApp::CColEditApp() -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CColEditApp object - -CColEditApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CColEditApp initialization - -BOOL CColEditApp::InitInstance() -{ - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. -/* -#ifdef _AFXDLL - Enable3dControls(); // Call this when using MFC in a shared DLL -#else - Enable3dControlsStatic(); // Call this when linking to MFC statically -#endif -*/ - CColEditDlg dlg; - m_pMainWnd = &dlg; - int nResponse = dlg.DoModal(); - if (nResponse == IDOK) - { - // TODO: Place code here to handle when the dialog is - // dismissed with OK - } - else if (nResponse == IDCANCEL) - { - // TODO: Place code here to handle when the dialog is - // dismissed with Cancel - } - - // Since the dialog has been closed, return FALSE so that we exit the - // application, rather than start the application's message pump. - return FALSE; -} diff --git a/mapedit/ColEdit/ColEdit.h b/mapedit/ColEdit/ColEdit.h deleted file mode 100644 index 5013faf..0000000 --- a/mapedit/ColEdit/ColEdit.h +++ /dev/null @@ -1,49 +0,0 @@ -// ColEdit.h : main header file for the COLEDIT application -// - -#if !defined(AFX_COLEDIT_H__4A70A254_5D3A_4703_9034_4EE5A90DFE73__INCLUDED_) -#define AFX_COLEDIT_H__4A70A254_5D3A_4703_9034_4EE5A90DFE73__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CColEditApp: -// See ColEdit.cpp for the implementation of this class -// - -class CColEditApp : public CWinApp -{ -public: - CColEditApp(); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CColEditApp) - public: - virtual BOOL InitInstance(); - //}}AFX_VIRTUAL - -// Implementation - - //{{AFX_MSG(CColEditApp) - // NOTE - the ClassWizard will add and remove member functions here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_COLEDIT_H__4A70A254_5D3A_4703_9034_4EE5A90DFE73__INCLUDED_) diff --git a/mapedit/ColEdit/ColEdit.rc b/mapedit/ColEdit/ColEdit.rc deleted file mode 100644 index cb6985d..0000000 --- a/mapedit/ColEdit/ColEdit.rc +++ /dev/null @@ -1,281 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Czech resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CSY) -#ifdef _WIN32 -LANGUAGE LANG_CZECH, SUBLANG_DEFAULT -#pragma code_page(1250) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_SPLITTER_RESOURCES\r\n" - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\ColEdit.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\ColEdit.ico" -IDI_UP ICON "res\\icon1.ico" -IDI_DOWN ICON "res\\down.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_EDITPALETTE DIALOG 200, 0, 336, 301 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Edit Palette" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,77,280,50,14 - PUSHBUTTON "Cancel",IDCANCEL,143,280,50,14 - CONTROL "",IDC_PALETA,"Static",SS_BLACKFRAME | SS_NOTIFY,7,7,322, - 188 - LTEXT "Barva",IDC_STATIC,7,206,20,8 - CONTROL "Slider1",IDC_BARVA,"msctls_trackbar32",TBS_BOTH | - TBS_NOTICKS | WS_TABSTOP,35,204,294,15 - LTEXT "Sitost",IDC_STATIC,7,226,18,8 - CONTROL "Slider1",IDC_SITOST,"msctls_trackbar32",TBS_BOTH | - TBS_NOTICKS | WS_TABSTOP,35,224,294,15 - LTEXT "Jas",IDC_STATIC,7,246,12,8 - CONTROL "Slider1",IDC_JAS,"msctls_trackbar32",TBS_BOTH | - TBS_NOTICKS | WS_TABSTOP,35,244,294,15 - PUSHBUTTON "Undo",IDC_UNDO,209,280,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_EDITPALETTE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 329 - TOPMARGIN, 7 - BOTTOMMARGIN, 294 - HORZGUIDE, 195 - END -END -#endif // APSTUDIO_INVOKED - -#endif // Czech resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOG 0, 0, 235, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About ColEdit" -FONT 8, "MS Sans Serif" -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "ColEdit Version 1.0",IDC_STATIC,40,10,119,8,SS_NOPREFIX - LTEXT "Copyright (C) 2005",IDC_STATIC,40,25,119,8 - DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP -END - -IDD_COLEDIT_DIALOG DIALOGEX 0, 0, 484, 330 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | - WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "ColEdit" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - LISTBOX IDC_COLORLIST,7,7,50,152,LBS_NOINTEGRALHEIGHT | - WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Insert",IDC_INSERT,7,210,50,14 - PUSHBUTTON "Delete",IDC_DELETE,7,246,50,14 - DEFPUSHBUTTON "Save",IDOK,7,263,50,14 - PUSHBUTTON "Quit",IDCANCEL,7,309,50,14 - CONTROL "",IDC_IMAGE,"Static",SS_BLACKFRAME,61,7,416,299 - PUSHBUTTON "Load",IDC_LOAD,7,292,50,14 - COMBOBOX IDC_IMAGESEL,372,311,105,114,CBS_DROPDOWNLIST | CBS_SORT | - WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Duplicate",IDC_DUPLICATE,7,227,50,14 - PUSHBUTTON "Up",IDC_UP,7,163,50,18,BS_ICON - PUSHBUTTON "Down",IDC_DOWN,7,182,50,18,BS_ICON - PUSHBUTTON "Oprav paletu",IDC_OPRAVPALETU,61,309,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_ABOUTBOX, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 228 - TOPMARGIN, 7 - BOTTOMMARGIN, 48 - END - - IDD_COLEDIT_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 477 - VERTGUIDE, 61 - TOPMARGIN, 7 - BOTTOMMARGIN, 323 - HORZGUIDE, 306 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "FileDescription", "ColEdit MFC Application" - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "ColEdit" - VALUE "LegalCopyright", "Copyright (C) 2005" - VALUE "OriginalFilename", "ColEdit.EXE" - VALUE "ProductName", "ColEdit Application" - VALUE "ProductVersion", "1, 0, 0, 1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDS_ABOUTBOX "&About ColEdit..." - IDS_PALETANAME "Paleta %d" - IDS_COLFILTER "Skeldal palette list (*.col)|*.col||" - IDS_LOADFAILED "Load failed." - IDS_PALFILTER "JASC Palette (ex: IrfanView)|*.pal|All files|*.*|" - IDS_NOVAPALETA "" - IDS_SAVEFAILED "Nemohu soubor uložit" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\ColEdit.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/mapedit/ColEdit/ColEdit.sln b/mapedit/ColEdit/ColEdit.sln deleted file mode 100644 index a110117..0000000 --- a/mapedit/ColEdit/ColEdit.sln +++ /dev/null @@ -1,21 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ColEdit", "ColEdit.vcproj", "{0ED4C971-BCD5-4E05-890D-26C8E2FAE867}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {0ED4C971-BCD5-4E05-890D-26C8E2FAE867}.Debug.ActiveCfg = Debug|Win32 - {0ED4C971-BCD5-4E05-890D-26C8E2FAE867}.Debug.Build.0 = Debug|Win32 - {0ED4C971-BCD5-4E05-890D-26C8E2FAE867}.Release.ActiveCfg = Release|Win32 - {0ED4C971-BCD5-4E05-890D-26C8E2FAE867}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/mapedit/ColEdit/ColEdit.vcproj b/mapedit/ColEdit/ColEdit.vcproj deleted file mode 100644 index 11b66e5..0000000 --- a/mapedit/ColEdit/ColEdit.vcproj +++ /dev/null @@ -1,454 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mapedit/ColEdit/ColEditDlg.cpp b/mapedit/ColEdit/ColEditDlg.cpp deleted file mode 100644 index 798b8af..0000000 --- a/mapedit/ColEdit/ColEditDlg.cpp +++ /dev/null @@ -1,489 +0,0 @@ -// ColEditDlg.cpp : implementation file -// - -#include "stdafx.h" -#include "ColEdit.h" -#include "ColEditDlg.h" -#include "..\..\LIBS\PCX.H" -#include "EditPaletteDlg.h" -#include "../../DDLReader/WString.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - - // Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation -protected: - //{{AFX_MSG(CAboutDlg) - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) -//{{AFX_MSG_MAP(CAboutDlg) -// No message handlers -//}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CColEditDlg dialog - -CColEditDlg::CColEditDlg(CWnd* pParent /*=NULL*/) -: CDialog(CColEditDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CColEditDlg) - //}}AFX_DATA_INIT - // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 - m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); - _palused=0; -} - -void CColEditDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CColEditDlg) - DDX_Control(pDX, IDC_UP, wUp); - DDX_Control(pDX, IDC_DOWN, wDown); - DDX_Control(pDX, IDC_IMAGESEL, wImageSel); - DDX_Control(pDX, IDC_IMAGE, wImage); - DDX_Control(pDX, IDC_COLORLIST, wColList); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CColEditDlg, CDialog) -//{{AFX_MSG_MAP(CColEditDlg) -ON_WM_SYSCOMMAND() -ON_WM_PAINT() -ON_WM_QUERYDRAGICON() -ON_BN_CLICKED(IDC_LOAD, OnLoad) -ON_LBN_SELCHANGE(IDC_COLORLIST, OnSelchangeColorlist) -ON_CBN_SELCHANGE(IDC_IMAGESEL, OnSelchangeImagesel) -ON_BN_CLICKED(IDC_INSERT, OnInsert) -ON_BN_CLICKED(IDC_UP, OnUp) -ON_BN_CLICKED(IDC_DOWN, OnDown) -ON_BN_CLICKED(IDC_DUPLICATE, OnDuplicate) -ON_BN_CLICKED(IDC_DELETE, OnDelete) -ON_BN_CLICKED(IDC_OPRAVPALETU, OnOpravpaletu) -//}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CColEditDlg message handlers - -BOOL CColEditDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // Add "About..." menu item to system menu. - - // IDM_ABOUTBOX must be in the system command range. - ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); - ASSERT(IDM_ABOUTBOX < 0xF000); - - CMenu* pSysMenu = GetSystemMenu(FALSE); - if (pSysMenu != NULL) - { - CString strAboutMenu; - strAboutMenu.LoadString(IDS_ABOUTBOX); - if (!strAboutMenu.IsEmpty()) - { - pSysMenu->AppendMenu(MF_SEPARATOR); - pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); - } - } - - // Set the icon for this dialog. The framework does this automatically - // when the application's main window is not a dialog - SetIcon(m_hIcon, TRUE); // Set big icon - SetIcon(m_hIcon, FALSE); // Set small icon - - wUp.SetIcon(AfxGetApp()->LoadIcon(IDI_UP)); - wDown.SetIcon(AfxGetApp()->LoadIcon(IDI_DOWN)); - - // TODO: Add extra initialization here - OnSelchangeColorlist(); - - return TRUE; // return TRUE unless you set the focus to a control -} - -void CColEditDlg::OnSysCommand(UINT nID, LPARAM lParam) -{ - if ((nID & 0xFFF0) == IDM_ABOUTBOX) - { - CAboutDlg dlgAbout; - dlgAbout.DoModal(); - } - else - { - CDialog::OnSysCommand(nID, lParam); - } -} - -// If you add a minimize button to your dialog, you will need the code below -// to draw the icon. For MFC applications using the document/view model, -// this is automatically done for you by the framework. - -void CColEditDlg::OnPaint() -{ - if (IsIconic()) - { - CPaintDC dc(this); // device context for painting - - SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); - - // Center icon in client rectangle - int cxIcon = GetSystemMetrics(SM_CXICON); - int cyIcon = GetSystemMetrics(SM_CYICON); - CRect rect; - GetClientRect(&rect); - int x = (rect.Width() - cxIcon + 1) / 2; - int y = (rect.Height() - cyIcon + 1) / 2; - - // Draw the icon - dc.DrawIcon(x, y, m_hIcon); - } - else - { - CDialog::OnPaint(); - } -} - -// The system calls this to obtain the cursor to display while the user drags -// the minimized window. -HCURSOR CColEditDlg::OnQueryDragIcon() -{ - return (HCURSOR) m_hIcon; -} - -void CColEditDlg::UpdateLB() -{ - CString name; - wColList.ResetContent(); - for (int i=0;i<_palused;i++) - { - name.Format(IDS_PALETANAME,_indexes[i]); - wColList.AddString(name); - } - if (_palusedEnableWindow(curSel>=0); - GetDlgItem(IDC_DUPLICATE)->EnableWindow(curSel>=0); - GetDlgItem(IDC_DELETE)->EnableWindow(curSel>=0); - GetDlgItem(IDC_UP)->EnableWindow(curSel>=0); - GetDlgItem(IDC_DOWN)->EnableWindow(curSel>=0); - GetDlgItem(IDC_OPRAVPALETU)->EnableWindow(curSel>=0); -} - -extern "C" -{ - - void *getmem(int32_t sz) - { - return malloc(sz); - } - -} - -void CColEditDlg::OnSelchangeImagesel() -{ - int i=wImageSel.GetCurSel(); - if (i!=-1) - { - CString pos; - wImageSel.GetLBText(i,pos); - int bsl=fname.ReverseFind('\\'); - pos=fname.Mid(0,bsl+1)+pos; - char * buffer; - memset(_stbuff,0,sizeof(_stbuff)); -#ifdef _UNICODE - WString pname(pos.GetString()); - const char *pcxname=pname.AsUTF8(pname); -#else - const char *pcxname=pos; -#endif - if (open_pcx(const_cast(pcxname),A_8BIT,&buffer)) return; - unsigned short *xy=(unsigned short *)buffer; - for (int y=0;y=0) - { - char *p=_palety[palid]; - for (int i=0;i<768;i++) - { - int item=0; - _ftscanf(f,_T("%d"),&item); - *p++=(char)item; - } - ok=true; - OnSelchangeImagesel(); - } - } - } - } - fclose(f); - if (!ok) - AfxMessageBox(IDS_LOADFAILED,MB_OK); - } -} - -int CColEditDlg::DuplicateCurrent() -{ - int i; - int curSel=wColList.GetCurSel(); - int saveCurSel=curSel; - if (curSel==_palused) curSel--; - if (curSel==-1) curSel=0; - for (i=MAX_PALET-1;i>curSel;i--) - { - memcpy(_palety[i],_palety[i-1],sizeof(_palety[i])); - _indexes[i]=_indexes[i-1]; - } - _palused++; - if (_palused>MAX_PALET) _palused=MAX_PALET; - int maxnum=0; - for (i=0;i<_palused;i++) - if (_indexes[i]>maxnum) maxnum=_indexes[i]; - _indexes[saveCurSel]=maxnum+1; - UpdateLB(); - wColList.SetCurSel(saveCurSel); - return saveCurSel; -} - - -void CColEditDlg::OnUp() -{ - int i; - int curSel=wColList.GetCurSel(); - if (curSel<1) return; - if (curSel>=_palused) return; - i=curSel; - char buff[768]; - memcpy(buff,_palety[i-1],sizeof(_palety[i])); - memcpy(_palety[i-1],_palety[i],sizeof(_palety[i])); - memcpy(_palety[i],buff,sizeof(_palety[i])); - int p=_indexes[i-1]; - _indexes[i-1]=_indexes[i]; - _indexes[i]=p; - curSel--; - UpdateLB(); - wColList.SetCurSel(curSel); -} - -void CColEditDlg::OnDown() -{ - int i; - int curSel=wColList.GetCurSel(); - if (curSel<0) return; - if (curSel>=_palused-1) return; - i=curSel; - char buff[768]; - memcpy(buff,_palety[i+1],sizeof(_palety[i])); - memcpy(_palety[i+1],_palety[i],sizeof(_palety[i])); - memcpy(_palety[i],buff,sizeof(_palety[i])); - int p=_indexes[i+1]; - _indexes[i+1]=_indexes[i]; - _indexes[i]=p; - curSel++; - UpdateLB(); - wColList.SetCurSel(curSel); - -} - -void CColEditDlg::OnDuplicate() -{ - DuplicateCurrent(); - OnSelchangeImagesel(); - -} - -void CColEditDlg::OnDelete() -{ - int i=wColList.GetCurSel(); - if (i<0) return; - if (i>=_palused) return; - for (int p=i+1;p<_palused;p++) - { - memcpy(_palety[p-1],_palety[p],sizeof(_palety[p])); - _indexes[p-1]=_indexes[p]; - } - _palused--; - UpdateLB(); - OnSelchangeColorlist(); -} - -void CColEditDlg::OnOK() -{ - if (fname=="") - { - CString filter; - filter.LoadString(IDS_COLFILTER); - CFileDialog fdlg(FALSE,_T("COL"),fname,OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|OFN_OVERWRITEPROMPT,filter); - if (fdlg.DoModal()!=IDOK) return; - fname=fdlg.GetPathName(); - } - if (SaveDocument(fname)==false) - AfxMessageBox(IDS_SAVEFAILED); - - -} - -bool CColEditDlg::SaveDocument(LPCTSTR name) -{ - HANDLE h=CreateFile(name,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL); - if (h==INVALID_HANDLE_VALUE) return false; - for (int i=0;i<_palused;i++) - { - DWORD dummy[2]={0,0}; - DWORD result=0; - WriteFile(h,&dummy,8,&result,NULL); - if (result!=8) {CloseHandle(h);return false;} - WriteFile(h,_palety[i],768,&result,NULL); - if (result!=768) {CloseHandle(h);return false;} - } - CloseHandle(h); - return true; -} - -void CColEditDlg::OnOpravpaletu() -{ - CEditPaletteDlg dlg; - int i=wColList.GetCurSel(); - if (i<0) return; - dlg._palette=_palety[i]; - dlg._imgView=&wImage; - dlg.DoModal(); - -} diff --git a/mapedit/ColEdit/ColEditDlg.h b/mapedit/ColEdit/ColEditDlg.h deleted file mode 100644 index 042a041..0000000 --- a/mapedit/ColEdit/ColEditDlg.h +++ /dev/null @@ -1,79 +0,0 @@ -// ColEditDlg.h : header file -// - -#if !defined(AFX_COLEDITDLG_H__2FF53390_ECD2_468E_B1C9_60F1718D1470__INCLUDED_) -#define AFX_COLEDITDLG_H__2FF53390_ECD2_468E_B1C9_60F1718D1470__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -///////////////////////////////////////////////////////////////////////////// -// CColEditDlg dialog - - -#include "..\Podlahar\ImageView.h" -#define MAX_PALET 100 - -class CColEditDlg : public CDialog -{ -// Construction - char _palety[MAX_PALET][768]; - int _palused; - int _indexes[MAX_PALET]; - CString fname; - - char _stbuff[640*480]; - -public: - bool SaveDocument(LPCTSTR name); - int DuplicateCurrent(); - void UpdateCB(); - bool LoadDocument(LPCTSTR name); - void UpdateLB(); - CColEditDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CColEditDlg) - enum { IDD = IDD_COLEDIT_DIALOG }; - CButton wUp; - CButton wDown; - CComboBox wImageSel; - CImageView wImage; - CListBox wColList; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CColEditDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - HICON m_hIcon; - - // Generated message map functions - //{{AFX_MSG(CColEditDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnSysCommand(UINT nID, LPARAM lParam); - afx_msg void OnPaint(); - afx_msg HCURSOR OnQueryDragIcon(); - afx_msg void OnLoad(); - afx_msg void OnSelchangeColorlist(); - afx_msg void OnSelchangeImagesel(); - afx_msg void OnInsert(); - afx_msg void OnUp(); - afx_msg void OnDown(); - afx_msg void OnDuplicate(); - afx_msg void OnDelete(); - virtual void OnOK(); - afx_msg void OnOpravpaletu(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_COLEDITDLG_H__2FF53390_ECD2_468E_B1C9_60F1718D1470__INCLUDED_) diff --git a/mapedit/ColEdit/EditPaletteDlg.cpp b/mapedit/ColEdit/EditPaletteDlg.cpp deleted file mode 100644 index 85f7e58..0000000 --- a/mapedit/ColEdit/EditPaletteDlg.cpp +++ /dev/null @@ -1,233 +0,0 @@ -// EditPaletteDlg.cpp : implementation file -// - -#include "stdafx.h" -#include "ColEdit.h" -#include "EditPaletteDlg.h" -#include -#include - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CEditPaletteDlg dialog - - -CEditPaletteDlg::CEditPaletteDlg(CWnd* pParent /*=NULL*/) - : CDialog(CEditPaletteDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CEditPaletteDlg) - //}}AFX_DATA_INIT -} - - -void CEditPaletteDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CEditPaletteDlg) - DDX_Control(pDX, IDC_SITOST, wSitost); - DDX_Control(pDX, IDC_JAS, wJas); - DDX_Control(pDX, IDC_BARVA, wBarva); - DDX_Control(pDX, IDC_PALETA, wPaleta); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CEditPaletteDlg, CDialog) - //{{AFX_MSG_MAP(CEditPaletteDlg) - ON_BN_CLICKED(IDC_PALETA, OnPaleta) - ON_WM_HSCROLL() - ON_BN_CLICKED(IDC_UNDO, OnUndo) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CEditPaletteDlg message handlers - -/* -RGB to HSV & HSV to RGB - -The Hue/Saturation/Value model was created by A. R. Smith in 1978. It is based on such intuitive color characteristics as tint, shade and tone (or family, purety and intensity). The coordinate system is cylindrical, and the colors are defined inside a hexcone. The hue value H runs from 0 to 360o. The saturation S is the degree of strength or purity and is from 0 to 1. Purity is how much white is added to the color, so S=1 makes the purest color (no white). Brightness V also ranges from 0 to 1, where 0 is the black. - -There is no transformation matrix for RGB/HSV conversion, but the algorithm follows: -*/ -// r,g,b values are from 0 to 1 -// h = [0,360], s = [0,1], v = [0,1] -// if s == 0, then h = -1 (undefined) -static void RGBtoHSV( float r, float g, float b, float *h, float *s, float *v ) -{ - float min, max, delta; - min = __min( r, __min(g, b )); - max = __max( r, __max(g, b )); - *v = max; // v - delta = max - min; - if( max != 0 ) - *s = delta / max; // s - else { - // r = g = b = 0 // s = 0, v is undefined - *s = 0; - *h = -1; - return; - } - if( r == max ) - *h = ( g - b ) / delta; // between yellow & magenta - else if( g == max ) - *h = 2 + ( b - r ) / delta; // between cyan & yellow - else - *h = 4 + ( r - g ) / delta; // between magenta & cyan - *h *= 60; // degrees - if( *h < 0 ) - *h += 360; -} -static void HSVtoRGB( float *r, float *g, float *b, float h, float s, float v ) -{ - int i; - float f, p, q, t; - if( s == 0 ) { - // achromatic (grey) - *r = *g = *b = v; - return; - } - h /= 60; // sector 0 to 5 - i = (int)floor( h ); - f = h - i; // factorial part of h - p = v * ( 1 - s ); - q = v * ( 1 - s * f ); - t = v * ( 1 - s * ( 1 - f ) ); - switch( i ) { - case 0: - *r = v; - *g = t; - *b = p; - break; - case 1: - *r = q; - *g = v; - *b = p; - break; - case 2: - *r = p; - *g = v; - *b = t; - break; - case 3: - *r = p; - *g = q; - *b = v; - break; - case 4: - *r = t; - *g = p; - *b = v; - break; - default: // case 5: - *r = v; - *g = p; - *b = q; - break; - } -} - - -BOOL CEditPaletteDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - memcpy(_paletteUndo,_palette,768); - wPaleta.SetPalette(_palette); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CEditPaletteDlg::CalculateAvgHSV() -{ - float h,s,v,sh=0,ss=0,sv=0; - int cnt=0; - for (int i=0;i<256;i++) if (wPaleta.IsSelected(i)) - { - RGBtoHSV(wPaleta.GetR(i)/255.0f,wPaleta.GetG(i)/255.0f,wPaleta.GetB(i)/255.0f,&h,&s,&v); - if (!_finite(h)) h=0; - sh+=h; - ss+=s; - sv+=v; - cnt++; - } - if (cnt==0) return; - sh/=cnt; - ss/=cnt; - sv/=cnt; - wBarva.SetRange(0,359); - wBarva.SetPos((int)sh); - wSitost.SetRange(0,100); - wSitost.SetPos((int)(ss*100)); - wJas.SetRange(0,100); - wJas.SetPos((int)(sv*100)); - _curh=sh,_curv=sv,_curs=ss; - memcpy(_paletteScrl,_palette,768); - -} - -void CEditPaletteDlg::OnPaleta() -{ - CalculateAvgHSV(); -} - -void CEditPaletteDlg::OnCancel() -{ - memcpy(_palette,_paletteUndo,768); - wPaleta.Invalidate(FALSE); - _imgView->SetPalette(_palette); - _imgView->Invalidate(FALSE); - CDialog::OnCancel(); -} - -void CEditPaletteDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) -{ - float h,s,v; - float difh=wBarva.GetPos()-_curh; - float difs=(wSitost.GetPos()/100.0f)/_curs; - float difv=(wJas.GetPos()/100.0f)/_curv; - for (int i=0;i<256;i++) if (wPaleta.IsSelected(i)) - { - RGBtoHSV(_paletteScrl[i*3]/255.0f,_paletteScrl[i*3+1]/255.0f,_paletteScrl[i*3+2]/255.0f,&h,&s,&v); - if (!_finite(h)) h=0; - h+=difh; - while (h<0) {h+=360.0f;} - while (h>=360.0f) {h-=360.0f;} - if (s>0.001) - s*=difs; - else - s=wSitost.GetPos()/100.0f; - if (v>0.001) - v*=difv; - else - v=wJas.GetPos()/100.0f; - if (s<0) s=0; - if (s>1.0f) s=1.0f; - if (v<0) v=0; - if (v>1.0f) v=1.0f; - float r,g,b; - HSVtoRGB(&r,&g,&b,h,s,v); - _palette[i*3]=(int)(r*255.0f); - _palette[i*3+1]=(int)(g*255.0f); - _palette[i*3+2]=(int)(b*255.0f); - } - wPaleta.Invalidate(FALSE); - wPaleta.UpdateWindow(); - _imgView->SetPalette(_palette); - _imgView->Invalidate(FALSE); - _imgView->UpdateWindow(); -} - -void CEditPaletteDlg::OnUndo() -{ - memcpy(_palette,_paletteScrl,768); - wPaleta.Invalidate(FALSE); - _imgView->SetPalette(_palette); - _imgView->Invalidate(FALSE); -} diff --git a/mapedit/ColEdit/EditPaletteDlg.h b/mapedit/ColEdit/EditPaletteDlg.h deleted file mode 100644 index a574351..0000000 --- a/mapedit/ColEdit/EditPaletteDlg.h +++ /dev/null @@ -1,63 +0,0 @@ -#if !defined(AFX_EDITPALETTEDLG_H__8ED55BD3_E477_4C1A_80E7_D79CDA43A55E__INCLUDED_) -#define AFX_EDITPALETTEDLG_H__8ED55BD3_E477_4C1A_80E7_D79CDA43A55E__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// EditPaletteDlg.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CEditPaletteDlg dialog - -#include "PaletteEditor.h" -#include "..\Podlahar\ImageView.h" - -class CEditPaletteDlg : public CDialog -{ -// Construction - char _paletteUndo[768]; - char _paletteScrl[768]; - float _curh,_curv,_curs; -public: - CEditPaletteDlg(CWnd* pParent = NULL); // standard constructor - char *_palette; - CImageView *_imgView; - - -// Dialog Data - //{{AFX_DATA(CEditPaletteDlg) - enum { IDD = IDD_EDITPALETTE }; - CSliderCtrl wSitost; - CSliderCtrl wJas; - CSliderCtrl wBarva; - CPaletteEditor wPaleta; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CEditPaletteDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - void CalculateAvgHSV(); - - // Generated message map functions - //{{AFX_MSG(CEditPaletteDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnPaleta(); - virtual void OnCancel(); - afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - afx_msg void OnUndo(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EDITPALETTEDLG_H__8ED55BD3_E477_4C1A_80E7_D79CDA43A55E__INCLUDED_) diff --git a/mapedit/ColEdit/PaletteEditor.cpp b/mapedit/ColEdit/PaletteEditor.cpp deleted file mode 100644 index 3f41f36..0000000 --- a/mapedit/ColEdit/PaletteEditor.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// PaletteEditor.cpp : implementation file -// - -#include "stdafx.h" -#include "ColEdit.h" -#include "PaletteEditor.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CPaletteEditor - -CPaletteEditor::CPaletteEditor() -{ - memset(_selection,0,sizeof(_selection)); -} - -CPaletteEditor::~CPaletteEditor() -{ -} - - -BEGIN_MESSAGE_MAP(CPaletteEditor, CStatic) - //{{AFX_MSG_MAP(CPaletteEditor) - ON_WM_PAINT() - ON_WM_LBUTTONDOWN() - ON_WM_MOUSEMOVE() - ON_WM_LBUTTONUP() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPaletteEditor message handlers - -void CPaletteEditor::OnPaint() -{ - CPaintDC dc(this); // device context for painting - CRect rc; - GetClientRect(&rc); - char *p=_palette; - - for (int i=0;i<16;i++) - for (int j=0;j<16;j++) - { - int x1=rc.right*j/16; - int y1=rc.bottom*i/16; - int x2=rc.right*(j+1)/16-1; - int y2=rc.bottom*(i+1)/16-1; - - COLORREF ref=RGB(p[0],p[1],p[2]); - bool white=(p[0]*0.3+p[1]*0.5+p[2]*0.2)<128; - p+=3; - dc.FillSolidRect(x1,y1,x2-x1,y2-y1,ref); - dc.SelectStockObject(white?WHITE_PEN:BLACK_PEN); - if (!_selection[i*16+j]) - { - dc.SelectStockObject(HOLLOW_BRUSH); - dc.Rectangle(x1,y1,x2,y2); - dc.MoveTo(x1,y1);dc.LineTo(x2,y2); - dc.MoveTo(x1,y2);dc.LineTo(x2,y1); - } - } -} - // Do not call CStatic::OnPaint() for painting message} - - -void CPaletteEditor::OnLButtonDown(UINT nFlags, CPoint point) -{ - int pt=IndexFromPoint(point); - if (!(nFlags & MK_CONTROL)) - memset(_selection,0,sizeof(_selection)); - if (pt>=0 && pt<256) - _selection[pt]=!_selection[pt]; - _drawsel=_selection[pt]; - Invalidate(); - SetCapture(); -} - - -void CPaletteEditor::OnMouseMove(UINT nFlags, CPoint point) -{ - if (GetCapture()==this) - { - int pt=IndexFromPoint(point); - if (pt>=0 && pt<256) - _selection[pt]=_drawsel; - Invalidate(); - } -} - -int CPaletteEditor::IndexFromPoint(CPoint pt) -{ - CRect rc; - GetClientRect(&rc); - int x=pt.x*16/rc.right; - int y=pt.y*16/rc.bottom; - int ret=y*16+x; - return ret; -} - -void CPaletteEditor::OnLButtonUp(UINT nFlags, CPoint point) -{ - if (GetCapture()==this) - { - ReleaseCapture(); - GetParent()->SendNotifyMessage(WM_COMMAND,MAKEWPARAM(GetDlgCtrlID(),BN_CLICKED),(LPARAM)GetSafeHwnd()); - } - -} diff --git a/mapedit/ColEdit/PaletteEditor.h b/mapedit/ColEdit/PaletteEditor.h deleted file mode 100644 index 272376c..0000000 --- a/mapedit/ColEdit/PaletteEditor.h +++ /dev/null @@ -1,61 +0,0 @@ -#if !defined(AFX_PALETTEEDITOR_H__45E6ACB6_CCFC_47F4_906C_BF0D2E76E2FE__INCLUDED_) -#define AFX_PALETTEEDITOR_H__45E6ACB6_CCFC_47F4_906C_BF0D2E76E2FE__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// PaletteEditor.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CPaletteEditor window - -class CPaletteEditor : public CStatic -{ -// Construction - char *_palette; - bool _selection[256]; - bool _drawsel; -public: - CPaletteEditor(); - - void SetPalette(char *pal) {_palette=pal;} - bool IsSelected(int p) {return _selection[p];} - int GetR(int p) {return _palette[p*3];} - int GetG(int p) {return _palette[p*3+1];} - int GetB(int p) {return _palette[p*3+2];} - -// Attributes -public: - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CPaletteEditor) - //}}AFX_VIRTUAL - -// Implementation -public: - int IndexFromPoint(CPoint pt); - virtual ~CPaletteEditor(); - - // Generated message map functions -protected: - //{{AFX_MSG(CPaletteEditor) - afx_msg void OnPaint(); - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg void OnLButtonUp(UINT nFlags, CPoint point); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_PALETTEEDITOR_H__45E6ACB6_CCFC_47F4_906C_BF0D2E76E2FE__INCLUDED_) diff --git a/mapedit/ColEdit/StdAfx.cpp b/mapedit/ColEdit/StdAfx.cpp deleted file mode 100644 index d74f23c..0000000 --- a/mapedit/ColEdit/StdAfx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// ColEdit.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/mapedit/ColEdit/StdAfx.h b/mapedit/ColEdit/StdAfx.h deleted file mode 100644 index bb1666b..0000000 --- a/mapedit/ColEdit/StdAfx.h +++ /dev/null @@ -1,26 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__5BFBE43D_BB22_424B_B397_EA20C9E39657__INCLUDED_) -#define AFX_STDAFX_H__5BFBE43D_BB22_424B_B397_EA20C9E39657__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers - -#include // MFC core and standard components -#include // MFC extensions -#include // MFC support for Internet Explorer 4 Common Controls -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__5BFBE43D_BB22_424B_B397_EA20C9E39657__INCLUDED_) diff --git a/mapedit/ColEdit/res/ColEdit.ico b/mapedit/ColEdit/res/ColEdit.ico deleted file mode 100644 index 7eef0bc..0000000 Binary files a/mapedit/ColEdit/res/ColEdit.ico and /dev/null differ diff --git a/mapedit/ColEdit/res/ColEdit.rc2 b/mapedit/ColEdit/res/ColEdit.rc2 deleted file mode 100644 index 867ae26..0000000 --- a/mapedit/ColEdit/res/ColEdit.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// COLEDIT.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/mapedit/ColEdit/res/down.ico b/mapedit/ColEdit/res/down.ico deleted file mode 100644 index 40df50a..0000000 Binary files a/mapedit/ColEdit/res/down.ico and /dev/null differ diff --git a/mapedit/ColEdit/res/icon1.ico b/mapedit/ColEdit/res/icon1.ico deleted file mode 100644 index ae4cff9..0000000 Binary files a/mapedit/ColEdit/res/icon1.ico and /dev/null differ diff --git a/mapedit/ColEdit/resource.h b/mapedit/ColEdit/resource.h deleted file mode 100644 index c9ce4fa..0000000 --- a/mapedit/ColEdit/resource.h +++ /dev/null @@ -1,44 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by ColEdit.rc -// -#define IDM_ABOUTBOX 0x0010 -#define IDD_ABOUTBOX 100 -#define IDS_ABOUTBOX 101 -#define IDD_COLEDIT_DIALOG 102 -#define IDS_PALETANAME 102 -#define IDS_COLFILTER 103 -#define IDS_LOADFAILED 104 -#define IDS_PALFILTER 105 -#define IDS_NOVAPALETA 106 -#define IDS_SAVEFAILED 107 -#define IDR_MAINFRAME 128 -#define IDI_UP 129 -#define IDI_DOWN 130 -#define IDD_EDITPALETTE 131 -#define IDC_COLORLIST 1000 -#define IDC_INSERT 1001 -#define IDC_DELETE 1002 -#define IDC_IMAGE 1003 -#define IDC_LOAD 1004 -#define IDC_IMAGESEL 1005 -#define IDC_DUPLICATE 1006 -#define IDC_BARVA 1006 -#define IDC_UP 1007 -#define IDC_SITOST 1007 -#define IDC_DOWN 1008 -#define IDC_JAS 1008 -#define IDC_PALETA 1009 -#define IDC_OPRAVPALETU 1010 -#define IDC_UNDO 1011 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 132 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1012 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/mapedit/ItemIcons/DlgOpen.cpp b/mapedit/ItemIcons/DlgOpen.cpp deleted file mode 100644 index 4d739bb..0000000 --- a/mapedit/ItemIcons/DlgOpen.cpp +++ /dev/null @@ -1,184 +0,0 @@ -// DlgOpen.cpp : implementation file -// - -#include "stdafx.h" -#include "ItemIcons.h" -#include "iconviewerbutton.h" -#include "DlgOpen.h" - - -// DlgOpen dialog - -IMPLEMENT_DYNAMIC(DlgOpen, CDialog) -DlgOpen::DlgOpen(CWnd* pParent /*=NULL*/) - : CDialog(DlgOpen::IDD, pParent) -{ -} - -DlgOpen::~DlgOpen() -{ -} - -void DlgOpen::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - for (int i=0;i<18;i++) - DDX_Control(pDX, IDC_ICON1+i, icons[i]); - DDX_Control(pDX, IDC_LIST, wList); -} - - -BEGIN_MESSAGE_MAP(DlgOpen, CDialog) - ON_BN_CLICKED(IDC_BROWSE, OnBnClickedBrowse) - ON_LBN_DBLCLK(IDC_LIST, OnLbnDblclkList) - ON_WM_DESTROY() - ON_LBN_SELCHANGE(IDC_LIST, OnLbnSelchangeList) -END_MESSAGE_MAP() - - -// DlgOpen message handlers - -BOOL DlgOpen::OnInitDialog() -{ - CDialog::OnInitDialog(); - ReadFolder(); - _iconlib=new char[ICONLIBSIZE]; - ZeroMemory(_iconlib,ICONLIBSIZE); - for (int i=0;i<18;i++) icons[i]._data=GETICONADDR(i); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void DlgOpen::ReadFolder(void) -{ - wList.ResetContent(); - CFileFind fnd; - BOOL ok=fnd.FindFile(_umisteni+_T("ikony*.lib")); - while (ok) - { - ok=fnd.FindNextFile(); - wList.AddString(fnd.GetFileName()); - } - CString createnew; - createnew.LoadString(IDS_CREATENEW); - int index=wList.AddString(createnew); - wList.SetItemData(index,1); -} - -static int WINAPI PosBrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lParam,LPARAM lpData) - { - const _TCHAR *curpath=(const _TCHAR *)lpData; - if (uMsg == BFFM_INITIALIZED) - { - if (curpath && curpath[0]) - { - ::SendMessage(hwnd,BFFM_SETSELECTION,TRUE,(LPARAM)((LPCSTR)curpath)); - ::SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)((LPCSTR)curpath)); - } - } - else if (uMsg == BFFM_SELCHANGED) - { - _TCHAR buff[_MAX_PATH]; - if (SHGetPathFromIDList((LPITEMIDLIST)lParam,buff)) - { - ::SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)buff); - } - } - return 0; - }; - -static bool PathBrowser(HWND hWnd, _TCHAR *path /* MAX_PATH size */) -{ - BROWSEINFO brw; - memset(&brw,0,sizeof(brw)); - brw.hwndOwner=hWnd; - brw.pidlRoot=NULL; - brw.pszDisplayName=path; - brw.lParam=(LPARAM)path; - brw.ulFlags= BIF_RETURNONLYFSDIRS |BIF_STATUSTEXT|BIF_USENEWUI ; - brw.lpfn = (BFFCALLBACK)(PosBrowseCallbackProc); - LPITEMIDLIST il=SHBrowseForFolder( &brw ); - if (il==NULL) return false; - SHGetPathFromIDList(il,path); - IMalloc *shmalloc; - SHGetMalloc(&shmalloc); - shmalloc->Free(il); - if (path[0]==0) return false; - return true; -} - - -void DlgOpen::OnBnClickedBrowse() -{ - _TCHAR buffer[MAX_PATH+1]; - _tcsncpy(buffer,_umisteni,MAX_PATH); - if (PathBrowser(*this,buffer)) - _umisteni=buffer; - if (_umisteni.GetLength() && _umisteni[_umisteni.GetLength()-1]!='\\') - _umisteni=_umisteni+'\\'; - ReadFolder(); -} - -void DlgOpen::OnOK() -{ - int sel=wList.GetCurSel(); - if (sel<0) return; - CString name; - if (wList.GetItemData(sel)==1) - { - int i=-1; - do - { - i++; - name.Format(_T("IKONY%02d.LIB"),i); - _selected=_umisteni+name; - } - while (_tcheck_file_exists( _selected)==0); - } - else - { - wList.GetText(sel,name); - _selected=_umisteni+name; - } - CDialog::OnOK(); -} - - -CString DlgOpen::GetSelectedFile() -{ - return _selected; -} - -void DlgOpen::OnLbnDblclkList() -{ -OnOK(); -} - -void DlgOpen::OnDestroy() -{ - delete [] _iconlib; -} - -void DlgOpen::OnLbnSelchangeList() -{ - ZeroMemory(_iconlib,ICONLIBSIZE); - int sel=wList.GetCurSel(); - if (sel>=0) - { - CString name; - if (wList.GetItemData(sel)!=1) - { - wList.GetText(sel,name); - _selected=_umisteni+name; - HANDLE h=CreateFile(_selected,GENERIC_READ,0,0,OPEN_EXISTING,0,0); - if (h!=INVALID_HANDLE_VALUE) - { - DWORD rd; - ReadFile(h,_iconlib,ICONLIBSIZE,&rd,0); - CloseHandle(h); - } - } - } - for (int i=0;i<18;i++) icons[i].Invalidate(); -} diff --git a/mapedit/ItemIcons/DlgOpen.h b/mapedit/ItemIcons/DlgOpen.h deleted file mode 100644 index a48f516..0000000 --- a/mapedit/ItemIcons/DlgOpen.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -#include "afxwin.h" - - -// DlgOpen dialog - -class DlgOpen : public CDialog -{ - DECLARE_DYNAMIC(DlgOpen) - CString _umisteni; - CString _selected; - char *_iconlib; - CIconViewerButton icons[18]; - -public: - DlgOpen(CWnd* pParent = NULL); // standard constructor - virtual ~DlgOpen(); - -// Dialog Data - enum { IDD = IDD_OPENDLG }; - -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - - - DECLARE_MESSAGE_MAP() -public: - virtual BOOL OnInitDialog(); - void ReadFolder(void); - CListBox wList; - afx_msg void OnBnClickedBrowse(); - CString GetSelectedFile(); -protected: - virtual void OnOK(); -public: - afx_msg void OnLbnDblclkList(); - afx_msg void OnDestroy(); - afx_msg void OnLbnSelchangeList(); -}; diff --git a/mapedit/ItemIcons/IconViewerButton.cpp b/mapedit/ItemIcons/IconViewerButton.cpp deleted file mode 100644 index 64d3424..0000000 --- a/mapedit/ItemIcons/IconViewerButton.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// IconViewerButton.cpp : implementation file -// - -#include "stdafx.h" -#include "ItemIcons.h" -#include "IconViewerButton.h" -#include ".\iconviewerbutton.h" - - -// CIconViewerButton - -IMPLEMENT_DYNAMIC(CIconViewerButton, CStatic) -CIconViewerButton::CIconViewerButton() -{ -} - -CIconViewerButton::~CIconViewerButton() -{ -} - - -BEGIN_MESSAGE_MAP(CIconViewerButton, CStatic) - ON_WM_PAINT() - ON_WM_SETCURSOR() -END_MESSAGE_MAP() - - - -// CIconViewerButton message handlers - - - -void CIconViewerButton::OnPaint() -{ - unsigned short *data=reinterpret_cast(_data); - if (data[0]!=45 && data[1]!=55 && data[2]!=8) - { - __super::OnPaint(); - return; - } - - - BitMapInfo bmpinfo; - ZeroMemory(&bmpinfo,sizeof(bmpinfo)); - bmpinfo.hdr.biSize=sizeof(bmpinfo.hdr); - bmpinfo.hdr.biBitCount=8; - bmpinfo.hdr.biCompression=BI_RGB; - bmpinfo.hdr.biHeight=55; - bmpinfo.hdr.biPlanes=1; - bmpinfo.hdr.biWidth=45; - for (int i=0;i<256;i++) - { - RGBQUAD &col=bmpinfo.palette[i]; - col.rgbBlue=(data[i+3] & 0x1F)<<3; - col.rgbGreen=(data[i+3] & 0x3E0)>>2; - col.rgbRed=(data[i+3] & 0x7C00)>>7; - col.rgbReserved=0; - } - - bmpinfo.palette[0].rgbBlue=80; - bmpinfo.palette[0].rgbGreen=70; - bmpinfo.palette[0].rgbRed=60; - - char bitmap[55][48]; - char *p=reinterpret_cast(data+3+256); - for (int i=0;i<55;i++,p+=45) memcpy(bitmap[55-i-1],p,45); - - CPaintDC dc(this); - CRect rc; - GetClientRect(&rc); - dc.SetStretchBltMode(HALFTONE); - StretchDIBits(dc,0,0,rc.right,rc.bottom,0,0,45,55,bitmap,reinterpret_cast(&bmpinfo),DIB_RGB_COLORS,SRCCOPY); -} - -BOOL CIconViewerButton::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) -{ - if (pWnd==this) - { - HCURSOR h=LoadCursor(0,IDC_HAND); - ::SetCursor(h); - return TRUE; - } - else - return __super::OnSetCursor(pWnd,nHitTest,message); - -} diff --git a/mapedit/ItemIcons/IconViewerButton.h b/mapedit/ItemIcons/IconViewerButton.h deleted file mode 100644 index e7df456..0000000 --- a/mapedit/ItemIcons/IconViewerButton.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - - -// CIconViewerButton - - struct BitMapInfo - { - BITMAPINFOHEADER hdr; - RGBQUAD palette[256]; - }; - - -class CIconViewerButton : public CStatic -{ - DECLARE_DYNAMIC(CIconViewerButton) - -public: - CIconViewerButton(); - virtual ~CIconViewerButton(); - - void *_data; - -protected: - DECLARE_MESSAGE_MAP() -public: - afx_msg void OnPaint(); - afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); -}; - - diff --git a/mapedit/ItemIcons/ItemIcons.cpp b/mapedit/ItemIcons/ItemIcons.cpp deleted file mode 100644 index d62a712..0000000 --- a/mapedit/ItemIcons/ItemIcons.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// ItemIcons.cpp : Defines the class behaviors for the application. -// - -#include "stdafx.h" -#include "ItemIcons.h" -#include "ItemIconsDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CItemIconsApp - -BEGIN_MESSAGE_MAP(CItemIconsApp, CWinApp) - ON_COMMAND(ID_HELP, CWinApp::OnHelp) -END_MESSAGE_MAP() - - -// CItemIconsApp construction - -CItemIconsApp::CItemIconsApp() -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - - -// The one and only CItemIconsApp object - -CItemIconsApp theApp; - - -// CItemIconsApp initialization - -BOOL CItemIconsApp::InitInstance() -{ - // InitCommonControls() is required on Windows XP if an application - // manifest specifies use of ComCtl32.dll version 6 or later to enable - // visual styles. Otherwise, any window creation will fail. - InitCommonControls(); - - CWinApp::InitInstance(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need - // Change the registry key under which our settings are stored - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization - SetRegistryKey(_T("Local AppWizard-Generated Applications")); - - CItemIconsDlg dlg; - m_pMainWnd = &dlg; - INT_PTR nResponse = dlg.DoModal(); - if (nResponse == IDOK) - { - // TODO: Place code here to handle when the dialog is - // dismissed with OK - } - else if (nResponse == IDCANCEL) - { - // TODO: Place code here to handle when the dialog is - // dismissed with Cancel - } - - // Since the dialog has been closed, return FALSE so that we exit the - // application, rather than start the application's message pump. - return FALSE; -} diff --git a/mapedit/ItemIcons/ItemIcons.h b/mapedit/ItemIcons/ItemIcons.h deleted file mode 100644 index 629029f..0000000 --- a/mapedit/ItemIcons/ItemIcons.h +++ /dev/null @@ -1,31 +0,0 @@ -// ItemIcons.h : main header file for the PROJECT_NAME application -// - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - - -// CItemIconsApp: -// See ItemIcons.cpp for the implementation of this class -// - -class CItemIconsApp : public CWinApp -{ -public: - CItemIconsApp(); - -// Overrides - public: - virtual BOOL InitInstance(); - -// Implementation - - DECLARE_MESSAGE_MAP() -}; - -extern CItemIconsApp theApp; \ No newline at end of file diff --git a/mapedit/ItemIcons/ItemIcons.rc b/mapedit/ItemIcons/ItemIcons.rc deleted file mode 100644 index 6352fa1..0000000 --- a/mapedit/ItemIcons/ItemIcons.rc +++ /dev/null @@ -1,354 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Czech resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CSY) -#ifdef _WIN32 -LANGUAGE LANG_CZECH, SUBLANG_DEFAULT -#pragma code_page(1250) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_SPLITTER_RESOURCES\r\n" - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1250)\r\n" - "#include ""res\\ItemIcons.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\ItemIcons.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_OPENDLG DIALOGEX 0, 0, 390, 175 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | - WS_SYSMENU -CAPTION "Otevřít knihovnu ikon" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Otevřít",IDOK,7,118,92,14 - PUSHBUTTON "Cancel",IDCANCEL,7,153,91,14 - LISTBOX IDC_LIST,7,7,92,105,LBS_SORT | LBS_NOINTEGRALHEIGHT | - WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Vybrat jiné umístění",IDC_BROWSE,7,135,92,14 - CTEXT "",IDC_ICON1,104,6,44,51,SS_NOTIFY | SS_CENTERIMAGE - CTEXT "",IDC_ICON2,151,6,44,51,SS_NOTIFY | SS_CENTERIMAGE - CTEXT "",IDC_ICON3,198,6,44,51,SS_NOTIFY | SS_CENTERIMAGE - CTEXT "",IDC_ICON4,245,6,44,51,SS_NOTIFY | SS_CENTERIMAGE - CTEXT "",IDC_ICON5,292,6,44,51,SS_NOTIFY | SS_CENTERIMAGE - CTEXT "",IDC_ICON6,339,6,44,51,SS_NOTIFY | SS_CENTERIMAGE - CTEXT "",IDC_ICON7,104,62,44,51,SS_NOTIFY | SS_CENTERIMAGE - CTEXT "",IDC_ICON8,151,62,44,51,SS_NOTIFY | SS_CENTERIMAGE - CTEXT "Náhled",IDC_ICON9,198,62,44,51,SS_NOTIFY | - SS_CENTERIMAGE - CTEXT "",IDC_ICON10,245,62,44,51,SS_NOTIFY | SS_CENTERIMAGE - CTEXT "",IDC_ICON11,292,62,44,51,SS_NOTIFY | SS_CENTERIMAGE - CTEXT "",IDC_ICON12,339,62,44,51,SS_NOTIFY | SS_CENTERIMAGE - CTEXT "",IDC_ICON13,104,118,44,51,SS_NOTIFY | SS_CENTERIMAGE - CTEXT "",IDC_ICON14,151,118,44,51,SS_NOTIFY | SS_CENTERIMAGE - CTEXT "",IDC_ICON15,198,118,44,51,SS_NOTIFY | SS_CENTERIMAGE - CTEXT "",IDC_ICON16,245,118,44,51,SS_NOTIFY | SS_CENTERIMAGE - CTEXT "",IDC_ICON17,292,118,44,51,SS_NOTIFY | SS_CENTERIMAGE - CTEXT "",IDC_ICON18,339,118,44,51,SS_NOTIFY | SS_CENTERIMAGE -END - -IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | - WS_SYSMENU -CAPTION "About ItemIcons" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "ItemIcons Version 1.0",IDC_STATIC,40,10,119,8, - SS_NOPREFIX - LTEXT "Copyright (C) 2005",IDC_STATIC,40,25,119,8 - DEFPUSHBUTTON "OK",IDOK,178,7,50,16,WS_GROUP -END - -IDD_ITEMICONS_DIALOG DIALOGEX 0, 0, 299, 224 -STYLE DS_SETFONT | DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | - WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_ACCEPTFILES | WS_EX_APPWINDOW -CAPTION "Icon Library" -MENU IDR_MAINMENU -FONT 10, "Microsoft Sans Serif", 400, 0, 0xEE -BEGIN - CTEXT "",IDC_ICON1,7,35,45,55,SS_NOTIFY | SS_CENTERIMAGE, - WS_EX_STATICEDGE - CTEXT "",IDC_ICON2,55,35,45,55,SS_NOTIFY | SS_CENTERIMAGE, - WS_EX_STATICEDGE - CTEXT "",IDC_ICON3,103,35,45,55,SS_NOTIFY | - SS_CENTERIMAGE,WS_EX_STATICEDGE - CTEXT "",IDC_ICON4,151,35,45,55,SS_NOTIFY | - SS_CENTERIMAGE,WS_EX_STATICEDGE - CTEXT "",IDC_ICON5,199,35,45,55,SS_NOTIFY | - SS_CENTERIMAGE,WS_EX_STATICEDGE - CTEXT "",IDC_ICON6,247,35,45,55,SS_NOTIFY | - SS_CENTERIMAGE,WS_EX_STATICEDGE - CTEXT "",IDC_ICON7,7,92,45,55,SS_NOTIFY | SS_CENTERIMAGE, - WS_EX_STATICEDGE - CTEXT "",IDC_ICON8,55,92,45,55,SS_NOTIFY | SS_CENTERIMAGE, - WS_EX_STATICEDGE - CTEXT "",IDC_ICON9,103,92,45,55,SS_NOTIFY | - SS_CENTERIMAGE,WS_EX_STATICEDGE - CTEXT "",IDC_ICON10,151,92,45,55,SS_NOTIFY | - SS_CENTERIMAGE,WS_EX_STATICEDGE - CTEXT "",IDC_ICON11,199,92,45,55,SS_NOTIFY | - SS_CENTERIMAGE,WS_EX_STATICEDGE - CTEXT "",IDC_ICON12,247,92,45,55,SS_NOTIFY | - SS_CENTERIMAGE,WS_EX_STATICEDGE - CTEXT "",IDC_ICON13,7,150,45,55,SS_NOTIFY | - SS_CENTERIMAGE,WS_EX_STATICEDGE - CTEXT "",IDC_ICON14,55,150,45,55,SS_NOTIFY | - SS_CENTERIMAGE,WS_EX_STATICEDGE - CTEXT "",IDC_ICON15,103,150,45,55,SS_NOTIFY | - SS_CENTERIMAGE,WS_EX_STATICEDGE - CTEXT "",IDC_ICON16,151,150,45,55,SS_NOTIFY | - SS_CENTERIMAGE,WS_EX_STATICEDGE - CTEXT "",IDC_ICON17,199,150,45,55,SS_NOTIFY | - SS_CENTERIMAGE,WS_EX_STATICEDGE - CTEXT "",IDC_ICON18,247,150,45,55,SS_NOTIFY | - SS_CENTERIMAGE,WS_EX_STATICEDGE - LTEXT "Jméno souboru",IDC_STATIC,7,6,50,11 - EDITTEXT IDC_FILENAME,7,17,285,12,ES_AUTOHSCROLL | ES_READONLY - CONTROL "Při vkládání do knihovny vybrat vhodnou transparetní barvu.", - IDC_TRANSPARENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6, - 208,193,10 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_OPENDLG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 383 - TOPMARGIN, 7 - BOTTOMMARGIN, 168 - END - - IDD_ABOUTBOX, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 228 - TOPMARGIN, 7 - BOTTOMMARGIN, 48 - END - - IDD_ITEMICONS_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 292 - TOPMARGIN, 6 - BOTTOMMARGIN, 217 - HORZGUIDE, 17 - HORZGUIDE, 29 - HORZGUIDE, 35 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINMENU MENUEX -BEGIN - MENUITEM "&Otevřít", ID_OPEN,MFT_STRING,MFS_ENABLED - MENUITEM "&Uložit!", ID_SAVE,MFT_STRING,MFS_ENABLED - POPUP "Ú&pravy", 65535,MFT_STRING,MFS_ENABLED - BEGIN - MENUITEM "&Kopírovat", 57634,MFT_STRING,MFS_ENABLED - MENUITEM "&Vloži", 57637,MFT_STRING,MFS_ENABLED - MENUITEM "V&ymazat", ID_EDIT_DELETE,MFT_STRING, - MFS_ENABLED - MENUITEM MFT_SEPARATOR - MENUITEM "Kopírovat &do souboru", 32792,MFT_STRING,MFS_ENABLED - MENUITEM "Vložit ze &souboru", 32793,MFT_STRING,MFS_ENABLED - MENUITEM MFT_SEPARATOR - MENUITEM "Kopírovat vš&e do souboru", 32794,MFT_STRING,MFS_ENABLED - END - MENUITEM "O &Aplikaci!", 32779, - MFT_STRING | MFT_RIGHTJUSTIFY,MFS_ENABLED -END - -IDR_POPUP MENU -BEGIN - POPUP "Popup" - BEGIN - MENUITEM "Import BMP", ID_POPUP_IMPORTBMP - MENUITEM "Export BMP", ID_POPUP_EXPORTBMP - MENUITEM SEPARATOR - MENUITEM "Copy", ID_POPUP_COPY - MENUITEM "Paste", ID_POPUP_PASTE - MENUITEM SEPARATOR - MENUITEM "Vymazat", ID_POPUP_VYMAZAT - END - POPUP "List" - BEGIN - MENUITEM "Obrázek", 1 - MENUITEM "Obrázek", 7 - MENUITEM "Obrázek", 13 - MENUITEM "Obrázek", 2, MENUBREAK - MENUITEM "Obrázek", 8 - MENUITEM "Obrázek", 14 - MENUITEM "Obrázek", 3, MENUBREAK - MENUITEM "Obrázek", 9 - MENUITEM "Obrázek", 15 - MENUITEM "Obrázek", 4, MENUBREAK - MENUITEM "Obrázek", 10 - MENUITEM "Obrázek", 16 - MENUITEM "Obrázek", 5, MENUBREAK - MENUITEM "Obrázek", 11 - MENUITEM "Obrázek", 17 - MENUITEM "Obrázek", 6, MENUBREAK - MENUITEM "Obrázek", 12 - MENUITEM "Obrázek", 18 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040504e4" - BEGIN - VALUE "CompanyName", "TODO: " - VALUE "FileDescription", "TODO: " - VALUE "FileVersion", "1.0.0.1" - VALUE "InternalName", "ItemIcons.exe" - VALUE "LegalCopyright", "TODO: (c) . All rights reserved." - VALUE "OriginalFilename", "ItemIcons.exe" - VALUE "ProductName", "TODO: " - VALUE "ProductVersion", "1.0.0.1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x405, 1250 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDS_ABOUTBOX "&About ItemIcons..." - IDS_CREATENEW "" - IDS_CHYBNYFORMAT "Chybný formát obrázku. Povolen je pouze obrázek ve formátě Windows BMP o rozměrech 45x55 a bitové hloubce 8bit (256 barev) - bez kompresse" - IDS_CHYBAPRIULOZENI "Nepodařilo se uložit knihovnu." -END - -STRINGTABLE -BEGIN - IDS_BMPFILTER "Obrázky v BMP (*.BMP - 45 x 55 x 256 barev)|*.bmp||" - IDS_NEPLATNYFORMATBMP "Soubor nebyl rozpoznán jako BMP" - IDS_NELZEOTEVRITSOUBOR "Soubor se nepodařilo otevřít" - IDS_CHYBAPRIZAPISU "Nastala nejaka chyba pri zapisu. Obrazek se nepodarilo ulozit" -END - -#endif // Czech resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 -#pragma code_page(1250) -#include "res\ItemIcons.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/mapedit/ItemIcons/ItemIcons.sln b/mapedit/ItemIcons/ItemIcons.sln deleted file mode 100644 index 0e97678..0000000 --- a/mapedit/ItemIcons/ItemIcons.sln +++ /dev/null @@ -1,30 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ItemIcons", "ItemIcons.vcproj", "{ADB487B3-9F9B-4B49-8B02-92F8B2B5D563}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SourceCodeControl) = preSolution - SccNumberOfProjects = 2 - SccLocalPath0 = . - CanCheckoutShared = false - SolutionUniqueID = {B21D216F-7A5B-43A2-BED6-A3AB49EF2F3D} - SccProjectUniqueName1 = ItemIcons.vcproj - SccLocalPath1 = . - CanCheckoutShared = false - EndGlobalSection - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {ADB487B3-9F9B-4B49-8B02-92F8B2B5D563}.Debug.ActiveCfg = Debug|Win32 - {ADB487B3-9F9B-4B49-8B02-92F8B2B5D563}.Debug.Build.0 = Debug|Win32 - {ADB487B3-9F9B-4B49-8B02-92F8B2B5D563}.Release.ActiveCfg = Release|Win32 - {ADB487B3-9F9B-4B49-8B02-92F8B2B5D563}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/mapedit/ItemIcons/ItemIcons.vcproj b/mapedit/ItemIcons/ItemIcons.vcproj deleted file mode 100644 index e6c5617..0000000 --- a/mapedit/ItemIcons/ItemIcons.vcproj +++ /dev/null @@ -1,208 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mapedit/ItemIcons/ItemIconsDlg.cpp b/mapedit/ItemIcons/ItemIconsDlg.cpp deleted file mode 100644 index c4800ad..0000000 --- a/mapedit/ItemIcons/ItemIconsDlg.cpp +++ /dev/null @@ -1,554 +0,0 @@ -// ItemIconsDlg.cpp : implementation file -// - - -#include "stdafx.h" -#include "ItemIcons.h" -#include "ItemIconsDlg.h" -#include ".\itemiconsdlg.h" -#include "DlgOpen.h" -#include - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - enum { IDD = IDD_ABOUTBOX }; - - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -public: -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) -END_MESSAGE_MAP() - - -// CItemIconsDlg dialog - - - -CItemIconsDlg::CItemIconsDlg(CWnd* pParent /*=NULL*/) - : CDialog(CItemIconsDlg::IDD, pParent) - , _selicon(0) -{ - m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); -} - -void CItemIconsDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - for (int i=0;i<18;i++) - DDX_Control(pDX, IDC_ICON1+i, icons[i]); - DDX_Control(pDX, IDC_FILENAME, wFilename); -} - -BEGIN_MESSAGE_MAP(CItemIconsDlg, CDialog) - ON_WM_SYSCOMMAND() - ON_WM_PAINT() - ON_WM_QUERYDRAGICON() - //}}AFX_MSG_MAP - ON_COMMAND(ID_OPEN, OnOpen) - ON_WM_CONTEXTMENU() - ON_COMMAND(ID_POPUP_PASTE, OnPopupPaste) - ON_COMMAND(ID_POPUP_COPY, OnPopupCopy) - ON_COMMAND(ID_POPUP_IMPORTBMP, OnPopupImportbmp) - ON_WM_DROPFILES() - ON_COMMAND(ID_POPUP_EXPORTBMP, OnPopupExportbmp) - ON_COMMAND(ID_EDIT_COPY, OnEditCopy) - ON_COMMAND(ID_EDIT_PASTE, OnEditPaste) - ON_COMMAND_RANGE(IDC_ICON1,IDC_ICON18,OnClickIcon) - ON_COMMAND(ID_EDIT_EXPORT, OnEditExport) - ON_COMMAND(ID_EDIT_IMPORT, OnEditImport) - ON_COMMAND(ID_EDIT_EXPORTALL, OnEditExportall) - ON_COMMAND(ID_SAVE, OnSave) - ON_COMMAND(ID_POPUP_VYMAZAT, OnPopupVymazat) - ON_COMMAND(ID_EDIT_DELETE, OnEditDelete) -END_MESSAGE_MAP() - - -// CItemIconsDlg message handlers - -BOOL CItemIconsDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // Add "About..." menu item to system menu. - - // IDM_ABOUTBOX must be in the system command range. - ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); - ASSERT(IDM_ABOUTBOX < 0xF000); - - CMenu* pSysMenu = GetSystemMenu(FALSE); - if (pSysMenu != NULL) - { - CString strAboutMenu; - strAboutMenu.LoadString(IDS_ABOUTBOX); - if (!strAboutMenu.IsEmpty()) - { - pSysMenu->AppendMenu(MF_SEPARATOR); - pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); - } - } - - // Set the icon for this dialog. The framework does this automatically - // when the application's main window is not a dialog - SetIcon(m_hIcon, TRUE); // Set big icon - SetIcon(m_hIcon, FALSE); // Set small icon - - // TODO: Add extra initialization here - ZeroMemory(_iconlib,sizeof(_iconlib)); - for (int i=0;i<18;i++) icons[i]._data=_iconlib+i*ICONSIZE; - CheckDlgButton(IDC_TRANSPARENT,1); - return TRUE; // return TRUE unless you set the focus to a control -} - -void CItemIconsDlg::OnSysCommand(UINT nID, LPARAM lParam) -{ - if ((nID & 0xFFF0) == IDM_ABOUTBOX) - { - CAboutDlg dlgAbout; - dlgAbout.DoModal(); - } - else - { - CDialog::OnSysCommand(nID, lParam); - } -} - -// If you add a minimize button to your dialog, you will need the code below -// to draw the icon. For MFC applications using the document/view model, -// this is automatically done for you by the framework. - -void CItemIconsDlg::OnPaint() -{ - if (IsIconic()) - { - CPaintDC dc(this); // device context for painting - - SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); - - // Center icon in client rectangle - int cxIcon = GetSystemMetrics(SM_CXICON); - int cyIcon = GetSystemMetrics(SM_CYICON); - CRect rect; - GetClientRect(&rect); - int x = (rect.Width() - cxIcon + 1) / 2; - int y = (rect.Height() - cyIcon + 1) / 2; - - // Draw the icon - dc.DrawIcon(x, y, m_hIcon); - } - else - { - CDialog::OnPaint(); - } -} - -// The system calls this function to obtain the cursor to display while the user drags -// the minimized window. -HCURSOR CItemIconsDlg::OnQueryDragIcon() -{ - return static_cast(m_hIcon); -} - -void CItemIconsDlg::OnOpen() -{ - if (_dlgOpen.DoModal()==IDOK) - { - CString name=_dlgOpen.GetSelectedFile(); - LoadDocument(name); - } -} - -bool CItemIconsDlg::LoadDocument(const CString & name) -{ - _documentName=name; - wFilename.SetWindowText(name); - HANDLE h=CreateFile(name,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,0,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0); - if (h==INVALID_HANDLE_VALUE) - { - ZeroMemory(_iconlib,sizeof(_iconlib)); - for (int i=0;i<18;i++) - { - unsigned short *data=reinterpret_cast(_iconlib+i*ICONSIZE); - data[0]=45; - data[1]=55; - data[2]=8; - } - } - else - { - DWORD rd; - ReadFile(h,_iconlib,ICONLIBSIZE,&rd,0); - CloseHandle(h); - } - for (int i=0;i<18;i++) icons[i].Invalidate(TRUE); - return true; -} - -void CItemIconsDlg::OnContextMenu(CWnd* pWnd, CPoint point) -{ - _selicon=IconFromWnd(pWnd); - if (_selicon!=-1) - { - CMenu mnu; - mnu.LoadMenu(IDR_POPUP); - CMenu *sub=mnu.GetSubMenu(0); - sub->TrackPopupMenu(TPM_RIGHTBUTTON,point.x,point.y,this,0); - } -} - -int CItemIconsDlg::IconFromWnd(CWnd * wnd) -{ - for (int i=0;i<18;i++) if (icons+i==wnd) return i; - return -1; -} - -int CItemIconsDlg::ImportBMP(int icon,void *bmp, int dataoffset) -{ - BITMAPINFO *binfo=reinterpret_cast(bmp); - char *data=reinterpret_cast(bmp)+dataoffset; - if (binfo->bmiHeader.biBitCount==8 && binfo->bmiHeader.biWidth==45 && binfo->bmiHeader.biHeight==55 && binfo->bmiHeader.biCompression==BI_RGB) - { - unsigned short *pal=GETICONPAL(icon); - char *bits=GETICONBITS(icon); - for (int i=0;i<256;i++) - pal[i]=(((unsigned)binfo->bmiColors[i].rgbRed>>3)<<10)| - (((unsigned)binfo->bmiColors[i].rgbGreen>>3)<<5)| - (((unsigned)binfo->bmiColors[i].rgbBlue>>3)); - for (int i=0;i<55;i++,data+=3) - { - bits=GETICONBITS(icon)+(55-i-1)*45; - for (int j=0;j<45;j++) - *bits++=*data++; - } - if (IsDlgButtonChecked(IDC_TRANSPARENT)) AutodetectTransparent(icon); - } - else - AfxMessageBox(IDS_CHYBNYFORMAT); - icons[icon].Invalidate(); - return 0; -} - -void CItemIconsDlg::OnPopupPaste() -{ - OpenClipboard(); - HANDLE h=GetClipboardData(CF_DIB); - if (h) - { - LPVOID v=GlobalLock(h); - ImportBMP(_selicon,v,sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)*256); - GlobalUnlock(h); - } - CloseClipboard(); -} - -void CItemIconsDlg::OnPopupCopy() -{ - HANDLE buff=GlobalAlloc(GHND, sizeof(BitMapInfo)+48*55); - BITMAPINFO *bmp=reinterpret_cast(GlobalLock(buff)); - ExportBMP(_selicon,bmp); - GlobalUnlock(buff); - OpenClipboard(); - EmptyClipboard(); - SetClipboardData(CF_DIB,buff); - CloseClipboard(); -} - -void CItemIconsDlg::ExportBMP(int icon, BITMAPINFO * bitmap) -{ - BitMapInfo &bmpinfo=*reinterpret_cast(bitmap); - - ZeroMemory(&bmpinfo,sizeof(bmpinfo)); - bmpinfo.hdr.biSize=sizeof(bmpinfo.hdr); - bmpinfo.hdr.biBitCount=8; - bmpinfo.hdr.biCompression=BI_RGB; - bmpinfo.hdr.biHeight=55; - bmpinfo.hdr.biPlanes=1; - bmpinfo.hdr.biWidth=45; - unsigned short *pal=GETICONPAL(icon); - for (int i=0;i<256;i++) - { - RGBQUAD &col=bmpinfo.palette[i]; - col.rgbBlue=(pal[i] & 0x1F)<<3; - col.rgbGreen=(pal[i] & 0x3E0)>>2; - col.rgbRed=(pal[i] & 0x7C00)>>7; - col.rgbReserved=0; - } - char *input=GETICONBITS(icon); - for (int i=0;i<55;i++) - { - char *data=reinterpret_cast(bitmap)+sizeof(bmpinfo)+48*(54-i); - for (int j=0;j<45;j++) - *data++=*input++; - } - -} - -void CItemIconsDlg::OnPopupImportbmp() -{ - CString filter; - filter.LoadString(IDS_BMPFILTER); - CFileDialog fdlg(TRUE,0,0,OFN_HIDEREADONLY|OFN_FILEMUSTEXIST,filter,0); - if (fdlg.DoModal()==IDOK) - { - ImportBMP(fdlg.GetPathName(),_selicon); - } -} - -void CItemIconsDlg::OnDropFiles(HDROP hDropInfo) -{ - CPoint mouse; - DragQueryPoint(hDropInfo,&mouse); -// ScreenToClient(&mouse); - CWnd *wnd=ChildWindowFromPoint(mouse,CWP_SKIPINVISIBLE|CWP_SKIPDISABLED); - int icon=IconFromWnd(wnd); - if (icon!=-1) - { - int index=0; - CString name; - int sz=DragQueryFile(hDropInfo,index,0,0); - while (sz) - { - _TCHAR *buff=name.GetBuffer(sz+1); - DragQueryFile(hDropInfo,index,buff,sz+1); - _TCHAR *ext=_tcsrchr(buff,'.'); - if (ext && _tcsicmp(ext,_T(".BMP"))==0) - ImportBMP(buff,icon); - name.ReleaseBuffer(); - icon++; - if (icon>=18) icon=0; - index++; - sz=DragQueryFile(hDropInfo,index,0,0); - } - } - DragFinish(hDropInfo); -} - -void CItemIconsDlg::ImportBMP(const _TCHAR * name, int icon) -{ - HANDLE h=CreateFile(name,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0); - if (h!=INVALID_HANDLE_VALUE) - { - BITMAPFILEHEADER *hdr=(BITMAPFILEHEADER *)malloc(GetFileSize(h,0)); - DWORD rd; - ReadFile(h,hdr,GetFileSize(h,0),&rd,0); - if (hdr->bfType==MAKEWORD('B','M')) - { - BITMAPINFO *nfo=(BITMAPINFO *)((char *)hdr+sizeof(BITMAPFILEHEADER)); - ImportBMP(icon,nfo,hdr->bfOffBits-sizeof(*hdr)); - } - else - AfxMessageBox(IDS_NEPLATNYFORMATBMP); - free(hdr); - CloseHandle(h); - } - else - AfxMessageBox(IDS_NELZEOTEVRITSOUBOR); -} - -void CItemIconsDlg::ExportBMP(int icon, const _TCHAR * filename) -{ - DWORD sz=48*55+sizeof(BitMapInfo); - char *data=(char *)malloc(sz); - ExportBMP(icon,(BITMAPINFO *)data); - BITMAPFILEHEADER hdr; - ZeroMemory(&hdr,sizeof(hdr)); - hdr.bfType=MAKEWORD('B','M'); - hdr.bfSize=sz; - hdr.bfOffBits=sizeof(hdr)+sizeof(BitMapInfo); - HANDLE h=CreateFile(filename,GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,0,0); - if (h!=INVALID_HANDLE_VALUE) - { - DWORD rd; - WriteFile(h,&hdr,sizeof(hdr),&rd,0); - if (rd!=sizeof(hdr)) - { - AfxMessageBox(IDS_CHYBAPRIZAPISU); - } - else - { - WriteFile(h,data,sz,&rd,0); - if (sz!=rd) - { - AfxMessageBox(IDS_CHYBAPRIZAPISU); - } - } - CloseHandle(h); - } - else - AfxMessageBox(IDS_NELZEOTEVRITSOUBOR); -} - -void CItemIconsDlg::OnPopupExportbmp() -{ - CString filter; - filter.LoadString(IDS_BMPFILTER); - CFileDialog fdlg(FALSE,_T(".BMP"),0,OFN_HIDEREADONLY|OFN_PATHMUSTEXIST,filter,0); - if (fdlg.DoModal()==IDOK) - { - ExportBMP(_selicon,fdlg.GetPathName()); - } -} - -int CItemIconsDlg::ManualSelectPic(void) -{ - CMenu mnu; - mnu.LoadMenu(IDR_POPUP); - CMenu *sub=mnu.GetSubMenu(1); - CPoint pt(0,0); - ClientToScreen(&pt); - int res=sub->TrackPopupMenu(TPM_LEFTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,pt.x,pt.y,this,0); - return res-1; -} - -void CItemIconsDlg::OnEditCopy() -{ - _selicon=ManualSelectPic(); - if (_selicon>=0) OnPopupCopy(); -} - -void CItemIconsDlg::OnEditPaste() -{ - _selicon=ManualSelectPic(); - if (_selicon>=0) OnPopupPaste(); -} - -void CItemIconsDlg::OnClickIcon(UINT cmd) -{ - _selicon=cmd-IDC_ICON1; - OnPopupImportbmp(); -} -void CItemIconsDlg::OnEditExport() -{ - _selicon=ManualSelectPic(); - if (_selicon>=0) OnPopupExportbmp(); -} - -void CItemIconsDlg::OnEditImport() -{ - CString filter; - filter.LoadString(IDS_BMPFILTER); - CFileDialog fdlg(TRUE,0,0,OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT,filter,0); - if (fdlg.DoModal()==IDOK) - { - _selicon=ManualSelectPic(); - POSITION pos=fdlg.GetStartPosition(); - while (pos) - { - ImportBMP(fdlg.GetNextPathName(pos),_selicon); - _selicon=(_selicon+1)%18; - } - } -} - -void CItemIconsDlg::OnEditExportall() -{ - CString filter; - filter.LoadString(IDS_BMPFILTER); - CFileDialog fdlg(FALSE,0,0,OFN_HIDEREADONLY|OFN_PATHMUSTEXIST,filter,0); - if (fdlg.DoModal()==IDOK) - { - CString mask=fdlg.GetPathName()+_T(".%02d.BMP"); - for (int i=0;i<18;i++) - { - CString name; - name.Format(mask,i+1); - ExportBMP(i,name); - } - } -} - -void CItemIconsDlg::OnSave() -{ - if (SaveDocument(_documentName)==false) - { - AfxMessageBox(IDS_CHYBAPRIULOZENI); - } -} - -bool CItemIconsDlg::SaveDocument(const _TCHAR * name) -{ - HANDLE h=CreateFile(name,GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,0,CREATE_ALWAYS,FILE_FLAG_SEQUENTIAL_SCAN,0); - if (h==INVALID_HANDLE_VALUE) - { - return false; - } - else - { - DWORD rd; - WriteFile(h,_iconlib,ICONLIBSIZE,&rd,0); - CloseHandle(h); - return rd==ICONLIBSIZE; - } - -} - -void CItemIconsDlg::OnPopupVymazat() -{ - char *bits=GETICONBITS(_selicon); - ZeroMemory(bits,45*55); - icons[_selicon].Invalidate(); -} - -void CItemIconsDlg::OnEditDelete() -{ - _selicon=ManualSelectPic(); - if (_selicon>=0) OnPopupVymazat(); - -} - -void CItemIconsDlg::SetTransparentIndex(int icon, int index) -{ - if (index==0) return; - unsigned short *pal=GETICONPAL(icon); - char *bits=GETICONBITS(icon); - unsigned short save=pal[index]; - pal[index]=pal[0]; - pal[0]=save; - - for (int i=0;i<45*55;i++,bits++) if (*bits==index) *bits=0;else if (*bits==0) *bits=index; -} - - -void CItemIconsDlg::AutodetectTransparent(int icon) -{ - int stats[256]; - ZeroMemory(stats,sizeof(stats)); - for (int i=0;i<45;i++) - { - stats[*(unsigned char *)(GETICONBITS(icon)+i)]++; - stats[*(unsigned char *)(GETICONBITS(icon)+i+54*45)]++; - } - for (int i=1;i<54;i++) - { - stats[*(unsigned char *)(GETICONBITS(icon)+i*45)]++; - stats[*(unsigned char *)(GETICONBITS(icon)+i*45+44)]++; - } - int max=0,index=0; - for (int i=0;i<256;i++) if (stats[i]>max) {max=stats[i];index=i;} - SetTransparentIndex(icon,index); -} diff --git a/mapedit/ItemIcons/ItemIconsDlg.h b/mapedit/ItemIcons/ItemIconsDlg.h deleted file mode 100644 index a156d80..0000000 --- a/mapedit/ItemIcons/ItemIconsDlg.h +++ /dev/null @@ -1,69 +0,0 @@ -// ItemIconsDlg.h : header file -// - -#pragma once -#include "iconviewerbutton.h" -#include "dlgopen.h" -#include "afxwin.h" - - - -// CItemIconsDlg dialog -class CItemIconsDlg : public CDialog -{ -// Construction -public: - CItemIconsDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - enum { IDD = IDD_ITEMICONS_DIALOG }; - - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - - -// Implementation -protected: - HICON m_hIcon; - - // Generated message map functions - virtual BOOL OnInitDialog(); - afx_msg void OnSysCommand(UINT nID, LPARAM lParam); - afx_msg void OnPaint(); - afx_msg HCURSOR OnQueryDragIcon(); - DECLARE_MESSAGE_MAP() -public: - CIconViewerButton icons[18]; - char _iconlib[ICONLIBSIZE]; - afx_msg void OnOpen(); - DlgOpen _dlgOpen; - CString _documentName; - bool LoadDocument(const CString & name); - CEdit wFilename; - int _selicon; - int IconFromWnd(CWnd * wnd); - int ImportBMP(int icon,void *bmp, int dataoffset); - afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/); - afx_msg void OnPopupPaste(); - afx_msg void OnPopupCopy(); - void ExportBMP(int icon, BITMAPINFO * bitmap); - afx_msg void OnPopupImportbmp(); - afx_msg void OnDropFiles(HDROP hDropInfo); - void ImportBMP(const _TCHAR * name, int icon); - void ExportBMP(int icon, const _TCHAR * filename); - afx_msg void OnPopupExportbmp(); - int ManualSelectPic(void); - afx_msg void OnEditCopy(); - afx_msg void OnEditPaste(); - afx_msg void OnClickIcon(UINT cmd); - afx_msg void OnEditExport(); - afx_msg void OnEditImport(); - afx_msg void OnEditExportall(); - afx_msg void OnSave(); - bool SaveDocument(const _TCHAR * name); - afx_msg void OnPopupVymazat(); - afx_msg void OnEditDelete(); - void SetTransparentIndex(int icon, int index); - void AutodetectTransparent(int icon); -}; - diff --git a/mapedit/ItemIcons/res/ItemIcons.ico b/mapedit/ItemIcons/res/ItemIcons.ico deleted file mode 100644 index 8a84ca3..0000000 Binary files a/mapedit/ItemIcons/res/ItemIcons.ico and /dev/null differ diff --git a/mapedit/ItemIcons/res/ItemIcons.rc2 b/mapedit/ItemIcons/res/ItemIcons.rc2 deleted file mode 100644 index b527f80..0000000 --- a/mapedit/ItemIcons/res/ItemIcons.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// ItemIcons.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/mapedit/ItemIcons/resource.h b/mapedit/ItemIcons/resource.h deleted file mode 100644 index d9ff19a..0000000 --- a/mapedit/ItemIcons/resource.h +++ /dev/null @@ -1,66 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by ItemIcons.rc -// -#define IDC_BROWSE 3 -#define IDR_MAINMENU 4 -#define IDM_ABOUTBOX 0x0010 -#define IDD_ABOUTBOX 100 -#define IDS_ABOUTBOX 101 -#define IDD_ITEMICONS_DIALOG 102 -#define IDS_CREATENEW 102 -#define IDS_CHYBNYFORMAT 103 -#define IDS_CHYBAPRIULOZENI 104 -#define IDR_MAINFRAME 128 -#define IDD_OPENDLG 130 -#define IDR_POPUP 131 -#define IDS_BMPFILTER 132 -#define IDS_NEPLATNYFORMATBMP 133 -#define IDS_NELZEOTEVRITSOUBOR 134 -#define IDS_CHYBAPRIZAPISU 135 -#define IDC_ICON1 1001 -#define IDC_ICON2 1002 -#define IDC_ICON3 1003 -#define IDC_ICON4 1004 -#define IDC_ICON5 1005 -#define IDC_ICON6 1006 -#define IDC_ICON7 1007 -#define IDC_ICON8 1008 -#define IDC_ICON9 1009 -#define IDC_ICON10 1010 -#define IDC_ICON11 1011 -#define IDC_ICON12 1012 -#define IDC_ICON13 1013 -#define IDC_ICON14 1014 -#define IDC_ICON15 1015 -#define IDC_ICON16 1016 -#define IDC_ICON17 1017 -#define IDC_ICON18 1018 -#define IDC_FILENAME 1019 -#define IDC_LIST 1021 -#define IDC_CHECK1 1024 -#define IDC_TRANSPARENT 1024 -#define ID_OPEN 32774 -#define ID_SAVE 32776 -#define ID_ABOUT 32779 -#define ID_POPUP_COPY 32781 -#define ID_POPUP_PASTE 32782 -#define ID_POPUP_IMPORTBMP 32784 -#define ID_POPUP_EXPORTBMP 32785 -#define ID_EDIT_EXPORT 32792 -#define ID_EDIT_IMPORT 32793 -#define ID_EDIT_EXPORTALL 32794 -#define ID_POPUP_VYMAZAT 32795 -#define ID_Menu 32796 -#define ID_EDIT_DELETE 32798 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 136 -#define _APS_NEXT_COMMAND_VALUE 32799 -#define _APS_NEXT_CONTROL_VALUE 1025 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/mapedit/ItemIcons/stdafx.cpp b/mapedit/ItemIcons/stdafx.cpp deleted file mode 100644 index 880faec..0000000 --- a/mapedit/ItemIcons/stdafx.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// ItemIcons.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - diff --git a/mapedit/ItemIcons/stdafx.h b/mapedit/ItemIcons/stdafx.h deleted file mode 100644 index 8556315..0000000 --- a/mapedit/ItemIcons/stdafx.h +++ /dev/null @@ -1,46 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. -#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. -#endif - -#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. -#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. -#endif - -#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. -#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later. -#endif - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include // MFC support for Internet Explorer 4 Common Controls -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#define ICONSIZE (6+512+45*55) -#define ICONLIBSIZE (18*ICONSIZE) -#define GETICONADDR(icon) (_iconlib+icon*ICONSIZE) -#define GETICONBITS(icon) (_iconlib+icon*ICONSIZE+6+512) -#define GETICONPAL(icon) reinterpret_cast(_iconlib+icon*ICONSIZE+6) diff --git a/mapedit/Lex_Lib/Debug/BuildLog.htm b/mapedit/Lex_Lib/Debug/BuildLog.htm deleted file mode 100644 index 9b4fbfd..0000000 Binary files a/mapedit/Lex_Lib/Debug/BuildLog.htm and /dev/null differ diff --git a/mapedit/Lex_Lib/Debug/Lex_Lib.exe b/mapedit/Lex_Lib/Debug/Lex_Lib.exe deleted file mode 100644 index 12c5aac..0000000 Binary files a/mapedit/Lex_Lib/Debug/Lex_Lib.exe and /dev/null differ diff --git a/mapedit/Lex_Lib/Debug/Lex_Lib.exe.embed.manifest b/mapedit/Lex_Lib/Debug/Lex_Lib.exe.embed.manifest deleted file mode 100644 index 11bb704..0000000 --- a/mapedit/Lex_Lib/Debug/Lex_Lib.exe.embed.manifest +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/mapedit/Lex_Lib/Debug/Lex_Lib.exe.embed.manifest.res b/mapedit/Lex_Lib/Debug/Lex_Lib.exe.embed.manifest.res deleted file mode 100644 index 9c8df0e..0000000 Binary files a/mapedit/Lex_Lib/Debug/Lex_Lib.exe.embed.manifest.res and /dev/null differ diff --git a/mapedit/Lex_Lib/Debug/Lex_Lib.exe.intermediate.manifest b/mapedit/Lex_Lib/Debug/Lex_Lib.exe.intermediate.manifest deleted file mode 100644 index ecea6f7..0000000 --- a/mapedit/Lex_Lib/Debug/Lex_Lib.exe.intermediate.manifest +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/mapedit/Lex_Lib/Debug/mt.dep b/mapedit/Lex_Lib/Debug/mt.dep deleted file mode 100644 index 66a4874..0000000 --- a/mapedit/Lex_Lib/Debug/mt.dep +++ /dev/null @@ -1 +0,0 @@ -Manifest resource last updated at 21:19:30,59 on st 11.09.2013 diff --git a/mapedit/Lex_Lib/Debug/vc80.idb b/mapedit/Lex_Lib/Debug/vc80.idb deleted file mode 100644 index 9c17e7f..0000000 Binary files a/mapedit/Lex_Lib/Debug/vc80.idb and /dev/null differ diff --git a/mapedit/Lex_Lib/Debug/vc90.idb b/mapedit/Lex_Lib/Debug/vc90.idb deleted file mode 100644 index 76f3121..0000000 Binary files a/mapedit/Lex_Lib/Debug/vc90.idb and /dev/null differ diff --git a/mapedit/Lex_Lib/Lex_Lib.cpp b/mapedit/Lex_Lib/Lex_Lib.cpp deleted file mode 100644 index 9bf699f..0000000 --- a/mapedit/Lex_Lib/Lex_Lib.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// Lex_Lib.cpp : Defines the entry point for the console application. -// - -#include "stdafx.h" - -int _tmain(int argc, _TCHAR* argv[]) -{ - return 0; -} - diff --git a/mapedit/Lex_Lib/Lex_Lib.vcproj b/mapedit/Lex_Lib/Lex_Lib.vcproj deleted file mode 100644 index a010c65..0000000 --- a/mapedit/Lex_Lib/Lex_Lib.vcproj +++ /dev/null @@ -1,208 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mapedit/Lex_Lib/Release/BuildLog.htm b/mapedit/Lex_Lib/Release/BuildLog.htm deleted file mode 100644 index 2d3cb9b..0000000 Binary files a/mapedit/Lex_Lib/Release/BuildLog.htm and /dev/null differ diff --git a/mapedit/Lex_Lib/Release/Lex_Lib.exe b/mapedit/Lex_Lib/Release/Lex_Lib.exe deleted file mode 100644 index 4354358..0000000 Binary files a/mapedit/Lex_Lib/Release/Lex_Lib.exe and /dev/null differ diff --git a/mapedit/Lex_Lib/Release/Lex_Lib.exe.intermediate.manifest b/mapedit/Lex_Lib/Release/Lex_Lib.exe.intermediate.manifest deleted file mode 100644 index ecea6f7..0000000 --- a/mapedit/Lex_Lib/Release/Lex_Lib.exe.intermediate.manifest +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/mapedit/Lex_Lib/Release/mt.dep b/mapedit/Lex_Lib/Release/mt.dep deleted file mode 100644 index d15065b..0000000 --- a/mapedit/Lex_Lib/Release/mt.dep +++ /dev/null @@ -1 +0,0 @@ -Manifest resource last updated at 20:25:58,79 on st 11.09.2013 diff --git a/mapedit/Lex_Lib/Release/vc80.idb b/mapedit/Lex_Lib/Release/vc80.idb deleted file mode 100644 index f785173..0000000 Binary files a/mapedit/Lex_Lib/Release/vc80.idb and /dev/null differ diff --git a/mapedit/Lex_Lib/Release/vc90.idb b/mapedit/Lex_Lib/Release/vc90.idb deleted file mode 100644 index 2db3a57..0000000 Binary files a/mapedit/Lex_Lib/Release/vc90.idb and /dev/null differ diff --git a/mapedit/Lex_Lib/stdafx.cpp b/mapedit/Lex_Lib/stdafx.cpp deleted file mode 100644 index 1c479e4..0000000 --- a/mapedit/Lex_Lib/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// Lex_Lib.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/mapedit/Lex_Lib/stdafx.h b/mapedit/Lex_Lib/stdafx.h deleted file mode 100644 index f9aca9b..0000000 --- a/mapedit/Lex_Lib/stdafx.h +++ /dev/null @@ -1,12 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - - -#include -#include - -// TODO: reference additional headers your program requires here diff --git a/mapedit/Podlahar/ColorButton.cpp b/mapedit/Podlahar/ColorButton.cpp deleted file mode 100644 index 119ffc7..0000000 --- a/mapedit/Podlahar/ColorButton.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// ColorButton.cpp : implementation file -// - -#include "stdafx.h" -#include "ColorButton.h" -#include ".\colorbutton.h" - - -// CColorButton - -IMPLEMENT_DYNAMIC(CColorButton, CButton) -CColorButton::CColorButton() -{ -} - -CColorButton::~CColorButton() -{ -} - - -BEGIN_MESSAGE_MAP(CColorButton, CButton) -END_MESSAGE_MAP() - - - -// CColorButton message handlers - - -void CColorButton::DrawItem(LPDRAWITEMSTRUCT dis) - { - CRect rcitem(dis->rcItem); - CDC dc; - dc.Attach(dis->hDC); - dc.DrawFrameControl(&dis->rcItem,DFC_BUTTON,DFCS_BUTTONPUSH|(dis->itemState & 1?DFCS_PUSHED:0)); - rcitem-=CRect(2,2,2,2); - if (dis->itemState & ODS_FOCUS) dc.DrawFocusRect(&rcitem); - rcitem-=CRect(2,2,2,2); - dc.FillSolidRect(&rcitem,_color); - dc.Detach(); - } - -void CColorButton ::SetColor(COLORREF color, BOOL redraw) - { - _color=color; - Invalidate(FALSE); - } diff --git a/mapedit/Podlahar/ColorButton.h b/mapedit/Podlahar/ColorButton.h deleted file mode 100644 index a7c28e8..0000000 --- a/mapedit/Podlahar/ColorButton.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - - -// CColorButton - -class CColorButton : public CButton -{ - DECLARE_DYNAMIC(CColorButton) - COLORREF _color; - -public: - CColorButton(); - virtual ~CColorButton(); - - void SetColor(COLORREF color, BOOL redraw=1); - COLORREF GetColor() const {return _color;} - - -protected: - DECLARE_MESSAGE_MAP() - -public: - virtual void DrawItem(LPDRAWITEMSTRUCT /*lpDrawItemStruct*/); -}; - - diff --git a/mapedit/Podlahar/ImageView.cpp b/mapedit/Podlahar/ImageView.cpp deleted file mode 100644 index b402d9c..0000000 --- a/mapedit/Podlahar/ImageView.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// ImageView.cpp : implementation file -// - -#include "stdafx.h" -#include "ImageView.h" -#include ".\imageview.h" - - -// CImageView - -IMPLEMENT_DYNAMIC(CImageView, CStatic) -CImageView::CImageView() -{ - ZeroMemory(&_bmi,sizeof(_bmi._bmh)); - _bmi._bmh.biSize=sizeof(_bmi._bmh); - _bmi._bmh.biWidth=640; - _bmi._bmh.biHeight=-480; - _bmi._bmh.biPlanes=1; - _bmi._bmh.biBitCount=8; - _bmi._bmh.biCompression=BI_RGB; - _bmi._bmh.biSizeImage =0; - _buffer=NULL; -} - -CImageView::~CImageView() -{ -} - - -BEGIN_MESSAGE_MAP(CImageView, CStatic) - ON_WM_PAINT() -END_MESSAGE_MAP() - - - -// CImageView message handlers - - -void CImageView::OnPaint() -{ - CPaintDC dc(this); - if (_buffer) - { - SetDIBitsToDevice(dc,0,0,640,480,0,0,0,480,_buffer,(BITMAPINFO *)&_bmi,DIB_RGB_COLORS); - } -} - - -void CImageView::UpdateBuffer(char *buffer) -{ - _buffer=buffer; - Invalidate(); -} - -void CImageView::SetPalette(char *palette) -{ - for (int i=0;i<256;i++) - { - _bmi._palette[i].rgbRed=*palette++; - _bmi._palette[i].rgbGreen=*palette++; - _bmi._palette[i].rgbBlue=*palette++; - _bmi._palette[i].rgbReserved=0; - } -} \ No newline at end of file diff --git a/mapedit/Podlahar/ImageView.h b/mapedit/Podlahar/ImageView.h deleted file mode 100644 index 6404871..0000000 --- a/mapedit/Podlahar/ImageView.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - - -// CImageView - -class CImageView : public CStatic -{ - DECLARE_DYNAMIC(CImageView) - char *_buffer; - struct BMI - { - BITMAPINFOHEADER _bmh; - RGBQUAD _palette[256]; - } _bmi; -public: - CImageView(); - virtual ~CImageView(); - -protected: - DECLARE_MESSAGE_MAP() -public: - afx_msg void OnPaint(); - void UpdateBuffer(char *buffer); - void SetPalette(char *palette); -}; - - diff --git a/mapedit/Podlahar/Podlahar.cpp b/mapedit/Podlahar/Podlahar.cpp deleted file mode 100644 index ffb3d0f..0000000 --- a/mapedit/Podlahar/Podlahar.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// Podlah��.cpp : Defines the class behaviors for the application. -// - -#include "stdafx.h" -#include "Podlahar.h" -#include "PodlaharDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CPodlahApp - -BEGIN_MESSAGE_MAP(CPodlahApp, CWinApp) - ON_COMMAND(ID_HELP, CWinApp::OnHelp) -END_MESSAGE_MAP() - - -// CPodlahApp construction - -CPodlahApp::CPodlahApp() -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - - -// The one and only CPodlahApp object - -CPodlahApp theApp; - - -// CPodlahApp initialization - -BOOL CPodlahApp::InitInstance() -{ - // InitCommonControls() is required on Windows XP if an application - // manifest specifies use of ComCtl32.dll version 6 or later to enable - // visual styles. Otherwise, any window creation will fail. - InitCommonControls(); - - CWinApp::InitInstance(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need - // Change the registry key under which our settings are stored - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization - SetRegistryKey(_T("Local AppWizard-Generated Applications")); - - CPodlahDlg dlg; - m_pMainWnd = &dlg; - INT_PTR nResponse = dlg.DoModal(); - if (nResponse == IDOK) - { - // TODO: Place code here to handle when the dialog is - // dismissed with OK - } - else if (nResponse == IDCANCEL) - { - // TODO: Place code here to handle when the dialog is - // dismissed with Cancel - } - - // Since the dialog has been closed, return FALSE so that we exit the - // application, rather than start the application's message pump. - return FALSE; -} - - -extern "C" -{ - showview() {abort();} - screen_buffer_size() {abort();} - DxDoneWalk() {abort();} - DxZoomWalk() {abort();} - DxPrepareWalk() {abort();} - get_timer_value() {abort();} - DxDoneTurn() {abort();} - DxTurn() {abort();} - DxPrepareTurn() {abort();} - GetBuffer2nd() {abort();} - GetScreenAdr() {abort();} - put_picture() {abort();} - put_textured_bar_() {abort();} - RestoreScreen() {abort();} - outtext() {abort();} - set_aligned_position() {abort();} - trans_bar() {abort();} - text_width() {abort();} - RedirectScreenBufferSecond() {abort();} - void *getmem(int32_t size) {return malloc(size);} -} \ No newline at end of file diff --git a/mapedit/Podlahar/Podlahar.h b/mapedit/Podlahar/Podlahar.h deleted file mode 100644 index 071bd29..0000000 --- a/mapedit/Podlahar/Podlahar.h +++ /dev/null @@ -1,32 +0,0 @@ -// Podlahář.h : main header file for the PROJECT_NAME application -// - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - - -// CPodlahApp: -// See Podlahář.cpp for the implementation of this class -// - -class CPodlahApp : public CWinApp -{ -public: - CPodlahApp(); - -// Overrides - public: - virtual BOOL InitInstance(); - -// Implementation - - DECLARE_MESSAGE_MAP() -}; - -extern CPodlahApp theApp; - diff --git a/mapedit/Podlahar/Podlahar.rc b/mapedit/Podlahar/Podlahar.rc deleted file mode 100644 index 51e89b1..0000000 --- a/mapedit/Podlahar/Podlahar.rc +++ /dev/null @@ -1,235 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Czech resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CSY) -#ifdef _WIN32 -LANGUAGE LANG_CZECH, SUBLANG_DEFAULT -#pragma code_page(1250) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE MOVEABLE PURE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE MOVEABLE PURE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE MOVEABLE PURE -BEGIN - "#define _AFX_NO_SPLITTER_RESOURCES\r\n" - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1250)\r\n" - "\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\Podlahar.ico" -#endif // Czech resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55 -STYLE DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About Podlahář" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "Podlahář Version 1.0",IDC_STATIC,40,10,119,8, - SS_NOPREFIX - LTEXT "Copyright (C) 2005",IDC_STATIC,40,25,119,8 - DEFPUSHBUTTON "OK",IDOK,178,7,50,16,WS_GROUP -END - -IDD_PODLAH_DIALOG DIALOGEX 0, 0, 455, 426 -STYLE DS_MODALFRAME | DS_FIXEDSYS | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "Podlahář" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "Hlavní textura:",IDC_STATIC,7,7,49,8 - EDITTEXT IDC_HLTEXTURA,60,7,314,12,ES_AUTOHSCROLL | WS_GROUP - PUSHBUTTON "Browse",IDC_BROWSE1,378,7,70,12,WS_GROUP - LTEXT "Vedlejší textura:",IDC_STATIC,7,20,54,8 - EDITTEXT IDC_VDTEXTURA,60,21,314,12,ES_AUTOHSCROLL | WS_GROUP - PUSHBUTTON "Browse",IDC_BROWSE2,378,21,70,12,WS_GROUP - LTEXT "Barva mlhy",IDC_STATIC,7,41,36,8 - CONTROL "Button4",IDC_COLOR,"Button",BS_OWNERDRAW | WS_GROUP | - WS_TABSTOP,59,38,44,14 - LTEXT "Cílový soubor:",IDC_STATIC,7,72,47,8 - EDITTEXT IDC_CILOVYSOUBOR,60,71,314,12,ES_AUTOHSCROLL | WS_GROUP - PUSHBUTTON "Browse",IDC_BROWSE3,378,71,70,12,WS_GROUP - DEFPUSHBUTTON "Preview",IDC_PREVIEW,7,111,50,14,WS_GROUP - CONTROL "Podlaha",IDC_TYP,"Button",BS_AUTORADIOBUTTON | WS_GROUP | - WS_TABSTOP,280,89,41,10 - CONTROL "Strop",IDC_TYP2,"Button",BS_AUTORADIOBUTTON,336,89,33, - 10 - PUSHBUTTON "Ulož obrázek",IDC_SAVEPIC,377,88,71,14,WS_GROUP - CONTROL "",IDC_IMAGE,"Static",SS_BLACKFRAME | WS_GROUP,7,133,441, - 286 - CONTROL "Generuj mlhu",IDC_GENMLHU,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,115,40,58,10 -END - - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904e4" - BEGIN - VALUE "CompanyName", "TODO: \0" - VALUE "FileDescription", "TODO: \0" - VALUE "FileVersion", "1.0.0.1\0" - VALUE "InternalName", "Podlahář.exe\0" - VALUE "LegalCopyright", "TODO: (c) . All rights reserved.\0" - VALUE "OriginalFilename", "Podlahář.exe\0" - VALUE "ProductName", "TODO: \0" - VALUE "ProductVersion", "1.0.0.1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO MOVEABLE PURE -BEGIN - IDD_ABOUTBOX, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 228 - TOPMARGIN, 7 - BOTTOMMARGIN, 48 - END - - IDD_PODLAH_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 448 - TOPMARGIN, 7 - BOTTOMMARGIN, 419 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE DISCARDABLE -BEGIN - IDS_ABOUTBOX "&About Podlahář..." - IDS_PCXFILTER "PCX images|*.pcx||" - IDS_BROWSEPCX "Vyber PCX soubor 500x320" - IDS_ERRORPCX "PCX je neplatný. Povolen je pouze obrázek ve formátu PCX 8-bit velikosti přesně 500x320." -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 -#pragma code_page(1250) - -#include "afxres.rc" // Standard components -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/mapedit/Podlahar/Podlahar.sln b/mapedit/Podlahar/Podlahar.sln deleted file mode 100644 index 8fa88d5..0000000 --- a/mapedit/Podlahar/Podlahar.sln +++ /dev/null @@ -1,30 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Podlahář", "Podlahar.vcproj", "{5D7F2D3A-8169-4514-A9EC-A0FDBBAC917B}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SourceCodeControl) = preSolution - SccNumberOfProjects = 1 - SccProjectUniqueName0 = Podlahar.vcproj - SccProjectName0 = \u0022$/Skeldal\u0022,\u0020RYCAAAAA - SccLocalPath0 = ..\\.. - SccProvider0 = MSSCCI:Microsoft\u0020Visual\u0020SourceSafe - CanCheckoutShared = false - SccProjectFilePathRelativizedFromConnection0 = mapedit\\Podlahar\\ - EndGlobalSection - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {5D7F2D3A-8169-4514-A9EC-A0FDBBAC917B}.Debug.ActiveCfg = Debug|Win32 - {5D7F2D3A-8169-4514-A9EC-A0FDBBAC917B}.Debug.Build.0 = Debug|Win32 - {5D7F2D3A-8169-4514-A9EC-A0FDBBAC917B}.Release.ActiveCfg = Release|Win32 - {5D7F2D3A-8169-4514-A9EC-A0FDBBAC917B}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/mapedit/Podlahar/Podlahar.vcproj b/mapedit/Podlahar/Podlahar.vcproj deleted file mode 100644 index f591956..0000000 --- a/mapedit/Podlahar/Podlahar.vcproj +++ /dev/null @@ -1,338 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mapedit/Podlahar/PodlaharDlg.cpp b/mapedit/Podlahar/PodlaharDlg.cpp deleted file mode 100644 index 27cfead..0000000 --- a/mapedit/Podlahar/PodlaharDlg.cpp +++ /dev/null @@ -1,260 +0,0 @@ -// PodlahářDlg.cpp : implementation file -// - -#include "stdafx.h" -#include "Podlahar.h" -#include "PodlaharDlg.h" -#include ".\podlahardlg.h" -#include "..\..\DDLReader\WString.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - enum { IDD = IDD_ABOUTBOX }; - - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) -END_MESSAGE_MAP() - - -// CPodlahDlg dialog - - - -CPodlahDlg::CPodlahDlg(CWnd* pParent /*=NULL*/) - : CDialog(CPodlahDlg::IDD, pParent) - , vHlTextura(_T("")) - , vVdTextura(_T("")) - , vTarget(_T("")) - , vGenMlhu(FALSE) - , vType(0) -{ - m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); -} - -void CPodlahDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - DDX_Text(pDX, IDC_HLTEXTURA, vHlTextura); - DDX_Text(pDX, IDC_VDTEXTURA, vVdTextura); - DDX_Control(pDX, IDC_COLOR, wColorButt); - DDX_Text(pDX, IDC_CILOVYSOUBOR, vTarget); - DDX_Control(pDX, IDC_BROWSE1, wBrowse1); - DDX_Control(pDX, IDC_BROWSE2, wBrowse2); - DDX_Control(pDX, IDC_BROWSE3, wBrowse3); - DDX_Control(pDX, IDC_SAVEPIC, wSavePic); - DDX_Control(pDX, IDC_IMAGE, wPreview); - DDX_Check(pDX, IDC_GENMLHU, vGenMlhu); - DDX_Radio(pDX, IDC_TYP, vType); -} - -BEGIN_MESSAGE_MAP(CPodlahDlg, CDialog) - ON_WM_SYSCOMMAND() - ON_WM_PAINT() - ON_WM_QUERYDRAGICON() - //}}AFX_MSG_MAP - ON_BN_CLICKED(IDC_BROWSE1, OnBnClickedBrowse) - ON_BN_CLICKED(IDC_BROWSE2, OnBnClickedBrowse) - ON_BN_CLICKED(IDC_BROWSE3, OnBnClickedBrowseSave) - ON_BN_CLICKED(IDC_COLOR, OnBnClickedColor) - ON_BN_CLICKED(IDC_PREVIEW, OnBnClickedPreview) - ON_BN_CLICKED(IDC_SAVEPIC, OnBnClickedSavepic) -END_MESSAGE_MAP() - - -// CPodlahDlg message handlers - -BOOL CPodlahDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // Add "About..." menu item to system menu. - - // IDM_ABOUTBOX must be in the system command range. - ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); - ASSERT(IDM_ABOUTBOX < 0xF000); - - CMenu* pSysMenu = GetSystemMenu(FALSE); - if (pSysMenu != NULL) - { - CString strAboutMenu; - strAboutMenu.LoadString(IDS_ABOUTBOX); - if (!strAboutMenu.IsEmpty()) - { - pSysMenu->AppendMenu(MF_SEPARATOR); - pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); - } - } - - // Set the icon for this dialog. The framework does this automatically - // when the application's main window is not a dialog - SetIcon(m_hIcon, TRUE); // Set big icon - SetIcon(m_hIcon, FALSE); // Set small icon - - // TODO: Add extra initialization here - - return TRUE; // return TRUE unless you set the focus to a control -} - -void CPodlahDlg::OnSysCommand(UINT nID, LPARAM lParam) -{ - if ((nID & 0xFFF0) == IDM_ABOUTBOX) - { - CAboutDlg dlgAbout; - dlgAbout.DoModal(); - } - else - { - CDialog::OnSysCommand(nID, lParam); - } -} - -// If you add a minimize button to your dialog, you will need the code below -// to draw the icon. For MFC applications using the document/view model, -// this is automatically done for you by the framework. - -void CPodlahDlg::OnPaint() -{ - if (IsIconic()) - { - CPaintDC dc(this); // device context for painting - - SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); - - // Center icon in client rectangle - int cxIcon = GetSystemMetrics(SM_CXICON); - int cyIcon = GetSystemMetrics(SM_CYICON); - CRect rect; - GetClientRect(&rect); - int x = (rect.Width() - cxIcon + 1) / 2; - int y = (rect.Height() - cyIcon + 1) / 2; - - // Draw the icon - dc.DrawIcon(x, y, m_hIcon); - } - else - { - CDialog::OnPaint(); - } -} - -// The system calls this function to obtain the cursor to display while the user drags -// the minimized window. -HCURSOR CPodlahDlg::OnQueryDragIcon() -{ - return static_cast(m_hIcon); -} - -void CPodlahDlg::OnBnClickedBrowse() -{ - CString pszFilePath; - GetFocus()->GetNextWindow(GW_HWNDPREV)->GetWindowText(pszFilePath); - CString filter;filter.LoadString(IDS_PCXFILTER); - CString title;title.LoadString(IDS_BROWSEPCX); - CFileDialog fdlg(TRUE,_T("PCX"),pszFilePath,OFN_PATHMUSTEXIST|OFN_HIDEREADONLY,filter); - if (fdlg.DoModal()==IDOK) - { - pszFilePath=fdlg.GetPathName(); -#ifdef _UNICODE - char *name=(char *)alloca(pszFilePath.GetLength()+1); - WideCharToMultiByte(CP_ACP,0,pszFilePath,pszFilePath.GetLength()+1,name,pszFilePath.GetLength()+1,NULL,NULL); -#else - const char *name=pszFilePath; -#endif - if (CheckPCX(name)==0) - { - GetFocus()->GetNextWindow(GW_HWNDPREV)->SetWindowText(fdlg.GetPathName()); - } - else - AfxMessageBox(IDS_ERRORPCX); - } -} - -void CPodlahDlg::OnBnClickedBrowseSave() -{ - CString pszFilePath; - GetFocus()->GetNextWindow(GW_HWNDPREV)->GetWindowText(pszFilePath); - CString filter;filter.LoadString(IDS_PCXFILTER); - CString title;title.LoadString(IDS_BROWSEPCX); - CFileDialog fdlg(FALSE,_T("PCX"),pszFilePath,OFN_PATHMUSTEXIST|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,filter); - if (fdlg.DoModal()) - { - GetFocus()->GetNextWindow(GW_HWNDPREV)->SetWindowText(fdlg.GetPathName()); - } -} - -void CPodlahDlg::OnBnClickedColor() -{ - CColorDialog dlg(wColorButt._color,CC_FULLOPEN|CC_ANYCOLOR|CC_RGBINIT); - if (dlg.DoModal()==IDOK) - { - wColorButt.SetColor(dlg.GetColor()); - } -} - -void CPodlahDlg::OnBnClickedPreview() -{ - UpdateData(TRUE); -#ifdef _UNICODE - WString hlTex(vHlTextura.GetString()); - WString vlTex(vVdTextura.GetString()); - COLORREF color=wColorButt._color; - char *result=PodlahaStrop(GetRValue(color), GetGValue(color), GetBValue(color), - hlTex.AsUTF8(hlTex),vlTex.AsUTF8(vlTex),vGenMlhu); -#else - const char *hlTex=vHlTextura; - const char *vlTex=vVdTextura; - COLORREF color=wColorButt._color; - char *result=PodlahaStrop(GetRValue(color), GetGValue(color), GetBValue(color), - hlTex,vlTex,vGenMlhu); -#endif - wPreview.UpdateBuffer(result+512+6); - wPreview.SetPalette(GetPodlahaPalette()); - -} - -void CPodlahDlg::OnBnClickedSavepic() -{ - UpdateData(TRUE); - if (vTarget.GetLength()) - { - OnBnClickedPreview(); -#ifdef _UNICODE - WString name(vTarget.GetString()); - char *cname=const_cast(name.AsUTF8(name)); -#else - char *cname=const_cast((LPCTSTR)vTarget); -#endif - if (vType) - save_pcx(cname,0,0,639,89); - else - save_pcx(cname,0,360-198,639,360); - ShellExecute(*this,NULL,vTarget,0,NULL,SW_SHOWNORMAL); - } -} diff --git a/mapedit/Podlahar/PodlaharDlg.h b/mapedit/Podlahar/PodlaharDlg.h deleted file mode 100644 index b44659e..0000000 --- a/mapedit/Podlahar/PodlaharDlg.h +++ /dev/null @@ -1,62 +0,0 @@ -// PodlahářDlg.h : header file -// - -#pragma once -#include "afxwin.h" -#include "ColorButton.h" -#include "ImageView.h" - - -// CPodlahDlg dialog -class CPodlahDlg : public CDialog -{ -// Construction -public: - CPodlahDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - enum { IDD = IDD_PODLAH_DIALOG }; - - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - - -// Implementation -protected: - HICON m_hIcon; - - // Generated message map functions - virtual BOOL OnInitDialog(); - afx_msg void OnSysCommand(UINT nID, LPARAM lParam); - afx_msg void OnPaint(); - afx_msg HCURSOR OnQueryDragIcon(); - DECLARE_MESSAGE_MAP() -public: - afx_msg void OnBnClickedBrowse(); - int type; - CString vHlTextura; - CString vVdTextura; - CColorButton wColorButt; - CString vTarget; - CButton wBrowse1; - CButton wBrowse2; - CButton wBrowse3; - CButton wSavePic; - CImageView wPreview; - afx_msg void OnBnClickedColor(); - afx_msg void OnBnClickedPreview(); - BOOL vGenMlhu; - afx_msg void OnBnClickedSavepic(); - afx_msg void OnBnClickedBrowseSave(); - int vType; -}; - - -extern "C" -{ - char *PodlahaStrop(int r, int g, int b, const char *filename1, const char *filename2, int genMlhu); - char *GetPodlahaPalette(); - int save_pcx(char *filename,int x1,int y1,int x2,int y2); - char CheckPCX(const char *pcx); - -} \ No newline at end of file diff --git a/mapedit/Podlahar/Podlahy.c b/mapedit/Podlahar/Podlahy.c deleted file mode 100644 index 404bf87..0000000 --- a/mapedit/Podlahar/Podlahy.c +++ /dev/null @@ -1,397 +0,0 @@ -#include -#include -#include -#include -#include -#include "..\..\libs\types.h" -#include "..\..\game\engine1.h" -#include "..\..\libs\pcx.h" - - -void calc_points(); -void create_tables(); - -char filename1[128]; -char filename2[128]; - -char buffer[640*480+6+512]; - -char *obr1,*obr2; - -#pragma pack(1) -typedef struct tbarva - { - char r,g,b; - }TBARVA; -#pragma pack() - -TBARVA shadow; -int shadow_max; - -struct tbarva palette[256]; - - -char datapath[]=""; -extern struct all_view showtabs; -extern t_points viewport_geometry; - -void do_events() - { - - } - -int get_shd_color(char src,int cur) - { - struct tbarva what; - int c,d,m,p,i,ml; - - m=256*256*256; - c=0;d=0; - what=palette[src]; - cur=shadow_max-cur; - cur=(int)(shadow_max*sqrt((float)cur/(float)shadow_max)); - what.r=(shadow.r+(what.r-shadow.r)*cur/shadow_max); - what.g=(shadow.g+(what.g-shadow.g)*cur/shadow_max); - what.b=(shadow.b+(what.b-shadow.b)*cur/shadow_max); - for(i=0;i<256;i++) - { - p=(what.r-palette[i].r)*(what.r-palette[i].r)+ - (what.g-palette[i].g)*(what.g-palette[i].g)+ - (what.b-palette[i].b)*(what.b-palette[i].b); - if (p=1000) xp-=1000; - while (xp<0) xp+=1000; - if ((xp>=500)^(swap)) srcp=srcadr2+(xp % 500); else srcp=srcadr1+(xp%500); - if (genMlhu) - { - if (table[*srcp]==0xffff) table[*srcp]=get_shd_color(*srcp,yline); - *point=table[*srcp]&0xff; - } - else - *point=*srcp; - - } - return showtabs.f_table[2][yline].counter; - } - -void draw_it_all_f(int genMlhu) - { - int i,m,y,m2,s; - - y=0;s=0; - m2=(360-MIDDLE_Y)-viewport_geometry[0][0][VIEW3D_Z].y; - shadow_max=m2; - for (i=0;i=1000) xp-=1000; - while (xp<0) xp+=1000; - if ((xp>=500)^(swap)) srcp=srcadr2+(xp % 500); else srcp=srcadr1+(xp % 500); - if (genMlhu) - { - if (table[*srcp]==0xffff) table[*srcp]=get_shd_color(*srcp,yline); - *point=(table[*srcp]&0xff); - } - else - *point=*srcp; - } - return showtabs.c_table[2][yline].counter; - } - -void draw_it_all_c(int genMlhu) - { - int i,m,y,m2,s; - - y=0;s=0; - m2=MIDDLE_Y+viewport_geometry[0][1][VIEW3D_Z].y; - shadow_max=m2; - for (i=0;i \n" - "\n" - " \n" - " soubory s texturami ve formatu pcx. Textura musi mit velikost 500x320\n\n" - " \n" - " Cisla predstavujici slozky barvy, jenz se pouzije ke generovani mlhy,\n" - " nebo ke stmavovani. Jednotlive hodnoty jsou v rozsahu <0-255>\n" - "\n" - "Vysledne soubory se ulozi do aktualniho adresare pod jmeny:\n" - " PODLAHA.PCX - soubor s podlahou\n" - " STROP.PCX - soubor se stropem\n" - "\n" - "Pozn.: Prestoze se jedna o korektni format PCX, doporucuji oba soubory \n" - " natahnout do Autodesk Animatora a znovu v tomto formatu ulozit\n" - " Stavalo se mi, ze se muj PCX dekomprimator s timto vygenerovanym souborem\n" - " hroutil.\n" - ); - exit(0); - } -*/ -/* -main(int argv,char *argc[]) - { - int r,g,b,i; - char rv[10],gv[10],bv[10]; - if (argv!=6) help(); - strass(filename1,argc[1],128); - strass(filename2,argc[2],128); - strass(rv,argc[3],10); - strass(gv,argc[4],10); - strass(bv,argc[5],10); - sscanf(rv,"%d",&r); - sscanf(gv,"%d",&g); - sscanf(bv,"%d",&b); - if (r<0 || r>255 || g<0 || g>255 || b<0 || b>255 ) - { - printf("Hodnoty by mely byt rozsahu <0-255> \n"); - abort(); - } - shadow.r=r;shadow.g=g;shadow.b=b; - calc_points(); - create_tables(); - read_palette(filename1,&palette); - shadow_max=100; - memset(buffer,get_shd_color(0,100),640*480+6+512); - *(word *)buffer=640; - *((word *)buffer+1)=480; - *((word *)buffer+2)=8; - if (open_pcx(filename1,A_8BIT,&obr1) ) - { - printf("Nemohu najit %s.\n",filename1); - abort(); - } - if (open_pcx(filename2,A_8BIT,&obr2) ) - { - printf("Nemohu najit %s.\n",filename2); - abort(); - } - memcpy(buffer+6,obr1+6,512); - draw_it_all_f(); - draw_it_all_c(); - initmode32(); - for(i=0;i>3)<<10)+((g>>3)<<5)+(b>>3); - put_picture(0,0,buffer); - showview(0,0,0,0); - getchar(); - closemode(); - save_pcx("STROP.PCX",0,0,639,92); - save_pcx("PODLAHA.PCX",0,360-198,639,360); - printf("Vytvoreny soubory STROP.PCX a PODLAHA.PCX\n"); - - } - -*/ - - - int32_t scr_linelen=1280; - int32_t scr_linelen2=640; - - char *PodlahaStrop(int r, int g, int b, const char *filename1, const char *filename2, int genMlhu) - { - shadow.r=r;shadow.g=g;shadow.b=b; - obr1=obr2=NULL; - calc_points(); - create_tables(); - read_palette(filename1,&palette); - shadow_max=100; - memset(buffer,get_shd_color(0,100),640*480+6+512); - *(word *)buffer=640; - *((word *)buffer+1)=480; - *((word *)buffer+2)=8; - if (open_pcx(filename1,A_8BIT,&obr1) ) - { - free(obr1); - return NULL; - } - if (open_pcx(filename2,A_8BIT,&obr2) ) - { - free(obr1); - free(obr2); - return NULL; - } - memcpy(buffer+6,obr1+6,512); - draw_it_all_f(genMlhu); - draw_it_all_c(genMlhu); - free(obr1); - free(obr2); - return buffer; - } - - char CheckPCX(const char *pcx) - { - char p=open_pcx(pcx,A_8BIT,&obr1); - word *xy; - - if (p) {free(obr1);return -1;} - xy=(word *)obr1; - if (xy[0]!=500 || xy[1]!=320) p=-1; - free(obr1); - return p; - - } - -char *GetPodlahaPalette() -{ - return (char *)palette; -} \ No newline at end of file diff --git a/mapedit/Podlahar/res/Podlahar.ico b/mapedit/Podlahar/res/Podlahar.ico deleted file mode 100644 index 7eef0bc..0000000 Binary files a/mapedit/Podlahar/res/Podlahar.ico and /dev/null differ diff --git a/mapedit/Podlahar/res/Podlahar.rc2 b/mapedit/Podlahar/res/Podlahar.rc2 deleted file mode 100644 index 08c8e1d..0000000 --- a/mapedit/Podlahar/res/Podlahar.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// PODLAHAR.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/mapedit/Podlahar/res/Podlahář.ico b/mapedit/Podlahar/res/Podlahář.ico deleted file mode 100644 index 8a84ca3..0000000 Binary files a/mapedit/Podlahar/res/Podlahář.ico and /dev/null differ diff --git a/mapedit/Podlahar/res/Podlahář.rc2 b/mapedit/Podlahar/res/Podlahář.rc2 deleted file mode 100644 index c14d366..0000000 --- a/mapedit/Podlahar/res/Podlahář.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// Podlah.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/mapedit/Podlahar/resource.h b/mapedit/Podlahar/resource.h deleted file mode 100644 index e7d4b77..0000000 --- a/mapedit/Podlahar/resource.h +++ /dev/null @@ -1,39 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by Podlahar.rc -// -#define IDM_ABOUTBOX 0x0010 -#define IDD_ABOUTBOX 100 -#define IDS_ABOUTBOX 101 -#define IDD_PODLAH_DIALOG 102 -#define IDS_PCXFILTER 102 -#define IDS_BROWSEPCX 103 -#define IDS_ERRORPCX 104 -#define IDR_MAINFRAME 128 -#define IDC_HLTEXTURA 1000 -#define IDC_BROWSE1 1001 -#define IDC_VDTEXTURA 1002 -#define IDC_BROWSE2 1003 -#define IDC_CILOVYSOUBOR 1004 -#define IDC_COLOR 1005 -#define IDC_BROWSE3 1006 -#define IDC_SAVEPIC 1009 -#define IDC_BUTTON9 1010 -#define IDC_SAVEREF 1010 -#define IDC_TYP 1011 -#define IDC_TYP2 1012 -#define IDC_IMAGE 1013 -#define IDC_PREVIEW 1014 -#define IDC_GENMLHU 1015 -#define IDC_TYP3 1016 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 129 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1016 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/mapedit/Podlahar/stdafx.cpp b/mapedit/Podlahar/stdafx.cpp deleted file mode 100644 index 9520d94..0000000 --- a/mapedit/Podlahar/stdafx.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// Podlahář.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - diff --git a/mapedit/Podlahar/stdafx.h b/mapedit/Podlahar/stdafx.h deleted file mode 100644 index 6ec1eb3..0000000 --- a/mapedit/Podlahar/stdafx.h +++ /dev/null @@ -1,41 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. -#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. -#endif - -#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. -#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. -#endif - -#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. -#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later. -#endif - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include // MFC support for Internet Explorer 4 Common Controls -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - diff --git a/platform/CMakeLists.txt b/platform/CMakeLists.txt index 33f54d2..8b22c12 100644 --- a/platform/CMakeLists.txt +++ b/platform/CMakeLists.txt @@ -29,7 +29,6 @@ if(WIN32) target_compile_definitions(skeldal_platform PRIVATE PLATFORM_WINDOWS) message(STATUS "Building for Windows") - elseif(UNIX AND NOT APPLE) target_sources(skeldal_platform PRIVATE linux/save_folder.cpp @@ -40,6 +39,11 @@ elseif(UNIX AND NOT APPLE) linux/app_start.cpp ) target_compile_definitions(skeldal_platform PRIVATE PLATFORM_LINUX) + add_custom_command( + TARGET skeldal POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_LIST_DIR}/linux/skeldal.sh + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/skeldal.sh) message(STATUS "Building for Linux") elseif(APPLE) diff --git a/platform/istr.c b/platform/istr.c index 65e155c..3d1fdfd 100644 --- a/platform/istr.c +++ b/platform/istr.c @@ -103,3 +103,13 @@ int imatch(const char *text, const char *hledany) { return 1; // Všechny části byly nalezeny ve správnĂ©m poĹ™adĂ­ } + +const char *strcopy_n(char *target, const char *source, int target_size) { + const char *ret = target; + while (target_size>1 && *source) { + *target++ = *source++; + --target_size; + } + *target = 0; + return ret; +} diff --git a/platform/linux/skeldal.sh b/platform/linux/skeldal.sh new file mode 100755 index 0000000..9f86177 --- /dev/null +++ b/platform/linux/skeldal.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +temp_file=$(mktemp /tmp/skeldal.XXXXXX.log) + +./skeldal > "$temp_file" 2>&1 + +exit_code=$? + +if [ $exit_code -ne 0 ]; then + error_message=$(cat "$temp_file") + + if command -v zenity > /dev/null; then + zenity --warning --title="Skeldal ERROR" --text="$error_message" + elif command -v kdialog > /dev/null; then + kdialog --title "Skeldal ERROR" --error "$error_message" + elif command -v xmessage > /dev/null; then + xmessage -center -file $temp_file + elif command -v xdg-open > /dev/null; then + xdg-open "$temp_file" + sleep 5; + else + cat "$temp_file" + fi +fi +#rm $temp_file +exit $exit_code \ No newline at end of file diff --git a/platform/platform.h b/platform/platform.h index 6d287fa..bd82317 100644 --- a/platform/platform.h +++ b/platform/platform.h @@ -16,8 +16,8 @@ #pragma warning(disable: 4456) #pragma warning(disable: 4457) #pragma warning(disable: 4702) -#define CASE_FALLTHROUGH -#else +#define CASE_FALLTHROUGH +#else #define CASE_FALLTHROUGH [[fallthrough]] #endif @@ -88,6 +88,7 @@ const char *file_icase_find(const char *pathname); int istrcmp(const char *a, const char *b); int imatch(const char *haystack, const char *needle); +const char *strcopy_n(char *target, const char *source, int target_size); #define MIN(a, b) ((a)<(b)?(a):(b)) #define MAX(a, b) ((a)>(b)?(a):(b)) void strupper(char *c); diff --git a/platform/sdl/BGraph2.cpp b/platform/sdl/BGraph2.cpp index 8656819..c00d8f3 100644 --- a/platform/sdl/BGraph2.cpp +++ b/platform/sdl/BGraph2.cpp @@ -225,3 +225,8 @@ char game_display_is_quit_requested() { void game_display_cancel_quit_request() { return get_sdl_global_context().cancel_quit_request(); } + +void game_display_set_icon(const void *icon_data, size_t icon_size) { + auto &sdl = get_sdl_global_context(); + sdl.set_window_icon(icon_data, icon_size); +} diff --git a/platform/sdl/BGraph2.h b/platform/sdl/BGraph2.h index 64f398a..cda94ba 100644 --- a/platform/sdl/BGraph2.h +++ b/platform/sdl/BGraph2.h @@ -1,6 +1,7 @@ #include #include "../config.h" +#include #ifndef __BGRAPH_DX_WRAPPER_ #define __BGRAPH_DX_WRAPPER_ @@ -23,6 +24,7 @@ void game_display_close(void); void game_display_update_rect(unsigned short x,unsigned short y,unsigned short xs,unsigned short ys); char game_display_is_quit_requested(); void game_display_cancel_quit_request(); +void game_display_set_icon(const void *icon_data, size_t icon_size); void *DxPrepareWalk(int ypos); void DxZoomWalk(void *handle, int ypos, int *points,float phase, void *lodka); diff --git a/platform/sdl/sdl_context.cpp b/platform/sdl/sdl_context.cpp index bc7043f..1c1898c 100644 --- a/platform/sdl/sdl_context.cpp +++ b/platform/sdl/sdl_context.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include void SDLContext::SDL_Deleter::operator ()(SDL_Window* window) { @@ -613,3 +614,17 @@ void SDLContext::pause_audio(bool pause) { void SDLContext::close_audio() { _audio.reset(); } + +void SDLContext::set_window_icon(const void *icon_data, size_t icon_size) { + SDL_Surface *surface = SDL_LoadBMP_RW(SDL_RWFromConstMem(icon_data, icon_size), 1); + if (surface == 0) { + char buff[256]; + snprintf(buff,sizeof(buff),"Can't load icon: %s", SDL_GetError()); + display_error(buff); + std::ofstream x("test.dat", std::ios::out|std::ios::binary|std::ios::trunc); + x.write(reinterpret_cast(icon_data), icon_size); + } else { + SDL_SetWindowIcon(_window.get(), surface); + } + +} diff --git a/platform/sdl/sdl_context.h b/platform/sdl/sdl_context.h index 396d670..5b131ab 100644 --- a/platform/sdl/sdl_context.h +++ b/platform/sdl/sdl_context.h @@ -47,6 +47,8 @@ public: void init_video(const VideoConfig &config, const char *title); + void set_window_icon(const void *icon_data, size_t icon_size); + void close_video(); AudioInfo init_audio(const AudioConfig &config, SDL_AudioCallback cb, void *cb_ctx);