diff --git a/Tupfile b/Tupfile index 79080b40..2893c6f2 100644 --- a/Tupfile +++ b/Tupfile @@ -23,6 +23,7 @@ BMP2ARR = bin\\Pipeline\\bmp2arr.exe !bmp2arr = | $(BMP2ARR) |> $(BMP2ARR) -q -i %f -o %o |> %o +: th01/sprites/ileave_m.bmp |> !bmp2arr -sym _sINTERLEAVE_MASKS -of asm -sw 8 -sh 8 |> th01/sprites/ileave_m.asp : th01/sprites/pellet.bmp |> !bmp2arr -sym sPELLET -of c -sw 8 -sh 8 -pshf inner |> th01/sprites/pellet.csp : th01/sprites/pellet_c.bmp |> !bmp2arr -sym _sPELLET_CLOUD -of asm -sw 16 -sh 16 |> th01/sprites/pellet_c.asp : th01/sprites/shape8x8.bmp |> !bmp2arr -sym _sSHAPE8X8 -of asm -sw 8 -sh 8 |> th01/sprites/shape8x8.asp @@ -50,6 +51,7 @@ BMP2ARR = bin\\Pipeline\\bmp2arr.exe : th01_op.asm |> !as |> bin\\th01\\op.obj : th01_reiiden.asm | \ + th01/sprites/ileave_m.asp \ th01/sprites/pellet_c.asp \ th01/sprites/shape8x8.asp \ th01/sprites/shape_in.asp \ diff --git a/Tupfile.bat b/Tupfile.bat index d863315b..f2ff0a04 100644 --- a/Tupfile.bat +++ b/Tupfile.bat @@ -3,6 +3,7 @@ : if the Tupfile changes. @echo on bcc32 -w-8004 -w-8012 -O2 -v- -x- -nbin/Pipeline/ Pipeline/bmp2arr.c Pipeline/bmp2arrl.c +bin\\Pipeline\\bmp2arr.exe -q -i th01/sprites/ileave_m.bmp -o th01/sprites/ileave_m.asp -sym _sINTERLEAVE_MASKS -of asm -sw 8 -sh 8 bin\\Pipeline\\bmp2arr.exe -q -i th01/sprites/pellet.bmp -o th01/sprites/pellet.csp -sym sPELLET -of c -sw 8 -sh 8 -pshf inner bin\\Pipeline\\bmp2arr.exe -q -i th01/sprites/pellet_c.bmp -o th01/sprites/pellet_c.asp -sym _sPELLET_CLOUD -of asm -sw 16 -sh 16 bin\\Pipeline\\bmp2arr.exe -q -i th01/sprites/shape8x8.bmp -o th01/sprites/shape8x8.asp -sym _sSHAPE8X8 -of asm -sw 8 -sh 8 diff --git a/th01/hardware/ptrans_d.cpp b/th01/hardware/ptrans_d.cpp new file mode 100644 index 00000000..9c771b5d --- /dev/null +++ b/th01/hardware/ptrans_d.cpp @@ -0,0 +1,33 @@ +#include "th01/sprites/ileave_m.h" + +// Combines the pixels from both VRAM pages in the 8×8 square starting at +// (⌊left/8⌋*8, top), using one of the interlace masks. The resulting square +// is blitted to VRAM page 0. +void graph_interleave_pages_8x8_8(screen_x_t left, vram_y_t top, int mask_id) +{ + const interleave_masks_t masks = sINTERLEAVE_MASKS; + + vram_offset_t vram_offset = vram_offset_divmul(left, top); + dots8_t dots; + for(char y = 0; y < INTERLEAVE_W; y++) { + #define mask masks.dots[mask_id][y] + + #define snap(plane, vram_offset) \ + VRAM_CHUNK(plane, vram_offset, 8) + + #define interleave(plane, vram_offset) \ + graph_accesspage_func(1); dots = ~mask & snap(plane, vram_offset); \ + graph_accesspage_func(0); dots |= mask & snap(plane, vram_offset); \ + graph_accesspage_func(0); VRAM_PUT(plane, vram_offset, dots, 8); + + interleave(B, vram_offset); + interleave(R, vram_offset); + interleave(G, vram_offset); + interleave(E, vram_offset); + vram_offset += ROW_SIZE; + + #undef interleave + #undef snap + #undef mask + } +} diff --git a/th01/main_13.cpp b/th01/main_13.cpp index f6e18233..8b22e382 100644 --- a/th01/main_13.cpp +++ b/th01/main_13.cpp @@ -3,6 +3,8 @@ * 1st part of code segment #13 of TH01's REIIDEN.EXE */ +#pragma option -2 + extern "C" { #include @@ -15,4 +17,5 @@ extern "C" { #include "th01/hardware/scrollup.cpp" #include "th01/hardware/egcrows.cpp" +#include "th01/hardware/ptrans_d.cpp" } diff --git a/th01/sprites/ileave_m.bmp b/th01/sprites/ileave_m.bmp new file mode 100644 index 00000000..89d0b93a Binary files /dev/null and b/th01/sprites/ileave_m.bmp differ diff --git a/th01/sprites/ileave_m.h b/th01/sprites/ileave_m.h new file mode 100644 index 00000000..2477dbc3 --- /dev/null +++ b/th01/sprites/ileave_m.h @@ -0,0 +1,11 @@ +// Combines dots from VRAM page 1 (where the mask is 0) with dots from VRAM +// page 0 (where the mask is 1). +static const int INTERLEAVE_MASK_COUNT = 10; +static const pixel_t INTERLEAVE_W = 8; +static const pixel_t INTERLEAVE_H = 8; + +typedef struct { + dots8_t dots[INTERLEAVE_MASK_COUNT][INTERLEAVE_H]; +} interleave_masks_t; + +extern const interleave_masks_t sINTERLEAVE_MASKS; diff --git a/th01_reiiden.asm b/th01_reiiden.asm index e4e0c721..bb415f9f 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -4559,214 +4559,7 @@ main_13__TEXT segment byte public 'CODE' use16 extern _z_vsync_wait_and_scrollup:proc extern _egc_copy_rows_1_to_0:proc - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_118A2 proc far - -var_52 = byte ptr -52h -var_2 = byte ptr -2 -var_1 = byte ptr -1 -arg_0 = word ptr 6 -arg_2 = word ptr 8 -arg_4 = word ptr 0Ah - - enter 52h, 0 - push si - push di - mov di, [bp+arg_4] - lea ax, [bp+var_52] - push ss - push ax - push ds - push offset unk_355EC - mov cx, 50h ; 'P' - call SCOPY@ - mov ax, [bp+arg_0] - mov bx, 8 - cwd - idiv bx - mov dx, [bp+arg_2] - imul dx, 50h - add ax, dx - mov si, ax - mov [bp+var_2], 0 - jmp loc_11A6C -; --------------------------------------------------------------------------- - -loc_118D6: - push 1 - call _graph_accesspage_func - pop cx - mov bx, di - shl bx, 3 - mov al, [bp+var_2] - cbw - add bx, ax - lea ax, [bp+var_52] - add bx, ax - mov al, ss:[bx] - not al - les bx, _VRAM_PLANE_B - add bx, si - and al, es:[bx] - mov [bp+var_1], al - push 0 - call _graph_accesspage_func - pop cx - mov bx, di - shl bx, 3 - mov al, [bp+var_2] - cbw - add bx, ax - lea ax, [bp+var_52] - add bx, ax - mov al, ss:[bx] - les bx, _VRAM_PLANE_B - add bx, si - and al, es:[bx] - or [bp+var_1], al - push 0 - call _graph_accesspage_func - pop cx - les bx, _VRAM_PLANE_B - add bx, si - mov al, [bp+var_1] - mov es:[bx], al - push 1 - call _graph_accesspage_func - pop cx - mov bx, di - shl bx, 3 - mov al, [bp+var_2] - cbw - add bx, ax - lea ax, [bp+var_52] - add bx, ax - mov al, ss:[bx] - not al - les bx, _VRAM_PLANE_R - add bx, si - and al, es:[bx] - mov [bp+var_1], al - push 0 - call _graph_accesspage_func - pop cx - mov bx, di - shl bx, 3 - mov al, [bp+var_2] - cbw - add bx, ax - lea ax, [bp+var_52] - add bx, ax - mov al, ss:[bx] - les bx, _VRAM_PLANE_R - add bx, si - and al, es:[bx] - or [bp+var_1], al - push 0 - call _graph_accesspage_func - pop cx - les bx, _VRAM_PLANE_R - add bx, si - mov al, [bp+var_1] - mov es:[bx], al - push 1 - call _graph_accesspage_func - pop cx - mov bx, di - shl bx, 3 - mov al, [bp+var_2] - cbw - add bx, ax - lea ax, [bp+var_52] - add bx, ax - mov al, ss:[bx] - not al - les bx, _VRAM_PLANE_G - add bx, si - and al, es:[bx] - mov [bp+var_1], al - push 0 - call _graph_accesspage_func - pop cx - mov bx, di - shl bx, 3 - mov al, [bp+var_2] - cbw - add bx, ax - lea ax, [bp+var_52] - add bx, ax - mov al, ss:[bx] - les bx, _VRAM_PLANE_G - add bx, si - and al, es:[bx] - or [bp+var_1], al - push 0 - call _graph_accesspage_func - pop cx - les bx, _VRAM_PLANE_G - add bx, si - mov al, [bp+var_1] - mov es:[bx], al - push 1 - call _graph_accesspage_func - pop cx - mov bx, di - shl bx, 3 - mov al, [bp+var_2] - cbw - add bx, ax - lea ax, [bp+var_52] - add bx, ax - mov al, ss:[bx] - not al - les bx, _VRAM_PLANE_E - add bx, si - and al, es:[bx] - mov [bp+var_1], al - push 0 - call _graph_accesspage_func - pop cx - mov bx, di - shl bx, 3 - mov al, [bp+var_2] - cbw - add bx, ax - lea ax, [bp+var_52] - add bx, ax - mov al, ss:[bx] - les bx, _VRAM_PLANE_E - add bx, si - and al, es:[bx] - or [bp+var_1], al - push 0 - call _graph_accesspage_func - pop cx - les bx, _VRAM_PLANE_E - add bx, si - mov al, [bp+var_1] - mov es:[bx], al - add si, 50h ; 'P' - inc [bp+var_2] - -loc_11A6C: - mov al, [bp+var_2] - cbw - cmp ax, 8 - jge short loc_11A78 - jmp loc_118D6 -; --------------------------------------------------------------------------- - -loc_11A78: - pop di - pop si - leave - retf -sub_118A2 endp - + extern _graph_interleave_pages_8x8_8:proc ; =============== S U B R O U T I N E ======================================= @@ -4799,10 +4592,10 @@ sub_11A94 proc far var_E = word ptr -0Eh var_C = word ptr -0Ch var_A = word ptr -0Ah -var_8 = word ptr -8 -var_6 = word ptr -6 -var_4 = word ptr -4 -var_2 = word ptr -2 +@@top_2 = word ptr -8 +@@left_2 = word ptr -6 +@@top_1 = word ptr -4 +@@left_1 = word ptr -2 arg_0 = word ptr 6 @@palette = dword ptr 8 arg_6 = dword ptr 0Ch @@ -4810,39 +4603,35 @@ arg_6 = dword ptr 0Ch enter 0Eh, 0 push si push di - mov [bp+var_2], 0 - mov [bp+var_4], 0 - mov [bp+var_6], 278h - mov [bp+var_8], 188h + mov [bp+@@left_1], 0 + mov [bp+@@top_1], 0 + mov [bp+@@left_2], (RES_X - 8) + mov [bp+@@top_2], (RES_Y - 8) mov [bp+var_E], 0 jmp loc_11BFE ; --------------------------------------------------------------------------- loc_11AB6: - mov ax, [bp+var_2] + mov ax, [bp+@@left_1] mov [bp+var_A], ax - mov ax, [bp+var_4] + mov ax, [bp+@@top_1] mov [bp+var_C], ax jmp short loc_11ADB ; --------------------------------------------------------------------------- loc_11AC4: - push 1 - push [bp+var_4] - push [bp+var_2] - call sub_118A2 - add sp, 6 - sub [bp+var_2], 8 - add [bp+var_4], 8 + call _graph_interleave_pages_8x8_8 c, [bp+@@left_1], [bp+@@top_1], 1 + sub [bp+@@left_1], 8 + add [bp+@@top_1], 8 loc_11ADB: - cmp [bp+var_2], 0 + cmp [bp+@@left_1], 0 jl short loc_11AE8 - cmp [bp+var_4], 18Fh + cmp [bp+@@top_1], (RES_Y - 1) jle short loc_11AC4 loc_11AE8: - cmp [bp+var_A], 278h + cmp [bp+var_A], 632 jge short loc_11AF7 mov ax, [bp+var_A] add ax, 8 @@ -4853,8 +4642,8 @@ loc_11AF7: mov ax, [bp+var_A] loc_11AFA: - mov [bp+var_2], ax - cmp [bp+var_A], 278h + mov [bp+@@left_1], ax + cmp [bp+var_A], 632 jge short loc_11B08 xor ax, ax jmp short loc_11B0E @@ -4865,7 +4654,7 @@ loc_11B08: add ax, 8 loc_11B0E: - mov [bp+var_4], ax + mov [bp+@@top_1], ax mov ax, [bp+var_E] mov bx, 8 cwd @@ -4937,26 +4726,22 @@ loc_11B85: call _z_palette_set_all_show c, word ptr [bp+@@palette], word ptr [bp+@@palette+2] loc_11B98: - mov ax, [bp+var_6] + mov ax, [bp+@@left_2] mov [bp+var_A], ax - mov ax, [bp+var_8] + mov ax, [bp+@@top_2] mov [bp+var_C], ax jmp short loc_11BBD ; --------------------------------------------------------------------------- loc_11BA6: - push 2 - push [bp+var_8] - push [bp+var_6] - call sub_118A2 - add sp, 6 - sub [bp+var_6], 8 - add [bp+var_8], 8 + call _graph_interleave_pages_8x8_8 c, [bp+@@left_2], [bp+@@top_2], 2 + sub [bp+@@left_2], 8 + add [bp+@@top_2], 8 loc_11BBD: - cmp [bp+var_6], 0 + cmp [bp+@@left_2], 0 jl short loc_11BCA - cmp [bp+var_8], 18Fh + cmp [bp+@@top_2], (RES_Y - 1) jle short loc_11BA6 loc_11BCA: @@ -4971,7 +4756,7 @@ loc_11BD5: add ax, 0FFF8h loc_11BDB: - mov [bp+var_6], ax + mov [bp+@@left_2], ax cmp [bp+var_C], 0 jle short loc_11BEC mov ax, [bp+var_C] @@ -4983,7 +4768,7 @@ loc_11BEC: mov ax, [bp+var_C] loc_11BEF: - mov [bp+var_8], ax + mov [bp+@@top_2], ax push [bp+arg_0] call _delay pop cx @@ -46989,59 +46774,7 @@ include libs/master.lib/rand[data].asm include th01/sprites/pellet_c.asp public _res_id _res_id db 'ReiidenConfig',0 -unk_355EC db 0 - dd 0 - db 0 - db 0 - db 0 - db 55h ; U - db 0AAh ; ª - db 55h ; U - db 0AAh ; ª - db 55h ; U - db 0AAh ; ª - db 55h ; U - db 0AAh ; ª - db 0AAh ; ª - db 55h ; U - db 0AAh ; ª - db 55h ; U - db 0AAh ; ª - db 55h ; U - db 0AAh ; ª - db 55h ; U - db 0 - db 0DDh - db 0 - db 77h ; w - db 0 - db 0DDh - db 0 - db 77h ; w - db 33h ; 3 - db 33h ; 3 - db 0CCh ; Ì - db 0CCh ; Ì - db 33h ; 3 - db 33h ; 3 - db 0CCh ; Ì - db 0CCh ; Ì - db 0CCh ; Ì - db 0CCh ; Ì - db 33h ; 3 - db 33h ; 3 - db 0CCh ; Ì - db 0CCh ; Ì - db 33h ; 3 - db 33h ; 3 - dd 0 - dd 0 - dd 0 - dd 0 - dd 0 - dd 0 - dd 0 - dd 0 +include th01/sprites/ileave_m.asp db 0 db 0FFh db 80h