fix stuff

This commit is contained in:
Speedy_Lex 2025-07-01 23:54:48 +02:00
parent 786c2e8014
commit 9d9fc4c8fa
3 changed files with 13 additions and 5 deletions

View File

@ -60,7 +60,7 @@ void nn_drive_writeSector(nn_drive *drive, void *_, nn_component *component, nn_
int sector = nn_toInt(sectorValue);
size_t sector_size = drive->getSectorSize(component, drive->userdata);
nn_value bufValue = nn_getArgument(computer, 1);
char *buf = nn_toString(bufValue, &sector_size);
const char *buf = nn_toString(bufValue, &sector_size);
drive->writeSector(component, drive->userdata, sector, buf);
}
void nn_drive_readByte(nn_drive *drive, void *_, nn_component *component, nn_computer *computer) {
@ -71,7 +71,7 @@ void nn_drive_readByte(nn_drive *drive, void *_, nn_component *component, nn_com
size_t sector_offset = disk_offset % sector_size;
char buf[sector_size];
drive->readSector(component, drive->userdata, sector, &buf);
drive->readSector(component, drive->userdata, sector, buf);
nn_return(computer, nn_values_integer(buf[sector_offset]));
}
@ -85,7 +85,7 @@ void nn_drive_writeByte(nn_drive *drive, void *_, nn_component *component, nn_co
size_t sector_offset = disk_offset % sector_size;
char buf[sector_size];
drive->readSector(component, drive->userdata, sector, &buf);
drive->readSector(component, drive->userdata, sector, buf);
buf[sector_offset] = write;

View File

@ -51,6 +51,10 @@ const char *ne_location(nn_address address) {
size_t ne_eeprom_get(nn_component *component, void *_, char *buf) {
FILE *f = fopen(ne_location(nn_getComponentAddress(component)), "rb");
if (f == NULL) {
printf("couldn't read eeprom");
exit(1);
}
fseek(f, 0, SEEK_END);
size_t len = ftell(f);
fseek(f, 0, SEEK_SET);
@ -61,6 +65,10 @@ size_t ne_eeprom_get(nn_component *component, void *_, char *buf) {
void ne_eeprom_set(nn_component *component, void *_, const char *buf, size_t len) {
FILE *f = fopen(ne_location(nn_getComponentAddress(component)), "wb");
if (f == NULL) {
printf("couldn't write eeprom");
exit(1);
}
fwrite(buf, sizeof(char), len, f);
fclose(f);
}

View File

@ -505,7 +505,7 @@ int testLuaArch_unicode_sub(lua_State *L) {
}
char *sub = nn_unicode_char(points + start - 1, stop - start + 1);
char *res = testLuaArch_pushstring(L, sub);
const char *res = testLuaArch_pushstring(L, sub);
nn_free(sub);
nn_free(points);
if (!res) {
@ -531,7 +531,7 @@ int testLuaArch_unicode_char(lua_State *L) {
codepoints[i] = lua_tointeger(L, idx);
}
char *s = nn_unicode_char(codepoints, argc);
char *res = testLuaArch_pushstring(L, s);
const char *res = testLuaArch_pushstring(L, s);
nn_free(s);
nn_free(codepoints);
if (!res) {