The Lush Engine






Introduction
Expedition
Introduction
Features
Design Notes
Coding
Startup
Tile areas
Flooring
Walls



Tile Areas

It is always worth planning the various tile areas out in advance before you start a project. If you plan the tiles out properly, you should only need to make minor, if any, alterations during the course of the project.

To help you plan the areas out, I have provided a convenient reference sheet in the source section of this site. The file is tilenum.doc and it is in Word for Windows version 2 format. If you need it in a different format (that can support tables) let me know and I will send you a version.

In expedition, we will be using both banks, and both tile areas of each bank. The first tile area will be used for the sprites, the second area will be used for the background and window. Where these two areas cross over, we will be placing objects that will be displayed on the background/window and also used as sprites.

Code

To set up our code to reflect this, open up your exped.asm file and go to the following section of the file:

Start:
; Do some initialisation stuff here, setup data, etc.

loop:
Now, after the start comment and before the loop: line, place the following commands (the ones in bold text):
Start:
; Do some initialisation stuff here, setup data, etc.

 ld	sp,$FFFE
 ld	a,0
 ldh	[$FF],a
 ldh	[$41],a
 ldh	[$42],a
 ldh	[$43],a
 ld	a,%01000011
 ldh	[$40],a

loop:
What this section of code does is to do some simple initialisation stuff. The ldh command is basically the same as the ld command except that it automatically adds $FF00 to the address given. This was incorporated by Nintendo to allow quick data transfer to the registers. Obviously ldh is quicker than ld, and takes less memory.

Loading the stack pointer (SP) with $FFFE is always a good idea. It means that the stack is in a decent place.
Loading 0 into $FFFF tells the gameboy not to bother with any of the interrupts.
Loading 0 into $FF41 resets the LCDC status register.
Loading 0 into $FF42 sets the Background Scroll Y to zero, or no offset.
Loading 0 into $FF43 sets the Background Scroll X to zero, or no offset.

The data loaded into $FF40 is the important bit here, it sets the following information:

Bit 7 : 0=Turn the LCD off
Bit 6 : 1=Window Tile Map data is between $9C00 and $9FFF
Bit 5 : 0=Window display off
Bit 4 : 0=Background and Window are using the tile data between $8800 and $97FF
Bit 3 : 0=Background Tile Map data is between $9800 and $9BFF
Bit 2 : 0=OBJ (Sprite) size is 8x8 pixels
Bit 1 : 1=OBJ (Sprite) display is turned on
Bit 0 : 1=Background and Window display is turned on

Area Planning

The following section shows which tiles of which tile areas are being used for what. Obviously this section will be expanded as the project develops. As each new part of the project is written, this section will reflect the new tiles needed. As a result, please check this section when you get to a new part of the project.

Bank One - First Tile Area

This section will be used for the sprites. The crossover with the second tile area will be used when a tile will be used for both sprites and background/window.

Tiles

None assigned yet

Bank One - Second Tile Area

This section will be used for the background and window. The crossover with the first tile area will be used when a tile will be used for both background/window and sprites.

Tiles
0-3 : Cross Floor Tile
4-15 : Basic Walls
16-25 : Basic Texture Set

Bank Two - First Tile Area

This section will be used for the sprites. The crossover with the second tile area will be used when a tile will be used for both sprites and background/window.

Tiles

None assigned yet

Bank Two - Second Tile Area

This section will be used for the background and window. The crossover with the first tile area will be used when a tile will be used for both background/window and sprites.

Tiles

None assigned yet


Buttons created using the interactive button maker at Coolarchive