mirror of
https://github.com/mi57730/a2d.git
synced 2025-02-26 23:29:11 +00:00
Calc: calc state/error recovery sleuthing
This commit is contained in:
parent
8095434e1e
commit
2bbd9e4ec9
@ -76,7 +76,8 @@ A2D_DRAW_TEXT := $19
|
|||||||
;; .addr data
|
;; .addr data
|
||||||
;; .byte length
|
;; .byte length
|
||||||
|
|
||||||
A2D_UNK_1A := $1A ; Unknown - used in calculator before window creation
|
A2D_UNK_1A := $1A ; Unknown - used in calculator before window creation,
|
||||||
|
; and after destruction
|
||||||
|
|
||||||
A2D_UNK_24 := $24 ; Unknown - used in calculator
|
A2D_UNK_24 := $24 ; Unknown - used in calculator
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ L0020 := $0020
|
|||||||
adjust_txtptr := $B1
|
adjust_txtptr := $B1
|
||||||
|
|
||||||
ROMIN2 := $C082
|
ROMIN2 := $C082
|
||||||
|
COUT_HOOK := $36
|
||||||
|
|
||||||
;;; ==================================================
|
;;; ==================================================
|
||||||
;;; Start of the code
|
;;; Start of the code
|
||||||
@ -139,7 +140,7 @@ L089D: .byte 0
|
|||||||
;; Called after window drag is complete
|
;; Called after window drag is complete
|
||||||
|
|
||||||
L089E: sta L08D1
|
L089E: sta L08D1
|
||||||
lda L0CBD
|
lda create_window_params_top
|
||||||
cmp #$BF
|
cmp #$BF
|
||||||
bcc :+
|
bcc :+
|
||||||
lda #$80
|
lda #$80
|
||||||
@ -198,11 +199,16 @@ id: .byte 0
|
|||||||
state: .byte 0
|
state: .byte 0
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
L08D1: .byte $00
|
;; param block for a 3C call
|
||||||
|
L08D1: .byte $00 ; set to window_id
|
||||||
.addr L0C6E
|
.addr L0C6E
|
||||||
|
|
||||||
|
;; param block for a 1A call
|
||||||
L08D4: .byte $80
|
L08D4: .byte $80
|
||||||
|
|
||||||
|
;; param block for a 1A call
|
||||||
|
L08D5: .byte $00
|
||||||
|
|
||||||
;; button definitions
|
;; button definitions
|
||||||
|
|
||||||
button_width := 17
|
button_width := 17
|
||||||
@ -231,8 +237,6 @@ L08D4: .byte $80
|
|||||||
border_lt := 1 ; border width pixels (left/top)
|
border_lt := 1 ; border width pixels (left/top)
|
||||||
border_br := 2 ; (bottom/right)
|
border_br := 2 ; (bottom/right)
|
||||||
|
|
||||||
L08D5: .byte $00
|
|
||||||
|
|
||||||
.proc btn_c
|
.proc btn_c
|
||||||
.word col1_left - border_lt
|
.word col1_left - border_lt
|
||||||
.word row1_top - border_lt
|
.word row1_top - border_lt
|
||||||
@ -488,14 +492,15 @@ L0B70: ; pattern for '+' button
|
|||||||
.byte $1F,$00,$00,$00,$01,$00,$00
|
.byte $1F,$00,$00,$00,$01,$00,$00
|
||||||
|
|
||||||
;; Calculation state
|
;; Calculation state
|
||||||
L0BC4: .byte $00
|
saved_stack:
|
||||||
L0BC5: .byte $00
|
.byte $00 ; restored after error
|
||||||
|
L0BC5: .byte $00 ; high bit set if pending op?
|
||||||
calc_op:.byte $00
|
calc_op:.byte $00
|
||||||
L0BC7: .byte $00
|
L0BC7: .byte $00 ; '.' if decimal present, 0 otherwise
|
||||||
L0BC8: .byte $00
|
L0BC8: .byte $00 ; exponential?
|
||||||
L0BC9: .byte $00
|
L0BC9: .byte $00 ; negative?
|
||||||
L0BCA: .byte $00
|
L0BCA: .byte $00 ; related to = key
|
||||||
L0BCB: .byte $00
|
L0BCB: .byte $00 ; input length
|
||||||
|
|
||||||
.proc background_box_params
|
.proc background_box_params
|
||||||
left: .word 1
|
left: .word 1
|
||||||
@ -591,6 +596,7 @@ left: .word 15
|
|||||||
base: .word 16
|
base: .word 16
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
;; ???
|
||||||
L0C4E: .byte $45,$00,$10,$00
|
L0C4E: .byte $45,$00,$10,$00
|
||||||
|
|
||||||
farg:
|
farg:
|
||||||
@ -616,23 +622,46 @@ L0CA3: .byte $00 ; arg for fill mode?
|
|||||||
.byte $01,$02
|
.byte $01,$02
|
||||||
L0CA6: .byte $06 ; arg for fill mode?
|
L0CA6: .byte $06 ; arg for fill mode?
|
||||||
|
|
||||||
create_window_params:
|
window_width := 130
|
||||||
.byte window_id ; id
|
window_height := 96
|
||||||
.byte $02 ; flags
|
default_left := 210
|
||||||
|
default_top := 60
|
||||||
|
|
||||||
|
.proc create_window_params
|
||||||
|
id: .byte window_id
|
||||||
|
flags: .byte $02
|
||||||
.addr title
|
.addr title
|
||||||
.byte $00,$00,$00,$00
|
hscroll:.byte 0
|
||||||
.byte $00,$00,$00,$00,$82,$00,$60,$00
|
vscroll:.byte 0
|
||||||
.byte $82,$00,$60,$00
|
hs_max: .byte 0
|
||||||
L0CBB: .byte $D2
|
hs_pos: .byte 0
|
||||||
L0CBC: .byte $00
|
vs_max: .byte 0
|
||||||
L0CBD: .byte $3C
|
vs_pos: .byte 0
|
||||||
L0CBE: .byte $00,$00,$20,$80,$00,$00,$00,$00
|
.byte 0,0 ; ???
|
||||||
.byte $00,$82,$00,$60,$00,$FF,$FF,$FF
|
width_a: .word window_width
|
||||||
|
height_a:.word window_height
|
||||||
|
width_b: .word window_width
|
||||||
|
height_b:.word window_height
|
||||||
|
left: .word default_left
|
||||||
|
top: .word default_top
|
||||||
|
.word $2000 ;???
|
||||||
|
.word $80
|
||||||
|
hoffset:.word 0
|
||||||
|
voffset:.word 0
|
||||||
|
width: .word window_width
|
||||||
|
height: .word window_height
|
||||||
|
.endproc
|
||||||
|
create_window_params_top := create_window_params::top
|
||||||
|
|
||||||
|
;; ???
|
||||||
|
.byte $FF,$FF,$FF
|
||||||
.byte $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
|
.byte $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
|
||||||
.byte $00,$00,$00,$01,$01,$00,$7F,$00
|
.byte $00,$00,$00,$01,$01,$00,$7F,$00
|
||||||
.byte $88,$00,$00
|
.byte $88,$00,$00
|
||||||
|
|
||||||
title: PASCAL_STRING "Calc"
|
title: PASCAL_STRING "Calc"
|
||||||
|
|
||||||
|
;; param block for $24 call (just before entering input loop)
|
||||||
L0CE6: .byte $00,$00,$02,$00,$06,$00,$0E,$00
|
L0CE6: .byte $00,$00,$02,$00,$06,$00,$0E,$00
|
||||||
.byte $1E,$00,$3E,$00,$7E,$00,$1A,$00
|
.byte $1E,$00,$3E,$00,$7E,$00,$1A,$00
|
||||||
.byte $30,$00,$30,$00,$60,$00,$00,$00
|
.byte $30,$00,$30,$00,$60,$00,$00,$00
|
||||||
@ -684,10 +713,10 @@ loop: lda adjust_txtptr_copied-1,x
|
|||||||
lda #0 ; Turn off errors
|
lda #0 ; Turn off errors
|
||||||
sta ERRFLG
|
sta ERRFLG
|
||||||
|
|
||||||
lda #<hook_36
|
lda #<error_hook
|
||||||
sta $36
|
sta COUT_HOOK
|
||||||
lda #>hook_36
|
lda #>error_hook
|
||||||
sta $36+1
|
sta COUT_HOOK+1
|
||||||
|
|
||||||
lda #1
|
lda #1
|
||||||
jsr FLOAT
|
jsr FLOAT
|
||||||
@ -706,7 +735,7 @@ loop: lda adjust_txtptr_copied-1,x
|
|||||||
ldy #>farg
|
ldy #>farg
|
||||||
jsr ROUND
|
jsr ROUND
|
||||||
tsx
|
tsx
|
||||||
stx L0BC4
|
stx saved_stack
|
||||||
lda #'='
|
lda #'='
|
||||||
jsr process_key
|
jsr process_key
|
||||||
lda #'C'
|
lda #'C'
|
||||||
@ -1477,16 +1506,16 @@ loop: ldy #0
|
|||||||
;;; Draw the title bar - with extra doodad (???)
|
;;; Draw the title bar - with extra doodad (???)
|
||||||
|
|
||||||
draw_title_bar:
|
draw_title_bar:
|
||||||
ldx L0CBC
|
ldx create_window_params::left+1
|
||||||
lda L0CBB
|
lda create_window_params::left
|
||||||
clc
|
clc
|
||||||
adc #$73
|
adc #$73
|
||||||
sta L0C58
|
sta L0C58
|
||||||
bcc :+
|
bcc :+
|
||||||
inx
|
inx
|
||||||
: stx L0C59
|
: stx L0C59
|
||||||
ldx L0CBE
|
ldx create_window_params::top+1
|
||||||
lda L0CBD
|
lda create_window_params::top
|
||||||
sec
|
sec
|
||||||
sbc #$16
|
sbc #$16
|
||||||
sta L0C5A
|
sta L0C5A
|
||||||
@ -1503,14 +1532,16 @@ draw_title_bar:
|
|||||||
jsr display_buffer2
|
jsr display_buffer2
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.proc hook_36
|
;; Traps FP error via call to $36 from MON.COUT, resets stack
|
||||||
|
;; and returns to the input loop.
|
||||||
|
.proc error_hook
|
||||||
jsr reset_buffers_and_display
|
jsr reset_buffers_and_display
|
||||||
A2D_CALL A2D_SET_TEXT_POS, L0C4E
|
A2D_CALL A2D_SET_TEXT_POS, L0C4E
|
||||||
A2D_CALL A2D_DRAW_TEXT, error_string
|
A2D_CALL A2D_DRAW_TEXT, error_string
|
||||||
jsr reset_buffer1_and_state
|
jsr reset_buffer1_and_state
|
||||||
lda #'='
|
lda #'='
|
||||||
sta calc_op
|
sta calc_op
|
||||||
ldx L0BC4
|
ldx saved_stack
|
||||||
txs
|
txs
|
||||||
jmp input_loop
|
jmp input_loop
|
||||||
.endproc
|
.endproc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user