Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
RiscOS
S
Sources
HWSupport
Joystick
Commits
2a7c44db
Commit
2a7c44db
authored
26 years ago
by
Tim Roddis
Browse files
Options
Download
Email Patches
Plain Diff
Modifications for Phoebe HW.
parent
26a160c7
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
279 additions
and
51 deletions
+279
-51
s/Front
s/Front
+38
-4
s/ModHead
s/ModHead
+13
-8
s/SWI
s/SWI
+187
-36
s/Service
s/Service
+38
-2
s/Ticky
s/Ticky
+3
-1
No files found.
s/Front
View file @
2a7c44db
...
...
@@ -42,6 +42,10 @@ Module_BaseAddr
GET
Hdr:MsgTrans
GET
Hdr:NdrDebug
GET
Hdr:Podule
GET
Hdr:HostDebug
GET
Hdr:HostFS
$GetCodec
GET
Version
...
...
@@ -49,11 +53,13 @@ Module_BaseAddr
GBLL
debugmod
GBLL
debugtmp
GBLL
debugwt
GBLL
debugtgr
debug
SETL
false
debugmod
SETL
false
; Module debug
debugtmp
SETL
false
; Temporary debug
debugwt
SETL
false
; Misc debugging by WT
debugmod
SETL
false
; Module debug
debugtmp
SETL
false
; Temporary debug
debugwt
SETL
false
; Misc debugging by WT
debugtgr
SETL
false
hostvdu
SETL
false
; ----------------------------------------------------------------------------------------------------------------------
...
...
@@ -72,9 +78,19 @@ AnalogueJoyFire * DigitalJoystickAddress
|
[
Codec_Type
=
"AD1816"
[
AD1816_Podule
AnalogueJoy
*
&88400800
|
piwporp
]
|
AnalogueJoyFire
*
&03220000
]
]
AnalogueIrqReg
*
&032000e0
; Provisional MORRIS address
AnalogueStatusReg
*
&032000e4
; " " "
...
...
@@ -118,11 +134,23 @@ DigitalFireBit * 1 :SHL: 4
]
[
Codec_Type
=
"AD1816"
AnalogueJoy0FireShift
*
4
AnalogueJoy0Fire
*
3
:SHL:
AnalogueJoy0FireShift
AnalogueJoy1FireShift
*
6
AnalogueJoy1Fire
*
3
:SHL:
AnalogueJoy1FireShift
AnalogueAdvalFireA
*
1
:SHL:
AnalogueJoy0FireShift
AnalogueAdvalFireB
*
1
:SHL:
AnalogueJoy1FireShift
|
AnalogueJoy0Fire
*
&0f
:SHL:
0
AnalogueJoy1Fire
*
&0f
:SHL:
8
AnalogueAdvalFireA
*
1
:SHL:
0
AnalogueAdvalFireB
*
1
:SHL:
8
]
UpCode
*
&00040
; 64 in byte 0
DownCode
*
&000C0
; -64 in byte 0 (signed)
LeftCode
*
&0C000
; -64 in byte 1 (signed)
...
...
@@ -145,10 +173,12 @@ workspace RN R12
^
0
,
workspace
message_file_open
#
4
message_file_block
#
4
*
4
[
{TRUE}
;Codec_Type <> "AD1816"
magic_chan_one
#
4
magic_chan_two
#
4
magic_chan_three
#
4
magic_chan_four
#
4
]
range_chan_one
#
4
;Split XXXXYYYY where XXXX is max-min, YYYY is min
range_chan_two
#
4
;
range_chan_three
#
4
;
...
...
@@ -158,9 +188,13 @@ misc_flags # 1
adc_numchanstosample
#
1
adc_lastconversion
#
1
[
Codec_Type
=
"AD1816"
defaultrange
*
&1700
;These happen to suit Quickshot Warrior (cheap & nasty!)
defaultmin
*
&50
;PC-compatible joysticks
|
defaultrange
*
&1000
;These happen to suit Quickshot Warrior (cheap & nasty!)
defaultmin
*
&30
;PC-compatible joysticks
]
SixteenBitFlag
*
1
;This is a SWI entry flag, _NOT_ a misc flag
NoJoystickFlag
*
1
:SHL:
0
;However, these _ARE_ the misc flags!
...
...
This diff is collapsed.
Click to expand it.
s/ModHead
View file @
2a7c44db
...
...
@@ -75,7 +75,6 @@ Init
MOVVS
r1
,
#
0
LDRVC
r1
,
magic_chan_one
;r1 contains the podule id byte in bits 0->7
]
Debug
wt
,
"Read back from type detect:"
,
r1
TST
r1
,
#
DetectHardwareBit
; Check for hardware first
BNE
NoHware
...
...
@@ -84,13 +83,10 @@ Init
; ORR r1, r1, #RstFlags ; Set the reset flags too
STRB
r1
,
misc_flags
; And store it away, zeroing the rest of the misc flags too.
BLNE
init_analogue
; And then go set it in action...
|
MOV
r1
,
#
AnalogueFlag
STRB
r1
,
misc_flags
BL
init_analogue
]
;Initialise any other flags
...
...
@@ -145,14 +141,15 @@ Die
MOV
r0
,#
7
MOV
r2
,
r12
SWI
XOS_Module
; Clear workspace
[
Codec_Type
<>
"AD1816"
BL
StopTickyRoutine
]
BL
Shut_Down
Pull
"r4,pc"
,,^
[
Codec_Type
<>
"AD1816"
StopTickyRoutine
Push
"r0-r2,lr"
...
...
@@ -171,7 +168,7 @@ StopTickyRoutine
SWI
XOS_Release
; Release the ticker routine
Pull
"r0-r2,pc"
]
Shut_Down
Push
"r0,lr"
...
...
@@ -188,6 +185,14 @@ Shut_Down
; ---------------------------------------------------------------------------------------------------
; Initialising the analogue registers in Morris
init_analogue
[
Codec_Type
=
"AD1816"
LDR
r0
,
=
AD1816_SSBase
LDRB
r1
,
[
r0
,
#
SS_JoystkCtrl
]
ORR
r1
,
r1
,
#
SS_JWRP
:OR:
(
SS_JMSK_Mask
:SHL:
SS_JMSK_Shift
)
STRB
r1
,
[
r0
,
#
SS_JoystkCtrl
]
; set sampling off circa every 16 ms
STRB
r1
,
[
r0
,
#
SS_JoystkPos
]
STRB
r1
,
[
r0
,
#
SS_JoystkPos
+
4
]
|
LDR
r1
,
=
AnalogueIrqReg
MOV
r0
,
#
&0f
;Enable all channels, but don't allow irqs
STRB
r0
,
[
r1
]
;
...
...
@@ -195,7 +200,7 @@ init_analogue
LDR
r1
,
=
AnalogueControlReg
MOV
r0
,
#
&0f
;Counters on, discharge off
STRB
r0
,
[
r1
]
]
MOV
pc
,
lr
...
...
This diff is collapsed.
Click to expand it.
s/SWI
View file @
2a7c44db
...
...
@@ -28,8 +28,7 @@ SWInames
SWIhandler
ROUT
Push
"r2-r5,lr"
Push
"r1"
Push
"r1-r6,lr"
CMP
r11
,
#
3
BGT
%FT01
...
...
@@ -37,15 +36,18 @@ SWIhandler
LDR
r12
,[
r12
]
; Get workspace from private word
ADD
pc
,
pc
,
r11
,
LSL
#
2
; Jumptable calculation
MOV
r0
,
r0
; dummy instruction
[
Codec_Type
=
"AD1816"
B
Read
|
B
AreWeAnaOrDigi
; Oh look! it's a jumptable after all...
]
B
Calib_SWIS
; If it's the calibrationTL SWI, then go do it...
B
Calib_SWIS
; If it's the calibrationBR SWI, then go do it...
01
ADR
r0
,
ErrorBlock_BadSWI
; Uh Oh!
addr
r4
,
Title
BL
msgtrans_errorlookup
Pull
"r1"
,
VS
Pull
"r2-r5,pc"
,
VS
Pull
"r1-r6,pc"
,
VS
;----------------------------------------------------------------------------------------
ErrorBlock_BadSWI
...
...
@@ -58,6 +60,54 @@ ErrorBlock_BadJoystick
DCB
"BadJoy"
,
0
ALIGN
[
Codec_Type
=
"AD1816"
Read
MOV
r5
,
r0
,
LSR
#
8
; R5 contains the flag info now
AND
r0
,
r0
,
#
&FF
; Mask off the flags from R0
CMP
r0
,
#
1
; Test against 1
ADRHI
r0
,
ErrorBlock_BadJoystick
; Too high
BLHI
msgtrans_errorlookup
Pull
"r1-r6,pc"
,
VS
; Return if error
LDR
r6
,
=
AD1816_SSBase
LDRB
r4
,
[
r6
,
#
SS_RawJoystk
]
ANDNE
r3
,
r4
,
#
AnalogueJoy0Fire
; Pick out Joystick 0 fire buttons
EORNE
r3
,
r3
,
#
AnalogueJoy0Fire
; Invert them
MOVNE
r4
,
r3
,
LSL
#
16
-
AnalogueJoy0FireShift
; Put in byte 2 of R4
ANDEQ
r3
,
r4
,
#
AnalogueJoy1Fire
; Pick out Joystick 1 fire buttons
EOREQ
r3
,
r3
,
#
AnalogueJoy1Fire
; Invert them
MOVEQ
r4
,
r3
,
LSL
#
16
-
AnalogueJoy1FireShift
; Put in byte 2 of R4
10
LDRB
r3
,
[
r6
,
#
SS_JoystkCtrl
]
[
{FALSE}
TST
r3
,
r3
,
#
SS_JRDY
BEQ
%BT10
CMP
r0
,
#
1
]
BIC
r3
,
r3
,
#
SS_JSEL_Mask
; figure out which joystick was wanted (above)
; read in relevant two channels
ORRNE
r3
,
r3
,
#
SS_JSEL_AX
; Get x axis
ORREQ
r3
,
r3
,
#
SS_JSEL_BX
;
STRB
r3
,
[
r6
,
#
SS_JoystkCtrl
]
LDRB
r1
,
[
r6
,
#
SS_JoystkPos
]
; Get 16-bit
LDRB
r2
,
[
r6
,
#
SS_JoystkPos
+
4
]
; x position
ORR
r1
,
r1
,
r2
,
LSL
#
8
; into r1
BIC
r3
,
r3
,
#
SS_JSEL_Mask
ORRNE
r3
,
r3
,
#
SS_JSEL_AY
; Get y axis
ORREQ
r3
,
r3
,
#
SS_JSEL_BY
;
STRB
r3
,
[
r6
,
#
SS_JoystkCtrl
]
LDRB
r2
,
[
r6
,
#
SS_JoystkPos
]
; Get 16-bit
LDRB
r3
,
[
r6
,
#
SS_JoystkPos
+
4
]
; y position
ORR
r2
,
r2
,
r3
,
LSL
#
8
; into r2
|
AreWeAnaOrDigi
;Don't upset R0 or R4!
...
...
@@ -78,8 +128,7 @@ AreWeAnaOrDigi
BL
StartTickyRoutine
; If set, special case...
Debug
wt
,
"Ticky tick tick started"
05
MOV
r0
,
#
0
; Dummy value to return from the SWI (centred joystick)
Pull
"r1"
Pull
"r2-r5,pc"
; All done, let's go
Pull
"r1-r6,pc"
; All done, let's go
; Drop through to...
...
...
@@ -96,8 +145,7 @@ Joystick_ReadAnaSWICode
CMPNE
r0
,
#
0
; No, but did we really want Joystick 0?
ADRNE
r0
,
ErrorBlock_BadJoystick
; Nope, so it's not a valid joystick ( >1 )
BLNE
msgtrans_errorlookup
Pull
"r1"
,
VS
Pull
"r2-r5,pc"
,
VS
; Return if error
Pull
"r1-r6,pc"
,
VS
; Return if error
;Now sort out the fire buttons, into R4
LDR
r4
,
[
r3
]
; Latch &
...
...
@@ -113,42 +161,44 @@ Joystick_ReadAnaSWICode
;Do twiddling to go from raw to 16 or 8 bits scaled
LDR
r1
,
[
r1
]
; Read the X channel
LDR
r2
,
[
r2
]
; Read the Y channel
MOV
r3
,
#
&ff
ORR
r3
,
r3
,
r3
,
LSL
#
8
; Now we have &ffff in r3
AND
r1
,
r1
,
r3
; Clear the top 16 bits from r1...
AND
r2
,
r2
,
r3
; ... and from R2.
]
[
Codec_Type
=
"AD1816"
MOV
r3
,
#
&ff
ORR
r3
,
r3
,
r3
,
LSL
#
8
; Now we have &ffff in r3
]
;Now scale to cover the entire 16-bit range (0 -> &ffff)
BL
ExpandRange
; NB: This routine needs the joystick number in R0!
TST
r5
,
#
SixteenBitFlag
; Do we want 16 or 8 bit results?
BNE
%FA30
; Sixteen, so jump
; Bug fix applied to the following - TGR
MOV
r3
,
r1
,
LSR
#
8
; If 8-bits,
TST
r3
,
#
1
<<
7
;bit 7 set?
BICNE
r3
,
r3
,
#
1
<<
7
;Clear top bit then.
EOREQ
r3
,
r3
,
#
&ff
;Nope, so invert all bits.
MOV
r1
,
r3
; this bit
MOV
r3
,
r2
,
LSR
#
8
; twiddling
TST
r3
,
#
1
<<
7
;bit 7 set?
BICNE
r3
,
r3
,
#
1
<<
7
;Clear top bit then.
EOREQ
r3
,
r3
,
#
&ff
;Nope, so invert all bits.
SUB
r3
,
r3
,
#
128
; range -128 to 127
AND
r3
,
r3
,
#
&ff
; 8-bit signed
MOV
r1
,
r3
;
MOV
r3
,
r2
,
LSR
#
8
;
SUB
r3
,
r3
,
#
128
AND
r3
,
r3
,
#
&ff
MOV
r2
,
r3
; .
;Put the values into the result word if 8-bit values wanted
MOV
r0
,
r4
ORR
r0
,
r0
,
r2
; Put the Y in the result
ORR
r0
,
r0
,
r1
,
LSL
#
8
; Put the X in the result
Pull
"r1"
Pull
"r2-r5,pc"
; All done, let's go
Pull
"r1-r6,pc"
; All done, let's go
;Put the values into the result word, unsigned
30
Pull
"r5"
; Pull r1 into r5 so we can fill it instead...
MOV
r0
,
r2
; Put the Y axis value in R0
ORR
r0
,
r0
,
r1
,
LSL
#
16
; Put the X axis value in R0
MOV
r1
,
r4
,
LSR
#
16
; Put switch bits in R1, bottom byte
Pull
"r2-r
5
,pc"
; End of story
Pull
"r2-r
6
,pc"
; End of story
[
IOMD_C_JoystickDetectBits
<>
0
...
...
@@ -166,8 +216,7 @@ Joystick_ReadDigSWICode
CMPNE
r0
,
#
0
; But did we?
ADRNE
r0
,
ErrorBlock_BadJoystick
; Nope, so error & quit
BLNE
msgtrans_errorlookup
Pull
"r1"
,
VS
Pull
"r2-r5,pc"
,
VS
Pull
"r1-r6,pc"
,
VS
;At this point, we have the joystick info in the low byte of r2
MOV
r0
,
#
0
; Clear R0!
...
...
@@ -182,10 +231,10 @@ Joystick_ReadDigSWICode
TST
r2
,
#
DigitalFireBit
; And finally the fire bit (in byte 2)
ORREQ
r0
,
r0
,
#
FireCode
Debug
wt
,
"Done calculatin'"
Pull
"r1"
Pull
"r2-r5,pc"
; All done, let's go
Pull
"r1-r6,pc"
; All done, let's go
]
[
Codec_Type
<>
"AD1816"
;----------------------------------------------------------------------------------------
StartTickyRoutine
...
...
@@ -202,9 +251,10 @@ StartTickyRoutine
MOV
r1
,
#
4
; Claim VSync event
SWI
XOS_Byte
Pull
"pc"
,,^
]
;----------------------------------------------------------------------------------------
ExpandRange
;On entry, R0=joystick number, R1=Xval, R2=Yval, R3=&ffff, R4=fires, R5=16-bit flag
;On exit, R0=joystick number, R1=scaled Xval, R2=scaled Yval, R3=&ffff, R4=fires, R5=16-bit flag
...
...
@@ -232,6 +282,8 @@ ExpandRange
CMP
r0
,
#
0
;Joystick 0 or 1?
LDREQ
r4
,
range_chan_two
LDRNE
r4
,
range_chan_four
Debug
tgr
,
"Y was "
,
r2
Debug
tgr
,
"Range is "
,
r4
AND
r5
,
r4
,
r3
;R5=min calib
SUBS
r6
,
r2
,
r5
;R6=value-min
MOVMI
r6
,
#
0
; Don't allow R6 < 0
...
...
@@ -243,6 +295,8 @@ ExpandRange
CMP
r2
,
#
0
MOVMI
r2
,
#
0
;and a 0 min
Debug
tgr
,
"Y is "
,
r2
;Ranges done, now invert R1,R2 if necessary
LDRB
r4
,
range_polarity
...
...
@@ -268,6 +322,7 @@ ExpandRange
;----------------------------------------------------------------------------------------
Calib_SWIS
;R2 to R5 and LR are pushed, as is R1 (separately)
;Need optional checks here to determine axis polarity.
[
Codec_Type
<>
"AD1816"
LDRB
r2
,
misc_flags
TST
r2
,
#
FirstTimeFlag
; Check the first time flag if we're analogue
BEQ
%FT48
; Not first time, so don't set the ticky thing going
...
...
@@ -277,15 +332,111 @@ Calib_SWIS ;R2 to R5 and LR are pushed, as is R1 (separately)
SWI
OS_Byte
;Wait for a VSync so we get some sensible values...
SWI
OS_Byte
;Wait for a VSync so we get some sensible values...
SWI
OS_Byte
;Wait for a VSync so we get some sensible values...
48
MOV
r1
,
#
&ff
|
LDR
r6
,
=
AD1816_SSBase
]
48
[
Codec_Type
<>
"AD1816"
MOV
r1
,
#
&ff
ORR
r1
,
r1
,
r1
,
LSL
#
8
;R1 is &ffff
]
LDRB
r2
,
misc_flags
TST
r2
,
#
CalibrateFlag
BNE
%FT50
;This is the second calibration!
ORR
r2
,
r2
,
#
CalibrateFlag
;I'm 'aving a CALIBRATE!
STRB
r2
,
misc_flags
[
Codec_Type
=
"AD1816"
LDRB
r3
,
[
r6
,
#
SS_JoystkCtrl
]
[
{FALSE}
TST
r3
,
r3
,
SS_JRDY
BEQ
%BT10
CMP
r0
,
#
1
]
BIC
r3
,
r3
,
#
SS_JSEL_Mask
ORR
r3
,
r3
,
#
SS_JSEL_AX
; Get x axis
STRB
r3
,
[
r6
,
#
SS_JoystkCtrl
]
LDRB
r4
,
[
r6
,
#
SS_JoystkPos
]
; Get
LDRB
r2
,
[
r6
,
#
SS_JoystkPos
+
4
]
; 16-bit
ORR
r2
,
r4
,
r2
,
LSL
#
8
; position
STR
r2
,
range_chan_one
BIC
r3
,
r3
,
#
SS_JSEL_Mask
ORR
r3
,
r3
,
#
SS_JSEL_AY
; Get y axis
STRB
r3
,
[
r6
,
#
SS_JoystkCtrl
]
LDRB
r4
,
[
r6
,
#
SS_JoystkPos
]
; Get
LDRB
r2
,
[
r6
,
#
SS_JoystkPos
+
4
]
; 16-bit
ORR
r2
,
r4
,
r2
,
LSL
#
8
; position
STR
r2
,
range_chan_two
BIC
r3
,
r3
,
#
SS_JSEL_Mask
ORR
r3
,
r3
,
#
SS_JSEL_BX
; Get x axis
STRB
r3
,
[
r6
,
#
SS_JoystkCtrl
]
LDRB
r4
,
[
r6
,
#
SS_JoystkPos
]
; Get
LDRB
r2
,
[
r6
,
#
SS_JoystkPos
+
4
]
; 16-bit
ORR
r2
,
r4
,
r2
,
LSL
#
8
; position
STR
r2
,
range_chan_three
BIC
r3
,
r3
,
#
SS_JSEL_Mask
ORR
r3
,
r3
,
#
SS_JSEL_BY
; Get y axis
STRB
r3
,
[
r6
,
#
SS_JoystkCtrl
]
LDRB
r4
,
[
r6
,
#
SS_JoystkPos
]
; Get
LDRB
r2
,
[
r6
,
#
SS_JoystkPos
+
4
]
; 16-bit
ORR
r2
,
r4
,
r2
,
LSL
#
8
; position
STR
r2
,
range_chan_four
Pull
"r1-r6, pc"
50
BIC
r2
,
r2
,
#
CalibrateFlag
;Clear the calibrate flag
STRB
r2
,
misc_flags
LDRB
r1
,
[
r6
,
#
SS_JoystkCtrl
]
[
{FALSE}
TST
r1
,
r1
,
SS_JRDY
BEQ
%BT10
CMP
r0
,
#
1
]
MOV
r2
,
#
0
;Clear R2 ready to accept polarity flags
BIC
r1
,
r1
,
#
SS_JSEL_Mask
ORR
r1
,
r1
,
#
SS_JSEL_AX
; Get x axis
STRB
r1
,
[
r6
,
#
SS_JoystkCtrl
]
LDRB
r4
,
[
r6
,
#
SS_JoystkPos
]
; Get
LDRB
r3
,
[
r6
,
#
SS_JoystkPos
+
4
]
; 16-bit
ORR
r3
,
r4
,
r3
,
LSL
#
8
; position
LDR
r4
,
range_chan_one
;Previous reading
MOV
r5
,
#
polarity_chan_one
BL
DoRanging
STR
r3
,
range_chan_one
BIC
r1
,
r1
,
#
SS_JSEL_Mask
ORR
r1
,
r1
,
#
SS_JSEL_AY
; Get y axis
STRB
r1
,
[
r6
,
#
SS_JoystkCtrl
]
LDRB
r4
,
[
r6
,
#
SS_JoystkPos
]
; Get
LDRB
r3
,
[
r6
,
#
SS_JoystkPos
+
4
]
; 16-bit
ORR
r3
,
r4
,
r3
,
LSL
#
8
; position
LDR
r4
,
range_chan_two
;Previous reading
MOV
r5
,
#
polarity_chan_two
BL
DoRanging
STR
r3
,
range_chan_two
BIC
r1
,
r1
,
#
SS_JSEL_Mask
ORR
r1
,
r1
,
#
SS_JSEL_BX
; Get x axis
STRB
r1
,
[
r6
,
#
SS_JoystkCtrl
]
LDRB
r4
,
[
r6
,
#
SS_JoystkPos
]
; Get
LDRB
r3
,
[
r6
,
#
SS_JoystkPos
+
4
]
; 16-bit
ORR
r3
,
r4
,
r3
,
LSL
#
8
; position
LDR
r4
,
range_chan_three
;Previous reading
MOV
r5
,
#
polarity_chan_three
BL
DoRanging
STR
r3
,
range_chan_three
BIC
r1
,
r1
,
#
SS_JSEL_Mask
ORR
r1
,
r1
,
#
SS_JSEL_BY
; Get y axis
STRB
r1
,
[
r6
,
#
SS_JoystkCtrl
]
LDRB
r4
,
[
r6
,
#
SS_JoystkPos
]
; Get
LDRB
r3
,
[
r6
,
#
SS_JoystkPos
+
4
]
; 16-bit
ORR
r3
,
r4
,
r3
,
LSL
#
8
; position
LDR
r4
,
range_chan_four
;Previous reading
MOV
r5
,
#
polarity_chan_four
BL
DoRanging
STR
r3
,
range_chan_four
|
LDR
r2
,
magic_chan_one
;Take snaphots
AND
r2
,
r2
,
r1
STR
r2
,
range_chan_one
...
...
@@ -299,8 +450,7 @@ Calib_SWIS ;R2 to R5 and LR are pushed, as is R1 (separately)
AND
r2
,
r2
,
r1
STR
r2
,
range_chan_four
Pull
"r1"
Pull
"r2-r5,pc"
Pull
"r1-r6,pc"
;Right, munge stuff to get range-min pairs & polarities
...
...
@@ -335,31 +485,31 @@ Calib_SWIS ;R2 to R5 and LR are pushed, as is R1 (separately)
MOV
r5
,
#
polarity_chan_four
BL
DoRanging
STR
r3
,
range_chan_four
]
Debug
wt
,
"Storing r2 as "
,
r2
STRB
r2
,
range_polarity
Pull
"r1"
Pull
"r2-r5,pc"
Pull
"r1-r6,pc"
DoRanging
CMP
r3
,
r4
;Sort out which way around they are to get the 'range'
BPL
%FT60
;first call was the smaller
X1
BPL
%FT60
;first call was the smaller
SUB
r4
,
r4
,
r3
;R4 = range now
SUB
r4
,
r4
,
r4
,
LSR
#
12
;Decrease the range slightly at CWhyte's request :-P
;
SUB r4, r4, r4, LSR #12 ;Decrease the range slightly at CWhyte's request :-P
CMP
r4
,
#
0
MOVEQ
r4
,
#
1
ORR
r3
,
r3
,
r4
,
LSL
#
16
;Combine the min & range in r3
CMP
r11
,
#
1
;Is this 2nd call the TR?
ORREQ
r2
,
r2
,
r5
;Nope, so we need reverse polarity
Debug
wt
,
"After a doranging, r2 is "
,
r2
Debug
tgr
,
"range is "
,
r3
MOV
pc
,
lr
60
SUB
r3
,
r3
,
r4
;R3 = range now
SUB
r3
,
r3
,
r3
,
LSR
#
12
;Decrease the range slightly at CWhyte's request :-P
;
SUB r3, r3, r3, LSR #12 ;Decrease the range slightly at CWhyte's request :-P
CMP
r3
,
#
0
MOVEQ
r3
,
#
1
ORR
r4
,
r4
,
r3
,
LSL
#
16
;Combine the min & range in r4
...
...
@@ -367,6 +517,7 @@ DoRanging
ORRNE
r2
,
r2
,
r5
;Yup, so we need reverse polarity
Debug
wt
,
"After a doranging.., r2 is "
,
r2
MOV
r3
,
r4
Debug
tgr
,
"range is "
,
r3
MOV
pc
,
lr
LNK
s.Service
This diff is collapsed.
Click to expand it.
s/Service
View file @
2a7c44db
...
...
@@ -31,13 +31,13 @@ Service
Pull
"r0,r12,pc"
,
EQ
,^
;It's a digital i/f, so ignore the service
TST
r0
,
#
CalibrateFlag
;and the 'calibrate' flag
Pull
"r0,r12,pc"
,
NE
,^
;It's being calibrated at the mo, so ignore the service
[
Codec_Type
<>
"AD1816"
TST
r0
,
#
FirstTimeFlag
;Is the ticky routine going yet?
Push
"r0-r5"
,
NE
MOV
r4
,
r14
;Grab the value of R12 into R4 from R14
BLNE
StartTickyRoutine
;Nope, so go start it
Pull
"r0-r5"
,
NE
]
;I know I should be claiming ByteV, but doing it this way is the easiest
;way to ensure that if present, the I/O podule will get to the UKByte first...
;However, it does mean that we can't indicate any errors :-(
...
...
@@ -86,6 +86,41 @@ OSByte128
; BLT %BT05 ;Bzzt, wrong answer!
CMP
r3
,
#
0
BNE
%FT15
[
Codec_Type
=
"AD1816"
LDR
r1
,
=
AD1816_SSBase
LDRB
r3
,
[
r1
,
#
SS_RawJoystk
]
AND
r3
,
r3
,
#
AnalogueAdvalFireA
:OR:
AnalogueAdvalFireB
ORR
r3
,
r3
,
r3
,
LSR
#
1
MOV
r3
,
r3
,
LSR
#
AnalogueJoy0FireShift
LDRB
r4
,
adc_lastconversion
B
%FT20
15
MOV
r0
,
#
0
; bit mask in use
TEQ
r3
,
#
1
MOVEQ
r0
,
#
SS_JSEL_AX
TEQ
r3
,
#
2
MOVEQ
r0
,
#
SS_JSEL_AY
TEQ
r3
,
#
3
MOVEQ
r0
,
#
SS_JSEL_BX
TEQ
r3
,
#
4
MOVEQ
r0
,
#
SS_JSEL_BY
TEQ
r0
,
#
0
Pull
"r0, r12, pc"
,
EQ
,^
; not one of ours
LDRB
r3
,
[
r6
,
#
SS_JoystkCtrl
]
[
{FALSE}
TST
r3
,
r3
,
#
SS_JRDY
BEQ
%BT10
CMP
r0
,
#
1
]
BIC
r3
,
r3
,
#
SS_JSEL_Mask
ORR
r3
,
r3
,
r4
; which channel to read
STRB
r3
,
[
r6
,
#
SS_JoystkCtrl
]
LDRB
r3
,
[
r6
,
#
SS_JoystkPos
]
; Get lo order byte
LDRB
r4
,
[
r6
,
#
SS_JoystkPos
+
4
]
; Get hi order byte
B
%FT20
|
;Do the fire bit reading here
LDR
r3
,
=
AnalogueJoyFire
LDR
r4
,
[
r3
]
; Latch &
...
...
@@ -112,6 +147,7 @@ OSByte128
MOV
r4
,
r0
,
LSR
#
8
; R4 (Y) contains the high 8 bits now
B
%FT20
; Claim & quit
]
;-----------------
OSByte188
...
...
This diff is collapsed.
Click to expand it.
s/Ticky
View file @
2a7c44db
...
...
@@ -14,6 +14,8 @@
;
; > Sources.Ticky
[
Codec_Type
<>
"AD1816"
TickerRoutine
;Periodically executes, updating the magic locations.
ROUT
CMP
r0
,
#
4
...
...
@@ -163,7 +165,7 @@ SortChan4 ;Don't use R4!
MOV
pc
,
lr
;Return
]
;----------------------------
LNK
s.SWI
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment