changeset 1585:4a2a4667a4cf

Source enhancements
author boisy
date Fri, 21 May 2004 21:44:15 +0000
parents 0e3a28789196
children e26f7d2e40df
files level1/modules/ccio.asm level1/modules/co32.asm level1/modules/co80.asm
diffstat 3 files changed, 461 insertions(+), 487 deletions(-) [+]
line wrap: on
line diff
--- a/level1/modules/ccio.asm	Fri May 21 16:44:02 2004 +0000
+++ b/level1/modules/ccio.asm	Fri May 21 21:44:15 2004 +0000
@@ -28,60 +28,7 @@
 
          mod   eom,name,tylg,atrv,start,size
 
-         rmb   V.SCF
-u001D    rmb   7
-u0024    rmb   1
-u0025    rmb   1
-u0026    rmb   2
-u0028    rmb   1
-u0029    rmb   4
-ScreenX  rmb   1
-ScreenY  rmb   1
-u002F    rmb   1
-u0030    rmb   1
-u0031    rmb   1
-u0032    rmb   1
-u0033    rmb   2
-u0035    rmb   2
-u0037    rmb   9
-u0040    rmb   2
-u0042    rmb   2
-u0044    rmb   1
-u0045    rmb   2
-u0047    rmb   1
-u0048    rmb   1
-u0049    rmb   2
-u004B    rmb   5
-u0050    rmb   1
-u0051    rmb   1
-WrChar   rmb   1
-CoInUse  rmb   2
-u0055    rmb   6
-u005B    rmb   2
-u005D    rmb   2
-u005F    rmb   1
-u0060    rmb   1
-u0061    rmb   2
-u0063    rmb   2
-u0065    rmb   1
-u0066    rmb   1
-u0067    rmb   1
-u0068    rmb   1
-u0069    rmb   1
-u006A    rmb   1
-u006B    rmb   1
-u006C    rmb   1
-u006D    rmb   1
-u006E    rmb   1
-u006F    rmb   1
-u0070    rmb   1
-trulocas rmb   1
-CoEnt    equ   .
-GRFOEnt  rmb   6
-IBufHead rmb   1
-IBufTail rmb   1
-u007A    rmb   128
-size     equ   .
+size     equ   V.Last
 
          fcb   UPDAT.+EXEC.
 
@@ -114,17 +61,17 @@
          bne   L002E			continue if more
          coma				A = $FF
          comb				B = $FF
-         stb   <VD.Caps,u
-         std   <u005F,u
-         std   <u0061,u
+         stb   <V.Caps,u
+         std   <V.LKeyCd,u
+         std   <V.2Key2,u
          lda   #60
-         sta   <u0051,u
+         sta   <V.ClkCnt,u
          leax  >AltIRQ,pcr		get IRQ routine ptr
          stx   >D.AltIRQ		store in AltIRQ
-         leax  >SetDsply,pcr
-         stx   <u005B,u
-         leax  >L050F,pcr
-         stx   <u005D,u
+         leax  >SetDsply,pcr		get display vector
+         stx   <V.DspVct,u		store in vector address
+         leax  >XY2Addr,pcr		get address of XY2Addr
+         stx   <V.CnvVct,u
          ldd   <IT.PAR,y		get parity and baud
          lbra  L05CE			process them
 
@@ -154,15 +101,15 @@
 *    CC = carry set on error
 *    B  = error code
 *
-Read     leax  <VD.InBuf,u	point X to input buffer
-         ldb   <VD.IBufT,u	get tail pointer
+Read     leax  <V.InBuf,u	point X to input buffer
+         ldb   <V.IBufT,u	get tail pointer
          orcc  #IRQMask		mask IRQ
-         cmpb  <VD.IBufH,u	same as head pointer
+         cmpb  <V.IBufH,u	same as head pointer
          beq   Put2Bed		if so, buffer is empty, branch to sleep
          abx			X now points to curr char
          lda   ,x		get char
          bsr   L009D		check for tail wrap
-         stb   <VD.IBufT,u	store updated tail
+         stb   <V.IBufT,u	store updated tail
          andcc #^(IRQMask+Carry)	unmask IRQ
          rts
 
@@ -190,40 +137,41 @@
 * IRQ routine for keyboard
 *
 AltIRQ   ldu   >D.KbdSta	get keyboard static
-         ldb   <VD.CFlg1,u	graphics screen currently being displayed?
+         ldb   <V.CFlg1,u	graphics screen currently being displayed?
          beq   L00B7		branch if not
-         ldb   <VD.Alpha,u	alpha mode?
+         ldb   <V.Alpha,u	alpha mode?
          beq   L00B7		branch if so
-         lda   <u0030,u
+         lda   <V.PIA1,u
          lbsr  SetDsply		set up display
 L00B7    ldx   #PIA0Base	point to PIA base
          clra
          clrb
-         std   <u006A,u		clear
-         bsr   L00E8
+         std   <V.KySns,u	clear keysense byte
+         bsr   L00E8		get bits
          bne   L00CC
-         clr   $02,x
+         clr   $02,x		clear PIA0Base+2
          lda   ,x		get byte from PIA
          coma			complement
          anda  #$7F		strip off hi bit
          bne   L00F1		branch if any bit set
 L00CC    clra
          clrb
-         std   <u006E,u		clear
+         std   <V.KTblLC,u	clear
          coma			A = $FF
-         tst   <u006D,u
-         bne   L00DA
-         sta   <u005F,u
-L00DA    stb   <u006D,u
+         tst   <V.Spcl,u	special key?
+         bne   l@		branch if so
+         sta   <V.LKeyCd,u
+l@       stb   <V.Spcl,u	clear for next time
          comb  
-         sta   <u0060,u
-         std   <u0061,u
+         sta   <V.2Key1,u
+         std   <V.2Key2,u
 L00E4    jmp   [>D.Clock]	jump into clock module
+
 L00E8    comb
-         stb   $02,x
-         ldb   ,x
-         comb
-         andb  #$03
+         stb   $02,x		strobe one column
+         ldb   ,x		read PIA #0 row states
+         comb			invert bits so 1=key pressed
+         andb  #$03		mask out all but lower 2 bits
          rts
 
 L00F1    bsr   L015C
@@ -231,28 +179,28 @@
          clrb
          bsr   L00E8
          bne   L00CC
-         cmpa  <u006F,u
+         cmpa  <V.6F,u
          bne   L010E
-         ldb   <u0051,u
+         ldb   <V.ClkCnt,u
          beq   L010A
          decb
-L0105    stb   <u0051,u
+L0105    stb   <V.ClkCnt,u
          bra   L00E4
 L010A    ldb   #$05
          bra   L011A
-L010E    sta   <u006F,u
+L010E    sta   <V.6F,u
          ldb   #$05
-         tst   <u006B,u
+         tst   <V.KySame,u
          bne   L0105
          ldb   #60
-L011A    stb   <u0051,u
-         ldb   <VD.IBufH,u	get head pointer in B
-         leax  <VD.InBuf,u	point X to input buffer
+L011A    stb   <V.ClkCnt,u
+         ldb   <V.IBufH,u	get head pointer in B
+         leax  <V.InBuf,u	point X to input buffer
          abx			X now holds address of head
          lbsr  L009D		check for tail wrap
-         cmpb  <VD.IBufT,u	B at tail?
+         cmpb  <V.IBufT,u	B at tail?
          beq   L012F		branch if so
-         stb   <VD.IBufH,u
+         stb   <V.IBufH,u
 L012F    sta   ,x		store our char at ,X
          beq   WakeIt		if nul, do wake-up
          cmpa  V.PCHR,u		pause character?
@@ -278,89 +226,95 @@
 
 L015C    clra
          clrb
-         std   <u0066,u
-         std   <u0068,u
+         std   <V.ShftDn,u		SHIFT/CTRL flag; 0=NO $FF=YES
+         std   <V.KeyFlg,u
+* %00000111-Column # (Output, 0-7)
+* %00111000-Row # (Input, 0-6)
          coma
          comb
