changeset 1584:0e3a28789196

Source comments updated
author boisy
date Fri, 21 May 2004 16:44:02 +0000
parents 2d73cd04596b
children 4a2a4667a4cf
files level1/modules/ccio.asm level1/modules/co32.asm
diffstat 2 files changed, 147 insertions(+), 136 deletions(-) [+]
line wrap: on
line diff
--- a/level1/modules/ccio.asm	Fri May 21 15:14:45 2004 +0000
+++ b/level1/modules/ccio.asm	Fri May 21 16:44:02 2004 +0000
@@ -121,7 +121,7 @@
          sta   <u0051,u
          leax  >AltIRQ,pcr		get IRQ routine ptr
          stx   >D.AltIRQ		store in AltIRQ
-         leax  >L03CC,pcr
+         leax  >SetDsply,pcr
          stx   <u005B,u
          leax  >L050F,pcr
          stx   <u005D,u
@@ -180,23 +180,23 @@
          coma
          rts
 * Check if we need to wrap around tail pointer to zero
-L009D    incb
-         cmpb  #$7F
-         bls   L00A3
-         clrb
+L009D    incb			increment pointer
+         cmpb  #$7F		at end?
+         bls   L00A3		branch if not
+         clrb			else clear pointer (wrap to head)
 L00A3    rts
 
 *
 * IRQ routine for keyboard
 *
 AltIRQ   ldu   >D.KbdSta	get keyboard static
-         ldb   <u0032,u
-         beq   L00B7
-         ldb   <u002F,u
-         beq   L00B7
+         ldb   <VD.CFlg1,u	graphics screen currently being displayed?
+         beq   L00B7		branch if not
+         ldb   <VD.Alpha,u	alpha mode?
+         beq   L00B7		branch if so
          lda   <u0030,u
-         lbsr  L03CC
-L00B7    ldx   #PIA0Base
+         lbsr  SetDsply		set up display
+L00B7    ldx   #PIA0Base	point to PIA base
          clra
          clrb
          std   <u006A,u		clear
@@ -246,35 +246,36 @@
          bne   L0105
          ldb   #60
 L011A    stb   <u0051,u
-         ldb   <VD.IBufH,u
-         leax  <VD.InBuf,u
-         abx
+         ldb   <VD.IBufH,u	get head pointer in B
+         leax  <VD.InBuf,u	point X to input buffer
+         abx			X now holds address of head
          lbsr  L009D		check for tail wrap
-         cmpb  <VD.IBufT,u
-         beq   L012F
+         cmpb  <VD.IBufT,u	B at tail?
+         beq   L012F		branch if so
          stb   <VD.IBufH,u
-L012F    sta   ,x
-         beq   L014F
-         cmpa  V.PCHR,u
-         bne   L013F
-         ldx   V.DEV2,u
-         beq   L014F
-         sta   $08,x
-         bra   L014F
-L013F    ldb   #S$Intrpt
-         cmpa  V.INTR,u
-         beq   L014B
-         ldb   #S$Abort
-         cmpa  V.QUIT,u
-         bne   L014F
-L014B    lda   V.LPRC,u
-         bra   L0153
-L014F    ldb   #S$Wake
-         lda   V.WAKE,u
-L0153    beq   L0158
-         os9   F$Send
-L0158    clr   V.WAKE,u
-         bra   L00E4
+L012F    sta   ,x		store our char at ,X
+         beq   WakeIt		if nul, do wake-up
+         cmpa  V.PCHR,u		pause character?
+         bne   L013F		branch if not
+         ldx   V.DEV2,u		else get dev2 statics
+         beq   WakeIt		branch if none
+         sta   V.PAUS,x		else set pause request
+         bra   WakeIt
+L013F    ldb   #S$Intrpt	get interrupt signal
+         cmpa  V.INTR,u		our char same as intr?
+         beq   L014B		branch if same
+         ldb   #S$Abort		get abort signal
+         cmpa  V.QUIT,u		our char same as QUIT?
+         bne   WakeIt		branch if not
+L014B    lda   V.LPRC,u		get ID of last process to get this device
+         bra   L0153		go for it
+WakeIt   ldb   #S$Wake		get wake signal
+         lda   V.WAKE,u		get process to wake
+L0153    beq   L0158		branch if none
+         os9   F$Send		else send wakeup signal
+L0158    clr   V.WAKE,u		clear process to wake flag
+         bra   L00E4		and move along
+
 L015C    clra
          clrb
          std   <u0066,u
