DA: renames

This commit is contained in:
Joshua Bell 2018-01-29 20:49:42 -08:00
parent 6a2aa90656
commit 76311ce501
6 changed files with 426 additions and 423 deletions

View File

@ -65,7 +65,7 @@ save_stack: .byte 0
;;; ==================================================
.proc exit_da
.proc exit_da
lda LCBANK1
lda LCBANK1
ldx save_stack
@ -101,7 +101,7 @@ call_init:
DESKTOP_CALL DESKTOP_REDRAW_ICONS
;; Redraw window after drag
lda #window_id
lda #da_window_id
jsr check_visibility_and_draw_window
MGTK_CALL MGTK::GetWinPort, getwinport_params
@ -129,7 +129,7 @@ offscreen_flag:
;; Called after window drag is complete
;; (called with window_id in A)
.proc check_visibility_and_draw_window
sta query_state_params_id
sta getwinport_params_window_id
lda openwindow_params_top
cmp #screen_height - 1
bcc :+
@ -144,8 +144,8 @@ offscreen_flag:
;; https://github.com/inexorabletash/a2d/issues/34
MGTK_CALL MGTK::GetWinPort, getwinport_params
MGTK_CALL MGTK::SetPort, port_params
lda query_state_params_id
cmp #window_id
lda getwinport_params_window_id
cmp #da_window_id
bne :+
jmp draw_background
: rts
@ -157,24 +157,24 @@ offscreen_flag:
;; The following params blocks overlap for data re-use
.proc screentowindow_params
id := *
window_id := *
screen := * + 1
screenx := * + 1 ; aligns with input_state::xcoord
screeny := * + 3 ; aligns with input_state::ycoord
client := * + 5
clientx := * + 5
clienty := * + 7
window := * + 5
windowx := * + 5
windowy := * + 7
.endproc
.proc drag_params
id := *
.proc dragwindow_params
window_id := *
xcoord := * + 1 ; aligns with input_state::xcoord
ycoord := * + 3 ; aligns with input_state::ycoord
moved := * + 5 ; ignored
.endproc
.proc event_params
state: .byte 0
kind: .byte 0
xcoord := * ; if state is 0,1,2,4
ycoord := * + 2 ; "
key := * ; if state is 3
@ -182,24 +182,24 @@ modifiers := * + 1 ; "
.endproc
.proc findwindow_params
queryx: .word 0 ; aligns with event_params::xcoord
queryy: .word 0 ; aligns with event_params::ycoord
elem: .byte 0
id: .byte 0
mousex: .word 0 ; aligns with event_params::xcoord
mousey: .word 0 ; aligns with event_params::ycoord
area: .byte 0
window_id: .byte 0
.endproc
.byte 0, 0 ; fills out space for screentowindow_params
.byte 0, 0 ; ???
.proc trackgoaway_params
state: .byte 0
goaway: .byte 0
.endproc
.proc getwinport_params
id: .byte 0
window_id: .byte 0
.addr port_params
.endproc
query_state_params_id := getwinport_params::id
getwinport_params_window_id := getwinport_params::window_id
.proc preserve_zp_params
flag: .byte MGTK::zp_preserve
@ -242,7 +242,7 @@ flag: .byte MGTK::zp_overwrite
left: .word col1_left - border_lt
top: .word row1_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -250,14 +250,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte 'c'
pos: .word col1_left + 6, row1_bot
box: .word col1_left,row1_top,col1_right,row1_bot
port: .word col1_left,row1_top,col1_right,row1_bot
.endproc
.proc btn_e
left: .word col2_left - border_lt
top: .word row1_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -265,14 +265,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte 'e'
pos: .word col2_left + 6, row1_bot
box: .word col2_left,row1_top,col2_right,row1_bot
port: .word col2_left,row1_top,col2_right,row1_bot
.endproc
.proc btn_eq
left: .word col3_left - border_lt
top: .word row1_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -280,14 +280,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '='
pos: .word col3_left + 6, row1_bot
box: .word col3_left,row1_top,col3_right,row1_bot
port: .word col3_left,row1_top,col3_right,row1_bot
.endproc
.proc btn_mul
left: .word col4_left - border_lt
top: .word row1_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -295,14 +295,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '*'
pos: .word col4_left + 6, row1_bot
box: .word col4_left,row1_top,col4_right,row1_bot
port: .word col4_left,row1_top,col4_right,row1_bot
.endproc
.proc btn_7
left: .word col1_left - border_lt
top: .word row2_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -310,14 +310,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '7'
pos: .word col1_left + 6, row2_bot
box: .word col1_left,row2_top,col1_right,row2_bot
port: .word col1_left,row2_top,col1_right,row2_bot
.endproc
.proc btn_8
left: .word col2_left - border_lt
top: .word row2_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -325,14 +325,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '8'
pos: .word col2_left + 6, row2_bot
box: .word col2_left,row2_top,col2_right,row2_bot
port: .word col2_left,row2_top,col2_right,row2_bot
.endproc
.proc btn_9
left: .word col3_left - border_lt
top: .word row2_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -340,14 +340,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '9'
pos: .word col3_left + 6, row2_bot
box: .word col3_left,row2_top,col3_right,row2_bot
port: .word col3_left,row2_top,col3_right,row2_bot
.endproc
.proc btn_div
left: .word col4_left - border_lt
top: .word row2_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -355,14 +355,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '/'
pos: .word col4_left + 6, row2_bot
box: .word col4_left,row2_top,col4_right,row2_bot
port: .word col4_left,row2_top,col4_right,row2_bot
.endproc
.proc btn_4
left: .word col1_left - border_lt
top: .word row3_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -370,14 +370,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '4'
pos: .word col1_left + 6, row3_bot
box: .word col1_left,row3_top,col1_right,row3_bot
port: .word col1_left,row3_top,col1_right,row3_bot
.endproc
.proc btn_5
left: .word col2_left - border_lt
top: .word row3_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -385,14 +385,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '5'
pos: .word col2_left + 6, row3_bot
box: .word col2_left,row3_top,col2_right,row3_bot
port: .word col2_left,row3_top,col2_right,row3_bot
.endproc
.proc btn_6
left: .word col3_left - border_lt
top: .word row3_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -400,14 +400,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '6'
pos: .word col3_left + 6, row3_bot
box: .word col3_left,row3_top,col3_right,row3_bot
port: .word col3_left,row3_top,col3_right,row3_bot
.endproc
.proc btn_sub
left: .word col4_left - border_lt
top: .word row3_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -415,14 +415,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '-'
pos: .word col4_left + 6, row3_bot
box: .word col4_left,row3_top,col4_right,row3_bot
port: .word col4_left,row3_top,col4_right,row3_bot
.endproc
.proc btn_1
left: .word col1_left - border_lt
top: .word row4_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -430,14 +430,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '1'
pos: .word col1_left + 6, row4_bot
box: .word col1_left,row4_top,col1_right,row4_bot
port: .word col1_left,row4_top,col1_right,row4_bot
.endproc
.proc btn_2
left: .word col2_left - border_lt
top: .word row4_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -445,14 +445,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '2'
pos: .word col2_left + 6, row4_bot
box: .word col2_left,row4_top,col2_right,row4_bot
port: .word col2_left,row4_top,col2_right,row4_bot
.endproc
.proc btn_3
left: .word col3_left - border_lt
top: .word row4_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -460,14 +460,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '3'
pos: .word col3_left + 6, row4_bot
box: .word col3_left,row4_top,col3_right,row4_bot
port: .word col3_left,row4_top,col3_right,row4_bot
.endproc
.proc btn_0
left: .word col1_left - border_lt
top: .word row5_top - border_lt
bitmap: .addr wide_button_bitmap
stride: .byte 8 ; bitmap_stride (bytes)
mapwidth: .byte 8 ; bitmap_stride (bytes)
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -475,14 +475,14 @@ width: .word 49 ; 0 is extra wide
height: .word button_height + border_lt + border_br
label: .byte '0'
pos: .word col1_left + 6, row5_bot
box: .word col1_left,row5_top,col2_right,row5_bot
port: .word col1_left,row5_top,col2_right,row5_bot
.endproc
.proc btn_dec
left: .word col3_left - border_lt
top: .word row5_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -490,14 +490,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '.'
pos: .word col3_left + 6 + 2, row5_bot ; + 2 to center the label
box: .word col3_left,row5_top,col3_right,row5_bot
port: .word col3_left,row5_top,col3_right,row5_bot
.endproc
.proc btn_add
left: .word col4_left - border_lt
top: .word row4_top - border_lt
bitmap: .addr tall_button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -505,7 +505,7 @@ width: .word button_width + border_lt + border_br
height: .word 27 ; + is extra tall
label: .byte '+'
pos: .word col4_left + 6, row5_bot
box: .word col4_left,row4_top,col4_right,row5_bot
port: .word col4_left,row4_top,col4_right,row5_bot
.endproc
.byte 0 ; sentinel
@ -642,8 +642,8 @@ height: .word display_height-1
label: .byte 0 ; modified with char to draw
.proc drawtext_params1
addr: .addr text_buffer1
length: .byte 15
textptr: .addr text_buffer1
textlen: .byte 15
.endproc
text_buffer_size := 14
@ -652,8 +652,8 @@ text_buffer1:
.res text_buffer_size+2, 0
.proc drawtext_params2
addr: .addr text_buffer2
length: .byte 15
textptr: .addr text_buffer2
textlen: .byte 15
.endproc
text_buffer2:
@ -666,15 +666,15 @@ error_string:
;; used when clearing display; params to a $18 call
.proc textwidth_params
addr: .addr text_buffer1
len: .byte 15 ; ???
width: .word 0
textptr: .addr text_buffer1
textlen: .byte 15 ; ???
result: .word 0
.endproc
window_id = 52
da_window_id = 52
.proc closewindow_params
id: .byte window_id
window_id: .byte da_window_id
.endproc
.proc text_pos_params3
@ -698,7 +698,7 @@ farg: .byte $00,$00,$00,$00,$00,$00
left: .word 115 ; overwritten
top: .word $FFF7 ; overwritten
bitmap:.addr pixels
stride: .byte 1
mapwidth: .byte 1
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -716,8 +716,8 @@ pixels: .byte px(%1000001)
.proc port_params
left: .word 0
top: .word 0
addr: .word 0
stride: .word 0
mapbits: .word 0
mapwidth: .word 0
hoff: .word 0
voff: .word 0
width: .word 0
@ -766,8 +766,8 @@ mode: .byte MGTK::notpenXOR
default_left := 210
default_top := 60
.proc openwindow_params
id: .byte window_id
.proc winfo
window_id: .byte da_window_id
flags: .byte MGTK::option_go_away_box
title: .addr window_title
hscroll:.byte MGTK::scroll_option_none
@ -776,15 +776,16 @@ hs_max: .byte 0
hs_pos: .byte 0
vs_max: .byte 0
vs_pos: .byte 0
.byte 0,0 ; ???
w1: .word window_width
h1: .word window_height
w2: .word window_width
h2: .word window_height
status: .byte 0
reserved: .byte 0
mincontwidth: .word window_width
mincontlength: .word window_height
maxcontwidth: .word window_width
maxcontlength: .word window_height
left: .word default_left
top: .word default_top
addr: .addr MGTK::screen_mapbits
stride: .word MGTK::screen_mapwidth
mapbits: .addr MGTK::screen_mapbits
mapwidth: .word MGTK::screen_mapwidth
hoff: .word 0
voff: .word 0
width: .word window_width
@ -801,7 +802,7 @@ tmask: .byte 0
font: .addr DEFAULT_FONT
next: .addr 0
.endproc
openwindow_params_top := openwindow_params::top
openwindow_params_top := winfo::top
window_title:
PASCAL_STRING "Calc"
@ -813,14 +814,14 @@ init: sta ALTZPON
lda LCBANK1
lda LCBANK1
MGTK_CALL MGTK::SetZP1, preserve_zp_params
MGTK_CALL MGTK::OpenWindow, openwindow_params
MGTK_CALL MGTK::OpenWindow, winfo
MGTK_CALL MGTK::InitPort, port_params
MGTK_CALL MGTK::SetPort, port_params
MGTK_CALL MGTK::FlushEvents
jsr reset_buffer2
lda #window_id
lda #da_window_id
jsr check_visibility_and_draw_window
jsr reset_buffers_and_display
@ -881,7 +882,7 @@ loop: lda adjust_txtptr_copied-1,x
input_loop:
MGTK_CALL MGTK::GetEvent, event_params
lda event_params::state
lda event_params::kind
cmp #MGTK::button_down
bne :+
jsr on_click
@ -897,17 +898,17 @@ input_loop:
on_click:
MGTK_CALL MGTK::FindWindow, findwindow_params
lda findwindow_params::elem
lda findwindow_params::area
cmp #MGTK::area_content ; Less than CLIENT is MENU or DESKTOP
bcc ignore_click
lda findwindow_params::id
cmp #window_id ; This window?
lda findwindow_params::window_id
cmp #da_window_id ; This window?
beq :+
ignore_click:
rts
: lda findwindow_params::elem
: lda findwindow_params::area
cmp #MGTK::area_content ; Client area?
bne :+
jsr map_click_to_button ; try to translate click into key
@ -917,7 +918,7 @@ ignore_click:
: cmp #MGTK::area_close_box ; Close box?
bne :+
MGTK_CALL MGTK::TrackGoAway, trackgoaway_params
lda trackgoaway_params::state
lda trackgoaway_params::goaway
beq ignore_click
exit: MGTK_CALL MGTK::CloseWindow, closewindow_params
DESKTOP_CALL DESKTOP_REDRAW_ICONS
@ -945,9 +946,9 @@ loop: lda routine,x
: cmp #MGTK::area_dragbar ; Title bar?
bne ignore_click
lda #window_id
sta drag_params::id
MGTK_CALL MGTK::DragWindow, drag_params
lda #da_window_id
sta dragwindow_params::window_id
MGTK_CALL MGTK::DragWindow, dragwindow_params
jsr redraw_screen_and_window
rts
@ -983,14 +984,14 @@ rts1: rts ; used by next proc
;;; If a button was clicked, carry is set and accum has key char
.proc map_click_to_button
lda #window_id
sta screentowindow_params::id
lda #da_window_id
sta screentowindow_params::window_id
MGTK_CALL MGTK::ScreenToWindow, screentowindow_params
lda screentowindow_params::clientx+1 ; ensure high bits of coords are 0
ora screentowindow_params::clienty+1
lda screentowindow_params::windowx+1 ; ensure high bits of coords are 0
ora screentowindow_params::windowy+1
bne rts1
lda screentowindow_params::clienty
ldx screentowindow_params::clientx
lda screentowindow_params::windowy
ldx screentowindow_params::windowx
.proc find_button_row
cmp #row1_top+border_lt - 1 ; row 1 ? (- 1 is bug in original?)
@ -1032,7 +1033,7 @@ rts1: rts ; used by next proc
: cmp #row5_top-border_lt ; special case for tall + button
bcs :+
lda screentowindow_params::clientx
lda screentowindow_params::windowx
cmp #col4_left-border_lt
bcc miss
cmp #col4_right+border_br-1 ; is -1 bug in original?
@ -1048,7 +1049,7 @@ rts1: rts ; used by next proc
lda row5_lookup,x
rts
: lda screentowindow_params::clientx ; special case for wide 0 button
: lda screentowindow_params::windowx ; special case for wide 0 button
cmp #col1_left-border_lt
bcc miss
cmp #col2_right+border_br
@ -1120,8 +1121,8 @@ miss: clc
.proc process_key
cmp #'C' ; Clear?
bne :+
ldx #<btn_c::box
ldy #>btn_c::box
ldx #<btn_c::port
ldy #>btn_c::port
lda #'c'
jsr depress_button
lda #$00
@ -1141,8 +1142,8 @@ miss: clc
: cmp #'E' ; Exponential?
bne try_eq
ldx #<btn_e::box
ldy #>btn_e::box
ldx #<btn_e::port
ldy #>btn_e::port
lda #'e'
jsr depress_button
ldy calc_e
@ -1162,21 +1163,21 @@ rts1: rts
try_eq: cmp #'=' ; Equals?
bne :+
pha
ldx #<btn_eq::box
ldy #>btn_eq::box
ldx #<btn_eq::port
ldy #>btn_eq::port
jmp do_op_click
: cmp #'*' ; Multiply?
bne :+
pha
ldx #<btn_mul::box
ldy #>btn_mul::box
ldx #<btn_mul::port
ldy #>btn_mul::port
jmp do_op_click
: cmp #'.' ; Decimal?
bne try_add
ldx #<btn_dec::box
ldy #>btn_dec::box
ldx #<btn_dec::port
ldy #>btn_dec::port
jsr depress_button
lda calc_d
ora calc_e
@ -1193,15 +1194,15 @@ rts2: rts
try_add:cmp #'+' ; Add?
bne :+
pha
ldx #<btn_add::box
ldy #>btn_add::box
ldx #<btn_add::port
ldy #>btn_add::port
jmp do_op_click
: cmp #'-' ; Subtract?
bne trydiv
pha
ldx #<btn_sub::box
ldy #>btn_sub::box
ldx #<btn_sub::port
ldy #>btn_sub::port
lda calc_e ; negate vs. subtract
beq :+
lda calc_n
@ -1219,78 +1220,78 @@ try_add:cmp #'+' ; Add?
trydiv: cmp #'/' ; Divide?
bne :+
pha
ldx #<btn_div::box
ldy #>btn_div::box
ldx #<btn_div::port
ldy #>btn_div::port
jmp do_op_click
: cmp #'0' ; Digit 0?
bne :+
pha
ldx #<btn_0::box
ldy #>btn_0::box
ldx #<btn_0::port
ldy #>btn_0::port
jmp do_digit_click
: cmp #'1' ; Digit 1?
bne :+
pha
ldx #<btn_1::box
ldy #>btn_1::box
ldx #<btn_1::port
ldy #>btn_1::port
jmp do_digit_click
: cmp #'2' ; Digit 2?
bne :+
pha
ldx #<btn_2::box
ldy #>btn_2::box
ldx #<btn_2::port
ldy #>btn_2::port
jmp do_digit_click
: cmp #'3' ; Digit 3?
bne :+
pha
ldx #<btn_3::box
ldy #>btn_3::box
ldx #<btn_3::port
ldy #>btn_3::port
jmp do_digit_click
: cmp #'4' ; Digit 4?
bne :+
pha
ldx #<btn_4::box
ldy #>btn_4::box
ldx #<btn_4::port
ldy #>btn_4::port
jmp do_digit_click
: cmp #'5' ; Digit 5?
bne :+
pha
ldx #<btn_5::box
ldy #>btn_5::box
ldx #<btn_5::port
ldy #>btn_5::port
jmp do_digit_click
: cmp #'6' ; Digit 6?
bne :+
pha
ldx #<btn_6::box
ldy #>btn_6::box
ldx #<btn_6::port
ldy #>btn_6::port
jmp do_digit_click
: cmp #'7' ; Digit 7?
bne :+
pha
ldx #<btn_7::box
ldy #>btn_7::box
ldx #<btn_7::port
ldy #>btn_7::port
jmp do_digit_click
: cmp #'8' ; Digit 8?
bne :+
pha
ldx #<btn_8::box
ldy #>btn_8::box
ldx #<btn_8::port
ldy #>btn_8::port
jmp do_digit_click
: cmp #'9' ; Digit 9?
bne :+
pha
ldx #<btn_9::box
ldy #>btn_9::box
ldx #<btn_9::port
ldy #>btn_9::port
jmp do_digit_click
: cmp #$7F ; Delete?
@ -1488,18 +1489,18 @@ end: jsr display_buffer1
sec
ror button_state
invert: MGTK_CALL MGTK::PaintRect, 0, invert_addr ; Inverts box
invert: MGTK_CALL MGTK::PaintRect, 0, invert_addr ; Inverts port
check_button:
MGTK_CALL MGTK::GetEvent, event_params
lda event_params::state
lda event_params::kind
cmp #MGTK::drag ; Button down?
bne done ; Nope, done immediately
lda #window_id
sta screentowindow_params::id
lda #da_window_id
sta screentowindow_params::window_id
MGTK_CALL MGTK::ScreenToWindow, screentowindow_params
MGTK_CALL MGTK::MoveTo, screentowindow_params::client
MGTK_CALL MGTK::MoveTo, screentowindow_params::window
MGTK_CALL MGTK::InRect, 0, inrect_params
bne inside
@ -1576,12 +1577,12 @@ end: rts
.endproc
.proc pre_display_buffer
stx textwidth_params::addr ; text buffer address in x,y
sty textwidth_params::addr+1
stx textwidth_params::textptr ; text buffer address in x,y
sty textwidth_params::textptr+1
MGTK_CALL MGTK::TextWidth, textwidth_params
lda #display_width-15 ; ???
sec
sbc textwidth_params::width
sbc textwidth_params::result
sta text_pos_params3::left
MGTK_CALL MGTK::MoveTo, text_pos_params2 ; clear with spaces
MGTK_CALL MGTK::DrawText, spaces_string
@ -1652,16 +1653,16 @@ loop: ldy #0
draw_title_bar:
offset_left := 115 ; pixels from left of client area
offset_top := 22 ; pixels from top of client area (up!)
ldx openwindow_params::left+1
lda openwindow_params::left
ldx winfo::left+1
lda winfo::left
clc
adc #offset_left
sta title_bar_decoration::left
bcc :+
inx
: stx title_bar_decoration::left+1
ldx openwindow_params::top+1
lda openwindow_params::top
ldx winfo::top+1
lda winfo::top
sec
sbc #offset_top
sta title_bar_decoration::top
@ -1670,8 +1671,8 @@ draw_title_bar:
: stx title_bar_decoration::top+1
MGTK_CALL MGTK::SetPortBits, screen_port ; set clipping rect to whole screen
MGTK_CALL MGTK::PaintBits, title_bar_decoration ; Draws decoration in title bar
lda #window_id
sta getwinport_params::id
lda #da_window_id
sta getwinport_params::window_id
MGTK_CALL MGTK::GetWinPort, getwinport_params
MGTK_CALL MGTK::SetPort, port_params
MGTK_CALL MGTK::ShowCursor

