Commodore 128 Programmer's Reference Manual page 402

Hide thumbs Also See for 128:
Table of Contents

Advertisement

392
COMMODORE 128
ij
Using Boolean logic and the masking technique, a comparison can be made to
determine whether the fire button was depressed:
IF (JOY(N)AND 128) = 128 THEN PRINT'FIRE"
IJ
THE 1350 MOUSE
.
The Commodore 128 makes use of an additional new peripheral device known as a
I—I
mouse. The Commodore mouse is a user interface that allows you to control the
operations of a program, such as selecting menu or icon options, without the need to
i t
type on the keyboard. It attaches to the controller ports like a joystick, paddle or light
[J
pen. Programs that support a mouse usually have a pointer indicator to let you know
where the mouse is pointing on the screen. To move the pointer on the screen, place the
mouse on a flat surface and move it in the direction you want to move the pointer. Lift
I j
the mouse off the surface and the screen indicator remains stationary. The left hand
LJ
button responds like a joystick fire button. The right hand button may have additional
functions as specified by a particular software package.
j i
As far as BASIC is concerned, the mouse is supported by the JOY function, the
M
same way a joystick is controlled. The previous joystick program example, which
moves a sprite on the screen, also works with the mouse. The Joystick Musician
program in Chapter 11 also works with the mouse. Any BASIC program using the JOY
I j
joystick function should operate with the Commodore mouse.
U
The mouse also works in C64 mode, the same way a joystick routine would in
C64 mode. The previous C64 mode joystick example program supports the mouse in
i
C64 mode.
J
PADDLES
.
A paddle is connected to both CIA-1 and the SID chip (MOS 6581 Sound Interface Device)
U
through a controller port. The paddle value is read via the SID registers 54297 ($D419) and
54298 ($D41A). Paddles are not reliable when readfrom BASIC alone! The best way to
i i
use paddles, from BASIC or machine code, is to use a machine language routine (SYS
I
to it from BASIC then PEEK the memory locations used by the subroutine).
The following BASIC program moves a sprite with paddles:
10 REM C128-MODE SPRITE-MOVE PADDLE ROUTINE
[J
20 REM PLACE DUAL PADDLES
IN CONTROLLER PORT A
30 REM PADDLE
1
CONTROLS HORIZONTAL SPRITE MOVEMENT
40 REM PADDLE
2
CONTROLS VERTICAL MOVEMENT
50 SPRITE 1,1,7
I
60
DO
70 A=POT(1):REM GET POSITION (X) OF PADDLE 1
UJ
80 B=POT(2):REM GET POSITION
(Y)
OF PADDLE 2
90
PRINT A;B:REM PRINT VALUES
100 MOVSPR 1,A,B:REM MOVE SPRITE 1 ACCORDING TO PADDLE VALUES
I
I
110
IF
(A>255)
OR
(B>255)
THEN BEGIN:REM CHECK FOR FIRE BUTTON
120 :
SOUND 2,64000,60,0,1000, 16000,3:REM FIRE
LJ
130
:
COLOR 0,3:REM CHANGE SCREEN COLOR
140
:
SLEEP
1
:REM DELAY
150
:
COLOR 0,1:REM CHANGE SCREEN COLOR BACK
160 BEND:REM END THE BEGIN/BEND STRUCTURE
170
LOOP:REM DO
IT AGAIN
U
U

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents