Demo for KansasFest 2021

This commit is contained in:
Charles Mangin 2021-07-24 00:13:36 -04:00 committed by GitHub
parent 4ca4b069b5
commit 1a2a2719ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 221 additions and 0 deletions

159
SG32.6502 Normal file
View File

@ -0,0 +1,159 @@
DSK SG32
**************************************************
* Version 1.0 - 32-byte output
* By Charles Mangin
* License: CC0 1.0 Universal
* https://creativecommons.org/publicdomain/zero/1.0/
**************************************************
* "To make a Cold Hash, or Salad-Magundy. TAKE a cold Turkey, two cold Chickens,
* or if you have neither, a piece of fine white Veal will do; cut the Breasts of
* these Fowls into fair dices, and Mince all the rest; to the Quantity of two
* Chickens you mull take eight or ten large Anchovies, wash and bone them, eight
* large Pickld Oysters, ten or twelve fine green Pickld Cucumbers, shred the
* Oysters, the Anchovies, the Cucumbers, and one whole Lemon small, mix them with
* the shred Meat, lay it in the middle of the Dish, lay the Dices of the white part
* round the Dish, with halvd Anchovies, whole Pickld Oysters, quarterd Cucumbers,
* sliced Lemon, whole Pickld Mushrooms, Capers or any Pickle you like; cut also
* some fine Lettice, and lay round among the Garnish, but put not Oil and Vinegar
* to the Minced Meat, till it comes to Table."
*
* -- https://en.wikipedia.org/wiki/Salmagundi
**************************************************
* Variables
**************************************************
HASH EQU $800
SCRATCH EQU $900
SEED EQU $B00
MESSAGE EQU $C00
**************************************************
* Apple Standard Memory Locations
**************************************************
COUT EQU $FDED ; CALLS THE OUTPUT ROUTINE
NEWLINE EQU $FD8E ; OUTPUTS NEW LINE/ CARRIAGE RETURN
PRHEX EQU $FDDA ; PRINTS BYTE IN ACCUMULATOR AS HEX
**************************************************
* Let's get this party started
**************************************************
ORG $0300 ; PROGRAM DATA STARTS AT $800
* EC-ED - ITERATIONS
* MESSAGE ORIGIN IN FC,FD
* MESSAGE DESTINATION IN EE,EF
* BLOAD FILE LENGTH AT $AA60 -> FA,FB
CLEARMEM
LDA #$00
TAY
ZERO DEY
STA HASH, Y
BNE ZERO
* EORs MESSAGE TO SCRATCH WITH RUNNING CHECKSUM, PADS WITH BYTES FROM SEED IF NEEDED
LDA #$00 ; ZERO ITERATION COUNT
STA $EC ;
STA $ED ;
STA $FE ; CLEAR CHECKSUM
STA $FC
TAX ;
TAY ;
LDA #$0C
STA $FD
ITERATE INC $ED ; INCREMENT ITERATION COUNT LO <--INCED
BNE ROLLOVER ; ROLLED OVER TO 0?
INC $EC ; IF SO, INCREMENT HI BYTE
ROLLOVER LDA $ED ; ITERATION == MESSAGE LENGTH?
CMP $FA ; BLOAD FILE LENGTH AT $AA60
BNE FULLLENGTH ; NOT YET
LDA $EC ; YES? HOW ABOUT HI BYTE?
CMP $FB ; BLOAD FILE LENGTH AT $AA60
BNE FULLLENGTH ; NOT YET. CONTINUE.
LDA #$0B ; MESSAGE LENGTH COMPLETE
STA $FD ; POINT MESSAGE SOURCE TO SEED PAGE 0B00
LDY #$00 ; ZERO Y OFFSET
STY $FA ; ZERO MESSAGE LENGTH
STY $FB ; ZERO MESSAGE LENGTH
FULLLENGTH LDA ($FC),Y ; LOAD ORIGIN + Y OFFSET
EOR SCRATCH,X ; COMBINE WITH SEED/SCRATCH
STA SCRATCH,X ; STORE DESTINATION + X OFFSET
EOR $FE ; XOR WITH RUNNING CHECKSUM
STA $FE ; STORE CHECKSUM
INY ; NEXT Y OFFSET
BNE NEXTOFFSET ; IF Y=ZERO, NEXT SOURCE PAGE
INC $FD ; IF Y=ZERO, NEXT SOURCE PAGE
NEXTOFFSET INX ; NEXT X OFFSET
CPX #$FF ; IS X=FF
BNE ITERATE ; OTHERWISE LOOP -> INCED
STA SCRATCH,X ; STORE CHECKSUM AT SCRATCH+FF
INX ; ZERO X OFFSET
LDA $FB ; X=0. DOING SEED PADDING?
ORA $FA ; IF SO, FA, FB WILL BE ZERO
BNE ITERATE ; IF FA/FB=ZERO THEN FINISH
* load 4 bytes into FPAcc. Multiply by GRatio. EOR result bytes into hash.
* repeats until all 256 bytes of scratch processed.
LDA GOLDENLO ; GOLDEN RATIO IN FP FORMAT
LDY GOLDENHI
JSR $E9E3 ; PUTS GR INTO ARG (A5-A9)
LDA #$09 ; SCRATCH PAGE SOURCE into FC/FB
STA $FC
LDA #$FC ; last 4 bytes of scratch
STA $FB
HASHLO LDA #$1F ; HASH DESTINATION FE/FD
STA $FD
LDY #$03 ; 4 BYTES AT A GO - FROM RIGHT TO LEFT
HASHHI LDA #$08 ; HASH DESTINATION HI BYTE
STA $FE
LDA #$81
STA $9D ; reset FPA high byte for Multiply
LOADSCRATCH LDA ($FB),Y ; LOAD SCRATCH BYTES INTO FAC
STA $009E,Y ; FAC=9d-a1
DEY
BPL LOADSCRATCH
JSR $E982 ; Multiply FAC and ARG.
LDY #$00
LDA $A1
EOR $A0
EOR $9F
EOR $9E
EOR ($FD),Y ; EOR RESULT BYTES WITH BYTE IN HASH,
STA ($FD),Y ; STORE IN HASH
DEC $FB ; SLIDE UP ONE BYTE AND REPEAT
BEQ PRHASH
DEC $FD ; NEXT BYTE OF HASH
BPL HASHHI
BMI HASHLO
PRHASH LDY #$00 ; print hash as hex
LDX #$08
LDHASH LDA HASH,Y
DOTHETHING JSR PRHEX ; PRINTS HEX CHAR
LDA #$A0
JSR COUT ; SPACE AFTER EACH BYTE
DEX
BNE NEXTHEX
JSR NEWLINE ; NEWLINE AFTER 8 BYTES - PRETTIFY FORMATTING
LDX #$08
NEXTHEX INY
CPY #$20
BNE LDHASH
RTS
GOLDEN EQU *
HEX 81,CF,1B,BC,DD ; golden ratio
GOLDENLO db <GOLDEN
GOLDENHI db >GOLDEN
*** SEED BYTES
*** B3 83 BD D3 1E F4 A6 F5 83 FC B0 10 0C 1F 67 CA DE 53 CB C1 14 64 70 4C B7 EA 51 7A 63 30 88 7E
*** 67 07 7B A7 3C E9 4D EB 07 F9 61 20 18 3E CE 95 BD A6 97 83 28 C8 E0 98 6F D5 A2 F4 C6 60 11 FC
*** CE 0E F6 4F 78 D3 9A D7 0E F3 C2 40 30 7C 9D 2B 7B 4D 2F 07 50 91 C1 31 DE AB 45 E9 8D C0 22 F9
*** 9D 1C ED 9E F0 A7 35 AF 1C E7 85 80 60 F8 3B 56 F6 9A 5E 0E A0 23 83 62 BD 57 8A D3 1B 81 44 F3
*** 3B 38 DB 3D E1 4F 6A 5F 38 CF 0B 01 C0 F1 76 AC ED 35 BC 1C 41 46 07 C4 7B AE 15 A7 36 03 88 E7
*** 76 70 B7 7A C3 9E D4 BE 70 9F 16 02 81 E3 EC 59 DB 6A 79 38 82 8C 0E 89 F6 5D 2A 4F 6C 06 11 CF
*** EC E0 6F F4 87 3D A9 7D E0 3F 2C 04 03 C7 D9 B2 B7 D4 F2 70 05 19 1C 13 ED BA 54 9E D8 0C 22 9F
*** D9 C1 DE E9 0F 7A 53 FA C1 7E 58 08 06 8F B3 65 6F A9 E5 E0 0A 32 38 26 DB 75 A8 3D B1 18 44 3F

