Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////
- // v0.0.01
- // Author: William "Wistaro" Romiguieres
- // License: OpenSource
- // Description: A Windows-like in C just for fun :)
- ////////////////////////////////////////
- /* Keep these headers */
- #include <stdbool.h>
- #include <stddef.h>
- #include <stdint.h>
- #include <tice.h>
- #include <math.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <lib/ce/graphx.h>
- #include <lib/ce/keypadc.h>
- #include <decompress.h>
- #include "gfx_wind.h"
- //#include "gfx_fond.h"
- #define CURSOR_MOVE_AMT 1
- #define CURSOR_MIN_X 0
- #define CURSOR_MIN_Y 0
- #define CURSOR_MAX_X (LCD_WIDTH-1)
- #define CURSOR_MAX_Y (LCD_HEIGHT-1)
- /* Put function prototypes here */
- void printText(const char *text, uint8_t x, uint8_t y);
- void printTextSmall(const char *text, uint8_t xpos, uint8_t ypos);
- void printHomeScreen();
- void pause(int time);
- void printBoxMessage(uint8_t posx, uint8_t posy, char* text, uint8_t mode, gfx_image_t* windBh);
- /* Put all your code here */
- void main(void) {
- int cursor_x = 50;
- int cursor_y = 50;
- uint8_t demOpen = 0;
- kb_key_t keyg1, keyg7, keyg2;
- kb_key_t keyg6;
- gfx_image_t *behind_cursor = gfx_MallocSprite(16, 16);
- // begin graphics
- gfx_Begin(gfx_8bpp);
- // draw main screen
- printHomeScreen();
- // set initial state
- gfx_GetSprite(behind_cursor, cursor_x, cursor_y);
- gfx_TransparentSprite(cursor, cursor_x, cursor_y);
- // wait for a keypress
- do {
- kb_Scan();
- keyg1 = kb_Data[kb_group_1];
- keyg7 = kb_Data[kb_group_7];
- keyg6 = kb_Data[kb_group_6];
- if (!keyg7) continue; // if no arrows pressed, skip
- gfx_Sprite(behind_cursor, cursor_x, cursor_y);
- if(keyg7 & kb_Up) {
- gfx_GetSprite(behind_cursor, cursor_x, cursor_y);
- if ((cursor_y -= CURSOR_MOVE_AMT) < CURSOR_MIN_X) cursor_y = CURSOR_MIN_X;
- }
- if(keyg7 & kb_Down) {
- gfx_GetSprite(behind_cursor, cursor_x, cursor_y);
- if ((cursor_y += CURSOR_MOVE_AMT) > CURSOR_MAX_Y) cursor_y = CURSOR_MAX_Y;
- }
- if(keyg7 & kb_Left) {
- gfx_GetSprite(behind_cursor, cursor_x, cursor_y);
- if ((cursor_x -= CURSOR_MOVE_AMT) < CURSOR_MIN_Y) cursor_x = CURSOR_MIN_Y;
- }
- if(keyg7 & kb_Right) {
- gfx_GetSprite(behind_cursor, cursor_x, cursor_y);
- if ((cursor_x += CURSOR_MOVE_AMT) > CURSOR_MAX_X) cursor_x = CURSOR_MAX_X;
- }
- if(keyg6 & kb_Enter) {
- //draw something just for debug x)
- gfx_SetColor(gfx_blue);
- gfx_FillRectangle(0,0,100,50);
- }
- gfx_GetSprite(behind_cursor, cursor_x, cursor_y);
- gfx_TransparentSprite(cursor, cursor_x, cursor_y);
- } while (keyg1 != kb_2nd);
- gfx_End();
- free(behind_cursor);
- /* Retour à l'OS */
- pgrm_CleanUp();
- malloc(0);
- }
- /* Draw text on the homescreen at the given X/Y location */
- void printText(const char *text, uint8_t xpos, uint8_t ypos) {
- os_SetCursorPos(ypos, xpos);
- os_PutStrFull(text);
- }
- /* Draw small text at the given X/Y location */
- void printTextSmall(const char *text, uint8_t xpos, uint8_t ypos) {
- os_FontDrawText(text, xpos, ypos);
- }
- void printHomeScreen() {
- uint8_t a,b;
- // gfx_image_t *fontleft_uncompress = (gfx_image_t*)0xD031F6;
- // gfx_image_t *fontright_uncompress = (gfx_image_t*)0xD031F6;
- //gfx_image_t *behind_cursor = gfx_MallocSprite( 319, 239 ); //allocate space
- // dzx7_Standard(fondleft, fontleft_uncompress);
- //gfx_ScaledSprite_NoClip(fontleft_uncompress,0,0,1,1);
- //dzx7_Standard(fondleft, fontright_uncompress);
- //gfx_ScaledSprite_NoClip(fontright_uncompress,0,0,1,1);
- //gfx_image_t *fondleft_uncomp;
- //gfx_image_t *fondright_uncomp;
- //fondleft_uncomp = gfx_MallocSprite( 154, 240 ); //allocate space
- /*fondright_uncomp = gfx_MallocSprite( 167, 241 ); //allocate space
- dzx7_Standard( fondleft, fondleft_uncomp ); //uncompress sprite
- dzx7_Standard( fondright, fondright_uncomp ); //uncompress sprite
- */
- //gfx_SetDrawBuffer();
- gfx_FillScreen(gfx_blue);
- gfx_ScaledSprite_NoClip(fond,0,0,3,3);
- gfx_SetColor( 0xFF15 );
- gfx_FillRectangle(0,215,319,50);
- // gfx_ScaledSprite_NoClip(fontleft_uncompress,0,0,1,1);
- // gfx_ScaledSprite_NoClip(fontright_uncompress,150,0,1,1);
- gfx_TransparentSprite(start2,0,215);
- for(a = 0;a<=220;a = a+40){
- for(b = 0;b<=100;b = b+40){
- gfx_TransparentSprite_NoClip(folder,a,b);
- }
- }
- //gfx_Sprite(xpdem,0,62);
- // gfx_SwapDraw();
- /*gfx_GetSprite(behind_cursor,50,100);
- gfx_RotateSpriteHalf(behind_cursor,behind_cursor);
- gfx_TransparentSprite_NoClip(behind_cursor,30,60);*/
- //free(fondleft_uncomp); //free the memory
- //free(fondright_uncomp); //free the memory
- }
- void pause(int time){
- int i;
- time = 1000*time;
- for(i=0; i<time; i++);
- }
- void printBoxMessage(uint8_t posx, uint8_t posy, char* text, uint8_t mode, gfx_image_t* windBh){
- gfx_SetColor( gfx_RGBTo1555(23,101,125) );
- gfx_FillRectangle(posx,posy,100,50);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement