Page 1
Programming Manual Version 1.35 1999-2005 NINTENDO AGB-06-0001-002-B13 Released: May 27, 2005...
Page 2
"Confidential" These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America I nc. and/or Nintendo Company Ltd., and are pro- tected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nin- tendo.
May 25, 2005 Table of Contents Contents Revision History............................xiii Introduction ............................. xxi Using This Manual ..........................xxii The Game Boy Advance System ......................1 System Overview........................1 System Configuration ..........................3 CPU Block Diagram........................3 Complete Block Diagram ......................4 Memory Configuration and Access Widths................5 Little-Endian..........................5 Game Boy Advance Memory.......................7...
Page 4
Game Boy Advance Programming Manual May 25, 2005 Color Palettes ............................61 Color Palette Overview ......................61 7.1.1 16 Colors x 16 Palettes ....................61 7.1.2 256 Colors x 1 Palette....................61 7.1.3 Color 0 Transparency ....................61 Color Palette RAM ........................62 Color Data Format ........................63 Window Feature ..........................
Page 5
13.5.7 [Type/Status Data Request] Command(00h) Received..........128 13.5.8 [JOY Bus Data Write] Command(15h) Received ............129 13.5.9 [JOY Bus Data Read] Command(14h) Received............129 13.6 Game Boy Advance Game Link Cable ..................131 14 Key Input ............................133 14.1 Key Status ..........................133 14.2 Key Interrupt Control......................133 14.2.1 Interrupt Conditions......................133...
Page 6
Game Boy Advance Programming Manual May 25, 2005 17.1.2 Multiple Calls........................146 18 ROM Registration Data ........................149 18.1 Start Address .........................149 18.2 Nintendo Logo Character Data ....................149 18.3 Game Title ..........................149 18.4 Game Code ...........................149 18.5 Maker Code ...........................149 18.6 96h............................149 18.7 Main Unit Code........................149...
Page 7
May 25, 2005 Tables Table 1 - Game Boy Advance Memory Configuration and Access Widths..........5 Table 2 - Game Pak Memory Wait Control Values ..................11 Table 3 - Wait Control Values and Wait Cycles ..................12 Table 4 - Game Pak Bus Terminals......................13 Table 5 - Game Boy Advance Display Screen Features .................15...
Page 8
Figure 1 - Bit Operation Attribute Symbols .....................xxii Figure 1 - Game Boy Advance CPU Block Diagram..................3 Figure 2 - Complete Game Boy Advance System Block Diagram............. 4 Figure 3 - Game Boy Advance CPU Memory Addresses (Little-Endian)...........5 Figure 4 - Game Boy Advance System Memory Map................7 Figure 5 - The WAITCNT Register......................10...
Page 9
Figure 101 - Multi-Player Communication Connection Status ...............113 Figure 102 - Multi-player Communication Timing Chart ................114 Figure 103 - Multi Player Game Boy Advance Game Link Cable Connecting Diagram ......115 Figure 104 - The SIOMLT_SEND Register....................115 Figure 105 - Multi-Player Data Registers....................115 Figure 106 - Multi-Player Data Transitions ....................116...
Page 10
Figure 119 - JOY Bus Send Data Registers ..................127 Figure 120 - The JOYSTAT Register.....................127 Figure 121 - Game Boy Advance Game Link Cable Connection Types..........131 Figure 122 - The KEYINPUT Register ....................133 Figure 123 - The KEYCNT Register ......................133 Figure 124 - The IME Register.......................135...
Page 14
Game Boy Advance Programming Manual May 25, 2005 Revision Date Description Revised 1.22 8/10/2001 • Fixed section explaining Game Pak interrupts in the “Interrupt Control” chapter. • Added additional information to explanations about the DISPCNT regis- ter’s Individual Screens Display Flag and Forced Blank.
Page 15
Revision Date Description Revised 4/2/2001 • Changed the picture in the Game Boy Advance introduction in the begin- ning paragraph. • Added a caution regarding clearing of IME and IE in the chapter “Inter- rupt Control”. • Added additional description of an error flag and ID flag for multi-play communication.
Page 16
Game Boy Advance Programming Manual May 25, 2005 Revision Date Description Revised 4/2/2001 • Changed the names of following registers according to header files pro- vided by Nintendo. (Cont.) --Wait Control-- 204h WSCNT _ WAITCNT --Color Special Effects-- 050h BLDMOD _ BLDCNT...
Page 17
• Revised the hours you can play continuously from “about 20 hours” to “about 15 hours”. • Revised the illustrations of the Game Boy Advance hardware and the Multi Player Communication Cable in the multi play communication dia- gram. •...
Page 18
• Deleted the checksum of ROM registration data and revised the diagram. • Revised the diagram for “Game Boy Advance Game Link Cable” in the “Communication Function”. • Revised the number of DMG sold from tens of millions to a hundred mil- lion in the Game boy Advance introduction.
Page 20
Game Boy Advance Programming Manual May 25, 2005 Revision Date Description Revised 0.4.1 02/25/2000 • Changed the method to specify OBJ size. • Corrected misprints in the communication control register. 02/24/2000 • Added the PWM sampling cycle control function. 02/22/2000 •...
32768 COLORS COMPATIBLE FOR CGB 32BIT RISC CPU 16MHz Game Boy Advance (GBA, or sometimes AGB) stresses portability and focuses on 2D rather than 3D image processing functions, resulting in a cutting-edge portable game device with revolutionary capabili- ties. It provides window-like functions, rotation, scaling, blending, and fade-in/fade-out features that can be...
Unrestricted bit Fixed-value bit Can be set to either 0 or 1. Must be set to a specified fixed value. 3. Abbreviations Nintendo's game hardware is abbreviated as follows: • DMG: Game Boy • CGB: Game Boy Color • GBA or AGB: Game Boy® Advance •...
Serial communication (8 bit/32 bit, UART, Multi-player, General-purpose, JOY Bus) Game Pak Like the original Game Boy and Game Boy Color, Game Boy Advance is equipped with a 32-pin connector for Game Pak connection. When a Game Pak is inserted, Game Boy Advance automatically detects its type and switches to either Game Boy Color or Game Boy Advance mode.
May 25, 2005 System Configuration CPU Block Diagram Figure 1 - Game Boy Advance CPU Block Diagram Game Pak CPU 6 1 Game Pak I/F (Prefetch Buffer) VRAM_A ARM7TDMI (64KByte) (16.78MHz) 6 1 BG Processing Circuit R:16/32 W:16/32 Control R:8/16/32 6...
Game Boy Advance Programming Manual May 25, 2005 Complete Block Diagram Figure 2 - Complete Game Boy Advance System Block Diagram AGB Unit LCD Module -15V 2.5V 3.3V 13.6V 2.9"Reflective TFT Color LCD Regulator IC r 240 x 160 x RGB Dot e...
Little-Endian In the Game Boy Advance CPU, memory addresses are allocated in 8-bit increments, and little-endian for- mat is used in implementing the 8-, 16-, and 32-bit access widths. Figure 3 - Game Boy Advance CPU Memory Addresses (Little-Endian) Memory Register ...
May 25, 2005 Game Boy Advance Memory Overall Memory Map The following is the overall memory map of the Game Boy Advance system. Figure 4 - Game Boy Advance System Memory Map 0FFFFFFFh 0E00FFFFh Game Pak RAM Images (0 - 512 Kbits)
Game Boy Advance programming, do not perform processing based on these results. Be aware that the memory access methods in Nintendo DS differ fr om those in Game Boy Advance, Game Boy Advance-SP, and Game Boy Player and therefore, the values obtained when reading unmapped areas are very likely to differ.
The area beginning from 0E000000h is the Game Pak RAM area. Up to 512 kilobits of SRAM or Flash Memory can be stored here. However, it is an 8 bit data bus. Due to the specifications, any Game Pak device other than ROM must be accessed using Nintendo's library. Game Pak Memory Wait Control Although the 32 MB Game Pak memory space is mapped to the area from 08000000h onward, the 32 MB...
Game Boy Advance Programming Manual May 25, 2005 Table 3 - Wait Control Values and Wait Cycles Wait Control Value Wait Cycles 3.3.1 Access Timing The following timing charts illustrate Game Pak ROM access with 3 wait cycles on the first access and 1 wait cycle on the second.
Page 36
Game Boy Advance Programming Manual May 25, 2005 Table 4 - Game Pak Bus Terminals (Continued) Game Pak ROM Access Game Pak RAM Access Terminal Terminal Address (upper) Data /CS2 /CS2 RAM Chip Selection /IREQ and Terminal used for IREQ...
May 25, 2005 The Game Boy Advance uses a 2.9-inch-wide reflective TFT color LCD screen. The vertical blanking interval of Game Boy Advance is longer than that of DMG and CGB, and its horizon- tal blanking interval is fixed. Figure 8 - Display Screen Horizontal and Vertical Blanking Intervals...
Game Boy Advance Programming Manual May 25, 2005 LCD Status 4.1.1 V Counter The VCOUNT register can be used to read which of the total of 228 LCD lines (see "Figure 8 - Display Screen Horizontal and Vertical Blanking Intervals"...
May 25, 2005 Image System Game Boy Advance can use different image systems depending on the purpose of the software. These display-related items are changed mainly using the DISPCNT register. Figure 11 - The DISPCNT Register 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 Address...
Page 42
0 for rendering; a setting of 1 selects the contents of frame buffer 1 for rendering. DISPCNT [d03] (CGB Mode) Game Boy Advance is equipped with two CPUs. In Game Boy Advance mode, a 32-bit RISC CPU starts, and in CGB mode, an 8-bit CISC CPU starts.
5.1.1 Details of BG Modes In Game Boy Advance, changing the BG mode allows character format and bitmap format to be used selectively, as appropriate. In modes 0, 1, and 2, rendering to the LCD screen is performed in a character format suitable for the game.
Game Boy Advance Programming Manual May 25, 2005 Table 7 - Background Mode Details (Bitmap Format BG Screen) Bitmap Format BG Screen Features Frame No. of Mode Rotation No. of Memory Colors Size /Scaling Screens 240 x 160 32,768 O O O O...
May 25, 2005 Rendering Functions The Game Boy Advance CPU has 96 KB of built-in VRAM. Its rendering functions include BG and OBJ display capability. The method used for BG rendering varies with the BG mode, as described below. Character Mode BG (BG Modes 0-2) In character mode, the components of the BG screen are basic characters of 8 x 8 pixels.
Game Boy Advance Programming Manual May 25, 2005 The contents of the BG control registers are shown below. 6.1.1.1 Text BG Screen Control (BG0, BG1) Figure 13 - Background Screen Control Registers 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 Address...
Game Boy Advance Programming Manual May 25, 2005 (2) Illustration of Screen Sizes for Rotation/Scaling BG Screens Figure 16 - Rotation/Scaling Background Screen Sizes [d15,d14]=[0,0] [d15,d14]=[0,1] Virtual screen size: 128 x 128 Virtual screen size: 256 x 256 or (128 x 128) or ...
Game Boy Advance Programming Manual May 25, 2005 6.1.3 VRAM Address Mapping of BG Data BG data (BG character and screen data) are stored in the 64-KB BG area of VRAM. 6.1.3.1 BG Character Data The starting address for referencing BG character data can be specified using the character base block specification of the BG control register.
Game Boy Advance Programming Manual May 25, 2005 6.1.4 Character Data Format There are two formats for character pixel data, 16 color x 16 palettes and 256 colors x 1 palette. The same format is used for OBJ and BG.
Game Boy Advance Programming Manual May 25, 2005 6.1.5.1 Text BG Screen A text BG screen consists of 2 byt es of screen data per basic character ; 1,024 character types can be specified. Figure 22 - Text Background Screen Format...
Character Mode BG (BG Modes 0-2) Cautions for VRAM Game Boy Advance provides a high degree of freedom in using the BG area of VRAM. Consequently, in managing VRAM, the following points deserve particular attention. 1. There are 2 formats for BG character data (defined by 16 and 256 colors), and these can be used together.
Game Boy Advance Programming Manual May 25, 2005 6.1.7 BG Rotation and Scaling Features Rotation and scaling of the BG as a whole can be performed in a rotation/scaling BG screen. With rotation, BG data is referenced as shown in the following figure.
May 25, 2005 Character Mode BG (BG Modes 0-2) BG rotation and scaling are implemented in Game Boy Advance using the following arithmetic expres- sions. Equation 1 - Background Rotation and Scaling Parameters used in rotation and scaling operations are specified for BG2 and BG3 in the following regis- ters.
Game Boy Advance Programming Manual May 25, 2005 6.1.7.1 Operations Used in BG Rotation/Scaling Processing 1. Using software, the user determines the results of the rotation/scaling operation for the left-upper coor- dinate of the display screen and sets this as the starting point of the BG data reference in registers BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, BG3X_L, BG3X_H, BG3Y_L, and BG3Y_H.
Game Boy Advance Programming Manual May 25, 2005 6.2.3 Pixel Data In the bitmap modes, only the amount of pixel data corresponding to the size of the display screen can be stored in VRAM. Available bitmap modes allow the simultaneous display of 32,768 colors (BG modes 3 and 5) and the display of 256 of the 32,768 colors (BG mode 4).
Game Boy Advance Programming Manual May 25, 2005 The “Number of Rendering Cycles” and the corresponding number of OBJ displayable for a single line is expressed in the table below. Table 16 - Rendering Cycles and the Corresponding Number of Displayable Objects...
Game Boy Advance Programming Manual May 25, 2005 VRAM Basic Character With OBJ Character Display OBJ Character Storage Area Unit Image b20h n+2 n+3 16 x 32-pixel character (256 colors x 1 palette format) n+4 n+5 1 basic character n+6 n+7...
Game Boy Advance Programming Manual May 25, 2005 In case of (double size flag, rotation/scaling flag) = (1, 0), OBJ is not displayed, but is displayed in other cases. [d08] Rotation/Scaling Flag Allows rotation processing for the OBJ to be enabled and disabled.
Game Boy Advance Programming Manual May 25, 2005 [d13] [d12] Vertical and Horizontal Flip Flags Allows the OBJ to be flipped horizontally and vertically. A normal display is produced by a setting of 0 and a flip display by a setting of 1.
Game Boy Advance Programming Manual May 25, 2005 The values set for PA, PB, PC, and PD are signed, fixed-point numbers (8-bit fractional portion, 7-bit inte- ger portion, 1-bit sign, for a total of 16 bits). These 4 parameters are used together as a single group, which can be placed in any of 32 areas in OAM.
Page 83
Color Palettes Color Palette Overview The LCD unit of Game Boy Advance can display 32 levels of red, 32 levels of green, and 32 levels of blue, for a total of 32,768 colors. The number of colors that can be displayed at once varies with the BG mode. See "5.1.1 Details of BG...
Game Boy Advance Programming Manual May 25, 2005 Color Palette RAM OBJs and BGs use separate palettes. The size of palette RAM is large enough (512 bytes) to hold data (16-bit) for up to 256 colors (of 32,768) that can be specified. The memory map of the OBJ and BG palettes is shown in the follow figure.
May 25, 2005 Window Feature The Game Boy Advance system can display 2 windows simultaneously. Display of the areas inside and outside the windows can be separately turned on and off. In addition, scrolling and color special effects such as rotation, blending, and fade-in/fade-out can be per-...
Game Boy Advance Programming Manual May 25, 2005 8.2.1 Control of Inside of Window The WININ register controls display of the area inside windows 0 and 1. The high-order bits (d13-8) control Window 1, while the low-order bits (d5-0) control Window 0.
May 25, 2005 Color Special Effects The Game Boy Advance provides the following color special effects. The area where these effects are applied can be limited using a window. Blending α Performs arithmetic operations on 2 selected surfaces and implements processing for 16 levels of semi-transparency.
Game Boy Advance Programming Manual May 25, 2005 In addition, semi-transparent OBJs are individually specified in OAM, and color special effects for the OBJ as a whole, are specified in the BLDCNT register. These specifications are summarized in the following table.
May 25, 2005 10 Sound In addition to 4 channels of CGB-compatible sound, Game Boy Advance has 2 channels of direct sound. 1. Direct Sounds A and B • Provides playback of linear 8-bit audio data. • Uses the timer and DMA.
Game Boy Advance Programming Manual May 25, 2005 SOUND1CNT_L [d02 - 00] Number of Sweep Shifts Specifies the number of sweeps. The frequency data with a single shift are determined according to the following formula, with f signi- fying the frequency after a shift and f ...
Game Boy Advance Programming Manual May 25, 2005 Sound 1 Usage Notes 1. When the sweep function is not used, the sweep time should be set to 0 and the sweep increase/ decrease flag should be set to 1. 2. If sweep increase/decrease flag of NR10 is set to 0, the number of sweep shifts set to a non-zero value, and sweep OFF mode is set, sound production may be stopped.
RAM and output them while modifying their length, frequency, and level. The capacity of the waveform RAM of Sound 3 in Game Boy Advance (total of 64 steps) is twice that in CGB, and can be used as 2 banks of 32 steps or as 64 steps.
Page 102
Game Boy Advance Programming Manual May 25, 2005 SOUND3CNT_X [d14] Sound Length Flag When 0, sound is continuously output. When 1, sound is output for only the length of time specified for the sound length in NR31. When sound output ends, the Sound 2 ON flag of NR52 is reset.
Game Boy Advance Programming Manual May 25, 2005 10.6 Sound 4 Sound 4 is a circuit that generates white noise with the envelope function. The contents of NR41, NR42, NR43, and NR44 for Sound 4 conform with those of CGB.
Game Boy Advance Programming Manual May 25, 2005 SOUND4CNT_H [d02 - 00] Dividing Ratio Frequency Selection Selects a 14-step prescalar input clock to produce the shift clock for the polynomial counter. With f=4.194304 MHz, selection is as shown in the following table.
Sound PWM Control Bit modulation format PWM is used in the Game Boy Advance sound circuit. When no sound is produced, the duty waveform is output, and bias voltage is provided. The PWM circuit is stopped when the setting for duty is 0h.
Game Boy Advance Programming Manual May 25, 2005 SOUNDBIAS [d15 - 14] Amplitude Resolution/Sampling Cycle This sets the amplitude resolution and sampling cycle frequency during PWM modulation. The DMG compatible sound is input at 4 bits/130.93KHz so in order to have accurate modulation the sampling frequency must be set high.
May 25, 2005 Timer Game Boy Advance is equipped with 4 channels of 16-bit timers. Of these, timers 0 and 1 can be used to set the interval for the supply of data from the FIFO(s) for direct sounds A and B. This interval is set by timer overflow.
Game Boy Advance Programming Manual May 25, 2005 TM*CNT_H [d01 - 00] Prescalar Selection Allows selection of a prescal ar based on the system clock (16.78M Hz). Table 23 - Timer Control Prescalar Selection Setting Prescalar (Count-Up Interval) System clock (59.595 ns)
Page 113
(In order to prevent conflict with the external bus, the CPU stops when the DMA controller is working.) Game Boy Advance has 4 DMA transfer channels. The highest priority of these channels is DMA0, followed in order by DMA1, DMA2, and DMA3.
Game Boy Advance Programming Manual May 25, 2005 12.1.1 Source Address Specifies the source address using 27 bits. The area 00000000h-07FFFFFFh (internal memory area of main unit) can be specified. Figure 83 - DMA 0 Source Address Registers 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 Address...
Game Boy Advance Programming Manual May 25, 2005 DMA0CNT_H [d13 - 12] DMA Startup Timing The timing of the DMA transfer can be selected from the following options. Table 24 - DMA Transfer Timing Selections (DMA 0) Setting DMA Startup Timing...
Game Boy Advance Programming Manual May 25, 2005 12.2.3 Word Count Specifies the number of bytes transferred by DMA 1 and DMA 2, using 14 bits. The number can be speci- fied in the range 0001h~3FFFh~0000h (when 0000h is set, 4000h bytes are transferred).
Game Boy Advance Programming Manual May 25, 2005 DMA(1,2)CNT_H [d13-12] DMA Startup Timing The timing of the DMA transfer can be selected from the following options. Table 25 - DMA Transfer Timing Selections (DMA 1 and 2) Setting DMA Startup Timing...
Game Boy Advance Programming Manual May 25, 2005 12.3.3 Word Count Specifies the number of bytes transferred by DMA 3, using 16 bits. The number can be specified in the range 0001h~FFFFh~0000h (when 0000h is set, 10000h bytes are transferred).
Page 124
Game Boy Advance Programming Manual May 25, 2005 DMA3CNT_H [d09] DMA Repeat With the DMA repeat function set to ON, if V-blanking or H-blanking intervals are selected as the tim ing of DMA startup, DMA is restarted when the next startup condition occurs (a V-blank or H-blank).
Page 126
Game Boy Advance Programming Manual May 25, 2005 12.4 DMA Problems: How to Avoid Them With DMA transfer it is possible to synchronize with H-blank, V-blank, Direct sound (DMA1,2), and Display (DMA3) (DMA repeat). However, there are some problems with this function as discussed below.
Always set the communication speed at 256KHz when performi ng normal communication using a Game Boy Advance Game Link Cable. Communication cannot be done properly at 2MHz. Also, please note it will be a one-way communication due to cable connection of multi-play communication.
When different software is connected to other device • When the communication mode is different from the other device • When the Game Boy Advance Game Link cable is connected incorrectly • When an error occurs in data due to noise 13.1 8-Bit/32-Bit Normal Serial Communication Serial transfer sends/receives simultaneously.
Game Boy Advance Programming Manual May 25, 2005 13.1.2 32-Bit Normal Serial Communication Data Registers 32-bit transfer mode uses [120h:SIODATA32_L] and [122h:SIODATA32_H] as data registers.(These data registers are used for 16-bit multi-player communication also.) The most significant bit will be d15 in the register SIODATA32_H, and the least significant bit will be d0 in the register SIODATA32_L.
Page 133
CNT register is being set. (Because it transforms to a receiving data bit that is being communicated.) The 8 bit transfer mode is compatible in terms of modes with DMG/CGB, but the voltage with the commu- nication terminal varies. Therefore, communication between Game Boy Advance and DMG/CGB is not possible.
Game Boy Advance Programming Manual May 25, 2005 Figure 100 - Normal Serial Communication Flow (Example) Set (0) in (d15) of Register RCNT Set (0,0) or (0,1) in (d13,d12) of Control Regis ter SIOCNT Set transfer data Set (1) in (d03) of Control...
HI, you can tell that all connected terminals have entered multi-player communication mode. The SI terminal is in pull-up input, but due to the multi player Game Boy Advance Game Link cable it becomes pull-down. Thus, once all of the terminals are in multi-player mode, the terminal that is LO input to the SI terminal becomes the master.
Game Boy Advance Programming Manual May 25, 2005 Once the transmission ends, the received data is stored in each of the data registers (SIOMULTI0, SIOMULTI1, SIOMULTI2, and SIOMULTI3). If there is a terminal that is not connected the initial data FFFFh is stored.
May 25, 2005 16-Bit Multi-player Communication Figure 103 - Multi Player Game Boy Advance Game Link Cable Connecting Diagram Small Large Connecter Connecter 13.2.2 Data Registers The data send is stored in the Register SIOMLT_SEND. Figure 104 - The SIOMLT_SEND Register ...
When set to 1, a data transfer is started. Upon completion of the data transfer, it is automatically reset. Caution Due to individual differences in Game Boy Advance hardware, there is a variation in the timing of inter- rupt occurrences. Always use a timer when sending data, so that you have an adequate interval between communications (minimum send interval + 600 clocks).
Game Boy Advance Programming Manual May 25, 2005 SIOCNT [d06] Communication Error Flag The communication status can be confirmed at the end of a communication. (During communication, it is not reflected properly.) If the status for this bit is 0, there is no error. If it is 1, it means an error has occurred.
Game Boy Advance Programming Manual May 25, 2005 13.3 UART Communication Functions UART communications can be illustrated using the following drawing. Figure 109 - UART Communication In UART communication mode, a HI level is output from the SD terminal. When the receive data register (or the receive FIFO) is full, a HI is output from the SD terminal. When it is not full, a LO is output from the SD terminal if the receive enable flag is set.
Game Boy Advance Programming Manual May 25, 2005 13.3.5 Control Register If Register SIOCNT (d13,d12) = (1,1) is set when Register RCNT (d15) = (0), you will go to UART commu- nication mode. Figure 114 - The SIOCNT Register (UART)
Game Boy Advance Programming Manual May 25, 2005 SIOCNT [d05] Receive Data Flag When set to 0, there is still data present. When set to 1, it is empty. SIOCNT [d04] Send Data Flag When set to 0, it is not full.
Game Boy Advance Programming Manual May 25, 2005 13.5 JOY Bus Communication By setting the communication function set flag to 11 for Register RCNT, JOY Bus communication mode is selected. In JOY Bus communication mode, the SI Terminal is for input, and SO Terminal is for output. SD and SC Terminals go to LO output.
Game Boy Advance JOY Bus communication recognizes four commands sent from the host (for example, Nintendo GameCube). These commands are: “JOY Bus Reset”, “Type/Status Data Request”, “JOY Bus Data Write”, and “JOY Bus Data Read.” Game Boy Advance operates based on the particular signal received.
If the GBA cable is disconnected and then reconnected, the Game Boy Advance may behave the same way it does when it receives a JOY Bus reset command (i.e., the JOY_IF_RESET bit of the REG_JOYCNT register is set).
Page 152
Game Boy Advance Programming Manual May 25, 2005 If the Game Boy Advance cannot respond to this series of SIO interrupts (due to such factors as a large DMA, an extended interrupt process, or a prolonged disabling of interrupts), then data communication will fail and incorrect values will be exchanged.
14.1 Key Status Game Boy Advance allows input with the L and R Buttons, as well as with the START and SELECT but- tons, the +Control Pad, and A and B Buttons. The status of each of these buttons can be checked by reading the individual bits of Register KEYINPUT.
May 25, 2005 15 Interrupt Control Game Boy Advance can use 14 types of maskable hardware interrupts. If an interrupt request signal is received from a hardware item, the corresponding interrupt request flag is set in the IF register. Masking can be performed individually for interrupt request signals received from each hardware item by means o f the interrupt request flag register IE.
An interrupt request occurs when the IREQ terminal is “High”. Although the IREQ terminal is pulled “High” in the Game Boy Advance hardware, the IREQ terminal is set to “Lo” when a normal Game Pak is installed. Therefore, the IREQ terminal is pulled “High” and an interrupt request occurs when the Game Pak is removed from the Game Boy Advance.
Page 160
Game Boy Advance Programming Manual May 25, 2005 15.5.1 Normal Interrupt 1. If an interrupt occurs, the CPU enters IRQ mode and control shifts to the Monitor ROM. In Monitor ROM, save each register (R0~R3, R12, LR_irq (former PC)) to the Interrupt Stack. The total is 6 words.
Canceling stop status requires a brief wait until the system clock stabilizes. Note: 16.1.3 System Working Status in Stop Mode The working status of each block of the Game Boy Advance system during a stop is shown in the following table. Table 35 - System Status while in Stop Mode Block...
Game Boy Advance Programming Manual May 25, 2005 16.1.4 Stop Function Cautions • The only way to distinguish the stopped state from the power off state is to observe the Power lamp. Therefore, it is possible that a user may fail to notice the stopped state.
16.2.3 System Working Status in Halt Mode The working status of each block of the Game Boy Advance system during a semi-stop is shown in the fol- lowing table. Table 39 - System Status while in Halt Mode...
Page 167
May 25, 2005 17 Game Boy Advance System Calls Please refer to the for Game Boy Advance system calls. AGB System Call Ref erence Manual 17.1 System Call Operation 17.1.1 Normal Calls 1. When an argument is required for the system call used, after writing to registers R0-R3 call the monitor ROM system call with the “SWI<Number>”.
Page 168
Game Boy Advance Programming Manual May 25, 2005 17.1.2 Multiple Calls 1. When an argument is required for the system call used, after reading to the registers, R0-R3, call the monitor ROM system call with the “SWI<Number>”. 2. Save the registers, SPSR_svc (formerly CPSR), R12, LR_svc (formerly PC) to the system call stack with the monitor ROM.
Page 170
Game Boy Advance Programming Manual May 25, 2005 13. Complete processing with each system call. USR Stack IRQ Stack SVC Stack 03007F00 03007FA0 03007FE0 SP_usr SP_irq 4 WORDS SP_svc 03007F00 03007FA0 14. Return value to registers R0, R1, and R3, in cases where a system call provides a return value, and then return to the user program.
Store the 32-bit ARM command “B<User program start address>”. 18.2 Nintendo Logo Character Data The Nintendo logo/character data, which is displayed when the game is started, is stored here. The Moni- tor ROM checks this data at start-up, therefore always store the data provided by Nintendo. 18.3 Game Title Store the Game title in this area.
Game Boy Advance Programming Manual May 25, 2005 18.8 Device Type Store the type of device that is installed in the Game Pak. If there is a 1-megabit flash DACS (Debugging And Communication System) (=custom 1Mbit flash Memory with security and patch functions) in a Game Pak, set the applicable bit to 1.