DeskTop: IconEntry struct, more DT calls

This commit is contained in:
Joshua Bell 2018-05-25 18:24:35 -07:00
parent 2d835585c0
commit 94e02e4a72
5 changed files with 105 additions and 99 deletions

View File

@ -59,7 +59,7 @@ DT_ADD_ICON := $01 ; { .addr icondata }
DT_HIGHLIGHT_ICON := $02 ; { .byte icon }
DT_REDRAW_ICON := $03 ; { .byte icon }
DT_UNHIGHLIGHT_ICON := $04 ; { .byte icon }
;; $05 ???
DT_HIGHLIGHT_ALL := $05 ; { .byte window_id }
DT_UNHIGHLIGHT_ALL := $06
DT_CLOSE_WINDOW := $07 ; { .byte window_id }
DT_GET_HIGHLIGHTED := $08 ; { .res 20 }
@ -68,7 +68,10 @@ DT_FIND_ICON := $09 ; { .word mousex, .word mousey, .byte result }
;; $0B ???
DT_REDRAW_ICONS := $0C ; Repaints desktop icons *
DT_ICON_IN_RECT := $0D ; { .byte icon, rect bounds }
;; $0E ???
DT_REDRAW_ICON_IDX := $0E ; { .byte icon_index }
;;; `icon` is the icon number, i.e. first field in icon entry
;;; `icon_index` is the index in the icon table
;;; Call a DESKTOP entry point:
;;; DESKTOP_CALL n - params is $0000
@ -143,7 +146,7 @@ file_table := $DD9F ; file address table
;;; Icon (file/volume) entries - length 27 bytes, maximum of 127
;;; .byte icon icon index
;;; .byte state (
;;; .byte state $80 = highlighted, 0 = otherwise
;;; .byte type/window_id
;;; (bits 0-3 window_id)
;;; (bits 4,5,6)
@ -162,16 +165,16 @@ file_table := $DD9F ; file address table
;;; .byte len (name length + 2)
;;; .res 17 name (name, with a space before and after)
icon_entry_offset_index := 0
icon_entry_offset_state := 1
icon_entry_offset_win_type := 2
icon_entry_offset_iconx := 3
icon_entry_offset_icony := 5
icon_entry_offset_iconbits := 7
icon_entry_offset_len := 9
icon_entry_offset_name := 10
icon_entry_name_bufsize := 17
icon_entry_size := 27
.struct IconEntry
index .byte
state .byte
win_type .byte
iconx .word
icony .word
iconbits .addr
len .byte
name .res 17 ; 15 chars plus leading/trailing spaces
.endstruct
max_icon_count := 127

View File

@ -249,7 +249,7 @@ desktop_jump_table:
.addr L9EBE ; $0B
.addr REDRAW_ICONS_IMPL
.addr ICON_IN_RECT_IMPL
.addr L958F ; $0E
.addr REDRAW_ICON_IDX_IMPL
.macro DESKTOP_DIRECT_CALL op, addr, label
jsr DESKTOP_DIRECT
@ -381,7 +381,7 @@ bail1: return #1 ; Not found
L9469: asl a
tax
copy16 icon_ptrs,x, ptr
ldy #icon_entry_offset_state
ldy #IconEntry::state
lda (ptr),y
bne L947E ; Already set ??? Routine semantics are incorrect ???
return #2
@ -499,7 +499,7 @@ bail1: return #1 ; Not found
found: asl a
tax
copy16 icon_ptrs,x, ptr
ldy #icon_entry_offset_state
ldy #IconEntry::state
lda (ptr),y
bne :+
@ -508,7 +508,7 @@ found: asl a
;; Unhighlight
: jsr calc_icon_poly
MGTK_CALL MGTK::SetPenMode, pencopy_2
jsr LA39D
jsr draw_icon
ldy #0
lda (ptr),y
ldx num_icons
@ -517,7 +517,7 @@ found: asl a
lda #0
ldx num_icons
sta icon_table,x
ldy #icon_entry_offset_state
ldy #IconEntry::state
lda #0
sta (ptr),y
lda has_highlight
@ -549,18 +549,20 @@ done: return #0 ; Unhighlighted
.endproc
;;; ============================================================
;;; REDRAW_ICON_IDX IMPL
;;; DESKTOP $0E IMPL
.proc L958F
ptr := $6
.proc REDRAW_ICON_IDX_IMPL
PARAM_BLOCK params, $06
ptr_icon_idx: .addr 0
END_PARAM_BLOCK
ptr := $06 ; Overwrites param
ldy #0
lda (ptr),y
lda (params::ptr_icon_idx),y
asl a
tax
copy16 icon_ptrs,x, ptr
jmp LA39D
jmp draw_icon
.endproc
;;; ============================================================
@ -592,7 +594,7 @@ start: lda HIGHLIGHT_ICON_IMPL ; ???
start2:
;; Zero out buffer
ldx #$7E ; 127 icons
ldx #max_icon_count-1
lda #0
: sta buffer,x
dex
@ -606,7 +608,7 @@ loop: lda icon_table,x
asl a
tay
copy16 icon_ptrs,y, ptr
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda (ptr),y
and #icon_entry_winid_mask
ldy #0
@ -665,7 +667,7 @@ L969D: ldx L9696
asl a
tax
copy16 icon_ptrs,x, $08
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($08),y
and #icon_entry_winid_mask
ldy #0
@ -698,7 +700,7 @@ L96E5: dec L96D6
asl a
tax
copy16 icon_ptrs,x, $08
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($08),y
and #icon_entry_winid_mask
ldy #0
@ -712,7 +714,7 @@ L96E5: dec L96D6
lda #0
ldx num_icons
sta icon_table,x
ldy #icon_entry_offset_state
ldy #IconEntry::state
lda #0
sta ($08),y
lda has_highlight
@ -810,7 +812,7 @@ L97B9: txa
asl a
tax
copy16 icon_ptrs,x, $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_winid_mask
cmp L97F5
@ -860,7 +862,7 @@ L9803: lda ($06),y
lda L982A
jsr L9EB4
stax $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_winid_mask
sta L9829
@ -931,7 +933,7 @@ L98AC: lda highlight_count
: lda highlight_list
jsr L9EB4
stax $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_winid_mask
sta L9832
@ -966,7 +968,7 @@ L9909: sta L9834
sta $08
bcs L992D
dec $08+1
L992D: ldy #icon_entry_offset_state
L992D: ldy #IconEntry::state
lda #$80 ; Highlighted
sta ($08),y
jsr pop_zp_addrs
@ -997,7 +999,7 @@ L9961: lda drag_outline_buffer+2,x
dex
bpl L9961
copy16 #drag_outline_buffer, $08
L9972: ldy #icon_entry_offset_win_type
L9972: ldy #IconEntry::win_type
L9974: lda ($08),y
cmp L9C76
iny
@ -1056,7 +1058,7 @@ L99C7: dey
L99E1: iny
cpy #$22
bne L9974
ldy #icon_entry_offset_state
ldy #IconEntry::state
lda ($08),y
beq L99FC
add16 $08, #34, $08
@ -1176,7 +1178,7 @@ L9B62: lda ($08),y
iny
cpy #$22
bne L9B62
ldy #icon_entry_offset_state
ldy #IconEntry::state
lda ($08),y
beq L9B9C
lda $08
@ -1226,7 +1228,7 @@ L9BF3: dex
copy16 icon_ptrs,x, $06
jsr calc_icon_poly
MGTK_CALL MGTK::SetPenMode, pencopy_2
jsr LA39D
jsr draw_icon
pla
tax
jmp L9BF3
@ -1241,7 +1243,7 @@ L9C29: lda highlight_list,x
asl a
tax
copy16 icon_ptrs,x, $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($08),y
iny
sta ($06),y
@ -1420,7 +1422,7 @@ L9E3D: cmp highlight_list,x
asl a
tax
copy16 icon_ptrs,x, $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_winid_mask
sta L9831
@ -1567,7 +1569,7 @@ L9F9F: lda #$80
sta L9F92
.proc L9FA4
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_winid_mask
bne :+
@ -1575,11 +1577,11 @@ L9F9F: lda #$80
ora #$40
sta L9F92
;; copy icon coords and bits
: ldy #icon_entry_offset_iconx
: ldy #IconEntry::iconx
: lda ($06),y
sta paintbits_params2::viewloc-icon_entry_offset_iconx,y
sta paintbits_params2::viewloc-IconEntry::iconx,y
iny
cpy #icon_entry_offset_iconx + 6 ; x/y/bits
cpy #IconEntry::iconx + 6 ; x/y/bits
bne :-
jsr push_zp_addrs
@ -1655,7 +1657,7 @@ LA097: MGTK_CALL MGTK::HideCursor, DESKTOP_DIRECT ; These params should be igno
LA0B6: MGTK_CALL MGTK::PaintBits, paintbits_params
MGTK_CALL MGTK::SetPenMode, penXOR_2
LA0C2: MGTK_CALL MGTK::PaintBits, paintbits_params2
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_open_mask
beq LA0F2
@ -1743,7 +1745,7 @@ LA189: rts
jsr push_zp_addrs
;; v0 - copy from icon entry
ldy #icon_entry_offset_iconx+3
ldy #IconEntry::iconx+3
ldx #3
: lda (entry_ptr),y
sta poly::v0,x
@ -1757,7 +1759,7 @@ LA189: rts
;; Left edge of icon (v0, v7)
copy16 poly::v0::xcoord, poly::v7::xcoord
ldy #icon_entry_offset_iconbits
ldy #IconEntry::iconbits
lda (entry_ptr),y
sta bitmap_ptr
iny
@ -1814,7 +1816,7 @@ LA189: rts
sta poly::v5::ycoord+1
;; Compute text width
ldy #icon_entry_size+1
ldy #.sizeof(IconEntry)+1
ldx #19 ; len byte + 15 chars + 2 spaces
: lda (entry_ptr),y
sta text_buffer-1,x
@ -1900,7 +1902,7 @@ LA2B5: bmi LA2AA
asl a
tax
copy16 icon_ptrs,x, $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_winid_mask
bne LA2DD
@ -2048,7 +2050,8 @@ stash: .word 0
;;; ============================================================
LA39D: MGTK_CALL MGTK::InitPort, grafport
draw_icon:
MGTK_CALL MGTK::InitPort, grafport
MGTK_CALL MGTK::SetPort, grafport
jmp LA3B9
@ -2153,7 +2156,7 @@ LA466: txa
asl a
tax
copy16 icon_ptrs,x, ptr
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda (ptr),y
and #$07 ; window_id
cmp LA3AD

View File

@ -1749,7 +1749,7 @@ L4DF2: txa
lda selected_icon_list,x
jsr icon_entry_lookup
stax $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_type_mask
bne L4E10
@ -1860,7 +1860,7 @@ L4EC3: sta cached_window_icon_count
sta icon_param
jsr icon_entry_lookup
stax $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #(~icon_entry_open_mask)&$FF ; clear open_flag
sta ($06),y
@ -2707,7 +2707,7 @@ L55D1: ldx L544A
sta selected_icon_list
jsr icon_entry_lookup
stax $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_winid_mask
sta selected_window_index
@ -2720,7 +2720,7 @@ L55F0: ldx L544A
sta icon_param
jsr icon_entry_lookup
stax $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_winid_mask
sta getwinport_params2::window_id
@ -2739,7 +2739,7 @@ L562B: rts
L562C: lda icon_param
jsr icon_entry_lookup
stax $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_winid_mask
sta getwinport_params2::window_id
@ -3705,7 +3705,7 @@ L5DF7: ldx LE256
L5DFC: lda L5CD9 ; after a double-click (on file or folder)
jsr icon_entry_lookup
stax $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_type_mask
cmp #icon_entry_type_sys
@ -4146,7 +4146,7 @@ L6227: sta cached_window_icon_count
lda ($06),y
and #$0F
beq L6276
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #(~icon_entry_open_mask)&$FF ; clear open_flag
sta ($06),y
@ -4877,7 +4877,7 @@ L6A3E: .byte 0
dex
bpl :-
jsr icon_entry_lookup
addax #icon_entry_offset_len, ptr
addax #IconEntry::len, ptr
ldy #0
lda (ptr),y
tay
@ -4928,11 +4928,11 @@ L6AA7: stx cached_window_id
lda icon_params2
jsr icon_entry_lookup
stax $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
ora #icon_entry_open_mask ; set open_flag
sta ($06),y
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_winid_mask
sta getwinport_params2::window_id
@ -5006,11 +5006,11 @@ L6B68: lda #$01
lda icon_params2
jsr icon_entry_lookup
stax $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
ora #icon_entry_open_mask ; set open_flag
sta ($06),y
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_winid_mask
sta getwinport_params2::window_id
@ -5962,12 +5962,12 @@ L7471: lda ($06),y
bne L7471
lda #$20
sta ($08),y
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($08),y
and #%11011111 ; ???
sta ($08),y
jsr pop_zp_addrs
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_winid_mask
bne L74D3
@ -6091,7 +6091,7 @@ L7569: addr_call_indirect capitalize_string, $08
pla
lsr a
clc
adc #icon_entry_size
adc #.sizeof(IconEntry)
sta ($06),y
iny
lda #$00
@ -6122,7 +6122,7 @@ L75A3: sta ($06),y
lda icon_params2
jsr icon_entry_lookup
stax $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_winid_mask
beq L75FA
@ -6347,7 +6347,7 @@ L77DA: tay
;; L7624 = icon type
jsr find_icon_details_for_file_type
addr_call capitalize_string, $1800
ldy #icon_entry_offset_len
ldy #IconEntry::len
ldx #0
L77F0: lda $1800,x
sta ($08),y
@ -6389,9 +6389,9 @@ L7862: lda L762A
inc L762A+1
L7870: lda cached_window_id
ora L7624
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
sta ($08),y
ldy #icon_entry_offset_iconbits
ldy #IconEntry::iconbits
lda L7622
sta ($08),y
iny
@ -6776,7 +6776,7 @@ L7C36: tax
lda cached_window_icon_list,x
jsr icon_entry_lookup
stax $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_winid_mask
cmp L7D5C
@ -8295,7 +8295,7 @@ port_copy:
bpl :-
;; iconx
ldy #icon_entry_offset_iconx
ldy #IconEntry::iconx
lda (entry_ptr),y
clc
adc pos_screen
@ -8317,7 +8317,7 @@ port_copy:
sta (entry_ptr),y
;; iconx
ldy #icon_entry_offset_iconx
ldy #IconEntry::iconx
lda (entry_ptr),y
sec
sbc pos_win
@ -8387,7 +8387,7 @@ pos_win: .word 0, 0
bpl :-
;; iconx
ldy #icon_entry_offset_iconx
ldy #IconEntry::iconx
lda (entry_ptr),y
sec
sbc pos_screen
@ -8409,7 +8409,7 @@ pos_win: .word 0, 0
sta (entry_ptr),y
;; iconx
ldy #icon_entry_offset_iconx
ldy #IconEntry::iconx
lda (entry_ptr),y
clc
adc pos_win
@ -8493,30 +8493,30 @@ create_icon:
;; Fill name with spaces
ldx #0
ldy #icon_entry_offset_len
ldy #IconEntry::len
lda #$20 ; ??? space? shouldn't this be at +1 ?
: sta (icon_ptr),y
iny
inx
cpx #icon_entry_name_bufsize+1
cpx #.sizeof(IconEntry::name)+1
bne :-
;; Copy name, with leading/trailing space
ldy #icon_entry_offset_len
ldy #IconEntry::len
lda gdi_data_buffer
and #$0F
sta gdi_data_buffer
sta (icon_ptr),y
addr_call capitalize_string, gdi_data_buffer ; ???
ldx #0
ldy #icon_entry_offset_name+1 ; past leading space
ldy #IconEntry::name+1 ; past leading space
: lda gdi_data_buffer+1,x
sta (icon_ptr),y
iny
inx
cpx gdi_data_buffer
bne :-
ldy #icon_entry_offset_len
ldy #IconEntry::len
lda (icon_ptr),y
clc
adc #2 ; leading/trailing space
@ -8552,7 +8552,7 @@ create_icon:
;; fall through...
use_ramdisk_icon:
ldy #icon_entry_offset_iconbits
ldy #IconEntry::iconbits
lda #<desktop_aux::ramdisk_icon
sta (icon_ptr),y
iny
@ -8561,7 +8561,7 @@ use_ramdisk_icon:
jmp selected_device_icon
use_profile_icon:
ldy #icon_entry_offset_iconbits
ldy #IconEntry::iconbits
lda #<desktop_aux::profile_icon
sta (icon_ptr),y
iny
@ -8572,7 +8572,7 @@ use_profile_icon:
use_floppy_icon:
cmp #$B ; removable / 4 volumes
bne use_floppy140_icon
ldy #icon_entry_offset_iconbits
ldy #IconEntry::iconbits
lda #<desktop_aux::floppy800_icon
sta (icon_ptr),y
iny
@ -8583,7 +8583,7 @@ use_floppy_icon:
use_floppy140_icon:
cmp #DT_DISKII ; 0 = Disk II
bne use_profile_icon ; last chance
ldy #icon_entry_offset_iconbits
ldy #IconEntry::iconbits
lda #<desktop_aux::floppy140_icon
sta (icon_ptr),y
iny
@ -8592,7 +8592,7 @@ use_floppy140_icon:
selected_device_icon:
;; Assign icon type
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda #0
sta (icon_ptr),y
inc device_num
@ -8602,18 +8602,18 @@ selected_device_icon:
asl a ; device num * 4 is coordinates index
asl a
tax
ldy #icon_entry_offset_iconx
ldy #IconEntry::iconx
: lda desktop_icon_coords_table,x
sta (icon_ptr),y
inx
iny
cpy #icon_entry_offset_iconbits
cpy #IconEntry::iconbits
bne :-
;; Assign icon number
ldx cached_window_icon_count
dex
ldy #icon_entry_offset_index
ldy #IconEntry::index
lda (icon_ptr),y
sta cached_window_icon_list,x
jsr pop_zp_addrs
@ -8693,7 +8693,7 @@ L8B25: jsr push_zp_addrs
skip: lda icon_params2
jsr icon_entry_lookup
stax ptr
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda (ptr),y
and #(~icon_entry_open_mask)&$FF ; clear open_flag
sta ($06),y
@ -9127,7 +9127,7 @@ L8FA1: jsr L8FE1
L8FA7: asl a
tay
copy16 icon_entry_address_table,y, $06
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda ($06),y
rts
@ -9361,7 +9361,7 @@ L918D: .byte 0
.proc icon_entry_name_lookup
asl a
tay
add16 icon_entry_address_table,y, #icon_entry_offset_len, $06
add16 icon_entry_address_table,y, #IconEntry::len, $06
rts
.endproc
@ -14267,7 +14267,7 @@ loop: cpx #max_icon_count
sta (ptr),y
lda ptr
clc
adc #icon_entry_size
adc #.sizeof(IconEntry)
sta ptr
bcc :+
inc ptr+1
@ -14312,10 +14312,10 @@ trash_name: PASCAL_STRING " Trash "
sta cached_window_icon_list
jsr desktop_main::icon_entry_lookup
stax ptr
ldy #icon_entry_offset_win_type
ldy #IconEntry::win_type
lda #icon_entry_type_trash
sta (ptr),y
ldy #icon_entry_offset_iconbits
ldy #IconEntry::iconbits
lda #<desktop_aux::trash_icon
sta (ptr),y
iny

View File

@ -202,7 +202,7 @@ L86C4: sta ($06),y
cmp #$04
bne L86ED
ldy #icon_entry_offset_iconbits
ldy #IconEntry::iconbits
lda #<$14B4 ; $14B4 ???
sta ($06),y
iny
@ -212,7 +212,7 @@ L86C4: sta ($06),y
L86ED: cmp #$0B
bne L86FF
ldy #icon_entry_offset_iconbits
ldy #IconEntry::iconbits
lda #<$1470 ; $1470 ???
sta ($06),y
iny
@ -220,14 +220,14 @@ L86ED: cmp #$0B
sta ($06),y
jmp L870A
L86FF: ldy #icon_entry_offset_iconbits
L86FF: ldy #IconEntry::iconbits
lda #<$1440 ; $1440 ???
sta ($06),y
iny
lda #>$1440
sta ($06),y
L870A: ldy #icon_entry_offset_win_type
L870A: ldy #IconEntry::win_type
lda #0
sta ($06),y
inc L8738
@ -235,7 +235,7 @@ L870A: ldy #icon_entry_offset_win_type
asl a
asl a
tax
ldy #icon_entry_offset_iconx
ldy #IconEntry::iconx
: lda L8739,x
sta ($06),y
inx

View File

@ -52,7 +52,7 @@ while (<STDIN>) {
$_ .= ' ' while length($_) % $tab;
$_ .= ':= ' . $expression . ' ';
} elsif (m/^(\.(?:end)?(?:proc|scope|macro)\b)\s*(.*)$/) {
} elsif (m/^(\.(?:end)?(?:proc|scope|macro|struct)\b)\s*(.*)$/) {
# scope - flush left
my ($opcode, $arguments) = ($1 // '', $2 // '');