Skip to content

Commit

Permalink
refactored code and finished readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheep-s4n committed Oct 28, 2023
1 parent 09474d7 commit cb46bac
Show file tree
Hide file tree
Showing 18 changed files with 110 additions and 135 deletions.
32 changes: 31 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
## Rick Roll

A rick roll for the TI-84+CE and TI-83 Premium calculators.
A rick roll for TI-84 Plus CE and TI-83 Premium CE calculators.

![Rick roll demo](https://i.ibb.co/Z8wtvbW/rickroll-demo.png)

### Prerequisites

In order to run this program, you have to send the [C libraries](https://github.com/CE-Programming/libraries/releases) to your calculator. Either by using [TI-Connect CE](https://education.ti.com/en/software/details/en/CA9C74CAD02440A69FDC7189D7E1B6C2/swticonnectcesoftware) or TiLP (for GNU/Linux, therefore I can't provide a single download link).

### Installation

#### Download

You have two choices:
- Compile the binary files yourself using the [CE toolchain](https://ce-programming.github.io/toolchain/static/getting-started.html). Don't forget to run `make gfx` to make the frame data, before running `make` to compile the source code.
- Download the binary files already compiled from the [releases](https://github.com/Sheep-s4n/TI84-Rick-Roll/releases).

After this, you just have to send `RICKROLL.8xp`, `RICKROLL.8xp.0.8xv`, `RICKROLL.8xp.1.8.xv` and `RICKROLL.8xp.2.8.xv` to your calculator.

#### Usage

> OS version < v5.5
Run the program named `RICKROLL` that you can access by pressing the `[prgm]` button.
> OS version >= v5.5
If you have OS 5.5 or a newer version, you'll have to install [arTIfiCE](https://yvantt.github.io/arTIfiCE/) jailbreak to run the binary eZ80 ASM files. Also, you can install a shell such as [Cesium](https://github.com/mateoconlechuga/cesium/releases) in order to quickly launch the rick roll.

### Notes

- I had to reduce the frames sizes to 120 x 120 instead of keeping their full size as the calculator has only 154 kB of RAM.
- To exit the program, press any key.
32 changes: 9 additions & 23 deletions src/gfx/convimg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ converts:
transparent-color-index: 0
compress : 'zx0'
images:

- rickroll/frame_0.gif
- rickroll/frame_1.gif
- rickroll/frame_2.gif
- rickroll/frame_3.gif
- rickroll/frame_4.gif
- rickroll/frame_5.gif
- rickroll/frame_6.gif
- rickroll/frame_7.gif
- rickroll/frame_8.gif
- rickroll/frame_9.gif
- rickroll/frame_10.gif
- rickroll/frame_11.gif
- rickroll/frame_12.gif
Expand All @@ -24,7 +32,6 @@ converts:
- rickroll/frame_17.gif
- rickroll/frame_18.gif
- rickroll/frame_19.gif
- rickroll/frame_2.gif
- rickroll/frame_20.gif
- rickroll/frame_21.gif
- rickroll/frame_22.gif
Expand All @@ -35,7 +42,6 @@ converts:
- rickroll/frame_27.gif
- rickroll/frame_28.gif
- rickroll/frame_29.gif
- rickroll/frame_3.gif
- rickroll/frame_30.gif
- rickroll/frame_31.gif
- rickroll/frame_32.gif
Expand All @@ -46,26 +52,6 @@ converts:
- rickroll/frame_37.gif
- rickroll/frame_38.gif
- rickroll/frame_39.gif
- rickroll/frame_4.gif
- rickroll/frame_40.gif
- rickroll/frame_41.gif
- rickroll/frame_42.gif
- rickroll/frame_43.gif
- rickroll/frame_44.gif
- rickroll/frame_45.gif
- rickroll/frame_46.gif
- rickroll/frame_47.gif
- rickroll/frame_48.gif
- rickroll/frame_49.gif
- rickroll/frame_5.gif
- rickroll/frame_50.gif
- rickroll/frame_51.gif
- rickroll/frame_52.gif
- rickroll/frame_53.gif
- rickroll/frame_6.gif
- rickroll/frame_7.gif
- rickroll/frame_8.gif
- rickroll/frame_9.gif

outputs:
- type: c
Expand Down
Binary file removed src/gfx/rickroll.gif
Binary file not shown.
Binary file removed src/gfx/rickroll/frame_40.gif
Binary file not shown.
Binary file removed src/gfx/rickroll/frame_41.gif
Binary file not shown.
Binary file removed src/gfx/rickroll/frame_42.gif
Binary file not shown.
Binary file removed src/gfx/rickroll/frame_43.gif
Binary file not shown.
Binary file removed src/gfx/rickroll/frame_44.gif
Binary file not shown.
Binary file removed src/gfx/rickroll/frame_45.gif
Binary file not shown.
Binary file removed src/gfx/rickroll/frame_46.gif
Binary file not shown.
Binary file removed src/gfx/rickroll/frame_47.gif
Binary file not shown.
Binary file removed src/gfx/rickroll/frame_48.gif
Binary file not shown.
Binary file removed src/gfx/rickroll/frame_49.gif
Binary file not shown.
Binary file removed src/gfx/rickroll/frame_50.gif
Binary file not shown.
Binary file removed src/gfx/rickroll/frame_51.gif
Binary file not shown.
Binary file removed src/gfx/rickroll/frame_52.gif
Binary file not shown.
Binary file removed src/gfx/rickroll/frame_53.gif
Binary file not shown.
181 changes: 70 additions & 111 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,133 +10,92 @@
#define SCREEN_X_MAX 320
#define SCREEN_Y_MAX 240
#define IMAGE_X 255
#define FRAME_NUMBER 54
#define FRAME_NUMBER 40
#define SPRITE_SIZE 120
#define X_DRAW (SCREEN_X_MAX - SPRITE_SIZE) / 2
#define Y_DRAW (SCREEN_Y_MAX - SPRITE_SIZE) / 2

#define Y_DRAW (SCREEN_Y_MAX - SPRITE_SIZE) / 2 - (SCREEN_Y_MAX - SPRITE_SIZE) / 6

bool key_press = false;

unsigned char* frames_data[FRAME_NUMBER] = {
frame_0_compressed,
frame_1_compressed,
frame_2_compressed,
frame_3_compressed,
frame_4_compressed,
frame_5_compressed,
frame_6_compressed,
frame_7_compressed,
frame_8_compressed,
frame_9_compressed,
frame_10_compressed,
frame_11_compressed,
frame_12_compressed,
frame_13_compressed,
frame_14_compressed,
frame_15_compressed,
frame_16_compressed,
frame_17_compressed,
frame_18_compressed,
frame_19_compressed,
frame_20_compressed,
frame_21_compressed,
frame_22_compressed,
frame_23_compressed,
frame_24_compressed,
frame_25_compressed,
frame_26_compressed,
frame_27_compressed,
frame_28_compressed,
frame_29_compressed,
frame_30_compressed,
frame_31_compressed,
frame_32_compressed,
frame_33_compressed,
frame_34_compressed,
frame_35_compressed,
frame_36_compressed,
frame_37_compressed,
frame_38_compressed,
frame_39_compressed,
};

void gfx_init() {
gfx_SetTextFGColor(254);
gfx_SetTextScale(1 , 2);
gfx_SetPalette(global_palette, sizeof_global_palette, 0);
gfx_SetTransparentColor(0);
gfx_FillScreen(2);
}

void drawFrame(gfx_sprite_t* spriteBuffer , unsigned char* frame_data) {
zx0_Decompress(spriteBuffer , frame_data);
gfx_TransparentSprite(spriteBuffer, X_DRAW , Y_DRAW);
msleep(20);
void drawFrame(gfx_sprite_t* sprite_buffer , unsigned char* frame_data) {
if (key_press) return;
if (os_GetCSC()) key_press = true;
zx0_Decompress(sprite_buffer , frame_data);
gfx_TransparentSprite(sprite_buffer, X_DRAW , Y_DRAW);
gfx_PrintStringXY("You just got rick rolled !" , SCREEN_X_MAX / 4 , SCREEN_Y_MAX - 45);
msleep(15);
}

int main(void)
{

/* Clear the homescreen */
os_ClrHome();
gfx_Begin();

/* Set the palette for sprites */
gfx_SetPalette(global_palette, sizeof_global_palette, 0);
gfx_SetTransparentColor(0);
gfx_FillScreen(2);

gfx_sprite_t* spriteBuffer = gfx_MallocSprite(SPRITE_SIZE, SPRITE_SIZE);
if (spriteBuffer == NULL) {
gfx_PrintStringXY("Failed to allocate memory for the sprite" , 0 ,0);
return 1;
}
do {
drawFrame(spriteBuffer , frame_0_compressed);
drawFrame(spriteBuffer , frame_0_compressed);
drawFrame(spriteBuffer , frame_1_compressed);
drawFrame(spriteBuffer , frame_2_compressed);
drawFrame(spriteBuffer , frame_3_compressed);
drawFrame(spriteBuffer , frame_4_compressed);
drawFrame(spriteBuffer , frame_5_compressed);
drawFrame(spriteBuffer , frame_6_compressed);
drawFrame(spriteBuffer , frame_7_compressed);
drawFrame(spriteBuffer , frame_8_compressed);
drawFrame(spriteBuffer , frame_9_compressed);
drawFrame(spriteBuffer , frame_10_compressed);
drawFrame(spriteBuffer , frame_11_compressed);
drawFrame(spriteBuffer , frame_12_compressed);
drawFrame(spriteBuffer , frame_13_compressed);
drawFrame(spriteBuffer , frame_14_compressed);
drawFrame(spriteBuffer , frame_15_compressed);
drawFrame(spriteBuffer , frame_16_compressed);
drawFrame(spriteBuffer , frame_17_compressed);
drawFrame(spriteBuffer , frame_18_compressed);
drawFrame(spriteBuffer , frame_19_compressed);
drawFrame(spriteBuffer , frame_20_compressed);
drawFrame(spriteBuffer , frame_21_compressed);
drawFrame(spriteBuffer , frame_22_compressed);
drawFrame(spriteBuffer , frame_23_compressed);
drawFrame(spriteBuffer , frame_24_compressed);
drawFrame(spriteBuffer , frame_25_compressed);
drawFrame(spriteBuffer , frame_26_compressed);
drawFrame(spriteBuffer , frame_27_compressed);
drawFrame(spriteBuffer , frame_28_compressed);
drawFrame(spriteBuffer , frame_29_compressed);
drawFrame(spriteBuffer , frame_30_compressed);
drawFrame(spriteBuffer , frame_31_compressed);
drawFrame(spriteBuffer , frame_32_compressed);
drawFrame(spriteBuffer , frame_33_compressed);
drawFrame(spriteBuffer , frame_34_compressed);
drawFrame(spriteBuffer , frame_35_compressed);
drawFrame(spriteBuffer , frame_36_compressed);
drawFrame(spriteBuffer , frame_37_compressed);
drawFrame(spriteBuffer , frame_38_compressed);
drawFrame(spriteBuffer , frame_39_compressed);
gfx_init();
gfx_sprite_t* sprite_buffer = gfx_MallocSprite(SPRITE_SIZE, SPRITE_SIZE);
if (sprite_buffer == NULL) return 1;

do {
for (int i = 0; i < FRAME_NUMBER; i++) {
drawFrame(sprite_buffer , frames_data[i]);
};
}
while (!os_GetCSC()); // wait for a key
while (key_press == false);

gfx_End();

/* Return 0 for success */
return 0;
}


/*
gfx_SetDefaultPalette();
gfx_SetDrawBuffer();
do {
//gfx_SetColor(color);
//gfx_SetTextFGColor(254);
//gfx_PrintStringXY("Os Major Version: " , 3 , SCREEN_Y_MAX - 10);
//gfx_PrintInt(majorVersion , 1);
gfx_SwapDraw();
}
while (!os_GetCSC()); // wait for a key
*/

/*
int x = 0;
int y = 0;
gfx_sprite_t *behind_sprite = gfx_MallocSprite(SPRITE_WIDTH, SPRITE_HEIGHT);
// ...draw the background code here...
// set initial sprite state
gfx_GetSprite(behind_sprite, x, y);
gfx_TransparentSprite(sprite, x, y);
do {
// if we don't need to move, loop
if (no_move) continue;
// clear out the old sprite
gfx_Sprite(behind_sprite, x, y);
// ...movement code here...
// updates x and y
// get the new background and draw the moved sprite
gfx_GetSprite(behind_sprite, x, y);
gfx_TransparentSprite(sprite, x, y);
} while (moving);
*/

// Todo :
// add a "You have been rickrolled" text
// make it possible to exit without reseting RAM
// refactor code

0 comments on commit cb46bac

Please sign in to comment.