@@ -337,7 +338,7 @@
          inc   <u0069,u
          subb  #$06
 L01DD    pshs  x
-         leax  >L0321,pcr
+         leax  >KeyTbl,pcr		point to keyboard table
          lda   b,x
          puls  x
          bmi   L01FD
@@ -358,6 +359,7 @@
          com   <VD.Caps,u
 L0208    orcc  #Negative
 L020A    rts
+
 L020B    pshs  b,a
          clrb
          orcc  #Carry
@@ -495,7 +497,11 @@
          stb   ,x
 L0320    rts
 
-L0321    fcb   $00,$40,$60	ALT @ `
+* Key Table
+* 1st column = key (no modifier)
+* 2nd column = SHIFT+key
+* 3rd column = CTRL+key 
+KeyTbl   fcb   $00,$40,$60	ALT @ `
          fcb   $0c,$1c,$13	UP
          fcb   $0a,$1a,$12	DOWN
          fcb   $08,$18,$10	LEFT
@@ -579,30 +585,34 @@
 COEscape ldb   #$03		write offset into CO-module
          lbra  JmpCO
 
-L03CC    pshs  x,a
-         stb   <u002F,u
+* 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
          lda   >PIA1Base+2
-         anda  #$07
-         ora   ,s+
-         tstb
-         bne   L03DE
+         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
 L03DE    sta   >PIA1Base+2
          sta   <u0030,u
-         tstb
-         bne   L03F5
-* Bang %00010101 to VDG
+         tstb			display graphics?
+         bne   DoGfx		branch if so
+* Set up VDG screen for text
+DoVDG
          stb   >$FFC0
          stb   >$FFC2
          stb   >$FFC4
-         lda   <u001D,u
+         lda   <VD.ScrnA,u		get pointer to alpha screen
          bra   L0401
 
-* Bang %00101001 to VDG
-L03F5    stb   >$FFC0
+* Set up VDG screen for graphics
+DoGfx    stb   >$FFC0
          stb   >$FFC3
          stb   >$FFC5
-         lda   <VD.CurBf,u
+         lda   <VD.CurBf,u		get pointer to graphics screen
+
 L0401    ldb   #$07
          ldx   #$FFC6
          lsra
@@ -851,7 +861,7 @@
          ldd   R$X,x		get select flag
          beq   L05C3		if zero, do nothing
          ldb   #$01		else set display flag
-L05C3    stb   <u0032,u		save display flag
+L05C3    stb   <VD.CFlg1,u	save display flag
          clrb
          rts
 BadMode  comb
@@ -1036,7 +1046,7 @@
          pshs  b
          ora   ,s+
          ldb   #$01
-         lbra  L03CC
+         lbra  SetDsply
 
 L0742    fcb   $c0,$30,$0c,$03
 L0746    fcb   $80,$40,$20,$10,$08,$04,$02,$01
@@ -1070,7 +1080,7 @@
 L0788    puls  u,b		restore regs
          clra
          sta   <VD.Rdy,u	gfx mem no longer alloced
-         lbra  L03CC
+         lbra  SetDsply
 
 Do10     leax  <Preset,pcr	set up return address
          lbra  L03BD
--- a/level1/modules/co32.asm	Fri May 21 15:14:45 2004 +0000
+++ b/level1/modules/co32.asm	Fri May 21 16:44:02 2004 +0000
@@ -43,8 +43,8 @@
          lbra  SetStat
 Term     pshs  y,x
          pshs  u		save U
-         ldd   #$0200		32x16 VDG memory size
-         ldu   <VD.ScrnA,u $1D	get pointer to memory
+         ldd   #512		32x16 VDG memory size
+         ldu   <VD.ScrnA,u 	get pointer to memory
          os9   F$SRtMem 	return to system
          puls  u		restore U
          ldb   <$70,u
@@ -53,7 +53,7 @@
 * Init
 Init     pshs  y,x		save regs
          lda   #$AF
-         sta   <VD.CColr,u $2C save default color cursor
+         sta   <VD.CColr,u	save default color cursor
          pshs  u		save static ptr
          ldd   #768		allocate 768 bytes for now
          os9   F$SRqMem 	get it
@@ -67,19 +67,19 @@
 L0056    ldd   #256		and return last 256 bytes
          os9   F$SRtMem 	free it!
          puls  u		restore static ptr
-         stx   <VD.ScrnA,u $1D	save VDG screen memory
+         stx   <VD.ScrnA,u 	save VDG screen memory
          pshs  y
          leay  -$0E,y
          clra  
          clrb  
          jsr   [<$5B,u]
          puls  y
