From 53495c2e1b805f8192650173d3125b567a98bf0e Mon Sep 17 00:00:00 2001
From: Ian C
+CASM - General usage +
++Z80 - Z80 processor support. +
++6502 - 6502 processor support. +
++Gameboy Z80 - The Gameboy Z80 derivative processor. +
-Any remaining blocks will be stored as-is without any basic loader.
++Generates a ROM file for a Gameboy emulator or hardware. Note that large ROM +sizes have not been extensively checked and verified. +
+ +If a single bank was used during the assembly then a simple 32K ROM is +assumed, and an error will be shown if the addresses used fall outside the range +0x150 to 0x7fff.
+ +Similarly if multiple banks are used then it is assumed that the first bank +is only used in the range 0x150 to 0x3fff, and subsequent banks in the range +0x4000 to 0x7fff. This is to fit in with the method the Gameboy uses to page +memory banks into the upper 16K portion of the normal 32K ROM address space. +
+ +By default the output driver will try and fill in the ROM size and type in +the header properly, but these can be overridden using settings.
+ +The Gameboy output driver supports the following settings that can be set via +an option command. +
+ +Option | +Description |
+option gameboy-colour, <on|off> + | ++Whether this is a Gameboy Colour cartridge. Defaults to off. +Note that gameboy-color can be used as a different spelling for this +setting. + |
+option gameboy-super, <on|off> + | ++Whether this is a Gameboy Super extended cartridge. Defaults to off. + |
+option gameboy-cart-type, <on|off> + | ++Specifies the cartridge type. Defaults to -1, which means the output driver +will pick the appropriate type. + |
+option gameboy-irq, irq, address; + | +
+Specifies an address where an IRQ routine is stored, and requests that the
+IRQ be transferred to that address when it happens. The IRQ routine must end
+with a reti opcode. +irq can be either vbl, lcd, timer, serial +or joypad. If left at the default value of -1 then an IRQ handler is +installed with just a reti instruction. + |
@@ -1138,7 +1229,7 @@ down to a single blank line in the listing. -
+The Gameboy assembler uses the standard Z80 opcodes where applicable. +Note that the Gameboy processor has a reduced number of opcodes, flags +and no index registers, though it has some additional instructions and +addressing modes. +
+ ++For instructions were the Accumulator can be assumed it can be omitted, and +EOR can be used the same as XOR: +
+ ++ xor a,a ; These are equivalent + xor a + eor a,a + + and a,b ; These are equivalent + and b ++ +
+The Gameboy CPU has a special addressing mode used for one opcode, where the +referenced address is stored as a single byte, and used as an offset into the +top page (0xff00). This can be either triggered by using the special opcode, or +will automatically used whenever an address is accessed in the range 0xff00 to +0xffff: +
+ ++ ; These all will use the special addressing mode opcode, accessing + ; memory location $ff34 + ; +label equ $ff34 + + ldh a,($34) + ldh a,($ff34) + ld a,($ff34) + ld a,(label) + + ld (label),a + ld ($ff34),a + ldh ($34),a + ldh ($ff34),a ++ +
+The Gameboy CPU also supports incrementing or decrementing the HL register when +it is used as an address: +
+ ++ ; All these decrement HL after the value has been used. + ; + ld a,(hl-) + ld a,(hld) + ldd a,(hl) + ld (hl-),a + ld (hld),a + ldd (hl),a + + ; All these increment HL after the value has been used. + ; + ld a,(hl+) + ld a,(hli) + ldi a,(hl) + ld (hl+),a + ld (hli),a + ldi (hl),a ++ +
In addition the Gameboy CPU supports these extra instructions over the Z80: +
+ ++ ; Actually loads using the address $ff00 + C + ; + ld a,(c) + ld (c),a + + ; Put the Gameboy into a low-power mode till a control is pressed. + ; Note it is accepted practice to put a NOP afterwards. This may be + ; due to the stop replacing DJNZ, which may still be wired to expect + ; an argument. That is just a wild guess though. + ; + stop + nop + + ; Swaps the low/high nibbles of the register + ; + swap a + swap b + swap c + swap d + swap e + swap h + swap l + swap (hl) ++ + +