Skip to content
Kyuchumimo edited this page Jul 9, 2022 · 13 revisions

pmem

🧩 This function depends on json Python 3.x built-in module.

pmem index -> val32 Retrieve value from persistent memory file

pmem index val32 -> prior_val32 Save new value to persistent memory file, retrieve prior value.

Parameters

  • index : an index (0..255) into the persistent memory file.
  • val32 : the 32-bit integer value you want to store. Omit this parameter to read vs write.

Returns

  • val32 : the current/prior value saved to the specified memory slot.

Description

This function allows you to save and retrieve data in one of 256 individual 32-bit slots available in the file's persistent memory. This is useful for saving high-scores, level advancement or achievements. Data is stored as unsigned 32-bit integers (from 0 to 4294967295).

Example

_TIC["PALETTE"] = [[0x14,0x0c,0x1c], [0x44,0x24,0x34], [0x30,0x34,0x6d], [0x4e,0x4a,0x4e], [0x85,0x4c,0x30], [0x34,0x65,0x24], [0xd0,0x46,0x48], [0x75,0x71,0x61], [0x59,0x7d,0xce], [0xd2,0x7d,0x2c], [0x85,0x95,0xa1], [0x6d,0xaa,0x2c], [0xd2,0xaa,0x99], [0x6d,0xc2,0xca], [0xda,0xd4,0x5e], [0xde,0xee,0xd6]] #DB16
#pmem demo
#load saved value at slot zero and save it back
#incremented by 1
pmem(0,pmem(0)+1)

def TIC():
    cls()
    print("Started " + str(pmem(0)) + " times");
Clone this wiki locally