Skip to content

Commit

Permalink
[BASIC/BANNEX] add TILE command to BASIC (X16Community#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
mooinglemur authored Oct 7, 2023
1 parent 2e24842 commit e854469
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ BANNEX_SOURCES= \
bannex/help.s \
bannex/splash.s \
bannex/locate.s \
bannex/dos.s
bannex/dos.s \
bannex/tile.s

GENERIC_DEPS = \
inc/kernal.inc \
Expand Down Expand Up @@ -372,7 +373,7 @@ $(BUILD_DIR)/util.bin: $(UTIL_OBJS) $(UTIL_DEPS) $(CFG_DIR)/util-x16.cfg
$(BUILD_DIR)/bannex.bin: $(BANNEX_OBJS) $(BANNEX_DEPS) $(CFG_DIR)/bannex-x16.cfg
@mkdir -p $$(dirname $@)
$(LD) -C $(CFG_DIR)/bannex-x16.cfg $(BANNEX_OBJS) -o $@ -m $(BUILD_DIR)/bannex.map -Ln $(BUILD_DIR)/bannex.sym \
`${BUILD_DIR}/../../findsymbols ${BUILD_DIR}/basic.sym basic_fa chrgot crambank curlin eormsk facho index index1 index2 poker rencur reninc rennew renold rentmp rentmp2 txtptr txttab valtyp vartab verck` \
`${BUILD_DIR}/../../findsymbols ${BUILD_DIR}/basic.sym basic_fa chrgot crambank curlin eormsk fac facho index index1 index2 poker rencur reninc rennew renold rentmp rentmp2 txtptr txttab valtyp vartab verck` \
`${BUILD_DIR}/../../findsymbols ${BUILD_DIR}/basic.sym -p basic_ chkcom cld10 crdo erexit error frefac frmadr frmevl getadr getbyt linprt nsnerr6` \
`${BUILD_DIR}/../../findsymbols ${BUILD_DIR}/kernal.sym mode`
./scripts/relist.py $(BUILD_DIR)/bannex.map $(BUILD_DIR)/bannex
Expand Down
2 changes: 2 additions & 0 deletions bannex/main.s
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ rom_bank = 1
.import dos_ptstat3
.import dos_clear_disk_status
.import dos_chkdosw
.import tile

.segment "JMPTBL"
jmp renumber ; $C000
Expand All @@ -33,3 +34,4 @@ rom_bank = 1
jmp dos_ptstat3 ; $C018
jmp dos_clear_disk_status ; $C01B
jmp dos_chkdosw ; $C01E
jmp tile ; $C021
128 changes: 128 additions & 0 deletions bannex/tile.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
.include "io.inc"

.import fcerr
.import chkcom
.import getbyt

.importzp fac, chrgot, chrget, poker

.export tile

.proc tile: near
stz poker+1 ; attribute exists flag
jsr getbyt ; X
phx
jsr chkcom
jsr getbyt ; Y
phx
jsr chkcom
jsr getbyt ; tile/screen code
phx
jsr chrgot
beq @plargs
jsr chkcom
jsr getbyt ; attributes
stx poker
dec poker+1 ; set flag
@plargs:
pla
sta fac+2
pla
sta fac+1
pla
sta fac+0
@chkh:
lda VERA_L1_CONFIG ; bounds checking, keep tile numbers within the map size
and #$c0
cmp #$c0
beq @chkw
cmp #$80
bcc @h1
lda fac+1
cmp #128
bcs @erange
bra @chkw
@h1:
cmp #$40
bcc @h2
lda fac+1
cmp #64
bcs @erange
bra @chkw
@h2:
lda fac+1
cmp #32
bcs @erange
@chkw:
lda VERA_L1_CONFIG
and #$30
cmp #$30
beq @ok
cmp #$20
bcc @w1
lda fac+0
cmp #128
bcs @erange
bra @ok
@w1:
cmp #$10
bcc @w2
lda fac+0
cmp #64
bcs @erange
bra @chkw
@w2:
lda fac+0
cmp #32
bcc @ok
@erange:
jmp fcerr
@ok: ; bounds checking complete
lda VERA_L1_MAPBASE
asl
sta VERA_ADDR_M
lda #0
rol
ora #$10
sta VERA_ADDR_H
lda VERA_L1_CONFIG
lsr
lsr
lsr
lsr
and #3
clc
adc #6 ; left shift 5 + map width +1 for attribute spacing
tax ; this is the byte size per row in the map
lda fac+1
stz fac+1
: asl
rol fac+1
dex
bne :-
sta VERA_ADDR_L
lda fac+1
adc VERA_ADDR_M
sta VERA_ADDR_M
bcc :+
inc VERA_ADDR_H
: lda fac+0
stz fac+0
; now add the column in
asl ; x2
rol fac+0 ; for attribute
adc VERA_ADDR_L
sta VERA_ADDR_L
lda fac+0
adc VERA_ADDR_M
sta VERA_ADDR_M
bcc :+
inc VERA_ADDR_H
: lda fac+2
sta VERA_DATA0
bit poker+1
bpl :+
lda poker
sta VERA_DATA0
: rts
.endproc
1 change: 1 addition & 0 deletions basic/token2.s
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ reslst3
.byt "HEL", 'P' + $80
.byt "BANNE", 'R' + $80
.byt "EXE", 'C' + $80
.byt "TIL", 'E' + $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 @@ -141,6 +141,7 @@ stmdsp2 ; statements
.word help-1
.word banner-1
.word exec-1
.word ctile-1
; functions
ptrfunc .word vpeek
.word mx
Expand Down
4 changes: 4 additions & 0 deletions basic/x16additions.s
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,10 @@ exec:
rts


ctile:
bannex_call bannex_tile
rts

; BASIC's entry into jsrfar
.setcpu "65c02"
.export bjsrfar
Expand Down
1 change: 1 addition & 0 deletions inc/bannex.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ bannex_dos_getfa = $C015
bannex_dos_ptstat3 = $C018
bannex_dos_clear_disk_status = $C01B
bannex_dos_chkdosw = $C01E
bannex_tile = $C021

0 comments on commit e854469

Please sign in to comment.