Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ORG 0h
- %define _ScreenWidth 80
- %define _ParamOffset (4+16+2+2) ;(CS/IP)+PUSHA+ES+DS
- %define _StartX BP+_ParamOffset+14
- %define _StartY BP+_ParamOffset+12
- %define _Width BP+_ParamOffset+10
- %define _Height BP+_ParamOffset+8
- %define _GFXPtr BP+_ParamOffset+6
- %define _GFXSeg BP+_ParamOffset+4
- %define _BuffSeg BP+_ParamOffset+2
- %define _BuffAddr BP+_ParamOffset+0
- Start:
- PUSHA ;16 bytes
- PUSH ES ;2 bytes
- PUSH DS ;2 bytes
- MOV BP, SP
- ;Start pos on buffer is (X + (Y*ScreenWidth)) << 1
- MOV BX, WORD [_StartY] ;Get Y
- IMUL AX, BX, _ScreenWidth ;Multiply by ScreenWidth and store result in AX
- ADD AX, WORD [_StartX] ;Add X
- SHL AX, 1 ;2 bytes per character block
- MOV SI, WORD [_BuffAddr] ;Set SI to start of buffer
- ADD SI, AX ;SI is now start of where to read image
- MOV ES, WORD [_GFXSeg] ;Image segment
- MOV DI, WORD [_GFXPtr] ;Image offset
- ;Image is now ES:DI
- MOV BX, WORD [_Width] ;How long are the rows
- MOV DX, WORD [_Height] ;How many rows to draw
- MOV AX, _ScreenWidth ;How much to advance to get to next row
- SUB AX, BX ;AX = ScreenWidth - ImageWidth
- MOV DS, WORD [_BuffSeg] ;Get buffer segment
- ;Buffer is now DS:SI
- NextRow:
- MOV CX, BX ;How much to draw to complete a row
- REP MOVSW ;Draw a row
- ADD SI, AX ;Adjust pointer to start of next row
- DEC DX ;Done a row, still more?
- JNZ NextRow ;Yes? Draw the next line
- End:
- POP DS
- POP ES
- POPA
- RETF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement