SprPoP: HDD-раскладка и пути от каталога EXE
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "pop_pace.h"
|
||||
#include "pop_timer.h"
|
||||
#include "sprpop_cold.h"
|
||||
#include "_pop_file.h"
|
||||
|
||||
#define QS_VERSION 4
|
||||
#define QS_SAVE 1
|
||||
@@ -154,6 +155,7 @@ static int8_t qs_save(uint8_t page)
|
||||
uint8_t tail[4];
|
||||
const uint8_t h[7]={'P','O','P','Q',QS_VERSION,pop_current_level,0};
|
||||
uint16_t size;
|
||||
int rc;
|
||||
qs_init(&io,page,QS_LIMIT,0,0);
|
||||
pop_qs_raw_put(&io,h,sizeof(h));
|
||||
qs_payload(&io);
|
||||
@@ -162,14 +164,18 @@ static int8_t qs_save(uint8_t page)
|
||||
tail[2]=(uint8_t)io.checksum; tail[3]=(uint8_t)(io.checksum >> 8);
|
||||
pop_qs_raw_put(&io,tail,4); size=(uint16_t)(io.pos-QS_BASE);
|
||||
if (io.failed) return -1;
|
||||
unlink("POP.NEW");
|
||||
if (bank_save_file(page,QS_BASE,"POP.NEW",size) != size) {
|
||||
unlink("POP.NEW"); return -1;
|
||||
POP_PATH_CALL(rc, unlink("POP.NEW"));
|
||||
POP_PATH_CALL(rc, bank_save_file(page,QS_BASE,"POP.NEW",size));
|
||||
if (rc != size) {
|
||||
POP_PATH_CALL(rc, unlink("POP.NEW"));
|
||||
return -1;
|
||||
}
|
||||
unlink("POP.BAK");
|
||||
(void)rename("POP.SAV", "POP.BAK");
|
||||
if (rename("POP.NEW", "POP.SAV") != 0) {
|
||||
(void)rename("POP.BAK", "POP.SAV"); return -1;
|
||||
POP_PATH_CALL(rc, unlink("POP.BAK"));
|
||||
POP_PATH_CALL(rc, rename("POP.SAV", "POP.BAK"));
|
||||
POP_PATH_CALL(rc, rename("POP.NEW", "POP.SAV"));
|
||||
if (rc != 0) {
|
||||
POP_PATH_CALL(rc, rename("POP.BAK", "POP.SAV"));
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -178,7 +184,8 @@ static int8_t qs_load_one(const char *name, uint8_t page)
|
||||
{
|
||||
uint8_t level;
|
||||
uint16_t payload_size;
|
||||
int size=bank_load_file(page,QS_BASE,name,QS_LIMIT);
|
||||
int size;
|
||||
POP_PATH_CALL(size, bank_load_file(page,QS_BASE,name,QS_LIMIT));
|
||||
if (size <= 0 || !qs_validate_page(page,(uint16_t)size,&level,
|
||||
&payload_size)) return -1;
|
||||
if (level != pop_current_level) {
|
||||
@@ -205,11 +212,11 @@ uint8_t pop_qsave_probe(void) __banked
|
||||
page = mem_get_page(blk, 0);
|
||||
gfx_w0_page_prepare(page);
|
||||
|
||||
size = bank_load_file(page, QS_BASE, "POP.SAV", QS_LIMIT);
|
||||
POP_PATH_CALL(size, bank_load_file(page, QS_BASE, "POP.SAV", QS_LIMIT));
|
||||
if (size > 0 && qs_validate_page(page, (uint16_t)size, &level,
|
||||
&payload_size))
|
||||
slots |= POP_QS_SLOT_SAVE;
|
||||
size = bank_load_file(page, QS_BASE, "POP.BAK", QS_LIMIT);
|
||||
POP_PATH_CALL(size, bank_load_file(page, QS_BASE, "POP.BAK", QS_LIMIT));
|
||||
if (size > 0 && qs_validate_page(page, (uint16_t)size, &level,
|
||||
&payload_size))
|
||||
slots |= POP_QS_SLOT_BACKUP;
|
||||
|
||||
Reference in New Issue
Block a user