mirror of https://github.com/nmlgc/ReC98.git
[Decompilation] [th03] SPRITE16: Inline method for sprite size assignments
All but one of the writes to these globals follow the consistent scheme of assigning hardcoded literals to first `w` and then `h`, so it makes sense to encapsulate the conversion from display-space pixels to VRAM words and heights in a method. (On that note, we also need a new type to encode the notion of VRAM-space heights as opposed to the display-space heights of `pixel_t`.) Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
This commit is contained in:
parent
415bef1176
commit
51de5ec036
3
pc98.h
3
pc98.h
|
@ -28,6 +28,9 @@ typedef unsigned int uvram_byte_amount_t;
|
|||
typedef unsigned int uvram_word_amount_t;
|
||||
typedef unsigned int uvram_dword_amount_t;
|
||||
|
||||
// VRAM heights. Different from `pixel_t` in 200-line mode.
|
||||
typedef int vram_h_t;
|
||||
|
||||
// TRAM widths or heights
|
||||
typedef int tram_cell_amount_t;
|
||||
/// ------
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
#define SHOT_SO_PID (320 / 8)
|
||||
|
||||
#define SHOT_SPRITE_COUNT 4
|
||||
#define SHOT_W 16
|
||||
#define SHOT_H 8
|
||||
#define SHOT_VRAM_W (SHOT_W / BYTE_DOTS)
|
||||
#define SHOT_VRAM_H (SHOT_H / 2)
|
||||
|
||||
static const pixel_t SHOT_W = 16;
|
||||
static const pixel_t SHOT_H = 16;
|
||||
static const vram_byte_amount_t SHOT_VRAM_W = (SHOT_W / BYTE_DOTS);
|
||||
|
||||
enum shot_mode_t {
|
||||
SM_NONE = 0,
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
SHOT_VELOCITY = (-12 shl 4)
|
||||
SHOT_SO_PID = (320 / 8)
|
||||
|
||||
SHOT_SPRITE_COUNT = 4
|
||||
SHOT_W = 16
|
||||
SHOT_H = 8
|
||||
SHOT_VRAM_W = (SHOT_W / 8)
|
||||
SHOT_VRAM_H = (SHOT_H / 2)
|
||||
|
||||
; shot_mode_t
|
||||
SM_NONE = 0
|
||||
SM_1_PAIR = 1
|
||||
|
|
|
@ -37,7 +37,7 @@ void pascal sprite16_sprites_commit(void)
|
|||
#define SETUP_VARS(left, top, so) \
|
||||
sprite_offset_local = so; \
|
||||
putpos_left = left; \
|
||||
put_w_words = sprite16_put_w.v; \
|
||||
put_w_words = sprite16_put_size.w.v; \
|
||||
putpos_right_high ^= putpos_right_high; \
|
||||
static_cast<char>(putpos_right) = put_w_words; \
|
||||
putpos_right <<= 4; \
|
||||
|
@ -51,7 +51,7 @@ void pascal sprite16_sprites_commit(void)
|
|||
_BX = top; \
|
||||
static_cast<int>(_BX) >>= 1; \
|
||||
_AL = put_w_words; \
|
||||
_CX = sprite16_put_h; \
|
||||
_CX = sprite16_put_size.h; \
|
||||
_DI = so; \
|
||||
geninterrupt(SPRITE16); \
|
||||
|
||||
|
@ -114,7 +114,7 @@ put:
|
|||
_BX = top;
|
||||
static_cast<int>(_BX) >>= 1;
|
||||
_AL = put_w_words;
|
||||
_CX = sprite16_put_h;
|
||||
_CX = sprite16_put_size.h;
|
||||
_DI = sprite_offset_local;
|
||||
while(1) {
|
||||
should_draw_column = func;
|
||||
|
@ -157,7 +157,7 @@ void pascal sprite16_put_noclip(
|
|||
putpos_right <<= 4;
|
||||
putpos_right += putpos_left;
|
||||
|
||||
CALL_PUT(putpos_left, top, sprite16_put_w.v, sprite_offset_local);
|
||||
CALL_PUT(putpos_left, top, sprite16_put_size.w.v, sprite_offset_local);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,8 +4,15 @@
|
|||
// SPRITE16_OFFSET.
|
||||
typedef uvram_byte_amount_t sprite16_offset_t;
|
||||
|
||||
extern pixel_t sprite16_put_h;
|
||||
extern VRAMWord sprite16_put_w;
|
||||
extern struct {
|
||||
vram_h_t h;
|
||||
VRAMWord w;
|
||||
|
||||
void set(pixel_t w_, pixel_t h_) {
|
||||
w = w_;
|
||||
h = (h_ / 2);
|
||||
}
|
||||
} sprite16_put_size;
|
||||
extern screen_x_t sprite16_clip_left;
|
||||
extern screen_x_t sprite16_clip_right;
|
||||
|
||||
|
|
|
@ -28,8 +28,7 @@ void pascal near shots_render(void)
|
|||
{
|
||||
shotpair_t near *shotpair = shotpairs;
|
||||
|
||||
sprite16_put_w = SHOT_W;
|
||||
sprite16_put_h = SHOT_H;
|
||||
sprite16_put_size.set(SHOT_W, SHOT_H);
|
||||
sprite16_clip_left = 0;
|
||||
sprite16_clip_right = RES_X - 1;
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
public _sprite16_clip_left, _sprite16_clip_right
|
||||
public _sprite16_put_h, _sprite16_put_w
|
||||
|
||||
public _sprite16_clip_left, _sprite16_clip_right, _sprite16_put_size
|
||||
_sprite16_clip_left dw ?
|
||||
_sprite16_clip_right dw ?
|
||||
label _sprite16_put_size byte
|
||||
_sprite16_put_h dw ?
|
||||
_sprite16_put_w db ?
|
||||
db ?
|
||||
evendata
|
||||
|
|
Loading…
Reference in New Issue