From d576a07fbafb48449474651d384e37d34c111cbd Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Tue, 27 Apr 2021 15:48:43 +0200 Subject: Add most of the BIOS assembly calls --- src/bios_calls.s | 336 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 332 insertions(+), 4 deletions(-) diff --git a/src/bios_calls.s b/src/bios_calls.s index 2268b4d..740fa02 100644 --- a/src/bios_calls.s +++ b/src/bios_calls.s @@ -1,9 +1,337 @@ -@ Bios division call. - .text @ aka .section .text - .code 16 @ aka .thumb - .align 2 @ aka .balign 4 +@ +@ Arithmetic functions. +@ + +@ Division. + .text + .code 16 + .align 2 .global bios_div .thumb_func bios_div: swi 0x06 bx lr + +@ Square root. + .text + .code 16 + .align 2 + .global bios_sqrt + .thumb_func +bios_sqrt: + swi 0x08 + bx lr + +@ Arc-tangent. + .text + .code 16 + .align 2 + .global bios_atan + .thumb_func +bios_atan: + swi 0x09 + bx lr + +@ Arc-tangent2. + .text + .code 16 + .align 2 + .global bios_atan2 + .thumb_func +bios_atan2: + swi 0x0a + bx lr + +@ +@ Rotation/Scaling. +@ + +@ BG Affine Set. + .text + .code 16 + .align 2 + .global bios_bg_affine_set + .thumb_func +bios_bg_affine_set: + swi 0x0e + bx lr + +@ OBJ Affine Set. + .text + .code 16 + .align 2 + .global bios_obj_affine_set + .thumb_func +bios_obj_affine_set: + swi 0x0f + bx lr + +@ +@ (De)compression. +@ + +@ Bit unpacking. + .text + .code 16 + .align 2 + .global bios_bit_unpack + .thumb_func +bios_bit_unpack: + swi 0x10 + bx lr + +@ Huffman decompression. + .text + .code 16 + .align 2 + .global bios_huff_expand + .thumb_func +bios_huff_expand: + swi 0x13 + bx lr + +@ LZ77 decompression (Fast, WRAM, 8 bit writes). + .text + .code 16 + .align 2 + .global bios_lz77_expand_wram + .thumb_func +bios_lz77_expand_wram: + swi 0x11 + bx lr + +@ LZ77 decompression (Slow, VRAM, 16 bit writes). + .text + .code 16 + .align 2 + .global bios_lz77_expand_vram + .thumb_func +bios_lz77_expand_vram: + swi 0x12 + bx lr + +@ Run length encoding decompression (Fast, WRAM, 8 bit writes). + .text + .code 16 + .align 2 + .global bios_rle_expand_wram + .thumb_func +bios_rle_expand_wram: + swi 0x14 + bx lr + +@ Run length encoding decompression (Slow, VRAM, 16 bit writes). + .text + .code 16 + .align 2 + .global bios_rle_expand_vram + .thumb_func +bios_rle_expand_vram: + swi 0x15 + bx lr + +@ +@ Memory copy. +@ + +@ Memcopy/memfill in 32 byte units (Fast). + .text + .code 16 + .align 2 + .global bios_memcopy_32 + .thumb_func +bios_memcopy_32: + swi 0x0C + bx lr + +@ Memcopy/memfill in 4 / 2 byte units (Slow). + .text + .code 16 + .align 2 + .global bios_memcopy_8 + .thumb_func +bios_memcopy_8: + swi 0x0B + bx lr + +@ +@ Sound functions. +@ + +@ MIDI key to frequency. + .text + .code 16 + .align 2 + .global bios_midi2freq + .thumb_func +bios_midi2freq: + swi 0x1f + bx lr + +@ Sound bias. + .text + .code 16 + .align 2 + .global bios_sound_bias + .thumb_func +bios_sound_bias: + swi 0x19 + bx lr + +@ Sound channels clear. + .text + .code 16 + .align 2 + .global bios_sound_clear + .thumb_func +bios_sound_clear: + swi 0x1e + bx lr + +@ Sound driver initialization. + .text + .code 16 + .align 2 + .global bios_sound_init + .thumb_func +bios_sound_init: + swi 0x1a + bx lr + +@ Sound main function. To be called each 1/60 of a second after the sound VSync. + .text + .code 16 + .align 2 + .global bios_sound_main + .thumb_func +bios_sound_main: + swi 0x1c + bx lr + +@ Sound driver operation mode. + .text + .code 16 + .align 2 + .global bios_sound_mode + .thumb_func +bios_sound_mode: + swi 0x1b + bx lr + +@ Sound VSync. Called just after the VBlank interrupt each 1/60 of a second. + .text + .code 16 + .align 2 + .global bios_sound_vsync + .thumb_func +bios_sound_vsync: + swi 0x1d + bx lr + +@ Sound VSync off In case of issues manually call this to stop the sound. + .text + .code 16 + .align 2 + .global bios_sound_vsync_off + .thumb_func +bios_sound_vsync_off: + swi 0x28 + bx lr + +@ +@ Halt/Reset functions. +@ + +@ Halt until interrupt request. + .text + .code 16 + .align 2 + .global bios_halt + .thumb_func +bios_halt: + swi 0x02 + bx lr + +@ Halt until one of the specified interrupts occur. + .text + .code 16 + .align 2 + .global bios_interrupt_wait + .thumb_func +bios_interrupt_wait: + swi 0x04 + bx lr + +@ Halt until the VBlank interrupt occurs. + .text + .code 16 + .align 2 + .global bios_vblank_wait + .thumb_func +bios_vblank_wait: + swi 0x05 + bx lr + +@ Stop. Switches GBA to low power mode. + .text + .code 16 + .align 2 + .global bios_stop + .thumb_func +bios_stop: + swi 0x03 + bx lr + +@ Soft reset. + .text + .code 16 + .align 2 + .global bios_soft_reset + .thumb_func +bios_soft_reset: + swi 0x00 + bx lr + +@ Register RAM reset. + .text + .code 16 + .align 2 + .global bios_regram_reset + .thumb_func +bios_regram_reset: + swi 0x01 + bx lr + +@ Hard reset. + .text + .code 16 + .align 2 + .global bios_hard_reset + .thumb_func +bios_hard_reset: + swi 0x26 + bx lr + +@ +@ Misc functions. +@ + +@ BIOS checksum. + .text + .code 16 + .align 2 + .global bios_bios_checksum + .thumb_func +bios_bios_checksum: + swi 0x0d + bx lr + +@ MultiBoot. + .text + .code 16 + .align 2 + .global bios_multiboot + .thumb_func +bios_multiboot: + swi 0x25 + bx lr -- cgit v1.2.1