www.MethowValley.org-2023

Tristan Glib's Posts
User avatar
tristanbgilb
Posts: 980
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

This is the link to the BEST ZX81 Emulator EVER!!!

http://zx81.vb81.free.fr/

This is the ZX-COMPILER program I wrote pasted on top the ZX- COMPILER program making a circle in machine code with only adding, multiplying, dividing, and subtracting. No square root makes it sort of difficult.

Code: Select all

    10 REM LETH=34
    20 REM LETK=22
    30 REM PLOTH,K
    40 REM LETR=20
    50 REM LETT=R
    60 REM LETU=R
    70 REM LETL=0
    80 REM LETL=L+1
    90 REM IFL=RGOTO150
   100 REM LETE=K+L
   110 REM LETF=K-L
   120 REM PLOTH,E
   130 REM PLOTH,F
   140 REM GOTO80
   150 REM LETL=0
   160 REM LETL=L+1
   170 REM IFL=RGOTO230
   180 REM LETE=H+L
   190 REM LETF=H-L
   200 REM PLOTE,K
   210 REM PLOTF,K
   220 REM GOTO160
   230 REM LETT=R
   240 REM LETX=T
   250 REM LETY=0
   260 REM LETY=Y+1
   270 REM IFY=RGOTO420
   280 REM LETG=R*R
   290 REM LETJ=Y*Y
   300 REM LETW=G-J
   310 REM LETT=X
   320 REM LETX=W/T
   330 REM LETA=X+H
   340 REM LETB=H-X
   350 REM LETC=Y+K
   360 REM LETD=K-Y
   370 REM PLOTA,C
   380 REM PLOTB,C
   390 REM PLOTA,D
   400 REM PLOTB,D
   410 REM GOTO260
   420 REM LETY=R
   430 REM LETX=0
   440 REM LETX=X+1
   450 REM IFX=RGOTO600
   460 REM LETM=R*R
   470 REM LETN=X*X
   480 REM LETQ=M-N
   490 REM LETU=Y
   500 REM LETY=Q/U
   510 REM LETA=X+H
   520 REM LETB=H-X
   530 REM LETC=K-Y
   540 REM LETD=Y+K
   550 REM PLOTB,C
   560 REM PLOTA,C
   570 REM PLOTB,D
   580 REM PLOTA,D
   590 REM GOTO440
   600 REM RETURN

# REM **COMPILER**
  1000  REM [HEX:\
17,17,28,34,32,35,2E,31,\
2A,37,17,17,76 ]

  1010 FAST 
  1011 LET Q=3950
  1012 LET Q1=2830
  1013 LET Q2=3320
  1014 LET Q3=3630
  1015 LET Q4=3970
  1016 LET Q5=1320
  1017 LET Q6=4
  1020 LET P=28858
  1030 LET P1=16514
  1040 GOSUB 2920
  1050 IF PEEK (P1-1)<>234 THEN GOTO Q1
  1060 IF PEEK P1=118 THEN GOTO Q1
  1070 GOSUB 2880
  1080 LET A$=""
  1090 LET A$=A$+CHR$ PEEK P1
  1100 LET P1=P1+1
  1110 IF PEEK (P1-1)<>118 THEN GOTO 1090
  1120 IF PEEK (P1+1)*256+PEEK (P1+2)=1010 THEN GOTO 3690
  1130 LET P1=P1-3
  1140 LET T$=A$( TO 2)
  1150 LET B$=A$+"      "
  1160 LET J=0
  1170 LET J=J+(T$="RE")*2170+(T$="SC")*1200+(T$="PR")*1360+(T$="GE")*1530+(T$="EN")*1620+(T$="PA")*1670+(T$="CL")*1720+(T$="MO")*1770+(T$="LE")*1890+(A$( TO 3)="GOT")*2060+(A$( TO 3)="GOS")*2130+(T$="IF")*2200+(T$="PO")*2430+(T$="UN")*2550+(T$="PL")*2580+(T$="DO")*2720
  1180 IF NOT J THEN LET J=Q1
  1190 GOTO J
  1201 IF B$(7)<>CHR$ 118 THEN GOTO Q1
  1202 LET U$="2A0C40112100EB1901F702EDB00620AF131210FC"
  1203 GOSUB Q3
  1204 GOTO Q5
  1320 LET P1=P1+8
  1330 GOTO 1050
  1360 LET B$=B$(6 TO )
  1370 IF B$(1)=CHR$ 11 THEN GOTO 1420
  1380 GOSUB Q2
  1390 LET U$="7DD7"
  1400 GOSUB Q3
  1410 GOTO Q5
  1420 GOSUB Q
  1430 LET U$="CDBA40"
  1440 GOSUB Q3
  1450 POKE P,CODE (B$(1))
  1460 GOSUB Q
  1470 IF B$(1)=CHR$ 11 THEN POKE P+1,255
  1480 LET P=P+1
  1490 IF B$(1)=CHR$ 11 THEN GOTO 1510
  1500 GOTO 1450
  1510 LET P=P+1
  1520 GOTO Q5
  1530 LET B$=B$(Q6 TO )
  1540 LET U$="CDBB02444D51142808CDBD077ECB7728023E8021004077233600"
  1550 GOSUB Q3
  1560 LET V=CODE B$(1)
  1570 IF CODE B$(2)<>118 THEN GOTO Q1
  1580 IF V<38 OR V>63 THEN GOTO Q1
  1590 LET V=(V-38)*2+130
  1600 POKE P-6,V
  1610 GOTO Q5
  1620 LET B$=B$(Q6 TO )
  1630 IF B$(1)<>CHR$ 118 THEN GOTO Q1
  1640 LET U$="CFFF"
  1650 GOSUB Q3
  1660 GOTO Q5
  1670 LET B$=B$(6 TO )
  1680 GOSUB Q2
  1690 LET U$="2B7CB520FB"
  1700 GOSUB Q3
  1710 GOTO Q5
  1720 LET B$=B$(Q6 TO )
  1730 IF B$(1)<>CHR$ 118 THEN GOTO Q1
  1740 LET U$="2A0C40161823062036002310FB1520F5010000CDF508"
  1750 GOSUB Q3
  1760 GOTO Q5
  1770 LET B$=B$(5 TO )
  1780 GOSUB Q2
  1790 GOSUB Q4
  1830 LET U$="45"
  1840 GOSUB Q3
  1850 GOSUB Q2
  1860 LET U$="4DCDF508"
  1870 GOSUB Q3
  1880 GOTO Q5
  1890 LET B$=B$(Q6 TO )
  1900 LET L=(CODE B$-38)*2+130
  1910 LET B$=B$(3 TO )
  1920 GOSUB Q2
  1930 GOSUB 3570
  1940 IF CODE B$=118 THEN GOTO 2020
  1950 LET U$="EB"
  1960 GOSUB Q3
  1970 LET S$=B$(1)
  1980 GOSUB Q
  1990 GOSUB Q2
  1991 LET N$="CD0913"
  1992 IF PEEK 4869=197 THEN LET N$="CD0513"
  2000 LET U$=(N$ AND S$="*")+("EBCDC440" AND S$="/")+("19" AND S$="+")+("EBA7ED52" AND S$="-")
  2010 GOSUB Q3
  2020 LET U$="220040"
  2030 GOSUB Q3
  2040 POKE P-2,L
  2050 GOTO Q5
  2060 LET B$=B$(5 TO )
  2070 GOSUB Q2
  2080 POKE P-3,195
  2090 LET G(N1,1)=PEEK (P-2)+PEEK (P-1)*256
  2100 LET G(N1,2)=P-2
  2110 LET N1=N1+1
  2120 GOTO Q5
  2130 LET B$=B$(6 TO )
  2140 GOSUB Q2
  2150 POKE P-3,205
  2160 GOTO 2090
  2170 LET U$="C9"
  2180 GOSUB Q3
  2190 GOTO Q5
  2200 LET B$=B$(3 TO )
  2210 GOSUB Q2
  2220 GOSUB 3570
  2230 LET U$="EB"
  2240 GOSUB Q3
  2250 LET S$=B$(1)
  2260 GOSUB Q
  2270 GOSUB Q2
  2280 IF CODE B$>37 THEN GOSUB Q
  2290 IF CODE B$<38 THEN GOSUB 3600
  2300 LET U$="A7ED52"
  2310 IF S$="<>" THEN LET U$=U$+"CA"
  2320 IF S$="=" THEN LET U$=U$+"C2"
  2330 IF S$="<" THEN LET U$=U$+"DA"
  2340 IF S$=">" THEN LET U$=U$+"D2"
  2350 LET U$=U$+"0000"
  2360 IF S$<>">" AND S$<>"=" AND S$<>"<" AND S$<>"<>" THEN GOTO Q1
  2370 GOSUB Q3
  2380 LET G(N1,2)=P-2
  2390 LET G(N1,1)=1000
  2400 LET N1=N1+1
  2410 LET A$=B$
  2420 GOTO 1140
  2430 LET B$=B$(5 TO )
  2440 GOSUB Q2
  2450 GOSUB Q4
  2490 LET U$="EB"
  2500 GOSUB Q3
  2510 GOSUB Q2
  2520 LET U$="EB73"
  2530 GOSUB Q3
  2540 GOTO Q5
  2550 LET B$=B$(3 TO )
  2560 LET U$="3EA0323040"
  2570 GOTO 2590
  2580 LET U$="3E9B323040"
  2590 GOSUB Q3
  2600 LET B$=B$(5 TO )
  2610 GOSUB Q2
  2620 LET U$="4D"
  2630 GOSUB Q3
  2640 GOSUB Q4
  2680 GOSUB Q2
  2690 LET U$="45CDB20B"
  2700 GOSUB Q3
  2710 GOTO Q5
  2720 LET B$=B$(5 TO )
  2730 GOSUB Q2
  2740 GOSUB Q4
  2771 LET U$="EB"
  2780 GOSUB Q3
  2790 GOSUB Q2
  2800 LET U$="EB732372"
  2810 GOSUB Q3
  2820 GOTO Q5
  2830 IF PEEK (P1-1)=118 THEN GOTO 3180
  2840 IF P1=16509 THEN GOTO 3180
  2850 LET P1=P1-1
  2860 GOTO 2830
  2870 SLOW 
  2880 LET L(N,1)=PEEK (P1-5)*256+PEEK (P1-4)
  2890 LET L(N,2)=P-12288
  2900 LET N=N+1
  2910 RETURN 
  2920 DIM L(100,2)
  2930 DIM G(70,2)
  2940 LET N=1
  2950 LET N1=N
  2960 LET U$="E17E23E5FEFFC8D718F601FFFFA7ED520330FAC5E1C9A6AFAC"
  2965 LET U$=U$+"FD3622002182403600237DFEBA20F8"
  2970 GOSUB Q3
  2980 RETURN 
  2990 IF N1=1 THEN RETURN 
  3000 FOR X=1 TO N1-1
  3010 LET PO=G(X,2)
  3020 LET L=G(X,1)
  3030 LET G=1
  3040 GOTO 3120
  3050 LET G=G+1
  3060 IF G=N THEN GOTO 3150
  3070 GOTO 3040
  3080 POKE PO,L(G,2)-256*INT (L(G,2)/256)
  3090 POKE PO+1,INT (L(G,2)/256)
  3100 NEXT X
  3110 RETURN 
  3120 IF L=1000 THEN IF PO-12288<=L(G,2) THEN GOTO 3080
  3130 IF L=L(G,1) THEN GOTO 3080
  3140 GOTO 3050
  3160 GOTO 3200
  3170 RETURN 
  3190 LET L=PEEK P1*256+PEEK (P1+1)
  3200 SLOW 
  3201 POKE 16418,0
  3202 PRINT AT 22,0;"*******ERROR IN ";L;"******";AT 0,0;
  3203 POKE 16418,2
  3204 LIST L
  3205 GOTO 3200
  3230 LET V=CODE B$
  3240 IF V<38 OR V>63 THEN GOTO Q1
  3250 LET V=(V-38)*2+16514
  3260 LET U$="2A"
  3270 GOSUB Q3
  3280 POKE P,V-16384
  3290 POKE P+1,64
  3300 LET P=P+2
  3310 RETURN 
  3320 LET V=1
  3330 IF CODE B$(V)>37 OR CODE B$(V)<28 THEN GOTO 3360
  3340 LET V=V+1
  3350 GOTO 3330
  3360 IF V=1 THEN GOTO 3420
  3370 LET V=VAL (B$( TO V-1))
  3380 IF V<>INT V OR V>65536 THEN GOTO Q1
  3390 GOSUB 3530
  3400 POKE P+1,INT (V/256)
  3405 LET P=P+2
  3410 RETURN 
  3420 LET U$=""
  3430 IF B$( TO 3)="TOP" THEN LET U$="2A0C4023"
  3440 GOSUB 3780
  3450 IF B$( TO 3)<>"USR" THEN GOTO 3850
  3460 LET B$=B$(Q6 TO )
  3470 GOSUB Q2
  3480 POKE P-3,205
  3490 RETURN 
  3500 IF U$="" THEN GOTO 3220
  3510 GOSUB Q3
  3520 RETURN 
  3530 LET U$="21"
  3540 GOSUB Q3
  3550 POKE P,V-256*INT (V/256)
  3560 RETURN 
  3570 IF CODE B$<28 OR CODE B$>63 THEN RETURN 
  3580 GOSUB Q
  3590 GOTO 3570
  3600 IF CODE B$<28 OR CODE B$>37 THEN RETURN 
  3610 GOSUB Q
  3620 GOTO 3600
  3630 POKE P,CODE U$*16+CODE U$(2)-476
  3640 LET U$=U$(3 TO )
  3650 LET P=P+1
  3660 IF P>=32700 THEN STOP 
  3670 IF U$="" THEN RETURN 
  3680 GOTO Q3
  3690 GOSUB 2990
  3700 LET J=P-12287
  3710 LET P=28672
  3720 LET U$="210000E5C103E52182401182701A7723137DB920F87CB820F4E136A62336AF2336AC233676E5118040A7ED52227F40E123C30304"
  3730 GOSUB Q3
  3740 LET P=J
  3750 POKE 28673,P-256*INT (P/256)
  3760 POKE 28674,INT (P/256)
  3770 RAND USR 28672
  3780 IF B$( TO 3)<>"RND" THEN RETURN 
  3790 LET U$="D92A3240545D29291929292919223240EB"
  3800 GOSUB Q3
  3810 LET B$=B$(Q6 TO )
  3820 GOSUB Q2
  3830 LET U$="EBA7ED5230FB19E5D9E1"
  3840 RETURN 
  3850 IF B$( TO Q6)<>"PEEK" THEN GOTO 3900
  3860 LET B$=B$(5 TO )
  3870 GOSUB Q2
  3880 LET U$="6E2600"
  3890 GOTO 3500
  3900 IF B$( TO Q6)<>"DEEK" THEN GOTO 3500
  3910 LET B$=B$(5 TO )
  3920 GOSUB Q2
  3930 LET U$="D55E2356EBD1"
  3940 GOTO 3500
  3950 LET B$=B$(2 TO )
  3960 RETURN 
  3970 IF B$(1)="," THEN GOTO 4000
  3980 GOSUB Q
  3990 GOTO Q4
  4000 GOSUB Q
  4010 RETURN 
This is my machine code program that the ZX-COMPILER Created along with a BASIC program calling the machine code.

Code: Select all

# REM Q : , > P ? (_6   ( - =         
#       =   < =    _= _       __7____
    10  REM [HEX:\
36,00,0E,00,1A,00,12,00,\
35,00,0F,00,90,01,22,00,\
00,00,10,00,16,00,14,00,\
00,00,00,00,00,00,00,00,\
00,00,14,00,00,00,13,00,\
14,00,00,00,80,01,14,00,\
04,00,00,00,00,00,00,00,\
E1,7E,23,E5,FE,FF,C8,D7,\
18,F6,01,FF,FF,A7,ED,52,\
03,30,FA,C5,E1,C9,A6,AF,\
AC,FD,36,22,00,21,82,40,\
36,00,23,7D,FE,BA,20,F8,\
21,22,00,22,90,40,21,16,\
00,22,96,40,3E,9B,32,30,\
40,2A,90,40,4D,2A,96,40,\
45,CD,B2,0B,21,14,00,22,\
A4,40,2A,A4,40,22,A8,40,\
2A,A4,40,22,AA,40,21,00,\
00,22,98,40,2A,98,40,EB,\
21,01,00,19,22,98,40,2A,\
98,40,EB,2A,A4,40,A7,ED,\
52,C2,31,41,C3,6D,41,2A,\
96,40,EB,2A,98,40,19,22,\
8A,40,2A,96,40,EB,2A,98,\
40,EB,A7,ED,52,22,8C,40,\
3E,9B,32,30,40,2A,90,40,\
4D,2A,8A,40,45,CD,B2,0B,\
3E,9B,32,30,40,2A,90,40,\
4D,2A,8C,40,45,CD,B2,0B,\
C3,16,41,21,00,00,22,98,\
40,2A,98,40,EB,21,01,00,\
19,22,98,40,2A,98,40,EB,\
2A,A4,40,A7,ED,52,C2,8E,\
41,C3,CA,41,2A,90,40,EB,\
2A,98,40,19,22,8A,40,2A,\
90,40,EB,2A,98,40,EB,A7,\
ED,52,22,8C,40,3E,9B,32,\
30,40,2A,8A,40,4D,2A,96,\
40,45,CD,B2,0B,3E,9B,32,\
30,40,2A,8C,40,4D,2A,96,\
40,45,CD,B2,0B,C3,73,41,\
2A,A4,40,22,A8,40,2A,A8,\
40,22,B0,40,21,00,00,22,\
B2,40,2A,B2,40,EB,21,01,\
00,19,22,B2,40,2A,B2,40,\
EB,2A,A4,40,A7,ED,52,C2,\
F7,41,C3,A8,42,2A,A4,40,\
EB,2A,A4,40,CD,09,13,22,\
8E,40,2A,B2,40,EB,2A,B2,\
40,CD,09,13,22,94,40,2A,\
8E,40,EB,2A,94,40,EB,A7,\
ED,52,22,AE,40,2A,B0,40,\
22,A8,40,2A,AE,40,EB,2A,\
A8,40,EB,CD,C4,40,22,B0,\
40,2A,B0,40,EB,2A,90,40,\
19,22,82,40,2A,90,40,EB,\
2A,B0,40,EB,A7,ED,52,22,\
84,40,2A,B2,40,EB,2A,96,\
40,19,22,86,40,2A,96,40,\
EB,2A,B2,40,EB,A7,ED,52,\
22,88,40,3E,9B,32,30,40,\
2A,82,40,4D,2A,86,40,45,\
CD,B2,0B,3E,9B,32,30,40,\
2A,84,40,4D,2A,86,40,45,\
CD,B2,0B,3E,9B,32,30,40,\
2A,82,40,4D,2A,88,40,45,\
CD,B2,0B,3E,9B,32,30,40,\
2A,84,40,4D,2A,88,40,45,\
CD,B2,0B,C3,DC,41,2A,A4,\
40,22,B2,40,21,00,00,22,\
B0,40,2A,B0,40,EB,21,01,\
00,19,22,B0,40,2A,B0,40,\
EB,2A,A4,40,A7,ED,52,C2,\
CF,42,C3,80,43,2A,A4,40,\
EB,2A,A4,40,CD,09,13,22,\
9A,40,2A,B0,40,EB,2A,B0,\
40,CD,09,13,22,9C,40,2A,\
9A,40,EB,2A,9C,40,EB,A7,\
ED,52,22,A2,40,2A,B2,40,\
22,AA,40,2A,A2,40,EB,2A,\
AA,40,EB,CD,C4,40,22,B2,\
40,2A,B0,40,EB,2A,90,40,\
19,22,82,40,2A,90,40,EB,\
2A,B0,40,EB,A7,ED,52,22,\
84,40,2A,96,40,EB,2A,B2,\
40,EB,A7,ED,52,22,86,40,\
2A,B2,40,EB,2A,96,40,19,\
22,88,40,3E,9B,32,30,40,\
2A,84,40,4D,2A,86,40,45,\
CD,B2,0B,3E,9B,32,30,40,\
2A,82,40,4D,2A,86,40,45,\
CD,B2,0B,3E,9B,32,30,40,\
2A,84,40,4D,2A,88,40,45,\
CD,B2,0B,3E,9B,32,30,40,\
2A,82,40,4D,2A,88,40,45,\
CD,B2,0B,C3,B4,42,C9,45,\
A6,AF,AC ]

   100 LET X=USR 16595
   120 SLOW 
   130 FOR D=1 TO 100
   140 NEXT D
   145 CLS 
   150 GOTO 100
ZX81 Circle.gif
ZX81 Circle.gif (592.49 KiB) Viewed 1368 times
Attachments
ZX81 Circle.gif
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 980
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

I wrote a program for the ZX81 that draws a circle with only adding, subtracting, multiplying, or dividing. Square Root won't be allowed after I convert it into ZX-COMPILER BASIC. I want to get the ZX81 to draw a circle in Machine Code to see how fast it goes.

Code: Select all

   
          
    10 LET H=34
    20 LET K=22
    30 PLOT (H),(K)
    40 LET R=20
    50 LET T=R
    60 LET U=R
    70 LET L=0
    80 LET L=L+1
    90 IF L=R THEN GOTO 150
   100 LET E=K+L
   110 LET F=K-L
   120 PLOT (H),(E)
   130 PLOT (H),(F)
   140 GOTO 80
   150 LET L=0
   160 LET L=L+1
   170 IF L=R THEN GOTO 230
   180 LET E=(H+L)
   190 LET F=(H-L)
   200 PLOT (E),(K)
   210 PLOT (F),(K)
   220 GOTO 160
   230 LET T=R
   240 LET X=T
   250 LET Y=0
   260 LET Y=Y+1
   270 IF Y=R THEN GOTO 420
   280 LET G=R*R
   290 LET J=Y*Y
   300 LET W=(G-J)
   310 LET T=X
   320 LET X=(W/T)
   330 LET A=(X+H)
   340 LET B=(H-X)
   350 LET C=(Y+K)
   360 LET D=(K-Y)
   370 PLOT (A),(C)
   380 PLOT (B),(C)
   390 PLOT (A),(D)
   400 PLOT (B),(D)
   410 GOTO 260
   420 LET Y=R
   430 LET X=0
   440 LET X=X+1
   450 IF X=R THEN GOTO 600
   460 LET M=R*R
   470 LET N=X*X
   480 LET Q=(M-N)
   490 LET U=Y
   500 LET Y=(Q/U)
   510 LET A=(X+H)
   520 LET B=(H-X)
   530 LET C=(K-Y)
   540 LET D=(Y+K)
   550 PLOT (B),(C)
   560 PLOT (A),(C)
   570 PLOT (B),(D)
   580 PLOT (A),(D)
   590 GOTO 440
   600 STOP 

   



Last edited by tristanbgilb on Sun Jan 29, 2023 12:27 pm, edited 1 time in total.
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 980
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

tristanbgilb wrote: Tue Dec 27, 2022 4:59 am Image
For my NO BUDGET MOVIE, in my brainstorm, page 27 requires a working Z80 Processor that we can reprogram to get the detonators to function after the Y2K bug. We will use the ZX-Compiler to create the machine code since none of us know how to program in machine code directly. It is decided we will have better success and less chance of blowing ourselves up using the compiler program. I am hoping out of my dozen Sinclairs with Z80 processors that I can get one working good enough for the movie.
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 980
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

pasayten wrote: Fri Jan 27, 2023 5:11 pm I second the raspberry pi... They are great!!!
The Timex Sinclair 1000 ZX81 was my first home computer and will always be my favorite.

Image
Developer Sinclair Research
Manufacturer Timex Corporation
Type Home computer
Release date 5 March 1981; 41 years ago[1]
Introductory price £49.95 kit, £69.95 assembled[2] (£204–285/$279–390 at 2023 prices)
Discontinued 1984
Units sold More than 1.5 million[3]
Operating system Sinclair BASIC[4]
CPU Z80 @ 3.25 MHz[4]
Memory 1 KB (64 KB max. 56 KB usable)[4]
Storage External Compact Cassette recorder at a claimed 250 bps[4] or an average 300 bps[5]
Display Monochrome display on UHF television[4]
Graphics 24 lines × 32 characters or
64 × 48 pixels graphics mode[4]
Power 9V DC[4]
Dimensions 167 millimetres (6.6 in) wide by 175 millimetres (6.9 in) deep[6]
Mass 350 grams (12 oz)[4]
Predecessor ZX80
Successor ZX Spectrum
Related Timex Sinclair 1000,
Timex Sinclair 1500
Attachments
Sinclair-ZX81.png
Sinclair-ZX81.png (35.92 KiB) Viewed 1366 times
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
pasayten
Posts: 1753
Joined: Thu Mar 11, 2021 8:03 pm
Contact:

Re: www.MethowValley.org

Post by pasayten »

I second the raspberry pi... They are great!!!
pasayten
Ray Peterson
User avatar
tristanbgilb
Posts: 980
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

Terry and I produced this album of him and our friends. Click Album Cover to be sent to youtube to hear songs.

Image
Attachments
the last outlaws cover.jpg
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
mister_coffee
Posts: 978
Joined: Thu Jul 16, 2020 7:35 pm
Location: Winthrop, WA
Contact:

Re: www.MethowValley.org

Post by mister_coffee »

