home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / asm / 3dvect25 / main1.asm < prev    next >
Encoding:
Assembly Source File  |  1993-09-06  |  8.2 KB  |  299 lines

  1.            .386p
  2.  
  3. code32     segment para public use32
  4.            assume cs:code32, ds:code32
  5.  
  6. ; define externals
  7.  
  8.            include pmode.inc       ; protected mode externals
  9.            include xmouse.inc      ; xmode mouse externals
  10.            include xmode.inc       ; xmode externals by matt pritchard
  11.            include 3d.inc
  12.            include irq.inc
  13.  
  14.            include macros.inc
  15.            include equ.inc
  16.  
  17.            include sphere.inc
  18.            include gamecolr.inc    ; dac palette
  19.  
  20.            include objects.inc     ; table of shapes/colours
  21.            include stuff.inc       ; ending screen stuff
  22.  
  23.            public _main
  24.  
  25. _main:
  26.            sti
  27.  
  28.            push offset defpal
  29.            call fadeoffpalette
  30.  
  31.            pushw xmode
  32.            pushw xactual
  33.            pushw yactual
  34.            pushw pages
  35.            call set_vga_modex
  36.            cmp ax,-1               ; test for error in setting videomode
  37.            jne getout
  38.  
  39.            call wipeoffpalette
  40.  
  41.            mov ax,0+0*256
  42.            mov background,ax
  43.            push ax
  44.            call clear_vga_screen
  45.  
  46.           ;push offset gamecolr
  47.           ;pushw 0
  48.           ;pushw 255
  49.           ;pushw 1
  50.           ;call load_dac_registers
  51.  
  52.            call setupbase
  53.            call initpages
  54.  
  55.            pushw xactual/2
  56.            pushw yactual/2
  57.            call show_mouse
  58.  
  59. comment $
  60.            call flip_page    ; example of how to draw a single polygon
  61.  
  62.            p1x equ -50
  63.            p1y equ -50
  64.            p2x equ -90
  65.            p2y equ 70
  66.            p3x equ 60
  67.            p3y equ 80
  68.  
  69.            mov x1,p1x
  70.            mov y1,p1y
  71.            mov x2,p2x
  72.            mov y2,p2y
  73.            call fakeline
  74.  
  75.            mov x1,p2x
  76.            mov y1,p2y
  77.            mov x2,p3x
  78.            mov y2,p3y
  79.            call fakeline
  80.  
  81.            mov x1,p3x
  82.            mov y1,p3y
  83.            mov x2,p1x
  84.            mov y2,p1y
  85.            call fakeline
  86.  
  87.            mov colq,7
  88.            mov steel,-1
  89.            call poly_fill
  90.  
  91.            call flip_page
  92. $
  93.  
  94.            push o gamecolr
  95.            call fadeonpalette
  96.  
  97.            mov si,cameraobject
  98.            mov bx,0
  99.            mov cx,0
  100.            mov bp,0
  101.            call set_angle
  102.            mov ebx,100000
  103.            mov ecx,25000
  104.            mov ebp,-385000
  105.            call put_object
  106.  
  107.            mov si,0
  108.            mov ebx,-26000
  109.            mov ecx,65000
  110.            mov ebp,0
  111.            call put_object
  112.            call set_object_on
  113.            mov ax,0
  114.            call set_shape
  115.  
  116.            mov si,1
  117.            mov ebx,130000
  118.            mov ecx,0
  119.            mov ebp,50000
  120.            call put_object
  121.            call set_object_on
  122.            mov ax,1
  123.            call set_shape
  124.  
  125.            mov si,2
  126.            mov ebx,50000
  127.            mov ecx,70000
  128.            mov ebp,20000
  129.            call put_object
  130.            call set_object_on
  131.            mov ax,2
  132.            call set_shape
  133.  
  134.            mov si,3
  135.            mov ebx,50000
  136.            mov ecx,-50000
  137.            mov ebp,80000
  138.            call put_object
  139.            call set_object_on
  140.            mov ax,3
  141.            call set_shape
  142.  
  143.            mov si,4
  144.            mov ebx,-70000
  145.            mov ecx,30000
  146.            mov ebp,40000
  147.            call put_object
  148.            call set_object_on
  149.            mov ax,4
  150.            call set_shape
  151.  
  152.            mov si,5
  153.            mov ebx,-50000
  154.            mov ecx,-30000
  155.            mov ebp,10000
  156.            call put_object
  157.            call set_object_on
  158.            mov ax,5
  159.            call set_shape
  160.  
  161.            mov si,6             ; bitmap
  162.            mov ebx,-5000
  163.            mov ecx,5000
  164.            mov ebp,250000
  165.            call put_object
  166.            call set_object_on
  167.            mov ax,0             ; zeroth bitmap
  168.            call set_shape
  169.            mov vxs[6*2],100     ; bitmap scaling (gets added to bitx and bity)
  170.            mov vys[6*2],100     ; bitmap scaling
  171.            mov userotate[6],32  ; it's a bitmap (32)
  172.  
  173.            mov vxadds[2*0],80   ; set objects spin velocity
  174.            mov vyadds[2*0],320
  175.            mov vzadds[2*0],231
  176.  
  177.            mov vxadds[2*1],100
  178.            mov vyadds[2*1],230
  179.            mov vzadds[2*1],122
  180.  
  181.            mov vxadds[2*2],200
  182.            mov vyadds[2*2],590
  183.            mov vzadds[2*2],410
  184.  
  185.            mov vxadds[2*3],320
  186.            mov vyadds[2*3],290
  187.            mov vzadds[2*3],340
  188.  
  189.            mov vxadds[2*4],570
  190.            mov vyadds[2*4],320
  191.            mov vzadds[2*4],400
  192.  
  193.            mov vxadds[2*5],570
  194.            mov vyadds[2*5],320
  195.            mov vzadds[2*5],200
  196.  
  197.            mov acount[2*0],9553  ; objects won't move or spin without counter!!
  198.            mov acount[2*1],8223  ; if your objects don't move, think! did you
  199.            mov acount[2*2],6323  ; set you counter!!, god this is frustrating
  200.            mov acount[2*3],4423  ; when debuging.  counter is number of frames
  201.            mov acount[2*4],3523  ; to move/rotate
  202.            mov acount[2*5],5523
  203.  
  204.            mov si,0              ; follow first object
  205.            mov di,65             ; 35 frames to get there
  206.            call newfollow
  207.  
  208.            mov bitx,15           ; base object scaling
  209.            mov bity,15
  210.            mov bitbase,o sphere
  211.  
  212.            call set_pmirq        ; select irq:use one or the other
  213. ;          call set_rmirq
  214.  
  215.            call reset_raster_count   ; done before any animation loop!!!
  216.  
  217.            call set_makeorder        ; reset sort order - done once in 3d1
  218.  
  219. ieox:
  220.            call look_at_it           ; make camera look at selected object
  221.            call setsincose           ; set rotation multipliers for eye
  222.            call makeobjs             ; plot all objects in sides table
  223.  
  224. ;          call set_makeorder        ; reset sort order - done always in 3d2
  225. ;          call sort_list            ; sort all sides/points/bitmaps
  226. ;          call drawvect             ; draw vectors/bitmaps/points/lines
  227.            call instant_mouse        ; plot mouse on screen
  228.  
  229.            call flip_page            ; flip video pages
  230.            call clear_fill           ; clear video memory (last screen)
  231.            call resetupd             ; reset borders
  232.  
  233.            call updvectors           ; move objects around, rotate them
  234.  
  235.            in al,60h                 ; test keyboard
  236.            cmp al,1
  237.            jne ieox
  238. ieox2:
  239.            in al,60h                 ; test keyboard
  240.            cmp al,1
  241.            je ieox2
  242.  
  243.            mov ax,w temp
  244.            cmp ax,5
  245.            jge ieox4
  246.  
  247.            inc w temp
  248.            inc ax
  249.            mov si,ax     ; ax = object
  250.            mov di,65     ; di = time to get there (# of frames)
  251.            call newfollow
  252.  
  253.            call reset_raster_count   ; done before any animation loop!!!
  254.            jmp ieox
  255. ieox4:
  256.            call reset_raster_count   ; done before any animation loop!!!
  257. ieox3:
  258.            mov wherelook,5  ; force to look at sphered cube
  259.            call look_at_it
  260.            call setsincose
  261.            call makeobjs
  262.  
  263. ;          call set_makeorder
  264. ;          call sort_list
  265. ;          call drawvect
  266.  
  267.            call flip_page
  268.            call clear_fill
  269.            call resetupd
  270.            call updvectors
  271.  
  272.            sub zs[5*4],22000
  273.            mov eax,zs[5*4]
  274.            cmp eax,-3500000
  275.            jg ieox3
  276. getout:
  277. ;          call reset_rmirq  ; use one or the other, could use both if
  278.            call reset_pmirq  ; needed but delete inc traces_past from pmode
  279.  
  280.            jmp endpage       ; jump to stuff.inc for ending
  281.  
  282. temp       dw 0            ; next object to look at, for this demo only
  283.  
  284.            public objbase  ; make sure these are here even if you don't
  285.            public bitbase  ; use them.  tlink will fail if not present.
  286.            public bitx
  287.            public bity
  288.  
  289. numberofobjects equ 32       ; number of 3d objects available to display
  290. numberofbitmaps equ 32       ; number of 3d bitmaps in data tables
  291.  
  292. objbase    dd numberofobjects*4 dup (0) ; memory locations of shapes
  293. bitbase    dd numberofbitmaps*4 dup (0) ; memory locations of bitmaps
  294. bitx       dd numberofbitmaps dup (0)   ; x size of bitmaps (for 3d)
  295. bity       dd numberofbitmaps dup (0)   ; y size of bitmaps
  296.  
  297. code32     ends
  298.            end
  299.