;******************************************************************************** ; @module string ; @type utility ; @details ; String utility ;******************************************************************************** .ifndef INCLUDE_STRING INCLUDE_STRING = 1 .include "system/system.h65" .scope str Import str, strf, int8_to_hex_str .macro _StrfStoreArg arg .if (.not .blank(arg)) .if .match(arg, x) stx ARG4 + @N_ARGS .elseif .match(arg, y) sty ARG4 + @N_ARGS .else lda arg sta ARG4 + @N_ARGS .endif @N_ARGS .set (@N_ARGS + 1) .endif .endmacro ;******************************************************************************** ; @function Macro for passing arguments to strf ; @param fmt: Format string address ; @param out: Output string address ; @param x0-x9: Additional parameters ; @warning Addresses as additional paramteres must be passed like this `#addr` ; @modifies: A, X, Y ; @see strf ;******************************************************************************** .macro Strf fmt,out,x0,x1,x2,x3,x4,x5,x6,x7,x8,x9 @N_ARGS .set 0 ; @ so that it doesnt break cheap labels lda #fmt sta ARG1 lda #out sta ARG3 _StrfStoreArg x0 _StrfStoreArg x1 _StrfStoreArg x2 _StrfStoreArg x3 _StrfStoreArg x4 _StrfStoreArg x5 _StrfStoreArg x6 _StrfStoreArg x7 jsr str::strf .out .sprintf("info: Strf: called with %d arguments", @N_ARGS) .endmacro ; TODO allocate zp memory fmt_idx = $30 out_idx = $31 .endscope .endif ; guard