head     56.3;
access   ;
symbols  ;
locks    ; strict;
comment  @# @;


56.3
date     93.01.27.13.37.06;  author jwh;  state Exp;
branches ;
next     56.2;

56.2
date     93.01.27.12.12.41;  author jwh;  state Exp;
branches ;
next     56.1;

56.1
date     91.11.05.09.42.37;  author jwh;  state Exp;
branches ;
next     55.8;

55.8
date     91.11.04.15.54.27;  author jwh;  state Exp;
branches ;
next     55.7;

55.7
date     91.10.27.14.42.25;  author cfb;  state Exp;
branches ;
next     55.6;

55.6
date     91.10.27.10.43.28;  author cfb;  state Exp;
branches ;
next     55.5;

55.5
date     91.09.26.12.38.09;  author cfb;  state Exp;
branches ;
next     55.4;

55.4
date     91.09.10.17.14.39;  author cfb;  state Exp;
branches ;
next     55.3;

55.3
date     91.09.09.17.40.57;  author cfb;  state Exp;
branches ;
next     55.2;

55.2
date     91.08.27.09.17.26;  author cfb;  state Exp;
branches ;
next     55.1;

55.1
date     91.08.25.10.20.52;  author jwh;  state Exp;
branches ;
next     1.9;

1.9
date     91.08.21.13.31.40;  author jwh;  state Exp;
branches ;
next     1.8;

1.8
date     91.08.12.16.31.19;  author cfb;  state Exp;
branches ;
next     1.7;

1.7
date     91.08.12.13.28.04;  author cfb;  state Exp;
branches ;
next     1.6;

1.6
date     91.07.26.12.32.16;  author cfb;  state Exp;
branches ;
next     1.5;

1.5
date     91.07.25.15.20.22;  author cfb;  state Exp;
branches ;
next     1.4;

1.4
date     91.07.24.13.50.26;  author cfb;  state Exp;
branches ;
next     1.3;

1.3
date     91.07.23.14.17.03;  author cfb;  state Exp;
branches ;
next     1.2;

1.2
date     91.06.17.09.15.00;  author cfb;  state Exp;
branches ;
next     1.1;

1.1
date     91.06.14.11.26.41;  author cfb;  state Exp;
branches ;
next     ;


desc
@checking in FASSM (part of CRTF) for the first time
@


