Les membres ayant 30 points peuvent parler sur les canaux annonces, projets et hs du chat.
La shoutbox n'est pas chargée par défaut pour des raisons de performances. Cliquez pour charger.

Forum Casio - Autres questions


Index du Forum » Autres questions » Maybe small problem
Zaky202 Hors ligne Membre Points: 48 Défis: 0 Message

Maybe small problem

Posté le 20/10/2025 05:22

Hi guys , im trying to make a new program
main idea is 3D Engine
it run (.ve) file
.ve file = vertices + edges
And its a text format of course , should look like :
# Simple Cube
V
-1 -1 -1
-1 -1  1
-1  1 -1
-1  1  1
1 -1 -1
1 -1  1
1  1 -1
1  1  1
E
1 2
1 3
1 5
2 4
2 6
3 4
3 7
4 8
5 6
5 7
6 8
7 8


As you see Vertices are some (x,y,z) points, edges are some line drew between them.

In the casio add-in i use some projection to turn it 2D.

My problem : the code look fine, and complies well, but nothing works when transfer it to the calculater

all the build code as zip file : https://drive.google.com/file/d/1b-nFsRZMBSCLV4BtiZDfp80_Kfvfmoc_/view?usp=sharing

I used some AI i can't deny it , i'm a bad at C
So it will be nice if anyone could help me here.


Dark storm En ligne Labélisateur Points: 11650 Défis: 179 Message

Citer : Posté le 20/10/2025 10:04 | #


I do not have time to debug this, but the List_Push function looks unsafe and broken.
If the write fails, you still have updated the number of elements in your list.
Moreover you copy elements at position list->count * list->size but you want them to be at (list_count - 1) * list_size (when list_count = 1 you want to write at index 0).
What would be better is something like this:

int List_Push(list_t* list, void* item) {
    // If there are no elements in the list, allocate a new one
    if (list->count == 0) {
        list->items = malloc(list->size);
        if (list->items == NULL) return 1;
    }
    // If there are already some elements, reallocate the existing one
    else {
        list->items = realloc(list->items, (list->count + 1) * list->size);
        if (list->items == NULL) return 1;
    }

    // If the execution reach this, it means that allocation succeded
    memcpy((char*)((char*)(list->items) + (list->count * list->size)) - list->size, item, list->size);
    list->count++;
    return 0;
}


I did not compile it but it looks ok. You don't need those goto/labels BTW
Finir est souvent bien plus difficile que commencer. — Jack Beauregard
Zaky202 Hors ligne Membre Points: 48 Défis: 0 Message

Citer : Posté le 20/10/2025 10:17 | #


I use the list.c code just to make it easier for myself. I'm primarily a Python programmer and feel unfamiliar with C.

The list code works, and I've built a FxLinux add-in with it, and everything works. I think the problem is with the main.c file.
Lephenixnoir En ligne Administrateur Points: 25437 Défis: 174 Message

Citer : Posté le 20/10/2025 11:04 | # | Fichier joint


From warnings:

    list_t* ve_list;
    List_Init(ve_list, SCREEN);

You didn't allocate storage for a list_t, so you're writing to random things in the initialization code. It should be something like:

    list_t *ve_list = malloc(sizeof(list_t));
    List_Init(ve_list, SCREEN);

In general you could also allocate the list on the stack (list_t l; List_Init(&l);) but it's not applicable here because you want to return the list and you can't return the address of a local variable.

Other than this the code is quite complicated. There are way too many copies, conversions, etc. everywhere. Try to think about what data you're using and why you need to copy it all the time. The file access code was super complicated due to a mix of BFile and not BFile (not particularly your fault). Ultimately the cause of the problem was that your opendir() didn't filter for .ve files so you were opening the wrong thing.

Attached is an archive with a working build (I get a cube from the example, at least) with all the BFile code removed and the rest hopefully quite simplified. Notice how the only copies in the entire file management code are for copying the list of entries and concatenating the folder and file paths.
Mon graphe (27 Juin): (MQ || Rogue Life) ; serial gint ; passe gint 3 ; Azur ; ...) || (shoutbox v5 ; v5)
Zaky202 Hors ligne Membre Points: 48 Défis: 0 Message

Citer : Posté le 20/10/2025 11:19 | #


I modified the list definition.
The program still gives me a blank white screen. Did it work for you? Can you share it?
Sorry for the inconvenience.
Lephenixnoir En ligne Administrateur Points: 25437 Défis: 174 Message

Citer : Posté le 20/10/2025 11:56 | #


Please check the archive attached to my previous message (on the top right, "Fichier joint"), which contains the code I modified
Mon graphe (27 Juin): (MQ || Rogue Life) ; serial gint ; passe gint 3 ; Azur ; ...) || (shoutbox v5 ; v5)
Zaky202 Hors ligne Membre Points: 48 Défis: 0 Message

Citer : Posté le 20/10/2025 12:57 | #


Lephenixnoir a écrit :
Please check the archive attached to my previous message (on the top right, "Fichier joint"), which contains the code I modified


oh found it thanks.

model didn't work, but files is fine, i will do some debugging
Zaky202 Hors ligne Membre Points: 48 Défis: 0 Message

Citer : Posté le 20/10/2025 13:04 | #


Now its Wooooooooooooooooooooooooooooooooooooorks

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 v4.3 © créé par Neuronix et Muelsaco 2004 - 2025 | Il y a 88 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