Log In  
Follow
Xeonic
Follow

Friendly Helpful Engineer.

This is a basic example i wrote to give a friend some help learning basic use of memory

--basic himem use for small games.
--credit, 𝘭uenardi 𝘭uigi 𝘥e 𝘱olo aka 𝘭egion𝘬𝘪𝘯
--𝘮𝘢𝘬𝘦 𝘴𝘶𝘳𝘦 you are currently in the working folder for these carts.
--this cart 'mem_1.p8' runs the code, 
--create a cart called mem_2.p8 contains 1 sprite we will load and put into himem.
--this copies a entire sprite sheet
--then we will draw the sprites both from this cart and mem2.p8 from himem. 

--dest = destination-
--src = source-
--len = length-

--0x0000 is the start of the graphics memory
--0x1000 is the end of the graphics memory
--0x8000 is the start of himem (high memory)
-- all of these are memory addresses

-- backup current gfx sheet in mem_1.p8 from memory address 0 to 0x1000 and put it down in himem at 0x8000  
This will fill himem from 0x8000 to 0x9000 with data from the sprite sheet already in the cart mem_1.p8
memcpy(0x8000, 0x0000, 0x1000)

-- here we copied to x8000 and we copied from x0000 to x1000 meaning the length is 0x1000  
-- meaning length + destination address = next open space = x9000
--         x1000  + x8000 = x9000

-- meaning here we copy or reload to the next available space = 0x9000

-- load data from a cart from the source address 0x000 to 0x1000 from mem_2.p8
-- just like mem cpy reload will copy to the specified addresse 0x9000
reload(0x9000, 0x0000, 0x1000,'mem_2.p8')

-- now we have both sheets in memory

-- sheet 1 is at 0x8000
-- and
-- sheet 2 is at 0x9000

function _draw()
cls(0) 

--load sprite sheet1 
--copies memory from 0x8000 to 0x0000 and dont forget the lenght 0x1000
memcpy(0x0000, 0x8000, 0x1000) 
--this replaces everything from 0x000 to 0x1000 from 0x8000

-- now we draw everything we want from that sheet
spr(1,32,64) in this case

--load sprite sheet2 
--copies memory from 0x9000 to 0x0000 and dont forget the lenght 0x1000
memcpy(0x0000, 0x9000, 0x1000) 
--this replaces everything from 0x000 to 0x1000 from 0x9000

-- now we draw everything we want from that sheet!
spr(1,96,64)
--done
end

--note that i used sprite index one on both sheets
-- this does impact performance a bit but works for small games that just need a few more sprites handy

see the discord link bellow for the zipped example
https://cdn.discordapp.com/attachments/938158730246254643/997921832227328131/himem_-_basic_example_how_to_use.zip

P#114416 2022-07-16 17:31 ( Edited 2022-07-17 04:16)

 
P#113749 [hidden by admin]

I need some real advice thats not "RNG click on everything till it sounds good"
That seems to be a real pain in the butt the only advice two music makers here have shared with me.

https://luchak.github.io/rp8/#running-rp-8
When i can easily make music with something like this blind folded but cant use it for music in my games

it's not than you cant make good music
the problem is 1 in 200 can
where as everyone on this planet CAN import a wave file IF pico-8 let you

P#113099 2022-06-13 06:22 ( Edited 2022-06-13 09:27)

someone shared a command for the pico-8 for holding the current palette so you can use the built editor if need be?
or was i mistaken?

P#112999 2022-06-10 20:22 ( Edited 2022-06-10 20:23)

The reason i am asking for this is several.

Most dev boards allow serial communication, the mighty serial port has stood the test of time.

I tend to mess about with loads of electronics and having access to a serial port from within pico-8 would be prenominal for robotics and making multiplayer games over serial work even if it only at a low emulated transfer rate.

I have linux machines that run pico-8 along with the logic for other gadgets but it makes me dependent or a raspberry pi and that does not have enough kick for my needs to gets stuff done so.
I run atom or zen chipsets with a modded build of windows as I tend to prefer the environment over linux, however this causes me to have to use some messy cabling and running 2 pieces of hardware to kill one rabbit and the needing to use hax for this pi to pass thru the laptop. it's not pretty.

Open CV alone tilts a pi and i cant afford chip for acceleration so i run my code for CV on a laptop chipset's gpu, something the pi can't do at a good speed without dying.

Honestly would understand fully if the developer feels that people will be breaking pico-8 if they could locally access com ports on pc's, it honestly should not be too hard to add.

Just allow a user to append a object to sync on the other side and then the host sends the updated object "table" across keeping it simple enough to use for most users.

Mostly be planning 2 case uses for this, controlling electronics without a raspberry pi and serial local over com gameplay.

There is a simple design for a usb>com to com>usb host cable most can make cheaply at home for this.
And am will to take on any responsibilities assisting users with debugging.

I hope that Lexaoffle will consider my idea if not today some time somewhere in the future.
Thank you for reading.

P#112929 2022-06-09 08:23 ( Edited 2022-06-09 09:48)

Follow Lexaloffle:        
Generated 2022-08-15 03:30:24 | 0.049s | Q:8