# HG changeset patch # User Mike Pavone # Date 1378280512 25200 # Node ID 997690aa05076de5413e545ea59d76d685b80b79 # Parent a049de420cc16318198bb53060a827cda07d60b0 Improve method for choosing line palette entries. Read number of global and dynamic colors from image binary. Go back to doing a word, longword, word pattern of writes for turning off display, doing DMA and turning it back on again to make things work correctly on the real hardware. diff -r a049de420cc1 -r 997690aa0507 genesis.s68 --- a/genesis.s68 Tue Sep 03 09:49:29 2013 -0700 +++ b/genesis.s68 Wed Sep 04 00:41:52 2013 -0700 @@ -87,7 +87,7 @@ PalAddress equ ButtonStateNew+2 CRAMXferSizeCmd equ $9308 -CRAMDMACmd equ $C0100080 +CRAMDMACmd equ $C0000080 StaticColors equ 8 USE_HINT equ 0 @@ -141,10 +141,17 @@ dbra d2, WriteNamesY move.l #$C0000000, (a5) ;setup writes to CRAM - moveq #(StaticColors-1), d0 ;copy first 12 colors (static pallete) + move.b (a0)+, d0 ;Number of static colors + move.b (a0)+, d1 ;Number of dynamic colors + ext.w d0 + move.w d0, -(a7) + beq NoStatic + subq.w #1, d0 CopyColors: move.w (a0)+, (a4) dbra d0, CopyColors + move.w (a7)+, d0 +NoStatic: move.l a0, (PalAddress).w @@ -172,11 +179,16 @@ moveq #0, d3 ;bsr ChangeFrameBigSprite - + move.w d0, d5 + ext.l d5 + moveq #17, d2 + lsl.l d2, d5 + or.l #CRAMDMACmd, d5 ;setup DMA command word - move.l #CRAMDMACmd, d5 ;setup DMA command word - - move.w #CRAMXferSizeCmd, (a5) ;set Transfer length + ext.w d1 + beq NoDynamic + or.w #$9300, d1 + move.w d1, (a5) ;set Transfer length move.w #$9400, (a5) move.w #$8114, d6 @@ -209,12 +221,12 @@ HINT: - ;move.w d6, (a5) - ;move.l d5, (a5) ;start DMA - ;move.w d7, (a5) - move.l d6, (a5) - move.l d7, (a5) - move.w #CRAMXferSizeCmd, (a5) ;set Transfer length + move.w d6, (a5) + move.l d5, (a5) ;start DMA + move.w d7, (a5) + ;move.l d6, (a5) + ;move.l d7, (a5) + move.w d1, (a5) ;set Transfer length move.w #$9400, (a5) if USE_HINT @@ -225,8 +237,13 @@ beq WaitTop bra LineDone - +NoDynamic: + move.w #$8174, (a5) + move #$2300, SR +.loop + bra .loop VINT: + move.w d1, -(a7) if USE_HINT move.w #$8144, (a5) endif @@ -253,16 +270,17 @@ ;move.l d5, (a5) ;do DMA for first line - move.w #CRAMXferSizeCmd, (a5) ;set Transfer length + move.w (a7)+, d1 + move.w d1, (a5) ;set Transfer length move.w #$9400, (a5) move.w #$8114, d6 ;VDP commands to turn screen on and off during HBlank - swap d6 - swap d5 - move.w d5, d6 - swap d5 - move.w d5, d7 - swap d7 + ;swap d6 + ;swap d5 + ;move.w d5, d6 + ;swap d5 + ;move.w d5, d7 + ;swap d7 move.w #$8174, d7 if USE_HINT move.w d7, (a5) diff -r a049de420cc1 -r 997690aa0507 img2tiles.py --- a/img2tiles.py Tue Sep 03 09:49:29 2013 -0700 +++ b/img2tiles.py Wed Sep 04 00:41:52 2013 -0700 @@ -92,9 +92,17 @@ #linecolors = get_color_info_error(pixels, xrange(linestart, linestart+width), trans_thresh, glob_pal) linecolors = get_color_info_both(pixels, xrange(linestart, linestart+width), trans_thresh, glob_pal) line_pal = {} - for idx in xrange(0, min(max_line, len(linecolors))): - (count, color) = linecolors[idx] - line_pal[color] = idx + max_global + while len(line_pal) < max_line and len(linecolors): + (score, color) = linecolors[0] + line_pal[color] = len(line_pal) + max_global + if len(line_pal) < max_line: + combo = dict(glob_pal) + for color in line_pal: + combo[color] = line_pal[color] + linecolors = get_color_info_both(pixels, xrange(linestart, linestart+width), trans_thresh, combo) + #for idx in xrange(0, min(max_line, len(linecolors))): + # (count, color) = linecolors[idx] + # line_pal[color] = idx + max_global line_pals.append(line_pal) return (glob_pal, line_pals, max_global, max_line) @@ -189,6 +197,8 @@ def add_pal_entries(tiles, pal): (global_pal, line_pals, max_global, max_line) = pal + tiles.append(max_global) + tiles.append(max_line) pal_list = [(0, 0, 0)] * max_global for entry in global_pal: pal_list[global_pal[entry]] = entry @@ -216,7 +226,7 @@ dynamic_colors = 8 if len(argv) > 3: static_colors = int(argv[3]) - dynamic_colors = min(dynamic_colors, 16-static_colors) + dynamic_colors = 16-static_colors if len(argv) > 4: dynamic_colors = int(argv[4]) if dynamic_colors + static_colors > 16: