Compare commits

...

3 Commits
master ... ce

Author SHA1 Message Date
duarteapcoelho eea8550238 CE: enable compression 2022-12-07 22:02:38 +00:00
duarteapcoelho ae6bbc5861 Fix ce/makefile missing 2022-12-07 21:40:07 +00:00
duarteapcoelho ffc5f9d651 Add untested TI-84 Plus CE support 2022-12-07 16:01:42 +00:00
14 changed files with 197 additions and 0 deletions

4
.gitignore vendored
View File

@ -7,6 +7,10 @@ sdl/*
gint/*
!gint/Makefile
ce/*
!ce/makefile
!ce/icon.png
resources/models/models.h
resources/models/models.blend1

View File

@ -8,10 +8,13 @@ prizm: prizm/racing.g3a
gint: gint/racing_singleplayer.g3a
ce: ce/bin/DEMO.8xp
clean:
make $(MFLAGS) -C sdl/ clean
make $(MFLAGS) -C prizm/ clean
make $(MFLAGS) -C gint/ clean
make $(MFLAGS) -C ce/ clean
sdl/racing: $(SOURCES)
make $(MFLAGS) -C sdl/
@ -22,6 +25,9 @@ prizm/racing.g3a: $(SOURCES)
gint/racing_singleplayer.g3a: $(SOURCES)
make $(MFLAGS) -C gint/
ce/bin/DEMO.8xp: $(SOURCES)
make $(MFLAGS) -C ce/
package: release/racing.zip release/racing.tar.gz release/racing_singleplayer.zip release/racing_singleplayer.tar.gz
release/racing.zip: prizm/racing.g3a

BIN
ce/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

17
ce/makefile Normal file
View File

@ -0,0 +1,17 @@
# ----------------------------
# Makefile Options
# ----------------------------
NAME = DEMO
ICON = icon.png
DESCRIPTION = "CE C Toolchain Demo"
COMPRESSED = YES
ARCHIVED = NO
SRCDIR = ../src/
CFLAGS = -Wall -Wextra -Oz -DCE
CXXFLAGS = -Wall -Wextra -Oz -DCE
# ----------------------------
include $(shell cedev-config --makefile)

36
src/display-ce.cpp Normal file
View File

@ -0,0 +1,36 @@
#ifdef CE
#include "display.h"
#include <ti/screen.h>
Color newColor(int r, int g, int b){
return {
.color = uint8_t((g >> 5) | ((b >> 6) << 3) | ((r >> 5) << 5))
};
}
namespace Display {
int textHeight = 0; // TODO
void init(){
gfx_Begin();
os_ClrHome();
gfx_SetDrawBuffer();
}
void clear(Color color){
fillRect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, color);
}
void destroy(){
gfx_End();
}
void show(){
gfx_SwapDraw();
}
int textWidth(const char *text){
return 0; // TODO
}
void drawText(int x, int y, const char *text, Color color){
// TODO
}
};
#endif

21
src/display-ce.h Normal file
View File

@ -0,0 +1,21 @@
#include <graphx.h>
#define DISPLAY_WIDTH GFX_LCD_WIDTH
#define DISPLAY_HEIGHT GFX_LCD_HEIGHT
struct Color {
int r;
int g;
int b;
unsigned char color;
};
namespace Display {
inline void fillRect(int x, int y, int w, int h, Color color){
gfx_SetColor(color.color);
gfx_FillRectangle(x, y, w, h);
}
inline void drawPoint(int x, int y, Color color){
gfx_SetColor(color.color);
gfx_SetPixel(x, y);
}
};

28
src/input-ce.cpp Normal file
View File

@ -0,0 +1,28 @@
#ifdef CE
#include "input.h"
#include "util.h"
#include <keypadc.h>
namespace Input {
uint8_t lastData[7];
uint8_t data[7];
void init(){
}
void _updateKeys(){
kb_Scan();
memcpy(lastData, data, 7*sizeof(uint8_t));
for(int i = 0; i < 7; i++)
data[i] = kb_Data[i];
}
bool keyDown(int key){
if(key == -1)
return false;
return data[key / 8] & (1 << (key % 8));
}
bool keyDownLast(int key){
if(key == -1)
return false;
return lastData[key / 8] & (1 << (key % 8));
}
}
#endif

60
src/input-ce.h Normal file
View File

@ -0,0 +1,60 @@
#define KEY(x, y) (y-1)*8+x
#define KEY_MENU -1
#define KEY_EXIT -1
#define KEY_EXE KEY(0, 6)
#define KEY_AC -1
#define KEY_DEL -1
#define KEY_OPTN -1
#define KEY_VARS -1
#define KEY_0 KEY(0, 3)
#define KEY_1 KEY(1, 3)
#define KEY_2 KEY(1, 4)
#define KEY_3 KEY(1, 5)
#define KEY_4 KEY(2, 3)
#define KEY_5 KEY(2, 4)
#define KEY_6 KEY(2, 5)
#define KEY_7 KEY(3, 3)
#define KEY_8 KEY(3, 4)
#define KEY_9 KEY(3, 5)
#define KEY_A -1
#define KEY_B -1
#define KEY_C -1
#define KEY_D -1
#define KEY_E -1
#define KEY_F -1
#define KEY_G -1
#define KEY_H -1
#define KEY_I -1
#define KEY_J -1
#define KEY_K -1
#define KEY_L -1
#define KEY_M -1
#define KEY_N -1
#define KEY_O -1
#define KEY_P -1
#define KEY_Q -1
#define KEY_R -1
#define KEY_S -1
#define KEY_T -1
#define KEY_U -1
#define KEY_V -1
#define KEY_W -1
#define KEY_X -1
#define KEY_Y -1
#define KEY_Z -1
#define KEY_F1 -1
#define KEY_F2 -1
#define KEY_F3 -1
#define KEY_F4 -1
#define KEY_F5 -1
#define KEY_F6 -1
#define KEY_UP KEY(3, 7)
#define KEY_DOWN KEY(0, 7)
#define KEY_LEFT KEY(1, 7)
#define KEY_RIGHT KEY(2, 7)
#define KEY_SHIFT -1

View File

@ -66,6 +66,7 @@ int main(){
Display::clear(newColor(70, 180, 220));
Display::show();
Time::init();
Time::update();
Input::init();

15
src/time-ce.cpp Normal file
View File

@ -0,0 +1,15 @@
#ifdef CE
#include "time.h"
#include <sys/rtc.h>
namespace Time {
void init(){
rtc_Enable(0);
}
void update(){
const float lastTime = time;
time = rtc_Time();
delta = time - lastTime;
}
};
#endif

View File

@ -3,6 +3,7 @@
#include <fxcg/rtc.h>
namespace Time {
void init(){}
void update(){
const float lastTime = time;
time = RTC_GetTicks();

View File

@ -3,6 +3,7 @@
#include <SDL2/SDL.h>
namespace Time {
void init(){}
void update(){
const float lastTime = time;
time = ((float)(SDL_GetTicks()) / (1000.0/128.0));

View File

@ -3,5 +3,6 @@
namespace Time {
extern float time;
extern float delta;
void init();
void update();
};

View File

@ -20,6 +20,12 @@
#define srand sys_srand
#endif
#ifdef CE
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#endif
#ifdef SDL
#include "stdio.h"
#include "stdlib.h"