Merge remote-tracking branch 'origin/disasm'

This commit is contained in:
Joshua Bell 2019-04-01 19:03:36 -07:00
commit 1abe9dec39
5 changed files with 236 additions and 151 deletions

View File

@ -193,14 +193,14 @@ last_menu_click_params := $E23D
;;; .res 17 name (name, with a space before and after) ;;; .res 17 name (name, with a space before and after)
.struct IconEntry .struct IconEntry
id .byte id .byte ; 0
state .byte state .byte ; 1
win_type .byte win_type .byte ; 2
iconx .word iconx .word ; 3
icony .word icony .word ; 5
iconbits .addr iconbits .addr ; 7
len .byte len .byte ; 9
name .res 17 ; 15 chars plus leading/trailing spaces name .res 17 ; 10 (15 chars plus leading/trailing spaces)
.endstruct .endstruct
max_icon_count = 127 max_icon_count = 127

View File

@ -575,7 +575,7 @@ not_menu:
jmp start jmp start
L445C: .byte 0 winid: .byte 0
start: jsr clear_selection start: jsr clear_selection
@ -588,24 +588,27 @@ start: jsr clear_selection
lda icon_param lda icon_param
jsr icon_entry_lookup jsr icon_entry_lookup
stax ptr stax ptr
ldy #1
ldy #IconEntry::state ; set state to open
lda (ptr),y lda (ptr),y
beq L44A6 beq continue
ora #$80 ora #icon_entry_open_mask
sta (ptr),y sta (ptr),y
iny
iny ; IconEntry::win_type
lda (ptr),y lda (ptr),y
and #$0F and #icon_entry_winid_mask
sta L445C sta winid
jsr zero_grafport5_coords jsr zero_grafport5_coords
DESKTOP_RELAY_CALL DT_HIGHLIGHT_ICON, icon_param DESKTOP_RELAY_CALL DT_HIGHLIGHT_ICON, icon_param
jsr reset_grafport3 jsr reset_grafport3
copy L445C, selected_window_index copy winid, selected_window_index
copy #1, selected_icon_count copy #1, selected_icon_count
copy icon_param, selected_icon_list copy icon_param, selected_icon_list
;; Actually make the window active. ;; Actually make the window active.
L44A6: MGTK_RELAY_CALL MGTK::SelectWindow, findwindow_window_id continue:
MGTK_RELAY_CALL MGTK::SelectWindow, findwindow_window_id
copy findwindow_window_id, active_window_id copy findwindow_window_id, active_window_id
jsr LoadActiveWindowIconTable jsr LoadActiveWindowIconTable
jsr L6C19 jsr L6C19
@ -2962,7 +2965,7 @@ L56F8: .byte 0
L5708: sta $800 L5708: sta $800
ldy #$01 ldy #$01
ldx #$00 ldx #0
L570F: lda window_to_dir_icon_table,x L570F: lda window_to_dir_icon_table,x
beq L5720 beq L5720
inx inx
@ -4041,7 +4044,7 @@ L5E77: .byte 0
lda (ptr),y lda (ptr),y
tay tay
: lda (ptr),y : lda (ptr),y
sta LE1B0,y sta open_dir_path_buf,y
dey dey
bpl :- bpl :-
@ -4286,26 +4289,30 @@ handle_close_click:
rts rts
.proc close_window .proc close_window
icon_ptr := $06
jsr LoadActiveWindowIconTable jsr LoadActiveWindowIconTable
jsr clear_selection jsr clear_selection
ldx active_window_id ldx active_window_id
dex dex
lda win_view_by_table,x lda win_view_by_table,x
bmi L6215 ; list view, not icons bmi iter ; list view, not icons
lda icon_count lda icon_count
sec sec
sbc cached_window_icon_count sbc cached_window_icon_count
sta icon_count sta icon_count
DESKTOP_RELAY_CALL DT_CLOSE_WINDOW, active_window_id DESKTOP_RELAY_CALL DT_CLOSE_WINDOW, active_window_id
ldx #$00 ldx #$00
L6206: cpx cached_window_icon_count L6206: cpx cached_window_icon_count
beq L6215 beq iter
lda cached_window_icon_list,x lda cached_window_icon_list,x
jsr FreeIcon jsr FreeIcon
inx inx
jmp L6206 jmp L6206
L6215: dec num_open_windows iter: dec num_open_windows
ldx #$00 ldx #$00
txa txa
L621B: sta cached_window_icon_list,x L621B: sta cached_window_icon_list,x
@ -5243,7 +5250,7 @@ update_view:
jsr icon_window_to_screen jsr icon_window_to_screen
jsr reset_grafport3 jsr reset_grafport3
skip2: jsr L744B skip2: jsr prepare_new_window
;; Create the window ;; Create the window
lda cached_window_id lda cached_window_id
@ -5842,7 +5849,7 @@ L70C4: .byte $00
sta L72A7 sta L72A7
jsr push_pointers jsr push_pointers
COPY_BYTES $41, LE1B0, path_buffer COPY_BYTES 65, open_dir_path_buf, path_buffer
jsr do_open jsr do_open
lda open_params::ref_num lda open_params::ref_num
@ -6130,12 +6137,12 @@ get_vol_free_used:
.proc L7345 .proc L7345
sta L7445 sta L7445
ldx #$00 ldx #0
L734A: lda LE1F1+1,x L734A: lda LE1F1+1,x
cmp L7445 cmp L7445
beq :+ beq :+
inx inx
cpx #$08 cpx #8
bne L734A bne L734A
rts rts
@ -6214,92 +6221,130 @@ L7449: .word 0
.endproc .endproc
;;; ============================================================ ;;; ============================================================
;;; Set up path and coords for new window, contents and free/used.
;;;
;;; Inputs: IconEntry pointer in $06, new window_id in cached_window_id
;;; Outputs: Winfo configured, open_dir_path_buf has full path
.proc L744B .proc prepare_new_window
icon_ptr := $06
title_ptr := $08
;; Get icon name length, update ptr
lda cached_window_id lda cached_window_id
asl a asl a
tax tax
copy16 LE6BF,x, $08 copy16 window_title_addr_table,x, title_ptr
ldy #$09 ldy #IconEntry::len
lda ($06),y lda (icon_ptr),y
tay tay ; length in Y
jsr push_pointers jsr push_pointers
lda $06 lda icon_ptr
clc clc
adc #$09 adc #IconEntry::len
sta $06 sta icon_ptr
bcc L746D bcc :+
inc $06+1 inc icon_ptr+1
L746D: tya : tya
tax tax ; length in X
ldy #$00
L7471: lda ($06),y ;; Copy name (with leading/trailing spaces) to title
sta ($08),y ldy #0
: lda (icon_ptr),y
sta (title_ptr),y
iny iny
dex dex
bne L7471 bne :-
lda #$20
sta ($08),y lda #' '
sta (title_ptr),y
ldy #IconEntry::win_type ldy #IconEntry::win_type
lda ($08),y lda (title_ptr),y
and #%11011111 ; ??? and #%11011111 ; upcase first letter
sta ($08),y sta (title_ptr),y
jsr pop_pointers jsr pop_pointers
;; Is there a parent window?
ldy #IconEntry::win_type ldy #IconEntry::win_type
lda ($06),y lda (icon_ptr),y
and #icon_entry_winid_mask and #icon_entry_winid_mask
bne L74D3 bne has_parent
;; --------------------------------------------------
;; Desktop (volume) icon; no parent path
path_ptr := $08
jsr push_pointers jsr push_pointers
lda cached_window_id lda cached_window_id
jsr window_path_lookup jsr window_path_lookup
stax $08 stax path_ptr
lda $06
;; Point at length-prefixed icon name (with leading/trailing spaces)
lda icon_ptr
clc clc
adc #$09 adc #IconEntry::len
sta $06 sta icon_ptr
bcc L74A8 bcc :+
inc $06+1 inc icon_ptr+1
L74A8: ldy #$00 : ldy #0
lda ($06),y lda ($06),y
tay tay ; Y = length
L74AD: lda ($06),y
sta ($08),y ;; Copy, including leading/trailing spaces
: lda (icon_ptr),y
sta (path_ptr),y
dey dey
bpl L74AD bpl :-
ldy #$00
lda ($08),y ;; Reduce length by one (trailing space)
ldy #0
lda (path_ptr),y
sec sec
sbc #$01 sbc #1
sta ($08),y sta (path_ptr),y
;; Convert leading space to '/'
ldy #1 ldy #1
lda #'/' lda #'/'
sta ($08),y sta (path_ptr),y
ldy #$00
lda ($08),y
tay
L74C8: lda ($08),y
sta LE1B0,y
dey
bpl L74C8
jmp L7569
L74D3: tay ;; Copy path to open_dir_path_buf ???
copy #$00, L7620 ldy #0
lda (path_ptr),y
tay
: lda (path_ptr),y
sta open_dir_path_buf,y
dey
bpl :-
jmp common
;; --------------------------------------------------
;; Windowed (folder) icon; has a parent path
parent_path_ptr := $06
has_parent:
tay
copy #$00, L7620 ; ???
jsr push_pointers jsr push_pointers
tya tya
pha pha
jsr window_path_lookup jsr window_path_lookup
stax $06 stax parent_path_ptr
pla pla
asl a asl a
tax tax
copy16 LE6BF,x, $08 copy16 window_title_addr_table,x, title_ptr
ldy #$00 ldy #0
lda ($06),y lda (parent_path_ptr),y
clc clc
adc ($08),y adc (title_ptr),y
cmp #$43 cmp #67 ; Max path length is 64; title has leading/trailing spaces
bcc L750D bcc :+
lda #ERR_INVALID_PATHNAME lda #ERR_INVALID_PATHNAME
jsr ShowAlert jsr ShowAlert
jsr mark_icons_not_opened_2 jsr mark_icons_not_opened_2
@ -6308,102 +6353,133 @@ L74D3: tay
txs txs
rts rts
L750D: ldy #0 ;; Copy parent path to open_dir_path_buf
lda ($06),y : ldy #0
lda (parent_path_ptr),y
tay tay
L7512: lda ($06),y : lda (parent_path_ptr),y
sta LE1B0,y sta open_dir_path_buf,y
dey dey
bpl L7512 bpl :-
;; Suffix with '/'
lda #'/' lda #'/'
sta LE1B0+1 sta open_dir_path_buf+1
inc LE1B0 inc open_dir_path_buf
ldx LE1B0 ldx open_dir_path_buf
sta LE1B0,x sta open_dir_path_buf,x
icon_ptr2 := $08
;; Append icon name
lda icon_params2 lda icon_params2
jsr icon_entry_lookup jsr icon_entry_lookup
stax $08 stax icon_ptr2
ldx LE1B0 ldx open_dir_path_buf
ldy #$09 ldy #IconEntry::len ; compute total length
lda ($08),y lda (icon_ptr2),y
clc clc
adc LE1B0 adc open_dir_path_buf
sta LE1B0 sta open_dir_path_buf
dec LE1B0 dec open_dir_path_buf ; discount leading/trailing spaces
dec LE1B0 dec open_dir_path_buf
ldy #$0A ldy #IconEntry::name
L7548: iny
: iny ; skip leading space immediately
inx inx
lda ($08),y lda (icon_ptr2),y
sta LE1B0,x sta open_dir_path_buf,x
cpx LE1B0 cpx open_dir_path_buf
bne L7548 bne :-
;; Copy into window path
lda cached_window_id lda cached_window_id
jsr window_path_lookup jsr window_path_lookup
stax $08 stax path_ptr
ldy LE1B0 ldy open_dir_path_buf
L7561: lda LE1B0,y : lda open_dir_path_buf,y
sta ($08),y sta (path_ptr),y
dey dey
bpl L7561 bpl :-
L7569: lda cached_window_id
;; --------------------------------------------------
common:
winfo_ptr := $06
;; Set window coordinates
lda cached_window_id
jsr window_lookup jsr window_lookup
stax $06 stax winfo_ptr
ldy #$14 ldy #MGTK::Winfo::port
;; xcoord = (window_id-1) * 16 + 5
;; ycoord = (window_id-1) * 8 + 27
lda cached_window_id lda cached_window_id
sec sec
sbc #$01 sbc #1 ; * 16
asl a asl a
asl a asl a
asl a asl a
asl a asl a
pha pha
adc #$05 adc #5
sta ($06),y sta (winfo_ptr),y ; viewloc::xcoord
iny iny
lda #$00 lda #0
sta ($06),y sta (winfo_ptr),y
iny iny
pla pla
lsr a
lsr a ; / 2
clc clc
adc #.sizeof(IconEntry) adc #27
sta ($06),y sta (winfo_ptr),y ; viewloc::ycoord
iny iny
lda #$00 lda #0
sta ($06),y sta (winfo_ptr),y
lda #$00
ldy #$1F ;; Map rect
ldx #$03 lda #0
L75A3: sta ($06),y ldy #MGTK::Winfo::port + MGTK::GrafPort::maprect + 3
ldx #3
: sta (winfo_ptr),y
dey dey
dex dex
bpl L75A3 bpl :-
ldy #$04
lda ($06),y ;; Scrollbars
and #$FE ldy #MGTK::Winfo::hscroll
sta ($06),y lda (winfo_ptr),y
and #AS_BYTE(~MGTK::Scroll::option_active)
sta (winfo_ptr),y
iny iny
lda ($06),y lda (winfo_ptr),y
and #$FE and #AS_BYTE(~MGTK::Scroll::option_active)
sta ($06),y sta (winfo_ptr),y
lda #$00
ldy #$07 lda #0
sta ($06),y ldy #MGTK::Winfo::hthumbpos
ldy #$09 sta (winfo_ptr),y
sta ($06),y ldy #MGTK::Winfo::vthumbpos
sta (winfo_ptr),y
jsr pop_pointers jsr pop_pointers
;; --------------------------------------------------
lda icon_params2 lda icon_params2
jsr open_directory jsr open_directory
lda icon_params2 lda icon_params2
jsr icon_entry_lookup jsr icon_entry_lookup
stax $06 stax icon_ptr
ldy #IconEntry::win_type ldy #IconEntry::win_type
lda ($06),y lda (icon_ptr),y
and #icon_entry_winid_mask and #icon_entry_winid_mask
beq L75FA beq :+
tax tax
dex dex
txa txa
@ -6411,7 +6487,8 @@ L75A3: sta ($06),y
tax tax
copy16 window_k_used_table,x, vol_kb_used copy16 window_k_used_table,x, vol_kb_used
copy16 window_k_free_table,x, vol_kb_free copy16 window_k_free_table,x, vol_kb_free
L75FA: ldx cached_window_id
: ldx cached_window_id
dex dex
txa txa
asl a asl a

View File

@ -984,7 +984,9 @@ devlst_backup:
device_to_icon_map: device_to_icon_map:
.res 16, 0 .res 16, 0
LE1B0: .res 65, 0 ; path buffer? ;;; Path buffer for open_directory logic
open_dir_path_buf:
.res 65, 0
LE1F1: .res 15, 0 ; length-prefixed string LE1F1: .res 15, 0 ; length-prefixed string
LE200: .word 0 LE200: .word 0
LE202: .res 24, 0 ; addr table LE202: .res 24, 0 ; addr table
@ -1197,9 +1199,8 @@ dummy_dd_item:
icon_params2: icon_params2:
.byte 0 .byte 0
LE6BF: .word 0 window_title_addr_table:
.addr 0
LE6C1:
.addr winfo1title_ptr .addr winfo1title_ptr
.addr winfo2title_ptr .addr winfo2title_ptr
.addr winfo3title_ptr .addr winfo3title_ptr

View File

@ -59,7 +59,7 @@ L183F: sta BITMAP+1,x
lda LCBANK1 lda LCBANK1
lda LCBANK1 lda LCBANK1
jmp MGTK_RELAY jmp disk_copy_overlay3_start
;;; ============================================================ ;;; ============================================================
;;; Copy first chunk to the Language Card ;;; Copy first chunk to the Language Card

View File

@ -45,7 +45,12 @@ L12AF := $12AF
.endif .endif
.endmacro .endmacro
jmp LD5E1 ;;; ============================================================
.assert *= $D000, error, "Entry point mismatch"
start:
jmp init
;;; ============================================================ ;;; ============================================================
;;; Resources ;;; Resources
@ -497,7 +502,8 @@ watch_cursor:
;;; ============================================================ ;;; ============================================================
LD5E0: .byte 0 LD5E0: .byte 0
LD5E1: jsr remove_ram_disk
init: jsr remove_ram_disk
MGTK_RELAY_CALL2 MGTK::SetMenu, menu_definition MGTK_RELAY_CALL2 MGTK::SetMenu, menu_definition
jsr set_cursor_pointer jsr set_cursor_pointer
copy #1, checkitem_params::menu_item copy #1, checkitem_params::menu_item
@ -3137,3 +3143,4 @@ show_alert_dialog := alert_dialog::show_alert_dialog
PAD_TO $F200 PAD_TO $F200
.endproc .endproc
disk_copy_overlay3_start := disk_copy_overlay3::start