Welcome to mirror list, hosted at ThFree Co, Russian Federation.

NesTiler.git/NesTiler.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <cluster@cluster.wtf>2023-09-19 22:21:37 +0300
committerAlexey 'Cluster' Avdyukhin <cluster@cluster.wtf>2023-09-19 22:21:51 +0300
commit2637455503f9ca24ce0597a19db374c349169894 (patch)
treea64a2b88b91bde6370e7150051707104d5fa202d
parentbced52e29952aac5fe4d04c35d9a7cbc72e22c93 (diff)
"--no-group-tiles" example: ascii
-rw-r--r--Examples/ascii/Makefile38
-rw-r--r--Examples/ascii/ascii.asm166
-rw-r--r--Examples/ascii/main.asm157
-rw-r--r--TestImages/Images/ascii.pngbin0 -> 1496 bytes
4 files changed, 361 insertions, 0 deletions
diff --git a/Examples/ascii/Makefile b/Examples/ascii/Makefile
new file mode 100644
index 0000000..4ab6b7a
--- /dev/null
+++ b/Examples/ascii/Makefile
@@ -0,0 +1,38 @@
+NESASM?=nesasm
+EMU?=fceux64
+TILER?=nestiler
+SOURCE=main.asm
+EXECUTABLE=ascii.nes
+
+IMAGE?=../../TestImages/Images/ascii.png
+
+PATTERN_0_BIN=pattern_0.bin
+PALETTE_0_BIN=palette_0.bin
+
+build: $(EXECUTABLE)
+
+all: $(EXECUTABLE)
+
+clean:
+ rm -f *.nes *.lst *.nl *.bin
+
+run: $(EXECUTABLE)
+ $(EMU) $(EXECUTABLE)
+
+$(EXECUTABLE): $(SOURCE) \
+$(PATTERN_0_BIN) $(PATTERN_1_BIN) \
+$(NAME_TABLE_0_BIN) $(NAME_TABLE_1_BIN) \
+$(ATTR_TABLE_0_BIN) $(ATTR_TABLE_1_BIN) \
+$(PALETTE_0_BIN) $(PALETTE_1_BIN)
+ $(NESASM) $(SOURCE) -o $(EXECUTABLE) --symbols=$(notdir $(EXECUTABLE)) -iWss
+
+$(PATTERN_0_BIN) \
+$(NAME_TABLE_0_BIN) \
+$(ATTR_TABLE_0_BIN) \
+$(PALETTE_0_BIN) $(PALETTE_1_BIN) \
+$(PALETTE_2_BIN) $(PALETTE_3_BIN): $(IMAGE)
+ $(TILER) --mode bg --enable-palettes 0 \
+ --in-0 $(IMAGE) \
+ --out-pattern-table-0 $(PATTERN_0_BIN) \
+ --out-palette-0 $(PALETTE_0_BIN) \
+ --no-group-tiles-0
diff --git a/Examples/ascii/ascii.asm b/Examples/ascii/ascii.asm
new file mode 100644
index 0000000..340fd1b
--- /dev/null
+++ b/Examples/ascii/ascii.asm
@@ -0,0 +1,166 @@
+ ; INES header stuff
+ .inesprg 1 ; 1 bank of PRG
+ .ineschr 2 ; 2 banks of CHR data
+ .inesmap 4 ; we use mapper 4 (MMC3)
+
+ .rsset $0000 ; variables
+COPY_SOURCE_ADDR .rs 2
+COPY_DEST_ADDR .rs 2
+
+ .org $DFFA ; start at $FFFA
+ .dw NMI
+ .dw Start
+ .dw IRQ
+
+ .org $C000 ; code starts at $E000
+
+Start:
+ ;sei ; no interrupts
+
+ ; disable PPU
+ lda #%00000000
+ sta PPUCTRL
+ sta PPUMASK
+ ; warm-up
+ jsr waitblank
+ jsr waitblank
+
+ ; clean memory
+ lda #$00
+ sta <COPY_SOURCE_ADDR
+ lda #$02
+ sta <COPY_SOURCE_ADDR + 1
+ lda #$00
+ ldy #$00
+ ldx #$06
+.loop:
+ sta [COPY_SOURCE_ADDR], y
+ iny
+ bne .loop
+ inc <COPY_SOURCE_ADDR+1
+ dex
+ bne .loop
+
+ ; use IRQ at $DFFE
+ lda #$C0
+ sta IRQ_ACTION
+ ; return to BIOS on reset
+ lda #$00
+ sta RESET_FLAG
+ sta RESET_TYPE
+
+ ; loading palette
+load_palette:
+ jsr waitblank
+ lda #$3F
+ sta PPUADDR
+ lda #$00
+ sta PPUADDR
+ ldx #$00
+.loop:
+ lda palette, x
+ sta PPUDATA
+ inx
+ cpx #4
+ bne .loop
+
+ ; loading blank nametable
+clear_nametable:
+ lda PPUSTATUS
+ lda #$20
+ sta PPUADDR
+ lda #$00
+ sta PPUADDR
+ ldy #0
+ ldx #0
+ lda #$20
+.loop:
+ cpy #$C0
+ bne .noat
+ cpx #$03
+ bne .noat
+ lda #$00
+.noat:
+ sta PPUDATA
+ iny
+ bne .loop
+ inx
+ cpx #$04
+ bne .loop
+.end:
+
+load_text:
+ lda PPUSTATUS
+ lda #$20
+ sta PPUADDR
+ lda #$41
+ sta PPUADDR
+ lda #LOW(hello_world)
+ sta COPY_SOURCE_ADDR
+ lda #HIGH(hello_world)
+ sta COPY_SOURCE_ADDR+1
+ ldy #0
+.loop:
+ lda [COPY_SOURCE_ADDR], y
+ beq .end
+ sta PPUDATA
+ iny
+ bne .loop
+.end:
+
+ ; enable PPU
+ jsr waitblank
+ ; show background
+ lda #%00001010
+ sta PPUMASK
+
+ ; main loop
+infin:
+ jsr waitblank
+ jsr ReadOrDownPads
+ jmp infin
+
+waitblank:
+ jsr fix_scroll
+ pha
+ bit PPUSTATUS
+.loop:
+ bit PPUSTATUS ; load A with value at location PPUSTATUS
+ bpl .loop ; if bit 7 is not set (not VBlank) keep checking
+ pla
+ rts
+
+fix_scroll:
+ ; fix scrolling
+ pha
+ bit PPUSTATUS
+ lda #0
+ sta PPUSCROLL
+ sta PPUSCROLL
+ pla
+ rts
+
+IRQ:
+ rti
+
+NMI:
+ ;
+ lda #$35
+ sta $102
+ lda #$AC
+ sta $103
+ jmp [$FFFC]
+
+nametable:
+; .incbin "bg_name_table.bin"
+; .org nametable + $3C0
+; .incbin "bg_attr_table.bin"
+palette:
+ .incbin "palette0.bin"
+; .incbin "palette1.bin"
+
+hello_world:
+ .db "HELLO WORLD!", 0
+
+ .org $0000
+ .incbin "pattern_2.bin"
diff --git a/Examples/ascii/main.asm b/Examples/ascii/main.asm
new file mode 100644
index 0000000..8c48a32
--- /dev/null
+++ b/Examples/ascii/main.asm
@@ -0,0 +1,157 @@
+ ; INES header stuff
+ .inesprg 1 ; 1 bank of PRG
+ .ineschr 1 ; 1 bank of CHR data
+ .inesmir 0 ; mirroring
+ .inesmap 0 ; we use mapper 0
+
+ .rsset $0000 ; variables
+COPY_SOURCE_ADDR .rs 2
+COPY_DEST_ADDR .rs 2
+
+ .bank 1
+ .org $FFFA ; reset vectors
+ .dw NMI
+ .dw Start
+ .dw IRQ
+
+ .bank 0
+ .org $C000 ; code starts here
+Start:
+ ; disable interrupts
+ sei
+ ; reset stack
+ ldx #$ff
+ txs
+
+ ; disable PPU
+ lda #%00000000
+ sta PPUCTRL
+ lda #%00000000
+ sta PPUMASK
+
+ jsr waitblank
+
+ ; reset sound
+ lda #0
+ sta $4000
+ sta $4001
+ sta $4002
+ sta $4003
+ sta $4004
+ sta $4005
+ sta $4006
+ sta $4007
+ sta $4009
+ sta $400A
+ sta $400C
+ sta $400D
+ sta $400E
+ sta $400F
+ sta $4010
+ sta $4011
+ sta $4012
+ sta $4013
+ lda #$0F
+ sta $4015
+ lda #$40
+ sta $4017
+ lda #0
+
+load_palette:
+ lda #LOW(palette)
+ sta <COPY_SOURCE_ADDR
+ lda #HIGH(palette)
+ sta <COPY_SOURCE_ADDR+1
+ lda #$3F
+ sta PPUADDR
+ lda #$00
+ sta PPUADDR
+ ldy #$00
+ ldx #4
+.loop:
+ lda [COPY_SOURCE_ADDR], y
+ sta PPUDATA
+ iny
+ dex
+ bne .loop
+
+ ; loading blank nametable
+clear_nametable:
+ lda PPUSTATUS
+ lda #$20
+ sta PPUADDR
+ lda #$00
+ sta PPUADDR
+ ldy #0
+ ldx #0
+ lda #$20
+.loop:
+ cpy #$C0
+ bne .noat
+ cpx #$03
+ bne .noat
+ lda #$00
+.noat:
+ sta PPUDATA
+ iny
+ bne .loop
+ inx
+ cpx #$04
+ bne .loop
+.end:
+
+ ; write HELLO WORLD
+load_text:
+ lda PPUSTATUS
+ lda #$20
+ sta PPUADDR
+ lda #$41
+ sta PPUADDR
+ lda #LOW(.hello_world)
+ sta COPY_SOURCE_ADDR
+ lda #HIGH(.hello_world)
+ sta COPY_SOURCE_ADDR+1
+ ldy #0
+.loop:
+ lda [COPY_SOURCE_ADDR], y
+ beq .end
+ sta PPUDATA
+ iny
+ jmp .loop
+.hello_world:
+ .db "HELLO WORLD!", 0
+.end:
+
+ ; enable PPU
+ jsr waitblank
+ lda #%00001010
+ sta PPUMASK
+ lda #%00000000
+ sta PPUCTRL
+main_loop:
+ jsr waitblank
+ jmp main_loop
+
+ ; VBlank wait subroutine
+waitblank:
+ bit PPUSTATUS
+ lda #0
+ sta PPUSCROLL
+ sta PPUSCROLL
+.loop:
+ lda PPUSTATUS ; load A with value at location PPUSTATUS
+ bpl .loop ; if bit 7 is not set (not VBlank) keep checking
+ rts
+
+NMI:
+ rti
+
+IRQ:
+ rti
+
+palette:
+ .incbin "palette_0.bin"
+
+ .bank 2
+ .org $0200
+ .incbin "pattern_0.bin"
diff --git a/TestImages/Images/ascii.png b/TestImages/Images/ascii.png
new file mode 100644
index 0000000..90904e9
--- /dev/null
+++ b/TestImages/Images/ascii.png
Binary files differ