------------------------------------------------------------------------------ WLA DX GB-Z80/Z80 Macro Assembler Package Copyright 1998-2000 Ville Helin ------------------------------------------------------------------------------ 1..... Introduction 2..... WLA GB-Z80/Z80 History 3..... WLAB History 4..... WLAD History 5..... WLALINK History 6..... Assembler Directives 7..... Assembler Syntax 7.1.. Case Sensitivity 7.2.. Comments 7.3.. Labels 7.4.. Number Types 7.5.. Strings 7.6.. Supported Z80 Commands 7.7.. Brackets? 8..... Error Messages 9..... Supported Types 9.1.. ROM Size 9.2.. RAM Size 9.3.. Cartridge Type 10.... Bugs 11.... Files 11.1. 'examples' 11.2. 'lib' 12.... Temporary Files 13.... Compiling 13.1. Compiling ROM Images 13.2. Compiling Object Files 13.3. Compiling Compact Object Files 13.4. Compiling Library Files 13.5. Compiling Compact Library Files 13.6. Compiling Program Files 14.... Arithmetics 15.... Linking 16.... Disassembling 17.... Binary to DB Conversion 18.... Pocket Voice 19.... WLA Flags 20.... Author 21.... Thanks 22.... Future 23.... Support 24.... Legal Note ------------------------------------------------------------------------------ 1... Introduction ------------------------------------------------------------------------------ Here is yet another macro assembler to help you to produce Game Boy software. With the release of WLA DX 6.0 other Z80 systems are supported as well. I wrote this because I had never written an assembler before and I really needed a macro assembler which could compile the GB-Z80 code I wrote. ;) Gaelan Griffin needed real Z80 support for his SMS projects so I thought I could write WLA to be a little more open and nowadays it supports all the Z80 systems you can think of. You'll just have to define the memorymap of the destination machine for your project. This is my ideal GB-Z80 macro assembler (not in final form, not yet). ;) Tastes differ. Thus WLA! I will not release WLA's source code, not now, as it is ugly, and would put me into shame. ;) Any comments are gladly accepted. And if you produce nice software with WLA, send me email about it (or even the whole programme)! ;) Currently WLA can also be used as a patch tool. Just include the original ROM image into the project with .BACKGROUND and insert OVERWRITE .SECTIONs to patch the desired areas. Output the data into a new ROM image and there you have it. 100% readable patches are reality! About the names... WLA DX means all the tools covered in this documentation. So WLA DX includes WLA GB-Z80/Z80 macro assembler, WLAB, WLAD and WLALINK GB-Z80/Z80. I use plain WLA to refer to the macro assembler. WLA DX's homepage: http://www.hut.fi/~vhelin/wla.html ------------------------------------------------------------------------------ 2... WLA GB-Z80/Z80 History ------------------------------------------------------------------------------ v6.5 (20-Sep-2000) [ALL] Optimized number decoding. [ALL] Enhanced documentation. [ALL] Binary file compiling is now called program file compiling (still doesn't suit it 100%). [ALL] Macros couldn't be used before setting an ORG. [Z80] Program file compiling accepts now BANKHEADER section for bank 0. [Z80] The default program file suffix is now '.prg'. [Z80] NO$GMB symbol files can also be written. v6.4 (12-Sep-2000) [ALL] Returned '*' commenting (from the beginning of a line). [ALL] 'LABEL:XYZ' is now correctly decoded. [ALL] BIT/RES/RST/SET opcodes understand now defines and calculations. [ALL] References to local labels outside sections were possible. [ALL] Added a much faster and enhanced MACRO language. [ALL] IF directives can now be nested. [ALL] .INCBIN works in library files. [ALL] Added .REDEFINE. [ALL] Added .PRINTT and .PRINTV. [ALL] Added .DBSIN, .DBCOS, .DWSIN and DWCOS. [ALL] Added .IFEQ, .IFNEQ, .IFGR and .IFLE. [ALL] Added .IF with the following operators: '>', '<', '!=' and '=='. [ALL] Added .IFNDEFM and .IFDEFM. [ALL] Added .UNDEF. [ALL] Added .FAIL. [ALL] Added SEMIFREE sections. [ALL] Fixed a bug in opcode case sensitivity checks. [ALL] Opcode case sensitivity mode can be changed so WLA understands only uppercase letters (flag u). [ALL] Added support for modulo ('#') in calculations. [ALL] Enhanced error messages. [ALL] ROM banks can be inserted into different sized slots as long as the bank fits fully inside the slot. [ALL] Computations are now computed internally with higher precision when possible and the result is converted to an integer. v6.3 (04-Sep-2000) [ALL] Enhanced error messages. [ALL] Optimized section handling. [ALL] Optimized label handling. [ALL] Removed support for '*' commenting. [ALL] Added support for special ROM bank header sections. [ALL] Added support for powers ('^') and shifts ('<<' and '>>') in calculations. [ALL] Fixed calculator engine to work better. [ALL] Enhanced calculation detection. [ALL] .DB and .DW take now comma separated data. Make sure to use commas when placing arithmetic calculations inside .DB and .DW data fields. [ALL] .DSW, .DSB, .DW and .DB take labels and pending computations as data. [ALL] The following directives can be redefined as long as the values equal: .ROMBANKS, .EMPTYFILL and .ROMBANKSIZE. [ALL] .ROMBANKMAPs and .ROMBANKS can be redefined as long as they match (as much as possible). WLA will then use the biggest defined ROM bank map. [GB ] The following directives can be redefined as long as the values equal: .NAME, .RAMSIZE, .CARTRIDGETYPE, .LICENSEECODENEW, .LICENSEECODEOLD, .COMPUTECHECKSUM, .COMPUTECOMPLEMENTCHECK, .ROMDMG, .ROMGBC and .ROMSGB. v6.2 (31-Aug-2000) [ALL] Enhanced error messages. [ALL] Enhanced number size checks in the opcode decoding loop. [ALL] Braces are not needed anymore in arithmetics. [ALL] Added a fully functional stack calculator engine. [ALL] Unused local labels don't get smoked anymore. [ALL] WLA could crash when including a file while using the old error message engine. [ALL] Negative values in the 16bit range are now handled with better care. [ALL] When compiling a ROM image and using a section inside direct mapped code WLA would screw up the data. v6.1 (26-Aug-2000) [ALL] Directives accept now definitions as arguments. [ALL] Added more security checks to .MEMORYMAP. [ALL] Optimized .MEMORYMAP building. [ALL] Optimized SLOT usage. [ALL] Added .ROMBANKMAP and .ENDRO. [ALL] .BANKSIZE is now .ROMBANKSIZE. [ALL] 4G worth of ROM banks are supported. [ALL] SLOT numbers start from 0. v6.0 (23-Aug-2000) [ALL] Rewrote and optimized opcode decoding. [ALL] Preprocessing subroutine removed comments from inside data strings. [ALL] Support for old syntax directives is dropped. [ALL] Enhanced the documentation. [ALL] Enhanced the error messages. [ALL] .INCBIN could break the line numbering in the error messaging engine. [ALL] Fixed a bug in .FORCE section handling. [ALL] Added .BANKSIZE. [ALL] Added .MEMORYMAP and .ENDME. [ALL] Added .ENDASM and .ASM. [ALL] '*' can also be used to comment away lines. [ALL] WLA can now test compile (flag t). [ALL] .ROMSIZE is replaced with .ROMBANKS. [ALL] Changed FREE section positioning a little. [Z80] Binary files can be compiled with the flag 'b'. [Z80] Added .HEADER. [Z80] Added .FOOTER. v5.0 (09-Jul-2000) Enhanced brackets detection. Enhanced the documentation. Enhanced error messages. WLA outputs now a NO$GMB symbolic information file along with a ROM image (s flag). .SECTION without a specifier is treated as a FREE section. Optimized directive decoding. Optimized parser loop. If .RAMSIZE is not defined a warning is issued instead of an error. Added SWAP to .INCBIN. Verbose mode shows data usage percentages (per bank as well). WLAD (WLA Disassembler) is now included with the WLA archive. v4.6 (21-Jun-2000) Enhanced the documentation. Optimized directive decoding. "JP (HL)" is now known as "JP HL". GB-Z80 syntax parser supports now brackets as well. WLA doesn't crash if the project's main file is missing. v4.5 (15-Jun-2000) Enhanced the documentation. Fixed the reintroduced '.INCDIR ""'-bug. Target file name can now be left away as WLA has now built in default suffices (.gb, .o and .lib). Added lib-directory to the archive. Trying to compile a compact ROM file will give a warning. v4.4 (09-Jun-2000) Enhanced the documentation. Fixed "RR A"->"RRCA" and "RL A"->"RLCA" transformations. "EI" and "RST $x" were followed by a "NOP"! Hexadecimal and binary values are supported in arithmetics. Optimized number decoding. v4.3 (03-Jun-2000) Enhanced error messages. Number decoding routines are now compatible with the new error messaging system. Optimized define and macro handling. Optimized GB-Z80 opcode decoding. Optimized source file parsing. Very long (typos?) tokens don't crash WLA anymore. .INCDIR accepts directory paths which are not terminated with '/' (or '\' under MSDOS). Added support for very simple arithmetics. Fixed "LD HL, SP+x". Removed "EX HL, (SP)". Added OVERWRITE to .SECTION (patch tool function). Added .BACKGROUND (patch tool function). WLA would crash if the whole project was inside one file, and if the file was not found. "=" can be optionally left away from many directives. Added "JP (HL)". v4.2 (11-Apr-2000) Enhanced documentation. Enhanced error messages. WLA could crash if .REPT wasn't ended with .ENDR. .MACRO and .REPT are now compatible with the new error messaging system. .REPT size is now 2k. v4.1 (29-Mar-2000) Enhanced documentation. Enhanced error messages. Optimized number conversion. Added ANSI-C -like commenting ("/* ... */"). v4.0 (19-Mar-2000) Optimized data parsing. Added a much better error messaging system as default. Added "-f" -option for fast compiling (uses old error messaging system with few enhancements). "LDH (x), A" and "LDH A, (x)" support was broken due to a typo. WLA accepts now negative values as well. WLA's flags and usage changed totally! Read about the changes in the documentation. Input and output files cannot be the same. Enhanced the documentation. v3.0 (20-Feb-2000) Added support for "LDH (x), A", "LDH A, (x)", "LD (HLI), A", "LD (HL+), A", "LD A, (HLI)", "LD A, (HL+)", "LD (HLD), A", LD (HL-), A", "LD A, (HLD)" and "LD A, (HL-)". WLA filters away unreferenced local lables in object/library output mode. MSDOS temporary file directory is now the working directory. Added "-co" -option for compact object file producing. Added "-cl" -option for compact library file producing. Enhanced .SECTION logic (syntax changed!). Added new error messages. Optimized temporary file usage. Optimized directive decoding. Optimized internal pass 2. Optimized .SECTION handling. Optimized .DSB and .DSW. Optimized pass 1. Optimized .INCLUDE. v2.9 (16-Feb-2000) Section names with spaces crashed WLA. Fixed address bound checking in .BANK. Added more error messages. v2.8 (15-Feb-2000) Added .EXPORT. All strings starting with "." are treated as directives. Directives are not case sensitive any more. Fixed a broken 0x0D filter (in MSDOS text files). Source file ending into a comment could crash WLA. Optimized .INCLUDE. Libraries can now have references outside. Amiga object/library files were not compatible with PC files. Fixed a bug in object file generator that could crash WLA. v2.7 (07-Feb-2000) WLA returns 0 when help information is displayed. WLA returns 1 when execution ended in error. -1 produced ugly error messages on Amiga computers. WLA gives now an error when the user tries to produce a library file which has references to outside. Amiga version has version string. Enhanced some error messages. Enhanced documents. v2.6 (03-Feb-2000) PC relative reference distances inside sections could be more than 127 bytes. v2.5 (29-Jan-2000) Enhanced documents. Fixed GBC indicator from $C0 to $80. v2.4 (26-Jan-2000) Fixed a typo "NET NC" to "RET NC". Enhanced some error messages. Added .ROMGBC, .ROMDMG and .ROMSGB. Rewriting memory with equal data doesn't give an error. v2.3 (23-Jan-2000) Added .SECTION, .ENDS. Added "-l" -option for library file producing. Fixed address calculations a little more. WLA returns -1 when execution ended in error. Local labels are now local to sections or object file. Enhanced the documents. v2.2 (16-Jan-2000) Added .DSW, .DW, .ENUM and .ENDE. v2.1 (14-Jan-2000) Added $BE (Pocket Voice) to supported cartridge types. Added "-v" -option for verbose information displaying. Optimized pass 1. Fixed possible errors in address calculations. v2.0 (12-Jan-2000) Enhanced the documents. Optimized internal pass 2 and directive including. Fixed overflow check (in .ORG). Added "-o" -option for object file producing. Added linker executable "wlalink". Added .INCDIR. v1.9 (06-Jan-2000) Optimized .INCBIN, .INCLUDE and internal passes 1 and 2. v1.8 (23-Dec-1999) Enhanced the documents. Fixed overflow checker once again. Every bank gained one byte more (total 16384). v1.7 (04-Dec-1999) Enhanced the documents. Added gb_hardware.i. .INCBIN didn't free buffer memory. Optimized .INCBIN. .INCBIN now caches all the files. Optimized internal passes 1 and 2. Linux version is optimized for 486. v1.6 (14-Nov-1999) Enhanced the documents. Fixed nintendo_logo.i so it works on a real Game Boy. Fixed complement check calculation to work. Overflow checker thought GB ROM banks were 8KB each! Fixed to 16KB. Ville no baka! Added .REPT. Added .ENDR. v1.5 (10-Jun-1999) Enhanced the documents. WLA does now one pass to the input data and two passes to the internal data. v1.4 (25-May-1999) Renamed nintendo_logo.s to nintendo_logo.i. Fixed nintendo_logo.i Wzonka-Lad-compatible. Fixed pass-texts, as WLA does actually one pass, three of the old ones were made to the WLA's internal data. Added one funky new optcode, "DEBUG", which will translate to $ED (unused in GB-Z80). This one will flash the power light when executed on Wzonka-Lad, my Game Boy emulator. Use it only for debugging! v1.3 (01-Jan-1999) Enhanced the documents. WLA now shows the unused areas of the ROM file after a successful compile in hexadecimal format. Many WLA directives accepted non-pure values, not anymore. Added .DSB. .DB handles now strings as well. v1.2 (21-Dec-1998) Enhanced the documents. Added a list ("gb-z80.txt") of the supported GB-Z80 commands to the archive. Free strings don't break the compile loop anymore. Added .INCBIN. v1.1 (13-Dec-1998) Enhanced the documents. Removed an unused function. Number input now detects and discards numbers from outside the word boundaries. WLA now shows the unused areas of the ROM file after a successful compile. Added .IFNDEF. Added .IFDEF. Added .ELSE. Added .ENDIF. Added @@@ to .MACRO. .DB accepted values from outside the byte boundaries. v1.0 (12-Dec-1998) The first public release. ------------------------------------------------------------------------------ 3... WLAB History ------------------------------------------------------------------------------ v1.1 (04-Sep-2000) Uses now WLA v6.3+ syntax (introduced commas). Accepts now files bigger than 64KB. v1.0 (23-Aug-2000) The first public release. ------------------------------------------------------------------------------ 4... WLAD History ------------------------------------------------------------------------------ v1.2 (01-Sep-2000) SLOT numbers are handled correctly. Uses ROMBANKS instead of ROMSIZE. String detection works better. v1.1 (23-Aug-2000) Added flag 'a' to disable address output. v1.0 (10-Jul-2000) The first public release. ------------------------------------------------------------------------------ 5... WLALINK History ------------------------------------------------------------------------------ v3.5 (20-Sep-2000) Added support for program file output (Z80 only, flag b). NO$GMB symbol files can also be written in Z80 mode. v3.4 (09-Sep-2000) Label duplicate checker didn't handle local labels correctly. Added support for modulo in calculations. Added support for SEMIFREE sections. Computations are now computed internally with higher precision when possible and the result is converted to an integer. v3.3 (04-Sep-2000) Enhanced error messages. Added support for powers and shifts in calculations. Added support for special ROM bank header sections. Labels' slot and bank numbers inside library files could get corrupted. Optimized label handling. v3.2 (31-Aug-2000) The supported file formats are only "WLAP", "WLA9" (GB-Z80) and "WLAA" (Z80). Added a fully functional stack calculator engine. Objects with different ROM sizes can be combined, and the result will use the biggest ROM size found as long as the sizes of the ROM banks match. Optimized file parsers. Enhanced error messages. v3.1 (26-Aug-2000) The supported file formats are only "WLAO", "WLA7" (GB-Z80) and "WLA8" (Z80). Exported definitions were handled incorrectly. Memory overwrite warnings were displayed when fixing relative addresses. v3.0 (23-Aug-2000) The supported file formats are only "WLAO", "WLA5" (GB-Z80) and "WLA6" (Z80). Rewrote 30% of the code. WLALINK arguments changed! WLALINK needs now a linkfile. v2.0 (09-Jul-2000) WLALINK outputs now NO$GMB symbolic information files along with a ROM image (flag s). Verbose mode shows data usage percentages (per bank as well). v1.9 (25-May-2000) Added support for WLA v4.3's .SECTION OVERWRITE. v1.8 (20-Feb-2000) The supported file formats are only "WLAN" and "WLA4". WLALINK uses now less memory. Enhanced some error messages. v1.7 (15-Feb-2000) Added support for WLA's .EXPORT. Enhanced some error messages. Optimized ROM file generation. The supported file formats are only "WLAM" and "WLA3". Amiga object/library files were not compatible with PC files. v1.6 (07-Feb-2000) WLALINK returns 0 when help information is displayed. Amiga version has version string. v1.5 (03-Feb-2000) PC relative reference distances inside sections could be more than 127 bytes. Enhanced some error messages. v1.4 (31-Jan-2000) Duplicate labels positioned in different places in Game Boy memory map break the linking loop. Fixed object identifier, verbose mode screwed up the names. Enhanced some error messages. Referencing to a label inside a section more than once screwed up the label's address. v1.3 (26-Jan-2000) Rewriting memory with equal data doesn't give an error. Enhanced some error messages. v1.2 (23-Jan-2000) Added support for library files. v1.1 (14-Jan-2000) Added support for Pocket Voice. Added "-v" -option for verbose information displaying. WLALINK now checks the object file formats. v1.0 (12-Jan-2000) The first public release. ------------------------------------------------------------------------------ 6... Assembler Directives ------------------------------------------------------------------------------ The directives are collected as they appear. Group 2 directives take place as they are found. Group 1 directives are applied at the very end, after all the code has been processed, where they overwrite the actual code. Here are the supported directives (with examples) in WLA: [ALL] - Both, GB-Z80 and Z80 versions apply. [GB ] - Only the GB-Z80 version applies. [Z80] - Only the Z80 version applies. Group 1: [ALL] .EMPTYFILL $C9 [ALL] .EXPORT work_x [GB ] .CARTRIDGETYPE 1 [GB ] .COMPUTECHECKSUM [GB ] .COMPUTECOMPLEMENTCHECK [GB ] .LICENSEECODENEW "1A" [GB ] .LICENSEECODEOLD $1A [GB ] .NAME "NAME OF THE ROM" [GB ] .RAMSIZE 0 [GB ] .ROMDMG [GB ] .ROMGBC [GB ] .ROMSGB [Z80] .FOOTER "abc.bin" [Z80] .HEADER "xyz.bin" Group 2: [ALL] .ASM [ALL] .BACKGROUND "parallax.gb" [ALL] .BANK 0 SLOT 1 [ALL] .ROMBANKSIZE $4000 [ALL] .DB 100, $30, %1000, "HELLO WORLD!" [ALL] .DBCOS 0.2, 10, 3.2, 120, 1.3 [ALL] .DBSIN 0.2, 10, 3.2, 120, 1.3 [ALL] .DEFINE IF $FF0F [ALL] .DSB 256 $10 [ALL] .DSW 128 20 [ALL] .DW 16000, 10, 255 [ALL] .DWCOS 0.2, 10, 3.2, 1024, 1.3 [ALL] .DWSIN 0.2, 10, 3.2, 1024, 1.3 [ALL] .ELSE [ALL] .ENDASM [ALL] .ENDE [ALL] .ENDIF [ALL] .ENDM [ALL] .ENDME [ALL] .ENDR [ALL] .ENDRO [ALL] .ENDS [ALL] .ENUM $C000 [ALL] .FAIL [ALL] .IF DEBUG == 2 [ALL] .IFDEF IF [ALL] .IFDEFM \2 [ALL] .IFEQ DEBUG 2 [ALL] .IFGR DEBUG 2 [ALL] .IFLE DEBUG 2 [ALL] .IFNDEF IF [ALL] .IFNDEFM \2 [ALL] .IFNEQ DEBUG 2 [ALL] .INCBIN "sorority.bin" [ALL] .INCDIR "/usr/programming/gb/include/" [ALL] .INCLUDE "cgb_hardware.i" [ALL] .MACRO TEST [ALL] .MEMORYMAP [ALL] .ORG $150 [ALL] .PRINTT "Here we are...\n" [ALL] .PRINTV DEC DEBUG+1 [ALL] .REDEFINE IF $F [ALL] .REPT 6 [ALL] .ROMBANKS 2 [ALL] .ROMBANKMAP [ALL] .SECTION "Init" FORCE [ALL] .UNDEF DEBUG Descriptions: ---- .ASM ---- Tells WLA to start assembling. Use .ASM to continue the work which has been disabled with .ENDASM. .ASM and .ENDASM can be used to mask away big blocks of code. This is analogous to the ANSI C -comments (/*...*/), but .ASM and .ENDASM can be nested, unlike the ANSI C -counterpart. This is not a compulsory directive. ------- .ENDASM ------- Tells WLA to stop assembling. Use .ASM to continue the work. This is not a compulsory directive. ----------------------------- .DBCOS 0.2, 10, 3.2, 120, 1.3 ----------------------------- Defines bytes just like .DSB does, only this time they are filled with cosine data. .DBCOS takes five arguments. The first argument is the starting angle. Angles range from 0 to 359, but you can supply WLA with values that are out of the range - WLA fixes them ok. The value can be integer or float. The second one descibes the amount of additional angles. The example will define 11 angles. The third one is the adder value which is added to the angle value when next angle is defined. The value can be integer or float. The fourth and fifth ones can be seen from the pseudo code below, which also describes how .DBCOS works. The values can be integer or float. .DBCOS A, B, C, D, E for (B++, B > 0; B--) { output_data((D * cos(A)) + E) A = keep_in_range(A + C) } This is not a compulsory directive. ----------------------------- .DBSIN 0.2, 10, 3.2, 120, 1.3 ----------------------------- Analogous to .DBCOS. ------------------------------ .DWCOS 0.2, 10, 3.2, 1024, 1.3 ------------------------------ Analogous to .DBCOS. ------------------------------ .DWSIN 0.2, 10, 3.2, 1024, 1.3 ------------------------------ Analogous to .DBCOS. ----------------------- .NAME "NAME OF THE ROM" ----------------------- Fills the 16 bytes ranging from $134 to $143 with the provided string. If the string is shorter than 16 bytes the remaining space is filled with $00. This is not a compulsory directive. ----------- .ROMBANKS 2 ----------- Indicates the size of the ROM in rombanks. This value is converted to a standard GB ROM size indicator value found at $148 in a GB ROM, and there this one is put into. This is a compulsory directive unless .ROMBANKMAP is defined. You can redefine .ROMBANKS as many times as you wish as long as the old and the new ROM bank maps match as much as possible. This way you can enlarge the size of the project on the fly. ---------- .RAMSIZE 0 ---------- Indicates the size of the RAM. This is a standard GB RAM size indicator value found at $149 in a GB ROM, and there this one is put to also. This is not a compulsory directive. -------------- .EMPTYFILL $C9 -------------- This byte is used in filling the unused areas of the ROM file. EMPTYFILL defaults to $00. This is not a compulsory directive. ---------------- .CARTRIDGETYPE 1 ---------------- Indicates the type of the cartridge (mapper and so on). This is a standard GB cartridge type indicator value found at $147 in a GB ROM, and there this one is put to also. This is not a compulsory directive. -------------------- .LICENSEECODEOLD $1A -------------------- This is a standard old licensee code found at $14B in a GB ROM, and there this one is put to also. .LICENSEECODEOLD cannot be defined with .LICENSEECODENEW. This is not a compulsory directive. --------------------- .LICENSEECODENEW "1A" --------------------- This is a standard new licensee code found at $144 and $145 in a GB ROM, and there this one is put to also. .LICENSEECODENEW cannot be defined with .LICENSEECODEOLD. $33 is inserted into $14B, as well. This is not a compulsory directive. ---------------- .COMPUTECHECKSUM ---------------- When this directive is used WLA computes the ROM checksum found at $14E and $14F in a GB ROM. This is not a compulsory directive. ----------------------- .COMPUTECOMPLEMENTCHECK ----------------------- When this directive is used WLA computes the ROM complement check found at $14D in a GB ROM. This is not a compulsory directive, but very recommended. ;) -------------------------------------- .INCDIR "/usr/programming/gb/include/" -------------------------------------- Changes the current include root directory. Use this to specify main directory for the following .INCLUDE and .INCBIN directives. If you want to change to the current working directory (WLA also defaults to this), use .INCDIR "" This is not a compulsory directive. ------------------------- .INCLUDE "cgb_hardware.i" ------------------------- Includes the specified file to the source file. This is not a compulsory directive. ---------------------- .INCBIN "sorority.bin" ---------------------- Includes the specified data file into the source file. .INCBIN caches all files into memory, so you can .INCBIN any data file millions of times, but it is loaded only once. You can optionally use SWAP after the file name, e.g. .INCBIN "kitten.bin" SWAP .INCBIN data is divided into blocks of two bytes, and inside every block the bytes are exchanged (like "SWAP r" does to nibbles). This requires that the size of the file is even. This is not a compulsory directive. ------------------------- .BACKGROUND "parallax.gb" ------------------------- This chooses an existing ROM image (parallax.gb in this case) as a background data for project. You can overwrite the data with OVERWRITE sections only. With .BACKGROUND defined you can leave away .ROMSIZE, .ROMTYPE and .RAMTYPE. .BACKGROUND can be used only when compiling a ROM image, not library or object file. .BACKGROUND is useful if you wish to patch an existing ROM image with new code or data. This is not a compulsory directive. ----- .FAIL ----- Terminates the compiling process. This is not a compulsory directive. ----------- .MACRO TEST ----------- Begins a macro called 'TEST'. WLA v6.4 introduced finally a nice little macro language that can handle macro parameters. You can use '\@' inside a macro to eg. separate a label from the other macro 'TEST' occurrences. '\@' is replaced with an integer number indicating the amount of times the macro has been called previously so it is unique to every macro call. Also, if you want to give parameters to a macro, you can use '\X' where X is the number of the argument. X ranges from 1 to 256, so you can give maximum of 256 parameters to a macro. Remember to use .ENDM to finish the macro definition. Note that you cannot do computations with arguments, eg. \1+\2 doesn't work. Another thing you cannot do is use .INCLUDE inside a macro. Here are some examples: .MACRO NOPMONSTER NOP NOP NOP .ENDM .MACRO LOAD_ABCD LD A, \1 LD B, \2 LD C, \3 LD D, \4 .INCBIN \5 .ENDM .MACRO QUEEN QUEEN\@: LD A, \1 LD B, \1 CALL QUEEN\@ .ENDM And here's how they can be used: ... NOPMONSTER NOPMONSTER ... LOAD_ABCD $10, $20, $30, XYZ, "merman.bin" QUEEN 123 Note that you must separate the arguments with commas. This is not a compulsory directive. ----- .ENDM ----- Ends the macro. This is not a compulsory directive, but when .MACRO is used this one is required to terminate it. -------------- .BANK 0 SLOT 1 -------------- Defines the ROM bank and the slot it is inserted into in the memory. You can also type the following: .BANK 0 This tells WLA to move into BANK 0 which will be put into the DEFAULTSLOT of .MEMORYMAP. This is a compulsory directive. ------------------ .ROMBANKSIZE $4000 ------------------ Defines the ROM bank size. Old syntax is ".BANKSIZE x". This is a compulsory directive unless .ROMBANKMAP is defined. --------- .ORG $150 --------- Defines the starting address. The value supplied here is relative to the ROM bank given with .BANK. This is a compulsory directive. ------------ .DSB 256 $10 ------------ Defines 256 bytes of $10. This is not a compulsory directive. ----------- .DSW 128 20 ----------- Defines 128 words (two bytes) of 20. This is not a compulsory directive. ----------------------------------- .DB 100, $30, %1000, "HELLO WORLD!" ----------------------------------- Defines bytes. This is not a compulsory directive. ------------------ .DW 16000, 10, 255 ------------------ Defines words (two bytes each). .DW takes only numbers and characters as input, not strings. This is not a compulsory directive. ---------------- .DEFINE IF $FF0F ---------------- Assigns a number to a string. This is all it can do, nothing else. Defined strings can only be found amid the GB-Z80 code. By default all defines are local to the file where they are presented. If you want to make the definition visible to all the files in the project, use .EXPORT. This is not a compulsory directive. ---------------- .REDEFINE IF $0F ---------------- Assigns a new value to an old definition. If the definition doesn't exist, REDEFINE performs DEFINE's work. When used with .REPT REDEFINE helps creating tables: .DEFINE CNT 0 .REPT 256 .DB CNT .REDEFINE CNT CNT+1 .ENDR This is not a compulsory directive. -------------- .IF DEBUG == 2 -------------- If the condition is fulfilled the following piece of code is acknowledged until .ENDIF/.ELSE occurs in the text, otherwise it is skipped. Operands must be immediate values. The following operators are supported: < - smaller than > - greater than == - equals to != - doesn't equal to All IF (yes, including .IFDEF, .IFNDEF, etc) directives can be nested. This is not a compulsory directive. --------- .IFDEF IF --------- If "IF" is defined, then the following piece of code is acknowledged until .ENDIF/.ELSE occurs in the text, otherwise it is skipped. This is not a compulsory directive. ------------ .UNDEF DEBUG ------------ Removes the supplied definition label from system. If there is no such label as given no error is displayed as the result would be the same. This is not a compulsory directive. ---------- .IFNDEF IF ---------- If "IF" is not defined, then the following piece of code is acknowledged until .ENDIF/.ELSE occurs in the text, otherwise it is skipped. This is not a compulsory directive. ---------- .IFDEFM \2 ---------- If the specified argument is defined (argument number two, in the example), then the following piece of code is acknowledged until .ENDIF/.ELSE occurs in the macro, otherwise it is skipped. This is not a compulsory directive. .IFDEFM works only inside a macro. ----------- .IFNDEFM \2 ----------- If the specified argument is not defined, then the following piece of code is acknowledged until .ENDIF/.ELSE occurs in the macro, otherwise it is skipped. This is not a compulsory directive. .IFNDEFM works only inside a macro. ------------- .IFEQ DEBUG 2 ------------- If the value of DEBUG equals to 2, then the following piece of code is acknowledged until .ENDIF/.ELSE occurs in the text, otherwise it is skipped. Both arguments can be computations, defines or immediate values. This is not a compulsory directive. -------------- .IFNEQ DEBUG 2 -------------- If the value of DEBUG doesn't equal to 2, then the following piece of code is acknowledged until .ENDIF/.ELSE occurs in the text, otherwise it is skipped. Both arguments can be computations, defines or immediate values. This is not a compulsory directive. ------------- .IFLE DEBUG 2 ------------- If the value of DEBUG is less than 2, then the following piece of code is acknowledged until .ENDIF/.ELSE occurs in the text, otherwise it is skipped. Both arguments can be computations, defines or immediate values. This is not a compulsory directive. ------------- .IFGR DEBUG 2 ------------- If the value of DEBUG is greater than 2, then the following piece of code is acknowledged until .ENDIF/.ELSE occurs in the text, otherwise it is skipped. Both arguments can be computations, defines or immediate values. This is not a compulsory directive. ----- .ELSE ----- If the previous .IFxxx failed then the following text until .ENDIF is acknowledged. This is not a compulsory directive. ------ .ENDIF ------ This terminates any .IFxxx directive. This is not a compulsory directive, but if you use any .IFxxx then you need also to apply this. ------- .REPT 6 ------- Repeats the text enclosed between ".REPT x" and ".ENDR" x times (6 in this example). Repetition text size is at max 2048 bytes. This is not a compulsory directive. ----- .ENDR ----- Ends the repetition. This is not a compulsory directive, but when .REPT is used this one is required to terminate it. ----------- .ENUM $C000 ----------- Starts enumeration from $C000. Very useful for defining variables. Here's an example: ... .ENUM $A000 _scroll_x DB _scroll_y DB player_x DW player_y DW map_01 DS 1024 map_02 DS 2048 .ENDE ... Previous example transforms into following definitions: .DEFINE _scroll_x $A000 .DEFINE _scroll_y $A001 .DEFINE player_x $A002 .DEFINE player_y $A004 .DEFINE map_01 $A006 .DEFINE map_02 $A406 This is not a compulsory directive. ----- .ENDE ----- Ends the enumeration. This is not a compulsory directive, but when .ENUM is used this one is required to terminate it. ---------- .MEMORYMAP ---------- Begins the memory map definition. Using .MEMORYMAP you must first describe the target system's memory architecture to WLA before it can start to compile the code. .MEMORYMAP gives you the freedom to use WLA Z80 to compile data for numerous different real Z80 based systems. Examples: .MEMORYMAP SLOTSIZE $4000 DEFAULTSLOT 2 SLOT 0 $0000 SLOT 1 $4000 .ENDME .MEMORYMAP DEFAULTSLOT 1 SLOTSIZE $6000 SLOT 0 $0000 SLOTSIZE $2000 SLOT 1 $6000 SLOT 2 $8000 .ENDME SLOTSIZE defines the size of the following slots. You can redefine it as many times as you wish, like in the second example. DEFAULTSLOT describes the default slot for banks which aren't explicitly inserted anywhere. Check .BANK definition for more information. SLOT defines a slot and its starting address. SLOT numbering starts at 0 and ends to 255 so you have 256 slots at your disposal. This is a compulsory directive, and make sure all the object files share the same .MEMORYMAP or you can't link them together. ------ .ENDME ------ Ends the memorymap. This is not a compulsory directive, but when .MEMORYMAP is used this one is required to terminate it. ----------- .ROMBANKMAP ----------- Begins the ROM bank map definition. You can use this directive to describe the project's ROM banks. Use .ROMBANKMAP when not all the ROM banks are of equal size. Note that you can use .ROMBANKSIZE and .ROMBANKS instead of .ROMBANKMAP, but that's only when the ROM banks are equal in size. Some systems based on a real Z80 chip and Pocket Voice cartridges for Game Boy require the usage of this directive. Examples: .ROMBANKMAP BANKSTOTAL 16 BANKSIZE $4000 BANKS 16 .ENDRO .ROMBANKMAP BANKSTOTAL 510 BANKSIZE $6000 BANKS 1 BANKSIZE $2000 BANKS 509 .ENDRO The first one describes an ordinary ROM image of 16 equal sized banks. The second one defines a 4MB Pocket Voice ROM image. In the PV ROM image the first bank is $6000 bytes and the remaining 509 banks are smaller ones, $2000 bytes each. BANKSTOTAL tells the total amount of ROM banks. It must be defined prior to anything else. BANKSIZE tells the size of the following ROM banks. You can supply WLA with BANKSIZE as many times as you wish. BANKS tells the amount of banks that follow and that are of the size BANKSIZE which has been previously defined. This is not a compulsory directive when .ROMBANKSIZE and .ROMBANKS are defined. You can redefine .ROMBANKMAP as many times as you wish as long as the old and the new ROM bank maps match as much as possible. This way you can enlarge the size of the project on the fly. ------ .ENDRO ------ Ends the rom bank map. This is not a compulsory directive, but when .ROMBANKMAP is used this one is required to terminate it. --------------------- .SECTION "Init" FORCE --------------------- Begins a section called "Init". Before a section can be declared, .BANK and .ORG must be used unless WLA is in library file output mode. Library file's sections must all be FREE ones. .BANK tells the bank number where this section will be later relocated into. .ORG tells the offset for the relocation from the beginning of .BANK. FORCE after the name of the section tells WLA that the section _must_ be inserted so it starts at .ORG. FORCE can be replaced with FREE which means that the section can be inserted somewhere in the defined bank, where there is room. You can also use OVERWRITE to insert the section into the memory regardless of data collisions. Using OVERWRITE you can easily patch an existing ROM image just by .BACKGROUND'ing the data and inserting an OVERWRITE section into it. SEMIFREE sections are also possible and they behave much like FREE sections. The only difference is that they are positioned somewhere in the bank starting from .ORG. You can also leave away the type specifier as the default type for the section is FREE. You can name the sections as you wish, but there is one special name. A section called "BANKHEADER" is placed in the front of the bank where it is defined. These sections contain data that is not in the memory map of the machine, so you can't refer to the data of a BANKHEADER section, but you can write references to outside. So no labels inside BANKHEADER sections. These special sections are useful when writing eg. MSX programs. Note that library files don't take BANKHEADER sections. Here's an example of a "BANKHEADER" section: ... .BANK 0 .ORG 0 .SECTION "BANKHEADER" .DW MAIN .DW VBI .ENDS .SECTION "Program" MAIN: CALL monty_on_the_run VBI: PUSH HL ... POP HL RETI .ENDS Here's an example of an ordinary section: ... .BANK 0 .ORG $150 .SECTION "Init" FREE DI LD SP, $FFFE SUB A LD ($FF00+R_IE), A .ENDS ... This tells WLA that a FREE section called "Init" must be located somewhere in bank 0. If you replace FREE with SEMIFREE the section will be inserted somewhere in the bank 0, but not in the $0-$14F area. This is not a compulsory directive. ----- .ENDS ----- Ends the section. This is not a compulsory directive, but when .SECTION is used this one is required to terminate it. ------- .ROMGBC ------- Inserts data into the specific ROM location to mark the ROM as a GBC ROM ($C0 -> $0143, so ROM name is max. 15 characters long). This is not a compulsory directive. ------- .ROMDMG ------- Inserts data into the specific ROM location to mark the ROM as a DMG ROM ($00 -> $0146). This is not a compulsory directive. .ROMDMG cannot be used with .ROMSGB. ------- .ROMSGB ------- Inserts data into the specific ROM location to mark the ROM as a SGB enhanced ROM ($03 -> $0146). This is not a compulsory directive. .ROMSGB cannot be used with .ROMDMG. -------------- .EXPORT work_x -------------- Exports the definition "work_x" to outside. .EXPORT can only be used inside object and library files. Exported definitions are visible to all object files and libraries in the linking procedure. This is not a compulsory directive. ----------------- .HEADER "xyz.bin" ----------------- Uses the file "xyz.bin" as a header for the ROM image. HEADER can only be used in ROM output mode and with wla-z80. This is not a compulsory directive. ----------------- .FOOTER "abc.bin" ----------------- Uses the file "abc.bin" as a footer for the ROM image. FOOTER can only be used in ROM output mode and with wla-z80. This is not a compulsory directive. -------------------------- .PRINTT "Here we are...\n" -------------------------- Prints the given text into stdout. Good for debugging stuff. PRINTT takes only a string as argument, and the only supported formatting symbol is '\n' (line feed). This is not a compulsory directive. ------------------- .PRINTV DEC DEBUG+1 ------------------- Prints the value of the supplied definition or computation into stdout. Computation must be solvable at the time of printing (just like definitions values). PRINTV takes two parameters. The first describes the type of the print output. "DEC" means decimal, "HEX" means hexadecimal. Use PRINTV with PRINTT as PRINTV doesn't print linefeeds, only the result. Here's an example: .PRINTT "Value of DEBUG = $" .PRINTV HEX DEBUG .PRINTT "\n" This is not a compulsory directive. ------------------------------------------------------------------------------ 7... Assembler Syntax ------------------------------------------------------------------------------ 7.1. Case Sensitivity WLA is case sensitive, so be careful. By default directives are not case sensitive. If you wish to speed up compiling, use uppercase directives and flag 'u'. 7.2. Comments Comments begin with ';' or '*' and end along with the line. ';' can be used anywhere, but '*' can be placed only at the beginning of a new line. Version 4.1 of WLA introduced ANSI-C -like commenting. This means you can start a multiline comment with "/*" and end it with "*/". Version 6.0 of WLA introduced .ASM and .ENDASM directives. These function much like ANSI-C comments, but unlike the ANSI-C comments these can be nested. 7.3. Labels Labels are ordinary strings that end to ':'. Labels starting with "_" are considered as local labels and do not show outside sections where they were defined, or outside object files, if they were not defined inside a section. Here are few examples of different labels: VBI_IRQ: _VBI_LOOP: main: 7.4. Number Types 1000 - decimal. $100 - hexadecimal. %100 - binary. 'x' - character. All numbers must be integers. *SIN/*COS -families are expections as they take real numbers as some of their arguments. 7.5. Strings Strings begin and end to '"'. Note that no 0 is inserted to indicate the termination of the string like in eg. C. You'll have to do it yourself. 7.6. Supported Z80 commands Check out the file "gb-z80.txt" for GB-Z80 and "z80.txt" for Z80 coming with this archive. Additionally there is a command called "DEBUG" which will translate to $ED. This one is not used in real GB-Z80, but my Game Boy emulator, Wzonka-Lad, will invert the power light mode when $ED is executed. Don't use DEBUG if you are going to use your code elsewhere! 7.7. Brackets? With v4.6+ of WLA brackets are also supported in the GB-Z80/Z80 syntax. So you can write LDI (HL), A or LDI [HL], A Yes, you could write LDI [HL), A but I don't recommend that. ;) ------------------------------------------------------------------------------ 8... Error Messages ------------------------------------------------------------------------------ There are quite a few of them in WLA, but most of them are not as informative as I would like them to be. This will be fixed in the future. Mean while, be careful. ;) ------------------------------------------------------------------------------ 9... Supported Types ------------------------------------------------------------------------------ 9.1. ROM Size GB-Z80 version of WLA supports the following ROM bank sizes. There's no such limit in the Z80 version of WLA. Supply one of the following values to .ROMBANKS. $0 - 256Kbit = 32KByte = 2 banks $1 - 512Kbit = 64KByte = 4 banks $2 - 1Mbit = 128KByte = 8 banks $3 - 2Mbit = 256KByte = 16 banks $4 - 4Mbit = 512KByte = 32 banks $5 - 8Mbit = 1MByte = 64 banks $6 - 16Mbit = 2MByte = 128 banks $52 - 9Mbit = 1.1MByte = 72 banks $53 - 10Mbit = 1.2MByte = 80 banks $54 - 12Mbit = 1.5MByte = 96 banks 9.2. RAM Size Supply one of the following hex values to .RAMSIZE in the GB-Z80 version of WLA. $0 - None $1 - 16kbit = 2kByte = 1 bank $2 - 64kbit = 8kByte = 1 bank $3 - 256kbit = 32kByte = 4 banks $4 - 1Mbit = 128kByte = 16 banks 9.3. Cartridge Type It's up to the user to check that the cartridge type is valid and can be used combined with the supplied ROM and RAM sizes. Give one the the following values to .CARTRIDGETYPE in the GB-Z80 version of WLA. $0 - ROM ONLY $1 - ROM+MBC1 $2 - ROM+MBC1+RAM $3 - ROM+MBC1+RAM+BATT $5 - ROM+MBC2 $6 - ROM+MBC2+BATTERY $8 - ROM+RAM $9 - ROM+RAM+BATTERY $B - ROM+MMM01 $C - ROM+MMM01+SRAM $D - ROM+MMM01+SRAM+BATT $F - ROM+MBC3+TIMER+BATT $10 - ROM+MBC3+TIMER+RAM+BATT $11 - ROM+MBC3 $12 - ROM+MBC3+RAM $13 - ROM+MBC3+RAM+BATT $19 - ROM+MBC5 $1A - ROM+MBC5+RAM $1B - ROM+MBC5+RAM+BATT $1C - ROM+MBC5+RUMBLE $1D - ROM+MBC5+RUMBLE+SRAM $1E - ROM+MBC5+RUMBLE+SRAM+BATT $1F - Pocket Camera $BE - Pocket Voice $FD - Bandai TAMA5 $FE - Hudson HuC-3 $FF - Hudson HuC-1 ------------------------------------------------------------------------------ 10.. Bugs ------------------------------------------------------------------------------ If you find bugs, please let me know asap. Anything, small or big, send me email! ------------------------------------------------------------------------------ 11.. Files ------------------------------------------------------------------------------ 11.1. 'examples' The main purpose of the files in the 'examples' directory is to teach people few things about WLA. If you feel a little uncertain with the syntax check out this place. 'examples' directory holds two directories, 'gb' and 'z80'. 'include' directory under 'gb' could be very useful as the five include files there have all the Game Boy hardware register address and memory definitions you could ever need and more. 11.2. 'lib' This folder holds few very useful libraries for you to use in your Game Boy projects. Instead of reinventing the wheel, use the stuff found in here. Remember to compile the libraries right after you've installed WLA by executing 'make' in the 'lib' directory. ------------------------------------------------------------------------------ 12.. Temporary Files ------------------------------------------------------------------------------ Note that WLA will generate two temporary files while it works. Make sure the directories where the temporary files are generated to exist. On Amiga machines these files are placed in T: and are called "gba_a.tmp" and "gba_b.tmp". On Linux x86 systems these files are placed in /tmp/ and are called ".gba_a.tmp" and ".gba_b.tmp". On MSDOS x86 machines these files are placed in the working directory and are called "GBA_A.TMP" and "GBA_B.TMP". So remember not to use more than one WLA process at a time. I will be honoured to fix this, but it requires a request from a WLA Power User. ;) When WLA finishes its work these two files are deleted as they serve of no further use. ------------------------------------------------------------------------------ 13.. Compiling ------------------------------------------------------------------------------ 13.1. Compiling ROM images To compile a ROM image from an asm file use the following: "wla -[fstuv]r [OUTPUT FILE]" One asm file (or more included in the main asm file), one ROM image. Simple, but not very flexible. Compile object files and link them together in the case of a bigger project. 13.2. Compiling Object Files Version 2.0 of WLA introduced object files. To compile an object file use: "wla -[ftuv]o [OUTPUT FILE]" These object files can be linked together (or with library files) later with "wlalink". Name object files so that they can be recognized as object files. Normal suffix is ".o" (WLA default). With object files you can reduce the amount of compiling when editing small parts of the program. Note also the possibility of using local labels (starting with "_"). Note! When you compile objects, group 1 directives are saved for linking time, when they are all compared and if they differ, an error message is shown. It is advisable to use something like an include file to hold all the group 1 directives for that particular project and include it to every object file. If you are interested in the WLA object file format, take a look at the file "wla_file_formats.txt" which is included in the release archive. 13.3. Compiling Compact Object Files Version 3.0 of WLA introduced compact object files. To compile a compact object file use: "wla -[ftuv]co [OUTPUT FILE]" Compact object files are just like object files, but the local labels are made as small as possible by renaming them to short, cryptic strings like "_a" and "_9e" to save space. 13.4. Compiling Library Files Version 2.3 of WLA introduced library files. To compile a library file use: "wla -[cftuv]l [OUTPUT FILE]" Name object files so that they can be recognized as library files. Normal suffix is ".lib" (WLA default). With library files you can reduce the amount of compiling. Library files are meant to hold general functions that can be used in different projects. Note also the possibility of using local labels (starting with "_"). Library files consist only of FREE sections. 13.5. Compiling Compact Library Files Version 3.0 of WLA introduced compact library files. To compile a compact library file use: "wla -[ftuv]cl [OUTPUT FILE]" Compact library files are just like library files, but the local labels are made as small as possible by renaming them to short, cryptic strings like "_a" and "_9e" to save space. 13.6. Compiling Program Files Version 6.0 of WLA Z80 introduced program files. Program file's size is arbitrary and defined by the amount of compiled data. Let's say you give 32KB bounds (rom size) to WLA and have two sections in it, one starting at 0 and ending at 100, the other starting at 200 and ending at 511. If WLA was to make a program compile out of this, you'd end up having a file of 512 bytes worth your data. It'd have 98 unused bytes also. Anyway, I guess you'll get the idea. ;) To compile a program file, write: "wla -[fstuv]b [OUTPUT FILE]" All ROM image compiling rules apply to program file compiling. Note that depending on the destination system your result program file might need a header of some kind. Use "BANKHEADER" section for bank 0 to achieve this. Also note that to achieve the most compact program file make all your sections FREE ones or don't use sections at all. This way you will avoid the gaps between static and free sections. ------------------------------------------------------------------------------ 14.. Arithmetics ------------------------------------------------------------------------------ With the coming of WLA DX v6.2 WLA has been able to solve complex calculations like -((HELLO / 2) | 3) and skeletor_end-skeletor Before v6.2 there were severe limitations in the computation sentences, but those are void forever. ;) So now you can type something like LD HL, data_end-data LD A, (pointer + 1) CP (TEST + %100) & %10101010 WLALINK also has this ability so it can compute the pending calculations WLA wasn't able to solve. The following operators are valid: (, ), | (or), & (and), ^ (power), << (shift left), >> (shift right), +, -, # (modulo), * and /. WLA computes internally with real numbers so (5/2)*2 produces 5, not 4. ------------------------------------------------------------------------------ 15.. Linking ------------------------------------------------------------------------------ After you have produced one or more object files and perhaps some library files, you might want to link them together to produce a ROM image. "wlalink" is the program you use for that. Here's how you use it: "wlalink [-vs] " Link file is a text file which contains information about the files you want to link together. Here's the format: 1. You must define the group for the files. Put the name of the group inside brackets. Valid group definitions are [objects] [libraries] Z80 linking will also support these two: [header] [footer] 2. Start to list the file names. [objects] main.o vbi.o level_01.o ... 3. Give parameters to the library files: [libraries] bank 0 slot 1 speed.lib bank 4 slot 2 map_data.lib ... You must tell WLALINK the bank and the slot for the library files. 4. If you want to use header and/or footer in your Z80 project, you can type the following: [header] header.dat [footer] footer.dat If flag "v" is used, WLALINK displays information about ROM file after a succesful linking. If flag "s" is used, WLALINK will produce a NO$GMB symbol file. It's useful when you work under MSDOS (NO$GMB is a very good Game Boy emulator for MSDOS/ Windows) as it contains information about the labels in your project. Make sure you don't create duplicate labels in different places in Game Boy memory map as they break the linking loop. Duplicate labels are allowed when they overlap each other in the destination machine's memory. Look at the following example: ... .BANK 0 .ORG $150 ... LD A, 1 CALL LOAD_LEVEL ... LOAD_LEVEL: LD HL, $2000 LD (HL), A CALL INIT_LEVEL RET .BANK 1 .ORG 0 INIT_LEVEL: ... RET .BANK 2 .ORG $0 INIT_LEVEL: ... RET ... Here duplicate INIT_LEVEL labels are accepted as they both point to the same memory address. ------------------------------------------------------------------------------ 16.. Disassembling ------------------------------------------------------------------------------ WLAD is a disassembler that can be used to disassemble an existing ROM image into a WLA-syntax compatible source file. It won't produce very readable code as all the labels etc. are discarded in the last phase of linking when the ROM image is made. In the current state WLAD doesn't generate labels, but it will in the future. Here's how you use it: "wlad [-dsa] " Give it the binary file (usually the extension is .gb or .cgb) and WLAD will output the source code into stdout (the shell you are using). Here's an example what you can do if you want the source code into a file instead of the screen: "wlad tbp.cgb > tbp.s" WLAD has three option flags: a - Disable address output. d - The upper banks (1->) are disassembled as data. s - The upper banks (1->) are disassembled as data with string detection enabled. Use the 's'-flag if you intend to change texts in games. The flags 'd' and 's' cannot be used at the same time. Examples: [root@jaakkopotti parallax]# wlad -da parallax.gb > parallax.s [root@jaakkopotti parallax]# wlad -s parallax.gb > parallax.s WLAD supports both normal ROMs and Pocket Voice (tm) ROM images. Only WLAD GB-Z80 exists curently, Z80 version is under work. ------------------------------------------------------------------------------ 17.. Binary to DB Conversion ------------------------------------------------------------------------------ WLAB converts binary files to WLA's byte definition strings. Here's how you use it: "wlab -[ap]{bdh} " Give it the binary file and WLAB will output the WLA DB formatted data of it into stdout. Here's an example from real life: "wlad -da gayskeletor.bin > gayskeletor.s" WLAB has three command flags of which one must be given to WLAB: b - Output data in binary format. d - Output data in decimal format. h - Output data in hexadecimal format. WLAB has also two option flags: a - Print the address (relative to the beginning of the data). p - Don't print file header. Examples: [root@jaakkopotti src]# wlab -bap iscandar.bin > iscandar.s [root@jaakkopotti src]# wlab -h starsha.bin > starsha.s ------------------------------------------------------------------------------ 18.. Pocket Voice ------------------------------------------------------------------------------ Pocket Voice uses its own MBC. You can enable Pocket Voice mode by selecting Pocket Voice cartridge type ($BE in $0147) and defining correct .ROMBANKMAP and .MEMORYMAP. In PV mode bank 0 is 24KB and the rest are 8KB. Note that WLA assumes that ROM offset is all the time 0. If you use something else as the offset, make sure to compute the jumps by hand as WLA cannot do that. Check out examples/gb/includes/pocket_voice.i for more information. ------------------------------------------------------------------------------ 19.. WLA Flags ------------------------------------------------------------------------------ Here are short descriptions for the flags you can give to WLA: You can supply WLA with some (or all or none) of the following option flags. c - Compact mode. Can be used when compiling a library or an object. Minimizes the size of the local labels. f - Fast mode. Turns on the old error messaging engine (v3.0-), which lacks among other things line numbers. Fast is fast, but for advanced users only. s - Output NO$GMB symbol file. Targetted to people who want to do some GB debugging. Works only when compiling a ROM image. WLA GB-Z80 has this flag, not the Z80 version. t - Test compile. Doesn't output any files. u - Opcodes are written with uppercase letters. This will speed up compiling process, but all the opcodes must be written with uppercase letters. v - Verbose mode. Shows a lot of information about the compiling process. One (and only one) of the following command flags must be defined. l - Output a library file. o - Output an object file. r - Output a ROM image. b - Output program file (only in WLA Z80). Examples: [root@jaakkopotti tbp]# wla -vucfo testa.s [root@jaakkopotti tbp]# wla -fcl testb.s testb.lib [root@jaakkopotti tbp]# wla -vr testc.s mygame.gb Note that the first example produces file named "testa.o". ------------------------------------------------------------------------------ 20.. Author ------------------------------------------------------------------------------ Ville Helin, the author of Wzonka-Lad, a Game Boy emulator for the Amiga machines. I have 23 years behind me, many more to travel through. I study information technology at the Helsinki University of Technology (http://www.hut.fi). I like Game Boy (goes without saying), anime soap operas, Japanese culture and monkey kung-fu Tai Shin Mun. email: vhelin@cc.hut.fi hpage: http://www.hut.fi/~vhelin smail: Ville Helin Dagmarinkatu 8 C 38 00100 Helsinki Finland ------------------------------------------------------------------------------ 21.. Thanks ------------------------------------------------------------------------------ Biggest thanks to Gaelan Griffin for endless suggestions and fast bug reports! Thanks to Madonna MkII (Matra Computer Corp.), Mike Blum, Anders Montonen and Arto Salmi for reporting bugs in WLA and providing me with great ideas. Thanks to Mark Knox, Igor Wronsky and Anders Montonen for helping me with the MSDOS port! Thanks to Clem for the BeOS port! Thanks to Gaelan Griffin for the Amiga port! Thanks to people at gameboy@vip.co.za for keeping up the good work! ;) ------------------------------------------------------------------------------ 22.. Future ------------------------------------------------------------------------------ Future enhancements (if I get really inspired): - Much more features to WLAD (I already know of three) and Z80 support. - Other optimizations, bug fixes and new features. - Game Boy Advance version. - You tell me. ------------------------------------------------------------------------------ 23.. Support ------------------------------------------------------------------------------ The currently supported systems are MSDOS/x86, AmigaOS/680x0, Linux/x86. If you'd like to see WLA for other platforms/configurations, send me email and we'll see what I can do about it. All x86 versions are compiled for 486+ (with -m486). BeOS/x86 is currently discontinued. ------------------------------------------------------------------------------ 24.. Legal Note ------------------------------------------------------------------------------ WLA GB-Z80/Z80 Macro Assembler Copyright 1998-2000 Ville Helin WLAB GB-Z80/Z80 Binary to WLA DB Converter Copyright 2000 Ville Helin WLAD GB-Z80 Disassembler Copyright 2000 Ville Helin WLALINK GB-Z80/Z80 Macro Assembler Linker Copyright 2000 Ville Helin I take no responsibility what WLA, WLAB, WLAD or WLALINK do on your machine. Remember that when using WLA, WLAB, WLAD or WLALINK you do it at your own risk. WLA, WLAB, WLAD and WLALINK are freeware as long as it is used to produce non-commercial software. WLA, WLAB, WLAD or WLALINK cannot be used in any commercial project without my permission. If and when WLA, WLAB, WLAD or/and WLALINK are used in a commercial project, I want something as well, like the finished product. ;) Or credits would be nice. ;) Something, so I know there are people using WLA. WLA, WLAB, WLAD or WLALINK may not be put on any CD DISC or HD DISK or any other form of media for distribution unless I myself grant the premission. If I am not contacted before WLA, WLAB, WLAD or WLALINK is used in a process that involves money, then may the seven drunken Gods strike such a foul business down! If the Gods won't do me a favor, I'll ask Monkey King and come and do my Kung-Fu. Game Boy and Game Boy Color are copyrighted by Nintendo. Pocket Voice is copyrighted by Bung HK.