mirror of
https://github.com/V2RetroComputing/analog-firmware.git
synced 2024-06-01 06:41:34 +00:00
Compare commits
4 Commits
0a23cd3eff
...
a29b7d8921
Author | SHA1 | Date | |
---|---|---|---|
|
a29b7d8921 | ||
|
2955c08f76 | ||
|
8a43169dd7 | ||
|
2176303980 |
|
@ -11,7 +11,7 @@ void __noinline memcpy32(void *dst, void *src, uint32_t size) {
|
||||||
if(!size) return;
|
if(!size) return;
|
||||||
|
|
||||||
// Cowardly avoid unaligned transfers, let memcpy() handle them.
|
// Cowardly avoid unaligned transfers, let memcpy() handle them.
|
||||||
if((size & 0x3) || (((uint32_t)dst) & 0x3) || (((uint32_t)src) & 0x3)) {
|
if((size < 64) || (size & 0x3) || (((uint32_t)dst) & 0x3) || (((uint32_t)src) & 0x3)) {
|
||||||
memcpy(dst, src, size);
|
memcpy(dst, src, size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,47 @@ void __noinline memcpy32(void *dst, void *src, uint32_t size) {
|
||||||
channel_config_set_write_increment(&c, false);
|
channel_config_set_write_increment(&c, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __noinline memset32(void *dst, uint8_t val, uint32_t size) {
|
||||||
|
dma_channel_config c;
|
||||||
|
uint32_t src = val;
|
||||||
|
src |= src << 8;
|
||||||
|
src |= src << 16;
|
||||||
|
|
||||||
|
// Nothing to do!
|
||||||
|
if(!size) return;
|
||||||
|
|
||||||
|
// Cowardly avoid unaligned transfers, let memset() handle them.
|
||||||
|
if((size < 64) || (size & 0x3) || (((uint32_t)dst) & 0x3)) {
|
||||||
|
memset(dst, val, size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 32 bit transfers. Write address increments after each
|
||||||
|
// transfer (pointing to a location in dst).
|
||||||
|
// No DREQ is selected, so the DMA transfers as fast as it can.
|
||||||
|
|
||||||
|
// Get a free channel, panic() if there are none
|
||||||
|
if(dmacopy_channel == -1)
|
||||||
|
dmacopy_channel = dma_claim_unused_channel(true);
|
||||||
|
|
||||||
|
c = dma_channel_get_default_config(dmacopy_channel);
|
||||||
|
channel_config_set_transfer_data_size(&c, DMA_SIZE_32);
|
||||||
|
channel_config_set_read_increment(&c, false);
|
||||||
|
channel_config_set_write_increment(&c, true);
|
||||||
|
|
||||||
|
dma_channel_configure(dmacopy_channel, &c, dst, &src, (size >> 2), true);
|
||||||
|
|
||||||
|
dma_channel_wait_for_finish_blocking(dmacopy_channel);
|
||||||
|
|
||||||
|
dma_channel_abort(dmacopy_channel);
|
||||||
|
|
||||||
|
// Deinit the DMA channel
|
||||||
|
c = dma_channel_get_default_config(dmacopy_channel);
|
||||||
|
dma_channel_configure(dmacopy_channel, &c, NULL, NULL, 0, false);
|
||||||
|
channel_config_set_read_increment(&c, false);
|
||||||
|
channel_config_set_write_increment(&c, false);
|
||||||
|
}
|
||||||
|
|
||||||
void __noinline dmacpy32(void *start, void *end, void *source) {
|
void __noinline dmacpy32(void *start, void *end, void *source) {
|
||||||
uint32_t size = ((uint32_t)end) - ((uint32_t)start);
|
uint32_t size = ((uint32_t)end) - ((uint32_t)start);
|
||||||
|
|
||||||
|
|
|
@ -2,3 +2,5 @@
|
||||||
|
|
||||||
void memcpy32(void *dst, void *src, uint32_t size);
|
void memcpy32(void *dst, void *src, uint32_t size);
|
||||||
void dmacpy32(void *start, void *end, void *source);
|
void dmacpy32(void *start, void *end, void *source);
|
||||||
|
|
||||||
|
void __noinline memset32(void *dst, uint8_t val, uint32_t size);
|
|
@ -224,17 +224,14 @@ void __time_critical_func(vga_businterface)(uint32_t address, uint32_t value) {
|
||||||
apple_memory[address] = terminal_border;
|
apple_memory[address] = terminal_border;
|
||||||
break;
|
break;
|
||||||
case 0x08:
|
case 0x08:
|
||||||
terminal_row = (value < 24) ? value : 23;
|
soft_switches &= ~SOFTSW_TERMINAL;
|
||||||
apple_memory[address] = terminal_row;
|
|
||||||
apple_memory[address+2] = terminal_memory[terminal_row*80+terminal_col];
|
|
||||||
break;
|
break;
|
||||||
case 0x09:
|
case 0x09:
|
||||||
terminal_col = (value < 80) ? value : 79;
|
soft_switches |= SOFTSW_TERMINAL;
|
||||||
apple_memory[address] = terminal_col;
|
|
||||||
apple_memory[address+1] = terminal_memory[terminal_row*80+terminal_col];
|
|
||||||
break;
|
break;
|
||||||
case 0x0A:
|
case 0x0A:
|
||||||
terminal_memory[terminal_row*80+terminal_col] = value;
|
terminal_fifo[terminal_fifo_wrptr++] = (value & 0xFF);
|
||||||
|
apple_memory[address] = (terminal_fifo_rdptr - terminal_fifo_wrptr);
|
||||||
break;
|
break;
|
||||||
case 0x0B:
|
case 0x0B:
|
||||||
if((value & 0xFF) <= 0x27) {
|
if((value & 0xFF) <= 0x27) {
|
||||||
|
@ -244,5 +241,10 @@ void __time_critical_func(vga_businterface)(uint32_t address, uint32_t value) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if(CARD_SELECT && CARD_DEVSEL) {
|
||||||
|
if((address & 0x0F) == 0x0A) {
|
||||||
|
apple_memory[address] = (terminal_fifo_rdptr - terminal_fifo_wrptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,8 @@ void DELAYED_COPY_CODE(render_init)() {
|
||||||
memcpy(terminal_character_rom, (void*)FLASH_FONT_APPLE_IIE, 4096);
|
memcpy(terminal_character_rom, (void*)FLASH_FONT_APPLE_IIE, 4096);
|
||||||
memset(status_line, 0, sizeof(status_line));
|
memset(status_line, 0, sizeof(status_line));
|
||||||
|
|
||||||
|
terminal_clear_screen();
|
||||||
|
|
||||||
render_test_init();
|
render_test_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +126,7 @@ void DELAYED_COPY_CODE(render_border)(uint count) {
|
||||||
uint sl_pos = 0;
|
uint sl_pos = 0;
|
||||||
|
|
||||||
while(sl_pos < VGA_WIDTH/16) {
|
while(sl_pos < VGA_WIDTH/16) {
|
||||||
sl->data[sl_pos] = (text_border|THEN_EXTEND_7) | ((text_border|THEN_EXTEND_7) << 16); // 8 pixels per word
|
sl->data[sl_pos] = (text_border|THEN_EXTEND_7) | ((text_border|THEN_EXTEND_7) << 16); // 16 pixels per word
|
||||||
sl_pos++;
|
sl_pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,8 +205,6 @@ void DELAYED_COPY_CODE(render_loop)() {
|
||||||
testdone = 1;
|
testdone = 1;
|
||||||
render_about_init();
|
render_about_init();
|
||||||
}
|
}
|
||||||
} else if(soft_switches & SOFTSW_TERMINAL) {
|
|
||||||
render_terminal();
|
|
||||||
#if defined(ANALOG_GS) || defined(OVERCLOCKED)
|
#if defined(ANALOG_GS) || defined(OVERCLOCKED)
|
||||||
} else if(soft_switches & SOFTSW_SHR) {
|
} else if(soft_switches & SOFTSW_SHR) {
|
||||||
render_shr();
|
render_shr();
|
||||||
|
@ -220,6 +220,9 @@ void DELAYED_COPY_CODE(render_loop)() {
|
||||||
render_border(32);
|
render_border(32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(soft_switches & SOFTSW_TERMINAL) {
|
||||||
|
render_terminal();
|
||||||
|
} else
|
||||||
switch(soft_switches & SOFTSW_MODE_MASK) {
|
switch(soft_switches & SOFTSW_MODE_MASK) {
|
||||||
case 0:
|
case 0:
|
||||||
if(soft_switches & SOFTSW_DGR) {
|
if(soft_switches & SOFTSW_DGR) {
|
||||||
|
|
|
@ -9,6 +9,8 @@ extern uint16_t lores_palette[16];
|
||||||
extern uint16_t text_fore, text_back, text_border;
|
extern uint16_t text_fore, text_back, text_border;
|
||||||
extern uint8_t status_line[81];
|
extern uint8_t status_line[81];
|
||||||
|
|
||||||
|
extern void terminal_clear_screen();
|
||||||
|
|
||||||
extern void update_status_left(const char *str);
|
extern void update_status_left(const char *str);
|
||||||
extern void update_status_right(const char *str);
|
extern void update_status_right(const char *str);
|
||||||
|
|
||||||
|
@ -27,7 +29,6 @@ extern void render_text80_line(bool p2, unsigned int line);
|
||||||
extern void render_status_line();
|
extern void render_status_line();
|
||||||
|
|
||||||
extern void render_terminal();
|
extern void render_terminal();
|
||||||
extern void render_terminal_line(unsigned int line);
|
|
||||||
|
|
||||||
extern void render_border(uint count);
|
extern void render_border(uint count);
|
||||||
|
|
||||||
|
|
|
@ -1,76 +1,241 @@
|
||||||
|
#include <string.h>
|
||||||
#include <pico/stdlib.h>
|
#include <pico/stdlib.h>
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
|
#include "common/dmacopy.h"
|
||||||
|
|
||||||
#include "vga/vgabuf.h"
|
#include "vga/vgabuf.h"
|
||||||
#include "vga/render.h"
|
#include "vga/render.h"
|
||||||
#include "vga/vgaout.h"
|
#include "vga/vgaout.h"
|
||||||
|
|
||||||
static inline uint_fast8_t char_terminal_bits(uint_fast8_t ch, uint_fast8_t glyph_line) {
|
uint8_t terminal_jsoffset = 0;
|
||||||
uint_fast8_t bits = terminal_character_rom[((uint_fast16_t)ch << 3) | glyph_line];
|
uint8_t terminal_ssoffset = 0;
|
||||||
if(ch & 0x80) {
|
bool terminal_esc = 0;
|
||||||
// normal character
|
bool terminal_esc_crz = 0;
|
||||||
return bits & 0x7f;
|
int terminal_esc_pos = 0;
|
||||||
}
|
uint16_t terminal_charset = 0;
|
||||||
|
uint8_t terminal_width = 80;
|
||||||
|
uint8_t terminal_height = 24;
|
||||||
|
|
||||||
if((bits & 0x80) == 0) {
|
static inline uint_fast8_t char_terminal_bits(uint_fast8_t ch, uint_fast8_t glyph_line) {
|
||||||
// inverse character
|
uint_fast8_t bits = terminal_character_rom[terminal_charset | (((uint_fast16_t)ch & 0x7f) << 3) | glyph_line];
|
||||||
return bits ^ 0x7f;
|
|
||||||
|
if(ch & 0x80) {
|
||||||
|
return (bits & 0x7f) ^ 0x7f;
|
||||||
|
}
|
||||||
|
return (bits & 0x7f);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DELAYED_COPY_CODE(terminal_linefeed)() {
|
||||||
|
if(terminal_row < (terminal_height-1)) {
|
||||||
|
terminal_row++;
|
||||||
} else {
|
} else {
|
||||||
// flashing character
|
// Clear the next text buffer line (using dma if possible)
|
||||||
return (bits ^ text_flasher_mask) & 0x7f;
|
memset((void*)(terminal_memory+(((terminal_row+1+terminal_jsoffset) * 128) & 0xFFF)), ' ', 128);
|
||||||
|
|
||||||
|
// Smooth scroll then increment jsoffset
|
||||||
|
terminal_ssoffset = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void DELAYED_COPY_CODE(terminal_advance_cursor)() {
|
||||||
|
terminal_col++;
|
||||||
|
if(terminal_col >= terminal_width) {
|
||||||
|
terminal_col = 0;
|
||||||
|
terminal_linefeed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DELAYED_COPY_CODE(terminal_clear_screen)() {
|
||||||
|
// Clear screen (using dma)
|
||||||
|
memset((void*)terminal_memory, ' ', 4096);
|
||||||
|
terminal_jsoffset = 0;
|
||||||
|
terminal_row = 0;
|
||||||
|
terminal_col = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DELAYED_COPY_CODE(terminal_clear_to_line_end)() {
|
||||||
|
// Clear to end of line first
|
||||||
|
memset((void*)(terminal_memory+((((terminal_row+terminal_jsoffset) * 128) + terminal_col) & 0xFFF)), ' ', 128-terminal_col);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DELAYED_COPY_CODE(terminal_clear_to_screen_end)() {
|
||||||
|
// Clear to end of line first
|
||||||
|
memset((void*)(terminal_memory+((((terminal_row+terminal_jsoffset) * 128) + terminal_col) & 0xFFF)), ' ', 128-terminal_col);
|
||||||
|
|
||||||
|
// Then clear remaining lines on the screen
|
||||||
|
for(uint i = terminal_row; i < terminal_height; i++)
|
||||||
|
memset((void*)(terminal_memory+(((i+terminal_jsoffset) * 128) & 0xFFF)), ' ', 128);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DELAYED_COPY_CODE(terminal_process_input)() {
|
||||||
|
if(terminal_ssoffset > 0) return;
|
||||||
|
|
||||||
|
if(terminal_fifo_rdptr != terminal_fifo_wrptr) {
|
||||||
|
char ch = terminal_fifo[terminal_fifo_rdptr++];
|
||||||
|
if(terminal_esc_pos == 1) {
|
||||||
|
terminal_col = (ch - 32);
|
||||||
|
if(terminal_col >= terminal_width)
|
||||||
|
terminal_col = terminal_width - 1;
|
||||||
|
terminal_esc_pos = 2;
|
||||||
|
} else if(terminal_esc_pos == 2) {
|
||||||
|
terminal_row = (ch - 32);
|
||||||
|
if(terminal_row >= terminal_height)
|
||||||
|
terminal_row = terminal_height - 1;
|
||||||
|
terminal_esc_pos = 0;
|
||||||
|
} else if(terminal_esc_crz) {
|
||||||
|
switch(ch) {
|
||||||
|
case '0': // Clear Screen
|
||||||
|
terminal_clear_screen();
|
||||||
|
break;
|
||||||
|
case '1':
|
||||||
|
soft_switches &= ~SOFTSW_TERMINAL;
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
terminal_charset = 0;
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
terminal_charset = 2048;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
terminal_memory[(((terminal_row+terminal_jsoffset) * 128) + terminal_col) & 0xFFF] = ch;
|
||||||
|
terminal_advance_cursor();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
terminal_esc_crz = false;
|
||||||
|
} else if(terminal_esc) {
|
||||||
|
switch(ch) {
|
||||||
|
case 'A':
|
||||||
|
terminal_advance_cursor();
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
if(terminal_col > 0)
|
||||||
|
terminal_col--;
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
terminal_linefeed();
|
||||||
|
break;
|
||||||
|
case 'D': // Reverse Linefeed
|
||||||
|
if(terminal_row > 0)
|
||||||
|
terminal_row--;
|
||||||
|
break;
|
||||||
|
case 'E': // Clear to end of line
|
||||||
|
terminal_clear_to_line_end();
|
||||||
|
break;
|
||||||
|
case 'F': // Clear to end of screen
|
||||||
|
terminal_clear_to_screen_end();
|
||||||
|
break;
|
||||||
|
case '@': // Clear screen
|
||||||
|
terminal_clear_screen();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
terminal_memory[(((terminal_row+terminal_jsoffset) * 128) + terminal_col) & 0xFFF] = ch;
|
||||||
|
terminal_advance_cursor();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
terminal_esc = false;
|
||||||
|
} else
|
||||||
|
switch(ch) {
|
||||||
|
case 0x0A: // Line Feed
|
||||||
|
terminal_linefeed();
|
||||||
|
break;
|
||||||
|
case 0x0B: // Ctrl-K: Clear to End of Screen
|
||||||
|
terminal_clear_to_screen_end();
|
||||||
|
break;
|
||||||
|
case 0x0C: // Ctrl-L: Form Feed
|
||||||
|
terminal_clear_screen();
|
||||||
|
break;
|
||||||
|
case 0x0D: // Ctrl-M: Carriage Return
|
||||||
|
terminal_col = 0;
|
||||||
|
break;
|
||||||
|
case 0x13: // Ctrl-S: Xon/Xoff (unimplemented)
|
||||||
|
break;
|
||||||
|
case 0x15: // Ctrl-U: Copy (unimplemented)
|
||||||
|
break;
|
||||||
|
case 0x19: // Ctrl-Y: Home Cursor
|
||||||
|
terminal_row = 0;
|
||||||
|
terminal_col = 0;
|
||||||
|
break;
|
||||||
|
case 0x1A: // Ctrl-Z
|
||||||
|
terminal_esc_crz = true;
|
||||||
|
break;
|
||||||
|
case 0x1B: // Escape
|
||||||
|
terminal_esc = true;
|
||||||
|
break;
|
||||||
|
case 0x1C: // Forward Space
|
||||||
|
terminal_advance_cursor();
|
||||||
|
break;
|
||||||
|
case 0x1D: // Clear to end of line
|
||||||
|
terminal_clear_to_line_end();
|
||||||
|
break;
|
||||||
|
case 0x1E: // Position Cursor
|
||||||
|
terminal_esc_pos = 1;
|
||||||
|
break;
|
||||||
|
case 0x1F: // Reverse Linefeed
|
||||||
|
if(terminal_row > 0)
|
||||||
|
terminal_row--;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
terminal_memory[(((terminal_row+terminal_jsoffset) * 128) + terminal_col) & 0xFFF] = ch;
|
||||||
|
terminal_advance_cursor();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DELAYED_COPY_CODE(render_terminal_line)(uint16_t line) {
|
||||||
|
uint glyph_line = line & 0x7;
|
||||||
|
const uint8_t *line_buf = (const uint8_t *)terminal_memory + (((line>>3) * 128) & 0xFFF);
|
||||||
|
bool cursor_row = ((((terminal_row+terminal_jsoffset) * 128) & 0xFFF) == (((line>>3) * 128) & 0xFFF));
|
||||||
|
|
||||||
|
struct vga_scanline *sl = vga_prepare_scanline();
|
||||||
|
uint sl_pos = 0;
|
||||||
|
|
||||||
|
// Pad 40 pixels on the left to center horizontally
|
||||||
|
sl->data[sl_pos++] = (text_border|THEN_EXTEND_7) | ((text_border|THEN_EXTEND_7) << 16); // 16 pixels per word
|
||||||
|
sl->data[sl_pos++] = (text_border|THEN_EXTEND_7) | ((text_border|THEN_EXTEND_7) << 16); // 16 pixels per word
|
||||||
|
sl->data[sl_pos++] = (text_border|THEN_EXTEND_3) | ((text_border|THEN_EXTEND_3) << 16); // 8 pixels per word
|
||||||
|
|
||||||
|
for(uint col=0; col < 80; ) {
|
||||||
|
// Grab 14 pixels from the next two characters
|
||||||
|
uint32_t bits_a = char_terminal_bits(line_buf[col], glyph_line) ^ ((cursor_row && (col==terminal_col)) ? text_flasher_mask : 0x00);
|
||||||
|
col++;
|
||||||
|
uint32_t bits_b = char_terminal_bits(line_buf[col], glyph_line) ^ ((cursor_row && (col==terminal_col)) ? text_flasher_mask : 0x00);
|
||||||
|
col++;
|
||||||
|
|
||||||
|
uint32_t bits = (bits_a << 7) | bits_b;
|
||||||
|
|
||||||
|
// Translate each pair of bits into a pair of pixels
|
||||||
|
for(int i=0; i < 7; i++) {
|
||||||
|
uint32_t pixeldata = (bits & 0x2000) ? (text_fore) : (text_back);
|
||||||
|
pixeldata |= (bits & 0x1000) ?
|
||||||
|
(((uint32_t)text_fore) << 16) :
|
||||||
|
(((uint32_t)text_back) << 16);
|
||||||
|
bits <<= 2;
|
||||||
|
|
||||||
|
sl->data[sl_pos] = pixeldata;
|
||||||
|
sl_pos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pad 40 pixels on the right to center horizontally
|
||||||
|
sl->data[sl_pos++] = (text_border|THEN_EXTEND_7) | ((text_border|THEN_EXTEND_7) << 16); // 16 pixels per word
|
||||||
|
sl->data[sl_pos++] = (text_border|THEN_EXTEND_7) | ((text_border|THEN_EXTEND_7) << 16); // 16 pixels per word
|
||||||
|
sl->data[sl_pos++] = (text_border|THEN_EXTEND_3) | ((text_border|THEN_EXTEND_3) << 16); // 8 pixels per word
|
||||||
|
|
||||||
|
sl->length = sl_pos;
|
||||||
|
sl->repeat_count = 1;
|
||||||
|
vga_submit_scanline(sl);
|
||||||
|
}
|
||||||
|
|
||||||
void DELAYED_COPY_CODE(render_terminal)() {
|
void DELAYED_COPY_CODE(render_terminal)() {
|
||||||
for(int line=0; line < 24; line++) {
|
for(uint line=0; line < 192; line++) {
|
||||||
render_terminal_line(line);
|
render_terminal_line((terminal_jsoffset<<3)+line+terminal_ssoffset);
|
||||||
}
|
}
|
||||||
}
|
if(terminal_ssoffset > 0) {
|
||||||
|
terminal_ssoffset++;
|
||||||
|
if(terminal_ssoffset >= 8) {
|
||||||
void DELAYED_COPY_CODE(render_terminal_line)(unsigned int line) {
|
terminal_ssoffset = 0;
|
||||||
const uint8_t *page = (const uint8_t *)terminal_memory;
|
terminal_jsoffset++;
|
||||||
const uint8_t *line_buf = page + (line * 80);
|
|
||||||
|
|
||||||
for(uint glyph_line=0; glyph_line < 8; glyph_line++) {
|
|
||||||
struct vga_scanline *sl = vga_prepare_scanline();
|
|
||||||
uint sl_pos = 0;
|
|
||||||
|
|
||||||
// Pad 40 pixels on the left to center horizontally
|
|
||||||
sl->data[sl_pos++] = (text_border|THEN_EXTEND_7) | ((text_border|THEN_EXTEND_7) << 16); // 16 pixels per word
|
|
||||||
sl->data[sl_pos++] = (text_border|THEN_EXTEND_7) | ((text_border|THEN_EXTEND_7) << 16); // 16 pixels per word
|
|
||||||
sl->data[sl_pos++] = (text_border|THEN_EXTEND_3) | ((text_border|THEN_EXTEND_3) << 16); // 16 pixels per word
|
|
||||||
|
|
||||||
for(uint col=0; col < 80; ) {
|
|
||||||
// Grab 14 pixels from the next two characters
|
|
||||||
uint32_t bits_a = char_terminal_bits(line_buf[col], glyph_line);
|
|
||||||
col++;
|
|
||||||
uint32_t bits_b = char_terminal_bits(line_buf[col], glyph_line);
|
|
||||||
col++;
|
|
||||||
|
|
||||||
uint32_t bits = (bits_a << 7) | bits_b;
|
|
||||||
|
|
||||||
// Translate each pair of bits into a pair of pixels
|
|
||||||
for(int i=0; i < 7; i++) {
|
|
||||||
uint32_t pixeldata = (bits & 0x2000) ? (text_fore) : (text_back);
|
|
||||||
pixeldata |= (bits & 0x1000) ?
|
|
||||||
(((uint32_t)text_fore) << 16) :
|
|
||||||
(((uint32_t)text_back) << 16);
|
|
||||||
bits <<= 2;
|
|
||||||
|
|
||||||
sl->data[sl_pos] = pixeldata;
|
|
||||||
sl_pos++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pad 40 pixels on the right to center horizontally
|
|
||||||
sl->data[sl_pos++] = (text_border|THEN_EXTEND_7) | ((text_border|THEN_EXTEND_7) << 16); // 16 pixels per word
|
|
||||||
sl->data[sl_pos++] = (text_border|THEN_EXTEND_7) | ((text_border|THEN_EXTEND_7) << 16); // 16 pixels per word
|
|
||||||
sl->data[sl_pos++] = (text_border|THEN_EXTEND_3) | ((text_border|THEN_EXTEND_3) << 16); // 16 pixels per word
|
|
||||||
|
|
||||||
sl->length = sl_pos;
|
|
||||||
sl->repeat_count = 1;
|
|
||||||
vga_submit_scanline(sl);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,10 @@ volatile uint32_t mono_palette = 0;
|
||||||
uint8_t __attribute__((section(".uninitialized_data."))) character_rom[4096];
|
uint8_t __attribute__((section(".uninitialized_data."))) character_rom[4096];
|
||||||
uint8_t __attribute__((section(".uninitialized_data."))) terminal_character_rom[4096];
|
uint8_t __attribute__((section(".uninitialized_data."))) terminal_character_rom[4096];
|
||||||
|
|
||||||
|
uint8_t __attribute__((section(".uninitialized_data."))) terminal_fifo[256];
|
||||||
|
uint8_t terminal_fifo_wrptr = 0;
|
||||||
|
uint8_t terminal_fifo_rdptr = 0;
|
||||||
|
|
||||||
volatile uint8_t terminal_row = 0;
|
volatile uint8_t terminal_row = 0;
|
||||||
volatile uint8_t terminal_col = 0;
|
volatile uint8_t terminal_col = 0;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
extern uint8_t character_rom[4096];
|
extern uint8_t character_rom[4096];
|
||||||
extern uint8_t terminal_character_rom[4096];
|
extern uint8_t terminal_character_rom[4096];
|
||||||
|
|
||||||
|
extern uint8_t terminal_fifo[256];
|
||||||
|
extern uint8_t terminal_fifo_wrptr;
|
||||||
|
extern uint8_t terminal_fifo_rdptr;
|
||||||
|
|
||||||
extern volatile uint8_t terminal_row;
|
extern volatile uint8_t terminal_row;
|
||||||
extern volatile uint8_t terminal_col;
|
extern volatile uint8_t terminal_col;
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,8 @@ struct vga_scanline * DELAYED_COPY_CODE(vga_prepare_scanline)() {
|
||||||
|
|
||||||
// Wait for the scanline buffer to become available again
|
// Wait for the scanline buffer to become available again
|
||||||
while(scanline->_flags & FLAG_BUSY)
|
while(scanline->_flags & FLAG_BUSY)
|
||||||
tight_loop_contents();
|
terminal_process_input();
|
||||||
|
//tight_loop_contents();
|
||||||
|
|
||||||
// Reinitialize the scanline struct for reuse
|
// Reinitialize the scanline struct for reuse
|
||||||
scanline->length = 0;
|
scanline->length = 0;
|
||||||
|
|
14
vga/vgaout.h
14
vga/vgaout.h
|
@ -41,10 +41,12 @@ struct vga_scanline {
|
||||||
uint32_t data[(VGA_WIDTH/2)+8];
|
uint32_t data[(VGA_WIDTH/2)+8];
|
||||||
};
|
};
|
||||||
|
|
||||||
void vga_prepare_frame();
|
extern void vga_prepare_frame();
|
||||||
struct vga_scanline *vga_prepare_scanline();
|
extern struct vga_scanline *vga_prepare_scanline();
|
||||||
void vga_submit_scanline(struct vga_scanline *scanline);
|
extern void vga_submit_scanline(struct vga_scanline *scanline);
|
||||||
|
|
||||||
void vga_stop();
|
extern void vga_stop();
|
||||||
void vga_dpms_sleep();
|
extern void vga_dpms_sleep();
|
||||||
void vga_dpms_wake();
|
extern void vga_dpms_wake();
|
||||||
|
|
||||||
|
extern void terminal_process_input();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user