Disasm: icon offset logic

This commit is contained in:
Joshua Bell 2019-07-28 15:24:36 -07:00
parent 13c1f6166a
commit 24d318c274
2 changed files with 109 additions and 86 deletions

View File

@ -2293,7 +2293,7 @@ window_id: .byte 0
lda frontwindow_params::window_id lda frontwindow_params::window_id
sta getwinport_params::window_id sta getwinport_params::window_id
MGTK_CALL MGTK::GetWinPort, getwinport_params MGTK_CALL MGTK::GetWinPort, getwinport_params
jsr LA4CC jsr offset_icon_poly
jsr shift_port_down ; Further offset by window's items/used/free bar jsr shift_port_down ; Further offset by window's items/used/free bar
jsr erase_window_icon jsr erase_window_icon
jmp LA446 jmp LA446
@ -2331,16 +2331,17 @@ volume:
;;; ============================================================ ;;; ============================================================
LA446: jsr push_pointers .proc LA446
ptr := $8
jsr push_pointers
ldx num_icons ldx num_icons
dex ; any icons to draw? dex ; any icons to draw?
.proc LA44D loop: cpx #$FF ; =-1
ptr := $8
cpx #$FF ; =-1
bne LA466 bne LA466
bit LA3B7 ; no, almost done
bit LA3B7
bpl :+ bpl :+
;; TODO: Is this restoration necessary? ;; TODO: Is this restoration necessary?
MGTK_CALL MGTK::InitPort, icon_grafport MGTK_CALL MGTK::InitPort, icon_grafport
@ -2352,7 +2353,7 @@ LA466: txa
pha pha
lda icon_table,x lda icon_table,x
cmp LA3AC cmp LA3AC
beq LA4C5 beq next
asl a asl a
tax tax
copy16 icon_ptrs,x, ptr copy16 icon_ptrs,x, ptr
@ -2360,7 +2361,7 @@ LA466: txa
lda (ptr),y lda (ptr),y
and #$07 ; window_id and #$07 ; window_id
cmp LA3AD cmp LA3AD
bne LA4C5 bne next
;; Is icon highlighted? ;; Is icon highlighted?
lda has_highlight lda has_highlight
@ -2369,7 +2370,7 @@ LA466: txa
lda (ptr),y lda (ptr),y
ldx #0 ldx #0
: cmp highlight_list,x : cmp highlight_list,x
beq LA4C5 beq next ; skip it ???
inx inx
cpx highlight_count cpx highlight_count
bne :- bne :-
@ -2377,115 +2378,137 @@ LA466: txa
LA49D: ldy #IconEntry::id ; icon num LA49D: ldy #IconEntry::id ; icon num
lda (ptr),y lda (ptr),y
sta LA3AE sta LA3AE
bit LA3B7 bit LA3B7 ; windowed?
bpl LA4AC bpl LA4AC ; nope, desktop
jsr LA4D3 jsr offset_icon_do ; yes, adjust rect
LA4AC: DESKTOP_DIRECT_CALL DT_ICON_IN_RECT, LA3AE LA4AC: DESKTOP_DIRECT_CALL DT_ICON_IN_RECT, LA3AE
beq LA4BA beq :+
DESKTOP_DIRECT_CALL DT_REDRAW_ICON, LA3AE DESKTOP_DIRECT_CALL DT_REDRAW_ICON, LA3AE
LA4BA: bit LA3B7 : bit LA3B7
bpl LA4C5 bpl next
lda LA3AE lda LA3AE
jsr LA4DC jsr offset_icon_undo
LA4C5: pla
next: pla
tax tax
dex dex
jmp LA44D jmp loop
.endproc .endproc
;;; ============================================================ ;;; ============================================================
;;; Offset coordinates for windowed icons
LA4CB: .byte 0 .proc offset_icon
LA4CC: copy #$80, LA4CB offset_flags: .byte 0 ; bit 7 = offset poly, bit 6 = undo offset, otherwise do offset
vl_offset: DEFINE_POINT 0,0,vl_offset
mr_offset: DEFINE_POINT 0,0,mr_offset
entry_poly: copy #$80, offset_flags
bmi LA4E2 ; always bmi LA4E2 ; always
LA4D3: pha
entry_do: pha
lda #$40 lda #$40
sta LA4CB sta offset_flags
jmp LA4E2 jmp LA4E2
LA4DC: pha entry_undo: pha
lda #0 lda #0
sta LA4CB sta offset_flags
LA4E2: ldy #0
LA4E4: lda icon_grafport,y
sta LA567,y
iny
cpy #4
bne LA4E4
ldy #8
LA4F1: lda icon_grafport,y
sta LA567-4,y
iny
cpy #12
bne LA4F1
bit LA4CB
bmi LA506
bvc LA56F
jmp LA5CB
LA506: ldx #0 LA4E2: ldy #MGTK::GrafPort::viewloc
LA508: sub16 poly::vertices,x, LA567, poly::vertices,x : lda icon_grafport,y
sub16 poly::vertices+2,x, LA569, poly::vertices+2,x sta vl_offset,y
inx iny
inx cpy #MGTK::GrafPort::viewloc + .sizeof(MGTK::Point)
inx bne :-
inx
cpx #32 ldy #MGTK::GrafPort::maprect
bne LA508 : lda icon_grafport,y
sta mr_offset - MGTK::GrafPort::maprect,y
iny
cpy #MGTK::GrafPort::maprect + .sizeof(MGTK::Point)
bne :-
bit offset_flags
bmi offset_poly
bvc do_offset
jmp undo_offset
.proc offset_poly
ldx #0 ldx #0
LA538: add16 poly::vertices,x, LA56B, poly::vertices,x loop1: sub16 poly::vertices+0,x, vl_offset::xcoord, poly::vertices+0,x
add16 poly::vertices+2,x, LA56D, poly::vertices+2,x sub16 poly::vertices+2,x, vl_offset::ycoord, poly::vertices+2,x
inx inx
inx inx
inx inx
inx inx
cpx #32 cpx #32
bne LA538 bne loop1
ldx #0
loop2: add16 poly::vertices+0,x, mr_offset::xcoord, poly::vertices+0,x
add16 poly::vertices+2,x, mr_offset::ycoord, poly::vertices+2,x
inx
inx
inx
inx
cpx #32
bne loop2
rts rts
.endproc
LA567: .word 0 .proc do_offset
LA569: .word 0 ptr := $06
LA56B: .word 0
LA56D: .word 0
LA56F: pla pla
tay tay
jsr push_pointers jsr push_pointers
tya tya
asl a asl a
tax tax
copy16 icon_ptrs,x, $06 copy16 icon_ptrs,x, ptr
ldy #3 ldy #IconEntry::iconx
add16in ($06),y, LA567, ($06),y add16in (ptr),y, vl_offset::xcoord, (ptr),y ; iconx += viewloc::xcoord
iny iny
add16in ($06),y, LA569, ($06),y add16in (ptr),y, vl_offset::ycoord, (ptr),y ; icony += viewloc::xcoord
ldy #3 ldy #IconEntry::iconx
sub16in ($06),y, LA56B, ($06),y sub16in (ptr),y, mr_offset::xcoord, (ptr),y ; icony -= maprect::left
iny iny
sub16in ($06),y, LA56D, ($06),y sub16in (ptr),y, mr_offset::ycoord, (ptr),y ; icony -= maprect::top
jsr pop_pointers jsr pop_pointers
rts rts
.endproc
LA5CB: pla .proc undo_offset
ptr := $06
pla
tay tay
jsr push_pointers jsr push_pointers
tya tya
asl a asl a
tax tax
copy16 icon_ptrs,x, $06 copy16 icon_ptrs,x, ptr
ldy #3 ldy #IconEntry::iconx
sub16in ($06),y, LA567, ($06),y sub16in (ptr),y, vl_offset::xcoord, (ptr),y ; iconx -= viewloc::xcoord
iny iny
sub16in ($06),y, LA569, ($06),y sub16in (ptr),y, vl_offset::ycoord, (ptr),y ; icony -= viewloc::xcoord
ldy #3 ldy #IconEntry::iconx
add16in ($06),y, LA56B, ($06),y add16in (ptr),y, mr_offset::xcoord, (ptr),y ; iconx += maprect::left
iny iny
add16in ($06),y, LA56D, ($06),y add16in (ptr),y, mr_offset::ycoord, (ptr),y ; icony += maprect::top
jsr pop_pointers jsr pop_pointers
rts rts
.endproc
.endproc
offset_icon_poly := offset_icon::entry_poly
offset_icon_do := offset_icon::entry_do
offset_icon_undo := offset_icon::entry_undo
;;; ============================================================ ;;; ============================================================
;;; This handles drawing volume icons "behind" windows. It is ;;; This handles drawing volume icons "behind" windows. It is

View File

@ -45,20 +45,20 @@ MLI := $4000
.struct GrafPort .struct GrafPort
;; MapInfo ;; MapInfo
viewloc .tag Point viewloc .tag Point ; 0
mapbits .addr mapbits .addr ; 4
mapwidth .byte mapwidth .byte ; 6
reserved .byte reserved .byte ; 7
maprect .tag Rect maprect .tag Rect ; 8
pattern .tag Pattern pattern .tag Pattern ; 16
colormasks .byte 2 ; colormask_and, colormask_or colormasks .byte 2 ; 24 colormask_and, colormask_or
penloc .tag Point penloc .tag Point ; 26
penwidth .byte ; horizontal pen thickness penwidth .byte ; 30 horizontal pen thickness
penheight .byte ; vertical pen thickness penheight .byte ; 31 vertical pen thickness
penmode .byte penmode .byte ; 32
textback .byte ; text background textback .byte ; 33 text background
textfont .addr textfont .addr ; 34
.endstruct .endstruct
;;; PolyList record: ;;; PolyList record: