Skip to content

Commit

Permalink
About This Apple: Show duplicate SmartPort device names with counts
Browse files Browse the repository at this point in the history
Rather than showing "SmartPort: Devname, Devname, Devname, Devname,
..." until it is cut off, show "SmartPort: DevName (8)" or whatever
the actual count is. This only counts adjacent devices with the
same name, so if the units are heterogeneous then the list may still
be cut off, but it's better than it was.
  • Loading branch information
inexorabletash committed Nov 12, 2024
1 parent b467559 commit fa2e3d9
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 8 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Project Page: https://github.com/a2stuff/a2d
* About This Apple II
* Detect Microdigital TK-3000 //e
* Detect Pravetz 8A/C
* Show duplicate SmartPort device names with counts.
* Screen Dump: Improve use of SSC and IW2.
* Print Catalog: Improve use of SSC and IW2.
* Options: Add option to show invisible files.
Expand Down
2 changes: 2 additions & 0 deletions desk.acc/res/this.apple.res.da
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
.define res_string_unknown "(ukendt)"
.define res_string_empty "(tom)"
.define res_string_none "(ingen)"
.define res_string_duplicate_suffix_pattern " (#)"
.define res_const_duplicate_suffix_pattern_offset1 3
.define res_string_cpu_prefix " CPU: "
.define res_string_cpu_type_6502 "6502"
.define res_string_cpu_type_65C02 "65C02"
Expand Down
2 changes: 2 additions & 0 deletions desk.acc/res/this.apple.res.de
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
.define res_string_unknown "(unbekannt)"
.define res_string_empty "(leer)"
.define res_string_none "(keine)"
.define res_string_duplicate_suffix_pattern " (#)"
.define res_const_duplicate_suffix_pattern_offset1 3
.define res_string_cpu_prefix " CPU: "
.define res_string_cpu_type_6502 "6502"
.define res_string_cpu_type_65C02 "65C02"
Expand Down
2 changes: 2 additions & 0 deletions desk.acc/res/this.apple.res.en
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
.define res_string_unknown "(unknown)"
.define res_string_empty "(empty)"
.define res_string_none "(none)"
.define res_string_duplicate_suffix_pattern " (#)"
.define res_const_duplicate_suffix_pattern_offset1 3
.define res_string_cpu_prefix " CPU: "
.define res_string_cpu_type_6502 "6502"
.define res_string_cpu_type_65C02 "65C02"
Expand Down
2 changes: 2 additions & 0 deletions desk.acc/res/this.apple.res.es
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
.define res_string_unknown "(desconocido)"
.define res_string_empty "(vac\x12o)"
.define res_string_none "(nada)"
.define res_string_duplicate_suffix_pattern " (#)"
.define res_const_duplicate_suffix_pattern_offset1 3
.define res_string_cpu_prefix " CPU: "
.define res_string_cpu_type_6502 "6502"
.define res_string_cpu_type_65C02 "65C02"
Expand Down
2 changes: 2 additions & 0 deletions desk.acc/res/this.apple.res.fr
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
.define res_string_unknown "(inconnu)"
.define res_string_empty "(vide)"
.define res_string_none "(aucun)"
.define res_string_duplicate_suffix_pattern " (#)"
.define res_const_duplicate_suffix_pattern_offset1 3
.define res_string_cpu_prefix " CPU : "
.define res_string_cpu_type_6502 "6502"
.define res_string_cpu_type_65C02 "65C02"
Expand Down
2 changes: 2 additions & 0 deletions desk.acc/res/this.apple.res.it
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
.define res_string_unknown "(sconosciuto)"
.define res_string_empty "(vuoto)"
.define res_string_none "(nessuno)"
.define res_string_duplicate_suffix_pattern " (#)"
.define res_const_duplicate_suffix_pattern_offset1 3
.define res_string_cpu_prefix " CPU: "
.define res_string_cpu_type_6502 "6502"
.define res_string_cpu_type_65C02 "65C02"
Expand Down
2 changes: 2 additions & 0 deletions desk.acc/res/this.apple.res.nl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
.define res_string_unknown "(onbekend)"
.define res_string_empty "(leeg)"
.define res_string_none "(geen)"
.define res_string_duplicate_suffix_pattern " (#)"
.define res_const_duplicate_suffix_pattern_offset1 3
.define res_string_cpu_prefix " CPU: "
.define res_string_cpu_type_6502 "6502"
.define res_string_cpu_type_65C02 "65C02"
Expand Down
2 changes: 2 additions & 0 deletions desk.acc/res/this.apple.res.pt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
.define res_string_unknown "(desconhecido)"
.define res_string_empty "(v@cuo)"
.define res_string_none "(nenhum)"
.define res_string_duplicate_suffix_pattern " (#)"
.define res_const_duplicate_suffix_pattern_offset1 3
.define res_string_cpu_prefix " CPU: "
.define res_string_cpu_type_6502 "6502"
.define res_string_cpu_type_65C02 "65C02"
Expand Down
2 changes: 2 additions & 0 deletions desk.acc/res/this.apple.res.sv
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
.define res_string_unknown "(ok{nt)"
.define res_string_empty "(t|mma)"
.define res_string_none "(ingen)"
.define res_string_duplicate_suffix_pattern " (#)"
.define res_const_duplicate_suffix_pattern_offset1 3
.define res_string_cpu_prefix " CPU: "
.define res_string_cpu_type_6502 "6502"
.define res_string_cpu_type_65C02 "65C02"
Expand Down
67 changes: 59 additions & 8 deletions desk.acc/this.apple.s
Original file line number Diff line number Diff line change
Expand Up @@ -719,9 +719,13 @@ str_unknown: PASCAL_STRING res_string_unknown
str_empty: PASCAL_STRING res_string_empty
str_none: PASCAL_STRING res_string_none

str_duplicate_suffix: PASCAL_STRING res_string_duplicate_suffix_pattern
kDuplicateCountOffset = res_const_duplicate_suffix_pattern_offset1

;;; ============================================================

dib_buffer: .tag SPDIB
kMaxSPDeviceNameLength = SPDIB::Device_Type_Code - SPDIB::Device_Name

;;; ============================================================
;;; Per Technical Note: Apple II Miscellaneous #7: Apple II Family Identification
Expand Down Expand Up @@ -2151,6 +2155,9 @@ p65802: return16 #str_65802 ; Other boards support 65802

start:
copy #$80, empty_flag
lda #0
sta str_last
sta duplicate_count

;; Locate SmartPort entry point: $Cn00 + ($CnFF) + 3
ldy #$FF
Expand Down Expand Up @@ -2219,21 +2226,33 @@ next: dey
done:
.endscope

str_current := dib_buffer+SPDIB::ID_String_Length

;; Empty?
lda dib_buffer+SPDIB::ID_String_Length
IF_ZERO
.assert .strlen(res_string_unknown) < kMaxSPDeviceNameLength, error, "string length"
COPY_STRING str_unknown, str_current
END_IF

;; Same as last?
jsr CompareWithLast
IF_EQ
inc duplicate_count
bne next ; always
END_IF
jsr MaybeDrawDuplicateSuffix
COPY_STRING str_current, str_last

;; Need a comma?
bit empty_flag
IF_PLUS
param_call DrawString, str_list_separator
END_IF
copy #0, empty_flag ; saw a unit!

;; Draw the device name
copy #0, empty_flag ; saw a unit!
lda dib_buffer+SPDIB::ID_String_Length
IF_ZERO
ldax #str_unknown
ELSE
ldax #dib_buffer+SPDIB::ID_String_Length
END_IF
jsr DrawString
param_call DrawString, str_current

;; Next!
next: lda status_params::unit_num
Expand All @@ -2243,6 +2262,8 @@ next: lda status_params::unit_num
jmp device_loop

finish:
jsr MaybeDrawDuplicateSuffix

;; If no units, populate with "(none)"
bit empty_flag
IF_MINUS
Expand All @@ -2252,6 +2273,10 @@ finish:

rts

str_last:
.res ::kMaxSPDeviceNameLength+1
duplicate_count:
.byte 0
empty_flag:
.byte 0
num_devices:
Expand All @@ -2268,6 +2293,32 @@ num_devices:
.endproc ; SmartPortCall
sp_addr = SmartPortCall::sp_addr

.proc CompareWithLast
lda str_current
cmp str_last
bne ret
tax
: lda str_current,x
cmp str_last,x
bne ret
dex
bne :-
ret: rts
.endproc ; CompareWithLast

.proc MaybeDrawDuplicateSuffix
ldx duplicate_count
IF_NOT_ZERO
inx
txa
ora #'0'
sta str_duplicate_suffix + kDuplicateCountOffset
param_call DrawString, str_duplicate_suffix
lda #0
sta duplicate_count
END_IF
rts
.endproc ; MaybeDrawDuplicateSuffix

.endproc ; ShowSmartPortDeviceNamesImpl
ShowSmartPortDeviceNames := ShowSmartPortDeviceNamesImpl::start
Expand Down

0 comments on commit fa2e3d9

Please sign in to comment.