Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,415,125
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 04-16-24 03:28 PM
Guest: Register | Login

0 users currently in ROM Hacking | 1 guest | 1 bot

Main - ROM Hacking - Foofatron's asm stuff. New thread | New reply


foofatron
Posted on 06-21-08 02:51 PM (rev. 3 of 06-21-08 03:01 PM) Link | Quote | ID: 85472


Micro-Goomba
Level: 11

Posts: 9/17
EXP: 5360
Next: 625

Since: 04-12-08

Last post: 5731 days
Last view: 5721 days
I merged many of my tutorials together. For learning thumb\arm visit gbatek. For some of my tutorials you'll need to use the assemblers. How to use them:
as -o C:\MIDI2GBA\MIDI2GBA\text.o C:\MIDI2GBA\MIDI2GBA\text.s
objcopy -O binary C:\MIDI2GBA\MIDI2GBA\text.o C:\MIDI2GBA\MIDI2GBA\text.bin
pause
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ok well in case you didn't know midi2gba comes with the official assembler and mid2agb converts a .mid to .s so with this knowledge lets make a bat file that converts our .mid to an .s file then converts it to an object file and then to a .bin file for inserting.

Its usage is like this: MID2AGB input_file [output_file] [options]

input_file Filename(.MID) of Standard MIDI file.
output_file Filename(.s) for AGB file.(default:input_file)

Mid2agb has different options that you but after -your asm file-.s
The first few are in Japanese.They are the following:
-L??? Label for assembler.(default:output_file)
-V??? master Volume.(default:127)
-G??? voiceGroup number.(default:0)
-P??? Priority.(default:0)
-R??? Reverb.(default:off)
-X 48 clock/beet.(default:24 c/b)
-E Exact gate-time.
-N No compression.

Now for the rest of the bat file:

PATH= C:\MIDI2GBA\MIDI2GBA;
MID2AGB text.mid text.s
as -o C:\MIDI2GBA\MIDI2GBA\text.o C:\MIDI2GBA\MIDI2GBA\text.s
objcopy -O binary C:\MIDI2GBA\MIDI2GBA\text.o C:\MIDI2GBA\MIDI2GBA\text.bin
pause

Now save that as text.bat or whatever you want the name doesn't really matter.
Now click!

I put the pause so you can see if any errors occurred. Since these are the official assemblers you could remove the mid2agb part and use the rest to assemble your assembly file. You could just include the .s or .bin file in your code too, but if your doing by hex just copy and paste in your hex editor on an offset and you've inserted your song .

P.S you'll have to change the folder names and .mid names unless they are the same as mine. Meaning there are two folders both named MIDI2GBA and both your midi and the tools are in there. By the way, you can't have any spaces in your folder name just use a _ instead.

*Note: While retesting this I noticed some songs would not work right after asembled into a bin file. I thought maybe ld had to be used, but it crashed everytime I fed it a file. There is a gui tool that turns your midi to an object file, then you would only have to put it in object copy and you got your bin file!

İFoofatron 2008

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here's a list of the software interrupts (swi).:

SWI 00h - SoftReset
SWI 01h - RegisterRamReset
SWI 02h - Halt
SWI 03h - Stop
SWI 06h - Div
SWI 07h - DivArm
SWI 08h - Sqrt
SWI 09h - ArcTan
SWI 0Ah - ArcTan2
SWI 0Bh - CpuSet
SWI 0Ch - CpuFastSet
SWI 0Dh - GetBiosChecksum
SWI 0Eh - BgAffineSet
SWI 0Fh - ObjAffineSet
SWI 10h - BitUnPack
SWI 11h - LZ77UnCompWram
SWI 12h - LZ77UnCompVram
SWI 13h - HuffUnComp
SWI 14h - RLUnCompWram
SWI 15h - RLUnCompVram
SWI 16h - Diff8bitUnFilterWram
SWI 17h - Diff8bitUnFilterVram
SWI 18h - Diff16bitUnFilter
SWI 19h - SoundBias
SWI 1Ah - SoundDriverInit
SWI 1Bh - SoundDriverMode
SWI 1Ch - SoundDriverMain
SWI 1Dh - SoundDriverVSync
SWI 1Eh - SoundChannelClear
SWI 1Fh - MidiKey2Freq
SWI 20h..24h - SoundUndocumented
SWI 25h - MultiBoot
SWI 26h - HardReset
SWI 27h - CustomHalt
SWI 28h - SoundDriverVSyncOff
SWI 29h - SoundDriverVSyncOn
SWI 2Ah - SoundGetJumpList

