diff --git a/readme.md b/readme.md index f891311..92b887a 100644 --- a/readme.md +++ b/readme.md @@ -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. \ No newline at end of file diff --git a/src/gfx/convimg.yaml b/src/gfx/convimg.yaml index a7b99c1..fa34ec0 100644 --- a/src/gfx/convimg.yaml +++ b/src/gfx/convimg.yaml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/gfx/rickroll.gif b/src/gfx/rickroll.gif deleted file mode 100644 index 268bb18..0000000 Binary files a/src/gfx/rickroll.gif and /dev/null differ diff --git a/src/gfx/rickroll/frame_40.gif b/src/gfx/rickroll/frame_40.gif deleted file mode 100644 index 3b00eb3..0000000 Binary files a/src/gfx/rickroll/frame_40.gif and /dev/null differ diff --git a/src/gfx/rickroll/frame_41.gif b/src/gfx/rickroll/frame_41.gif deleted file mode 100644 index 1681e2e..0000000 Binary files a/src/gfx/rickroll/frame_41.gif and /dev/null differ diff --git a/src/gfx/rickroll/frame_42.gif b/src/gfx/rickroll/frame_42.gif deleted file mode 100644 index d15ac83..0000000 Binary files a/src/gfx/rickroll/frame_42.gif and /dev/null differ diff --git a/src/gfx/rickroll/frame_43.gif b/src/gfx/rickroll/frame_43.gif deleted file mode 100644 index 4130b9c..0000000 Binary files a/src/gfx/rickroll/frame_43.gif and /dev/null differ diff --git a/src/gfx/rickroll/frame_44.gif b/src/gfx/rickroll/frame_44.gif deleted file mode 100644 index 1033ded..0000000 Binary files a/src/gfx/rickroll/frame_44.gif and /dev/null differ diff --git a/src/gfx/rickroll/frame_45.gif b/src/gfx/rickroll/frame_45.gif deleted file mode 100644 index c31b389..0000000 Binary files a/src/gfx/rickroll/frame_45.gif and /dev/null differ diff --git a/src/gfx/rickroll/frame_46.gif b/src/gfx/rickroll/frame_46.gif deleted file mode 100644 index 5e40d18..0000000 Binary files a/src/gfx/rickroll/frame_46.gif and /dev/null differ diff --git a/src/gfx/rickroll/frame_47.gif b/src/gfx/rickroll/frame_47.gif deleted file mode 100644 index 8a77806..0000000 Binary files a/src/gfx/rickroll/frame_47.gif and /dev/null differ diff --git a/src/gfx/rickroll/frame_48.gif b/src/gfx/rickroll/frame_48.gif deleted file mode 100644 index 4be248f..0000000 Binary files a/src/gfx/rickroll/frame_48.gif and /dev/null differ diff --git a/src/gfx/rickroll/frame_49.gif b/src/gfx/rickroll/frame_49.gif deleted file mode 100644 index a7a14ea..0000000 Binary files a/src/gfx/rickroll/frame_49.gif and /dev/null differ diff --git a/src/gfx/rickroll/frame_50.gif b/src/gfx/rickroll/frame_50.gif deleted file mode 100644 index 3f651c1..0000000 Binary files a/src/gfx/rickroll/frame_50.gif and /dev/null differ diff --git a/src/gfx/rickroll/frame_51.gif b/src/gfx/rickroll/frame_51.gif deleted file mode 100644 index 0818ab8..0000000 Binary files a/src/gfx/rickroll/frame_51.gif and /dev/null differ diff --git a/src/gfx/rickroll/frame_52.gif b/src/gfx/rickroll/frame_52.gif deleted file mode 100644 index 734f92e..0000000 Binary files a/src/gfx/rickroll/frame_52.gif and /dev/null differ diff --git a/src/gfx/rickroll/frame_53.gif b/src/gfx/rickroll/frame_53.gif deleted file mode 100644 index 01e94ba..0000000 Binary files a/src/gfx/rickroll/frame_53.gif and /dev/null differ diff --git a/src/main.c b/src/main.c index ad411ea..47a4037 100644 --- a/src/main.c +++ b/src/main.c @@ -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 \ No newline at end of file