SDCC and header files or constant values

Страница 1/2
| 2

By jepmsx

Champion (281)

Аватар пользователя jepmsx

01-11-2022, 21:07

Hi!

Is there any limitation in the static constant values that can be defined in a header file to be used in SDCC?

I've had some poltergeist while developing a game in SDCC. In a header file I have all the definitions of sprites defined using static const unsigned int sprite_name[] and it has worked without a problem. But recently, I added a few more definitions of sprites and depending where I use these news values in the main function I get different behaviors: some times there are no sprites on the screen, other times the system resets and other times it works well.

My guess is that the problem is with the header file. Has someone found something similar? What am I doing wrong?

Для того, чтобы оставить комментарий, необходимо регистрация или !login

By geijoenr

Champion (391)

Аватар пользователя geijoenr

01-11-2022, 21:46

Are you building a ROM?

When you define a variable as const, it goes into the CODE or HOME segment. As long as it does not spill over into RAM it should be fine, but you need to make sure this doesn't happen by checking the *.map file in the output of the linker.

It would be good if you copy over the map file here so that we can see what is going on.

By aoineko

Paragon (1138)

Аватар пользователя aoineko

01-11-2022, 22:07

jepmsx wrote:

In a header file I have all the definitions of sprites defined using static const unsigned int sprite_name[] and it has worked without a problem.

Why seting your data as static? I see no need for your case.
unsigned int is 16-bits. Is this intentional? Otherwise, it doubles the size of your data.

Apart from that, as geijoenr says, look in your .map file to see where your data is.
If you make a 32 KB ROM for example, you have to make sure that all your code and constant data are between 4000h and BFFFh and that your variables are at addresses above C000h.

By jepmsx

Champion (281)

Аватар пользователя jepmsx

02-11-2022, 07:02

Thanks a lot for you answers.

I'm building a COM game using FUSION-C library. I thought that I wouldn't need to worry about memory mapping until the game would be bigger than 64K.

I'm using unsigned int because the definition of the function that defines 16x16 sprites in Fusion-C uses it. And I'm using static because I didn't want it to change value in different function spaces, and I think that const definition didn't compile.

The map that works is:

