#11 Article 169 Posted at 1987/06/10 19:54:14 by NOZOMU (MAP041) [PRG.NL2]

Subject: NLOADER2 for 98+MASM ソノ2

add     ax,15360
        cmp     si,ax
        jb      get_1char

        mov     ah,3eh                  ;Close file
        int     21h

        mov     ax,0
        jmp     short exit_read

error:
        mov     ah,09h                  ;Display string
        mov     dx,offset error_message
        int     21h
        mov     ax,0ffffh

exit_read:
        pop     si
        pop     di
        pop     dx
        pop     cx
        pop     bx

        pop     bp

        ret     4

read    endp

;--------------------------------------
;
;       display(logial_page)
;
;       char    *logical_page
;
;--------------------------------------
public  display

display_arg     struc
        dw      ?
        dw      ?
lpd     dw      ?       ;&logical_page
display_arg     ends

display proc    near

        push    bp
        mov     bp,sp

        push    bx
        push    cx
        push    dx
        push    si

        mov     cx,0
loop2:
        mov     bx,0
        mov     si,[bp].lpd
        mov     ax,cx           ;x
        add     ax,ax           ;*2
        add     ax,ax           ;*4
        add     ax,ax           ;*8
        add     ax,ax           ;*16
        add     ax,ax           ;*32
        mov     dx,ax
        add     ax,ax           ;*64
        add     ax,dx           ;*96
        add     si,ax
loop1:
        mov     al,[bx+si]
        mov     ah,0

        push    ax
        push    bx
        push    cx
        call    pset

        inc     bx
        cmp     bx,96
        jb      loop1

        inc     cx
        cmp     cx,160
        jb      loop2

        mov     ax,0
        pop     si
        pop     dx
        pop     cx
        pop     bx

        pop     bp

        ret     2

display endp

;--------------------------------------
;
;       pset(x,y,c)
;
;       int     x,y,c
;
;--------------------------------------
public  pset

pset_arg        struc
bpsave  dw      ?
retadd  dw      ?
x       dw      ?
y       dw      ?
c       dw      ?
pset_arg        ends

pset    proc    near

        push    bp
        mov     bp,sp
        push    bx
        push    cx
        push    dx
        push    si
        push    di

        mov     ax,[bp].y
        add     ax,ax           ;*2
        add     ax,ax           ;*4
        add     ax,ax           ;*8
        add     ax,ax           ;*16
        mov     bx,ax
        add     ax,ax           ;*32
        add     ax,ax           ;*64
        add     ax,bx           ;*80
        add     ax,ax           ;*160
        mov     di,ax

        mov     ax,[bp].x
        shr     ax,1
        mov     bl,0
        rcl     bl,1
        add     di,ax

        mov     ax,[bp].c
        add     ax,ax
        mov     si,offset pattern
        cmp     gray,0
        jne     draw_pattern
        mov     si,offset color
draw_pattern:
        add     si,ax
        add     si,ax
        add     si,ax

        mov     dx,0000111111110000b
        cmp     bl,1
        jne     left
        mov     dx,1111000000001111b
left:
        mov     cx,0a800h
        mov     es,cx

        mov     ax,[si]
        inc     si
        inc     si
        mov     bl,al
        and     bl,dl
        mov     bh,es:[di]
        and     bh,dh
        or      bl,bh
        mov     es:[di],bl

        mov     bl,ah
        and     bl,dl
        mov     bh,es:[di+80]
        and     bh,dh
        or      bl,bh
        mov     es:[di+80],bl

        mov     cx,0b000h
        mov     es,cx