• Please review our updated Terms and Rules here

Random Characters Issue on a COMMOODRE PET 2001

Now all we need is a corresponding program for the PC to generate the checksums of the binary images and then a little batch file to enter them into my Excel sheet with all the ROM numbers and descriptions ;-)

I'm not much of a PC programmer, but I think Visual Basic may read binary files. I do not think the old MS Basic interpreter does. For that, the binary files would need to be converted to the BASIC sequential file format. I'll look into it.
 
I'm not much of a PC programmer, but I think Visual Basic may read binary files. I do not think the old MS Basic interpreter does. For that, the binary files would need to be converted to the BASIC sequential file format. I'll look into it.
Nah, Open for input, and ASC(INPUT$(1,1)) will work in most MS BASICs; some don't like a null, so you'd have to test for that first.

Try this:

1 INPUT "ROM";R$:OPEN R$+".bin" FOR INPUT AS 1:FOR I=0 TO 0 STEP 0:S=S+ASC(INPUT$(1,1)):IF NOT EOF(1) THEN NEXT ELSE PRINT S-(INT(S/256)*256):END

Oops: looks like GWBASIC uses CTL-Z for EOF instead of the DOS file length; more R&D required.
 
Last edited:
Had to take a break and watch the Simpsons for inspiration, but here are the checksums:

90143901.BIN 2048 95
90143902.BIN 2048 252
90143903.BIN 2048 146
90143904.BIN 2048 28
90143905.BIN 2048 254
90143906.BIN 2048 73
90143907.BIN 2048 136
90143909.BIN 2048 203
90144701.BIN 2048 95
90144702.BIN 2048 254
90144703.BIN 2048 252
90144704.BIN 2048 73
90144705.BIN 2048 146
90144706.BIN 2048 28
90144707.BIN 2048 136
90144708.BIN 2048 103
90144709.BIN 2048 203
90144710.BIN 2048 103
90144724.BIN 2048 191
90144729.BIN 2048 84
90146501.BIN 4096 56
90146502.BIN 4096 106
90146503.BIN 4096 152
90146519.BIN 4096 94
90146520.BIN 4096 96
90146521.BIN 4096 37
90146522.BIN 4096 25
90146523.BIN 4096 104
90147401.BIN 2048 234
90147402.BIN 2048 114
90147403.BIN 2048 138
90147404.BIN 2048 138
90149801.BIN 2048 82
90149901.BIN 2048 128

Do they match what you get?

Note that the old PET ROMs can have different numbers, depending on whether they're 6540s or 2316s; I only list one of the two since the images are identical. Also note that only the 4K 2332 versions of BASIC 2 are listed; the 6540 versions are 2K, the lower and upper half of the corresponding 2332.
 
Last edited:
Excellent! I'd posted the list below in another thread but it makes sense to post it here to go with the list of checksums.

BASIC 1:
A2 901439-08 6540-010 ROM charGen
H1 901439-01 6540-011 ROM Basic 1 C000-C7FF
H1 901439-09 6540-019 ROM Basic 1r C000-C7FF
H5 901439-05 6540-012 ROM Basic 1 C800-CFFF
H2 901439-02 6540-013 ROM Basic 1 D000-D7FF
H6 901439-06 6540-014 ROM Basic 1 D800-DFFF
H3 901439-03 6540-015 ROM Basic 1 E000-E7FF
H4 901439-04 6540-016 ROM Basic 1 F000-F7FF
H7 901439-07 6540-018 ROM Basic 1 F800-FFFF
A2 901447-08 2316B-08 ROM charGen
H1/H5 901447-01 2316B-01 ROM Basic 1 C000-C7FF
H1/H5 901447-09 2316B-09 ROM Basic 1r C000-C7FF
H1/H5 901447-02 2316B-02 ROM Basic 1 C800-CFFF
H2/H6 901447-03 2316B-03 ROM Basic 1 D000-D7FF
H2/H6 901447-04 2316B-04 ROM Basic 1 D800-DFFF
H3 901447-05 2316B-05 ROM Basic 1 E000-E7FF
H4/H7 901447-06 2316B-06 ROM Basic 1 F000-F7FF
H4/H7 901447-07 2316B-07 ROM Basic 1 F800-FFFF
BASIC 2:
H1 901439-13 6540-020 ROM Basic 2 C000-C7FF
H5 901439-14 6540-021 ROM Basic 2 C800-CFFF
H2 901439-15 6540-022 ROM Basic 2 D000-D7FF
H6 901439-16 6540-023 ROM Basic 2 D800-DFFF
H3 901439-17 6540-024 ROM Basic 2 E000-E7FF
H4 901439-18 6540-025 ROM Basic 2 F000-F7FF
H7 901439-19 6540-026 ROM Basic 2 F800-FFFF
901447-10 2316-004 ROM charGen
901465-01 2332-007 ROM Basic 2 COOO-CFFF
901447-24 2316-011 ROM Basic 2 EOOO-E7FF (PET)
901474-01 2316-024 ROM Basic 2 EOOO-E7FF (CBM)
901465-02 2332-008 ROM Basic 2 DOOO-DFFF
901465-03 2332-009 ROM Basic 2 FOOO-FFFF
BASIC 4.0:
901465-19 2332 ROM Basic 4.0 B000-BFFF
901465-23 2332-120 ROM Basic 4.0r B000-BFFF
901465-20 2332-059 ROM Basic 4.0 C000-CFFF
901465-21 2332-096 ROM Basic 4.0 D000-DFFF
UD8 901447-29 2316-034 ROM Basic 4.0 E000-E7FF (PET)
UD8 901474-02 2316-035 ROM Basic 4.0 E000-E7FF (CBM)
UD7 901474-03 2316-041 ROM Basic 4.0 E000-E7FF (CBM 60Hz)
UD7 901474-04 2316-059 ROM Basic 4.0 E000-E7FF (CBM 50Hz)
901498-01 2316 ROM Basic 4.0 E000-E7FF (PET 50Hz)
901499-01 2316 ROM Basic 4.0 E000-E7FF (PET 60Hz)
970150-07 2516 EPR Basic 4.0 E000-E7FF (PET 9" 60Hz)
901465-22 2332-075 ROM Basic 4.0 F000-FFFF
UB3 901640-01 2332-221 ROM charGen (SuperPET)
 
I ran your program in the VICE emulator and the TI$ clock goes from 000000 to 000139, i.e. 99 seconds. It depends a little on ROM contents, how many IF statements will yield true. This version of the program runs for 50-52 seconds, i.e. twice as fast:

Code:
10 for i=36864 to 36864+4095
20 s=s+peek(i):if s>255 then s=s-256
30 next
40 print"sum check ="s

This is because floating point variables are faster than integer variables (but integers take slightly less space, in particular in arrays). The FOR loop also calculates the range once instead of performing an addition every time. I tried to set variable B=36864 and add inside the loop but it slowed it down a little.

If you want even faster, replace the IF statement with bitwise logic:

20 s=(s+peek(i)) and 255

Now my program executes in 39 seconds, independent of ROM contents.

Tests were conducted on an emulated 8032 or thereabouts, but should yield similar results on actual PETs of most models.
 
Anders,
From 99 Seconds to 39 Seconds is an impressive improvement. Great job!
-Dave
Forget the test, calculate MOD 256 at the end, put it on one line and it should take abt. 20 seconds:

for i=11*4096 to i+4095:s=s+peek(i):next: ? s-int(s/256)*256

(Replace 11 with the ROM block number to check (9 to 15), and if the ROM number is 14 replace the 4095 with 2047).
 
Last edited:
Forget the test, calculate MOD 256 at the end, put it on one line and it should take abt. 20 seconds:

Mike,
Yes, I noticed your technique of calculating modulo 256 at the very end rather than in the loop. At first look, I thought it would never work, but it did. Slick!

You and Anders are naturals at algorithms.

I will benchmark and report on a possible new speed record.
-Dave
 
If you want to get fancy, you can automatically adjust for the 2K E ROM:
1 input r:for i=r*4096 to i+((r=14)+2)*2048-1:s=s+peek(i):next: ? s-int(s/256)*256

(Some of us get obsessed with seeing just how much we can do in one line; you have to remove the spaces to get it to just fit, unless of course you're sane and just split it over several lines ;-) ):

10 input "ROM block number (9-15)";r
20 for i=r*4096 to i+((r=14)+2)*2048-1
30 s=s+peek(i):next: print s-int(s/256)*256
 
Last edited:
I will benchmark and report on a possible new speed record.
-Dave

I put this into 4 lines (as I like legible code):

for i=11*4096 to i+4095:s=s+peek(i):next: ? s-int(s/256)*256

and the time was 22 Seconds. Congratulations.

How many characters can one put in a single line of BASIC? Is it 255? I know you guys like to do this as a lark, but I find it hard to decipher, which I'm sure is what you are after!
 
How many characters can one put in a single line of BASIC? Is it 255? I know you guys like to do this as a lark, but I find it hard to decipher, which I'm sure is what you are after!
Heh, heh... ;-) You mean like this: "for i=r*4096 to i+((r=14)+2)*2048-1"

I'm not sure; I think it can be 255 characters or one or two characters less, but I don't think you can edit lines longer than 80 characters. Mind you, other than this little piece of silliness I haven't programmed on a PET in, oh, 30 years or so...
 
This is because floating point variables are faster than integer variables

I didn't know the PET had a math coprocessor...:)

if you want even faster, replace the IF statement with bitwise logic:

20 s=(s+peek(i)) and 255
Anders,
Really clever way to do it, but somewhere the variable 's' had to be converted to an integer to be able to get logical AND'ed with an eight bit number.

You guys are super good at this. But from a hardware guy's simplistic point of view:Curse all great coders! :)
-Dave
 
Mind you, other than this little piece of silliness I haven't programmed on a PET in, oh, 30 years or so...

Well for your information, the PET is still my main programming machine. More powerful machines and operating systems just get me confused! :)

Pet BASIC and 6502 assembly language - what more could one want in life? ;)
 
Back
Top