diff options
author | ISSOtm <eldredhabert0@gmail.com> | 2018-05-27 01:19:23 +0200 |
---|---|---|
committer | ISSOtm <eldredhabert0@gmail.com> | 2018-05-27 01:32:42 +0200 |
commit | 022a418e1080145189f4282861d6706f739eae44 (patch) | |
tree | 326fd7fdfb583164118cc3606c25ef2f13af6ff4 | |
parent | c48cf5565c9ece114d41abc913e7649e118ca4e6 (diff) |
Add constants and macros
-rw-r--r-- | charmap.asm | 249 | ||||
-rw-r--r-- | constants.asm | 6 | ||||
-rw-r--r-- | constants/gfx_constants.asm | 58 | ||||
-rw-r--r-- | constants/hardware_constants.asm | 161 | ||||
-rw-r--r-- | home.asm | 2 | ||||
-rw-r--r-- | macros.asm | 1 | ||||
-rw-r--r-- | macros/enum.asm | 53 | ||||
-rw-r--r-- | main.asm | 4 | ||||
-rw-r--r-- | wram.asm | 4 |
9 files changed, 538 insertions, 0 deletions
diff --git a/charmap.asm b/charmap.asm new file mode 100644 index 0000000..1d25197 --- /dev/null +++ b/charmap.asm @@ -0,0 +1,249 @@ +; $00-$16 are TX_* constants (see macros/scripts/text.asm) + +; Control characters (see home/text.asm) + + charmap "<PLAY_G>", $14 ; "<PLAYER>くん" or "<PLAYER>ちゃん"; same as "<PLAYER>" in English + charmap "¯", $1f ; soft linebreak + charmap "<LNBRK>", $22 + charmap "<POKE>", $24 ; "<PO><KE>" + charmap "%", $25 ; soft linebreak in landmark names + charmap "<RED>", $38 ; wRedsName + charmap "<GREEN>", $39 ; wGreensName + charmap "<ENEMY>", $3f + charmap "<MOM>", $49 ; wMomsName + charmap "<PKMN>", $4a ; "<PK><MN>" + charmap "<_CONT>", $4b ; implements "<CONT>" + charmap "<SCROLL>", $4c + charmap "<NEXT>", $4e + charmap "<LINE>", $4f + charmap "@", $50 ; string terminator + charmap "<PARA>", $51 + charmap "<PLAYER>", $52 ; wPlayerName + charmap "<RIVAL>", $53 ; wRivalName + charmap "#", $54 ; "POKé" + charmap "<CONT>", $55 + charmap "<……>", $56 ; "……" + charmap "<DONE>", $57 + charmap "<PROMPT>", $58 + charmap "<TARGET>", $59 + charmap "<USER>", $5a + charmap "<PC>", $5b ; "PC" + charmap "<TM>", $5c ; "TM" + charmap "<TRAINER>", $5d ; "TRAINER" + charmap "<ROCKET>", $5e ; "ROCKET" + charmap "<DEXEND>", $5f + +; Actual characters (from other graphics files) + + ; needed for _LoadFontsExtra1 (see engine/load_font.asm) + charmap "■", $60 ; gfx/font/black.2bpp + charmap "▲", $61 ; gfx/font/up_arrow.png + charmap "☎", $62 ; gfx/font/phone_icon.2bpp + +; Japanese control characters (see home/text.asm) + + charmap "<JP_18>", $18 ; "ノ゛"? (ungrammatical) + charmap "<NI>", $1d ; "に " + charmap "<TTE>", $1e ; "って" + charmap "<WO>", $1f ; "を " + charmap "<TA!>", $22 ; "た!" + charmap "<KOUGEKI>", $23 ; "こうげき" + charmap "<WA>", $24 ; "は " + charmap "<NO>", $25 ; "の " + charmap "<ROUTE>", $35 ; "ばん どうろ" + charmap "<WATASHI>", $36 ; "わたし" + charmap "<KOKO_WA>", $37 ; "ここは" + charmap "<GA>", $4a ; "が " + +; Japanese kana + + charmap "ガ", $05 + charmap "ギ", $06 + charmap "グ", $07 + charmap "ゲ", $08 + charmap "ゴ", $09 + charmap "ザ", $0a + charmap "ジ", $0b + charmap "ズ", $0c + charmap "ゼ", $0d + charmap "ゾ", $0e + charmap "ダ", $0f + charmap "ヂ", $10 + charmap "ヅ", $11 + charmap "デ", $12 + charmap "ド", $13 + + charmap "バ", $19 + charmap "ビ", $1a + charmap "ブ", $1b + charmap "ボ", $1c + + charmap "が", $26 + charmap "ぎ", $27 + charmap "ぐ", $28 + charmap "げ", $29 + charmap "ご", $2a + charmap "ざ", $2b + charmap "じ", $2c + charmap "ず", $2d + charmap "ぜ", $2e + charmap "ぞ", $2f + charmap "だ", $30 + charmap "ぢ", $31 + charmap "づ", $32 + charmap "で", $33 + charmap "ど", $34 + + charmap "ば", $3a + charmap "び", $3b + charmap "ぶ", $3c + charmap "べ", $3d + charmap "ぼ", $3e + + charmap "パ", $40 + charmap "ピ", $41 + charmap "プ", $42 + charmap "ポ", $43 + charmap "ぱ", $44 + charmap "ぴ", $45 + charmap "ぷ", $46 + charmap "ぺ", $47 + charmap "ぽ", $48 + + charmap "「", $70 + charmap "」", $71 + charmap "』", $73 + charmap "⋯", $75 + + charmap " ", $7f + + charmap "ア", $80 + charmap "イ", $81 + charmap "ウ", $82 + charmap "エ", $83 + charmap "オ", $84 + charmap "カ", $85 + charmap "キ", $86 + charmap "ク", $87 + charmap "ケ", $88 + charmap "コ", $89 + charmap "サ", $8a + charmap "シ", $8b + charmap "ス", $8c + charmap "セ", $8d + charmap "ソ", $8e + charmap "タ", $8f + charmap "チ", $90 + charmap "ツ", $91 + charmap "テ", $92 + charmap "ト", $93 + charmap "ナ", $94 + charmap "ニ", $95 + charmap "ヌ", $96 + charmap "ネ", $97 + charmap "ノ", $98 + charmap "ハ", $99 + charmap "ヒ", $9a + charmap "フ", $9b + charmap "ホ", $9c + charmap "マ", $9d + charmap "ミ", $9e + charmap "ム", $9f + charmap "メ", $a0 + charmap "モ", $a1 + charmap "ヤ", $a2 + charmap "ユ", $a3 + charmap "ヨ", $a4 + charmap "ラ", $a5 + charmap "ル", $a6 + charmap "レ", $a7 + charmap "ロ", $a8 + charmap "ワ", $a9 + charmap "ヲ", $aa + charmap "ン", $ab + charmap "ッ", $ac + charmap "ャ", $ad + charmap "ュ", $ae + charmap "ョ", $af + charmap "ィ", $b0 + + charmap "あ", $b1 + charmap "い", $b2 + charmap "う", $b3 + charmap "え", $b4 + charmap "お", $b5 + charmap "か", $b6 + charmap "き", $b7 + charmap "く", $b8 + charmap "け", $b9 + charmap "こ", $ba + charmap "さ", $bb + charmap "し", $bc + charmap "す", $bd + charmap "せ", $be + charmap "そ", $bf + charmap "た", $c0 + charmap "ち", $c1 + charmap "つ", $c2 + charmap "て", $c3 + charmap "と", $c4 + charmap "な", $c5 + charmap "に", $c6 + charmap "ぬ", $c7 + charmap "ね", $c8 + charmap "の", $c9 + charmap "は", $ca + charmap "ひ", $cb + charmap "ふ", $cc + charmap "へ", $cd + charmap "ほ", $ce + charmap "ま", $cf + charmap "み", $d0 + charmap "む", $d1 + charmap "め", $d2 + charmap "も", $d3 + charmap "や", $d4 + charmap "ゆ", $d5 + charmap "よ", $d6 + charmap "ら", $d7 + charmap "り", $d8 + charmap "る", $d9 + charmap "れ", $da + charmap "ろ", $db + charmap "わ", $dc + charmap "を", $dd + charmap "ん", $de + charmap "っ", $df + charmap "ゃ", $e0 + charmap "ゅ", $e1 + charmap "ょ", $e2 + + charmap "ー", $e3 + charmap "゚", $e4 + charmap "゙", $e5 + + charmap "?", $e6 + charmap "!", $e7 + charmap "。", $e8 + + charmap "ァ", $e9 + charmap "ゥ", $ea + charmap "ェ", $eb + + charmap "円", $f0 + + charmap ".", $f2 + charmap "/", $f3 + + charmap "ォ", $f4 + + charmap "0", $f6 + charmap "1", $f7 + charmap "2", $f8 + charmap "3", $f9 + charmap "4", $fa + charmap "5", $fb + charmap "6", $fc + charmap "7", $fd + charmap "8", $fe + charmap "9", $ff diff --git a/constants.asm b/constants.asm new file mode 100644 index 0000000..63ba248 --- /dev/null +++ b/constants.asm @@ -0,0 +1,6 @@ +INCLUDE "charmap.asm" + +INCLUDE "macros.asm" + +INCLUDE "constants/hardware_constants.asm" +INCLUDE "constants/gfx_constants.asm"
\ No newline at end of file diff --git a/constants/gfx_constants.asm b/constants/gfx_constants.asm new file mode 100644 index 0000000..0da273f --- /dev/null +++ b/constants/gfx_constants.asm @@ -0,0 +1,58 @@ +TILE_WIDTH EQU 8 ; pixels +LEN_1BPP_TILE EQU 1 * TILE_WIDTH ; bytes +LEN_2BPP_TILE EQU 2 * TILE_WIDTH ; bytes + +NUM_PAL_COLORS EQU 4 +PAL_COLOR_SIZE EQU 2 +PALETTE_SIZE EQU NUM_PAL_COLORS * PAL_COLOR_SIZE + +PALRGB_WHITE EQUS "palred 31 + palgreen 31 + palblue 31" ; $7fff + + +SCREEN_WIDTH EQU 20 ; tiles +SCREEN_HEIGHT EQU 18 ; tiles +SCREEN_WIDTH_PX EQU SCREEN_WIDTH * TILE_WIDTH ; pixels +SCREEN_HEIGHT_PX EQU SCREEN_HEIGHT * TILE_WIDTH ; pixels + +BG_MAP_WIDTH EQU 32 ; tiles +BG_MAP_HEIGHT EQU 32 ; tiles + +METATILE_WIDTH EQU 4 ; tiles +SCREEN_META_WIDTH EQU 6 ; metatiles +SCREEN_META_HEIGHT EQU 5 ; metatiles +SURROUNDING_WIDTH EQU SCREEN_META_WIDTH * METATILE_WIDTH ; tiles +SURROUNDING_HEIGHT EQU SCREEN_META_HEIGHT * METATILE_WIDTH ; tiles + + +HP_BAR_LENGTH EQU 6 ; tiles +EXP_BAR_LENGTH EQU 8 ; tiles +HP_BAR_LENGTH_PX EQU HP_BAR_LENGTH * TILE_WIDTH ; pixels +EXP_BAR_LENGTH_PX EQU EXP_BAR_LENGTH * TILE_WIDTH ; pixels + +; GetHPPal return values (see home.asm) +HP_GREEN EQU 0 +HP_YELLOW EQU 1 +HP_RED EQU 2 + + +; sprite_oam_struct members (see macros/wram.asm) + const_def + const SPRITEOAMSTRUCT_YCOORD ; 0 + const SPRITEOAMSTRUCT_XCOORD ; 1 + const SPRITEOAMSTRUCT_TILE_ID ; 2 + const SPRITEOAMSTRUCT_ATTRIBUTES ; 3 +SPRITEOAMSTRUCT_LENGTH EQU const_value +NUM_SPRITE_OAM_STRUCTS EQU 40 ; see wVirtualOAM + + +; PokeAnims indexes (see engine/gfx/pic_animation.asm) + const_def + const ANIM_MON_SLOW + const ANIM_MON_NORMAL + const ANIM_MON_MENU + const ANIM_MON_TRADE + const ANIM_MON_EVOLVE + const ANIM_MON_HATCH + const ANIM_MON_UNUSED + const ANIM_MON_EGG1 + const ANIM_MON_EGG2 diff --git a/constants/hardware_constants.asm b/constants/hardware_constants.asm new file mode 100644 index 0000000..d96672c --- /dev/null +++ b/constants/hardware_constants.asm @@ -0,0 +1,161 @@ +; Graciously aped from: +; http://nocash.emubase.de/pandocs.htm +; http://gameboy.mongenel.com/dmg/asmmemmap.html + +; memory map +VRAM_Begin EQU $8000 +VRAM_End EQU $a000 +SRAM_Begin EQU $a000 +SRAM_End EQU $c000 +WRAM0_Begin EQU $c000 +WRAM0_End EQU $d000 +WRAM1_Begin EQU $d000 +WRAM1_End EQU $e000 +; hardware registers $ff00-$ff80 (see below) +HRAM_Begin EQU $ff80 +HRAM_End EQU $ffff + +; MBC3 +MBC3SRamEnable EQU $0000 +MBC3RomBank EQU $2000 +MBC3SRamBank EQU $4000 +MBC3LatchClock EQU $6000 +MBC3RTC EQU $a000 + +SRAM_DISABLE EQU $00 +SRAM_ENABLE EQU $0a + +NUM_SRAM_BANKS EQU 4 + +RTC_S EQU $08 ; Seconds 0-59 (0-3Bh) +RTC_M EQU $09 ; Minutes 0-59 (0-3Bh) +RTC_H EQU $0a ; Hours 0-23 (0-17h) +RTC_DL EQU $0b ; Lower 8 bits of Day Counter (0-FFh) +RTC_DH EQU $0c ; Upper 1 bit of Day Counter, Carry Bit, Halt Flag + ; Bit 0 Most significant bit of Day Counter (Bit 8) + ; Bit 6 Halt (0=Active, 1=Stop Timer) + ; Bit 7 Day Counter Carry Bit (1=Counter Overflow) + +; interrupt flags +VBLANK EQU 0 +LCD_STAT EQU 1 +TIMER EQU 2 +SERIAL EQU 3 +JOYPAD EQU 4 + +; OAM attribute flags +OAM_TILE_BANK EQU 3 +OAM_OBP_NUM EQU 4 ; non CGB Mode Only +OAM_X_FLIP EQU 5 +OAM_Y_FLIP EQU 6 +OAM_PRIORITY EQU 7 ; 0: OBJ above BG, 1: OBJ behind BG (colors 1-3) + +; BG Map attribute flags +PALETTE_MASK EQU %111 +VRAM_BANK_1 EQU 1 << OAM_TILE_BANK ; $08 +OBP_NUM EQU 1 << OAM_OBP_NUM ; $10 +X_FLIP EQU 1 << OAM_X_FLIP ; $20 +Y_FLIP EQU 1 << OAM_Y_FLIP ; $40 +PRIORITY EQU 1 << OAM_PRIORITY ; $80 + +; Other useful constants +LCDC_DEFAULT EQU %11100011 +LY_VBLANK EQU 144 + +; Hardware registers +rJOYP EQU $ff00 ; Joypad (R/W) +rSB EQU $ff01 ; Serial transfer data (R/W) +rSC EQU $ff02 ; Serial Transfer Control (R/W) +rSC_ON EQU 7 +rSC_CGB EQU 1 +rSC_CLOCK EQU 0 +rDIV EQU $ff04 ; Divider Register (R/W) +rTIMA EQU $ff05 ; Timer counter (R/W) +rTMA EQU $ff06 ; Timer Modulo (R/W) +rTAC EQU $ff07 ; Timer Control (R/W) +rTAC_ON EQU 2 +rTAC_4096_HZ EQU 0 +rTAC_262144_HZ EQU 1 +rTAC_65536_HZ EQU 2 +rTAC_16384_HZ EQU 3 +rIF EQU $ff0f ; Interrupt Flag (R/W) +rNR10 EQU $ff10 ; Channel 1 Sweep register (R/W) +rNR11 EQU $ff11 ; Channel 1 Sound length/Wave pattern duty (R/W) +rNR12 EQU $ff12 ; Channel 1 Volume Envelope (R/W) +rNR13 EQU $ff13 ; Channel 1 Frequency lo (Write Only) +rNR14 EQU $ff14 ; Channel 1 Frequency hi (R/W) +rNR20 EQU $ff15 ; Channel 2 Sweep register (R/W) +rNR21 EQU $ff16 ; Channel 2 Sound Length/Wave Pattern Duty (R/W) +rNR22 EQU $ff17 ; Channel 2 Volume Envelope (R/W) +rNR23 EQU $ff18 ; Channel 2 Frequency lo data (W) +rNR24 EQU $ff19 ; Channel 2 Frequency hi data (R/W) +rNR30 EQU $ff1a ; Channel 3 Sound on/off (R/W) +rNR31 EQU $ff1b ; Channel 3 Sound Length +rNR32 EQU $ff1c ; Channel 3 Select output level (R/W) +rNR33 EQU $ff1d ; Channel 3 Frequency's lower data (W) +rNR34 EQU $ff1e ; Channel 3 Frequency's higher data (R/W) +rNR40 EQU $ff1f ; Channel 4 Sweep register (R/W) +rNR41 EQU $ff20 ; Channel 4 Sound Length (R/W) +rNR42 EQU $ff21 ; Channel 4 Volume Envelope (R/W) +rNR43 EQU $ff22 ; Channel 4 Polynomial Counter (R/W) +rNR44 EQU $ff23 ; Channel 4 Counter/consecutive; Inital (R/W) +rNR50 EQU $ff24 ; Channel control / ON-OFF / Volume (R/W) +rNR51 EQU $ff25 ; Selection of Sound output terminal (R/W) +rNR52 EQU $ff26 ; Sound on/off +rWave_0 EQU $ff30 +rWave_1 EQU $ff31 +rWave_2 EQU $ff32 +rWave_3 EQU $ff33 +rWave_4 EQU $ff34 +rWave_5 EQU $ff35 +rWave_6 EQU $ff36 +rWave_7 EQU $ff37 +rWave_8 EQU $ff38 +rWave_9 EQU $ff39 +rWave_a EQU $ff3a +rWave_b EQU $ff3b +rWave_c EQU $ff3c +rWave_d EQU $ff3d +rWave_e EQU $ff3e +rWave_f EQU $ff3f +rLCDC EQU $ff40 ; LCD Control (R/W) +rLCDC_SPRITES_ENABLE EQU 1 ; 0=Off, 1=On +rLCDC_SPRITE_SIZE EQU 2 ; 0=8x8, 1=8x16 +rLCDC_WINDOW_TILEMAP EQU 6 ; 0=9800-9BFF, 1=9C00-9FFF +rLCDC_ENABLE EQU 7 ; 0=Off, 1=On +rSTAT EQU $ff41 ; LCDC Status (R/W) +rSCY EQU $ff42 ; Scroll Y (R/W) +rSCX EQU $ff43 ; Scroll X (R/W) +rLY EQU $ff44 ; LCDC Y-Coordinate (R) +rLYC EQU $ff45 ; LY Compare (R/W) +rDMA EQU $ff46 ; DMA Transfer and Start Address (W) +rBGP EQU $ff47 ; BG Palette Data (R/W) - Non CGB Mode Only +rOBP0 EQU $ff48 ; Object Palette 0 Data (R/W) - Non CGB Mode Only +rOBP1 EQU $ff49 ; Object Palette 1 Data (R/W) - Non CGB Mode Only +rWY EQU $ff4a ; Window Y Position (R/W) +rWX EQU $ff4b ; Window X Position minus 7 (R/W) +rLCDMODE EQU $ff4c +rKEY1 EQU $ff4d ; CGB Mode Only - Prepare Speed Switch +rVBK EQU $ff4f ; CGB Mode Only - VRAM Bank +rBLCK EQU $ff50 +rHDMA1 EQU $ff51 ; CGB Mode Only - New DMA Source, High +rHDMA2 EQU $ff52 ; CGB Mode Only - New DMA Source, Low +rHDMA3 EQU $ff53 ; CGB Mode Only - New DMA Destination, High +rHDMA4 EQU $ff54 ; CGB Mode Only - New DMA Destination, Low +rHDMA5 EQU $ff55 ; CGB Mode Only - New DMA Length/Mode/Start +rRP EQU $ff56 ; CGB Mode Only - Infrared Communications Port +rBGPI EQU $ff68 ; CGB Mode Only - Background Palette Index +rBGPI_AUTO_INCREMENT EQU 7 ; increment rBGPI after write to rBGPD +rBGPD EQU $ff69 ; CGB Mode Only - Background Palette Data +rOBPI EQU $ff6a ; CGB Mode Only - Sprite Palette Index +rOBPI_AUTO_INCREMENT EQU 7 ; increment rOBPI after write to rOBPD +rOBPD EQU $ff6b ; CGB Mode Only - Sprite Palette Data +rUNKNOWN1 EQU $ff6c ; (FEh) Bit 0 (Read/Write) - CGB Mode Only +rSVBK EQU $ff70 ; CGB Mode Only - WRAM Bank +rUNKNOWN2 EQU $ff72 ; (00h) - Bit 0-7 (Read/Write) +rUNKNOWN3 EQU $ff73 ; (00h) - Bit 0-7 (Read/Write) +rUNKNOWN4 EQU $ff74 ; (00h) - Bit 0-7 (Read/Write) - CGB Mode Only +rUNKNOWN5 EQU $ff75 ; (8Fh) - Bit 4-6 (Read/Write) +rUNKNOWN6 EQU $ff76 ; (00h) - Always 00h (Read Only) +rUNKNOWN7 EQU $ff77 ; (00h) - Always 00h (Read Only) +rIE EQU $ffff ; Interrupt Enable (R/W) @@ -1,3 +1,5 @@ +INCLUDE "constants.asm" + SECTION "Entry point", ROM0[$100] nop diff --git a/macros.asm b/macros.asm new file mode 100644 index 0000000..87fa36d --- /dev/null +++ b/macros.asm @@ -0,0 +1 @@ +INCLUDE "macros/enum.asm"
\ No newline at end of file diff --git a/macros/enum.asm b/macros/enum.asm new file mode 100644 index 0000000..385aee6 --- /dev/null +++ b/macros/enum.asm @@ -0,0 +1,53 @@ +; Enumerate variables + +enum_start: MACRO +if _NARG >= 1 +__enum__ = \1 +else +__enum__ = 0 +endc +if _NARG >= 2 +__enumdir__ = \2 +else +__enumdir__ = +1 +endc +ENDM + +enum: MACRO +\1 = __enum__ +__enum__ = __enum__ + __enumdir__ +ENDM + +enum_set: MACRO +__enum__ = \1 +ENDM + + +; Enumerate constants + +const_def: MACRO +if _NARG >= 1 +const_value = \1 +else +const_value = 0 +endc +ENDM + +const: MACRO +\1 EQU const_value +const_value = const_value + 1 +ENDM + +shift_const: MACRO +\1 EQU (1 << const_value) +const_value = const_value + 1 +ENDM + + +; Enumerate strings + +define: MACRO +if !DEF(\1) +\1 EQUS \2 +endc +ENDM @@ -0,0 +1,4 @@ +INCLUDE "constants.asm" + + +; TODO @@ -0,0 +1,4 @@ +INCLUDE "constants.asm" + + +; TODO |