mirror of
https://github.com/a2stuff/vnIIc.git
synced 2024-06-26 00:29:28 +00:00
pull more out of core client src
This commit is contained in:
parent
f92ef31fe4
commit
efeff6cdb9
Binary file not shown.
1176
client/client.list
1176
client/client.list
File diff suppressed because it is too large
Load Diff
217
client/client.s
217
client/client.s
|
@ -1,75 +1,31 @@
|
||||||
PADDLE_SUPPORT = 1
|
PADDLE_SUPPORT = 1
|
||||||
;;; MOUSE_SUPPORT = 1
|
;;; MOUSE_SUPPORT = 1
|
||||||
|
|
||||||
;;;---------------------------------------------------------
|
.include "apple2.inc"
|
||||||
;;; Super Serial constants/locations
|
|
||||||
;;;---------------------------------------------------------
|
|
||||||
|
|
||||||
;;; These get incremented by the slot where they appear
|
|
||||||
UACTRL = $C08B ; Control Register
|
|
||||||
UACMND = $C08A ; Command Register
|
|
||||||
UASTAT = $C089 ; Status Register
|
|
||||||
UADATA = $C088 ; Data Register - incoming and outgoing data
|
|
||||||
|
|
||||||
|
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
;;; Hi-res graphics constants/locations
|
;;; Hi-res graphics constants/locations
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
|
|
||||||
PLOTPAGE = $E6 ; Active hires plotting page (Applesoft)
|
PLOTPAGE := $E6 ; Active hires plotting page (Applesoft)
|
||||||
PLOTPAGE1 = $20
|
PLOTPAGE1 := $20
|
||||||
PLOTPAGE2 = $40
|
PLOTPAGE2 := $40
|
||||||
PAGESIZE = $20 ; Size of hi-res screen in pages
|
PAGESIZE := $20 ; Size of hi-res screen in pages
|
||||||
|
|
||||||
|
|
||||||
CLRTEXT = $C050 ;display graphics
|
|
||||||
SETTEXT = $C051 ;display text
|
|
||||||
CLRMIXED = $C052 ;clear mixed mode- enable full graphics
|
|
||||||
SETMIXED = $C053 ;enable graphics/text mixed mode
|
|
||||||
PAGE1 = $C054 ;select text/graphics page1
|
|
||||||
PAGE2 = $C055 ;select text/graphics page2
|
|
||||||
CLRHIRES = $C056 ;select Lo-res
|
|
||||||
SETHIRES = $C057 ;select Hi-res
|
|
||||||
|
|
||||||
|
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
;;; Keyboard input constants/locations
|
;;; ROM routines
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
|
|
||||||
KEYBD = $C000 ; key down in bit 7; key code in lower bits
|
PREAD := $FB1E ; Monitor paddle reading routine, call
|
||||||
STROBE = $C010 ; write to clear key down state
|
; with paddle # in X, returns value in Y
|
||||||
OPNAPPLE = $C061 ; open apple (command) key data (read)
|
|
||||||
CLSAPPLE = $C062 ; closed apple (option) key data (read)
|
|
||||||
PB2 = $C063 ; Paddle button 2 (read)
|
|
||||||
PB3 = $C060 ; Paddle button 3 (read)
|
|
||||||
|
|
||||||
|
|
||||||
;;;---------------------------------------------------------
|
|
||||||
;;; Paddle/Joystick constants/locations/routines
|
|
||||||
;;;---------------------------------------------------------
|
|
||||||
|
|
||||||
PADDLE0 = $C064 ; bit 7 = status of pdl-0 timer (read)
|
|
||||||
PADDLE1 = $C065 ; bit 7 = status of pdl-1 timer (read)
|
|
||||||
PADDLE2 = $C066 ; bit 7 = status of pdl-2 timer (read)
|
|
||||||
PADDLE3 = $C067 ; bit 7 = status of pdl-3 timer (read)
|
|
||||||
PDLTRIG = $C070 ; trigger paddles
|
|
||||||
|
|
||||||
PREAD = $FB1E ; Monitor paddle reading routine, call
|
|
||||||
; with paddle # in X, returns value in Y
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
;;; Other
|
;;; Other
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
|
|
||||||
SLOT_CASE = $c000 ; Firmware for slots are at $cx00
|
MAX_SLOT := 7 ; Maximum slot # on an Apple II
|
||||||
MAX_SLOT = 7 ; Maximum slot # on an Apple II
|
|
||||||
|
|
||||||
ZP = $FA ; Write cursor location on zero page
|
|
||||||
ESCAPE = $80 ; Unused image data byte (all black2)
|
|
||||||
ESCAPE2 = $FF ; Unused image data byte (all white2)
|
|
||||||
|
|
||||||
|
ZP_PTR := $FA ; Write cursor location on zero page
|
||||||
|
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
;;; Generic Macros
|
;;; Generic Macros
|
||||||
|
@ -97,9 +53,9 @@ ESCAPE2 = $FF ; Unused image data byte (all white2)
|
||||||
|
|
||||||
|
|
||||||
;;;-------------------------------------------------------------------
|
;;;-------------------------------------------------------------------
|
||||||
;
|
;;;
|
||||||
;;; Application-level logic
|
;;; Application-level logic
|
||||||
;
|
;;;
|
||||||
;;;-------------------------------------------------------------------
|
;;;-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,6 +69,29 @@ ESCAPE2 = $FF ; Unused image data byte (all white2)
|
||||||
.endif ; MOUSE_SUPPORT
|
.endif ; MOUSE_SUPPORT
|
||||||
|
|
||||||
|
|
||||||
|
;;;-------------------------------------------------------------------
|
||||||
|
;;; Variables
|
||||||
|
;;;-------------------------------------------------------------------
|
||||||
|
|
||||||
|
;;; Application configuration
|
||||||
|
PSPEED: .byte SSC::BPS_115k ; Hardcoded for Apple IIc (TODO: Allow configuration)
|
||||||
|
PSLOT: .byte 2 ; Hardcoded for Apple IIc (TODO: Allow configuration)
|
||||||
|
PEXIT: .byte 0 ; Set when it's time to exit (Not Yet Implemented)
|
||||||
|
|
||||||
|
;;; Keyboard state
|
||||||
|
LASTKB: .byte 0
|
||||||
|
LASTOA: .byte 0
|
||||||
|
LASTCA: .byte 0
|
||||||
|
|
||||||
|
.ifdef PADDLE_SUPPORT
|
||||||
|
|
||||||
|
;;; Paddle state
|
||||||
|
LASTP0: .byte 0
|
||||||
|
LASTP1: .byte 0
|
||||||
|
|
||||||
|
.endif ; PADDLE_SUPPORT
|
||||||
|
|
||||||
|
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
.proc AppEntry
|
.proc AppEntry
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
|
@ -133,16 +112,16 @@ ESCAPE2 = $FF ; Unused image data byte (all white2)
|
||||||
;;; Clean up and exit app
|
;;; Clean up and exit app
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
jsr SSC::Reset
|
jsr SSC::Reset
|
||||||
sta PAGE1
|
sta LOWSCR
|
||||||
sta SETTEXT
|
sta TXTSET
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
;;;-------------------------------------------------------------------
|
;;;-------------------------------------------------------------------
|
||||||
;
|
;;;
|
||||||
;;; Main loop functionality
|
;;; Main loop functionality
|
||||||
;
|
;;;
|
||||||
;;;-------------------------------------------------------------------
|
;;;-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,27 +145,27 @@ ESCAPE2 = $FF ; Unused image data byte (all white2)
|
||||||
.proc ReceivePage
|
.proc ReceivePage
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
;;; Pull a hi-res page down over serial
|
;;; Pull a hi-res page down over serial
|
||||||
;
|
;;;
|
||||||
;;; Protocol is:
|
;;; Protocol is:
|
||||||
;;; * Recieve 256 bytes (graphic data)
|
;;; * Recieve 256 bytes (graphic data)
|
||||||
;;; * Send 1 byte (input state)
|
;;; * Send 1 byte (input state)
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
|
|
||||||
lda #0 ; set up write pointer
|
lda #0 ; set up write pointer
|
||||||
sta ZP
|
sta ZP_PTR
|
||||||
lda PLOTPAGE
|
lda PLOTPAGE
|
||||||
sta ZP+1
|
sta ZP_PTR+1
|
||||||
ldx #PAGESIZE ; plan to receive this many pages
|
ldx #PAGESIZE ; plan to receive this many pages
|
||||||
ldy #0
|
ldy #0
|
||||||
|
|
||||||
: jsr SSC::Get ; TODO: look for escape codes in the sequence
|
: jsr SSC::Get ; TODO: look for escape codes in the sequence
|
||||||
sta (ZP),Y
|
sta (ZP_PTR),Y
|
||||||
iny
|
iny
|
||||||
bne :- ; Do a full page...
|
bne :- ; Do a full page...
|
||||||
|
|
||||||
jsr SendInputState ; brief moment to send data back upstream
|
jsr SendInputState ; brief moment to send data back upstream
|
||||||
|
|
||||||
inc ZP+1
|
inc ZP_PTR+1
|
||||||
dex
|
dex
|
||||||
bne :- ; ...as many pages as we need
|
bne :- ; ...as many pages as we need
|
||||||
rts
|
rts
|
||||||
|
@ -194,29 +173,29 @@ ESCAPE2 = $FF ; Unused image data byte (all white2)
|
||||||
|
|
||||||
|
|
||||||
;;;-------------------------------------------------------------------
|
;;;-------------------------------------------------------------------
|
||||||
;
|
;;;
|
||||||
;;; Input device routines
|
;;; Input device routines
|
||||||
;
|
;;;
|
||||||
;;;-------------------------------------------------------------------
|
;;;-------------------------------------------------------------------
|
||||||
;;; Protocol:
|
;;; Protocol:
|
||||||
;;; $7f - $ff - key down, ASCII code + $80
|
;;; $7f - $ff - key down, ASCII code + $80
|
||||||
;;; otherwise, a transition:
|
;;; otherwise, a transition:
|
||||||
;
|
;;;
|
||||||
SIS_KBUP = $00 ; Key up
|
SIS_KBUP = $00 ; Key up
|
||||||
SIS_OADOWN = $01 ; Open Apple transitioned to down
|
SIS_OADOWN = $01 ; Open Apple transitioned to down
|
||||||
SIS_OAUP = $02 ; Open Apple transitioned to up
|
SIS_OAUP = $02 ; Open Apple transitioned to up
|
||||||
SIS_CADOWN = $03 ; Closed Apple transitioned to down
|
SIS_CADOWN = $03 ; Closed Apple transitioned to down
|
||||||
SIS_CAUP = $04 ; Closed Apple transitioned to up
|
SIS_CAUP = $04 ; Closed Apple transitioned to up
|
||||||
;
|
;;;
|
||||||
;;; $05 - $0f : reserved
|
;;; $05 - $0f : reserved
|
||||||
;
|
;;;
|
||||||
SIS_MX = $10 ; Mouse X high nibble
|
SIS_MX = $10 ; Mouse X high nibble
|
||||||
SIS_MY = $20 ; Mouse Y high nibble
|
SIS_MY = $20 ; Mouse Y high nibble
|
||||||
SIS_PDL0 = $30 ; Paddle 0 high nibble
|
SIS_PDL0 = $30 ; Paddle 0 high nibble
|
||||||
SIS_PDL1 = $40 ; Paddle 1 high nibble
|
SIS_PDL1 = $40 ; Paddle 1 high nibble
|
||||||
;
|
;;;
|
||||||
;;; $50 - $7e : reserved
|
;;; $50 - $7e : reserved
|
||||||
;
|
;;;
|
||||||
SIS_SYNC = $7f
|
SIS_SYNC = $7f
|
||||||
|
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
|
@ -259,7 +238,7 @@ ESCAPE2 = $FF ; Unused image data byte (all white2)
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
;;; Send keyboard joystick and/or mouse state over the
|
;;; Send keyboard joystick and/or mouse state over the
|
||||||
;;; serial port
|
;;; serial port
|
||||||
;
|
;;;
|
||||||
;;; Algorithm:
|
;;; Algorithm:
|
||||||
;;; - Send key state (if it changed)
|
;;; - Send key state (if it changed)
|
||||||
;;; - otherwise send open-apple state (if it changed)
|
;;; - otherwise send open-apple state (if it changed)
|
||||||
|
@ -275,22 +254,22 @@ ESCAPE2 = $FF ; Unused image data byte (all white2)
|
||||||
;;;--------------------------------------
|
;;;--------------------------------------
|
||||||
;;; Send key state, if it changed
|
;;; Send key state, if it changed
|
||||||
|
|
||||||
;;; NOTE: Can't use STROBE to detect key up -> key down transition
|
;;; NOTE: Can't use KBDSTRB to detect key up -> key down transition
|
||||||
;;; since the msb can change before the key code. Instead, consider
|
;;; since the msb can change before the key code. Instead, consider
|
||||||
;;; these cases:
|
;;; these cases:
|
||||||
;
|
;;;
|
||||||
;;; OLD STATE KEYBD STROBE RESULT
|
;;; OLD STATE KBD KBDSTRB RESULT
|
||||||
;;; Up Up - No-op
|
;;; Up Up - No-op
|
||||||
;;; Up Down - Save and send key down
|
;;; Up Down - Save and send key down
|
||||||
;;; Down - Up Save and send key up
|
;;; Down - Up Save and send key up
|
||||||
;;; Down - Down Save and send key ONLY if different
|
;;; Down - Down Save and send key ONLY if different
|
||||||
;
|
;;;
|
||||||
|
|
||||||
lda LASTKB
|
lda LASTKB
|
||||||
bne KEY_WAS_DOWN
|
bne KEY_WAS_DOWN
|
||||||
|
|
||||||
KEY_WAS_UP:
|
KEY_WAS_UP:
|
||||||
lda KEYBD ; Read keyboard
|
lda KBD ; Read keyboard
|
||||||
bpl END_KEY ; - still up
|
bpl END_KEY ; - still up
|
||||||
sta LASTKB ; Down, so save it
|
sta LASTKB ; Down, so save it
|
||||||
jsr SSC::Put ; and send it
|
jsr SSC::Put ; and send it
|
||||||
|
@ -299,14 +278,14 @@ KEY_WAS_UP:
|
||||||
KEY_WAS_DOWN:
|
KEY_WAS_DOWN:
|
||||||
; key was down - strobe should match
|
; key was down - strobe should match
|
||||||
; unless the key changed or was released
|
; unless the key changed or was released
|
||||||
lda STROBE
|
lda KBDSTRB
|
||||||
bmi STROBE_DOWN
|
bmi KBDSTRB_DOWN
|
||||||
STROBE_UP:
|
KBDSTRB_UP:
|
||||||
lda #SIS_KBUP ; Key was released
|
lda #SIS_KBUP ; Key was released
|
||||||
sta LASTKB ; so save it
|
sta LASTKB ; so save it
|
||||||
jsr SSC::Put ; and send it
|
jsr SSC::Put ; and send it
|
||||||
jmp DONE
|
jmp DONE
|
||||||
STROBE_DOWN:
|
KBDSTRB_DOWN:
|
||||||
cmp LASTKB ; Same key as last time?
|
cmp LASTKB ; Same key as last time?
|
||||||
beq END_KEY ; - no change
|
beq END_KEY ; - no change
|
||||||
sta LASTKB ; New key, so save it
|
sta LASTKB ; New key, so save it
|
||||||
|
@ -319,10 +298,10 @@ END_KEY:
|
||||||
;;; Send Open Apple state, if it changed
|
;;; Send Open Apple state, if it changed
|
||||||
|
|
||||||
;;; TODO: Can simplify this code if we make the high bits the same
|
;;; TODO: Can simplify this code if we make the high bits the same
|
||||||
;;; for both OA states and bit = 0 down: lda OPNAPPLE ; ROL ; LDA #0 ; ROL ; ORA #signature
|
;;; for both OA states and bit = 0 down: lda BUTN0 ; ROL ; LDA #0 ; ROL ; ORA #signature
|
||||||
|
|
||||||
TEST_OA:
|
TEST_OA:
|
||||||
lda OPNAPPLE ; Test Open Apple state
|
lda BUTN0 ; Test Open Apple state
|
||||||
bmi OA_IS_DOWN
|
bmi OA_IS_DOWN
|
||||||
OA_IS_UP:
|
OA_IS_UP:
|
||||||
lda #SIS_OAUP
|
lda #SIS_OAUP
|
||||||
|
@ -345,7 +324,7 @@ END_OA:
|
||||||
;;; Send Closed Apple state, if it changed
|
;;; Send Closed Apple state, if it changed
|
||||||
|
|
||||||
TEST_CA:
|
TEST_CA:
|
||||||
lda CLSAPPLE ; Has the Open Apple/Button 1 value changed?
|
lda BUTN1 ; Has the Open Apple/Button 1 value changed?
|
||||||
bmi CA_IS_DOWN
|
bmi CA_IS_DOWN
|
||||||
CA_IS_UP:
|
CA_IS_UP:
|
||||||
lda #SIS_CAUP
|
lda #SIS_CAUP
|
||||||
|
@ -430,9 +409,9 @@ DONE:
|
||||||
|
|
||||||
|
|
||||||
;;;-------------------------------------------------------------------
|
;;;-------------------------------------------------------------------
|
||||||
;
|
;;;
|
||||||
;;; Hi-res graphics routines
|
;;; Hi-res graphics routines
|
||||||
;
|
;;;
|
||||||
;;;-------------------------------------------------------------------
|
;;;-------------------------------------------------------------------
|
||||||
|
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
|
@ -445,10 +424,10 @@ DONE:
|
||||||
jsr ClearHires
|
jsr ClearHires
|
||||||
|
|
||||||
jsr FlipHires ; then show it and flip to 2
|
jsr FlipHires ; then show it and flip to 2
|
||||||
sta SETHIRES
|
sta HIRES
|
||||||
sta CLRTEXT
|
sta TXTCLR
|
||||||
sta CLRMIXED
|
sta MIXCLR
|
||||||
sta PAGE1
|
sta LOWSCR
|
||||||
|
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
@ -465,12 +444,12 @@ DONE:
|
||||||
cmp #PLOTPAGE1
|
cmp #PLOTPAGE1
|
||||||
beq :+
|
beq :+
|
||||||
|
|
||||||
sta PAGE2 ; page 2 - so show it
|
sta HISCR ; page 2 - so show it
|
||||||
lda #PLOTPAGE1 ; and plot on page 1
|
lda #PLOTPAGE1 ; and plot on page 1
|
||||||
sta PLOTPAGE
|
sta PLOTPAGE
|
||||||
rts
|
rts
|
||||||
|
|
||||||
: sta PAGE1 ; page 1 - so show it
|
: sta LOWSCR ; page 1 - so show it
|
||||||
lda #PLOTPAGE2 ; and plot on page 2
|
lda #PLOTPAGE2 ; and plot on page 2
|
||||||
sta PLOTPAGE
|
sta PLOTPAGE
|
||||||
rts
|
rts
|
||||||
|
@ -481,60 +460,20 @@ DONE:
|
||||||
.proc ClearHires
|
.proc ClearHires
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
;;; Clear hires plotting page (selected in PLOTPAGE) to
|
;;; Clear hires plotting page (selected in PLOTPAGE) to
|
||||||
;;; black uses ZP; not terribly efficient
|
;;; black uses ZP_PTR; not terribly efficient
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
lda #0 ; Set up ZP as a pointer into the hires page
|
lda #0 ; Set up ZP_PTR as a pointer into the hires page
|
||||||
sta ZP
|
sta ZP_PTR
|
||||||
lda PLOTPAGE
|
lda PLOTPAGE
|
||||||
sta ZP+1
|
sta ZP_PTR+1
|
||||||
ldx #PAGESIZE ; Clear this many pages
|
ldx #PAGESIZE ; Clear this many pages
|
||||||
lda #0 ; with black!
|
lda #0 ; with black!
|
||||||
tay
|
tay
|
||||||
: sta (ZP),Y
|
: sta (ZP_PTR),Y
|
||||||
iny
|
iny
|
||||||
bne :-
|
bne :-
|
||||||
inc ZP+1
|
inc ZP_PTR+1
|
||||||
dex
|
dex
|
||||||
bne :-
|
bne :-
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;;-------------------------------------------------------------------
|
|
||||||
;
|
|
||||||
;;; Lookup Tables and Variable Storage
|
|
||||||
;
|
|
||||||
;;;-------------------------------------------------------------------
|
|
||||||
|
|
||||||
;;; Lookup table for UACTRL register, by baud rate
|
|
||||||
|
|
||||||
BPSCTRL: .byte $16,$1E,$1F,$10 ; 300, 9600, 19200, 115k (with 8 data bits, 1 stop bit, no echo)
|
|
||||||
.enum
|
|
||||||
BPS_300
|
|
||||||
BPS_9600
|
|
||||||
BPS_19200
|
|
||||||
BPS_115k
|
|
||||||
.endenum
|
|
||||||
CMND_NRDI = $0B ; Command: no parity, RTS on, DTR on, no interrupts
|
|
||||||
|
|
||||||
|
|
||||||
;;; Application configuration
|
|
||||||
PSPEED: .byte BPS_115k ; Hardcoded for Apple IIc (TODO: Allow configuration)
|
|
||||||
PSLOT: .byte 2 ; Hardcoded for Apple IIc (TODO: Allow configuration)
|
|
||||||
PEXIT: .byte 0 ; Set when it's time to exit (Not Yet Implemented)
|
|
||||||
|
|
||||||
|
|
||||||
;;; Keyboard state
|
|
||||||
LASTKB: .byte 0
|
|
||||||
LASTOA: .byte 0
|
|
||||||
LASTCA: .byte 0
|
|
||||||
|
|
||||||
.ifdef PADDLE_SUPPORT
|
|
||||||
|
|
||||||
;;; Paddle state
|
|
||||||
LASTP0: .byte 0
|
|
||||||
LASTP1: .byte 0
|
|
||||||
|
|
||||||
.endif ; PADDLE_SUPPORT
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
;;; Mouse
|
;;; Mouse
|
||||||
;;;
|
;;;
|
||||||
;;;-------------------------------------------------------------------
|
;;;-------------------------------------------------------------------
|
||||||
|
|
||||||
.error "Mouse support not fully implemented"
|
.error "Mouse support not fully implemented"
|
||||||
|
|
||||||
.proc Mouse
|
.proc Mouse
|
||||||
|
@ -14,30 +13,32 @@
|
||||||
|
|
||||||
;;; For READMOUSE and POSMOUSE
|
;;; For READMOUSE and POSMOUSE
|
||||||
|
|
||||||
MOUSE_X_LSB = $0478 ; + slot Low byte of absolute X position
|
MOUSE_X_LSB := $0478 ; + slot Low byte of absolute X position
|
||||||
MOUSE_X_MSB = $0578 ; + slot High byte of absolute X position
|
MOUSE_X_MSB := $0578 ; + slot High byte of absolute X position
|
||||||
MOUSE_Y_LSB = $04F8 ; + slot Low byte of absolute Y position
|
MOUSE_Y_LSB := $04F8 ; + slot Low byte of absolute Y position
|
||||||
MOUSE_Y_MSB = $05F8 ; + slot High byte of absolute Y position
|
MOUSE_Y_MSB := $05F8 ; + slot High byte of absolute Y position
|
||||||
MOUSE_RSV1 = $0678 ; + slot Reserved and used by the firmware
|
MOUSE_RSV1 := $0678 ; + slot Reserved and used by the firmware
|
||||||
MOUSE_RSV2 = $06F8 ; + slot Reserved and used by the firmware
|
MOUSE_RSV2 := $06F8 ; + slot Reserved and used by the firmware
|
||||||
MOUSE_BTN = $0778 ; + slot Button 0/1 interrupt status byte
|
MOUSE_BTN := $0778 ; + slot Button 0/1 interrupt status byte
|
||||||
MOUSE_MODE = $07F8 ; + slot Mode byte
|
MOUSE_MODE := $07F8 ; + slot Mode byte
|
||||||
|
|
||||||
;;; For CLAMPMOUSE:
|
;;; For CLAMPMOUSE:
|
||||||
|
|
||||||
MOUSE_CMIN_LSB = $0478 ; low byte of low clamp
|
MOUSE_CMIN_LSB := $0478 ; low byte of low clamp
|
||||||
MOUSE_CMIN_MSB = $0578 ; high byte of low clamp
|
MOUSE_CMIN_MSB := $0578 ; high byte of low clamp
|
||||||
MOUSE_CMAX_LSB = $04F8 ; low byte of high clamp
|
MOUSE_CMAX_LSB := $04F8 ; low byte of high clamp
|
||||||
MOUSE_CMAX_MSB = $05F8 ; high byte of high clamp
|
MOUSE_CMAX_MSB := $05F8 ; high byte of high clamp
|
||||||
|
|
||||||
MOUSE_CLAMP_X = 0 ; Value for A when setting X clamp with CLAMPMOUSE
|
MOUSE_CLAMP_X := 0 ; Value for A when setting X clamp with CLAMPMOUSE
|
||||||
MOUSE_CLAMP_Y = 1 ; Value for A when setting X clamp with CLAMPMOUSE
|
MOUSE_CLAMP_Y := 1 ; Value for A when setting X clamp with CLAMPMOUSE
|
||||||
|
|
||||||
;;; Mouse ID bytes
|
;;; Mouse ID bytes
|
||||||
MOUSEID_MAX = 4
|
MOUSEID_MAX := 4
|
||||||
MOUSEID_ADDR: .byte $05, $07, $0b, $0c, $fb
|
MOUSEID_ADDR: .byte $05, $07, $0b, $0c, $fb
|
||||||
MOUSEID_VAL: .byte $38, $18, $01, $20, $d6
|
MOUSEID_VAL: .byte $38, $18, $01, $20, $d6
|
||||||
|
|
||||||
|
SLOT_BASE := $C000
|
||||||
|
|
||||||
;;;--------------------------------------------------
|
;;;--------------------------------------------------
|
||||||
;;; Data
|
;;; Data
|
||||||
;;;--------------------------------------------------
|
;;;--------------------------------------------------
|
||||||
|
@ -54,12 +55,12 @@ LAST_MY: .byte $7f
|
||||||
|
|
||||||
MOUSEPTR = $EB ; Zero page location
|
MOUSEPTR = $EB ; Zero page location
|
||||||
|
|
||||||
MOUSE_MIN_X = $10
|
MOUSE_MIN_X := $10
|
||||||
MOUSE_MAX_X = $1f
|
MOUSE_MAX_X := $1f
|
||||||
MOUSE_CENTER_X = $17
|
MOUSE_CENTER_X := $17
|
||||||
MOUSE_MIN_Y = $20
|
MOUSE_MIN_Y := $20
|
||||||
MOUSE_MAX_Y = $2f
|
MOUSE_MAX_Y := $2f
|
||||||
MOUSE_CENTER_Y = $2f
|
MOUSE_CENTER_Y := $2f
|
||||||
|
|
||||||
|
|
||||||
;;;--------------------------------------------------
|
;;;--------------------------------------------------
|
||||||
|
@ -122,14 +123,14 @@ TESTSLOT:
|
||||||
tya
|
tya
|
||||||
clc
|
clc
|
||||||
adc #>SLOT_BASE ; Firmware is $c0 + slot
|
adc #>SLOT_BASE ; Firmware is $c0 + slot
|
||||||
sta MOD_MOUSE_ID + 2 ; Update msb of signature test
|
sta slot_addr + 1 ; Update msb of signature test
|
||||||
ldx #MOUSEID_MAX ; This many signature bytes
|
ldx #MOUSEID_MAX ; This many signature bytes
|
||||||
|
|
||||||
TESTID:
|
TESTID:
|
||||||
lda MOUSEID_ADDR,x
|
lda MOUSEID_ADDR,x
|
||||||
sta MOD_MOUSE_ID + 1 ; Update lsb of signature test
|
sta MOD_MOUSE_ID + 1 ; Update lsb of signature test
|
||||||
MOD_MOUSE_ID:
|
slot_addr := *+1
|
||||||
lda SLOT_BASE
|
lda SLOT_BASE ; Self-modified
|
||||||
cmp MOUSEID_VAL,x ; Does it match the signature?
|
cmp MOUSEID_VAL,x ; Does it match the signature?
|
||||||
bne NOMATCH ; Nope - try the next slot
|
bne NOMATCH ; Nope - try the next slot
|
||||||
dex ; Yes! Keep testing
|
dex ; Yes! Keep testing
|
||||||
|
@ -215,28 +216,30 @@ INITMOUSE: ldy #$19
|
||||||
lda (MOUSEPTR),Y ; Get the routine entry point
|
lda (MOUSEPTR),Y ; Get the routine entry point
|
||||||
sta TOMOUSE_lsb ; Patch the JMP instruction
|
sta TOMOUSE_lsb ; Patch the JMP instruction
|
||||||
txa ; Restore the value in A
|
txa ; Restore the value in A
|
||||||
.endproc
|
|
||||||
; fall through
|
|
||||||
|
|
||||||
;;; The following operand bytes must be patched by the
|
;;; The following operand bytes must be patched by the
|
||||||
;;; initialization code which detects the mouse.
|
;;; initialization code which detects the mouse.
|
||||||
|
|
||||||
BANK = $C054
|
BANK := $C054
|
||||||
|
|
||||||
TOMOUSE:
|
TOMOUSE:
|
||||||
|
TOMOUSE_Cn := *+1
|
||||||
ldx #$C1 ; Set up slot in $Cn form in X
|
ldx #$C1 ; Set up slot in $Cn form in X
|
||||||
|
TOMOUSE_n0 := *+1
|
||||||
ldy #$10 ; Set up slot in $n0 form in Y
|
ldy #$10 ; Set up slot in $n0 form in Y
|
||||||
php ; Save interrupt state
|
php ; Save interrupt state
|
||||||
sei ; No interrupts while calling
|
sei ; No interrupts while calling
|
||||||
bit BANK
|
bit BANK
|
||||||
jsr SLOT_BASE ; Go to the mouse routine
|
TOMOUSE_slot := *+1
|
||||||
|
jsr 0 ; Go to the mouse routine
|
||||||
plp ; Restore interrupt state
|
plp ; Restore interrupt state
|
||||||
rts
|
rts
|
||||||
|
.endproc
|
||||||
|
|
||||||
TOMOUSE_Cn = TOMOUSE + 1
|
TOMOUSE_Cn := GoMouse::TOMOUSE_Cn
|
||||||
TOMOUSE_n0 = TOMOUSE + 3
|
TOMOUSE_n0 := GoMouse::TOMOUSE_n0
|
||||||
TOMOUSE_lsb = TOMOUSE + 10
|
TOMOUSE_lsb := GoMouse::TOMOUSE_slot
|
||||||
TOMOUSE_msb = TOMOUSE + 11
|
TOMOUSE_msb := GoMouse::TOMOUSE_slot+1
|
||||||
|
|
||||||
|
|
||||||
;;; TODO: Turn this into a proper delta-sending routine
|
;;; TODO: Turn this into a proper delta-sending routine
|
||||||
|
@ -290,4 +293,4 @@ DONE:
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|
|
@ -8,6 +8,29 @@
|
||||||
|
|
||||||
.proc SSC
|
.proc SSC
|
||||||
|
|
||||||
|
;;;---------------------------------------------------------
|
||||||
|
;;; Super Serial constants/locations
|
||||||
|
;;;---------------------------------------------------------
|
||||||
|
|
||||||
|
;;; These get incremented by the slot where they appear
|
||||||
|
UACTRL = $C08B ; Control Register
|
||||||
|
UACMND = $C08A ; Command Register
|
||||||
|
UASTAT = $C089 ; Status Register
|
||||||
|
UADATA = $C088 ; Data Register - incoming and outgoing data
|
||||||
|
|
||||||
|
;;; Lookup table for UACTRL register, by baud rate
|
||||||
|
|
||||||
|
BPSCTRL: .byte $16,$1E,$1F,$10 ; 300, 9600, 19200, 115k (with 8 data bits, 1 stop bit, no echo)
|
||||||
|
.enum
|
||||||
|
BPS_300
|
||||||
|
BPS_9600
|
||||||
|
BPS_19200
|
||||||
|
BPS_115k
|
||||||
|
.endenum
|
||||||
|
|
||||||
|
CMND_NRDI = $0B ; Command: no parity, RTS on, DTR on, no interrupts
|
||||||
|
|
||||||
|
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
.proc Init
|
.proc Init
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
|
@ -24,15 +47,14 @@
|
||||||
ldy PSPEED ; Control register: look up by baud rate (8 data bits, 1 stop bit)
|
ldy PSPEED ; Control register: look up by baud rate (8 data bits, 1 stop bit)
|
||||||
lda BPSCTRL,Y
|
lda BPSCTRL,Y
|
||||||
sta $C003,X
|
sta $C003,X
|
||||||
stx MOD_UADATA_1+1 ; Modify references to
|
stx MOD_UADATA_1 ; Modify references to
|
||||||
stx MOD_UADATA_2+1 ; UADATA to point at
|
stx MOD_UADATA_2 ; UADATA to point at
|
||||||
stx MOD_UADATA_3+1 ; correct slot (UADATA+S0)
|
stx MOD_UADATA_3 ; correct slot (UADATA+S0)
|
||||||
inx
|
inx
|
||||||
stx MOD_UASTAT_1+1 ; Modify reference to
|
stx MOD_UASTAT_1 ; Modify reference to
|
||||||
stx MOD_UASTAT_2+1 ; UASTAT to point at
|
stx MOD_UASTAT_2 ; UASTAT to point at
|
||||||
stx MOD_UASTAT_3+1 ; correct slot (UASTAT+S0)
|
stx MOD_UASTAT_3 ; correct slot (UASTAT+S0)
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,13 +64,13 @@
|
||||||
;;; Send accumulator out the serial port
|
;;; Send accumulator out the serial port
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
pha ; Push A onto the stack
|
pha ; Push A onto the stack
|
||||||
MOD_UASTAT_1:
|
MOD_UASTAT_1 := *+1
|
||||||
: lda UASTAT ; Check status bits
|
: lda UASTAT ; Check status bits
|
||||||
and #$70
|
and #$70
|
||||||
cmp #$10
|
cmp #$10
|
||||||
bne :- ; Output register is full, so loop
|
bne :- ; Output register is full, so loop
|
||||||
pla
|
pla
|
||||||
MOD_UADATA_1:
|
MOD_UADATA_1 := *+1
|
||||||
sta UADATA ; Put character
|
sta UADATA ; Put character
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
@ -60,12 +82,12 @@ MOD_UADATA_1:
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
;;; Read a character from the serial port to the accumulator
|
;;; Read a character from the serial port to the accumulator
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
MOD_UASTAT_2:
|
MOD_UASTAT_2 := *+1
|
||||||
lda UASTAT ; Check status bits
|
lda UASTAT ; Check status bits
|
||||||
and #$68
|
and #$68
|
||||||
cmp #$8
|
cmp #$8
|
||||||
bne Get ; Input register empty, loop
|
bne Get ; Input register empty, loop
|
||||||
MOD_UADATA_2:
|
MOD_UADATA_2 := *+1
|
||||||
lda UADATA ; Get character
|
lda UADATA ; Get character
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
@ -77,7 +99,7 @@ MOD_UADATA_2:
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
;;; Read a character from the serial port to the accumulator
|
;;; Read a character from the serial port to the accumulator
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
MOD_UASTAT_3:
|
MOD_UASTAT_3 := *+1
|
||||||
lda UASTAT ; Check status bits
|
lda UASTAT ; Check status bits
|
||||||
and #$68
|
and #$68
|
||||||
cmp #$8
|
cmp #$8
|
||||||
|
@ -91,7 +113,7 @@ MOD_UASTAT_3:
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
;;; Clean up serial port
|
;;; Clean up serial port
|
||||||
;;;---------------------------------------------------------
|
;;;---------------------------------------------------------
|
||||||
MOD_UADATA_3:
|
MOD_UADATA_3 := *+1
|
||||||
bit UADATA
|
bit UADATA
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
|
Loading…
Reference in New Issue
Block a user