Skip to content

Commit

Permalink
[Decompilation] [th02] Verdict: Masked VRAM row copies from page 1→0
Browse files Browse the repository at this point in the history
Part of P0278, funded by Yanga.
  • Loading branch information
nmlgc committed Apr 11, 2024
1 parent 35f320e commit 7ac1db3
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 221 deletions.
1 change: 1 addition & 0 deletions Tupfile
Expand Up @@ -75,6 +75,7 @@ BMP2ARR = bin\\Pipeline\\bmp2arr.exe
: th02/sprites/pellet.bmp |> !bmp2arr -sym _sPELLET -of asm -sw 8 -sh 8 -pshf outer |> th02/sprites/pellet.asp
: th02/sprites/sparks.bmp |> !bmp2arr -sym _sSPARKS -of asm -sw 8 -sh 8 -pshf outer |> th02/sprites/sparks.asp
: th02/sprites/pointnum.bmp |> !bmp2arr -sym _sPOINTNUMS -of asm -sw 8 -sh 8 |> th02/sprites/pointnum.asp
: th02/sprites/verdict.bmp |> !bmp2arr -sym sVERDICT_MASKS -of cpp -sw 16 -sh 16 |> th02/sprites/verdict.csp
: th03/sprites/score.bmp |> !bmp2arr -sym _sSCORE_FONT -of asm -sw 8 -sh 8 -u |> th03/sprites/score.asp
: th04/sprites/pelletbt.bmp |> !bmp2arr -sym _sPELLET_BOTTOM -of asm -sw 8 -sh 4 -pshf outer |> th04/sprites/pelletbt.asp
: th04/sprites/pointnum.bmp |> !bmp2arr -sym _sPOINTNUMS -of asm -sw 8 -sh 8 -pshf inner |> th04/sprites/pointnum.asp
Expand Down
1 change: 1 addition & 0 deletions Tupfile.bat
Expand Up @@ -18,6 +18,7 @@ bin\\Pipeline\\bmp2arr.exe -q -i th02/sprites/bombpart.bmp -o th02/sprites/bombp
bin\\Pipeline\\bmp2arr.exe -q -i th02/sprites/pellet.bmp -o th02/sprites/pellet.asp -sym _sPELLET -of asm -sw 8 -sh 8 -pshf outer
bin\\Pipeline\\bmp2arr.exe -q -i th02/sprites/sparks.bmp -o th02/sprites/sparks.asp -sym _sSPARKS -of asm -sw 8 -sh 8 -pshf outer
bin\\Pipeline\\bmp2arr.exe -q -i th02/sprites/pointnum.bmp -o th02/sprites/pointnum.asp -sym _sPOINTNUMS -of asm -sw 8 -sh 8
bin\\Pipeline\\bmp2arr.exe -q -i th02/sprites/verdict.bmp -o th02/sprites/verdict.csp -sym sVERDICT_MASKS -of cpp -sw 16 -sh 16
bin\\Pipeline\\bmp2arr.exe -q -i th03/sprites/score.bmp -o th03/sprites/score.asp -sym _sSCORE_FONT -of asm -sw 8 -sh 8 -u
bin\\Pipeline\\bmp2arr.exe -q -i th04/sprites/pelletbt.bmp -o th04/sprites/pelletbt.asp -sym _sPELLET_BOTTOM -of asm -sw 8 -sh 4 -pshf outer
bin\\Pipeline\\bmp2arr.exe -q -i th04/sprites/pointnum.bmp -o th04/sprites/pointnum.asp -sym _sPOINTNUMS -of asm -sw 8 -sh 8 -pshf inner
Expand Down
6 changes: 6 additions & 0 deletions planar.h
Expand Up @@ -192,6 +192,12 @@ static inline vram_offset_t vram_offset_divshift_wtf(screen_x_t x, vram_y_t y) {
VRAM_CHUNK(G, offset, bit_count) |= src.G; \
VRAM_CHUNK(E, offset, bit_count) |= src.E;

#define vram_or_planar_masked(offset, src, bit_count, mask) \
VRAM_CHUNK(B, offset, bit_count) |= (src.B & mask); \
VRAM_CHUNK(R, offset, bit_count) |= (src.R & mask); \
VRAM_CHUNK(G, offset, bit_count) |= (src.G & mask); \
VRAM_CHUNK(E, offset, bit_count) |= (src.E & mask);

#define vram_or_planar_emptyopt(offset, src, bit_count) \
vram_or_emptyopt(B, offset, src.B, bit_count); \
vram_or_emptyopt(R, offset, src.R, bit_count); \
Expand Down
49 changes: 49 additions & 0 deletions th02/end/end.cpp
@@ -1,6 +1,8 @@
#include <stddef.h>
#include "platform.h"
#include "x86real.h"
#include "pc98.h"
#include "planar.h"
#include "master.hpp"
#include "shiftjis.hpp"
#include "th01/hardware/grppsafx.h"
Expand All @@ -11,6 +13,7 @@
#include "th02/formats/end.hpp"
#include "th02/gaiji/gaiji.h"
#include "th02/gaiji/score_p.hpp"
#include "th02/sprites/verdict.hpp"

// State
// -----
Expand Down Expand Up @@ -126,3 +129,49 @@ void pascal near line_type(
end_line_clear();
}
}

void verdict_kanji_1_to_0_masked(
screen_x_t left, screen_y_t top, const dots16_t mask[VERDICT_MASK_H]
)
{
static_assert(VERDICT_MASK_H == GLYPH_H);
Planar<dots_t(VERDICT_MASK_W)> dots;
vram_offset_t vo = vram_offset_shift(left, top);
for(pixel_t row = 0; row < VERDICT_MASK_H; row++) {
// ZUN bloat: Thanks to the blit functions being macros, `mask[row]` is
// evaluated a total of 5 times. Once would be enough.
graph_accesspage(1);
VRAM_SNAP_PLANAR(dots, vo, VERDICT_MASK_W);

graph_accesspage(0);

grcg_setcolor(GC_RMW, 0);
grcg_put(vo, mask[row], VERDICT_MASK_W);
grcg_off();

vram_or_planar_masked(vo, dots, VERDICT_MASK_W, mask[row]);

vo += ROW_SIZE;
}
}

void verdict_row_1_to_0_animate(
screen_x_t left, screen_y_t top, shiftjis_kanji_amount_t len
)
{
// ZUN bloat: This array is not `static`, and will be needlessly copied
// into a local variable at every call to the function.
#include "th02/sprites/verdict.csp"

shiftjis_kanji_amount_t i;
for(int mask = 0; mask < VERDICT_MASK_COUNT; mask++) {
for(i = 0; i < len; i++) {
verdict_kanji_1_to_0_masked(
(left + (i * GLYPH_FULL_W)),
top,
&sVERDICT_MASKS[mask][0]
);
}
frame_delay(10);
}
}
Binary file added th02/sprites/verdict.bmp
Binary file not shown.
6 changes: 6 additions & 0 deletions th02/sprites/verdict.hpp
@@ -0,0 +1,6 @@
// These masks are applied on top of each other, and should therefore combine
// into a bitmap with every bit set.
// ZUN bloat: Could have been compressed down to 4 rows.
static const int VERDICT_MASK_COUNT = 3;
#define VERDICT_MASK_W 16
#define VERDICT_MASK_H 16

0 comments on commit 7ac1db3

Please sign in to comment.