Skip to content

Commit

Permalink
Fixed byte writes to bg vram and menu cursor speed
Browse files Browse the repository at this point in the history
MAKE SURE YOU CLEAN BEFORE BUILDING! Otherwise the data permissions are
not updated yielding broken graphics.
  • Loading branch information
Gericom committed Apr 22, 2017
1 parent c4fda5b commit a61e70e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
2 changes: 1 addition & 1 deletion arm9/source/consts.s
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sd_cluster_cache_info = (sd_is_cluster_cached_table + (16 * 1024))
sd_sd_info = (sd_cluster_cache_info + (256 * 8 + 4)) @0x0685C404


pu_data_permissions = 0x33600003 @0x33660003
pu_data_permissions = 0x33600603 @0x33600003 @0x33660003

@destroys r12, r13
.macro printreg reg
Expand Down
35 changes: 35 additions & 0 deletions arm9/source/handle_address_write.s
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,22 @@ write_address_from_handler_32bit:
write_address_from_handler_sprites_32bit:
cmp r9, #0x0E000000
bge write_address_from_handler_sram_32bit
ldr r13,= DISPCNT_copy
ldrh r13, [r13]
and r13, #7
cmp r13, #3
ldrlt r13,= 0x06010000
ldrge r13,= 0x06014000
cmp r9, r13
movlt r10, r9
blt write_address_from_handler_sprites_32bit_cont

ldr r12,= 0x06018000
cmp r9, r12
bxge lr
add r10, r9, #0x3F0000

write_address_from_handler_sprites_32bit_cont:
str r11, [r10]
bx lr

Expand Down Expand Up @@ -57,11 +69,22 @@ write_address_from_handler_16bit:
write_address_from_handler_sprites_16bit:
cmp r9, #0x0E000000
bge write_address_from_handler_sram_16bit
ldr r13,= DISPCNT_copy
ldrh r13, [r13]
and r13, #7
cmp r13, #3
ldrlt r13,= 0x06010000
ldrge r13,= 0x06014000
cmp r9, r13
movlt r10, r9
blt write_address_from_handler_sprites_16bit_cont

ldr r12,= 0x06018000
cmp r9, r12
bxge lr
add r10, r9, #0x3F0000

write_address_from_handler_sprites_16bit_cont:
tst r9, #1
movne r11, r11, ror #8
strh r11, [r10]
Expand Down Expand Up @@ -99,6 +122,18 @@ write_address_from_handler_8bit:
write_address_from_handler_sprites_8bit:
cmp r9, #0x0E000000
bge write_address_from_handler_sram_8bit
ldr r13,= DISPCNT_copy
ldrh r13, [r13]
and r13, #7
cmp r13, #3
ldrlt r13,= 0x06010000
ldrge r13,= 0x06014000
cmp r9, r13
bxge lr //nothing written on 8 bit access

orr r11, r11, lsl #8
strh r11, [r9]

//nothing written on 8 bit access
bx lr

Expand Down
11 changes: 9 additions & 2 deletions arm9/source/sd_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,18 @@ PUT_IN_VRAM void get_game_first_cluster(uint32_t& cur_dir_cluster, dir_entry_t*
while(1) {
//show cursor
MI_WriteByte((void*)0x06202000 + 32*(cursor_position - start_at_position + ENTRIES_START_ROW), 0x1A);

for (int i = 0; i < 8; i++)
{
while (*((vu16*)0x04000006) != 192);
while (*((vu16*)0x04000006) == 192);
}

do {
//do {
old_keys = keys;
keys = ~*((vu16*)0x04000130);
} while (keys == old_keys);
// while (*((vu16*)0x04000006) != 192);
//} while (keys == old_keys);

//hide cursor
if(keys & (KEY_UP | KEY_DOWN | KEY_LEFT | KEY_RIGHT))
Expand Down
7 changes: 5 additions & 2 deletions arm9/source/setup.s
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ vram_setup_copyloop:
//region 2 card 0x08000000-0x0FFFFFFF 2 << 26 -/-/-
//ldr r0,= (1 | (26 << 1) | 0x08000000)
//mcr p15, 0, r0, c6, c2, 0
mov r0, #0
//mov r0, #0
//mcr p15, 0, r0, c6, c2, 0
//vram; write protected, cause byte writes are not possible :/
ldr r0,= (1 | (16 << 1) | 0x06000000)
mcr p15, 0, r0, c6, c2, 0

//region 3 oam vram region 0x06010000-0x06017FFF 2 << 14 -/-/-
Expand Down Expand Up @@ -133,7 +136,7 @@ vram_setup_copyloop:
//orr r0, r0, #(0x36 << (4 * 5))
//orr r0, r0, #(0x3 << (4 * 7))
mcr p15, 0, r0, c5, c0, 2
ldr r0,= 0x33660003
ldr r0,= 0x33660303
mcr p15, 0, r0, c5, c0, 3

//only instruction and data cache for (fake) cartridge
Expand Down

0 comments on commit a61e70e

Please sign in to comment.