Advertisement
LuigiBlood

Hello World GBA source code

Dec 21st, 2011
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Hello World by Seru-kun/LuigiBlood for GBA.
  2.  
  3. .gba
  4. .create hello.gba,0x08000000
  5. .org 0x08000000
  6. .area 0x080000BE        ;Header Area
  7. header:
  8.     .arm
  9.     b rom_start             ;Start the ROM
  10.     .incbin nintendo.bin
  11.     .db "HELLO WORLD "      ;Game Title
  12.     .db "HOME"              ;Game Code
  13.     .db "01"                ;Maker Code
  14.     .db 0x96                ;Fixed Value
  15.     .db 0x00                ;GBA Model
  16.     .db 0x00                ;Normal Cart
  17.     .fill 7                 ;Reserved Area
  18.     .db 0                   ;Version: 0.0
  19.     .db 0xFF                ;Checksum, must be replaced
  20.     .fill 2
  21. .endarea
  22.  
  23. rom_start:
  24.     .arm
  25.     ldr r0,=rom_start2|1
  26.     bx r0
  27.     .pool
  28.    
  29. rom_start2:
  30.     .thumb
  31.     mov r0,0x80
  32.     lsl r0,r0,8
  33.     mov r1,0x01
  34.     eor r0,r1
  35.     lsl r0,r0,12            ;r0=0x08001000
  36.    
  37.     mov r1,0x06
  38.     lsl r1,r1,24            ;r1=0x06000000
  39.    
  40.     mov r2,0x01
  41.     lsl r2,r2,8             ;r2=0x100
  42.     bl uploadDMA1
  43.     b rom_start3   
  44.    
  45. uploadDMA1:
  46.     .thumb
  47. ;Inputs:
  48. ;r0=SourceAddr
  49. ;r1=DestAddr
  50. ;r2=Size (Bytes)
  51.    
  52.     mov r3,0x04
  53.     lsl r3,r3,24
  54.     mov r4,0xBC
  55.     eor r3,r4       ;r3=0x040000BC
  56.     str r0,[r3]     ;Put r0 data to 0x040000BC
  57.    
  58.     eor r3,r4
  59.     mov r4,0xC0
  60.     eor r3,r4       ;r3=0x040000C0
  61.     str r1,[r3]     ;Put r1 data to 0x040000C0
  62.    
  63.     eor r3,r4
  64.     mov r4,0xC4
  65.     eor r3,r4
  66.     lsr r2,r2,1     ;r3=0x040000C4
  67.     strh r2,[r3]    ;Put r2 data to 0x040000C4
  68.    
  69.     eor r3,r4
  70.     mov r4,0xC7
  71.     eor r3,r4
  72.     mov r4,0x80
  73.     strb r4,[r3] ;Begin DMA Channel 1
  74.    
  75.     mov r15,r14 ;Return
  76.    
  77. rom_start3:
  78.     .thumb
  79.     ;Set Palette
  80.     mov r0,0xFF
  81.     eor r1,r0
  82.     lsl r1,r1,8
  83.     eor r1,r0
  84.     lsl r1,r1,16  ;r1=0xFFFF0000
  85.     mov r0,0x05
  86.     lsl r0,r0,4*6 ;r0=0x05000000
  87.     str r1,[r0] ;Put 0xFFFF0000 to address 0x05000000
  88.    
  89.     ;Set BG1 Map to 0x06000800
  90.     mov r1,0x01
  91.     lsl r1,r1,8 ;r1=0x0100
  92.    
  93.     mov r0,0x04
  94.     lsl r0,r0,4*6
  95.     mov r2,0x08
  96.     eor r0,r2   ;r0=0x04000008
  97.     strh r1,[r0] ;Put 0x0100 to address 0x04000008
  98.    
  99.     ;Set BG1 Tile Map
  100.     mov r0,0x08
  101.     lsl r0,r0,4*4
  102.     mov r1,0x11
  103.     eor r0,r1
  104.     lsl r0,r0,4*2 ;r0=0x08001100
  105.    
  106.     mov r1,0x06
  107.     lsl r1,r1,4*6
  108.     mov r2,0x80
  109.     lsl r2,r2,4
  110.     eor r1,r2     ;r1=0x06000800
  111.    
  112.     mov r2,22       ;r2=22
  113.    
  114.     bl uploadDMA1
  115.    
  116.     mov r0,0x01
  117.     lsl r0,r0,8 ;r0=0x0100
  118.    
  119.     mov r1,0x04
  120.     lsl r1,r1,4*6 ;r1=0x04000000
  121.     strh r0,[r1] ;Remove Force Blank and activate BG1
  122.    
  123. @@loop:
  124.     b @@loop
  125.  
  126.  
  127. .org 0x08001000
  128. GFXData:
  129.     .incbin hello.bin
  130. TileMap:
  131.     .dh 0x0001,0x0002,0x0003,0x0003,0x0004 ;HELLO
  132.     .dh 0x0000 ;space
  133.     .dh 0x0005,0x0004,0x0006,0x0003,0x0007 ;WORLD
  134.    
  135. .close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement