drawlogo86.asm 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. ;
  2. ; Copyright (C) 2017-2018 Farooq Karimi Zadeh <fkz@riseup.net>
  3. ;
  4. ; Permission is hereby granted, free of charge, to any person obtaining a copy
  5. ; of this software and associated documentation files (the "Software"), to deal
  6. ; in the Software without restriction, including without limitation the rights
  7. ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. ; copies of the Software, and to permit persons to whom the Software is
  9. ; furnished to do so, subject to the following conditions:
  10. ;
  11. ; The above copyright notice and this permission notice shall be included in all
  12. ; copies or substantial portions of the Software.
  13. ;
  14. ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. ; SOFTWARE.
  21. ;
  22. org 0x7c00
  23. mov AX, 0
  24. mov DS, AX
  25. ; because nasm (by default) does optimization itself, I didn't bother!
  26. jmp start
  27. %include "pixels.inc" ; this include file has the pixels table and LEN
  28. start:
  29. mov AH, 0
  30. mov AL, 0x13
  31. int 0x10 ; changing mode to 13h
  32. mov SI, pixels ; the pixels variable is in "pixels.inc" include file
  33. mov DI, SI
  34. add DI, LEN ; this should be declared in pixels.inc
  35. mov BH, byte [SI] ; color of our dear pixel!
  36. mov CL, 0 ; Y
  37. mov CH, 0 ; and X
  38. ; X and Y may not be smaller than 0 or bigger than 15 + 1
  39. loop: ; drawing pixels
  40. call drawpix
  41. inc SI
  42. mov BH, byte [SI]
  43. inc CH
  44. cmp CH, 15 + 1
  45. jnz loop
  46. mov CH, 0
  47. inc CL
  48. cmp DI, SI
  49. jnz loop
  50. ; now reboot if user pressed any key
  51. mov AH, 0x10 ; input a character
  52. int 0x16 ; from keyboard
  53. int 0x19 ; this might not reboot any machine
  54. ; on some machines, it boots the
  55. ; next device.
  56. drawpix:
  57. ; args: X, Y and Color in CH, CL and BH
  58. ; draws a 10x10 square which its starting
  59. ; point is (X,Y) and (X+10,Y+10) its
  60. ; ending point
  61. pusha
  62. mov AL, 10 ; calculating real y
  63. mul CL ; which is 10*Y + 20
  64. mov DX, AX ; and Y is the givel Y
  65. add DX, 20 ; in CL
  66. mov AL, 10 ; calculating real x
  67. mul CH ; which is 10*X + 80
  68. mov CX, AX ; and X is the given X
  69. add CX, 80 ; in CH
  70. mov SI, CX ; saving starting values of CX
  71. mov DI, DX ; and DX, we'll need them later
  72. mov AH, 0x0C ; draw pixel function
  73. mov AL, BH ; color of our dear pixels
  74. mov BH, 0 ; page number
  75. ; this loop draws a 10x10 square
  76. loopxy:
  77. int 0x10
  78. inc CX
  79. push CX
  80. sub CX, SI
  81. cmp CX, 10
  82. pop CX
  83. jnz loopxy
  84. inc DX
  85. mov CX, SI
  86. push DX
  87. sub DX, DI
  88. cmp DX, 10
  89. pop DX
  90. jnz loopxy
  91. popa
  92. ret
  93. times 510 - ($-$$) db 0 ; edit these two lines to suit your need
  94. dw 0xAA55 ; boot sign