bgri / m100LE

A Wordle-like game for the vintage Tandy (Radio Shack) Model 100
11 stars 1 forks source link

Kyocera Kyotronic-85 support #40

Closed hackerb9 closed 2 years ago

hackerb9 commented 2 years ago

I was looking into what was needed for the Kyotronic-85 to work. The main thing needed is the start address of the Ram Directory. PEEK(1) on a K-85 is 225, which is how we're IDing the machines in line 2016.

I compared the tokenized BASIC for the K-85 and it seems to be equivalent to what runs on the Model 100/102/200. That makes life easier because we may have one less file format to deal with.

bgri commented 2 years ago

Neat... Having it run on a K-85 would be really cool. Now if only we had a hardware version to verify on. Not in my collection (sadly).

Oh, not sure if this helps or not - K-85 Service Manual - Memory detail at 3-41

hackerb9 commented 2 years ago

I think I have Kyotronic-85 support working and will issue a pull request after a bit more testing. These are just notes for anyone who follows in my footsteps:

PEEK(1) == 225

It does appear that all the Kyotronic-85 sisters actually can be identified reasonably uniquely by looking at PEEK(1), which is an old technique (from the 1980s) that was used for differentiating between the Model 100 and similar machines.

Model PEEK(1) RAM Directory Address SAVEM bug? KB Count Address
Kyocera Kyotronic-85 225 63849 Yes 65387
TRS-80 Model 100 51 63842 No 65450
Tandy 102 167 63842 No 65450
Tandy 102 (UK) 167 63842 No 65450
Tandy 200 171 62034 No 64799
NEC PC-8201 148 63567 Yes 65128
NEC PC-8201A 148 63567 Yes 65128
NEC PC-8300 148 63567 Yes 65128
Olivetti M10 (Italy) 35 63849 Yes 65389
Olivetti M10 (US) 125 ? ? ?

For all machines, the Keyboard Buffer starts one byte after the Keyboard Buffer Count. The buffer holds 32 entries on all machines. Except on the M10, each entry takes two bytes. Only the second byte seems to be significant for ordinary keystrokes. On the M10, each entry takes a single byte.

SAVEM Bug and adding keystrokes to the keyboard buffer

All of the Kyotronic sisters , except the ones from Tandy Radio-Shack, have what I was calling the "BSAVE BUG". Of course, for non-NEC machines, it is actually a bug in SAVEM. It affects only CMPRSS.DO, which uses SAVEM to allocate memory in the RAM Directory for the compressed wordlists. The bug is that the program halts after a line which contains SAVEM. A solution is to put that line in a subroutine and then, from "Direct Mode", the user can type "RETURN" to continue the program. I have created a routine which will programmatically add any string to the keyboard buffer so that, as soon as the program stops, the machine will think the user has typed RETURNENTER. It works on any platform.

Subroutine to insert R$ in the keyboard buffer ```BASIC 8800 REM INSERT R$ INTO KEYBOARD BUFFER 8801 ' INPUT: R$, a string of <=32 char 8802 ' OUTPUT: None. Types R$ on kbd. 8805 ' TEMP: ID: Machine platform 8806 ' KC: Key count address 8807 ' KB: Keyboard buffer addrss 8808 ' I, SK: Loop iterator, skip 8809 ' 8810 ID=PEEK(1) 8820 KC=-( 65128*(ID=148) + 65389*(ID=35 OR ID=125) + 65387*(ID=225) + 64799*(ID=171) + 65450*(ID=51 OR ID=167) ) 8830 IF KC=0 THEN PRINT "Error: Keyboard buffer address not known for machine ID";ID;". Please file a bug report.": END 8840 KB=KC+1 8850 IF (LEN(R$) > 32) THEN PRINT "Error: String too long to fit in keyboard buffer: ";R$: END 8860 IF (LEN(R$) = 0) THEN RETURN 8870 SK=2 'Read every other byte 8879 ' Olivetti reads every byte 8880 IF (ID=35 OR ID=125) THEN SK=1 8889 ' "Type" into keyboard buffer. 8890 FOR I=0 TO LEN(R$)-1 8900 POKE KB+I*SK, ASC(MID$(R$,I+1,1)) 8910 NEXT I 8919 ' Number of keys "typed". 8920 POKE KC, LEN(R$) 8930 RETURN ```

Kyotronic-85's RAM Directory address is 63849

bgri commented 2 years ago

So, it's like the dev. team just forgot that someone could be using BSAVE/SAVEM in code vs through direct entry? Curious that it survived existing on both platforms. I'd assume that code review would have caught it on the conversion. Maybe it is expected behaviour for the time...

Nice workaround to solve it :)