Add icon y-delta table to minimize bitmap sizes

This commit is contained in:
Joshua Bell 2018-12-30 19:59:37 -08:00
parent 72be3c1231
commit b2a9e62f6d
3 changed files with 34 additions and 45 deletions

View File

@ -260,5 +260,4 @@ op: lda dummy1234
.include "desktop_res.s"
.assert * = $FFBA, error, "Segment length mismatch"
PAD_TO $10000

View File

@ -6309,6 +6309,7 @@ L7620: .byte $00
window_id: .byte 0
iconbits: .addr 0
icon_type: .byte 0
icon_deltay: .byte 0
L7625: .byte 0 ; ???
initial_coords: ; first icon in window
@ -6554,6 +6555,17 @@ L77F0: lda name_tmp,x
cpx #.sizeof(MGTK::Point)
bne :-
;; 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
lda cached_window_icon_count
cmp icons_per_row
beq L781A
@ -6564,12 +6576,15 @@ L7826: copy16 row_coords::ycoord, icon_coords::ycoord
lda icons_this_row
cmp icons_per_row
bne L7862
;; Next row (and initial column) if necessary
add16 row_coords::ycoord, #32, row_coords::ycoord
copy16 initial_coords::xcoord, row_coords::xcoord
lda #0
sta icons_this_row
jmp L7870
;; Next column otherwise
L7862: lda row_coords::xcoord
clc
adc #icon_x_spacing
@ -6602,6 +6617,10 @@ L7870: lda cached_window_id
sta file_type
jsr push_pointers
;; BUG: If file type is $08, the above search yields an
;; index of 0, which is unexpected.
;; https://github.com/inexorabletash/a2d/issues/103
;; Find index of file type
copy16 type_table_addr, ptr
ldy #0
@ -6620,6 +6639,12 @@ found:
lda (ptr),y
sta icon_type
dey
;; Look up y-offset
copy16 #type_deltays, ptr
lda (ptr),y
sta icon_deltay
tya
asl a
tay

View File

@ -1452,6 +1452,9 @@ type_names:
type_icons:
.addr gen, src, txt, bin, dir, sys, bas, app
type_deltays:
.byte 2, 2, 2, 2, 6, 0, 2, 0
.macro DEFICON mapbits, mapwidth, x1, y1, x2, y2
.addr mapbits
.byte mapwidth
@ -1459,20 +1462,18 @@ type_icons:
.word x1, y1, x2, y2
.endmacro
gen: DEFICON generic_icon, 4, 0, 0, 27, 17
gen: DEFICON generic_icon, 4, 0, 0, 27, 15
src:
txt: DEFICON text_icon, 4, 0, 0, 27, 17
bin: DEFICON binary_icon, 4, 0, 0, 27, 17
dir: DEFICON folder_icon, 4, 0, 0, 27, 17
txt: DEFICON text_icon, 4, 0, 0, 27, 15
bin: DEFICON binary_icon, 4, 0, 0, 27, 14
dir: DEFICON folder_icon, 4, 0, 0, 27, 11
sys: DEFICON sys_icon, 4, 0, 0, 27, 17
bas: DEFICON basic_icon, 4, 0, 0, 27, 17
app: DEFICON app_icon, 5, 0, 0, 34, 17
bas: DEFICON basic_icon, 4, 0, 0, 27, 14
app: DEFICON app_icon, 5, 0, 0, 34, 16
;;; Generic
generic_icon:
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0111111),px(%1111111),px(%1111100),px(%0000000)
.byte px(%0100000),px(%0000000),px(%0001011),px(%0000000)
.byte px(%0100000),px(%0000000),px(%0001000),px(%1100000)
@ -1491,8 +1492,6 @@ generic_icon:
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
generic_mask:
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0111111),px(%1111111),px(%1111100),px(%0000000)
.byte px(%0111111),px(%1111111),px(%1111111),px(%0000000)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1100000)
@ -1513,8 +1512,6 @@ generic_mask:
;;; Text File
text_icon:
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0111111),px(%1111111),px(%1111100),px(%0000000)
.byte px(%0100000),px(%0000000),px(%0001011),px(%0000000)
.byte px(%0100000),px(%1110111),px(%1011000),px(%1100000)
@ -1533,8 +1530,6 @@ text_icon:
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
text_mask:
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0111111),px(%1111111),px(%1111100),px(%0000000)
.byte px(%0111111),px(%1111111),px(%1111111),px(%0000000)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1100000)
@ -1555,8 +1550,6 @@ text_mask:
;;; Binary
binary_icon:
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000001),px(%1000000),px(%0000000)
.byte px(%0000000),px(%0000110),px(%0110000),px(%0000000)
.byte px(%0000000),px(%0011000),px(%0001100),px(%0000000)
@ -1572,12 +1565,8 @@ binary_icon:
.byte px(%0000000),px(%0011000),px(%0001100),px(%0000000)
.byte px(%0000000),px(%0000110),px(%0110000),px(%0000000)
.byte px(%0000000),px(%0000001),px(%1000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
binary_mask:
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000001),px(%1000000),px(%0000000)
.byte px(%0000000),px(%0000111),px(%1110000),px(%0000000)
.byte px(%0000000),px(%0011111),px(%1111100),px(%0000000)
@ -1591,17 +1580,9 @@ binary_mask:
.byte px(%0000000),px(%0011111),px(%1111100),px(%0000000)
.byte px(%0000000),px(%0000111),px(%1110000),px(%0000000)
.byte px(%0000000),px(%0000001),px(%1000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
;;; Folder
folder_icon:
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0011111),px(%1111110),px(%0000000),px(%0000000)
.byte px(%0100000),px(%0000001),px(%0000000),px(%0000000)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
@ -1616,12 +1597,6 @@ folder_icon:
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
folder_mask:
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0011111),px(%1111110),px(%0000000),px(%0000000)
.byte px(%0111111),px(%1111111),px(%0000000),px(%0000000)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
@ -1680,8 +1655,6 @@ sys_mask:
;;; Basic
basic_icon:
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000001),px(%1000000),px(%0000000)
.byte px(%0000000),px(%0000110),px(%0110000),px(%0000000)
.byte px(%0000000),px(%0011000),px(%0001100),px(%0000000)
@ -1697,12 +1670,8 @@ basic_icon:
.byte px(%0000000),px(%0011000),px(%0001100),px(%0000000)
.byte px(%0000000),px(%0000110),px(%0110000),px(%0000000)
.byte px(%0000000),px(%0000001),px(%1000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
basic_mask:
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000001),px(%1000000),px(%0000000)
.byte px(%0000000),px(%0000111),px(%1110000),px(%0000000)
.byte px(%0000000),px(%0011111),px(%1111100),px(%0000000)
@ -1716,8 +1685,6 @@ basic_mask:
.byte px(%0000000),px(%0011111),px(%1111100),px(%0000000)
.byte px(%0000000),px(%0000111),px(%1110000),px(%0000000)
.byte px(%0000000),px(%0000001),px(%1000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
;;; System (with .SYSTEM suffix)
@ -1739,7 +1706,6 @@ app_icon:
.byte px(%0000000),px(%0000011),px(%0000001),px(%1000000),px(%0011110)
.byte px(%0000000),px(%0000000),px(%1100110),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0011000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000),px(%0000000)
app_mask:
.byte px(%0000000),px(%0000000),px(%0011000),px(%0000000),px(%0000000)
@ -1759,4 +1725,3 @@ app_mask:
.byte px(%0000000),px(%0000011),px(%1111111),px(%1000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%1111110),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0011000),px(%0000000),px(%0000000)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000),px(%0000000)