-         std   <u0063,u
-         sta   <u0065,u
-         deca
-         sta   $02,x
-L016F    lda   ,x
-         coma
-         anda  #$7F
-         beq   L0183
-         ldb   #$FF
+         std   <V.Key1,u	key 1&2 flags $FF=none
+         sta   <V.Key3,u	key 3     "
+         deca			lda #%11111110
+         sta   $02,x		write column strobe
+L016F    lda   ,x		read row from PIA0Base
+         coma			invert so 1=key pressed
+         anda  #$7F		keep only keys, bit 0=off 1=on
+         beq   L0183		no keys pressed, try next column
+         ldb   #$FF		preset counter to -1
 L0178    incb
-         lsra
-         bcc   L017F
-         lbsr  L0221
-L017F    cmpb  #$06
-         bcs   L0178
-L0183    inc   <u0068,u
-         orcc  #Carry
-         rol   $02,x
-         bcs   L016F
-         lbsr  L0289
-         bmi   L020A
-         cmpa  <u005F,u
+         lsra			bit test regA
+         bcc   L017F		no key, brach
+         lbsr  L0221		convert column/row to matrix value and store
+L017F    cmpb  #$06		max counter
+         bcs   L0178		loop if more bits to test
+L0183    inc   <V.KeyFlg,u	counter; used here for column
+         orcc  #Carry		bit marker; disable strobe
+         rol   $02,x		shift to next column
+         bcs   L016F		not finished with columns so loop
+         lbsr  L0289		simultaneous check; recover key matrix value
+         bmi   L020A		invalid so go
+         cmpa  <V.LKeyCd,u	last keyboard code
          bne   L0199
-         inc   <u006B,u
-L0199    sta   <u005F,u
-         beq   L01B9
-         suba  #$1A
-         bhi   L01B9
-         adda  #$1A
-         ldb   <u0067,u
-         bne   L01E9
-         adda  #$40
-         ldb   <u0066,u
-         eorb  <VD.Caps,u
-         andb  #$01
-         bne   L01E9
-         adda  #$20
+         inc   <V.KySame,u	same key flag ?counter?
+L0199    sta   <V.LKeyCd,u	setup for last key pressed
+         beq   L01B9		if @ key, use lookup table
+         suba  #$1A		the key value (matrix) of Z
+         bhi   L01B9		not a letter, so go
+         adda  #$1A		restore regA
+         ldb   <V.CtrlDn,u	CTRL flag
+         bne   L01E9		CTRL is down so go
+         adda  #$40		convert to ASCII value; all caps
+         ldb   <V.ShftDn,u	shift key flag
+         eorb  <V.Caps,u	get current device static memory pointer
+         andb  #$01		tet caps flag
+         bne   L01E9		not shifted so go
+         adda  #$20		convert to ASCII lowercase
          bra   L01E9
-L01B9    ldb   #$03
-         mul
-         lda   <u0066,u
-         beq   L01C4
-         incb
-         bra   L01CB
-L01C4    lda   <u0067,u
-         beq   L01CB
+* Not a letter key, use the special keycode lookup table
+* Entry: A = table idnex (matrix scancode-26)
+L01B9    ldb   #$03		three entries per key (normal, SHIFT, CTRL)
+         mul			convert index to table offset
+         lda   <V.ShftDn,u	shift key flag
+         beq   L01C4		not shifted so go
+         incb			else adjust offset for SHIFTed entry
+         bra   L01CB		and do it
+L01C4    lda   <V.CtrlDn,u	CTRL flag?
+         beq   L01CB		adjust offset for CTRL key
          addb  #$02
-L01CB    lda   <u006C,u
-         beq   L01D4
-         cmpb  #$11
-         ble   L0208
-L01D4    cmpb  #$4C
-         blt   L01DD
-         inc   <u0069,u
-         subb  #$06
-L01DD    pshs  x
-         leax  >KeyTbl,pcr		point to keyboard table
+L01CB    lda   <V.KySnsF,u	key sense flag?
+         beq   L01D4		not set, so go
+         cmpb  #$11		spacebar?
+         ble   L0208		must be an arrow so go
+L01D4    cmpb  #$4C		ALT key? (SHOULD BE $4C???)
+         blt   L01DD		not ALT, CTRL, F1, F2 or SHIFT so go
+         inc   <V.AltDwn,u	flag special keys (ALT, CTRL)
+         subb  #$06		adjust offset to skip them
+L01DD    pshs  x		save X
+         leax  >KeyTbl,pcr	point to keyboard table
          lda   b,x
          puls  x
-         bmi   L01FD
-L01E9    ldb   <u0069,u
-         beq   L01FA
-         cmpa  #$3F
-         bls   L01F8
-         cmpa  #$5B
-         bcc   L01F8
-         ora   #$20
-L01F8    ora   #$80
-L01FA    andcc #^Negative
+         bmi   L01FD		if A = $81 - $84, special key
+* several entries to this routine from any key press; A is already ASCII
+L01E9    ldb   <V.AltDwn,u	was ALT flagged?
+         beq   L01FA		no, so go
+         cmpa  #$3F		?
+         bls   L01F8		# or code
+         cmpa  #$5B		[
+         bcc   L01F8		capital letter so go
+         ora   #$20		convert to lower case
+L01F8    ora   #$80		set for ALT characters
+L01FA    andcc #^Negative	not negative
          rts
-
-L01FD    inc   <u006D,u
-         ldb   <u006B,u
+* Flag that special key was hit
+L01FD    inc   <V.Spcl,u
+         ldb   <V.KySame,u
          bne   L0208
-         com   <VD.Caps,u
-L0208    orcc  #Negative
+         com   <V.Caps,u
+L0208    orcc  #Negative	set negative
 L020A    rts
 
-L020B    pshs  b,a
+* Calculate arrow keys for key sense byte
+L020B    pshs  b,a		convert column into power of 2
          clrb
          orcc  #Carry
          inca
@@ -369,43 +323,45 @@
          bne   L0211
          bra   L0219
 L0217    pshs  b,a
-L0219    orb   <u006A,u
-         stb   <u006A,u
+L0219    orb   <V.KySns,u	previous value of column
+         stb   <V.KySns,u
          puls  pc,b,a
+* Check special keys (SHIFT, CTRL, ALT)
 L0221    pshs  b,a
-         cmpb  #$03
+         cmpb  #$03		is it row 3?
          bne   L0230
-         lda   <u0068,u
-         cmpa  #$03
-         blt   L0230
-         bsr   L020B
-L0230    lslb
+         lda   <V.KeyFlg,u	get column #
+         cmpa  #$03		is it column 3?; ie up arrow
+         blt   L0230		if lt it must be a letter
+         bsr   L020B		its a non letter so bsr
+L0230    lslb			B*8 8 keys per row
          lslb
          lslb
-         addb  <u0068,u
+         addb  <V.KeyFlg,u	add in the column #
          beq   L025D
-         cmpb  #$33
+         cmpb  #$33		ALT
          bne   L0243
-         inc   <u0069,u
+         inc   <V.AltDwn,u	ALT down flag
          ldb   #$04
          bra   L0219
-L0243    cmpb  #$31
+L0243    cmpb  #$31		CLEAR?
          beq   L024B
-         cmpb  #$34
+         cmpb  #$34		CTRL?
          bne   L0252
-L024B    inc   <u0067,u
+L024B    inc   <V.CtrlDn,u	CTRL down flag
          ldb   #$02
          bra   L0219
-L0252    cmpb  #$37
+L0252    cmpb  #$37		SHIFT key
          bne   L0262
-         com   <u0066,u
+         com   <V.ShftDn,u	SHIFT down flag
          ldb   #$01
          bra   L0219
 L025D    ldb   #$04
          bsr   L0217
          clrb
+* Check how many key (1-3) are currently being pressed
 L0262    pshs  x
-         leax  <u0063,u
+         leax  <V.Key1,u	1st key table
          bsr   L026D
          puls  x
          puls  pc,b,a
@@ -423,57 +379,59 @@
 L0283    stb   $02,x
          ldb   #$03
          puls  pc,a
+* simultaneous key test
 L0289    pshs  y,x,b
          bsr   L02EE
-         ldb   <u006E,u
+         ldb   <V.KTblLC,u	key table entry #
          beq   L02C5
-         leax  <u0060,u
+         leax  <V.2Key1,u	point to 2nd key table
          pshs  b
-L0297    leay  <u0063,u
+L0297    leay  <V.Key1,u	1st key table
          ldb   #$03
-         lda   ,x
-         bmi   L02B6
-L02A0    cmpa  ,y
-         bne   L02AA
+         lda   ,x		get key #1
+         bmi   L02B6		go if invalid? (no key)
+L02A0    cmpa  ,y		is it a match?
+         bne   L02AA		go if not a matched key
          clr   ,y
-         com   ,y
+         com   ,y		set value to $FF
          bra   L02B6
 L02AA    leay  $01,y
          decb
          bne   L02A0
          lda   #$FF
          sta   ,x
-         dec   <u006E,u
+         dec   <V.KTblLC,u	key table entry #
 L02B6    leax  $01,x
-         dec   ,s
+         dec   ,s		column counter
          bne   L0297
          leas  $01,s
-         ldb   <u006E,u
+         ldb   <V.KTblLC,u	key table entry (can test for 3 simul keys)
          beq   L02C5
          bsr   L0309
-L02C5    leax  <u0063,u
+L02C5    leax  <V.Key1,u	1st key table
          lda   #$03
 L02CA    ldb   ,x+
          bpl   L02DE
          deca
          bne   L02CA
-         ldb   <u006E,u
+         ldb   <V.KTblLC,u	key table entry (can test for 3 simul keys)
          beq   L02EA
          decb
-         leax  <u0060,u
+         leax  <V.2Key1,u	2nd key table
          lda   b,x
          bra   L02E8
 L02DE    tfr   b,a
-         leax  <u0060,u
+         leax  <V.2Key1,u	2nd key table
          bsr   L026D
-         stb   <u006E,u
+         stb   <V.KTblLC,u
 L02E8    puls  pc,y,x,b
-L02EA    orcc  #Negative
+L02EA    orcc  #Negative	flag negative
          puls  pc,y,x,b
-L02EE    ldd   <u0066,u
+
+L02EE    ldd   <V.ShftDn,u
          bne   L0301
          lda   #$03
-         leax  <u0063,u
+         leax  <V.Key1,u
 L02F8    ldb   ,x
          beq   L0302
          leax  $01,x
@@ -482,18 +440,21 @@
 L0301    rts
 L0302    comb
          stb   ,x
-         inc   <u0069,u
+         inc   <V.AltDwn,u
          rts
-L0309    leax  <u0060,u
-         bsr   L0314
+
+* Sort 3 byte packet @ G.2Key1 according to sign of each byte
+* so that positive #'s are at beginning & negative #'s at end
+L0309    leax  <V.2Key1,u	2nd key table
+         bsr   L0314		sort bytes 1 & 2
          leax  $01,x
-         bsr   L0314
-         leax  -$01,x
-L0314    lda   ,x
-         bpl   L0320
-         ldb   $01,x
-         bmi   L0320
-         sta   $01,x
+         bsr   L0314		sort bytes 2 & 3
+         leax  -$01,x		sort 1 & 2 again (fall thru for third pass)
+L0314    lda   ,x		get current byte
+         bpl   L0320		positive - no swap
+         ldb   $01,x		get next byte
+         bmi   L0320		negative - no swap
+         sta   $01,x		swap the bytes
          stb   ,x
 L0320    rts
 
@@ -540,9 +501,9 @@
 *    CC = carry set on error
 *    B  = error code
 *
-Write    ldb   <VD.NGChr,u	are we in the process of getting parameters?
+Write    ldb   <V.NGChr,u	are we in the process of getting parameters?
          bne   PrmHandl		yes, go process
-         sta   <VD.WrChr,u	save character to write
+         sta   <V.WrChr,u	save character to write
          cmpa  #C$SPAC		space or higher?
          bcc   GoCo		yes, normal write
          cmpa  #$1E		escape sequence $1E or $1F?
@@ -552,12 +513,12 @@
          cmpa  #C$BELL		bell?
          lbeq  Ding		if so, ring bell
 * Here we call the CO-module to write the character
-GoCo     lda   <VD.CurCo,u	get CO32/CO80 flag
+GoCo     lda   <V.CurCo,u	get CO32/CO80 flag
 CoWrite  ldb   #$03		we want to write
-CallCO   leax  <CoEnt,u		get base pointer to CO-entries
+CallCO   leax  <V.GRFOE,u	get base pointer to CO-entries
          ldx   a,x		get pointer to CO32/CO80
          beq   NoIOMod		branch if no module
-         lda   <VD.WrChr,u	get character to write
+         lda   <V.WrChr,u	get character to write
 L039D    jmp   b,x		call i/o subroutine
 NoIOMod  comb  
          ldb   #E$MNF
@@ -566,19 +527,19 @@
 * Parameter handler
 PrmHandl cmpb  #$02		two parameters left?
          beq   L03B0		branch if so
-         sta   <VD.NChar,u	else store in VD.NChar
-         clr   <VD.NGChr,u	clear parameter counter
-         jmp   [<VD.RTAdd,u]	jump to return address
-L03B0    sta   <VD.NChr2,u	store in VD.NChr2
-         dec   <VD.NGChr,u	decrement parameter counter
+         sta   <V.NChr2,u	else store in V.NChr2
+         clr   <V.NGChr,u	clear parameter counter
+         jmp   [<V.RTAdd,u]	jump to return address
+L03B0    sta   <V.NChar,u	store in V.NChar
+         dec   <V.NGChr,u	decrement parameter counter
          clrb
          rts
 
 Escape   beq   L03C5		if $1E, we conveniently ignore it
          leax  <COEscape,pcr	else it's $1F... set up to get next char
 L03BD    ldb   #$01
-L03BF    stx   <VD.RTAdd,u
-         stb   <VD.NGChr,u
+L03BF    stx   <V.RTAdd,u
+         stb   <V.NGChr,u
 L03C5    clrb
          rts
 
@@ -588,15 +549,15 @@
 * Show VDG or Graphics screen
 * Entry: B = 0 for VDG, 1 for Graphics
 SetDsply pshs  x,a
-         stb   <VD.Alpha,u	save passed flag in B
+         stb   <V.Alpha,u	save passed flag in B
          lda   >PIA1Base+2
          anda  #$07		mask out all but lower 3 bits
          ora   ,s+		OR in passed A
          tstb			display graphics?
          bne   L03DE		branch if so
-         ora   <VD.CFlag,u
+         ora   <V.CFlag,u
 L03DE    sta   >PIA1Base+2
-         sta   <u0030,u
+         sta   <V.PIA1,u
          tstb			display graphics?
          bne   DoGfx		branch if so
 * Set up VDG screen for text
@@ -604,14 +565,14 @@
          stb   >$FFC0
          stb   >$FFC2
          stb   >$FFC4
-         lda   <VD.ScrnA,u		get pointer to alpha screen
+         lda   <V.ScrnA,u		get pointer to alpha screen
          bra   L0401
 
 * Set up VDG screen for graphics
 DoGfx    stb   >$FFC0
          stb   >$FFC3
          stb   >$FFC5
-         lda   <VD.CurBf,u		get pointer to graphics screen
+         lda   <V.SBAdd,u		get pointer to graphics screen
 
 L0401    ldb   #$07
          ldx   #$FFC6
@@ -643,39 +604,41 @@
 *    CC = carry set on error
 *    B  = error code
 *
-GetStat  sta   <VD.WrChr,u
-         cmpa  #SS.Ready
-         bne   L0439
-         lda   <VD.IBufT,u		get buff tail ptr
-         suba  <VD.IBufH,u		Num of chars ready in A
-         lbeq  NotReady			branch if empty
+GetStat  sta   <V.WrChr,u	save off stat code
+         cmpa  #SS.Ready	ready call?
+         bne   L0439		branch if not
+         lda   <V.IBufT,u	get buff tail ptr
+         suba  <V.IBufH,u	num of chars ready in A
+         lbeq  NotReady		branch if empty
 SSEOF    clrb	
          rts
-L0439    cmpa  #SS.EOF
-         beq   SSEOF
-         ldx   PD.RGS,y
-         cmpa  #SS.Joy
-         beq   SSJOY
-         cmpa  #SS.ScSiz
-         beq   SSSCSIZ
-         cmpa  #SS.KySns
-         beq   SSKYSNS
-         cmpa  #SS.DStat
-         lbeq  SSDSTAT
+L0439    cmpa  #SS.EOF		EOF?
+         beq   SSEOF		branch if so
+         ldx   PD.RGS,y		get caller's regs
+         cmpa  #SS.Joy		joystick?
+         beq   SSJOY		branch if so
+         cmpa  #SS.ScSiz	screen size?
+         beq   SSSCSIZ		branch if so
+         cmpa  #SS.KySns	keyboard sense?
+         beq   SSKYSNS		branch if so
+         cmpa  #SS.DStat	display status?
+         lbeq  SSDSTAT		branch if so
          ldb   #$06		getstat entry into CO-module
          lbra  JmpCO
 
-SSKYSNS  ldb   <u006A,u		get key sense info
+* Return key sense information
+SSKYSNS  ldb   <V.KySns,u		get key sense info
          stb   R$A,x		put in caller's A
          clrb
          rts
 
-SSSCSIZ  clra
-         ldb   <VD.Col,u
-         std   R$X,x
-         ldb   <VD.Row,u
-         std   R$Y,x
-         clrb
+* Return screen size
+SSSCSIZ  clra			clear upper 8 bits of D
+         ldb   <V.Col,u	get column count
+         std   R$X,x		save in X
+         ldb   <V.Row,u	get row count
+         std   R$Y,x		save in Y
+         clrb			no error
          rts
 
 * Get joytsick values
@@ -707,7 +670,7 @@
          ora   #$08
          bsr   L04B3
          pshs  b,a
-         ldd   #$003F
+         ldd   #63
          subd  ,s++
          std   R$Y,x
          clrb
@@ -734,54 +697,61 @@
 L04D5    suba  ,s+
          bra   L04BC
 
-SSDSTAT  lbsr  L065B
-         bcs   L050E
-         ldd   <u0045,u
-         bsr   L050F
+* Return display status
+* Entry: A = path
+* Exit: A = color code of pixel at cursor address
+*       X = address of graphics display memory
+*       Y = graphics cursor address; X = MSB, Y = LSB
+SSDSTAT  lbsr  GfxActv		gfx screen allocated?
+         bcs   L050E		branch if not
+         ldd   <V.GCrsX,u	else get X/Y gfx cursor position
+         bsr   XY2Addr		
          tfr   a,b
          andb  ,x
 L04E7    bita  #$01
          bne   L04F6
-         lsra
+         lsra			divide D by 2
          lsrb
-         tst   <u0024,u
-         bmi   L04E7
-         lsra
+         tst   <V.Mode,u	which mode?
+         bmi   L04E7		branch if 256x192
+         lsra			else divide D by 2 again
          lsrb
          bra   L04E7
 L04F6    pshs  b
-         ldb   <u004B,u
+         ldb   <V.PMask,u	get pixel color mask in B
          andb  #$FC
          orb   ,s+
-         ldx   $06,y
-         stb   $01,x
-         ldd   <u0045,u
-         std   $06,x
-         ldd   <VD.CurBf,u
-         std   $04,x
+         ldx   PD.RGS,y		get caller's regs
+         stb   R$A,x		place pixel color in A
+         ldd   <V.GCrsX,u
+         std   R$Y,x		cursor X/Y pos in Y,
+         ldd   <V.SBAdd,u
+         std   R$X,x		and screen addr in X
          clrb
 L050E    rts
-L050F    pshs  y,b,a
-         ldb   <u0024,u
-         bpl   L0517
-         lsra
+
+* Entry: A = X coor, B = Y coor
+XY2Addr  pshs  y,b,a		save off regs
+         ldb   <V.Mode,u	get video mode
+         bpl   L0517		branch if 128x192 (divide A by 4)
+         lsra			else divide by 8
 L0517    lsra
          lsra
-         pshs  a
-         ldb   #$BF
-         subb  $02,s
-         lda   #$20
+         pshs  a		save on stack
+         ldb   #191		get max Y
+         subb  $02,s		sutract from Y on stack
+         lda   #32		byte sper line
          mul
-         addb  ,s+
+         addb  ,s+		add offset on stack
          adca  #$00
-         ldy   <VD.CurBf,u
-         leay  d,y
-         lda   ,s
-         sty   ,s
-         anda  <u0044,u
-         ldx   <u0042,u
+         ldy   <V.SBAdd,u	get base address
+         leay  d,y		move D bytes into address
+         lda   ,s		pick up original X coor
+         sty   ,s		put offset addr on stack
+         anda  <V.PixBt,u
+         ldx   <V.MTabl,u
          lda   a,x
-         puls  pc,y,x
+         puls  pc,y,x		X = offset address, Y = base
 
 * SetStat
 *
@@ -794,7 +764,7 @@
 *    CC = carry set on error
 *    B  = error code
 *
-SetStat  sta   <VD.WrChr,u		save function code
+SetStat  sta   <V.WrChr,u		save function code
          ldx   PD.RGS,y			get caller's regs
          cmpa  #SS.ComSt
          lbeq  SSCOMST
@@ -804,30 +774,30 @@
          beq   SSSLGBF
          cmpa  #SS.KySns
          bne   CoGetStt
-         ldd   R$X,x
-         beq   L0558
-         ldb   #$FF
-L0558    stb   <u006C,u
+         ldd   R$X,x		get caller's key sense set data
+         beq   L0558		branch if zero
+         ldb   #$FF		else set all bits
+L0558    stb   <V.KySnsF,u	store value in KySnsFlag
 L055B    clrb
 L055C    rts
 
-CoGetStt ldb   #$09			CO-module setstat
+CoGetStt ldb   #$09		CO-module setstat
 JmpCO    pshs  b
-         lda   <VD.CurCo,u		get CO-module in use
+         lda   <V.CurCo,u	get CO-module in use
          lbsr  CallCO
          puls  a
          bcc   L055B
-         tst   <VD.GRFOE,u		GRFO linked?
+         tst   <V.GRFOE,u	GRFO linked?
          beq   L055C
          tfr   a,b
-         clra				GRFO address offset in statics
-         lbra  CallCO			call it
+         clra			GRFO address offset in statics
+         lbra  CallCO		call it
 
 * Reserve an additional graphics buffer (up to 2)
-SSAAGBF  ldb   <VD.Rdy,u	was initial buffer allocated with $0F?
+SSAAGBF  ldb   <V.Rdy,u	was initial buffer allocated with $0F?
          lbeq  NotReady		branch if not
          pshs  b		save buffer number
-         leay  <VD.AGBuf,u	point to additional graphics buffers
+         leay  <V.AGBuf,u	point to additional graphics buffers
          ldd   ,y		first entry empty?
          beq   L058E		branch if so
          leay  $02,y		else move to next entry
@@ -848,20 +818,20 @@
 L05A1    puls  pc,a
 
 * Select a graphics buffer
-SSSLGBF  ldb   <VD.Rdy,u	was initial buffer allocated with $0F?
+SSSLGBF  ldb   <V.Rdy,u	was initial buffer allocated with $0F?
          lbeq  NotReady		branch if not
          ldd   R$Y,x		else get buffer number from caller
          cmpd  #$0002		compare against high
          bhi   BadMode		branch if error
