Crazy Characters!  by Tim Campen  for B/B+/M/C (with SWR) ( (c) BAU July 1990 2: < 7 F =&6600 Posnewl=&FFE7 Zosbyte=&FFF4 doswrch=&FFEE nosword=&FFF1 xosasci=&FFE3 oscli=&FFF7 patch=&900 diff%=&2500 comline=&F2  pass=0 2 2 P%=&5B00 [OPT pass EQUB0 EQUB75 EQUB66 JMP serve+diff% EQUB&82 EQUB copyright 256  EQUB1  .title EQUS"Crazy Characters!" " EQUB0 ,.copyright 6 EQUB0 @EQUS"(C) BAU Tim Campen" J EQUB0 T .serve ^PHA hSTA temp+diff% rTXA |PHA TYA PHA  LDX#255  .inloop INX  LDA&70,X STA zero+diff%,X  CPX#10  BCS nobuf LDA patch,X STA buffer+diff%,X  .nobuf  CPX#31 BNE inloop LDA temp+diff%  CMP#9 & BEQ help 0 CMP#4 : BEQ unrec D .splat NJSR locate+diff% XPLA bTAY lPLA vTAX PLA RTS  .help JSR osnewl  LDX#&FF  .helploop INX LDA title2+diff%,X JSR osasci BNE helploop JSR osnewl  LDX#0  .hstart LDA (comline),Y  CMP#91 BCS adjust  CMP#13 * BNE miss 4 CPX#4 > BCC bye H .miss RCMP Htext+diff%,X \ BEQ su fLDA (comline),Y p CMP#13 zINY BNE hstart  CPX#5 BCS explain .bye JMP splat+diff%  .explain LDA#helpcode 256  STA&70 LDA#helpcode 256  STA&71  DEC&70  .disp  INC&70 LDA (&70),Y JSR osasci  LDA&70 $ CMP#255 . BEQ next 8LDA (&70),Y B BNE disp L .outhelp VJMP out+diff% ` .adjust jSEC t SBC#32 ~STA (comline),Y JMP hstart+diff%  .next  LDA#255  STA&70  INC&71 JMP disp+diff% .su INX JMP hstart+diff%  .unrec  LDA#0  STA&80  STA&72  LDX#1  .loop  LDA&72 ( CMP#3 2 BEQ char < .nochar F LDA&72 P CMP#5 Z BEQ large d .blarge nLDA table+diff%,X x .backhigh CMP (comline),Y  BEQ part LDA (comline),Y  CMP#91  BCS high  CMP#32 BEQ spacebar .not INX  LDA&80  CMP#1 BNE noback DEY  .noback  LDA#0  STA&80 " STA&72 , CPX#100 6 BNE loop @JMP splat+diff% J .high TSEC ^ SBC#32 hSTA (comline),Y rJMP backhigh+diff% | .spacebar INY JMP nochar+diff%  .part  LDA&80  BNE clear DEX LDA table+diff%,X  CMP#13  BNE fake  LDA#1  STA&80 INX  .clear LDA table+diff%,X  CMP#13 BEQ findjmp &INX 0INY : INC&72 DJMP loop+diff% N .fake XINX b LDA#0 l STA&80 vJMP not+diff%  .char LDA (comline),Y  CMP#"R" BEQ char22  CMP#"r" BEQ char22  CMP#"P"  BEQ flip  CMP#"p"  BEQ flip  CMP#"M"  BEQ norm  CMP#"m"  BEQ norm  JMPfile+diff%  .seeya  LDA#0 * STA&72 4JMP nochar+diff% > .large HJMPlarge2+diff% R .findjmp \ BEQ find f .norm pINY zLDA (comline),Y  CMP#33  BCS seeya CMP#32:BEQ norm  LDA #0  LDX #1 JSR osbyte TXA  LDX #0  CMP #3 BCS fxcode  LDX #6  .fxcode  LDA#20  LDY#0 JSR osbyte JMP out+diff% $ .char22 .INY 8LDA (comline),Y B STA charX LINY VLDA (comline),Y ` STA charY jJMP out+diff% t .flip ~INY LDA (comline),Y CMP#"X" BEQ flipX CMP#"x" BEQ flipX CMP#"Y" BEQ flipY CMP#"y" BEQ flipY JMP splat+diff% .flipX JSR flipXX+diff% JMP out+diff% .flipY JSR flipYY+diff% JMP out+diff% ( .find 2 STX&70 < CPX#7 F BEQ fat1 P CPX#12 Z BEQ thin1 d CPX#17 n BEQ anti1 x CPX#24 BEQ clock1 CPX#32 BEQ inverse1 .out JSR locate+diff% PLA TAY PLA TAX PLA LDA#0 RTS .fat1  LDA#1 JSR font2+diff% JMP out+diff% " .thin1 , LDA#0 6JSR font2+diff% @JMP out+diff% J .anti1 T LDA#0 ^ STA&74 hJMP go+diff% r .clock1 | LDA#1 STA&74 .go JSR rotation+diff% JMP out+diff% .inverse1 JSR inv+diff% JMP out+diff% .flipXX LDA charX STA&70 .loopX LDA&70 STA patch STA patch2 JSR definition+diff%  LDX#0 & LDY#9 0 .loopXX :INX DDEY NLDA patch,X XSTA patch2,Y bLDA patch,Y lSTA patch2,X v CPX#4 BNE loopXX JSR end+diff% LDA&70 CMP charY BEQ finX INC&70 JMP loopX+diff% .finX RTS .flipYY LDA charX STA&72 DEC&72  .flump INC&72  LDA&72 STA patch *STA patch2 4JSR definition+diff% > LDY#0 H .loopY R LDA#128 \ STA&73 fINY p LDA#0 z STA&71 LDA patch,Y STA space+diff% LDX#255 LDA#1 STA&80 .loopYY INX LDA&80 BIT space+diff% BNE add .outy CLC LSR&73  ASL&80  LDA&80 BNE loopYY $ LDA&71 .STA patch2,Y 8 CPY#8 B BNE loopY LJSR end+diff% V LDA&72 ` CMP charY j BNE flump tRTS ~.add CLC  LDA&71  ADC&73  STA&71 JMP outy+diff%  .table  EQUB0  EQUB0  EQUB0  EQUB13  EQUS"FAT"  EQUB13 EQUS"THIN"  EQUB13 EQUS"ANTI"  EQUB13 (EQUS"CLOCKW" 2 EQUB13 <EQUS"INVERSE" F EQUB13 PEQUS"NORM" Z EQUB13 dEQUS"CHAR" n EQUB13 xEQUS"FLIP"  EQUB13 EQUS"CPUT"  EQUB13 EQUS"CGET"  EQUB13 EQUS"LARGE"  EQUB13 EQUS"DEFIN"  EQUB13  .Htext EQUS"CRAZY"  .coded FEQUS" ANTI Rotate selected chars 90 degrees anticlockwise"  EQUB13 :EQUS" CGET Loads Crazy Characters! file"  EQUB13 "GEQUS" CHAR Informs characters from X to Y to be acted apon" , EQUB13 6BEQUS" CLOCKW Rotate selected chars 90 degrees clockwise" @ EQUB13 J2EQUS" CPUT Saves selected chars" T EQUB13 ^8EQUS" DEFIN Prints definition of character X" h EQUB13 r0EQUS" FAT Selected chars fattened!" | EQUB13 :EQUS" FLIPX Flip selected chars across x-plane"  EQUB13 :EQUS" FLIPY Flip selected chars across y-plane"  EQUB13 /EQUS" INVERSE Inverses selected chars"  EQUB13 ;EQUS" LARGE Message Y printed X characters high"  EQUB13 =EQUS" NORM Restores all chars to original states"  EQUB13 /EQUS" THIN Selected chars thinned!"  EQUB13  EQUB0  .title2  EQUS"Crazy Characters! 1.20"  EQUB13 &EQUS"by Tim Campen" 0 EQUB13 :EQUS" CRAZY" D EQUB0 N .temp X EQUB0 b .rotation l LDA charX v STA&72  DEC&72  .startA  INC&72  LDA&72  STA patch STA patch2 JSR definition+diff%  LDA#1  STA&80  LDX#0  LDA#9  STA&76  .loopA  LDA&74  BEQ an1  LDA#1  STA&73 *JMP nan1+diff% 4.an1 > LDA#128 H STA&73 R .nan1 \INX f DEC&76 p LDY#0 z LDA#0  STA&71  .loopAA INY LDA patch,Y STA space+diff%  LDA&80 BIT space+diff%  BNE addY  .outf  LDA&74  BEQ an2  ASL&73 JMP nan2+diff% .an2  LSR&73  .nan2 $ CPY#8 .BNE loopAA 8 LDA&74 B CMP#1 LBEQ cwsave V LDA&71 `STA patch2,X j .backcw t ASL&80 ~ LDA&80  BNE loopA JSR end+diff%  LDA&72  CMP charY BNE startA RTS  .addY CLC  LDA&73  ADC&71  STA&71 JMP outf+diff%  .cwsave  LDA&76 TAX  LDA&71 (STA patch2,X 2JMP backcw+diff% <.definition FLDX#patch 256 PLDY#patch 256 Z LDA#&A dJSR osword nRTS x.end  LDX#0  LDA#23 JSR oswrch LDA patch2 JSR oswrch  .loop2 LDA patch2+1,X JSR oswrch INX  CPX#8  BNE loop2 RTS .inv  LDA charX  STA &73  LDA charY " STA&74 , LDA&73 6 STA&72 @ DEC&72 J .inv_loop T INC&72 ^ LDA&72 h STA patch rSTA patch2 |JSR definition+diff%  LDX#255 .pop INX LDA patch+1,X  #&FF STA patch2+1,X  CPX#8  BNE pop JSR end+diff%  LDA&72  CMP&74 BNE inv_loop RTS  .font2  BNE fat  LDA#61 &STA convert+diff% 0JMP thin+diff% :.fat D LDA#&1D NSTA convert+diff% X .thin b LDA charX l STA&72 v DEC&72 .font_loop  INC&72  LDA&72  STA patch STA patch2 JSR definition+diff%  LDX#255  .pop2 INX LDA patch+1,X  LSR A  .convert  patch+1,X STA patch2+1,X  CPX#8  BNE pop2  JSR end+diff% * LDA&72 4 CMP charY >BNE font_loop HRTS R .locate \ LDX#255 f .outloop pINX zLDA zero+diff%,X  STA &70,X  CPX#10 BCS nobuf2 LDA buffer+diff%,X STA patch,X  .nobuf2  CPX#31 BNE outloop RTS  .file DEY LDA(comline),Y  CMP#"U"  BEQ save  CMP#"u"  BEQ save $ CMP#"E" . BEQ load 8 CMP#"e" B BEQ load LINY VJMPnochar+diff% ` .load jJMP load2+diff% t .save ~ LDX#0  .resetl  LDA#32 STAfilename+diff%,X INX  CPX#20 BNE resetl JSR findname+diff%  LDA charX  STA&80  LDA charY  STA&81  INC&81  LDA#0  STA&82  LDA#&27  STA&83 ( LDA&83 2#15 <STAareas+1 F LDA&83 PJSR lsrac+diff% Z STAareas d LDA&82 n#15 xSTAareas+3  LDA&82 JSR lsrac+diff% STAareas+2 JSR swapup+diff% JSR sendl+diff%  LDA&83 #15 STAareas+6  LDA&83 JSR lsrac+diff% STAareas+5  LDA&82 #15 STAareas+8  LDA&82 JSR lsrac+diff% "STAareas+7 , LDX#255 6.kal @INX JLDAareas+5,X TCLC ^ ADC#48 h CMP#58 r BCS hex | .bhex STAareas+5,X LDAareas,X CLC  ADC#48  CMP#58  BCS hex2  .bhex2 STAareas,X  CPX#3  BNE kal  LDA#13 STA areas+9  LDX#0  .savelo LDAsacode+diff%,X STA scode2,X &INX 0 CPX#4 : BNEsavelo DJSR filingup+diff% N LDX#&E0 X LDY#&26 b JSR oscli lJSR filingdown+diff% vJSR swapdown+diff% JMP out+diff%  .swaping JSRdefinition+diff%  LDY#255  .lswap INY LDApatch,Y STA(&82),Y  CPY#8  BNE lswap JMP bswaping+diff% .hex CLC  ADC#7  JMPbhex+diff%  .hex2  CLC * ADC#7 4JMPbhex2+diff% > .sendl H LDA&80 R STApatch \JMP swaping+diff% f .bswaping pCLC z LDA&82  ADC#9  BCS set80  .bset80  STA&82  INC&80  LDA&80  CMP&81  BNE sendl  LDX#0  LDY#0  .trans LDAheader+diff%,X STA(&82),Y INX INY  CPX#9 $ BNE trans .CLC 8 LDA&82 B ADC#8 LBCS sethead V .bsethead ` STA&82 jRTS t .set80 ~ INC&83 JMPbset80+diff%  .sethead  INC&83 JMPbsethead+diff%  .remember  LDY#0  .ramloop1 LDA(&72),Y STA(&70),Y  INC&70  INC&72  LDA&70  BEQ next1  .bnext1  LDA&72  BEQ next2 ( .bnext2 2 LDA&72 < .Azero F CMP#0 PBEQ endram ZJMP ramloop1+diff% d .next1 n INC&71 xJMP bnext1+diff%  .next2  INC&73 JMP bnext2+diff%  .endram2 RTS  .endram  LDA&73  .Bzero  CMP#&67 BEQ endram2 JMP ramloop1+diff%  .load2  LDX#0  .copyl LDAcopyi+diff%,X STAscode2,X "INX , CPX#21 6 BNE copyl @JSR findname+diff% JJSR swapup+diff% TJSR filingup+diff% ^ LDX#&E0 h LDY#&26 r JSR oscli |JSR filingdown+diff%  LDA#0  STA&70  LDA#&27  STA&71  LDY#0  .defhead LDA(&70),Y CMPheader+diff%  BEQ headK  .bheadK  LDX#0  .loopload LDA(&70),Y STApatch2,X INX INY & CPX#9 0BNE loopload :JSR end+diff% D LDY#0 NCLC X LDA&70 b ADC#9 l BCS pageb v .bpageb STA&70 JMP defhead+diff% .pageb INC&71 JMP bpageb+diff% .headK INX INY LDA(&70),Y CMPheader+diff%,X BNE notnowK JMP headK+diff% .notnowK ! CPX#9 ! BEQ enddefK ! LDX#0 ! LDY#0 !*JMP bheadK+diff% !4 .enddefK !>JSR swapdown+diff% !HJMP out+diff% !R .enlarge !\ LDA#240 !f STApatch !pTYA !zPHA !JSR definition+diff% ! LDX#1 !PLA !TAY ! .retain !LDApatch,X !STAstoring,X !INX ! CPX#9 !BNE retain !INY ! STY&78 ! .gilbert " LDY&78 "LDA(comline),Y " CMP#13 "$BEQ NoLarge ". STApatch "8 LDA#0 "B STA&70 "L LDA#255 "V STA&71 "` STA&74 "j STA&72 "tJSR definition+diff% "~.repeatloopK " INC&71 " INC&74 " LDA&74 " CMP#8 "BEQ resetK " .bresetK "JMP maths+diff% " .bmaths " CPX#7 "BNE repeatloopK "JMP defineK+diff% " .bdefineK # LDA&70 # CMP&73 #BNE repeatloopK # INC&78 #( LDX#0 #2 LDA#11 #<.upl #FJSR oswrch #PINX #Z CPX&73 #d BNE upl #n LDA#9 #xJSR oswrch #JMP gilbert+diff% # .NoLarge # LDX#0 # LDA#10 # .doloop #JSR oswrch #INX # CPX&73 #BNE doloop # LDA#13 #JSR oswrch #PLA #TAY $ LDX#1 $ LDA#240 $ STApatch2 $" .pull $,LDAstoring,X $6STApatch2,X $@INX $J CPX#9 $T BNE pull $^JSR end+diff% $hJMP out+diff% $r .resetK $| LDA#0 $ STA&74 $JMP bresetK+diff% $ .maths $ LDA#0 $ STA&77 $ LDX#0 $ .looplsr $CLC $ LDA&77 $ ADC&73 $ STA&77 $ CMP&71 $ BCS overK %INX %JMP looplsr+diff% % .overK %& STX&77 %0CLC %:LDApatch+1,X %D LDX&74 %NSTA patch2,X %XJMP bmaths+diff% %b .defineK %l INC&70 %v LDA#23 %JSR oswrch % LDA#240 %JSR oswrch % LDX#0 % .dloop %LDApatch2,X %JSR oswrch %INX % CPX#8 % BNE dloop % LDA#240 %JSR oswrch % LDA#10 &JSR oswrch & LDA#8 &JSR oswrch & JMP bdefineK+diff% &* .large2 &4TYA &>PHA &H LDY#5 &RLDA(comline),Y &\ CMP#"E" &fBEQ foundlar &p CMP#"e" &zBEQ foundlar & CMP#"N" &BEQ foundef & CMP#"n" &BEQ foundef &PLA &TAY &JMP blarge+diff% & .foundlar &INY &LDA(comline),Y & CMP#65 & BCS hexN &SEC ' SBC#48 ' STA&73 'JMP enlarge+diff% '$ .hexN '.SEC '8 SBC#55 'B STA&73 'LJMP enlarge+diff% 'V .foundef '`INY 'jLDA(comline),Y 't STApatch '~JSRdefinition+diff% ' LDX#1 ' .defKloop ' LDA#38 'JSR oswrch 'LDApatch,X 'PHA ' #&F0 'JSR lsrac+diff% 'CLC ' ADC#48 ' CMP#58 ' BCS Hset ( .bHset ( JSR oswrch (PLA (#&F ((CLC (2 ADC#48 (< CMP#58 (F BCS Hset2 (P .bHset2 (ZJSR oswrch (d CPX#8 (nBEQ endinfo (x LDA#"," (JSR oswrch (INX (JMPdefKloop+diff% ( .endinfo (PLA (TAY ( LDA#13 (JSR osasci (JMP out+diff% ( .Hset (CLC ( ADC#7 (JMP bHset+diff% ) .Hset2 )CLC ) ADC#7 )"JMP bHset2+diff% ), .swapup )6LDA#storing 256 )@ STA&70 )JLDA#storing 256 )T STA&71 )^ LDA#0 )h STA&72 )r LDA#&27 )| STA&73 ) LDA#0 )STA Azero+1+diff% ) LDA#&2F )STA Bzero+1+diff% )JSR remember+diff% )RTS ) .filingup ) LDX#0 ) .filoop1 )LDA&26E0,X )STA filepatch+diff%,X )LDAscode2,X )STA&26E0,X *INX * CPX#26 *BNE filoop1 *&RTS *0.filingdown *: LDX#0 *D .filoop2 *NLDA filepatch+diff%,X *XSTA&26E0,X *bINX *l CPX#26 *vBNE filoop2 *RTS * .swapdown *LDA#storing 256 * STA&72 *LDA#storing 256 * STA&73 * LDA#0 * STA&70 * LDA#&27 * STA&71 *LDA#storplus 256 *STA Azero+1+diff% *LDA#storplus 256 +STA Bzero+1+diff% + JSR remember+diff% +RTS + .findname +*INY +4 LDX#255 +> .nospa +HINX +RINY +\LDA(comline),Y +f CMP#13 +p BEQ cr13 +z CMP#32 +BEQ spaces +STA filename+diff%,X +JMP nospa+diff% + .spaces +DEX +JMPnospa+diff% + .cr13 +RTS + .lsrac +LSRA +LSRA +LSRA +LSRA ,RTS , .sacode ,EQUS"*SA." ,$ .copyi ,.EQUS"*LO." ,8EQUD&20202020 ,BEQUD&20202020 ,LEQUD&20202020 ,VEQUS"2700" ,` EQUB13 ,j .header ,tEQUS"(C)BAUTC" ,~ .buffer , EQUD0 , EQUD0 , EQUD0 , .zero , EQUD0 , EQUD0 , EQUD0 , EQUD0 , EQUD0 , EQUD0 , EQUD0 , EQUD0 - EQUD0 - .patch2 - EQUD0 - EQUD0 -( EQUW0 -2 .charX -<BRK -F .charY -PBRK -Z .space -dBRK -n .scode2 -xEQUD&20202020 - EQUB32 - .filename -EQUD&20202020 -EQUD&20202020 - EQUW&2020 - EQUB32 - .areas -EQUD&20202020 -EQUD&20202020 - EQUW&2020 - EQUB13 -.filepatch - EQUD0 . EQUD0 . EQUD0 . EQUD0 ." EQUD0 ., EQUD0 .6 EQUD0 .@ .storing .J] .Thelpcode=coded+diff% .^scode2=scode2+diff% .hareas=areas+diff% .rstoring=storing+diff% .|storplus=storing+&600 .patch2=patch2+diff% .charX=charX+diff% .charY=charY+diff% .; IF fxcode=0 THEN ?version=ASC"M" ELSE ?version=ASC"B" . . check . C%<>&4B5F7 error .)"Press to save 'CRAZYC'" . : =32 .%*SAVE"CRAZYC" 5B00 65E2 8000 8000 . .: . check /"Checking..." /C%=0 / N=&5B00 &65E0 /& C%=C%+?N /0 /: /D: /N error /X$"Checksum error...please check" /b