Skip to content

Commit

Permalink
[BASIC/BANNEX] Implement EDIT command (X16Community#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-b-jakobsson authored Oct 8, 2023
1 parent 5152994 commit 3583e76
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ BANNEX_SOURCES= \
bannex/splash.s \
bannex/locate.s \
bannex/dos.s \
bannex/tile.s
bannex/tile.s \
bannex/x16edit.s

GENERIC_DEPS = \
inc/kernal.inc \
Expand Down
2 changes: 2 additions & 0 deletions bannex/main.s
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ rom_bank = 1
.import dos_clear_disk_status
.import dos_chkdosw
.import tile
.import x16edit

.segment "JMPTBL"
jmp renumber ; $C000
Expand All @@ -35,3 +36,4 @@ rom_bank = 1
jmp dos_clear_disk_status ; $C01B
jmp dos_chkdosw ; $C01E
jmp tile ; $C021
jmp x16edit ; $C024
42 changes: 42 additions & 0 deletions bannex/x16edit.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.include "banks.inc"

.export x16edit
.import bajsrfar, frmevl, valtyp, fcerr, frefac, index1

.segment "ANNEX"

.proc x16edit
beq new ; No input param, open editor with a new empty buffer
jsr frmevl ; Evaluate input
bit valtyp
bmi file ; Input is a string, try to open file in the editor

error:
jmp fcerr ; Input was not a string => error

file:
jsr frefac ; Get string
beq new ; String is empty, open new empty buffer

sta $04 ; R1L = file name length
lda index1
sta $02 ; R0L = file name address low
lda index1+1
sta $03 ; R0H = file name address high
ldx #10 ; First RAM bank used by the editor
ldy #255 ; Last RAM bank used by the editor

jsr bajsrfar
.word $C003
.byte BANK_X16EDIT
rts

new:
ldx #10 ; First RAM bank used by the editor
ldy #255 ; Last RAM bank used by the editor
stz $04 ; R1L = file name length, 0 => no file
jsr bajsrfar
.word $C003
.byte BANK_X16EDIT
rts
.endproc
1 change: 1 addition & 0 deletions basic/token2.s
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ reslst3
.byt "BANNE", 'R' + $80
.byt "EXE", 'C' + $80
.byt "TIL", 'E' + $80
.byt "EDI", 'T' + $80

; add new statements before this line

Expand Down
1 change: 1 addition & 0 deletions basic/tokens.s
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ stmdsp2 ; statements
.word banner-1
.word exec-1
.word ctile-1
.word cedit-1
; functions
ptrfunc .word vpeek
.word mx
Expand Down
10 changes: 10 additions & 0 deletions basic/x16additions.s
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,16 @@ ctile:
bannex_call bannex_tile
rts

;******************************************************************
;
; EDIT [<string filename>]
; Opens a file in the X16 text editor
;
;******************************************************************
cedit:
bannex_call bannex_x16edit
rts

; BASIC's entry into jsrfar
.setcpu "65c02"
.export bjsrfar
Expand Down
1 change: 1 addition & 0 deletions inc/banks.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ BANK_DEMO = $09
BANK_AUDIO = $0A
BANK_UTIL = $0B
BANK_BANNEX = $0C
BANK_X16EDIT = $0D ; Occupies two banks!

; XXX these constant RAM addresses are KERNAL
; XXX implementation details and need to go away!
Expand Down
1 change: 1 addition & 0 deletions inc/bannex.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ bannex_dos_ptstat3 = $C018
bannex_dos_clear_disk_status = $C01B
bannex_dos_chkdosw = $C01E
bannex_tile = $C021
bannex_x16edit = $C024

0 comments on commit 3583e76

Please sign in to comment.