Skip to content

Commit 4fe5dba

Browse files
committed
v0.80.0 | 2023/12/21 21:35 | Attempted to get file access to work, while it seems to work on Windows it will eat a quarter of the screen at a time on the Ti84CE. Also optimized the graphics routines for fillRect and fillHoriz.
1 parent 1b23d77 commit 4fe5dba

File tree

25 files changed

+1953
-398
lines changed

25 files changed

+1953
-398
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ add_executable(${PROJECT_NAME} ${SRC_FILES})
3131
target_include_directories(${PROJECT_NAME} PUBLIC ${SRC_LCD_DIR})
3232
# Compiler Flags Debug(-g -O0) Release(-O3)
3333
set(OPT_FLAG -O3)
34-
target_compile_options(${PROJECT_NAME} PUBLIC ${OPT_FLAG} -Wall)
34+
target_compile_options(${PROJECT_NAME} PUBLIC ${OPT_FLAG} -Wall -Wextra -Werror)
3535
target_link_libraries(${PROJECT_NAME} PUBLIC SDL2 SDL2main)

src-lcd/x86_Common_Def.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
#include <stdbool.h>
1919
#include <time.h>
2020

21+
/* Platform */
22+
23+
#define PLATFORM_WINDOWS
24+
//#define PLATFORM_LINUX
2125

2226
typedef uint32_t uint24_t;
2327
typedef int32_t int24_t;

src-lcd/x86_Render.c

Lines changed: 1 addition & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -123,32 +123,6 @@ uint16_t paletteRAM[256];
123123
volatile uint16_t _videoMode = 0x92D;
124124
volatile uint16_t* videoMode = &_videoMode;
125125

126-
// uint32_t _LCDTiming0 = 0x1F0A0338;
127-
// uint32_t* LCDTiming0 = &_LCDTiming0;
128-
// uint32_t _LCDTiming1 = 0x0402093F;
129-
// uint32_t* LCDTiming1 = &_LCDTiming1;
130-
// uint32_t _LCDTiming2 = 0x00EF7802;
131-
// uint32_t* LCDTiming2 = &_LCDTiming2;
132-
// uint32_t _LCDTiming3 = 0x00000000;
133-
// uint32_t* LCDTiming3 = &_LCDTiming3;
134-
135-
// uint32_t _lcd_CrsrImage;
136-
// uint32_t* lcd_CrsrImage = &_lcd_CrsrImage;
137-
// uint32_t _lcd_CrsrCtrl;
138-
// uint32_t* lcd_CrsrCtrl = &_lcd_CrsrCtrl;
139-
// uint32_t _lcd_CrsrConfig;
140-
// uint32_t* lcd_CrsrConfig = &_lcd_CrsrConfig;
141-
// uint32_t _lcd_CrsrPalette0;
142-
// uint32_t* lcd_CrsrPalette0 = &_lcd_CrsrPalette0;
143-
// uint32_t _lcd_CrsrPalette1;
144-
// uint32_t* lcd_CrsrPalette1 = &_lcd_CrsrPalette1;
145-
// uint32_t _lcd_CrsrXY;
146-
// uint32_t* const lcd_CrsrXY = &_lcd_CrsrXY;
147-
// uint16_t* lcd_CrsrX = (uint16_t*)lcd_CrsrXY;
148-
// uint16_t* lcd_CrsrY = (uint16_t*)((uint8_t*)lcd_CrsrXY + 2);
149-
// uint32_t _lcd_CrsrClip;
150-
// uint32_t* lcd_CrsrClip = &_lcd_CrsrClip;
151-
152126
/* Pointers */
153127

154128
SDL_Event* grab_SDL2_event() {
@@ -349,53 +323,6 @@ void internal_kb_Scan() {
349323
}
350324
}
351325

352-
void panFrame() {
353-
lcd_UpBase = 0xD00000 | (lcd_UpBase & 0x7FFF8);
354-
uint32_t lcdBase = lcd_UpBase;
355-
if (lcdBase > 0xD65800 || lcdBase < 0xD40000 - (LCD_RESX * LCD_RESY)) {
356-
memset(videoCopy,0,153600);
357-
return;
358-
}
359-
if (lcdBase == 0xD40000) { //Fast Case
360-
memcpy(videoCopy,_VRAM,153600);
361-
} else if (lcdBase < 0xD40000) { //Above
362-
u32 dif = 0xD40000 - lcdBase;
363-
memset(videoCopy,0,dif);
364-
for (u32 r = 0; r < 153600 - dif; r++) {
365-
if (r + dif >= 0 && r + dif < 153600 - 1) {
366-
videoCopy[r + dif] = _VRAM[r];
367-
} else {
368-
videoCopy[r + dif] = 0x00;
369-
}
370-
}
371-
} else if (lcdBase > 0xD40000) { //Below
372-
u32 dif = lcdBase - 0xD40000;
373-
for (u32 r = 0; r < 153600 - dif; r++) {
374-
if (r + dif >= 0 && r + dif < 153600 - 1) {
375-
videoCopy[r] = _VRAM[r + dif];
376-
} else {
377-
videoCopy[r] = 0x00;
378-
}
379-
}
380-
memset(&videoCopy[153600 - dif],0,dif);
381-
}
382-
}
383-
384-
void outputVRAM() {
385-
if (SDL_PollEvent(&event) && event.type == SDL_QUIT) {
386-
exit(0);
387-
}
388-
389-
//printf("%X,%X,%X\n",*frameBase,0xD40000,dif); fflush(stdout);
390-
panFrame();
391-
392-
memcpy(color16,lcd_Palette,256 * sizeof(uint16_t));
393-
memcpy(paletteRAM,lcd_Palette,256 * sizeof(uint16_t));
394-
395-
displayFrame();
396-
}
397-
398-
//#define videoCopyArray uint8_t c = ((uint8_t*)VRAM)[z]
399326
#define videoCopyArray uint8_t c = videoCopy[z]
400327

401328
void blit16bpp(uint8_t* data) {
@@ -649,8 +576,7 @@ void copyFrame(uint8_t* data) {
649576
copyAmount = (LCD_RESX * LCD_RESY) * 2;
650577
};
651578

652-
lcd_UpBase = 0xD00000 | (lcd_UpBase & 0x7FFF8);
653-
memcpy(videoCopy,((uint8_t*)&simulated_ram[lcd_UpBase]),copyAmount);
579+
memcpy(videoCopy,((uint8_t*)&simulated_ram[0xD00000 | (lcd_UpBase & 0x7FFF8)]),copyAmount);
654580
if (lcd_VideoMode & 0x100) {
655581
//Converts 1555 to 888 Color
656582
for (uint32_t i = 0; i < 256; i++) {
@@ -729,52 +655,12 @@ void copyFrame(uint8_t* data) {
729655
}
730656
}
731657

732-
733-
734-
void displayFrame() {
735-
// if (SDL_PollEvent(&event) && event.type == SDL_QUIT) {
736-
// terminateLCDcontroller();
737-
// exit(0);
738-
// }
739-
740-
// uint8_t *frame = NULL;
741-
742-
// SDL_LockTexture(buffer,NULL,(void **) &frame,&pitch);
743-
744-
// copyFrame(frame);
745-
746-
// SDL_UnlockTexture(buffer);
747-
// SDL_RenderCopy(renderer, buffer, NULL, NULL);
748-
749-
// SDL_RenderPresent(renderer);
750-
}
751-
752658
/*
753659
** ===========
754660
** Modern Code
755661
** ===========
756662
*/
757663

758-
fp64 DeltaTime = (1.0 / 60.0);
759-
760-
const uint8_t color_square_divider = 2;
761-
762-
void renderTestGraphic(fp64 cycleSpeed, fp64 minSpeed, fp64 maxSpeed) {
763-
static fp64 f = 0.0;
764-
fp64 halfDiff = (maxSpeed - minSpeed) / 2.0;
765-
fp64 speed = halfDiff * sin(cycleSpeed * TAU * getDecimalTime()) + minSpeed + halfDiff;
766-
f += DeltaTime * speed;
767-
uint32_t w = (uint32_t)(f * (256.0));
768-
size_t z = 0;
769-
for (uint32_t y = 0; y < Master.resY; y++) {
770-
for (uint32_t x = 0; x < Master.resX; x++) {
771-
Master.vram[z] = (x - w) % 256; Master.vram[z] /= color_square_divider; z++;
772-
Master.vram[z] = (w - y) % 256; Master.vram[z] /= color_square_divider; z++;
773-
Master.vram[z] = (w + x + y) % 256; Master.vram[z] /= color_square_divider; z++;
774-
}
775-
}
776-
}
777-
778664
int terminateLCDcontroller() {
779665
SDL_DestroyRenderer(renderer);
780666
SDL_DestroyWindow(window);
@@ -789,9 +675,6 @@ void initLCDcontroller() {
789675
Master.pitch = Master.resX * 3;
790676
Master.vram = calloc((size_t)Master.resY * Master.pitch, sizeof(uint8_t));
791677
if (Master.vram == NULL) { printf("\nMaster.vram is NULL"); fflush(stdout); return; }
792-
// for (size_t z = 0; z < (size_t)Master.resY * Master.pitch; z++) {
793-
// Master.vram[z] = (uint8_t)((((z * 7) ^ z) + z) & 0xFF);
794-
// }
795678
SDL_Init(SDL_INIT_VIDEO);
796679
window = SDL_CreateWindow("Endless-Super-Sweeper", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, LCD_RESX * scale, LCD_RESY * scale,0);
797680
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
@@ -806,7 +689,6 @@ void newFrame() {
806689
terminateLCDcontroller();
807690
exit(0);
808691
}
809-
//renderTestGraphic(0.5,0.3,0.8);
810692
copyFrame(Master.vram);
811693
SDL_UpdateTexture(texture, NULL, Master.vram, Master.pitch);
812694
{

src-lcd/x86_Render.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,11 @@ void internal_kb_Scan();
1717

1818
void newFrame(); // Outputs the current vram
1919

20-
// void setKey(uint8_t k);
21-
// void resetKey(uint8_t k);
22-
23-
// void panFrame();
24-
25-
void outputVRAM();
26-
2720
void blit16bpp(uint8_t* data);
2821
void blit8bpp(uint8_t* data);
2922
void blit4bpp(uint8_t* data);
3023

3124
void copyFrame(uint8_t* data);
32-
void displayFrame();
3325

3426
extern uint8_t darkMode;
3527

0 commit comments

Comments
 (0)