mirror of
https://github.com/a2-4am/4cade.git
synced 2025-03-01 12:30:33 +00:00
joystick detection works
This commit is contained in:
parent
3232d592ff
commit
b03ac885e4
147
src/4cade.a
147
src/4cade.a
@ -2,134 +2,43 @@
|
||||
!to "build/LAUNCHER.SYSTEM",plain
|
||||
*=$2000
|
||||
|
||||
Has128KStatus =$FF ; [byte] set by Has128K
|
||||
jmp Start
|
||||
|
||||
!source "src/constants.a"
|
||||
!source "src/macros.a"
|
||||
!source "src/memcheck.a"
|
||||
!source "src/joystick.a"
|
||||
!source "src/normfast.a"
|
||||
|
||||
!zone {
|
||||
Start
|
||||
jsr $FE89
|
||||
jsr $FE93
|
||||
jsr $FB2F
|
||||
jsr $FC58
|
||||
jsr Has128K
|
||||
- ldx #0
|
||||
beq -
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Has128K
|
||||
; Checks whether computer has auxiliary memory (i.e. 128K)
|
||||
;
|
||||
; in: none
|
||||
; out: zero page $FF has
|
||||
; $00 = not a //e
|
||||
; $20 = //e but no 80-col card
|
||||
; $40 = 80-col card but no aux mem
|
||||
; $80 = aux mem detected (yay!)
|
||||
; all other flags clobbered
|
||||
; all registers clobbered
|
||||
; zero page $1A-$1D clobbered
|
||||
;
|
||||
; original was AUX.MEM.CHECK from "Extra K"
|
||||
; (c) 1986 Beagle Bros
|
||||
; written by Alan Bird and Mark Simonsen, 1986-03-28
|
||||
;------------------------------------------------------------------------------
|
||||
Has128K
|
||||
php
|
||||
sei
|
||||
lda $E000 ; store values from language card
|
||||
sta $1A ; (used later to determine which
|
||||
lda $D000 ; RAM bank is active and reset it)
|
||||
sta $1B
|
||||
lda $D400
|
||||
sta $1C
|
||||
lda $D800
|
||||
sta $1D
|
||||
lda ROMIN
|
||||
lda ROMIN
|
||||
lda MACHINEID
|
||||
cmp #$06
|
||||
bne @noiie
|
||||
lda SLOT3STATUS
|
||||
bmi @no80col
|
||||
lda AUXMEMSTATUS
|
||||
bmi @yesauxmem
|
||||
lda AUXZPSTATUS
|
||||
bmi @yesauxmem
|
||||
ldy #$28
|
||||
- ldx @checker,Y
|
||||
lda $100,Y
|
||||
sta @checker,Y
|
||||
txa
|
||||
sta $100,Y
|
||||
bmi @found128K
|
||||
ldy #9
|
||||
- lda @s_needs128K,y
|
||||
sta $400,y
|
||||
dey
|
||||
bpl -
|
||||
jmp $100
|
||||
@postcheck
|
||||
ldy #$28
|
||||
- lda @checker,Y
|
||||
sta $100,Y
|
||||
@hang bmi @hang
|
||||
@s_needs128K
|
||||
!text "NEEDS 128K"
|
||||
@found128K
|
||||
jsr DisableAccelerator
|
||||
jsr HasJoystick
|
||||
bcc @hang
|
||||
ldy #10
|
||||
- lda @s_nojoystick,y
|
||||
sta $400,y
|
||||
dey
|
||||
bpl -
|
||||
bcs @noauxmem
|
||||
@yesauxmem
|
||||
lda #$80
|
||||
+HIDE_NEXT_2_BYTES
|
||||
@noauxmem
|
||||
lda #$40
|
||||
+HIDE_NEXT_2_BYTES
|
||||
@no80col
|
||||
lda #$20
|
||||
+HIDE_NEXT_2_BYTES
|
||||
@noiie
|
||||
lda #$00
|
||||
sta Has128KStatus
|
||||
lda $E000
|
||||
cmp $1A
|
||||
bne @tryRAMbank1
|
||||
lda $D000
|
||||
cmp $1B
|
||||
bne @tryRAMbank1
|
||||
lda $D400
|
||||
cmp $1C
|
||||
bne @tryRAMbank1
|
||||
lda $D800
|
||||
cmp $1D
|
||||
beq @done
|
||||
@tryRAMbank1
|
||||
lda LCBANK1READ
|
||||
lda $E000
|
||||
cmp $1A
|
||||
bne @tryRAMbank2
|
||||
lda $D000
|
||||
cmp $1B
|
||||
bne @tryRAMbank2
|
||||
lda $D400
|
||||
cmp $1C
|
||||
bne @tryRAMbank2
|
||||
lda $D800
|
||||
cmp $1D
|
||||
beq @done
|
||||
@tryRAMbank2
|
||||
lda LCBANK2READ
|
||||
@done
|
||||
plp
|
||||
lda Has128KStatus
|
||||
rts
|
||||
@checker
|
||||
lda #$EE
|
||||
sta WRITEAUXMEM
|
||||
sta READAUXMEM
|
||||
sta $800
|
||||
lda $C00
|
||||
cmp #$EE
|
||||
bne @auxworks
|
||||
asl $C00
|
||||
lda $800
|
||||
cmp $C00
|
||||
bne @auxworks
|
||||
sec
|
||||
+HIDE_NEXT_BYTE
|
||||
@auxworks
|
||||
clc
|
||||
sta WRITEMAINMEM
|
||||
sta READMAINMEM
|
||||
jmp @postcheck
|
||||
bmi @hang
|
||||
@s_nojoystick
|
||||
!text "NO JOYSTICK"
|
||||
}
|
||||
|
||||
; jsr init ; initialize ProRWTS2
|
||||
; lda $C08B
|
||||
|
40
src/joystick.a
Normal file
40
src/joystick.a
Normal file
@ -0,0 +1,40 @@
|
||||
;------------------------------------------------------------------------------
|
||||
; HasJoystick
|
||||
; Checks whether computer has joystick connected
|
||||
;
|
||||
; in: none
|
||||
; out: C clear if joystick found
|
||||
; C set if no joystick found
|
||||
; other flags clobbered
|
||||
; A,X clobbered
|
||||
; Y preserved
|
||||
;
|
||||
; adapted from "Prince of Persia" by Jordan Mechner
|
||||
; (c) 1989 Broderbund Software
|
||||
; https://github.com/jmechner/Prince-of-Persia-Apple-II/blob/master/01%20POP%20Source/Source/GRAFIX.S#L1225
|
||||
;------------------------------------------------------------------------------
|
||||
HasJoystick
|
||||
lda #0
|
||||
sta joyX
|
||||
sta joyY
|
||||
lda $C070 ; reset analog input timers
|
||||
@loop ldx #1
|
||||
@1 lda $C064,x ; check timer input
|
||||
bpl @beat
|
||||
inc joyX,x ; still high, increment counter
|
||||
@nextpdl dex
|
||||
bpl @1
|
||||
lda $C064
|
||||
ora $C065
|
||||
bpl @rts ; both inputs low, we're done
|
||||
lda joyX
|
||||
ora joyY
|
||||
bpl @loop ; do it again
|
||||
sec
|
||||
+HIDE_NEXT_BYTE
|
||||
@rts clc
|
||||
rts
|
||||
@beat nop
|
||||
bpl @nextpdl ; kill time
|
||||
joyX !byte 0
|
||||
joyY !byte 0
|
121
src/memcheck.a
Normal file
121
src/memcheck.a
Normal file
@ -0,0 +1,121 @@
|
||||
Has128KStatus =$FF ; [byte] set by Has128K
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Has128K
|
||||
; Checks whether computer has auxiliary memory (i.e. 128K)
|
||||
;
|
||||
; in: none
|
||||
; out: zero page $FF has
|
||||
; $00 = not a //e
|
||||
; $20 = //e but no 80-col card
|
||||
; $40 = 80-col card but no aux mem
|
||||
; $80 = aux mem detected (yay!)
|
||||
; all other flags clobbered
|
||||
; all registers clobbered
|
||||
; zero page $1A-$1D clobbered
|
||||
;
|
||||
; original was AUX.MEM.CHECK from "Extra K"
|
||||
; (c) 1986 Beagle Bros
|
||||
; written by Alan Bird and Mark Simonsen, 1986-03-28
|
||||
;------------------------------------------------------------------------------
|
||||
Has128K
|
||||
php
|
||||
sei
|
||||
lda $E000 ; store values from language card
|
||||
sta $1A ; (used later to determine which
|
||||
lda $D000 ; RAM bank is active and reset it)
|
||||
sta $1B
|
||||
lda $D400
|
||||
sta $1C
|
||||
lda $D800
|
||||
sta $1D
|
||||
lda ROMIN
|
||||
lda ROMIN
|
||||
lda MACHINEID
|
||||
cmp #$06
|
||||
bne @noiie
|
||||
lda SLOT3STATUS
|
||||
bmi @no80col
|
||||
lda AUXMEMSTATUS
|
||||
bmi @yesauxmem
|
||||
lda AUXZPSTATUS
|
||||
bmi @yesauxmem
|
||||
ldy #$28
|
||||
- ldx @checker,Y
|
||||
lda $100,Y
|
||||
sta @checker,Y
|
||||
txa
|
||||
sta $100,Y
|
||||
dey
|
||||
bpl -
|
||||
jmp $100
|
||||
@postcheck
|
||||
ldy #$28
|
||||
- lda @checker,Y
|
||||
sta $100,Y
|
||||
dey
|
||||
bpl -
|
||||
bcs @noauxmem
|
||||
@yesauxmem
|
||||
lda #$80
|
||||
+HIDE_NEXT_2_BYTES
|
||||
@noauxmem
|
||||
lda #$40
|
||||
+HIDE_NEXT_2_BYTES
|
||||
@no80col
|
||||
lda #$20
|
||||
+HIDE_NEXT_2_BYTES
|
||||
@noiie
|
||||
lda #$00
|
||||
sta Has128KStatus
|
||||
lda $E000
|
||||
cmp $1A
|
||||
bne @tryRAMbank1
|
||||
lda $D000
|
||||
cmp $1B
|
||||
bne @tryRAMbank1
|
||||
lda $D400
|
||||
cmp $1C
|
||||
bne @tryRAMbank1
|
||||
lda $D800
|
||||
cmp $1D
|
||||
beq @done
|
||||
@tryRAMbank1
|
||||
lda LCBANK1READ
|
||||
lda $E000
|
||||
cmp $1A
|
||||
bne @tryRAMbank2
|
||||
lda $D000
|
||||
cmp $1B
|
||||
bne @tryRAMbank2
|
||||
lda $D400
|
||||
cmp $1C
|
||||
bne @tryRAMbank2
|
||||
lda $D800
|
||||
cmp $1D
|
||||
beq @done
|
||||
@tryRAMbank2
|
||||
lda LCBANK2READ
|
||||
@done
|
||||
plp
|
||||
lda Has128KStatus
|
||||
rts
|
||||
@checker
|
||||
lda #$EE
|
||||
sta WRITEAUXMEM
|
||||
sta READAUXMEM
|
||||
sta $800
|
||||
lda $C00
|
||||
cmp #$EE
|
||||
bne @auxworks
|
||||
asl $C00
|
||||
lda $800
|
||||
cmp $C00
|
||||
bne @auxworks
|
||||
sec
|
||||
+HIDE_NEXT_BYTE
|
||||
@auxworks
|
||||
clc
|
||||
sta WRITEMAINMEM
|
||||
sta READMAINMEM
|
||||
jmp @postcheck
|
287
src/normfast.a
Normal file
287
src/normfast.a
Normal file
@ -0,0 +1,287 @@
|
||||
;;; NORMFAST Disable/enable Apple II compatible accelerator
|
||||
;
|
||||
; Release 6 2017-10-05 Fix Mac IIe card check
|
||||
;
|
||||
; Release 5 2017-09-27 Add Macintosh IIe Card. Addon
|
||||
; accelerators are now set blindly, so will access
|
||||
; annunciators/IIc locations and may trigger the
|
||||
; paddle timer.
|
||||
; No plans for the Saturn Systems Accelerator which would
|
||||
; require a slot search.
|
||||
;
|
||||
; Release 4 2017-09-06 Add Laser 128EX, TransWarp I, UW
|
||||
;
|
||||
; Release 3 2017-08-29 Change FASTChip partially back to
|
||||
; release 1, which seems to work the way release 2 was
|
||||
; intended?!
|
||||
;
|
||||
; Release 2 2017-08-27 change enable entry point, add Zip
|
||||
; Chip, change setting FASTChip speed to disable/enable
|
||||
;
|
||||
; Release 1 2017-08-25 IIGS, //c+ and FASTChip
|
||||
;
|
||||
; WARNING: The memory location to set the accelerator
|
||||
; speed may overlap existing locations such as:
|
||||
; annuciators or Apple //c specific hardware
|
||||
; paddle trigger
|
||||
;
|
||||
; Known to work: IIGS, //c+
|
||||
; Theoretically: FASTChip, Laser 128EX, Mac IIe Card,
|
||||
; TransWarp I, trademarked German product, Zip Chip
|
||||
;
|
||||
; BRUN NORMFAST or CALL 768 to disable the accelerator.
|
||||
; CALL 771 to enable the accelerator.
|
||||
; Enabling an older accelerator may set maximum speed.
|
||||
; Accelerators such as the FASTChip or Zip Chip can run
|
||||
; slower than 1Mhz when enabled.
|
||||
;
|
||||
; NORMFAST is position independent and can be loaded most
|
||||
; anywhere in the first 48K of memory.
|
||||
; The ROMs must be enabled to identify the model of the
|
||||
; computer.
|
||||
;
|
||||
; This was originally for the //c+ which is normally
|
||||
; difficult to set to 1Mhz speed.
|
||||
; The other expected use is to set the speed in a program.
|
||||
;
|
||||
; Written for Andrew Jacobs' Java based dev65 assembler at
|
||||
; http://sourceforge.net/projects/dev65 but has portability
|
||||
; in mind.
|
||||
|
||||
; addresses are lowercase, constant values are in CAPS
|
||||
|
||||
RELEASE = 6 ; our version
|
||||
|
||||
romid = $FBB3
|
||||
; $38=][, $EA=][+, $06=//e compatible
|
||||
ROMID_IIECOMPAT = 6
|
||||
romid_ec = $FBC0
|
||||
; $EA=//e original, $E0=//e enhanced, $E1=//e EDM, $00=//c
|
||||
; Laser 128s are $E0
|
||||
romid_c = $FBBF
|
||||
; $FF=original, $00=Unidisk 3.5 ... $05=//c+
|
||||
ROMID_CPLUS = 5
|
||||
romid_maciie_2 = $FBDD ; 2
|
||||
|
||||
; IIGS
|
||||
idroutine = $FE1F ; SEC, JSR $FE1F, BCS notgs
|
||||
gsspeed = $C036
|
||||
GS_FAST = $80 ; mask
|
||||
|
||||
; //c+ Cache Glue Gate Array (accelerator)
|
||||
cgga = $C7C7 ; entry point
|
||||
CGGA_ENABLE = 1 ; fast
|
||||
CGGA_DISABLE = 2 ; normal
|
||||
CGGA_LOCK = 3
|
||||
CGGA_UNLOCK = 4 ; required to make a change
|
||||
|
||||
; Macintosh IIe Card
|
||||
maciie = $C02B
|
||||
MACIIE_FAST = 4 ; mask
|
||||
|
||||
l128irqpage = $C4
|
||||
; From the 4.2, 4.5 and EX2 ROM dumps at the Apple II
|
||||
; Documentation Project, the Laser 128 IRQ handlers are
|
||||
; in the $C4 page.
|
||||
; A comp.sys.apple2 post says the 6.0 ROM for the 128 and
|
||||
; 128EX are identical, so there may not be an easy way to
|
||||
; tell a plain 128 from an (accelerated) 128EX.
|
||||
irq = $FFFE ; 6502 IRQ vector
|
||||
|
||||
; may overlap with paddle trigger
|
||||
ex_cfg = $C074 ; bits 7 & 6 for speed
|
||||
EX_NOTSPEED = $3F
|
||||
EX_1MHZMASK = $0
|
||||
EX_2MHZMASK = $80 ; 2.3Mhz
|
||||
EX_3MHZMASK = $C0 ; 3.6Mhz
|
||||
|
||||
; FASTChip
|
||||
fc_lock = $C06A
|
||||
FC_UNLOCK = $6A ; write 4 times
|
||||
FC_LOCK = $A6
|
||||
fc_enable = $C06B
|
||||
fc_speed = $C06D
|
||||
FC_1MHZ = 9
|
||||
FC_ON = 40 ; doco says 16.6Mhz
|
||||
|
||||
; TransWarp I
|
||||
; may overlap with paddle trigger
|
||||
tw1_speed = $C074
|
||||
TW1_1MHZ = 1
|
||||
TW1_MAX = 0
|
||||
|
||||
; Trademarked German accelerator
|
||||
; overlaps annunciator 2 & //c mouse interrupts
|
||||
uw_fast = $C05C
|
||||
uw_1mhz = $C05D
|
||||
|
||||
; Zip Chip
|
||||
; overlaps annunciator 1 & //c vertical blank
|
||||
zc_lock = $C05A
|
||||
ZC_UNLOCK = $5A ; write 4 times
|
||||
ZC_LOCK = $A5
|
||||
zc_enable = $C05B
|
||||
|
||||
iobase = $C000 ; easily confused with kbd
|
||||
|
||||
DisableAccelerator
|
||||
; disable accelerator
|
||||
lda #1
|
||||
!byte $2C ; BIT <ABSOLUTE>, hide next lda #
|
||||
EnableAccelerator
|
||||
; enable accelerator
|
||||
lda #0
|
||||
|
||||
ldx #RELEASE ; our release number
|
||||
|
||||
;; first check built-in accelerators
|
||||
|
||||
ldx romid
|
||||
cpx #ROMID_IIECOMPAT
|
||||
bne addon ; not a //e
|
||||
|
||||
ldx romid_ec
|
||||
beq iic ; //c family
|
||||
|
||||
; not worth the bytes for enhanced //e check
|
||||
ldx irq+1
|
||||
cpx #l128irqpage
|
||||
bne gscheck
|
||||
|
||||
; a Laser 128, hopefully harmless on a non EX
|
||||
|
||||
ldy #EX_3MHZMASK ; phew, all needed bits set
|
||||
ldx #<(ex_cfg)
|
||||
|
||||
;; setspeed - set 1Mhz with AND and fast with OR
|
||||
;
|
||||
; A = lsb set for normal speed
|
||||
; X = low byte address of speed location
|
||||
; Y = OR mask for fast
|
||||
|
||||
setspeed
|
||||
lsr
|
||||
tya
|
||||
bcs setnorm
|
||||
ora iobase,x
|
||||
bne setsta ; always
|
||||
|
||||
setnorm
|
||||
eor #$FF
|
||||
and iobase,x
|
||||
setsta
|
||||
sta iobase,x
|
||||
rts
|
||||
|
||||
gscheck
|
||||
pha
|
||||
sec
|
||||
jsr idroutine
|
||||
pla
|
||||
bcs maccheck ; not a gs
|
||||
|
||||
; set IIGS speed
|
||||
|
||||
ldy #GS_FAST
|
||||
ldx #<(gsspeed)
|
||||
bne setspeed ; always
|
||||
|
||||
maccheck
|
||||
ldx romid_maciie_2
|
||||
cpx #2
|
||||
bne addon ; no built-in accelerator
|
||||
|
||||
; the IIe Card in a Mac
|
||||
|
||||
ldy #MACIIE_FAST
|
||||
ldx #<(maciie)
|
||||
bne setspeed ; always
|
||||
|
||||
iic
|
||||
ldx romid_c
|
||||
cpx #ROMID_CPLUS
|
||||
bne addon ; not a //c+, eventually hit Zip
|
||||
|
||||
; Set //c+ speed. Uses the horrible firmware in case other
|
||||
; code works "by the book", that is can check and set
|
||||
; whether the accelerator is enabled.
|
||||
; The //c+ is otherwise Zip compatible.
|
||||
|
||||
!cpu 65C02 ; only used for //c+
|
||||
inc ; 65C02 $1A
|
||||
!cpu 6502
|
||||
|
||||
; cgga calls save X and Y regs but sets $0 to 0
|
||||
; (this will get a laugh from C programmers)
|
||||
ldx $0
|
||||
php
|
||||
sei ; timing sensitive
|
||||
pha ; action after CGGA_UNLOCK
|
||||
|
||||
lda #CGGA_UNLOCK ; unlock to change
|
||||
pha
|
||||
jsr cgga
|
||||
|
||||
jsr cgga ; disable/enable
|
||||
|
||||
lda #CGGA_LOCK ; should lock after a change
|
||||
pha
|
||||
jsr cgga
|
||||
|
||||
plp ; restore interrupt state
|
||||
stx $0
|
||||
rts
|
||||
|
||||
;; At this point, the computer does not have a built-in
|
||||
;; accelerator
|
||||
;
|
||||
; Previous versions had tested fc_enable, which was not
|
||||
; enough. Running low on space so just set blindly.
|
||||
|
||||
addon
|
||||
; TransWarp I
|
||||
|
||||
sta tw1_speed
|
||||
|
||||
; Zip Chip
|
||||
|
||||
tay
|
||||
eor #1
|
||||
tax
|
||||
lda #ZC_UNLOCK
|
||||
php
|
||||
sei ; timing sensitive
|
||||
sta zc_lock
|
||||
sta zc_lock
|
||||
sta zc_lock
|
||||
sta zc_lock
|
||||
lsr ; not ZC_LOCK or ZC_UNLOCK
|
||||
sta zc_lock,x ; disable/enable
|
||||
lda #ZC_LOCK
|
||||
sta zc_lock
|
||||
|
||||
;; current products are subject to change so do
|
||||
;; these last
|
||||
|
||||
; trademarked accelerator from Germany
|
||||
|
||||
sta uw_fast,y ; value does not matter
|
||||
|
||||
; FASTChip
|
||||
|
||||
ldx #FC_1MHZ
|
||||
tya
|
||||
bne fcset
|
||||
ldx #FC_ON ; enable set speed?
|
||||
fcset
|
||||
lda #FC_UNLOCK
|
||||
sta fc_lock
|
||||
sta fc_lock
|
||||
sta fc_lock
|
||||
sta fc_lock
|
||||
sta fc_enable
|
||||
stx fc_speed
|
||||
lda #FC_LOCK
|
||||
sta fc_lock
|
||||
plp ; restore interrupt state
|
||||
rts
|
Loading…
x
Reference in New Issue
Block a user