tristanbgilb wrote: Fri Jan 27, 2023 6:08 am ...
[I wonder if this is what I want. It is inexpensive compared to my Vintage Computer Collection. I think I own a Raspberry Pi that is modified to be a peripheral interface for my TI-99/4a Home Computer.
What I'd probably recommend is a good Raspberry Pi starter kit like this one:

https://www.amazon.com/CanaKit-Raspberr ... r=8-6&th=1

A 1GB Pi is probably fine for starting unless you have some specific project in mind. This gives you a Pi, a 128GB Micro SD Card, a reader for the card, a good power supply (very important), a fan, and a case. The fan and the case are nice but not strictly necessary.

There are weatherproof outdoor cases available with varying capabilities. You can plausibly run a Pi from a solar panel and batteries if you want as well.

You'll need a keyboard, mouse, and HDMI display. Chances are you have those laying around your house, but if you don't any cheap ones will do the job fine.

Also it is a Good Idea to invest (about $60) in a USB Hard Drive. Running Linux continuously from an SD card limits the SD card's life (so back them up frequently, usually bulk-copying the SD card image is Good Enough). I can walk you through how to set up the USB hard drive and also walk you through trickery that greatly extends an SD card's life if you like.

Also, if you want a book about starting out I can recommend this one:

https://www.amazon.com/Programming-Rasp ... 198&sr=8-1
:arrow: David Bonn :idea:
User avatar
tristanbgilb
Posts: 980
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

mister_coffee wrote: Thu Jan 26, 2023 7:21 pm
tristanbgilb wrote: Thu Jan 26, 2023 10:55 am ...
I am not strong in any computer language. I am a wimp programmer. I just like the logic and hope to understand a computer by studying the ZX81.
In 2023 I'd recommend accomplishing that by getting your hands on a Raspberry Pi and starting to play.

Oh, and subject to US Patent #11145090

NEW Raspberry Pi 4 Compute Module (CM4) 1GB RAM 16GB Wi-Fi CM4101016 FAST S&H!
US $84.99
Compute Module 4 (CM4) brings the power of Raspberry Pi 4 to the popular Compute Module family. For the first time wireless connectivity is an option, and this includes a built-in antenna on the PCB as well as a connector for an external antenna.

This model features Wireless connectivity, 1GB RAM and 16GB eMMC storage.
I wonder if this is what I want. It is inexpensive compared to my Vintage Computer Collection. I think I own a Raspberry Pi that is modified to be a peripheral interface for my TI-99/4a Home Computer.
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
mister_coffee
Posts: 978
Joined: Thu Jul 16, 2020 7:35 pm
Location: Winthrop, WA
Contact:

Re: www.MethowValley.org

Post by mister_coffee »

tristanbgilb wrote: Thu Jan 26, 2023 10:55 am ...
I am not strong in any computer language. I am a wimp programmer. I just like the logic and hope to understand a computer by studying the ZX81.
In 2023 I'd recommend accomplishing that by getting your hands on a Raspberry Pi and starting to play.

Oh, and subject to US Patent #11145090

Code: Select all

def detect_flames(g, ir):
    """detect regions likely to have flames: how:
        A. locate hot areas in the thermal image, and turbulent areas in the image
        B. generate contours for each
        C. locate contours that overlap and where the centroid of the turbulent area
           is above the centroid of the hot area, mask these areas
        D. Generate contours from the masks found in C and choose the biggest bounding box
           for each mask
    """
    global Min_value

    ret, r = cv2.threshold(ir, Min_value + ir_threshold, 65535, cv2.THRESH_BINARY)
    ret, g = cv2.threshold(g, 192, 255, cv2.THRESH_BINARY)

    numpy.right_shift(r, 8, r)
    r = r.astype(numpy.uint8)

    # try this erode step...
    #g = erode(g)
    g = dilate(g)
    r = dilate(r)

    candidates = []
    ir_contours = cv2.findContours(r, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)[0]
    motion_contours = cv2.findContours(g, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)[0]

    m_centroids = []

    for (j, m) in enumerate(motion_contours):
        m_centroids.append(y_centroid(m))

    for (i, c) in enumerate(ir_contours):
        irp = numpy.zeros(r.shape, numpy.uint8)
        irp = cv2.drawContours(irp, [c], 0, 255, -1)
        ir_y = y_centroid(c)

        for (j, m) in enumerate(motion_contours):
            m_y = m_centroids[j]

            # turbulent motion should be above hot spot
            # FIXME:  rethink because thermal column becomes too large...
            if ir_y < m_y:
                continue

            mp = numpy.zeros(g.shape, numpy.uint8)
            mp = cv2.drawContours(mp, [m], 0, 255, -1)

            result = cv2.bitwise_and(irp, mp)

            if cv2.countNonZero(result) > 0:
                print(f"[ir:info] motion area {cv2.contourArea(m)}, ir area {cv2.contourArea(c)}")
                candidates.append(result)
                break

    for i in range(0, len(candidates)):
        candidates[i] = biggest_rect(candidates[i])
        if verbose:
            print("[ir:info] candidate:  (%d,%d)+(%d,%d)" % candidates[i])

    return candidates
... and ...

Code: Select all

def process_flicker(delta):
    """helper function that detects areas of turbulent motion in the image:
        from:  'A real-time video fire flame and smoke detection algorithm', 2013,
                Yu, Mei, and Zhang
    """
    global flicker, flicker_data, b1, b2

    ret, add_mask = cv2.threshold(delta, motiondelta, 1, cv2.THRESH_BINARY)
    sub_mask = numpy.logical_not(add_mask)

    add_mask = numpy.multiply(add_mask, b1).astype(flicker_data.dtype)
    sub_mask = numpy.multiply(sub_mask, b2).astype(flicker_data.dtype)

    flicker_data = cv2.add(flicker_data, add_mask)
    flicker_data = cv2.subtract(flicker_data, sub_mask)

    ret, flicker = cv2.threshold(flicker_data, flickerdelta, 255, cv2.THRESH_BINARY)

:arrow: David Bonn :idea:
User avatar
tristanbgilb
Posts: 980
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

Image

I used the ZX COMPILER by Silversoft to make BASIC GRAPHICS into ASSEMBLY Language.

BASIC

Code: Select all

515 PRINT AT 7,7;"½½½½½½½½½½½½½½½½½½"
   516 PRINT AT 6,7;"½½½½½½½½½½½½½½½½½½"
   517 PRINT AT 8,7;"¿½½½½½½½½½½½½½½½½¿"
   518 PRINT AT 5,7;"¾½½½½½½½½½½½½½½½½¾"
   519 PRINT AT 9,10;"½½½½½½½½½½½½"
   520 PRINT AT 4,8;"¾½½½½½½½½½½½½½½¾"
   521 PRINT AT 10,11;"¿½½½½½½½½¿"
   522 PRINT AT 3,9;"¾½½½½½½½½½½½½¾"
   523 PRINT AT 11,14;"½½½½"
   524 PRINT AT 2,11;"¾½½½½½½½½¾"
   525 PRINT AT 12,14;"½½½½"
   526 PRINT AT 13,11;"¾¾½½½½½½¾¾"
   527 PRINT AT 14,11;"¿¿½½½½½½¿¿"
   528 PRINT AT 15,14;"½½½½";AT 16,14;"½½½½"
   529 PRINT AT 17,12;"¾½½½½½½¾";AT 18,12;"¿½½½½½½¿"
   530 PRINT AT 19,14;"½½½½";AT 20,14;"½½½½";AT 21,14;"½½½½"
MACHINE CODE

Code: Select all

# REM                                 
#                             __7____
   145  REM [HEX:\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
E1,7E,23,E5,FE,FF,C8,D7,\
18,F6,01,FF,FF,A7,ED,52,\
03,30,FA,C5,E1,C9,A6,AF,\
AC,FD,36,22,00,21,82,40,\
36,00,23,7D,FE,BA,20,F8,\
21,07,00,45,21,07,00,4D,\
CD,F5,08,CD,BA,40,08,08,\
08,08,08,08,08,08,08,08,\
08,08,08,08,08,08,08,08,\
FF,21,06,00,45,21,07,00,\
4D,CD,F5,08,CD,BA,40,08,\
08,08,08,08,08,08,08,08,\
08,08,08,08,08,08,08,08,\
08,FF,21,08,00,45,21,07,\
00,4D,CD,F5,08,CD,BA,40,\
0A,08,08,08,08,08,08,08,\
08,08,08,08,08,08,08,08,\
08,0A,FF,21,05,00,45,21,\
07,00,4D,CD,F5,08,CD,BA,\
40,09,08,08,08,08,08,08,\
08,08,08,08,08,08,08,08,\
08,08,09,FF,21,09,00,45,\
21,0A,00,4D,CD,F5,08,CD,\
BA,40,08,08,08,08,08,08,\
08,08,08,08,08,08,FF,21,\
04,00,45,21,08,00,4D,CD,\
F5,08,CD,BA,40,09,08,08,\
08,08,08,08,08,08,08,08,\
08,08,08,08,09,FF,21,0A,\
00,45,21,0B,00,4D,CD,F5,\
08,CD,BA,40,0A,08,08,08,\
08,08,08,08,08,0A,FF,21,\
03,00,45,21,09,00,4D,CD,\
F5,08,CD,BA,40,09,08,08,\
08,08,08,08,08,08,08,08,\
08,08,09,FF,21,0B,00,45,\
21,0E,00,4D,CD,F5,08,CD,\
BA,40,08,08,08,08,FF,21,\
02,00,45,21,0B,00,4D,CD,\
F5,08,CD,BA,40,09,08,08,\
08,08,08,08,08,08,09,FF,\
21,0C,00,45,21,0E,00,4D,\
CD,F5,08,CD,BA,40,08,08,\
08,08,FF,21,0D,00,45,21,\
0B,00,4D,CD,F5,08,CD,BA,\
40,09,09,08,08,08,08,08,\
08,09,09,FF,21,0E,00,45,\
21,0B,00,4D,CD,F5,08,CD,\
BA,40,0A,0A,08,08,08,08,\
08,08,0A,0A,FF,21,0F,00,\
45,21,0E,00,4D,CD,F5,08,\
CD,BA,40,08,08,08,08,FF,\
21,10,00,45,21,0E,00,4D,\
CD,F5,08,CD,BA,40,08,08,\
08,08,FF,21,11,00,45,21,\
0C,00,4D,CD,F5,08,CD,BA,\
40,09,08,08,08,08,08,08,\
09,FF,21,12,00,45,21,0C,\
00,4D,CD,F5,08,CD,BA,40,\
0A,08,08,08,08,08,08,0A,\
FF,21,13,00,45,21,0E,00,\
4D,CD,F5,08,CD,BA,40,08,\
08,08,08,FF,21,14,00,45,\
21,0E,00,4D,CD,F5,08,CD,\
BA,40,08,08,08,08,FF,21,\
15,00,45,21,0E,00,4D,CD,\
F5,08,CD,BA,40,08,08,08,\
08,FF,21,E8,03,2B,7C,B5,\
20,FB,C9,CF,FF,00,A6,AF,\
AC ]

   190 SLOW 
   200 LET X=USR 16595
   210 CLS 
   500 GOTO 190

Translated in ZX-COMPILER BASIC

Code: Select all

   145 REM MOVE7,7
   150 REM PRINT"½½½½½½½½½½½½½½½½½½"
   155 REM MOVE6,7
   160 REM PRINT"½½½½½½½½½½½½½½½½½½"
   165 REM MOVE8,7
   170 REM PRINT"¿½½½½½½½½½½½½½½½½¿"
   175 REM MOVE5,7
   180 REM PRINT"¾½½½½½½½½½½½½½½½½¾"
   185 REM MOVE9,10
   190 REM PRINT"½½½½½½½½½½½½"
   195 REM MOVE4,8
   200 REM PRINT"¾½½½½½½½½½½½½½½¾"
   205 REM MOVE10,11
   210 REM PRINT"¿½½½½½½½½¿"
   215 REM MOVE3,9
   220 REM PRINT"¾½½½½½½½½½½½½¾"
   225 REM MOVE11,14
   230 REM PRINT"½½½½"
   235 REM MOVE2,11
   240 REM PRINT"¾½½½½½½½½¾"
   245 REM MOVE12,14
   250 REM PRINT"½½½½"
   255 REM MOVE13,11
   260 REM PRINT"¾¾½½½½½½¾¾"
   265 REM MOVE14,11
   270 REM PRINT"¿¿½½½½½½¿¿"
   275 REM MOVE15,14
   280 REM PRINT"½½½½"
   281 REM MOVE16,14
   282 REM PRINT"½½½½"
   285 REM MOVE17,12
   290 REM PRINT"¾½½½½½½¾"
   292 REM MOVE18,12
   293 REM PRINT"¿½½½½½½¿"
   295 REM MOVE19,14
   300 REM PRINT"½½½½"
   305 REM MOVE20,14
   310 REM PRINT"½½½½"
   315 REM MOVE21,14
   320 REM PRINT"½½½½"
   350 REM PAUSE1000
   400 REM RETURN
   500 REM END
# REM **COMPILER**
  1000  REM [HEX:\
17,17,28,34,32,35,2E,31,\
2A,37,17,17,76 ]
  1010 FAST 
  1011 LET Q=3950
  1012 LET Q1=2830
  1013 LET Q2=3320
  1014 LET Q3=3630
  1015 LET Q4=3970
  1016 LET Q5=1320
  1017 LET Q6=4
  1020 LET P=28858
  1030 LET P1=16514
  1040 GOSUB 2920
  1050 IF PEEK (P1-1)<>234 THEN GOTO Q1
  1060 IF PEEK P1=118 THEN GOTO Q1
  1070 GOSUB 2880
  1080 LET A$=""
  1090 LET A$=A$+CHR$ PEEK P1
  1100 LET P1=P1+1
  1110 IF PEEK (P1-1)<>118 THEN GOTO 1090
  1120 IF PEEK (P1+1)*256+PEEK (P1+2)=1010 THEN GOTO 3690
  1130 LET P1=P1-3
  1140 LET T$=A$( TO 2)
  1150 LET B$=A$+"      "
  1160 LET J=0
  1170 LET J=J+(T$="RE")*2170+(T$="SC")*1200+(T$="PR")*1360+(T$="GE")*1530+(T$="EN")*1620+(T$="PA")*1670+(T$="CL")*1720+(T$="MO")*1770+(T$="LE")*1890+(A$( TO 3)="GOT")*2060+(A$( TO 3)="GOS")*2130+(T$="IF")*2200+(T$="PO")*2430+(T$="UN")*2550+(T$="PL")*2580+(T$="DO")*2720
  1180 IF NOT J THEN LET J=Q1
  1190 GOTO J
  1201 IF B$(7)<>CHR$ 118 THEN GOTO Q1
  1202 LET U$="2A0C40112100EB1901F702EDB00620AF131210FC"
  1203 GOSUB Q3
  1204 GOTO Q5
  1320 LET P1=P1+8
  1330 GOTO 1050
  1360 LET B$=B$(6 TO )
  1370 IF B$(1)=CHR$ 11 THEN GOTO 1420
  1380 GOSUB Q2
  1390 LET U$="7DD7"
  1400 GOSUB Q3
  1410 GOTO Q5
  1420 GOSUB Q
  1430 LET U$="CDBA40"
  1440 GOSUB Q3
  1450 POKE P,CODE (B$(1))
  1460 GOSUB Q
  1470 IF B$(1)=CHR$ 11 THEN POKE P+1,255
  1480 LET P=P+1
  1490 IF B$(1)=CHR$ 11 THEN GOTO 1510
  1500 GOTO 1450
  1510 LET P=P+1
  1520 GOTO Q5
  1530 LET B$=B$(Q6 TO )
  1540 LET U$="CDBB02444D51142808CDBD077ECB7728023E8021004077233600"
  1550 GOSUB Q3
  1560 LET V=CODE B$(1)
  1570 IF CODE B$(2)<>118 THEN GOTO Q1
  1580 IF V<38 OR V>63 THEN GOTO Q1
  1590 LET V=(V-38)*2+130
  1600 POKE P-6,V
  1610 GOTO Q5
  1620 LET B$=B$(Q6 TO )
  1630 IF B$(1)<>CHR$ 118 THEN GOTO Q1
  1640 LET U$="CFFF"
  1650 GOSUB Q3
  1660 GOTO Q5
  1670 LET B$=B$(6 TO )
  1680 GOSUB Q2
  1690 LET U$="2B7CB520FB"
  1700 GOSUB Q3
  1710 GOTO Q5
  1720 LET B$=B$(Q6 TO )
  1730 IF B$(1)<>CHR$ 118 THEN GOTO Q1
  1740 LET U$="2A0C40161823062036002310FB1520F5010000CDF508"
  1750 GOSUB Q3
  1760 GOTO Q5
  1770 LET B$=B$(5 TO )
  1780 GOSUB Q2
  1790 GOSUB Q4
  1830 LET U$="45"
  1840 GOSUB Q3
  1850 GOSUB Q2
  1860 LET U$="4DCDF508"
  1870 GOSUB Q3
  1880 GOTO Q5
  1890 LET B$=B$(Q6 TO )
  1900 LET L=(CODE B$-38)*2+130
  1910 LET B$=B$(3 TO )
  1920 GOSUB Q2
  1930 GOSUB 3570
  1940 IF CODE B$=118 THEN GOTO 2020
  1950 LET U$="EB"
  1960 GOSUB Q3
  1970 LET S$=B$(1)
  1980 GOSUB Q
  1990 GOSUB Q2
  1991 LET N$="CD0913"
  1992 IF PEEK 4869=197 THEN LET N$="CD0513"
  2000 LET U$=(N$ AND S$="*")+("EBCDC440" AND S$="/")+("19" AND S$="+")+("EBA7ED52" AND S$="-")
  2010 GOSUB Q3
  2020 LET U$="220040"
  2030 GOSUB Q3
  2040 POKE P-2,L
  2050 GOTO Q5
  2060 LET B$=B$(5 TO )
  2070 GOSUB Q2
  2080 POKE P-3,195
  2090 LET G(N1,1)=PEEK (P-2)+PEEK (P-1)*256
  2100 LET G(N1,2)=P-2
  2110 LET N1=N1+1
  2120 GOTO Q5
  2130 LET B$=B$(6 TO )
  2140 GOSUB Q2
  2150 POKE P-3,205
  2160 GOTO 2090
  2170 LET U$="C9"
  2180 GOSUB Q3
  2190 GOTO Q5
  2200 LET B$=B$(3 TO )
  2210 GOSUB Q2
  2220 GOSUB 3570
  2230 LET U$="EB"
  2240 GOSUB Q3
  2250 LET S$=B$(1)
  2260 GOSUB Q
  2270 GOSUB Q2
  2280 IF CODE B$>37 THEN GOSUB Q
  2290 IF CODE B$<38 THEN GOSUB 3600
  2300 LET U$="A7ED52"
  2310 IF S$="<>" THEN LET U$=U$+"CA"
  2320 IF S$="=" THEN LET U$=U$+"C2"
  2330 IF S$="<" THEN LET U$=U$+"DA"
  2340 IF S$=">" THEN LET U$=U$+"D2"
  2350 LET U$=U$+"0000"
  2360 IF S$<>">" AND S$<>"=" AND S$<>"<" AND S$<>"<>" THEN GOTO Q1
  2370 GOSUB Q3
  2380 LET G(N1,2)=P-2
  2390 LET G(N1,1)=1000
  2400 LET N1=N1+1
  2410 LET A$=B$
  2420 GOTO 1140
  2430 LET B$=B$(5 TO )
  2440 GOSUB Q2
  2450 GOSUB Q4
  2490 LET U$="EB"
  2500 GOSUB Q3
  2510 GOSUB Q2
  2520 LET U$="EB73"
  2530 GOSUB Q3
  2540 GOTO Q5
  2550 LET B$=B$(3 TO )
  2560 LET U$="3EA0323040"
  2570 GOTO 2590
  2580 LET U$="3E9B323040"
  2590 GOSUB Q3
  2600 LET B$=B$(5 TO )
  2610 GOSUB Q2
  2620 LET U$="4D"
  2630 GOSUB Q3
  2640 GOSUB Q4
  2680 GOSUB Q2
  2690 LET U$="45CDB20B"
  2700 GOSUB Q3
  2710 GOTO Q5
  2720 LET B$=B$(5 TO )
  2730 GOSUB Q2
  2740 GOSUB Q4
  2771 LET U$="EB"
  2780 GOSUB Q3
  2790 GOSUB Q2
  2800 LET U$="EB732372"
  2810 GOSUB Q3
  2820 GOTO Q5
  2830 IF PEEK (P1-1)=118 THEN GOTO 3180
  2840 IF P1=16509 THEN GOTO 3180
  2850 LET P1=P1-1
  2860 GOTO 2830
  2870 SLOW 
  2880 LET L(N,1)=PEEK (P1-5)*256+PEEK (P1-4)
  2890 LET L(N,2)=P-12288
  2900 LET N=N+1
  2910 RETURN 
  2920 DIM L(100,2)
  2930 DIM G(70,2)
  2940 LET N=1
  2950 LET N1=N
  2960 LET U$="E17E23E5FEFFC8D718F601FFFFA7ED520330FAC5E1C9A6AFAC"
  2965 LET U$=U$+"FD3622002182403600237DFEBA20F8"
  2970 GOSUB Q3
  2980 RETURN 
  2990 IF N1=1 THEN RETURN 
  3000 FOR X=1 TO N1-1
  3010 LET PO=G(X,2)
  3020 LET L=G(X,1)
  3030 LET G=1
  3040 GOTO 3120
  3050 LET G=G+1
  3060 IF G=N THEN GOTO 3150
  3070 GOTO 3040
  3080 POKE PO,L(G,2)-256*INT (L(G,2)/256)
  3090 POKE PO+1,INT (L(G,2)/256)
  3100 NEXT X
  3110 RETURN 
  3120 IF L=1000 THEN IF PO-12288<=L(G,2) THEN GOTO 3080
  3130 IF L=L(G,1) THEN GOTO 3080
  3140 GOTO 3050
  3160 GOTO 3200
  3170 RETURN 
  3190 LET L=PEEK P1*256+PEEK (P1+1)
  3200 SLOW 
  3201 POKE 16418,0
  3202 PRINT AT 22,0;"*******ERROR IN ";L;"******";AT 0,0;
  3203 POKE 16418,2
  3204 LIST L
  3205 GOTO 3200
  3230 LET V=CODE B$
  3240 IF V<38 OR V>63 THEN GOTO Q1
  3250 LET V=(V-38)*2+16514
  3260 LET U$="2A"
  3270 GOSUB Q3
  3280 POKE P,V-16384
  3290 POKE P+1,64
  3300 LET P=P+2
  3310 RETURN 
  3320 LET V=1
  3330 IF CODE B$(V)>37 OR CODE B$(V)<28 THEN GOTO 3360
  3340 LET V=V+1
  3350 GOTO 3330
  3360 IF V=1 THEN GOTO 3420
  3370 LET V=VAL (B$( TO V-1))
  3380 IF V<>INT V OR V>65536 THEN GOTO Q1
  3390 GOSUB 3530
  3400 POKE P+1,INT (V/256)
  3405 LET P=P+2
  3410 RETURN 
  3420 LET U$=""
  3430 IF B$( TO 3)="TOP" THEN LET U$="2A0C4023"
  3440 GOSUB 3780
  3450 IF B$( TO 3)<>"USR" THEN GOTO 3850
  3460 LET B$=B$(Q6 TO )
  3470 GOSUB Q2
  3480 POKE P-3,205
  3490 RETURN 
  3500 IF U$="" THEN GOTO 3220
  3510 GOSUB Q3
  3520 RETURN 
  3530 LET U$="21"
  3540 GOSUB Q3
  3550 POKE P,V-256*INT (V/256)
  3560 RETURN 
  3570 IF CODE B$<28 OR CODE B$>63 THEN RETURN 
  3580 GOSUB Q
  3590 GOTO 3570
  3600 IF CODE B$<28 OR CODE B$>37 THEN RETURN 
  3610 GOSUB Q
  3620 GOTO 3600
  3630 POKE P,CODE U$*16+CODE U$(2)-476
  3640 LET U$=U$(3 TO )
  3650 LET P=P+1
  3660 IF P>=32700 THEN STOP 
  3670 IF U$="" THEN RETURN 
  3680 GOTO Q3
  3690 GOSUB 2990
  3700 LET J=P-12287
  3710 LET P=28672
  3720 LET U$="210000E5C103E52182401182701A7723137DB920F87CB820F4E136A62336AF2336AC233676E5118040A7ED52227F40E123C30304"
  3730 GOSUB Q3
  3740 LET P=J
  3750 POKE 28673,P-256*INT (P/256)
  3760 POKE 28674,INT (P/256)
  3770 RAND USR 28672
  3780 IF B$( TO 3)<>"RND" THEN RETURN 
  3790 LET U$="D92A3240545D29291929292919223240EB"
  3800 GOSUB Q3
  3810 LET B$=B$(Q6 TO )
  3820 GOSUB Q2
  3830 LET U$="EBA7ED5230FB19E5D9E1"
  3840 RETURN 
  3850 IF B$( TO Q6)<>"PEEK" THEN GOTO 3900
  3860 LET B$=B$(5 TO )
  3870 GOSUB Q2
  3880 LET U$="6E2600"
  3890 GOTO 3500
  3900 IF B$( TO Q6)<>"DEEK" THEN GOTO 3500
  3910 LET B$=B$(5 TO )
  3920 GOSUB Q2
  3930 LET U$="D55E2356EBD1"
  3940 GOTO 3500
  3950 LET B$=B$(2 TO )
  3960 RETURN 
  3970 IF B$(1)="," THEN GOTO 4000
  3980 GOSUB Q
  3990 GOTO Q4
  4000 GOSUB Q
  4010 RETURN 
Attachments
nukeuncut2023-01-26 17-45-35.gif
nukeuncut2023-01-26 17-45-35.gif (2.91 MiB) Viewed 1282 times
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 980
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

Adventure games are about one of the neatest programs created on early computers. Here is an example of hexadecimal mixed with Sinclair BASIC. This assembly language has me baffled I am am eager to understand what is happening here.

ADVENTURE
ZX81

Code: Select all

# REM _P_E£_7"___4___5 ______K__KJ____
#     (__E£__Q__6:_E:_Q _V_A4__V____=
     1  REM [HEX:\
01,B5,02,2A,0C,40,23,0B,\
7E,FE,82,20,F9,C5,01,21,\
00,09,54,5D,09,C1,ED,B0,\
C9,06,B0,AF,D7,D7,D7,D7,\
10,FA,C9,2A,0C,40,01,B6,\
02,09,22,0E,40,2A,0E,40,\
36,80,CD,BB,02,26,20,FA,\
CD,BB,02,44,4D,51,14,28,\
F7,CD,BD,07,7E,FE,76,28,\
27,FE,77,28,15,FE,0B,28,\
E1,CB,77,20,DD,2A,0E,40,\
77,23,7E,FE,76,20,CB,2B,\
18,C8,2A,0E,40,AF,77,2B,\
7E,FE,76,20,BD,23,18,BA,\
2A,0E,40,AF,77,11,16,41,\
2A,0C,40,01,B6,02,09,01,\
1F,00,ED,B0,C9,1B,1B,1B,\
1B,1B ]

     2 LET C$="                               "
     3 RETURN 
     4 SLOW 
     5 LET IN=USR VAL "16549"
     6 IF F$="F" THEN FAST 
     7 GOTO VAL "2"
     8 PRINT AT VAL "21",USR VAL "16514";
     9 RETURN 
    10 PRINT AT PI-PI,PI-PI;
    20 LET CL=USR 16539
    25 IF LN>15 AND (LAMP=0 OR P(23)<>99) THEN PRINT AT PI-PI,PI-PI;"ITS TOO DARK TO SEE."
    26 IF LN>15 AND (P(23)<>99 OR LAMP=0) THEN GOTO 135
    30 PRINT AT 0,0;"LOCATION : ";L$(LN)
    40 IF E$(LN)="    " THEN GOTO 100
    50 PRINT "EXITS : ";
    60 FOR Z=1 TO 4
    70 LET U$=E$(LN)(Z)
    80 IF U$="N" THEN PRINT "NORTH.";
    82 IF U$="S" THEN PRINT "SOUTH.";
    84 IF U$="E" THEN PRINT "EAST.";
    86 IF U$="W" THEN PRINT "WEST.";
    87 IF U$="U" THEN PRINT "UP.";
    88 IF U$="D" THEN PRINT "DOWN.";
    90 NEXT Z
    95 PRINT 
   100 PRINT "I CAN SEE : ";
   101 LET FZ=0
   110 FOR Z=1 TO NO
   120 IF P(Z)<>LN THEN GOTO 130
   121 PRINT O$(Z),
   122 LET FZ=1
   130 NEXT Z
   132 IF FZ=0 THEN PRINT "NOTHING SPECIAL",
   135 PRINT 
   140 PRINT "ª®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®¬"
   145 IF TU=PI-PI THEN PRINT AT VAL "7",PI-PI;"YOU MUST SEARCH FOR THE 3 PIECESOF THE ROYAL SCEPTER , REMAKE ITAND RETURN IT TO THE EMPEROR."
   150 IF (LAMP=0 OR P(23)<>99) AND LN>15 THEN GOSUB S
   151 IF (LAMP=0 OR P(23)<>99) AND LN>15 THEN PRINT "ITS RISKY MOVING IN THE DARK"
   152 GOSUB S
   155 LET TU=TU+1
   160 PRINT "TELL ME WHAT TO DO NEXT :"
   170 GOSUB S
   180 GOSUB 4
   190 GOSUB S
   200 IF C$(1)=" " THEN GOTO 155
   202 LET T$=C$( TO 3)
   204 IF T$="NOR" OR T$="SOU" OR T$="EAS" OR T$="WES" OR T$="UP " OR T$="DOWN" OR T$="U  " OR T$="D  " OR T$="N  " OR T$="S  " OR T$="E  " OR T$="W  " THEN GOTO 1000
   208 IF T$="I  " THEN GOTO 1100
   218 IF LEN C$>26 THEN LET C$=C$( TO 26)
   219 GOSUB 5500
   220 IF C$="SLO" THEN LET F$="S"
   230 IF C$="FAS" THEN LET F$="F"
   240 IF C$="SLO" OR C$="FAS" THEN GOTO 150
   250 IF C$="TAK" OR C$="GRA" OR C$="GET" THEN GOTO 2000
   260 IF C$="LEAV" OR C$="PUT" OR C$="DRO" THEN GOTO 2100
   270 IF C$="SEA" OR C$="LOO" OR C$="EXA" THEN GOTO 2500
   280 IF C$="INV" THEN GOTO 1100
   290 IF C$="HEL" THEN GOTO 7500
   300 IF C$="SCO" THEN GOTO 2700
   310 IF C$="ENT" OR C$="BOA" THEN GOTO 2800
   320 IF C$="LEA" OR C$="JUM" THEN GOTO 2810
   330 IF C$="REA" THEN GOTO 3100
   340 IF C$="CLI" THEN GOTO 2820
   350 IF C$="SHA" THEN GOTO 2840
   360 IF C$="CLE" OR C$="WAS" THEN GOTO 2850
   370 IF C$="MAK" OR C$="BUI" OR C$="COM" THEN GOTO 3800
   380 IF C$="CUT" OR C$="CHO" THEN GOTO 2860
   390 IF C$="KIC" THEN GOTO 2870
   400 IF C$="PUS" OR C$="PRE" THEN GOTO 2890
   410 IF C$="SWI" THEN GOTO 4500
   420 IF C$="UNL" THEN GOTO 2950
   430 IF C$="OPE" THEN GOTO 6000
   440 IF C$="UNL" THEN GOTO 6100
   450 IF C$="LIF" THEN GOTO 6100
   460 IF C$="LIG" THEN GOTO 2960
   470 IF C$="SAV" THEN GOTO 8000
   480 IF C$="QUI" THEN GOTO 2900
   490 IF C$="TIM" THEN GOTO 2760
   500 IF C$="OFF" OR C$="GIV" THEN GOTO 4000
   510 IF C$="RUB" THEN GOTO 4020
   520 IF C$="ROL" THEN GOTO 4050
   530 IF C$="SAY" THEN GOTO 4200
   540 IF C$="PIC" THEN GOTO 4300
   550 IF C$="MEL" THEN GOTO 4400
   560 IF C$="INS" THEN GOTO 4600
   570 IF C$="ATT" OR C$="KIL" THEN GOTO 4700
   580 IF C$="EXC" OR C$="SWA" THEN GOTO 7000
   590 IF C$="FOR" THEN GOTO 7050
   600 IF C$="WAV" THEN GOTO 7200
   980 PRINT "I DO NOT UNDESRTAND WHAT"
   981 GOSUB S
   982 PRINT "À";A$;"À IS."
   990 GOTO M
  1000 LET C$=C$(1)
  1010 FOR Z=1 TO 4
  1020 IF E$(LN)(Z)=C$ THEN GOTO 1060
  1030 NEXT Z
  1035 IF (P(23)<>99 OR LAMP=0) AND LN>15 THEN GOTO 1081 
  1040 PRINT "I CANT GO THERE."
  1050 GOTO M
  1060 LET TV=(Z-1)*2+1
  1070 LET LN=VAL D$(LN)(TV TO TV+1)
  1080 GOTO 10
  1081 PRINT "YOU FELL IN THE DARK AND BROKE"
  1082 GOSUB S
  1083 PRINT "YOUR NECK,SO SORRY."
  1085 GOTO 2900
  1100 PRINT "I AM CARRYING :"
  1105 IF IC=0 THEN GOTO 1150
  1110 FOR Z=1 TO NO
  1120 IF P(Z)=99 THEN PRINT AT 21,USR 16514;O$(Z)
  1130 NEXT Z
  1140 GOTO M
  1150 GOSUB S
  1160 PRINT "NOTHING AT ALL."
  1170 GOTO M
  1200 PRINT "I CANT DO THAT...YET."
  1210 GOTO M
  1220 PRINT "I CANT DO THAT."
  1230 GOTO M
  1240 PRINT "NOTHING HAPPENS."
  1250 GOTO M
  2000 IF IC<8 THEN GOTO 2010
  2001 PRINT "MY HANDS ARE FULL."
  2002 GOTO M
  2010 GOSUB CH
  2011 IF P(Z)<>99 THEN GOTO 2020
  2012 PRINT "I ALREADY HAVE."
  2013 GOTO M
  2020 IF P(Z)=LN THEN GOTO 2030
  2021 PRINT "IT IS NOT HERE."
  2022 GOTO M
  2030 IF G$(Z)="Y" THEN GOTO 2040
  2031 PRINT "I CANT."
  2032 GOTO M
  2040 IF ((Z=3 AND SW=0) OR (Z=4 AND SW=1)) AND LN=26 THEN GOTO 2043
  2041 GOTO 2049
  2043 PRINT "THE WEIGHT IMBALANCE ON THE"
  2044 GOSUB S
  2045 PRINT "PEDASTOL RELEASES A CLOUD OF"
  2046 GOSUB S
  2047 PRINT "DEADLY GAS."
  2048 GOTO 2900
  2049 LET P(Z)=99
  2050 LET IC=IC+1
  2060 PRINT "OK."
  2070 GOTO DL
  2100 GOSUB CH
  2110 IF P(Z)=99 THEN GOTO 2140
  2120 PRINT "I HAVE NOT GOT IT."
  2130 GOTO M
  2140 LET P(Z)=LN
  2150 LET IC=IC-1
  2160 GOTO OK
  2500 GOSUB CH
  2505 IF P(Z)<>LN AND P(Z)<>99 THEN GOTO 1200
  2510 PRINT "I SEE"
  2520 GOSUB S
  2530 LET R$="NOTHING SPECIAL"
  2531 IF X$<>"FEN" OR P(8)<>0 THEN GOTO 2540
  2532 PRINT "A LOOSE WIRE"
  2533 LET P(8)=LN
  2534 GOTO DL
  2540 IF X$="GOB" THEN LET R$="AN ENGRAVING : ÀMELT MEÀ"
  2550 IF X$="SWO" THEN LET R$="THAT IT IS VERY SHARP"
  2560 IF X$="CRY" THEN LET R$="A GOBLET AND A FURNACE"
  2570 IF X$="MAC" THEN LET R$="A SLOT"
  2580 IF X$="FUR" THEN LET R$="THAT IT IS VERY HOT"
  2590 IF X$="SKU" OR X$="STA" OR X$="RUB" THEN LET R$="THAT IT IS PART OF THE SCEPTER"
  2680 PRINT R$;"."
  2685 IF X$="BRI" THEN GOTO DL
  2690 GOTO M
  2700 LET P=0
  2701 IF P(35)<>99 THEN GOTO 2710
  2702 PRINT "YOU HAVE ALL OF THE PIECES."
  2703 GOTO M
  2710 LET P=P+(1 AND P(1)=99)+(1 AND P(2)=99)+(1 AND P(3)=99)
  2720 PRINT "YOU HAVE ";P;" PIECE";("S" AND P<>1);" OF THE SCEPTER"
  2730 GOTO M
  2760 PRINT "YOU HAVE USED ";TU;" TURN";("S" AND TU>1);"."
  2770 GOTO M
  2800 GOSUB CH
  2801 IF X$<>"BOA" THEN GOTO CD
  2802 IF LN<>5 THEN GOTO NY
  2803 LET LN=8
  2804 GOTO OK
  2810 GOSUB CH
  2811 IF X$<>"FEN" THEN GOTO 2815
  2812 IF LN<>3 THEN GOTO NY
  2813 LET LN=7
  2814 GOTO OK
  2815 IF X$<>"PIT" OR LN<>20 THEN GOTO CD
  2816 PRINT "YOU FALL TO YOUR DEATH."
  2817 GOTO 2900
  2820 GOSUB CH
  2821 IF X$="ROP" THEN GOTO 2830
  2822 IF X$<>"TRE" THEN GOTO CD
  2823 IF O$(15)(1)<>"C" THEN GOTO 2826
  2824 PRINT "ITS TOO LATE FOR THAT."
  2825 GOTO M
  2826 IF LN<>4 THEN GOTO NY
  2827 LET LN=6
  2828 GOTO OK
  2830 IF LN<>28 THEN GOTO NY
  2831 LET LN=29
  2832 GOTO OK
  2840 GOSUB CH
  2841 IF P(Z)<>99 THEN GOTO CD
  2842 IF X$<>"BOO" OR P(12)<>0 THEN GOTO NH
  2843 PRINT "SOMETHING FALLS TO THE FLOOR."
  2844 LET P(12)=LN
  2845 GOTO DL
  2850 GOSUB CH
  2851 IF P(Z)<>99 OR LN<>5 THEN GOTO NY
  2852 IF Z=13 THEN GOTO 2855
  2853 PRINT "IT IS NOW VERY CLEAN."
  2854 GOTO M
  2855 LET P(13)=0
  2856 LET P(14)=99
  2857 PRINT "THE MUD WASHES OFF THE BALL....."
  2858 GOSUB S
  2859 GOTO 1100
  2860 GOSUB CH
  2861 IF X$<>"TRE" THEN GOTO CD
  2862 IF P(6)<>99 OR LN<>4 OR O$(15)(1)="C" THEN GOTO NY
  2863 LET O$(15)="CHOPPED TREE"
  2864 PRINT "TIMBER..."
  2865 GOTO DL
  2870 GOSUB CH
  2871 IF P(Z)<>LN THEN GOTO NY
  2872 IF O$(17)(1)<>"B" AND X$="GAT" THEN GOTO 2875
  2873 PRINT "OUCH,MY FOOT."
  2874 GOTO M
  2875 PRINT "IT FALLS TO THE FLOOR."
  2876 LET O$(17)="BROKEN GATE"
  2877 LET E$(LN)="NE"
  2878 GOSUB S
  2879 PRINT "I CAN NOW GO EAST."
  2880 GOTO DL
  2890 GOSUB CH
  2891 IF P(Z)<>LN AND P(Z)<>99 THEN GOTO NY
  2892 IF X$<>"BEL" THEN GOTO NH
  2893 PRINT "BUZZ....."
  2894 GOSUB S
  2895 PRINT "IM ELECTROCUTED."
  2900 GOSUB S
  2905 PRINT "THE GAME IS OVER."
  2910 GOSUB S
  2920 PRINT "DO YOU WISH TO PLAY AGAIN? (Y/N)"
  2925 GOSUB S
  2930 GOSUB 4
  2935 IF C$(1)="Y" THEN GOTO 9000
  2940 IF C$(1)="N" THEN STOP 
  2945 GOTO 2910
  2950 GOSUB CH
  2951 IF P(Z)<>LN THEN GOTO CD
  2952 IF X$="CHE" THEN PRINT "HOW?"
  2953 IF X$="CHE" THEN GOTO M
  2954 IF X$<>"DOO" THEN GOTO CD
  2955 IF LN<>10 OR P(12)<>99 OR O$(18)(1)<>"D" THEN GOTO NY
  2956 LET O$(18)="UNLOCKED DOOR"
  2957 GOTO OK
  2960 GOSUB CH
  2961 IF X$<>"LAM" THEN GOTO CD
  2962 IF P(23)<>99 OR LAMP=1 THEN GOTO NY
  2963 LET LAMP=1
  2964 LET O$(23)="LIT LAMP"
  2965 GOTO OK
  3100 GOSUB CH
  3110 IF X$<>"SCR" THEN GOTO CD
  3120 IF P(Z)<>99 THEN GOTO NY
  3130 PRINT "ZAPP..."
  3135 LET LN=16
  3140 GOTO DL
  3300 IF F$="F" THEN PAUSE 100
  3305 FOR D=1 TO 50
  3310 NEXT D
  3320 GOTO 10
  3800 GOSUB CH
  3810 IF X$<>"SCE" THEN GOTO CD
  3820 IF P(1)=99 AND P(2)=99 AND P(3)=99 THEN GOTO 3830
  3821 PRINT "YOU HAVE NOT GOT ALL THE PIECES"
  3822 GOTO M
  3830 IF P(35)<>0 THEN GOTO NY
  3840 LET P(1)=0
  3850 LET P(2)=0
  3860 LET P(3)=0
  3870 LET P(35)=99
  3880 LET IC=IC-2
  3890 GOTO 1100
  4000 GOSUB CH
  4001 IF X$<>"ACO" AND X$<>"DIA" THEN GOTO CD
  4002 IF P(Z)<>99 THEN GOTO NY
  4003 IF X$="DIA" THEN GOTO 4012
  4004 IF P(24)=0 OR LN<>27 THEN GOTO NY
  4005 PRINT "THE DEMON TAKES IT AND RUNS OFF."
  4006 LET P(Z)=0
  4007 LET P(24)=0
  4008 LET E$(27)="WE"
  4009 GOSUB 4030
  4010 PRINT "I CAN NOW GO EAST."
  4011 GOTO DL
  4012 IF P(7)=0 OR LN<>25 THEN GOTO NY
  4013 PRINT "THE DRAGON IS NOW VERY HAPPY."
  4014 LET O$(33)="HAPPY DRAGON"
  4015 LET P(Z)=0
  4016 LET E$(25)="WE"
  4017 GOTO 4009
  4020 GOSUB CH
  4021 IF X$<>"CRY" THEN GOTO CD
  4022 IF P(Z)<>99 THEN GOTO NY
  4023 IF LN<>20 THEN GOTO NH
  4024 PRINT "I SLOWLY FLOAT ACROSS THE PIT..."
  4025 LET LN=21
  4026 GOTO DL
  4030 LET IC=IC-1
  4032 GOSUB S
  4034 RETURN 
  4050 GOSUB CH
  4055 IF X$<>"WHE" THEN GOTO CD
  4060 IF P(Z)<>99 THEN GOTO NY
  4065 IF LN=17 THEN GOTO 4100
  4070 PRINT "THE WHEEL ROLLS FOR A WHILE....."
  4072 FOR D=1 TO 25
  4074 NEXT D
  4076 IF F$="F" THEN PAUSE 100
  4080 GOSUB S
  4085 PRINT "AND FALLS OVER."
  4086 LET IC=IC-1
  4087 LET P(Z)=LN
  4088 GOTO M
  4100 IF O$(26)(1)="B" THEN GOTO 4108
  4101 PRINT "THE WHEEL ROLLS AWAY."
  4102 GOTO 4135
  4108 PRINT "THE WHEEL ROLLS AWAY AND YOU"
  4109 GOSUB S
  4110 PRINT "HEAR A SQUELCHING SOUND TO THE"
  4115 GOSUB S
  4120 PRINT "SOUTH."
  4125 LET O$(26)="FLAT SPIDER"
  4130 LET E$(18)="NS"
  4135 LET IC=IC-1
  4140 LET P(10)=18
  4141 IF F$="F" THEN PAUSE 100
  4145 GOTO DL
  4200 PRINT "OK."
  4210 GOSUB S
  4220 PRINT "À";B$;"À."
  4230 GOSUB S
  4240 IF LN<>21 OR P(29)=0 OR X$<>"HEL" THEN GOTO NH
  4250 PRINT "THE GHOST SAYS :"
  4255 GOSUB S
  4260 PRINT "ÀWAVE THE STAFF BY THE FALLEN"
  4265 GOSUB S
  4270 PRINT "OAK.À AND VANISHES."
  4280 LET P(29)=0
  4290 GOTO DL
  4300 IF X$<>"LOC" THEN GOTO CD
  4301 IF LN<>19 OR P(8)<>99 OR O$(27)(1)="O" THEN GOTO NY
  4302 PRINT "THE CHEST SPRINGS OPEN."
  4303 LET O$(27)="OPEN CHEST"
  4304 LET P(2)=LN
  4305 GOTO DL
  4400 GOSUB CH
  4401 IF P(Z)<>99 OR LN<>23 THEN GOTO NY
  4402 IF X$<>"GOB" THEN GOTO 4410
  4403 LET O$(21)="GOLD COIN"
  4404 LET N$(21)="COI"
  4405 PRINT "SOMETHING HAPPENS."
  4406 LET IC=IC-1
  4407 LET P(Z)=LN
  4408 GOTO DL
  4410 PRINT "IT VANISHES IN A PUFF OF SMOKE."
  4411 LET P(Z)=-1
  4412 LET IC=IC-1
  4413 GOTO M
  4500 PRINT "NO THANKS."
  4510 GOTO M
  4600 GOSUB CH
  4610 IF X$<>"COI" THEN GOTO CD
  4620 IF LN<>22 OR P(Z)<>99 THEN GOTO NY
  4630 LET P(Z)=LN
  4640 LET O$(Z)="SCROLL"
  4650 LET N$(Z)="SCR"
  4660 LET IC=IC-1
  4670 GOTO OK
  4700 GOSUB CH
  4705 IF X$<>"DOG" THEN GOTO CD
  4710 IF LN<>24 OR O$(32)(1)<>"F" THEN GOTO NY
  4715 IF P(20)=99 THEN GOTO 4720
  4716 PRINT "I WILL NEED SOMETHING SHARP."
  4717 GOTO M
  4720 LET O$(32)="DEAD DOG"
  4725 LET E$(LN)="NE"
  4726 PRINT "WITH A BLOW OF THE SWORD THE DOG"
  4727 GOSUB S
  4728 PRINT "KEELS OVER."
  4729 GOSUB S
  4730 PRINT "I CAN NOW GO EAST."
  4735 GOTO DL
  5000 FOR Z=1 TO NO
  5010 IF N$(Z)=X$ THEN RETURN 
  5020 NEXT Z
  5030 PRINT "I DO NOT KNOW WHAT À";B$;"À IS."
  5040 GOTO M
  5500 FOR Z=1 TO LEN C$
  5510 IF C$(Z)=" " THEN GOTO 5600
  5520 NEXT Z
  5530 LET A$=C$
  5540 LET C$=C$( TO 3)
  5550 RETURN 
  5600 LET A$=C$( TO Z-1)
  5610 LET B$=C$(Z+1 TO )
  5615 IF LEN B$<6 OR LEN A$<3 THEN GOTO 980
  5620 LET C$=A$( TO 3)
  5630 LET X$=B$( TO 3)
  5640 LET B$=B$( TO 6)
  5650 RETURN 
  6000 GOSUB CH
  6001 IF X$<>"DOO" THEN GOTO 6010
  6002 IF LN<>10 THEN GOTO NY
  6003 IF O$(18)(1)="D" THEN PRINT "ITS LOCKED."
  6004 IF O$(18)(1)="O" THEN PRINT "IT ALREADY IS."
  6005 IF O$(18)(1)="D" OR O$(18)(1)="O" THEN GOTO M
  6006 LET O$(18)="OPEN DOOR"
  6007 PRINT "I CAN NOW GO SOUTH."
  6008 LET E$(10)="WS"
  6009 GOTO DL
  6010 IF X$<>"CHE" THEN GOTO CD
  6011 IF LN<>19 OR O$(27)(1)="O" THEN GOTO NY
  6012 PRINT "IT IS SHUT TIGHT AND LOCKED."
  6013 GOTO M
  6100 GOSUB CH
  6101 IF X$<>"PAN" THEN GOTO CD
  6102 IF LN<>14 OR O$(22)(1)="O" THEN GOTO NY
  6103 LET O$(22)="OPEN PANEL"
  6104 PRINT "I CAN NOW GO DOWN."
  6105 LET E$(14)="NED"
  6106 GOTO DL
  7000 GOSUB CH
  7010 IF X$<>"RUB" THEN GOTO CD
  7020 IF LN<>26 OR SW=1 THEN GOTO NY
  7030 PRINT "WHAT FOR?"
  7040 GOTO M
  7050 GOSUB CH
  7060 IF LN<>26 OR SW=1 THEN GOTO NY
  7070 IF P(Z)<>99 THEN GOTO NY
  7080 IF X$="DIR" THEN GOTO 7100
  7081 PRINT "NOT THE RIGHT WEIGHT."
  7082 GOSUB S
  7089 GOTO 2043
  7100 LET P(3)=99
  7110 LET P(Z)=LN
  7120 LET SW=1
  7130 GOTO OK
  7200 GOSUB CH
  7205 IF P(Z)<>VAL "99" THEN GOTO NY
  7210 IF LN<>VAL "4" OR O$(15)(1)="O" OR X$<>"SCE" THEN GOTO NH
  7220 PRINT AT PI-PI,PI-PI;
  7225 LET CL=USR VAL "16539"
  7226 PRINT AT PI-PI,PI-PI;"YOU ARE TELEPORTED TO THE PALACE",," OF THE EMPEROR AND MADE A HERO",,,"    FOR FINDING THE STAFF."
  7230 PRINT ,,"CONGRATULATIONS.YOU HAVE BEATEN THE ADVENTURE."
  7240 PRINT "ª®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®¬"
  7250 GOTO VAL "2900"
  7500 LET R$="TRY EXAMINING THINGS."
  7510 IF LN=VAL "3" THEN LET R$="WHATS OVER THE FENCE?"
  7520 IF LN=VAL "27" THEN LET R$="DEMONS LIKE NUTS."
  7530 IF LN=VAL "21" THEN LET R$="SAY SOMETHING THEN."
  7540 IF LN=VAL "26" THEN LET R$="THINGS MUST BE PROPERLY BALANCED."
  7550 IF P(10)=VAL "99" THEN LET R$="WHAT DO WHEELS DO?"
  7560 PRINT R$
  7570 GOTO M
  8000 PRINT "PRESS ÀNEWLINEÀ WHEN READY."
  8010 GOSUB S
  8020 GOSUB 4
  8030 SAVE "ADVENTURe"
  8040 GOSUB 9500
  8050 GOTO 9800
  9000 GOSUB VAL "9500"
  9010 LET F$="S"
  9070 LET IC=1
  9080 LET TU=0
  9115 LET LN=1
  9117 LET LAMP=0
  9118 LET SW=0
  9120 LET G$="YYYYNYYYNYYYYYNYNNNYYYYNNNNNNNNNNNY"
  9130 LET P$="2900269905080800030707000200040609101012131415272818192021232224252600"
  9140 FOR Z=1 TO NO
  9150 LET Z1=VAL "2*Z-1"
  9160 LET P(Z)=VAL P$(Z1 TO Z1+1)
  9170 NEXT Z
  9200 LET O$(15)="OAK TREE"
  9210 LET O$(17)="GATE"
  9220 LET E$(9)="N"
  9230 LET O$(18)="DOOR"
  9240 LET E$(10)="W"
  9250 LET O$(22)="PANEL"
  9260 LET O$(21)="GOLD GOBLET"
  9270 LET N$(21)="GOB"
  9280 LET E$(14)="NE"
  9290 LET O$(23)="LAMP"
  9300 LET E$(27)="W"
  9310 LET O$(33)="SAD DRAGON"
  9320 LET O$(26)="BIG SPIDER"
  9330 LET E$(18)="N"
  9340 LET O$(27)="ANCIENT CHEST"
  9370 LET E$(24)="N"
  9380 LET O$(32)="FIERCE DOG"
  9490 GOTO 9800
  9500 CLS 
  9501 SLOW 
  9502 POKE 16418,0
  9505 PRINT "ADVENTURE NUMBER 1.ÀTHE SCEPTERÀ"
  9510 PRINT "¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿"
  9520 PRINT "  WITH THIS PROGRAM YOU MAY HAVEAN ÀADVENTUREÀ WITHOUT HAVING TOLEAVE THE COMFORT OF YOUR CHAIR."
  9530 PRINT ,,"  THE COMPUTER WILL ACT AS YOUR GUIDE AND WILL RESPOND TO ONE ORTWO WORD ENGLISH PHRASES,SUCH AS"
  9540 PRINT "ÀGET SWORDÀ,ÀNORTHÀ,ÀOPEN BOXÀ."
  9550 PRINT ,,"SOME USEFUL COMMANDS ARE :"
  9560 PRINT "ÀSAVE GAMEÀ,ÀINVENTORYÀ,ÀGETÀ,  ÀDROPÀ,ÀNORTHÀ,ÀSOUTHÀ,ÀEASTÀ,  ÀWESTÀ";
  9570 PRINT ",ÀEXAMINEÀ AND ÀTIMEÀ."
  9580 PRINT ,,"  DIRECTIONS MAY BE ABBRIEVIATEDTO ONLY THE FIRST LETTER EG. ÀNTAB FOR ÀNORTHÀ."
  9590 PRINT "  YOUR GUIDE KNOWS MORE THAN 80 WORDS."
  9600 PRINT AT 23,0;"««author««‰««simon««wadsworth«««"
  9700 RETURN 
  9800 PRINT AT 22,4;"PRESS ÀNEWLINEÀ TO PLAY"
  9810 GOSUB 4
  9820 PRINT AT 22,0;"                                "
  9980 PRINT AT 23,0;"««‹cŒ«˜ Ÿ™«‘«bug«byte«software««"
  9990 GOTO 10
  9998 SAVE "ADVENTURe"
  9999 GOTO 9000
I think the attachment is more accurate. There might be errors in text editor settings.
Attachments
ADVENTURE_[ZX81 BASIC TEXT CODES].txt
(16.71 KiB) Downloaded 26 times
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 980
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

pasayten wrote: Thu Jan 26, 2023 10:15 am No wimps here... OCEC Electric Rate Calulator... Support program to https://methow.chewack.com/getmybill2022.php

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>My Methow Information Web Pages</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<meta name="keywords" content="">
	<meta name="description" content="">
	<!-- master default -->
<link rel="stylesheet" type="text/css" href="mymetbill2.css" />

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="https://methow.chewack.com/getbill_function24mo2022.js"></script>


<?php
echo '<script type="text/javascript">';
echo 'google.load("visualization", "1", {packages:["corechart","gauge"]});';
echo 'var qsParm = new Array();';
echo 'var kary = new Array();';
echo 'var dary = new Array();';
echo 'var nary = new Array();';

echo 'var pary = new Array();';
echo 'var ravg = new Array();';
echo 'var crb = new Array();';
echo 'var prb = new Array();';
echo 'var chb = new Array();';
echo 'var cbill = 0.0;';
echo 'var pbill = 0.0;';
echo 'var chgbill = 0.0;';
echo 'var kavg = 0;';
echo 'var crank = 0;';
echo 'var kmax = 0;';
echo 'var dmax = 0;';
echo 'var grank = 0;';
echo 'var xtemp = 0.0;';
echo 'var origrate = 0;';
echo 'var newcls = "G1";';
echo 'var oldcls = "Residential";';
echo 'var mary = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];';
// ***********************************
// set default starts
// ***********************************
echo 'var enddat = 2212;';
echo 'var maxrank = 4000;';
$enddat = "2212";


if(isset($_GET['recsel'])) $xkey = $_GET['recsel'];
if(isset($_GET['enddat'])) $enddat = $_GET['enddat'];
$fd = fopen("membertool.log", "a");
$msg = "[" . date("Y/m/d h:i:s", time()) . "] ";
$msg = $msg.' RateCalc Member key: '.$xkey.'/';
$msg = $msg.' End date: '.$enddat.'/';
foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) {
  if (array_key_exists($key, $_SERVER) === true) {
    foreach (explode(',', $_SERVER[$key]) as $ip) {
      if (filter_var($ip, FILTER_VALIDATE_IP) !== false) {
          $msg = $msg.$ip.'/';
      }
    }
  }
}
fwrite($fd, $msg . "\n");
fclose($fd);

 // Otherwise we connect to our Database
$hostname = 'localhost';
$username = '????????';
$password = '????????';
$database = '????????';

$link = mysqli_connect($hostname, $username, $password) or die("Unable to Connect to '$hostname'");
mysqli_select_db($link, $database) or die("Could not open the db '$database'");

 //Now we search for our search term, in the field the user specified
$query="SELECT * FROM mem_tool2022 WHERE member_fake = ";
$query=$query.$xkey;
//$query=$query."'";
//$data = mysql_query($query);
$data = mysqli_query($link, $query);

//echo "data query=".$query.":<br>";
//echo $data;
 //And we display the results
 $i =0;
 // ************************************
 // arrays set for 2001 thru 2212...
 // ************************************
 $kary=array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1);
 $dary=array(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);
 $ravg=array(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);
 $totk = 0.0;
 $totd = 0.0;

 while($result = mysqli_fetch_array( $data ))

 {
 $i = $i + 1;
 // Get all regular stuff for meter
 if ($i == 1)
   {
   $cls = $result['class'];
   echo 'crank = '.$result['rank'].';';
   //echo 'debug';
   //echo $result['kwhavg_2022'];
   //echo $result['rank'];
   //echo 'debug';

   echo 'kavg = '.$result['kwhavg_2022'].';';
   //echo 'totk = '.$result['tot_kwh'].';';
   //echo 'totd = '.$result['tot_kw'].';';
   //echo 'totbil = '.$result['tot_rev'].';';
   echo 'phase = '.$result['rate'].';';
   echo 'cur_rate = '.$result['cur_rate'].';';
   // WAS COMMENTED OUT
   echo 'origrate = '.$result['cur_rate'].';';
   $gcls = $result['kwhavg_2022'];
   $xnm = "G1 (0-1200 avg kwh/mth)";
   if ( $gcls > 1200 ) $xnm ="G2 (1200-5000 avg kwh/mth)";
   if ( $gcls > 5000 ) $xnm ="G3 (5000-16,667 avg kwh/mth)";
   if ( $gcls > 16667 ) $xnm ="G4 (Abv 16,667 avg kwh/mth)";
   echo 'newcls = "'.$xnm.'";';
   }
 // Now load kwh/kw arrays
 $xd = $result['billyrmo'];
 $xkwh = $result['kwh'];
 $xdem = $result['kwdemand'];
 if ($xd < 2101) {
   $xd = $xd - 2000;
   $xd = $xd -1;
 } elseif ($xd < 2201) {
   $xd = $xd - 2100;
   $xd = $xd +11;
 } else {
   $xd = $xd - 2200;
   $xd = $xd +23;
 }




 //echo 'xd:'.$xd.' kwh:'.$xkwh.' <br>';
 $kary[$xd] = $xkwh;
 $dary[$xd] = $xdem;
 }

//  Calculate annual running averages
 $rtot = 0;
 $rnum = 0;
 for ($i=11; $i<=35; $i++)
   {
   if ($kary[$i] > -1) {
     // Have value, do running average
     $j = $i - 11;
     $rtot = 0;
	 $rnum = 0;
     for ($j=$i-11; $j<=$i; $j++)
     {
        if ($kary[$j] > -1)
        {
           $rtot = $rtot + $kary[$j];
           $rnum = $rnum + 1;
        }
     }
     $ravg[$i] = $rtot / $rnum;
     //echo 'i: '.$i.' kwh:'.$ravg[$i].' <br>';
   }
 }




 // Now set up annual values for chosen end month
 // VERIFY OFFSET data starts at 1201, not 1101

 if ($enddat == 2112) $istrt = 12;
 if ($enddat > 2112)  $istrt = $enddat - 2200 +12;
 if ($enddat > 2212)  $istrt = $enddat - 2300 +24;
 //if ($enddat == 1309) $istrt = 12;
 //if ($enddat > 1212)  $istrt = $enddat - 1300 +12;
 //if ($enddat > 1312)  $istrt = $enddat - 1400 +12;

 for ($i=0; $i<=11; $i++)
   {
   $ioff = $i + $istrt;
   if ($kary[$ioff] == -1)
   {
     echo 'kary['.$i.'] = -1;';
     echo 'dary['.$i.'] = 0.0;';
     echo 'ravg['.$i.'] = 0.0;';
   } else {
     $totk = $totk + $kary[$ioff];
     $totd = $totd + $dary[$ioff];
     echo 'kary['.$i.'] = '.$kary[$ioff].';';
     echo 'dary['.$i.'] = '.$dary[$ioff].';';
     echo 'ravg['.$i.'] = '.round($ravg[$ioff],1).';';
   }

   if ($kary[$ioff-12] == -1)
   {
     echo 'pary['.$i.'] = -1;';
   } else {
     echo 'pary['.$i.'] = '.$kary[$ioff-12].';';
   }

   }
 echo 'totk = '.$totk.';';
 echo 'totd = '.$totd.';';
 echo 'enddat = '.$enddat.';';
 //$xkey = 792194002;
 echo 'frec = '.$xkey.';';
 $mrec = ( $xkey -1994 ) / 4;
 echo 'mrec = '.$mrec.';';


echo 'google.setOnLoadCallback(getMemberData);';
//echo 'getMemberData();';

echo '</script>';
?>


</head>
<body>
<div style="float: left; width: 800px;border:1px solid black;">

<div style="float: left; clear: left; width: 327px; height: 110px; border-right:1px solid black;border-bottom:1px solid black;border-top:1px solid black;background: rgb(200,229,238);">
<center id="cursive18">My Methow<br>
Electrical<br>
Information</b></center>
</div>

<div style="float: right; width: 470px; height: 110px; border:1px solid black;background: rgb(200,229,238);">
<img src="https://methow.chewack.com/images/mymetlogo3.jpg" />
</div>

<div id="body" style="width:800px;">


<p id="mediumcursive"><center><b>Your OCEC electrical bill summary analysis</b></center><br>

<div style="width:800;height:320px;">
<div id="chart_div" style="width:580;height:320px;float:left;margin-left:10px;border:1px solid black;">
<br><br><span style="width:580px;text-align:center;float:left;">... loading data ...</span></div>

<div style="width:170px;height:240px;float:left;margin-left:20px;margin-top:0px;border:1px solid black;">

<div style="width:170px;height:40px;margin-top:5px;">
<span style="width:165px;text-align:center;float:left;"><p class="txsmall">Your Average Monthly<br>kwh Usage Rank</p></span>
</div>

<div id="gage_div" style="width:160px;height:150px;margin-left:10px;"></div>

<div style="width:170px;height:40px;margin-top:0px;">
<span style="width:165px;text-align:center;float:left;"><p class="txsmall">Scale of 0-100<br> for 4000 meters @ OCEC</p></span>
</div>

<div style="width:170px;height:75px; margin-top:10px; border:1px solid black;">
<span style="width:165px;text-align:center;float:left;"><p class="txsmall">
Choose dates to analyze:<br>
<form name="disptype" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<select name="enddat" style="float:left;height:22px;margin-left:8px;margin-top:5px;background:rgb(200,229,238);">
<?php
$xx = "";
if ($enddat == 2112) $xx = "selected";
echo '<option value="2112" '.$xx.'>Jan 2021-Dec 2021</option>';
$xx = "";
if ($enddat == 2209) $xx = "selected";
echo '<option value="2209" '.$xx.'>Oct 2021-Sep 2022</option>';
$xx = "";
if ($enddat == 2212) $xx = "selected";
echo '<option value="2212" '.$xx.'>Jan 2022-Dec 2022</option>';



echo '</select><br>';
echo '<input style="margin-left:0px;line-height:18px;text-align:center;background: rgb(200,229,238);" type="submit" value="Submit New Dates" />';
echo '<input name="recsel" type="hidden" value="'.$xkey.'" />';


//Pulled out of rate summary
//Energy Chg:
//<span id="pener">0.00</span>
//&nbsp; &nbsp; Inc kwh:
//<span id="ptier1">0</span>
//<br>








?>

</form>
</p></span>
</div>

</div>

</div>

<div style="width:770px;margin-top:20px;margin-left:20px;">

<p class="tzsmall">
Member Account: <b id="mrec">0</b> Data Record: <b id="frec">0</b><br>
<b>Summary stats are for the 2022 base year:</b> Your monthly avg kwh was <b id="mavg">0</b> and ranked <b id="krank">0</b> from the highest of the approx 4000
OCEC meter accounts.  This is converted to <b id="grk">0</b> out of 100 to display on the gage.
Under the current policies, your average monthly kwh usage would place you in the
<b>General Service Class <span id="newgx">G1</span></b> and
<b>Rate Code <span id="ratecd">1</span></b>.
Your rate class is currently set to <b id="currate">00</b>.
Your current average kwh usage
<span id="classchg">and existing rate meet policies. You might check if a higher rate code would save you money</span>.

