Here are some tips to programming shown devices in BASIC 7.0
Joystick
Most used input device for gaming on the Commodore 128.
Known are more and more models.
If I can say my own opinion, Competition Pro is the best joystick which is currently possible to buy new from Individual Computers.
Here's simple BASIC program to read joystick positions and fire:
0 REM **** JOYSTICK IN PORT 2 ****
10 SPRITE1,1,2:X=100:Y=100
20 MOVSPR1,X,Y
30 A=JOY(2)
40 IFA=1THENY=Y-1
50 IFA=5THENY=Y+1
60 IFA=7THENX=X-1
70 IFA=3THENX=X+1
80 IFA=8THENX=X-1:Y=Y-1
90 IFA=2THENX=X+1:Y=Y-1
100 IFA=6THENX=X-1:Y=Y+1
110 IFA=4THENX=X+1:Y=Y+1
120 GOTO20
Possible is also with PEEK command:
Port 1 = 56321 / Port 2 = 56320
values: L = left / R = right / U = up / D = down
L - 251 / 123
R - 247 / 119
U - 254 / 126
D - 253 / 125
UL - 250 / 122
UR - 246 / 118
DL - 249 / 121
DR - 245 / 117
FIRE - 239 / 111
N/A - 255 / 127
with FIRE:
L - 235 / 107
R - 231 / 103
U - 238 / 110
D - 237 / 109
UL - 234 / 106
UR - 230 / 102
DL - 233 / 105
DR - 229 / 101
Mouse
Mouse is advanced device used by system applications, of course, it can be used also for gaming or other.
Most used mouse is mouse Commodore 1351, successor of joystick-type mouse Commodore 1350.
Also made are other mouses which can be used with Commodore 128, e.g.:
Commodore 1352 (designed for Commodore Amiga computers - not fully compatible)
Computek GEOS-101
DATALUX SV-705
M1 Maus
NEOS Cheese
Scanntronik with wheel
TQ Mouse
CMD SmartMouse
... or other
Mouse is best solution for GEOS operating system.
Here's driver in BASIC, it uses IRQ so you can edit text or to do other things and mouse will be ready:
0 REM **** MOUSE 128 DRIVER ****
100 gosub 230:gosub 420:sys 6144
120 ba=dec("0a04"):poke ba,1 or peek(ba)
130 sprite 1,1,2:movspr 1,100,100
170 end
180 x=rspos(1,0)-25:y=rspos(1,1)-51:x=-x*(x>0):y=-y*(y>0)
190 locate x,y:c=1-rdot(2):draw c,x,y
200 do:x=rspos(1,0)-25:y=rspos(1,1)-51:x=-x*(x>0):y=-y*(y>0)
210 draw c to x,y:loop while joy(1) and 128:return
220 rem ------------------------
230 for x=0 to 135:read a$:poke 6144+x,dec(a$):next x:return
240 data ad,15,03,c9,18,f0,19,08
250 data 78,ad,14,03,8d,f0,18,ad
260 data 15,03,8d,f1,18,a9,21,8d
270 data 14,03,a9,18,8d,15,03,28
280 data 60,d8,ad,7e,11,d0,33,ad
290 data 19,d4,ac,f2,18,20,5d,18
300 data 8c,f2,18,18,6d,d6,11,8d
310 data d6,11,8a,69,00,29,01,4d
320 data e6,11,8d,e6,11,ad,1a,d4
330 data ac,f3,18,20,5d,18,8c,f3
340 data 18,38,49,ff,6d,d7,11,8d
350 data d7,11,6c,f0,18,8c,f5,18
360 data 8d,f4,18,a2,00,38,ed,f5
370 data 18,29,7f,c9,40,b0,07,4a
380 data f0,12,ac,f4,18,60,09,c0
390 data c9,ff,f0,08,38,6a,a2,ff
400 data ac,f4,18,60,a9,00,60,00
410 rem ------------------------
420 for x=0 to 63:reada$:poke dec("0e00")+x,dec(a$):next x:return
430 data f8,00,00,90,00,00,b8,00
440 data 00,dc,00,00,8e,00,00,07
450 data 00,00,02,00,00,00,00,00
460 data 00,00,00,00,00,00,00,00
470 data 00,00,00,00,00,00,00,00
480 data 00,00,00,00,00,00,00,00
490 data 00,00,00,00,00,00,00,00
500 data 00,00,00,00,00,00,00,00
Lightpen
One of advanced devices is also Lightpen. It's not standard device, but can be very useful to create pictures straight on monitor. Also is possible to use it in "Touch-screen" input.
Simple demo in BASIC is here:
100 REM * LIGHT PEN DEMO *
150 A$=CHR$(147):PRINTA$
160 PRINTTAB(10)"THREE CHOICES"
170 PRINT:PRINT
180 PRINTTAB(5)"* CHOICE ONE"
190 PRINT:PRINT:PRINT:PRINT
200 PRINTTAB(5)"* CHOICE TWO"
210 PRINT:PRINT:PRINT:PRINT
220 PRINTTAB(5)"* CHOICE THREE"
225 PRINT:PRINT:PRINT:PRINT
227 PRINTTAB(5)"* EXIT"
230 A=PEN(0):B=PEN(1):C=PEEK(56321)
250 IF (B>75) AND (B<90) AND C=251 THEN 300
260 IF (B>110) AND (B<135) AND C=251 THEN 330
270 IF (B>145) AND (B<170) AND C=251 THEN 360
280 IF (B>180) AND (B<205) AND C=251 THEN END
290 GOTO230
300 PRINTA$
310 PRINT"CHOICE ONE"
320 GOTO 400
330 PRINTA$
340 PRINT"CHOICE TWO"
350 GOTO 400
360 PRINTA$
370 PRINT"CHOICE THREE"
400 FOR I=0 TO 1500
410 NEXT I:PRINT
420 PRINT"* CONTINUE"
430 IF PEN(0)<55 AND PEN(1)<70 AND PEEK(56321)=251THEN 150
440 GOTO 430
Lightgun
We are at word "LIGHT", so here's other device with this prexif:
LIGHTGUN - FULL GAMING DEVICE!!!
On picture is shown Lightgun Defender64, but it's not only one type of lightgun.
Lightgun is used always (not seen before other) in GAMES...
You can aim & press the trigger!
For this device are made some games, here are some about which I know:
ARMY DAYS
BABY BLUES
COMBAT SCHOOL (BLAZE OUT COLLECTION)
HYPER SPORTS (BLAZE OUT COLLECTION)
PLATOON (BLAZE OUT COLLECTION)
RAMBO 3 (BLAZE OUT COLLECTION)
ROBOCOP (BLAZE OUT COLLECTION)
COSMIC STORM
GANGSTER
GOOSEBUSTERS
GUNSLINGER
OPERATION THUNDERBOLT
OPERATION WOLF
TIME TRAVELLER
-----------------------------
GHOST TOWN (ZX/C64?)
MISSILE GROUND ZERO (ZX/C64?)
SOLAR INVASION (ZX/C64?)
And here's little demo for using Lightgun Defender64 (on other I didn't tested - no have other device):
100 REM * LIGHT GUN DEMO *
110 COLOR0,2:COLOR4,14:COLOR5,1
150 A$=CHR$(147):PRINTA$:X=0:Y=0:Z=0
160 PRINTTAB(10)"SHOOT TARGETS!"
180 CHAR1,5,5,"O"
200 CHAR1,5,10,"O"
220 CHAR1,5,15,"O"
230 IF(POT(2)AND255)<>2THEN230
235 A=PEN(0):B=PEN(1)
250 IF (B>75) AND (B<90) THEN CHAR1,5,5,"X":X=1
260 IF (B>110) AND (B<135) THEN CHAR1,5,10,"X":Y=1
270 IF (B>145) AND (B<170) THEN CHAR1,5,15,"X":Z=1
280 IFX=1ANDY=1ANDZ=1THENCHAR1,10,20,"YOU PASSED!":END
290 GOTO230
Paddles
Paddles are used in some older games, it uses two potentiometers to check e.g. position on screen which explains this demo:
0 REM *** TOUCHPAD AND PADDLES DEMO ***
10 SPRITE1,1,2
20 MOVSPR1,100,100:GETKEYA$
30 A=POT(1):B=POT(2)
40 MOVSPR1,A,B
50 GOTO30
Touchpad
On picture is shown touchpad Koala. This is solution to paint the same what's on paper to the screen.
Koala has also two buttons for enlargement of painting area.
You can check previous demo with this device too.
Useful for this device can be also using it like touchpad like is used on notebooks...
Trackball
Trackball is like mouse, but the wheel is on top. Why this solution?
At work with mouse you need any area for moving. Trackball it does other, you can roll the wheel and cursor position is changed, but trackball is on the same position - really good solution.
Some older notebooks it had as solution for movement.
Access is same as joystick, but trackball is more sensitive and can move cursor to every degree - and this causes its speed. So, you must add bigger value for every movement, but not too large 'cause then is movement not so sensitive.
The same demo as in joystick has changed only adding values:
0 REM **** TRACKBALL ****
10 SPRITE1,1,2:X=100:Y=100
20 MOVSPR1,X,Y
30 A=JOY(2)
40 IFA=1THENY=Y-5
50 IFA=5THENY=Y+5
60 IFA=7THENX=X-5
70 IFA=3THENX=X+5
80 IFA=8THENX=X-5:Y=Y-5
90 IFA=2THENX=X+5:Y=Y-5
100 IFA=6THENX=X-5:Y=Y+5
110 IFA=4THENX=X+5:Y=Y+5
120 GOTO20
Commodore 128 keyboard
Commodore 128 uses advaced keyboard with control keys and numeric block.
All about is in Keyboard section.
Uses also four cursor keys and has also two CRSR keys which were
on Commodore 64. If you was 64'er and you get accustomed to use CRSR keys, you can download in Download section D64 image with utility E-KEY which uses these arrows as PgUp/PgDn/Home/End and key ALT as last entered command, SHIFT+ALT (in national versions of Commodore 128) to switch ASCII/DIN (ASCII/CC) to CAPS LOCK and back and SHIFT+ESC as exit of utility, CTRL+C and CTRL+V to copy/paste to/from clipboard, it's usable in 40 and 80 columns modes.
Keys on the image at right side are changed from MITSUMI keyboard, exactly model KKR-E99AC. But it's not problem to change any key 'think from all models of MITSUMI keyboards 'cause Commodore 128 keyboard manufacturer was MITSUMI.
On the end of this section is little BASIC program to use KoalaPad to paint, so, here is:
0 REM **** MINI PAINT ****
5 Y=0:PRINT"CLEAR SCREEN? (Y/N)":GETKEYA$:IFA$="Y"THENY=1
10 SPRITE1,1,8:MOVSPR1,100,100:GOSUB70
20 GRAPHIC2,Y,22:COLOR1,2:WIDTH2
25 A=POT(1):B=POT(2):IFA>255THENA=A-255
30 IFB>255THENB=B-255
35 IFPEEK(56321)<>247THEN50
40 IFA<11ORB<11THEN25
45 DRAW1,A,B
50 MOVSPR1,A+23,B+29+20
55 IFPEEK(56321)=251THENGRAPHIC0:END
60 GOTO25
70 PRINT"“":CHAR1,0,22," /":CHAR1,0,23,"/"
80 CHAR1,0,24,"MINI PAINT",1:RETURN