Compare commits

...

5 Commits

Author SHA1 Message Date
David Kuder 6d83fc50eb Status line tweaks
Fix border size
2023-04-25 16:23:44 -04:00
David Kuder 08ba4e7911 Unified mono_rendering flag
In preparation for Video7 monochrome mode, add unified flag for mono rendering
2023-04-25 16:20:29 -04:00
David Kuder 9727add223 AGS performace tweaks and bugfixes
Bypass legacy 80 column card when in SHR rendering mode
Mask unused palette bits that were causing VGA PIO to fail
Fixed color calculation for AGS hardware
2023-04-25 16:19:28 -04:00
David Kuder 0fa9fe4538 businterface performance tweaks and bugfixes for AGS 2023-04-25 16:16:03 -04:00
David Kuder 1b8a30ac1e Fix for AGS register corruption 2023-04-25 16:15:20 -04:00
12 changed files with 72 additions and 46 deletions

View File

@ -3,9 +3,9 @@
void abus_init();
#define CARD_SELECT ((value & (1u << CONFIG_PIN_APPLEBUS_DEVSEL-CONFIG_PIN_APPLEBUS_DATA_BASE)) == 0)
#define CARD_DEVSEL ((address & 0xcf80) == 0xc080)
#define CARD_IOSEL (((address & 0xcf00) >= 0xc100) && ((address & 0xcf00) < 0xc700))
#define CARD_IOSTROBE ((address & 0xc800) == 0xc800)
#define CARD_DEVSEL ((address & 0xff80) == 0xc080)
#define CARD_IOSEL (((address & 0xff00) >= 0xc100) && ((address & 0xff00) < 0xc700))
#define CARD_IOSTROBE ((address & 0xf800) == 0xc800)
enum {
ABUS_MAIN_SM = 0,

View File

@ -8,6 +8,40 @@
volatile uint8_t *terminal_page = terminal_memory;
void __time_critical_func(vga_businterface)(uint32_t address, uint32_t value) {
// Shadow parts of the Apple's memory by observing the bus write cycles
if((address < 0xC000) && ((value & (1u << CONFIG_PIN_APPLEBUS_RW-CONFIG_PIN_APPLEBUS_DATA_BASE)) == 0)) {
// Apple IIgs: CARD_SELECT is pulled low by our CPLD when M2B0 is active and addr < $C000
#ifdef ANALOG_GS
if(CARD_SELECT) {
private_memory[address] = value & 0xff;
return;
}
#endif
// Mirror Video Memory from MAIN & AUX banks
if(soft_switches & SOFTSW_80STORE) {
if(soft_switches & SOFTSW_PAGE_2) {
if((address >= 0x400) && (address < 0x800)) {
private_memory[address] = value & 0xff;
return;
} else if((soft_switches & SOFTSW_HIRES_MODE) && (address >= 0x2000) && (address < 0x4000)) {
private_memory[address] = value & 0xff;
return;
}
}
} else if(soft_switches & SOFTSW_AUX_WRITE) {
if((address >= 0x200) && (address < 0xC000)) {
private_memory[address] = value & 0xff;
return;
}
}
if((address >= 0x200) && (address < 0xC000)) {
apple_memory[address] = value & 0xff;
return;
}
}
// Shadow the soft-switches by observing all read & write bus cycles
if((address & 0xff80) == 0xc000) {
switch(address & 0x7f) {
@ -176,38 +210,8 @@ void __time_critical_func(vga_businterface)(uint32_t address, uint32_t value) {
}
}
// Shadow parts of the Apple's memory by observing the bus write cycles
// Card Registers
if((value & (1u << CONFIG_PIN_APPLEBUS_RW-CONFIG_PIN_APPLEBUS_DATA_BASE)) == 0) {
// Mirror Video Memory from MAIN & AUX banks
if(soft_switches & SOFTSW_LINEARIZE) {
if((address >= 0x2000) && (address < 0xC000)) {
private_memory[address] = value & 0xff;
return;
}
}
if(soft_switches & SOFTSW_80STORE) {
if(soft_switches & SOFTSW_PAGE_2) {
if((address >= 0x400) && (address < 0x800)) {
private_memory[address] = value & 0xff;
return;
} else if((soft_switches & SOFTSW_HIRES_MODE) && (address >= 0x2000) && (address < 0x4000)) {
private_memory[address] = value & 0xff;
return;
}
}
} else if(soft_switches & SOFTSW_AUX_WRITE) {
if((address >= 0x200) && (address < 0xC000)) {
private_memory[address] = value & 0xff;
return;
}
}
if((address >= 0x200) && (address < 0xC000)) {
apple_memory[address] = value & 0xff;
return;
}
if(CARD_SELECT && CARD_DEVSEL) {
cardslot = (address >> 4) & 0x7;
switch(address & 0x0F) {

View File

@ -14,6 +14,7 @@ uint16_t text_border;
compat_t machinefont = MACHINE_INVALID;
bool userfont = false;
bool mono_rendering = false;
uint16_t DELAYED_COPY_DATA(mono_colors)[14] = {
_RGB(0x00, 0x00, 0x00), _RGB(0xFF, 0xFF, 0xFF), // White Normal
@ -196,6 +197,8 @@ void DELAYED_COPY_CODE(render_loop)() {
text_back = mono_colors[palette*2];
text_border = (palette == 0x6) ? text_fore : text_back;
}
mono_rendering = ((soft_switches & SOFTSW_MONOCHROME) || (mono_palette & 0x8));
if(internal_flags & IFLAGS_TEST) {
render_testpattern();
@ -216,10 +219,9 @@ void DELAYED_COPY_CODE(render_loop)() {
} else {
vga_prepare_frame();
render_border(24);
render_border(16);
if(status_line[0] != 0) {
render_status_line();
render_border(16);
} else {
render_border(32);
}

View File

@ -8,6 +8,7 @@
extern uint16_t lores_palette[16];
extern uint16_t text_fore, text_back, text_border;
extern uint8_t status_line[81];
extern bool mono_rendering;
extern void terminal_clear_screen();
@ -53,9 +54,9 @@ extern void vga_deinit();
#ifdef ANALOG_GS
#define _RGB(r, g, b) ( \
(((((uint)(r) * 256 / 18) + 256) / 256) << 8) | \
(((((uint)(g) * 256 / 18) + 256) / 256) << 4) | \
((((uint)(b) * 256 / 18) + 256) / 256) \
(((((uint)(r) * 256 / 18) + 255) / 256) << 8) | \
(((((uint)(g) * 256 / 18) + 255) / 256) << 4) | \
((((uint)(b) * 256 / 18) + 255) / 256) \
)
#define _RGBHALF 0x777
#else

View File

@ -65,7 +65,7 @@ static void DELAYED_COPY_CODE(render_dgr_line)(bool p2, uint line) {
sl_pos++;
i = 0;
if((soft_switches & SOFTSW_MONOCHROME) || (mono_palette & 0x8)) {
if(mono_rendering) {
while(i < 40) {
while((dotc <= 18) && (i < 40)) {
color1 |= dgr_dot_pattern[((i & 1) << 4) | (line_bufb[i] & 0xf)] << dotc;

View File

@ -65,7 +65,7 @@ static void DELAYED_COPY_CODE(render_dhgr_line)(bool p2, uint line) {
uint32_t pixeldata;
i = 0;
if((soft_switches & SOFTSW_MONOCHROME) || (mono_palette & 0x8)) {
if(mono_rendering) {
while(i < 40) {
// Load in as many subpixels as possible
while((dotc < 28) && (i < 40)) {

View File

@ -55,7 +55,7 @@ static void DELAYED_COPY_CODE(render_hires_line)(bool p2, uint line) {
uint32_t pixeldata;
uint i;
if((soft_switches & SOFTSW_MONOCHROME) || (mono_palette & 0x8)) {
if(mono_rendering) {
while(i < 40) {
// Load in as many subpixels as possible
while((dotc < 18) && (i < 40)) {

View File

@ -79,7 +79,7 @@ static void DELAYED_COPY_CODE(render_lores_line)(bool p2, uint line) {
sl2->data[sl_pos] = (text_border|THEN_EXTEND_3) | ((text_border|THEN_EXTEND_3) << 16); // 8 pixels per word
sl_pos++;
if((soft_switches & SOFTSW_MONOCHROME) || (mono_palette & 0x8)) {
if(mono_rendering) {
for(i = 0; i < 40; i+=2) {
color1 = lores_dot_pattern[line_buf[i] & 0xf] << 14;
color2 = lores_dot_pattern[(line_buf[i] >> 4) & 0xf] << 14;

View File

@ -9,7 +9,7 @@
static void render_shr_line(uint16_t line);
#ifdef ANALOG_GS
#define rgb444(a) (a)
#define rgb444(a) (a & 0xFFF)
#else
static inline uint16_t rgb444(uint16_t a) {
return ((a & 0xe00) >> 3) | ((a & 0xe0) >> 2) | ((a & 0xe) >> 1);
@ -27,7 +27,7 @@ void DELAYED_COPY_CODE(render_shr)() {
}
static void DELAYED_COPY_CODE(render_shr_line)(uint16_t line) {
struct vga_scanline *sl = vga_prepare_scanline();
struct vga_scanline *sl = vga_prepare_scanline_quick();
uint sl_pos = 0;
uint i;

View File

@ -140,7 +140,7 @@ void DELAYED_COPY_CODE(render_testpattern)() {
}
void DELAYED_COPY_CODE(render_status_line)() {
for(uint glyph_line=0; glyph_line < 8; glyph_line++) {
for(uint glyph_line=0; glyph_line < 16; glyph_line++) {
struct vga_scanline *sl = vga_prepare_scanline();
uint8_t *line_buf = status_line;
uint32_t bits;

View File

@ -249,6 +249,24 @@ struct vga_scanline * DELAYED_COPY_CODE(vga_prepare_scanline)() {
return scanline;
}
// Set up and return a new display scanline
struct vga_scanline * DELAYED_COPY_CODE(vga_prepare_scanline_quick)() {
struct vga_scanline *scanline = &scanline_queue[scanline_queue_head];
// Wait for the scanline buffer to become available again
while(scanline->_flags & FLAG_BUSY)
tight_loop_contents();
// Reinitialize the scanline struct for reuse
scanline->length = 0;
scanline->repeat_count = 0;
scanline->_flags = FLAG_BUSY;
scanline->_sync = (uint32_t)THEN_WAIT_HSYNC << 16;
scanline_queue_head = (scanline_queue_head + 1) & (NUM_SCANLINE_BUFFERS-1);
return scanline;
}
// Mark the scanline as ready so it can be displayed
void DELAYED_COPY_CODE(vga_submit_scanline)(struct vga_scanline *scanline) {
spin_lock_t *lock = spin_lock_instance(CONFIG_VGA_SPINLOCK_ID);

View File

@ -43,6 +43,7 @@ struct vga_scanline {
extern void vga_prepare_frame();
extern struct vga_scanline *vga_prepare_scanline();
extern struct vga_scanline *vga_prepare_scanline_quick();
extern void vga_submit_scanline(struct vga_scanline *scanline);
extern void vga_stop();