home *** CD-ROM | disk | FTP | other *** search
/ Die ASC Mega 2 / ASC-Mega2-CD-ROM.iso / SPIELE / KAISER / KAISEGA.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-08-18  |  8.7 KB  |  605 lines

  1. ; KAISEGA.ASM
  2. ;
  3. ; ega, EGA Grafik:
  4.  
  5. ; ega, öffentliche Definitionen:
  6.         public    ega_graphmode    ; 17.08.1990
  7.         public    ega_textmode    ; 18.08.1990
  8.         public    ega_palette    ; 18.08.1990
  9.         public    ega_horline    ; 17.08.1990
  10.         public    ega_verline    ; 17.08.1990
  11.         public    ega_mal        ; 18.08.1990
  12.         public    ega_char    ; 18.08.1990
  13.         public    ega_text    ; 18.08.1990
  14.         public    ega_row        ; 18.08.1990
  15.         public    ega_kugel    ; 18.08.1990
  16.         public    ega_scroll    ; 18.08.1990
  17.  
  18. ; ega, Konstanten:
  19. ega_adress    equ    03CEh    ; Ports
  20. ega_data    equ    03CFh
  21. ega_graph_seg    equ    0A000h    ; Segment
  22. ega_rowbytes    equ    80    ; Bytes pro Zeile
  23. ega_graf_zeilen    equ    16    ; Zeilen pro Zeichen im Grafikzeichensatz
  24. ega_text_zeilen    equ    8    ; Zeilen pro Zeichen im Textzeichensatz
  25. ega_text_next    equ    ega_rowbytes*ega_text_zeilen-1
  26. ega_graf_next    equ    ega_rowbytes*ega_graf_zeilen-2
  27. ega_bankused    equ    28000
  28.  
  29. ; ega, lokale Prozeduren:
  30.  
  31. ; ega_calcptr
  32. ;
  33. ; Parameter:    AX: X-Koordinate
  34. ;        BX: Y-Koordinate
  35. ;
  36. ; Rückgabe:    ES:DI: ^ auf Bildschirm
  37. ;
  38. ; verändert:    DX
  39. ega_calcptr    proc near
  40.  
  41.     shr    ax,1
  42.     shr    ax,1
  43.     shr    ax,1
  44.     mov    di,ax
  45.     mov    ax,ega_graph_seg
  46.     mov    es,ax
  47.     mov    ax,ega_rowbytes
  48.     mul    bx
  49.     add    di,ax
  50.  
  51.     ret
  52. ega_calcptr    endp
  53.  
  54.  
  55. ; ega_farbe
  56. ;
  57. ; verändert:    AX,DX
  58. ega_farbe    proc near
  59.     mov    dx,ega_adress
  60.     mov    al,1
  61.     mov    ah,farbe
  62.     xor    ah,0Fh
  63.     out    dx,ax
  64.     mov    ax,0FF08h
  65.     out    dx,ax
  66.     ret
  67. ega_farbe    endp
  68.  
  69.  
  70. ; ega_setpixel
  71. ;
  72. ; Parameter:    BX: Y-Koordinate im momentanen Byte (0..7)
  73. ;        ES:DI: ^ auf Bildschirm
  74. ;
  75. ; verändert:    AX,DX
  76. ega_setpixel    proc near
  77.     mov    al,es:[di]
  78.     mov    ah,cs:[bx+(offset hgc_or_tab)]
  79.     mov    al,8
  80.     mov    dx,ega_adress
  81.     out    dx,ax
  82.     mov    es:[di],ah
  83.     ret
  84. ega_setpixel    endp
  85.  
  86. ; ega_calc_graf
  87. ;
  88. ; Parameter:    BH: Nummer des Zeichens
  89. ;
  90. ; Rückgabe:    DS:SI: ^ auf Grafikzeichen
  91. ;
  92. ; verändert:    BX
  93. ega_calc_graf    proc near
  94.  
  95.     lds    si,graf_satz
  96.     xor    bl,bl
  97.         shr     bx,1
  98.     add    si,bx
  99.  
  100.     ret
  101. ega_calc_graf    endp
  102.  
  103.  
  104. ; ega_setz_graf_z
  105. ;
  106. ; Parameter:    DS:SI: ^ auf Grafikzeichen
  107. ;        ES:DI: ^ auf Bildschirm
  108. ;        DX: ega_adress
  109. ega_setz_graf_z    proc near
  110.     mov    cx,ega_graf_zeilen
  111.     mov    dx,ega_adress
  112. ega_sg_loop1:
  113.     push    cx
  114.     mov    cx,4
  115.     mov    bx,1
  116. ega_sg_loop2:
  117.     mov    al,1
  118.     mov    ah,bl
  119.     xor    ah,0Fh
  120.     out    dx,ax
  121.     mov    al,es:[di]
  122.     lodsb
  123.     mov    es:[di],al
  124.     mov    al,es:[di+1]
  125.     lodsb
  126.     mov    es:[di+1],al
  127.     shl    bx,1
  128.     mov    ax,1003h
  129.     out    dx,ax
  130.     loop    ega_sg_loop2
  131.  
  132.     mov    ax,0003h
  133.     out    dx,ax
  134.     add    di,ega_rowbytes
  135.     pop    cx
  136.     loop    ega_sg_loop1
  137.  
  138.     ret
  139. ega_setz_graf_z    endp
  140.  
  141. ; ega_xor_graf_z
  142. ;
  143. ; Parameter:    DS:SI: ^ auf Grafikzeichen
  144. ;        ES:DI: ^ auf Bildschirm
  145. ;        DX: ega_adress
  146. ega_xor_graf_z    proc near
  147.     mov    cx,ega_graf_zeilen
  148.     mov    dx,ega_adress
  149.     mov    ax,1803h
  150.     out    dx,ax
  151. ega_xg_loop1:
  152.     push    cx
  153.     mov    cx,4
  154.     mov    bx,1
  155. ega_xg_loop2:
  156.     mov    al,1
  157.     mov    ah,bl
  158.     xor    ah,0Fh
  159.     out    dx,ax
  160.     mov    al,es:[di]
  161.     lodsb
  162.     mov    es:[di],al
  163.     mov    al,es:[di+1]
  164.     lodsb
  165.     mov    es:[di+1],al
  166.     shl    bx,1
  167.     loop    ega_xg_loop2
  168.  
  169.     add    di,ega_rowbytes
  170.     pop    cx
  171.     loop    ega_xg_loop1
  172.  
  173.     mov    ax,0003h
  174.     out    dx,ax
  175.     ret
  176. ega_xor_graf_z    endp
  177.  
  178. ; ega_setz_text_z
  179. ;
  180. ; Parameter:    DS:SI: ^ auf Textzeichen
  181. ;        ES:DI: ^ auf Bildschirm
  182. ;
  183. ; verändert:    AX,CX,DI
  184. ega_setz_text_z    proc near
  185.     mov    cx,ega_text_zeilen
  186. ega_st_loop:
  187.     lodsb
  188.     mov    es:[di],al
  189.     add    di,ega_rowbytes
  190.     loop    ega_st_loop
  191.  
  192.     ret
  193. ega_setz_text_z    endp
  194.  
  195.  
  196. ;
  197. ; ega, globale Prozeduren:
  198. ;
  199. ega_palette    proc far
  200.     les    dx,palette
  201.     mov    ax,1002h
  202.     int    10h
  203.     ret
  204. ega_palette    endp
  205.  
  206.  
  207. ega_graphmode    proc far
  208.     mov    ax,10h
  209.     int    10h
  210.     call    ega_palette
  211.     mov    dx,ega_adress
  212.     mov    ax,00005h
  213.     out    dx,ax
  214.     mov    ax,00003h
  215.     out    dx,ax
  216.     xor    ax,ax
  217.     out    dx,ax
  218.     ret
  219. ega_graphmode    endp
  220.  
  221.  
  222. ega_textmode    proc far
  223.     mov    ax,3
  224.     int    10h
  225.     mov    ah,1
  226.     mov    cx,1000h
  227.     int    10h
  228.     call    ega_palette
  229.     ret
  230. ega_textmode    endp
  231.  
  232.  
  233. ega_horline    proc far
  234. lng        = 6        ; BP + Rücksprung-AD
  235. y        = word ptr [bp+lng]
  236. bis_x        = word ptr [bp+lng+2]
  237. von_x        = word ptr [bp+lng+4]
  238. param_bytes    = 6
  239.     push    bp
  240.     mov    bp,sp
  241.     cld
  242.     inc    bis_x
  243.  
  244.     call    ega_farbe
  245.  
  246.     mov    ax,von_x
  247.     mov    bx,y
  248.     call    ega_calcptr
  249.  
  250.     mov    bx,von_x
  251.     and    bx,7
  252.     je    ega_hl_1
  253.  
  254. ega_hl_2:
  255.     mov    bx,von_x
  256.     cmp    bx,bis_x
  257.     je    ega_hl_fertig
  258.     and    bx,7
  259.     je    ega_hl_3
  260.     call    ega_setpixel
  261.     inc    von_x
  262.     jmp    short ega_hl_2
  263.  
  264. ega_hl_3:
  265.     inc    di
  266.  
  267. ega_hl_1:
  268.     call    ega_farbe
  269.     mov    bx,bis_x
  270.     sub    bx,von_x
  271.     shr     bx,1
  272.         shr     bx,1
  273.         shr     bx,1
  274.     je      ega_hl_4
  275.     mov     cx,bx
  276.     mov     al,0FFh
  277.     rep     stosb
  278.  
  279. ega_hl_4:
  280.     mov    bx,bis_x
  281.         mov     ax,bx
  282.         and     ax,7
  283.         je      ega_hl_fertig
  284.     and    bx,0FFF8h
  285.     mov    von_x,bx
  286.  
  287. ega_hl_5:
  288.     mov    bx,von_x
  289.     cmp    bx,bis_x
  290.     je    ega_hl_fertig
  291.     and    bx,7
  292.     call    ega_setpixel
  293.     inc    von_x
  294.     jmp    short ega_hl_5
  295.  
  296. ega_hl_fertig:
  297.     pop    bp
  298.     ret    param_bytes
  299. ega_horline    endp
  300.  
  301.  
  302. ega_verline    proc far
  303. lng        = 6        ; BP + Rücksprung-AD
  304. bis_y        = word ptr [bp+lng]
  305. von_y        = word ptr [bp+lng+2]
  306. x        = word ptr [bp+lng+4]
  307. param_bytes    = 6
  308.     push    bp
  309.     mov    bp,sp
  310.     cld
  311.     call    ega_farbe
  312.  
  313.     mov    ax,x
  314.     mov    bx,von_y
  315.     call    ega_calcptr
  316.  
  317.     mov    cx,bis_y
  318.     inc    cx
  319.     sub    cx,von_y
  320.     mov    bx,x
  321.     and    bx,7
  322.  
  323. ega_vl_loop:
  324.     call    ega_setpixel
  325.     add    di,ega_rowbytes
  326.     loop    ega_vl_loop
  327.  
  328.     pop    bp
  329.     ret    param_bytes
  330. ega_verline    endp
  331.  
  332.  
  333. ega_mal        proc far
  334. lng        = 6        ; BP + Rücksprung-AD
  335. zeichen        = byte ptr [bp+lng]
  336. y        = word ptr [bp+lng+2]
  337. x        = byte ptr [bp+lng+4]
  338. param_bytes    = 6
  339.     push    bp
  340.     mov    bp,sp
  341.     push    ds
  342.     cld
  343.     call    ega_farbe
  344.  
  345.     mov    al,x
  346.     xor    ah,ah
  347.     shl    ax,1
  348.     shl    ax,1
  349.     shl    ax,1
  350.     mov    bx,y
  351.     call    ega_calcptr
  352.  
  353.     cmp    xorput,0
  354.     pushf
  355.     mov     bh,zeichen
  356.     call    ega_calc_graf
  357.     popf
  358.     jne    ega_mal_1
  359.     call    ega_setz_graf_z
  360.     jmp    short ega_mal_2
  361. ega_mal_1:
  362.     call    ega_xor_graf_z
  363.  
  364. ega_mal_2:
  365.     pop    ds
  366.     pop     bp
  367.     ret    param_bytes
  368. ega_mal        endp
  369.  
  370.  
  371. ega_char    proc far
  372. lng        = 6        ; BP + Rücksprung-AD
  373. zeichen        = byte ptr [bp+lng]
  374. y        = word ptr [bp+lng+2]
  375. x        = byte ptr [bp+lng+4]
  376. param_bytes    = 6
  377.     push    bp
  378.     mov    bp,sp
  379.     push    ds
  380.         call    ega_farbe
  381.     cld
  382.  
  383.     mov    al,x
  384.     xor    ah,ah
  385.     shl    ax,1
  386.     shl    ax,1
  387.     shl    ax,1
  388.     mov    bx,y
  389.     call    ega_calcptr
  390.  
  391.     mov     al,zeichen
  392.     call    hgc_calc_text
  393.  
  394.     call    ega_setz_text_z
  395.  
  396.     pop    ds
  397.     pop     bp
  398.     ret    param_bytes
  399. ega_char    endp
  400.  
  401.  
  402. ega_text    proc far
  403. lng        = 6        ; BP + Rücksprung-AD
  404. text        = [bp+lng]
  405. y        = word ptr [bp+lng+4]
  406. x        = byte ptr [bp+lng+6]
  407. param_bytes    = 8
  408.  
  409. ega_tx_repl    macro    zahl1,zahl2
  410.     local    ega_tx_repl_1
  411.     cmp    al,zahl1
  412.     jne    ega_tx_repl_1
  413.     mov    al,zahl2
  414.     jmp    short ega_tx_do
  415. ega_tx_repl_1:
  416.                   endm
  417.  
  418.     push    bp
  419.     mov    bp,sp
  420.     push    ds
  421.     call    ega_farbe
  422.     cld
  423.  
  424.     mov    al,x
  425.     xor    ah,ah
  426.     shl    ax,1
  427.     shl    ax,1
  428.     shl    ax,1
  429.     mov    bx,y
  430.     call    ega_calcptr
  431.  
  432.     mov    dx,ds
  433.     lds    si,text
  434.     lodsb
  435.     mov    cl,al
  436.     xor    ch,ch
  437. ega_tx_loop:
  438.     lodsb
  439.     push    cx
  440.     push    si
  441.     push    ds
  442.     cmp    al,129
  443.     jb    ega_tx_do
  444.     ega_tx_repl    142,64        ; Ä
  445.     ega_tx_repl    153,96        ; Ö
  446.     ega_tx_repl    154,123        ; Ü
  447.     ega_tx_repl    132,124        ; ä
  448.     ega_tx_repl    148,125        ; ö
  449.     ega_tx_repl    129,126        ; ü
  450.     ega_tx_repl    225,127        ; ß
  451. ega_tx_do:
  452.     sub    al,20h
  453.     mov    ds,dx
  454.     call    hgc_calc_text
  455.     call    ega_setz_text_z
  456.     sub    di,ega_text_next
  457.     pop    ds
  458.     pop    si
  459.     pop    cx
  460.     loop    ega_tx_loop
  461.  
  462.     pop    ds
  463.     pop     bp
  464.     ret    param_bytes
  465. ega_text    endp
  466.  
  467.  
  468. ega_row        proc far
  469. lng        = 6    ; BP + Rücksprung-AD
  470. y        = byte ptr ss:[bp+lng]
  471. param_bytes    = 2
  472.  
  473.     push    bp
  474.     mov    bp,sp
  475.     push    ds
  476.     call    ega_farbe
  477.     cld
  478.  
  479.     mov    al,y
  480.     add    al,feld_oben
  481.     xor    ah,ah
  482.     mov    cl,40
  483.     mul    cl
  484.     add    ax,offset spielfeld
  485.     mov    si,ax
  486.  
  487.     mov     ax,feld_x
  488.     mov    bx,c_y
  489.     call    ega_calcptr
  490.  
  491.     mov    cx,40
  492.  
  493. ega_row_loop:
  494.     push    cx
  495.  
  496.     lodsb
  497.     push    ds
  498.     push    si
  499.     mov    bh,al
  500.     call    ega_calc_graf
  501.     call    ega_setz_graf_z
  502.     sub    di,ega_graf_next
  503.     pop    si
  504.     pop    ds
  505.     pop    cx
  506.     loop    ega_row_loop
  507.  
  508.     pop    ds
  509.     pop    bp
  510.     ret    param_bytes
  511. ega_row        endp
  512.  
  513.  
  514. ega_kugel    proc far
  515. lng        = 6    ; BP + Rücksprung-AD
  516. y        = word ptr ss:[bp+lng]
  517. x        = word ptr ss:[bp+lng+2]
  518. param_bytes    = 4
  519.     push    bp
  520.     mov    bp,sp
  521.     push    ds
  522.     call    ega_farbe
  523.     cld
  524.  
  525.     mov    ax,1803h
  526.     out    dx,ax
  527.     mov    ax,x
  528.     mov    bx,y
  529.     call    ega_calcptr
  530.  
  531.     push    cs
  532.     pop    ds
  533.     mov    si,offset hgc_kugel_data
  534.  
  535.     mov    cx,4
  536.     xor    bx,bx
  537.  
  538. ega_ku_loop:
  539.     push    cx
  540.     mov    al,es:[di]
  541.     lodsw
  542.     mov    cx,x
  543.     and    cx,7
  544.     shr    ax,cl
  545.         xchg    al,ah
  546.     mov    es:[di],al
  547.     mov    al,es:[di+1]
  548.     mov    es:[di+1],ah
  549.     add    di,ega_rowbytes
  550.  
  551.     pop    cx
  552.     loop    ega_ku_loop
  553.  
  554.     pop    ds
  555.     pop    bp
  556.     ret    param_bytes
  557. ega_kugel    endp
  558.  
  559.  
  560. ega_scroll    proc far
  561. lng        = 6    ; BP + Rücksprung-AD
  562. bytes        = word ptr ss:[bp+lng]
  563. bis_y        = word ptr ss:[bp+lng+2]
  564. von_y        = word ptr ss:[bp+lng+4]
  565. param_bytes    = 4
  566.  
  567.     push    bp
  568.     mov    bp,sp
  569.     push    ds
  570.  
  571.     xor    ax,ax
  572.     mov    bx,von_y
  573.     call    ega_calcptr
  574.     mov    si,di
  575.     push    es
  576.     pop    ds
  577.     xor    ax,ax
  578.     mov    bx,bis_y
  579.     call    ega_calcptr
  580.  
  581.         mov     ax,von_y
  582.     cmp    ax,bis_y
  583.     jb    ega_sc_1
  584.     cld
  585.     jmp    short ega_sc_2
  586. ega_sc_1:
  587.     std
  588.     add    si,bytes
  589.     dec    si
  590.     add    di,bytes
  591.     dec    di
  592.  
  593. ega_sc_2:
  594.     call    ega_farbe
  595.     mov    ax,0105h
  596.     out    dx,ax
  597.     mov    cx,bytes
  598.     rep    movsb
  599.  
  600.     mov    ax,0005h
  601.     out    dx,ax
  602.     pop    ds
  603.     pop    bp
  604.     ret    param_bytes
  605. ega_scroll    endp