2023-01-07 07:15:21 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <pico/stdlib.h>
|
|
|
|
#include <hardware/timer.h>
|
|
|
|
#include "common/config.h"
|
|
|
|
#include "vga/vgabuf.h"
|
|
|
|
#include "vga/render.h"
|
|
|
|
#include "vga/character_rom.h"
|
|
|
|
#include "vga/vgaout.h"
|
2023-01-17 01:36:00 +00:00
|
|
|
#include "pico_hal.h"
|
2023-01-07 07:15:21 +00:00
|
|
|
|
|
|
|
uint16_t text_fore;
|
|
|
|
uint16_t text_back;
|
|
|
|
uint16_t text_border;
|
|
|
|
|
2023-01-17 01:36:00 +00:00
|
|
|
compat_t machinefont = APPLE_II;
|
|
|
|
bool userfont = false;
|
|
|
|
|
|
|
|
// Initialize the character generator ROM
|
|
|
|
void switch_font() {
|
|
|
|
switch(machine) {
|
|
|
|
default:
|
|
|
|
case APPLE_II:
|
|
|
|
memcpy(character_rom, default_character_rom, 2048);
|
|
|
|
break;
|
|
|
|
case APPLE_IIE:
|
|
|
|
memcpy(character_rom, appleiie_character_rom, 2048);
|
|
|
|
break;
|
|
|
|
case APPLE_IIGS:
|
|
|
|
memcpy(character_rom, appleiigs_character_rom, 2048);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
machinefont = machine;
|
|
|
|
}
|
|
|
|
|
|
|
|
void load_font() {
|
|
|
|
int file = pico_open("font", LFS_O_RDONLY);
|
|
|
|
int br = 0;
|
|
|
|
|
|
|
|
userfont = false;
|
|
|
|
|
|
|
|
if(file < 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
br = pico_read(file, character_rom, 2048);
|
|
|
|
if(br == 2048) {
|
|
|
|
userfont = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
pico_close(file);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-01-07 07:15:21 +00:00
|
|
|
void render_init() {
|
|
|
|
int i;
|
2023-01-17 01:36:00 +00:00
|
|
|
|
|
|
|
load_font();
|
|
|
|
if(!userfont)
|
|
|
|
switch_font();
|
|
|
|
|
|
|
|
if((soft_switches & SOFTSW_MODE_MASK) == 0)
|
|
|
|
soft_switches |= SOFTSW_TEST;
|
|
|
|
terminal_tbcolor = 0xf0;
|
2023-01-08 05:35:06 +00:00
|
|
|
terminal_border = 0x00;
|
2023-01-07 07:15:21 +00:00
|
|
|
|
|
|
|
render_test_init();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t testdone=0;
|
|
|
|
void __noinline __time_critical_func(render_loop)() {
|
|
|
|
while(v2mode == MODE_VGACARD) {
|
2023-01-17 01:36:00 +00:00
|
|
|
if(!userfont && (machinefont != machine)) {
|
|
|
|
switch_font();
|
|
|
|
}
|
|
|
|
|
2023-01-07 07:15:21 +00:00
|
|
|
update_text_flasher();
|
|
|
|
|
|
|
|
text_fore = lores_palette[TERMINAL_FORE];
|
|
|
|
text_back = lores_palette[TERMINAL_BACK];
|
|
|
|
text_border = lores_palette[TERMINAL_BORDER];
|
|
|
|
|
2023-01-17 01:36:00 +00:00
|
|
|
if(soft_switches & SOFTSW_TEST) {
|
2023-01-07 07:15:21 +00:00
|
|
|
render_testpattern();
|
|
|
|
|
|
|
|
// Automatically dismiss the test pattern when the Apple II initializes
|
|
|
|
// soft switches during startup.
|
|
|
|
if(((soft_switches & SOFTSW_MODE_MASK) != 0) && (testdone == 0)) {
|
2023-01-17 01:36:00 +00:00
|
|
|
soft_switches &= ~SOFTSW_TEST;
|
2023-01-07 07:15:21 +00:00
|
|
|
testdone = 1;
|
|
|
|
render_about_init();
|
|
|
|
}
|
2023-01-17 01:36:00 +00:00
|
|
|
} else if(soft_switches & SOFTSW_VIDEX) {
|
|
|
|
render_videx();
|
|
|
|
} else if(soft_switches & SOFTSW_SHR) {
|
|
|
|
render_shr();
|
2023-01-07 07:15:21 +00:00
|
|
|
} else {
|
|
|
|
switch(soft_switches & SOFTSW_MODE_MASK) {
|
|
|
|
case 0:
|
2023-01-17 01:36:00 +00:00
|
|
|
if(soft_switches & SOFTSW_DGR) {
|
2023-01-07 07:15:21 +00:00
|
|
|
render_dgr();
|
|
|
|
} else {
|
|
|
|
render_lores();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SOFTSW_MIX_MODE:
|
2023-01-17 01:36:00 +00:00
|
|
|
if((soft_switches & (SOFTSW_80COL | SOFTSW_DGR)) == (SOFTSW_80COL | SOFTSW_DGR)) {
|
2023-01-07 07:15:21 +00:00
|
|
|
render_mixed_dgr();
|
|
|
|
} else {
|
|
|
|
render_mixed_lores();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SOFTSW_HIRES_MODE:
|
2023-01-17 01:36:00 +00:00
|
|
|
if(soft_switches & SOFTSW_DGR) {
|
2023-01-07 07:15:21 +00:00
|
|
|
render_dhgr();
|
|
|
|
} else {
|
|
|
|
render_hires();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SOFTSW_HIRES_MODE|SOFTSW_MIX_MODE:
|
2023-01-17 01:36:00 +00:00
|
|
|
if((soft_switches & (SOFTSW_80COL | SOFTSW_DGR)) == (SOFTSW_80COL | SOFTSW_DGR)) {
|
2023-01-07 07:15:21 +00:00
|
|
|
render_mixed_dhgr();
|
|
|
|
} else {
|
|
|
|
render_mixed_hires();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2023-01-17 01:36:00 +00:00
|
|
|
render_text();
|
2023-01-07 07:15:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|