Updated flake. Started modifying example
This commit is contained in:
parent
828c98ba34
commit
ffb6d1369c
4 changed files with 149 additions and 21 deletions
12
flake.nix
12
flake.nix
|
|
@ -19,7 +19,17 @@
|
||||||
overlays = [devkitNix.overlays.default];
|
overlays = [devkitNix.overlays.default];
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
devShells.default = pkgs.mkShell.override {stdenv = pkgs.devkitNix.stdenvARM;} {packages = with pkgs; [imagemagick];};
|
devShells.default =
|
||||||
|
pkgs.mkShell.override {
|
||||||
|
stdenv = pkgs.devkitNix.stdenvARM;
|
||||||
|
} {
|
||||||
|
packages = with pkgs; [imagemagick];
|
||||||
|
shellHook = ''
|
||||||
|
# export DEVKITARM=${pkgs.devkitNix.devkitARM}
|
||||||
|
# export C_INCLUDE_PATH=$(find $DEVKITARM -type d -name include | tr '\n' ':'):$C_INCLUDE_PATH
|
||||||
|
# export LIBRARY_PATH=$(find $DEVKITARM -type d -name lib | tr '\n' ':'):$LIBRARY_PATH
|
||||||
|
'';
|
||||||
|
};
|
||||||
packages.default = pkgs.devkitNix.stdenvARM.mkDerivation {
|
packages.default = pkgs.devkitNix.stdenvARM.mkDerivation {
|
||||||
name = "somding";
|
name = "somding";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
|
||||||
33
src/class.c
Normal file
33
src/class.c
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
typedef struct {
|
||||||
|
uint8_t room;
|
||||||
|
char subject[20];
|
||||||
|
int startDate;
|
||||||
|
int endDate;
|
||||||
|
|
||||||
|
C2D_Text classText_static[2];
|
||||||
|
C2D_Text classText_dynamic[1];
|
||||||
|
|
||||||
|
C2D_TextBuf g_static*;
|
||||||
|
C2D_TextBuf g_dynamic*;
|
||||||
|
} lesson;
|
||||||
|
|
||||||
|
lesson Lesson(
|
||||||
|
uint8_t room,
|
||||||
|
char subject[20],
|
||||||
|
int startDate,
|
||||||
|
int endDate,
|
||||||
|
C2D_TextBuf g_static*,
|
||||||
|
C2D_TextBuf g_dynamic*
|
||||||
|
) {
|
||||||
|
char roomStr[8]
|
||||||
|
sprintf(roomStr, "%d", room);
|
||||||
|
|
||||||
|
C2D_TextParse(&g_staticText[0], g_staticBuf, roomStr);
|
||||||
|
C2D_TextParse(&g_staticText[1], g_staticBuf, subject);
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
C2D_TextOptimize(&g_staticText[i]);
|
||||||
|
};
|
||||||
|
void renderLesson(lesson Lesson*, int x, int y);
|
||||||
|
|
||||||
|
|
||||||
18
src/lesson.h
Normal file
18
src/lesson.h
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include <citro2d.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t room;
|
||||||
|
char subject[20];
|
||||||
|
int startDate;
|
||||||
|
int endDate;
|
||||||
|
|
||||||
|
C2D_Text classText_static[2];
|
||||||
|
C2D_Text classText_dynamic[1];
|
||||||
|
|
||||||
|
C2D_TextBuf g_static*;
|
||||||
|
C2D_TextBuf g_dynamic*;
|
||||||
|
} lesson;
|
||||||
|
|
||||||
|
lesson Lesson(uint8_t room, char subject[20], int startDate, int endDate, C2D_TextBuf g_static*, C2D_TextBuf g_dynamic*);
|
||||||
|
void renderLesson(lesson Lesson*, int x, int y);
|
||||||
|
|
||||||
93
src/main.c
93
src/main.c
|
|
@ -1,28 +1,95 @@
|
||||||
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
#include <citro2d.h>
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
static const char *ordinalIndicators[] = {
|
||||||
|
"st",
|
||||||
|
"nd",
|
||||||
|
"rd",
|
||||||
|
"th"
|
||||||
|
};
|
||||||
|
|
||||||
|
u32 clrBg;
|
||||||
|
u32 clrBg2;
|
||||||
|
u32 clrFg;
|
||||||
|
C2D_TextBuf g_staticBuf;
|
||||||
|
C2D_Text g_staticText[3];
|
||||||
|
C2D_Text g_staticText_hoursEnumerator[9];
|
||||||
|
|
||||||
|
static void sceneInit(void) {
|
||||||
|
g_staticBuf = C2D_TextBufNew(3 * 9);
|
||||||
|
// g_dynamicBuf = C2D_TextBufNew(4096);
|
||||||
|
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
char str[3];
|
||||||
|
sprintf(str, "%d%s", i+1, ordinalIndicators[i < 4 ? i : 3]);
|
||||||
|
C2D_TextParse(&g_staticText[i], g_staticBuf, str);
|
||||||
|
C2D_TextOptimize(&g_staticText[i]);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static void colorInit(void) {
|
||||||
|
clrBg = C2D_Color32(0x1D, 0x23, 0x2A, 0xFF); // #1d232a
|
||||||
|
clrBg = C2D_Color32(0xFF, 0xFF, 0xFF, 0xFF); // #1d232a
|
||||||
|
clrBg2 = C2D_Color32(0x19, 0x1E, 0x24, 0xFF); // #191e24
|
||||||
|
clrFg = C2D_Color32f(0xEC, 0xF9, 0xFF, 0xFF); // #ecf9ff
|
||||||
|
};
|
||||||
|
|
||||||
|
static void sceneExit(void)
|
||||||
{
|
{
|
||||||
gfxInitDefault();
|
C2D_TextBufDelete(g_staticBuf);
|
||||||
consoleInit(GFX_TOP, NULL);
|
}
|
||||||
|
|
||||||
printf("Hello, world!\n");
|
static void sceneRender() {
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
C2D_DrawText(&g_staticText[i], C2D_AtBaseline | C2D_AlignJustified | C2D_WordWrap | C2D_WithColor, 100.0f, i*15.0f + 50.0f, 0.5f, 0.75f, 0.75f, 200.0f, clrFg);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int keyHandle() {
|
||||||
|
u32 kDown = hidKeysDown();
|
||||||
|
u32 kHeld = hidKeysHeld();
|
||||||
|
|
||||||
|
if (kDown & KEY_START)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
gfxInitDefault();
|
||||||
|
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
|
||||||
|
C2D_Init(C2D_DEFAULT_MAX_OBJECTS);
|
||||||
|
C2D_Prepare();
|
||||||
|
|
||||||
|
C3D_RenderTarget* top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
|
||||||
|
|
||||||
|
sceneInit();
|
||||||
|
colorInit();
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
while (aptMainLoop())
|
while (aptMainLoop()) {
|
||||||
{
|
|
||||||
gspWaitForVBlank();
|
|
||||||
gfxSwapBuffers();
|
|
||||||
hidScanInput();
|
hidScanInput();
|
||||||
|
|
||||||
// Your code goes here
|
// Respond to user input
|
||||||
u32 kDown = hidKeysDown();
|
if (keyHandle()) break;
|
||||||
if (kDown & KEY_START)
|
|
||||||
break; // break in order to return to hbmenu
|
// Render the scene
|
||||||
|
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||||
|
C2D_TargetClear(top, clrBg);
|
||||||
|
C2D_SceneBegin(top);
|
||||||
|
sceneRender();
|
||||||
|
C3D_FrameEnd(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deinitialize the scene
|
||||||
|
sceneExit();
|
||||||
|
|
||||||
|
C2D_Fini();
|
||||||
|
C3D_Fini();
|
||||||
gfxExit();
|
gfxExit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue