1000 ;
1010 ; KOALA-SWAPPER
1020 ;
1030 ; V1.70 / 6.'86
1040 ;
1050 ;
1060 ORG 2049
1070 ;
1080 ;
1090 CHKIN EQU $FFC6
1100 CLRCH EQU $FFCC
1110 OUTCHR EQU $FFD2
1120 BASIN EQU $FFCF
1130 GET EQU $F142 ; NUR TAST.
1140 ;
1150 ST EQU 144
1160 XCNTR EQU 100
1170 YCNTR EQU 101
1180 BYTE EQU 102
1190 TMP1 EQU 252
1200 TMP2 EQU 254
1210 ;
1220 FILENAME EQU 49152
1230 ;
1240 BA EQU 8192 ; START
1250 BE EQU BA+10001 ; ENDE+1
1260 C1 EQU BA+8000
1270 C2 EQU BA+9000
1280 C0 EQU BA+10000
1290 C1A EQU 1024
1300 C2A EQU 55296
1310 ;
1320 ;
1330 ;
1340 DFB 15,8,250,255,158,"",0,0,0,0
1350 ANFANG LDX #0
1360 STX 157
1370 STX 53280
1380 STX 53281
1390 TEXT1LOOP LDA TEXT1,X
1400 BEQ LOADER
1410 JSR OUTCHR
1420 INX
1430 BNE TEXT1LOOP
1440 ;
1450 LOADER JSR INPUT
1460 ;
1470 LOADIT JSR INIT
1480 LDA #1
1490 LDX #8
1500 LDY #0 ; RELATIV
1510 JSR 65466
1520 LDA #15
1530 LDX #<FILENAME
1540 LDY #>FILENAME
1550 JSR 65469
1560 LDA #0
1570 LDX #<BA
1580 LDY #>BA
1590 JSR 65493
1600 BCS LOADER
1610 ;
1620 LDX #0
1630 TEXT2LOOP LDA TEXT2,X
1640 BEQ MAINLOOP
1650 JSR OUTCHR
1660 INX
1670 BNE TEXT2LOOP
1680 ;
1690 MAINLOOP JSR GET
1700 CMP #32
1710 BNE MAINLOOP
1720 ;
1730 WHATNOW JSR SHOWPIC
1740 WHATNOW1 JSR GET
1750 CMP #133 ; F1
1760 BNE WHATNOW2
1770 JSR SWAP
1780 JMP WHATNOW
1790 ;
1800 WHATNOW2 CMP #88 ; ""
1810 BNE WHATNOW3
1820 JSR NORM
1830 JMP ANFANG
1840 ;
1850 WHATNOW3 CMP #83 ; ""
1860 BNE WHATNOW1
1870 ;
1880 JSR NORM
1890 SAVE JSR INPUT
1900 ;
1910 JSR INIT
1920 LDA #1
1930 LDX #8
1940 LDY #1
1950 JSR $FFBA
1960 LDA #15
1970 LDX #<FILENAME
1980 LDY #>FILENAME
1990 JSR $FFBD
2000 LDA #<BA
2010 STA TMP1
2020 LDA #>BA
2030 STA TMP1+1
2040 LDA #TMP1
2050 LDX #<BE
2060 LDY #>BE
2070 JSR 65496
2080 BRK
2090 ;
2100 ;
2110 SHOWPIC LDA #<C1
2120 STA TMP1
2130 LDA #>C1
2140 STA TMP1+1
2150 LDA #<C1A
2160 STA TMP2
2170 LDA #>C1A
2180 STA TMP2+1
2190 ;
2200 JSR MOVE
2210 ;
2220 LDA #<C2
2230 STA TMP1
2240 LDA #>C2
2250 STA TMP1+1
2260 LDA #<C2A
2270 STA TMP2
2280 LDA #>C2A
2290 STA TMP2+1
2300 ;
2310 JSR MOVE
2320 ;
2330 LDA #59
2340 STA 53265
2350 LDA #24
2360 STA 53272
2370 LDA #216
2380 STA 53270
2390 LDA #0
2400 STA 53280
2410 LDA C0
2420 STA 53281
2430 RTS
2440 ;
2450 MOVE LDX #4
2460 LDY #0
2470 MOVE1 LDA (TMP1),Y
2480 STA (TMP2),Y
2490 INY
2500 BNE MOVE1
2510 INC TMP1+1
2520 INC TMP2+1
2530 DEX
2540 BNE MOVE1
2550 RTS
2560 ;
2570 NORM LDA #27
2580 STA 53265
2590 LDA #21
2600 STA 53272
2610 LDA #200
2620 STA 53270
2630 LDA #147
2640 JMP OUTCHR
2650 ;
2660 ;
2670 SWAP LDA #<C1
2680 LDX #>C1
2690 JSR SWAPCOL
2700 ;
2710 LDA #<C2
2720 LDX #>C2
2730 JSR SWAPCOL
2740 ;
2750 LDA #<BA
2760 LDX #>BA
2770 STA TMP1
2780 STX TMP1+1
2790 CLC
2800 ADC #56
2810 STA TMP2
2820 INX
2830 STX TMP2+1
2840 ;
2850 LDA #25
2860 STA YCNTR
2870 SWAP1 LDA #20
2880 STA XCNTR
2890 ;
2900 SWAP2 LDY #7
2910 SWAP3 LDA (TMP1),Y
2920 TAX
2930 LDA (TMP2),Y
2940 JSR SWAPBYTE
2950 STA (TMP1),Y
2960 TXA
2970 JSR SWAPBYTE
2980 STA (TMP2),Y
2990 DEY
3000 BPL SWAP3
3010 ;
3020 LDA #8
3030 JSR ADDTMP1
3040 LDA TMP2
3050 SEC
3060 SBC #8
3070 STA TMP2
3080 LDA TMP2+1
3090 SBC #0
3100 STA TMP2+1
3110 ;
3120 DEC XCNTR
3130 BNE SWAP2
3140 ;
3150 LDA #160
3160 JSR ADDTMP1
3170 LDA #240
3180 JSR ADDTMP2
3190 LDA #240
3200 JSR ADDTMP2
3210 ;
3220 DEC YCNTR
3230 BEQ SWAP4
3240 JMP SWAP1
3250 ;
3260 SWAP4 RTS
3270 ;
3280 ;
3290 SWAPCOL STA TMP1
3300 STX TMP1+1
3310 CLC
3320 ADC #39
3330 STA TMP2
3340 TXA
3350 ADC #0
3360 STA TMP2+1
3370 ;
3380 LDA #25
3390 STA YCNTR
3400 ;
3410 LDY #0
3420 SWAPCOL1 LDA #20
3430 STA XCNTR
3440 ;
3450 SWAPCOL2 LDA (TMP1),Y
3460 TAX
3470 LDA (TMP2),Y
3480 STA (TMP1),Y
3490 TXA
3500 STA (TMP2),Y
3510 ;
3520 LDA #1
3530 JSR ADDTMP1
3540 LDA TMP2
3550 SEC
3560 SBC #1
3570 STA TMP2
3580 LDA TMP2+1
3590 SBC #0
3600 STA TMP2+1
3610 ;
3620 DEC XCNTR
3630 BNE SWAPCOL2
3640 ;
3650 LDA #20
3660 JSR ADDTMP1
3670 LDA #60
3680 JSR ADDTMP2
3690 ;
3700 DEC YCNTR
3710 BEQ SWAPCOL3
3720 JMP SWAPCOL1
3730 ;
3740 SWAPCOL3 RTS
3750 ;
3760 ;
3770 SWAPBYTE PHA
3780 ROL
3790 ROL
3800 ROL
3810 AND #%00000011
3820 STA BYTE
3830 PLA
3840 PHA
3850 ROR
3860 ROR
3870 AND #%00001100
3880 ORA BYTE
3890 STA BYTE
3900 PLA
3910 PHA
3920 ROL
3930 ROL
3940 AND #%00110000
3950 ORA BYTE
3960 STA BYTE
3970 PLA
3980 ROR
3990 ROR
4000 ROR
4010 AND #%11000000
4020 ORA BYTE
4030 RTS
4040 ;
4050 ;
4060 ADDTMP1 CLC
4070 ADC TMP1
4080 STA TMP1
4090 LDA TMP1+1
4100 ADC #0
4110 STA TMP1+1
4120 RTS
4130 ;
4140 ADDTMP2 CLC
4150 ADC TMP2
4160 STA TMP2
4170 LDA TMP2+1
4180 ADC #0
4190 STA TMP2+1
4200 RTS
4210 ;
4220 ;
4230 ;
4240 INPUT LDX #0
4250 ILOOP1 LDA ITEXT,X
4260 BEQ INPUT1
4270 JSR OUTCHR
4280 INX
4290 BNE ILOOP1
4300 ;
4310 INPUT1 LDA #129 ; ""
4320 STA FILENAME
4330 LDX #14
4340 LDA #32
4350 ILOOP2 STA FILENAME,X
4360 DEX
4370 BNE ILOOP2
4380 ;
4390 INX
4400 ILOOP3 JSR BASIN
4410 CMP #13
4420 BEQ INPUTAUS
4430 CMP #36 ; ""
4440 BEQ DIR
4450 ;
4460 STA FILENAME,X
4470 INX
4480 BNE ILOOP3
4490 INPUTAUS RTS
4500 ;
4510 DIR JSR INIT
4520 LDA #1
4530 LDX #8
4540 LDY #0
4550 JSR 65466
4560 LDA #1
4570 LDX #<DTEXT
4580 LDY #>DTEXT
4590 JSR 65469
4600 JSR 65472
4610 ;
4620 LDA #147
4630 JSR OUTCHR
4640 LDX #1
4650 JSR CHKIN
4660 JSR BASIN
4670 JSR BASIN
4680 DIR1 JSR BASIN
4690 JSR BASIN
4700 BEQ DIREND
4710 JSR BASIN
4720 STA TMP1
4730 JSR BASIN
4740 LDX TMP1
4750 JSR $BDCD ; NUMOUT
4760 LDA #32
4770 JSR OUTCHR
4780 DIR2 JSR GET
4790 BEQ DIR3
4800 CMP #3
4810 BEQ DIREND
4820 DIRWAIT JSR GET
4830 BEQ DIRWAIT
4840 CMP #3
4850 BEQ DIREND
4860 DIR3 JSR BASIN
4870 JSR OUTCHR
4880 BNE DIR2
4890 LDA #13
4900 JSR OUTCHR
4910 JMP DIR1
4920 ;
4930 DIREND JSR CLRCH
4940 LDA #1
4950 JSR 65475 ; CLOSE
4960 JMP INPUT
4970 ;
4980 INIT LDA #1
4990 LDX #8
5000 LDY #15
5010 JSR 65466
5020 LDA #1
5030 LDX #<INITEXT
5040 LDY #>INITEXT
5050 JSR 65469
5060 JSR 65472
5070 LDA #1
5080 JMP 65475
5090 ;
5100 ;
5110 TEXT1 DFB "",13
5120 DFB "",13
5130 DFB "",13
5140 DFB "",13
5150 DFB "",13,0
5160 ITEXT DFB 13,"",0
5170 TEXT2 DFB 13,"",13
5180 DFB "",13
5190 DFB "",13
5200 DFB "",0
5210 DTEXT DFB ""
5220 INITEXT DFB ""
READY.