<br>
<b>Summary for the selected dates:</b> Your total energy usage for the 12 month period was <b id="tkwh">0</b> kwh.   Your peak monthly usage was <b id="mxkwh">0</b> kwh
and your peak monthly demand was <b id="mxkw">0</b> kw. Following is a summary of your monthly usage and billings using the 2021/22 rates which you can compare with the
a new rate class and other utility/coop/class rates.
Also note yard lights/local taxes have not been included.
</p><br>
<br>
<div style="width:520px;float:left;margin-top:0px;margin-left:0px;border:0px solid black;">

<table class="billtab" border="1">
<tr>
<th>Month</th>
<th>Total kwh</th>
<th>Dem kw</th>
<th id="g2015">2021 xx Rate</th>
<th>Compare Rate</th>
<th>% Change</th>
</tr>

<tr><td id="m1" style="text-align:left;">Jan</td>
<td id="k1">0</td>
<td id="kw1">0</td>
<td id="o1">0.00</td>
<td id="n1">0.00</td>
<td id="c1">0.0%</td></tr>

<tr><td id="m2" style="text-align:left;">Feb</td>
<td id="k2">0</td>
<td id="kw2">0</td>
<td id="o2">0.00</td>
<td id="n2">0.00</td>
<td id="c2">0.0%</td></tr>

<tr><td id="m3" style="text-align:left;">Mar</td>
<td id="k3">0</td>
<td id="kw3">0</td>
<td id="o3">0.00</td>
<td id="n3">0.00</td>
<td id="c3">0.0%</td></tr>

<tr><td id="m4" style="text-align:left;">Apr</td>
<td id="k4">0</td>
<td id="kw4">0</td>
<td id="o4">0.00</td>
<td id="n4">0.00</td>
<td id="c4">0.0%</td></tr>

<tr><td id="m5" style="text-align:left;">May</td>
<td id="k5">0</td>
<td id="kw5">0</td>
<td id="o5">0.00</td>
<td id="n5">0.00</td>
<td id="c5">0.0%</td></tr>

<tr><td id="m6" style="text-align:left;">Jun</td>
<td id="k6">0</td>
<td id="kw6">0</td>
<td id="o6">0.00</td>
<td id="n6">0.00</td>
<td id="c6">0.0%</td></tr>

<tr><td id="m7" style="text-align:left;">Jul</td>
<td id="k7">0</td>
<td id="kw7">0</td>
<td id="o7">0.00</td>
<td id="n7">0.00</td>
<td id="c7">0.0%</td></tr>

<tr><td id="m8" style="text-align:left;">Aug</td>
<td id="k8">0</td>
<td id="kw8">0</td>
<td id="o8">0.00</td>
<td id="n8">0.00</td>
<td id="c8">0.0%</td></tr>

<tr><td id="m9" style="text-align:left;">Sep</td>
<td id="k9">0</td>
<td id="kw9">0</td>
<td id="o9">0.00</td>
<td id="n9">0.00</td>
<td id="c9">0.0%</td></tr>

<tr><td id="m10" style="text-align:left;">Oct</td>
<td id="k10">0</td>
<td id="kw10">0</td>
<td id="o10">0.00</td>
<td id="n10">0.00</td>
<td id="c10">0.0%</td></tr>

<tr><td id="m11" style="text-align:left;">Nov</td>
<td id="k11">0</td>
<td id="kw11">0</td>
<td id="o11">0.00</td>
<td id="n11">0.00</td>
<td id="c11">0.0%</td></tr>

<tr><td id="m12" style="text-align:left;">Dec</td>
<td id="k12">0</td>
<td id="kw12">0</td>
<td id="o12">0.00</td>
<td id="n12">0.00</td>
<td id="c12">0.0%</td></tr>

<tr><td style="text-align:left;"><b>Total</b></td>
<td><b id="k13">0</b></td>
<td><b id="kw13">-</b></td>
<td><b id="o13">0.00</b></td>
<td><b id="n13">0.00</b></td>
<td><b id="c13">0.0%</b></td></tr>
</table>
</div>

<div style="width:250px;float:left;margin-top:0px;margin-left:0px;border:0px solid black;">
<form name="rateform" action="" >
<p class="txsmall"><b>Choose a rate to compare your bill:</b><br>
<select id="kratex" name="kratex" style="float:left;width:240px;height:22px;margin-left:0px;margin-top:10px;background:rgb(200,229,238);" onChange="newbill();">
<option value="1" selected="0">Need rate selection</option>
<option value="201"> OCEC Apr 2023 Gen Serv 1 rate</option>
<option value="202"> OCEC Apr 2023 Gen Serv 2 rate</option>
<option value="203"> OCEC Apr 2023 Gen Serv 3 rate</option>
<option value="204"> OCEC Apr 2023 Gen Serv 4 rate</option>
<option value="205"> OCEC Apr 2023 Irrigation 1P</option>
<option value="206"> OCEC Apr 2023 Irrigation 3P</option>
<option value="181"> OCEC 2021/22 Gen Serv 1 rate</option>
<option value="182"> OCEC 2021/22 Gen Serv 2 rate</option>
<option value="183"> OCEC 2021/22 Gen Serv 3 rate</option>
<option value="184"> OCEC 2021/22 Gen Serv 4 rate</option>
<option value="185"> OCEC 2021/22 Irrigation 1P</option>
<option value="186"> OCEC 2021/22 Irrigation 3P</option>
<option value="18">Big Bend residential rate (chk Nov22)</option>
<option value="15">Chelan PUD residential rate (chk Nov22)</option>
<option value="22">Columbia REA residential rate (chk Jan19)</option>
<option value="4">Colville (Avista) residential rate (chk Nov22)</option>
<option value="12">Ferry County PUD residential rate (chk Nov22)</option>
<option value="11">Inland Power residential rate (chk Nov22)</option>
<option value="19">Kittitas PUD residential rate (chk Nov22)</option>
<option value="91">Lakeview residential rate (chk Nov22)</option>
<option value="9">Nespelum Electric residential rate (chk Nov22)</option>
<option value="2">Okanogan PUD Apr 23 residential rate (chk Jan23)</option>
<option value="3">OPALCO (Island Cty) residential winter rate (chk Nov22)</option>
<option value="5">Oregon Trail Coop residential rate (chk Nov22)</option>
<option value="17">Parkland Light Coop residential rate (chk Nov22)</option>
<option value="21">Pend Oreille PUD residential rate (chk Nov22)</option>
<option value="20">Skamania residential rate (chk Nov22)</option>
<option value="10">Snohomish County PUD residential rate (chk Nov22)</option>
<option value="8">Tanner Electric residential rate (chk Nov22)</option>
<option value="200">Umatilla Electric residential rate Winter (chk Nov22)</option>
<option value="7">Western Oregon Coop residential rate (chk Nov22)</option>
</select>

<br><br>
<span style="width:150px;float:left;">Existing 12mth bill:</span>
<b id="zold" style="width:70px;float:left;text-align:right;">$0.00</b>
<br>
<span style="width:150px;float:left;">Compare 12mth bill:</span>
<b id="znew" style="width:70px;float:left;text-align:right;">$0.00</b>
<br>
<span style="width:230px;float:left;">Inc/(Dec): &nbsp;
<b id="zchg">$0.00</b>/yr or
<b id="zchgm">$0.00</b>/mth
</span><br></p>
<p class="cursive12">Rate structure used to compare:<br>
<span><b id="pcomp">OCEC current rate</b></span><br>
Base Meter 1P:
<span id="pbase">0.00</span>
&nbsp; &nbsp; 3P:
<span id="pbase3">0.00</span>
<br>
Demand Chg:
<span id="pdem">0.00</span>
&nbsp; &nbsp; Inc kw:
<span id="pdinc">0</span>
<br>
Base kwh rate:
<span id="prate1">0.0000</span>
<br>
Tier 2 rate:
<span id="prate2">0.0000</span>
&nbsp; &nbsp; Abv kwh:
<span id="ptier2">0</span>
<br>
Tier 3 rate:
<span id="prate3">0.0000</span>
&nbsp; &nbsp; Abv kwh:
<span id="ptier3">0</span>
<br>
Cost of power adj:
<span id="pkopa">0.0000</span>
</p>
<input name="kwh01" value="0" type="hidden">
<input name="kwh02" value="0" type="hidden">
<input name="kwh03" value="0" type="hidden">
<input name="kwh04" value="0" type="hidden">
<input name="kwh05" value="0" type="hidden">
<input name="kwh06" value="0" type="hidden">
<input name="kwh07" value="0" type="hidden">
<input name="kwh08" value="0" type="hidden">
<input name="kwh09" value="0" type="hidden">
<input name="kwh10" value="0" type="hidden">
<input name="kwh11" value="0" type="hidden">
<input name="kwh12" value="0" type="hidden">
<input name="kw01" value="0" type="hidden">
<input name="kw02" value="0" type="hidden">
<input name="kw03" value="0" type="hidden">
<input name="kw04" value="0" type="hidden">
<input name="kw05" value="0" type="hidden">
<input name="kw06" value="0" type="hidden">
<input name="kw07" value="0" type="hidden">
<input name="kw08" value="0" type="hidden">
<input name="kw09" value="0" type="hidden">
<input name="kw10" value="0" type="hidden">
<input name="kw11" value="0" type="hidden">
<input name="kw12" value="0" type="hidden">
<input name="kwhtot" value="0" type="hidden">
<input name="kwhavg" value="0" type="hidden">
<input name="kwtot" value="0" type="hidden">
<input name="rank" value="0" type="hidden">
<input name="mtype" value="1" type="hidden">
<input name="xphase" value="1" type="hidden">
<input name="orate" value="0" type="hidden">
<input name="enddat" value="1309" type="hidden">
</form>
</div>

</div>

<div id="footer" style="width:760px;margin-left:20px;margin-top:10px;">
<hr>
<center><p class="txxsmall">This application is provided as a free service to all members of the Okanogan
County Electric Coop<br>
Copyright January 2012 by Ray Peterson of Pasayten Consulting,
Phone: 425-239-3777, email: pasayten@yahoo.com
</p>
</center></div>
</div>
</body>
</html>

I am curious about mixing machine code with basic.

Code: Select all

# REM X
     1  REM [HEX:\
3D ]


# REM **COMPILER**
  1000  REM [HEX:\
17,17,28,34,32,35,2E,31,\
2A,37,17,17,76 ]

  1010 FAST 
  1011 LET Q=3950
  1012 LET Q1=2830
  1013 LET Q2=3320
  1014 LET Q3=3630
  1015 LET Q4=3970
  1016 LET Q5=1320
  1017 LET Q6=4
  1020 LET P=28858
  1030 LET P1=16514
  1040 GOSUB 2920
  1050 IF PEEK (P1-1)<>234 THEN GOTO Q1
  1060 IF PEEK P1=118 THEN GOTO Q1
  1070 GOSUB 2880
  1080 LET A$=""
  1090 LET A$=A$+CHR$ PEEK P1
  1100 LET P1=P1+1
  1110 IF PEEK (P1-1)<>118 THEN GOTO 1090
  1120 IF PEEK (P1+1)*256+PEEK (P1+2)=1010 THEN GOTO 3690
  1130 LET P1=P1-3
  1140 LET T$=A$( TO 2)
  1150 LET B$=A$+"      "
  1160 LET J=0
  1170 LET J=J+(T$="RE")*2170+(T$="SC")*1200+(T$="PR")*1360+(T$="GE")*1530+(T$="EN")*1620+(T$="PA")*1670+(T$="CL")*1720+(T$="MO")*1770+(T$="LE")*1890+(A$( TO 3)="GOT")*2060+(A$( TO 3)="GOS")*2130+(T$="IF")*2200+(T$="PO")*2430+(T$="UN")*2550+(T$="PL")*2580+(T$="DO")*2720
  1180 IF NOT J THEN LET J=Q1
  1190 GOTO J
  1201 IF B$(7)<>CHR$ 118 THEN GOTO Q1
  1202 LET U$="2A0C40112100EB1901F702EDB00620AF131210FC"
  1203 GOSUB Q3
  1204 GOTO Q5
  1320 LET P1=P1+8
  1330 GOTO 1050
  1360 LET B$=B$(6 TO )
  1370 IF B$(1)=CHR$ 11 THEN GOTO 1420
  1380 GOSUB Q2
  1390 LET U$="7DD7"
  1400 GOSUB Q3
  1410 GOTO Q5
  1420 GOSUB Q
  1430 LET U$="CDBA40"
  1440 GOSUB Q3
  1450 POKE P,CODE (B$(1))
  1460 GOSUB Q
  1470 IF B$(1)=CHR$ 11 THEN POKE P+1,255
  1480 LET P=P+1
  1490 IF B$(1)=CHR$ 11 THEN GOTO 1510
  1500 GOTO 1450
  1510 LET P=P+1
  1520 GOTO Q5
  1530 LET B$=B$(Q6 TO )
  1540 LET U$="CDBB02444D51142808CDBD077ECB7728023E8021004077233600"
  1550 GOSUB Q3
  1560 LET V=CODE B$(1)
  1570 IF CODE B$(2)<>118 THEN GOTO Q1
  1580 IF V<38 OR V>63 THEN GOTO Q1
  1590 LET V=(V-38)*2+130
  1600 POKE P-6,V
  1610 GOTO Q5
  1620 LET B$=B$(Q6 TO )
  1630 IF B$(1)<>CHR$ 118 THEN GOTO Q1
  1640 LET U$="CFFF"
  1650 GOSUB Q3
  1660 GOTO Q5
  1670 LET B$=B$(6 TO )
  1680 GOSUB Q2
  1690 LET U$="2B7CB520FB"
  1700 GOSUB Q3
  1710 GOTO Q5
  1720 LET B$=B$(Q6 TO )
  1730 IF B$(1)<>CHR$ 118 THEN GOTO Q1
  1740 LET U$="2A0C40161823062036002310FB1520F5010000CDF508"
  1750 GOSUB Q3
  1760 GOTO Q5
  1770 LET B$=B$(5 TO )
  1780 GOSUB Q2
  1790 GOSUB Q4
  1830 LET U$="45"
  1840 GOSUB Q3
  1850 GOSUB Q2
  1860 LET U$="4DCDF508"
  1870 GOSUB Q3
  1880 GOTO Q5
  1890 LET B$=B$(Q6 TO )
  1900 LET L=(CODE B$-38)*2+130
  1910 LET B$=B$(3 TO )
  1920 GOSUB Q2
  1930 GOSUB 3570
  1940 IF CODE B$=118 THEN GOTO 2020
  1950 LET U$="EB"
  1960 GOSUB Q3
  1970 LET S$=B$(1)
  1980 GOSUB Q
  1990 GOSUB Q2
  1991 LET N$="CD0913"
  1992 IF PEEK 4869=197 THEN LET N$="CD0513"
  2000 LET U$=(N$ AND S$="*")+("EBCDC440" AND S$="/")+("19" AND S$="+")+("EBA7ED52" AND S$="-")
  2010 GOSUB Q3
  2020 LET U$="220040"
  2030 GOSUB Q3
  2040 POKE P-2,L
  2050 GOTO Q5
  2060 LET B$=B$(5 TO )
  2070 GOSUB Q2
  2080 POKE P-3,195
  2090 LET G(N1,1)=PEEK (P-2)+PEEK (P-1)*256
  2100 LET G(N1,2)=P-2
  2110 LET N1=N1+1
  2120 GOTO Q5
  2130 LET B$=B$(6 TO )
  2140 GOSUB Q2
  2150 POKE P-3,205
  2160 GOTO 2090
  2170 LET U$="C9"
  2180 GOSUB Q3
  2190 GOTO Q5
  2200 LET B$=B$(3 TO )
  2210 GOSUB Q2
  2220 GOSUB 3570
  2230 LET U$="EB"
  2240 GOSUB Q3
  2250 LET S$=B$(1)
  2260 GOSUB Q
  2270 GOSUB Q2
  2280 IF CODE B$>37 THEN GOSUB Q
  2290 IF CODE B$<38 THEN GOSUB 3600
  2300 LET U$="A7ED52"
  2310 IF S$="<>" THEN LET U$=U$+"CA"
  2320 IF S$="=" THEN LET U$=U$+"C2"
  2330 IF S$="<" THEN LET U$=U$+"DA"
  2340 IF S$=">" THEN LET U$=U$+"D2"
  2350 LET U$=U$+"0000"
  2360 IF S$<>">" AND S$<>"=" AND S$<>"<" AND S$<>"<>" THEN GOTO Q1
  2370 GOSUB Q3
  2380 LET G(N1,2)=P-2
  2390 LET G(N1,1)=1000
  2400 LET N1=N1+1
  2410 LET A$=B$
  2420 GOTO 1140
  2430 LET B$=B$(5 TO )
  2440 GOSUB Q2
  2450 GOSUB Q4
  2490 LET U$="EB"
  2500 GOSUB Q3
  2510 GOSUB Q2
  2520 LET U$="EB73"
  2530 GOSUB Q3
  2540 GOTO Q5
  2550 LET B$=B$(3 TO )
  2560 LET U$="3EA0323040"
  2570 GOTO 2590
  2580 LET U$="3E9B323040"
  2590 GOSUB Q3
  2600 LET B$=B$(5 TO )
  2610 GOSUB Q2
  2620 LET U$="4D"
  2630 GOSUB Q3
  2640 GOSUB Q4
  2680 GOSUB Q2
  2690 LET U$="45CDB20B"
  2700 GOSUB Q3
  2710 GOTO Q5
  2720 LET B$=B$(5 TO )
  2730 GOSUB Q2
  2740 GOSUB Q4
  2771 LET U$="EB"
  2780 GOSUB Q3
  2790 GOSUB Q2
  2800 LET U$="EB732372"
  2810 GOSUB Q3
  2820 GOTO Q5
  2830 IF PEEK (P1-1)=118 THEN GOTO 3180
  2840 IF P1=16509 THEN GOTO 3180
  2850 LET P1=P1-1
  2860 GOTO 2830
  2870 SLOW 
  2880 LET L(N,1)=PEEK (P1-5)*256+PEEK (P1-4)
  2890 LET L(N,2)=P-12288
  2900 LET N=N+1
  2910 RETURN 
  2920 DIM L(100,2)
  2930 DIM G(70,2)
  2940 LET N=1
  2950 LET N1=N
  2960 LET U$="E17E23E5FEFFC8D718F601FFFFA7ED520330FAC5E1C9A6AFAC"
  2965 LET U$=U$+"FD3622002182403600237DFEBA20F8"
  2970 GOSUB Q3
  2980 RETURN 
  2990 IF N1=1 THEN RETURN 
  3000 FOR X=1 TO N1-1
  3010 LET PO=G(X,2)
  3020 LET L=G(X,1)
  3030 LET G=1
  3040 GOTO 3120
  3050 LET G=G+1
  3060 IF G=N THEN GOTO 3150
  3070 GOTO 3040
  3080 POKE PO,L(G,2)-256*INT (L(G,2)/256)
  3090 POKE PO+1,INT (L(G,2)/256)
  3100 NEXT X
  3110 RETURN 
  3120 IF L=1000 THEN IF PO-12288<=L(G,2) THEN GOTO 3080
  3130 IF L=L(G,1) THEN GOTO 3080
  3140 GOTO 3050
  3160 GOTO 3200
  3170 RETURN 
  3190 LET L=PEEK P1*256+PEEK (P1+1)
  3200 SLOW 
  3201 POKE 16418,0
  3202 PRINT AT 22,0;"*******ERROR IN ";L;"******";AT 0,0;
  3203 POKE 16418,2
  3204 LIST L
  3205 GOTO 3200
  3230 LET V=CODE B$
  3240 IF V<38 OR V>63 THEN GOTO Q1
  3250 LET V=(V-38)*2+16514
  3260 LET U$="2A"
  3270 GOSUB Q3
  3280 POKE P,V-16384
  3290 POKE P+1,64
  3300 LET P=P+2
  3310 RETURN 
  3320 LET V=1
  3330 IF CODE B$(V)>37 OR CODE B$(V)<28 THEN GOTO 3360
  3340 LET V=V+1
  3350 GOTO 3330
  3360 IF V=1 THEN GOTO 3420
  3370 LET V=VAL (B$( TO V-1))
  3380 IF V<>INT V OR V>65536 THEN GOTO Q1
  3390 GOSUB 3530
  3400 POKE P+1,INT (V/256)
  3405 LET P=P+2
  3410 RETURN 
  3420 LET U$=""
  3430 IF B$( TO 3)="TOP" THEN LET U$="2A0C4023"
  3440 GOSUB 3780
  3450 IF B$( TO 3)<>"USR" THEN GOTO 3850
  3460 LET B$=B$(Q6 TO )
  3470 GOSUB Q2
  3480 POKE P-3,205
  3490 RETURN 
  3500 IF U$="" THEN GOTO 3220
  3510 GOSUB Q3
  3520 RETURN 
  3530 LET U$="21"
  3540 GOSUB Q3
  3550 POKE P,V-256*INT (V/256)
  3560 RETURN 
  3570 IF CODE B$<28 OR CODE B$>63 THEN RETURN 
  3580 GOSUB Q
  3590 GOTO 3570
  3600 IF CODE B$<28 OR CODE B$>37 THEN RETURN 
  3610 GOSUB Q
  3620 GOTO 3600
  3630 POKE P,CODE U$*16+CODE U$(2)-476
  3640 LET U$=U$(3 TO )
  3650 LET P=P+1
  3660 IF P>=32700 THEN STOP 
  3670 IF U$="" THEN RETURN 
  3680 GOTO Q3
  3690 GOSUB 2990
  3700 LET J=P-12287
  3710 LET P=28672
  3720 LET U$="210000E5C103E52182401182701A7723137DB920F87CB820F4E136A62336AF2336AC233676E5118040A7ED52227F40E123C30304"
  3730 GOSUB Q3
  3740 LET P=J
  3750 POKE 28673,P-256*INT (P/256)
  3760 POKE 28674,INT (P/256)
  3770 RAND USR 28672
  3780 IF B$( TO 3)<>"RND" THEN RETURN 
  3790 LET U$="D92A3240545D29291929292919223240EB"
  3800 GOSUB Q3
  3810 LET B$=B$(Q6 TO )
  3820 GOSUB Q2
  3830 LET U$="EBA7ED5230FB19E5D9E1"
  3840 RETURN 
  3850 IF B$( TO Q6)<>"PEEK" THEN GOTO 3900
  3860 LET B$=B$(5 TO )
  3870 GOSUB Q2
  3880 LET U$="6E2600"
  3890 GOTO 3500
  3900 IF B$( TO Q6)<>"DEEK" THEN GOTO 3500
  3910 LET B$=B$(5 TO )
  3920 GOSUB Q2
  3930 LET U$="D55E2356EBD1"
  3940 GOTO 3500
  3950 LET B$=B$(2 TO )
  3960 RETURN 
  3970 IF B$(1)="," THEN GOTO 4000
  3980 GOSUB Q
  3990 GOTO Q4
  4000 GOSUB Q
  4010 RETURN 
This is the SILVERSOFT ZX-COMPILER Code.
Attachments
zxcompiler_[ZX81 BASIC TEXT CODES].txt
(7.49 KiB) Downloaded 23 times
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 980
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

This is what I pulled out of Avenger. I might still need to do some different character settings.

Code: Select all

# REM _3_ __:_____*_;_:_3-__(+5 > 5   
#     4 5   4 3   2 5 5 -_=   AAAAAAA
     1  REM [HEX:\
02,1F,64,00,FF,02,0E,01,\
7E,58,8A,58,97,58,99,58,\
8E,5B,1F,16,02,08,10,15,\
21,00,12,00,21,00,00,00,\
20,00,21,00,00,00,20,00,\
1F,00,00,00,1E,00,21,00,\
21,00,16,F9,14,00,00,00,\
26,26,26,26,26,26,26,26 ]


# REM Y_M__Y_M__Y M__M__E£___ _6___£ _
#     6£__$ _6:_5  6__5/_Y6Q 7X_ 4_E£
     2  REM [HEX:\
3E,05,32,82,40,3E,01,32,\
84,40,3E,00,32,83,40,32,\
85,40,2A,0C,40,01,07,00,\
09,22,8A,40,01,0C,00,09,\
22,8C,40,01,0D,00,09,22,\
8E,40,21,00,00,22,88,40,\
21,98,40,3E,22,36,00,23,\
3D,FE,00,20,F8,2A,0C,40,\
01,22,00,09,22,90,40,01,\
F5,02,09,22,92,40,21,02,\
0B,22,96,40,21,1F,17,22,\
94,40,2A,0C,40,01,F8,02,\
09,3E,20,36,80,23,3D,FE,\
00,20,F8,C9,27,27,27,27,\
27,27,27,27,27,27,27,27,\
27,27,27,27,27,27,27,27 ]


# REM __JE£_7)5 SC__;/________JE£_7)5 
#     SC__;/_TC______CCCCCCCCCCCCCCCC
     3  REM [HEX:\
C5,F5,AF,2A,0C,40,23,11,\
21,00,B8,28,04,05,19,18,\
F9,09,F1,77,C1,C9,D5,C5,\
AF,2A,0C,40,23,11,21,00,\
B8,28,04,05,19,18,F9,B9,\
28,01,09,7E,C1,D1,C9,28,\
28,28,28,28,28,28,28,28,\
28,28,28,28,28,28,28,28 ]


# REM _E___Q_     6_____C:1U___ C_XM__
#     /__2 -.Q*7_V4__FF_V4___6 __V4__
     4  REM [HEX:\
E5,2A,88,40,CD,B6,47,00,\
00,00,00,00,22,88,40,7B,\
FE,01,28,0E,1D,3A,82,40,\
FE,00,28,06,3D,32,82,40,\
18,ED,E1,1E,00,16,1B,36,\
17,23,7E,BB,20,01,72,2B,\
2B,7E,BB,20,01,72,01,22,\
00,09,7E,BB,20,01,72,01,\
42,00,AF,ED,42,7E,BB,20,\
01,72,01,21,00,09,AF,BA,\
28,10,06,11,0E,FF,0D,20,\
FD,10,F9,16,00,1E,1B,72,\
18,C7,3A,33,40,5F,3A,32,\
40,8E,FE,00,20,03,3A,34,\
40,3C,3C,32,32,40,3A,85,\
40,CB,FF,32,85,40,C9,29 ]


# REM _<C___C__.CT_ CP__4_Y_/A_:4_Y2/2
#     __4_YC/-_T4_YM/:_O4)Y_M__   Y 2
     5  REM [HEX:\
FE,13,28,44,FE,87,28,40,\
FE,1B,28,39,FE,80,28,35,\
FE,09,20,04,3E,0A,18,26,\
FE,8E,20,04,3E,1E,18,1E,\
FE,82,20,04,3E,28,18,16,\
FE,B9,20,04,3E,32,18,0E,\
FE,34,20,11,3E,64,32,84,\
40,00,00,00,3E,00,1E,01,\
CD,94,41,36,14,3E,01,C9,\
3E,00,C9,2A,2A,2A,2A,2A,\
2A,2A,2A,2A,2A,2A,2A,2A,\
2A,2A,2A,2A,2A,2A,2A,2A ]


# REM JS4<U_______M__ _:_2 />___U___ 4
#     _F__.4_Q J0___K_£/:_(K_£_U___ 4
     6  REM [HEX:\
AF,B8,20,13,3A,85,40,CB,\
47,C8,CB,87,32,85,40,00,\
44,0E,04,1E,00,18,12,CD,\
64,41,3A,84,40,FE,00,20,\
01,2B,7E,FE,1B,20,02,36,\
00,AF,1C,7B,FE,0A,30,03,\
0C,18,0E,FE,10,30,01,0C,\
04,3A,84,40,FE,00,20,01,\
0D,CD,64,41,FE,00,28,0E,\
FE,16,28,0A,CD,1E,42,FE,\
00,28,03,06,00,C9,36,1B,\
C9,2B,2B,2B,2B,2B,2B,2B ]


# REM JS_U___ 4_$___ __4__T**_/6__C__-C
#     __ 4NQ E-_J_WC_S____J___S_$____
     7  REM [HEX:\
AF,B8,C8,3A,84,40,FE,00,\
20,01,0D,CD,64,41,00,FE,\
82,20,06,78,B9,D8,05,18,\
22,FE,87,28,08,FE,16,28,\
04,FE,00,20,33,36,00,2A,\
96,40,AF,78,BC,28,05,38,\
02,05,05,04,AF,79,FE,03,\
38,01,0D,CD,64,41,FE,00,\
28,13,FE,16,28,0F,FE,87,\
28,0B,FE,80,20,0A,0C,23,\
7E,FE,00,20,03,36,87,C9,\
FE,83,28,0E,FE,8A,28,0A,\
FE,1B,20,0D,1E,01,3E,0A,\
18,04,1E,03,3E,00,CD,94,\
41,06,00,C9,06,00,C9,2C,\
2C,2C,2C,2C,2C,2C,2C,2C ]


# REM JS47_$Y_T_J_S_J____F$__ C____K_J
#     _/J__ ____U___ 4_JT4__ _F__.C:_
     8  REM [HEX:\
AF,B8,20,23,4D,0D,3E,03,\
B9,D0,AF,44,B8,C8,AF,CD,\
64,41,C5,2B,0D,7E,FE,80,\
28,09,79,FE,05,30,F4,AF,\
C1,18,2F,C1,06,00,C9,CD,\
64,41,3A,84,40,FE,00,20,\
08,AF,B9,20,03,06,00,C9,\
2B,7E,FE,1B,28,0E,FE,00,\
28,0A,FE,16,28,06,FE,13,\
28,04,18,19,36,00,AF,B9,\
28,22,0D,CD,64,41,FE,00,\
28,08,FE,16,28,04,FE,1B,\
20,03,36,1B,C9,FE,83,28,\
04,FE,8A,20,07,1E,02,3E,\
00,CD,94,41,06,00,C9,2D,\
2D,2D,2D,2D,2D,2D,2D,2D ]


# REM JS4-UM____:3_____ 4_Q<__ _JS_U__
#     _ 4_JT4__ _$____<C>_-C__.4_2_Y_
     9  REM [HEX:\
AF,B8,20,16,3A,32,40,FE,\
05,D0,0E,1F,43,CD,64,41,\
FE,00,20,03,36,13,C9,06,\
00,C9,AF,B8,C8,3A,84,40,\
FE,00,20,08,AF,B9,20,03,\
06,00,C9,0D,CD,64,41,FE,\
13,28,12,FE,16,28,04,FE,\
1B,20,07,1E,01,3E,0A,CD,\
94,41,06,00,C9,11,21,00,\
E5,19,7E,E1,FE,B9,18,06,\
3A,32,40,FE,32,D0,36,00,\
AF,3A,34,40,CB,57,28,18,\
3A,97,40,B8,38,07,19,04,\
7E,FE,00,28,0B,AF,ED,52,\
05,7E,FE,00,28,02,19,04,\
36,13,C9,2E,2E,2E,2E,2E ]


# REM JU____C_WM__?8_Y M__Y-__(__3 <__
#     ._K<<_ C_X/_UO__UM____=_JY XS__
    10  REM [HEX:\
AF,3A,84,40,FE,05,28,07,\
3C,32,84,40,C3,A4,45,3E,\
00,32,84,40,3E,16,ED,5B,\
90,40,01,1F,00,13,62,6B,\
1B,ED,B0,13,13,FE,00,28,\
03,3D,18,EE,3A,34,40,67,\
3A,32,40,6F,ED,4B,94,40,\
AF,3E,80,BD,38,01,04,AF,\
3E,80,BD,30,01,05,AF,3E,\
CE,BC,38,01,04,AF,3E,32,\
BC,30,01,05,AF,3E,06,B8,\
38,02,06,06,AF,3E,17,B8,\
30,02,06,17,ED,43,94,40,\
2A,0C,40,11,41,00,0E,01,\
19,11,21,00,AF,79,FE,17,\
28,0D,B8,30,04,36,00,18,\
02,36,80,0C,19,18,ED,2A,\
32,40,54,5D,29,29,19,29,\
29,29,19,23,22,32,40,C3,\
1E,45,2F,2F,2F,2F,2F,2F ]


# REM __=__JUM__/K_/M__K_Y____/B__K,YT
#     ___EE_Y W4-_Y<___£__E_/___K_Y:_
    11  REM [HEX:\
ED,4B,94,40,05,AF,3A,32,\
40,FE,98,30,02,18,32,FE,\
C1,30,07,3E,09,CD,4E,41,\
18,27,FE,CA,30,1A,3E,B9,\
CD,4E,41,2A,AA,40,3E,00,\
BC,20,16,05,3E,13,CD,4E,\
41,0C,ED,43,AA,40,18,09,\
FE,F3,30,07,3E,8E,CD,4E,\
41,18,2A,FE,FC,30,21,3E,\
82,CD,4E,41,2A,B0,40,3E,\
00,BC,20,07,0C,ED,43,B0,\
40,18,12,2A,B2,40,BC,20,\
0C,0C,ED,43,B2,40,18,05,\
3E,34,CD,4E,41,C3,A4,45,\
30,30,30,30,30,30,30,30,\
30,30,30,30,30,30,30,30 ]


# REM __-____U____C*_?M__2=7__-4_Q __ 
#     C_1/______ _Q F_$_ 4_U9___C__X4
    12  REM [HEX:\
ED,4B,96,40,CD,64,41,3A,\
85,40,CB,4F,28,17,CB,8F,\
32,85,40,1E,14,23,7E,FE,\
16,20,02,36,00,7B,FE,00,\
28,03,1D,18,F0,CD,64,41,\
7E,FE,80,C8,36,00,2B,79,\
0D,FE,00,20,F3,3A,25,40,\
FE,FD,28,04,FE,BD,20,09,\
05,78,FE,00,20,12,04,18,\
0F,FE,FE,28,04,FE,BE,20,\
07,04,78,FE,18,20,01,05,\
0E,02,ED,43,96,40,CD,64,\
41,FE,00,28,07,FE,1B,28,\
03,FE,87,C0,36,83,2B,7E,\
FE,00,28,07,FE,1B,28,03,\
FE,87,C0,36,8A,2B,7E,FE,\
00,28,07,FE,1B,28,03,FE,\
87,C0,36,84,23,23,C3,4A,\
46,32,32,32,32,32,32,32,\
32,32,32,32,32,32,32,32 ]


# REM U9__ZC£_XC__ZC__Y4PU___2_Y_UCE=1
#     V4__M__U____M__2=7__ C__,__ 4_Q
    13  REM [HEX:\
3A,25,40,FE,BF,28,0C,FE,\
BD,28,08,FE,3F,28,04,FE,\
BE,20,35,3A,83,40,57,1E,\
6A,3E,64,BA,28,2A,14,1D,\
BB,20,F8,7A,32,83,40,3A,\
85,40,CB,CF,32,85,40,1E,\
14,23,7E,FE,00,28,07,CD,\
1A,42,FE,00,20,0A,36,16,\
7B,FE,00,28,03,1D,18,E9,\
3A,25,40,FE,7F,28,04,FE,\
7F,20,08,3A,85,40,CB,C7,\
32,85,40,ED,4B,98,40,3A,\
B4,40,5F,2A,96,40,CD,80,\
42,ED,43,98,40,7B,32,B4,\
40,ED,4B,9A,40,3A,B5,40,\
5F,2A,96,40,CD,80,42,ED,\
43,9A,40,7B,32,B5,40,ED,\
4B,9C,40,3A,B6,40,5F,2A,\
96,40,CD,80,42,ED,43,9C,\
40,7B,32,B6,40,3A,83,40,\
FE,00,28,04,3D,32,83,40,\
3A,85,40,CB,87,32,85,40,\
C3,10,47,33,33,33,33,33,\
33,33,33,33,33,33,33,33 ]


# REM __4_E2_   __4___2_2______2_____6
#     ______6___A_E8_   __A___8_2____
    14  REM [HEX:\
ED,4B,A0,40,2A,9E,40,00,\
00,00,ED,43,A0,40,ED,4B,\
9E,40,1E,05,CD,F2,43,ED,\
43,9E,40,60,69,ED,4B,A2,\
40,CD,6C,43,ED,43,A2,40,\
ED,4B,A6,40,2A,A4,40,00,\
00,00,ED,43,A6,40,ED,4B,\
A4,40,1E,08,CD,F2,43,ED,\
43,A4,40,60,69,ED,4B,A8,\
40,CD,6C,43,ED,43,A8,40,\
ED,4B,AC,40,2A,AA,40,00,\
00,00,ED,43,AC,40,ED,4B,\
AA,40,CD,0C,44,ED,43,AA,\
40,60,69,ED,4B,AE,40,CD,\
6C,43,ED,43,AE,40,ED,4B,\
B0,40,CD,E6,42,ED,43,B0,\
40,ED,4B,B2,40,CD,E6,42,\
ED,43,B2,40,C3,FC,47,34,\
34,34,34,34,34,34,34,34,\
34,34,34,34,34,34,34,34 ]


# REM _ ___JE£___ 4_Y0W_A4_Q0F/___X_7/
#     _     __: /_£/K_JY0__A"Y+_PPPPP
    15  REM [HEX:\
FE,00,C8,E5,F5,AF,2A,8C,\
40,7E,FE,80,20,02,3E,9C,\
3C,FE,A6,20,05,36,9C,2B,\
18,EF,77,F1,3D,E1,23,18,\
DF,00,00,00,00,00,06,0A,\
0E,00,18,01,0C,98,30,FC,\
AF,3E,9C,81,FE,A6,C0,3E,\
95,C9,35,35,35,35,35,35 ]


# REM JE£_)_ ;__ 4_Y0W_A4_Q0F/__E__76_
#     _JU___Y0_E£_), ;_JU___>=_E£_)4 ;
    16  REM [HEX:\
AF,2A,0C,40,11,07,00,19,\
7E,FE,80,20,02,3E,9C,3C,\
FE,A6,20,05,36,9C,2B,18,\
EF,77,2A,86,40,23,22,86,\
40,AF,3A,82,40,67,3E,9C,\
84,2A,0C,40,11,1A,00,19,\
77,AF,3A,83,40,CD,DC,47,\
2A,0C,40,11,20,00,19,77,\
AF,3A,85,40,CB,7F,28,07,\
CB,BF,32,85,40,18,09,06,\
05,0E,FF,0D,20,FD,10,F9,\
3A,82,40,FE,00,C8,3A,84,\
40,FE,64,C8,AF,3A,84,40,\
FE,05,20,0E,ED,4B,96,40,\
CD,64,41,3E,00,77,2B,77,\
2B,77,C3,78,44,78,44,36 ]

    17 DIM H(5)
    18 DIM M(5)
    20 LET T=0
    21 LET S=0
    22 RAND 
    23 LET SHIP=1
    25 GOTO 5000
    30 POKE 16518,0
    35 POKE 16519,0
    40 CLS 
    50 PRINT AT 0,0;"t‰—————««hits‰—————««sld‰«las‰—"
    55 LET A=USR 16584
    60 LET A=USR 17528
    65 IF PEEK 16516=100 THEN GOTO 500
    67 PRINT AT 10,2;"SHIP ";SHIP;" HAS BEEN DESTROYED"
    68 FOR N=1 TO 100
    69 NEXT N
    70 LET T=T+(PEEK 16518+256*PEEK 16519)
    75 LET S=S+(PEEK 16520+256*PEEK 16521)
    80 IF SHIP=5 THEN GOTO 100
    85 LET SHIP=SHIP+1
    90 GOTO 30
   100 CLS 
   101 LET R=(INT (100*(S/T)))/100
   102 PRINT AT 0,6;"AT LEVEL ";U$
   103 LET U=VAL U$
   105 PRINT AT 2,0;"YOUR TOTAL SCORE IS ";S;AT 3,2;"WITH A HIT/TIME RATIO OF ";R
   109 IF S>H(U) THEN LET H(U)=S
   110 IF R>M(U) THEN LET M(U)=R
   118 IF S<=5000 THEN PRINT AT 5,0;"YOU HAVE NOT INFLICTED ENOUGH   DAMAGE TO SECURE THE PLANET."
   120 IF S>5000 THEN PRINT AT 5,0;" YOU HAVE BADLY DAMAGED THE     ALIEN PLANET.                     "
   125 IF S>5000 AND 1.5*S>T THEN PRINT AT 7,0;"THE PLANET IS YOURS."
   130 PRINT AT 10,0;"LEVEL    HIGH SCORE   HIGH RATIO"
   131 PRINT 
   135 FOR N=1 TO 5
   140 PRINT TAB 2;N;TAB 16-LEN (STR$ H(N));H(N);TAB 25;M(N)
   145 NEXT N
   190 PRINT AT 21,0;"PRESS ÀPÀ TO PLAY"
   195 IF NOT INKEY$="P" THEN GOTO 195
   200 GOTO 20
   500 PRINT AT 7,15;"½½"
   505 FOR N=1 TO 10
   506 NEXT N
   510 PRINT AT 7,15;"  "
   511 FOR N=1 TO 10
   512 NEXT N
   515 PRINT AT 7,7;"½½½½½½½½½½½½½½½½½½"
   516 PRINT AT 6,7;"½½½½½½½½½½½½½½½½½½"
   517 PRINT AT 8,7;"¿½½½½½½½½½½½½½½½½¿"
   518 PRINT AT 5,7;"¾½½½½½½½½½½½½½½½½¾"
   519 PRINT AT 9,10;"½½½½½½½½½½½½"
   520 PRINT AT 4,8;"¾½½½½½½½½½½½½½½¾"
   521 PRINT AT 10,11;"¿½½½½½½½½¿"
   522 PRINT AT 3,9;"¾½½½½½½½½½½½½¾"
   523 PRINT AT 11,14;"½½½½"
   524 PRINT AT 2,11;"¾½½½½½½½½¾"
   525 PRINT AT 12,14;"½½½½"
   526 PRINT AT 13,11;"¾¾½½½½½½¾¾"
   527 PRINT AT 14,11;"¿¿½½½½½½¿¿"
   528 PRINT AT 15,14;"½½½½";AT 16,14;"½½½½"
   529 PRINT AT 17,12;"¾½½½½½½¾";AT 18,12;"¿½½½½½½¿"
   530 PRINT AT 19,14;"½½½½";AT 20,14;"½½½½";AT 21,14;"½½½½"
   535 FOR N=1 TO 75
   536 NEXT N
   540 GOTO 67
  5000 CLS 
  5001 PRINT "        A V E N G E R"
  5002 PRINT AT 2,22;"BY K FLYNN"
  5003 PRINT AT 3,8;"(C) ABACUS PROGRAMS 1982"
  5005 PRINT ,," YOU COMMAND THE ZARQON SPACE-  SHIP ÀAVENGERÀ."
  5010 PRINT " YOUR CONTROLS ARE :-"
  5011 PRINT "   UP     - ÀAÀ                    DOWN   - ÀZÀ                    LASER  - ÀLÀ                    BOMBS  - ÀMÀ"
  5012 PRINT " KEY COMBINATIONS ARE :-           A/L , Z/L AND M/L ."
  5016 PRINT ,," USING THE LASER AND BOMBS YOU  MUST ATTACK THE ENEMY PLANET    WHILE PROTECTING YOURSELF."
  5020 PRINT " THE ALIENS WILL FIGHT BACK WITHMISSILE FIRING INTERCEPTORS AND GUIDED MISSILES."
  5021 PRINT AT 21,0;"PRESS ÀPÀ"
  5026 IF NOT INKEY$="P" THEN GOTO 5026
  5027 CLS 
  5030 PRINT "POINTS ARE SCORED AS FOLLOWS :-"
  5031 PRINT "(ÀLÀ INDICATES THAT THE TARGET  WILL BE DESTROYED BY LASER ,    ÀBÀ FOR BOMBS.)"
  5036 PRINT ,,"À<À INTERCEPTOR  10 POINTS (L)"
  5037 PRINT ,,"À²À GUIDED MIS.  10 POINTS (B)"
  5038 PRINT ,,"À¾À BUILDINGS    10 POINTS (L/B)"
  5039 PRINT ,,"À‰À FACTORY      30 POINTS (L/B)"
  5040 PRINT ,,"ÀªÀ MISSILE PAD  40 POINTS (L/B)"
  5041 PRINT ,,"ÀtÀ INTERCEP.PAD 50 POINTS (L/B)"
  5042 PRINT ,,"ÀOÀ ATOMIC POWER STATION ....        D O  N O T  H I T."
  5045 PRINT AT 21,0;"PRESS ÀPÀ"
  5046 IF NOT INKEY$="P" THEN GOTO 5046
  5047 CLS 
  5050 PRINT " THE TOP LINE OF THE DISPLAY    GIVES THE TIME , POINTS ,       SHIELDS AND THE TEMPERATURE OF  THE LASER."
  5055 PRINT " THE SHIP HAS 5 SHIELDS , 1 IS  LOST FOR EACH HIT FROM AN INTER-CEPTOR , 2 FOR EACH GUIDED MIS."
  5060 PRINT " THE TEMP. OF THE LASER RISES   AS IT IS FIRED AND FIRING STOPS WHEN IT EXCEEDS 9."
  5065 PRINT ,," YOU HAVE 5 SHIPS AND MUST SCOREOVER 5000 POINTS TO WIN."
  5066 PRINT AT 18,0;"ENTER LEVEL OF PLAY (1 TO 5)            (5 BEING HARDEST)"
  5067 LET U$=INKEY$
  5069 IF U$<"1" OR U$>"5" THEN GOTO 5067
  5070 LET E=26-(2*(VAL U$))
  5071 POKE 17848,E
  5072 POKE 18042,E
  5074 POKE 18018,(103+(VAL U$))
  5075 POKE 18508,(6-(INT ((VAL U$)/2)))
  5076 POKE 16871,(20-(VAL U$))
  5090 CLS 
  5095 PRINT AT 10,0;"G O O D  L U C K . . ."
  5098 FOR N=1 TO 50
  5099 NEXT N
  5100 GOTO 30
  9000 INPUT I$
  9005 SAVE "AVENGEr"
  9010 RUN 
http://zx81.vb81.free.fr/
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 980
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

mister_coffee wrote: Thu Jan 26, 2023 7:08 am Wimps, all wimps here.

Blast from the past, about 22 years ago:

Code: Select all

<?
        include("include/wp2001.php");
        include("include/view_functions.php");
        ob_end_flush();
?>
<FORM action="logsheets.php" method=POST>
<?
        if (ereg("r=([0-9]+),d=(.+)",$QUERY_STRING,$matches)) {
                $where = $matches[1];
                $date = mysqldate_to_wp2001($matches[2]);
                $action = "Update";
                $QUERY_STRING = "";
        }

        if ($where == "") {
                $where = cookiejar("zone");
        } else {
                fill_cookiejar("zone",$where);
        }

        $form = new html_table;
        $form->init(array("rows" => 2, "cols" => 2));
        $form->table_style= 'BORDER="1" CELLPADDING="2" CELLSPACING="2"';

        $form->cell[1][1]["content"] = "Where";
        $form->cell[1][2]["content"] = myselector(
                "SELECT id,name FROM resources WHERE type=$zone_resourcetype AND active<>0 ORDER BY name",
                "where",$where);

        $form->cell[2][1]["content"] = "Date (mm/dd)";
        $form->cell[2][2]["content"] = myfield("date",25,$date);

        $form->code();
        $form->display();
?>
<BR>
        <INPUT type=submit name=action value=Update></INPUT>
        </FORM>
  <HR WIDTH="100%">
<?
        if ($action == "Update" and $where != "") {
                $q  = "SELECT resourcemap.right_resource,resources.name ";
                $q .= "FROM resourcemap,resources ";
                $q .= "WHERE resourcemap.left_resource=$where AND ";
                $q .= "resourcemap.right_resource=resources.id AND ";
                $q .= "resources.type=$camp_resourcetype ";
                $q .= "ORDER BY resourcemap.stacking_order";

                $r1 = wpquery($q);

                $i = 0;
                while ($row = mysql_fetch_row($r1)) {
                        $resources[$i]["id"]   = $row[0];
                        $resources[$i]["name"] = $row[1];
                        ++$i;
                }

                mysql_free_result($r1);

                $extras = extra_resource_data($resources);
                $extra_col = 0;

                for ($i = 0; $i < count($resources); $i++) {
                        $x = $extras[$resources[$i]["id"]];
                        $resources[$i]["extra"] = $x;

                        if (strlen($x) > 0) $extra_col = 1;
                }

                $range = new date_range($date);
                $base = 1;

                $tbl = new html_table;
                $tbl->init(array("rows" => $i + 1, "cols" => 8 + $extra_col));
                $tbl->table_style= 'BORDER="1" CELLPADDING="2" CELLSPACING="2"';

                for ($i = 0; $i < 7; $i++) {
                        $range->span($i);
                        $tm = $range->raw_last();
                        $tbl->cell[1][$extra_col + 2 + $i]["content"] =
                                "<strong>" . date("m/d",$tm) .
                                "</strong>";
                        $tbl->col_style[$extra_col + 2 + $i] = "VALIGN=TOP";
                }

                $range->span(7);

                for ($i = 0; $i < count($resources); $i++) {
                        // make the camp be a link to the camps view on
                        // the appropriate dates...
                        $url_tail = "r=" . $resources[$i]["id"] . ",d=" .
                                $range->mysql_first();

                        $tbl->cell[2 + $i][1]["content"] =
                                "<A HREF=\"camps.php?$url_tail\">" .
                                "<small>" . $resources[$i]["name"] .
                                "</small></A>";

                        if ($extra_col) {
                                $tbl->cell[2 + $i][2]["content"] =
                                        "<small>" .
                                        $resources[$i]["extra"] .
                                        "</small>";
                        }

                        $list = camp_report($range,$resources[$i]["id"],0);

                        for ($j = 0; $j < 7; $j++) {
                                if ($list[$j] == "") continue;
                                $tbl->cell [2+$i][$extra_col+2+$j]["content"] =
                                        "<small>" . $list[$j] . "</small>";
                        }
                }

                $tbl->code();
                $tbl->display();
                print "<HR WIDTH=\"100%\">\n";

        }
?>

<h2>How This Works</h2>

<UL>
<LI>If you don't enter a date, we use the current date.<P>

<LI>You can enter a date with a four-digit year for a year other than
the current one.  There is plenty of data for 1999 and 2000.<P>

<LI>Choose a zone and you'll see all the permits for that zone (by camps)
for the next week.<P>

</UL>

<h2>To Think About</h2>

<UL>
<LI>It got too busy and too ugly when displaying assigned camp sites as well.
Speed might be a concern too.<P>

<LI>Perhaps a variant of this tool that generates a printable form of
the logsheets that could be used in emergencies would be a good idea.<P>

</UL>

</BODY>
</HTML>
More recent work:

Code: Select all

@router.post("/status", response_model=StatusResult)
async def post_status(item: StatusItem):
    """
        posts status from a device, status data is in the json payload

        returns a dict with one entry (ok) set to 1 on success
    """
    # FIXME:  confirm we are posting for the logged-in device
    check_location(item.latitude, item.longitude)
    check_device_id(item.device_id)

    when = time.time()

    if item.status != "GREEN":
        statuses = await get_device_status(item.device_id)
        changed = False

        if statuses is None:
            changed = True
        else:
            status = statuses[0]
            if status["status"] != item.status:
                changed = True

        if changed:
            get_logger().info(f"{item.device_id}:  status changed to {item.status}")
            wps = await find_watchpoints(item.latitude, item.longitude)

            if wps is not None and len(wps) > 0:
                await enqueue_detection(
                    item.status, item.device_id, item.latitude, item.longitude, wps
                )

    """
        FIXME:  there is an optimization here where when there is no image data,
        in that case we can gather both of these futures rather than run them sequentially
    """
    await note_db_status(when, item)
    await note_status(when, item)

    return StatusResult(ok=1)

PHP is freaking ugly.
I am not strong in any computer language. I am a wimp programmer. I just like the logic and hope to understand a computer by studying the ZX81.
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 980
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

http://zx81.vb81.free.fr/

Here is a very powerful ZX81 Emulator. It seems to make the Timex Sinclair 1000 do everything I ever dreamed and more. I am looking for a way to convert this image of the listing into a text file that I can manipulate in the ZX81 and outside the ZX81 in a text editor. I can now write in the text editor and the program will load into the emulator. Now I need to have the listing for Avenger in a text editor to edit and reload.

Attached is an image of the Avenger listing that I will try to convert to text for editing.
Attachments
Avenger Listing.png
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
pasayten
Posts: 1753
Joined: Thu Mar 11, 2021 8:03 pm
Contact:

Re: www.MethowValley.org

Post by pasayten »

No wimps here... OCEC Electric Rate Calulator... Support program to https://methow.chewack.com/getmybill2022.php

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>My Methow Information Web Pages</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<meta name="keywords" content="">
	<meta name="description" content="">
	<!-- master default -->
<link rel="stylesheet" type="text/css" href="mymetbill2.css" />

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="https://methow.chewack.com/getbill_function24mo2022.js"></script>


<?php
echo '<script type="text/javascript">';
echo 'google.load("visualization", "1", {packages:["corechart","gauge"]});';
echo 'var qsParm = new Array();';
echo 'var kary = new Array();';
echo 'var dary = new Array();';
echo 'var nary = new Array();';

echo 'var pary = new Array();';
echo 'var ravg = new Array();';
echo 'var crb = new Array();';
echo 'var prb = new Array();';
echo 'var chb = new Array();';
echo 'var cbill = 0.0;';
echo 'var pbill = 0.0;';
echo 'var chgbill = 0.0;';
echo 'var kavg = 0;';
echo 'var crank = 0;';
echo 'var kmax = 0;';
echo 'var dmax = 0;';
echo 'var grank = 0;';
echo 'var xtemp = 0.0;';
echo 'var origrate = 0;';
echo 'var newcls = "G1";';
echo 'var oldcls = "Residential";';
echo 'var mary = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];';
// ***********************************
// set default starts
// ***********************************
echo 'var enddat = 2212;';
echo 'var maxrank = 4000;';
$enddat = "2212";


if(isset($_GET['recsel'])) $xkey = $_GET['recsel'];
if(isset($_GET['enddat'])) $enddat = $_GET['enddat'];
$fd = fopen("membertool.log", "a");
$msg = "[" . date("Y/m/d h:i:s", time()) . "] ";
$msg = $msg.' RateCalc Member key: '.$xkey.'/';
$msg = $msg.' End date: '.$enddat.'/';
foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) {
  if (array_key_exists($key, $_SERVER) === true) {
    foreach (explode(',', $_SERVER[$key]) as $ip) {
      if (filter_var($ip, FILTER_VALIDATE_IP) !== false) {
          $msg = $msg.$ip.'/';
      }
    }
  }
}
fwrite($fd, $msg . "\n");
fclose($fd);

 // Otherwise we connect to our Database
$hostname = 'localhost';
$username = '????????';
$password = '????????';
$database = '????????';

$link = mysqli_connect($hostname, $username, $password) or die("Unable to Connect to '$hostname'");
mysqli_select_db($link, $database) or die("Could not open the db '$database'");

 //Now we search for our search term, in the field the user specified
$query="SELECT * FROM mem_tool2022 WHERE member_fake = ";
$query=$query.$xkey;
//$query=$query."'";
//$data = mysql_query($query);
$data = mysqli_query($link, $query);

//echo "data query=".$query.":<br>";
//echo $data;
 //And we display the results
 $i =0;
 // ************************************
 // arrays set for 2001 thru 2212...
 // ************************************
 $kary=array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1);
 $dary=array(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);
 $ravg=array(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);
 $totk = 0.0;
 $totd = 0.0;

 while($result = mysqli_fetch_array( $data ))

 {
 $i = $i + 1;
 // Get all regular stuff for meter
 if ($i == 1)
   {
   $cls = $result['class'];
   echo 'crank = '.$result['rank'].';';
   //echo 'debug';
   //echo $result['kwhavg_2022'];
   //echo $result['rank'];
   //echo 'debug';

   echo 'kavg = '.$result['kwhavg_2022'].';';
   //echo 'totk = '.$result['tot_kwh'].';';
   //echo 'totd = '.$result['tot_kw'].';';
   //echo 'totbil = '.$result['tot_rev'].';';
   echo 'phase = '.$result['rate'].';';
   echo 'cur_rate = '.$result['cur_rate'].';';
   // WAS COMMENTED OUT
   echo 'origrate = '.$result['cur_rate'].';';
   $gcls = $result['kwhavg_2022'];
   $xnm = "G1 (0-1200 avg kwh/mth)";
   if ( $gcls > 1200 ) $xnm ="G2 (1200-5000 avg kwh/mth)";
   if ( $gcls > 5000 ) $xnm ="G3 (5000-16,667 avg kwh/mth)";
   if ( $gcls > 16667 ) $xnm ="G4 (Abv 16,667 avg kwh/mth)";
   echo 'newcls = "'.$xnm.'";';
   }
 // Now load kwh/kw arrays
 $xd = $result['billyrmo'];
 $xkwh = $result['kwh'];
 $xdem = $result['kwdemand'];
 if ($xd < 2101) {
   $xd = $xd - 2000;
   $xd = $xd -1;
 } elseif ($xd < 2201) {
   $xd = $xd - 2100;
   $xd = $xd +11;
 } else {
   $xd = $xd - 2200;
   $xd = $xd +23;
 }




 //echo 'xd:'.$xd.' kwh:'.$xkwh.' <br>';
 $kary[$xd] = $xkwh;
 $dary[$xd] = $xdem;
 }

//  Calculate annual running averages
 $rtot = 0;
 $rnum = 0;
 for ($i=11; $i<=35; $i++)
   {
   if ($kary[$i] > -1) {
     // Have value, do running average
     $j = $i - 11;
     $rtot = 0;
	 $rnum = 0;
     for ($j=$i-11; $j<=$i; $j++)
     {
        if ($kary[$j] > -1)
        {
           $rtot = $rtot + $kary[$j];
           $rnum = $rnum + 1;
        }
     }
     $ravg[$i] = $rtot / $rnum;
     //echo 'i: '.$i.' kwh:'.$ravg[$i].' <br>';
   }
 }




 // Now set up annual values for chosen end month
 // VERIFY OFFSET data starts at 1201, not 1101

 if ($enddat == 2112) $istrt = 12;
 if ($enddat > 2112)  $istrt = $enddat - 2200 +12;
 if ($enddat > 2212)  $istrt = $enddat - 2300 +24;
 //if ($enddat == 1309) $istrt = 12;
 //if ($enddat > 1212)  $istrt = $enddat - 1300 +12;
 //if ($enddat > 1312)  $istrt = $enddat - 1400 +12;

 for ($i=0; $i<=11; $i++)
   {
   $ioff = $i + $istrt;
   if ($kary[$ioff] == -1)
   {
     echo 'kary['.$i.'] = -1;';
     echo 'dary['.$i.'] = 0.0;';
     echo 'ravg['.$i.'] = 0.0;';
   } else {
     $totk = $totk + $kary[$ioff];
     $totd = $totd + $dary[$ioff];
     echo 'kary['.$i.'] = '.$kary[$ioff].';';
     echo 'dary['.$i.'] = '.$dary[$ioff].';';
     echo 'ravg['.$i.'] = '.round($ravg[$ioff],1).';';
   }

   if ($kary[$ioff-12] == -1)
   {
     echo 'pary['.$i.'] = -1;';
   } else {
     echo 'pary['.$i.'] = '.$kary[$ioff-12].';';
   }

   }
 echo 'totk = '.$totk.';';
 echo 'totd = '.$totd.';';
 echo 'enddat = '.$enddat.';';
 //$xkey = 792194002;
 echo 'frec = '.$xkey.';';
 $mrec = ( $xkey -1994 ) / 4;
 echo 'mrec = '.$mrec.';';


echo 'google.setOnLoadCallback(getMemberData);';
//echo 'getMemberData();';

echo '</script>';
?>


</head>
<body>
<div style="float: left; width: 800px;border:1px solid black;">

<div style="float: left; clear: left; width: 327px; height: 110px; border-right:1px solid black;border-bottom:1px solid black;border-top:1px solid black;background: rgb(200,229,238);">
<center id="cursive18">My Methow<br>
Electrical<br>
Information</b></center>
</div>

<div style="float: right; width: 470px; height: 110px; border:1px solid black;background: rgb(200,229,238);">
<img src="https://methow.chewack.com/images/mymetlogo3.jpg" />
</div>

<div id="body" style="width:800px;">


<p id="mediumcursive"><center><b>Your OCEC electrical bill summary analysis</b></center><br>

<div style="width:800;height:320px;">
<div id="chart_div" style="width:580;height:320px;float:left;margin-left:10px;border:1px solid black;">
<br><br><span style="width:580px;text-align:center;float:left;">... loading data ...</span></div>

<div style="width:170px;height:240px;float:left;margin-left:20px;margin-top:0px;border:1px solid black;">

<div style="width:170px;height:40px;margin-top:5px;">
<span style="width:165px;text-align:center;float:left;"><p class="txsmall">Your Average Monthly<br>kwh Usage Rank</p></span>
</div>

<div id="gage_div" style="width:160px;height:150px;margin-left:10px;"></div>

<div style="width:170px;height:40px;margin-top:0px;">
<span style="width:165px;text-align:center;float:left;"><p class="txsmall">Scale of 0-100<br> for 4000 meters @ OCEC</p></span>
</div>

<div style="width:170px;height:75px; margin-top:10px; border:1px solid black;">
<span style="width:165px;text-align:center;float:left;"><p class="txsmall">
Choose dates to analyze:<br>
<form name="disptype" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<select name="enddat" style="float:left;height:22px;margin-left:8px;margin-top:5px;background:rgb(200,229,238);">
<?php
$xx = "";
if ($enddat == 2112) $xx = "selected";
echo '<option value="2112" '.$xx.'>Jan 2021-Dec 2021</option>';
$xx = "";
if ($enddat == 2209) $xx = "selected";
echo '<option value="2209" '.$xx.'>Oct 2021-Sep 2022</option>';
$xx = "";
if ($enddat == 2212) $xx = "selected";
echo '<option value="2212" '.$xx.'>Jan 2022-Dec 2022</option>';



echo '</select><br>';
echo '<input style="margin-left:0px;line-height:18px;text-align:center;background: rgb(200,229,238);" type="submit" value="Submit New Dates" />';
echo '<input name="recsel" type="hidden" value="'.$xkey.'" />';


//Pulled out of rate summary
//Energy Chg:
//<span id="pener">0.00</span>
//&nbsp; &nbsp; Inc kwh:
//<span id="ptier1">0</span>
//<br>








?>

</form>
</p></span>
</div>

</div>

</div>

<div style="width:770px;margin-top:20px;margin-left:20px;">

<p class="tzsmall">
Member Account: <b id="mrec">0</b> Data Record: <b id="frec">0</b><br>
<b>Summary stats are for the 2022 base year:</b> Your monthly avg kwh was <b id="mavg">0</b> and ranked <b id="krank">0</b> from the highest of the approx 4000
OCEC meter accounts.  This is converted to <b id="grk">0</b> out of 100 to display on the gage.
Under the current policies, your average monthly kwh usage would place you in the
<b>General Service Class <span id="newgx">G1</span></b> and
<b>Rate Code <span id="ratecd">1</span></b>.
Your rate class is currently set to <b id="currate">00</b>.
Your current average kwh usage
<span id="classchg">and existing rate meet policies. You might check if a higher rate code would save you money</span>.

<br>
<b>Summary for the selected dates:</b> Your total energy usage for the 12 month period was <b id="tkwh">0</b> kwh.   Your peak monthly usage was <b id="mxkwh">0</b> kwh
and your peak monthly demand was <b id="mxkw">0</b> kw. Following is a summary of your monthly usage and billings using the 2021/22 rates which you can compare with the
a new rate class and other utility/coop/class rates.
Also note yard lights/local taxes have not been included.
</p><br>
<br>
<div style="width:520px;float:left;margin-top:0px;margin-left:0px;border:0px solid black;">

<table class="billtab" border="1">
<tr>
<th>Month</th>
<th>Total kwh</th>
<th>Dem kw</th>
<th id="g2015">2021 xx Rate</th>
<th>Compare Rate</th>
<th>% Change</th>
</tr>

<tr><td id="m1" style="text-align:left;">Jan</td>
<td id="k1">0</td>
<td id="kw1">0</td>
<td id="o1">0.00</td>
<td id="n1">0.00</td>
<td id="c1">0.0%</td></tr>

<tr><td id="m2" style="text-align:left;">Feb</td>
<td id="k2">0</td>
<td id="kw2">0</td>
<td id="o2">0.00</td>
<td id="n2">0.00</td>
<td id="c2">0.0%</td></tr>

<tr><td id="m3" style="text-align:left;">Mar</td>
<td id="k3">0</td>
<td id="kw3">0</td>
<td id="o3">0.00</td>
<td id="n3">0.00</td>
<td id="c3">0.0%</td></tr>

<tr><td id="m4" style="text-align:left;">Apr</td>
<td id="k4">0</td>
<td id="kw4">0</td>
<td id="o4">0.00</td>
<td id="n4">0.00</td>
<td id="c4">0.0%</td></tr>

<tr><td id="m5" style="text-align:left;">May</td>
<td id="k5">0</td>
<td id="kw5">0</td>
<td id="o5">0.00</td>
<td id="n5">0.00</td>
<td id="c5">0.0%</td></tr>

<tr><td id="m6" style="text-align:left;">Jun</td>
<td id="k6">0</td>
<td id="kw6">0</td>
<td id="o6">0.00</td>
<td id="n6">0.00</td>
<td id="c6">0.0%</td></tr>

<tr><td id="m7" style="text-align:left;">Jul</td>
<td id="k7">0</td>
<td id="kw7">0</td>
<td id="o7">0.00</td>
<td id="n7">0.00</td>
<td id="c7">0.0%</td></tr>

<tr><td id="m8" style="text-align:left;">Aug</td>
<td id="k8">0</td>
<td id="kw8">0</td>
<td id="o8">0.00</td>
<td id="n8">0.00</td>
<td id="c8">0.0%</td></tr>

<tr><td id="m9" style="text-align:left;">Sep</td>
<td id="k9">0</td>
<td id="kw9">0</td>
<td id="o9">0.00</td>
<td id="n9">0.00</td>
<td id="c9">0.0%</td></tr>

<tr><td id="m10" style="text-align:left;">Oct</td>
<td id="k10">0</td>
<td id="kw10">0</td>
<td id="o10">0.00</td>
<td id="n10">0.00</td>
<td id="c10">0.0%</td></tr>

<tr><td id="m11" style="text-align:left;">Nov</td>
<td id="k11">0</td>
<td id="kw11">0</td>
<td id="o11">0.00</td>
<td id="n11">0.00</td>
<td id="c11">0.0%</td></tr>

<tr><td id="m12" style="text-align:left;">Dec</td>
<td id="k12">0</td>
<td id="kw12">0</td>
<td id="o12">0.00</td>
<td id="n12">0.00</td>
<td id="c12">0.0%</td></tr>

<tr><td style="text-align:left;"><b>Total</b></td>
<td><b id="k13">0</b></td>
<td><b id="kw13">-</b></td>
<td><b id="o13">0.00</b></td>
<td><b id="n13">0.00</b></td>
<td><b id="c13">0.0%</b></td></tr>
</table>
</div>

<div style="width:250px;float:left;margin-top:0px;margin-left:0px;border:0px solid black;">
<form name="rateform" action="" >
<p class="txsmall"><b>Choose a rate to compare your bill:</b><br>
<select id="kratex" name="kratex" style="float:left;width:240px;height:22px;margin-left:0px;margin-top:10px;background:rgb(200,229,238);" onChange="newbill();">
<option value="1" selected="0">Need rate selection</option>
<option value="201"> OCEC Apr 2023 Gen Serv 1 rate</option>
<option value="202"> OCEC Apr 2023 Gen Serv 2 rate</option>
<option value="203"> OCEC Apr 2023 Gen Serv 3 rate</option>
<option value="204"> OCEC Apr 2023 Gen Serv 4 rate</option>
<option value="205"> OCEC Apr 2023 Irrigation 1P</option>
<option value="206"> OCEC Apr 2023 Irrigation 3P</option>
<option value="181"> OCEC 2021/22 Gen Serv 1 rate</option>
<option value="182"> OCEC 2021/22 Gen Serv 2 rate</option>
<option value="183"> OCEC 2021/22 Gen Serv 3 rate</option>
<option value="184"> OCEC 2021/22 Gen Serv 4 rate</option>
<option value="185"> OCEC 2021/22 Irrigation 1P</option>
<option value="186"> OCEC 2021/22 Irrigation 3P</option>
<option value="18">Big Bend residential rate (chk Nov22)</option>
<option value="15">Chelan PUD residential rate (chk Nov22)</option>
<option value="22">Columbia REA residential rate (chk Jan19)</option>
<option value="4">Colville (Avista) residential rate (chk Nov22)</option>
<option value="12">Ferry County PUD residential rate (chk Nov22)</option>
<option value="11">Inland Power residential rate (chk Nov22)</option>
<option value="19">Kittitas PUD residential rate (chk Nov22)</option>
<option value="91">Lakeview residential rate (chk Nov22)</option>
<option value="9">Nespelum Electric residential rate (chk Nov22)</option>
<option value="2">Okanogan PUD Apr 23 residential rate (chk Jan23)</option>
<option value="3">OPALCO (Island Cty) residential winter rate (chk Nov22)</option>
<option value="5">Oregon Trail Coop residential rate (chk Nov22)</option>
<option value="17">Parkland Light Coop residential rate (chk Nov22)</option>
<option value="21">Pend Oreille PUD residential rate (chk Nov22)</option>
<option value="20">Skamania residential rate (chk Nov22)</option>
<option value="10">Snohomish County PUD residential rate (chk Nov22)</option>
<option value="8">Tanner Electric residential rate (chk Nov22)</option>
<option value="200">Umatilla Electric residential rate Winter (chk Nov22)</option>
<option value="7">Western Oregon Coop residential rate (chk Nov22)</option>
</select>

<br><br>
<span style="width:150px;float:left;">Existing 12mth bill:</span>
<b id="zold" style="width:70px;float:left;text-align:right;">$0.00</b>
<br>
<span style="width:150px;float:left;">Compare 12mth bill:</span>
<b id="znew" style="width:70px;float:left;text-align:right;">$0.00</b>
<br>
<span style="width:230px;float:left;">Inc/(Dec): &nbsp;
<b id="zchg">$0.00</b>/yr or
<b id="zchgm">$0.00</b>/mth
</span><br></p>
<p class="cursive12">Rate structure used to compare:<br>
<span><b id="pcomp">OCEC current rate</b></span><br>
Base Meter 1P:
<span id="pbase">0.00</span>
&nbsp; &nbsp; 3P:
<span id="pbase3">0.00</span>
<br>
Demand Chg:
<span id="pdem">0.00</span>
&nbsp; &nbsp; Inc kw:
<span id="pdinc">0</span>
<br>
Base kwh rate:
<span id="prate1">0.0000</span>
<br>
Tier 2 rate:
<span id="prate2">0.0000</span>
&nbsp; &nbsp; Abv kwh:
<span id="ptier2">0</span>
<br>
Tier 3 rate:
<span id="prate3">0.0000</span>
&nbsp; &nbsp; Abv kwh:
<span id="ptier3">0</span>
<br>
Cost of power adj:
<span id="pkopa">0.0000</span>
</p>
<input name="kwh01" value="0" type="hidden">
<input name="kwh02" value="0" type="hidden">
<input name="kwh03" value="0" type="hidden">
<input name="kwh04" value="0" type="hidden">
<input name="kwh05" value="0" type="hidden">
<input name="kwh06" value="0" type="hidden">
<input name="kwh07" value="0" type="hidden">
<input name="kwh08" value="0" type="hidden">
<input name="kwh09" value="0" type="hidden">
<input name="kwh10" value="0" type="hidden">
<input name="kwh11" value="0" type="hidden">
<input name="kwh12" value="0" type="hidden">
<input name="kw01" value="0" type="hidden">
<input name="kw02" value="0" type="hidden">
<input name="kw03" value="0" type="hidden">
<input name="kw04" value="0" type="hidden">
<input name="kw05" value="0" type="hidden">
<input name="kw06" value="0" type="hidden">
<input name="kw07" value="0" type="hidden">
<input name="kw08" value="0" type="hidden">
<input name="kw09" value="0" type="hidden">
<input name="kw10" value="0" type="hidden">
<input name="kw11" value="0" type="hidden">
<input name="kw12" value="0" type="hidden">
<input name="kwhtot" value="0" type="hidden">
<input name="kwhavg" value="0" type="hidden">
<input name="kwtot" value="0" type="hidden">
<input name="rank" value="0" type="hidden">
<input name="mtype" value="1" type="hidden">
<input name="xphase" value="1" type="hidden">
<input name="orate" value="0" type="hidden">
<input name="enddat" value="1309" type="hidden">
</form>
</div>

</div>

<div id="footer" style="width:760px;margin-left:20px;margin-top:10px;">
<hr>
<center><p class="txxsmall">This application is provided as a free service to all members of the Okanogan
County Electric Coop<br>
Copyright January 2012 by Ray Peterson of Pasayten Consulting,
Phone: 425-239-3777, email: pasayten@yahoo.com
</p>
</center></div>
</div>
</body>
</html>

pasayten
Ray Peterson
User avatar
mister_coffee
Posts: 978
Joined: Thu Jul 16, 2020 7:35 pm
Location: Winthrop, WA
Contact:

Re: www.MethowValley.org

Post by mister_coffee »

Wimps, all wimps here.

Blast from the past, about 22 years ago:

Code: Select all

<?
        include("include/wp2001.php");
        include("include/view_functions.php");
        ob_end_flush();
?>
<FORM action="logsheets.php" method=POST>
<?
        if (ereg("r=([0-9]+),d=(.+)",$QUERY_STRING,$matches)) {
                $where = $matches[1];
                $date = mysqldate_to_wp2001($matches[2]);
                $action = "Update";
                $QUERY_STRING = "";
        }

        if ($where == "") {
                $where = cookiejar("zone");
        } else {
                fill_cookiejar("zone",$where);
        }

        $form = new html_table;
        $form->init(array("rows" => 2, "cols" => 2));
        $form->table_style= 'BORDER="1" CELLPADDING="2" CELLSPACING="2"';

        $form->cell[1][1]["content"] = "Where";
        $form->cell[1][2]["content"] = myselector(
                "SELECT id,name FROM resources WHERE type=$zone_resourcetype AND active<>0 ORDER BY name",
                "where",$where);

        $form->cell[2][1]["content"] = "Date (mm/dd)";
        $form->cell[2][2]["content"] = myfield("date",25,$date);

        $form->code();
        $form->display();
?>
<BR>
        <INPUT type=submit name=action value=Update></INPUT>
        </FORM>
  <HR WIDTH="100%">
<?
        if ($action == "Update" and $where != "") {
                $q  = "SELECT resourcemap.right_resource,resources.name ";
                $q .= "FROM resourcemap,resources ";
                $q .= "WHERE resourcemap.left_resource=$where AND ";
                $q .= "resourcemap.right_resource=resources.id AND ";
                $q .= "resources.type=$camp_resourcetype ";
                $q .= "ORDER BY resourcemap.stacking_order";

                $r1 = wpquery($q);

                $i = 0;
                while ($row = mysql_fetch_row($r1)) {
                        $resources[$i]["id"]   = $row[0];
                        $resources[$i]["name"] = $row[1];
                        ++$i;
                }

                mysql_free_result($r1);

                $extras = extra_resource_data($resources);
                $extra_col = 0;

                for ($i = 0; $i < count($resources); $i++) {
                        $x = $extras[$resources[$i]["id"]];
                        $resources[$i]["extra"] = $x;

                        if (strlen($x) > 0) $extra_col = 1;
                }

                $range = new date_range($date);
                $base = 1;

                $tbl = new html_table;
                $tbl->init(array("rows" => $i + 1, "cols" => 8 + $extra_col));
                $tbl->table_style= 'BORDER="1" CELLPADDING="2" CELLSPACING="2"';

                for ($i = 0; $i < 7; $i++) {
                        $range->span($i);
                        $tm = $range->raw_last();
                        $tbl->cell[1][$extra_col + 2 + $i]["content"] =
                                "<strong>" . date("m/d",$tm) .
                                "</strong>";
                        $tbl->col_style[$extra_col + 2 + $i] = "VALIGN=TOP";
                }

                $range->span(7);

                for ($i = 0; $i < count($resources); $i++) {
                        // make the camp be a link to the camps view on
                        // the appropriate dates...
                        $url_tail = "r=" . $resources[$i]["id"] . ",d=" .
                                $range->mysql_first();

                        $tbl->cell[2 + $i][1]["content"] =
                                "<A HREF=\"camps.php?$url_tail\">" .
                                "<small>" . $resources[$i]["name"] .
                                "</small></A>";

                        if ($extra_col) {
                                $tbl->cell[2 + $i][2]["content"] =
                                        "<small>" .
                                        $resources[$i]["extra"] .
                                        "</small>";
                        }

                        $list = camp_report($range,$resources[$i]["id"],0);

                        for ($j = 0; $j < 7; $j++) {
                                if ($list[$j] == "") continue;
                                $tbl->cell [2+$i][$extra_col+2+$j]["content"] =
                                        "<small>" . $list[$j] . "</small>";
                        }
                }

                $tbl->code();
                $tbl->display();
                print "<HR WIDTH=\"100%\">\n";

        }
?>

<h2>How This Works</h2>

<UL>
<LI>If you don't enter a date, we use the current date.<P>

<LI>You can enter a date with a four-digit year for a year other than
the current one.  There is plenty of data for 1999 and 2000.<P>

<LI>Choose a zone and you'll see all the permits for that zone (by camps)
for the next week.<P>

</UL>

<h2>To Think About</h2>

<UL>
<LI>It got too busy and too ugly when displaying assigned camp sites as well.
Speed might be a concern too.<P>

<LI>Perhaps a variant of this tool that generates a printable form of
the logsheets that could be used in emergencies would be a good idea.<P>

</UL>

</BODY>
</HTML>
More recent work:

Code: Select all

@router.post("/status", response_model=StatusResult)
async def post_status(item: StatusItem):
    """
        posts status from a device, status data is in the json payload

        returns a dict with one entry (ok) set to 1 on success
    """
    # FIXME:  confirm we are posting for the logged-in device
    check_location(item.latitude, item.longitude)
    check_device_id(item.device_id)

    when = time.time()

    if item.status != "GREEN":
        statuses = await get_device_status(item.device_id)
        changed = False

        if statuses is None:
            changed = True
        else:
            status = statuses[0]
            if status["status"] != item.status:
                changed = True

        if changed:
            get_logger().info(f"{item.device_id}:  status changed to {item.status}")
            wps = await find_watchpoints(item.latitude, item.longitude)

            if wps is not None and len(wps) > 0:
                await enqueue_detection(
                    item.status, item.device_id, item.latitude, item.longitude, wps
                )

    """
        FIXME:  there is an optimization here where when there is no image data,
        in that case we can gather both of these futures rather than run them sequentially
    """
    await note_db_status(when, item)
    await note_status(when, item)

    return StatusResult(ok=1)

PHP is freaking ugly.
:arrow: David Bonn :idea:
User avatar
pasayten
Posts: 1753
Joined: Thu Mar 11, 2021 8:03 pm
Contact:

Re: www.MethowValley.org

Post by pasayten »

I have never programmed in Java before but would love to be able to customize the JtyOne Online ZX81 Emulator to be able to save files once created in the emulator.
Can you copy/paste code to a text editor?

Update...

Ahhh... Tried the emulator... can't copy pixel text to save it... lol...

A long time ago, I wrote a great blackjack program for the Z81... wonder where that tape went... :-)
pasayten
Ray Peterson
User avatar
tristanbgilb
Posts: 980
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

pasayten wrote: Wed Jan 25, 2023 5:57 pm Need some javascript code on here...

Code: Select all

function getMemberData()
{

//alert("get member data:" + crank);
// Load post arguments
loadpost();
var i = 0;
    kmax = 0.0;
    dmax = 0.0;
for (i = 0; i<12; i++)
{
        if ( isNaN(kary[i]) || kary[i] < 0)
        {
	kary[i] =  0;
	dary[i] =  0;
	nary[i] =  0;
	} else {
	nary[i] = 1;
	if (kary[i] > kmax) kmax = kary[i];
	if (dary[i] > dmax) dmax = dary[i];
	}
        if ( pary[i] < 0) pary[i] = 0;
}
grank = (maxrank - crank) * 100 / maxrank;
grank = Number(grank.toFixed(0));

// Draw the Charts
drawChart4();
fillTable();
drawGage();
calcbill();

}

function loadpost ()
{
document.rateform.kwh01.value = kary[0];
document.rateform.kwh02.value = kary[1];
document.rateform.kwh03.value = kary[2];
document.rateform.kwh04.value = kary[3];
document.rateform.kwh05.value = kary[4];
document.rateform.kwh06.value = kary[5];
document.rateform.kwh07.value = kary[6];
document.rateform.kwh08.value = kary[7];
document.rateform.kwh09.value = kary[8];
document.rateform.kwh10.value = kary[9];
document.rateform.kwh11.value = kary[10];
document.rateform.kwh12.value = kary[11];
document.rateform.kw01.value = dary[0];
document.rateform.kw02.value = dary[1];
document.rateform.kw03.value = dary[2];
document.rateform.kw04.value = dary[3];
document.rateform.kw05.value = dary[4];
document.rateform.kw06.value = dary[5];
document.rateform.kw07.value = dary[6];
document.rateform.kw08.value = dary[7];
document.rateform.kw09.value = dary[8];
document.rateform.kw10.value = dary[9];
document.rateform.kw11.value = dary[10];
document.rateform.kw12.value = dary[11];

document.rateform.xphase.value = phase;
document.rateform.kwhtot.value = totk;
document.rateform.kwhavg.value = kavg;
document.rateform.kwtot.value = totd;
document.rateform.orate.value = origrate;
document.rateform.enddat.value = enddat;
//document.rateform.mrec.value = mrec;
//document.rateform.frec.value = frec;


var sel = document.getElementById('kratex');
for(var i, j = 0; i = sel.options[j]; j++) {
   if(i.value == cur_rate) {
       sel.selectedIndex = j;
       break;
    }
    }
}

function wrtvaln(id,x,z,d)
{
	xx = x;
	if (nary[z] > 0)
	{
	document.getElementById(id).innerHTML = xx.toFixed(d);
	} else {
	document.getElementById(id).innerHTML = "-";
	}
}
function wrtval(id,x,d)
{
	xx = x;
	document.getElementById(id).innerHTML = xx.toFixed(d);
}

function wrpct(id,x,d)
{
	xx = x * 100;
	document.getElementById(id).innerHTML = xx.toFixed(d) + "%";
}
function wrrev(id,x,d)
{
	xx = x;
	//if ( Math.abs(xx) < 1.5 ) xx = 0.0;
	if ( xx < 0) {
	xx = xx * -1.0;
	xx = "($" + AddCom(xx.toFixed(d)) + ")";
	document.getElementById(id).innerHTML = xx;
	} else {
	document.getElementById(id).innerHTML = "$" + AddCom(xx.toFixed(d));
	}
}
function AddCom(nStr)
{
        nStr += '';
        nStr = nStr.replace(/,/g, '');
        x = nStr.split('.');
        x1 = x[0];
        x2 = x.length > 1 ? '.' + x[1] : '';
        var rgx = /(\d+)(\d{3})/;
        while (rgx.test(x1))
        {
            x1 = x1.replace(rgx, '$1' + ',' + '$2');
        }
        return x1 + x2;
}



function drawChart4()
{
var moff = 0;
var xoff = 0;
var leg1 = 'Jan-Dec 2020';
var leg2 = 'Jan-Dec 2021';
if (enddat > 2112) {
xoff = enddat - 2200;
leg1 = mary[xoff] + "2020 - " + mary[xoff+11] + "2021";
leg2 = mary[xoff] + "2021 - " + mary[xoff+11] + "2022";
}

var xdata = google.visualization.arrayToDataTable([
           ['Month', leg1, leg2,'kwh 12 month running avg'],
           [mary[xoff], pary[moff], kary[moff], ravg[moff]],
           [mary[xoff+1], pary[moff+1], kary[moff+1], ravg[moff+1]],
           [mary[xoff+2], pary[moff+2], kary[moff+2], ravg[moff+2]],
           [mary[xoff+3], pary[moff+3], kary[moff+3], ravg[moff+3]],
           [mary[xoff+4], pary[moff+4], kary[moff+4], ravg[moff+4]],
           [mary[xoff+5], pary[moff+5], kary[moff+5], ravg[moff+5]],
           [mary[xoff+6], pary[moff+6], kary[moff+6], ravg[moff+6]],
           [mary[xoff+7], pary[moff+7], kary[moff+7], ravg[moff+7]],
           [mary[xoff+8], pary[moff+8], kary[moff+8], ravg[moff+8]],
           [mary[xoff+9], pary[moff+9], kary[moff+9], ravg[moff+9]],
           [mary[xoff+10], pary[moff+10], kary[moff+10], ravg[moff+10]],
           [mary[xoff+11], pary[moff+11], kary[moff+11], ravg[moff+11]]
         ]);


var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
var options = {
  width: 580, height: 320,
  vAxis: {title: 'kwh used', titleTextStyle: {color: 'black', fontSize: 16 }},
  pointSize: 6,
  chartArea: {width: "87%", left: 60, height: "90%", top:15},
  seriesType: "bars",
  legend: {position: 'in', textStyle: {color: 'black', fontSize: 12}},
  series: [{type: 'bars', color: '#F88017'},{type: 'bars', color: 'Blue'},{type: 'line', color: '#800517'}]
  };

 chart.draw(xdata, options);
}




function fillTable()
{

var moff = 0;
var xxg = "G";
var yr1 = " 2021";
var yr2 = " 2021";
if (enddat > 2112) {
moff = enddat - 2200;
yr2 = " 2022";
}
document.getElementById('m1').innerHTML = mary[moff] + yr1;
document.getElementById('m2').innerHTML = mary[moff+1];
document.getElementById('m3').innerHTML = mary[moff+2];
document.getElementById('m4').innerHTML = mary[moff+3];
document.getElementById('m5').innerHTML = mary[moff+4];
document.getElementById('m6').innerHTML = mary[moff+5];
document.getElementById('m7').innerHTML = mary[moff+6];
document.getElementById('m8').innerHTML = mary[moff+7];
document.getElementById('m9').innerHTML = mary[moff+8];
document.getElementById('m10').innerHTML = mary[moff+9];
document.getElementById('m11').innerHTML = mary[moff+10];
document.getElementById('m12').innerHTML = mary[moff+11] + yr2;
wrtvaln('k1',kary[0],0,0);
wrtvaln('k2',kary[1],1.0);
wrtvaln('k3',kary[2],2,0);
wrtvaln('k4',kary[3],3,0);
wrtvaln('k5',kary[4],4,0);
wrtvaln('k6',kary[5],5,0);
wrtvaln('k7',kary[6],6,0);
wrtvaln('k8',kary[7],7,0);
wrtvaln('k9',kary[8],8,0);
wrtvaln('k10',kary[9],9,0);
wrtvaln('k11',kary[10],10,0);
wrtvaln('k12',kary[11],11,0);
wrtval('k13',totk,0);
wrtval('tkwh',totk,0);
wrtval('mxkwh',kmax,0);
wrtval('mavg',kavg,1);
wrtval('krank',crank,0);
wrtval('grk',grank,0);

xxr = 0;
if (cur_rate == 50) xxr = 1;
if (cur_rate == 51) xxr = 2;
if (cur_rate == 52) xxr = 3;
if (cur_rate == 53) xxr = 4;
xxg = "2021 G" + xxr + " Rate";
if (cur_rate == 54) {
	xxr = "Irrig 1P";
	xxg = "2021 Irr1P Rate";
    newcls = "Irrig 1P";
    document.getElementById('ratecd').innerHTML = "5";
}
if (cur_rate == 55) {
	xxr = "Irrig 3P";
	xxg = "2021 Irr3P Rate";
    newcls = "Irrig 3P";
    document.getElementById('ratecd').innerHTML = "6";
}
document.getElementById('newgx').innerHTML = newcls;
document.getElementById('currate').innerHTML = xxr;
//alert(xxg);
document.getElementById('g2015').innerHTML = xxg;

// set member id
document.getElementById('mrec').innerHTML = mrec;
document.getElementById('frec').innerHTML = frec;




// Logic to figure if acceptable class/rate
if ( cur_rate < 54 ) {
  if ( kavg > 16666.0 ) {
  document.getElementById('ratecd').innerHTML = "4";
  } else if ( kavg > 5000.0 ) {
  document.getElementById('ratecd').innerHTML = "3";
  } else if ( kavg > 1200.0 ) {
  document.getElementById('ratecd').innerHTML = "2";
  }
}
// Logic to figure if class/rate OK
// rate g1... class g3/g3
if ( cur_rate == 50 && kavg > 1200.0 ) {
document.getElementById('classchg').innerHTML = "exceeds the limit for Class G1 and you may be changed to Class G2";
}
// rate g2 and class g3
if ( cur_rate == 51 && kavg > 5000.0 ) {
document.getElementById('classchg').innerHTML = "exceeds the limit for Class G2 and you may be changed to Class G3";
}
if ( cur_rate == 56 && kavg > 5000.0 ) {
document.getElementById('classchg').innerHTML = "exceeds the limit for Class G3 and you may be changed to Class G4";
}
// rate g2... class g1
if ( cur_rate == 51 && kavg <= 1200.0 ) {
document.getElementById('classchg').innerHTML = "is less than minimums for Class G2 and you may reduce to Class G1";
}
// rate g2... class g1
if ( cur_rate == 52 && kavg <= 5000.0 ) {
document.getElementById('classchg').innerHTML = "is less than minimums for Class G3 and you may reduce to Class G2";
}
// rate g2... class g1
if ( cur_rate == 53 && kavg <= 16667.0 ) {
document.getElementById('classchg').innerHTML = "is less than minimums for Class G4 and you may reduce to Class G3";
}


wrtvaln('kw1',dary[0],0,2);
wrtvaln('kw2',dary[1],1,2);
wrtvaln('kw3',dary[2],2,2);
wrtvaln('kw4',dary[3],3,2);
wrtvaln('kw5',dary[4],4,2);
wrtvaln('kw6',dary[5],5,2);
wrtvaln('kw7',dary[6],6,2);
wrtvaln('kw8',dary[7],7,2);
wrtvaln('kw9',dary[8],8,2);
wrtvaln('kw10',dary[9],9,2);
wrtvaln('kw11',dary[10],10,2);
wrtvaln('kw12',dary[11],11,2);
//wrtval('kw13',totd,2);
wrtval('mxkw',dmax,2);


}


