Application Development Overview
The development application uses a text program with a .clx extension, and the program contains specifications/scripts/data. Run debugging on the host, and automatically generate a binary format file for deployment to the device.
Noun
- bios : System components, used to switch cartridges and set configurations.
- cartridge : Cartridge, a function box, used to represent an application.
- setting : configuration function.
BIOS
- Control all hardware drivers.
- Operate switching between cartridges.
- Control the life cycle and state of the cartridge.
- Control background services: life cycle, data access.
Background Services
- Multiple services built into the system.
- Cartridge can register background service.
- You can access the data of the background service and initiate a request to the background service through the key.
- Only the background service and the currently used cartridge can be run, other cartridges will be suspended or released.
Application Development File Format
An example of a standard file:
coloX-4
version 1
style:game
name:test001
author:tester
desc:this is a demo
__lua__
function _draw()
cls()
print('this is a demo',10,50,red)
end
__gfx__
__gff__
__map__
__sfx__
__music__
coloX-4 Indicates the device specification corresponding to the application, and different specifications correspond to different resolutions/number of colors. version Indicates the minimum version of the device specification required by the application. style/name/author/desc It's text information.
__?__ Represents various data segments
__lua__
Code area, which contains lua scripts, you can use #include filename to include external script files, which is convenient for editing with external editors, or include public function files.
You can use #blob filename to define a lua string variable, which means that the file content is directly converted into a lua string.
You can use #blob :z:1 filename to define a lua string variable, went is compressed and directly converted into a lua sthich means that the file contring.
You can use #blob :za:2048 filename to define a lua string variable array, which means to divide the file content into 2048 bytes, and then compress it separately and directly convert it into a lua string array.
- z can be replaced by e/g to indicate different compression algorithms, e indicates adpcm audio compression, g indicates g711a audio compression, e/g is used to conveniently provide audio data to the wave interface.
The following example defines the temp.png image content as a lua string variable and loads it as an image:
local tempimg=
#blob temp.png
local png=img_load(tempimg)
function _draw()
cls(dark_green)
img_draw(png,0,0,1)
--img_drawex(png,0,0,1,100,100,40,40)
end
The following example splits the audio.pcm audio into an array and compresses it with adpcm.
local tempimg={
#blob :ea:22050: audio.pcm
}
When the application is running, it will look for specific functions to run at specific stages.
function _init() end -- run once after the app loads
function _update() end -- run once per frame when the app is active
function _draw() end -- When the application is activated, it runs once when the canvas needs to be refreshed (basically once per frame)
function _idle_update() end -- run once per frame when the application is idle
function _idle_draw() end -- In the idle state of the application, it runs once when the canvas needs to be refreshed (basically once per frame)
function _svcind(seq,name,path) end --Monitor service data notification
__gfx__
sprite image data area, image data represented by a hexadecimal string, the maximum data length does not exceed the data length defined by the specification.
You can also use #include filename to include external text.
You can use #png filename to directly import png images, note that after using #png, other gfx data will be discarded.
Example:
__gfx__
#png png/bg.png
__gff__
Elf flag data, represented by a hexadecimal string, the maximum length does not exceed the number of elves defined in the specification.
You can also use #include filename to include external text.
__map__
Map data, represented by a hexadecimal string, the maximum length does not exceed the map size defined by the specification. Since each map element is 2-byte data, the data should be placed in a small-byte-first manner.
You can also use #include filename to include external text.
__sfx__
Sound effect data, represented by a hexadecimal string in a specific format, one sound effect definition per line, up to 64 lines.
Example: 002800001a0551c055180550c05513055000050000500005000050000500005000050000500005000050000500005000050000500005000050000500005000050000500005000050000500005000050000500005
You can also use #include filename to include external text.
__music__
Music data, represented by a hexadecimal string in a specific format.
Example:
__music__
00 00044208
00 00044108
00 00010304
00 00010304
01 00010203
00 00010203
00 00010305
00 00010306
00 00010305
00 00010306
00 00010245
02 00010243
You can also use #include filename to include external text.
__sfxd__ / __musicd__
Another format of sound effect data, represented by a hexadecimal string, stored directly according to the memory block.
You can also use #include filename to include external text.