Jump to content
  • entries
    46
  • comments
    9
  • views
    48,147

Can I ………?


k-Pack

967 views

blog-0911750001432337026.jpgANSWER: Yes, you can use an Atari mouse plugged into port 1 while using the digital pins on port 0 as outputs while operating in the Diamond GOS environment.

 

The answer was needed because I’ve been thinking about writing the control software for some hardware projects to work under the Diamond GOS. As a test, this short program was written to randomly set the outputs to control the LEDs in the Joystick Port Logic Box (JPLB). (See “Out of the Pack” Blog 4/20/2015)

 

This BASIC program sets up Diamond so that the mouse can be moved around. When the mouse is clicked a random number between 0 and 15 is used to set the pin’s logic state as indicated by the JPLB connected to port 0. When a key on the keyboard is pressed the program exits Diamond and returns you to the READY prompt.

 

blogentry-37655-0-04458700-1432336466_thumb.jpg

 

 

5 REM DIAMOND - PORTTEST.BAS 5/19/2015

10 REM TEST PROGRAM TO SEE IF DIAMOND MOUSE STILL WORKS ON PORT 1 WHEN PORT 0 IS USED FOR OUTPUT

20 REM

100 REM SETUP JOYSTICK PORT#1 (PORT0) FOR OUTPUT

110 POKE 54018,48

120 POKE 54016,15

130 POKE 54018,52

140 POKE 54016,0

149 REM LOAD PAGE 6 DIAMOND LINK

150 CLOSE #1:OPEN #1,4,0,"D:DIABASIC.OBJ":TRAP 180

155 GET #1,A:GET #1,B:GET #1,C:GET #1,D

160 IF A<>255 OR B<>255 THEN 170

165 A=C:B=D:GET #1,C:GET #1,D

170 FOR X=A+B*256 TO C+D*256:GET #1,Y:POKE X,Y:NEXT X

175 GOTO 155

180 W0=1539:W1=1541:W2=1543:W3=1545

182 W4=1547:W5=1549:W6=1551:W7=1553

184 B0=1555:B1=1556:B2=1557:B3=1558

186 B4=1559:B5=1560:B6=1561:B7=1562

188 EVENTTYPE=39571:DIAMOND=1536

200 REM INITILIZE DIAMOND

210 POKE B0,0:X=USR(DIAMOND,0)

300 REM GET EVENT TYPE

310 X=USR(DIAMOND,23)

320 IF PEEK(EVENTTYPE)=0 THEN 310:REM NO EVENT

330 IF PEEK(EVENTTYPE)=5 THEN 400:REM BACKGROUND

340 IF PEEK(EVENTTYPE)=4 THEN 500:REM KEYPRESS

350 GOTO 310

400 REM BACKGROUND EVENT - SEND OUTPUT TO PIN

410 FOR X=1 TO 10:SOUND 0,100,14,8:NEXT X

415 POKE 54016,INT(RND(0)*16)

420 SOUND 0,0,0,0:GOTO 310

500 REM EVENT KEYBOARD - QUIT

510 X=USR(DIAMOND,1)

600 STOP

 

 

 

Line 100-140 Sets the port 0 for output and leaves port1 for mouse input. Diamond does not reset the port settings when initialized. It was also noted that JPLB showed that the logic outputs did not change when the BASIC program was stopped or when going back to the Diamond Desktop. Joystick port operations should be reset before the program ends. The ports will also reset for input if the RESET key is pressed, although you will more than likely have to reboot to use Diamond again.

 

Line 150-188 This part of the program loads in the machine language program that links the Diamond cartridge routines to BASIC. This is a shortened version of the original code, the line numbers were changed and the Diamond routine number definitions were removed. You’ll need a copy of DIABASIC.OBJ on the specified drive.

 

Line 210 Initializes the Diamond in High Rez mode. It’s a blank screen with a mouse pointer to move around.

 

Line 300-350 Checks for an EVENT. No event keep checking. A click of the mouse will change logic levels of port 0. Pressing a key on the keyboard will exit the program.

 

Line 400-420 Makes a sound to let you know the number changed. A new random number (sometimes the same number) is picked and sent to port 0 for output. Then the sound is turned off. Then back to check for next event.

 

Line 500-600 Exits the Diamond environment and STOPs the program. It is a good idea to use the quit function to exit Diamond. It can clean up memory and turn off the player graphics used for the mouse.

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...