Calc: FP ops

This commit is contained in:
Joshua Bell 2017-09-06 20:43:12 -07:00
parent e8f4b5f515
commit a86513cf32

View File

@ -435,8 +435,10 @@ left: .word 15
base: .word 16 base: .word 16
.endproc .endproc
L0C4E: .byte $45,$00,$10,$00,$00,$00,$00,$00 L0C4E: .byte $45,$00,$10,$00
.byte $00,$00
farg:
.byte $00,$00,$00,$00,$00,$00
L0C58: .byte $73 L0C58: .byte $73
L0C59: .byte $00 L0C59: .byte $00
L0C5A: .byte $F7 L0C5A: .byte $F7
@ -517,8 +519,8 @@ L0D79: lda L13CB,x
sta $37 sta $37
lda #$01 lda #$01
jsr FLOAT jsr FLOAT
ldx #$52 ldx #<farg
ldy #$0C ldy #>farg
jsr ROUND jsr ROUND
lda #$00 lda #$00
jsr FLOAT jsr FLOAT
@ -528,15 +530,15 @@ L0D79: lda L13CB,x
jsr FMULT jsr FMULT
lda #$00 lda #$00
jsr FLOAT jsr FLOAT
ldx #$52 ldx #<farg
ldy #$0C ldy #>farg
jsr ROUND jsr ROUND
tsx tsx
stx L0BC4 stx L0BC4
lda #$3D lda #'='
jsr L0F6A jsr process_key
lda #$43 lda #'C'
jsr L0F6A jsr process_key
A2D_CALL $24, L0CE6 A2D_CALL $24, L0CE6
L0DC9: A2D_CALL $2A, button_state_params L0DC9: A2D_CALL $2A, button_state_params
lda button_state_params::state lda button_state_params::state
@ -567,7 +569,7 @@ L0E04: lda text_pos_params1::left
bne L0E13 bne L0E13
jsr L0E95 jsr L0E95
bcc L0E03 bcc L0E03
jmp L0F6A jmp process_key
L0E13: cmp #$05 L0E13: cmp #$05
bne L0E53 bne L0E53
@ -604,24 +606,26 @@ L0E53: cmp #$03
jsr L084C jsr L084C
rts rts
L0E6F: lda L08C7 .proc L0E6F
bne L0E94 lda L08C7
lda L08C6 bne bail
cmp #$1B ; Escape lda L08C6 ; Check key
bne L0E87 cmp #$1B ; Escape?
lda L0BC5 bne trydel
bne L0E85 lda L0BC5 ; ??? (esc behavior variable?
bne clear
lda L0BCB lda L0BCB
beq L0E22 beq L0E22
L0E85: lda #$43 clear: lda #'C' ; turn Escape into Clear
L0E87: cmp #$7F ; Delete trydel: cmp #$7F ; Delete?
beq L0E91 beq :+
cmp #$60 cmp #$60 ; lowercase range?
bcc L0E91 bcc :+
and #$5F and #$5F ; convert to uppercase
L0E91: jmp L0F6A : jmp process_key
bail:
L0E94: rts .endproc
L0E94: rts ; used by prev/next proc
L0E95: lda #window_id L0E95: lda #window_id
sta button_state_params::state sta button_state_params::state
@ -715,9 +719,9 @@ miss: clc
row5_lookup := *-1 row5_lookup := *-1
.byte '0', '0', '.', '+' .byte '0', '0', '.', '+'
find_button_col: .proc find_button_col
cpx #col1_left-border_lt ; col 1? cpx #col1_left-border_lt ; col 1?
bcc L0F68 bcc miss
cpx #col1_right+border_br cpx #col1_right+border_br
bcs :+ bcs :+
ldx #1 ldx #1
@ -725,7 +729,7 @@ find_button_col:
rts rts
: cpx #col2_left-border_lt ; col 2? : cpx #col2_left-border_lt ; col 2?
bcc L0F68 bcc miss
cpx #col2_right+border_br cpx #col2_right+border_br
bcs :+ bcs :+
ldx #2 ldx #2
@ -733,7 +737,7 @@ find_button_col:
rts rts
: cpx #col3_left-border_lt ; col 3? : cpx #col3_left-border_lt ; col 3?
bcc L0F68 bcc miss
cpx #col3_right+border_br cpx #col3_right+border_br
bcs :+ bcs :+
ldx #3 ldx #3
@ -741,17 +745,19 @@ find_button_col:
rts rts
: cpx #col4_left-border_lt ; col 4? : cpx #col4_left-border_lt ; col 4?
bcc L0F68 bcc miss
cpx #col4_right+border_br - 1 ; bug in original? cpx #col4_right+border_br - 1 ; bug in original?
bcs L0F68 bcs miss
ldx #4 ldx #4
sec sec
rts rts
L0F68: clc miss: clc
rts rts
.endproc
L0F6A: cmp #'C' .proc process_key
cmp #'C' ; Clear?
bne :+ bne :+
ldx #<btnc_box ldx #<btnc_box
ldy #>btnc_box ldy #>btnc_box
@ -759,12 +765,12 @@ L0F6A: cmp #'C'
jsr L120A jsr L120A
lda #$00 lda #$00
jsr FLOAT jsr FLOAT
ldx #$52 ldx #<farg
ldy #$0C ldy #>farg
jsr ROUND jsr ROUND
lda #$3D lda #'='
sta L0BC6 sta L0BC6
lda #$00 lda #0
sta L0BC5 sta L0BC5
sta L0BCB sta L0BCB
sta L0BC7 sta L0BC7
@ -772,7 +778,7 @@ L0F6A: cmp #'C'
sta L0BC9 sta L0BC9
jmp L129E jmp L129E
: cmp #'E' : cmp #'E' ; Exponential?
bne L0FC7 bne L0FC7
ldx #<btne_box ldx #<btne_box
ldy #>btne_box ldy #>btne_box
@ -792,21 +798,21 @@ L0F6A: cmp #'C'
L0FC6: rts L0FC6: rts
L0FC7: cmp #'=' L0FC7: cmp #'=' ; Equals?
bne :+ bne :+
pha pha
ldx #<btneq_box ldx #<btneq_box
ldy #>btneq_box ldy #>btneq_box
jmp L114C jmp L114C
: cmp #'*' : cmp #'*' ; Multiply?
bne :+ bne :+
pha pha
ldx #<btnmul_box ldx #<btnmul_box
ldy #>btnmul_box ldy #>btnmul_box
jmp L114C jmp L114C
: cmp #'.' : cmp #'.' ; Decimal?
bne L1003 bne L1003
ldx #<btndec_box ldx #<btndec_box
ldy #>btndec_box ldy #>btndec_box
@ -823,113 +829,113 @@ L0FC7: cmp #'='
L1002: rts L1002: rts
L1003: cmp #'+' L1003: cmp #'+' ; Add?
bne :+ bne :+
pha pha
ldx #<btnadd_box ldx #<btnadd_box
ldy #>btnadd_box ldy #>btnadd_box
jmp L114C jmp L114C
: cmp #'-' : cmp #'-' ; Subtract?
bne L1030 bne trydiv
pha pha
ldx #<btnsub_box ldx #<btnsub_box
ldy #>btnsub_box ldy #>btnsub_box
lda L0BC8 lda L0BC8
beq L102B beq :+
lda L0BC9 lda L0BC9
bne L102B bne :+
sec sec
ror L0BC9 ror L0BC9
pla pla
pha pha
jmp L10FF jmp L10FF
L102B: pla : pla
pha pha
jmp L114C jmp L114C
L1030: cmp #'/' trydiv: cmp #'/' ; Divide?
bne :+ bne :+
pha pha
ldx #<btndiv_box ldx #<btndiv_box
ldy #>btndiv_box ldy #>btndiv_box
jmp L114C jmp L114C
: cmp #'0' : cmp #'0' ; Digit 0?
bne :+ bne :+
pha pha
ldx #<btn0_box ldx #<btn0_box
ldy #>btn0_box ldy #>btn0_box
jmp L10FF jmp L10FF
: cmp #'1' : cmp #'1' ; Digit 1?
bne :+ bne :+
pha pha
ldx #<btn1_box ldx #<btn1_box
ldy #>btn1_box ldy #>btn1_box
jmp L10FF jmp L10FF
: cmp #'2' : cmp #'2' ; Digit 2?
bne :+ bne :+
pha pha
ldx #<btn2_box ldx #<btn2_box
ldy #>btn2_box ldy #>btn2_box
jmp L10FF jmp L10FF
: cmp #'3' : cmp #'3' ; Digit 3?
bne :+ bne :+
pha pha
ldx #<btn3_box ldx #<btn3_box
ldy #>btn3_box ldy #>btn3_box
jmp L10FF jmp L10FF
: cmp #'4' : cmp #'4' ; Digit 4?
bne :+ bne :+
pha pha
ldx #<btn4_box ldx #<btn4_box
ldy #>btn4_box ldy #>btn4_box
jmp L10FF jmp L10FF
: cmp #'5' : cmp #'5' ; Digit 5?
bne :+ bne :+
pha pha
ldx #<btn5_box ldx #<btn5_box
ldy #>btn5_box ldy #>btn5_box
jmp L10FF jmp L10FF
: cmp #'6' : cmp #'6' ; Digit 6?
bne :+ bne :+
pha pha
ldx #<btn6_box ldx #<btn6_box
ldy #>btn6_box ldy #>btn6_box
jmp L10FF jmp L10FF
: cmp #'7' : cmp #'7' ; Digit 7?
bne :+ bne :+
pha pha
ldx #<btn7_box ldx #<btn7_box
ldy #>btn7_box ldy #>btn7_box
jmp L10FF jmp L10FF
: cmp #'8' : cmp #'8' ; Digit 8?
bne :+ bne :+
pha pha
ldx #<btn8_box ldx #<btn8_box
ldy #>btn8_box ldy #>btn8_box
jmp L10FF jmp L10FF
: cmp #'9' : cmp #'9' ; Digit 9?
bne :+ bne :+
pha pha
ldx #<btn9_box ldx #<btn9_box
ldy #>btn9_box ldy #>btn9_box
jmp L10FF jmp L10FF
: cmp #$7F ; Delete : cmp #$7F ; Delete?
bne L10FE bne end
ldy L0BCB ldy L0BCB
beq L10FE beq end
cpy #1 cpy #1
bne :+ bne :+
jsr L11F5 jsr L11F5
@ -959,7 +965,8 @@ L10E6: lda text_buffer1,x
sta text_buffer2+1,x sta text_buffer2+1,x
jmp L12A4 jmp L12A4
L10FE: rts end: rts
.endproc
L10FF: jsr L120A L10FF: jsr L120A
bne L1106 bne L1106
@ -1031,38 +1038,38 @@ L1173: lda #$07
jsr FIN jsr FIN
L1181: pla L1181: pla
ldx L0BC6 ldx L0BC6
sta L0BC6 sta L0BC6 ; Operation
lda #$52 lda #<farg
ldy #$0C ldy #>farg
cpx #'+' cpx #'+'
bne :+ bne :+
jsr FADD jsr FADD
jmp L11C0 jmp post
: cpx #'-' : cpx #'-'
bne :+ bne :+
jsr FSUB jsr FSUB
jmp L11C0 jmp post
: cpx #'*' : cpx #'*'
bne :+ bne :+
jsr FMULT jsr FMULT
jmp L11C0 jmp post
: cpx #'/' : cpx #'/'
bne :+ bne :+
jsr FDIV jsr FDIV
jmp L11C0 jmp post
: cpx #'=' : cpx #'='
bne L11C0 bne post
ldy L0BCA ldy L0BCA
bne L11C0 bne post
jmp L11F5 jmp L11F5
L11C0: ldx #$52 post: ldx #<farg ; after the FP operation is done
ldy #$0C ldy #>farg
jsr ROUND jsr ROUND
jsr FOUT jsr FOUT
ldy #0 ldy #0