home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Animation & Sound / SOS-ANIM_SOUND.ISO / programm / alphapci / bobs.asm < prev    next >
Assembly Source File  |  1993-07-26  |  9KB  |  268 lines

  1. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2. ;
  3. ; BOBS.ASM
  4. ;
  5. ; Shadebobs.
  6. ; FRiAR TuCK [PCi]
  7. ;
  8. ; This is how the "shadebobs" in a lot of demos are done. Many other effects
  9. ; use this type of technique, I figured it out while trying to duplicate the
  10. ; lines in the beginning of Renaissance's "Amnesia".
  11. ;
  12. ; Simple stuff.. Put together a palette with a fade in it, and then go around
  13. ; incrementing the value in the pixel. I use a block of BOBSIZE*BOBSIZE size.
  14. ; XMove and YMove are equates to move the block, but you can use a sine
  15. ; routine, anything.. All you do is put the X and Y coords for the block in
  16. ; [_x] and [_y], and then call _plotbob. Also you must call _init once in
  17. ; the beginning to set the screen and palette. Don't trust anything with
  18. ; these routines, because they're quick hacks. They destroy all registers,
  19. ; except the BP and SP regs.
  20. ;
  21. ; This is made into a .COM file, so all data work is in the same segment...
  22. ; For the uneducated, to create from this source:
  23. ;
  24. ;       TASM bobs
  25. ;       TLINK /t bobs
  26. ;
  27. ; Enjoy!
  28. ; -FT
  29. ;
  30. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  31. ; mumbo jumbo
  32.     DOSSEG
  33.     .MODEL TINY
  34.     .CODE
  35.     .386
  36.     ORG 100h
  37.     ASSUME CS:@CODE, DS:@CODE
  38. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  39. ;
  40. ; GENERAL EQUATES
  41. ;
  42. ;==============================================================================
  43. ; Try different numbers here. BOBBER is the increment in color each time.
  44. BOBSIZE equ 51
  45. XMOVE   equ 19
  46. YMOVE   equ 12
  47. BOBBER  equ 4
  48.  
  49. ; Comment the next line for a neat effect.
  50. ; FULLSCRN equ 1
  51.  
  52. ; Lets make this a .COM file.
  53. START:  jmp begin
  54. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  55. ;
  56. ; GENERAL DATA VARS
  57. ;
  58. ;==============================================================================
  59.  
  60. _x      dw      0
  61. _y      dw      0
  62. xm      db      XMOVE
  63. ym      db      YMOVE
  64.  
  65. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  66. ;
  67. ; PALETTE VALUES
  68. ;
  69. ;==============================================================================
  70. colors  db       0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0
  71.     db       0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0
  72.     db       0, 8, 0, 0, 9, 0, 0,10, 0, 0,11, 0
  73.     db       0,12, 0, 0,13, 0, 0,14, 0, 0,15, 0   ; 16
  74.     db       0,16, 0, 0,17, 0, 0,18, 0, 0,19, 0
  75.     db       0,20, 0, 0,21, 0, 0,22, 0, 0,23, 0
  76.     db       0,24, 0, 0,25, 0, 0,26, 0, 0,27, 0
  77.     db       0,28, 0, 0,29, 0, 0,30, 0, 0,31, 0   ; 32
  78.     db       0,32, 0, 0,33, 0, 0,34, 0, 0,35, 0
  79.     db       0,36, 0, 0,37, 0, 0,38, 0, 0,39, 0
  80.     db       0,40, 0, 0,41, 0, 0,42, 0, 0,43, 0
  81.     db       0,44, 0, 0,45, 0, 0,46, 0, 0,47, 0   ; 48
  82.     db       0,48, 0, 0,49, 0, 0,50, 0, 0,51, 0
  83.     db       0,52, 0, 0,53, 0, 0,54, 0, 0,55, 0
  84.     db       0,56, 0, 0,57, 0, 0,58, 0, 0,59, 0
  85.     db       0,60, 0, 0,61, 0, 0,62, 0, 0,63, 0   ; 64
  86.     db       0,63, 0, 1,63, 1, 2,63, 2, 3,63, 3
  87.     db       4,63, 4, 5,63, 5, 6,63, 6, 7,63, 7
  88.     db       8,63, 8, 9,63, 9,10,63,10,11,63,11
  89.     db      12,63,12,13,63,13,14,63,14,15,63,15   ; 80
  90.     db      16,63,16,17,63,17,18,63,18,19,63,19
  91.     db      20,63,20,21,63,21,22,63,22,23,63,23
  92.     db      24,63,24,25,63,25,26,63,26,27,63,27
  93.     db      28,63,28,29,63,29,30,63,30,31,63,31   ; 96
  94.     db      32,63,32,33,63,33,34,63,34,35,63,35
  95.     db      36,63,36,37,63,37,38,63,38,39,63,39
  96.     db      40,63,40,41,63,41,42,63,42,43,63,43
  97.     db      44,63,44,45,63,45,46,63,46,47,63,47   ; 112
  98.     db      48,63,48,49,63,49,50,63,50,51,63,51
  99.     db      52,63,52,53,63,53,54,63,54,55,63,55
  100.     db      56,63,56,57,63,57,58,63,58,59,63,59
  101.     db      60,63,60,61,63,61,62,63,62,63,63,63   ; 128
  102.  
  103. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  104. ;
  105. ; MACROS
  106. ;
  107. ; I use these macros because they make the code a little more readable.
  108. ; Nuthin' fancy, just nicer lookin'.
  109. ;
  110. ;==============================================================================
  111.  
  112. ; @grmode = set 320x200x256c mode
  113. @grmode macro
  114.     mov     ax,0013h
  115.     int     10h
  116. endm
  117.  
  118. ; @textmode = set 80x25x16c mode
  119. @textmode macro
  120.     mov     ax,0003h
  121.     int     10h
  122. endm
  123.  
  124. ; @terminate = DOS Terminate.
  125. @terminate macro
  126.     mov     ax,4C00h
  127.     int     21h
  128. endm
  129.  
  130. ; @keypressed - check for keypress, zero flag set if yes.
  131. @keypressed macro
  132.     mov     ah,1                    ;check to see if a key's been pressed
  133.     int     16h
  134. endm
  135. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  136. ;
  137. ; CODE BEGINS HERE
  138. ;
  139. ;==============================================================================
  140.  
  141. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  142. ;
  143. ; _INIT
  144. ;
  145. ;       pops the screen into graphics mode, and writes the palette.
  146. ;
  147. ;==============================================================================
  148.  
  149. _init proc near
  150.     @grmode
  151.  
  152.     xor ax,ax
  153.     mov dx,03C8h                    ; Tell the VGA card that the
  154.     out dx,al                       ; Palette's comin'.
  155.  
  156.     mov dx,03C9h                    ; The values go here
  157.     mov cx,384                      ; 3*(128 colors)
  158.     mov si,offset colors            ; Point to the table
  159.     cld                             
  160. in01:   lodsb                           ; In
  161.     out dx,al                       ; and Out
  162.     dec cx                          ; NEXT!
  163.     cmp cx,00h                      ; done?
  164.     jne in01                        ; nope
  165.                     ;
  166.     std                             ; backwards
  167.     dec si                          ; comment this line for green white and
  168.                     ; blue
  169.     mov cx,384                      ;
  170. in02:   lodsb                           ;
  171.     out dx,al                       ;
  172.     dec cx                          ;
  173.     cmp cx,00h                      ;
  174.     jne in02                        ;
  175.     cld                             ; Forwards
  176.  
  177. _init endp
  178.  
  179. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  180. ;
  181. ; _PLOTBOB
  182. ;
  183. ;       Plots a square of [BOBSIZE x BOBSIZE], upper left at [_x,_y]
  184. ;
  185. ;==============================================================================
  186. _plotbob    proc    near
  187.     mov     di,word ptr [_x]    ; DI = x
  188.     mov     cx,di               ; CX = x
  189.     jmp     short pb07          ; compare and continue
  190. pb01:                               ;
  191.     mov     si,word ptr [_y]    ; SI = y
  192.     jmp     short pb06          ; same thing
  193. pb02:                               ;
  194.     mov     ax,si               ; AX = y
  195.     ;
  196.     ; This next stuff is conditional compile, if FULLSCRN is defined
  197.     ; the bob will use the full screen, otherwise it clips
  198.     ;
  199. ifdef fullscrn
  200.     cmp     ax,200              ; AX > 200?
  201.     jl      pb03                ; nope, skip this
  202.     sub     ax,200              ; AX = y - 200
  203. endif
  204. pb03:   mov     dx,320              ;
  205.     imul    dx                  ; AX = (y|y-200) * 320
  206. ifdef fullscrn
  207.     cmp     cx,320              ; CX > 320?
  208.     jl      pb05                ; nope, skip next line
  209.     sub     ax,320              ; AX = AX - 320
  210. endif
  211. pb05:   add     ax,cx               ; AX = (y*320)+x
  212.     mov     bx,ax               ; ES:[AX] is illegal, so use BX
  213.     mov     dx,0A000h           ;
  214.     mov     es,dx               ; ES = segment 0A000 - the screen mem
  215.     add     byte ptr es:[bx],BOBBER  ; PLOT THE POINT!
  216.     inc     si                  ; y = y + 1
  217. pb06:
  218.     mov     ax,word ptr [_y]    ; SI > y+BOBSIZE?
  219.     add     ax,BOBSIZE          ;
  220.     cmp     ax,si
  221.     jg      short pb02          ; nope, NEXT!
  222.     inc     cx                  ; x = x + 1
  223. pb07:
  224.     mov     ax,di               ;
  225.     add     ax,BOBSIZE          ; CX > x+BOBSIZE?
  226.     cmp     ax,cx               ;
  227.     jg      short pb01          ; nope, next X.
  228.     ret     
  229. _plotbob    endp
  230.  
  231. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  232. ;
  233. ; PROGRAM ENTRY POINT
  234. ;
  235. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  236. begin:
  237.     call _init
  238.     mov [_x],0
  239.     mov [_y],0
  240.  
  241. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  242. bg01:   add [_x],XMOVE                  ; Increment the X and Y locations
  243.     add [_y],YMOVE                  ;
  244. ifdef fullscrn
  245.     cmp [_x],320                    ;======================================
  246.     jl bg02                         ;
  247.     sub [_x],320                    ; This stuff is conditional assembled,
  248. bg02:   cmp [_y],200                    ;
  249.     jl bg03                         ; based on the existence of a FULLSCRN
  250.     sub [_y],200                    ;
  251. else                                    ; equate. It clips the screenwork at a
  252.     cmp [_x],320 - BOBSIZE          ;
  253.     jl bg02                         ; MUCH smaller boundary. Looks cool if
  254.     sub [_x],320 - BOBSIZE          ;
  255. bg02:   cmp [_y],200 - BOBSIZE          ; you let it run a while.
  256.     jl bg03                         ;
  257.     sub [_y],200 - BOBSIZE          ;======================================
  258. endif
  259. bg03:   call _plotbob                   ; Plot it.
  260.     @keypressed                     ; Press a key?
  261.     jz     bg01                     ;nope, continue
  262.  
  263.     @textmode
  264. l8r:    @terminate                      ;Terminate.
  265.  
  266.        END START
  267. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  268.