From 422eb6fd9f83b660c0f7635f194f7ef55e6bd484 Mon Sep 17 00:00:00 2001 From: Sky Date: Tue, 18 Jul 2023 15:21:19 -0700 Subject: [PATCH] =?UTF-8?q?=E3=80=90HTTP=E3=80=91Add=20address=20map=20com?= =?UTF-8?q?mand.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/HTTP_CONTROL_SERVER.md | 28 ++++++++++++++++++++++++++++ src/main.c | 16 +++++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/docs/HTTP_CONTROL_SERVER.md b/docs/HTTP_CONTROL_SERVER.md index 401f16a5e..2e5287672 100644 --- a/docs/HTTP_CONTROL_SERVER.md +++ b/docs/HTTP_CONTROL_SERVER.md @@ -107,6 +107,8 @@ The paramater format specifies which image format to use. It can be set to png, Reads one or multiple bytes of data from the emulated system at addresses provided using parameters. The addr parameter can be repeated an arbitrary amount of times to read an arbitrary amount of bytes. +The paramater map can be used to specify different address maps. This is currently only used in the NDS core where address map 7 is used for the ARM7 address map and 0 and 9 are used for the ARM9 address map. The default address map is 0. The map command only effects bytes read after the parameter and does not persist across API calls. + **Example (Read a single byte):** ```http://localhost:8080/read_byte?addr=02000004``` @@ -127,10 +129,22 @@ Reads one or multiple bytes of data from the emulated system at addresses provid ```f0bf01``` +**Example (Read multiple bytes from different address spaces ):** + +```http://localhost:8080/read_byte?addr=02000004&map=7&addr=02000005&addr=02000006``` + +**Result:** + +3 bytes of data are returned in hexadecimal (in the order mem_map0[0x02000004], mem_map7[0x02000005], mem_map7[0x02000006] of map 7) + +```f0bf01``` + # /write_byte command Writes one or multiple bytes of data from the emulated system at addresses provided using parameters. Multiple addresses can be written to in a single command. Returns "ok" on completion +The paramater map can be used to specify different address maps. This is currently only used in the NDS core where address map 7 is used for the ARM7 address map and 0 and 9 are used for the ARM9 address map. The default address map is 0. The map command only effects bytes read after the parameter and does not persist across API calls. + **Example (Write a single byte):** ```http://localhost:8080/write_byte?02000000=ff``` @@ -155,6 +169,20 @@ mem[0x02000002] = 0xcc; ```ok``` +**Example (Write multiple bytes from different maps ):** + +```http://localhost:8080/write_byte?02000000=ff&map=7&02000001=ee&02000002=cc``` + +**Result:** + +mem_map0[0x02000000] = 0xff; + +mem_map7[0x02000001] = 0xee; + +mem_map7[0x02000002] = 0xcc; + +```ok``` + # /input command Sends an input to the emulated system which will stay until a different input command assigns a new value. The parameters specify the input to set and the value to set it to. In general all inputs that have keybinds in the GUI can be set using this command. A full list of the valid input names and their current state is viewable with the /status command. An arbitrary number of inputs can be set using this command. Returns "ok" on completion. diff --git a/src/main.c b/src/main.c index 5d3b72d7a..630576193 100644 --- a/src/main.c +++ b/src/main.c @@ -4093,10 +4093,12 @@ uint8_t* se_hcs_callback(const char* cmd, const char** params, uint64_t* result_ }else if(strcmp(cmd,"/read_byte")==0){ uint64_t response_size = 0; char *response = NULL; + int address_map=0; while(*params){ - if(strcmp(params[0],"addr")==0){ + if(strcmp(params[0],"map")==0) address_map = atoi(params[1]); + else if(strcmp(params[0],"addr")==0){ uint64_t addr = se_hex_string_to_int(params[1]); - uint8_t byte = se_read_byte(addr,0); + uint8_t byte = se_read_byte(addr,address_map); const char *map="0123456789abcdef"; se_append_char_to_string(&response,&response_size,map[SB_BFE(byte,4,4)]); se_append_char_to_string(&response,&response_size,map[SB_BFE(byte,0,4)]); @@ -4110,10 +4112,14 @@ uint8_t* se_hcs_callback(const char* cmd, const char** params, uint64_t* result_ }else if(strcmp(cmd,"/write_byte")==0){ uint64_t response_size = 0; char *response = NULL; + int address_map = 0; while(*params){ - uint64_t addr = se_hex_string_to_int(params[0]); - uint8_t data = se_hex_string_to_int(params[1]); - se_write_byte(addr,0,data); + if(strcmp(params[0],"map")==0) address_map = atoi(params[1]); + else{ + uint64_t addr = se_hex_string_to_int(params[0]); + uint8_t data = se_hex_string_to_int(params[1]); + se_write_byte(addr,address_map,data); + } params+=2; } str_result="ok";