-         stx   <VD.CrsrA,u $21	save start cursor position
+         stx   <VD.CrsrA,u 	save start cursor position
          leax  >512,x		point to end of screen
-         stx   <VD.ScrnE,u $1F	save it
+         stx   <VD.ScrnE,u 	save it
          lda   #$60		get default character
-         sta   <VD.CChar,u $23	put character under the cursor
-         sta   <VD.Chr1,u $2B   only referenced here ??
+         sta   <VD.CChar,u 	put character under the cursor
+         sta   <VD.Chr1,u	only referenced here ??
          lbsr  ClrScrn		clear the screen
          ldb   <$70,u
          orb   #$02		set to CO32 found (?)
@@ -94,7 +94,7 @@
          bmi   L00D0
          cmpa  #$1F			byte $1F?
          bls   Dispatch			branch if lower or same
-         ldb   <VD.CFlag,u $71
+         ldb   <VD.CFlag,u
          beq   L00B0
          cmpa  #$5E
          bne   L00A0
@@ -124,42 +124,43 @@
          bcs   L00CE
          suba  #$40
 L00CE    eora  #$40
-L00D0    ldx   <VD.CrsrA,u $21
-         sta   ,x+
-         stx   <VD.CrsrA,u $21
-         cmpx  <VD.ScrnE,u $1F
-         bcs   L00DF
-         bsr   SScrl			if at end of screen, scroll it
+L00D0    ldx   <VD.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?
+         bcs   L00DF			branch if not
+         bsr   SScrl			else if at end of screen, scroll it
 L00DF    bsr   ShowCrsr			ends with a CLRB/RTS anyhow
 
 * no operation entry point
 NoOp     clrb  
          rts   
 
-SScrl    ldx   <VD.ScrnA,u $1D
-         leax  <32,x
-L00E9    ldd   ,x++
-         std   <-34,x
-         cmpx  <VD.ScrnE,u $1F
-         bcs   L00E9
-         leax  <-32,x
-         stx   <VD.CrsrA,u $21
-         lda   #32
-         ldb   #$60
-L00FD    stb   ,x+
-         deca  
-         bne   L00FD
+* Screen Scroll Routine
+SScrl    ldx   <VD.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?
+         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)
+         lda   #32			clear out row...
+         ldb   #$60			...width spaces
+L00FD    stb   ,x+			do it...
+         deca  				end of rope?
+         bne   L00FD			branch if not
 L0102    rts   
 
-Dispatch cmpa  #$1B
-         bcc   L0113
-         cmpa  #$0E
-         bhi   L0102
-         leax  <DCodeTbl,pcr
-         lsla  
-         ldd   a,x
-         jmp   d,x
-L0113    comb  
+Dispatch cmpa  #$1B		escape code?
+         bcc   bad@		branch if same or greater
+         cmpa  #$0E		$0E?
+         bhi   L0102		branch if higher than
+         leax  <DCodeTbl,pcr	deal with screen codes
+         lsla  			adjust for table entry size
+         ldd   a,x		get address in D
+         jmp   d,x		and jump to routine
+bad@     comb  
          ldb   #E$Write
          rts   
 
@@ -169,7 +170,7 @@
          fdb   CurXY-DCodeTbl  $00c9  $02:CURSOR XY
          fdb   DelLine-DCodeTbl  $0107  $03:ERASE LINE
          fdb   ErEOLine-DCodeTbl  $00f9  $04:CLEAR TO EOL
-         fdb   CrsrSw-DCodeTbl  $0091  $05:CURSOR ON/OFF
+         fdb   Do05-DCodeTbl  $0091  $05:CURSOR ON/OFF
          fdb   CurRght-DCodeTbl  $005e  $06:CURSOR RIGHT
          fdb   NoOp-DCodeTbl  $ffca  $07:no-op (bel:handled in CCIO)
          fdb   CurLeft-DCodeTbl  $0050  $08:CURSOR LEFT
@@ -181,10 +182,10 @@
          fdb   DoAlpha-DCodeTbl  $012a  $0E:DISPLAY ALPHA
 
 * $0D - move cursor to start of line (carriage return)
-Retrn    bsr   HideCrsr
-         tfr   x,d
-         andb  #$E0
-         stb   <$22,u
+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
          lda   ,x		get char at cursor position
          sta   <VD.CChar,u $23	save it
@@ -249,14 +250,14 @@
          rts   
 
 * $05 XX - set cursor off/on/color per XX-32
-CrsrSw   ldb   #$01
-         leax  <L01AF,pcr	
+Do05     ldb   #$01		need additional byte
+         leax  <CrsrSw,pcr	
          bra   L01E5
 
-L01AF    lda   <VD.NChar,u $29	get next char
+CrsrSw   lda   <VD.NChar,u 	get next char
          suba  #C$SPAC		take out ASCII space
          bne   L01BB		branch if not zero
-         sta   <VD.CColr,u $2C	else save cursor color zero (no cursor)
+         sta   <VD.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
@@ -275,8 +276,8 @@
          lsla  
          lsla  
          ora   #$8F
-L01D7    sta   <VD.CColr,u $2C	save new cursor
-         ldx   <VD.CrsrA,u $21	get cursor address
+L01D7    sta   <VD.CColr,u 	save new cursor
+         ldx   <VD.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
@@ -334,11 +335,11 @@
          jmp   [<$5B,u]
 
 * GetStat
-GetStat  ldx   PD.RGS,y
-         cmpa  #SS.AlfaS	$1C
-         beq   Rt.AlfaS
-         cmpa  #SS.Cursr	$25
-         beq   Rt.Cursr
+GetStat  ldx   PD.RGS,y		get caller's regs
+         cmpa  #SS.AlfaS	AlfaS?
+         beq   Rt.AlfaS		branch if so
+         cmpa  #SS.Cursr	Cursr?
+         beq   Rt.Cursr		branch if so
 
 * SetStat
 SetStat  comb  
@@ -346,21 +347,21 @@
          rts   
 
 * SS.AlfaS getstat
-Rt.AlfaS ldd   <VD.ScrnA,u $1D	memory address of buffer
-         std   R$X,x
-         ldd   <VD.CrsrA,u $21
-         std   R$Y,x
-         lda   <VD.Caps,u $50	save caps lock status in A and exit
-         bra   L02BA
+Rt.AlfaS ldd   <VD.ScrnA,u 	memory address of buffer
+         std   R$X,x		save in caller's X
+         ldd   <VD.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
+         bra   SaveA
 
 * SS.Cursr getstat
-Rt.Cursr ldd   <VD.CrsrA,u $21
-         subd  <VD.ScrnA,u $1D
-         pshs  b,a
+Rt.Cursr ldd   <VD.CrsrA,u	get address of cursor
+         subd  <VD.ScrnA,u	subtract screen address
+         pshs  b,a		D now holds cursor position relative to screen
          clra  
          andb  #$1F
-         addb  #$20
-         std   R$X,x		save column position in ASCII
+         addb  #$20		compute column position
+         std   R$X,x		save column position to caller's X
          puls  b,a		then divide by 32
          lsra  
          rolb  
@@ -370,38 +371,38 @@
          clra  
          andb  #$0F		only 16 line to a screen
          addb  #$20
-         std   $06,x
-         ldb   <VD.CFlag,u $71
-         lda   <VD.CChar,u $23
-         bmi   L02BA
-         cmpa  #$60
-         bcc   L02A5
-         cmpa  #$20
+         std   R$Y,x		and save column to caller's Y
+         ldb   <VD.CFlag,u
+         lda   <VD.CChar,u	get character under cursor
+         bmi   SaveA		if hi bit set, go on
+         cmpa  #$60		VDG space?
+         bcc   L02A5		branch if greater than
+         cmpa  #$20		
          bcc   L02A9
-         tstb  
+         tstb 
          beq   L02A3
          cmpa  #$00
          bne   L029B
          lda   #$5E
-         bra   L02BA		save it and exit
+         bra   SaveA		save it and exit
 
 L029B    cmpa  #$1F
          bne   L02A3
          lda   #$5F
-         bra   L02BA
-L02A3    ora   #$20		turn it into ASCII from vDG codes
+         bra   SaveA
+L02A3    ora   #$20		turn it into ASCII from VDG codes
 L02A5    eora  #$40
-         bra   L02BA
+         bra   SaveA
 L02A9    tstb  
-         bne   L02BA
+         bne   SaveA
          cmpa  #$21		remap specific codes
          bne   L02B4
          lda   #$7C
-         bra   L02BA
+         bra   SaveA
 L02B4    cmpa  #$2D
-         bne   L02BA
+         bne   SaveA
          lda   #$7E
-L02BA    sta   $01,x
+SaveA    sta   R$A,x
          clrb  
          rts