mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[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:
@@ -21,25 +21,10 @@ void quit() {
|
||||
}
|
||||
|
||||
void draw() {
|
||||
// copy framebuffer
|
||||
const short unsigned int * ptr = (const short unsigned int *) Ion::Simulator::Framebuffer::address();
|
||||
Gc * gcptr = get_gc();
|
||||
for (int j = 0; j < LCD_HEIGHT_PX; ++j) {
|
||||
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();
|
||||
unsigned short * ionFramebuffer = (unsigned short *) Ion::Simulator::Framebuffer::address();
|
||||
// we specify the screen fmt here because the "native" fmt varies between calculator revisions
|
||||
// some default to a 240x320 specification, which results in a 90-degree framebuffer rotation and other terribleness.
|
||||
lcd_blit(ionFramebuffer,SCR_320x240_565);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -617,7 +617,7 @@ void statusline(int mode){
|
||||
#include "k_defs.h"
|
||||
|
||||
void sdk_init(void){
|
||||
lcd_init(lcd_type()); // clrscr();
|
||||
lcd_init(lcd_type());
|
||||
}
|
||||
|
||||
void sdk_end(void){
|
||||
@@ -993,6 +993,7 @@ int nspire_shift=0;
|
||||
int nspire_ctrl=0;
|
||||
int nspire_select=false;
|
||||
void statusline(int mode){
|
||||
return; //this is broken for our purposes and it honestly doesn't matter enough to fix.
|
||||
char *msg=0;
|
||||
if (nspire_ctrl){
|
||||
if (nspire_shift)
|
||||
|
||||
@@ -261,6 +261,9 @@ State scan() {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
if (isKeyPressed(KEY_NSPIRE_TENX)){
|
||||
exit(0);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 main() {
|
||||
sdk_init();
|
||||
sdk_init(); //this calls the lcd init functions from behind the scenes
|
||||
Ion::Simulator::Main::init();
|
||||
ion_main(0, NULL);
|
||||
Ion::Simulator::Main::quit();
|
||||
@@ -63,35 +63,6 @@ void 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();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@ void quit();
|
||||
void setNeedsRefresh();
|
||||
void refresh();
|
||||
|
||||
void runPowerOffSafe(void (*powerOffSafeFunction)(), bool prepareVRAM);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,12 +11,16 @@ void powerOff(void){
|
||||
namespace Ion {
|
||||
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) {
|
||||
Simulator::Main::runPowerOffSafe(powerOff, true);
|
||||
// Simulator::Main::runPowerOffSafe(powerOff, true);
|
||||
}
|
||||
|
||||
void standby() {
|
||||
Simulator::Main::runPowerOffSafe(powerOff, true);
|
||||
// Simulator::Main::runPowerOffSafe(powerOff, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user