diff --git a/LICENSE b/LICENSE index eff6ac2..8005d8f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 The Industrious Rabbit +Copyright (c) 2021 John Bintz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 7442c74..c9c7473 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,20 @@ # TheAutomaticProofreader-Decompiled + A decompiled copy of The New Automatic Proofreader with comments + +## Decompile it yourself + +### radare2 + +``` +r2 -a6502 -m4443 ap_6502.prg +pD 166 +``` + +### da65 + + + +## License + +Ruby code is licensed MIT. The Automatic Proofreader code is not mine. diff --git a/ap.asm b/ap.asm new file mode 100644 index 0000000..4deaf2e --- /dev/null +++ b/ap.asm @@ -0,0 +1,169 @@ +; da65 V2.18 - Ubuntu 2.19-1 +; Created: 2021-10-11 14:35:45 +; Input file: ap_6502.prg +; Page: 1 + + + .setcpu "6502" + +L8956 := $8956 +L9BD2 := $9BD2 +LFFD2 := $FFD2 + ;; set interrupt, we can't be interrupted in this block + ;; like a mutex + sei + ;; patching in our own tokenizer routine to $0304 + lda #$49 + sta $0304 + lda #$03 + sta $0305 + ;; clear interrupt + cli + rts + + ;; start of our tokenizer + + ;; line number during GOSUB, GOTO, and RUN + ;; $a7 and $a8 are RS-232 input stuff + lda $14 + sta $A7 + lda $15 + sta $A8 + + ;; $FF00: don't know what's here + lda #$00 + sta $FF00 + + ldx #$1F + ;; reverse mode switch + ... + ;; some sort of setup? +make_text_reversed: lda $C7,x + sta $03E3,x + dex + bpl make_text_reversed + + ;; write #$13 (home), put cursor in upper left corner + lda #$13 + jsr LFFD2 + + ;; i don't know what this is + lda #$12 + jsr L9BD2 + + ;; some places to store data in zero page? + ldy #$00 + + ;; b4 = current character index + sty $B4 + + ;; b0 = are we in a quoted string + sty $B0 + + ;; 0 -> 255 + dey +process_character: inc $B4 + + ;; 255 -> 0 + ;; y = current character position +next_character: iny + + ;; load a character from input buffer + ;; where what you type goes before committing + lda $0200,y + + ;; if result is 0 (null), finish the line + beq done_with_line + cmp #$22 + bne its_not_a_quote + + ;; push current character onto stack + pha + + ;; toggle are we in a string + lda $B0 + eor #$FF + sta $B0 + + ;; pull current character + pla + ;; push character +its_not_a_quote: pha + ;; is this character a space + ;; spaces aren't significant unless we're in quotes + cmp #$20 + ;; no, keep going + bne count_this_character + ;; are we in a quote + lda $B0 + bne count_this_character + ;; is the character in here a 0? then get the next character + pla + bne next_character +count_this_character: pla + ;; load current char index + ldx $B4 +repeatedly_process: clc + ;; take the Character part... + lda $A7 + ;; load this character from input buffer + ;; this can set the carry bit + ;; so if this overflows, we want to know + adc $0200,y + ;; store it in $a7 + sta $A7 + + ;; load a8 + lda $A8 + ;; we put the # of overflows in here + adc #$00 + sta $A8 + + ;; count down number of times + dex + + ;; if not zero, keep going + bne repeatedly_process + ;; if done, go to the next character + beq process_character + ;; get the continually added char +done_with_line: lda $A7 + ;; xor it with the number of overflows + eor $A8 + ;; push it onto the stack + pha + ;; take 0-15... + and #$0F + ;; and stick it in y + tay + + ;; $03d3 is the end part of the data and defined what + ;; characters there are + lda $03D3,y + ;; print that character to the screen + jsr LFFD2 + + ;; pull from the stack... + pla + ;; shift it four bits to make it 0-15 + lsr a + lsr a + lsr a + lsr a + ;; and stick it in y + tay + + ;; same printing + lda $03D3,y + jsr LFFD2 + + ldx #$1F +reverse_it_again: lda $03E3,x + sta $C7,x + dex + bpl reverse_it_again + + lda #$92 + jsr LFFD2 + + ;; run the original tokenizer + jmp L8956 diff --git a/ap.cfg b/ap.cfg new file mode 100644 index 0000000..c63031c --- /dev/null +++ b/ap.cfg @@ -0,0 +1,9 @@ +MEMORY { + MAIN: file=%O, start=%S, size=65536; +} +SEGMENTS { + CODE: load=MAIN, type=rw; +} +FEATURES {} +SYMBOLS {} + diff --git a/ap_6502.prg b/ap_6502.prg new file mode 100644 index 0000000..9af9d2c Binary files /dev/null and b/ap_6502.prg differ diff --git a/data2.rb b/data2.rb new file mode 100644 index 0000000..580547e --- /dev/null +++ b/data2.rb @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby + +# the original one + +DATA = [ + 169, 75, 141, 36, 3, 169, 3, 141, + 37, 3, 169, 0, 133, 255, 96, 32, + 14, 242, 133, 252, 134, 253, 132, 254, + 8, 201, 13, 240, 17, 201, 32, 240, + 5, 24, 101, 255, 133, 255, 165, 252, + 166, 253, 164, 254, 40, 96, 169, 13, + 32, 210, 255, 165, 214, 141, 165, 3, + 206, 165, 3, 169, 0, 133, 216, 169, + 19, 32, 210, 255, 169, 18, 32, 210, + 255, 169, 58, 32, 210, 255, 166, 255, + 169, 0, 32, 205, 221, 169, 0, 133, + 255, 169, 32, 210, 255, 32, 210, + 255, 173, 165, 3, 133, 214, 76, 98, 3 +] + +File.open('ap_orig_6502.prg', 'w') do |fh| + #fh.print (LOCATION & 0x255).chr + #fh.print ((LOCATION >> 8) & 0x255).chr + + DATA.each do |i| + fh.print i.chr + end +end +