Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
shinkarom committed Nov 7, 2021
1 parent 4e4d638 commit 51f517a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
35 changes: 29 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

> 64x32 is enough for everybody.
Luchok is a Fantasy Console inspired by Chip-8.
Luchok is a Fantasy Console inspired by Chip-8 (https://en.wikipedia.org/wiki/CHIP-8).

# Features

Screen: 64x32
Scripting: Lua
Sound: 440Hz square wave
Controls: 16 buttons, labeled from 0 to F
* Screen: 64x32

* Scripting: Lua

* Sound: 440Hz square wave

* Controls: 16 buttons, labeled from 0 to F


# Building
Building luchok requires:
Expand All @@ -18,7 +22,26 @@ Building luchok requires:
* liblua5.4-dev

# Usage
How to use it.
The games for Luchok are written in Lua. (I prefer the .luchok extension, but the engine does not care).

Every frame (60 per second) the function `vblank()` is called.

The API for the fantasy console is:

* `cls()` - clears the screen.
* `draw(sprite, x, y)` - draw the array `sprite` at `x` (0-63) and `y` (0-31).
* `draw(sprite, x, y, start, len)` - draw the array `sprite` (`len` (0-31) bytes starting from index `start`) at `x` (0-63) and `y` (0-31).
* `rnd(limit)` - generate a random integer from 0 to `limit` (0-255).
* `key_pressed(num)` - check if the specified key (0-15) is pressed at this frame.
* `key_released(num)` - check if the specified key (0-15) has been released.
* `bcd(num)` - splits the specified number (0-255), into array of its digits
* `get_sprite(num)` - gets the built-in sprite for the specified number (0-255)
* `delay_timer` (0-255) - decrements every frame until it hits 0
* `sound_timer` (0-255) - decrements every frame until it hits 0, each frame it's not 0 a buzzer sounds

# License
GPL 3.


# Author
Roman "shinkarom" Shynkarenko (https://shinkarom.github.io).
6 changes: 6 additions & 0 deletions source/script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ void CallVBlank(){
void ProcessDelayTimer(){
lua_getglobal(lua, DELAY_TIMER_VARIABLE);
delay_timer = lua_tointeger(lua, -1);
if(delay_timer < -255 || delay_timer > 255){
luaL_error(lua, "delay_timer must be from 0 to 255");
}
lua_pop(lua, 1);

if(delay_timer > 0){
Expand All @@ -255,6 +258,9 @@ void ProcessDelayTimer(){
void ProcessSoundTimer(){
lua_getglobal(lua, SOUND_TIMER_VARIABLE);
sound_timer = lua_tointeger(lua, -1);
if(sound_timer < -255 || sound_timer > 255){
luaL_error(lua, "sound_timer must be from 0 to 255");
}
lua_pop(lua, 1);

if(sound_timer > 0){
Expand Down

0 comments on commit 51f517a

Please sign in to comment.