Skip to content

Commit

Permalink
GBA: replace Grid and Linearity with Monoscope
Browse files Browse the repository at this point in the history
fix #50
  • Loading branch information
pinobatch committed Mar 9, 2024
1 parent 1923651 commit 6e25d86
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 99 deletions.
2 changes: 1 addition & 1 deletion gba/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ CFILES := \
CPPFILES :=
SFILES := \
posprintf.s \
bggfx_chr.s spritegfx_chr.s linearity_chr.s sharpness_chr.s \
bggfx_chr.s spritegfx_chr.s monoscope_chr.s sharpness_chr.s \
stopwatchface_chr.s stopwatchhand_chr.s stopwatchdigits_chr.s \
kikimap_chr.s kikitiles_chr.s greenhillzone_chr.s hepsie_chr.s \
Gus_portrait_chr.s convergence_chr.s pluge_shark_6color_chr.s \
Expand Down
3 changes: 1 addition & 2 deletions gba/src/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@ void draw_barslist(const BarsListEntry *rects);

extern const unsigned short gray4pal[4];
extern const unsigned short invgray4pal[4];
void activity_linearity(void);
void activity_monoscope(void);
void activity_sharpness(void);
void activity_smpte(void);
void activity_601bars(void);
void activity_pluge(void);
void activity_gcbars(void);
void activity_gray_ramp(void);
void activity_cps_grid(void);
void activity_full_stripes(void);
void activity_color_bleed(void);
void activity_solid_color(void);
Expand Down
66 changes: 40 additions & 26 deletions gba/src/helppages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Gradient color bars
SMPTE color bars
Color bars on gray
Color bleed
Grid
Linearity
Monoscope
Convergence
Gray ramp
Solid color screen
Expand Down Expand Up @@ -69,33 +68,48 @@ other consoles.
For more info, visit
http://junkerhq.net/240p

== Grid ==
== Monoscope ==

This grid uses the screen's
full 240x160 pixel resolution.
Use it to verify that the
entire picture is visible,
including the red border,
with no distortion.
Contains elements to
calibrate multiple aspects
of a CRT. Read your TV's
service manual to learn how.

Select: Invert grays

== Linearity ==

This pattern shows five
circles at the square pixel
aspect ratio of the GBA
screen. The circles should
have the same diameter in
all directions.

Use it to verify the horizontal
to vertical size ratio setting
of a display or scaler or to
measure distortion on a CRT.
Convergence:
Use the center crosshair
to check static (center
of screen) convergence.
Use the patterns at the
sides to check dynamic
(edge) convergence.

A: Hide or show grid
Select: Invert grays
↑↓: Change brightness
----
Adjust convergence at low
brightness. An overly bright
pattern causes bloom that
masks convergence issues.

Corners:
After setting center and
edge convergence, use
magnets to adjust corner
purity and geometry.
----
Size and aspect ratio:
After setting horizontal
size, use a tape measure to
adjust vertical size until
the red squares are square.

Linearity:
The squares in each corner
should get you started.
Confirm your adjustment
using the scroll tests.

Pattern by khmr33; adapted
to GBA by Lorenzoone

== Convergence ==

Expand Down
3 changes: 1 addition & 2 deletions gba/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ static const activity_func page_one_handlers[] = {
activity_smpte,
activity_601bars,
activity_color_bleed,
activity_cps_grid,
activity_linearity,
activity_monoscope,
activity_convergence,
activity_gray_ramp,
activity_solid_color,
Expand Down
90 changes: 22 additions & 68 deletions gba/src/stills.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ extern const unsigned char helpsect_gradient_color_bars[];
extern const unsigned char helpsect_smpte_color_bars[];
extern const unsigned char helpsect_color_bars_on_gray[];
extern const unsigned char helpsect_color_bleed[];
extern const unsigned char helpsect_grid[];
extern const unsigned char helpsect_linearity[];
extern const unsigned char helpsect_monoscope[];
extern const unsigned char helpsect_convergence[];
extern const unsigned char helpsect_gray_ramp[];
extern const unsigned char helpsect_sharpness[];
Expand All @@ -45,8 +44,8 @@ extern const unsigned char helpsect_full_screen_stripes[];
#define PFMAP 23
#define PFOVERLAY 22

extern const VBTILE linearity_chrTiles[27];
extern const unsigned int linearity_chrMap[];
extern const VBTILE monoscope_chrTiles[32];
extern const unsigned int monoscope_chrMap[];
extern const VBTILE sharpness_chrTiles[48];
extern const unsigned int sharpness_chrMap[];
extern const VBTILE convergence_chrTiles[5];
Expand Down Expand Up @@ -134,37 +133,32 @@ static const uint32_t brickstile[8] = {
0x11111122,
};

void activity_linearity(void) {
unsigned int inverted = 0;
unsigned int lcdc_value = MODE_0 | BG1_ON;
static const uint16_t monoscope_whites[] = {
RGB5( 0, 0, 0),RGB5(13,13,13),RGB5(22,22,22),RGB5(31,31,31),RGB5(31,31,31)
};

void activity_monoscope(void) {
unsigned int brightness = 1;

bitunpack2(PATRAM4(0, 0), linearity_chrTiles, sizeof(linearity_chrTiles));
RLUnCompVram(linearity_chrMap, MAP[PFMAP]);
dma_memset16(MAP[PFOVERLAY], 0x01, 32*20*2);
bitunpack2(PATRAM4(0, 0), monoscope_chrTiles, sizeof(monoscope_chrTiles));
RLUnCompVram(monoscope_chrMap, MAP[PFMAP]);
BG_COLORS[1] = RGB5(31, 0, 0);

while (1) {
read_pad_help_check(helpsect_linearity);
if (new_keys & KEY_SELECT) {
inverted = !inverted;
read_pad_help_check(helpsect_monoscope);
if (new_keys & KEY_UP) {
if (++brightness >= 5) brightness = 0;
}
if (new_keys & KEY_A) {
lcdc_value ^= BG0_ON;
}
if (new_keys & KEY_B) {
REG_BLDCNT = 0;
return;
if (new_keys & KEY_DOWN) {
if (!brightness--) brightness = 4;
}

// This uses blending.
VBlankIntrWait();
BGCTRL[1] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFMAP);
BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFOVERLAY);
BG_OFFSET[1].x = BG_OFFSET[0].x = BG_OFFSET[0].y = 0;
BG_OFFSET[1].y = 8;
dmaCopy(inverted ? invgray4pal : gray4pal, BG_COLORS+0x00, sizeof(gray4pal));
REG_DISPCNT = lcdc_value;
REG_BLDCNT = 0x2241; // sub is bg1 and backdrop; main is bg0; function is alpha blend
REG_BLDALPHA = 0x040C; // alpha levels: 4/16*sub + 12/16*main
BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFMAP);
BG_OFFSET[0].x = BG_OFFSET[0].y = 0;
BG_COLORS[0] = (brightness >= 4) ? RGB5(13,13,13) : 0;
BG_COLORS[2] = monoscope_whites[brightness];
REG_DISPCNT = MODE_0 | BG0_ON;
}
}

Expand Down Expand Up @@ -518,46 +512,6 @@ void activity_gray_ramp(void) {
}
}

void activity_cps_grid(void) {
unsigned int bright = 0;

load_common_bg_tiles();

// Draw grid map
for (unsigned int y = 0; y < 20; ++y) {
unsigned short *row = MAP[PFMAP][y];
unsigned int basetile = (y & 1) ? 0x0821 : 0x0021; // Xflip
if (y < 2 || y >= 18) basetile |= 0x1000;

row[0] = basetile | 0x1000;
row[1] = basetile | 0x1400;
for (unsigned int x = 2; x < 28; ++x) {
row[x] = basetile;
basetile ^= 0x0400;
}
row[28] = basetile | 0x1000;
row[29] = basetile | 0x1400;
}

while (1) {
read_pad_help_check(helpsect_grid);
if (new_keys & KEY_SELECT) {
bright = !bright;
}
if (new_keys & KEY_B) {
return;
}

VBlankIntrWait();
BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFMAP);
BG_OFFSET[0].x = BG_OFFSET[0].y = 0;
BG_COLORS[0] = bright ? RGB5(31, 31, 31) : RGB5(0, 0, 0);
BG_COLORS[1] = bright ? RGB5(0, 0, 0) : RGB5(31, 31, 31);
BG_COLORS[17] = RGB5(31, 0, 0);
REG_DISPCNT = MODE_0 | BG0_ON;
}
}

static const uint32_t full_stripes_patterns[3][2] = {
{0x11111111,0x22222222},
{0x12121212,0x12121212},
Expand Down
1 change: 1 addition & 0 deletions gba/tilesets/monoscope.grit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-p! -gB2 -mRtpf -mLs -mzr
Binary file added gba/tilesets/monoscope.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6e25d86

Please sign in to comment.