[NSpire Simulator] Fix framebuffer in nspire port (#340)

* Fix the nspire port (ergo: framebuffer functions, shift/ctrl don't corrupt things due to weird draw calls)

* cleanup the k_csdk changes
This commit is contained in:
Luminoso-256
2023-09-15 11:12:05 -05:00
committed by GitHub
parent fd159fe489
commit 0cabec542d
6 changed files with 16 additions and 54 deletions

View File

@@ -21,25 +21,10 @@ void quit() {
} }
void draw() { void draw() {
// copy framebuffer unsigned short * ionFramebuffer = (unsigned short *) Ion::Simulator::Framebuffer::address();
const short unsigned int * ptr = (const short unsigned int *) Ion::Simulator::Framebuffer::address(); // we specify the screen fmt here because the "native" fmt varies between calculator revisions
Gc * gcptr = get_gc(); // some default to a 240x320 specification, which results in a 90-degree framebuffer rotation and other terribleness.
for (int j = 0; j < LCD_HEIGHT_PX; ++j) { lcd_blit(ionFramebuffer,SCR_320x240_565);
for (int i = 0; i < LCD_WIDTH_PX;){
int c = *ptr;
int k = 1;
for (; k+i < LCD_WIDTH_PX; ++k) {
if (ptr[k]!=c) {
break;
}
}
gui_gc_setColor(*gcptr,c_rgb565to888(c));
gui_gc_drawRect(*gcptr,i,j,k-1,0);
ptr += k;
i += k;
}
}
sync_screen();
} }
} }

View File

@@ -617,7 +617,7 @@ void statusline(int mode){
#include "k_defs.h" #include "k_defs.h"
void sdk_init(void){ void sdk_init(void){
lcd_init(lcd_type()); // clrscr(); lcd_init(lcd_type());
} }
void sdk_end(void){ void sdk_end(void){
@@ -993,6 +993,7 @@ int nspire_shift=0;
int nspire_ctrl=0; int nspire_ctrl=0;
int nspire_select=false; int nspire_select=false;
void statusline(int mode){ void statusline(int mode){
return; //this is broken for our purposes and it honestly doesn't matter enough to fix.
char *msg=0; char *msg=0;
if (nspire_ctrl){ if (nspire_ctrl){
if (nspire_shift) if (nspire_shift)

View File

@@ -261,6 +261,9 @@ State scan() {
return state; return state;
} }
} }
if (isKeyPressed(KEY_NSPIRE_TENX)){
exit(0);
}
return state; return state;
} }

View File

@@ -25,7 +25,7 @@ extern "C" {
int calculator=4; // -1 means OS not checked, 0 unknown, 1 cg50 or 90, 2 emu 50 or 90, 3 other int calculator=4; // -1 means OS not checked, 0 unknown, 1 cg50 or 90, 2 emu 50 or 90, 3 other
int main() { int main() {
sdk_init(); sdk_init(); //this calls the lcd init functions from behind the scenes
Ion::Simulator::Main::init(); Ion::Simulator::Main::init();
ion_main(0, NULL); ion_main(0, NULL);
Ion::Simulator::Main::quit(); Ion::Simulator::Main::quit();
@@ -63,35 +63,6 @@ void quit() {
Ion::Simulator::Display::quit(); Ion::Simulator::Display::quit();
} }
void runPowerOffSafe(void (*powerOffSafeFunction)(), bool prepareVRAM) {
// somewhat OFF by setting LCD to 0
unsigned NSPIRE_CONTRAST_ADDR=is_cx2?0x90130014:0x900f0020;
unsigned oldval=*(volatile unsigned *)NSPIRE_CONTRAST_ADDR,oldval2;
if (is_cx2){
oldval2=*(volatile unsigned *) (NSPIRE_CONTRAST_ADDR+4);
*(volatile unsigned *) (NSPIRE_CONTRAST_ADDR+4)=0xffff;
}
*(volatile unsigned *)NSPIRE_CONTRAST_ADDR=is_cx2?0xffff:0x100;
static volatile uint32_t *lcd_controller = (volatile uint32_t*) 0xC0000000;
lcd_controller[6] &= ~(0b1 << 11);
loopsleep(20);
lcd_controller[6] &= ~ 0b1;
unsigned NSPIRE_RTC_ADDR=0x90090000;
unsigned offtime=* (volatile unsigned *) NSPIRE_RTC_ADDR;
for (int n=0;!on_key_pressed();++n){
loopsleep(100);
idle();
}
lcd_controller[6] |= 0b1;
loopsleep(20);
lcd_controller[6]|= 0b1 << 11;
if (is_cx2)
*(volatile unsigned *)(NSPIRE_CONTRAST_ADDR+4)=oldval2;
*(volatile unsigned *)NSPIRE_CONTRAST_ADDR=oldval;
sync_screen();
}
} }
} }
} }

View File

@@ -11,8 +11,6 @@ void quit();
void setNeedsRefresh(); void setNeedsRefresh();
void refresh(); void refresh();
void runPowerOffSafe(void (*powerOffSafeFunction)(), bool prepareVRAM);
} }
} }
} }

View File

@@ -11,12 +11,16 @@ void powerOff(void){
namespace Ion { namespace Ion {
namespace Power { namespace Power {
//NOTE: These should probably be reimplemented at some point
//the prior version was a janky mess that flickered a ton on wake
//and was generally awfulness.
void suspend(bool checkIfOnOffKeyReleased) { void suspend(bool checkIfOnOffKeyReleased) {
Simulator::Main::runPowerOffSafe(powerOff, true); // Simulator::Main::runPowerOffSafe(powerOff, true);
} }
void standby() { void standby() {
Simulator::Main::runPowerOffSafe(powerOff, true); // Simulator::Main::runPowerOffSafe(powerOff, true);
} }
} }