For documentation on these please refer to gbatek. They offer a more detailed description than I can give.

İFoofatron 2008

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3rd Gen cry on the title screen:

Okay go to 080791EE (791EE in your hex editor). A little thumb here. 2006 mov r0, #0x6 (charizard cry) So the max is 255 right mov r0, #0xff (20ff)? Right, but we can use two codes to get our value!. The second part is mov r1, 0x0. Pointless, so let change it to add. The basic r0 add is 3000. I want deoxys, deoxys is number 410 the max is 255 so subtract them to get 155. 9B in hex. So we but 309b. That's FF plus 9B which equals 19a which is 410 in hex. Its easy only two thumb codes you have to edit .
My code is: 20ff 309b. Type in your hex editor the flipped values. FF 20 9B 30.
Enjoy!

İFoofatron 2008

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Loading a compressed image:

@ Foofatron 2008. @
@ Loading compressed graphics. @
@ Here's how! @
@ The "@" you see in here means comment in asm. @
@ Since the assembler doesn't know your offset, @
@ you have to calculate it likeC+4+(nn SHL 12) @
@ Bit Expl. @
@ 15-11 Must be 11110b for BL/BLX type of instructions @
@ 10-0 nn - Upper 11 bits of Target Address @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
.code 16
ldr r0, .UncompressedPalette
mov r1, #0xd0 @Means which offset in the pal ram.
mov r2, #0x20 @parameter, size.
bl label @$080703ec
lsl r0, #0x00 @Calculation room.
ldr r1, .CompressedImage
mov r0, #0x1
mov r2, #0x0
mov r3, #0x0
bl label @$080f6878
lsl r0, #0x00 @Calculation room.
ldr r1, .RawFile
mov r0, #0x1
mov r2, #0x0
mov r3, #0x0
bl label @$080f6878
lsl r0, #0x00 @Calculation room.
.align 2
.UncompressedPalette:
.word 0x08e39d48
.CompressedImage:
.word 0x08800000
.RawFile:
.word 0x08800020

Pretty self explanatory... Credits to gbatek for the bl info.
The forum ruined my perfect @ box D:!

İFoofatron 2008

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@Change palettes.
.code 16
push {r0, r1, r2, r3, r4, lr}
ldr r0, .PaletteSource
ldr r1, .PaletteDestination
mov r2, #224
swi #11
ldr r0, .PaletteSourceSprite
ldr r1, .PaletteDestinationSprite
mov r2, #16
swi #11
pop {r0, r1, r2, r3, r4, pc}
.align 2
.PaletteSource:
.word 0x08800000
.PaletteDestination:
.word 0x020375f8
.PaletteSourceSprite:
.word 0x08870000
.PaletteDestinationSprite:
.word 0x020377f8


@Ruby Offsets [AXVE]
@Background Palettes start @ 0x0202EEC8
@Sprite Palettes start @ 0x0202F0C8

@Fire Red Offsets [BPRE]
@Background Palettes start @ 0x020375f8
@Sprite Palettes start @ 0x020377f8

@credit: Zodiac for finding the ruby offsets.

İFoofatron 2008

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Pointers!
082350ac - front sprite pointer table.
0823654c - back sprite pointer table.
0823730c - normal palette pointer table.
082380cc - shiny palette pointer table. Ends 0823932b
083d37a0 - icon pointer table.
083d3e80 - icon palette pointer table starts at 0x083d4294 though...
083d4038 - 2nd icon palette pointer same pointers though... Starts at 0x083d4294 though...
08245ee0 - wtf?
084556f8 - some pointers and thumb code...

*Note: The pointers in the icon palettes are based off evolution so the first pointer is for the bulbasuar series, the second for charmander, etc.
As for the second pointer table I think that's what it is, but I can't tell.

08254784 -
0824fc40 -
0824fb08 -
083db028 -
08250c04 -
0826056c -
082605cc -

This second set is codes or pointers to codes.

How to reappoint these will be added... Later.

In your hex editor you'll have to take away the 08. 08 means rom to the gba.

İFoofatron 2008

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
İFoofatron 2008

DO NOT STEAL! You may use the asm codes and stuff in your hack though.

____________________
pho.xpt.net An awsome rom hacking site.

Main - ROM Hacking - Foofatron's asm stuff. New thread | New reply

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.016 seconds. (347KB of memory used)
MySQL - queries: 37, rows: 58/58, time: 0.013 seconds.