function drawGage()
{
   var zdata = new google.visualization.DataTable();
   zdata.addColumn('string', 'Label');
   zdata.addColumn('number', 'Value');
   zdata.addRows([
    ['kwh rank', grank]
   ]);
    var options = {
     width: 150, height: 150,
     yellowFrom:60, yellowTo: 100,
     minorTicks: 5
   };
    var chart = new google.visualization.Gauge(document.getElementById('gage_div'));
   chart.draw(zdata, options);
}

function calcrate (rate,docur)
{

var kfac = 1.0;
var kbase1 = 0.0;
var kbase3 = 0.0;
var kbase = 0.0;
var kener = 0.0;
var kdinc = 0.0;
var xt1 = 0;
var xt2 = 0;
var xt3 = 0;
var krate1 = 0.0;
var krate2 = 0.0;
var krate3 = 0.0;
var kopa = 0.0;
var kdem = 0.0;
var zkwh = 0.0;
var xdem = 0.0;
pbill = 0.0;

// Okanogan PUD
if (rate == 1)
{
kbase1 = 39.95;
kener = 0.0;
//xt1 = 500;
//xt2 = 2000;
xt2 = 2000;
krate1 = 0.05441;
krate2 = 0.07019;
kopa = 0.0000;
document.getElementById('pcomp').innerHTML = "Okanogan PUD rate 2021";
}

// Okanogan PUD
if (rate == 2)
{
kbase1 = 42.00;
kener = 0.0;
//xt1 = 500;
//xt2 = 2000;
xt2 = 2000;
krate1 = 0.05824;
krate2 = 0.06989;
kopa = 0.0000;
document.getElementById('pcomp').innerHTML = "Okanogan PUD rate Apr 2023";
}

// Orcas Coop
if (rate == 3)
{
kbase1 = 50.35;
xt2 = 4000;
krate1 = 0.1133;
krate2 = 0.1284;
xt3 = 5000;
krate3 = 0.1478;
kopa = 0.00079;
document.getElementById('pcomp').innerHTML = "OPALCO (Island County) winter rate";
}

// Colville
if (rate == 4)
{
kbase1 = 9.00;
xt2 = 800;
xt3 = 1500;
krate1 = 0.08519;
krate2 = 0.09911;
krate3 = 0.11621;
kfac = 1.06;
document.getElementById('pcomp').innerHTML = "Colville (Avista) rate";
}

// Oregon Trail
if (rate == 5)
{
kbase1 = 33.50;
krate1 = 0.06797;
kopa = 0.00000;
document.getElementById('pcomp').innerHTML = "Oregon Trail rate";
}
// Northern Lites
if (rate == 6)
{
kbase1 = 30.00;
xt2 = 1250;
krate1 = 0.08230;
krate2 = 0.10280;
document.getElementById('pcomp').innerHTML = "Northern Lights (Montana) rate";
}
// Western Oregon
if (rate == 7)
{
kbase1 = 52.00;
xt2 = 1500;
//xt3 = 1200;
krate1 = 0.16930;
krate2 = 0.13410;
//krate3 = 0.0890;
document.getElementById('pcomp').innerHTML = "Western Oregon Coop rate";
}

// Umatilla
if (rate == 200)
{
kbase1 = 22.00;
//xt2 = 1800;
krate1 = 0.0733;
//krate2 = 0.0800;
document.getElementById('pcomp').innerHTML = "Umatilla Electric Winter rate";
}

// Puget Sound Energy
if (rate == 301)
{
kbase1 = 7.49;
xt2 = 600;
krate1 = 0.08593;
krate2 = 0.10490;
document.getElementById('pcomp').innerHTML = "Puget Sound Energy rate";
}

// Tanner Electric
if (rate == 8)
{
kbase1 = 39.83;
krate1 = 0.0998;
document.getElementById('pcomp').innerHTML = "Tanner Electric rate";
}

// Nespelum Electric
if (rate == 9)
{
kbase1 = 23.50;
krate1 = 0.07690;
document.getElementById('pcomp').innerHTML = "Nespelem Electric rate";
}

// Inland Power
if (rate == 11)
{
kbase1 = 24.55;
krate1 = 0.0680;
document.getElementById('pcomp').innerHTML = "Inland Electric rate";
}

// Lakeview Power
if (rate == 91)
{
kbase1 = 25.00;
krate1 = 0.0750;
document.getElementById('pcomp').innerHTML = "Lakeview Electric rate";
}

// Sno county pud
if (rate == 10)
{
kbase1 = 57.00;
krate1 = 0.10174;
document.getElementById('pcomp').innerHTML = "Snohomish County PUD rate";
}


// Ferry Power
if (rate == 12)
{
kbase1 = 20.00;
krate1 = 0.08798;
document.getElementById('pcomp').innerHTML = "Ferry Power rate";
}


// glacier electric
if (rate == 13)
{
kbase1 = 25.00;
krate1 = 0.0725;
document.getElementById('pcomp').innerHTML = "Glacier Electric (Montana) rate";
}

// Chelan PUD
if (rate == 15)
{
kbase1 = 12.95;
krate1 = 0.0270;
document.getElementById('pcomp').innerHTML = "Chelan PUD residential rate";
}


// Parkland
if (rate == 17)
{
kbase1 = 20.00;
krate1 = 0.0671;
document.getElementById('pcomp').innerHTML = "Parkland Light Coop rate";
}

// Big Bend
if (rate == 18)
{
kbase1 = 28.00;
krate1 = 0.06640;
document.getElementById('pcomp').innerHTML = "Big Bend	 rate";
}

// Kittitas PUD
if (rate == 19)
{
kbase1 = 25.50;
krate1 = 0.0982;
document.getElementById('pcomp').innerHTML = "Kittitas PUD rate";
}

// Skamania
if (rate == 20)
{
kbase1 = 47.00;
krate1 = 0.0929;
document.getElementById('pcomp').innerHTML = "Skamania PUD rate";
}

// Pend Oreille
if (rate == 21)
{
kbase1 = 35.50;
krate1 = 0.0623;
document.getElementById('pcomp').innerHTML = "Pend Oreille PUD rate";
}

// Columbia REA
if (rate == 22)
{
kbase1 = 35.00;
krate1 = 0.0902;
document.getElementById('pcomp').innerHTML = "Columbia REA rate";
}


// Seattle
if (rate == 25)
{
kbase1 = 5.06;
xt2 = 480;
krate1 = 0.0780;
krate2 = 0.1326;
document.getElementById('pcomp').innerHTML = "Seattle rate";
}


// Tacoma
if (rate == 26)
{
kbase1 = 16.50;
krate1 = 0.079786;
document.getElementById('pcomp').innerHTML = "Tacoma rate";
}



// Old OCEC
if (rate == 23)
{
kbase1 = 29.00;
xt2 = 1400;
krate1 = 0.048;
krate2 = 0.058;
document.getElementById('pcomp').innerHTML = "OCEC 2006 rate";
}

// General 1 rate
if (rate == 181)
{
kbase1 = 32.00;
kdem = 0.0;
krate1 = 0.081;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 1 Rate (1)";
}

// General 2 rate
if (rate == 182)
{
kbase1 = 50.0;
kdem = 0.0;
krate1 = 0.0678;
xt2 = 5000;
krate2 = 0.0758;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 2 Rate (2)";
}

// General 3 rate
if (rate == 183)
{
kbase1 = 60.0;
kdem = 3.25
krate1 = 0.0493;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 3 Rate (3)";
}

// General 4 rate
if (rate == 184)
{
kbase1 = 145.0;
kdem = 3.25;
krate1 = 0.0477;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 4 Rate (4)";
}


// General Irr 1P rate
if (rate == 185)
{
kbase1 = 46.0;
kdem = 3.25;
krate1 = 0.04950;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Irrigation 1P Rate (5)";
}
// General Irr 3P rate
if (rate == 186)
{
kbase1 = 59.0;
kdem = 3.25;
krate1 = 0.04950;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Irrigation 3P Rate (6)";
}

// General 1 rate
if (rate == 191)
{
kbase1 = 32.00;
kdem = 0.0;
krate1 = 0.0836;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 1 Rate (1)";
}

// General 2 rate
if (rate == 192)
{
kbase1 = 50.0;
kdem = 0.0;
krate1 = 0.0704;
xt2 = 5000;
krate2 = 0.0784;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 2 Rate (2)";
}

// General 3 rate
if (rate == 193)
{
kbase1 = 60.0;
kdem = 3.50
krate1 = 0.05080;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 3 Rate (3)";
}

// General 4 rate
if (rate == 194)
{
kbase1 = 145.0;
kdem = 3.50;
krate1 = 0.0485;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 4 Rate (4)";
}


// General Irr 1P rate
if (rate == 195)
{
kbase1 = 46.0;
kdem = 3.50;
krate1 = 0.0508;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Irrigation 1P Rate (5)";
}
// General Irr 3P rate
if (rate == 196)
{
kbase1 = 59.0;
kdem = 3.50;
krate1 = 0.0508;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Irrigation 3P Rate (6)";
}


// General 1 rate
if (rate == 201)
{
kbase1 = 33.60;
kdem = 0.0;
krate1 = 0.0851;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Gen Service 1 Rate(1)";
}

// General 2 rate
if (rate == 202)
{
kbase1 = 52.50;
kdem = 0.0;
krate1 = 0.0712;
xt2 = 5000;
krate2 = 0.0796;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Gen Service 2 Rate(2)";
}

// General 3 rate
if (rate == 203)
{
kbase1 = 63.0;
kdem = 3.40
krate1 = 0.05180;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Gen Service 3 Rate(3)";
}

// General 4 rate
if (rate == 204)
{
kbase1 = 152.25;
kdem = 3.40;
krate1 = 0.0501;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Gen Service 4 Rate(4)";
}


// General Irr 1P rate
if (rate == 205)
{
kbase1 = 48.30;
kdem = 3.40;
krate1 = 0.0520;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Irrig 1P Rate(5)";
}
// General Irr 3P rate
if (rate == 206)
{
kbase1 = 62.0;
kdem = 3.40;
krate1 = 0.0520;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Irrig 3P Rate 6)";
}

if ( kbase3 == 0 ) kbase3 = kbase1;
kbase = kbase1;
if (phase == 3 )
{
kbase = kbase3;
}
wrtval('pbase',kbase1,2);
wrtval('pbase3',kbase3,2);
//wrtval('pener',kener,2);
//wrtval('ptier1',xt1,0);
wrtval('pdem',kdem,2);
wrtval('pdinc',kdinc,0);
wrtval('prate1',krate1,5);
wrtval('prate2',krate2,5);
wrtval('prate3',krate3,5);
wrtval('ptier2',xt2,0);
wrtval('ptier3',xt3,0);
wrtval('pkopa',kopa,4);

if (docur && origrate == 3) alert("Note: Just for your information, you are signed up for the current alternate rate w/o demand. Click to continue");

for (i = 0; i<12;i++)
{
xkwh = kary[i];
xkw = dary[i];
if (docur) crb[i] = 0;

if (nary[i] && docur)
{
if (cur_rate == 50) {
	crb[i] = 32.00 + (xkwh * 0.081);
	//if (xkwh > 1200) crb[i] = crb[i] + (xkwh -1200) * 0.006;
}
//alert("currate:" + cur_rate);
if (cur_rate == 51) {
	crb[i] = 50.0 + (xkwh * 0.0678);
	if (xkwh > 5000) crb[i] = crb[i] + (xkwh -5000) * 0.008;
}
if (cur_rate == 52) crb[i] = 60.0 + (xkwh * 0.0493) + (xkw * 3.25);
if (cur_rate == 53) crb[i] = 145.0 + (xkwh * 0.0477) + (xkw * 3.25);
if (cur_rate == 54) {
   if ( mary[i] == "Oct" ) {
	   crb[i] = (xkwh * 0.0495) + (xkw * 3.25);
       } else {
	   crb[i] = 46.0 + (xkwh * 0.0495) + (xkw * 3.25);
   }
}

if (cur_rate == 55) {
   if ( mary[i] == "Oct" ) {
	   crb[i] = (xkwh * 0.0495) + (xkw * 3.25);
       } else {
	   crb[i] = 59.0 + (xkwh * 0.0495) + (xkw * 3.25);
   }
}
}
// Calc with propsed rate
   zkwh = 0;
   if ( xt3 > 0 )
   	{
   	if (xkwh > xt3)
   		{
   		zkwh = zkwh + (xkwh - xt3) * krate3;
   		xkwh = xt3;
   		}
   	}
   if ( xt2 > 0 )
   	{
	if (xkwh > xt2)
   		{
   		zkwh = zkwh + (xkwh - xt2) * krate2;
   		xkwh = xt2;
   		}
   	}
   // Check for kwh inc = ktier1
   if (xkwh > xt1)
   	{
   	xkwh = xkwh - xt1;
   	} else {
   	xkwh = 0.0;
	}
   zkwh = zkwh + xkwh * krate1;
   if ( kopa > 0 ) zkwh = zkwh + kary[i] * kopa;

// Calc demand rev
   zdem = 0.0;
   if (kdinc > 0)
   {
   		if (xkw > kdinc )
   		{
   		xkw = xkw - kdinc;
   		} else {
   		xkw = 0.0;
   		}
	}
	zdem = xkw * kdem;
if (nary[i])
	{

        if (cur_rate == 55 || cur_rate == 54) {
			if (mary[i] == "Oct") kbase = 0;
		}
     	prb[i] = (kbase + zkwh + zdem + kener) * kfac;
		chb[i] = (prb[i] - crb[i]) / crb[i];
		if (docur) cbill = cbill + crb[i];
		pbill = pbill + prb[i];
	} else {
		prb[i] = 0;
		chb[i] = 0;
	}

}

chgbill = (pbill - cbill) / cbill;

}


function calcbill ()
{
// Put rates in table...

calcrate(cur_rate,1);
wrrev('o1',crb[0],2);
wrrev('o2',crb[1],2);
wrrev('o3',crb[2],2);
wrrev('o4',crb[3],2);
wrrev('o5',crb[4],2);
wrrev('o6',crb[5],2);
wrrev('o7',crb[6],2);
wrrev('o8',crb[7],2);
wrrev('o9',crb[8],2);
wrrev('o10',crb[9],2);
wrrev('o11',crb[10],2);
wrrev('o12',crb[11],2);
wrrev('o13',cbill,2);
wrrev('zold',cbill,2);
}

function newbill ()
{
// Put rates in table...

var xrate = document.rateform.kratex.value;
calcrate(xrate,0);
wrrev('n1',prb[0],2);
wrrev('n2',prb[1],2);
wrrev('n3',prb[2],2);
wrrev('n4',prb[3],2);
wrrev('n5',prb[4],2);
wrrev('n6',prb[5],2);
wrrev('n7',prb[6],2);
wrrev('n8',prb[7],2);
wrrev('n9',prb[8],2);
wrrev('n10',prb[9],2);
wrrev('n11',prb[10],2);
wrrev('n12',prb[11],2);
wrrev('n13',pbill,2);
wrpct('c1',chb[0],1);
wrpct('c2',chb[1],1);
wrpct('c3',chb[2],1);
wrpct('c4',chb[3],1);
wrpct('c5',chb[4],1);
wrpct('c6',chb[5],1);
wrpct('c7',chb[6],1);
wrpct('c8',chb[7],1);
wrpct('c9',chb[8],1);
wrpct('c10',chb[9],1);
wrpct('c11',chb[10],1);
wrpct('c12',chb[11],1);
wrpct('c13',chgbill,1);
wrrev('zold',cbill,2);
wrrev('znew',pbill,2);
xtemp = pbill - cbill;
wrrev('zchg',xtemp,2);
xtemp = (pbill - cbill)/12.0;
wrrev('zchgm',xtemp,2);

}
I have never programmed in Java before but would love to be able to customize the JtyOne Online ZX81 Emulator to be able to save files once created in the emulator.

Code: Select all

/* EightyOne  - A Windows ZX80/81/clone emulator.
 * Copyright (C) 2003-2006 Michael D Wynne
 * Java translation (C) 2006 Simon Holdsworth
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
package jtyone.main;

import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Canvas;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Label;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import jtyone.config.ZX81Config;
import jtyone.config.ZX81ConfigDefs;
import jtyone.display.AccDraw;
import jtyone.io.KBStatus;
import jtyone.zx81.ZX81;

/**
 * This class allows display of the Jtyone emulator as an application or
 * applet.
 * 
 * @author Simon Holdsworth
 */
public class JtyOne 
extends Applet
implements KeyListener, WindowListener, ActionListener, FocusListener
  {
  private AccDraw mDisplayDrawer;
  private KBStatus mKeyboard;
  private ZX81Config mConfig;
  
  private Canvas mCanvas;
  private Thread mDisplayThread;
  private Button mPauseButton;
  private Button mResetButton;
  private Label mStatusLabel;
  private Label mJtyOneLabel;
  
  /**
   * @param args
   */
  public static 
  void main(String[] args) 
    {
    JtyOne jtyone = new JtyOne();
    Frame f = new Frame("JtyOne Emulator Window");
    jtyone.init(args,f,false);
    // Focus listening is only done for the application. For the applet, that's
    // handled via javascript on the web page.
    f.addWindowListener(jtyone);
    f.addKeyListener(jtyone);
    f.pack();    
    f.setVisible(true);
    jtyone.start();
    }
  
  /** Constructor.
   */
  public
  JtyOne()
    {
    // One-off initialisation.
    mConfig = new ZX81Config();
    mConfig.machine = new ZX81();
    mConfig.load_config();
    mConfig.zx81opts.cwd = ".";
    mConfig.zx81opts.m1not = 32768;
    }
  
  /**
   *  
   */
  public
  void init()
    {
    init(getParameter("tzxFileName"),
         getParameter("hires"),
         getParameter("scale"),
         getParameter("machine"),
         this,true);
    }
  

  /**
   *
   */
  public
  void init(String[] args, Container container, boolean applet )
    {   
    String tzxFileName = (args.length > 0 && !args[0].startsWith("-")) ? args[0] : null;
    String scale = null;
    String hires = null;
    String machine = null;
    
    for( int aPos = tzxFileName == null ? 0 : 1; aPos < args.length; aPos++ )
      {
      if( args[aPos].equals("-scale") && aPos < args.length-1 )
        {
        scale = args[++aPos];    
        }
      if( args[aPos].equals("-hires") && aPos < args.length-1 )
        {
        hires = args[++aPos];    
        }
      if( args[aPos].equals("-machine") && aPos < args.length-1 )
        {
        machine = args[++aPos];    
        }
      }

    init(tzxFileName,hires,scale,machine,container,applet);
    }
  
  /**
   * 
   */
  private
  void init(String tzxFileName, String hires, String scale, String machine, Container container, boolean applet )
    {
    // Sort out any configured options for the emulator.
    if( "ZX80".equals(machine) )
      {
      mConfig.machine.CurRom = mConfig.zx81opts.ROM80;
      mConfig.zx81opts.machine = ZX81ConfigDefs.MACHINEZX80;
      }
    else 
      mConfig.machine.CurRom = mConfig.zx81opts.ROM81;
    
    int scaleCanvas = 2;
    if( scale != null && scale.length() > 0 )
      scaleCanvas = Integer.parseInt(scale);
    
    if( "qs".equals(hires) )
      mConfig.zx81opts.chrgen = ZX81ConfigDefs.CHRGENQS;
    else if( "dk".equals(hires) )
      mConfig.zx81opts.chrgen = ZX81ConfigDefs.CHRGENDK;

    mConfig.machine.initialise(mConfig);

    // Set up keyboard.
    mKeyboard = new KBStatus(mConfig);
    
    // Set up the various components.
    container.setLayout(new BorderLayout());
    container.addKeyListener(this);
    container.addFocusListener(this);
    Panel bottomPanel = new Panel();
    bottomPanel.setLayout(new BorderLayout());
    container.add(bottomPanel,"South");
    Panel buttonPanel = new Panel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
    bottomPanel.add(buttonPanel,"East");
    mPauseButton = new Button("Pause");
    mPauseButton.addActionListener(this);
    buttonPanel.add(mPauseButton);
    mResetButton = new Button("Reset");
    mResetButton.addActionListener(this);
    buttonPanel.add(mResetButton);
    mStatusLabel = new Label("status");
    bottomPanel.add(mStatusLabel,"Center");
    mJtyOneLabel = new Label("JtyOne");
    bottomPanel.add(mJtyOneLabel,"West");

    // Set up the display.
    mDisplayDrawer = new AccDraw(mConfig,mStatusLabel,false,scaleCanvas);
    mCanvas = mDisplayDrawer.getCanvas();
    mCanvas.addFocusListener(this);
    mCanvas.addKeyListener(this);
    container.add(mCanvas,"Center");

    // Load the .TZX file.
    try 
      {
      if( tzxFileName != null )
        {
        String tzxEntry = null;
        int entryNum = 0;
        int atPos = tzxFileName.indexOf('@');
        if( atPos != -1 )
          {
          tzxEntry = tzxFileName.substring(atPos+1);
          tzxFileName = tzxFileName.substring(0,atPos);
          entryNum = Integer.parseInt(tzxEntry);
          }

        mConfig.machine.getTape().loadTZX(mConfig,mKeyboard,tzxFileName,entryNum,applet);
        }
      }
    catch( Exception exc )
      {
      System.out.println("Error: "+exc);
      exc.printStackTrace();
      }
    }

  public
  void start()
    {   
    mCanvas.requestFocus();
    mDisplayThread = new Thread(mDisplayDrawer);
    mDisplayThread.start();           
    }

  /**Stops the applet.
   */
  public void
  stop()
    {
    mDisplayDrawer.stop();
    mDisplayThread.stop();
    mDisplayThread = null;
    }
  
  public void keyPressed(KeyEvent e)
    {
    mKeyboard.PCKeyDown(e.getKeyCode());
    }
  
  public void keyReleased(KeyEvent e) 
    {
    mKeyboard.PCKeyUp(e.getKeyCode());
    }
  
  public void keyTyped(KeyEvent e) 
    {
    }
  
  public void windowOpened(WindowEvent e) { }

  public void windowClosing(WindowEvent e) 
    { 
    stop();
    System.exit(0);
    }

  public void windowClosed(WindowEvent e) 
    { 
    }

  public void windowIconified(WindowEvent e) { }

  public void windowDeiconified(WindowEvent e) { }

  public void windowActivated(WindowEvent e) { }

  public void windowDeactivated(WindowEvent e) { }
  
  public void actionPerformed(ActionEvent e) 
    {
    if( e.getSource() instanceof Button )
      {
      Button button = (Button)e.getSource();
      if( button.getLabel().equals("Pause") )
        windowActive(false);
      else if( button.getLabel().equals("Start") )
        windowActive(true);
      else if( button.getLabel().equals("Reset") )
        {
        mConfig.machine.initialise(mConfig);
        mCanvas.requestFocus();
        windowActive(true);
        }
      }
    }

  public void windowActive(boolean active)
    {
    mDisplayDrawer.setPaused(!active);
    mPauseButton.setLabel(active?"Pause":"Start");
    }

  public void focusGained(FocusEvent e) 
    {
    windowActive(true);
    }

  public void focusLost(FocusEvent e) 
    {
    if( e.getOppositeComponent() != mPauseButton &&
        e.getOppositeComponent() != mResetButton &&
        e.getOppositeComponent() != mCanvas )
      windowActive(false);
    }    
  }
The entire emulator source is available for download here. http://www.zx81stuff.org.uk/zx81/JtyOne.1.3.src.zip
I love this ZX81 emulator only I would also like to be able to load programs in from a text file.
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
pasayten
Posts: 1753
Joined: Thu Mar 11, 2021 8:03 pm
Contact:

Re: www.MethowValley.org

Post by pasayten »

Need some javascript code on here...

Code: Select all

function getMemberData()
{

//alert("get member data:" + crank);
// Load post arguments
loadpost();
var i = 0;
    kmax = 0.0;
    dmax = 0.0;
for (i = 0; i<12; i++)
{
        if ( isNaN(kary[i]) || kary[i] < 0)
        {
	kary[i] =  0;
	dary[i] =  0;
	nary[i] =  0;
	} else {
	nary[i] = 1;
	if (kary[i] > kmax) kmax = kary[i];
	if (dary[i] > dmax) dmax = dary[i];
	}
        if ( pary[i] < 0) pary[i] = 0;
}
grank = (maxrank - crank) * 100 / maxrank;
grank = Number(grank.toFixed(0));

// Draw the Charts
drawChart4();
fillTable();
drawGage();
calcbill();

}

function loadpost ()
{
document.rateform.kwh01.value = kary[0];
document.rateform.kwh02.value = kary[1];
document.rateform.kwh03.value = kary[2];
document.rateform.kwh04.value = kary[3];
document.rateform.kwh05.value = kary[4];
document.rateform.kwh06.value = kary[5];
document.rateform.kwh07.value = kary[6];
document.rateform.kwh08.value = kary[7];
document.rateform.kwh09.value = kary[8];
document.rateform.kwh10.value = kary[9];
document.rateform.kwh11.value = kary[10];
document.rateform.kwh12.value = kary[11];
document.rateform.kw01.value = dary[0];
document.rateform.kw02.value = dary[1];
document.rateform.kw03.value = dary[2];
document.rateform.kw04.value = dary[3];
document.rateform.kw05.value = dary[4];
document.rateform.kw06.value = dary[5];
document.rateform.kw07.value = dary[6];
document.rateform.kw08.value = dary[7];
document.rateform.kw09.value = dary[8];
document.rateform.kw10.value = dary[9];
document.rateform.kw11.value = dary[10];
document.rateform.kw12.value = dary[11];

document.rateform.xphase.value = phase;
document.rateform.kwhtot.value = totk;
document.rateform.kwhavg.value = kavg;
document.rateform.kwtot.value = totd;
document.rateform.orate.value = origrate;
document.rateform.enddat.value = enddat;
//document.rateform.mrec.value = mrec;
//document.rateform.frec.value = frec;


var sel = document.getElementById('kratex');
for(var i, j = 0; i = sel.options[j]; j++) {
   if(i.value == cur_rate) {
       sel.selectedIndex = j;
       break;
    }
    }
}

function wrtvaln(id,x,z,d)
{
	xx = x;
	if (nary[z] > 0)
	{
	document.getElementById(id).innerHTML = xx.toFixed(d);
	} else {
	document.getElementById(id).innerHTML = "-";
	}
}
function wrtval(id,x,d)
{
	xx = x;
	document.getElementById(id).innerHTML = xx.toFixed(d);
}

function wrpct(id,x,d)
{
	xx = x * 100;
	document.getElementById(id).innerHTML = xx.toFixed(d) + "%";
}
function wrrev(id,x,d)
{
	xx = x;
	//if ( Math.abs(xx) < 1.5 ) xx = 0.0;
	if ( xx < 0) {
	xx = xx * -1.0;
	xx = "($" + AddCom(xx.toFixed(d)) + ")";
	document.getElementById(id).innerHTML = xx;
	} else {
	document.getElementById(id).innerHTML = "$" + AddCom(xx.toFixed(d));
	}
}
function AddCom(nStr)
{
        nStr += '';
        nStr = nStr.replace(/,/g, '');
        x = nStr.split('.');
        x1 = x[0];
        x2 = x.length > 1 ? '.' + x[1] : '';
        var rgx = /(\d+)(\d{3})/;
        while (rgx.test(x1))
        {
            x1 = x1.replace(rgx, '$1' + ',' + '$2');
        }
        return x1 + x2;
}



function drawChart4()
{
var moff = 0;
var xoff = 0;
var leg1 = 'Jan-Dec 2020';
var leg2 = 'Jan-Dec 2021';
if (enddat > 2112) {
xoff = enddat - 2200;
leg1 = mary[xoff] + "2020 - " + mary[xoff+11] + "2021";
leg2 = mary[xoff] + "2021 - " + mary[xoff+11] + "2022";
}

var xdata = google.visualization.arrayToDataTable([
           ['Month', leg1, leg2,'kwh 12 month running avg'],
           [mary[xoff], pary[moff], kary[moff], ravg[moff]],
           [mary[xoff+1], pary[moff+1], kary[moff+1], ravg[moff+1]],
           [mary[xoff+2], pary[moff+2], kary[moff+2], ravg[moff+2]],
           [mary[xoff+3], pary[moff+3], kary[moff+3], ravg[moff+3]],
           [mary[xoff+4], pary[moff+4], kary[moff+4], ravg[moff+4]],
           [mary[xoff+5], pary[moff+5], kary[moff+5], ravg[moff+5]],
           [mary[xoff+6], pary[moff+6], kary[moff+6], ravg[moff+6]],
           [mary[xoff+7], pary[moff+7], kary[moff+7], ravg[moff+7]],
           [mary[xoff+8], pary[moff+8], kary[moff+8], ravg[moff+8]],
           [mary[xoff+9], pary[moff+9], kary[moff+9], ravg[moff+9]],
           [mary[xoff+10], pary[moff+10], kary[moff+10], ravg[moff+10]],
           [mary[xoff+11], pary[moff+11], kary[moff+11], ravg[moff+11]]
         ]);


var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
var options = {
  width: 580, height: 320,
  vAxis: {title: 'kwh used', titleTextStyle: {color: 'black', fontSize: 16 }},
  pointSize: 6,
  chartArea: {width: "87%", left: 60, height: "90%", top:15},
  seriesType: "bars",
  legend: {position: 'in', textStyle: {color: 'black', fontSize: 12}},
  series: [{type: 'bars', color: '#F88017'},{type: 'bars', color: 'Blue'},{type: 'line', color: '#800517'}]
  };

 chart.draw(xdata, options);
}




