mirror of https://github.com/nmlgc/ReC98.git
[Decompilation] [th01] Ellipse arc blitting
Most frequently used for complete circles, though… but who cares, as of this commit, ReC98, as a whole, is ⅓ done! Part of P0120, funded by Yanga.
This commit is contained in:
parent
a80343aac1
commit
23f5645be5
|
@ -0,0 +1,69 @@
|
|||
#include "th01/sprites/shape8x8.h"
|
||||
#include "th01/main/shape.hpp"
|
||||
|
||||
#define shape8x8_put(shape, left, top, col) \
|
||||
dots8x8_t sprite = sSHAPE8X8[shape]; \
|
||||
vram_offset_t vram_offset_topleft = vram_offset_divmul(left, top); \
|
||||
int first_bit = (left % BYTE_DOTS); \
|
||||
if((left < 0) || (left >= RES_X) || (top < 0) || (top >= RES_Y)) { \
|
||||
return; \
|
||||
} \
|
||||
grcg_put_8x8_mono(vram_offset_topleft, first_bit, sprite.rows, col);
|
||||
|
||||
void shape8x8_diamond_put(screen_x_t left, vram_y_t top, int col)
|
||||
{
|
||||
shape8x8_put(SHAPE8X8_DIAMOND, left, top, col);
|
||||
}
|
||||
|
||||
void shape8x8_star_put(screen_x_t left, vram_y_t top, int col)
|
||||
{
|
||||
shape8x8_put(SHAPE8X8_STAR, left, top, col);
|
||||
}
|
||||
|
||||
void shape8x8_flake_put(screen_x_t left, vram_y_t top, int col)
|
||||
{
|
||||
shape8x8_put(SHAPE8X8_FLAKE, left, top, col);
|
||||
}
|
||||
|
||||
void shape_ellipse_arc_put(
|
||||
screen_x_t center_x,
|
||||
vram_y_t center_y,
|
||||
pixel_t radius_x,
|
||||
pixel_t radius_y,
|
||||
int col,
|
||||
unsigned char angle_step,
|
||||
unsigned char angle_start,
|
||||
unsigned char angle_end
|
||||
)
|
||||
{
|
||||
int angle; // 16 bits to correctly work for an [angle_end] of 0xFF
|
||||
dots8_t cache_dots = 0;
|
||||
vram_offset_t cache_vram_offset = -1;
|
||||
|
||||
grcg_setcolor_rmw(col);
|
||||
|
||||
if(angle_start > angle_end) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(angle = angle_start; angle <= angle_end; angle += angle_step) {
|
||||
vram_offset_t vram_offset;
|
||||
screen_x_t cur_x = polar_x(center_x, radius_x, angle);
|
||||
vram_y_t cur_y = polar_y(center_y, radius_y, angle);
|
||||
|
||||
vram_offset = vram_offset_shift(cur_x, cur_y);
|
||||
if(cache_vram_offset != vram_offset) {
|
||||
if(
|
||||
(cur_x >= 0) && (cur_x < RES_X) &&
|
||||
(cache_vram_offset >= 0) && (cache_vram_offset < PLANE_SIZE)
|
||||
) {
|
||||
VRAM_PUT(B, cache_vram_offset, cache_dots, 8);
|
||||
}
|
||||
cache_dots = ((0x80) >> (cur_x & (BYTE_DOTS - 1)));
|
||||
cache_vram_offset = vram_offset;
|
||||
} else {
|
||||
cache_dots |= ((0x80) >> (cur_x & (BYTE_DOTS - 1)));
|
||||
}
|
||||
}
|
||||
grcg_off();
|
||||
}
|
|
@ -3,3 +3,14 @@
|
|||
void shape8x8_diamond_put(screen_x_t left, vram_y_t top, int col);
|
||||
void shape8x8_star_put(screen_x_t left, vram_y_t top, int col);
|
||||
void shape8x8_flake_put(screen_x_t left, vram_y_t top, int col);
|
||||
|
||||
void shape_ellipse_arc_put(
|
||||
screen_x_t center_x,
|
||||
vram_y_t center_y,
|
||||
pixel_t radius_x,
|
||||
pixel_t radius_y,
|
||||
int col,
|
||||
unsigned char angle_step,
|
||||
unsigned char angle_start,
|
||||
unsigned char angle_end
|
||||
);
|
|
@ -1,26 +0,0 @@
|
|||
#include "th01/sprites/shape8x8.h"
|
||||
#include "th01/main/shape8x8.hpp"
|
||||
|
||||
#define shape8x8_put(shape, left, top, col) \
|
||||
dots8x8_t sprite = sSHAPE8X8[shape]; \
|
||||
vram_offset_t vram_offset_topleft = vram_offset_divmul(left, top); \
|
||||
int first_bit = (left % BYTE_DOTS); \
|
||||
if((left < 0) || (left >= RES_X) || (top < 0) || (top >= RES_Y)) { \
|
||||
return; \
|
||||
} \
|
||||
grcg_put_8x8_mono(vram_offset_topleft, first_bit, sprite.rows, col);
|
||||
|
||||
void shape8x8_diamond_put(screen_x_t left, vram_y_t top, int col)
|
||||
{
|
||||
shape8x8_put(SHAPE8X8_DIAMOND, left, top, col);
|
||||
}
|
||||
|
||||
void shape8x8_star_put(screen_x_t left, vram_y_t top, int col)
|
||||
{
|
||||
shape8x8_put(SHAPE8X8_STAR, left, top, col);
|
||||
}
|
||||
|
||||
void shape8x8_flake_put(screen_x_t left, vram_y_t top, int col)
|
||||
{
|
||||
shape8x8_put(SHAPE8X8_FLAKE, left, top, col);
|
||||
}
|
|
@ -6,8 +6,10 @@
|
|||
#pragma option -3 -Z
|
||||
|
||||
extern "C" {
|
||||
#include "libs/master.lib/master.h"
|
||||
#include "th01/formats/grc.cpp"
|
||||
#include "th01/hardware/grcg8x8m.cpp"
|
||||
#include "th01/math/vector.hpp"
|
||||
}
|
||||
|
||||
#include "th01/main/shape8x8.cpp"
|
||||
#include "th01/main/shape.cpp"
|
||||
|
|
837
th01_reiiden.asm
837
th01_reiiden.asm
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue