From 550247f4724d070930dd9deb159e70ddf91ce954 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Thu, 3 Jan 2019 18:13:47 -0800 Subject: [PATCH] Compute icon offsets, eliminate table --- desktop.inc | 28 +++++++++++++++++++++++++ desktop/desktop_main.s | 42 ++++++++++--------------------------- desktop/desktop_res.s | 47 ++++++++++++++---------------------------- 3 files changed, 55 insertions(+), 62 deletions(-) diff --git a/desktop.inc b/desktop.inc index 2dbb865..5d2b9ac 100644 --- a/desktop.inc +++ b/desktop.inc @@ -269,3 +269,31 @@ GLYPH_SAPPLE = $1E ;;; Check $1D ;;; Control $01 ;;; Inactive $7F + +;;; ============================================================ +;;; Internals - miscellaneous structures + +.struct IconDefinition + ;; First part is MGTK::MapInfo without leading viewloc + mapbits .addr ; address of bitmap bits + mapwidth .byte ; stride of bitmap bits + reserved .byte ; 0 + maprect .tag MGTK::Rect ; x1,y1 must be 0,0 + + ;; Next part is link to mask - not used for volume + ;; icons (which currently lack a mask). + maskbits .addr +.endstruct + +.struct FileRecord + name .res 16 + file_type .byte ; 16 $10 + blocks .word ; 17 $11 + creation_date .word ; 19 $13 + creation_time .word ; 21 $15 + modification_date .word ; 23 $17 + modification_time .word ; 25 $19 + access .byte ; 27 $1B + header_pointer .word ; 28 $1C + reserved .word ; ??? +.endstruct diff --git a/desktop/desktop_main.s b/desktop/desktop_main.s index 209f86c..b8c506d 100644 --- a/desktop/desktop_main.s +++ b/desktop/desktop_main.s @@ -5689,21 +5689,6 @@ L704C: .res 8 ;;; ============================================================ -.struct FileRecord - name .res 16 - file_type .byte ; 16 $10 - blocks .word ; 17 $11 - creation_date .word ; 19 $13 - creation_time .word ; 21 $15 - modification_date .word ; 23 $17 - modification_time .word ; 25 $19 - access .byte ; 27 $1B - header_pointer .word ; 28 $1C - reserved .word ; ??? -.endstruct - -;;; ============================================================ - .proc open_directory jmp start @@ -6309,11 +6294,13 @@ L7620: .byte $00 window_id: .byte 0 iconbits: .addr 0 icon_type: .byte 0 -icon_deltay: .byte 0 +icon_height: .word 0 L7625: .byte 0 ; ??? + max_icon_height = 17 + initial_coords: ; first icon in window - DEFINE_POINT 52,16, initial_coords + DEFINE_POINT 52,16 + max_icon_height, initial_coords row_coords: ; first icon in current row DEFINE_POINT 0, 0, row_coords @@ -6580,14 +6567,7 @@ L77F0: lda name_tmp,x ;; Include y-offset ldy #IconEntry::icony - lda (icon_entry),y - clc - adc icon_deltay - sta (icon_entry),y - iny - lda (icon_entry),y - adc #0 - sta (icon_entry),y + sub16in (icon_entry),y, icon_height, (icon_entry),y lda cached_window_icon_count cmp icons_per_row @@ -6657,12 +6637,6 @@ found: lda (ptr),y sta icon_type - ;; Look up y-offset - copy16 #type_deltay_table, ptr - lda (ptr),y - sta icon_deltay - ;; TODO: compute y-offset from iconbits instead - tya asl a tay @@ -6670,6 +6644,12 @@ found: ;; Look up icon definition copy16 #type_icons_table, ptr copy16in (ptr),y, iconbits + + ;; Icon height will be needed too + copy16 iconbits, ptr + ldy #IconDefinition::maprect + MGTK::Rect::y2 + copy16in (ptr),y, icon_height + jsr pop_pointers rts diff --git a/desktop/desktop_res.s b/desktop/desktop_res.s index 172bd47..b963f1b 100644 --- a/desktop/desktop_res.s +++ b/desktop/desktop_res.s @@ -1466,44 +1466,29 @@ type_icons_table: ; map into definitions below .addr asp ; appleworks sp .addr app ; system (see below) -type_deltay_table: - .byte 2 ; typeless - .byte 2 ; src - .byte 3 ; rel - .byte 2 ; text - .byte 3 ; binary - .byte 6 ; directory - .byte 0 ; system - .byte 3 ; basic - .byte 6 ; graphics - .byte 2 ; appleworks db - .byte 2 ; appleworks wp - .byte 2 ; appleworks sp - .byte 1 ; system (see below) - -.macro DEFICON mapbits, mapwidth, x1, y1, x2, y2, maskbits +.macro DEFICON mapbits, mapwidth, dx, dy, maskbits ;; First part is MGTK::MapInfo without leading viewloc .addr mapbits .byte mapwidth - .byte 0 ; reserved - .word x1, y1, x2, y2 ; maprect + .byte 0 ; reserved + .word 0, 0, dx, dy ; maprect ;; Next part is link to mask .addr maskbits .endmacro -gen: DEFICON generic_icon, 4, 0, 0, 27, 15, generic_mask -src: DEFICON desktop_aux::iigs_file_icon, 4, 0, 0, 27, 15, generic_mask -rel: DEFICON desktop_aux::rel_file_icon, 4, 0, 0, 27, 14, binary_mask -txt: DEFICON text_icon, 4, 0, 0, 27, 15, generic_mask -bin: DEFICON binary_icon, 4, 0, 0, 27, 14, binary_mask -dir: DEFICON folder_icon, 4, 0, 0, 27, 11, folder_mask -sys: DEFICON sys_icon, 4, 0, 0, 27, 17, sys_mask -bas: DEFICON basic_icon, 4, 0, 0, 27, 14, basic_mask -fot: DEFICON desktop_aux::graphics_icon, 4, 0, 0, 27, 11, desktop_aux::graphics_mask -adb: DEFICON desktop_aux::adb_icon, 4, 0, 0, 27, 15, generic_mask -awp: DEFICON desktop_aux::awp_icon, 4, 0, 0, 27, 15, generic_mask -asp: DEFICON desktop_aux::asp_icon, 4, 0, 0, 27, 15, generic_mask -app: DEFICON app_icon, 5, 0, 0, 34, 16, app_mask +gen: DEFICON generic_icon, 4, 27, 15, generic_mask +src: DEFICON desktop_aux::iigs_file_icon, 4, 27, 15, generic_mask +rel: DEFICON desktop_aux::rel_file_icon, 4, 27, 14, binary_mask +txt: DEFICON text_icon, 4, 27, 15, generic_mask +bin: DEFICON binary_icon, 4, 27, 14, binary_mask +dir: DEFICON folder_icon, 4, 27, 11, folder_mask +sys: DEFICON sys_icon, 4, 27, 17, sys_mask +bas: DEFICON basic_icon, 4, 27, 14, basic_mask +fot: DEFICON desktop_aux::graphics_icon, 4, 27, 11, desktop_aux::graphics_mask +adb: DEFICON desktop_aux::adb_icon, 4, 27, 15, generic_mask +awp: DEFICON desktop_aux::awp_icon, 4, 27, 15, generic_mask +asp: DEFICON desktop_aux::asp_icon, 4, 27, 15, generic_mask +app: DEFICON app_icon, 5, 34, 16, app_mask ;;; Generic