From a064de86c92a27213aa483c9f23c868a9edaf3d1 Mon Sep 17 00:00:00 2001
From: Vince Weaver <vince@deater.net>
Date: Mon, 21 Jan 2013 15:23:24 -0500
Subject: [PATCH] snes: Use compressed tilemap for title

This actually makes the executable bigger for now, as
it's not actually compressing yet.
---
 tb_snes/Makefile       |  4 +--
 tb_snes/checksum.inc   |  4 +--
 tb_snes/title_screen.s | 60 +++++-------------------------------------
 3 files changed, 10 insertions(+), 58 deletions(-)

diff --git a/tb_snes/Makefile b/tb_snes/Makefile
index 942231c..cf32daa 100644
--- a/tb_snes/Makefile
+++ b/tb_snes/Makefile
@@ -23,8 +23,8 @@ level1_pal0.sprites:	graphics/level1_pal0.pcx tools/pcx_to_tiles_4bpp
 tb1_opening.tiles:	graphics/vmw_logo.pcx ./tools/pcx_to_tiles_8bpp
 	./tools/pcx_to_tiles_8bpp vmw_logo < graphics/vmw_logo.pcx > tb1_opening.tiles
 
-tb1_title.tiles:	graphics/tb1_title.pcx ./tools/pcx_to_tiles_8bpp
-	./tools/pcx_to_tiles_8bpp title_screen < graphics/tb1_title.pcx > tb1_title.tiles
+tb1_title.tiles:	graphics/tb1_title.pcx ./tools/pcx_to_compressed_tilemap_8bpp
+	./tools/pcx_to_compressed_tilemap_8bpp title_screen < graphics/tb1_title.pcx > tb1_title.tiles
 
 checksum.inc:	./tools/snes_checksum tb1_snes.sfc
 	./tools/snes_checksum < tb1_snes.sfc > checksum.inc
diff --git a/tb_snes/checksum.inc b/tb_snes/checksum.inc
index 3071784..87f1eb6 100644
--- a/tb_snes/checksum.inc
+++ b/tb_snes/checksum.inc
@@ -1,2 +1,2 @@
-	.word	$cc93		; Complement of checksum
-	.word	$336c		; Unsigned 16-bit sum of ROM
+	.word	$2797		; Complement of checksum
+	.word	$d868		; Unsigned 16-bit sum of ROM
diff --git a/tb_snes/title_screen.s b/tb_snes/title_screen.s
index 9137613..e5f5101 100644
--- a/tb_snes/title_screen.s
+++ b/tb_snes/title_screen.s
@@ -90,37 +90,8 @@ copy_tile_data:
 	bne     copy_tile_data
 
 
-	;=====================
-	; Load TB_FONT Data
-	;=====================
-
-	; replace with DMA!
-
-
-;	rep     #$20            ; set accumulator/mem to 16bit
-;.a16
-;.i16
-;	lda     #$6000          ;
-;        sta     $2116           ; set adddress for VRAM read/write
-;				; multiply by 2, so 0xc000
-;
- ;       ldy     #$600		; Copy 96 tiles, which are 32 bytes each
-;                                ;  8x8 tile with 4bpp (four bits per pixel)
-;				; in 2-byte chunks, so
-;				; (96*32)/2 = 1536 = 0x600
-;
- ;       ldx     #$0000
-copy_font_data:
-;        lda     f:tb_font, x
- ;       sta     $2118           ; write the data
-  ;      inx                     ; increment by 2 (16-bits)
-   ;     inx
-    ;    dey                     ; decrement counter
-     ;   bne     copy_font_data
-
-
 	;===================================
-	; clear background to linear tilemap
+	; Load Tile Map
 	;===================================
 .a16
 .i16
@@ -130,38 +101,19 @@ clear_linear_tilemap:
 	lda	#$f000		; we set tilemap to be at VRAM 0xf000 earlier
 	sta	$2116
 
-        ldy     #$0000          ; clear counters
-				; store to VRAM
-                                ; the bottom 8 bits is the tile to use
-                                ; the top 8 bits is vhopppcc
-                                ; vert flip, horiz flip o=priority
-                                ; p = palette, c=top bits of tile#
-
-	; 8-bit color so ppp is 0
-	; and we have a linear tilemap
-	; 0000 0000
-	; vhop ppcc cccc cccc
-
-.a16
-.i16
+        ldx	#$0000          ; clear offset
 
 fill_screen_loop:
 
-	tya
-
+	lda	f:title_screen_tilemap,X
         sta     $2118
+	inx
+	inx
 
-	iny
-
-	cpy	#$0380			; 32x28 = 896 = 0x380
-
+	cpx	#$0700			; 32x28 = 896 * 2 = 0x700
 	bne     fill_screen_loop
 
 
-
-
-        ; Write String to Background
-
 setup_video:
 
         sep     #$20            ; set accumulator to 8 bit