AMXX-BG.INFO fmt.inc Raw include

fmt.inc

Original include source with line numbers.

Back Download .inc
1 #if defined _fmt_included
2 #endinput
3 #endif
4
5 #define _fmt_included
6
7 #if !defined MAX_FMT_LENGTH
8 const MAX_FMT_LENGTH = 256
9
10 #if !defined __vformat_allower
11 #define __vformat_allower __vformat_allower_
12
13 __vformat_allower_()
14 {
15 vformat("", 0, "", 0)
16 }
17 #endif
18
19 stock fmt(const format[], any:...)
20 {
21 static formatted[MAX_FMT_LENGTH]
22 #emit PUSH.C 0x2
23 #emit PUSH.S format
24 const FORMATTED_CHARSMAX = charsmax(formatted)
25 #emit PUSH.C FORMATTED_CHARSMAX
26 #emit LOAD.S.PRI 0x8 // Get size of arguments (count of arguments multiply by sizeof(cell))
27 #emit ADDR.ALT 0xC // This is the pointer to first argument
28 #emit ADD // Now in PRI we have the pointer to hidden return argument
29 #emit LOAD.I // Now in PRI we have the pointer to return buffer
30 #emit PUSH.PRI
31 #emit PUSH.C 0x10
32 #emit SYSREQ.C vformat
33 #emit STACK 0x14
34 #emit RETN // Don't execute the code for copy return generated by compiler
35 __vformat_allower()
36 return formatted
37 }
38 #endif