BIN
SG32.dsk Normal file

Binary file not shown.

53
hello.bas Normal file
View File

@ -0,0 +1,53 @@
0 GOTO 100: REM ADAPTED FROM https://vintageapple.org/apple_ii/pdf/The_Best_Apple_Public_Domain_Software1985.pdf
10 C1 = INT (CV / 8): C2 = CV - C1 * 8: P = 1024 + 128 * C2 + 40 * C1 + CH: C = PEEK (P): RETURN
100 TEXT: HOME: D$ = CHR$(4): PRINT D$"CATALOG": B = PEEK (37) - 2: IF B > 22 THEN B = 22
110 T = 0: CH = 4: FOR CV = 5 TO 23: GOSUB 10: IF C < > 160 THEN POKE P - 1,219: POKE P,T + 193: POKE P + 1,221: T = T + 1: S = CV
120 NEXT CV: B$ = "BLOAD": HTAB 1 : VTAB 3 : ? "TYPE A LETTER TO CHOOSE THE FILE TO HASH"
130 K = PEEK (-16384): IF K < 128 THEN FOR K = 1 TO 75: NEXT K: K = FRE (0): GOTO 130
140 POKE -16368,0: K = K - 176 : IF K < 17 OR K > T+16 GOTO 130
150 CH = 1:CV = S - T + K - 16: GOSUB 10
160 VTAB 24: ? "LOADING: ";
170 FOR CH = 6 TO 39: GOSUB 10: B$ = B$ + CHR$ (C): ?CHR$ (C) ; : NEXT CH
180 ?"": HTAB 1: CALL -868: PRINT CHR$(4) "BLOAD SEED,A$B00" : PRINT CHR$(4) B$ ",A$C00"
190 POKE 251, PEEK(-21919): POKE 250,PEEK(-21920)
200 HOME: PRINT CHR$(4) "BRUN SG32"
B = VTAB?
REM READS LINE FROM TEXT PAGE
P = MEMORY LOCATION
C = CHARACTER
T=LETTER FOR SELECTION
B$ IS THE COMMAND
CH HORIZ CHAR
CV VERT CHAR
"LEVI"
0 REM 06/06/83
100 TEXT : HOME :D$ = CHR$ (4): PRINT D$"CATALOG":B = PEEK (37) - 2: IF B > 22 THEN B = 22
110 T = 0:CH = 4: FOR CV = 5 TO 23: GOSUB 1000: IF C < > 160 THEN POKE P - 1,219: POKE P,T + 193: POKE P + 1,221:T =T + 1:S = CV
120 NEXT CV: VTAB 24:A$ = "TYPE LETTER TO RUN, OR LOAD=1 LOCK=2 UNLOCK=3 DELETE=4 EXIT=5...."
130 B$ = "RUN": HTAB 1: PRINT LEFT$ (A$,39);:A$ = MID$ (A$,2) + LEFT$ (A$,1):K = PEEK ( -16384): IF K < 128 THEN FOR K = 1 TO 75: NEXT K:K = FRE (0): GOTO 130
140 POKE - 16368,0:K = K - 176: IF K < 1 OR K > 5 THEN 300
200 HTAB 1: CALL - 868: IF K = 5 THEN END
210 PRINT "PRESS 'LETTER' YOU WISH TO ";: IF K = 1 THEN B$ ="LOAD"
220 IF K = 2 THEN B$ = "LOCK"
230 IF K = 3 THEN B$ = "UNLOCK"
240 IF K = 4 THEN B$ = "DELETE": FLASH
250 PRINT B$;: CALL - 198: NORMAL: GET K$:K = ASC (K$) - 48
300 IF K < 17 OR K > T + 16 THEN 130
310 CH = 1:CV = S - T + K - 16: GOSUB 1000: IF C = 194 AND (B$ = "RUN" OR B$ = "LOAD") THEN B$ = "B" + B$
320 FOR CH = 6 TO 39: GOSUB 1000: B$ = B$ + CHR$ (C): NEXT CH: HTAB 1: CALL - 868: PRINT B$: PRINT D$;B$: GOTO 100
1000 C1 = INT (CV / 8):C2 = CV - C1 * 8:P = 1024 + 128 * C2 + 40 * C1 + CH:C = PEEK (P): RETURN

9
lorem.ipsum.bin Normal file
View File

@ -0,0 +1,9 @@
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam condimentum nec arcu sit amet faucibus. Praesent consequat dolor vitae odio pellentesque fermentum. In volutpat felis sit amet mi vulputate, ut pulvinar nunc dignissim. Integer eget placerat neque. Praesent felis velit, ultrices at risus pellentesque, tempus iaculis ante. Cras ac diam ac sapien tincidunt rutrum eu vel enim. Fusce rutrum velit luctus nulla ultrices, quis viverra ligula maximus. Phasellus aliquet dolor ac dictum malesuada. Ut varius consectetur dui fringilla feugiat. Aenean posuere pulvinar ex, eget laoreet odio finibus vitae. In tempor urna metus, vel hendrerit eros pulvinar id. Vestibulum tincidunt quis purus eget ornare. Duis sit amet blandit eros.
Duis sed tempus libero. Aliquam egestas semper erat, id mattis ligula sagittis dignissim. Maecenas vitae facilisis turpis. Vivamus justo nisl, fermentum et urna eget, tempor sagittis sapien. Cras et sapien erat. Nulla venenatis nec velit at egestas. Donec eget ullamcorper neque. Vivamus in massa auctor, venenatis justo nec, auctor metus. Integer sed pretium elit, vel mattis sapien.
Maecenas vel nisi efficitur, aliquam ex blandit, pellentesque erat. Praesent in pulvinar augue. Sed sit amet ipsum ut quam vestibulum commodo. Etiam ipsum risus, viverra et neque sit amet, efficitur fermentum diam. Nunc eu orci odio. Pellentesque vestibulum ipsum vel justo tempus, eget feugiat velit ullamcorper. Curabitur euismod quam nec euismod tincidunt. Etiam auctor tellus ante, sed auctor quam convallis at. Donec tincidunt sollicitudin iaculis. Aliquam non augue tortor. Suspendisse bibendum porttitor aliquet.
Curabitur mattis diam et elit convallis gravida. Mauris sit amet justo quis risus convallis faucibus. Nulla facilisi. Pellentesque ac nunc lobortis, fermentum lectus vehicula, fermentum nulla. Sed egestas et tortor in ornare. Nullam eget eleifend nulla, nec aliquam dui. Mauris ut imperdiet nunc. In lacinia libero in turpis porttitor dictum. Maecenas hendrerit massa at lacus vulputate, ac ullamcorper ligula porta. Aliquam vel arcu elit. Duis purus velit, vulputate commodo felis non, dapibus congue nisl.
In sit amet libero ut neque semper maximus. Vivamus congue risus quis lectus tempor placerat. Quisque ullamcorper ultrices sagittis. Aenean convallis turpis vel sodales auctor. Aliquam et mattis mi, id interdum massa. Etiam cursus rutrum erat, at cursus nibh accumsan ut. Integer blandit lectus sed ex malesuada malesuada. Fusce accumsan neque mi, et rutrum ante bibendum vitae. Nam egestas, risus sed fringilla efficitur, mi magna malesuada arcu, at gravida velit ipsum a risus. Phasellus vestibulum elit eros, feugiat condimentum sem accumsan id. In lobortis orci massa, ut consequat lectus tempus sit amet. Nullam laoreet suscipit odio, in eleifend massa malesuada a. Etiam varius pellentesque mauris sed sagittis. Aenean dolor augue, maximus eget fringilla vel, pharetra at nibh. Donec dui nisi, sodales at mauris ut, venenatis congue turpis.