The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Sunday, January 22, 2012

99 ways to program a hex, Part 14: COLOR COMPUTER BASIC

Yesterday's code was labeled “COLOR COMPUTER BASIC, EASY” not because it was easy to write (it was somewhat easy—seeing how I didn't have to run it, and going off referenece material for a language I haven't used in over twenty years) but because it was relatively “easy” to read.

I'm being serious.

I never saw any published BASIC code look that nice. No, it would usually be presented as this (but probably without the blank lines):

1 '*****************************
2 '* COPYRIGHT 2012 SEAN CONNER
3 '* 
4 '* THIS PROGRAM RELEASED UNDER
5 '* THE GNU LICENSE, VERSION 2
6 '* OF THE LICENSE, OR (AT YOUR
7 '* OPTION) ANY LATER VERSION.
8 '*
9 '* SEE THE GNU GENERAL PUBLIC
10 '* LICENCE FOR MORE DETAILS.
11 '***************************
12 '
13 'COLOR COMPUTER BASIC
14 'REQUIRES EXTENDED AND
15 'DOS BASIC TO RUN.
16'
20 PRINT "INPUT FILE NAME:";:INP
UT FN$:OPEN"I",#1,FN$:I=0:Y=0:FO
R S=1TOLOC(2):GET#1,S:D$=INPUT#1
:FOR B=1TO256STEP8:DD$=MID$(D$,B
,16):I$=HEX$(I):IF LEN(I$)<>4 TH
EN I$ = MID$("000",1,4-LEN(I$))+
I$
21 H$="":A$="":FOR C=1TO8:B$=MID
$(H$,C,1):IF CHR$(B$)<32 OR CHR$
(B$)>1THEN B$="."
22 A$=A$+B$:T$=HEX$(B$):IF LEN(T
$)=1THENT$="0"+T$
23 H$=H$+T$:NEXT C:PRINTI$;": ";
H$;" ";A$:I=I+8:Y=Y+1:IF Y=15 TH
EN INPUT T$:Y=1
24 NEXT B:NEXT S:CLOSE#1:END

Line 20 here covers lines 20 through 103 of yesterday's code, and I only broke it there because of the IF statement, which ends at the end of a number statement. Otherwise, it could have been longer, up to 255 characters in length. All due to memory constraints—4,096 bytes, 16,384 bytes or 32,768 bytes of RAM to fit both the program and data (and if you want high resolution graphics, you give up 6,144 bytes; 12,288 bytes if you want double-buffered high resolution graphics—and by “high resolution graphics” I mean 256×192 pixels, two colors).

Yes kids, this is how we used to write programs. And part of the reason why BASIC has the terrible reputation that it does.

Obligatory Picture

Trying to get into the festive mood this year

Obligatory Contact Info

Obligatory Feeds

Obligatory Links

Obligatory Miscellaneous

Obligatory AI Disclaimer

No AI was used in the making of this site, unless otherwise noted.

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: https://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

https://boston.conman.org/2000/08/01

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2024 by Sean Conner. All Rights Reserved.