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

  1. ; KAISHGC.ASM
  2. ;
  3. ; hgc, Hercules Grafik:
  4.  
  5. ; hgc, öffentliche Definitionen:
  6.         public    hgc_graphmode    ; 12.08.1990
  7.         public    hgc_textmode    ; 12.08.1990
  8.         public    hgc_horline     ; 12.08.1990
  9.         public    hgc_verline     ; 12.08.1990
  10.         public    hgc_mal         ; 15.08.1990
  11.         public    hgc_char    ; 15.08.1990
  12.         public    hgc_text    ; 15.08.1990
  13.         public    hgc_row        ; 16.08.1990
  14.         public    hgc_kugel    ; 16.08.1990
  15.  
  16. ; hgc, Konstanten:
  17. hgc_adress    equ    03B4h    ; Port-Adressen
  18. hgc_data    equ    03B5h
  19. hgc_modecont    equ    03B8h
  20. hgc_config    equ    03BFh
  21. hgc_graph_off    equ    82h    ; Port-Werte
  22. hgc_graph_on    equ    8Ah
  23. hgc_text_off    equ    20h
  24. hgc_text_on    equ    28h
  25. hgc_graph_conf    equ    3
  26. hgc_text_conf    equ    1
  27. hgc_graph_seg    equ    0B800h    ; Segmente
  28. hgc_text_seg    equ     0B000h
  29. hgc_rowbytes    equ    90    ; Bytes pro Zeile
  30. hgc_bankbytes    equ    2000h    ; Bytes pro Bank
  31. hgc_maxbank    equ    8000h    ; Bytes in allen Banks
  32. hgc_graf_zeilen    equ    16    ; Zeilen pro Zeichen im Grafikzeichensatz
  33. hgc_text_zeilen    equ    8    ; Zeilen pro Zeichen im Textzeichensatz
  34. hgc_text_next    equ    hgc_rowbytes*(hgc_text_zeilen/(hgc_maxbank/hgc_bankbytes))-1
  35. hgc_graf_next    equ    hgc_rowbytes*(hgc_graf_zeilen/(hgc_maxbank/hgc_bankbytes))-2
  36.  
  37. ; hgc, Tabellen:
  38. hgc_graph_value    db    35h,2Dh,2Eh,07h,5Bh,02h,57h,57h,02h,03h,00h,00h
  39. hgc_text_value    db      61h,50h,52h,0Fh,19h,06h,19h,19h,02h,0Dh,10h,00h
  40. hgc_banks    dw    0000h,2000h,4000h,6000h
  41. hgc_and_tab    db    07Fh,0BFh,0DFh,0EFh,0F7h,0FBh,0FDh,0FEh
  42. hgc_or_tab    db    80h,40h,20h,10h,08h,04h,02h,01h
  43. hgc_kugel_data    dw    06000h,0F000h,0F000h,06000h
  44.  
  45. ; hgc, lokale Prozeduren:
  46.  
  47. ; hgc_setmode:
  48. ;
  49. ; Parameter:    CS:SI: ^ auf Port-Register-Wertetabelle
  50. ;
  51. ; verändert:    AX, BX, CX, DX
  52. hgc_setmode    proc near
  53.     push    ds
  54.     push    cs
  55.     pop    ds
  56.     mov    cx,12
  57.     xor    bl,bl
  58.     mov    dx,hgc_adress
  59. hgc_sm_loop:
  60.     mov    al,bl
  61.     out    dx,al
  62.     inc    dx
  63.     lodsb
  64.     out    dx,al
  65.     dec    dx
  66.     inc    bl
  67.     loop    hgc_sm_loop
  68.     pop    ds
  69.         ret
  70. hgc_setmode    endp
  71.  
  72. ; hgc_calcptr
  73. ;
  74. ; Parameter:    AX: X-Koordinate
  75. ;        BX: Y-Koordinate
  76. ;
  77. ; Rückgabe:    ES:DI: ^ auf Bildschirm
  78. ;
  79. ; verändert:    AX, BX, CX, DX
  80. ;        SI, DI
  81. hgc_calcptr    proc near
  82.  
  83.     shr    ax,1            ; DI := X DIV 8
  84.     shr     ax,1
  85.     shr     ax,1
  86.     mov    di,ax
  87.  
  88.     mov    ax,hgc_rowbytes        ; + hgc_rowbytes * (Y DIV 4)
  89.     mov     cx,bx
  90.     shr    cx,1
  91.     shr     cx,1
  92.     mul    cx
  93.     add    di,ax
  94.  
  95.     and    bx,3
  96.     shl     bx,1
  97.         add     di,cs:[bx+(offset hgc_banks)]
  98.     mov     ax,hgc_graph_seg
  99.     mov    es,ax
  100.  
  101.     ret
  102. hgc_calcptr    endp
  103.  
  104.  
  105. ; hgc_setpixel
  106. ;
  107. ; Parameter:    BX: Y-Koordinate im momentanen Byte (0..7)
  108. ;        ES:DI: ^ auf Bildschirm
  109. ;
  110. ; verändert:    AL
  111. hgc_setpixel    proc near
  112.     cmp    farbe,0
  113.     je    hgc_sp_1
  114.     mov    al,cs:[bx+(offset hgc_or_tab)]
  115.     or    es:[di],al
  116.     ret
  117. hgc_sp_1:
  118.     mov    al,cs:[bx+(offset hgc_and_tab)]
  119.     and    es:[di],al
  120.     ret
  121. hgc_setpixel    endp
  122.  
  123. ; hgc_nextline
  124. ;
  125. ; Setzt ES:DI auf die nächste Zeile
  126. hgc_nextline    proc near
  127.     add    di,hgc_bankbytes
  128.         cmp     di,hgc_maxbank
  129.     jb      hgc_nl_fertig
  130.     sub    di,hgc_maxbank-hgc_rowbytes
  131. hgc_nl_fertig:
  132.     ret
  133. hgc_nextline    endp
  134.  
  135. ; hgc_calc_graf
  136. ;
  137. ; Parameter:    BH: Nummer des Zeichens
  138. ;
  139. ; Rückgabe:    DS:SI: ^ auf Grafikzeichen
  140. ;
  141. ; verändert:    BX
  142. hgc_calc_graf    proc near
  143.  
  144.     lds    si,graf_satz
  145.     xor    bl,bl
  146.         shr     bx,1
  147.         shr     bx,1
  148.         shr     bx,1
  149.     add    si,bx
  150.  
  151.     ret
  152. hgc_calc_graf    endp
  153.  
  154.  
  155. ; hgc_setz_graf_z
  156. ;
  157. ; Parameter:    DS:SI: ^ auf Grafikzeichen
  158. ;        ES:DI: ^ auf Bildschirm
  159. hgc_setz_graf_z    proc near
  160.     mov    cx,hgc_graf_zeilen
  161. hgc_sg_loop:
  162.     lodsw
  163.     mov    es:[di],ax
  164.     call    hgc_nextline
  165.     loop    hgc_sg_loop
  166.  
  167.     ret
  168. hgc_setz_graf_z    endp
  169.  
  170. ; hgc_xor_graf_z
  171. ;
  172. ; Parameter:    DS:SI: ^ auf Grafikzeichen
  173. ;        ES:DI: ^ auf Bildschirm
  174. hgc_xor_graf_z    proc near
  175.     mov    cx,hgc_graf_zeilen
  176. hgc_xg_loop:
  177.     lodsw
  178.     xor    es:[di],ax
  179.     call    hgc_nextline
  180.     loop    hgc_xg_loop
  181.  
  182.     ret
  183. hgc_xor_graf_z    endp
  184.  
  185. ; hgc_calc_text
  186. ;
  187. ; Parameter:    AL: Nummer des Zeichens
  188. ;
  189. ; Rückgabe:    DS:SI: ^ auf Grafikzeichen
  190. ;
  191. ; verändert:    AX
  192. hgc_calc_text    proc near
  193.  
  194.     lds    si,text_satz
  195.     xor    ah,ah
  196.     shl     ax,1
  197.     shl     ax,1
  198.     shl     ax,1
  199.     add    si,ax
  200.  
  201.     ret
  202. hgc_calc_text    endp
  203.  
  204.  
  205. ; hgc_setz_text_z
  206. ;
  207. ; Parameter:    DS:SI: ^ auf Textzeichen
  208. ;        ES:DI: ^ auf Bildschirm
  209. ;
  210. ; verändert:    AX,CX,DI
  211. hgc_setz_text_z    proc near
  212.     mov    cx,hgc_text_zeilen
  213. hgc_st_loop:
  214.     lodsb
  215.     mov    es:[di],al
  216.     call    hgc_nextline
  217.     loop    hgc_st_loop
  218.  
  219.     ret
  220. hgc_setz_text_z    endp
  221.  
  222.  
  223. hgc_graphmode    proc far
  224.     cld
  225.     mov    al,hgc_graph_off
  226.     mov    dx,hgc_modecont
  227.     out    dx,al
  228.     mov    si,offset hgc_graph_value
  229.     call    hgc_setmode
  230.     mov    al,hgc_graph_conf
  231.     mov    dx,hgc_config
  232.     out    dx,al
  233.         cmp     auto_cls,0
  234.     je    hgc_gm_no_cls
  235.     mov    ax,hgc_graph_seg
  236.     mov    es,ax
  237.     xor    ax,ax
  238.     xor    di,di
  239.     mov    cx,4000h
  240.     rep    stosw
  241. hgc_gm_no_cls:
  242.     mov    auto_cls,1
  243.     mov    al,hgc_graph_on
  244.     mov    dx,hgc_modecont
  245.     out    dx,al
  246.     ret
  247. hgc_graphmode    endp
  248.  
  249.  
  250. hgc_textmode    proc far
  251.     cld
  252.     mov    al,hgc_text_off
  253.     mov    dx,hgc_modecont
  254.     out    dx,al
  255.     mov    ax,hgc_text_seg
  256.     mov    es,ax
  257.     xor    ax,ax
  258.     xor    di,di
  259.     mov    cx,07D0h
  260.     rep    stosw
  261.     mov    si,offset hgc_text_value
  262.     call    hgc_setmode
  263.     mov    al,hgc_text_conf
  264.     mov    dx,hgc_config
  265.     out    dx,al
  266.     mov    al,hgc_text_on
  267.     mov    dx,hgc_modecont
  268.     out    dx,al
  269.     ret
  270. hgc_textmode    endp
  271.  
  272.  
  273. hgc_horline    proc far
  274. lng        = 6        ; BP + Rücksprung-AD
  275. y        = word ptr [bp+lng]
  276. bis_x        = word ptr [bp+lng+2]
  277. von_x        = word ptr [bp+lng+4]
  278. param_bytes    = 6
  279.     push    bp
  280.     mov    bp,sp
  281.     cld
  282.     inc    bis_x
  283.  
  284.     mov    ax,von_x
  285.     mov    bx,y
  286.     call    hgc_calcptr
  287.     mov    bx,von_x
  288.     and    bx,7
  289.     je    hgc_hl_1
  290.  
  291. hgc_hl_2:
  292.     mov    bx,von_x
  293.     cmp    bx,bis_x
  294.     je    hgc_hl_fertig
  295.     and    bx,7
  296.     je    hgc_hl_3
  297.     call    hgc_setpixel
  298.     inc    von_x
  299.     jmp    short hgc_hl_2
  300.  
  301. hgc_hl_3:
  302.     inc    di
  303.  
  304. hgc_hl_1:
  305.     mov    cx,bis_x
  306.     sub    cx,von_x
  307.     shr     cx,1
  308.     shr     cx,1
  309.     shr     cx,1
  310.     je      hgc_hl_4
  311.     xor    al,al
  312.     cmp    farbe,0
  313.     je    hgc_hl_6
  314.     dec    al
  315. hgc_hl_6:
  316.     rep     stosb
  317.  
  318. hgc_hl_4:
  319.     mov    bx,bis_x
  320.         mov     ax,bx
  321.         and     ax,7
  322.         je      hgc_hl_fertig
  323.     and    bx,0FFF8h
  324.     mov    von_x,bx
  325.  
  326. hgc_hl_5:
  327.     mov    bx,von_x
  328.     cmp    bx,bis_x
  329.     je    hgc_hl_fertig
  330.     and    bx,7
  331.     call    hgc_setpixel
  332.     inc    von_x
  333.     jmp    short hgc_hl_5
  334.  
  335. hgc_hl_fertig:
  336.     pop    bp
  337.     ret    param_bytes
  338. hgc_horline    endp
  339.  
  340.  
  341. hgc_verline    proc far
  342. lng        = 6        ; BP + Rücksprung-AD
  343. bis_y        = word ptr [bp+lng]
  344. von_y        = word ptr [bp+lng+2]
  345. x        = word ptr [bp+lng+4]
  346. param_bytes    = 6
  347.     push    bp
  348.     mov    bp,sp
  349.     cld
  350.  
  351.     mov    ax,x
  352.     mov    bx,von_y
  353.     call    hgc_calcptr
  354.  
  355.     mov    cx,bis_y
  356.     inc    cx
  357.     sub    cx,von_y
  358.     mov    bx,x
  359.     and    bx,7
  360.  
  361. hgc_vl_loop:
  362.     call    hgc_setpixel
  363.     call    hgc_nextline
  364.     loop    hgc_vl_loop
  365.  
  366.     pop    bp
  367.     ret    param_bytes
  368. hgc_verline    endp
  369.  
  370.  
  371. hgc_mal        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.     cld
  381.  
  382.     mov    al,x
  383.     xor    ah,ah
  384.     shl    ax,1
  385.     shl    ax,1
  386.     shl    ax,1
  387.     mov    bx,y
  388.     call    hgc_calcptr
  389.  
  390.     cmp    xorput,0
  391.     pushf
  392.  
  393.         mov     bh,zeichen
  394.     call    hgc_calc_graf
  395.  
  396.     popf
  397.     jne    hgc_mal_1
  398.     call    hgc_setz_graf_z
  399.     jmp    short    hgc_mal_2
  400. hgc_mal_1:
  401.     call    hgc_xor_graf_z
  402. hgc_mal_2:
  403.  
  404.     pop    ds
  405.     pop     bp
  406.     ret    param_bytes
  407. hgc_mal        endp
  408.  
  409.  
  410. hgc_char    proc far
  411. lng        = 6        ; BP + Rücksprung-AD
  412. zeichen        = byte ptr [bp+lng]
  413. y        = word ptr [bp+lng+2]
  414. x        = byte ptr [bp+lng+4]
  415. param_bytes    = 6
  416.     push    bp
  417.     mov    bp,sp
  418.     push    ds
  419.     cld
  420.  
  421.     mov    al,x
  422.     xor    ah,ah
  423.     shl    ax,1
  424.     shl    ax,1
  425.     shl    ax,1
  426.     mov    bx,y
  427.     call    hgc_calcptr
  428.  
  429.     mov     al,zeichen
  430.     call    hgc_calc_text
  431.  
  432.     call    hgc_setz_text_z
  433.  
  434.     pop    ds
  435.     pop     bp
  436.     ret    param_bytes
  437. hgc_char    endp
  438.  
  439.  
  440.  
  441. hgc_text    proc far
  442. lng        = 6        ; BP + Rücksprung-AD
  443. text        = [bp+lng]
  444. y        = word ptr [bp+lng+4]
  445. x        = byte ptr [bp+lng+6]
  446. param_bytes    = 8
  447.  
  448. hgc_tx_repl    macro    zahl1,zahl2
  449.     local    hgc_tx_repl_1
  450.     cmp    al,zahl1
  451.     jne    hgc_tx_repl_1
  452.     mov    al,zahl2
  453.     jmp    short hgc_tx_do
  454. hgc_tx_repl_1:
  455.                   endm
  456.  
  457.     push    bp
  458.     mov    bp,sp
  459.     push    ds
  460.     cld
  461.  
  462.     mov    al,x
  463.     xor    ah,ah
  464.     shl    ax,1
  465.     shl    ax,1
  466.     shl    ax,1
  467.     mov    bx,y
  468.     call    hgc_calcptr
  469.  
  470.     mov    dx,ds
  471.     lds    si,text
  472.     lodsb
  473.     mov    cl,al
  474.     xor    ch,ch
  475. hgc_tx_loop:
  476.     lodsb
  477.     push    cx
  478.     push    si
  479.     push    ds
  480.     cmp    al,129
  481.     jb    hgc_tx_do
  482.     hgc_tx_repl    142,64        ; Ä
  483.     hgc_tx_repl    153,96        ; Ö
  484.     hgc_tx_repl    154,123        ; Ü
  485.     hgc_tx_repl    132,124        ; ä
  486.     hgc_tx_repl    148,125        ; ö
  487.     hgc_tx_repl    129,126        ; ü
  488.     hgc_tx_repl    225,127        ; ß
  489. hgc_tx_do:
  490.     sub    al,20h
  491.     mov    ds,dx
  492.     call    hgc_calc_text
  493.     call    hgc_setz_text_z
  494.     sub    di,hgc_text_next
  495.     pop    ds
  496.     pop    si
  497.     pop    cx
  498.     loop    hgc_tx_loop
  499.  
  500.     pop    ds
  501.     pop     bp
  502.     ret    param_bytes
  503. hgc_text    endp
  504.  
  505.  
  506. hgc_row        proc far
  507. lng        = 6    ; BP + Rücksprung-AD
  508. y        = byte ptr ss:[bp+lng]
  509. param_bytes    = 2
  510.  
  511.     push    bp
  512.     mov    bp,sp
  513.     push    ds
  514.     cld
  515.  
  516.     mov    al,y
  517.     add    al,feld_oben
  518.     xor    ah,ah
  519.     mov    cl,40
  520.     mul    cl
  521.     add    ax,offset spielfeld
  522.     mov    si,ax
  523.  
  524.     mov     ax,feld_x
  525.     mov    bx,c_y
  526.     call    hgc_calcptr
  527.  
  528.     mov    cx,40
  529.  
  530. hgc_row_loop:
  531.     push    cx
  532.  
  533.     lodsb
  534.     push    ds
  535.     push    si
  536.     mov    bh,al
  537.     call    hgc_calc_graf
  538.     call    hgc_setz_graf_z
  539.     sub    di,hgc_graf_next
  540.     pop    si
  541.     pop    ds
  542.     pop    cx
  543.     loop    hgc_row_loop
  544.  
  545.     pop    ds
  546.     pop    bp
  547.     ret    param_bytes
  548. hgc_row        endp
  549.  
  550.  
  551. hgc_kugel    proc far
  552. lng        = 6    ; BP + Rücksprung-AD
  553. y        = word ptr ss:[bp+lng]
  554. x        = word ptr ss:[bp+lng+2]
  555. param_bytes    = 4
  556.     push    bp
  557.     mov    bp,sp
  558.     push    ds
  559.     cld
  560.  
  561.     mov    ax,x
  562.     mov    bx,y
  563.     call    hgc_calcptr
  564.  
  565.     push    cs
  566.     pop    ds
  567.     mov    si,offset hgc_kugel_data
  568.  
  569.     mov    cx,4
  570.     xor    bx,bx
  571.  
  572. hgc_ku_loop:
  573.     push    cx
  574.     lodsw
  575.     mov    cx,x
  576.     and    cx,7
  577.     shr    ax,cl
  578.         xchg    al,ah
  579.     xor    es:[di],ax
  580.     call    hgc_nextline
  581.  
  582.     pop    cx
  583.     loop    hgc_ku_loop
  584.  
  585.     pop    ds
  586.     pop    bp
  587.     ret    param_bytes
  588. hgc_kugel    endp
  589.  
  590.