-         leay  <VD.GBuff,u	point to base graphics buffer address
+         leay  <V.GBuff,u	point to base graphics buffer address
          lslb			multiply by 2
          ldd   b,y		get pointer
          beq   BadMode		branch if error
-         std   <VD.CurBf,u	else save in current
+         std   <V.SBAdd,u	else save in current
          ldd   R$X,x		get select flag
          beq   L05C3		if zero, do nothing
          ldb   #$01		else set display flag
-L05C3    stb   <VD.CFlg1,u	save display flag
+L05C3    stb   <V.CFlg1,u	save display flag
          clrb
          rts
 BadMode  comb
@@ -875,7 +845,7 @@
          bita  #$01		true lowercase bit set?
          bne   GoCO32		branch if so
          clrb			true lower case FALSE
-GoCO32   stb   <VD.CFlag,u	save flag for later
+GoCO32   stb   <V.CFlag,u	save flag for later
          lda   #$02		CO32 is loaded bit
          ldx   #$2010		32x16
          pshs  u,y,x,a
@@ -888,10 +858,10 @@
 L05F4    bsr   L0601		load CO-module if not already loaded
          puls  u,y,x,a
          bcs   L0600
-         stx   <VD.Col,u	save screen size
-         sta   <VD.CurCo,u	current module in use? ($02=CO32, $04=C080)
+         stx   <V.Col,u	save screen size
+         sta   <V.CurCo,u	current module in use? ($02=CO32, $04=C080)
 L0600    rts
-L0601    bita  <u0070,u		module loaded?
+L0601    bita  <V.COLoad,u	module loaded?
          beq   L0608		branch if not
 L0606    clrb			else clear carry
          rts			and return
@@ -905,7 +875,7 @@
          bcc   L061F
          puls  y,x,a
          lbra  NoIOMod
-L061F    leax  <CoEnt,u		get base pointer to CO-entries
+L061F    leax  <V.GRFOE,u	get base pointer to CO-entries
          lda   ,s		get A off stack
          sty   a,x		save off CO32/CO80 entry point
          puls  y,x,a
@@ -918,7 +888,8 @@
          os9   F$Link
          puls  pc,u
 
-L0637    fdb   $0055,$aaff
+* 128x192 4 color pixel table
+Mode1Clr fdb   $0055,$aaff
 
 GfxDispatch
          cmpa  #$15		GRFO-handled code?
@@ -926,7 +897,7 @@
          cmpa  #$0F		display graphics code?
          beq   Do0F		branch if so
          suba  #$10
-         bsr   L065B		check if first gfx screen was alloc'ed
+         bsr   GfxActv		check if first gfx screen was alloc'ed
          bcs   L0663		if not, return with error
          leax  <gfxtbl,pcr	else point to jump table
          lsla			multiply by two
@@ -940,38 +911,38 @@
          fdb   Do13-gfxtbl	$13 - Erase Graphics
          fdb   Do14-gfxtbl	$14 - Home Graphics Cursor
 
-L065B    ldb   <VD.Rdy,u		ready?
-         bne   L0606
+GfxActv  ldb   <V.Rdy,u	gfx screen allocated?
+         bne   L0606		branch if so
 NotReady comb
          ldb   #E$NotRdy
 L0663    rts
 
-GoGrfo   bsr   L065B
+GoGrfo   bsr   GfxActv
          bcs   L0663
-         ldx   <VD.GRFOE,u		get GRFO entry point
-         bne   L0681			branch if not zero
-         pshs  y,a			else preserve regs
+         ldx   <V.GRFOE,u	get GRFO entry point
+         bne   L0681		branch if not zero
+         pshs  y,a		else preserve regs
          bne   L067F
-         leax  >GRFO,pcr		get pointer to name string
-         bsr   LinkSub			link to GRFO
-         bcc   L067B			branch if ok
-         puls  pc,y,a			else exit with error
-L067B    sty   <VD.GRFOE,u		save module entry pointer
-L067F    puls  y,a			restore regs
-L0681    clra				A = GRFO address offset in statics
+         leax  >GRFO,pcr	get pointer to name string
+         bsr   LinkSub		link to GRFO
+         bcc   L067B		branch if ok
+         puls  pc,y,a		else exit with error
+L067B    sty   <V.GRFOE,u	save module entry pointer
+L067F    puls  y,a		restore regs
+L0681    clra			A = GRFO address offset in statics
          lbra  CoWrite
 
 * Allocate GFX mem -- we must allocate on a 512 byte page boundary
-GetMem   pshs  u			save static pointer
-         ldd   #6144+256		allocate graphics memory + 1 page
-         os9   F$SRqMem			do it
-         bcc   L0691			branch if ok
-         puls  pc,u			else return with error
-L0691    tfr   u,d			move mem ptr to D
-         puls  u			restore statics
-         tfr   a,b			move high 8 bits to lower
-         bita  #$01			odd page?
-         beq   L069F			branch if not
+GetMem   pshs  u		save static pointer
+         ldd   #6144+256	allocate graphics memory + 1 page
+         os9   F$SRqMem		do it
+         bcc   L0691		branch if ok
+         puls  pc,u		else return with error
+L0691    tfr   u,d		move mem ptr to D
+         puls  u		restore statics
+         tfr   a,b		move high 8 bits to lower
+         bita  #$01		odd page?
+         beq   L069F		branch if not
          adda  #$01
          bra   L06A1
 L069F    addb  #$18
@@ -980,9 +951,9 @@
          clrb
          tfr   d,u
          ldd   #256
-         os9   F$SRtMem			return page
+         os9   F$SRtMem		return page
          puls  u,a
-         bcs   L06B3			branch if error
+         bcs   L06B3		branch if error
          clrb
 L06B3    rts
 
@@ -991,36 +962,36 @@
          ldb   #$02
          lbra  L03BF
 
-DispGfx  ldb   <VD.Rdy,u		already allocated initial buffer?
-         bne   L06D1			branch if so
-         bsr   GetMem			else get graphics memory
-         bcs   L06EF			branch if error
-         std   <VD.CurBf,u		save memory
-         std   <VD.GBuff,u		and GBuff
-         inc   <VD.Rdy,u		ok, we're ready
-         lbsr  EraseGfx			clear gfx mem
-L06D1    lda   <VD.NChar,u
-         sta   <u004B,u
-         anda  #$03
-         leax  >L0637,pcr
-         lda   a,x
-         sta   <u0047,u
-         sta   <u0048,u
-         lda   <VD.NChr2,u
-         cmpa  #$01
-         bls   L06F0
+DispGfx  ldb   <V.Rdy,u		already allocated initial buffer?
+         bne   L06D1		branch if so
+         bsr   GetMem		else get graphics memory
+         bcs   L06EF		branch if error
+         std   <V.SBAdd,u	save memory
+         std   <V.GBuff,u	and GBuff
+         inc   <V.Rdy,u		ok, we're ready
+         lbsr  EraseGfx		clear gfx mem
+L06D1    lda   <V.NChr2,u	get character after next
+         sta   <V.PMask,u	save color set (0-3)
+         anda  #$03		mask out all but lower 2 bits
+         leax  >Mode1Clr,pcr	point to mask byte table
+         lda   a,x		get byte
+         sta   <V.Msk1,u	save mask byte here
+         sta   <V.Msk2,u	and here
+         lda   <V.NChar,u	get next char, mode byte (0-1)
+         cmpa  #$01		compare against max
+         bls   L06F0		branch if valid
          comb
-         ldb   #E$BMode
+         ldb   #E$BMode		else invalid mode specified, send error
 L06EF    rts
 
-L06F0    tsta
-         beq   L0710
+L06F0    tsta			test user supplied mode byte
+         beq   L0710		branch if 256x192
          ldd   #$C003
-         std   <u0049,u
+         std   <V.MCol,u
          lda   #$01
-         sta   <u0024,u
+         sta   <V.Mode,u	128x192 mode
          lda   #$E0
