diff options
author | JaceCearK1 <JaceCearK1@users.noreply.github.com> | 2017-07-01 21:04:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-01 21:04:18 +0200 |
commit | 0dd804a99e5455a0eac8ff6ed87d9de16c7380b7 (patch) | |
tree | 7b3567978b63ee6548a7b945e075ea8ba37bef51 /include/gba | |
parent | f1344efd2aff92292f58f7323bd9297a38fe9b02 (diff) | |
parent | 8d82578d3a101b06f9d2ced31738021007c4e533 (diff) |
Merge pull request #1 from pret/master
Update fork to match main fork.
Diffstat (limited to 'include/gba')
-rw-r--r-- | include/gba/flash_internal.h | 7 | ||||
-rw-r--r-- | include/gba/gba.h | 1 | ||||
-rw-r--r-- | include/gba/io_reg.h | 37 | ||||
-rw-r--r-- | include/gba/multiboot.h | 55 | ||||
-rw-r--r-- | include/gba/syscall.h | 4 | ||||
-rw-r--r-- | include/gba/types.h | 23 |
6 files changed, 120 insertions, 7 deletions
diff --git a/include/gba/flash_internal.h b/include/gba/flash_internal.h index 6156b6c14..cbcfb5466 100644 --- a/include/gba/flash_internal.h +++ b/include/gba/flash_internal.h @@ -65,6 +65,10 @@ u16 ReadFlashId(void); void StartFlashTimer(u8 phase); void SetReadFlash1(u16 *dest); void StopFlashTimer(void); +u16 SetFlashTimerIntr(u8 timerNum, void (**intrFunc)(void)); +u32 ProgramFlashSectorAndVerify(u16 sectorNum, u8 *src); +void ReadFlash(u16 sectorNum, u32 offset, u8 *dest, u32 size); +u32 ProgramFlashSectorAndVerifyNBytes(u16 sectorNum, u8 *src, u32 n); u16 WaitForFlashWrite_Common(u8 phase, u8 *addr, u8 lastData); @@ -73,4 +77,7 @@ u16 EraseFlashSector_MX(u16 sectorNum); u16 ProgramFlashByte_MX(u16 sectorNum, u32 offset, u8 data); u16 ProgramFlashSector_MX(u16 sectorNum, u8 *src); +// agb_flash_1m +u16 IdentifyFlash(void); + #endif // GUARD_GBA_FLASH_INTERNAL_H diff --git a/include/gba/gba.h b/include/gba/gba.h index 26342cf88..42ae3cdde 100644 --- a/include/gba/gba.h +++ b/include/gba/gba.h @@ -4,6 +4,7 @@ #include "gba/defines.h" #include "gba/io_reg.h" #include "gba/types.h" +#include "gba/multiboot.h" #include "gba/syscall.h" #include "gba/macro.h" diff --git a/include/gba/io_reg.h b/include/gba/io_reg.h index 0be92fa60..d483d4ddc 100644 --- a/include/gba/io_reg.h +++ b/include/gba/io_reg.h @@ -495,12 +495,12 @@ // I/O register fields // DISPCNT -#define DISPCNT_MODE_0 0x0000 -#define DISPCNT_MODE_1 0x0001 -#define DISPCNT_MODE_2 0x0002 -#define DISPCNT_MODE_3 0x0003 -#define DISPCNT_MODE_4 0x0004 -#define DISPCNT_MODE_5 0x0005 +#define DISPCNT_MODE_0 0x0000 // BG0: text, BG1: text, BG2: text, BG3: text +#define DISPCNT_MODE_1 0x0001 // BG0: text, BG1: text, BG2: affine, BG3: off +#define DISPCNT_MODE_2 0x0002 // BG0: off, BG1: off, BG2: affine, BG3: affine +#define DISPCNT_MODE_3 0x0003 // Bitmap mode, 240x160, BGR555 color +#define DISPCNT_MODE_4 0x0004 // Bitmap mode, 240x160, 256 color palette +#define DISPCNT_MODE_5 0x0005 // Bitmap mode, 160x128, BGR555 color #define DISPCNT_OBJ_1D_MAP 0x0040 #define DISPCNT_FORCED_BLANK 0x0080 #define DISPCNT_BG0_ON 0x0100 @@ -521,6 +521,26 @@ #define DISPSTAT_HBLANK_INTR 0x0010 // H-Blank interrupt enabled #define DISPSTAT_VCOUNT_INTR 0x0020 // V-Count interrupt enabled +// BGCNT +#define BGCNT_PRIORITY(n) (n) // Values 0 - 3. Lower priority BGs will be drawn on top of higher priority BGs. +#define BGCNT_CHARBASE(n) ((n) << 2) // Values 0 - 3. Base block for tile pixel data. +#define BGCNT_MOSAIC 0x0040 +#define BGCNT_16COLOR 0x0000 // 4 bits per pixel +#define BGCNT_256COLOR 0x0080 // 8 bits per pixel +#define BGCNT_SCREENBASE(n) ((n) << 8) // Values 0 - 31. Base block for tile map. +#define BGCNT_WRAP 0x2000 // Only affects affine BGs. Text BGs wrap by default. +#define BGCNT_TXT256x256 0x0000 // Internal screen size size of text mode BG in pixels. +#define BGCNT_TXT512x256 0x4000 +#define BGCNT_TXT256x512 0x8000 +#define BGCNT_TXT512x512 0xC000 +#define BGCNT_AFF128x128 0x0000 // Internal screen size size of affine mode BG in pixels. +#define BGCNT_AFF256x256 0x4000 +#define BGCNT_AFF512x512 0x8000 +#define BGCNT_AFF1024x1024 0xC000 + +// BLDCNT + + // SOUNDCNT_H #define SOUND_CGB_MIX_QUARTER 0x0000 #define SOUND_CGB_MIX_HALF 0x0001 @@ -577,6 +597,8 @@ #define TIMER_ENABLE 0x80 // serial +#define SIO_ID 0x0030 // Communication ID + #define SIO_8BIT_MODE 0x0000 // Normal 8-bit communication mode #define SIO_32BIT_MODE 0x1000 // Normal 32-bit communication mode #define SIO_MULTI_MODE 0x2000 // Multi-player communication mode @@ -589,6 +611,7 @@ #define SIO_MULTI_SI 0x0004 // Multi-player communication SI terminal #define SIO_MULTI_SD 0x0008 // SD terminal +#define SIO_MULTI_BUSY 0x0080 #define SIO_ERROR 0x0040 // Detect error #define SIO_START 0x0080 // Start transfer @@ -616,6 +639,8 @@ #define KEY_INTR_ENABLE 0x0400 #define KEY_OR_INTR 0x0000 #define KEY_AND_INTR 0x8000 +#define DPAD_ANY 0x00F0 +#define JOY_EXCL_DPAD 0x030F // interrupt flags #define INTR_FLAG_VBLANK (1 << 0) diff --git a/include/gba/multiboot.h b/include/gba/multiboot.h new file mode 100644 index 000000000..e88b43a19 --- /dev/null +++ b/include/gba/multiboot.h @@ -0,0 +1,55 @@ +#ifndef GUARD_GBA_MULTIBOOT_H +#define GUARD_GBA_MULTIBOOT_H + +#define MULTIBOOT_NCHILD 3 // Maximum number of slaves +#define MULTIBOOT_HEADER_SIZE 0xc0 // Header size +#define MULTIBOOT_SEND_SIZE_MIN 0x100 // Minimum transmission size +#define MULTIBOOT_SEND_SIZE_MAX 0x40000 // Maximum transmission size + +struct MultiBootParam +{ + u32 system_work[5]; + u8 handshake_data; + u8 padding; + u16 handshake_timeout; + u8 probe_count; + u8 client_data[MULTIBOOT_NCHILD]; + u8 palette_data; + u8 response_bit; + u8 client_bit; + u8 reserved1; + u8 *boot_srcp; + u8 *boot_endp; + u8 *masterp; + u8 *reserved2[MULTIBOOT_NCHILD]; + u32 system_work2[4]; + u8 sendflag; + u8 probe_target_bit; + u8 check_wait; + u8 server_type; +}; + +#define MULTIBOOT_ERROR_04 0x04 +#define MULTIBOOT_ERROR_08 0x08 +#define MULTIBOOT_ERROR_0c 0x0c +#define MULTIBOOT_ERROR_40 0x40 +#define MULTIBOOT_ERROR_44 0x44 +#define MULTIBOOT_ERROR_48 0x48 +#define MULTIBOOT_ERROR_4c 0x4c +#define MULTIBOOT_ERROR_80 0x80 +#define MULTIBOOT_ERROR_84 0x84 +#define MULTIBOOT_ERROR_88 0x88 +#define MULTIBOOT_ERROR_8c 0x8c +#define MULTIBOOT_ERROR_NO_PROBE_TARGET 0x50 +#define MULTIBOOT_ERROR_NO_DLREADY 0x60 +#define MULTIBOOT_ERROR_BOOT_FAILURE 0x70 +#define MULTIBOOT_ERROR_HANDSHAKE_FAILURE 0x71 + +#define MULTIBOOT_CONNECTION_CHECK_WAIT 15 + +#define MULTIBOOT_SERVER_TYPE_NORMAL 0 +#define MULTIBOOT_SERVER_TYPE_QUICK 1 + +#define MULTIBOOT_HANDSHAKE_TIMEOUT 400 + +#endif // GUARD_GBA_MULTIBOOT_H diff --git a/include/gba/syscall.h b/include/gba/syscall.h index 9576f7e99..deddec5ba 100644 --- a/include/gba/syscall.h +++ b/include/gba/syscall.h @@ -31,6 +31,8 @@ void CpuSet(const void *src, void *dest, u32 control); void CpuFastSet(const void *src, void *dest, u32 control); +void BgAffineSet(struct BgAffineSrcData *src, struct BgAffineDstData *dest, s32 count); + void ObjAffineSet(struct ObjAffineSrcData *src, void *dest, s32 count, s32 offset); void LZ77UnCompWram(const void *src, void *dest); @@ -41,4 +43,6 @@ void RLUnCompWram(const void *src, void *dest); void RLUnCompVram(const void *src, void *dest); +int MultiBoot(struct MultiBootParam *mp); + #endif // GUARD_GBA_SYSCALL_H diff --git a/include/gba/types.h b/include/gba/types.h index be7390d5a..96e057ab7 100644 --- a/include/gba/types.h +++ b/include/gba/types.h @@ -34,7 +34,7 @@ struct PlttData u16 g:5; // green u16 b:5; // blue u16 unused_15:1; -}; +} /*__attribute__((packed))*/; struct OamData { @@ -74,6 +74,27 @@ struct OamData #define ST_OAM_H_RECTANGLE 1 #define ST_OAM_V_RECTANGLE 2 +struct BgAffineSrcData +{ + s32 texX; + s32 texY; + s16 scrX; + s16 scrY; + s16 sx; + s16 sy; + u16 alpha; +}; + +struct BgAffineDstData +{ + s16 pa; + s16 pb; + s16 pc; + s16 pd; + s32 dx; + s32 dy; +}; + struct ObjAffineSrcData { s16 xScale; |