Rework file type / icon tables. Fixes #103

This commit is contained in:
Joshua Bell 2018-12-30 20:35:23 -08:00
parent b2a9e62f6d
commit 813e60443e
4 changed files with 73 additions and 57 deletions

View File

@ -37,6 +37,7 @@
* SELECTOR.LIST created if missing. (#92) * SELECTOR.LIST created if missing. (#92)
* Position desktop icons based on Slot/Drive assignment. (#94) * Position desktop icons based on Slot/Drive assignment. (#94)
* Don't crash after renaming volume. (#99) * Don't crash after renaming volume. (#99)
* Correct odd behavior for file type $08 (#103)
* Hardware/Emulator Specific: * Hardware/Emulator Specific:
* IIc Plus: don't spin slot 5 drives constantly. (Use Special > Check Drives) (#25) * IIc Plus: don't spin slot 5 drives constantly. (Use Special > Check Drives) (#25)
* Macintosh LC IIe Option Card: prevent crash. (#93) * Macintosh LC IIe Option Card: prevent crash. (#93)

View File

@ -6495,7 +6495,12 @@ L7767: .byte $14
;; Check file type ;; Check file type
ldy #FileEntry::file_type ldy #FileEntry::file_type
lda (file_entry),y lda (file_entry),y
cmp #FT_S16 ; IIgs System?
cmp #FT_BAD ; T$01 is overloaded below for "apps", so
bne :+ ; treat as generic
lda #FT_TYPELESS
: cmp #FT_S16 ; IIgs System?
beq is_app beq is_app
cmp #FT_SYSTEM ; Other system? cmp #FT_SYSTEM ; Other system?
bne got_type ; nope bne got_type ; nope
@ -6516,7 +6521,7 @@ L7767: .byte $14
is_app: is_app:
lda #$01 ; TODO: Define a symbol for this. lda #$01 ; TODO: Define a symbol for this.
bne got_type bne got_type ; always
str_sys_suffix: str_sys_suffix:
PASCAL_STRING ".SYSTEM" PASCAL_STRING ".SYSTEM"
@ -6610,6 +6615,7 @@ L7870: lda cached_window_id
.endproc .endproc
;;; ============================================================ ;;; ============================================================
;;; Special case: $01 is used for App-like SYS files.
.proc find_icon_details_for_file_type .proc find_icon_details_for_file_type
ptr := $6 ptr := $6
@ -6617,31 +6623,24 @@ L7870: lda cached_window_id
sta file_type sta file_type
jsr push_pointers 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 ;; Find index of file type
copy16 type_table_addr, ptr copy16 #type_table, ptr
ldy #0 ldy #num_file_types-1
lda (ptr),y ; first entry is size of table
tay
: lda (ptr),y : lda (ptr),y
cmp file_type cmp file_type
beq found beq found
dey dey
bpl :- bpl :-
ldy #1 ; default is first entry (FT_TYPELESS) ldy #0 ; default is first entry (FT_TYPELESS)
found: found:
;; Look up icon type ;; Look up icon type
copy16 icon_type_table_addr, ptr copy16 #icon_type_table, ptr
lda (ptr),y lda (ptr),y
sta icon_type sta icon_type
dey
;; Look up y-offset ;; Look up y-offset
copy16 #type_deltays, ptr copy16 #type_deltay_table, ptr
lda (ptr),y lda (ptr),y
sta icon_deltay sta icon_deltay
@ -6650,7 +6649,7 @@ found:
tay tay
;; Look up icon definition ;; Look up icon definition
copy16 type_icons_addr, ptr copy16 #type_icons_table, ptr
copy16in (ptr),y, iconbits copy16in (ptr),y, iconbits
jsr pop_pointers jsr pop_pointers
rts rts
@ -7465,14 +7464,12 @@ check_type:
.scope .scope
type_table_copy := $807 type_table_copy := $807
;; Copy type_table (including size) to $807 ;; Copy type_table prefixed by length to $807
copy16 type_table_addr, $08 copy16 #type_table, $08
ldy #0 copy #num_file_types, type_table_copy
lda ($08),y ldy #num_file_types-1
sta type_table_copy
tay ; num entries
: lda ($08),y : lda ($08),y
sta type_table_copy,y sta type_table_copy+1,y
dey dey
bne :- bne :-
@ -8202,37 +8199,42 @@ tmp: .byte 0
;;; ============================================================ ;;; ============================================================
.proc compose_file_type_string .proc compose_file_type_string
sta L877F ptr := $06
copy16 type_table_addr, $06
ldy #$00
lda ($06),y
tay
L8719: lda ($06),y
cmp L877F
beq L8726
dey
bne L8719
jmp L8745
L8726: tya sta file_type
copy16 #type_table, ptr
ldy #num_file_types-1
: lda ($06),y
cmp file_type
beq found
dey
bpl :-
jmp not_found
;; Found - copy string from table
found: tya
asl a asl a
asl a asl a
tay tay
copy16 type_names_addr, $06 copy16 #type_names_table, ptr
ldx #$00
L8736: lda ($06),y ldx #0
: lda ($06),y
sta str_file_type+1,x sta str_file_type+1,x
iny iny
inx inx
cpx #$04 cpx #4
bne L8736 bne :-
stx str_file_type stx str_file_type
rts rts
L8745: copy #4, str_file_type ;; Type not found - use generic " $xx"
not_found:
copy #4, str_file_type
copy #' ', str_file_type+1 copy #' ', str_file_type+1
copy #'$', str_file_type+2 copy #'$', str_file_type+2
lda L877F lda file_type
lsr a lsr a
lsr a lsr a
lsr a lsr a
@ -8245,7 +8247,7 @@ L8745: copy #4, str_file_type
L8764: clc L8764: clc
adc #'7' ; A-F adc #'7' ; A-F
L8767: sta str_file_type+3 L8767: sta str_file_type+3
lda L877F lda file_type
and #$0F and #$0F
cmp #$0A cmp #$0A
bcs L8778 bcs L8778
@ -8257,7 +8259,8 @@ L8778: clc
L877B: sta path_buf4 L877B: sta path_buf4
rts rts
L877F: .byte 0 file_type:
.byte 0
.endproc .endproc

View File

@ -1426,33 +1426,28 @@ icon_entries:
.org $FB00 .org $FB00
type_table_addr: .addr type_table num_file_types = 8
type_icons_addr: .addr type_icons
icon_type_table_addr: .addr icon_type_table
type_names_addr: .addr type_names
type_table: type_table:
.byte 8 ; size of table; first entry is default
.byte FT_TYPELESS, FT_SRC, FT_TEXT, FT_BINARY .byte FT_TYPELESS, FT_SRC, FT_TEXT, FT_BINARY
.byte FT_DIRECTORY, FT_SYSTEM, FT_BASIC, FT_BAD .byte FT_DIRECTORY, FT_SYSTEM, FT_BASIC, FT_BAD
icon_type_table: icon_type_table:
.byte $60 ; unused?
.byte $50,$50,$50,$20,$00,$10,$30,$10 .byte $50,$50,$50,$20,$00,$10,$30,$10
type_names: type_names_table:
.byte " ???"
;; Same order as icon list below
.byte " ???", " SRC", " TXT", " BIN" .byte " ???", " SRC", " TXT", " BIN"
.byte " DIR", " SYS", " BAS", " SYS" .byte " DIR", " SYS", " BAS", " BAD"
.byte " BAD" ;;; The icon-related tables (below) use a distinguishing icon
;;; for "apps" (SYS files with ".SYSTEM" name suffix). This is
;;; done by changing the type from $FF to $01 so that an index
;;; lookup into |type_table| finds the last slot.
type_icons: type_icons_table:
.addr gen, src, txt, bin, dir, sys, bas, app .addr gen, src, txt, bin, dir, sys, bas, app
type_deltays: type_deltay_table:
.byte 2, 2, 2, 2, 6, 0, 2, 0 .byte 2, 2, 2, 2, 6, 0, 2, 0
.macro DEFICON mapbits, mapwidth, x1, y1, x2, y2 .macro DEFICON mapbits, mapwidth, x1, y1, x2, y2

17
res/pxmap.pl Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env perl
use strict;
use warnings;
while (<STDIN>) {
chomp;
s/[^ #]//g;
tr/ #/01/;
next unless $_;
$_ .= '0' while length($_) % 7 != 0;
my @a = m/(.......)/g;
print ' .byte ' . join(',', map { "px(\%$_)" } @a) . "\n";
}