icon poly calc

This commit is contained in:
Joshua Bell 2018-02-12 20:41:17 -08:00
parent 10f68da6c1
commit 512a94f792

View File

@ -2059,36 +2059,62 @@ LA189: rts
;;; ================================================== ;;; ==================================================
;;; v0 v1
;;; +----------+
;;; | |
;;; | |
;;; | |
;;; v7 | | v2
;;; v6 +-----+ +-----+ v3
;;; | |
;;; v5 +----------------------+ v4
;;;
;;; (Label is always at least as wide as the icon)
.proc calc_icon_poly .proc calc_icon_poly
entry_ptr := $6
bitmap_ptr := $8
jsr push_zp_addrs jsr push_zp_addrs
;; v0 - copy from icon entry
ldy #icon_entry_offset_iconx+3 ldy #icon_entry_offset_iconx+3
ldx #3 ldx #3
LA191: lda ($06),y : lda (entry_ptr),y
sta poly::vertices,x sta poly::v0,x
dey dey
dex dex
bpl LA191 bpl :-
;; Top edge (v0, v1)
copy16 poly::v0::ycoord, poly::v1::ycoord copy16 poly::v0::ycoord, poly::v1::ycoord
;; Left edge of icon (v0, v7)
copy16 poly::v0::xcoord, poly::v7::xcoord copy16 poly::v0::xcoord, poly::v7::xcoord
ldy #$07
lda ($06),y ldy #icon_entry_offset_iconbits
sta $08 lda (entry_ptr),y
sta bitmap_ptr
iny iny
lda ($06),y lda (entry_ptr),y
sta $08+1 sta bitmap_ptr+1
ldy #$08
lda ($08),y ;; Right edge of icon (v1, v2)
ldy #8 ; bitmap x2
lda (bitmap_ptr),y
clc clc
adc poly::v0::xcoord adc poly::v0::xcoord
sta poly::v1::xcoord sta poly::v1::xcoord
sta poly::v2::xcoord sta poly::v2::xcoord
iny iny
lda ($08),y lda (bitmap_ptr),y
adc poly::v0::xcoord+1 adc poly::v0::xcoord+1
sta poly::v1::xcoord+1 sta poly::v1::xcoord+1
sta poly::v2::xcoord+1 sta poly::v2::xcoord+1
ldy #$0A
lda ($08),y ;; Bottom edge of icon (v2, v7)
ldy #10 ; bitmap y2
lda (bitmap_ptr),y
clc clc
adc poly::v0::ycoord adc poly::v0::ycoord
sta poly::v2::ycoord sta poly::v2::ycoord
@ -2096,66 +2122,78 @@ LA191: lda ($06),y
lda ($08),y lda ($08),y
adc poly::v0::ycoord+1 adc poly::v0::ycoord+1
sta poly::v2::ycoord+1 sta poly::v2::ycoord+1
lda poly::v2::ycoord
lda poly::v2::ycoord ; 2px down
clc clc
adc #$02 adc #2
sta poly::v2::ycoord sta poly::v2::ycoord
sta poly::v3::ycoord sta poly::v3::ycoord
sta poly::v6::ycoord sta poly::v6::ycoord
sta poly::v7::ycoord sta poly::v7::ycoord
lda poly::v2::ycoord+1 lda poly::v2::ycoord+1
adc #$00 adc #0
sta poly::v2::ycoord+1 sta poly::v2::ycoord+1
sta poly::v3::ycoord+1 sta poly::v3::ycoord+1
sta poly::v6::ycoord+1 sta poly::v6::ycoord+1
sta poly::v7::ycoord+1 sta poly::v7::ycoord+1
;; Bottom edge of label (v4, v5)
lda font_height lda font_height
clc clc
adc poly::v2::ycoord adc poly::v2::ycoord
sta poly::v4::ycoord sta poly::v4::ycoord
sta poly::v5::ycoord sta poly::v5::ycoord
lda poly::v2::ycoord+1 lda poly::v2::ycoord+1
adc #$00 adc #0
sta poly::v4::ycoord+1 sta poly::v4::ycoord+1
sta poly::v5::ycoord+1 sta poly::v5::ycoord+1
ldy #$1C
ldx #$13 ;; Compute text width
LA22A: lda ($06),y ldy #icon_entry_size+1
ldx #19 ; len byte + 15 chars + 2 spaces
: lda (entry_ptr),y
sta text_buffer-1,x sta text_buffer-1,x
dey dey
dex dex
bpl LA22A bpl :-
LA233: lda drawtext_params::textlen
;; Pad with spaces until it's at least as wide as the icon
: lda drawtext_params::textlen
sta textwidth_params::textlen sta textwidth_params::textlen
MGTK_CALL MGTK::TextWidth, textwidth_params MGTK_CALL MGTK::TextWidth, textwidth_params
ldy #$08 ldy #8 ; bitmap x2 offset
lda textwidth_params::result lda textwidth_params::result
cmp ($08),y cmp (bitmap_ptr),y
bcs LA256 bcs got_width
inc drawtext_params::textlen inc drawtext_params::textlen
ldx drawtext_params::textlen ldx drawtext_params::textlen
lda #' ' lda #' '
sta text_buffer-1,x sta text_buffer-1,x
jmp LA233 jmp :-
LA256: lsr a got_width:
sta LA2A5 lsr a ; width / 2
lda ($08),y sta text_width
lsr a lda ($08),y ; still has bitmap x2 offset
sta LA2A4 lsr a ; / 2
lda LA2A5 sta icon_width
;; Left edge of label (v5, v6)
lda text_width
sec sec
sbc LA2A4 sbc icon_width
sta LA2A4 sta icon_width
lda poly::v0::xcoord lda poly::v0::xcoord
sec sec
sbc LA2A4 sbc icon_width
sta poly::v6::xcoord sta poly::v6::xcoord
sta poly::v5::xcoord sta poly::v5::xcoord
lda poly::v0::xcoord+1 lda poly::v0::xcoord+1
sbc #$00 sbc #0
sta poly::v6::xcoord+1 sta poly::v6::xcoord+1
sta poly::v5::xcoord+1 sta poly::v5::xcoord+1
;; Right edge of label (v3, v4)
inc textwidth_params::result inc textwidth_params::result
inc textwidth_params::result inc textwidth_params::result
lda poly::v5::xcoord lda poly::v5::xcoord
@ -2170,8 +2208,8 @@ LA256: lsr a
jsr pop_zp_addrs jsr pop_zp_addrs
rts rts
LA2A4: .byte 0 icon_width: .byte 0
LA2A5: .byte 0 text_width: .byte 0
.endproc .endproc
@ -2653,12 +2691,10 @@ LA5CB: pla
;;; ================================================== ;;; ==================================================
LA627: .byte $00 LA627: .word 0
LA628: .byte $00 LA629: .word 0
LA629: .byte $00 LA62B: .word 0
LA62A: .byte $00 LA62D: .word 0
LA62B: .byte $00
LA62C: .byte $00,$00,$00
.proc setportbits_params2 .proc setportbits_params2
viewloc: DEFINE_POINT 0, 0, viewloc viewloc: DEFINE_POINT 0, 0, viewloc
@ -2667,39 +2703,48 @@ mapwidth: .word MGTK::screen_mapwidth
cliprect: DEFINE_RECT 0, 0, 0, 0, cliprect cliprect: DEFINE_RECT 0, 0, 0, 0, cliprect
.endproc .endproc
LA63F: jsr calc_icon_poly .proc LA63F
jsr calc_icon_poly
lda poly::v0::ycoord lda poly::v0::ycoord
sta LA629 sta LA629
sta setportbits_params2::cliprect::y1 sta setportbits_params2::cliprect::y1
sta setportbits_params2::viewloc::ycoord sta setportbits_params2::viewloc::ycoord
lda poly::v0::ycoord+1 lda poly::v0::ycoord+1
sta LA62A sta LA629+1
sta setportbits_params2::cliprect::y1+1 sta setportbits_params2::cliprect::y1+1
sta setportbits_params2::viewloc::ycoord+1 sta setportbits_params2::viewloc::ycoord+1
lda poly::v5::xcoord lda poly::v5::xcoord
sta LA627 sta LA627
sta setportbits_params2::cliprect::x1 sta setportbits_params2::cliprect::x1
sta setportbits_params2::viewloc::xcoord sta setportbits_params2::viewloc::xcoord
lda poly::v5::xcoord+1 lda poly::v5::xcoord+1
sta LA628 sta LA627+1
sta setportbits_params2::cliprect::x1+1 sta setportbits_params2::cliprect::x1+1
sta setportbits_params2::viewloc::xcoord+1 sta setportbits_params2::viewloc::xcoord+1
ldx #$03
LA674: lda poly::v4::xcoord,x ldx #3
: lda poly::v4::xcoord,x
sta LA62B,x sta LA62B,x
sta setportbits_params2::cliprect::x2,x sta setportbits_params2::cliprect::x2,x
dex dex
bpl LA674 bpl :-
cmp16 LA62B, #$22F
bmi LA69C cmp16 LA62B, #screen_width - 1
lda #$2E bmi done
lda #<(screen_width - 2)
sta LA62B sta LA62B
sta setportbits_params2::cliprect::x2 sta setportbits_params2::cliprect::x2
lda #$02 lda #>(screen_width - 2)
sta LA62C sta LA62B+1
sta setportbits_params2::cliprect::x2+1 sta setportbits_params2::cliprect::x2+1
LA69C: MGTK_CALL MGTK::SetPortBits, setportbits_params2
done: MGTK_CALL MGTK::SetPortBits, setportbits_params2
rts rts
.endproc
;;; ==================================================
LA6A3: lda #$00 LA6A3: lda #$00
jmp LA6C7 jmp LA6C7
@ -2786,7 +2831,7 @@ LA747: lda LA6B0
sta LA6B0 sta LA6B0
LA753: MGTK_CALL MGTK::SetPortBits, setportbits_params2 LA753: MGTK_CALL MGTK::SetPortBits, setportbits_params2
lda setportbits_params2::cliprect::x2+1 lda setportbits_params2::cliprect::x2+1
cmp LA62C cmp LA62B+1
bne LA76F bne LA76F
lda setportbits_params2::cliprect::x2 lda setportbits_params2::cliprect::x2
cmp LA62B cmp LA62B
@ -4579,7 +4624,13 @@ watch_cursor:
.byte 5, 5 .byte 5, 5
LD343: .res 18, 0 LD343: .res 18, 0
LD355: .res 173, 0 LD355: .res 88, 0
LD3AD: .res 65, 0
LD3EE: .res 17, 0
LD3FF: .byte 0
LD400: .byte 0
LD401: .byte 0
path_buf0: .res 65, 0 path_buf0: .res 65, 0
path_buf1: .res 65, 0 path_buf1: .res 65, 0
@ -6771,13 +6822,8 @@ L4859: dey
L485D: .addr LE000 ; addresses or numbers??? L485D: .addr LE000 ; addresses or numbers???
L485F: .word $D000 L485F: .word $D000
L4861: .byte $00 sys_start_flag: .byte $00
L4862: .byte $00,$00,$00,$00,$00,$00 sys_start_path: .res 40, 0
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00
;;; ================================================== ;;; ==================================================
@ -6880,7 +6926,7 @@ L492E: jsr set_pointer_cursor
bpl done bpl done
jsr L4AAD jsr L4AAD
jsr L4A77 jsr L4A77
jsr L4AFD jsr get_LD3FF
bpl L497A bpl L497A
jsr L8F24 jsr L8F24
bmi done bmi done
@ -6947,7 +6993,7 @@ L49A6: lda menu_click_params::item_num
asl a asl a
bmi L49FA bmi L49FA
bcc L49E0 bcc L49E0
jsr L4AFD jsr get_LD3FF
beq L49FA beq L49FA
lda L49A5 lda L49A5
jsr L4AEA jsr L4AEA
@ -6958,7 +7004,7 @@ L49A6: lda menu_click_params::item_num
bpl L49ED bpl L49ED
jmp redraw_windows_and_desktop jmp redraw_windows_and_desktop
L49E0: jsr L4AFD L49E0: jsr get_LD3FF
beq L49FA beq L49FA
lda L49A5 lda L49A5
jsr L4AEA jsr L4AEA
@ -7057,7 +7103,7 @@ L4AB0: lda LD355,y
sta L0800,y sta L0800,y
dey dey
bpl L4AB0 bpl L4AB0
addr_call L4B15, $840 addr_call copy_LD3EE_str, $840
ldy L0800 ldy L0800
L4AC3: lda L0800,y L4AC3: lda L0800,y
cmp #$2F cmp #$2F
@ -7085,58 +7131,69 @@ L4AEA: jsr L4B5F
MLI_RELAY_CALL GET_FILE_INFO, get_file_info_params3 MLI_RELAY_CALL GET_FILE_INFO, get_file_info_params3
rts rts
L4AFD: sta ALTZPOFF ;;; ==================================================
.proc get_LD3FF
sta ALTZPOFF
lda LCBANK2 lda LCBANK2
lda LCBANK2 lda LCBANK2
lda $D3FF lda LD3FF
tax tax
sta ALTZPON sta ALTZPON
lda LCBANK1 lda LCBANK1
lda LCBANK1 lda LCBANK1
txa txa
rts rts
.endproc
L4B15: stax L4B2B .proc copy_LD3EE_str
stax destptr
sta ALTZPOFF sta ALTZPOFF
lda LCBANK2 lda LCBANK2
lda LCBANK2 lda LCBANK2
ldx $D3EE
L4B27: lda $D3EE,x
L4B2B := *+1 ldx LD3EE
: lda LD3EE,x
destptr := *+1
sta dummy1234,x sta dummy1234,x
dex dex
bpl L4B27 bpl :-
sta ALTZPON sta ALTZPON
lda LCBANK1 lda LCBANK1
lda LCBANK1 lda LCBANK1
rts rts
.endproc
L4B3A: stax L4B50 .proc copy_LD3AD_str
stax destptr
sta ALTZPOFF sta ALTZPOFF
lda LCBANK2 lda LCBANK2
lda LCBANK2 lda LCBANK2
ldx $D3AD
L4B4C: lda $D3AD,x ldx LD3AD
L4B50 := *+1 : lda LD3AD,x
destptr := *+1
sta dummy1234,x sta dummy1234,x
dex dex
bpl L4B4C bpl :-
sta ALTZPON sta ALTZPON
lda LCBANK1 lda LCBANK1
lda LCBANK1 lda LCBANK1
rts rts
.endproc
L4B5F: sta L4BB0 .proc L4B5F
addr_call L4B15, path_buffer sta L4BB0
addr_call copy_LD3EE_str, path_buffer
lda L4BB0 lda L4BB0
jsr a_times_6 jsr a_times_6
clc clc
adc #$9E adc #<$DB9E
sta $06 sta $06
txa txa
adc #$DB adc #>$DB9E
sta $06+1 sta $06+1
ldy #$00 ldy #$00
lda ($06),y lda ($06),y
@ -7144,7 +7201,7 @@ L4B5F: sta L4BB0
tay tay
L4B81: lda ($06),y L4B81: lda ($06),y
and #$7F and #$7F
cmp #$2F cmp #'/'
beq L4B8C beq L4B8C
dey dey
bne L4B81 bne L4B81
@ -7169,6 +7226,7 @@ L4B9C: inx
L4BB0: .byte 0 L4BB0: .byte 0
L4BB1: .byte 0 L4BB1: .byte 0
.endproc
;;; ================================================== ;;; ==================================================
@ -20478,7 +20536,7 @@ slot_string_table:
.proc get_file_info_params2 .proc get_file_info_params2
param_count: .byte $A param_count: .byte $A
pathname: .addr desktop_main::L4862 pathname: .addr desktop_main::sys_start_path
access: .byte 0 access: .byte 0
file_type: .byte 0 file_type: .byte 0
aux_type: .word 0 aux_type: .word 0
@ -20493,42 +20551,51 @@ create_time: .word 0
.proc get_prefix_params .proc get_prefix_params
param_count: .byte 1 param_count: .byte 1
data_buffer: .addr desktop_main::L4862 data_buffer: .addr desktop_main::sys_start_path
.endproc .endproc
L0ED4: PASCAL_STRING "System/Start" str_system_start: PASCAL_STRING "System/Start"
.proc L0EE1 .proc L0EE1
lda #$00 lda #$00
sta desktop_main::L4861 sta desktop_main::sys_start_flag
jsr desktop_main::L4AFD jsr desktop_main::get_LD3FF
cmp #$80 cmp #$80
beq L0EFE beq L0EFE
MLI_RELAY_CALL GET_PREFIX, get_prefix_params MLI_RELAY_CALL GET_PREFIX, get_prefix_params
bne L0F34 bne config_toolkit
dec desktop_main::L4862 dec desktop_main::sys_start_path
jmp L0F05 jmp L0F05
L0EFE: addr_call desktop_main::L4B3A, desktop_main::L4862 L0EFE: addr_call desktop_main::copy_LD3AD_str, desktop_main::sys_start_path
L0F05: ldx desktop_main::L4862 L0F05: ldx desktop_main::sys_start_path
L0F08: lda desktop_main::L4862,x
;; Find last /
floop: lda desktop_main::sys_start_path,x
cmp #'/' cmp #'/'
beq L0F12 beq :+
dex dex
bne L0F08 bne floop
L0F12: ldy #$00
L0F14: inx ;; Replace last path segment with "System/Start"
: ldy #0
cloop: inx
iny iny
lda L0ED4,y lda str_system_start,y
sta desktop_main::L4862,x sta desktop_main::sys_start_path,x
cpy L0ED4 cpy str_system_start
bne L0F14 bne cloop
stx desktop_main::L4862 stx desktop_main::sys_start_path
;; Does it point at anything? If so, set flag.
MLI_RELAY_CALL GET_FILE_INFO, get_file_info_params2 MLI_RELAY_CALL GET_FILE_INFO, get_file_info_params2
bne L0F34 bne config_toolkit
lda #$80 lda #$80
sta desktop_main::L4861 sta desktop_main::sys_start_flag
L0F34: MGTK_RELAY_CALL MGTK::CheckEvents
;; Final MGTK configuration
config_toolkit:
MGTK_RELAY_CALL MGTK::CheckEvents
MGTK_RELAY_CALL MGTK::SetMenu, desktop_aux::desktop_menu MGTK_RELAY_CALL MGTK::SetMenu, desktop_aux::desktop_menu
MGTK_RELAY_CALL MGTK::SetCursor, pointer_cursor MGTK_RELAY_CALL MGTK::SetCursor, pointer_cursor
lda #$00 lda #$00