diff --git a/th04/hardware/egc.h b/th04/hardware/egc.h new file mode 100644 index 00000000..c6cc1943 --- /dev/null +++ b/th04/hardware/egc.h @@ -0,0 +1,3 @@ +// Blits the rectangle from (⌊x/16⌋*16, y) to (⌈((x + w)/16)*16⌉, (y + h)) +// from VRAM page 1 to the same position on VRAM page 0. +void pascal egc_copy_rect_1_to_0(int x, int y, int w, int h); diff --git a/th04/hardware/egccopyr.asm b/th04/hardware/egccopyr.asm new file mode 100644 index 00000000..00e18672 --- /dev/null +++ b/th04/hardware/egccopyr.asm @@ -0,0 +1,111 @@ +public EGC_COPY_RECT_1_TO_0 +egc_copy_rect_1_to_0 proc far + +@@h = word ptr [bp+6] +@@w = word ptr [bp+8] +@@y = word ptr [bp+10] +@@x = word ptr [bp+12] + +@@row equ bx +@@stride equ bp + + push bp + mov bp, sp + push di +if GAME eq 4 + cld +endif + call egc_start_copy + outw EGC_MODE_ROP_REG, EGC_COMPAREREAD or EGC_WS_ROP or EGC_RL_MEMREAD or 0F0h + mov ax, @@x + mov dx, @@y + mov bx, ax + sar bx, 4 + shl bx, 1 + shl dx, 6 + add bx, dx + shr dx, 2 + add bx, dx + mov di, bx + and ax, 0Fh + mov cx, ax + add ax, @@w + shr ax, 4 + or cx, cx + jz short @@x_on_word_boundary + inc ax + +@@x_on_word_boundary: + mov _egccopyr_width_words, ax + mov cx, (ROW_SIZE / 2) + sub cx, ax + shl cx, 1 + mov @@row, @@h + mov @@stride, cx + mov ax, GRAM_400 + mov es, ax + assume es:nothing + +@@next_row: + mov cx, _egccopyr_width_words + +@@next_word: +if GAME eq 5 + or di, di + js short @@skip + cmp di, (ROW_SIZE * RES_Y) + jnb short @@skip +endif + mov al, 1 + out 0A6h, al + mov dx, es:[di] + xor ax, ax + out 0A6h, al +if GAME eq 5 + mov es:[di], dx + +@@skip: + add di, 2 +else + mov ax, dx + stosw +endif + loop @@next_word + add di, @@stride + dec @@row + jns short @@next_row + call egc_off + pop di + pop bp + retf 8 +egc_copy_rect_1_to_0 endp + align 2 + + +public egc_start_copy +egc_start_copy proc near + push es + push 0 + pop es + pushf + cli + GRCG_SETMODE_VIA_MOV al, GC_TDW + mov es:[495h], al + popf + pop es + assume es:nothing + mov al, 7 + out 6Ah, al + mov al, 5 + out 6Ah, al + mov al, 6 + out 6Ah, al + outw EGC_ACTIVEPLANEREG, 0FFF0h + outw EGC_READPLANEREG, 0FFh + outw EGC_MASKREG, 0FFFFh + mov dx, EGC_ADDRRESSREG + sub ax, ax + out dx, ax + outw EGC_BITLENGTHREG, 0Fh + retn +egc_start_copy endp diff --git a/th04/hardware/egccopyr[bss].asm b/th04/hardware/egccopyr[bss].asm new file mode 100644 index 00000000..efc9291f --- /dev/null +++ b/th04/hardware/egccopyr[bss].asm @@ -0,0 +1,2 @@ +public _egccopyr_width_words +_egccopyr_width_words dw ? diff --git a/th04_op.asm b/th04_op.asm index 68492500..fedb2870 100644 --- a/th04_op.asm +++ b/th04_op.asm @@ -550,7 +550,7 @@ arg_2 = word ptr 6 push 100h push ax push 800010h - call sub_E378 + call egc_copy_rect_1_to_0 call grcg_setcolor pascal, GC_RMW, [bp+arg_0] mov [bp+var_2], si mov bx, si @@ -615,7 +615,7 @@ loc_AB59: call cdg_put pascal, 352, di, 36 pushd 180h push 2800010h - call sub_E378 + call egc_copy_rect_1_to_0 mov _graph_putsa_fx_func, 2 mov bx, [bp+var_2] shl bx, 2 @@ -675,7 +675,7 @@ loc_ABF7: push 0E0h push [bp+var_4] push 0C00010h - call sub_E378 + call egc_copy_rect_1_to_0 loc_AC08: call grcg_setcolor pascal, GC_RMW, [bp+arg_0] @@ -849,7 +849,7 @@ loc_ADC0: call cdg_put pushd 180h push 2800010h - call sub_E378 + call egc_copy_rect_1_to_0 mov _graph_putsa_fx_func, 2 mov bx, si shl bx, 2 @@ -955,7 +955,7 @@ sub_AE96 proc near mov byte_10DAC, 0 push 0C000E0h push 12000A0h - call sub_E378 + call egc_copy_rect_1_to_0 xor si, si jmp short loc_AED6 ; --------------------------------------------------------------------------- @@ -1120,7 +1120,7 @@ sub_B052 proc near mov byte_10DAD, 0 push 11000E0h push 0A00090h - call sub_E378 + call egc_copy_rect_1_to_0 xor si, si jmp short loc_B08D ; --------------------------------------------------------------------------- @@ -1583,7 +1583,7 @@ arg_2 = word ptr 6 shl ax, 4 push ax push 10h - call sub_E378 + call egc_copy_rect_1_to_0 push si push di push 2 @@ -1654,7 +1654,7 @@ arg_2 = word ptr 6 shl ax, 4 push ax push 10h - call sub_E378 + call egc_copy_rect_1_to_0 push si push di push 6 @@ -1778,7 +1778,7 @@ arg_2 = word ptr 6 shl ax, 4 push ax push 20h ; ' ' - call sub_E378 + call egc_copy_rect_1_to_0 push si push di push 5 @@ -4997,112 +4997,8 @@ include th02/initop.asm include th04/formats/cdg_put_noalpha.asm include th04/hardware/input_sense.asm include th04/snd/se.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_E378 proc far - -arg_0 = word ptr 6 -arg_2 = word ptr 8 -arg_4 = word ptr 0Ah -arg_6 = word ptr 0Ch - - push bp - mov bp, sp - push di - cld - call sub_E3E8 - outw EGC_MODE_ROP_REG, EGC_COMPAREREAD or EGC_WS_ROP or EGC_RL_MEMREAD or 0F0h - mov ax, [bp+arg_6] - mov dx, [bp+arg_4] - mov bx, ax - sar bx, 4 - shl bx, 1 - shl dx, 6 - add bx, dx - shr dx, 2 - add bx, dx - mov di, bx - and ax, 0Fh - mov cx, ax - add ax, [bp+arg_2] - shr ax, 4 - or cx, cx - jz short loc_E3B0 - inc ax - -loc_E3B0: - mov word_11A54, ax - mov cx, 28h ; '(' - sub cx, ax - shl cx, 1 - mov bx, [bp+arg_0] - mov bp, cx - mov ax, 0A800h - mov es, ax - assume es:nothing - -loc_E3C4: - mov cx, word_11A54 - -loc_E3C8: - mov al, 1 - out 0A6h, al - mov dx, es:[di] - xor ax, ax - out 0A6h, al - mov ax, dx - stosw - loop loc_E3C8 - add di, bp - dec bx - jns short loc_E3C4 - call egc_off - pop di - pop bp - retf 8 -sub_E378 endp - -; --------------------------------------------------------------------------- - nop - -; =============== S U B R O U T I N E ======================================= - - -sub_E3E8 proc near - push es - push 0 - pop es - pushf - cli - GRCG_SETMODE_VIA_MOV al, GC_TDW - mov byte ptr es:[495h], al - popf - pop es - assume es:nothing - mov al, 7 - out 6Ah, al ; PC-98 GDC (6a): - ; - mov al, 5 - out 6Ah, al ; PC-98 GDC (6a): - ; - mov al, 6 - out 6Ah, al ; PC-98 GDC (6a): - ; - outw EGC_ACTIVEPLANEREG, 0FFF0h - outw EGC_READPLANEREG, 0FFh - outw EGC_MASKREG, 0FFFFh - mov dx, EGC_ADDRRESSREG - sub ax, ax - out dx, ax - outw EGC_BITLENGTHREG, 0Fh - retn -sub_E3E8 endp - -; --------------------------------------------------------------------------- - nop +include th04/hardware/egccopyr.asm + even include th04/bgimage.asm include th04/bgimage_put_rect.asm include th04/formats/cdg_load.asm @@ -5442,7 +5338,7 @@ include libs/master.lib/bgm[bss].asm include th02/snd/load[bss].asm include th04/mem[bss].asm include th04/hardware/input[bss].asm -word_11A54 dw ? +include th04/hardware/egccopyr[bss].asm include th04/formats/cdg[bss].asm dd ? ; dd ? ; diff --git a/th05_maine.asm b/th05_maine.asm index 8985cf41..8df36983 100644 --- a/th05_maine.asm +++ b/th05_maine.asm @@ -460,7 +460,7 @@ arg_6 = word ptr 0Ah push si push di push 14000C8h - call sub_F3FC + call egc_copy_rect_1_to_0 pop di pop si pop bp @@ -1301,7 +1301,7 @@ loc_AE42: loc_AE64: push 0A00040h push 14000C8h - call sub_F3FC + call egc_copy_rect_1_to_0 jmp loc_AF8F ; default ; --------------------------------------------------------------------------- @@ -8298,115 +8298,7 @@ include th05/snd/delaymea.asm include th05/hardware/frame_delay.asm db 0 include th04/formats/cdg_load.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_F3FC proc far - -arg_0 = word ptr 6 -arg_2 = word ptr 8 -arg_4 = word ptr 0Ah -arg_6 = word ptr 0Ch - - push bp - mov bp, sp - push di - call sub_F478 - outw EGC_MODE_ROP_REG, EGC_COMPAREREAD or EGC_WS_ROP or EGC_RL_MEMREAD or 0F0h - mov ax, [bp+arg_6] - mov dx, [bp+arg_4] - mov bx, ax - sar bx, 4 - shl bx, 1 - shl dx, 6 - add bx, dx - shr dx, 2 - add bx, dx - mov di, bx - and ax, 0Fh - mov cx, ax - add ax, [bp+arg_2] - shr ax, 4 - or cx, cx - jz short loc_F433 - inc ax - -loc_F433: - mov word_12F86, ax - mov cx, 28h ; '(' - sub cx, ax - shl cx, 1 - mov bx, [bp+arg_0] - mov bp, cx - mov ax, GRAM_400 - mov es, ax - assume es:nothing - -loc_F447: - mov cx, word_12F86 - -loc_F44B: - or di, di - js short loc_F463 - cmp di, 7D00h - jnb short loc_F463 - mov al, 1 - out 0A6h, al - mov dx, es:[di] - xor ax, ax - out 0A6h, al - mov es:[di], dx - -loc_F463: - add di, 2 - loop loc_F44B - add di, bp - dec bx - jns short loc_F447 - call egc_off - pop di - pop bp - retf 8 -sub_F3FC endp - -; --------------------------------------------------------------------------- - nop - -; =============== S U B R O U T I N E ======================================= - - -sub_F478 proc near - push es - push 0 - pop es - pushf - cli - GRCG_SETMODE_VIA_MOV al, GC_TDW - mov es:[495h], al - popf - pop es - assume es:nothing - mov al, 7 - out 6Ah, al ; PC-98 GDC (6a): - ; - mov al, 5 - out 6Ah, al ; PC-98 GDC (6a): - ; - mov al, 6 - out 6Ah, al ; PC-98 GDC (6a): - ; - outw EGC_ACTIVEPLANEREG, 0FFF0h - outw EGC_READPLANEREG, 0FFh - outw EGC_MASKREG, 0FFFFh - mov dx, EGC_ADDRRESSREG - sub ax, ax - out dx, ax - outw EGC_BITLENGTHREG, 0Fh - retn -sub_F478 endp - +include th04/hardware/egccopyr.asm maine_02_TEXT ends .data @@ -8876,7 +8768,7 @@ include th05/formats/pi_slot_headers[bss].asm include th04/hardware/input[bss].asm include th04/formats/cdg[bss].asm include libs/master.lib/pfint21[bss].asm -word_12F86 dw ? +include th04/hardware/egccopyr[bss].asm dd ? ; dd ? ; dd ? ; diff --git a/th05_op.asm b/th05_op.asm index d1c670a0..1c072677 100644 --- a/th05_op.asm +++ b/th05_op.asm @@ -453,7 +453,7 @@ arg_2 = word ptr 6 push 100h push ax push 800010h - call sub_E2D8 + call egc_copy_rect_1_to_0 call grcg_setcolor pascal, GC_RMW, [bp+arg_0] mov [bp+var_2], si mov bx, si @@ -520,7 +520,7 @@ loc_A69A: call cdg_put pascal, 352, di, 36 pushd 180h push 2800010h - call sub_E2D8 + call egc_copy_rect_1_to_0 mov _graph_putsa_fx_func, 2 mov bx, [bp+var_2] shl bx, 2 @@ -579,7 +579,7 @@ loc_A737: push 0E0h push [bp+var_4] push 0C00010h - call sub_E2D8 + call egc_copy_rect_1_to_0 call grcg_setcolor pascal, GC_RMW, [bp+arg_0] mov bx, [bp+arg_2] cmp bx, 7 @@ -753,7 +753,7 @@ loc_A900: call cdg_put pushd 180h push 2800010h - call sub_E2D8 + call egc_copy_rect_1_to_0 mov _graph_putsa_fx_func, 2 mov bx, si shl bx, 2 @@ -859,7 +859,7 @@ sub_A9D6 proc near mov byte_11DD4, 0 push 0C000FAh push 12000A0h - call sub_E2D8 + call egc_copy_rect_1_to_0 xor si, si jmp short loc_AA16 ; --------------------------------------------------------------------------- @@ -1034,7 +1034,7 @@ sub_ABCF proc near mov byte_11DD5, 0 push 11000FAh push 0A00090h - call sub_E2D8 + call egc_copy_rect_1_to_0 xor si, si jmp short loc_AC0A ; --------------------------------------------------------------------------- @@ -1525,7 +1525,7 @@ arg_2 = word ptr 6 shl ax, 4 push ax push 10h - call sub_E2D8 + call egc_copy_rect_1_to_0 push si push di push 2 @@ -1596,7 +1596,7 @@ arg_2 = word ptr 6 shl ax, 4 push ax push 10h - call sub_E2D8 + call egc_copy_rect_1_to_0 push si push di push 6 @@ -1720,7 +1720,7 @@ arg_2 = word ptr 6 shl ax, 4 push ax push 20h ; ' ' - call sub_E2D8 + call egc_copy_rect_1_to_0 push si push di push 5 @@ -4799,116 +4799,8 @@ include th04/formats/cdg_put_nocolors.asm include th05/hardware/frame_delay.asm db 0 include th04/formats/cdg_load.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_E2D8 proc far - -arg_0 = word ptr 6 -arg_2 = word ptr 8 -arg_4 = word ptr 0Ah -arg_6 = word ptr 0Ch - - push bp - mov bp, sp - push di - call sub_E354 - outw EGC_MODE_ROP_REG, EGC_COMPAREREAD or EGC_WS_ROP or EGC_RL_MEMREAD or 0F0h - mov ax, [bp+arg_6] - mov dx, [bp+arg_4] - mov bx, ax - sar bx, 4 - shl bx, 1 - shl dx, 6 - add bx, dx - shr dx, 2 - add bx, dx - mov di, bx - and ax, 0Fh - mov cx, ax - add ax, [bp+arg_2] - shr ax, 4 - or cx, cx - jz short loc_E30F - inc ax - -loc_E30F: - mov word_12EFE, ax - mov cx, 28h ; '(' - sub cx, ax - shl cx, 1 - mov bx, [bp+arg_0] - mov bp, cx - mov ax, GRAM_400 - mov es, ax - assume es:nothing - -loc_E323: - mov cx, word_12EFE - -loc_E327: - or di, di - js short loc_E33F - cmp di, 7D00h - jnb short loc_E33F - mov al, 1 - out 0A6h, al - mov dx, es:[di] - xor ax, ax - out 0A6h, al - mov es:[di], dx - -loc_E33F: - add di, 2 - loop loc_E327 - add di, bp - dec bx - jns short loc_E323 - call egc_off - pop di - pop bp - retf 8 -sub_E2D8 endp - -; --------------------------------------------------------------------------- - nop - -; =============== S U B R O U T I N E ======================================= - - -sub_E354 proc near - push es - push 0 - pop es - pushf - cli - GRCG_SETMODE_VIA_MOV al, GC_TDW - mov es:[495h], al - popf - pop es - assume es:nothing - mov al, 7 - out 6Ah, al ; PC-98 GDC (6a): - ; - mov al, 5 - out 6Ah, al ; PC-98 GDC (6a): - ; - mov al, 6 - out 6Ah, al ; PC-98 GDC (6a): - ; - outw EGC_ACTIVEPLANEREG, 0FFF0h - outw EGC_READPLANEREG, 0FFh - outw EGC_MASKREG, 0FFFFh - mov dx, EGC_ADDRRESSREG - sub ax, ax - out dx, ax - outw EGC_BITLENGTHREG, 0Fh - retn -sub_E354 endp - align 2 - +include th04/hardware/egccopyr.asm + even op_02_TEXT ends .data @@ -5696,7 +5588,7 @@ include th05/formats/pi_slot_headers[bss].asm include th04/hardware/input[bss].asm include th04/formats/cdg[bss].asm include libs/master.lib/pfint21[bss].asm -word_12EFE dw ? +include th04/hardware/egccopyr[bss].asm dd ? ; dd ? ; dd ? ;