| 
   
    |  |  
    |  |  
   
    | Crome has a powerful scripting language.  There are many functions you can call to do things.  It would be good to document them here.
3/5/04 see below for additional information - Lego
Java Functions  Crome Functions| Variable | Use for | How to create | Note |  | Array | when you need more then one value |  | new array(x,y) | x and y are the values |  | Var | When you need 1 variable |  | var test | test is the new variable |  | select() | Use when you want the user to select your options | usage: select (sPrompt, sVar); | Use a pipe for sVar |  | input() | Use when you need input from a user | usage: input(sPromt,sVar,sArray) | sVar:"'no1','no2'; sSrray(1,2) the values for no1, no2; Return a string with commas |  | string.spilt(',') | Split a string in a array |  | String is split at ',' |  | isNaN(string) | Java function to check if the string is numric |  |  | Alert('str'); | Shows a msg box with the msg: str |  |   New documentation follows -- Lego Z81? - 06 Mar 2004
CROME JAVASCRIPT API
These javascript objects and their members are accessible directly
through CROME scripts.  If you plan to write an html based plugin,
these objects are accessible through the 'window.external' call.
Here are some example:
To access the window object in CROME scripts, you can use window.MEMBER
or simply call the MEMBER directly. eg. window.refresh() = refresh().
To access the window object in an html plugin you have to use:
window.external.window.refresh() or window.external.refresh().
The rom object is a member of the window object so to access a member
of the rom object you can use window.rom.MEMBER or rom.MEMBER in 
CROME scripts and window.external.window.rom.MEMBER or
window.external.rom.MEMBER in html plugins.
Any other javascript objects, methods, properties are still accessible,
but I will not comment on them since there are websites/books that can
do a better job than me.
Any other confusions contact me @ [email protected] and make
the subject 'crome script api'.| Function | What does it do? | Explain Variables | Notes |  | _rom_write(start, v, count) | Write an array of bytes to the rom file | start:Startadrress; v:array; count: | Needed most of the time to write something to the rom |  | _rom_fill(fromAdr, toAdr, byteFill) | Write any area of the rom with the same bytes | fromAdr:Where to start; toAdr:Where to stop; byteFill:Which byte(if left empty 0x00 is assumed | Usefull when you need to put NOP a locations |  | refresh() | Refersh the rom to seen new values |  |  |  | rom.gup() | Group Unupdate |  | When your script changes a lot of values use this so you can undo |  | rom.byteAt(0xFF) | point to a location in the rom(1 byte) | (0xFF) is the location |  | rom.wordAt(0xFFFF) | point to a location in the rom(1 word) | (0xFFFF) is the location |  | rom.hasLaunchControl | Tells Crome the bin has FTL | Set to 1 for FTL |  | rom.hasFullThrottleShift | Tells Crome the bin has FTS | Set to 1 for FTS |  | rom.hasBoost | Tells Crome the bin has Boost | Set to 1 for 1bar\2 for 3bar |  | rom.addressOf('') | Tells Crome Where something is |  | Works for tables\scalers\rev limits\ |  | rom.title | Tells Crome the title of the bin | needs to be string |  | rom.type | Tells Crome the type of the bin | rp30/rp72/rp28/rpCustom |  | addPlugin (strAuthor, strCaption, strExecCall, strInfoCall, intCategory); | Add a plugin in Crome |  | read it in Crome |  | addRomHandler (ecuType, strAuthor, strHandlerCall | Add a rom handler in Crome |  | read it in Crome |  | eval('0x' + Dec To Hex?(dec_value) | convert a decimal value to hex 0xab |  | dev_value exmaple 125 |  C R O M E  O B J E C T S  S T R U C T U R E
 +(o)window (default object)
+-(f)addRomHandler(romtype: byte; author, jscmd: string)
+-(f)addPlugin(author, mnucaption, jscmd: string; category: byte)
+-(f)alert(msg: string)
+-(f)confirm(msg: string): boolean
+-(f)DecToHex(dec: longword): string
+-(f)exal(cipherstring: string)
+-(f)GetFilePath(filename: string): string
+-(f)GetFileName(filename: string): string
+-(f)HiByte(w: word): byte
+-(f)input(msg, options, values: string): string
+-(f)include(filename: string)
+-(f)LoByte(w: word): byte
+-(f)prompt(caption, msg, default: string): boolean
+-(f)select(prompt, selection: string): integer
+-(f)shell(filename, params: string; windowstate: byte)
+-(f)shelld(doscmd: string): string
+-(f)shellw(filename, params: string; windowstate: byte)
+-(f)showBrowser(url: string; width, height: integer)
+-(f)refresh()
+-(o)rom
+-(p)byteAt(addr: word): byte
+-(p)wordAt(addr: word): word
+-(p)working_table: byte
+-(p)tableByte(col, row: byte): byte
+-(p)tableValue(col, row: byte): single
+-(p*)tableWidth: byte
+-(p*)tableHeight: byte
+-(p)addressOf(SPECIALSTR: string): word
+-(p)addressIn(index: byte): word
+-(p)hasLaunchControl: byte
+-(p)hasFullThrottleShift: byte
+-(p)hasBoost: byte
+-(p)hasFinalMultiplier: byte
+-(p)hasShiftLight: byte
+-(p)hasIAB: byte
+-(p)mapScalar(tbl, col: byte): word
+-(p)revScalar(tbl, row: byte): word
+-(p)base: byte
+-(p)title: string
+-(p*)filename: string
+-(f)gup()
+-(p)OBDMode: byte
+-(p)notes: string
+-files
+-(f)showSave(filter: string; filterindex: integer): string
+-(f)exists(filename: string): boolean
+-(f)getFile(filename: string): string
+-(f)putFile(filename, data: string)
+-(f)browseFolder: string
+-(f)showOpen(filter: string; filterindex: integer): string
note: (f) = function
      (p) = property (read/write)
      (p*) = property (read only)
      (o) = object
 W I N D O W  O B J E C T  U S A G E
 addRomHandler(romtype: byte; author, jscmd: string)
  desc      : used to add a rom handler for a non-stock rom such as
              roms with boost options, launch control, full throttle shift,
              etc.
  ecutype   : integer value specifying for which rom type this handler
              will be called for
  author    : name/handle of script writer
  jscmd     : javascript command used to handle the a rom
  eg. addRomHandler(rtP30, 'John Cui', '_handle_p30_rom()');
 addPlugin(author, mnucaption, jscmd: string; category: byte)
  desc      : used to add a plugin to the plugins list on the CROME
              main window
  author    : name/handle of script writer
  mnucaption: visible caption that apears on plugins menu
  jscmd     : javascript command called when plugin is executed
  eg. addPlugin('John Cui', 'Test Plugin', '_run_test_plugin()', 0);
 alert(msg: string)
  desc      : displays an alert message with 'OK' button as an option
  msg       : message displayed on alert message box
 confirm(msg: string): boolean
  desc      : displays a confirmation message with 'Yes' and 'No' buttons
              as options
  msg       : message displayed on confirm box
  return    : 0 -> false
              1 -> true
 Dec To Hex?(dec: longword): string
  dec       : decimal value to convert to hex
  return    : hex value as a string
 exal(cipherstring: string)
  desc      : used to evaluate an encoded javascript code
              encoding javascripts can be used to prevent copying of scripts
  cipherstring: an encoded string of javascript code
 Get File Path?(filename: string): string
  desc      : utility function used to get the path portion of a filename
  filename  : full filename of a file including path
  return    : path portion of filename
 Get File Name?(filename: string): string
  desc      : utility function used to get the file name portion of a filename
  filename  : full filename of a file including path
  return    : file name portion of a filename
 Hi Byte?(w: word): byte
  desc      : utility function to retreive the high byte of a word value
  w         : a word value
  return    : high byte of w
 input(msg, options, values: string): string
  desc      : displays a user prompt for an input
  msg       : instructions for user
  options   :
 include(filename: string)
  desc      : include a file containing scripts to current script
  filename  : filename of an existing script file
 Lo Byte?(w: word): byte
  desc      : utility function to retreive the low byte of a word value
  w         : a word value
  return    : low byte of w
 prompt(caption, msg, default: string): boolean
  desc      : propmts a user for a response
  caption   : caption for prompt
  msg       : message for user
  default   : default input 
  return    : user response
              empty string if cancelled
 select(prompt, selection: string): integer
  desc      : prompt a user to pick from a list of items
  prompt    : message for user
  selection : a list of selections for the user
  return    : the index of selected item
              -1 if cancelled
 shell(filename, params: string; windowstate: byte)
  desc      : call an external application
  filename  : filename of external app
  params    : parameters passed to the external app
  windowstate : window state for external app
  eg. shell('notepad.exe', 'C:\autoexec.bat', 0);
 shelld(doscmd: string): string
  desc      : call an external DOS app and retreive its message
  doscmd    : DOS command to call
  return    : returned string from DOS prompt
  eg. m = shelld('dasm662.exe "my_file.bin"');
      if (m) alert(m);
 shellw(filename, params: string; windowstate: byte)
  desc      : same as shell() function but waits for external app
              to close before continuing execution
 showBrowser(url: string; width, height: integer)
  desc      : show CROME's built-in web browser to display html-based
              scripts/plugins or web pages
  url       : address of an existing file or web page
  width     : window width for the browser
  height    : window height for the browser
  eg. showBrowser('my_html_plugin.html', 400, 250)
 refresh()
  desc      : refreshes the current display to show any updates
              use this at the end of a script to make sure the current
              changes are displayed
 R O M  O B J E C T  U S A G E
 byteAt(addr: word): byte
  desc      : used to access any part of the rom and set/get a byte value
  addr      : ROM file address
  eg. a = rom.byteAt(0x7FFF); // retreives the byte value at address 0x7FFF
      rom.byteAt(0x7FFF) = 0xFF; // sets the byte value at address 0x7FFF to 0xFF
 wordAt(addr: word): word
  desc      : same as byteAt() but for word values
              this function takes into account for endianess, an item in
              the rom stored as [0xAB][0xCD] will be returned as 0xCDAB
 working_table: byte
  desc      : set/get current working table for CROME
  wt        : working table value
              0 = low fuel
              1 = high fuel
              2 = low ignition
              3 = high ignition
 tableByte(col, row: byte): byte
  desc      : set/get byte value of the the col:row of the current working table
              does not change fuel multiplier values
  col,row   : column and row of the table
  eg. working_table = 2;
      b = rom.tableByte(0, 5);
 tableValue(col, row: byte): single
  desc      : set/get actual value of the col:row of the current working table
              this will also set the fuel multiplier for fuel tables if necessary
 tableWidth: byte
  desc      : gets the table width of the current working table
 tableHeight: byte
  desc      : gets the table height of the current working table
 addressOf(SPECIALSTR: string): word
  desc      : set/get word sized values in special registers in CROME
  SPECIALSTR : special names used to access the differents registers
               see list for special names and usage
  eg. rom.addressOf('CHECKSUM') = 0x7FFF
 addressIn(index: byte): word
  desc      : set/get word sized values in special registers in CROME
              these registers are accessible by index numbers
  index     : 0-63 corresponding to the index of the 64 special registers
  eg. rom.addressIn(40) = 0x1234
 hasLaunchControl: byte
  desc      : set/get launch control support
              0 = off
              1 = on
 hasFullThrottleShift: byte
  desc      : set/get full throttle shift support
              0 = off
              1 = on
 hasBoost: byte
  desc      : set/get boost support
              0 = no boost
              1 = stock map boost
              2 = 3 bar boost
              3 = custom
 hasFinalMultiplier: byte
  desc      : set/get final multiplier support
              0 = off
              1 = on
 hasShiftLight: byte
  desc      : set/get shift light support
              0 = off
              1 = on
 hasIAB: byte
  desc      : set/get IAB support
              0 = off
              1 = on
 mapScalar(tbl, col: byte): word
  desc      : set/get map scalar values in millibars
  tbl       : 0 = low tables
              1 = high tables
  col       : column number of scalar
 revScalar(tbl, row: byte): word
  desc      : set/get rev scalar values in rpms
  tbl       : 0 = low tables
              1 = high tables
  row       : row number of scalar
 base: byte
  desc      : set/get base rom of to be loaded
 =     this determines which default address locations to use for
 =     a particular rom
 title: string
  desc      : set/get the value of the statusbar on the lower left of
              the main window
 filename: string
  desc      : (read only) gets the full filename of the current ROM
 gup()
  desc      : Group Undo Point
              used in the begining and the end of a complex ROM manipulation
              in order to combine multiple changes as one undo/redo action
  eg. rom.gup();
      for (i = 0; i <= 0x7FFF; i++) {
        rom.byteAt(i) = Lo Byte?(i);
      }
      rom.gup();
 OBDMode: byte
  desc      : set/get OBD mode to determine which formulas to use
              0 = OBD0
              1 = OBD1
              2 = OBD2
              3 = Unknown
 notes: string
  desc      : set/get notes for current ROM
 F I L E  O B J E C T  U S A G E
 showSave(filter: string; filterindex: integer): string
  desc      : display a save dialog
  filter    : list of file type filters
  filterindex : index of default filter
  return    : selected filename
              empty string if cancelled
  eg. fn = showSave('HTML Files|*.htm;*.html|Text Files|*.txt|All Files|*.*', 0)
 exists(filename: string): boolean
  desc      : utility function to determine if a file exists
  filename  : filename of file to check
  return    : 0 = file does not exist
              1 = file exists
 getFile(filename: string): string
  desc      : gets the contents of a file (text files only)
  filename  : full filename
  return    : content of the file
 putFile(filename, data: string)
  desc      : writes to a file
  filename  : full filename
  data      : content to write to the file
 browseFolder: string
  desc      : displays the browser for folder dialog
              returns path of selected folder
              returns empty string if cancelled
 showOpen(filter: string; filterindex: integer): string
  desc      : display an open dialog
  filter    : list of file type filters
  filterindex : index of default filter
  return    : selected filename
              empty string if cancelled
 S P E C I A L  N A M E S  L I S T
 These are the special names and corresponding special register indexes
that can be used with the rom.addressOf() or rom.addressIn() calls
[SPECIAL NAMES]        [INDEX]      [COMMENT]
CHECKSUM                 0           address where to apply checksum correction
LOW_MAP_SCALAR           1           address of low map scalar
HIGH_MAP_SCALAR          2           address of high map scalar
LOW_REV_SCALAR           3           address of low rev scalar
HIGH_REV_SCALAR          4           address of high rev scalar
LOW_FUEL                 5           address of low fuel table
HIGH_FUEL                6           address of high fuel table
LOW_IGNITION             7           address of low ignition table
HIGH_IGNITION            8           address of high ignition table
NFO_LOW_TABLE            9           low table size hibyte = height lobyte = width
NFO_HIGH_TABLE           10          high table size hibyte = height lobyte = width
REVCUT1                  11          address of 1st revcut value
REVRES1                  12          address of 1st revres value
REVCUT2                  13          address of 2nd revcut value
REVRES2                  14          address of 2nd revres value
VTEC_TABLE               15          address of vtec tables
NFO_VTEC_TABLE           16          vtec table info hibyte = vtec pair count (2 or 4)
VTEC                     17          address of VTEC config byte
IDLE                     25          address of idle value
KNOCK                    26          address of knock config byte
ELD                      27          address of eld config byte
BARO                     29          address of baro config byte
VTECVSS                  30          address of vtec vss check config byte
VTECCOOL                 31          address of vtec coolant check config byte
DEBUGMODE                32          address of debug mode config byte
OXYHEAT                  33          address of o2 heater check config byte
LAUNCH_CUT               40          address of lauch cut value
LAUNCH_RES               41          address of lauch res value
SHIFT_CUT                42          address of shift cut value
SHIFT_RES                43          address of shift res value
SPEED_LIMIT              44          address of speed limitter value
NFO_MAP_MIN              45          
NFO_MAP_MAX              46
MTX1                     50          address of final fuel multiplier value
MTX2                     51
MTX3                     52          address of cranking fuel multiplier value
MTX4                     53
MTX5                     54          address of tip-in fuel multiplier value
MTX6                     55
SL_BYTE                  56          address of shift light config byte
SL_RPM                   57          address of shift light rpm value
Notes: in order to use the built-in editors in the options page of CROME you must
       set the hasLaunchControl, hasFullThrottleShift, hasFinalMultiplier,
       hasShiftLight, and hasIAB properties of the rom object to true (1).
Revision infromation
05 Mar 2004 Lego Z81? fixed tables, added documentation written by John Cui? for Crome.  E-mail me if you have any questions I saved a copy of this before I made and changes.  Thank you.
 |  
      
       | Copyright © 2002-present by the contributing authors. All material on this collaboration platform is the property of the contributing authors, and is covered by the Non-Commercial Share-Alike License unless explicitly stated otherwise.
 |  |