Homebrew DEAD Calculator-NX - Mathematics on your Switch !

  • Thread starter Deleted_444986
  • Start date
  • Views 10,632
  • Replies 49
  • Likes 8

Do you want a GUI ?

  • YES

    Votes: 72 77.4%
  • NO

    Votes: 7 7.5%
  • What's a GUI ...

    Votes: 14 15.1%

  • Total voters
    93

Coto

-
Member
Joined
Jun 4, 2010
Messages
2,979
Trophies
2
XP
2,565
Country
Chile
cool, but i think thats a silly idea because your Code is completly trash i could help you when you enter
printf(CONSOLE_ESC(Number;NumberAndH)"TEXT"); Then it overwrite it so u dont need to clear the screen and your code is little bit cleaner.
for example: printf(CONSOLE_ESC(1;1H)"Im using that!");
would print Im using that! in the corner. but think that you only overwrite so if you print Hello 123 and then overwrite it with Hello then will the 123 be still there so do that printf(CONSOLE_ESC(1;1H)"Hello 123"); and then to overwrite printf(CONSOLE_ESC(1;1H)"Hello [And spam some spacebar in this]"); like that printf(CONSOLE_ESC(1;1H)"Hello . . . . . . . . . . . . . . . . ")
Hope i can help you. ^^

my own calculator, look at the Code, it will help you, im sure: http://bit.ly/2I4j8wc

Now they’re going to see who I am, he said to himself in his strong new man’s voice, many years after he had first seen the huge ocean liner without lights and without any sound which passed by the village one night like a great uninhabited place, longer than the whole village and much taller than the steeple of the church, and it sailed by in the darkness toward the colonial city on the other side of the bay that had been fortified against buccaneers, with its old slave port and the rotating light, whose gloomy beams transfigured the village into a lunar encampment of glowing houses and streets of volcanic deserts every fifteen seconds, and even though at that time he’d been a boy without a man’s strong voice but with his’ mother’s permission to stay very late on the beach to listen to the wind’s night harps, he could still remember, as if still seeing it, how the liner would disappear when the light of the beacon struck its side and how it would reappear when the light had passed, so that it was an intermittent ship sailing along, appearing and disappearing, toward the mouth of the bay, groping its way like a sleep‐walker for the buoys that marked the harbor channel, until something must have gone wrong with the compass needle, because it headed toward the shoals, ran aground, broke up, and sank without a single sound, even though a collision against the reefs like that should have produced a crash of metal and the explosion of engines that would have frozen, with fright the soundest‐sleeping dragons in the prehistoric jungle that began with the last streets of the village and ended on the other side of the world, so that he himself thought it was a dream, especially the, next day, when he. saw the radiant fishbowl. of the bay, the disorder of colors of the n**** shacks on the hills above the harbor, the schooners of the smugglers from the Guianas loading their cargoes ‐of innocent parrots whose craws were full of diamonds, he thought, I fell asleep counting the stars and L dreamed about that huge ship, of course, he was so convinced that he didn’t tell anyone nor did he remember the vision again until the same night on the following March when he was looking for the flash of dolphins in the sea and what he found was the illusory line, gloomy, intermittent, with the same mistaken direction as the first time, except that then he was so sure he was awake that he ran to tell his mother and she spent three weeks moaning with disappointment, because your brain’s rotting away from doing so many things backward, sleeping during the day and going out at night like a criminal, and since she had to go to the city around that time to get something comfortable where she could sit and think about her dead husband, because the rockers on her chair had worn out after eleven years of widowhood, she took advantage of the occasion and had the boatman go near the shoals so that her son could see what he really saw in the glass of; the sea, the lovemaking of manta rays in a springtime of sponges, pink snappers and blue corvinas diving into the other wells of softer waters that were there among the waters, and even the wandering hairs of victims of drowning in some colonial shipwreck, no trace of sunken liners of anything like it, and yet he was so pigheaded that his mother promised to watch with him the next March, absolutely, not knowing that the only thing absolute in her future now was an easy chair from the days of Sir Francis Drake which she had bought at an auction in a Turk’s store, in which she sat down to rest that same night sighing, oh, my poor Olofernos, if you could only see how nice it is to think about you on this velvet lining and this brocade from the casket of a queen, but the more she brought back the memory of her dead husband, the more the blood in her heart bubbled up and turned to chocolate, as if instead of sitting down she were running, soaked from chills and fevers and her breathing full of earth, until he returned at dawn and found her dead in the easy chair, still warm, but half rotted away as after a snakebite, the same as happened afterward to four other women before the murderous chair was thrown into the sea, far away where it wouldn’t bring evil to anyone, because it had. been used so much over the centuries that its faculty for giving rest had been used up, and so he had to grow accustomed to his miserable routine of an orphan who was pointed out by everyone as the son of the widow who had brought the throne of misfortune into the village, living not so much from public charity as from fish he stole out of the boats, while his voice was becoming a roar, and not remembering his visions of past times anymore until another night in March when he chanced to look seaward and suddenly, good Lord, there, it is, the huge asbestos whale, the behemoth beast, come see it, he shouted madly, come see it, raising such an uproar of dogs’ barking and women’s panic that even the oldest men remembered the frights of their great‐grandfathers and crawled under their beds, thinking that William Dampier had come back, but those who ran into the street didn’t make the effort to see the unlikely apparatus which at that instant was lost again in the east and raised up in its annual disaster, but they covered him with blows and left him so twisted that it was then he said to himself, drooling with rage, now they’re going to see who I am, but he took care not to share his determination with anyone, but spent the whole year with the fixed idea, now they’re going to see who I am, waiting for it to be the eve of the apparition once more in order to do what he did, which was steal a boat, cross the bay, and spend the evening waiting for his great moment in the inlets of the slave port, in the human brine of the Caribbean, but so absorbed in his adventure that he didn’t stop as he always did in front of the Hindu shops to look at the ivory mandarins carved from the whole tusk of an elephant, nor did he make fun of the Dutch Negroes in their orthopedic velocipedes, nor was he frightened as at other times of the copper‐skinned Malayans, who had gone around the world, enthralled by the chimera of a secret tavern where they sold roast filets of Brazilian women, because he wasn’t aware of anything until night came over him with all the weight of the stars and the jungle exhaled a sweet fragrance of gardenias and rotter salamanders, and there he was, rowing in the stolen boat, toward the mouth of the bay, with the lantern out so as not to alert the customs police, idealized every fifteen seconds by the green wing flap of the beacon and turned human once more by the darkness, knowing that he was getting close to the buoys that marked the harbor, channel, not only because its oppressive glow was getting more intense, but because the breathing of the water was becoming sad, and he rowed like that, so wrapped up in himself, that he. didn’t know where the fearful shark’s breath that suddenly reached him came from or why the night became dense, as if the stars had suddenly died, and it was because the liner was there, with all of its inconceivable size, Lord, bigger than, any other big thing in the world and darker than any other dark thing on land or sea, three hundred thousand tons of shark smell passing so close to the boat that he could see the seams of the steel precipice without a single light in the infinite portholes, without a sigh from the engines, without a soul, and carrying its own circle of silence with it, its own dead air, its halted time, its errant sea in which a whole world of drowned animals floated, and suddenly it all disappeared with the flash of the beacon and for an instant it was the diaphanous Caribbean once more, the March night, the everyday air of the pelicans, so he stayed alone among the buoys, not knowing what to do, asking himself, startled, if perhaps he wasn’t dreaming while he was awake, not just now but the other times too, but no sooner had. he asked himself than a breath of mystery snuffled out the buoys, from the first to the last, so that when the light of the beacon passed by the liner appeared again and now its compasses were out of order, perhaps not even knowing what part of the ocean sea it was in, groping for the invisible channel but actually heading for the shoals, until he got the overwhelming revelation that that misfortune of the buoys was the last key to the enchantment and he lighted the lantern in the boat, a tiny red light that had no reason to alarm anyone in the watch towers but which would be like a guiding sun for the pilot, because, thanks to it, the liner corrected its course and passed into the main gate of the channel in a maneuver of lucky resurrection, and then all the lights went on at the same time so that the boilers wheezed again, the stars were fixed in their places, and the animal corpses went to the bottom, and there was a clatter of plates and a fragrance of laurel sauce in the kitchens, and one could hear the pulsing of the orchestra on the moon decks and the throbbing of the arteries of high‐sea lovers in the shadows of the staterooms, but he still carried so much leftover rage in him that he would not let himself be confused by emotion or be frightened by the miracle, but said to himself with more decision than ever, now they’re going to see who I am, the cowards, now they’re going to see, and instead of turning aside so that the colossal machine would not charge into him he began to row in front of it, because now they really are going to see who I am, and he continued guiding the ship with the lantern until he was so sure of its obedience that he made it change course from the direction of the docks once more, took it out of the invisible channel, and led it by the halter as if it were a sea lamb toward the lights of the sleeping village, a living ship, invulnerable to the torches of the beacon, that no longer made invisible but made it aluminum every fifteen seconds, and the crosses of the church, the misery of the houses, the illusion began to stand out and still the ocean liner followed behind him, following his will inside of it, the captain asleep on his heart side, the fighting bulls in the snow of their pantries, the solitary patient in the infirmary, the orphan water of its cisterns, the unredeemed pilot who must have mistaken the cliffs for the docks, because at that instant the great roar of the whistle burst forth, once, and he with downpour of steam that fell on him, again, and the boat belonging to someone else was on the point of capsizing, and again, but it was too late, because there were the shells of the shoreline, the stones of the street, the doors of the disbelievers, the whole village illuminated by the lights of the fearsome liner itself, and he barely had time to get out of the way to make room for the cataclysm, shouting in the midst of the confusion, there it is, you cowards, a second before the huge steel cask shattered the ground and one could hear the neat destruction of ninety thousand five hundred champagne glasses breaking, one after the other, from stem to stern, and then the light came out and it was no longer a March dawn but the noon of a radiant Wednesday, and he was able to give himself the pleasure of watching the disbelievers as with open mouths they contemplated the largest ocean liner in this world and the other aground in front of the church, whiter than anything, twenty times taller than the steeple and some ninety‐seven times longer than the village, with its name engraved in iron letters, Halalcsillag, and the ancient and languid waters of the sea of death dripping down its sides. (Or call it like that: A Fatal Error appeared!)