View File

@ -65,7 +65,7 @@ save_stack: .byte 0
;;; ==================================================
.proc exit_da
.proc exit_da
lda LCBANK1
lda LCBANK1
ldx save_stack
@ -96,7 +96,7 @@ call_init:
;; Redraw window after drag
lda ROMIN2
lda #window_id
lda #da_window_id
jsr check_visibility_and_draw_window
;; ???
@ -137,7 +137,7 @@ offscreen_flag:
;; Called after window drag is complete
;; (called with window_id in A)
.proc check_visibility_and_draw_window
sta get_port_params_id
sta getwinport_params_window_id
lda openwindow_params_top
cmp #screen_height - 1
bcc :+
@ -149,8 +149,8 @@ offscreen_flag:
;; https://github.com/inexorabletash/a2d/issues/34
: MGTK_CALL MGTK::GetWinPort, getwinport_params
MGTK_CALL MGTK::SetPort, port_params
lda get_port_params_id
cmp #window_id
lda getwinport_params_window_id
cmp #da_window_id
bne :+
jmp draw_background
: rts
@ -162,17 +162,17 @@ offscreen_flag:
;; The following params blocks overlap for data re-use
.proc screentowindow_params
id := *
window_id := *
screen := * + 1
screenx := * + 1 ; aligns with input_state::xcoord
screeny := * + 3 ; aligns with input_state::ycoord
client := * + 5
clientx := * + 5
clienty := * + 7
window := * + 5
windowx := * + 5
windowy := * + 7
.endproc
.proc drag_params
id := *
.proc dragwindow_params
window_id := *
xcoord := * + 1 ; aligns with input_state::xcoord
ycoord := * + 3 ; aligns with input_state::ycoord
moved := * + 5 ; ignored
@ -187,10 +187,10 @@ modifiers := * + 1 ; "
.endproc
.proc findwindow_params
queryx: .word 0 ; aligns with event_params::xcoord
queryy: .word 0 ; aligns with event_params::ycoord
mousex: .word 0 ; aligns with event_params::xcoord
mousey: .word 0 ; aligns with event_params::ycoord
which_area: .byte 0
id: .byte 0
window_id: .byte 0
.endproc
.byte 0, 0 ; fills out space for screentowindow_params
@ -201,10 +201,10 @@ goaway: .byte 0
.endproc
.proc getwinport_params
id: .byte 0
window_id: .byte 0
.addr port_params
.endproc
get_port_params_id := getwinport_params::id
getwinport_params_window_id := getwinport_params::window_id
.proc preserve_zp_params
flag: .byte MGTK::zp_preserve
@ -247,7 +247,7 @@ flag: .byte MGTK::zp_overwrite
left: .word col1_left - border_lt
top: .word row1_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -255,14 +255,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte 'c'
pos: .word col1_left + 6, row1_bot
box: .word col1_left,row1_top,col1_right,row1_bot
port: .word col1_left,row1_top,col1_right,row1_bot
.endproc
.proc btn_e
left: .word col2_left - border_lt
top: .word row1_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -270,14 +270,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte 'e'
pos: .word col2_left + 6, row1_bot
box: .word col2_left,row1_top,col2_right,row1_bot
port: .word col2_left,row1_top,col2_right,row1_bot
.endproc
.proc btn_eq
left: .word col3_left - border_lt
top: .word row1_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -285,14 +285,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '='
pos: .word col3_left + 6, row1_bot
box: .word col3_left,row1_top,col3_right,row1_bot
port: .word col3_left,row1_top,col3_right,row1_bot
.endproc
.proc btn_mul
left: .word col4_left - border_lt
top: .word row1_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -300,14 +300,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '*'
pos: .word col4_left + 6, row1_bot
box: .word col4_left,row1_top,col4_right,row1_bot
port: .word col4_left,row1_top,col4_right,row1_bot
.endproc
.proc btn_7
left: .word col1_left - border_lt
top: .word row2_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -315,14 +315,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '7'
pos: .word col1_left + 6, row2_bot
box: .word col1_left,row2_top,col1_right,row2_bot
port: .word col1_left,row2_top,col1_right,row2_bot
.endproc
.proc btn_8
left: .word col2_left - border_lt
top: .word row2_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -330,14 +330,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '8'
pos: .word col2_left + 6, row2_bot
box: .word col2_left,row2_top,col2_right,row2_bot
port: .word col2_left,row2_top,col2_right,row2_bot
.endproc
.proc btn_9
left: .word col3_left - border_lt
top: .word row2_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -345,14 +345,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '9'
pos: .word col3_left + 6, row2_bot
box: .word col3_left,row2_top,col3_right,row2_bot
port: .word col3_left,row2_top,col3_right,row2_bot
.endproc
.proc btn_div
left: .word col4_left - border_lt
top: .word row2_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -360,14 +360,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '/'
pos: .word col4_left + 6, row2_bot
box: .word col4_left,row2_top,col4_right,row2_bot
port: .word col4_left,row2_top,col4_right,row2_bot
.endproc
.proc btn_4
left: .word col1_left - border_lt
top: .word row3_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -375,14 +375,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '4'
pos: .word col1_left + 6, row3_bot
box: .word col1_left,row3_top,col1_right,row3_bot
port: .word col1_left,row3_top,col1_right,row3_bot
.endproc
.proc btn_5
left: .word col2_left - border_lt
top: .word row3_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -390,14 +390,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '5'
pos: .word col2_left + 6, row3_bot
box: .word col2_left,row3_top,col2_right,row3_bot
port: .word col2_left,row3_top,col2_right,row3_bot
.endproc
.proc btn_6
left: .word col3_left - border_lt
top: .word row3_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -405,14 +405,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '6'
pos: .word col3_left + 6, row3_bot
box: .word col3_left,row3_top,col3_right,row3_bot
port: .word col3_left,row3_top,col3_right,row3_bot
.endproc
.proc btn_sub
left: .word col4_left - border_lt
top: .word row3_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -420,14 +420,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '-'
pos: .word col4_left + 6, row3_bot
box: .word col4_left,row3_top,col4_right,row3_bot
port: .word col4_left,row3_top,col4_right,row3_bot
.endproc
.proc btn_1
left: .word col1_left - border_lt
top: .word row4_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -435,14 +435,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '1'
pos: .word col1_left + 6, row4_bot
box: .word col1_left,row4_top,col1_right,row4_bot
port: .word col1_left,row4_top,col1_right,row4_bot
.endproc
.proc btn_2
left: .word col2_left - border_lt
top: .word row4_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -450,14 +450,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '2'
pos: .word col2_left + 6, row4_bot
box: .word col2_left,row4_top,col2_right,row4_bot
port: .word col2_left,row4_top,col2_right,row4_bot
.endproc
.proc btn_3
left: .word col3_left - border_lt
top: .word row4_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -465,14 +465,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '3'
pos: .word col3_left + 6, row4_bot
box: .word col3_left,row4_top,col3_right,row4_bot
port: .word col3_left,row4_top,col3_right,row4_bot
.endproc
.proc btn_0
left: .word col1_left - border_lt
top: .word row5_top - border_lt
bitmap: .addr wide_button_bitmap
stride: .byte 8 ; bitmap_stride (bytes)
mapwidth: .byte 8 ; bitmap_stride (bytes)
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -480,14 +480,14 @@ width: .word 49 ; 0 is extra wide
height: .word button_height + border_lt + border_br
label: .byte '0'
pos: .word col1_left + 6, row5_bot
box: .word col1_left,row5_top,col2_right,row5_bot
port: .word col1_left,row5_top,col2_right,row5_bot
.endproc
.proc btn_dec
left: .word col3_left - border_lt
top: .word row5_top - border_lt
bitmap: .addr button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -495,14 +495,14 @@ width: .word button_width + border_lt + border_br
height: .word button_height + border_lt + border_br
label: .byte '.'
pos: .word col3_left + 6 + 2, row5_bot ; + 2 to center the label
box: .word col3_left,row5_top,col3_right,row5_bot
port: .word col3_left,row5_top,col3_right,row5_bot
.endproc
.proc btn_add
left: .word col4_left - border_lt
top: .word row4_top - border_lt
bitmap: .addr tall_button_bitmap
stride: .byte bitmap_stride
mapwidth: .byte bitmap_stride
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -510,7 +510,7 @@ width: .word button_width + border_lt + border_br
height: .word 27 ; + is extra tall
label: .byte '+'
pos: .word col4_left + 6, row5_bot
box: .word col4_left,row4_top,col4_right,row5_bot
port: .word col4_left,row4_top,col4_right,row5_bot
.endproc
.byte 0 ; sentinel
@ -647,8 +647,8 @@ height: .word display_height-1
label: .byte 0 ; modified with char to draw
.proc drawtext_params1
addr: .addr text_buffer1
length: .byte 15
textptr: .addr text_buffer1
textlen: .byte 15
.endproc
text_buffer_size := 14
@ -657,8 +657,8 @@ text_buffer1:
.res text_buffer_size+2, 0
.proc drawtext_params2
addr: .addr text_buffer2
length: .byte 15
textptr: .addr text_buffer2
textlen: .byte 15
.endproc
text_buffer2:
@ -671,15 +671,15 @@ error_string:
;; used when clearing display; params to a $18 call
.proc textwidth_params
addr: .addr text_buffer1
len: .byte 15 ; ???
width: .word 0
textptr: .addr text_buffer1
textlen: .byte 15 ; ???
result: .word 0
.endproc
window_id = 52
da_window_id = 52
.proc closewindow_params
id: .byte window_id
window_id: .byte da_window_id
.endproc
.proc text_pos_params3
@ -703,7 +703,7 @@ farg: .byte $00,$00,$00,$00,$00,$00
left: .word 115 ; overwritten
top: .word $FFF7 ; overwritten
bitmap:.addr pixels
stride: .byte 1
mapwidth: .byte 1
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -722,8 +722,8 @@ pixels: .byte px(%1000001)
.proc port_params
left: .word 0
top: .word 0
addr: .word 0
stride: .word 0
mapbits: .word 0
mapwidth: .word 0
hoff: .word 0
voff: .word 0
width: .word 0
@ -751,8 +751,8 @@ font: .addr 0
.proc screen_port
left: .word 0
top: .word menu_bar_height
addr: .word MGTK::screen_mapbits
stride: .word MGTK::screen_mapwidth
mapbits: .word MGTK::screen_mapbits
mapwidth: .word MGTK::screen_mapwidth
hoff: .word 0
voff: .word 0
width: .word screen_width - 1
@ -774,8 +774,8 @@ mode: .byte MGTK::notpenXOR
default_left := 210
default_top := 60
.proc openwindow_params
id: .byte window_id
.proc winfo
window_id: .byte da_window_id
flags: .byte MGTK::option_go_away_box
title: .addr window_title
hscroll:.byte MGTK::scroll_option_none
@ -784,15 +784,16 @@ hs_max: .byte 0
hs_pos: .byte 0
vs_max: .byte 0
vs_pos: .byte 0
.byte 0,0 ; ???
w1: .word window_width
h1: .word window_height
w2: .word window_width
h2: .word window_height
status: .byte 0
reserved: .byte 0
mincontwidth: .word window_width
mincontlength: .word window_height
maxcontwidth: .word window_width
maxcontlength: .word window_height
left: .word default_left
top: .word default_top
addr: .addr MGTK::screen_mapbits
stride: .word MGTK::screen_mapwidth
mapbits: .addr MGTK::screen_mapbits
mapwidth: .word MGTK::screen_mapwidth
hoff: .word 0
voff: .word 0
width: .word window_width
@ -809,7 +810,7 @@ tmask: .byte $7f
font: .addr DEFAULT_FONT
next: .addr 0
.endproc
openwindow_params_top := openwindow_params::top
openwindow_params_top := winfo::top
window_title:
PASCAL_STRING "Calc"
@ -849,7 +850,7 @@ init: sta ALTZPON
lda LCBANK1
lda LCBANK1
MGTK_CALL MGTK::SetZP1, preserve_zp_params
MGTK_CALL MGTK::OpenWindow, openwindow_params
MGTK_CALL MGTK::OpenWindow, winfo
MGTK_CALL MGTK::InitPort, port_params
MGTK_CALL MGTK::SetPort, port_params ; set clipping bounds?
MGTK_CALL MGTK::FlushEvents
@ -859,7 +860,7 @@ init: sta ALTZPON
MGTK_CALL MGTK::GetEvent, event_params
lda ROMIN2
jsr reset_buffer2
lda #window_id
lda #da_window_id
jsr check_visibility_and_draw_window
jsr reset_buffers_and_display
@ -946,8 +947,8 @@ on_click:
lda findwindow_params::which_area
cmp #MGTK::area_content
bcc ignore_click
lda findwindow_params::id
cmp #window_id ; This window?
lda findwindow_params::window_id
cmp #da_window_id ; This window?
beq :+
ignore_click:
@ -993,11 +994,11 @@ loop: lda routine,x
: cmp #MGTK::area_dragbar ; Title bar?
bne ignore_click
lda #window_id
sta drag_params::id
lda #da_window_id
sta dragwindow_params::window_id
lda LCBANK1
lda LCBANK1
MGTK_CALL MGTK::DragWindow, drag_params
MGTK_CALL MGTK::DragWindow, dragwindow_params
lda ROMIN2
jsr redraw_screen_and_window
rts
@ -1034,14 +1035,14 @@ rts1: rts ; used by next proc
;;; If a button was clicked, carry is set and accum has key char
.proc map_click_to_button
lda #window_id
sta screentowindow_params::id
lda #da_window_id
sta screentowindow_params::window_id
MGTK_CALL MGTK::ScreenToWindow, screentowindow_params
lda screentowindow_params::clientx+1 ; ensure high bits of coords are 0
ora screentowindow_params::clienty+1
lda screentowindow_params::windowx+1 ; ensure high bits of coords are 0
ora screentowindow_params::windowy+1
bne rts1
lda screentowindow_params::clienty
ldx screentowindow_params::clientx
lda screentowindow_params::windowy
ldx screentowindow_params::windowx
.proc find_button_row
cmp #row1_top+border_lt - 1 ; row 1 ? (- 1 is bug in original?)
@ -1083,7 +1084,7 @@ rts1: rts ; used by next proc
: cmp #row5_top-border_lt ; special case for tall + button
bcs :+
lda screentowindow_params::clientx
lda screentowindow_params::windowx
cmp #col4_left-border_lt
bcc miss
cmp #col4_right+border_br-1 ; is -1 bug in original?
@ -1099,7 +1100,7 @@ rts1: rts ; used by next proc
lda row5_lookup,x
rts
: lda screentowindow_params::clientx ; special case for wide 0 button
: lda screentowindow_params::windowx ; special case for wide 0 button
cmp #col1_left-border_lt
bcc miss
cmp #col2_right+border_br
@ -1171,8 +1172,8 @@ miss: clc
.proc process_key
cmp #'C' ; Clear?
bne :+
ldx #<btn_c::box
ldy #>btn_c::box
ldx #<btn_c::port
ldy #>btn_c::port
lda #'c'
jsr depress_button
lda #$00
@ -1192,8 +1193,8 @@ miss: clc
: cmp #'E' ; Exponential?
bne try_eq
ldx #<btn_e::box
ldy #>btn_e::box
ldx #<btn_e::port
ldy #>btn_e::port
lda #'e'
jsr depress_button
ldy calc_e
@ -1213,21 +1214,21 @@ rts1: rts
try_eq: cmp #'=' ; Equals?
bne :+
pha
ldx #<btn_eq::box
ldy #>btn_eq::box
ldx #<btn_eq::port
ldy #>btn_eq::port
jmp do_op_click
: cmp #'*' ; Multiply?
bne :+
pha
ldx #<btn_mul::box
ldy #>btn_mul::box
ldx #<btn_mul::port
ldy #>btn_mul::port
jmp do_op_click
: cmp #'.' ; Decimal?
bne try_add
ldx #<btn_dec::box
ldy #>btn_dec::box
ldx #<btn_dec::port
ldy #>btn_dec::port
jsr depress_button
lda calc_d
ora calc_e
@ -1244,15 +1245,15 @@ rts2: rts
try_add:cmp #'+' ; Add?
bne :+
pha
ldx #<btn_add::box
ldy #>btn_add::box
ldx #<btn_add::port
ldy #>btn_add::port
jmp do_op_click
: cmp #'-' ; Subtract?
bne trydiv
pha
ldx #<btn_sub::box
ldy #>btn_sub::box
ldx #<btn_sub::port
ldy #>btn_sub::port
lda calc_e ; negate vs. subtract
beq :+
lda calc_n
@ -1270,78 +1271,78 @@ try_add:cmp #'+' ; Add?
trydiv: cmp #'/' ; Divide?
bne :+
pha
ldx #<btn_div::box
ldy #>btn_div::box
ldx #<btn_div::port
ldy #>btn_div::port
jmp do_op_click
: cmp #'0' ; Digit 0?
bne :+
pha
ldx #<btn_0::box
ldy #>btn_0::box
ldx #<btn_0::port
ldy #>btn_0::port
jmp do_digit_click
: cmp #'1' ; Digit 1?
bne :+
pha
ldx #<btn_1::box
ldy #>btn_1::box
ldx #<btn_1::port
ldy #>btn_1::port
jmp do_digit_click
: cmp #'2' ; Digit 2?
bne :+
pha
ldx #<btn_2::box
ldy #>btn_2::box
ldx #<btn_2::port
ldy #>btn_2::port
jmp do_digit_click
: cmp #'3' ; Digit 3?
bne :+
pha
ldx #<btn_3::box
ldy #>btn_3::box
ldx #<btn_3::port
ldy #>btn_3::port
jmp do_digit_click
: cmp #'4' ; Digit 4?
bne :+
pha
ldx #<btn_4::box
ldy #>btn_4::box
ldx #<btn_4::port
ldy #>btn_4::port
jmp do_digit_click
: cmp #'5' ; Digit 5?
bne :+
pha
ldx #<btn_5::box
ldy #>btn_5::box
ldx #<btn_5::port
ldy #>btn_5::port
jmp do_digit_click
: cmp #'6' ; Digit 6?
bne :+
pha
ldx #<btn_6::box
ldy #>btn_6::box
ldx #<btn_6::port
ldy #>btn_6::port
jmp do_digit_click
: cmp #'7' ; Digit 7?
bne :+
pha
ldx #<btn_7::box
ldy #>btn_7::box
ldx #<btn_7::port
ldy #>btn_7::port
jmp do_digit_click
: cmp #'8' ; Digit 8?
bne :+
pha
ldx #<btn_8::box
ldy #>btn_8::box
ldx #<btn_8::port
ldy #>btn_8::port
jmp do_digit_click
: cmp #'9' ; Digit 9?
bne :+
pha
ldx #<btn_9::box
ldy #>btn_9::box
ldx #<btn_9::port
ldy #>btn_9::port
jmp do_digit_click
: cmp #$7F ; Delete?
@ -1539,18 +1540,18 @@ end: jsr display_buffer1
sec
ror button_state
invert: MGTK_CALL MGTK::PaintRect, 0, invert_addr ; Inverts box
invert: MGTK_CALL MGTK::PaintRect, 0, invert_addr ; Inverts port
check_button:
MGTK_CALL MGTK::GetEvent, event_params
lda event_params::kind
cmp #MGTK::drag ; Button down?
bne done ; Nope, done immediately
lda #window_id
sta screentowindow_params::id
lda #da_window_id
sta screentowindow_params::window_id
MGTK_CALL MGTK::ScreenToWindow, screentowindow_params
MGTK_CALL MGTK::MoveTo, screentowindow_params::client
MGTK_CALL MGTK::MoveTo, screentowindow_params::window
MGTK_CALL MGTK::InRect, 0, inrect_params
bne inside
@ -1623,12 +1624,12 @@ loop: lda #' '
.endproc
.proc pre_display_buffer
stx textwidth_params::addr ; text buffer address in x,y
sty textwidth_params::addr+1
stx textwidth_params::textptr ; text buffer address in x,y
sty textwidth_params::textptr+1
MGTK_CALL MGTK::TextWidth, textwidth_params
lda #display_width-15 ; ???
sec
sbc textwidth_params::width
sbc textwidth_params::result
sta text_pos_params3::left
MGTK_CALL MGTK::MoveTo, text_pos_params2 ; clear with spaces
MGTK_CALL MGTK::DrawText, spaces_string
@ -1699,16 +1700,16 @@ loop: ldy #0
draw_title_bar:
offset_left := 115 ; pixels from left of client area
offset_top := 22 ; pixels from top of client area (up!)
ldx openwindow_params::left+1
lda openwindow_params::left
ldx winfo::left+1
lda winfo::left
clc
adc #offset_left
sta title_bar_decoration::left
bcc :+
inx
: stx title_bar_decoration::left+1
ldx openwindow_params::top+1
lda openwindow_params::top
ldx winfo::top+1
lda winfo::top
sec
sbc #offset_top
sta title_bar_decoration::top
@ -1717,8 +1718,8 @@ draw_title_bar:
: stx title_bar_decoration::top+1
MGTK_CALL MGTK::SetPortBits, screen_port ; set clipping rect to whole screen
MGTK_CALL MGTK::PaintBits, title_bar_decoration ; Draws decoration in title bar
lda #window_id
sta getwinport_params::id
lda #da_window_id
sta getwinport_params::window_id
MGTK_CALL MGTK::GetWinPort, getwinport_params
MGTK_CALL MGTK::SetPort, port_params
MGTK_CALL MGTK::ShowCursor

