- Added a non-blocking version of GET to AppleSoft

- Procedural GOSUBs no longer rely on V flag in Applesoft (wasn't reliable with interrupts)
- Added &MOUSE
- Added &PDACT
- Added &GET
- Button clicking with mouse now flashes state
- Mouse clicking on controls now works from AppleSoft
This commit is contained in:
Quinn Dunki 2014-10-01 15:53:20 -07:00
parent b1cefa96c0
commit 6c36f5e627
6 changed files with 110 additions and 9 deletions

View File

@ -4,6 +4,7 @@ Known issues
- Negative cursor positions unsupported
- Positive scroll values unsupported
- Hitting Reset in app that uses windows and desktop (no mouse needed) seems to mess up screen holes for Disk II
To Do:

Binary file not shown.

View File

@ -18,6 +18,7 @@ CHRGET = $00b1 ; Advances text point and gets character in A
CHRGOT = $00b7 ; Returns character at text pointer in A
TXTPTRL = $00b8 ; Current location in BASIC listing (LSB)
TXTPTRH = $00b9 ; Current location in BASIC listing (MSB)
VARPNT = $0083 ; Return value for PTRGET
FAC = $009d ; Floating point accumulator
@ -32,6 +33,7 @@ SYNCHR = $dec0 ; Validates current character is what's in A
AYINT = $e10c ; Convert FAC to 8-bit signed integer
GETBYT = $e6f8 ; Gets an integer at text pointer, stores in X
GETNUM = $e746 ; Gets an 8-bit, stores it X, skips past a comma
PTRGET = $dfe3 ; Finds the Applesoft variable in memory at text pointer
TOKEN_GOSUB = $b0 ; Applesoft's token for GOSUB
TOKEN_HOME = $97 ; Applesoft's token for HOME
@ -39,6 +41,7 @@ TOKEN_PRINT = $ba ; Applesoft's token for PRINT
TOKEN_MINUS = $c9 ; Applesoft's token for a minus sign
TOKEN_DRAW = $94 ; Applesoft's token for DRAW
TOKEN_PLOT = $8d ; Applesoft's token for PLOT
TOKEN_GET = $be ; Applesoft's token for GET
ERR_UNDEFINEDFUNC = 224
ERR_SYNTAX = 16
@ -540,7 +543,8 @@ WGAmpersand_ACT:
jsr WGViewFocusAction
jsr WGBottomCursor
bvs WGAmpersand_ACTGosub
lda WG_GOSUB
bne WGAmpersand_ACTGosub
rts
WGAmpersand_ACTGosub:
@ -853,6 +857,84 @@ WGAmpersand_PLOT:
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGAmpersand_MOUSE
; Enable or disable the mouse
; &MOUSE(enable)
WGAmpersand_MOUSE:
jsr WGAmpersandBeginArguments
jsr WGAmpersandIntArgument
pha
jsr WGAmpersandEndArguments
pla
beq WGAmpersand_MOUSEoff
jsr WGEnableMouse
rts
WGAmpersand_MOUSEoff:
jsr WGDisableMouse
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGAmpersand_PDACT
; Performs any pending view action
; &PDACT
WGAmpersand_PDACT:
lda WG_PENDINGACTIONVIEW
bmi WGAmpersand_PDACTdone
jsr WGPendingViewAction
jsr WGBottomCursor
WGAmpersand_PDACTdone:
lda WG_GOSUB
bne WGAmpersand_PDACTGosub
rts
WGAmpersand_PDACTGosub:
jmp WGGosub ; No coming back from an Applesoft GOSUB!
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGAmpersand_GET
; A non-blocking version of Applesoft GET. Returns 0 if no key
; is pending
; &GET(A$)
WGAmpersand_GET:
jsr WGAmpersandBeginArguments
jsr PTRGET
lda KBD
bpl WGAmpersand_GETnone ; No key pending
sta KBDSTRB ; Clear strobe and high bit
and #%01111111
bra WGAmpersand_GETstore
WGAmpersand_GETnone:
lda #0
WGAmpersand_GETstore:
ldy #0
sta WG_KEYBUFFER ; Store the key
lda #1 ; Create an Applesoft string record in the
sta (VARPNT),y ; variable's location
iny
lda #<WG_KEYBUFFER
sta (VARPNT),y
iny
lda #>WG_KEYBUFFER
sta (VARPNT),y
jsr WGAmpersandEndArguments
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -886,6 +968,9 @@ WGBottomCursor:
; PARAM1: Line number (MSB)
;
WGGosub:
lda #0
sta WG_GOSUB ; Clear the flag
; Can't come back from what we're about to do, so cleanup from the
; original Ampersand entry point now! This is some seriously voodoo
; shit we're gonna pull here.
@ -941,6 +1026,12 @@ WGAmpersandCommandBufferEnd:
WG_STACKPTR: ; A place to save the stack pointer for tricky Applesoft manipulation
.byte 0
WG_KEYBUFFER: ; A phony string buffer for non-blocking GET
.byte 0
WG_GOSUB: ; Set if a gosub was generated by a view action
.byte 0
; Jump table for ampersand commands.
; Each row is 8 bytes (5 for name, NULL terminator, 2 for address)
@ -1026,6 +1117,14 @@ WGAmpersandCommandTable:
.byte TOKEN_PLOT,0,0,0,0,0
.addr WGAmpersand_PLOT
.byte "MOUSE",0
.addr WGAmpersand_MOUSE
.byte "PDACT",0
.addr WGAmpersand_PDACT
.byte TOKEN_GET,0,0,0,0,0
.addr WGAmpersand_GET
;.byte TOKEN_GOSUB,0,0,0,0,0,0,0,0,0,0,0,0,0 ; For internal testing of the procedural gosub
;.addr WGAmpersand_GOSUB

2
gui.s
View File

@ -22,7 +22,7 @@ main:
jsr WGInit
jsr WG80
;rts
rts
;jmp tortureTestPrint
;jmp tortureTestRects

Binary file not shown.

15
views.s
View File

@ -793,7 +793,7 @@ WGViewFocusPrev_focus:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGViewFocusAction
; Performs the action of the focused view
; OUT V : Set if the caller should perform an Applesoft GOSUB
; WG_GOSUB : Set if the caller should perform an Applesoft GOSUB
; Side effects: Changes selected view, Repaints some views
;
WGViewFocusAction:
@ -835,11 +835,12 @@ WGViewFocusAction_buttonClick:
sta WGViewFocusAction_userJSR+1
WGViewFocusAction_userJSR:
jsr WGViewFocusAction_knownRTS ; Overwritten with user's function pointer
jsr WGViewFocusAction_done ; Overwritten with user's function pointer
bra WGViewFocusAction_done
WGViewFocusAction_buttonClickApplesoft:
clv
lda #0
sta WG_GOSUB
lda WG_VIEWRECORDS+10,y ; Do we have a callback?
beq WGViewFocusAction_mightBeZero
@ -850,8 +851,8 @@ WGViewFocusAction_buttonClickApplesoftNotZero:
WGViewFocusAction_buttonClickApplesoftGosub:
; Caller needs to handle Applesoft Gosub, so signal with a flag and return
lda #%01000000
bit WGViewFocusAction_knownRTS ; Set V by BITting an RTS instruction
lda #1
sta WG_GOSUB
bra WGViewFocusAction_done
WGViewFocusAction_mightBeZero:
@ -874,7 +875,6 @@ WGViewFocusAction_knownRTS:
;
WGPendingViewAction:
pha
lda WG_PENDINGACTIONVIEW
bmi WGPendingViewAction_done
@ -883,6 +883,7 @@ WGPendingViewAction:
jsr WGSelectView
jsr WGViewFocus
jsr WGViewFocusAction
jsr delayShort
jsr WGViewUnfocus
jsr WGDrawPointer ; Leave pointer hidden, but ensure
@ -890,7 +891,7 @@ WGPendingViewAction:
lda #$ff
sta WG_PENDINGACTIONVIEW
WGPendingViewAction_done:
pla
rts