dude I had no idea you were a writer and a coder. I mean that about message escalated quickly


still better story than twilight
 
Last edited by Coto,

spx

Member
Newcomer
Joined
Nov 1, 2018
Messages
19
Trophies
0
Age
23
Location
Bucharest, Romania
XP
197
Country
Romania
@Thomhack don't get discouraged because people are making fun of your code,
you're a beginner; if it weren't horrible something would be very wrong.


A good rule to follow in the future is "don't repeat yourself" (or "DRY" in short),
which basically means if you write something more than two times you should probably create a function (or sometimes a macro, but that is overkill right now) instead.
For example,
https://github.com/thomleg50/Calculator-NX/blob/master/source/main.c#L11-L19 could instead be a function.

Good luck with your adventure into C!
/ F
Replying to this might be a waste of time, but I definitely think bad code is NOT the main reason for *this* situation.
 

spx

Member
Newcomer
Joined
Nov 1, 2018
Messages
19
Trophies
0
Age
23
Location
Bucharest, Romania
XP
197
Country
Romania
How tool i install? When sd cart taken out switch crashes how to stop crash? Why in video no minus only plus? Where files on sd go? Why does it crash when i open file on notepadalliseeis giberish?
Yes yes i had same problem, i had to buy XKOS and AceOS and booted one from hekate then injected other then took sd out mid boot then plugged back in then opened the calculator mathematical nro with notepad then copied then put inside nand in a system nca application and then it worked
 

Jayro

MediCat USB Dev
Developer
Joined
Jul 23, 2012
Messages
12,973
Trophies
4
Location
WA State
Website
ko-fi.com
XP
17,003
Country
United States
I wish someone would make a TI-83/84 calculator emulator for the Switch, WabbitEmu on Android is lit, and the Switch has a good screen size for it to be almost a 1:1 emulated replica.
 
  • Like
Reactions: Julie_Pilgrim

lordelan

Well-Known Member
Member
Joined
Jan 4, 2015
Messages
5,787
Trophies
1
Age
44
XP
6,517
Country
Germany
Haha, while this thread entertained me well, your calculator is a good simple example for other beginners I think.
If you allow me to give you this advice: Keep that non GUI calc on github as it is and whenever you add a GUI, do it in a separate git repository.
That helps people even more to understand the steps.

In case you're ignoring me, I'll preserve your actual state here:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <switch.h>

int first = 0, second = 0, operation = 1, result;
float resultF;

void printTop()
{
   printf(
   "Thomleg50@2019 calculator 0.5\n"
   "Press < To calculate\n"
   "Press L to add 10 to first\n"
   "Press R to add 1 to first\n"
   "Press ZL to add 10 to second\n"
   "Press ZR to add 1 to second\n"
   "Press X to remove 10 to first\n"
   "Press Y to remove 10 to second\n"
   "Press - to reset calculator\n"
   "Press + to exit\n"
   "Select operation by pressing >.\n1.Addition\n2.Substraction\n3.Multiplication\n4.Division\n");
}

void printNumbers(int n1, int n2)
{
   printf("first = %d\nsecond = %d\n", n1, n2);
}

