fred@cbmvax.cbm.UUCP (Fred Bowen) (04/30/87)
I thought it might be fun to drop some programming hints, from time to time, on the C64/128 community. Surely there are a few crusty 8-bit hackers still out there who will appreciate them... One problem with a great many programs I've seen and used stems from the difficulty of finding out if a serial bus device exists. Until the 128's TRAP statement came along, most programs either hung or crashed with a DEVICE NOT PRESENT error. I hate when that happens! And it's fairly easy to test for that situation and handle it in a dignified manner. Try this: C64's: 10 POKE 144,0 :REM CLEAR ST 20 POKE 780,unit :REM LDA unit 30 SYS 65457 :REM JSR LISTEN 40 POKE 780,1 :REM LDA SA 50 SYS 65427 :REM JSR SECOND 60 IF ST<0 THEN PRINT"DEVICE NOT PRESENT!" This can be collapsed into a one liner, of course, as in the 128 version: 10 POKEDEC("90"),0:SYSDEC("FFB1"),unit:SYSDEC("FF93"),1:IF ST<0 THEN... But I find the following the best case- it works on either machine: 10 T=ABS(PEEK(65533)=255) :REM T=0 IF C64, T=1 IF C128 20 A=780:IF T THEN A=6 30 POKE 144,0: POKE A,unit: SYS65457: POKE A,1: SYS 65427 40 IF ST<0 THEN do whatever you wanna do if unit ain't there This works for disk drives, printers, and such. And it's easily converted to machine code. Just remember to do all this in BANK 15 (IO, ROMs) on the 128. -- -- -- Fred Bowen uucp: {ihnp4|seismo|caip}!cbmvax!fred arpa: cbmvax!fred@seismo.css.GOV tele: 215 431-9100 Commodore Electronics, Ltd., 1200 Wilson Drive, West Chester, PA, 19380