-         ldb   <VD.NChar,u
+         ldb   <V.NChr2,u
          andb  #$08
          beq   L0709
          lda   #$F0
@@ -1028,41 +999,42 @@
          leax  <L0742,pcr
          bra   L072D
 L0710    ldd   #$8001
-         std   <u0049,u
+         std   <V.MCol,u
          lda   #$FF
-         tst   <u0047,u
+         tst   <V.Msk1,u
          beq   L0723
-         sta   <u0047,u
-         sta   <u0048,u
-L0723    sta   <u0024,u
+         sta   <V.Msk1,u
+         sta   <V.Msk2,u
+L0723    sta   <V.Mode,u	256x192 mode
          lda   #$F0
          ldb   #$07
          leax  <L0746,pcr
-L072D    stb   <u0044,u
-         stx   <u0042,u
-         ldb   <VD.NChar,u
+L072D    stb   <V.PixBt,u
+         stx   <V.MTabl,u
+         ldb   <V.NChr2,u
          andb  #$04
          lslb  
          pshs  b
          ora   ,s+
          ldb   #$01
+* Indicate screen is current
          lbra  SetDsply
 
 L0742    fcb   $c0,$30,$0c,$03
 L0746    fcb   $80,$40,$20,$10,$08,$04,$02,$01
 
-* $11 - Set Color
+* $11 - set color
 Do11     leax  <SetColor,pcr	set up return address
          lbra  L03BD
 
-SetColor clr   <VD.NChr2,u
-         lda   <u0024,u
-         bmi   L075F
-         inc   <VD.NChr2,u
+SetColor clr   <V.NChar,u	get next char
+         lda   <V.Mode,u	which mode?
+         bmi   L075F		branch if 256x192
+         inc   <V.NChar,u
 L075F    lbra  L06D1
 
-* End graphics
-Do12     leax  <VD.GBuff,u	point to first buffer
+* $12 - end graphics
+Do12     leax  <V.GBuff,u	point to first buffer
          ldy   #$0000		Y = 0
          ldb   #$03		free 3 gfx screens max
          pshs  u,b
@@ -1079,37 +1051,37 @@
          os9   F$SRtMem		and free memory
 L0788    puls  u,b		restore regs
          clra
-         sta   <VD.Rdy,u	gfx mem no longer alloced
+         sta   <V.Rdy,u	gfx mem no longer alloced
          lbra  SetDsply
 
 Do10     leax  <Preset,pcr	set up return address
          lbra  L03BD
 
-Preset   lda   <VD.NChar,u
-         tst   <u0024,u
-         bpl   L07A7
-         ldb   #$FF
-         anda  #$01
-         beq   EraseGfx
-         bra   L07B2
-
-L07A7    anda  #$03
-         leax  >L0637,pcr
-         ldb   a,x
-         bra   L07B2
+* NOTE! Shouldn't this be lda <V.NChar,u ??
+Preset   lda   <V.NChr2,u	get next char
+         tst   <V.Mode,u	which mode?
+         bpl   L07A7		branch if 128x192 4 color
+         ldb   #$FF		assume we will clear with $FF
+         anda  #$01		mask out all but 1 bit (2 colors)
+         beq   EraseGfx		erase graphic screen with color $00
+         bra   L07B2		else erase screen with color $FF
+L07A7    anda  #$03		mask out all but 2 bits (4 colors)
+         leax  >Mode1Clr,pcr	point to color table
+         ldb   a,x		get appropriate byte
+         bra   L07B2		and start the clearing
 
 * Erase graphics screen
 Do13
 EraseGfx clrb				value to clear screen with
-L07B2    ldx   <VD.CurBf,u
+L07B2    ldx   <V.SBAdd,u
          leax  >6144+1,x		point to end of gfx mem + 1
 L07B9    stb   ,-x			clear
-         cmpx  <VD.CurBf,u		X = to start?
+         cmpx  <V.SBAdd,u		X = to start?
          bhi   L07B9			if not, continue
 * Home Graphics cursor
 Do14     clra
          clrb
-         std   <u0045,u
+         std   <V.GCrsX,u
          rts
 
 *
--- a/level1/modules/co32.asm	Fri May 21 16:44:02 2004 +0000
+++ b/level1/modules/co32.asm	Fri May 21 21:44:15 2004 +0000
@@ -44,16 +44,16 @@
 Term     pshs  y,x
          pshs  u		save U
          ldd   #512		32x16 VDG memory size
-         ldu   <VD.ScrnA,u 	get pointer to memory
+         ldu   <V.ScrnA,u 	get pointer to memory
          os9   F$SRtMem 	return to system
          puls  u		restore U
-         ldb   <$70,u
+         ldb   <V.COLoad,u
          andb  #$FD
          bra   L0086
 * Init
 Init     pshs  y,x		save regs
          lda   #$AF
-         sta   <VD.CColr,u	save default color cursor
+         sta   <V.CColr,u	save default color cursor
          pshs  u		save static ptr
          ldd   #768		allocate 768 bytes for now
          os9   F$SRqMem 	get it
@@ -67,23 +67,23 @@
 L0056    ldd   #256		and return last 256 bytes
          os9   F$SRtMem 	free it!
          puls  u		restore static ptr
-         stx   <VD.ScrnA,u 	save VDG screen memory
+         stx   <V.ScrnA,u 	save VDG screen memory
          pshs  y
          leay  -$0E,y
          clra  
          clrb  
-         jsr   [<$5B,u]
+         jsr   [<V.DspVct,u]	display screen (routine in CCIO)
          puls  y
-         stx   <VD.CrsrA,u 	save start cursor position
+         stx   <V.CrsrA,u 	save start cursor position
          leax  >512,x		point to end of screen
-         stx   <VD.ScrnE,u 	save it
+         stx   <V.ScrnE,u 	save it
          lda   #$60		get default character
-         sta   <VD.CChar,u 	put character under the cursor
-         sta   <VD.Chr1,u	only referenced here ??
+         sta   <V.CChar,u 	put character under the cursor
+         sta   <V.Chr1,u	only referenced here ??
          lbsr  ClrScrn		clear the screen
-         ldb   <$70,u
+         ldb   <V.COLoad,u
          orb   #$02		set to CO32 found (?)
-L0086    stb   <$70,u
+L0086    stb   <V.COLoad,u
          clrb  
          puls  pc,y,x
 
@@ -94,7 +94,7 @@
          bmi   L00D0
          cmpa  #$1F			byte $1F?
          bls   Dispatch			branch if lower or same
-         ldb   <VD.CFlag,u
+         ldb   <V.CFlag,u
          beq   L00B0
          cmpa  #$5E
          bne   L00A0
@@ -124,10 +124,10 @@
          bcs   L00CE
          suba  #$40
 L00CE    eora  #$40
-L00D0    ldx   <VD.CrsrA,u		get cursor address in X
+L00D0    ldx   <V.CrsrA,u		get cursor address in X
          sta   ,x+			store character at address
-         stx   <VD.CrsrA,u 		update cursor address
-         cmpx  <VD.ScrnE,u 		end of screen?
+         stx   <V.CrsrA,u 		update cursor address
+         cmpx  <V.ScrnE,u 		end of screen?
          bcs   L00DF			branch if not
          bsr   SScrl			else if at end of screen, scroll it
 L00DF    bsr   ShowCrsr			ends with a CLRB/RTS anyhow
@@ -137,14 +137,14 @@
          rts   
 
 * Screen Scroll Routine
-SScrl    ldx   <VD.ScrnA,u		get address of screen
+SScrl    ldx   <V.ScrnA,u		get address of screen
          leax  <32,x			move to 2nd line
 L00E9    ldd   ,x++			copy from this line
          std   <-34,x			to prevous
-         cmpx  <VD.ScrnE,u		at end of screen yet?
+         cmpx  <V.ScrnE,u		at end of screen yet?
          bcs   L00E9			branch if not
          leax  <-32,x			else back up one line