function fillTable()
{

var moff = 0;
var xxg = "G";
var yr1 = " 2021";
var yr2 = " 2021";
if (enddat > 2112) {
moff = enddat - 2200;
yr2 = " 2022";
}
document.getElementById('m1').innerHTML = mary[moff] + yr1;
document.getElementById('m2').innerHTML = mary[moff+1];
document.getElementById('m3').innerHTML = mary[moff+2];
document.getElementById('m4').innerHTML = mary[moff+3];
document.getElementById('m5').innerHTML = mary[moff+4];
document.getElementById('m6').innerHTML = mary[moff+5];
document.getElementById('m7').innerHTML = mary[moff+6];
document.getElementById('m8').innerHTML = mary[moff+7];
document.getElementById('m9').innerHTML = mary[moff+8];
document.getElementById('m10').innerHTML = mary[moff+9];
document.getElementById('m11').innerHTML = mary[moff+10];
document.getElementById('m12').innerHTML = mary[moff+11] + yr2;
wrtvaln('k1',kary[0],0,0);
wrtvaln('k2',kary[1],1.0);
wrtvaln('k3',kary[2],2,0);
wrtvaln('k4',kary[3],3,0);
wrtvaln('k5',kary[4],4,0);
wrtvaln('k6',kary[5],5,0);
wrtvaln('k7',kary[6],6,0);
wrtvaln('k8',kary[7],7,0);
wrtvaln('k9',kary[8],8,0);
wrtvaln('k10',kary[9],9,0);
wrtvaln('k11',kary[10],10,0);
wrtvaln('k12',kary[11],11,0);
wrtval('k13',totk,0);
wrtval('tkwh',totk,0);
wrtval('mxkwh',kmax,0);
wrtval('mavg',kavg,1);
wrtval('krank',crank,0);
wrtval('grk',grank,0);

xxr = 0;
if (cur_rate == 50) xxr = 1;
if (cur_rate == 51) xxr = 2;
if (cur_rate == 52) xxr = 3;
if (cur_rate == 53) xxr = 4;
xxg = "2021 G" + xxr + " Rate";
if (cur_rate == 54) {
	xxr = "Irrig 1P";
	xxg = "2021 Irr1P Rate";
    newcls = "Irrig 1P";
    document.getElementById('ratecd').innerHTML = "5";
}
if (cur_rate == 55) {
	xxr = "Irrig 3P";
	xxg = "2021 Irr3P Rate";
    newcls = "Irrig 3P";
    document.getElementById('ratecd').innerHTML = "6";
}
document.getElementById('newgx').innerHTML = newcls;
document.getElementById('currate').innerHTML = xxr;
//alert(xxg);
document.getElementById('g2015').innerHTML = xxg;

// set member id
document.getElementById('mrec').innerHTML = mrec;
document.getElementById('frec').innerHTML = frec;




// Logic to figure if acceptable class/rate
if ( cur_rate < 54 ) {
  if ( kavg > 16666.0 ) {
  document.getElementById('ratecd').innerHTML = "4";
  } else if ( kavg > 5000.0 ) {
  document.getElementById('ratecd').innerHTML = "3";
  } else if ( kavg > 1200.0 ) {
  document.getElementById('ratecd').innerHTML = "2";
  }
}
// Logic to figure if class/rate OK
// rate g1... class g3/g3
if ( cur_rate == 50 && kavg > 1200.0 ) {
document.getElementById('classchg').innerHTML = "exceeds the limit for Class G1 and you may be changed to Class G2";
}
// rate g2 and class g3
if ( cur_rate == 51 && kavg > 5000.0 ) {
document.getElementById('classchg').innerHTML = "exceeds the limit for Class G2 and you may be changed to Class G3";
}
if ( cur_rate == 56 && kavg > 5000.0 ) {
document.getElementById('classchg').innerHTML = "exceeds the limit for Class G3 and you may be changed to Class G4";
}
// rate g2... class g1
if ( cur_rate == 51 && kavg <= 1200.0 ) {
document.getElementById('classchg').innerHTML = "is less than minimums for Class G2 and you may reduce to Class G1";
}
// rate g2... class g1
if ( cur_rate == 52 && kavg <= 5000.0 ) {
document.getElementById('classchg').innerHTML = "is less than minimums for Class G3 and you may reduce to Class G2";
}
// rate g2... class g1
if ( cur_rate == 53 && kavg <= 16667.0 ) {
document.getElementById('classchg').innerHTML = "is less than minimums for Class G4 and you may reduce to Class G3";
}


wrtvaln('kw1',dary[0],0,2);
wrtvaln('kw2',dary[1],1,2);
wrtvaln('kw3',dary[2],2,2);
wrtvaln('kw4',dary[3],3,2);
wrtvaln('kw5',dary[4],4,2);
wrtvaln('kw6',dary[5],5,2);
wrtvaln('kw7',dary[6],6,2);
wrtvaln('kw8',dary[7],7,2);
wrtvaln('kw9',dary[8],8,2);
wrtvaln('kw10',dary[9],9,2);
wrtvaln('kw11',dary[10],10,2);
wrtvaln('kw12',dary[11],11,2);
//wrtval('kw13',totd,2);
wrtval('mxkw',dmax,2);


}


function drawGage()
{
   var zdata = new google.visualization.DataTable();
   zdata.addColumn('string', 'Label');
   zdata.addColumn('number', 'Value');
   zdata.addRows([
    ['kwh rank', grank]
   ]);
    var options = {
     width: 150, height: 150,
     yellowFrom:60, yellowTo: 100,
     minorTicks: 5
   };
    var chart = new google.visualization.Gauge(document.getElementById('gage_div'));
   chart.draw(zdata, options);
}

function calcrate (rate,docur)
{

var kfac = 1.0;
var kbase1 = 0.0;
var kbase3 = 0.0;
var kbase = 0.0;
var kener = 0.0;
var kdinc = 0.0;
var xt1 = 0;
var xt2 = 0;
var xt3 = 0;
var krate1 = 0.0;
var krate2 = 0.0;
var krate3 = 0.0;
var kopa = 0.0;
var kdem = 0.0;
var zkwh = 0.0;
var xdem = 0.0;
pbill = 0.0;

// Okanogan PUD
if (rate == 1)
{
kbase1 = 39.95;
kener = 0.0;
//xt1 = 500;
//xt2 = 2000;
xt2 = 2000;
krate1 = 0.05441;
krate2 = 0.07019;
kopa = 0.0000;
document.getElementById('pcomp').innerHTML = "Okanogan PUD rate 2021";
}

// Okanogan PUD
if (rate == 2)
{
kbase1 = 42.00;
kener = 0.0;
//xt1 = 500;
//xt2 = 2000;
xt2 = 2000;
krate1 = 0.05824;
krate2 = 0.06989;
kopa = 0.0000;
document.getElementById('pcomp').innerHTML = "Okanogan PUD rate Apr 2023";
}

// Orcas Coop
if (rate == 3)
{
kbase1 = 50.35;
xt2 = 4000;
krate1 = 0.1133;
krate2 = 0.1284;
xt3 = 5000;
krate3 = 0.1478;
kopa = 0.00079;
document.getElementById('pcomp').innerHTML = "OPALCO (Island County) winter rate";
}

// Colville
if (rate == 4)
{
kbase1 = 9.00;
xt2 = 800;
xt3 = 1500;
krate1 = 0.08519;
krate2 = 0.09911;
krate3 = 0.11621;
kfac = 1.06;
document.getElementById('pcomp').innerHTML = "Colville (Avista) rate";
}

// Oregon Trail
if (rate == 5)
{
kbase1 = 33.50;
krate1 = 0.06797;
kopa = 0.00000;
document.getElementById('pcomp').innerHTML = "Oregon Trail rate";
}
// Northern Lites
if (rate == 6)
{
kbase1 = 30.00;
xt2 = 1250;
krate1 = 0.08230;
krate2 = 0.10280;
document.getElementById('pcomp').innerHTML = "Northern Lights (Montana) rate";
}
// Western Oregon
if (rate == 7)
{
kbase1 = 52.00;
xt2 = 1500;
//xt3 = 1200;
krate1 = 0.16930;
krate2 = 0.13410;
//krate3 = 0.0890;
document.getElementById('pcomp').innerHTML = "Western Oregon Coop rate";
}

// Umatilla
if (rate == 200)
{
kbase1 = 22.00;
//xt2 = 1800;
krate1 = 0.0733;
//krate2 = 0.0800;
document.getElementById('pcomp').innerHTML = "Umatilla Electric Winter rate";
}

// Puget Sound Energy
if (rate == 301)
{
kbase1 = 7.49;
xt2 = 600;
krate1 = 0.08593;
krate2 = 0.10490;
document.getElementById('pcomp').innerHTML = "Puget Sound Energy rate";
}

// Tanner Electric
if (rate == 8)
{
kbase1 = 39.83;
krate1 = 0.0998;
document.getElementById('pcomp').innerHTML = "Tanner Electric rate";
}

// Nespelum Electric
if (rate == 9)
{
kbase1 = 23.50;
krate1 = 0.07690;
document.getElementById('pcomp').innerHTML = "Nespelem Electric rate";
}

// Inland Power
if (rate == 11)
{
kbase1 = 24.55;
krate1 = 0.0680;
document.getElementById('pcomp').innerHTML = "Inland Electric rate";
}

// Lakeview Power
if (rate == 91)
{
kbase1 = 25.00;
krate1 = 0.0750;
document.getElementById('pcomp').innerHTML = "Lakeview Electric rate";
}

// Sno county pud
if (rate == 10)
{
kbase1 = 57.00;
krate1 = 0.10174;
document.getElementById('pcomp').innerHTML = "Snohomish County PUD rate";
}


// Ferry Power
if (rate == 12)
{
kbase1 = 20.00;
krate1 = 0.08798;
document.getElementById('pcomp').innerHTML = "Ferry Power rate";
}


// glacier electric
if (rate == 13)
{
kbase1 = 25.00;
krate1 = 0.0725;
document.getElementById('pcomp').innerHTML = "Glacier Electric (Montana) rate";
}

// Chelan PUD
if (rate == 15)
{
kbase1 = 12.95;
krate1 = 0.0270;
document.getElementById('pcomp').innerHTML = "Chelan PUD residential rate";
}


// Parkland
if (rate == 17)
{
kbase1 = 20.00;
krate1 = 0.0671;
document.getElementById('pcomp').innerHTML = "Parkland Light Coop rate";
}

// Big Bend
if (rate == 18)
{
kbase1 = 28.00;
krate1 = 0.06640;
document.getElementById('pcomp').innerHTML = "Big Bend	 rate";
}

// Kittitas PUD
if (rate == 19)
{
kbase1 = 25.50;
krate1 = 0.0982;
document.getElementById('pcomp').innerHTML = "Kittitas PUD rate";
}

// Skamania
if (rate == 20)
{
kbase1 = 47.00;
krate1 = 0.0929;
document.getElementById('pcomp').innerHTML = "Skamania PUD rate";
}

// Pend Oreille
if (rate == 21)
{
kbase1 = 35.50;
krate1 = 0.0623;
document.getElementById('pcomp').innerHTML = "Pend Oreille PUD rate";
}

// Columbia REA
if (rate == 22)
{
kbase1 = 35.00;
krate1 = 0.0902;
document.getElementById('pcomp').innerHTML = "Columbia REA rate";
}


// Seattle
if (rate == 25)
{
kbase1 = 5.06;
xt2 = 480;
krate1 = 0.0780;
krate2 = 0.1326;
document.getElementById('pcomp').innerHTML = "Seattle rate";
}


// Tacoma
if (rate == 26)
{
kbase1 = 16.50;
krate1 = 0.079786;
document.getElementById('pcomp').innerHTML = "Tacoma rate";
}



// Old OCEC
if (rate == 23)
{
kbase1 = 29.00;
xt2 = 1400;
krate1 = 0.048;
krate2 = 0.058;
document.getElementById('pcomp').innerHTML = "OCEC 2006 rate";
}

// General 1 rate
if (rate == 181)
{
kbase1 = 32.00;
kdem = 0.0;
krate1 = 0.081;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 1 Rate (1)";
}

// General 2 rate
if (rate == 182)
{
kbase1 = 50.0;
kdem = 0.0;
krate1 = 0.0678;
xt2 = 5000;
krate2 = 0.0758;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 2 Rate (2)";
}

// General 3 rate
if (rate == 183)
{
kbase1 = 60.0;
kdem = 3.25
krate1 = 0.0493;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 3 Rate (3)";
}

// General 4 rate
if (rate == 184)
{
kbase1 = 145.0;
kdem = 3.25;
krate1 = 0.0477;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 4 Rate (4)";
}


// General Irr 1P rate
if (rate == 185)
{
kbase1 = 46.0;
kdem = 3.25;
krate1 = 0.04950;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Irrigation 1P Rate (5)";
}
// General Irr 3P rate
if (rate == 186)
{
kbase1 = 59.0;
kdem = 3.25;
krate1 = 0.04950;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Irrigation 3P Rate (6)";
}

// General 1 rate
if (rate == 191)
{
kbase1 = 32.00;
kdem = 0.0;
krate1 = 0.0836;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 1 Rate (1)";
}

// General 2 rate
if (rate == 192)
{
kbase1 = 50.0;
kdem = 0.0;
krate1 = 0.0704;
xt2 = 5000;
krate2 = 0.0784;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 2 Rate (2)";
}

// General 3 rate
if (rate == 193)
{
kbase1 = 60.0;
kdem = 3.50
krate1 = 0.05080;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 3 Rate (3)";
}

// General 4 rate
if (rate == 194)
{
kbase1 = 145.0;
kdem = 3.50;
krate1 = 0.0485;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 4 Rate (4)";
}


// General Irr 1P rate
if (rate == 195)
{
kbase1 = 46.0;
kdem = 3.50;
krate1 = 0.0508;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Irrigation 1P Rate (5)";
}
// General Irr 3P rate
if (rate == 196)
{
kbase1 = 59.0;
kdem = 3.50;
krate1 = 0.0508;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Irrigation 3P Rate (6)";
}


// General 1 rate
if (rate == 201)
{
kbase1 = 33.60;
kdem = 0.0;
krate1 = 0.0851;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Gen Service 1 Rate(1)";
}

// General 2 rate
if (rate == 202)
{
kbase1 = 52.50;
kdem = 0.0;
krate1 = 0.0712;
xt2 = 5000;
krate2 = 0.0796;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Gen Service 2 Rate(2)";
}

// General 3 rate
if (rate == 203)
{
kbase1 = 63.0;
kdem = 3.40
krate1 = 0.05180;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Gen Service 3 Rate(3)";
}

// General 4 rate
if (rate == 204)
{
kbase1 = 152.25;
kdem = 3.40;
krate1 = 0.0501;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Gen Service 4 Rate(4)";
}


// General Irr 1P rate
if (rate == 205)
{
kbase1 = 48.30;
kdem = 3.40;
krate1 = 0.0520;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Irrig 1P Rate(5)";
}
// General Irr 3P rate
if (rate == 206)
{
kbase1 = 62.0;
kdem = 3.40;
krate1 = 0.0520;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Irrig 3P Rate 6)";
}

if ( kbase3 == 0 ) kbase3 = kbase1;
kbase = kbase1;
if (phase == 3 )
{
kbase = kbase3;
}
wrtval('pbase',kbase1,2);
wrtval('pbase3',kbase3,2);
//wrtval('pener',kener,2);
//wrtval('ptier1',xt1,0);
wrtval('pdem',kdem,2);
wrtval('pdinc',kdinc,0);
wrtval('prate1',krate1,5);
wrtval('prate2',krate2,5);
wrtval('prate3',krate3,5);
wrtval('ptier2',xt2,0);
wrtval('ptier3',xt3,0);
wrtval('pkopa',kopa,4);

if (docur && origrate == 3) alert("Note: Just for your information, you are signed up for the current alternate rate w/o demand. Click to continue");

for (i = 0; i<12;i++)
{
xkwh = kary[i];
xkw = dary[i];
if (docur) crb[i] = 0;

if (nary[i] && docur)
{
if (cur_rate == 50) {
	crb[i] = 32.00 + (xkwh * 0.081);
	//if (xkwh > 1200) crb[i] = crb[i] + (xkwh -1200) * 0.006;
}
//alert("currate:" + cur_rate);
if (cur_rate == 51) {
	crb[i] = 50.0 + (xkwh * 0.0678);
	if (xkwh > 5000) crb[i] = crb[i] + (xkwh -5000) * 0.008;
}
if (cur_rate == 52) crb[i] = 60.0 + (xkwh * 0.0493) + (xkw * 3.25);
if (cur_rate == 53) crb[i] = 145.0 + (xkwh * 0.0477) + (xkw * 3.25);
if (cur_rate == 54) {
   if ( mary[i] == "Oct" ) {
	   crb[i] = (xkwh * 0.0495) + (xkw * 3.25);
       } else {
	   crb[i] = 46.0 + (xkwh * 0.0495) + (xkw * 3.25);
   }
}

if (cur_rate == 55) {
   if ( mary[i] == "Oct" ) {
	   crb[i] = (xkwh * 0.0495) + (xkw * 3.25);
       } else {
	   crb[i] = 59.0 + (xkwh * 0.0495) + (xkw * 3.25);
   }
}
}
// Calc with propsed rate
   zkwh = 0;
   if ( xt3 > 0 )
   	{
   	if (xkwh > xt3)
   		{
   		zkwh = zkwh + (xkwh - xt3) * krate3;
   		xkwh = xt3;
   		}
   	}
   if ( xt2 > 0 )
   	{
	if (xkwh > xt2)
   		{
   		zkwh = zkwh + (xkwh - xt2) * krate2;
   		xkwh = xt2;
   		}
   	}
   // Check for kwh inc = ktier1
   if (xkwh > xt1)
   	{
   	xkwh = xkwh - xt1;
   	} else {
   	xkwh = 0.0;
	}
   zkwh = zkwh + xkwh * krate1;
   if ( kopa > 0 ) zkwh = zkwh + kary[i] * kopa;

// Calc demand rev
   zdem = 0.0;
   if (kdinc > 0)
   {
   		if (xkw > kdinc )
   		{
   		xkw = xkw - kdinc;
   		} else {
   		xkw = 0.0;
   		}
	}
	zdem = xkw * kdem;
if (nary[i])
	{

        if (cur_rate == 55 || cur_rate == 54) {
			if (mary[i] == "Oct") kbase = 0;
		}
     	prb[i] = (kbase + zkwh + zdem + kener) * kfac;
		chb[i] = (prb[i] - crb[i]) / crb[i];
		if (docur) cbill = cbill + crb[i];
		pbill = pbill + prb[i];
	} else {
		prb[i] = 0;
		chb[i] = 0;
	}

}

chgbill = (pbill - cbill) / cbill;

}


function calcbill ()
{
// Put rates in table...

calcrate(cur_rate,1);
wrrev('o1',crb[0],2);
wrrev('o2',crb[1],2);
wrrev('o3',crb[2],2);
wrrev('o4',crb[3],2);
wrrev('o5',crb[4],2);
wrrev('o6',crb[5],2);
wrrev('o7',crb[6],2);
wrrev('o8',crb[7],2);
wrrev('o9',crb[8],2);
wrrev('o10',crb[9],2);
wrrev('o11',crb[10],2);
wrrev('o12',crb[11],2);
wrrev('o13',cbill,2);
wrrev('zold',cbill,2);
}

function newbill ()
{
// Put rates in table...

var xrate = document.rateform.kratex.value;
calcrate(xrate,0);
wrrev('n1',prb[0],2);
wrrev('n2',prb[1],2);
wrrev('n3',prb[2],2);
wrrev('n4',prb[3],2);
wrrev('n5',prb[4],2);
wrrev('n6',prb[5],2);
wrrev('n7',prb[6],2);
wrrev('n8',prb[7],2);
wrrev('n9',prb[8],2);
wrrev('n10',prb[9],2);
wrrev('n11',prb[10],2);
wrrev('n12',prb[11],2);
wrrev('n13',pbill,2);
wrpct('c1',chb[0],1);
wrpct('c2',chb[1],1);
wrpct('c3',chb[2],1);
wrpct('c4',chb[3],1);
wrpct('c5',chb[4],1);
wrpct('c6',chb[5],1);
wrpct('c7',chb[6],1);
wrpct('c8',chb[7],1);
wrpct('c9',chb[8],1);
wrpct('c10',chb[9],1);
wrpct('c11',chb[10],1);
wrpct('c12',chb[11],1);
wrpct('c13',chgbill,1);
wrrev('zold',cbill,2);
wrrev('znew',pbill,2);
xtemp = pbill - cbill;
wrrev('zchg',xtemp,2);
xtemp = (pbill - cbill)/12.0;
wrrev('zchgm',xtemp,2);

}
pasayten
Ray Peterson
User avatar
tristanbgilb
Posts: 980
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

Image
Attachments
Avenger.Cover.jpg
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 980
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

Image
Attachments
zxcompilerlisting.png
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 980
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

tristanbgilb wrote: Sun Jan 22, 2023 9:51 am Avenger is my favorite video game for the Timex Sinclair 1000 ZX81


Image
tristanbgilb wrote: Tue Feb 08, 2022 4:01 pm http://www.zx81stuff.org.uk/zx81/jtyone.html

Image
I have the instructions to the ZX-Compiler for the Timex Sinclair 1000 ZX81
SILVERSOFT ZX Compiler

Instruction Manual for Silversoft ZX Compiler

Page 1
SILVERSOFT
Introducing the ZX Compiler
Instructions on loading.
Place the cassette on side A, into the recorder. Follow loading instructions, as found in chapter 16 of the ZX81 manual. If at first the program does not load, try different tone and volume levels. If after this it still does not load, try a different tape recorder. There are two copies of ZX COMPILER on the tape. (Use File name "COMPILER")

About the ZX Compiler
The ZX COMPILER is a program, written in basic and machine code that will change a program in "BASIC" into machine code. This can be used to create programs or sub routines that can run up to twenty or thirty times faster than normal 'BASIC'. Because the ZX81 only has a capacity of 16K ram the compiler works in an integer-only, sub-set of BASIC. To save even more space commands have been left out that are not needed, for example REM:- which is not needed in compiled programs anyway and INPUT:- which can be made by a routine using gets and if....then statements. Once your program to be compiled is written, you run the compiler. After a period of fast mode, the program "NEWS" itself and leaves you with a single rem statement containing the machine code (it looks like random junk).
Once written you may either call the code from within a program or directly from the keyboard using LET X=USR 16595.

INSTRUCTIONS ON USE
The program to be compiled is written in 'REM' statements before line 1000 beyond line 1000 is the compiler. The reason for REM's is so you can have extra commands that can't be keyed-in, in normal BASIC. This does mean though that you will have to key in whole commands for example PRINT is P-R-I-N-T. eg:
1 REM PRINT"HELLO"
In the program there are to be no spaces, except in print statements. Also goto statements must be followed by a 'true' line, for example the following will not work.
1 REM PRINT"HELLO"
2 REM GOTO28
When you type run and newline, the screen will blank for a few seconds and then print up:
ERROR IN LINE 28
Which means it can't find any line 28
The compiler program may only have variables A-Z, no strings or arrays. (These maybe be implemented using other commands such as peek and poke).
-Variables in the compiler are not the same ZX81 Variables.

Page 2
Numbers may be 0-65535. To get a negative number use 65535-x
eg: -2=65536-2
There may seem a lot you can't do but it is enough to write most programs, (such as space invaders, breakout, etc.) The only way to really find out what the compiler can do is use it, read through the examples and work them out.
COMPILER COMMANDS
In this section I will go through all the commands available on the compiler.
In this section (variable) can mean a number of things:
1) A number 0-65535
2) A letter A-Z
3) RND followed by a variable
4)USR Followed by a variable
5) TOP
6) Deek followed by a variable
7) Peek followed by a variable
eg: RNDA RND200 RNDUSRDEEK16514!!
Top and DEEK need explaining, the others should be clear enough. Top will return the first position on the display that can be poked. It's basic equivalent is : PEEK 16396 + 256 *PEEK 16397 + 1
Deek is the opposite of doke and peeks two locations at the same time. (To return a number 0-65535) Top is the equivalent of DEEK 16396+1. The nascom and other computer use these commands. eg: It can be used for poking a Lazer base with one command.
1 REM DOKE TOP 1153
PRINT
This can either be followed by text enclosed in speech marks or a variable, (A-Z) it will print the chrs of the variable. The semi colon at the end of the print is automatic. To print at the start of a new line use the following:
1 REM PRINT 118
(Which is the same as the BASIC PRINT CHRS 118) So print can be used in two forms which are:
1. PRINT "--TEXT--"
2. PRINT (VARIABLE)
GET
This is the same as the BASIC INKEY, except only it returns the code (0-128) of the key pressed. It may only be used in one form, if no key is pressed it returns 128.
1. GET (VARIABLE)
eg: 1 REM GET A 2 REM PRINT A 3 REM GOTO 1
END
It is important that you end a compiler program with either an END if you want execution to stop, or RETURN (see later) if you want to continue the calling BASIC program.
Page 3
PAUSE
This may only be used in one form:
1) PAUSE (VARIABLE)
It is a delay, the length of which is determined by the (VARIABLE). The longest delay possible would be 65535, it lasts for 2 seconds!!
CLS
This is the same as BASIC CLS except it clears all 24 lines of the display, not just 22. It has only one form:
1. CLS
MOVE
This is the same as the BASIC PRINT AT, except you may "PRINT AT" all 24 lines down. It takes only one form:
1. MOVE (VARIABLE),(VARIABLE)
eg: 1 REM MOVE 23, 10 2 REM PRINT "HELLO" 3 REM END
LET
This is like the BASIC LET statement except you may not have long equations or brackets. It may take only two forms:
1. LET (VARIABLE) = (VARIABLE)
2. LET (VARIABLE) = (OPERATOR) (VARIABLE)
(OPERATOR) can be either +,-,* or /
SCROLL
This is the same as the BASIC SCROLL except that it is a lot quicker and scrolls all 24 lines of the screen.
GOTO
This is like the BASIC goto except the line number must exist. It may only take one form:
1. GOTO NUMBER (1-999)
GOSUB
This is the same as BASIC GOSUB, except for destination line number which must exist. It can only take one form:
1. GOSUB NUMBER (1-999)
RETURN
Used in conjunction with GOSUB, this is identical t its BASIC equivalent. Used when not in a GOSUB sub-routine, it will return you to BASIC and continue with the calling program. It may only take one form:
1. RETURN
PLOT
This is the same as BASIC PLOT. It may take only one form:
1. PLOT (VARIABLE), (VARIABLE)
UNPLOT
This is the same as BASIC UNPLOT. It may take only one form:
1. UNPLOT (VARIABLE),(VARIABLE)
POKE
This is the same as its BASIC equivalent. It may only take one form:
1. POKE (VARIABLE),(VARIABLE)


Page 4
DOKE
Is used on the nascom and other computer, it pokes two locations at the same time with a number of up to 65535. The low byte of the number at the address and the high byte at address +1. For more information see example programs. It can only take one form:
1. DOKE (VARIABLE),(VARIABLE)
IF is used in only one way:
1. IF (VARIABLE) (SIGN)(VARIABLE)______
(SIGN) can mean either =,<>,<>. There is no need to use the then statement. For more information see example programs.
eg: IF A>2 GOTO 10
SCROLL
These are all the commands allowed in the compiler. But as you can see from the example programs, these are enough.
EXAMPLE 1
This program will invert the screen, then Return to basic not stop. It will invert all 24 lines of the display.
1 REM LETB=24
2 REM LETA=TOP
3 REM IFPEEKA=118GOTO10
4 REM LETZ=PEEKA+128 : NUMBER OF LINES
5 REM POKEA,Z : TOP OF SCREEN
6 REM LETA=A+1 : END OF LINE ?
7 REM GOTO3 : INVERT IT
10 REM LET B=B-1
11 REM IFB=0RETURN : "RETURN" TO BASIC, USE END
12 REM GOTO6 STOP WITH AN ERROR CODE:
Try this program out, then try it in BASIC to see how slow it is.
EXAMPLE 2
This program demonstrates the DEEK and DOKE commands, DOKE is used to 'save' the variable while it is used for something else, DEEK reads it back again.
1 REM LETA=45192
2 REM DOKE30000,A
3 REM LETA=0
4 REM LETA=DEEK30000
5 REM IFA<>45192PRINT"THIS WILL NEVER BE PRINTED"
6 REM END
In this program location 30000 was chosen because it is high up in the memory and will not interfere with anything.
WHEN YOU HAVE WRITTEN A PROGRAM
When you have written your program in REM statements, SAVE a copy on cassette (in case you have to de-bug it) Then RUN, this will run the compiler as it will go past REMS. After a delay (10mins for 4k program0 the screen will return. If it says error, correct error and re-run it. If it comes up with one rem followed by junk then it has finished compiling, BEFORE YOU DO ANYTHING ELSE type in: 2 RAND USR 16595

Page 5
Then SAVE another copy of the program and run it. If the program does something odd, try and see what is happening, re-load the first copy and correct the program.
MORE FACTS
Don't forget in machine code there is no 'break' key to test for one use.
1. REM GETA
2. REM IFA=0END
Even a one line compiler program when compiled may seem to take up a lot of room, this is quite normal because about 1K is taken up with variables and routines. The compiler was really developed for small fast routines to be used in a BASIC program or entire games in machine code.
If you want to interchange basic variables and compiler variables, the compiler variables are held at 16514 low byte first, high byte next. A(low) is at 16514, B(low) is at 16515 and so on.
In the program you will see two sets of inverse AJGs this is so the author can identify any compiled program. (No program may be used personal gain which in any way connected with the compiler without the permission of the author.
Try to use POKE and PEEK, (deeks and dokes) more as they are very fast in the compiler. Things like PRINT, PRINT AT, PLOT, UNPLOT use basic routines to space so they will only be executed at about twice the speed as normal.
The RND function is not very random when displaying the results, but it is good enough for normal random decisions. (This is again due to the lack of space available). Compilers available for other computers may need 4K of code for one line of compiled program!!
MORE EXAMPLES
1) Add all the numbers 1-1000 together.
(returns the answer in s 165114+16515)
1 REM LETA=0
2 REM LETC=0
3 REM LETA=A+C
4 REM LETC=C+1
5 REM IFC 101 GOTO3
6 REM END
Type this in, then RUN it, to see the answer
PRINT PEEK 16514+256*PEEK 16515
try out he program in BASIC as well and see the difference in speed

Page 6
2)
1 REM LET P=0
2 REM MOVE23,P
3 REM PRINT34
4 REM GET A
5 REM IFA=33LETp=p-1 key 5
6 REM IFA=36LETp=P+1 key 8
7 REM IFP=65535LETP=0
8 REM IFP=31LETp=30
9 REM SCROLL
10 REM GOTO2


Image
Attachments
Timex-Sinclair1000UserManual_0000.jpg
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests