Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic bank statement #340

Merged
merged 15 commits into from
Oct 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions basic/code17.s
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,33 @@ peek lda poker+1
jsr getadr0
ldy #0
lda poker+1
cmp #$c0
cmp #$a0
bcs peek1
lda (poker),y ;RAM
lda (poker),y ;Low RAM
jmp peek2
peek1 lda #poker
ldx #BANK_KERNAL
jsr fetch ;ROM
peek1 lda #poker ;High RAM or ROM
ldx curbank
jsr fetch
peek2 tay
dosgfl pla
sta poker
pla
sta poker+1
jmp sngflt
poke jsr getnum
lda poker+1
cmp #$a0
bcs pokefr
txa
ldy #0
sta (poker),y
rts
pokefr lda #poker
sta stavec
txa
ldx curbank
ldy #0
jmp stash
fnwait jsr getnum
stx andmsk
ldx #0
Expand Down
35 changes: 33 additions & 2 deletions basic/code26.s
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ setmsg =$ff90
plot =$fff0

csys jsr frmadr ;get int. addr
lda linnum+1
cmp #$a0
bcs csysfar
lda #>csysrz ;push return address
pha
lda #<csysrz
Expand All @@ -53,6 +56,33 @@ csys jsr frmadr ;get int. addr
ldy syreg
plp ;load 6502 status reg
jmp (linnum) ;go do it

csysfar jsr csysfr2
bra csysrz+1

csysfr2 pha ;Far jump; extra byte on stack for return bank

lda spreg ;Processor status -> stack
pha
lda sareg ;A -> stack
pha
ldx sxreg ;X -> stack
phx
ldy syreg ;Fetch Y

lda linnum ;Set jsrfar target address
sta jmpfr+1
lda linnum+1
sta jmpfr+2

tsx ;Push return bank to extra byte reserved on stack
lda #BANK_BASIC
sta $0104,x
plx

lda curbank ;Fetch target bank, and go far!
jmp jsrfar3

csysrz =*-1 ;return to here
php ;save status reg
sta sareg ;save 6502 regs
Expand All @@ -69,8 +99,9 @@ nsnerr6 ldx vartab ;end save addr
ldy vartab+1
lda #<txttab ;indirect with start address
jsr $ffd8 ;save it
bcs erexit
rts
bcs :+
jmp erexit
: rts

cverf lda #1 ;verify flag
bra :+
Expand Down
1 change: 1 addition & 0 deletions basic/init.s
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ nready jmp readyx
init jsr initv ;go init vectors
jsr initcz ;go init charget & z-page
jsr initms ;go print initilization messages
stz curbank ;set default value for BANK statement
init2 ldx #stkend-256 ;set up end of stack
txs
boot lda #0
Expand Down
1 change: 1 addition & 0 deletions basic/token2.s
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ reslst2 .byt "MO", 'N' + $80
.byt "BLOA", 'D' + $80
.byt "BVLOA", 'D' + $80
.byt "BVERIF", 'Y' + $80
.byt "BAN", 'K' + $80
.byt "VPEE", 'K' + $80
.byt "M", 'X' + $80
.byt "M", 'Y' + $80
Expand Down
1 change: 1 addition & 0 deletions basic/tokens.s
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ stmdsp2 ; statements
.word bload-1
.word bvload-1
.word bvrfy-1
.word setbank-1

; functions
ptrfunc .word vpeek
Expand Down
12 changes: 12 additions & 0 deletions basic/x16additions.s
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,18 @@ ckeymap:
rts
@fcerr: jmp fcerr

;***************
.export curbank
.segment "BVARS"
curbank: .res 1

.segment "BASIC"
.export setbank
setbank:
jsr getbyt
stx curbank
rts

;***************
test:
beq @test0
Expand Down
5 changes: 2 additions & 3 deletions cfg/x16.cfginc
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ KVECTORS: start = $0314, size = $0020; # KERNAL vectors
/* $0334-$03FF: variables and RAM code (not available for *legacy* GEOS apps) */
KVAR2: start = $0334, size = $0057; # KERNAL: screen editor table
KERNRAM2: start = $038B, size = $003F; # KERNAL: banked IRQ, fetch, stash
/* start = $03CA, size = $0002; # reserved for KERNAL growth */
FPVARS: start = $03CB, size = $0009; # MATH
BVARS: start = $03D4, size = $002C; # BASIC
FPVARS: start = $03CA, size = $0009; # MATH
BVARS: start = $03D3, size = $002D; # BASIC

/* KERNAL/DOS bank #0 vars */
KEYMAP: start = $A000, size = $0800; # the current keyboard mapping table
Expand Down