int main(int argc, char* argv[])
{

   consoleInit(NULL);
   printTop();

   while (appletMainLoop()){
    
       hidScanInput();

       u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);

       if (kDown & KEY_PLUS) break;

       if (kDown & KEY_MINUS)
       {
           consoleClear();
           first = 0;
           second = 0;
           printTop();
       }
       if(kDown & KEY_DRIGHT)
       {
           consoleClear();
           printTop();
           if(operation < 4)
               operation++;
           else
               operation = 1;
           printf("The choosen operation is %d", operation);
       }
       if(kDown & KEY_DLEFT)
       {
               consoleClear();
               printTop();
               printf("Calculating...\n");
       }
       switch(operation)
       {
           case 1:
               result = first + second;
               printf("The result of %d + %d is %d\n", first, second, result);
               break;
           case 2:
               result = first - second;
               printf("The result of %d - %d is %d\n", first, second, result);
               break;
           case 3:
               result = first * second;
               printf("The result of %d * %d is %d\n", first, second, result);
               break;
           case 4:
               resultF = (float)first / second;
               printf("The result of %d divided by %d is %f\n", first, second, resultF);
       }
       if(kDown & KEY_L)
       {
           consoleClear();
           printTop();
           first += 10;
           printNumbers(first, second);
       }

       if(kDown & KEY_R)
       {
           consoleClear();
           printTop();
           first++;
           printNumbers(first, second);
       }

       if(kDown & KEY_ZL)
       {
           consoleClear();
           printTop();
           second += 10;
           printNumbers(first, second);
       }

       if(kDown & KEY_ZR)
       {
           consoleClear();
           printTop();
           second++;
           printNumbers(first, second);
       }

       if(kDown & KEY_X)
       {
           consoleClear();
           printTop();
           first -= 10;
           printNumbers(first, second);
       }

       if(kDown & KEY_Y)
       {
           consoleClear();
           printTop();
           second -= 10;
           printNumbers(first, second);
       }
       consoleUpdate(NULL);
   }

   consoleExit(NULL);
   return 0;
}
 
  • Like
Reactions: Julie_Pilgrim

hippy dave

BBMB
Member
Joined
Apr 30, 2012
Messages
9,868
Trophies
2
XP
29,101
Country
United Kingdom
Haha, while this thread entertained me well, your calculator is a good simple example for other beginners I think.
If you allow me to give you this advice: Keep that non GUI calc on github as it is and whenever you add a GUI, do it in a separate git repository.
That helps people even more to understand the steps.

In case you're ignoring me, I'll preserve your actual state here:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <switch.h>

int first = 0, second = 0, operation = 1, result;
float resultF;

void printTop()
{
   printf(
   "Thomleg50@2019 calculator 0.5\n"
   "Press < To calculate\n"
   "Press L to add 10 to first\n"
   "Press R to add 1 to first\n"
   "Press ZL to add 10 to second\n"
   "Press ZR to add 1 to second\n"
   "Press X to remove 10 to first\n"
   "Press Y to remove 10 to second\n"
   "Press - to reset calculator\n"
   "Press + to exit\n"
   "Select operation by pressing >.\n1.Addition\n2.Substraction\n3.Multiplication\n4.Division\n");
}

void printNumbers(int n1, int n2)
{
   printf("first = %d\nsecond = %d\n", n1, n2);
}

int main(int argc, char* argv[])
{

   consoleInit(NULL);
   printTop();

   while (appletMainLoop()){
   
       hidScanInput();

       u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);

       if (kDown & KEY_PLUS) break;

       if (kDown & KEY_MINUS)
       {
           consoleClear();
           first = 0;
           second = 0;
           printTop();
       }
       if(kDown & KEY_DRIGHT)
       {
           consoleClear();
           printTop();
           if(operation < 4)
               operation++;
           else
               operation = 1;
           printf("The choosen operation is %d", operation);
       }
       if(kDown & KEY_DLEFT)
       {
               consoleClear();
               printTop();
               printf("Calculating...\n");
       }
       switch(operation)
       {
           case 1:
               result = first + second;
               printf("The result of %d + %d is %d\n", first, second, result);
               break;
           case 2:
               result = first - second;
               printf("The result of %d - %d is %d\n", first, second, result);
               break;
           case 3:
               result = first * second;
               printf("The result of %d * %d is %d\n", first, second, result);
               break;
           case 4:
               resultF = (float)first / second;
               printf("The result of %d divided by %d is %f\n", first, second, resultF);
       }
       if(kDown & KEY_L)
       {
           consoleClear();
           printTop();
           first += 10;
           printNumbers(first, second);
       }

       if(kDown & KEY_R)
       {
           consoleClear();
           printTop();
           first++;
           printNumbers(first, second);
       }

       if(kDown & KEY_ZL)
       {
           consoleClear();
           printTop();
           second += 10;
           printNumbers(first, second);
       }

       if(kDown & KEY_ZR)
       {
           consoleClear();
           printTop();
           second++;
           printNumbers(first, second);
       }

       if(kDown & KEY_X)
       {
           consoleClear();
           printTop();
           first -= 10;
           printNumbers(first, second);
       }

       if(kDown & KEY_Y)
       {
           consoleClear();
           printTop();
           second -= 10;
           printNumbers(first, second);
       }
       consoleUpdate(NULL);
   }

   consoleExit(NULL);
   return 0;
}
Cool thing about github is you can show any revision of a file, so even if the app gets totally revamped, you can still look at the code from the first version.
 
  • Like
Reactions: Julie_Pilgrim

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    I @ idonthave: :)