-         stx   <VD.CrsrA,u		save address of cursor (first col of last row)
+         stx   <V.CrsrA,u		save address of cursor (first col of last row)
          lda   #32			clear out row...
          ldb   #$60			...width spaces
 L00FD    stb   ,x+			do it...
@@ -185,11 +185,11 @@
 Retrn    bsr   HideCrsr		hide cursor
          tfr   x,d		put cursor address in D
          andb  #$E0		place at start of line
-         stb   <VD.CrsAL,u	and save low cursor address
-ShowCrsr ldx   <VD.CrsrA,u $21	get cursor address
+         stb   <V.CrsAL,u	and save low cursor address
+ShowCrsr ldx   <V.CrsrA,u 	get cursor address
          lda   ,x		get char at cursor position
-         sta   <VD.CChar,u $23	save it
-         lda   <VD.CColr,u $2C	get cursor character
+         sta   <V.CChar,u 	save it
+         lda   <V.CColr,u 	get cursor character
          beq   L014D		branch if none
 L014B    sta   ,x		else turn on cursor
 L014D    clrb  
@@ -198,29 +198,29 @@
 * $0A - cursor down (line feed)
 CurDown  bsr   HideCrsr		hide cursor
          leax  <32,x		move X down one line
-         cmpx  <VD.ScrnE,u $1F	at end of screen?
+         cmpx  <V.ScrnE,u 	at end of screen?
          bcs   L0162		branch if not
          leax  <-32,x		else go back up one line
          pshs  x		save X
          bsr   SScrl		and scroll the screen
          puls  x		restore pointer
-L0162    stx   <VD.CrsrA,u $21	save cursor pointer
+L0162    stx   <V.CrsrA,u 	save cursor pointer
          bra   ShowCrsr		show cursor
 
 * $08 - cursor left
 CurLeft  bsr   HideCrsr		hide cursor
-         cmpx  <VD.ScrnA,u $1D	compare against start of screen
+         cmpx  <V.ScrnA,u 	compare against start of screen
          bls   L0173		ignore it if at the screen start
          leax  -$01,x		else back up one
-         stx   <VD.CrsrA,u $21	save updated pointer
+         stx   <V.CrsrA,u 	save updated pointer
 L0173    bra   ShowCrsr		and show cursor
 
 * $06 - cursor right
 CurRght  bsr   HideCrsr		hide cursor
          leax  $01,x		move to the right
-         cmpx  <VD.ScrnE,u $1F	compare against end of screen
+         cmpx  <V.ScrnE,u 	compare against end of screen
          bcc   L0181		if past end, ignore it
-         stx   <VD.CrsrA,u $21	else save updated pointer
+         stx   <V.CrsrA,u 	else save updated pointer
 L0181    bra   ShowCrsr		and show cursor
 
 * $0B - erase to end of screen
@@ -231,20 +231,20 @@
 ClrScrn  bsr   CurHome		home cursor
 L0189    lda   #$60		get default char
 L018B    sta   ,x+		save at location
-         cmpx  <VD.ScrnE,u $1F	end of screen?
+         cmpx  <V.ScrnE,u 	end of screen?
          bcs   L018B		branch if not
          bra   ShowCrsr		now show cursor
 
 * $01 - home cursor
 CurHome  bsr   HideCrsr		hide cursor
-         ldx   <VD.ScrnA,u $1D	get pointer to screen
-         stx   <VD.CrsrA,u $21	save as new cursor position
+         ldx   <V.ScrnA,u $1D	get pointer to screen
+         stx   <V.CrsrA,u $21	save as new cursor position
          bra   ShowCrsr		and show it
 
 * Hides the cursor from the screen
 * Exit: X = address of cursor
-HideCrsr ldx   <VD.CrsrA,u $21	get address of cursor in X
-         lda   <VD.CChar,u $23	get value of char under cursor
+HideCrsr ldx   <V.CrsrA,u $21	get address of cursor in X
+         lda   <V.CChar,u $23	get value of char under cursor
          sta   ,x		put char in place of cursor
          clrb  			must be here, in general, for [...] BRA HideCrsr
          rts   
@@ -254,10 +254,10 @@
          leax  <CrsrSw,pcr	
          bra   L01E5
 
-CrsrSw   lda   <VD.NChar,u 	get next char
+CrsrSw   lda   <V.NChr2,u 	get next char
          suba  #C$SPAC		take out ASCII space
          bne   L01BB		branch if not zero
-         sta   <VD.CColr,u 	else save cursor color zero (no cursor)
+         sta   <V.CColr,u 	else save cursor color zero (no cursor)
          bra   HideCrsr		and hide cursor
 L01BB    cmpa  #$0B		greater than $0B?
          bge   L014D		yep, just ignore byte
@@ -276,30 +276,30 @@
          lsla  
          lsla  
          ora   #$8F
-L01D7    sta   <VD.CColr,u 	save new cursor
-         ldx   <VD.CrsrA,u 	get cursor address
+L01D7    sta   <V.CColr,u 	save new cursor
+         ldx   <V.CrsrA,u 	get cursor address
          lbra  L014B		branch to save cursor in X
 
 * $02 XX YY - move cursor to col XX-32, row YY-32
 CurXY    ldb   #$02		we want to claim next two chars
          leax  <DoCurXY,pcr	point to processing routine
-L01E5    stx   <$26,u
-         stb   <$25,u
+L01E5    stx   <V.RTAdd,u	store routine to return to
+         stb   <V.NGChr,u	get two more chars
          clrb  
          rts   
 
 DoCurXY  bsr   HideCrsr		hide cursor
-         ldb   <VD.NChar,u $29	get ASCII Y-pos
+         ldb   <V.NChr2,u 	get ASCII Y-pos
          subb  #C$SPAC		take out ASCII space
          lda   #32		go down
          mul   			multiply it
-         addb  <VD.NChr2,u $28	add in X-pos
+         addb  <V.NChar,u 	add in X-pos
          adca  #$00
          subd  #C$SPAC		take out another ASCII space
-         addd  <VD.ScrnA,u $1D	add top of screen address
-         cmpd  <VD.ScrnE,u $1F	at end of the screen?
+         addd  <V.ScrnA,u 	add top of screen address
+         cmpd  <V.ScrnE,u 	at end of the screen?
          lbcc  L014D		exit if off the screen
-         std   <VD.CrsrA,u $21	otherwise save new cursor address
+         std   <V.CrsrA,u 	otherwise save new cursor address
          lbra  ShowCrsr		and show cursor
 
 * $04 - erase to end of line
@@ -315,7 +315,7 @@
 DelLine  lbsr  Retrn		do a CR
          ldb   #32		line length
 L0223    lda   #$60		get default character
-         ldx   <VD.CrsrA,u $21	get cursor address
+         ldx   <V.CrsrA,u 	get cursor address
 L0228    sta   ,x+		fill screen line with 'space'
          decb  			decrement
          bne   L0228		and branch if not end
@@ -324,15 +324,15 @@
 * $09 - cursor up
 CurUp    lbsr  HideCrsr		hide cursor
          leax  <-32,x		move X up one line
-         cmpx  <VD.ScrnA,u $1D	compare against start of screen
+         cmpx  <V.ScrnA,u 	compare against start of screen
          bcs   L023E		branch if we went beyond
-         stx   <VD.CrsrA,u $21	else store updated X
+         stx   <V.CrsrA,u 	else store updated X
 L023E    lbra  ShowCrsr		and show cursor
 
 * $0E - switch screen to alphanumeric mode
 DoAlpha  clra  
          clrb  
-         jmp   [<$5B,u]
+         jmp   [<V.DspVct,u]	display screen (routine in CCIO)
 
 * GetStat
 GetStat  ldx   PD.RGS,y		get caller's regs
@@ -347,16 +347,16 @@
          rts   
 
 * SS.AlfaS getstat
-Rt.AlfaS ldd   <VD.ScrnA,u 	memory address of buffer
+Rt.AlfaS ldd   <V.ScrnA,u 	memory address of buffer
          std   R$X,x		save in caller's X
