home *** CD-ROM | disk | FTP | other *** search
/ The Party 1994: Try This At Home / disk_image.bin / source / mythic / writer.asm < prev   
Assembly Source File  |  1994-08-26  |  59KB  |  3,222 lines

  1. ;        (C)93 xToto
  2.  
  3.         TITLE    'Mythic-Writer V1.10'
  4.  
  5.         PAGE    66, 132
  6.  
  7.         P286
  8.         MODEL    SMALL
  9.  
  10. INCLUDE        INCLUDE\BIOS.INC
  11. INCLUDE        INCLUDE\DOS.INC
  12. INCLUDE        INCLUDE\KEYCODES.INC
  13.  
  14. STRWARN        EQU    KBLF, KBCR, '$'
  15.  
  16. PRSEQUENCER    =    03C4H
  17. PRGRAPHICS    =    03CEH
  18. PRCRT        =    03D4H
  19.  
  20. NO        =    0
  21. OFF        =    0
  22. YES        =    1
  23. ON        =    1
  24.  
  25. ENOFF        =    0
  26. ENJUSTOFF    =    1
  27. ENON        =    2
  28. ENJUSTON    =    3
  29.  
  30. CCOLOR        =    256
  31. CBASECOLOR    =    3
  32. CPATTERN        =    4
  33. MSECSPERTICK    =    54945
  34. CCHAR        =    256
  35. BOTTOMLINE    =    24
  36. LEFTCOLUMN    =    0
  37. RIGHTCOLUMN    =    39
  38. TOPLINE        =    0
  39.  
  40. CCURSET        =    2
  41. CCURSOR        =    16
  42. CCURCOLUMN    =    8
  43. CCURLINE    =    8
  44.  
  45. CITEM        =    2
  46. COBJECT        =    8
  47. COBJCOLUMN    =    16
  48. COBJLINE    =    16
  49.  
  50. CSTAR        =    200
  51. CSTARCOLOR    =    5
  52. CBITMAP        =    4
  53. CFRAME        =    2
  54. CFX        =    3
  55. CSCRCOLUMN    =    320
  56. CSCRLINE    =    200
  57. CSTONELINE    =    8
  58. CSTONECOLUMN    =    8
  59. CEXTKEY        =    128
  60. CBCHAR        =    2
  61. CBDELAY        =    2
  62. CCURPHASE    =    16
  63. SEGGFX        =    0A000H
  64.  
  65. CBATTRIBUTE    =    11
  66. CBCURBUFFER    =    CCURCOLUMN * CCURLINE
  67. CBCURSOR    =    CCURLINE * CCURCOLUMN
  68. CBOBJECT    =    COBJLINE * COBJCOLUMN
  69. CBOBJBUFFER    =    CBOBJECT * COBJECT
  70. CBOBJECTPOS    =    COBJECT * 2
  71. CBPARAGRAPH    =    16
  72. CBSCRBUFFER    =    CSCRCOLUMN * CSCRLINE
  73. CBSTACK        =    512
  74. CBCHARSET    =    CCHAR * CCURLINE
  75. CBCOLUMN    =    CCURLINE * (BOTTOMLINE - TOPLINE + 1)
  76. CBLINE        =    CCURCOLUMN * (RIGHTCOLUMN - LEFTCOLUMN + 1)
  77. CBMAP        =    CBCOLUMN * CSCRCOLUMN
  78. CBOBJMASK    =    CITEM * COBJECT * COBJLINE * COBJCOLUMN / CBITMAP
  79.  
  80. Stack        CBSTACK
  81.  
  82. Data        SEGMENT    PUBLIC
  83.         ASSUME    CS:Code,    DS:Data
  84.  
  85. STREXT        DB    '.WRT', 0
  86. STR286ERROR    DB    '286-Processor required.', STRWARN
  87. STRVGAERROR    DB    'VGA-Card required.', STRWARN
  88.         IFDEF    _WRITE
  89. STRACCESSERROR    DB    'Can''t write to file.', STRWARN
  90. STRERROR    DB    'Can''t create file.', STRWARN
  91. STRUSAGE    DB    'Usage: WRITE <FileName>', STRWARN
  92.         ENDIF
  93. IFDEF    _READ
  94. STRACCESSERROR    DB    'Can''t read from file.', STRWARN
  95. STRERROR    DB    'Can''t open file.', STRWARN
  96. STRUSAGE    DB    'Usage: READ <FileName>', STRWARN
  97.         ENDIF
  98. STRHEXNUMBERS    DB    '0123456789ABCDEF', 0
  99. STRQUADNUMBERS    DB    '0123', 0
  100. STRDUALNUMBERS    DB    '01', 0
  101.  
  102. INCLUDE        INCLUDE\PALETTE.INC
  103. INCLUDE        CURSOR\CURSOR.INC
  104. INCLUDE        INCLUDE\STONE.INC
  105.  
  106. OFFSAAABFONTS    =    OFFSET    $
  107. INCLUDE        CHAR\BIG.INC
  108. INCLUDE        CHAR\SMALL.INC
  109. INCLUDE        CHAR\TINY.INC
  110. VGACHARS    =    $
  111.         DB    CCHAR * CCURLINE DUP (0)
  112. INCLUDE        INCLUDE\REQUEST.INC
  113.  
  114. AAABOBJ        =    AABSTAR
  115. INCLUDE        OBJECT\STAR.INC
  116. INCLUDE        OBJECT\HEART.INC
  117.  
  118. OFFSAAABOBJ    =    0A0H
  119. OFFSAAABCUR    =    0C8H
  120. OFFSAABCURBUF    =    0ECH
  121. OFFSAABMBOXBUF    =    0F0H
  122. OFFSAAABOBJBUF    =    CSCRCOLUMN * CITEM * COBJLINE + OFFSAAABOBJ
  123. OFFSAAABSTONE    =    OFFSAAABCUR + CSCRCOLUMN * CCURSET * CCURLINE
  124.  
  125. AOBJECTSEQ    DB    0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0
  126. abObjTimer    DB    000H, 010H, 020H, 030H, 040H, 050H, 060H, 070H
  127.  
  128. offsCursor    DW    OFFSAAABCUR
  129. offsFont    DW      OFFSAAABFONTS
  130. offsPalette    DW    AABCOLOR
  131. offsPattern    DW    AAPATTERN
  132.         IFDEF    _PLAY
  133. offsText    DW    OFFSET    abText
  134.         ENDIF
  135. ynInsert    DB    YES
  136. ynLock        DB    NO
  137.         IFNDEF    _WRITE
  138. ynShowEnd    DB    YES
  139.         ENDIF
  140.  
  141. aenFXDefault    DB    ENON
  142.         DB    ENON
  143.         DB    ENON
  144.  
  145. aenFX        =    $
  146. enStars        DB    ENON
  147. enCursor    DB    ENON
  148. enObjects    DB    ENON
  149.  
  150. AENHANCEPROC    DW    OFFSET    EnhanceStars
  151.         DW    OFFSET    EnhanceCursor
  152.         DW    OFFSET    EnhanceObjects
  153.  
  154. AINITPROC    DW    OFFSET    InitStars
  155.         DW    OFFSET    InitCursor
  156.         DW    OFFSET    InitObjects
  157.  
  158. ATURNOFFPROC    DW    OFFSET    TurnOffStars
  159.         DW    OFFSET    TurnOffCursor
  160.         DW    OFFSET    TurnOffObjects
  161.  
  162. ATURNONPROC    DW    OFFSET    TurnOnStars
  163.         DW    OFFSET    TurnOnCursor
  164.         DW    OFFSET    TurnOnObjects
  165.  
  166. AJUMPPROC    DW    0
  167.         DW    0        ; !
  168.         DW    0
  169.         DW    0
  170.         DW    0
  171.         DW    0
  172.         DW    0
  173.         DW    0
  174.         DW    OFFSET    KeyBackSpace
  175.         DW    0
  176.         DW    0        ; 10
  177.         DW    0
  178.         DW    0
  179.         DW    OFFSET    KeyReturn
  180.         DW    0
  181.         DW    0
  182.         DW    0
  183.         DW    0
  184.         DW    0
  185.         IFDEF    _WRITE
  186.         DW    OFFSET    ResetFile
  187.         ELSE
  188.         DW    0
  189.         ENDIF
  190.         DW    OFFSET    AskText ; 20
  191.         DW    0
  192.         DW    0
  193.         DW    OFFSET    AskInfo
  194.         DW    OFFSET    AskObject
  195.         DW    OFFSET  AskPattern
  196.         DW    0
  197.         DW    0
  198.         DW    0
  199.         DW    0
  200.         DW    0        ; 30
  201.         DW    0
  202.         DW    0
  203.         DW    OFFSET    AskFont
  204.         DW    0
  205.         DW    OFFSET    AskHelp
  206.         DW    0
  207.         DW    0
  208.         DW    OFFSET    KeyInsLine
  209.         DW    0
  210.         DW    0        ; 40
  211.         DW    0
  212.         DW    0
  213.         DW    0
  214.         DW    OFFSET    KeyDelLine
  215.         DW    0
  216.         DW    OFFSET    AskCursor
  217.         DW    0
  218.         DW    OFFSET    AskBack
  219.         DW    0
  220.         DW    0        ; 50
  221.         DW    0
  222.         DW    0
  223.         DW    0
  224.         DW    0
  225.         DW    0
  226.         DW    0
  227.         DW      0
  228.         DW      0
  229.         DW    OFFSET  AskHelp
  230.         DW    OFFSET    SwitchStars ; 60
  231.         DW    OFFSET    SwitchCursor
  232.         DW    OFFSET    SwitchSprites
  233.         DW    OFFSET    KeyClear
  234.         DW    0
  235.         DW    0
  236.         DW    0
  237.         DW    0
  238.         DW    0
  239.         DW    0
  240.         DW    0        ; 70
  241.         DW    OFFSET  KeyToLeft
  242.         DW    OFFSET  KeyUp
  243.         DW    OFFSET    KeyToUp
  244.         DW    0
  245.         DW    OFFSET  KeyLeft
  246.         DW    0
  247.         DW    OFFSET  KeyRight
  248.         DW    0
  249.         DW    OFFSET  KeyToRight
  250.         DW    OFFSET  KeyDown    ; 80
  251.         DW    OFFSET    KeyToDown
  252.         DW    OFFSET    KeyInsert
  253.         DW    OFFSET  KeyDelete
  254.         DW    0
  255.         DW    0
  256.         DW    0
  257.         DW    0
  258.         DW    0
  259.         DW    0
  260.         DW    0        ; 90
  261.         DW    0
  262.         DW    0
  263.         DW    0
  264.         DW    0
  265.         DW    0
  266.         DW    0
  267.         DW    0
  268.         DW    0
  269.         DW    0
  270.         DW    0        ; 100
  271.         DW    0
  272.         DW    0
  273.         DW    0
  274.         DW    0
  275.         DW    0
  276.         DW    0
  277.         DW    0
  278.         DW    0
  279.         DW    0
  280.         DW    0        ; 110
  281.         DW    0
  282.         DW    0
  283.         DW    0
  284.         DW    0
  285.         DW    0
  286.         DW    0
  287.         DW    0
  288.         DW    0
  289.         DW    0
  290.         DW    0        ; 120
  291.         DW    0
  292.         DW    0
  293.         DW    0
  294.         DW    0
  295.         DW    0
  296.         DW    0
  297.         DW    0
  298.  
  299. ;        Uninitialisierte Variablen werden auf 0 gesetzt
  300. ;
  301.  
  302. offsFirstVoid    =    OFFSET    $
  303.  
  304. BackColor    DB    ?
  305. BitPlane    DB    ?
  306. cRepeat        DB    ?
  307. CursorNewX    DW    ?
  308. CursorNewY    DW    ?
  309. CursorX        DW    ?
  310. CursorY        DW    ?
  311.         DW    2 * (CFRAME - 1) DUP (?)
  312. Delay        DW    ?
  313. iCursor        DW    ?
  314. iFrame        DW    ?
  315. iItem        DW    ?
  316. iObject        DW    ?
  317. iPhase        DW    ?
  318.         IFNDEF    _WRITE
  319. NextChar    DW    ?
  320.         ENDIF
  321. offs        DW    ?
  322. offsChar    DW    ?
  323. offsFileName    DW    ?
  324. offsFrame    DW    ?
  325. OldRWMode    DB    ?
  326. segFileName    DW    ?
  327.         IFDEF    _PLAY
  328. segText        DW    ?
  329.         ENDIF
  330. Random        DW    ?
  331.         IFNDEF    _PLAY
  332. skey        DW    ?
  333.         ENDIF
  334. Timer        DW    ?
  335. TimerLast    DW    ?
  336. XPos        DW    ?
  337. YPos        DW    ?
  338.         DW    2 * CFRAME DUP (?)
  339. ynError        DB    ?
  340. ynFXOn        DB    ?
  341. ynQuit        DB    ?
  342. ynSingle    DB    ?
  343. ynSkip        DB    ?
  344. Char        DW    ?
  345.  
  346. ;        Koordinaten der MessageBox in Zeichen
  347. ;
  348. MBox_Coords     =    MBox_Left
  349. MBox_Left    DW    ?
  350. MBox_Top    DW    ?
  351. MBox_Right    DW    ?
  352. MBox_Bottom    DW    ?
  353. MBox_Text    DW    ?
  354.  
  355. aoffsItem    DW    COBJECT            DUP    (?)
  356. aoffsMask    DW    COBJECT            DUP    (?)
  357. aoffsObj    DW    COBJECT    * CFRAME    DUP    (?)
  358. aoffsObjNew    DW    COBJECT            DUP    (?)
  359. abAttribBuffer    DB    CBATTRIBUTE        DUP    (?)
  360. aaabObjMask    DB    CBOBJMASK        DUP    (?)
  361. awStarX        DW    CSTAR * CFRAME        DUP    (?)
  362.  
  363. offsLastVoid    =    OFFSET    $
  364. cbVoid        =    offsLastVoid - offsFirstVoid
  365.  
  366.         IFDEF    _PLAY
  367. dummy        DB    0
  368.         IFDEF   _TEST
  369. abText        DW    'H', 50
  370.         DW    'a', 50
  371.         DW    'l', 50
  372.         DW    'l', 50
  373.         DW    'o', 50
  374.         DW    KBESC, 50
  375.         ELSE
  376. abText        =    $
  377.         ENDIF
  378.         ENDIF
  379. Data        ENDS
  380.  
  381. Code        SEGMENT    PUBLIC
  382.         ASSUME    CS:Code,    DS:Data
  383.  
  384.  
  385. ; *****************************************************************************
  386. ; Holt das nächste Zeichen aus dem Speicher: C
  387. ; *****************************************************************************
  388.         IFDEF    _PLAY
  389. AccessFile    PROC
  390.         push    si
  391.         push    es
  392.         push    ax
  393.         mov    si, offsText
  394.         mov    es, segText
  395.         mov    ax, es:[si]
  396.         mov    NextChar, ax
  397.         mov    ax, es:[si+CBCHAR]
  398.         mov    Delay, ax
  399.         add    offsText, CBCHAR + CBDELAY
  400.         cmp    offsText, CBPARAGRAPH
  401.         jna    AccessFile_Ok
  402.         sub    offsText, CBPARAGRAPH
  403.         inc     segText
  404. AccessFile_Ok:    mov    cRepeat, CFRAME
  405.         dec    Delay
  406.         clc
  407.         pop    ax
  408.         pop    es
  409.         pop    si
  410.         ret
  411. AccessFile    ENDP
  412.         ENDIF
  413.  
  414. ; *****************************************************************************
  415. ; Liest die Informationen zum nächsten Zeichen aus der Datei: C
  416. ; *****************************************************************************
  417.         IFDEF    _READ
  418. AccessFile    PROC
  419.         pusha
  420.         mov    ah, DOS_Read_FROM_HANDLE
  421.         mov    bx, skey
  422.         mov    cx, cbChar
  423.         mov    dx, OFFSET NextChar
  424.         int    DOS_FUNCTION
  425.         jc    Access_Error
  426.         cmp    ax, cbChar
  427.         jne    Access_Error
  428.  
  429. ;        Liest die Verzügerung
  430. ;
  431.         mov    ah, DOS_Read_FROM_HANDLE
  432.         mov    bx, skey
  433.         mov    cx, cbDelay
  434.         mov    dx, OFFSET Delay
  435.         int    DOS_FUNCTION
  436.         jc    Access_Error
  437.         cmp    ax, cbDelay
  438.         jne    Access_Error
  439.         clc
  440.         mov    cRepeat, CFRAME
  441.         dec    Delay
  442.         jmp    Access_End
  443.  
  444. Access_Error:    mov    ynError, YES
  445.         stc
  446. Access_End:    popa
  447.         ret
  448. AccessFile    ENDP
  449.         ENDIF
  450.  
  451. ; *****************************************************************************
  452. ; Schreibt die Informationen zum nächsten Zeichein in die Datei: C
  453. ; *****************************************************************************
  454.         IFDEF    _WRITE
  455. AccessFile    PROC
  456.         pusha
  457.         call    GetDelay
  458.         mov    ah, DOS_WRITE_TO_HANDLE
  459.         mov    bx, skey
  460.         mov    cx, cbChar
  461.         mov    dx, OFFSET Char
  462.         int    DOS_FUNCTION
  463.         jc    Access_Error
  464.         cmp    ax, cbChar
  465.         jne    Access_Error
  466.  
  467. ;        Schreibt die Verzügerung
  468. ;
  469.         mov    ah, DOS_WRITE_TO_HANDLE
  470.         mov    bx, skey
  471.         mov    cx, cbDelay
  472.         mov    dx, OFFSET Delay
  473.         int    DOS_FUNCTION
  474.         jc    Access_Error
  475.         cmp    ax, cbDelay
  476.         jne    Access_Error
  477.         jmp    Access_End
  478. Access_Error:    mov    ynError, YES
  479.         stc
  480. Access_End:    popa
  481.         ret
  482. AccessFile    ENDP
  483.         ENDIF
  484.  
  485. ActualizeCursor    PROC
  486.         push    ax
  487.         push    si
  488.         mov    si, iFrame
  489.         shl    si, 2
  490.         add    si, OFFSET CursorX
  491.         mov    ax, CursorNewX
  492.         mov    ds:[si], ax
  493.         mov    ax, CursorNewY
  494.         mov    ds:[si+2], ax
  495.         pop    si
  496.         pop    ax
  497.         ret
  498. ActualizeCursor    ENDP
  499.  
  500. ; *****************************************************************************
  501. ; Dialogboxen auf dem Bildschirm darstellen
  502. ; *****************************************************************************
  503. AskBack        PROC
  504.         pusha
  505.         mov    si, OFFSET BACKREQUESTER
  506.         call    MessageBox
  507.         jc    AskBack_End
  508.         call    UpCase
  509.         mov    ax, Char
  510.         mov    di, OFFSET STRHEXNUMBERS
  511.         call    Pos
  512.         jc    AskBack_End
  513.         mov    si, OFFSET ABACKCOLOR
  514.         add    si, cx
  515.         mov    al, ds:[si]
  516.         mov    BackColor, al
  517. AskBack_End:    popa
  518.         ret
  519. AskBack        ENDP
  520.  
  521. AskCursor    PROC
  522.         pusha
  523.         mov    si, OFFSET CURSORREQUESTER
  524.         call    MessageBox
  525.         jc    AskCursor_End
  526.         mov    ax, Char
  527.         mov    di, OFFSET STRDUALNUMBERS
  528.         call    Pos
  529.         jc    AskCursor_End
  530.         mov    iCursor, cx
  531.         mov    ax, cx
  532.         mov    dx, CCURLINE * CSCRCOLUMN
  533.         mul    dx
  534.         add    ax, OFFSAAABCUR
  535.         mov    offsCursor, ax
  536. AskCursor_End:    popa
  537.         ret
  538. AskCursor    ENDP
  539.  
  540.         IFNDEF    _WRITE
  541. AskEnd        PROC
  542.         push    ax
  543.         push    si
  544.         mov    ynLock, YES
  545. AskEnd_Wait:    call    ExpectRetrace
  546.         call    ExpectPicture
  547.         call    SwitchFrame
  548.         call    TurnOffFX
  549.         mov    ax, 1
  550.         call    EnhanceTimer
  551.         cmp    ynShowEnd, YES
  552.         jne    AskEnd_NoShow
  553.         cmp    iFrame, 0
  554.         jne    AskEnd_NoShow
  555.         mov    si, OFFSET ENDREQUESTER
  556.         call    MessageBox
  557.         mov    ynShowEnd, NO
  558. AskEnd_NoShow:    call    TurnOnFX
  559.         call    GetKey
  560.         jc    AskEnd_Wait
  561.         pop    si
  562.         pop    ax
  563.         ret
  564. AskEnd        ENDP
  565.         ENDIF
  566.  
  567. AskFont        PROC
  568.         pusha
  569.         mov    si, OFFSET FONTREQUESTER
  570.         call    MessageBox
  571.         jc    AskFont_End
  572.         mov    ax, Char
  573.         mov    di, OFFSET STRQUADNUMBERS
  574.         call    Pos
  575.         jc    AskFont_End
  576.         shl    cx, 11
  577.         add    cx, OFFSAAABFONTS
  578.         mov    offsFont, cx
  579. AskFont_End:    popa
  580.         ret
  581. AskFont        ENDP
  582.  
  583. AskText        PROC
  584.         pusha
  585.         mov    si, OFFSET FRONTREQUESTER
  586.         call    MessageBox
  587.         jc    AskText_End
  588.         mov    ax, Char
  589.         mov    di, OFFSET STRHEXNUMBERS
  590.         call    Pos
  591.         jc    AskText_End
  592.         shl    cx, 4
  593.         add    cx, OFFSET AABCOLOR
  594.         mov    offsPalette, cx
  595. AskText_End:    popa
  596.         ret
  597. AskText        ENDP
  598.  
  599. AskHelp        PROC
  600.         push    si
  601.         mov    si, OFFSET HELP1REQUESTER
  602.         call    MessageBox
  603.         mov    si, OFFSET HELP2REQUESTER
  604.         call    MessageBox
  605.         pop    si
  606.         ret
  607. AskHelp        ENDP
  608.  
  609. AskInfo        PROC
  610.         push    si
  611.         mov    si, OFFSET INFOREQUESTER
  612.         call    MessageBox
  613.         pop    si
  614.         ret
  615. AskInfo        ENDP
  616.  
  617. AskObject    PROC
  618.         pusha
  619.         mov    si, OFFSET OBJECTREQUESTER
  620.         call    MessageBox
  621.         jc    AskObject_End
  622.         mov    ax, Char
  623.         mov    di, OFFSET STRDUALNUMBERS
  624.         call    Pos
  625.         jc    AskObject_End
  626.         mov    iItem, cx
  627. AskObject_End:    popa
  628.         ret
  629. AskObject    ENDP
  630.  
  631. AskPattern    PROC
  632.         pusha
  633.         mov    si, OFFSET PATTERNREQUESTER
  634.         call    MessageBox
  635.         mov    ax, Char
  636.         mov    di, OFFSET STRQUADNUMBERS
  637.         call    Pos
  638.         jc    AskPattern_End
  639.         shl    cx, 6
  640.         add    cx, OFFSET AAPATTERN
  641.         mov    offsPattern, cx
  642. AskPattern_End: popa
  643.         ret
  644. AskPattern    ENDP
  645.  
  646. ClearLatches    PROC
  647.         push    ds
  648.         push    si
  649.         mov    ax, SEGGFX
  650.         mov    ds, ax
  651.         mov    si, CSCRLINE * CSCRCOLUMN
  652.         lodsb
  653.         pop    si
  654.         pop    ds
  655.         ret
  656. ClearLatches    ENDP
  657.  
  658. ; *****************************************************************************
  659. ; Schließt die Textdatei
  660. ; *****************************************************************************
  661.         IFNDEF    _PLAY
  662. CloseFile    PROC
  663.         push    ax
  664.         push    bx
  665.         mov    ah, DOS_CLOSE_FILE
  666.         mov    bx, skey
  667.  
  668.         int    DOS_FUNCTION
  669.         pop    bx
  670.         pop    ax
  671.         ret
  672. CloseFile    ENDP
  673.         ENDIF
  674.  
  675. ; *****************************************************************************
  676. ; Konvertiert die Objekte in das Video-Format
  677. ; *****************************************************************************
  678. Convert        PROC
  679.         pusha
  680.         mov    bp, sp
  681.         add    bp, 012H
  682.         mov    dx, PRSEQUENCER
  683.         mov    al, 002H
  684.         out    dx, al
  685.         inc    dx
  686.         mov    al, 001H
  687.         mov    bx, ss:[bp]
  688.         mov    si, ss:[bp+2]
  689.         mov    di, ss:[bp+4]
  690.         mov    cx, ss:[bp+6]
  691. Convert_NextLn:    push    cx
  692.         mov    cx, ss:[bp+8]
  693. Convert_NextCl:    out    dx, al
  694.         mov    ah, ds:[si]
  695.         mov    es:[di], ah
  696.         or    ah, ah
  697.         je    Convert_Blank
  698.         mov    ah, 0FFH
  699.         mov    ds:[si], ah
  700. Convert_Blank:    inc    si
  701.         add    al, al
  702.         cmp    al, 010H
  703.         jne    Convert_Next
  704.         inc    di
  705.         mov    al, 001H
  706. Convert_Next:    loop    Convert_NextCl
  707.         pop    cx
  708.         sub    di, bx
  709.         add    di, CSCRCOLUMN
  710.         loop    Convert_NextLn
  711.         popa
  712.         ret    10
  713. Convert        ENDP
  714.  
  715. ConvertChars    PROC
  716.         pusha
  717.         mov    bp, OFFSET ABCPHASE
  718.         mov    ax, CCURCOLUMN
  719.         mov    dx, CCURLINE
  720.         mov    di, OFFSAAABCUR
  721.         mov    si, OFFSET AAAABCURSOR
  722.         mov    bx, CCURCOLUMN / CBITMAP
  723.         mov    cx, CCURSET + 1
  724. ConvChr_NextIt:    push    cx
  725.         xor    ch, ch
  726.         mov    cl, ds:[bp]
  727. ConvChr_Next:    push    ax
  728.         push    dx
  729.         push    di
  730.         push    si
  731.         push    bx
  732.         call    Convert
  733.         add    si, CBCURSOR
  734.         add    di, CCURCOLUMN / CBITMAP
  735.         loop    ConvChr_Next
  736.         mov    cl, ds:[bp]
  737.         shl    cl, 1
  738.         sub    di, cx
  739.         add    di, CSCRCOLUMN * CCURLINE
  740.         inc    bp
  741.         pop    cx
  742.         loop    ConvChr_NextIt
  743.         popa
  744.         ret
  745. ConvertChars    ENDP
  746.  
  747. ConvertObjects    PROC
  748.         pusha
  749.         mov    ax, COBJCOLUMN
  750.         mov    dx, COBJLINE
  751.         mov    di, OFFSAAABOBJ
  752.         mov    si, OFFSET AAABOBJ
  753.         mov    bx, COBJCOLUMN / CBITMAP
  754.         mov    cx, CITEM
  755. ConvObj_NextIt:    push    cx
  756.         mov    cx, COBJECT
  757. ConvObj_Next:    push    ax
  758.         push    dx
  759.         push    di
  760.         push    si
  761.         push    bx
  762.         call    Convert
  763.         add    si, CBOBJECT
  764.         add    di, COBJCOLUMN / CBITMAP
  765.         loop    ConvObj_Next
  766.         pop    cx
  767.         add    di, CSCRCOLUMN * COBJLINE - COBJCOLUMN * 2
  768.         loop    ConvObj_NextIt
  769.  
  770. ;        Bitmasken anlegen
  771. ;
  772.         mov    si, OFFSET AAABOBJ
  773.         mov    di, OFFSET aaabObjMask
  774.         push    es
  775.         push    ds
  776.         pop    es
  777.         mov    cx, CBOBJMASK
  778. ConvObj_NextMsk:push    cx
  779.         xor    ah, ah
  780.         mov    cx, CBITMAP
  781. ConvObj_NextBit:shr    ah, 1
  782.         lodsb
  783.         or    al, al
  784.         je    ConvObj_Void
  785.         or    ah, 008H
  786. ConvObj_Void:    loop    ConvObj_NextBit
  787.         mov    al, ah
  788.         stosb
  789.         pop    cx
  790.         loop    ConvObj_NextMsk
  791.         pop    es
  792.         popa
  793.         ret
  794. ConvertObjects    ENDP
  795.  
  796. ; *****************************************************************************
  797. ; Schaltet die Rahmenfarbe auf Schwarz
  798. ; *****************************************************************************
  799.         IFDEF    _TEST
  800. DarkBorder    PROC
  801.         push    ax
  802.         push    dx
  803.         mov    dx, 003C0H
  804.         mov    al, 031H
  805.         out    dx, al
  806.         mov    al, 000H
  807.         out    dx, al
  808.         pop    dx
  809.         pop    ax
  810.         ret
  811. DarkBorder    ENDP
  812.         ENDIF
  813.  
  814. ; *****************************************************************************
  815. ; Führt Aktionen auf dem Bildschirm aus
  816. ; *****************************************************************************
  817. DoABC        PROC
  818.         pusha
  819.         cmp    ynSingle, YES
  820.         je    DoABC_Single
  821.         mov    ax, Char
  822.  
  823. ;        Kontrolle auf Ende
  824. ;
  825.         cmp    ax, KBESC
  826.         jne    DoABC_NotEnd
  827.         mov    ynQuit, YES
  828.         jmp    DoABC_End
  829.  
  830. ;        Kontrolle auf Rückschritt
  831. ;
  832. DoABC_NotEnd:    cmp    ax, KBBS
  833.         jne    DoABC_NoBS
  834.         call    KeyBackSpace
  835.         jmp    DoABC_End
  836.  
  837. ;        Kontrolle auf Zeilenvorschub
  838. ;
  839. DoABC_NoBS:    cmp    ax, KBLF
  840.         je    DoABC_End
  841.         cmp    ax, KBCR
  842.         jne    DoABC_NoCR
  843.         call    KeyReturn
  844.         jmp    DoABC_End
  845.  
  846. ;        Kontrolle aus ASCII-Textzeichen
  847. ;
  848. DoABC_NoCR:    or    ah, ah
  849.         jne    DoABC_Ext
  850.         call    KeyABC
  851.         jmp    DoABC_End
  852.  
  853. ;        Ansprung einer Funktion für Steuerzeichen
  854. ;
  855. DoABC_Ext:    shr    ax, 7
  856.         mov    si, ax
  857.         add    si, OFFSET AJUMPPROC
  858.         mov    bx, ds:[si]
  859.         or    bx, bx
  860.         je    DoABC_End
  861.         call    bx
  862.         jmp    DoABC_End
  863. DoABC_Single:    mov    ynSingle, NO
  864.         mov    ynSkip, YES
  865. DoABC_End:    dec    cRepeat
  866.         call    ResetCursor
  867.         call    ActualizeCursor
  868.         popa
  869.         ret
  870. DoABC        ENDP
  871.  
  872. DoClear        PROC
  873.         pusha
  874.         call    ClearLatches
  875.         xor    di, di
  876.         mov    cx, CSCRLINE
  877. DoClear_NextLn:    push    cx
  878.         mov    cx, CSCRCOLUMN / CBITMAP
  879.         rep    stosb
  880.         add    di, (CSCRCOLUMN * (CBITMAP - 1)) / CBITMAP
  881.         pop    cx
  882.         loop    DoClear_NextLn
  883.  
  884. ;        Uhr vorstellen
  885. ;
  886.         mov    ax, 2
  887.         call    EnhanceTimer
  888.         popa
  889.         ret
  890. DoClear        ENDP
  891.  
  892. DoDown        PROC
  893.  
  894. ;        Bildinhalt verschieben und neue Zeile leeren
  895. ;
  896.         pusha
  897.         std
  898.         mov    si, (CSCRLINE - CCURLINE - 1) * CSCRCOLUMN + CSCRCOLUMN / CBITMAP - 1
  899.         mov    di, (CSCRLINE - 1) * CSCRCOLUMN + CSCRCOLUMN / CBITMAP - 1
  900.         push    ds
  901.         push    es
  902.         pop    ds
  903.         mov    cx, CSCRLINE - CCURLINE
  904. DoDown_NextCpy: push    cx
  905.         mov    cx, CSCRCOLUMN / CBITMAP
  906.         rep    movsb
  907.         sub    di, (CSCRCOLUMN * (CBITMAP - 1)) / CBITMAP
  908.         sub    si, (CSCRCOLUMN * (CBITMAP - 1)) / CBITMAP
  909.         pop    cx
  910.         loop    DoDown_NextCpy
  911.         pop    ds
  912.         cld
  913.  
  914.         call    ClearLatches
  915.         xor    di, di
  916.         mov    cx, CCURLINE
  917. DoDown_NextClr:    push    cx
  918.         mov    cx, CSCRCOLUMN / CBITMAP
  919.         rep    stosb
  920.         add    di, (CSCRCOLUMN * (CBITMAP - 1)) / CBITMAP
  921.         pop    cx
  922.         loop    DoDown_NextClr
  923.  
  924. ;        Uhr vorstellen
  925. ;
  926.         mov    ax, 2
  927.         call    EnhanceTimer
  928.         popa
  929.         ret
  930. DoDown        ENDP
  931.  
  932. DoInsert    PROC
  933.         pusha
  934.         call    GetCurOffset
  935.         std
  936.         mov    dx, RIGHTCOLUMN
  937.         sub    dx, xPos
  938.         add    dx, dx
  939.         mov    si, offs
  940.         add    si, (CCURLINE - 1) * CSCRCOLUMN - 1
  941.         add    si, dx
  942.         mov    di, si
  943.         add    di, CCURCOLUMN / CBITMAP
  944.         push    ds
  945.         push    es
  946.         pop    ds
  947.         mov    cx, CCURLINE
  948. DoIns_NextLn:    push    cx
  949.         mov    cx, dx
  950.         rep    movsb
  951.         call    ClearLatches
  952.         mov    cx, CCURCOLUMN / CBITMAP
  953.         rep    stosb
  954.         add    si, dx
  955.         sub    si, CSCRCOLUMN
  956.         add    di, dx
  957.         sub    di, CSCRCOLUMN - (CCURCOLUMN / CBITMAP)
  958.         pop    cx
  959.         loop    DoIns_NextLn
  960.         cld
  961.         pop    ds
  962.         popa
  963.         ret
  964. DoInsert    ENDP
  965.  
  966. DoInsLine    PROC
  967.  
  968. ;        Bildinhalt verschieben und neue Zeile leeren
  969. ;
  970.         pusha
  971.         std
  972.         mov    si, (CSCRLINE - CCURLINE - 1) * CSCRCOLUMN + CSCRCOLUMN / CBITMAP - 1
  973.         mov    di, (CSCRLINE - 1) * CSCRCOLUMN + CSCRCOLUMN / CBITMAP - 1
  974.         mov    cx, BOTTOMLINE
  975.         sub    cx, yPos
  976.         push    ds
  977.         push    es
  978.         pop    ds
  979.         je    DoInsL_Bottom
  980.         shl    cx, 3
  981. DoInsL_NextCpy: push    cx
  982.         mov    cx, CSCRCOLUMN / CBITMAP
  983.         rep    movsb
  984.         sub    di, (CSCRCOLUMN * (CBITMAP - 1)) / CBITMAP
  985.         sub    si, (CSCRCOLUMN * (CBITMAP - 1)) / CBITMAP
  986.         pop    cx
  987.         loop    DoInsL_NextCpy
  988. DoInsL_Bottom:    pop    ds
  989.         cld
  990.  
  991.         call    ClearLatches
  992.         mov    di, si
  993.         add    di, (CSCRCOLUMN * (CBITMAP - 1)) / CBITMAP + 1
  994.         mov    cx, CCURLINE
  995. DoInsL_NextClr:    push    cx
  996.         mov    cx, CSCRCOLUMN / CBITMAP
  997.         rep    stosb
  998.         add    di, (CSCRCOLUMN * (CBITMAP - 1)) / CBITMAP
  999.         pop    cx
  1000.         loop    DoInsL_NextClr
  1001.  
  1002. ;        Uhr vorstellen
  1003. ;
  1004.         mov    ax, 2
  1005.         call    EnhanceTimer
  1006.         popa
  1007.         ret
  1008. DoInsLine    ENDP
  1009.  
  1010. DoUp        PROC
  1011.  
  1012. ;        Bildinhalt verschieben und neue Zeile leeren
  1013. ;
  1014.         pusha
  1015.         mov    si, CCURLINE * CSCRCOLUMN
  1016.         xor    di, di
  1017.         push    ds
  1018.         push    es
  1019.         pop    ds
  1020.         mov    cx, CSCRLINE - CCURLINE
  1021. DoUp_NextCpy:    push    cx
  1022.         mov    cx, CSCRCOLUMN / CBITMAP
  1023.         rep    movsb
  1024.         add    di, (CSCRCOLUMN * (CBITMAP - 1)) / CBITMAP
  1025.         add    si, (CSCRCOLUMN * (CBITMAP - 1)) / CBITMAP
  1026.         pop    cx
  1027.         loop    DoUp_NextCpy
  1028.         pop    ds
  1029.  
  1030.         call    ClearLatches
  1031.         mov    cx, CCURLINE
  1032. DoUp_NextClr:    push    cx
  1033.         mov    cx, CSCRCOLUMN / CBITMAP
  1034.         rep    stosb
  1035.         add    di, (CSCRCOLUMN * (CBITMAP - 1)) / CBITMAP
  1036.         pop    cx
  1037.         loop    DoUp_NextClr
  1038.  
  1039. ;        Uhr vorstellen
  1040. ;
  1041.         mov    ax, 2
  1042.         call    EnhanceTimer
  1043.         popa
  1044.         ret
  1045. DoUp        ENDP
  1046.  
  1047. DoZipChar    PROC
  1048.         pusha
  1049.         call    GetCurOffset
  1050.         mov    dx, RIGHTCOLUMN
  1051.         sub    dx, xPos
  1052.         add    dx, dx
  1053.         mov    si, offs
  1054.         add    si, CCURCOLUMN / CBITMAP
  1055.         mov    di, offs
  1056.         push    ds
  1057.         push    es
  1058.         pop    ds
  1059.         mov    cx, CCURLINE
  1060. DoZipChar_Next:    push    cx
  1061.         mov    cx, dx
  1062.         rep    movsb
  1063.         call    ClearLatches
  1064.         mov    cx, CCURCOLUMN / CBITMAP
  1065.         rep    stosb
  1066.         sub    si, dx
  1067.         add    si, CSCRCOLUMN
  1068.         sub    di, dx
  1069.         add    di, CSCRCOLUMN - (CCURCOLUMN / CBITMAP)
  1070.         pop    cx
  1071.         loop    DoZipChar_Next
  1072.         pop    ds
  1073.         popa
  1074.         ret
  1075. DoZipChar    ENDP
  1076.  
  1077. DoZipLine    PROC
  1078.  
  1079. ;        Bildinhalt verschieben und neue Zeile leeren
  1080. ;
  1081.         pusha
  1082.         mov    ax, yPos
  1083.         mov    dx, CSCRCOLUMN * CCURLINE
  1084.         mul    dx
  1085.         mov    di, ax
  1086.         mov    si, ax
  1087.         add    si, CSCRCOLUMN * CCURLINE
  1088.         mov    cx, BOTTOMLINE
  1089.         sub    cx, yPos
  1090.         push    ds
  1091.         push    es
  1092.         pop    ds
  1093.         je    DoZipL_Bottom
  1094.         shl    cx, 3
  1095. DoZipL_NextCpy: push    cx
  1096.         mov    cx, CSCRCOLUMN / CBITMAP
  1097.         rep    movsb
  1098.         add    di, (CSCRCOLUMN * (CBITMAP - 1)) / CBITMAP
  1099.         add    si, (CSCRCOLUMN * (CBITMAP - 1)) / CBITMAP
  1100.         pop    cx
  1101.         loop    DoZipL_NextCpy
  1102. DoZipL_Bottom:    pop    ds
  1103.  
  1104.         call    ClearLatches
  1105.         mov    cx, CCURLINE
  1106. DoZipL_NextClr:    push    cx
  1107.         mov    cx, CSCRCOLUMN / CBITMAP
  1108.         rep    stosb
  1109.         add    di, (CSCRCOLUMN * (CBITMAP - 1)) / CBITMAP
  1110.         pop    cx
  1111.         loop    DoZipL_NextClr
  1112.  
  1113. ;        Uhr vorstellen
  1114. ;
  1115.         mov    ax, 2
  1116.         call    EnhanceTimer
  1117.         popa
  1118.         ret
  1119. DoZipLine    ENDP
  1120.  
  1121. ; *****************************************************************************
  1122. ; Stellt den alten Video-Modus wieder her
  1123. ; *****************************************************************************
  1124. Done        PROC
  1125.         pusha
  1126.         mov    ah, VIDEO_SET_MODE
  1127.         mov    al, VIDEO_80x25x16
  1128.         int    VIDEO_FUNCTION
  1129.  
  1130.         IFNDEF    _PLAY
  1131.         cmp    ynError, YES
  1132.         jne    Done_OK
  1133.         IFDEF    _READ
  1134.         cmp    NextChar, KBESC
  1135.         je    Done_OK
  1136.         ENDIF
  1137.         mov    dx, OFFSET STRACCESSERROR
  1138.         mov    ah, DOS_WRITE_STRING
  1139.         int    DOS_FUNCTION
  1140.         stc
  1141.         jmp    Done_End
  1142.         ENDIF
  1143.  
  1144. Done_OK:    clc
  1145. Done_End:    popa
  1146.         ret
  1147. Done        ENDP
  1148.  
  1149. DoneBlit    PROC
  1150.         push    dx
  1151.         push    ax
  1152.         mov    al, OldRWMode
  1153.         mov    ah, 005H
  1154.         xchg    al, ah
  1155.         mov    dx, PRGRAPHICS
  1156.         out    dx, ax
  1157.         pop    ax
  1158.         pop    dx
  1159.         ret
  1160. DoneBlit    ENDP
  1161.  
  1162. ; *****************************************************************************
  1163. ; Zeichnet den Block ax ab der Adresse es:di
  1164. ; *****************************************************************************
  1165. DrawBlock    PROC
  1166.  
  1167. ;        Anfangsadresse des Steins bestimmen
  1168. ;
  1169.         pusha
  1170.         mov    si, OFFSAAABSTONE
  1171.         add    si, ax
  1172.         add    si, ax
  1173.         push    ds
  1174.         mov    ax, SEGGFX
  1175.         mov    ds, ax
  1176.  
  1177.         mov    cx, CSTONELINE
  1178. DBlock_NextLn:    push    cx
  1179.         mov    cx, CSTONECOLUMN / CBITMAP
  1180.         rep    movsb
  1181.         add    di, CSCRCOLUMN - CSTONECOLUMN / CBITMAP
  1182.         add    si, CSCRCOLUMN - CSTONECOLUMN / CBITMAP
  1183.         pop    cx
  1184.         loop    DBlock_NextLn
  1185.         pop    ds
  1186.         popa
  1187.         ret
  1188. DrawBlock    ENDP
  1189.  
  1190. EnhanceTimer    PROC
  1191.         pusha
  1192.         add    Timer, ax
  1193.  
  1194. ;        Effekte weiterstellen
  1195. ;
  1196.         mov    si, OFFSET AENHANCEPROC
  1197.         mov    di, OFFSET aenFX
  1198.         mov    cx, CFX
  1199. EnhanceTimer_FX:mov    dl, ds:[di]
  1200.         inc    dl
  1201.         and    dl, 3
  1202.         cmp    dl, ENON
  1203.         jl    EnhanceTimer_No
  1204.         mov    bx, ds:[si]
  1205.         call    bx
  1206. EnhanceTimer_No:inc    di
  1207.         add    si, 2
  1208.         loop    EnhanceTimer_FX
  1209.         popa
  1210.         ret
  1211. EnhanceTimer    ENDP
  1212.  
  1213. EnhanceCursor    PROC
  1214.         pusha
  1215.         add    iPhase, ax
  1216.         mov    si, iCursor
  1217.         add    si, OFFSET ABCPHASE
  1218.         xor    dh, dh
  1219.         mov    dl, ds:[si]
  1220.         shl    dx, 2
  1221.         cmp    iPhase, dx
  1222.         jnae    EnhCur_End
  1223.         sub    iPhase, dx
  1224. EnhCur_End:    popa
  1225.         ret
  1226. EnhanceCursor    ENDP
  1227.  
  1228. EnhanceObjects    PROC
  1229.         pusha
  1230.         cmp    enObjects, ENON
  1231.         jl    EnhObj_End
  1232.         mov    si, OFFSET abObjTimer
  1233.         mov    cx, COBJECT
  1234. EnhanceTm_Obj:    add    ds:[si], al
  1235.         inc    si
  1236.         loop    EnhanceTm_Obj
  1237. EnhObj_End:    popa
  1238.         ret
  1239. EnhanceObjects    ENDP
  1240.  
  1241. EnhanceStars    PROC
  1242.         pusha
  1243.         mov    si, OFFSET awStarX
  1244.         cmp    iFrame, 0
  1245.         je    EnhStars_Frm0
  1246.         add    si, CSTAR * 2
  1247. EnhStars_Frm0:    mov    cx, CSTAR
  1248. EnhStars_Next:    mov    ax, ds:[si]
  1249.         mov    dx, cx
  1250.         and    dx, 3
  1251.         inc    dx
  1252.         sub    ax, dx
  1253.         jns    EnhStars_Ok
  1254.         add    ax, CSCRCOLUMN
  1255. EnhStars_Ok:    mov    ds:[si], ax
  1256.         add    si, 2
  1257.         loop    EnhStars_Next
  1258.         popa
  1259.         ret
  1260. EnhanceStars    ENDP
  1261.  
  1262. ; *****************************************************************************
  1263. ; Auf Rasterstrahlpositionen warten
  1264. ; *****************************************************************************
  1265. ExpectPicture    PROC
  1266.         push    dx
  1267.         push    ax
  1268.         mov    dx, 003DAH
  1269. Ray_OutFrame:    in    ax, dx
  1270.         and    ax, 00008H
  1271.         cmp    ax, 00000H
  1272.         jne    Ray_OutFrame
  1273.         pop    ax
  1274.         pop    dx
  1275.         ret
  1276. ExpectPicture    ENDP
  1277.  
  1278. ExpectRetrace    PROC
  1279.         pusha
  1280.  
  1281. ;        Bildanfangsadresse bestimmen
  1282. ;
  1283.         mov    dx, PRCRT
  1284.         mov    al, 00DH
  1285.         out    dx, al
  1286.         inc    dx
  1287.         mov    ax, offsFrame
  1288.         out    dx, al
  1289.  
  1290. ;        Auf Rücklauf warten
  1291. ;
  1292.         IFDEF    _TEST
  1293.         call    DarkBorder
  1294.         ENDIF
  1295.         mov    dx, 003DAH
  1296. Ray_InFrame:    in    ax, dx
  1297.         and    ax, 00008H
  1298.         cmp    ax, 00008H
  1299.         jne    Ray_InFrame
  1300.         IFDEF    _TEST
  1301.         call    WhiteBorder
  1302.         ENDIF
  1303.         popa
  1304.         ret
  1305. ExpectRetrace    ENDP
  1306.  
  1307. ; *****************************************************************************
  1308. ; Bestimmt die Bildschiradresse der oberen linken Cursor-Ecke: Offs
  1309. ; *****************************************************************************
  1310. GetCurOffset    PROC
  1311.         pusha
  1312.         mov    si, iFrame
  1313.         shl    si, 2
  1314.         add    si, OFFSET CursorX
  1315.         mov    ax, ds:[si+2]
  1316.         mov    dx, CCURLINE * CSCRCOLUMN
  1317.         mul    dx
  1318.         mov    dx, ds:[si]
  1319.         add    ax, dx
  1320.         add    ax, dx
  1321.         mov    offs, ax
  1322.         popa
  1323.         ret
  1324. GetCurOffset    ENDP
  1325.  
  1326. ; ****************************************************************************
  1327. ; Bestimmt die Zeit zwischen zwei Tastendrücken: Delay
  1328. ; ****************************************************************************
  1329. GetDelay    PROC
  1330.         push    ax
  1331.         mov    ax, Timer
  1332.         sub    ax, TimerLast
  1333.         mov    Delay, ax
  1334.         mov    ax, Timer
  1335.         mov    TimerLast, ax
  1336.         pop    ax
  1337.         ret
  1338. GetDelay    ENDP
  1339.  
  1340.         IFNDEF    _PLAY
  1341. GetFile        PROC
  1342.         pusha
  1343.  
  1344. ;        Kontrolle, ob Dateiname angegeben ist
  1345. ;
  1346.         mov    segFileName, es
  1347.         mov    di, 080H
  1348.         mov    al, es:[di]
  1349.         or    al, al
  1350.         je    GetFile_Error
  1351. ;        0zeichen einfügen
  1352. ;
  1353. GetFile_Ok1:    xor    ah, ah
  1354.         inc    di
  1355.         mov    si, di
  1356.         add    di, ax
  1357.         mov    es:[di], ah
  1358.  
  1359. ;        Führende Leerzeichen überspringen
  1360. ;
  1361.         mov    di, si
  1362.         mov    cx, ax
  1363.         mov    bx, ax
  1364.         mov    al, ' '
  1365.         inc    cx
  1366.         repe    scasb
  1367.         or    cx, cx
  1368.         je    GetFile_Error
  1369. GetFile_Ok2:    dec    di
  1370.         mov    offsFileName, di
  1371.  
  1372. ;        Aus Option untersuchen
  1373. ;
  1374.         mov    al, es:[di]
  1375.         cmp    al, '0'
  1376.         jl    GetFile_Error
  1377.  
  1378. ;        Endung suchen
  1379. ;
  1380.         mov    di, si
  1381.         mov    cx, bx
  1382.         mov    al, '.'
  1383.         repne    scasb
  1384.         or    cx, cx
  1385.         jne    GetFile_Ok
  1386.  
  1387. ;        Endung .WRT anfügen
  1388. ;
  1389.         mov    si, OFFSET STREXT
  1390.         mov    cx, 5
  1391.         rep    movsb
  1392. GetFile_Ok:    clc
  1393. GetFile_End:    popa
  1394.         ret
  1395.  
  1396. ;        Zeigt die Syntax ax
  1397. ;
  1398. GetFile_Error:    mov    dx, OFFSET STRUSAGE
  1399.         mov    ah, DOS_WRITE_STRING
  1400.         int    021H
  1401.         stc
  1402.         jmp    GetFile_End
  1403.  
  1404. GetFile        ENDP
  1405.         ENDIF
  1406.  
  1407.         IFDEF    _WRITE
  1408. ; ****************************************************************************
  1409. ; Liest ein Zeichen von der Tastatur: Char, C
  1410. ; ****************************************************************************
  1411. GetKey        PROC
  1412.  
  1413. ;        Kontrolle, ob ein Zeichen vorliegt
  1414. ;
  1415.         push    ax
  1416.         mov    ah, KEYBOARD_GET_STATUS
  1417.         int    KEYBOARD_FUNCTION
  1418.         jz    GKey_None
  1419.  
  1420. ;        Vorhandenes Zeichen einlesen
  1421. ;
  1422.         mov    ah, KEYBOARD_READ_CHAR
  1423.         int    KEYBOARD_FUNCTION
  1424.         cmp    al, 0
  1425.         je    GKey_Normal
  1426.         xor    ah, ah
  1427. Gkey_Normal:    mov    Char, ax
  1428.  
  1429. ;        Zeichen abspeichern
  1430. ;
  1431.         cmp    ynLock, YES
  1432.         je    GKey_Locked
  1433.         call    AccessFile
  1434.  
  1435. GKey_Locked:    clc
  1436.         jmp    GKey_End
  1437.  
  1438. GKey_None:    stc
  1439. GKey_End:    pop    ax
  1440.         ret
  1441. GetKey        ENDP
  1442.         ENDIF
  1443.  
  1444. ; *****************************************************************************
  1445. ; Liest ein Zeichen aus einer Datei oder von der Tastatur
  1446. ; *****************************************************************************
  1447.         IFNDEF    _WRITE
  1448. GetKey        PROC
  1449.         push    ax
  1450.         cmp    ynLock, YES
  1451.         je    GKey_Locked
  1452.  
  1453. ;        Verzögerung abwarten
  1454. ;
  1455.         call    MakeDelay
  1456.         jg    GKey_None
  1457.         mov    ax, NextChar
  1458.         call    AccessFile
  1459.         mov    Char, ax
  1460.         jmp    GKey_Hit
  1461.  
  1462. GKey_Locked:    mov    ah, KEYBOARD_GET_STATUS
  1463.         int    KEYBOARD_FUNCTION
  1464.         jz    GKey_None
  1465.  
  1466. ;        Vorhandenes Zeichen einlesen
  1467. ;
  1468.         mov    ah, KEYBOARD_READ_CHAR
  1469.         int    KEYBOARD_FUNCTION
  1470. GKey_Hit:    clc
  1471.         jmp    GKey_End
  1472.  
  1473. GKey_None:    stc
  1474.  
  1475. GKey_End:    pop    ax
  1476.         ret
  1477. GetKey        ENDP
  1478.         ENDIF
  1479.  
  1480.  
  1481. ; *****************************************************************************
  1482. ; Erzeugt eine Zufallszahl: Random
  1483. ; *****************************************************************************
  1484. GetRandom    PROC
  1485.         push    ax
  1486.         mov    ax, Random
  1487.         ror    ax, 1
  1488.         xor    ax, Timer
  1489.         not    ax
  1490.         add    ax, 04294
  1491.         xchg    ah, al
  1492.         mov    Random, ax
  1493.         pop    ax
  1494.         ret
  1495. GetRandom    ENDP
  1496.  
  1497. ; *****************************************************************************
  1498. ; Nimmt alle nötigen Voreinstellungen vor: C
  1499. ; *****************************************************************************
  1500. Init        PROC
  1501.  
  1502. ;        Initialisierung der Segmentregister
  1503. ;
  1504.         pusha
  1505.         mov    ax, SEG Data
  1506.         mov    ds, ax
  1507.  
  1508. ;        Uninitialisierte Variablen auf 0 setzen
  1509. ;
  1510.         push    es
  1511.         push    ds
  1512.         pop    es
  1513.         mov    di, offsFirstVoid
  1514.         xor    al, al
  1515.         mov    cx, cbVoid
  1516.         rep    stosb
  1517.         pop    es
  1518.  
  1519.         IFNDEF    _PLAY
  1520.         call    GetFile
  1521.         jnc    Init_OpenFile
  1522.         jmp    Init_End
  1523.         ENDIF
  1524.  
  1525. ;        Datei öffnen
  1526. ;
  1527. Init_OpenFile:    call    OpenFile
  1528.  
  1529.         IFNDEF    _PLAY
  1530.         jnc    Init_Opened
  1531.         mov    dx, OFFSET STRERROR
  1532.         mov    ah, DOS_WRITE_STRING
  1533.         int    021H
  1534.         stc
  1535.         jmp    Init_End
  1536.         ENDIF
  1537.  
  1538. Init_Opened:    cld
  1539.         mov    ax, SEGGFX
  1540.         mov    es, ax
  1541.  
  1542. ;        Bestimmung des Prozessortypes
  1543. ;
  1544.         xor    ax, ax
  1545.         push    ax
  1546.         popf
  1547.         pushf
  1548.         pop    ax
  1549.         and    ax, 0F0H
  1550.         cmp    ax, 0F0H
  1551.         jne    Init_286OK
  1552.         mov    dx, OFFSET STR286ERROR
  1553.         mov    ah, DOS_WRITE_STRING
  1554.         int    DOS_FUNCTION
  1555.         stc
  1556.         jmp    Init_End
  1557.  
  1558. ;        Bestimmung der Grafikkarte
  1559. ;
  1560. Init_286OK:    mov    ah, VIDEO_GET_VGA
  1561.         int    VIDEO_FUNCTION
  1562.         cmp    al, VIDEO_GET_VGA
  1563.         je    Init_VGAOK
  1564.         mov    dx, OFFSET STRVGAERROR
  1565.         mov    ah, DOS_WRITE_STRING
  1566.         int    DOS_FUNCTION
  1567.         stc
  1568.         jmp    Init_End
  1569.  
  1570. ;        VGA-Zeichensatz laden
  1571. ;
  1572. Init_VGAOK:    push    ds
  1573.         push    es
  1574.         mov    ax, 01130H
  1575.         mov    bh, 003H
  1576.         int    VIDEO_FUNCTION
  1577.         mov    ax, ds
  1578.         push    es
  1579.         pop    ds
  1580.         mov    es, ax
  1581.         mov    si, bp
  1582.         mov    di, OFFSET VGAChars
  1583.         mov    cx, CCHAR * CCURLINE
  1584.         rep    movsb
  1585.         pop    es
  1586.         pop    ds
  1587.  
  1588. ;        Sicherung des alten Bildschirmmodus und Einschaltung des neuen
  1589. ;
  1590.         mov    ah, VIDEO_SET_MODE
  1591.         mov    al, VIDEO_320x200x256
  1592.         int    VIDEO_FUNCTION
  1593.  
  1594. ;        Lineare Adressierung des Graphics-Controllers
  1595. ;
  1596.         mov    dx, 003CEH
  1597.         mov    al, 005H
  1598.         out    dx, al
  1599.         inc    dx
  1600.         in    al, dx
  1601.         and    al, 0EFH
  1602.         out    dx, al
  1603.         dec    dx
  1604.  
  1605. ;        Lineare Adressierung des Graphics-Controllers (s.o.)
  1606. ;
  1607.         mov    al, 006H
  1608.         out    dx, al
  1609.         inc    dx
  1610.         in    al, dx
  1611.         and    al, 0FDH
  1612.         out    dx, al
  1613.  
  1614. ;        Lineare Adressierung des Sequencer-Controllers
  1615. ;
  1616.         mov    dx, PRSEQUENCER
  1617.         mov    al, 004H
  1618.         out    dx, al
  1619.         inc    dx
  1620.         in    al, dx
  1621.         and    al, 0F7H
  1622.         or    al, 4
  1623.         out    dx, al
  1624.  
  1625. ;        Byteweise-Adressierung des CRT-Controllers
  1626. ;
  1627.         mov    dx, PRCRT
  1628.         mov    al, 014H
  1629.         out    dx, al
  1630.         inc    dx
  1631.         in    al, dx
  1632.         and    al, 0BFH
  1633.         out    dx, al
  1634.         dec    dx
  1635.  
  1636. ;        Byteweise-Adressierung des CRT-Controllers (s.o.)
  1637. ;
  1638.         mov    al, 017H
  1639.         out    dx, al
  1640.         inc    dx
  1641.         in    al, dx
  1642.         or    al, 040H
  1643.         out    dx, al
  1644.  
  1645. ;        Bildschirm löschen
  1646. ;
  1647.         xor    di, di
  1648.         xor    al, al
  1649.         mov    cx, CBMAP
  1650.         rep    stosb
  1651.  
  1652. ;        Initialisierung der 256 Farben
  1653. ;
  1654.         push    es
  1655.         push    ds
  1656.         pop    es
  1657.         mov     dx, OFFSET AAPALETTE
  1658.         mov     ah, VIDEO_DACS
  1659.         mov     al, VIDEO_SET_DACS
  1660.         xor     bx, bx
  1661.         mov     cx, CCOLOR
  1662.         int     VIDEO_FUNCTION
  1663.         pop    es
  1664.  
  1665. ;        Alle Bitplanes für Zugriff einschalten
  1666. ;
  1667.         mov    dx, PRSEQUENCER
  1668.         mov    al, 002H
  1669.         out    dx, al
  1670.         inc    dx
  1671.         mov    al, 00FH
  1672.         out    dx, al
  1673.  
  1674. ;        Zeilen-Abstand bestimmen
  1675. ;
  1676.         mov    dx, PRCRT
  1677.         mov    al, 013H
  1678.         out    dx, al
  1679.         inc    dx
  1680.         mov    al, CSCRCOLUMN / 2
  1681.         out    dx, al
  1682.  
  1683. ;        Effekte initialisieren
  1684. ;
  1685.         mov    si, OFFSET AINITPROC
  1686.         mov    cx, CFX
  1687. Init_NextFX:    mov    bx, ds:[si]
  1688.         call    bx
  1689.         add    si, 2
  1690.         loop    Init_NextFX
  1691.  
  1692.         call    InitBlit
  1693.         call    TurnOnFX
  1694.         call    SwitchFrame
  1695.         call    TurnOnFX
  1696.         call    SwitchFrame
  1697.         clc
  1698. Init_End:    popa
  1699.         ret
  1700. Init        ENDP
  1701.  
  1702. InitBlit    PROC
  1703.         push    dx
  1704.         push    ax
  1705.         mov    dx, PRSEQUENCER
  1706.         mov    al, 002H
  1707.         out    dx, al
  1708.         inc    dx
  1709.         mov    al, 00FH
  1710.         out    dx, al
  1711.         mov    dx, PRGRAPHICS
  1712.         mov    al, 005H
  1713.         out    dx, al
  1714.         inc    dx
  1715.         in    al, dx
  1716.         mov    OldRWMode, al
  1717.         and    al, not 3
  1718.         or    al, 1
  1719.         out    dx, al
  1720.         pop    ax
  1721.         pop    dx
  1722.         ret
  1723. InitBlit    ENDP
  1724.  
  1725. ; *****************************************************************************
  1726. ; Cursor initialisieren
  1727. ; *****************************************************************************
  1728. InitCursor    PROC
  1729.         call    ConvertChars
  1730.         ret
  1731. InitCursor    ENDP
  1732.  
  1733. ; *****************************************************************************
  1734. ; Sprites initialisieren
  1735. ; *****************************************************************************
  1736. InitObjects    PROC
  1737.         push    cx
  1738.         call    ConvertObjects
  1739.         xor    cx, cx
  1740. InitObjects_Nx:    mov    iObject, cx
  1741.         call    MoveObject
  1742.         inc    cx
  1743.         cmp    cx, COBJECT
  1744.         jl    InitObjects_Nx
  1745.         pop    cx
  1746.         ret
  1747. InitObjects    ENDP
  1748.  
  1749. ; *****************************************************************************
  1750. ; Sterne initialisieren
  1751. ; *****************************************************************************
  1752. InitStars    PROC
  1753.         pusha
  1754.         mov    si, OFFSET awStarX
  1755.         mov    di, si
  1756.         add    di, CSTAR * 2
  1757.         mov    cx, CSTAR
  1758. InitStars_Next:    call    GetRandom
  1759.         mov    dx, Random
  1760.         mov    ax, CSCRCOLUMN
  1761.         mul    dx
  1762.         mov    ds:[si], dx
  1763.         mov    ax, cx
  1764.         and    ax, 3
  1765.         inc    ax
  1766.         shr    ax, 1
  1767.         add    dx, ax
  1768.         mov    ds:[di], dx
  1769.         add    si, 2
  1770.         add    di, 2
  1771.         loop    InitStars_Next
  1772.         popa
  1773.         ret
  1774. InitStars    ENDP
  1775.  
  1776. ; *****************************************************************************
  1777. ; Funktionen zur Ausgabe von Tasten
  1778. ; *****************************************************************************
  1779. KeyABC        PROC
  1780.         call    GetCurOffset
  1781.         cmp    ynInsert, YES
  1782.         jne    KeyABC_NoIns
  1783.         call    DoInsert
  1784. KeyABC_NoIns:    call    MoveRight
  1785.         pushf
  1786.         call    DoneBlit
  1787.         call    Print
  1788.         call    InitBlit
  1789.         popf
  1790.         jnc    KeyABC_End
  1791.         call    DoUp
  1792. KeyABC_End:    ret
  1793. KeyABC        ENDP
  1794.  
  1795. KeyBackSpace    PROC
  1796.         call    MoveLeft
  1797.         jnc    KeyLeft_Del
  1798.         call    DoDown
  1799. KeyLeft_Del:    call    ResetCursor
  1800.         call    ActualizeCursor
  1801.         call    DoZipChar
  1802.         ret
  1803. KeyBackSpace    ENDP
  1804.  
  1805. KeyDelete    PROC
  1806.         call    DoZipChar
  1807.         ret
  1808. KeyDelete    ENDP
  1809.  
  1810. KeyDelLine    PROC
  1811.         call    DoZipLine
  1812.         ret
  1813. KeyDelLine    ENDP
  1814.  
  1815. KeyDown        PROC
  1816.         call    MoveDown
  1817.         jnc    KeyDown_End
  1818.         call    DoUp
  1819. KeyDown_End:    ret
  1820. KeyDown        ENDP
  1821.  
  1822. KeyInsert    PROC
  1823.         cmp    iFrame, 0
  1824.         jne    KeyInsert_End
  1825.         xor    ynInsert, YES
  1826. KeyInsert_End:    ret
  1827. KeyInsert    ENDP
  1828.  
  1829. KeyInsLine    PROC
  1830.         call    DoInsLine
  1831.         ret
  1832. KeyInsLine    ENDP
  1833.  
  1834. KeyClear    PROC
  1835.         call    DoClear
  1836.         ret
  1837. KeyClear    ENDP
  1838.  
  1839. KeyLeft        PROC
  1840.         call    MoveLeft
  1841.         jnc    KeyLeft_End
  1842.         call    DoDown
  1843. KeyLeft_End:    ret
  1844. KeyLeft        ENDP
  1845.  
  1846. KeyReturn    PROC
  1847.         call    MoveToNextLine
  1848.         jnc    KeyReturn_End
  1849.         call    DoUp
  1850. KeyReturn_End:    ret
  1851. KeyReturn    ENDP
  1852.  
  1853. KeyRight    PROC
  1854.         call    MoveRight
  1855.         jnc    KeyRight_End
  1856.         call    DoUp
  1857. KeyRight_End:    ret
  1858. KeyRight    ENDP
  1859.  
  1860. KeyToDown    PROC
  1861.         call    MoveToBottom
  1862.         ret
  1863. KeyToDown    ENDP
  1864.  
  1865. KeyToLeft    PROC
  1866.         call    MoveToLeft
  1867.         ret
  1868. KeyToLeft    ENDP
  1869.  
  1870. KeyToRight    PROC
  1871.         call    MoveToRight
  1872.         ret
  1873. KeyToRight    ENDP
  1874.  
  1875. KeyToUp        PROC
  1876.         call    MoveToTop
  1877.         ret
  1878. KeyToUp        ENDP
  1879.  
  1880. KeyUp        PROC
  1881.         call    MoveUp
  1882.         jnc    KeyDown_End
  1883.         call    DoDown
  1884. KeyUp_End:    ret
  1885. KeyUp        ENDP
  1886.  
  1887. ; ****************************************************************************
  1888. ; Stellt die Bildattribute wieder her
  1889. ; ****************************************************************************
  1890. LoadAttributes    PROC
  1891.         push    es
  1892.         push    si
  1893.         push    di
  1894.         mov    si, OFFSET abAttribBuffer
  1895.         mov    di, OFFSET CursorX
  1896.         push    ds
  1897.         pop    es
  1898.         movsw
  1899.         movsw
  1900.         mov    di, OFFSET BackColor
  1901.         movsb
  1902.         mov    di, OFFSET offsPalette
  1903.         movsw
  1904.         mov    di, OFFSET offsPattern
  1905.         movsw
  1906.         mov    di, OFFSET offsFont
  1907.         movsw
  1908.         pop    di
  1909.         pop    si
  1910.         pop    es
  1911.         ret
  1912. LoadAttributes    ENDP
  1913.  
  1914. ; *****************************************************************************
  1915. ; Hauptprogramm
  1916. ; *****************************************************************************
  1917. Main        PROC
  1918.         call    Init
  1919.         jc    Main_Error1
  1920.         call    Run
  1921.  
  1922.         IFNDEF    _PLAY
  1923.         call    CloseFile
  1924.         ENDIF
  1925.  
  1926.         call    Done
  1927. Main_Error1:    mov    al, 0
  1928.         adc    al, al
  1929.         mov    ah, DOS_TERMINATE_EXE
  1930.         int    DOS_FUNCTION
  1931. Main        ENDP
  1932.  
  1933. ; ****************************************************************************
  1934. ; Bestimmt, ob wieder ein Tastendruck kommt
  1935. ; ****************************************************************************
  1936. MakeDelay    PROC
  1937.         push    ax
  1938.  
  1939. ;        Kontrolle, ob eine Taste gedrückt wird
  1940. ;
  1941.         mov    ah, KEYBOARD_GET_STATUS
  1942.         int    KEYBOARD_FUNCTION
  1943.         je    MakeDelay_OK
  1944.         mov    ah, KEYBOARD_READ_CHAR
  1945.         int    KEYBOARD_FUNCTION
  1946.         cmp    al, KBESC
  1947.         jne    MakeDelay_GoOn
  1948.         mov    ynQuit, YES
  1949. MakeDelay_GoOn:    mov    ax, 00001H
  1950.         mov    Delay, ax
  1951. MakeDelay_OK:    dec    Delay
  1952.         cmp    Delay, 0
  1953.         pop    ax
  1954.         ret
  1955. MakeDelay    ENDP
  1956.  
  1957. ; *****************************************************************************
  1958. ; Zeichnet einen Kasten auf den Bildschirm < ds:si
  1959. ; *****************************************************************************
  1960. MessageBox    PROC
  1961.         pusha
  1962.         call    TurnOnFX
  1963.  
  1964. ;        Koordinaten der Box und Text bestimmen
  1965. ;
  1966. MBox_Draw:    mov    di, OFFSET MBox_Coords
  1967.         push    es
  1968.         push    ds
  1969.         pop    es
  1970.         mov    cx, 4
  1971.         rep    movsw
  1972.         pop    es
  1973.         mov    MBox_Text, si
  1974.  
  1975. ;        Startadresse des Hintergrundes bestimmen: ds:si
  1976. ;
  1977.         mov    ax, MBox_Top
  1978.         shl    ax, 3
  1979.         mov    dx, CSCRCOLUMN
  1980.         mul    dx
  1981.         mov    dx, MBox_Left
  1982.         shl    dx, 1
  1983.         add    ax, dx
  1984.         mov    si, ax
  1985.  
  1986. ;        Startadresses der Puffers bestimmen
  1987.         mov    di, OFFSAABMBOXBUF
  1988.  
  1989. ;        Zahl der Bildschirmzeilen bestimmen
  1990. ;
  1991.         mov    cx, MBox_Bottom
  1992.         sub    cx, MBox_Top
  1993.         inc    cx
  1994.         shl    cx, 3
  1995.  
  1996. ;        Zahl der Bildschirmspalten bestimmen
  1997. ;
  1998.         mov    bx, MBox_Right
  1999.         sub    bx, MBox_Left
  2000.         inc    bx
  2001.         shl    bx, 1
  2002.  
  2003. ;        Daten zum Zurücklesen sichern
  2004. ;
  2005.         push    bx
  2006.         push    cx
  2007.         push    si
  2008.  
  2009. ;        Hintergrund kopieren
  2010. ;
  2011.         push    es
  2012.         push    ds
  2013.         push    es
  2014.         pop    ds
  2015.         mov    ax, SEGGFX
  2016.         mov    es, ax
  2017. MBox_SNextLn:    push    cx
  2018.         mov    cx, bx
  2019.         rep    movsb
  2020.         add    si, CSCRCOLUMN
  2021.         sub    si, bx
  2022.         add    di, CSCRCOLUMN
  2023.         sub    di, bx
  2024.         pop    cx
  2025.         loop    MBox_SNextLn
  2026.         pop    ds
  2027.         pop    es
  2028.  
  2029. ;        Obere Kante zeichnen
  2030. ;
  2031.         pop    di
  2032.         push    di
  2033.         push    di
  2034.         mov    ax, ISTONETOPLEFT
  2035.         call    DrawBlock
  2036.         add    di, CCURCOLUMN / CBITMAP
  2037.         mov    cx, MBox_Right
  2038.         sub    cx, MBox_Left
  2039.         dec    cx
  2040.         push    cx
  2041.         mov    ax, ISTONEHORIZONTAL
  2042. MBox_TopLn:    call    DrawBlock
  2043.         add    di, CCURCOLUMN / CBITMAP
  2044.         loop    MBox_TopLn
  2045.         mov    ax, ISTONETOPRIGHT
  2046.         call    DrawBlock
  2047.  
  2048. ;        Mittleren Bereich zeichnen
  2049. ;
  2050.         pop    cx
  2051.         inc    cx
  2052.         shl    cx, 1
  2053.         push    cx
  2054.         mov    cx, MBox_Bottom
  2055.         sub    cx, MBox_Top
  2056.         dec    cx
  2057. MBox_NextLn:    mov    bx, cx
  2058.         pop    cx
  2059.         pop    di
  2060.         add    di, CSCRCOLUMN * CSTONELINE
  2061.         push    di
  2062.         push    cx
  2063.         mov    ax, ISTONEVERTICAL
  2064.         call    DrawBlock
  2065.         add    di, cx
  2066.         call    DrawBlock
  2067.         mov    cx, bx
  2068.         loop    MBox_NextLn
  2069.  
  2070. ;        Untere Kante zeichnen
  2071. ;
  2072.         pop    cx
  2073.         shr    cx, 1
  2074.         dec    cx
  2075.         pop    di
  2076.         add    di, CSCRCOLUMN * CSTONELINE
  2077.         mov    ax, ISTONEBOTTOMLEFT
  2078.         call    DrawBlock
  2079.         mov    ax, ISTONEHORIZONTAL
  2080. MBox_BottomLn:    add    di, CCURCOLUMN / CBITMAP
  2081.         call    DrawBlock
  2082.         loop    MBox_BottomLn
  2083.         add    di, CCURCOLUMN / CBITMAP
  2084.         mov    ax, ISTONEBOTTOMRIGHT
  2085.         call    DrawBlock
  2086.  
  2087. ;        Hintergrund wiederherstellen
  2088. ;
  2089.         call    Write
  2090.         call    WaitKey
  2091.         mov    ynSingle, YES
  2092.         mov    ynSkip, YES
  2093.         mov    si, OFFSAABMBOXBUF
  2094.         pop    di
  2095.         pop    cx
  2096.         pop    bx
  2097.         push    ds
  2098.         mov    ax, SEGGFX
  2099.         mov    ds, ax
  2100. MBox_LNextLn:    push    cx
  2101.         mov    cx, bx
  2102.         rep    movsb
  2103.         add    di, CSCRCOLUMN
  2104.         sub    di, bx
  2105.         add    si, CSCRCOLUMN
  2106.         sub    si, bx
  2107.         pop    cx
  2108.         loop    MBox_LNextLn
  2109.         pop    ds
  2110.         clc
  2111. MBox_End:    popa
  2112.         ret
  2113. MessageBox    ENDP
  2114.  
  2115. ; ****************************************************************************
  2116. ; Funktionen zur Bewegung des Cursors: C
  2117. ; ****************************************************************************
  2118. MoveDown    PROC
  2119.         push    ax
  2120.         mov    ax, yPos
  2121.         cmp    ax, BOTTOMLINE
  2122.         je    MoveDown_Scroll
  2123.         inc    yPos
  2124.         clc
  2125.         jmp    MoveDown_End
  2126. MoveDown_Scroll:stc
  2127. MoveDown_End:    pop    ax
  2128.         ret
  2129. MoveDown    ENDP
  2130.  
  2131. MoveLeft    PROC
  2132.         push    ax
  2133.         mov    ax, xPos
  2134.         cmp    ax, LEFTCOLUMN
  2135.         je    MoveLeft_Jump
  2136.         dec    xPos
  2137.         clc
  2138.         jmp    MoveLeft_End
  2139. MoveLeft_Jump:    mov    ax, RIGHTCOLUMN
  2140.         mov    xPos, ax
  2141.         call    MoveUp
  2142. MoveLeft_End:    pop    ax
  2143.         ret
  2144. MoveLeft    ENDP
  2145.  
  2146. MoveRight    PROC
  2147.         push    ax
  2148.         mov    ax, xPos
  2149.         cmp    ax, RIGHTCOLUMN
  2150.         je    MoveRight_Jump
  2151.         inc    xPos
  2152.         clc
  2153.         jmp    MoveRight_End
  2154. MoveRight_Jump:    mov    ax, LEFTCOLUMN
  2155.         mov    xPos, ax
  2156.         call    MoveDown
  2157. MoveRight_End:    pop    ax
  2158.         ret
  2159. MoveRight    ENDP
  2160.  
  2161. MoveToBottom    PROC
  2162.         push    ax
  2163.         mov    ax, BOTTOMLINE
  2164.         mov    yPos, ax
  2165.         pop    ax
  2166.         ret
  2167. MoveToBottom    ENDP
  2168.  
  2169. MoveToLeft    PROC
  2170.         push    ax
  2171.         mov    ax, LEFTCOLUMN
  2172.         mov    xPos, ax
  2173.         pop    ax
  2174.         ret
  2175. MoveToLeft    ENDP
  2176.  
  2177. MoveToNextLine    PROC
  2178.         push    ax
  2179.         mov    ax, LEFTCOLUMN
  2180.         mov    xPos, ax
  2181.         call    MoveDown
  2182.         pop    ax
  2183.         ret
  2184. MoveToNextLine    ENDP
  2185.  
  2186. MoveToRight    PROC
  2187.         push    ax
  2188.         mov    ax, RIGHTCOLUMN
  2189.         mov    xPos, ax
  2190.         pop    ax
  2191.         ret
  2192. MoveToRight    ENDP
  2193.  
  2194. MoveToTop    PROC
  2195.         push    ax
  2196.         mov    ax, TOPLINE
  2197.         mov    yPos, ax
  2198.         pop    ax
  2199.         ret
  2200. MoveToTop    ENDP
  2201.  
  2202. MoveUp        PROC
  2203.         push    ax
  2204.         mov    ax, yPos
  2205.         cmp    ax, TOPLINE
  2206.         je    MoveUp_Scroll
  2207.         dec    yPos
  2208.         clc
  2209.         jmp    MoveUp_End
  2210. MoveUp_Scroll:    stc
  2211. MoveUp_End:    pop    ax
  2212.         ret
  2213. MoveUp        ENDP
  2214.  
  2215. ; *****************************************************************************
  2216. ; Versetzt das mit iObject angegebene Objekt zufällig
  2217. ; *****************************************************************************
  2218. MoveObject    PROC
  2219.         pusha
  2220.  
  2221. ;        Adresse des Objekttypes bestimmen
  2222. ;
  2223.         mov    ax, iItem
  2224.         mov    dx, CSCRCOLUMN * COBJLINE
  2225.         mul    dx
  2226.         add    ax, 0A0H
  2227.         mov    si, OFFSET aoffsItem
  2228.         add    si, iObject
  2229.         add    si, iObject
  2230.         mov    ds:[si], ax
  2231.  
  2232. ;        Adresse der Maske bestimmen
  2233. ;
  2234.         add    si, OFFSET aoffsMask - OFFSET aoffsItem
  2235.         mov    ax, iItem
  2236.         mov    dx, CBOBJMASK / CITEM
  2237.         mul    dx
  2238.         add    ax, OFFSET aaabObjMask
  2239.         mov    ds:[si], ax
  2240.  
  2241. ;        Startadresse in Grafik bestimmen
  2242. ;
  2243.         add    si, OFFSET aoffsObjNew - OFFSET aoffsMask
  2244.  
  2245.         call    GetRandom
  2246.         mov    dx, Random
  2247.         mov    ax, (CSCRCOLUMN - COBJCOLUMN) / CBITMAP
  2248.         mul    dx
  2249.         mov    bx, dx
  2250.  
  2251.         call    GetRandom
  2252.         mov    dx, CSCRLINE - COBJLINE
  2253.         mov    ax, Random
  2254.         mul    dx
  2255.         mov    ax, CSCRCOLUMN
  2256.         mul    dx
  2257.         add    ax, bx
  2258.         mov    ds:[si], ax
  2259.         popa
  2260.         ret
  2261. MoveObject    ENDP
  2262.  
  2263. ; *****************************************************************************
  2264. ; Öffnen der Datei zum Abspielen
  2265. ; *****************************************************************************
  2266.         IFDEF    _PLAY
  2267. OpenFile    PROC
  2268.         push    ax
  2269.         push    dx
  2270.         mov    ax, offsText
  2271.         shr    ax, 4
  2272.         mov    dx, ds
  2273.         add    ax, dx
  2274.         mov    segText, ax
  2275.         and    offsText, 0000FH
  2276.         pop    dx
  2277.         pop    ax
  2278.         clc
  2279.         ret
  2280. OpenFile    ENDP
  2281.         ENDIF
  2282.  
  2283. ; *****************************************************************************
  2284. ; Öffnen der Textdatei zum lesen: C
  2285. ; *****************************************************************************
  2286.         IFDEF    _READ
  2287. OpenFile    PROC
  2288.         push    ax
  2289.         push    dx
  2290.         mov    ah, DOS_OPEN_FILE
  2291.         xor    al, al
  2292.         mov    dx, offsFileName
  2293.         push    ds
  2294.         mov    ds, segFileName
  2295.         int    DOS_FUNCTION
  2296.         pop    ds
  2297.         mov    skey, ax
  2298.         pop    dx
  2299.         pop    ax
  2300.         ret
  2301. OpenFile    ENDP
  2302.         ENDIF
  2303.  
  2304. ; *****************************************************************************
  2305. ; Öffnen der Textdatei zum schreiben: C
  2306. ; *****************************************************************************
  2307.         IFDEF    _WRITE
  2308. OpenFile    PROC
  2309.         pusha
  2310.         mov    ah, DOS_CREATE_FILE
  2311.         xor    cx, cx
  2312.         mov    dx, offsFileName
  2313.         push    ds
  2314.         mov    ds, segFileName
  2315.         int    DOS_FUNCTION
  2316.         pop    ds
  2317.         mov    skey, ax
  2318.         popa
  2319.         ret
  2320. OpenFile    ENDP
  2321.         ENDIF
  2322.  
  2323. ; ****************************************************************************
  2324. ; Bestimmt die Position eines Zeichens (> cx) in einem String (< di)
  2325. ; ****************************************************************************
  2326. Pos        PROC
  2327.         push    dx
  2328.         push    es
  2329.         push    ds
  2330.         pop    es
  2331.         xor    cx, cx
  2332.         dec    cx
  2333.         push    ax
  2334.         push    di
  2335.         xor    al, al
  2336.         repne    scasb
  2337.         not    cx
  2338.         mov    dx, cx
  2339.         pop    di
  2340.         pop    ax
  2341.         repne    scasb
  2342.         or    cx, cx
  2343.         je    Pos_Failure
  2344.         sub    dx, cx
  2345.         mov    cx, dx
  2346.         dec    cx
  2347.         clc
  2348.         jmp    Pos_End
  2349. Pos_Failure:    stc
  2350. Pos_End:    pop    es
  2351.         pop    dx
  2352.         ret
  2353. Pos        ENDP
  2354.  
  2355. ; *****************************************************************************
  2356. ; Gibt ein Zeichen auf dem Bildschirm aus
  2357. ; *****************************************************************************
  2358. Print        PROC
  2359.         pusha
  2360.  
  2361. ;        Sequencer-Controller einstellen
  2362. ;
  2363.         mov    dx, PRSEQUENCER
  2364.         mov    al, 002H
  2365.         out    dx, al
  2366.         inc    dx
  2367.         mov    al, 080H
  2368.         mov    BitPlane, al
  2369.  
  2370. ;        Bildschirmadresse bestimmen: es:[di]
  2371. ;
  2372.         mov    di, Offs
  2373.  
  2374. ;        Adresse der Zeichenmusters bestimmen: ds:[si]
  2375. ;
  2376.         mov    si, Char
  2377.         shl    si, 3
  2378.         add    si, offsFont
  2379.  
  2380. ;        Anfangsadresse der Füllmusters bestimmen: ds:[bx]
  2381. ;
  2382.         mov    bx, offsPattern
  2383.  
  2384. ;        Anfangsadresse der Füllfarben bestimmem: ds:[bp]
  2385. ;
  2386.         mov    bp, offsPalette
  2387.  
  2388.         mov    cx, CCURLINE
  2389. Print_NextLn:    push    cx
  2390.         lodsb
  2391.         mov    ah, al
  2392.         mov    cx, CCURCOLUMN
  2393. Print_NextCol:  mov    al, BitPlane
  2394.         rol    al, 1
  2395.         cmp    al, 010H
  2396.         jne    Print_NoReMap
  2397.         mov    al, 001H
  2398.         inc    di
  2399. Print_NoReMap:    out    dx, al
  2400.         mov    BitPlane, al
  2401.         push    dx
  2402.         shl    ah, 1
  2403.         jnc    Print_Back
  2404.  
  2405. ;        Pixel in der Vordergrundfarbe setzen
  2406. ;
  2407. Print_Front:    xor    dh, dh
  2408.         mov    dl, ds:[bx]
  2409.         add    bp, dx
  2410.         mov    al, ds:[bp]
  2411.         sub    bp, dx
  2412.         jmp    Print_Pixel
  2413.  
  2414. ;        Pixel in der Hintergrundfarbe setzen
  2415. ;
  2416. Print_Back:    mov    al, BackColor
  2417. Print_Pixel:    mov    es:[di], al
  2418.         inc    bx
  2419.         pop    dx
  2420.         loop    Print_NextCol
  2421.         add    di, CSCRCOLUMN - (CCURCOLUMN / CBITMAP)
  2422.         pop    cx
  2423.         loop    Print_NextLn
  2424.         popa
  2425.         ret
  2426. Print        ENDP
  2427.  
  2428. ; *****************************************************************************
  2429. ; Setzt die Schreibposition auf die Cursorposition
  2430. ; *****************************************************************************
  2431. ResetCursor    PROC
  2432.         push    ax
  2433.         mov    ax, xPos
  2434.         mov    CursorNewX, ax
  2435.         mov    ax, yPos
  2436.         mov    CursorNewY, ax
  2437.         pop    ax
  2438.         ret
  2439. ResetCursor    ENDP
  2440.  
  2441. ; *****************************************************************************
  2442. ; Springt zum Anfang der Datei
  2443. ; *****************************************************************************
  2444.         IFDEF    _WRITE
  2445. ResetFile    PROC
  2446.         pusha
  2447.  
  2448. ;        Dateizeiger an Anfang zurücksetzen
  2449. ;
  2450.         mov    ah, DOS_MOVE_FILE_POINTER
  2451.         xor    al, al
  2452.         mov    bx, sKey
  2453.         xor    cx, cx
  2454.         xor    dx, dx
  2455.         int    DOS_FUNCTION
  2456.  
  2457. ;        Bildschirm löschen und Cursor in obere linke Ecke bewegen
  2458. ;
  2459.         call    DoClear
  2460.         call    MoveToLeft
  2461.         call    MoveToTop
  2462.  
  2463. ;        Effekte auf Anfangswerte setzen
  2464. ;
  2465.         mov    si, OFFSET aenFXDefault
  2466.         mov    di, OFFSET aenFX
  2467.         mov    cx, CFX
  2468. ResetFile_FX:    mov    al, ds:[si]
  2469.         cmp    al, ds:[di]
  2470.         je    ResetFile_FXNo
  2471.         dec    BYTE PTR ds:[di]
  2472.         and    BYTE PTR ds:[di], 3
  2473. ResetFile_FXNo:    inc    si
  2474.         inc    di
  2475.         loop    ResetFile_FX
  2476.  
  2477. ;        Einstellungen zurücksetzen
  2478. ;
  2479. ResetFile_SpOn:    mov    iItem, 0
  2480.         mov    ynInsert, YES
  2481.         mov    BackColor, PABLACK
  2482.         mov    iCursor, 0
  2483.         mov    iPhase, 0
  2484.         mov    offsCursor, OFFSAAABCUR
  2485.         mov    offsFont, OFFSAAABFONTS
  2486.         mov    offsPalette, OFFSET AABCOLOR
  2487.         mov    offsPattern, OFFSET AAPATTERN
  2488.         popa
  2489.         ret
  2490. ResetFile    ENDP
  2491.         ENDIF
  2492.  
  2493. ResetInput    PROC
  2494.         mov    Char, 0
  2495.         mov    Timer, 0
  2496.         mov    TimerLast, 0
  2497.         mov    Delay, 0
  2498.         mov    iFrame, 0
  2499.         mov    ynLock, OFF
  2500.         mov    ynSingle, NO
  2501.         mov    ynSkip, NO
  2502.         mov    cRepeat, 0
  2503.         ret
  2504. ResetInput    ENDP
  2505.  
  2506. ; *****************************************************************************
  2507. ; Arbeitet den Ablauf synchron zum Kathodenstrahl ab
  2508. ; *****************************************************************************
  2509. Run        PROC
  2510.         push    ax
  2511.  
  2512.         IFNDEF    _WRITE
  2513.         call    AccessFile
  2514.         mov    cRepeat, 0
  2515.         jc    Run_End
  2516.         ENDIF
  2517.  
  2518. ;        Auf neuen Bildschirm warten
  2519. ;
  2520. Run_Next:    call    ExpectPicture
  2521.         call    ExpectRetrace
  2522.  
  2523. ;        Bildschirme vertauschen
  2524. ;
  2525.         call    SwitchFrame
  2526.  
  2527. ;        Zeichen auf zweitem Bildschirm wiederholen
  2528. ;
  2529.         cmp    cRepeat, 0
  2530.         jne    Run_Key
  2531.  
  2532. ;        Zeichen nur vom ersten Bildschirm annehmen
  2533. ;
  2534.         cmp    iFrame, 0
  2535.         jne    Run_NoKey
  2536.  
  2537. ;        Zeichen lesen und zwei Wiederholungen setzen
  2538. ;
  2539.         call    GetKey
  2540.         jc    Run_NoKey
  2541.         mov    cRepeat, CFRAME
  2542.  
  2543. ;        Effekte während Zeichenausgabe abschalten
  2544. ;
  2545. Run_Key:    call    TurnOffFX
  2546.         call    DoABC
  2547.         cmp    ynSkip, YES
  2548.         je    Run_Skip
  2549.  
  2550. ;        Uhr weiterstellen
  2551. ;
  2552.         mov    ax, 1
  2553.         call    EnhanceTimer
  2554. Run_Skip:    mov    ynSkip, NO
  2555.         call    TurnOnFX
  2556.  
  2557. ;        Weitermachen, solange nicht am Ende
  2558. ;
  2559.         cmp    ynQuit, YES
  2560.         jne    Run_Next
  2561.         cmp    cRepeat, 0
  2562.         jne    Run_Next
  2563.         jmp    Run_Exit
  2564.  
  2565. ;        Aktualisiert nur den Cusor und die Objekte
  2566. ;
  2567. Run_NoKey:    call    TurnOffFX
  2568.  
  2569. ;        Uhr weiterstellen
  2570. ;
  2571.         mov    ax, 1
  2572.         call    EnhanceTimer
  2573.  
  2574.         call    TurnOnFX
  2575.         jmp    Run_Next
  2576.  
  2577. Run_Exit:       IFNDEF    _WRITE
  2578.         call    AskEnd
  2579.         clc
  2580.         ENDIF
  2581.  
  2582. Run_End:    pop    ax
  2583.         ret
  2584. Run        ENDP
  2585.  
  2586. ; *****************************************************************************
  2587. ; Sichert die Bildattribute
  2588. ; *****************************************************************************
  2589. SaveAttributes    PROC
  2590.         push    es
  2591.         push    si
  2592.         push    di
  2593.         mov    di, OFFSET abAttribBuffer
  2594.         mov    si, OFFSET CursorX
  2595.         push    ds
  2596.         pop    es
  2597.         movsw
  2598.         movsw
  2599.         mov    si, OFFSET BackColor
  2600.         movsb
  2601.         mov    si, OFFSET offsPalette
  2602.         movsw
  2603.         mov    si, OFFSET offsPattern
  2604.         movsw
  2605.         mov    si, OFFSET offsFont
  2606.         movsw
  2607.         pop    di
  2608.         pop    si
  2609.         pop    es
  2610.         ret
  2611. SaveAttributes    ENDP
  2612.  
  2613. SwitchFrame    PROC
  2614.         push    ax
  2615.         push    si
  2616.  
  2617. ;        Cursor-Position sichern
  2618. ;
  2619.         mov    si, iFrame
  2620.         inc    si
  2621.         shl    si, 2
  2622.         add    si, OFFSET xPos
  2623.         mov    ax, xPos
  2624.         mov    ds:[si], ax
  2625.         mov    ax, yPos
  2626.         mov    ds:[si+2], ax
  2627.  
  2628.         mov    ax, iFrame
  2629.         xor    ax, 1
  2630.         mov    iFrame, ax
  2631.         mov    ax, offsFrame
  2632.         xor    ax, CSCRCOLUMN / CBITMAP
  2633.         mov    offsFrame, ax
  2634.         shr    ax, 4
  2635.         or    ax, SEGGFX
  2636.         mov    es, ax
  2637.  
  2638. ;        Cursor-Position restaurieren
  2639. ;
  2640.         mov    si, iFrame
  2641.         inc    si
  2642.         shl    si, 2
  2643.         add    si, OFFSET xPos
  2644.         mov    ax, ds:[si]
  2645.         mov    xPos, ax
  2646.         mov    ax, ds:[si+2]
  2647.         mov    yPos, ax
  2648.         pop    si
  2649.         pop    ax
  2650.         ret
  2651. SwitchFrame    ENDP
  2652.  
  2653. SwitchCursor    PROC
  2654.         dec    enCursor
  2655.         and    enCursor, 3
  2656.         ret
  2657. SwitchCursor    ENDP
  2658.  
  2659. SwitchSprites    PROC
  2660.         dec    enObjects
  2661.         and    enObjects, 3
  2662.         ret
  2663. SwitchSprites    ENDP
  2664.  
  2665. SwitchStars    PROC
  2666.         dec    enStars
  2667.         and    enStars, 3
  2668.         ret
  2669. SwitchStars    ENDP
  2670.  
  2671. ; ****************************************************************************
  2672. ; Stellt den Hintergrund des Cursors wieder her
  2673. ; ****************************************************************************
  2674. TurnOffCursor    PROC
  2675.         pusha
  2676.         call    GetCurOffset
  2677.         mov    di, offs
  2678.         mov    si, OFFSET OFFSAABCURBUF
  2679.         mov    ax, iFrame
  2680.         add    ax, ax
  2681.         add    si, ax
  2682.         push    ds
  2683.         mov    ax, SEGGFX
  2684.         mov    ds, ax
  2685.         mov    cx, CCURLINE
  2686. TOfCur_NextLn:    push    cx
  2687.         mov    cx, CCURCOLUMN / CBITMAP
  2688.         rep    movsb
  2689.         add    si, CSCRCOLUMN - (CCURCOLUMN / CBITMAP)
  2690.         add    di, CSCRCOLUMN - (CCURCOLUMN / CBITMAP)
  2691.         pop    cx
  2692.         loop    TOfCur_NextLn
  2693.         pop    ds
  2694.         popa
  2695.         ret
  2696. TurnOffCursor    ENDP
  2697.  
  2698. ; ****************************************************************************
  2699. ; Schaltet den Cursor ein
  2700. ; ****************************************************************************
  2701. TurnOnCursor    PROC
  2702.         pusha
  2703.  
  2704.         call    GetCurOffset
  2705.  
  2706. ;        Sicherung des Hintergrundes
  2707. ;
  2708.         mov    si, offs
  2709.         mov    di, OFFSET OFFSAABCURBUF
  2710.         mov    ax, iFrame
  2711.         add    ax, ax
  2712.         add    di, ax
  2713.         push    ds
  2714.         push    es
  2715.         push    es
  2716.         pop    ds
  2717.         mov    ax, SEGGFX
  2718.         mov    es, ax
  2719.         mov    cx, CCURLINE
  2720. TOnCur_SNextLn:    push    cx
  2721.         mov    cx, CCURCOLUMN / CBITMAP
  2722.         rep    movsb
  2723.         add    si, CSCRCOLUMN - (CCURCOLUMN / CBITMAP)
  2724.         add    di, CSCRCOLUMN - (CCURCOLUMN / CBITMAP)
  2725.         pop    cx
  2726.         loop    TOnCur_SNextLn
  2727.         pop    es
  2728.         pop    ds
  2729.  
  2730. ;        Zeichnet den Cursor neu
  2731. ;
  2732.         mov    si, iPhase
  2733.         shr    si, 1
  2734.         and    si, 0FFFEH
  2735.         add    si, offsCursor
  2736.         mov    di, offs
  2737.         push    ds
  2738.         mov    ax, SEGGFX
  2739.         mov    ds, ax
  2740.         mov    cx, CCURLINE
  2741. TOnCur_CNextLn:    push    cx
  2742.         mov    cx, CCURCOLUMN / CBITMAP
  2743.         rep    movsb
  2744.         add    di, CSCRCOLUMN - CCURCOLUMN / CBITMAP
  2745.         add    si, CSCRCOLUMN - CCURCOLUMN / CBITMAP
  2746.         pop    cx
  2747.         loop    TOnCur_CNextLn
  2748.         pop    ds
  2749.         popa
  2750.         ret
  2751. TurnOnCursor    ENDP
  2752.  
  2753. TurnOffFX    PROC
  2754.         pusha
  2755.  
  2756. ;        Kontrolle, ob Effekte schon aus sind
  2757. ;
  2758.         cmp    ynFXOn, OFF
  2759.         je    TurnOffFX_End
  2760.         mov    ynFXOn, OFF
  2761.  
  2762. ;        Alle gewählten Objekte einschalten
  2763. ;
  2764.         mov    si, OFFSET aenFX + (CFX - 1)
  2765.         mov    di, OFFSET ATURNOFFPROC + (CFX - 1) * 2
  2766.         mov    cx, CFX
  2767. TurnOffFX_Next:    mov    al, ds:[si]
  2768.         inc    al
  2769.         and    al, 3
  2770.         cmp    al, ENON
  2771.         jl    TurnOffFX_Not
  2772.         mov    bx, ds:[di]
  2773.         call    bx
  2774. TurnOffFX_Not:    dec    si
  2775.         sub    di, 2
  2776.         loop    TurnOffFX_Next
  2777. TurnOffFX_End:    popa
  2778.         ret
  2779. TurnOffFX    ENDP
  2780.  
  2781. TurnOnFX    PROC
  2782.         pusha
  2783.  
  2784. ;        Kontrolle, ob Effekte schon an sind
  2785. ;
  2786.         cmp    ynFXOn, ON
  2787.         je    TurnOnFX_End
  2788.         mov    ynFXOn, ON
  2789.  
  2790. ;        Alle gewählten Objekte einschalten
  2791. ;
  2792.         mov    si, OFFSET aenFX
  2793.         mov    di, OFFSET ATURNONPROC
  2794.         mov    cx, CFX
  2795. TurnOnFX_Next:    cmp    BYTE PTR ds:[si], ENON
  2796.         jl    TurnOnFX_Not
  2797.         mov    bx, ds:[di]
  2798.         call    bx
  2799. TurnOnFX_Not:    inc    si
  2800.         add    di, 2
  2801.         loop    TurnOnFX_Next
  2802. TurnOnFX_End:    popa
  2803.         ret
  2804. TurnOnFX    ENDP
  2805.  
  2806. ; *****************************************************************************
  2807. ; Löschen aller Objekte
  2808. ; *****************************************************************************
  2809. TurnOffObjects    PROC
  2810.         pusha
  2811.         xor    cx, cx
  2812.  
  2813. ;        Anfangsadresse der Hintergrund-Puffers bestimmen: es:si
  2814. ;
  2815. TOfObj_Next:    mov    si, cx
  2816.         shl    si, 2
  2817.         add    si, OFFSAAABOBJBUF
  2818.         mov    ax, iFrame
  2819.         or    ax, ax
  2820.         je    TOfObj_F1
  2821.         add    si, CSCRCOLUMN * COBJLINE
  2822.  
  2823. ;        Anfangsadresse des Hintergrundes bestimmen: es:di
  2824. ;
  2825. TOfObj_F1:    mov    di, iFrame
  2826.         shl    di, 4
  2827.         add    di, OFFSET aoffsObj
  2828.         add    di, cx
  2829.         add    di, cx
  2830.         mov    di, ds:[di]
  2831.  
  2832. ;        Hintergrund wiederherstellen
  2833. ;
  2834.         push    cx
  2835.         push    ds
  2836.         mov    ax, SEGGFX
  2837.         mov    ds, ax
  2838.         mov    cx, COBJLINE
  2839. TOfObj_SNextLn:    push    cx
  2840.         mov    cx, COBJCOLUMN / CBITMAP
  2841.         rep    movsb
  2842.         add    si, CSCRCOLUMN - COBJCOLUMN / CBITMAP
  2843.         add    di, CSCRCOLUMN - COBJCOLUMN / CBITMAP
  2844.         pop    cx
  2845.         loop    TOfObj_SNextLn
  2846.         pop    ds
  2847.         pop    cx
  2848.         inc    cx
  2849.         cmp    cx, COBJECT
  2850.         jne    TOfObj_Next
  2851.         popa
  2852.         ret
  2853. TurnOffObjects    ENDP
  2854.  
  2855. ; *****************************************************************************
  2856. ; Neuzeichnen der Objekte
  2857. ; *****************************************************************************
  2858. TurnOnObjects    PROC
  2859.         pusha
  2860.         mov    cx, COBJECT - 1
  2861.  
  2862. ;        Kontrolle, ob das Objekt bewegt werden muß
  2863. ;
  2864. TOnObj_Next:    xor    dh, dh
  2865.         mov    si, OFFSET abObjTimer
  2866.         add    si, cx
  2867.         mov    dl, ds:[si]
  2868.         or    dl, dl
  2869.         jns    TOnObj_NoMove
  2870.         xor    dl, dl
  2871.         mov    iObject, cx
  2872.         call    MoveObject
  2873.  
  2874. ;        Anfangsadresse des Hintergrundes bestimmen: es:si
  2875. ;
  2876. TOnObj_NoMove:    mov    ds:[si], dl
  2877.         shr    dl, 3
  2878.         mov    si, OFFSET aoffsObjNew
  2879.         add    si, cx
  2880.         add    si, cx
  2881.         mov    ax, ds:[si]
  2882.         mov    di, iFrame
  2883.         shl    di, 4
  2884.         add    di, OFFSET aoffsObj
  2885.         add    di, cx
  2886.         add    di, cx
  2887.         mov    ds:[di], ax
  2888.         mov    si, ax
  2889.  
  2890. ;        Anfangsadresse der Hintergrund-Puffers bestimmen: es:di
  2891. ;
  2892.         mov    di, cx
  2893.         shl    di, 2
  2894.         add    di, OFFSAAABOBJBUF
  2895.         mov    ax, iFrame
  2896.         or    ax, ax
  2897.         je      TOnObj_F1
  2898.         add    di, CSCRCOLUMN * COBJLINE
  2899.  
  2900. ;        Hintergrund sichern
  2901. ;
  2902. TOnObj_F1:    push    cx
  2903.         push    es
  2904.         push    ds
  2905.         push    es
  2906.         pop    ds
  2907.         mov    ax, SEGGFX
  2908.         mov    es, ax
  2909.         push    si
  2910.         mov    cx, COBJLINE
  2911. TOnObj_SNextLn:    push    cx
  2912.         mov    cx, COBJCOLUMN / CBITMAP
  2913.         rep    movsb
  2914.         add    si, CSCRCOLUMN - COBJCOLUMN / CBITMAP
  2915.         add    di, CSCRCOLUMN - COBJCOLUMN / CBITMAP
  2916.         pop    cx
  2917.         loop    TOnObj_SNextLn
  2918.  
  2919. ;        Hintergrundadresse bestimmen: es:[di]
  2920. ;
  2921.         pop    di
  2922.         pop    ds
  2923.         pop    es
  2924.  
  2925. ;               Anfangsadresse des Objekts bestimmen: es:[si]
  2926. ;
  2927.         pop    cx
  2928.         push    cx
  2929.         mov    si, OFFSET AOBJECTSEQ
  2930.         add    si, dx
  2931.         mov    al, ds:[si]
  2932.         xor    ah, ah
  2933.         mov    dx, ax
  2934.         shl    ax, 2
  2935.         mov    si, OFFSET aoffsItem
  2936.         add    si, cx
  2937.         add    si, cx
  2938.         mov    si, ds:[si]
  2939.         add    si, ax
  2940.  
  2941. ;        Adresse der Maske bestimmen: ds:bx
  2942. ;
  2943.         mov     bx, OFFSET aoffsMask
  2944.         add    bx, cx
  2945.         add    bx, cx
  2946.         mov    bx, ds:[bx]
  2947.         mov    ax, COBJLINE * COBJCOLUMN / CBITMAP
  2948.         mul    dx
  2949.         add    bx, ax
  2950.  
  2951. ;        Sequencer-Controller einstellen
  2952. ;
  2953.         mov    dx, PRSEQUENCER
  2954.         mov    al, 002H
  2955.         out    dx, al
  2956.         inc    dx
  2957.  
  2958. ;           Objekt auf Hintergrund kopieren
  2959. ;
  2960.         mov    bp, ds
  2961.         mov    ax, SEGGFX
  2962.         mov    ds, ax
  2963.         mov    cx, COBJLINE
  2964. TOnObj_CNextLn:    push    cx
  2965.         mov    cx, COBJCOLUMN / CBITMAP
  2966. TOnObj_CNextCl: push    ds
  2967.         mov    ds, bp
  2968.         mov    al, ds:[bx]
  2969.         pop    ds
  2970.         out    dx, al
  2971.         mov    al, ds:[si]
  2972.         mov    es:[di], al
  2973.         inc    bx
  2974.         inc    si
  2975.         inc    di
  2976.         loop    TOnObj_CNextCl
  2977.         add    si, CSCRCOLUMN - COBJCOLUMN / CBITMAP
  2978.         add    di, CSCRCOLUMN - COBJCOLUMN / CBITMAP
  2979.         pop    cx
  2980.         loop    TOnObj_CNextLn
  2981.  
  2982.         mov    ds, bp
  2983.         mov    al, 00FH
  2984.         out    dx, al
  2985.  
  2986. ;        Nächstes Objekt
  2987. ;
  2988.         pop    cx
  2989.         dec    cx
  2990.         js    TOnObj_End
  2991.         jmp    TOnObj_Next
  2992. TOnObj_End:    popa
  2993.         ret
  2994. TurnOnObjects    ENDP
  2995.  
  2996. TurnOffStars    PROC
  2997.         pusha
  2998. ;        Sequencer-Controller einstellen
  2999. ;
  3000.         call    DoneBlit
  3001.         mov    dx, PRSEQUENCER
  3002.         mov    al, 002H
  3003.         out    dx, al
  3004.         mov    dx, PRGRAPHICS
  3005.         mov    al, 004H
  3006.         out    dx, al
  3007.         mov    cx, CSTAR
  3008.         xor    di, di
  3009.         cmp    iFrame, 0
  3010.         jne    TOffStr_Page2
  3011.         mov    si, OFFSET awStarX
  3012.         jmp    TOffStr_Next
  3013. TOffStr_Page2:    mov    si, OFFSET awStarX + 2 * CSTAR
  3014. TOffStr_Next:    push    cx
  3015.         push    di
  3016.         mov    bx, ds:[si]
  3017.         mov    cl, bl
  3018.         and    cl, 3
  3019.         mov    al, 1
  3020.         shl    al, cl
  3021.         mov    dx, PRSEQUENCER + 1
  3022.         out    dx, al
  3023.         mov    al, cl
  3024.         mov    dx, PRGRAPHICS + 1
  3025.         out    dx, al
  3026.         shr    bx, 2
  3027.         add    di, bx
  3028.         mov    al, es:[di]
  3029.         cmp    al, CSTARCOLOR
  3030.         ja    TOffStr_No
  3031.         mov    BYTE PTR es:[di], 0
  3032. TOffStr_No:    add    si, 2
  3033.         pop    di
  3034.         add    di, CSCRCOLUMN
  3035.         pop    cx
  3036.         loop    TOffStr_Next
  3037.         call    InitBlit
  3038.         popa
  3039.         ret
  3040. TurnOffStars    ENDP
  3041.  
  3042. TurnOnStars    PROC
  3043.         pusha
  3044.  
  3045. ;        Sequencer-Controller einstellen
  3046. ;
  3047.         call    DoneBlit
  3048.         mov    dx, PRSEQUENCER
  3049.         mov    al, 002H
  3050.         out    dx, al
  3051.         mov    dx, PRGRAPHICS
  3052.         mov    al, 004H
  3053.         out    dx, al
  3054.         mov    cx, CSTAR
  3055.         xor    di, di
  3056.         cmp    iFrame, 0
  3057.         jne    TOnStr_Page2
  3058.         mov    si, OFFSET awStarX
  3059.         jmp    TOnStr_Next
  3060. TOnStr_Page2:    mov    si, OFFSET awStarX + 2 * CSTAR
  3061. TOnStr_Next:    push    cx
  3062.         push    di
  3063.         mov    ah, cl
  3064.         and    ah, 3
  3065.         inc    ah
  3066.         mov    bx, ds:[si]
  3067.         mov    cl, bl
  3068.         and    cl, 3
  3069.         mov    al, 1
  3070.         shl    al, cl
  3071.         mov    dx, PRSEQUENCER + 1
  3072.         out    dx, al
  3073.         mov    al, cl
  3074.         mov    dx, PRGRAPHICS + 1
  3075.         out    dx, al
  3076.         shr    bx, 2
  3077.         add    di, bx
  3078.         mov    al, es:[di]
  3079.         cmp    al, CSTARCOLOR
  3080.         ja    TOnStr_Above
  3081.         mov    es:[di], ah
  3082. TOnStr_Above:    add    si, 2
  3083.         pop    di
  3084.         add    di, CSCRCOLUMN
  3085.         pop    cx
  3086.         loop    TOnStr_Next
  3087.         call    InitBlit
  3088.         popa
  3089.         ret
  3090. TurnOnStars    ENDP
  3091.  
  3092. ; *****************************************************************************
  3093. ; Wandelt einen Buchstaben in einen Großbuchstaben um
  3094. ; *****************************************************************************
  3095. UpCase        PROC
  3096.         cmp    Char, 'a'
  3097.         jnae    UpCase_End
  3098.         cmp    Char, 'z'
  3099.         ja    UpCase_End
  3100.         add    Char, 'A' - 'a'
  3101. UpCase_End:    ret
  3102. UpCase        ENDP
  3103.  
  3104. VoidProc    PROC
  3105.         ret
  3106. VoidProc    ENDP
  3107.  
  3108. ; *****************************************************************************
  3109. ; Wartet auf einen Tastendruck
  3110. ; *****************************************************************************
  3111. WaitKey        PROC
  3112.  
  3113. ;        Auf neuen Bildschirm warten
  3114. ;
  3115. WaitKey_More:    call    ExpectPicture
  3116.         call    ExpectRetrace
  3117.  
  3118. ;        Uhr weiterstellen
  3119. ;
  3120.         cmp    ynLock, YES
  3121.         je    WaitKey_Locked
  3122.         inc    Timer
  3123.  
  3124. WaitKey_Locked:    call    GetKey
  3125.         jc    WaitKey_More
  3126.         ret
  3127. WaitKey        ENDP
  3128.  
  3129. ; ****************************************************************************
  3130. ; Schaltet die Rahmenfarbe auf Weiß
  3131. ; ****************************************************************************
  3132.         IFDEF    _TEST
  3133. WhiteBorder    PROC
  3134.         push    ax
  3135.         push    dx
  3136.         mov    dx, 003C0H
  3137.         mov    al, 031H
  3138.         out    dx, al
  3139.         mov    al, 03FH
  3140.         out    dx, al
  3141.         pop    dx
  3142.         pop    ax
  3143.         ret
  3144. WhiteBorder    ENDP
  3145.         ENDIF
  3146.  
  3147. ; ****************************************************************************
  3148. ; Gibt eine Zeichenkette aus
  3149. ; ****************************************************************************
  3150. Write        PROC
  3151.         pusha
  3152.         call    SaveAttributes
  3153.         mov    si, MBox_Text
  3154.         mov    dx, MBox_Left
  3155.         inc    dx
  3156.         mov    CursorX, dx
  3157.         mov    dx, MBox_Top
  3158.         inc    dx
  3159.         mov    CursorY, dx
  3160. Write_Next:    xor    ah, ah
  3161.         lodsb
  3162.         cmp    al, CHBACK
  3163.         je    Write_Back
  3164.         cmp    al, CHTEXT
  3165.         je    Write_Front
  3166.         cmp    al, CHPATTERN
  3167.         je    Write_Pattern
  3168.         cmp    al, CHFONT
  3169.         je    Write_Font
  3170.  
  3171.         mov    Char, ax
  3172.         call    GetCurOffset
  3173.         call    DoneBlit
  3174.         call    Print
  3175.         call    InitBlit
  3176.  
  3177.         inc    CursorX
  3178.         mov    ax, CursorX
  3179.         cmp    ax, MBox_Right
  3180.         jne    Write_Next
  3181.  
  3182.         inc    CursorY
  3183.         mov    ax, CursorY
  3184.         cmp    ax, MBox_Bottom
  3185.         je    Write_End
  3186.  
  3187.         mov    ax, MBox_Left
  3188.         inc    ax
  3189.         mov    CursorX, ax
  3190.         jmp    Write_Next
  3191.  
  3192. Write_Back:    lodsb
  3193.         mov    BackColor, al
  3194.         jmp    Write_Next
  3195.  
  3196. Write_Font:    lodsb
  3197.         shl    ax, 11
  3198.         add    ax, OFFSAAABFONTS
  3199.         mov    offsFont, ax
  3200.         jmp    Write_Next
  3201.  
  3202. Write_Front:    lodsb
  3203.         shl    ax, 4
  3204.         add    ax, OFFSET AABCOLOR
  3205.         mov    offsPalette, ax
  3206.         jmp    Write_Next
  3207.  
  3208. Write_Pattern:    lodsb
  3209.         shl    ax, 6
  3210.         add    ax, OFFSET AAPATTERN
  3211.         mov    offsPattern, ax
  3212.         jmp    Write_Next
  3213.  
  3214. Write_End:    call    LoadAttributes
  3215.         popa
  3216.         ret
  3217. Write        ENDP
  3218.  
  3219. Code        ENDS
  3220.  
  3221.         END    Main
  3222.