2017-09-06 01:41:13 +00:00
|
|
|
.setcpu "65C02"
|
|
|
|
.org $800
|
|
|
|
|
2017-09-06 05:19:45 +00:00
|
|
|
.include "apple2.inc"
|
2017-09-15 04:13:54 +00:00
|
|
|
.include "../inc/apple2.inc"
|
2017-09-06 01:41:13 +00:00
|
|
|
.include "../inc/prodos.inc"
|
|
|
|
.include "../inc/auxmem.inc"
|
|
|
|
.include "../inc/applesoft.inc"
|
2017-09-06 05:19:45 +00:00
|
|
|
|
2017-09-06 01:41:13 +00:00
|
|
|
.include "a2d.inc"
|
|
|
|
|
2017-09-08 15:36:36 +00:00
|
|
|
adjust_txtptr := $B1
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-09 01:34:34 +00:00
|
|
|
;;; ==================================================
|
|
|
|
;;; Start of the code
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-06 05:19:45 +00:00
|
|
|
start: jmp copy2aux
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-06 05:19:45 +00:00
|
|
|
save_stack: .byte 0
|
|
|
|
|
2017-09-09 01:34:34 +00:00
|
|
|
;;; ==================================================
|
|
|
|
;;; Duplicate the DA (code and data) to AUX memory,
|
|
|
|
;;; then invoke the code in AUX.
|
|
|
|
|
2017-09-06 05:19:45 +00:00
|
|
|
.proc copy2aux
|
|
|
|
tsx
|
|
|
|
stx save_stack
|
|
|
|
|
|
|
|
start := call_init
|
|
|
|
end := da_end
|
|
|
|
dest := start
|
|
|
|
|
2017-09-09 01:34:34 +00:00
|
|
|
;; Copy the DA to AUX memory.
|
2017-09-06 05:19:45 +00:00
|
|
|
lda ROMIN2
|
|
|
|
lda #<start
|
|
|
|
sta STARTLO
|
|
|
|
lda #>start
|
|
|
|
sta STARTHI
|
|
|
|
lda #<end
|
|
|
|
sta ENDLO
|
|
|
|
lda #>end
|
|
|
|
sta ENDHI
|
|
|
|
lda #<dest
|
|
|
|
sta DESTINATIONLO
|
|
|
|
lda #>dest
|
|
|
|
sta DESTINATIONHI
|
|
|
|
sec ; main>aux
|
2017-09-06 01:41:13 +00:00
|
|
|
jsr AUXMOVE
|
2017-09-06 02:08:11 +00:00
|
|
|
|
2017-09-09 01:34:34 +00:00
|
|
|
;; Invoke it.
|
2017-09-06 05:19:45 +00:00
|
|
|
lda #<start
|
|
|
|
sta XFERSTARTLO
|
|
|
|
lda #>start
|
|
|
|
sta XFERSTARTHI
|
2017-09-06 01:41:13 +00:00
|
|
|
php
|
|
|
|
pla
|
2017-09-06 05:19:45 +00:00
|
|
|
ora #$40 ; set overflow: use aux zp/stack
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
|
|
|
plp
|
2017-09-06 05:19:45 +00:00
|
|
|
sec ; control main>aux
|
2017-09-06 01:41:13 +00:00
|
|
|
jmp XFER
|
2017-09-06 05:19:45 +00:00
|
|
|
.endproc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 08:00:58 +00:00
|
|
|
;;; ==================================================
|
|
|
|
|
2017-09-06 05:19:45 +00:00
|
|
|
.proc exit_da
|
2017-09-06 01:41:13 +00:00
|
|
|
lda LCBANK1
|
2017-09-06 05:19:45 +00:00
|
|
|
lda LCBANK1
|
|
|
|
ldx save_stack
|
2017-09-06 01:41:13 +00:00
|
|
|
txs
|
|
|
|
rts
|
2017-09-06 05:19:45 +00:00
|
|
|
.endproc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 08:00:58 +00:00
|
|
|
;;; ==================================================
|
|
|
|
|
2017-09-06 05:19:45 +00:00
|
|
|
call_init:
|
|
|
|
lda ROMIN2
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp init
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-09 04:10:56 +00:00
|
|
|
;; Used after a drag-and-drop is completed;
|
|
|
|
;; redraws the window.
|
2017-09-09 01:34:34 +00:00
|
|
|
.proc call_4015_main
|
2017-09-08 06:40:01 +00:00
|
|
|
|
|
|
|
zp_stash := $20
|
|
|
|
|
2017-09-09 01:34:34 +00:00
|
|
|
;; Call jump table entry $4015 in main memory, by
|
|
|
|
;; copying a trampoline routine to the ZP.
|
|
|
|
|
2017-09-08 06:40:01 +00:00
|
|
|
lda LCBANK1
|
2017-09-06 01:41:13 +00:00
|
|
|
lda LCBANK1
|
2017-09-08 06:40:01 +00:00
|
|
|
ldx #(routine_end - routine)
|
2017-09-08 15:41:51 +00:00
|
|
|
: lda routine,x
|
2017-09-08 06:40:01 +00:00
|
|
|
sta zp_stash,x
|
2017-09-06 01:41:13 +00:00
|
|
|
dex
|
2017-09-08 15:41:51 +00:00
|
|
|
bpl :-
|
2017-09-08 06:40:01 +00:00
|
|
|
jsr zp_stash
|
2017-09-08 15:41:51 +00:00
|
|
|
|
2017-09-09 04:10:56 +00:00
|
|
|
;; Redraw window after drag
|
2017-09-06 05:19:45 +00:00
|
|
|
lda ROMIN2
|
2017-09-08 06:40:01 +00:00
|
|
|
lda #window_id
|
2017-09-10 04:15:01 +00:00
|
|
|
jsr draw_window
|
2017-09-08 15:41:51 +00:00
|
|
|
|
2017-09-09 01:34:34 +00:00
|
|
|
;; ???
|
2017-09-06 01:41:13 +00:00
|
|
|
lda LCBANK1
|
|
|
|
lda LCBANK1
|
2017-09-15 07:53:45 +00:00
|
|
|
bit redraw_flag
|
2017-09-15 04:22:27 +00:00
|
|
|
|
2017-09-08 15:41:51 +00:00
|
|
|
bmi skip
|
2017-09-06 01:41:13 +00:00
|
|
|
jsr UNKNOWN_CALL
|
|
|
|
.byte $0C
|
|
|
|
.addr 0
|
2017-09-06 05:19:45 +00:00
|
|
|
|
2017-09-09 01:34:34 +00:00
|
|
|
;; ???
|
2017-09-08 15:41:51 +00:00
|
|
|
skip: lda #0
|
2017-09-15 07:53:45 +00:00
|
|
|
sta redraw_flag
|
2017-09-06 05:19:45 +00:00
|
|
|
lda ROMIN2
|
2017-09-14 04:35:23 +00:00
|
|
|
A2D_CALL A2D_QUERY_STATE, query_state_params
|
|
|
|
A2D_CALL A2D_SET_STATE, state_params
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
|
|
|
|
2017-09-08 06:40:01 +00:00
|
|
|
.proc routine
|
|
|
|
sta RAMRDOFF
|
2017-09-06 01:41:13 +00:00
|
|
|
sta RAMWRTOFF
|
2017-09-06 05:19:45 +00:00
|
|
|
jsr JUMP_TABLE_15
|
2017-09-06 01:41:13 +00:00
|
|
|
sta RAMRDON
|
|
|
|
sta RAMWRTON
|
|
|
|
rts
|
2017-09-08 06:40:01 +00:00
|
|
|
.endproc
|
|
|
|
routine_end := *
|
|
|
|
.endproc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 08:00:58 +00:00
|
|
|
;;; ==================================================
|
|
|
|
|
|
|
|
|
2017-09-15 07:53:45 +00:00
|
|
|
redraw_flag: .byte 0 ; ???
|
2017-09-09 01:34:34 +00:00
|
|
|
|
2017-09-09 04:10:56 +00:00
|
|
|
;; Called after window drag is complete
|
2017-09-10 02:11:05 +00:00
|
|
|
;; (called with window_id in A)
|
2017-09-10 04:15:01 +00:00
|
|
|
.proc draw_window
|
2017-09-14 04:35:23 +00:00
|
|
|
sta query_state_params_id
|
2017-09-09 18:08:40 +00:00
|
|
|
lda create_window_params_top
|
2017-09-10 01:11:01 +00:00
|
|
|
cmp #screen_height - 1
|
2017-09-08 06:40:01 +00:00
|
|
|
bcc :+
|
2017-09-06 01:41:13 +00:00
|
|
|
lda #$80
|
2017-09-15 07:53:45 +00:00
|
|
|
sta redraw_flag
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
|
|
|
|
2017-09-14 04:35:23 +00:00
|
|
|
: A2D_CALL A2D_QUERY_STATE, query_state_params
|
|
|
|
A2D_CALL A2D_SET_STATE, state_params
|
|
|
|
lda query_state_params_id
|
2017-09-08 06:40:01 +00:00
|
|
|
cmp #window_id
|
2017-09-10 01:11:01 +00:00
|
|
|
bne :+
|
2017-09-10 04:15:01 +00:00
|
|
|
jmp draw_background
|
2017-09-10 01:11:01 +00:00
|
|
|
: rts
|
2017-09-10 04:15:01 +00:00
|
|
|
.endproc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 08:00:58 +00:00
|
|
|
;;; ==================================================
|
|
|
|
;;; Call Params (and other data)
|
|
|
|
|
2017-09-09 04:10:56 +00:00
|
|
|
;; The following params blocks overlap for data re-use
|
2017-09-09 03:13:09 +00:00
|
|
|
|
|
|
|
.proc map_coords_params
|
|
|
|
id := *
|
|
|
|
screen := * + 1
|
2017-09-09 04:10:56 +00:00
|
|
|
screenx := * + 1 ; aligns with input_state::xcoord
|
|
|
|
screeny := * + 3 ; aligns with input_state::ycoord
|
2017-09-09 03:13:09 +00:00
|
|
|
client := * + 5
|
|
|
|
clientx := * + 5
|
|
|
|
clienty := * + 7
|
|
|
|
.endproc
|
|
|
|
|
2017-09-09 04:10:56 +00:00
|
|
|
.proc drag_params
|
|
|
|
id := *
|
|
|
|
xcoord := * + 1 ; aligns with input_state::xcoord
|
|
|
|
ycoord := * + 3 ; aligns with input_state::ycoord
|
|
|
|
.endproc
|
|
|
|
|
2017-09-09 03:13:09 +00:00
|
|
|
.proc input_state_params
|
2017-09-08 04:42:58 +00:00
|
|
|
state: .byte 0
|
2017-09-09 03:45:11 +00:00
|
|
|
xcoord := * ; if state is 0,1,2,4
|
|
|
|
ycoord := * + 2 ; "
|
|
|
|
key := * ; if state is 3
|
|
|
|
modifiers := * + 1 ; "
|
2017-09-06 06:24:21 +00:00
|
|
|
.endproc
|
2017-09-06 05:59:02 +00:00
|
|
|
|
2017-09-09 03:45:11 +00:00
|
|
|
.proc target_params
|
|
|
|
queryx: .word 0 ; aligns with input_state_params::xcoord
|
|
|
|
queryy: .word 0 ; aligns with input_state_params::ycoord
|
2017-09-08 03:59:38 +00:00
|
|
|
elem: .byte 0
|
|
|
|
id: .byte 0
|
2017-09-06 05:59:02 +00:00
|
|
|
.endproc
|
|
|
|
|
2017-09-09 03:45:11 +00:00
|
|
|
.byte 0, 0 ; fills out space for map_coords_params
|
|
|
|
.byte 0, 0 ; ???
|
2017-09-06 06:24:21 +00:00
|
|
|
|
2017-09-10 01:43:32 +00:00
|
|
|
.proc close_click_params
|
2017-09-08 04:42:58 +00:00
|
|
|
state: .byte 0
|
2017-09-06 06:24:21 +00:00
|
|
|
.endproc
|
|
|
|
|
2017-09-14 04:35:23 +00:00
|
|
|
.proc query_state_params
|
2017-09-10 01:11:01 +00:00
|
|
|
id: .byte 0
|
2017-09-14 04:35:23 +00:00
|
|
|
.addr state_params
|
2017-09-10 01:11:01 +00:00
|
|
|
.endproc
|
2017-09-14 04:35:23 +00:00
|
|
|
query_state_params_id := query_state_params::id
|
2017-09-08 04:42:58 +00:00
|
|
|
|
2017-09-09 18:08:40 +00:00
|
|
|
;; param block for a 1A call
|
2017-09-06 01:41:13 +00:00
|
|
|
L08D4: .byte $80
|
2017-09-08 04:42:58 +00:00
|
|
|
|
2017-09-09 18:08:40 +00:00
|
|
|
;; param block for a 1A call
|
|
|
|
L08D5: .byte $00
|
|
|
|
|
2017-09-10 02:11:05 +00:00
|
|
|
;;; ==================================================
|
|
|
|
;;; Button Definitions
|
2017-09-06 15:42:33 +00:00
|
|
|
|
|
|
|
button_width := 17
|
|
|
|
button_height := 9
|
|
|
|
|
|
|
|
col1_left := 13
|
2017-09-07 02:05:49 +00:00
|
|
|
col1_right := col1_left+button_width ; 30
|
2017-09-06 15:42:33 +00:00
|
|
|
col2_left := 42
|
2017-09-07 02:05:49 +00:00
|
|
|
col2_right := col2_left+button_width ; 59
|
2017-09-06 15:42:33 +00:00
|
|
|
col3_left := 70
|
2017-09-07 02:05:49 +00:00
|
|
|
col3_right := col3_left+button_width ; 87
|
2017-09-06 15:42:33 +00:00
|
|
|
col4_left := 98
|
2017-09-07 02:05:49 +00:00
|
|
|
col4_right := col4_left+button_width ; 115
|
2017-09-06 15:42:33 +00:00
|
|
|
|
|
|
|
row1_top := 22
|
2017-09-07 02:05:49 +00:00
|
|
|
row1_bot := row1_top+button_height ; 31
|
2017-09-06 15:42:33 +00:00
|
|
|
row2_top := 38
|
2017-09-07 02:05:49 +00:00
|
|
|
row2_bot := row2_top+button_height ; 47
|
2017-09-06 15:42:33 +00:00
|
|
|
row3_top := 53
|
2017-09-07 02:05:49 +00:00
|
|
|
row3_bot := row3_top+button_height ; 62
|
2017-09-06 15:42:33 +00:00
|
|
|
row4_top := 68
|
2017-09-07 02:05:49 +00:00
|
|
|
row4_bot := row4_top+button_height ; 77
|
2017-09-06 15:42:33 +00:00
|
|
|
row5_top := 83
|
2017-09-07 02:05:49 +00:00
|
|
|
row5_bot := row5_top+button_height ; 92
|
2017-09-06 15:42:33 +00:00
|
|
|
|
2017-09-08 08:00:58 +00:00
|
|
|
border_lt := 1 ; border width pixels (left/top)
|
|
|
|
border_br := 2 ; (bottom/right)
|
2017-09-06 15:42:33 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_c
|
2017-09-08 05:13:24 +00:00
|
|
|
.word col1_left - border_lt
|
|
|
|
.word row1_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00 ; ???
|
2017-09-08 05:13:24 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word button_height + border_lt + border_br
|
2017-09-08 04:42:58 +00:00
|
|
|
label: .byte 'c'
|
2017-09-08 07:42:45 +00:00
|
|
|
pos: .word col1_left + 6, row1_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col1_left,row1_top,col1_right,row1_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_e
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col2_left - border_lt
|
|
|
|
.word row1_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word button_height + border_lt + border_br
|
|
|
|
label: .byte 'e'
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col2_left + 6, row1_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col2_left,row1_top,col2_right,row1_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_eq
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col3_left - border_lt
|
|
|
|
.word row1_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word button_height + border_lt + border_br
|
|
|
|
label: .byte '='
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col3_left + 6, row1_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col3_left,row1_top,col3_right,row1_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_mul
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col4_left - border_lt
|
|
|
|
.word row1_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word button_height + border_lt + border_br
|
|
|
|
label: .byte '*'
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col4_left + 6, row1_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col4_left,row1_top,col4_right,row1_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_7
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col1_left - border_lt
|
|
|
|
.word row2_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word button_height + border_lt + border_br
|
|
|
|
label: .byte '7'
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col1_left + 6, row2_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col1_left,row2_top,col1_right,row2_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_8
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col2_left - border_lt
|
|
|
|
.word row2_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word button_height + border_lt + border_br
|
|
|
|
label: .byte '8'
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col2_left + 6, row2_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col2_left,row2_top,col2_right,row2_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_9
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col3_left - border_lt
|
|
|
|
.word row2_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word button_height + border_lt + border_br
|
|
|
|
label: .byte '9'
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col3_left + 6, row2_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col3_left,row2_top,col3_right,row2_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_div
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col4_left - border_lt
|
|
|
|
.word row2_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word button_height + border_lt + border_br
|
|
|
|
label: .byte '/'
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col4_left + 6, row2_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col4_left,row2_top,col4_right,row2_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_4
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col1_left - border_lt
|
|
|
|
.word row3_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word button_height + border_lt + border_br
|
|
|
|
label: .byte '4'
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col1_left + 6, row3_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col1_left,row3_top,col1_right,row3_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_5
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col2_left - border_lt
|
|
|
|
.word row3_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word button_height + border_lt + border_br
|
|
|
|
label: .byte '5'
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col2_left + 6, row3_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col2_left,row3_top,col2_right,row3_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_6
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col3_left - border_lt
|
|
|
|
.word row3_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word button_height + border_lt + border_br
|
|
|
|
label: .byte '6'
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col3_left + 6, row3_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col3_left,row3_top,col3_right,row3_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_sub
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col4_left - border_lt
|
|
|
|
.word row3_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word button_height + border_lt + border_br
|
|
|
|
label: .byte '-'
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col4_left + 6, row3_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col4_left,row3_top,col4_right,row3_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_1
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col1_left - border_lt
|
|
|
|
.word row4_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word button_height + border_lt + border_br
|
|
|
|
label: .byte '1'
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col1_left + 6, row4_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col1_left,row4_top,col1_right,row4_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_2
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col2_left - border_lt
|
|
|
|
.word row4_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word button_height + border_lt + border_br
|
|
|
|
label: .byte '2'
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col2_left + 6, row4_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col2_left,row4_top,col2_right,row4_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_3
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col3_left - border_lt
|
|
|
|
.word row4_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word button_height + border_lt + border_br
|
|
|
|
label: .byte '3'
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col3_left + 6, row4_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col3_left,row4_top,col3_right,row4_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_0
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col1_left - border_lt
|
|
|
|
.word row5_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr wide_button_bitmap
|
|
|
|
.byte 8 ; bitmap_stride (bytes)
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word 49 ; 0 is extra wide
|
|
|
|
.word button_height + border_lt + border_br
|
|
|
|
.byte '0'
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col1_left + 6, row5_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col1_left,row5_top,col2_right,row5_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_dec
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col3_left - border_lt
|
|
|
|
.word row5_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word button_height + border_lt + border_br
|
|
|
|
.byte '.'
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col3_left + 6 + 2, row5_bot ; + 2 to center the label
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col3_left,row5_top,col3_right,row5_bot
|
|
|
|
.endproc
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
.proc btn_add
|
2017-09-08 07:10:54 +00:00
|
|
|
.word col4_left - border_lt
|
|
|
|
.word row4_top - border_lt
|
2017-09-15 04:22:27 +00:00
|
|
|
.addr tall_button_bitmap
|
|
|
|
.byte bitmap_stride
|
2017-09-10 02:11:05 +00:00
|
|
|
.byte $00,$00,$00,$00,$00
|
2017-09-08 07:10:54 +00:00
|
|
|
.word button_width + border_lt + border_br
|
|
|
|
.word 27 ; + is extra tall
|
|
|
|
.byte '+'
|
2017-09-08 07:42:45 +00:00
|
|
|
.word col4_left + 6, row5_bot
|
2017-09-08 04:42:58 +00:00
|
|
|
box: .word col4_left,row4_top,col4_right,row5_bot
|
|
|
|
.endproc
|
2017-09-08 04:47:27 +00:00
|
|
|
.byte 0 ; sentinel
|
2017-09-06 15:23:23 +00:00
|
|
|
|
2017-09-15 04:22:27 +00:00
|
|
|
;; Button bitmaps. These are used as bitmaps for
|
2017-09-10 02:11:05 +00:00
|
|
|
;; drawing the shadowed buttons.
|
2017-09-10 00:43:37 +00:00
|
|
|
|
2017-09-15 04:22:27 +00:00
|
|
|
;; bitmaps are low 7 bits, 0=black 1=white
|
|
|
|
bitmap_stride := 3 ; bytes
|
|
|
|
button_bitmap: ; bitmap for normal buttons
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte px(%0000000),px(%0000000),px(%0000001)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0000000),px(%0000000),px(%0000000)
|
|
|
|
.byte px(%1000000),px(%0000000),px(%0000000)
|
|
|
|
|
2017-09-15 04:22:27 +00:00
|
|
|
wide_bitmap_stride := 8
|
|
|
|
wide_button_bitmap: ; bitmap for '0' button
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000),px(%0000000),px(%0000000),px(%0000000),px(%1111111)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111110),px(%0111111)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111110),px(%0111111)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111110),px(%0111111)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111110),px(%0111111)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111110),px(%0111111)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111110),px(%0111111)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111110),px(%0111111)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111110),px(%0111111)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111110),px(%0111111)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111111),px(%1111110),px(%0111111)
|
|
|
|
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000),px(%0000000),px(%0000000),px(%0000000),px(%0111111)
|
|
|
|
.byte px(%1000000),px(%0000000),px(%0000000),px(%0000000),px(%0000000),px(%0000000),px(%0000000),px(%0111111)
|
|
|
|
|
2017-09-15 04:22:27 +00:00
|
|
|
tall_button_bitmap: ; bitmap for '+' button
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte px(%0000000),px(%0000000),px(%0000001)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0111111),px(%1111111),px(%1111100)
|
|
|
|
.byte px(%0000000),px(%0000000),px(%0000000)
|
|
|
|
.byte px(%1000000),px(%0000000),px(%0000000)
|
2017-09-08 07:10:54 +00:00
|
|
|
|
2017-09-06 15:55:53 +00:00
|
|
|
|
2017-09-10 02:11:05 +00:00
|
|
|
;;; ==================================================
|
|
|
|
;;; Calculation state
|
|
|
|
|
2017-09-09 18:08:40 +00:00
|
|
|
saved_stack:
|
|
|
|
.byte $00 ; restored after error
|
2017-09-15 07:53:45 +00:00
|
|
|
calc_p: .byte $00 ; high bit set if pending op?
|
2017-09-08 07:42:45 +00:00
|
|
|
calc_op:.byte $00
|
2017-09-10 00:43:37 +00:00
|
|
|
calc_d: .byte $00 ; '.' if decimal present, 0 otherwise
|
|
|
|
calc_e: .byte $00 ; exponential?
|
|
|
|
calc_n: .byte $00 ; negative?
|
2017-09-15 07:53:45 +00:00
|
|
|
calc_g: .byte $00 ; high bit set if last input digit
|
2017-09-10 00:43:37 +00:00
|
|
|
calc_l: .byte $00 ; input length
|
2017-09-06 05:59:02 +00:00
|
|
|
|
2017-09-10 02:11:05 +00:00
|
|
|
;;; ==================================================
|
|
|
|
;;; Miscellaneous param blocks
|
|
|
|
|
2017-09-07 06:43:40 +00:00
|
|
|
.proc background_box_params
|
|
|
|
left: .word 1
|
|
|
|
top: .word 0
|
|
|
|
right: .word 129
|
|
|
|
bottom: .word 96
|
2017-09-06 05:59:02 +00:00
|
|
|
.endproc
|
|
|
|
|
2017-09-06 05:19:45 +00:00
|
|
|
background_pattern:
|
|
|
|
.byte $77,$DD,$77,$DD,$77,$DD,$77,$DD
|
2017-09-06 01:41:13 +00:00
|
|
|
.byte $00
|
2017-09-06 05:19:45 +00:00
|
|
|
|
|
|
|
black_pattern:
|
2017-09-14 04:01:30 +00:00
|
|
|
.res 8, $00
|
2017-09-06 01:41:13 +00:00
|
|
|
.byte $00
|
2017-09-06 05:19:45 +00:00
|
|
|
|
|
|
|
white_pattern:
|
2017-09-14 04:01:30 +00:00
|
|
|
.res 8, $FF
|
2017-09-06 01:41:13 +00:00
|
|
|
.byte $00
|
2017-09-06 05:19:45 +00:00
|
|
|
|
2017-09-15 07:53:45 +00:00
|
|
|
;; arg for $0C call ???
|
2017-09-06 01:41:13 +00:00
|
|
|
L0BEF: .byte $7F
|
2017-09-06 05:59:02 +00:00
|
|
|
|
2017-09-08 15:36:36 +00:00
|
|
|
display_left := 10
|
|
|
|
display_top := 5
|
|
|
|
display_width := 120
|
|
|
|
display_height := 17
|
|
|
|
|
2017-09-07 06:43:40 +00:00
|
|
|
.proc frame_display_params
|
2017-09-08 15:36:36 +00:00
|
|
|
left: .word display_left
|
|
|
|
top: .word display_top
|
|
|
|
width: .word display_width
|
|
|
|
height: .word display_height
|
2017-09-07 06:43:40 +00:00
|
|
|
.endproc
|
|
|
|
|
|
|
|
.proc clear_display_params
|
2017-09-08 15:36:36 +00:00
|
|
|
left: .word display_left+1
|
|
|
|
top: .word display_top+1
|
|
|
|
width: .word display_width-1
|
|
|
|
height: .word display_height-1
|
2017-09-06 05:59:02 +00:00
|
|
|
.endproc
|
|
|
|
|
2017-09-06 06:37:05 +00:00
|
|
|
;; For drawing 1-character strings (button labels)
|
|
|
|
.proc draw_text_params_label
|
|
|
|
.addr label
|
|
|
|
.byte 1
|
|
|
|
.endproc
|
|
|
|
label: .byte 0 ; modified with char to draw
|
2017-09-06 06:24:21 +00:00
|
|
|
|
|
|
|
.proc draw_text_params1
|
2017-09-06 06:37:05 +00:00
|
|
|
addr: .addr text_buffer1
|
2017-09-06 06:24:21 +00:00
|
|
|
length: .byte 15
|
|
|
|
.endproc
|
|
|
|
|
2017-09-06 06:55:44 +00:00
|
|
|
text_buffer_size := 14
|
|
|
|
|
2017-09-06 06:24:21 +00:00
|
|
|
text_buffer1:
|
2017-09-14 04:01:30 +00:00
|
|
|
.res text_buffer_size+2, 0
|
2017-09-06 06:37:05 +00:00
|
|
|
|
|
|
|
.proc draw_text_params2
|
|
|
|
addr: .addr text_buffer2
|
|
|
|
length: .byte 15
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
text_buffer2:
|
2017-09-14 04:01:30 +00:00
|
|
|
.res text_buffer_size+2, 0
|
2017-09-06 06:37:05 +00:00
|
|
|
|
|
|
|
spaces_string:
|
|
|
|
A2D_DEFSTRING " "
|
|
|
|
error_string:
|
|
|
|
A2D_DEFSTRING "Error "
|
2017-09-06 06:24:21 +00:00
|
|
|
|
2017-09-08 15:36:36 +00:00
|
|
|
;; used when clearing display; params to a $18 call
|
|
|
|
.proc measure_text_params
|
|
|
|
addr: .addr text_buffer1
|
|
|
|
len: .byte 15 ; ???
|
|
|
|
width: .word 0
|
|
|
|
.endproc
|
2017-09-06 06:24:21 +00:00
|
|
|
|
2017-09-07 02:38:06 +00:00
|
|
|
window_id = $34
|
|
|
|
|
2017-09-06 06:24:21 +00:00
|
|
|
.proc destroy_window_params
|
2017-09-07 02:38:06 +00:00
|
|
|
id: .byte window_id
|
2017-09-06 06:24:21 +00:00
|
|
|
.endproc
|
2017-09-06 05:59:02 +00:00
|
|
|
|
|
|
|
.proc text_pos_params3
|
|
|
|
left: .word 0
|
|
|
|
base: .word 16
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
.proc text_pos_params2
|
|
|
|
left: .word 15
|
|
|
|
base: .word 16
|
|
|
|
.endproc
|
|
|
|
|
2017-09-10 02:11:05 +00:00
|
|
|
.proc error_pos
|
|
|
|
left: .word 69
|
|
|
|
base: .word 16
|
|
|
|
.endproc
|
2017-09-07 03:43:12 +00:00
|
|
|
|
2017-09-14 04:01:30 +00:00
|
|
|
farg: .byte $00,$00,$00,$00,$00,$00
|
2017-09-08 04:42:58 +00:00
|
|
|
|
2017-09-14 04:58:37 +00:00
|
|
|
.proc title_bar_decoration ; Params for A2D_DRAW_BITMAP
|
2017-09-10 00:43:37 +00:00
|
|
|
left: .word 115 ; overwritten
|
|
|
|
top: .word $FFF7 ; overwritten
|
2017-09-15 04:22:27 +00:00
|
|
|
bitmap:.addr pixels
|
2017-09-10 00:43:37 +00:00
|
|
|
stride: .byte 1
|
|
|
|
.byte 0,0,0,0,0 ; ???
|
|
|
|
width: .word 6
|
|
|
|
height: .word 5
|
|
|
|
;; (not part of struct, but not referenced outside)
|
|
|
|
pixels: .byte px(%1000001)
|
|
|
|
.byte px(%1010110)
|
|
|
|
.byte px(%1110001)
|
|
|
|
.byte px(%1110110)
|
|
|
|
.byte px(%0110110)
|
|
|
|
.byte px(%1001001)
|
|
|
|
.endproc
|
|
|
|
|
2017-09-14 04:35:23 +00:00
|
|
|
;; param block for a QUERY_SCREEN and SET_STATE calls, and ref'd in QUERY_STATE call
|
|
|
|
.proc state_params
|
2017-09-10 00:43:37 +00:00
|
|
|
left: .word 0
|
|
|
|
top: .word 0
|
2017-09-10 01:28:15 +00:00
|
|
|
addr: .word 0
|
|
|
|
stride: .word 0
|
2017-09-10 00:43:37 +00:00
|
|
|
hoffset:.word 0
|
|
|
|
voffset:.word 0
|
2017-09-14 04:01:30 +00:00
|
|
|
width: .word 0
|
|
|
|
height: .word 0
|
|
|
|
pattern:.res 8, 0
|
2017-09-14 04:35:23 +00:00
|
|
|
mskand: .byte 0
|
|
|
|
mskor: .byte 0
|
|
|
|
.byte 0,0,0,0 ; ???
|
2017-09-14 04:01:30 +00:00
|
|
|
hthick: .byte 0
|
|
|
|
vthick: .byte 0
|
|
|
|
.byte 0,0,0,0,0 ; ???
|
2017-09-10 00:43:37 +00:00
|
|
|
.endproc
|
2017-09-08 04:42:58 +00:00
|
|
|
|
2017-09-10 01:11:01 +00:00
|
|
|
menu_bar_height := 13
|
|
|
|
screen_width := 560
|
|
|
|
screen_height := 192
|
|
|
|
|
2017-09-14 04:35:23 +00:00
|
|
|
;; params for A2D_SET_BOX when decorating title bar
|
2017-09-10 01:11:01 +00:00
|
|
|
.proc screen_box
|
|
|
|
.word 0
|
|
|
|
.word menu_bar_height
|
2017-09-10 01:28:15 +00:00
|
|
|
.word A2D_SCREEN_ADDR
|
|
|
|
.word A2D_SCREEN_STRIDE
|
2017-09-10 01:11:01 +00:00
|
|
|
.word 0, 0 ; hoffset/voffset
|
|
|
|
.word screen_width - 1
|
|
|
|
.word screen_height - menu_bar_height - 2
|
|
|
|
.endproc
|
2017-09-08 04:42:58 +00:00
|
|
|
|
2017-09-10 17:40:08 +00:00
|
|
|
.proc fill_mode_normal
|
|
|
|
mode: .byte A2D_SFM_NORMAL
|
|
|
|
.endproc
|
|
|
|
|
2017-09-10 00:43:37 +00:00
|
|
|
.byte $01,$02 ; ??
|
|
|
|
|
2017-09-10 17:40:08 +00:00
|
|
|
.proc fill_mode_xor
|
|
|
|
mode: .byte A2D_SFM_XOR
|
|
|
|
.endproc
|
2017-09-06 05:59:02 +00:00
|
|
|
|
2017-09-09 18:08:40 +00:00
|
|
|
window_width := 130
|
|
|
|
window_height := 96
|
|
|
|
default_left := 210
|
|
|
|
default_top := 60
|
|
|
|
|
|
|
|
.proc create_window_params
|
|
|
|
id: .byte window_id
|
|
|
|
flags: .byte $02
|
2017-09-06 06:24:21 +00:00
|
|
|
.addr title
|
2017-09-09 18:08:40 +00:00
|
|
|
hscroll:.byte 0
|
|
|
|
vscroll:.byte 0
|
|
|
|
hs_max: .byte 0
|
|
|
|
hs_pos: .byte 0
|
|
|
|
vs_max: .byte 0
|
|
|
|
vs_pos: .byte 0
|
|
|
|
.byte 0,0 ; ???
|
2017-09-14 04:01:30 +00:00
|
|
|
w1: .word window_width
|
|
|
|
h1: .word window_height
|
|
|
|
w2: .word window_width
|
|
|
|
h2: .word window_height
|
2017-09-09 18:08:40 +00:00
|
|
|
left: .word default_left
|
|
|
|
top: .word default_top
|
2017-09-10 01:28:15 +00:00
|
|
|
.word A2D_SCREEN_ADDR
|
|
|
|
.word A2D_SCREEN_STRIDE
|
2017-09-09 18:08:40 +00:00
|
|
|
hoffset:.word 0
|
|
|
|
voffset:.word 0
|
|
|
|
width: .word window_width
|
|
|
|
height: .word window_height
|
2017-09-14 04:01:30 +00:00
|
|
|
pattern:.res 8, $FF
|
2017-09-15 08:02:38 +00:00
|
|
|
mskand: .byte A2D_DEFAULT_MSKAND
|
|
|
|
mskor: .byte A2D_DEFAULT_MSKOR
|
2017-09-14 04:35:23 +00:00
|
|
|
.byte 0,0,0,0 ; ???
|
2017-09-14 03:09:36 +00:00
|
|
|
hthick: .byte 1
|
|
|
|
vthick: .byte 1
|
2017-09-14 04:01:30 +00:00
|
|
|
.byte $00,$7F,$00,$88,$00,$00 ; ???
|
2017-09-14 03:09:36 +00:00
|
|
|
.endproc
|
|
|
|
create_window_params_top := create_window_params::top
|
2017-09-06 06:24:21 +00:00
|
|
|
|
|
|
|
title: PASCAL_STRING "Calc"
|
2017-09-09 18:08:40 +00:00
|
|
|
|
|
|
|
;; param block for $24 call (just before entering input loop)
|
2017-09-06 01:41:13 +00:00
|
|
|
L0CE6: .byte $00,$00,$02,$00,$06,$00,$0E,$00
|
|
|
|
.byte $1E,$00,$3E,$00,$7E,$00,$1A,$00
|
|
|
|
.byte $30,$00,$30,$00,$60,$00,$00,$00
|
|
|
|
.byte $03,$00,$07,$00,$0F,$00,$1F,$00
|
|
|
|
.byte $3F,$00,$7F,$00,$7F,$01,$7F,$00
|
|
|
|
.byte $78,$00,$78,$00,$70,$01,$70,$01
|
|
|
|
.byte $01,$01
|
2017-09-06 05:19:45 +00:00
|
|
|
|
2017-09-08 08:00:58 +00:00
|
|
|
;;; ==================================================
|
|
|
|
;;; DA Init
|
|
|
|
|
2017-09-15 04:22:27 +00:00
|
|
|
init: sta ALTZPON
|
2017-09-06 01:41:13 +00:00
|
|
|
lda LCBANK1
|
|
|
|
lda LCBANK1
|
2017-09-06 02:08:11 +00:00
|
|
|
A2D_CALL $1A, L08D4
|
2017-09-06 05:59:02 +00:00
|
|
|
A2D_CALL A2D_CREATE_WINDOW, create_window_params
|
2017-09-14 04:35:23 +00:00
|
|
|
A2D_CALL A2D_QUERY_SCREEN, state_params
|
|
|
|
A2D_CALL A2D_SET_STATE, state_params ; set clipping bounds?
|
2017-09-10 17:40:08 +00:00
|
|
|
A2D_CALL $2B ; reset drawing state?
|
2017-09-06 01:41:13 +00:00
|
|
|
lda #$01
|
2017-09-09 03:13:09 +00:00
|
|
|
sta input_state_params::state
|
|
|
|
A2D_CALL $2D, input_state_params
|
|
|
|
A2D_CALL A2D_GET_INPUT, input_state_params
|
2017-09-06 05:19:45 +00:00
|
|
|
lda ROMIN2
|
2017-09-08 07:42:45 +00:00
|
|
|
jsr reset_buffer2
|
2017-09-07 02:38:06 +00:00
|
|
|
lda #window_id
|
2017-09-10 04:15:01 +00:00
|
|
|
jsr draw_window
|
2017-09-08 15:36:36 +00:00
|
|
|
jsr reset_buffers_and_display
|
2017-09-08 07:42:45 +00:00
|
|
|
|
|
|
|
lda #'=' ; last operation
|
|
|
|
sta calc_op
|
|
|
|
|
|
|
|
lda #0 ; clear registers
|
2017-09-15 07:53:45 +00:00
|
|
|
sta calc_p
|
2017-09-10 00:43:37 +00:00
|
|
|
sta calc_d
|
|
|
|
sta calc_e
|
|
|
|
sta calc_n
|
2017-09-15 07:53:45 +00:00
|
|
|
sta calc_g
|
2017-09-10 00:43:37 +00:00
|
|
|
sta calc_l
|
2017-09-08 07:42:45 +00:00
|
|
|
|
2017-09-08 15:36:36 +00:00
|
|
|
.proc copy_to_b1
|
|
|
|
ldx #(end_adjust_txtptr_copied - adjust_txtptr_copied + 4) ; should be just + 1 ?
|
|
|
|
loop: lda adjust_txtptr_copied-1,x
|
|
|
|
sta adjust_txtptr-1,x
|
2017-09-06 01:41:13 +00:00
|
|
|
dex
|
2017-09-08 07:42:45 +00:00
|
|
|
bne loop
|
|
|
|
.endproc
|
|
|
|
|
2017-09-08 15:36:36 +00:00
|
|
|
lda #0 ; Turn off errors
|
|
|
|
sta ERRFLG
|
|
|
|
|
2017-09-09 18:27:35 +00:00
|
|
|
lda #<error_hook ; set up FP error handler
|
2017-09-09 18:08:40 +00:00
|
|
|
sta COUT_HOOK
|
|
|
|
lda #>error_hook
|
|
|
|
sta COUT_HOOK+1
|
2017-09-08 15:36:36 +00:00
|
|
|
|
|
|
|
lda #1
|
2017-09-06 01:41:13 +00:00
|
|
|
jsr FLOAT
|
2017-09-07 03:43:12 +00:00
|
|
|
ldx #<farg
|
|
|
|
ldy #>farg
|
2017-09-06 01:41:13 +00:00
|
|
|
jsr ROUND
|
2017-09-08 15:36:36 +00:00
|
|
|
lda #0 ; set FAC to 0
|
2017-09-06 01:41:13 +00:00
|
|
|
jsr FLOAT
|
|
|
|
jsr FADD
|
|
|
|
jsr FOUT
|
|
|
|
lda #$07
|
|
|
|
jsr FMULT
|
|
|
|
lda #$00
|
|
|
|
jsr FLOAT
|
2017-09-07 03:43:12 +00:00
|
|
|
ldx #<farg
|
|
|
|
ldy #>farg
|
2017-09-06 01:41:13 +00:00
|
|
|
jsr ROUND
|
2017-09-09 18:27:35 +00:00
|
|
|
|
2017-09-06 01:41:13 +00:00
|
|
|
tsx
|
2017-09-09 18:08:40 +00:00
|
|
|
stx saved_stack
|
2017-09-09 18:27:35 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
lda #'='
|
|
|
|
jsr process_key
|
|
|
|
lda #'C'
|
|
|
|
jsr process_key
|
2017-09-09 18:27:35 +00:00
|
|
|
|
2017-09-06 02:08:11 +00:00
|
|
|
A2D_CALL $24, L0CE6
|
2017-09-08 08:00:58 +00:00
|
|
|
;; fall through
|
|
|
|
|
|
|
|
;;; ==================================================
|
|
|
|
;;; Input Loop
|
2017-09-08 07:42:45 +00:00
|
|
|
|
|
|
|
input_loop:
|
2017-09-09 03:13:09 +00:00
|
|
|
A2D_CALL A2D_GET_INPUT, input_state_params
|
|
|
|
lda input_state_params::state
|
|
|
|
cmp #A2D_INPUT_DOWN
|
2017-09-09 01:34:34 +00:00
|
|
|
bne :+
|
2017-09-08 03:59:38 +00:00
|
|
|
jsr on_click
|
2017-09-08 07:42:45 +00:00
|
|
|
jmp input_loop
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-09 03:13:09 +00:00
|
|
|
: cmp #A2D_INPUT_KEY
|
2017-09-08 07:42:45 +00:00
|
|
|
bne input_loop
|
2017-09-09 03:13:09 +00:00
|
|
|
jsr on_key_press
|
2017-09-08 07:42:45 +00:00
|
|
|
jmp input_loop
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 08:00:58 +00:00
|
|
|
;;; ==================================================
|
|
|
|
;;; On Click
|
|
|
|
|
2017-09-08 03:59:38 +00:00
|
|
|
on_click:
|
|
|
|
lda LCBANK1
|
2017-09-06 01:41:13 +00:00
|
|
|
lda LCBANK1
|
2017-09-09 03:45:11 +00:00
|
|
|
A2D_CALL A2D_QUERY_TARGET, target_params
|
2017-09-06 05:19:45 +00:00
|
|
|
lda ROMIN2
|
2017-09-09 03:45:11 +00:00
|
|
|
lda target_params::elem
|
2017-09-08 03:59:38 +00:00
|
|
|
cmp #A2D_ELEM_CLIENT ; Less than CLIENT is MENU or DESKTOP
|
|
|
|
bcc ignore_click
|
2017-09-09 03:45:11 +00:00
|
|
|
lda target_params::id
|
2017-09-08 03:59:38 +00:00
|
|
|
cmp #window_id ; This window?
|
|
|
|
beq :+
|
|
|
|
|
|
|
|
ignore_click:
|
|
|
|
rts
|
|
|
|
|
2017-09-09 03:45:11 +00:00
|
|
|
: lda target_params::elem
|
2017-09-08 03:59:38 +00:00
|
|
|
cmp #A2D_ELEM_CLIENT ; Client area?
|
|
|
|
bne :+
|
2017-09-08 08:00:58 +00:00
|
|
|
jsr map_click_to_button ; try to translate click into key
|
2017-09-08 03:59:38 +00:00
|
|
|
bcc ignore_click
|
2017-09-07 03:43:12 +00:00
|
|
|
jmp process_key
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 03:59:38 +00:00
|
|
|
: cmp #A2D_ELEM_CLOSE ; Close box?
|
|
|
|
bne :+
|
2017-09-10 01:43:32 +00:00
|
|
|
A2D_CALL A2D_CLOSE_CLICK, close_click_params
|
|
|
|
lda close_click_params::state
|
2017-09-08 03:59:38 +00:00
|
|
|
beq ignore_click
|
2017-09-07 06:43:40 +00:00
|
|
|
exit: lda LCBANK1
|
2017-09-06 01:41:13 +00:00
|
|
|
lda LCBANK1
|
2017-09-06 06:24:21 +00:00
|
|
|
A2D_CALL A2D_DESTROY_WINDOW, destroy_window_params
|
2017-09-06 01:41:13 +00:00
|
|
|
jsr UNKNOWN_CALL
|
|
|
|
.byte $0C
|
|
|
|
.addr 0
|
2017-09-06 05:19:45 +00:00
|
|
|
lda ROMIN2
|
2017-09-10 17:40:08 +00:00
|
|
|
A2D_CALL $1A, L08D5 ; ??? one byte input value?
|
2017-09-08 03:59:38 +00:00
|
|
|
|
|
|
|
.proc do_close
|
|
|
|
;; Copy following routine to ZP and invoke it
|
|
|
|
zp_stash := $20
|
|
|
|
|
|
|
|
ldx #(routine_end - routine)
|
|
|
|
loop: lda routine,x
|
|
|
|
sta zp_stash,x
|
2017-09-06 01:41:13 +00:00
|
|
|
dex
|
2017-09-08 03:59:38 +00:00
|
|
|
bpl loop
|
|
|
|
jmp zp_stash
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 03:59:38 +00:00
|
|
|
.proc routine
|
2017-09-08 08:00:58 +00:00
|
|
|
sta RAMRDOFF
|
2017-09-06 01:41:13 +00:00
|
|
|
sta RAMWRTOFF
|
2017-09-06 05:19:45 +00:00
|
|
|
jmp exit_da
|
2017-09-08 03:59:38 +00:00
|
|
|
.endproc
|
|
|
|
routine_end := * ; Can't use .sizeof before the .proc definition
|
|
|
|
.endproc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 03:59:38 +00:00
|
|
|
: cmp #A2D_ELEM_TITLE ; Title bar?
|
|
|
|
bne ignore_click
|
2017-09-07 02:38:06 +00:00
|
|
|
lda #window_id
|
2017-09-09 04:10:56 +00:00
|
|
|
sta drag_params::id
|
2017-09-06 01:41:13 +00:00
|
|
|
lda LCBANK1
|
|
|
|
lda LCBANK1
|
2017-09-09 04:10:56 +00:00
|
|
|
A2D_CALL A2D_DRAG_WINDOW, drag_params
|
2017-09-06 05:19:45 +00:00
|
|
|
lda ROMIN2
|
2017-09-09 04:10:56 +00:00
|
|
|
jsr call_4015_main ; redraws window
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
|
|
|
|
2017-09-08 08:00:58 +00:00
|
|
|
;;; ==================================================
|
|
|
|
;;; On Key Press
|
|
|
|
|
2017-09-09 03:13:09 +00:00
|
|
|
.proc on_key_press
|
|
|
|
lda input_state_params::modifiers
|
2017-09-07 03:43:12 +00:00
|
|
|
bne bail
|
2017-09-09 03:13:09 +00:00
|
|
|
lda input_state_params::key
|
2017-09-15 04:13:54 +00:00
|
|
|
cmp #KEY_ESCAPE
|
2017-09-07 03:43:12 +00:00
|
|
|
bne trydel
|
2017-09-15 07:53:45 +00:00
|
|
|
lda calc_p
|
2017-09-07 06:43:40 +00:00
|
|
|
bne clear ; empty state?
|
2017-09-10 00:43:37 +00:00
|
|
|
lda calc_l
|
2017-09-07 06:43:40 +00:00
|
|
|
beq exit ; if so, exit DA
|
|
|
|
clear: lda #'C' ; otherwise turn Escape into Clear
|
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
trydel: cmp #$7F ; Delete?
|
|
|
|
beq :+
|
|
|
|
cmp #$60 ; lowercase range?
|
|
|
|
bcc :+
|
|
|
|
and #$5F ; convert to uppercase
|
|
|
|
: jmp process_key
|
|
|
|
bail:
|
|
|
|
.endproc
|
2017-09-15 04:22:27 +00:00
|
|
|
|
|
|
|
rts1: rts ; used by next proc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 08:00:58 +00:00
|
|
|
;;; ==================================================
|
|
|
|
;;; Try to map a click to a button
|
|
|
|
|
|
|
|
;;; If a button was clicked, carry is set and accum has key char
|
|
|
|
|
|
|
|
.proc map_click_to_button
|
|
|
|
lda #window_id
|
2017-09-09 03:13:09 +00:00
|
|
|
sta map_coords_params::id
|
|
|
|
A2D_CALL A2D_MAP_COORDS, map_coords_params
|
|
|
|
lda map_coords_params::clientx+1 ; ensure high bits of coords are 0
|
|
|
|
ora map_coords_params::clienty+1
|
2017-09-15 04:22:27 +00:00
|
|
|
bne rts1
|
2017-09-09 03:13:09 +00:00
|
|
|
lda map_coords_params::clienty
|
|
|
|
ldx map_coords_params::clientx
|
2017-09-07 02:05:49 +00:00
|
|
|
|
|
|
|
.proc find_button_row
|
2017-09-07 02:38:06 +00:00
|
|
|
cmp #row1_top+border_lt - 1 ; row 1 ? (- 1 is bug in original?)
|
2017-09-07 02:05:49 +00:00
|
|
|
bcc miss
|
2017-09-07 02:38:06 +00:00
|
|
|
cmp #row1_bot+border_br + 1 ; (+ 1 is bug in original?)
|
2017-09-06 06:55:44 +00:00
|
|
|
bcs :+
|
2017-09-07 02:05:49 +00:00
|
|
|
jsr find_button_col
|
|
|
|
bcc miss
|
|
|
|
lda row1_lookup,x
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
|
|
|
|
2017-09-07 02:38:06 +00:00
|
|
|
: cmp #row2_top-border_lt ; row 2?
|
2017-09-07 02:05:49 +00:00
|
|
|
bcc miss
|
2017-09-07 02:38:06 +00:00
|
|
|
cmp #row2_bot+border_br
|
2017-09-06 06:55:44 +00:00
|
|
|
bcs :+
|
2017-09-07 02:05:49 +00:00
|
|
|
jsr find_button_col
|
|
|
|
bcc miss
|
|
|
|
lda row2_lookup,x
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
|
|
|
|
2017-09-07 02:38:06 +00:00
|
|
|
: cmp #row3_top-border_lt ; row 3?
|
2017-09-07 02:05:49 +00:00
|
|
|
bcc miss
|
2017-09-07 02:38:06 +00:00
|
|
|
cmp #row3_bot+border_br
|
2017-09-06 06:55:44 +00:00
|
|
|
bcs :+
|
2017-09-07 02:05:49 +00:00
|
|
|
jsr find_button_col
|
|
|
|
bcc miss
|
|
|
|
lda row3_lookup,x
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
|
|
|
|
2017-09-07 02:38:06 +00:00
|
|
|
: cmp #row4_top-border_lt ; row 4?
|
2017-09-07 02:05:49 +00:00
|
|
|
bcc miss
|
2017-09-07 02:38:06 +00:00
|
|
|
cmp #row4_bot+border_br
|
2017-09-06 06:55:44 +00:00
|
|
|
bcs :+
|
2017-09-07 02:05:49 +00:00
|
|
|
jsr find_button_col
|
|
|
|
bcc miss
|
2017-09-06 01:41:13 +00:00
|
|
|
sec
|
2017-09-07 02:05:49 +00:00
|
|
|
lda row4_lookup,x
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
|
|
|
|
2017-09-08 04:03:07 +00:00
|
|
|
: cmp #row5_top-border_lt ; special case for tall + button
|
2017-09-06 06:55:44 +00:00
|
|
|
bcs :+
|
2017-09-09 03:13:09 +00:00
|
|
|
lda map_coords_params::clientx
|
2017-09-08 04:03:07 +00:00
|
|
|
cmp #col4_left-border_lt
|
2017-09-07 02:05:49 +00:00
|
|
|
bcc miss
|
2017-09-08 04:03:57 +00:00
|
|
|
cmp #col4_right+border_br-1 ; is -1 bug in original?
|
2017-09-07 02:05:49 +00:00
|
|
|
bcs miss
|
|
|
|
lda #'+'
|
2017-09-06 01:41:13 +00:00
|
|
|
sec
|
|
|
|
rts
|
|
|
|
|
2017-09-07 02:38:06 +00:00
|
|
|
: cmp #row5_bot+border_br ; row 5?
|
2017-09-07 02:05:49 +00:00
|
|
|
bcs miss
|
|
|
|
jsr find_button_col
|
2017-09-06 06:55:44 +00:00
|
|
|
bcc :+
|
2017-09-07 02:05:49 +00:00
|
|
|
lda row5_lookup,x
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
|
|
|
|
2017-09-09 03:13:09 +00:00
|
|
|
: lda map_coords_params::clientx ; special case for wide 0 button
|
2017-09-08 04:03:07 +00:00
|
|
|
cmp #col1_left-border_lt
|
2017-09-07 02:05:49 +00:00
|
|
|
bcc miss
|
2017-09-08 04:03:07 +00:00
|
|
|
cmp #col2_right+border_br
|
2017-09-07 02:05:49 +00:00
|
|
|
bcs miss
|
|
|
|
lda #'0'
|
2017-09-06 01:41:13 +00:00
|
|
|
sec
|
|
|
|
rts
|
|
|
|
|
2017-09-07 02:05:49 +00:00
|
|
|
miss: clc
|
|
|
|
rts
|
|
|
|
.endproc
|
2017-09-06 02:08:11 +00:00
|
|
|
|
2017-09-07 02:05:49 +00:00
|
|
|
row1_lookup := *-1
|
|
|
|
.byte 'C', 'E', '=', '*'
|
|
|
|
row2_lookup := *-1
|
|
|
|
.byte '7', '8', '9', '/'
|
|
|
|
row3_lookup := *-1
|
|
|
|
.byte '4', '5', '6', '-'
|
|
|
|
row4_lookup := *-1
|
|
|
|
.byte '1', '2', '3', '+'
|
|
|
|
row5_lookup := *-1
|
|
|
|
.byte '0', '0', '.', '+'
|
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
.proc find_button_col
|
2017-09-07 02:38:06 +00:00
|
|
|
cpx #col1_left-border_lt ; col 1?
|
2017-09-07 03:43:12 +00:00
|
|
|
bcc miss
|
2017-09-07 02:38:06 +00:00
|
|
|
cpx #col1_right+border_br
|
2017-09-06 06:55:44 +00:00
|
|
|
bcs :+
|
2017-09-07 02:05:49 +00:00
|
|
|
ldx #1
|
2017-09-06 01:41:13 +00:00
|
|
|
sec
|
|
|
|
rts
|
|
|
|
|
2017-09-07 02:38:06 +00:00
|
|
|
: cpx #col2_left-border_lt ; col 2?
|
2017-09-07 03:43:12 +00:00
|
|
|
bcc miss
|
2017-09-07 02:38:06 +00:00
|
|
|
cpx #col2_right+border_br
|
2017-09-06 06:55:44 +00:00
|
|
|
bcs :+
|
2017-09-07 02:05:49 +00:00
|
|
|
ldx #2
|
2017-09-06 01:41:13 +00:00
|
|
|
sec
|
|
|
|
rts
|
|
|
|
|
2017-09-07 02:38:06 +00:00
|
|
|
: cpx #col3_left-border_lt ; col 3?
|
2017-09-07 03:43:12 +00:00
|
|
|
bcc miss
|
2017-09-07 02:38:06 +00:00
|
|
|
cpx #col3_right+border_br
|
2017-09-06 06:55:44 +00:00
|
|
|
bcs :+
|
2017-09-07 02:05:49 +00:00
|
|
|
ldx #3
|
2017-09-06 01:41:13 +00:00
|
|
|
sec
|
|
|
|
rts
|
|
|
|
|
2017-09-07 02:38:06 +00:00
|
|
|
: cpx #col4_left-border_lt ; col 4?
|
2017-09-07 03:43:12 +00:00
|
|
|
bcc miss
|
2017-09-07 02:38:06 +00:00
|
|
|
cpx #col4_right+border_br - 1 ; bug in original?
|
2017-09-07 03:43:12 +00:00
|
|
|
bcs miss
|
2017-09-07 02:05:49 +00:00
|
|
|
ldx #4
|
2017-09-06 01:41:13 +00:00
|
|
|
sec
|
|
|
|
rts
|
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
miss: clc
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
2017-09-07 03:43:12 +00:00
|
|
|
.endproc
|
2017-09-08 08:00:58 +00:00
|
|
|
.endproc
|
|
|
|
|
|
|
|
;;; ==================================================
|
|
|
|
;;; Handle Key
|
|
|
|
|
|
|
|
;;; Accumulator is set to key char. Also used by
|
|
|
|
;;; click handlers (button is mapped to key char)
|
|
|
|
;;; and during initialization (by sending 'C', etc)
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
.proc process_key
|
|
|
|
cmp #'C' ; Clear?
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_c::box
|
|
|
|
ldy #>btn_c::box
|
2017-09-09 19:18:06 +00:00
|
|
|
lda #'c'
|
2017-09-07 06:43:40 +00:00
|
|
|
jsr depress_button
|
2017-09-06 01:41:13 +00:00
|
|
|
lda #$00
|
|
|
|
jsr FLOAT
|
2017-09-07 03:43:12 +00:00
|
|
|
ldx #<farg
|
|
|
|
ldy #>farg
|
2017-09-06 01:41:13 +00:00
|
|
|
jsr ROUND
|
2017-09-07 03:43:12 +00:00
|
|
|
lda #'='
|
2017-09-08 07:42:45 +00:00
|
|
|
sta calc_op
|
2017-09-07 03:43:12 +00:00
|
|
|
lda #0
|
2017-09-15 07:53:45 +00:00
|
|
|
sta calc_p
|
2017-09-10 00:43:37 +00:00
|
|
|
sta calc_l
|
|
|
|
sta calc_d
|
|
|
|
sta calc_e
|
|
|
|
sta calc_n
|
2017-09-08 15:36:36 +00:00
|
|
|
jmp reset_buffers_and_display
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
: cmp #'E' ; Exponential?
|
2017-09-15 07:53:45 +00:00
|
|
|
bne try_eq
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_e::box
|
|
|
|
ldy #>btn_e::box
|
2017-09-09 19:18:06 +00:00
|
|
|
lda #'e'
|
2017-09-07 06:43:40 +00:00
|
|
|
jsr depress_button
|
2017-09-10 00:43:37 +00:00
|
|
|
ldy calc_e
|
2017-09-15 07:53:45 +00:00
|
|
|
bne rts1
|
2017-09-10 00:43:37 +00:00
|
|
|
ldy calc_l
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-10 00:43:37 +00:00
|
|
|
inc calc_l
|
2017-09-06 06:37:05 +00:00
|
|
|
lda #'1'
|
2017-09-06 07:00:46 +00:00
|
|
|
sta text_buffer1 + text_buffer_size
|
|
|
|
sta text_buffer2 + text_buffer_size
|
2017-09-06 06:55:44 +00:00
|
|
|
: lda #'E'
|
2017-09-10 00:43:37 +00:00
|
|
|
sta calc_e
|
2017-09-15 07:53:45 +00:00
|
|
|
jmp update
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-15 07:53:45 +00:00
|
|
|
rts1: rts
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-15 07:53:45 +00:00
|
|
|
try_eq: cmp #'=' ; Equals?
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_eq::box
|
|
|
|
ldy #>btn_eq::box
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp do_op_click
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
: cmp #'*' ; Multiply?
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_mul::box
|
|
|
|
ldy #>btn_mul::box
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp do_op_click
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
: cmp #'.' ; Decimal?
|
2017-09-15 04:22:27 +00:00
|
|
|
bne try_add
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_dec::box
|
|
|
|
ldy #>btn_dec::box
|
2017-09-07 06:43:40 +00:00
|
|
|
jsr depress_button
|
2017-09-10 00:43:37 +00:00
|
|
|
lda calc_d
|
|
|
|
ora calc_e
|
2017-09-15 04:22:27 +00:00
|
|
|
bne rts2
|
2017-09-10 00:43:37 +00:00
|
|
|
lda calc_l
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-10 00:43:37 +00:00
|
|
|
inc calc_l
|
2017-09-06 15:55:53 +00:00
|
|
|
: lda #'.'
|
2017-09-10 00:43:37 +00:00
|
|
|
sta calc_d
|
2017-09-15 07:53:45 +00:00
|
|
|
jmp update
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-15 04:22:27 +00:00
|
|
|
rts2: rts
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-15 04:22:27 +00:00
|
|
|
try_add:cmp #'+' ; Add?
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_add::box
|
|
|
|
ldy #>btn_add::box
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp do_op_click
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
: cmp #'-' ; Subtract?
|
|
|
|
bne trydiv
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_sub::box
|
|
|
|
ldy #>btn_sub::box
|
2017-09-10 00:43:37 +00:00
|
|
|
lda calc_e ; negate vs. subtract
|
2017-09-07 03:43:12 +00:00
|
|
|
beq :+
|
2017-09-10 00:43:37 +00:00
|
|
|
lda calc_n
|
2017-09-07 03:43:12 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
sec
|
2017-09-10 00:43:37 +00:00
|
|
|
ror calc_n
|
2017-09-06 01:41:13 +00:00
|
|
|
pla
|
|
|
|
pha
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp do_digit_click
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
: pla
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp do_op_click
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
trydiv: cmp #'/' ; Divide?
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_div::box
|
|
|
|
ldy #>btn_div::box
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp do_op_click
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
: cmp #'0' ; Digit 0?
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_0::box
|
|
|
|
ldy #>btn_0::box
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp do_digit_click
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
: cmp #'1' ; Digit 1?
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_1::box
|
|
|
|
ldy #>btn_1::box
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp do_digit_click
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
: cmp #'2' ; Digit 2?
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_2::box
|
|
|
|
ldy #>btn_2::box
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp do_digit_click
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
: cmp #'3' ; Digit 3?
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_3::box
|
|
|
|
ldy #>btn_3::box
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp do_digit_click
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
: cmp #'4' ; Digit 4?
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_4::box
|
|
|
|
ldy #>btn_4::box
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp do_digit_click
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
: cmp #'5' ; Digit 5?
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_5::box
|
|
|
|
ldy #>btn_5::box
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp do_digit_click
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
: cmp #'6' ; Digit 6?
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_6::box
|
|
|
|
ldy #>btn_6::box
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp do_digit_click
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
: cmp #'7' ; Digit 7?
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_7::box
|
|
|
|
ldy #>btn_7::box
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp do_digit_click
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
: cmp #'8' ; Digit 8?
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_8::box
|
|
|
|
ldy #>btn_8::box
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp do_digit_click
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
: cmp #'9' ; Digit 9?
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-08 04:42:58 +00:00
|
|
|
ldx #<btn_9::box
|
|
|
|
ldy #>btn_9::box
|
2017-09-15 04:22:27 +00:00
|
|
|
jmp do_digit_click
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
: cmp #$7F ; Delete?
|
|
|
|
bne end
|
2017-09-10 00:43:37 +00:00
|
|
|
ldy calc_l
|
2017-09-07 03:43:12 +00:00
|
|
|
beq end
|
2017-09-06 15:55:53 +00:00
|
|
|
cpy #1
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-08 15:36:36 +00:00
|
|
|
jsr reset_buffer1_and_state
|
|
|
|
jmp display_buffer1
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-10 00:43:37 +00:00
|
|
|
: dec calc_l
|
2017-09-06 05:59:02 +00:00
|
|
|
ldx #0
|
2017-09-06 07:00:46 +00:00
|
|
|
lda text_buffer1 + text_buffer_size
|
2017-09-06 05:59:02 +00:00
|
|
|
cmp #'.'
|
2017-09-07 04:33:22 +00:00
|
|
|
bne :+
|
2017-09-10 00:43:37 +00:00
|
|
|
stx calc_d
|
2017-09-07 04:33:22 +00:00
|
|
|
: cmp #'E'
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-10 00:43:37 +00:00
|
|
|
stx calc_e
|
2017-09-06 06:55:44 +00:00
|
|
|
: cmp #'-'
|
|
|
|
bne :+
|
2017-09-10 00:43:37 +00:00
|
|
|
stx calc_n
|
2017-09-07 04:33:22 +00:00
|
|
|
: ldx #text_buffer_size-1
|
|
|
|
loop: lda text_buffer1,x
|
2017-09-06 06:24:21 +00:00
|
|
|
sta text_buffer1+1,x
|
2017-09-06 06:37:05 +00:00
|
|
|
sta text_buffer2+1,x
|
2017-09-06 01:41:13 +00:00
|
|
|
dex
|
|
|
|
dey
|
2017-09-07 04:33:22 +00:00
|
|
|
bne loop
|
2017-09-06 06:55:44 +00:00
|
|
|
lda #' '
|
2017-09-06 06:24:21 +00:00
|
|
|
sta text_buffer1+1,x
|
2017-09-06 06:37:05 +00:00
|
|
|
sta text_buffer2+1,x
|
2017-09-08 15:36:36 +00:00
|
|
|
jmp display_buffer1
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 03:43:12 +00:00
|
|
|
end: rts
|
|
|
|
.endproc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-15 04:22:27 +00:00
|
|
|
do_digit_click:
|
|
|
|
jsr depress_button
|
2017-09-15 07:53:45 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pla
|
|
|
|
rts
|
|
|
|
|
2017-09-15 07:53:45 +00:00
|
|
|
: pla
|
|
|
|
update: sec
|
|
|
|
ror calc_g
|
2017-09-10 00:43:37 +00:00
|
|
|
ldy calc_l
|
2017-09-15 07:53:45 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-08 07:42:45 +00:00
|
|
|
jsr reset_buffer2
|
2017-09-06 01:41:13 +00:00
|
|
|
pla
|
2017-09-15 07:53:45 +00:00
|
|
|
cmp #'0'
|
|
|
|
bne :+
|
2017-09-08 15:36:36 +00:00
|
|
|
jmp display_buffer1
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-15 07:53:45 +00:00
|
|
|
: sec
|
|
|
|
ror calc_p
|
2017-09-06 01:41:13 +00:00
|
|
|
cpy #$0A
|
2017-09-15 07:53:45 +00:00
|
|
|
bcs rts3
|
2017-09-06 01:41:13 +00:00
|
|
|
pha
|
2017-09-10 00:43:37 +00:00
|
|
|
ldy calc_l
|
2017-09-15 07:53:45 +00:00
|
|
|
beq empty
|
2017-09-06 01:41:13 +00:00
|
|
|
lda #$0F
|
|
|
|
sec
|
2017-09-10 00:43:37 +00:00
|
|
|
sbc calc_l
|
2017-09-06 01:41:13 +00:00
|
|
|
tax
|
2017-09-15 07:53:45 +00:00
|
|
|
: lda text_buffer1,x
|
2017-09-06 06:24:21 +00:00
|
|
|
sta text_buffer1-1,x
|
2017-09-06 06:37:05 +00:00
|
|
|
sta text_buffer2-1,x
|
2017-09-06 01:41:13 +00:00
|
|
|
inx
|
|
|
|
dey
|
2017-09-15 07:53:45 +00:00
|
|
|
bne :-
|
|
|
|
empty: inc calc_l
|
2017-09-06 01:41:13 +00:00
|
|
|
pla
|
2017-09-06 07:00:46 +00:00
|
|
|
sta text_buffer1 + text_buffer_size
|
|
|
|
sta text_buffer2 + text_buffer_size
|
2017-09-08 15:36:36 +00:00
|
|
|
jmp display_buffer1
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-15 07:53:45 +00:00
|
|
|
rts3: rts
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-15 07:53:45 +00:00
|
|
|
.proc do_op_click
|
2017-09-15 04:22:27 +00:00
|
|
|
jsr depress_button
|
2017-09-15 07:53:45 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
pla
|
|
|
|
rts
|
|
|
|
|
2017-09-15 07:53:45 +00:00
|
|
|
: lda calc_op
|
2017-09-06 05:59:02 +00:00
|
|
|
cmp #'='
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-15 07:53:45 +00:00
|
|
|
lda calc_g
|
|
|
|
bne reparse
|
2017-09-06 01:41:13 +00:00
|
|
|
lda #$00
|
|
|
|
jsr FLOAT
|
2017-09-15 07:53:45 +00:00
|
|
|
jmp do_op
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-15 07:53:45 +00:00
|
|
|
: lda calc_g
|
|
|
|
bne reparse
|
2017-09-06 01:41:13 +00:00
|
|
|
pla
|
2017-09-08 07:42:45 +00:00
|
|
|
sta calc_op
|
2017-09-08 15:36:36 +00:00
|
|
|
jmp reset_buffer1_and_state
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-15 07:53:45 +00:00
|
|
|
reparse:lda #<text_buffer1
|
2017-09-08 15:36:36 +00:00
|
|
|
sta TXTPTR
|
|
|
|
lda #>text_buffer1
|
|
|
|
sta TXTPTR+1
|
|
|
|
jsr adjust_txtptr
|
2017-09-06 01:41:13 +00:00
|
|
|
jsr FIN
|
2017-09-15 07:53:45 +00:00
|
|
|
|
|
|
|
do_op: pla
|
2017-09-08 07:42:45 +00:00
|
|
|
ldx calc_op
|
2017-09-15 07:53:45 +00:00
|
|
|
sta calc_op
|
2017-09-07 03:43:12 +00:00
|
|
|
lda #<farg
|
|
|
|
ldy #>farg
|
2017-09-06 05:59:02 +00:00
|
|
|
|
|
|
|
cpx #'+'
|
2017-09-06 06:55:44 +00:00
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
jsr FADD
|
2017-09-08 15:36:36 +00:00
|
|
|
jmp post_op
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-06 06:55:44 +00:00
|
|
|
: cpx #'-'
|
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
jsr FSUB
|
2017-09-08 15:36:36 +00:00
|
|
|
jmp post_op
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-06 06:55:44 +00:00
|
|
|
: cpx #'*'
|
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
jsr FMULT
|
2017-09-08 15:36:36 +00:00
|
|
|
jmp post_op
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-06 06:55:44 +00:00
|
|
|
: cpx #'/'
|
|
|
|
bne :+
|
2017-09-06 01:41:13 +00:00
|
|
|
jsr FDIV
|
2017-09-08 15:36:36 +00:00
|
|
|
jmp post_op
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-06 06:55:44 +00:00
|
|
|
: cpx #'='
|
2017-09-08 15:36:36 +00:00
|
|
|
bne post_op
|
2017-09-15 07:53:45 +00:00
|
|
|
ldy calc_g
|
2017-09-08 15:36:36 +00:00
|
|
|
bne post_op
|
|
|
|
jmp reset_buffer1_and_state
|
2017-09-15 07:53:45 +00:00
|
|
|
.endproc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 15:36:36 +00:00
|
|
|
.proc post_op
|
|
|
|
ldx #<farg ; after the FP operation is done
|
2017-09-07 03:43:12 +00:00
|
|
|
ldy #>farg
|
2017-09-06 01:41:13 +00:00
|
|
|
jsr ROUND
|
2017-09-08 15:36:36 +00:00
|
|
|
jsr FOUT ; output as null-terminated string to FBUFFR
|
|
|
|
|
|
|
|
ldy #0 ; count the eize
|
|
|
|
sloop: lda FBUFFR,y
|
|
|
|
beq :+
|
2017-09-06 01:41:13 +00:00
|
|
|
iny
|
2017-09-08 15:36:36 +00:00
|
|
|
bne sloop
|
|
|
|
|
|
|
|
: ldx #text_buffer_size ; copy to text buffers
|
|
|
|
cloop: lda FBUFFR-1,y
|
2017-09-06 06:24:21 +00:00
|
|
|
sta text_buffer1,x
|
2017-09-06 06:37:05 +00:00
|
|
|
sta text_buffer2,x
|
2017-09-06 01:41:13 +00:00
|
|
|
dex
|
|
|
|
dey
|
2017-09-08 15:36:36 +00:00
|
|
|
bne cloop
|
|
|
|
|
|
|
|
cpx #0 ; pad out with spaces if needed
|
|
|
|
bmi end
|
|
|
|
pad: lda #' '
|
2017-09-06 06:24:21 +00:00
|
|
|
sta text_buffer1,x
|
2017-09-06 06:37:05 +00:00
|
|
|
sta text_buffer2,x
|
2017-09-06 01:41:13 +00:00
|
|
|
dex
|
2017-09-08 15:36:36 +00:00
|
|
|
bpl pad
|
|
|
|
end: jsr display_buffer1
|
|
|
|
; fall through
|
|
|
|
.endproc
|
|
|
|
.proc reset_buffer1_and_state
|
|
|
|
jsr reset_buffer1
|
2017-09-06 06:55:44 +00:00
|
|
|
lda #0
|
2017-09-10 00:43:37 +00:00
|
|
|
sta calc_l
|
|
|
|
sta calc_d
|
|
|
|
sta calc_e
|
|
|
|
sta calc_n
|
2017-09-15 07:53:45 +00:00
|
|
|
sta calc_g
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
2017-09-08 15:36:36 +00:00
|
|
|
.endproc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-07 06:43:40 +00:00
|
|
|
.proc depress_button
|
2017-09-09 18:27:35 +00:00
|
|
|
button_state := $FC
|
|
|
|
|
2017-09-07 06:43:40 +00:00
|
|
|
stx invert_addr
|
2017-09-07 04:33:22 +00:00
|
|
|
stx c13_addr
|
2017-09-07 06:43:40 +00:00
|
|
|
stx restore_addr
|
|
|
|
sty invert_addr+1
|
2017-09-07 04:33:22 +00:00
|
|
|
sty c13_addr+1
|
2017-09-07 06:43:40 +00:00
|
|
|
sty restore_addr+1
|
2017-09-06 05:19:45 +00:00
|
|
|
A2D_CALL A2D_SET_PATTERN, black_pattern
|
2017-09-10 17:40:08 +00:00
|
|
|
A2D_CALL A2D_SET_FILL_MODE, fill_mode_xor
|
2017-09-06 01:41:13 +00:00
|
|
|
sec
|
2017-09-09 18:27:35 +00:00
|
|
|
ror button_state
|
|
|
|
|
|
|
|
invert: A2D_CALL A2D_FILL_RECT, 0, invert_addr ; Inverts box
|
|
|
|
|
2017-09-07 04:33:22 +00:00
|
|
|
check_button:
|
2017-09-09 03:13:09 +00:00
|
|
|
A2D_CALL A2D_GET_INPUT, input_state_params
|
|
|
|
lda input_state_params::state
|
|
|
|
cmp #A2D_INPUT_HELD ; Button down?
|
2017-09-07 04:33:22 +00:00
|
|
|
bne done ; Nope, done immediately
|
2017-09-07 02:38:06 +00:00
|
|
|
lda #window_id
|
2017-09-09 03:13:09 +00:00
|
|
|
sta map_coords_params::id
|
2017-09-09 18:27:35 +00:00
|
|
|
|
2017-09-09 03:13:09 +00:00
|
|
|
A2D_CALL A2D_MAP_COORDS, map_coords_params
|
2017-09-09 19:18:06 +00:00
|
|
|
A2D_CALL A2D_SET_POS, map_coords_params::client
|
|
|
|
A2D_CALL A2D_TEST_BOX, 0, c13_addr
|
|
|
|
bne inside
|
2017-09-09 18:27:35 +00:00
|
|
|
|
|
|
|
lda button_state ; outside, not down
|
|
|
|
beq check_button ; so keep looping
|
|
|
|
|
|
|
|
lda #0 ; outside, was down
|
|
|
|
sta button_state ; so set up
|
|
|
|
beq invert ; and show it
|
|
|
|
|
|
|
|
inside: lda button_state ; inside, and down
|
|
|
|
bne check_button ; so keep looking
|
|
|
|
|
|
|
|
sec ; inside, was not down
|
|
|
|
ror button_state ; so set down
|
|
|
|
jmp invert ; and show it
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-09 18:27:35 +00:00
|
|
|
done: lda button_state ; high bit set if button down
|
2017-09-07 06:43:40 +00:00
|
|
|
beq :+
|
|
|
|
A2D_CALL A2D_FILL_RECT, 0, restore_addr ; Inverts back to normal
|
2017-09-10 17:40:08 +00:00
|
|
|
: A2D_CALL A2D_SET_FILL_MODE, fill_mode_normal ; Normal draw mode??
|
2017-09-09 18:27:35 +00:00
|
|
|
lda button_state
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
2017-09-07 04:33:22 +00:00
|
|
|
.endproc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 15:36:36 +00:00
|
|
|
;;; ==================================================
|
|
|
|
;;; Value Display
|
|
|
|
|
2017-09-08 07:42:45 +00:00
|
|
|
.proc reset_buffer1
|
|
|
|
ldy #text_buffer_size
|
|
|
|
loop: lda #' '
|
2017-09-06 06:24:21 +00:00
|
|
|
sta text_buffer1-1,y
|
2017-09-06 01:41:13 +00:00
|
|
|
dey
|
2017-09-08 07:42:45 +00:00
|
|
|
bne loop
|
|
|
|
lda #'0'
|
2017-09-06 07:00:46 +00:00
|
|
|
sta text_buffer1 + text_buffer_size
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
2017-09-08 07:42:45 +00:00
|
|
|
.endproc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 07:42:45 +00:00
|
|
|
.proc reset_buffer2
|
|
|
|
ldy #text_buffer_size
|
|
|
|
loop: lda #' '
|
2017-09-06 06:37:05 +00:00
|
|
|
sta text_buffer2-1,y
|
2017-09-06 01:41:13 +00:00
|
|
|
dey
|
2017-09-08 07:42:45 +00:00
|
|
|
bne loop
|
2017-09-06 07:00:46 +00:00
|
|
|
lda #'0'
|
|
|
|
sta text_buffer2 + text_buffer_size
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
2017-09-08 07:42:45 +00:00
|
|
|
.endproc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 15:36:36 +00:00
|
|
|
.proc reset_buffers_and_display
|
|
|
|
jsr reset_buffer1
|
2017-09-08 07:42:45 +00:00
|
|
|
jsr reset_buffer2
|
2017-09-08 15:36:36 +00:00
|
|
|
; fall through
|
|
|
|
.endproc
|
|
|
|
.proc display_buffer1
|
|
|
|
ldx #<text_buffer1
|
2017-09-08 07:42:45 +00:00
|
|
|
ldy #>text_buffer1
|
2017-09-08 15:36:36 +00:00
|
|
|
jsr pre_display_buffer
|
2017-09-06 06:24:21 +00:00
|
|
|
A2D_CALL A2D_DRAW_TEXT, draw_text_params1
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
2017-09-08 15:36:36 +00:00
|
|
|
.endproc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 15:36:36 +00:00
|
|
|
.proc display_buffer2
|
|
|
|
ldx #<text_buffer2
|
|
|
|
ldy #>text_buffer2
|
|
|
|
jsr pre_display_buffer
|
2017-09-06 06:37:05 +00:00
|
|
|
A2D_CALL A2D_DRAW_TEXT, draw_text_params2
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
2017-09-08 07:42:45 +00:00
|
|
|
.endproc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 15:36:36 +00:00
|
|
|
.proc pre_display_buffer
|
|
|
|
stx measure_text_params::addr ; text buffer address in x,y
|
|
|
|
sty measure_text_params::addr+1
|
|
|
|
A2D_CALL A2D_MEASURE_TEXT, measure_text_params
|
|
|
|
lda #display_width-15 ; ???
|
2017-09-06 01:41:13 +00:00
|
|
|
sec
|
2017-09-08 15:36:36 +00:00
|
|
|
sbc measure_text_params::width
|
2017-09-06 05:59:02 +00:00
|
|
|
sta text_pos_params3::left
|
2017-09-09 19:18:06 +00:00
|
|
|
A2D_CALL A2D_SET_POS, text_pos_params2 ; clear with spaces
|
2017-09-06 06:37:05 +00:00
|
|
|
A2D_CALL A2D_DRAW_TEXT, spaces_string
|
2017-09-09 19:18:06 +00:00
|
|
|
A2D_CALL A2D_SET_POS, text_pos_params3 ; set up for display
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
2017-09-08 07:42:45 +00:00
|
|
|
.endproc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 08:00:58 +00:00
|
|
|
;;; ==================================================
|
|
|
|
;;; Draw the window contents (background, buttons)
|
|
|
|
|
2017-09-10 04:15:01 +00:00
|
|
|
.proc draw_background
|
2017-09-07 06:43:40 +00:00
|
|
|
;; Frame
|
|
|
|
A2D_CALL A2D_HIDE_CURSOR
|
2017-09-06 05:19:45 +00:00
|
|
|
A2D_CALL A2D_SET_PATTERN, background_pattern
|
2017-09-07 06:43:40 +00:00
|
|
|
A2D_CALL A2D_FILL_RECT, background_box_params
|
2017-09-06 05:19:45 +00:00
|
|
|
A2D_CALL A2D_SET_PATTERN, black_pattern
|
2017-09-07 06:43:40 +00:00
|
|
|
A2D_CALL A2D_DRAW_RECT, frame_display_params
|
2017-09-06 05:19:45 +00:00
|
|
|
A2D_CALL A2D_SET_PATTERN, white_pattern
|
2017-09-07 06:43:40 +00:00
|
|
|
A2D_CALL A2D_FILL_RECT, clear_display_params
|
2017-09-10 04:15:01 +00:00
|
|
|
|
2017-09-07 06:43:40 +00:00
|
|
|
A2D_CALL $0C, L0BEF ; ???
|
2017-09-10 04:15:01 +00:00
|
|
|
;; fall through
|
|
|
|
.endproc
|
2017-09-07 06:43:40 +00:00
|
|
|
|
2017-09-10 04:15:01 +00:00
|
|
|
.proc draw_buttons
|
2017-09-07 06:43:40 +00:00
|
|
|
;; Buttons
|
|
|
|
ptr := $FA
|
2017-09-08 04:42:58 +00:00
|
|
|
|
|
|
|
lda #<btn_c
|
2017-09-07 06:43:40 +00:00
|
|
|
sta ptr
|
2017-09-08 04:42:58 +00:00
|
|
|
lda #>btn_c
|
2017-09-07 06:43:40 +00:00
|
|
|
sta ptr+1
|
|
|
|
loop: ldy #0
|
|
|
|
lda (ptr),y
|
2017-09-08 04:42:58 +00:00
|
|
|
beq draw_title_bar ; done!
|
2017-09-08 07:42:45 +00:00
|
|
|
|
|
|
|
lda ptr ; address for shadowed rect params
|
2017-09-14 04:58:37 +00:00
|
|
|
sta bitmap_addr
|
2017-09-07 06:43:40 +00:00
|
|
|
ldy ptr+1
|
2017-09-14 04:58:37 +00:00
|
|
|
sty bitmap_addr+1
|
2017-09-08 07:42:45 +00:00
|
|
|
|
|
|
|
clc ; address for label pos
|
|
|
|
adc #(btn_c::pos - btn_c)
|
2017-09-07 06:43:40 +00:00
|
|
|
sta text_addr
|
|
|
|
bcc :+
|
2017-09-06 01:41:13 +00:00
|
|
|
iny
|
2017-09-07 06:43:40 +00:00
|
|
|
: sty text_addr+1
|
2017-09-08 07:42:45 +00:00
|
|
|
|
|
|
|
ldy #(btn_c::label - btn_c) ; label
|
2017-09-08 04:42:58 +00:00
|
|
|
lda (ptr),y
|
2017-09-06 06:37:05 +00:00
|
|
|
sta label
|
2017-09-08 07:42:45 +00:00
|
|
|
|
2017-09-14 04:58:37 +00:00
|
|
|
A2D_CALL A2D_DRAW_BITMAP, 0, bitmap_addr ; draw shadowed rect
|
2017-09-09 19:18:06 +00:00
|
|
|
A2D_CALL A2D_SET_POS, 0, text_addr ; button label pos
|
2017-09-07 06:43:40 +00:00
|
|
|
A2D_CALL A2D_DRAW_TEXT, draw_text_params_label ; button label text
|
2017-09-08 07:42:45 +00:00
|
|
|
|
|
|
|
lda ptr ; advance to next record
|
2017-09-06 01:41:13 +00:00
|
|
|
clc
|
2017-09-08 04:42:58 +00:00
|
|
|
adc #.sizeof(btn_c)
|
|
|
|
sta ptr
|
2017-09-07 06:43:40 +00:00
|
|
|
bcc loop
|
2017-09-08 04:42:58 +00:00
|
|
|
inc ptr+1
|
2017-09-07 06:43:40 +00:00
|
|
|
jmp loop
|
|
|
|
.endproc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 08:00:58 +00:00
|
|
|
;;; ==================================================
|
2017-09-10 00:43:37 +00:00
|
|
|
;;; Draw the title bar decoration
|
2017-09-08 08:00:58 +00:00
|
|
|
|
2017-09-08 04:42:58 +00:00
|
|
|
draw_title_bar:
|
2017-09-10 00:43:37 +00:00
|
|
|
offset_left := 115 ; pixels from left of client area
|
|
|
|
offset_top := 22 ; pixels from top of client area (up!)
|
2017-09-09 18:08:40 +00:00
|
|
|
ldx create_window_params::left+1
|
|
|
|
lda create_window_params::left
|
2017-09-06 01:41:13 +00:00
|
|
|
clc
|
2017-09-10 00:43:37 +00:00
|
|
|
adc #offset_left
|
|
|
|
sta title_bar_decoration::left
|
2017-09-08 04:42:58 +00:00
|
|
|
bcc :+
|
2017-09-06 01:41:13 +00:00
|
|
|
inx
|
2017-09-10 00:43:37 +00:00
|
|
|
: stx title_bar_decoration::left+1
|
2017-09-09 18:08:40 +00:00
|
|
|
ldx create_window_params::top+1
|
|
|
|
lda create_window_params::top
|
2017-09-06 01:41:13 +00:00
|
|
|
sec
|
2017-09-10 00:43:37 +00:00
|
|
|
sbc #offset_top
|
|
|
|
sta title_bar_decoration::top
|
2017-09-08 04:42:58 +00:00
|
|
|
bcs :+
|
2017-09-06 01:41:13 +00:00
|
|
|
dex
|
2017-09-10 00:43:37 +00:00
|
|
|
: stx title_bar_decoration::top+1
|
2017-09-14 04:35:23 +00:00
|
|
|
A2D_CALL A2D_SET_BOX, screen_box ; set clipping rect to whole screen
|
2017-09-14 04:58:37 +00:00
|
|
|
A2D_CALL A2D_DRAW_BITMAP, title_bar_decoration ; Draws decoration in title bar
|
2017-09-07 02:38:06 +00:00
|
|
|
lda #window_id
|
2017-09-14 04:35:23 +00:00
|
|
|
sta query_state_params::id
|
|
|
|
A2D_CALL A2D_QUERY_STATE, query_state_params
|
|
|
|
A2D_CALL A2D_SET_STATE, state_params
|
2017-09-07 06:43:40 +00:00
|
|
|
A2D_CALL A2D_SHOW_CURSOR
|
2017-09-08 15:36:36 +00:00
|
|
|
jsr display_buffer2
|
2017-09-06 01:41:13 +00:00
|
|
|
rts
|
|
|
|
|
2017-09-09 18:08:40 +00:00
|
|
|
;; Traps FP error via call to $36 from MON.COUT, resets stack
|
|
|
|
;; and returns to the input loop.
|
|
|
|
.proc error_hook
|
2017-09-08 15:36:36 +00:00
|
|
|
jsr reset_buffers_and_display
|
2017-09-10 02:11:05 +00:00
|
|
|
A2D_CALL A2D_SET_POS, error_pos
|
2017-09-06 06:37:05 +00:00
|
|
|
A2D_CALL A2D_DRAW_TEXT, error_string
|
2017-09-08 15:36:36 +00:00
|
|
|
jsr reset_buffer1_and_state
|
2017-09-08 07:42:45 +00:00
|
|
|
lda #'='
|
|
|
|
sta calc_op
|
2017-09-09 18:08:40 +00:00
|
|
|
ldx saved_stack
|
2017-09-06 01:41:13 +00:00
|
|
|
txs
|
2017-09-08 07:42:45 +00:00
|
|
|
jmp input_loop
|
2017-09-08 15:36:36 +00:00
|
|
|
.endproc
|
2017-09-06 01:41:13 +00:00
|
|
|
|
2017-09-08 15:36:36 +00:00
|
|
|
;; Following proc is copied to $B1
|
|
|
|
.proc adjust_txtptr_copied
|
|
|
|
loop: inc TXTPTR
|
2017-09-08 07:42:45 +00:00
|
|
|
bne :+
|
2017-09-08 15:36:36 +00:00
|
|
|
inc TXTPTR+1
|
|
|
|
: lda $EA60 ; this ends up being aligned on TXTPTR
|
|
|
|
cmp #'9'+1 ; after digits?
|
2017-09-08 07:42:45 +00:00
|
|
|
bcs end
|
2017-09-08 15:36:36 +00:00
|
|
|
cmp #' ' ; space? keep going
|
2017-09-08 07:42:45 +00:00
|
|
|
beq loop
|
2017-09-06 01:41:13 +00:00
|
|
|
sec
|
2017-09-08 15:36:36 +00:00
|
|
|
sbc #'0' ; convert to digit...
|
2017-09-06 01:41:13 +00:00
|
|
|
sec
|
2017-09-08 15:36:36 +00:00
|
|
|
sbc #$D0 ; carry set if successful
|
2017-09-08 07:42:45 +00:00
|
|
|
end: rts
|
|
|
|
.endproc
|
2017-09-08 15:36:36 +00:00
|
|
|
end_adjust_txtptr_copied := *
|
2017-09-06 05:19:45 +00:00
|
|
|
|
|
|
|
da_end := *
|