View File

@ -175,7 +175,7 @@ year_rect:
.word $7F,$14,$95,$1E
.proc settextbg_params
mask: .byte 0
backcolor: .byte 0 ; black
.endproc
.res 7, $00 ; ???
@ -226,10 +226,10 @@ ycoord := *+2
.endproc
;; xcoord/ycoord are used to query...
.proc findwindow_params
xcoord := *
ycoord := *+2
element:.byte 0
id: .byte 0
mousex := *
mousey := *+2
which_area:.byte 0
window_id: .byte 0
.endproc
window_id := 100
@ -239,9 +239,9 @@ id: .byte window_id
screen:
screenx:.word 0
screeny:.word 0
client:
clientx:.word 0
clienty:.word 0
window:
windowx:.word 0
windowy:.word 0
.endproc
.proc closewindow_params
@ -254,26 +254,27 @@ mode: .byte $02 ; this should be normal, but we do inverts ???
.endproc
.byte $06 ; ???
.proc openwindow_params
.proc winfo
id: .byte window_id
flags: .byte MGTK::option_dialog_box
options:.byte MGTK::option_dialog_box
title: .addr 0
hscroll:.byte MGTK::scroll_option_none
vscroll:.byte MGTK::scroll_option_none
hsmax: .byte 0
hspos: .byte 0
vsmax: .byte 0
vspos: .byte 0
.byte 0, 0 ; ???
w1: .word 100
h1: .word 100
w2: .word $1F4
h2: .word $1F4
.proc box
hthumbmax: .byte 0
hthumbpos: .byte 0
vthumbmax: .byte 0
vthumbpos: .byte 0
status: .byte 0
reserved: .byte 0
mincontwidth: .word 100
mincontlength: .word 100
maxcontwidth: .word $1F4
maxcontlength: .word $1F4
.proc port
left: .word 180
top: .word 50
addr: .addr MGTK::screen_mapbits
stride: .word MGTK::screen_mapwidth
mapbits: .addr MGTK::screen_mapbits
mapwidth: .word MGTK::screen_mapwidth
hoff: .word 0
voff: .word 0
width: .word $C7
@ -321,7 +322,7 @@ init_window:
lsr a
sta month
MGTK_CALL MGTK::OpenWindow, openwindow_params
MGTK_CALL MGTK::OpenWindow, winfo
lda #0
sta selected_field
jsr draw_window
@ -406,10 +407,10 @@ update_selection:
MGTK_CALL MGTK::FindWindow, event_params::xcoord
MGTK_CALL MGTK::SetPenMode, penmode_params
MGTK_CALL MGTK::SetPattern, white_pattern
lda findwindow_params::id
lda findwindow_params::window_id
cmp #window_id
bne miss
lda findwindow_params::element
lda findwindow_params::which_area
bne hit
miss: rts
@ -718,7 +719,7 @@ skip: jmp dest
lda event_params::ycoord+1
sta screentowindow_params::screeny+1
MGTK_CALL MGTK::ScreenToWindow, screentowindow_params
MGTK_CALL MGTK::MoveTo, screentowindow_params::client
MGTK_CALL MGTK::MoveTo, screentowindow_params::window
ldx #1
lda #<first_hit_rect
sta test_addr
@ -787,7 +788,7 @@ vthick: .byte 1
;;; Render the window contents
draw_window:
MGTK_CALL MGTK::SetPort, openwindow_params::box
MGTK_CALL MGTK::SetPort, winfo::port
MGTK_CALL MGTK::FrameRect, border_rect
MGTK_CALL MGTK::SetPenSize, setpensize_params
MGTK_CALL MGTK::FrameRect, date_rect

View File

@ -237,8 +237,8 @@ position_table:
.proc draw_bitmap_params
left: .word 0
top: .word 0
addr: .addr 0
stride: .byte 4
mapbits: .addr 0
mapwidth: .byte 4
.byte 0 ; ???
hoff: .word 0
voff: .word 0
@ -591,26 +591,26 @@ setport_params:
default_width := $79
default_height := $44
.proc openwindow_params
.proc winfo
id: .byte window_id
flags: .byte MGTK::option_go_away_box
title: .addr name
hscroll:.byte MGTK::scroll_option_none
vscroll:.byte MGTK::scroll_option_none
hsmax: .byte 0
hspos: .byte 0
vsmax: .byte 0
vspos: .byte 0
hthumbmax: .byte 0
hthumbpos: .byte 0
vthumbmax: .byte 0
vthumbpos: .byte 0
.byte 0,0 ; ???
w1: .word default_width
h1: .word default_height
w2: .word default_width
h2: .word default_height
mincontwidth: .word default_width
mincontlength: .word default_height
maxcontwidth: .word default_width
maxcontlength: .word default_height
left: .word default_left
top: .word default_top
addr: .addr MGTK::screen_mapbits
stride: .word MGTK::screen_mapwidth
mapbits: .addr MGTK::screen_mapbits
mapwidth: .word MGTK::screen_mapwidth
hoff: .word 0
voff: .word 0
width: .word default_width
@ -633,8 +633,8 @@ next: .addr 0
.proc box_cruft ; Unknown usage
left: .word default_left
top: .word default_top
addr: .addr MGTK::screen_mapbits
stride: .word MGTK::screen_mapwidth
mapbits: .addr MGTK::screen_mapbits
mapwidth: .word MGTK::screen_mapwidth
hoff: .word 0
voff: .word 0
width: .word default_width
@ -654,14 +654,14 @@ font: .addr DEFAULT_FONT
name: PASCAL_STRING "Puzzle"
openwindow_params_top := openwindow_params::top
openwindow_params_top := winfo::top
;;; ==================================================
;;; Create the window
.proc create_window
jsr save_zp
MGTK_CALL MGTK::OpenWindow, openwindow_params
MGTK_CALL MGTK::OpenWindow, winfo
;; init pieces
ldy #15
@ -742,7 +742,7 @@ bail: rts
bcc bail
jmp process_click
;; close box?
;; close port?
: cmp #MGTK::area_close_box
bne check_title
MGTK_CALL MGTK::TrackGoAway, trackgoaway_params
@ -1087,9 +1087,9 @@ loop: tya
asl a
tax
lda bitmap_table,x
sta draw_bitmap_params::addr
sta draw_bitmap_params::mapbits
lda bitmap_table+1,x
sta draw_bitmap_params::addr+1
sta draw_bitmap_params::mapbits+1
MGTK_CALL MGTK::PaintBits, draw_bitmap_params
pla
clc

View File

@ -199,21 +199,21 @@ flags: .byte MGTK::option_dialog_box
title: .addr window_title
hscroll:.byte MGTK::scroll_option_none
vscroll:.byte MGTK::scroll_option_none
hsmax: .byte 32
hspos: .byte 0
vsmax: .byte 32
vspos: .byte 0
hthumbmax: .byte 32
hthumbpos: .byte 0
vthumbmax: .byte 32
vthumbpos: .byte 0
.byte 0, 0 ; ???
w1: .word default_width
h1: .word default_height
w2: .word default_width
h2: .word default_height
mincontwidth: .word default_width
mincontlength: .word default_height
maxcontwidth: .word default_width
maxcontlength: .word default_height
.proc box
.proc port
left: .word default_left
top: .word default_top
addr: .addr MGTK::screen_mapbits
stride: .word MGTK::screen_mapwidth
mapbits: .addr MGTK::screen_mapbits
mapwidth: .word MGTK::screen_mapwidth
hoff: .word 0
voff: .word 0
width: .word default_width
@ -345,7 +345,7 @@ end: rts
MGTK_CALL MGTK::HideCursor
jsr stash_menu
MGTK_CALL MGTK::OpenWindow, window_params
MGTK_CALL MGTK::SetPort, window_params::box
MGTK_CALL MGTK::SetPort, window_params::port
jsr show_file
MGTK_CALL MGTK::ShowCursor

