Advertisement
Ham62

DrawBSV.ASM

Jan 12th, 2016
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ; ZoomDraw Routine for Screen 13h BSAVE ;
  3. ; Graphics                              ;
  4. ;                                       ;
  5. ; (C) Copyright Graham Downey 2016      ;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. ORG 0h
  9.  
  10. PUSH BP
  11. MOV BP, SP
  12. PUSHA
  13. PUSH ES
  14. PUSH DS
  15.  
  16.                         ;Start pos on VRAM is [MinX + (MinY*320)]
  17. MOV BX, WORD [BP+6]     ;Get MinY
  18. IMUL AX, BX, 320
  19. ADD AX, WORD [BP+8]     ;Get MinX
  20. MOV DI, AX              ;Set DI to start position for drawing
  21.  
  22.  
  23. MOV DS, WORD [BP+14]    ;Bitmap Segment
  24. MOV SI, WORD [BP+12]    ;Bitmap Address
  25.  
  26. MOV BX, WORD [SI]       ;Read width*8
  27. SHR BX, 3               ;Shift bits right 3 (Same as divide by 8)
  28. MOV DX, 320
  29. SUB DX, BX              ;BX = 320-width
  30. MOV BH, BYTE [SI+2]     ;Get height
  31.  
  32. ADD SI, 4               ;Goto bitmap pixels
  33.  
  34. MOV ES, WORD [BP+14]    ;Bitmap Segment
  35.  
  36. MOV AX, 0A000h          ;Set screen Segment
  37. MOV DS, AX
  38.  
  39. MOV AL, BYTE [BP+10]    ;Get scale mode
  40. CMP AL, 2
  41. JE Zoomx2
  42. CMP AL, 3
  43. JE Zoomx3
  44. CMP AL, 4
  45. JE Zoomx4
  46.  
  47. ;;;;;;;;;;;;;;;;;;;;;;;;
  48. ; 2x Zoom Draw Routine ;
  49. ;;;;;;;;;;;;;;;;;;;;;;;;
  50. Zoomx2:
  51. ADD DX, Dx              ;How many lines to skip
  52.  
  53. .NextY:
  54. MOV CL, BL              ;Set counter to X pixel amount
  55.  
  56. .NextX:
  57. MOV AL, [ES:SI]         ;Read a pixel
  58. MOV AH, AL
  59. MOV [DI], AX            ;Draw first row
  60. MOV [DI+320], AX        ;Draw second row
  61. INC SI
  62. ADD DI, 2
  63.  
  64. DEC CL                  ;One pixel, still more?
  65. JNZ .NextX              ;Yes? Draw next pixel
  66. ADD DI, DX              ;Adjust target to next line
  67. DEC BH                  ;One line done, still more?
  68. JNZ .NextY              ;Yes? Go back until done
  69. JMP End                 ;Done
  70.  
  71. ;;;;;;;;;;;;;;;;;;;;;;;;
  72. ; 3x Zoom Draw Routine ;
  73. ;;;;;;;;;;;;;;;;;;;;;;;;
  74. Zoomx3:
  75. IMUL DX, 3              ;How far to move when finished a line
  76.  
  77. .NextY:
  78. MOV CL, BL              ;Set counter to x pixel amount
  79.  
  80. .NextX:
  81. MOV AL, [ES:SI]         ;Read a pixel
  82. MOV AH, AL
  83. MOV [DI], AX            ;Draw first row
  84. MOV [DI+2], AL
  85. MOV [DI+320], AX        ;Draw second row
  86. MOV [DI+322], AL
  87. MOv [DI+640], AX        ;Draw third row
  88. MOV [DI+642], AL
  89. INC SI
  90. ADD DI, 3               ;Move 3 pixels forward on screen
  91.  
  92. DEC CL                  ;One pixel, still more?
  93. JNZ .NextX              ;Yes? Draw next pixel
  94. ADD DI, DX              ;Adjust target to next line
  95. DEC BH                  ;One line done, still more?
  96. JNZ .NextY              ;Yes? Go back until done
  97. JMP End                 ;Done
  98.  
  99.  
  100. ;;;;;;;;;;;;;;;;;;;;;;;;
  101. ; 4x Zoom Draw Routine ;
  102. ;;;;;;;;;;;;;;;;;;;;;;;;
  103. Zoomx4:
  104. SHL DX, 2               ;How far to jump after a line
  105.  
  106. .NextY:
  107. MOV CL, BL              ;Set counter to x pixel amount
  108.  
  109. .NextX:
  110. MOV AL, [ES:SI]         ;Read a pixel
  111. MOV AH, AL              ;AX full for 2 pixel write
  112. MOV BP, AX              ;Copy AX to BP
  113. SHL EAX, 16             ;Shift EAX over 2 bytes left
  114. MOV AX, BP              ;Copy BP back to the newly free'd AX
  115. MOV [DI], EAX           ;Draw first row
  116. MOV [DI+320], EAX       ;Draw second row
  117. MOV [DI+640], EAX       ;Draw third row
  118. MOV [DI+960], EAX       ;Draw fith row
  119. INC SI
  120. ADD DI, 4               ;Move 4 pixels forward on screen
  121.  
  122. DEC CL                  ;One pixel, still more?
  123. JNZ .NextX              ;Yes? Draw next pixel
  124. ADD DI, DX              ;Adjust target to next line
  125. DEC BH                  ;One line, still more?
  126. JNZ .NextY              ;Yes? Repeat until done
  127.  
  128. End:
  129. POP DS
  130. POP ES
  131. POPA
  132. POP BP
  133. RETF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement