From 14e69ceb6d0e1f525066bb56af62a8e8d2d8863e Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sat, 5 Sep 2015 22:06:46 +0200 Subject: [PATCH] [C decompilation] [th01] VSync interrupt handler Time to get back into this. --- Makefile.mak | 6 +- th01/fuuin_05.c | 7 + th01/hardware/vsync.c | 80 +++++++++ th01/hardware/vsync[bss].asm | 5 + th01/hardware/vsync[data].asm | 46 ++++++ th01/hardware/vsyncclr.c | 12 ++ th01/main_03.c | 6 + th01/main_04.c | 1 + th01/op_03.c | 7 + th01_fuuin.asm | 294 ++------------------------------- th01_op.asm | 277 ++----------------------------- th01_reiiden.asm | 298 ++-------------------------------- 12 files changed, 209 insertions(+), 830 deletions(-) create mode 100644 th01/fuuin_05.c create mode 100644 th01/hardware/vsync.c create mode 100644 th01/hardware/vsync[bss].asm create mode 100644 th01/hardware/vsync[data].asm create mode 100644 th01/hardware/vsyncclr.c create mode 100644 th01/main_03.c create mode 100644 th01/op_03.c diff --git a/Makefile.mak b/Makefile.mak index cf35aa99..76ea8c47 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -28,17 +28,17 @@ th05:: $(TH05:\=bin\th05\) bin\th01\zunsoft.com: th01\zunsoft.c $(CC) $(CFLAGS) -mt -lt -nbin\th01\ $** masters.lib -bin\th01\op.exe: bin\th01\op.obj th01\op_04.c th01\op_10.c th01\op_11.c th01\op_12.cpp +bin\th01\op.exe: bin\th01\op.obj th01\op_03.c th01\op_04.c th01\op_10.c th01\op_11.c th01\op_12.cpp $(CC) $(CFLAGS) -ml -3 -nbin\th01\ -eOP.EXE @&&| $** | -bin\th01\reiiden.exe: bin\th01\reiiden.obj th01\main_04.c th01\main_12.c th01\main_13.c th01\main_14.c th01\main_16.c +bin\th01\reiiden.exe: bin\th01\reiiden.obj th01\main_03.c th01\main_04.c th01\main_12.c th01\main_13.c th01\main_14.c th01\main_16.c $(CC) $(CFLAGS) -ml -3 -nbin\th01\ -eREIIDEN.EXE @&&| $** | -bin\th01\fuuin.exe: bin\th01\fuuin.obj th01\fuuin_06.c th01\fuuin_11.c th01\fuuin_12.c th01\fuuin_13.c +bin\th01\fuuin.exe: bin\th01\fuuin.obj th01\fuuin_05.c th01\fuuin_06.c th01\fuuin_11.c th01\fuuin_12.c th01\fuuin_13.c $(CC) $(CFLAGS) -ml -3 -nbin\th01\ -eFUUIN.EXE @&&| $** | diff --git a/th01/fuuin_05.c b/th01/fuuin_05.c new file mode 100644 index 00000000..d2432a6e --- /dev/null +++ b/th01/fuuin_05.c @@ -0,0 +1,7 @@ +/* ReC98 + * ----- + * Code segment #5 of TH01's FUUIN.EXE + */ + +#include "th01/hardware/vsync.c" +#include "th01/hardware/vsyncclr.c" diff --git a/th01/hardware/vsync.c b/th01/hardware/vsync.c new file mode 100644 index 00000000..f8aaa09c --- /dev/null +++ b/th01/hardware/vsync.c @@ -0,0 +1,80 @@ +/* ReC98 + * ----- + * VSync interrupt handler + */ + +#include "th01/th01.h" + +#pragma option -2 +#pragma warn -aus + +extern char vsync_initialized; +extern int vsync_callback_is_set; + +extern int RES_X_HALF; +extern int RES_Y_HALF; + +extern int vsync_frame; +extern int vsync_unused; +extern void interrupt (*vsync_callback_old)(void); +extern void (*vsync_callback)(void); + +static void interrupt vsync_intfunc(void) +{ + int res_x_half = RES_X_HALF; + int res_y_half = RES_Y_HALF; + vsync_frame++; + vsync_unused++; + if(vsync_callback_is_set) { + vsync_callback(); + } + OUTB(0x00, 0x20); // End of Interrupt + OUTB(0x64, 0); // VSync interrupt trigger +} + +void vsync_init(void) +{ + if(vsync_initialized == 0) { + vsync_initialized = 1; + disable(); + vsync_callback_old = getvect(0x0A); + setvect(0x0A, vsync_intfunc); + + // Disable all interrupts from 0x08 to 0x0F except for 0x0A + OUTB(0x02, INPB(0x02) & 0xFB); + + OUTB(0x64, 0); // VSync interrupt trigger + enable(); + } +} + +void vsync_exit(void) +{ + if(vsync_initialized == 1) { + vsync_initialized = 0; + disable(); + + // Reenable all interrupts from 0x08 to 0x0F except for 0x0A + OUTB(0x02, INPB(0x02) | 0x04); + + setvect(0x0a, vsync_callback_old); + enable(); + } +} + +void z_vsync_wait(void) +{ + do { + _AL = INPB(0x60); + } while((_AL & 0x20) != 0); + do { + _AL = INPB(0x60); + } while((_AL & 0x20) == 0); +} + +void vsync_callback_set(void (*vsync_callback_new)()) +{ + vsync_callback_is_set = 0; + vsync_callback = vsync_callback_new; + vsync_callback_is_set = 1; +} diff --git a/th01/hardware/vsync[bss].asm b/th01/hardware/vsync[bss].asm new file mode 100644 index 00000000..642f1242 --- /dev/null +++ b/th01/hardware/vsync[bss].asm @@ -0,0 +1,5 @@ +public _vsync_frame, _vsync_unused, _vsync_callback_old, _vsync_callback +_vsync_frame dw ? +_vsync_unused dw ? +_vsync_callback_old dd ? +_vsync_callback dd ? diff --git a/th01/hardware/vsync[data].asm b/th01/hardware/vsync[data].asm new file mode 100644 index 00000000..104b2276 --- /dev/null +++ b/th01/hardware/vsync[data].asm @@ -0,0 +1,46 @@ +public _vsync_initialized, _vsync_callback_is_set, _RES_X_HALF, _RES_Y_HALF +_vsync_initialized db 0 +_vsync_callback_is_set dw 0 + dd 7 + dd 0 +_RES_X_HALF dw 320 +_RES_Y_HALF dw 200 + +; Unused? + dw 0 + dw 0 + dw 639 + dw 399 + dw 0C000h + dw 0E000h + dw 0F000h + dw 0F800h + dw 0FC00h + dw 0FE00h + dw 0FF00h + dw 0FF80h + dw 0FFC0h + dw 0FFE0h + dw 0FE00h + dw 0EF00h + dw 0CF00h + dw 780h + dw 780h + dw 300h + dw 0 + dw 4000h + dw 6000h + dw 7000h + dw 7800h + dw 7C00h + dw 7E00h + dw 7F00h + dw 7F80h + dw 7C00h + dw 6C00h + dw 4600h + dw 600h + dw 300h + dw 300h + dw 0 + db 0 diff --git a/th01/hardware/vsyncclr.c b/th01/hardware/vsyncclr.c new file mode 100644 index 00000000..2be8681f --- /dev/null +++ b/th01/hardware/vsyncclr.c @@ -0,0 +1,12 @@ +/* ReC98 + * ----- + * VSync interrupt callback clear function. In REIIDEN.EXE, this function needs + * to be put into a segment separate from vsync.c. + */ + +extern int vsync_callback_is_set; + +void vsync_callback_clear(void) +{ + vsync_callback_is_set = 0; +} diff --git a/th01/main_03.c b/th01/main_03.c new file mode 100644 index 00000000..daa593c1 --- /dev/null +++ b/th01/main_03.c @@ -0,0 +1,6 @@ +/* ReC98 + * ----- + * Code segment #3 of TH01's REIIDEN.EXE + */ + +#include "th01/hardware/vsync.c" diff --git a/th01/main_04.c b/th01/main_04.c index e99658c1..6e935639 100644 --- a/th01/main_04.c +++ b/th01/main_04.c @@ -3,4 +3,5 @@ * Code segment #4 of TH01's REIIDEN.EXE */ +#include "th01/hardware/vsyncclr.c" #include "th01/ztext.c" diff --git a/th01/op_03.c b/th01/op_03.c new file mode 100644 index 00000000..841b467f --- /dev/null +++ b/th01/op_03.c @@ -0,0 +1,7 @@ +/* ReC98 + * ----- + * Code segment #3 of TH01's OP.EXE + */ + +#include "th01/hardware/vsync.c" +#include "th01/hardware/vsyncclr.c" diff --git a/th01_fuuin.asm b/th01_fuuin.asm index 2fe42409..62c89638 100644 --- a/th01_fuuin.asm +++ b/th01_fuuin.asm @@ -5363,10 +5363,10 @@ arg_0 = word ptr 6 push bp mov bp, sp - mov word_14044, 0 + mov _vsync_frame, 0 loc_C836: - mov ax, word_14044 + mov ax, _vsync_frame cmp ax, [bp+arg_0] jnb short loc_C840 jmp short loc_C836 @@ -5748,192 +5748,9 @@ fuuin_04_TEXT ends ; Segment type: Pure code fuuin_05_TEXT segment byte public 'CODE' use16 - assume cs:fuuin_05_TEXT - assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -; void __interrupt isr() -isr proc far - -var_4 = word ptr -4 -var_2 = word ptr -2 - - push ax - push bx - push cx - push dx - push es - push ds - push si - push di - push bp - mov bp, seg _DATA - mov ds, bp - mov bp, sp - sub sp, 4 - mov ax, word_1344D - mov [bp+var_2], ax - mov ax, word_1344F - mov [bp+var_4], ax - inc word_14044 - inc word_14046 - cmp word_13443, 0 - jz short loc_CA72 - call farfp_1404C - -loc_CA72: - xor dx, dx - mov al, 20h ; ' ' - out dx, al - mov dx, 64h ; 'd' - mov al, 0 - out dx, al ; AT Keyboard controller 8042. - leave - pop di - pop si - pop ds - pop es - pop dx - pop cx - pop bx - pop ax - iret -isr endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_CA87 proc far - push bp - mov bp, sp - cmp byte_13442, 0 - jnz short loc_CAC7 - mov byte_13442, 1 - cli - push 0Ah ; interruptno - call _getvect - pop cx - mov word_1404A, dx - mov off_14048, ax - push seg fuuin_05_TEXT - push offset isr ; isr - push 0Ah ; interruptno - call _setvect - add sp, 6 - mov dx, 2 - in al, dx ; DMA controller, 8237A-5. - ; channel 1 current address - and al, 0FBh - mov dx, 2 - out dx, al ; DMA controller, 8237A-5. - ; channel 1 base address - ; (also sets current address) - mov dx, 64h ; 'd' - mov al, 0 - out dx, al ; AT Keyboard controller 8042. - sti - -loc_CAC7: - pop bp - retf -sub_CA87 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_CAC9 proc far - push bp - mov bp, sp - cmp byte_13442, 1 - jnz short loc_CAF6 - mov byte_13442, 0 - cli - mov dx, 2 - in al, dx ; DMA controller, 8237A-5. - ; channel 1 current address - or al, 4 - mov dx, 2 - out dx, al ; DMA controller, 8237A-5. - ; channel 1 base address - ; (also sets current address) - push word_1404A - push off_14048 ; isr - push 0Ah ; interruptno - call _setvect - add sp, 6 - sti - -loc_CAF6: - pop bp - retf -sub_CAC9 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_CAF8 proc far - push bp - mov bp, sp - -loc_CAFB: - mov dx, 60h - in al, dx ; AT Keyboard controller 8042. - test al, 20h - jnz short loc_CAFB - -loc_CB03: - mov dx, 60h - in al, dx ; AT Keyboard controller 8042. - test al, 20h - jz short loc_CB03 - pop bp - retf -sub_CAF8 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_CB0D proc far - -arg_0 = word ptr 6 -arg_2 = word ptr 8 - - push bp - mov bp, sp - mov word_13443, 0 - mov dx, [bp+arg_2] - mov ax, [bp+arg_0] - mov word ptr farfp_1404C+2, dx - mov word ptr farfp_1404C, ax - mov word_13443, 1 - pop bp - retf -sub_CB0D endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_CB2B proc far - push bp - mov bp, sp - mov word_13443, 0 - pop bp - retf -sub_CB2B endp - + extern _vsync_init:proc + extern _vsync_exit:proc + extern _z_vsync_wait:proc fuuin_05_TEXT ends ; =========================================================================== @@ -6006,7 +5823,7 @@ sub_CEAD proc far push 6 ; interruptno call _setvect add sp, 6 - call sub_CA87 + call _vsync_init call _z_text_init call egc_start call graph_start @@ -6075,7 +5892,7 @@ sub_CF48 proc far push offset sub_CE87 ; isr push 6 ; interruptno call _setvect - call sub_CAC9 + call _vsync_exit call _z_text_clear call sub_D4FE call sub_D094 @@ -6945,7 +6762,7 @@ var_2 = word ptr -2 ; --------------------------------------------------------------------------- loc_D470: - call sub_CAF8 + call _z_vsync_wait xor si, si jmp short loc_D4E2 ; --------------------------------------------------------------------------- @@ -7050,7 +6867,7 @@ var_2 = word ptr -2 ; --------------------------------------------------------------------------- loc_D51E: - call sub_CAF8 + call _z_vsync_wait xor si, si jmp short loc_D585 ; --------------------------------------------------------------------------- @@ -7178,7 +6995,7 @@ var_2 = word ptr -2 ; --------------------------------------------------------------------------- loc_D5E1: - call sub_CAF8 + call _z_vsync_wait xor si, si jmp short loc_D653 ; --------------------------------------------------------------------------- @@ -7283,7 +7100,7 @@ var_2 = word ptr -2 ; --------------------------------------------------------------------------- loc_D68F: - call sub_CAF8 + call _z_vsync_wait xor si, si jmp short loc_D6F6 ; --------------------------------------------------------------------------- @@ -9454,7 +9271,7 @@ loc_E7C1: ; --------------------------------------------------------------------------- loc_E7CD: - call sub_CAF8 + call _z_vsync_wait mov [bp+var_2], 0 jmp loc_E88C ; --------------------------------------------------------------------------- @@ -10552,85 +10369,7 @@ aKo_0 db ' aC db '%c',0 ; char aCC_5[] aCC_5 db '%c%c',0 -byte_13442 db 0 -word_13443 dw 0 - db 7 - dd 0 - db 0 - db 0 - db 0 -word_1344D dw 140h -word_1344F dw 0C8h - dd 0 - db 7Fh - db 2 - db 8Fh - db 1 - db 0 - db 0C0h ; タ - db 0 - db 0E0h - db 0 - db 0F0h - db 0 - db 0F8h - db 0 - db 0FCh - db 0 - db 0FEh - db 0 - db 0FFh - db 80h - db 0FFh - db 0C0h ; タ - db 0FFh - db 0E0h - db 0FFh - db 0 - db 0FEh - db 0 - db 0EFh - db 0 - db 0CFh ; マ - db 80h - db 7 - db 80h - db 7 - db 0 - db 3 - db 0 - db 0 - db 0 - db 40h - db 0 - db 60h - db 0 - db 70h ; p - db 0 - db 78h ; x - db 0 - db 7Ch ; | - db 0 - db 7Eh ; ~ - db 0 - db 7Fh - db 80h - db 7Fh - db 0 - db 7Ch ; | - db 0 - db 6Ch ; l - db 0 - db 46h ; F - db 0 - db 6 - db 0 - db 3 - db 0 - db 3 - db 0 - db 0 - db 0 +include th01/hardware/vsync[data].asm include th01/ztext[data].asm byte_134B8 db 0 db 0 @@ -10827,12 +10566,7 @@ byte_14040 db ? byte_14041 db ? byte_14042 db ? db ? -word_14044 dw ? -word_14046 dw ? -; void (__interrupt far *off_14048)() -off_14048 dw ? -word_1404A dw ? -farfp_1404C dd ? +include th01/hardware/vsync[bss].asm dd ? dd ? dd ? diff --git a/th01_op.asm b/th01_op.asm index 524dd58d..99b13b68 100644 --- a/th01_op.asm +++ b/th01_op.asm @@ -2113,10 +2113,10 @@ arg_0 = word ptr 6 mov bp, sp loc_B26C: - mov ax, word_1355C + mov ax, _vsync_frame cmp ax, [bp+arg_0] jb short loc_B26C - mov word_1355C, 0 + mov _vsync_frame, 0 pop bp retf sub_B269 endp @@ -2127,175 +2127,9 @@ op_02_TEXT ends ; Segment type: Pure code op_03_TEXT segment byte public 'CODE' use16 - assume cs:op_03_TEXT - ;org 0Ch - assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -; void __interrupt isr() -isr proc far - -var_4 = word ptr -4 -var_2 = word ptr -2 - - push ax - push bx - push cx - push dx - push es - push ds - push si - push di - push bp - mov bp, seg _DATA - mov ds, bp - mov bp, sp - sub sp, 4 - mov ax, word_1290D - mov [bp+var_2], ax - mov ax, word_1290F - mov [bp+var_4], ax - inc word_1355C - inc word_1355E - cmp word_12903, 0 - jz short loc_B2AE - call farfp_13564 - -loc_B2AE: - xor dx, dx - mov al, 20h ; ' ' - out dx, al - mov dx, 64h ; 'd' - mov al, 0 - out dx, al ; AT Keyboard controller 8042. - leave - pop di - pop si - pop ds - pop es - pop dx - pop cx - pop bx - pop ax - iret -isr endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_B2C3 proc far - push bp - mov bp, sp - cmp byte_12902, 0 - jnz short loc_B303 - mov byte_12902, 1 - cli - push 0Ah ; interruptno - call _getvect - pop cx - mov word_13562, dx - mov off_13560, ax - push seg op_03_TEXT - push offset isr ; isr - push 0Ah ; interruptno - call _setvect - add sp, 6 - mov dx, 2 - in al, dx ; DMA controller, 8237A-5. - ; channel 1 current address - and al, 0FBh - mov dx, 2 - out dx, al ; DMA controller, 8237A-5. - ; channel 1 base address - ; (also sets current address) - mov dx, 64h ; 'd' - mov al, 0 - out dx, al ; AT Keyboard controller 8042. - sti - -loc_B303: - pop bp - retf -sub_B2C3 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_B305 proc far - push bp - mov bp, sp - cmp byte_12902, 1 - jnz short loc_B332 - mov byte_12902, 0 - cli - mov dx, 2 - in al, dx ; DMA controller, 8237A-5. - ; channel 1 current address - or al, 4 - mov dx, 2 - out dx, al ; DMA controller, 8237A-5. - ; channel 1 base address - ; (also sets current address) - push word_13562 - push off_13560 ; isr - push 0Ah ; interruptno - call _setvect - add sp, 6 - sti - -loc_B332: - pop bp - retf -sub_B305 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_B334 proc far - push bp - mov bp, sp - -loc_B337: - mov dx, 60h - in al, dx ; AT Keyboard controller 8042. - test al, 20h - jnz short loc_B337 - -loc_B33F: - mov dx, 60h - in al, dx ; AT Keyboard controller 8042. - test al, 20h - jz short loc_B33F - pop bp - retf -sub_B334 endp - -; --------------------------------------------------------------------------- - push bp - mov bp, sp - mov word_12903, 0 - mov dx, [bp+8] - mov ax, [bp+6] - mov word ptr farfp_13564+2, dx - mov word ptr farfp_13564, ax - mov word_12903, 1 - pop bp - retf -; --------------------------------------------------------------------------- - push bp - mov bp, sp - mov word_12903, 0 - pop bp - retf + extern _vsync_init:proc + extern _vsync_exit:proc + extern _z_vsync_wait:proc op_03_TEXT ends ; =========================================================================== @@ -2368,7 +2202,7 @@ sub_B6E9 proc far push 6 ; interruptno call _setvect add sp, 6 - call sub_B2C3 + call _vsync_init call _z_text_init call egc_start call graph_start @@ -2437,7 +2271,7 @@ sub_B784 proc far push offset sub_B6C3 ; isr push 6 ; interruptno call _setvect - call sub_B305 + call _vsync_exit call _z_text_clear call sub_BD3A call sub_B8D0 @@ -3261,7 +3095,7 @@ var_2 = word ptr -2 ; --------------------------------------------------------------------------- loc_BCAC: - call sub_B334 + call _z_vsync_wait xor si, si jmp short loc_BD1E ; --------------------------------------------------------------------------- @@ -3366,7 +3200,7 @@ var_2 = word ptr -2 ; --------------------------------------------------------------------------- loc_BD5A: - call sub_B334 + call _z_vsync_wait xor si, si jmp short loc_BDC1 ; --------------------------------------------------------------------------- @@ -3476,7 +3310,7 @@ loc_BDF4: ; --------------------------------------------------------------------------- loc_BE1D: - call sub_B334 + call _z_vsync_wait xor si, si jmp short loc_BE8F ; --------------------------------------------------------------------------- @@ -3568,7 +3402,7 @@ loc_BE9F: ; --------------------------------------------------------------------------- loc_BECB: - call sub_B334 + call _z_vsync_wait xor si, si jmp short loc_BF32 ; --------------------------------------------------------------------------- @@ -5592,7 +5426,7 @@ loc_CFFD: ; --------------------------------------------------------------------------- loc_D009: - call sub_B334 + call _z_vsync_wait mov word ptr [bp-2], 0 jmp loc_D0C8 ; --------------------------------------------------------------------------- @@ -8205,85 +8039,7 @@ aGogbgGtg@gcglv db ' aCon db 'CON',0 ; char format[] format db 'おつかれさまでした!!',0Ah,0 -byte_12902 db 0 -word_12903 dw 0 - db 7 - dd 0 - db 0 - db 0 - db 0 -word_1290D dw 140h -word_1290F dw 0C8h - dd 0 - db 7Fh - db 2 - db 8Fh - db 1 - db 0 - db 0C0h - db 0 - db 0E0h - db 0 - db 0F0h - db 0 - db 0F8h - db 0 - db 0FCh - db 0 - db 0FEh - db 0 - db 0FFh - db 80h - db 0FFh - db 0C0h - db 0FFh - db 0E0h - db 0FFh - db 0 - db 0FEh - db 0 - db 0EFh - db 0 - db 0CFh - db 80h - db 7 - db 80h - db 7 - db 0 - db 3 - db 0 - db 0 - db 0 - db 40h - db 0 - db 60h - db 0 - db 70h ; p - db 0 - db 78h ; x - db 0 - db 7Ch ; | - db 0 - db 7Eh ; ~ - db 0 - db 7Fh - db 80h - db 7Fh - db 0 - db 7Ch ; | - db 0 - db 6Ch ; l - db 0 - db 46h ; F - db 0 - db 6 - db 0 - db 3 - db 0 - db 3 - db 0 - db 0 - db 0 +include th01/hardware/vsync[data].asm include th01/ztext[data].asm byte_12978 db 0 db 0 @@ -8450,12 +8206,7 @@ dword_13418 dd ? dd ? dd ? dd ? -word_1355C dw ? -word_1355E dw ? -; void (__interrupt far *off_13560)() -off_13560 dw ? -word_13562 dw ? -farfp_13564 dd ? +include th01/hardware/vsync[bss].asm dd ? dd ? dd ? diff --git a/th01_reiiden.asm b/th01_reiiden.asm index ab6227ec..af1c6f16 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -5370,12 +5370,12 @@ arg_0 = word ptr 6 mov bp, sp loc_E367: - mov ax, word_38812 + mov ax, _vsync_frame cmp ax, [bp+arg_0] jb short loc_E367 loc_E36F: - mov word_38812, 0 + mov _vsync_frame, 0 pop bp retf sub_E364 endp @@ -5386,202 +5386,15 @@ main_02_TEXT ends ; Segment type: Pure code main_03_TEXT segment byte public 'CODE' use16 - assume cs:main_03_TEXT - ;org 7 - assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -; void __interrupt isr() -isr proc far - -var_4 = word ptr -4 -var_2 = word ptr -2 - - push ax - push bx - push cx - push dx - push es - push ds - push si - push di - push bp - mov bp, seg _DATA - mov ds, bp - mov bp, sp - sub sp, 4 - mov ax, word_35023 - mov [bp+var_2], ax - mov ax, word_35025 - mov [bp+var_4], ax - inc word_38812 - inc word_38814 - cmp word_35019, 0 - jz short loc_E3A9 - call farfp_3881A - -loc_E3A9: - xor dx, dx - mov al, 20h ; ' ' - out dx, al - mov dx, 64h ; 'd' - mov al, 0 - out dx, al ; AT Keyboard controller 8042. - leave - pop di - pop si - pop ds - pop es - pop dx - pop cx - pop bx - pop ax - iret -isr endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_E3BE proc far - push bp - mov bp, sp - cmp byte_35018, 0 - jnz short loc_E3FE - mov byte_35018, 1 - cli - push 0Ah ; interruptno - call _getvect - pop cx - mov word_38818, dx - mov off_38816, ax - push seg main_03_TEXT - push offset isr ; isr - push 0Ah ; interruptno - call _setvect - add sp, 6 - mov dx, 2 - in al, dx ; DMA controller, 8237A-5. - ; channel 1 current address - and al, 0FBh - mov dx, 2 - out dx, al ; DMA controller, 8237A-5. - ; channel 1 base address - ; (also sets current address) - mov dx, 64h ; 'd' - mov al, 0 - out dx, al ; AT Keyboard controller 8042. - sti - -loc_E3FE: - pop bp - retf -sub_E3BE endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_E400 proc far - push bp - mov bp, sp - cmp byte_35018, 1 - jnz short loc_E42D - mov byte_35018, 0 - cli - mov dx, 2 - in al, dx ; DMA controller, 8237A-5. - ; channel 1 current address - or al, 4 - mov dx, 2 - out dx, al ; DMA controller, 8237A-5. - ; channel 1 base address - ; (also sets current address) - push word_38818 - push off_38816 ; isr - push 0Ah ; interruptno - call _setvect - add sp, 6 - sti - -loc_E42D: - pop bp - retf -sub_E400 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_E42F proc far - push bp - mov bp, sp - -loc_E432: - mov dx, 60h - in al, dx ; AT Keyboard controller 8042. - test al, 20h - jnz short loc_E432 - -loc_E43A: - mov dx, 60h - in al, dx ; AT Keyboard controller 8042. - test al, 20h - jz short loc_E43A - pop bp - retf -sub_E42F endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_E444 proc far - -arg_0 = word ptr 6 -arg_2 = word ptr 8 - - push bp - mov bp, sp - mov word_35019, 0 - mov dx, [bp+arg_2] - mov ax, [bp+arg_0] - mov word ptr farfp_3881A+2, dx - mov word ptr farfp_3881A, ax - mov word_35019, 1 - pop bp - retf -sub_E444 endp - + extern _vsync_init:proc + extern _vsync_exit:proc + extern _z_vsync_wait:proc main_03_TEXT ends ; =========================================================================== ; Segment type: Pure code main_04_TEXT segment byte public 'CODE' use16 - assume cs:main_04_TEXT - ;org 2 - assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_E462 proc far - push bp - mov bp, sp - mov word_35019, 0 - pop bp - retf -sub_E462 endp - extern _z_text_init:proc extern _z_text_25line:proc extern _z_text_setcursor:proc @@ -5649,7 +5462,7 @@ sub_E7E4 proc far push 6 ; interruptno call _setvect add sp, 6 - call sub_E3BE + call _vsync_init call _z_text_init call egc_start call graph_start @@ -5718,7 +5531,7 @@ sub_E87F proc far push offset sub_E7BE ; isr push 6 ; interruptno call _setvect - call sub_E400 + call _vsync_exit call _z_text_clear call sub_EE35 call sub_E9CB @@ -6598,7 +6411,7 @@ var_2 = word ptr -2 ; --------------------------------------------------------------------------- loc_EDA7: - call sub_E42F + call _z_vsync_wait xor si, si jmp short loc_EE19 ; --------------------------------------------------------------------------- @@ -6703,7 +6516,7 @@ var_2 = word ptr -2 ; --------------------------------------------------------------------------- loc_EE55: - call sub_E42F + call _z_vsync_wait xor si, si jmp short loc_EEBC ; --------------------------------------------------------------------------- @@ -6831,7 +6644,7 @@ var_2 = word ptr -2 ; --------------------------------------------------------------------------- loc_EF18: - call sub_E42F + call _z_vsync_wait xor si, si jmp short loc_EF8A ; --------------------------------------------------------------------------- @@ -6936,7 +6749,7 @@ var_2 = word ptr -2 ; --------------------------------------------------------------------------- loc_EFC6: - call sub_E42F + call _z_vsync_wait xor si, si jmp short loc_F02D ; --------------------------------------------------------------------------- @@ -9107,7 +8920,7 @@ loc_100F8: ; --------------------------------------------------------------------------- loc_10104: - call sub_E42F + call _z_vsync_wait mov [bp+var_2], 0 jmp loc_101C3 ; --------------------------------------------------------------------------- @@ -29824,85 +29637,7 @@ aTn db ' ; char aOp[3] aOp db 'op',0 db 0 -byte_35018 db 0 -word_35019 dw 0 - db 7 - dd 0 - db 0 - db 0 - db 0 -word_35023 dw 140h -word_35025 dw 0C8h - dd 0 - db 7Fh - db 2 - db 8Fh - db 1 - db 0 - db 0C0h ; タ - db 0 - db 0E0h - db 0 - db 0F0h - db 0 - db 0F8h - db 0 - db 0FCh - db 0 - db 0FEh - db 0 - db 0FFh - db 80h - db 0FFh - db 0C0h ; タ - db 0FFh - db 0E0h - db 0FFh - db 0 - db 0FEh - db 0 - db 0EFh - db 0 - db 0CFh ; マ - db 80h - db 7 - db 80h - db 7 - db 0 - db 3 - db 0 - db 0 - db 0 - db 40h - db 0 - db 60h - db 0 - db 70h ; p - db 0 - db 78h ; x - db 0 - db 7Ch ; | - db 0 - db 7Eh ; ~ - db 0 - db 7Fh - db 80h - db 7Fh - db 0 - db 7Ch ; | - db 0 - db 6Ch ; l - db 0 - db 46h ; F - db 0 - db 6 - db 0 - db 3 - db 0 - db 3 - db 0 - db 0 - db 0 +include th01/hardware/vsync[data].asm include th01/ztext[data].asm byte_3508E db 0 db 0 @@ -33111,12 +32846,7 @@ word_387DA dw ? dword_3880A dd ? word_3880E dw ? word_38810 dw ? -word_38812 dw ? -word_38814 dw ? -; void (__interrupt far *off_38816)() -off_38816 dw ? -word_38818 dw ? -farfp_3881A dd ? +include th01/hardware/vsync[bss].asm dd ? dd ? dd ?