Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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.
- Loading branch information
Showing
5 changed files
with
445 additions
and
502 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.