Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2018-01-16 18:18:30

tobiasvl
Member
From: Norway
Registered: 2017-10-19
Posts: 26

ASM: Sprites show up in BGB/Gambatte, but not on real hardware

Hey! I have a strange problem.

I'm making a game, and it works perfectly so far. I use several sprites, and they work fine. However, I have a problem with some specific sprites on my title screen. They show up in BGB and Gambatte, which I use for testing, but not on a real Game Boy.

I put 10 sprites on the title screen to spell out "PRESS START", and I used sprites to easily get them to blink. Yes, I know I can use BG tiles instead of sprites here and blink them during Hblank, but this problem is nagging me. There are 10 sprites total, so although they're all on the same scanline, that shouldn't be a problem. I do not use DMA.

Here's my full code (my actual program is much longer of course, but I removed everything extraneous to eliminate potential bugs), with the line where I start copying to OAM attributes highlighted:

https://gist.github.com/tobiasvl/59f810 … s-asm-L109

I've also tried halting between every OAM write just in case.

The ROM can be downloaded here (assembled using RGBDS from the above files plus the regular hardware.inc): http://thespug.net/stuff/rom.gb

Does anyone know what the problem is?


Discord: tobiasvl#6844 | GitHub: tobiasvl

Offline

 

#2 2018-01-16 19:57:27

ISSOtm
Member
From: Somewhere in Echo RAM
Registered: 2017-04-18
Posts: 160
Website

Re: ASM: Sprites show up in BGB/Gambatte, but not on real hardware

Your code is correct, the sprites are loaded into OAM, but you should add this to your ROM ;P

Code:

ld a, $E4
ld [rOBP0], a

Furthermore, the sprites didn't show up in BGB for me.


The French Lord Of Laziness.
Legend of Zelda and Undertale fan, I also tend to break Pokémon R/B/Y a little too much.

Twitter | Me on GCL | Discord : ISSOtm#9015 | Skype : isso.tm (I don't login anymore)

Offline

 

#3 2018-01-17 03:56:49

tobiasvl
Member
From: Norway
Registered: 2017-10-19
Posts: 26

Re: ASM: Sprites show up in BGB/Gambatte, but not on real hardware

Thanks, nice catch. It had to be something simple.

I guess the reason they show up for me and not for you (and not on real hardware) is that rOBP0 contains random initialized values that made it seem like a pattern. It's consistent though; it never shows up for me on real hardware, and always in BGB. I don't know how BGB randomizes its memory, but I see I'm on 1.5.4, so if you're on 1.5.6 the behavior might have changed. (tbsp confirmed that it showed up for him in BGB too.) For me, rOBP0 is set to $FF in BGB here.

Last edited by tobiasvl (2018-01-17 04:09:03)


Discord: tobiasvl#6844 | GitHub: tobiasvl

Offline

 

#4 2018-01-17 04:38:34

gekkio
Member
Registered: 2016-05-29
Posts: 16

Re: ASM: Sprites show up in BGB/Gambatte, but not on real hardware

Yeah, at least on DMG/SGB the BGP/OBP0/OBP1 registers are not initialized in hardware to any default value. The boot ROM sets BGP so it doesn't matter for that register, but with the others you can see pretty much anything there.
The registers can retain their values for a couple of seconds even with the power off, so if you switch cartridges fast enough, the previous game that you played can affect the values smile
Also applies to flash carts that can reset the system without you touching the power switch (e.g. Everdrive).

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson