int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int eax) { struct TASK *task = task_now(); int ds_base = task->ds_base; struct CONSOLE *cons = task->cons; struct SHTCTL *shtctl = (struct SHTCTL *) *((int *) 0x0fe4); struct SHEET *sht; struct FIFO32 *sys_fifo = (struct FIFO32 *) *((int *) 0x0fec); int *reg = &eax + 1; /* eaxの次の番地 */ /* 保存のためのPUSHADを強引に書き換える */ /* reg[0] : EDI, reg[1] : ESI, reg[2] : EBP, reg[3] : ESP */ /* reg[4] : EBX, reg[5] : EDX, reg[6] : ECX, reg[7] : EAX */ int i; struct FILEINFO *finfo; struct FILEHANDLE *fh; struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR; if (edx == 1) { cons_putchar(cons, eax & 0xff, 1); } else if (edx == 2) { cons_putstr0(cons, (char *) ebx + ds_base); } else if (edx == 3) { cons_putstr1(cons, (char *) ebx + ds_base, ecx); } else if (edx == 4) { return &(task->tss.esp0); } else if (edx == 5) { sht = sheet_alloc(shtctl); sht->task = task; sht->flags |= 0x10; sheet_setbuf(sht, (char *) ebx + ds_base, esi, edi, eax); make_window8((char *) ebx + ds_base, esi, edi, (char *) ecx + ds_base, 0); sheet_slide(sht, ((shtctl->xsize - esi) / 2) & ~3, (shtctl->ysize - edi) / 2); sheet_updown(sht, shtctl->top); /* 今のマウスと同じ高さになるように指定: マウスはこの上になる */ reg[7] = (int) sht; } else if (edx == 6) { sht = (struct SHEET *) (ebx & 0xfffffffe); putfonts8_asc(sht->buf, sht->bxsize, esi, edi, eax, (char *) ebp + ds_base); if ((ebx & 1) == 0) { sheet_refresh(sht, esi, edi, esi + ecx * 8, edi + 16); } } else if (edx == 7) { sht = (struct SHEET *) (ebx & 0xfffffffe); boxfill8(sht->buf, sht->bxsize, ebp, eax, ecx, esi, edi); if ((ebx & 1) == 0) { sheet_refresh(sht, eax, ecx, esi + 1, edi + 1); } } else if (edx == 8) { memman_init((struct MEMMAN *) (ebx + ds_base)); ecx &= 0xfffffff0; /* 16バイト単位に */ memman_free((struct MEMMAN *) (ebx + ds_base), eax, ecx); } else if (edx == 9) { ecx = (ecx + 0x0f) & 0xfffffff0; /* 16バイト単位に切り上げ */ reg[7] = memman_alloc((struct MEMMAN *) (ebx + ds_base), ecx); } else if (edx == 10) { ecx = (ecx + 0x0f) & 0xfffffff0; /* 16バイト単位に切り上げ */ memman_free((struct MEMMAN *) (ebx + ds_base), eax, ecx); } else if (edx == 11) { sht = (struct SHEET *) (ebx & 0xfffffffe); sht->buf[sht->bxsize * edi + esi] = eax; if ((ebx & 1) == 0) { sheet_refresh(sht, esi, edi, esi + 1, edi + 1); } } else if (edx == 12) { sht = (struct SHEET *) ebx; sheet_refresh(sht, eax, ecx, esi, edi); } else if (edx == 13) { sht = (struct SHEET *) (ebx & 0xfffffffe); hrb_api_linewin(sht, eax, ecx, esi, edi, ebp); if ((ebx & 1) == 0) { sheet_refresh(sht, eax, ecx, esi + 1, edi + 1); } } else if (edx == 14) { sheet_free((struct SHEET *) ebx); } else if (edx == 15) { for (;;) { io_cli(); if (fifo32_status(&task->fifo) == 0) { if (eax != 0) { task_sleep(task); /* FIFOが空なので寝て待つ */ } else { io_sti(); reg[7] = -1; return 0; } } i = fifo32_get(&task->fifo); io_sti(); if (i <= 1 && cons->sht != 0) { /* カーソル用タイマ */ /* アプリ実行中はカーソルが出ないので、いつも次は表示用の1を注文しておく */ timer_init(cons->timer, &task->fifo, 1); /* 次は1を */ timer_settime(cons->timer, 50); } if (i == 2) { /* カーソルON */ cons->cur_c = COL8_FFFFFF; } if (i == 3) { /* カーソルOFF */ cons->cur_c = -1; } if (i == 4) { /* コンソールだけを閉じる */ timer_cancel(cons->timer); io_cli(); fifo32_put(sys_fifo, cons->sht - shtctl->sheets0 + 2024); /* 2024〜2279 */ cons->sht = 0; io_sti(); } if (i >= 256) { /* キーボードデータ(タスクA経由)など */ reg[7] = i - 256; return 0; } } } else if (edx == 16) { reg[7] = (int) timer_alloc(); ((struct TIMER *) reg[7])->flags2 = 1; /* 自動キャンセル有効 */ } else if (edx == 17) { timer_init((struct TIMER *) ebx, &task->fifo, eax + 256); } else if (edx == 18) { timer_settime((struct TIMER *) ebx, eax); } else if (edx == 19) { timer_free((struct TIMER *) ebx); } else if (edx == 20) { if (eax == 0) { i = io_in8(0x61); io_out8(0x61, i & 0x0d); } else { i = 1193180000 / eax; io_out8(0x43, 0xb6); io_out8(0x42, i & 0xff); io_out8(0x42, i >> 8); i = io_in8(0x61); io_out8(0x61, (i | 0x03) & 0x0f); } } else if (edx == 21) {
int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int eax) { struct TASK *task = task_now(); int ds_base = task->ds_base; struct CONSOLE *cons = task->cons; struct SHTCTL *shtctl = (struct SHTCTL *) *((int *) 0x0fe4); struct SHEET *sht; struct FIFO32 *sys_fifo = (struct FIFO32 *) *((int *) 0x0fec); int *reg = &eax + 1; /* 返し値 */ int i; struct FILEINFO *finfo; struct FILEHANDLE *fh; struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR; unsigned char *p; int *memtotal = (int *) *((int *) 0x0fe2); struct TASK *task2; struct FIFO32 *fifo; struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO; int bpp = binfo->vmode; unsigned short *sp; unsigned int *ip; struct PICTURE *pic; if (edx == 1) { cons_putchar(cons, eax & 0xff, 1); } else if (edx == 2) { cons_putstr0(cons, (char *) ebx + ds_base); } else if (edx == 3) { cons_putstr1(cons, (char *) ebx + ds_base, ecx); } else if (edx == 4) { return &(task->tss.esp0); } else if (edx == 5) { sht = sheet_alloc(shtctl); sht->task = task; sht->flags |= 0x10; sheet_setbuf(sht, (char *) ebx + ds_base, esi, edi, eax); make_window((unsigned int *) ((char *) ebx + ds_base), esi, edi, (char *) ecx + ds_base, 0, 0); sht->windowname = (char *) ecx + ds_base; sheet_slide(sht, ((shtctl->xsize - esi) / 2) & ~3, (shtctl->ysize - edi) / 2); keywin_off(shtctl->sheets[shtctl->top - 2]); sheet_updown(sht, shtctl->top - 1); keywin_on(sht); fifo32_put(sys_fifo, 0x4000); /* key_win変更要求 */ reg[7] = (int) sht; } else if (edx == 6) { sht = (struct SHEET *) (ebx & 0xfffffffe); putfonts((unsigned int *) (sht->buf), sht->bxsize, esi, edi, get_color(1, eax), (char *) ebp + ds_base); if ((ebx & 1) == 0) { sheet_refresh(sht, esi, edi, esi + ecx * 8, edi + 16); } } else if (edx == 7) { sht = (struct SHEET *) (ebx & 0xfffffffe); boxfill((unsigned int *) (sht->buf), sht->bxsize, get_color(1, ebp), eax, ecx, esi, edi); if ((ebx & 1) == 0) { sheet_refresh(sht, eax, ecx, esi + 1, edi + 1); } } else if (edx == 8) { memman_init((struct MEMMAN *) (ebx + ds_base)); ecx &= 0xfffffff0; /* 16バイト単位にする */ memman_free((struct MEMMAN *) (ebx + ds_base), eax, ecx); } else if (edx == 9) { ecx = (ecx + 0x0f) & 0xfffffff0; /* 16バイト単位に切り上げ */ reg[7] = memman_alloc((struct MEMMAN *) (ebx + ds_base), ecx); } else if (edx == 10) { ecx = (ecx + 0x0f) & 0xfffffff0; /* 16バイト単位に切り上げ */ memman_free((struct MEMMAN *) (ebx + ds_base), eax, ecx); } else if (edx == 11) { sht = (struct SHEET *) (ebx & 0xfffffffe); i = get_color(1, eax); if (bpp == 8) { sht->buf[sht->bxsize * edi + esi] = get_color(bpp, i); } else if (bpp == 16) { sp = (unsigned short *) (sht->buf); sp[sht->bxsize * edi + esi] = get_color(bpp, i); } else if (bpp == 24) { ip = (unsigned int *) (sht->buf); ip[sht->bxsize * edi + esi] = get_color(bpp, i); } if ((ebx & 1) == 0) { sheet_refresh(sht, esi, edi, esi + 1, edi + 1); } } else if (edx == 12) { sht = (struct SHEET *) ebx; sheet_refresh(sht, eax, ecx, esi, edi); } else if (edx == 13) { sht = (struct SHEET *) (ebx & 0xfffffffe); hrb_api_linewin(sht, eax, ecx, esi, edi, get_color(1, ebp)); if ((ebx & 1) == 0) { if (eax > esi) { i = eax; eax = esi; esi = i; } if (ecx > edi) { i = ecx; ecx = edi; edi = i; } sheet_refresh(sht, eax, ecx, esi + 1, edi + 1); } } else if (edx == 14) { sheet_free((struct SHEET *) ebx); keywin_on(shtctl->sheets[shtctl->top - 2]); } else if (edx == 15) { for (;;) { io_cli(); if (fifo32_status(&task->fifo) == 0) { if (eax != 0) { /* fifoカラッポ */ task_sleep(task); /* 寝て待つ */ } else { io_sti(); reg[7] = -1; return 0; } } i = fifo32_get(&task->fifo); io_sti(); if (i <= 1) { /* カーソル用 */ /* アプリ実行中はカーソルが出ないので、いつも次は表示用の1を注文 */ timer_init(cons->timer, &task->fifo, 1); timer_settime(cons->timer, 50); } if (i == 2) { /* カーソルON */ cons->curcol = 0xffffff; } if (i == 3) { /* カーソルOFF */ cons->curcol = -1; } if (i == 4) { timer_cancel(cons->timer); io_cli(); fifo32_put(sys_fifo, cons->sht - shtctl->sheets0 + 2024); /* 2024〜2279 */ cons->sht = 0; io_sti(); } if (i >= 256) { reg[7] = i - 256; return 0; } } } else if (edx == 16) { reg[7] = (int) timer_alloc(); ((struct TIMER *) reg[7])->flags2 = 1; /* 自動キャンセル有効 */ } else if (edx == 17) { timer_init((struct TIMER *) ebx, &task->fifo, eax + 256); } else if (edx == 18) { timer_settime((struct TIMER *) ebx, eax); } else if (edx == 19) { timer_free((struct TIMER *) ebx); } else if (edx == 20) { if (eax == 0) { /* 音を消す */ i = io_in8(0x61); io_out8(0x61, i & 0x0d); } else { i = 1193180000 / eax; io_out8(0x43, 0xb6); io_out8(0x42, i & 0xff); io_out8(0x42, i >> 8); i = io_in8(0x61); io_out8(0x61, (i | 0x03) & 0x0f); } } else if (edx == 21) {
int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int eax) { struct TASK *task = task_now(); int ds_base = task->ds_base; struct CONSOLE *cons = task->cons; struct SHTCTL *shtctl = (struct SHTCTL *) *((int *) 0x0fe4); struct SHEET *sht; struct FIFO32 *sys_fifo = (struct FIFO32 *) *((int *) 0x0fec); int *reg = &eax + 1; /* eax�� ���� ���� */ /* ������ ���� PUSHAD�� ������ ���� */ /* reg[0] : EDI, reg[1] : ESI, reg[2] : EBP, reg[3] : ESP */ /* reg[4] : EBX, reg[5] : EDX, reg[6] : ECX, reg[7] : EAX */ int i; struct FILEINFO *finfo; struct FILEHANDLE *fh; struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR; if (edx == 1) { // api_putchar cons_putchar(cons, eax & 0xff, 1); } else if (edx == 2) { // api_putstr0 cons_putstr0(cons, (char *) ebx + ds_base); } else if (edx == 3) { // api_putstr1 cons_putstr1(cons, (char *) ebx + ds_base, ecx); } else if (edx == 4) { // api_end return &(task->tss.esp0); } else if (edx == 5) { // api_openwin sht = sheet_alloc(shtctl); sht->task = task; sht->flags |= 0x10; sheet_setbuf(sht, (char *) ebx + ds_base, esi, edi, eax); make_window8((char *) ebx + ds_base, esi, edi, (char *) ecx + ds_base, 0); sheet_slide(sht, ((shtctl->xsize - esi) / 2) & ~3, (shtctl->ysize - edi) / 2); sheet_updown(sht, shtctl->top); /* ������ ���콺�� ���� ���̰� �ǵ��� ������ ���콺�� �� ���� �ȴ� */ reg[7] = (int) sht; } else if (edx == 6) { // api_putstrwin sht = (struct SHEET *) (ebx & 0xfffffffe); putfonts8_asc(sht->buf, sht->bxsize, esi, edi, eax, (char *) ebp + ds_base); if ((ebx & 1) == 0) { sheet_refresh(sht, esi, edi, esi + ecx * 8, edi + 16); } } else if (edx == 7) { // api_boxfilwin sht = (struct SHEET *) (ebx & 0xfffffffe); boxfill8(sht->buf, sht->bxsize, ebp, eax, ecx, esi, edi); if ((ebx & 1) == 0) { sheet_refresh(sht, eax, ecx, esi + 1, edi + 1); } } else if (edx == 8) { // api_initmalloc memman_init((struct MEMMAN *) (ebx + ds_base)); ecx &= 0xfffffff0; /* 16����Ʈ ������ */ memman_free((struct MEMMAN *) (ebx + ds_base), eax, ecx); } else if (edx == 9) { // api_malloc ecx = (ecx + 0x0f) & 0xfffffff0; /* 16����Ʈ ������ ���� */ reg[7] = memman_alloc((struct MEMMAN *) (ebx + ds_base), ecx); } else if (edx == 10) { // api_free ecx = (ecx + 0x0f) & 0xfffffff0; /* 16����Ʈ ������ ���� */ memman_free((struct MEMMAN *) (ebx + ds_base), eax, ecx); } else if (edx == 11) { // api_point sht = (struct SHEET *) (ebx & 0xfffffffe); sht->buf[sht->bxsize * edi + esi] = eax; if ((ebx & 1) == 0) { sheet_refresh(sht, esi, edi, esi + 1, edi + 1); } } else if (edx == 12) { // api_refreshwin sht = (struct SHEET *) ebx; sheet_refresh(sht, eax, ecx, esi, edi); } else if (edx == 13) { // api_linewin sht = (struct SHEET *) (ebx & 0xfffffffe); hrb_api_linewin(sht, eax, ecx, esi, edi, ebp); if ((ebx & 1) == 0) { if (eax > esi) { i = eax; eax = esi; esi = i; } if (ecx > edi) { i = ecx; ecx = edi; edi = i; } sheet_refresh(sht, eax, ecx, esi + 1, edi + 1); } } else if (edx == 14) { // api_closewin sheet_free((struct SHEET *) ebx); } else if (edx == 15) { // api_getkey for (;;) { io_cli(); if (fifo32_status(&task->fifo) == 0) { if (eax != 0) { task_sleep(task); /* FIFO�� ������Ƿ� ��ٸ��� */ } else { io_sti(); reg[7] = -1; return 0; } } i = fifo32_get(&task->fifo); io_sti(); if (i <= 1 && cons->sht != 0) { /* Ŀ���� Ÿ�̸� */ /* ���ø����̼� �������� Ŀ���� ������ �ʱ� ������, ǥ�ÿ� 1�� call */ timer_init(cons->timer, &task->fifo, 1); /* ������ 1�� */ timer_settime(cons->timer, 50); } if (i == 2) { /* Ŀ�� ON */ cons->cur_c = COL8_FFFFFF; } if (i == 3) { /* Ŀ�� OFF */ cons->cur_c = -1; } if (i == 4) { /* �ָܼ��� �ݴ´� */ timer_cancel(cons->timer); io_cli(); fifo32_put(sys_fifo, cons->sht - shtctl->sheets0 + 2024); /* 2024~2279 */ cons->sht = 0; io_sti(); } if (i >= 256) { /* Ű���� ������(�½�ũ A����) �� */ reg[7] = i - 256; return 0; } } } else if (edx == 16) { // api_alloctimer reg[7] = (int) timer_alloc(); ((struct TIMER *) reg[7])->flags2 = 1; /* �ڵ� ĵ�� ��ȿ */ } else if (edx == 17) { // api_inittimer timer_init((struct TIMER *) ebx, &task->fifo, eax + 256); } else if (edx == 18) { // api_settimer timer_settime((struct TIMER *) ebx, eax); } else if (edx == 19) { // api_freetimer timer_free((struct TIMER *) ebx); } else if (edx == 20) { // api_beep if (eax == 0) { i = io_in8(0x61); io_out8(0x61, i & 0x0d); } else { i = 1193180000 / eax; io_out8(0x43, 0xb6); io_out8(0x42, i & 0xff); io_out8(0x42, i >> 8); i = io_in8(0x61); io_out8(0x61, (i | 0x03) & 0x0f); } } else if (edx == 21) {