56.3
log
@
pws2rcs automatic delta on Wed Jan 27 13:14:25 MST 1993
@
text
@	     page
*
*   WOODCUT family bit-mapped alpha driver
*
*     Pascal 3.25 version by C. Brett
*
*       In most routines registers are used as follows:
*               a0      CRT control space base address
*               a1      scratch
*               a2      scratch
*               a3      CRT information base address
*               a4      scratch
*               a5      Global Base used by PAWS
*               a6      Stack Frame Pointer used by PAWS
*               a7      stack pointer SP (don't modify)
*
*               d0      scratch
*               d1      scratch
*               d2      scratch
*               d3      scratch
*               d4      scratch
*               d5      scratch
*               d6      scratch
*               d7      scratch



		def     cscrollup,cscrolldown,cupdatecursor,cchar,cclear
		def     cbuildtable,cshiftleft,cshiftright
		def     cexchange,cscrollwindow,cursoroff
		def     cscrollwinddn,cdbscrolll,cdbscrollr,cclearall
		def     csetcolormap,csetreg,csavewoodenv,crestorewoodenv
		def     cromshort,csetupcchar,cprepdumpline

		def     setupcchar

		rorg.l 0

		refa    woodcutdvr,sysdevs
		refa    misc_lockup,misc_lockdown

		nosyms
		sprint
crtinfo         equ     woodcutdvr-4
cpl             equ     crtinfo-2
cppl            equ     cpl-2
fb_fontchars    equ     cppl-2
maxy            equ     fb_fontchars-2
xcurs           equ     maxy-2
ycurs           equ     xcurs-2
hascolor        equ     ycurs-1
midres          equ     hascolor-1
screenwidth     equ     midres-2
screenheight    equ     screenwidth-2
maxx            equ     screenheight-2
screensize      equ     maxx-2
defaulthighlight equ    screensize-2

controladdr     equ     sysdevs-86
screen          equ     sysdevs-90

* OFFSETS FOR CRTPARAMS

fbwidth         equ     0
fbheight        equ     2+fbwidth
dispx           equ     2+fbheight
dispy           equ     2+dispx
dispw           equ     2+dispy
disph           equ     2+dispw
printx          equ     2+disph
printy          equ     2+printx
printw          equ     2+printy
printh          equ     2+printw
offx            equ     2+printh
offy            equ     2+offx
offw            equ     2+offy
offh            equ     2+offw
charw           equ     2+offh
charh           equ     2+charw
fb_fontstartx   equ     2+charh
fb_fontstarty   equ     2+fb_fontstartx
fb_font_line_len equ    2+fb_fontstarty
fb_fontlines    equ     2+fb_font_line_len
nfontchars      equ     2+fb_fontlines
fb_cursorx      equ     4+nfontchars
fb_cursory      equ     2+fb_cursorx
set_colormap_proc equ   2+fb_cursory
planemask       equ     8+set_colormap_proc
alphacolor      equ     4+planemask
cursorcolor     equ     2+alphacolor
highlight       equ     2+cursorcolor
creplrule0      equ     2+highlight
creplrule1      equ     1+creplrule0
cursreplrule0   equ     1+creplrule1
cursreplrule1   equ     1+cursreplrule0

flags           equ     1+cursreplrule1
togglealpha     equ     7       bit number
togglegraphics  equ     6       bit number
copy_under_cursor equ   5       bit number
use_fib_xy      equ     4       bit number
disable_low_ctl equ     3       bit number
disable_hi_ctl  equ     2       bit number
copy_to_abuf    equ     1       bit number
*pad            equ     0       bit number


*       WOODCUT REGISTER OFFSETS (ADD TO CONTROL BASE ADDRESS)

dio2base        equ     $01000000 -$01FFFFFF    16 Meg (DIO-II Select Code 132)
sgcbase         equ     $02000000 -$02FFFFFF    32 Meg

stirom          equ     $00000000
ashregs         equ     $00040000 -$0004FFFF
refreshrate     equ     $00050000       refresh rate select (60Hz or 72Hz)
alphaplane      equ     $00050004       not used
vramcolor1      equ     $00060000       colormask used for rows 0-511
dacregs         equ     $00060200
vramcolor2      equ     $00060400       colormask used for rows 512-1023
beechregs       equ     $00060600
*                       $00060800 -$001FFFFF    unused
framebuffer     equ     $00200000 -$003FFFFF
*                       $00400000 -$005FFFFF    unused
*cachedfb       equ     $00600000 -$007FFFFF    unused - HPUX caches this space
*                       $00800000 -$00FFFFFF    unused

* ASH registers

visiblemask     equ     $00040000 -$00040FFF    bits 19-16 only
colormask       equ     $00041000 -$00041FFF    bits 19-16 only
cursorcontrol0  equ     $00042000
cursorcontrol1  equ     $00042004

cursoronmask    equ     $fffb           1111 1111 1111 1011 (and in)
cursoroffmask   equ     $0004           0000 0000 0000 0100 (or in)
cursorbusy      equ     3               0000 0000 0000 1000 (bit to test)

* BEECH registers

byteshift       equ     $00060600
blankandtest    equ     $00060604
blockmode       equ     $00060608
pagemode        equ     $0006060c
blueregimage    equ     $00060610
blueregcursor   equ     $00060614
maskreg         equ     $00060618
cursorposition  equ     $0006061c
timingh0        equ     $00060620
timingh1        equ     $00060624
timingv0        equ     $00060628
timingv1        equ     $0006062c
testvideo       equ     $00060630
testcursorup    equ     $00060634
testcursorsh    equ     $00060638
testvideocount  equ     $0006063c

* common DAC registers

dacimagewrite   equ     $00060202
colormapvalue   equ     $00060206

* low/medium resolution DAC registers on bt474

pixelreadmask   equ     $0006020a
dacimageread    equ     $0006020e
dacoverlaywrite equ     $00060212
dacoverlayregs  equ     $00060216
*                       $0006021a       reserved
dacoverlayread  equ     $0006021e
daccommandreg0  equ     $00060222
daccommandreg1  equ     $00060226
dacidreg        equ     $0006022a       value should be $11 for WOODCUT family
dacstatusreg    equ     $0006022e

* high resolution DAC registers on bt458

overlaycolor1   equ     2
overlaycolor2   equ     3
readmask        equ     4
blinkmask       equ     5
commandreg      equ     6
cntlstatreg     equ     7
hrdacoverlaywrite equ   $0006020e


* GRAPHICS ROM OFFSETS

framewidth      equ     $00000005       width of frame buffer
frameheight     equ     $00000009       height of frame buffer
displaywidth    equ     $0000000D       width of displayed frame buffer
displayheight   equ     $00000011       height of displayed frame buffer
displayid       equ     $00000015       secondary ID byte
initoffset      equ     $00000023       offset to initialization offset
fontoffset      equ     $0000003B       offset to font info offset
framecount      equ     $0000005B       number of frames
frameoffset     equ     $0000005D       offset to frame buffer

width           equ     2048            width is always 2048 on WOODCUT
widthdiv16      equ     128             pixels / 16 for block mode

* BOOT ROM ADDRESSES

sysflag2        equ     $FFFFFEDA

* USEFUL CONSTANTS

*                                       kludge because MOVE16 is 16 byte aligned
*                                       and we don't know where zero16 will be
		dc.l    0,0,0,0         16 bytes of zeros
zero16          dc.l    0,0,0,0         16 bytes of zeros
		dc.l    0,0,0,0         16 bytes of zeros

currentintlevel ds.l    1               current interrupt level
hires           ds.l    1               hires flag (0 med or low, 1 high)

fontstorage     ds.b    15360           ((256 + 128) * 16 * 20) / 8

*
*******************************************************************
*
*               misc utilities for initialization
*               uses register a1 contrary to intro comments
*

loadcmap        lea     cmaptable,a1          initialize the color map
		tst.b   hascolor(a5)          color?
		bne     cmapstart             yes, jump over greyscale
		lea     gmaptable,a1          initialize the greyscale color map
cmapstart       moveq   #0,d1                 clear some registers
		move.l  d1,d2
		move.l  d1,d3
		move.l  d1,d4
cmaploop1       move.b  (a1)+,d2              get rgb values in d2-d4
		move.b  (a1)+,d3
		move.b  (a1)+,d4
		jsr     cmapenter             call the color map entry routine
		addq    #1,d1                 bump cmap pointer value
		cmp     #16,d1                have we done 16 yet?
		bne.s   cmaploop1             if not then continue
		moveq   #-1,d2                set entries 16-255 to white
		move.l  d2,d3
		move.l  d2,d4
cmaploop2       jsr     cmapenter
		addq    #1,d1
		cmp     #256,d1                 done with cmap init?
		bne.s   cmaploop2

		move.l  #blueregcursor,d6
		move.l  #colormapvalue,d7
		move.l  #dacoverlaywrite,d5

cursorcmapwait  btst    #0,1(a0,d6.l)           check for color map busy
		bne.s   cursorcmapwait          loop till bit is clear
		move.b  #2,0(a0,d5.l)           write the index to the DAC
		move.b  #0,0(a0,d7.l)           then red to the DAC
		move.b  #0,0(a0,d7.l)           then green to the DAC
		move.b  #0,3(a0,d6.l)           then blue to BEECH

cursorcmapwait2 btst    #0,1(a0,d6.l)           check for color map busy
		bne.s   cursorcmapwait2         loop till bit is clear
		move.b  #3,0(a0,d5.l)           write the index to the DAC
		move.b  #255,0(a0,d7.l)         then red to the DAC
		move.b  #255,0(a0,d7.l)         then green to the DAC
		move.b  #255,3(a0,d6.l)         then blue to BEECH
		rts

cmapenter       move.l  #blueregimage,d6
		move.l  #dacimagewrite,d5
		move.l  #colormapvalue,d7

cmapwait        btst    #0,1(a0,d6.l)           check for color map busy
		bne.s   cmapwait                loop till bit is clear
		move.b  d1,0(a0,d5.l)           write the index to the DAC
		move.b  d2,0(a0,d7.l)           then red to the DAC
		move.b  d3,0(a0,d7.l)           then green to the DAC
		move.b  d4,3(a0,d6.l)           then blue to BEECH

		rts                             done with cmap entry write

*
*************************************************************************
*
*               font unpacking routines (unpacking moved to cchar)
*               a2 points to font ROM
*               a3 points to crtinfo
*               a4 points to font storage
*               d3 number of characters
*

unpkroman       equ     *
		moveq   #0,d0
		move.l  d0,d1

		move    charw(a3),d0
		move    charh(a3),d1
		addq    #7,d0                   round off to the nearest byte
		andi.b  #$f8,d0                 to fix HIRES       24OCT91 - CFB
		mulu    d0,d1                   number of pixels/char
		lsr     #3,d1                   number of bytes/char
		subq    #1,d1                   subtract 1 to make loop correct

unpackchar      move.l  d1,d5                   unpack d1 bytes/char
unpackrow       move.b  (a2),(a4)+              copy over byte
		addq.l  #2,a2                   look at next font byte
		dbra    d5,unpackrow            and loop till bytes in char done
		dbra    d3,unpackchar           loop till all chars done

		rts


*
*************************************************************************
*
*               ginit routines
*

ginitblock      moveq    #0,d1              clear some regs
		moveq    #0,d0
		move.b   2(a1),d0           get word count to initialize
		movep    4(a1),d1           form destination offset
		add.l    a0,d1              d1 points to dest addr
		lea      8(a1),a2           a2 points to first data byte
		movea.l  d1,a4              a4 points to destination
		btst     #0,(a1)            is this a bit test block?
		bne.s    ginitbtst          if so go handle it
ginitloop       movep    0(a2),d1           form a data word in d1
		move.w   d1,(a4)+           move data to the destination addr
		btst     #6,(a1)            increment data pointer
		bne.s    ginit1             based on control byte
		addq     #4,a2
ginit1          dbra     d0,ginitloop       loop till word count exhausted
		btst     #7,(a1)            was this last block?
		bne.s    ginitdone          yes -- go return
		btst     #6,(a1)            adjust data pointer
		beq.s    ginit2             to point to next init block
ginit3          addq     #4,a2
ginit2          movea.l  a2,a1              a1 points to new init block
		bra      ginitblock         do the initialize

ginitbtst       moveq    #0,d2              handle bit test blocks here
		move.b   2(a2),d2           d2 = bit # to test
ginittst2       move     (a4),d3            d3 = data word to test
		btst     #0,(a2)            check for sense of test
		bne.s    ginittst3          comp if waiting for 0
		not      d3
ginittst3       btst     d2,d3              check the bit
		beq      ginittst2          if not 1 then loop
		btst     #7,(a1)            was this last block?
		bne.s   ginitdone          if so then return
		bra      ginit3             else do next block

ginitdone       rts

*
*************************************************************************
*
*               variable initialization and font table building routines
*

cbuildtable     movea.l controladdr(a5),a0      get pointer to ROM start
		movea.l crtinfo(a5),a3          crtparamrec
		movep   initoffset(a0),d1       form pointer to init block
		movea.l a0,a1                   make copy of ROM start addr
		adda.l  d1,a1                   a1 points to init info now
		jsr     ginitblock              call the initialization routine
		clr.b   hascolor(a5)            clear color flag
		cmpi.b  #17,displayid(a0)       greyscale?
		bgt     cframeaddr              yes, don't set color
		st      hascolor(a5)            set for color
cframeaddr      movea.l a0,a1                   make copy of ROM start addr
		adda.l  #framebuffer,a1         add offset to frame buffer
		move.l  a1,screen(a5)           form frame buffer addr

		move.b  framecount(a0),d0       d0=# of planes in system
		beq.s   cnumplanes              if zero then read planes
		moveq   #8,d1                   else make the mask up
		moveq   #$ff,d2
		sub     d0,d1                   d1 has shift count
		lsr.b   d1,d2                   after shift d2 has mask
		bra.s   csetplanes              go setup planemask

cnumplanes      moveq   #0,d2                   determine how many planes
		movea.l screen(a5),a1           addr of fb in a1
		move.b  #$FF,(a1)               write all 1's
		move.b  (a1),d2                 read it back to get plane mask
csetplanes      move.l  #0,planemask(a3)        clear full 32 bits
		move.b  d2,3+planemask(a3)      save as plane mask

cnocolor2       moveq   #0,d0
		move.l  d0,hires                clear hires flag
		move    d0,dispx(a3)            set positions to (0,0)
		move    d0,dispy(a3)
		move    d0,printx(a3)
		move    d0,printy(a3)
		movep.w framewidth(a0),d2       get width from ROM
		move    d2,fbwidth(a3)
		movep.w displaywidth(a0),d2    set visible width as window width
		movep.w frameheight(a0),d2      get height from ROM
		move    d2,fbheight(a3)
		movep.w displayheight(a0),d2
		move    d2,disph(a3)
		movep.w displaywidth(a0),d2
		move    d2,dispw(a3)
		move    d2,printw(a3)
		cmp     #1024,d2
		beq.s   setuplcc
		cmp     #640,d2                 no offscreen available
		beq.s   setupvga

setuphrx        equ     *                       offscreen available to right
		move    #1280,offx(a3)
		move    #0,offy(a3)
		move    #768,offw(a3)
		move    #1024,offh(a3)
		st      hires                   set hires flag
		bra.s   donesetupoff

setuplcc        equ     *                       no offscreen available
		move    #0,offx(a3)
		move    #0,offy(a3)
		move    #0,offw(a3)
		move    #0,offh(a3)
		bra.s   donesetupoff

setupvga        equ     *                       offscreen available to right
		move    #640,offx(a3)           and at the bottom. right larger
		move    #0,offy(a3)
		move    #384,offw(a3)
		move    #512,offh(a3)

donesetupoff    equ     *
		jsr     loadcmap                load the color map

		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d7

		movep   fontoffset(a0),d1       get font info offset
		move.b  (a0,d1.w),d7            d3 = number of fonts
		subq    #1,d7                   subtract 1 to make loop correct
		lea     4(a0,d1.w),a1           a1 = address of font offset
		lea     (fontstorage),a4        a4 = address of font storage

getfontinfo     movep   0(a1),d2                d2 = offset to font info
		lea     0(a0,d2.l),a2           a2 = address of font info

		moveq   #0,d1                   clear d1 for re-use
		move.b  (a2),d0                 d0 = font height
		move.b  2(a2),d1                d1 = font width
		move    d0,charh(a3)            store them for later use
		move    d1,charw(a3)

		moveq   #0,d3
		move.b  8(a2),d3                get last char value
		sub.b   6(a2),d3                subtract first char value
*                                               d3 = number of chars in font

		adda.l  #10,a2                  a2 now points to first char
		jsr     unpkroman               go unpack it

		adda.l  #6,a1                   a1 = address of next font
		dbra    d7,getfontinfo

buildcursor     equ     *
		jsr     cursoroff

		move.l  #cursorcontrol1,d2

		move.l  #colormask,d0           write to the cursor image
		move.l  #1023,d1                clear the entire cursor

buildcursorclr  btst    #cursorbusy,1(a0,d2.l)  wait until the cursor not busy
		bne.s   buildcursorclr
		move    #0,0(a0,d0.l)
		addq.l  #4,d0
		dbra    d1,buildcursorclr

		move.l  #colormask,d0           create cursor image
		moveq   #1,d4                   2 rows

buildcursorclr3 moveq   #1,d3                   2 nybbles wide
		move.l  d0,d1                   beginning of row
buildcursorclr2 btst    #cursorbusy,1(a0,d2.l)  wait until the cursor not busy
		bne.s   buildcursorclr2
		move    #-1,0(a0,d1.l)
		addq.l  #4,d1                   next 4 pixels
		dbra    d3,buildcursorclr2
		tst     hires
		beq     buildcursorclr1
		move    #$000c,0(a0,d1.l)
buildcursorclr1 addi.l  #64,d0                  next row
		dbra    d4,buildcursorclr3

		move.l  #visiblemask,d0         write to the cursor mask
		move.l  #1023,d1                clear the entire mask

buildcursorvis  btst    #cursorbusy,1(a0,d2.l)  wait until the cursor not busy
		bne.s   buildcursorvis
		move    #0,0(a0,d0.l)
		addq.l  #4,d0
		dbra    d1,buildcursorvis

		move.l  #visiblemask,d0         create "cookie cutter"
		moveq   #1,d4                   2 rows

buildcursorvis3 moveq   #1,d3                   8 nybbles wide
		move.l  d0,d1                   beginning of row
buildcursorvis2 btst    #cursorbusy,1(a0,d2.l)  wait until the cursor not busy
		bne.s   buildcursorvis2
		move    #-1,0(a0,d1.l)
		addq.l  #4,d1                   next 4 pixels
		dbra    d3,buildcursorvis2
		tst     hires
		beq     buildcursorvis1
		move    #$000c,0(a0,d1.l)
buildcursorvis1 addi.l  #64,d0                  next row
		dbra    d4,buildcursorvis3

		move.l  #cursorcontrol0,d0
		move.l  #0,0(a0,d0.l)           clear y-clip LSB's

		move.l  #cursorcontrol1,d0
		andi    #$000c0,0(a0,d0.l)      clear y-clip MSB's

		jsr     cursoron

		move.l  #readmask,d2
		move.b  #255,0(a0,d2)           turn on all planes

		rts

*
****************************************************************
*
*

cmaptable       equ     *               initial color map contents (r,g,b)
		dc.b    0,0,0                   0
		dc.b    255,255,255             1
		dc.b    255,0,0                 2
		dc.b    255,255,0               3
		dc.b    0,255,0                 4
		dc.b    0,255,255               5
		dc.b    0,0,255                 6
		dc.b    255,0,255               7
		dc.b    0,0,0                   8
		dc.b    204,187,51              9
		dc.b    51,170,119              10
		dc.b    136,102,170             11
		dc.b    204,68,102              12
		dc.b    255,102,51              13
		dc.b    255,119,0               14
		dc.b    221,136,68              15

gmaptable       equ     *           initial greyscale color map contents (r,g,b)
		dc.b    0,0,0                   0
		dc.b    0,255,0                 1
		dc.b    0,239,0                 2
		dc.b    0,233,0                 3
		dc.b    0,207,0                 4
		dc.b    0,191,0                 5
		dc.b    0,175,0                 6
		dc.b    0,159,0                 7
		dc.b    0,143,0                 8
		dc.b    0,128,0                 9
		dc.b    0,112,0                10
		dc.b    0,96,0                 11
		dc.b    0,80,0                 12
		dc.b    0,64,0                 13
		dc.b    0,48,0                 14
		dc.b    0,32,0                 15
		dc.b    0,16,0                 16

*
*               end of misc utilities
****************************************************************
*
*               procedure cscrollup
*               scroll up one line
*

cscrollup       movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0

		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3

		move    printy(a3),d0
		move    printh(a3),d1           set up window size
		sub     charh(a3),d1            one less row
		sub     d0,d1                   d1 = number of rows
		subq    #1,d1                   subtract 1 to make loop correct

		mulu    #width,d0               d0 = address of first row

		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d0,a1                   a1 = destination row

		move    charh(a3),d3
		mulu    #width,d3               number of rows per line height

		move    printw(a3),d2
		lsr     #2,d2                   number of longs per line

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

		move.l  #pagemode,d7            turn on page mode
		move.l  #0,0(a0,d7.l)

		btst    #3,sysflag2             test for 68040 to use move16
		bne     cscroll68030

*                   68040 section

		lsr     #2,d2                   number of move16's
		subq    #1,d2                   subtract 1 to make loop correct

cscrollnextrow  move.l  d2,d4                   reset column counter
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		adda.l  d3,a4                   set up source address

cscrollnextword move16  (a4)+,(a2)+             move from one line to the other
		dbra    d4,cscrollnextword      and loop

		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollnextrow       and loop again

		move    charh(a3),d1            set up to clear next line
		subq    #1,d1

cscrollclrrow   move.l  d2,d4                   reset column counter
		movea.l a1,a2

cscrollclrword  move16  zero16,(a2)+            clear line
		dbra    d4,cscrollclrword       and loop

		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollclrrow        and loop again

		bra     cscrollpageoff

*                   68030 section

cscroll68030    subq    #1,d2                   subtract 1 to make loop correct

cscrollnextrow2 move.l  d2,d4                   reset column counter
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		adda.l  d3,a4                   set up source address

cscrollnextword2 move.l  (a4)+,(a2)+            move from one line to the other
		dbra    d4,cscrollnextword2     and loop

		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollnextrow2      and loop again

		move    charh(a3),d1            set up to clear next line
		subq    #1,d1

cscrollclrrow2  move.l  d2,d4                   reset column counter
		movea.l a1,a2

cscrollclrword2 move.l  #0,(a2)+                clear line
		dbra    d4,cscrollclrword2      and loop

		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollclrrow2       and loop again

cscrollpageoff  move.l  #pagemode,d7            turn off page mode
		move.l  #1,0(a0,d7.l)

		jsr     misc_lockdown           enable STOP key

		rts

*
****************************************************************
*
*               procedure cscrolldown
*               scroll down one line
*

cscrolldown     movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0

		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3

		move    printh(a3),d0           get last row
		sub     charh(a3),d0            start one line height up
		move    d0,d1                   set up window size
		sub     printy(a3),d1           d1 = number of rows
		subq    #1,d1                   subtract 1 to make loop correct

		mulu    #width,d0               d0 = address of last row

		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d0,a1                   a1 = source row

		move    charh(a3),d3
		mulu    #width,d3               number of rows per line height

		move    printw(a3),d2
		lsr     #2,d2                   number of longs per line

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

		move.l  #pagemode,d7            turn on page mode
		move.l  #0,0(a0,d7.l)

		btst    #3,sysflag2             test for 68040 to use move16
		bne     cscrolld68030

*                   68040 section

		lsr     #2,d2                   number of move16's
		subq    #1,d2

cscrolldnextrow move.l  d2,d4                   reset column counter
		movea.l a1,a2
		movea.l a1,a4
		adda.l  d3,a4                   set up source address

cscrolldnextword move16 (a2)+,(a4)+             move from one line to the other
		dbra    d4,cscrolldnextword     and loop

		suba.l  #width,a1               decrement row by width
		dbra    d1,cscrolldnextrow      and loop again

		move    charh(a3),d1            set up to clear next line
		subq    #1,d1

cscrolldclrrow  move.l  d2,d4                   reset column counter
		movea.l a1,a2

cscrolldclrword move16  zero16,(a2)+            move from one line to the other
		dbra    d4,cscrolldclrword      and loop

		adda.l  #width,a1               decrement row by width
		dbra    d1,cscrolldclrrow       and loop again

		bra     cscrolldpageoff

*                   68030 section

cscrolld68030   subq    #1,d2

cscrolldnextrow2 move.l  d2,d4                  reset column counter
		movea.l a1,a2
		movea.l a1,a4
		adda.l  d3,a4                   set up source address

cscrolldnextword2 move.l (a2)+,(a4)+            move from one line to the other
		dbra    d4,cscrolldnextword2    and loop

		suba.l  #width,a1               decrement row by width
		dbra    d1,cscrolldnextrow2     and loop again

		move    charh(a3),d1            set up to clear next line
		subq    #1,d1

cscrolldclrrow2 move.l  d2,d4                   reset column counter
		movea.l a1,a2

cscrolldclrword2 move.l  #0,(a2)+               move from one line to the other
		dbra    d4,cscrolldclrword2     and loop

		adda.l  #width,a1               decrement row by width
		dbra    d1,cscrolldclrrow2      and loop again

cscrolldpageoff move.l  #pagemode,d7            turn off page mode
		move.l  #1,0(a0,d7.l)

		jsr     misc_lockdown           enable STOP key

		rts

*
********************************************************************
*
*               procedure cupdatecursor(xpos,ypos:shortint);
*               positions cursor on screen at (x,y)

cupdatecursor   movea.l  crtinfo(a5),a3
		movea.l controladdr(a5),a0
		moveq   #0,d0                   clear some registers
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3
		move.l  d0,d4

		movea.l (sp)+,a4                a4 = return addr
		move    (sp)+,d1                y in chars
		move    (sp)+,d2                x in chars
		move.l  a4,-(sp)                stack return address

		mulu    charh(a3),d1
		add     charh(a3),d1            put cursor under the character
		subq    #1,d1
		move.l  #timingv0,d3
		add     0(a0,d3.l),d1           add yoffset (see WOODCUT ERS)
		move    d1,ycurs(a5)            y position in pixels

		mulu    charw(a3),d2
		move.l  #timingh0,d3
		move    0(a0,d3.l),d4
		subq    #4,d4
		lsl     #2,d4                   multiply by 4
		add     d4,d2                   add xoffset (see WOODCUT ERS)
		move    d2,xcurs(a5)            x position in pixels

* added test for cursor status to keep cursor from appearing when it is off
* to begin with         25OCT91 - CFB
		move.l  #cursorcontrol1,d0
		btst    #2,1(a0,d0.l)
		bne     donttoggle

		jsr     cursoroff
		move.l  #cursorposition,d3      update cursor position
		move    d1,0(a0,d3.l)
		move    d2,2(a0,d3.l)
		jsr     cursoron
		rts

donttoggle      move.l  #cursorposition,d3      update cursor position
		move    d1,0(a0,d3.l)
		move    d2,2(a0,d3.l)

		rts
*
********************************************************************
*
*               procedure cchar(ord(char),xpos,ypos:shortint);
*               places character on screen at (x,y)

cchar           movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0
		movea.l (sp)+,a1                get the return address

		moveq   #0,d0                   clear some registers
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d4
		move.l  d0,d5

		move    (sp)+,d0                y coordinate in rows
		move    (sp)+,d1                x coordinate in chars
		move    (sp)+,d2                character to write
		move.l  a1,-(sp)                put the return address back

		lea     (fontstorage),a2        get font base address
		move    charh(a3),d4            d4 =  font height
		move    charw(a3),d5            d5 =  font width

		mulu    d4,d0                   d0 = y coordinate in pixels
		mulu    d5,d1                   d1 = x coordinate in pixels

		mulu    d4,d2                   char # times height
		addq    #7,d5                   round off to the nearest byte
		andi.b  #$f8,d5                 to fix HIRES       24OCT91 - CFB
		mulu    d5,d2                   times width
		lsr.l   #3,d2                   / 8 -> font offset

		move.l  d0,d3                   start with row number
		mulu    #width,d3               times row width
		add     d1,d3                   plus column number
		addi.l  #framebuffer,d3         plus frame buffer base

		movea.l a0,a4
		adda.l  d3,a4                   now a4 has address of FB
		suba    #width,a4               add back later
		subq    #1,d4                   subtract 1 to make loop correct
		move    charw(a3),d5            d5 =  font width
		subq    #1,d5

		moveq   #0,d1                   re-use d1 for alpha color mask
		move    alphacolor(a3),d1       get color (will only be a byte)

		move.l  #maskreg,d6
		move.l  #-1,0(a0,d6.l)          enable writes to all planes

		adda.l  d2,a2                   a2 = char start addr

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

ccharnextrow    adda.l  #width,a4               beginning of frame buffer row
		movea.l a4,a1                   make copy to be incremented
		move.l  d5,d6

		moveq   #0,d7                   clear d7 for subtract at dbra

ccharnextcol    dbra    d7,ccharnextbit         still have bits?, don't reset
		moveq   #7,d7                   all done?, reset to bit 7
		move.b  (a2)+,d3                get next byte of packed font

ccharnextbit    moveq   #0,d0                   clear d0
		btst    d7,d3                   test bit in font
		sne     d0                      set d0 if not 0

		btst    #0,highlight(a3)        inverse video?
		beq.s   ccharputchar            no, skip over invert
		not.b   d0

ccharputchar    and.b   d1,d0                   and in color mask
		move.b  d0,(a1)+                write to frame buffer
		dbra    d6,ccharnextcol
		dbra    d4,ccharnextrow

		btst    #2,highlight(a3)        underline?
		bne.s   dounderline             yes, do the underline

		jsr     misc_lockdown           enable STOP key
		rts

dounderline     btst    #0,highlight(a3)        inverse video?
		beq.s   dounderline1            no, skip over invert
		moveq   #0,d1                   make underline pen 0

dounderline1    moveq   #0,d5
		move    charw(a3),d5            d5 =  font width
		subq    #1,d5                   subtract 1 to make loop correct
dounderline2    move.b  d1,-(a1)                underline going backward
		dbra    d5,dounderline2

		jsr     misc_lockdown           enable STOP key

		rts

*
********************************************************************
*
*               cclear(xpos,ypos,nchars:shortint);
*               -- clears nchars starting at xpos, ypos
*               -- nchars + xpos must not exceed screenwidth
*               no range checking is done
*

cclear          movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0

		moveq   #0,d1
		move.l  d1,d2
		move.l  d1,d3

		movea.l (sp)+,a1                return address
		move    (sp)+,d1                d1 = number of chars to clear
		move    (sp)+,d2                d2 = y to begin at
		move    (sp)+,d3                d3 = x to begin at
		move.l  a1,-(sp)                put back the return address

		mulu    charw(a3),d1            d1 = length in pixels
		lsr     #1,d1                   length in long words
		mulu    charh(a3),d2            d2 = y in pixels
		mulu    charw(a3),d3            d3 = x in pixels

		move.l  #vramcolor1,d7
		move.l  #0,0(a0,d7.l)           set color registers to 0
		move.l  #maskreg,d7
		move.l  #-1,0(a0,d7.l)          to clear on all planes

		move.l  screen(a5),a1           base address of FB
		mulu    #width,d2               multiply row * width
		adda.l  d2,a1                   add to the FB address
		adda.l  d3,a1                   add on the column

		moveq   #0,d2
		move    charh(a3),d2            d2 = # of rows

		subq    #1,d2
		subq    #1,d1                   subtract 1 to make loop correct

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

cclearnextrow   move.l  d1,d4                   reset column counter
		movea.l a1,a2                   reset to next line
cclearnextword  move.w  #0,(a2)+                write to the display
		dbra    d4,cclearnextword       and loop
		adda.l  #width,a1               increment row by width
		dbra    d2,cclearnextrow        and loop again

		jsr     misc_lockdown           enable STOP key

		rts

*
************************************************************************
*
*    procedure shiftleft
*

cshiftleft      movea.l crtinfo(a5),a3

		moveq   #0,d1
		move.l  d1,d2
		move.l  d1,d3

		move    printw(a3),d2           calculate width of lastline
		move    charw(a3),d3
		mulu    #8,d3                   lastline ends 8 from right edge
		sub     d3,d2                   width of last line
		lsr     #1,d2                   d2 = width in words
		move    printy(a3),d3           start at upper y
		add     printh(a3),d3           add print height -> last row

		mulu    #width,d3               offset address of last line
		add     printx(a3),d3           add on column

		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d3,a1                   a1 = destination address

		move    charh(a3),d1            d1 = number of rows
		moveq   #0,d3
		move    charw(a3),d3            d3 = width of char

		subq    #1,d1                   subtract 1 to make loop correct
		subq    #1,d2

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

cshiftlnextrow  move.w  d2,d4                   reset column counter
		movea.l a1,a2
cshiftlnextword move.w  0(a2,d3),(a2)+          move from one word to the other
		dbra    d4,cshiftlnextword      and loop
		adda.l  #width,a1               next row
		dbra    d1,cshiftlnextrow       and loop

		jsr     misc_lockdown           enable STOP key

		rts

*
************************************************************************
*
*    procedure shiftright
*

cshiftright     movea.l crtinfo(a5),a3

		moveq   #0,d1
		move.l  d1,d2
		move.l  d1,d3

		move    printw(a3),d2           calculate width of lastline
		move    charw(a3),d3
		mulu    #9,d3                   lastline ends 9 from right edge
		sub     d3,d2                   width of last line
		move    printy(a3),d3           start at upper y
		add     printh(a3),d3           add print height -> last row

		mulu    #width,d3               offset address of last line
		add     printx(a3),d3           add on column
		add     d2,d3                   add width
		lsr     #1,d2                   d2 = width in words

		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d3,a1                   a1 = destination address

		move    charh(a3),d1            d1 = number of rows
		moveq   #0,d3
		move    charw(a3),d3            d3 = width of char

		subq    #1,d1                   subtract 1 to make loop correct

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

cshiftrnextrow  move.l  d2,d4                   reset column counter
		movea.l a1,a2
cshiftrnextword move.w  (a2),0(a2,d3)           move from one word to the other
		subq    #2,a2
		dbra    d4,cshiftrnextword      and loop
		adda.l  #width,a1               next row
		dbra    d1,cshiftrnextrow       and loop

		jsr     misc_lockdown           enable STOP key

		rts

*
************************************************************************
*
*    procedure cexchange( savearea: windowp; ymin, ymax, xmin, width: shortint)
*

cexchange       movea.l crtinfo(a5),a3

		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3

		movea.l (sp)+,a1                return address
		move.w  (sp)+,d2                width in pixels
		move.w  (sp)+,d3                xmin
		move.w  (sp)+,d1                ymax
		move.w  (sp)+,d0                ymin
		movea.l (sp)+,a2                pointer to the window
		move.l  a1,-(sp)                stack return address

		mulu    charh(a3),d0            d0 = first row in pixels
		mulu    charh(a3),d1            d1 = last row in pixels
		sub     d0,d1                   d1 = number of rows
		add     charh(a3),d1            don't forget last row
		subq    #1,d1                   subtract 1 to make loop correct
		mulu    charw(a3),d3            x offset in pixels

		mulu    #width,d0
		add.l   d3,d0                   d0 = address of first row

		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d0,a1                   a1 = source address

		lsr     #1,d2                   number of words per line
		subq    #1,d2                   subtract 1 to make loop correct

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

cexchangenextrow move.l d2,d4                   reset column counter
		movea.l a1,a4

cexchangenextword move.w (a4),d7                move display to temp space
		move.w  (a2),(a4)+              replace display with save
		move.w  d7,(a2)+                replace save with temp
		dbra    d4,cexchangenextword    and loop

		adda.l  #width,a1               increment row by width
		dbra    d1,cexchangenextrow     and loop again

		jsr     misc_lockdown           enable STOP key

		rts

*
************************************************************************
*
*               procedure cscrollwindow( ymin, ymax, xmin, width: shortint)
*

cscrollwindow   movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0

		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3
		movea.l (sp)+,a1                return address
		move.w  (sp)+,d2                width in characters
		move.w  (sp)+,d3                xmin in characters
		move.w  (sp)+,d1                ymax in lines
		move.w  (sp)+,d0                ymin in lines
		move.l  a1,-(sp)                stack return address

		sub     d0,d1                   d1 = number of rows - 1
		tst     d1
		beq     cscrollwinrts           1 line window
		mulu    charh(a3),d0            d0 = first row in pixels
		mulu    charh(a3),d1            d1 = number of rows in pixels

		subq    #1,d1                   subtract 1 to make loop correct
		mulu    charw(a3),d3            x offset in pixels
		mulu    charw(a3),d2            x width in pixels

		mulu    #width,d0
		add.l   d3,d0                   d0 = address of first row

		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d0,a1                   a1 = destination row

		moveq   #0,d3                   reuse d3
		move    charh(a3),d3
		mulu    #width,d3               number of rows per line height

		lsr     #2,d2                   number of longs per line

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

		move.l  #pagemode,d7            turn on page mode
		move.l  #0,0(a0,d7.l)

		btst    #3,sysflag2             test for 68040 to use move16
		bne     cscrollwin68030

*                   68040 section

		lsr     #2,d2                   number of move16's
		subq    #1,d2                   subtract 1 to make loop correct

cscrollwinnextrow move.l  d2,d4                 reset column counter
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		adda.l  d3,a4                   set up source address

cscrollwinnextword move16  (a4)+,(a2)+          move from one line to the other
		dbra    d4,cscrollwinnextword   and loop

		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollwinnextrow    and loop again

		bra     cscrollwinpageoff

*                   68030 section

cscrollwin68030 subq    #1,d2                   subtract 1 to make loop correct

cscrollwinnextrow2 move.l d2,d4                 reset column counter
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		adda.l  d3,a4                   set up source address

cscrollwinnextword2 move.l (a4)+,(a2)+          move from one line to the other
		dbra    d4,cscrollwinnextword2  and loop

		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollwinnextrow2   and loop again

cscrollwinpageoff move.l #pagemode,d7           turn off page mode
		move.l  #1,0(a0,d7.l)

		jsr     misc_lockdown           enable STOP key
cscrollwinrts   rts

*
************************************************************************
*
*               procedure cursoroff
*

cursoroff       movea.l controladdr(a5),a0
		move.l  #cursorcontrol1,d0
		ori     #cursoroffmask,0(a0,d0.l)
		rts

*
************************************************************************
*
*               procedure cursoron
*

cursoron        movea.l controladdr(a5),a0
		move.l  #cursorcontrol1,d0
		andi    #cursoronmask,0(a0,d0.l)
		rts

*
************************************************************************
*
*               procedure cscrollwinddn( ymin, ymax, xmin, width: shortint)
*

cscrollwinddn   movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0

		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3
		movea.l (sp)+,a1                return address
		move.w  (sp)+,d2                width in characters
		move.w  (sp)+,d3                xmin in characters
		move.w  (sp)+,d1                ymax in lines
		move.w  (sp)+,d0                ymin in lines
		move.l  a1,-(sp)                stack return address

		move.l  d1,d4
		sub     d0,d4                   number of lines-1
		tst     d4
		beq     cscrollwindnrts         1 line window
		mulu    charh(a3),d4            d4 = number of rows in pixels
		subq    #1,d4                   subtract 1 to make loop correct
		move.l  d4,d0                   d0 = number of rows-1

		addq    #1,d1                   1 more line down
		mulu    charh(a3),d1            d1 = last row in pixels
		subq    #1,d1                   1 row up (last row of dest)
		mulu    charw(a3),d3            x offset in pixels
		mulu    charw(a3),d2            x width in pixels

		mulu    #width,d1
		add.l   d3,d1                   d1 = address of last row

		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d1,a1                   a1 = destination row

		moveq   #0,d3                   reuse d3
		move    charh(a3),d3
		mulu    #width,d3               number of rows per line height

		lsr     #2,d2                   number of longs per line

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

		move.l  #pagemode,d7            turn on page mode
		move.l  #0,0(a0,d7.l)

		btst    #3,sysflag2             test for 68040 to use move16
		bne     cscrollwindn68030

*                   68040 section

		lsr     #2,d2                   number of move16's
		subq    #1,d2                   subtract 1 to make loop correct

cscrollwindnnextrow move.l  d2,d4               reset column counter
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		suba.l  d3,a4                   set up source address

cscrollwindnnextword move16  (a4)+,(a2)+        move from one line to the other
		dbra    d4,cscrollwindnnextword and loop

		suba.l  #width,a1               decrement row by width
		dbra    d0,cscrollwindnnextrow  and loop again

		bra     cscrollwindnpageoff

*                   68030 section

cscrollwindn68030 subq    #1,d2                 subtract 1 to make loop correct

cscrollwindnnextrow2 move.l d2,d4               reset column counter
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		suba.l  d3,a4                   set up source address

cscrollwindnnextword2 move.l (a4)+,(a2)+        move from one line to the other
		dbra    d4,cscrollwindnnextword2 and loop

		suba.l  #width,a1               increment row by width
		dbra    d0,cscrollwindnnextrow2 and loop again

cscrollwindnpageoff move.l #pagemode,d7         turn off page mode
		move.l  #1,0(a0,d7.l)

		jsr     misc_lockdown           enable STOP key
cscrollwindnrts rts

*
************************************************************************
*
*               procedure cscrolll(ymin, ymax, xmin, width: shortint)
*

cdbscrolll      movea.l crtinfo(a5),a3

		moveq   #0,d1
		move.l  d1,d2
		move.l  d1,d3
		move.l  d1,d4

		movea.l (sp)+,a1                return address
		move.w  (sp)+,d4                width (in chars)
		move.w  (sp)+,d3                xmin (in chars)
		move.w  (sp)+,d2                ymax (in lines)
		move.w  (sp)+,d1                ymin (in lines)
		move.l  a1,-(sp)                stack return address

		sub     d1,d2
		addq    #1,d2                   add 1 to lines
		mulu    charh(a3),d2            d2 = number of rows in pixels
		mulu    charh(a3),d1            d1 = first row in pixels
		mulu    charw(a3),d3            d3 = first column
		subq    #1,d4                   1 char less
		beq     cdbscrolllrts           1 column window
		mulu    charw(a3),d4            number of columns
		lsr     #2,d4                   d4 = number of long words

		movea.l screen(a5),a1
		mulu    #width,d1
		adda.l  d1,a1
		adda.l  d3,a1                   address of first pixel

		subq    #1,d2                   subtract 1 to make loop correct
		subq    #1,d4                   subtract 1 to make loop correct

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

cdbscrolllnextrow movea.l a1,a2                 set up destination address
		movea.l a2,a4
		move.l  d4,d3                   reuse d3 for counter
		adda    charw(a3),a4            set up source address

cdbscrolllnextword move.l (a4)+,(a2)+
		dbra    d3,cdbscrolllnextword

		adda.l  #width,a1
		dbra    d2,cdbscrolllnextrow

		jsr     misc_lockdown           enable STOP key
cdbscrolllrts   rts

*
************************************************************************
*
*               procedure cscrollr( ymin, ymax, xmin, width: shortint)
*

cdbscrollr      movea.l crtinfo(a5),a3

		moveq   #0,d1
		move.l  d1,d2
		move.l  d1,d3
		move.l  d1,d4

		movea.l (sp)+,a1                return address
		move.w  (sp)+,d4                width
		move.w  (sp)+,d3                xmin
		move.w  (sp)+,d2                ymax
		move.w  (sp)+,d1                ymin
		move.l  a1,-(sp)                stack return address

		sub     d1,d2
		addq    #1,d2                   add 1 to lines
		mulu    charh(a3),d2            d2 = number of rows
		mulu    charh(a3),d1            d1 = first row
		mulu    charw(a3),d3            d3 = first column
		subq    #1,d4                   1 less char
		beq     cdbscrollrrts           1 column window
		mulu    charw(a3),d4            number of columns

		move.l  screen(a5),a1
		mulu    #width,d1
		adda.l  d1,a1
		adda.l  d3,a1
		adda.l  d4,a1                   address of first pixel
		addq    #4,a1                   subtract later with pre-dec

		lsr     #2,d4                   d4 = number of long words

		subq    #1,d2                   subtract 1 to make loop correct

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

cdbscrollrnextrow movea.l a1,a2                 set up source address
		movea.l a2,a4
		move.l  d4,d3                   reuse d3 for counter
		adda    charw(a3),a4            set up destination address

cdbscrollrnextword move.l -(a2),-(a4)
		dbra    d3,cdbscrollrnextword

		adda.l  #width,a1
		dbra    d2,cdbscrollrnextrow

		jsr     misc_lockdown           enable STOP key
cdbscrollrrts   rts

*
*********************************************************************
*
*               procedure cclearall
*               clears all of visible area except typeahead
*

cclearall       movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0

		moveq   #0,d2
		move.l  d1,d3

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

		move.l  #blockmode,d6
		move.l  #0,0(a0,d6.l)           turn on block mode
		move.l  #vramcolor1,d5
		move.l  #0,0(a0,d5.l)           set color registers to 0
		move.l  #maskreg,d5
		move.l  #-1,0(a0,d5.l)          to clear on all planes

		move.l  screen(a5),a1           base address of FB
		move    disph(a3),d2            get width and height in pixels
		move    dispw(a3),d3
		lsr     #4,d3                   change to number of words
		subq    #1,d2
		subq    #1,d3
		movea.l a1,a2                   make a copy for reference

nextrow         move.l  d3,d4                   reset column counter
		movea.l a2,a1                   reset to beginning of next line

nextword        move.w  #-1,(a1)+               write to the display
		dbra    d4,nextword             and loop

		adda.l  #widthdiv16,a2          increment row by width
		dbra    d2,nextrow              and loop again

		move.l  #1,0(a0,d6.l)           turn off block mode

		jsr     misc_lockdown           enable STOP key

		rts

*
************************************************************************
*
*               procedure csetcolormap(index,red,green,blue:integer)
*               Set a color map entry
*               To minimize flicker, wait for BEECH blue register
*               to go not busy. Then write the index, red, and
*               green data to the DAC. Then write the blue data
*               to BEECH. BEECH will send the blue data to the
*               DAC and the DAC will then update.
*

csetcolormap    movea.l controladdr(a5),a0
		movea.l (sp)+,a1                return address
		move.l  (sp)+,d3
		move.l  (sp)+,d2
		move.l  (sp)+,d1
		move.l  (sp)+,d0                get data off stack as longs
		move.l  a1,-(sp)                stack return address

		move.l  #blueregimage,d5

ccheckblue      btst    #0,2(a0,d5.l)           check for color map busy
		bne.s   ccheckblue              loop until bit is clear
		move.l  #dacimagewrite,d6
		move.b  d0,0(a0,d6.l)           write the index to the DAC
		move.b  d1,4(a0,d6.l)           then red to the DAC
		move.b  d2,4(a0,d6.l)           then green to the DAC
		move.b  d3,3(a0,d5.l)           then blue to BEECH
		rts

*
************************************************************************
*
*               procedure  csetreg(register:integer; value:shortint)
*

csetreg         movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0
		movea.l (sp)+,a1                return address
		move.w  (sp)+,d2                register value
		move.l  (sp)+,d1                register number
		move.l  a1,-(sp)                stack return address
		rts

*
************************************************************************
*
*               procedure  csavewoodenv(anyvar buffer:window)
*

csavewoodenv    movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0
		movea.l (sp)+,a1                return address
		movea.l (sp)+,a2
		move.l  a1,-(sp)                stack return address
		rts

*
************************************************************************
*
*               procedure  crestorewoodenv(anyvar buffer:window)
*

crestorewoodenv movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0
		movea.l (sp)+,a1                return address
		movea.l (sp)+,a2
		move.l  a1,-(sp)                stack return address
		rts

*
************************************************************************
*
*               function   cromshort(offset:integer):shortint
*

cromshort   equ      *
	    movea.l  controladdr(a5),a0
	    movea.l  (sp)+,a1           return address
	    adda.l   (sp)+,a0           offset
	    movep    0(a0),d0
	    move     d0,(sp)            store on stack as function value
	    jmp      (a1)

*
************************************************************************
*
*               procedure  csetupcchar
*

csetupcchar     movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0
		rts

*
************************************************************************
*
*               procedure  cprepdumpline(mybuf:windowp; size:shortint;
*                                        rowstart:anyptr);
*
* Takes the data in the frame buffer at rowstart, for size*8 bytes, and
* preps it for graphic output by creating an array of size number of bytes
* which has 1 bits where there are non-0 pixels in rowstart array, and 0 bits
* elsewhere. This is the format of PCL graphics data. The mybuf pointer
* is actually a pointer 8 bytes into a pascal string structure.
* the routine detects the last non-0 output byte, and adjusts both the
* strlen of the Pascal string, and the ASCII numeric string to that. The
* adjustment is done to minimize data transmission to printer, especially
* for RS232 printers.
* The ASCII string header looks like #27'*bxxxW' where xxx is a
* 3-digit number, which reflects the length of FOLLOWING binary data.

* called by dumpg in CATCRT - SFB/LAF Jan 26, '88

cprepdumpline   equ *
		move.l  (sp)+,a0        return address
		move.l  (sp)+,a3        rowstart
		move.w  (sp)+,d0        size
		move.l  (sp),a1         outbufptr, leave on stack for later
		move.w  d0,d1           copy for adjusting strlen, etc later
		ext.l   d1              ensure MSBs are 0 for later divide
		move.l  d1,d5           keeps track of last non-zero outbuf char
		movea.l crtinfo(a5),a2  get access to crt description
		bra.s   initcharbuf     start up the process

preploop        equ    *
		move.b  (a3)+,d2        prepare to test non-zero pixel
		and.b   planemask+3(a2),d2 mask out "floating" bits in pixel
		subi.b  #1,d2           will set X in CCR if (a3) is zero
		roxl.b  #1,d3           put X into output char buf LSB
		dbra    d4,preploop     do it 8 times per out char

		not.b   d3              because X was wrong sense
		move.b  d3,(a1)+        put character into outbuf
		beq.s   initcharbuf     if it wasn't empty, then
		move.w  d0,d5           keep track of last non-empty char

initcharbuf     equ *
		move.w  #7,d4           8 bits per output char
		dbra    d0,preploop     n chars/line

		move.l  (sp)+,a1        recover initial outbufptr, and clr stack
		sub.w   d5,d1
		bne.s   fixstrlen       line has something on it
		moveq   #1,d1        must have min of 1 to force slew (we wish!)

fixstrlen       equ   *
		move.b  d1,-8(a1)       stick correct length in strlen of outbuf
		addi.b  #7,-8(a1)       and adjust for #27'*bxxxW' header

* compute ASCII representation of d1 into longword, with trailing 'W'

		divu    #10,d1          remainder->upper word of d1
		move.w  d1,d2
		ext.l   d2              clear MSBs of d2
		divu    #10,d2          remainder->upper word of d2
		swap    d2
		rol.w   #8,d2
		clr.w   d1              clear LSBs
		swap    d1
		or.l    d2,d1
		ori.l   #'000',d1       attach ASCII numeric headers
		rol.l   #8,d1           justify for copy to outbuf
		ori.b   #'W',d1         now have 'xxxW' in longword
		move.l  d1,-4(a1)       copy to outbuf

		jmp     (a0)            and return


*
************************************************************************
*
*               procedure  setupcchar
*

setupcchar      movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0
		rts

*
************************************************************************
*               end of code
@


56.2
log
@
pws2rcs automatic delta on Wed Jan 27 11:57:27 MST 1993
@
text
@d1 1703
@


56.1
log
@Automatic bump of revision number for PWS version 3.25
@
text
@a0 1703
	     page
*
*   WOODCUT family bit-mapped alpha driver
*
*     Pascal 3.25 version by C. Brett
*
*       In most routines registers are used as follows:
*               a0      CRT control space base address
*               a1      scratch
*               a2      scratch
*               a3      CRT information base address
*               a4      scratch
*               a5      Global Base used by PAWS
*               a6      Stack Frame Pointer used by PAWS
*               a7      stack pointer SP (don't modify)
*
*               d0      scratch
*               d1      scratch
*               d2      scratch
*               d3      scratch
*               d4      scratch
*               d5      scratch
*               d6      scratch
*               d7      scratch



		def     cscrollup,cscrolldown,cupdatecursor,cchar,cclear
		def     cbuildtable,cshiftleft,cshiftright
		def     cexchange,cscrollwindow,cursoroff
		def     cscrollwinddn,cdbscrolll,cdbscrollr,cclearall
		def     csetcolormap,csetreg,csavewoodenv,crestorewoodenv
		def     cromshort,csetupcchar,cprepdumpline

		def     setupcchar

		rorg.l 0

		refa    woodcutdvr,sysdevs
		refa    misc_lockup,misc_lockdown

		nosyms
		sprint
crtinfo         equ     woodcutdvr-4
cpl             equ     crtinfo-2
cppl            equ     cpl-2
fb_fontchars    equ     cppl-2
maxy            equ     fb_fontchars-2
xcurs           equ     maxy-2
ycurs           equ     xcurs-2
hascolor        equ     ycurs-1
midres          equ     hascolor-1
screenwidth     equ     midres-2
screenheight    equ     screenwidth-2
maxx            equ     screenheight-2
screensize      equ     maxx-2
defaulthighlight equ    screensize-2

controladdr     equ     sysdevs-86
screen          equ     sysdevs-90

* OFFSETS FOR CRTPARAMS

fbwidth         equ     0
fbheight        equ     2+fbwidth
dispx           equ     2+fbheight
dispy           equ     2+dispx
dispw           equ     2+dispy
disph           equ     2+dispw
printx          equ     2+disph
printy          equ     2+printx
printw          equ     2+printy
printh          equ     2+printw
offx            equ     2+printh
offy            equ     2+offx
offw            equ     2+offy
offh            equ     2+offw
charw           equ     2+offh
charh           equ     2+charw
fb_fontstartx   equ     2+charh
fb_fontstarty   equ     2+fb_fontstartx
fb_font_line_len equ    2+fb_fontstarty
fb_fontlines    equ     2+fb_font_line_len
nfontchars      equ     2+fb_fontlines
fb_cursorx      equ     4+nfontchars
fb_cursory      equ     2+fb_cursorx
set_colormap_proc equ   2+fb_cursory
planemask       equ     8+set_colormap_proc
alphacolor      equ     4+planemask
cursorcolor     equ     2+alphacolor
highlight       equ     2+cursorcolor
creplrule0      equ     2+highlight
creplrule1      equ     1+creplrule0
cursreplrule0   equ     1+creplrule1
cursreplrule1   equ     1+cursreplrule0

flags           equ     1+cursreplrule1
togglealpha     equ     7       bit number
togglegraphics  equ     6       bit number
copy_under_cursor equ   5       bit number
use_fib_xy      equ     4       bit number
disable_low_ctl equ     3       bit number
disable_hi_ctl  equ     2       bit number
copy_to_abuf    equ     1       bit number
*pad            equ     0       bit number


*       WOODCUT REGISTER OFFSETS (ADD TO CONTROL BASE ADDRESS)

dio2base        equ     $01000000 -$01FFFFFF    16 Meg (DIO-II Select Code 132)
sgcbase         equ     $02000000 -$02FFFFFF    32 Meg

stirom          equ     $00000000
ashregs         equ     $00040000 -$0004FFFF
refreshrate     equ     $00050000       refresh rate select (60Hz or 72Hz)
alphaplane      equ     $00050004       not used
vramcolor1      equ     $00060000       colormask used for rows 0-511
dacregs         equ     $00060200
vramcolor2      equ     $00060400       colormask used for rows 512-1023
beechregs       equ     $00060600
*                       $00060800 -$001FFFFF    unused
framebuffer     equ     $00200000 -$003FFFFF
*                       $00400000 -$005FFFFF    unused
*cachedfb       equ     $00600000 -$007FFFFF    unused - HPUX caches this space
*                       $00800000 -$00FFFFFF    unused

* ASH registers

visiblemask     equ     $00040000 -$00040FFF    bits 19-16 only
colormask       equ     $00041000 -$00041FFF    bits 19-16 only
cursorcontrol0  equ     $00042000
cursorcontrol1  equ     $00042004

cursoronmask    equ     $fffb           1111 1111 1111 1011 (and in)
cursoroffmask   equ     $0004           0000 0000 0000 0100 (or in)
cursorbusy      equ     3               0000 0000 0000 1000 (bit to test)

* BEECH registers

byteshift       equ     $00060600
blankandtest    equ     $00060604
blockmode       equ     $00060608
pagemode        equ     $0006060c
blueregimage    equ     $00060610
blueregcursor   equ     $00060614
maskreg         equ     $00060618
cursorposition  equ     $0006061c
timingh0        equ     $00060620
timingh1        equ     $00060624
timingv0        equ     $00060628
timingv1        equ     $0006062c
testvideo       equ     $00060630
testcursorup    equ     $00060634
testcursorsh    equ     $00060638
testvideocount  equ     $0006063c

* common DAC registers

dacimagewrite   equ     $00060202
colormapvalue   equ     $00060206

* low/medium resolution DAC registers on bt474

pixelreadmask   equ     $0006020a
dacimageread    equ     $0006020e
dacoverlaywrite equ     $00060212
dacoverlayregs  equ     $00060216
*                       $0006021a       reserved
dacoverlayread  equ     $0006021e
daccommandreg0  equ     $00060222
daccommandreg1  equ     $00060226
dacidreg        equ     $0006022a       value should be $11 for WOODCUT family
dacstatusreg    equ     $0006022e

* high resolution DAC registers on bt458

overlaycolor1   equ     2
overlaycolor2   equ     3
readmask        equ     4
blinkmask       equ     5
commandreg      equ     6
cntlstatreg     equ     7
hrdacoverlaywrite equ   $0006020e


* GRAPHICS ROM OFFSETS

framewidth      equ     $00000005       width of frame buffer
frameheight     equ     $00000009       height of frame buffer
displaywidth    equ     $0000000D       width of displayed frame buffer
displayheight   equ     $00000011       height of displayed frame buffer
displayid       equ     $00000015       secondary ID byte
initoffset      equ     $00000023       offset to initialization offset
fontoffset      equ     $0000003B       offset to font info offset
framecount      equ     $0000005B       number of frames
frameoffset     equ     $0000005D       offset to frame buffer

width           equ     2048            width is always 2048 on WOODCUT
widthdiv16      equ     128             pixels / 16 for block mode

* BOOT ROM ADDRESSES

sysflag2        equ     $FFFFFEDA

* USEFUL CONSTANTS

*                                       kludge because MOVE16 is 16 byte aligned
*                                       and we don't know where zero16 will be
		dc.l    0,0,0,0         16 bytes of zeros
zero16          dc.l    0,0,0,0         16 bytes of zeros
		dc.l    0,0,0,0         16 bytes of zeros

currentintlevel ds.l    1               current interrupt level
hires           ds.l    1               hires flag (0 med or low, 1 high)

fontstorage     ds.b    15360           ((256 + 128) * 16 * 20) / 8

*
*******************************************************************
*
*               misc utilities for initialization
*               uses register a1 contrary to intro comments
*

loadcmap        lea     cmaptable,a1          initialize the color map
		tst.b   hascolor(a5)          color?
		bne     cmapstart             yes, jump over greyscale
		lea     gmaptable,a1          initialize the greyscale color map
cmapstart       moveq   #0,d1                 clear some registers
		move.l  d1,d2
		move.l  d1,d3
		move.l  d1,d4
cmaploop1       move.b  (a1)+,d2              get rgb values in d2-d4
		move.b  (a1)+,d3
		move.b  (a1)+,d4
		jsr     cmapenter             call the color map entry routine
		addq    #1,d1                 bump cmap pointer value
		cmp     #16,d1                have we done 16 yet?
		bne.s   cmaploop1             if not then continue
		moveq   #-1,d2                set entries 16-255 to white
		move.l  d2,d3
		move.l  d2,d4
cmaploop2       jsr     cmapenter
		addq    #1,d1
		cmp     #256,d1                 done with cmap init?
		bne.s   cmaploop2

		move.l  #blueregcursor,d6
		move.l  #colormapvalue,d7
		move.l  #dacoverlaywrite,d5

cursorcmapwait  btst    #0,1(a0,d6.l)           check for color map busy
		bne.s   cursorcmapwait          loop till bit is clear
		move.b  #2,0(a0,d5.l)           write the index to the DAC
		move.b  #0,0(a0,d7.l)           then red to the DAC
		move.b  #0,0(a0,d7.l)           then green to the DAC
		move.b  #0,3(a0,d6.l)           then blue to BEECH

cursorcmapwait2 btst    #0,1(a0,d6.l)           check for color map busy
		bne.s   cursorcmapwait2         loop till bit is clear
		move.b  #3,0(a0,d5.l)           write the index to the DAC
		move.b  #255,0(a0,d7.l)         then red to the DAC
		move.b  #255,0(a0,d7.l)         then green to the DAC
		move.b  #255,3(a0,d6.l)         then blue to BEECH
		rts

cmapenter       move.l  #blueregimage,d6
		move.l  #dacimagewrite,d5
		move.l  #colormapvalue,d7

cmapwait        btst    #0,1(a0,d6.l)           check for color map busy
		bne.s   cmapwait                loop till bit is clear
		move.b  d1,0(a0,d5.l)           write the index to the DAC
		move.b  d2,0(a0,d7.l)           then red to the DAC
		move.b  d3,0(a0,d7.l)           then green to the DAC
		move.b  d4,3(a0,d6.l)           then blue to BEECH

		rts                             done with cmap entry write

*
*************************************************************************
*
*               font unpacking routines (unpacking moved to cchar)
*               a2 points to font ROM
*               a3 points to crtinfo
*               a4 points to font storage
*               d3 number of characters
*

unpkroman       equ     *
		moveq   #0,d0
		move.l  d0,d1

		move    charw(a3),d0
		move    charh(a3),d1
		addq    #7,d0                   round off to the nearest byte
		andi.b  #$f8,d0                 to fix HIRES       24OCT91 - CFB
		mulu    d0,d1                   number of pixels/char
		lsr     #3,d1                   number of bytes/char
		subq    #1,d1                   subtract 1 to make loop correct

unpackchar      move.l  d1,d5                   unpack d1 bytes/char
unpackrow       move.b  (a2),(a4)+              copy over byte
		addq.l  #2,a2                   look at next font byte
		dbra    d5,unpackrow            and loop till bytes in char done
		dbra    d3,unpackchar           loop till all chars done

		rts


*
*************************************************************************
*
*               ginit routines
*

ginitblock      moveq    #0,d1              clear some regs
		moveq    #0,d0
		move.b   2(a1),d0           get word count to initialize
		movep    4(a1),d1           form destination offset
		add.l    a0,d1              d1 points to dest addr
		lea      8(a1),a2           a2 points to first data byte
		movea.l  d1,a4              a4 points to destination
		btst     #0,(a1)            is this a bit test block?
		bne.s    ginitbtst          if so go handle it
ginitloop       movep    0(a2),d1           form a data word in d1
		move.w   d1,(a4)+           move data to the destination addr
		btst     #6,(a1)            increment data pointer
		bne.s    ginit1             based on control byte
		addq     #4,a2
ginit1          dbra     d0,ginitloop       loop till word count exhausted
		btst     #7,(a1)            was this last block?
		bne.s    ginitdone          yes -- go return
		btst     #6,(a1)            adjust data pointer
		beq.s    ginit2             to point to next init block
ginit3          addq     #4,a2
ginit2          movea.l  a2,a1              a1 points to new init block
		bra      ginitblock         do the initialize

ginitbtst       moveq    #0,d2              handle bit test blocks here
		move.b   2(a2),d2           d2 = bit # to test
ginittst2       move     (a4),d3            d3 = data word to test
		btst     #0,(a2)            check for sense of test
		bne.s    ginittst3          comp if waiting for 0
		not      d3
ginittst3       btst     d2,d3              check the bit
		beq      ginittst2          if not 1 then loop
		btst     #7,(a1)            was this last block?
		bne.s   ginitdone          if so then return
		bra      ginit3             else do next block

ginitdone       rts

*
*************************************************************************
*
*               variable initialization and font table building routines
*

cbuildtable     movea.l controladdr(a5),a0      get pointer to ROM start
		movea.l crtinfo(a5),a3          crtparamrec
		movep   initoffset(a0),d1       form pointer to init block
		movea.l a0,a1                   make copy of ROM start addr
		adda.l  d1,a1                   a1 points to init info now
		jsr     ginitblock              call the initialization routine
		clr.b   hascolor(a5)            clear color flag
		cmpi.b  #17,displayid(a0)       greyscale?
		bgt     cframeaddr              yes, don't set color
		st      hascolor(a5)            set for color
cframeaddr      movea.l a0,a1                   make copy of ROM start addr
		adda.l  #framebuffer,a1         add offset to frame buffer
		move.l  a1,screen(a5)           form frame buffer addr

		move.b  framecount(a0),d0       d0=# of planes in system
		beq.s   cnumplanes              if zero then read planes
		moveq   #8,d1                   else make the mask up
		moveq   #$ff,d2
		sub     d0,d1                   d1 has shift count
		lsr.b   d1,d2                   after shift d2 has mask
		bra.s   csetplanes              go setup planemask

cnumplanes      moveq   #0,d2                   determine how many planes
		movea.l screen(a5),a1           addr of fb in a1
		move.b  #$FF,(a1)               write all 1's
		move.b  (a1),d2                 read it back to get plane mask
csetplanes      move.l  #0,planemask(a3)        clear full 32 bits
		move.b  d2,3+planemask(a3)      save as plane mask

cnocolor2       moveq   #0,d0
		move.l  d0,hires                clear hires flag
		move    d0,dispx(a3)            set positions to (0,0)
		move    d0,dispy(a3)
		move    d0,printx(a3)
		move    d0,printy(a3)
		movep.w framewidth(a0),d2       get width from ROM
		move    d2,fbwidth(a3)
		movep.w displaywidth(a0),d2    set visible width as window width
		movep.w frameheight(a0),d2      get height from ROM
		move    d2,fbheight(a3)
		movep.w displayheight(a0),d2
		move    d2,disph(a3)
		movep.w displaywidth(a0),d2
		move    d2,dispw(a3)
		move    d2,printw(a3)
		cmp     #1024,d2
		beq.s   setuplcc
		cmp     #640,d2                 no offscreen available
		beq.s   setupvga

setuphrx        equ     *                       offscreen available to right
		move    #1280,offx(a3)
		move    #0,offy(a3)
		move    #768,offw(a3)
		move    #1024,offh(a3)
		st      hires                   set hires flag
		bra.s   donesetupoff

setuplcc        equ     *                       no offscreen available
		move    #0,offx(a3)
		move    #0,offy(a3)
		move    #0,offw(a3)
		move    #0,offh(a3)
		bra.s   donesetupoff

setupvga        equ     *                       offscreen available to right
		move    #640,offx(a3)           and at the bottom. right larger
		move    #0,offy(a3)
		move    #384,offw(a3)
		move    #512,offh(a3)

donesetupoff    equ     *
		jsr     loadcmap                load the color map

		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d7

		movep   fontoffset(a0),d1       get font info offset
		move.b  (a0,d1.w),d7            d3 = number of fonts
		subq    #1,d7                   subtract 1 to make loop correct
		lea     4(a0,d1.w),a1           a1 = address of font offset
		lea     (fontstorage),a4        a4 = address of font storage

getfontinfo     movep   0(a1),d2                d2 = offset to font info
		lea     0(a0,d2.l),a2           a2 = address of font info

		moveq   #0,d1                   clear d1 for re-use
		move.b  (a2),d0                 d0 = font height
		move.b  2(a2),d1                d1 = font width
		move    d0,charh(a3)            store them for later use
		move    d1,charw(a3)

		moveq   #0,d3
		move.b  8(a2),d3                get last char value
		sub.b   6(a2),d3                subtract first char value
*                                               d3 = number of chars in font

		adda.l  #10,a2                  a2 now points to first char
		jsr     unpkroman               go unpack it

		adda.l  #6,a1                   a1 = address of next font
		dbra    d7,getfontinfo

buildcursor     equ     *
		jsr     cursoroff

		move.l  #cursorcontrol1,d2

		move.l  #colormask,d0           write to the cursor image
		move.l  #1023,d1                clear the entire cursor

buildcursorclr  btst    #cursorbusy,1(a0,d2.l)  wait until the cursor not busy
		bne.s   buildcursorclr
		move    #0,0(a0,d0.l)
		addq.l  #4,d0
		dbra    d1,buildcursorclr

		move.l  #colormask,d0           create cursor image
		moveq   #1,d4                   2 rows

buildcursorclr3 moveq   #1,d3                   2 nybbles wide
		move.l  d0,d1                   beginning of row
buildcursorclr2 btst    #cursorbusy,1(a0,d2.l)  wait until the cursor not busy
		bne.s   buildcursorclr2
		move    #-1,0(a0,d1.l)
		addq.l  #4,d1                   next 4 pixels
		dbra    d3,buildcursorclr2
		tst     hires
		beq     buildcursorclr1
		move    #$000c,0(a0,d1.l)
buildcursorclr1 addi.l  #64,d0                  next row
		dbra    d4,buildcursorclr3

		move.l  #visiblemask,d0         write to the cursor mask
		move.l  #1023,d1                clear the entire mask

buildcursorvis  btst    #cursorbusy,1(a0,d2.l)  wait until the cursor not busy
		bne.s   buildcursorvis
		move    #0,0(a0,d0.l)
		addq.l  #4,d0
		dbra    d1,buildcursorvis

		move.l  #visiblemask,d0         create "cookie cutter"
		moveq   #1,d4                   2 rows

buildcursorvis3 moveq   #1,d3                   8 nybbles wide
		move.l  d0,d1                   beginning of row
buildcursorvis2 btst    #cursorbusy,1(a0,d2.l)  wait until the cursor not busy
		bne.s   buildcursorvis2
		move    #-1,0(a0,d1.l)
		addq.l  #4,d1                   next 4 pixels
		dbra    d3,buildcursorvis2
		tst     hires
		beq     buildcursorvis1
		move    #$000c,0(a0,d1.l)
buildcursorvis1 addi.l  #64,d0                  next row
		dbra    d4,buildcursorvis3

		move.l  #cursorcontrol0,d0
		move.l  #0,0(a0,d0.l)           clear y-clip LSB's

		move.l  #cursorcontrol1,d0
		andi    #$000c0,0(a0,d0.l)      clear y-clip MSB's

		jsr     cursoron

		move.l  #readmask,d2
		move.b  #255,0(a0,d2)           turn on all planes

		rts

*
****************************************************************
*
*

cmaptable       equ     *               initial color map contents (r,g,b)
		dc.b    0,0,0                   0
		dc.b    255,255,255             1
		dc.b    255,0,0                 2
		dc.b    255,255,0               3
		dc.b    0,255,0                 4
		dc.b    0,255,255               5
		dc.b    0,0,255                 6
		dc.b    255,0,255               7
		dc.b    0,0,0                   8
		dc.b    204,187,51              9
		dc.b    51,170,119              10
		dc.b    136,102,170             11
		dc.b    204,68,102              12
		dc.b    255,102,51              13
		dc.b    255,119,0               14
		dc.b    221,136,68              15

gmaptable       equ     *           initial greyscale color map contents (r,g,b)
		dc.b    0,0,0                   0
		dc.b    0,255,0                 1
		dc.b    0,239,0                 2
		dc.b    0,233,0                 3
		dc.b    0,207,0                 4
		dc.b    0,191,0                 5
		dc.b    0,175,0                 6
		dc.b    0,159,0                 7
		dc.b    0,143,0                 8
		dc.b    0,128,0                 9
		dc.b    0,112,0                10
		dc.b    0,96,0                 11
		dc.b    0,80,0                 12
		dc.b    0,64,0                 13
		dc.b    0,48,0                 14
		dc.b    0,32,0                 15
		dc.b    0,16,0                 16

*
*               end of misc utilities
****************************************************************
*
*               procedure cscrollup
*               scroll up one line
*

cscrollup       movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0

		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3

		move    printy(a3),d0
		move    printh(a3),d1           set up window size
		sub     charh(a3),d1            one less row
		sub     d0,d1                   d1 = number of rows
		subq    #1,d1                   subtract 1 to make loop correct

		mulu    #width,d0               d0 = address of first row

		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d0,a1                   a1 = destination row

		move    charh(a3),d3
		mulu    #width,d3               number of rows per line height

		move    printw(a3),d2
		lsr     #2,d2                   number of longs per line

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

		move.l  #pagemode,d7            turn on page mode
		move.l  #0,0(a0,d7.l)

		btst    #3,sysflag2             test for 68040 to use move16
		bne     cscroll68030

*                   68040 section

		lsr     #2,d2                   number of move16's
		subq    #1,d2                   subtract 1 to make loop correct

cscrollnextrow  move.l  d2,d4                   reset column counter
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		adda.l  d3,a4                   set up source address

cscrollnextword move16  (a4)+,(a2)+             move from one line to the other
		dbra    d4,cscrollnextword      and loop

		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollnextrow       and loop again

		move    charh(a3),d1            set up to clear next line
		subq    #1,d1

cscrollclrrow   move.l  d2,d4                   reset column counter
		movea.l a1,a2

cscrollclrword  move16  zero16,(a2)+            clear line
		dbra    d4,cscrollclrword       and loop

		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollclrrow        and loop again

		bra     cscrollpageoff

*                   68030 section

cscroll68030    subq    #1,d2                   subtract 1 to make loop correct

cscrollnextrow2 move.l  d2,d4                   reset column counter
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		adda.l  d3,a4                   set up source address

cscrollnextword2 move.l  (a4)+,(a2)+            move from one line to the other
		dbra    d4,cscrollnextword2     and loop

		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollnextrow2      and loop again

		move    charh(a3),d1            set up to clear next line
		subq    #1,d1

cscrollclrrow2  move.l  d2,d4                   reset column counter
		movea.l a1,a2

cscrollclrword2 move.l  #0,(a2)+                clear line
		dbra    d4,cscrollclrword2      and loop

		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollclrrow2       and loop again

cscrollpageoff  move.l  #pagemode,d7            turn off page mode
		move.l  #1,0(a0,d7.l)

		jsr     misc_lockdown           enable STOP key

		rts

*
****************************************************************
*
*               procedure cscrolldown
*               scroll down one line
*

cscrolldown     movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0

		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3

		move    printh(a3),d0           get last row
		sub     charh(a3),d0            start one line height up
		move    d0,d1                   set up window size
		sub     printy(a3),d1           d1 = number of rows
		subq    #1,d1                   subtract 1 to make loop correct

		mulu    #width,d0               d0 = address of last row

		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d0,a1                   a1 = source row

		move    charh(a3),d3
		mulu    #width,d3               number of rows per line height

		move    printw(a3),d2
		lsr     #2,d2                   number of longs per line

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

		move.l  #pagemode,d7            turn on page mode
		move.l  #0,0(a0,d7.l)

		btst    #3,sysflag2             test for 68040 to use move16
		bne     cscrolld68030

*                   68040 section

		lsr     #2,d2                   number of move16's
		subq    #1,d2

cscrolldnextrow move.l  d2,d4                   reset column counter
		movea.l a1,a2
		movea.l a1,a4
		adda.l  d3,a4                   set up source address

cscrolldnextword move16 (a2)+,(a4)+             move from one line to the other
		dbra    d4,cscrolldnextword     and loop

		suba.l  #width,a1               decrement row by width
		dbra    d1,cscrolldnextrow      and loop again

		move    charh(a3),d1            set up to clear next line
		subq    #1,d1

cscrolldclrrow  move.l  d2,d4                   reset column counter
		movea.l a1,a2

cscrolldclrword move16  zero16,(a2)+            move from one line to the other
		dbra    d4,cscrolldclrword      and loop

		adda.l  #width,a1               decrement row by width
		dbra    d1,cscrolldclrrow       and loop again

		bra     cscrolldpageoff

*                   68030 section

cscrolld68030   subq    #1,d2

cscrolldnextrow2 move.l  d2,d4                  reset column counter
		movea.l a1,a2
		movea.l a1,a4
		adda.l  d3,a4                   set up source address

cscrolldnextword2 move.l (a2)+,(a4)+            move from one line to the other
		dbra    d4,cscrolldnextword2    and loop

		suba.l  #width,a1               decrement row by width
		dbra    d1,cscrolldnextrow2     and loop again

		move    charh(a3),d1            set up to clear next line
		subq    #1,d1

cscrolldclrrow2 move.l  d2,d4                   reset column counter
		movea.l a1,a2

cscrolldclrword2 move.l  #0,(a2)+               move from one line to the other
		dbra    d4,cscrolldclrword2     and loop

		adda.l  #width,a1               decrement row by width
		dbra    d1,cscrolldclrrow2      and loop again

cscrolldpageoff move.l  #pagemode,d7            turn off page mode
		move.l  #1,0(a0,d7.l)

		jsr     misc_lockdown           enable STOP key

		rts

*
********************************************************************
*
*               procedure cupdatecursor(xpos,ypos:shortint);
*               positions cursor on screen at (x,y)

cupdatecursor   movea.l  crtinfo(a5),a3
		movea.l controladdr(a5),a0
		moveq   #0,d0                   clear some registers
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3
		move.l  d0,d4

		movea.l (sp)+,a4                a4 = return addr
		move    (sp)+,d1                y in chars
		move    (sp)+,d2                x in chars
		move.l  a4,-(sp)                stack return address

		mulu    charh(a3),d1
		add     charh(a3),d1            put cursor under the character
		subq    #1,d1
		move.l  #timingv0,d3
		add     0(a0,d3.l),d1           add yoffset (see WOODCUT ERS)
		move    d1,ycurs(a5)            y position in pixels

		mulu    charw(a3),d2
		move.l  #timingh0,d3
		move    0(a0,d3.l),d4
		subq    #4,d4
		lsl     #2,d4                   multiply by 4
		add     d4,d2                   add xoffset (see WOODCUT ERS)
		move    d2,xcurs(a5)            x position in pixels

* added test for cursor status to keep cursor from appearing when it is off
* to begin with         25OCT91 - CFB
		move.l  #cursorcontrol1,d0
		btst    #2,1(a0,d0.l)
		bne     donttoggle

		jsr     cursoroff
		move.l  #cursorposition,d3      update cursor position
		move    d1,0(a0,d3.l)
		move    d2,2(a0,d3.l)
		jsr     cursoron
		rts

donttoggle      move.l  #cursorposition,d3      update cursor position
		move    d1,0(a0,d3.l)
		move    d2,2(a0,d3.l)

		rts
*
********************************************************************
*
*               procedure cchar(ord(char),xpos,ypos:shortint);
*               places character on screen at (x,y)

cchar           movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0
		movea.l (sp)+,a1                get the return address

		moveq   #0,d0                   clear some registers
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d4
		move.l  d0,d5

		move    (sp)+,d0                y coordinate in rows
		move    (sp)+,d1                x coordinate in chars
		move    (sp)+,d2                character to write
		move.l  a1,-(sp)                put the return address back

		lea     (fontstorage),a2        get font base address
		move    charh(a3),d4            d4 =  font height
		move    charw(a3),d5            d5 =  font width

		mulu    d4,d0                   d0 = y coordinate in pixels
		mulu    d5,d1                   d1 = x coordinate in pixels

		mulu    d4,d2                   char # times height
		addq    #7,d5                   round off to the nearest byte
		andi.b  #$f8,d5                 to fix HIRES       24OCT91 - CFB
		mulu    d5,d2                   times width
		lsr.l   #3,d2                   / 8 -> font offset

		move.l  d0,d3                   start with row number
		mulu    #width,d3               times row width
		add     d1,d3                   plus column number
		addi.l  #framebuffer,d3         plus frame buffer base

		movea.l a0,a4
		adda.l  d3,a4                   now a4 has address of FB
		suba    #width,a4               add back later
		subq    #1,d4                   subtract 1 to make loop correct
		move    charw(a3),d5            d5 =  font width
		subq    #1,d5

		moveq   #0,d1                   re-use d1 for alpha color mask
		move    alphacolor(a3),d1       get color (will only be a byte)

		move.l  #maskreg,d6
		move.l  #-1,0(a0,d6.l)          enable writes to all planes

		adda.l  d2,a2                   a2 = char start addr

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

ccharnextrow    adda.l  #width,a4               beginning of frame buffer row
		movea.l a4,a1                   make copy to be incremented
		move.l  d5,d6

		moveq   #0,d7                   clear d7 for subtract at dbra

ccharnextcol    dbra    d7,ccharnextbit         still have bits?, don't reset
		moveq   #7,d7                   all done?, reset to bit 7
		move.b  (a2)+,d3                get next byte of packed font

ccharnextbit    moveq   #0,d0                   clear d0
		btst    d7,d3                   test bit in font
		sne     d0                      set d0 if not 0

		btst    #0,highlight(a3)        inverse video?
		beq.s   ccharputchar            no, skip over invert
		not.b   d0

ccharputchar    and.b   d1,d0                   and in color mask
		move.b  d0,(a1)+                write to frame buffer
		dbra    d6,ccharnextcol
		dbra    d4,ccharnextrow

		btst    #2,highlight(a3)        underline?
		bne.s   dounderline             yes, do the underline

		jsr     misc_lockdown           enable STOP key
		rts

dounderline     btst    #0,highlight(a3)        inverse video?
		beq.s   dounderline1            no, skip over invert
		moveq   #0,d1                   make underline pen 0

dounderline1    moveq   #0,d5
		move    charw(a3),d5            d5 =  font width
		subq    #1,d5                   subtract 1 to make loop correct
dounderline2    move.b  d1,-(a1)                underline going backward
		dbra    d5,dounderline2

		jsr     misc_lockdown           enable STOP key

		rts

*
********************************************************************
*
*               cclear(xpos,ypos,nchars:shortint);
*               -- clears nchars starting at xpos, ypos
*               -- nchars + xpos must not exceed screenwidth
*               no range checking is done
*

cclear          movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0

		moveq   #0,d1
		move.l  d1,d2
		move.l  d1,d3

		movea.l (sp)+,a1                return address
		move    (sp)+,d1                d1 = number of chars to clear
		move    (sp)+,d2                d2 = y to begin at
		move    (sp)+,d3                d3 = x to begin at
		move.l  a1,-(sp)                put back the return address

		mulu    charw(a3),d1            d1 = length in pixels
		lsr     #1,d1                   length in long words
		mulu    charh(a3),d2            d2 = y in pixels
		mulu    charw(a3),d3            d3 = x in pixels

		move.l  #vramcolor1,d7
		move.l  #0,0(a0,d7.l)           set color registers to 0
		move.l  #maskreg,d7
		move.l  #-1,0(a0,d7.l)          to clear on all planes

		move.l  screen(a5),a1           base address of FB
		mulu    #width,d2               multiply row * width
		adda.l  d2,a1                   add to the FB address
		adda.l  d3,a1                   add on the column

		moveq   #0,d2
		move    charh(a3),d2            d2 = # of rows

		subq    #1,d2
		subq    #1,d1                   subtract 1 to make loop correct

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

cclearnextrow   move.l  d1,d4                   reset column counter
		movea.l a1,a2                   reset to next line
cclearnextword  move.w  #0,(a2)+                write to the display
		dbra    d4,cclearnextword       and loop
		adda.l  #width,a1               increment row by width
		dbra    d2,cclearnextrow        and loop again

		jsr     misc_lockdown           enable STOP key

		rts

*
************************************************************************
*
*    procedure shiftleft
*

cshiftleft      movea.l crtinfo(a5),a3

		moveq   #0,d1
		move.l  d1,d2
		move.l  d1,d3

		move    printw(a3),d2           calculate width of lastline
		move    charw(a3),d3
		mulu    #8,d3                   lastline ends 8 from right edge
		sub     d3,d2                   width of last line
		lsr     #1,d2                   d2 = width in words
		move    printy(a3),d3           start at upper y
		add     printh(a3),d3           add print height -> last row

		mulu    #width,d3               offset address of last line
		add     printx(a3),d3           add on column

		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d3,a1                   a1 = destination address

		move    charh(a3),d1            d1 = number of rows
		moveq   #0,d3
		move    charw(a3),d3            d3 = width of char

		subq    #1,d1                   subtract 1 to make loop correct
		subq    #1,d2

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

cshiftlnextrow  move.w  d2,d4                   reset column counter
		movea.l a1,a2
cshiftlnextword move.w  0(a2,d3),(a2)+          move from one word to the other
		dbra    d4,cshiftlnextword      and loop
		adda.l  #width,a1               next row
		dbra    d1,cshiftlnextrow       and loop

		jsr     misc_lockdown           enable STOP key

		rts

*
************************************************************************
*
*    procedure shiftright
*

cshiftright     movea.l crtinfo(a5),a3

		moveq   #0,d1
		move.l  d1,d2
		move.l  d1,d3

		move    printw(a3),d2           calculate width of lastline
		move    charw(a3),d3
		mulu    #9,d3                   lastline ends 9 from right edge
		sub     d3,d2                   width of last line
		move    printy(a3),d3           start at upper y
		add     printh(a3),d3           add print height -> last row

		mulu    #width,d3               offset address of last line
		add     printx(a3),d3           add on column
		add     d2,d3                   add width
		lsr     #1,d2                   d2 = width in words

		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d3,a1                   a1 = destination address

		move    charh(a3),d1            d1 = number of rows
		moveq   #0,d3
		move    charw(a3),d3            d3 = width of char

		subq    #1,d1                   subtract 1 to make loop correct

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

cshiftrnextrow  move.l  d2,d4                   reset column counter
		movea.l a1,a2
cshiftrnextword move.w  (a2),0(a2,d3)           move from one word to the other
		subq    #2,a2
		dbra    d4,cshiftrnextword      and loop
		adda.l  #width,a1               next row
		dbra    d1,cshiftrnextrow       and loop

		jsr     misc_lockdown           enable STOP key

		rts

*
************************************************************************
*
*    procedure cexchange( savearea: windowp; ymin, ymax, xmin, width: shortint)
*

cexchange       movea.l crtinfo(a5),a3

		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3

		movea.l (sp)+,a1                return address
		move.w  (sp)+,d2                width in pixels
		move.w  (sp)+,d3                xmin
		move.w  (sp)+,d1                ymax
		move.w  (sp)+,d0                ymin
		movea.l (sp)+,a2                pointer to the window
		move.l  a1,-(sp)                stack return address

		mulu    charh(a3),d0            d0 = first row in pixels
		mulu    charh(a3),d1            d1 = last row in pixels
		sub     d0,d1                   d1 = number of rows
		add     charh(a3),d1            don't forget last row
		subq    #1,d1                   subtract 1 to make loop correct
		mulu    charw(a3),d3            x offset in pixels

		mulu    #width,d0
		add.l   d3,d0                   d0 = address of first row

		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d0,a1                   a1 = source address

		lsr     #1,d2                   number of words per line
		subq    #1,d2                   subtract 1 to make loop correct

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

cexchangenextrow move.l d2,d4                   reset column counter
		movea.l a1,a4

cexchangenextword move.w (a4),d7                move display to temp space
		move.w  (a2),(a4)+              replace display with save
		move.w  d7,(a2)+                replace save with temp
		dbra    d4,cexchangenextword    and loop

		adda.l  #width,a1               increment row by width
		dbra    d1,cexchangenextrow     and loop again

		jsr     misc_lockdown           enable STOP key

		rts

*
************************************************************************
*
*               procedure cscrollwindow( ymin, ymax, xmin, width: shortint)
*

cscrollwindow   movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0

		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3
		movea.l (sp)+,a1                return address
		move.w  (sp)+,d2                width in characters
		move.w  (sp)+,d3                xmin in characters
		move.w  (sp)+,d1                ymax in lines
		move.w  (sp)+,d0                ymin in lines
		move.l  a1,-(sp)                stack return address

		sub     d0,d1                   d1 = number of rows - 1
		tst     d1
		beq     cscrollwinrts           1 line window
		mulu    charh(a3),d0            d0 = first row in pixels
		mulu    charh(a3),d1            d1 = number of rows in pixels

		subq    #1,d1                   subtract 1 to make loop correct
		mulu    charw(a3),d3            x offset in pixels
		mulu    charw(a3),d2            x width in pixels

		mulu    #width,d0
		add.l   d3,d0                   d0 = address of first row

		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d0,a1                   a1 = destination row

		moveq   #0,d3                   reuse d3
		move    charh(a3),d3
		mulu    #width,d3               number of rows per line height

		lsr     #2,d2                   number of longs per line

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

		move.l  #pagemode,d7            turn on page mode
		move.l  #0,0(a0,d7.l)

		btst    #3,sysflag2             test for 68040 to use move16
		bne     cscrollwin68030

*                   68040 section

		lsr     #2,d2                   number of move16's
		subq    #1,d2                   subtract 1 to make loop correct

cscrollwinnextrow move.l  d2,d4                 reset column counter
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		adda.l  d3,a4                   set up source address

cscrollwinnextword move16  (a4)+,(a2)+          move from one line to the other
		dbra    d4,cscrollwinnextword   and loop

		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollwinnextrow    and loop again

		bra     cscrollwinpageoff

*                   68030 section

cscrollwin68030 subq    #1,d2                   subtract 1 to make loop correct

cscrollwinnextrow2 move.l d2,d4                 reset column counter
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		adda.l  d3,a4                   set up source address

cscrollwinnextword2 move.l (a4)+,(a2)+          move from one line to the other
		dbra    d4,cscrollwinnextword2  and loop

		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollwinnextrow2   and loop again

cscrollwinpageoff move.l #pagemode,d7           turn off page mode
		move.l  #1,0(a0,d7.l)

		jsr     misc_lockdown           enable STOP key
cscrollwinrts   rts

*
************************************************************************
*
*               procedure cursoroff
*

cursoroff       movea.l controladdr(a5),a0
		move.l  #cursorcontrol1,d0
		ori     #cursoroffmask,0(a0,d0.l)
		rts

*
************************************************************************
*
*               procedure cursoron
*

cursoron        movea.l controladdr(a5),a0
		move.l  #cursorcontrol1,d0
		andi    #cursoronmask,0(a0,d0.l)
		rts

*
************************************************************************
*
*               procedure cscrollwinddn( ymin, ymax, xmin, width: shortint)
*

cscrollwinddn   movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0

		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3
		movea.l (sp)+,a1                return address
		move.w  (sp)+,d2                width in characters
		move.w  (sp)+,d3                xmin in characters
		move.w  (sp)+,d1                ymax in lines
		move.w  (sp)+,d0                ymin in lines
		move.l  a1,-(sp)                stack return address

		move.l  d1,d4
		sub     d0,d4                   number of lines-1
		tst     d4
		beq     cscrollwindnrts         1 line window
		mulu    charh(a3),d4            d4 = number of rows in pixels
		subq    #1,d4                   subtract 1 to make loop correct
		move.l  d4,d0                   d0 = number of rows-1

		addq    #1,d1                   1 more line down
		mulu    charh(a3),d1            d1 = last row in pixels
		subq    #1,d1                   1 row up (last row of dest)
		mulu    charw(a3),d3            x offset in pixels
		mulu    charw(a3),d2            x width in pixels

		mulu    #width,d1
		add.l   d3,d1                   d1 = address of last row

		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d1,a1                   a1 = destination row

		moveq   #0,d3                   reuse d3
		move    charh(a3),d3
		mulu    #width,d3               number of rows per line height

		lsr     #2,d2                   number of longs per line

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

		move.l  #pagemode,d7            turn on page mode
		move.l  #0,0(a0,d7.l)

		btst    #3,sysflag2             test for 68040 to use move16
		bne     cscrollwindn68030

*                   68040 section

		lsr     #2,d2                   number of move16's
		subq    #1,d2                   subtract 1 to make loop correct

cscrollwindnnextrow move.l  d2,d4               reset column counter
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		suba.l  d3,a4                   set up source address

cscrollwindnnextword move16  (a4)+,(a2)+        move from one line to the other
		dbra    d4,cscrollwindnnextword and loop

		suba.l  #width,a1               decrement row by width
		dbra    d0,cscrollwindnnextrow  and loop again

		bra     cscrollwindnpageoff

*                   68030 section

cscrollwindn68030 subq    #1,d2                 subtract 1 to make loop correct

cscrollwindnnextrow2 move.l d2,d4               reset column counter
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		suba.l  d3,a4                   set up source address

cscrollwindnnextword2 move.l (a4)+,(a2)+        move from one line to the other
		dbra    d4,cscrollwindnnextword2 and loop

		suba.l  #width,a1               increment row by width
		dbra    d0,cscrollwindnnextrow2 and loop again

cscrollwindnpageoff move.l #pagemode,d7         turn off page mode
		move.l  #1,0(a0,d7.l)

		jsr     misc_lockdown           enable STOP key
cscrollwindnrts rts

*
************************************************************************
*
*               procedure cscrolll(ymin, ymax, xmin, width: shortint)
*

cdbscrolll      movea.l crtinfo(a5),a3

		moveq   #0,d1
		move.l  d1,d2
		move.l  d1,d3
		move.l  d1,d4

		movea.l (sp)+,a1                return address
		move.w  (sp)+,d4                width (in chars)
		move.w  (sp)+,d3                xmin (in chars)
		move.w  (sp)+,d2                ymax (in lines)
		move.w  (sp)+,d1                ymin (in lines)
		move.l  a1,-(sp)                stack return address

		sub     d1,d2
		addq    #1,d2                   add 1 to lines
		mulu    charh(a3),d2            d2 = number of rows in pixels
		mulu    charh(a3),d1            d1 = first row in pixels
		mulu    charw(a3),d3            d3 = first column
		subq    #1,d4                   1 char less
		beq     cdbscrolllrts           1 column window
		mulu    charw(a3),d4            number of columns
		lsr     #2,d4                   d4 = number of long words

		movea.l screen(a5),a1
		mulu    #width,d1
		adda.l  d1,a1
		adda.l  d3,a1                   address of first pixel

		subq    #1,d2                   subtract 1 to make loop correct
		subq    #1,d4                   subtract 1 to make loop correct

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

cdbscrolllnextrow movea.l a1,a2                 set up destination address
		movea.l a2,a4
		move.l  d4,d3                   reuse d3 for counter
		adda    charw(a3),a4            set up source address

cdbscrolllnextword move.l (a4)+,(a2)+
		dbra    d3,cdbscrolllnextword

		adda.l  #width,a1
		dbra    d2,cdbscrolllnextrow

		jsr     misc_lockdown           enable STOP key
cdbscrolllrts   rts

*
************************************************************************
*
*               procedure cscrollr( ymin, ymax, xmin, width: shortint)
*

cdbscrollr      movea.l crtinfo(a5),a3

		moveq   #0,d1
		move.l  d1,d2
		move.l  d1,d3
		move.l  d1,d4

		movea.l (sp)+,a1                return address
		move.w  (sp)+,d4                width
		move.w  (sp)+,d3                xmin
		move.w  (sp)+,d2                ymax
		move.w  (sp)+,d1                ymin
		move.l  a1,-(sp)                stack return address

		sub     d1,d2
		addq    #1,d2                   add 1 to lines
		mulu    charh(a3),d2            d2 = number of rows
		mulu    charh(a3),d1            d1 = first row
		mulu    charw(a3),d3            d3 = first column
		subq    #1,d4                   1 less char
		beq     cdbscrollrrts           1 column window
		mulu    charw(a3),d4            number of columns

		move.l  screen(a5),a1
		mulu    #width,d1
		adda.l  d1,a1
		adda.l  d3,a1
		adda.l  d4,a1                   address of first pixel
		addq    #4,a1                   subtract later with pre-dec

		lsr     #2,d4                   d4 = number of long words

		subq    #1,d2                   subtract 1 to make loop correct

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

cdbscrollrnextrow movea.l a1,a2                 set up source address
		movea.l a2,a4
		move.l  d4,d3                   reuse d3 for counter
		adda    charw(a3),a4            set up destination address

cdbscrollrnextword move.l -(a2),-(a4)
		dbra    d3,cdbscrollrnextword

		adda.l  #width,a1
		dbra    d2,cdbscrollrnextrow

		jsr     misc_lockdown           enable STOP key
cdbscrollrrts   rts

*
*********************************************************************
*
*               procedure cclearall
*               clears all of visible area except typeahead
*

cclearall       movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0

		moveq   #0,d2
		move.l  d1,d3

		movem.l d0-d7/a0-a5,-(sp)
		jsr     misc_lockup             disable STOP key
		movem.l (sp)+,d0-d7/a0-a5

		move.l  #blockmode,d6
		move.l  #0,0(a0,d6.l)           turn on block mode
		move.l  #vramcolor1,d5
		move.l  #0,0(a0,d5.l)           set color registers to 0
		move.l  #maskreg,d5
		move.l  #-1,0(a0,d5.l)          to clear on all planes

		move.l  screen(a5),a1           base address of FB
		move    disph(a3),d2            get width and height in pixels
		move    dispw(a3),d3
		lsr     #4,d3                   change to number of words
		subq    #1,d2
		subq    #1,d3
		movea.l a1,a2                   make a copy for reference

nextrow         move.l  d3,d4                   reset column counter
		movea.l a2,a1                   reset to beginning of next line

nextword        move.w  #-1,(a1)+               write to the display
		dbra    d4,nextword             and loop

		adda.l  #widthdiv16,a2          increment row by width
		dbra    d2,nextrow              and loop again

		move.l  #1,0(a0,d6.l)           turn off block mode

		jsr     misc_lockdown           enable STOP key

		rts

*
************************************************************************
*
*               procedure csetcolormap(index,red,green,blue:integer)
*               Set a color map entry
*               To minimize flicker, wait for BEECH blue register
*               to go not busy. Then write the index, red, and
*               green data to the DAC. Then write the blue data
*               to BEECH. BEECH will send the blue data to the
*               DAC and the DAC will then update.
*

csetcolormap    movea.l controladdr(a5),a0
		movea.l (sp)+,a1                return address
		move.l  (sp)+,d3
		move.l  (sp)+,d2
		move.l  (sp)+,d1
		move.l  (sp)+,d0                get data off stack as longs
		move.l  a1,-(sp)                stack return address

		move.l  #blueregimage,d5

ccheckblue      btst    #0,2(a0,d5.l)           check for color map busy
		bne.s   ccheckblue              loop until bit is clear
		move.l  #dacimagewrite,d6
		move.b  d0,0(a0,d6.l)           write the index to the DAC
		move.b  d1,4(a0,d6.l)           then red to the DAC
		move.b  d2,4(a0,d6.l)           then green to the DAC
		move.b  d3,3(a0,d5.l)           then blue to BEECH
		rts

*
************************************************************************
*
*               procedure  csetreg(register:integer; value:shortint)
*

csetreg         movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0
		movea.l (sp)+,a1                return address
		move.w  (sp)+,d2                register value
		move.l  (sp)+,d1                register number
		move.l  a1,-(sp)                stack return address
		rts

*
************************************************************************
*
*               procedure  csavewoodenv(anyvar buffer:window)
*

csavewoodenv    movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0
		movea.l (sp)+,a1                return address
		movea.l (sp)+,a2
		move.l  a1,-(sp)                stack return address
		rts

*
************************************************************************
*
*               procedure  crestorewoodenv(anyvar buffer:window)
*

crestorewoodenv movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0
		movea.l (sp)+,a1                return address
		movea.l (sp)+,a2
		move.l  a1,-(sp)                stack return address
		rts

*
************************************************************************
*
*               function   cromshort(offset:integer):shortint
*

cromshort   equ      *
	    movea.l  controladdr(a5),a0
	    movea.l  (sp)+,a1           return address
	    adda.l   (sp)+,a0           offset
	    movep    0(a0),d0
	    move     d0,(sp)            store on stack as function value
	    jmp      (a1)

*
************************************************************************
*
*               procedure  csetupcchar
*

csetupcchar     movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0
		rts

*
************************************************************************
*
*               procedure  cprepdumpline(mybuf:windowp; size:shortint;
*                                        rowstart:anyptr);
*
* Takes the data in the frame buffer at rowstart, for size*8 bytes, and
* preps it for graphic output by creating an array of size number of bytes
* which has 1 bits where there are non-0 pixels in rowstart array, and 0 bits
* elsewhere. This is the format of PCL graphics data. The mybuf pointer
* is actually a pointer 8 bytes into a pascal string structure.
* the routine detects the last non-0 output byte, and adjusts both the
* strlen of the Pascal string, and the ASCII numeric string to that. The
* adjustment is done to minimize data transmission to printer, especially
* for RS232 printers.
* The ASCII string header looks like #27'*bxxxW' where xxx is a
* 3-digit number, which reflects the length of FOLLOWING binary data.

* called by dumpg in CATCRT - SFB/LAF Jan 26, '88

cprepdumpline   equ *
		move.l  (sp)+,a0        return address
		move.l  (sp)+,a3        rowstart
		move.w  (sp)+,d0        size
		move.l  (sp),a1         outbufptr, leave on stack for later
		move.w  d0,d1           copy for adjusting strlen, etc later
		ext.l   d1              ensure MSBs are 0 for later divide
		move.l  d1,d5           keeps track of last non-zero outbuf char
		movea.l crtinfo(a5),a2  get access to crt description
		bra.s   initcharbuf     start up the process

preploop        equ    *
		move.b  (a3)+,d2        prepare to test non-zero pixel
		and.b   planemask+3(a2),d2 mask out "floating" bits in pixel
		subi.b  #1,d2           will set X in CCR if (a3) is zero
		roxl.b  #1,d3           put X into output char buf LSB
		dbra    d4,preploop     do it 8 times per out char

		not.b   d3              because X was wrong sense
		move.b  d3,(a1)+        put character into outbuf
		beq.s   initcharbuf     if it wasn't empty, then
		move.w  d0,d5           keep track of last non-empty char

initcharbuf     equ *
		move.w  #7,d4           8 bits per output char
		dbra    d0,preploop     n chars/line

		move.l  (sp)+,a1        recover initial outbufptr, and clr stack
		sub.w   d5,d1
		bne.s   fixstrlen       line has something on it
		moveq   #1,d1        must have min of 1 to force slew (we wish!)

fixstrlen       equ   *
		move.b  d1,-8(a1)       stick correct length in strlen of outbuf
		addi.b  #7,-8(a1)       and adjust for #27'*bxxxW' header

* compute ASCII representation of d1 into longword, with trailing 'W'

		divu    #10,d1          remainder->upper word of d1
		move.w  d1,d2
		ext.l   d2              clear MSBs of d2
		divu    #10,d2          remainder->upper word of d2
		swap    d2
		rol.w   #8,d2
		clr.w   d1              clear LSBs
		swap    d1
		or.l    d2,d1
		ori.l   #'000',d1       attach ASCII numeric headers
		rol.l   #8,d1           justify for copy to outbuf
		ori.b   #'W',d1         now have 'xxxW' in longword
		move.l  d1,-4(a1)       copy to outbuf

		jmp     (a0)            and return


*
************************************************************************
*
*               procedure  setupcchar
*

setupcchar      movea.l crtinfo(a5),a3
		movea.l controladdr(a5),a0
		rts

*
************************************************************************
*               end of code
@


55.8
log
@
pws2rcs automatic delta on Mon Nov  4 13:45:04 MST 1991
@
text
@@


55.7
log
@Fix ed bug that kept dump graphics from working. Removed unused code
in cprepdumpline - CFB
@
text
@d1 1
a1 1
             page
d28 6
a33 6
                def     cscrollup,cscrolldown,cupdatecursor,cchar,cclear
                def     cbuildtable,cshiftleft,cshiftright
                def     cexchange,cscrollwindow,cursoroff
                def     cscrollwinddn,cdbscrolll,cdbscrollr,cclearall
                def     csetcolormap,csetreg,csavewoodenv,crestorewoodenv
                def     cromshort,csetupcchar,cprepdumpline
d35 1
a35 1
                def     setupcchar
d37 1
a37 1
                rorg.l 0
d39 2
a40 2
                refa    woodcutdvr,sysdevs
                refa    misc_lockup,misc_lockdown
d42 2
a43 2
                nosyms
                sprint
d203 1
a203 1
sysflag2	equ	$FFFFFEDA
d207 5
a211 5
*					kludge because MOVE16 is 16 byte aligned
*					and we don't know where zero16 will be
		dc.l	0,0,0,0	 	16 bytes of zeros
zero16		dc.l	0,0,0,0	 	16 bytes of zeros
		dc.l	0,0,0,0	 	16 bytes of zeros
d213 2
a214 2
currentintlevel ds.l	1		current interrupt level
hires           ds.l	1		hires flag (0 med or low, 1 high)
d226 3
a228 3
                tst.b   hascolor(a5)          color?
                bne     cmapstart             yes, jump over greyscale
                lea     gmaptable,a1          initialize the greyscale color map
d230 3
a232 3
                move.l  d1,d2
                move.l  d1,d3
                move.l  d1,d4
d234 9
a242 9
                move.b  (a1)+,d3
                move.b  (a1)+,d4
                jsr     cmapenter             call the color map entry routine
                addq    #1,d1                 bump cmap pointer value
                cmp     #16,d1                have we done 16 yet?
                bne.s   cmaploop1             if not then continue
                moveq   #-1,d2                set entries 16-255 to white
                move.l  d2,d3
                move.l  d2,d4
d244 3
a246 3
                addq    #1,d1
                cmp     #256,d1                 done with cmap init?
                bne.s   cmaploop2
d248 3
a250 3
                move.l  #blueregcursor,d6
                move.l  #colormapvalue,d7
                move.l  #dacoverlaywrite,d5
d253 5
a257 5
                bne.s   cursorcmapwait          loop till bit is clear
                move.b  #2,0(a0,d5.l)           write the index to the DAC
                move.b  #0,0(a0,d7.l)           then red to the DAC
                move.b  #0,0(a0,d7.l)           then green to the DAC
                move.b  #0,3(a0,d6.l)           then blue to BEECH
d260 6
a265 6
                bne.s   cursorcmapwait2         loop till bit is clear
                move.b  #3,0(a0,d5.l)           write the index to the DAC
                move.b  #255,0(a0,d7.l)         then red to the DAC
                move.b  #255,0(a0,d7.l)         then green to the DAC
                move.b  #255,3(a0,d6.l)         then blue to BEECH
                rts
d268 2
a269 2
                move.l  #dacimagewrite,d5
                move.l  #colormapvalue,d7
d272 5
a276 5
                bne.s   cmapwait                loop till bit is clear
                move.b  d1,0(a0,d5.l)           write the index to the DAC
                move.b  d2,0(a0,d7.l)           then red to the DAC
                move.b  d3,0(a0,d7.l)           then green to the DAC
                move.b  d4,3(a0,d6.l)           then blue to BEECH
d278 1
a278 1
                rts                             done with cmap entry write
d291 2
a292 2
                moveq   #0,d0
                move.l  d0,d1
d294 7
a300 7
                move    charw(a3),d0
                move    charh(a3),d1
                addq    #7,d0                   round off to the nearest byte
                andi.b  #$f0,d0                 to fix HIRES       24OCT91 - CFB
                mulu    d0,d1                   number of pixels/char
                lsr     #3,d1                   number of bytes/char
                subq    #1,d1                   subtract 1 to make loop correct
d304 3
a306 3
                addq.l  #2,a2                   look at next font byte
                dbra    d5,unpackrow            and loop till bytes in char done
                dbra    d3,unpackchar           loop till all chars done
d308 1
a308 1
                rts
d318 8
a325 8
                moveq    #0,d0
                move.b   2(a1),d0           get word count to initialize
                movep    4(a1),d1           form destination offset
                add.l    a0,d1              d1 points to dest addr
                lea      8(a1),a2           a2 points to first data byte
                movea.l  d1,a4              a4 points to destination
                btst     #0,(a1)            is this a bit test block?
                bne.s    ginitbtst          if so go handle it
d327 4
a330 4
                move.w   d1,(a4)+           move data to the destination addr
                btst     #6,(a1)            increment data pointer
                bne.s    ginit1             based on control byte
                addq     #4,a2
d332 4
a335 4
                btst     #7,(a1)            was this last block?
                bne.s    ginitdone          yes -- go return
                btst     #6,(a1)            adjust data pointer
                beq.s    ginit2             to point to next init block
d338 1
a338 1
                bra      ginitblock         do the initialize
d341 1
a341 1
                move.b   2(a2),d2           d2 = bit # to test
d343 3
a345 3
                btst     #0,(a2)            check for sense of test
                bne.s    ginittst3          comp if waiting for 0
                not      d3
d347 4
a350 4
                beq      ginittst2          if not 1 then loop
                btst     #7,(a1)            was this last block?
                bne.s   ginitdone          if so then return
                bra      ginit3             else do next block
d361 9
a369 9
                movea.l crtinfo(a5),a3          crtparamrec
                movep   initoffset(a0),d1       form pointer to init block
                movea.l a0,a1                   make copy of ROM start addr
                adda.l  d1,a1                   a1 points to init info now
                jsr     ginitblock              call the initialization routine
                clr.b   hascolor(a5)            clear color flag
                cmpi.b  #17,displayid(a0)       greyscale?
                bgt     cframeaddr              yes, don't set color
                st      hascolor(a5)            set for color
d371 2
a372 2
                adda.l  #framebuffer,a1         add offset to frame buffer
                move.l  a1,screen(a5)           form frame buffer addr
d374 7
a380 7
                move.b  framecount(a0),d0       d0=# of planes in system
                beq.s   cnumplanes              if zero then read planes
                moveq   #8,d1                   else make the mask up
                moveq   #$ff,d2
                sub     d0,d1                   d1 has shift count
                lsr.b   d1,d2                   after shift d2 has mask
                bra.s   csetplanes              go setup planemask
d383 3
a385 3
                movea.l screen(a5),a1           addr of fb in a1
                move.b  #$FF,(a1)               write all 1's
                move.b  (a1),d2                 read it back to get plane mask
d387 1
a387 1
                move.b  d2,3+planemask(a3)      save as plane mask
d390 19
a408 19
                move.l  d0,hires                clear hires flag
                move    d0,dispx(a3)            set positions to (0,0)
                move    d0,dispy(a3)
                move    d0,printx(a3)
                move    d0,printy(a3)
                movep.w framewidth(a0),d2       get width from ROM
                move    d2,fbwidth(a3)
                movep.w displaywidth(a0),d2    set visible width as window width
                movep.w frameheight(a0),d2      get height from ROM
                move    d2,fbheight(a3)
                movep.w displayheight(a0),d2
                move    d2,disph(a3)
                movep.w displaywidth(a0),d2
                move    d2,dispw(a3)
                move    d2,printw(a3)
                cmp     #1024,d2
                beq.s   setuplcc
                cmp     #640,d2                 no offscreen available
                beq.s   setupvga
d411 6
a416 6
                move    #1280,offx(a3)
                move    #0,offy(a3)
                move    #768,offw(a3)
                move    #1024,offh(a3)
                st	hires                   set hires flag
                bra.s   donesetupoff
d418 6
a423 6
setuplcc        equ	*                       no offscreen available
                move    #0,offx(a3)
                move    #0,offy(a3)
                move    #0,offw(a3)
                move    #0,offh(a3)
                bra.s   donesetupoff
d426 4
a429 4
                move    #640,offx(a3)           and at the bottom. right larger
                move    #0,offy(a3)
                move    #384,offw(a3)
                move    #512,offh(a3)
d432 1
a432 1
                jsr     loadcmap                load the color map
d434 4
a437 4
                moveq   #0,d0
                move.l  d0,d1
                move.l  d0,d2
                move.l  d0,d7
d439 5
a443 5
                movep   fontoffset(a0),d1       get font info offset
                move.b  (a0,d1.w),d7            d3 = number of fonts
                subq    #1,d7                   subtract 1 to make loop correct
                lea     4(a0,d1.w),a1           a1 = address of font offset
                lea     (fontstorage),a4        a4 = address of font storage
d446 1
a446 1
                lea     0(a0,d2.l),a2           a2 = address of font info
d448 5
a452 5
                moveq   #0,d1                   clear d1 for re-use
                move.b  (a2),d0                 d0 = font height
                move.b  2(a2),d1                d1 = font width
                move    d0,charh(a3)            store them for later use
                move    d1,charw(a3)
d454 3
a456 3
                moveq   #0,d3
                move.b  8(a2),d3                get last char value
                sub.b   6(a2),d3                subtract first char value
d459 2
a460 2
                adda.l  #10,a2                  a2 now points to first char
                jsr     unpkroman               go unpack it
d462 2
a463 2
                adda.l  #6,a1                   a1 = address of next font
                dbra    d7,getfontinfo
d466 1
a466 1
                jsr     cursoroff
d468 1
a468 1
                move.l  #cursorcontrol1,d2
d470 2
a471 2
                move.l  #colormask,d0           write to the cursor image
                move.l  #1023,d1                clear the entire cursor
d474 4
a477 4
                bne.s   buildcursorclr
                move    #0,0(a0,d0.l)
                addq.l  #4,d0
                dbra    d1,buildcursorclr
d479 2
a480 2
                move.l  #colormask,d0           create cursor image
                moveq   #1,d4                   2 rows
d483 1
a483 1
                move.l  d0,d1                   beginning of row
d485 7
a491 7
                bne.s   buildcursorclr2
                move    #-1,0(a0,d1.l)
                addq.l  #4,d1                   next 4 pixels
                dbra    d3,buildcursorclr2
                tst     hires
                beq     buildcursorclr1
                move    #$000c,0(a0,d1.l)
d493 1
a493 1
                dbra    d4,buildcursorclr3
d495 2
a496 2
                move.l  #visiblemask,d0         write to the cursor mask
                move.l  #1023,d1                clear the entire mask
d499 4
a502 4
                bne.s   buildcursorvis
                move    #0,0(a0,d0.l)
                addq.l  #4,d0
                dbra    d1,buildcursorvis
d504 2
a505 2
                move.l  #visiblemask,d0         create "cookie cutter"
                moveq   #1,d4                   2 rows
d508 1
a508 1
                move.l  d0,d1                   beginning of row
d510 7
a516 7
                bne.s   buildcursorvis2
                move    #-1,0(a0,d1.l)
                addq.l  #4,d1                   next 4 pixels
                dbra    d3,buildcursorvis2
                tst     hires
                beq     buildcursorvis1
                move    #$000c,0(a0,d1.l)
d518 1
a518 1
                dbra    d4,buildcursorvis3
d520 2
a521 2
                move.l  #cursorcontrol0,d0
                move.l  #0,0(a0,d0.l)           clear y-clip LSB's
d523 2
a524 2
                move.l  #cursorcontrol1,d0
                andi    #$000c0,0(a0,d0.l)      clear y-clip MSB's
d526 1
a526 1
                jsr     cursoron
d528 4
a531 4
                move.l  #readmask,d2
                move.b  #255,0(a0,d2)           turn on all planes
                
                rts
d539 16
a554 16
                dc.b    0,0,0                   0
                dc.b    255,255,255             1
                dc.b    255,0,0                 2
                dc.b    255,255,0               3
                dc.b    0,255,0                 4
                dc.b    0,255,255               5
                dc.b    0,0,255                 6
                dc.b    255,0,255               7
                dc.b    0,0,0                   8
                dc.b    204,187,51              9
                dc.b    51,170,119              10
                dc.b    136,102,170             11
                dc.b    204,68,102              12
                dc.b    255,102,51              13
                dc.b    255,119,0               14
                dc.b    221,136,68              15
d557 17
a573 17
                dc.b    0,0,0                   0
                dc.b    0,255,0                 1
                dc.b    0,239,0                 2
                dc.b    0,233,0                 3
                dc.b    0,207,0                 4
                dc.b    0,191,0                 5
                dc.b    0,175,0                 6
                dc.b    0,159,0                 7
                dc.b    0,143,0                 8
                dc.b    0,128,0                 9
                dc.b    0,112,0                10
                dc.b    0,96,0                 11
                dc.b    0,80,0                 12
                dc.b    0,64,0                 13
                dc.b    0,48,0                 14
                dc.b    0,32,0                 15
                dc.b    0,16,0                 16
d584 1
a584 1
                movea.l controladdr(a5),a0
d586 4
a589 4
                moveq   #0,d0
                move.l  d0,d1
                move.l  d0,d2
                move.l  d0,d3
d591 5
a595 5
                move    printy(a3),d0
                move    printh(a3),d1           set up window size
                sub     charh(a3),d1            one less row
                sub     d0,d1                   d1 = number of rows
                subq    #1,d1                   subtract 1 to make loop correct
d597 1
a597 1
                mulu    #width,d0               d0 = address of first row
d599 2
a600 2
                movea.l screen(a5),a1           get base address of framebuffer
                adda.l  d0,a1                   a1 = destination row
d602 2
a603 2
                move    charh(a3),d3
                mulu    #width,d3               number of rows per line height
d605 2
a606 2
                move    printw(a3),d2
                lsr     #2,d2                   number of longs per line
d608 3
a610 3
                movem.l d0-d7/a0-a5,-(sp)
                jsr     misc_lockup             disable STOP key
                movem.l (sp)+,d0-d7/a0-a5
d612 2
a613 2
                move.l  #pagemode,d7		turn on page mode
                move.l  #0,0(a0,d7.l)
d615 2
a616 2
		btst	#3,sysflag2		test for 68040 to use move16
		bne	cscroll68030
d620 2
a621 2
		lsr	#2,d2			number of move16's
                subq    #1,d2			subtract 1 to make loop correct
d624 3
a626 3
                movea.l a1,a2                   set up destination address
                movea.l a1,a4
                adda.l  d3,a4                   set up source address
d629 1
a629 1
                dbra    d4,cscrollnextword      and loop
d631 2
a632 2
                adda.l  #width,a1               increment row by width
                dbra    d1,cscrollnextrow       and loop again
d634 2
a635 2
                move    charh(a3),d1            set up to clear next line
                subq    #1,d1
d638 1
a638 1
                movea.l a1,a2
d641 1
a641 1
                dbra    d4,cscrollclrword       and loop
d643 2
a644 2
                adda.l  #width,a1               increment row by width
                dbra    d1,cscrollclrrow        and loop again
d646 1
a646 1
                bra	cscrollpageoff
d650 1
a650 1
cscroll68030    subq    #1,d2			subtract 1 to make loop correct
d653 3
a655 3
                movea.l a1,a2                   set up destination address
                movea.l a1,a4
                adda.l  d3,a4                   set up source address
d658 1
a658 1
                dbra    d4,cscrollnextword2     and loop
d660 2
a661 2
                adda.l  #width,a1               increment row by width
                dbra    d1,cscrollnextrow2      and loop again
d663 2
a664 2
                move    charh(a3),d1            set up to clear next line
                subq    #1,d1
d667 1
a667 1
                movea.l a1,a2
d670 1
a670 1
                dbra    d4,cscrollclrword2      and loop
d672 2
a673 2
                adda.l  #width,a1               increment row by width
                dbra    d1,cscrollclrrow2       and loop again
d675 2
a676 2
cscrollpageoff  move.l  #pagemode,d7		turn off page mode
                move.l  #1,0(a0,d7.l)
d678 1
a678 1
                jsr     misc_lockdown           enable STOP key
d690 1
a690 1
                movea.l controladdr(a5),a0
d692 4
a695 4
                moveq   #0,d0
                move.l  d0,d1
                move.l  d0,d2
                move.l  d0,d3
d697 5
a701 5
                move    printh(a3),d0           get last row
                sub     charh(a3),d0            start one line height up
                move    d0,d1                   set up window size
                sub     printy(a3),d1           d1 = number of rows
                subq    #1,d1                   subtract 1 to make loop correct
d703 1
a703 1
                mulu    #width,d0               d0 = address of last row
d705 2
a706 2
                movea.l screen(a5),a1           get base address of framebuffer
                adda.l  d0,a1                   a1 = source row
d708 2
a709 2
                move    charh(a3),d3
                mulu    #width,d3               number of rows per line height
d711 2
a712 2
                move    printw(a3),d2
                lsr     #2,d2                   number of longs per line
d714 3
a716 3
                movem.l d0-d7/a0-a5,-(sp)
                jsr     misc_lockup             disable STOP key
                movem.l (sp)+,d0-d7/a0-a5
d718 2
a719 2
                move.l  #pagemode,d7		turn on page mode
                move.l  #0,0(a0,d7.l)
d721 2
a722 2
		btst	#3,sysflag2		test for 68040 to use move16
		bne	cscrolld68030
d726 2
a727 2
		lsr	#2,d2			number of move16's
                subq    #1,d2
d730 3
a732 3
                movea.l a1,a2
                movea.l a1,a4
                adda.l  d3,a4                   set up source address
d735 1
a735 1
                dbra    d4,cscrolldnextword     and loop
d737 2
a738 2
                suba.l  #width,a1               decrement row by width
                dbra    d1,cscrolldnextrow      and loop again
d740 2
a741 2
                move    charh(a3),d1            set up to clear next line
                subq    #1,d1
d744 1
a744 1
                movea.l a1,a2
d747 1
a747 1
                dbra    d4,cscrolldclrword      and loop
d749 2
a750 2
                adda.l  #width,a1               decrement row by width
                dbra    d1,cscrolldclrrow       and loop again
d752 1
a752 1
                bra	cscrolldpageoff
d759 3
a761 3
                movea.l a1,a2
                movea.l a1,a4
                adda.l  d3,a4                   set up source address
d764 1
a764 1
                dbra    d4,cscrolldnextword2    and loop
d766 2
a767 2
                suba.l  #width,a1               decrement row by width
                dbra    d1,cscrolldnextrow2     and loop again
d769 2
a770 2
                move    charh(a3),d1            set up to clear next line
                subq    #1,d1
d773 1
a773 1
                movea.l a1,a2
d776 1
a776 1
                dbra    d4,cscrolldclrword2     and loop
d778 2
a779 2
                adda.l  #width,a1               decrement row by width
                dbra    d1,cscrolldclrrow2      and loop again
d781 2
a782 2
cscrolldpageoff move.l  #pagemode,d7		turn off page mode
                move.l  #1,0(a0,d7.l)
d786 1
a786 1
                rts
d795 6
a800 6
                movea.l controladdr(a5),a0
                moveq   #0,d0                   clear some registers
                move.l  d0,d1
                move.l  d0,d2
                move.l  d0,d3
                move.l  d0,d4
d802 4
a805 4
                movea.l (sp)+,a4                a4 = return addr
                move    (sp)+,d1                y in chars
                move    (sp)+,d2                x in chars
                move.l  a4,-(sp)                stack return address
d807 6
a812 6
                mulu    charh(a3),d1
                add     charh(a3),d1            put cursor under the character
                subq    #1,d1
                move.l  #timingv0,d3
                add     0(a0,d3.l),d1           add yoffset (see WOODCUT ERS)
                move    d1,ycurs(a5)            y position in pixels
d814 7
a820 7
                mulu    charw(a3),d2
                move.l  #timingh0,d3
                move    0(a0,d3.l),d4
                subq    #4,d4
                lsl     #2,d4                   multiply by 4
                add     d4,d2                   add xoffset (see WOODCUT ERS)
                move    d2,xcurs(a5)            x position in pixels
d824 3
a826 3
                move.l  #cursorcontrol1,d0
                btst    #2,1(a0,d0.l)
		bne	donttoggle
d828 6
a833 6
                jsr     cursoroff
                move.l  #cursorposition,d3      update cursor position
                move    d1,0(a0,d3.l)
                move    d2,2(a0,d3.l)
                jsr     cursoron
                rts 
d836 2
a837 2
                move    d1,0(a0,d3.l)
                move    d2,2(a0,d3.l)
d839 1
a839 1
                rts
d847 2
a848 2
                movea.l controladdr(a5),a0
                movea.l (sp)+,a1                get the return address
d850 5
a854 5
                moveq   #0,d0                   clear some registers
                move.l  d0,d1
                move.l  d0,d2
                move.l  d0,d4
                move.l  d0,d5
d856 4
a859 4
                move    (sp)+,d0                y coordinate in rows
                move    (sp)+,d1                x coordinate in chars
                move    (sp)+,d2                character to write
                move.l  a1,-(sp)                put the return address back
d861 3
a863 3
                lea     (fontstorage),a2        get font base address
                move    charh(a3),d4            d4 =  font height
                move    charw(a3),d5            d5 =  font width
d865 2
a866 2
                mulu    d4,d0                   d0 = y coordinate in pixels
                mulu    d5,d1                   d1 = x coordinate in pixels
d868 5
a872 5
                mulu    d4,d2                   char # times height
                addq    #7,d5                   round off to the nearest byte
                andi.b  #$f0,d5                 to fix HIRES       24OCT91 - CFB
                mulu    d5,d2                   times width
                lsr.l   #3,d2                   / 8 -> font offset
d874 4
a877 4
                move.l  d0,d3                   start with row number
                mulu    #width,d3               times row width
                add     d1,d3                   plus column number
                addi.l  #framebuffer,d3         plus frame buffer base
d879 6
a884 6
                movea.l a0,a4
                adda.l  d3,a4                   now a4 has address of FB
                suba    #width,a4               add back later
                subq    #1,d4                   subtract 1 to make loop correct
                move    charw(a3),d5            d5 =  font width
                subq    #1,d5
d886 2
a887 5
		moveq	#0,d1                   re-use d1 for alpha color mask
		move	alphacolor(a3),d1	get color (will only be a byte)
		
                move.l  #maskreg,d6
                move.l  #-1,0(a0,d6.l)          enable writes to all planes
d889 2
a890 1
                adda.l  d2,a2                   a2 = char start addr
d892 3
a894 1
                movem.l d0-d7/a0-a5,-(sp)
d896 1
a896 1
                movem.l (sp)+,d0-d7/a0-a5
d899 2
a900 2
                movea.l a4,a1                   make copy to be incremented
                move.l  d5,d6
d902 1
a902 1
                moveq   #0,d7                   clear d7 for subtract at dbra
d905 2
a906 2
                moveq   #7,d7                   all done?, reset to bit 7
                move.b  (a2)+,d3                get next byte of packed font
d909 2
a910 2
                btst    d7,d3                   test bit in font
                sne     d0                      set d0 if not 0
d912 3
a914 8
                btst    #0,highlight(a3)        inverse video?
                beq.s   ccharputchar		no, skip over invert
		not.b	d0
		
ccharputchar	and.b	d1,d0			and in color mask
		move.b	d0,(a1)+                write to frame buffer
                dbra    d6,ccharnextcol
                dbra    d4,ccharnextrow
d916 5
d922 1
a922 1
		bne.s   dounderline		yes, do the underline
d924 2
a925 2
                jsr     misc_lockdown           enable STOP key
                rts
d927 3
a929 3
dounderline	btst    #0,highlight(a3)        inverse video?
                beq.s   dounderline1		no, skip over invert
		moveq	#0,d1			make underline pen 0
d932 3
a934 3
                move    charw(a3),d5            d5 =  font width
                subq    #1,d5                   subtract 1 to make loop correct
dounderline2	move.b  d1,-(a1)		underline going backward
d937 1
a937 1
                jsr     misc_lockdown           enable STOP key
d939 1
a939 1
                rts
d951 1
a951 1
                movea.l controladdr(a5),a0
d953 3
a955 3
                moveq   #0,d1
                move.l  d1,d2
                move.l  d1,d3
d957 5
a961 5
                movea.l (sp)+,a1                return address
                move    (sp)+,d1                d1 = number of chars to clear
                move    (sp)+,d2                d2 = y to begin at
                move    (sp)+,d3                d3 = x to begin at
                move.l  a1,-(sp)                put back the return address
d963 4
a966 4
                mulu    charw(a3),d1            d1 = length in pixels
                lsr     #1,d1                   length in long words
                mulu    charh(a3),d2            d2 = y in pixels
                mulu    charw(a3),d3            d3 = x in pixels
d968 4
a971 4
                move.l  #vramcolor1,d7
                move.l  #0,0(a0,d7.l)           set color registers to 0
                move.l  #maskreg,d7
                move.l  #-1,0(a0,d7.l)          to clear on all planes
d973 4
a976 4
                move.l  screen(a5),a1           base address of FB
                mulu    #width,d2               multiply row * width
                adda.l  d2,a1                   add to the FB address
                adda.l  d3,a1                   add on the column
d978 5
a982 5
                moveq   #0,d2
                move    charh(a3),d2            d2 = # of rows
                
                subq    #1,d2
                subq    #1,d1                   subtract 1 to make loop correct
d984 3
a986 3
                movem.l d0-d7/a0-a5,-(sp)
                jsr     misc_lockup             disable STOP key
                movem.l (sp)+,d0-d7/a0-a5
d989 1
a989 1
                movea.l a1,a2                   reset to next line
d991 3
a993 3
                dbra    d4,cclearnextword       and loop
                adda.l  #width,a1               increment row by width
                dbra    d2,cclearnextrow        and loop again
d995 1
a995 1
                jsr     misc_lockdown           enable STOP key
d997 1
a997 1
                rts
d1007 3
a1009 3
                moveq   #0,d1
                move.l  d1,d2
                move.l  d1,d3
d1011 7
a1017 7
                move    printw(a3),d2           calculate width of lastline
                move    charw(a3),d3
                mulu    #8,d3                   lastline ends 8 from right edge
                sub     d3,d2                   width of last line
                lsr     #1,d2                   d2 = width in words
                move    printy(a3),d3           start at upper y
                add     printh(a3),d3           add print height -> last row
d1019 2
a1020 2
                mulu    #width,d3               offset address of last line
                add     printx(a3),d3           add on column
d1022 2
a1023 2
                movea.l screen(a5),a1           get base address of framebuffer
                adda.l  d3,a1                   a1 = destination address
d1025 3
a1027 3
                move    charh(a3),d1            d1 = number of rows
                moveq   #0,d3
                move    charw(a3),d3            d3 = width of char
d1029 2
a1030 2
                subq    #1,d1                   subtract 1 to make loop correct
                subq    #1,d2
d1032 3
a1034 3
                movem.l d0-d7/a0-a5,-(sp)
                jsr     misc_lockup             disable STOP key
                movem.l (sp)+,d0-d7/a0-a5
d1037 1
a1037 1
                movea.l a1,a2
d1039 3
a1041 3
                dbra    d4,cshiftlnextword      and loop
                adda.l  #width,a1               next row
                dbra    d1,cshiftlnextrow       and loop
d1043 1
a1043 1
                jsr     misc_lockdown           enable STOP key
d1045 1
a1045 1
                rts
d1055 3
a1057 3
                moveq   #0,d1
                move.l  d1,d2
                move.l  d1,d3
d1059 6
a1064 6
                move    printw(a3),d2           calculate width of lastline
                move    charw(a3),d3
                mulu    #9,d3                   lastline ends 9 from right edge
                sub     d3,d2                   width of last line
                move    printy(a3),d3           start at upper y
                add     printh(a3),d3           add print height -> last row
d1066 4
a1069 4
                mulu    #width,d3               offset address of last line
                add     printx(a3),d3           add on column
		add	d2,d3			add width
                lsr     #1,d2                   d2 = width in words
d1071 2
a1072 2
                movea.l screen(a5),a1           get base address of framebuffer
                adda.l  d3,a1                   a1 = destination address
d1074 3
a1076 3
                move    charh(a3),d1            d1 = number of rows
                moveq   #0,d3
                move    charw(a3),d3            d3 = width of char
d1078 1
a1078 1
                subq    #1,d1                   subtract 1 to make loop correct
d1080 3
a1082 3
                movem.l d0-d7/a0-a5,-(sp)
                jsr     misc_lockup             disable STOP key
                movem.l (sp)+,d0-d7/a0-a5
d1085 1
a1085 1
                movea.l a1,a2
d1087 4
a1090 4
		subq	#2,a2
                dbra    d4,cshiftrnextword      and loop
                adda.l  #width,a1               next row
                dbra    d1,cshiftrnextrow       and loop
d1092 1
a1092 1
                jsr     misc_lockdown           enable STOP key
d1094 1
a1094 1
                rts
d1104 4
a1107 4
		moveq	#0,d0
		move.l	d0,d1
		move.l	d0,d2
		move.l	d0,d3
d1109 7
a1115 7
                movea.l (sp)+,a1                return address
                move.w  (sp)+,d2                width in pixels
                move.w  (sp)+,d3                xmin
                move.w  (sp)+,d1                ymax
                move.w  (sp)+,d0                ymin
                movea.l (sp)+,a2                pointer to the window
                move.l  a1,-(sp)                stack return address
d1117 6
a1122 6
		mulu	charh(a3),d0		d0 = first row in pixels
		mulu	charh(a3),d1		d1 = last row in pixels
                sub     d0,d1                   d1 = number of rows
		add	charh(a3),d1		don't forget last row
                subq    #1,d1                   subtract 1 to make loop correct
		mulu	charw(a3),d3		x offset in pixels
d1124 2
a1125 2
                mulu    #width,d0               
                add.l   d3,d0                   d0 = address of first row
d1127 2
a1128 2
                movea.l screen(a5),a1           get base address of framebuffer
                adda.l  d0,a1                   a1 = source address
d1130 2
a1131 2
                lsr     #1,d2                   number of words per line
                subq    #1,d2			subtract 1 to make loop correct
d1133 3
a1135 3
                movem.l d0-d7/a0-a5,-(sp)
                jsr     misc_lockup             disable STOP key
                movem.l (sp)+,d0-d7/a0-a5
d1138 1
a1138 1
                movea.l a1,a4
d1141 3
a1143 3
		move.w	(a2),(a4)+		replace display with save
                move.w  d7,(a2)+                replace save with temp
                dbra    d4,cexchangenextword    and loop
d1145 2
a1146 2
                adda.l  #width,a1               increment row by width
                dbra    d1,cexchangenextrow     and loop again
d1148 1
a1148 1
                jsr     misc_lockdown           enable STOP key
d1150 1
a1150 1
                rts
d1159 1
a1159 1
                movea.l controladdr(a5),a0
d1161 10
a1170 10
		moveq	#0,d0
		move.l	d0,d1
		move.l	d0,d2
		move.l	d0,d3
                movea.l (sp)+,a1                return address
                move.w  (sp)+,d2                width in characters
                move.w  (sp)+,d3                xmin in characters
                move.w  (sp)+,d1                ymax in lines
                move.w  (sp)+,d0                ymin in lines
                move.l  a1,-(sp)                stack return address
d1172 9
a1180 9
                sub     d0,d1                   d1 = number of rows - 1
                tst     d1
                beq     cscrollwinrts           1 line window
		mulu	charh(a3),d0		d0 = first row in pixels
		mulu	charh(a3),d1		d1 = number of rows in pixels
                
                subq    #1,d1                   subtract 1 to make loop correct
		mulu	charw(a3),d3		x offset in pixels
		mulu	charw(a3),d2		x width in pixels
d1182 2
a1183 2
                mulu    #width,d0               
                add.l   d3,d0                   d0 = address of first row
d1185 2
a1186 2
                movea.l screen(a5),a1           get base address of framebuffer
                adda.l  d0,a1                   a1 = destination row
d1188 3
a1190 3
		moveq	#0,d3			reuse d3
                move    charh(a3),d3
                mulu    #width,d3               number of rows per line height
d1192 1
a1192 1
                lsr     #2,d2                   number of longs per line
d1194 3
a1196 3
                movem.l d0-d7/a0-a5,-(sp)
                jsr     misc_lockup             disable STOP key
                movem.l (sp)+,d0-d7/a0-a5
d1198 2
a1199 2
                move.l  #pagemode,d7		turn on page mode
                move.l  #0,0(a0,d7.l)
d1201 2
a1202 2
		btst	#3,sysflag2		test for 68040 to use move16
		bne	cscrollwin68030
d1206 2
a1207 2
		lsr	#2,d2			number of move16's
                subq    #1,d2			subtract 1 to make loop correct
d1210 3
a1212 3
                movea.l a1,a2                   set up destination address
                movea.l a1,a4
                adda.l  d3,a4                   set up source address
d1215 1
a1215 1
                dbra    d4,cscrollwinnextword   and loop
d1217 2
a1218 2
                adda.l  #width,a1               increment row by width
                dbra    d1,cscrollwinnextrow    and loop again
d1220 1
a1220 1
                bra	cscrollwinpageoff
d1224 1
a1224 1
cscrollwin68030 subq    #1,d2			subtract 1 to make loop correct
d1227 3
a1229 3
                movea.l a1,a2                   set up destination address
                movea.l a1,a4
                adda.l  d3,a4                   set up source address
d1232 1
a1232 1
                dbra    d4,cscrollwinnextword2  and loop
d1234 2
a1235 2
                adda.l  #width,a1               increment row by width
                dbra    d1,cscrollwinnextrow2   and loop again
d1237 2
a1238 2
cscrollwinpageoff move.l #pagemode,d7		turn off page mode
                move.l  #1,0(a0,d7.l)
d1240 1
a1240 1
                jsr     misc_lockdown           enable STOP key
d1250 3
a1252 3
                move.l  #cursorcontrol1,d0
                ori     #cursoroffmask,0(a0,d0.l)
                rts
d1261 3
a1263 3
                move.l  #cursorcontrol1,d0
                andi    #cursoronmask,0(a0,d0.l)
                rts
d1272 1
a1272 1
                movea.l controladdr(a5),a0
d1274 10
a1283 10
		moveq	#0,d0
		move.l	d0,d1
		move.l	d0,d2
		move.l	d0,d3
                movea.l (sp)+,a1                return address
                move.w  (sp)+,d2                width in characters
                move.w  (sp)+,d3                xmin in characters
                move.w  (sp)+,d1                ymax in lines
                move.w  (sp)+,d0                ymin in lines
                move.l  a1,-(sp)                stack return address
d1285 7
a1291 7
		move.l	d1,d4
                sub     d0,d4                   number of lines-1
                tst     d4
                beq     cscrollwindnrts         1 line window
		mulu	charh(a3),d4		d4 = number of rows in pixels
                subq    #1,d4                   subtract 1 to make loop correct
		move.l	d4,d0			d0 = number of rows-1
d1293 5
a1297 5
                addq    #1,d1                   1 more line down
		mulu	charh(a3),d1		d1 = last row in pixels
                subq    #1,d1                   1 row up (last row of dest)
		mulu	charw(a3),d3		x offset in pixels
		mulu	charw(a3),d2		x width in pixels
d1299 2
a1300 2
                mulu    #width,d1               
                add.l   d3,d1                   d1 = address of last row
d1302 2
a1303 2
                movea.l screen(a5),a1           get base address of framebuffer
                adda.l  d1,a1                   a1 = destination row
d1305 3
a1307 3
		moveq	#0,d3			reuse d3
                move    charh(a3),d3
                mulu    #width,d3               number of rows per line height
d1309 1
a1309 1
                lsr     #2,d2                   number of longs per line
d1311 3
a1313 3
                movem.l d0-d7/a0-a5,-(sp)
                jsr     misc_lockup             disable STOP key
                movem.l (sp)+,d0-d7/a0-a5
d1315 2
a1316 2
                move.l  #pagemode,d7		turn on page mode
                move.l  #0,0(a0,d7.l)
d1318 2
a1319 2
		btst	#3,sysflag2		test for 68040 to use move16
		bne	cscrollwindn68030
d1323 2
a1324 2
		lsr	#2,d2			number of move16's
                subq    #1,d2			subtract 1 to make loop correct
d1327 3
a1329 3
                movea.l a1,a2                   set up destination address
                movea.l a1,a4
                suba.l  d3,a4                   set up source address
d1332 1
a1332 1
                dbra    d4,cscrollwindnnextword and loop
d1334 2
a1335 2
                suba.l  #width,a1               decrement row by width
                dbra    d0,cscrollwindnnextrow  and loop again
d1337 1
a1337 1
                bra	cscrollwindnpageoff
d1341 1
a1341 1
cscrollwindn68030 subq    #1,d2			subtract 1 to make loop correct
d1344 3
a1346 3
                movea.l a1,a2                   set up destination address
                movea.l a1,a4
                suba.l  d3,a4                   set up source address
d1349 1
a1349 1
                dbra    d4,cscrollwindnnextword2 and loop
d1351 2
a1352 2
                suba.l  #width,a1               increment row by width
                dbra    d0,cscrollwindnnextrow2 and loop again
d1354 2
a1355 2
cscrollwindnpageoff move.l #pagemode,d7		turn off page mode
                move.l  #1,0(a0,d7.l)
d1357 1
a1357 1
                jsr     misc_lockdown           enable STOP key
d1368 4
a1371 4
		moveq	#0,d1
		move.l	d1,d2
		move.l	d1,d3
		move.l	d1,d4
d1373 6
a1378 6
                movea.l (sp)+,a1                return address
                move.w  (sp)+,d4                width (in chars)
                move.w  (sp)+,d3                xmin (in chars)
                move.w  (sp)+,d2                ymax (in lines)
                move.w  (sp)+,d1                ymin (in lines)
                move.l  a1,-(sp)                stack return address
d1380 9
a1388 9
		sub	d1,d2
		addq	#1,d2			add 1 to lines
		mulu	charh(a3),d2		d2 = number of rows in pixels
		mulu	charh(a3),d1		d1 = first row in pixels
		mulu	charw(a3),d3		d3 = first column
		subq	#1,d4			1 char less
                beq     cdbscrolllrts           1 column window
		mulu	charw(a3),d4		number of columns
		lsr	#2,d4			d4 = number of long words
d1390 4
a1393 4
		movea.l	screen(a5),a1
                mulu    #width,d1
		adda.l	d1,a1
		adda.l	d3,a1			address of first pixel
d1395 2
a1396 2
		subq	#1,d2			subtract 1 to make loop correct
		subq	#1,d4			subtract 1 to make loop correct
d1398 3
a1400 3
                movem.l d0-d7/a0-a5,-(sp)
                jsr     misc_lockup             disable STOP key
                movem.l (sp)+,d0-d7/a0-a5
d1403 3
a1405 3
                movea.l a2,a4
		move.l	d4,d3			reuse d3 for counter
		adda	charw(a3),a4		set up source address
d1408 1
a1408 1
		dbra	d3,cdbscrolllnextword
d1410 2
a1411 2
		adda.l	#width,a1
		dbra	d2,cdbscrolllnextrow
d1413 1
a1413 1
                jsr     misc_lockdown           enable STOP key
d1424 4
a1427 4
		moveq	#0,d1
		move.l	d1,d2
		move.l	d1,d3
		move.l	d1,d4
d1429 6
a1434 6
                movea.l (sp)+,a1                return address
                move.w  (sp)+,d4                width
                move.w  (sp)+,d3                xmin
                move.w  (sp)+,d2                ymax
                move.w  (sp)+,d1                ymin
                move.l  a1,-(sp)                stack return address
d1436 8
a1443 8
		sub	d1,d2
                addq    #1,d2                   add 1 to lines
		mulu	charh(a3),d2		d2 = number of rows
		mulu	charh(a3),d1		d1 = first row
		mulu	charw(a3),d3		d3 = first column
		subq	#1,d4			1 less char
                beq     cdbscrollrrts           1 column window
		mulu	charw(a3),d4		number of columns
d1445 6
a1450 6
		move.l	screen(a5),a1
                mulu    #width,d1
		adda.l	d1,a1
		adda.l	d3,a1
		adda.l	d4,a1			address of first pixel
		addq	#4,a1			subtract later with pre-dec
d1452 1
a1452 1
		lsr	#2,d4			d4 = number of long words
d1454 1
a1454 1
		subq	#1,d2			subtract 1 to make loop correct
d1456 3
a1458 3
                movem.l d0-d7/a0-a5,-(sp)
                jsr     misc_lockup             disable STOP key
                movem.l (sp)+,d0-d7/a0-a5
d1460 1
a1460 1
cdbscrollrnextrow movea.l a1,a2			set up source address
d1462 2
a1463 2
		move.l  d4,d3			reuse d3 for counter
		adda	charw(a3),a4		set up destination address
d1466 1
a1466 1
		dbra	d3,cdbscrollrnextword
d1468 2
a1469 2
		adda.l	#width,a1
		dbra	d2,cdbscrollrnextrow
d1471 1
a1471 1
                jsr     misc_lockdown           enable STOP key
d1482 1
a1482 1
                movea.l controladdr(a5),a0
d1484 2
a1485 2
                moveq   #0,d2
                move.l  d1,d3
d1487 3
a1489 3
                movem.l d0-d7/a0-a5,-(sp)
                jsr     misc_lockup             disable STOP key
                movem.l (sp)+,d0-d7/a0-a5
d1491 6
a1496 6
                move.l  #blockmode,d6
                move.l  #0,0(a0,d6.l)           turn on block mode
                move.l  #vramcolor1,d5
                move.l  #0,0(a0,d5.l)           set color registers to 0
                move.l  #maskreg,d5
                move.l  #-1,0(a0,d5.l)          to clear on all planes
d1498 7
a1504 7
                move.l  screen(a5),a1           base address of FB
                move    disph(a3),d2            get width and height in pixels
                move    dispw(a3),d3
                lsr     #4,d3                   change to number of words
                subq    #1,d2
                subq    #1,d3
                movea.l a1,a2                   make a copy for reference
d1507 1
a1507 1
                movea.l a2,a1                   reset to beginning of next line
d1510 1
a1510 1
                dbra    d4,nextword             and loop
d1512 2
a1513 2
                adda.l  #widthdiv16,a2          increment row by width
                dbra    d2,nextrow              and loop again
d1515 1
a1515 1
                move.l  #1,0(a0,d6.l)           turn off block mode
d1517 1
a1517 1
                jsr     misc_lockdown           enable STOP key
d1519 1
a1519 1
                rts
d1534 6
a1539 6
                movea.l (sp)+,a1                return address
                move.l  (sp)+,d3
                move.l  (sp)+,d2
                move.l  (sp)+,d1
                move.l  (sp)+,d0                get data off stack as longs
                move.l  a1,-(sp)                stack return address
d1541 1
a1541 1
                move.l  #blueregimage,d5
d1544 7
a1550 7
                bne.s   ccheckblue              loop until bit is clear
                move.l  #dacimagewrite,d6
                move.b  d0,0(a0,d6.l)           write the index to the DAC
                move.b  d1,4(a0,d6.l)           then red to the DAC
                move.b  d2,4(a0,d6.l)           then green to the DAC
                move.b  d3,3(a0,d5.l)           then blue to BEECH
                rts
d1559 6
a1564 6
                movea.l controladdr(a5),a0
                movea.l (sp)+,a1                return address
                move.w  (sp)+,d2                register value
                move.l  (sp)+,d1                register number
                move.l  a1,-(sp)                stack return address
                rts
d1573 5
a1577 5
                movea.l controladdr(a5),a0
                movea.l (sp)+,a1                return address
                movea.l (sp)+,a2
                move.l  a1,-(sp)                stack return address
                rts
d1586 5
a1590 5
                movea.l controladdr(a5),a0
                movea.l (sp)+,a1                return address
                movea.l (sp)+,a2
                move.l  a1,-(sp)                stack return address
                rts
d1599 6
a1604 6
            movea.l  controladdr(a5),a0
            movea.l  (sp)+,a1           return address
            adda.l   (sp)+,a0           offset
            movep    0(a0),d0
            move     d0,(sp)            store on stack as function value
            jmp      (a1)
d1613 2
a1614 2
                movea.l controladdr(a5),a0
                rts
d1636 1
a1636 1
cprepdumpline	equ *
d1647 1
a1647 1
preploop	equ    *
d1659 1
a1659 1
initcharbuf	equ *
d1668 1
a1668 1
fixstrlen	equ   *
d1698 2
a1699 2
                movea.l controladdr(a5),a0
                rts
@


55.6
log
@Hi-res fonts didn't work. Increased font storage size and accounted fo
byte wide padding on Hi-res fonts. Saved and restored registers when
calling misc_lockup. - CFB
@
text
@d400 2
d403 2
a432 4
                move    d2,dispw(a3)
                move    d2,printw(a3)
                movep.w displayheight(a0),d2
                move    d2,disph(a3)
a1689 65

*cprepdumpline   movea.l crtinfo(a5),a3
                movea.l controladdr(a5),a0
                movea.l (sp)+,a1                return address
                movea.l (sp)+,a2                buffer address
                move.w  (sp)+,d1                size of buffer in bytes
                movea.l (sp)+,a4                row start address of FB
                move.l  a1,-(sp)                stack return address

		moveq	#0,d2

		move	displaywidth(a0),d2	get width of display
		subq	#1,d2			make loop correct

cprepchecklast	tst.b	0(a4,d2.l)		any bits set?	
		bne	cprepfoundlast
		dbra	d2,cprepchecklast

		move.b	#0,(a2)			no bits on this line
		moveq	#1,d2			make at least one
		bra	cprepcalcascii		

cprepfoundlast	addq	#1,d2			d2 now has number of bits set
		move.l	d2,d3
		andi	#7,d3			get remainder (d2 mod 8)
		lsr	#3,d2			number of bytes (d2 / 8)
		tst	d3			any remainder?
		beq	cprepmakebyte 		no, get data
		addq	#1,d2			yes, round up to next byte

cprepmakebyte	move	d2,d4			make copy for later
		subq	#1,d4			subtract 1 to make loop correct
		moveq	#0,d5			clear d5
		moveq	#7,d6			check 8 bytes

cprepnextbit	lsl	#1,d5
		tst.b	(a4)+			any bits set?
		beq	cprepcheckloop		no bits set
		ori.b	#1,d5			there's a bit set, add to byte
cprepcheckloop	dbra	d6,cprepnextbit

		move.b 	d5,(a2)+
		dbra	d4,cprepmakebyte

* compute ASCII representation of d2 into longword, with trailing 'W'

cprepcalcascii	equ	*
		move.b  d2,-8(a2)       stick correct length in strlen of outbuf
		addi.b  #7,-8(a2)              and adjust for #27'*bxxxW' header

		divu    #10,d2                  remainder->upper word of d2
		move.w  d2,d3
		ext.l   d3                      clear MSBs of d3
		divu    #10,d3                  remainder->upper word of d3
		swap    d3
		rol.w   #8,d3
		clr.w   d2                      clear LSBs
		swap    d2
		or.l    d3,d1
		ori.l   #'000',d2               attach ASCII numeric headers
		rol.l   #8,d2                  	justify for copy to outbuf
		ori.b   #'W',d2                	now have 'xxxW' in longword
		move.l  d2,-4(a2)      	        copy to outbuf

                rts
@


55.5
log
@Fixed 68030 debug wimdow section. FIxed lockup/lockdown problem. CFB
@
text
@d183 1
d214 1
d216 1
a216 1
fontstorage     ds.b    9600            ((256 + 128) * 10 * 20) / 8
d236 1
a236 1
                bsr     cmapenter             call the color map entry routine
d243 1
a243 1
cmaploop2       bsr     cmapenter
d249 1
a250 1
                move.l  #colormapvalue,d7
d296 2
a387 1
                jsr     loadcmap                load the color map
d389 2
a390 2
cnocolor2       moveq   #0,d0    we don't clear framebuf here, as the graphics
*                                ID ROM will do it anyway on CATSEYE. SFB}
d411 1
d428 1
d446 1
a446 1
                lea     0(a0,d2.l),a2           a3 = address of font info
d460 1
a460 1
                bsr     unpkroman               go unpack it
d482 1
a482 1
buildcursorclr3 moveq   #1,d3                   8 pixels wide (2 nybbles)
d489 4
a492 1
                addi.l  #64,d0                  next row
d507 1
a507 1
buildcursorvis3 moveq   #1,d3                   8 pixels wide (2 nybbles)
d514 4
a517 1
                addi.l  #64,d0                  next row
d608 1
d610 1
d714 1
d716 1
d822 6
d835 3
d839 1
d869 2
d872 1
a872 1
                lsr     #3,d2                   / 8 -> font offset
d883 1
d894 1
a894 2
                moveq   #0,d7                   clear d7 for subtract at dbra

d896 1
d902 2
d928 1
a928 1
                beq.s   dounderline2		no, skip over invert
d931 5
a935 2
dounderline2	move.l d1,-(a1)			underline going backward
		move.l d1,-(a1)
d964 1
a964 1
                lsr     #2,d1                   length in long words
d981 1
a982 1
                subq    #1,d2
d984 1
d986 1
d990 1
a990 1
cclearnextword  move.l  #0,(a2)+                write to the display
d1032 1
d1034 1
d1080 1
d1082 1
d1130 1
a1130 1
                lsr     #2,d2                   number of longs per line
d1133 1
d1135 1
d1140 3
a1142 3
cexchangenextword move.l (a4),d7                move display to temp space
		move.l	(a2),(a4)+		replace display with save
                move.l  d7,(a2)+                replace save with temp
d1194 1
d1196 1
d1311 1
d1313 1
d1398 1
d1400 1
d1456 1
d1458 1
d1487 1
d1489 1
@


55.4
log
@Changed stop key disabling from setintlevel() to lockup/lockdown - CFB
@
text
@d659 1
a659 1
                adda.l  #width,a1              increment row by width
d997 1
a997 1
                jsr     misc_lockup             enable STOP key
d1048 1
a1048 1
		subq	#4,a2
d1197 2
a1198 2
cscrollwinrts   jsr     misc_lockdown           enable STOP key
                rts
d1307 1
a1307 1
                dbra    d1,cscrollwindnnextrow2 and loop again
a1308 12
cscrollwindnclr2 move    charh(a3),d1            set up to clear next line
                subq    #1,d1

cscrollwindnclrrow2 move.l d2,d4                reset column counter
                movea.l a1,a2

cscrollwindnclrword2 move.l #0,(a2)+            clear line
                dbra    d4,cscrollwindnclrword2 and loop

                suba.l  #width,a1               increment row by width
                dbra    d1,cscrollwindnclrrow2  and loop again

d1312 2
a1313 2
cscrollwindnrts jsr     misc_lockdown           enable STOP key
                rts
d1366 2
a1367 2
cdbscrolllrts   jsr     misc_lockdown           enable STOP key
                rts
d1422 2
a1423 2
cdbscrollrrts   jsr     misc_lockdown           enable STOP key
                rts
@


55.3
log
@Set interrupt level to 7 before crt operations to prevent partial ops - CFB
@
text
@d39 2
a40 1
                refa    woodcutdvr,sysdevs,asm_intlevel,asm_setintlevel
a572 7

                subq.l	#4,sp                   make room on the stack
                jsr	asm_intlevel		place current intlevel on stack
                move.l  (sp),currentintlevel
                move.l	#7,(sp)                 push new level on the stack
                jsr	asm_setintlevel		set new intlevel

d597 2
d665 1
a665 2
                move.l  currentintlevel,-(sp)   push old int level back on stack
                jsr	asm_setintlevel		set intlevel back
a676 7

                subq.l  #4,sp                   make room on the stack
                jsr     asm_intlevel            place current intlevel on stack
                move.l  (sp),currentintlevel
                move.l  #7,(sp)                 push new level on the stack
                jsr     asm_setintlevel         set new intlevel

d701 2
d769 1
a769 2
                move.l  currentintlevel,-(sp)   push old int level back on stack
                jsr	asm_setintlevel		set intlevel back
a821 7

                subq.l  #4,sp                   make room on the stack
                jsr     asm_intlevel            place current intlevel on stack
                move.l  (sp),currentintlevel
                move.l  #7,(sp)                 push new level on the stack
                jsr     asm_setintlevel         set new intlevel

d868 2
d893 2
d904 1
a904 2
                move.l  currentintlevel,-(sp)   push old int level back on stack
                jsr	asm_setintlevel		set intlevel back
a917 7

                subq.l  #4,sp                   make room on the stack
                jsr     asm_intlevel            place current intlevel on stack
                move.l  (sp),currentintlevel
                move.l  #7,(sp)                 push new level on the stack
                jsr     asm_setintlevel         set new intlevel

d951 2
d960 1
a960 2
                move.l  currentintlevel,-(sp)   push old int level back on stack
                jsr	asm_setintlevel		set intlevel back
a971 8
                subq.l  #4,sp                   make room on the stack
                jsr     asm_intlevel            place current intlevel on stack
                move.l  (sp),currentintlevel
                move.l  #7,(sp)                 push new level on the stack
                jsr     asm_setintlevel         set new intlevel

                movea.l controladdr(a5),a0

d997 2
d1006 1
a1006 2
                move.l  currentintlevel,-(sp)   push old int level back on stack
                jsr	asm_setintlevel		set intlevel back
a1017 8
                subq.l  #4,sp                   make room on the stack
                jsr     asm_intlevel            place current intlevel on stack
                move.l  (sp),currentintlevel
                move.l  #7,(sp)                 push new level on the stack
                jsr     asm_setintlevel         set new intlevel

                movea.l controladdr(a5),a0

d1043 2
d1053 1
a1053 2
                move.l  currentintlevel,-(sp)   push old int level back on stack
                jsr	asm_setintlevel		set intlevel back
a1064 8
                subq.l  #4,sp                   make room on the stack
                jsr     asm_intlevel            place current intlevel on stack
                move.l  (sp),currentintlevel
                move.l  #7,(sp)                 push new level on the stack
                jsr     asm_setintlevel         set new intlevel

                movea.l controladdr(a5),a0

d1094 2
d1107 1
a1107 2
                move.l  currentintlevel,-(sp)   push old int level back on stack
                jsr	asm_setintlevel		set intlevel back
a1117 7

                subq.l  #4,sp                   make room on the stack
                jsr     asm_intlevel            place current intlevel on stack
                move.l  (sp),currentintlevel
                move.l  #7,(sp)                 push new level on the stack
                jsr     asm_setintlevel         set new intlevel

d1153 2
d1197 2
a1198 2
                move.l  currentintlevel,-(sp)   push old int level back on stack
                jsr	asm_setintlevel		set intlevel back
a1199 2
cscrollwinrts   rts

a1228 7

                subq.l  #4,sp                   make room on the stack
                jsr     asm_intlevel            place current intlevel on stack
                move.l  (sp),currentintlevel
                move.l  #7,(sp)                 push new level on the stack
                jsr     asm_setintlevel         set new intlevel

d1268 2
d1324 2
a1325 2
                move.l  currentintlevel,-(sp)   push old int level back on stack
                jsr     asm_setintlevel         set intlevel back
a1326 2
cscrollwindnrts rts

a1334 6
                subq.l  #4,sp                   make room on the stack
                jsr     asm_intlevel            place current intlevel on stack
                move.l  (sp),currentintlevel
                move.l  #7,(sp)                 push new level on the stack
                jsr     asm_setintlevel         set new intlevel

d1365 2
a1376 3
		
                move.l  currentintlevel,-(sp)   push old int level back on stack
                jsr     asm_setintlevel         set intlevel back
d1378 2
a1379 1
cdbscrolllrts   rts
a1388 8
                subq.l  #4,sp                   make room on the stack
                jsr     asm_intlevel            place current intlevel on stack
                move.l  (sp),currentintlevel
                move.l  #7,(sp)                 push new level on the stack
                jsr     asm_setintlevel         set new intlevel

                movea.l controladdr(a5),a0

d1421 2
a1432 3
		
                move.l  currentintlevel,-(sp)   push old int level back on stack
                jsr     asm_setintlevel         set intlevel back
d1434 2
a1435 1
cdbscrollrrts   rts
a1444 7

                subq.l  #4,sp                   make room on the stack
                jsr     asm_intlevel            place current intlevel on stack
                move.l  (sp),currentintlevel
                move.l  #7,(sp)                 push new level on the stack
                jsr     asm_setintlevel         set new intlevel

d1450 2
d1477 2
a1478 2
                move.l  currentintlevel,-(sp)   push old int level back on stack
                jsr     asm_setintlevel         set intlevel back
@


55.2
log
@Cleaned up code (indents and such). Fixed all bugs found in QA - CFB
@
text
@d39 1
a39 1
                refa    woodcutdvr,sysdevs
d211 2
d572 7
d580 1
d669 3
d682 7
d690 1
d779 3
d833 7
d918 3
d933 7
d979 4
d992 7
d1000 1
d1033 3
d1045 7
d1053 1
d1087 3
d1099 7
d1107 1
d1148 3
d1160 7
d1168 1
d1244 3
d1278 7
d1286 1
d1378 3
d1390 7
d1438 3
d1450 7
d1458 1
d1502 3
d1515 7
d1523 1
d1552 3
@


55.1
log
@Automatic bump of revision number for PWS version 3.25A
@
text
@d1 1
a1 1
	     page
d28 6
a33 6
		def     cscrollup,cscrolldown,cupdatecursor,cchar,cclear
		def     cbuildtable,cshiftleft,cshiftright
		def     cexchange,cscrollwindow,cursoroff
		def     cscrollwinddn,cdbscrolll,cdbscrollr,cclearall
		def     csetcolormap,csetreg,csavewoodenv,crestorewoodenv
		def     cromshort,csetupcchar,cprepdumpline
d35 1
a35 1
		def     setupcchar
d37 1
a37 1
		rorg.l 0
d39 1
a39 1
		refa    woodcutdvr,sysdevs
d41 2
a42 2
		nosyms
		sprint
d104 1
d190 1
d193 1
a193 1
framecount      equ     $0000005B       offset of number of frames
d201 1
a201 1
sysflag2        equ     $FFFFFEDA
d205 5
a209 5
*                                       kludge because MOVE16 is 16 byte aligned
*                                       and we don't know where zero16 will be
		dc.l    0,0,0,0         16 bytes of zeros
zero16          dc.l    0,0,0,0         16 bytes of zeros
		dc.l    0,0,0,0         16 bytes of zeros
d211 1
a211 1
* FONT STORAGE ( needs to be move to FCRT )
a212 4
fontstorage1    ds.b    16384           ASCII chars 0-127
fontstorage2    ds.b    16384           ROMAN 8 chars 128-255
fontstorage3    ds.b    16384           Katakana chars

d221 7
a227 4
		moveq   #0,d1                 clear some registers
		move.l  d1,d2
		move.l  d1,d3
		move.l  d1,d4
d229 9
a237 9
		move.b  (a1)+,d3
		move.b  (a1)+,d4
		bsr     cmapenter             call the color map entry routine
		addq    #1,d1                 bump cmap pointer value
		cmp     #16,d1                have we done 16 yet?
		bne.s   cmaploop1             if not then continue
		moveq   #-1,d2                set entries 16-255 to white
		move.l  d2,d3
		move.l  d2,d4
d239 3
a241 3
		addq    #1,d1
		cmp     #256,d1                 done with cmap init?
		bne.s   cmaploop2
d243 3
a245 3
		move.l  #blueregcursor,d6
		move.l  #dacoverlaywrite,d5
		move.l  #colormapvalue,d7
d248 5
a252 5
		bne.s   cursorcmapwait          loop till bit is clear
		move.b  #2,0(a0,d5.l)           write the index to the DAC
		move.b  #0,0(a0,d7.l)           then red to the DAC
		move.b  #0,0(a0,d7.l)           then green to the DAC
		move.b  #0,3(a0,d6.l)           then blue to BEECH
d255 6
a260 6
		bne.s   cursorcmapwait2         loop till bit is clear
		move.b  #3,0(a0,d5.l)           write the index to the DAC
		move.b  #255,0(a0,d7.l)         then red to the DAC
		move.b  #255,0(a0,d7.l)         then green to the DAC
		move.b  #255,3(a0,d6.l)         then blue to BEECH
		rts
d263 2
a264 2
		move.l  #dacimagewrite,d5
		move.l  #colormapvalue,d7
d267 5
a271 5
		bne.s   cmapwait                loop till bit is clear
		move.b  d1,0(a0,d5.l)           write the index to the DAC
		move.b  d2,0(a0,d7.l)           then red to the DAC
		move.b  d3,0(a0,d7.l)           then green to the DAC
		move.b  d4,3(a0,d6.l)           then blue to BEECH
d273 1
a273 1
		rts                             done with cmap entry write
d278 1
a278 1
*               font unpacking routines
d282 1
d286 2
a287 17
		moveq   #0,d0
		move.l  d0,d1
		move    charw(a3),d0
		move    charh(a3),d1
		move    d1,d2
		mulu    d0,d2                   # bytes/char
		subq    #1,d7                   count a found font
		moveq   #127,d3                 #chars to unpack-1
		lea     (fontstorage1),a4       start at beginning of font store
		bsr.s   unpackit
		moveq   #127,d3                 now unpack second half of font
		lea     (fontstorage2),a4
		bsr.s   unpackit
		rts                     * forget the rest, bail out for now
		subq    #1,d7
		moveq   #127,d3
		lea     (fontstorage3),a4
d289 5
a293 12
unpackit        equ     *
		subq    #2,a2                   added back later
unpackchar      move.l  d1,d5                   unpack d0 rows/char
		subq    #1,d5
unpackrow       moveq   #7,d4                   we need to look at 8 bits/byte
		addq    #2,a2                   look at next font byte
unpackbyte      btst    d4,(a2)                 is bit set in font?
		sne     (a4)+                   set frame buffer byte if bit set
		dbra    d4,unpackbyte           loop till all 8 bits done
		dbra    d5,unpackrow            and loop till rows in char done
		dbra    d3,unpackchar           loop till all chars done
		rts                             go look at next font
d295 5
d301 1
d303 1
d311 8
a318 8
		moveq    #0,d0
		move.b   2(a1),d0           get word count to initialize
		movep    4(a1),d1           form destination offset
		add.l    a0,d1              d1 points to dest addr
		lea      8(a1),a2           a2 points to first data byte
		movea.l  d1,a4              a4 points to destination
		btst     #0,(a1)            is this a bit test block?
		bne.s    ginitbtst          if so go handle it
d320 4
a323 4
		move.w   d1,(a4)+           move data to the destination addr
		btst     #6,(a1)            increment data pointer
		bne.s    ginit1             based on control byte
		addq     #4,a2
d325 4
a328 4
		btst     #7,(a1)            was this last block?
		bne.s    ginitdone          yes -- go return
		btst     #6,(a1)            adjust data pointer
		beq.s    ginit2             to point to next init block
d331 1
a331 1
		bra      ginitblock         do the initialize
d334 1
a334 1
		move.b   2(a2),d2           d2 = bit # to test
d336 3
a338 3
		btst     #0,(a2)            check for sense of test
		bne.s    ginittst3          comp if waiting for 0
		not      d3
d340 4
a343 4
		beq      ginittst2          if not 1 then loop
		btst     #7,(a1)            was this last block?
		bne.s   ginitdone          if so then return
		bra      ginit3             else do next block
d354 12
a365 10
		movea.l crtinfo(a5),a3          crtparamrec
		movep   initoffset(a0),d1       form pointer to init block
		movea.l a0,a1                   make copy of ROM start addr
		adda.l  d1,a1                   a1 points to init info now
		jsr     ginitblock              call the initialization routine
		st      hascolor(a5)            always has color
		clr.l   screen(a5)             clear space for frame buffer addr
		movea.l a0,a1                   make copy of ROM start addr
		adda.l  #framebuffer,a1         add offset to frame buffer
		move.l  a1,screen(a5)           form frame buffer addr
d367 7
a373 7
		move.b  framecount(a0),d0       d0=# of planes in system
		beq.s   cnumplanes              if zero then read planes
		moveq   #8,d1                   else make the mask up
		moveq   #$ff,d2
		sub     d0,d1                   d1 has shift count
		lsr.b   d1,d2                   after shift d2 has mask
		bra.s   csetplanes              go setup planemask
d376 3
a378 3
		movea.l screen(a5),a1           addr of fb in a1
		move.b  #$FF,(a1)               write all 1's
		move.b  (a1),d2                 read it back to get plane mask
d380 2
a381 2
		move.b  d2,3+planemask(a3)      save as plane mask
		jsr     loadcmap                load the color map
d385 14
a398 14
		move    d0,dispx(a3)            set positions to (0,0)
		move    d0,dispy(a3)
		move    d0,printx(a3)
		move    d0,printy(a3)
		movep.w framewidth(a0),d2       get width from ROM
		move    d2,fbwidth(a3)
		movep.w displaywidth(a0),d2    set visible width as window width
		movep.w frameheight(a0),d2      get height from ROM
		move    d2,fbheight(a3)
		movep.w displaywidth(a0),d2
		cmp     #1024,d2
		beq.s   setuplcc
		cmp     #640,d2                 no offscreen available
		beq.s   setupvga
d401 5
a405 5
		move    #1280,offx(a3)
		move    #0,offy(a3)
		move    #768,offw(a3)
		move    #1024,offh(a3)
		bra.s   donesetupoff
d407 6
a412 6
setuplcc        equ     *                       no offscreen available
		move    #0,offx(a3)
		move    #0,offy(a3)
		move    #0,offw(a3)
		move    #0,offh(a3)
		bra.s   donesetupoff
d415 4
a418 4
		move    #640,offx(a3)           and at the bottom. right larger
		move    #0,offy(a3)
		move    #384,offw(a3)
		move    #512,offh(a3)
d421 4
a424 4
		move    d2,dispw(a3)
		move    d2,printw(a3)
		movep.w displayheight(a0),d2
		move    d2,disph(a3)
d426 4
a429 6
		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		movep   fontoffset(a0),d1       get font info offset
		lea     2(a0,d1.w),a1           point to font id code
		moveq   #2,d7                 count number of font found with d7
d431 5
a435 10
		movep   2(a1),d2                get offset of font info
		lea     0(a0,d2.l),a2           a3 points to font info
		moveq   #0,d0
		move.b  (a2),d0                 d0 = font height
		moveq   #0,d1
		move.b  2(a2),d1                d1 = font width
		move    d0,charh(a3)            store them for later use
		move    d1,charw(a3)
		adda.l  #10,a2                  a2 now points to first char
		bsr     unpkroman               if so go unpack it
d437 20
d458 1
a458 1
		jsr     cursoroff
d460 1
a460 1
		move.l  #cursorcontrol1,d2
d462 2
a463 2
		move.l  #colormask,d0           write to the cursor image
		move.l  #1023,d1                clear the entire cursor
d466 4
a469 4
		bne.s   buildcursorclr
		move    #0,0(a0,d0.l)
		addq.l  #4,d0
		dbra    d1,buildcursorclr
d471 2
a472 2
		move.l  #colormask,d0           create cursor image
		moveq   #1,d4                   2 rows
d475 1
a475 1
		move.l  d0,d1                   beginning of row
d477 6
a482 6
		bne.s   buildcursorclr2
		move    #-1,0(a0,d1.l)
		addq.l  #4,d1                   next 4 pixels
		dbra    d3,buildcursorclr2
		addi.l  #64,d0                  next row
		dbra    d4,buildcursorclr3
d484 2
a485 2
		move.l  #visiblemask,d0         write to the cursor mask
		move.l  #1023,d1                clear the entire mask
d488 4
a491 4
		bne.s   buildcursorvis
		move    #0,0(a0,d0.l)
		addq.l  #4,d0
		dbra    d1,buildcursorvis
d493 2
a494 2
		move.l  #visiblemask,d0         create "cookie cutter"
		moveq   #1,d4                   2 rows
d497 1
a497 1
		move.l  d0,d1                   beginning of row
d499 6
a504 6
		bne.s   buildcursorvis2
		move    #-1,0(a0,d1.l)
		addq.l  #4,d1                   next 4 pixels
		dbra    d3,buildcursorvis2
		addi.l  #64,d0                  next row
		dbra    d4,buildcursorvis3
d506 2
a507 2
		move.l  #cursorcontrol0,d0
		move.l  #0,0(a0,d0.l)           clear y-clip LSB's
d509 2
a510 2
		move.l  #cursorcontrol1,d0
		andi    #$000c0,0(a0,d0.l)      clear y-clip MSB's
d512 1
a512 1
		jsr     cursoron
d514 4
a517 4
		move.l  #readmask,d2
		move.b  #255,0(a0,d2)           turn on all planes

		rts
d525 16
a540 16
		dc.b    0,0,0                   0
		dc.b    255,255,255             1
		dc.b    255,0,0                 2
		dc.b    255,255,0               3
		dc.b    0,255,0                 4
		dc.b    0,255,255               5
		dc.b    0,0,255                 6
		dc.b    255,0,255               7
		dc.b    0,0,0                   8
		dc.b    204,187,51              9
		dc.b    51,170,119              10
		dc.b    136,102,170             11
		dc.b    204,68,102              12
		dc.b    255,102,51              13
		dc.b    255,119,0               14
		dc.b    221,136,68              15
d542 19
d570 5
a574 5
		movea.l controladdr(a5),a0
		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3
d576 5
a580 5
		move    printy(a3),d0
		move    printh(a3),d1           set up window size
		sub     charh(a3),d1            one less row
		sub     d0,d1                   d1 = number of rows
		subq    #1,d1                   subtract 1 to make loop correct
d582 1
a582 1
		mulu    #width,d0               d0 = address of first row
d584 2
a585 2
		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d0,a1                   a1 = destination row
d587 2
a588 2
		move    charh(a3),d3
		mulu    #width,d3               number of rows per line height
d590 2
a591 2
		move    printw(a3),d2
		lsr     #2,d2                   number of longs per line
d593 2
a594 2
		move.l  #pagemode,d7            turn on page mode
		move.l  #0,0(a0,d7.l)
d596 2
a597 2
		btst    #3,sysflag2             test for 68040 to use move16
		bne     cscroll68030
d601 2
a602 2
		lsr     #2,d2                   number of move16's
		subq    #1,d2                   subtract 1 to make loop correct
d605 3
a607 3
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		adda.l  d3,a4                   set up source address
d610 1
a610 1
		dbra    d4,cscrollnextword      and loop
d612 2
a613 2
		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollnextrow       and loop again
d615 2
a616 2
		move    charh(a3),d1            set up to clear next line
		subq    #1,d1
d619 1
a619 1
		movea.l a1,a2
d622 1
a622 1
		dbra    d4,cscrollclrword       and loop
d624 2
a625 2
		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollclrrow        and loop again
d627 1
a627 1
		bra     cscrollpageoff
d631 1
a631 1
cscroll68030    subq    #1,d2                   subtract 1 to make loop correct
d634 3
a636 3
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		adda.l  d3,a4                   set up source address
d639 1
a639 1
		dbra    d4,cscrollnextword2     and loop
d641 2
a642 2
		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollnextrow2      and loop again
d644 2
a645 2
		move    charh(a3),d1            set up to clear next line
		subq    #1,d1
d648 1
a648 1
		movea.l a1,a2
d651 1
a651 1
		dbra    d4,cscrollclrword2      and loop
d653 2
a654 2
		adda.l  #width,a1              increment row by width
		dbra    d1,cscrollclrrow2       and loop again
d656 2
a657 2
cscrollpageoff  move.l  #pagemode,d7            turn off page mode
		move.l  #1,0(a0,d7.l)
d669 5
a673 5
		movea.l controladdr(a5),a0
		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3
d675 5
a679 5
		move    printh(a3),d0           get last row
		sub     charh(a3),d0            start one line height up
		move    d0,d1                   set up window size
		sub     printy(a3),d1           d1 = number of rows
		subq    #1,d1                   subtract 1 to make loop correct
d681 1
a681 1
		mulu    #width,d0               d0 = address of last row
d683 2
a684 2
		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d0,a1                   a1 = source row
d686 2
a687 2
		move    charh(a3),d3
		mulu    #width,d3               number of rows per line height
d689 2
a690 2
		move    printw(a3),d2
		lsr     #2,d2                   number of longs per line
d692 2
a693 2
		move.l  #pagemode,d7            turn on page mode
		move.l  #0,0(a0,d7.l)
d695 2
a696 2
		btst    #3,sysflag2             test for 68040 to use move16
		bne     cscrolld68030
d700 2
a701 2
		lsr     #2,d2                   number of move16's
		subq    #1,d2
d704 3
a706 3
		movea.l a1,a2
		movea.l a1,a4
		adda.l  d3,a4                   set up source address
d709 1
a709 1
		dbra    d4,cscrolldnextword     and loop
d711 2
a712 2
		suba.l  #width,a1               decrement row by width
		dbra    d1,cscrolldnextrow      and loop again
d714 2
a715 2
		move    charh(a3),d1            set up to clear next line
		subq    #1,d1
d718 1
a718 1
		movea.l a1,a2
d721 1
a721 1
		dbra    d4,cscrolldclrword      and loop
d723 2
a724 2
		adda.l  #width,a1               decrement row by width
		dbra    d1,cscrolldclrrow       and loop again
d726 1
a726 1
		bra     cscrolldpageoff
d733 3
a735 3
		movea.l a1,a2
		movea.l a1,a4
		adda.l  d3,a4                   set up source address
d738 1
a738 1
		dbra    d4,cscrolldnextword2    and loop
d740 2
a741 2
		suba.l  #width,a1               decrement row by width
		dbra    d1,cscrolldnextrow2     and loop again
d743 2
a744 2
		move    charh(a3),d1            set up to clear next line
		subq    #1,d1
d747 1
a747 1
		movea.l a1,a2
d750 1
a750 1
		dbra    d4,cscrolldclrword2     and loop
d752 2
a753 2
		adda.l  #width,a1               decrement row by width
		dbra    d1,cscrolldclrrow2      and loop again
d755 2
a756 2
cscrolldpageoff move.l  #pagemode,d7            turn off page mode
		move.l  #1,0(a0,d7.l)
d758 1
a758 1
		rts
d767 6
a772 6
		movea.l controladdr(a5),a0
		moveq   #0,d0                   clear some registers
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3
		move.l  d0,d4
d774 4
a777 4
		movea.l (sp)+,a4                a4 = return addr
		move    (sp)+,d1                y in chars
		move    (sp)+,d2                x in chars
		move.l  a4,-(sp)                stack return address
d779 6
a784 6
		mulu    charh(a3),d1
		add     charh(a3),d1            put cursor under the character
		subq    #1,d1
		move.l  #timingv0,d3
		add     0(a0,d3.l),d1           add yoffset (see WOODCUT ERS)
		move    d1,ycurs(a5)            y position in pixels
d786 7
a792 7
		mulu    charw(a3),d2
		move.l  #timingh0,d3
		move    0(a0,d3.l),d4
		subq    #4,d4
		lsl     #2,d4                   multiply by 4
		add     d4,d2                   add xoffset (see WOODCUT ERS)
		move    d2,xcurs(a5)            x position in pixels
d794 6
a799 6
		jsr     cursoroff
		move.l  #cursorposition,d3      update cursor position
		move    d1,0(a0,d3.l)
		move    d2,2(a0,d3.l)
		jsr     cursoron
		rts
d809 2
a810 14
		movea.l controladdr(a5),a0
		movea.l (sp)+,a1                get the return address
		moveq   #0,d0                   clear some registers
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d4
		move.l  d0,d5
		move    (sp)+,d0                y coordinate in rows
		move    (sp)+,d1                x coordinate in chars
		move    (sp)+,d2                character to write
		move.l  a1,-(sp)                put the return address back
		lea     (fontstorage1),a2       get font base address
		move    charh(a3),d4            d4 =  font height
		move    charw(a3),d5            d5 =  font width
d812 5
a816 2
		mulu    d4,d0                   d0 = y coordinate in pixels
		mulu    d5,d1                   d1 = x coordinate in pixels
d818 4
a821 2
		mulu    d4,d2                   char # times height
		mulu    d5,d2                   times width -> font offset
d823 3
a825 1
		lsr     #2,d5                   font width in longs
d827 2
a828 4
		move.l  d0,d3                   start with row number
		mulu    #width,d3               times row width
		add     d1,d3                   plus column number
		addi.l  #framebuffer,d3         plus frame buffer base
d830 3
a832 5
		movea.l a0,a4
		adda.l  d3,a4                   now a4 has address of FB
		suba    #width,a4               add back later
		subq    #1,d4                   subtract 1 to make loop correct
		subq    #1,d5
d834 4
a837 9
		moveq   #0,d0
		move    alphacolor(a3),d0       get color (will only be a byte)
		move.b  d0,d1                   set up long word mask
		lsl.l   #8,d1
		or.b    d0,d1
		lsl.l   #8,d1
		or.b    d0,d1
		lsl.l   #8,d1
		or.b    d0,d1
d839 5
a843 2
		move.l  #maskreg,d6
		move.l  #-1,0(a0,d6.l)          enable writes to all planes
d845 5
a849 1
		adda.l  d2,a2                   a2 = char start addr
d851 4
d856 2
a857 3
		movea.l a4,a1                   make copy to be incremented
		move.l  d5,d6
ccharnextcol    move.l  (a2)+,d0
d859 3
a861 3
		btst    #0,highlight(a3)        inverse video?
		beq.s   ccharputchar            no, skip over invert
		not.l   d0
d863 3
a865 4
ccharputchar    and.l   d1,d0                   and in color mask
		move.l  d0,(a1)+                write to frame buffer
		dbra    d6,ccharnextcol
		dbra    d4,ccharnextrow
d867 9
d877 2
a878 2
		bne.s   dounderline             yes, do the underline
		rts
d880 3
a882 3
dounderline     btst    #0,highlight(a3)        inverse video?
		beq.s   dounderline2            no, skip over invert
		moveq   #0,d1                   make underline pen 0
d884 1
a884 1
dounderline2    move.l d1,-(a1)                 underline going backward
d887 1
a887 1
		rts
d899 1
a899 1
		movea.l controladdr(a5),a0
d901 3
a903 3
		moveq   #0,d1
		move.l  d1,d2
		move.l  d1,d3
d905 5
a909 5
		movea.l (sp)+,a1                return address
		move    (sp)+,d1                d1 = number of chars to clear
		move    (sp)+,d2                d2 = y to begin at
		move    (sp)+,d3                d3 = x to begin at
		move.l  a1,-(sp)                put back the return address
d911 4
a914 4
		mulu    charw(a3),d1            d1 = length in pixels
		lsr     #2,d1                   length in long words
		mulu    charh(a3),d2            d2 = y in pixels
		mulu    charw(a3),d3            d3 = x in pixels
d916 4
a919 4
		move.l  #vramcolor1,d7
		move.l  #0,0(a0,d7.l)           set color registers to 0
		move.l  #maskreg,d7
		move.l  #-1,0(a0,d7.l)          to clear on all planes
d921 4
a924 4
		move.l  screen(a5),a1           base address of FB
		mulu    #width,d2               multiply row * width
		adda.l  d2,a1                   add to the FB address
		adda.l  d3,a1                   add on the column
d926 5
a930 5
		moveq   #0,d2
		move    charh(a3),d2            d2 = # of rows

		subq    #1,d1                   subtract 1 to make loop correct
		subq    #1,d2
d933 1
a933 1
		movea.l a1,a2                   reset to next line
d935 4
a938 4
		dbra    d4,cclearnextword       and loop
		adda.l  #width,a1               increment row by width
		dbra    d2,cclearnextrow        and loop again
		rts
d947 4
a950 4
		movea.l controladdr(a5),a0
		moveq   #0,d1
		move.l  d1,d2
		move.l  d1,d3
d952 7
a958 7
		move    printw(a3),d2           calculate width of lastline
		move    charw(a3),d3
		mulu    #8,d3                   lastline ends 8 from right edge
		sub     d3,d2                   width of last line
		lsr     #2,d2                   d2 = width in long words
		move    printy(a3),d3           start at upper y
		add     printh(a3),d3           add print height -> last row
d960 2
a961 2
		mulu    #width,d3               offset address of last line
		add     printx(a3),d3           add on column
d963 2
a964 2
		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d3,a1                   a1 = destination address
d966 3
a968 3
		move    charh(a3),d1            d1 = number of rows
		moveq   #0,d3
		move    charw(a3),d3            d3 = width of char
d970 2
a971 2
		subq    #1,d1                   subtract 1 to make loop correct
		subq    #1,d2
d973 6
a978 6
cshiftlnextrow  move.l  d2,d4                   reset column counter
		movea.l a1,a2
cshiftlnextword move.l  0(a2,d3),(a2)+          move from one long to the other
		dbra    d4,cshiftlnextword      and loop
		adda.l  #width,a1               next row
		dbra    d1,cshiftlnextrow       and loop
d980 1
a980 1
		rts
d989 4
a992 4
		movea.l controladdr(a5),a0
		moveq   #0,d1
		move.l  d1,d2
		move.l  d1,d3
d994 6
a999 6
		move    printw(a3),d2           calculate width of lastline
		move    charw(a3),d3
		mulu    #9,d3                   lastline ends 9 from right edge
		sub     d3,d2                   width of last line
		move    printy(a3),d3           start at upper y
		add     printh(a3),d3           add print height -> last row
d1001 4
a1004 4
		mulu    #width,d3               offset address of last line
		add     printx(a3),d3           add on column
		add     d2,d3                   add width
		lsr     #2,d2                   d2 = width in long words
d1006 2
a1007 2
		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d3,a1                   a1 = destination address
d1009 3
a1011 3
		move    charh(a3),d1            d1 = number of rows
		moveq   #0,d3
		move    charw(a3),d3            d3 = width of char
d1013 1
a1013 1
		subq    #1,d1                   subtract 1 to make loop correct
d1016 6
a1021 6
		movea.l a1,a2
cshiftrnextword move.l  (a2),0(a2,d3)           move from one long to the other
		subq    #4,a2
		dbra    d4,cshiftrnextword      and loop
		adda.l  #width,a1               next row
		dbra    d1,cshiftrnextrow       and loop
d1023 1
a1023 1
		rts
d1032 5
a1036 5
		movea.l controladdr(a5),a0
		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3
d1038 7
a1044 7
		movea.l (sp)+,a1                return address
		move.w  (sp)+,d2                width in pixels
		move.w  (sp)+,d3                xmin
		move.w  (sp)+,d1                ymax
		move.w  (sp)+,d0                ymin
		movea.l (sp)+,a2                pointer to the window
		move.l  a1,-(sp)                stack return address
d1046 6
a1051 6
		mulu    charh(a3),d0            d0 = first row in pixels
		mulu    charh(a3),d1            d1 = last row in pixels
		sub     d0,d1                   d1 = number of rows
		add     charh(a3),d1            don't forget last row
		subq    #1,d1                   subtract 1 to make loop correct
		mulu    charw(a3),d3            x offset in pixels
d1053 2
a1054 2
		mulu    #width,d0
		add.l   d3,d0                   d0 = address of first row
d1056 2
a1057 2
		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d0,a1                   a1 = source address
d1059 2
a1060 2
		lsr     #2,d2                   number of longs per line
		subq    #1,d2                   subtract 1 to make loop correct
d1063 1
a1063 1
		movea.l a1,a4
d1066 3
a1068 3
		move.l  (a2),(a4)+              replace display with save
		move.l  d7,(a2)+                replace save with temp
		dbra    d4,cexchangenextword    and loop
d1070 2
a1071 2
		adda.l  #width,a1               increment row by width
		dbra    d1,cexchangenextrow     and loop again
d1073 1
a1073 1
		rts
d1082 11
a1092 11
		movea.l controladdr(a5),a0
		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3
		movea.l (sp)+,a1                return address
		move.w  (sp)+,d2                width in characters
		move.w  (sp)+,d3                xmin in characters
		move.w  (sp)+,d1                ymax in lines
		move.w  (sp)+,d0                ymin in lines
		move.l  a1,-(sp)                stack return address
d1094 9
a1102 9
		sub     d0,d1                   d1 = number of rows - 1
		tst     d1
		beq     cscrollwinrts           1 line window
		mulu    charh(a3),d0            d0 = first row in pixels
		mulu    charh(a3),d1            d1 = number of rows in pixels

		subq    #1,d1                   subtract 1 to make loop correct
		mulu    charw(a3),d3            x offset in pixels
		mulu    charw(a3),d2            x width in pixels
d1104 2
a1105 2
		mulu    #width,d0
		add.l   d3,d0                   d0 = address of first row
d1107 2
a1108 2
		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d0,a1                   a1 = destination row
d1110 3
a1112 3
		moveq   #0,d3                   reuse d3
		move    charh(a3),d3
		mulu    #width,d3               number of rows per line height
d1114 1
a1114 1
		lsr     #2,d2                   number of longs per line
d1116 2
a1117 2
		move.l  #pagemode,d7            turn on page mode
		move.l  #0,0(a0,d7.l)
d1119 2
a1120 2
		btst    #3,sysflag2             test for 68040 to use move16
		bne     cscrollwin68030
d1124 2
a1125 2
		lsr     #2,d2                   number of move16's
		subq    #1,d2                   subtract 1 to make loop correct
d1128 3
a1130 3
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		adda.l  d3,a4                   set up source address
d1133 1
a1133 1
		dbra    d4,cscrollwinnextword   and loop
d1135 2
a1136 2
		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollwinnextrow    and loop again
d1138 1
a1138 1
		bra     cscrollwinpageoff
d1142 1
a1142 1
cscrollwin68030 subq    #1,d2                   subtract 1 to make loop correct
d1145 3
a1147 3
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		adda.l  d3,a4                   set up source address
d1150 1
a1150 1
		dbra    d4,cscrollwinnextword2  and loop
d1152 2
a1153 2
		adda.l  #width,a1               increment row by width
		dbra    d1,cscrollwinnextrow2   and loop again
d1155 2
a1156 2
cscrollwinpageoff move.l #pagemode,d7           turn off page mode
		move.l  #1,0(a0,d7.l)
d1167 3
a1169 3
		move.l  #cursorcontrol1,d0
		ori     #cursoroffmask,0(a0,d0.l)
		rts
d1178 3
a1180 3
		move.l  #cursorcontrol1,d0
		andi    #cursoronmask,0(a0,d0.l)
		rts
d1189 11
a1199 11
		movea.l controladdr(a5),a0
		moveq   #0,d0
		move.l  d0,d1
		move.l  d0,d2
		move.l  d0,d3
		movea.l (sp)+,a1                return address
		move.w  (sp)+,d2                width in characters
		move.w  (sp)+,d3                xmin in characters
		move.w  (sp)+,d1                ymax in lines
		move.w  (sp)+,d0                ymin in lines
		move.l  a1,-(sp)                stack return address
d1201 7
a1207 7
		move.l  d1,d4
		sub     d0,d4                   number of lines-1
		tst     d4
		beq     cscrollwindnrts         1 line window
		mulu    charh(a3),d4            d4 = number of rows in pixels
		subq    #1,d4                   subtract 1 to make loop correct
		move.l  d4,d0                   d0 = number of rows-1
d1209 5
a1213 5
		addq    #1,d1                   1 more line down
		mulu    charh(a3),d1            d1 = last row in pixels
		subq    #1,d1                   1 row up (last row of dest)
		mulu    charw(a3),d3            x offset in pixels
		mulu    charw(a3),d2            x width in pixels
d1215 2
a1216 2
		mulu    #width,d1
		add.l   d3,d1                   d1 = address of last row
d1218 2
a1219 2
		movea.l screen(a5),a1           get base address of framebuffer
		adda.l  d1,a1                   a1 = destination row
d1221 3
a1223 3
		moveq   #0,d3                   reuse d3
		move    charh(a3),d3
		mulu    #width,d3               number of rows per line height
d1225 1
a1225 1
		lsr     #2,d2                   number of longs per line
d1227 2
a1228 2
		move.l  #pagemode,d7            turn on page mode
		move.l  #0,0(a0,d7.l)
d1230 2
a1231 2
		btst    #3,sysflag2             test for 68040 to use move16
		bne     cscrollwindn68030
d1235 2
a1236 2
		lsr     #2,d2                   number of move16's
		subq    #1,d2                   subtract 1 to make loop correct
d1239 3
a1241 3
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		suba.l  d3,a4                   set up source address
d1244 1
a1244 1
		dbra    d4,cscrollwindnnextword and loop
d1246 2
a1247 2
		suba.l  #width,a1               decrement row by width
		dbra    d0,cscrollwindnnextrow  and loop again
d1249 1
a1249 1
		bra     cscrollwindnpageoff
d1253 1
a1253 1
cscrollwindn68030 subq    #1,d2                 subtract 1 to make loop correct
d1256 3
a1258 3
		movea.l a1,a2                   set up destination address
		movea.l a1,a4
		suba.l  d3,a4                   set up source address
d1261 1
a1261 1
		dbra    d4,cscrollwindnnextword2 and loop
d1263 2
a1264 2
		suba.l  #width,a1               increment row by width
		dbra    d1,cscrollwindnnextrow2 and loop again
d1267 1
a1267 1
		subq    #1,d1
d1270 1
a1270 1
		movea.l a1,a2
d1273 1
a1273 1
		dbra    d4,cscrollwindnclrword2 and loop
d1275 2
a1276 2
		suba.l  #width,a1               increment row by width
		dbra    d1,cscrollwindnclrrow2  and loop again
d1278 2
a1279 2
cscrollwindnpageoff move.l #pagemode,d7         turn off page mode
		move.l  #1,0(a0,d7.l)
d1290 4
a1293 4
		moveq   #0,d1
		move.l  d1,d2
		move.l  d1,d3
		move.l  d1,d4
d1295 6
a1300 6
		movea.l (sp)+,a1                return address
		move.w  (sp)+,d4                width (in chars)
		move.w  (sp)+,d3                xmin (in chars)
		move.w  (sp)+,d2                ymax (in lines)
		move.w  (sp)+,d1                ymin (in lines)
		move.l  a1,-(sp)                stack return address
d1302 9
a1310 9
		sub     d1,d2
		addq    #1,d2                   add 1 to lines
		mulu    charh(a3),d2            d2 = number of rows in pixels
		mulu    charh(a3),d1            d1 = first row in pixels
		mulu    charw(a3),d3            d3 = first column
		subq    #1,d4                   1 char less
		beq     cdbscrolllrts           1 column window
		mulu    charw(a3),d4            number of columns
		lsr     #2,d4                   d4 = number of long words
d1312 4
a1315 4
		movea.l screen(a5),a1
		mulu    #width,d1
		adda.l  d1,a1
		adda.l  d3,a1                   address of first pixel
d1317 2
a1318 2
		subq    #1,d2                   subtract 1 to make loop correct
		subq    #1,d4                   subtract 1 to make loop correct
d1321 3
a1323 3
		movea.l a2,a4
		move.l  d4,d3                   reuse d3 for counter
		adda    charw(a3),a4            set up source address
d1326 1
a1326 1
		dbra    d3,cdbscrolllnextword
d1328 3
a1330 3
		adda.l  #width,a1
		dbra    d2,cdbscrolllnextrow

d1340 5
a1344 5
		movea.l controladdr(a5),a0
		moveq   #0,d1
		move.l  d1,d2
		move.l  d1,d3
		move.l  d1,d4
d1346 6
a1351 6
		movea.l (sp)+,a1                return address
		move.w  (sp)+,d4                width
		move.w  (sp)+,d3                xmin
		move.w  (sp)+,d2                ymax
		move.w  (sp)+,d1                ymin
		move.l  a1,-(sp)                stack return address
d1353 8
a1360 8
		sub     d1,d2
		addq    #1,d2                   add 1 to lines
		mulu    charh(a3),d2            d2 = number of rows
		mulu    charh(a3),d1            d1 = first row
		mulu    charw(a3),d3            d3 = first column
		subq    #1,d4                   1 less char
		beq     cdbscrollrrts           1 column window
		mulu    charw(a3),d4            number of columns
d1362 6
a1367 6
		move.l  screen(a5),a1
		mulu    #width,d1
		adda.l  d1,a1
		adda.l  d3,a1
		adda.l  d4,a1                   address of first pixel
		addq    #4,a1                   subtract later with pre-dec
d1369 1
a1369 1
		lsr     #2,d4                   d4 = number of long words
d1371 1
a1371 1
		subq    #1,d2                   subtract 1 to make loop correct
d1373 1
a1373 1
cdbscrollrnextrow movea.l a1,a2                 set up source address
d1375 2
a1376 2
		move.l  d4,d3                   reuse d3 for counter
		adda    charw(a3),a4            set up destination address
d1379 1
a1379 1
		dbra    d3,cdbscrollrnextword
d1381 3
a1383 3
		adda.l  #width,a1
		dbra    d2,cdbscrollrnextrow

d1394 3
a1396 3
		movea.l controladdr(a5),a0
		moveq   #0,d2
		move.l  d1,d3
d1398 6
a1403 6
		move.l  #blockmode,d6
		move.l  #0,0(a0,d6.l)           turn on block mode
		move.l  #vramcolor1,d5
		move.l  #0,0(a0,d5.l)           set color registers to 0
		move.l  #maskreg,d5
		move.l  #-1,0(a0,d5.l)          to clear on all planes
d1405 7
a1411 7
		move.l  screen(a5),a1           base address of FB
		move    disph(a3),d2            get width and height in pixels
		move    dispw(a3),d3
		lsr     #4,d3                   change to number of words
		subq    #1,d2
		subq    #1,d3
		movea.l a1,a2                   make a copy for reference
d1414 1
a1414 1
		movea.l a2,a1                   reset to beginning of next line
d1417 1
a1417 1
		dbra    d4,nextword             and loop
d1419 2
a1420 2
		adda.l  #widthdiv16,a2          increment row by width
		dbra    d2,nextrow              and loop again
d1422 2
a1423 2
		move.l  #1,0(a0,d6.l)           turn off block mode
		rts
d1438 6
a1443 6
		movea.l (sp)+,a1                return address
		move.l  (sp)+,d3
		move.l  (sp)+,d2
		move.l  (sp)+,d1
		move.l  (sp)+,d0                get data off stack as longs
		move.l  a1,-(sp)                stack return address
d1445 1
a1445 1
		move.l  #blueregimage,d5
d1448 7
a1454 7
		bne.s   ccheckblue              loop until bit is clear
		move.l  #dacimagewrite,d6
		move.b  d0,0(a0,d6.l)           write the index to the DAC
		move.b  d1,4(a0,d6.l)           then red to the DAC
		move.b  d2,4(a0,d6.l)           then green to the DAC
		move.b  d3,3(a0,d5.l)           then blue to BEECH
		rts
d1463 6
a1468 6
		movea.l controladdr(a5),a0
		movea.l (sp)+,a1                return address
		move.w  (sp)+,d2                register value
		move.l  (sp)+,d1                register number
		move.l  a1,-(sp)                stack return address
		rts
d1477 5
a1481 5
		movea.l controladdr(a5),a0
		movea.l (sp)+,a1                return address
		movea.l (sp)+,a2
		move.l  a1,-(sp)                stack return address
		rts
d1490 5
a1494 5
		movea.l controladdr(a5),a0
		movea.l (sp)+,a1                return address
		movea.l (sp)+,a2
		move.l  a1,-(sp)                stack return address
		rts
d1503 6
a1508 6
	    movea.l  controladdr(a5),a0
	    movea.l  (sp)+,a1           return address
	    adda.l   (sp)+,a0           offset
	    movep    0(a0),d0
	    move     d0,(sp)            store on stack as function value
	    jmp      (a1)
d1517 2
a1518 2
		movea.l controladdr(a5),a0
		rts
d1540 1
a1540 1
cprepdumpline   equ *
d1551 1
a1551 1
preploop        equ    *
d1563 1
a1563 1
initcharbuf     equ *
d1572 1
a1572 1
fixstrlen       equ   *
d1596 6
a1601 6
		movea.l controladdr(a5),a0
		movea.l (sp)+,a1                return address
		movea.l (sp)+,a2                buffer address
		move.w  (sp)+,d1                size of buffer in bytes
		movea.l (sp)+,a4                row start address of FB
		move.l  a1,-(sp)                stack return address
d1603 1
a1603 1
		moveq   #0,d2
d1605 2
a1606 2
		move    displaywidth(a0),d2     get width of display
		subq    #1,d2                   make loop correct
d1608 3
a1610 3
cprepchecklast  tst.b   0(a4,d2.l)              any bits set?
		bne     cprepfoundlast
		dbra    d2,cprepchecklast
d1612 3
a1614 3
		move.b  #0,(a2)                 no bits on this line
		moveq   #1,d2                   make at least one
		bra     cprepcalcascii
d1616 7
a1622 7
cprepfoundlast  addq    #1,d2                   d2 now has number of bits set
		move.l  d2,d3
		andi    #7,d3                   get remainder (d2 mod 8)
		lsr     #3,d2                   number of bytes (d2 / 8)
		tst     d3                      any remainder?
		beq     cprepmakebyte           no, get data
		addq    #1,d2                   yes, round up to next byte
d1624 4
a1627 4
cprepmakebyte   move    d2,d4                   make copy for later
		subq    #1,d4                   subtract 1 to make loop correct
		moveq   #0,d5                   clear d5
		moveq   #7,d6                   check 8 bytes
d1629 5
a1633 5
cprepnextbit    lsl     #1,d5
		tst.b   (a4)+                   any bits set?
		beq     cprepcheckloop          no bits set
		ori.b   #1,d5                   there's a bit set, add to byte
cprepcheckloop  dbra    d6,cprepnextbit
d1635 2
a1636 2
		move.b  d5,(a2)+
		dbra    d4,cprepmakebyte
d1640 1
a1640 1
cprepcalcascii  equ     *
d1654 3
a1656 3
		rol.l   #8,d2                   justify for copy to outbuf
		ori.b   #'W',d2                 now have 'xxxW' in longword
		move.l  d2,-4(a2)               copy to outbuf
d1658 1
a1658 1
		rts
d1667 2
a1668 2
		movea.l controladdr(a5),a0
		rts
@


1.9
log
@
pws2rcs automatic delta on Wed Aug 21 12:59:22 MDT 1991
@
text
@@


1.8
log
@Increase font storage size to handle 10x20 characters - CFB
@
text
@d1 1
a1 1
             page
d28 6
a33 6
                def     cscrollup,cscrolldown,cupdatecursor,cchar,cclear
                def     cbuildtable,cshiftleft,cshiftright
                def     cexchange,cscrollwindow,cursoroff
                def     cscrollwinddn,cdbscrolll,cdbscrollr,cclearall
                def     csetcolormap,csetreg,csavewoodenv,crestorewoodenv
                def     cromshort,csetupcchar,cprepdumpline
d35 1
a35 1
                def     setupcchar
d37 1
a37 1
                rorg.l 0
d39 1
a39 1
                refa    woodcutdvr,sysdevs
d41 2
a42 2
                nosyms
                sprint
a188 1
displayid       equ     $00000015       secondary ID byte
d191 1
a191 1
framecount      equ     $0000005B       number of frames
d199 1
a199 1
sysflag2	equ	$FFFFFEDA
d203 5
a207 5
*					kludge because MOVE16 is 16 byte aligned
*					and we don't know where zero16 will be
		dc.l	0,0,0,0	 	16 bytes of zeros
zero16		dc.l	0,0,0,0	 	16 bytes of zeros
		dc.l	0,0,0,0	 	16 bytes of zeros
d211 3
a213 1
fontstorage1    ds.l    19200    increaed to support 384 10x20 chars CFB 12AUG91
d223 4
a226 7
                tst.b   hascolor(a5)          color?
                bne     cmapstart             yes, jump over greyscale
                lea     gmaptable,a1          initialize the greyscale color map
cmapstart       moveq   #0,d1                 clear some registers
                move.l  d1,d2
                move.l  d1,d3
                move.l  d1,d4
d228 9
a236 9
                move.b  (a1)+,d3
                move.b  (a1)+,d4
                bsr     cmapenter             call the color map entry routine
                addq    #1,d1                 bump cmap pointer value
                cmp     #16,d1                have we done 16 yet?
                bne.s   cmaploop1             if not then continue
                moveq   #-1,d2                set entries 16-255 to white
                move.l  d2,d3
                move.l  d2,d4
d238 3
a240 3
                addq    #1,d1
                cmp     #256,d1                 done with cmap init?
                bne.s   cmaploop2
d242 3
a244 3
                move.l  #blueregcursor,d6
                move.l  #dacoverlaywrite,d5
                move.l  #colormapvalue,d7
d247 5
a251 5
                bne.s   cursorcmapwait          loop till bit is clear
                move.b  #2,0(a0,d5.l)           write the index to the DAC
                move.b  #0,0(a0,d7.l)           then red to the DAC
                move.b  #0,0(a0,d7.l)           then green to the DAC
                move.b  #0,3(a0,d6.l)           then blue to BEECH
d254 6
a259 6
                bne.s   cursorcmapwait2         loop till bit is clear
                move.b  #3,0(a0,d5.l)           write the index to the DAC
                move.b  #255,0(a0,d7.l)         then red to the DAC
                move.b  #255,0(a0,d7.l)         then green to the DAC
                move.b  #255,3(a0,d6.l)         then blue to BEECH
                rts
d262 2
a263 2
                move.l  #dacimagewrite,d5
                move.l  #colormapvalue,d7
d266 5
a270 5
                bne.s   cmapwait                loop till bit is clear
                move.b  d1,0(a0,d5.l)           write the index to the DAC
                move.b  d2,0(a0,d7.l)           then red to the DAC
                move.b  d3,0(a0,d7.l)           then green to the DAC
                move.b  d4,3(a0,d6.l)           then blue to BEECH
d272 1
a272 1
                rts                             done with cmap entry write
d284 17
a300 6
                moveq   #0,d0
                move.l  d0,d1
                move    charw(a3),d0
                move    charh(a3),d1
                move    d1,d2
                mulu    d0,d2                   number of bytes/char
d303 1
a303 1
                subq    #2,a2                   added back later
d305 1
a305 1
                subq    #1,d5
d307 1
a307 1
                addq    #2,a2                   look at next font byte
d309 5
a313 5
                sne     (a4)+                   set frame buffer byte if bit set
                dbra    d4,unpackbyte           loop till all 8 bits done
                dbra    d5,unpackrow            and loop till rows in char done
                dbra    d3,unpackchar           loop till all chars done
                rts                             go look at next font
d324 8
a331 8
                moveq    #0,d0
                move.b   2(a1),d0           get word count to initialize
                movep    4(a1),d1           form destination offset
                add.l    a0,d1              d1 points to dest addr
                lea      8(a1),a2           a2 points to first data byte
                movea.l  d1,a4              a4 points to destination
                btst     #0,(a1)            is this a bit test block?
                bne.s    ginitbtst          if so go handle it
d333 4
a336 4
                move.w   d1,(a4)+           move data to the destination addr
                btst     #6,(a1)            increment data pointer
                bne.s    ginit1             based on control byte
                addq     #4,a2
d338 4
a341 4
                btst     #7,(a1)            was this last block?
                bne.s    ginitdone          yes -- go return
                btst     #6,(a1)            adjust data pointer
                beq.s    ginit2             to point to next init block
d344 1
a344 1
                bra      ginitblock         do the initialize
d347 1
a347 1
                move.b   2(a2),d2           d2 = bit # to test
d349 3
a351 3
                btst     #0,(a2)            check for sense of test
                bne.s    ginittst3          comp if waiting for 0
                not      d3
d353 4
a356 4
                beq      ginittst2          if not 1 then loop
                btst     #7,(a1)            was this last block?
                bne.s   ginitdone          if so then return
                bra      ginit3             else do next block
d367 10
a376 12
                movea.l crtinfo(a5),a3          crtparamrec
                movep   initoffset(a0),d1       form pointer to init block
                movea.l a0,a1                   make copy of ROM start addr
                adda.l  d1,a1                   a1 points to init info now
                jsr     ginitblock              call the initialization routine
                clr.b   hascolor(a5)            clear color flag
                cmpi.b  #17,displayid(a0)       greyscale?
                bgt     cframeaddr              yes, don't set color
                st      hascolor(a5)            set for color
cframeaddr      movea.l a0,a1                   make copy of ROM start addr
                adda.l  #framebuffer,a1         add offset to frame buffer
                move.l  a1,screen(a5)           form frame buffer addr
d378 7
a384 7
                move.b  framecount(a0),d0       d0=# of planes in system
                beq.s   cnumplanes              if zero then read planes
                moveq   #8,d1                   else make the mask up
                moveq   #$ff,d2
                sub     d0,d1                   d1 has shift count
                lsr.b   d1,d2                   after shift d2 has mask
                bra.s   csetplanes              go setup planemask
d387 3
a389 3
                movea.l screen(a5),a1           addr of fb in a1
                move.b  #$FF,(a1)               write all 1's
                move.b  (a1),d2                 read it back to get plane mask
d391 2
a392 2
                move.b  d2,3+planemask(a3)      save as plane mask
                jsr     loadcmap                load the color map
d396 14
a409 14
                move    d0,dispx(a3)            set positions to (0,0)
                move    d0,dispy(a3)
                move    d0,printx(a3)
                move    d0,printy(a3)
                movep.w framewidth(a0),d2       get width from ROM
                move    d2,fbwidth(a3)
                movep.w displaywidth(a0),d2    set visible width as window width
                movep.w frameheight(a0),d2      get height from ROM
                move    d2,fbheight(a3)
                movep.w displaywidth(a0),d2
                cmp     #1024,d2
                beq.s   setuplcc
                cmp     #640,d2                 no offscreen available
                beq.s   setupvga
d412 5
a416 5
                move    #1280,offx(a3)
                move    #0,offy(a3)
                move    #768,offw(a3)
                move    #1024,offh(a3)
                bra.s   donesetupoff
d418 6
a423 6
setuplcc        equ	*                       no offscreen available
                move    #0,offx(a3)
                move    #0,offy(a3)
                move    #0,offw(a3)
                move    #0,offh(a3)
                bra.s   donesetupoff
d426 4
a429 4
                move    #640,offx(a3)           and at the bottom. right larger
                move    #0,offy(a3)
                move    #384,offw(a3)
                move    #512,offh(a3)
d432 4
a435 4
                move    d2,dispw(a3)
                move    d2,printw(a3)
                movep.w displayheight(a0),d2
                move    d2,disph(a3)
d437 6
a442 4
                moveq   #0,d0
                move.l  d0,d1
                move.l  d0,d2
                move.l  d0,d7
d444 10
a453 5
                movep   fontoffset(a0),d1       get font info offset
                move.b  (a0,d1.w),d7            d3 = number of fonts
                subq    #1,d7                   subtract 1 to make loop correct
                lea     4(a0,d1.w),a1           a1 = address of font offset
                lea     (fontstorage1),a4       a4 = address of font storage
a454 20
getfontinfo     movep   0(a1),d2                d2 = offset to font info
                lea     0(a0,d2.l),a2           a3 = address of font info

                moveq   #0,d1                   clear d1 for re-use
                move.b  (a2),d0                 d0 = font height
                move.b  2(a2),d1                d1 = font width
                move    d0,charh(a3)            store them for later use
                move    d1,charw(a3)

                moveq   #0,d3
                move.b  8(a2),d3                get last char value
                sub.b   6(a2),d3                subtract first char value
*                                               d3 = number of chars in font

                adda.l  #10,a2                  a2 now points to first char
                bsr     unpkroman               if so go unpack it

                adda.l  #6,a1                   a1 = address of next font
                dbra    d7,getfontinfo

d456 1
a456 1
                jsr     cursoroff
d458 1
a458 1
                move.l  #cursorcontrol1,d2
d460 2
a461 2
                move.l  #colormask,d0           write to the cursor image
                move.l  #1023,d1                clear the entire cursor
d464 4
a467 4
                bne.s   buildcursorclr
                move    #0,0(a0,d0.l)
                addq.l  #4,d0
                dbra    d1,buildcursorclr
d469 2
a470 2
                move.l  #colormask,d0           create cursor image
                moveq   #1,d4                   2 rows
d473 1
a473 1
                move.l  d0,d1                   beginning of row
d475 6
a480 6
                bne.s   buildcursorclr2
                move    #-1,0(a0,d1.l)
                addq.l  #4,d1                   next 4 pixels
                dbra    d3,buildcursorclr2
                addi.l  #64,d0                  next row
                dbra    d4,buildcursorclr3
d482 2
a483 2
                move.l  #visiblemask,d0         write to the cursor mask
                move.l  #1023,d1                clear the entire mask
d486 4
a489 4
                bne.s   buildcursorvis
                move    #0,0(a0,d0.l)
                addq.l  #4,d0
                dbra    d1,buildcursorvis
d491 2
a492 2
                move.l  #visiblemask,d0         create "cookie cutter"
                moveq   #1,d4                   2 rows
d495 1
a495 1
                move.l  d0,d1                   beginning of row
d497 6
a502 6
                bne.s   buildcursorvis2
                move    #-1,0(a0,d1.l)
                addq.l  #4,d1                   next 4 pixels
                dbra    d3,buildcursorvis2
                addi.l  #64,d0                  next row
                dbra    d4,buildcursorvis3
d504 2
a505 2
                move.l  #cursorcontrol0,d0
                move.l  #0,0(a0,d0.l)           clear y-clip LSB's
d507 2
a508 2
                move.l  #cursorcontrol1,d0
                andi    #$000c0,0(a0,d0.l)      clear y-clip MSB's
d510 1
a510 1
                jsr     cursoron
d512 4
a515 4
                move.l  #readmask,d2
                move.b  #255,0(a0,d2)           turn on all planes
                
                rts
d523 16
a538 16
                dc.b    0,0,0                   0
                dc.b    255,255,255             1
                dc.b    255,0,0                 2
                dc.b    255,255,0               3
                dc.b    0,255,0                 4
                dc.b    0,255,255               5
                dc.b    0,0,255                 6
                dc.b    255,0,255               7
                dc.b    0,0,0                   8
                dc.b    204,187,51              9
                dc.b    51,170,119              10
                dc.b    136,102,170             11
                dc.b    204,68,102              12
                dc.b    255,102,51              13
                dc.b    255,119,0               14
                dc.b    221,136,68              15
a539 19
gmaptable       equ     *           initial greyscale color map contents (r,g,b)
                dc.b    0,0,0                   0
                dc.b    0,255,0                 1
                dc.b    0,239,0                 2
                dc.b    0,233,0                 3
                dc.b    0,207,0                 4
                dc.b    0,191,0                 5
                dc.b    0,175,0                 6
                dc.b    0,159,0                 7
                dc.b    0,143,0                 8
                dc.b    0,128,0                 9
                dc.b    0,112,0                10
                dc.b    0,96,0                 11
                dc.b    0,80,0                 12
                dc.b    0,64,0                 13
                dc.b    0,48,0                 14
                dc.b    0,32,0                 15
                dc.b    0,16,0                 16

d549 5
a553 5
                movea.l controladdr(a5),a0
                moveq   #0,d0
                move.l  d0,d1
                move.l  d0,d2
                move.l  d0,d3
d555 5
a559 5
                move    printy(a3),d0
                move    printh(a3),d1           set up window size
                sub     charh(a3),d1            one less row
                sub     d0,d1                   d1 = number of rows
                subq    #1,d1                   subtract 1 to make loop correct
d561 1
a561 1
                mulu    #width,d0               d0 = address of first row
d563 2
a564 2
                movea.l screen(a5),a1           get base address of framebuffer
                adda.l  d0,a1                   a1 = destination row
d566 2
a567 2
                move    charh(a3),d3
                mulu    #width,d3               number of rows per line height
d569 2
a570 2
                move    printw(a3),d2
                lsr     #2,d2                   number of longs per line
d572 2
a573 2
                move.l  #pagemode,d7		turn on page mode
                move.l  #0,0(a0,d7.l)
d575 2
a576 2
		btst	#3,sysflag2		test for 68040 to use move16
		bne	cscroll68030
d580 2
a581 2
		lsr	#2,d2			number of move16's
                subq    #1,d2			subtract 1 to make loop correct
d584 3
a586 3
                movea.l a1,a2                   set up destination address
                movea.l a1,a4
                adda.l  d3,a4                   set up source address
d589 1
a589 1
                dbra    d4,cscrollnextword      and loop
d591 2
a592 2
                adda.l  #width,a1               increment row by width
                dbra    d1,cscrollnextrow       and loop again
d594 2
a595 2
                move    charh(a3),d1            set up to clear next line
                subq    #1,d1
d598 1
a598 1
                movea.l a1,a2
d601 1
a601 1
                dbra    d4,cscrollclrword       and loop
d603 2
a604 2
                adda.l  #width,a1               increment row by width
                dbra    d1,cscrollclrrow        and loop again
d606 1
a606 1
                bra	cscrollpageoff
d610 1
a610 1
cscroll68030    subq    #1,d2			subtract 1 to make loop correct
d613 3
a615 3
                movea.l a1,a2                   set up destination address
                movea.l a1,a4
                adda.l  d3,a4                   set up source address
d618 1
a618 1
                dbra    d4,cscrollnextword2     and loop
d620 2
a621 2
                adda.l  #width,a1               increment row by width
                dbra    d1,cscrollnextrow2      and loop again
d623 2
a624 2
                move    charh(a3),d1            set up to clear next line
                subq    #1,d1
d627 1
a627 1
                movea.l a1,a2
d630 1
a630 1
                dbra    d4,cscrollclrword2      and loop
d632 2
a633 2
                adda.l  #width,a1              increment row by width
                dbra    d1,cscrollclrrow2       and loop again
d635 2
a636 2
cscrollpageoff  move.l  #pagemode,d7		turn off page mode
                move.l  #1,0(a0,d7.l)
d648 5
a652 5
                movea.l controladdr(a5),a0
                moveq   #0,d0
                move.l  d0,d1
                move.l  d0,d2
                move.l  d0,d3
d654 5
a658 5
                move    printh(a3),d0           get last row
                sub     charh(a3),d0            start one line height up
                move    d0,d1                   set up window size
                sub     printy(a3),d1           d1 = number of rows
                subq    #1,d1                   subtract 1 to make loop correct
d660 1
a660 1
                mulu    #width,d0               d0 = address of last row
d662 2
a663 2
                movea.l screen(a5),a1           get base address of framebuffer
                adda.l  d0,a1                   a1 = source row
d665 2
a666 2
                move    charh(a3),d3
                mulu    #width,d3               number of rows per line height
d668 2
a669 2
                move    printw(a3),d2
                lsr     #2,d2                   number of longs per line
d671 2
a672 2
                move.l  #pagemode,d7		turn on page mode
                move.l  #0,0(a0,d7.l)
d674 2
a675 2
		btst	#3,sysflag2		test for 68040 to use move16
		bne	cscrolld68030
d679 2
a680 2
		lsr	#2,d2			number of move16's
                subq    #1,d2
d683 3
a685 3
                movea.l a1,a2
                movea.l a1,a4
                adda.l  d3,a4                   set up source address
d688 1
a688 1
                dbra    d4,cscrolldnextword     and loop
d690 2
a691 2
                suba.l  #width,a1               decrement row by width
                dbra    d1,cscrolldnextrow      and loop again
d693 2
a694 2
                move    charh(a3),d1            set up to clear next line
                subq    #1,d1
d697 1
a697 1
                movea.l a1,a2
d700 1
a700 1
                dbra    d4,cscrolldclrword      and loop
d702 2
a703 2
                adda.l  #width,a1               decrement row by width
                dbra    d1,cscrolldclrrow       and loop again
d705 1
a705 1
                bra	cscrolldpageoff
d712 3
a714 3
                movea.l a1,a2
                movea.l a1,a4
                adda.l  d3,a4                   set up source address
d717 1
a717 1
                dbra    d4,cscrolldnextword2    and loop
d719 2
a720 2
                suba.l  #width,a1               decrement row by width
                dbra    d1,cscrolldnextrow2     and loop again
d722 2
a723 2
                move    charh(a3),d1            set up to clear next line
                subq    #1,d1
d726 1
a726 1
                movea.l a1,a2
d729 1
a729 1
                dbra    d4,cscrolldclrword2     and loop
d731 2
a732 2
                adda.l  #width,a1               decrement row by width
                dbra    d1,cscrolldclrrow2      and loop again
d734 2
a735 2
cscrolldpageoff move.l  #pagemode,d7		turn off page mode
                move.l  #1,0(a0,d7.l)
d737 1
a737 1
                rts
d746 6
a751 6
                movea.l controladdr(a5),a0
                moveq   #0,d0                   clear some registers
                move.l  d0,d1
                move.l  d0,d2
                move.l  d0,d3
                move.l  d0,d4
d753 4
a756 4
                movea.l (sp)+,a4                a4 = return addr
                move    (sp)+,d1                y in chars
                move    (sp)+,d2                x in chars
                move.l  a4,-(sp)                stack return address
d758 6
a763 6
                mulu    charh(a3),d1
                add     charh(a3),d1            put cursor under the character
                subq    #1,d1
                move.l  #timingv0,d3
                add     0(a0,d3.l),d1           add yoffset (see WOODCUT ERS)
                move    d1,ycurs(a5)            y position in pixels
d765 7
a771 7
                mulu    charw(a3),d2
                move.l  #timingh0,d3
                move    0(a0,d3.l),d4
                subq    #4,d4
                lsl     #2,d4                   multiply by 4
                add     d4,d2                   add xoffset (see WOODCUT ERS)
                move    d2,xcurs(a5)            x position in pixels
d773 6
a778 6
                jsr     cursoroff
                move.l  #cursorposition,d3      update cursor position
                move    d1,0(a0,d3.l)
                move    d2,2(a0,d3.l)
                jsr     cursoron
                rts 
d788 14
a801 14
                movea.l controladdr(a5),a0
                movea.l (sp)+,a1                get the return address
                moveq   #0,d0                   clear some registers
                move.l  d0,d1
                move.l  d0,d2
                move.l  d0,d4
                move.l  d0,d5
                move    (sp)+,d0                y coordinate in rows
                move    (sp)+,d1                x coordinate in chars
                move    (sp)+,d2                character to write
                move.l  a1,-(sp)                put the return address back
                lea     (fontstorage1),a2       get font base address
                move    charh(a3),d4            d4 =  font height
                move    charw(a3),d5            d5 =  font width
d803 2
a804 2
                mulu    d4,d0                   d0 = y coordinate in pixels
                mulu    d5,d1                   d1 = x coordinate in pixels
d806 2
a807 2
                mulu    d4,d2                   char # times height
                mulu    d5,d2                   times width -> font offset
d809 1
a809 1
                lsr     #2,d5                   font width in longs
d811 4
a814 4
                move.l  d0,d3                   start with row number
                mulu    #width,d3               times row width
                add     d1,d3                   plus column number
                addi.l  #framebuffer,d3         plus frame buffer base
d816 5
a820 5
                movea.l a0,a4
                adda.l  d3,a4                   now a4 has address of FB
                suba    #width,a4               add back later
                subq    #1,d4                   subtract 1 to make loop correct
                subq    #1,d5
d822 9
a830 12
		moveq	#0,d0
		move	alphacolor(a3),d0	get color (will only be a byte)
		move.b	d0,d1			set up long word mask
		lsl.l	#8,d1
		or.b	d0,d1
		lsl.l	#8,d1
		or.b	d0,d1
		lsl.l	#8,d1
		or.b	d0,d1
		
                move.l  #maskreg,d6
                move.l  #-1,0(a0,d6.l)          enable writes to all planes
d832 2
a833 1
                adda.l  d2,a2                   a2 = char start addr
d835 2
d838 2
a839 2
                movea.l a4,a1                   make copy to be incremented
                move.l  d5,d6
d842 3
a844 8
                btst    #0,highlight(a3)        inverse video?
                beq.s   ccharputchar		no, skip over invert
		not.l	d0
		
ccharputchar	and.l	d1,d0			and in color mask
		move.l	d0,(a1)+                write to frame buffer
                dbra    d6,ccharnextcol
                dbra    d4,ccharnextrow
d846 5
d852 2
a853 2
		bne.s   dounderline		yes, do the underline
                rts
d855 3
a857 3
dounderline	btst    #0,highlight(a3)        inverse video?
                beq.s   dounderline2		no, skip over invert
		moveq	#0,d1			make underline pen 0
d859 1
a859 1
dounderline2	move.l d1,-(a1)			underline going backward
d862 1
a862 1
                rts
d874 1
a874 1
                movea.l controladdr(a5),a0
d876 3
a878 3
                moveq   #0,d1
                move.l  d1,d2
                move.l  d1,d3
d880 5
a884 5
                movea.l (sp)+,a1                return address
                move    (sp)+,d1                d1 = number of chars to clear
                move    (sp)+,d2                d2 = y to begin at
                move    (sp)+,d3                d3 = x to begin at
                move.l  a1,-(sp)                put back the return address
d886 4
a889 4
                mulu    charw(a3),d1            d1 = length in pixels
                lsr     #2,d1                   length in long words
                mulu    charh(a3),d2            d2 = y in pixels
                mulu    charw(a3),d3            d3 = x in pixels
d891 4
a894 4
                move.l  #vramcolor1,d7
                move.l  #0,0(a0,d7.l)           set color registers to 0
                move.l  #maskreg,d7
                move.l  #-1,0(a0,d7.l)          to clear on all planes
d896 4
a899 4
                move.l  screen(a5),a1           base address of FB
                mulu    #width,d2               multiply row * width
                adda.l  d2,a1                   add to the FB address
                adda.l  d3,a1                   add on the column
d901 5
a905 5
                moveq   #0,d2
                move    charh(a3),d2            d2 = # of rows
                
                subq    #1,d1                   subtract 1 to make loop correct
                subq    #1,d2
d908 1
a908 1
                movea.l a1,a2                   reset to next line
d910 4
a913 4
                dbra    d4,cclearnextword       and loop
                adda.l  #width,a1               increment row by width
                dbra    d2,cclearnextrow        and loop again
                rts
d922 4
a925 4
                movea.l controladdr(a5),a0
                moveq   #0,d1
                move.l  d1,d2
                move.l  d1,d3
d927 7
a933 7
                move    printw(a3),d2           calculate width of lastline
                move    charw(a3),d3
                mulu    #8,d3                   lastline ends 8 from right edge
                sub     d3,d2                   width of last line
                lsr     #2,d2                   d2 = width in long words
                move    printy(a3),d3           start at upper y
                add     printh(a3),d3           add print height -> last row
d935 2
a936 2
                mulu    #width,d3               offset address of last line
                add     printx(a3),d3           add on column
d938 2
a939 2
                movea.l screen(a5),a1           get base address of framebuffer
                adda.l  d3,a1                   a1 = destination address
d941 3
a943 3
                move    charh(a3),d1            d1 = number of rows
                moveq   #0,d3
                move    charw(a3),d3            d3 = width of char
d945 2
a946 2
                subq    #1,d1                   subtract 1 to make loop correct
                subq    #1,d2
d949 1
a949 1
                movea.l a1,a2
d951 3
a953 3
                dbra    d4,cshiftlnextword      and loop
                adda.l  #width,a1               next row
                dbra    d1,cshiftlnextrow       and loop
d955 1
a955 1
                rts
d964 4
a967 4
                movea.l controladdr(a5),a0
                moveq   #0,d1
                move.l  d1,d2
                move.l  d1,d3
d969 6
a974 6
                move    printw(a3),d2           calculate width of lastline
                move    charw(a3),d3
                mulu    #9,d3                   lastline ends 9 from right edge
                sub     d3,d2                   width of last line
                move    printy(a3),d3           start at upper y
                add     printh(a3),d3           add print height -> last row
d976 4
a979 4
                mulu    #width,d3               offset address of last line
                add     printx(a3),d3           add on column
		add	d2,d3			add width
                lsr     #2,d2                   d2 = width in long words
d981 2
a982 2
                movea.l screen(a5),a1           get base address of framebuffer
                adda.l  d3,a1                   a1 = destination address
d984 3
a986 3
                move    charh(a3),d1            d1 = number of rows
                moveq   #0,d3
                move    charw(a3),d3            d3 = width of char
d988 1
a988 1
                subq    #1,d1                   subtract 1 to make loop correct
d991 1
a991 1
                movea.l a1,a2
d993 4
a996 4
		subq	#4,a2
                dbra    d4,cshiftrnextword      and loop
                adda.l  #width,a1               next row
                dbra    d1,cshiftrnextrow       and loop
d998 1
a998 1
                rts
d1007 5
a1011 5
                movea.l controladdr(a5),a0
		moveq	#0,d0
		move.l	d0,d1
		move.l	d0,d2
		move.l	d0,d3
d1013 7
a1019 7
                movea.l (sp)+,a1                return address
                move.w  (sp)+,d2                width in pixels
                move.w  (sp)+,d3                xmin
                move.w  (sp)+,d1                ymax
                move.w  (sp)+,d0                ymin
                movea.l (sp)+,a2                pointer to the window
                move.l  a1,-(sp)                stack return address
d1021 6
a1026 6
		mulu	charh(a3),d0		d0 = first row in pixels
		mulu	charh(a3),d1		d1 = last row in pixels
                sub     d0,d1                   d1 = number of rows
		add	charh(a3),d1		don't forget last row
                subq    #1,d1                   subtract 1 to make loop correct
		mulu	charw(a3),d3		x offset in pixels
d1028 2
a1029 2
                mulu    #width,d0               
                add.l   d3,d0                   d0 = address of first row
d1031 2
a1032 2
                movea.l screen(a5),a1           get base address of framebuffer
                adda.l  d0,a1                   a1 = source address
d1034 2
a1035 2
                lsr     #2,d2                   number of longs per line
                subq    #1,d2			subtract 1 to make loop correct
d1038 1
a1038 1
                movea.l a1,a4
d1041 3
a1043 3
		move.l	(a2),(a4)+		replace display with save
                move.l  d7,(a2)+                replace save with temp
                dbra    d4,cexchangenextword    and loop
d1045 2
a1046 2
                adda.l  #width,a1               increment row by width
                dbra    d1,cexchangenextrow     and loop again
d1048 1
a1048 1
                rts
d1057 11
a1067 11
                movea.l controladdr(a5),a0
		moveq	#0,d0
		move.l	d0,d1
		move.l	d0,d2
		move.l	d0,d3
                movea.l (sp)+,a1                return address
                move.w  (sp)+,d2                width in characters
                move.w  (sp)+,d3                xmin in characters
                move.w  (sp)+,d1                ymax in lines
                move.w  (sp)+,d0                ymin in lines
                move.l  a1,-(sp)                stack return address
d1069 9
a1077 9
                sub     d0,d1                   d1 = number of rows - 1
                tst     d1
                beq     cscrollwinrts           1 line window
		mulu	charh(a3),d0		d0 = first row in pixels
		mulu	charh(a3),d1		d1 = number of rows in pixels
                
                subq    #1,d1                   subtract 1 to make loop correct
		mulu	charw(a3),d3		x offset in pixels
		mulu	charw(a3),d2		x width in pixels
d1079 2
a1080 2
                mulu    #width,d0               
                add.l   d3,d0                   d0 = address of first row
d1082 2
a1083 2
                movea.l screen(a5),a1           get base address of framebuffer
                adda.l  d0,a1                   a1 = destination row
d1085 3
a1087 3
		moveq	#0,d3			reuse d3
                move    charh(a3),d3
                mulu    #width,d3               number of rows per line height
d1089 1
a1089 1
                lsr     #2,d2                   number of longs per line
d1091 2
a1092 2
                move.l  #pagemode,d7		turn on page mode
                move.l  #0,0(a0,d7.l)
d1094 2
a1095 2
		btst	#3,sysflag2		test for 68040 to use move16
		bne	cscrollwin68030
d1099 2
a1100 2
		lsr	#2,d2			number of move16's
                subq    #1,d2			subtract 1 to make loop correct
d1103 3
a1105 3
                movea.l a1,a2                   set up destination address
                movea.l a1,a4
                adda.l  d3,a4                   set up source address
d1108 1
a1108 1
                dbra    d4,cscrollwinnextword   and loop
d1110 2
a1111 2
                adda.l  #width,a1               increment row by width
                dbra    d1,cscrollwinnextrow    and loop again
d1113 1
a1113 1
                bra	cscrollwinpageoff
d1117 1
a1117 1
cscrollwin68030 subq    #1,d2			subtract 1 to make loop correct
d1120 3
a1122 3
                movea.l a1,a2                   set up destination address
                movea.l a1,a4
                adda.l  d3,a4                   set up source address
d1125 1
a1125 1
                dbra    d4,cscrollwinnextword2  and loop
d1127 2
a1128 2
                adda.l  #width,a1               increment row by width
                dbra    d1,cscrollwinnextrow2   and loop again
d1130 2
a1131 2
cscrollwinpageoff move.l #pagemode,d7		turn off page mode
                move.l  #1,0(a0,d7.l)
d1142 3
a1144 3
                move.l  #cursorcontrol1,d0
                ori     #cursoroffmask,0(a0,d0.l)
                rts
d1153 3
a1155 3
                move.l  #cursorcontrol1,d0
                andi    #cursoronmask,0(a0,d0.l)
                rts
d1164 11
a1174 11
                movea.l controladdr(a5),a0
		moveq	#0,d0
		move.l	d0,d1
		move.l	d0,d2
		move.l	d0,d3
                movea.l (sp)+,a1                return address
                move.w  (sp)+,d2                width in characters
                move.w  (sp)+,d3                xmin in characters
                move.w  (sp)+,d1                ymax in lines
                move.w  (sp)+,d0                ymin in lines
                move.l  a1,-(sp)                stack return address
d1176 7
a1182 7
		move.l	d1,d4
                sub     d0,d4                   number of lines-1
                tst     d4
                beq     cscrollwindnrts         1 line window
		mulu	charh(a3),d4		d4 = number of rows in pixels
                subq    #1,d4                   subtract 1 to make loop correct
		move.l	d4,d0			d0 = number of rows-1
d1184 5
a1188 5
                addq    #1,d1                   1 more line down
		mulu	charh(a3),d1		d1 = last row in pixels
                subq    #1,d1                   1 row up (last row of dest)
		mulu	charw(a3),d3		x offset in pixels
		mulu	charw(a3),d2		x width in pixels
d1190 2
a1191 2
                mulu    #width,d1               
                add.l   d3,d1                   d1 = address of last row
d1193 2
a1194 2
                movea.l screen(a5),a1           get base address of framebuffer
                adda.l  d1,a1                   a1 = destination row
d1196 3
a1198 3
		moveq	#0,d3			reuse d3
                move    charh(a3),d3
                mulu    #width,d3               number of rows per line height
d1200 1
a1200 1
                lsr     #2,d2                   number of longs per line
d1202 2
a1203 2
                move.l  #pagemode,d7		turn on page mode
                move.l  #0,0(a0,d7.l)
d1205 2
a1206 2
		btst	#3,sysflag2		test for 68040 to use move16
		bne	cscrollwindn68030
d1210 2
a1211 2
		lsr	#2,d2			number of move16's
                subq    #1,d2			subtract 1 to make loop correct
d1214 3
a1216 3
                movea.l a1,a2                   set up destination address
                movea.l a1,a4
                suba.l  d3,a4                   set up source address
d1219 1
a1219 1
                dbra    d4,cscrollwindnnextword and loop
d1221 2
a1222 2
                suba.l  #width,a1               decrement row by width
                dbra    d0,cscrollwindnnextrow  and loop again
d1224 1
a1224 1
                bra	cscrollwindnpageoff
d1228 1
a1228 1
cscrollwindn68030 subq    #1,d2			subtract 1 to make loop correct
d1231 3
a1233 3
                movea.l a1,a2                   set up destination address
                movea.l a1,a4
                suba.l  d3,a4                   set up source address
d1236 1
a1236 1
                dbra    d4,cscrollwindnnextword2 and loop
d1238 2
a1239 2
                suba.l  #width,a1               increment row by width
                dbra    d1,cscrollwindnnextrow2 and loop again
d1242 1
a1242 1
                subq    #1,d1
d1245 1
a1245 1
                movea.l a1,a2
d1248 1
a1248 1
                dbra    d4,cscrollwindnclrword2 and loop
d1250 2
a1251 2
                suba.l  #width,a1               increment row by width
                dbra    d1,cscrollwindnclrrow2  and loop again
d1253 2
a1254 2
cscrollwindnpageoff move.l #pagemode,d7		turn off page mode
                move.l  #1,0(a0,d7.l)
d1265 4
a1268 4
		moveq	#0,d1
		move.l	d1,d2
		move.l	d1,d3
		move.l	d1,d4
d1270 6
a1275 6
                movea.l (sp)+,a1                return address
                move.w  (sp)+,d4                width (in chars)
                move.w  (sp)+,d3                xmin (in chars)
                move.w  (sp)+,d2                ymax (in lines)
                move.w  (sp)+,d1                ymin (in lines)
                move.l  a1,-(sp)                stack return address
d1277 9
a1285 9
		sub	d1,d2
		addq	#1,d2			add 1 to lines
		mulu	charh(a3),d2		d2 = number of rows in pixels
		mulu	charh(a3),d1		d1 = first row in pixels
		mulu	charw(a3),d3		d3 = first column
		subq	#1,d4			1 char less
                beq     cdbscrolllrts           1 column window
		mulu	charw(a3),d4		number of columns
		lsr	#2,d4			d4 = number of long words
d1287 4
a1290 4
		movea.l	screen(a5),a1
                mulu    #width,d1
		adda.l	d1,a1
		adda.l	d3,a1			address of first pixel
d1292 2
a1293 2
		subq	#1,d2			subtract 1 to make loop correct
		subq	#1,d4			subtract 1 to make loop correct
d1296 3
a1298 3
                movea.l a2,a4
		move.l	d4,d3			reuse d3 for counter
		adda	charw(a3),a4		set up source address
d1301 1
a1301 1
		dbra	d3,cdbscrolllnextword
d1303 3
a1305 3
		adda.l	#width,a1
		dbra	d2,cdbscrolllnextrow
		
d1315 5
a1319 5
                movea.l controladdr(a5),a0
		moveq	#0,d1
		move.l	d1,d2
		move.l	d1,d3
		move.l	d1,d4
d1321 6
a1326 6
                movea.l (sp)+,a1                return address
                move.w  (sp)+,d4                width
                move.w  (sp)+,d3                xmin
                move.w  (sp)+,d2                ymax
                move.w  (sp)+,d1                ymin
                move.l  a1,-(sp)                stack return address
d1328 8
a1335 8
		sub	d1,d2
                addq    #1,d2                   add 1 to lines
		mulu	charh(a3),d2		d2 = number of rows
		mulu	charh(a3),d1		d1 = first row
		mulu	charw(a3),d3		d3 = first column
		subq	#1,d4			1 less char
                beq     cdbscrollrrts           1 column window
		mulu	charw(a3),d4		number of columns
d1337 6
a1342 6
		move.l	screen(a5),a1
                mulu    #width,d1
		adda.l	d1,a1
		adda.l	d3,a1
		adda.l	d4,a1			address of first pixel
		addq	#4,a1			subtract later with pre-dec
d1344 1
a1344 1
		lsr	#2,d4			d4 = number of long words
d1346 1
a1346 1
		subq	#1,d2			subtract 1 to make loop correct
d1348 1
a1348 1
cdbscrollrnextrow movea.l a1,a2			set up source address
d1350 2
a1351 2
		move.l  d4,d3			reuse d3 for counter
		adda	charw(a3),a4		set up destination address
d1354 1
a1354 1
		dbra	d3,cdbscrollrnextword
d1356 3
a1358 3
		adda.l	#width,a1
		dbra	d2,cdbscrollrnextrow
		
d1369 3
a1371 3
                movea.l controladdr(a5),a0
                moveq   #0,d2
                move.l  d1,d3
d1373 6
a1378 6
                move.l  #blockmode,d6
                move.l  #0,0(a0,d6.l)           turn on block mode
                move.l  #vramcolor1,d5
                move.l  #0,0(a0,d5.l)           set color registers to 0
                move.l  #maskreg,d5
                move.l  #-1,0(a0,d5.l)          to clear on all planes
d1380 7
a1386 7
                move.l  screen(a5),a1           base address of FB
                move    disph(a3),d2            get width and height in pixels
                move    dispw(a3),d3
                lsr     #4,d3                   change to number of words
                subq    #1,d2
                subq    #1,d3
                movea.l a1,a2                   make a copy for reference
d1389 1
a1389 1
                movea.l a2,a1                   reset to beginning of next line
d1392 1
a1392 1
                dbra    d4,nextword             and loop
d1394 2
a1395 2
                adda.l  #widthdiv16,a2          increment row by width
                dbra    d2,nextrow              and loop again
d1397 2
a1398 2
                move.l  #1,0(a0,d6.l)           turn off block mode
                rts
d1413 6
a1418 6
                movea.l (sp)+,a1                return address
                move.l  (sp)+,d3
                move.l  (sp)+,d2
                move.l  (sp)+,d1
                move.l  (sp)+,d0                get data off stack as longs
                move.l  a1,-(sp)                stack return address
d1420 1
a1420 1
                move.l  #blueregimage,d5
d1423 7
a1429 7
                bne.s   ccheckblue              loop until bit is clear
                move.l  #dacimagewrite,d6
                move.b  d0,0(a0,d6.l)           write the index to the DAC
                move.b  d1,4(a0,d6.l)           then red to the DAC
                move.b  d2,4(a0,d6.l)           then green to the DAC
                move.b  d3,3(a0,d5.l)           then blue to BEECH
                rts
d1438 6
a1443 6
                movea.l controladdr(a5),a0
                movea.l (sp)+,a1                return address
                move.w  (sp)+,d2                register value
                move.l  (sp)+,d1                register number
                move.l  a1,-(sp)                stack return address
                rts
d1452 5
a1456 5
                movea.l controladdr(a5),a0
                movea.l (sp)+,a1                return address
                movea.l (sp)+,a2
                move.l  a1,-(sp)                stack return address
                rts
d1465 5
a1469 5
                movea.l controladdr(a5),a0
                movea.l (sp)+,a1                return address
                movea.l (sp)+,a2
                move.l  a1,-(sp)                stack return address
                rts
d1478 6
a1483 6
            movea.l  controladdr(a5),a0
            movea.l  (sp)+,a1           return address
            adda.l   (sp)+,a0           offset
            movep    0(a0),d0
            move     d0,(sp)            store on stack as function value
            jmp      (a1)
d1492 2
a1493 2
                movea.l controladdr(a5),a0
                rts
d1515 1
a1515 1
cprepdumpline	equ *
d1526 1
a1526 1
preploop	equ    *
d1538 1
a1538 1
initcharbuf	equ *
d1547 1
a1547 1
fixstrlen	equ   *
d1571 6
a1576 6
                movea.l controladdr(a5),a0
                movea.l (sp)+,a1                return address
                movea.l (sp)+,a2                buffer address
                move.w  (sp)+,d1                size of buffer in bytes
                movea.l (sp)+,a4                row start address of FB
                move.l  a1,-(sp)                stack return address
d1578 1
a1578 1
		moveq	#0,d2
d1580 2
a1581 2
		move	displaywidth(a0),d2	get width of display
		subq	#1,d2			make loop correct
d1583 3
a1585 3
cprepchecklast	tst.b	0(a4,d2.l)		any bits set?	
		bne	cprepfoundlast
		dbra	d2,cprepchecklast
d1587 3
a1589 3
		move.b	#0,(a2)			no bits on this line
		moveq	#1,d2			make at least one
		bra	cprepcalcascii		
d1591 7
a1597 7
cprepfoundlast	addq	#1,d2			d2 now has number of bits set
		move.l	d2,d3
		andi	#7,d3			get remainder (d2 mod 8)
		lsr	#3,d2			number of bytes (d2 / 8)
		tst	d3			any remainder?
		beq	cprepmakebyte 		no, get data
		addq	#1,d2			yes, round up to next byte
d1599 4
a1602 4
cprepmakebyte	move	d2,d4			make copy for later
		subq	#1,d4			subtract 1 to make loop correct
		moveq	#0,d5			clear d5
		moveq	#7,d6			check 8 bytes
d1604 5
a1608 5
cprepnextbit	lsl	#1,d5
		tst.b	(a4)+			any bits set?
		beq	cprepcheckloop		no bits set
		ori.b	#1,d5			there's a bit set, add to byte
cprepcheckloop	dbra	d6,cprepnextbit
d1610 2
a1611 2
		move.b 	d5,(a2)+
		dbra	d4,cprepmakebyte
d1615 1
a1615 1
cprepcalcascii	equ	*
d1629 3
a1631 3
		rol.l   #8,d2                  	justify for copy to outbuf
		ori.b   #'W',d2                	now have 'xxxW' in longword
		move.l  d2,-4(a2)      	        copy to outbuf
d1633 1
a1633 1
                rts
d1642 2
a1643 2
                movea.l controladdr(a5),a0
                rts
@


1.7
log
@Added Katakana support and Greyscale support. - CFB
@
text
@d212 1
a212 3
fontstorage1    ds.b    16384           ASCII chars 0-127
fontstorage2    ds.b    16384           ROMAN 8 chars 128-255
fontstorage3    ds.b    16384           Katakana chars
@


1.6
log
@fixed cclear bug - CFB
@
text
@d189 1
d192 1
a192 1
framecount      equ     $0000005B       offset of number of frames
d224 4
a227 1
                moveq   #0,d1                 clear some registers
d293 1
a293 12
                mulu    d0,d2                   # bytes/char
                subq    #1,d7                   count a found font
                moveq   #127,d3                 #chars to unpack-1
                lea     (fontstorage1),a4       start at beginning of font store
                bsr.s   unpackit
                moveq   #127,d3                 now unpack second half of font
                lea     (fontstorage2),a4
                bsr.s   unpackit
                rts                     * forget the rest, bail out for now
                subq    #1,d7
                moveq   #127,d3
                lea     (fontstorage3),a4
d365 5
a369 3
                st      hascolor(a5)            always has color
                clr.l   screen(a5)             clear space for frame buffer addr
                movea.l a0,a1                   make copy of ROM start addr
d435 2
d438 9
a446 6
                lea     2(a0,d1.w),a1           point to font id code
                moveq   #2,d7                 count number of font found with d7
                
                movep   2(a1),d2                get offset of font info
                lea     0(a0,d2.l),a2           a3 points to font info
                moveq   #0,d0
a447 1
                moveq   #0,d1
d451 6
d460 3
d547 19
@


1.5
log
@fixed scoll problem in debug window - CFB
@
text
@d1370 3
d1381 3
a1383 3
                move    disph(a5),d2            get width and height in pixels
                move    dispw(a5),d3
                lsr.w   #4,d3                   change to number of words
d1394 1
a1394 1
                adda.l  #widthdiv16,a2                 increment row by width
@


1.4
log
@fixed scroll down problem to include to line - CFB
@
text
@a988 1
                subq    #1,d2
d1069 3
d1073 2
a1074 2
		mulu	charh(a3),d1		d1 = last row in pixels
                sub     d0,d1                   d1 = number of rows - 1
a1112 12
                move    charh(a3),d1            set up to clear next line
                subq    #1,d1

cscrollwinclrrow move.l  d2,d4                  reset column counter
                movea.l a1,a2

cscrollwinclrword move16 zero16,(a2)+           clear line
                dbra    d4,cscrollwinclrword    and loop

                adda.l  #width,a1               increment row by width
                dbra    d1,cscrollwinclrrow     and loop again

a1129 12
                move    charh(a3),d1            set up to clear next line
                subq    #1,d1

cscrollwinclrrow2 move.l d2,d4                  reset column counter
                movea.l a1,a2

cscrollwinclrword2 move.l #0,(a2)+              clear line
                dbra    d4,cscrollwinclrword2   and loop

                adda.l  #width,a1               increment row by width
                dbra    d1,cscrollwinclrrow2    and loop again

d1133 1
a1133 1
                rts
a1175 3
                subq    #1,d1                   start one line height up
		mulu	charh(a3),d0		d0 = first row in pixels
		mulu	charh(a3),d1		d1 = last row in pixels
d1177 4
a1180 1
                sub     d0,d4
d1183 4
d1191 1
a1191 1
                add.l   d3,d0                   d0 = address of first row
a1223 12
                move    charh(a3),d0            set up to clear next line
                subq    #1,d0

cscrollwindnclrrow move.l  d2,d4                reset column counter
                movea.l a1,a2

cscrollwindnclrword move16 zero16,(a2)+         clear line
                dbra    d4,cscrollwindnclrword  and loop

                suba.l  #width,a1               increment row by width
                dbra    d1,cscrollwindnclrrow   and loop again

d1241 1
a1241 1
                move    charh(a3),d1            set up to clear next line
d1256 1
a1256 1
                rts
a1264 1
                movea.l controladdr(a5),a0
d1267 2
a1268 2
		move.l	d2,d3
		move.l	d3,d4
d1278 3
a1280 2
		mulu	charh(a3),d2		d2 = number of rows
		mulu	charh(a3),d1		d1 = first row
d1282 2
a1283 1
		add	charw(a3),d3		1 char to the right
d1285 1
a1285 1
		lsl	#2,d4			d4 = number of long words
d1287 4
a1290 2
		add.l	screen(a5),d1
		add.l	d3,d1			address of first pixel
d1295 4
a1298 4
cdbscrolllnextrow movea.l d1,a1			set up source address
		movea a1,a2
		suba	charw(a3),a2		set up destination address
		move.l d4,d3			reuse d3 for counter
d1300 1
a1300 1
cdbscrolllnextword move.l (a1)+,(a2)+
d1303 1
a1303 1
		add	#width,d1
d1306 1
a1306 1
                rts
d1318 2
a1319 2
		move.l	d2,d3
		move.l	d3,d4
d1329 1
d1333 2
a1334 1
		sub	charw(a3),d4		1 less char
a1335 1
		lsl	#2,d4			d4 = number of long words
d1337 6
a1342 4
		add.l	screen(a5),d1
		add.l	d3,d1
		add.l	d4,d1			address of first pixel
		addq	#4,d1			subtract later with pre-dec
d1344 2
a1346 1
		subq	#1,d4			subtract 1 to make loop correct
d1348 4
a1351 4
cdbscrollrnextrow movea.l d1,a1			set up source address
		movea a1,a2
		adda	charw(a3),a2		set up destination address
		move.l d4,d3			reuse d3 for counter
d1353 1
a1353 1
cdbscrollrnextword move.l -(a1),-(a2)
d1356 1
a1356 1
		add	#width,d1
d1359 1
a1359 1
                rts
@


1.3
log
@fixed scrollup problem (not scrolling to top line) - CFB
@
text
@a657 1
                sub     charh(a3),d1            minus one line height
@


1.2
log
@Fixed debugger window scrolling problem (top line not being scrolled)
@
text
@a555 1
                add     charh(a3),d0            start one line height down
@


1.1
log
@Initial revision
@
text
@a1071 1
                addq    #1,d0                   start one line height down
d1074 1
a1074 1
                sub     d0,d1                   d1 = number of rows
@
