[Maintenance] Turn `vram_offset_divmul` into a template

Has been on the todo list of small features for over two years.

Part of P0285, funded by [Anonymous] and iruleatgames.
This commit is contained in:
nmlgc 2024-07-03 17:40:41 +02:00
parent 1e41fa0617
commit e0eb5cb1be
2 changed files with 3 additions and 7 deletions

View File

@ -129,11 +129,7 @@ static inline vram_offset_t vram_offset_muldiv(screen_x_t x, vram_y_t y) {
return (y * ROW_SIZE) + (x / BYTE_DOTS);
}
static inline vram_offset_t vram_offset_divmul(screen_x_t x, vram_y_t y) {
return (x / BYTE_DOTS) + (y * ROW_SIZE);
}
static inline vram_offset_t vram_offset_divmul_double(double x, double y) {
template <class T> inline vram_offset_t vram_offset_divmul(T x, T y) {
return (x / BYTE_DOTS) + (y * ROW_SIZE);
}

View File

@ -245,7 +245,7 @@ static const int PARTICLE2X2_COUNT = 30;
static const dots8_t sPARTICLE2X2 = 0xC0; // (** )
#define particle2x2_linear_vram_offset(vo, first_bit, left, top) { \
vo = vram_offset_divmul_double(left, top); \
vo = vram_offset_divmul(left, top); \
first_bit = (static_cast<screen_x_t>(left) % BYTE_DOTS); \
}
@ -1342,7 +1342,7 @@ void pascal near particles2x2_vertical_unput_update_render(bool16 from_bottom)
top[i] += velocity_y[i];
// Recalculate VRAM offset and clip
vo = vram_offset_divmul_double(left[i], top[i]);
vo = vram_offset_divmul(left[i], top[i]);
if((vo >= (((RES_Y - PARTICLE2X2_H) + 1) * ROW_SIZE) || (vo < 0))) {
col[i] = 0;
continue;