News: 11 March 2016 - Forum Rules

Author Topic: Castlevania II Belmont's revenge GBC  (Read 4487 times)

Sepp666

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
Castlevania II Belmont's revenge GBC
« on: October 22, 2020, 01:48:34 pm »
Hello all,

does anyone know why the Konami GB Collection Vol.4 does not run on the GBA with a ez-flash card? I like to play Castlevania II Belmont's revenge in color, but no way - only a black screen on the GBA.

Kind regards Sepp

Jorpho

  • Hero Member
  • *****
  • Posts: 5060
  • The cat screams with the voice of a man.
    • View Profile
Re: Castlevania II Belmont's revenge GBC
« Reply #1 on: October 22, 2020, 03:25:44 pm »
To be clear, are you talking about an EZ-Flash Jr? Can you run other GBC games?
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

Chronosplit

  • Hero Member
  • *****
  • Posts: 1601
    • View Profile
Re: Castlevania II Belmont's revenge GBC
« Reply #2 on: October 22, 2020, 05:46:21 pm »
If you're talking about a GBA flashcart, look up the emulator and see if it has compatibility with the game first.  The GBA carts only run GB/GBC games through Goomba Color.

If it's a GBC flashcart like the junior, I'm pretty sure those don't require you to do anything with it and work similarly to the Everdrive GB line.

Sepp666

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
Re: Castlevania II Belmont's revenge GBC
« Reply #3 on: October 23, 2020, 12:20:43 am »
OK, sorry for the missing Info here... I have it on the Ez-Flash Omega. Other GBC Games that I have tested are running good so far. I tried to convert the Konami GB Collection Vol.4 with Goomba color, but it doesn't start also... So i have the same problem with the Collection Vol.2, while Vol.1+3 are running great. To check if the roms have an error i loaded them into VisualBoyAdvance on my PC and they are running great. So i have no clue what's going on here. Is there a way to extract each of the 4 games of that package to run them stand allone? I wish i could extract Castlevania II color. I saw that there is a hack that let you directly boot into Castlevania II without loading up the menu where to select which game you want to play of the 4 and i have tested it but it doesn't work too. :-(
« Last Edit: October 23, 2020, 03:27:24 am by Sepp666 »

Jorpho

  • Hero Member
  • *****
  • Posts: 5060
  • The cat screams with the voice of a man.
    • View Profile
Re: Castlevania II Belmont's revenge GBC
« Reply #4 on: October 23, 2020, 11:01:28 am »
That is a much more informative post, thank you.

A little Googling suggests you are not the first person to have this problem.
https://www.dwedit.org/dwedit_board/viewtopic.php?id=639
https://krikzz.com/forum/index.php?topic=5780.15

No idea what we can do about it, though.

To check if the roms have an error i loaded them into VisualBoyAdvance on my PC and they are running great.
To be clear, are those the GBC ROMs, or the roms converted with Goomba Color?

Quote
Is there a way to extract each of the 4 games of that package to run them stand allone?
I dimly recall from the last time this came up that there is no easy way to do it.  Whichever game is at the start of the ROM might be easy to extract, but the addresses in each of the other games would all need to be re-written.  But don't take my word for it.

ETA: There is A Clue! on the second page of Google results.
http://nintendo-ds.dcemu.co.uk/newsarchive/03-2008.html
Quote
fixed: STOP opcode (fixes Konami Collection 2 JP & 4 JP)

This seems to suggest the problem here is a flaw in Goomba Color's emulation.  The question now is if it would be easier to fix Goomba Color or to find some way to patch the opcode out of the ROM (without breaking it completely).
« Last Edit: October 23, 2020, 11:10:53 am by Jorpho »
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

Sepp666

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
Re: Castlevania II Belmont's revenge GBC
« Reply #5 on: October 24, 2020, 02:07:00 am »
Thank you for searching for a way to help me Jorpho! OK, so it is a problem with the .rom and the emulation... I think that I need help from a experienced person to solve the problem as my knowledge of hacking roms is zero... Anybody here that has the skill to look for it, or help me with this? Jorpho?

Jorpho

  • Hero Member
  • *****
  • Posts: 5060
  • The cat screams with the voice of a man.
    • View Profile
Re: Castlevania II Belmont's revenge GBC
« Reply #6 on: October 24, 2020, 01:09:55 pm »
Oh, it's well beyond my capabilities.  I'd need a lot more time than I have these days if I was going to puzzle it out.

