[Reverse-engineering] [th03] SPRITE16 calls

Aha! TH03's in-game graphics run in line-doubled 640×200 simply because
that's what this SPRITE16.COM version was written for, making use of
the PC-98 EGC for optimized blitting.

Doesn't seem all *too* optimized though, given that it chooses to
effectively draw every sprite twice, just in case it might overlap with
something that's already in VRAM. It first clears the previous VRAM
content at the drawing position according to the sprite's alpha mask,
then ORs in the actual sprite data. The EGC can do monochrome alpha-
tested blitting just as well as the GRCG, but once the sprite data
covers all bitplanes, ORing is apparently the best it can do by itself?
More technical details on the raster operations in the next push!

Completes P0056, funded by rosenrose and [Anonymous].
This commit is contained in:
nmlgc 2019-11-03 12:47:10 +01:00
parent 772897c8f5
commit c09446a1f4
4 changed files with 287 additions and 234 deletions

35
libs/sprite16/sprite16.h Normal file
View File

@ -0,0 +1,35 @@
// Function numbers for the SPRITE16.COM driver, according to SPRITE16.DOC.
// Refer to this file for the actual documentation on the functions itself,
// the comments here only provide additional context.
// Only includes functions that are actually used in TH03.
#define SPRITE16 0x42
typedef enum {
// Derives SPRITE16's internal alpha masks used for monochrome and
// overlapped drawing from the sprite data area in VRAM. Should
// consequently be called after every change to that area.
SPRITE16_GENERATE_ALPHA = 1,
SPRITE16_PUT = 2,
SPRITE16_SET_MONO = 3,
SPRITE16_SET_COLOR = 4,
// Determines whether the VRAM area that will be occupied by newly drawn
// sprites will be
// • cleared using the alpha mask generated by SPRITE16_GENERATE_ALPHA
// before drawing (DX = OVERLAP_CLEAR, default)
// • or left as is, with the bits of the new sprite being ORed on top of
// the existing VRAM content, separately on every individual bitplane
// (DX = OVERLAP_OR). This will consequently produce interesting colors
// wherever two sprites overlap.
// This setting is ignored when in monochrome mode, which always touches
// all bitplanes according to the alpha mask, identical to monochrome
// blitting using the GRCG in RMW mode (e.g. using master.lib's
// grcg_setcolor()).
SPRITE16_SET_OVERLAP = 5,
SPRITE16_SET_MASK = 8
} sprite16_func_t;
typedef enum {
OVERLAP_CLEAR = 1,
OVERLAP_OR = 0
} sprite16_overlap_t;

View File

@ -0,0 +1,14 @@
; Function numbers for the SPRITE16.COM driver, according to SPRITE16.DOC.
; Only includes functions that are actually used in TH03.
SPRITE16 = 42h
SPRITE16_GENERATE_ALPHA = 1
SPRITE16_PUT = 2
SPRITE16_SET_MONO = 3
SPRITE16_SET_COLOR = 4
SPRITE16_SET_OVERLAP = 5
SPRITE16_SET_MASK = 8
OVERLAP_CLEAR = 1
OVERLAP_OR = 0

5
th03/sprite16[bss].asm Normal file
View File

@ -0,0 +1,5 @@
public _sprite16_put_h, _sprite16_put_w
_sprite16_put_h dw ?
_sprite16_put_w db ?
db ?

File diff suppressed because it is too large Load Diff