[hatari-devel] Wotanoid problem : Malloc ?

Laurent Sallafranque laurent.sallafranque at free.fr
Sat Jan 23 18:36:02 CET 2010


Would it be the Malloc gemdos function that gives problems ?
(I haven't founf where it is implemented in Hatari) (gemdos.c ?)

Here is the Gemdos trace
 

GEMDOS Fopen("data\bat.cmc", 0x2)
conv data\bat.cmc -> 
/media/Jeux/Jeux/Atari/DiskDur/Jeux/Falcon/WOTANOID/DATA/BAT.CMC
-> FD 0 (read/write)
GEMDOS Fread(64, -1, 0x16c70c)
GEMDOS Fclose(64)
GEMDOS call 0x4C (Pterm)
GEMDOS call 0x49 (Mfree)
GEMDOS call 0x49 (Mfree)
GEMDOS call 0x48 (Malloc)
GEMDOS call 0x48 (Malloc)
GEMDOS call 0x49 (Mfree)
GEMDOS call 0x49 (Mfree)
GEMDOS call 0x48 (Malloc)
GEMDOS call 0x48 (Malloc)
GEMDOS call 0x48 (Malloc)
GEMDOS call 0x48 (Malloc)
GEMDOS call 0x48 (Malloc)
GEMDOS call 0x48 (Malloc)
GEMDOS call 0x19 (Dgetdrv)
GEMDOS Dsetdrv(0x2)
GEMDOS call 0x19 (Dgetdrv)
GEMDOS Dsetdrv(0x2)
GEMDOS call 0x19 (Dgetdrv)
GEMDOS Dsetdrv(0x2)
GEMDOS call 0x48 (Malloc)




Laurent Sallafranque a écrit :
> In complement, when code arrives il Load_file, registers are llike this :
>
> > cpureg                                                               
> D0: 00070000 D1: 00000001 D2: ffff0000 D3: 00000000                    
> D4: 00010000 D5: 00000000 D6: fffe0001 D7: 00000000                    
> A0: 0003a028 A1: 0016c70c A2: 000445b0 A3: 00000000                    
> A4: 0003dbec A5: 0002e0d4 A6: 00dc16c6 A7: 00dc16b0                    
> USP=00dc16f2 ISP=00dc16b0 MSP=00000000 VBR=00000000                    
> T=00 S=1 M=0 X=0 N=0 Z=0 V=0 C=0 IMASK=3                               
> FP0: 0 FP1: 0 FP2: 0 FP3: 0                                            
> FP4: 0 FP5: 0 FP6: 0 FP7: 0
> N=0 Z=0 I=0 NAN=0
> prefetch 6100d7e0
> 0002e630: 48e7 fffe 203c ffff ffff MVMLE.L #$fffe,-(A7)
> next PC: 0002e634
>
>
> (A0)
> 03A028: 64 61 74 61 5c 62 61 74 2e 63 6d 63 00 64 61 74   
> data\bat.cmc.dat
> 03A038: 61 5c 6f 70 74 69 6f 6e 73 2e 63 6d 63 00 00 00   
> a\options.cmc...
>
> Hope this helps
>
> Regards
>
> Laurent
>
>
>
> Laurent Sallafranque a écrit :
>> Hello,
>>
>> I've add a look at Wotanoid (falcon).
>> The problem is absolutely not a DSP problem here.
>> I've disassembled the 68030 code with desert drain.
>> (I can send it to you if needed)
>>
>> the program goes wrong in the following part of code.
>> (don't try to read it all, I'll explain what I think goes wrong).
>>
>> I think the problem comes from the Load_file function (see code below)
>>
>> Just after, it does a "depack", and goes to "prepare_un_sprite_cmc".
>> The problem is here because D2 (used for the loop) starts with value 
>> -1 ($ffffffff)
>>
>> D2 comes from D1 (move D1, D2)
>> D1 is saved by the movem.l (just after recale_adr:)
>> D1 comes from the depack routine (just after the load_file).
>>         ok59:                 lea         (A1),A0
>>             cmpi.l      #$434D5030,(A0)+
>>             move.l      (A0)+,D1
>>
>> If the load_file is wrong, the depack will depack wrong.
>>
>> The load file contains 3 TRAP #1 (I don't know what to do with that).
>> But I think this part is related to hatari/host computer code.
>>
>> That's why I think the problem is here.
>>
>> As there are many programs that loop until they reach the ROM 
>> addresses, I think
>> this problem would let more programs to run.
>>
>> Any comment here ?
>>
>> Best regards,
>>
>> Laurent
>>
>>
>>
>> Load_cmc:             movem.l     D0-A6,-(SP)
>>             move.l      #-1,D0
>>             bsr.w       Load_file
>>             lea         (A1),A0
>>             lea         $7D00(A0),A1
>>             move.l      4(A0),D3
>>             bsr.w       depack
>>             bra.b       ok59
>> use_cmp:              movem.l     D0-A6,-(SP)
>> ok59:                 lea         (A1),A0
>>             cmpi.l      #$434D5030,(A0)+
>>             move.l      (A0)+,D1
>>             move.w      D1,D2
>>             addq.l      #1,D1
>>             lea         (A0),A3
>>             lea         0(A3,D1.w*4),A0
>>             move.l      A0,D7
>> recale_adr:
>>             add.l       D7,0(A3,D2.w*4)
>>             dbra        D2,recale_adr
>>             movem.l     D0-D2/A0,-(SP)
>>             move.l      D3,D0
>>             subq.l      #1,D1
>>             movea.l     A2,A0
>>             move.w      #1,D2
>>             bsr.w       Malloc
>>             movea.l     A0,A1
>>             move.l      D0,D3
>>             movem.l     (SP)+,D0-D2/A0
>>             movea.l     A1,A4
>>             move.w      D1,D2
>>             subq.w      #2,D2
>> prepare_un_sprite_cmc: A1,(A2)+
>>             movea.l     (A3)+,A0
>>             bsr.w       prep_tmx_plus
>>             movea.l     4(A1),A1
>>             dbra        D2,prepare_un_sprite_cmc
>>             suba.l      A4,A1
>>             move.l      A1,D1
>>             move.l      D3,D0
>>             bsr.w       Mshrink
>>             movem.l     (SP)+,D0-A6
>>             rts       
>>
>> -----------> Here is the Load_file function <------------------------
>>
>> Load_file: movem.l     D1/D2/A0-A2,-(SP)
>>             lea         (A1),A2
>>             move.l      D0,D2
>>             move.w      #2,-(SP)
>>             move.l      A0,-(SP)
>>             move.w      #$3D,-(SP)
>>             trap        #1          ;Fopen
>>             addq.l      #8,SP
>>             move.w      D0,handle2
>>             move.l      A2,-(SP)
>>             move.l      D2,-(SP)
>>             move.w      D0,-(SP)
>>             move.w      #$3F,-(SP)
>>             trap        #1          ;Fread
>>             adda.l      #12,SP
>>             move.l      D0,-(SP)
>>             move.w      handle2,-(SP)
>>             move.w      #$3E,-(SP)
>>             trap        #1          ;Fclose
>>             addq.l      #4,SP
>>             move.l      (SP)+,D0
>>             movem.l     (SP)+,D1/D2/A0-A2
>>             rts       
>>
>> _______________________________________________
>> hatari-devel mailing list
>> hatari-devel at lists.berlios.de
>> https://lists.berlios.de/mailman/listinfo/hatari-devel
>>
>>
>>   
>
>
>




More information about the hatari-devel mailing list