reformat, dedupe

This commit is contained in:
Joshua Bell 2018-10-28 22:23:33 -07:00
parent efeff6cdb9
commit 684b82ca56
6 changed files with 801 additions and 864 deletions

Binary file not shown.

View File

@ -2,6 +2,12 @@ ca65 V2.16 - Git f5e9b401
Main file : client.s
Current file: client.s
000000r 1 ;;;-------------------------------------------------------------------
000000r 1 ;;;
000000r 1 ;;; vnIIc Client Application
000000r 1 ;;;
000000r 1 ;;;-------------------------------------------------------------------
000000r 1
000000r 1 PADDLE_SUPPORT = 1
000000r 1 ;;; MOUSE_SUPPORT = 1
000000r 1
@ -72,13 +78,38 @@ Current file: client.s
000000r 2 BUTN1 := $C062 ; Closed-Apple Key
000000r 2
000000r 1
000000r 1 .include "macros.inc"
000000r 2 ;;;---------------------------------------------------------
000000r 2 ;;;
000000r 2 ;;; Generic Macros
000000r 2 ;;;
000000r 2 ;;;---------------------------------------------------------
000000r 2
000000r 2 .macro SaveRegisters
000000r 2 pha
000000r 2 txa
000000r 2 pha
000000r 2 tya
000000r 2 pha
000000r 2 .endmacro
000000r 2
000000r 2 .macro RestoreRegisters
000000r 2 pla
000000r 2 tay
000000r 2 pla
000000r 2 tax
000000r 2 pla
000000r 2 .endmacro
000000r 2
000000r 1
000000r 1 ;;;---------------------------------------------------------
000000r 1 ;;; Hi-res graphics constants/locations
000000r 1 ;;;---------------------------------------------------------
000000r 1
000000r 1 PLOTPAGE := $E6 ; Active hires plotting page (Applesoft)
000000r 1 PLOTPAGE1 := $20
000000r 1 PLOTPAGE2 := $40
000000r 1 PAGE := $E6 ; Active hires plotting page (Applesoft)
000000r 1 PAGE1 := $20
000000r 1 PAGE2 := $40
000000r 1
000000r 1 PAGESIZE := $20 ; Size of hi-res screen in pages
000000r 1
000000r 1 ;;;---------------------------------------------------------
@ -88,6 +119,8 @@ Current file: client.s
000000r 1 PREAD := $FB1E ; Monitor paddle reading routine, call
000000r 1 ; with paddle # in X, returns value in Y
000000r 1
000000r 1 HCLR := $F3F2 ; Clear current hires screen to black
000000r 1
000000r 1 ;;;---------------------------------------------------------
000000r 1 ;;; Other
000000r 1 ;;;---------------------------------------------------------
@ -96,38 +129,13 @@ Current file: client.s
000000r 1
000000r 1 ZP_PTR := $FA ; Write cursor location on zero page
000000r 1
000000r 1 ;;;---------------------------------------------------------
000000r 1 ;;; Generic Macros
000000r 1 ;;;---------------------------------------------------------
000000r 1
000000r 1 ;;;----------------------------------------
000000r 1 .macro SaveRegisters
000000r 1 ;;;----------------------------------------
000000r 1 pha
000000r 1 txa
000000r 1 pha
000000r 1 tya
000000r 1 pha
000000r 1 .endmacro
000000r 1
000000r 1 ;;;----------------------------------------
000000r 1 .macro RestoreRegisters
000000r 1 ;;;----------------------------------------
000000r 1 pla
000000r 1 tay
000000r 1 pla
000000r 1 tax
000000r 1 pla
000000r 1 .endmacro
000000r 1
000000r 1
000000r 1 ;;;-------------------------------------------------------------------
000000r 1 ;;;
000000r 1 ;;; Application-level logic
000000r 1 ;;; Client Code
000000r 1 ;;;
000000r 1 ;;;-------------------------------------------------------------------
000000r 1
000000r 1
000000r 1 .org $6000
006000 1 4C 60 60 jmp AppEntry
006003 1
@ -166,10 +174,9 @@ Current file: client.s
006007 2
006007 2
006007 2 ;;;---------------------------------------------------------
006007 2 .proc Init
006007 2 ;;;---------------------------------------------------------
006007 2 ;;; Initialize the SSC; slot passed in A
006007 2 ;;;---------------------------------------------------------
006007 2
006007 2 .proc Init
006007 2 0A asl ; Slot passed in A
006008 2 0A asl
006009 2 0A asl
@ -193,10 +200,9 @@ Current file: client.s
006030 2
006030 2
006030 2 ;;;---------------------------------------------------------
006030 2 .proc Put
006030 2 ;;;---------------------------------------------------------
006030 2 ;;; Send accumulator out the serial port
006030 2 ;;;---------------------------------------------------------
006030 2
006030 2 .proc Put
006030 2 48 pha ; Push A onto the stack
006031 2 MOD_UASTAT_1 := *+1
006031 2 AD 89 C0 : lda UASTAT ; Check status bits
@ -212,10 +218,9 @@ Current file: client.s
00603F 2 MOD_UADATA_1 := Put::MOD_UADATA_1
00603F 2
00603F 2 ;;;---------------------------------------------------------
00603F 2 .proc Get
00603F 2 ;;;---------------------------------------------------------
00603F 2 ;;; Read a character from the serial port to the accumulator
00603F 2 ;;;---------------------------------------------------------
00603F 2
00603F 2 .proc Get
00603F 2 MOD_UASTAT_2 := *+1
00603F 2 AD 89 C0 lda UASTAT ; Check status bits
006042 2 29 68 and #$68
@ -229,10 +234,9 @@ Current file: client.s
00604C 2 MOD_UADATA_2 := Get::MOD_UADATA_2
00604C 2
00604C 2 ;;;---------------------------------------------------------
00604C 2 ;;; Check if the serial port has pending data
00604C 2
00604C 2 .proc HasData
00604C 2 ;;;---------------------------------------------------------
00604C 2 ;;; Read a character from the serial port to the accumulator
00604C 2 ;;;---------------------------------------------------------
00604C 2 MOD_UASTAT_3 := *+1
00604C 2 AD 89 C0 lda UASTAT ; Check status bits
00604F 2 29 68 and #$68
@ -243,10 +247,9 @@ Current file: client.s
006054 2
006054 2
006054 2 ;;;---------------------------------------------------------
006054 2 .proc Reset
006054 2 ;;;---------------------------------------------------------
006054 2 ;;; Clean up serial port
006054 2 ;;;---------------------------------------------------------
006054 2
006054 2 .proc Reset
006054 2 MOD_UADATA_3 := *+1
006054 2 2C 88 C0 bit UADATA
006057 2 60 rts
@ -258,7 +261,7 @@ Current file: client.s
006058 1
006058 1 .ifdef MOUSE_SUPPORT
006058 1 .include "mouse.inc"
006058 1 .endif ; MOUSE_SUPPORT
006058 1 .endif
006058 1
006058 1
006058 1 ;;;-------------------------------------------------------------------
@ -285,10 +288,9 @@ Current file: client.s
006060 1
006060 1
006060 1 ;;;---------------------------------------------------------
006060 1 .proc AppEntry
006060 1 ;;;---------------------------------------------------------
006060 1 ;;; Initialize the application, and enter the main loop
006060 1 ;;;---------------------------------------------------------
006060 1
006060 1 .proc AppEntry
006060 1 AD 59 60 lda PSLOT ; Use slot 2
006063 1 20 07 60 jsr SSC::Init ; Initialize Super Serial Card
006066 1 20 8C 61 jsr InitHires ; Initialize Hi-Res graphics
@ -299,10 +301,9 @@ Current file: client.s
00606F 1 .endproc
00606F 1
00606F 1 ;;;---------------------------------------------------------
00606F 1 .proc AppExit
00606F 1 ;;;---------------------------------------------------------
00606F 1 ;;; Clean up and exit app
00606F 1 ;;;---------------------------------------------------------
00606F 1
00606F 1 .proc AppExit
00606F 1 20 54 60 jsr SSC::Reset
006072 1 8D 54 C0 sta LOWSCR
006075 1 8D 51 C0 sta TXTSET
@ -319,11 +320,10 @@ Current file: client.s
006079 1
006079 1 ;;;---------------------------------------------------------
006079 1 .proc MainLoop
006079 1 ;;;---------------------------------------------------------
006079 1
006079 1 ;;; TODO: Sort out the protocol - should be able to send
006079 1 ;;; input state without receiving data
006079 1 ;;; jsr SSCHasData ; Anything to read?
006079 1 ;;; jsr SSC::HasData ; Anything to read?
006079 1 ;;; bne :+ ; Nope
006079 1
006079 1 20 83 60 : jsr ReceivePage
@ -334,18 +334,16 @@ Current file: client.s
006083 1
006083 1
006083 1 ;;;---------------------------------------------------------
006083 1 .proc ReceivePage
006083 1 ;;;---------------------------------------------------------
006083 1 ;;; Pull a hi-res page down over serial
006083 1 ;;;
006083 1 ;;; Protocol is:
006083 1 ;;; * Recieve 256 bytes (graphic data)
006083 1 ;;; * Send 1 byte (input state)
006083 1 ;;;---------------------------------------------------------
006083 1
006083 1 .proc ReceivePage
006083 1 A9 00 lda #0 ; set up write pointer
006085 1 85 FA sta ZP_PTR
006087 1 A5 E6 lda PLOTPAGE
006087 1 A5 E6 lda PAGE
006089 1 85 FB sta ZP_PTR+1
00608B 1 A2 20 ldx #PAGESIZE ; plan to receive this many pages
00608D 1 A0 00 ldy #0
@ -391,11 +389,10 @@ Current file: client.s
0060A0 1 SIS_SYNC = $7f
0060A0 1
0060A0 1 ;;;---------------------------------------------------------
0060A0 1 .proc InitInput
0060A0 1 ;;;---------------------------------------------------------
0060A0 1 ;;; Initialize input devices and storage for detecting
0060A0 1 ;;; state transitions
0060A0 1 ;;;---------------------------------------------------------
0060A0 1
0060A0 1 .proc InitInput
0060A0 1
0060A0 1 ;;; Init keyboard state
0060A0 1 A9 00 lda #SIS_KBUP
@ -426,8 +423,6 @@ Current file: client.s
0060BE 1
0060BE 1
0060BE 1 ;;;---------------------------------------------------------
0060BE 1 .proc SendInputState
0060BE 1 ;;;---------------------------------------------------------
0060BE 1 ;;; Send keyboard joystick and/or mouse state over the
0060BE 1 ;;; serial port
0060BE 1 ;;;
@ -438,7 +433,8 @@ Current file: client.s
0060BE 1 ;;; - otherwise send paddle 0 state (if it changed)
0060BE 1 ;;; - (TODO: Mouse state)
0060BE 1 ;;; - otherwise send sync byte
0060BE 1 ;;;---------------------------------------------------------
0060BE 1
0060BE 1 .proc SendInputState
0060BE 1
0060BE 1 48 8A 48 98 SaveRegisters ; Store registers
0060C2 1 48
@ -611,13 +607,12 @@ Current file: client.s
00618C 1 ;;;-------------------------------------------------------------------
00618C 1
00618C 1 ;;;---------------------------------------------------------
00618C 1 .proc InitHires
00618C 1 ;;;---------------------------------------------------------
00618C 1 ;;; Set up the graphics display and pointers
00618C 1 ;;;---------------------------------------------------------
00618C 1 A9 20 lda #PLOTPAGE1 ; clear page 1
00618E 1 85 E6 sta PLOTPAGE
006190 1 20 B9 61 jsr ClearHires
00618C 1
00618C 1 .proc InitHires
00618C 1 A9 20 lda #PAGE1 ; clear page 1
00618E 1 85 E6 sta PAGE
006190 1 20 F2 F3 jsr HCLR
006193 1
006193 1 20 A3 61 jsr FlipHires ; then show it and flip to 2
006196 1 8D 57 C0 sta HIRES
@ -630,47 +625,23 @@ Current file: client.s
0061A3 1
0061A3 1
0061A3 1 ;;;---------------------------------------------------------
0061A3 1 .proc FlipHires
0061A3 1 ;;;---------------------------------------------------------
0061A3 1 ;;; Call when done with the current plotting page
0061A3 1 ;;; (selected in PLOTPAGE) and it will be shown and the
0061A3 1 ;;; (selected in PAGE) and it will be shown and the
0061A3 1 ;;; other page will be shown.
0061A3 1 ;;;---------------------------------------------------------
0061A3 1 A5 E6 lda PLOTPAGE ; plotting on which page?
0061A5 1 C9 20 cmp #PLOTPAGE1
0061A3 1
0061A3 1 .proc FlipHires
0061A3 1 A5 E6 lda PAGE ; plotting on which page?
0061A5 1 C9 20 cmp #PAGE1
0061A7 1 F0 08 beq :+
0061A9 1
0061A9 1 8D 55 C0 sta HISCR ; page 2 - so show it
0061AC 1 A9 20 lda #PLOTPAGE1 ; and plot on page 1
0061AE 1 85 E6 sta PLOTPAGE
0061AC 1 A9 20 lda #PAGE1 ; and plot on page 1
0061AE 1 85 E6 sta PAGE
0061B0 1 60 rts
0061B1 1
0061B1 1 8D 54 C0 : sta LOWSCR ; page 1 - so show it
0061B4 1 A9 40 lda #PLOTPAGE2 ; and plot on page 2
0061B6 1 85 E6 sta PLOTPAGE
0061B4 1 A9 40 lda #PAGE2 ; and plot on page 2
0061B6 1 85 E6 sta PAGE
0061B8 1 60 rts
0061B9 1 .endproc
0061B9 1
0061B9 1
0061B9 1 ;;;---------------------------------------------------------
0061B9 1 .proc ClearHires
0061B9 1 ;;;---------------------------------------------------------
0061B9 1 ;;; Clear hires plotting page (selected in PLOTPAGE) to
0061B9 1 ;;; black uses ZP_PTR; not terribly efficient
0061B9 1 ;;;---------------------------------------------------------
0061B9 1 A9 00 lda #0 ; Set up ZP_PTR as a pointer into the hires page
0061BB 1 85 FA sta ZP_PTR
0061BD 1 A5 E6 lda PLOTPAGE
0061BF 1 85 FB sta ZP_PTR+1
0061C1 1 A2 20 ldx #PAGESIZE ; Clear this many pages
0061C3 1 A9 00 lda #0 ; with black!
0061C5 1 A8 tay
0061C6 1 91 FA : sta (ZP_PTR),Y
0061C8 1 C8 iny
0061C9 1 D0 FB bne :-
0061CB 1 E6 FB inc ZP_PTR+1
0061CD 1 CA dex
0061CE 1 D0 F6 bne :-
0061D0 1 60 rts
0061D1 1 .endproc
0061D1 1

View File

@ -1,15 +1,24 @@
PADDLE_SUPPORT = 1
;;;-------------------------------------------------------------------
;;;
;;; vnIIc Client Application
;;;
;;;-------------------------------------------------------------------
PADDLE_SUPPORT = 1
;;; MOUSE_SUPPORT = 1
.include "apple2.inc"
.include "apple2.inc"
.include "macros.inc"
;;;---------------------------------------------------------
;;; Hi-res graphics constants/locations
;;;---------------------------------------------------------
PLOTPAGE := $E6 ; Active hires plotting page (Applesoft)
PLOTPAGE1 := $20
PLOTPAGE2 := $40
PAGE := $E6 ; Active hires plotting page (Applesoft)
PAGE1 := $20
PAGE2 := $40
PAGESIZE := $20 ; Size of hi-res screen in pages
;;;---------------------------------------------------------
@ -19,6 +28,8 @@ PAGESIZE := $20 ; Size of hi-res screen in pages
PREAD := $FB1E ; Monitor paddle reading routine, call
; with paddle # in X, returns value in Y
HCLR := $F3F2 ; Clear current hires screen to black
;;;---------------------------------------------------------
;;; Other
;;;---------------------------------------------------------
@ -27,46 +38,21 @@ MAX_SLOT := 7 ; Maximum slot # on an Apple II
ZP_PTR := $FA ; Write cursor location on zero page
;;;---------------------------------------------------------
;;; Generic Macros
;;;---------------------------------------------------------
;;;----------------------------------------
.macro SaveRegisters
;;;----------------------------------------
pha
txa
pha
tya
pha
.endmacro
;;;----------------------------------------
.macro RestoreRegisters
;;;----------------------------------------
pla
tay
pla
tax
pla
.endmacro
;;;-------------------------------------------------------------------
;;;
;;; Application-level logic
;;; Client Code
;;;
;;;-------------------------------------------------------------------
.org $6000
.org $6000
jmp AppEntry
.include "ssc.inc"
.include "ssc.inc"
.ifdef MOUSE_SUPPORT
.ifdef MOUSE_SUPPORT
.include "mouse.inc"
.endif ; MOUSE_SUPPORT
.endif
;;;-------------------------------------------------------------------
@ -83,20 +69,19 @@ LASTKB: .byte 0
LASTOA: .byte 0
LASTCA: .byte 0
.ifdef PADDLE_SUPPORT
.ifdef PADDLE_SUPPORT
;;; Paddle state
LASTP0: .byte 0
LASTP1: .byte 0
.endif ; PADDLE_SUPPORT
.endif ; PADDLE_SUPPORT
;;;---------------------------------------------------------
.proc AppEntry
;;;---------------------------------------------------------
;;; Initialize the application, and enter the main loop
;;;---------------------------------------------------------
.proc AppEntry
lda PSLOT ; Use slot 2
jsr SSC::Init ; Initialize Super Serial Card
jsr InitHires ; Initialize Hi-Res graphics
@ -106,11 +91,10 @@ LASTP1: .byte 0
; fall through
.endproc
;;;---------------------------------------------------------
.proc AppExit
;;;---------------------------------------------------------
;;; Clean up and exit app
;;;---------------------------------------------------------
.proc AppExit
jsr SSC::Reset
sta LOWSCR
sta TXTSET
@ -127,11 +111,10 @@ LASTP1: .byte 0
;;;---------------------------------------------------------
.proc MainLoop
;;;---------------------------------------------------------
;;; TODO: Sort out the protocol - should be able to send
;;; input state without receiving data
;;; jsr SSCHasData ; Anything to read?
;;; jsr SSC::HasData ; Anything to read?
;;; bne :+ ; Nope
: jsr ReceivePage
@ -141,19 +124,17 @@ LASTP1: .byte 0
.endproc
;;;---------------------------------------------------------
.proc ReceivePage
;;;---------------------------------------------------------
;;; Pull a hi-res page down over serial
;;;
;;; Protocol is:
;;; * Recieve 256 bytes (graphic data)
;;; * Send 1 byte (input state)
;;;---------------------------------------------------------
.proc ReceivePage
lda #0 ; set up write pointer
sta ZP_PTR
lda PLOTPAGE
lda PAGE
sta ZP_PTR+1
ldx #PAGESIZE ; plan to receive this many pages
ldy #0
@ -198,12 +179,11 @@ LASTP1: .byte 0
;;;
SIS_SYNC = $7f
;;;---------------------------------------------------------
.proc InitInput
;;;---------------------------------------------------------
;;; Initialize input devices and storage for detecting
;;; state transitions
;;;---------------------------------------------------------
.proc InitInput
;;; Init keyboard state
lda #SIS_KBUP
@ -215,7 +195,7 @@ LASTP1: .byte 0
lda #SIS_CAUP ; NOTE: Don't store CA state as it fluctuates
sta LASTCA
.ifdef PADDLE_SUPPORT
.ifdef PADDLE_SUPPORT
;;; Init Paddle state
lda #SIS_PDL0
ora #8 ; Middle of range 0...15
@ -223,18 +203,16 @@ LASTP1: .byte 0
lda #SIS_PDL1
ora #8 ; Middle of range 0...15
sta LASTP1
.endif
.endif
.ifdef MOUSE_SUPPORT
.ifdef MOUSE_SUPPORT
jsr Mouse::FindMouse
.endif
.endif
rts
.endproc
;;;---------------------------------------------------------
.proc SendInputState
;;;---------------------------------------------------------
;;; Send keyboard joystick and/or mouse state over the
;;; serial port
@ -246,7 +224,8 @@ LASTP1: .byte 0
;;; - otherwise send paddle 0 state (if it changed)
;;; - (TODO: Mouse state)
;;; - otherwise send sync byte
;;;---------------------------------------------------------
.proc SendInputState
SaveRegisters ; Store registers
clc
@ -343,7 +322,7 @@ CA_IS_DOWN:
END_CA:
.ifdef PADDLE_SUPPORT
.ifdef PADDLE_SUPPORT
;;;--------------------------------------
;;; Send Paddle 0 state, if it changed
@ -392,7 +371,7 @@ END_PDL1:
; since data receive will make up for it; if we
; loop in SendInputState need to add it here
.endif
.endif
;;;--------------------------------------
@ -414,14 +393,13 @@ DONE:
;;;
;;;-------------------------------------------------------------------
;;;---------------------------------------------------------
.proc InitHires
;;;---------------------------------------------------------
;;; Set up the graphics display and pointers
;;;---------------------------------------------------------
lda #PLOTPAGE1 ; clear page 1
sta PLOTPAGE
jsr ClearHires
.proc InitHires
lda #PAGE1 ; clear page 1
sta PAGE
jsr HCLR
jsr FlipHires ; then show it and flip to 2
sta HIRES
@ -433,47 +411,23 @@ DONE:
.endproc
;;;---------------------------------------------------------
.proc FlipHires
;;;---------------------------------------------------------
;;; Call when done with the current plotting page
;;; (selected in PLOTPAGE) and it will be shown and the
;;; (selected in PAGE) and it will be shown and the
;;; other page will be shown.
;;;---------------------------------------------------------
lda PLOTPAGE ; plotting on which page?
cmp #PLOTPAGE1
.proc FlipHires
lda PAGE ; plotting on which page?
cmp #PAGE1
beq :+
sta HISCR ; page 2 - so show it
lda #PLOTPAGE1 ; and plot on page 1
sta PLOTPAGE
lda #PAGE1 ; and plot on page 1
sta PAGE
rts
: sta LOWSCR ; page 1 - so show it
lda #PLOTPAGE2 ; and plot on page 2
sta PLOTPAGE
rts
.endproc
;;;---------------------------------------------------------
.proc ClearHires
;;;---------------------------------------------------------
;;; Clear hires plotting page (selected in PLOTPAGE) to
;;; black uses ZP_PTR; not terribly efficient
;;;---------------------------------------------------------
lda #0 ; Set up ZP_PTR as a pointer into the hires page
sta ZP_PTR
lda PLOTPAGE
sta ZP_PTR+1
ldx #PAGESIZE ; Clear this many pages
lda #0 ; with black!
tay
: sta (ZP_PTR),Y
iny
bne :-
inc ZP_PTR+1
dex
bne :-
lda #PAGE2 ; and plot on page 2
sta PAGE
rts
.endproc

