Changeset 1123 for trunk


Ignore:
Timestamp:
04/03/11 00:39:38 (2 years ago)
Author:
reyalP
Message:

rand and srand for g12 and sx30 from philmoz in http://chdk.setepontos.com/index.php?topic=650.msg63805#msg63805

Location:
trunk/platform
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/platform/g12/sub/100c/stubs_entry_2.S

    r1111 r1123  
    9393NHSTUB(PutOutNdFilter,                  0xFFB04E90) 
    9494NHSTUB(PT_MoveDigitalZoomToWide,                0xFF87F5C0) 
     95NHSTUB(rand,                                                    0xFFA5B364)     // search for 0x41C64E6D. Function before this value is rand. 
     96NHSTUB(srand,                                                   0xFFA5B358)     // search for 0x41C64E6D. Function before rand is srand. 
    9597 
    9698# From stubs_entry_ida.s 
     
    117119NHSTUB(kbd_pwr_off,                                             0xFF810B1C)                                                             // ??? not on sx20 or s95 
    118120NHSTUB(kbd_pwr_on,                                              0xFF810B1C)                                                             // ??? not on sx20 or s95 
    119 NSTUB(rand,                                                             0xFF810B1C) // ??? could not find use C version from S95 wrappers 
    120 NSTUB(srand,                                                    0xFF810B1C) // ??? could not find use C version from S95 wrappers 
    121121NHSTUB(UIFS_WriteFirmInfoToFile,                0xFF810B1C)     // Is this needed? 
    122122NHSTUB(rewinddir,                                               0xFF810B1C) 
  • trunk/platform/g12/sub/100e/stubs_entry_2.S

    r1111 r1123  
    9393NHSTUB(PutOutNdFilter,                  0xFFB05040) 
    9494NHSTUB(PT_MoveDigitalZoomToWide,                0xFF87F5C0) 
     95NHSTUB(rand,                                                    0xFFA5B370)     // search for 0x41C64E6D. Function before this value is rand. 
     96NHSTUB(srand,                                                   0xFFA5B364)     // search for 0x41C64E6D. Function before rand is srand. 
    9597 
    9698# From stubs_entry_ida.s 
     
    117119NHSTUB(kbd_pwr_off,                                             0xFF810B1C)                                                             // ??? not on sx20 or s95 
    118120NHSTUB(kbd_pwr_on,                                              0xFF810B1C)                                                             // ??? not on sx20 or s95 
    119 NSTUB(rand,                                                             0xFF810B1C) // ??? could not find use C version from S95 wrappers 
    120 NSTUB(srand,                                                    0xFF810B1C) // ??? could not find use C version from S95 wrappers 
    121121NHSTUB(UIFS_WriteFirmInfoToFile,                0xFF810B1C)     // Is this needed? 
    122122NHSTUB(rewinddir,                                               0xFF810B1C) 
  • trunk/platform/g12/wrappers.c

    r1008 r1123  
     1 
    12#include "../generic/wrappers.c" 
    23 
     
    1516        return _GetCurrentTargetDistance(); 
    1617} 
    17  
    18  
    19 // G12 firmware does not include rand(), srand() so we add them here 
    20  
    21 #define RAND_MAX 0x7fffffff 
    22  
    23 static unsigned int next = 1; 
    24  
    25 int rand_r(unsigned int *seed) 
    26 { 
    27         *seed = *seed * 1103515245 + 12345; 
    28         return (*seed % ((unsigned int) RAND_MAX + 1)); 
    29 } 
    30  
    31 int _rand(void) 
    32 { 
    33         return (rand_r(&next)); 
    34 } 
    35  
    36 void* _srand(unsigned int seed) 
    37 { 
    38         next = seed; 
    39         return 0;                               // unused return value 
    40 } 
  • trunk/platform/sx30/sub/100e/stubs_entry_2.S

    r1111 r1123  
    8888NHSTUB(Rec2PB,                          0xFF8A1B3C) 
    8989NHSTUB(exmem_alloc,                                             0xFF8944F4)     // search for ExMem.AllocCacheable (from reyalp) 
     90NHSTUB(rand,                                                    0xFFA4D8C8)     // search for 0x41C64E6D. Function before this value is rand. 
     91NHSTUB(srand,                                                   0xFFA4D8BC)     // search for 0x41C64E6D. Function before rand is srand. 
    9092 
    9193# from stubs_entry_ida.S 
     
    113115NHSTUB(kbd_pwr_off,                                             0xFF810B1C)                                                             // ??? not on sx20 or s95 
    114116NHSTUB(kbd_pwr_on,                                              0xFF810B1C)                                                             // ??? not on sx20 or s95 
    115 NSTUB(rand,                                                             0xFF810B1C) // ??? could not find use C version from S95 wrappers 
    116 NSTUB(srand,                                                    0xFF810B1C) // ??? could not find use C version from S95 wrappers 
    117117NHSTUB(UIFS_WriteFirmInfoToFile,                0xFF810B1C)     // Is this needed? 
    118118NHSTUB(rewinddir,                                               0xFF810B1C) 
  • trunk/platform/sx30/sub/100h/stubs_entry_2.S

    r1111 r1123  
    8888NHSTUB(Rec2PB,                          0xFF8A1B3C) 
    8989NHSTUB(exmem_alloc,                                             0xFF8944F4)     // search for ExMem.AllocCacheable (from reyalp) 
     90NHSTUB(rand,                                                    0xFFA4D984)     // search for 0x41C64E6D. Function before this value is rand. 
     91NHSTUB(srand,                                                   0xFFA4D978)     // search for 0x41C64E6D. Function before rand is srand. 
    9092 
    9193# from stubs_entry_ida.S 
     
    113115NHSTUB(kbd_pwr_off,                                             0xFF810B1C)                                                             // ??? not on sx20 or s95 
    114116NHSTUB(kbd_pwr_on,                                              0xFF810B1C)                                                             // ??? not on sx20 or s95 
    115 NSTUB(rand,                                                             0xFF810B1C) // ??? could not find use C version from S95 wrappers 
    116 NSTUB(srand,                                                    0xFF810B1C) // ??? could not find use C version from S95 wrappers 
    117117NHSTUB(UIFS_WriteFirmInfoToFile,                0xFF810B1C)     // Is this needed? 
    118118NHSTUB(rewinddir,                                               0xFF810B1C) 
  • trunk/platform/sx30/sub/100l/stubs_entry_2.S

    r1111 r1123  
    8888NHSTUB(Rec2PB,                          0xFF8A1B40) 
    8989NHSTUB(exmem_alloc,                                             0xFF8944F8)     // search for ExMem.AllocCacheable (from reyalp) 
     90NHSTUB(rand,                                                    0xFFA4DB2C)     // search for 0x41C64E6D. Function before this value is rand. 
     91NHSTUB(srand,                                                   0xFFA4DB20)     // search for 0x41C64E6D. Function before rand is srand. 
    9092 
    9193# from stubs_entry_ida.S 
     
    113115NHSTUB(kbd_pwr_off,                                             0xFF810B1C)                                                             // ??? not on sx20 or s95 
    114116NHSTUB(kbd_pwr_on,                                              0xFF810B1C)                                                             // ??? not on sx20 or s95 
    115 NSTUB(rand,                                                             0xFF810B1C) // ??? could not find use C version from S95 wrappers 
    116 NSTUB(srand,                                                    0xFF810B1C) // ??? could not find use C version from S95 wrappers 
    117117NHSTUB(UIFS_WriteFirmInfoToFile,                0xFF810B1C)     // Is this needed? 
    118118NHSTUB(rewinddir,                                               0xFF810B1C) 
  • trunk/platform/sx30/wrappers.c

    r1008 r1123  
     1 
    12#include "../generic/wrappers.c" 
    23 
     
    1516        return _GetCurrentTargetDistance(); 
    1617} 
    17  
    18  
    19 // SX30 firmware does not include rand(), srand() so we add them here 
    20  
    21 #define RAND_MAX 0x7fffffff 
    22  
    23 static unsigned int next = 1; 
    24  
    25 int rand_r(unsigned int *seed) 
    26 { 
    27         *seed = *seed * 1103515245 + 12345; 
    28         return (*seed % ((unsigned int) RAND_MAX + 1)); 
    29 } 
    30  
    31 int _rand(void) 
    32 { 
    33         return (rand_r(&next)); 
    34 } 
    35  
    36 void* _srand(unsigned int seed) 
    37 { 
    38         next = seed; 
    39         return 0;                               // unused return value 
    40 } 
Note: See TracChangeset for help on using the changeset viewer.