Calc: proc identifications

This commit is contained in:
Joshua Bell 2017-09-08 00:42:45 -07:00
parent 6278ba56a8
commit ca77bd988f

View File

@ -191,8 +191,7 @@ L08D5: .byte $00
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
label: .byte 'c' label: .byte 'c'
.word col1_left + 6 pos: .word col1_left + 6, row1_bot
.word row1_bot
box: .word col1_left,row1_top,col1_right,row1_bot box: .word col1_left,row1_top,col1_right,row1_bot
.endproc .endproc
@ -204,8 +203,7 @@ box: .word col1_left,row1_top,col1_right,row1_bot
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
label: .byte 'e' label: .byte 'e'
.word col2_left + 6 .word col2_left + 6, row1_bot
.word row1_bot
box: .word col2_left,row1_top,col2_right,row1_bot box: .word col2_left,row1_top,col2_right,row1_bot
.endproc .endproc
@ -217,8 +215,7 @@ box: .word col2_left,row1_top,col2_right,row1_bot
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
label: .byte '=' label: .byte '='
.word col3_left + 6 .word col3_left + 6, row1_bot
.word row1_bot
box: .word col3_left,row1_top,col3_right,row1_bot box: .word col3_left,row1_top,col3_right,row1_bot
.endproc .endproc
@ -230,8 +227,7 @@ box: .word col3_left,row1_top,col3_right,row1_bot
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
label: .byte '*' label: .byte '*'
.word col4_left + 6 .word col4_left + 6, row1_bot
.word row1_bot
box: .word col4_left,row1_top,col4_right,row1_bot box: .word col4_left,row1_top,col4_right,row1_bot
.endproc .endproc
@ -243,8 +239,7 @@ box: .word col4_left,row1_top,col4_right,row1_bot
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
label: .byte '7' label: .byte '7'
.word col1_left + 6 .word col1_left + 6, row2_bot
.word row2_bot
box: .word col1_left,row2_top,col1_right,row2_bot box: .word col1_left,row2_top,col1_right,row2_bot
.endproc .endproc
@ -256,8 +251,7 @@ box: .word col1_left,row2_top,col1_right,row2_bot
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
label: .byte '8' label: .byte '8'
.word col2_left + 6 .word col2_left + 6, row2_bot
.word row2_bot
box: .word col2_left,row2_top,col2_right,row2_bot box: .word col2_left,row2_top,col2_right,row2_bot
.endproc .endproc
@ -269,8 +263,7 @@ box: .word col2_left,row2_top,col2_right,row2_bot
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
label: .byte '9' label: .byte '9'
.word col3_left + 6 .word col3_left + 6, row2_bot
.word row2_bot
box: .word col3_left,row2_top,col3_right,row2_bot box: .word col3_left,row2_top,col3_right,row2_bot
.endproc .endproc
@ -282,8 +275,7 @@ box: .word col3_left,row2_top,col3_right,row2_bot
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
label: .byte '/' label: .byte '/'
.word col4_left + 6 .word col4_left + 6, row2_bot
.word row2_bot
box: .word col4_left,row2_top,col4_right,row2_bot box: .word col4_left,row2_top,col4_right,row2_bot
.endproc .endproc
@ -295,8 +287,7 @@ box: .word col4_left,row2_top,col4_right,row2_bot
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
label: .byte '4' label: .byte '4'
.word col1_left + 6 .word col1_left + 6, row3_bot
.word row3_bot
box: .word col1_left,row3_top,col1_right,row3_bot box: .word col1_left,row3_top,col1_right,row3_bot
.endproc .endproc
@ -308,8 +299,7 @@ box: .word col1_left,row3_top,col1_right,row3_bot
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
label: .byte '5' label: .byte '5'
.word col2_left + 6 .word col2_left + 6, row3_bot
.word row3_bot
box: .word col2_left,row3_top,col2_right,row3_bot box: .word col2_left,row3_top,col2_right,row3_bot
.endproc .endproc
@ -321,8 +311,7 @@ box: .word col2_left,row3_top,col2_right,row3_bot
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
label: .byte '6' label: .byte '6'
.word col3_left + 6 .word col3_left + 6, row3_bot
.word row3_bot
box: .word col3_left,row3_top,col3_right,row3_bot box: .word col3_left,row3_top,col3_right,row3_bot
.endproc .endproc
@ -334,8 +323,7 @@ box: .word col3_left,row3_top,col3_right,row3_bot
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
label: .byte '-' label: .byte '-'
.word col4_left + 6 .word col4_left + 6, row3_bot
.word row3_bot
box: .word col4_left,row3_top,col4_right,row3_bot box: .word col4_left,row3_top,col4_right,row3_bot
.endproc .endproc
@ -347,8 +335,7 @@ box: .word col4_left,row3_top,col4_right,row3_bot
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
label: .byte '1' label: .byte '1'
.word col1_left + 6 .word col1_left + 6, row4_bot
.word row4_bot
box: .word col1_left,row4_top,col1_right,row4_bot box: .word col1_left,row4_top,col1_right,row4_bot
.endproc .endproc
@ -360,8 +347,7 @@ box: .word col1_left,row4_top,col1_right,row4_bot
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
label: .byte '2' label: .byte '2'
.word col2_left + 6 .word col2_left + 6, row4_bot
.word row4_bot
box: .word col2_left,row4_top,col2_right,row4_bot box: .word col2_left,row4_top,col2_right,row4_bot
.endproc .endproc
@ -373,8 +359,7 @@ box: .word col2_left,row4_top,col2_right,row4_bot
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
label: .byte '3' label: .byte '3'
.word col3_left + 6 .word col3_left + 6, row4_bot
.word row4_bot
box: .word col3_left,row4_top,col3_right,row4_bot box: .word col3_left,row4_top,col3_right,row4_bot
.endproc .endproc
@ -386,8 +371,7 @@ box: .word col3_left,row4_top,col3_right,row4_bot
.word 49 ; 0 is extra wide .word 49 ; 0 is extra wide
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
.byte '0' .byte '0'
.word col1_left + 6 .word col1_left + 6, row5_bot
.word row5_bot
box: .word col1_left,row5_top,col2_right,row5_bot box: .word col1_left,row5_top,col2_right,row5_bot
.endproc .endproc
@ -399,8 +383,7 @@ box: .word col1_left,row5_top,col2_right,row5_bot
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word button_height + border_lt + border_br .word button_height + border_lt + border_br
.byte '.' .byte '.'
.word col3_left + 6 + 2 ; + 2 to center the label .word col3_left + 6 + 2, row5_bot ; + 2 to center the label
.word row5_bot
box: .word col3_left,row5_top,col3_right,row5_bot box: .word col3_left,row5_top,col3_right,row5_bot
.endproc .endproc
@ -412,13 +395,12 @@ box: .word col3_left,row5_top,col3_right,row5_bot
.word button_width + border_lt + border_br .word button_width + border_lt + border_br
.word 27 ; + is extra tall .word 27 ; + is extra tall
.byte '+' .byte '+'
.word col4_left + 6 .word col4_left + 6, row5_bot
.word row5_bot
box: .word col4_left,row4_top,col4_right,row5_bot box: .word col4_left,row4_top,col4_right,row5_bot
.endproc .endproc
.byte 0 ; sentinel .byte 0 ; sentinel
L0AE1: L0AE1: ; pattern for normal buttons
.byte $00,$00,$40,$7E .byte $00,$00,$40,$7E
.byte $7F,$1F,$7E,$7F,$1F,$7E,$7F,$1F .byte $7F,$1F,$7E,$7F,$1F,$7E,$7F,$1F
.byte $7E,$7F,$1F,$7E,$7F,$1F,$7E,$7F .byte $7E,$7F,$1F,$7E,$7F,$1F,$7E,$7F
@ -426,7 +408,7 @@ L0AE1:
.byte $7F,$1F,$7E,$7F,$1F,$00,$00,$00 .byte $7F,$1F,$7E,$7F,$1F,$00,$00,$00
.byte $01,$00,$00 .byte $01,$00,$00
L0B08: L0B08: ; pattern for '0' button
.byte $00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00
.byte $00,$00,$7F,$7E,$7F,$7F,$7F,$7F .byte $00,$00,$7F,$7E,$7F,$7F,$7F,$7F
.byte $7F,$3F,$7E,$7E,$7F,$7F,$7F,$7F .byte $7F,$3F,$7E,$7E,$7F,$7F,$7F,$7F
@ -441,7 +423,8 @@ L0B08:
.byte $7F,$3F,$7E,$00,$00,$00,$00,$00 .byte $7F,$3F,$7E,$00,$00,$00,$00,$00
.byte $00,$00,$7E,$01,$00,$00,$00,$00 .byte $00,$00,$7E,$01,$00,$00,$00,$00
.byte $00,$00,$7E .byte $00,$00,$7E
L0B70:
L0B70: ; pattern for '+' button
.byte $00,$00,$40,$7E,$7F .byte $00,$00,$40,$7E,$7F
.byte $1F,$7E,$7F,$1F,$7E,$7F,$1F,$7E .byte $1F,$7E,$7F,$1F,$7E,$7F,$1F,$7E
.byte $7F,$1F,$7E,$7F,$1F,$7E,$7F,$1F .byte $7F,$1F,$7E,$7F,$1F,$7E,$7F,$1F
@ -454,9 +437,10 @@ L0B70:
.byte $7E,$7F,$1F,$7E,$7F,$1F,$7E,$7F .byte $7E,$7F,$1F,$7E,$7F,$1F,$7E,$7F
.byte $1F,$00,$00,$00,$01,$00,$00 .byte $1F,$00,$00,$00,$01,$00,$00
;; Calculation state
L0BC4: .byte $00 L0BC4: .byte $00
L0BC5: .byte $00 L0BC5: .byte $00
L0BC6: .byte $00 calc_op:.byte $00
L0BC7: .byte $00 L0BC7: .byte $00
L0BC8: .byte $00 L0BC8: .byte $00
L0BC9: .byte $00 L0BC9: .byte $00
@ -612,24 +596,30 @@ L0D18: sta ALTZPON
A2D_CALL $2D, button_state_params A2D_CALL $2D, button_state_params
A2D_CALL A2D_GET_BUTTON, button_state_params A2D_CALL A2D_GET_BUTTON, button_state_params
lda ROMIN2 lda ROMIN2
jsr L128E jsr reset_buffer2
lda #window_id lda #window_id
jsr L089E jsr L089E
jsr L129E jsr L129E
lda #$3D
sta L0BC6 lda #'=' ; last operation
lda #$00 sta calc_op
lda #0 ; clear registers
sta L0BC5 sta L0BC5
sta L0BC7 sta L0BC7
sta L0BC8 sta L0BC8
sta L0BC9 sta L0BC9
sta L0BCA sta L0BCA
sta L0BCB sta L0BCB
ldx #$1C
L0D79: lda L13CB,x .proc copy_to_b0
ldx #(end_copied_to_b0 - copied_to_b0 + 4) ; should be just + 1 ?
loop: lda copied_to_b0-1,x
sta $B0,x sta $B0,x
dex dex
bne L0D79 bne loop
.endproc
lda #$00 lda #$00
sta $D8 sta $D8
lda #$AE lda #$AE
@ -659,17 +649,19 @@ L0D79: lda L13CB,x
lda #'C' lda #'C'
jsr process_key jsr process_key
A2D_CALL $24, L0CE6 A2D_CALL $24, L0CE6
L0DC9: A2D_CALL $2A, button_state_params
input_loop:
A2D_CALL $2A, button_state_params
lda button_state_params::state lda button_state_params::state
cmp #$01 cmp #$01
bne L0DDC bne L0DDC
jsr on_click jsr on_click
jmp L0DC9 jmp input_loop
L0DDC: cmp #$03 L0DDC: cmp #$03
bne L0DC9 bne input_loop
jsr L0E6F jsr L0E6F
jmp L0DC9 jmp input_loop
on_click: on_click:
lda LCBANK1 lda LCBANK1
@ -901,7 +893,7 @@ miss: clc
ldy #>farg ldy #>farg
jsr ROUND jsr ROUND
lda #'=' lda #'='
sta L0BC6 sta calc_op
lda #0 lda #0
sta L0BC5 sta L0BC5
sta L0BCB sta L0BCB
@ -1111,7 +1103,7 @@ L1107: sec
ldy L0BCB ldy L0BCB
bne L111C bne L111C
pha pha
jsr L128E jsr reset_buffer2
pla pla
cmp #$30 cmp #$30
bne L111C bne L111C
@ -1147,7 +1139,7 @@ L114C: jsr depress_button
pla pla
rts rts
L1153: lda L0BC6 L1153: lda calc_op
cmp #'=' cmp #'='
bne :+ bne :+
lda L0BCA lda L0BCA
@ -1159,18 +1151,18 @@ L1153: lda L0BC6
: lda L0BCA : lda L0BCA
bne L1173 bne L1173
pla pla
sta L0BC6 sta calc_op
jmp L11F5 jmp L11F5
L1173: lda #$07 L1173: lda #<text_buffer1
sta $B8 sta $B8
lda #$0C lda #>text_buffer2
sta $B9 sta $B9
jsr L00B1 jsr L00B1
jsr FIN jsr FIN
L1181: pla L1181: pla
ldx L0BC6 ldx calc_op
sta L0BC6 ; Operation sta calc_op ; Operation
lda #<farg lda #<farg
ldy #>farg ldy #>farg
@ -1224,7 +1216,7 @@ loop: lda #' '
dex dex
bpl loop bpl loop
L11F2: jsr L12A4 L11F2: jsr L12A4
L11F5: jsr L127E L11F5: jsr reset_buffer1
lda #0 lda #0
sta L0BCB sta L0BCB
sta L0BC7 sta L0BC7
@ -1275,39 +1267,46 @@ done: lda $FC ; high bit set if button down
rts rts
.endproc .endproc
L127E: ldy #text_buffer_size .proc reset_buffer1
L1280: lda #' ' ldy #text_buffer_size
loop: lda #' '
sta text_buffer1-1,y sta text_buffer1-1,y
dey dey
bne L1280 bne loop
lda #$30 lda #'0'
sta text_buffer1 + text_buffer_size sta text_buffer1 + text_buffer_size
rts rts
.endproc
L128E: ldy #text_buffer_size .proc reset_buffer2
L1290: lda #' ' ldy #text_buffer_size
loop: lda #' '
sta text_buffer2-1,y sta text_buffer2-1,y
dey dey
bne L1290 bne loop
lda #'0' lda #'0'
sta text_buffer2 + text_buffer_size sta text_buffer2 + text_buffer_size
rts rts
.endproc
L129E: jsr L127E L129E: jsr reset_buffer1
jsr L128E jsr reset_buffer2
L12A4: ldx #$07 L12A4: ldx #<text_buffer1
ldy #$0C ldy #>text_buffer1
jsr L12C0 jsr L12C0
A2D_CALL A2D_DRAW_TEXT, draw_text_params1 A2D_CALL A2D_DRAW_TEXT, draw_text_params1
rts rts
L12B2: ldx #$1A .proc L12B2
ldx #$1A
ldy #$0C ldy #$0C
jsr L12C0 jsr L12C0
A2D_CALL A2D_DRAW_TEXT, draw_text_params2 A2D_CALL A2D_DRAW_TEXT, draw_text_params2
rts rts
.endproc
L12C0: stx L0C40 .proc L12C0
stx L0C40
sty L0C41 sty L0C41
A2D_CALL $18, L0C40 A2D_CALL $18, L0C40
lda #$69 lda #$69
@ -1318,6 +1317,7 @@ L12C0: stx L0C40
A2D_CALL A2D_DRAW_TEXT, spaces_string A2D_CALL A2D_DRAW_TEXT, spaces_string
A2D_CALL A2D_SET_TEXT_POS, text_pos_params3 A2D_CALL A2D_SET_TEXT_POS, text_pos_params3
rts rts
.endproc
.proc draw_window .proc draw_window
;; Frame ;; Frame
@ -1340,23 +1340,28 @@ L12C0: stx L0C40
loop: ldy #0 loop: ldy #0
lda (ptr),y lda (ptr),y
beq draw_title_bar ; done! beq draw_title_bar ; done!
lda ptr
lda ptr ; address for shadowed rect params
sta c14_addr sta c14_addr
ldy ptr+1 ldy ptr+1
sty c14_addr+1 sty c14_addr+1
clc
adc #(btn_c::label - btn_c + 1) clc ; address for label pos
adc #(btn_c::pos - btn_c)
sta text_addr sta text_addr
bcc :+ bcc :+
iny iny
: sty text_addr+1 : sty text_addr+1
ldy #$10
ldy #(btn_c::label - btn_c) ; label
lda (ptr),y lda (ptr),y
sta label sta label
A2D_CALL $14, 0, c14_addr ; draw shadowed rect A2D_CALL $14, 0, c14_addr ; draw shadowed rect
A2D_CALL A2D_SET_TEXT_POS, 0, text_addr ; button label pos A2D_CALL A2D_SET_TEXT_POS, 0, text_addr ; button label pos
A2D_CALL A2D_DRAW_TEXT, draw_text_params_label ; button label text A2D_CALL A2D_DRAW_TEXT, draw_text_params_label ; button label text
lda ptr
lda ptr ; advance to next record
clc clc
adc #.sizeof(btn_c) adc #.sizeof(btn_c)
sta ptr sta ptr
@ -1396,25 +1401,28 @@ draw_title_bar:
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 L11F5 jsr L11F5
lda #$3D lda #'='
sta L0BC6 sta calc_op
ldx L0BC4 ldx L0BC4
txs txs
L13CB := * + 2 jmp input_loop
jmp L0DC9
L13CC: inc $B8 ;; Following proc is copied to $B0
bne L13D2 .proc copied_to_b0
loop: inc $B8
bne :+
inc $B9 inc $B9
L13D2: lda $EA60 : lda $EA60
cmp #$3A cmp #$3A
bcs L13E3 bcs end
cmp #' ' cmp #' '
beq L13CC beq loop
sec sec
sbc #'0' sbc #'0'
sec sec
sbc #$D0 sbc #$D0
L13E3: rts end: rts
.endproc
end_copied_to_b0 := *
da_end := * da_end := *