nomainwin WindowWidth = 800 WindowHeight = 500 UpperLeftX = 50 UpperLeftY = 50 b0 =1 ' this will be outputting 0 or 1 on D0, and toggled by the button. b1 =1 ' this will be outputting 0 or 1 on D1, and toggled by you pulling Status S4 pin low. button #w.b1, "Toggle D0", [toggle], UL, 60, 20 base = hexdec( "&H378") 'the usual base address graphicbox #w.g1, 290, 50, 470, 260 graphicbox #w.g2, 10,330, 780, 104 texteditor #w.te, 10, 50, 240, 270 open "Port pin tester" for window as #w loadbmp "mimic", "port.bmp" #w.g1, "down ; drawbmp mimic 0 0" loadbmp "ext", "external.bmp" #w.g2, "down ; drawbmp ext 0 0" #w, "trapclose [quit]" #w.te, "Toggle button should control D0 on the port" #w.te, " and on the graphic mimic." #w.te, "Pulling S4 low with a switch to earth should" #w.te, " do the same for S4" #w.te, "I'll this status bit input every second." #w.g1, "backcolor red ; place 142 160 ; circlefilled 9" [mainloop] timer 200, [refresh]' check every 200/1000 second for inputs, & refresh output state wait goto [mainloop] [refresh] in =inp( base +1) and hexdec( "10") 'Note this looks at the status port whose upper 5 bits are ' the inputs to use. (Mask is binary 0001 0000 for S4) ' and it's address is 1 on from the port base address. ' (effectively mask with 1111 1000 and then with 0001 0000) if in =hexdec("10") then state =state or hexdec( "02")' 0000 0010 so sets D1 high #w.g1, "backcolor black ; place 366 71 ; circlefilled 9" out base, state #w.g1, "backcolor black ; place 142 160 ; circlefilled 9" out base, state #w.te, "Status line S4 pulled high." else state =state and hexdec( "FD") ' 1111 1101 so pulls D1 low #w.g1, "backcolor red ; place 366 71 ; circlefilled 9" out base, state #w.g1, "backcolor red ; place 142 160 ; circlefilled 9" out base, state #w.te, "Status line S4 pulled low." end if goto [mainloop] [quit] timer 0 ' stop the timer unloadbmp "ext" unloadbmp "mimic" close #w end [toggle] #w.te, "Toggle button clicked!" if b0 =0 then b0 =1 state =state or hexdec( "01") out base, state #w.g1, "backcolor red ; place 398 71 ; circlefilled 9" else b0 =0 state =state and hexdec( "FE") out base, state #w.g1, "backcolor black ; place 398 71 ; circlefilled 9" end if goto [mainloop]