21
client/macros.inc Normal file
View File

@ -0,0 +1,21 @@
;;;---------------------------------------------------------
;;;
;;; Generic Macros
;;;
;;;---------------------------------------------------------
.macro SaveRegisters
pha
txa
pha
tya
pha
.endmacro
.macro RestoreRegisters
pla
tay
pla
tax
pla
.endmacro

View File

@ -3,7 +3,7 @@
;;; Mouse
;;;
;;;-------------------------------------------------------------------
.error "Mouse support not fully implemented"
.error "Mouse support not fully implemented"
.proc Mouse
@ -53,7 +53,7 @@ LAST_MY: .byte $7f
;;; Routines
;;;--------------------------------------------------
MOUSEPTR = $EB ; Zero page location
MOUSEPTR := $EB ; Zero page location
MOUSE_MIN_X := $10
MOUSE_MAX_X := $1f
@ -74,7 +74,6 @@ MOUSE_CENTER_Y := $2f
;;; min: minimum value (2 byte)
;;; max: maximum value (2 byte)
;;;----------------------------------------
; Clamp X to 0...255
lda #<min
sta MOUSE_CMIN_LSB
lda #>min
@ -103,18 +102,17 @@ MOUSE_CENTER_Y := $2f
.endmacro
;;;---------------------------------------------------------
.proc FindMouse
;;;---------------------------------------------------------
;;; Find and initialize the mouse port
;;;---------------------------------------------------------
.proc FindMouse
;;; Reference: http://home.swbell.net/rubywand/R034MOUSEPRG.TXT
sei ; No interrupts while we're getting set up
;
;
;;; Step 1: Find the mouse card by scanning slots for ID bytes
;
;
ldy #MAX_SLOT ; Start search in slot 7
@ -129,7 +127,7 @@ TESTSLOT:
TESTID:
lda MOUSEID_ADDR,x
sta MOD_MOUSE_ID + 1 ; Update lsb of signature test
slot_addr := *+1
slot_addr := *+1
lda SLOT_BASE ; Self-modified
cmp MOUSEID_VAL,x ; Does it match the signature?
bne NOMATCH ; Nope - try the next slot
@ -143,9 +141,9 @@ NOMATCH:
sty MOUSE_SLOT ; Oops, no mouse - make a note
rts ; and bail
;
;
;;; Step 2: Set up indirect calling routines
;
;
FOUND_MOUSE:
; Slot is in y
@ -166,17 +164,17 @@ FOUND_MOUSE:
asl
sta TOMOUSE_n0 ; Y register before firmware calls
;
;
;;; Step 3: Configure the mouse card
;
;
;;; Initialize the mouse for use
jsr INITMOUSE ; reset, clamp to 0-1023 x/y
lda #1 ; mouse on, no interrupts
jsr SETMOUSE ; TODO: test carry bit result (set = error)
;
;
;;; Since we want deltas, clamp and center
;
;
ClampMouse MOUSE_CLAMP_X, MOUSE_MIN_X, MOUSE_MAX_X
ClampMouse MOUSE_CLAMP_Y, MOUSE_MIN_Y, MOUSE_MAX_Y
PosMouse MOUSE_CENTER_X, MOUSE_CENTER_Y
@ -210,8 +208,8 @@ INITMOUSE: ldy #$19
jmp GoMouse
;;;--------------------------------------------------
.proc GoMouse
;;;--------------------------------------------------
tax ; Preserve the value in A
lda (MOUSEPTR),Y ; Get the routine entry point
sta TOMOUSE_lsb ; Patch the JMP instruction
@ -223,14 +221,14 @@ INITMOUSE: ldy #$19
BANK := $C054
TOMOUSE:
TOMOUSE_Cn := *+1
TOMOUSE_Cn := *+1
ldx #$C1 ; Set up slot in $Cn form in X
TOMOUSE_n0 := *+1
TOMOUSE_n0 := *+1
ldy #$10 ; Set up slot in $n0 form in Y
php ; Save interrupt state
sei ; No interrupts while calling
bit BANK
TOMOUSE_slot := *+1
TOMOUSE_slot := *+1
jsr 0 ; Go to the mouse routine
plp ; Restore interrupt state
rts
@ -246,9 +244,7 @@ TOMOUSE_msb := GoMouse::TOMOUSE_slot+1
;;;--------------------------------------------------
.proc FOOMOUSE
;;;--------------------------------------------------
;
;;;--------------------------------------------------
txa ; save x
pha
tya ; save y

View File

@ -13,29 +13,28 @@
;;;---------------------------------------------------------
;;; 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
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
.enum
BPS_300
BPS_9600
BPS_19200
BPS_115k
.endenum
.endenum
CMND_NRDI = $0B ; Command: no parity, RTS on, DTR on, no interrupts
CMND_NRDI = $0B ; Command: no parity, RTS on, DTR on, no interrupts
;;;---------------------------------------------------------
.proc Init
;;;---------------------------------------------------------
;;; Initialize the SSC; slot passed in A
;;;---------------------------------------------------------
.proc Init
asl ; Slot passed in A
asl
asl
@ -58,11 +57,10 @@ CMND_NRDI = $0B ; Command: no parity, RTS on, DTR on, no interrupts
.endproc
;;;---------------------------------------------------------
.proc Put
;;;---------------------------------------------------------
;;; Send accumulator out the serial port
;;;---------------------------------------------------------
.proc Put
pha ; Push A onto the stack
MOD_UASTAT_1 := *+1
: lda UASTAT ; Check status bits
@ -74,14 +72,13 @@ MOD_UADATA_1 := *+1
sta UADATA ; Put character
rts
.endproc
MOD_UASTAT_1 := Put::MOD_UASTAT_1
MOD_UADATA_1 := Put::MOD_UADATA_1
MOD_UASTAT_1 := Put::MOD_UASTAT_1
MOD_UADATA_1 := Put::MOD_UADATA_1
;;;---------------------------------------------------------
.proc Get
;;;---------------------------------------------------------
;;; Read a character from the serial port to the accumulator
;;;---------------------------------------------------------
.proc Get
MOD_UASTAT_2 := *+1
lda UASTAT ; Check status bits
and #$68
@ -91,32 +88,30 @@ MOD_UADATA_2 := *+1
lda UADATA ; Get character
rts
.endproc
MOD_UASTAT_2 := Get::MOD_UASTAT_2
MOD_UADATA_2 := Get::MOD_UADATA_2
MOD_UASTAT_2 := Get::MOD_UASTAT_2
MOD_UADATA_2 := Get::MOD_UADATA_2
;;;---------------------------------------------------------
;;; Check if the serial port has pending data
.proc HasData
;;;---------------------------------------------------------
;;; Read a character from the serial port to the accumulator
;;;---------------------------------------------------------
MOD_UASTAT_3 := *+1
lda UASTAT ; Check status bits
and #$68
cmp #$8
rts
.endproc
MOD_UASTAT_3 := HasData::MOD_UASTAT_3
MOD_UASTAT_3 := HasData::MOD_UASTAT_3
;;;---------------------------------------------------------
.proc Reset
;;;---------------------------------------------------------
;;; Clean up serial port
;;;---------------------------------------------------------
.proc Reset
MOD_UADATA_3 := *+1
bit UADATA
rts
.endproc
MOD_UADATA_3 := Reset::MOD_UADATA_3
MOD_UADATA_3 := Reset::MOD_UADATA_3
.endproc