home *** CD-ROM | disk | FTP | other *** search
/ The Equalizer BBS / equalizer-bbs-collection_2004.zip / equalizer-bbs-collection / DEMOSCENE-STUFF / ASMINTRO.ZIP / STERN.ASM < prev    next >
Assembly Source File  |  1994-02-24  |  5KB  |  298 lines

  1. ;-----------------------------------------------       -----------------------+
  2. ;OK, KLEINE STERN-ROUTINE                              |
  3. ;--------------                            --------------+
  4. ;doc lazy of the lkcc berlin                              |
  5. ;---------------                ------------------------------|
  6. ;some greets to: !twin,tt,trill,xxs,ds,ea,synec,lion,iku,tga,baco,stone,brain |
  7. ;-----------------                    ----------------------|
  8. ;look  " . "-file for more information                          |
  9. ;---------------------------        --------------------------------------|
  10.  
  11. .model    small
  12. .286
  13. .stack    100h
  14.  
  15. assume cs:code,ds:data
  16.  
  17. code    segment
  18. ;-------------------------------------
  19. ;SOME EQUS
  20. ;------------
  21. bs_width    equ    320
  22. stars_number    equ    200    ;LIKE LINES IN MODE 13H
  23. random_byte    equ    63    ;2^X-1 XεN
  24.  
  25. ;---------------------------------------
  26. ;SOME VARS
  27. ;-----------
  28. count        dw    0
  29.  
  30. ;------------------------------------------
  31. ;JSUT THE STRUC FOR THE TABLE
  32. ;----------------
  33. star_field    struc
  34.     st_adr        dw    0
  35.     st_start_adr    dw    0
  36.     st_left        dw    0
  37.     st_left_strt    dw    0
  38.     st_bgrd_color    db    0
  39.     st_color    db    0
  40.     st_speed    db    0    ;1/2/4/5/8
  41.     st_wait        db    0
  42.     st_next        dw    0    ;JUST TO GET LENGTH OF STRUC
  43. star_field    ends
  44.  
  45. start:
  46.  
  47.     ;------------------------
  48.     ;SET MODE
  49.         mov    ax,13h
  50.         int    10h
  51.  
  52.         cli
  53.     ;-------------------------
  54.     ;SET PAL
  55.         push    seg data
  56.         pop    ds
  57.         mov    si,offset hpal
  58.         call    raster
  59.         call    setpal
  60.  
  61.     ;------------------------
  62.     ;SET SEGS
  63.         mov    ax,0a000h
  64.         mov    es,ax
  65.  
  66.         push    seg dspic
  67.         pop    ds
  68.     ;-----------------------
  69.     ;PIC TO SCREEN
  70.         sub    di,di
  71.         sub    si,si
  72.         mov    cx,32000
  73.         rep    movsw
  74.  
  75.     ;-------------------------
  76.     ;BEGIN OF THE STARS
  77.         push    seg data
  78.         pop    ds
  79.  
  80.         call    setstar
  81.  
  82.     ;-------------------------------------------
  83.     ;MAKE PIC BIGHT
  84.     ;WITH THE HELP OF PAL AND HPAL
  85.     ;HPAL IS THE PALLETTE WHICH IS OUTED
  86.     ; TO THE VGA..
  87.     ;PAL IS THE PALLETTE WHICH ISI THE GOAL
  88.     ;------
  89.         push    seg data
  90.         pop    ds
  91.  
  92.         mov    bl,63        ;GRAY-STEPS
  93. br_lop1:    push    bx
  94.         mov    di,offset hpal
  95.         mov    si,offset pal
  96.         mov    cx,768
  97. br_lop2:    lodsb
  98.         sub    al,bl
  99.         jnb    br_jmp1
  100.         sub    al,al
  101. br_jmp1:    mov    [di],al
  102.         inc    di
  103.         loop    br_lop2
  104.         call    frame
  105.         pop    bx
  106.         dec    bl
  107.     ;-------
  108.         jne    br_lop1
  109.  
  110.     ;-----------------------------
  111.     ; WAIT FOR A KEY
  112.     ;--------------------
  113. wait_key:    call    frame
  114.         in    al,60h
  115.         cmp    al,1
  116.         jne    wait_key
  117.  
  118.     ;-------------------------------------------
  119.     ;MAKE PIC DARK
  120.     ;------
  121.         mov    bl,63        ;GRAY-STEPS
  122.     ;-------
  123. dr_lop1:    push    bx
  124.         mov    di,offset hpal
  125.         mov    cx,768
  126. dr_lop2:    cmp    byte ptr [di],0
  127.         je    dr_jmp1
  128.         dec    byte ptr [di]
  129. dr_jmp1:    inc    di
  130.         loop    dr_lop2
  131.         call    frame
  132.     ;-------
  133.         pop    bx
  134.         dec    bl
  135.         jne    dr_lop1
  136.  
  137.         mov    ax,3
  138.         int    10h
  139.         mov    ah,4ch
  140.         int    21h
  141.  
  142.  
  143. ;-----------------------------------
  144. ;MAIN-CALL
  145. ;----------
  146. frame:        call    raster
  147.         mov    si,offset hpal
  148.         call    setpal
  149.         call    stars
  150.         ret
  151.  
  152. ;--------------------------------------
  153. ;PUT SOME DATAS INTO THE TABLE
  154. ;-----------
  155. setstar:    push    0a000h
  156.         pop    es
  157.         push    seg data
  158.         pop    ds
  159.         mov    di,offset star_datas
  160.         mov    si,bs_width-1        ;BS_START
  161.         mov    cx,stars_number
  162.     ;------
  163. st0:        mov    [di.ST_ADR],si        ;ADR.
  164.         mov    [di.ST_START_ADR],si
  165.         mov    al,es:[si]
  166.         mov    [di.ST_BGRD_COLOR],al
  167.         mov    ah,byte ptr cs:[count]        ;RANDOM
  168.         and    ah,3
  169.         inc    ah
  170.         cmp    ah,3
  171.         jnz    st1
  172.         inc    ah
  173.     ;AL:=1,2,4
  174. st1:        mov    [di.ST_SPEED],ah
  175.  
  176.         mov    bl,ah
  177.  
  178.         add    ah,251
  179.         mov    [di+st_color],ah    ;COLOR
  180.  
  181.         sub    bh,bh
  182.         mov    ax,320
  183.         sub    dx,dx
  184.         div    bx
  185.         mov    [di.st_left],ax
  186.         mov    [di.st_left_strt],ax
  187.  
  188.         mov    al,byte ptr cs:[count+1]
  189.         mov    byte ptr [di.st_wait],al        ;WAIT
  190.         in    al,41h
  191.         mov    ah,al
  192.         in    al,40h
  193.         sub    word ptr cs:[count],ax
  194.         add    word ptr cs:[count],di
  195.  
  196.         add    di,st_next
  197.         add    si,bs_width
  198.         loop    st0
  199.     ;------
  200.         ret
  201.  
  202.  
  203. ;---------------------------------------
  204. ;MOVE STARS AND PUT THEM TO SCREEN
  205. ;----------------
  206. stars:        push    seg data    ;SURE IS SURE...
  207.         pop    ds
  208.         push    0a000h
  209.         pop    es
  210.  
  211.         mov    cx,stars_number
  212.         mov    di,offset star_datas
  213.     ;------
  214. star1:        push    cx
  215.         cmp    byte ptr [di.st_wait],0
  216.         jz    move
  217.         dec    byte ptr [di.st_wait]
  218.         jmp    next
  219.  
  220. move:        mov    al,[di.st_bgrd_color]
  221.         mov    ah,[di.st_color]
  222.         mov    bx,[di.st_adr]
  223.         cmp    es:[bx],ah
  224.         jnz    no
  225.         mov    byte ptr es:[bx],al
  226.  
  227. no:        dec    word ptr [di.st_left]    ;LEFT
  228.         jz    new
  229.  
  230.         mov    dl,[di.st_speed]
  231.         sub    dh,dh
  232.         sub    bx,dx
  233.         cmp    es:[bx],al
  234.         jnz    no2
  235.         mov    es:[bx],ah
  236. no2:        mov    [di],bx        ;NEW ADR
  237.  
  238. next:        in    al,41h
  239.         mov    ah,al
  240.         in    al,42h
  241.         add    word ptr cs:[count],ax
  242.         add    di,st_next
  243.         pop    cx
  244.         loop    star1
  245.     ;------
  246.         ret
  247.  
  248.  
  249. new:        mov    bx,[di.st_start_Adr]
  250.         mov    [di.st_adr],bx
  251.         mov    bx,[di.st_left_strt]
  252.         mov    [di.st_left],bx
  253.         mov    al,byte ptr cs:[count]
  254.         and    al,random_byte
  255.         mov    [di.st_wait],al
  256.         jmp    next
  257.  
  258.  
  259. ;----------------------------
  260. ;WAIT FOR VBL
  261. ;-------------
  262. raster:        mov    ah,8
  263.         mov    dx,3dah
  264. rast1:        in    al,dx
  265.         and    al,ah
  266.         je    rast1
  267.         ret
  268.  
  269. ;--------------------------------------------
  270. ;PUT PAL TO VGA
  271. ;-------------------
  272. setpal:        mov    cx,300h    ;DS:SI & CLI
  273.         sub    al,al
  274. setcx:        mov    dx,3c8h
  275.         out    dx,al
  276.         inc    dx
  277.         rep    outsb
  278.         ret
  279.  
  280. code    ends
  281.  
  282.  
  283. ;------------------------
  284. dspic segment
  285. include pic.dat
  286. dspic ends
  287.  
  288. ;------------------------
  289. data    segment byte
  290. pal:
  291.     include pal.dat
  292. hpal:
  293.     db 768 dup (0)
  294. star_datas:
  295.     db    stars_number*st_next dup (?)
  296. data    ends
  297.  
  298. end start