home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Emulatoren / FRODO24.LZX / Frodo / Src / 6569.asm < prev    next >
Encoding:
Assembly Source File  |  1997-01-03  |  57.8 KB  |  3,047 lines

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