mirror of
https://github.com/mi57730/a2d.git
synced 2024-09-27 18:54:49 +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_FILE_TYPE = $F1
|
||||||
DA_AUX_TYPE = $640 ; High bit set = don't show in Apple menu
|
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
|
max_desk_acc_count = 12
|
||||||
|
|
||||||
INVOKER := $290 ; Invoke other programs
|
INVOKER := $290 ; Invoke other programs
|
||||||
|
@ -909,7 +909,7 @@ begin:
|
|||||||
: cmp #FT_SYSTEM
|
: cmp #FT_SYSTEM
|
||||||
beq launch
|
beq launch
|
||||||
|
|
||||||
cmp #FT_S16
|
cmp #APP_FILE_TYPE
|
||||||
beq launch
|
beq launch
|
||||||
|
|
||||||
cmp #FT_GRAPHICS
|
cmp #FT_GRAPHICS
|
||||||
@ -6650,26 +6650,6 @@ L7767: .byte $14
|
|||||||
ldy #FileRecord::file_type
|
ldy #FileRecord::file_type
|
||||||
lda (file_entry),y
|
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
|
;; Handle several classes of overrides
|
||||||
sta fto_type
|
sta fto_type
|
||||||
ldy #FileRecord::aux_type
|
ldy #FileRecord::aux_type
|
||||||
@ -6678,11 +6658,11 @@ L7767: .byte $14
|
|||||||
copy16in (file_entry),y, fto_blocks
|
copy16in (file_entry),y, fto_blocks
|
||||||
jsr check_file_type_overrides
|
jsr check_file_type_overrides
|
||||||
|
|
||||||
cmp #FT_SYSTEM ; Other system?
|
|
||||||
bne got_type ; nope
|
|
||||||
|
|
||||||
;; Distinguish *.SYSTEM files as apps (use $01) from other
|
;; Distinguish *.SYSTEM files as apps (use $01) from other
|
||||||
;; type=SYS files (use $FF).
|
;; type=SYS files (use $FF).
|
||||||
|
cmp #FT_SYSTEM
|
||||||
|
bne got_type
|
||||||
|
|
||||||
ldy #FileRecord::name
|
ldy #FileRecord::name
|
||||||
lda (file_entry),y
|
lda (file_entry),y
|
||||||
tay
|
tay
|
||||||
@ -6697,15 +6677,7 @@ cloop: lda (file_entry),y
|
|||||||
bne cloop
|
bne cloop
|
||||||
|
|
||||||
is_app:
|
is_app:
|
||||||
lda #FT_BAD ; overloaded meaning in icon tables
|
lda #APP_FILE_TYPE ; overloaded meaning in icon tables
|
||||||
bne got_type ; always
|
|
||||||
|
|
||||||
is_generic:
|
|
||||||
lda #FT_TYPELESS
|
|
||||||
beq got_type ; always
|
|
||||||
|
|
||||||
is_iigs:
|
|
||||||
lda #FT_SRC
|
|
||||||
bne got_type ; always
|
bne got_type ; always
|
||||||
|
|
||||||
str_sys_suffix:
|
str_sys_suffix:
|
||||||
@ -6841,74 +6813,68 @@ file_type:
|
|||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;; Check file type for possible overrides
|
;;; Check file type for possible overrides
|
||||||
;;; TODO: Make this data driven.
|
|
||||||
|
|
||||||
;;; Input: fto_type, fto_auxtype, fto_blocks populated
|
;;; 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
|
.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
|
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
|
rts
|
||||||
|
|
||||||
is_graphics:
|
;; Check type (with mask)
|
||||||
lda #FT_GRAPHICS
|
: and fto_type ; A = type & type_mask
|
||||||
rts
|
iny ; ASSERT: Y = FTORecord::type
|
||||||
|
cmp (ptr),y ; type check
|
||||||
|
bne next
|
||||||
|
|
||||||
auxtype:
|
;; Flags
|
||||||
.word 0
|
iny ; ASSERT: Y = FTORecord::flags
|
||||||
|
lda (ptr),y
|
||||||
|
sta flags
|
||||||
|
|
||||||
.proc compare_aux
|
;; Does Aux Type matter, and if so does it match?
|
||||||
cpx fto_auxtype
|
bit flags
|
||||||
bne :+
|
bpl blocks ; bit 7 = compare aux
|
||||||
cpy fto_auxtype+1
|
iny ; ASSERT: Y = FTORecord::aux
|
||||||
: rts
|
lda fto_auxtype
|
||||||
.endproc
|
cmp (ptr),y
|
||||||
|
bne next
|
||||||
|
iny
|
||||||
|
lda fto_auxtype+1
|
||||||
|
cmp (ptr),y
|
||||||
|
bne next
|
||||||
|
|
||||||
.proc compare_blocks
|
;; Does Block Count matter, and if so does it match?
|
||||||
cpx fto_blocks
|
blocks: bit flags
|
||||||
bne :+
|
bvc match ; bit 6 = compare blocks
|
||||||
cpy fto_blocks+1
|
ldy #FTORecord::blocks
|
||||||
: rts
|
lda fto_blocks
|
||||||
.endproc
|
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
|
.endproc
|
||||||
|
|
||||||
|
@ -1401,11 +1401,66 @@ date: .word 0
|
|||||||
hex_digits:
|
hex_digits:
|
||||||
.byte "0123456789ABCDEF"
|
.byte "0123456789ABCDEF"
|
||||||
|
|
||||||
|
;;; --------------------------------------------------
|
||||||
|
|
||||||
;;; Params for check_file_type_overrides
|
;;; Params for check_file_type_overrides
|
||||||
fto_type: .byte 0
|
fto_type: .byte 0
|
||||||
fto_auxtype: .word 0
|
fto_auxtype: .word 0
|
||||||
fto_blocks: .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
|
PAD_TO $ED00
|
||||||
@ -1464,6 +1519,9 @@ type_names_table:
|
|||||||
;;; Similarly, IIgs-specific types ($5x, $Ax-$Cx) are all
|
;;; Similarly, IIgs-specific types ($5x, $Ax-$Cx) are all
|
||||||
;;; mapped to $B0 (SRC).
|
;;; mapped to $B0 (SRC).
|
||||||
|
|
||||||
|
.assert FT_BAD = APP_FILE_TYPE, error, "Mismatched file type remapping"
|
||||||
|
|
||||||
|
|
||||||
icon_type_table:
|
icon_type_table:
|
||||||
.byte icon_entry_type_generic ; typeless
|
.byte icon_entry_type_generic ; typeless
|
||||||
.byte icon_entry_type_generic ; src
|
.byte icon_entry_type_generic ; src
|
||||||
|
Loading…
Reference in New Issue
Block a user