Skip to content

Commit 4021f74

Browse files
Add LOCK/UNLOCK commands. Costs 55 bytes.
1 parent 8a4b6e3 commit 4021f74

File tree

4 files changed

+46
-4
lines changed

4 files changed

+46
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This is a version of Steve Wozniak's Integer BASIC for the Apple II, with a wrap
1616
* `BSAVE path,A<address>,L<length>"` saves a `BIN` file.
1717
* `BLOAD path[,A<address>]"` loads a `BIN` file.
1818
* `BRUN path[,A<address>]"` runs a `BIN` file.
19+
* `LOCK path` and `UNLOCK path` lock/unlock the specified file.
1920
* `BYE` exits back to ProDOS.
2021

2122
2. When invoked as an "interpreter" for an `INT` file from a program selector (such as [Bitsy Bye](https://prodos8.com/bitsy-bye/) or [Apple II DeskTop](https://a2desktop.com)), the file is loaded and executed.

intbasic.system.s

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ dispatch:
670670
syn: ldy #<intbasic::ErrMsg02 ;"SYNTAX"
671671
jmp intbasic::ERRMESS
672672

673-
NUM_CMDS = 15
673+
NUM_CMDS = 17
674674

675675
cmdtable:
676676
scrcode "RUN" ; must be 0 for special handling
@@ -703,14 +703,18 @@ cmdtable:
703703
.byte 0
704704
scrcode "NOMON"
705705
.byte 0
706+
scrcode "LOCK"
707+
.byte 0
708+
scrcode "UNLOCK"
709+
.byte 0
706710
.byte 0 ; sentinel
707711

708712
MonCmd := 0 ; ignored
709713
NomonCmd := 0
710714
cmdproclo:
711-
.byte <RunCmd,<QuitCmd,<SaveCmd,<LoadCmd,<PrefixCmd,<CatCmd,<CatCmd,<DeleteCmd,<RenameCmd,<BSaveCmd,<BLoadCmd,<BRunCmd,<PRCmd,<MonCmd,<NomonCmd
715+
.byte <RunCmd,<QuitCmd,<SaveCmd,<LoadCmd,<PrefixCmd,<CatCmd,<CatCmd,<DeleteCmd,<RenameCmd,<BSaveCmd,<BLoadCmd,<BRunCmd,<PRCmd,<MonCmd,<NomonCmd,<LockCmd,<UnlockCmd
712716
cmdprochi:
713-
.byte >RunCmd,>QuitCmd,>SaveCmd,>LoadCmd,>PrefixCmd,>CatCmd,>CatCmd,>DeleteCmd,>RenameCmd,>BSaveCmd,>BLoadCmd,>BRunCmd,>PRCmd,>MonCmd,>NomonCmd
717+
.byte >RunCmd,>QuitCmd,>SaveCmd,>LoadCmd,>PrefixCmd,>CatCmd,>CatCmd,>DeleteCmd,>RenameCmd,>BSaveCmd,>BLoadCmd,>BRunCmd,>PRCmd,>MonCmd,>NomonCmd,>LockCmd,>UnlockCmd
714718
.assert * - cmdproclo = NUM_CMDS * 2, error, "table size"
715719

716720
cmdparse:
@@ -729,6 +733,8 @@ cmdparse:
729733
.byte ParseFlags::slotnum ; PR#
730734
.byte ParseFlags::ignore ; MON
731735
.byte ParseFlags::ignore ; NOMON
736+
.byte ParseFlags::path ; LOCK
737+
.byte ParseFlags::path ; UNLOCK
732738
.assert * - cmdparse = NUM_CMDS, error, "table size"
733739

734740
parse_flags:
@@ -1433,6 +1439,32 @@ finish:
14331439
run: jmp (rw_data_buffer)
14341440
.endproc ; BRunCmd
14351441

1442+
;;; ============================================================
1443+
;;; "LOCK path" and "UNLOCK path"
1444+
1445+
.proc LockCmd
1446+
jsr GetFileInfo
1447+
bne ret
1448+
1449+
lda gfi_access
1450+
and #%00111101 ; clear destroy, rename, write
1451+
store: sta gfi_access
1452+
1453+
lda #7 ; param count for SET_FILE_INFO
1454+
sta gfi_param_count
1455+
MLI_CALL SET_FILE_INFO, gfi_params
1456+
ret: rts
1457+
.endproc ; LockCmd
1458+
1459+
.proc UnlockCmd
1460+
jsr GetFileInfo
1461+
bne LockCmd::ret
1462+
1463+
lda gfi_access
1464+
ora #%11000010 ; set destroy, rename, write
1465+
bne LockCmd::store ; always
1466+
.endproc ; UnlockCmd
1467+
14361468
;;; ============================================================
14371469
;;; "PR#<slot>"
14381470

res/TESTS.INT

128 Bytes
Binary file not shown.

res/tests.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ NEW
6868
343 PRINT D$;"BSAVE BIN,V254,A8192,L1"
6969
344 A=1 : GOSUB 10000
7070

71-
350 TEST$ = "Leading spaves"
71+
350 TEST$ = "Leading spaces"
7272
351 PRINT D$;" BSAVE BIN,A8192,L1"
7373
352 A=1 : GOSUB 10000
7474

@@ -113,6 +113,15 @@ NEW
113113
473 PRINT D$;"NOMONICO"
114114
474 A=1 : GOSUB 10000
115115

116+
480 TEST$ = "LOCK"
117+
481 PRINT D$;"BSAVE BIN,A8192,L1"
118+
482 PRINT D$;"LOCK BIN"
119+
483 A=1 : GOSUB 10000
120+
121+
490 TEST$ = "UNLOCK"
122+
491 PRINT D$;"UNLOCK BIN"
123+
492 A=1 : GOSUB 10000
124+
116125

117126
9000 REM ******************************
118127
9001 REM CLEANUP

0 commit comments

Comments
 (0)