ASxxxx Linker V03.00 + NoICE + sdld,  page 1.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
.  .ABS.                            00000000    00000000 =           0. bytes (ABS,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
     00000000  .__.ABS.                           
     00000000  l__CABS                         
     00000000  l__DABS                         
     00000000  l__HEADER                       
     00000000  l__HEAP                         
     00000000  l__HOME                         
     00000000  s__CABS                         
     00000000  s__DABS                         
     00000000  s__HEADER                       
     00000000  s__HEADER0                      
     00000001  l__GSFINAL                      
     00000006  l__HEADER0                      
     00000007  l__INITIALIZER                  
     00000009  l__INITIALIZED                  
     0000000F  l__GSINIT                       
     00000020  l__XDATA                        
     00000106  s__CODE                         
     000045B3  l__CODE                         
     000046B9  s__DATA                         
     00005F2F  l__DATA                         
     0000A5E8  s__INITIALIZED                  
     0000A5F1  s__GSINIT                       
     0000A5F1  s__HOME                         
     0000A600  s__GSFINAL                      
     0000A601  s__INITIALIZER                  
     0000A608  s__HEAP                         
     0000A608  s__XDATA                        
ASxxxx Linker V03.00 + NoICE + sdld,  page 2.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_CODE                               00000106    000045B3 =       17843. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
     0000011D  _WAIT                              sc7brick
     00000410  _paleta_patrons                    sc7brick
     00000550  _sprites_estats                    sc7brick
     00000564  _pos_nums                          sc7brick
     0000057A  _vectzero                          sc7brick
     000008FE  _cara                              sc7brick
     0000097E  _posa_puntuacio                    sc7brick
     00000A32  _pinta_vides                       sc7brick
     00000A89  _pinta_numero_level                sc7brick
     00000ADF  _puc_esquerra                      sc7brick
     00000BF1  _puc_caure_esquerra                sc7brick
     00000C3B  _puc_dreta                         sc7brick
     00000D55  _puc_caure_dreta                   sc7brick
     00000D9F  _puc_caure_dreta_mirantEsq         sc7brick
     00000DE9  _calcula_pos_car_principal         sc7brick
     00001417  _calcula_pos_mao                   sc7brick
     000015DD  _init_sprites                      sc7brick
     000017DC  _FT_SetName                        sc7brick
     000018FC  _FT_errorHandler                   sc7brick
     000019B4  _FT_LoadSc5Image                   sc7brick
     00001A65  _FT_LoadPalette                    sc7brick
     00001BF2  _FT_openFile                       sc7brick
     00001C1C  _init_pantalla_joc                 sc7brick
     00001CDC  _esborrar_pantalla_joc             sc7brick
     00001D0B  _canvi_nivell                      sc7brick
     000024EF  _gameOver                          sc7brick
     0000265D  _main                              sc7brick
     00002BED  _ompleCapcaleraPatrons             FM_MBM
     00002C3A  _notesFreq                         FM_MBM
     00002C46  _WriteOPLLreg                      FM_MBM
     00002C5B  _PlayNote                          FM_MBM
     00002CA8  _PlayBend                          FM_MBM
     00002D2A  _seguentPatro                      FM_MBM
     00002D87  _canviDrumset                      FM_MBM
     00002DEA  _InicialitzemCanalsReproductor     FM_MBM
     00002F3A  _playPatro                         FM_MBM
     000036E9  _apaguemOPLL                       FM_MBM
     00003725  _Cls                               
     00003736  _Sprite32Bytes                     
     00003768  _rand                              rand
     00003815  _srand                             rand
     00003848  _HMMC                              hmmc
     000038D8  _HMMM                              hmmm
     00003937  _GetTime                           
     00003960  _PutSprite                         putsprite
     000039C1  _SpriteSmall                       
     000039D5  _InitFX                            
     000039D5  _StopFX                            
     00003A18  _UpdateFX                          
     00003B27  _PlayFX                            
ASxxxx Linker V03.00 + NoICE + sdld,  page 3.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_CODE                               00000106    000045B3 =       17843. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
     00003BA4  _SetPalette                        
     00003BD9  _RestorePalette                    
     00003C1E  _SetColorPalette                   
     00003C4C  _SpriteOff                         
     00003C68  _SpriteOn                          
     00003C84  _SpriteReset                       
     00003C95  _WaitKey                           
     00003CA9  _SetVDPread                        
     00003CB1  _SetVDPwrite                       
     00003CE8  _SetSpritePattern                  setspritepattern
     00003D18  _SetSpriteColors                   setspritepattern
     00003D4A  _FcbRead                           
     00003D6D  _InitVDPInterruptHandler           
     00003DA9  _EndVDPInterruptHandler            
     00003DD7  _Point                             point
     00003E2A  _Print                             print
     00003E59  _Rkeys                             
     00003E62  _Fkeys                             
     00003E7E  _printf                            printf
     00003E96  _sprintf                           printf
     00004217  _CopyRamToVram                     copyramtovram
     00004279  ___sdcc_enter_ix                   
     00004283  _Exit                              
     0000428A  _FcbOpen                           
     0000429B  _FcbCreate                         
     000042BC  __modschar                         
     000042C9  __modsint                          
     000042D5  _Sprite16                          
     000042E9  _SetColors                         
     00004312  ___itoa                            
     00004343  ___uitoa                           
     000043F4  _Screen                            
     00004415  __divsint                          
     0000441E  __divschar                         
     00004425  __div8                             
     00004429  __div_signexte                     
     0000442D  __div16                            
     00004453  __get_remainder                    
     0000445D  ___ltoa                            
     000044A1  ___ultoa                           
     0000457D  ___uitobcd                         
     000045B4  ___ultobcd                         
     00004628  ___strreverse                      
     0000462E  ___strreverse_reg                  
     0000463E  __divuint                          
     00004646  __divuchar                         
     0000464D  __divu8                            
     00004650  __divu16                           
     0000468A  _PrintChar                         
     0000469C  _bchput                            
     000046AE  _putchar                           
ASxxxx Linker V03.00 + NoICE + sdld,  page 4.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_CODE                               00000106    000045B3 =       17843. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
     000046AE  _putchar_rr_s                      
     000046B3  _putchar_rr_dbs                    

ASxxxx Linker V03.00 + NoICE + sdld,  page 5.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_DATA                               000046B9    00005F2F =       24367. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
     000046DE  _LDbuffer                          sc7brick
     00005ADE  _ayFX_Bank                         sc7brick
     00005F42  _struct_car_principal              sc7brick
     00005F4B  _struct_car_secundari              sc7brick
     00005F54  _struct_mao                        sc7brick
     00005F5C  _nivell                            sc7brick
     00005F5D  _puntuacio                         sc7brick
     00005F5F  _debug_stop                        FM_MBM
     00005F60  _tempo                             FM_MBM
     00005F61  _copsInterrupcio                   FM_MBM
     00005F62  _filera                            FM_MBM
     00005F63  _capcalera                         FM_MBM
     000060DB  _songFile                          FM_MBM
     0000A4BB  _ordrePatrons                      FM_MBM
     0000A583  _posSong                           FM_MBM
     0000A584  _posPatro                          FM_MBM
     0000A586  _notaTocantCanal                   FM_MBM
     0000A5A4  _brightness_inst_orig              FM_MBM
     0000A5A5  _debug_byteLlegit                  FM_MBM

ASxxxx Linker V03.00 + NoICE + sdld,  page 6.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_INITIALIZED                        0000A5E8    00000009 =           9. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
     0000A5EA  _temps_entre_maons                 sc7brick
     0000A5EB  _heap_top                          

ASxxxx Linker V03.00 + NoICE + sdld,  page 7.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_GSINIT                             0000A5F1    0000000F =          15. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
ASxxxx Linker V03.00 + NoICE + sdld,  page 8.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_GSFINAL                            0000A600    00000001 =           1. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
ASxxxx Linker V03.00 + NoICE + sdld,  page 9.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_INITIALIZER                        0000A601    00000007 =           7. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
ASxxxx Linker V03.00 + NoICE + sdld,  page 10.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_HEADER0                            00000000    00000006 =           6. bytes (ABS,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
ASxxxx Linker V03.00 + NoICE + sdld,  page 11.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_HEAP                               0000A608    00000000 =           0. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
     0000A608  _HEAP_start                        

ASxxxx Linker V03.00 + NoICE + sdld,  page 12.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_XDATA                              0000A608    00000020 =          32. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
ASxxxx Linker V03.00 + NoICE + sdld,  page 13.

Files Linked                              [ module(s) ]

sc7brick.rel                              [ sc7brick ]
./fusion-c/include/crt0_msxdos.rel        [  ]
FM_MBM.rel                                [ FM_MBM ]


Libraries Linked                          [ object file ]

./fusion-c/source/lib/fusion.lib          [ cls.rel ]
./fusion-c/source/lib/fusion.lib          [ sprite32bytes.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ rand.rel ]
./fusion-c/source/lib/fusion.lib          [ hmmc.rel ]
./fusion-c/source/lib/fusion.lib          [ hmmm.rel ]
./fusion-c/source/lib/fusion.lib          [ gettime.rel ]
./fusion-c/source/lib/fusion.lib          [ putsprite.rel ]
./fusion-c/source/lib/fusion.lib          [ spritesmall.rel ]
./fusion-c/source/lib/fusion.lib          [ ayfxDriver.rel ]
./fusion-c/source/lib/fusion.lib          [ Set_Palette.rel ]
./fusion-c/source/lib/fusion.lib          [ spriteoff.rel ]
./fusion-c/source/lib/fusion.lib          [ spritereset.rel ]
./fusion-c/source/lib/fusion.lib          [ waitkey.rel ]
./fusion-c/source/lib/fusion.lib          [ setvdp.rel ]
./fusion-c/source/lib/fusion.lib          [ setspritepattern.rel ]
./fusion-c/source/lib/fusion.lib          [ fcbread.rel ]
./fusion-c/source/lib/fusion.lib          [ interrupt_vdp.rel ]
./fusion-c/source/lib/fusion.lib          [ point.rel ]
./fusion-c/source/lib/fusion.lib          [ print.rel ]
./fusion-c/source/lib/fusion.lib          [ keyboardread.rel ]
./fusion-c/source/lib/fusion.lib          [ printf.rel ]
./fusion-c/source/lib/fusion.lib          [ copyramtovram.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ crtenter.rel ]
./fusion-c/source/lib/fusion.lib          [ exitdos.rel ]
./fusion-c/source/lib/fusion.lib          [ fcbopen.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ modsigned.rel ]
./fusion-c/source/lib/fusion.lib          [ sprite16.rel ]
./fusion-c/source/lib/fusion.lib          [ setcolors.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ __itoa.rel ]
./fusion-c/source/lib/fusion.lib          [ screen.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ divsigned.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ __ltoa.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ __uitobcd.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ __ultobcd.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ __strreverse.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ divunsigned.rel ]
./fusion-c/source/lib/fusion.lib          [ printchar.rel ]
./fusion-c/source/lib/fusion.lib          [ putcharrrdos.rel ]

ASxxxx Linker V03.00 + NoICE + sdld,  page 14.

User Base Address Definitions

_CODE = 0x0106
_DATA = 0x0000

And the one that doesn't work is:

ASxxxx Linker V03.00 + NoICE + sdld,  page 1.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
.  .ABS.                            00000000    00000000 =           0. bytes (ABS,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
     00000000  .__.ABS.                           
     00000000  l__CABS                         
     00000000  l__DABS                         
     00000000  l__HEADER                       
     00000000  l__HEAP                         
     00000000  l__HOME                         
     00000000  s__CABS                         
     00000000  s__DABS                         
     00000000  s__HEADER                       
     00000000  s__HEADER0                      
     00000001  l__GSFINAL                      
     00000006  l__HEADER0                      
     00000007  l__INITIALIZER                  
     00000009  l__INITIALIZED                  
     0000000F  l__GSINIT                       
     00000020  l__XDATA                        
     00000106  s__CODE                         
     00004C6D  l__CODE                         
     00004D73  s__DATA                         
     00005F71  l__DATA                         
     0000ACE4  s__INITIALIZED                  
     0000ACED  s__GSINIT                       
     0000ACED  s__HOME                         
     0000ACFC  s__GSFINAL                      
     0000ACFD  s__INITIALIZER                  
     0000AD04  s__HEAP                         
     0000AD04  s__XDATA                        
ASxxxx Linker V03.00 + NoICE + sdld,  page 2.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_CODE                               00000106    00004C6D =       19565. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
     0000011D  _WAIT                              sc7brick
     00000410  _paleta_patrons                    sc7brick
     00000550  _sprites_estats                    sc7brick
     00000564  _pos_nums                          sc7brick
     0000057A  _vectzero                          sc7brick
     000008FE  _cara                              sc7brick
     0000097E  _posa_puntuacio                    sc7brick
     00000A32  _pinta_vides                       sc7brick
     00000A89  _pinta_numero_level                sc7brick
     00000ADF  _puc_esquerra                      sc7brick
     00000BF1  _puc_caure_esquerra                sc7brick
     00000C3B  _puc_dreta                         sc7brick
     00000D55  _puc_caure_dreta                   sc7brick
     00000D9F  _puc_caure_dreta_mirantEsq         sc7brick
     00000DE9  _calcula_pos_car_principal         sc7brick
     00001417  _calcula_pos_mao                   sc7brick
     000015DD  _init_sprites                      sc7brick
     000017DC  _FT_SetName                        sc7brick
     000018FC  _FT_errorHandler                   sc7brick
     000019B4  _FT_LoadSc5Image                   sc7brick
     00001A65  _FT_LoadPalette                    sc7brick
     00001BF2  _FT_openFile                       sc7brick
     00001C1C  _init_pantalla_joc                 sc7brick
     00001CDC  _esborrar_pantalla_joc             sc7brick
     00001D0B  _canvi_nivell                      sc7brick
     000024EF  _gameOver                          sc7brick
     0000265D  _main                              sc7brick
     00002C16  _ompleCapcaleraPatrons             FM_MBM
     00002C63  _notesFreq                         FM_MBM
     00002C6F  _WriteOPLLreg                      FM_MBM
     00002C84  _PlayNote                          FM_MBM
     00002CD1  _PlayBend                          FM_MBM
     00002D53  _seguentPatro                      FM_MBM
     00002DB0  _canviDrumset                      FM_MBM
     00002E13  _InicialitzemCanalsReproductor     FM_MBM
     00002F63  _playPatro                         FM_MBM
     00003712  _apaguemOPLL                       FM_MBM
     0000374E  _Cls                               
     0000375F  _Sprite32Bytes                     
     00003791  _rand                              rand
     0000383E  _srand                             rand
     00003871  _HMMC                              hmmc
     00003901  _HMMM                              hmmm
     00003960  _GetTime                           
     00003989  _Pattern16RotationRam              PatternTransform
     00003AD5  _shift                             PatternTransform
     00003AE5  _Pattern16RotationVram             PatternTransform
     00003B91  _Pattern8RotationVram              PatternTransform
     00003C0E  _Pattern8RotationRam               PatternTransform
     00003CD0  _Pattern8FlipRam                   PatternTransform
ASxxxx Linker V03.00 + NoICE + sdld,  page 3.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_CODE                               00000106    00004C6D =       19565. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
     00003D28  _Pattern16FlipRam                  PatternTransform
     00003DC8  _Pattern16FlipVram                 PatternTransform
     00003E8B  _Pattern8FlipVram                  PatternTransform
     00003F05  _PutSprite                         putsprite
     00003F66  _SpriteSmall                       
     00003F7A  _PatternHFlip                      patternhflip
     00003FAC  _InitFX                            
     00003FAC  _StopFX                            
     00003FEF  _UpdateFX                          
     000040FE  _PlayFX                            
     0000417B  _SetPalette                        
     000041B0  _RestorePalette                    
     000041F5  _SetColorPalette                   
     00004223  _SpriteOff                         
     0000423F  _SpriteOn                          
     0000425B  _MemCopy                           
     0000427D  _SpriteReset                       
     0000428E  _WaitKey                           
     000042A2  _PatternVFlip                      patternvflip
     000042C5  _SetVDPread                        
     000042CD  _SetVDPwrite                       
     00004304  _SetSpritePattern                  setspritepattern
     00004334  _SetSpriteColors                   setspritepattern
     00004366  _FcbRead                           
     00004389  _InitVDPInterruptHandler           
     000043C5  _EndVDPInterruptHandler            
     000043F3  _Point                             point
     00004446  _Print                             print
     00004475  _Rkeys                             
     0000447E  _Fkeys                             
     0000449A  _printf                            printf
     000044B2  _sprintf                           printf
     00004833  _CopyVramToRam                     copyvramtoram
     00004896  _CopyRamToVram                     copyramtovram
     000048F8  ___sdcc_enter_ix                   
     00004902  _Exit                              
     00004909  _FcbOpen                           
     0000491A  _FcbCreate                         
     0000493B  __modschar                         
     00004948  __modsint                          
     00004954  _Sprite16                          
     00004968  _SetColors                         
     00004991  ___itoa                            
     000049C2  ___uitoa                           
     00004A73  _Screen                            
     00004A94  __divsint                          
     00004A9D  __divschar                         
     00004AA4  __div8                             
     00004AA8  __div_signexte                     
     00004AAC  __div16                            
     00004AD2  __get_remainder                    
ASxxxx Linker V03.00 + NoICE + sdld,  page 4.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_CODE                               00000106    00004C6D =       19565. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
     00004ADC  ___ltoa                            
     00004B20  ___ultoa                           
     00004BFC  ___uitobcd                         
     00004C33  ___ultobcd                         
     00004CA7  _PatternRotation                   patternrotation
     00004CE2  ___strreverse                      
     00004CE8  ___strreverse_reg                  
     00004CF8  __divuint                          
     00004D00  __divuchar                         
     00004D07  __divu8                            
     00004D0A  __divu16                           
     00004D44  _PrintChar                         
     00004D56  _bchput                            
     00004D68  _putchar                           
     00004D68  _putchar_rr_s                      
     00004D6D  _putchar_rr_dbs                    
ASxxxx Linker V03.00 + NoICE + sdld,  page 5.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_DATA                               00004D73    00005F71 =       24433. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
     00004D98  _LDbuffer                          sc7brick
     00006198  _ayFX_Bank                         sc7brick
     000065FC  _struct_car_principal              sc7brick
     00006605  _struct_car_secundari              sc7brick
     0000660E  _struct_mao                        sc7brick
     00006616  _nivell                            sc7brick
     00006617  _puntuacio                         sc7brick
     00006619  _debug_stop                        FM_MBM
     0000661A  _tempo                             FM_MBM
     0000661B  _copsInterrupcio                   FM_MBM
     0000661C  _filera                            FM_MBM
     0000661D  _capcalera                         FM_MBM
     00006795  _songFile                          FM_MBM
     0000AB75  _ordrePatrons                      FM_MBM
     0000AC3D  _posSong                           FM_MBM
     0000AC3E  _posPatro                          FM_MBM
     0000AC40  _notaTocantCanal                   FM_MBM
     0000AC5E  _brightness_inst_orig              FM_MBM
     0000AC5F  _debug_byteLlegit                  FM_MBM
     0000AC60  _TempBuffer                        PatternTransform
     0000AC80  _DoBuffer                          PatternTransform
     0000ACA0  _rot                               PatternTransform
     0000ACA1  _i                                 PatternTransform

ASxxxx Linker V03.00 + NoICE + sdld,  page 6.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_INITIALIZED                        0000ACE4    00000009 =           9. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
     0000ACE6  _temps_entre_maons                 sc7brick
     0000ACE7  _heap_top                          

ASxxxx Linker V03.00 + NoICE + sdld,  page 7.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_GSINIT                             0000ACED    0000000F =          15. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
ASxxxx Linker V03.00 + NoICE + sdld,  page 8.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_GSFINAL                            0000ACFC    00000001 =           1. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
ASxxxx Linker V03.00 + NoICE + sdld,  page 9.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_INITIALIZER                        0000ACFD    00000007 =           7. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
ASxxxx Linker V03.00 + NoICE + sdld,  page 10.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_HEADER0                            00000000    00000006 =           6. bytes (ABS,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
ASxxxx Linker V03.00 + NoICE + sdld,  page 11.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_HEAP                               0000AD04    00000000 =           0. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
     0000AD04  _HEAP_start                        

ASxxxx Linker V03.00 + NoICE + sdld,  page 12.
Hexadecimal  [32-Bits]

Area                                    Addr        Size        Decimal Bytes (Attributes)
--------------------------------        ----        ----        ------- ----- ------------
_XDATA                              0000AD04    00000020 =          32. bytes (REL,CON)

      Value  Global                              Global Defined In Module
      -----  --------------------------------   ------------------------
ASxxxx Linker V03.00 + NoICE + sdld,  page 13.

Files Linked                              [ module(s) ]

sc7brick.rel                              [ sc7brick ]
./fusion-c/include/crt0_msxdos.rel        [  ]
FM_MBM.rel                                [ FM_MBM ]


Libraries Linked                          [ object file ]

./fusion-c/source/lib/fusion.lib          [ cls.rel ]
./fusion-c/source/lib/fusion.lib          [ sprite32bytes.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ rand.rel ]
./fusion-c/source/lib/fusion.lib          [ hmmc.rel ]
./fusion-c/source/lib/fusion.lib          [ hmmm.rel ]
./fusion-c/source/lib/fusion.lib          [ gettime.rel ]
./fusion-c/source/lib/fusion.lib          [ PatternTransform.rel ]
./fusion-c/source/lib/fusion.lib          [ putsprite.rel ]
./fusion-c/source/lib/fusion.lib          [ spritesmall.rel ]
./fusion-c/source/lib/fusion.lib          [ patternhflip.rel ]
./fusion-c/source/lib/fusion.lib          [ ayfxDriver.rel ]
./fusion-c/source/lib/fusion.lib          [ Set_Palette.rel ]
./fusion-c/source/lib/fusion.lib          [ spriteoff.rel ]
./fusion-c/source/lib/fusion.lib          [ memcopy.rel ]
./fusion-c/source/lib/fusion.lib          [ spritereset.rel ]
./fusion-c/source/lib/fusion.lib          [ waitkey.rel ]
./fusion-c/source/lib/fusion.lib          [ patternvflip.rel ]
./fusion-c/source/lib/fusion.lib          [ setvdp.rel ]
./fusion-c/source/lib/fusion.lib          [ setspritepattern.rel ]
./fusion-c/source/lib/fusion.lib          [ fcbread.rel ]
./fusion-c/source/lib/fusion.lib          [ interrupt_vdp.rel ]
./fusion-c/source/lib/fusion.lib          [ point.rel ]
./fusion-c/source/lib/fusion.lib          [ print.rel ]
./fusion-c/source/lib/fusion.lib          [ keyboardread.rel ]
./fusion-c/source/lib/fusion.lib          [ printf.rel ]
./fusion-c/source/lib/fusion.lib          [ copyvramtoram.rel ]
./fusion-c/source/lib/fusion.lib          [ copyramtovram.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ crtenter.rel ]
./fusion-c/source/lib/fusion.lib          [ exitdos.rel ]
./fusion-c/source/lib/fusion.lib          [ fcbopen.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ modsigned.rel ]
./fusion-c/source/lib/fusion.lib          [ sprite16.rel ]
./fusion-c/source/lib/fusion.lib          [ setcolors.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ __itoa.rel ]
./fusion-c/source/lib/fusion.lib          [ screen.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ divsigned.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ __ltoa.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ __uitobcd.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ __ultobcd.rel ]
./fusion-c/source/lib/fusion.lib          [ patternrotation.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ __strreverse.rel ]
/usr/bin/../share/sdcc/lib/z80/z80.lib    [ divunsigned.rel ]
./fusion-c/source/lib/fusion.lib          [ printchar.rel ]
./fusion-c/source/lib/fusion.lib          [ putcharrrdos.rel ]

ASxxxx Linker V03.00 + NoICE + sdld,  page 14.

User Base Address Definitions

_CODE = 0x0106
_DATA = 0x0000

By aoineko

Paragon (1138)

Аватар пользователя aoineko

02-11-2022, 08:09

If you target DOS program, const will have no effect outside your C program (code, data and variables are all in RAM).
DOS program can't use 64 KB because the upper part of the RAM is used by the BIOS work area and MSXDOS.SYS.
To check how many RAM can be used, get the value at (0006h) and substract 100h.

By geijoenr

Champion (391)

Аватар пользователя geijoenr

02-11-2022, 09:37

In that case, most likely you have a buffer overrun somewhere and are overwriting some variables or even code.
That would explain the weird behavior.

As you have a case that works and one that does not, you should be able to find which is the change that causes the problem.

By jepmsx

Champion (281)

Аватар пользователя jepmsx

02-11-2022, 09:56

The memory used is 19565+24433, quite below the 64k but I will check the value at 06h.
I'll also do a file diff between the two map files and see the variables that change.
Finally, to detect the overflow, I will use the openMSX debugger and check when the variable changes more bytes than its size. I hope I'll find it (fingers crossed)

By aoineko

Paragon (1138)

Аватар пользователя aoineko

02-11-2022, 10:44

If I remember correctly, Fusion-C uses hex2bin to generate the final binary program. It should display a warning if it has overlapping memory areas.

By jepmsx

Champion (281)

Аватар пользователя jepmsx

02-11-2022, 19:37

aoineko thanks for the hint. I've checked the output from hex2bin and it doesn't complain.

After some debugging, I've discovered so far is that the interrupt function is not working. In Fusion-C there is the function InitVDPInterruptHandler(interrupt_function) and interrupt_function is not called. Now I have to discover why changing so few things in one version makes this function wrong. Furthermore, the extra commands are not inside the interrupt_function

By ducasp

Paladin (712)

Аватар пользователя ducasp

02-11-2022, 21:04

There were known issues with interrupt handlers in fusion-c, not sure if it is actually fixed, the discussion and fixes were talked here:

https://www.msx.org/forum/msx-talk/development/fusion-c-and-...

Perhaps reading there you can identify if your version of library has a good interrupt handler, and if so, also learn about some possible pitfalls that can cause issues :)

Be careful about what you do during your interrupt function, it should be fast, and should not mess with VDP reading S0 otherwise BIOS will stop doing its stuff because you clear interrupt status from VDP before BIOS routines check if the interrupt was due to that (the hook interrupt functions work before the BIOS own interrupt function)

By jepmsx

Champion (281)

Аватар пользователя jepmsx

05-11-2022, 08:33

I've been working on this bug.

I've checked the InitVDPInterruptHandler and it is the version that uses ducasp's suggestion.

I've checked the map file and seen the address where my hook function is and set a breakpoint using openmsx-debugger. When the simulation stops there, the assembler instructions that appear in the memory of the debugger aren't the same as the ones that appear in the lst file of my function to be called in the interruption.
I've checked the address in the map file of the InitVDPInterruptHandler and the assembler instructions that appear in the debugger are the same as in the .s file. I've also checked another function of my code and is the right one.

The address of my interrupt function is 0x154B (following map file indications). I think that this address is not overwritten by variable codes. Furthermore, I've checked the previous function in 0x1417 and it is well debugged in the debugger, following the same instructions as in the .lst file. Why is not right the function in 0x154B?

Страница 1/2
| 2