Skip to content

Commit 7edf425

Browse files
Show header and modified date for CAT/CATALOG command
Costs 193 bytes, but we've got space.
1 parent 45b7be1 commit 7edf425

File tree

1 file changed

+102
-11
lines changed

1 file changed

+102
-11
lines changed

intbasic.system.s

+102-11
Original file line numberDiff line numberDiff line change
@@ -1345,8 +1345,13 @@ open: jsr Open
13451345
jsr intbasic::MON_COUT
13461346
:
13471347
jsr print_entry_name
1348-
jsr intbasic::MON_CROUT
1349-
jsr intbasic::MON_CROUT
1348+
1349+
ldx #0
1350+
: lda header_str,x
1351+
jsr COUT
1352+
inx
1353+
cpx #kHeaderStrLen
1354+
bne :-
13501355

13511356
lda ENTRY_BUFFER + $24 - 4; entries_per_block
13521357
sta entries_per_block
@@ -1384,7 +1389,7 @@ next_entry:
13841389
lda ENTRY_BUFFER + $00 ; storage_type / name_length
13851390
beq next_entry ; inactive - skip
13861391

1387-
;; Entry display: locked, name, type, block count
1392+
;; Entry display: locked, name, type, block count, date
13881393
ldx #' '|$80
13891394
lda ENTRY_BUFFER + $1E ; access
13901395
and #%11000010 ; destroy, rename, write
@@ -1393,15 +1398,26 @@ next_entry:
13931398
: txa
13941399
jsr intbasic::MON_COUT
13951400

1401+
;; Name
13961402
jsr print_entry_name
13971403

1404+
;; Type
1405+
lda #17
1406+
sta CH
13981407
jsr print_entry_type
13991408

1400-
lda #' '|$80
1401-
jsr intbasic::MON_COUT
1409+
;; Blocks
1410+
lda #22
1411+
sta CH
14021412
ldx ENTRY_BUFFER + $13 ; blocks_used lo
14031413
lda ENTRY_BUFFER + $14 ; blocks_used hi
14041414
jsr intbasic::PRDEC
1415+
1416+
;; Date
1417+
lda #28
1418+
sta CH
1419+
jsr print_entry_date
1420+
14051421
jsr intbasic::MON_CROUT
14061422

14071423
;; Next file, unless the use cancelled
@@ -1427,12 +1443,6 @@ ret: rts
14271443
@len := *+1
14281444
cpx #$00 ; self-modified
14291445
bne :-
1430-
;; Pad with spaces
1431-
lda #' '|$80
1432-
: jsr intbasic::MON_COUT
1433-
inx
1434-
cpx #16
1435-
bne :-
14361446
rts
14371447
.endproc ; print_entry_name
14381448

@@ -1481,13 +1491,94 @@ types:
14811491
.byte 0 ; sentinel
14821492
.endproc ; print_entry_type
14831493

1494+
.proc print_entry_date
1495+
DATE := ENTRY_BUFFER + $21
1496+
1497+
lda DATE
1498+
ora DATE+1
1499+
beq no_date
1500+
1501+
;; Day
1502+
lda DATE ; MMMDDDDD
1503+
and #%00011111 ; 000DDDDD
1504+
cmp #10
1505+
bcs :+
1506+
inc CH
1507+
: tax
1508+
lda #0
1509+
jsr intbasic::PRDEC
1510+
1511+
lda #'-'|$80
1512+
jsr COUT
1513+
1514+
;; Month
1515+
lda DATE+1 ; YYYYYYYM
1516+
lsr ; high bit of M into C
1517+
pha
1518+
lda DATE ; MMMDDDDD
1519+
ror ; MMMMDDDD
1520+
lsr ; 0MMMMDDD
1521+
lsr ; 00MMMMDD
1522+
lsr ; 000MMMMD
1523+
lsr ; 0000MMMM
1524+
tax ; 1-based to 0-based
1525+
dex
1526+
lda months,x
1527+
jsr COUT
1528+
lda months+12,x
1529+
jsr COUT
1530+
lda months+24,x
1531+
jsr COUT
1532+
1533+
lda #'-'|$80
1534+
jsr COUT
1535+
1536+
;; Year
1537+
1538+
pla
1539+
cmp #40 ; 0-39 is 2000-2039
1540+
bcs :+ ; Per Technical Note: ProDOS #28:
1541+
adc #100 ; ProDOS Dates -- 2000 and Beyond
1542+
: clc
1543+
adc #<1900
1544+
tax
1545+
lda #0
1546+
adc #>1900
1547+
jmp intbasic::PRDEC
1548+
1549+
months: ; swizzled
1550+
scrcode "JFMAMJJASOND"
1551+
scrcode "AEAPAUUUECOE"
1552+
scrcode "NBRRYNLGPTVC"
1553+
1554+
no_date:
1555+
ldx #0
1556+
: lda no_date_str,x
1557+
jsr COUT
1558+
inx
1559+
cpx #kNoDateStrLen
1560+
bne :-
1561+
rts
1562+
1563+
no_date_str:
1564+
scrcode "<NO DATE>"
1565+
kNoDateStrLen := * - no_date_str
1566+
1567+
.endproc ; print_entry_date
1568+
14841569
file_count:
14851570
.word 0
14861571
entries_per_block:
14871572
.byte 0
14881573
entries_this_block:
14891574
.byte 0
14901575

1576+
header_str:
1577+
.byte $8D, $8D ; CR
1578+
scrcode " NAME TYPE BLOCKS MODIFIED"
1579+
.byte $8D, $8D ; CR
1580+
kHeaderStrLen := * - header_str
1581+
14911582
.endproc ; CatCmd
14921583

14931584
;;; ============================================================

0 commit comments

Comments
 (0)