- 249
- Posts
- 12
- Years
- Seen Jun 17, 2024
Hi!
In these days i developed a variant of prime's DNS:
.THUMB
.ALIGN 2
MOV R6, #1
AND R6, R7
CMP R6, #1
BEQ CHANGE
PUSH {R2}
MOV R2, R3
LSR R2, R2, #2
SWI 0xC
POP {R2}
CHANGE:
PUSH {R2-R7}
MOV R4, #0
LDR R2, .HOUR
LDRB R7, [R2, #1]
LDRB R6, [R2]
MOV R3, #60
MUL R7, R3
MOV R5, R3
MUL R3, R5
MUL R6, R3
ADD R6, R7
PUSH {R0-R6}
MOV R0, R6
MOV R1, #135
LSL R1, R1, #4
SWI 0x6
LDR R7, .FILTRI
LSL R0, R0, #1
ADD R7, R0
LDR R7, [R7]
POP {R0-R6}
LOOP:
LDRH R5, [R0, R4]
LSL R2, R5, #27
LSR R2, R2, #27
LSL R6, R7, #27
LSR R6, R6, #27
SUB R2, R6
BPL GREEN
MOV R2, #0
GREEN:
LSL R3, R5, #22
LSR R3, R3, #27
LSL R6, R7, #22
LSR R6, R6, #27
SUB R3, R6
BPL BLUE
MOV R3, #0
BLUE:
LSL R5, R5, #17
LSR R5, R5, #27
LSL R6, R6, #17
LSR R6, R6, #27
SUB R5, R6
BPL SHIFT
MOV R5, #0
SHIFT:
LSL R3, R3, #5
LSL R5, R5, #10
EOR R5, R2
EOR R5, R3
STRH R5, [R1, R4]
ADD R4, #2
CMP R4, #4
BNE LOOP
END:
POP {R2-R7}
ADD R0, #4
ADD R1, #4
SUB R3, #1
BPL CHANGE
LDR R6, .RETURN
BX R6
.ALIGN 2
.FILTRI: .word 0x08F00000
.RETURN: .word 0x08B000C4+1
.HOUR: .word 0x03005542
Each filter follows the same format of GBA palettes:
[0] - [5 bit blue] - [5 bit green] - [5 red bit]
The first bit is unused, while the remaining fields occupy 5 bits.
In each field, you must specify how much blue/green/red subtract from the palette.
For example, to get a blue-tinted filter, you have to subtract red and green:
[0] - [0] - [8] - [8] -> [0] - [01000] - [01000] - [01000] -> 0x2108
I used these filters:
In this specific case, there are 40 filters.
This number is obtained from the following formula: ((hours * 3600) + (minutes * 60) / 2160) = [0-39]
To increase the number of filters, replace the red highlighted part of the code with:
LDR R1, = VAL, where instead of VAL will be entered the denominator of the previous division, in my case 2160.
For example, to use 144 filters, you must be raplce VAL with 600 -> (24 hours * 3600) / 600 = 144.
In the last part of the routine, where the various offsets are marked, one is highlighted in blue and corresponds to the table where the filters are placed.
You can change it the offset where filters will insert.
To insert it we must go to 0x98 bytes later than the offset of the original DNS routine, and then overwrite the bytes with 00 4E 30 47 XX XX XX 08, where XX will be raplced by the offset of the new routine in little endian + 1.
Here's a little video to show the end result:
In these days i developed a variant of prime's DNS:
Spoiler:
.THUMB
.ALIGN 2
MOV R6, #1
AND R6, R7
CMP R6, #1
BEQ CHANGE
PUSH {R2}
MOV R2, R3
LSR R2, R2, #2
SWI 0xC
POP {R2}
CHANGE:
PUSH {R2-R7}
MOV R4, #0
LDR R2, .HOUR
LDRB R7, [R2, #1]
LDRB R6, [R2]
MOV R3, #60
MUL R7, R3
MOV R5, R3
MUL R3, R5
MUL R6, R3
ADD R6, R7
PUSH {R0-R6}
MOV R0, R6
MOV R1, #135
LSL R1, R1, #4
SWI 0x6
LDR R7, .FILTRI
LSL R0, R0, #1
ADD R7, R0
LDR R7, [R7]
POP {R0-R6}
LOOP:
LDRH R5, [R0, R4]
LSL R2, R5, #27
LSR R2, R2, #27
LSL R6, R7, #27
LSR R6, R6, #27
SUB R2, R6
BPL GREEN
MOV R2, #0
GREEN:
LSL R3, R5, #22
LSR R3, R3, #27
LSL R6, R7, #22
LSR R6, R6, #27
SUB R3, R6
BPL BLUE
MOV R3, #0
BLUE:
LSL R5, R5, #17
LSR R5, R5, #27
LSL R6, R6, #17
LSR R6, R6, #27
SUB R5, R6
BPL SHIFT
MOV R5, #0
SHIFT:
LSL R3, R3, #5
LSL R5, R5, #10
EOR R5, R2
EOR R5, R3
STRH R5, [R1, R4]
ADD R4, #2
CMP R4, #4
BNE LOOP
END:
POP {R2-R7}
ADD R0, #4
ADD R1, #4
SUB R3, #1
BPL CHANGE
LDR R6, .RETURN
BX R6
.ALIGN 2
.FILTRI: .word 0x08F00000
.RETURN: .word 0x08B000C4+1
.HOUR: .word 0x03005542
Each filter follows the same format of GBA palettes:
[0] - [5 bit blue] - [5 bit green] - [5 red bit]
The first bit is unused, while the remaining fields occupy 5 bits.
In each field, you must specify how much blue/green/red subtract from the palette.
For example, to get a blue-tinted filter, you have to subtract red and green:
[0] - [0] - [8] - [8] -> [0] - [01000] - [01000] - [01000] -> 0x2108
I used these filters:
Spoiler:
E8 00 C7 00 A6 00 86 00 65 00 44 00 24 00 03 00 02 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 04 40 08 60 0C 80 10 A0 14 C0 18 E0 1C 00 21 01 1D 02 19 03 15 04 11 05 0D 06 09 07 05 08 01
In this specific case, there are 40 filters.
This number is obtained from the following formula: ((hours * 3600) + (minutes * 60) / 2160) = [0-39]
To increase the number of filters, replace the red highlighted part of the code with:
LDR R1, = VAL, where instead of VAL will be entered the denominator of the previous division, in my case 2160.
For example, to use 144 filters, you must be raplce VAL with 600 -> (24 hours * 3600) / 600 = 144.
In the last part of the routine, where the various offsets are marked, one is highlighted in blue and corresponds to the table where the filters are placed.
You can change it the offset where filters will insert.
To insert it we must go to 0x98 bytes later than the offset of the original DNS routine, and then overwrite the bytes with 00 4E 30 47 XX XX XX 08, where XX will be raplced by the offset of the new routine in little endian + 1.
Here's a little video to show the end result: