Example program for the Cidco MailStation Z80 computer
1#!/usr/bin/env ruby
2#
3# generate cursorx lookup table using 5 bits for col group and 3 for offset
4# Copyright (c) 2019 joshua stein <jcs@jcs.org>
5#
6# Permission to use, copy, modify, and distribute this software for any
7# purpose with or without fee is hereby granted, provided that the above
8# copyright notice and this permission notice appear in all copies.
9#
10# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17#
18
19# pixels: 01234567012345670123456801234567012345670123456701234567012345670
20# col group: | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 |
21# font cell: .....11111.....11111.....11111.....11111.....11111.....11111.....
22
23File.open("#{__dir__}/../cursorx_lookup.inc", "w+") do |f|
24 f.puts "; AUTOMATICALLY GENERATED FILE - see tools/generate_cursorx_lookup.rb"
25
26 pcol = 0
27 64.times do |x|
28 col_group = 20 - (pcol / 8) - 1
29 off = pcol % 8
30
31 v = sprintf("%05b%03b", col_group, off).to_i(2)
32
33 f.puts "\t.db #0x#{sprintf("%02x", v)}\t\t\t; #{sprintf("%08b", v)} - col group #{col_group}, offset #{off}"
34
35 pcol += 5
36
37 if pcol == 160
38 pcol = 0
39 end
40 end
41end