From b67d68409ebb287a458a6880ecad35d28d973d03 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Thu, 28 Aug 2014 04:45:41 +0200 Subject: [PATCH] [Reduction] #242: egc_shift_left --- libs/master.lib/egc_shift_left.asm | 182 +++++++++++++++++++++++++++++ th02_maine.asm | 167 +------------------------- th04_main.asm | 126 +------------------- th05_main.asm | 129 +------------------- 4 files changed, 189 insertions(+), 415 deletions(-) create mode 100644 libs/master.lib/egc_shift_left.asm diff --git a/libs/master.lib/egc_shift_left.asm b/libs/master.lib/egc_shift_left.asm new file mode 100644 index 00000000..137e6c9a --- /dev/null +++ b/libs/master.lib/egc_shift_left.asm @@ -0,0 +1,182 @@ +; master library - +; +; Description: +; EGCによる部分左スクロール +; +; Functions/Procedures: +; void egc_shift_left(int x1, int y1, int x2, int y2, int dots); +; +; Parameters: +; dots +; +; Returns: +; none +; +; Binding Target: +; Microsoft-C / Turbo-C / Turbo Pascal +; +; Running Target: +; PC-9801VX +; +; Requiring Resources: +; CPU: 186 +; EGC +; +; Notes: +; +; +; Assembly Language Note: +; +; +; Compiler/Assembler: +; TASM 3.0 +; OPTASM 1.6 +; +; Author: +; Kazumi +; +; Revision History: +;$Id: lshift.asm 0.04 92/05/28 22:55:10 Kazumi Rel $ +; 94/ 5/16 Initial: egcsftl.asm/master.lib 0.23 +; + +func EGC_SHIFT_LEFT ; egc_shift_left() { + push BP + mov BP,SP + push DS + push SI + push DI + + x1 = (RETSIZE+5)*2 + y1 = (RETSIZE+4)*2 + x2 = (RETSIZE+3)*2 + y2 = (RETSIZE+2)*2 + dots = (RETSIZE+1)*2 + + mov CX,[BP+x1] + mov SI,[BP+y1] + mov DX,[BP+x2] + mov BX,[BP+y2] + mov DI,[BP+dots] + mov AX,DI + dec AX ; 94/05/13 dots が 16 の倍数のとき + shr AX,4 + shl AX,1 + mov BYTE PTR CS:[egcsftl_start_di],AL + sub BX,SI + inc BX ; line count + mov AX,SI + shl SI,2 + add SI,AX + shl SI,4 ; y1 * 80 + mov AX,CX + shr AX,3 + and AX,0fffeh ; LSB = 0 + add SI,AX ; start address + shr AX,1 + mov BP,DX + shr BP,4 + sub BP,AX + inc BP + mov AX,BP + mov BP,DX + sub BP,CX ; bit length(not inc !!) + mov ES,CX + mov CX,AX ; 転送 word 数 + mov DX,ES + sub DX,DI + and DX,000fh ; Dest Bit Address + mov AX,ES + and AX,000fh ; Src Bit Address + push BX + push BP + mov BX,BP + add BX,AX + shr BX,4 + add BP,DX + shr BP,4 + cmp AL,DL + je short @@none + jl short @@less + cmp BX,BP + jne short @@none + jmp SHORT @@plus + EVEN +@@less: cmp BX,BP + jge short @@none + EVEN +@@plus: inc CX + EVEN +@@none: pop BP + pop BX + shl DL,4 + or DL,AL + xor DH,DH + mov DI,DX + mov AX,41 + sub AX,CX + shl AX,1 + mov BYTE PTR CS:[egcsftl_add_si],AL + mov BYTE PTR CS:[egcsftl_add_di],AL + mov AL,00000111b ; RegWriteEnable + out 6ah,AL + mov AL,80h ; CGmode = 1 + out 7ch,AL + mov AL,05h ; ExBit = 1 + out 6ah,AL + mov DX,04a0h + mov AX,0fff0h ; アクティブプレーン + out DX,AX + mov DX,04a2h + mov AX,00ffh ; FGC/BGC/リードプレーン + out DX,AX + mov DX,04a4h + mov AX,28f0h ; モードレジスタ/ROPコードレジスタ + out DX,AX + mov DX,04a8h + mov AX,0ffffh ; マスクレジスタ + out DX,AX + mov DX,04ach + mov AX,DI ; Dir/Bitアドレス + out DX,AX + mov DX,04aeh + mov AX,BP ; ビット長 + out DX,AX + mov AX,0a800h + mov DS,AX + mov ES,AX + mov DI,SI + dec DI + dec DI + sub DI,80 ; dummy +egcsftl_start_di EQU $-1 + mov DX,CX + EVEN +@@next_line: mov CX,DX + rep movsw + dec SI + dec SI + dec DI + dec DI + add SI,80 ; dummy +egcsftl_add_si EQU $-1 + add DI,80 ; dummy +egcsftl_add_di EQU $-1 + dec BX + jne @@next_line + mov DX,04a0h + mov AX,0fff0h + out DX,AX + mov AL,04h ; ExBit = 0 + out 6ah,AL + mov AL,00h ; GRCG stop + out 7ch,AL + mov AL,00000110b ; RegWriteDIsable + out 6ah,AL + + pop DI + pop SI + pop DS + pop BP + ret 5*2 +endfunc ; } diff --git a/th02_maine.asm b/th02_maine.asm index cc6da73b..5f223172 100644 --- a/th02_maine.asm +++ b/th02_maine.asm @@ -87,170 +87,7 @@ sub_73A endp include libs/master.lib/dos_setvect.asm include libs/master.lib/egc.asm include libs/master.lib/egc_shift_down.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_8FA proc far - -arg_0 = word ptr 6 -arg_2 = word ptr 8 -arg_4 = word ptr 0Ah -arg_6 = word ptr 0Ch -arg_8 = word ptr 0Eh - - push bp - mov bp, sp - push ds - push si - push di - mov cx, [bp+arg_8] - mov si, [bp+arg_6] - mov dx, [bp+arg_4] - mov bx, [bp+arg_2] - mov di, [bp+arg_0] - mov ax, di - dec ax - shr ax, 4 - shl ax, 1 - mov byte ptr cs:loc_9CB+2, al - sub bx, si - inc bx - mov ax, si - shl si, 2 - add si, ax - shl si, 4 - mov ax, cx - shr ax, 3 - and ax, 0FFFEh - add si, ax - shr ax, 1 - mov bp, dx - shr bp, 4 - sub bp, ax - inc bp - mov ax, bp - mov bp, dx - sub bp, cx - mov es, cx - assume es:nothing - mov cx, ax - mov dx, es - sub dx, di - and dx, 0Fh - mov ax, es - and ax, 0Fh - push bx - push bp - mov bx, bp - add bx, ax - shr bx, 4 - add bp, dx - shr bp, 4 - cmp al, dl - jz short loc_972 - jl short loc_96C - cmp bx, bp - jnz short loc_972 - jmp short loc_970 -; --------------------------------------------------------------------------- - -loc_96C: - cmp bx, bp - jge short loc_972 - -loc_970: - inc cx - nop - -loc_972: - pop bp - pop bx - shl dl, 4 - or dl, al - xor dh, dh - mov di, dx - mov ax, 29h ; ')' - sub ax, cx - shl ax, 1 - mov byte ptr cs:loc_9D8+2, al - mov byte ptr cs:loc_9DB+2, al - mov al, 7 - out 6Ah, al ; PC-98 GDC (6a): - ; - mov al, 80h ; '' - out 7Ch, al - mov al, 5 - out 6Ah, al ; PC-98 GDC (6a): - ; - mov dx, 4A0h - mov ax, 0FFF0h - out dx, ax - mov dx, 4A2h - mov ax, 0FFh - out dx, ax - mov dx, 4A4h - mov ax, 28F0h - out dx, ax - mov dx, 4A8h - mov ax, 0FFFFh - out dx, ax - mov dx, 4ACh - mov ax, di - out dx, ax - mov dx, 4AEh - mov ax, bp - out dx, ax - mov ax, 0A800h - mov ds, ax - assume ds:nothing - mov es, ax - assume es:nothing - mov di, si - dec di - dec di - -loc_9CB: - sub di, 50h ; 'P' - mov dx, cx - -loc_9D0: - mov cx, dx - rep movsw - dec si - dec si - dec di - dec di - -loc_9D8: - add si, 50h ; 'P' - -loc_9DB: - add di, 50h ; 'P' - dec bx - jnz short loc_9D0 - mov dx, 4A0h - mov ax, 0FFF0h - out dx, ax - mov al, 4 - out 6Ah, al ; PC-98 GDC (6a): - ; - mov al, 0 - out 7Ch, al - mov al, 6 - out 6Ah, al ; PC-98 GDC (6a): - ; - pop di - pop si - pop ds - assume ds:dseg - pop bp - retf 0Ah -sub_8FA endp - -; --------------------------------------------------------------------------- - nop +include libs/master.lib/egc_shift_left.asm ; =============== S U B R O U T I N E ======================================= @@ -14785,7 +14622,7 @@ loc_9B1B: lea ax, [si+13Fh] push ax push large 12B0004h - call sub_8FA + call egc_shift_left push large 0C00000h call grcg_setcolor lea ax, [si+138h] diff --git a/th04_main.asm b/th04_main.asm index 615dfe3a..5f820ee4 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -91,129 +91,7 @@ include libs/master.lib/dos_seek.asm include libs/master.lib/dos_setvect.asm include libs/master.lib/egc.asm include libs/master.lib/egc_shift_down.asm - -loc_A22: - push bp - mov bp, sp - push ds - push si - push di - mov cx, [bp+0Eh] - mov si, [bp+0Ch] - mov dx, [bp+0Ah] - mov bx, [bp+8] - mov di, [bp+6] - mov ax, di - dec ax - shr ax, 4 - shl ax, 1 - mov cs:byte_AF5, al - sub bx, si - inc bx - mov ax, si - shl si, 2 - add si, ax - shl si, 4 - mov ax, cx - shr ax, 3 - and ax, 0FFFEh - add si, ax - shr ax, 1 - mov bp, dx - shr bp, 4 - sub bp, ax - inc bp - mov ax, bp - mov bp, dx - sub bp, cx - mov es, cx - assume es:nothing - mov cx, ax - mov dx, es - sub dx, di - and dx, 0Fh - mov ax, es - and ax, 0Fh - push bx - push bp - mov bx, bp - add bx, ax - shr bx, 4 - add bp, dx - shr bp, 4 - cmp al, dl - jz short loc_A9A - jl short loc_A94 - cmp bx, bp - jnz short loc_A9A - jmp short loc_A98 -; --------------------------------------------------------------------------- - -loc_A94: - cmp bx, bp - jge short loc_A9A - -loc_A98: - inc cx - nop - -loc_A9A: - pop bp - pop bx - shl dl, 4 - or dl, al - xor dh, dh - mov di, dx - mov ax, 29h ; ')' - sub ax, cx - shl ax, 1 - mov cs:byte_B02, al - mov cs:byte_B05, al - mov al, 7 - out 6Ah, al ; PC-98 GDC (6a): - ; - mov al, 80h ; '' - out 7Ch, al - mov al, 5 - out 6Ah, al ; PC-98 GDC (6a): - ; - mov dx, 4A0h - mov ax, 0FFF0h - out dx, ax - mov dx, 4A2h - mov ax, 0FFh - out dx, ax - mov dx, 4A4h - mov ax, 28F0h - out dx, ax - mov dx, 4A8h - mov ax, 0FFFFh - out dx, ax - mov dx, 4ACh - mov ax, di - out dx, ax - mov dx, 4AEh - mov ax, bp - out dx, ax - mov ax, 0A800h - mov ds, ax - mov es, ax - assume es:nothing - mov di, si - dec di - dec di -; --------------------------------------------------------------------------- - db 83h, 0EFh -byte_AF5 db 50h - db 8Bh, 0D1h, 8Bh, 0CAh, 0F3h, 0A5h, 2 dup(4Eh), 2 dup(4Fh) - db 83h, 0C6h -byte_B02 db 50h - db 83h, 0C7h -byte_B05 db 50h - db 4Bh, 75h, 0EFh, 0BAh, 0A0h, 4, 0B8h, 0F0h, 0FFh, 0EFh - db 0B0h, 4, 0E6h, 6Ah, 0B0h, 0, 0E6h, 7Ch, 0B0h, 6, 0E6h - db 6Ah, 5Fh, 5Eh, 1Fh, 5Dh, 0CAh, 0Ah, 0, 90h -; --------------------------------------------------------------------------- +include libs/master.lib/egc_shift_left.asm loc_B24: push bp @@ -20996,7 +20874,7 @@ loc_CD68: mov ax, word_255BE neg ax push ax - call far ptr loc_A22 + call egc_shift_left jmp short loc_CDA4 ; --------------------------------------------------------------------------- diff --git a/th05_main.asm b/th05_main.asm index 1c7095c0..28280549 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -48,130 +48,7 @@ include libs/master.lib/dos_seek.asm include libs/master.lib/dos_setvect.asm include libs/master.lib/egc.asm include libs/master.lib/egc_shift_down.asm - -loc_9B0: - ; sub_10287+62P - push bp - mov bp, sp - push ds - push si - push di - mov cx, [bp+0Eh] - mov si, [bp+0Ch] - mov dx, [bp+0Ah] - mov bx, [bp+8] - mov di, [bp+6] - mov ax, di - dec ax - shr ax, 4 - shl ax, 1 - mov cs:byte_A83, al - sub bx, si - inc bx - mov ax, si - shl si, 2 - add si, ax - shl si, 4 - mov ax, cx - shr ax, 3 - and ax, 0FFFEh - add si, ax - shr ax, 1 - mov bp, dx - shr bp, 4 - sub bp, ax - inc bp - mov ax, bp - mov bp, dx - sub bp, cx - mov es, cx - assume es:nothing - mov cx, ax - mov dx, es - sub dx, di - and dx, 0Fh - mov ax, es - and ax, 0Fh - push bx - push bp - mov bx, bp - add bx, ax - shr bx, 4 - add bp, dx - shr bp, 4 - cmp al, dl - jz short loc_A28 - jl short loc_A22 - cmp bx, bp - jnz short loc_A28 - jmp short loc_A26 -; --------------------------------------------------------------------------- - -loc_A22: - cmp bx, bp - jge short loc_A28 - -loc_A26: - inc cx - nop - -loc_A28: - pop bp - pop bx - shl dl, 4 - or dl, al - xor dh, dh - mov di, dx - mov ax, 29h ; ')' - sub ax, cx - shl ax, 1 - mov cs:byte_A90, al - mov cs:byte_A93, al - mov al, 7 - out 6Ah, al ; PC-98 GDC (6a): - ; - mov al, 80h ; '' - out 7Ch, al - mov al, 5 - out 6Ah, al ; PC-98 GDC (6a): - ; - mov dx, 4A0h - mov ax, 0FFF0h - out dx, ax - mov dx, 4A2h - mov ax, 0FFh - out dx, ax - mov dx, 4A4h - mov ax, 28F0h - out dx, ax - mov dx, 4A8h - mov ax, 0FFFFh - out dx, ax - mov dx, 4ACh - mov ax, di - out dx, ax - mov dx, 4AEh - mov ax, bp - out dx, ax - mov ax, 0A800h - mov ds, ax - mov es, ax - assume es:nothing - mov di, si - dec di - dec di -; --------------------------------------------------------------------------- - db 83h, 0EFh -byte_A83 db 50h - db 8Bh, 0D1h, 8Bh, 0CAh, 0F3h, 0A5h, 2 dup(4Eh), 2 dup(4Fh) - db 83h, 0C6h -byte_A90 db 50h - db 83h, 0C7h -byte_A93 db 50h - db 4Bh, 75h, 0EFh, 0BAh, 0A0h, 4, 0B8h, 0F0h, 0FFh, 0EFh - db 0B0h, 4, 0E6h, 6Ah, 0B0h, 0, 0E6h, 7Ch, 0B0h, 6, 0E6h - db 6Ah, 5Fh, 5Eh, 1Fh, 5Dh, 0CAh, 0Ah, 0, 90h -; --------------------------------------------------------------------------- +include libs/master.lib/egc_shift_left.asm loc_AB2: push bp @@ -27961,13 +27838,13 @@ loc_102B9: mov ax, word_2CE02 neg ax push ax - call far ptr loc_9B0 + call egc_shift_left push large 200000h push large 19F018Fh mov ax, word_2CE02 neg ax push ax - call far ptr loc_9B0 + call egc_shift_left jmp short loc_1030C ; ---------------------------------------------------------------------------