mirror of https://github.com/mist64/cbmsrc.git
Michael Steil
4 years ago
18 changed files with 5093 additions and 0 deletions
@ -0,0 +1,105 @@
|
||||
.subttl CUT and PASTE types of operations |
||||
; |
||||
; |
||||
; |
||||
;BUFLOAD: |
||||
; entry: buf_pos text buffer pointer to destination. |
||||
; abuf_start pointer to source in bank one. |
||||
; x,a = number of bytes to load from one. |
||||
; |
||||
; exit: error if insufficient room. |
||||
; information transfered from abuffer area into the |
||||
; text buffer. text buffer is left at the end of the inserted |
||||
; information. |
||||
; |
||||
; BUFSAVE: ( effect a cut type of operation ). |
||||
; entry: cut_start_pos text buffer pointer of start of text to "cut" |
||||
; cut_end_pos text buffer pointer to end of text to cut. |
||||
; |
||||
; abuf_start destination start address. |
||||
; ( may be "played with" for appends.. ) |
||||
; abuf_end max legal position to moditfy. |
||||
; |
||||
; exit: error returned in insufficient room for operation. |
||||
; information transferd from the text buffer in bank 0 |
||||
; to the buffer in bank one. |
||||
; x,a = number of bytes saved |
||||
; |
||||
buf_save |
||||
ldax cut_end_pos len <- number of bytes to cut |
||||
sbcx cut_start_pos |
||||
stax abuf_len |
||||
; |
||||
adcx abuf_start x,a <= calced end address |
||||
bcs 90$ |
||||
cmpx abuf_end if > end address |
||||
bcc 10$ |
||||
90$ lda #error_insufficient_memory |
||||
sec return unhappy |
||||
rts |
||||
|
||||
10$ stax abuf_end |
||||
ldax cut_start_pos move buffer to start of ara to "cut" |
||||
jsr buf_position |
||||
; |
||||
20$ ldax abuf_start while start <> end |
||||
cmpx abuf_end |
||||
beq 30$ do |
||||
; |
||||
jsr buf_remove remove byte from text buffer |
||||
ldy #0 stash it out |
||||
sta mmu_bank1 |
||||
sta (abuf_start),y |
||||
sta mmu_normal |
||||
incd abuf_start inc start address |
||||
jmp 20$ |
||||
; |
||||
30$ ldax abuf_len x,a <= number of bytes moved |
||||
clc return happy |
||||
rts |
||||
; |
||||
;BUFLOAD: |
||||
; entry: buf_pos text buffer pointer to destination. |
||||
; abuf_start pointer to source in bank one. |
||||
; x,a = number of bytes to load from one. |
||||
; |
||||
; exit: error if insufficient room. |
||||
; information transfered from abuffer area into the |
||||
; text buffer. text buffer is left at the end of the inserted |
||||
; information. |
||||
; |
||||
; |
||||
buf_load |
||||
stax abuf_len len <= number of bytes to load |
||||
adcx abuf_start end <= ending pointer |
||||
stax abuf_end |
||||
; |
||||
jsr buf_return_free x,a <= space to fit |
||||
cmpx abuf_len if x,a < lengtth of buffer |
||||
bcs 20$ |
||||
lda #error_insufficient_memory |
||||
sec return error |
||||
rts |
||||
; |
||||
20$ ldax abuf_start while start <> end |
||||
cmpx abuf_end |
||||
beq 30$ |
||||
; |
||||
ldy #0 do a <= char from bank one |
||||
sta mmu_bank1 |
||||
lda (abuf_start),y |
||||
sta mmu_normal |
||||
jsr buf_insert insert the char |
||||
bcs 90$ |
||||
incd abuf_start start <= start + 1 |
||||
jmp 20$ |
||||
; |
||||
; |
||||
30$ clc ;return happy |
||||
rts |
||||
; |
||||
90$ lda #99 return the unknown error |
||||
sec |
||||
rts |
||||
; |
||||
; |
@ -0,0 +1,29 @@
|
||||
version .macro |
||||
.byte "2.0" |
||||
.endm |
||||
|
||||
.blist |
||||
.include macro ; decalre macros |
||||
.include declare ; declare variables and memory map |
||||
*=code_start ; init pc |
||||
jmp init ; code |
||||
; |
||||
jsr $ff7d ; primm.... |
||||
.byte "(C)1986 COMMODORE ELECTRONICS, LTD.",$0d |
||||
.byte "ALL RIGHTS RESERVED",cr,00 |
||||
rts |
||||
; |
||||
.include kernal |
||||
.include buf |
||||
.include main |
||||
.include keyproc |
||||
.include keyops |
||||
.include plot |
||||
.include bufop |
||||
.include command |
||||
.include dos |
||||
.include help |
||||
.ifgt *-text_start |
||||
*** error *** code overflow |
||||
.endif |
||||
.end |
@ -0,0 +1,128 @@
|
||||
.subttl 16 bit macro definitions |
||||
; |
||||
ram .macro %a,%b |
||||
%a = curram |
||||
.ifb <%b> |
||||
curram = curram+1 |
||||
.else |
||||
curram = curram+%b |
||||
.endif |
||||
.endm |
||||
|
||||
zpage .macro %a,%b |
||||
%a = curzpage |
||||
.ifb <%b> |
||||
curzpage = curzpage+1 |
||||
.else |
||||
curzpage = curzpage+%b |
||||
.endif |
||||
.ifgt curzpage-$0090 |
||||
ERROR- too many zero page variables..... |
||||
.endif |
||||
.endm |
||||
; |
||||
; |
||||
; double precision macros |
||||
; |
||||
; |
||||
ldax .macro %a |
||||
lda %a ; x,a <= %a |
||||
ldx %a+1 |
||||
.endm |
||||
; |
||||
stax .macro %a |
||||
sta %a ; %a <= x,a |
||||
stx %a+1 |
||||
.endm |
||||
; |
||||
cmpx .macro %a |
||||
cpx %a+1 ; compare x,a with %a |
||||
.ifn >%a |
||||
bne *+5 |
||||
.else |
||||
bne *+4 |
||||
.endif |
||||
cmp %a |
||||
.endm |
||||
; |
||||
; |
||||
cmpi .macro %a |
||||
cpx #>%a ; compare x,a with #%a |
||||
bne *+4 |
||||
cmp #<%a |
||||
.endm |
||||
; |
||||
ldai .macro %a |
||||
lda #<%a ; x,a <= #%a |
||||
ldx #>%a |
||||
.endm |
||||
; |
||||
; |
||||
incd .macro %a |
||||
inc %a ; inc double precision %a |
||||
.ifn >%a |
||||
bne *+5 |
||||
.else |
||||
bne *+4 |
||||
.endif |
||||
inc %a+1 |
||||
.endm |
||||
; |
||||
decd .macro %a |
||||
pha ; dec double precision %a |
||||
lda %a |
||||
.ifn >%a |
||||
bne *+5 |
||||
.else |
||||
bne *+4 |
||||
.endif |
||||
dec %a+1 |
||||
dec %a |
||||
pla |
||||
.endm |
||||
; |
||||
adcx .macro %a |
||||
cld ; add %a to x,a |
||||
clc ; ( carry is only good condition code ) |
||||
adc %a |
||||
pha |
||||
txa |
||||
adc %a+1 |
||||
tax |
||||
pla |
||||
.endm |
||||
; |
||||
sbcx .macro %a |
||||
cld ; sub %a from x,a |
||||
sec ; ( carry is only good condition code ) |
||||
sbc %a |
||||
pha |
||||
txa |
||||
sbc %a+1 |
||||
tax |
||||
pla |
||||
.endm |
||||
; |
||||
cmpdr .macro %a,%b,%r ; double compare %a to %b using .%r |
||||
ld%r %a+1 |
||||
cp%r %b+1 |
||||
.ifn >%a |
||||
.ifn >%b |
||||
bne *+2+3+3 |
||||
.else |
||||
bne *+2+3+2 |
||||
.endif |
||||
.else |
||||
.ifn >%b |
||||
bne *+2+2+3 |
||||
.else |
||||
bne *+2+2+2 |
||||
.endif |
||||
.endif |
||||
ld%r %a |
||||
cp%r %b |
||||
.endm |
||||
; |
||||
cpa .macro %a |
||||
cmp %a |
||||
.endm |
@ -0,0 +1,54 @@
|
||||
; |
||||
print jsr clrchn |
||||
jsr parse ; parse the filename ( we'll ignore the name ) |
||||
bcs 90$ |
||||
|
||||
lda #0 ; set up kernal for no name |
||||
jsr setnam |
||||
lda #printer_lfn set up lfs etc. using users device |
||||
ldy #0 |
||||
ldx list_device ; ( puke if device is not 4 or 5 ) |
||||
cpx #4 |
||||
beq 10$ |
||||
cpx #5 |
||||
beq 10$ |
||||
lda #error_numeric_value_illegal |
||||
sec |
||||
rts |
||||
; |
||||
10$ jsr setlfs |
||||
; |
||||
jsr open ; attempt the open |
||||
bcc 90$ ; puke if error |
||||
; |
||||
ldx #print_lfn ; attach the printer.. |
||||
jsr ckout |
||||
bcc 90$ |
||||
; |
||||
; save current buffer position |
||||
; ; point to start of buffer |
||||
jsr start of file |
||||
|
||||
; |
||||
20$ jsr forward while can get a byte |
||||
bcs 80$ |
||||
jsr bsout do print the byte |
||||
jsr stop if stop key |
||||
bne 20$ |
||||
jsr 80$ close the file |
||||
lda #error_stop return stop key error |
||||
sec |
||||
rts |
||||
; |
||||
80$ jsr clrchn |
||||
ldx #print_lfn ; close the file |
||||
jsr close |
||||
jsr clrchn |
||||
clc ; return happy |
||||
rts |
||||
; |
||||
90$ jsr 80$ ; close the file |
||||
lda #error_device_not_present |
||||
sec ; return error |
||||
rts |
||||
; |
@ -0,0 +1,97 @@
|
||||
.subttl validate routine |
||||
; |
||||
; |
||||
; validate: |
||||
; the purpose of this routines is too attempt to keep the |
||||
; cursor within the middle lines of the screen. |
||||
; I.E. moveing up and down operations result in the |
||||
; cursor being placed on the top or bottom lines of the screen. |
||||
; this function detects when the cursor is near the edge of |
||||
; a window, and examines the text buffer to see if a more |
||||
; optimal location can be selected. |
||||
; |
||||
; |
||||
; validate works a follows: |
||||
; copy cursor line to temp location. |
||||
; modify temp location based on various rules for cursor placement |
||||
; compare temp tto cursor line |
||||
; if different |
||||
; cursor lione <= temp |
||||
; force new_screen |
||||
; |
||||
ram val_temp,1 |
||||
; |
||||
validate |
||||
lda cur_line a <= cur_line |
||||
bpl 10$ if .a < 0 |
||||
lda #0 .a <= 0 |
||||
; |
||||
10$ sta val_temp val_temp <= .a |
||||
; |
||||
sec .a <= max desired line |
||||
lda nlines |
||||
sbc hyster_lines |
||||
; |
||||
cmp val_temp if .a < val_temp |
||||
bcs 20$ |
||||
; |
||||
ldax cr_count_post .a <= mim(hyster_lines,cr_count_post) |
||||
jsr 100$ |
||||
; |
||||
eor #$ff .a <= nlines - .a |
||||
sec |
||||
adc nlines |
||||
; |
||||
cmp val_temp if .a < val_temp |
||||
bcs 20$ |
||||
sta val_temp val_temp <= .a |
||||
; |
||||
20$ lda val_temp if val_temp < hyster_lines |
||||
cmp hyster_lines |
||||
bcs 50$ |
||||
ldax cr_count_pre .a <= min(hyster_lines,cr_count_pre) |
||||
jsr 100$ |
||||
cmp val_temp if .a > val_temp |
||||
bcc 50$ |
||||
beq 50$ |
||||
; |
||||
sta val_temp val_temp <= .a |
||||
; |
||||
50$ lda cr_count_post+1 |
||||
; if < 255 lines after cursor |
||||
bne 70$ |
||||
sec |
||||
lda nlines a <= nlines - number of crs behind us |
||||
sbc cr_count_post |
||||
bcc 70$ if .a > 0 |
||||
; |
||||
cmp val_temp if .a > val_temp |
||||
bcc 70$ |
||||
beq 70$ |
||||
sta val_temp select a new cursor line |
||||
; |
||||
; if cr_count_pre < val_temp |
||||
70$ ldx cr_count_pre+1 |
||||
bne 80$ |
||||
lda cr_count_pre |
||||
cmp val_temp |
||||
bcs 80$ |
||||
sta val_temp val_temp <= cr_count_pre |
||||
; |
||||
80$ lda val_temp if val_temp <> cur_line |
||||
cmp cur_line |
||||
beq 88$ |
||||
sta cur_line cur_line <= val_temp |
||||
inc new_screen force a new_screen |
||||
88$ clc return happy |
||||
rts |
||||
; |
||||
; |
||||
100$ cpx #0 .a <= min( hyster_lines, (x,a) ) |
||||
bne 110$ |
||||
cmp hyster_lines |
||||
bcc 120$ |
||||
110$ lda hyster_lines |
||||
120$ rts |
||||
; |
||||
|
Loading…
Reference in new issue