Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ZoomDraw Routine for Screen 13h BSAVE ;
- ; Graphics ;
- ; ;
- ; (C) Copyright Graham Downey 2016 ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ORG 0h
- PUSH BP
- MOV BP, SP
- PUSHA
- PUSH ES
- PUSH DS
- ;Start pos on VRAM is [MinX + (MinY*320)]
- MOV BX, WORD [BP+6] ;Get MinY
- IMUL AX, BX, 320
- ADD AX, WORD [BP+8] ;Get MinX
- MOV DI, AX ;Set DI to start position for drawing
- MOV DS, WORD [BP+14] ;Bitmap Segment
- MOV SI, WORD [BP+12] ;Bitmap Address
- MOV BX, WORD [SI] ;Read width*8
- SHR BX, 3 ;Shift bits right 3 (Same as divide by 8)
- MOV DX, 320
- SUB DX, BX ;BX = 320-width
- MOV BH, BYTE [SI+2] ;Get height
- ADD SI, 4 ;Goto bitmap pixels
- MOV ES, WORD [BP+14] ;Bitmap Segment
- MOV AX, 0A000h ;Set screen Segment
- MOV DS, AX
- MOV AL, BYTE [BP+10] ;Get scale mode
- CMP AL, 2
- JE Zoomx2
- CMP AL, 3
- JE Zoomx3
- CMP AL, 4
- JE Zoomx4
- ;;;;;;;;;;;;;;;;;;;;;;;;
- ; 2x Zoom Draw Routine ;
- ;;;;;;;;;;;;;;;;;;;;;;;;
- Zoomx2:
- ADD DX, Dx ;How many lines to skip
- .NextY:
- MOV CL, BL ;Set counter to X pixel amount
- .NextX:
- MOV AL, [ES:SI] ;Read a pixel
- MOV AH, AL
- MOV [DI], AX ;Draw first row
- MOV [DI+320], AX ;Draw second row
- INC SI
- ADD DI, 2
- DEC CL ;One pixel, still more?
- JNZ .NextX ;Yes? Draw next pixel
- ADD DI, DX ;Adjust target to next line
- DEC BH ;One line done, still more?
- JNZ .NextY ;Yes? Go back until done
- JMP End ;Done
- ;;;;;;;;;;;;;;;;;;;;;;;;
- ; 3x Zoom Draw Routine ;
- ;;;;;;;;;;;;;;;;;;;;;;;;
- Zoomx3:
- IMUL DX, 3 ;How far to move when finished a line
- .NextY:
- MOV CL, BL ;Set counter to x pixel amount
- .NextX:
- MOV AL, [ES:SI] ;Read a pixel
- MOV AH, AL
- MOV [DI], AX ;Draw first row
- MOV [DI+2], AL
- MOV [DI+320], AX ;Draw second row
- MOV [DI+322], AL
- MOv [DI+640], AX ;Draw third row
- MOV [DI+642], AL
- INC SI
- ADD DI, 3 ;Move 3 pixels forward on screen
- DEC CL ;One pixel, still more?
- JNZ .NextX ;Yes? Draw next pixel
- ADD DI, DX ;Adjust target to next line
- DEC BH ;One line done, still more?
- JNZ .NextY ;Yes? Go back until done
- JMP End ;Done
- ;;;;;;;;;;;;;;;;;;;;;;;;
- ; 4x Zoom Draw Routine ;
- ;;;;;;;;;;;;;;;;;;;;;;;;
- Zoomx4:
- SHL DX, 2 ;How far to jump after a line
- .NextY:
- MOV CL, BL ;Set counter to x pixel amount
- .NextX:
- MOV AL, [ES:SI] ;Read a pixel
- MOV AH, AL ;AX full for 2 pixel write
- MOV BP, AX ;Copy AX to BP
- SHL EAX, 16 ;Shift EAX over 2 bytes left
- MOV AX, BP ;Copy BP back to the newly free'd AX
- MOV [DI], EAX ;Draw first row
- MOV [DI+320], EAX ;Draw second row
- MOV [DI+640], EAX ;Draw third row
- MOV [DI+960], EAX ;Draw fith row
- INC SI
- ADD DI, 4 ;Move 4 pixels forward on screen
- DEC CL ;One pixel, still more?
- JNZ .NextX ;Yes? Draw next pixel
- ADD DI, DX ;Adjust target to next line
- DEC BH ;One line, still more?
- JNZ .NextY ;Yes? Repeat until done
- End:
- POP DS
- POP ES
- POPA
- POP BP
- RETF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement