PB d'appel de procédure

Sujets variés concernant le développement en PureBasic
KarLKoX
Messages : 1191
Inscription : jeu. 26/févr./2004 15:36
Localisation : France
Contact :

PB d'appel de procédure

Message par KarLKoX »

Bonjour :)
Cette fois ci à mois de vous embêter et je doit que je suis façe à un problème vraiement incompréhensible (pour moi :oops: )
Je suis en train de porter une bibliothèque de lecture de MOD (soundtracking) en PureBasic, tout se passait bien, je l'ai "pensé" en orienté objet (pour le fun ).
Mon problème arrive lorsque je tente d'appeler une fonction, je vous donne ce dont vous avez besoin :

Code : Tout sélectionner

Structure INSTRUMENT
  name.s[22]
  samples.l
  volume.l
  finetune.l
  loopStart.l
  loopLength.l
  
  ; private
  sampleLen.w
  
  *toString.l
EndStructure

Structure NOTE
  period.l
  Instrument.l
  effect.l
  effectP.l
  effectP1.l
  effectP2.l
  
  *toString.l
EndStructure

Structure PATTERN
  rows.l
  channels.l
  *pData.l
  
  *getNote.l
EndStructure

Structure CHANNEL
  *Note.NOTE
  *Module.l               ; BUGFIX !!!
  *Instrument.INSTRUMENT
  *Assigned.INSTRUMENT
  mixVol.f
  mixPan.f
  mixPitch.f
  samplePos.f
  loopRow.l
  loopCount.l
  volume.l
  period.l
  porta.l
  counter.l
  portaP.l
  vibSpeed.l
  vibDepth.l
  tremSpeed.l
  tremDepth.l
  vibrato.l
  tremolo.l
  defaultPanning.f
  tunning.f
  arpeggio.f
  
  *reset.l
  *row.l
  *tick.l
  *updateVibrato.l
  *updateTremolo.l
  *trigger.l
  *tickUpdate.l
EndStructure

#PAL_CPU  = 7093789
#NTSC_CPU = 7159090
Structure MODULE
  name.s
  format.s
  pal.b
  channels.CHANNEL[4]
  instruments.INSTRUMENT[32]
  *patterns.PATTERN[1]             ; will be dynamicly reallocated
  sequences.l[128]
  songLength.l
  restart.l
  defaultBPM.l
  defaultTempo.l
  
  *getTickTime.l
  *getPitch.l
  *toString.l
EndStructure

Structure SEQUENCER
  *Module.MODULE
  channels.CHANNEL[4]
  position.l
  row.l
  tick.l
  tempo.l
  bpm.l
  
  *reset.l
  *getTickTime.l
  *tick.l
  *setrow.l
EndStructure

; Contenu de Sequencer.pb, la ou il y a le problème

Procedure dummy()
  PrintN("DUMMY")
EndProcedure

Procedure PBMOD_SequencerSetRow(*This.SEQUENCER, row.l)
  OnErrorGosub(?CatchError)
  
  *This\row  = row
  *This\tick = *This\tempo
  *Pattern.PATTERN = *This\Module\patterns + (*This\Module\sequences[*This\position] * SizeOf(PATTERN) )
  For c = 0 To 3
    *n.note = *This\channels[c]\Note
    *channel.CHANNEL = *This\channels[c]
    PrintN("PBMOD_SequencerSetRow::SEQUENCER DEBUT")
    ; Appel via les pointeurs sur fonction
    CallFunctionFast(*Pattern\getNote, *Pattern, *n, row, c)    ; OK
    START_CODE:    
    CallFunctionFast(*channel\row, *channel) ; BUG !! FIXME
    END_CODE:    
    ; Appel via les procédure :
    ;PBMOD_PatternGetNote(*Pattern, *n, row, c)                 ; OK
    ;PBMOD_ChannelRow(*channel)                                 ; BUG !! FIXME
    ;Dummy()                                                                 ; BUG aussi !
    PrintN("PBMOD_SequencerSetRow::SEQUENCER FIN")              
    ; Set speed
    If (*n\effect = $F)
      If (*n\effectP < 32)
        *This\tick  = *n\effectP
        *This\tempo = *n\effectP
      Else
        *This\bpm   = *n\effectP
      EndIf
    EndIf
  Next c
  
  For c = 0 To 3
    *n.note = *This\channels[c]\Note
    If (*n\effect = $E And *n\effectP1 = $E)
      ; Pattern delay
      *This\tick  = *This\tempo + *This\tempo * (*n\effectP2)
    EndIf
  Next c

  CatchError:
  Msg$ = "There was an error:"+Chr(13)+Chr(10)+Chr(13)+Chr(10)
  Msg$ + "Description: " + GetErrorDescription()+Chr(13)+Chr(10)
  Msg$ + "Total number of errors: "+Str(GetErrorCounter())+Chr(13)+Chr(10)+Chr(13)+Chr(10)
  Msg$ + "The program will end now."
  
  ASMCounter=0             
  ASMPointer = ?START_CODE 
  
  Repeat
    ASMPointer=DisASMCommand(ASMPointer)
    Debug GetDisASMString()
    ASMCounter+1
  Until ASMPointer=?END_CODE
  
  MessageRequester("Error!", Msg$)
  End
    
EndProcedure

; Contenu de Channel.pb, la ou se trouve la fonction que je tente d'appeler 

Procedure PBMOD_ChannelRow(*This.CHANNEL)
; Je ne met pas le contenu car je n'arrive même pas ici
[..]
EndProcedure
Le problème intervient apres mon appel GetNote (via la procédure ou le pointeur sur fonction qui, toutes deux, fonctionnent parfaitement) : que j'appel la fonction Row via le pointeur sur fonction ou via la procédure, le programme s'arrête.
Le débugger me dit qu'il y a eu une tentative d'acces à un processus qui ne le permet pas (traduction approximative).
Le désassembleur me compte deux erreurs et me sort :

Code : Tout sélectionner

PUSH 0C000093
CALL 00409103
PUSH dword [esp+14]
MOV Ebp,[esp+18]
CALL 004091DA
MOV Eax,[ebp+64]
CALL 0040C3CC
N'ayant que les bases en asm (et ne voyant aucune erreur), je ne comprend pas mon problème.
Désolé pour la longueur du code mais je pense que cela permetra une meilleur compréhension du code :)
Merci à tous ceux qui m'auront lu jusqu'au bout et un "hip hip hip ? Hourra" à qui résoudra mon problème :D
D'avance merci.
"Qui baise trop bouffe un poil." P. Desproges
Dr. Dri
Messages : 2527
Inscription : ven. 23/janv./2004 18:10

Message par Dr. Dri »

Y'a pâs les interfaces pour tout ce qui est objet ?
J'ai pas l'aide sous la main et je ne m'en suis jamais servi...

Dri
KarLKoX
Messages : 1191
Inscription : jeu. 26/févr./2004 15:36
Localisation : France
Contact :

Message par KarLKoX »

Non en fait c'est pas une interface ou quoi que ce soit mais le côde a été pensé objet (instanciation d'"objet", aucune variable globale, pointeur sur fonction équivalent aux fonctions membres) mais ce n'est pas un objet com.
J'ai oublié de préciser que si je ne debugg pas mon programme je n'ai pas de plantage, le programme s'arrête.
Merci de m'avoir répondu néanmoins :)
"Qui baise trop bouffe un poil." P. Desproges
Répondre