nesdev.com
https://forums.nesdev.com/

[homebrew] Cheril Perils GB/GBC
https://forums.nesdev.com/viewtopic.php?f=20&t=17383
Page 1 of 1

Author:  tonma [ Tue May 22, 2018 2:12 am ]
Post subject:  [homebrew] Cheril Perils GB/GBC

Hi,

I'm working on my first ever GameBoy game. It's a version of the MegaDrive game by Mojon Twins.

I've added tilemap, sprite with animations, basic collision, bank switching (seems to work) and GameBoy / GameBoyColor compatibility.
I'ts works on real hardware.

I'll certainly have questions when I'll attack the sound/music part.

Image

Image

Author:  calima [ Tue May 22, 2018 10:53 am ]
Post subject:  Re: [homebrew] Cheril Perils GB/GBC

The green-and-black text's lowest, darkest color makes it hard to read.

Author:  tonma [ Wed May 23, 2018 5:22 am ]
Post subject:  Re: [homebrew] Cheril Perils GB/GBC

calima wrote:
The green-and-black text's lowest, darkest color makes it hard to read.

Yep, I'll change that to a 2 colors fonts to be more readable.

Author:  tonma [ Sat Jun 02, 2018 11:48 pm ]
Post subject:  Re: [homebrew] Cheril Perils GB/GBC

News : room transition, ennemies with collision, lethal weapon and modified gameplay.

Video of the gameplay :
https://youtu.be/UMzqGtDpL-A

Image

I also hard coded a music for the title of the game (I used @DavidBonus 's score) :
https://soundcloud.com/user-218371570/gb-title

Author:  tonma [ Wed Jun 06, 2018 9:09 am ]
Post subject:  Re: [homebrew] Cheril Perils GB/GBC

I have a problem with the bank switching. I read different documents on the forums and tested different solutions.

I use gbdk 2.95 with windows.

Code:
REM      Link banks
REM       ROM+MBC1 : -Wl-yt1
REM       ROM+MBC1+RAM : -Wl-yt2
REM       4 ROM banks  : -Wl-yo4
REM       4 RAM banks  : -Wl-ya4

..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-ba0 -c -o -c -o banks.o banks.c
..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-bo0 -c -o -c -o bank_0.o bank_0.c
..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-bo1 -c -o -c -o bank_1.o bank_1.c
..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-bo2 -c -o -c -o bank_2.o bank_2.c
..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-bo3 -c -o -c -o bank_3.o bank_3.c
..\..\bin\lcc -Wa-l -Wl-m -Wl-j -Wl-yt2 -Wl-yo4 -Wl-ya1 -o banks.gb banks.o bank_0.o bank_1.o bank_2.o bank_3.o


I put my bank fixed code in banks.0 but I have an error at the compilation :
ERROR: address overflow (addr a002 >= 8000)

I use the same syntax for all my bank.

bank0:
Code:
int var_0;  /* In external RAM bank 0 */
extern int var_internal;
void bank_0() ;

void bank_0()  {

}


bank 1 to 3 with a same size const array cut1_tileset, cut2_tileset, cut3_tileset
Code:
#include <gb/gb.h>
#include <stdio.h>

#pragma bank=1

int var_1;  /* In external RAM bank 1 */
extern var_internal;

const unsigned char cut1_tileset[] =
{
 
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,......
};


void bank_1()  /* In ROM bank 1 */
{
 
DISPLAY_ON;
SPRITES_8x16;
SHOW_BKG;

}


In the external file from compilation :
Code:
AREA _CODE_0
   RADIX HEX
   BASE A002
   SIZE 0016
   ATTRIB REL CON
   GLOBALS
      _bank_fixed   A002
      _bank_0   A017
AREA _CODE_1
   RADIX HEX
   BASE 4000
   SIZE 36C6
   ATTRIB REL CON
   GLOBALS
      _bank_1   4000
      _cut1_tileset   4001
      _bank_1_test   76A1
AREA _CODE_2
   RADIX HEX
   BASE 4000
   SIZE 36BC
   ATTRIB REL CON
   GLOBALS
      _bank_2   4000
      _cut2_tileset   400A
AREA _CODE_3
   RADIX HEX
   BASE 4000
   SIZE 36A1
   ATTRIB REL CON
   GLOBALS
      _bank_3   4000
      _cut3_tileset   4001

Author:  tonma [ Thu Jun 07, 2018 2:33 am ]
Post subject:  Re: [homebrew] Cheril Perils GB/GBC

After a lot of tests, I've find how bank switching works with my version of gbdk.

I've tried with 7 banks switchables using ROM+MBC1+RAM :
Code:
..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-ba0 -c -o -c -o banks.o banks.c
..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-bo0 -c -o -c -o bank_0.o bank_0.c
..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-bo1 -c -o -c -o bank_1.o bank_1.c
..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-bo2 -c -o -c -o bank_2.o bank_2.c
..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-bo3 -c -o -c -o bank_3.o bank_3.c
..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-bo4 -c -o -c -o bank_4.o bank_4.c
..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-bo5 -c -o -c -o bank_5.o bank_5.c
..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-bo6 -c -o -c -o bank_6.o bank_6.c
..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-bo7 -c -o -c -o bank_7.o bank_7.c
..\..\bin\lcc -Wa-l -Wl-m -Wl-j -Wl-yt2 -Wl-yo8 -Wl-ya1 -o banks.gb banks.o bank_0.o bank_1.o bank_2.o bank_3.o bank_4.o bank_5.o bank_6.o bank_7.o


Image

I used "banked" and pragma for each bank (1->7) :
Code:
#include <gb/gb.h>
#include <stdio.h>
#pragma bank=1
extern var_internal;

const unsigned char title_map[] = { 0,0,0,0, ....};

void bank_1() banked /* In ROM bank 1 */
{
puts("I'm in ROM bank 1");
}


So I have in my map file 7 banks with more of $3000 of rom used :
Code:
AREA _CODE_1
   RADIX HEX
   BASE 4000
   SIZE 3521
   ATTRIB REL CON
   GLOBALS
      _bank_1   4000
      _title_map   400A
      _title_tileset   6BA2
      _title_tiledata   72A2
      _title_map_pal   7322
      _title_start_map   748A
      _bank_1_test   74E4


But now I have a problem with the bank 0, the "fixed bank".
Normaly with the memory map, banks switchable go to $4000 and it's ok : Base 4000

-Wf-ba0 banks.c
-Wf-bo0 bank_0.c
The fixed bank may go to $0150-$3FFF and the internal ram bank $C000-$CFFF. So my rom code/data of bank_0 must begin at $0150.

In my map file, my code begin at A000 in the cartrige RAM :
Code:
AREA _CODE_0
   RADIX HEX
   BASE A006
   SIZE 001C
   ATTRIB REL CON
   GLOBALS
      _bank0   A006


I certainly doing something wrong in the declaration of my compilation file. The tests continue.

Author:  tonma [ Thu Jun 07, 2018 4:33 am ]
Post subject:  Re: [homebrew] Cheril Perils GB/GBC

Seems to works now. :mrgreen:
My code in bank 0 has the good address value :
Code:
AREA _CODE
   RADIX HEX
   BASE 0200
   SIZE 2822
   ATTRIB REL CON


I just changed my compilation file.
I'm not using anymore -Wf-bo0 for the fixed bank and using the External RAM in A000.
Code:
REM ..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-ba0 -c -o banks.o banks.c
REM ..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-bo0 -c -o bank_0.o bank_0.c
..\..\bin\lcc -Wa-l -Wl-m -Wl-j -c -o banks.o banks.c
..\..\bin\lcc -Wa-l -Wl-m -Wl-j  -Wf-ba0 -c -o bank_0.o bank_0.c

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/