shithub: pokered

Download patch

ref: c744e3b4a82f7af7b315787bfc00a333b9c0b248
parent: bfef13bfa25e3d4300d71bbf4818c249bc498f80
author: Bryan Bishop <kanzure@gmail.com>
date: Sat Jan 14 12:45:55 EST 2012

extract and include blockset data

extract_tileblocks also has the ability to output asm, but the output
seems like it would be too much for rgbasm to handle. Instead of
cluttering up common.asm, I am opting to place the data in binary
data files under gfx/blocksets/ in .bst files.

Every 16 bytes is a separate block in the blockset. Each byte is
referencing a tile id from the tileset graphics in gfx/tilesets/.

hg-commit-id: 0540eff0f081


diff: cannot open b/gfx/blocksets//null: file does not exist: 'b/gfx/blocksets//null'
--- a/common.asm
+++ b/common.asm
@@ -34920,31 +34920,31 @@
 Tset00_GFX:
     INCBIN "gfx/tilesets/00.2bpp"
 Tset00_Block:
-	INCBIN "baserom.gbc",$645E0,$64DE0-$645E0
+    INCBIN "gfx/blocksets/00.bst"
 Tset01_GFX:
     INCBIN "gfx/tilesets/01.2bpp"
 Tset01_Block:
-	INCBIN "baserom.gbc",$65270,$653A0-$65270
+    INCBIN "gfx/blocksets/01.bst"
 Tset08_GFX:
     INCBIN "gfx/tilesets/08.2bpp"
 Tset08_Block:
-	INCBIN "baserom.gbc",$65980,$65BB0-$65980
+    INCBIN "gfx/blocksets/08.bst"
 Tset13_GFX:
     INCBIN "gfx/tilesets/13.2bpp"
 Tset13_Block:
-	INCBIN "baserom.gbc",$66190,$66610-$66190
+    INCBIN "gfx/blocksets/13.bst"
 Tset0E_GFX:
     INCBIN "gfx/tilesets/0e.2bpp"
 Tset0E_Block:
-	INCBIN "baserom.gbc",$66BF0,$66D60-$66BF0
+    INCBIN "gfx/blocksets/0e.bst"
 Tset10_GFX:
     INCBIN "gfx/tilesets/10.2bpp"
 Tset10_Block:
-	INCBIN "baserom.gbc",$67350,$676F0-$67350
+    INCBIN "gfx/blocksets/10.bst"
 Tset17_GFX:
     INCBIN "gfx/tilesets/17.2bpp"
 Tset17_Block:
-	INCBIN "baserom.gbc",$67B50,$68000-$67B50
+    INCBIN "gfx/blocksets/17.bst"
 
 SECTION "bank1A",DATA,BANK[$1A]
 
@@ -34988,23 +34988,23 @@
 Tset05_GFX:
     INCBIN "gfx/tilesets/05.2bpp"
 Tset05_Block:
-	INCBIN "baserom.gbc",$6867F,$68DBF-$6867F
+    INCBIN "gfx/blocksets/05.bst"
 Tset02_GFX:
     INCBIN "gfx/tilesets/02.2bpp"
 Tset02_Block:
-	INCBIN "baserom.gbc",$693BF,$6960F-$693BF
+    INCBIN "gfx/blocksets/02.bst"
 Tset09_GFX:
     INCBIN "gfx/tilesets/09.2bpp"
 Tset09_Block:
-	INCBIN "baserom.gbc",$69BFF,$6A3FF-$69BFF
+    INCBIN "gfx/blocksets/09.bst"
 Tset03_GFX:
     INCBIN "gfx/tilesets/03.2bpp"
 Tset03_Block:
-	INCBIN "baserom.gbc",$6A9FF,$6B1FF-$6A9FF
+    INCBIN "gfx/blocksets/03.bst"
 Tset16_GFX:
     INCBIN "gfx/tilesets/16.2bpp"
 Tset16_Block:
-	INCBIN "baserom.gbc",$6B7FF,$6C000-$6B7FF
+    INCBIN "gfx/blocksets/16.bst"
 
 SECTION "bank1B",DATA,BANK[$1B]
 
@@ -35011,31 +35011,31 @@
 Tset0F_GFX:
     INCBIN "gfx/tilesets/0f.2bpp"
 Tset0F_Block:
-	INCBIN "baserom.gbc",$6C5C0,$6CCA0-$6C5C0
+    INCBIN "gfx/blocksets/0f.bst"
 Tset11_GFX:
     INCBIN "gfx/tilesets/11.2bpp"
 Tset11_Block:
-	INCBIN "baserom.gbc",$6D0C0,$6D8C0-$6D0C0
+    INCBIN "gfx/blocksets/11.bst"
 Tset12_GFX:
     INCBIN "gfx/tilesets/12.2bpp"
 Tset12_Block:
-	INCBIN "baserom.gbc",$6DEA0,$6E390-$6DEA0
+    INCBIN "gfx/blocksets/12.bst"
 Tset0D_GFX:
     INCBIN "gfx/tilesets/0d.2bpp"
 Tset0D_Block:
-	INCBIN "baserom.gbc",$6E930,$6ED10-$6E930
+    INCBIN "gfx/blocksets/0d.bst"
 Tset14_GFX:
     INCBIN "gfx/tilesets/14.2bpp"
 Tset14_Block:
-	INCBIN "baserom.gbc",$6F2D0,$6F670-$6F2D0
+    INCBIN "gfx/blocksets/14.bst"
 Tset15_GFX:
     INCBIN "gfx/tilesets/15.2bpp"
 Tset15_Block:
-	INCBIN "baserom.gbc",$6FB20,$6FD60-$6FB20
+    INCBIN "gfx/blocksets/15.bst"
 Tset0B_GFX:
     INCBIN "gfx/tilesets/0b.2bpp"
 Tset0B_Block:
-	INCBIN "baserom.gbc",$6FEF0,$70000-$6FEF0
+    INCBIN "gfx/blocksets/0b.bst"
 
 SECTION "bank1C",DATA,BANK[$1C]
 
--- /dev/null
+++ b/extras/extract_tileblocks.py
@@ -1,0 +1,95 @@
+#!/usr/bin/python
+#author: Bryan Bishop <kanzure@gmail.com>
+#date: 2012-01-14
+#split out blocksets into binary data files
+# There's also code here to spit out asm for each blockset,
+# but it's too many lines and will probably crash rgbasm.
+
+import sys
+import extract_maps
+extract_maps.load_rom()
+spacing = "    "
+
+tileblocks = {
+"Tset00_Block": [0x645E0, 0x64DE0, ""],
+"Tset01_Block": [0x65270, 0x653A0, ""],
+"Tset02_Block": [0x693BF, 0x6960F, ""],
+"Tset03_Block": [0x6A9FF, 0x6B1FF, ""],
+"Tset05_Block": [0x6867F, 0x68DBF, ""],
+"Tset08_Block": [0x65980, 0x65BB0, ""],
+"Tset09_Block": [0x69BFF, 0x6A3FF, ""],
+"Tset0B_Block": [0x6FEF0, 0x70000, ""],
+"Tset0D_Block": [0x6E930, 0x6ED10, ""],
+"Tset0E_Block": [0x66BF0, 0x66D60, ""],
+"Tset0F_Block": [0x6C5C0, 0x6CCA0, ""],
+"Tset10_Block": [0x67350, 0x676F0, ""],
+"Tset13_Block": [0x66190, 0x66610, ""],
+"Tset11_Block": [0x6D0C0, 0x6D8C0, ""],
+"Tset12_Block": [0x6DEA0, 0x6E390, ""],
+"Tset14_Block": [0x6F2D0, 0x6F670, ""],
+"Tset15_Block": [0x6FB20, 0x6FD60, ""],
+"Tset16_Block": [0x6B7FF, 0x6C000, ""],
+"Tset17_Block": [0x67B50, 0x68000, ""],
+}
+
+#10:02 <+sawakita> each block is composed by 4x4 tiles
+#10:03 <+sawakita> so you can see a blockset as a list of 16-bytes long arrays
+#10:07 <+sawakita> 4 bytes for each row of the block, left-to-right, top-to-down
+#10:08 <+sawakita> so first byte is top-left tile
+#10:08 <+kanzure> top-left tile byte is a tile id?
+#10:08 <+sawakita> exactly
+#10:09 <+kanzure> what does a tile id reference
+#10:10 <+sawakita> tile ID $00 is the first tile of the tileset's graphics (first 16-bytes, since gfx are 2bpp)
+
+output = ""
+for tileblock_id in tileblocks.keys():
+    tileblock = tileblocks[tileblock_id]
+    start_address = tileblock[0]
+    end_address = tileblock[1]
+    block_count = (end_address - start_address) / 16
+    main_data = extract_maps.rom[start_address:end_address]
+    
+    blockset_id = int(tileblock_id[4:6], 16)
+    
+    output = "; "
+    output += tileblock_id + " - " + str(block_count) + " blocks (" + hex(start_address) + " to " + hex(end_address) + ")\n"
+    #print tileblock_id + " has " + str(block_count) + " block tiles."
+    for block_id in range(0, block_count):
+        start_address2 = start_address + (16 * block_id)
+        end_address2 = start_address + (16 * block_id) + 16
+        data = extract_maps.rom[start_address2:end_address2]
+    
+        output += spacing + "; block " + str(block_id + 1) + " on " + tileblock_id + "\n"
+        
+        #output += spacing + spacing + "db $%.2x" % (ord(data[0]))
+        #for data_bit in range(1,15):
+        #    output += ", $%.2x" % (ord(data[data_bit]))
+        #output += ", $%.2x" % (ord(data[15]))
+        #output += "\n"
+
+        for row_id in range(0,4):
+            subdata = data[row_id * 4:row_id * 4 + 4]
+            subdata2 = [ord(subdata[0]), ord(subdata[1]), ord(subdata[2]), ord(subdata[3])]
+
+            output += spacing + spacing + " ; row " + str(row_id + 1) + "\n"
+            output += spacing + spacing + spacing + "db $%.2x, $%.2x, $%.2x, $%.2x\n" % (subdata2[0], subdata2[1], subdata2[2], subdata2[3])
+    
+    fh = open("../gfx/blocksets/%.2x.bst" % (blockset_id), "w")
+    fh.write(main_data)
+    fh.close()
+
+    print output
+
+"""
+Tset00_Block:
+    ; block 1
+        ; row 1
+            db 0, 0, 0, 0
+        ; row 2
+            db 0, 0, 0, 0
+        ; row 3
+            db 0, 0, 0, 0
+        ; row 4
+            db 0, 0, 0, 0
+"""
+
--- /dev/null
+++ b/gfx/blocksets/00.bst
@@ -1,0 +1,71 @@
+
+
+()KKK
+
+
+O####9#########9#%&N	
+
+()O*+:;<<<<<<<<<<<<<<HI77XY77,,,,,,,,,,,,77779999999999FG99VW#
+
+#,,,,,,,,,,,,,,,,RRRRRRRRRRRRRRRRSS88SSSSSS	88@A@APQPQ@A@APQPQ%&
+
+"""
+
+
+N"/?"""""
+
+
+
+
+
+()"""
+O*+*+:;:;*+*+:;:;*+:;*+*+:;:;*+:;*+*+:;:;*+*+:;:;*+:;*+*+:;:;*+:;*+:;*+:;*+:;*+:;9999999999996777##UU####UU######9###@A@APQPQ33332223333TTT3333LSSSZZ\SSSMZZ]!########!##    ########    '''''6776777$$$$774$7774##!########!########''''''''$$$$$$$$7'57$533,,,,,,,,,,,,74<<%&
+"N9999999999999999@A-.PQ=>@A,,PQ,,@A@APQPQ,,-.,,=>-.,,=>,,@A@APQPQ,,-.,,=>@A,,PQ,,@A@APQPQ,,@A,,PQ
+
+
+KKKKKKN####9#######9###	
+KK
+KKKK
+
+9$$$$$%&
+"\"N
+
+()]
+
+"O#'''''*+,,:;,,,,,,,,,,,,,,,,,,*+,,:;,,,,@A,,PQ,,@A74PQ##!######!   !########   !'999'999'999'99999
$99
$99
$99
$   !######!##!   ########!'999'999'99967<<99
$99
$99
$6774,,,,,,,,@A,,PQ,,,,*+,,:;,,*+,,:;*+,,:;,,*+,,:;,,,,*+,,:;*+*+:;:;*+,,:;,,*+*+:;:;*+*+:;:;,,,,,,,,,,,,,,,,*+*+:;:;,,*+,,:;,,,,,,,,<<<<<<<<<<<<<<<<[[[[[[[[[[[[[[[[99999999FGUUVW77777777',,,',,,',,,',,,,,$,,$,,$,,$',,,',,,',,,6777,,$,,$,,$7774999999999999<<67!##!############!##!####UU####UU,,@A,,PQ-.@A=>PQ99999999*+*+:;:;*+*+:;:;*+,,:;,,*+*+:;:;,,*+,,:;TTTT22222T2T2T2T*+33:;*+:;
+
+
+KKK
+
+
+KKK
+
+
+KKK
+
+
+KKK33*+:;*+:;*+*+:;:;@A@APQPQ,,,,,,,,@A,,PQ,,@A,,PQ,,,,@A,,PQ,,@A,,PQ,,,,,,,,@A@APQPQ$$$$HI4$XY74""""
+
+
+KKKBCKJJO
+
+
+KKKDEKJJO,,,,,,,,,,,,88%&""88""()99999999UUUU11110000000000FG00VW,0,00,0,,0,00,0,0909909009099090
+
+
+KKKKN
+
+
+
+KKKKKKKK
+
+
+KKKKKKO
+
+
+
+KKKK
+
+
+
+KKKK
\ No newline at end of file
binary files /dev/null b/gfx/blocksets/01.bst differ
binary files /dev/null b/gfx/blocksets/02.bst differ
binary files /dev/null b/gfx/blocksets/03.bst differ
binary files /dev/null b/gfx/blocksets/05.bst differ
binary files /dev/null b/gfx/blocksets/08.bst differ
binary files /dev/null b/gfx/blocksets/09.bst differ
binary files /dev/null b/gfx/blocksets/0b.bst differ
binary files /dev/null b/gfx/blocksets/0d.bst differ
binary files /dev/null b/gfx/blocksets/0e.bst differ
--- /dev/null
+++ b/gfx/blocksets/0f.bst
@@ -1,0 +1,149 @@
+GGGGGGGGGGGGGGGG	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+
	
+	
+	
+	
+	
+	
+
!  #1003=>=>	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+""""""""""""""""	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+-***+,::+,+,****::::***.::+,+,+,()()89898989HIHI+,+,+,+,'/7?=>+,+,+,+,    0000+,+,-***;:::****::::+,+,***.:::<'/7?=>	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+'/	
+7?=>	
+'/7?	
+=>
\ No newline at end of file
binary files /dev/null b/gfx/blocksets/10.bst differ
binary files /dev/null b/gfx/blocksets/11.bst differ
binary files /dev/null b/gfx/blocksets/12.bst differ
binary files /dev/null b/gfx/blocksets/13.bst differ
binary files /dev/null b/gfx/blocksets/14.bst differ
binary files /dev/null b/gfx/blocksets/15.bst differ
binary files /dev/null b/gfx/blocksets/16.bst differ
binary files /dev/null b/gfx/blocksets/17.bst differ