mirror of
https://github.com/freebip/BipEmulator.git
synced 2025-05-18 17:36:32 +03:00
CHG: Add "read_elf_res_by_id" functionality
This commit is contained in:
parent
218c15c2d9
commit
78508e4e7e
@ -19,6 +19,7 @@
|
|||||||
public const string LOG_PRINTF = "log_printf";
|
public const string LOG_PRINTF = "log_printf";
|
||||||
public const string REG_MENU = "reg_menu";
|
public const string REG_MENU = "reg_menu";
|
||||||
public const string REPAINT_SCREEN_LINES = "repaint_screen_lines";
|
public const string REPAINT_SCREEN_LINES = "repaint_screen_lines";
|
||||||
|
public const string READ_ELF_RES_BY_ID = "read_elf_res_by_id";
|
||||||
public const string SET_BG_COLOR = "set_bg_color";
|
public const string SET_BG_COLOR = "set_bg_color";
|
||||||
public const string SET_FG_COLOR = "set_fg_color";
|
public const string SET_FG_COLOR = "set_fg_color";
|
||||||
public const string SET_UPDATE_PERIOD = "set_update_period";
|
public const string SET_UPDATE_PERIOD = "set_update_period";
|
||||||
|
@ -5,6 +5,7 @@ using System.Drawing;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.MemoryMappedFiles;
|
using System.IO.MemoryMappedFiles;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -191,16 +192,27 @@ namespace BipEmulator.Host
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case FunctionNames.GET_RES_PARAMS:
|
case FunctionNames.GET_RES_PARAMS:
|
||||||
var res = GetUserResImage((int)args[2]);
|
{
|
||||||
if (res == null)
|
var res = GetUserResImage((int)args[2]);
|
||||||
return -1;
|
if (res == null)
|
||||||
|
return -1;
|
||||||
|
|
||||||
var bmp = res.Bitmap;
|
var bmp = res.Bitmap;
|
||||||
|
|
||||||
var param = new ResParam { Width=(short)bmp.Width, Height=(short)bmp.Height };
|
var param = new ResParam { Width = (short)bmp.Width, Height = (short)bmp.Height };
|
||||||
CopyStructToUnmanagedMemory(param, (IntPtr)args[3]);
|
CopyStructToUnmanagedMemory(param, (IntPtr)args[3]);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
case FunctionNames.READ_ELF_RES_BY_ID:
|
||||||
|
{
|
||||||
|
// only own resources
|
||||||
|
if ((int)args[1] != -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
var data = GetUserResData(/*resId*/(int)args[2],/*offset*/(int)args[3], (int)args[5]/*len*/);
|
||||||
|
Marshal.Copy(data, 0, (IntPtr)args[4], data.Length);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
case FunctionNames.SHOW_BIG_DIGITS:
|
case FunctionNames.SHOW_BIG_DIGITS:
|
||||||
ShowBigDigit((int)args[1], args[2].ToString(), (int)args[3], (int)args[4], (int)args[5]);
|
ShowBigDigit((int)args[1], args[2].ToString(), (int)args[3], (int)args[4], (int)args[5]);
|
||||||
break;
|
break;
|
||||||
@ -390,6 +402,27 @@ namespace BipEmulator.Host
|
|||||||
Marshal.FreeHGlobal(pnt);
|
Marshal.FreeHGlobal(pnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private byte[] GetUserResData(int resId, int offset, int len)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_userResFile == null)
|
||||||
|
{
|
||||||
|
_userResFile = ResFile.Load(tbUserResFile.Text);
|
||||||
|
var data = new byte[len];
|
||||||
|
if (offset + len > _userResFile.Resources[resId].Length)
|
||||||
|
return null;
|
||||||
|
Buffer.BlockCopy(_userResFile.Resources[resId], 0, data, 0, len);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Debug.WriteLine("Exception GetUserResData");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private ResImage GetUserResImage(int resId)
|
private ResImage GetUserResImage(int resId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -221,6 +221,16 @@ namespace BipEmulatorProxy
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int CallbackInt(String^ fName, int p0, int p1, int p2, void* p3, int p4)
|
||||||
|
{
|
||||||
|
if (CallbackFunc != nullptr)
|
||||||
|
{
|
||||||
|
array<Object^>^ arr = gcnew array<Object^>(6) { fName, p0, p1, p2, gcnew IntPtr(p3), p4 };
|
||||||
|
return safe_cast<int>(CallbackFunc(arr));
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static int CallbackInt(String^ fName, int p0, int p1, int p2, int p3)
|
static int CallbackInt(String^ fName, int p0, int p1, int p2, int p3)
|
||||||
{
|
{
|
||||||
if (CallbackFunc != nullptr)
|
if (CallbackFunc != nullptr)
|
||||||
@ -394,7 +404,6 @@ int get_text_height()
|
|||||||
return BipEmulatorProxy::ProxyLib::CallbackInt("get_text_height");
|
return BipEmulatorProxy::ProxyLib::CallbackInt("get_text_height");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int get_res_params(int index_listed, int res_id, struct res_params_* res_params)
|
int get_res_params(int index_listed, int res_id, struct res_params_* res_params)
|
||||||
{
|
{
|
||||||
return BipEmulatorProxy::ProxyLib::CallbackInt("get_res_params", index_listed, res_id, (void*)res_params);
|
return BipEmulatorProxy::ProxyLib::CallbackInt("get_res_params", index_listed, res_id, (void*)res_params);
|
||||||
@ -540,6 +549,11 @@ int ElfWriteSettings(int index_listed, void* buffer, int offset, int len)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int read_elf_res_by_id(int index_listed, int res_id, int offset, void* buffer, int len)
|
||||||
|
{
|
||||||
|
return BipEmulatorProxy::ProxyLib::CallbackInt("read_elf_res_by_id", index_listed, res_id, offset, buffer, len);
|
||||||
|
}
|
||||||
|
|
||||||
void _srand(unsigned int seed)
|
void _srand(unsigned int seed)
|
||||||
{
|
{
|
||||||
srand(seed);
|
srand(seed);
|
||||||
|
@ -65,7 +65,7 @@ struct gesture_ {
|
|||||||
#define GESTURE_SWIPE_UP 2 // ñâàéï ñíèçó ââåðõ
|
#define GESTURE_SWIPE_UP 2 // ñâàéï ñíèçó ââåðõ
|
||||||
#define GESTURE_SWIPE_DOWN 3 // ñâàéï ñâåðõó âíèç
|
#define GESTURE_SWIPE_DOWN 3 // ñâàéï ñâåðõó âíèç
|
||||||
#define GESTURE_SWIPE_LEFT 4 // ñâàéï ñïðàâà íàëåâî
|
#define GESTURE_SWIPE_LEFT 4 // ñâàéï ñïðàâà íàëåâî
|
||||||
#define GESTURE_SWIPE_RIGHT 5 // ñâàéï ñëåâà íàïðàâî
|
#define GESTURE_SWIPE_RIGHT 5 // ñâàéï ñëåâà íàïðàâî
|
||||||
|
|
||||||
// âèä àíèìàöèè äëÿ ôóíêöèè show_menu_animate
|
// âèä àíèìàöèè äëÿ ôóíêöèè show_menu_animate
|
||||||
#define ANIMATE_LEFT 0 // àíèìàöèÿ ïåðåõîäà ýêðàíà ñïðàâà íàëåâî
|
#define ANIMATE_LEFT 0 // àíèìàöèÿ ïåðåõîäà ýêðàíà ñïðàâà íàëåâî
|
||||||
@ -129,6 +129,9 @@ struct res_params_ {
|
|||||||
short height; // âûñîòà â ðõ
|
short height; // âûñîòà â ðõ
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define INDEX_MAIN_RES ((int)0xFFFF0000)
|
||||||
|
#define ELF_INDEX_SELF ((int)0xFFFFFFFF)
|
||||||
|
|
||||||
// ñòðóêòóðû äàííûõ äàò÷èêà ñåðäöà
|
// ñòðóêòóðû äàííûõ äàò÷èêà ñåðäöà
|
||||||
// 1.1.5.12, 1.1.5.36
|
// 1.1.5.12, 1.1.5.36
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -258,6 +261,8 @@ void draw_filled_rect_bg(int from_x, int from_y, int to_x, int to_y);
|
|||||||
int ElfReadSettings(int index_listed, void* buffer, int offset, int len);
|
int ElfReadSettings(int index_listed, void* buffer, int offset, int len);
|
||||||
// çàïèñü ñåêöèè íàñòðîåê êîíêðåòíîãî ýëüôà
|
// çàïèñü ñåêöèè íàñòðîåê êîíêðåòíîãî ýëüôà
|
||||||
int ElfWriteSettings(int index_listed, void* buffer, int offset, int len);
|
int ElfWriteSettings(int index_listed, void* buffer, int offset, int len);
|
||||||
|
// ÷òåíèå äàííûõ ðåñóðñîâ (ñòàíäàðòíûõ è ïðèëîæåíèÿ) íà÷èíàÿ ñ offset äëèíîé len ïî åãî íîìåðó res_id
|
||||||
|
int read_elf_res_by_id(int index_listed, int res_id, int offset, void* buffer, int len);
|
||||||
// îòîáðàæåíèå ãðàôè÷åñêîãî ðåñóðñà ïî åãî íîìåðó
|
// îòîáðàæåíèå ãðàôè÷åñêîãî ðåñóðñà ïî åãî íîìåðó
|
||||||
void show_res_by_id(int res_ID, int pos_x, int pos_y);
|
void show_res_by_id(int res_ID, int pos_x, int pos_y);
|
||||||
// îòîáðàæàåò íà ýêðàíå ãðàôè÷åñêèé ðåñóðñ êîíêðåòíîãî ýëüôà, ñîäåðæàùèéñÿ â ñåêöèè .elf.resources
|
// îòîáðàæàåò íà ýêðàíå ãðàôè÷åñêèé ðåñóðñ êîíêðåòíîãî ýëüôà, ñîäåðæàùèéñÿ â ñåêöèè .elf.resources
|
||||||
|
Loading…
x
Reference in New Issue
Block a user