diff --git a/Makefile b/Makefile index c3315669..f69e89a0 100644 --- a/Makefile +++ b/Makefile @@ -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 \ @@ -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 diff --git a/bannex/main.s b/bannex/main.s index 88deda44..2a435b24 100644 --- a/bannex/main.s +++ b/bannex/main.s @@ -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 @@ -33,3 +34,4 @@ rom_bank = 1 jmp dos_ptstat3 ; $C018 jmp dos_clear_disk_status ; $C01B jmp dos_chkdosw ; $C01E + jmp tile ; $C021 diff --git a/bannex/tile.s b/bannex/tile.s new file mode 100644 index 00000000..fc91c0d9 --- /dev/null +++ b/bannex/tile.s @@ -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 diff --git a/basic/token2.s b/basic/token2.s index 8c083517..33c24d25 100644 --- a/basic/token2.s +++ b/basic/token2.s @@ -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 diff --git a/basic/tokens.s b/basic/tokens.s index f80894bd..c6f8e4ad 100644 --- a/basic/tokens.s +++ b/basic/tokens.s @@ -141,6 +141,7 @@ stmdsp2 ; statements .word help-1 .word banner-1 .word exec-1 + .word ctile-1 ; functions ptrfunc .word vpeek .word mx diff --git a/basic/x16additions.s b/basic/x16additions.s index c4877e88..21e5cd9a 100644 --- a/basic/x16additions.s +++ b/basic/x16additions.s @@ -871,6 +871,10 @@ exec: rts +ctile: + bannex_call bannex_tile + rts + ; BASIC's entry into jsrfar .setcpu "65c02" .export bjsrfar diff --git a/inc/bannex.inc b/inc/bannex.inc index 43ae01a6..9c402c5c 100644 --- a/inc/bannex.inc +++ b/inc/bannex.inc @@ -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