-         ldd   <VD.CrsrA,u 	get cursor address
+         ldd   <V.CrsrA,u 	get cursor address
          std   R$Y,x		save in caller's Y
-         lda   <VD.Caps,u 	save caps lock status in A and exit
+         lda   <V.Caps,u 	save caps lock status in A and exit
          bra   SaveA
 
 * SS.Cursr getstat
-Rt.Cursr ldd   <VD.CrsrA,u	get address of cursor
-         subd  <VD.ScrnA,u	subtract screen address
+Rt.Cursr ldd   <V.CrsrA,u	get address of cursor
+         subd  <V.ScrnA,u	subtract screen address
          pshs  b,a		D now holds cursor position relative to screen
          clra  
          andb  #$1F
@@ -372,8 +372,8 @@
          andb  #$0F		only 16 line to a screen
          addb  #$20
          std   R$Y,x		and save column to caller's Y
-         ldb   <VD.CFlag,u
-         lda   <VD.CChar,u	get character under cursor
+         ldb   <V.CFlag,u
+         lda   <V.CChar,u	get character under cursor
          bmi   SaveA		if hi bit set, go on
          cmpa  #$60		VDG space?
          bcc   L02A5		branch if greater than
--- a/level1/modules/co80.asm	Fri May 21 16:44:02 2004 +0000
+++ b/level1/modules/co80.asm	Fri May 21 21:44:15 2004 +0000
@@ -19,6 +19,7 @@
 
          ifp1
          use   defsfile
+         use   cciodefs
          endc
 
 tylg     set   Systm+Objct   
@@ -57,26 +58,26 @@
          lbsr  L0229
          ldd   #$07D0
          lbsr  L0189
-         ldb   <$70,u
+         ldb   <V.COLoad,u
          orb   #$04
          bra   L004F
 * Term
-Term     ldb   <$70,u
+Term     ldb   <V.COLoad,u
          andb  #$FB
-L004F    stb   <$70,u
+L004F    stb   <V.COLoad,u
          clrb  
          rts   
 * GetStat
-GetStat  cmpa  #$25
+GetStat  cmpa  #SS.Cursr
          bne   SetStat
-         ldy   $06,y
+         ldy   R$Y,y
          clra  
-         ldb   <$58,u
+         ldb   <V.C80X,u
          addb  #$20
          std   $06,y
-         ldb   <$59,u
+         ldb   <V.C80Y,u
          addb  #$20
-         std   $04,y
+         std   R$X,y
          ldx   #$FF78
          lda   #$0D
          sta   $01,x
@@ -139,33 +140,34 @@
          fdb   L0121-L00C5  $005c  $0A:CURSOR DOWN
          fdb   L0186-L00C5  $00c1  $0B:ERASE TO EOS
          fdb   L0184-L00C5  $00bf  $0C:CLEAR SCREEN
-         fdb   L0101-L00C5  $003c  $0D:RETURN
+         fdb   Do0D-L00C5  $003c  $0D:RETURN
 
 * $08 - cursor left
-L00E1    ldd   <$58,u
-         bne   L00E8
+L00E1    ldd   <V.C80X,u	get CO80 X/Y
+         bne   L00E8		branch if not at start
          clrb  	
          rts   	
 L00E8    decb  
          bge   L00EE
          ldb   #$4F
          deca  
-L00EE    std   <$58,u
+L00EE    std   <V.C80X,u
          bra   L014F
 
 * $09 - cursor up
-L00F3    lda   <$58,u
+L00F3    lda   <V.C80X,u
          beq   L00FF
          deca  
-         sta   <$58,u
+         sta   <V.C80X,u
          lbra  L01CC
 L00FF    clrb  
          rts   
 
 * $0D - move cursor to start of line (carriage return)
-L0101    clr   <$59,u
+Do0D     clr   <V.C80Y,u
          bra   L014C
-L0106    ora   <$5A,u
+
+L0106    ora   <V.5A,u
          pshs  a
          bsr   L0174
          puls  a
@@ -174,39 +176,39 @@
          sta   ,x
 
 * $06 - cursor right
-L0115    inc   <$59,u
-         lda   <$59,u
+L0115    inc   <V.C80Y,u
+         lda   <V.C80Y,u
          cmpa  #$4F
          ble   L014C
-         bsr   L0101
+         bsr   Do0D
 
 * $0A - cursor down (line feed)
-L0121    lda   <$58,u
+L0121    lda   <V.C80X,u
          cmpa  #$17
          bge   L012E
          inca  
-         sta   <$58,u
+         sta   <V.C80X,u
          bra   L014F
-L012E    ldd   <$54,u
+L012E    ldd   <V.54,u
          lbsr  L01DC
-         ldd   <$54,u
-         addd  #$0050
+         ldd   <V.54,u
+         addd  #80
          bsr   L0161
-         std   <$54,u
+         std   <V.54,u
          bsr   L018E
-         ldd   <$54,u
+         ldd   <V.54,u
          bsr   L016B
          lda   #$08
          sta   $01,x
          stb   ,x
-L014C    lda   <$58,u
+L014C    lda   <V.C80X,u
 L014F    lbra  L01CC
 
 * $01 - home cursor
-L0152    clr   <$58,u
-         clr   <$59,u
-         ldd   <$54,u
-         std   <$56,u
+L0152    clr   <V.C80X,u
+         clr   <V.C80Y,u
+         ldd   <V.54,u
+         std   <V.56,u
          lbra  L01DC
 L0161    cmpd  #$07D0
          blt   L016A
@@ -226,8 +228,8 @@
          rts   
 
 * $03 - erase line
-L0179    bsr   L0101		do a CR
-L017B    lda   <$58,u
+L0179    bsr   Do0D		do a CR
+L017B    lda   <V.C80X,u
          inca  
          ldb   #80		line length
          mul   
@@ -238,7 +240,7 @@
 
 * $0B - erase to end of screen
 L0186    ldd   #$0780
-L0189    addd  <$54,u
+L0189    addd  <V.54,u
          bsr   L0161
 L018E    bsr   L016B
          bsr   L0174
@@ -255,13 +257,13 @@
 * $02 XX YY - move cursor to col XX-32, row YY-32
 L01A2    leax  >L01B0,pcr
          ldb   #$02
-L01A8    stx   <$26,u
-         stb   <$25,u
+L01A8    stx   <V.RTAdd,u
+         stb   <V.NGChr,u
          clrb  
          rts   
 L01B0    ldx   #$FF78
-         lda   <$29,u
-         ldb   <$28,u
+         lda   <V.NChr2,u
+         ldb   <V.NChar,u
          subb  #$20
          blt   L01A0
          cmpb  #$4F
@@ -270,14 +272,14 @@
          blt   L01A0
          cmpa  #$17
          bgt   L01A0
-         std   <$58,u
+         std   <V.C80X,u
 L01CC    ldb   #$50
          mul   
-         addb  <$59,u
+         addb  <V.C80Y,u
          adca  #$00
-         addd  <$54,u
+         addd  <V.54,u
          bsr   L0161
-         std   <$56,u
+         std   <V.56,u
 L01DC    pshs  b,a
          bsr   L0174
          lda   #$0A
@@ -292,7 +294,7 @@
          rts   
 L01F2    cmpa  #$1F
          bne   L0201
-         lda   <$29,u
+         lda   <V.NChr2,u
          cmpa  #$21
          beq   L0205
          cmpa  #$20
@@ -301,10 +303,10 @@
          ldb   #E$Write
          rts   
 L0205    lda   #$80
-         sta   <$5A,u
+         sta   <V.5A,u
          clrb  
          rts   
-L020C    clr   <$5A,u
+L020C    clr   <V.5A,u
 L020F    clrb  
          rts   
 
@@ -313,7 +315,7 @@
          ldb   #$01
          bra   L01A8
 L0219    ldx   #$FF78
-         lda   <$29,u
+         lda   <V.NChr2,u	get next character
          cmpa  #$20		cursor code valid?
          blt   L0201		 no, error
          beq   L022D