;------------------------------------------------------------------------
;		Copyright 2010 Integrated Logic Systems
;                  Source Code is Copyright Stephen J. Carden
;
;
;			Please do not share this source!
;------------------------------------------------------------------------
;                              Makemsgb.com
;
;	This is a program to peak a byte and display it to the screen
;	to Make a database structor	05/27/2010	sjc
;	added a recursive dir maker	05/29/2010	sjc
;
;       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;------------------------------------------------------------------------
; Notes: o This source code MAY NOT be placed for download on any BBS's!
;        o "mea" is a macro that loads the address of the first field
;          into the pointer specified by the second field.
;------------------------------------------------------------------------
; Assembler:  MADMAC (tm) ST Cross Assembler (Atari Corp)
;             XASM   st and IBM VERSIONS
;------------------------------------------------------------------------

com_file_name:		.macro
;			dc.b   13,"filename.ext",$9b
			dc.b   12,"Makemsgb.com",$9b
			.endm

;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; File revision history. Version Number in hex
;
file_ver:		equ	$16
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; the Month in dec for the first time this revision 
;was compiled
;
c_month:		equ	8
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; the day in dec for the first time this revision 
;was compiled
c_day:			equ	28
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; the year in dec for the first time this revision 
;was compiled
c_year:			equ	2012
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Type of compiler used in program
;
; 0 = unknown Compiler
; 1 = xasm
; 2 = mac_65
; 3 = basic
; 4 = compiled basic xl
; 5 = C65
; 6 = Action
;
; We can add more as time goes on!
;
;
;
xasm:			equ	1
mac_65:			equ	2 
basic:			equ	3
basicxl:		equ	4
c65:			equ	5
action:			equ	6

file_compiler:		equ	xasm
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; is this relocatable code ?
; anyother value other than 1 or 2 would be unknown
r..yes:			equ	1
r..no:			equ	2
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Gotta define if it can be relocated
l_relocatable:		equ	r..no
;
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Gotta define our Header control Byte
;$ff =bypass intro
;$15 = Bypass Dos check
r..crl:			equ	$7d
r..crlf:		equ	$9b
r..space:		equ	$20
r..bypassDOS:		equ	$15
r..bypass:		equ	$ff

l_frstscreenbyte:	equ	$ff
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; The language the output file is in. 
;
;
; 0	=	Undifined
; 1	=	English
; 2	=	German
;
r..language:		equ	1
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


			.include	equates
			.include	globals
			.include	macros

			.org  $4000

win_start:
header_info:
			.include	header			; this reads info out of the header and displays to screen
 
tammy:
			ldx	#disk1
			jsr	close
			ldx	#disk2
			jsr	close

			lda	comtab
			CLC 
			adc	# low ZCRNAME
			sta	cli.crunch+1
			lda	comtab+1
			adc	# high ZCRNAME
			sta	cli.crunch+2
			jsr	cli.crunch
			bne	.get_parm1				; nothing there
			jmp	parm_errors

.get_parm1:
			lda	comtab
			CLC 
			adc	# low COMFNAM
			sta	s_ptr
			lda	comtab+1
			adc	# high COMFNAM
			sta	s_ptr+1
			mea	parm_1,d_ptr
			jsr	tostr

			mea	parm_1,s_ptr
			mea	filename,d_ptr
			jsr	toascii
			jsr	make_path


			lda	consol
			cmp	#consol_any
			beq	.no_tell		;beq
		
			jsr	printsi		
			dc.b	$9b," this is my cli to parm Code"
			dc.b	$9b,"Parm_1 =",-1
			mea	parm_1,pr_ptr
			jsr	echos

			jsr	cr_lf
			mea	path1,pr_ptr
			jsr	echos

			jsr	printsi
			dc.b	" #",-1
			lda	totalpath
			jsr	pr_byte

			jsr	printsi
			dc.b	$9b,$9b,-1
			jsr	get_key
			rts

.no_tell:
			jmp	begin

cli.crunch:		jmp	$0000

parm_errors:

			jsr	printsi
			dc.b	$9B,$9B
			dc.b	" Syntax for use:",$9b
			dc.b	" Makemsgb Dn:>dir>fname.ext",$9b
			dc.b	" This Program will make",$9b
			dc.b	" Directorys for you!",$9b
			dc.b	$9b

			dc.b	$9b
			dc.b	-1
			rts
;
;

word:			ds.b    30              ;damn backward compatibility!    
s_node:			dc.w	26		; need to change this to the dos build #

s_today:        	ds.b    14              ;today's date
cur_date:       	ds.b    15              ; Mon 13-May-87 + len_byte + $9B
cur_time:       	ds.b    15              ; 11:00:00am    + len_byte + $9B
cur_month:      	ds.b    1               ;1-12
cur_day:        	ds.b    1               ;1-31
cur_year:       	ds.b    1               ;1-99
cur_hour:       	ds.b    1               ;0-23
cur_minute:     	ds.b    1               ;0-59
cur_second:     	ds.b    1               ;0-59
cur_weekday:    	ds.b    1               ;0=sunday, 1=monday,...7=saturday
s_msgbdr:       	ds.b    32              ;drives each message base is on
hi_msglo:       	ds.b    32      	;PRIVATE  32 hi message numbers (2 bytes each)
hi_msghi:       	ds.b    32      	;PRIVATE
u_handle:       	ds.b    21              ;handle
u_flags:       		dc.w    $ffff,$ffff	; 16 individual flags
u_seclvl:       	dc.w    $ffff,$ffff	;security level (32 bits)
u_msgread:      	ds.b    4               ;read messages?
u_msgpost:      	ds.b    4               ;post messages?
u_msgedit:      	ds.b    4               ;edit any message?
u_msgdel:       	dc.w    $ffff,$ffff               ;delete any message?
;
in_clock:		dc.b	0		;set by the Z: handler functions
tdbuff:			ds.b	30		;time/date buffer area
queue:			dc.b	0		;stuff a key into the
qout:			dc.b	0		;
qin:			dc.b	0		;
rc:			dc.b	0		; Return Code
trans:			dc.b	0		;0=atascii,1=ascii

parm_1:			ds.b	80
parm_2:			ds.b	80
parm_3:			ds.b	80
in_str:         	ds.b    80              ;
instr:          	ds.b    80              ;
read_buff:      	ds.b    512             ;PRIVATE generic read buffer

;
my_count:		ds.b	1

tammy_c:		dc.w	0
steve1:			dc.b	26


filename:		ds.b	80


totalpath:		dc.b	0
path1:			ds.b	128
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
f.temp:			dc.b	0,0,0
ascii:			ds.b	6
num:			dc.w	0
char:			ds.b	6
counter:		dc.w	0
count:			dc.b	0
counter2:		dc.w	2560
mbsize:			dc.w	768,1024,1280,1536,1792,2048,2304,2560
temp2:			dc.b	0,0,0
stat:			dc.b	0

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;Make Path
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make_path:
			ldx	#0
			ldy	#1
.a:			lda	parm_1,y
			cmp	#'>'
			bne	.b
			lda	#$00			;'%'
			inc	totalpath
			inx

.b:			cmp	#'.'
			beq	.strip
			cpy	parm_1
			beq	.strip
			sta	path1,y
			sty	path1
			iny
			lda	#$9b
			sta	path1,y
			beq	.a
			bne	.a
.strip:
			lda	totalpath
			cmp	#$00
			beq	.done
			ldy	path1
.loop:			dey
			lda	path1,y
			cmp	#$00			;'%'
			bne	.loop
.done:			sty	path1
			lda	#$9b
			sta	path1,y
			ldy	#4
			lda	path1,y
			cmp	#$00			;'%'
			bne	.exit
			lda	#'>'
			sta	path1,y
			ldy	totalpath
			dey
			sty	totalpath
.exit:
			rts
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;next Path
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

next_path:
			lda	totalpath
			cmp	#$00
			bne	.next
			rts
.next:
			ldy	#$00
.a:			iny
			lda	path1,y
			cpy	path1
			beq	.done
			cmp	#$00			;'%'
			bne	.a
			lda	#'>'
			sta	path1,y
			ldy	totalpath
			dey
			sty	totalpath
			rts
.done:
			lda	#$00
			sta	totalpath
			rts

;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;Prints a byte or a card to the screen
;
;
pr_byte:
			ldx	#$00
pr_card:
			sta	fr0
			stx	fr0+1
			lda	#$00
			sta	cix
			jsr	ifp
			jsr	fasc
			ldy	#$00
.aprbloop:
			lda	(inbuff),y
			php
			and	#$7f
			iny
			jsr	echo
			plp
			bpl	.aprbloop
			rts


;       gets a BYTE value - returned in Accum
;       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

get_byte:		jsr     get_str
			dc.w   .work
			dc.b	3,1,0
			tay
			iny
			lda     #$9b			;install eol
			sta     .work,y	
			mea     .work,inbuff
			lda     #1
			sta     cix
			jsr     afp			;ascii --> floating pt.
			bcs     .default
			jsr     fpi			;floating --> integer
			bcs     .default
			lda     fr0+1			;enter > 255?
			bne     .ovfl			;yes
			lda     fr0
			rts
.ovfl:          	lda     #255
			rts
.default:       	lda     #0
			rts

.work:          	ds.b    6



;       get_str    gets an input line into the specified string.
;
;       input:  address of string in in_ptr
;               A - max length
;               X - mask (0=alpha/numeric, 1=numeric)
;               Y - allow return key only (1=yes)
;
;     length of inputted string is returned in the 0th position (and A)
;    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

get_str:		pla				;entry here, parms on stack
			sta     pr_ptr
			pla
			sta     pr_ptr+1
			ldy     #1
			lda     (pr_ptr),y		;get address lo
			sta     in_ptr
			iny
			lda     (pr_ptr),y		;   address hi
			sta     in_ptr+1
			iny
			lda     (pr_ptr),y		;   length byte
			sta     .gsa
			iny
			lda     (pr_ptr),y		;   mask
			sta     .gsx
			iny
			lda     (pr_ptr),y		;   return allowed?
			sta     .gsy
			lda     pr_ptr			;now, correct stack
			clc
			adc     #5
			sta     pr_ptr
			lda     pr_ptr+1
			adc     #0
			pha
			lda     pr_ptr
			pha
			lda     .gsa
			ldx     .gsx
			ldy     .gsy
			jmp     get_string

.gsa:           	dc.b    0
.gsx:           	dc.b    0
.gsy:           	dc.b    0


get_string:		cmp     #83			;max < 83?
			bcc     .gsentry		;yes
			lda     #80
.gsentry:		sta     .maxlth			;save max length
			stx     .mask
			sty     .return

			lda     #0
			sta     attract


			lda     in_ptr
			sta     .address		;hold address of string
			lda     in_ptr+1		; to input into
			sta     .address+1
			lda     #0
			sta     .instr			;zero length byte

.gsloop:		jsr     get_key			;get a keypress
			cmp     #'\'			;can't allow this key!
			beq     .gsloop			;yes, ignore
			cmp     #$9b			;carriage return?
			bne     .nogs			;nope
			jmp     .gscr			;yes
.nogs:			cmp     #14			;treat ^N as a C/R
			bne     .not14
			jmp     .gscr
.not14:			cmp     #126			;backspace?
			beq     .bspace
			cmp     #30
			beq     .bspace
			cmp     #24			;^X?
			bne     .nowipe
			jmp     .wipeout
.nowipe:		and     #$7f			;strip inverse bit
			sta     .key			;hold it

;       now, see if it falls within requested mask
;       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


			ldx     .mask			;get mask
			beq     .alphanum
			cpx     #1
			beq     .numeric

