diff --git a/.gitignore b/.gitignore index fa0077821..8455b559e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,5 @@ pokeas pokeld pokeobjcopy src/*.s -tools/agbcc +tools/* *.map diff --git a/Makefile b/Makefile index 4189cd33b..631a49860 100644 --- a/Makefile +++ b/Makefile @@ -35,40 +35,11 @@ PREPROC := tools/preproc/preproc C_SRCS := $(wildcard src/*.c) C_OBJS := $(C_SRCS:%.c=%.o) -ASM_OBJS := \ -asm/crt0.o \ -asm/main.o \ -asm/dma3_manager.o \ -asm/gpu_bg.o \ -asm/pixel_buffer.o \ -asm/window.o \ -asm/text_renderer.o \ -asm/gpu_obj.o \ -asm/string_util.o \ -asm/rom_80093CC.o \ -asm/rtc.o \ -asm/main_menu.o \ -asm/rom_8032654.o \ -asm/tileset_animation.o \ -asm/rom_80A18F4.o \ -asm/rom_80A92F4.o \ -asm/multiboot.o \ -asm/rom_81BAD84.o \ -asm/libgcnmultiboot.o \ -asm/libmks4agb.o \ -asm/libagbbackup.o \ -asm/librtc.o \ -asm/librfu.o \ -asm/libagbsyscall.o +ASM_SRCS := $(wildcard asm/*.s) +ASM_OBJS := $(ASM_SRCS:%.s=%.o) -DATA_ASM_OBJS := data/data2.o data/anim_mon_front_pics.o \ -data/graphics.o data/unknown_serial_data.o data/multiboot_berry_glitch_fix.o \ -data/multiboot_pokemon_colosseum.o data/libagbbackup_rodata.o \ -data/librtc_rodata.o data/librfu_rodata.o data/sound_data.o \ -data/m4a_tables.o \ -data/event_scripts.o data/battle_anim_scripts.o \ -data/battle_scripts_1.o data/battle_scripts_2.o data/field_effect_scripts.o \ -data/battle_ai_scripts.o data/contest_ai_scripts.o data/script_funcs.o +DATA_ASM_SRCS := $(wildcard data/*.s) +DATA_ASM_OBJS := $(DATA_ASM_SRCS:%.s=%.o) OBJS := $(C_OBJS) $(ASM_OBJS) $(DATA_ASM_OBJS) diff --git a/asm/crt0.s b/asm/crt0.s index 7c2115c15..7b2f38bb7 100644 --- a/asm/crt0.s +++ b/asm/crt0.s @@ -1,4 +1,4 @@ - .include "constants/gba_constants.s" + .include "constants/gba_constants.inc" .syntax unified @@ -11,7 +11,7 @@ Start: @ 8000000 b Init - .include "asm/rom_header.s" + .include "asm/rom_header.inc" @ 80000C0 .word 0 diff --git a/asm/dma3_manager.s b/asm/dma3_manager.s index 6be63dabb..5ab41b675 100644 --- a/asm/dma3_manager.s +++ b/asm/dma3_manager.s @@ -1,5 +1,5 @@ - .include "asm/macros.s" - .include "constants/gba_constants.s" + .include "asm/macros.inc" + .include "constants/gba_constants.inc" .syntax unified diff --git a/asm/gpu_bg.s b/asm/gpu_bg.s index 76b383608..b523c1d2f 100644 --- a/asm/gpu_bg.s +++ b/asm/gpu_bg.s @@ -1,4 +1,4 @@ - .include "asm/macros.s" + .include "asm/macros.inc" .syntax unified diff --git a/asm/gpu_obj.s b/asm/gpu_obj.s index 2ae2eac56..dad412f9f 100644 --- a/asm/gpu_obj.s +++ b/asm/gpu_obj.s @@ -1,4 +1,4 @@ - .include "asm/macros.s" + .include "asm/macros.inc" .syntax unified diff --git a/asm/libagbbackup.s b/asm/libagbbackup.s index 01e972431..35180530c 100644 --- a/asm/libagbbackup.s +++ b/asm/libagbbackup.s @@ -1,4 +1,4 @@ - .include "asm/macros.s" + .include "asm/macros.inc" .syntax unified diff --git a/asm/libagbsyscall.s b/asm/libagbsyscall.s index 41f3718b9..812ab17ec 100644 --- a/asm/libagbsyscall.s +++ b/asm/libagbsyscall.s @@ -1,4 +1,4 @@ - .include "asm/macros.s" + .include "asm/macros.inc" .syntax unified diff --git a/asm/libgcnmultiboot.s b/asm/libgcnmultiboot.s index 7d8e4d340..0e418e51f 100644 --- a/asm/libgcnmultiboot.s +++ b/asm/libgcnmultiboot.s @@ -1,8 +1,8 @@ @ This library can be used to download and execute a multi-boot image from @ a GameCube using the JOY Bus protocol over the link cable. - .include "asm/macros.s" - .include "constants/constants.s" + .include "asm/macros.inc" + .include "constants/constants.inc" .equiv GCMB_STRUCT_BASE_DEST_PTR, 0x20 .equiv GCMB_STRUCT_CUR_DEST_PTR, 0x24 diff --git a/asm/libmks4agb.s b/asm/libmks4agb.s index c0af24a0e..09d4605ca 100644 --- a/asm/libmks4agb.s +++ b/asm/libmks4agb.s @@ -1,4 +1,4 @@ - .include "asm/macros.s" + .include "asm/macros.inc" .syntax unified diff --git a/asm/librfu.s b/asm/librfu.s index d0ee616b2..e60652e4f 100644 --- a/asm/librfu.s +++ b/asm/librfu.s @@ -1,4 +1,4 @@ - .include "asm/macros.s" + .include "asm/macros.inc" .syntax unified diff --git a/asm/librtc.s b/asm/librtc.s index f19734d61..b0c87bb3f 100644 --- a/asm/librtc.s +++ b/asm/librtc.s @@ -1,4 +1,4 @@ - .include "asm/macros.s" + .include "asm/macros.inc" .syntax unified diff --git a/asm/macros.s b/asm/macros.inc similarity index 87% rename from asm/macros.s rename to asm/macros.inc index 1e3a3e78f..642b6a33f 100644 --- a/asm/macros.s +++ b/asm/macros.inc @@ -1,10 +1,10 @@ - .include "asm/macros/asm.s" - .include "asm/macros/function.s" - .include "asm/macros/window.s" - .include "asm/macros/pokemon_data.s" - .include "asm/macros/ec.s" - .include "asm/macros/map.s" - .include "asm/macros/field_effect_script.s" + .include "asm/macros/asm.inc" + .include "asm/macros/function.inc" + .include "asm/macros/window.inc" + .include "asm/macros/pokemon_data.inc" + .include "asm/macros/ec.inc" + .include "asm/macros/map.inc" + .include "asm/macros/field_effect_script.inc" .macro region_map_entry x, y, width, height, name .byte \x diff --git a/asm/macros/asm.s b/asm/macros/asm.inc similarity index 100% rename from asm/macros/asm.s rename to asm/macros/asm.inc diff --git a/asm/macros/contest_ai_script.s b/asm/macros/contest_ai_script.inc similarity index 100% rename from asm/macros/contest_ai_script.s rename to asm/macros/contest_ai_script.inc diff --git a/asm/macros/ec.s b/asm/macros/ec.inc similarity index 100% rename from asm/macros/ec.s rename to asm/macros/ec.inc diff --git a/asm/macros/field_effect_script.s b/asm/macros/field_effect_script.inc similarity index 100% rename from asm/macros/field_effect_script.s rename to asm/macros/field_effect_script.inc diff --git a/asm/macros/function.s b/asm/macros/function.inc similarity index 100% rename from asm/macros/function.s rename to asm/macros/function.inc diff --git a/asm/macros/map.s b/asm/macros/map.inc similarity index 100% rename from asm/macros/map.s rename to asm/macros/map.inc diff --git a/asm/macros/pokemon_data.s b/asm/macros/pokemon_data.inc similarity index 100% rename from asm/macros/pokemon_data.s rename to asm/macros/pokemon_data.inc diff --git a/asm/macros/window.s b/asm/macros/window.inc similarity index 100% rename from asm/macros/window.s rename to asm/macros/window.inc diff --git a/asm/main.s b/asm/main.s index f02f39ed8..bbedc3c26 100644 --- a/asm/main.s +++ b/asm/main.s @@ -1,4 +1,4 @@ - .include "asm/macros.s" + .include "asm/macros.inc" .syntax unified diff --git a/asm/main_menu.s b/asm/main_menu.s index c6dccfff8..3ae2788c7 100644 --- a/asm/main_menu.s +++ b/asm/main_menu.s @@ -1,4 +1,4 @@ - .include "asm/macros.s" + .include "asm/macros.inc" .syntax unified diff --git a/asm/malloc.s b/asm/malloc.s deleted file mode 100644 index 529b654c7..000000000 --- a/asm/malloc.s +++ /dev/null @@ -1,339 +0,0 @@ - .include "asm/macros.s" - - .syntax unified - - .text - - thumb_func_start PutMemBlockHeader -@ void PutMemBlockHeader(void *block, struct MemBlock *prev, struct MemBlock *next, u32 size) -PutMemBlockHeader: @ 8000988 - push {r4,lr} - movs r4, 0 - strh r4, [r0] - ldr r4, =0x0000a3a3 - strh r4, [r0, 0x2] - str r3, [r0, 0x4] - str r1, [r0, 0x8] - str r2, [r0, 0xC] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end PutMemBlockHeader - - thumb_func_start PutFirstMemBlockHeader -@ void PutFirstMemBlockHeader(void *block, u32 size) -PutFirstMemBlockHeader: @ 80009A4 - push {lr} - adds r2, r0, 0 - adds r3, r1, 0 - subs r3, 0x10 - adds r1, r2, 0 - bl PutMemBlockHeader - pop {r0} - bx r0 - thumb_func_end PutFirstMemBlockHeader - - thumb_func_start AllocInternal -@ void *AllocInternal(struct MemBlock *head, u32 size) -AllocInternal: @ 80009B8 - push {r4-r6,lr} - adds r4, r0, 0 - adds r6, r4, 0 - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _080009CC - lsrs r0, r1, 2 - adds r0, 0x1 - lsls r1, r0, 2 -_080009CC: - movs r2, 0x1 -_080009CE: - ldrh r0, [r4] - cmp r0, 0 - bne _08000A0C - ldr r3, [r4, 0x4] - cmp r3, r1 - bcc _08000A0C - subs r0, r3, r1 - cmp r0, 0x1F - bhi _080009E4 - strh r2, [r4] - b _08000A06 -_080009E4: - subs r3, 0x10 - subs r3, r1 - adds r0, r1, 0 - adds r0, 0x10 - adds r5, r4, r0 - strh r2, [r4] - str r1, [r4, 0x4] - ldr r2, [r4, 0xC] - adds r0, r5, 0 - adds r1, r4, 0 - bl PutMemBlockHeader - str r5, [r4, 0xC] - ldr r0, [r5, 0xC] - cmp r0, r6 - beq _08000A06 - str r5, [r0, 0x8] -_08000A06: - adds r0, r4, 0 - adds r0, 0x10 - b _08000A18 -_08000A0C: - ldr r0, [r4, 0xC] - cmp r0, r6 - beq _08000A16 - adds r4, r0, 0 - b _080009CE -_08000A16: - movs r0, 0 -_08000A18: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end AllocInternal - - thumb_func_start FreeInternal -@ void FreeInternal(void *heapStart, void *pointer) -FreeInternal: @ 8000A20 - push {r4,r5,lr} - cmp r1, 0 - beq _08000A7C - adds r5, r0, 0 - adds r2, r1, 0 - subs r2, 0x10 - movs r0, 0 - strh r0, [r2] - ldr r3, [r2, 0xC] - cmp r3, r5 - beq _08000A54 - ldrh r4, [r3] - cmp r4, 0 - bne _08000A54 - ldr r0, [r2, 0x4] - adds r0, 0x10 - ldr r1, [r3, 0x4] - adds r0, r1 - str r0, [r2, 0x4] - strh r4, [r3, 0x2] - ldr r0, [r2, 0xC] - ldr r0, [r0, 0xC] - str r0, [r2, 0xC] - cmp r0, r5 - beq _08000A54 - str r2, [r0, 0x8] -_08000A54: - cmp r2, r5 - beq _08000A7C - ldr r1, [r2, 0x8] - ldrh r3, [r1] - cmp r3, 0 - bne _08000A7C - ldr r0, [r2, 0xC] - str r0, [r1, 0xC] - ldr r1, [r2, 0xC] - cmp r1, r5 - beq _08000A6E - ldr r0, [r2, 0x8] - str r0, [r1, 0x8] -_08000A6E: - strh r3, [r2, 0x2] - ldr r0, [r2, 0x8] - ldr r1, [r0, 0x4] - adds r1, 0x10 - ldr r2, [r2, 0x4] - adds r1, r2 - str r1, [r0, 0x4] -_08000A7C: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end FreeInternal - - thumb_func_start AllocZeroedInternal -@ void *AllocZeroedInternal(void *heapStart, u32 size) -AllocZeroedInternal: @ 8000A84 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r1, 0 - bl AllocInternal - adds r5, r0, 0 - cmp r5, 0 - beq _08000AB8 - movs r0, 0x3 - ands r0, r4 - cmp r0, 0 - beq _08000AA2 - lsrs r0, r4, 2 - adds r0, 0x1 - lsls r4, r0, 2 -_08000AA2: - movs r0, 0 - str r0, [sp] - lsls r2, r4, 9 - lsrs r2, 11 - movs r0, 0xA0 - lsls r0, 19 - orrs r2, r0 - mov r0, sp - adds r1, r5, 0 - bl CpuSet -_08000AB8: - adds r0, r5, 0 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end AllocZeroedInternal - - thumb_func_start CheckMemBlockInternal -@ bool8 CheckMemBlockInternal(struct MemBlock *head, struct MemBlock *node) -CheckMemBlockInternal: @ 8000AC4 - push {r4,r5,lr} - adds r5, r0, 0 - adds r3, r1, 0 - subs r3, 0x10 - ldrh r2, [r3, 0x2] - ldr r0, =0x0000a3a3 - cmp r2, r0 - bne _08000B0A - ldr r0, [r3, 0xC] - ldrh r1, [r0, 0x2] - adds r4, r0, 0 - cmp r1, r2 - bne _08000B0A - cmp r4, r5 - beq _08000AE8 - ldr r0, [r4, 0x8] - cmp r0, r3 - bne _08000B0A -_08000AE8: - ldr r2, [r3, 0x8] - ldrh r1, [r2, 0x2] - ldr r0, =0x0000a3a3 - cmp r1, r0 - bne _08000B0A - cmp r2, r5 - beq _08000AFC - ldr r0, [r2, 0xC] - cmp r0, r3 - bne _08000B0A -_08000AFC: - cmp r4, r5 - beq _08000B14 - ldr r0, [r3, 0x4] - adds r0, 0x10 - adds r0, r3, r0 - cmp r4, r0 - beq _08000B14 -_08000B0A: - movs r0, 0 - b _08000B16 - .pool -_08000B14: - movs r0, 0x1 -_08000B16: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end CheckMemBlockInternal - - thumb_func_start InitHeap -@ void InitHeap(void *heapStart, u32 heapSize) -InitHeap: @ 8000B1C - push {lr} - ldr r2, =0x03000004 - str r0, [r2] - ldr r2, =0x03000008 - str r1, [r2] - bl PutFirstMemBlockHeader - pop {r0} - bx r0 - .pool - thumb_func_end InitHeap - - thumb_func_start Alloc -@ void *Alloc(u32 size) -Alloc: @ 8000B38 - push {lr} - adds r1, r0, 0 - ldr r0, =0x03000004 - ldr r0, [r0] - bl AllocInternal - pop {r1} - bx r1 - .pool - thumb_func_end Alloc - - thumb_func_start AllocZeroed -@ void *AllocZeroed(u32 size) -AllocZeroed: @ 8000B4C - push {lr} - adds r1, r0, 0 - ldr r0, =0x03000004 - ldr r0, [r0] - bl AllocZeroedInternal - pop {r1} - bx r1 - .pool - thumb_func_end AllocZeroed - - thumb_func_start Free -@ void Free(void *pointer) -Free: @ 8000B60 - push {lr} - adds r1, r0, 0 - ldr r0, =0x03000004 - ldr r0, [r0] - bl FreeInternal - pop {r0} - bx r0 - .pool - thumb_func_end Free - - thumb_func_start CheckMemBlock -@ bool8 CheckMemBlock(void *pointer) -CheckMemBlock: @ 8000B74 - push {lr} - adds r1, r0, 0 - ldr r0, =0x03000004 - ldr r0, [r0] - bl CheckMemBlockInternal - pop {r1} - bx r1 - .pool - thumb_func_end CheckMemBlock - - thumb_func_start CheckHeap -@ bool8 CheckHeap() -CheckHeap: @ 8000B88 - push {r4,r5,lr} - ldr r0, =0x03000004 - ldr r4, [r0] - adds r5, r0, 0 -_08000B90: - ldr r0, [r5] - adds r1, r4, 0 - adds r1, 0x10 - bl CheckMemBlockInternal - cmp r0, 0 - beq _08000BB0 - ldr r4, [r4, 0xC] - ldr r0, [r5] - cmp r4, r0 - bne _08000B90 - movs r0, 0x1 - b _08000BB2 - .pool -_08000BB0: - movs r0, 0 -_08000BB2: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end CheckHeap - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/multiboot.s b/asm/multiboot.s index cf072a87c..6d752c882 100644 --- a/asm/multiboot.s +++ b/asm/multiboot.s @@ -1,4 +1,4 @@ - .include "asm/macros.s" + .include "asm/macros.inc" .syntax unified diff --git a/asm/pixel_buffer.s b/asm/pixel_buffer.s index 0dcbccd18..70229b068 100644 --- a/asm/pixel_buffer.s +++ b/asm/pixel_buffer.s @@ -1,4 +1,4 @@ - .include "asm/macros.s" + .include "asm/macros.inc" .syntax unified diff --git a/asm/rom_80093CC.s b/asm/rom_80093CC.s index 9587dcbc5..753d2f778 100644 --- a/asm/rom_80093CC.s +++ b/asm/rom_80093CC.s @@ -1,5 +1,5 @@ - .include "asm/macros.s" - .include "constants/constants.s" + .include "asm/macros.inc" + .include "constants/constants.inc" .syntax unified diff --git a/asm/rom_8032654.s b/asm/rom_8032654.s index 59cc3bf7d..6283076d9 100644 --- a/asm/rom_8032654.s +++ b/asm/rom_8032654.s @@ -1,5 +1,5 @@ - .include "asm/macros.s" - .include "constants/constants.s" + .include "asm/macros.inc" + .include "constants/constants.inc" .syntax unified diff --git a/asm/rom_80A18F4.s b/asm/rom_80A18F4.s index 9f1d966fd..34a7fb872 100644 --- a/asm/rom_80A18F4.s +++ b/asm/rom_80A18F4.s @@ -1,5 +1,5 @@ - .include "asm/macros.s" - .include "constants/constants.s" + .include "asm/macros.inc" + .include "constants/constants.inc" .syntax unified diff --git a/asm/rom_80A92F4.s b/asm/rom_80A92F4.s index 07a72e235..f6bcd6bfd 100644 --- a/asm/rom_80A92F4.s +++ b/asm/rom_80A92F4.s @@ -1,5 +1,5 @@ - .include "asm/macros.s" - .include "constants/constants.s" + .include "asm/macros.inc" + .include "constants/constants.inc" .syntax unified diff --git a/asm/rom_81BAD84.s b/asm/rom_81BAD84.s index d32d573d0..7c88afd6c 100644 --- a/asm/rom_81BAD84.s +++ b/asm/rom_81BAD84.s @@ -1,5 +1,5 @@ - .include "asm/macros.s" - .include "constants/constants.s" + .include "asm/macros.inc" + .include "constants/constants.inc" .syntax unified diff --git a/asm/rom_header.s b/asm/rom_header.inc similarity index 100% rename from asm/rom_header.s rename to asm/rom_header.inc diff --git a/asm/rtc.s b/asm/rtc.s index 87ff95e80..c4a248dae 100644 --- a/asm/rtc.s +++ b/asm/rtc.s @@ -1,4 +1,4 @@ - .include "asm/macros.s" + .include "asm/macros.inc" .syntax unified diff --git a/asm/string_util.s b/asm/string_util.s index 6eda21515..47840c5a7 100644 --- a/asm/string_util.s +++ b/asm/string_util.s @@ -1,4 +1,4 @@ - .include "asm/macros.s" + .include "asm/macros.inc" .syntax unified diff --git a/asm/text_renderer.s b/asm/text_renderer.s index 285bcf15a..024a6cf4e 100644 --- a/asm/text_renderer.s +++ b/asm/text_renderer.s @@ -1,4 +1,4 @@ - .include "asm/macros.s" + .include "asm/macros.inc" .syntax unified diff --git a/asm/tileset_animation.s b/asm/tileset_animation.s index 404685366..b27eb059c 100644 --- a/asm/tileset_animation.s +++ b/asm/tileset_animation.s @@ -1,4 +1,4 @@ - .include "asm/macros.s" + .include "asm/macros.inc" .syntax unified diff --git a/asm/window.s b/asm/window.s index 5ea0462ac..bd65b1e5e 100644 --- a/asm/window.s +++ b/asm/window.s @@ -1,4 +1,4 @@ - .include "asm/macros.s" + .include "asm/macros.inc" .syntax unified diff --git a/constants/ability_constants.s b/constants/ability_constants.inc similarity index 100% rename from constants/ability_constants.s rename to constants/ability_constants.inc diff --git a/constants/battle_frontier_constants.s b/constants/battle_frontier_constants.inc similarity index 100% rename from constants/battle_frontier_constants.s rename to constants/battle_frontier_constants.inc diff --git a/constants/battle_move_constants.s b/constants/battle_move_constants.inc similarity index 100% rename from constants/battle_move_constants.s rename to constants/battle_move_constants.inc diff --git a/constants/berry_constants.s b/constants/berry_constants.inc similarity index 100% rename from constants/berry_constants.s rename to constants/berry_constants.inc diff --git a/constants/constants.inc b/constants/constants.inc new file mode 100644 index 000000000..650ba4703 --- /dev/null +++ b/constants/constants.inc @@ -0,0 +1,18 @@ + .include "constants/gba_constants.inc" + .include "constants/misc_constants.inc" + .include "constants/species_constants.inc" + .include "constants/ability_constants.inc" + .include "constants/move_constants.inc" + .include "constants/item_constants.inc" + .include "constants/type_constants.inc" + .include "constants/contest_constants.inc" + .include "constants/pokemon_data_constants.inc" + .include "constants/item_data_constants.inc" + .include "constants/battle_move_constants.inc" + .include "constants/easy_chat_constants.inc" + .include "constants/trainer_constants.inc" + .include "constants/battle_frontier_constants.inc" + .include "constants/map_constants.inc" + .include "constants/berry_constants.inc" + .include "constants/field_object_constants.inc" + .include "constants/contest_move_effects.inc" diff --git a/constants/constants.s b/constants/constants.s deleted file mode 100644 index 30fd312e6..000000000 --- a/constants/constants.s +++ /dev/null @@ -1,18 +0,0 @@ - .include "constants/gba_constants.s" - .include "constants/misc_constants.s" - .include "constants/species_constants.s" - .include "constants/ability_constants.s" - .include "constants/move_constants.s" - .include "constants/item_constants.s" - .include "constants/type_constants.s" - .include "constants/contest_constants.s" - .include "constants/pokemon_data_constants.s" - .include "constants/item_data_constants.s" - .include "constants/battle_move_constants.s" - .include "constants/easy_chat_constants.s" - .include "constants/trainer_constants.s" - .include "constants/battle_frontier_constants.s" - .include "constants/map_constants.s" - .include "constants/berry_constants.s" - .include "constants/field_object_constants.s" - .include "constants/contest_move_effects.s" diff --git a/constants/contest_constants.s b/constants/contest_constants.inc similarity index 100% rename from constants/contest_constants.s rename to constants/contest_constants.inc diff --git a/constants/contest_move_effects.s b/constants/contest_move_effects.inc similarity index 100% rename from constants/contest_move_effects.s rename to constants/contest_move_effects.inc diff --git a/constants/easy_chat_constants.s b/constants/easy_chat_constants.inc similarity index 100% rename from constants/easy_chat_constants.s rename to constants/easy_chat_constants.inc diff --git a/constants/field_object_constants.s b/constants/field_object_constants.inc similarity index 100% rename from constants/field_object_constants.s rename to constants/field_object_constants.inc diff --git a/constants/gba_constants.s b/constants/gba_constants.inc similarity index 100% rename from constants/gba_constants.s rename to constants/gba_constants.inc diff --git a/constants/item_constants.s b/constants/item_constants.inc similarity index 100% rename from constants/item_constants.s rename to constants/item_constants.inc diff --git a/constants/item_data_constants.s b/constants/item_data_constants.inc similarity index 100% rename from constants/item_data_constants.s rename to constants/item_data_constants.inc diff --git a/constants/map_constants.s b/constants/map_constants.inc similarity index 100% rename from constants/map_constants.s rename to constants/map_constants.inc diff --git a/constants/misc_constants.s b/constants/misc_constants.inc similarity index 100% rename from constants/misc_constants.s rename to constants/misc_constants.inc diff --git a/constants/move_constants.s b/constants/move_constants.inc similarity index 100% rename from constants/move_constants.s rename to constants/move_constants.inc diff --git a/constants/pokemon_data_constants.s b/constants/pokemon_data_constants.inc similarity index 100% rename from constants/pokemon_data_constants.s rename to constants/pokemon_data_constants.inc diff --git a/constants/species_constants.s b/constants/species_constants.inc similarity index 100% rename from constants/species_constants.s rename to constants/species_constants.inc diff --git a/constants/trainer_constants.s b/constants/trainer_constants.inc similarity index 100% rename from constants/trainer_constants.s rename to constants/trainer_constants.inc diff --git a/constants/type_constants.s b/constants/type_constants.inc similarity index 100% rename from constants/type_constants.s rename to constants/type_constants.inc diff --git a/data/base_stats.s b/data/base_stats.inc similarity index 100% rename from data/base_stats.s rename to data/base_stats.inc diff --git a/data/battle_ai_scripts.s b/data/battle_ai_scripts.s index 9e7c627a3..dfcda5397 100644 --- a/data/battle_ai_scripts.s +++ b/data/battle_ai_scripts.s @@ -1,5 +1,5 @@ - .include "asm/macros.s" - .include "constants/constants.s" + .include "asm/macros.inc" + .include "constants/constants.inc" .section script_data, "aw", %progbits diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index af3bef54f..b657ae179 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -1,5 +1,5 @@ - .include "asm/macros.s" - .include "constants/constants.s" + .include "asm/macros.inc" + .include "constants/constants.inc" .section script_data, "aw", %progbits diff --git a/data/battle_frontier/battle_arena_move_mind_ratings.s b/data/battle_frontier/battle_arena_move_mind_ratings.inc similarity index 100% rename from data/battle_frontier/battle_arena_move_mind_ratings.s rename to data/battle_frontier/battle_arena_move_mind_ratings.inc diff --git a/data/battle_frontier/battle_factory_style_move_lists.s b/data/battle_frontier/battle_factory_style_move_lists.inc similarity index 100% rename from data/battle_frontier/battle_factory_style_move_lists.s rename to data/battle_frontier/battle_factory_style_move_lists.inc diff --git a/data/battle_frontier/battle_frontier_held_items.s b/data/battle_frontier/battle_frontier_held_items.inc similarity index 100% rename from data/battle_frontier/battle_frontier_held_items.s rename to data/battle_frontier/battle_frontier_held_items.inc diff --git a/data/battle_frontier/battle_frontier_mons.s b/data/battle_frontier/battle_frontier_mons.inc similarity index 100% rename from data/battle_frontier/battle_frontier_mons.s rename to data/battle_frontier/battle_frontier_mons.inc diff --git a/data/battle_frontier/battle_frontier_trainer_mons.s b/data/battle_frontier/battle_frontier_trainer_mons.inc similarity index 100% rename from data/battle_frontier/battle_frontier_trainer_mons.s rename to data/battle_frontier/battle_frontier_trainer_mons.inc diff --git a/data/battle_frontier/battle_frontier_trainers.s b/data/battle_frontier/battle_frontier_trainers.inc similarity index 100% rename from data/battle_frontier/battle_frontier_trainers.s rename to data/battle_frontier/battle_frontier_trainers.inc diff --git a/data/battle_frontier/battle_pyramid_level_50_wild_mons.s b/data/battle_frontier/battle_pyramid_level_50_wild_mons.inc similarity index 100% rename from data/battle_frontier/battle_pyramid_level_50_wild_mons.s rename to data/battle_frontier/battle_pyramid_level_50_wild_mons.inc diff --git a/data/battle_frontier/battle_pyramid_open_level_wild_mons.s b/data/battle_frontier/battle_pyramid_open_level_wild_mons.inc similarity index 100% rename from data/battle_frontier/battle_pyramid_open_level_wild_mons.s rename to data/battle_frontier/battle_pyramid_open_level_wild_mons.inc diff --git a/data/battle_frontier/fallarbor_battle_tent_mons.s b/data/battle_frontier/fallarbor_battle_tent_mons.inc similarity index 100% rename from data/battle_frontier/fallarbor_battle_tent_mons.s rename to data/battle_frontier/fallarbor_battle_tent_mons.inc diff --git a/data/battle_frontier/fallarbor_battle_tent_trainer_mons.s b/data/battle_frontier/fallarbor_battle_tent_trainer_mons.inc similarity index 100% rename from data/battle_frontier/fallarbor_battle_tent_trainer_mons.s rename to data/battle_frontier/fallarbor_battle_tent_trainer_mons.inc diff --git a/data/battle_frontier/fallarbor_battle_tent_trainers.s b/data/battle_frontier/fallarbor_battle_tent_trainers.inc similarity index 100% rename from data/battle_frontier/fallarbor_battle_tent_trainers.s rename to data/battle_frontier/fallarbor_battle_tent_trainers.inc diff --git a/data/battle_frontier/slateport_battle_tent_mons.s b/data/battle_frontier/slateport_battle_tent_mons.inc similarity index 100% rename from data/battle_frontier/slateport_battle_tent_mons.s rename to data/battle_frontier/slateport_battle_tent_mons.inc diff --git a/data/battle_frontier/slateport_battle_tent_trainer_mons.s b/data/battle_frontier/slateport_battle_tent_trainer_mons.inc similarity index 100% rename from data/battle_frontier/slateport_battle_tent_trainer_mons.s rename to data/battle_frontier/slateport_battle_tent_trainer_mons.inc diff --git a/data/battle_frontier/slateport_battle_tent_trainers.s b/data/battle_frontier/slateport_battle_tent_trainers.inc similarity index 100% rename from data/battle_frontier/slateport_battle_tent_trainers.s rename to data/battle_frontier/slateport_battle_tent_trainers.inc diff --git a/data/battle_frontier/verdanturf_battle_tent_mons.s b/data/battle_frontier/verdanturf_battle_tent_mons.inc similarity index 100% rename from data/battle_frontier/verdanturf_battle_tent_mons.s rename to data/battle_frontier/verdanturf_battle_tent_mons.inc diff --git a/data/battle_frontier/verdanturf_battle_tent_trainer_mons.s b/data/battle_frontier/verdanturf_battle_tent_trainer_mons.inc similarity index 100% rename from data/battle_frontier/verdanturf_battle_tent_trainer_mons.s rename to data/battle_frontier/verdanturf_battle_tent_trainer_mons.inc diff --git a/data/battle_frontier/verdanturf_battle_tent_trainers.s b/data/battle_frontier/verdanturf_battle_tent_trainers.inc similarity index 100% rename from data/battle_frontier/verdanturf_battle_tent_trainers.s rename to data/battle_frontier/verdanturf_battle_tent_trainers.inc diff --git a/data/battle_moves.s b/data/battle_moves.inc similarity index 100% rename from data/battle_moves.s rename to data/battle_moves.inc diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 02a8103b3..da05b9367 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1,5 +1,5 @@ - .include "asm/macros.s" - .include "constants/constants.s" + .include "asm/macros.inc" + .include "constants/constants.inc" .section script_data, "aw", %progbits diff --git a/data/battle_scripts_2.s b/data/battle_scripts_2.s index 05f75bbb4..9acf48523 100644 --- a/data/battle_scripts_2.s +++ b/data/battle_scripts_2.s @@ -1,5 +1,5 @@ - .include "asm/macros.s" - .include "constants/constants.s" + .include "asm/macros.inc" + .include "constants/constants.inc" .section script_data, "aw", %progbits diff --git a/data/berries.s b/data/berries.inc similarity index 100% rename from data/berries.s rename to data/berries.inc diff --git a/data/contest_ai_scripts.s b/data/contest_ai_scripts.s index 3e8c9e59d..6eb254dae 100644 --- a/data/contest_ai_scripts.s +++ b/data/contest_ai_scripts.s @@ -1,6 +1,6 @@ - .include "asm/macros.s" - .include "asm/macros/contest_ai_script.s" - .include "constants/constants.s" + .include "asm/macros.inc" + .include "asm/macros/contest_ai_script.inc" + .include "constants/constants.inc" .section script_data, "aw", %progbits diff --git a/data/contest_effect_function_table.s b/data/contest_effect_function_table.inc similarity index 100% rename from data/contest_effect_function_table.s rename to data/contest_effect_function_table.inc diff --git a/data/contest_effects.s b/data/contest_effects.inc similarity index 100% rename from data/contest_effects.s rename to data/contest_effects.inc diff --git a/data/contest_moves.s b/data/contest_moves.inc similarity index 100% rename from data/contest_moves.s rename to data/contest_moves.inc diff --git a/data/cry_id_table.s b/data/cry_id_table.inc similarity index 100% rename from data/cry_id_table.s rename to data/cry_id_table.inc diff --git a/data/data2.s b/data/data2.s index 8f9853f62..35076df11 100644 --- a/data/data2.s +++ b/data/data2.s @@ -1,7 +1,7 @@ @ the second big chunk of data - .include "asm/macros.s" - .include "constants/constants.s" + .include "asm/macros.inc" + .include "constants/constants.inc" .section .rodata @@ -194,7 +194,7 @@ gUnknown_82EC7CC:: @ 82EC7CC .2byte 0x0008 @ 82EC7D4 - .include "data/string_util.s" + .include "data/string_util.inc" .align 2 gUnknown_082EC86C:: @ 82EC86C @@ -1284,7 +1284,7 @@ gUnknown_082FECA8:: @ 82FECA8 .incbin "baserom.gba", 0x2feca8, 0x18 @ 82FECC0 - .include "data/rtc.s" + .include "data/rtc.inc" gUnknown_082FECFC:: @ 82FECFC .incbin "baserom.gba", 0x2fecfc, 0x40 @@ -1371,19 +1371,19 @@ gUnknown_08300D38:: @ 8300D38 .incbin "baserom.gba", 0x300d38, 0x6e0 @ 8301418 - .include "data/graphics/pokemon/mon_still_front_pic_table.s" + .include "data/graphics/pokemon/mon_still_front_pic_table.inc" gUnknown_083021D8:: @ 83021D8 .incbin "baserom.gba", 0x3021d8, 0x6e0 @ 83028B8 - .include "data/graphics/pokemon/mon_back_pic_table.s" + .include "data/graphics/pokemon/mon_back_pic_table.inc" @ 8303678 - .include "data/graphics/pokemon/mon_palette_table.s" + .include "data/graphics/pokemon/mon_palette_table.inc" @ 8304438 - .include "data/graphics/pokemon/mon_shiny_palette_table.s" + .include "data/graphics/pokemon/mon_shiny_palette_table.inc" @ 83051F8 .incbin "baserom.gba", 0x3051f8, 0x174 @@ -1395,10 +1395,10 @@ gUnknown_083054E0:: @ 83054E0 .incbin "baserom.gba", 0x3054e0, 0x174 @ 8305654 - .include "data/graphics/trainers/trainer_front_pic_table.s" + .include "data/graphics/trainers/trainer_front_pic_table.inc" @ 830593C - .include "data/graphics/trainers/trainer_front_pic_palette_table.s" + .include "data/graphics/trainers/trainer_front_pic_palette_table.inc" @ 8305C24 .incbin "baserom.gba", 0x305c24, 0xe8 @@ -1410,10 +1410,10 @@ gUnknown_08305D2C:: @ 8305D2C .incbin "baserom.gba", 0x305d2c, 0x20 @ 8305D4C - .include "data/graphics/trainers/trainer_back_pic_table.s" + .include "data/graphics/trainers/trainer_back_pic_table.inc" @ 8305D8C - .include "data/graphics/trainers/trainer_back_pic_palette_table.s" + .include "data/graphics/trainers/trainer_back_pic_palette_table.inc" gUnknown_08305DCC:: @ 8305DCC .incbin "baserom.gba", 0x305dcc, 0x3ce0 @@ -1422,25 +1422,25 @@ gUnknown_08309AAC:: @ 8309AAC .incbin "baserom.gba", 0x309aac, 0x6e0 @ 830A18C - .include "data/graphics/pokemon/mon_front_pic_table.s" + .include "data/graphics/pokemon/mon_front_pic_table.inc" @ 830AF4C .incbin "baserom.gba", 0x30af4c, 0x6e0 @ 830B62C - .include "data/trainer_parties.s" + .include "data/trainer_parties.inc" @ 830FCD4 - .include "data/text/trainer_class_names.s" + .include "data/text/trainer_class_names.inc" @ 8310030 - .include "data/trainers.s" + .include "data/trainers.inc" @ 83185C8 - .include "data/text/species_names.s" + .include "data/text/species_names.inc" @ 831977C - .include "data/text/move_names.s" + .include "data/text/move_names.inc" .incbin "baserom.gba", 0x31a983, 0x4d @@ -1478,20 +1478,20 @@ gUnknown_0831ACE8:: @ 831ACE8 .incbin "baserom.gba", 0x31ace8, 0x150 @ 831AE38 - .include "data/text/type_names.s" + .include "data/text/type_names.inc" .align 2 gUnknown_0831AEB8:: @ 831AEB8 .incbin "baserom.gba", 0x31aeb8, 0xe0 @ 831AF98 - .include "data/text/ability_descriptions.s" + .include "data/text/ability_descriptions.inc" @ 831B6DB - .include "data/text/ability_names.s" + .include "data/text/ability_names.inc" @ 831BAD4 - .include "data/text/ability_description_pointers.s" + .include "data/text/ability_description_pointers.inc" gUnknown_0831BC0C:: @ 831BC0C .incbin "baserom.gba", 0x31bc0c, 0x38 @@ -1575,7 +1575,7 @@ gUnknown_0831C428:: @ 831C428 .incbin "baserom.gba", 0x31c428, 0x18 @ 831C440 - .include "data/pickup_items.s" + .include "data/pickup_items.inc" gUnknown_0831C483:: @ 831C483 .incbin "baserom.gba", 0x31c483, 0xa @@ -1620,48 +1620,48 @@ gUnknown_0831C7B4:: @ 831C7B4 .incbin "baserom.gba", 0x31c7b4, 0xe4 @ 831C898 - .include "data/battle_moves.s" + .include "data/battle_moves.inc" .incbin "baserom.gba", 0x31d93c, 0x10 @ 831D94C - .include "data/pokedex_order.s" + .include "data/pokedex_order.inc" @ 831E2F0 - .include "data/spinda_spot_graphics.s" + .include "data/spinda_spot_graphics.inc" @ 831E380 - .include "data/item_effect_info.s" + .include "data/item_effect_info.inc" @ 831E818 - .include "data/nature_stat_table.s" + .include "data/nature_stat_table.inc" @ 831E898 - .include "data/tm_hm_learnsets.s" + .include "data/tm_hm_learnsets.inc" @ 831F578 - .include "data/trainer_pic_indices.s" + .include "data/trainer_pic_indices.inc" @ 831F5CA - .include "data/trainer_class_name_indices.s" + .include "data/trainer_class_name_indices.inc" @ 831F61C - .include "data/cry_id_table.s" + .include "data/cry_id_table.inc" @ 831F72C - .include "data/experience_tables.s" + .include "data/experience_tables.inc" @ 83203CC - .include "data/base_stats.s" + .include "data/base_stats.inc" @ 83230DC - .include "data/level_up_learnsets.s" + .include "data/level_up_learnsets.inc" @ 832531C - .include "data/evolution_table.s" + .include "data/evolution_table.inc" @ 832937C - .include "data/level_up_learnset_pointers.s" + .include "data/level_up_learnset_pointers.inc" gUnknown_083299EC:: @ 83299EC .incbin "baserom.gba", 0x3299ec, 0x19b @@ -1739,7 +1739,7 @@ gUnknown_0832A3D8:: @ 832A3D8 .incbin "baserom.gba", 0x32a3d8, 0xa00 @ 832ADD8 - .include "data/egg_moves.s" + .include "data/egg_moves.inc" .align 2 gUnknown_0832B6C0:: @ 832B6C0 @@ -2253,13 +2253,13 @@ gUnknown_08339E00:: @ 8339E00 .incbin "baserom.gba", 0x339e00, 0x8 @ 8339E08 - .include "data/tilesets/tileset_graphics.s" + .include "data/tilesets/tileset_graphics.inc" @ 83960F0 - .include "data/tilesets/metatiles.s" + .include "data/tilesets/metatiles.inc" @ 83DF704 - .include "data/tilesets/tilesets.s" + .include "data/tilesets/tilesets.inc" @ 83DFE14 .incbin "baserom.gba", 0x3dfe14, 0xa1fc0 @@ -2373,7 +2373,7 @@ gUnknown_084975EC:: @ 84975EC .incbin "baserom.gba", 0x4975ec, 0xc @ 84975F8 - .include "data/graphics/field_objects/field_object_graphics.s" + .include "data/graphics/field_objects/field_object_graphics.inc" gUnknown_08505438:: @ 8505438 .incbin "baserom.gba", 0x505438, 0x144 @@ -2385,25 +2385,25 @@ gUnknown_085055CD:: @ 85055CD .incbin "baserom.gba", 0x5055cd, 0x53 @ 8505620 - .include "data/graphics/field_objects/field_object_graphics_info_pointers.s" + .include "data/graphics/field_objects/field_object_graphics_info_pointers.inc" @ 85059F8 - .include "data/graphics/field_objects/field_effect_object_template_pointers.s" + .include "data/graphics/field_objects/field_effect_object_template_pointers.inc" @ 8505A8C - .include "data/graphics/field_objects/field_object_pic_tables.s" + .include "data/graphics/field_objects/field_object_pic_tables.inc" @ 85089FC - .include "data/graphics/field_objects/field_object_anims.s" + .include "data/graphics/field_objects/field_object_anims.inc" gUnknown_085094AC:: @ 85094AC .incbin "baserom.gba", 0x5094ac, 0x40 @ 85094EC - .include "data/graphics/field_objects/field_object_oam.s" + .include "data/graphics/field_objects/field_object_oam.inc" @ 8509954 - .include "data/graphics/field_objects/field_object_graphics_info.s" + .include "data/graphics/field_objects/field_object_graphics_info.inc" gUnknown_0850BBC8:: @ 850BBC8 .incbin "baserom.gba", 0x50bbc8, 0x138 @@ -2418,10 +2418,10 @@ gUnknown_0850BE38:: @ 850BE38 .incbin "baserom.gba", 0x50be38, 0x10 @ 850BE48 - .include "data/graphics/field_objects/berry_tree_graphics_tables.s" + .include "data/graphics/field_objects/berry_tree_graphics_tables.inc" @ 850C9C0 - .include "data/graphics/field_objects/field_effect_objects.s" + .include "data/graphics/field_objects/field_effect_objects.inc" .incbin "baserom.gba", 0x50d6d4, 0x8 @@ -3394,7 +3394,7 @@ gUnknown_085507CC:: @ 85507CC .incbin "baserom.gba", 0x5507cc, 0x18 @ 85507E4 - .include "data/wild_mons.s" + .include "data/wild_mons.inc" .incbin "baserom.gba", 0x55370c, 0x188 @@ -3693,10 +3693,10 @@ gUnknown_0855D30C:: @ 855D30C .string "$" @ 855D30D - .include "data/text/pokedex_text.s" + .include "data/text/pokedex_text.inc" @ 856B5B0 - .include "data/pokedex_entries.s" + .include "data/pokedex_entries.inc" gUnknown_0856E610:: @ 856E610 .incbin "baserom.gba", 0x56e610, 0x20 @@ -3717,7 +3717,7 @@ gUnknown_0856E688:: @ 856E688 .incbin "baserom.gba", 0x56e688, 0xc @ 856E694 - .include "data/graphics/pokemon/mon_footprint_table.s" + .include "data/graphics/pokemon/mon_footprint_table.inc" gUnknown_0856ED08:: @ 856ED08 .incbin "baserom.gba", 0x56ed08, 0x28 @@ -4083,13 +4083,13 @@ gUnknown_0857BC88:: @ 857BC88 .incbin "baserom.gba", 0x57bc88, 0x20 @ 857BCA8 - .include "data/graphics/pokemon/mon_icon_table.s" + .include "data/graphics/pokemon/mon_icon_table.inc" @ 857C388 - .include "data/graphics/pokemon/mon_icon_palette_indices.s" + .include "data/graphics/pokemon/mon_icon_palette_indices.inc" @ 857C540 - .include "data/graphics/pokemon/mon_icon_palette_table.s" + .include "data/graphics/pokemon/mon_icon_palette_table.inc" gUnknown_0857C570:: @ 857C570 .incbin "baserom.gba", 0x57c570, 0x44 @@ -4168,7 +4168,7 @@ gUnknown_0857FC7C:: @ 857FC7C .incbin "baserom.gba", 0x57fc7c, 0x18 @ 857FC94 - .include "data/graphics/berries/berry_pic_table.s" + .include "data/graphics/berries/berry_pic_table.inc" gUnknown_0857FDEC:: @ 857FDEC .incbin "baserom.gba", 0x57fdec, 0x8 @@ -4180,10 +4180,10 @@ gUnknown_0857FE10:: @ 857FE10 .incbin "baserom.gba", 0x57fe10, 0x90 @ 857FEA0 - .include "data/text/item_descriptions.s" + .include "data/text/item_descriptions.inc" @ 85839A0 - .include "data/items.s" + .include "data/items.inc" gUnknown_08587A6C:: @ 8587A6C .incbin "baserom.gba", 0x587a6c, 0x4 @@ -4237,7 +4237,7 @@ gUnknown_08587C30:: @ 8587C30 .incbin "baserom.gba", 0x587c30, 0x20 @ 8587C50 - .include "data/text/contest_text_pointers.s" + .include "data/text/contest_text_pointers.inc" @ 8587D5C .incbin "baserom.gba", 0x587d5c, 0x34 @@ -4336,10 +4336,10 @@ gUnknown_08589ADE:: @ 8589ADE .incbin "baserom.gba", 0x589ade, 0x6 @ 8589AE4 - .include "data/text/berry_descriptions.s" + .include "data/text/berry_descriptions.inc" @ 858A670 - .include "data/berries.s" + .include "data/berries.inc" gUnknown_0858AB24:: @ 858AB24 .incbin "baserom.gba", 0x58ab24, 0xac @@ -4537,10 +4537,10 @@ gUnknown_0858C2AC:: @ 858C2AC .incbin "baserom.gba", 0x58c2ac, 0x8 @ 858C2B4 - .include "data/contest_moves.s" + .include "data/contest_moves.inc" @ 858CDCC - .include "data/contest_effects.s" + .include "data/contest_effects.inc" @ A lookup table with a 1 for each combo starter ID and a 0 for ID 0, @ which means "not a combo starter move". @@ -4552,7 +4552,7 @@ gComboStarterLookupTable:: @ 858CE8C .align 2 @ 858CECC - .include "data/contest_effect_function_table.s" + .include "data/contest_effect_function_table.inc" gUnknown_0858CF8C:: @ 858CF8C .incbin "baserom.gba", 0x58cf8c, 0x2 @@ -5140,13 +5140,13 @@ gUnknown_08597E6C:: @ 8597E6C .incbin "baserom.gba", 0x597e6c, 0x30 @ 8597E9C - .include "data/text/easy_chat/easy_chat_groups.s" + .include "data/text/easy_chat/easy_chat_groups.inc" @ 859D0B4 - .include "data/text/easy_chat/easy_chat_words_by_letter.s" + .include "data/text/easy_chat/easy_chat_words_by_letter.inc" @ 859E5D4 - .include "data/text/easy_chat/easy_chat_group_name_pointers.s" + .include "data/text/easy_chat/easy_chat_group_name_pointers.inc" gUnknown_0859E62C:: @ 859E62C .incbin "baserom.gba", 0x59e62c, 0x8 @@ -5275,7 +5275,7 @@ gUnknown_085A096C:: @ 85A096C .incbin "baserom.gba", 0x5a096c, 0x1a4 @ 85A0B10 - .include "data/region_map_entries.s" + .include "data/region_map_entries.inc" gUnknown_085A1B24:: @ 85A1B24 .incbin "baserom.gba", 0x5a1b24, 0x60 @@ -7205,16 +7205,16 @@ gUnknown_085CEC30:: @ 85CEC30 .incbin "baserom.gba", 0x5cec30, 0x80 @ 85CECB0 - .include "data/battle_frontier/battle_frontier_held_items.s" + .include "data/battle_frontier/battle_frontier_held_items.inc" @ 85CED2E - .include "data/battle_frontier/battle_frontier_trainer_mons.s" + .include "data/battle_frontier/battle_frontier_trainer_mons.inc" @ 85D5ACC - .include "data/battle_frontier/battle_frontier_trainers.s" + .include "data/battle_frontier/battle_frontier_trainers.inc" @ 85D97BC - .include "data/battle_frontier/battle_frontier_mons.s" + .include "data/battle_frontier/battle_frontier_mons.inc" gUnknown_085DCEDC:: @ 85DCEDC .incbin "baserom.gba", 0x5dcedc, 0x1e @@ -7247,31 +7247,31 @@ gUnknown_085DD6DC:: @ 85DD6DC .incbin "baserom.gba", 0x5dd6dc, 0x30 @ 85DD70C - .include "data/battle_frontier/slateport_battle_tent_trainer_mons.s" + .include "data/battle_frontier/slateport_battle_tent_trainer_mons.inc" @ 85DDA14 - .include "data/battle_frontier/slateport_battle_tent_trainers.s" + .include "data/battle_frontier/slateport_battle_tent_trainers.inc" @ 85DE02C - .include "data/battle_frontier/slateport_battle_tent_mons.s" + .include "data/battle_frontier/slateport_battle_tent_mons.inc" @ 85DE48C - .include "data/battle_frontier/verdanturf_battle_tent_trainer_mons.s" + .include "data/battle_frontier/verdanturf_battle_tent_trainer_mons.inc" @ 85DE610 - .include "data/battle_frontier/verdanturf_battle_tent_trainers.s" + .include "data/battle_frontier/verdanturf_battle_tent_trainers.inc" @ 85DEC28 - .include "data/battle_frontier/verdanturf_battle_tent_mons.s" + .include "data/battle_frontier/verdanturf_battle_tent_mons.inc" @ 85DEEF8 - .include "data/battle_frontier/fallarbor_battle_tent_trainer_mons.s" + .include "data/battle_frontier/fallarbor_battle_tent_trainer_mons.inc" @ 85DF084 - .include "data/battle_frontier/fallarbor_battle_tent_trainers.s" + .include "data/battle_frontier/fallarbor_battle_tent_trainers.inc" @ 85DF69C - .include "data/battle_frontier/fallarbor_battle_tent_mons.s" + .include "data/battle_frontier/fallarbor_battle_tent_mons.inc" gUnknown_085DF96C:: @ 85DF96C .incbin "baserom.gba", 0x5df96c, 0x40 @@ -8006,7 +8006,7 @@ gUnknown_085E9233:: @ 85E9233 .incbin "baserom.gba", 0x5e9233, 0x7 @ 85E923A - .include "data/text/berry_firmness_strings.s" + .include "data/text/berry_firmness_strings.inc" gUnknown_085E9263:: @ 85E9263 .incbin "baserom.gba", 0x5e9263, 0x8 @@ -9470,7 +9470,7 @@ gUnknown_085EE977:: @ 85EE977 .incbin "baserom.gba", 0x5ee977, 0x16 @ 85EE98D - .include "data/text/easy_chat/easy_chat_group_names.s" + .include "data/text/easy_chat/easy_chat_group_names.inc" gUnknown_085EEA42:: @ 85EEA42 .incbin "baserom.gba", 0x5eea42, 0x31 @@ -10650,7 +10650,7 @@ gUnknown_08611DB8:: @ 8611DB8 .incbin "baserom.gba", 0x611db8, 0x8 @ 8611DC0 - .include "data/battle_frontier/battle_arena_move_mind_ratings.s" + .include "data/battle_frontier/battle_arena_move_mind_ratings.inc" .align 2 @ 8611F24 @@ -10672,7 +10672,7 @@ gUnknown_08611FAC:: @ 8611FAC .incbin "baserom.gba", 0x611fac, 0x14 @ 8611FC0 - .include "data/battle_frontier/battle_factory_style_move_lists.s" + .include "data/battle_frontier/battle_factory_style_move_lists.inc" gUnknown_08612120:: @ 8612120 .incbin "baserom.gba", 0x612120, 0x44 @@ -10741,10 +10741,10 @@ gUnknown_086126AE:: @ 86126AE .incbin "baserom.gba", 0x6126ae, 0x2 @ 86126B0 - .include "data/battle_frontier/battle_pyramid_level_50_wild_mons.s" + .include "data/battle_frontier/battle_pyramid_level_50_wild_mons.inc" @ 8612E80 - .include "data/battle_frontier/battle_pyramid_open_level_wild_mons.s" + .include "data/battle_frontier/battle_pyramid_open_level_wild_mons.inc" gUnknown_08613650:: @ 8613650 .incbin "baserom.gba", 0x613650, 0x5 @@ -10921,7 +10921,7 @@ gUnknown_0861440E:: @ 861440E .incbin "baserom.gba", 0x61440e, 0x2 @ 8614410 - .include "data/graphics/items/item_icon_table.s" + .include "data/graphics/items/item_icon_table.inc" @ 8614FE0 .incbin "baserom.gba", 0x614fe0, 0x14 @@ -11246,10 +11246,10 @@ gUnknown_08618178:: @ 8618178 .incbin "baserom.gba", 0x618178, 0x49 @ 86181C1 - .include "data/text/move_descriptions.s" + .include "data/text/move_descriptions.inc" @ 861CAAC - .include "data/text/nature_names.s" + .include "data/text/nature_names.inc" gUnknown_0861CBB4:: @ 861CBB4 .incbin "baserom.gba", 0x61cbb4, 0x38 @@ -11732,10 +11732,10 @@ gUnknown_086237F8:: @ 86237F8 .incbin "baserom.gba", 0x6237f8, 0x44 @ 862383C - .include "data/text/ribbon_descriptions.s" + .include "data/text/ribbon_descriptions.inc" @ 8623A74 - .include "data/text/gift_ribbon_descriptions.s" + .include "data/text/gift_ribbon_descriptions.inc" gUnknown_08623FF8:: @ 8623FF8 .incbin "baserom.gba", 0x623ff8, 0xa0 @@ -12120,35 +12120,35 @@ gFont8LatinGlyphs:: @ 862BAE4 .incbin "data/graphics/fonts/font8.latfont" gFont8LatinGlyphWidths:: @ 8633AE4 - .include "data/graphics/fonts/font8_latin_widths.s" + .include "data/graphics/fonts/font8_latin_widths.inc" .align 2 gFont0LatinGlyphs:: @ 8633CE4 .incbin "data/graphics/fonts/font0.latfont" gFont0LatinGlyphWidths:: @ 863BCE4 - .include "data/graphics/fonts/font0_latin_widths.s" + .include "data/graphics/fonts/font0_latin_widths.inc" .align 2 gFont7LatinGlyphs:: @ 863BEE4 .incbin "data/graphics/fonts/font7.latfont" gFont7LatinGlyphWidths:: @ 8643EE4 - .include "data/graphics/fonts/font7_latin_widths.s" + .include "data/graphics/fonts/font7_latin_widths.inc" .align 2 gFont2LatinGlyphs:: @ 86440E4 .incbin "data/graphics/fonts/font2.latfont" gFont2LatinGlyphWidths:: @ 864C0E4 - .include "data/graphics/fonts/font2_latin_widths.s" + .include "data/graphics/fonts/font2_latin_widths.inc" .align 2 gFont1LatinGlyphs:: @ 864C2E4 .incbin "data/graphics/fonts/font1.latfont" gFont1LatinGlyphWidths:: @ 86542E4 - .include "data/graphics/fonts/font1_latin_widths.s" + .include "data/graphics/fonts/font1_latin_widths.inc" .align 2 gFont0JapaneseGlyphs:: @ 86544E4 @@ -12163,21 +12163,21 @@ gUnusedJapaneseFireRedLeafGreenMaleFontGlyphs:: @ 865C4E4 .incbin "data/graphics/fonts/unused_frlg_male.fwjpnfont" gUnusedJapaneseFireRedLeafGreenMaleFontGlyphWidths:: @ 86644E4 - .include "data/graphics/fonts/unused_japanese_frlg_male_font_widths.s" + .include "data/graphics/fonts/unused_japanese_frlg_male_font_widths.inc" .align 2 gUnusedJapaneseFireRedLeafGreenFemaleFontGlyphs:: @ 86646E4 .incbin "data/graphics/fonts/unused_frlg_female.fwjpnfont" gUnusedJapaneseFireRedLeafGreenFemaleFontGlyphWidths:: @ 866C6E4 - .include "data/graphics/fonts/unused_japanese_frlg_female_font_widths.s" + .include "data/graphics/fonts/unused_japanese_frlg_female_font_widths.inc" .align 2 gFont2JapaneseGlyphs:: @ 866C8E4 .incbin "data/graphics/fonts/font2.fwjpnfont" gFont2JapaneseGlyphWidths:: @ 86748E4 - .include "data/graphics/fonts/font2_japanese_widths.s" + .include "data/graphics/fonts/font2_japanese_widths.inc" gUnknown_08674AE4:: @ 8674AE4 .incbin "baserom.gba", 0x674ae4, 0x32 diff --git a/data/egg_moves.s b/data/egg_moves.inc similarity index 100% rename from data/egg_moves.s rename to data/egg_moves.inc diff --git a/data/event_script_command_function_table.s b/data/event_script_command_function_table.inc similarity index 100% rename from data/event_script_command_function_table.s rename to data/event_script_command_function_table.inc diff --git a/data/event_scripts.s b/data/event_scripts.s index c738a7415..49623df68 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -1,10 +1,10 @@ - .include "asm/macros.s" - .include "constants/constants.s" + .include "asm/macros.inc" + .include "constants/constants.inc" .section script_data, "aw", %progbits @ 81DB67C - .include "data/event_script_command_function_table.s" + .include "data/event_script_command_function_table.inc" gUnknown_081DBA08:: @ 81DBA08 .incbin "baserom.gba", 0x1dba08, 0x4 @@ -340,7 +340,7 @@ gUnknown_08278131:: @ 8278131 .incbin "baserom.gba", 0x278131, 0x4a51 @ 827CB82 - .include "data/text/contest_text.s" + .include "data/text/contest_text.inc" gUnknown_0827D507:: @ 827D507 .incbin "baserom.gba", 0x27d507, 0x2a diff --git a/data/evolution_table.s b/data/evolution_table.inc similarity index 100% rename from data/evolution_table.s rename to data/evolution_table.inc diff --git a/data/experience_tables.inc b/data/experience_tables.inc new file mode 100644 index 000000000..4afd6df40 --- /dev/null +++ b/data/experience_tables.inc @@ -0,0 +1,11 @@ + .align 2 +gExperienceTables:: @ 831F72C + .include "data/experience_tables/medium_fast_growth_rate.inc" + .include "data/experience_tables/erratic_growth_rate.inc" + .include "data/experience_tables/fluctuating_growth_rate.inc" + .include "data/experience_tables/medium_slow_growth_rate.inc" + .include "data/experience_tables/fast_growth_rate.inc" + .include "data/experience_tables/slow_growth_rate.inc" +@ TODO: find out if these copies are used + .include "data/experience_tables/medium_fast_growth_rate.inc" + .include "data/experience_tables/medium_fast_growth_rate.inc" diff --git a/data/experience_tables.s b/data/experience_tables.s deleted file mode 100644 index 1e929a00d..000000000 --- a/data/experience_tables.s +++ /dev/null @@ -1,11 +0,0 @@ - .align 2 -gExperienceTables:: @ 831F72C - .include "data/experience_tables/medium_fast_growth_rate.s" - .include "data/experience_tables/erratic_growth_rate.s" - .include "data/experience_tables/fluctuating_growth_rate.s" - .include "data/experience_tables/medium_slow_growth_rate.s" - .include "data/experience_tables/fast_growth_rate.s" - .include "data/experience_tables/slow_growth_rate.s" -@ TODO: find out if these copies are used - .include "data/experience_tables/medium_fast_growth_rate.s" - .include "data/experience_tables/medium_fast_growth_rate.s" diff --git a/data/experience_tables/erratic_growth_rate.s b/data/experience_tables/erratic_growth_rate.inc similarity index 100% rename from data/experience_tables/erratic_growth_rate.s rename to data/experience_tables/erratic_growth_rate.inc diff --git a/data/experience_tables/fast_growth_rate.s b/data/experience_tables/fast_growth_rate.inc similarity index 100% rename from data/experience_tables/fast_growth_rate.s rename to data/experience_tables/fast_growth_rate.inc diff --git a/data/experience_tables/fluctuating_growth_rate.s b/data/experience_tables/fluctuating_growth_rate.inc similarity index 100% rename from data/experience_tables/fluctuating_growth_rate.s rename to data/experience_tables/fluctuating_growth_rate.inc diff --git a/data/experience_tables/medium_fast_growth_rate.s b/data/experience_tables/medium_fast_growth_rate.inc similarity index 100% rename from data/experience_tables/medium_fast_growth_rate.s rename to data/experience_tables/medium_fast_growth_rate.inc diff --git a/data/experience_tables/medium_slow_growth_rate.s b/data/experience_tables/medium_slow_growth_rate.inc similarity index 100% rename from data/experience_tables/medium_slow_growth_rate.s rename to data/experience_tables/medium_slow_growth_rate.inc diff --git a/data/experience_tables/slow_growth_rate.s b/data/experience_tables/slow_growth_rate.inc similarity index 100% rename from data/experience_tables/slow_growth_rate.s rename to data/experience_tables/slow_growth_rate.inc diff --git a/data/field_effect_scripts.s b/data/field_effect_scripts.s index 9f4a9ce3a..d879df0ce 100644 --- a/data/field_effect_scripts.s +++ b/data/field_effect_scripts.s @@ -1,5 +1,5 @@ - .include "asm/macros.s" - .include "constants/constants.s" + .include "asm/macros.inc" + .include "constants/constants.inc" .section script_data, "aw", %progbits diff --git a/data/graphics.s b/data/graphics.s index e71f55906..25925e5c8 100644 --- a/data/graphics.s +++ b/data/graphics.s @@ -10,7 +10,7 @@ gUnknown_08C00524:: @ 8C00524 .incbin "baserom.gba", 0xc00524, 0x22c @ 8C00750 - .include "data/graphics/pokemon/circled_question_mark_graphics.s" + .include "data/graphics/pokemon/circled_question_mark_graphics.inc" @ 8C00C10 .incbin "baserom.gba", 0xc00c10, 0x16f0 @@ -160,10 +160,10 @@ gUnknown_08C2EA9C:: @ 8C2EA9C .incbin "baserom.gba", 0xc2ea9c, 0xf6c @ 8C2FA08 - .include "data/graphics/pokemon/mon_graphics.s" + .include "data/graphics/pokemon/mon_graphics.inc" @ 8D51DC8 - .include "data/graphics/trainers/trainer_graphics.s" + .include "data/graphics/trainers/trainer_graphics.inc" .align 2 gMonIcon_QuestionMark:: @ 8D774D0 @@ -540,7 +540,7 @@ gUnknown_08D9C13C:: @ 8D9C13C .incbin "baserom.gba", 0xd9c13c, 0x26c @ 8D9C3A8 - .include "data/graphics/berries/berry_graphics.s" + .include "data/graphics/berries/berry_graphics.inc" @ 8DA1E78 .incbin "baserom.gba", 0xda1e78, 0x1548 @@ -633,7 +633,7 @@ gUnknown_08DAAFEC:: @ 8DAAFEC .incbin "baserom.gba", 0xdaafec, 0x6c @ 8DAB058 - .include "data/graphics/items/item_graphics.s" + .include "data/graphics/items/item_graphics.inc" @ 8DB7AA0 .incbin "baserom.gba", 0xdb7aa0, 0x2a78 @@ -716,21 +716,19 @@ gUnknown_08DC3A0C:: @ 8DC3A0C gUnknown_08DC3CD4:: @ 8DC3CD4 .incbin "baserom.gba", 0xdc3cd4, 0x80 + .align 2 gIntroCopyright_Pal:: @ 8DC3D54 .incbin "graphics/intro/copyright.gbapal" .align 2 - gIntroCopyright_Gfx:: @ 8DC3D74 .incbin "graphics/intro/copyright.4bpp.lz" .align 2 - gIntroCopyright_Tilemap:: @ 8DC3FD4 .incbin "graphics/intro/copyright.bin.lz" .align 2 - gUnknown_08DC4120:: @ 8DC4120 .incbin "baserom.gba", 0xdc4120, 0x20 diff --git a/data/graphics/berries/berry_graphics.s b/data/graphics/berries/berry_graphics.inc similarity index 100% rename from data/graphics/berries/berry_graphics.s rename to data/graphics/berries/berry_graphics.inc diff --git a/data/graphics/berries/berry_pic_table.s b/data/graphics/berries/berry_pic_table.inc similarity index 100% rename from data/graphics/berries/berry_pic_table.s rename to data/graphics/berries/berry_pic_table.inc diff --git a/data/graphics/field_objects/berry_tree_graphics_tables.s b/data/graphics/field_objects/berry_tree_graphics_tables.inc similarity index 100% rename from data/graphics/field_objects/berry_tree_graphics_tables.s rename to data/graphics/field_objects/berry_tree_graphics_tables.inc diff --git a/data/graphics/field_objects/field_effect_object_template_pointers.s b/data/graphics/field_objects/field_effect_object_template_pointers.inc similarity index 100% rename from data/graphics/field_objects/field_effect_object_template_pointers.s rename to data/graphics/field_objects/field_effect_object_template_pointers.inc diff --git a/data/graphics/field_objects/field_effect_objects.s b/data/graphics/field_objects/field_effect_objects.inc similarity index 100% rename from data/graphics/field_objects/field_effect_objects.s rename to data/graphics/field_objects/field_effect_objects.inc diff --git a/data/graphics/field_objects/field_object_anims.s b/data/graphics/field_objects/field_object_anims.inc similarity index 100% rename from data/graphics/field_objects/field_object_anims.s rename to data/graphics/field_objects/field_object_anims.inc diff --git a/data/graphics/field_objects/field_object_graphics.s b/data/graphics/field_objects/field_object_graphics.inc similarity index 100% rename from data/graphics/field_objects/field_object_graphics.s rename to data/graphics/field_objects/field_object_graphics.inc diff --git a/data/graphics/field_objects/field_object_graphics_info.s b/data/graphics/field_objects/field_object_graphics_info.inc similarity index 100% rename from data/graphics/field_objects/field_object_graphics_info.s rename to data/graphics/field_objects/field_object_graphics_info.inc diff --git a/data/graphics/field_objects/field_object_graphics_info_pointers.s b/data/graphics/field_objects/field_object_graphics_info_pointers.inc similarity index 100% rename from data/graphics/field_objects/field_object_graphics_info_pointers.s rename to data/graphics/field_objects/field_object_graphics_info_pointers.inc diff --git a/data/graphics/field_objects/field_object_oam.s b/data/graphics/field_objects/field_object_oam.inc similarity index 100% rename from data/graphics/field_objects/field_object_oam.s rename to data/graphics/field_objects/field_object_oam.inc diff --git a/data/graphics/field_objects/field_object_pic_tables.s b/data/graphics/field_objects/field_object_pic_tables.inc similarity index 100% rename from data/graphics/field_objects/field_object_pic_tables.s rename to data/graphics/field_objects/field_object_pic_tables.inc diff --git a/data/graphics/fonts/font0_latin_widths.s b/data/graphics/fonts/font0_latin_widths.inc similarity index 100% rename from data/graphics/fonts/font0_latin_widths.s rename to data/graphics/fonts/font0_latin_widths.inc diff --git a/data/graphics/fonts/font1_latin_widths.s b/data/graphics/fonts/font1_latin_widths.inc similarity index 100% rename from data/graphics/fonts/font1_latin_widths.s rename to data/graphics/fonts/font1_latin_widths.inc diff --git a/data/graphics/fonts/font2_japanese_widths.s b/data/graphics/fonts/font2_japanese_widths.inc similarity index 100% rename from data/graphics/fonts/font2_japanese_widths.s rename to data/graphics/fonts/font2_japanese_widths.inc diff --git a/data/graphics/fonts/font2_latin_widths.s b/data/graphics/fonts/font2_latin_widths.inc similarity index 100% rename from data/graphics/fonts/font2_latin_widths.s rename to data/graphics/fonts/font2_latin_widths.inc diff --git a/data/graphics/fonts/font7_latin_widths.s b/data/graphics/fonts/font7_latin_widths.inc similarity index 100% rename from data/graphics/fonts/font7_latin_widths.s rename to data/graphics/fonts/font7_latin_widths.inc diff --git a/data/graphics/fonts/font8_latin_widths.s b/data/graphics/fonts/font8_latin_widths.inc similarity index 100% rename from data/graphics/fonts/font8_latin_widths.s rename to data/graphics/fonts/font8_latin_widths.inc diff --git a/data/graphics/fonts/unused_japanese_frlg_female_font_widths.s b/data/graphics/fonts/unused_japanese_frlg_female_font_widths.inc similarity index 100% rename from data/graphics/fonts/unused_japanese_frlg_female_font_widths.s rename to data/graphics/fonts/unused_japanese_frlg_female_font_widths.inc diff --git a/data/graphics/fonts/unused_japanese_frlg_male_font_widths.s b/data/graphics/fonts/unused_japanese_frlg_male_font_widths.inc similarity index 100% rename from data/graphics/fonts/unused_japanese_frlg_male_font_widths.s rename to data/graphics/fonts/unused_japanese_frlg_male_font_widths.inc diff --git a/data/graphics/items/item_graphics.s b/data/graphics/items/item_graphics.inc similarity index 100% rename from data/graphics/items/item_graphics.s rename to data/graphics/items/item_graphics.inc diff --git a/data/graphics/items/item_icon_table.s b/data/graphics/items/item_icon_table.inc similarity index 100% rename from data/graphics/items/item_icon_table.s rename to data/graphics/items/item_icon_table.inc diff --git a/data/graphics/pokemon/circled_question_mark_graphics.s b/data/graphics/pokemon/circled_question_mark_graphics.inc similarity index 100% rename from data/graphics/pokemon/circled_question_mark_graphics.s rename to data/graphics/pokemon/circled_question_mark_graphics.inc diff --git a/data/graphics/pokemon/mon_back_pic_table.s b/data/graphics/pokemon/mon_back_pic_table.inc similarity index 100% rename from data/graphics/pokemon/mon_back_pic_table.s rename to data/graphics/pokemon/mon_back_pic_table.inc diff --git a/data/graphics/pokemon/mon_footprint_table.s b/data/graphics/pokemon/mon_footprint_table.inc similarity index 100% rename from data/graphics/pokemon/mon_footprint_table.s rename to data/graphics/pokemon/mon_footprint_table.inc diff --git a/data/graphics/pokemon/mon_front_pic_table.s b/data/graphics/pokemon/mon_front_pic_table.inc similarity index 100% rename from data/graphics/pokemon/mon_front_pic_table.s rename to data/graphics/pokemon/mon_front_pic_table.inc diff --git a/data/graphics/pokemon/mon_graphics.s b/data/graphics/pokemon/mon_graphics.inc similarity index 100% rename from data/graphics/pokemon/mon_graphics.s rename to data/graphics/pokemon/mon_graphics.inc diff --git a/data/graphics/pokemon/mon_icon_palette_indices.s b/data/graphics/pokemon/mon_icon_palette_indices.inc similarity index 100% rename from data/graphics/pokemon/mon_icon_palette_indices.s rename to data/graphics/pokemon/mon_icon_palette_indices.inc diff --git a/data/graphics/pokemon/mon_icon_palette_table.s b/data/graphics/pokemon/mon_icon_palette_table.inc similarity index 100% rename from data/graphics/pokemon/mon_icon_palette_table.s rename to data/graphics/pokemon/mon_icon_palette_table.inc diff --git a/data/graphics/pokemon/mon_icon_table.s b/data/graphics/pokemon/mon_icon_table.inc similarity index 100% rename from data/graphics/pokemon/mon_icon_table.s rename to data/graphics/pokemon/mon_icon_table.inc diff --git a/data/graphics/pokemon/mon_palette_table.s b/data/graphics/pokemon/mon_palette_table.inc similarity index 100% rename from data/graphics/pokemon/mon_palette_table.s rename to data/graphics/pokemon/mon_palette_table.inc diff --git a/data/graphics/pokemon/mon_shiny_palette_table.s b/data/graphics/pokemon/mon_shiny_palette_table.inc similarity index 100% rename from data/graphics/pokemon/mon_shiny_palette_table.s rename to data/graphics/pokemon/mon_shiny_palette_table.inc diff --git a/data/graphics/pokemon/mon_still_front_pic_table.s b/data/graphics/pokemon/mon_still_front_pic_table.inc similarity index 100% rename from data/graphics/pokemon/mon_still_front_pic_table.s rename to data/graphics/pokemon/mon_still_front_pic_table.inc diff --git a/data/graphics/trainers/trainer_back_pic_palette_table.s b/data/graphics/trainers/trainer_back_pic_palette_table.inc similarity index 100% rename from data/graphics/trainers/trainer_back_pic_palette_table.s rename to data/graphics/trainers/trainer_back_pic_palette_table.inc diff --git a/data/graphics/trainers/trainer_back_pic_table.s b/data/graphics/trainers/trainer_back_pic_table.inc similarity index 100% rename from data/graphics/trainers/trainer_back_pic_table.s rename to data/graphics/trainers/trainer_back_pic_table.inc diff --git a/data/graphics/trainers/trainer_front_pic_palette_table.s b/data/graphics/trainers/trainer_front_pic_palette_table.inc similarity index 100% rename from data/graphics/trainers/trainer_front_pic_palette_table.s rename to data/graphics/trainers/trainer_front_pic_palette_table.inc diff --git a/data/graphics/trainers/trainer_front_pic_table.s b/data/graphics/trainers/trainer_front_pic_table.inc similarity index 100% rename from data/graphics/trainers/trainer_front_pic_table.s rename to data/graphics/trainers/trainer_front_pic_table.inc diff --git a/data/graphics/trainers/trainer_graphics.s b/data/graphics/trainers/trainer_graphics.inc similarity index 100% rename from data/graphics/trainers/trainer_graphics.s rename to data/graphics/trainers/trainer_graphics.inc diff --git a/data/item_effect_info.s b/data/item_effect_info.inc similarity index 100% rename from data/item_effect_info.s rename to data/item_effect_info.inc diff --git a/data/items.s b/data/items.inc similarity index 100% rename from data/items.s rename to data/items.inc diff --git a/data/level_up_learnset_pointers.s b/data/level_up_learnset_pointers.inc similarity index 100% rename from data/level_up_learnset_pointers.s rename to data/level_up_learnset_pointers.inc diff --git a/data/level_up_learnsets.s b/data/level_up_learnsets.inc similarity index 100% rename from data/level_up_learnsets.s rename to data/level_up_learnsets.inc diff --git a/data/nature_stat_table.s b/data/nature_stat_table.inc similarity index 100% rename from data/nature_stat_table.s rename to data/nature_stat_table.inc diff --git a/data/pickup_items.s b/data/pickup_items.inc similarity index 100% rename from data/pickup_items.s rename to data/pickup_items.inc diff --git a/data/pokedex_entries.s b/data/pokedex_entries.inc similarity index 100% rename from data/pokedex_entries.s rename to data/pokedex_entries.inc diff --git a/data/pokedex_order.s b/data/pokedex_order.inc similarity index 100% rename from data/pokedex_order.s rename to data/pokedex_order.inc diff --git a/data/region_map_entries.s b/data/region_map_entries.inc similarity index 100% rename from data/region_map_entries.s rename to data/region_map_entries.inc diff --git a/data/rtc.s b/data/rtc.inc similarity index 100% rename from data/rtc.s rename to data/rtc.inc diff --git a/data/spinda_spot_graphics.s b/data/spinda_spot_graphics.inc similarity index 100% rename from data/spinda_spot_graphics.s rename to data/spinda_spot_graphics.inc diff --git a/data/string_util.s b/data/string_util.inc similarity index 100% rename from data/string_util.s rename to data/string_util.inc diff --git a/data/text/ability_description_pointers.s b/data/text/ability_description_pointers.inc similarity index 100% rename from data/text/ability_description_pointers.s rename to data/text/ability_description_pointers.inc diff --git a/data/text/ability_descriptions.s b/data/text/ability_descriptions.inc similarity index 100% rename from data/text/ability_descriptions.s rename to data/text/ability_descriptions.inc diff --git a/data/text/ability_names.s b/data/text/ability_names.inc similarity index 100% rename from data/text/ability_names.s rename to data/text/ability_names.inc diff --git a/data/text/berry_descriptions.s b/data/text/berry_descriptions.inc similarity index 100% rename from data/text/berry_descriptions.s rename to data/text/berry_descriptions.inc diff --git a/data/text/berry_firmness_strings.s b/data/text/berry_firmness_strings.inc similarity index 100% rename from data/text/berry_firmness_strings.s rename to data/text/berry_firmness_strings.inc diff --git a/data/text/contest_text.s b/data/text/contest_text.inc similarity index 100% rename from data/text/contest_text.s rename to data/text/contest_text.inc diff --git a/data/text/contest_text_pointers.s b/data/text/contest_text_pointers.inc similarity index 100% rename from data/text/contest_text_pointers.s rename to data/text/contest_text_pointers.inc diff --git a/data/text/easy_chat/easy_chat_group_name_pointers.s b/data/text/easy_chat/easy_chat_group_name_pointers.inc similarity index 100% rename from data/text/easy_chat/easy_chat_group_name_pointers.s rename to data/text/easy_chat/easy_chat_group_name_pointers.inc diff --git a/data/text/easy_chat/easy_chat_group_names.s b/data/text/easy_chat/easy_chat_group_names.inc similarity index 100% rename from data/text/easy_chat/easy_chat_group_names.s rename to data/text/easy_chat/easy_chat_group_names.inc diff --git a/data/text/easy_chat/easy_chat_groups.s b/data/text/easy_chat/easy_chat_groups.inc similarity index 100% rename from data/text/easy_chat/easy_chat_groups.s rename to data/text/easy_chat/easy_chat_groups.inc diff --git a/data/text/easy_chat/easy_chat_words_by_letter.s b/data/text/easy_chat/easy_chat_words_by_letter.inc similarity index 100% rename from data/text/easy_chat/easy_chat_words_by_letter.s rename to data/text/easy_chat/easy_chat_words_by_letter.inc diff --git a/data/text/gift_ribbon_descriptions.s b/data/text/gift_ribbon_descriptions.inc similarity index 100% rename from data/text/gift_ribbon_descriptions.s rename to data/text/gift_ribbon_descriptions.inc diff --git a/data/text/item_descriptions.s b/data/text/item_descriptions.inc similarity index 100% rename from data/text/item_descriptions.s rename to data/text/item_descriptions.inc diff --git a/data/text/move_descriptions.s b/data/text/move_descriptions.inc similarity index 100% rename from data/text/move_descriptions.s rename to data/text/move_descriptions.inc diff --git a/data/text/move_names.s b/data/text/move_names.inc similarity index 100% rename from data/text/move_names.s rename to data/text/move_names.inc diff --git a/data/text/nature_names.s b/data/text/nature_names.inc similarity index 100% rename from data/text/nature_names.s rename to data/text/nature_names.inc diff --git a/data/text/pokedex_text.s b/data/text/pokedex_text.inc similarity index 100% rename from data/text/pokedex_text.s rename to data/text/pokedex_text.inc diff --git a/data/text/ribbon_descriptions.s b/data/text/ribbon_descriptions.inc similarity index 100% rename from data/text/ribbon_descriptions.s rename to data/text/ribbon_descriptions.inc diff --git a/data/text/species_names.s b/data/text/species_names.inc similarity index 100% rename from data/text/species_names.s rename to data/text/species_names.inc diff --git a/data/text/trainer_class_names.s b/data/text/trainer_class_names.inc similarity index 100% rename from data/text/trainer_class_names.s rename to data/text/trainer_class_names.inc diff --git a/data/text/type_names.s b/data/text/type_names.inc similarity index 100% rename from data/text/type_names.s rename to data/text/type_names.inc diff --git a/data/tilesets/metatiles.s b/data/tilesets/metatiles.inc similarity index 100% rename from data/tilesets/metatiles.s rename to data/tilesets/metatiles.inc diff --git a/data/tilesets/tileset_graphics.s b/data/tilesets/tileset_graphics.inc similarity index 100% rename from data/tilesets/tileset_graphics.s rename to data/tilesets/tileset_graphics.inc diff --git a/data/tilesets/tilesets.s b/data/tilesets/tilesets.inc similarity index 100% rename from data/tilesets/tilesets.s rename to data/tilesets/tilesets.inc diff --git a/data/tm_hm_learnsets.s b/data/tm_hm_learnsets.inc similarity index 100% rename from data/tm_hm_learnsets.s rename to data/tm_hm_learnsets.inc diff --git a/data/trainer_class_name_indices.s b/data/trainer_class_name_indices.inc similarity index 100% rename from data/trainer_class_name_indices.s rename to data/trainer_class_name_indices.inc diff --git a/data/trainer_parties.s b/data/trainer_parties.inc similarity index 100% rename from data/trainer_parties.s rename to data/trainer_parties.inc diff --git a/data/trainer_pic_indices.s b/data/trainer_pic_indices.inc similarity index 100% rename from data/trainer_pic_indices.s rename to data/trainer_pic_indices.inc diff --git a/data/trainers.s b/data/trainers.inc similarity index 100% rename from data/trainers.s rename to data/trainers.inc diff --git a/data/wild_mons.s b/data/wild_mons.inc similarity index 100% rename from data/wild_mons.s rename to data/wild_mons.inc diff --git a/src/libc.c b/src/libc.c index d00c30e09..1f457957b 100644 --- a/src/libc.c +++ b/src/libc.c @@ -11,163 +11,163 @@ void *memcpy(void *dst0, const void *src0, size_t len0) { - char *dst = dst0; - const char *src = src0; - long *aligned_dst; - const long *aligned_src; - unsigned int len = len0; - - // If the size is small, or either src or dst is unaligned, - // then go to the byte copy loop. This should be rare. - if(len >= 16 && !(UNALIGNED(src) | UNALIGNED(dst))) - { - aligned_dst = (long *)dst; - aligned_src = (long *)src; - - // Copy 4X long words at a time if possible. - while(len >= 16) - { - *aligned_dst++ = *aligned_src++; - *aligned_dst++ = *aligned_src++; - *aligned_dst++ = *aligned_src++; - *aligned_dst++ = *aligned_src++; - len -= 16; - } - - // Copy one long word at a time if possible - while(len >= 4) - { - *aligned_dst++ = *aligned_src++; - len -= 4; - } - - dst = (char *)aligned_dst; - src = (char *)aligned_src; - } - - // Pick up any remaining bytes with a byte copier. - while(len--) - *dst++ = *src++; - - return dst0; + char *dst = dst0; + const char *src = src0; + long *aligned_dst; + const long *aligned_src; + unsigned int len = len0; + + // If the size is small, or either src or dst is unaligned, + // then go to the byte copy loop. This should be rare. + if(len >= 16 && !(UNALIGNED(src) | UNALIGNED(dst))) + { + aligned_dst = (long *)dst; + aligned_src = (long *)src; + + // Copy 4X long words at a time if possible. + while(len >= 16) + { + *aligned_dst++ = *aligned_src++; + *aligned_dst++ = *aligned_src++; + *aligned_dst++ = *aligned_src++; + *aligned_dst++ = *aligned_src++; + len -= 16; + } + + // Copy one long word at a time if possible + while(len >= 4) + { + *aligned_dst++ = *aligned_src++; + len -= 4; + } + + dst = (char *)aligned_dst; + src = (char *)aligned_src; + } + + // Pick up any remaining bytes with a byte copier. + while(len--) + *dst++ = *src++; + + return dst0; } void *memset(void *m, int c, size_t n) { - char *s = (char *)m; - int count, i; - unsigned long buffer; - unsigned long *aligned_addr; - unsigned char *unaligned_addr; - - // If the size is small or m is unaligned, - // then go to the byte copy loop. This should be rare. - if(n >= LBLOCKSIZE && !UNALIGNED(m)) - { - // We know that n is large and m is word-aligned. - aligned_addr = (unsigned long *)m; - - // Store C into each char sized location in buffer so that - // we can set large blocks quickly. - c &= 0xFF; - if(LBLOCKSIZE == 4) - { - buffer = (c << 8) | c; - buffer |= (buffer << 16); - } - else - { - buffer = 0; - for(i = 0; i < LBLOCKSIZE; i++) - buffer = (buffer << 8) | c; - } - - while(n >= LBLOCKSIZE * 4) - { - *aligned_addr++ = buffer; - *aligned_addr++ = buffer; - *aligned_addr++ = buffer; - *aligned_addr++ = buffer; - n -= LBLOCKSIZE * 4; - } - while(n >= LBLOCKSIZE) - { - *aligned_addr++ = buffer; - n -= LBLOCKSIZE; - } - - s = (char *)aligned_addr; - } - - // Pick up the remainder with a bytewise loop. - while(n--) - *s++ = (char)c; - - return m; + char *s = (char *)m; + int count, i; + unsigned long buffer; + unsigned long *aligned_addr; + unsigned char *unaligned_addr; + + // If the size is small or m is unaligned, + // then go to the byte copy loop. This should be rare. + if(n >= LBLOCKSIZE && !UNALIGNED(m)) + { + // We know that n is large and m is word-aligned. + aligned_addr = (unsigned long *)m; + + // Store C into each char sized location in buffer so that + // we can set large blocks quickly. + c &= 0xFF; + if(LBLOCKSIZE == 4) + { + buffer = (c << 8) | c; + buffer |= (buffer << 16); + } + else + { + buffer = 0; + for(i = 0; i < LBLOCKSIZE; i++) + buffer = (buffer << 8) | c; + } + + while(n >= LBLOCKSIZE * 4) + { + *aligned_addr++ = buffer; + *aligned_addr++ = buffer; + *aligned_addr++ = buffer; + *aligned_addr++ = buffer; + n -= LBLOCKSIZE * 4; + } + while(n >= LBLOCKSIZE) + { + *aligned_addr++ = buffer; + n -= LBLOCKSIZE; + } + + s = (char *)aligned_addr; + } + + // Pick up the remainder with a bytewise loop. + while(n--) + *s++ = (char)c; + + return m; } int strcmp(const char *s1, const char *s2) { - unsigned long *a1; - unsigned long *a2; - - // If s1 or s2 are unaligned, then skip this and compare bytes. - if(!(UNALIGNED(s1) | UNALIGNED(s2))) - { - // Compare them a word at a time. - a1 = (unsigned long *)s1; - a2 = (unsigned long *)s2; - while(*a1 == *a2) - { - // If *a1 == *a2, and we find a null in *a1, - // then the strings must be equal, so return zero. - if(CONTAINSNULL(*a1)) - return 0; - - a1++; - a2++; - } - - s1 = (char *)a1; - s2 = (char *)a2; - } - - // Check the remaining few bytes. - while(*s1 != '\0' && *s1 == *s2) - { - s1++; - s2++; - } - - return (*(unsigned char *) s1) - (*(unsigned char *) s2); + unsigned long *a1; + unsigned long *a2; + + // If s1 or s2 are unaligned, then skip this and compare bytes. + if(!(UNALIGNED(s1) | UNALIGNED(s2))) + { + // Compare them a word at a time. + a1 = (unsigned long *)s1; + a2 = (unsigned long *)s2; + while(*a1 == *a2) + { + // If *a1 == *a2, and we find a null in *a1, + // then the strings must be equal, so return zero. + if(CONTAINSNULL(*a1)) + return 0; + + a1++; + a2++; + } + + s1 = (char *)a1; + s2 = (char *)a2; + } + + // Check the remaining few bytes. + while(*s1 != '\0' && *s1 == *s2) + { + s1++; + s2++; + } + + return (*(unsigned char *) s1) - (*(unsigned char *) s2); } char* strcpy(char *dst0, const char *src0) { - char *dst = dst0; - const char *src = src0; - unsigned long *a1; - const unsigned long *a2; - - /* If SRC or DEST is unaligned, then copy bytes. */ - if(!(UNALIGNED(src) | UNALIGNED(dst))) - { - /* SRC and DEST are both "long int" aligned, try to do "long int" - sized copies. */ - a1 = (unsigned long *)dst; - a2 = (unsigned long *)src; - while(!CONTAINSNULL(*a2)) - { - *a1++ = *a2++; - } - - dst = (char *)a1; - src = (char *)a2; - } - - // Copy the remaining few bytes. - while(*dst++ = *src++); - - return dst0; + char *dst = dst0; + const char *src = src0; + unsigned long *a1; + const unsigned long *a2; + + // If SRC or DEST is unaligned, then copy bytes. + if(!(UNALIGNED(src) | UNALIGNED(dst))) + { + // SRC and DEST are both "long int" aligned, try to do "long int" + // sized copies. + a1 = (unsigned long *)dst; + a2 = (unsigned long *)src; + while(!CONTAINSNULL(*a2)) + { + *a1++ = *a2++; + } + + dst = (char *)a1; + src = (char *)a2; + } + + // Copy the remaining few bytes. + while(*dst++ = *src++); + + return dst0; } diff --git a/tools/gbagfx/.gitignore b/tools/gbagfx/.gitignore deleted file mode 100644 index dbbb3f04c..000000000 --- a/tools/gbagfx/.gitignore +++ /dev/null @@ -1 +0,0 @@ -gbagfx diff --git a/tools/gbagfx/LICENSE b/tools/gbagfx/LICENSE deleted file mode 100644 index b66bf81c0..000000000 --- a/tools/gbagfx/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015 YamaArashi - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tools/gbagfx/Makefile b/tools/gbagfx/Makefile deleted file mode 100644 index e7f089445..000000000 --- a/tools/gbagfx/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -CC = gcc - -CFLAGS = -Wall -Wextra -std=c11 -O2 - -LIBS = -lz -lpng - -SRCS = main.c convert_png.c gfx.c jasc_pal.c lz.c util.c font.c - -.PHONY: clean - -gbagfx: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h util.h font.h - $(CC) $(CFLAGS) $(SRCS) -o $@ $(LIBS) - -clean: - $(RM) gbagfx gbagfx.exe diff --git a/tools/gbagfx/convert_png.c b/tools/gbagfx/convert_png.c deleted file mode 100644 index f6a30804a..000000000 --- a/tools/gbagfx/convert_png.c +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright (c) 2015 YamaArashi - -#include -#include -#include -#include "global.h" -#include "convert_png.h" -#include "gfx.h" - -void ReadPng(char *path, struct Image *image) -{ - FILE *fp = fopen(path, "rb"); - - if (fp == NULL) - FATAL_ERROR("Failed to open \"%s\" for reading.\n", path); - - unsigned char sig[8]; - - if (fread(sig, 8, 1, fp) != 1) - FATAL_ERROR("Failed to read PNG signature from \"%s\".\n", path); - - if (png_sig_cmp(sig, 0, 8)) - FATAL_ERROR("\"%s\" does not have a valid PNG signature.\n", path); - - png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - - if (!png_ptr) - FATAL_ERROR("Failed to create PNG read struct.\n"); - - png_infop info_ptr = png_create_info_struct(png_ptr); - - if (!info_ptr) - FATAL_ERROR("Failed to create PNG info struct.\n"); - - if (setjmp(png_jmpbuf(png_ptr))) - FATAL_ERROR("Failed to init I/O for reading \"%s\".\n", path); - - png_init_io(png_ptr, fp); - png_set_sig_bytes(png_ptr, 8); - png_read_info(png_ptr, info_ptr); - - int bit_depth = png_get_bit_depth(png_ptr, info_ptr); - - if (bit_depth != image->bitDepth) - FATAL_ERROR("\"%s\" has a bit depth of %d, but the expected bit depth is %d.\n", path, bit_depth, image->bitDepth); - - int color_type = png_get_color_type(png_ptr, info_ptr); - - if (color_type != PNG_COLOR_TYPE_GRAY && color_type != PNG_COLOR_TYPE_PALETTE) - FATAL_ERROR("\"%s\" has an unsupported color type.\n", path); - - // Check if the image has a palette so that we can tell if the colors need to be inverted later. - // Don't read the palette because it's not needed for now. - image->hasPalette = (color_type == PNG_COLOR_TYPE_PALETTE); - - image->width = png_get_image_width(png_ptr, info_ptr); - image->height = png_get_image_height(png_ptr, info_ptr); - - int rowbytes = png_get_rowbytes(png_ptr, info_ptr); - - image->pixels = malloc(image->height * rowbytes); - - if (image->pixels == NULL) - FATAL_ERROR("Failed to allocate pixel buffer.\n"); - - png_bytepp row_pointers = malloc(image->height * sizeof(png_bytep)); - - if (row_pointers == NULL) - FATAL_ERROR("Failed to allocate row pointers.\n"); - - for (int i = 0; i < image->height; i++) - row_pointers[i] = (png_bytep)(image->pixels + (i * rowbytes)); - - if (setjmp(png_jmpbuf(png_ptr))) - FATAL_ERROR("Error reading from \"%s\".\n", path); - - png_read_image(png_ptr, row_pointers); - - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - - free(row_pointers); - fclose(fp); -} - -void SetPngPalette(png_structp png_ptr, png_infop info_ptr, struct Palette *palette) -{ - png_colorp colors = malloc(palette->numColors * sizeof(png_color)); - - if (colors == NULL) - FATAL_ERROR("Failed to allocate PNG palette.\n"); - - for (int i = 0; i < palette->numColors; i++) { - colors[i].red = palette->colors[i].red; - colors[i].green = palette->colors[i].green; - colors[i].blue = palette->colors[i].blue; - } - - png_set_PLTE(png_ptr, info_ptr, colors, palette->numColors); - - free(colors); -} - -void WritePng(char *path, struct Image *image) -{ - FILE *fp = fopen(path, "wb"); - - if (fp == NULL) - FATAL_ERROR("Failed to open \"%s\" for writing.\n", path); - - png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - - if (!png_ptr) - FATAL_ERROR("Failed to create PNG write struct.\n"); - - png_infop info_ptr = png_create_info_struct(png_ptr); - - if (!info_ptr) - FATAL_ERROR("Failed to create PNG info struct.\n"); - - if (setjmp(png_jmpbuf(png_ptr))) - FATAL_ERROR("Failed to init I/O for writing \"%s\".\n", path); - - png_init_io(png_ptr, fp); - - if (setjmp(png_jmpbuf(png_ptr))) - FATAL_ERROR("Error writing header for \"%s\".\n", path); - - int color_type = image->hasPalette ? PNG_COLOR_TYPE_PALETTE : PNG_COLOR_TYPE_GRAY; - - png_set_IHDR(png_ptr, info_ptr, image->width, image->height, - image->bitDepth, color_type, PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - if (image->hasPalette) { - SetPngPalette(png_ptr, info_ptr, &image->palette); - - if (image->hasTransparency) { - png_byte trans = 0; - png_set_tRNS(png_ptr, info_ptr, &trans, 1, 0); - } - } - - png_write_info(png_ptr, info_ptr); - - png_bytepp row_pointers = malloc(image->height * sizeof(png_bytep)); - - if (row_pointers == NULL) - FATAL_ERROR("Failed to allocate row pointers.\n"); - - int rowbytes = png_get_rowbytes(png_ptr, info_ptr); - - for (int i = 0; i < image->height; i++) - row_pointers[i] = (png_bytep)(image->pixels + (i * rowbytes)); - - if (setjmp(png_jmpbuf(png_ptr))) - FATAL_ERROR("Error writing \"%s\".\n", path); - - png_write_image(png_ptr, row_pointers); - - if (setjmp(png_jmpbuf(png_ptr))) - FATAL_ERROR("Error ending write of \"%s\".\n", path); - - png_write_end(png_ptr, NULL); - - fclose(fp); - - png_destroy_write_struct(&png_ptr, &info_ptr); - free(row_pointers); -} diff --git a/tools/gbagfx/convert_png.h b/tools/gbagfx/convert_png.h deleted file mode 100644 index 55d3d6942..000000000 --- a/tools/gbagfx/convert_png.h +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2015 YamaArashi - -#ifndef CONVERT_PNG_H -#define CONVERT_PNG_H - -#include "gfx.h" - -void ReadPng(char *path, struct Image *image); -void WritePng(char *path, struct Image *image); - -#endif // CONVERT_PNG_H diff --git a/tools/gbagfx/font.c b/tools/gbagfx/font.c deleted file mode 100644 index 0dd6fbc3e..000000000 --- a/tools/gbagfx/font.c +++ /dev/null @@ -1,326 +0,0 @@ -// Copyright (c) 2015 YamaArashi - -#include -#include -#include -#include -#include "global.h" -#include "font.h" -#include "gfx.h" -#include "util.h" - -unsigned char gFontPalette[][3] = { - {0x90, 0xC8, 0xFF}, // bg (saturated blue that contrasts well with the shadow color) - {0x38, 0x38, 0x38}, // fg (dark grey) - {0xD8, 0xD8, 0xD8}, // shadow (light grey) - {0xFF, 0xFF, 0xFF} // box (white) -}; - -static void ConvertFromLatinFont(unsigned char *src, unsigned char *dest, unsigned int numRows) -{ - unsigned int srcPixelsOffset = 0; - - for (unsigned int row = 0; row < numRows; row++) { - for (unsigned int column = 0; column < 16; column++) { - for (unsigned int glyphTile = 0; glyphTile < 4; glyphTile++) { - unsigned int pixelsX = (column * 16) + ((glyphTile & 1) * 8); - - for (unsigned int i = 0; i < 8; i++) { - unsigned int pixelsY = (row * 16) + ((glyphTile >> 1) * 8) + i; - unsigned int destPixelsOffset = (pixelsY * 64) + (pixelsX / 4); - - dest[destPixelsOffset] = src[srcPixelsOffset + 1]; - dest[destPixelsOffset + 1] = src[srcPixelsOffset]; - - srcPixelsOffset += 2; - } - } - } - } -} - -static void ConvertToLatinFont(unsigned char *src, unsigned char *dest, unsigned int numRows) -{ - unsigned int destPixelsOffset = 0; - - for (unsigned int row = 0; row < numRows; row++) { - for (unsigned int column = 0; column < 16; column++) { - for (unsigned int glyphTile = 0; glyphTile < 4; glyphTile++) { - unsigned int pixelsX = (column * 16) + ((glyphTile & 1) * 8); - - for (unsigned int i = 0; i < 8; i++) { - unsigned int pixelsY = (row * 16) + ((glyphTile >> 1) * 8) + i; - unsigned int srcPixelsOffset = (pixelsY * 64) + (pixelsX / 4); - - dest[destPixelsOffset] = src[srcPixelsOffset + 1]; - dest[destPixelsOffset + 1] = src[srcPixelsOffset]; - - destPixelsOffset += 2; - } - } - } - } -} - -static void ConvertFromHalfwidthJapaneseFont(unsigned char *src, unsigned char *dest, unsigned int numRows) -{ - for (unsigned int row = 0; row < numRows; row++) { - for (unsigned int column = 0; column < 16; column++) { - unsigned int glyphIndex = (row * 16) + column; - - for (unsigned int glyphTile = 0; glyphTile < 2; glyphTile++) { - unsigned int pixelsX = column * 8; - unsigned int srcPixelsOffset = 512 * (glyphIndex >> 4) + 16 * (glyphIndex & 0xF) + 256 * glyphTile; - - for (unsigned int i = 0; i < 8; i++) { - unsigned int pixelsY = (row * 16) + (glyphTile * 8) + i; - unsigned int destPixelsOffset = (pixelsY * 32) + (pixelsX / 4); - - dest[destPixelsOffset] = src[srcPixelsOffset + 1]; - dest[destPixelsOffset + 1] = src[srcPixelsOffset]; - - srcPixelsOffset += 2; - } - } - } - } -} - -static void ConvertToHalfwidthJapaneseFont(unsigned char *src, unsigned char *dest, unsigned int numRows) -{ - for (unsigned int row = 0; row < numRows; row++) { - for (unsigned int column = 0; column < 16; column++) { - unsigned int glyphIndex = (row * 16) + column; - - for (unsigned int glyphTile = 0; glyphTile < 2; glyphTile++) { - unsigned int pixelsX = column * 8; - unsigned int destPixelsOffset = 512 * (glyphIndex >> 4) + 16 * (glyphIndex & 0xF) + 256 * glyphTile; - - for (unsigned int i = 0; i < 8; i++) { - unsigned int pixelsY = (row * 16) + (glyphTile * 8) + i; - unsigned int srcPixelsOffset = (pixelsY * 32) + (pixelsX / 4); - - dest[destPixelsOffset] = src[srcPixelsOffset + 1]; - dest[destPixelsOffset + 1] = src[srcPixelsOffset]; - - destPixelsOffset += 2; - } - } - } - } -} - -static void ConvertFromFullwidthJapaneseFont(unsigned char *src, unsigned char *dest, unsigned int numRows) -{ - for (unsigned int row = 0; row < numRows; row++) { - for (unsigned int column = 0; column < 16; column++) { - unsigned int glyphIndex = (row * 16) + column; - - for (unsigned int glyphTile = 0; glyphTile < 4; glyphTile++) { - unsigned int pixelsX = (column * 16) + ((glyphTile & 1) * 8); - unsigned int srcPixelsOffset = 512 * (glyphIndex >> 3) + 32 * (glyphIndex & 7) + 256 * (glyphTile >> 1) + 16 * (glyphTile & 1); - - for (unsigned int i = 0; i < 8; i++) { - unsigned int pixelsY = (row * 16) + ((glyphTile >> 1) * 8) + i; - unsigned int destPixelsOffset = (pixelsY * 64) + (pixelsX / 4); - - dest[destPixelsOffset] = src[srcPixelsOffset + 1]; - dest[destPixelsOffset + 1] = src[srcPixelsOffset]; - - srcPixelsOffset += 2; - } - } - } - } -} - -static void ConvertToFullwidthJapaneseFont(unsigned char *src, unsigned char *dest, unsigned int numRows) -{ - for (unsigned int row = 0; row < numRows; row++) { - for (unsigned int column = 0; column < 16; column++) { - unsigned int glyphIndex = (row * 16) + column; - - for (unsigned int glyphTile = 0; glyphTile < 4; glyphTile++) { - unsigned int pixelsX = (column * 16) + ((glyphTile & 1) * 8); - unsigned int destPixelsOffset = 512 * (glyphIndex >> 3) + 32 * (glyphIndex & 7) + 256 * (glyphTile >> 1) + 16 * (glyphTile & 1); - - for (unsigned int i = 0; i < 8; i++) { - unsigned int pixelsY = (row * 16) + ((glyphTile >> 1) * 8) + i; - unsigned int srcPixelsOffset = (pixelsY * 64) + (pixelsX / 4); - - dest[destPixelsOffset] = src[srcPixelsOffset + 1]; - dest[destPixelsOffset + 1] = src[srcPixelsOffset]; - - destPixelsOffset += 2; - } - } - } - } -} - -static void SetFontPalette(struct Image *image) -{ - image->hasPalette = true; - - image->palette.numColors = 4; - - for (int i = 0; i < image->palette.numColors; i++) { - image->palette.colors[i].red = gFontPalette[i][0]; - image->palette.colors[i].green = gFontPalette[i][1]; - image->palette.colors[i].blue = gFontPalette[i][2]; - } - - image->hasTransparency = false; -} - -void ReadLatinFont(char *path, struct Image *image) -{ - int fileSize; - unsigned char *buffer = ReadWholeFile(path, &fileSize); - - int numGlyphs = fileSize / 64; - - if (numGlyphs % 16 != 0) - FATAL_ERROR("The number of glyphs (%d) is not a multiple of 16.\n", numGlyphs); - - int numRows = numGlyphs / 16; - - image->width = 256; - image->height = numRows * 16; - image->bitDepth = 2; - image->pixels = malloc(fileSize); - - if (image->pixels == NULL) - FATAL_ERROR("Failed to allocate memory for font.\n"); - - ConvertFromLatinFont(buffer, image->pixels, numRows); - - free(buffer); - - SetFontPalette(image); -} - -void WriteLatinFont(char *path, struct Image *image) -{ - if (image->width != 256) - FATAL_ERROR("The width of the font image (%d) is not 256.\n", image->width); - - if (image->height % 16 != 0) - FATAL_ERROR("The height of the font image (%d) is not a multiple of 16.\n", image->height); - - int numRows = image->height / 16; - int bufferSize = numRows * 16 * 64; - unsigned char *buffer = malloc(bufferSize); - - if (buffer == NULL) - FATAL_ERROR("Failed to allocate memory for font.\n"); - - ConvertToLatinFont(image->pixels, buffer, numRows); - - WriteWholeFile(path, buffer, bufferSize); - - free(buffer); -} - -void ReadHalfwidthJapaneseFont(char *path, struct Image *image) -{ - int fileSize; - unsigned char *buffer = ReadWholeFile(path, &fileSize); - - int glyphSize = 32; - - if (fileSize % glyphSize != 0) - FATAL_ERROR("The file size (%d) is not a multiple of %d.\n", fileSize, glyphSize); - - int numGlyphs = fileSize / glyphSize; - - if (numGlyphs % 16 != 0) - FATAL_ERROR("The number of glyphs (%d) is not a multiple of 16.\n", numGlyphs); - - int numRows = numGlyphs / 16; - - image->width = 128; - image->height = numRows * 16; - image->bitDepth = 2; - image->pixels = malloc(fileSize); - - if (image->pixels == NULL) - FATAL_ERROR("Failed to allocate memory for font.\n"); - - ConvertFromHalfwidthJapaneseFont(buffer, image->pixels, numRows); - - free(buffer); - - SetFontPalette(image); -} - -void WriteHalfwidthJapaneseFont(char *path, struct Image *image) -{ - if (image->width != 128) - FATAL_ERROR("The width of the font image (%d) is not 128.\n", image->width); - - if (image->height % 16 != 0) - FATAL_ERROR("The height of the font image (%d) is not a multiple of 16.\n", image->height); - - int numRows = image->height / 16; - int bufferSize = numRows * 16 * 32; - unsigned char *buffer = malloc(bufferSize); - - if (buffer == NULL) - FATAL_ERROR("Failed to allocate memory for font.\n"); - - ConvertToHalfwidthJapaneseFont(image->pixels, buffer, numRows); - - WriteWholeFile(path, buffer, bufferSize); - - free(buffer); -} - -void ReadFullwidthJapaneseFont(char *path, struct Image *image) -{ - int fileSize; - unsigned char *buffer = ReadWholeFile(path, &fileSize); - - int numGlyphs = fileSize / 64; - - if (numGlyphs % 16 != 0) - FATAL_ERROR("The number of glyphs (%d) is not a multiple of 16.\n", numGlyphs); - - int numRows = numGlyphs / 16; - - image->width = 256; - image->height = numRows * 16; - image->bitDepth = 2; - image->pixels = malloc(fileSize); - - if (image->pixels == NULL) - FATAL_ERROR("Failed to allocate memory for font.\n"); - - ConvertFromFullwidthJapaneseFont(buffer, image->pixels, numRows); - - free(buffer); - - SetFontPalette(image); -} - -void WriteFullwidthJapaneseFont(char *path, struct Image *image) -{ - if (image->width != 256) - FATAL_ERROR("The width of the font image (%d) is not 256.\n", image->width); - - if (image->height % 16 != 0) - FATAL_ERROR("The height of the font image (%d) is not a multiple of 16.\n", image->height); - - int numRows = image->height / 16; - int bufferSize = numRows * 16 * 64; - unsigned char *buffer = malloc(bufferSize); - - if (buffer == NULL) - FATAL_ERROR("Failed to allocate memory for font.\n"); - - ConvertToFullwidthJapaneseFont(image->pixels, buffer, numRows); - - WriteWholeFile(path, buffer, bufferSize); - - free(buffer); -} diff --git a/tools/gbagfx/font.h b/tools/gbagfx/font.h deleted file mode 100644 index 45086d02a..000000000 --- a/tools/gbagfx/font.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2015 YamaArashi - -#ifndef FONT_H -#define FONT_H - -#include -#include "gfx.h" - -void ReadLatinFont(char *path, struct Image *image); -void WriteLatinFont(char *path, struct Image *image); -void ReadHalfwidthJapaneseFont(char *path, struct Image *image); -void WriteHalfwidthJapaneseFont(char *path, struct Image *image); -void ReadFullwidthJapaneseFont(char *path, struct Image *image); -void WriteFullwidthJapaneseFont(char *path, struct Image *image); - -#endif // FONT_H diff --git a/tools/gbagfx/gfx.c b/tools/gbagfx/gfx.c deleted file mode 100644 index c0f7f492c..000000000 --- a/tools/gbagfx/gfx.c +++ /dev/null @@ -1,329 +0,0 @@ -// Copyright (c) 2015 YamaArashi - -#include -#include -#include -#include -#include "global.h" -#include "gfx.h" -#include "util.h" - -#define GET_GBA_PAL_RED(x) (((x) >> 0) & 0x1F) -#define GET_GBA_PAL_GREEN(x) (((x) >> 5) & 0x1F) -#define GET_GBA_PAL_BLUE(x) (((x) >> 10) & 0x1F) - -#define SET_GBA_PAL(r, g, b) (((b) << 10) | ((g) << 5) | (r)) - -#define UPCONVERT_BIT_DEPTH(x) (((x) * 255) / 31) - -#define DOWNCONVERT_BIT_DEPTH(x) ((x) / 8) - -static void ConvertFromTiles1Bpp(unsigned char *src, unsigned char *dest, int numTiles, int tilesWidth, bool invertColors) -{ - int tilesX = 0; - int tilesY = 0; - int pitch = tilesWidth; - - for (int i = 0; i < numTiles; i++) { - for (int j = 0; j < 8; j++) { - int destY = tilesY * 8 + j; - int destX = tilesX; - unsigned char srcPixelOctet = *src++; - unsigned char *destPixelOctet = &dest[destY * pitch + destX]; - - for (int k = 0; k < 8; k++) { - *destPixelOctet <<= 1; - *destPixelOctet |= (srcPixelOctet & 1) ^ invertColors; - srcPixelOctet >>= 1; - } - } - - tilesX++; - - if (tilesX == tilesWidth) { - tilesX = 0; - tilesY++; - } - } -} - -static void ConvertFromTiles4Bpp(unsigned char *src, unsigned char *dest, int numTiles, int tilesWidth, bool invertColors) -{ - int tilesX = 0; - int tilesY = 0; - int pitch = tilesWidth * 4; - - for (int i = 0; i < numTiles; i++) { - for (int j = 0; j < 8; j++) { - int destY = tilesY * 8 + j; - - for (int k = 0; k < 4; k++) { - int destX = tilesX * 4 + k; - unsigned char srcPixelPair = *src++; - unsigned char leftPixel = srcPixelPair & 0xF; - unsigned char rightPixel = srcPixelPair >> 4; - - if (invertColors) { - leftPixel = 15 - leftPixel; - rightPixel = 15 - rightPixel; - } - - dest[destY * pitch + destX] = (leftPixel << 4) | rightPixel; - } - } - - tilesX++; - - if (tilesX == tilesWidth) { - tilesX = 0; - tilesY++; - } - } -} - -static void ConvertFromTiles8Bpp(unsigned char *src, unsigned char *dest, int numTiles, int tilesWidth, bool invertColors) -{ - int tilesX = 0; - int tilesY = 0; - int pitch = tilesWidth * 8; - - for (int i = 0; i < numTiles; i++) { - for (int j = 0; j < 8; j++) { - int destY = tilesY * 8 + j; - - for (int k = 0; k < 8; k++) { - int destX = tilesX * 8 + k; - unsigned char srcPixel = *src++; - - if (invertColors) - srcPixel = 255 - srcPixel; - - dest[destY * pitch + destX] = srcPixel; - } - } - - tilesX++; - - if (tilesX == tilesWidth) { - tilesX = 0; - tilesY++; - } - } -} - -static void ConvertToTiles1Bpp(unsigned char *src, unsigned char *dest, int numTiles, int tilesWidth, bool invertColors) -{ - int tilesX = 0; - int tilesY = 0; - int pitch = tilesWidth; - - for (int i = 0; i < numTiles; i++) { - for (int j = 0; j < 8; j++) { - int srcY = tilesY * 8 + j; - int srcX = tilesX; - unsigned char srcPixelOctet = src[srcY * pitch + srcX]; - unsigned char *destPixelOctet = dest++; - - for (int k = 0; k < 8; k++) { - *destPixelOctet <<= 1; - *destPixelOctet |= (srcPixelOctet & 1) ^ invertColors; - srcPixelOctet >>= 1; - } - } - - tilesX++; - - if (tilesX == tilesWidth) { - tilesX = 0; - tilesY++; - } - } -} - -static void ConvertToTiles4Bpp(unsigned char *src, unsigned char *dest, int numTiles, int tilesWidth, bool invertColors) -{ - int tilesX = 0; - int tilesY = 0; - int pitch = tilesWidth * 4; - - for (int i = 0; i < numTiles; i++) { - for (int j = 0; j < 8; j++) { - int srcY = tilesY * 8 + j; - - for (int k = 0; k < 4; k++) { - int srcX = tilesX * 4 + k; - unsigned char srcPixelPair = src[srcY * pitch + srcX]; - unsigned char leftPixel = srcPixelPair >> 4; - unsigned char rightPixel = srcPixelPair & 0xF; - - if (invertColors) { - leftPixel = 15 - leftPixel; - rightPixel = 15 - rightPixel; - } - - *dest++ = (rightPixel << 4) | leftPixel; - } - } - - tilesX++; - - if (tilesX == tilesWidth) { - tilesX = 0; - tilesY++; - } - } -} - -static void ConvertToTiles8Bpp(unsigned char *src, unsigned char *dest, int numTiles, int tilesWidth, bool invertColors) -{ - int tilesX = 0; - int tilesY = 0; - int pitch = tilesWidth * 8; - - for (int i = 0; i < numTiles; i++) { - for (int j = 0; j < 8; j++) { - int srcY = tilesY * 8 + j; - - for (int k = 0; k < 8; k++) { - int srcX = tilesX * 8 + k; - unsigned char srcPixel = src[srcY * pitch + srcX]; - - if (invertColors) - srcPixel = 255 - srcPixel; - - *dest++ = srcPixel; - } - } - - tilesX++; - - if (tilesX == tilesWidth) { - tilesX = 0; - tilesY++; - } - } -} - -void ReadImage(char *path, int tilesWidth, int bitDepth, struct Image *image, bool invertColors) -{ - int tileSize = bitDepth * 8; - - int fileSize; - unsigned char *buffer = ReadWholeFile(path, &fileSize); - - int numTiles = fileSize / tileSize; - - int tilesHeight = (numTiles + tilesWidth - 1) / tilesWidth; - - image->width = tilesWidth * 8; - image->height = tilesHeight * 8; - image->bitDepth = bitDepth; - image->pixels = calloc(tilesWidth * tilesHeight, tileSize); - - if (image->pixels == NULL) - FATAL_ERROR("Failed to allocate memory for pixels.\n"); - - switch (bitDepth) { - case 1: - ConvertFromTiles1Bpp(buffer, image->pixels, numTiles, tilesWidth, invertColors); - break; - case 4: - ConvertFromTiles4Bpp(buffer, image->pixels, numTiles, tilesWidth, invertColors); - break; - case 8: - ConvertFromTiles8Bpp(buffer, image->pixels, numTiles, tilesWidth, invertColors); - break; - } - - free(buffer); -} - -void WriteImage(char *path, int numTiles, int bitDepth, struct Image *image, bool invertColors) -{ - int tileSize = bitDepth * 8; - - if (image->width % 8 != 0) - FATAL_ERROR("The width in pixels (%d) isn't a multiple of 8.\n", image->width); - - if (image->height % 8 != 0) - FATAL_ERROR("The height in pixels (%d) isn't a multiple of 8.\n", image->height); - - int tilesWidth = image->width / 8; - int tilesHeight = image->height / 8; - - int maxNumTiles = tilesWidth * tilesHeight; - - if (numTiles == 0) - numTiles = maxNumTiles; - else if (numTiles > maxNumTiles) - FATAL_ERROR("The specified number of tiles (%d) is greater than the maximum possible value (%d).\n", numTiles, maxNumTiles); - - int bufferSize = numTiles * tileSize; - unsigned char *buffer = malloc(bufferSize); - - if (buffer == NULL) - FATAL_ERROR("Failed to allocate memory for pixels.\n"); - - switch (bitDepth) { - case 1: - ConvertToTiles1Bpp(image->pixels, buffer, numTiles, tilesWidth, invertColors); - break; - case 4: - ConvertToTiles4Bpp(image->pixels, buffer, numTiles, tilesWidth, invertColors); - break; - case 8: - ConvertToTiles8Bpp(image->pixels, buffer, numTiles, tilesWidth, invertColors); - break; - } - - WriteWholeFile(path, buffer, bufferSize); - - free(buffer); -} - -void FreeImage(struct Image *image) -{ - free(image->pixels); - image->pixels = NULL; -} - -void ReadGbaPalette(char *path, struct Palette *palette) -{ - int fileSize; - unsigned char *data = ReadWholeFile(path, &fileSize); - - if (fileSize % 2 != 0) - FATAL_ERROR("The file size (%d) is not a multiple of 2.\n", fileSize); - - palette->numColors = fileSize / 2; - - for (int i = 0; i < palette->numColors; i++) { - uint16_t paletteEntry = (data[i * 2 + 1] << 8) | data[i * 2]; - palette->colors[i].red = UPCONVERT_BIT_DEPTH(GET_GBA_PAL_RED(paletteEntry)); - palette->colors[i].green = UPCONVERT_BIT_DEPTH(GET_GBA_PAL_GREEN(paletteEntry)); - palette->colors[i].blue = UPCONVERT_BIT_DEPTH(GET_GBA_PAL_BLUE(paletteEntry)); - } - - free(data); -} - -void WriteGbaPalette(char *path, struct Palette *palette) -{ - FILE *fp = fopen(path, "wb"); - - if (fp == NULL) - FATAL_ERROR("Failed to open \"%s\" for writing.\n", path); - - for (int i = 0; i < palette->numColors; i++) { - unsigned char red = DOWNCONVERT_BIT_DEPTH(palette->colors[i].red); - unsigned char green = DOWNCONVERT_BIT_DEPTH(palette->colors[i].green); - unsigned char blue = DOWNCONVERT_BIT_DEPTH(palette->colors[i].blue); - - uint16_t paletteEntry = SET_GBA_PAL(red, green, blue); - - fputc(paletteEntry & 0xFF, fp); - fputc(paletteEntry >> 8, fp); - } - - fclose(fp); -} diff --git a/tools/gbagfx/gfx.h b/tools/gbagfx/gfx.h deleted file mode 100644 index ecd436652..000000000 --- a/tools/gbagfx/gfx.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2015 YamaArashi - -#ifndef GFX_H -#define GFX_H - -#include -#include - -struct Color { - unsigned char red; - unsigned char green; - unsigned char blue; -}; - -struct Palette { - struct Color colors[256]; - int numColors; -}; - -struct Image { - int width; - int height; - int bitDepth; - unsigned char *pixels; - bool hasPalette; - struct Palette palette; - bool hasTransparency; -}; - -void ReadImage(char *path, int tilesWidth, int bitDepth, struct Image *image, bool invertColors); -void WriteImage(char *path, int numTiles, int bitDepth, struct Image *image, bool invertColors); -void FreeImage(struct Image *image); -void ReadGbaPalette(char *path, struct Palette *palette); -void WriteGbaPalette(char *path, struct Palette *palette); - -#endif // GFX_H diff --git a/tools/gbagfx/global.h b/tools/gbagfx/global.h deleted file mode 100644 index 65dd351d2..000000000 --- a/tools/gbagfx/global.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2015 YamaArashi - -#ifndef GLOBAL_H -#define GLOBAL_H - -#include -#include - -#ifdef _MSC_VER - -#define FATAL_ERROR(format, ...) \ -do { \ - fprintf(stderr, format, __VA_ARGS__); \ - exit(1); \ -} while (0) - -#define UNUSED - -#else - -#define FATAL_ERROR(format, ...) \ -do { \ - fprintf(stderr, format, ##__VA_ARGS__); \ - exit(1); \ -} while (0) - -#define UNUSED __attribute__((__unused__)) - -#endif // _MSC_VER - -#endif // GLOBAL_H diff --git a/tools/gbagfx/jasc_pal.c b/tools/gbagfx/jasc_pal.c deleted file mode 100644 index 02b6ed915..000000000 --- a/tools/gbagfx/jasc_pal.c +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (c) 2015 YamaArashi - -#include -#include -#include "global.h" -#include "gfx.h" -#include "util.h" - -// Read/write Paint Shop Pro palette files. - -// Format of a Paint Shop Pro palette file, line by line: -// "JASC-PAL\r\n" (signature) -// "0100\r\n" (version; seems to always be "0100") -// "\r\n" (number of colors in decimal) -// -// 16 or 256 times (depending on above line): -// " \r\n" (color entry) -// -// Each color component is a decimal number from 0 to 255. -// Examples: -// Black - "0 0 0\r\n" -// Blue - "0 0 255\r\n" -// Brown - "150 75 0\r\n" - -#define MAX_LINE_LENGTH 11 - -void ReadJascPaletteLine(FILE *fp, char *line) -{ - int c; - int length = 0; - - for (;;) { - c = fgetc(fp); - - if (c == '\r') { - c = fgetc(fp); - - if (c != '\n') - FATAL_ERROR("CR line endings aren't supported.\n"); - - line[length] = 0; - - return; - } - - if (c == '\n') - FATAL_ERROR("LF line endings aren't supported.\n"); - - if (c == EOF) - FATAL_ERROR("Unexpected EOF. No CRLF at end of file.\n"); - - if (c == 0) - FATAL_ERROR("NUL character in file.\n"); - - if (length == MAX_LINE_LENGTH) { - line[length] = 0; - FATAL_ERROR("The line \"%s\" is too long.\n", line); - } - - line[length++] = c; - } -} - -void ReadJascPalette(char *path, struct Palette *palette) -{ - char line[MAX_LINE_LENGTH + 1]; - - FILE *fp = fopen(path, "rb"); - - ReadJascPaletteLine(fp, line); - - if (strcmp(line, "JASC-PAL") != 0) - FATAL_ERROR("Invalid JASC-PAL signature.\n"); - - ReadJascPaletteLine(fp, line); - - if (strcmp(line, "0100") != 0) - FATAL_ERROR("Unsuported JASC-PAL version.\n"); - - ReadJascPaletteLine(fp, line); - - if (!ParseNumber(line, NULL, 10, &palette->numColors)) - FATAL_ERROR("Failed to parse number of colors.\n"); - - if (palette->numColors != 16 && palette->numColors != 256) - FATAL_ERROR("%d is an invalid number of colors. The number of colors must be 16 or 256.\n", palette->numColors); - - for (int i = 0; i < palette->numColors; i++) { - ReadJascPaletteLine(fp, line); - - char *s = line; - char *end; - - int red; - int green; - int blue; - - if (!ParseNumber(s, &end, 10, &red)) - FATAL_ERROR("Failed to parse red color component.\n"); - - s = end; - - if (*s != ' ') - FATAL_ERROR("Expected a space after red color component.\n"); - - s++; - - if (*s < '0' || *s > '9') - FATAL_ERROR("Expected only a space between red and green color components.\n"); - - if (!ParseNumber(s, &end, 10, &green)) - FATAL_ERROR("Failed to parse green color component.\n"); - - s = end; - - if (*s != ' ') - FATAL_ERROR("Expected a space after green color component.\n"); - - s++; - - if (*s < '0' || *s > '9') - FATAL_ERROR("Expected only a space between green and blue color components.\n"); - - if (!ParseNumber(s, &end, 10, &blue)) - FATAL_ERROR("Failed to parse blue color component.\n"); - - if (*end != 0) - FATAL_ERROR("Garbage after blue color component.\n"); - - if (red < 0 || red > 255) - FATAL_ERROR("Red color component (%d) is outside the range [0, 255].\n", red); - - if (green < 0 || green > 255) - FATAL_ERROR("Green color component (%d) is outside the range [0, 255].\n", green); - - if (blue < 0 || blue > 255) - FATAL_ERROR("Blue color component (%d) is outside the range [0, 255].\n", blue); - - palette->colors[i].red = red; - palette->colors[i].green = green; - palette->colors[i].blue = blue; - } - - if (fgetc(fp) != EOF) - FATAL_ERROR("Garbage after color data.\n"); - - fclose(fp); -} - -void WriteJascPalette(char *path, struct Palette *palette) -{ - FILE *fp = fopen(path, "wb"); - - fputs("JASC-PAL\r\n", fp); - fputs("0100\r\n", fp); - fprintf(fp, "%d\r\n", palette->numColors); - - for (int i = 0; i < palette->numColors; i++) { - struct Color *color = &palette->colors[i]; - fprintf(fp, "%d %d %d\r\n", color->red, color->green, color->blue); - } - - fclose(fp); -} diff --git a/tools/gbagfx/jasc_pal.h b/tools/gbagfx/jasc_pal.h deleted file mode 100644 index b60b31fc8..000000000 --- a/tools/gbagfx/jasc_pal.h +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2015 YamaArashi - -#ifndef JASC_PAL_H -#define JASC_PAL_H - -void ReadJascPalette(char *path, struct Palette *palette); -void WriteJascPalette(char *path, struct Palette *palette); - -#endif // JASC_PAL_H diff --git a/tools/gbagfx/lz.c b/tools/gbagfx/lz.c deleted file mode 100644 index 7669dab9a..000000000 --- a/tools/gbagfx/lz.c +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) 2015 YamaArashi - -#include -#include -#include "global.h" -#include "lz.h" - -unsigned char *LZDecompress(unsigned char *src, int srcSize, int *uncompressedSize) -{ - if (srcSize < 4) - return NULL; - - int destSize = (src[3] << 16) | (src[2] << 8) | src[1]; - - unsigned char *dest = malloc(destSize); - - if (dest == NULL) - return NULL; - - int srcPos = 4; - int destPos = 0; - - for (;;) { - if (srcPos >= srcSize) - return NULL; - - unsigned char flags = src[srcPos++]; - - for (int i = 0; i < 8; i++) { - if (flags & 0x80) { - if (srcPos + 1 >= srcSize) - return NULL; - - int blockSize = (src[srcPos] >> 4) + 3; - int blockDistance = (((src[srcPos] & 0xF) << 8) | src[srcPos + 1]) + 1; - - srcPos += 2; - - int blockPos = destPos - blockDistance; - - if (destPos + blockSize > destSize || blockPos < 0) - return NULL; - - for (int j = 0; j < blockSize; j++) - dest[destPos++] = dest[blockPos + j]; - } else { - if (srcPos >= srcSize || destPos >= destSize) - return NULL; - - dest[destPos++] = src[srcPos++]; - } - - if (destPos == destSize) { - *uncompressedSize = destSize; - return dest; - } - - flags <<= 1; - } - } -} - -unsigned char *LZCompress(unsigned char *src, int srcSize, int *compressedSize) -{ - const int minDistance = 2; // for compatibility with LZ77UnCompVram() - - if (srcSize <= 0) - return NULL; - - int worstCaseDestSize = 4 + srcSize + ((srcSize + 7) / 8); - - // Round up to the next multiple of four. - worstCaseDestSize = (worstCaseDestSize + 3) & ~3; - - unsigned char *dest = malloc(worstCaseDestSize); - - if (dest == NULL) - return NULL; - - // header - dest[0] = 0x10; // LZ compression type - dest[1] = (unsigned char)srcSize; - dest[2] = (unsigned char)(srcSize >> 8); - dest[3] = (unsigned char)(srcSize >> 16); - - int srcPos = 0; - int destPos = 4; - - for (;;) { - unsigned char *flags = &dest[destPos++]; - *flags = 0; - - for (int i = 0; i < 8; i++) { - int bestBlockDistance = 0; - int bestBlockSize = 0; - int blockDistance = minDistance; - - while (blockDistance <= srcPos && blockDistance <= 0x1000) { - int blockStart = srcPos - blockDistance; - int blockSize = 0; - - while (blockSize < 18 - && srcPos + blockSize < srcSize - && src[blockStart + blockSize] == src[srcPos + blockSize]) - blockSize++; - - if (blockSize > bestBlockSize) { - bestBlockDistance = blockDistance; - bestBlockSize = blockSize; - - if (blockSize == 18) - break; - } - - blockDistance++; - } - - if (bestBlockSize >= 3) { - *flags |= (0x80 >> i); - srcPos += bestBlockSize; - bestBlockSize -= 3; - bestBlockDistance--; - dest[destPos++] = (bestBlockSize << 4) | ((unsigned int)bestBlockDistance >> 8); - dest[destPos++] = (unsigned char)bestBlockDistance; - } else { - dest[destPos++] = src[srcPos++]; - } - - if (srcPos == srcSize) { - // Pad to multiple of 4 bytes. - int remainder = destPos % 4; - - if (remainder != 0) { - for (int i = 0; i < 4 - remainder; i++) - dest[destPos++] = 0; - } - - *compressedSize = destPos; - return dest; - } - } - } -} diff --git a/tools/gbagfx/lz.h b/tools/gbagfx/lz.h deleted file mode 100644 index 164d62279..000000000 --- a/tools/gbagfx/lz.h +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2015 YamaArashi - -#ifndef LZ_H -#define LZ_H - -unsigned char *LZDecompress(unsigned char *src, int srcSize, int *uncompressedSize); -unsigned char *LZCompress(unsigned char *src, int srcSize, int *compressedSize); - -#endif // LZ_H diff --git a/tools/gbagfx/main.c b/tools/gbagfx/main.c deleted file mode 100644 index cc1e8f807..000000000 --- a/tools/gbagfx/main.c +++ /dev/null @@ -1,302 +0,0 @@ -// Copyright (c) 2015 YamaArashi - -#include -#include -#include -#include "global.h" -#include "util.h" -#include "gfx.h" -#include "convert_png.h" -#include "jasc_pal.h" -#include "lz.h" -#include "font.h" - -struct CommandHandler -{ - const char *inputFileExtension; - const char *outputFileExtension; - void(*function)(char *inputPath, char *outputPath, int argc, char **argv); -}; - -void ConvertGbaToPng(char *inputPath, char *outputPath, int width, int bitDepth, char *paletteFilePath, bool hasTransparency) -{ - struct Image image; - - if (paletteFilePath != NULL) { - ReadGbaPalette(paletteFilePath, &image.palette); - image.hasPalette = true; - } else { - image.hasPalette = false; - } - - ReadImage(inputPath, width, bitDepth, &image, !image.hasPalette); - - image.hasTransparency = hasTransparency; - - WritePng(outputPath, &image); - - FreeImage(&image); -} - -void ConvertPngToGba(char *inputPath, char *outputPath, int numTiles, int bitDepth) -{ - struct Image image; - - image.bitDepth = bitDepth; - - ReadPng(inputPath, &image); - - WriteImage(outputPath, numTiles, bitDepth, &image, !image.hasPalette); - - FreeImage(&image); -} - -void HandleGbaToPngCommand(char *inputPath, char *outputPath, int argc, char **argv) -{ - char *inputFileExtension = GetFileExtension(inputPath); - int bitDepth = inputFileExtension[0] - '0'; - char *paletteFilePath; - bool hasPalette = false; - bool hasTransparency = false; - int width = 1; - - for (int i = 3; i < argc; i++) { - char *option = argv[i]; - - if (strcmp(option, "-palette") == 0) { - if (i + 1 >= argc) - FATAL_ERROR("No palette file path following \"-palette\".\n"); - - i++; - - paletteFilePath = argv[i]; - - hasPalette = true; - } else if (strcmp(option, "-object") == 0) { - hasTransparency = true; - } else if (strcmp(option, "-width") == 0) { - if (i + 1 >= argc) - FATAL_ERROR("No width following \"-width\".\n"); - - i++; - - if (!ParseNumber(argv[i], NULL, 10, &width)) - FATAL_ERROR("Failed to parse width.\n"); - - if (width < 1) - FATAL_ERROR("Width must be positive.\n"); - } else { - FATAL_ERROR("Unrecognized option \"%s\".\n", option); - } - } - - ConvertGbaToPng(inputPath, outputPath, width, bitDepth, hasPalette ? paletteFilePath : NULL, hasTransparency); -} - -void HandlePngToGbaCommand(char *inputPath, char *outputPath, int argc, char **argv) -{ - char *outputFileExtension = GetFileExtension(outputPath); - int bitDepth = outputFileExtension[0] - '0'; - int numTiles = 0; - - for (int i = 3; i < argc; i++) { - char *option = argv[i]; - - if (strcmp(option, "-num_tiles") == 0) { - if (i + 1 >= argc) - FATAL_ERROR("No number of tiles following \"-num_tiles\".\n"); - - i++; - - if (!ParseNumber(argv[i], NULL, 10, &numTiles)) - FATAL_ERROR("Failed to parse number of tiles.\n"); - - if (numTiles < 1) - FATAL_ERROR("Number of tiles must be positive.\n"); - } else { - FATAL_ERROR("Unrecognized option \"%s\".\n", option); - } - } - - ConvertPngToGba(inputPath, outputPath, numTiles, bitDepth); -} - -void HandleGbaToJascPaletteCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) -{ - struct Palette palette; - - ReadGbaPalette(inputPath, &palette); - WriteJascPalette(outputPath, &palette); -} - -void HandleJascToGbaPaletteCommand(char *inputPath, char *outputPath, int argc, char **argv) -{ - int numColors = 0; - - for (int i = 3; i < argc; i++) { - char *option = argv[i]; - - if (strcmp(option, "-num_colors") == 0) { - if (i + 1 >= argc) - FATAL_ERROR("No number of colors following \"-num_colors\".\n"); - - i++; - - if (!ParseNumber(argv[i], NULL, 10, &numColors)) - FATAL_ERROR("Failed to parse number of colors.\n"); - - if (numColors < 1) - FATAL_ERROR("Number of colors must be positive.\n"); - } else { - FATAL_ERROR("Unrecognized option \"%s\".\n", option); - } - } - - struct Palette palette; - - ReadJascPalette(inputPath, &palette); - - if (numColors != 0) - palette.numColors = numColors; - - WriteGbaPalette(outputPath, &palette); -} - -void HandleLatinFontToPngCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) -{ - struct Image image; - - ReadLatinFont(inputPath, &image); - WritePng(outputPath, &image); - - FreeImage(&image); -} - -void HandlePngToLatinFontCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) -{ - struct Image image; - - image.bitDepth = 2; - - ReadPng(inputPath, &image); - WriteLatinFont(outputPath, &image); - - FreeImage(&image); -} - -void HandleHalfwidthJapaneseFontToPngCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) -{ - struct Image image; - - ReadHalfwidthJapaneseFont(inputPath, &image); - WritePng(outputPath, &image); - - FreeImage(&image); -} - -void HandlePngToHalfwidthJapaneseFontCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) -{ - struct Image image; - - image.bitDepth = 2; - - ReadPng(inputPath, &image); - WriteHalfwidthJapaneseFont(outputPath, &image); - - FreeImage(&image); -} - -void HandleFullwidthJapaneseFontToPngCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) -{ - struct Image image; - - ReadFullwidthJapaneseFont(inputPath, &image); - WritePng(outputPath, &image); - - FreeImage(&image); -} - -void HandlePngToFullwidthJapaneseFontCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) -{ - struct Image image; - - image.bitDepth = 2; - - ReadPng(inputPath, &image); - WriteFullwidthJapaneseFont(outputPath, &image); - - FreeImage(&image); -} - -void HandleLZCompressCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) -{ - int fileSize; - unsigned char *buffer = ReadWholeFile(inputPath, &fileSize); - - int compressedSize; - unsigned char *compressedData = LZCompress(buffer, fileSize, &compressedSize); - - free(buffer); - - WriteWholeFile(outputPath, compressedData, compressedSize); - - free(compressedData); -} - -void HandleLZDecompressCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) -{ - int fileSize; - unsigned char *buffer = ReadWholeFile(inputPath, &fileSize); - - int uncompressedSize; - unsigned char *uncompressedData = LZDecompress(buffer, fileSize, &uncompressedSize); - - free(buffer); - - WriteWholeFile(outputPath, uncompressedData, uncompressedSize); - - free(uncompressedData); -} - -int main(int argc, char **argv) -{ - if (argc < 3) - FATAL_ERROR("Usage: gbagfx INPUT_PATH OUTPUT_PATH [options...]\n"); - - struct CommandHandler handlers[] = - { - { "1bpp", "png", HandleGbaToPngCommand }, - { "4bpp", "png", HandleGbaToPngCommand }, - { "8bpp", "png", HandleGbaToPngCommand }, - { "png", "1bpp", HandlePngToGbaCommand }, - { "png", "4bpp", HandlePngToGbaCommand }, - { "png", "8bpp", HandlePngToGbaCommand }, - { "gbapal", "pal", HandleGbaToJascPaletteCommand }, - { "pal", "gbapal", HandleJascToGbaPaletteCommand }, - { "latfont", "png", HandleLatinFontToPngCommand }, - { "png", "latfont", HandlePngToLatinFontCommand }, - { "hwjpnfont", "png", HandleHalfwidthJapaneseFontToPngCommand }, - { "png", "hwjpnfont", HandlePngToHalfwidthJapaneseFontCommand }, - { "fwjpnfont", "png", HandleFullwidthJapaneseFontToPngCommand }, - { "png", "fwjpnfont", HandlePngToFullwidthJapaneseFontCommand }, - { NULL, "lz", HandleLZCompressCommand }, - { "lz", NULL, HandleLZDecompressCommand }, - { NULL, NULL, NULL } - }; - - char *inputPath = argv[1]; - char *outputPath = argv[2]; - - for (int i = 0; handlers[i].function != NULL; i++) { - char *inputFileExtension = GetFileExtension(inputPath); - char *outputFileExtension = GetFileExtension(outputPath); - - if ((handlers[i].inputFileExtension == NULL || strcmp(handlers[i].inputFileExtension, inputFileExtension) == 0) - && (handlers[i].outputFileExtension == NULL || strcmp(handlers[i].outputFileExtension, outputFileExtension) == 0)) { - handlers[i].function(inputPath, outputPath, argc, argv); - return 0; - } - } - - FATAL_ERROR("Don't know how to convert \"%s\" to \"%s\".\n", inputPath, outputPath); -} diff --git a/tools/gbagfx/util.c b/tools/gbagfx/util.c deleted file mode 100644 index 5af380184..000000000 --- a/tools/gbagfx/util.c +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2015 YamaArashi - -#include -#include -#include -#include -#include -#include -#include "global.h" -#include "util.h" - -bool ParseNumber(char *s, char **end, int radix, int *intValue) -{ - char *localEnd; - - if (end == NULL) - end = &localEnd; - - errno = 0; - - const long longValue = strtol(s, end, radix); - - if (*end == s) - return false; // not a number - - if ((longValue == LONG_MIN || longValue == LONG_MAX) && errno == ERANGE) - return false; - - if (longValue > INT_MAX) - return false; - - if (longValue < INT_MIN) - return false; - - *intValue = (int)longValue; - - return true; -} - -char *GetFileExtension(char *path) -{ - char *extension = path; - - while (*extension != 0) - extension++; - - while (extension > path && *extension != '.') - extension--; - - if (extension == path) - return NULL; - - extension++; - - if (*extension == 0) - return NULL; - - return extension; -} - -unsigned char *ReadWholeFile(char *path, int *size) -{ - FILE *fp = fopen(path, "rb"); - - if (fp == NULL) - FATAL_ERROR("Failed to open \"%s\" for reading.\n", path); - - fseek(fp, 0, SEEK_END); - - *size = ftell(fp); - - unsigned char *buffer = malloc(*size); - - if (buffer == NULL) - FATAL_ERROR("Failed to allocate memory for reading \"%s\".\n", path); - - rewind(fp); - - if (fread(buffer, *size, 1, fp) != 1) - FATAL_ERROR("Failed to read \"%s\".\n", path); - - fclose(fp); - - return buffer; -} - -void WriteWholeFile(char *path, void *buffer, int bufferSize) -{ - FILE *fp = fopen(path, "wb"); - - if (fp == NULL) - FATAL_ERROR("Failed to open \"%s\" for writing.\n", path); - - if (fwrite(buffer, bufferSize, 1, fp) != 1) - FATAL_ERROR("Failed to write to \"%s\".\n", path); - - fclose(fp); -} diff --git a/tools/gbagfx/util.h b/tools/gbagfx/util.h deleted file mode 100644 index cb26a31ef..000000000 --- a/tools/gbagfx/util.h +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2015 YamaArashi - -#ifndef UTIL_H -#define UTIL_H - -#include - -bool ParseNumber(char *s, char **end, int radix, int *intValue); -char *GetFileExtension(char *path); -unsigned char *ReadWholeFile(char *path, int *size); -void WriteWholeFile(char *path, void *buffer, int bufferSize); - -#endif // UTIL_H diff --git a/tools/scaninc/.gitignore b/tools/scaninc/.gitignore deleted file mode 100644 index 94bfbf989..000000000 --- a/tools/scaninc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -scaninc diff --git a/tools/scaninc/LICENSE b/tools/scaninc/LICENSE deleted file mode 100644 index b66bf81c0..000000000 --- a/tools/scaninc/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015 YamaArashi - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tools/scaninc/Makefile b/tools/scaninc/Makefile deleted file mode 100644 index 0efe283f1..000000000 --- a/tools/scaninc/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -CXX = g++ - -CXXFLAGS = -Wall -std=c++11 -O2 - -SRCS = scaninc.cpp - -.PHONY: clean - -scaninc: $(SRCS) - $(CXX) $(CXXFLAGS) $(SRCS) -o $@ - -clean: - $(RM) scaninc scaninc.exe diff --git a/tools/scaninc/scaninc.cpp b/tools/scaninc/scaninc.cpp deleted file mode 100644 index 9a228180a..000000000 --- a/tools/scaninc/scaninc.cpp +++ /dev/null @@ -1,320 +0,0 @@ -// Copyright (c) 2015 YamaArashi - -#include -#include -#include -#include -#include - -#ifdef _MSC_VER - -#define FATAL_INPUT_ERROR(format, ...) \ -do { \ - fprintf(stderr, "%s:%d " format, m_path.c_str(), m_lineNum, __VA_ARGS__); \ - exit(1); \ -} while (0) - -#define FATAL_ERROR(format, ...) \ -do { \ - fprintf(stderr, format, __VA_ARGS__); \ - exit(1); \ -} while (0) - -#else - -#define FATAL_INPUT_ERROR(format, ...) \ -do { \ - fprintf(stderr, "%s:%d " format, m_path.c_str(), m_lineNum, ##__VA_ARGS__); \ - exit(1); \ -} while (0) - -#define FATAL_ERROR(format, ...) \ -do { \ - fprintf(stderr, format, ##__VA_ARGS__); \ - exit(1); \ -} while (0) - -#endif // _MSC_VER - -#define SCANINC_MAX_PATH 255 - -enum class IncDirectiveType { - None, - Include, - Incbin -}; - -class AsmFile -{ -public: - AsmFile(std::string path); - ~AsmFile(); - IncDirectiveType ReadUntilIncDirective(std::string &path); - -private: - char *m_buffer; - int m_pos; - int m_size; - int m_lineNum; - std::string m_path; - - int GetChar() - { - if (m_pos >= m_size) - return -1; - - int c = m_buffer[m_pos++]; - - if (c == '\r') { - if (m_pos < m_size && m_buffer[m_pos++] == '\n') { - m_lineNum++; - return '\n'; - } else { - FATAL_INPUT_ERROR("CR line endings are not supported\n"); - } - } - - if (c == '\n') - m_lineNum++; - - return c; - } - - // No newline translation because it's not needed for any use of this function. - int PeekChar() - { - if (m_pos >= m_size) - return -1; - - return m_buffer[m_pos]; - } - - void SkipTabsAndSpaces() - { - while (m_pos < m_size && (m_buffer[m_pos] == '\t' || m_buffer[m_pos] == ' ')) - m_pos++; - } - - bool MatchIncDirective(std::string directiveName, std::string &path) - { - int length = directiveName.length(); - int i; - - for (i = 0; i < length && m_pos + i < m_size; i++) - if (directiveName[i] != m_buffer[m_pos + i]) - return false; - - if (i < length) - return false; - - m_pos += length; - - SkipTabsAndSpaces(); - - if (GetChar() != '"') - FATAL_INPUT_ERROR("no path after \".%s\" directive\n", directiveName.c_str()); - - path = ReadPath(); - - return true; - } - - std::string ReadPath(); - void SkipEndOfLineComment(); - void SkipMultiLineComment(); - void SkipString(); -}; - -AsmFile::AsmFile(std::string path) -{ - m_path = path; - - FILE *fp = fopen(path.c_str(), "rb"); - - if (fp == NULL) - FATAL_ERROR("Failed to open \"%s\" for reading.\n", path.c_str()); - - fseek(fp, 0, SEEK_END); - - m_size = ftell(fp); - - m_buffer = new char[m_size]; - - rewind(fp); - - if (fread(m_buffer, m_size, 1, fp) != 1) - FATAL_ERROR("Failed to read \"%s\".\n", path.c_str()); - - fclose(fp); - - m_pos = 0; - m_lineNum = 1; -} - -AsmFile::~AsmFile() -{ - delete[] m_buffer; -} - -IncDirectiveType AsmFile::ReadUntilIncDirective(std::string &path) -{ - // At the beginning of each loop iteration, the current file position - // should be at the start of a line or at the end of the file. - for (;;) { - SkipTabsAndSpaces(); - - IncDirectiveType incDirectiveType = IncDirectiveType::None; - - if (PeekChar() == '.') { - m_pos++; - - if (MatchIncDirective("incbin", path)) - incDirectiveType = IncDirectiveType::Incbin; - else if (MatchIncDirective("include", path)) - incDirectiveType = IncDirectiveType::Include; - } - - for (;;) { - int c = GetChar(); - - if (c == -1) - return incDirectiveType; - - if (c == ';') { - SkipEndOfLineComment(); - break; - } else if (c == '/' && PeekChar() == '*') { - m_pos++; - SkipMultiLineComment(); - } else if (c == '"') { - SkipString(); - } else if (c == '\n') { - break; - } - } - - if (incDirectiveType != IncDirectiveType::None) - return incDirectiveType; - } -} - -std::string AsmFile::ReadPath() -{ - int length = 0; - int startPos = m_pos; - - for (;;) { - int c = GetChar(); - - if (c == '"') - break; - - if (c == -1) - FATAL_INPUT_ERROR("unexpected EOF in include string\n"); - - if (c == 0) - FATAL_INPUT_ERROR("unexpected NUL character in include string\n"); - - if (c == '\n') - FATAL_INPUT_ERROR("unexpected end of line character in include string\n"); - - if (c == '\\') { - c = GetChar(); - - if (c != '"') - FATAL_INPUT_ERROR("unknown escape \"\\%c\" in include string\n", c); - } - - length++; - - if (length > SCANINC_MAX_PATH) - FATAL_INPUT_ERROR("path is too long"); - } - - return std::string(m_buffer, startPos, length); -} - -void AsmFile::SkipEndOfLineComment() -{ - int c; - - do { - c = GetChar(); - } while (c != -1 && c != '\n'); -} - -void AsmFile::SkipMultiLineComment() -{ - for (;;) { - int c = GetChar(); - - if (c == '*') { - if (PeekChar() == '/') { - m_pos++; - return; - } - } else if (c == -1) { - return; - } - } -} - -void AsmFile::SkipString() -{ - for (;;) { - int c = GetChar(); - - if (c == '"') - break; - - if (c == -1) - FATAL_INPUT_ERROR("unexpected EOF in string\n"); - - if (c == '\\') { - c = GetChar(); - } - } -} - -bool CanOpenFile(std::string path) -{ - FILE *fp = fopen(path.c_str(), "rb"); - - if (fp == NULL) - return false; - - fclose(fp); - return true; -} - -int main(int argc, char **argv) -{ - if (argc < 2) - FATAL_ERROR("Usage: scaninc ASM_FILE_PATH\n"); - - std::stack filesToProcess; - std::set dependencies; - - filesToProcess.push(std::string(argv[1])); - - while (!filesToProcess.empty()) { - AsmFile file(filesToProcess.top()); - - filesToProcess.pop(); - - IncDirectiveType incDirectiveType; - std::string path; - - while ((incDirectiveType = file.ReadUntilIncDirective(path)) != IncDirectiveType::None) { - bool inserted = dependencies.insert(path).second; - if (inserted - && incDirectiveType == IncDirectiveType::Include - && CanOpenFile(path)) - filesToProcess.push(path); - } - } - - for (const std::string &path : dependencies) { - printf("%s\n", path.c_str()); - } -}