From 5a1e16de60ba3304e606d85e995d40f74b40ec9e Mon Sep 17 00:00:00 2001 From: nmlgc Date: Tue, 25 Aug 2020 14:23:52 +0200 Subject: [PATCH] [Maintenance] Subpixels: Rename to_screen() to to_pixel() We've been establishing `screen` as meaning "a coordinate rooted at the top-left corner of the display", whereas most of the Subpixels in >TH01 are rooted at the top-left of the playfield. Part of P0112, funded by [Anonymous] and Blue Bolt. --- th01/main/bullet/pellet.cpp | 34 +++++++++++++++++----------------- th01/main/bullet/pellet.hpp | 4 ++-- th01/math/subpixel.hpp | 2 +- th03/main_01.cpp | 2 +- th05/i_shot.hpp | 1 + th05/main/boss/render.cpp | 8 ++++---- 6 files changed, 26 insertions(+), 25 deletions(-) diff --git a/th01/main/bullet/pellet.cpp b/th01/main/bullet/pellet.cpp index 32526553..0e250612 100644 --- a/th01/main/bullet/pellet.cpp +++ b/th01/main/bullet/pellet.cpp @@ -317,8 +317,8 @@ void CPellets::motion_type_apply_for_cur(void) p->angle += PELLET_SLING_DELTA_ANGLE; if(p->angle > 0x100) { vector2_between( - p->cur_left.to_screen(), - p->cur_top.to_screen(), + p->cur_left.to_pixel(), + p->cur_top.to_pixel(), player_left + 8, player_center_y, p->velocity.x.v, @@ -340,7 +340,7 @@ void CPellets::motion_type_apply_for_cur(void) // type system? :zunpet: if( (p->cur_left.v <= PELLET_LEFT_MIN) - || (p->cur_left.to_screen() >= to_sp(PELLET_LEFT_MAX)) + || (p->cur_left.to_pixel() >= to_sp(PELLET_LEFT_MAX)) || (p->cur_top.v <= to_sp(PELLET_BOUNCE_TOP_MIN)) ) { p->velocity.x.v = -p->velocity.x.v; @@ -359,11 +359,11 @@ void CPellets::motion_type_apply_for_cur(void) } break; case PM_FALL_STRAIGHT_FROM_TOP_THEN_NORMAL: - if(p->cur_top.to_screen() <= PELLET_BOUNCE_TOP_MIN) { + if(p->cur_top.to_pixel() <= PELLET_BOUNCE_TOP_MIN) { p->velocity.x.set(0.0f); p->velocity.y.v = p->speed.v; p->motion_type = PM_NORMAL; - if(p->cur_top.to_screen() <= PLAYFIELD_TOP) { + if(p->cur_top.to_pixel() <= PLAYFIELD_TOP) { p->cur_top.set(PLAYFIELD_TOP + 1.0f); } } @@ -381,8 +381,8 @@ void CPellets::motion_type_apply_for_cur(void) break; case PM_CHASE: vector2_between( - p->cur_left.to_screen(), - p->cur_top.to_screen(), + p->cur_left.to_pixel(), + p->cur_top.to_pixel(), player_left + 8, player_center_y, velocity_to_player_x.v, @@ -529,7 +529,7 @@ bool16 CPellets::visible_after_hittests_for_cur( (PLAYER_H + (PELLET_H * 2)) ) == true)) { char deflect_angle; - if(p->cur_left.to_screen() <= (player_left + 12)) { + if(p->cur_left.to_pixel() <= (player_left + 12)) { deflect_angle = 0x80; } else { deflect_angle = 0x00; @@ -588,7 +588,7 @@ void CPellets::unput_update_render(void) // Shot<->Pellet hit testing if(p->decay_frame == 0) { if(Shots.hittest_pellet( - p->cur_left.to_screen(), p->cur_top.to_screen() + p->cur_left.to_pixel(), p->cur_top.to_pixel() )) { p->decay_frame = 0; p->moving = false; @@ -619,7 +619,7 @@ void CPellets::unput_update_render(void) } if(!pellet_interlace || ((interlace_field & 1) == (i % 2))) { if(visible_after_hittests_for_cur( - p->cur_left.to_screen(), p->cur_top.to_screen() + p->cur_left.to_pixel(), p->cur_top.to_pixel() ) == true) { if(p->not_rendered == true) { p->not_rendered = false; @@ -628,11 +628,11 @@ void CPellets::unput_update_render(void) #define decay_frames_for_cel(cel) \ ((PELLET_DECAY_FRAMES / PELLET_DECAY_CELS) * cel) if(p->decay_frame == 0) { - render(p->cur_left.to_screen(), p->cur_top.to_screen(), 0); + render(p->cur_left.to_pixel(), p->cur_top.to_pixel(), 0); } else if(p->decay_frame <= decay_frames_for_cel(1)) { - render(p->cur_left.to_screen(), p->cur_top.to_screen(), 1); + render(p->cur_left.to_pixel(), p->cur_top.to_pixel(), 1); } else if(p->decay_frame < decay_frames_for_cel(2)) { - render(p->cur_left.to_screen(), p->cur_top.to_screen(), 2); + render(p->cur_left.to_pixel(), p->cur_top.to_pixel(), 2); } #undef decay_frames_for_cel #undef render @@ -710,11 +710,11 @@ bool16 CPellets::hittest_player_for_cur(void) return false; } if( - (p->cur_left.to_screen() >= (player_left + 4)) && - (p->cur_left.to_screen() <= (player_left + 20)) && - (p->cur_top.to_screen() >= (player_top + (player_sliding * 8))) && + (p->cur_left.to_pixel() >= (player_left + 4)) && + (p->cur_left.to_pixel() <= (player_left + 20)) && + (p->cur_top.to_pixel() >= (player_top + (player_sliding * 8))) && // Yup, <, not <= as in the overlap_point_le_ge() macro. - (p->cur_top.to_screen() < (player_top + PLAYER_H - PELLET_H)) + (p->cur_top.to_pixel() < (player_top + PLAYER_H - PELLET_H)) ) { done = true; return true; diff --git a/th01/main/bullet/pellet.hpp b/th01/main/bullet/pellet.hpp index 96c6dc04..1f349337 100644 --- a/th01/main/bullet/pellet.hpp +++ b/th01/main/bullet/pellet.hpp @@ -118,13 +118,13 @@ protected: // Why, I don't even?!? void sloppy_wide_unput(void) { egc_copy_rect_1_to_0_16( - prev_left.to_screen(), prev_top.to_screen(), 16, PELLET_H + prev_left.to_pixel(), prev_top.to_pixel(), 16, PELLET_H ); } void sloppy_wide_unput_at_cur_pos(void) { egc_copy_rect_1_to_0_16( - cur_left.to_screen(), cur_top.to_screen(), 16, PELLET_H + cur_left.to_pixel(), cur_top.to_pixel(), 16, PELLET_H ); } diff --git a/th01/math/subpixel.hpp b/th01/math/subpixel.hpp index be5c883e..f2d152a6 100644 --- a/th01/math/subpixel.hpp +++ b/th01/math/subpixel.hpp @@ -40,7 +40,7 @@ public: v = TO_SP(screen_v); } - T to_screen() const { + T to_pixel() const { return v >> 4; } diff --git a/th03/main_01.cpp b/th03/main_01.cpp index f6dbc6b2..bf6d3ce1 100644 --- a/th03/main_01.cpp +++ b/th03/main_01.cpp @@ -39,7 +39,7 @@ void pascal near shots_render(void) screen_x_t left = playfield_fg_x_to_screen( shotpair->topleft.x, shotpair->pid ); - screen_y_t top = shotpair->topleft.y.to_screen() + PLAYFIELD_Y; + screen_y_t top = shotpair->topleft.y.to_pixel() + PLAYFIELD_Y; sprite16_put(left + 0, top, so); sprite16_put(left + SHOTPAIR_DISTANCE, top, so); diff --git a/th05/i_shot.hpp b/th05/i_shot.hpp index 69c61c93..1859a737 100644 --- a/th05/i_shot.hpp +++ b/th05/i_shot.hpp @@ -5,6 +5,7 @@ #include #include "platform.h" +#include "pc98.h" #include "th01/math/subpixel.hpp" #include "th03/math/randring.h" #include "th04/math/motion.hpp" diff --git a/th05/main/boss/render.cpp b/th05/main/boss/render.cpp index 64ca12dd..094d73e1 100644 --- a/th05/main/boss/render.cpp +++ b/th05/main/boss/render.cpp @@ -51,14 +51,14 @@ void pascal near grcg_lineset_line_put(lineset_t near &set, int i) vector2_at(drawpoint, set.center[i].x, set.center[i].y, set.radius[i], set.angle[i] ); - screen_x_t x1 = (PLAYFIELD_X + drawpoint.x.to_screen()); - screen_y_t y1 = (PLAYFIELD_Y + drawpoint.y.to_screen()); + screen_x_t x1 = (PLAYFIELD_X + drawpoint.x.to_pixel()); + screen_y_t y1 = (PLAYFIELD_Y + drawpoint.y.to_pixel()); vector2_at(drawpoint, set.center[i].x, set.center[i].y, set.radius[i], (set.angle[i] + 0x80) ); - screen_x_t x2 = (PLAYFIELD_X + drawpoint.x.to_screen()); - screen_y_t y2 = (PLAYFIELD_Y + drawpoint.y.to_screen()); + screen_x_t x2 = (PLAYFIELD_X + drawpoint.x.to_pixel()); + screen_y_t y2 = (PLAYFIELD_Y + drawpoint.y.to_pixel()); grcg_line(x1, y1, x2, y2); }