I note that https://rgbds.gbdev.io/docs/v0.4.1/gbz80.7#STOP says that the STOP instruction is "used to switch between double and normal speed CPU modes in GBC", so it makes sense that you would find it uniquely employed in a compilation of older Game Boy games.

To eliminate the obvious: are you using the latest version of Goomba Color from https://www.dwedit.org/gba/goombacolor.php , released last year?  I expect a lot of sites wouldn't have that update.
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

Sepp666

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
Re: Castlevania II Belmont's revenge GBC
« Reply #7 on: October 25, 2020, 02:31:21 pm »
Jorpho, the Goomba color is part of the Ez-Flash Omega card that I use with my Gameboy advance... As I checked I am on the newest software from Ez-Flash. It's Kernel 1.07 and Fw 7.in that software it should be the latest version of Goomba color. I thought that there would be less people that have much free time to have a look at it. Maybe dACE will show up on this thread here, he did something with the Konami Collection vol.4 maybe he knows what to do... But hope is not very good because he last logged in here last year...

Jorpho

  • Hero Member
  • *****
  • Posts: 5060
  • The cat screams with the voice of a man.
    • View Profile
Re: Castlevania II Belmont's revenge GBC
« Reply #8 on: October 25, 2020, 08:06:35 pm »
There appears to already be some discussion on https://www.dwedit.org/dwedit_board/viewtopic.php?id=728 about using a "custom kernel" to get updated versions of Goomba Color.
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

EvilJagaGenius

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
    • The Jaga's Nest
Re: Castlevania II Belmont's revenge GBC
« Reply #9 on: October 25, 2020, 10:32:25 pm »
I have the latest version of Goomba Color installed via Sterophonick's Simple kernel found here: https://gbatemp.net/threads/new-theme-for-ez-flash-omega.520665/

Unfortunately, the Konami GB Collections 2 and 4 don't boot there either.  However, the Konami GB Collection games are GB compatible, so I used a different version of Goomba - I think it was Kuwanger's Goomba Paletted - and all 4 ROMs run fine in there in GB mode.  You'll have to give up color, but you'll be able to play the games.

Alternatively, the four Japanese Konami GB Collections run fine with Super Game Boy color and borders, but have the disadvantage of being in Japanese.  Pick your poison.

Jorpho

  • Hero Member
  • *****
  • Posts: 5060
  • The cat screams with the voice of a man.
    • View Profile
Re: Castlevania II Belmont's revenge GBC
« Reply #10 on: October 26, 2020, 02:24:19 pm »
Okay, that answers that question, thank you. :)

The next obvious suggestion is: perhaps you could try making a post on Dwedit's board, considering the author still seems interested in making changes to Goomba Color?  (It would be useful to say that Lameboy had similar problems, and that those problems were due to handling of the STOP opcode, and that the STOP opcode might be uniquely used in this case to switch the GBC CPU to normal speed.)
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

Sepp666

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
Re: Castlevania II Belmont's revenge GBC
« Reply #11 on: October 26, 2020, 02:27:59 pm »
Thank you Jorpho and Jaga for your input here and the searching for a solution. I will try to contact Dwedit. Maybe he can help us. Kind regards Sepp

minucce

  • Full Member
  • ***
  • Posts: 106
    • View Profile
Re: Castlevania II Belmont's revenge GBC
« Reply #12 on: November 03, 2021, 09:04:48 pm »
My first guess:

Code: [Select]
Konami GB Collection Vol.2 (Europe) (GB Compatible).gbc


ROM0:0917 21 4D FF         ld   hl,FF4D
ROM0:091A 4E               ld   c,(hl)
ROM0:091B CB 79            bit  7,c
ROM0:091D 20 0E            jr   nz,092D


switch to double speed
ROM0:091F 0E 01            ld   c,01
ROM0:0921 71               ld   (hl),c
ROM0:0922 AF               xor  a
ROM0:0923 E0 0F            ld   (ff00+0F),a
ROM0:0925 E0 FF            ld   (ff00+FF),a
ROM0:0927 3E 30            ld   a,30
ROM0:0929 E0 00            ld   (ff00+00),a
ROM0:092B 10 FF            "corrupted stop"


ROM0:092D F3               di   
ROM0:092E AF               xor  a
ROM0:092F EA A2 D6         ld   (D6A2),a
ROM0:0932 FA A2 D6         ld   a,(D6A2)

Normally we run STOP ($10) and ignore the next byte afterward (00-FF).

So what the heck is a "corrupted stop"?? Traditionally most software will do $10, $00 == STOP, skipped NOP


Bad emulators will run $10 (STOP), $FF (RST 38). How do we fix this? Change that $FF to $00!


Code: [Select]
Konami GB Collection Vol.4 (Europe) (GB Compatible).gbc


ROM0:0237 21 4D FF         ld   hl,FF4D
ROM0:023A 4E               ld   c,(hl)
ROM0:023B CB 79            bit  7,c
ROM0:023D 20 0E            jr   nz,024D
ROM0:023F 0E 01            ld   c,01
ROM0:0241 71               ld   (hl),c
ROM0:0242 AF               xor  a
ROM0:0243 E0 0F            ld   (ff00+0F),a
ROM0:0245 E0 FF            ld   (ff00+FF),a
ROM0:0247 3E 30            ld   a,30
ROM0:0249 E0 00            ld   (ff00+00),a
ROM0:024B 10 D0            "corrupted stop"


ROM0:024D F3               di   
ROM0:024E AF               xor  a


Could be wrong but that is the 1st thing to try!

EvilJagaGenius

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
    • The Jaga's Nest
Re: Castlevania II Belmont's revenge GBC
« Reply #13 on: November 03, 2021, 11:44:43 pm »
Yep, that fixes Vol. 2 on Goomba Color.  Vol. 4 has a corrupted stop of 10D0, I believe at address 0x024B.  Don't remember off the top of my head.  I could build some simple IPS patches containing the fixes... I'd rather modify Goomba Color itself but I can't work in ASM very well.

minucce

  • Full Member
  • ***
  • Posts: 106
    • View Profile
Re: Castlevania II Belmont's revenge GBC
« Reply #14 on: November 04, 2021, 12:28:08 am »
You are correct!

Source 2019-05-04
https://www.dwedit.org/gba/goombacolor.php

gbz80.s

Code: [Select]
@----------------------------------------------------------------------------
_10:@ STOP stops the processor until an (joypad) interrupt.
@----------------------------------------------------------------------------
ldrb_ r0,doublespeed
tst r0,#1
blne_long speedswitch

@ b _noStop
@@ b _76 ;halt instead?
@ ldrb r1,gb_ime
@ tst r1,#1 ;no Halt if IRQ disabled.
@ beq _noStop
@ ldrb r0,gb_ic ;interrupt confirm
@ cmp r0,#0
@ movne r0,#0
@ strneb r0,gb_ic
@ subeq gb_pc,gb_pc,#1
@ moveq cycles,#0
@_noStop
add gb_pc,gb_pc,#1      ; fix by EvilJagaGenius!
fetch 4

PC should skip 1 opcode. 10 xx.
« Last Edit: November 05, 2021, 09:56:35 am by minucce »

EvilJagaGenius

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
    • The Jaga's Nest
Re: Castlevania II Belmont's revenge GBC
« Reply #15 on: November 04, 2021, 12:49:05 pm »
I started a Github repo for Goomba Color fixes.  Not sure how much I'll be able to do, but you can find a release with this fix implemented there.  https://github.com/EvilJagaGenius/jagoombacolor

minucce

  • Full Member
  • ***
  • Posts: 106
    • View Profile
Re: Castlevania II Belmont's revenge GBC
« Reply #16 on: November 05, 2021, 09:55:28 am »
KDL DX: FRS -- relies on color register index wrapping.


LCD.s
Code: [Select]
FF69_W: @BCPD - BG Color Palette Data
ldrb_ r1,BCPS_index
and r2,r1,#0x3F
ldr addy,=gbc_palette
strb r0,[addy,r2]
tst r1,#0x80
addne r1,r1,#1

andne r1,r1,#0x3F
orne r1,r1,#0x80

strneb_ r1,BCPS_index
bx lr

Code: [Select]
FF6B_W: @OCPD - OBJ Color Palette Data
ldrb_ r1,OCPS_index
and r2,r1,#0x3F
ldr addy,=gbc_palette+64
strb r0,[addy,r2]
tst r1,#0x80
addne r1,r1,#1

andne r1,r1,#0x3F
orne r1,r1,#0x80

strneb_ r1,OCPS_index
bx lr

My MIPS, ARM, RISC is bleh-quality.

EvilJagaGenius

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
    • The Jaga's Nest
