Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define USE_TI89
- #define SAVE_SCREEN
- #include <tigcclib.h>
- #include "extgraph.h" // Made by TICT. Thank you TICT HQ and Lionel Debroux :)
- SYM_ENTRY* openBinVAT(char *varName) { // Quicker file reader than default fopen. Thanks Lionel
- SYM_ENTRY *symptr = DerefSym(SymFind(SYMSTR(varName)));
- if (!symptr) {
- printf("%s not found\n", varName);
- ngetchx();
- }
- return symptr;
- }
- #define TOTAL_STR 12
- volatile unsigned char x0 = 0, x1 = 0, y0 = 0, currentColor = 0, lastByte = 0, currentFile = 0; // Initialize vars for writing
- volatile unsigned int intCount = 0, i = 2;
- unsigned char* datas[TOTAL_STR];
- unsigned int dataLengths[TOTAL_STR];
- INT_HANDLER oldInt5 = NULL;
- DEFINE_INT_HANDLER(DrawFrameInt) {
- intCount++;
- if(intCount < 26) { // ~12 hz
- return;
- }
- intCount = 0;
- SetIntVec(AUTO_INT_5, NULL); // Disable interrupt (is this bad?), goal: prevent from interrupting itself (???)
- unsigned short *data = datas[currentFile];
- unsigned int dataLength = dataLengths[currentFile];
- while(i < dataLength) { // Draw a frame (essentially copied from for loop, with breaks instead of wait for frame)
- unsigned char nextByte = data[i];
- if (y0 == LCD_HEIGHT) {
- y0 = 0;
- x0 = 0;
- x1 = 0;
- currentColor = 0;
- i++;
- break;
- }
- unsigned char newColor = !currentColor; // Defined here so it doesnt have to be recalculated.
- if (nextByte == 255 || (lastByte < LCD_WIDTH && nextByte < lastByte)) { // New horizontal line? Then finish the previous row.
- FastDrawHLine_R(LCD_MEM, x0, LCD_WIDTH - 1, y0, newColor);
- x0 = 0;
- y0++;
- x1 = 0;
- }
- if (nextByte < LCD_WIDTH) { // This is the normal line draw. Majority
- x1 = nextByte;
- FastDrawHLine_R(LCD_MEM, x0, x1, y0, newColor);
- currentColor = newColor;
- x0 = x1;
- } else if (nextByte == 254) { // This is if the frame has not changed. Just wait.
- i++;
- break;
- } else if (nextByte == 253) { // Draw a full black screen, and wait
- unsigned char j;
- for (j = 0; j < LCD_HEIGHT; j++) {
- FastDrawHLine_R(LCD_MEM, 0, LCD_WIDTH - 1, j, 1);
- }
- i++;
- break;
- } else if (nextByte == 252) { // Draw an empty frame, wait
- ClrScr();
- i++;
- break;
- }
- lastByte = nextByte;
- i++;
- }
- SetIntVec(AUTO_INT_5, DrawFrameInt); // Re enable interrupt
- return;
- }
- void _main(void) {
- const char *VARNAME_STRS[] = {"ba\\px1","ba\\px2","ba\\px3","ba\\px4","ba\\px5","ba\\px6","ba\\px7","ba\\px8","ba\\px9","ba\\px10","ba\\px11","ba\\px12",};
- SYM_ENTRY *symPtrs[TOTAL_STR];
- int fileI;
- for(fileI = 0; fileI < TOTAL_STR; fileI++) {
- symPtrs[fileI] = openBinVAT(VARNAME_STRS[fileI]); // Define the data using the vat
- unsigned char* data = HLock(symPtrs[fileI]->handle);
- data+=2;
- datas[fileI] = data;
- unsigned int dataLength = 0; // Define the length of the data
- memcpy(&dataLength, data, sizeof(unsigned int));
- dataLengths[fileI] = dataLength;
- }
- ClrScr(); // Initial setup
- PRG_setRate(0);
- oldInt5 = GetIntVec(AUTO_INT_5);
- SetIntVec(AUTO_INT_5, DrawFrameInt);
- // TODO: set APD interrupt to null temporarily (???)
- while (!kbhit()); // Wait for video to end (or input in this case) (temporary, for testing)
- GKeyFlush();
- SetIntVec (AUTO_INT_5, oldInt5); // Restore the program
- for(fileI = 0; fileI < TOTAL_STR; fileI++) {
- HeapUnlock(symPtrs[fileI]->handle);
- }
- PRG_setRate(1);
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement