From 4ede6d5adeebd1fca196b5f2cc564e11dc513f4b Mon Sep 17 00:00:00 2001 From: jeffman Date: Sat, 15 Apr 2017 13:32:25 -0400 Subject: [PATCH] Fixed YOU WON! graphics --- compiled/vwf.c | 22 ++++++++++++++++++++++ compiled/vwf.h | 1 + 2 files changed, 23 insertions(+) diff --git a/compiled/vwf.c b/compiled/vwf.c index c9e4cfc..021c3a4 100644 --- a/compiled/vwf.c +++ b/compiled/vwf.c @@ -46,6 +46,13 @@ byte reduce_bit_depth(int row, int foreground) byte print_character(byte chr, int x, int y, int font, int foreground) { + // 0x64 to 0x6C (inclusive) is YOU WON + if ((chr >= 0x64) && (chr <= 0x6C)) + { + print_special_character(chr, x, y); + return 8; + } + return print_character_with_callback(chr, x, y, font, foreground, vram, &get_tile_number_with_offset, TRUE); } @@ -54,6 +61,21 @@ byte print_character_to_ram(byte chr, int *dest, int xOffset, int font, int fore return print_character_with_callback(chr, xOffset, 0, font, foreground, dest, &get_tile_number_grid, FALSE); } +void print_special_character(byte chr, int x, int y) +{ + // Special graphics must be tile-aligned + x >>= 3; + y >>= 3; + unsigned short sourceTileIndex = chr + 0xF0 + *tile_offset; + unsigned short destTileIndex = get_tile_number(x, y) + *tile_offset; + + (*tilemap)[x + (y * 32)] = destTileIndex | *palette_mask; + (*tilemap)[x + ((y + 1) * 32)] = (destTileIndex + 32) | *palette_mask; + + cpufastset(&vram[sourceTileIndex * 8], &vram[destTileIndex * 8], 8); + cpufastset(&vram[(sourceTileIndex + 32) * 8], &vram[(destTileIndex + 32) * 8], 8); +} + byte print_character_with_callback(byte chr, int x, int y, int font, int foreground, int *dest, int (*getTileCallback)(int, int), int useTilemap) { diff --git a/compiled/vwf.h b/compiled/vwf.h index ff1777d..32d7856 100644 --- a/compiled/vwf.h +++ b/compiled/vwf.h @@ -14,6 +14,7 @@ int get_tile_number(int x, int y); int expand_bit_depth(byte row, int foreground); byte reduce_bit_depth(int row, int foreground); byte print_character(byte chr, int x, int y, int font, int foreground); +void print_special_character(byte chr, int x, int y); byte print_character_with_callback(byte chr, int x, int y, int font, int foreground, int *dest, int (*getTileCallback)(int, int), int useTilemap); byte print_character_to_ram(byte chr, int *dest, int xOffset, int font, int foreground);