2 /*
\83V
\83X
\83e
\83\80\83f
\81[
\83^
\8c^
\90é
\8c¾*/
\r
5 //typedef enum _bool { false, true} bool;
\r
6 typedef unsigned char bool;
\r
7 typedef unsigned char uchar;
\r
8 typedef unsigned short ushort;
\r
9 typedef unsigned int uint;
\r
10 typedef enum _col_text { black, blue, green, skyblue, red, purple, brown, white} col_text;
\r
11 typedef unsigned char sector[512];
\r
15 typedef union CPU_CONTROL_REGISTER0 {
\r
17 struct CPU_CONTROL_REGISTER0_BIT {
\r
51 } CPU_ControlRegister0;
\r
53 typedef union CPU_CONTROL_REGISTER3 {
\r
55 struct CPU_CONTROL_REGISTER3_BIT {
\r
70 } CPU_ControlRegister3;
\r
72 typedef union CPU_CONTROL_REGISTER4 {
\r
74 struct CPU_CONTROL_REGISTER4_BIT {
\r
84 unsigned OSFXSR : 1;
\r
85 unsigned OSXMMEXCPT : 1;
\r
93 unsigned OSXSAVE : 1;
\r
100 unsigned bit25 : 1;
\r
101 unsigned bit26 : 1;
\r
102 unsigned bit27 : 1;
\r
103 unsigned bit28 : 1;
\r
104 unsigned bit29 : 1;
\r
105 unsigned bit30 : 1;
\r
106 unsigned bit31 : 1;
\r
108 } CPU_ControlRegister4;
\r
110 typedef union CPU_DEBUG_REGISTER6 {
\r
112 struct CPU_DEBUG_REGISTER6_BIT {
\r
117 unsigned bit4_11 : 8; //1
\r
118 unsigned bit12 : 1; //0
\r
122 unsigned bit16_31 : 16;
\r
124 } CPU_DebugRegister6;
\r
126 typedef union CPU_DEBUG_REGISTER7 {
\r
128 struct CPU_DEBUG_REGISTER7_BIT {
\r
137 unsigned LE : 1; //must be 1
\r
138 unsigned GE : 1; //must be 1
\r
139 unsigned bit10 : 1; //1
\r
140 unsigned bit11 : 1; //0
\r
141 unsigned bit12 : 1; //0
\r
143 unsigned bit14 : 1; //0
\r
144 unsigned bit15 : 1; //0
\r
154 } CPU_DebugRegister7;
\r
156 typedef union CPU_EFLAGS {
\r
158 struct CPU_EFLAGS_BIT {
\r
160 unsigned bit1 : 1; //
\8fí
\82ÉTrue
\81A
\82±
\82ê
\88È
\8aO
\82Ì
\97\
\96ñ
\8dÏ
\82Ý
\83r
\83b
\83g
\82Í
\8fí
\82ÉFalse
\r
173 unsigned bit15 : 1;
\r
180 unsigned bit22 : 1;
\r
181 unsigned bit23 : 1;
\r
182 unsigned bit24 : 1;
\r
183 unsigned bit25 : 1;
\r
184 unsigned bit26 : 1;
\r
185 unsigned bit27 : 1;
\r
186 unsigned bit28 : 1;
\r
187 unsigned bit29 : 1;
\r
188 unsigned bit30 : 1;
\r
189 unsigned bit31 : 1;
\r
193 typedef struct TASK_STATE_SEGMENT {
\r
194 ushort backlink, reserve00;
\r
196 ushort ss0, reserve01;
\r
198 ushort ss1, reserve02;
\r
200 ushort ss2, reserve03;
\r
212 ushort es, reserve04;
\r
213 ushort cs, reserve05;
\r
214 ushort ss, reserve06;
\r
215 ushort ds, reserve07;
\r
216 ushort fs, reserve08;
\r
217 ushort gs, reserve09;
\r
218 ushort ldtr, reserve10;
\r
219 unsigned flag_trap : 1;
\r
220 unsigned reserve11 : 15;
\r
222 } CPU_TaskStateSegment;
\r
224 typedef struct SEGMENT_DESCRIPTOR {
\r
225 ushort limit_low, base_low;
\r
226 uchar base_mid, access_right;
\r
227 uchar limit_high, base_high;
\r
228 } IO_SegmentDescriptor;
\r
230 typedef struct GATE_DESCRIPTOR {
\r
231 ushort offset_low, selector;
\r
232 uchar dw_count, access_right;
\r
233 ushort offset_high;
\r
234 } IO_GateDescriptor;
\r
237 typedef struct IO_MEMORYCONTROLTAG {
\r
240 } IO_MemoryControlTag;
\r
242 typedef IO_MemoryControlTag* IO_MemoryControl;
\r
245 typedef struct SYSTEM_COMMON_STRUCT {
\r
248 } System_CommonStruct;
\r
251 typedef struct FIFO32 {
\r
252 System_CommonStruct common_tag;
\r
254 uint p, q, size, free;
\r
255 struct FIFO32_FLAGS {
\r
256 unsigned initialized : 1;
\r
257 unsigned overflow : 1;
\r
259 struct UI_TASK *task;
\r
263 typedef struct UI_TASK {
\r
265 struct UI_TASK *next;
\r
268 CPU_TaskStateSegment *tss;
\r
269 struct UI_TASK_STATE_FLAGS {
\r
270 unsigned initialized : 1;
\r
271 unsigned linked : 1;
\r
272 unsigned running : 1;
\r
273 unsigned first_run : 1;
\r
277 typedef struct UI_TASK_CONTROL {
\r
278 struct UI_TASK *start;
\r
279 struct UI_TASK *now;
\r
280 IO_MemoryControl sysmemctrl;
\r
284 typedef struct CALL_BIOS_CONTROL {
\r
285 UI_Task *CallBIOS_Task;
\r
289 CPU_TaskStateSegment retvalue;
\r
291 } IO_CallBIOSControl;
\r
294 typedef struct CFUNCTION_VSNPRINTF_WORKAREA {
\r
295 uchar *destination_buf; /*
\8f\91\82«
\8d\9e\82Ý
\90æ
\95¶
\8e\9a\97ñ
\82Ì
\8aJ
\8en
\83A
\83h
\83\8c\83X*/
\r
296 uint length_destination_buf; /*
\8f\91\82«
\8d\9e\82Ý
\90æ
\95¶
\8e\9a\97ñ
\82Ì
\8dÅ
\91å
\83T
\83C
\83Y*/
\r
297 uint index_destination_buf; /*
\8f\91\82«
\8d\9e\82Ý
\90æ
\95¶
\8e\9a\97ñ
\82Ì
\83C
\83\93\83f
\83b
\83N
\83X*/
\r
299 const uchar *format_buf; /*
\8f\91\8e®
\8ew
\92è
\95¶
\8e\9a\97ñ
\82Ì
\8aJ
\8en
\83A
\83h
\83\8c\83X*/
\r
300 uint index_format_buf; /*
\8f\91\8e®
\8ew
\92è
\95¶
\8e\9a\97ñ
\82Ì
\83C
\83\93\83f
\83b
\83N
\83X*/
\r
302 uchar temporary_data[16]; /*
\88ê
\8e\9e\83f
\81[
\83^
\82Ì
\94z
\97ñ*/
\r
303 uchar temporary_data_double[8]; /*64
\83r
\83b
\83g
\95\82\93®
\8f¬
\90\94\93_
\97p
\83o
\83b
\83t
\83@*/
\r
305 uint *vargs; /*
\89Â
\95Ï
\92·
\88ø
\90\94\82Ì
\8aJ
\8en
\83A
\83h
\83\8c\83X*/
\r
306 uint index_vargs; /*
\89Â
\95Ï
\92·
\88ø
\90\94\82Ì
\8c»
\8dÝ
\82Ì
\8fê
\8f\8a*/
\r
308 uint format_phase; /*
\83t
\83H
\81[
\83}
\83b
\83g
\82Ì
\92i
\8aK
\82ð
\8e¦
\82·
\81B*/
\r
309 /*
\90\94\92l :
\88Ó
\96¡*/
\r
310 /*0 :
\83t
\83H
\81[
\83}
\83b
\83g
\8ew
\92è
\92\86\82Å
\82Í
\82È
\82¢*/
\r
311 /*1 :
\83t
\83\89\83O
\88È
\8d~
\82Ì
\8f\91\8e®
\82ð
\97v
\8b\81*/
\r
312 /*2 :
\83t
\83B
\81[
\83\8b\83h
\95\9d\88È
\8d~
\82Ì
\8f\91\8e®
\82ð
\97v
\8b\81\81B*/
\r
313 /*3 :
\90¸
\93x
\88È
\8d~
\82Ì
\8f\91\8e®
\82ð
\97v
\8b\81\81B*/
\r
314 /*4 :
\95Ï
\8a·
\8fC
\8fü
\8eq
\88È
\8d~
\82Ì
\8f\91\8e®
\82ð
\97v
\8b\81\81B*/
\r
315 /*5 :
\83t
\83H
\81[
\83}
\83b
\83g
\8ew
\92è
\8eq
\82ð
\97v
\8b\81*/
\r
316 } CFunction_vsnprintf_WorkArea;
\r
319 typedef struct EMULATOR_X86_ENVIRONMENT_SEGMENT_REGISTER {
\r
324 } Emulator_x86_Environment_SegmentRegister;
\r
326 typedef struct EMULATOR_X86_ENVIRONMENT_SYSTEM_TABLE_REGISTER {
\r
329 } Emulator_x86_Environment_SystemTableRegister;
\r
331 typedef struct EMULATOR_X86_ENVIRONMENT {
\r
337 Emulator_x86_Environment_SystemTableRegister GDTR;
\r
338 Emulator_x86_Environment_SystemTableRegister IDTR;
\r
340 Emulator_x86_Environment_SegmentRegister SReg[8];
\r
342 CPU_ControlRegister0 CR0;
\r
344 CPU_ControlRegister3 CR3;
\r
345 CPU_ControlRegister4 CR4;
\r
348 uchar operation_end;
\r
349 uchar operation_32bit;
\r
350 uchar operation_prefix_lock_repeat;
\r
351 uchar operation_prefix_segment;
\r
352 uchar operation_prefix_opsize;
\r
353 uchar operation_prefix_addrsize;
\r
354 } Emulator_x86_Environment;
\r
356 typedef union EMULATOR_X86_OPCODE_MODRM {
\r
358 struct EMULATOR_X86_OPCODE_MODRM_BIT {
\r
363 } Emulator_x86_OperationCode_ModRM;
\r
365 typedef struct EMULATOR_X86_FAR_POINTER {
\r
368 } Emulator_x86_FarPointer;
\r
371 typedef struct DATA_LOCATION_2D {
\r
376 typedef struct DATA_LOCATION_2DU {
\r
379 } DATA_Location2DU;
\r
382 typedef struct _INFO_VBE_BIOS {
\r
386 ushort oem_string_offset;
\r
387 ushort oem_string_segment;
\r
388 ushort flags[2]; //
\83p
\83f
\83B
\83\93\83O
\82Ì
\8aÖ
\8cW
\82Å
\81A
\96{
\93\96\82Íuint
\82¾
\82ªushort*2
\82É
\82µ
\82Ä
\82¢
\82é
\81B
\r
389 ushort vmode_args_offset;
\r
390 ushort vmode_args_segment;
\r
391 ushort vram_supported_size_kb;
\r
394 typedef struct _INFO_VBE_VIDEO_MODE {
\r
395 ushort ModeAttributes;
\r
396 uchar WinAAttributes;
\r
397 uchar WinBAttributes;
\r
398 ushort WinGranularity;
\r
400 ushort WinASegment;
\r
401 ushort WinBSegment;
\r
403 ushort BytesPerScanLine;
\r
404 ushort XResolution;
\r
405 ushort YResolution;
\r
408 uchar NumberOfPlanes;
\r
409 uchar BitsPerPixel;
\r
410 uchar NumberOfBanks;
\r
413 uchar NumberOfImagePages;
\r
416 uchar RedFieldPosition;
\r
417 uchar GreenMaskSize;
\r
418 uchar GreenFieldPosition;
\r
419 uchar BlueMaskSize;
\r
420 uchar BlueFieldPosition;
\r
421 uchar RsvdMaskSize;
\r
422 uchar RsvdFieldPodition;
\r
423 uchar DirectColorModeInfo;
\r
425 } INFO_VBE_VideoMode;
\r
427 typedef struct _INFO_VBE_VIDEOMODETAG {
\r
428 ushort mode_number;
\r
432 uchar memory_model; //0x00:text 0x04:256palette 0x06:direct color
\r
433 ushort attribute; //bit3:1:color 0:monochrome
\r
434 //bit4:1:graphic 0:text
\r
435 //bit7:linear buffer support
\r
437 void *vram; //vram:0=not supported.
\r
438 } INFO_VBE_VideoModeTag;
\r
440 typedef struct IO_DISPLAY_CONTROL {
\r
441 struct IO_DISPLAY_CONTROL_VBE {
\r
442 uchar version_minor;
\r
443 uchar version_major;
\r
444 ushort vram_supported_size_kb;
\r
447 ushort *vmode_args;
\r
448 uint list_vmode_tags;
\r
449 INFO_VBE_VideoModeTag *list_vmode;
\r
451 ushort display_mode; //0x0000:BIOS 0x0001:VBE Window Access(version < 2.0)(not implemented) 0x0002:VBE Linear Access
\r
452 ushort vmode; //0x0000:VGA 320x200 8bit
\r
453 ushort vmode_index;
\r
458 DATA_FIFO32 *bios_signal;
\r
459 struct UI_SHEET *vramsheet;
\r
460 } IO_DisplayControl;
\r
463 typedef struct UI_SHEET {
\r
464 System_CommonStruct common_tag;
\r
465 struct UI_SHEET *parent; //one sheet has one parent(if vramseet then:0)
\r
466 struct UI_SHEET *next; //same level sheet link
\r
467 struct UI_SHEET *child; //lowest height sheet in children
\r
468 DATA_Location2D location;
\r
469 DATA_Location2DU size;
\r
471 union UI_SHEET_FLAGS {
\r
473 struct UI_SHEET_FLAGS_BITS {
\r
474 unsigned initialized : 1;
\r
475 unsigned buffer_configured : 1;
\r
476 unsigned visible : 1;
\r
477 unsigned using_map : 1;
\r
478 unsigned vram_auto_allocated : 1;
\r
479 unsigned using_invcol : 1;
\r
480 unsigned topmost : 1;
\r
481 unsigned movable : 1;
\r
482 unsigned autorefresh_upperlevel : 1;
\r
490 uint (*Config_Functions)(struct UI_SHEET *sheet);
\r
491 uint (*RefreshSheet)(struct UI_SHEET *sheet, int px0, int py0, int px1, int py1);
\r
492 bool (*IsVisiblePixel)(struct UI_SHEET *sheet, int px, int py);
\r
493 struct UI_SHEET_DRAWING {
\r
494 uint (*Fill_Rectangle)(struct UI_SHEET *sheet, uint c, int px0, int py0, int px1, int py1);
\r
495 uint (*Put_String)(struct UI_SHEET *sheet, int x, int y, uint fc, const uchar s[]);
\r
496 uint (*Draw_Point)(struct UI_SHEET *sheet, int x, int y, uint c);
\r
498 DATA_FIFO32 *input_fifo;
\r
502 typedef struct UI_TIMER {
\r
505 struct UI_TIMER *root_next;
\r
506 struct UI_TIMER *tree_next;
\r
509 union UI_TIMER_FLAGS {
\r
511 struct UI_TIMER_FLAGS_BITS {
\r
512 unsigned initialized : 1;
\r
513 unsigned configured : 1;
\r
514 unsigned running : 1;
\r
515 unsigned interval : 1;
\r
520 typedef struct UI_TIMER_CONTROL {
\r
522 void (*TaskSwitch)(void);
\r
523 UI_Timer *timer_root;
\r
527 typedef union RGB_32BIT {
\r
529 struct RGB_32BIT_RGBA {
\r
539 typedef struct IO_MOUSE_CONTROL {
\r
541 uchar decode_buf[4];
\r
542 DATA_Location2D move;
\r
544 struct IO_MOUSE_CONTROL_FLAGS {
\r
545 unsigned scroll : 1;
\r
547 union IO_MOUSE_CONTROL_BUTTON {
\r
549 struct IO_MOUSE_CONTROL_BUTTON_BIT {
\r
557 typedef struct UI_MOUSE_CURSOR {
\r
558 UI_Sheet *cursor_sheet;
\r
559 struct UI_MOUSE_CURSOR_FLAGS {
\r
566 typedef struct UI_TEXT_BOX {
\r
567 System_CommonStruct common_tag;
\r
571 DATA_Location2D location_cursor;
\r
572 DATA_Location2D location_cursor_record_started;
\r
573 DATA_Location2DU chars;
\r
575 uint size_text_buf;
\r
576 uint using_text_buf;
\r
578 union UI_TEXT_BOX_FLAGS {
\r
580 struct UI_TEXT_BOX_FLAGS_BITS {
\r
581 unsigned initialized : 1;
\r
582 unsigned textbuffer_configured : 1;
\r
583 unsigned record_input_text : 1;
\r
584 unsigned cursor_blink : 1;
\r
585 unsigned cursor_state : 1;
\r
590 typedef struct IO_FLOPPYDISK_DIRECTORY_ENTRY {
\r
591 uchar name[8]; //0x00:empty(no more files)
\r
593 //0x2e:(only directory)
\r
594 //. 0x2e:current directory
\r
595 //.. 0x2e, 0x2e:parent directory
\r
596 //0xe5:deleted(usable)
\r
598 uchar attribute; //0x0f=LongFileNameEntry
\r
600 uchar VFAT_createTimeMs;
\r
601 ushort VFAT_createTime;
\r
602 ushort VFAT_createDate;
\r
603 ushort VFAT_accessDate;
\r
604 ushort VFAT_clusterHighWord;
\r
608 uint size; //attribute.bit.directory==true:0
\r
609 } IO_FloppyDisk_DirectoryEntry;
\r
611 typedef struct IO_FLOPPYDISK {
\r
612 System_CommonStruct common_tag;
\r
614 IO_FloppyDisk_DirectoryEntry *files;
\r
615 sector *userdataarea;
\r
619 typedef union IO_FLOPPYDISK_DIRECTORY_ENTRY_ATTRIBUTE {
\r
620 uchar attribute; //0x0f=LongFileNameEntry
\r
621 struct IO_FLOPPYDISK_RDE_ATTRIBUTE_BITS {
\r
622 unsigned readonly : 1;
\r
623 unsigned hidden : 1;
\r
624 unsigned system : 1;
\r
625 unsigned volumelabel : 1;
\r
626 unsigned directory : 1;
\r
627 unsigned archive : 1;
\r
631 } IO_FloppyDisk_DirectoryEntry_Attribute;
\r
633 typedef union IO_FLOPPYDISK_DIRECTORY_ENTRY_UPDATETIME {
\r
635 struct IO_FLOPPYDISK_RDE_UPDATETIME_BITS {
\r
636 unsigned second : 5; //second/2
\r
637 unsigned minute : 6;
\r
640 } IO_FloppyDisk_DirectoryEntry_UpdateTime;
\r
642 typedef union IO_FLOPPYDISK_DIRECTORY_ENTRY_UPDATEDATE {
\r
644 struct IO_FLOPPYDISK_RDE_UPDATEDATE_BITS {
\r
645 unsigned day : 5; //day(1-31)
\r
646 unsigned month : 4; //month(1-12)
\r
647 unsigned year : 7; //year(from 1980)
\r
649 } IO_FloppyDisk_DirectoryEntry_UpdateDate;
\r
651 typedef struct UI_CONSOLE {
\r
652 UI_TextBox *textbox;
\r
654 uchar *printf_buffer;
\r
655 union UI_CONSOLE_FLAGS {
\r
657 struct UI_CONSOLE_FLAGS_BITS {
\r
658 unsigned initialized : 1;
\r
659 unsigned configured_size : 1;
\r
660 unsigned isprompt : 1;
\r
663 IO_FloppyDisk *boot_fd;
\r
666 typedef struct IO_FILE {
\r
667 System_CommonStruct common_tag;
\r
671 union IO_FILE_FLAGS {
\r
673 struct IO_FILE_FLAGS_BITS {
\r
674 unsigned initialized : 1;
\r
675 unsigned img_loaded : 1;
\r