?login_element?

Subversion Repositories NedoOS

Rev

Rev 129 | Blame | Compare with Previous | Last modification | View Log | Download

  1.     OUTPUT "checking_macro_args_within_lua.bin"
  2.  
  3.     ; this was originally showing hack-ish solution how to get macro argument value
  4.  
  5.     ; since v1.20.0 the sj.get_define is extended to search optionally also in macro
  6.     ; arguments, rendering the original example pointless, this is now as simple as this:
  7.  
  8.     MACRO someMacro someArg0
  9.         LUA ALLPASS
  10.             _pc("db "..sj.get_define("someArg0", true)) -- "true" to enable search in macro arguments
  11.         ENDLUA
  12.     ENDM
  13.  
  14.     ; spawn the macro (should end as `db "ARG0_content"` final machine code.
  15.     someMacro "ARG0_content"
  16.  
  17. ;;-------------------------------------------------------------------------------
  18.     ; second example, with usage of LUA inside DUP-EDUP block (based on Issue #27)
  19.     LUA PASS1
  20.         AY8910_CLOCK_FREQUENCY=1000000
  21.         function getAyMidiFrequency(midiNumber)
  22.             return math.floor((AY8910_CLOCK_FREQUENCY/16.0)/(2^((midiNumber-69)/12.0)*440)+0.5)
  23.         end
  24.     ENDLUA
  25.  
  26. midi_number=21
  27.     dup 108-21+1
  28.     LUA ALLPASS
  29.         _pc('dw ' .. getAyMidiFrequency(sj.get_label("midi_number")))
  30.     ENDLUA
  31. midi_number=midi_number+1
  32.     edup
  33.