.alphanum:		cmp     #32			; < space?
			bcc     .gsloop			;yes, ignore
			cmp     #'z'+1			; > 'z'
			bcs     .gsloop			;yes, ignore
			jmp     .gsstore

.numeric:		cmp     #'0'			; < '0'?
			bcc     .gsloop			;yes, ignore
			cmp     #'9'+1			; > '9'
			bcs     .gsloop			;yes, ignore
			jmp     .gsstore

.gsstore:		lda     .instr			;get length byte
			cmp     .maxlth
			beq     .gsloop			;ignore it..at
			bcs     .gsloop			; max length now
			tay
			iny
			lda     .key
			cmp     #32			;is it a space?
			bne     .notspc			;nope
			cpy     #1			;1st char in line?
			bne     .notspc
			jmp     .gsloop			;yes..don't allow it
.notspc:		sta     .instr,y		;save key into string
			inc     .instr			;increase length
.nohide:		lda     .key
.showit:		jsr     echo
			lda     .maxlth			;one-key input?
			cmp     #1
			bne     .nohot			;nope
			lda     .instr
			cmp     #1			;1 byte entered?
			bne     .nohot
			lda     u_flags
			and     #f_hotkey               ;user want hotkeys?
			beq     .nohot			;nope..
			jmp     .gscr			;yes - auto carriage return!
.nohot:			jmp     .gsloop			;keep cookin..

.bspace:		lda     .instr			;can't backspace
			cmp     #0			; if no length!
			bne     .nt0
			jmp     .gsloop
.nt0:			dec     .instr			;-1 to length byte
			lda     #126			;output a BSpace
			jsr     echo
			jmp     .gsloop

.wipeout:		lda     .instr			;can't backspace if no length
			bne     .wt0
			jmp     .gsloop
.wt0:			dec     .instr			;-1 to length byte
			lda     #126			;output a BSpace
			jsr     echo
			jmp     .wipeout		;go until line cleared

.gscr:			lda     .instr			;get length
			bne     .nonull			;its not null
			ldx     .return			;allow return only?
			bne     .nonull			;yes..exit
			jmp     .gsloop			;nope..ignore it

;       done, so move our string into where they want it.
;       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.nonull:		lda     s_ptr
			sta     .holds
			lda     s_ptr+1
			sta     .holds+1
			lda     d_ptr
			sta     .holdd
			lda     d_ptr+1
			sta     .holdd+1
			mea     .instr,s_ptr
			lda     .address
			sta     d_ptr
			lda     .address+1
			sta     d_ptr+1
			jsr     move_str		;move to their area..
			lda     .holds
			sta     s_ptr
			lda     .holds+1
			sta     s_ptr+1
			lda     .holdd
			sta     d_ptr
			lda     .holdd+1
			sta     d_ptr+1
			lda     .instr			;return with lth in A
			rts


.address:		ds.b    2
.holds:			ds.b    2
.holdd:			ds.b    2
.maxlth:		ds.b    1
.mask:			ds.b    1
.return:		ds.b    1
.key:			ds.b    1
.instr:			ds.b    86


;       Search the string pointed to by S_PTR for the substring
;       pointed to by D_PTR.  Returns a 0 if substring not found.
;       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

substr:			ldy     #0
			lda     (s_ptr),y
			sta     .s_lth
			lda     (d_ptr),y
			sta     .d_lth
			lda     s_ptr
			sta     .comp+1
			lda     s_ptr+1
			sta     .comp+2
			lda     d_ptr
			sta     .get+1
			lda     d_ptr+1
			sta     .get+2
			lda     #1
			sta     .loc
			ldy     #0
			ldx     #0
			jsr     .up_str
			jsr     .up_sub

.comp:          	lda     $ffff,y
			jsr     upcase
			sta     .temp
.get:           	lda     $ffff,x
			jsr     upcase
			cmp     .temp
			beq     .match
.nomatch:       	ldx     #1
			inc     .loc
			jsr     .up_str
			jmp     .comp
.match:         	jsr     .up_sub
			jsr     .up_str
			jmp     .comp

.up_str:        	iny
			cpy     .s_lth
			bcc     .xup
			beq     .xup
			pla
			pla
			lda     #0
.xup:           	rts

.up_sub:        	inx
			cpx     .d_lth
			bcc     .xsub
			beq     .xsub
			pla
			pla
			lda     .loc
.xsub:          	rts

.temp:          	dc.b    0
.loc:           	dc.b    0
.s_lth:         	dc.b    0
.d_lth:         	dc.b    0

;     Make an ASCII ($9b terminated) string out of a lth-byte string
;     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

toascii:        	ldy     #0
			lda     (s_ptr),y               ;get lth byte
			sta     .lth
			beq     .null
			iny
			inc     .lth
.loop:          	lda     (s_ptr),y
			dey
			sta     (d_ptr),y
			iny
			iny
			cpy     .lth
			bne     .loop
.done:          	ldy     .lth
			dey
.rtn:  			lda	    #$9b
			sta     (d_ptr),y
			rts
.null:          	ldy     #0
			beq     .rtn

.lth:           	dc.b    1

;     Make a length-byte string from an ASCII ($9b terminated) string
;     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tostr:          	ldy     #0
.tfe:  			lda	(s_ptr),y               ;find end of string
			beq     .gotend
			cmp     #$9b
			beq     .gotend
			iny
			bne     .tfe
.gotend:        	sty     .lth		    ;save length
			cpy     #0
			beq     .rtn
			ldy     #0
.loop: 			lda	(s_ptr),y
			iny
			sta     (d_ptr),y
			cpy     .lth
			bcc     .loop
.rtn:           	ldy     #0
			lda     .lth
			sta     (d_ptr),y
			rts

.lth:           	dc.b    1


;============================================================================
;   These routines work very much like the filename crunch routines in
;   SpartaDOS.   On consecutive calls to CRUNCH, the next word from the
;   command line (pointed to by IN_PTR) will be placed into the field WORD.
;   If there are no more words on the command line, then CRUNCH will return
;   with carry set.
;     When calling the parser for the first time on a new input line, you
;   MUST zero out the BUFOFF field.  Also, extraneous spaces will be
;   compressed out of the input line, and the command word will be folded
;   to upper case.
;============================================================================


crunch:			ldy     bufoff          ;get index into line
			ldx     #0              ;zero storing index

.nonspc:        	lda     instr,y         ;move buffoff to next non-space
			cmp     #$9b
			beq     .nomore         ;end of line -- signal error
			cmp     #32             ;= space?
			beq     .go_on          ;yep
			cmp     #','
			beq     .go_on
			cmp     #'-'
			beq     .go_on
			bne     .gotone         ;found one
.go_on:         	iny
			bne     .nonspc         ;keep looking

.nomore:        	sec			;signal error
			rts			; and return

.gotone:        	lda     instr,y         ;get byte of command line
			cmp     #$9b
			beq     .end            ;end of line

			cmp     #32             ;space?
			beq     .end            ;yes
			cmp     #','
			beq     .end
			cmp     #'-'
			beq     .end

			jsr     upcase
			sta     word,x
			inx
			iny
			bne     .gotone         ;keep going

.end:           	sty     bufoff          ;save new bufoff value
			lda     #$9b            ;put null byte at end of word
			sta     word,x
			clc
end_crunch:     	rts



;--------------------------------------------
;printsi Routeen macro             
;this is a slow print to the screen
;usage jsr	printsi
;    .byte $9b," string to be printed",$ff
;--------------------------------------------
;
printsi:
			pla
			sta	.pstr+1
			pla
			sta	.pstr+2
.prsl:			inc	.pstr+1
			bne	.pstr
			inc	.pstr+2
.pstr:			lda	$ffff
			cmp	#$ff
			beq	.estri
			jsr	fast_output
			jmp	.prsl
.estri:			lda	.pstr+2
			pha
			lda	.pstr+1
			pha
			rts
;
;-------------------------
;actual screen handler    
;screen offset definitions
;-------------------------
scr_offset:		dc.w	0
			dc.w	40
			dc.w	80
			dc.w	120
			dc.w	160
			dc.w	200
			dc.w	240
			dc.w	280
			dc.w	320
			dc.w	360
			dc.w	400
			dc.w	440
			dc.w	480
			dc.w	520
			dc.w	560
			dc.w	600
			dc.w	640
			dc.w	680
			dc.w	720
			dc.w	760
			dc.w	800
			dc.w	840
			dc.w	880
			dc.w	920
;
fast_output:
			sta	$5a
			lda	sc.redirect
			cmp	#print_p
			beq	.go_cio
.leo:
			lda 	$02ff   	; CONTROL 1 FLAG
			cmp 	#$00
			bne 	.leo

			lda	$5a
			cmp	#32
			bcc	.do_look
			cmp	#125
			bcc	.do_here
.do_look:		ldy	#0
.lookup:		lda	.char_table,y
			beq	.do_here
			cmp	$5a
			beq	.go_cio
			iny
			bne	.lookup


.go_cio:		lda	$5a
			jmp	putlocal


.do_here:		ldy	#0
			lda	$5d
			sta	($5e),y
			lda	$5a
			cmp	#$9b
			beq	.docr
.notcr:			jsr	.get_adr
			lda	$5a
			and	#$7f
			cmp	#32
			bcc	.add64
			cmp	#96
			bcc	.sub32
			jmp	.asis
.add64:			clc
			adc	#64
			jmp	.asis
.sub32:			sec
			sbc	#32
.asis:			bit	$5a
			bpl	.xxlate
			ora	#$80
.xxlate:		ldy	#0
			sta	($5e),y
			inc	$55
			inc	$63
			lda	$55
			cmp	#40
			bcs	.next_row
			iny
			lda	($5e),y
			sta	$5d
			ora	#$80
			ldx	752
			bne	.nocurs1
			sta	($5e),y
.nocurs1:		inc	$5e
			bne	.nooav
			inc	$5e+1
.nooav:			rts
.docr:			lda	#0
			sta	$63
.next_row:		lda	$52
			sta	$55
			inc	$54
			ldy	$54
			cpy	#24
			bcs	.scroll
			jsr	.get_adr
			ldy	#0
			lda	($5e),y
			sta	$5d
			ldx	752
			bne	.nocurs2
			ora	#$80
			sta	($5e),y
.nocurs2:		rts

.scroll:		dec	$54
			lda	$58
			sta	$68
			clc
			adc	#40
			sta	$5e
			lda	$58+1
			sta	$68+1
			adc	#0
			sta	$5e+1
			ldy	#0
			ldx	#3
.scloop:		lda	($5e),y
			sta	($68),y
			iny
			bne	.scloop
			inc	$5e+1
			inc	$68+1
			dex
			bne	.scloop
.scloop2:		lda	($5e),y
			sta	($68),y
			iny
			cpy	#152
			bcc	.scloop2
			lda	$58
			clc
			adc	#920&$ff
			sta	$5e
			lda	$58+1
			adc	#920/256
			sta	$5e+1
			ldy	#0
			tya
.clear:			sta	($5e),y
			iny
			cpy	#40
			bcc	.clear
			ldx	752
			bne	.nocurs3
			lda	#$80
			ldy	$55
			sta	($5e),y
.nocurs3:		lda	#0
			sta	$5d
			lda	$5e
			clc
			adc	$55
			sta	$5e
			lda	$5e+1
			adc	#0
			sta	$5e+1
			rts
.get_adr:		lda	$54
			asl
			tay
			lda	$58
			clc
			adc	scr_offset,y
			sta	$5e
			lda	$58+1
			adc	scr_offset+1,y
			sta	$5e+1
			lda	$5e
			clc
			adc	$55
			sta	$5e
			lda	$5e+1
			adc	#0
			sta	$5e+1
			rts
.char_table:
			dc.b	27,28,29,30,31,125,126,127
			dc.b	156,157,158,159,253,254,255,0


putlocal:
			ldx	#11
			stx	$0342
			ldx	#0
			stx	$0348
			stx	$0349
			jmp	$e456
;
;
;------------
; PRINT BYTE 
;------------
echo:
sprint:			sta	$b8
			lda	#$04
			sta	$034a
			stx	$b6
			sty	$b7
			ldx	#$06
			lda	$e400+1,x
			sta	$b3
			lda	$e400,x
			sta	$b2
			lda	$b8
			jsr	.a
			ldx	$b6
			ldy	$b7
			lda	#$0c
			sta	$034a
			lda	$b8
			rts
;
.a:			inc	$b2
			jmp	($b2)
			rts

;  prints: prints string with address in PR_PTR, length byte in 0th byte
;  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

echos:
                	ldy     #0
                	lda     (pr_ptr),y              ;get length to print
                	beq     .xpri                   ;exit, null string
                	sta     .maxlth
                	iny
                	sty     .tempy

.pril:          	ldy     .tempy
                	lda     (pr_ptr),y
                	jsr     echo
.prnext:        	inc     .tempy
                	dec     .maxlth
                	bne     .pril
.xpri:          	rts

.tempy:         	dc.b    1
.maxlth:        	dc.b    1

;  prints: prints string with address in PR_PTR, length byte in 0th byte
;  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

echosE:
                	ldy     #0
                	lda     (pr_ptr),y              ;get length to print
                	beq     .xpri                   ;exit, null string
                	sta     .maxlth
                	iny
                	sty     .tempy

.pril:          	ldy     .tempy
                	lda     (pr_ptr),y
			cmp	#$00
			beq	.xpri			; stop printing if a zero is present
                	jsr     echo
.prnext:        	inc     .tempy
                	dec     .maxlth
                	bne     .pril
.xpri:          	rts

.tempy:         	dc.b    1
.maxlth:        	dc.b    1



;       lookup command in table (in s_ptr) and execute it
;       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

execute:		jsr     upcase
			sta     .key
			ldy     #0
.loop:			lda     (s_ptr),y
			beq     .found
			cmp     .key
			beq     .found
			iny
			iny
			iny
			bne     .loop
.found:			iny
			lda	(s_ptr),y
			sta     .goaddr+1
			iny
			lda	(s_ptr),y
			sta     .goaddr+2
.goaddr:		jmp     $ffff
.key:			dc.b    0

;------------------------------
;   GET KEY  ROUTEEN           
;this routeen get's one key and
;return it to the accumlator   
;------------------------------
;
get_key:		stx	$b6
			sty	$b7
			jsr	.a
			ldx	$b6
			ldy	$b7
			rts
.a:			lda	$e420+5
			pha
			lda	$e420+4
			pha
			rts



cr_lf:			lda	#$9b
			jsr	echo
			rts


open_in:		lda 	#4
			jmp 	do_open

open_out:		lda 	#8
			jmp 	do_open

open_app:		lda 	#9
			jmp 	do_open

open_updt:		lda 	#12
			jmp 	do_open

open_dir:		lda 	#6
			jmp 	do_open

open_raw:		lda 	#20     	;open raw directory
			jmp 	do_open

do_open:
			pha 		        ;open filespec pointed to by fn_ptr
			txa 		        ;
			pha
			jsr 	close		;make sure device is closed
			pla
			tax
			pla
			sta 	icaux1,x
			lda 	#ccopen
			sta 	iccom,x
			lda	fn_ptr
			sta 	icbal,x
			lda 	fn_ptr+1
			sta	icbah,x
			lda	#80
			sta	icbll,x
			lda	#0
			sta 	icblh,x
			lda 	#128		;for long directory (shouldn't hurt??)
			sta	icaux2,x
			jmp 	ciov

close:			lda 	#ccclose
			sta 	iccom,x
			jmp 	ciov

;       Generic system error routine
;       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~


sys_error:		save                            ;save all registers
                	sty     .temp                   ;save error status
       			jsr	printsi
			dc.b    $9b,$9b,"System Error: ",-1
			lda     .temp
			jsr	pr_byte
			jsr	cr_lf
			restore                         ;restore registers
			rts

.temp:			dc.b    1






upcase:			cmp	#'a'
			bcc	xupcase
			cmp	#'z'+1
			beq	xupcase
			bcs	xupcase
			sec
			sbc	#32
xupcase:		rts


locase:			cmp     #'A'
			bcc     xlocase
			cmp     #'Z'+1
			beq     xlocase
			bcs     xlocase
			clc
			adc     #32
xlocase:		rts


;       Compares the strings pointed to by s_ptr and d_ptr.
;       Returns with equal set if true, not equal if false.
;       The comparison IS NOT case-sensitive.
;       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cmp_str:		ldy     #0              ;zero index
                	lda     (s_ptr),y       ;get length bytes
                	sta     .lth
                	cmp     (d_ptr),y       ;they match?
                	bne     .noteq          ;nope
                	cmp     #0              ;null string?
                	beq     .end            ;they match
                	iny
.loop:          	lda     (s_ptr),y       ;get next byte
       			jsr	upcase
			sta     .temp
			lda     (d_ptr),y       ;they match?
			jsr	upcase
			cmp     .temp
			bne     .noteq          ;nope..
			cpy     .lth            ;end of string?
			beq     .end            ;yes -- they match
			iny
			bne     .loop
.noteq:			lda     #1              ;set BNE
			rts
.end:			lda     #0              ;set BEQ
                	rts
.lth:           	dc.b    1
.temp:          	dc.b    1


y_or_n:			jsr	get_str
			dc.w   .temp
			dc.b	1,0,0
                	lda     .temp+1
       			jsr	upcase
                	cmp     #'Y'
                	beq     .yes
                	cmp     #'N'
                	beq     .no
                	lda     #126                    ;backspace
       			jsr	echo
                	jmp     y_or_n                  ; and try it again
.no:   			jsr	cr_lf
                	lda     #'N'
                	rts
.yes:  			jsr	cr_lf
                	lda     #'Y'
                	rts
.temp:          	ds.b    2


;       Move string pointed to by s_ptr to string pointed to by d_ptr
;       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


move_str:		ldy     #0
			lda     (s_ptr),y               ;get lth byte
			tay                             ;go backwards
.loop:			lda     (s_ptr),y
			sta     (d_ptr),y
			cpy     #0
			beq     .done
			dey
			jmp     .loop
.done:			rts

datestamp:		lda     in_clock		;hold current tdline status
			sta     .hold
			lda     #1			;signal for the VBI to leave
			sta     in_clock		;  the TDLINE alone..
			jsr	waitvbi			;make sure VBI is done
			lda     #13
			sta     cur_date
			lda     #10
			sta     cur_time
			jsr	get_TD			;get the date/time/weekday
			lda     .hold			;restore tdline status
			sta     in_clock
			mea     cur_date,s_ptr		;if date has changed, then
			mea     s_today,d_ptr		; reset calls_today to 0
			jsr	cmp_str
			beq     .noupd
			jsr	move_str
.noupd:			rts

.hold:			dc.b    0

;		Wait for a VBI to occur
;		~~~~~~~~~~~~~~~~~~~~~~~

waitvbi:		lda     $14
.lp1:			cmp     $14
			beq     .lp1
			lda     $14
.lp2:			cmp     $14
			beq     .lp2
			rts

;          get both the "formatted" and "unformatted" date and time
;          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

get_TD:			lda     portb		;save PORTB setting
			pha
			and     #$FE
			sta     portb		;enable RAM under OS
			ldy     #.tdbuff & $ff
			ldx     #.tdbuff / 256
       			jsr	$FFC9		;get formatted time/date
       			jsr	$FFC0		;get unformatted time/date
			pla
			sta     portb		;restore PORTB setting
			bcc     .noerr

.error:			lda     #0
			sta     cur_date
			sta     cur_time
			rts

;       move the formatted date into cur_date, cur_time
;       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.noerr:			ldy     #0
			ldx     #1
.lp:			lda     tdbuff,y
			sta     cur_date,x
			inx
			iny
			cpy     #13
			bne     .lp
			ldx     #1
			iny
.lp2:			lda     tdbuff,y
			sta     cur_time,x
			inx
			iny
			cpy     #24
			bne     .lp2

;       move the unformatted date into the byte fields
;       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

			ldy     #13		;point to DATER
			lda     (comtab),y
			sta     cur_day
			iny
			lda     (comtab),y
			sta     cur_month
			iny
			lda     (comtab),y
			sta     cur_year
			iny
			lda     (comtab),y
			sta     cur_hour
			iny
			lda     (comtab),y
			sta     cur_minute
			iny
			lda     (comtab),y
			sta     cur_second

;           now, figure out what weekday it is
;           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

			lda     cur_date+2	;2nd char of the dateline
			cmp     #'o'
			beq     .monday
			cmp     #'e'
			beq     .wednesday
			cmp     #'h'
			beq     .thursday
			cmp     #'r'
			beq     .friday
			cmp     #'a'
			beq     .saturday
.tues_sun:		lda     cur_date+1
			cmp     #'T'
			beq     .tues
.sun:			lda     #0
			jmp     .exit
.tues:			lda     #2
			jmp     .exit
.monday:		lda     #1
			jmp     .exit
.wednesday:		lda     #3
			jmp     .exit
.thursday:		lda     #4
			jmp     .exit
.friday:		lda     #5
			jmp     .exit
.saturday:		lda     #6
.exit:			sta     cur_weekday
			rts

.tdbuff:		ds.b    30






begin:
top1:
			lda	#$20
			sta	header
top:
			lda	#$7d
			jsr	echo
			jsr	tammy-3

			jsr	printsi
			dc.b	$9b
			dc.b	<+128>,""
			dc.b	$9B
			dc.b	<+128>,"|     RealDos Database Creator     |"
			dc.b	$9B
			dc.b	<+128>,"|   (c)2010 by Stephen J. Carden   |"
			dc.b	$9B
			dc.b	<+128>,""
			dc.b	$9B,-1
			lda	#$00
			sta	my_count


header:
			jsr	cr_lf
			lda	#$60
			sta	header
wrongnum.10:
			jsr	blank
			jsr	cr_lf
			jsr	cr_lf
			jsr	printsi
			dc.b	<+128>,"[0]"
			dc.b	" to Exit",$9B
			dc.b	<+128>,"[1]"
			dc.b	" Make database "
			dc.b	$9b,$9b
			dc.b	" Enter Your Selection "
			dc.b	-1




			jsr	get_byte
			cmp	#0
			beq	restart
			cmp	#1+1
			bcc	gooddrivenum
			jsr	printsi
			dc.b	$9b,$9b,"Invalid selection",$FF
			jmp	wrongnum.10
;
restart:
			jmp	($a)
gooddrivenum:
wrongnum:
badbasenum:
goodbasenum:
			lda	#$01
			sta	num
			sta	count
;			jsr	top
			jsr	cr_lf


tohigh:
			jsr	cr_lf
goodmax:
			lda	#255
			sta	i_maxmsgs
;			jsr	top

			lda	#$7d
			jsr	echo
			jsr	tammy-3

			jsr	cr_lf
			jsr	printsi
			dc.b	"Message size:",$9B,$9B
			dc.b	<+128>,"[2]"
			dc.b	"  362 bytes",$9B
			dc.b	<+128>,"[3]"
			dc.b	"  618 bytes",$9B
			dc.b	<+128>,"[4]"
			dc.b	"  874 bytes",$9B
			dc.b	<+128>,"[5]"
			dc.b	" 1130 bytes",$9B
			dc.b	<+128>,"[6]"
			dc.b	" 1386 bytes",$9B
			dc.b	<+128>,"[7]"
			dc.b	" 1642 bytes",$9B
			dc.b	<+128>,"[8]"
			dc.b	" 1898 bytes",$9B
			dc.b	<+128>,"[9]"
			dc.b	" 2154 bytes",$9B,$FF
wrongsize:
			jsr	printsi
			dc.b	$9b,"Select ->",$FF
			jsr	get_byte
         		cmp	#10
         		bcs	sizewrong
			cmp	#2
			bcs	goodsize
sizewrong:
			jsr	printsi
			dc.b	$9b,"Invalid number....",$9B,$FF
			jmp	wrongsize
goodsize:
			sec
			sbc	#1
			sta	f.temp
			clc
			adc	#2
			sta	i_chunks
			jsr	top
			jsr	cr_lf
			jsr	cr_lf
			jsr	printsi
			dc.b	"Allow  "
			dc.b	<+128>,"ATASCII"
			dc.b	"  graphics(Y/N)? ",$FF
			jsr	y_or_n
			cmp	#'Y'
			bne	nographics
			lda	#$80
			jmp	storegr
nographics:
			lda	#$00
storegr:
			sta	i_graphics
			jsr	top
			jsr	cr_lf
			jsr	printsi
			dc.b	$9b,"Enter DataBase name: ",$FF
			jsr	get_str
			dc.w	in_str
			dc.b	20,0,0
			lda	# low in_str
			sta	s_ptr
			lda	# high in_str
			sta	s_ptr+1
			lda	# low i_name
			sta	d_ptr
			lda	# high i_name
			sta	d_ptr+1
			jsr	move_str

			lda	#$7d
			jsr	echo
			jsr	tammy-3

			jsr	cr_lf
			jsr	printsi
			dc.b	$9b
			dc.b	<+128>,""
			dc.b	$9B
			dc.b	<+128>,"|    RealDos Error DataBase Info   |"
			dc.b	$9B
			dc.b	<+128>,"|   (c)2010 by Stephen J. Carden   |"
			dc.b	$9B
			dc.b	<+128>,""
			dc.b	$9b,$9b
			dc.b	" DataBase name is :",-1
			mea	i_name,pr_ptr
			jsr	echos

			jsr	printsi
			dc.b	$9b
			dc.b	" DataBase size is           :",-1
			lda	i_chunks
			jsr 	pr_byte
			jsr	printsi
			dc.b	$9b
			dc.b	" Number of Slots in DataBase:",-1
			lda	i_maxmsgs
			jsr 	pr_byte

			jsr	printsi
			dc.b	$9b
			dc.b	" ATASCII Graphics Allowed  :",-1
			lda	i_graphics
			cmp	#$80
			beq	.aa
			jsr	printsi
			dc.b	"NO!",-1
			jmp	.bb
.aa:
			jsr	printsi
			dc.b	<+128>,"YES",-1


.bb:
			jsr	printsi
			dc.b	$9b
			dc.b	" Drive the base will be on :",-1
			lda	filename+1
			jsr 	echo





			jsr	printsi
			dc.b	$9b,$9b,$9b,"Is all correct?(Y/N) ",$FF
			jsr	y_or_n
			cmp	#'Y'
			beq	create
			jsr	top
			jmp	wrongnum.10
create:
			ldx	#disk_2
			jsr	close
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;          open  2,8,0,fn
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			ldx	#disk_2
			lda	#$03		
			sta	iccom,x
			lda	#$08
			sta	icaux1,x
			lda	#$00
			sta	icaux1+1,x
			lda	# low filename
			sta	icbal,x
			lda	# high filename
			sta	icbal+1,x
			jsr	cio


			cpy	#150
			beq	makedir
			cpy	#1
			bne	error
			jmp	cont.3
error:
			tya
			jsr	sys_error
			ldx	#disk_2
			jsr	close
			rts



makedir:
			lda	totalpath
			cmp	#$01
			beq	.onemore
			cmp	#$00
			bne	.do_dir
			jmp	create
.onemore:
			jsr	.next_dir
			lda	#$00
			sta	totalpath
			jmp	create
.do_dir:
			jsr	.next_dir
			jsr	next_path
			jmp	create

.next_dir:
			jsr	cr_lf
			jsr	cr_lf
			jsr	printsi
			dc.b	156,"Creating directory! ==>",$FF
			mea	path1,pr_ptr
			jsr	echosE
			jsr	printsi
			dc.b	"  ",-1

			ldx	#disk_2
			jsr	close
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;          xio  42,2,0,0,path1+1
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			ldx	#disk_2
			lda	#42
			sta	iccom,x
			lda	#$00
			sta	icaux1,x
			lda	#$00
			sta	icaux1+1,x
			lda	# low path1+1
			sta	icbal,x
			lda	# high path1+1
			sta	icbal+1,x
			jsr	cio

			ldx	#disk_2
			jsr	close

			jsr	printsi
			dc.b	"Done",$9B,$FF
			rts
;



cont.3:
			lda	f.temp
			sbc	#1
			asl
			tay
			lda	mbsize,y
			sta	f.temp
			sta	i_totbytes
			iny
			lda	mbsize,y
			sta	f.temp+1
			sta	i_totbytes+1
			sec
			lda	i_totbytes
			sbc	#$96
			sta	i_totbytes
			lda	i_totbytes+1
			sbc	#$01
			sta	i_totbytes+1
			lda	i_maxmsgs
			sta	char
			jsr	printsi
			dc.b	$9b,"Creating Base Header!",$FF

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;			 bput  2,i_buff,counter2
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			ldx	#disk_2
			lda	#$0b
			sta	iccom,x
			lda	# low i_buff
			sta	icbal,x
			lda	# high i_buff
			sta	icbal+1,x
			lda	counter2
			sta	icbll,x
			lda	counter2+1
			sta	icbll+1,x
			jsr	cio


;
			cpy #1
			bne	writerror
			jsr	blank
cont.20:
;----------------------------------------------------
			inc	my_count
			jsr	printsi
			dc.b	156,"Creating message #",-1
			lda	my_count
;----------------------------------<<< need to add it here >>>>
			ldy	my_count
			sta	i_msgnlo,y
			sta	i_msgptr,y
			sta	i_maxmsgs,y
			sty	i_inuse
			lda	#$01
			sta	i_flag,y


	 		lda	my_count

	 		jsr	pr_byte

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;          bput  2,i_buff,f.temp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			ldx	#disk_2
			lda	#$0b
			sta	iccom,x
			lda	# low m_buff
			sta	icbal,x
			lda	# high m_buff
			sta	icbal+1,x
			lda	f.temp
			sta	icbll,x
			lda	f.temp+1
			sta	icbll+1,x
			jsr	cio

			cpy	#1
			bne	writerror
			dec	char
			beq	done1
			jmp	cont.20
writerror:
			tya
			jsr	sys_error
			ldx	#disk_2
			jsr	close

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;			 xio  33,2,0,0,fn
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			ldx	#disk_2
			lda	#33	; xio 33
			sta	iccom,x
			lda	#$00
			sta	icaux1,x
			lda	#$00
			sta	icaux1+1,x
			lda	#low filename
			sta	icbal,x
			lda	#high filename
			sta	icbal+1,x
			jsr	cio
;
;
			ldx	#disk_2
			jsr	close
			rts
done1:
			ldx	#disk_2
			jsr	close
			jsr	printsi
			dc.b	"Done",$9B,$9B,$FF

			jmp	top1

;
blank:
			lda	# low i_buff
			sta	$cb
			lda	# high i_buff
			sta	$cc
			ldy	#0
			ldx	#0
clearloop:
			lda	#0
			sta	($cb),y
			iny
			bne	clearloop
			inx
			cpx	#$0a
			beq	allclear
			clc
			lda	$cb
			adc	#$ff
			sta	$cb
			lda	$cc
			adc	#0
			sta	$cc
			jmp	clearloop
allclear:
			rts
;




;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;Turn an interger to a string
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int2asc:
			lda	num
			sta	.enctemp
			lda	num+1
			sta	.enctemp+1
			ldy	#0
			sty	.encounter
.nextdigit2:
			ldx	#0
.subloop:
			lda	.enctemp
			sec
			sbc	.dectable,y
			sta	.enctemp
			lda	.enctemp+1
			iny
			sbc	.dectable,y
			bcc	.additback
			sta	.enctemp+1
			inx
			dey
			clc
			bcc	.subloop
.additback:
			dey
			lda	.enctemp
			adc	.dectable,y
			sta	.enctemp
			txa
			ora	#$30
			ldx	.encounter
			sta	char,x
			inc	.encounter
			iny
			iny
			cpy	#8
			bcc	.nextdigit2
			lda	.enctemp
			ora	#$30
			ldx	.encounter
			sta	char,x
			rts

.encounter:		dc.w	0
.enctemp:		dc.w	0
.dectable:
			dc.w	10000
			dc.w	1000
			dc.w	100
			dc.w	10
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;Chunk 256k chunks from one place to another
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chunk_copy:		Lda	# low i_buff
			sta	in_ptr
			lda	# high i_buff
			STA 	in_ptr+1
			lda	# low base_work
			sta	s_ptr
			LDA 	# high base_work
			STA 	s_ptr+1
			LDY 	#0
			LDX 	Tammy_c+1		; we are copying chuncks no need for small bytes 
.loop:			LDA 	(in_ptr),Y
			STA 	(s_ptr),Y
			INY
			BNE 	.loop
			INC 	in_ptr+1
			INC 	s_ptr+1
			DEX
			BNE 	.loop:
			rts

check_muxs:

.bypass:
			rts

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



;       Message base INDEX layout (125 messages max allowed - 1536 bytes)
;       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


i_buff:			ds.b	0			;read into here
i_name:			ds.b	21			;name of this message base
i_chunks:		ds.b	1			;number of chunks per message
i_totbytes:		ds.b	2			;max bytes allowed per message
i_maxmsgs:		dc.b	255			;max messages allocated for
i_inuse:		dc.b	255			;number of slots currently in use
i_posted:		dc.w	255			;total msgs posted here
i_graphics:		ds.b	1			;$80=allow /Graphics, 0=don't
i_msgptr:		ds.b	256			; 250 message pointers
i_flag:			ds.b	256			;locked/received
i_msgnlo:		ds.b	256			; messages numbers lo
i_msgnhi:		ds.b	256			;                  hi
i_tolo:			ds.b	256			;to user number lo
i_tohi:			ds.b	256			;               hi
i_fromlo:		ds.b	256			;from user number lo
i_fromhi:		ds.b	256			;                 hi
i_replylo:		ds.b	256			;message number this is a reply to lo
i_replyhi:		ds.b	256			;   hi
i_filler:		ds.b	21			;fill out to a chunk boundary


;       Message base DATA layout
;       ~~~~~~~~~~~~~~~~~~~~~~~~

m_buff:			ds.b	0               ;read into here
m_title:		dc.b	23,"RealDos Error Messages" ;26              ;title of this message
			dc.b	2
;m_title:		ds.b	26              ;title of this message
m_from:			dc.b	28,"Author              "         ;who it's from
;m_from:		ds.b	21              ;who it's from
m_to:			dc.b	28,"All                 ";who it's to
;m_to:			ds.b	21              ;who it's to
m_time:			ds.b	11              ;the time
m_date:			ds.b	14              ;the date
m_width:		dc.b	40              ;40 or 80 columns
m_edited:		ds.b	1               ;edited?
m_lines:		dc.b	1               ;# lines this message is
m_node:			ds.b	2               ;node this msg originated from
m_nodename:		ds.b	26              ;node's name
m_nodecity:		ds.b	26              ;node's city
m_nodelist:		ds.b	256             ;nodes that this msg has appeared on
m_data:			dc.b	12,"Error Number"

			ds.b	2187	;2200            ;the message text




base_work:		ds.b	0

win_end:		ds.b	0


