Skip to content

Commit 46ae438

Browse files
committed
Fix solid line under every sprite.
1 parent f3dc2a5 commit 46ae438

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
- PPU: Implemented scanline rendering.
1818
- Renders contents of CHR ROM
1919
- Renders background.
20-
- Preliminar sprite rendering.
20+
- Sprite rendering.
21+
- vertical mirror: implemented
22+
- horizontal mirror: missing
23+
- 8x16 sprites: missing
2124
- APU: 0%
2225
- MMU: 0%
2326
- UI

src/debugger/controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (dbg *GuiDebugger) DrawDebugger(emulator *nes.Nes) {
9898
//scale := 3
9999
drawASM(emulator)
100100
//drawPalettes(emulator, scale, DEBUG_X_OFFSET, 40+15*20, debuggerGUI)
101-
//drawCHR(emulator, 2, DEBUG_X_OFFSET, 40+15*20+50, font, debuggerGUI)
101+
dbg.drawCHR(emulator, 2, DEBUG_X_OFFSET, 40+15*20+50)
102102

103103
if emulator.Debugger().DebugPPU {
104104
drawPPUDebugger(emulator)
@@ -194,7 +194,7 @@ func drawColorWatch(coordX int, coordY int, width int, height int, color color.C
194194
raylib.DrawRectangle(coordX, coordY, width, height, pixelColor2RaylibColor(color))
195195
}
196196

197-
func drawCHR(console *nes.Nes, scale int, xOffset int, yOffset int, font *raylib.Font, debuggerGUI *GuiDebugger) {
197+
func (dbg *GuiDebugger) drawCHR(console *nes.Nes, scale int, xOffset int, yOffset int) {
198198
drawIndexes := false
199199

200200
if raylib.IsKeyDown(raylib.KeyZero) {
@@ -207,7 +207,7 @@ func drawCHR(console *nes.Nes, scale int, xOffset int, yOffset int, font *raylib
207207
const BorderWidth = 5
208208
nextOffsetY := yOffset
209209
for patternTableIdx := 0; patternTableIdx < 2; patternTableIdx++ {
210-
decodedPatternTable := console.Debugger().PatternTable(byte(patternTableIdx), debuggerGUI.chrPaletteSelector)
210+
decodedPatternTable := console.Debugger().PatternTable(byte(patternTableIdx), dbg.chrPaletteSelector)
211211
yOffset = nextOffsetY
212212

213213
for x := 0; x < decodedPatternTable.Bounds().Max.X; x++ {

src/nes/ppu/ppu.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ func (ppu *P2c02) ResetNmi() {
261261
*/
262262
func (ppu *P2c02) GetRGBColor(palette byte, colorIndex byte) color.RGBA {
263263
paletteColor := ppu.GetPaletteColor(palette, colorIndex)
264-
//paletteColor := 1
265264
return color.RGBA{
266265
R: SystemPalette[paletteColor][0],
267266
G: SystemPalette[paletteColor][1],

src/nes/ppu/render.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func (ppu *P2c02) finalPixelComposition() {
205205

206206
var fgPixel byte
207207
var fgPalette byte
208-
//var fgPriority byte
208+
//var fgPriority byte //todo implement priority
209209
if ppu.PpuMask.showSpritesEnabled() {
210210
for i := byte(0); i < ppu.spriteScanlineCount; i++ {
211211
if ppu.oamDataScanline[i].x > 0 {
@@ -300,8 +300,8 @@ func (ppu *P2c02) fetchSpriteShifters() {
300300
if ppu.PpuControl.SpriteSize == PPU_CONTROL_SPRITE_SIZE_8 {
301301
if !object.isFlippedVertically() {
302302
spritePatternAddressLow = types.Address(ppu.PpuControl.SpritePatternTableAddress) << 12
303-
spritePatternAddressLow |= types.Address(object.tileId) << 4 // Multiply ID per 16 (16 bytes per tile)
304-
spritePatternAddressLow |= types.Address(ppu.currentScanline - Scanline(object.y)) // Which tile line we want
303+
spritePatternAddressLow |= types.Address(object.tileId) << 4 // Multiply ID per 16 (16 bytes per tile)
304+
spritePatternAddressLow |= types.Address(ppu.currentScanline - Scanline(object.y) - 1) // Which tile line we want
305305
} else {
306306
// TODO implement vertical flip
307307
}

0 commit comments

Comments
 (0)