View File

@ -304,25 +304,25 @@ len: .byte 0 ; length
.proc window_params
id: .byte window_id ; window identifier
flags: .byte MGTK::option_go_away_box; window flags (2=include close box)
flags: .byte MGTK::option_go_away_box; window flags (2=include close port)
title: .addr $1000 ; overwritten to point at filename
hscroll:.byte MGTK::scroll_option_none
vscroll:.byte MGTK::scroll_option_normal
hsmax: .byte 32
hspos: .byte 0
vsmax: .byte 255
vspos: .byte 0
hthumbmax: .byte 32
hthumbpos: .byte 0
vthumbmax: .byte 255
vthumbpos: .byte 0
.byte 0, 0 ; ???
w1: .word 200
h1: .word 51
w2: .word default_width
h2: .word default_height
mincontwidth: .word 200
mincontlength: .word 51
maxcontwidth: .word default_width
maxcontlength: .word default_height
.proc box
.proc port
left: .word default_left
top: .word default_top
addr: .addr MGTK::screen_mapbits
stride: .word MGTK::screen_mapwidth
mapbits: .addr MGTK::screen_mapbits
mapwidth: .word MGTK::screen_mapwidth
hoff: .word 0 ; Also used for MGTK::PaintRect
voff: .word 0
width: .word default_width
@ -342,12 +342,12 @@ font: .addr DEFAULT_FONT
next: .addr 0
.endproc
;; gets copied over window_params::box after mode is drawn
;; gets copied over window_params::port after mode is drawn
.proc default_box
left: .word default_left
top: .word default_top
addr: .word MGTK::screen_mapbits
stride: .word MGTK::screen_mapwidth
mapbits: .word MGTK::screen_mapbits
mapwidth: .word MGTK::screen_mapwidth
hoff: .word 0
voff: .word 0
width: .word default_width
@ -498,7 +498,7 @@ loop: lda font_width_table - 1,x
;; create window
MGTK_CALL MGTK::OpenWindow, window_params
MGTK_CALL MGTK::SetPort, window_params::box
MGTK_CALL MGTK::SetPort, window_params::port
jsr calc_window_size
jsr calc_and_draw_mode
jsr draw_content
@ -570,23 +570,23 @@ title: jsr on_title_bar_click
max_width := default_width
lda #>max_width
cmp window_params::box::width+1
cmp window_params::port::width+1
bne :+
lda #<max_width
cmp window_params::box::width
cmp window_params::port::width
: bcs wider
lda #<max_width
sta window_params::box::width
sta window_params::port::width
lda #>max_width
sta window_params::box::width+1
sta window_params::port::width+1
sec
lda window_params::box::width
lda window_params::port::width
sbc window_width
sta window_params::box::hoff
lda window_params::box::width+1
sta window_params::port::hoff
lda window_params::port::width+1
sbc window_width+1
sta window_params::box::hoff+1
sta window_params::port::hoff+1
wider: lda window_params::hscroll
ldx window_width
cpx #<max_width
@ -672,11 +672,11 @@ end: rts
.endproc
.proc on_vscroll_above_click
loop: lda window_params::vspos
loop: lda window_params::vthumbpos
beq end
jsr calc_track_scroll_delta
sec
lda window_params::vspos
lda window_params::vthumbpos
sbc track_scroll_delta
bcs store
lda #0 ; underflow
@ -687,7 +687,7 @@ end: rts
.endproc
.proc on_vscroll_up_click
loop : lda window_params::vspos
loop : lda window_params::vthumbpos
beq end
sec
sbc #1
@ -700,12 +700,12 @@ end: rts
vscroll_max := $FA
.proc on_vscroll_below_click
loop: lda window_params::vspos
loop: lda window_params::vthumbpos
cmp #vscroll_max ; pos == max ?
beq end
jsr calc_track_scroll_delta
clc
lda window_params::vspos
lda window_params::vthumbpos
adc track_scroll_delta ; pos + delta
bcs overflow
cmp #vscroll_max+1 ; > max ?
@ -719,7 +719,7 @@ end: rts
.endproc
.proc on_vscroll_down_click
loop: lda window_params::vspos
loop: lda window_params::vthumbpos
cmp #vscroll_max
beq end
clc
@ -782,16 +782,16 @@ loop: inx
lda thumb_drag_params::pos
jsr mul_by_16
lda $06
sta window_params::box::hoff
sta window_params::port::hoff
lda $07
sta window_params::box::hoff+1
sta window_params::port::hoff+1
clc
lda window_params::box::hoff
lda window_params::port::hoff
adc window_width
sta window_params::box::width
lda window_params::box::hoff+1
sta window_params::port::width
lda window_params::port::hoff+1
adc window_width+1
sta window_params::box::width+1
sta window_params::port::width+1
jsr update_hscroll
jsr draw_content
end: rts
@ -799,7 +799,7 @@ end: rts
.proc on_hscroll_after_click
ldx #2
lda window_params::hsmax
lda window_params::hthumbmax
jmp hscroll_common
.endproc
@ -811,7 +811,7 @@ end: rts
.proc on_hscroll_right_click
ldx #1
lda window_params::hsmax
lda window_params::hthumbmax
jmp hscroll_common
.endproc
@ -824,23 +824,23 @@ end: rts
.proc hscroll_common
sta compare+1
stx delta+1
loop: lda window_params::hspos
loop: lda window_params::hthumbpos
compare:cmp #$0A ; self-modified
bne continue
rts
continue:
clc
lda window_params::hspos
lda window_params::hthumbpos
delta: adc #1 ; self-modified
bmi overflow
cmp window_params::hsmax
cmp window_params::hthumbmax
beq store
bcc store
lda window_params::hsmax
lda window_params::hthumbmax
jmp store
overflow:
lda #0
store: sta window_params::hspos
store: sta window_params::hthumbpos
jsr adjust_box_width
jsr update_hscroll
jsr draw_content
@ -874,44 +874,44 @@ store: sta window_params::hspos
;;; only used from hscroll code?
.proc adjust_box_width
lda window_params::hspos
lda window_params::hthumbpos
jsr mul_by_16
clc
lda $06
sta window_params::box::hoff
sta window_params::port::hoff
adc window_width
sta window_params::box::width
sta window_params::port::width
lda $07
sta window_params::box::hoff+1
sta window_params::port::hoff+1
adc window_width+1
sta window_params::box::width+1
sta window_params::port::width+1
rts
.endproc
.proc update_voffset
lda #0
sta window_params::box::voff
sta window_params::box::voff+1
sta window_params::port::voff
sta window_params::port::voff+1
ldx updatethumb_params::pos
loop: beq adjust_box_height
clc
lda window_params::box::voff
lda window_params::port::voff
adc #50
sta window_params::box::voff
sta window_params::port::voff
bcc :+
inc window_params::box::voff+1
inc window_params::port::voff+1
: dex
jmp loop
.endproc
.proc adjust_box_height
clc
lda window_params::box::voff
lda window_params::port::voff
adc window_height
sta window_params::box::height
lda window_params::box::voff+1
sta window_params::port::height
lda window_params::port::voff+1
adc window_height+1
sta window_params::box::height+1
sta window_params::port::height+1
jsr calc_line_position
lda #0
sta L096A
@ -932,9 +932,9 @@ end: rts
.proc update_hscroll
lda #2
sta updatethumb_params::type
lda window_params::box::hoff
lda window_params::port::hoff
sta $06
lda window_params::box::hoff+1
lda window_params::port::hoff+1
sta $07
jsr div_by_16
sta updatethumb_params::pos
@ -951,12 +951,12 @@ end: rts
.proc finish_resize ; only called from dead code
DESKTOP_CALL DESKTOP_REDRAW_ICONS
MGTK_CALL MGTK::SetPort, window_params::box
MGTK_CALL MGTK::SetPort, window_params::port
lda window_params::hscroll
ror a ; check if low bit (track enabled) is set
bcc :+
jsr update_hscroll
: lda window_params::vspos
: lda window_params::vthumbpos
sta updatethumb_params::pos
jsr update_vscroll
jsr draw_content
@ -965,7 +965,7 @@ end: rts
.proc clear_window
MGTK_CALL MGTK::SetPattern, white_pattern
MGTK_CALL MGTK::PaintRect, window_params::box::hoff
MGTK_CALL MGTK::PaintRect, window_params::port::hoff
MGTK_CALL MGTK::SetPattern, black_pattern
rts
.endproc
@ -1275,16 +1275,16 @@ end: rts
.proc calc_window_size
sec
lda window_params::box::width
sbc window_params::box::hoff
lda window_params::port::width
sbc window_params::port::hoff
sta window_width
lda window_params::box::width+1
sbc window_params::box::hoff+1
lda window_params::port::width+1
sbc window_params::port::hoff+1
sta window_width+1
sec
lda window_params::box::height
sbc window_params::box::voff
lda window_params::port::height
sbc window_params::port::voff
sta window_height
;; fall through
.endproc
@ -1292,9 +1292,9 @@ end: rts
;;; ==================================================
.proc calc_line_position
lda window_params::box::height
lda window_params::port::height
sta L0965
lda window_params::box::height+1
lda window_params::port::height+1
sta L0966
lda #0
@ -1430,11 +1430,11 @@ fixed_str: DEFINE_STRING "Fixed "
prop_str: DEFINE_STRING "Proportional"
label_width := 50
title_bar_height := 12
.proc mode_box ; bounding box for mode label
.proc mode_box ; bounding port for mode label
left: .word 0
top: .word 0
addr: .word MGTK::screen_mapbits
stride: .word MGTK::screen_mapwidth
mapbits: .word MGTK::screen_mapbits
mapwidth: .word MGTK::screen_mapwidth
hoff: .word 0
voff: .word 0
width: .word 80
@ -1450,14 +1450,14 @@ base: .word 10 ; vertical text offset (to baseline)
.proc calc_and_draw_mode
sec
lda window_params::box::top
lda window_params::port::top
sbc #title_bar_height
sta mode_box::top
clc
lda window_params::box::left
lda window_params::port::left
adc window_width
pha
lda window_params::box::left+1
lda window_params::port::left+1
adc window_width+1
tax
sec
@ -1481,9 +1481,9 @@ else: MGTK_CALL MGTK::DrawText, prop_str
endif: ldx #$0F
loop: lda default_box,x
sta window_params::box,x
sta window_params::port,x
dex
bpl loop
MGTK_CALL MGTK::SetPortBits, window_params::box
MGTK_CALL MGTK::SetPortBits, window_params::port
rts
.endproc