Re: Castlevania II Belmont's revenge GBC
« Reply #17 on: November 05, 2021, 02:14:33 pm »
First impressions seem good, I tweaked your fix a bit and stuff is visible in Level 2 again.  I'd like to think I'm helping here... will probably get another release out with that fix soon.

I really want to get Pokemon Crystal working, though.  This thread seems to indicate its errors are due to bad DMA emulation.  Looking at the code, Goomba Color doesn't have proper HDMA emulation, so I wonder if that's what it needs.  DoDma() in dma.c copies everything at once no matter if it's supposed to be a general DMA or HDMA call, at least how I understand it.

(I'm looking at this wiki page for reference on how it's supposed to work)

Thoughts.
- I added a _doing_hdma global var
- Rewrite DoDma() so that if _doing_hdma, it copies one chunk and returns instead of copying everything
- io.s, FF55_W looks split into sections for HDMA and general DMA, I think HDMA is the above part, falls through to general DMA... the comments and labels are a little confusing.  Instead set _doing_hdma to true (0xFF) and return, don't fall through
- FF55_W should probably set _doing_hdma to false (0x00) if _doing_hdma and bit 7 = 0
- FF55_R should return the number of blocks remaining if _doing_hdma, otherwise return 0xFF... might not be important though?
- On HBlank, if _doing_hdma, call DoDma().  Not sure where this would go... lcd.s, timeout.s?

minucce

  • Full Member
  • ***
  • Posts: 106
    • View Profile
Re: Castlevania II Belmont's revenge GBC
« Reply #18 on: November 05, 2021, 07:53:53 pm »
We'll try figuring this out together!


Quote
I added a _doing_hdma global var

Good! We likely rely on this.


Quote
io.s, FF55_W looks split into sections for HDMA and general DMA, I think HDMA is the above part, falls through to general DMA... the comments and labels are a little confusing.  Instead set _doing_hdma to true (0xFF) and return, don't fall through

Completely agree. It runs DoDma which feels like a bad idea; we could be in any of the 4 render states (H-Blank, V-Blank, OAM Scan, Active Draw). Don't fool around since I think h-dma doesn't start until the next h-blank start.


Quote
FF55_R should return the number of blocks remaining if _doing_hdma, otherwise return 0xFF... might not be important though?

Required for Crystal to work (1st part); it actively checks # blocks left.


Quote
FF55_W should probably set _doing_hdma to false (0x00) if _doing_hdma and bit 7 = 0

Correct. Crystal writes ~80 to FF55 when it's done.


Quote
Rewrite DoDma() so that if _doing_hdma, it copies one chunk and returns instead of copying everything

Quote
On HBlank, if _doing_hdma, call DoDma().  Not sure where this would go... lcd.s, timeout.s?

In theory, it starts exactly when we enter mode 0 (hblank). I believe we can just do this:


lcd.s: entermode0
- Check hdma active
- If so, DoDma(16). It will update FF51-FF54 automatically.
- Adjust FF55 by 1. Stop if FF reached.


There's no chance we will hdma during vblank (mode 1).


EDIT:
Code: [Select]
io.s

FF55_R: @HDMA5
mov r0,#0xFF
mov pc,lr

Really?? That would screw the transfers for sure!
(Crystal would shut everything down after 0-1 blocks!)

November 05, 2021, 11:04:06 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Donkey Kong Land DX is the interesting bug.

Code: [Select]
3:dfa3
ld a, $06
ldh ($70), a


ram bank swap ==>


6:dfa7
ld a, ($c29a)
ld h, $de
ld l, a


Goomba Color does this though

Code: [Select]
3:dfa3
ld a, $06
ldh ($70), a


no ram bank swap ==>


3:dfa7
nop
nop
..
(crash)

I suppose there's some wram_W_2 cache needs to be flushed.
« Last Edit: November 05, 2021, 11:05:18 pm by minucce »

Spooniest

  • Hero Member
  • *****
  • Posts: 3406
  • Kuru zotsu!!
    • View Profile
Re: Castlevania II Belmont's revenge GBC
« Reply #19 on: November 06, 2021, 08:09:28 am »
Thread was nice to read

Hey someone polite, that's nice :D

I do not recall a time in my life where I sat down and said "I'm beating Belmont's Revenge." I get that it's a lot better than the first GB game but I've never felt like CV was suited to the GB. This got fixed (obviously) with Circle of the Moon and so forth. CV has been quite popular on portables since then.

But this earlier era of portable CV has always been a hard pass for me...it's like Sugarless Gum, idk how else to put it.
Yamero~~!