mirror of
https://github.com/mi57730/a2d.git
synced 2024-11-28 15:50:16 +00:00
DeskTop: Make type remapping data driven
This commit is contained in:
parent
e3424bde4f
commit
0daa0f6184
@ -15,6 +15,8 @@ VERSION_MINOR = 2
|
||||
DA_FILE_TYPE = $F1
|
||||
DA_AUX_TYPE = $640 ; High bit set = don't show in Apple menu
|
||||
|
||||
APP_FILE_TYPE = $01 ; FT_SYS w/ ".SYSTEM" (FT_BAD mapped to FT_TYPELESS)
|
||||
|
||||
max_desk_acc_count = 12
|
||||
|
||||
INVOKER := $290 ; Invoke other programs
|
||||
|
@ -909,7 +909,7 @@ begin:
|
||||
: cmp #FT_SYSTEM
|
||||
beq launch
|
||||
|
||||
cmp #FT_S16
|
||||
cmp #APP_FILE_TYPE
|
||||
beq launch
|
||||
|
||||
cmp #FT_GRAPHICS
|
||||
@ -6650,26 +6650,6 @@ L7767: .byte $14
|
||||
ldy #FileRecord::file_type
|
||||
lda (file_entry),y
|
||||
|
||||
cmp #FT_S16 ; IIgs System?
|
||||
beq is_app
|
||||
|
||||
;; Map other IIgs-specific types to one icon
|
||||
tax
|
||||
and #$F0 ; high nibble
|
||||
cmp #$50 ; $5x Types: Apple IIgs General
|
||||
beq is_iigs
|
||||
cmp #$A0 ; $Ax Types: Apple IIgs BASIC
|
||||
beq is_iigs
|
||||
cmp #$B0 ; $Bx Types: Apple IIgs System
|
||||
beq is_iigs
|
||||
cmp #$C0 ; $Cx Types: Graphics
|
||||
beq is_iigs
|
||||
txa
|
||||
|
||||
;; FT_BAD is overloaded, so use generic
|
||||
cmp #FT_BAD ; T$01 is overloaded below for "apps", so
|
||||
beq is_generic ; treat as generic
|
||||
|
||||
;; Handle several classes of overrides
|
||||
sta fto_type
|
||||
ldy #FileRecord::aux_type
|
||||
@ -6678,11 +6658,11 @@ L7767: .byte $14
|
||||
copy16in (file_entry),y, fto_blocks
|
||||
jsr check_file_type_overrides
|
||||
|
||||
cmp #FT_SYSTEM ; Other system?
|
||||
bne got_type ; nope
|
||||
|
||||
;; Distinguish *.SYSTEM files as apps (use $01) from other
|
||||
;; type=SYS files (use $FF).
|
||||
cmp #FT_SYSTEM
|
||||
bne got_type
|
||||
|
||||
ldy #FileRecord::name
|
||||
lda (file_entry),y
|
||||
tay
|
||||
@ -6697,15 +6677,7 @@ cloop: lda (file_entry),y
|
||||
bne cloop
|
||||
|
||||
is_app:
|
||||
lda #FT_BAD ; overloaded meaning in icon tables
|
||||
bne got_type ; always
|
||||
|
||||
is_generic:
|
||||
lda #FT_TYPELESS
|
||||
beq got_type ; always
|
||||
|
||||
is_iigs:
|
||||
lda #FT_SRC
|
||||
lda #APP_FILE_TYPE ; overloaded meaning in icon tables
|
||||
bne got_type ; always
|
||||
|
||||
str_sys_suffix:
|
||||
@ -6841,74 +6813,68 @@ file_type:
|
||||
|
||||
;;; ============================================================
|
||||
;;; Check file type for possible overrides
|
||||
;;; TODO: Make this data driven.
|
||||
|
||||
;;; Input: fto_type, fto_auxtype, fto_blocks populated
|
||||
;;; Output: A is filetype to use
|
||||
;;; Output: A is filetype to use (for icons, open/preview, etc)
|
||||
|
||||
.proc check_file_type_overrides
|
||||
;; Binary - treat certain auxtypes/sizes as Graphics
|
||||
ptr := $06
|
||||
|
||||
jsr push_pointers
|
||||
copy16 #fto_table, ptr
|
||||
|
||||
loop: ldy #0 ; type_mask, or $00 if done
|
||||
lda (ptr),y
|
||||
bne :+
|
||||
jsr pop_pointers
|
||||
lda fto_type
|
||||
cmp #FT_BINARY
|
||||
bne check_da
|
||||
|
||||
ldxy #$5800 ; minipix
|
||||
jsr compare_aux
|
||||
bne :+
|
||||
ldxy #3 ; blocks
|
||||
jsr compare_blocks
|
||||
beq is_graphics
|
||||
:
|
||||
|
||||
ldxy #$2000 ; hires / double hires
|
||||
jsr compare_aux
|
||||
bne :+
|
||||
ldxy #17 ; blocks
|
||||
jsr compare_blocks
|
||||
beq is_graphics
|
||||
ldxy #33 ; blocks
|
||||
jsr compare_blocks
|
||||
beq is_graphics
|
||||
:
|
||||
|
||||
;; DA - treat as generic *unless* auxtypes are correct
|
||||
check_da:
|
||||
lda fto_type
|
||||
cmp #DA_FILE_TYPE
|
||||
bne :+
|
||||
ldxy #DA_AUX_TYPE
|
||||
jsr compare_aux
|
||||
beq :+
|
||||
ldxy #DA_AUX_TYPE | $8000
|
||||
jsr compare_aux
|
||||
bne is_generic
|
||||
|
||||
: rts
|
||||
|
||||
is_generic:
|
||||
lda #FT_TYPELESS
|
||||
rts
|
||||
|
||||
is_graphics:
|
||||
lda #FT_GRAPHICS
|
||||
rts
|
||||
;; Check type (with mask)
|
||||
: and fto_type ; A = type & type_mask
|
||||
iny ; ASSERT: Y = FTORecord::type
|
||||
cmp (ptr),y ; type check
|
||||
bne next
|
||||
|
||||
auxtype:
|
||||
.word 0
|
||||
;; Flags
|
||||
iny ; ASSERT: Y = FTORecord::flags
|
||||
lda (ptr),y
|
||||
sta flags
|
||||
|
||||
.proc compare_aux
|
||||
cpx fto_auxtype
|
||||
bne :+
|
||||
cpy fto_auxtype+1
|
||||
: rts
|
||||
.endproc
|
||||
;; Does Aux Type matter, and if so does it match?
|
||||
bit flags
|
||||
bpl blocks ; bit 7 = compare aux
|
||||
iny ; ASSERT: Y = FTORecord::aux
|
||||
lda fto_auxtype
|
||||
cmp (ptr),y
|
||||
bne next
|
||||
iny
|
||||
lda fto_auxtype+1
|
||||
cmp (ptr),y
|
||||
bne next
|
||||
|
||||
.proc compare_blocks
|
||||
cpx fto_blocks
|
||||
bne :+
|
||||
cpy fto_blocks+1
|
||||
: rts
|
||||
.endproc
|
||||
;; Does Block Count matter, and if so does it match?
|
||||
blocks: bit flags
|
||||
bvc match ; bit 6 = compare blocks
|
||||
ldy #FTORecord::blocks
|
||||
lda fto_blocks
|
||||
cmp (ptr),y
|
||||
bne next
|
||||
iny
|
||||
lda fto_blocks+1
|
||||
cmp (ptr),y
|
||||
bne next
|
||||
|
||||
;; Have a match
|
||||
match: ldy #FTORecord::newtype
|
||||
lda (ptr),y
|
||||
sta fto_type
|
||||
|
||||
;; Next entry
|
||||
next: add16 ptr, #.sizeof(FTORecord), ptr
|
||||
jmp loop
|
||||
|
||||
flags: .byte 0
|
||||
|
||||
.endproc
|
||||
|
||||
|
@ -1401,11 +1401,66 @@ date: .word 0
|
||||
hex_digits:
|
||||
.byte "0123456789ABCDEF"
|
||||
|
||||
;;; --------------------------------------------------
|
||||
|
||||
;;; Params for check_file_type_overrides
|
||||
fto_type: .byte 0
|
||||
fto_auxtype: .word 0
|
||||
fto_blocks: .word 0
|
||||
|
||||
;;; Data-driven remapping of file types - used for icons, open/preview, etc.
|
||||
;;;
|
||||
;;; The incoming type is compared (using a mask) against a type, and
|
||||
;;; optionally auxtype and block count. If matched, a replacement type
|
||||
;;; is used. All entries are processed, even if a match was found. This
|
||||
;;; allows inverted matches.
|
||||
|
||||
.struct FTORecord ; Offset
|
||||
mask .byte ; 0 incoming type masked before comparison
|
||||
type .byte ; 1 type for the record (must match)
|
||||
flags .byte ; 2 bit 7 = compare aux; 6 = compare blocks
|
||||
aux .word ; 3 optional aux type
|
||||
blocks .word ; 5 optional block count
|
||||
newtype .byte ; 7 replacement type
|
||||
.endstruct
|
||||
.macro DEFINE_FTORECORD mask, type, flags, aux, blocks, newtype
|
||||
.byte mask
|
||||
.byte type
|
||||
.byte flags
|
||||
.word aux
|
||||
.word blocks
|
||||
.byte newtype
|
||||
.endmacro
|
||||
FTO_FLAGS_NONE = %00000000
|
||||
FTO_FLAGS_AUX = %10000000
|
||||
FTO_FLAGS_BLOCKS = %01000000
|
||||
|
||||
fto_table_record_size = 8
|
||||
fto_table:
|
||||
DEFINE_FTORECORD $FF, FT_BAD, FTO_FLAGS_NONE, 0, 0, FT_TYPELESS ; Reserve BAD for tmp
|
||||
|
||||
;; Desk Accessories/Applets
|
||||
DEFINE_FTORECORD $FF, DA_FILE_TYPE, FTO_FLAGS_NONE, 0, 0, FT_BAD ; Remap $F1 by default...
|
||||
DEFINE_FTORECORD $FF, FT_BAD, FTO_FLAGS_AUX, $640, 0, DA_FILE_TYPE ; Restore $F1/$0640 as DA
|
||||
DEFINE_FTORECORD $FF, FT_BAD, FTO_FLAGS_AUX, $8640, 0, DA_FILE_TYPE ; Restore $F1/$8640 as DA
|
||||
DEFINE_FTORECORD $FF, FT_BAD, FTO_FLAGS_NONE, 0, 0, FT_TYPELESS ; Reserve BAD for tmp
|
||||
|
||||
;; Graphics Files
|
||||
DEFINE_FTORECORD $FF, FT_BINARY, FTO_FLAGS_AUX|FTO_FLAGS_BLOCKS, $2000, 17, FT_GRAPHICS ; HR image as FOT
|
||||
DEFINE_FTORECORD $FF, FT_BINARY, FTO_FLAGS_AUX|FTO_FLAGS_BLOCKS, $2000, 33, FT_GRAPHICS ; DHR image as FOT
|
||||
DEFINE_FTORECORD $FF, FT_BINARY, FTO_FLAGS_AUX|FTO_FLAGS_BLOCKS, $5800, 3, FT_GRAPHICS ; Minipix as FOT
|
||||
|
||||
;; Applications
|
||||
DEFINE_FTORECORD $FF, FT_S16, FTO_FLAGS_NONE, 0, 0, APP_FILE_TYPE ; IIgs System => "App"
|
||||
|
||||
;; IIgs-Specific Files (ranges)
|
||||
DEFINE_FTORECORD $F0, $50, FTO_FLAGS_NONE, 0, 0, FT_SRC ; IIgs General => SRC
|
||||
DEFINE_FTORECORD $F0, $A0, FTO_FLAGS_NONE, 0, 0, FT_SRC ; IIgs BASIC => SRC
|
||||
DEFINE_FTORECORD $F0, $B0, FTO_FLAGS_NONE, 0, 0, FT_SRC ; IIgs System => SRC
|
||||
DEFINE_FTORECORD $F0, $C0, FTO_FLAGS_NONE, 0, 0, FT_SRC ; IIgs Graphics => SRC
|
||||
|
||||
.byte 0 ; sentinel at end of table
|
||||
|
||||
;;; --------------------------------------------------
|
||||
|
||||
PAD_TO $ED00
|
||||
@ -1464,6 +1519,9 @@ type_names_table:
|
||||
;;; Similarly, IIgs-specific types ($5x, $Ax-$Cx) are all
|
||||
;;; mapped to $B0 (SRC).
|
||||
|
||||
.assert FT_BAD = APP_FILE_TYPE, error, "Mismatched file type remapping"
|
||||
|
||||
|
||||
icon_type_table:
|
||||
.byte icon_entry_type_generic ; typeless
|
||||
.byte icon_entry_type_generic ; src
|
||||
|
Loading…
Reference in New Issue
Block a user