Les membres ayant 30 points peuvent parler sur les canaux annonces, projets et hs du chat.

Forum Casio - Projets de programmation


Index du Forum » Projets de programmation » Terrario, a Terraria rewrite for the calculator
Kbd2 En ligne Membre Points: 244 Défis: 0 Message

Terrario, a Terraria rewrite for the calculator

Posté le 10/07/2020 16:05

Hi. I noticed a while ago there weren't any games like Terraria or Minecraft available for Casio calculators. For the past while I've been working on rewriting Terraria in C for the SH4 calculators using gint. I'm not sure when if ever I'll finish it, since it is a fairly big project, so I've decided to put it here for now.

Here are a few screenshots of the progress so far (some may be out-of-date):
Main menu


Gameplay


Inventory


Crafting


Equipment


A visualisation of a generated world (click for full detail)



The game runs at 30FPS. Worlds are 1000x250 tiles large (640x250 on the 35+E II / GIII).

The control scheme and a crafting guide can be found in the game's About menu.

This forum page is updated regularly with the latest release of the game, as well as a changelog in the comments.

If you aren't sure what an item does, feel free to search it up on the official Terraria wiki.

Most recent update:
NPCs.

Up next:
Money and shop NPCs.

The attached file contains the latest build of the game, as well as instructions and a screenshot compiling script and map tool.

The source code repository as well as early builds of the game can be found at this GitHub repo and its Gitea mirror. Obviously, expect bugs in these early builds, though I take care to remove the major ones I find before releasing.

Due to the very large world, the save files for this game are big. Make sure you have at least 450kB of storage space before installing the addin (300kB on Graph 35+E II), and try to keep at least 300kB free afterwards. Tampering with the files in the TERRARIO folder will corrupt the save, so don't do that. The game will warn you if you have low storage space available, so that you can optimise your storage.

NOTE: You must have a Graph 35+ E, Graph 35+E II, fx9860GII, or fx9750GIII model calculator to run this game.

Fichier joint


Précédente 1, 2, 3 ··· 5, 6, 7, 8
Kbd2 En ligne Membre Points: 244 Défis: 0 Message

Citer : Posté le 06/06/2021 09:39 | #


Right, I guess I was using an older gcc that allowed it or something
Lephenixnoir En ligne Administrateur Points: 20113 Défis: 143 Message

Citer : Posté le 06/06/2021 09:53 | #


Good. I also forgot the OpenLibm problem that you mentioned:

<KBD2> @Lephenixnoir Looks like the include path doesn't get set for openlibm, so even your sh-elf-gcc headers cause an error

Ok so OpenLibm has this issue where it installs itself in an openlibm/ subfolder but includes itself as if it were installed directly in an included folder. So it requires some -I option, which is documented on the repository.

For CMake-based add-ins I have made gint add the proper paths, which is transparent for everyone. But make doesn't have mechanisms where I can deploy code to your project through an fxSDK update, so you have to include it yourself. Here are the paths you need:

CFLAGS += -I $(shell sh-elf-gcc -print-file-name=include/openlibm)
LDFLAGS += -lopenlibm

This is also something I failed to mention in the changelogs because I forgot about Makefile-based add-ins.
Lephenixnoir En ligne Administrateur Points: 20113 Défis: 143 Message

Citer : Posté le 07/06/2021 17:47 | #


Since there was a (probably heap-related) problem yesterday I tried to see if I could find anything suspicious in the Terrario code.

I briefly mentioned the chest deletion code on the shoutbox where the replacement index seems to be invalid because of the extra division, even though this doesn't look like it would cause heap problems.

The realloc calls look good to me. Note that in general when reducing the size of the array realloc will not move the data and simply reclaim the extra space (unless the new size is 0 obviously).

I checked the whole NPC and marker logic more times than I care to admit (which is at least five), but couldn't find a visible bug; references in both directions seem consistant, no code seems to re-use a pointer after a call that can reallocate it, and everything seems to be initialized properly.

I suggest maybe try and reproduce the problem to find a common denominator ?

Ajouté le 08/06/2021 à 13:37 :
Picking up from your answers in chat...

