Skip to content

Commit

Permalink
Merge branch 'upsilon-dev' of https://github.com/UpsilonNumworks/Upsilon
Browse files Browse the repository at this point in the history
 into upsilon-dev
  • Loading branch information
Yaya-Cout committed Sep 28, 2023
2 parents a0583aa + 0cabec5 commit 764ff6f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 54 deletions.
23 changes: 4 additions & 19 deletions ion/src/simulator/nspire/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
Expand Down
3 changes: 2 additions & 1 deletion ion/src/simulator/nspire/k_csdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions ion/src/simulator/nspire/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ State scan() {
return state;
}
}
if (isKeyPressed(KEY_NSPIRE_TENX)){
exit(0);
}
return state;
}

Expand Down
31 changes: 1 addition & 30 deletions ion/src/simulator/nspire/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();

}

}
}
}
2 changes: 0 additions & 2 deletions ion/src/simulator/nspire/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ void quit();
void setNeedsRefresh();
void refresh();

void runPowerOffSafe(void (*powerOffSafeFunction)(), bool prepareVRAM);

}
}
}
Expand Down
8 changes: 6 additions & 2 deletions ion/src/simulator/nspire/power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
Expand Down

0 comments on commit 764ff6f

Please sign in to comment.