From 8300476140bf66a84fb5340f40bf1a67e44dccd6 Mon Sep 17 00:00:00 2001 From: Gyorgy Szombathelyi Date: Fri, 28 Jun 2019 19:32:24 +0200 Subject: [PATCH] [Gameboy] Sprite fixes from brNX --- cores/gameboy/sprite.v | 6 +++--- cores/gameboy/sprites.v | 26 +++++++------------------- cores/gameboy/video.v | 3 +-- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/cores/gameboy/sprite.v b/cores/gameboy/sprite.v index ee0ea05..ebfe74f 100644 --- a/cores/gameboy/sprite.v +++ b/cores/gameboy/sprite.v @@ -22,6 +22,8 @@ module sprite ( input clk, input size16, + input isGBC, + input [7:0] sprite_index, input [7:0] v_cnt, input [7:0] h_cnt, @@ -41,7 +43,6 @@ module sprite ( //gbc output [2:0] pixel_cmap_gbc, - output tile_vbank, input oam_wr, input [1:0] oam_addr, @@ -51,7 +52,7 @@ module sprite ( // x position for priority detection. Invisible sprites are far to the right and // have minimum priority -assign x = v_visible?x_pos:8'hff; +assign x = v_visible?isGBC?sprite_index:x_pos:8'hff; // register used to store pixel data for current line reg [7:0] data0; @@ -88,7 +89,6 @@ assign pixel_cmap = flags[4]; assign pixel_prio = flags[7]; assign pixel_cmap_gbc = flags[2:0]; -assign tile_vbank = flags[3]; reg [7:0] y_pos; reg [7:0] x_pos; diff --git a/cores/gameboy/sprites.v b/cores/gameboy/sprites.v index 6eec371..9797c2c 100644 --- a/cores/gameboy/sprites.v +++ b/cores/gameboy/sprites.v @@ -23,6 +23,7 @@ module sprites ( input clk, input clk_reg, input size16, + input isGBC, // pixel position input which the current pixel is generated for input [7:0] v_cnt, @@ -36,8 +37,7 @@ module sprites ( //gbc output [2:0] pixel_cmap_gbc, - output tile_vbank, - + input sort, input [3:0] index, // index of sprite which video wants to read data for output [10:0] addr, @@ -82,7 +82,8 @@ assign oam_do = sprite_oam_do[oam_addr[7:2]]; // address where the sprite wants to read data from wire [5:0] sprite_idx_array [SPRITES-1:0]; -wire [5:0] prio_index = sprite_idx_array[index]; +wire [5:0] padded_index = {2'd0,index}; +wire [5:0] prio_index = sprite_idx_array[padded_index]; assign addr = sprite_addr[prio_index]; //gbc @@ -98,6 +99,9 @@ for(i=0;i