<KBD2> @Lephenixnoir It doesn't happen every time either
<KBD2> Though if it doesn't happen it will reliably occur the next time
<KBD2> Made a little menu to easily display a bunch of ints, all the pointers have expected values
<KBD2> I'm only using 11.5k of the heap, actually less than I thought
<KBD2> Crash is still happening in the same place, the compiled arena_gint.c
<KBD2> Something weird's happening - if I don't free anything, the pointers are in the exact same place next run and the crash still happens
<KBD2> Does gint free the heap on exit anyway?
<KBD2> (This is when it doesn't crash on exit)
<KBD2> Oh, just got a juicy bit of info for you
<KBD2> The crash happens when exiting after using the About menu
<KBD2> So nothing is allocated on the heap and the crash happens
<KBD2> It's a lot less consistent but still happens in the same place
<KBD2> https://github.com/KBD2/terrario/blob/14e163828e7ed6c910876ad06a9944719fffed47/src/menu.c#L404 Something in here will cause that same crash occasionally
<KBD2> It's unlikely, but both the game loop and that menu call dfont
<KBD2> Pretty much the only thing I can see that both those do but the main menu doesn't
<KBD2> Confirmed that it only happens after the About menu is used

Not only is that juicy, it's perfect! I've narrowed down the cause of the crash to displaying this confetti image and reproduced the problem in a trivial add-in that just shows it.

I further found a problem with the image rendering code. Basically, the image renderer accounted for the image going past the edge of VRAM on the side left but not on the right side. The confetti image overlapped past the right side (because it is padded to width 64), which caused writes past the end of each line since the renderer was not careful enough. This extra write affects the leftmost part of the next line (which is invisible on the VRAM due to to what values are being written), or, in the case of the last line, some other variable stored after.

When using the gray engine, some of the VRAMs are allocated in the heap, so the "other variable stored after" is as you know part of the data structure maintained by the heap; and I think you know where this is heading.

Here is the commit fixing the problem. It is quite funny to see how many buffer overflows the new heap (which has not had a bug yet) has already revealed.

I have rebuilt Terrario with the fix and could not reproduce the problem anymore. Due to the fix I have released a new gint version 2.5.2, which also includes moving all the standard functions provided by gint to fxlibc. Starting now, <gint/std/*.h> users are officially useless, and you can include standard headers directly instead.

Thank you for your patience with this issue, and finding the precise About menu problem.
Kbd2 En ligne Membre Points: 244 Défis: 0 Message

Citer : Posté le 08/06/2021 15:43 | # | Fichier joint


Update:
- Added house markers and NPCs
- Make a valid house with a chair, workbench, and torches that's at least 60 tiles large.
- Press TAN inside it to place a marker; NPCs looking to move in will automatically claim it during the day.
- The Guide has no requirements to move in, and the Nurse will move in once you have increased your maximum health.
- Made movement a bit smoother over terrain changes
- And loads of bugfixes.
Précédente 1, 2, 3 ··· 5, 6, 7, 8

LienAjouter une imageAjouter une vidéoAjouter un lien vers un profilAjouter du codeCiterAjouter un spoiler(texte affichable/masquable par un clic)Ajouter une barre de progressionItaliqueGrasSoulignéAfficher du texte barréCentréJustifiéPlus petitPlus grandPlus de smileys !
Cliquez pour épingler Cliquez pour détacher Cliquez pour fermer
Alignement de l'image: Redimensionnement de l'image (en pixel):
Afficher la liste des membres
:bow: :cool: :good: :love: ^^
:omg: :fusil: :aie: :argh: :mdr:
:boulet2: :thx: :champ: :whistle: :bounce:
valider
 :)  ;)  :D  :p
 :lol:  8)  :(  :@
 0_0  :oops:  :grr:  :E
 :O  :sry:  :mmm:  :waza:
 :'(  :here:  ^^  >:)

Σ π θ ± α β γ δ Δ σ λ
Veuillez donner la réponse en chiffre
Vous devez activer le Javascript dans votre navigateur pour pouvoir valider ce formulaire.

Si vous n'avez pas volontairement désactivé cette fonctionnalité de votre navigateur, il s'agit probablement d'un bug : contactez l'équipe de Planète Casio.

Planète Casio v42 © créé par Neuronix et Muelsaco 2004 - 2021 | Il y a 62 connectés | Nous contacter | Qui sommes-nous ? | Licences et remerciements

Planète Casio est un site communautaire non affilié à Casio. Toute reproduction de Planète Casio, même partielle, est interdite.
Les programmes et autres publications présentes sur Planète Casio restent la propriété de leurs auteurs et peuvent être soumis à des licences ou copyrights.
CASIO est une marque déposée par CASIO Computer Co., Ltd