; bits headers
%pragma once
bits 16

%define getbit(s,x,y)       _getbit s,x,y    ; getbit  :: bitmap *seg:addr
                                             ;    -> int16 bitno -> bool val
%define setbit(s,x,y,z)     _setbit s,x,y,z  ; setbit  :: bitmap *seg:addr
                                             ;    -> int16 bitno -> bool val -> void
%define findbit(s,x,y,z)    _findbit s,x,y,z ; findbit :: bitmap *seg:addr
                                             ;    -> int16 size -> bool val -> int16 bitno

%ifdef xbits
    global Getbit
    global Setbit
    global Findbit
%else
    extern Getbit
    extern Setbit
    extern Findbit
%endif

%macro _getbit 3
    mov ax,%3
    push ax
    mov ax,%2
    push ax
    mov ax,%1
    push ax
    call Getbit
    add sp,0x0006
%endmacro

%macro _setbit 4
    mov ax,%4
    push ax
    mov ax,%3
    push ax
    mov ax,%2
    push ax
    mov ax,%1
    push ax
    call Setbit
    add sp,0x0008
%endmacro

%macro _findbit 4
    mov ax,%4
    push ax
    mov ax,%3
    push ax
    mov ax,%2
    push ax
    mov ax,%1
    push ax
    call Findbit
    add sp,0x0008
%endmacro

