|
楼主 |
发表于 2020-5-2 21:07:51
|
显示全部楼层
本帖最后由 本站第一萌新 于 2020-5-6 07:32 编辑
搭建内置金手指(内存锁)系统
本系统并不是实现了真正的锁住内存,而是不停往指定内存里写数据
此系统根据输入数据的大小来判断应该用什么指令储存,但事实上有时我们要求将某一区域的值全部写0。有兴趣者可以自行更改程序
和初始村中蓝色胖子对话查看效果- .gba
- .thumb
- .loadtable "header/CharTable.txt"
- .include "header/ArmipsMacros.asm"
- .create "3.0.gba",0x8000000
- .close
- .open "test.gba","3.0.gba", 0x8000000
- .org 0x08F80000
- .func GoldfingerPutIn
- push {r4-r5, lr}
- ldr r0, =0x020375E0
- ldrh r0, [r0]
- lsl r0, #3
- ldr r2, =0x0203F000
- add r0, r2
- mov r1, r2
- add r1, #40
- ldr r2, [r0]
- str r2, [r1]
- ldr r2, [r0, #4]
- str r2, [r1, #4]
- ldr r0, =(Task_GfProcessInput|1)
- mov r1, #0
- ldr r3, =(0x080A8FB0|1)
- bl call_bx
- ldr r5, =0x03005E00
- mov r1, #40
- mul r0, r1
- add r5, r0
- mov r0, #0 ;X
- mov r1, #0 ;Y
- mov r2, #18 ;W
- mov r3, #2 ;H
- ldr r4, =(0x080E2A1C|1)
- bl call_bx2
- strh r0, [r5, #8] ;twindowId
- mov r1, #0
- strh r1, [r5, #10] ;tstate
- mov r1, #3
- strh r1, [r5, #12] ;tslot
- mov r1, #0
- ldr r3, =(0x08197854|1)
- bl call_bx
- mov r0, #0
- ldr r3, =(0x081999BC|1)
- bl call_bx
- pop {r4-r5, pc}
- .endfunc
- .pool
- .func Task_GfProcessInput
- push {r4-r6, lr}
- mov r4, r0
- ldr r6, =0x03005E00
- mov r1, #40
- mul r0, r1
- add r6, r0
- ldrh r5, [r6, #8] ;twindowId
- ldrh r0, [r6, #10] ;tstate
- cmp r0, #0
- beq ShowGoldfinger
- ldr r0, =0x030022C0
- ldrh r0, [r0, #0x2E]
- cmp r0, #1
- beq A_Pressed
- cmp r0, #2
- beq B_Pressed
- cmp r0, #0x10
- beq Right_Pressed
- cmp r0, #0x20
- beq Left_Pressed
- cmp r0, #0x40
- beq Up_Pressed
- cmp r0, #0x80
- beq Down_Pressed
- b InputEnd
- A_Pressed:
- ldr r0, =0x020375E0
- ldrh r0, [r0]
- lsl r0, #3
- ldr r2, =0x0203F000
- add r0, r2
- mov r1, r2
- add r1, #40
- ldr r2, [r1]
- str r2, [r0]
- ldr r2, [r1, #4]
- str r2, [r0, #4]
- mov r2, #0
- str r2, [r1]
- str r2, [r1, #4]
- ldr r0, =0x020375E0
- mov r1, #1
- strh r1, [r0, #0x10]
- b DeleteTaskAndFreeWindow
- B_Pressed:
- mov r2, #0
- str r2, [r1]
- str r2, [r1, #4]
- ldr r0, =0x020375E0
- mov r1, #0
- strh r1, [r0, #0x10]
- DeleteTaskAndFreeWindow:
- mov r0, r4
- ldr r3, =(0x080A909C|1)
- bl call_bx
- mov r0, r5
- ldr r3, =(0x080E2A78|1)
- bl call_bx
- b InputEnd
- Right_Pressed:
- ldrb r0, [r6, #12]
- cmp r0, #4
- beq InputEnd
- cmp r0, #0
- beq ChangeSide1
- sub r0, #1
- b UpdateNumber1
- ChangeSide1:
- mov r0, #7
- UpdateNumber1:
- strb r0, [r6, #12]
- mov r1, r5
- bl UpdateGoldfinger
- b InputEnd
- Left_Pressed:
- ldrb r0, [r6, #12]
- cmp r0, #3
- beq InputEnd
- cmp r0, #7
- beq ChangeSide2
- add r0, #1
- b UpdateNumber2
- ChangeSide2:
- mov r0, #0
- UpdateNumber2:
- strb r0, [r6, #12]
- mov r1, r5
- bl UpdateGoldfinger
- b InputEnd
- Up_Pressed:
- ldrb r0, [r6, #12]
- ldr r1, =0x0203F000
- add r1, #40
- ldrb r2, [r0, r1]
- cmp r2, #0xFF
- bge InputEnd
- add r2, #1
- strb r2, [r0, r1]
- mov r1, r5
- bl UpdateGoldfinger
- b InputEnd
- Down_Pressed:
- ldrb r0, [r6, #12]
- ldr r1, =0x0203F000
- add r1, #40
- ldrb r2, [r0, r1]
- cmp r2, #0
- ble InputEnd
- sub r2, #1
- strb r2, [r0, r1]
- mov r1, r5
- bl UpdateGoldfinger
- b InputEnd
- ShowGoldfinger:
- mov r0, #3
- mov r1, r5
- bl UpdateGoldfinger
- mov r0, #1
- strh r0, [r6, #10]
- InputEnd:
- pop {r4-r6, pc}
- .endfunc
- .pool
- .func UpdateGoldfinger
- push {r4-r7, lr}
- add sp, #-8
- mov r7, r0
- mov r5, r1
- mov r0, r1
- mov r1, #17
- ldr r3, =(0x08003C48|1)
- bl call_bx
- mov r6, #0
- PrintPointerLoop:
- cmp r6, #4
- bge PrintColon
- mov r0, r6
- mov r1, r7
- mov r2, r5
- bl PrintNumberWithClour
- add r6, #1
- b PrintPointerLoop
- PrintColon:
- mov r0, #0
- str r0, [sp]
- str r0, [sp, #4]
- mov r0, r5
- ldr r1, =gText_Colon
- mov r2, #65
- mov r3, #1
- ldr r4, =(0x080E04A4|1)
- bl call_bx2
- PrintInputLoop:
- cmp r6, #8
- bge PrintEnd
- mov r0, r6
- mov r1, r7
- mov r2, r5
- bl PrintNumberWithClour
- add r6, #1
- b PrintInputLoop
- PrintEnd:
- add sp, #8
- pop {r4-r7, pc}
- .endfunc
- .pool
- .func PrintNumberWithClour
- push {r4-r7, lr}
- add sp, #-8
- mov r5, r0
- mov r6, r1
- mov r7, r2
- ldr r0, =0x02021FC4
- ldr r1, =0x0203F000
- add r1, #40
- ldrb r1, [r1, r5]
- mov r2, #2
- mov r3, #2
- ldr r4, =(0x08008E20|1)
- bl call_bx2
- cmp r5, r6
- bne NotHighLight
- ldr r0, =0x02021EC4
- ldr r1, =gText_HignLight
- ldr r3, =(0x08008EE0|1)
- bl call_bx
- ldr r0, =0x02021EC4
- ldr r1, =0x02021FC4
- ldr r3, =(0x08008BC0|1)
- bl call_bx
- mov r0, #0
- str r0, [sp]
- str r0, [sp, #4]
- mov r0, r7
- ldr r1, =0x02021EC4
- ldr r2, =poi
- ldr r2, [r2, r5]
- mov r3, #1
- ldr r4, =(0x080E04A4|1)
- bl call_bx2
- b PrintWithColourEnd
- NotHighLight:
- mov r0, #0
- str r0, [sp]
- str r0, [sp, #4]
- mov r0, r7
- ldr r1, =0x02021FC4
- ldr r2, =poi
- ldr r2, [r2, r5]
- mov r3, #1
- ldr r4, =(0x080E04A4|1)
- bl call_bx2
- PrintWithColourEnd:
- add sp, #8
- pop {r4-r7, pc}
- .endfunc
- .pool
- .func GoldfingerRun
- mov r4, #0
- RunGfLoop:
- cmp r4, #6
- bge LoopEnd
- ldr r0, =0x4012
- add r0, r4
- ldr r3, =(0x0809D790|1)
- bl call_bx
- cmp r0, #0
- beq PrepareForNext
- ldr r0, =0x0203F000
- lsl r1, r4, #3
- add r1, r0
- ldr r0, [r1]
- ldr r1, [r1, #4]
- mov r2, #1
- neg r2, r2 ;0xFFFFFFFF
- lsr r3, r2, #24 ;0xFF
- cmp r1, r3
- bls OneByte
- lsr r3, r2, #16 ;0xFFFF
- cmp r1, r3
- bls TwoByte
- str r1, [r0]
- b PrepareForNext
- OneByte:
- strb r1, [r0]
- b PrepareForNext
- TwoByte:
- strh r1, [r0]
- PrepareForNext:
- add r4, #1
- b RunGfLoop
- LoopEnd:
- ldrb r0, [r5]
- lsl r4, r0, #0x1F
- lsr r4, r4, #0x1F
- mov r1, #1
- ldr r3, =(0x08006A28|1)
- bx r3
- .endfunc
- .pool
- .func DeleteGoldfinger
- ldr r0, =0x020375E0
- ldrh r0, [r0]
- lsl r0, #3
- ldr r1, =0x0203F000
- add r0, r1
- mov r1, #0
- str r1, [r0]
- str r1, [r0, #4]
- bx lr
- .endfunc
- .pool
- .func OpenGoldfinger
- push {lr}
- ldr r0, =0x020375E0
- ldrh r0, [r0]
- ldr r1, =0x4012
- add r0, r1
- ldr r3, =(0x0809D740|1)
- bl call_bx
- pop {pc}
- .endfunc
- .pool
- .func CloseGoldfinger
- push {lr}
- ldr r0, =0x020375E0
- ldrh r0, [r0]
- ldr r1, =0x4012
- add r0, r1
- ldr r3, =(0x0809D768|1)
- bl call_bx
- pop {pc}
- .endfunc
- .pool
- .func call_bx
- bx r3
- .endfunc
- .pool
- .func call_bx2
- bx r4
- .endfunc
- .pool
- poi:
- .byte 49, 33, 17, 1, 129, 113, 97, 80
- gText_Colon:
- .string ":"
- gText_HignLight:
- .string "[文本色_红]"
- Script_BiGoldfinger:
- lock
- faceplayer
- msgbox gText_Weclome, 0x6
- Script_ChooseGf:
- preparemsg gText_ChooseGf
- waitmsg
- multichoice 0x0, 0x0, 0x74, 0x00 ;如果你打算手动扩充或者修改了下面写入的地址,把0x74改成你的多选框Id
- compare 0x800D, 0x7F
- if1 0x1, Script_End
- copyvar 0x8004, 0x800D
- Script_ChooseOperate:
- preparemsg gText_ChooseOperate
- waitmsg
- multichoice 0x0, 0x0, 0x75, 0x00 ;如果你打算手动扩充或者修改了下面写入的地址,把0x75改成你的多选框Id
- compare 0x800D, 0x7F
- if1 0x1, Script_ChooseGf
- compare 0x800D, 0x0
- if1 0x1, Script_OpenGf
- compare 0x800D, 0x1
- if1 0x1, Script_CloseGf
- compare 0x800D, 0x2
- if1 0x1, Script_AddGf
- callasm (DeleteGoldfinger|1)
- msgbox gText_DeleteSuccess, 0x6
- goto Script_ChooseOperate
- Script_OpenGf:
- callasm (OpenGoldfinger|1)
- msgbox gText_OpenSuccess, 0x6
- goto Script_ChooseOperate
- Script_CloseGf:
- callasm (CloseGoldfinger|1)
- msgbox gText_CloseSuccess, 0x6
- goto Script_ChooseOperate
- Script_AddGf:
- preparemsg gText_PleaseAddGf
- waitmsg ;这个waitmsg非常重要,因为文本框也是用的第四个buffer,必须等待文本输出完毕
- callasm (GoldfingerPutIn|1)
- waitkeypress
- compare 0x800D, 0x0
- if1 0x1, Script_AddCancel
- msgbox gText_AddSuccess, 0x6
- goto Script_ChooseOperate
- Script_AddCancel:
- msgbox gText_AddCancel, 0x6
- goto Script_ChooseOperate
- Script_End:
- release
- end
- .align 4
- Mult_ChooseSlot:
- .word gText_Goldfinger1
- .word 0x0
- .word gText_Goldfinger2
- .word 0x0
- .word gText_Goldfinger3
- .word 0x0
- .word gText_Goldfinger4
- .word 0x0
- .word gText_Goldfinger5
- .word 0x0
- Mult_Operate:
- .word gText_OpenGf
- .word 0x0
- .word gText_CloseGf
- .word 0x0
- .word gText_AddGf
- .word 0x0
- .word gText_DeleteGf
- .word 0x0
- gText_Goldfinger1:
- .string "金手指一"
- gText_Goldfinger2:
- .string "金手指二"
- gText_Goldfinger3:
- .string "金手指三"
- gText_Goldfinger4:
- .string "金手指四"
- gText_Goldfinger5:
- .string "金手指五"
- gText_OpenGf:
- .string "开启金手指"
- gText_CloseGf:
- .string "关闭金手指"
- gText_AddGf:
- .string "添加金手指"
- gText_DeleteGf:
- .string "删除金手指"
- gText_Weclome:
- .string "欢迎使用内置金手指!"
- gText_ChooseGf:
- .string "请选择金手指槽:"
- gText_ChooseOperate:
- .string "请选择操作:"
- gText_DeleteSuccess:
- .string "成功删除金手指!"
- gText_OpenSuccess:
- .string "成功开启金手指!"
- gText_CloseSuccess:
- .string "成功关闭金手指!"
- gText_PleaseAddGf:
- .string "请输入金手指!"
- gText_AddSuccess:
- .string "成功添加金手指!"
- gText_AddCancel:
- .string "取消添加金手指!"
- .org 0x08006A20 ;选择一个被调用及其频繁的地方
- ldr r3, =(GoldfingerRun|1)
- bx r3
- .pool
- .org 0x097003A0 ;这里是扩充多选框,注意此处是绿宝石802版本的。如果你用的是绿宝石原版请自行更改此地址(需要重定向)
- .align 4
- .word Mult_ChooseSlot
- .word 0x05
- .word Mult_Operate
- .word 0x04
- .org 0x089C0DFC
- .word Script_BiGoldfinger
- .close
复制代码 |
|