Kosmity Atakujo

A place where you can keep others updated about your NES-related projects through screenshots, videos or information in general.

Moderator: Moderators

sdm2
Posts: 46
Joined: Wed Feb 05, 2020 12:59 pm
Location: Poland

Re: Kosmity Atakujo

Post by sdm2 » Mon Dec 07, 2020 2:45 am

I know this, but I don't know why only on Nestopia. On FCEU, Mesen, Nintendulator and real Hardware OK.

Unfortunately, there are a lot of things that I do wrong, but I learn something all the time.
Pokun wrote:
Sun Dec 06, 2020 3:53 pm
You seldom seem to initialize the memory in your games. This last one is especially bad as both sprites and backgrounds are randomly corrupt.



Image
Here is the title screen scrolling up with lots of garbage on screen.

Pokun
Posts: 1761
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Kosmity Atakujo

Post by Pokun » Mon Dec 07, 2020 8:55 am

The screenshot above is taken in Mesen, and it has garbage as you can see.
Make sure to enable random values for the default power-on state of RAM and other registers. In Mesen this is found in the Emulation -> Advanced options. There you also find a lot of other things you may want to enable for more strict emulation.

FCEUX, Nintendulator NRS and other emulators also has similar options, and you usually have to enable the randomization manually, as the default is often to initialize everything to 0.

It's strange that it works on real hardware, my Famicom always displays garbage if I don't clear the screen at least. I haven't tried your games on my Famicom though.


Basically you need to initialize all RAM and VRAM (but not OAM) and any hardware register that matters except the sound registers, since the hardware disables sound at reset. Though I usually disable sound manually as well so I can do a soft-reset without getting glitchy sound.

sdm2
Posts: 46
Joined: Wed Feb 05, 2020 12:59 pm
Location: Poland

Re: Kosmity Atakujo

Post by sdm2 » Mon Dec 07, 2020 9:25 am

This is interesting because I did not know that such errors could occur. I test everything on real hardware and I've never had such bugs. I was surprised that the problem is only for me on Nestopia (only that games).


The RESET code I had used:

Code: Select all

RESET:

	STA $E000				;Disable IRQs.

	LDA #$01
	STA $A000				;Horizontal mirroring

	LDA #%10000000				;enable WRAM
	STA $A001

	SEI
	CLD
 
	LDA #$40
	STA $4017				;Wyłącz APU IRQ.
 
	LDX #$FF
	TXS
 
	INX
	STX $2000
	STX $2001

	lda #7
	sta $8000
	lda #1					;#nrbankuA000
	sta $8001

	lda #6
	sta $8000
	lda #0					;#nrbanku8000
	sta $8001

VBlankWait1:					;2x waitblanki aby 'rozgrzac PPU

	BIT $2002
	BPL VBlankWait1

VBlankWait2:

	BIT $2002
	BPL VBlankWait2

	TXA

ClearMemory:

	STA $0000, x
	STA $0100, x
	STA $0200, x
	STA $0300, x
	STA $0400, x
	STA $0500, x
	STA $0600, x
	STA $0700, x

	STA $6000, x
	STA $6100, x
	STA $6200, x
	STA $6300, x
	STA $6400, x
	STA $6500, x
	STA $6600, x
	STA $6700, x
	STA $6800, x
	STA $6900, x
	STA $6A00, x
	STA $6B00, x
	STA $6C00, x
	STA $6D00, x
	STA $6E00, x
	STA $6F00, x
	STA $7000, x
	STA $7100, x
	STA $7200, x
	STA $7300, x
	STA $7400, x
	STA $7500, x
	STA $7600, x
	STA $7700, x
	STA $7800, x
	STA $7900, x
	STA $7A00, x
	STA $7B00, x
	STA $7C00, x
	STA $7D00, x
	STA $7E00, x
	STA $7F00, x

	INX
	BNE ClearMemory

EDIT:

I changed the RESET code a bit and after selecting these "not recomended" functions in MESEN there are no errors (I think?). viewtopic.php?t=16781

Changed RESET code in the file "demo2.nes"

EDIT2:
I reset the second NT ($ 2800) - now it seems ok - "demo3.nes"

Code: Select all

RESET:

	STA $E000				;Disable IRQs.

	ldx #$07
mmc3initloop:
	stx $8000
	lda mmc3tbl,x
	sta $8001
	dex
	bpl mmc3initloop
	sta $A000

	LDA #$01
	STA $A000				;Horizontal mirroring

	LDA #%10000000				;enable WRAM (dziala, ale czy poprawnie?)
	STA $A001

	SEI
	CLD
 
	LDA #$40
	STA $4017				;Wyłącz APU IRQ.
 
	LDX #$FF
	TXS					;Wrzuć FF jako pointer Stosu
 
	INX
	STX $2000
	STX $2001

	lda #7
	sta $8000
	lda #1					;#nrbankuA000
	sta $8001

	lda #6
	sta $8000
	lda #0					;#nrbanku8000
	sta $8001

VBlankWait1:					;dwa waitblanki aby 'rozgrzac PPU

	BIT $2002
	BPL VBlankWait1

VBlankWait2:

	BIT $2002
	BPL VBlankWait2

	TXA

ClearMemory:

	STA $0000, x
	STA $0100, x
	STA $0200, x
	STA $0300, x
	STA $0400, x
	STA $0500, x
	STA $0600, x
	STA $0700, x

	STA $6000, x
	STA $6100, x
	STA $6200, x
	STA $6300, x
	STA $6400, x
	STA $6500, x
	STA $6600, x
	STA $6700, x
	STA $6800, x
	STA $6900, x
	STA $6A00, x
	STA $6B00, x
	STA $6C00, x
	STA $6D00, x
	STA $6E00, x
	STA $6F00, x
	STA $7000, x
	STA $7100, x
	STA $7200, x
	STA $7300, x
	STA $7400, x
	STA $7500, x
	STA $7600, x
	STA $7700, x
	STA $7800, x
	STA $7900, x
	STA $7A00, x
	STA $7B00, x
	STA $7C00, x
	STA $7D00, x
	STA $7E00, x
	STA $7F00, x

	INX
	BNE ClearMemory
(...)

mmc3tbl:
	.db $0,$2,$4,$5,$6,$7,$0,$1
Attachments
demo3.nes
(512.02 KiB) Downloaded 69 times
demo2.nes
(512.02 KiB) Downloaded 60 times
Last edited by sdm2 on Tue Dec 15, 2020 4:41 am, edited 8 times in total.

Pokun
Posts: 1761
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Kosmity Atakujo

Post by Pokun » Tue Dec 08, 2020 9:44 am

OK I see that you at least initialize RAM, but I can't see VRAM anywhere. The VRAM setup of course comes right after the "VBlankWait2" (starting with the palette). Since your CHR 0 is a blank tile, it should be fine to fill all nametables with zeroes. That should eliminate screen garbage.

If you use RAM page 2 ($0200-$02FF) as your OAM buffer like most people do, you need to set all the Y-values to an off-screen value like $FF, while the rest of it can be set to 0 (which you already did). This makes sure there are no unused garbage sprites on screen. I didn't really see any sprite garbage though, so I guess you already did that.

What I do is to change the fill value in the memory clearing code to an easily recognizable value such as $DB or $CD, then I run the program and check the memory in the emulator's memory viewer and makes sure every entry of the memory I'm checking has this value. To check the nametable, I fill it with a character like "!" (but setting all nametable attributes to 0) and makes sure all/both nametables got this character. That way I know that it works and can change back the fill value to 0 or whatever is needed for that particular memory area.

Code: Select all

	SEI
	CLD
 
	LDA #$40
	STA $4017				;Wyłącz APU IRQ.
 
	LDX #$FF
	TXS					;Wrzuć FF jako pointer Stosu
 
	INX
	STX $2000
	STX $2001
I could be wrong, and I haven't used MMC3 yet so I'm not sure how you initialize that, but I'm quite sure that this code here should go first of all. SEI makes sure that IRQs can't happen so you have all the time in the world to disable the MMC3 IRQ later. NMI can't be disabled on the CPU side though (that's why it's called Non-Maskable Interrupt after all) so the $2000 write here must come quite early so that an NMI doesn't trigger. The $2001 write is also important since you need to disable the screen somewhat soon to minimize visible screen garbage before everything is initialized.

User avatar
olddb
Posts: 147
Joined: Thu Oct 26, 2017 12:29 pm
Contact:

Re: Kosmity Atakujo

Post by olddb » Tue Dec 08, 2020 10:35 am

sdm2 wrote:
Mon Dec 07, 2020 9:25 am
I test everything on real hardware and I've never had such bugs.
This is odd.

BTW: Are you Japanese?
...

lancuster
Posts: 179
Joined: Thu Feb 18, 2016 3:20 am

Re: Kosmity Atakujo

Post by lancuster » Wed Dec 09, 2020 12:35 am

olddb wrote:
Tue Dec 08, 2020 10:35 am
sdm2 wrote:
Mon Dec 07, 2020 9:25 am
I test everything on real hardware and I've never had such bugs.
BTW: Are you Japanese?
No, he's from Poland. His name is Lukasz Siudym.

P. S.: after losing the last life, the character falls from above on the gameover screen.
Here is short fceux movie:
platfgametest-0.fm2
(27.72 KiB) Downloaded 60 times
demo3-0.fm2
(26.29 KiB) Downloaded 61 times
I would also like to speed up the scrolling of titlescreen + add the ability to skip scrolling by pressing start button.
Check my romhacks and NES arts on Patreon

See my hacks on Romhacking.net
I added level configs for 102 NES games in CaD Editor!

sdm2
Posts: 46
Joined: Wed Feb 05, 2020 12:59 pm
Location: Poland

Re: Kosmity Atakujo

Post by sdm2 » Tue Dec 15, 2020 4:41 am

I got confused because I checked the original game on my Hardware (famiclone) and there were no problems with the garbage on the screen. After changing the mapper to MMC3, however, I did not check it on real hardware (I forgot about that). There is actually garbage while scrolling (not cleared VRAM), but only the MMC3 version and UNROM all ok - why is this? In the case of UNROM it is not necessary to reset the VRAM, but in the case of MMC3 it is necessary to do it?

Oryginal Kosmity Atakujo ROM (UNROM) without VRAM reset - Real Hardware - Famiclone:
https://www.youtube.com/watch?v=cRfruOAWyhE

The name of the platform game is "Kuku-Ruku".
A few changes to the game engine, enlarged game map (first time I used NES Screen Tool - very nice software)

Gameplay:
https://www.youtube.com/watch?v=Vw2JcSjE_Ts

.
Attachments
kuku-ruku 17.12.2020.nes
(512.02 KiB) Downloaded 38 times
MAPA-small-900px.jpg
kuku.jpg
Last edited by sdm2 on Thu Dec 17, 2020 2:22 pm, edited 2 times in total.

Pokun
Posts: 1761
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Kosmity Atakujo

Post by Pokun » Tue Dec 15, 2020 6:01 am

sdm2 wrote:
Tue Dec 15, 2020 4:41 am
There is actually garbage while scrolling (not cleared VRAM), but only the MMC3 version and UNROM all ok - why is this? In the case of UNROM it is not necessary to reset the VRAM, but in the case of MMC3 it is necessary to do it?
No way. UNROM is a simple mapper and there is no way it could initialized RAM for you. It must be something else you are doing differently. Also uninitialized RAM is unpredictable (that's why it needs to be initialized to a known value so it behaves the same every time), so maybe it appears to be cleared sometimes although it really isn't.

sdm2
Posts: 46
Joined: Wed Feb 05, 2020 12:59 pm
Location: Poland

Re: Kosmity Atakujo

Post by sdm2 » Tue Dec 15, 2020 6:15 am

The RESET code and the boot screen loading are the same, the only difference is the added MMC3 initialization, I don't know why in the case of UNROM the scrolling is not garbage, and MMC3 already has and I need to reset the second part of VRAM.

Maybe UNROM works like this on Famiclone, but it will be different on the original Famicom.

EDIT:

I already know where the problem is - I used "KrzysioCart" SD ( http://forums.nesdev.com/viewtopic.php?t=15757 ), on which UNROM does not display garbage on the screen while scrolling, while when the game is running on a real UNROM card - it has these garbage tiles visible.

https://www.youtube.com/watch?v=xaStrBzJIOE

.
Attachments
DSC01742.JPG

lancuster
Posts: 179
Joined: Thu Feb 18, 2016 3:20 am

Re: Kosmity Atakujo

Post by lancuster » Wed Dec 16, 2020 8:30 am

sdm2, I recommend you to use YY-CHR for editing screens in your games. This is another nice program, to work with nametables, its enough to have a *.chr and *.nam file.
scr.png
Check my romhacks and NES arts on Patreon

See my hacks on Romhacking.net
I added level configs for 102 NES games in CaD Editor!

sdm2
Posts: 46
Joined: Wed Feb 05, 2020 12:59 pm
Location: Poland

Re: Kosmity Atakujo

Post by sdm2 » Wed Dec 16, 2020 11:45 am

I will check. Before, I only used "8NAME".

Pokun
Posts: 1761
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Kosmity Atakujo

Post by Pokun » Thu Dec 17, 2020 6:56 am

sdm2 wrote:
Tue Dec 15, 2020 6:15 am
I already know where the problem is - I used "KrzysioCart" SD ( http://forums.nesdev.com/viewtopic.php?t=15757 ), on which UNROM does not display garbage on the screen while scrolling, while when the game is running on a real UNROM card - it has these garbage tiles visible.
Ah right, flashcarts can hide initialization problems. Especially those that you load the game from a menu ROM, as opposed to one you flash the ROM directly to the chip. The Famicom is already "warm" when your game loads, so a cold boot can not be tested properly on those.

User avatar
bazza
Posts: 94
Joined: Fri Nov 24, 2017 1:36 pm
Location: Argentina
Contact:

Re: Kosmity Atakujo

Post by bazza » Thu Dec 17, 2020 9:37 am

I love them :D
Is there a website where I can see how you create them or the source code?

Post Reply