The Lush Engine








Introduction
Background
Math
Objects
Palettes
Tiles
Utilities
Introduction
asm.bat
joypad.asm
skeletal.asm
tilenum.doc

Skeletal file

The following file is a bare bones file on which to build your game. You can download the file as well if you don't want to cut and paste the text.

skeletal.asm

To download the file using a PC, right-click the link and select the option "Save Target As" then save the file as you would any other file from windows.

Explanation

The start of the code has three variables that need setting. The CARTTYPE, ROMSIZE, and RAMSIZE variables. Before each variable is a list of all possible values that can be set.

Next come the interrupt calls. If you need to place an interrupt in your code, this is where you place the call for each interrupt.

The next part is the standard Gameboy Header. The only thing you should need to change is the game title. Whatever you do, make sure that the title is in capitals and is exactly 15 characters long. If your game title is short, pad the extra characters with spaces.

After the Header comes your main program area. I've placed two labels in already to help you. The first label, Start: is where you should place the initialisation code that is run once, when the game is first run.

Following the initialisation area is the main loop of your game. This is where you call the various routines that handle your game. After this loop you should place the many routines that make up your game.

After this section is a data area, this is where you can place labels and reserve data space for your game to use.

Source

;******************************************************************
; Header Equates, change the values to suit your game
;******************************************************************
;Cartridge type:
;  0 - ROM ONLY
;  1 - ROM+MBC1
;  2 - ROM+MBC1+RAM
;  3 - ROM+MBC1+RAM+BATTERY
;  5 - ROM+MBC2
;  6 - ROM+MBC2+BATTERY
;  8 - ROM+RAM
;  9 - ROM+RAM+BATTERY
;  B - ROM+MM01
;  C - ROM+MM01+SRAM
;  D - ROM+MM01+SRAM+BATTERY
;  F - ROM+MBC3+TIMER+BATTERY
; 10 - ROM+MBC3+TIMER+RAM+BATTERY
; 11 - ROM+MBC3
; 12 - ROM+MBC3+RAM
; 13 - ROM+MBC3+RAM+BATTERY
; 19 - ROM+MBC5
; 1A - ROM+MBC5+RAM
; 1B - ROM+MBC5+RAM+BATTERY
; 1C - ROM+MBC5+RUMBLE
; 1D - ROM+MBC5+RUMBLE+SRAM
; 1E - ROM+MBC5+RUMBLE+SRAM+BATTERY
; 1F - Pocket Camera
; FD - Bandai TAMA5
; FE - Hudson HuC-3
; FF - Hudson HuC-1
CARTTYPE  EQU 0

;Rom Size:
;   0 - 256 Kbit        =  32 Kbyte     =   2 banks
;   1 - 512 Kbit        =  64 Kbyte     =   4 banks
;   2 -   1 Mbit        = 128 Kbyte     =   8 banks
;   3 -   2 Mbit        = 256 Kbyte     =  16 banks
;   4 -   4 Mbit        = 512 Kbyte     =  32 banks
;   5 -   8 Mbit        =   1 Mbyte     =  64 banks
;   6 -  16 Mbit        =   2 Mbyte     = 128 banks
; $52 -   9 Mbit        = 1.1 Mbyte     =  72 banks
; $53 -  10 Mbit        = 1.2 Mbyte     =  80 banks
; $54 -  12 Mbit        = 1.5 Mbyte     =  96 banks
ROMSIZE   EQU 0

;Ram Size:
; 0 - None
; 1 -  16 Kbit          =   2 Kbyte     =  1 bank
; 2 -  64 Kbit          =   8 Kbyte     =  1 bank
; 3 - 256 Kbit          =  32 Kbyte     =  4 banks
; 4 -   1 Mbit          = 128 Kbyte     = 16 banks
RAMSIZE   EQU 0

;*** Vertical blank IRQ ***
SECTION "VBLANK IRQ",home[$0040]
 reti

;*** LCDC status IRQ ***
SECTION "LCDC IRQ",home[$0048]
 reti

;*** Timer overflow IRQ ***
SECTION "TIMER IRQ",home[$0050]
 reti

;*** Serial transfer completion IRQ ***
SECTION "SERIAL IRQ",home[$0058]
 reti

;*** High-to-Low of P10-P13 IRQ ***
SECTION "HILO IRQ",home[$0060]
 reti

;******************************************************************
; Standard Header Information Template
;******************************************************************

SECTION "Header",home[$0100]
  ; Jumper
  nop
  jp Start ; go to Start of program:
  ; "Nintendo" Character Data
  DB $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C,$00,$0D
  DB $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$DD,$DD,$D9,$99
  DB $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E
  ; Game Title
  db "               "
  ;  "123456789012345" <- Title must be exactly that long, in caps
  ; Colour Compatibility Code ($80 : yes, $00 : no)
  db $80
  ; Maker Code
  db 0,0
  ; Game Unit Code (00=Gameboy, 03=Super Gameboy functions)
  db 0
  ; Cartridge type:
  db CARTTYPE
  ; Rom Size:
  db ROMSIZE
  ; External Ram Size:
  db RAMSIZE
  ; Destination code (0 - Japanese, 1 - Non-Japanese
  db 1
  ; Old Licensee code (33 - Check Maker Code)
  db $33
  ; Mask ROM Version
  db 0
  ; Complement check
  db $0
  ; Checksum
  db 0,0

;******************************************************************
;          This is the start of the program
;******************************************************************

SECTION "Main", home[$0150]

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


loop:
; This is the main game loop, put your code here.
    jp loop

;******************************************************************
; Main Memory area
;       Use this area to store variables etc
;
;****************************************************************** 
SECTION "Main Mem", BSS[$C000]


Buttons created using the interactive button maker at Coolarchive