Checking in Normatt's BIOS source code for reference and development.

This commit is contained in:
David Guillen Fandos 2021-09-07 00:28:31 +02:00
parent ad6bf7f24a
commit 663767b078
9 changed files with 2308 additions and 0 deletions

140
bios/Makefile Normal file
View File

@ -0,0 +1,140 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
include $(DEVKITARM)/gba_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
# SPECS is the directory containing the important build and link files
#---------------------------------------------------------------------------------
export TARGET := $(shell basename $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -mthumb-interwork
CFLAGS := -g -Wall -O2\
-mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\
-ffast-math -std=c99\
$(ARCH)
CFLAGS += $(INCLUDE)
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
ASFLAGS := -g $(ARCH)
LDFLAGS = -nostartfiles -Wl,-init=0x0 -g $(ARCH) -Wl,-Map,$(TARGET).map
#---------------------------------------------------------------------------------
# Setup some defines
#---------------------------------------------------------------------------------
# libtonc should be installed from devkitpro as well
LIBTONC := $(DEVKITPRO)/libtonc
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -ltonc
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(LIBTONC)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).dldi $(TARGET).elf
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
../gba_bios.bin : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
%.bin: %.elf
@$(OBJCOPY) --pad-to 0x4000 -O binary $< $@
@echo built ... $(notdir $@)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

176
bios/source/core.s Normal file
View File

@ -0,0 +1,176 @@
@---------------------------------------------------------------------------------
.section ".init"
@---------------------------------------------------------------------------------
.global _start
.type _start STT_FUNC
.align 4
.arm
@---------------------------------------------------------------------------------
_start:
@---------------------------------------------------------------------------------
b reset_vector @ 0x00 Reset
b reserved_vector @ 0x04 Undefined
b swi_vector @ 0x08 SWI
b reserved_vector @ 0x0C Abort Prefetch
b reserved_vector @ 0x10 Abort Data
b reserved_vector @ 0x14 Reserved
b irq_vector @ 0x18 IRQ
b irq_vector @ 0x1C FIQ
@---------------------------------------------------------------------------------
irq_vector:
@---------------------------------------------------------------------------------
@ Save these registers, IRQ functions will be allowed to modify them w/o
@ saving.
stmdb sp!, { r0 - r3, r12, lr }
@ Pointer to IRQ handler is at 0x03FFFFFC (mirrored WRAM)
mov r0, #0x04000000
@ Store return address and branch to handler
mov lr, pc
ldr pc, [ r0, #-4 ]
@ Return from IRQ
ldmia sp!, { r0 - r3, r12, lr }
subs pc, lr, #4
@---------------------------------------------------------------------------------
reset_vector: @This isn't required if not booting from bios
@---------------------------------------------------------------------------------
mov r0, #0xDF
msr cpsr_cf, r0
@Disable Interrupts IME=0
mov r3, #0x04000000
strb r3, [r3,#0x208]
@Setup stacks
bl init
mov r2, #1
strb r2, [r3,#0x208]
ldr r0, =DrawLogo
ldr lr, =swi_SoftReset
bx r0
@---------------------------------------------------------------------------------
reserved_vector: @Lets just infinite loop for now
@---------------------------------------------------------------------------------
b reserved_vector
@ SWI calling convention:
@ Parameters are passed in via r0 - r3
@ Called SWI can modify r0 - r3 (and return things here), r12, and r14.
@ They can't modify anything else.
@---------------------------------------------------------------------------------
swi_vector:
@---------------------------------------------------------------------------------
@ Save these as temporaries
stmdb sp!, { r11, r12, lr }
@ Load comment from SWI instruction, which indicates which SWI
@ to use.
ldrb r12, [lr,#-2]
adr r11, swi_branch_table
ldr r12, [r11,r12,lsl#2]
@ get SPSR and enter system mode, interrupts on
MRS R11, SPSR
@ This must be stacked and not just saved, because otherwise SWI won't
@ be reentrant, which can happen if you're waiting for interrupts and the
@ interrupt handler triggers the SWI.
stmfd sp!, {r11}
@ Set up new CPSR value
and r11, r11, #0x80
orr r11, r11, #0x1f
msr cpsr_cf, r11
@ We have to now save system-mode lr register as well
stmfd sp!, {r2, r3, lr}
@ Set return address
adr lr, swi_complete
@ Branch to SWI handler
bx r12
swi_complete:
@ Restore system mode lr
ldmfd sp!, {r2, r3, lr}
@ Go back to supervisor mode to get back to that stack
mov r12, #0xD3
msr cpsr_cf, r12
@ SPSR has to be restored because the transition to system mode broke it
ldmfd sp!, {r11}
msr spsr_cf, r11
@ Restore stuff we saved
ldmfd sp!, {r11,r12,lr}
@ Return from exception handler
movs pc, lr
@---------------------------------------------------------------------------------
swi_branch_table:
@---------------------------------------------------------------------------------
.word swi_SoftReset @ 0x00_SoftReset
.word swi_RegisterRamReset @ 0x01_RegisterRAMReset
.word swi_Halt @ 0x02_Halt
.word swi_Stop @ 0x03_Stop
.word swi_IntrWait @ 0x04_IntrWait
.word swi_VBlankIntrWait @ 0x05_VBlankIntrWait
.word swi_Div @ 0x06_Div
.word swi_DivARM @ 0x07_DivARM
.word swi_Sqrt @ 0x08_Sqrt
.word swi_ArcTan @ 0x09_ArcTan
.word swi_ArcTan2 @ 0x0A_ArcTan2
.word swi_CpuSet @ 0x0B_CPUSet
.word swi_CpuFastSet @ 0x0C_CPUFastSet
.word swi_GetBiosChecksum @ 0x0D_GetBiosChecksum
.word swi_BgAffineSet @ 0x0E_BgAffineSet
.word swi_ObjAffineSet @ 0x0F_ObjAffineSet
.word swi_BitUnPack @ 0x10_BitUnPack
.word swi_LZ77UnCompWram @ 0x11_LZ77UnCompWram
.word swi_LZ77UnCompVram @ 0x12_LZ77UnCompVram
.word swi_HuffUnComp @ 0x13_HuffUnComp
.word swi_RLUnCompWram @ 0x14_RLUnCompWram
.word swi_RLUnCompVram @ 0x15_RLUnCompVram
.word swi_Diff8bitUnFilterWram @ 0x16_Diff8bitUnFilterWram
.word swi_Diff8bitUnFilterVram @ 0x17_Diff8bitUnFilterVram
.word swi_Diff16bitUnFilter @ 0x18_Diff16bitUnFilter
.word swi_Invalid @ 0x19_SoundBiasChange
.word swi_Invalid @ 0x1A_SoundDriverInit
.word swi_Invalid @ 0x1B_SoundDriverMode
.word swi_Invalid @ 0x1C_SoundDriverMain
@ .word swi_SoundDriverMain @ 0x1C_SoundDriverMain
.word swi_Invalid @ 0x1D_SoundDriverVSync
.word swi_Invalid @ 0x1E_SoundChannelClear
.word swi_MidiKey2Freq @ 0x1F_MidiKey2Freq
.word swi_Invalid @ 0x20_MusicPlayerOpen
.word swi_Invalid @ 0x21_MusicPlayerStart
.word swi_Invalid @ 0x22_MusicPlayerStop
.word swi_MusicPlayerContinue @ 0x23_MusicPlayerContinue
.word swi_MusicPlayerFadeOut @ 0x24_MusicPlayerFadeOut
.word swi_Invalid @ 0x25_MultiBoot
.word swi_Invalid @ 0x26_HardReset
.word swi_CustomHalt @ 0x27_CustomHalt
.word swi_Invalid @ 0x28_SoundDriverVSyncOff
.word swi_Invalid @ 0x29_SoundDriverVSyncOn
.word swi_SoundGetJumpList @ 0x2A_SoundGetJumpList
@---------------------------------------------------------------------------------
.global swi_Invalid
.type swi_Invalid STT_FUNC
swi_Invalid:
@---------------------------------------------------------------------------------
@ Infinite loop for now
@b swi_Invalid
@ Do nothing for release builds
bx lr
@---------------------------------------------------------------------------------

76
bios/source/divide.s Normal file
View File

@ -0,0 +1,76 @@
@---------------------------------------------------------------------------------
@ Setup some nicer names
@---------------------------------------------------------------------------------
numerator .req r0
denominator .req r1
accumulator .req r2
current_bit .req r3
numerator_signed .req r12
denominator_signed .req r3
sign_flip .req r12
result .req r0
remainder .req r1
result_abs .req r3
temp .req r3
@---------------------------------------------------------------------------------
.global swi_DivARM
.type swi_DivARM STT_FUNC
swi_DivARM:
@---------------------------------------------------------------------------------
mov temp, numerator
mov numerator, denominator
mov denominator, temp
b swi_Div
@---------------------------------------------------------------------------------
.global swi_Div
.type swi_Div STT_FUNC
swi_Div:
@ See http://www.tofla.iconbar.com/tofla/arm/arm02/index.htm for more information
@---------------------------------------------------------------------------------
@ Set if numerator is signed, and abs numerator
ands numerator_signed, numerator, #0x80000000
rsbmi numerator, numerator, #0
// Same with denominator
ands denominator_signed, denominator, #0x80000000
rsbmi denominator, denominator, #0
// Gets set if sign(numerator) != sign(denominator)
eor sign_flip, numerator_signed, denominator_signed
mov accumulator, #0
mov current_bit, #1
// This moves out the current bit to the MSB of the denominator,
// and aligns the denominator up to the same bit-length as the
// numerator
0:
cmp denominator, numerator
movls denominator, denominator, lsl #1
movls current_bit, current_bit, lsl #1
bls 0b
// Basically the grade-school algorithm, for unsigned integers in binary
1:
cmp numerator, denominator
subcs numerator, numerator, denominator
orrcs accumulator, accumulator, current_bit
movs current_bit, current_bit, lsr #1
movcc denominator, denominator, lsr #1
bcc 1b
mov remainder, numerator
mov result_abs, accumulator
mov result, accumulator
tst sign_flip, #0x80000000
rsbmi result, result, #0
bx lr

33
bios/source/helper.arm.c Normal file
View File

@ -0,0 +1,33 @@
/*
Custom GBA BIOS replacement
Copyright (c) 2002-2006 VBA Development Team
Copyright (c) 2006-2013 VBA-M Development Team
Copyright (c) 2013 Normmatt
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <tonc.h>
u32 umul3232H32(u32 val, u32 val2)
{
register u32 a __asm ("r2");
register u32 b __asm ("r3");
__asm ("umull %0, %1, %2, %3" :
"=r"(a), "=r"(b) :
"r"(val), "r"(val2)
);
return b;
}

74
bios/source/logo.c Normal file
View File

@ -0,0 +1,74 @@
/*
Custom GBA BIOS replacement
Copyright (c) 2002-2006 VBA Development Team
Copyright (c) 2006-2013 VBA-M Development Team
Copyright (c) 2013 Normmatt
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <tonc.h>
#include "logo_data.h"
static inline void CPUWriteHalfWord(u32 adr, u16 val)
{
*(u16*)adr = val;
}
static inline u16 CPUReadHalfWord(u32 adr)
{
return *(u16*)adr;
}
void memcpy_(u32 source, u32 dest, int count)
{
// copy
while(count) {
CPUWriteHalfWord(dest, (source>0x0EFFFFFF ? 0x1CAD : CPUReadHalfWord(source)));
dest += 2;
source += 2;
count--;
}
}
extern void swi_LZ77UnCompVram_(u32 source, u32 dest, int checkBios);
extern void swi_RegisterRamReset(u32 flags);
/*-----------------------------------------------------------------
DrawLogo
Draws a custom logo and pauses for a second or two.
-----------------------------------------------------------------*/
void DrawLogo() {
// Load palette
memcpy_((u32)logo_dataPal, (u32)pal_bg_mem, logo_dataPalLen);
// Load tiles into CBB 0
swi_LZ77UnCompVram_((u32)logo_dataTiles, (u32)&tile_mem[0][0], 0);
// Load map into SBB 30
swi_LZ77UnCompVram_((u32)logo_dataMap, (u32)&se_mem[30][0], 0);
// set up BG0 for a 4bpp 64x32t map, using
// using charblock 0 and screenblock 31
REG_BG0CNT= BG_CBB(0) | BG_SBB(30) | BG_4BPP | BG_REG_32x32;
REG_DISPCNT= DCNT_MODE0 | DCNT_BG0;
int countdown = 60*2;
while(countdown--)
{
vid_vsync();
}
swi_RegisterRamReset(0xFF);
}

187
bios/source/logo_data.c Normal file
View File

@ -0,0 +1,187 @@
//{{BLOCK(logo_data)
//======================================================================
//
// logo_data, 256x256@4,
// + palette 16 entries, not compressed
// + 120 tiles (t|f|p reduced) lz77 compressed
// + regular map (in SBBs), lz77 compressed, 32x32
// Total size: 32 + 1720 + 496 = 2248
//
// Time-stamp: 2013-08-26, 19:29:30
// Exported by Cearn's GBA Image Transmogrifier, v0.8.6
// ( http://www.coranac.com/projects/#grit )
//
//======================================================================
const unsigned short logo_dataTiles[860] __attribute__((aligned(4)))=
{
0x0010,0x000F,0x003C,0xF000,0xF001,0xF001,0x1001,0x410D,
0x3376,0x8888,0x15F0,0x0770,0x8888,0x1FF0,0x1FA0,0x7810,
0x0247,0x15F0,0x9200,0x0000,0x2000,0x00DA,0xA300,0x00FF,
0x2020,0xFFEA,0x1F00,0x0095,0xB940,0x00ED,0xB910,0xFFFE,
0xFEB7,0xFFFF,0xFD14,0xFFFF,0x0110,0x00EF,0xAB06,0x06FF,
0xADFF,0xBA14,0x30ED,0x9010,0xCD05,0xAB0C,0x5699,0x4027,
0xF058,0xFF1D,0x08FF,0x5555,0x5555,0x7750,0xEFFF,0xC0BD,
0x4700,0x23B0,0x9995,0xEDCA,0x0000,0x1028,0x10A5,0x179B,
0xA000,0x5ACE,0x0901,0xFF00,0x4ACF,0x4B00,0x29CE,0x7E00,
0xAE56,0x7F10,0x00EB,0x9387,0x0400,0xBFD0,0xA703,0xD000,
0x005B,0xCFD4,0x0005,0x107B,0xF008,0xA801,0x0E10,0x0030,
0x7013,0x1700,0x00B0,0x85A2,0x4300,0xFFD9,0x60FF,0xD800,
0x00B1,0x80DB,0x0A00,0xFBAE,0xFFFF,0xFE3B,0x00FF,0x04DF,
0xFFFF,0x00AF,0xBDFF,0x0401,0xFF00,0x003A,0x8D00,0x4400,
0x1862,0x48F0,0x01F0,0x0000,0x00D0,0xF012,0x80C2,0xA003,
0xDD21,0xCDDD,0x0105,0x1A42,0x01AE,0x8E46,0x4A01,0xF0BF,
0xB03E,0xD0CB,0xDB02,0xDD01,0x0BDD,0xFFFC,0x0CFF,0x0350,
0xF0D6,0x5022,0x5009,0x6301,0xE1F0,0x501F,0x5509,0x4575,
0x9B01,0x7DF0,0x0680,0x0140,0xA0A3,0x3FF0,0x60C0,0x013F,
0xDF93,0x0004,0xA200,0x09FD,0x00FF,0xD910,0x2702,0xFB40,
0x2500,0xC662,0x5741,0x3060,0xBFFF,0x0203,0x1A03,0x02A4,
0x9E07,0x0B02,0x04CF,0x3F02,0xEA1A,0xFF0B,0x6CFF,0x01B3,
0x705C,0x1000,0x59F0,0x30AA,0x010B,0xFF70,0x00D4,0xE91D,
0x0F02,0xC8FA,0xB601,0x6300,0xFC40,0xDB00,0x00FE,0x5400,
0x0260,0x609B,0x8D02,0x305C,0xDF5F,0xB107,0x8F00,0x2002,
0x01D3,0x00B6,0x9FFF,0x0330,0xC1F5,0xE08B,0x4203,0x02CB,
0xDFD5,0xDA02,0x00BF,0x2A9A,0xC4BF,0x9601,0x0190,0x209A,
0x9E11,0xAB1A,0x9A00,0x007D,0xBF9E,0x2903,0x00EF,0x000C,
0x006E,0xFE00,0x01BF,0xFB00,0x09EF,0x003C,0x00D7,0x917B,
0xF08B,0x9103,0x109F,0x0021,0x4000,0xDBA7,0xB700,0xFFFD,
0x9008,0xFFFD,0x009E,0x1B64,0xFFFA,0xFF20,0x5009,0x22F9,
0x0122,0xFE00,0xDE10,0x15AB,0x5E03,0x129C,0xFFD9,0xEF4C,
0x7A01,0x00FF,0x2001,0x3E70,0x2222,0x0035,0x02B0,0x00EF,
0x2A03,0x0700,0x008D,0x600B,0x10BF,0x500F,0x013F,0x4410,
0x1BFF,0xB80A,0xFFFE,0x039C,0xCDA1,0xA403,0x02BE,0xFB99,
0x2CFF,0xA200,0x5951,0x0013,0x0000,0xBF21,0x003A,0xFFFA,
0xAF2D,0x0003,0x0A76,0x7A00,0x7E10,0x011D,0x8553,0x7F60,
0xFF51,0x3AFF,0x9A01,0x11AA,0x580B,0x03BB,0x3466,0x6900,
0x9C40,0x0000,0x15BA,0x8ABB,0x0301,0x3AFA,0x7F13,0x01EC,
0x58C8,0x04B7,0x4007,0x0B04,0xB931,0x4453,0x0B00,0xCB92,
0x50BC,0x3803,0x04B5,0x031F,0x003F,0xBFFF,0xDA99,0x4BFF,
0x8000,0xFD40,0xD951,0x004B,0x2220,0x08DF,0xD06A,0xF500,
0x0300,0x009F,0xAF07,0x0B00,0x40BF,0x70D0,0x02BF,0xA810,
0x6FFF,0xC0B6,0x1B00,0x3D01,0xBDFF,0xFFDB,0x37DF,0x8448,
0xBF41,0x2000,0x0C02,0xABBB,0x9505,0x4B04,0x119D,0xA701,
0x0497,0xCB82,0x8714,0x01A0,0xAE3F,0xAA32,0x0345,0xBA40,
0x30CC,0xC8AB,0x9B04,0x9F44,0x9AFF,0xFEA9,0xFF0D,0x1002,
0x64FA,0x141F,0x4B17,0x6602,0x0280,0xA31A,0x05CF,0xFB40,
0x07DF,0x0190,0x0960,0x74D8,0x213F,0x0112,0x10A6,0xCEEC,
0x10AB,0xFF7D,0x29EF,0x7092,0x01FF,0x50E3,0x527F,0x989D,
0x9999,0xB359,0xFF04,0x10AF,0x0103,0xAFBB,0x14D7,0x2320,
0x0163,0xFFF0,0xBBB2,0xFFFB,0x05F3,0xF91B,0x0310,0x1350,
0x5E22,0x8F12,0x9312,0xBBDF,0x5301,0xFF3C,0x20DF,0x5003,
0x2313,0x137F,0xA063,0x0FFF,0xBBA0,0xFFDB,0xDE01,0x0320,
0x1350,0x7F13,0x13DF,0x2063,0xEF03,0x3F20,0xAA42,0x1340,
0x7F13,0x3A43,0x049C,0x00EE,0x4007,0xA303,0x044D,0x00CC,
0xACE9,0x2705,0x05B4,0xA12B,0x2F05,0x5722,0xFFFE,0x002A,
0x3040,0x0803,0x7A03,0x030A,0x2B7E,0x03AB,0x6D82,0x8603,
0x039D,0x9E8A,0x2731,0x0320,0x53DD,0x3367,0x506F,0xCF01,
0x7F13,0x8713,0x1200,0x7F3B,0x53E9,0x2367,0x136F,0x2077,
0x03EB,0x03F3,0x331F,0x68F7,0xF0BF,0x8003,0xA107,0x6305,
0xFC30,0x44EF,0x0508,0x4B83,0xB200,0xCF01,0xFD50,0xDF69,
0x5A00,0x7706,0x06B3,0x707B,0x03FF,0x564B,0x034C,0x7C4F,
0x5303,0x109C,0x0603,0x9C7F,0x06A8,0x7C82,0x8606,0x064C,
0x1C8A,0xFFFC,0xEF17,0xFD08,0x0300,0x00FE,0x0607,0x2096,
0xEF07,0x0F10,0x1710,0xC705,0x3009,0x04E7,0xE0A3,0x0103,
0xA503,0x3E04,0x02EF,0xEF72,0x06B9,0xBAD4,0x0370,0x10B0,
0xEF0F,0xA004,0x5F13,0x0BFF,0x5000,0x00B1,0x0003,0x03F0,
0x0B30,0x9999,0x1319,0xFD43,0x03F0,0x0B40,0x6B03,0x0307,
0x03F0,0x0B50,0x1310,0xDF43,0x03F0,0x0B60,0x0408,0x05F3,
0xF065,0x4003,0x130B,0xDD43,0x03F0,0x0780,0x076F,0xF083,
0x6003,0xF90B,0x5F01,0xF871,0xE500,0x03F0,0x0B30,0x0000,
0x08F5,0x5903,0x08F2,0xF107,0x03F0,0x0F00,0x19FF,0xC504,
0x496A,0xF104,0x1913,0x0869,0x691C,0x2408,0xB749,0x2508,
0x1129,0x027D,0x7F78,0x0308,0x03F0,0x0B30,0x05BF,0xD6A3,
0x6407,0x03F0,0x0770,0x4B93,0x03F0,0x5F83,0xF0FF,0xA303,
0xF05F,0xC303,0xF05F,0x3603,0x43DF,0x0627,0x1C72,0x00FF,
0x0380,0x1537,0x0897,0x0028,0xFAC5,0x5733,0x2753,0x2F13,
0x3713,0x2718,0x065D,0x1BCE,0x43DA,0x0657,0xC4D9,0xE413,
0x6F48,0xD620,0xFFE9,0xFF25,0x096D,0xAF23,0x0800,0x076F,
0x7718,0x04A4,0xAE53,0xA603,0x40FF,0x4406,0xD800,0xF8D9,
0x17DF,0x1917,0xA713,0x2007,0x4AFF,0xDFF6,0x17E3,0xB0B8,
0xB35F,0x4473,0x3444,0x6CD7,0x0316,0x17B6,0x90B7,0x9FF0,
0xBF29,0x100C,0x0903,0x0CFA,0x0986,0x0C17,0x4443,0xA844,
0x0596,0x1B03,0xA100,0xFFFE,0x209E,0xFEC9,0x0BEF,0x6000,
0xDCBA,0x6606,0xA733,0x04CD,0x8073,0xCF06,0xDDDF,0xDFFE,
0xFF4A,0x0DBD,0x017A,0x2344,0xD917,0xEF77,0x064C,0x63D3,
0x4607,0x26D7,0x30DF,0x4444,0x3FA8,0x73C3,0xB0EC,0x607D,
0x93BF,0x427B,0x5FB1,0x73B3,0x4444,0xCADD,0xD3F2,0x4473,
0x7FB0,0x73D3,0xA908,0xB843,0x8CDF,0x73B3,0x3444,0xB030,
0xC3BF,0x4473,0xDA14,0xEBB8,0x73D3,0xC141,0xF35F,0x4073,
0x1FB1,0x8009,0x4909,0x9009,0xFFFE,0x1009,0x9CC9,0x4D08,
0x4460,0x5EB1,0xE309,0x3B0B,0x29EF,0x7104,0xFFFF,0xEDDE,
0xAB0B,0x21BD,0x4335,0xA144,0x039F,0xAFFF,0xAF08,0x0BAF,
0x41D6,0x0AAF,0xAFF7,0x4442,0x2444,0x8DB9,0xD3FB,0xC073,
0xC37F,0xF273,0xD35E,0x2073,0xDFB1,0x73C3,0x4470,0xC0D0,
0x01F0,0xA712,0x00C7,0x7100,0xFC03,0x2000,0xFFD9,0x0B10,
0x1AAC,0xAA47,0xDE06,0x0AAE,0x5C57,0xA20C,0x0A0A,0x0367,
0x08FD,0x2A2B,0x1777,0xF213,0x9232,0x079F,0x100B,0xE71C,
0xA264,0xEB1C,0xF70C,0x8100,0xBFAA,0x16BE,0x0C96,0xADC3,
0x0C16,0xACF6,0xFA1C,0xFF1C,0xC6A4,0x040D,0x0F1D,0x2000,
0x02A7,0x30EF,0x2852,0x0087,0xEF59,0xAAAB,0xDC89,0xDDED,
0xF08F,0x8C1F,0x1F6A,0xA8A6,0x1CAA,0xADD5,0xEF2F,0xBA00,
0x6C00,0x0AA4,0x4050,0x1D19,0xAD77,0xDC09,0x0307,0xBFFF,
0x0039,0x39BD,0xC31B,0xF30A,0x08B4,0xBFD8,0x8A0B,0xA60C,
0xFD00,0x00D0,0xD394,0x12F0,0x0770,0x09BA,0x31CC,0x7D44,
0xF38F,0xC0FF,0xAFBD,0x1FE0,0xBDEF,0x559A,0x3445,0xF1D8,
0x40B4,0x160A,0x12F0,0x01A0,
};
const unsigned short logo_dataMap[248] __attribute__((aligned(4)))=
{
0x0010,0x0008,0x003F,0xF000,0xF001,0xF001,0xF001,0xF001,
0xF001,0xFF01,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,
0x01F0,0x01F0,0xF0FF,0xF001,0xF001,0xF001,0xF001,0xF001,
0xF001,0x7001,0x1D07,0x0001,0xF002,0xF001,0x4001,0x030B,
0x40A0,0x0401,0x0500,0x0600,0x0700,0x01F0,0xF0C1,0x4001,
0x080B,0x0900,0x0A00,0x8440,0x0B00,0x0C00,0x0D00,0x0E00,
0x0600,0x000F,0x0010,0xF011,0xA098,0x1205,0x0002,0x0013,
0x0014,0x0015,0x1619,0x0008,0x0017,0x2018,0x1921,0x1A00,
0x0080,0x1B29,0x1C00,0x1D00,0x1E00,0x0000,0x001F,0x0020,
0x0021,0x0022,0x2300,0x2400,0x2500,0x2600,0x0000,0x0027,
0x0028,0x0029,0x002A,0x2B00,0x2C00,0x2D00,0x2E00,0x0000,
0x002F,0x0030,0x0031,0x8832,0x5B00,0x0033,0x2034,0x3561,
0x3600,0x2080,0x373F,0x3800,0x3900,0x3A00,0x0000,0x003B,
0x003C,0x003D,0x003E,0x3F00,0x4000,0x4100,0x4200,0x0000,
0x0043,0x0044,0x0045,0x0046,0x4700,0x4800,0x4900,0x4A00,
0x0008,0x004B,0x204C,0x4D99,0x4E00,0x2080,0x4FA1,0x5000,
0x5100,0x5200,0x0000,0x0053,0x0054,0x0055,0x0056,0x5700,
0x5800,0x5900,0x5A00,0x0000,0x005B,0x005C,0x005D,0x005E,
0x5F00,0x6000,0x6100,0x6200,0x0000,0x0063,0x0064,0x0065,
0x0866,0x6700,0x6800,0xD900,0x0069,0x206A,0x6B00,0xE140,
0x006C,0x006D,0x386E,0x6F00,0x01F0,0x01F0,0x0B40,0x0070,
0x2071,0x7200,0x1F81,0x0073,0x0074,0xE375,0x01F0,0x01F0,
0x0B40,0x0076,0xF177,0xF05D,0xFF01,0x01F0,0x01F0,0x01F0,
0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0xF0FF,0xF001,0xF001,
0xF001,0xF001,0xF001,0xF001,0xF001,0xFF01,0x01F0,0x01F0,
0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0xF0FF,0xF001,
0xF001,0xF001,0xF001,0xF001,0xF001,0xF001,0xFF01,0x01F0,
0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0xF0FF,
0xF001,0xF001,0xF001,0xF001,0xF001,0xF001,0xF001,0xFF01,
0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,0x01F0,
0xF0FE,0xF001,0xF001,0xF001,0xF001,0xF001,0x6001,0x0001,
};
const unsigned short logo_dataPal[16] __attribute__((aligned(4)))=
{
0x0000,0x0421,0x0842,0x0C63,0x1084,0x18C6,0x1CE7,0x2108,
0x294A,0x2D6B,0x4631,0x6318,0x6F7B,0x77BD,0x7BDE,0x7FFF,
};
//}}BLOCK(logo_data)

32
bios/source/logo_data.h Normal file
View File

@ -0,0 +1,32 @@
//{{BLOCK(logo_data)
//======================================================================
//
// logo_data, 256x256@4,
// + palette 16 entries, not compressed
// + 120 tiles (t|f|p reduced) lz77 compressed
// + regular map (in SBBs), lz77 compressed, 32x32
// Total size: 32 + 1720 + 496 = 2248
//
// Time-stamp: 2013-08-26, 19:29:30
// Exported by Cearn's GBA Image Transmogrifier, v0.8.6
// ( http://www.coranac.com/projects/#grit )
//
//======================================================================
#ifndef GRIT_LOGO_DATA_H
#define GRIT_LOGO_DATA_H
#define logo_dataTilesLen 1720
extern const unsigned short logo_dataTiles[860];
#define logo_dataMapLen 496
extern const unsigned short logo_dataMap[248];
#define logo_dataPalLen 32
extern const unsigned short logo_dataPal[16];
#endif // GRIT_LOGO_DATA_H
//}}BLOCK(logo_data)

62
bios/source/reset.s Normal file
View File

@ -0,0 +1,62 @@
.arm
@---------------------------------------------------------------------------------
.global swi_SoftReset
.type swi_SoftReset STT_FUNC
swi_SoftReset:
@---------------------------------------------------------------------------------
mov r3, #0x04000000
@ Read flag from 0x3007FFA
@ 00h=8000000h (ROM), or 01h-FFh=2000000h (RAM)
@ This must be done before init because it gets cleared in init
ldrb r2, [r3,#-6]
bl init
cmp r2, #0
ldmdb r3, {r0-r12}
movne lr, #0x02000000
moveq lr, #0x08000000
mov r0, #0x1F
msr cpsr_cf, r0
mov r0, #0
bx lr
@---------------------------------------------------------------------------------
.global init
init:
@ Requires r3 to be set to 0x04000000 already.
@---------------------------------------------------------------------------------
@ Reset the stack locations
mov r0, #0xD3
msr cpsr_cf, r0
ldr sp, Cpu_Stack_SVC
mov lr, #0
msr spsr_cf, lr
mov r0, #0xD2
msr cpsr_cf, r0
ldr sp, Cpu_Stack_IRQ
mov lr, #0
msr spsr_cf, lr
mov r0, #0x5F
msr cpsr_cf, r0
ldr sp, Cpu_Stack_USR
movs r0, #0
subs r1, r0, #0x200
@ Clear top 0x200 bytes of IWRAM 03007E00 -> 03008000
init_loop:
str r0, [r3,r1]
adds r1, r1, #4
blt init_loop
bx lr
@---------------------------------------------------------------------------------
@---------------------------------------------------------------------------------
Cpu_Stack_USR: .word 0x03007F00
Cpu_Stack_IRQ: .word 0x03007FA0
Cpu_Stack_SVC: .word 0x03007FE0
@---------------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff