[トップ][編集][ノート][編集履歴][一覧][最近の更新][->English]

HSP3用loadlib互換ライブラリ


廃止されたloadlib命令の互換ライブラリです。


loadlib.as

; ------------------------------------------------------------------------
; For Hot Soup Processor 3.0
;       これは廃止されたloadlib命令を使えるようにするための
;       ライブラリです。
; ------------------------------------------------------------------------
#ifndef INC__LOADLIB_AS
#define INC__LOADLIB_AS
#module loadlib

; 内部で使用するWinAPI関数群
#uselib "kernel32.dll"
#func ll_LoadLibrary    "LoadLibraryA"   sptr
#func ll_GetProcAddress "GetProcAddress" int, sptr
#func ll_FreeLibrary    "FreeLibrary"    int
#func ll_lstrcpy        "lstrcpyA"       sptr, sptr

; ------------------------------------------------------------------------
; ll_return - 戻り値を設定
; ------------------------------------------------------------------------
#deffunc ll_return@loadlib int p1
    ret = p1
    defret = p1
    return

; ------------------------------------------------------------------------
; ll_bin
; ------------------------------------------------------------------------
;#deffunc ll_bin var v1, str s1
;    return

; ------------------------------------------------------------------------
; ll_call
; ------------------------------------------------------------------------
;#deffunc ll_call
;    return

; ------------------------------------------------------------------------
; ll_callfnv
; ------------------------------------------------------------------------
#deffunc ll_callfnv int p1
    ll_return callfunc(void, p1, 0)
    return 0

; ------------------------------------------------------------------------
; ll_callfunc
; ------------------------------------------------------------------------
#deffunc ll_callfunc var v1, int p1, int p2
    ll_return callfunc(v1, p2, p1)
    return 0

; ------------------------------------------------------------------------
; ll_dll
; ------------------------------------------------------------------------
#deffunc ll_dll str s1
    if szdll = s1: return
    sdll = s1
    gosub *DllUninit
    return 0

; ------------------------------------------------------------------------
; ll_free
; ------------------------------------------------------------------------
#deffunc ll_free
    gosub *DllUninit
    return 0

; ------------------------------------------------------------------------
; ll_func
; ------------------------------------------------------------------------
;#deffunc ll_func str s1
;    return

; ------------------------------------------------------------------------
; ll_getproc
; ------------------------------------------------------------------------
#deffunc ll_getproc var v1, str s1, int p1
    ll_GetProcAddress p1, s1
    v1 = stat
    return stat == 0

; ------------------------------------------------------------------------
; ll_getptr
; ------------------------------------------------------------------------
#deffunc ll_getptr var v1
    ll_return varptr(v1)
    return 0

; ------------------------------------------------------------------------
; ll_libfree
; ------------------------------------------------------------------------
#deffunc ll_libfree int p1
    ll_FreeLibrary p1
    return stat == 0

; ------------------------------------------------------------------------
; ll_libload
; ------------------------------------------------------------------------
#deffunc ll_libload var v1, str s1
    ll_LoadLibrary s1
    v1 = stat
    return stat == 0

; ------------------------------------------------------------------------
; ll_n
; ------------------------------------------------------------------------
;#deffunc ll_n int p1, int p2
;    return

; ------------------------------------------------------------------------
; ll_p
; ------------------------------------------------------------------------
;#deffunc ll_p var v1, int p1
;    return

; ------------------------------------------------------------------------
; ll_peek
; ------------------------------------------------------------------------
#deffunc ll_peek var v1, int p1, int p2
    dupptr t1, p1, 1, 2,
    if p2 <= 0: v1 = t1: else: memcpy v1, t1, p2
    return 0

; ------------------------------------------------------------------------
; ll_peek1(2, 4)
; ------------------------------------------------------------------------
#define ll_peek1(%1,%2) ll_peek %1, %2, 1
#define ll_peek2(%1,%2) ll_peek %1, %2, 2
#define ll_peek4(%1,%2) ll_peek %1, %2, 4

; ------------------------------------------------------------------------
; ll_poke
; ------------------------------------------------------------------------
#deffunc ll_poke var v1, int p1, int p2
    if p2 <= 0{
        ll_lstrcpy p1, varptr(v1)
    } else {
        dupptr t1, p1, p2, 2
        memcpy t1, v1, p2
    }
    return 0

; ------------------------------------------------------------------------
; ll_poke1(2, 4)
; ------------------------------------------------------------------------
#define ll_poke1(%1,%2) ll_poke %1, %2, 1
#define ll_poke2(%1,%2) ll_poke %1, %2, 2
#define ll_poke4(%1,%2) ll_poke %1, %2, 4

; ------------------------------------------------------------------------
; ll_ret
; ------------------------------------------------------------------------
#deffunc ll_ret var v1
    v1 = ret
    return 0

; ------------------------------------------------------------------------
; ll_retset
; ------------------------------------------------------------------------
#deffunc ll_retset var v1
    dup defret, v1
    return 0

; ------------------------------------------------------------------------
; ll_s
; ------------------------------------------------------------------------
;#deffunc ll_s str s1, int n1
;    return

; ------------------------------------------------------------------------
; ll_str
; ------------------------------------------------------------------------
;#deffunc ll_str var v1, int p1, int p2
;    return

; ------------------------------------------------------------------------
; ll_type
; ------------------------------------------------------------------------
;#deffunc ll_type str s1, int p1
;    return

; ------------------------------------------------------------------------
; ll_z
; ------------------------------------------------------------------------
;#deffunc ll_z int p1, int p2
;    return

; ------------------------------------------------------------------------
; hDLLの解放
; ------------------------------------------------------------------------
*DllUninit
    if hDLL: ll_FreeLibrary hDLL: hDLL = 0
    gosub *VarInit
    return

; ------------------------------------------------------------------------
; 変数の初期化
; ------------------------------------------------------------------------
*VarInit
    return

#global
#endif ; !defined(INC__LOADLIB_AS)