Skip to content

Commit

Permalink
Add the rest of the gba instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
OFFTKP committed Jul 25, 2023
1 parent eba0135 commit 1b4905f
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions src/gba.h
Original file line number Diff line number Diff line change
Expand Up @@ -3177,6 +3177,11 @@ bool gba_run_ar_cheat(gba_t* gba, const uint32_t* buffer, uint32_t size){
if_stack_index--;
break;
}
case 0x08: {
// AR slowdown
// Probably has no effect on emulators
break;
}
case 0x18:
case 0x1A:
case 0x1C:
Expand All @@ -3189,6 +3194,60 @@ bool gba_run_ar_cheat(gba_t* gba, const uint32_t* buffer, uint32_t size){
i+=2;
break;
}
case 0x10:{
// IF AR_BUTTON THEN [a0aaaaa]=zz
// Let's treat the AR button as always pressed for now
uint32_t address=((right<<4)&0x0F000000) | (right&0x000FFFFF);
uint8_t data = buffer[i+2];
gba_store8(gba,address,data);
break;
}
case 0x12:{
// IF AR_BUTTON THEN [a0aaaaa]=zzzz
uint32_t address=((right<<4)&0x0F000000) | (right&0x000FFFFF);
uint16_t data = buffer[i+2];
gba_store16(gba,address,data);
break;
}
case 0x14:{
// IF AR_BUTTON THEN [a0aaaaa]=zzzzzzzz
uint32_t address=((right<<4)&0x0F000000) | (right&0x000FFFFF);
uint32_t data = buffer[i+2];
gba_store32(gba,address,data);
break;
}
case 0x80:
case 0x82:
case 0x84:{
// 00000000 8naaaaaa 000000yy ssccssss repeat cc times [a0aaaaa]=yy
// (with yy=yy+ss, a0aaaaa=a0aaaaa+ssss after each step)
uint32_t address=((right<<4)&0x0F000000) | (right&0x000FFFFF);
uint8_t repeat=(buffer[i+3]>>16)&0xFF;
uint8_t data_increment=(buffer[i+3]>>24)&0xFF;
uint32_t address_increment=buffer[i+3]&0xFFFF;
uint32_t data=buffer[i+2];

if((current_code&0xF)==0x2){
address_increment*=2;
} else if((current_code&0xF)==0x4){
address_increment*=4;
}

for (int j=0;j<repeat;j++){
if((current_code&0xF)==0x2){
gba_store16(gba,address,data);
} else if((current_code&0xF)==0x4){
gba_store32(gba,address,data);
} else {
gba_store8(gba,address,data);
}
address+=address_increment;
data+=data_increment;
}

i+=2;
break;
}
default:{
return false;
}
Expand Down

0 comments on commit 1b4905f

Please sign in to comment.