home *** CD-ROM | disk | FTP | other *** search
/ Brotikasten / BROTCD01.iso / amiga / frodov13.lha / src / 6569.asm < prev    next >
Assembly Source File  |  1995-02-22  |  65KB  |  3,223 lines

  1. *
  2. * 6569.asm - VIC-Emulation
  3. *
  4. * Copyright (C) 1994-1995 by Christian Bauer
  5. *
  6.  
  7. *
  8. * Anmerkungen:
  9. * ------------
  10. *
  11. * Funktionsweise/Periodic:
  12. *  - Die VIC-Emulation arbeitet zeilenweise. Pro (simulierter)
  13. *    C64-Rasterzeile wird vom 6510-Task die Routine Periodic6569
  14. *    aufgerufen, die eine Pixelzeile der Grafik anhand der aktuellen
  15. *    Einstellungen in den VIC-Registern aufbaut. Dadurch k÷nnen
  16. *    Rastereffekte sehr gut emuliert werden.
  17. *  - Die Emulation setzt eine 8-Bit-Chunky-Bitmap voraus und schreibt
  18. *    ihre Grafikdaten direkt dort hinein
  19. *  - Bei der Darstellung ⁿber die Amiga-Chips wird direkt in eine
  20. *    Chunky-Bitmap geschrieben, die beim VIC-VBlank in das planare Format
  21. *    konvertiert wird (mit c2p4), bei EGS/Picasso werden die Grafikdaten
  22. *    fⁿr eine Zeile in einen Puffer geschrieben, der am Ende der Zeile
  23. *    in den Grafikspeicher der Karte ⁿbertragen wird
  24. *  - Fⁿr eine sauberere Darstellung verwendet die Emulation Double
  25. *    Buffering. Es wird jeweils in eine unsichtbare Bitmap gezeichnet
  26. *    und bei einem VIC-VBlank werden die Puffer gewechselt.
  27. *  - Die Farbpalette besteht aus den 16 C64-Farben, 16mal wiederholt.
  28. *    Dadurch spart man sich das Ausmaskieren der unteren 4 Bit bei den
  29. *    VIC-Farbcodes. Allerdings mu▀ dieses bei der Chunky->Planar-
  30. *    Konvertierung fⁿr die Amiga-Chips erfolgen (der Algorithmus
  31. *    setzt voraus, da▀ die oberen Nibbles Null sind).
  32. *  - Die Auswahl der 5 verschiedenen Darstellungsmodi (plus 3 ungⁿltige,
  33. *    die einen schwarzen Bildschirm erzeugen) geschieht ⁿber den
  34. *    Zeiger DisplayProc, der auf die entsprechende Routine (z.B. TextStd,
  35. *    BitMapMulti etc.) zeigt und der bei einem Schreibzugriff auf eines
  36. *    der beiden Kontrollregister CTRL1/CTRL2 neu gesetzt wird
  37. *
  38. * 6510-ZyklenzΣhler
  39. *  - In jeder Rasterzeile wird der ZyklenzΣhler fⁿr die CPU neu gesetzt,
  40. *    und zwar unterschiedlich je nachdem, ob eine Bad Line stattfand
  41. *    oder nicht
  42. *  - Fⁿr jedes dargestellte Sprite werden nochmal je 2 Zyklen abgezogen
  43. *
  44. * Bad Lines:
  45. *  - Eine Bad Line ist dann, wenn $30 <= RASTER <= $f7 und
  46. *    die unteren drei Bits von RASTER mit den unteren drei Bits von
  47. *    Reg. $11 (Y-Scroll) ⁿbereinstimmen
  48. *  - In einer Bad Line werden 40 Bytes aus Videomatrix und Farb-RAM geholt
  49. *
  50. * RasterzΣhler RC/Grafikdarstellung:
  51. *  - Der RC wird in jeder Bad Line auf Null gesetzt, gleichzeitig wird
  52. *    die Darstellung der Grafik angeschaltet (DISPLAYOFF wird gel÷scht)
  53. *  - Am Ende einer Rasterzeile wird der RC um 1 erh÷ht, es sei denn,
  54. *    er steht auf 7. In diesem Fall wird die Darstellung ausgeschaltet.
  55. *  - Ist DISPLAYOFF gesetzt, wird in der Textspalte $3fff dargestellt,
  56. *    ansonsten Text oder Bitmapgrafik
  57. *  - Deshalb wird im oberen/unteren Rahmen immer $3fff dargestellt, weil
  58. *    es dort keine Bad Lines gibt und der RC nie zurⁿckgesetzt wird
  59. *
  60. * VideomatrixzΣhler VC:
  61. *  - Es gibt zwei Register, VCBASE und VCCOUNT. Zum Zugriff auf die
  62. *    Grafikdaten wird VCCOUNT benutzt.
  63. *  - Beim VBlank wird VCBASE auf Null gesetzt
  64. *  - Zu Beginn jeder Zeile wird VCCOUNT mit dem Wert aus VCBASE geladen
  65. *  - Wenn DISPLAYOFF gel÷scht ist und Grafik dargestellt wird, wird
  66. *    VCCOUNT um 40 erh÷ht (symbolisch fⁿr die 40 Zugriffe des VIC)
  67. *  - Wenn die Darstellung abgeschaltet wird, weil RC=7 ist (am Ende
  68. *    einer Zeile) wird VCBASE mit dem Wert aus VCCOUNT geladen
  69. *
  70. * SpritedatenzΣhler MCx/Spritedarstellung:
  71. *  - Da die Spritedaten beim VIC am Ende einer Rasterzeile geholt werden
  72. *    und daher die Y-Positionen der Sprites eins niedriger als die
  73. *    Rasterzeilennummern sind, werden die SpritedatenzΣhler in der
  74. *    Emulation am Ende einer Rasterzeile gehandhabt (nachdem die Sprites
  75. *    gezeichnet wurden)
  76. *  - Wenn ein Sprite eingeschaltet ist und die Y-Koordinate gleich den
  77. *    unteren 8 Bit von RASTER ist, wird der DatenzΣhler auf Null gesetzt
  78. *    und die Darstellung des Sprite eingeschaltet (Bit in SPRITEON).
  79. *    Jede folgende Rasterzeile wird der ZΣhler um 3 erh÷ht, solange er
  80. *    kleiner als 60 ist. Erreicht er 60, wird die Darstellung des Sprite
  81. *    ausgeschaltet. Wenn das Sprite Y-expandiert ist, wird der ZΣhler nur
  82. *    in den Zeilen erh÷ht, in denen die unteren Bits von Y-Koordinate und
  83. *    Zeilennummer gleich sind.
  84. *
  85. * X-Scroll>0 und 40 Spalten:
  86. *  - Wenn der X-Scroll>0 und die 40-Spalten-Darstellung eingeschaltet
  87. *    ist, hΣngt das, was am linken Bildrand dargestellt wird, vom
  88. *    aktuellen Grafikmodus ab
  89. *  - Im Standard-Text-, Multicolor-Text- und Multicolor-Bitmap-Modus wird
  90. *    dort die Hintergrundfarbe aus Reg.$21 dargestellt
  91. *  - Im Standard-Bitmap- und ECM-Text-Modus wird die Hintergrundfarbe
  92. *    der letzten 8 Pixel der vorherigen Zeile dargestellt
  93. *
  94. * InkompatibilitΣten:
  95. *  - Effekte, die durch die ─nderung von VIC-Registern innerhalb einer
  96. *    Rasterzeile erreicht werden, k÷nnen nicht emuliert werden
  97. *  - Keine Sprite-Grafik-PrioritΣt
  98. *  - Keine Sprite-Hintergrund-Kollisionen
  99. *  - Sprite-Sprite-Kollisionen werden nur innerhalb des sichtbaren
  100. *    Bereiches erkannt
  101. *  - X-expandierte Sprites mit X-Koordinaten >=$140 werden nicht angezeigt.
  102. *    Genaugenommen sollte ein Sprite nur dann unsichtbar sein, wenn die
  103. *    X-Koordinate zwischen $1f8 und $1ff liegt.
  104. *  - In den Bitmap-Darstellungen ab den Adressen $0000 und $8000 sollte
  105. *    eigentlich ab $1000/$9000 das Char-ROM sichtbar sein. Aus
  106. *    Geschwindigkeitsgrⁿnden wird in der Emulation das RAM darunter
  107. *    dargestellt. Dies sollte keine Rolle spielen, da diese Bitmap-Seiten
  108. *    aus dem genannten Grund von keinem Programm komplett verwendet werden.
  109. *  - Der IRQ wird bei jedem Schreibzugriff in das Flag-Register gel÷scht.
  110. *    Das ist ein Hack fⁿr die RMW-Befehle des 6510, die zuerst den
  111. *    Originalwert schreiben.
  112. *
  113.  
  114.         MACHINE    68020
  115.  
  116.         INCLUDE    "exec/types.i"
  117.         INCLUDE    "exec/macros.i"
  118.         INCLUDE    "exec/memory.i"
  119.         INCLUDE    "exec/libraries.i"
  120.         INCLUDE    "exec/ports.i"
  121.         INCLUDE    "intuition/intuition.i"
  122.         INCLUDE    "graphics/displayinfo.i"
  123.         INCLUDE    "egs/egs.i"
  124.         INCLUDE    "devices/inputevent.i"
  125.  
  126.         XREF    _SysBase    ;Main.asm
  127.         XREF    _GfxBase
  128.         XREF    _IntuitionBase
  129.         XREF    _EGSBase
  130.         XREF    _VilIntuiBase
  131.         XREF    _CyberGfxBase
  132.  
  133.         XREF    TheRAM        ;6510.asm
  134.         XREF    TheChar
  135.         XREF    TheColor
  136.         XREF    IntIsVICIRQ
  137.         XREF    CyclesLeft
  138.         XREF    DontPause
  139.         XREF    CPUTask
  140.  
  141.         XREF    CountTODs    ;6526.asm
  142.         XREF    Periodic6526
  143.         XREF    KeyPressed
  144.  
  145.         XREF    _c2p4        ;c2p4.asm
  146.         XREF    Initc2p4
  147.         XREF    Exitc2p4
  148.  
  149.         XDEF    OpenGraphics
  150.         XDEF    CloseGraphics
  151.         XDEF    AmigaToFront
  152.         XDEF    EmulToFront
  153.         XDEF    WaitForClick
  154.         XDEF    ChangedVA
  155.         XDEF    Init6569
  156.         XDEF    Exit6569
  157.         XDEF    ReadFrom6569
  158.         XDEF    WriteTo6569
  159.         XDEF    Periodic6569
  160.  
  161.         XDEF    DisplayID    ;Prefs
  162.         XDEF    ScreenType
  163.         XDEF    NormalCycles
  164.         XDEF    BadLineCycles
  165.         XDEF    Collisions
  166.         XDEF    Overscan
  167.         XDEF    SkipLatch
  168.  
  169.         SECTION    "CODE",CODE
  170.  
  171.  
  172. **
  173. ** Definitionen
  174. **
  175.  
  176. ; VIC-Register
  177. M0X        = $00    ;Position von Sprite 0
  178. M0Y        = $01
  179. M1X        = $02    ;Position von Sprite 1
  180. M1Y        = $03
  181. M2X        = $04    ;Position von Sprite 2
  182. M2Y        = $05
  183. M3X        = $06    ;Position von Sprite 3
  184. M3Y        = $07
  185. M4X        = $08    ;Position von Sprite 4
  186. M4Y        = $09
  187. M5X        = $0a    ;Position von Sprite 5
  188. M5Y        = $0b
  189. M6X        = $0c    ;Position von Sprite 6
  190. M6Y        = $0d
  191. M7X        = $0e    ;Position von Sprite 7
  192. M7Y        = $0f
  193. MX8        = $10    ;H÷chste Bits der Sprite X-Positionen
  194. CTRL1        = $11    ;Steuerreg. 1
  195. RASTER        = $12    ;RasterzΣhler
  196. SPREN        = $15    ;Sprite eingeschaltet
  197. CTRL2        = $16    ;Steuerreg. 2
  198. MYE        = $17    ;Sprite Y-Expansion
  199. VBASE        = $18    ;Basisadressen
  200. IRQFLAG        = $19    ;Interruptreg.
  201. IRQMASK        = $1a
  202. MMC        = $1c    ;Sprite Multicolor
  203. MXE        = $1d    ;Sprite X-Expansion
  204. CLXSPR        = $1e    ;Kollisionsreg.
  205. CLXBGR        = $1f
  206.  
  207. ; ZusΣtzliche Register
  208. DISPLAYOFF    = $2f    ;Flag: $3fff wird dargestellt
  209. IRQRASTER    = $30    ;Rasterzeile, bei der ein IRQ ausgel÷st wird (Wort)
  210. XSCROLL        = $32    ;X-Scroll-Wert (Wort)
  211. YSCROLL        = $34    ;Y-Scroll-Wert (Wort)
  212. DXSTART        = $36    ;Aktuelle Werte des Randbereichs
  213. DXSTOP        = $38
  214. DYSTART        = $3a
  215. DYSTOP        = $3c
  216. RC        = $3e    ;RasterzΣhler RC
  217. MATRIXBASE    = $40    ;Videomatrix-Basis (Amiga-Adresse)
  218. CHARBASE    = $44    ;Zeichengenerator-Basis (Amiga-Adresse)
  219. BITMAPBASE    = $48    ;Bitmap-Basis (Amiga-Adresse)
  220. CURRENTA5    = $4c    ;Augenblicklicher Zeiger im Bildschirmspeicher
  221.             ;Speicher fⁿr a5 zwischen Aufrufen von Periodic6569
  222. CURRENTRASTER    = $50    ;Augenblickliche Rasterzeile
  223.             ;Speicher fⁿr d7 zwischen Aufrufen von Periodic6569
  224. LASTBKGD    = $52    ;Letzte dargestellte Hintergrundfarbe
  225. SPRITEON    = $53    ;Sprite wird dargestellt, pro Sprite ein Bit
  226. BORDERON    = $54    ;Flag: Oberer/unterer Rahmen wird dargestellt
  227. IS38COL        = $55    ;Flag: 38 Spalten
  228. SCREENOFF    = $56    ;Flag: Bildschirm ist abgeschaltet, nur Rahmen darstellen
  229.             ;Bei jedem VBlank wird Bit 4 in $D011 getestet und
  230.             ; dieses Flag entsprechend gesetzt
  231. SKIPFRAME    = $57    ;Flag: Dieses Frame ⁿberspringen, nichts zeichnen
  232. MC0        = $58    ;SpritedatenzΣhler 0
  233. MC1        = $5a
  234. MC2        = $5c
  235. MC3        = $5e
  236. MC4        = $60
  237. MC5        = $62
  238. MC6        = $64
  239. MC7        = $66    ;SpritedatenzΣhler 7
  240. VCBASE        = $68    ;VC-Zwischenspeicher
  241. VCCOUNT        = $6a    ;VC-ZΣhler
  242. BORDERLONG    = $6c
  243. BACK0LONG    = $70
  244. BACK1LONG    = $74
  245.  
  246. ; Anzahl Rasterzeilen
  247. TotalRasters    = $138
  248.  
  249. ; Textfenster-Koordinaten (Stop-Werte sind immer eins mehr)
  250. Row25YStart    = $33
  251. Row25YStop    = $fb
  252. Row24YStart    = $37
  253. Row24YStop    = $f7
  254.  
  255. Col40XStart    = $18
  256. Col40XStop    = $158
  257. Col38XStart    = $1f
  258. Col38XStop    = $14f
  259.  
  260. ; Erste und letzte m÷gliche Zeile fⁿr Bad Lines
  261. FirstDMALine    = $30
  262. LastDMALine    = $f7
  263.  
  264. ; Erste und letzte dargestellte Zeile
  265. FirstDispLine    = $10
  266. LastDispLine    = $11f    ;eigentlich $12b
  267.  
  268. ; Gr÷▀e der Anzeige
  269. DisplayX    = $170
  270. DisplayY    = LastDispLine-FirstDispLine+1
  271.  
  272. ; ScreenTypes
  273. STYP_EGS    = 0
  274. STYP_PICASSO    = 1
  275. STYP_AMIGA    = 2
  276. STYP_AMIGAMONO    = 3
  277. STYP_CYBER    = 4
  278.  
  279. ; EGS
  280. E_OpenScreen    = -30
  281. E_CloseScreen    = -36
  282. E_ScreenToFront    = -60
  283. E_ScreenToBack    = -66
  284. E_ActivateEGSScreen = -72
  285. E_ActivateAmigaScreen = -78
  286. E_SetRGB8    = -84
  287. E_DisposeBitMap    = -132
  288. E_FlipMap    = -168
  289. E_AllocBitMap    = -198
  290.  
  291. ; Village
  292. OpenVillageScreen = -30
  293. CloseVillageScreen = -36
  294. LockVillageScreen = -42
  295. UnLockVillageScreen = -48
  296. OpenVillageScreenTagList = -114
  297. VillageGetBufAddr = -126
  298. VillageSetDisplayBuf = -132
  299.  
  300. TAVIS_FIRSTITEM    = TAG_USER+4711
  301. TAVIS_DOUBLE_BUFFER = TAVIS_FIRSTITEM+40
  302. TAVIS_DM_STRUCT    = TAVIS_FIRSTITEM+41
  303.  
  304. ; CyberGfx
  305. IsCyberModeID    = -54
  306. DoCDrawMethod    = -156
  307.  
  308. *
  309. * Makros
  310. *
  311.  
  312. ; Aus einer VIC-16-Bit-Adresse die entsprechende Amiga-Adresse berechnen
  313. ; -> d0.w: 16-Bit-Adresse
  314. ; <- a0.l: 32-Bit-Adresse
  315. GetPhysical    MACRO
  316.         or.w    CiaVABase(pc),d0 ;VA14/15 dazunehmen
  317.         move.w    d0,d1
  318.         and.w    #$7000,d1
  319.         cmp.w    #$1000,d1
  320.         beq    \@1$
  321.         move.l    TheRAM(pc),a0
  322.         moveq    #0,d1
  323.         move.w    d0,d1
  324.         add.l    d1,a0
  325.         bra    \@2$
  326. \@1$        and.w    #$0fff,d0    ;$1000-$1fff, $9000-$9fff: Char-ROM
  327.         move.l    TheChar(pc),a0
  328.         add.w    d0,a0
  329. \@2$
  330.         ENDM
  331.  
  332. ; Sprite darstellen
  333. DoSprite    MACRO    ;Nummer
  334.         moveq    #\1,d6        ;d6: Spritenummer
  335.         btst    d6,SPRITEON(a4)    ;Wird das Sprite dargestellt?
  336.         beq    \@1$
  337.  
  338.         move.w    $27+\1(a4),d2
  339.         move.b    $27+\1(a4),d2    ;d2.w: Spritefarbe
  340.         move.w    MC\1(a4),d5    ;d5: DatenzΣhler
  341.         move.l    MATRIXBASE(a4),a0
  342.         move.b    $03f8+\1(a0),d7    ;d7: Datenzeiger
  343.         lea    M\1X(a4),a2    ;a2: Zeiger auf X-Koordinate
  344.         bsr    DrawSprite
  345. \@1$
  346.         ENDM
  347.  
  348.  
  349. **
  350. ** Bildschirm ÷ffnen
  351. ** Rⁿckgabe: d0=0 Alles OK
  352. **           d0=1 Fehler beim Screen-╓ffnen
  353. **           d0=2 Kein Speicher
  354. **           d0=3 Kein EGS
  355. **           d0=4 Kein VilIntuiSup
  356. **           d0=5 Probleme mit DisplayID
  357. **           d0=6 Screen zu klein (min. 384╫272)
  358. **           d0=7 Kein CyberGfx
  359. **           d0=8 Kein CyberGfx-Modus ausgewΣhlt
  360. **
  361.  
  362. ; Kollisionsflag-Tabelle berechnen
  363. OpenGraphics    lea    SprCollTab,a0    ;Vorgabe: Kollision
  364.         moveq    #256/4-1,d0
  365. 1$        move.l    #-1,(a0)+
  366.         dbra    d0,1$
  367.  
  368.         lea    SprCollTab,a0    ;Keine Kollision bei nur einem Sprite
  369.         clr.w    (a0)
  370.         clr.b    2(a0)
  371.         clr.b    4(a0)
  372.         clr.b    8(a0)
  373.         clr.b    16(a0)
  374.         clr.b    32(a0)
  375.         clr.b    64(a0)
  376.         clr.b    128(a0)
  377.  
  378. ; Name des ScreenMode holen
  379.         move.l    _GfxBase,a6
  380.         sub.l    a0,a0
  381.         lea    ModeNameBuf,a1
  382.         moveq    #nif_SIZEOF,d0
  383.         move.l    #DTAG_NAME,d1
  384.         move.l    DisplayID,d2
  385.         JSRLIB    GetDisplayInfoData
  386.         tst.l    d0
  387.         beq    NoDisplayID
  388.  
  389. ; Register vorbereiten
  390.         lea    Registers,a0
  391.         move.w    #7,RC(a0)
  392.         move.w    #-1,CURRENTRASTER(a0)
  393.         move.l    TheRAM,MATRIXBASE(a0)
  394.         move.l    TheRAM,CHARBASE(a0)
  395.         move.l    TheRAM,BITMAPBASE(a0)
  396.         clr.w    CiaVABase
  397.         move.l    #TextStd,DisplayProc
  398.         move.w    #63,MC0(a0)
  399.         move.w    #63,MC1(a0)
  400.         move.w    #63,MC2(a0)
  401.         move.w    #63,MC3(a0)
  402.         move.w    #63,MC4(a0)
  403.         move.w    #63,MC5(a0)
  404.         move.w    #63,MC6(a0)
  405.         move.w    #63,MC7(a0)
  406.  
  407. ; Screen-Typ auswerten (Amiga)
  408.         cmp.w    #STYP_AMIGA,ScreenType
  409.         beq    OpenAmiga
  410.         cmp.w    #STYP_AMIGAMONO,ScreenType
  411.         beq    OpenAmigaMono
  412.  
  413. ; EGS/Picasso/Cyber: Dimensionen holen und prⁿfen, ob ausreichend
  414.         move.l    _IntuitionBase,a6
  415.         move.l    DisplayID,a0
  416.         lea    TheRect,a1
  417.         moveq    #OSCAN_TEXT,d0
  418.         JSRLIB    QueryOverscan
  419.         tst.l    d0
  420.         beq    NoDisplayID
  421.  
  422.         lea    TheRect,a0
  423.         move.w    ra_MaxX(a0),d0
  424.         sub.w    ra_MinX(a0),d0
  425.         addq.w    #1,d0
  426.         move.w    d0,ScreenX
  427.         move.w    ra_MaxY(a0),d0
  428.         sub.w    ra_MinY(a0),d0
  429.         addq.w    #1,d0
  430.         move.w    d0,ScreenY
  431.  
  432.         cmp.w    #384,ScreenX
  433.         blo    TooSmall
  434.         cmp.w    #272,ScreenY
  435.         blo    TooSmall
  436.  
  437. ; Screen-Typ auswerten (EGS/Picasso/Cyber)
  438.         cmp.w    #STYP_EGS,ScreenType
  439.         beq    OpenEGS
  440.         cmp.w    #STYP_CYBER,ScreenType
  441.         beq    OpenCyber
  442.         bra    OpenPicasso
  443.  
  444. *
  445. * Amiga-Screen ÷ffnen
  446. *
  447.  
  448. ; Screen ÷ffnen
  449. OpenAmiga    move.w    #$180,d0        ;Vielfaches von 32 (wegen c2p)
  450.         move.w    d0,ScreenX
  451.         move.w    d0,WindowWidth+2
  452.         move.w    #DisplayY,d0
  453.         move.w    d0,ScreenY
  454.         move.w    d0,WindowHeight+2
  455.         move.l    DisplayID,ScreenDID
  456.         move.w    Overscan,ScreenOScan+2
  457.  
  458.         bsr    Initc2p4
  459.         tst.l    d0
  460.         beq    NoMem
  461.  
  462.         move.l    _IntuitionBase,a6
  463.         sub.l    a0,a0
  464.         lea    ScreenTags,a1
  465.         JSRLIB    OpenScreenTagList
  466.         move.l    d0,TheScreen
  467.         beq    NoScreen
  468.         move.l    d0,WindowScreen
  469.  
  470.         move.l    TheScreen,a0
  471.         lea    sc_RastPort(a0),a1
  472.         move.l    a1,TheRastPort
  473.         lea    sc_ViewPort(a0),a1
  474.         move.l    a1,TheViewPort
  475.  
  476. ; Speicher fⁿr Chunky-BitMap und Comparison Buffer holen
  477.         move.l    _SysBase,a6
  478.         move.w    ScreenX,d0
  479.         mulu.w    #DisplayY,d0
  480.         add.l    d0,d0
  481.         move.l    #MEMF_PUBLIC|MEMF_CLEAR,d1
  482.         JSRLIB    AllocVec
  483.         move.l    d0,InvisibleMap
  484.         beq    NoMem
  485.         move.w    ScreenX,d1
  486.         mulu.w    #DisplayY,d1
  487.         add.l    d1,d0
  488.         move.l    d0,ComparisonBuf
  489.  
  490. ; Fenster ÷ffnen
  491.         move.l    _IntuitionBase,a6
  492.         sub.l    a0,a0
  493.         lea    WindowTags,a1
  494.         JSRLIB    OpenWindowTagList
  495.         move.l    d0,TheWindow
  496.         beq    NoMem
  497.  
  498.         move.l    TheWindow,a0
  499.         move.l    wd_UserPort(a0),WindowPort
  500.  
  501. ; Farbpalette laden
  502.         move.l    _GfxBase,a6
  503.         moveq    #0,d7        ;RegisterzΣhler
  504.         lea    Palette,a2
  505. 1$        move.b    d7,d0
  506.         and.w    #$0f,d0
  507.         lea    (a2,d0.w*4),a0
  508.         moveq    #0,d1
  509.         move.b    (a0)+,d1
  510.         lsr.b    #4,d1
  511.         moveq    #0,d2
  512.         move.b    (a0)+,d2
  513.         lsr.b    #4,d2
  514.         moveq    #0,d3
  515.         move.b    (a0)+,d3
  516.         lsr.b    #4,d3
  517.         move.l    d7,d0
  518.         move.l    TheViewPort,a0
  519.         JSRLIB    SetRGB4
  520.         addq.b    #1,d7
  521.         cmp.b    #16,d7        ;Hier nur 16 Register
  522.         bne    1$
  523.  
  524. ; VBlank-Routine setzen
  525.         move.l    #AmigaVBlank,VBlankProc
  526.  
  527. ; Double Buffering-Kram einrichten
  528. ; Bildschirmadresse neu setzen!
  529.         bsr    OpenDoubleBuf
  530.         clr.w    MustWaitForC2P
  531.  
  532.         moveq    #0,d0
  533.         rts
  534.  
  535. *
  536. * Amiga-Mono-Screen ÷ffnen
  537. *
  538.  
  539. ; Screen ÷ffnen
  540. OpenAmigaMono    move.w    #$180,d0
  541.         move.w    d0,ScreenX
  542.         move.w    d0,WindowWidth+2
  543.         move.w    #DisplayY,d0
  544.         move.w    d0,ScreenY
  545.         move.w    d0,WindowHeight+2
  546.         move.l    DisplayID,MonoScreenDID
  547.         move.w    Overscan,MonoScreenOScan+2
  548.  
  549.         move.l    _IntuitionBase,a6
  550.         sub.l    a0,a0
  551.         lea    MonoScreenTags,a1
  552.         JSRLIB    OpenScreenTagList
  553.         move.l    d0,TheScreen
  554.         beq    NoScreen
  555.         move.l    d0,WindowScreen
  556.  
  557.         move.l    TheScreen,a0
  558.         lea    sc_RastPort(a0),a1
  559.         move.l    a1,TheRastPort
  560.         lea    sc_ViewPort(a0),a1
  561.         move.l    a1,TheViewPort
  562.  
  563. ; Fenster ÷ffnen
  564.         move.l    _IntuitionBase,a6
  565.         sub.l    a0,a0
  566.         lea    WindowTags,a1
  567.         JSRLIB    OpenWindowTagList
  568.         move.l    d0,TheWindow
  569.         beq    NoMem
  570.  
  571.         move.l    TheWindow,a0
  572.         move.l    wd_UserPort(a0),WindowPort
  573.  
  574. ; Farbpalette laden (schwarz/wei▀)
  575.         move.l    _GfxBase,a6
  576.         move.l    TheViewPort,a0
  577.         moveq    #0,d0
  578.         moveq    #0,d1
  579.         moveq    #0,d2
  580.         moveq    #0,d3
  581.         JSRLIB    SetRGB4
  582.         move.l    TheViewPort,a0
  583.         moveq    #1,d0
  584.         moveq    #15,d1
  585.         moveq    #15,d2
  586.         moveq    #15,d3
  587.         JSRLIB    SetRGB4
  588.  
  589. ; Adresse der Bitplane setzen
  590.         move.l    TheRastPort,a0
  591.         move.l    rp_BitMap(a0),a0
  592.         move.l    bm_Planes(a0),a0
  593.         move.l    a0,InvisibleMap
  594.         move.l    a0,Registers+CURRENTA5
  595.  
  596. ; VBlank-Routine und erste Display-Proc setzen
  597.         move.l    #AmigaMonoVBlank,VBlankProc
  598.         move.l    #FTextStd,DisplayProc
  599.  
  600. ; Double Buffering-Kram einrichten
  601.         bsr    OpenDoubleBuf
  602.  
  603.         moveq    #0,d0
  604.         rts
  605.  
  606. *
  607. * Picasso-Screen ÷ffnen
  608. *
  609.  
  610. ; vilintuisup.library ÷ffnen
  611. OpenPicasso    move.l    _SysBase,a6
  612.         moveq    #2,d0
  613.         lea    VilIntuiName,a1
  614.         JSRLIB    OpenLibrary
  615.         move.l    d0,_VilIntuiBase
  616.         beq    NoVilIntuiSup
  617.  
  618. ; Screen ÷ffnen (interleaved)
  619.         move.w    ScreenX,WindowWidth+2
  620.         move.w    ScreenY,WindowHeight+2
  621.  
  622.         move.l    _VilIntuiBase,a6
  623.         lea    Dimensions,a0
  624.         move.w    ScreenX,4(a0)
  625.         move.w    ScreenY,6(a0)
  626.         lea    VilTags,a0
  627.         jsr    OpenVillageScreenTagList(a6)
  628.         move.l    d0,TheScreen
  629.         beq    NoScreen
  630.         move.l    d0,WindowScreen
  631.  
  632.         move.l    TheScreen,a0
  633.         lea    sc_ViewPort(a0),a1
  634.         move.l    a1,TheViewPort
  635.  
  636. ; Fenster ÷ffnen
  637.         move.l    _IntuitionBase,a6
  638.         sub.l    a0,a0
  639.         lea    WindowTags,a1
  640.         JSRLIB    OpenWindowTagList
  641.         move.l    d0,TheWindow
  642.         beq    NoMem
  643.  
  644.         move.l    TheWindow,a0
  645.         move.l    wd_UserPort(a0),WindowPort
  646.  
  647. ; Farbpalette laden
  648.         move.l    _GfxBase,a6
  649.         moveq    #0,d7        ;RegisterzΣhler
  650.         lea    Palette,a2
  651. 1$        move.b    d7,d0
  652.         and.w    #$0f,d0
  653.         lea    (a2,d0.w*4),a0
  654.         moveq    #0,d1
  655.         move.b    (a0)+,d1
  656.         moveq    #0,d2
  657.         move.b    (a0)+,d2
  658.         moveq    #0,d3
  659.         move.b    (a0)+,d3
  660.         move.l    d7,d0
  661.         move.l    TheViewPort,a0
  662.         JSRLIB    SetRGB4
  663.         addq.b    #1,d7
  664.         bne    1$
  665.  
  666. ; Adresse des Bildschirmspeichers setzen
  667.         move.l    #1,InvBufNum        ;Adresse des zweiten Puffers holen
  668.         move.l    _VilIntuiBase,a6
  669.         move.l    TheScreen,a0
  670.         jsr    LockVillageScreen(a6)
  671.         move.l    TheScreen,a0
  672.         move.l    InvBufNum,d0
  673.         jsr    VillageGetBufAddr(a6)
  674.         move.l    d0,Registers+CURRENTA5
  675.  
  676. ; VBlank-Routine setzen
  677.         move.l    #PicassoVBlank,VBlankProc
  678.  
  679.         moveq    #0,d0
  680.         rts
  681.  
  682. *
  683. * EGS-Screen ÷ffnen
  684. *
  685.  
  686. ; egs.library ÷ffnen
  687. OpenEGS        move.l    _SysBase,a6
  688.         moveq    #6,d0
  689.         lea    EGSName,a1
  690.         JSRLIB    OpenLibrary
  691.         move.l    d0,_EGSBase
  692.         beq    NoEGS
  693.  
  694. ; Screen ÷ffnen
  695.         move.l    _EGSBase,a6
  696.         lea    NewEScreen,a0
  697.         jsr    E_OpenScreen(a6)
  698.         move.l    d0,TheScreen
  699.         beq    NoScreen
  700.  
  701.         move.l    TheScreen,a0
  702.         move.l    esc_Port(a0),EGSPort
  703.  
  704. ; Zweite Bitmap fⁿr Double Buffering holen
  705.         moveq    #0,d0
  706.         move.w    ScreenX,d0
  707.         moveq    #0,d1
  708.         move.w    ScreenY,d1
  709.         moveq    #8,d2
  710.         moveq    #0,d3
  711.         move.l    #E_EB_DISPLAYABLE|E_EB_CLEARMAP,d4
  712.         move.l    TheScreen,a0
  713.         move.l    esc_Map(a0),a0
  714.         jsr    E_AllocBitMap(a6)
  715.         move.l    d0,InvisibleMap
  716.         beq    NoMem
  717.  
  718. ; Farbpalette laden
  719.         moveq    #0,d7        ;RegisterzΣhler
  720.         lea    Palette,a2
  721. 1$        move.b    d7,d0
  722.         and.w    #$0f,d0
  723.         lea    (a2,d0.w*4),a0
  724.         moveq    #0,d1
  725.         move.b    (a0)+,d1
  726.         moveq    #0,d2
  727.         move.b    (a0)+,d2
  728.         moveq    #0,d3
  729.         move.b    (a0)+,d3
  730.         move.l    d7,d0
  731.         move.l    TheScreen,a0
  732.         jsr    E_SetRGB8(a6)
  733.         addq.b    #1,d7
  734.         bne    1$
  735.  
  736. ; Adresse des Bildschirmspeichers setzen
  737.         move.l    InvisibleMap,a1
  738.         addq.b    #1,ebm_Lock(a1)
  739.         move.l    ebm_Dest(a1),Registers+CURRENTA5
  740.  
  741. ; VBlank-Routine setzen
  742.         move.l    #EGSVBlank,VBlankProc
  743.  
  744.         moveq    #0,d0
  745.         rts
  746.  
  747. *
  748. * Cybergraphics-Screen ÷ffnen
  749. *
  750.  
  751. ; cybergraphics.library ÷ffnen
  752. OpenCyber    tst.l    _CyberGfxBase
  753.         bne    2$
  754.         move.l    _SysBase,a6
  755.         moveq    #40,d0
  756.         lea    CyberGfxName,a1
  757.         JSRLIB    OpenLibrary
  758.         move.l    d0,_CyberGfxBase
  759.         beq    NoCyberGfx
  760. 2$
  761.  
  762. ; CyberGfx-Modus?
  763.         move.l    _CyberGfxBase,a6
  764.         move.l    DisplayID,d0
  765.         jsr    IsCyberModeID(a6)
  766.         tst.l    d0
  767.         beq    NoCyberMode
  768.  
  769. ; Screen ÷ffnen
  770.         move.w    ScreenX,WindowWidth+2
  771.         move.w    ScreenX,CyberScreenX+2
  772.         move.w    ScreenY,WindowHeight+2
  773.         move.w    ScreenY,CyberScreenY+2
  774.         move.l    DisplayID,CyberScreenDID
  775.  
  776.         move.l    _IntuitionBase,a6
  777.         sub.l    a0,a0
  778.         lea    CyberScreenTags,a1
  779.         JSRLIB    OpenScreenTagList
  780.         move.l    d0,TheScreen
  781.         beq    NoScreen
  782.         move.l    d0,WindowScreen
  783.  
  784.         move.l    TheScreen,a0
  785.         lea    sc_RastPort(a0),a1
  786.         move.l    a1,TheRastPort
  787.         lea    sc_ViewPort(a0),a1
  788.         move.l    a1,TheViewPort
  789.  
  790. ; Fenster ÷ffnen
  791.         move.l    _IntuitionBase,a6
  792.         sub.l    a0,a0
  793.         lea    WindowTags,a1
  794.         JSRLIB    OpenWindowTagList
  795.         move.l    d0,TheWindow
  796.         beq    NoMem
  797.  
  798.         move.l    TheWindow,a0
  799.         move.l    wd_UserPort(a0),WindowPort
  800.  
  801. ; Farbpalette laden
  802.         move.l    _GfxBase,a6
  803.         moveq    #0,d7        ;RegisterzΣhler
  804.         lea    Palette,a2
  805. 1$        move.b    d7,d0
  806.         and.w    #$0f,d0
  807.         lea    (a2,d0.w*4),a0
  808.         move.w    (a0),d1
  809.         move.b    (a0),d1
  810.         swap    d1
  811.         move.w    (a0),d1
  812.         move.b    (a0)+,d1
  813.         move.w    (a0),d2
  814.         move.b    (a0),d2
  815.         swap    d2
  816.         move.w    (a0),d2
  817.         move.b    (a0)+,d2
  818.         move.w    (a0),d3
  819.         move.b    (a0),d3
  820.         swap    d3
  821.         move.w    (a0),d3
  822.         move.b    (a0)+,d3
  823.         move.l    d7,d0
  824.         move.l    TheViewPort,a0
  825.         JSRLIB    SetRGB32
  826.         addq.b    #1,d7
  827.         bne    1$
  828.  
  829. ; Es wird alles nach LineStore geschrieben
  830.         move.l    #LineStore,Registers+CURRENTA5
  831.  
  832. ; VBlank-Routine setzen
  833.         move.l    #CyberVBlank,VBlankProc
  834.  
  835.         moveq    #0,d0
  836.         rts
  837.  
  838. ; Fehler aufgetreten
  839. NoScreen    moveq    #1,d0
  840.         rts
  841. NoMem        moveq    #2,d0
  842.         rts
  843. NoEGS        moveq    #3,d0
  844.         rts
  845. NoVilIntuiSup    moveq    #4,d0
  846.         rts
  847. NoDisplayID    moveq    #5,d0
  848.         rts
  849. TooSmall    moveq    #6,d0
  850.         rts
  851. NoCyberGfx    moveq    #7,d0
  852.         rts
  853. NoCyberMode    moveq    #8,d0
  854.         rts
  855.  
  856.  
  857. *
  858. * Double Buffering einrichten
  859. *
  860.  
  861. ; Intuition V39 vorhanden? Sonst hat's keinen Zweck.
  862. OpenDoubleBuf    move.l    _IntuitionBase,a0
  863.         cmp.w    #39,LIB_VERSION(a0)
  864.         blo    1$
  865.  
  866. ; Screen Buffer holen
  867.         move.l    _IntuitionBase,a6
  868.         move.l    TheScreen,a0
  869.         sub.l    a1,a1
  870.         moveq    #SB_SCREEN_BITMAP,d0
  871.         JSRLIB    AllocScreenBuffer
  872.         move.l    d0,ScrBuf0
  873.         beq    CloseDoubleBuf
  874.  
  875.         move.l    TheScreen,a0
  876.         sub.l    a1,a1
  877.         moveq    #SB_COPY_BITMAP,d0
  878.         JSRLIB    AllocScreenBuffer
  879.         move.l    d0,ScrBuf1
  880.         beq    CloseDoubleBuf
  881.  
  882. ; Etwas warten
  883.         move.l    _GfxBase,a6
  884.         JSRLIB    WaitTOF
  885.         JSRLIB    WaitTOF
  886.  
  887. ; Adresse des Bildschirmspeichers holen
  888.         move.l    #1,InvBufNum
  889.  
  890.         cmp.w    #STYP_AMIGA,ScreenType
  891.         beq    2$
  892.         move.l    ScrBuf1,a0
  893.         move.l    sb_BitMap(a0),a0
  894.         move.l    bm_Planes(a0),Registers+CURRENTA5
  895.         move.w    #-1,UsingDB
  896. 1$        rts
  897.  
  898. ; Amiga: Zweiten Comparison Buffer holen
  899. 2$        move.l    InvisibleMap,Registers+CURRENTA5
  900.  
  901.         move.l    _SysBase,a6
  902.         move.w    ScreenX,d0
  903.         mulu.w    #DisplayY,d0
  904.         move.l    #MEMF_PUBLIC|MEMF_CLEAR,d1
  905.         JSRLIB    AllocVec
  906.         move.l    d0,ComparisonBuf1
  907.         beq    CloseDoubleBuf
  908.  
  909.         move.w    #-1,UsingDB
  910.         rts
  911.  
  912.  
  913. **
  914. ** Bildschirm schlie▀en
  915. **
  916.  
  917. CloseGraphics    cmp.w    #STYP_EGS,ScreenType
  918.         beq    CloseEGS
  919.         cmp.w    #STYP_PICASSO,ScreenType
  920.         beq    ClosePicasso
  921.         cmp.w    #STYP_AMIGAMONO,ScreenType
  922.         beq    CloseAmigaMono
  923.         cmp.w    #STYP_CYBER,ScreenType
  924.         beq    CloseCyber
  925.  
  926. ; Amiga
  927. CloseAmiga    move.l    _IntuitionBase,a6
  928.         move.l    TheWindow,d0
  929.         beq    1$
  930.         move.l    d0,a0
  931.         JSRLIB    CloseWindow
  932.  
  933. 1$        bsr    CloseDoubleBuf
  934.  
  935.         move.l    _IntuitionBase,a6
  936.         move.l    TheScreen,d0
  937.         beq    2$
  938.         move.l    d0,a0
  939.         JSRLIB    CloseScreen
  940.  
  941. 2$        move.l    InvisibleMap,d0
  942.         beq    3$
  943.         move.l    _SysBase,a6
  944.         move.l    d0,a1
  945.         JSRLIB    FreeVec
  946.  
  947. 3$        bra    Exitc2p4
  948.  
  949. ; Amiga-Mono
  950. CloseAmigaMono    move.l    _IntuitionBase,a6
  951.         move.l    TheWindow,d0
  952.         beq    1$
  953.         move.l    d0,a0
  954.         JSRLIB    CloseWindow
  955.  
  956. 1$        bsr    CloseDoubleBuf
  957.  
  958.         move.l    _IntuitionBase,a6
  959.         move.l    TheScreen,d0
  960.         beq    2$
  961.         move.l    d0,a0
  962.         JSRLIB    CloseScreen
  963. 2$        rts
  964.  
  965. ; Picasso
  966. ClosePicasso    move.l    _IntuitionBase,a6
  967.         move.l    TheWindow,d0
  968.         beq    1$
  969.         move.l    d0,a0
  970.         JSRLIB    CloseWindow
  971.  
  972. 1$        move.l    _VilIntuiBase,a6
  973.         move.l    TheScreen,d0
  974.         beq    2$
  975.         move.l    d0,a0
  976.         jsr    UnLockVillageScreen(a6)
  977.         move.l    TheScreen,a0
  978.         jsr    CloseVillageScreen(a6)
  979. 2$        rts
  980.  
  981. ; EGS
  982. CloseEGS    move.l    _EGSBase,a6
  983.         move.l    TheScreen,d0
  984.         beq    1$
  985.         move.l    d0,a0
  986.         jsr    E_CloseScreen(a6)
  987.  
  988. 1$        move.l    InvisibleMap,d0
  989.         beq    2$
  990.         move.l    d0,a0
  991.         subq.b    #1,ebm_Lock(a0)
  992.         jsr    E_DisposeBitMap(a6)
  993. 2$        rts
  994.  
  995. ; Cybergraphics
  996. CloseCyber    move.l    _IntuitionBase,a6
  997.         move.l    TheWindow,d0
  998.         beq    1$
  999.         move.l    d0,a0
  1000.         JSRLIB    CloseWindow
  1001.  
  1002. 1$        move.l    TheScreen,d0
  1003.         beq    2$
  1004.         move.l    d0,a0
  1005.         JSRLIB    CloseScreen
  1006. 2$        rts
  1007.  
  1008. *
  1009. * Double Buffering schlie▀en
  1010. *
  1011.  
  1012. ; Zweiten Comparison Buffer freigeben
  1013. CloseDoubleBuf    tst.w    UsingDB
  1014.         beq    2$
  1015.  
  1016.         move.l    _SysBase,a6
  1017.         move.l    ComparisonBuf1,d0
  1018.         beq    1$
  1019.         move.l    d0,a1
  1020.         JSRLIB    FreeVec
  1021.  
  1022. ; Screen Buffer freigeben
  1023. 1$        move.l    _IntuitionBase,a6
  1024.         move.l    TheScreen,a0
  1025.         move.l    ScrBuf0,a1        ;NULL ist OK
  1026.         JSRLIB    FreeScreenBuffer
  1027.  
  1028.         move.l    TheScreen,a0
  1029.         move.l    ScrBuf1,a1
  1030.         JSRLIB    FreeScreenBuffer
  1031. 2$        rts
  1032.  
  1033.  
  1034. **
  1035. ** Amiga-Anzeige nach vorne
  1036. **
  1037.  
  1038. AmigaToFront    cmp.w    #STYP_EGS,ScreenType
  1039.         beq    ATFEGS
  1040.  
  1041. ; Amiga/Picasso/Cyber
  1042.         move.l    a6,-(sp)
  1043.         move.l    _IntuitionBase,a6
  1044.         move.l    TheScreen,a0
  1045.         JSRLIB    ScreenToBack
  1046.         move.l    (sp)+,a6
  1047.         rts
  1048.  
  1049. ; EGS
  1050. ATFEGS        move.l    a6,-(sp)
  1051.         move.l    _EGSBase,a6
  1052.         jsr    E_ActivateAmigaScreen(a6)
  1053.         move.l    TheScreen,a0
  1054.         jsr    E_ScreenToBack(a6)
  1055.         move.l    (sp)+,a6
  1056.         rts
  1057.  
  1058.  
  1059. **
  1060. ** Emulator-Anzeige nach vorne
  1061. **
  1062.  
  1063. EmulToFront    cmp.w    #STYP_EGS,ScreenType
  1064.         beq    ETFEGS
  1065.  
  1066. ; Amiga/Picasso/Cyber
  1067.         move.l    a6,-(sp)
  1068.         move.l    _IntuitionBase,a6
  1069.         move.l    TheScreen,a0
  1070.         JSRLIB    ScreenToFront
  1071.         move.l    (sp)+,a6
  1072.         rts
  1073.  
  1074. ; EGS
  1075. ETFEGS        move.l    a6,-(sp)
  1076.         move.l    _EGSBase,a6
  1077.         jsr    E_ActivateEGSScreen(a6)
  1078.         move.l    TheScreen,a0
  1079.         jsr    E_ScreenToFront(a6)
  1080.         move.l    (sp)+,a6
  1081.         rts
  1082.  
  1083.  
  1084. **
  1085. ** Auf rechten Mausklick warten, Tastatur handhaben
  1086. **
  1087.  
  1088. WaitForClick    cmp.w    #STYP_EGS,ScreenType
  1089.         beq    WFCEGS
  1090.  
  1091. ; Amiga/Picasso/Cyber
  1092. WFCAmiga    move.l    _SysBase,a6
  1093.         move.l    WindowPort,a0
  1094.         JSRLIB    WaitPort
  1095.  
  1096.         move.l    WindowPort,a0
  1097.         JSRLIB    GetMsg
  1098.         tst.l    d0
  1099.         beq    WFCAmiga
  1100.         move.l    d0,a1
  1101.         move.l    20(a1),d2    ;d2: Class
  1102.         move.w    24(a1),d3    ;d3: Code
  1103.         move.l    32(a1),d4    ;d4: MouseXY
  1104.         move.w    26(a1),d5    ;d5: Qualifier
  1105.         JSRLIB    ReplyMsg
  1106.  
  1107. ; Klasse auswerten
  1108.         cmp.l    #IDCMP_MOUSEBUTTONS,d2
  1109.         bne    1$
  1110.         cmp.w    #IECODE_RBUTTON,d3 ;Rechte Maustaste: Beenden
  1111.         beq    WFCDone
  1112.         bra    WFCAmiga
  1113.  
  1114. 1$        cmp.l    #IDCMP_RAWKEY,d2
  1115.         bne    WFCAmiga
  1116.         move.b    d3,d0
  1117.         bsr    KeyPressed    ;Tastaturabfrage
  1118.         bra    WFCAmiga
  1119.  
  1120. ; EGS
  1121. WFCEGS        move.l    _SysBase,a6
  1122.         move.l    EGSPort,a0
  1123.         JSRLIB    WaitPort
  1124.  
  1125.         move.l    EGSPort,a0
  1126.         JSRLIB    GetMsg
  1127.         tst.l    d0
  1128.         beq    WFCEGS
  1129.         move.l    d0,a1
  1130.         move.l    20(a1),d2    ;d2: Class
  1131.         move.w    24(a1),d3    ;d3: Code
  1132.         move.l    32(a1),d4    ;d4: MouseXY
  1133.         move.w    26(a1),d5    ;d5: Qualifier
  1134.         JSRLIB    ReplyMsg
  1135.  
  1136. ; Klasse auswerten
  1137.         cmp.w    #E_eMOUSEBUTTONS,d2
  1138.         bne    1$
  1139.         cmp.w    #IECODE_RBUTTON,d3 ;Rechte Maustaste: Beenden
  1140.         beq    WFCDone
  1141.         bra    WFCEGS
  1142.  
  1143. 1$        cmp.w    #E_eRAWKEY,d2
  1144.         bne    WFCEGS
  1145.         move.b    d3,d0
  1146.         bsr    KeyPressed    ;Tastaturabfrage
  1147.         bra    WFCEGS
  1148.  
  1149. ; Beenden
  1150. WFCDone        rts
  1151.  
  1152.  
  1153. **
  1154. ** CIA-VA14/15 hat sich geΣndert, Video-Bank wechseln
  1155. ** d0.b: Neue VA ($00-$03)
  1156. **
  1157.  
  1158. ChangedVA    lea    Registers,a0    ;Wichtig fⁿr WrVBASE
  1159.         clr.w    d1        ;VABase speichern
  1160.         move.b    d0,d1
  1161.         ror.w    #2,d1
  1162.         move.w    d1,CiaVABase
  1163.  
  1164.         move.b    VBASE(a0),d1 ;Zeiger neu berechnen
  1165.         bra    WrVBASE
  1166.  
  1167.  
  1168. **
  1169. ** Initialisierung vom 6510-Task aus
  1170. **
  1171.  
  1172. ; Signal fⁿr c2p4 holen
  1173. Init6569    move.l    _SysBase,a6
  1174.         moveq    #-1,d0
  1175.         JSRLIB    AllocSignal
  1176.         move.b    d0,GfxSig
  1177.         moveq    #0,d1
  1178.         bset    d0,d1
  1179.         move.l    d1,GfxSet
  1180.         rts
  1181.  
  1182.  
  1183. **
  1184. ** AufrΣumen vom 6510-Task aus
  1185. **
  1186.  
  1187. ; Ggf. auf Signal von c2p4 warten und freigeben
  1188. Exit6569    move.l    _SysBase,a6
  1189.         tst.w    MustWaitForC2P
  1190.         beq    1$
  1191.         move.l    GfxSet,d0
  1192.         JSRLIB    Wait
  1193.  
  1194. 1$        moveq    #0,d0
  1195.         move.b    GfxSig,d0
  1196.         JSRLIB    FreeSignal
  1197.         rts
  1198.  
  1199.  
  1200. **
  1201. ** Aus einem VIC-Register lesen
  1202. ** d0.w: Registernummer ($00-$3f)
  1203. ** Rⁿckgabe: d0.b: Byte
  1204. **
  1205. ** Darf das obere Wort von d0 und d1 nicht verΣndern!
  1206. ** Darf a1 nicht verΣndern!
  1207. **
  1208.  
  1209. ReadFrom6569    move.l    ReadTab(pc,d0.w*4),a0
  1210.         jmp    (a0)
  1211.  
  1212.         CNOP    0,4
  1213. ReadTab        dc.l    RdNormal
  1214.         dc.l    RdNormal
  1215.         dc.l    RdNormal
  1216.         dc.l    RdNormal
  1217.         dc.l    RdNormal
  1218.         dc.l    RdNormal
  1219.         dc.l    RdNormal
  1220.         dc.l    RdNormal
  1221.         dc.l    RdNormal
  1222.         dc.l    RdNormal
  1223.         dc.l    RdNormal
  1224.         dc.l    RdNormal
  1225.         dc.l    RdNormal
  1226.         dc.l    RdNormal
  1227.         dc.l    RdNormal
  1228.         dc.l    RdNormal
  1229.  
  1230.         dc.l    RdNormal
  1231.         dc.l    RdCTRL1
  1232.         dc.l    RdRASTER
  1233.         dc.l    RdNormal
  1234.         dc.l    RdNormal
  1235.         dc.l    RdNormal
  1236.         dc.l    RdCTRL2
  1237.         dc.l    RdNormal
  1238.         dc.l    RdVBASE
  1239.         dc.l    RdIRQFLAG
  1240.         dc.l    RdIRQMASK
  1241.         dc.l    RdNormal
  1242.         dc.l    RdNormal
  1243.         dc.l    RdNormal
  1244.         dc.l    RdCLXSPR
  1245.         dc.l    RdCLXBGR
  1246.  
  1247.         dc.l    RdColor
  1248.         dc.l    RdColor
  1249.         dc.l    RdColor
  1250.         dc.l    RdColor
  1251.         dc.l    RdColor
  1252.         dc.l    RdColor
  1253.         dc.l    RdColor
  1254.         dc.l    RdColor
  1255.         dc.l    RdColor
  1256.         dc.l    RdColor
  1257.         dc.l    RdColor
  1258.         dc.l    RdColor
  1259.         dc.l    RdColor
  1260.         dc.l    RdColor
  1261.         dc.l    RdColor
  1262.         dc.l    RdUndef
  1263.  
  1264.         dc.l    RdUndef
  1265.         dc.l    RdUndef
  1266.         dc.l    RdUndef
  1267.         dc.l    RdUndef
  1268.         dc.l    RdUndef
  1269.         dc.l    RdUndef
  1270.         dc.l    RdUndef
  1271.         dc.l    RdUndef
  1272.         dc.l    RdUndef
  1273.         dc.l    RdUndef
  1274.         dc.l    RdUndef
  1275.         dc.l    RdUndef
  1276.         dc.l    RdUndef
  1277.         dc.l    RdUndef
  1278.         dc.l    RdUndef
  1279.         dc.l    RdUndef
  1280.  
  1281. RdNormal    lea    Registers,a0
  1282.         move.b    (a0,d0.w),d0
  1283.         rts
  1284.  
  1285. RdColor        lea    Registers,a0
  1286.         move.b    (a0,d0.w),d0        ;Bei den Farbregistern
  1287.         or.b    #$f0,d0            ;das obere Nibble setzen
  1288.         rts
  1289.  
  1290. RdUndef        move.b    #$ff,d0            ;Nicht existierendes Register
  1291.         rts
  1292.  
  1293. RdCTRL1        lea    Registers,a0
  1294.         move.b    CTRL1(a0),d0
  1295.         and.b    #$7f,d0
  1296.         move.b    CURRENTRASTER(a0),d1    ;MSB des RasterzΣhlers lesen
  1297.         and.b    #$01,d1
  1298.         ror.b    #1,d1
  1299.         or.b    d1,d0            ;und dazunehmen
  1300.         rts
  1301.  
  1302. RdRASTER    move.b    Registers+CURRENTRASTER+1,d0 ;RasterzΣhler lesen
  1303.         rts
  1304.  
  1305. RdCTRL2        move.b    Registers+CTRL2,d0
  1306.         or.b    #$c0,d0            ;Unbenutzte Bits auf 1
  1307.         rts
  1308.  
  1309. RdVBASE        move.b    Registers+VBASE,d0
  1310.         or.b    #$01,d0            ;Unbenutzte Bits auf 1
  1311.         rts
  1312.  
  1313. RdIRQFLAG    move.b    Registers+IRQFLAG,d0
  1314.         or.b    #$70,d0            ;Unbenutzte Bits auf 1
  1315.         rts
  1316.  
  1317. RdIRQMASK    move.b    Registers+IRQMASK,d0
  1318.         or.b    #$f0,d0            ;Unbenutzte Bits auf 1
  1319.         rts
  1320.  
  1321. RdCLXSPR    lea    Registers+CLXSPR,a0
  1322.         move.b    (a0),d0            ;Lesen und l÷schen
  1323.         clr.b    (a0)
  1324.         rts
  1325.  
  1326. RdCLXBGR    lea    Registers+CLXBGR,a0
  1327.         move.b    (a0),d0            ;Lesen und l÷schen
  1328.         clr.b    (a0)
  1329.         rts
  1330.  
  1331.  
  1332. **
  1333. ** In ein VIC-Register schreiben
  1334. ** d0.w: Registernummer ($00-$3f)
  1335. ** d1.b: Byte
  1336. **
  1337. ** Darf das obere Wort von d0 und d1 nicht verΣndern!
  1338. **
  1339.  
  1340. WriteTo6569    lea    Registers,a0
  1341.         move.l    WriteTab(pc,d0.w*4),a1
  1342.         jmp    (a1)
  1343.  
  1344.         CNOP    0,4
  1345. WriteTab    dc.l    WrNormal
  1346.         dc.l    WrNormal
  1347.         dc.l    WrNormal
  1348.         dc.l    WrNormal
  1349.         dc.l    WrNormal
  1350.         dc.l    WrNormal
  1351.         dc.l    WrNormal
  1352.         dc.l    WrNormal
  1353.         dc.l    WrNormal
  1354.         dc.l    WrNormal
  1355.         dc.l    WrNormal
  1356.         dc.l    WrNormal
  1357.         dc.l    WrNormal
  1358.         dc.l    WrNormal
  1359.         dc.l    WrNormal
  1360.         dc.l    WrNormal
  1361.  
  1362.         dc.l    WrNormal
  1363.         dc.l    WrCTRL1
  1364.         dc.l    WrRASTER
  1365.         dc.l    WrNormal
  1366.         dc.l    WrNormal
  1367.         dc.l    WrNormal
  1368.         dc.l    WrCTRL2
  1369.         dc.l    WrNormal
  1370.         dc.l    WrVBASE
  1371.         dc.l    WrIRQFLAG
  1372.         dc.l    WrIRQMASK
  1373.         dc.l    WrNormal
  1374.         dc.l    WrNormal
  1375.         dc.l    WrNormal
  1376.         dc.l    WrUndef
  1377.         dc.l    WrUndef
  1378.  
  1379.         dc.l    WrBorder
  1380.         dc.l    WrBack0
  1381.         dc.l    WrNormal
  1382.         dc.l    WrNormal
  1383.         dc.l    WrNormal
  1384.         dc.l    WrNormal
  1385.         dc.l    WrNormal
  1386.         dc.l    WrNormal
  1387.         dc.l    WrNormal
  1388.         dc.l    WrNormal
  1389.         dc.l    WrNormal
  1390.         dc.l    WrNormal
  1391.         dc.l    WrNormal
  1392.         dc.l    WrNormal
  1393.         dc.l    WrNormal
  1394.         dc.l    WrUndef
  1395.  
  1396.         dc.l    WrUndef
  1397.         dc.l    WrUndef
  1398.         dc.l    WrUndef
  1399.         dc.l    WrUndef
  1400.         dc.l    WrUndef
  1401.         dc.l    WrUndef
  1402.         dc.l    WrUndef
  1403.         dc.l    WrUndef
  1404.         dc.l    WrUndef
  1405.         dc.l    WrUndef
  1406.         dc.l    WrUndef
  1407.         dc.l    WrUndef
  1408.         dc.l    WrUndef
  1409.         dc.l    WrUndef
  1410.         dc.l    WrUndef
  1411.         dc.l    WrUndef
  1412.  
  1413. WrBorder    move.b    d1,(a0,d0.w)
  1414.         move.b    d1,d0        ;In ein Langwort konvertieren
  1415.         lsl.w    #8,d0
  1416.         move.b    d1,d0
  1417.         move.w    d0,d1
  1418.         swap    d0
  1419.         move.w    d1,d0
  1420.         move.l    d0,BORDERLONG(a0)
  1421.         moveq    #0,d0
  1422.         rts
  1423.  
  1424. WrBack0        move.b    d1,(a0,d0.w)
  1425.         move.b    d1,d0        ;In ein Langwort konvertieren
  1426.         lsl.w    #8,d0
  1427.         move.b    d1,d0
  1428.         move.w    d0,d1
  1429.         swap    d0
  1430.         move.w    d1,d0
  1431.         move.l    d0,BACK0LONG(a0)
  1432.         moveq    #0,d0
  1433.         rts
  1434.  
  1435. WrNormal    move.b    d1,(a0,d0.w)
  1436. WrUndef        rts
  1437.  
  1438. WrCTRL1        move.b    d1,CTRL1(a0)
  1439.         move.b    d1,d0
  1440.         and.w    #7,d0
  1441.         move.w    d0,YSCROLL(a0)
  1442.         move.b    d1,d0        ;MSB Raster
  1443.         and.b    #$80,d0
  1444.         rol.b    #1,d0
  1445.         move.b    d0,IRQRASTER(a0)
  1446.         btst    #3,d1        ;24/25 Zeilen
  1447.         beq    1$
  1448.         move.w    #Row25YStart,DYSTART(a0)
  1449.         move.w    #Row25YStop,DYSTOP(a0)
  1450.         bra    SetDispProc
  1451. 1$        move.w    #Row24YStart,DYSTART(a0)
  1452.         move.w    #Row24YStop,DYSTOP(a0)
  1453.         bra    SetDispProc
  1454.  
  1455. WrRASTER    move.b    d1,IRQRASTER+1(a0)
  1456.         rts
  1457.  
  1458. WrCTRL2        move.b    d1,CTRL2(a0)
  1459.         move.b    d1,d0
  1460.         and.w    #7,d0
  1461.         move.w    d0,XSCROLL(a0)
  1462.         btst    #3,d1        ;38/40 Zeilen
  1463.         beq    1$
  1464.         clr.b    IS38COL(a0)
  1465.         move.w    #Col40XStart,DXSTART(a0)
  1466.         move.w    #Col40XStop,DXSTOP(a0)
  1467.         bra    SetDispProc
  1468. 1$        st.b    IS38COL(a0)
  1469.         move.w    #Col38XStart,DXSTART(a0)
  1470.         move.w    #Col38XStop,DXSTOP(a0)
  1471.         bra    SetDispProc
  1472.  
  1473. SetDispProc    moveq    #0,d0        ;ECM, BMM und MCM holen
  1474.         move.b    CTRL1(a0),d0
  1475.         and.b    #$60,d0
  1476.         move.b    CTRL2(a0),d1
  1477.         and.b    #$10,d1
  1478.         or.b    d1,d0
  1479.         lsr.b    #2,d0        ;Als Index in DispProcTab benutzen
  1480.         cmp.w    #STYP_AMIGAMONO,ScreenType
  1481.         beq    1$
  1482.         move.l    (DispProcTab,pc,d0.w),DisplayProc
  1483.         rts
  1484. 1$        move.l    (MonoDispProcTab,pc,d0.w),DisplayProc
  1485.         rts
  1486.  
  1487. WrVBASE        move.l    a0,a1        ;a1: Zeiger auf Register
  1488.         move.b    d1,VBASE(a1)
  1489.  
  1490.         move.w    d1,-(sp)
  1491.         move.b    d1,d0        ;Videomatrixbasis berechnen
  1492.         and.w    #$f0,d0
  1493.         lsl.w    #6,d0
  1494.         GetPhysical
  1495.         move.l    a0,MATRIXBASE(a1)
  1496.         move.w    (sp),d1        ;Nur lesen, nicht entfernen
  1497.  
  1498.         move.b    d1,d0        ;Zeichengeneratorbasis berechnen
  1499.         and.w    #$0e,d0
  1500.         ror.w    #6,d0
  1501.         GetPhysical
  1502.         move.l    a0,CHARBASE(a1)
  1503.         move.w    (sp)+,d1
  1504.  
  1505.         move.b    d1,d0
  1506.         and.w    #$08,d0
  1507.         ror.w    #6,d0
  1508.         GetPhysical
  1509.         move.l    a0,BITMAPBASE(a1)
  1510.         rts
  1511.  
  1512. WrIRQFLAG    not.b    d1        ;Gesetztes Bit: Flag l÷schen
  1513.         and.b    #$0f,d1
  1514.         move.b    IRQFLAG(a0),d0
  1515.         and.b    d1,d0
  1516.  
  1517.         clr.b    IntIsVICIRQ    ;IRQ zurⁿcknehmen
  1518.  
  1519.         move.b    d0,d1        ;Erlaubter IRQ noch gesetzt?
  1520.         and.b    IRQMASK(a0),d1
  1521.         beq    1$
  1522.         or.b    #$80,d0        ;Ja, Master-Bit setzen
  1523. 1$        move.b    d0,IRQFLAG(a0)
  1524.         rts
  1525.  
  1526. WrIRQMASK    and.b    #$0f,d1
  1527.         move.b    d1,IRQMASK(a0)
  1528.         rts
  1529.  
  1530.  
  1531. **
  1532. ** Eine Rasterzeile des VIC ausfⁿhren
  1533. **
  1534. ** d7: RasterzeilenzΣhler
  1535. ** a4: Zeiger auf VIC-Register
  1536. ** a5: Zeiger auf das Ziel im Bildschirmspeicher
  1537. **
  1538.  
  1539. ; VBlank: ZΣhler zurⁿcksetzen und Bitmap wechseln
  1540. VICVBlank    move.w    #-1,CURRENTRASTER(a4)
  1541.         clr.w    VCBASE(a4)
  1542.  
  1543.         btst    #4,CTRL1(a4)        ;Bildschirm abschalten, wenn DEN gel÷scht
  1544.         bne    1$
  1545.         st.b    SCREENOFF(a4)
  1546.         bra    2$
  1547. 1$        clr.b    SCREENOFF(a4)
  1548. 2$
  1549.         bsr    CountTODs        ;TODs zΣhlen
  1550.  
  1551.         st.b    SKIPFRAME(a4)
  1552.         subq.w    #1,SkipCounter
  1553.         bne    3$
  1554.         move.w    SkipLatch,SkipCounter
  1555.         clr.b    SKIPFRAME(a4)
  1556.  
  1557. 3$        tst.b    SKIPFRAME(a4)
  1558.         bne    Periodic6569
  1559.         move.l    VBlankProc,a0
  1560.         jmp    (a0)
  1561.  
  1562. ; EGS: BitMap wechseln (Double Buffering)
  1563. EGSVBlank    move.w    #-1,DontPause        ;Nicht hier anhalten
  1564.         move.l    a6,-(sp)
  1565.         move.l    _EGSBase(pc),a6        ;Vorher unsichtbare Bitmap
  1566.  
  1567.         move.l    TheScreen,a0        ;darstellen
  1568.         move.l    InvisibleMap,a1
  1569.         subq.b    #1,ebm_Lock(a1)
  1570.         jsr    E_FlipMap(a6)
  1571.         move.l    d0,InvisibleMap        ;In alte Bitmap ab jetzt zeichnen
  1572.  
  1573.         move.l    d0,a0            ;Adresse ermitteln
  1574.         addq.b    #1,ebm_Lock(a0)
  1575.         move.l    ebm_Dest(a0),CURRENTA5(a4)
  1576.  
  1577.         move.l    (sp)+,a6
  1578.         clr.w    DontPause        ;Darf wieder angehalten werden
  1579.         bra    Periodic6569
  1580.  
  1581. ; Cybergraphics: Nichts
  1582. CyberVBlank    bra    Periodic6569
  1583.  
  1584. ; Amiga: Chunky-BitMap in Planar konvertieren
  1585. AmigaVBlank    move.w    #-1,DontPause        ;Nicht hier anhalten
  1586.         movem.l    a4-a6,-(sp)
  1587.  
  1588.         tst.w    MustWaitForC2P(pc)    ;Ggf. erst auf c2p4 warten
  1589.         beq    1$
  1590.         move.l    _SysBase,a6
  1591.         move.l    GfxSet,d0
  1592.         JSRLIB    Wait
  1593.  
  1594. 1$        tst.w    UsingDB            ;Double Buffering?
  1595.         beq    4$
  1596.  
  1597. 3$        move.l    _IntuitionBase,a6    ;Ja, Puffer tauschen
  1598.         lea    ScrBuf0,a1
  1599.         move.w    InvBufNum+2,d0
  1600.         move.l    (a1,d0.w*4),a1
  1601.         move.l    TheScreen,a0
  1602.         JSRLIB    ChangeScreenBuffer
  1603.         tst.l    d0
  1604.         bne    2$
  1605.         move.l    _GfxBase,a6        ;Nicht gelungen, warten
  1606.         JSRLIB    WaitTOF            ; und nochmal versuchen
  1607.         bra    3$
  1608.  
  1609. 2$        eor.w    #1,InvBufNum+2        ;Adresse des neuen Grafikspeichers holen
  1610.         move.l    InvisibleMap,a2        ;Kein DB: Neue Konvertierung starten
  1611.         lea    ComparisonBuf,a0
  1612.         move.w    InvBufNum+2,d0
  1613.         move.l    (a0,d0.w*4),a3
  1614.         lea    ScrBuf0,a0
  1615.         move.l    (a0,d0.w*4),a0
  1616.         move.l    sb_BitMap(a0),a0
  1617.         lea    bm_Planes(a0),a4
  1618.         move.l    CPUTask,a5
  1619.         move.l    GfxSet,d0
  1620.         jsr    _c2p4
  1621.  
  1622.         movem.l    (sp)+,a4-a6
  1623.         move.l    InvisibleMap,CURRENTA5(a4)
  1624.         move.w    #-1,MustWaitForC2P
  1625.         clr.w    DontPause        ;Darf wieder angehalten werden
  1626.         bra    Periodic6569
  1627.  
  1628. 4$        move.l    InvisibleMap,a2        ;Kein DB: Neue Konvertierung starten
  1629.         move.l    ComparisonBuf,a3
  1630.         move.l    TheRastPort,a4
  1631.         move.l    rp_BitMap(a4),a4
  1632.         lea    bm_Planes(a4),a4
  1633.         move.l    CPUTask,a5
  1634.         move.l    GfxSet,d0
  1635.         jsr    _c2p4
  1636.  
  1637.         movem.l    (sp)+,a4-a6
  1638.         move.l    InvisibleMap,CURRENTA5(a4)
  1639.         move.w    #-1,MustWaitForC2P
  1640.         clr.w    DontPause        ;Darf wieder angehalten werden
  1641.         bra    Periodic6569
  1642.  
  1643. ; Amiga-Mono: Double Buffering
  1644. AmigaMonoVBlank    tst.w    UsingDB(pc)        ;Double Buffering?
  1645.         beq    1$
  1646.  
  1647.         move.w    #-1,DontPause        ;Ja, Puffer tauschen
  1648.         move.l    a6,-(sp)
  1649. 3$        move.l    _IntuitionBase,a6
  1650.         lea    ScrBuf0,a1
  1651.         move.w    InvBufNum+2,d0
  1652.         move.l    (a1,d0.w*4),a1
  1653.         move.l    TheScreen,a0
  1654.         JSRLIB    ChangeScreenBuffer
  1655.         tst.l    d0
  1656.         bne    2$
  1657.         move.l    _GfxBase,a6        ;Nicht gelungen, warten
  1658.         JSRLIB    WaitTOF            ; und nochmal versuchen
  1659.         bra    3$
  1660.  
  1661. 2$        eor.w    #1,InvBufNum+2        ;Adresse des neuen Grafikspeichers holen
  1662.         lea    ScrBuf0,a0
  1663.         move.w    InvBufNum+2,d0
  1664.         move.l    (a0,d0.w*4),a0
  1665.         move.l    sb_BitMap(a0),a0
  1666.         move.l    bm_Planes(a0),CURRENTA5(a4)
  1667.  
  1668.         move.l    (sp)+,a6
  1669.         clr.w    DontPause
  1670.         bra    Periodic6569
  1671.  
  1672. 1$        move.l    InvisibleMap,CURRENTA5(a4) ;Kein DB
  1673.         bra    Periodic6569
  1674.  
  1675. ; Picasso: Double Buffering
  1676. PicassoVBlank    move.w    #-1,DontPause        ;Nicht hier anhalten
  1677.         move.l    a6,-(sp)
  1678.         move.l    _VilIntuiBase(pc),a6
  1679.  
  1680.         move.l    TheScreen,a0
  1681.         jsr    UnLockVillageScreen(a6)
  1682.  
  1683.         move.l    TheScreen,a0        ;Vorher unsichtbare Bitmap
  1684.         move.l    InvBufNum,d0        ;darstellen
  1685.         jsr    VillageSetDisplayBuf(a6)
  1686.  
  1687.         eor.l    #1,InvBufNum        ;Puffer wechseln
  1688.         move.l    TheScreen,a0
  1689.         jsr    LockVillageScreen(a6)
  1690.         move.l    TheScreen,a0        ;Adresse ermitteln
  1691.         move.l    InvBufNum,d0
  1692.         jsr    VillageGetBufAddr(a6)
  1693.         move.l    d0,CURRENTA5(a4)
  1694.  
  1695.         move.l    (sp)+,a6
  1696.         clr.w    DontPause        ;Darf wieder angehalten werden
  1697.     ;FΣllt durch!
  1698. *
  1699. * Aktuelle Rasterzeile holen
  1700. *
  1701.  
  1702. Periodic6569    lea    Registers,a4
  1703.         move.w    CURRENTRASTER(a4),d7
  1704.  
  1705. *
  1706. * RasterzΣhler erh÷hen (mu▀ hier geschehen, damit bei einem Raster-IRQ
  1707. *  der Wert des RasterzΣhlers mit der IRQ-Zeile ⁿbereinstimmt)
  1708. *
  1709.  
  1710.         addq.w    #1,d7
  1711.         move.w    d7,CURRENTRASTER(a4)
  1712.         cmp.w    #TotalRasters,d7    ;Bildende erreicht?
  1713.         beq    VICVBlank
  1714.  
  1715. *
  1716. * Raster-IRQ ausl÷sen, wenn Vergeichswert erreicht
  1717. *
  1718.  
  1719.         cmp.w    IRQRASTER(a4),d7    ;IRQ-Zeile erreicht?
  1720.         bne    NoRasterIRQ
  1721.         or.b    #$01,IRQFLAG(a4)    ;Ja, IRST-Bit setzen
  1722.         btst    #0,IRQMASK(a4)        ;Raster-IRQ erlaubt?
  1723.         beq    NoRasterIRQ
  1724.         or.b    #$80,IRQFLAG(a4)    ;Ja, IRQ-Bit setzen
  1725.         st.b    IntIsVICIRQ        ;Und Interrupt ausl÷sen
  1726. NoRasterIRQ
  1727.  
  1728. *
  1729. * Neue Anzahl CPU-Zyklen setzen
  1730. *
  1731.  
  1732.         move.w    NormalCycles,CyclesLeft
  1733.  
  1734.         tst.b    SKIPFRAME(a4)
  1735.         bne    VICSkip
  1736.  
  1737. *
  1738. * Innerhalb des sichtbaren Bereichs?
  1739. *
  1740.  
  1741.         cmp.w    #FirstDispLine,d7
  1742.         blo    VICNop
  1743.         cmp.w    #LastDispLine,d7
  1744.         bhi    VICNop
  1745.  
  1746. *
  1747. * Zeiger in Bildschirmspeicher nach a5 holen
  1748. *
  1749.  
  1750.         move.w    ScreenType,d0
  1751.         jmp    ([GetA5JmpTab,pc,d0.w*4])
  1752. GetA5JmpTab    dc.l    GetA5EGS
  1753.         dc.l    GetA5Picasso
  1754.         dc.l    GetA5Amiga
  1755.         dc.l    GetA5AmigaMono
  1756.         dc.l    GetA5Cyber
  1757.  
  1758. GetA5AmigaMono    move.l    CURRENTA5(a4),a5    ;Amiga-Mono: In die Bitplane schreiben
  1759.         bra    AmigaMono6569        ; und in spezielle VIC-Routine springen
  1760. GetA5EGS
  1761. GetA5Picasso
  1762. GetA5Cyber
  1763.         lea    LineStore,a5        ;EGS/Picasso/Cyber: In LineStore schreiben
  1764.         bra    GetA5Done
  1765. GetA5Amiga    move.l    CURRENTA5(a4),a5    ;Amiga: In die Chunky-Map schreiben
  1766. GetA5Done
  1767.  
  1768. *
  1769. * Bei abgeschaltetem Bildschirm nur Rahmen zeichnen
  1770. *
  1771.  
  1772.         tst.b    SCREENOFF(a4)
  1773.         bne    TBBorderDraw
  1774.  
  1775. *
  1776. * VC-ZΣhler setzen
  1777. *
  1778.  
  1779.         move.w    VCBASE(a4),VCCOUNT(a4)
  1780.  
  1781. *
  1782. * "Bad Lines"-Videomatrixzugriff:
  1783. * 40 Bytes aus Videomatrix und Farb-RAM lesen und zwischenspeichern
  1784. *
  1785.  
  1786.         cmp.w    #FirstDMALine,d7 ;Innerhalb des DMA-Bereiches?
  1787.         blo    NoBadLine
  1788.         cmp.w    #LastDMALine,d7
  1789.         bhi    NoBadLine
  1790.  
  1791.         move.b    d7,d0        ;Ja, stimmen die unteren Bits
  1792.         and.b    #7,d0        ;der Rasterzeile mit dem Y-Scroll
  1793.         cmp.b    YSCROLL+1(a4),d0 ;ⁿberein?
  1794.         bne    NoBadLine
  1795.  
  1796. IsBadLine    move.w    VCCOUNT(a4),d2    ;d2: VC Videomatrix-ZΣhler
  1797.  
  1798.         move.l    MATRIXBASE(a4),a0 ;Videomatrixbasis holen
  1799.         add.w    d2,a0        ;VideomatrixzΣhler dazunehmen
  1800.  
  1801.         move.l    TheColor(pc),a2    ;Zeiger auf Farb-RAM holen
  1802.         add.w    d2,a2        ;VideomatrixzΣhler dazunehmen
  1803.  
  1804.         lea    MatrixLine,a1    ;Videomatrix- und Farb-RAM-Zeile lesen
  1805.         lea    ColorLine,a3
  1806.         movem.l    (a0)+,d0-d6    ;Je 40 Bytes kopieren
  1807.         movem.l    d0-d6,(a1)
  1808.         movem.l    (a2)+,d0-d6
  1809.         movem.l    d0-d6,(a3)
  1810.         movem.l    (a0)+,d0-d2
  1811.         movem.l    d0-d2,28(a1)
  1812.         movem.l    (a2)+,d0-d2
  1813.         movem.l    d0-d2,28(a3)
  1814.  
  1815.         clr.w    RC(a4)        ;RC zurⁿcksetzen
  1816.         clr.b    DISPLAYOFF(a4)    ;Darstellung anschalten
  1817.  
  1818.         move.w    BadLineCycles,CyclesLeft ;Andere Anzahl Zyklen
  1819. NoBadLine
  1820.  
  1821. *
  1822. * Oberen und unteren Rahmen handhaben
  1823. *
  1824.  
  1825.         cmp.w    DYSTOP(a4),d7    ;Unteres Ende des Fensters erreicht
  1826.         bne    1$        ; -> Rahmen einschalten
  1827.         st.b    BORDERON(a4)
  1828.         bra    TBBorderDraw
  1829.  
  1830. 1$        cmp.w    DYSTART(a4),d7    ;Oberes Ende des Fensters erreicht
  1831.         bne    TBBorderDone    ; -> Rahmen abschalten
  1832.         clr.b    BORDERON(a4)
  1833.         bra    TBNoBorder
  1834.  
  1835. TBBorderDone    tst.b    BORDERON(a4)    ;Rahmen an?
  1836.         beq    TBNoBorder
  1837.  
  1838. TBBorderDraw    move.l    CURRENTA5(a4),a0 ;Ja, Rahmen malen. Und zwar in jedem
  1839.                     ; Fall direkt in die Bitmap schreiben
  1840.                     ; (kein Umweg ⁿber LineStore)
  1841.         move.l    BORDERLONG(a4),d0 ;d0.l: Rahmenfarbe
  1842.         move.w    #DisplayX/4-1,d1
  1843. 1$        move.l    d0,(a0)+
  1844.         dbra    d1,1$
  1845.         cmp.w    #STYP_CYBER,ScreenType
  1846.         beq    VICNextCyber
  1847.         bra    VICIncA5    ;Sonst nix
  1848. TBNoBorder
  1849.  
  1850. *
  1851. * Inhalt des Fensters: Darstellung eingeschaltet?
  1852. *
  1853.  
  1854.         lea    Col40XStart(a5),a1
  1855.         add.w    XSCROLL(a4),a1    ;a1: Ziel in Bildschirmspeicher
  1856.         lea    MatrixLine,a2    ;a2: Zeichencodes
  1857.         lea    ColorLine,a3    ;a3: Farbcodes
  1858.  
  1859.         tst.b    DISPLAYOFF(a4)    ;$3FFF darstellen?
  1860.         bne    Show3FFF
  1861.  
  1862.         move.l    DisplayProc,a0    ;Nein, Routine entsprechend
  1863.         jmp    (a0)        ;dem Darstellungsmodus anspringen
  1864.  
  1865. *
  1866. * Standard-Text: Zeichendaten holen und darstellen
  1867. *
  1868.  
  1869. TextStd        add.w    #40,VCCOUNT(a4)    ;VC erh÷hen (wird nicht verwendet)
  1870.  
  1871.         move.l    CHARBASE(a4),a0    ;a0: Zeichengeneratorbasis
  1872.         add.w    RC(a4),a0    ;RC dazunehmen
  1873.  
  1874.         move.l    BACK0LONG(a4),d3 ;d3.l: Hintergrundfarbe
  1875.  
  1876.         move.l    d3,Col40XStart(a5) ;Hintergrund, wenn X-Scroll>0
  1877.         move.l    d3,Col40XStart+4(a5)
  1878.  
  1879. ; Schleife fⁿr 40 Zeichen
  1880.         moveq    #39,d1        ;d1: ZeichenzΣhler
  1881.         moveq    #0,d0
  1882. CharLoop    move.b    (a2)+,d0    ;Zeichencode lesen
  1883.         move.b    (a0,d0.w*8),d0    ;Zeichendaten lesen
  1884.         beq    OnlyBack
  1885.         move.b    (a3)+,d2    ;d2: Zeichenfarbe
  1886.  
  1887. ; 8 Pixel konvertieren
  1888.         add.b    d0,d0
  1889.         bcc    11$
  1890.         move.b    d2,(a1)+
  1891.         bra    12$
  1892. 11$        move.b    d3,(a1)+
  1893.  
  1894. 12$        add.b    d0,d0
  1895.         bcc    21$
  1896.         move.b    d2,(a1)+
  1897.         bra    22$
  1898. 21$        move.b    d3,(a1)+
  1899.  
  1900. 22$        add.b    d0,d0
  1901.         bcc    31$
  1902.         move.b    d2,(a1)+
  1903.         bra    32$
  1904. 31$        move.b    d3,(a1)+
  1905.  
  1906. 32$        add.b    d0,d0
  1907.         bcc    41$
  1908.         move.b    d2,(a1)+
  1909.         bra    42$
  1910. 41$        move.b    d3,(a1)+
  1911.  
  1912. 42$        add.b    d0,d0
  1913.         bcc    51$
  1914.         move.b    d2,(a1)+
  1915.         bra    52$
  1916. 51$        move.b    d3,(a1)+
  1917.  
  1918. 52$        add.b    d0,d0
  1919.         bcc    61$
  1920.         move.b    d2,(a1)+
  1921.         bra    62$
  1922. 61$        move.b    d3,(a1)+
  1923.  
  1924. 62$        add.b    d0,d0
  1925.         bcc    71$
  1926.         move.b    d2,(a1)+
  1927.         bra    72$
  1928. 71$        move.b    d3,(a1)+
  1929.  
  1930. 72$        add.b    d0,d0
  1931.         bcc    81$
  1932.         move.b    d2,(a1)+
  1933.         bra    82$
  1934. 81$        move.b    d3,(a1)+
  1935.  
  1936. 82$        dbra    d1,CharLoop
  1937.         bra    DoSprites
  1938.  
  1939. ; Nur Hintergrund
  1940.         CNOP    0,4
  1941. OnlyBack    move.l    d3,(a1)+
  1942.         move.l    d3,(a1)+
  1943.         addq.w    #1,a3        ;Farb-RAM-Byte ⁿberspringen
  1944.         dbra    d1,CharLoop
  1945.         bra    DoSprites
  1946.  
  1947. *
  1948. * Multicolor-Text: Zeichendaten holen und darstellen
  1949. *
  1950.  
  1951. TextMulti    add.w    #40,VCCOUNT(a4)    ;VC erh÷hen (wird nicht verwendet)
  1952.  
  1953.         move.l    CHARBASE(a4),a0    ;a0: Zeichengeneratorbasis
  1954.         add.w    RC(a4),a0    ;RC dazunehmen
  1955.  
  1956.         move.l    BACK0LONG(a4),d3 ;d3.l: Farbe 0
  1957.  
  1958.         move.w    $22(a4),d4    ;d4.w: Farbe 1
  1959.         move.b    $22(a4),d4
  1960.  
  1961.         move.w    $23(a4),d5    ;d5.w: Farbe 2
  1962.         move.b    $23(a4),d5
  1963.  
  1964.         move.l    d3,Col40XStart(a5) ;Hintergrund, wenn X-Scroll>0
  1965.         move.l    d3,Col40XStart+4(a5)
  1966.  
  1967. ; Schleife fⁿr 40 Zeichen
  1968.         moveq    #39,d1        ;d1: ZeichenzΣhler
  1969.         moveq    #0,d0
  1970. CharMLoop    move.b    (a2)+,d0    ;Zeichencode lesen
  1971.         move.b    (a0,d0.w*8),d0    ;Zeichendaten lesen
  1972.         beq    MOnlyBack
  1973.         move.b    (a3)+,d2    ;d2: Farbnibble
  1974.         bclr    #3,d2        ;Standard oder Multi?
  1975.         beq    StdInMulti
  1976.  
  1977. ; Multicolor: 4 Pixel konvertieren
  1978.         add.b    d0,d0
  1979.         bcc    11$
  1980.         add.b    d0,d0
  1981.         bcc    12$
  1982.         move.b    d2,(a1)+    ;11
  1983.         move.b    d2,(a1)+
  1984.         bra    20$
  1985. 12$        move.w    d5,(a1)+    ;10
  1986.         bra    20$
  1987. 11$        add.b    d0,d0
  1988.         bcc    13$
  1989.         move.w    d4,(a1)+    ;01
  1990.         bra    20$
  1991. 13$        move.w    d3,(a1)+    ;00
  1992.  
  1993. 20$        add.b    d0,d0
  1994.         bcc    21$
  1995.         add.b    d0,d0
  1996.         bcc    22$
  1997.         move.b    d2,(a1)+
  1998.         move.b    d2,(a1)+
  1999.         bra    30$
  2000. 22$        move.w    d5,(a1)+
  2001.         bra    30$
  2002. 21$        add.b    d0,d0
  2003.         bcc    23$
  2004.         move.w    d4,(a1)+
  2005.         bra    30$
  2006. 23$        move.w    d3,(a1)+
  2007.  
  2008. 30$        add.b    d0,d0
  2009.         bcc    31$
  2010.         add.b    d0,d0
  2011.         bcc    32$
  2012.         move.b    d2,(a1)+
  2013.         move.b    d2,(a1)+
  2014.         bra    40$
  2015. 32$        move.w    d5,(a1)+
  2016.         bra    40$
  2017. 31$        add.b    d0,d0
  2018.         bcc    33$
  2019.         move.w    d4,(a1)+
  2020.         bra    40$
  2021. 33$        move.w    d3,(a1)+
  2022.  
  2023. 40$        add.b    d0,d0
  2024.         bcc    41$
  2025.         add.b    d0,d0
  2026.         bcc    42$
  2027.         move.b    d2,(a1)+
  2028.         move.b    d2,(a1)+
  2029.         bra    50$
  2030. 42$        move.w    d5,(a1)+
  2031.         bra    50$
  2032. 41$        add.b    d0,d0
  2033.         bcc    43$
  2034.         move.w    d4,(a1)+
  2035.         bra    50$
  2036. 43$        move.w    d3,(a1)+
  2037.  
  2038. 50$        dbra    d1,CharMLoop
  2039.         bra    DoSprites
  2040.  
  2041. ; Standard: 8 Pixel konvertieren
  2042.         CNOP    0,4
  2043. StdInMulti    add.b    d0,d0
  2044.         bcc    11$
  2045.         move.b    d2,(a1)+
  2046.         bra    12$
  2047. 11$        move.b    d3,(a1)+
  2048.  
  2049. 12$        add.b    d0,d0
  2050.         bcc    21$
  2051.         move.b    d2,(a1)+
  2052.         bra    22$
  2053. 21$        move.b    d3,(a1)+
  2054.  
  2055. 22$        add.b    d0,d0
  2056.         bcc    31$
  2057.         move.b    d2,(a1)+
  2058.         bra    32$
  2059. 31$        move.b    d3,(a1)+
  2060.  
  2061. 32$        add.b    d0,d0
  2062.         bcc    41$
  2063.         move.b    d2,(a1)+
  2064.         bra    42$
  2065. 41$        move.b    d3,(a1)+
  2066.  
  2067. 42$        add.b    d0,d0
  2068.         bcc    51$
  2069.         move.b    d2,(a1)+
  2070.         bra    52$
  2071. 51$        move.b    d3,(a1)+
  2072.  
  2073. 52$        add.b    d0,d0
  2074.         bcc    61$
  2075.         move.b    d2,(a1)+
  2076.         bra    62$
  2077. 61$        move.b    d3,(a1)+
  2078.  
  2079. 62$        add.b    d0,d0
  2080.         bcc    71$
  2081.         move.b    d2,(a1)+
  2082.         bra    72$
  2083. 71$        move.b    d3,(a1)+
  2084.  
  2085. 72$        add.b    d0,d0
  2086.         bcc    81$
  2087.         move.b    d2,(a1)+
  2088.         bra    82$
  2089. 81$        move.b    d3,(a1)+
  2090.  
  2091. 82$        dbra    d1,CharMLoop
  2092.         bra    DoSprites
  2093.  
  2094. ; Nur Hintergrund
  2095.         CNOP    0,4
  2096. MOnlyBack    move.l    d3,(a1)+
  2097.         move.l    d3,(a1)+
  2098.         addq.w    #1,a3        ;Farb-RAM-Byte ⁿberspringen
  2099.         dbra    d1,CharMLoop
  2100.         bra    DoSprites
  2101.  
  2102. *
  2103. * Extended Color Mode: Grafikdaten holen und darstellen
  2104. *
  2105.  
  2106. TextECM        add.w    #40,VCCOUNT(a4)    ;VC erh÷hen (wird nicht verwendet)
  2107.  
  2108.         move.l    CHARBASE(a4),a0    ;a0: Zeichengeneratorbasis
  2109.         add.w    RC(a4),a0    ;RC dazunehmen
  2110.  
  2111.         move.b    $21(a4),d3    ;d3: Hintergrund 0
  2112.         move.b    $22(a4),d4    ;d4: Hintergrund 1
  2113.         move.b    $23(a4),d5    ;d5: Hintergrund 2
  2114.         move.b    $24(a4),d6    ;d6: Hintergrund 3
  2115.  
  2116.         move.w    LASTBKGD(a4),d0    ;Letzter Hintergrund, wenn X-Scroll>0
  2117.         move.b    LASTBKGD(a4),d0
  2118.  
  2119.         move.w    d0,Col40XStart(a5)
  2120.         move.w    d0,Col40XStart+2(a5)
  2121.         move.w    d0,Col40XStart+4(a5)
  2122.         move.w    d0,Col40XStart+6(a5)
  2123.  
  2124. ; Schleife fⁿr 40 Zeichen
  2125.         move.w    d7,-(sp)    ;d7: Aktuelle Hintergrundfarbe
  2126.         moveq    #39,d1        ;d1: ZeichenzΣhler
  2127.         moveq    #0,d0
  2128. CharELoop    move.b    (a2)+,d0    ;Zeichencode lesen
  2129.         move.b    (a3)+,d2    ;d2: Farbnibble
  2130.         bclr    #7,d0
  2131.         bne    1$
  2132.         bclr    #6,d0
  2133.         bne    2$
  2134.         move.b    d3,d7        ;00: Hintergrund 0
  2135.         bra    4$
  2136. 2$        move.b    d4,d7        ;01: Hintergrund 1
  2137.         bra    4$
  2138. 1$        bclr    #6,d0
  2139.         bne    3$
  2140.         move.b    d5,d7        ;10: Hintergrund 2
  2141.         bra    4$
  2142. 3$        move.b    d6,d7        ;11: Hintergrund 3
  2143. 4$        move.b    (a0,d0.w*8),d0    ;Zeichendaten lesen
  2144.         beq    EOnlyBack
  2145.  
  2146. ; 8 Pixel konvertieren
  2147.         add.b    d0,d0
  2148.         bcc    11$
  2149.         move.b    d2,(a1)+
  2150.         bra    12$
  2151. 11$        move.b    d7,(a1)+
  2152.  
  2153. 12$        add.b    d0,d0
  2154.         bcc    21$
  2155.         move.b    d2,(a1)+
  2156.         bra    22$
  2157. 21$        move.b    d7,(a1)+
  2158.  
  2159. 22$        add.b    d0,d0
  2160.         bcc    31$
  2161.         move.b    d2,(a1)+
  2162.         bra    32$
  2163. 31$        move.b    d7,(a1)+
  2164.  
  2165. 32$        add.b    d0,d0
  2166.         bcc    41$
  2167.         move.b    d2,(a1)+
  2168.         bra    42$
  2169. 41$        move.b    d7,(a1)+
  2170.  
  2171. 42$        add.b    d0,d0
  2172.         bcc    51$
  2173.         move.b    d2,(a1)+
  2174.         bra    52$
  2175. 51$        move.b    d7,(a1)+
  2176.  
  2177. 52$        add.b    d0,d0
  2178.         bcc    61$
  2179.         move.b    d2,(a1)+
  2180.         bra    62$
  2181. 61$        move.b    d7,(a1)+
  2182.  
  2183. 62$        add.b    d0,d0
  2184.         bcc    71$
  2185.         move.b    d2,(a1)+
  2186.         bra    72$
  2187. 71$        move.b    d7,(a1)+
  2188.  
  2189. 72$        add.b    d0,d0
  2190.         bcc    81$
  2191.         move.b    d2,(a1)+
  2192.         bra    82$
  2193. 81$        move.b    d7,(a1)+
  2194.  
  2195. 82$        dbra    d1,CharELoop
  2196.         move.b    d7,LASTBKGD(a4)    ;Letzte Hintergrundfarbe merken
  2197.         move.w    (sp)+,d7
  2198.         bra    DoSprites
  2199.  
  2200. ; Nur Hintergrund
  2201.         CNOP    0,4
  2202. EOnlyBack    move.b    d7,(a1)+
  2203.         move.b    d7,(a1)+
  2204.         move.b    d7,(a1)+
  2205.         move.b    d7,(a1)+
  2206.         move.b    d7,(a1)+
  2207.         move.b    d7,(a1)+
  2208.         move.b    d7,(a1)+
  2209.         move.b    d7,(a1)+
  2210.         dbra    d1,CharELoop
  2211.         move.b    d7,LASTBKGD(a4)    ;Letzte Hintergrundfarbe merken
  2212.         move.w    (sp)+,d7
  2213.         bra    DoSprites
  2214.  
  2215. *
  2216. * Standard-BitMap: Grafikdaten holen und darstellen
  2217. *
  2218.  
  2219. BitMapStd    move.l    BITMAPBASE(a4),a0 ;a0: Bitmap-Basis
  2220.         move.w    VCCOUNT(a4),d0    ;VC holen
  2221.         lsl.w    #3,d0        ;*8
  2222.         add.w    RC(a4),d0    ;RC dazunehmen
  2223.         add.w    d0,a0        ;und zur Bitmap-Basis dazunehmen
  2224.  
  2225.         add.w    #40,VCCOUNT(a4)    ;VC erh÷hen
  2226.  
  2227.         move.w    LASTBKGD(a4),d0    ;Letzter Hintergrund, wenn X-Scroll>0
  2228.         move.b    LASTBKGD(a4),d0
  2229.  
  2230.         move.w    d0,Col40XStart(a5)
  2231.         move.w    d0,Col40XStart+2(a5)
  2232.         move.w    d0,Col40XStart+4(a5)
  2233.         move.w    d0,Col40XStart+6(a5)
  2234.  
  2235. ; Schleife fⁿr 40 Bytes
  2236.         moveq    #39,d1        ;d1: ZeichenzΣhler
  2237. BitMapLoop    move.b    (a2)+,d2    ;Farbe holen
  2238.         move.b    d2,d3        ;d3: Hintergrundfarbe
  2239.         move.b    (a0),d0        ;Byte holen
  2240.         beq    BOnlyBack
  2241.         lsr.b    #4,d2        ;d2: Vordergrundfarbe
  2242.  
  2243. ; 8 Pixel konvertieren
  2244.         add.b    d0,d0
  2245.         bcc    11$
  2246.         move.b    d2,(a1)+
  2247.         bra    12$
  2248. 11$        move.b    d3,(a1)+
  2249.  
  2250. 12$        add.b    d0,d0
  2251.         bcc    21$
  2252.         move.b    d2,(a1)+
  2253.         bra    22$
  2254. 21$        move.b    d3,(a1)+
  2255.  
  2256. 22$        add.b    d0,d0
  2257.         bcc    31$
  2258.         move.b    d2,(a1)+
  2259.         bra    32$
  2260. 31$        move.b    d3,(a1)+
  2261.  
  2262. 32$        add.b    d0,d0
  2263.         bcc    41$
  2264.         move.b    d2,(a1)+
  2265.         bra    42$
  2266. 41$        move.b    d3,(a1)+
  2267.  
  2268. 42$        add.b    d0,d0
  2269.         bcc    51$
  2270.         move.b    d2,(a1)+
  2271.         bra    52$
  2272. 51$        move.b    d3,(a1)+
  2273.  
  2274. 52$        add.b    d0,d0
  2275.         bcc    61$
  2276.         move.b    d2,(a1)+
  2277.         bra    62$
  2278. 61$        move.b    d3,(a1)+
  2279.  
  2280. 62$        add.b    d0,d0
  2281.         bcc    71$
  2282.         move.b    d2,(a1)+
  2283.         bra    72$
  2284. 71$        move.b    d3,(a1)+
  2285.  
  2286. 72$        add.b    d0,d0
  2287.         bcc    81$
  2288.         move.b    d2,(a1)+
  2289.         bra    82$
  2290. 81$        move.b    d3,(a1)+
  2291.  
  2292. 82$        addq.l    #8,a0        ;Quellzeiger erh÷hen
  2293.         dbra    d1,BitMapLoop
  2294.         move.b    d3,LASTBKGD(a4)    ;Letzte Hintergrundfarbe merken
  2295.         bra    DoSprites
  2296.  
  2297. ; Nur Hintergrund
  2298.         CNOP    0,4
  2299. BOnlyBack    move.b    d3,(a1)+
  2300.         move.b    d3,(a1)+
  2301.         move.b    d3,(a1)+
  2302.         move.b    d3,(a1)+
  2303.         move.b    d3,(a1)+
  2304.         move.b    d3,(a1)+
  2305.         move.b    d3,(a1)+
  2306.         move.b    d3,(a1)+
  2307.         addq.l    #8,a0        ;Quellzeiger erh÷hen
  2308.         dbra    d1,BitMapLoop
  2309.         move.b    d3,LASTBKGD(a4)    ;Letzte Hintergrundfarbe merken
  2310.         bra    DoSprites
  2311.  
  2312. *
  2313. * Multicolor-Bitmap: Grafikdaten holen und darstellen
  2314. *
  2315.  
  2316. BitMapMulti    move.l    BITMAPBASE(a4),a0 ;a0: Bitmap-Basis
  2317.         move.w    VCCOUNT(a4),d0    ;VC holen
  2318.         lsl.w    #3,d0        ;*8
  2319.         add.w    RC(a4),d0    ;RC dazunehmen
  2320.         add.w    d0,a0        ;und zur Bitmap-Basis dazunehmen
  2321.  
  2322.         add.w    #40,VCCOUNT(a4)    ;VC erh÷hen
  2323.  
  2324.         move.l    BACK0LONG(a4),d5 ;d5.w: Farbe 0
  2325.  
  2326.         move.l    d5,Col40XStart(a5) ;Hintergrund, wenn X-Scroll>0
  2327.         move.l    d5,Col40XStart+4(a5)
  2328.  
  2329. ; Schleife fⁿr 40 Bytes
  2330.         moveq    #39,d1
  2331. BitMapMLoop    move.b    (a2)+,d2    ;Farbe 1/2 holen
  2332.         move.b    (a0),d0        ;Byte holen
  2333.         beq    BMOnlyBack
  2334.         move.b    d2,d3        ;d3.b: Farbe 2
  2335.         lsr.b    #4,d2        ;d2.b: Farbe 1
  2336.         move.b    (a3)+,d4    ;d4.b: Farbe 3
  2337.  
  2338. ; 4 Pixel konvertieren
  2339.         add.b    d0,d0
  2340.         bcc    11$
  2341.         add.b    d0,d0
  2342.         bcc    12$
  2343.         move.b    d4,(a1)+    ;11
  2344.         move.b    d4,(a1)+
  2345.         bra    20$
  2346. 12$        move.b    d3,(a1)+    ;10
  2347.         move.b    d3,(a1)+
  2348.         bra    20$
  2349. 11$        add.b    d0,d0
  2350.         bcc    13$
  2351.         move.b    d2,(a1)+    ;01
  2352.         move.b    d2,(a1)+
  2353.         bra    20$
  2354. 13$        move.w    d5,(a1)+    ;00
  2355.  
  2356. 20$        add.b    d0,d0
  2357.         bcc    21$
  2358.         add.b    d0,d0
  2359.         bcc    22$
  2360.         move.b    d4,(a1)+
  2361.         move.b    d4,(a1)+
  2362.         bra    30$
  2363. 22$        move.b    d3,(a1)+
  2364.         move.b    d3,(a1)+
  2365.         bra    30$
  2366. 21$        add.b    d0,d0
  2367.         bcc    23$
  2368.         move.b    d2,(a1)+
  2369.         move.b    d2,(a1)+
  2370.         bra    30$
  2371. 23$        move.w    d5,(a1)+
  2372.  
  2373. 30$        add.b    d0,d0
  2374.         bcc    31$
  2375.         add.b    d0,d0
  2376.         bcc    32$
  2377.         move.b    d4,(a1)+
  2378.         move.b    d4,(a1)+
  2379.         bra    40$
  2380. 32$        move.b    d3,(a1)+
  2381.         move.b    d3,(a1)+
  2382.         bra    40$
  2383. 31$        add.b    d0,d0
  2384.         bcc    33$
  2385.         move.b    d2,(a1)+
  2386.         move.b    d2,(a1)+
  2387.         bra    40$
  2388. 33$        move.w    d5,(a1)+
  2389.  
  2390. 40$        add.b    d0,d0
  2391.         bcc    41$
  2392.         add.b    d0,d0
  2393.         bcc    42$
  2394.         move.b    d4,(a1)+
  2395.         move.b    d4,(a1)+
  2396.         bra    50$
  2397. 42$        move.b    d3,(a1)+
  2398.         move.b    d3,(a1)+
  2399.         bra    50$
  2400. 41$        add.b    d0,d0
  2401.         bcc    43$
  2402.         move.b    d2,(a1)+
  2403.         move.b    d2,(a1)+
  2404.         bra    50$
  2405. 43$        move.w    d5,(a1)+
  2406.  
  2407. 50$        addq.l    #8,a0        ;Quellzeiger erh÷hen
  2408.         dbra    d1,BitMapMLoop
  2409.         bra    DoSprites
  2410.  
  2411. ; Nur Hintergrund
  2412.         CNOP    0,4
  2413. BMOnlyBack    move.l    d5,(a1)+
  2414.         move.l    d5,(a1)+
  2415.         addq.w    #1,a3        ;Farb-RAM-Byte ⁿberspringen
  2416.         addq.l    #8,a0        ;Quellzeiger erh÷hen
  2417.         dbra    d1,BitMapMLoop
  2418.         bra    DoSprites
  2419.  
  2420. *
  2421. * Ungⁿltiger Darstellungsmodus: Schwarzen Bildschirm anzeigen
  2422. *
  2423.  
  2424. BlackScreen    add.w    #40,VCCOUNT(a4)    ;VC erh÷hen
  2425.  
  2426.         moveq    #39,d0        ;40 Zeichen schwarz
  2427. 1$        clr.l    (a1)+
  2428.         clr.l    (a1)+
  2429.         dbra    d0,1$
  2430.         bra    DoSprites
  2431.  
  2432. *
  2433. * $3FFF darstellen
  2434. *
  2435.  
  2436. Show3FFF    move.l    BACK0LONG(a4),d3 ;d3.w: Hintergrundfarbe
  2437.  
  2438.         move.l    d3,Col40XStart(a5) ;Hintergrund, wenn X-Scroll>0
  2439.         move.l    d3,Col40XStart+4(a5)
  2440.  
  2441.         btst    #6,CTRL1(a4)
  2442.         bne    11$
  2443.         move.w    #$3fff,d0    ;Byte bei $3FFF lesen
  2444.         bra    12$
  2445. 11$        move.w    #$39ff,d0    ;ECM: Byte bei $39FF lesen
  2446. 12$        GetPhysical
  2447.         move.b    (a0),d0        ;Byte lesen
  2448.  
  2449. ; 4 Pixel nach d1 konvertieren, 0: Hintergrund, 1: schwarz
  2450.         moveq    #0,d1
  2451.         add.b    d0,d0
  2452.         bcs    1$
  2453.         move.b    d3,d1
  2454. 1$        lsl.w    #8,d1
  2455.         add.b    d0,d0
  2456.         bcs    2$
  2457.         move.b    d3,d1
  2458. 2$        lsl.l    #8,d1
  2459.         add.b    d0,d0
  2460.         bcs    3$
  2461.         move.b    d3,d1
  2462. 3$        lsl.l    #8,d1
  2463.         add.b    d0,d0
  2464.         bcs    4$
  2465.         move.b    d3,d1
  2466. 4$
  2467.  
  2468. ; 4 Pixel nach d2 konvertieren
  2469.         moveq    #0,d2
  2470.         add.b    d0,d0
  2471.         bcs    5$
  2472.         move.b    d3,d2
  2473. 5$        lsl.w    #8,d2
  2474.         add.b    d0,d0
  2475.         bcs    6$
  2476.         move.b    d3,d2
  2477. 6$        lsl.l    #8,d2
  2478.         add.b    d0,d0
  2479.         bcs    7$
  2480.         move.b    d3,d2
  2481. 7$        lsl.l    #8,d2
  2482.         add.b    d0,d0
  2483.         bcs    8$
  2484.         move.b    d3,d2
  2485. 8$
  2486.  
  2487. ; Zeile schreiben
  2488.         moveq    #39,d0        ;d0: BytezΣhler
  2489. Loop3FFF    move.l    d1,(a1)+
  2490.         move.l    d2,(a1)+
  2491.         dbra    d0,Loop3FFF
  2492.  
  2493. *
  2494. * Sprites malen?
  2495. *
  2496.  
  2497. DoSprites    tst.b    SPRITEON(a4)    ;Ist ⁿberhaupt ein Sprite z.Z. sichtbar?
  2498.         bne    DrawTheSprites    ;Ja, dann Sprites malen
  2499.  
  2500. *
  2501. * Linken und rechten Rahmen zeichnen
  2502. *
  2503.  
  2504. ; 40-Spalten-Rahmen
  2505. DrawLRBorder    move.l    a5,a0
  2506.         move.l    BORDERLONG(a4),d0 ;d0.l: Rahmenfarbe
  2507.  
  2508.         move.l    d0,(a0)+    ;Links: $00..$17
  2509.         move.l    d0,(a0)+
  2510.         move.l    d0,(a0)+
  2511.         move.l    d0,(a0)+
  2512.         move.l    d0,(a0)+
  2513.         move.l    d0,(a0)+
  2514.  
  2515.         lea    Col40XStop-Col40XStart(a0),a0
  2516.         move.l    d0,(a0)+    ;Rechts: $158..$16f
  2517.         move.l    d0,(a0)+
  2518.         move.l    d0,(a0)+
  2519.         move.l    d0,(a0)+
  2520.         move.l    d0,(a0)+
  2521.         move.l    d0,(a0)
  2522.  
  2523. ; 38-Spalten-Rahmen nach (a5) (Puffer oder Bitmap)
  2524.         tst.b    IS38COL(a4)
  2525.         beq    1$
  2526.  
  2527.         lea    Col40XStart(a5),a0
  2528.         move.l    d0,(a0)+    ;Links: $18..$1e
  2529.         move.w    d0,(a0)+
  2530.         move.b    d0,(a0)
  2531.  
  2532.         lea    Col38XStop(a5),a0
  2533.         move.b    d0,(a0)+    ;Rechts: $14f..$157
  2534.         move.l    d0,(a0)+
  2535.         move.l    d0,(a0)+
  2536. 1$
  2537.  
  2538. *
  2539. * Ende einer sichtbaren Zeile: Bei EGS/Picasso Zeile in die Karte schreiben
  2540. * Es wird nur der Bereich zwischen Col40XStart und Col40XStop geschrieben,
  2541. * der Rest ist immer Rahmen und der wird in DrawLRBorder direkt in die
  2542. * Bitmap geschrieben.
  2543. *
  2544.  
  2545. VICNext        cmp.w    #STYP_AMIGA,ScreenType
  2546.         beq    VICIncA5
  2547.         cmp.w    #STYP_CYBER,ScreenType
  2548.         beq    VICNextCyber
  2549.         move.l    CURRENTA5(a4),a1
  2550.         lea    LineStore,a0
  2551.         moveq    #DisplayX/4-1,d0
  2552. 1$        move.l    (a0)+,(a1)+
  2553.         dbra    d0,1$
  2554.         bra    VICIncA5
  2555.  
  2556. VICNextCyber    move.l    a6,-(sp)
  2557.         move.l    _CyberGfxBase,a6
  2558.         lea    CyberHook,a0
  2559.         move.l    TheRastPort,a1
  2560.         sub.l    a2,a2
  2561.         jsr    DoCDrawMethod(a6)
  2562.         move.l    (sp)+,a6
  2563.         bra    VICIncRC    ;a5 nicht erh÷hen (zeigt auf LineStore)!
  2564.  
  2565. CyberHookProc    move.l    (a1),a0        ;a0: Adresse des Bildschirmspeichers
  2566.         moveq    #0,d0
  2567.         move.w    ScreenX,d0
  2568.         move.w    Registers+CURRENTRASTER,d1
  2569.         sub.w    #FirstDispLine,d1
  2570.         mulu.w    d1,d0
  2571.         add.l    d0,a0
  2572.         lea    LineStore,a1
  2573.         moveq    #DisplayX/4-1,d0
  2574. 1$        move.l    (a1)+,(a0)+
  2575.         dbra    d0,1$
  2576.         rts
  2577.  
  2578. *
  2579. * Bild wird ⁿbersprungen, nur Bad-Line-Zyklen berechnen
  2580. *
  2581.  
  2582. VICSkip        cmp.w    #FirstDMALine,d7 ;Innerhalb des DMA-Bereiches?
  2583.         blo    VICNop
  2584.         cmp.w    #LastDMALine,d7
  2585.         bhi    VICNop
  2586.  
  2587.         move.b    d7,d0        ;Ja, stimmen die unteren Bits
  2588.         and.b    #7,d0        ;der Rasterzeile mit dem Y-Scroll
  2589.         cmp.b    YSCROLL+1(a4),d0 ;ⁿberein?
  2590.         bne    VICNop
  2591.  
  2592.         move.w    BadLineCycles,CyclesLeft
  2593.         bra    VICNop
  2594.  
  2595. *
  2596. * Zeiger in Bitmap erh÷hen
  2597. *
  2598.  
  2599. VICIncA5    moveq    #0,d0
  2600.         move.w    ScreenX,d0
  2601.         add.l    d0,CURRENTA5(a4)
  2602.  
  2603. *
  2604. * RC erh÷hen, Darstellung abschalten, wenn gleich 7
  2605. * (braucht nur im sichtbaren Bereich zu geschehen)
  2606. *
  2607.  
  2608. VICIncRC    cmp.w    #7,RC(a4)
  2609.         beq    1$
  2610.         addq.w    #1,RC(a4)
  2611.         bra    2$
  2612. 1$        st.b    DISPLAYOFF(a4)
  2613.         move.w    VCCOUNT(a4),VCBASE(a4)
  2614. 2$
  2615.  
  2616. *
  2617. * MCs erh÷hen (mu▀ in jeder Rasterzeile geschehen, damit die Sprites
  2618. *  auch im Overscan-Bereich korrekt dargestellt werden)
  2619. *
  2620.  
  2621. ; Wenn alle Sprites aus sind, direkt zu CIA-Periodic springen
  2622. VICNop        lea    SPRITEON(a4),a3
  2623.         move.b    (a3),d0
  2624.         or.b    SPREN(a4),d0
  2625.         beq    Periodic6526
  2626.  
  2627. ; MC fⁿr jedes Sprite zΣhlen (7..0)
  2628.         moveq    #7,d6        ;d6: Spritenummer
  2629.         lea    M7Y(a4),a1    ;a1: Zeiger auf erste Y-Koordinate
  2630.         lea    MC7(a4),a2    ;a2: Zeiger auf MC
  2631.  
  2632. MCLoop        move.b    (a1),d0        ;Y-Koordinate
  2633.         btst    d6,SPREN(a4)    ;Sprite angeschaltet?
  2634.         bne    1$
  2635. 3$        cmp.w    #60,(a2)    ;Nein, MC kleiner als 60?
  2636.         blo    2$
  2637.         bclr    d6,(a3)        ;Nein, Sprite nicht mehr darstellen
  2638.         bra    5$
  2639.  
  2640. 1$        cmp.b    d0,d7        ;Sprite angeschaltet, Y-Koord. mit
  2641.         bne    3$
  2642.         clr.w    (a2)        ;Gleich, MC zurⁿcksetzen
  2643.         bset    d6,(a3)        ;Und Sprite ab jetzt darstellen
  2644.         bra    5$
  2645.  
  2646. 2$        btst    d6,MYE(a4)    ;MC kleiner als 60, Sprite Y-expandiert?
  2647.         beq    4$
  2648.         eor.b    d7,d0        ;Ja, nur erh÷hen, wenn Bit 0
  2649.         and.b    #$01,d0        ; der Y-Koordinate gleich Bit 0
  2650.         bne    5$        ; des RasterzΣhlers ist
  2651. 4$        addq.w    #3,(a2)        ;MC erh÷hen
  2652.         subq.w    #2,CyclesLeft    ;2 Zyklen vom 6510 abziehen
  2653.  
  2654. 5$        subq.w    #2,a1        ;Zeiger auf Y-Koordinate erh÷hen
  2655.         subq.w    #2,a2        ;Zeiger auf MC erh÷hen
  2656.         dbra    d6,MCLoop
  2657.  
  2658. ; Zu CIA-Periodic springen
  2659.         bra    Periodic6526
  2660.  
  2661. *
  2662. * Mindestens ein Sprite ist sichtbar, Sprites malen
  2663. *
  2664.  
  2665. ; Kollisions-Puffer l÷schen
  2666. DrawTheSprites    tst.w    Collisions
  2667.         beq    7$
  2668.         lea    SprCollBuf,a0
  2669.         moveq    #DisplayX/4-1,d0
  2670. 6$        clr.l    (a0)+
  2671.         dbra    d0,6$
  2672. 7$
  2673.  
  2674. ; Multicolor-Farben laden
  2675.         move.w    $25(a4),d3    ;d3.l: Multicolor #0
  2676.         move.b    $25(a4),d3
  2677.         move.w    d3,d0
  2678.         swap    d3
  2679.         move.w    d0,d3
  2680.  
  2681.         move.w    $26(a4),d4    ;d4.l: Multicolor #1
  2682.         move.b    $26(a4),d4
  2683.         move.w    d4,d0
  2684.         swap    d4
  2685.         move.w    d0,d4
  2686.  
  2687. ; Sprites malen
  2688.         move.l    d7,-(sp)
  2689.         DoSprite 7
  2690.         DoSprite 6
  2691.         DoSprite 5
  2692.         DoSprite 4
  2693.         DoSprite 3
  2694.         DoSprite 2
  2695.         DoSprite 1
  2696.         DoSprite 0
  2697.         move.l    (sp)+,d7
  2698.  
  2699. ; Kollisions-Puffer auswerten
  2700.         tst.w    Collisions
  2701.         beq    DrawLRBorder
  2702.  
  2703.         lea    SprCollBuf,a0
  2704.         lea    SprCollTab,a1
  2705.         moveq    #0,d0
  2706.         move.w    #DisplayX-1,d2
  2707. 1$        move.b    (a0)+,d0    ;Byte aus Puffer holen
  2708.         beq    5$
  2709.         tst.b    (a1,d0.w)    ;Entspricht die Bitkombination einer
  2710.         bne    2$        ; Kollision?
  2711. 5$        dbra    d2,1$        ;Nein, weitertesten
  2712.         bra    DrawLRBorder
  2713.  
  2714. 2$        move.b    CLXSPR(a4),d1    ;Ja, Kollision erkannt
  2715.         or.b    d0,CLXSPR(a4)    ;Bits im Kollisionsregister setzen
  2716.         tst.b    d1        ;Wenn bereits Kollisionen stattgefunden
  2717.         bne    3$        ; haben, keinen IRQ mehr ausl÷sen
  2718.         or.b    #$04,IRQFLAG(a4) ;IMMC-Bit setzen
  2719.         btst    #2,IRQMASK(a4)    ;IRQ erlaubt?
  2720.         beq    3$
  2721.         or.b    #$80,IRQFLAG(a4) ;Ja, IRQ-Bit setzen
  2722.         st.b    IntIsVICIRQ    ;Und Interrupt ausl÷sen
  2723. 3$        dbra    d2,1$
  2724.         bra    DrawLRBorder
  2725.  
  2726.  
  2727. **
  2728. ** Ein Sprite zeichnen
  2729. ** d2.w: Spritefarbe
  2730. ** d3.l: Multicolor #0
  2731. ** d4.l: Multicolor #1
  2732. ** d5.w: MC
  2733. ** d6.l: Spritenummer (0..7)
  2734. ** d7.b: Spritedatenzeiger
  2735. ** a2  : Zeiger auf X-Koordinate
  2736. **
  2737.  
  2738.         CNOP    0,4
  2739. DrawSprite    moveq    #0,d0        ;Ja, Basisadresse berechnen
  2740.         move.b    d7,d0        ;Spritedatenzeiger
  2741.         lsl.w    #6,d0
  2742.         add.w    d5,d0        ;MC dazunehmen
  2743.         GetPhysical        ;a0: Spritedaten
  2744.  
  2745.         moveq    #0,d5        ;X-Position zusammenbauen
  2746.         move.b    (a2),d5
  2747.         btst    d6,MX8(a4)
  2748.         beq    1$
  2749.         or.w    #$0100,d5    ;d5: Sprite-X-Position
  2750. 1$
  2751.         move.l    a5,a1        ;(lea ist langsamer)
  2752.         add.w    d5,a1        ;a1: Ziel in Bildschirmspeicher
  2753.         lea    SprCollBuf,a2
  2754.         add.w    d5,a2        ;a2: Ziel im Kollisionspuffer
  2755.  
  2756.         btst    d6,MMC(a4)    ;Multicolor?
  2757.         bne    SprMulti
  2758.  
  2759.         btst    d6,MXE(a4)    ;Nein, X-expandiert?
  2760.         bne    SprStdExp
  2761.  
  2762. ; Standard-Sprite: 3 Byte mit je 8 Pixeln konvertieren
  2763.         cmp.w    #DisplayX-24,d5    ;Sprite horizontal sichtbar?
  2764.         bhs    SpriteDone
  2765.  
  2766.         moveq    #0,d5
  2767.         bset    d6,d5        ;d5: Bitmaske fⁿr Kollisionspuffer
  2768.  
  2769.         moveq    #2,d1        ;BytezΣhler
  2770. SprLoop        move.b    (a0)+,d0    ;Byte lesen
  2771.         beq    18$        ;Null: Nichts darstellen
  2772.  
  2773.         add.b    d0,d0
  2774.         bcc    11$
  2775.         move.b    d2,(a1)
  2776.         or.b    d5,(a2)
  2777.  
  2778. 11$        add.b    d0,d0
  2779.         bcc    12$
  2780.         move.b    d2,1(a1)
  2781.         or.b    d5,1(a2)
  2782.  
  2783. 12$        add.b    d0,d0
  2784.         bcc    13$
  2785.         move.b    d2,2(a1)
  2786.         or.b    d5,2(a2)
  2787.  
  2788. 13$        add.b    d0,d0
  2789.         bcc    14$
  2790.         move.b    d2,3(a1)
  2791.         or.b    d5,3(a2)
  2792.  
  2793. 14$        add.b    d0,d0
  2794.         bcc    15$
  2795.         move.b    d2,4(a1)
  2796.         or.b    d5,4(a2)
  2797.  
  2798. 15$        add.b    d0,d0
  2799.         bcc    16$
  2800.         move.b    d2,5(a1)
  2801.         or.b    d5,5(a2)
  2802.  
  2803. 16$        add.b    d0,d0
  2804.         bcc    17$
  2805.         move.b    d2,6(a1)
  2806.         or.b    d5,6(a2)
  2807.  
  2808. 17$        add.b    d0,d0
  2809.         bcc    18$
  2810.         move.b    d2,7(a1)
  2811.         or.b    d5,7(a2)
  2812.  
  2813. 18$        addq.w    #8,a1
  2814.         addq.w    #8,a2
  2815.         dbra    d1,SprLoop
  2816. SpriteDone    rts
  2817.  
  2818. ; X-expandiertes Standard-Sprite: 3 Byte mit je 8 Pixeln konvertieren
  2819. SprStdExp    cmp.w    #DisplayX-48,d5    ;Sprite sichtbar?
  2820.         bhs    SpriteDone
  2821.  
  2822.         moveq    #0,d5
  2823.         bset    d6,d5
  2824.         lsl.w    #8,d5
  2825.         bset    d6,d5        ;d5: Bitmaske fⁿr Kollisionspuffer
  2826.  
  2827.         moveq    #2,d1        ;BytezΣhler
  2828. SprELoop    move.b    (a0)+,d0    ;Byte lesen
  2829.         beq    18$        ;Null: Nichts darstellen
  2830.  
  2831.         add.b    d0,d0
  2832.         bcc    11$
  2833.         move.w    d2,(a1)
  2834.         or.w    d5,(a2)
  2835.  
  2836. 11$        add.b    d0,d0
  2837.         bcc    12$
  2838.         move.w    d2,2(a1)
  2839.         or.w    d5,2(a2)
  2840.  
  2841. 12$        add.b    d0,d0
  2842.         bcc    13$
  2843.         move.w    d2,4(a1)
  2844.         or.w    d5,4(a2)
  2845.  
  2846. 13$        add.b    d0,d0
  2847.         bcc    14$
  2848.         move.w    d2,6(a1)
  2849.         or.w    d5,6(a2)
  2850.  
  2851. 14$        add.b    d0,d0
  2852.         bcc    15$
  2853.         move.w    d2,8(a1)
  2854.         or.w    d5,8(a2)
  2855.  
  2856. 15$        add.b    d0,d0
  2857.         bcc    16$
  2858.         move.w    d2,10(a1)
  2859.         or.w    d5,10(a2)
  2860.  
  2861. 16$        add.b    d0,d0
  2862.         bcc    17$
  2863.         move.w    d2,12(a1)
  2864.         or.w    d5,12(a2)
  2865.  
  2866. 17$        add.b    d0,d0
  2867.         bcc    18$
  2868.         move.w    d2,14(a1)
  2869.         or.w    d5,14(a2)
  2870.  
  2871. 18$        lea    16(a1),a1
  2872.         lea    16(a2),a2
  2873.         dbra    d1,SprELoop
  2874.         rts
  2875.  
  2876. ; Multicolor-Sprite: 3 Byte mit je 4 Pixeln konvertieren
  2877. SprMulti    btst    d6,MXE(a4)    ;X-expandiert?
  2878.         bne    SprMultiExp
  2879.  
  2880.         moveq    #0,d5
  2881.         bset    d6,d5
  2882.         lsl.w    #8,d5
  2883.         bset    d6,d5        ;d5: Bitmaske fⁿr Kollisionspuffer
  2884.  
  2885.         moveq    #2,d1        ;BytezΣhler
  2886. SprMLoop    move.b    (a0)+,d0    ;Byte lesen
  2887.         beq    50$        ;Null: Nichts darstellen
  2888.  
  2889.         add.b    d0,d0
  2890.         bcc    11$
  2891.         or.w    d5,(a2)
  2892.         add.b    d0,d0
  2893.         bcc    12$
  2894.         move.w    d4,(a1)        ;11
  2895.         bra    20$
  2896. 12$        move.w    d2,(a1)        ;10
  2897.         bra    20$
  2898. 11$        add.b    d0,d0
  2899.         bcc    20$
  2900.         move.w    d3,(a1)        ;01
  2901.         or.w    d5,(a2)
  2902.  
  2903. 20$        add.b    d0,d0
  2904.         bcc    21$
  2905.         or.w    d5,2(a2)
  2906.         add.b    d0,d0
  2907.         bcc    22$
  2908.         move.w    d4,2(a1)
  2909.         bra    30$
  2910. 22$        move.w    d2,2(a1)
  2911.         bra    30$
  2912. 21$        add.b    d0,d0
  2913.         bcc    30$
  2914.         move.w    d3,2(a1)
  2915.         or.w    d5,2(a2)
  2916.  
  2917. 30$        add.b    d0,d0
  2918.         bcc    31$
  2919.         or.w    d5,4(a2)
  2920.         add.b    d0,d0
  2921.         bcc    32$
  2922.         move.w    d4,4(a1)
  2923.         bra    40$
  2924. 32$        move.w    d2,4(a1)
  2925.         bra    40$
  2926. 31$        add.b    d0,d0
  2927.         bcc    40$
  2928.         move.w    d3,4(a1)
  2929.         or.w    d5,4(a2)
  2930.  
  2931. 40$        add.b    d0,d0
  2932.         bcc    41$
  2933.         or.w    d5,6(a2)
  2934.         add.b    d0,d0
  2935.         bcc    42$
  2936.         move.w    d4,6(a1)
  2937.         bra    50$
  2938. 42$        move.w    d2,6(a1)
  2939.         bra    50$
  2940. 41$        add.b    d0,d0
  2941.         bcc    50$
  2942.         move.w    d3,6(a1)
  2943.         or.w    d5,6(a2)
  2944.  
  2945. 50$        addq.l    #8,a1
  2946.         addq.l    #8,a2
  2947.         dbra    d1,SprMLoop
  2948. SpriteDone1    rts
  2949.  
  2950. ; X-expandiertes Multicolor-Sprite: 3 Byte mit je 4 Pixeln konvertieren
  2951. SprMultiExp    cmp.w    #DisplayX-48,d5    ;Sprite sichtbar?
  2952.         bhs    SpriteDone1
  2953.  
  2954.         moveq    #0,d5
  2955.         bset    d6,d5
  2956.         lsl.w    #8,d5
  2957.         bset    d6,d5
  2958.         move.w    d5,d0
  2959.         swap    d5
  2960.         move.w    d0,d5        ;d5: Bitmaske fⁿr Kollisionspuffer
  2961.  
  2962.         move.w    d2,d0        ;d2 auf Langwort erweitern
  2963.         swap    d2
  2964.         move.w    d0,d2
  2965.  
  2966.         moveq    #2,d1
  2967. SprMELoop    move.b    (a0)+,d0    ;Byte lesen
  2968.         beq    50$        ;Null: Nichts darstellen
  2969.  
  2970.         add.b    d0,d0
  2971.         bcc    11$
  2972.         or.l    d5,(a2)
  2973.         add.b    d0,d0
  2974.         bcc    12$
  2975.         move.l    d4,(a1)        ;11
  2976.         bra    20$
  2977. 12$        move.l    d2,(a1)        ;10
  2978.         bra    20$
  2979. 11$        add.b    d0,d0
  2980.         bcc    20$
  2981.         move.l    d3,(a1)        ;01
  2982.         or.l    d5,(a2)
  2983.  
  2984. 20$        add.b    d0,d0
  2985.         bcc    21$
  2986.         or.l    d5,4(a2)
  2987.         add.b    d0,d0
  2988.         bcc    22$
  2989.         move.l    d4,4(a1)
  2990.         bra    30$
  2991. 22$        move.l    d2,4(a1)
  2992.         bra    30$
  2993. 21$        add.b    d0,d0
  2994.         bcc    30$
  2995.         move.l    d3,4(a1)
  2996.         or.l    d5,4(a2)
  2997.  
  2998. 30$        add.b    d0,d0
  2999.         bcc    31$
  3000.         or.l    d5,8(a2)
  3001.         add.b    d0,d0
  3002.         bcc    32$
  3003.         move.l    d4,8(a1)
  3004.         bra    40$
  3005. 32$        move.l    d2,8(a1)
  3006.         bra    40$
  3007. 31$        add.b    d0,d0
  3008.         bcc    40$
  3009.         move.l    d3,8(a1)
  3010.         or.l    d5,8(a2)
  3011.  
  3012. 40$        add.b    d0,d0
  3013.         bcc    41$
  3014.         or.l    d5,12(a2)
  3015.         add.b    d0,d0
  3016.         bcc    42$
  3017.         move.l    d4,12(a1)
  3018.         bra    50$
  3019. 42$        move.l    d2,12(a1)
  3020.         bra    50$
  3021. 41$        add.b    d0,d0
  3022.         bcc    50$
  3023.         move.l    d3,12(a1)
  3024.         or.l    d5,12(a2)
  3025.  
  3026. 50$        lea    16(a1),a1
  3027.         lea    16(a2),a2
  3028.         dbra    d1,SprMELoop
  3029.         rts
  3030.  
  3031.  
  3032. **
  3033. ** Amiga-Mono-Routinen einbinden
  3034. **
  3035.  
  3036.         INCLUDE    "6569mono.i"
  3037.  
  3038.  
  3039. **
  3040. ** Konstanten
  3041. **
  3042.  
  3043. ; Strings
  3044. EGSName        dc.b    "egs.library",0
  3045. VilIntuiName    dc.b    "vilintuisup.library",0
  3046. CyberGfxName    dc.b    "cybergraphics.library",0
  3047.  
  3048. ; Farbpalette
  3049.         CNOP    0,4
  3050. Palette        dc.b    0,0,0,0        ;Schwarz
  3051.         dc.b    255,255,255,0    ;Wei▀
  3052.         dc.b    204,0,0,0    ;Rot
  3053.         dc.b    0,255,204,0    ;Cyan
  3054.         dc.b    255,0,255,0    ;Magenta
  3055.         dc.b    0,204,0,0    ;Grⁿn
  3056.         dc.b    0,0,204,0    ;Blau
  3057.         dc.b    255,255,0,0    ;Gelb
  3058.         dc.b    255,128,0,0    ;Orange
  3059.         dc.b    128,64,0,0    ;Braun
  3060.         dc.b    255,128,128,0    ;Hellrot
  3061.         dc.b    64,64,64,0    ;Dunkelgrau
  3062.         dc.b    128,128,128,0    ;Mittelgrau
  3063.         dc.b    128,255,128,0    ;Hellgrⁿn
  3064.         dc.b    128,128,255,0    ;Hellblau
  3065.         dc.b    192,192,192,0    ;Hellgrau
  3066.  
  3067. ; Tabelle der Display-Routinen (jeweils fⁿr Farbe und Monochrom)
  3068. DispProcTab    dc.l    TextStd
  3069.         dc.l    TextMulti
  3070.         dc.l    BitMapStd
  3071.         dc.l    BitMapMulti
  3072.         dc.l    TextECM
  3073.         dc.l    BlackScreen
  3074.         dc.l    BlackScreen
  3075.         dc.l    BlackScreen
  3076.  
  3077. MonoDispProcTab    dc.l    FTextStd
  3078.         dc.l    FTextStd
  3079.         dc.l    FBitMapStd
  3080.         dc.l    FBitMapStd
  3081.         dc.l    FTextStd
  3082.         dc.l    FBlackScreen
  3083.         dc.l    FBlackScreen
  3084.         dc.l    FBlackScreen
  3085.  
  3086.  
  3087. **
  3088. ** Datenbereich
  3089. **
  3090.  
  3091. ; Taglist fⁿr den Screen (Amiga)
  3092. ScreenTags    dc.l    SA_DisplayID
  3093. ScreenDID    dc.l    0
  3094.         dc.l    SA_Width,$180    ;Vielfaches von 32
  3095.         dc.l    SA_Height,DisplayY
  3096.         dc.l    SA_Depth,4
  3097.         dc.l    SA_Quiet,-1
  3098.         dc.l    SA_AutoScroll,-1
  3099.         dc.l    SA_Overscan
  3100. ScreenOScan    dc.l    0
  3101.         dc.l    0,0
  3102.  
  3103. ; Taglist fⁿr den Screen (Amiga-Mono)
  3104. MonoScreenTags    dc.l    SA_DisplayID
  3105. MonoScreenDID    dc.l    0
  3106.         dc.l    SA_Width,$180
  3107.         dc.l    SA_Height,DisplayY
  3108.         dc.l    SA_Depth,1
  3109.         dc.l    SA_Quiet,-1
  3110.         dc.l    SA_AutoScroll,-1
  3111.         dc.l    SA_Overscan
  3112. MonoScreenOScan    dc.l    0
  3113.         dc.l    0,0
  3114.  
  3115. ; Taglist fⁿr den Screen (Cyber)
  3116. CyberScreenTags    dc.l    SA_DisplayID
  3117. CyberScreenDID    dc.l    0
  3118.         dc.l    SA_Width
  3119. CyberScreenX    dc.l    0
  3120.         dc.l    SA_Height
  3121. CyberScreenY    dc.l    0
  3122.         dc.l    SA_Depth,8
  3123.         dc.l    SA_Quiet,-1
  3124.         dc.l    0,0
  3125.  
  3126. ; Taglist fⁿr das Fenster (Picasso/Amiga/Cyber)
  3127. WindowTags    dc.l    WA_Left,0
  3128.         dc.l    WA_Top,0
  3129.         dc.l    WA_Width
  3130. WindowWidth    dc.l    0
  3131.         dc.l    WA_Height
  3132. WindowHeight    dc.l    0
  3133.         dc.l    WA_NoCareRefresh,-1
  3134.         dc.l    WA_Borderless,-1
  3135.         dc.l    WA_Activate,-1
  3136.         dc.l    WA_RMBTrap,-1
  3137.         dc.l    WA_CustomScreen
  3138. WindowScreen    dc.l    0
  3139.         dc.l    WA_IDCMP,IDCMP_MOUSEBUTTONS|IDCMP_RAWKEY
  3140.         dc.l    0,0
  3141.  
  3142. ; Struktur fⁿr E_OpenScreen (EGS)
  3143. NewEScreen    dc.l    ModeNameBuf+16
  3144.         dc.w    8,0    ;Tiefe 8
  3145.         dc.l    0
  3146.         dc.l    0
  3147.         dc.l    0
  3148.         dc.l    0
  3149.         dc.l    E_eMOUSEBUTTONS|E_eRAWKEY
  3150.         dc.l    0
  3151.  
  3152. ; Taglist fⁿr den Screen (Picasso)
  3153. VilTags        dc.l    TAVIS_DM_STRUCT,Dimensions
  3154.         dc.l    TAVIS_DOUBLE_BUFFER,-1
  3155.         dc.l    0,0
  3156.  
  3157. ; VilIntuiSup-Dimensions (Picasso)
  3158. Dimensions    dc.w    0,0,0,0,8,0    ;8: Tiefe
  3159.  
  3160. ; Hook fⁿr Cybergraphics
  3161. CyberHook    dc.l    0,0
  3162.         dc.l    CyberHookProc
  3163.         dc.l    0
  3164.         dc.l    0
  3165.  
  3166. ; Variablen
  3167.         CNOP    0,4
  3168. DisplayID    dc.l    0    ;Prefs: DisplayID des Screens
  3169. TheScreen    dc.l    0    ;Screen
  3170. TheWindow    dc.l    0    ;Window (Picasso/Amiga/Cyber)
  3171. EGSPort        dc.l    0    ;EDCMP-Port (EGS)
  3172. WindowPort    dc.l    0    ;IDCMP-Port (Amiga/Picasso/Cyber)
  3173. TheRastPort    dc.l    0    ;RastPort (Amiga/Cyber)
  3174. TheViewPort    dc.l    0    ;ViewPort (Amiga/Picasso/Cyber)
  3175. VBlankProc    dc.l    0    ;Zeiger auf VBlank-Routine
  3176. DisplayProc    dc.l    0    ;Zeiger auf die Display-Routine (Text/Bitmap etc.)
  3177.  
  3178. InvisibleMap    dc.l    0    ;Zeiger auf unsichtbare BitMap (EGS)
  3179.                 ;Zeiger auf Chunky-Map (Amiga)
  3180.                 ;Zeiger auf Bitplane (AmigaMono ohne DB)
  3181. InvBufNum    dc.l    0    ;Nummer des unsichtbaren Puffers (Amiga/Picasso)
  3182. ScrBuf0        dc.l    0    ;Screen Buffer 0 (Amiga) - Mu▀ zusammen bleiben!
  3183. ScrBuf1        dc.l    0    ;Screen Buffer 1 (Amiga) /
  3184.  
  3185. ComparisonBuf    dc.l    0    ;Puffer fⁿr c2p4 - Mu▀ zusammen bleiben!
  3186. ComparisonBuf1    dc.l    0    ;Zweiter Puffer  /
  3187. GfxSet        dc.l    0    ;Signal fⁿr c2p4
  3188. GfxSig        dc.w    0
  3189.  
  3190. ScreenType    dc.w    0    ;Prefs: Typ der Screen-Ansteuerung
  3191. NormalCycles    dc.w    0    ;Prefs: Anzahl 6510-Zyklen pro Rasterzeile
  3192. BadLineCycles    dc.w    0    ;Prefs: Anzahl 6510-Zyklen in einer Bad Line
  3193. Collisions    dc.w    0    ;Prefs: Sprite-Kollisionen angeschaltet
  3194. Overscan    dc.w    0    ;Prefs: Overscan-Typ fⁿr Amiga-Modi
  3195.  
  3196. CiaVABase    dc.w    0    ;16-Bit Basisadresse durch Cia-VA14/15
  3197. ScreenX        dc.w    0    ;Ausma▀e des Screens
  3198. ScreenY        dc.w    0
  3199. MustWaitForC2P    dc.w    0    ;Es mu▀ auf das Signal von c2p gewartet werden
  3200. UsingDB        dc.w    0    ;Flag: AmigaMono benutzt Double Buffering
  3201.  
  3202. SkipCounter    dc.w    1
  3203. SkipLatch    dc.w    0    ;Prefs: Nur jedes nte Bild darstellen
  3204.  
  3205.         CNOP    0,4
  3206. Registers    ds.b    128    ;VIC-Register
  3207. MatrixLine    ds.b    40    ;Eine Bildschirmzeile
  3208. ColorLine    ds.b    40    ;Eine Farb-RAM-Zeile
  3209.  
  3210. **
  3211. ** Nicht initialisierte Daten
  3212. **
  3213.  
  3214.         SECTION    "BSS",BSS
  3215. LineStore    ds.b    DisplayX    ;Puffer fⁿr eine Zeile
  3216. SprCollBuf    ds.b    DisplayX    ;Puffer fⁿr Sprite-Kollisionen
  3217.  
  3218. SprCollTab    ds.b    256        ;Welche Bitkombinationen l÷sen eine Kollision aus?
  3219.  
  3220. ModeNameBuf    ds.b    nif_SIZEOF    ;Puffer fⁿr GetDisplayInfoData
  3221. TheRect        ds.b    ra_SIZEOF    ;Puffer fⁿr QueryOverscan
  3222.         END
  3223.