In this "issue":
Ok, those long time readers of this drivel may well remember my lack of love for Open Transport - well the good news is that it finally seems to have settled down (but it still eats memory!). My only remaining gripe is why do I have to load a different configuration file in tcp/ip when I want to use Ethernet rather than PPP? Why can't we have a simple "configuration" toggle switch in tcp/ip, rather than having to load a new config in from the file menu. My main Mac is connected to three networks - an Ethernet link to the server, PPP to the Internet and the old AppleTalk network to Elsie. It is sometimes very confusing knowing what's going on. That's the problem with the Mac, sometimes I expect it to "know" I want to connect to a server in the States, and not the PC across the room - of course, the poor machine is not psychic, but maybe one day....
Interlude
And finally, a little bit of coding we've been doing you may find
interesting. We've just added support in Eddie for extended keyboards,
and while we were there, thought it a good idea to use the "scroll
lock" LED (Light Emitting Diode) to show when Eddie is running
a background task. We realised that we could flash this LED to
show anything we wanted. Well, by writing two routines - one to
light the LED and the other to extinguish it, we could see when
a routine was running - handy. And of course, the relative brightness
of the LED indicates how busy the routine is - you may find it
useful (unless of course you don't have an extended keyboard...).
Below are the routines - LED_ON and LED_OFF. They call a few smaller routines - read_leds and set_leds, so as to ensure that the current contents of keyboard register #2 are not destroyed. The only weird thing about the following code is that parameter passing to system routines are in registers, and the completion routine ("my_comp") for the send_data routine passes our data buffer in a2! (we set a flag in the data buffer to indicate to the main routine that the data has been sent to the keyboard).The code looks more complicated than it really is - it took longer to format and extra comment it for this piece, than it did to write!
Note, that both routines check for an extended keyboard - this is just time wasting - you could get the kbd address on boot up and pass that to led_on and led_off.
See
Inside Macintosh Devices chp 5and tech note
HW01 - ADB The Untold Story : Space Aliens Ate My Mousefor more details.
****Led_on lights the scroll lock led. led_on: save_all *as this is an example, I'd better save all the regs.. bsr find_extended *get first extended kbd, if there is one *d0=0=no extended tst.w d0 beq.s cant_lo *There is no extended keyboard, so don't do it. **address of first extended kbd in d0 abd param_block set up **set all leds move.w d0,d7 *save address for read_leds/set_leds bsr.s read_leds *into d0 lea adb_data_buffer(pc),a0 move.w 1(a0),d5 bclr #2,d5 *scroll lock led on - 0=on, 1=off bsr set_leds cant_lo: restore_All *and now put em back the way they were... rts_ "led_on" ****led_off extinguishes the scroll lock LED. led_off: save_all bsr find_extended *get first extended kbd, if there is one *d0=0=no extended tst.w d0 *dont assume flags is set, check! beq.s cant_lo **address of first extended kbd in d0 abd param_block set up **set all leds move.w d0,d7 *save address bsr.s read_leds *into d0 lea adb_data_buffer(pc),a0 move.w 1(a0),d6 *save current value in case we need it later... move.w d6,d5 *current value for modification bset #2,d5 *scroll lock led off bsr.s set_leds restore_all rts_ "led_on" **************************************************************** *******************Subroutines follow*************************** **************************************************************** **Needs adb address in d7,returns led register contents in adb_data_buffer (1...2) **0 is byte count which will be 2 in this case read_leds: **make adb instruction in d0 as per IMDevices move.w d7,d0 lsl.b #4,d0 *move address bset #3,d0 bset #2,d0 *talk bset #1,d0 *reg 2 lea adb_pb(pc),a0 *param block for adbop lea adb_data_buffer(pc),a1 *the data buffer - in this case its a receive buffer. clr.b (a1) *So we know when we've read move.l a1,(a0) *pointer to data buffer clr.l 4(a0) *no completion routine as we can monitor the rx buffer clr.l 8(a0) *no completion data dc.w _adbop tst.b d0 bmi.s read_leds *adb command queue full, so try again **Wait for data to come from adb processor (it's a 2 MHz Motorola 68HC11) lea adb_data_buffer(pc),a1 wait_for_it: tst.b (a1) beq.s wait_for_it *Guess whats going on here then... rts_ "Read_leds" **** **needs 16 bit reg data in d5,address in d7 set_leds: **make op move.w d7,d0 lsl.b #4,d0 *move address bset #3,d0 bclr #2,d0 *listen bset #1,d0 * to reg 2 lea adb_pb(pc),a0 *param block for adbop lea adb_data_buffer(pc),a1 move.w d5,1(a1) *the data for said reg move.b #2,(a1) *the size of the data - 16 bits move.l a1,(a0) *pointer to data buffer lea my_comp(pc),a1 move.l a1,4(a0) *no completion routine lea my_comp_data(pc),a1 clr.b (a1) *clear completion routine flag move.l a1,8(a0) *no optional data dc.w _adbop tst.b d0 bmi.s set_leds *command queue full lea my_comp_data(pc),a1 *completion routine sets this =1 wait_for_it_send: tst.b (a1) beq.s wait_for_it_send *wait for completion proc to run rts_ "Set_leds" ****Find address of extended keyboard if there is one ****Return d0=address of kbd or zero if no kbd. find_extended: moveq #1,d7 *device index 1-16 fe_loop: lea adb_data_block(pc),a0 move.w d7,d0 *index dc.w _getindadb *returns in d1! lea adb_data_block(pc),a0 cmpi.w #0x0202,(a0) *is extended kbd? (handler ID and default address are both 2) beq.s got_extended addq.w #1,d7 *No, so next device cmpi.w #17,d7 bne.s fe_loop *done all possible devices? clr.l d0 *yes, clr d0=no extended rts_ "Find_extended" got_extended: rts **Completion routine for set_led my_comp: move.b #1,(a2) *set my_comp_data so we can see it's finished rts_ "My_comp" ************************************************************* ********************Data follows***************************** ************************************************************* my_comp_data: ds.w 1 *flag set by completion routine for send adb_data_block: ds.b 1 *devtype ds.b 1 *original adb address ds.l 1 *handler ds.l 1 *data area adb_data_buffer: ds.b 12 *1st byte is count byte a la pascalish align adb_pb: ds.l 3 *PB for adbOP global led_on,led_off
Code on!
Stu.