Skip to content

Commit 331aa6e

Browse files
committed
displayio: When the display is tall, move blinka above the text
This makes a more useful display on the portrait magtag, allowing 21 characters across instead of just 18. There are 20 full rows of text, instead of 21. The total number of characters increases slightly from 378 to 420. For comparison, the Commodore VIC 20 had 22 rows of 23 characters for a total of 506 characters. :-P
1 parent 9a642fc commit 331aa6e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

supervisor/shared/display.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,21 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
6060

6161
#if CIRCUITPY_TERMINALIO
6262
displayio_tilegrid_t* grid = &supervisor_terminal_text_grid;
63-
uint16_t width_in_tiles = (width_px - blinka_bitmap.width) / grid->tile_width;
63+
bool tall = height_px > width_px;
64+
uint16_t terminal_width_px = tall ? width_px : width_px - blinka_bitmap.width;
65+
uint16_t terminal_height_px = tall ? height_px - blinka_bitmap.height : height_px ;
66+
uint16_t width_in_tiles = terminal_width_px / grid->tile_width;
6467
// determine scale based on h
6568
if (width_in_tiles < 80) {
6669
scale = 1;
6770
}
6871

69-
width_in_tiles = (width_px - blinka_bitmap.width * scale) / (grid->tile_width * scale);
72+
width_in_tiles = terminal_width_px / (grid->tile_width * scale);
7073
if (width_in_tiles < 1) {
7174
width_in_tiles = 1;
7275
}
73-
uint16_t height_in_tiles = height_px / (grid->tile_height * scale);
74-
uint16_t remaining_pixels = height_px % (grid->tile_height * scale);
76+
uint16_t height_in_tiles = terminal_height_px / (grid->tile_height * scale);
77+
uint16_t remaining_pixels = tall ? 0 : terminal_height_px % (grid->tile_height * scale);
7578
if (height_in_tiles < 1 || remaining_pixels > 0) {
7679
height_in_tiles += 1;
7780
}
@@ -91,7 +94,8 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
9194
if (tiles == NULL) {
9295
return;
9396
}
94-
grid->y = 0;
97+
grid->y = tall ? blinka_bitmap.height : 0;
98+
grid->x = tall ? 0 : blinka_bitmap.width;
9599
grid->top_left_y = 0;
96100
if (remaining_pixels > 0) {
97101
grid->y -= (grid->tile_height - remaining_pixels);

0 commit comments

Comments
 (0)