diff --git a/Makefile.mak b/Makefile.mak index e343f03a..1477bf23 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -38,6 +38,9 @@ bin\th01\zunsoft.com: th01\zunsoft.c # --------------------------------- bin\frmdely2.obj: th02\frmdely2.c $(CC) $(CFLAGS) -ml -n$(@D) -c $** + +bin\hfliplut.obj: th03\hfliplut.c + $(CC) $(CFLAGS) -ml -n$(@D) -c $** # --------------------------------- bin\th01\op.exe: bin\piloadc.obj bin\th01\op.obj th01\op_01.cpp th01\op_02.c th01\op_03.c th01\op_04.c th01\op_05.c th01\op_06.cpp th01\op_07.cpp th01\op_08.c th01\op_09.cpp th01\op_10.c th01\op_11.c th01\op_12.cpp @@ -80,7 +83,7 @@ bin\th03\res_yume.com: th03\res_yume.cpp $** | masters.lib -bin\th03\op.exe: bin\th03\op.obj bin\frmdely2.obj +bin\th03\op.exe: bin\th03\op.obj bin\hfliplut.obj bin\frmdely2.obj $(CC) $(CFLAGS) -ml -DGAME=3 -nbin\th03\ -eOP.EXE @&&| $** | @@ -90,6 +93,11 @@ bin\th03\main.exe: bin\th03\main.obj th03\main_01.cpp th03\sprite16.cpp $** | +bin\th03\mainl.exe: bin\th03\mainl.obj bin\hfliplut.obj + $(CC) $(CFLAGS) -ml -DGAME=3 -nbin\th03\ -eMAINL.EXE @&&| +$** +| + bin\th04\res_huma.com: th04\res_huma.cpp $(CC) $(CFLAGS) -mt -lt -Z -DGAME=4 -nbin\th04\ -eRES_HUMA.COM @&&| $** @@ -100,26 +108,36 @@ bin\th04\op.exe: bin\th04\op.obj th04\op_01.cpp bin\frmdely2.obj $** | -bin\th04\main.exe: bin\th04\main.obj bin\th04\scoreupd.obj th04\main011.cpp th04\main032.cpp +bin\th04\main.exe: bin\th04\main.obj bin\th04\scoreupd.obj th04\main011.cpp bin\hfliplut.obj th04\main032.cpp $(CC) $(CFLAGS) -ml -DGAME=4 -DBINARY='M' -3 -Z -nbin\th04\ -eMAIN.EXE @&&| $** | +bin\th04\maine.exe: bin\th04\maine.obj bin\hfliplut.obj + $(CC) $(CFLAGS) -ml -DGAME=4 -DBINARY='E' -nbin\th04\ -eMAINE.EXE @&&| +$** +| + bin\th05\res_kso.com: th05\res_kso.cpp $(CC) $(CFLAGS) -mt -lt -Z -DGAME=5 -nbin\th05\ -eRES_KSO.COM @&&| $** | masters.lib -bin\th05\op.exe: bin\th05\op.obj th05\op_01.cpp +bin\th05\op.exe: bin\th05\op.obj th05\op_01.cpp bin\hfliplut.obj $(CC) $(CFLAGS) -ml -DGAME=5 -DBINARY='O' -nbin\th05\ -eOP.EXE @&&| $** | -bin\th05\main.exe: bin\th05\main.obj th05\main010.cpp th05\main011.cpp th05\p_common.cpp th05\p_reimu.cpp th05\p_marisa.cpp th05\p_mima.cpp th05\p_yuuka.cpp bin\th05\player.obj bin\th05\hud_bar.obj bin\th05\scoreupd.obj th05\main012.cpp th05\main013.cpp bin\th05\bullet.obj th05\main031.cpp th05\main032.cpp th05\main033.cpp th05\main034.cpp +bin\th05\main.exe: bin\th05\main.obj th05\main010.cpp th05\main011.cpp th05\p_common.cpp th05\p_reimu.cpp th05\p_marisa.cpp th05\p_mima.cpp th05\p_yuuka.cpp bin\th05\player.obj bin\th05\hud_bar.obj bin\th05\scoreupd.obj th05\main012.cpp th05\main013.cpp bin\hfliplut.obj bin\th05\bullet.obj th05\main031.cpp th05\main032.cpp th05\main033.cpp th05\main034.cpp $(CC) $(CFLAGS) -ml -3 -Z -DGAME=5 -DBINARY='M' -nbin\th05\ -eMAIN.EXE @&&| $** | +bin\th05\maine.exe: bin\th05\maine.obj bin\hfliplut.obj + $(CC) $(CFLAGS) -ml -DGAME=5 -DBINARY='E' -nbin\th05\ -eMAINE.EXE @&&| +$** +| + # ZUN.COM packing {bin\zuncom}.obj{bin\zuncom}.bin: diff --git a/decomp.h b/decomp.h index 4305199b..ce8729e5 100644 --- a/decomp.h +++ b/decomp.h @@ -7,6 +7,7 @@ // ---------------- // When used inside a conditional expression like // if(FLAGS_*) { goto some_label; | return; } -// these assemble into the single given instruction. +// these assemble into the single given instruction. Apply the ! operator to +// get the N versions. #define FLAGS_ZERO (_FLAGS & 0x40) /* JZ */ // ---------------- diff --git a/th03/formats/cdg_put_hflip.asm b/th03/formats/cdg_put_hflip.asm index 71a40709..81bbe684 100644 --- a/th03/formats/cdg_put_hflip.asm +++ b/th03/formats/cdg_put_hflip.asm @@ -40,7 +40,7 @@ proc_defconv cdg_put_hflip add ax, 0A800h mov es, ax assume es:nothing - mov bx, offset hflip_lut + mov bx, offset _hflip_lut mov fs, [si+cdg_t.seg_alpha] xor si, si diff --git a/th03/formats/hfliplut.asm b/th03/formats/hfliplut.asm index 2fd8d383..786d34cf 100644 --- a/th03/formats/hfliplut.asm +++ b/th03/formats/hfliplut.asm @@ -1,11 +1,8 @@ -; Generates a lookup table for flipping one byte, interpreted as a horizontal -; line of 8 pixels in a single bitplane. - -; int DEFCONV hflip_lut_generate() -proc_defconv hflip_lut_generate +public _hflip_lut_generate +_hflip_lut_generate proc push di xor ax, ax - mov di, offset hflip_lut + mov di, offset _hflip_lut xor dl, dl jmp short @@check @@ -25,4 +22,4 @@ proc_defconv hflip_lut_generate jnz short @@outer pop di ret -endp_defconv +_hflip_lut_generate endp diff --git a/th03/formats/hfliplut.h b/th03/formats/hfliplut.h new file mode 100644 index 00000000..c315e709 --- /dev/null +++ b/th03/formats/hfliplut.h @@ -0,0 +1,5 @@ +// Lookup table for horizontally flipping a dots8_t. +extern dots8_t hflip_lut[256]; + +// Fills [hflip_lut]. +void hflip_lut_generate(void); diff --git a/th03/formats/hfliplut[bss].asm b/th03/formats/hfliplut[bss].asm index ba4e5c99..8bf0ce57 100644 --- a/th03/formats/hfliplut[bss].asm +++ b/th03/formats/hfliplut[bss].asm @@ -1 +1,2 @@ -hflip_lut db 100h dup(?) +public _hflip_lut +_hflip_lut db 100h dup(?) diff --git a/th03/hfliplut.c b/th03/hfliplut.c new file mode 100644 index 00000000..94f52f50 --- /dev/null +++ b/th03/hfliplut.c @@ -0,0 +1,34 @@ +#include "platform.h" +#include "pc98.h" +#include "planar.h" +#include "decomp.h" +#include "th03/formats/hfliplut.h" + +#pragma codeseg seg2 +#pragma option -k- + +void hflip_lut_generate(void) +{ + #define p (dots8_t near *)(_DI) + _AX = 0; + p = hflip_lut; + _DL ^= _DL; + goto set_and_loop; + +permutation_loop: + _DL ^= _DL; + _CX = BYTE_DOTS; + generation_loop: __asm { + rol al, 1 + rcr dl, 1 + loop generation_loop + } + +set_and_loop: + *(p++) = _DL; + _AL++; + if(!FLAGS_ZERO) { + goto permutation_loop; + } + #undef p +} diff --git a/th03_main.asm b/th03_main.asm index 33652e3e..54c7d449 100644 --- a/th03_main.asm +++ b/th03_main.asm @@ -615,7 +615,7 @@ var_2 = word ptr -2 call sub_13CDD mov byte_207E3, 0 call sub_9EBF - call hflip_lut_generate + call _hflip_lut_generate nopcall sub_D5A2 mov byte_23AFA, 0 les bx, _resident @@ -9228,7 +9228,7 @@ loc_F0A9: mov bx, [bp+arg_0] shl bx, 2 les di, [bx+1D64h] - mov bx, offset hflip_lut + mov bx, offset _hflip_lut loc_F0BB: mov al, es:[di] diff --git a/th03_mainl.asm b/th03_mainl.asm index 0cb8e290..3d4cc53f 100644 --- a/th03_mainl.asm +++ b/th03_mainl.asm @@ -906,7 +906,7 @@ loc_9DAD: call gaiji_entry_bfnt call snd_load c, offset aYume_efc, ds, SND_LOAD_SE call snd_se_reset - call hflip_lut_generate + call _hflip_lut_generate les bx, _resident cmp es:[bx+resident_t.show_score_menu], 0 jz short loc_9E04 @@ -5588,7 +5588,7 @@ include th03/hardware/input_modes.asm include th03/hardware/input_wait.asm db 0 include th03/formats/cdg_put_noalpha.asm -include th03/formats/hfliplut.asm + extern _hflip_lut_generate:proc seg2 ends .data diff --git a/th03_op.asm b/th03_op.asm index fc23d0e4..5b81b91c 100644 --- a/th03_op.asm +++ b/th03_op.asm @@ -2328,7 +2328,7 @@ sub_B38D proc near push bp mov bp, sp push si - call hflip_lut_generate + call _hflip_lut_generate xor si, si jmp short loc_B3B0 ; --------------------------------------------------------------------------- @@ -3642,7 +3642,7 @@ include th03/hardware/input_modes.asm include th03/hardware/input_wait.asm db 0 include th03/formats/cdg_put_noalpha.asm -include th03/formats/hfliplut.asm + extern _hflip_lut_generate:proc extern FRAME_DELAY_2:proc seg2 ends diff --git a/th04_main.asm b/th04_main.asm index 99b75a02..acd637f0 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -47,6 +47,7 @@ include th04/main/enemy/enemy.inc .seq main_01 group main_0_TEXT, main_01_TEXT, main_012_TEXT +g_seg2 group seg2, seg2_ main_03 group main_032_TEXT, main_033_TEXT ; =========================================================================== @@ -13167,7 +13168,7 @@ main_012_TEXT ends ; Segment type: Pure code seg2 segment word public 'CODE' use16 - assume cs:seg2 + assume cs:g_seg2 ;org 0Dh assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing @@ -13176,7 +13177,9 @@ include th03/math/vector2.asm nop include th03/math/vector2_between_plus.asm include th02/hardware/frame_delay.asm -include th03/formats/hfliplut.asm +seg2 ends + +seg2_ segment word public 'CODE' use16 ; =============== S U B R O U T I N E ======================================= @@ -13323,7 +13326,7 @@ include th04/formats/cdg_put_plane_roll.asm include th04/hardware/input_sense.asm include th04/snd/se.asm include th04/formats/cdg_load.asm -seg2 ends +seg2_ ends ; =========================================================================== diff --git a/th04_maine.asm b/th04_maine.asm index fe99f744..6519a4c5 100644 --- a/th04_maine.asm +++ b/th04_maine.asm @@ -28,6 +28,8 @@ include th04/th04.inc extern _tolower:proc extern __ctype:byte +g_seg2 group seg2, seg2_ + ; =========================================================================== ; Segment type: Pure code @@ -4694,7 +4696,7 @@ maine_01_TEXT ends ; Segment type: Pure code seg2 segment word public 'CODE' use16 - assume cs:seg2 + assume cs:g_seg2 ;org 0Ah assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing @@ -4704,7 +4706,9 @@ include th02/formats/pi_slot_palette_apply.asm include th02/formats/pi_slot_put.asm include th02/formats/pi_slot_load.asm include th03/formats/pi_slot_put_quarter.asm -include th03/formats/hfliplut.asm +seg2 ends + +seg2_ segment word public 'CODE' use16 include th04/hardware/input_wait.asm include th04/math/vector1_at.asm include th04/math/vector2_at.asm @@ -4726,7 +4730,7 @@ include th04/snd/se.asm include th04/bgimage.asm include th04/bgimage_put_rect.asm include th04/formats/cdg_load.asm -seg2 ends +seg2_ ends .data diff --git a/th05_main.asm b/th05_main.asm index 2fea2f08..11d0f9e3 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -39,6 +39,7 @@ include th05/main/enemy/enemy.inc .seq main_01 group main_TEXT, main__TEXT, main_0_TEXT, main_01_TEXT +g_seg2 group seg2, seg2_ main_03 group main_031_TEXT, main_032_TEXT, main_033_TEXT, main_034_TEXT, main_035_TEXT ; =========================================================================== @@ -10746,14 +10747,16 @@ main_01_TEXT ends ; Segment type: Pure code seg2 segment word public 'CODE' use16 - assume cs:seg2 + assume cs:g_seg2 ;org 3 assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing include th03/math/vector2.asm nop include th03/math/vector2_between_plus.asm -include th03/formats/hfliplut.asm +seg2 ends + +seg2_ segment word public 'CODE' use16 include th04/snd/pmd_res.asm include th02/snd/mmd_res.asm include th04/snd/detmodes.asm @@ -10772,7 +10775,7 @@ include th05/hardware/input_wait.asm include th05/hardware/frame_delay.asm db 0 include th04/formats/cdg_load.asm -seg2 ends +seg2_ ends ; =========================================================================== diff --git a/th05_maine.asm b/th05_maine.asm index a6cef1ce..59df6b2e 100644 --- a/th05_maine.asm +++ b/th05_maine.asm @@ -27,6 +27,8 @@ include th05/th05.inc extern _tolower:proc extern __ctype:byte +g_seg2 group seg2, seg2_ + ; =========================================================================== ; Segment type: Pure code @@ -7771,11 +7773,13 @@ maine_01_TEXT ends ; Segment type: Pure code seg2 segment word public 'CODE' use16 - assume cs:seg2 +seg2 ends + +seg2_ segment word public 'CODE' use16 + assume cs:g_seg2 ;org 0Ch assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing -include th03/formats/hfliplut.asm include th04/snd/pmd_res.asm include th02/snd/mmd_res.asm include th04/snd/detmodes.asm @@ -7804,7 +7808,7 @@ include th05/hardware/frame_delay.asm db 0 include th04/formats/cdg_load.asm include th04/hardware/egccopyr.asm -seg2 ends +seg2_ ends .data diff --git a/th05_op.asm b/th05_op.asm index 1c8c1729..3d47d674 100644 --- a/th05_op.asm +++ b/th05_op.asm @@ -30,6 +30,8 @@ include th05/music/piano.inc extern _getch:proc extern _strlen:proc +g_seg2 group seg2, seg2_ + ; =========================================================================== ; Segment type: Pure code @@ -3486,11 +3488,13 @@ op_01_TEXT ends ; Segment type: Pure code seg2 segment word public 'CODE' use16 - assume cs:seg2 +seg2 ends + +seg2_ segment word public 'CODE' use16 + assume cs:g_seg2 ; org 4 assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing -include th03/formats/hfliplut.asm include th04/snd/pmd_res.asm include th02/snd/mmd_res.asm include th04/snd/detmodes.asm @@ -3527,7 +3531,7 @@ include th05/hardware/frame_delay.asm include th04/formats/cdg_load.asm include th04/hardware/egccopyr.asm even -seg2 ends +seg2_ ends .data