First commit - Create punch-card encoding script
This commit is contained in:
commit
667897b31a
|
|
@ -0,0 +1,2 @@
|
||||||
|
.vscode
|
||||||
|
.DS_Store
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
0000001100000010000000011111101000000011000000100000000111111011000000110010101100000001111111100000101100110001000000111111111100000010111111010000000000000000000001001111101000000001111111010000010011111011000011100000000100001011001111010000110011111110000001001111110100000101000001010000000111111101000001001111101100000111000000010000000111111011000011100000000100001011001111010000110011111110
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
01234567 01234567 01234567 01234567 01234567 01234567 01
|
||||||
|
▮▯▮▯▮▯▮▮ ▮▮▮▯▮▮▮▮ ▯▮▯▯▯▯▮▮ ▯▮▯▮▮▮▯▯ ▯▮▮▮▮▮▯▮ ▮▮▮▮▯▮▮▮ ▯▯
|
||||||
|
▮▮▯▮▮▮▯▮ ▮▮▯▮▮▯▮▮ ▮▯▯▯▯▮▯▯ ▯▮▮▯▮▯▯▮ ▯▯▯▯▯▯▯▮ ▮▯▯▮▮▯▮▯ ▯▮
|
||||||
|
▯▯▯▯▯▯▯▯ ▯▯▯▮▯▯▯▮ ▯▮▯▯▮▯▯▮ ▮▯▮▯▯▮▮▮ ▮▮▮▮▯▮▮▯ ▮▯▯▯▮▯▯▮ ▮▮
|
||||||
|
▯▯▯▮▯▯▯▮ ▯▮▯▮▮▯▯▮ ▯▮▯▯▯▮▯▮ ▯▮▮▯▮▮▮▮ ▯▮▯▯▯▮▯▮ ▯▯▯▮▮▯▮▮ ▮▮
|
||||||
|
▯▯▯▮▯▯▯▮ ▯▯▯▮▯▮▯▮ ▯▮▯▯▯▮▯▮ ▯▮▯▯▯▮▯▮ ▯▮▯▯▯▮▯▮ ▯▯▯▮▯▯▯▮ ▯▮
|
||||||
|
▯▯▯▮▯▯▯▮ ▯▮▯▮▯▮▯▮ ▯▮▯▯▯▮▯▮ ▯▮▯▯▯▮▯▮ ▯▮▯▯▯▮▯▮ ▯▯▯▮▯▯▯▮ ▯▮
|
||||||
|
▯▯▯▮▯▯▯▮ ▯▯▯▮▯▯▯▮ ▯▮▯▯▯▮▯▮ ▯▮▯▯▯▯▯▮ ▯▮▯▯▯▮▯▮ ▯▯▯▮▯▯▯▯ ▯▮
|
||||||
|
▯▯▯▮▯▯▯▮ ▯▯▯▮▯▯▯▮ ▯▮▯▯▯▮▯▮ ▯▮▯▯▯▯▯▮ ▯▮▯▯▯▮▯▮ ▯▯▯▮▯▯▯▯ ▯▮
|
||||||
|
01234567 01234567 01234567 01234567 01234567 01234567 01
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
; Routine for drawing at (x, y) coordinates
|
||||||
|
|
||||||
|
#zeroflag 1
|
||||||
|
|
||||||
|
; *** Set your desired (x, y) here: ***
|
||||||
|
#input_x 2
|
||||||
|
#input_y 2
|
||||||
|
|
||||||
|
; Set up some handy shortcuts
|
||||||
|
#x $FA
|
||||||
|
#y $FB
|
||||||
|
#return_addr_ptr $FE
|
||||||
|
|
||||||
|
|
||||||
|
; Main:
|
||||||
|
|
||||||
|
LDA #input_x
|
||||||
|
STO #x
|
||||||
|
LDA #input_y
|
||||||
|
STO #y
|
||||||
|
LDA * 6 ; acc = current address + 6 (LDA, STO, JMP = 6)
|
||||||
|
STO #return_addr_ptr
|
||||||
|
JMP @getxy
|
||||||
|
|
||||||
|
LDA $FF
|
||||||
|
STO ($FD)
|
||||||
|
END
|
||||||
|
|
||||||
|
;; Convert a pair of (x, y) coords
|
||||||
|
;; to the address of a pixel on the display
|
||||||
|
;;
|
||||||
|
;; Call with:
|
||||||
|
;; - x in #x
|
||||||
|
;; - y in #y
|
||||||
|
;; - return address in #return_addr_ptr
|
||||||
|
;;
|
||||||
|
;; Returns: pixel address in $FD
|
||||||
|
@getxy
|
||||||
|
#gxy_px $FD
|
||||||
|
|
||||||
|
; stash x...
|
||||||
|
LDA (#x)
|
||||||
|
STO #gxy_px
|
||||||
|
|
||||||
|
; check if this is row 0...
|
||||||
|
LDA (#y)
|
||||||
|
FHP #zeroflag
|
||||||
|
JMP @getxy_loop
|
||||||
|
JMP (#return_addr_ptr) ; if row 0, we're done
|
||||||
|
|
||||||
|
@getxy_loop
|
||||||
|
LDA (#gxy_px)
|
||||||
|
ADD 5 ; add 5 to get to the next row
|
||||||
|
STO #gxy_px
|
||||||
|
LDA (#y) ; decrement y (it's acting as a loop counter)...
|
||||||
|
SUB 1
|
||||||
|
STO #y
|
||||||
|
FHP #zeroflag
|
||||||
|
JMP @getxy_loop
|
||||||
|
JMP (#return_addr_ptr)
|
||||||
|
|
||||||
|
;; Main variables:
|
||||||
|
;; F8
|
||||||
|
;; F9
|
||||||
|
;; FA - x coord
|
||||||
|
;; FB - y coord
|
||||||
|
;; FC - gxy temp
|
||||||
|
;; FD - gxy temp
|
||||||
|
;; FE - Return address for subroutine
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
// Input file must contain a binary string with no spaces, linebreaks, etc.
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const filename = process.argv[2];
|
||||||
|
const inputFile_str = fs.readFileSync(filename, 'utf8');
|
||||||
|
|
||||||
|
const create_square_wave_string = (s) => {
|
||||||
|
s = s.replace(/1/g, '▮');
|
||||||
|
return s = s.replace(/0/g, '▯');
|
||||||
|
}
|
||||||
|
|
||||||
|
const number_hex_string = (quantity) => {
|
||||||
|
let output = '';
|
||||||
|
let current_digit = 0;
|
||||||
|
for (let i = 0; i < quantity; i++) {
|
||||||
|
current_digit = i % 8;
|
||||||
|
output = output + current_digit;
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
const binary_string_to_bus_strings = (input) => {
|
||||||
|
let output = ['','','','','','','',''];
|
||||||
|
let input_bytes = input.match(/.{1,8}/g);
|
||||||
|
|
||||||
|
input_bytes.forEach( (byte) => {
|
||||||
|
let byte_array = byte.split('');
|
||||||
|
for (let i = 0; i < 8; i++) {
|
||||||
|
output[i] = output[i] + byte_array[i];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Print output
|
||||||
|
let nums = number_hex_string(output[0].length);
|
||||||
|
let spaced_nums = nums.match(/.{1,8}/g).join(' ');
|
||||||
|
console.log();
|
||||||
|
console.log(spaced_nums);
|
||||||
|
|
||||||
|
output.reverse().forEach( (s) => {
|
||||||
|
let spaced = s.match(/.{1,8}/g).join(' ');
|
||||||
|
console.log(create_square_wave_string(spaced));
|
||||||
|
});
|
||||||
|
console.log(spaced_nums);
|
||||||
|
console.log();
|
||||||
|
}
|
||||||
|
|
||||||
|
binary_string_to_bus_strings(inputFile_str);
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
# Create punch card patterns from binary strings
|
||||||
|
|
||||||
|
This script turns a binary string into a pattern formatted for copying to an IBM-style 80-column punch card.
|
||||||
|
|
||||||
|
It is intended for creating drawings patterns based on programs for my imaginary computer.
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
```
|
||||||
|
./punch-a-card.js bin.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
The input must be a text file containing nothing but 0s and 1s (no spaces, newlines, etc). It must be an even number of 8-bit bytes in length.
|
||||||
|
|
||||||
|
## Example output
|
||||||
|
|
||||||
|
```
|
||||||
|
01234567 01234567 01234567 01234567 01234567 01234567 01
|
||||||
|
▮▯▮▯▮▯▮▮ ▮▮▮▯▮▮▮▮ ▯▮▯▯▯▯▮▮ ▯▮▯▮▮▮▯▯ ▯▮▮▮▮▮▯▮ ▮▮▮▮▯▮▮▮ ▯▯
|
||||||
|
▮▮▯▮▮▮▯▮ ▮▮▯▮▮▯▮▮ ▮▯▯▯▯▮▯▯ ▯▮▮▯▮▯▯▮ ▯▯▯▯▯▯▯▮ ▮▯▯▮▮▯▮▯ ▯▮
|
||||||
|
▯▯▯▯▯▯▯▯ ▯▯▯▮▯▯▯▮ ▯▮▯▯▮▯▯▮ ▮▯▮▯▯▮▮▮ ▮▮▮▮▯▮▮▯ ▮▯▯▯▮▯▯▮ ▮▮
|
||||||
|
▯▯▯▮▯▯▯▮ ▯▮▯▮▮▯▯▮ ▯▮▯▯▯▮▯▮ ▯▮▮▯▮▮▮▮ ▯▮▯▯▯▮▯▮ ▯▯▯▮▮▯▮▮ ▮▮
|
||||||
|
▯▯▯▮▯▯▯▮ ▯▯▯▮▯▮▯▮ ▯▮▯▯▯▮▯▮ ▯▮▯▯▯▮▯▮ ▯▮▯▯▯▮▯▮ ▯▯▯▮▯▯▯▮ ▯▮
|
||||||
|
▯▯▯▮▯▯▯▮ ▯▮▯▮▯▮▯▮ ▯▮▯▯▯▮▯▮ ▯▮▯▯▯▮▯▮ ▯▮▯▯▯▮▯▮ ▯▯▯▮▯▯▯▮ ▯▮
|
||||||
|
▯▯▯▮▯▯▯▮ ▯▯▯▮▯▯▯▮ ▯▮▯▯▯▮▯▮ ▯▮▯▯▯▯▯▮ ▯▮▯▯▯▮▯▮ ▯▯▯▮▯▯▯▯ ▯▮
|
||||||
|
▯▯▯▮▯▯▯▮ ▯▯▯▮▯▯▯▮ ▯▮▯▯▯▮▯▮ ▯▮▯▯▯▯▯▮ ▯▮▯▯▯▮▯▮ ▯▯▯▮▯▯▯▯ ▯▮
|
||||||
|
01234567 01234567 01234567 01234567 01234567 01234567 01
|
||||||
|
```
|
||||||
Loading…
Reference in New Issue