Best of H & T - listing 5  Cut and Paste ROM  by Brian Ross ( for E/M/C 2 (c) BAU August 1990 <: F 7 P 28,0,24,39,21 Z: dcode%=&6000 nosbyte=&FFF4 xoswrch=&FFEE osnewl=&FFE7 osasci=&FFE3 : vdust=&D0 oldes=&275 : mode=&355 tcx=&318 tcy=&319 csp=&F6 : ass check ! "Press a key to save 'cut'"  ( "SAVE cut 6000 "+~O%+" 8000 8000" " ,: 6 ass @ X%=4 6 2 J P%=&8000 T O%=code% ^ [OPT X% h .romstrt r EQUB 0 | EQUW 0 JMP service  EQUB &82 EQUB (copyr-romstrt)  EQUB 0  .message EQUS "Cut and Paste"  .copyr  EQUB 0 EQUS "(C)1988 Brian Ross"  EQUB 0 :  .service PHA  STA temp TXA PHA &TYA 0PHA : LDA temp D CMP #&15 N BEQ poll X CMP #&09 b BEQ help l CMP #&01 v BEQ init  .exit  .anrts PLA TAY PLA TAX PLA RTS :  .poll JMP (pollvector) :  .help LDA (&F2),Y  CMP #13 BNE helpout  JSR osnewl * LDY #0 4 .hloop >LDA message,Y HBEQ helpexit RJSR osasci \INY f BNE hloop p .helpexit zJSR osnewl  .helpout  JMP exit :  .init  LDA #22  LDX #1 JSR osbyte LDA #poll1 256 STA pollvector LDA #poll1 256 STA pollvector+1  LDA #0  STA cflag  JMP exit :  .poll1 $ LDA #129 . LDX #&FF 8 LDY #&FF BJSR osbyte LBCC return V LDA #129 ` LDX #&FE j LDY #&FF tJSR osbyte ~BCC return  LDA #129  LDX #&AC  LDY #&FF JSR osbyte BCS cutout  LDA #129  LDX #&AB  LDY #&FF JSR osbyte BCS pasteout  .return  JMP exit :  .pasteout JMP pasteout1 : ( .cutout 2 LDA cflag < BEQ cut F JMP exit P.cut ZLDA pollvector dSTA ststatus nLDA pollvector+1 xSTA ststatus+1 LDA #anrts 256 STA pollvector LDA #anrts 256 STA pollvector+1 JSR savexy JSR savewindows  LDA #26 JSR oswrch LDA #cbuff 256  STA csp LDA #cbuff 256  STA csp+1 JSR sc_size  LDY nxc DEY  STY maxx " LDY nyc ,DEY 6 STY maxy @ LDA #0 J STA minx T STA miny ^ STA xpos h STA ypos r LDA #"*" | STA prc JSR move_cur  LDA #31 JSR oswrch  LDA xpos  STA minx  STA ulx JSR oswrch  LDA ypos  STA miny  STA uly JSR oswrch  LDA #135 JSR osbyte  STX ulc  LDA #"#" JSR oswrch &JSR move_cur 0 LDA xpos : STA lrx D LDA ypos N STA lry X INC lrx b INC lry l LDA #31 vJSR oswrch  LDA ulx JSR oswrch  LDA uly JSR oswrch  LDA ulc JSR oswrch  LDA uly  STA cuty  .cutl1  LDA ulx  STA cutx  .cutl2  LDA #31 JSR oswrch  LDA cutx JSR oswrch  LDA cuty *JSR oswrch 4 LDA #135 >JSR osbyte H CPX #&80 RBCC notudc \ LDX #32 f .notudc pTXA zJSR cutstore  INC cutx  LDA cutx  CMP lrx  BNE cutl2  JSR cutel  INC cuty  LDA cuty  CMP lry  BNE cutl1  JSR cutet  LDA #1  STA cflag JSR getwindows  JSR getxy LDA ststatus STA pollvector $LDA ststatus+1 .STA pollvector+1 8 JMP exit B: L .cutstore V LDY #0 `STA (csp),Y j INC csp tBEQ csover ~RTS .csover INC csp+1 RTS : .cutel SEC LDA csp SBC #1 STA csp LDA csp+1 SBC #0 STA csp+1 TXA A #&80 JSR cutstore RTS ( .cutet 2 LDA #&FF <JSR cutstore FRTS P: Z .move_cur d LDA oldes nSTA oldess x LDA #1 STA oldes LDA #31 JSR oswrch LDA xpos JSR oswrch LDA ypos JSR oswrch LDA #135 JSR osbyte STX oldchar LDA prc JSR oswrch LDA xpos  STA oldx  LDA ypos  STA oldy " .mcloop , LDY #30 6 .rdkde1 @ LDX #0 J .readkde TNOP ^NOP hNOP rINX |BNE readkde DEY BNE rdkde1 LDA #15 LDA #1 JSR osbyte .readkl LDA #&7A JSR osbyte CPX #&FF BEQ readkl CPX #25 BEQ left CPX #121  BEQ right  CPX #41  BEQ down & CPX #57 0 BEQ up : CPX #73 D BEQ rrr NJMP mcloop X.rrr b JMP end l .left v LDA xpos CMP minx BEQ leover DEC xpos .leover JMP pr_char .right LDA xpos CMP maxx BEQ riover INC xpos .riover JMP pr_char .down  LDA ypos CMP maxy BEQ doover INC ypos * .doover 4JMP pr_char >.up H LDA ypos R CMP miny \BEQ upover f DEC ypos p .upover z .pr_char LDA #0 STA mpflag LDA oldx CMP xpos BEQ xsame LDA #0 STA mpflag JMP prov .xsame LDA #1 STA mpflag .checky LDA oldy  CMP ypos  BEQ ysame  LDA #0 $STA mpflag . JMP prov 8 .ysame B LDA #1 LSTA mpflag V .prov `LDA mpflag j BEQ prov2 tJMP mcloop ~ .prov2  LDA #31 JSR oswrch  LDA oldx JSR oswrch  LDA oldy JSR oswrch LDA oldchar JSR oswrch  LDA #31 JSR oswrch  LDA xpos JSR oswrch  LDA ypos  JSR oswrch  LDA #135 JSR osbyte (STX oldchar 2 LDA prc <JSR oswrch F LDA xpos P STA oldx Z LDA ypos d STA oldy nJMP mcloop x.end  LDA #31 JSR oswrch  LDA oldx JSR oswrch  LDA ypos JSR oswrch LDA oldchar JSR oswrch LDA oldess  STA oldes  LDY #128 .dl2  LDX #0  .dl2a NOP NOP "NOP ,INX 6 BNE dl2a @DEY J BNE dl2 TRTS ^: h .sc_size r LDA mode | #7 TAY LDA xtable,Y  STA nxc LDA ytable,Y  STA nyc RTS :  .xtable  EQUB 80  EQUB 40  EQUB 20  EQUB 80  EQUB 40  EQUB 20  EQUB 40  EQUB 40 &: 0 .ytable : EQUB 32 D EQUB 32 N EQUB 32 X EQUB 25 b EQUB 32 l EQUB 32 v EQUB 25  EQUB 25 : .nyc  EQUB 0 .nxc  EQUB 0 : .pasteout1  LDA cflag  CMP #1  BEQ paste JMP return  .paste LDA pollvector  STA ststatus LDA pollvector+1  STA ststatus+1 *LDA #vector 256 4STA pollvector >LDA #vector 256 HSTA pollvector+1 RLDA #cbuff 256 \ STA papo fLDA #cbuff 256 pSTA papo+1 zJMP return :  .vector  LDA #&80  LDY #&FF  LDX #&FF JSR osbyte  CPX #0 BNE endpas JSR getpaste TXA  CMP #&FF BEQ switchoff PHA  #&7F  JSR ikb PLA $BPL endpas . LDA #13 8 JSR ikb B .endpas L JMP exit V.switchoff `LDA ststatus jSTA pollvector tLDA ststatus+1 ~STA pollvector+1  LDA #0  STA cflag  LDA #&FF  STA cbuff JMP endpas  .getpaste  LDA papo  STA csp LDA papo+1  STA csp+1  LDY #0 LDA (csp),Y TAX  LDA papo CLC  ADC #1 ( STA papo 2LDA papo+1 < ADC #0 FSTA papo+1 PRTS Z.ikb d LDX #0 nTAY x LDA #&8A JMP osbyte :  .savexy  LDA tcx  STA tabx  LDA tcy  STA taby  LDA vdust  STA vduss  A #2  #&BF  STA vdust RTS  .getxy  LDA #31 JSR oswrch "SEC , LDA tabx 6 SBC &308 @JSR oswrch JSEC T LDA taby ^ SBC &30B hJSR oswrch r LDA tabx | STA tcx  LDA taby  STA tcy  LDA vduss  STA vdust RTS .savewindows  LDY #0  .swloop LDA &300,Y STA swstore,Y INY  CPY #&10 BNE swloop RTS : .getwindows & LDY #0 0 LDA #24 :JSR oswrch D .gwl1 NLDA swstore,Y XJSR oswrch bINY l CPY #8 v BNE gwl1  LDA #28 JSR oswrch  .gwl2 LDA swstore,Y JSR oswrch INY  CPY #&C  BNE gwl2  LDA #29 JSR oswrch  .gwl3 LDA swstore,Y JSR oswrch INY  CPY #&10  BNE gwl3  RTS *: 4 .swstore > EQUD 0 H EQUD 0 R EQUD 0 \ EQUD 0 f EQUD 0 p: z .cutx  EQUB 0  .cuty  EQUB 0 .ulx  EQUB 0 .uly  EQUB 0 .ulc  EQUB 0 .lrx  EQUB 0 .lry  EQUB 0  .ststatus  EQUW 0  .cflag $ EQUB 0 . .tabx 8 EQUB 0 B .taby L EQUB 0 V .vduss ` EQUB 0 j.pollvector t EQUW 0 ~ .xpos  EQUB 0  .ypos  EQUB 0  .oldx  EQUB 0  .oldy  EQUB 0  .maxx  EQUB 0  .minx  EQUB 0  .maxy  EQUB 0  .miny  EQUB 0 .prc ( EQUB 0 2 .oldchar < EQUB 0 F .mpflag P EQUB 0 Z .editsts d EQUB 0 n .oldess x EQUB 0  .papo  EQUW 0  .temp  EQUB 0  .cbuff ]   :  check T%=0  X%=code% O%  T%=T%+?X%  B T%<>&25DDB 7: "Checksum error - Please check listing":